sde_hw_catalog.c 159 KB

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