sde_hw_catalog.c 138 KB

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