sde_hw_catalog.c 164 KB

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