sde_hw_catalog.c 158 KB

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