sde_hw_catalog.c 136 KB

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