sde_hw_catalog.c 153 KB

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