sde_hw_catalog.c 150 KB

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