sde_hw_catalog.c 170 KB

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