sde_hw_catalog.c 141 KB

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