sde_hw_catalog.c 165 KB

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