sde_hw_catalog.c 149 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #define pr_fmt(fmt) "[drm:%s:%d] " fmt, __func__, __LINE__
  6. #include <linux/slab.h>
  7. #include <linux/of_address.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/soc/qcom/llcc-qcom.h>
  10. #include <linux/pm_qos.h>
  11. #include "sde_hw_mdss.h"
  12. #include "sde_hw_catalog.h"
  13. #include "sde_hw_catalog_format.h"
  14. #include "sde_kms.h"
  15. #include "sde_hw_uidle.h"
  16. #include "sde_connector.h"
  17. /*************************************************************
  18. * MACRO DEFINITION
  19. *************************************************************/
  20. /**
  21. * Max hardware block in certain hardware. For ex: sspp pipes
  22. * can have QSEED, pcc, igc, pa, csc, qos entries, etc. This count is
  23. * 64 based on software design. It should be increased if any of the
  24. * hardware block has more subblocks.
  25. */
  26. #define MAX_SDE_HW_BLK 64
  27. /* each entry will have register address and bit offset in that register */
  28. #define MAX_BIT_OFFSET 2
  29. /* max table size for dts property lists, increase if tables grow larger */
  30. #define MAX_SDE_DT_TABLE_SIZE 64
  31. /* default line width for sspp, mixer, ds (input), dsc, wb */
  32. #define DEFAULT_SDE_LINE_WIDTH 2048
  33. /* default output line width for ds */
  34. #define DEFAULT_SDE_OUTPUT_LINE_WIDTH 2560
  35. /* max mixer blend stages */
  36. #define DEFAULT_SDE_MIXER_BLENDSTAGES 7
  37. /*
  38. * max bank bit for macro tile and ubwc format.
  39. * this value is left shifted and written to register
  40. */
  41. #define DEFAULT_SDE_HIGHEST_BANK_BIT 0x02
  42. /* No UBWC */
  43. #define DEFAULT_SDE_UBWC_NONE 0x0
  44. /* default ubwc static config register value */
  45. #define DEFAULT_SDE_UBWC_STATIC 0x0
  46. /* default ubwc swizzle register value */
  47. #define DEFAULT_SDE_UBWC_SWIZZLE 0x0
  48. /* default ubwc macrotile mode value */
  49. #define DEFAULT_SDE_UBWC_MACROTILE_MODE 0x0
  50. /* default hardware block size if dtsi entry is not present */
  51. #define DEFAULT_SDE_HW_BLOCK_LEN 0x100
  52. /* total number of intf - dp, dsi, hdmi */
  53. #define INTF_COUNT 3
  54. #define MAX_UPSCALE_RATIO 20
  55. #define MAX_DOWNSCALE_RATIO 4
  56. #define SSPP_UNITY_SCALE 1
  57. #define MAX_DOWNSCALE_RATIO_INROT_NOPD_RT_NUMERATOR 11
  58. #define MAX_DOWNSCALE_RATIO_INROT_NOPD_RT_DENOMINATOR 5
  59. #define MAX_DOWNSCALE_RATIO_INROT_PD_RT_NUMERATOR 4
  60. #define MAX_DOWNSCALE_RATIO_INROT_PD_RT_DENOMINATOR 1
  61. #define MAX_DOWNSCALE_RATIO_INROT_NRT_DEFAULT 4
  62. #define MAX_PRE_ROT_HEIGHT_INLINE_ROT_DEFAULT 1088
  63. #define MAX_HORZ_DECIMATION 4
  64. #define MAX_VERT_DECIMATION 4
  65. #define MAX_SPLIT_DISPLAY_CTL 2
  66. #define MAX_PP_SPLIT_DISPLAY_CTL 1
  67. #define MDSS_BASE_OFFSET 0x0
  68. #define ROT_LM_OFFSET 3
  69. #define LINE_LM_OFFSET 5
  70. #define LINE_MODE_WB_OFFSET 2
  71. /**
  72. * these configurations are decided based on max mdp clock. It accounts
  73. * for max and min display resolution based on virtual hardware resource
  74. * support.
  75. */
  76. #define MAX_DISPLAY_HEIGHT_WITH_DECIMATION 2160
  77. #define MAX_DISPLAY_HEIGHT 5760
  78. #define MIN_DISPLAY_HEIGHT 0
  79. #define MIN_DISPLAY_WIDTH 0
  80. /* maximum XIN halt timeout in usec */
  81. #define VBIF_XIN_HALT_TIMEOUT 0x4000
  82. #define DEFAULT_PIXEL_RAM_SIZE (50 * 1024)
  83. /* access property value based on prop_type and hardware index */
  84. #define PROP_VALUE_ACCESS(p, i, j) ((p + i)->value[j])
  85. /*
  86. * access element within PROP_TYPE_BIT_OFFSET_ARRAYs based on prop_type,
  87. * hardware index and offset array index
  88. */
  89. #define PROP_BITVALUE_ACCESS(p, i, j, k) ((p + i)->bit_value[j][k])
  90. #define DEFAULT_SBUF_HEADROOM (20)
  91. #define DEFAULT_SBUF_PREFILL (128)
  92. /*
  93. * Default parameter values
  94. */
  95. #define DEFAULT_MAX_BW_HIGH 7000000
  96. #define DEFAULT_MAX_BW_LOW 7000000
  97. #define DEFAULT_UNDERSIZED_PREFILL_LINES 2
  98. #define DEFAULT_XTRA_PREFILL_LINES 2
  99. #define DEFAULT_DEST_SCALE_PREFILL_LINES 3
  100. #define DEFAULT_MACROTILE_PREFILL_LINES 4
  101. #define DEFAULT_YUV_NV12_PREFILL_LINES 8
  102. #define DEFAULT_LINEAR_PREFILL_LINES 1
  103. #define DEFAULT_DOWNSCALING_PREFILL_LINES 1
  104. #define DEFAULT_CORE_IB_FF "6.0"
  105. #define DEFAULT_CORE_CLK_FF "1.0"
  106. #define DEFAULT_COMP_RATIO_RT \
  107. "NV12/5/1/1.23 AB24/5/1/1.23 XB24/5/1/1.23"
  108. #define DEFAULT_COMP_RATIO_NRT \
  109. "NV12/5/1/1.25 AB24/5/1/1.25 XB24/5/1/1.25"
  110. #define DEFAULT_MAX_PER_PIPE_BW 2400000
  111. #define DEFAULT_AMORTIZABLE_THRESHOLD 25
  112. #define DEFAULT_MNOC_PORTS 2
  113. #define DEFAULT_AXI_BUS_WIDTH 32
  114. #define DEFAULT_CPU_MASK 0
  115. #define DEFAULT_CPU_DMA_LATENCY PM_QOS_DEFAULT_VALUE
  116. /* Uidle values */
  117. #define SDE_UIDLE_FAL10_EXIT_CNT 128
  118. #define SDE_UIDLE_FAL10_EXIT_DANGER 4
  119. #define SDE_UIDLE_FAL10_DANGER 6
  120. #define SDE_UIDLE_FAL10_TARGET_IDLE 50
  121. #define SDE_UIDLE_FAL1_TARGET_IDLE 40
  122. #define SDE_UIDLE_FAL1_MAX_THRESHOLD 15
  123. #define SDE_UIDLE_REV102_FAL1_MAX_THRESHOLD 255
  124. #define SDE_UIDLE_FAL10_THRESHOLD_60 12
  125. #define SDE_UIDLE_FAL10_THRESHOLD_90 13
  126. #define SDE_UIDLE_MAX_DWNSCALE 1500
  127. #define SDE_UIDLE_MAX_FPS_60 60
  128. #define SDE_UIDLE_MAX_FPS_90 90
  129. #define SDE_UIDLE_MAX_FPS_120 120
  130. #define SDE_UIDLE_MAX_FPS_240 240
  131. #define SSPP_GET_REGDMA_BASE(blk_base, top_off) ((blk_base) >= (top_off) ?\
  132. (blk_base) - (top_off) : (blk_base))
  133. /*************************************************************
  134. * DTSI PROPERTY INDEX
  135. *************************************************************/
  136. enum {
  137. SDE_HW_VERSION,
  138. SDE_HW_PROP_MAX,
  139. };
  140. enum {
  141. HW_OFF,
  142. HW_LEN,
  143. HW_DISP,
  144. HW_PROP_MAX,
  145. };
  146. enum sde_prop {
  147. SDE_OFF,
  148. SDE_LEN,
  149. SSPP_LINEWIDTH,
  150. VIG_SSPP_LINEWIDTH,
  151. SCALING_LINEWIDTH,
  152. MIXER_LINEWIDTH,
  153. MIXER_BLEND,
  154. WB_LINEWIDTH,
  155. WB_LINEWIDTH_LINEAR,
  156. BANK_BIT,
  157. UBWC_VERSION,
  158. UBWC_STATIC,
  159. UBWC_SWIZZLE,
  160. QSEED_SW_LIB_REV,
  161. QSEED_HW_VERSION,
  162. CSC_TYPE,
  163. PANIC_PER_PIPE,
  164. SRC_SPLIT,
  165. DIM_LAYER,
  166. SMART_DMA_REV,
  167. IDLE_PC,
  168. WAKEUP_WITH_TOUCH,
  169. DEST_SCALER,
  170. SMART_PANEL_ALIGN_MODE,
  171. MACROTILE_MODE,
  172. UBWC_BW_CALC_VERSION,
  173. PIPE_ORDER_VERSION,
  174. SEC_SID_MASK,
  175. BASE_LAYER,
  176. TRUSTED_VM_ENV,
  177. MAX_TRUSTED_VM_DISPLAYS,
  178. SDE_PROP_MAX,
  179. };
  180. enum {
  181. PERF_MAX_BW_LOW,
  182. PERF_MAX_BW_HIGH,
  183. PERF_MIN_CORE_IB,
  184. PERF_MIN_LLCC_IB,
  185. PERF_MIN_DRAM_IB,
  186. PERF_CORE_IB_FF,
  187. PERF_CORE_CLK_FF,
  188. PERF_COMP_RATIO_RT,
  189. PERF_COMP_RATIO_NRT,
  190. PERF_UNDERSIZED_PREFILL_LINES,
  191. PERF_DEST_SCALE_PREFILL_LINES,
  192. PERF_MACROTILE_PREFILL_LINES,
  193. PERF_YUV_NV12_PREFILL_LINES,
  194. PERF_LINEAR_PREFILL_LINES,
  195. PERF_DOWNSCALING_PREFILL_LINES,
  196. PERF_XTRA_PREFILL_LINES,
  197. PERF_AMORTIZABLE_THRESHOLD,
  198. PERF_NUM_MNOC_PORTS,
  199. PERF_AXI_BUS_WIDTH,
  200. PERF_CDP_SETTING,
  201. PERF_CPU_MASK,
  202. CPU_MASK_PERF,
  203. PERF_CPU_DMA_LATENCY,
  204. PERF_CPU_IRQ_LATENCY,
  205. PERF_PROP_MAX,
  206. };
  207. enum {
  208. QOS_REFRESH_RATES,
  209. QOS_DANGER_LUT,
  210. QOS_SAFE_LUT,
  211. QOS_CREQ_LUT,
  212. QOS_PROP_MAX,
  213. };
  214. enum {
  215. SSPP_OFF,
  216. SSPP_SIZE,
  217. SSPP_TYPE,
  218. SSPP_XIN,
  219. SSPP_CLK_CTRL,
  220. SSPP_CLK_STATUS,
  221. SSPP_SCALE_SIZE,
  222. SSPP_VIG_BLOCKS,
  223. SSPP_RGB_BLOCKS,
  224. SSPP_DMA_BLOCKS,
  225. SSPP_EXCL_RECT,
  226. SSPP_SMART_DMA,
  227. SSPP_MAX_PER_PIPE_BW,
  228. SSPP_MAX_PER_PIPE_BW_HIGH,
  229. SSPP_PROP_MAX,
  230. };
  231. enum {
  232. VIG_SUBBLOCK_INDEX,
  233. VIG_TOP_OFF,
  234. VIG_QSEED_OFF,
  235. VIG_QSEED_LEN,
  236. VIG_CSC_OFF,
  237. VIG_HSIC_PROP,
  238. VIG_MEMCOLOR_PROP,
  239. VIG_PCC_PROP,
  240. VIG_GAMUT_PROP,
  241. VIG_IGC_PROP,
  242. VIG_INVERSE_PMA,
  243. VIG_FP16_IGC_PROP,
  244. VIG_FP16_GC_PROP,
  245. VIG_FP16_CSC_PROP,
  246. VIG_FP16_UNMULT_PROP,
  247. VIG_PROP_MAX,
  248. };
  249. enum {
  250. RGB_SCALER_OFF,
  251. RGB_SCALER_LEN,
  252. RGB_PCC_PROP,
  253. RGB_PROP_MAX,
  254. };
  255. enum {
  256. DMA_SUBBLOCK_INDEX,
  257. DMA_TOP_OFF,
  258. DMA_IGC_PROP,
  259. DMA_GC_PROP,
  260. DMA_DGM_INVERSE_PMA,
  261. DMA_CSC_OFF,
  262. DMA_FP16_IGC_PROP,
  263. DMA_FP16_GC_PROP,
  264. DMA_FP16_CSC_PROP,
  265. DMA_FP16_UNMULT_PROP,
  266. DMA_PROP_MAX,
  267. };
  268. enum {
  269. INTF_OFF,
  270. INTF_LEN,
  271. INTF_PREFETCH,
  272. INTF_TYPE,
  273. INTF_TE_IRQ,
  274. INTF_PROP_MAX,
  275. };
  276. enum {
  277. PP_OFF,
  278. PP_LEN,
  279. PP_CWB,
  280. TE_OFF,
  281. TE_LEN,
  282. TE2_OFF,
  283. TE2_LEN,
  284. PP_SLAVE,
  285. DITHER_OFF,
  286. DITHER_LEN,
  287. DITHER_VER,
  288. PP_MERGE_3D_ID,
  289. PP_PROP_MAX,
  290. };
  291. enum {
  292. DSC_OFF,
  293. DSC_LEN,
  294. DSC_PAIR_MASK,
  295. DSC_REV,
  296. DSC_ENC,
  297. DSC_ENC_LEN,
  298. DSC_CTL,
  299. DSC_CTL_LEN,
  300. DSC_422,
  301. DSC_LINEWIDTH,
  302. DSC_PROP_MAX,
  303. };
  304. enum {
  305. VDC_OFF,
  306. VDC_LEN,
  307. VDC_REV,
  308. VDC_ENC,
  309. VDC_ENC_LEN,
  310. VDC_CTL,
  311. VDC_CTL_LEN,
  312. VDC_PROP_MAX,
  313. };
  314. enum {
  315. DS_TOP_OFF,
  316. DS_TOP_LEN,
  317. DS_TOP_INPUT_LINEWIDTH,
  318. DS_TOP_OUTPUT_LINEWIDTH,
  319. DS_TOP_PROP_MAX,
  320. };
  321. enum {
  322. DS_OFF,
  323. DS_LEN,
  324. DS_PROP_MAX,
  325. };
  326. enum {
  327. DSPP_TOP_OFF,
  328. DSPP_TOP_SIZE,
  329. DSPP_TOP_PROP_MAX,
  330. };
  331. enum {
  332. DSPP_OFF,
  333. DSPP_SIZE,
  334. DSPP_BLOCKS,
  335. DSPP_PROP_MAX,
  336. };
  337. enum {
  338. DSPP_IGC_PROP,
  339. DSPP_PCC_PROP,
  340. DSPP_GC_PROP,
  341. DSPP_HSIC_PROP,
  342. DSPP_MEMCOLOR_PROP,
  343. DSPP_SIXZONE_PROP,
  344. DSPP_GAMUT_PROP,
  345. DSPP_DITHER_PROP,
  346. DSPP_HIST_PROP,
  347. DSPP_VLUT_PROP,
  348. DSPP_BLOCKS_PROP_MAX,
  349. };
  350. enum {
  351. AD_OFF,
  352. AD_VERSION,
  353. AD_PROP_MAX,
  354. };
  355. enum {
  356. LTM_OFF,
  357. LTM_VERSION,
  358. LTM_PROP_MAX,
  359. };
  360. enum {
  361. RC_OFF,
  362. RC_LEN,
  363. RC_VERSION,
  364. RC_MEM_TOTAL_SIZE,
  365. RC_PROP_MAX,
  366. };
  367. enum {
  368. SPR_OFF,
  369. SPR_LEN,
  370. SPR_VERSION,
  371. SPR_PROP_MAX,
  372. };
  373. enum {
  374. DEMURA_OFF,
  375. DEMURA_LEN,
  376. DEMURA_VERSION,
  377. DEMURA_PROP_MAX,
  378. };
  379. enum {
  380. MIXER_OFF,
  381. MIXER_LEN,
  382. MIXER_PAIR_MASK,
  383. MIXER_BLOCKS,
  384. MIXER_DISP,
  385. MIXER_CWB,
  386. MIXER_DCWB,
  387. MIXER_PROP_MAX,
  388. };
  389. enum {
  390. MIXER_GC_PROP,
  391. MIXER_BLOCKS_PROP_MAX,
  392. };
  393. enum {
  394. MIXER_BLEND_OP_OFF,
  395. MIXER_BLEND_PROP_MAX,
  396. };
  397. enum {
  398. WB_OFF,
  399. WB_LEN,
  400. WB_ID,
  401. WB_XIN_ID,
  402. WB_CLK_CTRL,
  403. WB_CLK_STATUS,
  404. WB_PROP_MAX,
  405. };
  406. enum {
  407. VBIF_OFF,
  408. VBIF_LEN,
  409. VBIF_ID,
  410. VBIF_DEFAULT_OT_RD_LIMIT,
  411. VBIF_DEFAULT_OT_WR_LIMIT,
  412. VBIF_DYNAMIC_OT_RD_LIMIT,
  413. VBIF_DYNAMIC_OT_WR_LIMIT,
  414. VBIF_MEMTYPE_0,
  415. VBIF_MEMTYPE_1,
  416. VBIF_QOS_RT_REMAP,
  417. VBIF_QOS_NRT_REMAP,
  418. VBIF_QOS_CWB_REMAP,
  419. VBIF_QOS_LUTDMA_REMAP,
  420. VBIF_PROP_MAX,
  421. };
  422. enum {
  423. UIDLE_OFF,
  424. UIDLE_LEN,
  425. UIDLE_PROP_MAX,
  426. };
  427. enum {
  428. REG_DMA_OFF,
  429. REG_DMA_ID,
  430. REG_DMA_VERSION,
  431. REG_DMA_TRIGGER_OFF,
  432. REG_DMA_BROADCAST_DISABLED,
  433. REG_DMA_XIN_ID,
  434. REG_DMA_CLK_CTRL,
  435. REG_DMA_PROP_MAX
  436. };
  437. enum {
  438. NOISE_LAYER_OFF,
  439. NOISE_LAYER_VERSION,
  440. NOISEL_LAYER_PROP_MAX
  441. };
  442. /*************************************************************
  443. * dts property definition
  444. *************************************************************/
  445. enum prop_type {
  446. PROP_TYPE_BOOL,
  447. PROP_TYPE_U32,
  448. PROP_TYPE_U32_ARRAY,
  449. PROP_TYPE_STRING,
  450. PROP_TYPE_STRING_ARRAY,
  451. PROP_TYPE_BIT_OFFSET_ARRAY,
  452. PROP_TYPE_NODE,
  453. };
  454. struct sde_prop_type {
  455. /* use property index from enum property for readability purpose */
  456. u8 id;
  457. /* it should be property name based on dtsi documentation */
  458. char *prop_name;
  459. /**
  460. * if property is marked mandatory then it will fail parsing
  461. * when property is not present
  462. */
  463. u32 is_mandatory;
  464. /* property type based on "enum prop_type" */
  465. enum prop_type type;
  466. };
  467. struct sde_prop_value {
  468. u32 value[MAX_SDE_HW_BLK];
  469. u32 bit_value[MAX_SDE_HW_BLK][MAX_BIT_OFFSET];
  470. };
  471. /**
  472. * struct sde_dt_props - stores dts properties read from a sde_prop_type table
  473. * @exists: Array of bools indicating if the given prop name was present
  474. * @counts: Count of the number of valid values for the property
  475. * @values: Array storing the count[i] property values
  476. *
  477. * Must use the sde_[get|put]_dt_props APIs to allocate/free this object.
  478. */
  479. struct sde_dt_props {
  480. bool exists[MAX_SDE_DT_TABLE_SIZE];
  481. int counts[MAX_SDE_DT_TABLE_SIZE];
  482. struct sde_prop_value *values;
  483. };
  484. /*************************************************************
  485. * dts property list
  486. *************************************************************/
  487. static struct sde_prop_type sde_hw_prop[] = {
  488. {SDE_HW_VERSION, "qcom,sde-hw-version", false, PROP_TYPE_U32},
  489. };
  490. static struct sde_prop_type sde_prop[] = {
  491. {SDE_OFF, "qcom,sde-off", true, PROP_TYPE_U32},
  492. {SDE_LEN, "qcom,sde-len", false, PROP_TYPE_U32},
  493. {SSPP_LINEWIDTH, "qcom,sde-sspp-linewidth", false, PROP_TYPE_U32},
  494. {VIG_SSPP_LINEWIDTH, "qcom,sde-vig-sspp-linewidth", false, PROP_TYPE_U32},
  495. {SCALING_LINEWIDTH, "qcom,sde-scaling-linewidth", false, PROP_TYPE_U32},
  496. {MIXER_LINEWIDTH, "qcom,sde-mixer-linewidth", false, PROP_TYPE_U32},
  497. {MIXER_BLEND, "qcom,sde-mixer-blendstages", false, PROP_TYPE_U32},
  498. {WB_LINEWIDTH, "qcom,sde-wb-linewidth", false, PROP_TYPE_U32},
  499. {WB_LINEWIDTH_LINEAR, "qcom,sde-wb-linewidth-linear",
  500. false, PROP_TYPE_U32},
  501. {BANK_BIT, "qcom,sde-highest-bank-bit", false,
  502. PROP_TYPE_BIT_OFFSET_ARRAY},
  503. {UBWC_VERSION, "qcom,sde-ubwc-version", false, PROP_TYPE_U32},
  504. {UBWC_STATIC, "qcom,sde-ubwc-static", false, PROP_TYPE_U32},
  505. {UBWC_SWIZZLE, "qcom,sde-ubwc-swizzle", false, PROP_TYPE_U32},
  506. {QSEED_SW_LIB_REV, "qcom,sde-qseed-sw-lib-rev", false,
  507. PROP_TYPE_STRING},
  508. {QSEED_HW_VERSION, "qcom,sde-qseed-scalar-version", false,
  509. PROP_TYPE_U32},
  510. {CSC_TYPE, "qcom,sde-csc-type", false, PROP_TYPE_STRING},
  511. {PANIC_PER_PIPE, "qcom,sde-panic-per-pipe", false, PROP_TYPE_BOOL},
  512. {SRC_SPLIT, "qcom,sde-has-src-split", false, PROP_TYPE_BOOL},
  513. {DIM_LAYER, "qcom,sde-has-dim-layer", false, PROP_TYPE_BOOL},
  514. {SMART_DMA_REV, "qcom,sde-smart-dma-rev", false, PROP_TYPE_STRING},
  515. {IDLE_PC, "qcom,sde-has-idle-pc", false, PROP_TYPE_BOOL},
  516. {WAKEUP_WITH_TOUCH, "qcom,sde-wakeup-with-touch", false,
  517. PROP_TYPE_BOOL},
  518. {DEST_SCALER, "qcom,sde-has-dest-scaler", false, PROP_TYPE_BOOL},
  519. {SMART_PANEL_ALIGN_MODE, "qcom,sde-smart-panel-align-mode",
  520. false, PROP_TYPE_U32},
  521. {MACROTILE_MODE, "qcom,sde-macrotile-mode", false, PROP_TYPE_U32},
  522. {UBWC_BW_CALC_VERSION, "qcom,sde-ubwc-bw-calc-version", false,
  523. PROP_TYPE_U32},
  524. {PIPE_ORDER_VERSION, "qcom,sde-pipe-order-version", false,
  525. PROP_TYPE_U32},
  526. {SEC_SID_MASK, "qcom,sde-secure-sid-mask", false, PROP_TYPE_U32_ARRAY},
  527. {BASE_LAYER, "qcom,sde-mixer-stage-base-layer", false, PROP_TYPE_BOOL},
  528. {TRUSTED_VM_ENV, "qcom,sde-trusted-vm-env", false, PROP_TYPE_BOOL},
  529. {MAX_TRUSTED_VM_DISPLAYS, "qcom,sde-max-trusted-vm-displays", false,
  530. PROP_TYPE_U32},
  531. };
  532. static struct sde_prop_type sde_perf_prop[] = {
  533. {PERF_MAX_BW_LOW, "qcom,sde-max-bw-low-kbps", false, PROP_TYPE_U32},
  534. {PERF_MAX_BW_HIGH, "qcom,sde-max-bw-high-kbps", false, PROP_TYPE_U32},
  535. {PERF_MIN_CORE_IB, "qcom,sde-min-core-ib-kbps", false, PROP_TYPE_U32},
  536. {PERF_MIN_LLCC_IB, "qcom,sde-min-llcc-ib-kbps", false, PROP_TYPE_U32},
  537. {PERF_MIN_DRAM_IB, "qcom,sde-min-dram-ib-kbps", false, PROP_TYPE_U32},
  538. {PERF_CORE_IB_FF, "qcom,sde-core-ib-ff", false, PROP_TYPE_STRING},
  539. {PERF_CORE_CLK_FF, "qcom,sde-core-clk-ff", false, PROP_TYPE_STRING},
  540. {PERF_COMP_RATIO_RT, "qcom,sde-comp-ratio-rt", false,
  541. PROP_TYPE_STRING},
  542. {PERF_COMP_RATIO_NRT, "qcom,sde-comp-ratio-nrt", false,
  543. PROP_TYPE_STRING},
  544. {PERF_UNDERSIZED_PREFILL_LINES, "qcom,sde-undersizedprefill-lines",
  545. false, PROP_TYPE_U32},
  546. {PERF_DEST_SCALE_PREFILL_LINES, "qcom,sde-dest-scaleprefill-lines",
  547. false, PROP_TYPE_U32},
  548. {PERF_MACROTILE_PREFILL_LINES, "qcom,sde-macrotileprefill-lines",
  549. false, PROP_TYPE_U32},
  550. {PERF_YUV_NV12_PREFILL_LINES, "qcom,sde-yuv-nv12prefill-lines",
  551. false, PROP_TYPE_U32},
  552. {PERF_LINEAR_PREFILL_LINES, "qcom,sde-linearprefill-lines",
  553. false, PROP_TYPE_U32},
  554. {PERF_DOWNSCALING_PREFILL_LINES, "qcom,sde-downscalingprefill-lines",
  555. false, PROP_TYPE_U32},
  556. {PERF_XTRA_PREFILL_LINES, "qcom,sde-xtra-prefill-lines",
  557. false, PROP_TYPE_U32},
  558. {PERF_AMORTIZABLE_THRESHOLD, "qcom,sde-amortizable-threshold",
  559. false, PROP_TYPE_U32},
  560. {PERF_NUM_MNOC_PORTS, "qcom,sde-num-mnoc-ports",
  561. false, PROP_TYPE_U32},
  562. {PERF_AXI_BUS_WIDTH, "qcom,sde-axi-bus-width",
  563. false, PROP_TYPE_U32},
  564. {PERF_CDP_SETTING, "qcom,sde-cdp-setting", false,
  565. PROP_TYPE_U32_ARRAY},
  566. {PERF_CPU_MASK, "qcom,sde-qos-cpu-mask", false, PROP_TYPE_U32},
  567. {CPU_MASK_PERF, "qcom,sde-qos-cpu-mask-performance", false,
  568. PROP_TYPE_U32},
  569. {PERF_CPU_DMA_LATENCY, "qcom,sde-qos-cpu-dma-latency", false,
  570. PROP_TYPE_U32},
  571. {PERF_CPU_IRQ_LATENCY, "qcom,sde-qos-cpu-irq-latency", false,
  572. PROP_TYPE_U32},
  573. };
  574. static struct sde_prop_type sde_qos_prop[] = {
  575. {QOS_REFRESH_RATES, "qcom,sde-qos-refresh-rates", false,
  576. PROP_TYPE_U32_ARRAY},
  577. {QOS_DANGER_LUT, "qcom,sde-danger-lut", false, PROP_TYPE_U32_ARRAY},
  578. {QOS_SAFE_LUT, "qcom,sde-safe-lut", false, PROP_TYPE_U32_ARRAY},
  579. {QOS_CREQ_LUT, "qcom,sde-creq-lut", false, PROP_TYPE_U32_ARRAY},
  580. };
  581. static struct sde_prop_type sspp_prop[] = {
  582. {SSPP_OFF, "qcom,sde-sspp-off", true, PROP_TYPE_U32_ARRAY},
  583. {SSPP_SIZE, "qcom,sde-sspp-src-size", false, PROP_TYPE_U32},
  584. {SSPP_TYPE, "qcom,sde-sspp-type", true, PROP_TYPE_STRING_ARRAY},
  585. {SSPP_XIN, "qcom,sde-sspp-xin-id", true, PROP_TYPE_U32_ARRAY},
  586. {SSPP_CLK_CTRL, "qcom,sde-sspp-clk-ctrl", false,
  587. PROP_TYPE_BIT_OFFSET_ARRAY},
  588. {SSPP_CLK_STATUS, "qcom,sde-sspp-clk-status", false,
  589. PROP_TYPE_BIT_OFFSET_ARRAY},
  590. {SSPP_SCALE_SIZE, "qcom,sde-sspp-scale-size", false, PROP_TYPE_U32},
  591. {SSPP_VIG_BLOCKS, "qcom,sde-sspp-vig-blocks", false, PROP_TYPE_NODE},
  592. {SSPP_RGB_BLOCKS, "qcom,sde-sspp-rgb-blocks", false, PROP_TYPE_NODE},
  593. {SSPP_DMA_BLOCKS, "qcom,sde-sspp-dma-blocks", false, PROP_TYPE_NODE},
  594. {SSPP_EXCL_RECT, "qcom,sde-sspp-excl-rect", false, PROP_TYPE_U32_ARRAY},
  595. {SSPP_SMART_DMA, "qcom,sde-sspp-smart-dma-priority", false,
  596. PROP_TYPE_U32_ARRAY},
  597. {SSPP_MAX_PER_PIPE_BW, "qcom,sde-max-per-pipe-bw-kbps", false,
  598. PROP_TYPE_U32_ARRAY},
  599. {SSPP_MAX_PER_PIPE_BW_HIGH, "qcom,sde-max-per-pipe-bw-high-kbps", false,
  600. PROP_TYPE_U32_ARRAY},
  601. };
  602. static struct sde_prop_type vig_prop[] = {
  603. [VIG_SUBBLOCK_INDEX] = {VIG_SUBBLOCK_INDEX, "cell-index", false,
  604. PROP_TYPE_U32},
  605. [VIG_TOP_OFF] = {VIG_TOP_OFF, "qcom,sde-vig-top-off", false,
  606. PROP_TYPE_U32},
  607. [VIG_QSEED_OFF] = {VIG_QSEED_OFF, "qcom,sde-vig-qseed-off", false,
  608. PROP_TYPE_U32},
  609. [VIG_QSEED_LEN] = {VIG_QSEED_LEN, "qcom,sde-vig-qseed-size", false,
  610. PROP_TYPE_U32},
  611. [VIG_CSC_OFF] = {VIG_CSC_OFF, "qcom,sde-vig-csc-off", false,
  612. PROP_TYPE_U32},
  613. [VIG_HSIC_PROP] = {VIG_HSIC_PROP, "qcom,sde-vig-hsic", false,
  614. PROP_TYPE_U32_ARRAY},
  615. [VIG_MEMCOLOR_PROP] = {VIG_MEMCOLOR_PROP, "qcom,sde-vig-memcolor",
  616. false, PROP_TYPE_U32_ARRAY},
  617. [VIG_PCC_PROP] = {VIG_PCC_PROP, "qcom,sde-vig-pcc", false,
  618. PROP_TYPE_U32_ARRAY},
  619. [VIG_GAMUT_PROP] = {VIG_GAMUT_PROP, "qcom,sde-vig-gamut", false,
  620. PROP_TYPE_U32_ARRAY},
  621. [VIG_IGC_PROP] = {VIG_IGC_PROP, "qcom,sde-vig-igc", false,
  622. PROP_TYPE_U32_ARRAY},
  623. [VIG_INVERSE_PMA] = {VIG_INVERSE_PMA, "qcom,sde-vig-inverse-pma", false,
  624. PROP_TYPE_BOOL},
  625. [VIG_FP16_IGC_PROP] = {VIG_FP16_IGC_PROP, "qcom,sde-fp16-igc", false,
  626. PROP_TYPE_U32_ARRAY},
  627. [VIG_FP16_GC_PROP] = {VIG_FP16_GC_PROP, "qcom,sde-fp16-gc", false,
  628. PROP_TYPE_U32_ARRAY},
  629. [VIG_FP16_CSC_PROP] = {VIG_FP16_CSC_PROP, "qcom,sde-fp16-csc", false,
  630. PROP_TYPE_U32_ARRAY},
  631. [VIG_FP16_UNMULT_PROP] = {VIG_FP16_UNMULT_PROP, "qcom,sde-fp16-unmult",
  632. false, PROP_TYPE_U32_ARRAY},
  633. };
  634. static struct sde_prop_type rgb_prop[] = {
  635. {RGB_SCALER_OFF, "qcom,sde-rgb-scaler-off", false, PROP_TYPE_U32},
  636. {RGB_SCALER_LEN, "qcom,sde-rgb-scaler-size", false, PROP_TYPE_U32},
  637. {RGB_PCC_PROP, "qcom,sde-rgb-pcc", false, PROP_TYPE_U32_ARRAY},
  638. };
  639. static struct sde_prop_type dma_prop[] = {
  640. [DMA_SUBBLOCK_INDEX] = {DMA_SUBBLOCK_INDEX, "cell-index", false,
  641. PROP_TYPE_U32},
  642. [DMA_TOP_OFF] = {DMA_TOP_OFF, "qcom,sde-dma-top-off", false,
  643. PROP_TYPE_U32},
  644. [DMA_IGC_PROP] = {DMA_IGC_PROP, "qcom,sde-dma-igc", false,
  645. PROP_TYPE_U32_ARRAY},
  646. [DMA_GC_PROP] = {DMA_GC_PROP, "qcom,sde-dma-gc", false,
  647. PROP_TYPE_U32_ARRAY},
  648. [DMA_DGM_INVERSE_PMA] = {DMA_DGM_INVERSE_PMA,
  649. "qcom,sde-dma-inverse-pma", false, PROP_TYPE_BOOL},
  650. [DMA_CSC_OFF] = {DMA_CSC_OFF, "qcom,sde-dma-csc-off", false,
  651. PROP_TYPE_U32},
  652. [DMA_FP16_IGC_PROP] = {DMA_FP16_IGC_PROP, "qcom,sde-fp16-igc", false,
  653. PROP_TYPE_U32_ARRAY},
  654. [DMA_FP16_GC_PROP] = {DMA_FP16_GC_PROP, "qcom,sde-fp16-gc", false,
  655. PROP_TYPE_U32_ARRAY},
  656. [DMA_FP16_CSC_PROP] = {DMA_FP16_CSC_PROP, "qcom,sde-fp16-csc", false,
  657. PROP_TYPE_U32_ARRAY},
  658. [DMA_FP16_UNMULT_PROP] = {DMA_FP16_UNMULT_PROP, "qcom,sde-fp16-unmult",
  659. false, PROP_TYPE_U32_ARRAY},
  660. };
  661. static struct sde_prop_type ctl_prop[] = {
  662. {HW_OFF, "qcom,sde-ctl-off", true, PROP_TYPE_U32_ARRAY},
  663. {HW_LEN, "qcom,sde-ctl-size", false, PROP_TYPE_U32},
  664. {HW_DISP, "qcom,sde-ctl-display-pref", false, PROP_TYPE_STRING_ARRAY},
  665. };
  666. struct sde_prop_type mixer_blend_prop[] = {
  667. {MIXER_BLEND_OP_OFF, "qcom,sde-mixer-blend-op-off", true,
  668. PROP_TYPE_U32_ARRAY},
  669. };
  670. static struct sde_prop_type mixer_prop[] = {
  671. {MIXER_OFF, "qcom,sde-mixer-off", true, PROP_TYPE_U32_ARRAY},
  672. {MIXER_LEN, "qcom,sde-mixer-size", false, PROP_TYPE_U32},
  673. {MIXER_PAIR_MASK, "qcom,sde-mixer-pair-mask", true,
  674. PROP_TYPE_U32_ARRAY},
  675. {MIXER_BLOCKS, "qcom,sde-mixer-blocks", false, PROP_TYPE_NODE},
  676. {MIXER_DISP, "qcom,sde-mixer-display-pref", false,
  677. PROP_TYPE_STRING_ARRAY},
  678. {MIXER_CWB, "qcom,sde-mixer-cwb-pref", false,
  679. PROP_TYPE_STRING_ARRAY},
  680. {MIXER_DCWB, "qcom,sde-mixer-dcwb-pref", false,
  681. PROP_TYPE_STRING_ARRAY},
  682. };
  683. static struct sde_prop_type mixer_blocks_prop[] = {
  684. {MIXER_GC_PROP, "qcom,sde-mixer-gc", false, PROP_TYPE_U32_ARRAY},
  685. };
  686. static struct sde_prop_type dspp_top_prop[] = {
  687. {DSPP_TOP_OFF, "qcom,sde-dspp-top-off", true, PROP_TYPE_U32},
  688. {DSPP_TOP_SIZE, "qcom,sde-dspp-top-size", false, PROP_TYPE_U32},
  689. };
  690. static struct sde_prop_type dspp_prop[] = {
  691. {DSPP_OFF, "qcom,sde-dspp-off", true, PROP_TYPE_U32_ARRAY},
  692. {DSPP_SIZE, "qcom,sde-dspp-size", false, PROP_TYPE_U32},
  693. {DSPP_BLOCKS, "qcom,sde-dspp-blocks", false, PROP_TYPE_NODE},
  694. };
  695. static struct sde_prop_type dspp_blocks_prop[] = {
  696. {DSPP_IGC_PROP, "qcom,sde-dspp-igc", false, PROP_TYPE_U32_ARRAY},
  697. {DSPP_PCC_PROP, "qcom,sde-dspp-pcc", false, PROP_TYPE_U32_ARRAY},
  698. {DSPP_GC_PROP, "qcom,sde-dspp-gc", false, PROP_TYPE_U32_ARRAY},
  699. {DSPP_HSIC_PROP, "qcom,sde-dspp-hsic", false, PROP_TYPE_U32_ARRAY},
  700. {DSPP_MEMCOLOR_PROP, "qcom,sde-dspp-memcolor", false,
  701. PROP_TYPE_U32_ARRAY},
  702. {DSPP_SIXZONE_PROP, "qcom,sde-dspp-sixzone", false,
  703. PROP_TYPE_U32_ARRAY},
  704. {DSPP_GAMUT_PROP, "qcom,sde-dspp-gamut", false, PROP_TYPE_U32_ARRAY},
  705. {DSPP_DITHER_PROP, "qcom,sde-dspp-dither", false, PROP_TYPE_U32_ARRAY},
  706. {DSPP_HIST_PROP, "qcom,sde-dspp-hist", false, PROP_TYPE_U32_ARRAY},
  707. {DSPP_VLUT_PROP, "qcom,sde-dspp-vlut", false, PROP_TYPE_U32_ARRAY},
  708. };
  709. static struct sde_prop_type ad_prop[] = {
  710. {AD_OFF, "qcom,sde-dspp-ad-off", false, PROP_TYPE_U32_ARRAY},
  711. {AD_VERSION, "qcom,sde-dspp-ad-version", false, PROP_TYPE_U32},
  712. };
  713. static struct sde_prop_type ltm_prop[] = {
  714. {LTM_OFF, "qcom,sde-dspp-ltm-off", false, PROP_TYPE_U32_ARRAY},
  715. {LTM_VERSION, "qcom,sde-dspp-ltm-version", false, PROP_TYPE_U32},
  716. };
  717. static struct sde_prop_type rc_prop[] = {
  718. {RC_OFF, "qcom,sde-dspp-rc-off", false, PROP_TYPE_U32_ARRAY},
  719. {RC_LEN, "qcom,sde-dspp-rc-size", false, PROP_TYPE_U32},
  720. {RC_VERSION, "qcom,sde-dspp-rc-version", false, PROP_TYPE_U32},
  721. {RC_MEM_TOTAL_SIZE, "qcom,sde-dspp-rc-mem-size", false, PROP_TYPE_U32},
  722. };
  723. static struct sde_prop_type spr_prop[] = {
  724. {SPR_OFF, "qcom,sde-dspp-spr-off", false, PROP_TYPE_U32_ARRAY},
  725. {SPR_LEN, "qcom,sde-dspp-spr-size", false, PROP_TYPE_U32},
  726. {SPR_VERSION, "qcom,sde-dspp-spr-version", false, PROP_TYPE_U32},
  727. };
  728. static struct sde_prop_type ds_top_prop[] = {
  729. {DS_TOP_OFF, "qcom,sde-dest-scaler-top-off", false, PROP_TYPE_U32},
  730. {DS_TOP_LEN, "qcom,sde-dest-scaler-top-size", false, PROP_TYPE_U32},
  731. {DS_TOP_INPUT_LINEWIDTH, "qcom,sde-max-dest-scaler-input-linewidth",
  732. false, PROP_TYPE_U32},
  733. {DS_TOP_OUTPUT_LINEWIDTH, "qcom,sde-max-dest-scaler-output-linewidth",
  734. false, PROP_TYPE_U32},
  735. };
  736. static struct sde_prop_type ds_prop[] = {
  737. {DS_OFF, "qcom,sde-dest-scaler-off", false, PROP_TYPE_U32_ARRAY},
  738. {DS_LEN, "qcom,sde-dest-scaler-size", false, PROP_TYPE_U32},
  739. };
  740. static struct sde_prop_type pp_prop[] = {
  741. {PP_OFF, "qcom,sde-pp-off", true, PROP_TYPE_U32_ARRAY},
  742. {PP_LEN, "qcom,sde-pp-size", false, PROP_TYPE_U32},
  743. {PP_CWB, "qcom,sde-pp-cwb", false, PROP_TYPE_U32_ARRAY},
  744. {TE_OFF, "qcom,sde-te-off", false, PROP_TYPE_U32_ARRAY},
  745. {TE_LEN, "qcom,sde-te-size", false, PROP_TYPE_U32},
  746. {TE2_OFF, "qcom,sde-te2-off", false, PROP_TYPE_U32_ARRAY},
  747. {TE2_LEN, "qcom,sde-te2-size", false, PROP_TYPE_U32},
  748. {PP_SLAVE, "qcom,sde-pp-slave", false, PROP_TYPE_U32_ARRAY},
  749. {DITHER_OFF, "qcom,sde-dither-off", false, PROP_TYPE_U32_ARRAY},
  750. {DITHER_LEN, "qcom,sde-dither-size", false, PROP_TYPE_U32},
  751. {DITHER_VER, "qcom,sde-dither-version", false, PROP_TYPE_U32},
  752. {PP_MERGE_3D_ID, "qcom,sde-pp-merge-3d-id", false, PROP_TYPE_U32_ARRAY},
  753. };
  754. static struct sde_prop_type dsc_prop[] = {
  755. {DSC_OFF, "qcom,sde-dsc-off", false, PROP_TYPE_U32_ARRAY},
  756. {DSC_LEN, "qcom,sde-dsc-size", false, PROP_TYPE_U32},
  757. {DSC_PAIR_MASK, "qcom,sde-dsc-pair-mask", false, PROP_TYPE_U32_ARRAY},
  758. {DSC_REV, "qcom,sde-dsc-hw-rev", false, PROP_TYPE_STRING},
  759. {DSC_ENC, "qcom,sde-dsc-enc", false, PROP_TYPE_U32_ARRAY},
  760. {DSC_ENC_LEN, "qcom,sde-dsc-enc-size", false, PROP_TYPE_U32},
  761. {DSC_CTL, "qcom,sde-dsc-ctl", false, PROP_TYPE_U32_ARRAY},
  762. {DSC_CTL_LEN, "qcom,sde-dsc-ctl-size", false, PROP_TYPE_U32},
  763. {DSC_422, "qcom,sde-dsc-native422-supp", false, PROP_TYPE_U32_ARRAY},
  764. {DSC_LINEWIDTH, "qcom,sde-dsc-linewidth", false, PROP_TYPE_U32},
  765. };
  766. static struct sde_prop_type vdc_prop[] = {
  767. {VDC_OFF, "qcom,sde-vdc-off", false, PROP_TYPE_U32_ARRAY},
  768. {VDC_LEN, "qcom,sde-vdc-size", false, PROP_TYPE_U32},
  769. {VDC_REV, "qcom,sde-vdc-hw-rev", false, PROP_TYPE_STRING},
  770. {VDC_ENC, "qcom,sde-vdc-enc", false, PROP_TYPE_U32_ARRAY},
  771. {VDC_ENC_LEN, "qcom,sde-vdc-enc-size", false, PROP_TYPE_U32},
  772. {VDC_CTL, "qcom,sde-vdc-ctl", false, PROP_TYPE_U32_ARRAY},
  773. {VDC_CTL_LEN, "qcom,sde-vdc-ctl-size", false, PROP_TYPE_U32},
  774. };
  775. static struct sde_prop_type cdm_prop[] = {
  776. {HW_OFF, "qcom,sde-cdm-off", false, PROP_TYPE_U32_ARRAY},
  777. {HW_LEN, "qcom,sde-cdm-size", false, PROP_TYPE_U32},
  778. };
  779. static struct sde_prop_type intf_prop[] = {
  780. {INTF_OFF, "qcom,sde-intf-off", true, PROP_TYPE_U32_ARRAY},
  781. {INTF_LEN, "qcom,sde-intf-size", false, PROP_TYPE_U32},
  782. {INTF_PREFETCH, "qcom,sde-intf-max-prefetch-lines", false,
  783. PROP_TYPE_U32_ARRAY},
  784. {INTF_TYPE, "qcom,sde-intf-type", false, PROP_TYPE_STRING_ARRAY},
  785. {INTF_TE_IRQ, "qcom,sde-intf-tear-irq-off", false, PROP_TYPE_U32_ARRAY},
  786. };
  787. static struct sde_prop_type wb_prop[] = {
  788. {WB_OFF, "qcom,sde-wb-off", false, PROP_TYPE_U32_ARRAY},
  789. {WB_LEN, "qcom,sde-wb-size", false, PROP_TYPE_U32},
  790. {WB_ID, "qcom,sde-wb-id", false, PROP_TYPE_U32_ARRAY},
  791. {WB_XIN_ID, "qcom,sde-wb-xin-id", false, PROP_TYPE_U32_ARRAY},
  792. {WB_CLK_CTRL, "qcom,sde-wb-clk-ctrl", false,
  793. PROP_TYPE_BIT_OFFSET_ARRAY},
  794. {WB_CLK_STATUS, "qcom,sde-wb-clk-status", false,
  795. PROP_TYPE_BIT_OFFSET_ARRAY},
  796. };
  797. static struct sde_prop_type vbif_prop[] = {
  798. {VBIF_OFF, "qcom,sde-vbif-off", true, PROP_TYPE_U32_ARRAY},
  799. {VBIF_LEN, "qcom,sde-vbif-size", false, PROP_TYPE_U32},
  800. {VBIF_ID, "qcom,sde-vbif-id", false, PROP_TYPE_U32_ARRAY},
  801. {VBIF_DEFAULT_OT_RD_LIMIT, "qcom,sde-vbif-default-ot-rd-limit", false,
  802. PROP_TYPE_U32},
  803. {VBIF_DEFAULT_OT_WR_LIMIT, "qcom,sde-vbif-default-ot-wr-limit", false,
  804. PROP_TYPE_U32},
  805. {VBIF_DYNAMIC_OT_RD_LIMIT, "qcom,sde-vbif-dynamic-ot-rd-limit", false,
  806. PROP_TYPE_U32_ARRAY},
  807. {VBIF_DYNAMIC_OT_WR_LIMIT, "qcom,sde-vbif-dynamic-ot-wr-limit", false,
  808. PROP_TYPE_U32_ARRAY},
  809. {VBIF_MEMTYPE_0, "qcom,sde-vbif-memtype-0", false, PROP_TYPE_U32_ARRAY},
  810. {VBIF_MEMTYPE_1, "qcom,sde-vbif-memtype-1", false, PROP_TYPE_U32_ARRAY},
  811. {VBIF_QOS_RT_REMAP, "qcom,sde-vbif-qos-rt-remap", false,
  812. PROP_TYPE_U32_ARRAY},
  813. {VBIF_QOS_NRT_REMAP, "qcom,sde-vbif-qos-nrt-remap", false,
  814. PROP_TYPE_U32_ARRAY},
  815. {VBIF_QOS_CWB_REMAP, "qcom,sde-vbif-qos-cwb-remap", false,
  816. PROP_TYPE_U32_ARRAY},
  817. {VBIF_QOS_LUTDMA_REMAP, "qcom,sde-vbif-qos-lutdma-remap", false,
  818. PROP_TYPE_U32_ARRAY},
  819. };
  820. static struct sde_prop_type uidle_prop[] = {
  821. {UIDLE_OFF, "qcom,sde-uidle-off", false, PROP_TYPE_U32},
  822. {UIDLE_LEN, "qcom,sde-uidle-size", false, PROP_TYPE_U32},
  823. };
  824. static struct sde_prop_type reg_dma_prop[REG_DMA_PROP_MAX] = {
  825. [REG_DMA_OFF] = {REG_DMA_OFF, "qcom,sde-reg-dma-off", false,
  826. PROP_TYPE_U32_ARRAY},
  827. [REG_DMA_ID] = {REG_DMA_ID, "qcom,sde-reg-dma-id", false,
  828. PROP_TYPE_U32_ARRAY},
  829. [REG_DMA_VERSION] = {REG_DMA_VERSION, "qcom,sde-reg-dma-version",
  830. false, PROP_TYPE_U32},
  831. [REG_DMA_TRIGGER_OFF] = {REG_DMA_TRIGGER_OFF,
  832. "qcom,sde-reg-dma-trigger-off", false,
  833. PROP_TYPE_U32},
  834. [REG_DMA_BROADCAST_DISABLED] = {REG_DMA_BROADCAST_DISABLED,
  835. "qcom,sde-reg-dma-broadcast-disabled", false, PROP_TYPE_BOOL},
  836. [REG_DMA_XIN_ID] = {REG_DMA_XIN_ID,
  837. "qcom,sde-reg-dma-xin-id", false, PROP_TYPE_U32},
  838. [REG_DMA_CLK_CTRL] = {REG_DMA_CLK_CTRL,
  839. "qcom,sde-reg-dma-clk-ctrl", false, PROP_TYPE_BIT_OFFSET_ARRAY},
  840. };
  841. static struct sde_prop_type merge_3d_prop[] = {
  842. {HW_OFF, "qcom,sde-merge-3d-off", false, PROP_TYPE_U32_ARRAY},
  843. {HW_LEN, "qcom,sde-merge-3d-size", false, PROP_TYPE_U32},
  844. };
  845. static struct sde_prop_type qdss_prop[] = {
  846. {HW_OFF, "qcom,sde-qdss-off", false, PROP_TYPE_U32_ARRAY},
  847. {HW_LEN, "qcom,sde-qdss-size", false, PROP_TYPE_U32},
  848. };
  849. static struct sde_prop_type demura_prop[] = {
  850. [DEMURA_OFF] = {DEMURA_OFF, "qcom,sde-dspp-demura-off", false,
  851. PROP_TYPE_U32_ARRAY},
  852. [DEMURA_LEN] = {DEMURA_LEN, "qcom,sde-dspp-demura-size", false,
  853. PROP_TYPE_U32},
  854. [DEMURA_VERSION] = {DEMURA_VERSION, "qcom,sde-dspp-demura-version",
  855. false, PROP_TYPE_U32},
  856. };
  857. static struct sde_prop_type noise_layer_prop[] = {
  858. [NOISE_LAYER_OFF] = {NOISE_LAYER_OFF, "qcom,sde-lm-noise-off",
  859. false, PROP_TYPE_U32},
  860. [NOISE_LAYER_VERSION] = {NOISE_LAYER_VERSION,
  861. "qcom,sde-lm-noise-version", false, PROP_TYPE_U32},
  862. };
  863. /*************************************************************
  864. * static API list
  865. *************************************************************/
  866. static int _sde_lm_noise_parse_dt(struct device_node *np, struct sde_mdss_cfg *sde_cfg);
  867. static int _parse_dt_u32_handler(struct device_node *np,
  868. char *prop_name, u32 *offsets, int len, bool mandatory)
  869. {
  870. int rc = -EINVAL;
  871. if (len > MAX_SDE_HW_BLK) {
  872. SDE_ERROR(
  873. "prop: %s tries out of bound access for u32 array read len: %d\n",
  874. prop_name, len);
  875. return -E2BIG;
  876. }
  877. rc = of_property_read_u32_array(np, prop_name, offsets, len);
  878. if (rc && mandatory)
  879. SDE_ERROR("mandatory prop: %s u32 array read len:%d\n",
  880. prop_name, len);
  881. else if (rc)
  882. SDE_DEBUG("optional prop: %s u32 array read len:%d\n",
  883. prop_name, len);
  884. return rc;
  885. }
  886. static int _parse_dt_bit_offset(struct device_node *np,
  887. char *prop_name, struct sde_prop_value *prop_value, u32 prop_index,
  888. u32 count, bool mandatory)
  889. {
  890. int rc = 0, len, i, j;
  891. const u32 *arr;
  892. arr = of_get_property(np, prop_name, &len);
  893. if (arr) {
  894. len /= sizeof(u32);
  895. len &= ~0x1;
  896. if (len > (MAX_SDE_HW_BLK * MAX_BIT_OFFSET)) {
  897. SDE_ERROR(
  898. "prop: %s len: %d will lead to out of bound access\n",
  899. prop_name, len / MAX_BIT_OFFSET);
  900. return -E2BIG;
  901. }
  902. for (i = 0, j = 0; i < len; j++) {
  903. PROP_BITVALUE_ACCESS(prop_value, prop_index, j, 0) =
  904. be32_to_cpu(arr[i]);
  905. i++;
  906. PROP_BITVALUE_ACCESS(prop_value, prop_index, j, 1) =
  907. be32_to_cpu(arr[i]);
  908. i++;
  909. }
  910. } else {
  911. if (mandatory) {
  912. SDE_ERROR("error mandatory property '%s' not found\n",
  913. prop_name);
  914. rc = -EINVAL;
  915. } else {
  916. SDE_DEBUG("error optional property '%s' not found\n",
  917. prop_name);
  918. }
  919. }
  920. return rc;
  921. }
  922. static int _validate_dt_entry(struct device_node *np,
  923. struct sde_prop_type *sde_prop, u32 prop_size, int *prop_count,
  924. int *off_count)
  925. {
  926. int rc = 0, i, val;
  927. struct device_node *snp = NULL;
  928. if (off_count) {
  929. *off_count = of_property_count_u32_elems(np,
  930. sde_prop[0].prop_name);
  931. if ((*off_count > MAX_BLOCKS) || (*off_count < 0)) {
  932. if (sde_prop[0].is_mandatory) {
  933. SDE_ERROR(
  934. "invalid hw offset prop name:%s count: %d\n",
  935. sde_prop[0].prop_name, *off_count);
  936. rc = -EINVAL;
  937. }
  938. *off_count = 0;
  939. memset(prop_count, 0, sizeof(int) * prop_size);
  940. return rc;
  941. }
  942. }
  943. for (i = 0; i < prop_size; i++) {
  944. switch (sde_prop[i].type) {
  945. case PROP_TYPE_U32:
  946. rc = of_property_read_u32(np, sde_prop[i].prop_name,
  947. &val);
  948. if (!rc)
  949. prop_count[i] = 1;
  950. break;
  951. case PROP_TYPE_U32_ARRAY:
  952. prop_count[i] = of_property_count_u32_elems(np,
  953. sde_prop[i].prop_name);
  954. if (prop_count[i] < 0)
  955. rc = prop_count[i];
  956. break;
  957. case PROP_TYPE_STRING_ARRAY:
  958. prop_count[i] = of_property_count_strings(np,
  959. sde_prop[i].prop_name);
  960. if (prop_count[i] < 0)
  961. rc = prop_count[i];
  962. break;
  963. case PROP_TYPE_BIT_OFFSET_ARRAY:
  964. of_get_property(np, sde_prop[i].prop_name, &val);
  965. prop_count[i] = val / (MAX_BIT_OFFSET * sizeof(u32));
  966. break;
  967. case PROP_TYPE_NODE:
  968. snp = of_get_child_by_name(np,
  969. sde_prop[i].prop_name);
  970. if (!snp)
  971. rc = -EINVAL;
  972. break;
  973. case PROP_TYPE_BOOL:
  974. /**
  975. * No special handling for bool properties here.
  976. * They will always exist, with value indicating
  977. * if the given key is present or not.
  978. */
  979. prop_count[i] = 1;
  980. break;
  981. default:
  982. SDE_DEBUG("invalid property type:%d\n",
  983. sde_prop[i].type);
  984. break;
  985. }
  986. SDE_DEBUG(
  987. "prop id:%d prop name:%s prop type:%d prop_count:%d\n",
  988. i, sde_prop[i].prop_name,
  989. sde_prop[i].type, prop_count[i]);
  990. if (rc && sde_prop[i].is_mandatory &&
  991. ((sde_prop[i].type == PROP_TYPE_U32) ||
  992. (sde_prop[i].type == PROP_TYPE_NODE))) {
  993. SDE_ERROR("prop:%s not present\n",
  994. sde_prop[i].prop_name);
  995. goto end;
  996. } else if (sde_prop[i].type == PROP_TYPE_U32 ||
  997. sde_prop[i].type == PROP_TYPE_BOOL ||
  998. sde_prop[i].type == PROP_TYPE_NODE) {
  999. rc = 0;
  1000. continue;
  1001. }
  1002. if (off_count && (prop_count[i] != *off_count) &&
  1003. sde_prop[i].is_mandatory) {
  1004. SDE_ERROR(
  1005. "prop:%s count:%d is different compared to offset array:%d\n",
  1006. sde_prop[i].prop_name,
  1007. prop_count[i], *off_count);
  1008. rc = -EINVAL;
  1009. goto end;
  1010. } else if (off_count && prop_count[i] != *off_count) {
  1011. SDE_DEBUG(
  1012. "prop:%s count:%d is different compared to offset array:%d\n",
  1013. sde_prop[i].prop_name,
  1014. prop_count[i], *off_count);
  1015. rc = 0;
  1016. }
  1017. if (prop_count[i] < 0) {
  1018. prop_count[i] = 0;
  1019. if (sde_prop[i].is_mandatory) {
  1020. SDE_ERROR("prop:%s count:%d is negative\n",
  1021. sde_prop[i].prop_name, prop_count[i]);
  1022. rc = -EINVAL;
  1023. } else {
  1024. rc = 0;
  1025. SDE_DEBUG("prop:%s count:%d is negative\n",
  1026. sde_prop[i].prop_name, prop_count[i]);
  1027. }
  1028. }
  1029. }
  1030. end:
  1031. return rc;
  1032. }
  1033. static int _read_dt_entry(struct device_node *np,
  1034. struct sde_prop_type *sde_prop, u32 prop_size, int *prop_count,
  1035. bool *prop_exists,
  1036. struct sde_prop_value *prop_value)
  1037. {
  1038. int rc = 0, i, j;
  1039. for (i = 0; i < prop_size; i++) {
  1040. prop_exists[i] = true;
  1041. switch (sde_prop[i].type) {
  1042. case PROP_TYPE_U32:
  1043. rc = of_property_read_u32(np, sde_prop[i].prop_name,
  1044. &PROP_VALUE_ACCESS(prop_value, i, 0));
  1045. SDE_DEBUG(
  1046. "prop id:%d prop name:%s prop type:%d value:0x%x\n",
  1047. i, sde_prop[i].prop_name,
  1048. sde_prop[i].type,
  1049. PROP_VALUE_ACCESS(prop_value, i, 0));
  1050. if (rc)
  1051. prop_exists[i] = false;
  1052. break;
  1053. case PROP_TYPE_BOOL:
  1054. PROP_VALUE_ACCESS(prop_value, i, 0) =
  1055. of_property_read_bool(np,
  1056. sde_prop[i].prop_name);
  1057. SDE_DEBUG(
  1058. "prop id:%d prop name:%s prop type:%d value:0x%x\n",
  1059. i, sde_prop[i].prop_name,
  1060. sde_prop[i].type,
  1061. PROP_VALUE_ACCESS(prop_value, i, 0));
  1062. break;
  1063. case PROP_TYPE_U32_ARRAY:
  1064. rc = _parse_dt_u32_handler(np, sde_prop[i].prop_name,
  1065. &PROP_VALUE_ACCESS(prop_value, i, 0),
  1066. prop_count[i], sde_prop[i].is_mandatory);
  1067. if (rc && sde_prop[i].is_mandatory) {
  1068. SDE_ERROR(
  1069. "%s prop validation success but read failed\n",
  1070. sde_prop[i].prop_name);
  1071. prop_exists[i] = false;
  1072. goto end;
  1073. } else {
  1074. if (rc)
  1075. prop_exists[i] = false;
  1076. /* only for debug purpose */
  1077. SDE_DEBUG(
  1078. "prop id:%d prop name:%s prop type:%d",
  1079. i, sde_prop[i].prop_name,
  1080. sde_prop[i].type);
  1081. for (j = 0; j < prop_count[i]; j++)
  1082. SDE_DEBUG(" value[%d]:0x%x ", j,
  1083. PROP_VALUE_ACCESS(prop_value, i,
  1084. j));
  1085. SDE_DEBUG("\n");
  1086. }
  1087. break;
  1088. case PROP_TYPE_BIT_OFFSET_ARRAY:
  1089. rc = _parse_dt_bit_offset(np, sde_prop[i].prop_name,
  1090. prop_value, i, prop_count[i],
  1091. sde_prop[i].is_mandatory);
  1092. if (rc && sde_prop[i].is_mandatory) {
  1093. SDE_ERROR(
  1094. "%s prop validation success but read failed\n",
  1095. sde_prop[i].prop_name);
  1096. prop_exists[i] = false;
  1097. goto end;
  1098. } else {
  1099. if (rc)
  1100. prop_exists[i] = false;
  1101. SDE_DEBUG(
  1102. "prop id:%d prop name:%s prop type:%d",
  1103. i, sde_prop[i].prop_name,
  1104. sde_prop[i].type);
  1105. for (j = 0; j < prop_count[i]; j++)
  1106. SDE_DEBUG(
  1107. "count[%d]: bit:0x%x off:0x%x\n", j,
  1108. PROP_BITVALUE_ACCESS(prop_value,
  1109. i, j, 0),
  1110. PROP_BITVALUE_ACCESS(prop_value,
  1111. i, j, 1));
  1112. SDE_DEBUG("\n");
  1113. }
  1114. break;
  1115. case PROP_TYPE_NODE:
  1116. /* Node will be parsed in calling function */
  1117. rc = 0;
  1118. break;
  1119. default:
  1120. SDE_DEBUG("invalid property type:%d\n",
  1121. sde_prop[i].type);
  1122. break;
  1123. }
  1124. rc = 0;
  1125. }
  1126. end:
  1127. return rc;
  1128. }
  1129. /**
  1130. * sde_get_dt_props - allocate and return prop counts, exists & values arrays
  1131. * @np - device node
  1132. * @prop_max - <BLK>_PROP_MAX enum, this will be number of values allocated
  1133. * @sde_prop - pointer to prop table
  1134. * @prop_size - size of prop table
  1135. * @off_count - pointer to callers off_count
  1136. *
  1137. * @Returns - valid pointer or -ve error code (can never return NULL)
  1138. * If a non-NULL off_count pointer is given, the value it points to will be
  1139. * updated with the number of elements in the offset array (entry 0 in table).
  1140. * Caller MUST free this object using sde_put_dt_props after parsing values.
  1141. */
  1142. static struct sde_dt_props *sde_get_dt_props(struct device_node *np,
  1143. size_t prop_max, struct sde_prop_type *sde_prop,
  1144. u32 prop_size, u32 *off_count)
  1145. {
  1146. struct sde_dt_props *props;
  1147. int rc = -ENOMEM;
  1148. props = kzalloc(sizeof(*props), GFP_KERNEL);
  1149. if (!props)
  1150. return ERR_PTR(rc);
  1151. props->values = kcalloc(prop_max, sizeof(*props->values),
  1152. GFP_KERNEL);
  1153. if (!props->values)
  1154. goto free_props;
  1155. rc = _validate_dt_entry(np, sde_prop, prop_size, props->counts,
  1156. off_count);
  1157. if (rc)
  1158. goto free_vals;
  1159. rc = _read_dt_entry(np, sde_prop, prop_size, props->counts,
  1160. props->exists, props->values);
  1161. if (rc)
  1162. goto free_vals;
  1163. return props;
  1164. free_vals:
  1165. kfree(props->values);
  1166. free_props:
  1167. kfree(props);
  1168. return ERR_PTR(rc);
  1169. }
  1170. /* sde_put_dt_props - free an sde_dt_props object obtained with "get" */
  1171. static void sde_put_dt_props(struct sde_dt_props *props)
  1172. {
  1173. if (!props)
  1174. return;
  1175. kfree(props->values);
  1176. kfree(props);
  1177. }
  1178. static int _add_to_irq_offset_list(struct sde_mdss_cfg *sde_cfg,
  1179. enum sde_intr_hwblk_type blk_type, u32 instance, u32 offset)
  1180. {
  1181. struct sde_intr_irq_offsets *item = NULL;
  1182. bool err = false;
  1183. switch (blk_type) {
  1184. case SDE_INTR_HWBLK_TOP:
  1185. if (instance >= SDE_INTR_TOP_MAX)
  1186. err = true;
  1187. break;
  1188. case SDE_INTR_HWBLK_INTF:
  1189. if (instance >= INTF_MAX)
  1190. err = true;
  1191. break;
  1192. case SDE_INTR_HWBLK_AD4:
  1193. if (instance >= AD_MAX)
  1194. err = true;
  1195. break;
  1196. case SDE_INTR_HWBLK_INTF_TEAR:
  1197. if (instance >= INTF_MAX)
  1198. err = true;
  1199. break;
  1200. case SDE_INTR_HWBLK_LTM:
  1201. if (instance >= LTM_MAX)
  1202. err = true;
  1203. break;
  1204. default:
  1205. SDE_ERROR("invalid hwblk_type: %d", blk_type);
  1206. return -EINVAL;
  1207. }
  1208. if (err) {
  1209. SDE_ERROR("unable to map instance %d for blk type %d",
  1210. instance, blk_type);
  1211. return -EINVAL;
  1212. }
  1213. /* Check for existing list entry */
  1214. item = sde_hw_intr_list_lookup(sde_cfg, blk_type, instance);
  1215. if (IS_ERR_OR_NULL(item)) {
  1216. SDE_DEBUG("adding intr type %d idx %d offset 0x%x\n",
  1217. blk_type, instance, offset);
  1218. } else if (item->base_offset == offset) {
  1219. SDE_INFO("duplicate intr %d/%d offset 0x%x, skipping\n",
  1220. blk_type, instance, offset);
  1221. return 0;
  1222. } else {
  1223. SDE_ERROR("type %d, idx %d in list with offset 0x%x != 0x%x\n",
  1224. blk_type, instance, item->base_offset, offset);
  1225. return -EINVAL;
  1226. }
  1227. item = kzalloc(sizeof(*item), GFP_KERNEL);
  1228. if (!item) {
  1229. SDE_ERROR("memory allocation failed!\n");
  1230. return -ENOMEM;
  1231. }
  1232. INIT_LIST_HEAD(&item->list);
  1233. item->type = blk_type;
  1234. item->instance_idx = instance;
  1235. item->base_offset = offset;
  1236. list_add_tail(&item->list, &sde_cfg->irq_offset_list);
  1237. return 0;
  1238. }
  1239. /* VIG color management (VCM) feature setup */
  1240. static bool _sde_sspp_setup_vcm(struct sde_sspp_cfg *sspp,
  1241. const struct sde_dt_props *props, const char *name,
  1242. struct sde_pp_blk *blk, u32 type, u32 prop, bool versioned)
  1243. {
  1244. bool exists = props->exists[prop];
  1245. if (exists) {
  1246. blk->id = type;
  1247. blk->len = 0;
  1248. set_bit(type, (unsigned long *) &sspp->features_ext);
  1249. blk->base = PROP_VALUE_ACCESS(props->values, prop, 0);
  1250. blk->regdma_base = SSPP_GET_REGDMA_BASE(blk->base, sspp->sblk->top_off);
  1251. snprintf(blk->name, SDE_HW_BLK_NAME_LEN, "%s%u", name,
  1252. sspp->id - SSPP_VIG0);
  1253. if (versioned)
  1254. blk->version = PROP_VALUE_ACCESS(props->values,
  1255. prop, 1);
  1256. } else {
  1257. blk->id = 0;
  1258. }
  1259. return exists;
  1260. }
  1261. static void _sde_sspp_setup_vigs_pp(struct sde_dt_props *props,
  1262. struct sde_mdss_cfg *sde_cfg, struct sde_sspp_cfg *sspp)
  1263. {
  1264. struct sde_sspp_sub_blks *sblk = sspp->sblk;
  1265. if (!props)
  1266. return;
  1267. if (sde_cfg->csc_type == SDE_SSPP_CSC)
  1268. _sde_sspp_setup_vcm(sspp, props, "sspp_csc", &sblk->csc_blk,
  1269. SDE_SSPP_CSC, VIG_CSC_OFF, false);
  1270. else if (sde_cfg->csc_type == SDE_SSPP_CSC_10BIT)
  1271. _sde_sspp_setup_vcm(sspp, props, "sspp_csc", &sblk->csc_blk,
  1272. SDE_SSPP_CSC_10BIT, VIG_CSC_OFF, false);
  1273. _sde_sspp_setup_vcm(sspp, props, "sspp_hsic", &sblk->hsic_blk,
  1274. SDE_SSPP_HSIC, VIG_HSIC_PROP, true);
  1275. _sde_sspp_setup_vcm(sspp, props, "sspp_memcolor", &sblk->memcolor_blk,
  1276. SDE_SSPP_MEMCOLOR, VIG_MEMCOLOR_PROP, true);
  1277. _sde_sspp_setup_vcm(sspp, props, "sspp_pcc", &sblk->pcc_blk,
  1278. SDE_SSPP_PCC, VIG_PCC_PROP, true);
  1279. _sde_sspp_setup_vcm(sspp, props, "sspp_vig_gamut", &sblk->gamut_blk,
  1280. SDE_SSPP_VIG_GAMUT, VIG_GAMUT_PROP, true);
  1281. _sde_sspp_setup_vcm(sspp, props, "sspp_vig_igc", &sblk->igc_blk[0],
  1282. SDE_SSPP_VIG_IGC, VIG_IGC_PROP, true);
  1283. if (props->exists[VIG_INVERSE_PMA])
  1284. set_bit(SDE_SSPP_INVERSE_PMA, &sspp->features);
  1285. }
  1286. static int _sde_sspp_setup_vigs(struct device_node *np,
  1287. struct sde_mdss_cfg *sde_cfg)
  1288. {
  1289. int i = 0, j = 0, rc = 0;
  1290. struct sde_dt_props *props[SSPP_SUBBLK_COUNT_MAX] = {NULL, NULL};
  1291. struct sde_dt_props *props_tmp = NULL;
  1292. struct device_node *snp = NULL;
  1293. int vig_count = 0, vcm_count = 0;
  1294. const char *type;
  1295. snp = of_get_child_by_name(np, sspp_prop[SSPP_VIG_BLOCKS].prop_name);
  1296. if (!snp)
  1297. return 0;
  1298. /* Assume sub nodes are in rect order */
  1299. vcm_count = of_get_child_count(snp);
  1300. if (vcm_count > 0) {
  1301. struct device_node *vcm_snp;
  1302. if (vcm_count > SSPP_SUBBLK_COUNT_MAX) {
  1303. SDE_ERROR("exceeded max vcm sub-block count!");
  1304. vcm_count = SSPP_SUBBLK_COUNT_MAX;
  1305. }
  1306. for_each_child_of_node(snp, vcm_snp) {
  1307. props_tmp = sde_get_dt_props(vcm_snp,
  1308. VIG_PROP_MAX, vig_prop,
  1309. ARRAY_SIZE(vig_prop), NULL);
  1310. if (IS_ERR(props_tmp)) {
  1311. rc = PTR_ERR(props_tmp);
  1312. props_tmp = NULL;
  1313. goto end;
  1314. }
  1315. if (!props_tmp->exists[VIG_SUBBLOCK_INDEX]) {
  1316. SDE_ERROR("vcm rect index must be specified!");
  1317. goto end;
  1318. }
  1319. i = PROP_VALUE_ACCESS(props_tmp->values, VIG_SUBBLOCK_INDEX, 0);
  1320. if (i >= SSPP_SUBBLK_COUNT_MAX) {
  1321. SDE_ERROR("invalid vcm rect index: %d", i);
  1322. goto end;
  1323. } else if (props[i] != NULL) {
  1324. SDE_ERROR("vcm rect index must be unique! repeat: %d", i);
  1325. goto end;
  1326. }
  1327. props[i] = props_tmp;
  1328. props_tmp = NULL;
  1329. }
  1330. } else {
  1331. props[0] = sde_get_dt_props(snp, VIG_PROP_MAX, vig_prop,
  1332. ARRAY_SIZE(vig_prop), NULL);
  1333. }
  1334. for (i = 0; i < sde_cfg->sspp_count; ++i) {
  1335. struct sde_sspp_cfg *sspp = sde_cfg->sspp + i;
  1336. struct sde_sspp_sub_blks *sblk = sspp->sblk;
  1337. of_property_read_string_index(np,
  1338. sspp_prop[SSPP_TYPE].prop_name, i, &type);
  1339. if (strcmp(type, "vig"))
  1340. continue;
  1341. sblk->maxlinewidth = sde_cfg->vig_sspp_linewidth;
  1342. sblk->scaling_linewidth = sde_cfg->scaling_linewidth;
  1343. sblk->maxupscale = MAX_UPSCALE_RATIO;
  1344. sblk->maxdwnscale = MAX_DOWNSCALE_RATIO;
  1345. sspp->id = SSPP_VIG0 + vig_count;
  1346. snprintf(sspp->name, SDE_HW_BLK_NAME_LEN, "sspp_%u",
  1347. sspp->id - SSPP_VIG0);
  1348. sspp->clk_ctrl = SDE_CLK_CTRL_VIG0 + vig_count;
  1349. sspp->type = SSPP_TYPE_VIG;
  1350. set_bit(SDE_PERF_SSPP_QOS, &sspp->perf_features);
  1351. if (sde_cfg->vbif_qos_nlvl == 8)
  1352. set_bit(SDE_PERF_SSPP_QOS_8LVL, &sspp->perf_features);
  1353. vig_count++;
  1354. /* Obtain sub block top, or maintain backwards compatibility */
  1355. if (props[0] && props[0]->exists[VIG_TOP_OFF])
  1356. sblk->top_off = PROP_VALUE_ACCESS(props[0]->values, VIG_TOP_OFF, 0);
  1357. else
  1358. sblk->top_off = 0x200;
  1359. sblk->format_list = sde_cfg->vig_formats;
  1360. sblk->virt_format_list = sde_cfg->virt_vig_formats;
  1361. sblk->num_fp16_igc_blk = 0;
  1362. sblk->num_fp16_gc_blk = 0;
  1363. sblk->num_fp16_csc_blk = 0;
  1364. sblk->num_fp16_unmult_blk = 0;
  1365. for (j = 0; j < SSPP_SUBBLK_COUNT_MAX; j++) {
  1366. if (!props[j])
  1367. continue;
  1368. if (_sde_sspp_setup_vcm(sspp, props[j],
  1369. "sspp_vig_fp16_igc",
  1370. &sblk->fp16_igc_blk[j],
  1371. SDE_SSPP_FP16_IGC, VIG_FP16_IGC_PROP,
  1372. true))
  1373. sblk->num_fp16_igc_blk += 1;
  1374. if (_sde_sspp_setup_vcm(sspp, props[j],
  1375. "sspp_vig_fp16_gc",
  1376. &sblk->fp16_gc_blk[j],
  1377. SDE_SSPP_FP16_GC, VIG_FP16_GC_PROP,
  1378. true))
  1379. sblk->num_fp16_gc_blk += 1;
  1380. if (_sde_sspp_setup_vcm(sspp, props[j],
  1381. "sspp_vig_fp16_csc",
  1382. &sblk->fp16_csc_blk[j],
  1383. SDE_SSPP_FP16_CSC, VIG_FP16_CSC_PROP,
  1384. true))
  1385. sblk->num_fp16_csc_blk += 1;
  1386. if (_sde_sspp_setup_vcm(sspp, props[j],
  1387. "sspp_vig_fp16_unmult",
  1388. &sblk->fp16_unmult_blk[j],
  1389. SDE_SSPP_FP16_UNMULT,
  1390. VIG_FP16_UNMULT_PROP, true))
  1391. sblk->num_fp16_unmult_blk += 1;
  1392. }
  1393. /* PP + scaling only supported on VIG rect 0 */
  1394. if (props[0] && ((sde_cfg->qseed_sw_lib_rev == SDE_SSPP_SCALER_QSEED2) ||
  1395. (sde_cfg->qseed_sw_lib_rev == SDE_SSPP_SCALER_QSEED3) ||
  1396. (sde_cfg->qseed_sw_lib_rev == SDE_SSPP_SCALER_QSEED3LITE))) {
  1397. set_bit(sde_cfg->qseed_sw_lib_rev, &sspp->features);
  1398. sblk->scaler_blk.id = sde_cfg->qseed_sw_lib_rev;
  1399. sblk->scaler_blk.base = PROP_VALUE_ACCESS(
  1400. props[0]->values, VIG_QSEED_OFF, 0);
  1401. sblk->scaler_blk.len = PROP_VALUE_ACCESS(
  1402. props[0]->values, VIG_QSEED_LEN, 0);
  1403. sblk->scaler_blk.regdma_base = SSPP_GET_REGDMA_BASE(sblk->scaler_blk.base,
  1404. sblk->top_off);
  1405. snprintf(sblk->scaler_blk.name, SDE_HW_BLK_NAME_LEN,
  1406. "sspp_scaler%u", sspp->id - SSPP_VIG0);
  1407. }
  1408. _sde_sspp_setup_vigs_pp(props[0], sde_cfg, sspp);
  1409. if (sde_cfg->true_inline_rot_rev > 0) {
  1410. set_bit(SDE_SSPP_TRUE_INLINE_ROT, &sspp->features);
  1411. sblk->in_rot_format_list = sde_cfg->inline_rot_formats;
  1412. sblk->in_rot_maxheight =
  1413. MAX_PRE_ROT_HEIGHT_INLINE_ROT_DEFAULT;
  1414. }
  1415. if (IS_SDE_INLINE_ROT_REV_200(sde_cfg->true_inline_rot_rev) ||
  1416. IS_SDE_INLINE_ROT_REV_201(sde_cfg->true_inline_rot_rev)) {
  1417. set_bit(SDE_SSPP_PREDOWNSCALE, &sspp->features);
  1418. sblk->in_rot_maxdwnscale_rt_num =
  1419. MAX_DOWNSCALE_RATIO_INROT_PD_RT_NUMERATOR;
  1420. sblk->in_rot_maxdwnscale_rt_denom =
  1421. MAX_DOWNSCALE_RATIO_INROT_PD_RT_DENOMINATOR;
  1422. sblk->in_rot_maxdwnscale_nrt =
  1423. MAX_DOWNSCALE_RATIO_INROT_NRT_DEFAULT;
  1424. sblk->in_rot_maxdwnscale_rt_nopd_num =
  1425. MAX_DOWNSCALE_RATIO_INROT_NOPD_RT_NUMERATOR;
  1426. sblk->in_rot_maxdwnscale_rt_nopd_denom =
  1427. MAX_DOWNSCALE_RATIO_INROT_NOPD_RT_DENOMINATOR;
  1428. } else if (IS_SDE_INLINE_ROT_REV_100(
  1429. sde_cfg->true_inline_rot_rev)) {
  1430. sblk->in_rot_maxdwnscale_rt_num =
  1431. MAX_DOWNSCALE_RATIO_INROT_NOPD_RT_NUMERATOR;
  1432. sblk->in_rot_maxdwnscale_rt_denom =
  1433. MAX_DOWNSCALE_RATIO_INROT_NOPD_RT_DENOMINATOR;
  1434. sblk->in_rot_maxdwnscale_nrt =
  1435. MAX_DOWNSCALE_RATIO_INROT_NRT_DEFAULT;
  1436. }
  1437. if (sde_cfg->inline_disable_const_clr)
  1438. set_bit(SDE_SSPP_INLINE_CONST_CLR, &sspp->features);
  1439. }
  1440. end:
  1441. sde_put_dt_props(props_tmp);
  1442. for (i = 0; i < SSPP_SUBBLK_COUNT_MAX; i++)
  1443. sde_put_dt_props(props[i]);
  1444. return rc;
  1445. }
  1446. static void _sde_sspp_setup_rgbs_pp(struct sde_dt_props *props,
  1447. struct sde_mdss_cfg *sde_cfg, struct sde_sspp_cfg *sspp)
  1448. {
  1449. struct sde_sspp_sub_blks *sblk = sspp->sblk;
  1450. sblk->pcc_blk.id = SDE_SSPP_PCC;
  1451. if (props->exists[RGB_PCC_PROP]) {
  1452. sblk->pcc_blk.base = PROP_VALUE_ACCESS(props->values,
  1453. RGB_PCC_PROP, 0);
  1454. sblk->pcc_blk.version = PROP_VALUE_ACCESS(props->values,
  1455. RGB_PCC_PROP, 1);
  1456. sblk->pcc_blk.len = 0;
  1457. set_bit(SDE_SSPP_PCC, &sspp->features);
  1458. }
  1459. }
  1460. static int _sde_sspp_setup_rgbs(struct device_node *np,
  1461. struct sde_mdss_cfg *sde_cfg)
  1462. {
  1463. int i;
  1464. struct sde_dt_props *props;
  1465. struct device_node *snp = NULL;
  1466. int rgb_count = 0;
  1467. const char *type;
  1468. snp = of_get_child_by_name(np, sspp_prop[SSPP_RGB_BLOCKS].prop_name);
  1469. if (!snp)
  1470. return 0;
  1471. props = sde_get_dt_props(snp, RGB_PROP_MAX, rgb_prop,
  1472. ARRAY_SIZE(rgb_prop), NULL);
  1473. if (IS_ERR(props))
  1474. return PTR_ERR(props);
  1475. for (i = 0; i < sde_cfg->sspp_count; ++i) {
  1476. struct sde_sspp_cfg *sspp = sde_cfg->sspp + i;
  1477. struct sde_sspp_sub_blks *sblk = sspp->sblk;
  1478. of_property_read_string_index(np,
  1479. sspp_prop[SSPP_TYPE].prop_name, i, &type);
  1480. if (strcmp(type, "rgb"))
  1481. continue;
  1482. sblk->maxupscale = MAX_UPSCALE_RATIO;
  1483. sblk->maxdwnscale = MAX_DOWNSCALE_RATIO;
  1484. sspp->id = SSPP_RGB0 + rgb_count;
  1485. snprintf(sspp->name, SDE_HW_BLK_NAME_LEN, "sspp_%u",
  1486. sspp->id - SSPP_VIG0);
  1487. sspp->clk_ctrl = SDE_CLK_CTRL_RGB0 + rgb_count;
  1488. sspp->type = SSPP_TYPE_RGB;
  1489. set_bit(SDE_PERF_SSPP_QOS, &sspp->perf_features);
  1490. if (sde_cfg->vbif_qos_nlvl == 8)
  1491. set_bit(SDE_PERF_SSPP_QOS_8LVL, &sspp->perf_features);
  1492. rgb_count++;
  1493. if ((sde_cfg->qseed_sw_lib_rev == SDE_SSPP_SCALER_QSEED2) ||
  1494. (sde_cfg->qseed_sw_lib_rev == SDE_SSPP_SCALER_QSEED3)) {
  1495. set_bit(SDE_SSPP_SCALER_RGB, &sspp->features);
  1496. sblk->scaler_blk.id = sde_cfg->qseed_sw_lib_rev;
  1497. sblk->scaler_blk.base = PROP_VALUE_ACCESS(props->values,
  1498. RGB_SCALER_OFF, 0);
  1499. sblk->scaler_blk.len = PROP_VALUE_ACCESS(props->values,
  1500. RGB_SCALER_LEN, 0);
  1501. snprintf(sblk->scaler_blk.name, SDE_HW_BLK_NAME_LEN,
  1502. "sspp_scaler%u", sspp->id - SSPP_VIG0);
  1503. }
  1504. _sde_sspp_setup_rgbs_pp(props, sde_cfg, sspp);
  1505. sblk->format_list = sde_cfg->dma_formats;
  1506. sblk->virt_format_list = NULL;
  1507. }
  1508. sde_put_dt_props(props);
  1509. return 0;
  1510. }
  1511. static void _sde_sspp_setup_cursor(struct sde_mdss_cfg *sde_cfg,
  1512. struct sde_sspp_cfg *sspp, struct sde_sspp_sub_blks *sblk,
  1513. struct sde_prop_value *prop_value, u32 *cursor_count)
  1514. {
  1515. if (!IS_SDE_MAJOR_MINOR_SAME(sde_cfg->hwversion, SDE_HW_VER_300))
  1516. SDE_ERROR("invalid sspp type %d, xin id %d\n",
  1517. sspp->type, sspp->xin_id);
  1518. set_bit(SDE_SSPP_CURSOR, &sspp->features);
  1519. sblk->maxupscale = SSPP_UNITY_SCALE;
  1520. sblk->maxdwnscale = SSPP_UNITY_SCALE;
  1521. sblk->format_list = sde_cfg->cursor_formats;
  1522. sblk->virt_format_list = NULL;
  1523. sspp->id = SSPP_CURSOR0 + *cursor_count;
  1524. snprintf(sspp->name, SDE_HW_BLK_NAME_LEN, "sspp_%u",
  1525. sspp->id - SSPP_VIG0);
  1526. sspp->clk_ctrl = SDE_CLK_CTRL_CURSOR0 + *cursor_count;
  1527. sspp->type = SSPP_TYPE_CURSOR;
  1528. (*cursor_count)++;
  1529. }
  1530. static void _sde_sspp_setup_dgm(struct sde_sspp_cfg *sspp,
  1531. const struct sde_dt_props *props, const char *name,
  1532. struct sde_pp_blk *blk, u32 type, u32 prop, bool versioned)
  1533. {
  1534. blk->id = type;
  1535. blk->len = 0;
  1536. set_bit(type, &sspp->features);
  1537. blk->base = PROP_VALUE_ACCESS(props->values, prop, 0);
  1538. blk->regdma_base = SSPP_GET_REGDMA_BASE(blk->base, sspp->sblk->top_off);
  1539. snprintf(blk->name, SDE_HW_BLK_NAME_LEN, "%s%u", name,
  1540. sspp->id - SSPP_DMA0);
  1541. if (versioned)
  1542. blk->version = PROP_VALUE_ACCESS(props->values, prop, 1);
  1543. }
  1544. static int _sde_sspp_setup_dmas(struct device_node *np,
  1545. struct sde_mdss_cfg *sde_cfg)
  1546. {
  1547. int i = 0, j;
  1548. int rc = 0, dma_count = 0, dgm_count = 0;
  1549. struct sde_dt_props *props[SSPP_SUBBLK_COUNT_MAX] = {NULL, NULL};
  1550. struct sde_dt_props *props_tmp = NULL;
  1551. struct device_node *snp = NULL;
  1552. const char *type;
  1553. snp = of_get_child_by_name(np, sspp_prop[SSPP_DMA_BLOCKS].prop_name);
  1554. if (snp) {
  1555. dgm_count = of_get_child_count(snp);
  1556. if (dgm_count > 0) {
  1557. struct device_node *dgm_snp;
  1558. if (dgm_count > SSPP_SUBBLK_COUNT_MAX) {
  1559. SDE_ERROR("too many dgm subblocks defined");
  1560. goto end;
  1561. }
  1562. for_each_child_of_node(snp, dgm_snp) {
  1563. props_tmp = sde_get_dt_props(dgm_snp,
  1564. DMA_PROP_MAX, dma_prop,
  1565. ARRAY_SIZE(dma_prop), NULL);
  1566. if (IS_ERR(props_tmp)) {
  1567. rc = PTR_ERR(props_tmp);
  1568. props_tmp = NULL;
  1569. goto end;
  1570. } else if (!props_tmp->exists[DMA_SUBBLOCK_INDEX]) {
  1571. SDE_ERROR("dgm sub-block index must be defined");
  1572. goto end;
  1573. }
  1574. i = PROP_VALUE_ACCESS(props_tmp->values, DMA_SUBBLOCK_INDEX, 0);
  1575. if (i >= SSPP_SUBBLK_COUNT_MAX) {
  1576. SDE_ERROR("dgm sub-block index greater than max: %d", i);
  1577. goto end;
  1578. } else if (props[i] != NULL) {
  1579. SDE_ERROR("dgm sub-block index already defined: %d", i);
  1580. goto end;
  1581. }
  1582. props[i] = props_tmp;
  1583. props_tmp = NULL;
  1584. }
  1585. }
  1586. }
  1587. for (i = 0; i < sde_cfg->sspp_count; ++i) {
  1588. struct sde_sspp_cfg *sspp = sde_cfg->sspp + i;
  1589. struct sde_sspp_sub_blks *sblk = sspp->sblk;
  1590. of_property_read_string_index(np,
  1591. sspp_prop[SSPP_TYPE].prop_name, i, &type);
  1592. if (strcmp(type, "dma"))
  1593. continue;
  1594. sblk->maxupscale = SSPP_UNITY_SCALE;
  1595. sblk->maxdwnscale = SSPP_UNITY_SCALE;
  1596. sblk->format_list = sde_cfg->dma_formats;
  1597. sblk->virt_format_list = sde_cfg->dma_formats;
  1598. sspp->id = SSPP_DMA0 + dma_count;
  1599. sspp->clk_ctrl = SDE_CLK_CTRL_DMA0 + dma_count;
  1600. snprintf(sspp->name, SDE_HW_BLK_NAME_LEN, "sspp_%u",
  1601. sspp->id - SSPP_VIG0);
  1602. sspp->type = SSPP_TYPE_DMA;
  1603. set_bit(SDE_PERF_SSPP_QOS, &sspp->perf_features);
  1604. if (sde_cfg->vbif_qos_nlvl == 8)
  1605. set_bit(SDE_PERF_SSPP_QOS_8LVL, &sspp->perf_features);
  1606. dma_count++;
  1607. /* Obtain sub block top, or maintain backwards compatibility */
  1608. if (props[0] && props[0]->exists[DMA_TOP_OFF])
  1609. sblk->top_off = PROP_VALUE_ACCESS(props[0]->values, DMA_TOP_OFF, 0);
  1610. else
  1611. sblk->top_off = 0x200;
  1612. sblk->num_igc_blk = dgm_count;
  1613. sblk->num_gc_blk = dgm_count;
  1614. sblk->num_dgm_csc_blk = dgm_count;
  1615. for (j = 0; j < SSPP_SUBBLK_COUNT_MAX; j++) {
  1616. if (props[j] == NULL)
  1617. continue;
  1618. if (props[j]->exists[DMA_IGC_PROP])
  1619. _sde_sspp_setup_dgm(sspp, props[j],
  1620. "sspp_dma_igc", &sblk->igc_blk[j],
  1621. SDE_SSPP_DMA_IGC, DMA_IGC_PROP, true);
  1622. if (props[j]->exists[DMA_GC_PROP])
  1623. _sde_sspp_setup_dgm(sspp, props[j],
  1624. "sspp_dma_gc", &sblk->gc_blk[j],
  1625. SDE_SSPP_DMA_GC, DMA_GC_PROP, true);
  1626. if (PROP_VALUE_ACCESS(props[j]->values,
  1627. DMA_DGM_INVERSE_PMA, 0))
  1628. set_bit(SDE_SSPP_DGM_INVERSE_PMA,
  1629. &sspp->features);
  1630. if (props[j]->exists[DMA_CSC_OFF])
  1631. _sde_sspp_setup_dgm(sspp, props[j],
  1632. "sspp_dgm_csc", &sblk->dgm_csc_blk[j],
  1633. SDE_SSPP_DGM_CSC, DMA_CSC_OFF, false);
  1634. if (props[j]->exists[DMA_FP16_IGC_PROP])
  1635. _sde_sspp_setup_dgm(sspp, props[j],
  1636. "sspp_dma_fp16_igc",
  1637. &sblk->fp16_igc_blk[j],
  1638. SDE_SSPP_FP16_IGC,
  1639. DMA_FP16_IGC_PROP, true);
  1640. if (props[j]->exists[DMA_FP16_GC_PROP])
  1641. _sde_sspp_setup_dgm(sspp, props[j],
  1642. "sspp_dma_fp16_gc",
  1643. &sblk->fp16_gc_blk[j],
  1644. SDE_SSPP_FP16_GC,
  1645. DMA_FP16_GC_PROP, true);
  1646. if (props[j]->exists[DMA_FP16_CSC_PROP])
  1647. _sde_sspp_setup_dgm(sspp, props[j],
  1648. "sspp_dma_fp16_csc",
  1649. &sblk->fp16_csc_blk[j],
  1650. SDE_SSPP_FP16_CSC,
  1651. DMA_FP16_CSC_PROP, true);
  1652. if (props[j]->exists[DMA_FP16_UNMULT_PROP])
  1653. _sde_sspp_setup_dgm(sspp, props[j],
  1654. "sspp_dma_fp16_unmult",
  1655. &sblk->fp16_unmult_blk[j],
  1656. SDE_SSPP_FP16_UNMULT,
  1657. DMA_FP16_UNMULT_PROP, true);
  1658. }
  1659. }
  1660. end:
  1661. for (i = 0; i < SSPP_SUBBLK_COUNT_MAX; i++)
  1662. sde_put_dt_props(props[i]);
  1663. sde_put_dt_props(props_tmp);
  1664. return rc;
  1665. }
  1666. static void sde_sspp_set_features(struct sde_mdss_cfg *sde_cfg,
  1667. const struct sde_dt_props *props)
  1668. {
  1669. int i;
  1670. for (i = 0; i < sde_cfg->sspp_count; ++i) {
  1671. struct sde_sspp_cfg *sspp = sde_cfg->sspp + i;
  1672. struct sde_sspp_sub_blks *sblk = sspp->sblk;
  1673. sblk->maxlinewidth = sde_cfg->max_sspp_linewidth;
  1674. sblk->smart_dma_priority =
  1675. PROP_VALUE_ACCESS(props->values, SSPP_SMART_DMA, i);
  1676. if (sblk->smart_dma_priority && sde_cfg->smart_dma_rev)
  1677. set_bit(sde_cfg->smart_dma_rev, &sspp->features);
  1678. sblk->src_blk.id = SDE_SSPP_SRC;
  1679. set_bit(SDE_SSPP_SRC, &sspp->features);
  1680. if (sde_cfg->has_cdp)
  1681. set_bit(SDE_PERF_SSPP_CDP, &sspp->perf_features);
  1682. if (sde_cfg->ts_prefill_rev == 1) {
  1683. set_bit(SDE_PERF_SSPP_TS_PREFILL, &sspp->perf_features);
  1684. } else if (sde_cfg->ts_prefill_rev == 2) {
  1685. set_bit(SDE_PERF_SSPP_TS_PREFILL, &sspp->perf_features);
  1686. set_bit(SDE_PERF_SSPP_TS_PREFILL_REC1,
  1687. &sspp->perf_features);
  1688. }
  1689. if (sde_cfg->uidle_cfg.uidle_rev)
  1690. set_bit(SDE_PERF_SSPP_UIDLE, &sspp->perf_features);
  1691. if (sde_cfg->sc_cfg[SDE_SYS_CACHE_DISP].has_sys_cache)
  1692. set_bit(SDE_PERF_SSPP_SYS_CACHE, &sspp->perf_features);
  1693. if (sde_cfg->sspp_multirect_error)
  1694. set_bit(SDE_SSPP_MULTIRECT_ERROR, &sspp->features);
  1695. if (sde_cfg->has_decimation) {
  1696. sblk->maxhdeciexp = MAX_HORZ_DECIMATION;
  1697. sblk->maxvdeciexp = MAX_VERT_DECIMATION;
  1698. } else {
  1699. sblk->maxhdeciexp = 0;
  1700. sblk->maxvdeciexp = 0;
  1701. }
  1702. sblk->pixel_ram_size = DEFAULT_PIXEL_RAM_SIZE;
  1703. if (PROP_VALUE_ACCESS(props->values, SSPP_EXCL_RECT, i) == 1)
  1704. set_bit(SDE_SSPP_EXCL_RECT, &sspp->features);
  1705. if (props->exists[SSPP_MAX_PER_PIPE_BW])
  1706. sblk->max_per_pipe_bw = PROP_VALUE_ACCESS(props->values,
  1707. SSPP_MAX_PER_PIPE_BW, i);
  1708. else
  1709. sblk->max_per_pipe_bw = DEFAULT_MAX_PER_PIPE_BW;
  1710. if (props->exists[SSPP_MAX_PER_PIPE_BW_HIGH])
  1711. sblk->max_per_pipe_bw_high =
  1712. PROP_VALUE_ACCESS(props->values,
  1713. SSPP_MAX_PER_PIPE_BW_HIGH, i);
  1714. else
  1715. sblk->max_per_pipe_bw_high = sblk->max_per_pipe_bw;
  1716. }
  1717. }
  1718. static int _sde_sspp_setup_cmn(struct device_node *np,
  1719. struct sde_mdss_cfg *sde_cfg)
  1720. {
  1721. int rc = 0, off_count, i, j;
  1722. struct sde_dt_props *props;
  1723. const char *type;
  1724. struct sde_sspp_cfg *sspp;
  1725. struct sde_sspp_sub_blks *sblk;
  1726. u32 cursor_count = 0;
  1727. props = sde_get_dt_props(np, SSPP_PROP_MAX, sspp_prop,
  1728. ARRAY_SIZE(sspp_prop), &off_count);
  1729. if (IS_ERR(props))
  1730. return PTR_ERR(props);
  1731. if (off_count > MAX_BLOCKS) {
  1732. SDE_ERROR("%d off_count exceeds MAX_BLOCKS, limiting to %d\n",
  1733. off_count, MAX_BLOCKS);
  1734. off_count = MAX_BLOCKS;
  1735. }
  1736. sde_cfg->sspp_count = off_count;
  1737. /* create all sub blocks before populating them */
  1738. for (i = 0; i < off_count; i++) {
  1739. sspp = sde_cfg->sspp + i;
  1740. sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
  1741. if (!sblk) {
  1742. rc = -ENOMEM;
  1743. /* catalog deinit will release the allocated blocks */
  1744. goto end;
  1745. }
  1746. sspp->sblk = sblk;
  1747. }
  1748. sde_sspp_set_features(sde_cfg, props);
  1749. for (i = 0; i < off_count; i++) {
  1750. sspp = sde_cfg->sspp + i;
  1751. sblk = sspp->sblk;
  1752. sspp->base = PROP_VALUE_ACCESS(props->values, SSPP_OFF, i);
  1753. sspp->len = PROP_VALUE_ACCESS(props->values, SSPP_SIZE, 0);
  1754. of_property_read_string_index(np,
  1755. sspp_prop[SSPP_TYPE].prop_name, i, &type);
  1756. if (!strcmp(type, "cursor")) {
  1757. /* No prop values for cursor pipes */
  1758. _sde_sspp_setup_cursor(sde_cfg, sspp, sblk, NULL,
  1759. &cursor_count);
  1760. }
  1761. snprintf(sblk->src_blk.name, SDE_HW_BLK_NAME_LEN, "sspp_src_%u",
  1762. sspp->id - SSPP_VIG0);
  1763. if (sspp->clk_ctrl >= SDE_CLK_CTRL_MAX) {
  1764. SDE_ERROR("%s: invalid clk ctrl: %d\n",
  1765. sblk->src_blk.name, sspp->clk_ctrl);
  1766. rc = -EINVAL;
  1767. goto end;
  1768. }
  1769. sspp->xin_id = PROP_VALUE_ACCESS(props->values, SSPP_XIN, i);
  1770. sblk->src_blk.len = PROP_VALUE_ACCESS(props->values, SSPP_SIZE,
  1771. 0);
  1772. for (j = 0; j < sde_cfg->mdp_count; j++) {
  1773. sde_cfg->mdp[j].clk_ctrls[sspp->clk_ctrl].reg_off =
  1774. PROP_BITVALUE_ACCESS(props->values,
  1775. SSPP_CLK_CTRL, i, 0);
  1776. sde_cfg->mdp[j].clk_ctrls[sspp->clk_ctrl].bit_off =
  1777. PROP_BITVALUE_ACCESS(props->values,
  1778. SSPP_CLK_CTRL, i, 1);
  1779. sde_cfg->mdp[j].clk_status[sspp->clk_ctrl].reg_off =
  1780. PROP_BITVALUE_ACCESS(props->values,
  1781. SSPP_CLK_STATUS, i, 0);
  1782. sde_cfg->mdp[j].clk_status[sspp->clk_ctrl].bit_off =
  1783. PROP_BITVALUE_ACCESS(props->values,
  1784. SSPP_CLK_STATUS, i, 1);
  1785. }
  1786. SDE_DEBUG("xin:%d ram:%d clk%d:%x/%d\n",
  1787. sspp->xin_id, sblk->pixel_ram_size, sspp->clk_ctrl,
  1788. sde_cfg->mdp[0].clk_ctrls[sspp->clk_ctrl].reg_off,
  1789. sde_cfg->mdp[0].clk_ctrls[sspp->clk_ctrl].bit_off);
  1790. }
  1791. end:
  1792. sde_put_dt_props(props);
  1793. return rc;
  1794. }
  1795. static int sde_sspp_parse_dt(struct device_node *np,
  1796. struct sde_mdss_cfg *sde_cfg)
  1797. {
  1798. int rc;
  1799. rc = _sde_sspp_setup_cmn(np, sde_cfg);
  1800. if (rc)
  1801. return rc;
  1802. rc = _sde_sspp_setup_vigs(np, sde_cfg);
  1803. if (rc)
  1804. return rc;
  1805. rc = _sde_sspp_setup_rgbs(np, sde_cfg);
  1806. if (rc)
  1807. return rc;
  1808. rc = _sde_sspp_setup_dmas(np, sde_cfg);
  1809. return rc;
  1810. }
  1811. static int sde_ctl_parse_dt(struct device_node *np,
  1812. struct sde_mdss_cfg *sde_cfg)
  1813. {
  1814. int i;
  1815. struct sde_dt_props *props;
  1816. struct sde_ctl_cfg *ctl;
  1817. u32 off_count;
  1818. if (!sde_cfg) {
  1819. SDE_ERROR("invalid argument input param\n");
  1820. return -EINVAL;
  1821. }
  1822. props = sde_get_dt_props(np, HW_PROP_MAX, ctl_prop,
  1823. ARRAY_SIZE(ctl_prop), &off_count);
  1824. if (IS_ERR(props))
  1825. return PTR_ERR(props);
  1826. sde_cfg->ctl_count = off_count;
  1827. for (i = 0; i < off_count; i++) {
  1828. const char *disp_pref = NULL;
  1829. ctl = sde_cfg->ctl + i;
  1830. ctl->base = PROP_VALUE_ACCESS(props->values, HW_OFF, i);
  1831. ctl->len = PROP_VALUE_ACCESS(props->values, HW_LEN, 0);
  1832. ctl->id = CTL_0 + i;
  1833. snprintf(ctl->name, SDE_HW_BLK_NAME_LEN, "ctl_%u",
  1834. ctl->id - CTL_0);
  1835. of_property_read_string_index(np,
  1836. ctl_prop[HW_DISP].prop_name, i, &disp_pref);
  1837. if (disp_pref && !strcmp(disp_pref, "primary"))
  1838. set_bit(SDE_CTL_PRIMARY_PREF, &ctl->features);
  1839. if ((i < MAX_SPLIT_DISPLAY_CTL) &&
  1840. !(IS_SDE_CTL_REV_100(sde_cfg->ctl_rev)))
  1841. set_bit(SDE_CTL_SPLIT_DISPLAY, &ctl->features);
  1842. if (i < MAX_PP_SPLIT_DISPLAY_CTL)
  1843. set_bit(SDE_CTL_PINGPONG_SPLIT, &ctl->features);
  1844. if (IS_SDE_CTL_REV_100(sde_cfg->ctl_rev))
  1845. set_bit(SDE_CTL_ACTIVE_CFG, &ctl->features);
  1846. if (SDE_UIDLE_MAJOR(sde_cfg->uidle_cfg.uidle_rev))
  1847. set_bit(SDE_CTL_UIDLE, &ctl->features);
  1848. if (SDE_HW_MAJOR(sde_cfg->hwversion) >=
  1849. SDE_HW_MAJOR(SDE_HW_VER_700))
  1850. set_bit(SDE_CTL_UNIFIED_DSPP_FLUSH, &ctl->features);
  1851. }
  1852. sde_put_dt_props(props);
  1853. return 0;
  1854. }
  1855. void sde_hw_mixer_set_preference(struct sde_mdss_cfg *sde_cfg, u32 num_lm,
  1856. uint32_t disp_type)
  1857. {
  1858. u32 i, cnt = 0, sec_cnt = 0;
  1859. if (disp_type == SDE_CONNECTOR_PRIMARY) {
  1860. for (i = 0; i < sde_cfg->mixer_count; i++) {
  1861. /* Check if lm was previously set for secondary */
  1862. /* Clear pref, primary has higher priority */
  1863. if (sde_cfg->mixer[i].features &
  1864. BIT(SDE_DISP_SECONDARY_PREF)) {
  1865. clear_bit(SDE_DISP_SECONDARY_PREF,
  1866. &sde_cfg->mixer[i].features);
  1867. sec_cnt++;
  1868. }
  1869. clear_bit(SDE_DISP_PRIMARY_PREF,
  1870. &sde_cfg->mixer[i].features);
  1871. /* Set lm for primary pref */
  1872. if (cnt < num_lm) {
  1873. set_bit(SDE_DISP_PRIMARY_PREF,
  1874. &sde_cfg->mixer[i].features);
  1875. cnt++;
  1876. }
  1877. /*
  1878. * When all primary prefs have been set,
  1879. * and if 2 lms are required for secondary
  1880. * preference must be set with an lm pair
  1881. */
  1882. if (cnt == num_lm && sec_cnt > 1 &&
  1883. !test_bit(sde_cfg->mixer[i+1].id,
  1884. &sde_cfg->mixer[i].lm_pair_mask))
  1885. continue;
  1886. /* After primary pref is set, now re apply secondary */
  1887. if (cnt >= num_lm && cnt < (num_lm + sec_cnt)) {
  1888. set_bit(SDE_DISP_SECONDARY_PREF,
  1889. &sde_cfg->mixer[i].features);
  1890. cnt++;
  1891. }
  1892. }
  1893. } else if (disp_type == SDE_CONNECTOR_SECONDARY) {
  1894. for (i = 0; i < sde_cfg->mixer_count; i++) {
  1895. clear_bit(SDE_DISP_SECONDARY_PREF,
  1896. &sde_cfg->mixer[i].features);
  1897. /*
  1898. * If 2 lms are required for secondary
  1899. * preference must be set with an lm pair
  1900. */
  1901. if (cnt == 0 && num_lm > 1 &&
  1902. !test_bit(sde_cfg->mixer[i+1].id,
  1903. &sde_cfg->mixer[i].lm_pair_mask))
  1904. continue;
  1905. if (cnt < num_lm && !(sde_cfg->mixer[i].features &
  1906. BIT(SDE_DISP_PRIMARY_PREF))) {
  1907. set_bit(SDE_DISP_SECONDARY_PREF,
  1908. &sde_cfg->mixer[i].features);
  1909. cnt++;
  1910. }
  1911. }
  1912. }
  1913. }
  1914. static int sde_mixer_parse_dt(struct device_node *np,
  1915. struct sde_mdss_cfg *sde_cfg)
  1916. {
  1917. int rc = 0, i, j;
  1918. u32 off_count, blend_off_count, max_blendstages, lm_pair_mask;
  1919. struct sde_lm_cfg *mixer;
  1920. struct sde_lm_sub_blks *sblk;
  1921. int pp_count, dspp_count, ds_count, mixer_count;
  1922. u32 pp_idx, dspp_idx, ds_idx;
  1923. u32 mixer_base;
  1924. struct device_node *snp = NULL;
  1925. struct sde_dt_props *props, *blend_props, *blocks_props = NULL;
  1926. if (!sde_cfg) {
  1927. SDE_ERROR("invalid argument input param\n");
  1928. return -EINVAL;
  1929. }
  1930. max_blendstages = sde_cfg->max_mixer_blendstages;
  1931. props = sde_get_dt_props(np, MIXER_PROP_MAX, mixer_prop,
  1932. ARRAY_SIZE(mixer_prop), &off_count);
  1933. if (IS_ERR(props))
  1934. return PTR_ERR(props);
  1935. pp_count = sde_cfg->pingpong_count;
  1936. dspp_count = sde_cfg->dspp_count;
  1937. ds_count = sde_cfg->ds_count;
  1938. /* get mixer feature dt properties if they exist */
  1939. snp = of_get_child_by_name(np, mixer_prop[MIXER_BLOCKS].prop_name);
  1940. if (snp) {
  1941. blocks_props = sde_get_dt_props(snp, MIXER_PROP_MAX,
  1942. mixer_blocks_prop,
  1943. ARRAY_SIZE(mixer_blocks_prop), NULL);
  1944. if (IS_ERR(blocks_props)) {
  1945. rc = PTR_ERR(blocks_props);
  1946. goto put_props;
  1947. }
  1948. }
  1949. /* get the blend_op register offsets */
  1950. blend_props = sde_get_dt_props(np, MIXER_BLEND_PROP_MAX,
  1951. mixer_blend_prop, ARRAY_SIZE(mixer_blend_prop),
  1952. &blend_off_count);
  1953. if (IS_ERR(blend_props)) {
  1954. rc = PTR_ERR(blend_props);
  1955. goto put_blocks;
  1956. }
  1957. for (i = 0, mixer_count = 0, pp_idx = 0, dspp_idx = 0,
  1958. ds_idx = 0; i < off_count; i++) {
  1959. const char *disp_pref = NULL;
  1960. const char *cwb_pref = NULL;
  1961. const char *dcwb_pref = NULL;
  1962. u32 dummy_mixer_base = 0x0f0f;
  1963. mixer_base = PROP_VALUE_ACCESS(props->values, MIXER_OFF, i);
  1964. if (!mixer_base)
  1965. continue;
  1966. mixer = sde_cfg->mixer + mixer_count;
  1967. sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
  1968. if (!sblk) {
  1969. rc = -ENOMEM;
  1970. /* catalog deinit will release the allocated blocks */
  1971. goto end;
  1972. }
  1973. mixer->sblk = sblk;
  1974. mixer->base = mixer_base;
  1975. mixer->len = !props->exists[MIXER_LEN] ?
  1976. DEFAULT_SDE_HW_BLOCK_LEN :
  1977. PROP_VALUE_ACCESS(props->values, MIXER_LEN, 0);
  1978. mixer->id = LM_0 + i;
  1979. snprintf(mixer->name, SDE_HW_BLK_NAME_LEN, "lm_%u",
  1980. mixer->id - LM_0);
  1981. lm_pair_mask = PROP_VALUE_ACCESS(props->values,
  1982. MIXER_PAIR_MASK, i);
  1983. if (lm_pair_mask)
  1984. mixer->lm_pair_mask = 1 << lm_pair_mask;
  1985. sblk->maxblendstages = max_blendstages;
  1986. sblk->maxwidth = sde_cfg->max_mixer_width;
  1987. for (j = 0; j < blend_off_count; j++)
  1988. sblk->blendstage_base[j] =
  1989. PROP_VALUE_ACCESS(blend_props->values,
  1990. MIXER_BLEND_OP_OFF, j);
  1991. if (sde_cfg->has_src_split)
  1992. set_bit(SDE_MIXER_SOURCESPLIT, &mixer->features);
  1993. if (sde_cfg->has_dim_layer)
  1994. set_bit(SDE_DIM_LAYER, &mixer->features);
  1995. if (sde_cfg->has_mixer_combined_alpha)
  1996. set_bit(SDE_MIXER_COMBINED_ALPHA, &mixer->features);
  1997. of_property_read_string_index(np,
  1998. mixer_prop[MIXER_DISP].prop_name, i, &disp_pref);
  1999. if (disp_pref && !strcmp(disp_pref, "primary"))
  2000. set_bit(SDE_DISP_PRIMARY_PREF, &mixer->features);
  2001. of_property_read_string_index(np,
  2002. mixer_prop[MIXER_CWB].prop_name, i, &cwb_pref);
  2003. if (cwb_pref && !strcmp(cwb_pref, "cwb"))
  2004. set_bit(SDE_DISP_CWB_PREF, &mixer->features);
  2005. of_property_read_string_index(np,
  2006. mixer_prop[MIXER_DCWB].prop_name, i, &dcwb_pref);
  2007. if (dcwb_pref && !strcmp(dcwb_pref, "dcwb")) {
  2008. set_bit(SDE_DISP_DCWB_PREF, &mixer->features);
  2009. if (mixer->base == dummy_mixer_base) {
  2010. mixer->base = 0x0;
  2011. mixer->len = 0;
  2012. }
  2013. }
  2014. mixer->pingpong = pp_count > 0 ? pp_idx + PINGPONG_0
  2015. : PINGPONG_MAX;
  2016. mixer->dspp = dspp_count > 0 ? dspp_idx + DSPP_0
  2017. : DSPP_MAX;
  2018. mixer->ds = ds_count > 0 ? ds_idx + DS_0 : DS_MAX;
  2019. pp_count--;
  2020. dspp_count--;
  2021. ds_count--;
  2022. pp_idx++;
  2023. dspp_idx++;
  2024. ds_idx++;
  2025. mixer_count++;
  2026. sblk->gc.id = SDE_MIXER_GC;
  2027. if (blocks_props && blocks_props->exists[MIXER_GC_PROP]) {
  2028. sblk->gc.base = PROP_VALUE_ACCESS(blocks_props->values,
  2029. MIXER_GC_PROP, 0);
  2030. sblk->gc.version = PROP_VALUE_ACCESS(
  2031. blocks_props->values, MIXER_GC_PROP,
  2032. 1);
  2033. sblk->gc.len = 0;
  2034. set_bit(SDE_MIXER_GC, &mixer->features);
  2035. }
  2036. }
  2037. sde_cfg->mixer_count = mixer_count;
  2038. _sde_lm_noise_parse_dt(np, sde_cfg);
  2039. end:
  2040. sde_put_dt_props(blend_props);
  2041. put_blocks:
  2042. sde_put_dt_props(blocks_props);
  2043. put_props:
  2044. sde_put_dt_props(props);
  2045. return rc;
  2046. }
  2047. static int sde_intf_parse_dt(struct device_node *np,
  2048. struct sde_mdss_cfg *sde_cfg)
  2049. {
  2050. int rc, prop_count[INTF_PROP_MAX], i;
  2051. struct sde_prop_value *prop_value = NULL;
  2052. bool prop_exists[INTF_PROP_MAX];
  2053. u32 off_count;
  2054. u32 dsi_count = 0, none_count = 0, hdmi_count = 0, dp_count = 0;
  2055. const char *type;
  2056. struct sde_intf_cfg *intf;
  2057. if (!sde_cfg) {
  2058. SDE_ERROR("invalid argument\n");
  2059. rc = -EINVAL;
  2060. goto end;
  2061. }
  2062. prop_value = kzalloc(INTF_PROP_MAX *
  2063. sizeof(struct sde_prop_value), GFP_KERNEL);
  2064. if (!prop_value) {
  2065. rc = -ENOMEM;
  2066. goto end;
  2067. }
  2068. rc = _validate_dt_entry(np, intf_prop, ARRAY_SIZE(intf_prop),
  2069. prop_count, &off_count);
  2070. if (rc)
  2071. goto end;
  2072. sde_cfg->intf_count = off_count;
  2073. rc = _read_dt_entry(np, intf_prop, ARRAY_SIZE(intf_prop), prop_count,
  2074. prop_exists, prop_value);
  2075. if (rc)
  2076. goto end;
  2077. for (i = 0; i < off_count; i++) {
  2078. intf = sde_cfg->intf + i;
  2079. intf->base = PROP_VALUE_ACCESS(prop_value, INTF_OFF, i);
  2080. intf->len = PROP_VALUE_ACCESS(prop_value, INTF_LEN, 0);
  2081. intf->id = INTF_0 + i;
  2082. snprintf(intf->name, SDE_HW_BLK_NAME_LEN, "intf_%u",
  2083. intf->id - INTF_0);
  2084. if (!prop_exists[INTF_LEN])
  2085. intf->len = DEFAULT_SDE_HW_BLOCK_LEN;
  2086. rc = _add_to_irq_offset_list(sde_cfg, SDE_INTR_HWBLK_INTF,
  2087. intf->id, intf->base);
  2088. if (rc)
  2089. goto end;
  2090. intf->prog_fetch_lines_worst_case =
  2091. !prop_exists[INTF_PREFETCH] ?
  2092. sde_cfg->perf.min_prefill_lines :
  2093. PROP_VALUE_ACCESS(prop_value, INTF_PREFETCH, i);
  2094. of_property_read_string_index(np,
  2095. intf_prop[INTF_TYPE].prop_name, i, &type);
  2096. if (!strcmp(type, "dsi")) {
  2097. intf->type = INTF_DSI;
  2098. intf->controller_id = dsi_count;
  2099. dsi_count++;
  2100. } else if (!strcmp(type, "hdmi")) {
  2101. intf->type = INTF_HDMI;
  2102. intf->controller_id = hdmi_count;
  2103. hdmi_count++;
  2104. } else if (!strcmp(type, "dp")) {
  2105. intf->type = INTF_DP;
  2106. intf->controller_id = dp_count;
  2107. dp_count++;
  2108. } else {
  2109. intf->type = INTF_NONE;
  2110. intf->controller_id = none_count;
  2111. none_count++;
  2112. }
  2113. if (IS_SDE_CTL_REV_100(sde_cfg->ctl_rev))
  2114. set_bit(SDE_INTF_INPUT_CTRL, &intf->features);
  2115. if (prop_exists[INTF_TE_IRQ])
  2116. intf->te_irq_offset = PROP_VALUE_ACCESS(prop_value,
  2117. INTF_TE_IRQ, i);
  2118. if (intf->te_irq_offset) {
  2119. rc = _add_to_irq_offset_list(sde_cfg,
  2120. SDE_INTR_HWBLK_INTF_TEAR,
  2121. intf->id, intf->te_irq_offset);
  2122. if (rc)
  2123. goto end;
  2124. set_bit(SDE_INTF_TE, &intf->features);
  2125. }
  2126. if (SDE_HW_MAJOR(sde_cfg->hwversion) >=
  2127. SDE_HW_MAJOR(SDE_HW_VER_500))
  2128. set_bit(SDE_INTF_STATUS, &intf->features);
  2129. if (SDE_HW_MAJOR(sde_cfg->hwversion) >=
  2130. SDE_HW_MAJOR(SDE_HW_VER_700))
  2131. set_bit(SDE_INTF_TE_ALIGN_VSYNC, &intf->features);
  2132. if (SDE_HW_MAJOR(sde_cfg->hwversion) >=
  2133. SDE_HW_MAJOR(SDE_HW_VER_810)) {
  2134. set_bit(SDE_INTF_WD_TIMER, &intf->features);
  2135. set_bit(SDE_INTF_RESET_COUNTER, &intf->features);
  2136. set_bit(SDE_INTF_VSYNC_TIMESTAMP, &intf->features);
  2137. }
  2138. }
  2139. end:
  2140. kfree(prop_value);
  2141. return rc;
  2142. }
  2143. static int sde_wb_parse_dt(struct device_node *np, struct sde_mdss_cfg *sde_cfg)
  2144. {
  2145. int rc, prop_count[WB_PROP_MAX], i, j;
  2146. struct sde_prop_value *prop_value = NULL;
  2147. bool prop_exists[WB_PROP_MAX];
  2148. u32 off_count, major_version;
  2149. struct sde_wb_cfg *wb;
  2150. struct sde_wb_sub_blocks *sblk;
  2151. if (!sde_cfg) {
  2152. SDE_ERROR("invalid argument\n");
  2153. rc = -EINVAL;
  2154. goto end;
  2155. }
  2156. prop_value = kzalloc(WB_PROP_MAX *
  2157. sizeof(struct sde_prop_value), GFP_KERNEL);
  2158. if (!prop_value) {
  2159. rc = -ENOMEM;
  2160. goto end;
  2161. }
  2162. rc = _validate_dt_entry(np, wb_prop, ARRAY_SIZE(wb_prop), prop_count,
  2163. &off_count);
  2164. if (rc)
  2165. goto end;
  2166. sde_cfg->wb_count = off_count;
  2167. rc = _read_dt_entry(np, wb_prop, ARRAY_SIZE(wb_prop), prop_count,
  2168. prop_exists, prop_value);
  2169. if (rc)
  2170. goto end;
  2171. major_version = SDE_HW_MAJOR(sde_cfg->hwversion);
  2172. for (i = 0; i < off_count; i++) {
  2173. wb = sde_cfg->wb + i;
  2174. sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
  2175. if (!sblk) {
  2176. rc = -ENOMEM;
  2177. /* catalog deinit will release the allocated blocks */
  2178. goto end;
  2179. }
  2180. wb->sblk = sblk;
  2181. wb->base = PROP_VALUE_ACCESS(prop_value, WB_OFF, i);
  2182. wb->id = WB_0 + PROP_VALUE_ACCESS(prop_value, WB_ID, i);
  2183. snprintf(wb->name, SDE_HW_BLK_NAME_LEN, "wb_%u",
  2184. wb->id - WB_0);
  2185. wb->clk_ctrl = SDE_CLK_CTRL_WB0 +
  2186. PROP_VALUE_ACCESS(prop_value, WB_ID, i);
  2187. wb->xin_id = PROP_VALUE_ACCESS(prop_value, WB_XIN_ID, i);
  2188. if (wb->clk_ctrl >= SDE_CLK_CTRL_MAX) {
  2189. SDE_ERROR("%s: invalid clk ctrl: %d\n",
  2190. wb->name, wb->clk_ctrl);
  2191. rc = -EINVAL;
  2192. goto end;
  2193. }
  2194. if (IS_SDE_MAJOR_MINOR_SAME((sde_cfg->hwversion),
  2195. SDE_HW_VER_170))
  2196. wb->vbif_idx = VBIF_NRT;
  2197. else
  2198. wb->vbif_idx = VBIF_RT;
  2199. wb->len = PROP_VALUE_ACCESS(prop_value, WB_LEN, 0);
  2200. if (!prop_exists[WB_LEN])
  2201. wb->len = DEFAULT_SDE_HW_BLOCK_LEN;
  2202. sblk->maxlinewidth = sde_cfg->max_wb_linewidth;
  2203. sblk->maxlinewidth_linear = sde_cfg->max_wb_linewidth_linear;
  2204. if (wb->id >= LINE_MODE_WB_OFFSET)
  2205. set_bit(SDE_WB_LINE_MODE, &wb->features);
  2206. else
  2207. set_bit(SDE_WB_BLOCK_MODE, &wb->features);
  2208. set_bit(SDE_WB_TRAFFIC_SHAPER, &wb->features);
  2209. set_bit(SDE_WB_YUV_CONFIG, &wb->features);
  2210. if (sde_cfg->has_cdp)
  2211. set_bit(SDE_WB_CDP, &wb->features);
  2212. set_bit(SDE_WB_QOS, &wb->features);
  2213. if (sde_cfg->vbif_qos_nlvl == 8)
  2214. set_bit(SDE_WB_QOS_8LVL, &wb->features);
  2215. if (sde_cfg->has_wb_ubwc)
  2216. set_bit(SDE_WB_UBWC, &wb->features);
  2217. if (sde_cfg->has_cwb_crop)
  2218. set_bit(SDE_WB_CROP, &wb->features);
  2219. set_bit(SDE_WB_XY_ROI_OFFSET, &wb->features);
  2220. if (IS_SDE_CTL_REV_100(sde_cfg->ctl_rev))
  2221. set_bit(SDE_WB_INPUT_CTRL, &wb->features);
  2222. if (sde_cfg->has_dedicated_cwb_support) {
  2223. set_bit(SDE_WB_HAS_DCWB, &wb->features);
  2224. if (IS_SDE_CTL_REV_100(sde_cfg->ctl_rev))
  2225. set_bit(SDE_WB_DCWB_CTRL, &wb->features);
  2226. if (major_version >= SDE_HW_MAJOR(SDE_HW_VER_810)) {
  2227. sde_cfg->cwb_blk_off = 0x66A00;
  2228. sde_cfg->cwb_blk_stride = 0x400;
  2229. } else {
  2230. sde_cfg->cwb_blk_off = 0x83000;
  2231. sde_cfg->cwb_blk_stride = 0x100;
  2232. }
  2233. } else if (sde_cfg->has_cwb_support) {
  2234. set_bit(SDE_WB_HAS_CWB, &wb->features);
  2235. if (IS_SDE_CTL_REV_100(sde_cfg->ctl_rev))
  2236. set_bit(SDE_WB_CWB_CTRL, &wb->features);
  2237. if (major_version >= SDE_HW_MAJOR(SDE_HW_VER_700)) {
  2238. sde_cfg->cwb_blk_off = 0x6A200;
  2239. sde_cfg->cwb_blk_stride = 0x1000;
  2240. } else {
  2241. sde_cfg->cwb_blk_off = 0x83000;
  2242. sde_cfg->cwb_blk_stride = 0x100;
  2243. }
  2244. }
  2245. for (j = 0; j < sde_cfg->mdp_count; j++) {
  2246. sde_cfg->mdp[j].clk_ctrls[wb->clk_ctrl].reg_off =
  2247. PROP_BITVALUE_ACCESS(prop_value,
  2248. WB_CLK_CTRL, i, 0);
  2249. sde_cfg->mdp[j].clk_ctrls[wb->clk_ctrl].bit_off =
  2250. PROP_BITVALUE_ACCESS(prop_value,
  2251. WB_CLK_CTRL, i, 1);
  2252. sde_cfg->mdp[j].clk_status[wb->clk_ctrl].reg_off =
  2253. PROP_BITVALUE_ACCESS(prop_value,
  2254. WB_CLK_STATUS, i, 0);
  2255. sde_cfg->mdp[j].clk_status[wb->clk_ctrl].bit_off =
  2256. PROP_BITVALUE_ACCESS(prop_value,
  2257. WB_CLK_STATUS, i, 1);
  2258. }
  2259. wb->format_list = sde_cfg->wb_formats;
  2260. SDE_DEBUG(
  2261. "wb:%d xin:%d vbif:%d clk%d:%x/%d\n",
  2262. wb->id - WB_0,
  2263. wb->xin_id,
  2264. wb->vbif_idx,
  2265. wb->clk_ctrl,
  2266. sde_cfg->mdp[0].clk_ctrls[wb->clk_ctrl].reg_off,
  2267. sde_cfg->mdp[0].clk_ctrls[wb->clk_ctrl].bit_off);
  2268. }
  2269. end:
  2270. kfree(prop_value);
  2271. return rc;
  2272. }
  2273. static int sde_dspp_top_parse_dt(struct device_node *np,
  2274. struct sde_mdss_cfg *sde_cfg)
  2275. {
  2276. int rc, prop_count[DSPP_TOP_PROP_MAX];
  2277. bool prop_exists[DSPP_TOP_PROP_MAX];
  2278. struct sde_prop_value *prop_value = NULL;
  2279. u32 off_count;
  2280. if (!sde_cfg) {
  2281. SDE_ERROR("invalid argument\n");
  2282. rc = -EINVAL;
  2283. goto end;
  2284. }
  2285. prop_value = kzalloc(DSPP_TOP_PROP_MAX *
  2286. sizeof(struct sde_prop_value), GFP_KERNEL);
  2287. if (!prop_value) {
  2288. rc = -ENOMEM;
  2289. goto end;
  2290. }
  2291. rc = _validate_dt_entry(np, dspp_top_prop, ARRAY_SIZE(dspp_top_prop),
  2292. prop_count, &off_count);
  2293. if (rc)
  2294. goto end;
  2295. rc = _read_dt_entry(np, dspp_top_prop, ARRAY_SIZE(dspp_top_prop),
  2296. prop_count, prop_exists, prop_value);
  2297. if (rc)
  2298. goto end;
  2299. if (off_count != 1) {
  2300. SDE_ERROR("invalid dspp_top off_count:%d\n", off_count);
  2301. rc = -EINVAL;
  2302. goto end;
  2303. }
  2304. sde_cfg->dspp_top.base =
  2305. PROP_VALUE_ACCESS(prop_value, DSPP_TOP_OFF, 0);
  2306. sde_cfg->dspp_top.len =
  2307. PROP_VALUE_ACCESS(prop_value, DSPP_TOP_SIZE, 0);
  2308. snprintf(sde_cfg->dspp_top.name, SDE_HW_BLK_NAME_LEN, "dspp_top");
  2309. end:
  2310. kfree(prop_value);
  2311. return rc;
  2312. }
  2313. static int _sde_ad_parse_dt(struct device_node *np,
  2314. struct sde_mdss_cfg *sde_cfg)
  2315. {
  2316. int rc = 0;
  2317. int off_count, i;
  2318. struct sde_dt_props *props;
  2319. props = sde_get_dt_props(np, AD_PROP_MAX, ad_prop,
  2320. ARRAY_SIZE(ad_prop), &off_count);
  2321. if (IS_ERR(props))
  2322. return PTR_ERR(props);
  2323. sde_cfg->ad_count = off_count;
  2324. if (off_count > sde_cfg->dspp_count) {
  2325. SDE_ERROR("limiting %d AD blocks to %d DSPP instances\n",
  2326. off_count, sde_cfg->dspp_count);
  2327. sde_cfg->ad_count = sde_cfg->dspp_count;
  2328. }
  2329. for (i = 0; i < sde_cfg->dspp_count; i++) {
  2330. struct sde_dspp_cfg *dspp = &sde_cfg->dspp[i];
  2331. struct sde_dspp_sub_blks *sblk = sde_cfg->dspp[i].sblk;
  2332. sblk->ad.id = SDE_DSPP_AD;
  2333. if (!props->exists[AD_OFF])
  2334. continue;
  2335. if (i < off_count) {
  2336. sblk->ad.base = PROP_VALUE_ACCESS(props->values,
  2337. AD_OFF, i);
  2338. sblk->ad.version = PROP_VALUE_ACCESS(props->values,
  2339. AD_VERSION, 0);
  2340. set_bit(SDE_DSPP_AD, &dspp->features);
  2341. rc = _add_to_irq_offset_list(sde_cfg,
  2342. SDE_INTR_HWBLK_AD4, dspp->id,
  2343. dspp->base + sblk->ad.base);
  2344. if (rc)
  2345. goto end;
  2346. }
  2347. }
  2348. end:
  2349. sde_put_dt_props(props);
  2350. return rc;
  2351. }
  2352. static int _sde_ltm_parse_dt(struct device_node *np,
  2353. struct sde_mdss_cfg *sde_cfg)
  2354. {
  2355. int rc = 0;
  2356. int off_count, i;
  2357. struct sde_dt_props *props;
  2358. props = sde_get_dt_props(np, LTM_PROP_MAX, ltm_prop,
  2359. ARRAY_SIZE(ltm_prop), &off_count);
  2360. if (IS_ERR(props))
  2361. return PTR_ERR(props);
  2362. sde_cfg->ltm_count = off_count;
  2363. if (off_count > sde_cfg->dspp_count) {
  2364. SDE_ERROR("limiting %d LTM blocks to %d DSPP instances\n",
  2365. off_count, sde_cfg->dspp_count);
  2366. sde_cfg->ltm_count = sde_cfg->dspp_count;
  2367. }
  2368. for (i = 0; i < sde_cfg->dspp_count; i++) {
  2369. struct sde_dspp_cfg *dspp = &sde_cfg->dspp[i];
  2370. struct sde_dspp_sub_blks *sblk = sde_cfg->dspp[i].sblk;
  2371. sblk->ltm.id = SDE_DSPP_LTM;
  2372. if (!props->exists[LTM_OFF])
  2373. continue;
  2374. if (i < off_count) {
  2375. sblk->ltm.base = PROP_VALUE_ACCESS(props->values,
  2376. LTM_OFF, i);
  2377. sblk->ltm.version = PROP_VALUE_ACCESS(props->values,
  2378. LTM_VERSION, 0);
  2379. set_bit(SDE_DSPP_LTM, &dspp->features);
  2380. rc = _add_to_irq_offset_list(sde_cfg,
  2381. SDE_INTR_HWBLK_LTM, dspp->id,
  2382. dspp->base + sblk->ltm.base);
  2383. if (rc)
  2384. goto end;
  2385. }
  2386. }
  2387. end:
  2388. sde_put_dt_props(props);
  2389. return rc;
  2390. }
  2391. static int _sde_dspp_demura_parse_dt(struct device_node *np,
  2392. struct sde_mdss_cfg *sde_cfg)
  2393. {
  2394. int off_count, i;
  2395. struct sde_dt_props *props;
  2396. struct sde_dspp_cfg *dspp;
  2397. struct sde_dspp_sub_blks *sblk;
  2398. props = sde_get_dt_props(np, DEMURA_PROP_MAX, demura_prop,
  2399. ARRAY_SIZE(demura_prop), &off_count);
  2400. if (IS_ERR(props))
  2401. return PTR_ERR(props);
  2402. sde_cfg->demura_count = off_count;
  2403. if (off_count > sde_cfg->dspp_count) {
  2404. SDE_ERROR("limiting %d demura blocks to %d DSPP instances\n",
  2405. off_count, sde_cfg->dspp_count);
  2406. sde_cfg->demura_count = sde_cfg->dspp_count;
  2407. }
  2408. for (i = 0; i < sde_cfg->dspp_count; i++) {
  2409. dspp = &sde_cfg->dspp[i];
  2410. sblk = sde_cfg->dspp[i].sblk;
  2411. sblk->demura.id = SDE_DSPP_DEMURA;
  2412. if (props->exists[DEMURA_OFF] && i < off_count) {
  2413. sblk->demura.base = PROP_VALUE_ACCESS(props->values,
  2414. DEMURA_OFF, i);
  2415. sblk->demura.len = PROP_VALUE_ACCESS(props->values,
  2416. DEMURA_LEN, 0);
  2417. sblk->demura.version = PROP_VALUE_ACCESS(props->values,
  2418. DEMURA_VERSION, 0);
  2419. set_bit(SDE_DSPP_DEMURA, &dspp->features);
  2420. }
  2421. }
  2422. sde_put_dt_props(props);
  2423. return 0;
  2424. }
  2425. static int _sde_dspp_spr_parse_dt(struct device_node *np,
  2426. struct sde_mdss_cfg *sde_cfg)
  2427. {
  2428. int off_count, i;
  2429. struct sde_dt_props *props;
  2430. struct sde_dspp_cfg *dspp;
  2431. struct sde_dspp_sub_blks *sblk;
  2432. props = sde_get_dt_props(np, SPR_PROP_MAX, spr_prop,
  2433. ARRAY_SIZE(spr_prop), &off_count);
  2434. if (IS_ERR(props))
  2435. return PTR_ERR(props);
  2436. sde_cfg->spr_count = off_count;
  2437. if (off_count > sde_cfg->dspp_count) {
  2438. SDE_ERROR("limiting %d spr blocks to %d DSPP instances\n",
  2439. off_count, sde_cfg->dspp_count);
  2440. sde_cfg->spr_count = sde_cfg->dspp_count;
  2441. }
  2442. for (i = 0; i < sde_cfg->dspp_count; i++) {
  2443. dspp = &sde_cfg->dspp[i];
  2444. sblk = sde_cfg->dspp[i].sblk;
  2445. sblk->spr.id = SDE_DSPP_SPR;
  2446. if (props->exists[SPR_OFF] && i < off_count) {
  2447. sblk->spr.base = PROP_VALUE_ACCESS(props->values,
  2448. SPR_OFF, i);
  2449. sblk->spr.len = PROP_VALUE_ACCESS(props->values,
  2450. SPR_LEN, 0);
  2451. sblk->spr.version = PROP_VALUE_ACCESS(props->values,
  2452. SPR_VERSION, 0);
  2453. set_bit(SDE_DSPP_SPR, &dspp->features);
  2454. }
  2455. }
  2456. sde_put_dt_props(props);
  2457. return 0;
  2458. }
  2459. static int _sde_rc_parse_dt(struct device_node *np,
  2460. struct sde_mdss_cfg *sde_cfg)
  2461. {
  2462. int off_count, i;
  2463. struct sde_dt_props *props;
  2464. props = sde_get_dt_props(np, RC_PROP_MAX, rc_prop,
  2465. ARRAY_SIZE(rc_prop), &off_count);
  2466. if (IS_ERR(props))
  2467. return PTR_ERR(props);
  2468. sde_cfg->rc_count = off_count;
  2469. if (off_count > sde_cfg->dspp_count) {
  2470. SDE_ERROR("limiting %d RC blocks to %d DSPP instances\n",
  2471. off_count, sde_cfg->dspp_count);
  2472. sde_cfg->rc_count = sde_cfg->dspp_count;
  2473. }
  2474. for (i = 0; i < sde_cfg->dspp_count; i++) {
  2475. struct sde_dspp_cfg *dspp = &sde_cfg->dspp[i];
  2476. struct sde_dspp_sub_blks *sblk = sde_cfg->dspp[i].sblk;
  2477. sblk->rc.id = SDE_DSPP_RC;
  2478. if (!props->exists[RC_OFF])
  2479. continue;
  2480. if (i < off_count) {
  2481. sblk->rc.base = PROP_VALUE_ACCESS(props->values,
  2482. RC_OFF, i);
  2483. sblk->rc.len = PROP_VALUE_ACCESS(props->values,
  2484. RC_LEN, 0);
  2485. sblk->rc.version = PROP_VALUE_ACCESS(props->values,
  2486. RC_VERSION, 0);
  2487. sblk->rc.mem_total_size = PROP_VALUE_ACCESS(
  2488. props->values, RC_MEM_TOTAL_SIZE, 0);
  2489. sblk->rc.idx = i;
  2490. set_bit(SDE_DSPP_RC, &dspp->features);
  2491. }
  2492. }
  2493. sde_put_dt_props(props);
  2494. return 0;
  2495. }
  2496. static int _sde_lm_noise_parse_dt(struct device_node *np,
  2497. struct sde_mdss_cfg *sde_cfg)
  2498. {
  2499. int off_count, i;
  2500. struct sde_dt_props *props;
  2501. props = sde_get_dt_props(np, NOISEL_LAYER_PROP_MAX, noise_layer_prop,
  2502. ARRAY_SIZE(noise_layer_prop), &off_count);
  2503. if (IS_ERR(props)) {
  2504. SDE_ERROR("noise: failed to get dt props\n");
  2505. return PTR_ERR(props);
  2506. }
  2507. if (!props->exists[NOISE_LAYER_OFF] ||
  2508. !props->exists[NOISE_LAYER_VERSION]) {
  2509. SDE_INFO("noise: prop doesnt exist %d %d\n",
  2510. props->exists[NOISE_LAYER_OFF],
  2511. props->exists[NOISE_LAYER_VERSION]);
  2512. goto exit;
  2513. }
  2514. for (i = 0; i < sde_cfg->mixer_count; i++) {
  2515. struct sde_lm_cfg *lm = &sde_cfg->mixer[i];
  2516. struct sde_lm_sub_blks *sblk = lm->sblk;
  2517. sblk->nlayer.base = PROP_VALUE_ACCESS(props->values,
  2518. NOISE_LAYER_OFF, 0);
  2519. sblk->nlayer.version = PROP_VALUE_ACCESS(props->values,
  2520. NOISE_LAYER_VERSION, 0);
  2521. sblk->nlayer.len = sizeof(u32);
  2522. set_bit(SDE_MIXER_NOISE_LAYER, &lm->features);
  2523. }
  2524. exit:
  2525. sde_put_dt_props(props);
  2526. return 0;
  2527. }
  2528. static void _sde_init_dspp_sblk(struct sde_dspp_cfg *dspp,
  2529. struct sde_pp_blk *pp_blk, int prop_id, int blk_id,
  2530. struct sde_dt_props *props)
  2531. {
  2532. pp_blk->id = prop_id;
  2533. if (props->exists[blk_id]) {
  2534. pp_blk->base = PROP_VALUE_ACCESS(props->values,
  2535. blk_id, 0);
  2536. pp_blk->version = PROP_VALUE_ACCESS(props->values,
  2537. blk_id, 1);
  2538. pp_blk->len = 0;
  2539. set_bit(prop_id, &dspp->features);
  2540. }
  2541. }
  2542. static int _sde_dspp_sblks_parse_dt(struct device_node *np,
  2543. struct sde_mdss_cfg *sde_cfg)
  2544. {
  2545. int i;
  2546. struct device_node *snp = NULL;
  2547. struct sde_dt_props *props;
  2548. snp = of_get_child_by_name(np, dspp_prop[DSPP_BLOCKS].prop_name);
  2549. if (!snp)
  2550. return 0;
  2551. props = sde_get_dt_props(snp, DSPP_BLOCKS_PROP_MAX,
  2552. dspp_blocks_prop, ARRAY_SIZE(dspp_blocks_prop),
  2553. NULL);
  2554. if (IS_ERR(props))
  2555. return PTR_ERR(props);
  2556. for (i = 0; i < sde_cfg->dspp_count; i++) {
  2557. struct sde_dspp_cfg *dspp = &sde_cfg->dspp[i];
  2558. struct sde_dspp_sub_blks *sblk = sde_cfg->dspp[i].sblk;
  2559. _sde_init_dspp_sblk(dspp, &sblk->igc, SDE_DSPP_IGC,
  2560. DSPP_IGC_PROP, props);
  2561. _sde_init_dspp_sblk(dspp, &sblk->pcc, SDE_DSPP_PCC,
  2562. DSPP_PCC_PROP, props);
  2563. _sde_init_dspp_sblk(dspp, &sblk->gc, SDE_DSPP_GC,
  2564. DSPP_GC_PROP, props);
  2565. _sde_init_dspp_sblk(dspp, &sblk->gamut, SDE_DSPP_GAMUT,
  2566. DSPP_GAMUT_PROP, props);
  2567. _sde_init_dspp_sblk(dspp, &sblk->dither, SDE_DSPP_DITHER,
  2568. DSPP_DITHER_PROP, props);
  2569. _sde_init_dspp_sblk(dspp, &sblk->hist, SDE_DSPP_HIST,
  2570. DSPP_HIST_PROP, props);
  2571. _sde_init_dspp_sblk(dspp, &sblk->hsic, SDE_DSPP_HSIC,
  2572. DSPP_HSIC_PROP, props);
  2573. _sde_init_dspp_sblk(dspp, &sblk->memcolor, SDE_DSPP_MEMCOLOR,
  2574. DSPP_MEMCOLOR_PROP, props);
  2575. _sde_init_dspp_sblk(dspp, &sblk->sixzone, SDE_DSPP_SIXZONE,
  2576. DSPP_SIXZONE_PROP, props);
  2577. _sde_init_dspp_sblk(dspp, &sblk->vlut, SDE_DSPP_VLUT,
  2578. DSPP_VLUT_PROP, props);
  2579. }
  2580. sde_put_dt_props(props);
  2581. return 0;
  2582. }
  2583. static int _sde_dspp_cmn_parse_dt(struct device_node *np,
  2584. struct sde_mdss_cfg *sde_cfg)
  2585. {
  2586. int rc = 0;
  2587. int i, off_count;
  2588. struct sde_dt_props *props;
  2589. struct sde_dspp_sub_blks *sblk;
  2590. props = sde_get_dt_props(np, DSPP_PROP_MAX, dspp_prop,
  2591. ARRAY_SIZE(dspp_prop), &off_count);
  2592. if (IS_ERR(props))
  2593. return PTR_ERR(props);
  2594. if (off_count > MAX_BLOCKS) {
  2595. SDE_ERROR("off_count %d exceeds MAX_BLOCKS, limiting to %d\n",
  2596. off_count, MAX_BLOCKS);
  2597. off_count = MAX_BLOCKS;
  2598. }
  2599. sde_cfg->dspp_count = off_count;
  2600. for (i = 0; i < sde_cfg->dspp_count; i++) {
  2601. sde_cfg->dspp[i].base = PROP_VALUE_ACCESS(props->values,
  2602. DSPP_OFF, i);
  2603. sde_cfg->dspp[i].len = PROP_VALUE_ACCESS(props->values,
  2604. DSPP_SIZE, 0);
  2605. sde_cfg->dspp[i].id = DSPP_0 + i;
  2606. snprintf(sde_cfg->dspp[i].name, SDE_HW_BLK_NAME_LEN, "dspp_%d",
  2607. i);
  2608. /* create an empty sblk for each dspp */
  2609. sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
  2610. if (!sblk) {
  2611. rc = -ENOMEM;
  2612. /* catalog deinit will release the allocated blocks */
  2613. goto end;
  2614. }
  2615. sde_cfg->dspp[i].sblk = sblk;
  2616. }
  2617. end:
  2618. sde_put_dt_props(props);
  2619. return rc;
  2620. }
  2621. static int sde_dspp_parse_dt(struct device_node *np,
  2622. struct sde_mdss_cfg *sde_cfg)
  2623. {
  2624. int rc;
  2625. rc = _sde_dspp_cmn_parse_dt(np, sde_cfg);
  2626. if (rc)
  2627. goto end;
  2628. rc = _sde_dspp_sblks_parse_dt(np, sde_cfg);
  2629. if (rc)
  2630. goto end;
  2631. rc = _sde_ad_parse_dt(np, sde_cfg);
  2632. if (rc)
  2633. goto end;
  2634. rc = _sde_ltm_parse_dt(np, sde_cfg);
  2635. if (rc)
  2636. goto end;
  2637. rc = _sde_dspp_spr_parse_dt(np, sde_cfg);
  2638. if (rc)
  2639. goto end;
  2640. rc = _sde_dspp_demura_parse_dt(np, sde_cfg);
  2641. if (rc)
  2642. goto end;
  2643. rc = _sde_rc_parse_dt(np, sde_cfg);
  2644. end:
  2645. return rc;
  2646. }
  2647. static int sde_ds_parse_dt(struct device_node *np,
  2648. struct sde_mdss_cfg *sde_cfg)
  2649. {
  2650. int rc, prop_count[DS_PROP_MAX], top_prop_count[DS_TOP_PROP_MAX], i;
  2651. struct sde_prop_value *prop_value = NULL, *top_prop_value = NULL;
  2652. bool prop_exists[DS_PROP_MAX], top_prop_exists[DS_TOP_PROP_MAX];
  2653. u32 off_count = 0, top_off_count = 0;
  2654. struct sde_ds_cfg *ds;
  2655. struct sde_ds_top_cfg *ds_top = NULL;
  2656. if (!sde_cfg) {
  2657. SDE_ERROR("invalid argument\n");
  2658. rc = -EINVAL;
  2659. goto end;
  2660. }
  2661. if (!sde_cfg->mdp[0].has_dest_scaler) {
  2662. SDE_DEBUG("dest scaler feature not supported\n");
  2663. rc = 0;
  2664. goto end;
  2665. }
  2666. /* Parse the dest scaler top register offset and capabilities */
  2667. top_prop_value = kzalloc(DS_TOP_PROP_MAX *
  2668. sizeof(struct sde_prop_value), GFP_KERNEL);
  2669. if (!top_prop_value) {
  2670. rc = -ENOMEM;
  2671. goto end;
  2672. }
  2673. rc = _validate_dt_entry(np, ds_top_prop,
  2674. ARRAY_SIZE(ds_top_prop),
  2675. top_prop_count, &top_off_count);
  2676. if (rc)
  2677. goto end;
  2678. rc = _read_dt_entry(np, ds_top_prop,
  2679. ARRAY_SIZE(ds_top_prop), top_prop_count,
  2680. top_prop_exists, top_prop_value);
  2681. if (rc)
  2682. goto end;
  2683. /* Parse the offset of each dest scaler block */
  2684. prop_value = kcalloc(DS_PROP_MAX,
  2685. sizeof(struct sde_prop_value), GFP_KERNEL);
  2686. if (!prop_value) {
  2687. rc = -ENOMEM;
  2688. goto end;
  2689. }
  2690. rc = _validate_dt_entry(np, ds_prop, ARRAY_SIZE(ds_prop), prop_count,
  2691. &off_count);
  2692. if (rc)
  2693. goto end;
  2694. sde_cfg->ds_count = off_count;
  2695. rc = _read_dt_entry(np, ds_prop, ARRAY_SIZE(ds_prop), prop_count,
  2696. prop_exists, prop_value);
  2697. if (rc)
  2698. goto end;
  2699. if (!off_count)
  2700. goto end;
  2701. ds_top = kzalloc(sizeof(struct sde_ds_top_cfg), GFP_KERNEL);
  2702. if (!ds_top) {
  2703. rc = -ENOMEM;
  2704. goto end;
  2705. }
  2706. ds_top->id = DS_TOP;
  2707. snprintf(ds_top->name, SDE_HW_BLK_NAME_LEN, "ds_top_%u",
  2708. ds_top->id - DS_TOP);
  2709. ds_top->base = PROP_VALUE_ACCESS(top_prop_value, DS_TOP_OFF, 0);
  2710. ds_top->len = PROP_VALUE_ACCESS(top_prop_value, DS_TOP_LEN, 0);
  2711. ds_top->maxupscale = MAX_UPSCALE_RATIO;
  2712. ds_top->maxinputwidth = PROP_VALUE_ACCESS(top_prop_value,
  2713. DS_TOP_INPUT_LINEWIDTH, 0);
  2714. if (!top_prop_exists[DS_TOP_INPUT_LINEWIDTH])
  2715. ds_top->maxinputwidth = DEFAULT_SDE_LINE_WIDTH;
  2716. ds_top->maxoutputwidth = PROP_VALUE_ACCESS(top_prop_value,
  2717. DS_TOP_OUTPUT_LINEWIDTH, 0);
  2718. if (!top_prop_exists[DS_TOP_OUTPUT_LINEWIDTH])
  2719. ds_top->maxoutputwidth = DEFAULT_SDE_OUTPUT_LINE_WIDTH;
  2720. for (i = 0; i < off_count; i++) {
  2721. ds = sde_cfg->ds + i;
  2722. ds->top = ds_top;
  2723. ds->base = PROP_VALUE_ACCESS(prop_value, DS_OFF, i);
  2724. ds->id = DS_0 + i;
  2725. ds->len = PROP_VALUE_ACCESS(prop_value, DS_LEN, 0);
  2726. snprintf(ds->name, SDE_HW_BLK_NAME_LEN, "ds_%u",
  2727. ds->id - DS_0);
  2728. if (!prop_exists[DS_LEN])
  2729. ds->len = DEFAULT_SDE_HW_BLOCK_LEN;
  2730. if (sde_cfg->qseed_sw_lib_rev == SDE_SSPP_SCALER_QSEED3)
  2731. set_bit(SDE_SSPP_SCALER_QSEED3, &ds->features);
  2732. else if (sde_cfg->qseed_sw_lib_rev ==
  2733. SDE_SSPP_SCALER_QSEED3LITE)
  2734. set_bit(SDE_SSPP_SCALER_QSEED3LITE, &ds->features);
  2735. }
  2736. end:
  2737. kfree(top_prop_value);
  2738. kfree(prop_value);
  2739. return rc;
  2740. };
  2741. static int sde_dsc_parse_dt(struct device_node *np,
  2742. struct sde_mdss_cfg *sde_cfg)
  2743. {
  2744. int rc, prop_count[MAX_BLOCKS], i;
  2745. struct sde_prop_value *prop_value;
  2746. bool prop_exists[DSC_PROP_MAX];
  2747. u32 off_count, dsc_pair_mask, dsc_rev;
  2748. const char *rev;
  2749. struct sde_dsc_cfg *dsc;
  2750. struct sde_dsc_sub_blks *sblk;
  2751. if (!sde_cfg) {
  2752. SDE_ERROR("invalid argument\n");
  2753. return -EINVAL;
  2754. }
  2755. prop_value = kzalloc(DSC_PROP_MAX *
  2756. sizeof(struct sde_prop_value), GFP_KERNEL);
  2757. if (!prop_value)
  2758. return -ENOMEM;
  2759. rc = _validate_dt_entry(np, dsc_prop, ARRAY_SIZE(dsc_prop), prop_count,
  2760. &off_count);
  2761. if (rc)
  2762. goto end;
  2763. sde_cfg->dsc_count = off_count;
  2764. rc = of_property_read_string(np, dsc_prop[DSC_REV].prop_name, &rev);
  2765. if (!rc && !strcmp(rev, "dsc_1_2"))
  2766. dsc_rev = SDE_DSC_HW_REV_1_2;
  2767. else if (!rc && !strcmp(rev, "dsc_1_1"))
  2768. dsc_rev = SDE_DSC_HW_REV_1_1;
  2769. else
  2770. /* default configuration */
  2771. dsc_rev = SDE_DSC_HW_REV_1_1;
  2772. rc = _read_dt_entry(np, dsc_prop, ARRAY_SIZE(dsc_prop), prop_count,
  2773. prop_exists, prop_value);
  2774. if (rc)
  2775. goto end;
  2776. sde_cfg->max_dsc_width = prop_exists[DSC_LINEWIDTH] ?
  2777. PROP_VALUE_ACCESS(prop_value, DSC_LINEWIDTH, 0) :
  2778. DEFAULT_SDE_LINE_WIDTH;
  2779. for (i = 0; i < off_count; i++) {
  2780. dsc = sde_cfg->dsc + i;
  2781. sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
  2782. if (!sblk) {
  2783. rc = -ENOMEM;
  2784. /* catalog deinit will release the allocated blocks */
  2785. goto end;
  2786. }
  2787. dsc->sblk = sblk;
  2788. dsc->base = PROP_VALUE_ACCESS(prop_value, DSC_OFF, i);
  2789. dsc->id = DSC_0 + i;
  2790. dsc->len = PROP_VALUE_ACCESS(prop_value, DSC_LEN, 0);
  2791. snprintf(dsc->name, SDE_HW_BLK_NAME_LEN, "dsc_%u",
  2792. dsc->id - DSC_0);
  2793. if (!prop_exists[DSC_LEN])
  2794. dsc->len = DEFAULT_SDE_HW_BLOCK_LEN;
  2795. if (IS_SDE_CTL_REV_100(sde_cfg->ctl_rev))
  2796. set_bit(SDE_DSC_OUTPUT_CTRL, &dsc->features);
  2797. dsc_pair_mask = PROP_VALUE_ACCESS(prop_value,
  2798. DSC_PAIR_MASK, i);
  2799. if (dsc_pair_mask)
  2800. set_bit(dsc_pair_mask, dsc->dsc_pair_mask);
  2801. if (dsc_rev == SDE_DSC_HW_REV_1_2) {
  2802. sblk->enc.base = PROP_VALUE_ACCESS(prop_value,
  2803. DSC_ENC, i);
  2804. sblk->enc.len = PROP_VALUE_ACCESS(prop_value,
  2805. DSC_ENC_LEN, 0);
  2806. sblk->ctl.base = PROP_VALUE_ACCESS(prop_value,
  2807. DSC_CTL, i);
  2808. sblk->ctl.len = PROP_VALUE_ACCESS(prop_value,
  2809. DSC_CTL_LEN, 0);
  2810. set_bit(SDE_DSC_HW_REV_1_2, &dsc->features);
  2811. if (PROP_VALUE_ACCESS(prop_value, DSC_422, i))
  2812. set_bit(SDE_DSC_NATIVE_422_EN,
  2813. &dsc->features);
  2814. } else {
  2815. set_bit(SDE_DSC_HW_REV_1_1, &dsc->features);
  2816. }
  2817. }
  2818. end:
  2819. kfree(prop_value);
  2820. return rc;
  2821. };
  2822. static int sde_vdc_parse_dt(struct device_node *np,
  2823. struct sde_mdss_cfg *sde_cfg)
  2824. {
  2825. int rc, prop_count[MAX_BLOCKS], i;
  2826. struct sde_prop_value *prop_value = NULL;
  2827. bool prop_exists[VDC_PROP_MAX];
  2828. u32 off_count, vdc_rev;
  2829. const char *rev;
  2830. struct sde_vdc_cfg *vdc;
  2831. struct sde_vdc_sub_blks *sblk;
  2832. if (!sde_cfg) {
  2833. SDE_ERROR("invalid argument\n");
  2834. rc = -EINVAL;
  2835. goto end;
  2836. }
  2837. prop_value = kzalloc(VDC_PROP_MAX *
  2838. sizeof(struct sde_prop_value), GFP_KERNEL);
  2839. if (!prop_value) {
  2840. rc = -ENOMEM;
  2841. goto end;
  2842. }
  2843. rc = _validate_dt_entry(np, vdc_prop, ARRAY_SIZE(vdc_prop), prop_count,
  2844. &off_count);
  2845. if (rc)
  2846. goto end;
  2847. sde_cfg->vdc_count = off_count;
  2848. rc = of_property_read_string(np, vdc_prop[VDC_REV].prop_name, &rev);
  2849. if ((rc == -EINVAL) || (rc == -ENODATA)) {
  2850. vdc_rev = SDE_VDC_HW_REV_1_2;
  2851. rc = 0;
  2852. } else if (!rc && !strcmp(rev, "vdc_1_2")) {
  2853. vdc_rev = SDE_VDC_HW_REV_1_2;
  2854. rc = 0;
  2855. } else {
  2856. SDE_ERROR("invalid vdc configuration\n");
  2857. goto end;
  2858. }
  2859. rc = _read_dt_entry(np, vdc_prop, ARRAY_SIZE(vdc_prop), prop_count,
  2860. prop_exists, prop_value);
  2861. if (rc)
  2862. goto end;
  2863. for (i = 0; i < off_count; i++) {
  2864. vdc = sde_cfg->vdc + i;
  2865. sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
  2866. if (!sblk) {
  2867. rc = -ENOMEM;
  2868. /* catalog deinit will release the allocated blocks */
  2869. goto end;
  2870. }
  2871. vdc->sblk = sblk;
  2872. vdc->base = PROP_VALUE_ACCESS(prop_value, VDC_OFF, i);
  2873. vdc->id = VDC_0 + i;
  2874. vdc->len = PROP_VALUE_ACCESS(prop_value, VDC_LEN, 0);
  2875. snprintf(vdc->name, SDE_HW_BLK_NAME_LEN, "vdc_%u",
  2876. vdc->id - VDC_0);
  2877. if (!prop_exists[VDC_LEN])
  2878. vdc->len = DEFAULT_SDE_HW_BLOCK_LEN;
  2879. sblk->enc.base = PROP_VALUE_ACCESS(prop_value,
  2880. VDC_ENC, i);
  2881. sblk->enc.len = PROP_VALUE_ACCESS(prop_value,
  2882. VDC_ENC_LEN, 0);
  2883. sblk->ctl.base = PROP_VALUE_ACCESS(prop_value,
  2884. VDC_CTL, i);
  2885. sblk->ctl.len = PROP_VALUE_ACCESS(prop_value,
  2886. VDC_CTL_LEN, 0);
  2887. set_bit(vdc_rev, &vdc->features);
  2888. }
  2889. end:
  2890. kfree(prop_value);
  2891. return rc;
  2892. };
  2893. static int sde_cdm_parse_dt(struct device_node *np,
  2894. struct sde_mdss_cfg *sde_cfg)
  2895. {
  2896. int rc, prop_count[HW_PROP_MAX], i;
  2897. struct sde_prop_value *prop_value = NULL;
  2898. bool prop_exists[HW_PROP_MAX];
  2899. u32 off_count;
  2900. struct sde_cdm_cfg *cdm;
  2901. if (!sde_cfg) {
  2902. SDE_ERROR("invalid argument\n");
  2903. rc = -EINVAL;
  2904. goto end;
  2905. }
  2906. prop_value = kzalloc(HW_PROP_MAX *
  2907. sizeof(struct sde_prop_value), GFP_KERNEL);
  2908. if (!prop_value) {
  2909. rc = -ENOMEM;
  2910. goto end;
  2911. }
  2912. rc = _validate_dt_entry(np, cdm_prop, ARRAY_SIZE(cdm_prop), prop_count,
  2913. &off_count);
  2914. if (rc)
  2915. goto end;
  2916. sde_cfg->cdm_count = off_count;
  2917. rc = _read_dt_entry(np, cdm_prop, ARRAY_SIZE(cdm_prop), prop_count,
  2918. prop_exists, prop_value);
  2919. if (rc)
  2920. goto end;
  2921. for (i = 0; i < off_count; i++) {
  2922. cdm = sde_cfg->cdm + i;
  2923. cdm->base = PROP_VALUE_ACCESS(prop_value, HW_OFF, i);
  2924. cdm->id = CDM_0 + i;
  2925. snprintf(cdm->name, SDE_HW_BLK_NAME_LEN, "cdm_%u",
  2926. cdm->id - CDM_0);
  2927. cdm->len = PROP_VALUE_ACCESS(prop_value, HW_LEN, 0);
  2928. /* intf3 and wb2 for cdm block */
  2929. cdm->wb_connect = sde_cfg->wb_count ? BIT(WB_2) : BIT(31);
  2930. cdm->intf_connect = sde_cfg->intf_count ? BIT(INTF_3) : BIT(31);
  2931. if (IS_SDE_CTL_REV_100(sde_cfg->ctl_rev))
  2932. set_bit(SDE_CDM_INPUT_CTRL, &cdm->features);
  2933. }
  2934. end:
  2935. kfree(prop_value);
  2936. return rc;
  2937. }
  2938. static int sde_uidle_parse_dt(struct device_node *np,
  2939. struct sde_mdss_cfg *sde_cfg)
  2940. {
  2941. int rc = 0, prop_count[UIDLE_PROP_MAX];
  2942. bool prop_exists[UIDLE_PROP_MAX];
  2943. struct sde_prop_value *prop_value = NULL;
  2944. u32 off_count;
  2945. if (!sde_cfg) {
  2946. SDE_ERROR("invalid argument\n");
  2947. return -EINVAL;
  2948. }
  2949. if (!sde_cfg->uidle_cfg.uidle_rev)
  2950. return 0;
  2951. prop_value = kcalloc(UIDLE_PROP_MAX,
  2952. sizeof(struct sde_prop_value), GFP_KERNEL);
  2953. if (!prop_value)
  2954. return -ENOMEM;
  2955. rc = _validate_dt_entry(np, uidle_prop, ARRAY_SIZE(uidle_prop),
  2956. prop_count, &off_count);
  2957. if (rc)
  2958. goto end;
  2959. rc = _read_dt_entry(np, uidle_prop, ARRAY_SIZE(uidle_prop), prop_count,
  2960. prop_exists, prop_value);
  2961. if (rc)
  2962. goto end;
  2963. if (!prop_exists[UIDLE_LEN] || !prop_exists[UIDLE_OFF]) {
  2964. SDE_DEBUG("offset/len missing, will disable uidle:%d,%d\n",
  2965. prop_exists[UIDLE_LEN], prop_exists[UIDLE_OFF]);
  2966. rc = -EINVAL;
  2967. goto end;
  2968. }
  2969. sde_cfg->uidle_cfg.id = UIDLE;
  2970. sde_cfg->uidle_cfg.base =
  2971. PROP_VALUE_ACCESS(prop_value, UIDLE_OFF, 0);
  2972. sde_cfg->uidle_cfg.len =
  2973. PROP_VALUE_ACCESS(prop_value, UIDLE_LEN, 0);
  2974. /* validate */
  2975. if (!sde_cfg->uidle_cfg.base || !sde_cfg->uidle_cfg.len) {
  2976. SDE_ERROR("invalid reg/len [%d, %d], will disable uidle\n",
  2977. sde_cfg->uidle_cfg.base, sde_cfg->uidle_cfg.len);
  2978. rc = -EINVAL;
  2979. }
  2980. end:
  2981. if (rc && sde_cfg->uidle_cfg.uidle_rev) {
  2982. SDE_DEBUG("wrong dt entries, will disable uidle\n");
  2983. sde_cfg->uidle_cfg.uidle_rev = 0;
  2984. }
  2985. kfree(prop_value);
  2986. /* optional feature, so always return success */
  2987. return 0;
  2988. }
  2989. static int sde_cache_parse_dt(struct device_node *np,
  2990. struct sde_mdss_cfg *sde_cfg)
  2991. {
  2992. struct llcc_slice_desc *slice;
  2993. struct sde_sc_cfg *sc_cfg = sde_cfg->sc_cfg;
  2994. struct device_node *llcc_node;
  2995. if (!sde_cfg) {
  2996. SDE_ERROR("invalid argument\n");
  2997. return -EINVAL;
  2998. }
  2999. if (!sde_cfg->syscache_supported)
  3000. return 0;
  3001. llcc_node = of_find_node_by_name(NULL, "cache-controller");
  3002. if (!llcc_node) {
  3003. SDE_DEBUG("cache controller missing, will disable img cache\n");
  3004. return 0;
  3005. }
  3006. slice = llcc_slice_getd(LLCC_DISP);
  3007. if (IS_ERR_OR_NULL(slice)) {
  3008. SDE_ERROR("failed to get system cache %ld\n", PTR_ERR(slice));
  3009. return -EINVAL;
  3010. }
  3011. sc_cfg[SDE_SYS_CACHE_DISP].has_sys_cache = true;
  3012. sc_cfg[SDE_SYS_CACHE_DISP].llcc_scid = llcc_get_slice_id(slice);
  3013. sc_cfg[SDE_SYS_CACHE_DISP].llcc_slice_size = llcc_get_slice_size(slice);
  3014. SDE_DEBUG("img cache scid:%d slice_size:%zu kb\n",
  3015. sc_cfg[SDE_SYS_CACHE_DISP].llcc_scid,
  3016. sc_cfg[SDE_SYS_CACHE_DISP].llcc_slice_size);
  3017. llcc_slice_putd(slice);
  3018. return 0;
  3019. }
  3020. static int _sde_vbif_populate_ot_parsing(struct sde_vbif_cfg *vbif,
  3021. struct sde_prop_value *prop_value, int *prop_count)
  3022. {
  3023. int j, k;
  3024. vbif->default_ot_rd_limit = PROP_VALUE_ACCESS(prop_value,
  3025. VBIF_DEFAULT_OT_RD_LIMIT, 0);
  3026. SDE_DEBUG("default_ot_rd_limit=%u\n",
  3027. vbif->default_ot_rd_limit);
  3028. vbif->default_ot_wr_limit = PROP_VALUE_ACCESS(prop_value,
  3029. VBIF_DEFAULT_OT_WR_LIMIT, 0);
  3030. SDE_DEBUG("default_ot_wr_limit=%u\n",
  3031. vbif->default_ot_wr_limit);
  3032. vbif->dynamic_ot_rd_tbl.count =
  3033. prop_count[VBIF_DYNAMIC_OT_RD_LIMIT] / 2;
  3034. SDE_DEBUG("dynamic_ot_rd_tbl.count=%u\n",
  3035. vbif->dynamic_ot_rd_tbl.count);
  3036. if (vbif->dynamic_ot_rd_tbl.count) {
  3037. vbif->dynamic_ot_rd_tbl.cfg = kcalloc(
  3038. vbif->dynamic_ot_rd_tbl.count,
  3039. sizeof(struct sde_vbif_dynamic_ot_cfg),
  3040. GFP_KERNEL);
  3041. if (!vbif->dynamic_ot_rd_tbl.cfg)
  3042. return -ENOMEM;
  3043. }
  3044. for (j = 0, k = 0; j < vbif->dynamic_ot_rd_tbl.count; j++) {
  3045. vbif->dynamic_ot_rd_tbl.cfg[j].pps = (u64)
  3046. PROP_VALUE_ACCESS(prop_value,
  3047. VBIF_DYNAMIC_OT_RD_LIMIT, k++);
  3048. vbif->dynamic_ot_rd_tbl.cfg[j].ot_limit =
  3049. PROP_VALUE_ACCESS(prop_value,
  3050. VBIF_DYNAMIC_OT_RD_LIMIT, k++);
  3051. SDE_DEBUG("dynamic_ot_rd_tbl[%d].cfg=<%llu %u>\n", j,
  3052. vbif->dynamic_ot_rd_tbl.cfg[j].pps,
  3053. vbif->dynamic_ot_rd_tbl.cfg[j].ot_limit);
  3054. }
  3055. vbif->dynamic_ot_wr_tbl.count =
  3056. prop_count[VBIF_DYNAMIC_OT_WR_LIMIT] / 2;
  3057. SDE_DEBUG("dynamic_ot_wr_tbl.count=%u\n",
  3058. vbif->dynamic_ot_wr_tbl.count);
  3059. if (vbif->dynamic_ot_wr_tbl.count) {
  3060. vbif->dynamic_ot_wr_tbl.cfg = kcalloc(
  3061. vbif->dynamic_ot_wr_tbl.count,
  3062. sizeof(struct sde_vbif_dynamic_ot_cfg),
  3063. GFP_KERNEL);
  3064. if (!vbif->dynamic_ot_wr_tbl.cfg)
  3065. return -ENOMEM;
  3066. }
  3067. for (j = 0, k = 0; j < vbif->dynamic_ot_wr_tbl.count; j++) {
  3068. vbif->dynamic_ot_wr_tbl.cfg[j].pps = (u64)
  3069. PROP_VALUE_ACCESS(prop_value,
  3070. VBIF_DYNAMIC_OT_WR_LIMIT, k++);
  3071. vbif->dynamic_ot_wr_tbl.cfg[j].ot_limit =
  3072. PROP_VALUE_ACCESS(prop_value,
  3073. VBIF_DYNAMIC_OT_WR_LIMIT, k++);
  3074. SDE_DEBUG("dynamic_ot_wr_tbl[%d].cfg=<%llu %u>\n", j,
  3075. vbif->dynamic_ot_wr_tbl.cfg[j].pps,
  3076. vbif->dynamic_ot_wr_tbl.cfg[j].ot_limit);
  3077. }
  3078. if (vbif->default_ot_rd_limit || vbif->default_ot_wr_limit ||
  3079. vbif->dynamic_ot_rd_tbl.count ||
  3080. vbif->dynamic_ot_wr_tbl.count)
  3081. set_bit(SDE_VBIF_QOS_OTLIM, &vbif->features);
  3082. return 0;
  3083. }
  3084. static int _sde_vbif_populate_qos_parsing(struct sde_mdss_cfg *sde_cfg,
  3085. struct sde_vbif_cfg *vbif, struct sde_prop_value *prop_value,
  3086. int *prop_count)
  3087. {
  3088. int i, j;
  3089. int prop_index = VBIF_QOS_RT_REMAP;
  3090. for (i = VBIF_RT_CLIENT;
  3091. ((i < VBIF_MAX_CLIENT) && (prop_index < VBIF_PROP_MAX));
  3092. i++, prop_index++) {
  3093. vbif->qos_tbl[i].npriority_lvl = prop_count[prop_index];
  3094. SDE_DEBUG("qos_tbl[%d].npriority_lvl=%u\n",
  3095. i, vbif->qos_tbl[i].npriority_lvl);
  3096. if (vbif->qos_tbl[i].npriority_lvl == sde_cfg->vbif_qos_nlvl) {
  3097. vbif->qos_tbl[i].priority_lvl = kcalloc(
  3098. vbif->qos_tbl[i].npriority_lvl,
  3099. sizeof(u32), GFP_KERNEL);
  3100. if (!vbif->qos_tbl[i].priority_lvl)
  3101. return -ENOMEM;
  3102. } else if (vbif->qos_tbl[i].npriority_lvl) {
  3103. vbif->qos_tbl[i].npriority_lvl = 0;
  3104. vbif->qos_tbl[i].priority_lvl = NULL;
  3105. SDE_ERROR("invalid qos table for client:%d, prop:%d\n",
  3106. i, prop_index);
  3107. }
  3108. for (j = 0; j < vbif->qos_tbl[i].npriority_lvl; j++) {
  3109. vbif->qos_tbl[i].priority_lvl[j] =
  3110. PROP_VALUE_ACCESS(prop_value, prop_index, j);
  3111. SDE_DEBUG("client:%d, prop:%d, lvl[%d]=%u\n",
  3112. i, prop_index, j,
  3113. vbif->qos_tbl[i].priority_lvl[j]);
  3114. }
  3115. if (vbif->qos_tbl[i].npriority_lvl)
  3116. set_bit(SDE_VBIF_QOS_REMAP, &vbif->features);
  3117. }
  3118. return 0;
  3119. }
  3120. static int _sde_vbif_populate(struct sde_mdss_cfg *sde_cfg,
  3121. struct sde_vbif_cfg *vbif, struct sde_prop_value *prop_value,
  3122. int *prop_count, u32 vbif_len, int i)
  3123. {
  3124. int j, k, rc;
  3125. vbif = sde_cfg->vbif + i;
  3126. vbif->base = PROP_VALUE_ACCESS(prop_value, VBIF_OFF, i);
  3127. vbif->len = vbif_len;
  3128. vbif->id = VBIF_0 + PROP_VALUE_ACCESS(prop_value, VBIF_ID, i);
  3129. snprintf(vbif->name, SDE_HW_BLK_NAME_LEN, "vbif_%u",
  3130. vbif->id - VBIF_0);
  3131. SDE_DEBUG("vbif:%d\n", vbif->id - VBIF_0);
  3132. vbif->xin_halt_timeout = VBIF_XIN_HALT_TIMEOUT;
  3133. rc = _sde_vbif_populate_ot_parsing(vbif, prop_value, prop_count);
  3134. if (rc)
  3135. return rc;
  3136. rc = _sde_vbif_populate_qos_parsing(sde_cfg, vbif, prop_value,
  3137. prop_count);
  3138. if (rc)
  3139. return rc;
  3140. vbif->memtype_count = prop_count[VBIF_MEMTYPE_0] +
  3141. prop_count[VBIF_MEMTYPE_1];
  3142. if (vbif->memtype_count > MAX_XIN_COUNT) {
  3143. vbif->memtype_count = 0;
  3144. SDE_ERROR("too many memtype defs, ignoring entries\n");
  3145. }
  3146. for (j = 0, k = 0; j < prop_count[VBIF_MEMTYPE_0]; j++)
  3147. vbif->memtype[k++] = PROP_VALUE_ACCESS(
  3148. prop_value, VBIF_MEMTYPE_0, j);
  3149. for (j = 0; j < prop_count[VBIF_MEMTYPE_1]; j++)
  3150. vbif->memtype[k++] = PROP_VALUE_ACCESS(
  3151. prop_value, VBIF_MEMTYPE_1, j);
  3152. if (sde_cfg->vbif_disable_inner_outer_shareable)
  3153. set_bit(SDE_VBIF_DISABLE_SHAREABLE, &vbif->features);
  3154. return 0;
  3155. }
  3156. static int sde_vbif_parse_dt(struct device_node *np,
  3157. struct sde_mdss_cfg *sde_cfg)
  3158. {
  3159. int rc, prop_count[VBIF_PROP_MAX], i;
  3160. struct sde_prop_value *prop_value = NULL;
  3161. bool prop_exists[VBIF_PROP_MAX];
  3162. u32 off_count, vbif_len;
  3163. struct sde_vbif_cfg *vbif = NULL;
  3164. if (!sde_cfg) {
  3165. SDE_ERROR("invalid argument\n");
  3166. rc = -EINVAL;
  3167. goto end;
  3168. }
  3169. prop_value = kzalloc(VBIF_PROP_MAX *
  3170. sizeof(struct sde_prop_value), GFP_KERNEL);
  3171. if (!prop_value) {
  3172. rc = -ENOMEM;
  3173. goto end;
  3174. }
  3175. rc = _validate_dt_entry(np, vbif_prop, ARRAY_SIZE(vbif_prop),
  3176. prop_count, &off_count);
  3177. if (rc)
  3178. goto end;
  3179. rc = _validate_dt_entry(np, &vbif_prop[VBIF_DYNAMIC_OT_RD_LIMIT], 1,
  3180. &prop_count[VBIF_DYNAMIC_OT_RD_LIMIT], NULL);
  3181. if (rc)
  3182. goto end;
  3183. rc = _validate_dt_entry(np, &vbif_prop[VBIF_DYNAMIC_OT_WR_LIMIT], 1,
  3184. &prop_count[VBIF_DYNAMIC_OT_WR_LIMIT], NULL);
  3185. if (rc)
  3186. goto end;
  3187. rc = _validate_dt_entry(np, &vbif_prop[VBIF_MEMTYPE_0], 1,
  3188. &prop_count[VBIF_MEMTYPE_0], NULL);
  3189. if (rc)
  3190. goto end;
  3191. rc = _validate_dt_entry(np, &vbif_prop[VBIF_MEMTYPE_1], 1,
  3192. &prop_count[VBIF_MEMTYPE_1], NULL);
  3193. if (rc)
  3194. goto end;
  3195. rc = _validate_dt_entry(np, &vbif_prop[VBIF_QOS_RT_REMAP], 1,
  3196. &prop_count[VBIF_QOS_RT_REMAP], NULL);
  3197. if (rc)
  3198. goto end;
  3199. rc = _validate_dt_entry(np, &vbif_prop[VBIF_QOS_NRT_REMAP], 1,
  3200. &prop_count[VBIF_QOS_NRT_REMAP], NULL);
  3201. if (rc)
  3202. goto end;
  3203. rc = _validate_dt_entry(np, &vbif_prop[VBIF_QOS_CWB_REMAP], 1,
  3204. &prop_count[VBIF_QOS_CWB_REMAP], NULL);
  3205. if (rc)
  3206. goto end;
  3207. rc = _validate_dt_entry(np, &vbif_prop[VBIF_QOS_LUTDMA_REMAP], 1,
  3208. &prop_count[VBIF_QOS_LUTDMA_REMAP], NULL);
  3209. if (rc)
  3210. goto end;
  3211. sde_cfg->vbif_count = off_count;
  3212. rc = _read_dt_entry(np, vbif_prop, ARRAY_SIZE(vbif_prop), prop_count,
  3213. prop_exists, prop_value);
  3214. if (rc)
  3215. goto end;
  3216. vbif_len = PROP_VALUE_ACCESS(prop_value, VBIF_LEN, 0);
  3217. if (!prop_exists[VBIF_LEN])
  3218. vbif_len = DEFAULT_SDE_HW_BLOCK_LEN;
  3219. for (i = 0; i < off_count; i++) {
  3220. rc = _sde_vbif_populate(sde_cfg, vbif, prop_value,
  3221. prop_count, vbif_len, i);
  3222. if (rc)
  3223. goto end;
  3224. }
  3225. end:
  3226. kfree(prop_value);
  3227. return rc;
  3228. }
  3229. static int sde_pp_parse_dt(struct device_node *np, struct sde_mdss_cfg *sde_cfg)
  3230. {
  3231. int rc, prop_count[PP_PROP_MAX], i;
  3232. struct sde_prop_value *prop_value = NULL;
  3233. bool prop_exists[PP_PROP_MAX];
  3234. u32 off_count, major_version;
  3235. struct sde_pingpong_cfg *pp;
  3236. struct sde_pingpong_sub_blks *sblk;
  3237. if (!sde_cfg) {
  3238. SDE_ERROR("invalid argument\n");
  3239. rc = -EINVAL;
  3240. goto end;
  3241. }
  3242. prop_value = kzalloc(PP_PROP_MAX *
  3243. sizeof(struct sde_prop_value), GFP_KERNEL);
  3244. if (!prop_value) {
  3245. rc = -ENOMEM;
  3246. goto end;
  3247. }
  3248. rc = _validate_dt_entry(np, pp_prop, ARRAY_SIZE(pp_prop), prop_count,
  3249. &off_count);
  3250. if (rc)
  3251. goto end;
  3252. sde_cfg->pingpong_count = off_count;
  3253. rc = _read_dt_entry(np, pp_prop, ARRAY_SIZE(pp_prop), prop_count,
  3254. prop_exists, prop_value);
  3255. if (rc)
  3256. goto end;
  3257. major_version = SDE_HW_MAJOR(sde_cfg->hwversion);
  3258. for (i = 0; i < off_count; i++) {
  3259. pp = sde_cfg->pingpong + i;
  3260. sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
  3261. if (!sblk) {
  3262. rc = -ENOMEM;
  3263. /* catalog deinit will release the allocated blocks */
  3264. goto end;
  3265. }
  3266. pp->sblk = sblk;
  3267. pp->base = PROP_VALUE_ACCESS(prop_value, PP_OFF, i);
  3268. pp->id = PINGPONG_0 + i;
  3269. snprintf(pp->name, SDE_HW_BLK_NAME_LEN, "pingpong_%u",
  3270. pp->id - PINGPONG_0);
  3271. pp->len = PROP_VALUE_ACCESS(prop_value, PP_LEN, 0);
  3272. sblk->te.base = PROP_VALUE_ACCESS(prop_value, TE_OFF, i);
  3273. sblk->te.id = SDE_PINGPONG_TE;
  3274. snprintf(sblk->te.name, SDE_HW_BLK_NAME_LEN, "te_%u",
  3275. pp->id - PINGPONG_0);
  3276. if (major_version < SDE_HW_MAJOR(SDE_HW_VER_500))
  3277. set_bit(SDE_PINGPONG_TE, &pp->features);
  3278. sblk->te2.base = PROP_VALUE_ACCESS(prop_value, TE2_OFF, i);
  3279. if (sblk->te2.base) {
  3280. sblk->te2.id = SDE_PINGPONG_TE2;
  3281. snprintf(sblk->te2.name, SDE_HW_BLK_NAME_LEN, "te2_%u",
  3282. pp->id - PINGPONG_0);
  3283. set_bit(SDE_PINGPONG_TE2, &pp->features);
  3284. set_bit(SDE_PINGPONG_SPLIT, &pp->features);
  3285. }
  3286. if (PROP_VALUE_ACCESS(prop_value, PP_SLAVE, i))
  3287. set_bit(SDE_PINGPONG_SLAVE, &pp->features);
  3288. if (PROP_VALUE_ACCESS(prop_value, PP_CWB, i)) {
  3289. set_bit(SDE_PINGPONG_CWB, &pp->features);
  3290. if (sde_cfg->has_dedicated_cwb_support)
  3291. sde_cfg->dcwb_count++;
  3292. }
  3293. if (major_version < SDE_HW_MAJOR(SDE_HW_VER_700)) {
  3294. sblk->dsc.base = PROP_VALUE_ACCESS(prop_value,
  3295. DSC_OFF, i);
  3296. if (sblk->dsc.base) {
  3297. sblk->dsc.id = SDE_PINGPONG_DSC;
  3298. snprintf(sblk->dsc.name, SDE_HW_BLK_NAME_LEN,
  3299. "dsc_%u",
  3300. pp->id - PINGPONG_0);
  3301. set_bit(SDE_PINGPONG_DSC, &pp->features);
  3302. }
  3303. }
  3304. sblk->dither.base = PROP_VALUE_ACCESS(prop_value, DITHER_OFF,
  3305. i);
  3306. if (sblk->dither.base) {
  3307. sblk->dither.id = SDE_PINGPONG_DITHER;
  3308. snprintf(sblk->dither.name, SDE_HW_BLK_NAME_LEN,
  3309. "dither_%u", pp->id);
  3310. set_bit(SDE_PINGPONG_DITHER, &pp->features);
  3311. }
  3312. sblk->dither.len = PROP_VALUE_ACCESS(prop_value, DITHER_LEN, 0);
  3313. sblk->dither.version = PROP_VALUE_ACCESS(prop_value, DITHER_VER,
  3314. 0);
  3315. if (sde_cfg->dither_luma_mode_support)
  3316. set_bit(SDE_PINGPONG_DITHER_LUMA, &pp->features);
  3317. if (prop_exists[PP_MERGE_3D_ID]) {
  3318. set_bit(SDE_PINGPONG_MERGE_3D, &pp->features);
  3319. pp->merge_3d_id = PROP_VALUE_ACCESS(prop_value,
  3320. PP_MERGE_3D_ID, i) + 1;
  3321. }
  3322. }
  3323. end:
  3324. kfree(prop_value);
  3325. return rc;
  3326. }
  3327. static void _sde_top_parse_dt_helper(struct sde_mdss_cfg *cfg,
  3328. struct sde_dt_props *props)
  3329. {
  3330. int i;
  3331. u32 ddr_type;
  3332. cfg->max_sspp_linewidth = props->exists[SSPP_LINEWIDTH] ?
  3333. PROP_VALUE_ACCESS(props->values, SSPP_LINEWIDTH, 0) :
  3334. DEFAULT_SDE_LINE_WIDTH;
  3335. cfg->vig_sspp_linewidth = props->exists[VIG_SSPP_LINEWIDTH] ?
  3336. PROP_VALUE_ACCESS(props->values, VIG_SSPP_LINEWIDTH,
  3337. 0) : cfg->max_sspp_linewidth;
  3338. cfg->scaling_linewidth = props->exists[SCALING_LINEWIDTH] ?
  3339. PROP_VALUE_ACCESS(props->values, SCALING_LINEWIDTH,
  3340. 0) : cfg->vig_sspp_linewidth;
  3341. cfg->max_wb_linewidth = props->exists[WB_LINEWIDTH] ?
  3342. PROP_VALUE_ACCESS(props->values, WB_LINEWIDTH, 0) :
  3343. DEFAULT_SDE_LINE_WIDTH;
  3344. /* if wb linear width is not defined use the line width as default */
  3345. cfg->max_wb_linewidth_linear = props->exists[WB_LINEWIDTH_LINEAR] ?
  3346. PROP_VALUE_ACCESS(props->values, WB_LINEWIDTH_LINEAR, 0)
  3347. : cfg->max_wb_linewidth;
  3348. cfg->max_mixer_width = props->exists[MIXER_LINEWIDTH] ?
  3349. PROP_VALUE_ACCESS(props->values, MIXER_LINEWIDTH, 0) :
  3350. DEFAULT_SDE_LINE_WIDTH;
  3351. cfg->max_mixer_blendstages = props->exists[MIXER_BLEND] ?
  3352. PROP_VALUE_ACCESS(props->values, MIXER_BLEND, 0) :
  3353. DEFAULT_SDE_MIXER_BLENDSTAGES;
  3354. cfg->ubwc_version = props->exists[UBWC_VERSION] ?
  3355. SDE_HW_UBWC_VER(PROP_VALUE_ACCESS(props->values,
  3356. UBWC_VERSION, 0)) : DEFAULT_SDE_UBWC_NONE;
  3357. cfg->mdp[0].highest_bank_bit = DEFAULT_SDE_HIGHEST_BANK_BIT;
  3358. if (props->exists[BANK_BIT]) {
  3359. for (i = 0; i < props->counts[BANK_BIT]; i++) {
  3360. ddr_type = PROP_BITVALUE_ACCESS(props->values,
  3361. BANK_BIT, i, 0);
  3362. if (!ddr_type || (of_fdt_get_ddrtype() == ddr_type))
  3363. cfg->mdp[0].highest_bank_bit =
  3364. PROP_BITVALUE_ACCESS(props->values,
  3365. BANK_BIT, i, 1);
  3366. }
  3367. }
  3368. cfg->macrotile_mode = props->exists[MACROTILE_MODE] ?
  3369. PROP_VALUE_ACCESS(props->values, MACROTILE_MODE, 0) :
  3370. DEFAULT_SDE_UBWC_MACROTILE_MODE;
  3371. cfg->ubwc_bw_calc_version =
  3372. PROP_VALUE_ACCESS(props->values, UBWC_BW_CALC_VERSION, 0);
  3373. cfg->mdp[0].ubwc_static = props->exists[UBWC_STATIC] ?
  3374. PROP_VALUE_ACCESS(props->values, UBWC_STATIC, 0) :
  3375. DEFAULT_SDE_UBWC_STATIC;
  3376. cfg->mdp[0].ubwc_swizzle = props->exists[UBWC_SWIZZLE] ?
  3377. PROP_VALUE_ACCESS(props->values, UBWC_SWIZZLE, 0) :
  3378. DEFAULT_SDE_UBWC_SWIZZLE;
  3379. cfg->mdp[0].has_dest_scaler =
  3380. PROP_VALUE_ACCESS(props->values, DEST_SCALER, 0);
  3381. cfg->mdp[0].smart_panel_align_mode =
  3382. PROP_VALUE_ACCESS(props->values, SMART_PANEL_ALIGN_MODE, 0);
  3383. if (props->exists[SEC_SID_MASK]) {
  3384. cfg->sec_sid_mask_count = props->counts[SEC_SID_MASK];
  3385. for (i = 0; i < cfg->sec_sid_mask_count; i++)
  3386. cfg->sec_sid_mask[i] = PROP_VALUE_ACCESS(props->values,
  3387. SEC_SID_MASK, i);
  3388. }
  3389. cfg->has_src_split = PROP_VALUE_ACCESS(props->values, SRC_SPLIT, 0);
  3390. cfg->has_dim_layer = PROP_VALUE_ACCESS(props->values, DIM_LAYER, 0);
  3391. cfg->has_idle_pc = PROP_VALUE_ACCESS(props->values, IDLE_PC, 0);
  3392. cfg->wakeup_with_touch = PROP_VALUE_ACCESS(props->values,
  3393. WAKEUP_WITH_TOUCH, 0);
  3394. cfg->pipe_order_type = PROP_VALUE_ACCESS(props->values,
  3395. PIPE_ORDER_VERSION, 0);
  3396. cfg->has_base_layer = PROP_VALUE_ACCESS(props->values, BASE_LAYER, 0);
  3397. cfg->qseed_hw_version = PROP_VALUE_ACCESS(props->values,
  3398. QSEED_HW_VERSION, 0);
  3399. cfg->trusted_vm_env = PROP_VALUE_ACCESS(props->values, TRUSTED_VM_ENV,
  3400. 0);
  3401. cfg->max_trusted_vm_displays = PROP_VALUE_ACCESS(props->values,
  3402. MAX_TRUSTED_VM_DISPLAYS, 0);
  3403. }
  3404. static int sde_top_parse_dt(struct device_node *np, struct sde_mdss_cfg *cfg)
  3405. {
  3406. int rc = 0, dma_rc, len;
  3407. struct sde_dt_props *props;
  3408. const char *type;
  3409. u32 major_version;
  3410. props = sde_get_dt_props(np, SDE_PROP_MAX, sde_prop,
  3411. ARRAY_SIZE(sde_prop), &len);
  3412. if (IS_ERR(props))
  3413. return PTR_ERR(props);
  3414. /* revalidate arrays not bound to off_count elements */
  3415. rc = _validate_dt_entry(np, &sde_prop[SEC_SID_MASK], 1,
  3416. &props->counts[SEC_SID_MASK], NULL);
  3417. if (rc)
  3418. goto end;
  3419. /* update props with newly validated arrays */
  3420. rc = _read_dt_entry(np, sde_prop, ARRAY_SIZE(sde_prop), props->counts,
  3421. props->exists, props->values);
  3422. if (rc)
  3423. goto end;
  3424. cfg->mdss_count = 1;
  3425. cfg->mdss[0].base = MDSS_BASE_OFFSET;
  3426. cfg->mdss[0].id = MDP_TOP;
  3427. snprintf(cfg->mdss[0].name, SDE_HW_BLK_NAME_LEN, "mdss_%u",
  3428. cfg->mdss[0].id - MDP_TOP);
  3429. cfg->mdp_count = 1;
  3430. cfg->mdp[0].id = MDP_TOP;
  3431. snprintf(cfg->mdp[0].name, SDE_HW_BLK_NAME_LEN, "top_%u",
  3432. cfg->mdp[0].id - MDP_TOP);
  3433. cfg->mdp[0].base = PROP_VALUE_ACCESS(props->values, SDE_OFF, 0);
  3434. cfg->mdp[0].len = props->exists[SDE_LEN] ? PROP_VALUE_ACCESS(
  3435. props->values, SDE_LEN, 0) : DEFAULT_SDE_HW_BLOCK_LEN;
  3436. _sde_top_parse_dt_helper(cfg, props);
  3437. major_version = SDE_HW_MAJOR(cfg->hwversion);
  3438. if (major_version < SDE_HW_MAJOR(SDE_HW_VER_500))
  3439. set_bit(SDE_MDP_VSYNC_SEL, &cfg->mdp[0].features);
  3440. else if (major_version < SDE_HW_MAJOR(SDE_HW_VER_810))
  3441. set_bit(SDE_MDP_WD_TIMER, &cfg->mdp[0].features);
  3442. rc = _add_to_irq_offset_list(cfg, SDE_INTR_HWBLK_TOP,
  3443. SDE_INTR_TOP_INTR, cfg->mdp[0].base);
  3444. if (rc)
  3445. goto end;
  3446. rc = _add_to_irq_offset_list(cfg, SDE_INTR_HWBLK_TOP,
  3447. SDE_INTR_TOP_INTR2, cfg->mdp[0].base);
  3448. if (rc)
  3449. goto end;
  3450. rc = _add_to_irq_offset_list(cfg, SDE_INTR_HWBLK_TOP,
  3451. SDE_INTR_TOP_HIST_INTR, cfg->mdp[0].base);
  3452. if (rc)
  3453. goto end;
  3454. rc = of_property_read_string(np, sde_prop[QSEED_SW_LIB_REV].prop_name,
  3455. &type);
  3456. if (rc) {
  3457. SDE_DEBUG("invalid %s node in device tree: %d\n",
  3458. sde_prop[QSEED_SW_LIB_REV].prop_name, rc);
  3459. rc = 0;
  3460. } else if (!strcmp(type, "qseedv3")) {
  3461. cfg->qseed_sw_lib_rev = SDE_SSPP_SCALER_QSEED3;
  3462. } else if (!strcmp(type, "qseedv3lite")) {
  3463. cfg->qseed_sw_lib_rev = SDE_SSPP_SCALER_QSEED3LITE;
  3464. } else if (!strcmp(type, "qseedv2")) {
  3465. cfg->qseed_sw_lib_rev = SDE_SSPP_SCALER_QSEED2;
  3466. } else {
  3467. SDE_DEBUG("Unknown type %s for property %s\n", type,
  3468. sde_prop[QSEED_SW_LIB_REV].prop_name);
  3469. }
  3470. rc = of_property_read_string(np, sde_prop[CSC_TYPE].prop_name, &type);
  3471. if (rc) {
  3472. SDE_DEBUG("invalid %s node in device tree: %d\n",
  3473. sde_prop[CSC_TYPE].prop_name, rc);
  3474. rc = 0;
  3475. } else if (!strcmp(type, "csc")) {
  3476. cfg->csc_type = SDE_SSPP_CSC;
  3477. } else if (!strcmp(type, "csc-10bit")) {
  3478. cfg->csc_type = SDE_SSPP_CSC_10BIT;
  3479. } else {
  3480. SDE_DEBUG("Unknown type %s for property %s\n", type,
  3481. sde_prop[CSC_TYPE].prop_name);
  3482. }
  3483. /*
  3484. * Current SDE support only Smart DMA 2.0-2.5.
  3485. * No support for Smart DMA 1.0 yet.
  3486. */
  3487. cfg->smart_dma_rev = 0;
  3488. dma_rc = of_property_read_string(np, sde_prop[SMART_DMA_REV].prop_name,
  3489. &type);
  3490. if (dma_rc) {
  3491. SDE_DEBUG("invalid %s node in device tree: %d\n",
  3492. sde_prop[SMART_DMA_REV].prop_name, dma_rc);
  3493. } else if (!strcmp(type, "smart_dma_v2p5")) {
  3494. cfg->smart_dma_rev = SDE_SSPP_SMART_DMA_V2p5;
  3495. } else if (!strcmp(type, "smart_dma_v2")) {
  3496. cfg->smart_dma_rev = SDE_SSPP_SMART_DMA_V2;
  3497. } else if (!strcmp(type, "smart_dma_v1")) {
  3498. SDE_ERROR("smart dma 1.0 is not supported in SDE\n");
  3499. } else {
  3500. SDE_DEBUG("unknown smart dma version %s\n", type);
  3501. }
  3502. end:
  3503. sde_put_dt_props(props);
  3504. return rc;
  3505. }
  3506. static int sde_parse_reg_dma_dt(struct device_node *np,
  3507. struct sde_mdss_cfg *sde_cfg)
  3508. {
  3509. int rc = 0, i, prop_count[REG_DMA_PROP_MAX];
  3510. struct sde_prop_value *prop_value = NULL;
  3511. u32 off_count;
  3512. bool prop_exists[REG_DMA_PROP_MAX];
  3513. bool dma_type_exists[REG_DMA_TYPE_MAX];
  3514. enum sde_reg_dma_type dma_type;
  3515. prop_value = kcalloc(REG_DMA_PROP_MAX,
  3516. sizeof(struct sde_prop_value), GFP_KERNEL);
  3517. if (!prop_value) {
  3518. rc = -ENOMEM;
  3519. goto end;
  3520. }
  3521. rc = _validate_dt_entry(np, reg_dma_prop, ARRAY_SIZE(reg_dma_prop),
  3522. prop_count, &off_count);
  3523. if (rc || !off_count)
  3524. goto end;
  3525. rc = _read_dt_entry(np, reg_dma_prop, ARRAY_SIZE(reg_dma_prop),
  3526. prop_count, prop_exists, prop_value);
  3527. if (rc)
  3528. goto end;
  3529. sde_cfg->reg_dma_count = 0;
  3530. memset(&dma_type_exists, 0, sizeof(dma_type_exists));
  3531. for (i = 0; i < off_count; i++) {
  3532. dma_type = PROP_VALUE_ACCESS(prop_value, REG_DMA_ID, i);
  3533. if (dma_type >= REG_DMA_TYPE_MAX) {
  3534. SDE_ERROR("Invalid DMA type %d\n", dma_type);
  3535. goto end;
  3536. } else if (dma_type_exists[dma_type]) {
  3537. SDE_ERROR("DMA type ID %d exists more than once\n",
  3538. dma_type);
  3539. goto end;
  3540. }
  3541. dma_type_exists[dma_type] = true;
  3542. sde_cfg->dma_cfg.reg_dma_blks[dma_type].base =
  3543. PROP_VALUE_ACCESS(prop_value, REG_DMA_OFF, i);
  3544. sde_cfg->dma_cfg.reg_dma_blks[dma_type].valid = true;
  3545. sde_cfg->reg_dma_count++;
  3546. }
  3547. sde_cfg->dma_cfg.version = PROP_VALUE_ACCESS(prop_value,
  3548. REG_DMA_VERSION, 0);
  3549. sde_cfg->dma_cfg.trigger_sel_off = PROP_VALUE_ACCESS(prop_value,
  3550. REG_DMA_TRIGGER_OFF, 0);
  3551. sde_cfg->dma_cfg.broadcast_disabled = PROP_VALUE_ACCESS(prop_value,
  3552. REG_DMA_BROADCAST_DISABLED, 0);
  3553. sde_cfg->dma_cfg.xin_id = PROP_VALUE_ACCESS(prop_value,
  3554. REG_DMA_XIN_ID, 0);
  3555. sde_cfg->dma_cfg.clk_ctrl = SDE_CLK_CTRL_LUTDMA;
  3556. sde_cfg->dma_cfg.vbif_idx = VBIF_RT;
  3557. for (i = 0; i < sde_cfg->mdp_count; i++) {
  3558. sde_cfg->mdp[i].clk_ctrls[sde_cfg->dma_cfg.clk_ctrl].reg_off =
  3559. PROP_BITVALUE_ACCESS(prop_value,
  3560. REG_DMA_CLK_CTRL, 0, 0);
  3561. sde_cfg->mdp[i].clk_ctrls[sde_cfg->dma_cfg.clk_ctrl].bit_off =
  3562. PROP_BITVALUE_ACCESS(prop_value,
  3563. REG_DMA_CLK_CTRL, 0, 1);
  3564. }
  3565. end:
  3566. kfree(prop_value);
  3567. /* reg dma is optional feature hence return 0 */
  3568. return 0;
  3569. }
  3570. static int _sde_perf_parse_dt_validate(struct device_node *np, int *prop_count)
  3571. {
  3572. int rc, len;
  3573. rc = _validate_dt_entry(np, sde_perf_prop, ARRAY_SIZE(sde_perf_prop),
  3574. prop_count, &len);
  3575. if (rc)
  3576. return rc;
  3577. rc = _validate_dt_entry(np, &sde_perf_prop[PERF_CDP_SETTING], 1,
  3578. &prop_count[PERF_CDP_SETTING], NULL);
  3579. if (rc)
  3580. return rc;
  3581. return rc;
  3582. }
  3583. static int _sde_qos_parse_dt_cfg(struct sde_mdss_cfg *cfg, int *prop_count,
  3584. struct sde_prop_value *prop_value, bool *prop_exists)
  3585. {
  3586. int i, j;
  3587. u32 qos_count = 1;
  3588. if (prop_exists[QOS_REFRESH_RATES]) {
  3589. qos_count = prop_count[QOS_REFRESH_RATES];
  3590. cfg->perf.qos_refresh_rate = kcalloc(qos_count,
  3591. sizeof(u32), GFP_KERNEL);
  3592. if (!cfg->perf.qos_refresh_rate)
  3593. goto end;
  3594. for (j = 0; j < qos_count; j++) {
  3595. cfg->perf.qos_refresh_rate[j] =
  3596. PROP_VALUE_ACCESS(prop_value,
  3597. QOS_REFRESH_RATES, j);
  3598. SDE_DEBUG("qos usage:%d refresh rate:0x%x\n",
  3599. j, cfg->perf.qos_refresh_rate[j]);
  3600. }
  3601. }
  3602. cfg->perf.qos_refresh_count = qos_count;
  3603. cfg->perf.danger_lut = kcalloc(qos_count,
  3604. sizeof(u64) * SDE_QOS_LUT_USAGE_MAX, GFP_KERNEL);
  3605. cfg->perf.safe_lut = kcalloc(qos_count,
  3606. sizeof(u64) * SDE_QOS_LUT_USAGE_MAX, GFP_KERNEL);
  3607. cfg->perf.creq_lut = kcalloc(qos_count,
  3608. sizeof(u64) * SDE_QOS_LUT_USAGE_MAX * SDE_CREQ_LUT_TYPE_MAX, GFP_KERNEL);
  3609. if (!cfg->perf.creq_lut || !cfg->perf.safe_lut || !cfg->perf.danger_lut)
  3610. goto end;
  3611. if (prop_exists[QOS_DANGER_LUT] &&
  3612. prop_count[QOS_DANGER_LUT] >= (SDE_QOS_LUT_USAGE_MAX * qos_count)) {
  3613. for (i = 0; i < prop_count[QOS_DANGER_LUT]; i++) {
  3614. cfg->perf.danger_lut[i] =
  3615. PROP_VALUE_ACCESS(prop_value,
  3616. QOS_DANGER_LUT, i);
  3617. SDE_DEBUG("danger usage:%i lut:0x%llx\n",
  3618. i, cfg->perf.danger_lut[i]);
  3619. }
  3620. }
  3621. if (prop_exists[QOS_SAFE_LUT] &&
  3622. prop_count[QOS_SAFE_LUT] >= (SDE_QOS_LUT_USAGE_MAX * qos_count)) {
  3623. for (i = 0; i < prop_count[QOS_SAFE_LUT]; i++) {
  3624. cfg->perf.safe_lut[i] =
  3625. PROP_VALUE_ACCESS(prop_value,
  3626. QOS_SAFE_LUT, i);
  3627. SDE_DEBUG("safe usage:%d lut:0x%llx\n",
  3628. i, cfg->perf.safe_lut[i]);
  3629. }
  3630. }
  3631. if (prop_exists[QOS_CREQ_LUT] &&
  3632. (prop_count[QOS_CREQ_LUT] >=
  3633. (SDE_QOS_LUT_USAGE_MAX * qos_count * SDE_CREQ_LUT_TYPE_MAX))) {
  3634. u64 lut_hi, lut_lo;
  3635. for (j = 0; j < (qos_count * SDE_QOS_LUT_USAGE_MAX * SDE_CREQ_LUT_TYPE_MAX); j++) {
  3636. lut_hi = PROP_VALUE_ACCESS(prop_value, QOS_CREQ_LUT, (j * 2) + 0);
  3637. lut_lo = PROP_VALUE_ACCESS(prop_value, QOS_CREQ_LUT, (j * 2) + 1);
  3638. cfg->perf.creq_lut[j] = (lut_hi << 32) | lut_lo;
  3639. SDE_DEBUG("creq usage:%d lut:0x%llx\n", j, cfg->perf.creq_lut[j]);
  3640. }
  3641. }
  3642. return 0;
  3643. end:
  3644. kfree(cfg->perf.qos_refresh_rate);
  3645. kfree(cfg->perf.creq_lut);
  3646. kfree(cfg->perf.danger_lut);
  3647. kfree(cfg->perf.safe_lut);
  3648. return -ENOMEM;
  3649. }
  3650. static void _sde_perf_parse_dt_cfg_populate(struct sde_mdss_cfg *cfg,
  3651. int *prop_count,
  3652. struct sde_prop_value *prop_value,
  3653. bool *prop_exists)
  3654. {
  3655. cfg->perf.max_bw_low =
  3656. prop_exists[PERF_MAX_BW_LOW] ?
  3657. PROP_VALUE_ACCESS(prop_value, PERF_MAX_BW_LOW, 0) :
  3658. DEFAULT_MAX_BW_LOW;
  3659. cfg->perf.max_bw_high =
  3660. prop_exists[PERF_MAX_BW_HIGH] ?
  3661. PROP_VALUE_ACCESS(prop_value, PERF_MAX_BW_HIGH, 0) :
  3662. DEFAULT_MAX_BW_HIGH;
  3663. cfg->perf.min_core_ib =
  3664. prop_exists[PERF_MIN_CORE_IB] ?
  3665. PROP_VALUE_ACCESS(prop_value, PERF_MIN_CORE_IB, 0) :
  3666. DEFAULT_MAX_BW_LOW;
  3667. cfg->perf.min_llcc_ib =
  3668. prop_exists[PERF_MIN_LLCC_IB] ?
  3669. PROP_VALUE_ACCESS(prop_value, PERF_MIN_LLCC_IB, 0) :
  3670. DEFAULT_MAX_BW_LOW;
  3671. cfg->perf.min_dram_ib =
  3672. prop_exists[PERF_MIN_DRAM_IB] ?
  3673. PROP_VALUE_ACCESS(prop_value, PERF_MIN_DRAM_IB, 0) :
  3674. DEFAULT_MAX_BW_LOW;
  3675. cfg->perf.undersized_prefill_lines =
  3676. prop_exists[PERF_UNDERSIZED_PREFILL_LINES] ?
  3677. PROP_VALUE_ACCESS(prop_value,
  3678. PERF_UNDERSIZED_PREFILL_LINES, 0) :
  3679. DEFAULT_UNDERSIZED_PREFILL_LINES;
  3680. cfg->perf.xtra_prefill_lines =
  3681. prop_exists[PERF_XTRA_PREFILL_LINES] ?
  3682. PROP_VALUE_ACCESS(prop_value,
  3683. PERF_XTRA_PREFILL_LINES, 0) :
  3684. DEFAULT_XTRA_PREFILL_LINES;
  3685. cfg->perf.dest_scale_prefill_lines =
  3686. prop_exists[PERF_DEST_SCALE_PREFILL_LINES] ?
  3687. PROP_VALUE_ACCESS(prop_value,
  3688. PERF_DEST_SCALE_PREFILL_LINES, 0) :
  3689. DEFAULT_DEST_SCALE_PREFILL_LINES;
  3690. cfg->perf.macrotile_prefill_lines =
  3691. prop_exists[PERF_MACROTILE_PREFILL_LINES] ?
  3692. PROP_VALUE_ACCESS(prop_value,
  3693. PERF_MACROTILE_PREFILL_LINES, 0) :
  3694. DEFAULT_MACROTILE_PREFILL_LINES;
  3695. cfg->perf.yuv_nv12_prefill_lines =
  3696. prop_exists[PERF_YUV_NV12_PREFILL_LINES] ?
  3697. PROP_VALUE_ACCESS(prop_value,
  3698. PERF_YUV_NV12_PREFILL_LINES, 0) :
  3699. DEFAULT_YUV_NV12_PREFILL_LINES;
  3700. cfg->perf.linear_prefill_lines =
  3701. prop_exists[PERF_LINEAR_PREFILL_LINES] ?
  3702. PROP_VALUE_ACCESS(prop_value,
  3703. PERF_LINEAR_PREFILL_LINES, 0) :
  3704. DEFAULT_LINEAR_PREFILL_LINES;
  3705. cfg->perf.downscaling_prefill_lines =
  3706. prop_exists[PERF_DOWNSCALING_PREFILL_LINES] ?
  3707. PROP_VALUE_ACCESS(prop_value,
  3708. PERF_DOWNSCALING_PREFILL_LINES, 0) :
  3709. DEFAULT_DOWNSCALING_PREFILL_LINES;
  3710. cfg->perf.amortizable_threshold =
  3711. prop_exists[PERF_AMORTIZABLE_THRESHOLD] ?
  3712. PROP_VALUE_ACCESS(prop_value,
  3713. PERF_AMORTIZABLE_THRESHOLD, 0) :
  3714. DEFAULT_AMORTIZABLE_THRESHOLD;
  3715. cfg->perf.num_mnoc_ports =
  3716. prop_exists[PERF_NUM_MNOC_PORTS] ?
  3717. PROP_VALUE_ACCESS(prop_value,
  3718. PERF_NUM_MNOC_PORTS, 0) :
  3719. DEFAULT_MNOC_PORTS;
  3720. cfg->perf.axi_bus_width =
  3721. prop_exists[PERF_AXI_BUS_WIDTH] ?
  3722. PROP_VALUE_ACCESS(prop_value,
  3723. PERF_AXI_BUS_WIDTH, 0) :
  3724. DEFAULT_AXI_BUS_WIDTH;
  3725. }
  3726. static int _sde_perf_parse_dt_cfg(struct device_node *np,
  3727. struct sde_mdss_cfg *cfg, int *prop_count,
  3728. struct sde_prop_value *prop_value, bool *prop_exists)
  3729. {
  3730. int rc, j;
  3731. const char *str = NULL;
  3732. /*
  3733. * The following performance parameters (e.g. core_ib_ff) are
  3734. * mapped directly as device tree string constants.
  3735. */
  3736. rc = of_property_read_string(np,
  3737. sde_perf_prop[PERF_CORE_IB_FF].prop_name, &str);
  3738. cfg->perf.core_ib_ff = rc ? DEFAULT_CORE_IB_FF : str;
  3739. rc = of_property_read_string(np,
  3740. sde_perf_prop[PERF_CORE_CLK_FF].prop_name, &str);
  3741. cfg->perf.core_clk_ff = rc ? DEFAULT_CORE_CLK_FF : str;
  3742. rc = of_property_read_string(np,
  3743. sde_perf_prop[PERF_COMP_RATIO_RT].prop_name, &str);
  3744. cfg->perf.comp_ratio_rt = rc ? DEFAULT_COMP_RATIO_RT : str;
  3745. rc = of_property_read_string(np,
  3746. sde_perf_prop[PERF_COMP_RATIO_NRT].prop_name, &str);
  3747. cfg->perf.comp_ratio_nrt = rc ? DEFAULT_COMP_RATIO_NRT : str;
  3748. rc = 0;
  3749. _sde_perf_parse_dt_cfg_populate(cfg, prop_count, prop_value,
  3750. prop_exists);
  3751. if (prop_exists[PERF_CDP_SETTING]) {
  3752. const u32 prop_size = 2;
  3753. u32 count = prop_count[PERF_CDP_SETTING] / prop_size;
  3754. count = min_t(u32, count, SDE_PERF_CDP_USAGE_MAX);
  3755. for (j = 0; j < count; j++) {
  3756. cfg->perf.cdp_cfg[j].rd_enable =
  3757. PROP_VALUE_ACCESS(prop_value,
  3758. PERF_CDP_SETTING, j * prop_size);
  3759. cfg->perf.cdp_cfg[j].wr_enable =
  3760. PROP_VALUE_ACCESS(prop_value,
  3761. PERF_CDP_SETTING, j * prop_size + 1);
  3762. SDE_DEBUG("cdp usage:%d rd:%d wr:%d\n",
  3763. j, cfg->perf.cdp_cfg[j].rd_enable,
  3764. cfg->perf.cdp_cfg[j].wr_enable);
  3765. }
  3766. cfg->has_cdp = true;
  3767. }
  3768. cfg->perf.cpu_mask =
  3769. prop_exists[PERF_CPU_MASK] ?
  3770. PROP_VALUE_ACCESS(prop_value, PERF_CPU_MASK, 0) :
  3771. DEFAULT_CPU_MASK;
  3772. cfg->perf.cpu_mask_perf =
  3773. prop_exists[CPU_MASK_PERF] ?
  3774. PROP_VALUE_ACCESS(prop_value, CPU_MASK_PERF, 0) :
  3775. DEFAULT_CPU_MASK;
  3776. cfg->perf.cpu_dma_latency =
  3777. prop_exists[PERF_CPU_DMA_LATENCY] ?
  3778. PROP_VALUE_ACCESS(prop_value, PERF_CPU_DMA_LATENCY, 0) :
  3779. DEFAULT_CPU_DMA_LATENCY;
  3780. cfg->perf.cpu_irq_latency =
  3781. prop_exists[PERF_CPU_IRQ_LATENCY] ?
  3782. PROP_VALUE_ACCESS(prop_value, PERF_CPU_IRQ_LATENCY, 0) :
  3783. PM_QOS_DEFAULT_VALUE;
  3784. return 0;
  3785. }
  3786. static int sde_perf_parse_dt(struct device_node *np, struct sde_mdss_cfg *cfg)
  3787. {
  3788. int rc, prop_count[PERF_PROP_MAX];
  3789. struct sde_prop_value *prop_value = NULL;
  3790. bool prop_exists[PERF_PROP_MAX];
  3791. if (!cfg) {
  3792. SDE_ERROR("invalid argument\n");
  3793. rc = -EINVAL;
  3794. goto end;
  3795. }
  3796. prop_value = kzalloc(PERF_PROP_MAX *
  3797. sizeof(struct sde_prop_value), GFP_KERNEL);
  3798. if (!prop_value) {
  3799. rc = -ENOMEM;
  3800. goto end;
  3801. }
  3802. rc = _sde_perf_parse_dt_validate(np, prop_count);
  3803. if (rc)
  3804. goto freeprop;
  3805. rc = _read_dt_entry(np, sde_perf_prop, ARRAY_SIZE(sde_perf_prop),
  3806. prop_count, prop_exists, prop_value);
  3807. if (rc)
  3808. goto freeprop;
  3809. rc = _sde_perf_parse_dt_cfg(np, cfg, prop_count, prop_value,
  3810. prop_exists);
  3811. freeprop:
  3812. kfree(prop_value);
  3813. end:
  3814. return rc;
  3815. }
  3816. static int sde_qos_parse_dt(struct device_node *np, struct sde_mdss_cfg *cfg)
  3817. {
  3818. int rc, prop_count[QOS_PROP_MAX];
  3819. struct sde_prop_value *prop_value = NULL;
  3820. bool prop_exists[QOS_PROP_MAX];
  3821. if (!cfg) {
  3822. SDE_ERROR("invalid argument\n");
  3823. rc = -EINVAL;
  3824. goto end;
  3825. }
  3826. prop_value = kzalloc(QOS_PROP_MAX *
  3827. sizeof(struct sde_prop_value), GFP_KERNEL);
  3828. if (!prop_value) {
  3829. rc = -ENOMEM;
  3830. goto end;
  3831. }
  3832. rc = _validate_dt_entry(np, sde_qos_prop, ARRAY_SIZE(sde_qos_prop),
  3833. prop_count, NULL);
  3834. if (rc)
  3835. goto freeprop;
  3836. rc = _read_dt_entry(np, sde_qos_prop, ARRAY_SIZE(sde_qos_prop),
  3837. prop_count, prop_exists, prop_value);
  3838. if (rc)
  3839. goto freeprop;
  3840. rc = _sde_qos_parse_dt_cfg(cfg, prop_count, prop_value, prop_exists);
  3841. freeprop:
  3842. kfree(prop_value);
  3843. end:
  3844. return rc;
  3845. }
  3846. static int sde_parse_merge_3d_dt(struct device_node *np,
  3847. struct sde_mdss_cfg *sde_cfg)
  3848. {
  3849. int rc, prop_count[HW_PROP_MAX], off_count, i;
  3850. struct sde_prop_value *prop_value = NULL;
  3851. bool prop_exists[HW_PROP_MAX];
  3852. struct sde_merge_3d_cfg *merge_3d;
  3853. prop_value = kcalloc(HW_PROP_MAX, sizeof(struct sde_prop_value),
  3854. GFP_KERNEL);
  3855. if (!prop_value)
  3856. return -ENOMEM;
  3857. rc = _validate_dt_entry(np, merge_3d_prop, ARRAY_SIZE(merge_3d_prop),
  3858. prop_count, &off_count);
  3859. if (rc)
  3860. goto end;
  3861. sde_cfg->merge_3d_count = off_count;
  3862. rc = _read_dt_entry(np, merge_3d_prop, ARRAY_SIZE(merge_3d_prop),
  3863. prop_count,
  3864. prop_exists, prop_value);
  3865. if (rc) {
  3866. sde_cfg->merge_3d_count = 0;
  3867. goto end;
  3868. }
  3869. for (i = 0; i < off_count; i++) {
  3870. merge_3d = sde_cfg->merge_3d + i;
  3871. merge_3d->base = PROP_VALUE_ACCESS(prop_value, HW_OFF, i);
  3872. merge_3d->id = MERGE_3D_0 + i;
  3873. snprintf(merge_3d->name, SDE_HW_BLK_NAME_LEN, "merge_3d_%u",
  3874. merge_3d->id - MERGE_3D_0);
  3875. merge_3d->len = PROP_VALUE_ACCESS(prop_value, HW_LEN, 0);
  3876. }
  3877. end:
  3878. kfree(prop_value);
  3879. return rc;
  3880. }
  3881. static int sde_qdss_parse_dt(struct device_node *np,
  3882. struct sde_mdss_cfg *sde_cfg)
  3883. {
  3884. int rc, prop_count[HW_PROP_MAX], i;
  3885. struct sde_prop_value *prop_value = NULL;
  3886. bool prop_exists[HW_PROP_MAX];
  3887. u32 off_count;
  3888. struct sde_qdss_cfg *qdss;
  3889. if (!sde_cfg) {
  3890. SDE_ERROR("invalid argument\n");
  3891. return -EINVAL;
  3892. }
  3893. prop_value = kzalloc(HW_PROP_MAX *
  3894. sizeof(struct sde_prop_value), GFP_KERNEL);
  3895. if (!prop_value)
  3896. return -ENOMEM;
  3897. rc = _validate_dt_entry(np, qdss_prop, ARRAY_SIZE(qdss_prop),
  3898. prop_count, &off_count);
  3899. if (rc) {
  3900. sde_cfg->qdss_count = 0;
  3901. goto end;
  3902. }
  3903. sde_cfg->qdss_count = off_count;
  3904. rc = _read_dt_entry(np, qdss_prop, ARRAY_SIZE(qdss_prop), prop_count,
  3905. prop_exists, prop_value);
  3906. if (rc)
  3907. goto end;
  3908. for (i = 0; i < off_count; i++) {
  3909. qdss = sde_cfg->qdss + i;
  3910. qdss->base = PROP_VALUE_ACCESS(prop_value, HW_OFF, i);
  3911. qdss->id = QDSS_0 + i;
  3912. snprintf(qdss->name, SDE_HW_BLK_NAME_LEN, "qdss_%u",
  3913. qdss->id - QDSS_0);
  3914. qdss->len = PROP_VALUE_ACCESS(prop_value, HW_LEN, 0);
  3915. }
  3916. end:
  3917. kfree(prop_value);
  3918. return rc;
  3919. }
  3920. static int sde_hardware_format_caps(struct sde_mdss_cfg *sde_cfg,
  3921. uint32_t hw_rev)
  3922. {
  3923. int rc = 0;
  3924. uint32_t dma_list_size, vig_list_size, wb2_list_size;
  3925. uint32_t virt_vig_list_size, in_rot_list_size = 0;
  3926. uint32_t cursor_list_size = 0;
  3927. uint32_t index = 0;
  3928. uint32_t in_rot_restricted_list_size = 0;
  3929. const struct sde_format_extended *inline_fmt_tbl = NULL;
  3930. const struct sde_format_extended *inline_restricted_fmt_tbl = NULL;
  3931. /* cursor input formats */
  3932. if (sde_cfg->has_cursor) {
  3933. cursor_list_size = ARRAY_SIZE(cursor_formats);
  3934. sde_cfg->cursor_formats = kcalloc(cursor_list_size,
  3935. sizeof(struct sde_format_extended), GFP_KERNEL);
  3936. if (!sde_cfg->cursor_formats) {
  3937. rc = -ENOMEM;
  3938. goto out;
  3939. }
  3940. index = sde_copy_formats(sde_cfg->cursor_formats,
  3941. cursor_list_size, 0, cursor_formats,
  3942. ARRAY_SIZE(cursor_formats));
  3943. }
  3944. /* DMA pipe input formats */
  3945. dma_list_size = ARRAY_SIZE(plane_formats);
  3946. if (sde_cfg->has_fp16)
  3947. dma_list_size += ARRAY_SIZE(fp16_formats);
  3948. sde_cfg->dma_formats = kcalloc(dma_list_size,
  3949. sizeof(struct sde_format_extended), GFP_KERNEL);
  3950. if (!sde_cfg->dma_formats) {
  3951. rc = -ENOMEM;
  3952. goto free_cursor;
  3953. }
  3954. index = sde_copy_formats(sde_cfg->dma_formats, dma_list_size,
  3955. 0, plane_formats, ARRAY_SIZE(plane_formats));
  3956. if (sde_cfg->has_fp16)
  3957. index += sde_copy_formats(sde_cfg->dma_formats, dma_list_size,
  3958. index, fp16_formats, ARRAY_SIZE(fp16_formats));
  3959. /* ViG pipe input formats */
  3960. vig_list_size = ARRAY_SIZE(plane_formats_vig);
  3961. if (sde_cfg->has_vig_p010)
  3962. vig_list_size += ARRAY_SIZE(p010_ubwc_formats);
  3963. if (sde_cfg->has_fp16)
  3964. vig_list_size += ARRAY_SIZE(fp16_formats);
  3965. sde_cfg->vig_formats = kcalloc(vig_list_size,
  3966. sizeof(struct sde_format_extended), GFP_KERNEL);
  3967. if (!sde_cfg->vig_formats) {
  3968. rc = -ENOMEM;
  3969. goto free_dma;
  3970. }
  3971. index = sde_copy_formats(sde_cfg->vig_formats, vig_list_size,
  3972. 0, plane_formats_vig, ARRAY_SIZE(plane_formats_vig));
  3973. if (sde_cfg->has_vig_p010)
  3974. index += sde_copy_formats(sde_cfg->vig_formats,
  3975. vig_list_size, index, p010_ubwc_formats,
  3976. ARRAY_SIZE(p010_ubwc_formats));
  3977. if (sde_cfg->has_fp16)
  3978. index += sde_copy_formats(sde_cfg->vig_formats, vig_list_size,
  3979. index, fp16_formats, ARRAY_SIZE(fp16_formats));
  3980. /* Virtual ViG pipe input formats (all virt pipes use DMA formats) */
  3981. virt_vig_list_size = ARRAY_SIZE(plane_formats);
  3982. if (sde_cfg->has_fp16)
  3983. virt_vig_list_size += ARRAY_SIZE(fp16_formats);
  3984. sde_cfg->virt_vig_formats = kcalloc(virt_vig_list_size,
  3985. sizeof(struct sde_format_extended), GFP_KERNEL);
  3986. if (!sde_cfg->virt_vig_formats) {
  3987. rc = -ENOMEM;
  3988. goto free_vig;
  3989. }
  3990. index = sde_copy_formats(sde_cfg->virt_vig_formats, virt_vig_list_size,
  3991. 0, plane_formats, ARRAY_SIZE(plane_formats));
  3992. if (sde_cfg->has_fp16)
  3993. index += sde_copy_formats(sde_cfg->virt_vig_formats,
  3994. virt_vig_list_size, index, fp16_formats,
  3995. ARRAY_SIZE(fp16_formats));
  3996. /* WB output formats */
  3997. wb2_list_size = ARRAY_SIZE(wb2_formats);
  3998. sde_cfg->wb_formats = kcalloc(wb2_list_size,
  3999. sizeof(struct sde_format_extended), GFP_KERNEL);
  4000. if (!sde_cfg->wb_formats) {
  4001. SDE_ERROR("failed to allocate wb format list\n");
  4002. rc = -ENOMEM;
  4003. goto free_virt;
  4004. }
  4005. index = sde_copy_formats(sde_cfg->wb_formats, wb2_list_size,
  4006. 0, wb2_formats, ARRAY_SIZE(wb2_formats));
  4007. /* Rotation enabled input formats */
  4008. if (IS_SDE_INLINE_ROT_REV_100(sde_cfg->true_inline_rot_rev)) {
  4009. inline_fmt_tbl = true_inline_rot_v1_fmts;
  4010. in_rot_list_size = ARRAY_SIZE(true_inline_rot_v1_fmts);
  4011. } else if (IS_SDE_INLINE_ROT_REV_200(sde_cfg->true_inline_rot_rev)) {
  4012. inline_fmt_tbl = true_inline_rot_v2_fmts;
  4013. in_rot_list_size = ARRAY_SIZE(true_inline_rot_v2_fmts);
  4014. } else if (IS_SDE_INLINE_ROT_REV_201(sde_cfg->true_inline_rot_rev)) {
  4015. inline_fmt_tbl = true_inline_rot_v201_fmts;
  4016. in_rot_list_size = ARRAY_SIZE(true_inline_rot_v201_fmts);
  4017. inline_restricted_fmt_tbl = true_inline_rot_v201_restricted_fmts;
  4018. in_rot_restricted_list_size = ARRAY_SIZE(true_inline_rot_v201_fmts);
  4019. }
  4020. if (in_rot_list_size) {
  4021. sde_cfg->inline_rot_formats = kcalloc(in_rot_list_size,
  4022. sizeof(struct sde_format_extended), GFP_KERNEL);
  4023. if (!sde_cfg->inline_rot_formats) {
  4024. SDE_ERROR("failed to alloc inline rot format list\n");
  4025. rc = -ENOMEM;
  4026. goto free_wb;
  4027. }
  4028. index = sde_copy_formats(sde_cfg->inline_rot_formats,
  4029. in_rot_list_size, 0, inline_fmt_tbl, in_rot_list_size);
  4030. }
  4031. if (in_rot_restricted_list_size) {
  4032. sde_cfg->inline_rot_restricted_formats = kcalloc(in_rot_restricted_list_size,
  4033. sizeof(struct sde_format_extended), GFP_KERNEL);
  4034. if (!sde_cfg->inline_rot_restricted_formats) {
  4035. SDE_ERROR("failed to alloc inline rot restricted format list\n");
  4036. rc = -ENOMEM;
  4037. goto free_in_rot;
  4038. }
  4039. index = sde_copy_formats(sde_cfg->inline_rot_restricted_formats,
  4040. in_rot_restricted_list_size, 0, inline_restricted_fmt_tbl,
  4041. in_rot_restricted_list_size);
  4042. }
  4043. return 0;
  4044. free_in_rot:
  4045. kfree(sde_cfg->inline_rot_formats);
  4046. free_wb:
  4047. kfree(sde_cfg->wb_formats);
  4048. free_virt:
  4049. kfree(sde_cfg->virt_vig_formats);
  4050. free_vig:
  4051. kfree(sde_cfg->vig_formats);
  4052. free_dma:
  4053. kfree(sde_cfg->dma_formats);
  4054. free_cursor:
  4055. if (sde_cfg->has_cursor)
  4056. kfree(sde_cfg->cursor_formats);
  4057. out:
  4058. return rc;
  4059. }
  4060. static void _sde_hw_setup_uidle(struct sde_uidle_cfg *uidle_cfg)
  4061. {
  4062. if (!uidle_cfg->uidle_rev)
  4063. return;
  4064. if ((IS_SDE_UIDLE_REV_102(uidle_cfg->uidle_rev)) ||
  4065. (IS_SDE_UIDLE_REV_101(uidle_cfg->uidle_rev)) ||
  4066. (IS_SDE_UIDLE_REV_100(uidle_cfg->uidle_rev))) {
  4067. uidle_cfg->fal10_exit_cnt = SDE_UIDLE_FAL10_EXIT_CNT;
  4068. uidle_cfg->fal10_exit_danger = SDE_UIDLE_FAL10_EXIT_DANGER;
  4069. uidle_cfg->fal10_danger = SDE_UIDLE_FAL10_DANGER;
  4070. uidle_cfg->fal10_target_idle_time = SDE_UIDLE_FAL10_TARGET_IDLE;
  4071. uidle_cfg->fal1_target_idle_time = SDE_UIDLE_FAL1_TARGET_IDLE;
  4072. uidle_cfg->max_dwnscale = SDE_UIDLE_MAX_DWNSCALE;
  4073. uidle_cfg->debugfs_ctrl = true;
  4074. uidle_cfg->fal1_max_threshold = SDE_UIDLE_FAL1_MAX_THRESHOLD;
  4075. if (IS_SDE_UIDLE_REV_100(uidle_cfg->uidle_rev)) {
  4076. uidle_cfg->fal10_threshold =
  4077. SDE_UIDLE_FAL10_THRESHOLD_60;
  4078. uidle_cfg->max_fps = SDE_UIDLE_MAX_FPS_60;
  4079. } else if (IS_SDE_UIDLE_REV_101(uidle_cfg->uidle_rev)) {
  4080. set_bit(SDE_UIDLE_QACTIVE_OVERRIDE,
  4081. &uidle_cfg->features);
  4082. uidle_cfg->fal10_threshold =
  4083. SDE_UIDLE_FAL10_THRESHOLD_90;
  4084. uidle_cfg->max_fps = SDE_UIDLE_MAX_FPS_90;
  4085. } else if (IS_SDE_UIDLE_REV_102(uidle_cfg->uidle_rev)) {
  4086. set_bit(SDE_UIDLE_QACTIVE_OVERRIDE,
  4087. &uidle_cfg->features);
  4088. uidle_cfg->fal10_threshold =
  4089. SDE_UIDLE_FAL10_THRESHOLD_90;
  4090. uidle_cfg->max_fps = SDE_UIDLE_MAX_FPS_90;
  4091. uidle_cfg->max_fal1_fps = SDE_UIDLE_MAX_FPS_240;
  4092. uidle_cfg->fal1_max_threshold =
  4093. SDE_UIDLE_REV102_FAL1_MAX_THRESHOLD;
  4094. }
  4095. } else {
  4096. pr_err("invalid uidle rev:0x%x, disabling uidle\n",
  4097. uidle_cfg->uidle_rev);
  4098. uidle_cfg->uidle_rev = 0;
  4099. }
  4100. }
  4101. static int _sde_hardware_pre_caps(struct sde_mdss_cfg *sde_cfg, uint32_t hw_rev)
  4102. {
  4103. int rc = 0, i;
  4104. if (!sde_cfg)
  4105. return -EINVAL;
  4106. /* default settings for *MOST* targets */
  4107. sde_cfg->has_mixer_combined_alpha = true;
  4108. sde_cfg->mdss_hw_block_size = DEFAULT_MDSS_HW_BLOCK_SIZE;
  4109. for (i = 0; i < SSPP_MAX; i++) {
  4110. sde_cfg->demura_supported[i][0] = ~0x0;
  4111. sde_cfg->demura_supported[i][1] = ~0x0;
  4112. }
  4113. /* target specific settings */
  4114. if (IS_MSM8996_TARGET(hw_rev)) {
  4115. sde_cfg->perf.min_prefill_lines = 21;
  4116. sde_cfg->has_decimation = true;
  4117. sde_cfg->has_mixer_combined_alpha = false;
  4118. } else if (IS_MSM8998_TARGET(hw_rev)) {
  4119. sde_cfg->has_wb_ubwc = true;
  4120. sde_cfg->perf.min_prefill_lines = 25;
  4121. sde_cfg->vbif_qos_nlvl = 4;
  4122. sde_cfg->ts_prefill_rev = 1;
  4123. sde_cfg->has_decimation = true;
  4124. sde_cfg->has_cursor = true;
  4125. sde_cfg->has_hdr = true;
  4126. sde_cfg->has_mixer_combined_alpha = false;
  4127. } else if (IS_SDM845_TARGET(hw_rev)) {
  4128. sde_cfg->has_wb_ubwc = true;
  4129. sde_cfg->has_cwb_support = true;
  4130. sde_cfg->perf.min_prefill_lines = 24;
  4131. sde_cfg->vbif_qos_nlvl = 8;
  4132. sde_cfg->ts_prefill_rev = 2;
  4133. sde_cfg->sui_misr_supported = true;
  4134. sde_cfg->sui_block_xin_mask = 0x3F71;
  4135. sde_cfg->has_decimation = true;
  4136. sde_cfg->has_hdr = true;
  4137. sde_cfg->has_vig_p010 = true;
  4138. } else if (IS_SDM670_TARGET(hw_rev)) {
  4139. sde_cfg->has_wb_ubwc = true;
  4140. sde_cfg->perf.min_prefill_lines = 24;
  4141. sde_cfg->vbif_qos_nlvl = 8;
  4142. sde_cfg->ts_prefill_rev = 2;
  4143. sde_cfg->has_decimation = true;
  4144. sde_cfg->has_hdr = true;
  4145. sde_cfg->has_vig_p010 = true;
  4146. } else if (IS_SM8150_TARGET(hw_rev)) {
  4147. sde_cfg->has_cwb_support = true;
  4148. sde_cfg->has_wb_ubwc = true;
  4149. sde_cfg->has_qsync = true;
  4150. sde_cfg->has_hdr = true;
  4151. sde_cfg->has_hdr_plus = true;
  4152. set_bit(SDE_MDP_DHDR_MEMPOOL, &sde_cfg->mdp[0].features);
  4153. sde_cfg->has_vig_p010 = true;
  4154. sde_cfg->perf.min_prefill_lines = 24;
  4155. sde_cfg->vbif_qos_nlvl = 8;
  4156. sde_cfg->ts_prefill_rev = 2;
  4157. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4158. sde_cfg->delay_prg_fetch_start = true;
  4159. sde_cfg->sui_ns_allowed = true;
  4160. sde_cfg->sui_misr_supported = true;
  4161. sde_cfg->sui_block_xin_mask = 0x3F71;
  4162. sde_cfg->has_sui_blendstage = true;
  4163. sde_cfg->has_3d_merge_reset = true;
  4164. sde_cfg->has_decimation = true;
  4165. sde_cfg->vbif_disable_inner_outer_shareable = true;
  4166. } else if (IS_SDMSHRIKE_TARGET(hw_rev)) {
  4167. sde_cfg->has_wb_ubwc = true;
  4168. sde_cfg->perf.min_prefill_lines = 24;
  4169. sde_cfg->vbif_qos_nlvl = 8;
  4170. sde_cfg->ts_prefill_rev = 2;
  4171. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4172. sde_cfg->delay_prg_fetch_start = true;
  4173. sde_cfg->has_decimation = true;
  4174. sde_cfg->has_hdr = true;
  4175. sde_cfg->has_vig_p010 = true;
  4176. } else if (IS_SM6150_TARGET(hw_rev)) {
  4177. sde_cfg->has_cwb_support = true;
  4178. sde_cfg->has_qsync = true;
  4179. sde_cfg->perf.min_prefill_lines = 24;
  4180. sde_cfg->vbif_qos_nlvl = 8;
  4181. sde_cfg->ts_prefill_rev = 2;
  4182. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4183. sde_cfg->delay_prg_fetch_start = true;
  4184. sde_cfg->sui_ns_allowed = true;
  4185. sde_cfg->sui_misr_supported = true;
  4186. sde_cfg->has_decimation = true;
  4187. sde_cfg->sui_block_xin_mask = 0x2EE1;
  4188. sde_cfg->has_sui_blendstage = true;
  4189. sde_cfg->has_3d_merge_reset = true;
  4190. sde_cfg->has_hdr = true;
  4191. sde_cfg->has_vig_p010 = true;
  4192. sde_cfg->vbif_disable_inner_outer_shareable = true;
  4193. } else if (IS_SDMMAGPIE_TARGET(hw_rev)) {
  4194. sde_cfg->has_cwb_support = true;
  4195. sde_cfg->has_wb_ubwc = true;
  4196. sde_cfg->has_qsync = true;
  4197. sde_cfg->perf.min_prefill_lines = 24;
  4198. sde_cfg->vbif_qos_nlvl = 8;
  4199. sde_cfg->ts_prefill_rev = 2;
  4200. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4201. sde_cfg->delay_prg_fetch_start = true;
  4202. sde_cfg->sui_ns_allowed = true;
  4203. sde_cfg->sui_misr_supported = true;
  4204. sde_cfg->sui_block_xin_mask = 0xE71;
  4205. sde_cfg->has_sui_blendstage = true;
  4206. sde_cfg->has_3d_merge_reset = true;
  4207. sde_cfg->vbif_disable_inner_outer_shareable = true;
  4208. } else if (IS_KONA_TARGET(hw_rev)) {
  4209. sde_cfg->has_cwb_support = true;
  4210. sde_cfg->has_wb_ubwc = true;
  4211. sde_cfg->has_qsync = true;
  4212. sde_cfg->perf.min_prefill_lines = 35;
  4213. sde_cfg->vbif_qos_nlvl = 8;
  4214. sde_cfg->ts_prefill_rev = 2;
  4215. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4216. sde_cfg->delay_prg_fetch_start = true;
  4217. sde_cfg->sui_ns_allowed = true;
  4218. sde_cfg->sui_misr_supported = true;
  4219. sde_cfg->sui_block_xin_mask = 0x3F71;
  4220. sde_cfg->has_sui_blendstage = true;
  4221. sde_cfg->has_3d_merge_reset = true;
  4222. sde_cfg->has_hdr = true;
  4223. sde_cfg->has_hdr_plus = true;
  4224. set_bit(SDE_MDP_DHDR_MEMPOOL, &sde_cfg->mdp[0].features);
  4225. sde_cfg->has_vig_p010 = true;
  4226. sde_cfg->true_inline_rot_rev = SDE_INLINE_ROT_VERSION_1_0_0;
  4227. sde_cfg->uidle_cfg.uidle_rev = SDE_UIDLE_VERSION_1_0_0;
  4228. sde_cfg->inline_disable_const_clr = true;
  4229. } else if (IS_SAIPAN_TARGET(hw_rev)) {
  4230. sde_cfg->has_cwb_support = true;
  4231. sde_cfg->has_wb_ubwc = true;
  4232. sde_cfg->has_qsync = true;
  4233. sde_cfg->perf.min_prefill_lines = 40;
  4234. sde_cfg->vbif_qos_nlvl = 8;
  4235. sde_cfg->ts_prefill_rev = 2;
  4236. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4237. sde_cfg->delay_prg_fetch_start = true;
  4238. sde_cfg->sui_ns_allowed = true;
  4239. sde_cfg->sui_misr_supported = true;
  4240. sde_cfg->sui_block_xin_mask = 0xE71;
  4241. sde_cfg->has_sui_blendstage = true;
  4242. sde_cfg->has_3d_merge_reset = true;
  4243. sde_cfg->has_hdr = true;
  4244. sde_cfg->has_hdr_plus = true;
  4245. set_bit(SDE_MDP_DHDR_MEMPOOL, &sde_cfg->mdp[0].features);
  4246. sde_cfg->has_vig_p010 = true;
  4247. sde_cfg->true_inline_rot_rev = SDE_INLINE_ROT_VERSION_1_0_0;
  4248. sde_cfg->inline_disable_const_clr = true;
  4249. } else if (IS_SDMTRINKET_TARGET(hw_rev)) {
  4250. sde_cfg->has_cwb_support = true;
  4251. sde_cfg->has_qsync = true;
  4252. sde_cfg->perf.min_prefill_lines = 24;
  4253. sde_cfg->vbif_qos_nlvl = 8;
  4254. sde_cfg->ts_prefill_rev = 2;
  4255. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4256. sde_cfg->delay_prg_fetch_start = true;
  4257. sde_cfg->sui_ns_allowed = true;
  4258. sde_cfg->sui_misr_supported = true;
  4259. sde_cfg->sui_block_xin_mask = 0xC61;
  4260. sde_cfg->has_hdr = false;
  4261. sde_cfg->has_sui_blendstage = true;
  4262. sde_cfg->vbif_disable_inner_outer_shareable = true;
  4263. } else if (IS_BENGAL_TARGET(hw_rev)) {
  4264. sde_cfg->has_cwb_support = false;
  4265. sde_cfg->has_qsync = true;
  4266. sde_cfg->perf.min_prefill_lines = 24;
  4267. sde_cfg->vbif_qos_nlvl = 8;
  4268. sde_cfg->ts_prefill_rev = 2;
  4269. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4270. sde_cfg->delay_prg_fetch_start = true;
  4271. sde_cfg->sui_ns_allowed = true;
  4272. sde_cfg->sui_misr_supported = true;
  4273. sde_cfg->sui_block_xin_mask = 0xC01;
  4274. sde_cfg->has_hdr = false;
  4275. sde_cfg->has_sui_blendstage = true;
  4276. sde_cfg->vbif_disable_inner_outer_shareable = true;
  4277. } else if (IS_LAGOON_TARGET(hw_rev)) {
  4278. sde_cfg->has_cwb_support = true;
  4279. sde_cfg->has_qsync = true;
  4280. sde_cfg->perf.min_prefill_lines = 40;
  4281. sde_cfg->vbif_qos_nlvl = 8;
  4282. sde_cfg->ts_prefill_rev = 2;
  4283. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4284. sde_cfg->delay_prg_fetch_start = true;
  4285. sde_cfg->sui_ns_allowed = true;
  4286. sde_cfg->sui_misr_supported = true;
  4287. sde_cfg->sui_block_xin_mask = 0x261;
  4288. sde_cfg->has_sui_blendstage = true;
  4289. sde_cfg->has_hdr = true;
  4290. sde_cfg->has_vig_p010 = true;
  4291. sde_cfg->vbif_disable_inner_outer_shareable = true;
  4292. } else if (IS_SCUBA_TARGET(hw_rev)) {
  4293. sde_cfg->has_cwb_support = false;
  4294. sde_cfg->has_qsync = true;
  4295. sde_cfg->perf.min_prefill_lines = 24;
  4296. sde_cfg->vbif_qos_nlvl = 8;
  4297. sde_cfg->ts_prefill_rev = 2;
  4298. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4299. sde_cfg->delay_prg_fetch_start = true;
  4300. sde_cfg->sui_ns_allowed = true;
  4301. sde_cfg->sui_misr_supported = true;
  4302. sde_cfg->sui_block_xin_mask = 0x1;
  4303. sde_cfg->has_hdr = false;
  4304. sde_cfg->has_sui_blendstage = true;
  4305. } else if (IS_LAHAINA_TARGET(hw_rev)) {
  4306. sde_cfg->has_demura = true;
  4307. sde_cfg->demura_supported[SSPP_DMA1][0] = 0;
  4308. sde_cfg->demura_supported[SSPP_DMA1][1] = 1;
  4309. sde_cfg->demura_supported[SSPP_DMA3][0] = 0;
  4310. sde_cfg->demura_supported[SSPP_DMA3][1] = 1;
  4311. sde_cfg->has_cwb_support = true;
  4312. sde_cfg->has_wb_ubwc = true;
  4313. sde_cfg->has_qsync = true;
  4314. sde_cfg->perf.min_prefill_lines = 40;
  4315. sde_cfg->vbif_qos_nlvl = 8;
  4316. sde_cfg->ts_prefill_rev = 2;
  4317. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4318. sde_cfg->delay_prg_fetch_start = true;
  4319. sde_cfg->sui_ns_allowed = true;
  4320. sde_cfg->sui_misr_supported = true;
  4321. sde_cfg->sui_block_xin_mask = 0x3F71;
  4322. sde_cfg->has_sui_blendstage = true;
  4323. sde_cfg->has_3d_merge_reset = true;
  4324. sde_cfg->has_hdr = true;
  4325. sde_cfg->has_hdr_plus = true;
  4326. set_bit(SDE_MDP_DHDR_MEMPOOL_4K, &sde_cfg->mdp[0].features);
  4327. sde_cfg->has_vig_p010 = true;
  4328. sde_cfg->true_inline_rot_rev = SDE_INLINE_ROT_VERSION_2_0_0;
  4329. sde_cfg->uidle_cfg.uidle_rev = SDE_UIDLE_VERSION_1_0_1;
  4330. sde_cfg->vbif_disable_inner_outer_shareable = true;
  4331. sde_cfg->dither_luma_mode_support = true;
  4332. sde_cfg->mdss_hw_block_size = 0x158;
  4333. sde_cfg->has_trusted_vm_support = true;
  4334. sde_cfg->syscache_supported = true;
  4335. } else if (IS_HOLI_TARGET(hw_rev)) {
  4336. sde_cfg->has_cwb_support = false;
  4337. sde_cfg->has_qsync = true;
  4338. sde_cfg->perf.min_prefill_lines = 24;
  4339. sde_cfg->vbif_qos_nlvl = 8;
  4340. sde_cfg->ts_prefill_rev = 2;
  4341. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4342. sde_cfg->delay_prg_fetch_start = true;
  4343. sde_cfg->sui_ns_allowed = true;
  4344. sde_cfg->sui_misr_supported = true;
  4345. sde_cfg->sui_block_xin_mask = 0xC01;
  4346. sde_cfg->has_hdr = false;
  4347. sde_cfg->has_sui_blendstage = true;
  4348. sde_cfg->vbif_disable_inner_outer_shareable = true;
  4349. sde_cfg->mdss_hw_block_size = 0x158;
  4350. sde_cfg->rc_lm_flush_override = true;
  4351. } else if (IS_SHIMA_TARGET(hw_rev)) {
  4352. sde_cfg->has_cwb_support = true;
  4353. sde_cfg->has_wb_ubwc = true;
  4354. sde_cfg->has_qsync = true;
  4355. sde_cfg->perf.min_prefill_lines = 35;
  4356. sde_cfg->vbif_qos_nlvl = 8;
  4357. sde_cfg->ts_prefill_rev = 2;
  4358. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4359. sde_cfg->delay_prg_fetch_start = true;
  4360. sde_cfg->sui_ns_allowed = true;
  4361. sde_cfg->sui_misr_supported = true;
  4362. sde_cfg->sui_block_xin_mask = 0xE71;
  4363. sde_cfg->has_sui_blendstage = true;
  4364. sde_cfg->has_3d_merge_reset = true;
  4365. sde_cfg->has_hdr = true;
  4366. sde_cfg->has_hdr_plus = true;
  4367. set_bit(SDE_MDP_DHDR_MEMPOOL, &sde_cfg->mdp[0].features);
  4368. sde_cfg->has_vig_p010 = true;
  4369. sde_cfg->true_inline_rot_rev = SDE_INLINE_ROT_VERSION_1_0_0;
  4370. sde_cfg->inline_disable_const_clr = true;
  4371. sde_cfg->vbif_disable_inner_outer_shareable = true;
  4372. sde_cfg->mdss_hw_block_size = 0x158;
  4373. sde_cfg->has_trusted_vm_support = true;
  4374. sde_cfg->syscache_supported = true;
  4375. } else if (IS_WAIPIO_TARGET(hw_rev)) {
  4376. sde_cfg->has_dedicated_cwb_support = true;
  4377. sde_cfg->has_wb_ubwc = true;
  4378. sde_cfg->has_cwb_crop = true;
  4379. sde_cfg->has_qsync = true;
  4380. sde_cfg->perf.min_prefill_lines = 40;
  4381. sde_cfg->vbif_qos_nlvl = 8;
  4382. sde_cfg->ts_prefill_rev = 2;
  4383. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4384. sde_cfg->delay_prg_fetch_start = true;
  4385. sde_cfg->sui_ns_allowed = true;
  4386. sde_cfg->sui_misr_supported = true;
  4387. sde_cfg->has_sui_blendstage = true;
  4388. sde_cfg->has_3d_merge_reset = true;
  4389. sde_cfg->has_hdr = true;
  4390. sde_cfg->has_hdr_plus = true;
  4391. set_bit(SDE_MDP_DHDR_MEMPOOL_4K, &sde_cfg->mdp[0].features);
  4392. sde_cfg->has_vig_p010 = true;
  4393. sde_cfg->true_inline_rot_rev = SDE_INLINE_ROT_VERSION_2_0_1;
  4394. sde_cfg->uidle_cfg.uidle_rev = SDE_UIDLE_VERSION_1_0_2;
  4395. sde_cfg->vbif_disable_inner_outer_shareable = true;
  4396. sde_cfg->dither_luma_mode_support = true;
  4397. sde_cfg->mdss_hw_block_size = 0x158;
  4398. sde_cfg->syscache_supported = true;
  4399. sde_cfg->sspp_multirect_error = true;
  4400. sde_cfg->has_fp16 = true;
  4401. set_bit(SDE_MDP_PERIPH_TOP_0_REMOVED, &sde_cfg->mdp[0].features);
  4402. sde_cfg->has_precise_vsync_ts = true;
  4403. sde_cfg->has_trusted_vm_support = true;
  4404. } else if (IS_YUPIK_TARGET(hw_rev)) {
  4405. sde_cfg->has_cwb_support = true;
  4406. sde_cfg->has_qsync = true;
  4407. sde_cfg->perf.min_prefill_lines = 40;
  4408. sde_cfg->vbif_qos_nlvl = 8;
  4409. sde_cfg->ts_prefill_rev = 2;
  4410. sde_cfg->ctl_rev = SDE_CTL_CFG_VERSION_1_0_0;
  4411. sde_cfg->delay_prg_fetch_start = true;
  4412. sde_cfg->sui_ns_allowed = true;
  4413. sde_cfg->sui_misr_supported = true;
  4414. sde_cfg->sui_block_xin_mask = 0x261;
  4415. sde_cfg->has_sui_blendstage = true;
  4416. sde_cfg->has_3d_merge_reset = true;
  4417. sde_cfg->has_hdr = true;
  4418. sde_cfg->has_hdr_plus = true;
  4419. set_bit(SDE_MDP_DHDR_MEMPOOL_4K, &sde_cfg->mdp[0].features);
  4420. sde_cfg->has_vig_p010 = true;
  4421. sde_cfg->true_inline_rot_rev = SDE_INLINE_ROT_VERSION_2_0_0;
  4422. sde_cfg->vbif_disable_inner_outer_shareable = true;
  4423. sde_cfg->dither_luma_mode_support = true;
  4424. sde_cfg->mdss_hw_block_size = 0x158;
  4425. sde_cfg->rc_lm_flush_override = false;
  4426. } else {
  4427. SDE_ERROR("unsupported chipset id:%X\n", hw_rev);
  4428. sde_cfg->perf.min_prefill_lines = 0xffff;
  4429. rc = -ENODEV;
  4430. }
  4431. if (!rc)
  4432. rc = sde_hardware_format_caps(sde_cfg, hw_rev);
  4433. _sde_hw_setup_uidle(&sde_cfg->uidle_cfg);
  4434. return rc;
  4435. }
  4436. static int _sde_hardware_post_caps(struct sde_mdss_cfg *sde_cfg,
  4437. uint32_t hw_rev)
  4438. {
  4439. int rc = 0, i;
  4440. u32 max_horz_deci = 0, max_vert_deci = 0;
  4441. if (!sde_cfg)
  4442. return -EINVAL;
  4443. if (sde_cfg->has_sui_blendstage)
  4444. sde_cfg->sui_supported_blendstage =
  4445. sde_cfg->max_mixer_blendstages - SDE_STAGE_0;
  4446. for (i = 0; i < sde_cfg->sspp_count; i++) {
  4447. if (sde_cfg->sspp[i].sblk) {
  4448. max_horz_deci = max(max_horz_deci,
  4449. sde_cfg->sspp[i].sblk->maxhdeciexp);
  4450. max_vert_deci = max(max_vert_deci,
  4451. sde_cfg->sspp[i].sblk->maxvdeciexp);
  4452. }
  4453. /*
  4454. * set sec-ui blocked SSPP feature flag based on blocked
  4455. * xin-mask if sec-ui-misr feature is enabled;
  4456. */
  4457. if (sde_cfg->sui_misr_supported
  4458. && (sde_cfg->sui_block_xin_mask
  4459. & BIT(sde_cfg->sspp[i].xin_id)))
  4460. set_bit(SDE_SSPP_BLOCK_SEC_UI,
  4461. &sde_cfg->sspp[i].features);
  4462. }
  4463. if (max_horz_deci)
  4464. sde_cfg->max_display_width = sde_cfg->max_sspp_linewidth *
  4465. max_horz_deci;
  4466. else
  4467. sde_cfg->max_display_width = sde_cfg->max_sspp_linewidth *
  4468. MAX_DOWNSCALE_RATIO;
  4469. if (max_vert_deci)
  4470. sde_cfg->max_display_height =
  4471. MAX_DISPLAY_HEIGHT_WITH_DECIMATION * max_vert_deci;
  4472. else
  4473. sde_cfg->max_display_height = MAX_DISPLAY_HEIGHT_WITH_DECIMATION
  4474. * MAX_DOWNSCALE_RATIO;
  4475. sde_cfg->min_display_height = MIN_DISPLAY_HEIGHT;
  4476. sde_cfg->min_display_width = MIN_DISPLAY_WIDTH;
  4477. return rc;
  4478. }
  4479. void sde_hw_catalog_deinit(struct sde_mdss_cfg *sde_cfg)
  4480. {
  4481. int i, j;
  4482. if (!sde_cfg)
  4483. return;
  4484. sde_hw_catalog_irq_offset_list_delete(&sde_cfg->irq_offset_list);
  4485. for (i = 0; i < sde_cfg->sspp_count; i++)
  4486. kfree(sde_cfg->sspp[i].sblk);
  4487. for (i = 0; i < sde_cfg->mixer_count; i++)
  4488. kfree(sde_cfg->mixer[i].sblk);
  4489. for (i = 0; i < sde_cfg->wb_count; i++)
  4490. kfree(sde_cfg->wb[i].sblk);
  4491. for (i = 0; i < sde_cfg->dspp_count; i++)
  4492. kfree(sde_cfg->dspp[i].sblk);
  4493. if (sde_cfg->ds_count)
  4494. kfree(sde_cfg->ds[0].top);
  4495. for (i = 0; i < sde_cfg->pingpong_count; i++)
  4496. kfree(sde_cfg->pingpong[i].sblk);
  4497. for (i = 0; i < sde_cfg->vdc_count; i++)
  4498. kfree(sde_cfg->vdc[i].sblk);
  4499. for (i = 0; i < sde_cfg->vbif_count; i++) {
  4500. kfree(sde_cfg->vbif[i].dynamic_ot_rd_tbl.cfg);
  4501. kfree(sde_cfg->vbif[i].dynamic_ot_wr_tbl.cfg);
  4502. for (j = VBIF_RT_CLIENT; j < VBIF_MAX_CLIENT; j++)
  4503. kfree(sde_cfg->vbif[i].qos_tbl[j].priority_lvl);
  4504. }
  4505. kfree(sde_cfg->perf.qos_refresh_rate);
  4506. kfree(sde_cfg->perf.danger_lut);
  4507. kfree(sde_cfg->perf.safe_lut);
  4508. kfree(sde_cfg->perf.creq_lut);
  4509. kfree(sde_cfg->dma_formats);
  4510. kfree(sde_cfg->cursor_formats);
  4511. kfree(sde_cfg->vig_formats);
  4512. kfree(sde_cfg->wb_formats);
  4513. kfree(sde_cfg->virt_vig_formats);
  4514. kfree(sde_cfg->inline_rot_formats);
  4515. kfree(sde_cfg);
  4516. }
  4517. static int sde_hw_ver_parse_dt(struct drm_device *dev, struct device_node *np,
  4518. struct sde_mdss_cfg *cfg)
  4519. {
  4520. int rc, len, prop_count[SDE_HW_PROP_MAX];
  4521. struct sde_prop_value *prop_value = NULL;
  4522. bool prop_exists[SDE_HW_PROP_MAX];
  4523. if (!cfg) {
  4524. SDE_ERROR("invalid argument\n");
  4525. return -EINVAL;
  4526. }
  4527. prop_value = kzalloc(SDE_HW_PROP_MAX *
  4528. sizeof(struct sde_prop_value), GFP_KERNEL);
  4529. if (!prop_value)
  4530. return -ENOMEM;
  4531. rc = _validate_dt_entry(np, sde_hw_prop, ARRAY_SIZE(sde_hw_prop),
  4532. prop_count, &len);
  4533. if (rc)
  4534. goto end;
  4535. rc = _read_dt_entry(np, sde_hw_prop, ARRAY_SIZE(sde_hw_prop),
  4536. prop_count, prop_exists, prop_value);
  4537. if (rc)
  4538. goto end;
  4539. if (prop_exists[SDE_HW_VERSION])
  4540. cfg->hwversion = PROP_VALUE_ACCESS(prop_value,
  4541. SDE_HW_VERSION, 0);
  4542. else
  4543. cfg->hwversion = sde_kms_get_hw_version(dev);
  4544. end:
  4545. kfree(prop_value);
  4546. return rc;
  4547. }
  4548. /*************************************************************
  4549. * hardware catalog init
  4550. *************************************************************/
  4551. struct sde_mdss_cfg *sde_hw_catalog_init(struct drm_device *dev)
  4552. {
  4553. int rc;
  4554. struct sde_mdss_cfg *sde_cfg;
  4555. struct device_node *np = dev->dev->of_node;
  4556. if (!np)
  4557. return ERR_PTR(-EINVAL);
  4558. sde_cfg = kzalloc(sizeof(*sde_cfg), GFP_KERNEL);
  4559. if (!sde_cfg)
  4560. return ERR_PTR(-ENOMEM);
  4561. INIT_LIST_HEAD(&sde_cfg->irq_offset_list);
  4562. rc = sde_hw_ver_parse_dt(dev, np, sde_cfg);
  4563. if (rc)
  4564. goto end;
  4565. rc = _sde_hardware_pre_caps(sde_cfg, sde_cfg->hwversion);
  4566. if (rc)
  4567. goto end;
  4568. rc = sde_top_parse_dt(np, sde_cfg);
  4569. if (rc)
  4570. goto end;
  4571. rc = sde_perf_parse_dt(np, sde_cfg);
  4572. if (rc)
  4573. goto end;
  4574. rc = sde_qos_parse_dt(np, sde_cfg);
  4575. if (rc)
  4576. goto end;
  4577. /* uidle must be done before sspp and ctl,
  4578. * so if something goes wrong, we won't
  4579. * enable it in ctl and sspp.
  4580. */
  4581. rc = sde_uidle_parse_dt(np, sde_cfg);
  4582. if (rc)
  4583. goto end;
  4584. rc = sde_cache_parse_dt(np, sde_cfg);
  4585. if (rc)
  4586. goto end;
  4587. rc = sde_ctl_parse_dt(np, sde_cfg);
  4588. if (rc)
  4589. goto end;
  4590. rc = sde_sspp_parse_dt(np, sde_cfg);
  4591. if (rc)
  4592. goto end;
  4593. rc = sde_dspp_top_parse_dt(np, sde_cfg);
  4594. if (rc)
  4595. goto end;
  4596. rc = sde_dspp_parse_dt(np, sde_cfg);
  4597. if (rc)
  4598. goto end;
  4599. rc = sde_ds_parse_dt(np, sde_cfg);
  4600. if (rc)
  4601. goto end;
  4602. rc = sde_dsc_parse_dt(np, sde_cfg);
  4603. if (rc)
  4604. goto end;
  4605. rc = sde_vdc_parse_dt(np, sde_cfg);
  4606. if (rc)
  4607. goto end;
  4608. rc = sde_pp_parse_dt(np, sde_cfg);
  4609. if (rc)
  4610. goto end;
  4611. /* mixer parsing should be done after dspp,
  4612. * ds and pp for mapping setup
  4613. */
  4614. rc = sde_mixer_parse_dt(np, sde_cfg);
  4615. if (rc)
  4616. goto end;
  4617. rc = sde_intf_parse_dt(np, sde_cfg);
  4618. if (rc)
  4619. goto end;
  4620. rc = sde_wb_parse_dt(np, sde_cfg);
  4621. if (rc)
  4622. goto end;
  4623. /* cdm parsing should be done after intf and wb for mapping setup */
  4624. rc = sde_cdm_parse_dt(np, sde_cfg);
  4625. if (rc)
  4626. goto end;
  4627. rc = sde_vbif_parse_dt(np, sde_cfg);
  4628. if (rc)
  4629. goto end;
  4630. rc = sde_parse_reg_dma_dt(np, sde_cfg);
  4631. if (rc)
  4632. goto end;
  4633. rc = sde_parse_merge_3d_dt(np, sde_cfg);
  4634. if (rc)
  4635. goto end;
  4636. rc = sde_qdss_parse_dt(np, sde_cfg);
  4637. if (rc)
  4638. goto end;
  4639. rc = _sde_hardware_post_caps(sde_cfg, sde_cfg->hwversion);
  4640. if (rc)
  4641. goto end;
  4642. return sde_cfg;
  4643. end:
  4644. sde_hw_catalog_deinit(sde_cfg);
  4645. return NULL;
  4646. }