sde_hw_catalog.c 171 KB

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