sde_hw_catalog.c 150 KB

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