sde_hw_catalog.c 151 KB

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