sde_hw_catalog.c 159 KB

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