123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805 |
- // SPDX-License-Identifier: GPL-2.0-only
- /*
- * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
- */
- #include <asm/memory.h>
- #include <linux/coresight-stm.h>
- #include <linux/delay.h>
- #include <linux/devfreq.h>
- #include <linux/hash.h>
- #include <linux/io.h>
- #include <linux/iommu.h>
- #include <linux/iopoll.h>
- #include <linux/of.h>
- #include <linux/pm_qos.h>
- #include <linux/regulator/consumer.h>
- #include <linux/slab.h>
- #include <linux/workqueue.h>
- #include <linux/platform_device.h>
- #include <linux/soc/qcom/llcc-qcom.h>
- #include <linux/qcom_scm.h>
- #include <linux/soc/qcom/smem.h>
- #include <linux/dma-mapping.h>
- #include <linux/reset.h>
- #include <linux/pm_wakeup.h>
- #include "hfi_packetization.h"
- #include "msm_cvp_debug.h"
- #include "cvp_core_hfi.h"
- #include "cvp_hfi_helper.h"
- #include "cvp_hfi_io.h"
- #include "msm_cvp_dsp.h"
- #include "msm_cvp_clocks.h"
- #include "vm/cvp_vm.h"
- #include "cvp_dump.h"
- // ysi - added for debug
- #include <linux/clk/qcom.h>
- #include "msm_cvp_common.h"
- #define REG_ADDR_OFFSET_BITMASK 0x000FFFFF
- #define QDSS_IOVA_START 0x80001000
- #define MIN_PAYLOAD_SIZE 3
- struct cvp_tzbsp_memprot {
- u32 cp_start;
- u32 cp_size;
- u32 cp_nonpixel_start;
- u32 cp_nonpixel_size;
- };
- #define TZBSP_CVP_PAS_ID 26
- /* Poll interval in uS */
- #define POLL_INTERVAL_US 50
- enum tzbsp_subsys_state {
- TZ_SUBSYS_STATE_SUSPEND = 0,
- TZ_SUBSYS_STATE_RESUME = 1,
- TZ_SUBSYS_STATE_RESTORE_THRESHOLD = 2,
- };
- const struct msm_cvp_gov_data CVP_DEFAULT_BUS_VOTE = {
- .data = NULL,
- .data_count = 0,
- };
- const int cvp_max_packets = 32;
- static void iris_hfi_pm_handler(struct work_struct *work);
- static DECLARE_DELAYED_WORK(iris_hfi_pm_work, iris_hfi_pm_handler);
- static inline int __resume(struct iris_hfi_device *device);
- static inline int __suspend(struct iris_hfi_device *device);
- static int __disable_regulator(struct iris_hfi_device *device,
- const char *name);
- static int __enable_regulator(struct iris_hfi_device *device,
- const char *name);
- static void __flush_debug_queue(struct iris_hfi_device *device, u8 *packet);
- static int __initialize_packetization(struct iris_hfi_device *device);
- static struct cvp_hal_session *__get_session(struct iris_hfi_device *device,
- u32 session_id);
- static bool __is_session_valid(struct iris_hfi_device *device,
- struct cvp_hal_session *session, const char *func);
- static int __iface_cmdq_write(struct iris_hfi_device *device,
- void *pkt);
- static int __load_fw(struct iris_hfi_device *device);
- static int __power_on_init(struct iris_hfi_device *device);
- static void __unload_fw(struct iris_hfi_device *device);
- static int __tzbsp_set_cvp_state(enum tzbsp_subsys_state state);
- static int __enable_subcaches(struct iris_hfi_device *device);
- static int __set_subcaches(struct iris_hfi_device *device);
- static int __release_subcaches(struct iris_hfi_device *device);
- static int __disable_subcaches(struct iris_hfi_device *device);
- static int __power_collapse(struct iris_hfi_device *device, bool force);
- static int iris_hfi_noc_error_info(void *dev);
- static void interrupt_init_iris2(struct iris_hfi_device *device);
- static void setup_dsp_uc_memmap_vpu5(struct iris_hfi_device *device);
- static void clock_config_on_enable_vpu5(struct iris_hfi_device *device);
- static void power_off_iris2(struct iris_hfi_device *device);
- static int __set_ubwc_config(struct iris_hfi_device *device);
- static void __noc_error_info_iris2(struct iris_hfi_device *device);
- static int __enable_hw_power_collapse(struct iris_hfi_device *device);
- static int __disable_hw_power_collapse(struct iris_hfi_device *device);
- static int __power_off_controller(struct iris_hfi_device *device);
- static int __hwfence_regs_map(struct iris_hfi_device *device);
- static int __hwfence_regs_unmap(struct iris_hfi_device *device);
- static int __reset_control_assert_name(struct iris_hfi_device *device, const char *name);
- static int __reset_control_deassert_name(struct iris_hfi_device *device, const char *name);
- static int __reset_control_acquire(struct iris_hfi_device *device, const char *name);
- static int __reset_control_release(struct iris_hfi_device *device, const char *name);
- static bool __is_ctl_power_on(struct iris_hfi_device *device);
- static void __print_sidebandmanager_regs(struct iris_hfi_device *device);
- static void dump_noc_reg(struct iris_hfi_device *device);
- static struct cvp_hal_ops hal_ops = {
- .interrupt_init = interrupt_init_iris2,
- .setup_dsp_uc_memmap = setup_dsp_uc_memmap_vpu5,
- .clock_config_on_enable = clock_config_on_enable_vpu5,
- .power_off = power_off_iris2,
- .noc_error_info = __noc_error_info_iris2,
- .reset_control_assert_name = __reset_control_assert_name,
- .reset_control_deassert_name = __reset_control_deassert_name,
- .reset_control_acquire_name = __reset_control_acquire,
- .reset_control_release_name = __reset_control_release,
- };
- /**
- * Utility function to enforce some of our assumptions. Spam calls to this
- * in hotspots in code to double check some of the assumptions that we hold.
- */
- static inline void __strict_check(struct iris_hfi_device *device)
- {
- msm_cvp_res_handle_fatal_hw_error(device->res,
- !mutex_is_locked(&device->lock));
- }
- static inline void __set_state(struct iris_hfi_device *device,
- enum iris_hfi_state state)
- {
- device->state = state;
- }
- static inline bool __core_in_valid_state(struct iris_hfi_device *device)
- {
- return device->state != IRIS_STATE_DEINIT;
- }
- static inline bool is_sys_cache_present(struct iris_hfi_device *device)
- {
- return device->res->sys_cache_present;
- }
- static int cvp_synx_recover(void)
- {
- #ifdef CVP_SYNX_ENABLED
- return synx_recover(SYNX_CLIENT_EVA_CTX0);
- #else
- return 0;
- #endif /* End of CVP_SYNX_ENABLED */
- }
- #define ROW_SIZE 32
- unsigned long long get_aon_time(void)
- {
- unsigned long long val;
- asm volatile("mrs %0, cntvct_el0" : "=r" (val));
- return val;
- }
- int get_hfi_version(void)
- {
- struct msm_cvp_core *core;
- struct iris_hfi_device *hfi;
- core = cvp_driver->cvp_core;
- hfi = (struct iris_hfi_device *)core->dev_ops->hfi_device_data;
- return hfi->version;
- }
- unsigned int get_msg_size(struct cvp_hfi_msg_session_hdr *hdr)
- {
- struct msm_cvp_core *core;
- struct iris_hfi_device *device;
- u32 minor_ver;
- core = cvp_driver->cvp_core;
- if (core)
- device = core->dev_ops->hfi_device_data;
- else
- return 0;
- if (!device) {
- dprintk(CVP_ERR, "%s: NULL device\n", __func__);
- return 0;
- }
- minor_ver = (device->version & HFI_VERSION_MINOR_MASK) >>
- HFI_VERSION_MINOR_SHIFT;
- if (minor_ver < 2)
- return sizeof(struct cvp_hfi_msg_session_hdr);
- if (hdr->packet_type == HFI_MSG_SESSION_CVP_FD)
- return sizeof(struct cvp_hfi_msg_session_hdr_ext);
- else
- return sizeof(struct cvp_hfi_msg_session_hdr);
- }
- unsigned int get_msg_session_id(void *msg)
- {
- struct cvp_hfi_msg_session_hdr *hdr =
- (struct cvp_hfi_msg_session_hdr *)msg;
- return hdr->session_id;
- }
- unsigned int get_msg_errorcode(void *msg)
- {
- struct cvp_hfi_msg_session_hdr *hdr =
- (struct cvp_hfi_msg_session_hdr *)msg;
- return hdr->error_type;
- }
- int get_msg_opconfigs(void *msg, unsigned int *session_id,
- unsigned int *error_type, unsigned int *config_id)
- {
- struct cvp_hfi_msg_session_op_cfg_packet *cfg =
- (struct cvp_hfi_msg_session_op_cfg_packet *)msg;
- *session_id = cfg->session_id;
- *error_type = cfg->error_type;
- *config_id = cfg->op_conf_id;
- return 0;
- }
- static void __dump_packet(u8 *packet, enum cvp_msg_prio log_level)
- {
- u32 c = 0, packet_size = *(u32 *)packet;
- /*
- * row must contain enough for 0xdeadbaad * 8 to be converted into
- * "de ad ba ab " * 8 + '\0'
- */
- char row[3 * ROW_SIZE];
- for (c = 0; c * ROW_SIZE < packet_size; ++c) {
- int bytes_to_read = ((c + 1) * ROW_SIZE > packet_size) ?
- packet_size % ROW_SIZE : ROW_SIZE;
- hex_dump_to_buffer(packet + c * ROW_SIZE, bytes_to_read,
- ROW_SIZE, 4, row, sizeof(row), false);
- dprintk(log_level, "%s\n", row);
- }
- }
- static int __dsp_suspend(struct iris_hfi_device *device, bool force)
- {
- int rc;
- if (msm_cvp_dsp_disable)
- return 0;
- dprintk(CVP_DSP, "%s: suspend dsp\n", __func__);
- rc = cvp_dsp_suspend(force);
- if (rc) {
- if (rc != -EBUSY)
- dprintk(CVP_ERR,
- "%s: dsp suspend failed with error %d\n",
- __func__, rc);
- return rc;
- }
- dprintk(CVP_DSP, "%s: dsp suspended\n", __func__);
- return 0;
- }
- static int __dsp_resume(struct iris_hfi_device *device)
- {
- int rc;
- if (msm_cvp_dsp_disable)
- return 0;
- dprintk(CVP_DSP, "%s: resume dsp\n", __func__);
- rc = cvp_dsp_resume();
- if (rc) {
- dprintk(CVP_ERR,
- "%s: dsp resume failed with error %d\n",
- __func__, rc);
- return rc;
- }
- dprintk(CVP_DSP, "%s: dsp resumed\n", __func__);
- return rc;
- }
- static int __dsp_shutdown(struct iris_hfi_device *device)
- {
- int rc;
- if (msm_cvp_dsp_disable)
- return 0;
- dprintk(CVP_DSP, "%s: shutdown dsp\n", __func__);
- rc = cvp_dsp_shutdown();
- if (rc) {
- dprintk(CVP_ERR,
- "%s: dsp shutdown failed with error %d\n",
- __func__, rc);
- WARN_ON(1);
- }
- dprintk(CVP_DSP, "%s: dsp shutdown successful\n", __func__);
- return rc;
- }
- static int __acquire_regulator(struct regulator_info *rinfo,
- struct iris_hfi_device *device)
- {
- int rc = 0;
- if (rinfo->has_hw_power_collapse) {
- /*Acquire XO_RESET to avoid race condition with video*/
- rc = call_iris_op(device, reset_control_acquire_name, device, "cvp_xo_reset");
- if (rc) {
- dprintk(CVP_ERR,
- "XO_RESET could not be acquired: skip acquiring the regulator %s from FW\n",
- rinfo->name);
- return -EINVAL;
- }
- rc = regulator_set_mode(rinfo->regulator,
- REGULATOR_MODE_NORMAL);
- if (rc) {
- /*
- * This is somewhat fatal, but nothing we can do
- * about it. We can't disable the regulator w/o
- * getting it back under s/w control
- */
- dprintk(CVP_WARN,
- "Failed to acquire regulator control: %s\n",
- rinfo->name);
- } else {
- dprintk(CVP_PWR,
- "Acquire regulator control from HW: %s\n",
- rinfo->name);
- }
- /*Release XO_RESET after regulator is enabled.*/
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- }
- if (!regulator_is_enabled(rinfo->regulator)) {
- dprintk(CVP_WARN, "Regulator is not enabled %s\n",
- rinfo->name);
- msm_cvp_res_handle_fatal_hw_error(device->res, true);
- }
- return rc;
- }
- static int __hand_off_regulator(struct iris_hfi_device *device, struct regulator_info *rinfo)
- {
- int rc = 0;
- if (rinfo->has_hw_power_collapse) {
- /*Acquire XO_RESET to avoid race condition with video*/
- rc = call_iris_op(device, reset_control_acquire_name, device, "cvp_xo_reset");
- if (rc) {
- dprintk(CVP_ERR,
- "XO_RESET could not be acquired: skip hand off the regulator %s to FW\n",
- rinfo->name);
- return -EINVAL;
- }
- rc = regulator_set_mode(rinfo->regulator,
- REGULATOR_MODE_FAST);
- /*Release XO_RESET after regulator is enabled.*/
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- if (rc) {
- dprintk(CVP_WARN,
- "Failed to hand off regulator control: %s\n",
- rinfo->name);
- } else {
- dprintk(CVP_PWR,
- "Hand off regulator control to HW: %s\n",
- rinfo->name);
- }
- }
- return rc;
- }
- static int __hand_off_regulators(struct iris_hfi_device *device)
- {
- struct regulator_info *rinfo;
- int rc = 0, c = 0;
- iris_hfi_for_each_regulator(device, rinfo) {
- rc = __hand_off_regulator(device, rinfo);
- /*
- * If one regulator hand off failed, driver should take
- * the control for other regulators back.
- */
- if (rc)
- goto err_reg_handoff_failed;
- c++;
- }
- return rc;
- err_reg_handoff_failed:
- iris_hfi_for_each_regulator_reverse_continue(device, rinfo, c)
- __acquire_regulator(rinfo, device);
- return rc;
- }
- static int __take_back_regulators(struct iris_hfi_device *device)
- {
- struct regulator_info *rinfo;
- int rc = 0;
- iris_hfi_for_each_regulator(device, rinfo) {
- rc = __acquire_regulator(rinfo, device);
- /*
- * if one regulator hand off failed, driver should take
- * the control for other regulators back.
- */
- if (rc)
- return rc;
- }
- return rc;
- }
- static int __write_queue(struct cvp_iface_q_info *qinfo, u8 *packet,
- bool *rx_req_is_set)
- {
- struct cvp_hfi_queue_header *queue;
- struct cvp_hfi_cmd_session_hdr *cmd_pkt;
- u32 packet_size_in_words, new_write_idx;
- u32 empty_space, read_idx, write_idx;
- u32 *write_ptr;
- if (!qinfo || !packet) {
- dprintk(CVP_ERR, "Invalid Params\n");
- return -EINVAL;
- } else if (!qinfo->q_array.align_virtual_addr) {
- dprintk(CVP_WARN, "Queues have already been freed\n");
- return -EINVAL;
- }
- queue = (struct cvp_hfi_queue_header *) qinfo->q_hdr;
- if (!queue) {
- dprintk(CVP_ERR, "queue not present\n");
- return -ENOENT;
- }
- cmd_pkt = (struct cvp_hfi_cmd_session_hdr *)packet;
- if (cmd_pkt->size >= sizeof(struct cvp_hfi_cmd_session_hdr))
- dprintk(CVP_CMD, "%s: pkt_type %08x sess_id %08x trans_id %u ktid %llu\n",
- __func__, cmd_pkt->packet_type,
- cmd_pkt->session_id,
- cmd_pkt->client_data.transaction_id,
- cmd_pkt->client_data.kdata & (FENCE_BIT - 1));
- else if (cmd_pkt->size >= 12)
- dprintk(CVP_CMD, "%s: pkt_type %08x sess_id %08x\n", __func__,
- cmd_pkt->packet_type, cmd_pkt->session_id);
- if (msm_cvp_debug & CVP_PKT) {
- dprintk(CVP_PKT, "%s: %pK\n", __func__, qinfo);
- __dump_packet(packet, CVP_PKT);
- }
- packet_size_in_words = (*(u32 *)packet) >> 2;
- if (!packet_size_in_words || packet_size_in_words >
- qinfo->q_array.mem_size>>2) {
- dprintk(CVP_ERR, "Invalid packet size\n");
- return -ENODATA;
- }
- spin_lock(&qinfo->hfi_lock);
- read_idx = queue->qhdr_read_idx;
- write_idx = queue->qhdr_write_idx;
- empty_space = (write_idx >= read_idx) ?
- ((qinfo->q_array.mem_size>>2) - (write_idx - read_idx)) :
- (read_idx - write_idx);
- if (empty_space <= packet_size_in_words) {
- queue->qhdr_tx_req = 1;
- spin_unlock(&qinfo->hfi_lock);
- dprintk(CVP_ERR, "Insufficient size (%d) to write (%d)\n",
- empty_space, packet_size_in_words);
- return -ENOTEMPTY;
- }
- queue->qhdr_tx_req = 0;
- new_write_idx = write_idx + packet_size_in_words;
- write_ptr = (u32 *)((qinfo->q_array.align_virtual_addr) +
- (write_idx << 2));
- if (write_ptr < (u32 *)qinfo->q_array.align_virtual_addr ||
- write_ptr > (u32 *)(qinfo->q_array.align_virtual_addr +
- qinfo->q_array.mem_size)) {
- spin_unlock(&qinfo->hfi_lock);
- dprintk(CVP_ERR, "Invalid write index\n");
- return -ENODATA;
- }
- if (new_write_idx < (qinfo->q_array.mem_size >> 2)) {
- memcpy(write_ptr, packet, packet_size_in_words << 2);
- } else {
- new_write_idx -= qinfo->q_array.mem_size >> 2;
- memcpy(write_ptr, packet, (packet_size_in_words -
- new_write_idx) << 2);
- memcpy((void *)qinfo->q_array.align_virtual_addr,
- packet + ((packet_size_in_words - new_write_idx) << 2),
- new_write_idx << 2);
- }
- /*
- * Memory barrier to make sure packet is written before updating the
- * write index
- */
- mb();
- queue->qhdr_write_idx = new_write_idx;
- if (rx_req_is_set)
- *rx_req_is_set = queue->qhdr_rx_req == 1;
- /*
- * Memory barrier to make sure write index is updated before an
- * interrupt is raised.
- */
- mb();
- spin_unlock(&qinfo->hfi_lock);
- return 0;
- }
- static int __read_queue(struct cvp_iface_q_info *qinfo, u8 *packet,
- u32 *pb_tx_req_is_set)
- {
- struct cvp_hfi_queue_header *queue;
- struct cvp_hfi_msg_session_hdr *msg_pkt;
- u32 packet_size_in_words, new_read_idx;
- u32 *read_ptr;
- u32 receive_request = 0;
- u32 read_idx, write_idx;
- int rc = 0;
- if (!qinfo || !packet || !pb_tx_req_is_set) {
- dprintk(CVP_ERR, "Invalid Params\n");
- return -EINVAL;
- } else if (!qinfo->q_array.align_virtual_addr) {
- dprintk(CVP_WARN, "Queues have already been freed\n");
- return -EINVAL;
- }
- /*
- * Memory barrier to make sure data is valid before
- *reading it
- */
- mb();
- queue = (struct cvp_hfi_queue_header *) qinfo->q_hdr;
- if (!queue) {
- dprintk(CVP_ERR, "Queue memory is not allocated\n");
- return -ENOMEM;
- }
- /*
- * Do not set receive request for debug queue, if set,
- * Iris generates interrupt for debug messages even
- * when there is no response message available.
- * In general debug queue will not become full as it
- * is being emptied out for every interrupt from Iris.
- * Iris will anyway generates interrupt if it is full.
- */
- spin_lock(&qinfo->hfi_lock);
- if (queue->qhdr_type & HFI_Q_ID_CTRL_TO_HOST_MSG_Q)
- receive_request = 1;
- read_idx = queue->qhdr_read_idx;
- write_idx = queue->qhdr_write_idx;
- if (read_idx == write_idx) {
- queue->qhdr_rx_req = receive_request;
- /*
- * mb() to ensure qhdr is updated in main memory
- * so that iris reads the updated header values
- */
- mb();
- *pb_tx_req_is_set = 0;
- if (write_idx != queue->qhdr_write_idx) {
- queue->qhdr_rx_req = 0;
- } else {
- spin_unlock(&qinfo->hfi_lock);
- dprintk(CVP_HFI,
- "%s queue is empty, rx_req = %u, tx_req = %u, read_idx = %u\n",
- receive_request ? "message" : "debug",
- queue->qhdr_rx_req, queue->qhdr_tx_req,
- queue->qhdr_read_idx);
- return -ENODATA;
- }
- }
- read_ptr = (u32 *)((qinfo->q_array.align_virtual_addr) +
- (read_idx << 2));
- if (read_ptr < (u32 *)qinfo->q_array.align_virtual_addr ||
- read_ptr > (u32 *)(qinfo->q_array.align_virtual_addr +
- qinfo->q_array.mem_size - sizeof(*read_ptr))) {
- spin_unlock(&qinfo->hfi_lock);
- dprintk(CVP_ERR, "Invalid read index\n");
- return -ENODATA;
- }
- packet_size_in_words = (*read_ptr) >> 2;
- if (!packet_size_in_words) {
- spin_unlock(&qinfo->hfi_lock);
- dprintk(CVP_ERR, "Zero packet size\n");
- return -ENODATA;
- }
- new_read_idx = read_idx + packet_size_in_words;
- if (((packet_size_in_words << 2) <= CVP_IFACEQ_VAR_HUGE_PKT_SIZE)
- && read_idx <= (qinfo->q_array.mem_size >> 2)) {
- if (new_read_idx < (qinfo->q_array.mem_size >> 2)) {
- memcpy(packet, read_ptr,
- packet_size_in_words << 2);
- } else {
- new_read_idx -= (qinfo->q_array.mem_size >> 2);
- memcpy(packet, read_ptr,
- (packet_size_in_words - new_read_idx) << 2);
- memcpy(packet + ((packet_size_in_words -
- new_read_idx) << 2),
- (u8 *)qinfo->q_array.align_virtual_addr,
- new_read_idx << 2);
- }
- } else {
- dprintk(CVP_WARN,
- "BAD packet received, read_idx: %#x, pkt_size: %d\n",
- read_idx, packet_size_in_words << 2);
- dprintk(CVP_WARN, "Dropping this packet\n");
- new_read_idx = write_idx;
- rc = -ENODATA;
- }
- if (new_read_idx != queue->qhdr_write_idx)
- queue->qhdr_rx_req = 0;
- else
- queue->qhdr_rx_req = receive_request;
- queue->qhdr_read_idx = new_read_idx;
- /*
- * mb() to ensure qhdr is updated in main memory
- * so that iris reads the updated header values
- */
- mb();
- *pb_tx_req_is_set = (queue->qhdr_tx_req == 1) ? 1 : 0;
- spin_unlock(&qinfo->hfi_lock);
- if (!(queue->qhdr_type & HFI_Q_ID_CTRL_TO_HOST_DEBUG_Q)) {
- msg_pkt = (struct cvp_hfi_msg_session_hdr *)packet;
- dprintk(CVP_CMD, "%s: "
- "pkt_type %08x sess_id %08x trans_id %u ktid %llu\n",
- __func__, msg_pkt->packet_type,
- msg_pkt->session_id,
- msg_pkt->client_data.transaction_id,
- msg_pkt->client_data.kdata & (FENCE_BIT - 1));
- }
- if ((msm_cvp_debug & CVP_PKT) &&
- !(queue->qhdr_type & HFI_Q_ID_CTRL_TO_HOST_DEBUG_Q)) {
- dprintk(CVP_PKT, "%s: %pK\n", __func__, qinfo);
- __dump_packet(packet, CVP_PKT);
- }
- return rc;
- }
- static int __smem_alloc(struct iris_hfi_device *dev, struct cvp_mem_addr *mem,
- u32 size, u32 align, u32 flags)
- {
- struct msm_cvp_smem *alloc = &mem->mem_data;
- int rc = 0;
- if (!dev || !mem || !size) {
- dprintk(CVP_ERR, "Invalid Params\n");
- return -EINVAL;
- }
- dprintk(CVP_INFO, "start to alloc size: %d, flags: %d\n", size, flags);
- alloc->flags = flags;
- rc = msm_cvp_smem_alloc(size, align, 1, (void *)dev->res, alloc);
- if (rc) {
- dprintk(CVP_ERR, "Alloc failed\n");
- rc = -ENOMEM;
- goto fail_smem_alloc;
- }
- dprintk(CVP_MEM, "%s: ptr = %pK, size = %d\n", __func__,
- alloc->kvaddr, size);
- mem->mem_size = alloc->size;
- mem->align_virtual_addr = alloc->kvaddr;
- mem->align_device_addr = alloc->device_addr;
- alloc->pkt_type = 0;
- alloc->buf_idx = 0;
- return rc;
- fail_smem_alloc:
- return rc;
- }
- static void __smem_free(struct iris_hfi_device *dev, struct msm_cvp_smem *mem)
- {
- if (!dev || !mem) {
- dprintk(CVP_ERR, "invalid param %pK %pK\n", dev, mem);
- return;
- }
- msm_cvp_smem_free(mem);
- }
- static void __write_register(struct iris_hfi_device *device,
- u32 reg, u32 value)
- {
- u32 hwiosymaddr = reg;
- u8 *base_addr;
- if (!device) {
- dprintk(CVP_ERR, "Invalid params: %pK\n", device);
- return;
- }
- __strict_check(device);
- if (!device->power_enabled) {
- dprintk(CVP_WARN,
- "HFI Write register failed : Power is OFF\n");
- msm_cvp_res_handle_fatal_hw_error(device->res, true);
- return;
- }
- base_addr = device->cvp_hal_data->register_base;
- dprintk(CVP_REG, "Base addr: %pK, written to: %#x, Value: %#x...\n",
- base_addr, hwiosymaddr, value);
- base_addr += hwiosymaddr;
- writel_relaxed(value, base_addr);
- /*
- * Memory barrier to make sure value is written into the register.
- */
- wmb();
- }
- static int __read_gcc_register(struct iris_hfi_device *device, u32 reg)
- {
- int rc = 0;
- u8 *base_addr;
- if (!device) {
- dprintk(CVP_ERR, "Invalid params: %pK\n", device);
- return -EINVAL;
- }
- __strict_check(device);
- if (!device->power_enabled) {
- dprintk(CVP_WARN,
- "%s HFI Read register failed : Power is OFF\n",
- __func__);
- msm_cvp_res_handle_fatal_hw_error(device->res, true);
- return -EINVAL;
- }
- base_addr = device->cvp_hal_data->gcc_reg_base;
- rc = readl_relaxed(base_addr + reg);
- /*
- * Memory barrier to make sure value is read correctly from the
- * register.
- */
- rmb();
- dprintk(CVP_REG,
- "GCC Base addr: %pK, read from: %#x, value: %#x...\n",
- base_addr, reg, rc);
- return rc;
- }
- static int __read_register(struct iris_hfi_device *device, u32 reg)
- {
- int rc = 0;
- u8 *base_addr;
- if (!device) {
- dprintk(CVP_ERR, "Invalid params: %pK\n", device);
- return -EINVAL;
- }
- __strict_check(device);
- if (!device->power_enabled) {
- dprintk(CVP_WARN,
- "HFI Read register failed : Power is OFF\n");
- msm_cvp_res_handle_fatal_hw_error(device->res, true);
- return -EINVAL;
- }
- base_addr = device->cvp_hal_data->register_base;
- rc = readl_relaxed(base_addr + reg);
- /*
- * Memory barrier to make sure value is read correctly from the
- * register.
- */
- rmb();
- dprintk(CVP_REG, "Base addr: %pK, read from: %#x, value: %#x...\n",
- base_addr, reg, rc);
- return rc;
- }
- static bool __is_ctl_power_on(struct iris_hfi_device *device)
- {
- u32 reg;
- reg = __read_register(device, CVP_CC_MVS1C_GDSCR);
- if (!(reg & 0x80000000))
- return false;
- reg = __read_register(device, CVP_CC_MVS1C_CBCR);
- if (reg & 0x80000000)
- return false;
- return true;
- }
- static int __set_registers(struct iris_hfi_device *device)
- {
- struct msm_cvp_core *core;
- struct msm_cvp_platform_data *pdata;
- struct reg_set *reg_set;
- int i;
- if (!device->res) {
- dprintk(CVP_ERR,
- "device resources null, cannot set registers\n");
- return -EINVAL ;
- }
- core = cvp_driver->cvp_core;
- pdata = core->platform_data;
- reg_set = &device->res->reg_set;
- for (i = 0; i < reg_set->count; i++) {
- __write_register(device, reg_set->reg_tbl[i].reg,
- reg_set->reg_tbl[i].value);
- dprintk(CVP_REG, "write_reg offset=%x, val=%x\n",
- reg_set->reg_tbl[i].reg,
- reg_set->reg_tbl[i].value);
- }
- i = call_iris_op(device, reset_control_acquire_name, device, "cvp_xo_reset");
- if (i) {
- dprintk(CVP_WARN, "%s Fail acquire xo_reset\n", __func__);
- return -EINVAL;
- }
- __write_register(device, CVP_CPU_CS_AXI4_QOS,
- pdata->noc_qos->axi_qos);
- __write_register(device,
- CVP_NOC_RGE_PRIORITYLUT_LOW +
- device->res->qos_noc_rge_niu_offset,
- pdata->noc_qos->prioritylut_low);
- __write_register(device,
- CVP_NOC_RGE_PRIORITYLUT_HIGH +
- device->res->qos_noc_rge_niu_offset,
- pdata->noc_qos->prioritylut_high);
- __write_register(device,
- CVP_NOC_RGE_URGENCY_LOW +
- device->res->qos_noc_rge_niu_offset,
- pdata->noc_qos->urgency_low);
- __write_register(device,
- CVP_NOC_RGE_DANGERLUT_LOW +
- device->res->qos_noc_rge_niu_offset,
- pdata->noc_qos->dangerlut_low);
- __write_register(device,
- CVP_NOC_RGE_SAFELUT_LOW +
- device->res->qos_noc_rge_niu_offset,
- pdata->noc_qos->safelut_low);
- __write_register(device,
- CVP_NOC_GCE_PRIORITYLUT_LOW +
- device->res->qos_noc_gce_vadl_tof_niu_offset,
- pdata->noc_qos->prioritylut_low);
- __write_register(device,
- CVP_NOC_GCE_PRIORITYLUT_HIGH +
- device->res->qos_noc_gce_vadl_tof_niu_offset,
- pdata->noc_qos->prioritylut_high);
- __write_register(device,
- CVP_NOC_GCE_URGENCY_LOW +
- device->res->qos_noc_gce_vadl_tof_niu_offset,
- pdata->noc_qos->urgency_low);
- __write_register(device,
- CVP_NOC_GCE_DANGERLUT_LOW +
- device->res->qos_noc_gce_vadl_tof_niu_offset,
- pdata->noc_qos->dangerlut_low);
- __write_register(device,
- CVP_NOC_GCE_SAFELUT_LOW +
- device->res->qos_noc_gce_vadl_tof_niu_offset,
- pdata->noc_qos->safelut_low);
- __write_register(device,
- CVP_NOC_CDM_PRIORITYLUT_LOW +
- device->res->qos_noc_cdm_niu_offset,
- pdata->noc_qos->prioritylut_low);
- __write_register(device,
- CVP_NOC_CDM_PRIORITYLUT_HIGH +
- device->res->qos_noc_cdm_niu_offset,
- pdata->noc_qos->prioritylut_high);
- __write_register(device,
- CVP_NOC_CDM_URGENCY_LOW +
- device->res->qos_noc_cdm_niu_offset,
- pdata->noc_qos->urgency_low_ro);
- __write_register(device,
- CVP_NOC_CDM_DANGERLUT_LOW +
- device->res->qos_noc_cdm_niu_offset,
- pdata->noc_qos->dangerlut_low);
- __write_register(device,
- CVP_NOC_CDM_SAFELUT_LOW +
- device->res->qos_noc_cdm_niu_offset,
- pdata->noc_qos->safelut_low);
- /* Below registers write moved from FW to SW to enable UBWC */
- __write_register(device,
- CVP_NOC_RGE_NIU_DECCTL_LOW +
- device->res->qos_noc_rge_niu_offset,
- 0x1);
- __write_register(device,
- CVP_NOC_RGE_NIU_ENCCTL_LOW +
- device->res->qos_noc_rge_niu_offset,
- 0x1);
- __write_register(device,
- CVP_NOC_GCE_VADL_TOF_NIU_DECCTL_LOW +
- device->res->qos_noc_gce_vadl_tof_niu_offset,
- 0x1);
- __write_register(device,
- CVP_NOC_GCE_VADL_TOF_NIU_ENCCTL_LOW +
- device->res->qos_noc_gce_vadl_tof_niu_offset,
- 0x1);
- __write_register(device,
- CVP_NOC_CORE_ERR_MAINCTL_LOW_OFFS +
- device->res->noc_core_err_offset,
- 0x3);
- __write_register(device,
- CVP_NOC_MAIN_SIDEBANDMANAGER_FAULTINEN0_LOW +
- device->res->noc_main_sidebandmanager_offset,
- 0x1);
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- return 0;
- }
- /*
- * The existence of this function is a hack for 8996 (or certain Iris versions)
- * to overcome a hardware bug. Whenever the GDSCs momentarily power collapse
- * (after calling __hand_off_regulators()), the values of the threshold
- * registers (typically programmed by TZ) are incorrectly reset. As a result
- * reprogram these registers at certain agreed upon points.
- */
- static void __set_threshold_registers(struct iris_hfi_device *device)
- {
- u32 version = __read_register(device, CVP_WRAPPER_HW_VERSION);
- version &= ~GENMASK(15, 0);
- if (version != (0x3 << 28 | 0x43 << 16))
- return;
- if (__tzbsp_set_cvp_state(TZ_SUBSYS_STATE_RESTORE_THRESHOLD))
- dprintk(CVP_ERR, "Failed to restore threshold values\n");
- }
- static int __unvote_buses(struct iris_hfi_device *device)
- {
- int rc = 0;
- struct bus_info *bus = NULL;
- kfree(device->bus_vote.data);
- device->bus_vote.data = NULL;
- device->bus_vote.data_count = 0;
- iris_hfi_for_each_bus(device, bus) {
- rc = cvp_set_bw(bus, 0);
- if (rc) {
- dprintk(CVP_ERR,
- "%s: Failed unvoting bus\n", __func__);
- goto err_unknown_device;
- }
- }
- err_unknown_device:
- return rc;
- }
- static int __vote_buses(struct iris_hfi_device *device,
- struct cvp_bus_vote_data *data, int num_data)
- {
- int rc = 0;
- struct bus_info *bus = NULL;
- struct cvp_bus_vote_data *new_data = NULL;
- if (!num_data) {
- dprintk(CVP_PWR, "No vote data available\n");
- goto no_data_count;
- } else if (!data) {
- dprintk(CVP_ERR, "Invalid voting data\n");
- return -EINVAL;
- }
- new_data = kmemdup(data, num_data * sizeof(*new_data), GFP_KERNEL);
- if (!new_data) {
- dprintk(CVP_ERR, "Can't alloc memory to cache bus votes\n");
- rc = -ENOMEM;
- goto err_no_mem;
- }
- no_data_count:
- kfree(device->bus_vote.data);
- device->bus_vote.data = new_data;
- device->bus_vote.data_count = num_data;
- iris_hfi_for_each_bus(device, bus) {
- if (bus) {
- rc = cvp_set_bw(bus, bus->range[1]);
- if (rc)
- dprintk(CVP_ERR,
- "Failed voting bus %s to ab %u\n",
- bus->name, bus->range[1]*1000);
- }
- }
- err_no_mem:
- return rc;
- }
- static int iris_hfi_vote_buses(void *dev, struct bus_info *bus, unsigned long bw)
- {
- int rc = 0;
- struct iris_hfi_device *device = dev;
- if (!device)
- return -EINVAL;
- mutex_lock(&device->lock);
- rc = cvp_set_bw(bus, bw);
- mutex_unlock(&device->lock);
- return rc;
- }
- static int __core_set_resource(struct iris_hfi_device *device,
- struct cvp_resource_hdr *resource_hdr, void *resource_value)
- {
- struct cvp_hfi_cmd_sys_set_resource_packet *pkt;
- u8 packet[CVP_IFACEQ_VAR_SMALL_PKT_SIZE];
- int rc = 0;
- if (!device || !resource_hdr || !resource_value) {
- dprintk(CVP_ERR, "set_res: Invalid Params\n");
- return -EINVAL;
- }
- pkt = (struct cvp_hfi_cmd_sys_set_resource_packet *) packet;
- rc = call_hfi_pkt_op(device, sys_set_resource,
- pkt, resource_hdr, resource_value);
- if (rc) {
- dprintk(CVP_ERR, "set_res: failed to create packet\n");
- goto err_create_pkt;
- }
- rc = __iface_cmdq_write(device, pkt);
- if (rc)
- rc = -ENOTEMPTY;
- err_create_pkt:
- return rc;
- }
- static int __core_release_resource(struct iris_hfi_device *device,
- struct cvp_resource_hdr *resource_hdr)
- {
- struct cvp_hfi_cmd_sys_release_resource_packet *pkt;
- u8 packet[CVP_IFACEQ_VAR_SMALL_PKT_SIZE];
- int rc = 0;
- if (!device || !resource_hdr) {
- dprintk(CVP_ERR, "release_res: Invalid Params\n");
- return -EINVAL;
- }
- pkt = (struct cvp_hfi_cmd_sys_release_resource_packet *) packet;
- rc = call_hfi_pkt_op(device, sys_release_resource,
- pkt, resource_hdr);
- if (rc) {
- dprintk(CVP_ERR, "release_res: failed to create packet\n");
- goto err_create_pkt;
- }
- rc = __iface_cmdq_write(device, pkt);
- if (rc)
- rc = -ENOTEMPTY;
- err_create_pkt:
- return rc;
- }
- static int __tzbsp_set_cvp_state(enum tzbsp_subsys_state state)
- {
- int rc = 0;
- rc = qcom_scm_set_remote_state(state, TZBSP_CVP_PAS_ID);
- dprintk(CVP_CORE, "Set state %d, resp %d\n", state, rc);
- if (rc) {
- dprintk(CVP_ERR, "Failed qcom_scm_set_remote_state %d\n", rc);
- return rc;
- }
- return 0;
- }
- /*
- * Based on fal10_veto, X2RPMh, core_pwr_on and PWAitMode value, infer
- * value of xtss_sw_reset. xtss_sw_reset is a TZ register bit. Driver
- * cannot access it directly.
- *
- * In __boot_firmware() function, the caller of this function. It checks
- * "core_pwr_on" == false, basically core powered off. So this function
- * doesn't check core_pwr_on. Assume core_pwr_on = false.
- *
- * fal10_veto = VPU_CPU_CS_X2RPMh[2] |
- * ( ~VPU_CPU_CS_X2RPMh[1] & core_pwr_on ) |
- * ( ~VPU_CPU_CS_X2RPMh[0] & ~( xtss_sw_reset | PWaitMode ) ) ;
- */
- static inline void check_tensilica_in_reset(struct iris_hfi_device *device)
- {
- u32 X2RPMh, fal10_veto, wait_mode;
- X2RPMh = __read_register(device, CVP_CPU_CS_X2RPMh);
- X2RPMh = X2RPMh & 0x7;
- /* wait_mode = 1: Tensilica is in WFI mode (PWaitMode = true) */
- wait_mode = __read_register(device, CVP_WRAPPER_CPU_STATUS);
- wait_mode = wait_mode & 0x1;
- fal10_veto = __read_register(device, CVP_CPU_CS_X2RPMh_STATUS);
- fal10_veto = fal10_veto & 0x1;
- dprintk(CVP_WARN, "tensilica reset check %#x %#x %#x\n",
- X2RPMh, wait_mode, fal10_veto);
- }
- static const char boot_states[0x40][32] = {
- "NOT INIT",
- "RST_START",
- "INIT_MEMCTL",
- "INTENABLE_RST",
- "LITBASE_RST",
- "PREFETCH_EN",
- "MPU_INIT",
- "CTRL_INIT_READ",
- "MEMCTL_L1_FIX",
- "RESTORE_EXTRA_NW",
- "CORE_RESTORE",
- "COLD_BOOT",
- "DISABLE_CACHE",
- "BEFORE_MPU_C",
- "RET_MPU_C",
- "IN_MPU_C",
- "IN_MPU_DEFAULT",
- "IN_MPU_SYNX",
- "UCR_SIZE_FAIL",
- "UCR_ADDR_FAIL",
- "UCR1_SIZE_FAIL",
- "UCR1_ADDR_FAIL",
- "UCR_OVERLAPPED_UCR1",
- "UCR1_OVERLAPPED_UCR",
- "UCR_EQ_UCR1",
- "MPU_CHECK_DONE",
- "BEFORE_INT_LOCK",
- "AFTER_INT_LOCK",
- "BEFORE_INT_UNLOCK",
- "AFTER_INT_UNLOCK",
- "CALL_START",
- "MAIN_ENTRY",
- "VENUS_INIT_ENTRY",
- "VSYS_INIT_ENTRY",
- "BEFORE_XOS_CLK",
- "AFTER_XOS_CLK",
- "LOG_MUTEX_INIT",
- "CREATE_FRAMEWORK_ENTRY",
- "DTG_INIT",
- "IDLE_TASK_INIT",
- "VENUS_CORE_INIT",
- "HW_CORES_INIT",
- "RST_THREAD_INIT",
- "HOST_THREAD_INIT",
- "ALL_THREADS_INIT",
- "TASK_MEMPOOL",
- "SESSION_MUTEX",
- "SIGNALS_INIT",
- "RST_SIGNAL_INIT",
- "INTR_EN_HOST",
- "INTR_REG_HOST",
- "INTR_EN_DSP",
- "INTR_REG_DSP",
- "X2HSOFTINTEN",
- "H2XSOFTINTEN",
- "CPU2DSPINTEN",
- "DSP2CPUINT_SWRESET",
- "THREADS_START",
- "RST_THREAD_START",
- "HST_THREAD_START",
- "HST_THREAD_ENTRY"
- };
- static inline int __boot_firmware(struct iris_hfi_device *device)
- {
- int rc = 0, loop = 10;
- u32 ctrl_init_val = 0, ctrl_status = 0, count = 0, max_tries = 5000;
- u32 reg_gdsc;
- /*
- * Hand off control of regulators to h/w _after_ enabling clocks.
- * Note that the GDSC will turn off when switching from normal
- * (s/w triggered) to fast (HW triggered) unless the h/w vote is
- * present. Since Iris isn't up yet, the GDSC will be off briefly.
- */
- if (__enable_hw_power_collapse(device))
- dprintk(CVP_ERR, "Failed to enabled inter-frame PC\n");
- if (!msm_cvp_fw_low_power_mode)
- goto skip_core_power_check;
- while (loop) {
- reg_gdsc = __read_register(device, CVP_CC_MVS1_GDSCR);
- if (reg_gdsc & 0x80000000) {
- usleep_range(100, 200);
- loop--;
- } else {
- break;
- }
- }
- if (!loop)
- dprintk(CVP_ERR, "fail to power off CORE during resume\n");
- skip_core_power_check:
- ctrl_init_val = BIT(0);
- /* RUMI: CVP_CTRL_INIT in MPTest has bit 0 and 3 set */
- __write_register(device, CVP_CTRL_INIT, ctrl_init_val);
- while (!(ctrl_status & CVP_CTRL_INIT_STATUS__M) && count < max_tries) {
- ctrl_status = __read_register(device, CVP_CTRL_STATUS);
- if ((ctrl_status & CVP_CTRL_ERROR_STATUS__M) == 0x4) {
- dprintk(CVP_ERR, "invalid setting for UC_REGION\n");
- rc = -ENODATA;
- break;
- }
- /* Reduce to 50, 100 on silicon */
- usleep_range(50, 100);
- count++;
- }
- if (!(ctrl_status & CVP_CTRL_INIT_STATUS__M)) {
- ctrl_init_val = __read_register(device, CVP_CTRL_INIT);
- dprintk(CVP_ERR,
- "Failed to boot FW status: %x %x %s\n",
- ctrl_status, ctrl_init_val,
- boot_states[(ctrl_status >> 9) & 0x3f]);
- check_tensilica_in_reset(device);
- rc = -ENODEV;
- }
- /* Enable interrupt before sending commands to tensilica */
- __write_register(device, CVP_CPU_CS_H2XSOFTINTEN, 0x1);
- __write_register(device, CVP_CPU_CS_X2RPMh, 0x0);
- return rc;
- }
- static int iris_hfi_resume(void *dev)
- {
- int rc = 0;
- struct iris_hfi_device *device = (struct iris_hfi_device *) dev;
- if (!device) {
- dprintk(CVP_ERR, "%s invalid device\n", __func__);
- return -EINVAL;
- }
- dprintk(CVP_CORE, "Resuming Iris\n");
- mutex_lock(&device->lock);
- rc = __resume(device);
- mutex_unlock(&device->lock);
- return rc;
- }
- static int iris_hfi_suspend(void *dev)
- {
- int rc = 0;
- struct iris_hfi_device *device = (struct iris_hfi_device *) dev;
- if (!device) {
- dprintk(CVP_ERR, "%s invalid device\n", __func__);
- return -EINVAL;
- } else if (!device->res->sw_power_collapsible) {
- return -ENOTSUPP;
- }
- dprintk(CVP_CORE, "Suspending Iris\n");
- mutex_lock(&device->lock);
- rc = __power_collapse(device, true);
- if (rc) {
- dprintk(CVP_WARN, "%s: Iris is busy\n", __func__);
- rc = -EBUSY;
- }
- mutex_unlock(&device->lock);
- /* Cancel pending delayed works if any */
- if (!rc)
- cancel_delayed_work(&iris_hfi_pm_work);
- return rc;
- }
- void cvp_dump_csr(struct iris_hfi_device *dev)
- {
- u32 reg;
- if (!dev)
- return;
- if (!dev->power_enabled || dev->reg_dumped)
- return;
- reg = __read_register(dev, CVP_WRAPPER_CPU_STATUS);
- dprintk(CVP_ERR, "CVP_WRAPPER_CPU_STATUS: %x\n", reg);
- reg = __read_register(dev, CVP_CPU_CS_SCIACMDARG0);
- dprintk(CVP_ERR, "CVP_CPU_CS_SCIACMDARG0: %x\n", reg);
- //reg = __read_register(dev, CVP_WRAPPER_INTR_STATUS);
- //dprintk(CVP_ERR, "CVP_WRAPPER_INTR_STATUS: %x\n", reg);
- //reg = __read_register(dev, CVP_CPU_CS_H2ASOFTINT);
- //dprintk(CVP_ERR, "CVP_CPU_CS_H2ASOFTINT: %x\n", reg);
- reg = __read_register(dev, CVP_CPU_CS_A2HSOFTINT);
- dprintk(CVP_ERR, "CVP_CPU_CS_A2HSOFTINT: %x\n", reg);
- reg = __read_register(dev, CVP_CC_MVS1C_GDSCR);
- dprintk(CVP_ERR, "CVP_CC_MVS1C_GDSCR: %x\n", reg);
- reg = __read_register(dev, CVP_CC_MVS1C_CBCR);
- dprintk(CVP_ERR, "CVP_CC_MVS1C_CBCR: %x\n", reg);
- reg = __read_register(dev, CVP_WRAPPER_CPU_CLOCK_CONFIG);
- dprintk(CVP_ERR, "CVP_WRAPPER_CPU_CLOCK_CONFIG: %x\n", reg);
- reg = __read_register(dev, CVP_WRAPPER_CORE_CLOCK_CONFIG);
- dprintk(CVP_ERR, "CVP_WRAPPER_CORE_CLOCK_CONFIG: %x\n", reg);
- dump_noc_reg(dev);
- dev->reg_dumped = true;
- }
- static int iris_hfi_flush_debug_queue(void *dev)
- {
- int rc = 0;
- struct iris_hfi_device *device = (struct iris_hfi_device *) dev;
- if (!device) {
- dprintk(CVP_ERR, "%s invalid device\n", __func__);
- return -EINVAL;
- }
- mutex_lock(&device->lock);
- if (!device->power_enabled) {
- dprintk(CVP_WARN, "%s: iris power off\n", __func__);
- rc = -EINVAL;
- goto exit;
- }
- cvp_dump_csr(device);
- __flush_debug_queue(device, NULL);
- exit:
- mutex_unlock(&device->lock);
- return rc;
- }
- static int iris_hfi_scale_clocks(void *dev, u32 freq)
- {
- int rc = 0;
- struct iris_hfi_device *device = dev;
- if (!device) {
- dprintk(CVP_ERR, "Invalid args: %pK\n", device);
- return -EINVAL;
- }
- mutex_lock(&device->lock);
- if (__resume(device)) {
- dprintk(CVP_ERR, "Resume from power collapse failed\n");
- rc = -ENODEV;
- goto exit;
- }
- rc = msm_cvp_set_clocks_impl(device, freq);
- exit:
- mutex_unlock(&device->lock);
- return rc;
- }
- /* Writes into cmdq without raising an interrupt */
- static int __iface_cmdq_write_relaxed(struct iris_hfi_device *device,
- void *pkt, bool *requires_interrupt)
- {
- struct cvp_iface_q_info *q_info;
- struct cvp_hal_cmd_pkt_hdr *cmd_packet;
- int result = -E2BIG;
- if (!device || !pkt) {
- dprintk(CVP_ERR, "Invalid Params\n");
- return -EINVAL;
- }
- __strict_check(device);
- if (!__core_in_valid_state(device)) {
- dprintk(CVP_ERR, "%s - fw not in init state\n", __func__);
- result = -EINVAL;
- goto err_q_null;
- }
- cmd_packet = (struct cvp_hal_cmd_pkt_hdr *)pkt;
- device->last_packet_type = cmd_packet->packet_type;
- q_info = &device->iface_queues[CVP_IFACEQ_CMDQ_IDX];
- if (!q_info) {
- dprintk(CVP_ERR, "cannot write to shared Q's\n");
- goto err_q_null;
- }
- if (!q_info->q_array.align_virtual_addr) {
- dprintk(CVP_ERR, "cannot write to shared CMD Q's\n");
- result = -ENODATA;
- goto err_q_null;
- }
- if (__resume(device)) {
- dprintk(CVP_ERR, "%s: Power on failed\n", __func__);
- goto err_q_write;
- }
- if (!__write_queue(q_info, (u8 *)pkt, requires_interrupt)) {
- if (device->res->sw_power_collapsible) {
- cancel_delayed_work(&iris_hfi_pm_work);
- if (!queue_delayed_work(device->iris_pm_workq,
- &iris_hfi_pm_work,
- msecs_to_jiffies(
- device->res->msm_cvp_pwr_collapse_delay))) {
- dprintk(CVP_PWR,
- "PM work already scheduled\n");
- }
- }
- result = 0;
- } else {
- dprintk(CVP_ERR, "__iface_cmdq_write: queue full\n");
- }
- err_q_write:
- err_q_null:
- return result;
- }
- static int __iface_cmdq_write(struct iris_hfi_device *device, void *pkt)
- {
- bool needs_interrupt = false;
- int rc = __iface_cmdq_write_relaxed(device, pkt, &needs_interrupt);
- int i = 0;
- if (!rc && needs_interrupt) {
- /* Consumer of cmdq prefers that we raise an interrupt */
- rc = 0;
- if (!__is_ctl_power_on(device))
- dprintk(CVP_ERR, "%s power off, don't access reg\n", __func__);
- i = call_iris_op(device, reset_control_acquire_name, device, "cvp_xo_reset");
- if (i) {
- dprintk(CVP_WARN, "%s Fail acquire xo_reset at %d\n", __func__, __LINE__);
- return -EINVAL;
- }
- __write_register(device, CVP_CPU_CS_H2ASOFTINT, 1);
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- }
- return rc;
- }
- static int __iface_msgq_read(struct iris_hfi_device *device, void *pkt)
- {
- u32 tx_req_is_set = 0;
- int rc = 0;
- struct cvp_iface_q_info *q_info;
- int i = 0;
- if (!pkt) {
- dprintk(CVP_ERR, "Invalid Params\n");
- return -EINVAL;
- }
- __strict_check(device);
- if (!__core_in_valid_state(device)) {
- dprintk(CVP_WARN, "%s - fw not in init state\n", __func__);
- rc = -EINVAL;
- goto read_error_null;
- }
- q_info = &device->iface_queues[CVP_IFACEQ_MSGQ_IDX];
- if (q_info->q_array.align_virtual_addr == NULL) {
- dprintk(CVP_ERR, "cannot read from shared MSG Q's\n");
- rc = -ENODATA;
- goto read_error_null;
- }
- if (!__read_queue(q_info, (u8 *)pkt, &tx_req_is_set)) {
- if (tx_req_is_set) {
- if (!__is_ctl_power_on(device))
- dprintk(CVP_ERR, "%s power off, don't access reg\n", __func__);
- i = call_iris_op(device, reset_control_acquire_name, device,
- "cvp_xo_reset");
- if (i) {
- dprintk(CVP_WARN, "%s Fail acquire xo_reset at %d\n",
- __func__, __LINE__);
- return -EINVAL;
- }
- __write_register(device, CVP_CPU_CS_H2ASOFTINT, 1);
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- }
- rc = 0;
- } else
- rc = -ENODATA;
- read_error_null:
- return rc;
- }
- static int __iface_dbgq_read(struct iris_hfi_device *device, void *pkt)
- {
- u32 tx_req_is_set = 0;
- int rc = 0;
- struct cvp_iface_q_info *q_info;
- int i = 0;
- if (!pkt) {
- dprintk(CVP_ERR, "Invalid Params\n");
- return -EINVAL;
- }
- __strict_check(device);
- q_info = &device->iface_queues[CVP_IFACEQ_DBGQ_IDX];
- if (q_info->q_array.align_virtual_addr == NULL) {
- dprintk(CVP_ERR, "cannot read from shared DBG Q's\n");
- rc = -ENODATA;
- goto dbg_error_null;
- }
- if (!__read_queue(q_info, (u8 *)pkt, &tx_req_is_set)) {
- if (tx_req_is_set) {
- if (!__is_ctl_power_on(device))
- dprintk(CVP_ERR, "%s power off, don't access reg\n", __func__);
- i = call_iris_op(device, reset_control_acquire_name, device,
- "cvp_xo_reset");
- if (i) {
- dprintk(CVP_WARN, "%s Fail acquire xo_reset at %d\n",
- __func__, __LINE__);
- return -EINVAL;
- }
- __write_register(device, CVP_CPU_CS_H2ASOFTINT, 1);
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- }
- rc = 0;
- } else
- rc = -ENODATA;
- dbg_error_null:
- return rc;
- }
- static void __set_queue_hdr_defaults(struct cvp_hfi_queue_header *q_hdr)
- {
- q_hdr->qhdr_status = 0x1;
- q_hdr->qhdr_type = CVP_IFACEQ_DFLT_QHDR;
- q_hdr->qhdr_q_size = CVP_IFACEQ_QUEUE_SIZE / 4;
- q_hdr->qhdr_pkt_size = 0;
- q_hdr->qhdr_rx_wm = 0x1;
- q_hdr->qhdr_tx_wm = 0x1;
- q_hdr->qhdr_rx_req = 0x1;
- q_hdr->qhdr_tx_req = 0x0;
- q_hdr->qhdr_rx_irq_status = 0x0;
- q_hdr->qhdr_tx_irq_status = 0x0;
- q_hdr->qhdr_read_idx = 0x0;
- q_hdr->qhdr_write_idx = 0x0;
- }
- /*
- *Unused, keep for reference
- */
- /*
- static void __interface_dsp_queues_release(struct iris_hfi_device *device)
- {
- int i;
- struct msm_cvp_smem *mem_data = &device->dsp_iface_q_table.mem_data;
- struct context_bank_info *cb = mem_data->mapping_info.cb_info;
- if (!device->dsp_iface_q_table.align_virtual_addr) {
- dprintk(CVP_ERR, "%s: already released\n", __func__);
- return;
- }
- dma_unmap_single_attrs(cb->dev, mem_data->device_addr,
- mem_data->size, DMA_BIDIRECTIONAL, 0);
- dma_free_coherent(device->res->mem_cdsp.dev, mem_data->size,
- mem_data->kvaddr, mem_data->dma_handle);
- for (i = 0; i < CVP_IFACEQ_NUMQ; i++) {
- device->dsp_iface_queues[i].q_hdr = NULL;
- device->dsp_iface_queues[i].q_array.align_virtual_addr = NULL;
- device->dsp_iface_queues[i].q_array.align_device_addr = 0;
- }
- device->dsp_iface_q_table.align_virtual_addr = NULL;
- device->dsp_iface_q_table.align_device_addr = 0;
- }
- */
- static int __interface_dsp_queues_init(struct iris_hfi_device *dev)
- {
- int rc = 0;
- u32 i;
- struct cvp_iface_q_info *iface_q;
- int offset = 0;
- phys_addr_t fw_bias = 0;
- size_t q_size;
- struct msm_cvp_smem *mem_data;
- void *kvaddr;
- dma_addr_t dma_handle;
- dma_addr_t iova;
- struct context_bank_info *cb;
- q_size = ALIGN(QUEUE_SIZE, SZ_1M);
- mem_data = &dev->dsp_iface_q_table.mem_data;
- if (mem_data->kvaddr) {
- memset((void *)mem_data->kvaddr, 0, q_size);
- cvp_dsp_init_hfi_queue_hdr(dev);
- return 0;
- }
- /* Allocate dsp queues from CDSP device memory */
- kvaddr = dma_alloc_coherent(dev->res->mem_cdsp.dev, q_size,
- &dma_handle, GFP_KERNEL);
- if (IS_ERR_OR_NULL(kvaddr)) {
- dprintk(CVP_ERR, "%s: failed dma allocation\n", __func__);
- goto fail_dma_alloc;
- }
- cb = msm_cvp_smem_get_context_bank(dev->res, SMEM_CDSP);
- if (!cb) {
- dprintk(CVP_ERR,
- "%s: failed to get DSP context bank\n", __func__);
- goto fail_dma_map;
- }
- iova = dma_map_single_attrs(cb->dev, phys_to_virt(dma_handle),
- q_size, DMA_BIDIRECTIONAL, 0);
- if (dma_mapping_error(cb->dev, iova)) {
- dprintk(CVP_ERR, "%s: failed dma mapping\n", __func__);
- goto fail_dma_map;
- }
- dprintk(CVP_DSP,
- "%s: kvaddr %pK dma_handle %#llx iova %#llx size %zd\n",
- __func__, kvaddr, dma_handle, iova, q_size);
- memset(mem_data, 0, sizeof(struct msm_cvp_smem));
- mem_data->kvaddr = kvaddr;
- mem_data->device_addr = iova;
- mem_data->dma_handle = dma_handle;
- mem_data->size = q_size;
- mem_data->mapping_info.cb_info = cb;
- if (!is_iommu_present(dev->res))
- fw_bias = dev->cvp_hal_data->firmware_base;
- dev->dsp_iface_q_table.align_virtual_addr = kvaddr;
- dev->dsp_iface_q_table.align_device_addr = iova - fw_bias;
- dev->dsp_iface_q_table.mem_size = CVP_IFACEQ_TABLE_SIZE;
- offset = dev->dsp_iface_q_table.mem_size;
- for (i = 0; i < CVP_IFACEQ_NUMQ; i++) {
- iface_q = &dev->dsp_iface_queues[i];
- iface_q->q_array.align_device_addr = iova + offset - fw_bias;
- iface_q->q_array.align_virtual_addr = kvaddr + offset;
- iface_q->q_array.mem_size = CVP_IFACEQ_QUEUE_SIZE;
- offset += iface_q->q_array.mem_size;
- spin_lock_init(&iface_q->hfi_lock);
- }
- cvp_dsp_init_hfi_queue_hdr(dev);
- return rc;
- fail_dma_map:
- dma_free_coherent(dev->res->mem_cdsp.dev, q_size, kvaddr, dma_handle);
- fail_dma_alloc:
- return -ENOMEM;
- }
- static void __interface_queues_release(struct iris_hfi_device *device)
- {
- #ifdef CONFIG_EVA_TVM
- int i;
- struct cvp_hfi_mem_map_table *qdss;
- struct cvp_hfi_mem_map *mem_map;
- int num_entries = device->res->qdss_addr_set.count;
- unsigned long mem_map_table_base_addr;
- struct context_bank_info *cb;
- if (device->qdss.align_virtual_addr) {
- qdss = (struct cvp_hfi_mem_map_table *)
- device->qdss.align_virtual_addr;
- qdss->mem_map_num_entries = num_entries;
- mem_map_table_base_addr =
- device->qdss.align_device_addr +
- sizeof(struct cvp_hfi_mem_map_table);
- qdss->mem_map_table_base_addr =
- (u32)mem_map_table_base_addr;
- if ((unsigned long)qdss->mem_map_table_base_addr !=
- mem_map_table_base_addr) {
- dprintk(CVP_ERR,
- "Invalid mem_map_table_base_addr %#lx",
- mem_map_table_base_addr);
- }
- mem_map = (struct cvp_hfi_mem_map *)(qdss + 1);
- cb = msm_cvp_smem_get_context_bank(device->res, 0);
- for (i = 0; cb && i < num_entries; i++) {
- iommu_unmap(cb->domain,
- mem_map[i].virtual_addr,
- mem_map[i].size);
- }
- __smem_free(device, &device->qdss.mem_data);
- }
- __smem_free(device, &device->iface_q_table.mem_data);
- __smem_free(device, &device->sfr.mem_data);
- for (i = 0; i < CVP_IFACEQ_NUMQ; i++) {
- device->iface_queues[i].q_hdr = NULL;
- device->iface_queues[i].q_array.align_virtual_addr = NULL;
- device->iface_queues[i].q_array.align_device_addr = 0;
- }
- device->iface_q_table.align_virtual_addr = NULL;
- device->iface_q_table.align_device_addr = 0;
- device->qdss.align_virtual_addr = NULL;
- device->qdss.align_device_addr = 0;
- device->sfr.align_virtual_addr = NULL;
- device->sfr.align_device_addr = 0;
- device->mem_addr.align_virtual_addr = NULL;
- device->mem_addr.align_device_addr = 0;
- #endif
- }
- static int __get_qdss_iommu_virtual_addr(struct iris_hfi_device *dev,
- struct cvp_hfi_mem_map *mem_map,
- struct iommu_domain *domain)
- {
- int i;
- int rc = 0;
- dma_addr_t iova = QDSS_IOVA_START;
- int num_entries = dev->res->qdss_addr_set.count;
- struct addr_range *qdss_addr_tbl = dev->res->qdss_addr_set.addr_tbl;
- if (!num_entries)
- return -ENODATA;
- for (i = 0; i < num_entries; i++) {
- if (domain) {
- rc = iommu_map(domain, iova,
- qdss_addr_tbl[i].start,
- qdss_addr_tbl[i].size,
- IOMMU_READ | IOMMU_WRITE);
- if (rc) {
- dprintk(CVP_ERR,
- "IOMMU QDSS mapping failed for addr %#x\n",
- qdss_addr_tbl[i].start);
- rc = -ENOMEM;
- break;
- }
- } else {
- iova = qdss_addr_tbl[i].start;
- }
- mem_map[i].virtual_addr = (u32)iova;
- mem_map[i].physical_addr = qdss_addr_tbl[i].start;
- mem_map[i].size = qdss_addr_tbl[i].size;
- mem_map[i].attr = 0x0;
- iova += mem_map[i].size;
- }
- if (i < num_entries) {
- dprintk(CVP_ERR,
- "QDSS mapping failed, Freeing other entries %d\n", i);
- for (--i; domain && i >= 0; i--) {
- iommu_unmap(domain,
- mem_map[i].virtual_addr,
- mem_map[i].size);
- }
- }
- return rc;
- }
- static void __setup_ucregion_memory_map(struct iris_hfi_device *device)
- {
- __write_register(device, CVP_UC_REGION_ADDR,
- (u32)device->iface_q_table.align_device_addr);
- __write_register(device, CVP_UC_REGION_SIZE, SHARED_QSIZE);
- __write_register(device, CVP_QTBL_ADDR,
- (u32)device->iface_q_table.align_device_addr);
- __write_register(device, CVP_QTBL_INFO, 0x01);
- if (device->sfr.align_device_addr)
- __write_register(device, CVP_SFR_ADDR,
- (u32)device->sfr.align_device_addr);
- if (device->qdss.align_device_addr)
- __write_register(device, CVP_MMAP_ADDR,
- (u32)device->qdss.align_device_addr);
- call_iris_op(device, setup_dsp_uc_memmap, device);
- }
- static void __hfi_queue_init(struct iris_hfi_device *dev)
- {
- int i, offset = 0;
- struct cvp_hfi_queue_table_header *q_tbl_hdr;
- struct cvp_iface_q_info *iface_q;
- struct cvp_hfi_queue_header *q_hdr;
- if (!dev)
- return;
- offset += dev->iface_q_table.mem_size;
- for (i = 0; i < CVP_IFACEQ_NUMQ; i++) {
- iface_q = &dev->iface_queues[i];
- iface_q->q_array.align_device_addr =
- dev->iface_q_table.align_device_addr + offset;
- iface_q->q_array.align_virtual_addr =
- dev->iface_q_table.align_virtual_addr + offset;
- iface_q->q_array.mem_size = CVP_IFACEQ_QUEUE_SIZE;
- offset += iface_q->q_array.mem_size;
- iface_q->q_hdr = CVP_IFACEQ_GET_QHDR_START_ADDR(
- dev->iface_q_table.align_virtual_addr, i);
- __set_queue_hdr_defaults(iface_q->q_hdr);
- spin_lock_init(&iface_q->hfi_lock);
- }
- q_tbl_hdr = (struct cvp_hfi_queue_table_header *)
- dev->iface_q_table.align_virtual_addr;
- q_tbl_hdr->qtbl_version = 0;
- q_tbl_hdr->device_addr = (void *)dev;
- strlcpy(q_tbl_hdr->name, "msm_cvp", sizeof(q_tbl_hdr->name));
- q_tbl_hdr->qtbl_size = CVP_IFACEQ_TABLE_SIZE;
- q_tbl_hdr->qtbl_qhdr0_offset =
- sizeof(struct cvp_hfi_queue_table_header);
- q_tbl_hdr->qtbl_qhdr_size = sizeof(struct cvp_hfi_queue_header);
- q_tbl_hdr->qtbl_num_q = CVP_IFACEQ_NUMQ;
- q_tbl_hdr->qtbl_num_active_q = CVP_IFACEQ_NUMQ;
- iface_q = &dev->iface_queues[CVP_IFACEQ_CMDQ_IDX];
- q_hdr = iface_q->q_hdr;
- q_hdr->qhdr_start_addr = iface_q->q_array.align_device_addr;
- q_hdr->qhdr_type |= HFI_Q_ID_HOST_TO_CTRL_CMD_Q;
- iface_q = &dev->iface_queues[CVP_IFACEQ_MSGQ_IDX];
- q_hdr = iface_q->q_hdr;
- q_hdr->qhdr_start_addr = iface_q->q_array.align_device_addr;
- q_hdr->qhdr_type |= HFI_Q_ID_CTRL_TO_HOST_MSG_Q;
- iface_q = &dev->iface_queues[CVP_IFACEQ_DBGQ_IDX];
- q_hdr = iface_q->q_hdr;
- q_hdr->qhdr_start_addr = iface_q->q_array.align_device_addr;
- q_hdr->qhdr_type |= HFI_Q_ID_CTRL_TO_HOST_DEBUG_Q;
- /*
- * Set receive request to zero on debug queue as there is no
- * need of interrupt from cvp hardware for debug messages
- */
- q_hdr->qhdr_rx_req = 0;
- }
- static void __sfr_init(struct iris_hfi_device *dev)
- {
- struct cvp_hfi_sfr_struct *vsfr;
- if (!dev)
- return;
- vsfr = (struct cvp_hfi_sfr_struct *) dev->sfr.align_virtual_addr;
- if (vsfr)
- vsfr->bufSize = ALIGNED_SFR_SIZE;
- }
- static int __interface_queues_init(struct iris_hfi_device *dev)
- {
- int rc = 0;
- struct cvp_hfi_mem_map_table *qdss;
- struct cvp_hfi_mem_map *mem_map;
- struct cvp_mem_addr *mem_addr;
- int num_entries = dev->res->qdss_addr_set.count;
- phys_addr_t fw_bias = 0;
- size_t q_size;
- unsigned long mem_map_table_base_addr;
- struct context_bank_info *cb;
- q_size = SHARED_QSIZE - ALIGNED_SFR_SIZE - ALIGNED_QDSS_SIZE;
- mem_addr = &dev->mem_addr;
- if (!is_iommu_present(dev->res))
- fw_bias = dev->cvp_hal_data->firmware_base;
- if (dev->iface_q_table.align_virtual_addr) {
- memset((void *)dev->iface_q_table.align_virtual_addr,
- 0, q_size);
- goto hfi_queue_init;
- }
- rc = __smem_alloc(dev, mem_addr, q_size, 1, SMEM_UNCACHED);
- if (rc) {
- dprintk(CVP_ERR, "iface_q_table_alloc_fail\n");
- goto fail_alloc_queue;
- }
- dev->iface_q_table.align_virtual_addr = mem_addr->align_virtual_addr;
- dev->iface_q_table.align_device_addr = mem_addr->align_device_addr -
- fw_bias;
- dev->iface_q_table.mem_size = CVP_IFACEQ_TABLE_SIZE;
- dev->iface_q_table.mem_data = mem_addr->mem_data;
- hfi_queue_init:
- __hfi_queue_init(dev);
- if (dev->sfr.align_virtual_addr) {
- memset((void *)dev->sfr.align_virtual_addr,
- 0, ALIGNED_SFR_SIZE);
- goto sfr_init;
- }
- rc = __smem_alloc(dev, mem_addr, ALIGNED_SFR_SIZE, 1, SMEM_UNCACHED);
- if (rc) {
- dprintk(CVP_WARN, "sfr_alloc_fail: SFR not will work\n");
- dev->sfr.align_device_addr = 0;
- } else {
- dev->sfr.align_device_addr = mem_addr->align_device_addr -
- fw_bias;
- dev->sfr.align_virtual_addr = mem_addr->align_virtual_addr;
- dev->sfr.mem_size = ALIGNED_SFR_SIZE;
- dev->sfr.mem_data = mem_addr->mem_data;
- }
- sfr_init:
- __sfr_init(dev);
- if (dev->qdss.align_virtual_addr)
- goto dsp_hfi_queue_init;
- if ((msm_cvp_fw_debug_mode & HFI_DEBUG_MODE_QDSS) && num_entries) {
- rc = __smem_alloc(dev, mem_addr, ALIGNED_QDSS_SIZE, 1,
- SMEM_UNCACHED);
- if (rc) {
- dprintk(CVP_WARN,
- "qdss_alloc_fail: QDSS messages logging will not work\n");
- dev->qdss.align_device_addr = 0;
- } else {
- dev->qdss.align_device_addr =
- mem_addr->align_device_addr - fw_bias;
- dev->qdss.align_virtual_addr =
- mem_addr->align_virtual_addr;
- dev->qdss.mem_size = ALIGNED_QDSS_SIZE;
- dev->qdss.mem_data = mem_addr->mem_data;
- }
- }
- if (dev->qdss.align_virtual_addr) {
- qdss =
- (struct cvp_hfi_mem_map_table *)dev->qdss.align_virtual_addr;
- qdss->mem_map_num_entries = num_entries;
- mem_map_table_base_addr = dev->qdss.align_device_addr +
- sizeof(struct cvp_hfi_mem_map_table);
- qdss->mem_map_table_base_addr = mem_map_table_base_addr;
- mem_map = (struct cvp_hfi_mem_map *)(qdss + 1);
- cb = msm_cvp_smem_get_context_bank(dev->res, 0);
- if (!cb) {
- dprintk(CVP_ERR,
- "%s: failed to get context bank\n", __func__);
- return -EINVAL;
- }
- rc = __get_qdss_iommu_virtual_addr(dev, mem_map, cb->domain);
- if (rc) {
- dprintk(CVP_ERR,
- "IOMMU mapping failed, Freeing qdss memdata\n");
- __smem_free(dev, &dev->qdss.mem_data);
- dev->qdss.align_virtual_addr = NULL;
- dev->qdss.align_device_addr = 0;
- }
- }
- dsp_hfi_queue_init:
- rc = __interface_dsp_queues_init(dev);
- if (rc) {
- dprintk(CVP_ERR, "dsp_queues_init failed\n");
- goto fail_alloc_queue;
- }
- __setup_ucregion_memory_map(dev);
- return 0;
- fail_alloc_queue:
- return -ENOMEM;
- }
- static int __sys_set_debug(struct iris_hfi_device *device, u32 debug)
- {
- u8 packet[CVP_IFACEQ_VAR_SMALL_PKT_SIZE];
- int rc = 0;
- struct cvp_hfi_cmd_sys_set_property_packet *pkt =
- (struct cvp_hfi_cmd_sys_set_property_packet *) &packet;
- rc = call_hfi_pkt_op(device, sys_debug_config, pkt, debug);
- if (rc) {
- dprintk(CVP_WARN,
- "Debug mode setting to FW failed\n");
- return -ENOTEMPTY;
- }
- if (__iface_cmdq_write(device, pkt))
- return -ENOTEMPTY;
- return 0;
- }
- static int __sys_set_idle_indicator(struct iris_hfi_device *device,
- bool enable)
- {
- u8 packet[CVP_IFACEQ_VAR_SMALL_PKT_SIZE];
- int rc = 0;
- struct cvp_hfi_cmd_sys_set_property_packet *pkt =
- (struct cvp_hfi_cmd_sys_set_property_packet *) &packet;
- rc = call_hfi_pkt_op(device, sys_set_idle_indicator, pkt, enable);
- if (__iface_cmdq_write(device, pkt))
- return -ENOTEMPTY;
- return 0;
- }
- static int __sys_set_coverage(struct iris_hfi_device *device, u32 mode)
- {
- u8 packet[CVP_IFACEQ_VAR_SMALL_PKT_SIZE];
- int rc = 0;
- struct cvp_hfi_cmd_sys_set_property_packet *pkt =
- (struct cvp_hfi_cmd_sys_set_property_packet *) &packet;
- rc = call_hfi_pkt_op(device, sys_coverage_config,
- pkt, mode);
- if (rc) {
- dprintk(CVP_WARN,
- "Coverage mode setting to FW failed\n");
- return -ENOTEMPTY;
- }
- if (__iface_cmdq_write(device, pkt)) {
- dprintk(CVP_WARN, "Failed to send coverage pkt to f/w\n");
- return -ENOTEMPTY;
- }
- return 0;
- }
- static int __sys_set_power_control(struct iris_hfi_device *device,
- bool enable)
- {
- struct regulator_info *rinfo;
- bool supported = false;
- u8 packet[CVP_IFACEQ_VAR_SMALL_PKT_SIZE];
- struct cvp_hfi_cmd_sys_set_property_packet *pkt =
- (struct cvp_hfi_cmd_sys_set_property_packet *) &packet;
- iris_hfi_for_each_regulator(device, rinfo) {
- if (rinfo->has_hw_power_collapse) {
- supported = true;
- break;
- }
- }
- if (!supported)
- return 0;
- call_hfi_pkt_op(device, sys_power_control, pkt, enable);
- if (__iface_cmdq_write(device, pkt))
- return -ENOTEMPTY;
- return 0;
- }
- static void cvp_pm_qos_update(struct iris_hfi_device *device, bool vote_on)
- {
- u32 latency, off_vote_cnt;
- int i, err = 0;
- spin_lock(&device->res->pm_qos.lock);
- off_vote_cnt = device->res->pm_qos.off_vote_cnt;
- spin_unlock(&device->res->pm_qos.lock);
- if (vote_on && off_vote_cnt)
- return;
- latency = vote_on ? device->res->pm_qos.latency_us :
- PM_QOS_RESUME_LATENCY_DEFAULT_VALUE;
- if (device->res->pm_qos.latency_us && device->res->pm_qos.pm_qos_hdls)
- for (i = 0; i < device->res->pm_qos.silver_count; i++) {
- if (!cpu_possible(device->res->pm_qos.silver_cores[i]))
- continue;
- err = dev_pm_qos_update_request(
- &device->res->pm_qos.pm_qos_hdls[i],
- latency);
- if (err < 0) {
- if (vote_on) {
- dprintk(CVP_WARN,
- "pm qos on failed %d\n", err);
- } else {
- dprintk(CVP_WARN,
- "pm qos off failed %d\n", err);
- }
- }
- }
- }
- static int iris_pm_qos_update(void *device)
- {
- struct iris_hfi_device *dev;
- if (!device) {
- dprintk(CVP_ERR, "%s Invalid device\n", __func__);
- return -ENODEV;
- }
- dev = device;
- mutex_lock(&dev->lock);
- cvp_pm_qos_update(dev, true);
- mutex_unlock(&dev->lock);
- return 0;
- }
- static int __hwfence_regs_map(struct iris_hfi_device *device)
- {
- int rc = 0;
- struct context_bank_info *cb;
- cb = msm_cvp_smem_get_context_bank(device->res, 0);
- if (!cb) {
- dprintk(CVP_ERR, "%s: fail to get cb\n", __func__);
- return -EINVAL;
- }
- if (device->res->reg_mappings.ipclite_phyaddr != 0) {
- rc = iommu_map(cb->domain,
- device->res->reg_mappings.ipclite_iova,
- device->res->reg_mappings.ipclite_phyaddr,
- device->res->reg_mappings.ipclite_size,
- IOMMU_READ | IOMMU_WRITE);
- if (rc) {
- dprintk(CVP_ERR, "map ipclite fail %d %#x %#x %#x\n",
- rc, device->res->reg_mappings.ipclite_iova,
- device->res->reg_mappings.ipclite_phyaddr,
- device->res->reg_mappings.ipclite_size);
- return rc;
- }
- }
- if (device->res->reg_mappings.hwmutex_phyaddr != 0) {
- rc = iommu_map(cb->domain,
- device->res->reg_mappings.hwmutex_iova,
- device->res->reg_mappings.hwmutex_phyaddr,
- device->res->reg_mappings.hwmutex_size,
- IOMMU_MMIO | IOMMU_READ | IOMMU_WRITE);
- if (rc) {
- dprintk(CVP_ERR, "map hwmutex fail %d %#x %#x %#x\n",
- rc, device->res->reg_mappings.hwmutex_iova,
- device->res->reg_mappings.hwmutex_phyaddr,
- device->res->reg_mappings.hwmutex_size);
- return rc;
- }
- }
- if (device->res->reg_mappings.aon_phyaddr != 0) {
- rc = iommu_map(cb->domain,
- device->res->reg_mappings.aon_iova,
- device->res->reg_mappings.aon_phyaddr,
- device->res->reg_mappings.aon_size,
- IOMMU_MMIO | IOMMU_READ | IOMMU_WRITE);
- if (rc) {
- dprintk(CVP_ERR, "map aon fail %d %#x %#x %#x\n",
- rc, device->res->reg_mappings.aon_iova,
- device->res->reg_mappings.aon_phyaddr,
- device->res->reg_mappings.aon_size);
- return rc;
- }
- }
- if (device->res->reg_mappings.timer_phyaddr != 0) {
- rc = iommu_map(cb->domain,
- device->res->reg_mappings.timer_iova,
- device->res->reg_mappings.timer_phyaddr,
- device->res->reg_mappings.timer_size,
- IOMMU_MMIO | IOMMU_READ | IOMMU_WRITE);
- if (rc) {
- dprintk(CVP_ERR, "map timer fail %d %#x %#x %#x\n",
- rc, device->res->reg_mappings.timer_iova,
- device->res->reg_mappings.timer_phyaddr,
- device->res->reg_mappings.timer_size);
- return rc;
- }
- }
- return rc;
- }
- static int __hwfence_regs_unmap(struct iris_hfi_device *device)
- {
- int rc = 0;
- struct context_bank_info *cb;
- cb = msm_cvp_smem_get_context_bank(device->res, 0);
- if (!cb) {
- dprintk(CVP_ERR, "%s: fail to get cb\n", __func__);
- return -EINVAL;
- }
- if (device->res->reg_mappings.ipclite_iova != 0) {
- iommu_unmap(cb->domain,
- device->res->reg_mappings.ipclite_iova,
- device->res->reg_mappings.ipclite_size);
- }
- if (device->res->reg_mappings.hwmutex_iova != 0) {
- iommu_unmap(cb->domain,
- device->res->reg_mappings.hwmutex_iova,
- device->res->reg_mappings.hwmutex_size);
- }
- if (device->res->reg_mappings.aon_iova != 0) {
- iommu_unmap(cb->domain,
- device->res->reg_mappings.aon_iova,
- device->res->reg_mappings.aon_size);
- }
- if (device->res->reg_mappings.timer_iova != 0) {
- iommu_unmap(cb->domain,
- device->res->reg_mappings.timer_iova,
- device->res->reg_mappings.timer_size);
- }
- return rc;
- }
- static int iris_hfi_core_init(void *device)
- {
- int rc = 0;
- u32 ipcc_iova;
- struct cvp_hfi_cmd_sys_init_packet pkt;
- struct cvp_hfi_cmd_sys_get_property_packet version_pkt;
- struct iris_hfi_device *dev;
- if (!device) {
- dprintk(CVP_ERR, "Invalid device\n");
- return -ENODEV;
- }
- dev = device;
- dprintk(CVP_CORE, "Core initializing\n");
- pm_stay_awake(dev->res->pdev->dev.parent);
- mutex_lock(&dev->lock);
- dev->bus_vote.data =
- kzalloc(sizeof(struct cvp_bus_vote_data), GFP_KERNEL);
- if (!dev->bus_vote.data) {
- dprintk(CVP_ERR, "Bus vote data memory is not allocated\n");
- rc = -ENOMEM;
- goto err_no_mem;
- }
- dev->bus_vote.data_count = 1;
- dev->bus_vote.data->power_mode = CVP_POWER_TURBO;
- __hwfence_regs_map(dev);
- rc = __power_on_init(dev);
- if (rc) {
- dprintk(CVP_ERR, "Failed to power on init EVA\n");
- goto err_load_fw;
- }
- rc = cvp_synx_recover();
- if (rc) {
- dprintk(CVP_ERR, "Failed to recover synx\n");
- goto err_core_init;
- }
- /* mmrm registration */
- if (msm_cvp_mmrm_enabled) {
- rc = msm_cvp_mmrm_register(device);
- if (rc) {
- dprintk(CVP_ERR, "Failed to register mmrm client\n");
- goto err_core_init;
- }
- }
- __set_state(dev, IRIS_STATE_INIT);
- dev->reg_dumped = false;
- dprintk(CVP_CORE, "Dev_Virt: %pa, Reg_Virt: %pK\n",
- &dev->cvp_hal_data->firmware_base,
- dev->cvp_hal_data->register_base);
- rc = __interface_queues_init(dev);
- if (rc) {
- dprintk(CVP_ERR, "failed to init queues\n");
- rc = -ENOMEM;
- goto err_core_init;
- }
- cvp_register_va_md_region();
- // Add node for dev struct
- add_va_node_to_list(CVP_QUEUE_DUMP, dev,
- sizeof(struct iris_hfi_device),
- "iris_hfi_device-dev", false);
- add_queue_header_to_va_md_list((void*)dev);
- add_hfi_queue_to_va_md_list((void*)dev);
- rc = msm_cvp_map_ipcc_regs(&ipcc_iova);
- if (!rc) {
- dprintk(CVP_CORE, "IPCC iova 0x%x\n", ipcc_iova);
- __write_register(dev, CVP_MMAP_ADDR, ipcc_iova);
- }
- rc = __load_fw(dev);
- if (rc) {
- dprintk(CVP_ERR, "Failed to load Iris FW\n");
- goto err_core_init;
- }
- rc = __boot_firmware(dev);
- if (rc) {
- dprintk(CVP_ERR, "Failed to start core\n");
- rc = -ENODEV;
- goto err_core_init;
- }
- dev->version = __read_register(dev, CVP_VERSION_INFO);
- rc = call_hfi_pkt_op(dev, sys_init, &pkt, 0);
- if (rc) {
- dprintk(CVP_ERR, "Failed to create sys init pkt\n");
- goto err_core_init;
- }
- if (__iface_cmdq_write(dev, &pkt)) {
- rc = -ENOTEMPTY;
- goto err_core_init;
- }
- rc = call_hfi_pkt_op(dev, sys_image_version, &version_pkt);
- if (rc || __iface_cmdq_write(dev, &version_pkt))
- dprintk(CVP_WARN, "Failed to send image version pkt to f/w\n");
- __sys_set_debug(device, msm_cvp_fw_debug);
- __enable_subcaches(device);
- __set_subcaches(device);
- __set_ubwc_config(device);
- __sys_set_idle_indicator(device, true);
- if (dev->res->pm_qos.latency_us) {
- int err = 0;
- u32 i, cpu;
- dev->res->pm_qos.pm_qos_hdls = kcalloc(
- dev->res->pm_qos.silver_count,
- sizeof(struct dev_pm_qos_request),
- GFP_KERNEL);
- if (!dev->res->pm_qos.pm_qos_hdls) {
- dprintk(CVP_WARN, "Failed allocate pm_qos_hdls\n");
- goto pm_qos_bail;
- }
- for (i = 0; i < dev->res->pm_qos.silver_count; i++) {
- cpu = dev->res->pm_qos.silver_cores[i];
- if (!cpu_possible(cpu))
- continue;
- err = dev_pm_qos_add_request(
- get_cpu_device(cpu),
- &dev->res->pm_qos.pm_qos_hdls[i],
- DEV_PM_QOS_RESUME_LATENCY,
- dev->res->pm_qos.latency_us);
- if (err < 0)
- dprintk(CVP_WARN,
- "%s pm_qos_add_req %d failed\n",
- __func__, i);
- }
- }
- pm_qos_bail:
- mutex_unlock(&dev->lock);
- cvp_dsp_send_hfi_queue();
- pm_relax(dev->res->pdev->dev.parent);
- dprintk(CVP_CORE, "Core inited successfully\n");
- return 0;
- err_core_init:
- __set_state(dev, IRIS_STATE_DEINIT);
- __unload_fw(dev);
- if (dev->mmrm_cvp)
- {
- msm_cvp_mmrm_deregister(dev);
- }
- err_load_fw:
- __hwfence_regs_unmap(dev);
- err_no_mem:
- dprintk(CVP_ERR, "Core init failed\n");
- mutex_unlock(&dev->lock);
- pm_relax(dev->res->pdev->dev.parent);
- return rc;
- }
- static int iris_hfi_core_release(void *dev)
- {
- int rc = 0, i;
- struct iris_hfi_device *device = dev;
- struct cvp_hal_session *session, *next;
- struct dev_pm_qos_request *qos_hdl;
- u32 ipcc_iova;
- if (!device) {
- dprintk(CVP_ERR, "invalid device\n");
- return -ENODEV;
- }
- mutex_lock(&device->lock);
- dprintk(CVP_WARN, "Core releasing\n");
- if (device->res->pm_qos.latency_us &&
- device->res->pm_qos.pm_qos_hdls) {
- for (i = 0; i < device->res->pm_qos.silver_count; i++) {
- if (!cpu_possible(device->res->pm_qos.silver_cores[i]))
- continue;
- qos_hdl = &device->res->pm_qos.pm_qos_hdls[i];
- if ((qos_hdl != NULL) && dev_pm_qos_request_active(qos_hdl))
- dev_pm_qos_remove_request(qos_hdl);
- }
- kfree(device->res->pm_qos.pm_qos_hdls);
- device->res->pm_qos.pm_qos_hdls = NULL;
- }
- __resume(device);
- __set_state(device, IRIS_STATE_DEINIT);
- rc = __tzbsp_set_cvp_state(TZ_SUBSYS_STATE_SUSPEND);
- if (rc)
- dprintk(CVP_WARN, "Failed to suspend cvp FW%d\n", rc);
- __dsp_shutdown(device);
- __disable_subcaches(device);
- ipcc_iova = __read_register(device, CVP_MMAP_ADDR);
- msm_cvp_unmap_ipcc_regs(ipcc_iova);
- __unload_fw(device);
- __hwfence_regs_unmap(device);
- if (msm_cvp_mmrm_enabled) {
- rc = msm_cvp_mmrm_deregister(device);
- if (rc) {
- dprintk(CVP_ERR,
- "%s: Failed msm_cvp_mmrm_deregister:%d\n",
- __func__, rc);
- }
- }
- /* unlink all sessions from device */
- list_for_each_entry_safe(session, next, &device->sess_head, list) {
- list_del(&session->list);
- session->device = NULL;
- }
- dprintk(CVP_CORE, "Core released successfully\n");
- mutex_unlock(&device->lock);
- return rc;
- }
- static void __core_clear_interrupt(struct iris_hfi_device *device)
- {
- u32 intr_status = 0, mask = 0;
- int i = 0;
- if (!device) {
- dprintk(CVP_ERR, "%s: NULL device\n", __func__);
- return;
- }
- i = call_iris_op(device, reset_control_acquire_name, device, "cvp_xo_reset");
- if (i) {
- dprintk(CVP_WARN, "%s Fail acquire xo_reset at %d\n", __func__, __LINE__);
- return;
- }
- intr_status = __read_register(device, CVP_WRAPPER_INTR_STATUS);
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- mask = (CVP_WRAPPER_INTR_MASK_A2HCPU_BMSK | CVP_FATAL_INTR_BMSK);
- if (intr_status & mask) {
- device->intr_status |= intr_status;
- device->reg_count++;
- dprintk(CVP_CORE,
- "INTERRUPT for device: %pK: times: %d status: %d\n",
- device, device->reg_count, intr_status);
- } else {
- device->spur_count++;
- }
- __write_register(device, CVP_CPU_CS_A2HSOFTINTCLR, 1);
- }
- static int iris_hfi_core_trigger_ssr(void *device,
- enum hal_ssr_trigger_type type)
- {
- struct cvp_hfi_cmd_sys_test_ssr_packet pkt;
- int rc = 0;
- struct iris_hfi_device *dev;
- cvp_free_va_md_list();
- if (!device) {
- dprintk(CVP_ERR, "invalid device\n");
- return -ENODEV;
- }
- dev = device;
- if (mutex_trylock(&dev->lock)) {
- rc = call_hfi_pkt_op(dev, ssr_cmd, type, &pkt);
- if (rc) {
- dprintk(CVP_ERR, "%s: failed to create packet\n",
- __func__);
- goto err_create_pkt;
- }
- if (__iface_cmdq_write(dev, &pkt))
- rc = -ENOTEMPTY;
- } else {
- return -EAGAIN;
- }
- err_create_pkt:
- mutex_unlock(&dev->lock);
- return rc;
- }
- static void __set_default_sys_properties(struct iris_hfi_device *device)
- {
- if (__sys_set_debug(device, msm_cvp_fw_debug))
- dprintk(CVP_WARN, "Setting fw_debug msg ON failed\n");
- if (__sys_set_power_control(device, msm_cvp_fw_low_power_mode))
- dprintk(CVP_WARN, "Setting h/w power collapse ON failed\n");
- }
- static void __session_clean(struct cvp_hal_session *session)
- {
- struct cvp_hal_session *temp, *next;
- struct iris_hfi_device *device;
- if (!session || !session->device) {
- dprintk(CVP_WARN, "%s: invalid params\n", __func__);
- return;
- }
- device = session->device;
- dprintk(CVP_SESS, "deleted the session: %pK\n", session);
- /*
- * session might have been removed from the device list in
- * core_release, so check and remove if it is in the list
- */
- list_for_each_entry_safe(temp, next, &device->sess_head, list) {
- if (session == temp) {
- list_del(&session->list);
- break;
- }
- }
- /* Poison the session handle with zeros */
- *session = (struct cvp_hal_session){ {0} };
- kfree(session);
- }
- static int iris_hfi_session_clean(void *session)
- {
- struct cvp_hal_session *sess_close;
- struct iris_hfi_device *device;
- if (!session || session == (void *)0xdeadbeef) {
- dprintk(CVP_ERR, "Invalid Params %s\n", __func__);
- return -EINVAL;
- }
- sess_close = session;
- device = sess_close->device;
- if (!device) {
- dprintk(CVP_ERR, "Invalid device handle %s\n", __func__);
- return -EINVAL;
- }
- mutex_lock(&device->lock);
- __session_clean(sess_close);
- mutex_unlock(&device->lock);
- return 0;
- }
- static int iris_debug_hook(void *device)
- {
- struct iris_hfi_device *dev = device;
- u32 val;
- if (!device) {
- dprintk(CVP_ERR, "%s Invalid device\n", __func__);
- return -ENODEV;
- }
- //__write_register(dev, CVP_WRAPPER_CORE_CLOCK_CONFIG, 0x11);
- //__write_register(dev, CVP_WRAPPER_TZ_CPU_CLOCK_CONFIG, 0x1);
- dprintk(CVP_ERR, "Halt Tensilica and core and axi\n");
- return 0;
- /******* FDU & MPU *****/
- #define CVP0_CVP_SS_FDU_SECURE_ENABLE 0x90
- #define CVP0_CVP_SS_MPU_SECURE_ENABLE 0x94
- #define CVP0_CVP_SS_ARP_THREAD_0_SECURE_ENABLE 0xA0
- #define CVP0_CVP_SS_ARP_THREAD_1_SECURE_ENABLE 0xA4
- #define CVP0_CVP_SS_ARP_THREAD_2_SECURE_ENABLE 0xA8
- #define CVP0_CVP_SS_ARP_THREAD_3_SECURE_ENABLE 0xAC
- val = __read_register(dev, CVP0_CVP_SS_FDU_SECURE_ENABLE);
- dprintk(CVP_ERR, "FDU_SECURE_ENABLE %#x\n", val);
- val = __read_register(dev, CVP0_CVP_SS_MPU_SECURE_ENABLE);
- dprintk(CVP_ERR, "MPU_SECURE_ENABLE %#x\n", val);
- val = __read_register(dev, CVP0_CVP_SS_ARP_THREAD_0_SECURE_ENABLE);
- dprintk(CVP_ERR, "ARP_THREAD_0_SECURE_ENABLE %#x\n", val);
- val = __read_register(dev, CVP0_CVP_SS_ARP_THREAD_1_SECURE_ENABLE);
- dprintk(CVP_ERR, "ARP_THREAD_1_SECURE_ENABLE %#x\n", val);
- val = __read_register(dev, CVP0_CVP_SS_ARP_THREAD_2_SECURE_ENABLE);
- dprintk(CVP_ERR, "ARP_THREAD_2_SECURE_ENABLE %#x\n", val);
- val = __read_register(dev, CVP0_CVP_SS_ARP_THREAD_3_SECURE_ENABLE);
- dprintk(CVP_ERR, "ARP_THREAD_3_SECURE_ENABLE %#x\n", val);
- if (true)
- return 0;
- /***** GCE *******
- * Bit 0 of below register is CDM secure enable for GCE
- * CDM buffer will be in CB4 if set
- */
- #define CVP_GCE_GCE_SS_CP_CTL 0x51100
- /* STATUS bit0 && CFG bit 4 of below register set,
- * expect pixel buffers in CB3,
- * otherwise in CB0
- * CFG bit 9:8 b01 -> LMC input in CB3
- * CFG bit 9:8 b10 -> LMC input in CB4
- */
- #define CVP_GCE0_CP_STATUS 0x51080
- #define CVP_GCE0_BIU_RD_INPUT_IF_SECURITY_CFG 0x52020
- val = __read_register(dev, CVP_GCE_GCE_SS_CP_CTL);
- dprintk(CVP_ERR, "CVP_GCE_GCE_SS_CP_CTL %#x\n", val);
- val = __read_register(dev, CVP_GCE0_CP_STATUS);
- dprintk(CVP_ERR, "CVP_GCE0_CP_STATUS %#x\n", val);
- val = __read_register(dev, CVP_GCE0_BIU_RD_INPUT_IF_SECURITY_CFG);
- dprintk(CVP_ERR, "CVP_GCE0_BIU_RD_INPUT_IF_SECURITY_CFG %#x\n", val);
- /***** RGE *****
- * Bit 0 of below regiser is CDM secure enable for RGE
- * CDM buffer to be in CB4 i fset
- */
- #define CVP_RGE0_TOPRGE_CP_CTL 0x31010
- /* CFG bit 4 && IN bit 0:
- * if both are set, expect CB3 or CB4 depending on IN 6:4 field
- * either is clear, expect CB0
- */
- #define CVP_RGE0_BUS_RD_INPUT_IF_SECURITY_CFG 0x32020
- #define CVP_RGE0_TOPSPARE_IN 0x311F4
- val = __read_register(dev, CVP_RGE0_TOPRGE_CP_CTL);
- dprintk(CVP_ERR, "CVP_RGE0_TOPRGE_CP_CTL %#x\n", val);
- val = __read_register(dev, CVP_RGE0_BUS_RD_INPUT_IF_SECURITY_CFG);
- dprintk(CVP_ERR, "CVP_RGE0_BUS_RD_INPUT_IF_SECURITY_CFG %#x\n", val);
- val = __read_register(dev, CVP_RGE0_TOPSPARE_IN);
- dprintk(CVP_ERR, "CVP_RGE0_TOPSPARE_IN %#x\n", val);
- /****** VADL ******
- * Bit 0 of below register is CDM secure enable for VADL
- * CDM buffer will bei in CB4 if set
- */
- #define CVP_VADL0_VADL_SS_CP_CTL 0x21010
- /* Below registers are used the same way as RGE */
- #define CVP_VADL0_BUS_RD_INPUT_IF_SECURITY_CFG 0x22020
- #define CVP_VADL0_SPARE_IN 0x211F4
- val = __read_register(dev, CVP_VADL0_VADL_SS_CP_CTL);
- dprintk(CVP_ERR, "CVP_VADL0_VADL_SS_CP_CTL %#x\n", val);
- val = __read_register(dev, CVP_VADL0_BUS_RD_INPUT_IF_SECURITY_CFG);
- dprintk(CVP_ERR, "CVP_VADL0_BUS_RD_INPUT_IF_SECURITY_CFG %#x\n", val);
- val = __read_register(dev, CVP_VADL0_SPARE_IN);
- dprintk(CVP_ERR, "CVP_VADL0_SPARE_IN %#x\n", val);
- /****** ITOF *****
- * Below registers are used the same way as RGE
- */
- #define CVP_ITOF0_TOF_SS_CP_CTL 0x41010
- #define CVP_ITOF0_BUS_RD_INPUT_IF_SECURITY_CFG 0x42020
- #define CVP_ITOF0_TOF_SS_SPARE_IN 0x411F4
- val = __read_register(dev, CVP_ITOF0_TOF_SS_CP_CTL);
- dprintk(CVP_ERR, "CVP_ITOF0_TOF_SS_CP_CTL %#x\n", val);
- val = __read_register(dev, CVP_ITOF0_BUS_RD_INPUT_IF_SECURITY_CFG);
- dprintk(CVP_ERR, "CVP_ITOF0_BUS_RD_INPUT_IF_SECURITY_CFG %#x\n", val);
- val = __read_register(dev, CVP_ITOF0_TOF_SS_SPARE_IN);
- dprintk(CVP_ERR, "CVP_ITOF0_TOF_SS_SPARE_IN %#x\n", val);
- return 0;
- }
- static int iris_hfi_session_init(void *device, void *session_id,
- void **new_session)
- {
- struct cvp_hfi_cmd_sys_session_init_packet pkt;
- struct iris_hfi_device *dev;
- struct cvp_hal_session *s;
- if (!device || !new_session) {
- dprintk(CVP_ERR, "%s - invalid input\n", __func__);
- return -EINVAL;
- }
- dev = device;
- mutex_lock(&dev->lock);
- s = kzalloc(sizeof(*s), GFP_KERNEL);
- if (!s) {
- dprintk(CVP_ERR, "new session fail: Out of memory\n");
- goto err_session_init_fail;
- }
- s->session_id = session_id;
- s->device = dev;
- dprintk(CVP_SESS,
- "%s: inst %pK, session %pK\n", __func__, session_id, s);
- list_add_tail(&s->list, &dev->sess_head);
- __set_default_sys_properties(device);
- if (call_hfi_pkt_op(dev, session_init, &pkt, s)) {
- dprintk(CVP_ERR, "session_init: failed to create packet\n");
- goto err_session_init_fail;
- }
- *new_session = s;
- if (__iface_cmdq_write(dev, &pkt))
- goto err_session_init_fail;
- mutex_unlock(&dev->lock);
- return 0;
- err_session_init_fail:
- if (s)
- __session_clean(s);
- *new_session = NULL;
- mutex_unlock(&dev->lock);
- return -EINVAL;
- }
- static int __send_session_cmd(struct cvp_hal_session *session, int pkt_type)
- {
- struct cvp_hal_session_cmd_pkt pkt;
- int rc = 0;
- struct iris_hfi_device *device = session->device;
- if (!__is_session_valid(device, session, __func__))
- return -ECONNRESET;
- rc = call_hfi_pkt_op(device, session_cmd,
- &pkt, pkt_type, session);
- if (rc == -EPERM)
- return 0;
- if (rc) {
- dprintk(CVP_ERR, "send session cmd: create pkt failed\n");
- goto err_create_pkt;
- }
- if (__iface_cmdq_write(session->device, &pkt))
- rc = -ENOTEMPTY;
- err_create_pkt:
- return rc;
- }
- static int iris_hfi_session_end(void *session)
- {
- struct cvp_hal_session *sess;
- struct iris_hfi_device *device;
- int rc = 0;
- if (!session) {
- dprintk(CVP_ERR, "Invalid Params %s\n", __func__);
- return -EINVAL;
- }
- sess = session;
- device = sess->device;
- if (!device) {
- dprintk(CVP_ERR, "Invalid session %s\n", __func__);
- return -EINVAL;
- }
- mutex_lock(&device->lock);
- if (msm_cvp_fw_coverage) {
- if (__sys_set_coverage(sess->device, msm_cvp_fw_coverage))
- dprintk(CVP_WARN, "Fw_coverage msg ON failed\n");
- }
- rc = __send_session_cmd(session, HFI_CMD_SYS_SESSION_END);
- mutex_unlock(&device->lock);
- return rc;
- }
- static int iris_hfi_session_abort(void *sess)
- {
- struct cvp_hal_session *session = sess;
- struct iris_hfi_device *device;
- int rc = 0;
- if (!session || !session->device) {
- dprintk(CVP_ERR, "Invalid Params %s\n", __func__);
- return -EINVAL;
- }
- device = session->device;
- mutex_lock(&device->lock);
- rc = __send_session_cmd(session, HFI_CMD_SYS_SESSION_ABORT);
- mutex_unlock(&device->lock);
- return rc;
- }
- static int iris_hfi_session_set_buffers(void *sess, u32 iova, u32 size)
- {
- struct cvp_hfi_cmd_session_set_buffers_packet pkt;
- int rc = 0;
- struct cvp_hal_session *session = sess;
- struct iris_hfi_device *device;
- if (!session || !session->device || !iova || !size) {
- dprintk(CVP_ERR, "Invalid Params\n");
- return -EINVAL;
- }
- device = session->device;
- mutex_lock(&device->lock);
- if (!__is_session_valid(device, session, __func__)) {
- rc = -ECONNRESET;
- goto err_create_pkt;
- }
- rc = call_hfi_pkt_op(device, session_set_buffers,
- &pkt, session, iova, size);
- if (rc) {
- dprintk(CVP_ERR, "set buffers: failed to create packet\n");
- goto err_create_pkt;
- }
- if (__iface_cmdq_write(session->device, &pkt))
- rc = -ENOTEMPTY;
- err_create_pkt:
- mutex_unlock(&device->lock);
- return rc;
- }
- static int iris_hfi_session_release_buffers(void *sess)
- {
- struct cvp_session_release_buffers_packet pkt;
- int rc = 0;
- struct cvp_hal_session *session = sess;
- struct iris_hfi_device *device;
- if (!session || session == (void *)0xdeadbeef || !session->device) {
- dprintk(CVP_ERR, "Invalid Params\n");
- return -EINVAL;
- }
- device = session->device;
- mutex_lock(&device->lock);
- if (!__is_session_valid(device, session, __func__)) {
- rc = -ECONNRESET;
- goto err_create_pkt;
- }
- rc = call_hfi_pkt_op(device, session_release_buffers, &pkt, session);
- if (rc) {
- dprintk(CVP_ERR, "release buffers: failed to create packet\n");
- goto err_create_pkt;
- }
- if (__iface_cmdq_write(session->device, &pkt))
- rc = -ENOTEMPTY;
- err_create_pkt:
- mutex_unlock(&device->lock);
- return rc;
- }
- static int iris_hfi_session_send(void *sess,
- struct eva_kmd_hfi_packet *in_pkt)
- {
- int rc = 0;
- struct eva_kmd_hfi_packet pkt;
- struct cvp_hal_session *session = sess;
- struct iris_hfi_device *device;
- if (!session || !session->device) {
- dprintk(CVP_ERR, "invalid session");
- return -ENODEV;
- }
- device = session->device;
- mutex_lock(&device->lock);
- if (!__is_session_valid(device, session, __func__)) {
- rc = -ECONNRESET;
- goto err_send_pkt;
- }
- rc = call_hfi_pkt_op(device, session_send,
- &pkt, session, in_pkt);
- if (rc) {
- dprintk(CVP_ERR,
- "failed to create pkt\n");
- goto err_send_pkt;
- }
- if (__iface_cmdq_write(session->device, &pkt))
- rc = -ENOTEMPTY;
- err_send_pkt:
- mutex_unlock(&device->lock);
- return rc;
- return rc;
- }
- static int iris_hfi_session_flush(void *sess)
- {
- struct cvp_hal_session *session = sess;
- struct iris_hfi_device *device;
- int rc = 0;
- if (!session || !session->device) {
- dprintk(CVP_ERR, "Invalid Params %s\n", __func__);
- return -EINVAL;
- }
- device = session->device;
- mutex_lock(&device->lock);
- rc = __send_session_cmd(session, HFI_CMD_SESSION_CVP_FLUSH);
- mutex_unlock(&device->lock);
- return rc;
- }
- static int iris_hfi_session_start(void *sess)
- {
- struct cvp_hal_session *session = sess;
- struct iris_hfi_device *device;
- int rc = 0;
- if (!session || !session->device) {
- dprintk(CVP_ERR, "Invalid Params %s\n", __func__);
- return -EINVAL;
- }
- device = session->device;
- mutex_lock(&device->lock);
- rc = __send_session_cmd(session, HFI_CMD_SESSION_EVA_START);
- mutex_unlock(&device->lock);
- return rc;
- }
- static int iris_hfi_session_stop(void *sess)
- {
- struct cvp_hal_session *session = sess;
- struct iris_hfi_device *device;
- int rc = 0;
- if (!session || !session->device) {
- dprintk(CVP_ERR, "Invalid Params %s\n", __func__);
- return -EINVAL;
- }
- device = session->device;
- mutex_lock(&device->lock);
- rc = __send_session_cmd(session, HFI_CMD_SESSION_EVA_STOP);
- mutex_unlock(&device->lock);
- return rc;
- }
- static void __process_fatal_error(
- struct iris_hfi_device *device)
- {
- struct msm_cvp_cb_cmd_done cmd_done = {0};
- device->callback(HAL_SYS_ERROR, &cmd_done);
- }
- static int __prepare_pc(struct iris_hfi_device *device)
- {
- int rc = 0;
- struct cvp_hfi_cmd_sys_pc_prep_packet pkt;
- rc = call_hfi_pkt_op(device, sys_pc_prep, &pkt);
- if (rc) {
- dprintk(CVP_ERR, "Failed to create sys pc prep pkt\n");
- goto err_pc_prep;
- }
- if (__iface_cmdq_write(device, &pkt))
- rc = -ENOTEMPTY;
- if (rc)
- dprintk(CVP_ERR, "Failed to prepare iris for power off");
- err_pc_prep:
- return rc;
- }
- static void iris_hfi_pm_handler(struct work_struct *work)
- {
- int rc = 0;
- struct msm_cvp_core *core;
- struct iris_hfi_device *device;
- core = cvp_driver->cvp_core;
- if (core)
- device = core->dev_ops->hfi_device_data;
- else
- return;
- if (!device) {
- dprintk(CVP_ERR, "%s: NULL device\n", __func__);
- return;
- }
- dprintk(CVP_PWR,
- "Entering %s\n", __func__);
- /*
- * It is ok to check this variable outside the lock since
- * it is being updated in this context only
- */
- if (device->skip_pc_count >= CVP_MAX_PC_SKIP_COUNT) {
- dprintk(CVP_WARN, "Failed to PC for %d times\n",
- device->skip_pc_count);
- device->skip_pc_count = 0;
- __process_fatal_error(device);
- return;
- }
- mutex_lock(&device->lock);
- if (gfa_cv.state == DSP_SUSPEND)
- rc = __power_collapse(device, true);
- else
- rc = __power_collapse(device, false);
- mutex_unlock(&device->lock);
- switch (rc) {
- case 0:
- device->skip_pc_count = 0;
- /* Cancel pending delayed works if any */
- cancel_delayed_work(&iris_hfi_pm_work);
- dprintk(CVP_PWR, "%s: power collapse successful!\n",
- __func__);
- break;
- case -EBUSY:
- device->skip_pc_count = 0;
- dprintk(CVP_PWR, "%s: retry PC as cvp is busy\n", __func__);
- queue_delayed_work(device->iris_pm_workq,
- &iris_hfi_pm_work, msecs_to_jiffies(
- device->res->msm_cvp_pwr_collapse_delay));
- break;
- case -EAGAIN:
- device->skip_pc_count++;
- dprintk(CVP_WARN, "%s: retry power collapse (count %d)\n",
- __func__, device->skip_pc_count);
- queue_delayed_work(device->iris_pm_workq,
- &iris_hfi_pm_work, msecs_to_jiffies(
- device->res->msm_cvp_pwr_collapse_delay));
- break;
- default:
- dprintk(CVP_ERR, "%s: power collapse failed\n", __func__);
- break;
- }
- }
- static int __power_collapse(struct iris_hfi_device *device, bool force)
- {
- int rc = 0;
- u32 wfi_status = 0, idle_status = 0, pc_ready = 0;
- int count = 0;
- const int max_tries = 150;
- if (!device) {
- dprintk(CVP_ERR, "%s: invalid params\n", __func__);
- return -EINVAL;
- }
- if (!device->power_enabled) {
- dprintk(CVP_PWR, "%s: Power already disabled\n",
- __func__);
- goto exit;
- }
- rc = __core_in_valid_state(device);
- if (!rc) {
- dprintk(CVP_WARN,
- "Core is in bad state, Skipping power collapse\n");
- return -EINVAL;
- }
- rc = __dsp_suspend(device, force);
- if (rc == -EBUSY)
- goto exit;
- else if (rc)
- goto skip_power_off;
- __flush_debug_queue(device, device->raw_packet);
- pc_ready = __read_register(device, CVP_CTRL_STATUS) &
- CVP_CTRL_STATUS_PC_READY;
- if (!pc_ready) {
- wfi_status = __read_register(device,
- CVP_WRAPPER_CPU_STATUS);
- idle_status = __read_register(device,
- CVP_CTRL_STATUS);
- if (!(wfi_status & BIT(0))) {
- dprintk(CVP_WARN,
- "Skipping PC as wfi_status (%#x) bit not set\n",
- wfi_status);
- goto skip_power_off;
- }
- if (!(idle_status & BIT(30))) {
- dprintk(CVP_WARN,
- "Skipping PC as idle_status (%#x) bit not set\n",
- idle_status);
- goto skip_power_off;
- }
- rc = __prepare_pc(device);
- if (rc) {
- dprintk(CVP_WARN, "Failed PC %d\n", rc);
- goto skip_power_off;
- }
- while (count < max_tries) {
- wfi_status = __read_register(device,
- CVP_WRAPPER_CPU_STATUS);
- pc_ready = __read_register(device,
- CVP_CTRL_STATUS);
- if ((wfi_status & BIT(0)) && (pc_ready &
- CVP_CTRL_STATUS_PC_READY))
- break;
- usleep_range(150, 250);
- count++;
- }
- if (count == max_tries) {
- dprintk(CVP_ERR,
- "Skip PC. Core is not ready (%#x, %#x)\n",
- wfi_status, pc_ready);
- goto skip_power_off;
- }
- } else {
- wfi_status = __read_register(device, CVP_WRAPPER_CPU_STATUS);
- if (!(wfi_status & BIT(0))) {
- dprintk(CVP_WARN,
- "Skip PC as wfi_status (%#x) bit not set\n",
- wfi_status);
- goto skip_power_off;
- }
- }
- rc = __suspend(device);
- if (rc)
- dprintk(CVP_ERR, "Failed __suspend\n");
- exit:
- return rc;
- skip_power_off:
- dprintk(CVP_PWR, "Skip PC(%#x, %#x, %#x)\n",
- wfi_status, idle_status, pc_ready);
- __flush_debug_queue(device, device->raw_packet);
- return -EAGAIN;
- }
- static void __process_sys_error(struct iris_hfi_device *device)
- {
- struct cvp_hfi_sfr_struct *vsfr = NULL;
- vsfr = (struct cvp_hfi_sfr_struct *)device->sfr.align_virtual_addr;
- if (vsfr) {
- void *p = memchr(vsfr->rg_data, '\0', vsfr->bufSize);
- /*
- * SFR isn't guaranteed to be NULL terminated
- * since SYS_ERROR indicates that Iris is in the
- * process of crashing.
- */
- if (p == NULL)
- vsfr->rg_data[vsfr->bufSize - 1] = '\0';
- dprintk(CVP_ERR, "SFR Message from FW: %s\n",
- vsfr->rg_data);
- }
- }
- static void __flush_debug_queue(struct iris_hfi_device *device, u8 *packet)
- {
- bool local_packet = false;
- enum cvp_msg_prio log_level = CVP_FW;
- if (!device) {
- dprintk(CVP_ERR, "%s: Invalid params\n", __func__);
- return;
- }
- if (!packet) {
- packet = kzalloc(CVP_IFACEQ_VAR_HUGE_PKT_SIZE, GFP_KERNEL);
- if (!packet) {
- dprintk(CVP_ERR, "In %s() Fail to allocate mem\n",
- __func__);
- return;
- }
- local_packet = true;
- /*
- * Local packek is used when something FATAL occurred.
- * It is good to print these logs by default.
- */
- log_level = CVP_ERR;
- }
- #define SKIP_INVALID_PKT(pkt_size, payload_size, pkt_hdr_size) ({ \
- if (pkt_size < pkt_hdr_size || \
- payload_size < MIN_PAYLOAD_SIZE || \
- payload_size > \
- (pkt_size - pkt_hdr_size + sizeof(u8))) { \
- dprintk(CVP_ERR, \
- "%s: invalid msg size - %d\n", \
- __func__, pkt->msg_size); \
- continue; \
- } \
- })
- while (!__iface_dbgq_read(device, packet)) {
- struct cvp_hfi_packet_header *pkt =
- (struct cvp_hfi_packet_header *) packet;
- if (pkt->size < sizeof(struct cvp_hfi_packet_header)) {
- dprintk(CVP_ERR, "Invalid pkt size - %s\n",
- __func__);
- continue;
- }
- if (pkt->packet_type == HFI_MSG_SYS_DEBUG) {
- struct cvp_hfi_msg_sys_debug_packet *pkt =
- (struct cvp_hfi_msg_sys_debug_packet *) packet;
- SKIP_INVALID_PKT(pkt->size,
- pkt->msg_size, sizeof(*pkt));
- /*
- * All fw messages starts with new line character. This
- * causes dprintk to print this message in two lines
- * in the kernel log. Ignoring the first character
- * from the message fixes this to print it in a single
- * line.
- */
- pkt->rg_msg_data[pkt->msg_size-1] = '\0';
- dprintk(log_level, "%s", &pkt->rg_msg_data[1]);
- }
- }
- #undef SKIP_INVALID_PKT
- if (local_packet)
- kfree(packet);
- }
- static bool __is_session_valid(struct iris_hfi_device *device,
- struct cvp_hal_session *session, const char *func)
- {
- struct cvp_hal_session *temp = NULL;
- if (!device || !session)
- goto invalid;
- list_for_each_entry(temp, &device->sess_head, list)
- if (session == temp)
- return true;
- invalid:
- dprintk(CVP_WARN, "%s: device %pK, invalid session %pK\n",
- func, device, session);
- return false;
- }
- static struct cvp_hal_session *__get_session(struct iris_hfi_device *device,
- u32 session_id)
- {
- struct cvp_hal_session *temp = NULL;
- list_for_each_entry(temp, &device->sess_head, list) {
- if (session_id == hash32_ptr(temp))
- return temp;
- }
- return NULL;
- }
- #define _INVALID_MSG_ "Unrecognized MSG (%#x) session (%pK), discarding\n"
- #define _INVALID_STATE_ "Ignore responses from %d to %d invalid state\n"
- #define _DEVFREQ_FAIL_ "Failed to add devfreq device bus %s governor %s: %d\n"
- static void process_system_msg(struct msm_cvp_cb_info *info,
- struct iris_hfi_device *device,
- void *raw_packet)
- {
- struct cvp_hal_sys_init_done sys_init_done = {0};
- switch (info->response_type) {
- case HAL_SYS_ERROR:
- __process_sys_error(device);
- break;
- case HAL_SYS_RELEASE_RESOURCE_DONE:
- dprintk(CVP_CORE, "Received SYS_RELEASE_RESOURCE\n");
- break;
- case HAL_SYS_INIT_DONE:
- dprintk(CVP_CORE, "Received SYS_INIT_DONE\n");
- sys_init_done.capabilities =
- device->sys_init_capabilities;
- cvp_hfi_process_sys_init_done_prop_read(
- (struct cvp_hfi_msg_sys_init_done_packet *)
- raw_packet, &sys_init_done);
- info->response.cmd.data.sys_init_done = sys_init_done;
- break;
- default:
- break;
- }
- }
- static void **get_session_id(struct msm_cvp_cb_info *info)
- {
- void **session_id = NULL;
- /* For session-related packets, validate session */
- switch (info->response_type) {
- case HAL_SESSION_INIT_DONE:
- case HAL_SESSION_END_DONE:
- case HAL_SESSION_ABORT_DONE:
- case HAL_SESSION_START_DONE:
- case HAL_SESSION_STOP_DONE:
- case HAL_SESSION_FLUSH_DONE:
- case HAL_SESSION_SET_BUFFER_DONE:
- case HAL_SESSION_SUSPEND_DONE:
- case HAL_SESSION_RESUME_DONE:
- case HAL_SESSION_SET_PROP_DONE:
- case HAL_SESSION_GET_PROP_DONE:
- case HAL_SESSION_RELEASE_BUFFER_DONE:
- case HAL_SESSION_REGISTER_BUFFER_DONE:
- case HAL_SESSION_UNREGISTER_BUFFER_DONE:
- case HAL_SESSION_PROPERTY_INFO:
- case HAL_SESSION_EVENT_CHANGE:
- case HAL_SESSION_DUMP_NOTIFY:
- case HAL_SESSION_ERROR:
- session_id = &info->response.cmd.session_id;
- break;
- case HAL_RESPONSE_UNUSED:
- default:
- session_id = NULL;
- break;
- }
- return session_id;
- }
- static void print_msg_hdr(void *hdr)
- {
- struct cvp_hfi_msg_session_hdr *new_hdr =
- (struct cvp_hfi_msg_session_hdr *)hdr;
- dprintk(CVP_HFI, "HFI MSG received: %x %x %x %x %x %x %x %#llx\n",
- new_hdr->size, new_hdr->packet_type,
- new_hdr->session_id,
- new_hdr->client_data.transaction_id,
- new_hdr->client_data.data1,
- new_hdr->client_data.data2,
- new_hdr->error_type,
- new_hdr->client_data.kdata);
- }
- static int __response_handler(struct iris_hfi_device *device)
- {
- struct msm_cvp_cb_info *packets;
- int packet_count = 0;
- u8 *raw_packet = NULL;
- bool requeue_pm_work = true;
- if (!device || device->state != IRIS_STATE_INIT)
- return 0;
- packets = device->response_pkt;
- raw_packet = device->raw_packet;
- if (!raw_packet || !packets) {
- dprintk(CVP_ERR,
- "%s: Invalid args : Res pkt = %pK, Raw pkt = %pK\n",
- __func__, packets, raw_packet);
- return 0;
- }
- if (device->intr_status & CVP_FATAL_INTR_BMSK) {
- if (device->intr_status & CVP_WRAPPER_INTR_MASK_CPU_NOC_BMSK)
- dprintk(CVP_ERR, "Received Xtensa NOC error\n");
- if (device->intr_status & CVP_WRAPPER_INTR_MASK_CORE_NOC_BMSK)
- dprintk(CVP_ERR, "Received CVP core NOC error\n");
- }
- /* Bleed the msg queue dry of packets */
- while (!__iface_msgq_read(device, raw_packet)) {
- void **session_id = NULL;
- struct msm_cvp_cb_info *info = &packets[packet_count++];
- struct cvp_hfi_msg_session_hdr *hdr =
- (struct cvp_hfi_msg_session_hdr *)raw_packet;
- int rc = 0;
- print_msg_hdr(hdr);
- rc = cvp_hfi_process_msg_packet(0, raw_packet, info);
- if (rc) {
- dprintk(CVP_WARN,
- "Corrupt/unknown packet found, discarding\n");
- --packet_count;
- continue;
- } else if (info->response_type == HAL_NO_RESP) {
- --packet_count;
- continue;
- }
- /* Process the packet types that we're interested in */
- process_system_msg(info, device, raw_packet);
- session_id = get_session_id(info);
- /*
- * hfi_process_msg_packet provides a session_id that's a hashed
- * value of struct cvp_hal_session, we need to coerce the hashed
- * value back to pointer that we can use. Ideally, hfi_process\
- * _msg_packet should take care of this, but it doesn't have
- * required information for it
- */
- if (session_id) {
- struct cvp_hal_session *session = NULL;
- if (upper_32_bits((uintptr_t)*session_id) != 0) {
- dprintk(CVP_ERR,
- "Upper 32-bits != 0 for sess_id=%pK\n",
- *session_id);
- }
- session = __get_session(device,
- (u32)(uintptr_t)*session_id);
- if (!session) {
- dprintk(CVP_ERR, _INVALID_MSG_,
- info->response_type,
- *session_id);
- --packet_count;
- continue;
- }
- *session_id = session->session_id;
- }
- if (packet_count >= cvp_max_packets) {
- dprintk(CVP_WARN,
- "Too many packets in message queue!\n");
- break;
- }
- /* do not read packets after sys error packet */
- if (info->response_type == HAL_SYS_ERROR)
- break;
- }
- if (requeue_pm_work && device->res->sw_power_collapsible) {
- cancel_delayed_work(&iris_hfi_pm_work);
- if (!queue_delayed_work(device->iris_pm_workq,
- &iris_hfi_pm_work,
- msecs_to_jiffies(
- device->res->msm_cvp_pwr_collapse_delay))) {
- dprintk(CVP_ERR, "PM work already scheduled\n");
- }
- }
- __flush_debug_queue(device, raw_packet);
- return packet_count;
- }
- irqreturn_t iris_hfi_core_work_handler(int irq, void *data)
- {
- struct msm_cvp_core *core;
- struct iris_hfi_device *device;
- int num_responses = 0, i = 0;
- u32 intr_status;
- static bool warning_on = true;
- core = cvp_driver->cvp_core;
- if (core)
- device = core->dev_ops->hfi_device_data;
- else
- return IRQ_HANDLED;
- mutex_lock(&device->lock);
- if (!__core_in_valid_state(device)) {
- if (warning_on) {
- dprintk(CVP_WARN, "%s Core not in init state\n",
- __func__);
- warning_on = false;
- }
- goto err_no_work;
- }
- warning_on = true;
- if (!device->callback) {
- dprintk(CVP_ERR, "No interrupt callback function: %pK\n",
- device);
- goto err_no_work;
- }
- if (__resume(device)) {
- dprintk(CVP_ERR, "%s: Power enable failed\n", __func__);
- goto err_no_work;
- }
- __core_clear_interrupt(device);
- num_responses = __response_handler(device);
- dprintk(CVP_HFI, "%s:: cvp_driver_debug num_responses = %d ",
- __func__, num_responses);
- err_no_work:
- /* Keep the interrupt status before releasing device lock */
- intr_status = device->intr_status;
- mutex_unlock(&device->lock);
- /*
- * Issue the callbacks outside of the locked contex to preserve
- * re-entrancy.
- */
- for (i = 0; !IS_ERR_OR_NULL(device->response_pkt) &&
- i < num_responses; ++i) {
- struct msm_cvp_cb_info *r = &device->response_pkt[i];
- void *rsp = (void *)&r->response;
- if (!__core_in_valid_state(device)) {
- dprintk(CVP_ERR,
- _INVALID_STATE_, (i + 1), num_responses);
- break;
- }
- dprintk(CVP_HFI, "Processing response %d of %d, type %d\n",
- (i + 1), num_responses, r->response_type);
- /* callback = void cvp_handle_cmd_response() */
- device->callback(r->response_type, rsp);
- }
- /* We need re-enable the irq which was disabled in ISR handler */
- if (!(intr_status & CVP_WRAPPER_INTR_STATUS_A2HWD_BMSK))
- enable_irq(device->cvp_hal_data->irq);
- return IRQ_HANDLED;
- }
- irqreturn_t cvp_hfi_isr(int irq, void *dev)
- {
- disable_irq_nosync(irq);
- return IRQ_WAKE_THREAD;
- }
- static void iris_hfi_wd_work_handler(struct work_struct *work)
- {
- struct msm_cvp_core *core;
- struct iris_hfi_device *device;
- struct msm_cvp_cb_cmd_done response = {0};
- enum hal_command_response cmd = HAL_SYS_WATCHDOG_TIMEOUT;
- core = cvp_driver->cvp_core;
- if (core)
- device = core->dev_ops->hfi_device_data;
- else
- return;
- if (msm_cvp_hw_wd_recovery) {
- dprintk(CVP_ERR, "Cleaning up as HW WD recovery is enable %d\n",
- msm_cvp_hw_wd_recovery);
- __print_sidebandmanager_regs(device);
- response.device_id = 0;
- handle_sys_error(cmd, (void *) &response);
- enable_irq(device->cvp_hal_data->irq_wd);
- }
- else {
- dprintk(CVP_ERR, "Crashing the device as HW WD recovery is disable %d\n",
- msm_cvp_hw_wd_recovery);
- BUG_ON(1);
- }
- }
- static DECLARE_WORK(iris_hfi_wd_work, iris_hfi_wd_work_handler);
- irqreturn_t iris_hfi_isr_wd(int irq, void *dev)
- {
- struct iris_hfi_device *device = dev;
- dprintk(CVP_ERR, "Got HW WDOG IRQ at %llu! \n", get_aon_time());
- disable_irq_nosync(irq);
- queue_work(device->cvp_workq, &iris_hfi_wd_work);
- return IRQ_HANDLED;
- }
- static int __init_reset_clk(struct msm_cvp_platform_resources *res,
- int reset_index)
- {
- int rc = 0;
- struct reset_control *rst;
- struct reset_info *rst_info;
- struct reset_set *rst_set = &res->reset_set;
- if (!rst_set->reset_tbl)
- return 0;
- rst_info = &rst_set->reset_tbl[reset_index];
- rst = rst_info->rst;
- dprintk(CVP_PWR, "reset_clk: name %s rst %pK required_stage=%d\n",
- rst_set->reset_tbl[reset_index].name, rst, rst_info->required_stage);
- if (rst)
- goto skip_reset_init;
- if (rst_info->required_stage == CVP_ON_USE) {
- rst = reset_control_get_exclusive_released(&res->pdev->dev,
- rst_set->reset_tbl[reset_index].name);
- if (IS_ERR(rst)) {
- rc = PTR_ERR(rst);
- dprintk(CVP_ERR, "reset get exclusive fail %d\n", rc);
- return rc;
- }
- dprintk(CVP_PWR, "reset_clk: name %s get exclusive rst %llx\n",
- rst_set->reset_tbl[reset_index].name, rst);
- } else if (rst_info->required_stage == CVP_ON_INIT) {
- rst = devm_reset_control_get(&res->pdev->dev,
- rst_set->reset_tbl[reset_index].name);
- if (IS_ERR(rst)) {
- rc = PTR_ERR(rst);
- dprintk(CVP_ERR, "reset get fail %d\n", rc);
- return rc;
- }
- dprintk(CVP_PWR, "reset_clk: name %s get rst %llx\n",
- rst_set->reset_tbl[reset_index].name, rst);
- } else {
- dprintk(CVP_ERR, "Invalid reset stage\n");
- return -EINVAL;
- }
- rst_set->reset_tbl[reset_index].rst = rst;
- rst_info->state = RESET_INIT;
- return 0;
- skip_reset_init:
- return rc;
- }
- static int __reset_control_assert_name(struct iris_hfi_device *device,
- const char *name)
- {
- struct reset_info *rcinfo = NULL;
- int rc = 0;
- bool found = false;
- iris_hfi_for_each_reset_clock(device, rcinfo) {
- if (strcmp(rcinfo->name, name))
- continue;
- found = true;
- rc = reset_control_assert(rcinfo->rst);
- if (rc)
- dprintk(CVP_ERR,
- "%s: failed to assert reset control (%s), rc = %d\n",
- __func__, rcinfo->name, rc);
- else
- dprintk(CVP_PWR, "%s: assert reset control (%s)\n",
- __func__, rcinfo->name);
- break;
- }
- if (!found) {
- dprintk(CVP_PWR, "%s: reset control (%s) not found\n",
- __func__, name);
- rc = -EINVAL;
- }
- return rc;
- }
- static int __reset_control_deassert_name(struct iris_hfi_device *device,
- const char *name)
- {
- struct reset_info *rcinfo = NULL;
- int rc = 0;
- bool found = false;
- iris_hfi_for_each_reset_clock(device, rcinfo) {
- if (strcmp(rcinfo->name, name))
- continue;
- found = true;
- rc = reset_control_deassert(rcinfo->rst);
- if (rc)
- dprintk(CVP_ERR,
- "%s: deassert reset control for (%s) failed, rc %d\n",
- __func__, rcinfo->name, rc);
- else
- dprintk(CVP_PWR, "%s: deassert reset control (%s)\n",
- __func__, rcinfo->name);
- break;
- }
- if (!found) {
- dprintk(CVP_PWR, "%s: reset control (%s) not found\n",
- __func__, name);
- rc = -EINVAL;
- }
- return rc;
- }
- static int __reset_control_acquire(struct iris_hfi_device *device,
- const char *name)
- {
- struct reset_info *rcinfo = NULL;
- int rc = 0;
- bool found = false;
- int max_retries = 10000;
- iris_hfi_for_each_reset_clock(device, rcinfo) {
- if (strcmp(rcinfo->name, name))
- continue;
- found = true;
- if (rcinfo->state == RESET_ACQUIRED)
- return rc;
- acquire_again:
- rc = reset_control_acquire(rcinfo->rst);
- if (rc) {
- if (rc == -EBUSY) {
- usleep_range(100, 150);
- max_retries--;
- if (max_retries) {
- goto acquire_again;
- } else {
- dprintk(CVP_ERR,
- "%s acquire %s -EBUSY\n",
- __func__, rcinfo->name);
- BUG_ON(1);
- }
- } else {
- dprintk(CVP_ERR,
- "%s: acquire failed (%s) rc %d\n",
- __func__, rcinfo->name, rc);
- rc = -EINVAL;
- }
- } else {
- dprintk(CVP_PWR, "%s: reset acquire succeed (%s)\n",
- __func__, rcinfo->name);
- rcinfo->state = RESET_ACQUIRED;
- }
- break;
- }
- if (!found) {
- dprintk(CVP_PWR, "%s: reset control (%s) not found\n",
- __func__, name);
- rc = -EINVAL;
- }
- return rc;
- }
- static int __reset_control_release(struct iris_hfi_device *device,
- const char *name)
- {
- struct reset_info *rcinfo = NULL;
- int rc = 0;
- bool found = false;
- iris_hfi_for_each_reset_clock(device, rcinfo) {
- if (strcmp(rcinfo->name, name))
- continue;
- found = true;
- if (rcinfo->state != RESET_ACQUIRED) {
- dprintk(CVP_WARN, "Double releasing reset clk?\n");
- return -EINVAL;
- }
- reset_control_release(rcinfo->rst);
- dprintk(CVP_PWR, "%s: reset release succeed (%s)\n",
- __func__, rcinfo->name);
- rcinfo->state = RESET_RELEASED;
- break;
- }
- if (!found) {
- dprintk(CVP_PWR, "%s: reset control (%s) not found\n",
- __func__, name);
- rc = -EINVAL;
- }
- return rc;
- }
- static void __deinit_bus(struct iris_hfi_device *device)
- {
- struct bus_info *bus = NULL;
- if (!device)
- return;
- kfree(device->bus_vote.data);
- device->bus_vote = CVP_DEFAULT_BUS_VOTE;
- iris_hfi_for_each_bus_reverse(device, bus) {
- dev_set_drvdata(bus->dev, NULL);
- icc_put(bus->client);
- bus->client = NULL;
- }
- }
- static int __init_bus(struct iris_hfi_device *device)
- {
- struct bus_info *bus = NULL;
- int rc = 0;
- if (!device)
- return -EINVAL;
- iris_hfi_for_each_bus(device, bus) {
- /*
- * This is stupid, but there's no other easy way to ahold
- * of struct bus_info in iris_hfi_devfreq_*()
- */
- WARN(dev_get_drvdata(bus->dev), "%s's drvdata already set\n",
- dev_name(bus->dev));
- dev_set_drvdata(bus->dev, device);
- bus->client = icc_get(&device->res->pdev->dev,
- bus->master, bus->slave);
- if (IS_ERR_OR_NULL(bus->client)) {
- rc = PTR_ERR(bus->client) ?: -EBADHANDLE;
- dprintk(CVP_ERR, "Failed to register bus %s: %d\n",
- bus->name, rc);
- bus->client = NULL;
- goto err_add_dev;
- }
- }
- return 0;
- err_add_dev:
- __deinit_bus(device);
- return rc;
- }
- static void __deinit_regulators(struct iris_hfi_device *device)
- {
- struct regulator_info *rinfo = NULL;
- iris_hfi_for_each_regulator_reverse(device, rinfo) {
- if (rinfo->regulator) {
- regulator_put(rinfo->regulator);
- rinfo->regulator = NULL;
- }
- }
- }
- static int __init_regulators(struct iris_hfi_device *device)
- {
- int rc = 0;
- struct regulator_info *rinfo = NULL;
- iris_hfi_for_each_regulator(device, rinfo) {
- rinfo->regulator = regulator_get(&device->res->pdev->dev,
- rinfo->name);
- if (IS_ERR_OR_NULL(rinfo->regulator)) {
- rc = PTR_ERR(rinfo->regulator) ?: -EBADHANDLE;
- dprintk(CVP_ERR, "Failed to get regulator: %s\n",
- rinfo->name);
- rinfo->regulator = NULL;
- goto err_reg_get;
- }
- }
- return 0;
- err_reg_get:
- __deinit_regulators(device);
- return rc;
- }
- static void __deinit_subcaches(struct iris_hfi_device *device)
- {
- struct subcache_info *sinfo = NULL;
- if (!device) {
- dprintk(CVP_ERR, "deinit_subcaches: invalid device %pK\n",
- device);
- goto exit;
- }
- if (!is_sys_cache_present(device))
- goto exit;
- iris_hfi_for_each_subcache_reverse(device, sinfo) {
- if (sinfo->subcache) {
- dprintk(CVP_CORE, "deinit_subcaches: %s\n",
- sinfo->name);
- llcc_slice_putd(sinfo->subcache);
- sinfo->subcache = NULL;
- }
- }
- exit:
- return;
- }
- static int __init_subcaches(struct iris_hfi_device *device)
- {
- int rc = 0;
- struct subcache_info *sinfo = NULL;
- if (!device) {
- dprintk(CVP_ERR, "init_subcaches: invalid device %pK\n",
- device);
- return -EINVAL;
- }
- if (!is_sys_cache_present(device))
- return 0;
- iris_hfi_for_each_subcache(device, sinfo) {
- if (!strcmp("cvp", sinfo->name)) {
- sinfo->subcache = llcc_slice_getd(LLCC_CVP);
- } else if (!strcmp("cvpfw", sinfo->name)) {
- sinfo->subcache = llcc_slice_getd(LLCC_CVPFW);
- } else {
- dprintk(CVP_ERR, "Invalid subcache name %s\n",
- sinfo->name);
- }
- if (IS_ERR_OR_NULL(sinfo->subcache)) {
- rc = PTR_ERR(sinfo->subcache) ?
- PTR_ERR(sinfo->subcache) : -EBADHANDLE;
- dprintk(CVP_ERR,
- "init_subcaches: invalid subcache: %s rc %d\n",
- sinfo->name, rc);
- sinfo->subcache = NULL;
- goto err_subcache_get;
- }
- dprintk(CVP_CORE, "init_subcaches: %s\n",
- sinfo->name);
- }
- return 0;
- err_subcache_get:
- __deinit_subcaches(device);
- return rc;
- }
- static int __init_resources(struct iris_hfi_device *device,
- struct msm_cvp_platform_resources *res)
- {
- int i, rc = 0;
- rc = __init_regulators(device);
- if (rc) {
- dprintk(CVP_ERR, "Failed to get all regulators\n");
- return -ENODEV;
- }
- rc = msm_cvp_init_clocks(device);
- if (rc) {
- dprintk(CVP_ERR, "Failed to init clocks\n");
- rc = -ENODEV;
- goto err_init_clocks;
- }
- for (i = 0; i < device->res->reset_set.count; i++) {
- rc = __init_reset_clk(res, i);
- if (rc) {
- dprintk(CVP_ERR, "Failed to init reset clocks\n");
- rc = -ENODEV;
- goto err_init_reset_clk;
- }
- }
- rc = __init_bus(device);
- if (rc) {
- dprintk(CVP_ERR, "Failed to init bus: %d\n", rc);
- goto err_init_bus;
- }
- rc = __init_subcaches(device);
- if (rc)
- dprintk(CVP_WARN, "Failed to init subcaches: %d\n", rc);
- device->sys_init_capabilities =
- kzalloc(sizeof(struct msm_cvp_capability)
- * CVP_MAX_SESSIONS, GFP_KERNEL);
- return rc;
- err_init_reset_clk:
- err_init_bus:
- msm_cvp_deinit_clocks(device);
- err_init_clocks:
- __deinit_regulators(device);
- return rc;
- }
- static void __deinit_resources(struct iris_hfi_device *device)
- {
- __deinit_subcaches(device);
- __deinit_bus(device);
- msm_cvp_deinit_clocks(device);
- __deinit_regulators(device);
- kfree(device->sys_init_capabilities);
- device->sys_init_capabilities = NULL;
- }
- static int __disable_regulator_impl(struct regulator_info *rinfo,
- struct iris_hfi_device *device)
- {
- int rc = 0;
- dprintk(CVP_PWR, "Disabling regulator %s\n", rinfo->name);
- /*
- * This call is needed. Driver needs to acquire the control back
- * from HW in order to disable the regualtor. Else the behavior
- * is unknown.
- */
- rc = __acquire_regulator(rinfo, device);
- if (rc) {
- /*
- * This is somewhat fatal, but nothing we can do
- * about it. We can't disable the regulator w/o
- * getting it back under s/w control
- */
- dprintk(CVP_WARN,
- "Failed to acquire control on %s\n",
- rinfo->name);
- goto disable_regulator_failed;
- }
- /*Acquire XO_RESET to avoid race condition with video*/
- rc = call_iris_op(device, reset_control_acquire_name, device, "cvp_xo_reset");
- if (rc) {
- dprintk(CVP_ERR,
- "XO_RESET could not be acquired: skip disabling the regulator %s\n",
- rinfo->name);
- return -EINVAL;
- }
- rc = regulator_disable(rinfo->regulator);
- /*Release XO_RESET after regulator is enabled.*/
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- if (rc) {
- dprintk(CVP_WARN,
- "Failed to disable %s: %d\n",
- rinfo->name, rc);
- goto disable_regulator_failed;
- }
- return 0;
- disable_regulator_failed:
- /* Bring attention to this issue */
- msm_cvp_res_handle_fatal_hw_error(device->res, true);
- return rc;
- }
- static int __disable_hw_power_collapse(struct iris_hfi_device *device)
- {
- int rc = 0;
- if (!msm_cvp_fw_low_power_mode) {
- dprintk(CVP_PWR, "Not enabling hardware power collapse\n");
- return 0;
- }
- rc = __take_back_regulators(device);
- if (rc)
- dprintk(CVP_WARN,
- "%s : Failed to disable HW power collapse %d\n",
- __func__, rc);
- return rc;
- }
- static int __enable_hw_power_collapse(struct iris_hfi_device *device)
- {
- int rc = 0;
- if (!msm_cvp_fw_low_power_mode) {
- dprintk(CVP_PWR, "Not enabling hardware power collapse\n");
- return 0;
- }
- rc = __hand_off_regulators(device);
- if (rc)
- dprintk(CVP_WARN,
- "%s : Failed to enable HW power collapse %d\n",
- __func__, rc);
- return rc;
- }
- static int __enable_regulator(struct iris_hfi_device *device,
- const char *name)
- {
- int rc = 0;
- struct regulator_info *rinfo;
- iris_hfi_for_each_regulator(device, rinfo) {
- if (strcmp(rinfo->name, name))
- continue;
- /*Acquire XO_RESET to avoid race condition with video*/
- rc = call_iris_op(device, reset_control_acquire_name, device, "cvp_xo_reset");
- if (rc) {
- dprintk(CVP_ERR,
- "XO_RESET could not be acquired: skip enabling the regulator %s\n",
- rinfo->name);
- return -EINVAL;
- }
- rc = regulator_enable(rinfo->regulator);
- /*Release XO_RESET after regulator is enabled.*/
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- if (rc) {
- dprintk(CVP_ERR, "Failed to enable %s: %d\n",
- rinfo->name, rc);
- return rc;
- }
- if (!regulator_is_enabled(rinfo->regulator)) {
- dprintk(CVP_ERR,"%s: regulator %s not enabled\n",
- __func__, rinfo->name);
- regulator_disable(rinfo->regulator);
- return -EINVAL;
- }
- dprintk(CVP_PWR, "Enabled regulator %s\n", rinfo->name);
- return 0;
- }
- dprintk(CVP_ERR, "regulator %s not found\n", name);
- return -EINVAL;
- }
- static int __disable_regulator(struct iris_hfi_device *device,
- const char *name)
- {
- struct regulator_info *rinfo;
- iris_hfi_for_each_regulator_reverse(device, rinfo) {
- if (strcmp(rinfo->name, name))
- continue;
- __disable_regulator_impl(rinfo, device);
- dprintk(CVP_PWR, "%s Disabled regulator %s\n", __func__, name);
- return 0;
- }
- dprintk(CVP_ERR, "%s regulator %s not found\n", __func__, name);
- return -EINVAL;
- }
- static int __enable_subcaches(struct iris_hfi_device *device)
- {
- int rc = 0;
- u32 c = 0;
- struct subcache_info *sinfo;
- if (msm_cvp_syscache_disable || !is_sys_cache_present(device))
- return 0;
- /* Activate subcaches */
- iris_hfi_for_each_subcache(device, sinfo) {
- rc = llcc_slice_activate(sinfo->subcache);
- if (rc) {
- dprintk(CVP_WARN, "Failed to activate %s: %d\n",
- sinfo->name, rc);
- msm_cvp_res_handle_fatal_hw_error(device->res, true);
- goto err_activate_fail;
- }
- sinfo->isactive = true;
- dprintk(CVP_CORE, "Activated subcache %s\n", sinfo->name);
- c++;
- }
- dprintk(CVP_CORE, "Activated %d Subcaches to CVP\n", c);
- return 0;
- err_activate_fail:
- __release_subcaches(device);
- __disable_subcaches(device);
- return 0;
- }
- static int __set_subcaches(struct iris_hfi_device *device)
- {
- int rc = 0;
- u32 c = 0;
- struct subcache_info *sinfo;
- u32 resource[CVP_MAX_SUBCACHE_SIZE];
- struct cvp_hfi_resource_syscache_info_type *sc_res_info;
- struct cvp_hfi_resource_subcache_type *sc_res;
- struct cvp_resource_hdr rhdr;
- if (device->res->sys_cache_res_set || msm_cvp_syscache_disable) {
- dprintk(CVP_CORE, "Subcaches already set or disabled\n");
- return 0;
- }
- memset((void *)resource, 0x0, (sizeof(u32) * CVP_MAX_SUBCACHE_SIZE));
- sc_res_info = (struct cvp_hfi_resource_syscache_info_type *)resource;
- sc_res = &(sc_res_info->rg_subcache_entries[0]);
- iris_hfi_for_each_subcache(device, sinfo) {
- if (sinfo->isactive) {
- sc_res[c].size = sinfo->subcache->slice_size;
- sc_res[c].sc_id = sinfo->subcache->slice_id;
- c++;
- }
- }
- /* Set resource to CVP for activated subcaches */
- if (c) {
- dprintk(CVP_CORE, "Setting %d Subcaches\n", c);
- rhdr.resource_handle = sc_res_info; /* cookie */
- rhdr.resource_id = CVP_RESOURCE_SYSCACHE;
- sc_res_info->num_entries = c;
- rc = __core_set_resource(device, &rhdr, (void *)sc_res_info);
- if (rc) {
- dprintk(CVP_WARN, "Failed to set subcaches %d\n", rc);
- goto err_fail_set_subacaches;
- }
- iris_hfi_for_each_subcache(device, sinfo) {
- if (sinfo->isactive)
- sinfo->isset = true;
- }
- dprintk(CVP_CORE, "Set Subcaches done to CVP\n");
- device->res->sys_cache_res_set = true;
- }
- return 0;
- err_fail_set_subacaches:
- __disable_subcaches(device);
- return 0;
- }
- static int __release_subcaches(struct iris_hfi_device *device)
- {
- struct subcache_info *sinfo;
- int rc = 0;
- u32 c = 0;
- u32 resource[CVP_MAX_SUBCACHE_SIZE];
- struct cvp_hfi_resource_syscache_info_type *sc_res_info;
- struct cvp_hfi_resource_subcache_type *sc_res;
- struct cvp_resource_hdr rhdr;
- if (msm_cvp_syscache_disable || !is_sys_cache_present(device))
- return 0;
- memset((void *)resource, 0x0, (sizeof(u32) * CVP_MAX_SUBCACHE_SIZE));
- sc_res_info = (struct cvp_hfi_resource_syscache_info_type *)resource;
- sc_res = &(sc_res_info->rg_subcache_entries[0]);
- /* Release resource command to Iris */
- iris_hfi_for_each_subcache_reverse(device, sinfo) {
- if (sinfo->isset) {
- /* Update the entry */
- sc_res[c].size = sinfo->subcache->slice_size;
- sc_res[c].sc_id = sinfo->subcache->slice_id;
- c++;
- sinfo->isset = false;
- }
- }
- if (c > 0) {
- dprintk(CVP_CORE, "Releasing %d subcaches\n", c);
- rhdr.resource_handle = sc_res_info; /* cookie */
- rhdr.resource_id = CVP_RESOURCE_SYSCACHE;
- rc = __core_release_resource(device, &rhdr);
- if (rc)
- dprintk(CVP_WARN,
- "Failed to release %d subcaches\n", c);
- }
- device->res->sys_cache_res_set = false;
- return 0;
- }
- static int __disable_subcaches(struct iris_hfi_device *device)
- {
- struct subcache_info *sinfo;
- int rc = 0;
- if (msm_cvp_syscache_disable || !is_sys_cache_present(device))
- return 0;
- /* De-activate subcaches */
- iris_hfi_for_each_subcache_reverse(device, sinfo) {
- if (sinfo->isactive) {
- dprintk(CVP_CORE, "De-activate subcache %s\n",
- sinfo->name);
- rc = llcc_slice_deactivate(sinfo->subcache);
- if (rc) {
- dprintk(CVP_WARN,
- "Failed to de-activate %s: %d\n",
- sinfo->name, rc);
- }
- sinfo->isactive = false;
- }
- }
- return 0;
- }
- static void interrupt_init_iris2(struct iris_hfi_device *device)
- {
- u32 mask_val = 0;
- /* All interrupts should be disabled initially 0x1F6 : Reset value */
- mask_val = __read_register(device, CVP_WRAPPER_INTR_MASK);
- /* Write 0 to unmask CPU and WD interrupts */
- mask_val &= ~(CVP_FATAL_INTR_BMSK | CVP_WRAPPER_INTR_MASK_A2HCPU_BMSK);
- __write_register(device, CVP_WRAPPER_INTR_MASK, mask_val);
- dprintk(CVP_REG, "Init irq: reg: %x, mask value %x\n",
- CVP_WRAPPER_INTR_MASK, mask_val);
- mask_val = 0;
- mask_val = __read_register(device, CVP_SS_IRQ_MASK);
- mask_val &= ~(CVP_SS_INTR_BMASK);
- __write_register(device, CVP_SS_IRQ_MASK, mask_val);
- dprintk(CVP_REG, "Init irq_wd: reg: %x, mask value %x\n",
- CVP_SS_IRQ_MASK, mask_val);
- }
- static void setup_dsp_uc_memmap_vpu5(struct iris_hfi_device *device)
- {
- /* initialize DSP QTBL & UCREGION with CPU queues */
- __write_register(device, HFI_DSP_QTBL_ADDR,
- (u32)device->dsp_iface_q_table.align_device_addr);
- __write_register(device, HFI_DSP_UC_REGION_ADDR,
- (u32)device->dsp_iface_q_table.align_device_addr);
- __write_register(device, HFI_DSP_UC_REGION_SIZE,
- device->dsp_iface_q_table.mem_data.size);
- }
- static void clock_config_on_enable_vpu5(struct iris_hfi_device *device)
- {
- __write_register(device, CVP_WRAPPER_CPU_CLOCK_CONFIG, 0);
- }
- static int __set_ubwc_config(struct iris_hfi_device *device)
- {
- u8 packet[CVP_IFACEQ_VAR_SMALL_PKT_SIZE];
- int rc = 0;
- struct cvp_hfi_cmd_sys_set_property_packet *pkt =
- (struct cvp_hfi_cmd_sys_set_property_packet *) &packet;
- if (!device->res->ubwc_config)
- return 0;
- rc = call_hfi_pkt_op(device, sys_ubwc_config, pkt,
- device->res->ubwc_config);
- if (rc) {
- dprintk(CVP_WARN,
- "ubwc config setting to FW failed\n");
- rc = -ENOTEMPTY;
- goto fail_to_set_ubwc_config;
- }
- if (__iface_cmdq_write(device, pkt)) {
- rc = -ENOTEMPTY;
- goto fail_to_set_ubwc_config;
- }
- fail_to_set_ubwc_config:
- return rc;
- }
- static int __power_on_controller(struct iris_hfi_device *device)
- {
- int rc = 0;
- rc = __enable_regulator(device, "cvp");
- if (rc) {
- dprintk(CVP_ERR, "Failed to enable ctrler: %d\n", rc);
- return rc;
- }
- rc = msm_cvp_prepare_enable_clk(device, "sleep_clk");
- if (rc) {
- dprintk(CVP_ERR, "Failed to enable sleep clk: %d\n", rc);
- goto fail_reset_clks;
- }
- rc = call_iris_op(device, reset_control_assert_name, device, "cvp_axi_reset");
- if (rc)
- dprintk(CVP_ERR, "%s: assert cvp_axi_reset failed\n", __func__);
- rc = call_iris_op(device, reset_control_assert_name, device, "cvp_core_reset");
- if (rc)
- dprintk(CVP_ERR, "%s: assert cvp_core_reset failed\n", __func__);
- /* wait for deassert */
- usleep_range(300, 400);
- rc = call_iris_op(device, reset_control_deassert_name, device, "cvp_axi_reset");
- if (rc)
- dprintk(CVP_ERR, "%s: de-assert cvp_axi_reset failed\n", __func__);
- rc = call_iris_op(device, reset_control_deassert_name, device, "cvp_core_reset");
- if (rc)
- dprintk(CVP_ERR, "%s: de-assert cvp_core_reset failed\n", __func__);
- rc = msm_cvp_prepare_enable_clk(device, "gcc_video_axi1");
- if (rc) {
- dprintk(CVP_ERR, "Failed to enable axi1 clk: %d\n", rc);
- goto fail_reset_clks;
- }
- rc = msm_cvp_prepare_enable_clk(device, "cvp_clk");
- if (rc) {
- dprintk(CVP_ERR, "Failed to enable cvp_clk: %d\n", rc);
- goto fail_enable_clk;
- }
- dprintk(CVP_PWR, "EVA controller powered on\n");
- return 0;
- fail_enable_clk:
- msm_cvp_disable_unprepare_clk(device, "gcc_video_axi1");
- fail_reset_clks:
- __disable_regulator(device, "cvp");
- return rc;
- }
- static int __power_on_core(struct iris_hfi_device *device)
- {
- int rc = 0;
- rc = __enable_regulator(device, "cvp-core");
- if (rc) {
- dprintk(CVP_ERR, "Failed to enable core: %d\n", rc);
- return rc;
- }
- rc = msm_cvp_prepare_enable_clk(device, "video_cc_mvs1_clk_src");
- if (rc) {
- dprintk(CVP_ERR, "Failed to enable video_cc_mvs1_clk_src:%d\n",
- rc);
- __disable_regulator(device, "cvp-core");
- return rc;
- }
- rc = msm_cvp_prepare_enable_clk(device, "core_clk");
- if (rc) {
- dprintk(CVP_ERR, "Failed to enable core_clk: %d\n", rc);
- __disable_regulator(device, "cvp-core");
- return rc;
- }
- /*#ifdef CONFIG_EVA_PINEAPPLE
- __write_register(device, CVP_AON_WRAPPER_CVP_NOC_ARCG_CONTROL, 0);
- __write_register(device, CVP_NOC_RCGCONTROLLER_HYSTERESIS_LOW, 0x2f);
- __write_register(device, CVP_NOC_RCG_VNOC_NOC_CLK_FORCECLOCKON_LOW, 1);
- __write_register(device, CVP_NOC_RCGCONTROLLER_MAINCTL_LOW, 1);
- usleep_range(50, 100);
- __write_register(device, CVP_NOC_RCG_VNOC_NOC_CLK_FORCECLOCKON_LOW, 0);
- #endif*/
- dprintk(CVP_PWR, "EVA core powered on\n");
- return 0;
- }
- static int __iris_power_on(struct iris_hfi_device *device)
- {
- int rc = 0;
- u32 reg_gdsc, reg_cbcr, spare_val;
- if (device->power_enabled)
- return 0;
- /* Vote for all hardware resources */
- rc = __vote_buses(device, device->bus_vote.data,
- device->bus_vote.data_count);
- if (rc) {
- dprintk(CVP_ERR, "Failed to vote buses, err: %d\n", rc);
- goto fail_vote_buses;
- }
- rc = __power_on_controller(device);
- if (rc)
- goto fail_enable_controller;
- rc = __power_on_core(device);
- if (rc)
- goto fail_enable_core;
- rc = msm_cvp_scale_clocks(device);
- if (rc) {
- dprintk(CVP_WARN,
- "Failed to scale clocks, perf may regress\n");
- rc = 0;
- } else {
- dprintk(CVP_PWR, "Done with scaling\n");
- }
- /*Do not access registers before this point!*/
- device->power_enabled = true;
- /* Thomas input to debug CPU NoC hang */
- __write_register(device, CVP_NOC_SBM_FAULTINEN0_LOW, 0x1);
- __write_register(device, CVP_NOC_ERR_MAINCTL_LOW_OFFS, 0x3);
- /*
- * Re-program all of the registers that get reset as a result of
- * regulator_disable() and _enable()
- * calling below function requires CORE powered on
- */
- rc = __set_registers(device);
- if (rc)
- goto fail_enable_core;
- dprintk(CVP_CORE, "Done with register set\n");
- reg_gdsc = __read_register(device, CVP_CC_MVS1_GDSCR);
- reg_cbcr = __read_register(device, CVP_CC_MVS1_CBCR);
- if (!(reg_gdsc & 0x80000000) || (reg_cbcr & 0x80000000)) {
- rc = -EINVAL;
- dprintk(CVP_ERR, "CORE power on failed gdsc %x cbcr %x\n",
- reg_gdsc, reg_cbcr);
- goto fail_enable_core;
- }
- reg_gdsc = __read_register(device, CVP_CC_MVS1C_GDSCR);
- reg_cbcr = __read_register(device, CVP_CC_MVS1C_CBCR);
- if (!(reg_gdsc & 0x80000000) || (reg_cbcr & 0x80000000)) {
- rc = -EINVAL;
- dprintk(CVP_ERR, "CTRL power on failed gdsc %x cbcr %x\n",
- reg_gdsc, reg_cbcr);
- goto fail_enable_core;
- }
- spare_val = __read_register(device, CVP_AON_WRAPPER_SPARE);
- if ((spare_val & 0x2) != 0) {
- usleep_range(2000, 3000);
- spare_val = __read_register(device, CVP_AON_WRAPPER_SPARE);
- if ((spare_val & 0x2) != 0) {
- dprintk(CVP_ERR, "WRAPPER_SPARE non-zero %#x\n", spare_val);
- rc = -EINVAL;
- goto fail_enable_core;
- }
- }
- call_iris_op(device, interrupt_init, device);
- dprintk(CVP_CORE, "Done with interrupt enabling\n");
- device->intr_status = 0;
- enable_irq(device->cvp_hal_data->irq);
- __write_register(device,
- CVP_WRAPPER_DEBUG_BRIDGE_LPI_CONTROL, 0x7);
- pr_info_ratelimited(CVP_DBG_TAG "cvp (eva) powered on\n", "pwr");
- return 0;
- fail_enable_core:
- __power_off_controller(device);
- fail_enable_controller:
- __unvote_buses(device);
- fail_vote_buses:
- device->power_enabled = false;
- return rc;
- }
- static inline int __suspend(struct iris_hfi_device *device)
- {
- int rc = 0;
- if (!device) {
- dprintk(CVP_ERR, "Invalid params: %pK\n", device);
- return -EINVAL;
- } else if (!device->power_enabled) {
- dprintk(CVP_PWR, "Power already disabled\n");
- return 0;
- }
- dprintk(CVP_PWR, "Entering suspend\n");
- rc = __tzbsp_set_cvp_state(TZ_SUBSYS_STATE_SUSPEND);
- if (rc) {
- dprintk(CVP_WARN, "Failed to suspend cvp core %d\n", rc);
- goto err_tzbsp_suspend;
- }
- __disable_subcaches(device);
- call_iris_op(device, power_off, device);
- if (device->res->pm_qos.latency_us && device->res->pm_qos.pm_qos_hdls)
- cvp_pm_qos_update(device, false);
- return rc;
- err_tzbsp_suspend:
- return rc;
- }
- static void __print_sidebandmanager_regs(struct iris_hfi_device *device)
- {
- u32 sbm_ln0_low, axi_cbcr, val;
- u32 main_sbm_ln0_low = 0xdeadbeef, main_sbm_ln0_high = 0xdeadbeef;
- u32 main_sbm_ln1_high = 0xdeadbeef, cpu_cs_x2rpmh;
- int rc;
- sbm_ln0_low =
- __read_register(device, CVP_NOC_SBM_SENSELN0_LOW);
- cpu_cs_x2rpmh = __read_register(device, CVP_CPU_CS_X2RPMh);
- __write_register(device, CVP_CPU_CS_X2RPMh,
- (cpu_cs_x2rpmh | CVP_CPU_CS_X2RPMh_SWOVERRIDE_BMSK));
- usleep_range(500, 1000);
- cpu_cs_x2rpmh = __read_register(device, CVP_CPU_CS_X2RPMh);
- if (!(cpu_cs_x2rpmh & CVP_CPU_CS_X2RPMh_SWOVERRIDE_BMSK)) {
- dprintk(CVP_WARN,
- "failed set CVP_CPU_CS_X2RPMH mask %x\n",
- cpu_cs_x2rpmh);
- goto exit;
- }
- axi_cbcr = __read_gcc_register(device, CVP_GCC_VIDEO_AXI1_CBCR);
- if (axi_cbcr & 0x80000000) {
- dprintk(CVP_WARN, "failed to turn on AXI clock %x\n",
- axi_cbcr);
- goto exit;
- }
- /* Added by Thomas to debug CPU NoC hang */
- val = __read_register(device, CVP_NOC_ERR_ERRVLD_LOW_OFFS);
- dprintk(CVP_ERR, "CVP_NOC_ERL_MAIN_ERRVLD_LOW %#x\n", val);
- val = __read_register(device, CVP_NOC_SBM_FAULTINSTATUS0_LOW);
- dprintk(CVP_ERR, "CVP_NOC_SBM_FAULTINSTATUS0_LOW %#x\n", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG0_LOW_OFFS);
- dprintk(CVP_ERR, "CVP_NOC_ERL_MAIN_ERRLOG0_LOW %#x\n", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG0_HIGH_OFFS);
- dprintk(CVP_ERR, "CVP_NOC_ERL_MAIN_ERRLOG0_HIGH %#x\n", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG1_LOW_OFFS);
- dprintk(CVP_ERR, "CVP_NOC_ERL_MAIN_ERRLOG1_LOW %#x\n", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG1_HIGH_OFFS);
- dprintk(CVP_ERR, "CVP_NOC_ERL_MAIN_ERRLOG1_HIGH %#x\n", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG2_LOW_OFFS);
- dprintk(CVP_ERR, "CVP_NOC_ERL_MAIN_ERRLOG2_LOW %#x\n", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG2_HIGH_OFFS);
- dprintk(CVP_ERR, "CVP_NOC_ERL_MAIN_ERRLOG2_HIGH %#x\n", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG3_LOW_OFFS);
- dprintk(CVP_ERR, "CVP_NOC_ERL_MAIN_ERRLOG3_LOW %#x\n", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG3_HIGH_OFFS);
- dprintk(CVP_ERR, "CVP_NOC_ERL_MAIN_ERRLOG3_HIGH %#x\n", val);
- /* end of addition */
- rc = call_iris_op(device, reset_control_acquire_name, device, "cvp_xo_reset");
- if (rc) {
- dprintk(CVP_WARN, "%s Fail acquire xo_reset\n", __func__);
- goto exit;
- }
- main_sbm_ln0_low = __read_register(device,
- CVP_NOC_MAIN_SIDEBANDMANAGER_SENSELN0_LOW +
- device->res->noc_main_sidebandmanager_offset);
- main_sbm_ln0_high = __read_register(device,
- CVP_NOC_MAIN_SIDEBANDMANAGER_SENSELN0_HIGH +
- device->res->noc_main_sidebandmanager_offset);
- main_sbm_ln1_high = __read_register(device,
- CVP_NOC_MAIN_SIDEBANDMANAGER_SENSELN1_HIGH +
- device->res->noc_main_sidebandmanager_offset);
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- exit:
- cpu_cs_x2rpmh = cpu_cs_x2rpmh & (~CVP_CPU_CS_X2RPMh_SWOVERRIDE_BMSK);
- __write_register(device, CVP_CPU_CS_X2RPMh, cpu_cs_x2rpmh);
- dprintk(CVP_WARN, "Sidebandmanager regs %x %x %x %x %x\n",
- sbm_ln0_low, main_sbm_ln0_low,
- main_sbm_ln0_high, main_sbm_ln1_high,
- cpu_cs_x2rpmh);
- }
- static void __enter_cpu_noc_lpi(struct iris_hfi_device *device)
- {
- u32 lpi_status, count = 0, max_count = 2000;
- /* New addition to put CPU/Tensilica to low power */
- count = 0;
- __write_register(device, CVP_WRAPPER_CPU_NOC_LPI_CONTROL, 0x1);
- while (count < max_count) {
- lpi_status = __read_register(device, CVP_WRAPPER_CPU_NOC_LPI_STATUS);
- if ((lpi_status & BIT(1)) || ((lpi_status & BIT(2)) && (!(lpi_status & BIT(0))))) {
- /*
- * If QDENY == true, or
- * If QACTIVE == true && QACCEPT == false
- * Try again
- */
- __write_register(device, CVP_WRAPPER_CPU_NOC_LPI_CONTROL, 0x0);
- usleep_range(10, 20);
- __write_register(device, CVP_WRAPPER_CPU_NOC_LPI_CONTROL, 0x1);
- usleep_range(1000, 1200);
- count++;
- } else {
- break;
- }
- }
- dprintk(CVP_PWR,
- "%s, CPU Noc: lpi_status %x (count %d)\n", __func__, lpi_status, count);
- if (count == max_count) {
- u32 pc_ready, wfi_status;
- wfi_status = __read_register(device, CVP_WRAPPER_CPU_STATUS);
- pc_ready = __read_register(device, CVP_CTRL_STATUS);
- dprintk(CVP_WARN,
- "%s, CPU NOC not in qaccept status %x %x %x\n",
- __func__, lpi_status, wfi_status, pc_ready);
- __print_sidebandmanager_regs(device);
- }
- }
- static int __power_off_controller(struct iris_hfi_device *device)
- {
- u32 lpi_status, count = 0, max_count = 1000;
- int rc;
- u32 spare_val, spare_status;
- /* HPG 6.2.2 Step 1 */
- __write_register(device, CVP_CPU_CS_X2RPMh, 0x3);
- /* HPG 6.2.2 Step 2, noc to low power */
- __enter_cpu_noc_lpi(device);
- /* HPG 6.2.2 Step 3, debug bridge to low power BYPASSED */
- /* HPG 6.2.2 Step 4, debug bridge to lpi release */
- __write_register(device,
- CVP_WRAPPER_DEBUG_BRIDGE_LPI_CONTROL, 0x0);
- lpi_status = 0x1;
- count = 0;
- while (lpi_status && count < max_count) {
- lpi_status = __read_register(device,
- CVP_WRAPPER_DEBUG_BRIDGE_LPI_STATUS);
- usleep_range(50, 100);
- count++;
- }
- dprintk(CVP_PWR,
- "DBLP Release: lpi_status %d(count %d)\n",
- lpi_status, count);
- if (count == max_count) {
- dprintk(CVP_WARN,
- "DBLP Release: lpi_status %x\n", lpi_status);
- }
- /* PDXFIFO reset: addition for Kailua / Lanai */
- __write_register(device, CVP_WRAPPER_AXI_CLOCK_CONFIG, 0x3);
- __write_register(device, CVP_WRAPPER_QNS4PDXFIFO_RESET, 0x1);
- __write_register(device, CVP_WRAPPER_QNS4PDXFIFO_RESET, 0x0);
- __write_register(device, CVP_WRAPPER_AXI_CLOCK_CONFIG, 0x0);
- /* HPG 6.2.2 Step 5 */
- msm_cvp_disable_unprepare_clk(device, "cvp_clk");
- rc = call_iris_op(device, reset_control_assert_name, device, "cvp_axi_reset");
- if (rc)
- dprintk(CVP_ERR, "%s: assert cvp_axi_reset failed\n", __func__);
- rc = call_iris_op(device, reset_control_assert_name, device, "cvp_core_reset");
- if (rc)
- dprintk(CVP_ERR, "%s: assert cvp_core_reset failed\n", __func__);
- /* wait for deassert */
- usleep_range(1000, 1050);
- rc = call_iris_op(device, reset_control_deassert_name, device, "cvp_axi_reset");
- if (rc)
- dprintk(CVP_ERR, "%s: de-assert cvp_axi_reset failed\n", __func__);
- rc = call_iris_op(device, reset_control_deassert_name, device, "cvp_core_reset");
- if (rc)
- dprintk(CVP_ERR, "%s: de-assert cvp_core_reset failed\n", __func__);
- /* disable EVA NoC clock */
- __write_register(device, CVP_AON_WRAPPER_CVP_NOC_CORE_CLK_CONTROL, 0x1);
- /* enable EVA NoC reset */
- __write_register(device, CVP_AON_WRAPPER_CVP_NOC_CORE_SW_RESET, 0x1);
- rc = call_iris_op(device, reset_control_acquire_name, device, "cvp_xo_reset");
- if (rc) {
- dprintk(CVP_ERR, "FATAL ERROR, HPG step 17 to 20 will be bypassed\n");
- goto skip_xo_reset;
- }
- spare_status = 0x1;
- while (spare_status != 0x0) {
- spare_val = __read_register(device, CVP_AON_WRAPPER_SPARE);
- spare_status = spare_val & 0x2;
- usleep_range(50, 100);
- }
- __write_register(device, CVP_AON_WRAPPER_SPARE, 0x1);
- rc = call_iris_op(device, reset_control_assert_name, device, "cvp_xo_reset");
- if (rc)
- dprintk(CVP_ERR, "%s: assert cvp_xo_reset failed\n", __func__);
- /* de-assert EVA_NoC reset */
- __write_register(device, CVP_AON_WRAPPER_CVP_NOC_CORE_SW_RESET, 0x0);
- /* de-assert EVA video_cc XO reset and enable video_cc XO clock after 80us */
- usleep_range(80, 100);
- rc = call_iris_op(device, reset_control_deassert_name, device, "cvp_xo_reset");
- if (rc)
- dprintk(CVP_ERR, "%s: de-assert cvp_xo_reset failed\n", __func__);
- /* clear XO mask bit - this step was missing in previous sequence */
- __write_register(device, CVP_AON_WRAPPER_SPARE, 0x0);
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- skip_xo_reset:
- /* enable EVA NoC clock */
- __write_register(device, CVP_AON_WRAPPER_CVP_NOC_CORE_CLK_CONTROL, 0x0);
- /* De-assert EVA_CTL Force Sleep Retention */
- usleep_range(400, 500);
- /* HPG 6.2.2 Step 6 */
- __disable_regulator(device, "cvp");
- /* HPG 6.2.2 Step 7 */
- rc = msm_cvp_disable_unprepare_clk(device, "gcc_video_axi1");
- if (rc) {
- dprintk(CVP_ERR, "Failed to enable axi1 clk: %d\n", rc);
- }
- rc = msm_cvp_disable_unprepare_clk(device, "sleep_clk");
- if (rc) {
- dprintk(CVP_ERR, "Failed to disable sleep clk: %d\n", rc);
- }
- return 0;
- }
- static int __power_off_core(struct iris_hfi_device *device)
- {
- u32 reg_status = 0, lpi_status, config, value = 0, count = 0;
- u32 warn_flag = 0, max_count = 10;
- value = __read_register(device, CVP_CC_MVS1_GDSCR);
- if (!(value & 0x80000000)) {
- /*
- * Core has been powered off by f/w.
- * Check NOC reset registers to ensure
- * NO outstanding NoC transactions
- */
- value = __read_register(device, CVP_NOC_RESET_ACK);
- if (value) {
- dprintk(CVP_WARN,
- "Core off with NOC RESET ACK non-zero %x\n",
- value);
- __print_sidebandmanager_regs(device);
- }
- __disable_regulator(device, "cvp-core");
- msm_cvp_disable_unprepare_clk(device, "core_clk");
- msm_cvp_disable_unprepare_clk(device, "video_cc_mvs1_clk_src");
- return 0;
- } else if (!(value & 0x2)) {
- /*
- * HW_CONTROL PC disabled, then core is powered on for
- * CVP NoC access
- */
- __disable_regulator(device, "cvp-core");
- msm_cvp_disable_unprepare_clk(device, "core_clk");
- msm_cvp_disable_unprepare_clk(device, "video_cc_mvs1_clk_src");
- return 0;
- }
- dprintk(CVP_PWR, "Driver controls Core power off now\n");
- /*
- * check to make sure core clock branch enabled else
- * we cannot read core idle register
- */
- config = __read_register(device, CVP_WRAPPER_CORE_CLOCK_CONFIG);
- if (config) {
- dprintk(CVP_PWR,
- "core clock config not enabled, enable it to access core\n");
- __write_register(device, CVP_WRAPPER_CORE_CLOCK_CONFIG, 0);
- }
- /*
- * add MNoC idle check before collapsing MVS1 per HPG update
- * poll for NoC DMA idle -> HPG 6.2.1
- *
- */
- do {
- value = __read_register(device, CVP_SS_IDLE_STATUS);
- if (value & 0x400000)
- break;
- else
- usleep_range(1000, 2000);
- count++;
- } while (count < max_count);
- if (count == max_count) {
- dprintk(CVP_WARN, "Core fail to go idle %x\n", value);
- warn_flag = 1;
- }
- count = 0;
- max_count = 1000;
- __write_register(device, CVP_AON_WRAPPER_CVP_NOC_LPI_CONTROL, 0x1);
- while (!reg_status && count < max_count) {
- lpi_status =
- __read_register(device,
- CVP_AON_WRAPPER_CVP_NOC_LPI_STATUS);
- reg_status = lpi_status & BIT(0);
- /* Wait for Core noc lpi status to be set */
- usleep_range(50, 100);
- count++;
- }
- dprintk(CVP_PWR,
- "Core Noc: lpi_status %x noc_status %x (count %d)\n",
- lpi_status, reg_status, count);
- if (count == max_count) {
- u32 pc_ready, wfi_status;
- wfi_status = __read_register(device, CVP_WRAPPER_CPU_STATUS);
- pc_ready = __read_register(device, CVP_CTRL_STATUS);
- dprintk(CVP_WARN,
- "Core NOC not in qaccept status %x %x %x %x\n",
- reg_status, lpi_status, wfi_status, pc_ready);
- __print_sidebandmanager_regs(device);
- }
- __write_register(device, CVP_AON_WRAPPER_CVP_NOC_LPI_CONTROL, 0x0);
- if (warn_flag)
- __print_sidebandmanager_regs(device);
- /* Reset both sides of 2 ahb2ahb_bridges (TZ and non-TZ) */
- __write_register(device, CVP_AHB_BRIDGE_SYNC_RESET, 0x3);
- __write_register(device, CVP_AHB_BRIDGE_SYNC_RESET, 0x2);
- __write_register(device, CVP_AHB_BRIDGE_SYNC_RESET, 0x0);
- __write_register(device, CVP_WRAPPER_CORE_CLOCK_CONFIG, config);
- __disable_hw_power_collapse(device);
- usleep_range(100, 200);
- __disable_regulator(device, "cvp-core");
- msm_cvp_disable_unprepare_clk(device, "core_clk");
- msm_cvp_disable_unprepare_clk(device, "video_cc_mvs1_clk_src");
- return 0;
- }
- static void power_off_iris2(struct iris_hfi_device *device)
- {
- if (!device->power_enabled || !device->res->sw_power_collapsible)
- return;
- if (!(device->intr_status & CVP_WRAPPER_INTR_STATUS_A2HWD_BMSK))
- disable_irq_nosync(device->cvp_hal_data->irq);
- device->intr_status = 0;
- __power_off_core(device);
- __power_off_controller(device);
- if (__unvote_buses(device))
- dprintk(CVP_WARN, "Failed to unvote for buses\n");
- /*Do not access registers after this point!*/
- device->power_enabled = false;
- pr_info(CVP_DBG_TAG "cvp (eva) power collapsed\n", "pwr");
- }
- static inline int __resume(struct iris_hfi_device *device)
- {
- int rc = 0;
- struct msm_cvp_core *core;
- if (!device) {
- dprintk(CVP_ERR, "Invalid params: %pK\n", device);
- return -EINVAL;
- } else if (device->power_enabled) {
- goto exit;
- } else if (!__core_in_valid_state(device)) {
- dprintk(CVP_PWR, "iris_hfi_device in deinit state.");
- return -EINVAL;
- }
- core = cvp_driver->cvp_core;
- dprintk(CVP_PWR, "Resuming from power collapse\n");
- rc = __iris_power_on(device);
- if (rc) {
- dprintk(CVP_ERR, "Failed to power on cvp\n");
- goto err_iris_power_on;
- }
- __setup_ucregion_memory_map(device);
- /* RUMI: set CVP_CTRL_INIT register to disable synx in FW */
- /* Reboot the firmware */
- rc = __tzbsp_set_cvp_state(TZ_SUBSYS_STATE_RESUME);
- if (rc) {
- dprintk(CVP_ERR, "Failed to resume cvp core %d\n", rc);
- goto err_set_cvp_state;
- }
- /* Wait for boot completion */
- rc = __boot_firmware(device);
- if (rc) {
- dprintk(CVP_ERR, "Failed to reset cvp core\n");
- goto err_reset_core;
- }
- /*
- * Work around for H/W bug, need to reprogram these registers once
- * firmware is out reset
- */
- __set_threshold_registers(device);
- if (device->res->pm_qos.latency_us && device->res->pm_qos.pm_qos_hdls)
- cvp_pm_qos_update(device, true);
- __sys_set_debug(device, msm_cvp_fw_debug);
- __enable_subcaches(device);
- __set_subcaches(device);
- __dsp_resume(device);
- dprintk(CVP_PWR, "Resumed from power collapse\n");
- exit:
- /* Don't reset skip_pc_count for SYS_PC_PREP cmd */
- if (device->last_packet_type != HFI_CMD_SYS_PC_PREP)
- device->skip_pc_count = 0;
- return rc;
- err_reset_core:
- __tzbsp_set_cvp_state(TZ_SUBSYS_STATE_SUSPEND);
- err_set_cvp_state:
- call_iris_op(device, power_off, device);
- err_iris_power_on:
- dprintk(CVP_ERR, "Failed to resume from power collapse\n");
- return rc;
- }
- static int __power_on_init(struct iris_hfi_device *device)
- {
- int rc = 0;
- /* Initialize resources */
- rc = __init_resources(device, device->res);
- if (rc) {
- dprintk(CVP_ERR, "Failed to init resources: %d\n", rc);
- return rc;
- }
- rc = __initialize_packetization(device);
- if (rc) {
- dprintk(CVP_ERR, "Failed to initialize packetization\n");
- goto fail_iris_init;
- }
- rc = __iris_power_on(device);
- if (rc) {
- dprintk(CVP_ERR, "Failed to power on iris in in load_fw\n");
- goto fail_iris_init;
- }
- return rc;
- fail_iris_init:
- __deinit_resources(device);
- return rc;
- }
- static int __load_fw(struct iris_hfi_device *device)
- {
- int rc = 0;
- if ((!device->res->use_non_secure_pil && !device->res->firmware_base)
- || device->res->use_non_secure_pil) {
- rc = load_cvp_fw_impl(device);
- if (rc)
- goto fail_load_fw;
- }
- return rc;
- fail_load_fw:
- call_iris_op(device, power_off, device);
- return rc;
- }
- static void __unload_fw(struct iris_hfi_device *device)
- {
- if (!device->resources.fw.cookie)
- return;
- cancel_delayed_work(&iris_hfi_pm_work);
- if (device->state != IRIS_STATE_DEINIT)
- flush_workqueue(device->iris_pm_workq);
- /* New addition to put CPU/Tensilica to low power */
- __enter_cpu_noc_lpi(device);
- unload_cvp_fw_impl(device);
- __interface_queues_release(device);
- call_iris_op(device, power_off, device);
- __deinit_resources(device);
- dprintk(CVP_WARN, "Firmware unloaded\n");
- }
- static int iris_hfi_get_fw_info(void *dev, struct cvp_hal_fw_info *fw_info)
- {
- int i = 0;
- struct iris_hfi_device *device = dev;
- if (!device || !fw_info) {
- dprintk(CVP_ERR,
- "%s Invalid parameter: device = %pK fw_info = %pK\n",
- __func__, device, fw_info);
- return -EINVAL;
- }
- mutex_lock(&device->lock);
- while (cvp_driver->fw_version[i++] != 'V' && i < CVP_VERSION_LENGTH)
- ;
- if (i == CVP_VERSION_LENGTH - 1) {
- dprintk(CVP_WARN, "Iris version string is not proper\n");
- fw_info->version[0] = '\0';
- goto fail_version_string;
- }
- memcpy(&fw_info->version[0], &cvp_driver->fw_version[0],
- CVP_VERSION_LENGTH);
- fw_info->version[CVP_VERSION_LENGTH - 1] = '\0';
- fail_version_string:
- dprintk(CVP_CORE, "F/W version retrieved : %s\n", fw_info->version);
- fw_info->base_addr = device->cvp_hal_data->firmware_base;
- fw_info->register_base = device->res->register_base;
- fw_info->register_size = device->cvp_hal_data->register_size;
- fw_info->irq = device->cvp_hal_data->irq;
- mutex_unlock(&device->lock);
- return 0;
- }
- static int iris_hfi_get_core_capabilities(void *dev)
- {
- dprintk(CVP_CORE, "%s not supported yet!\n", __func__);
- return 0;
- }
- static const char * const mid_names[16] = {
- "CVP_FW",
- "ARP_DATA",
- "CVP_MPU_PIXEL",
- "CVP_MPU_NON_PIXEL",
- "CVP_FDU_PIXEL",
- "CVP_FDU_NON_PIXEL",
- "CVP_GCE_PIXEL",
- "CVP_GCE_NON_PIXEL",
- "CVP_TOF_PIXEL",
- "CVP_TOF_NON_PIXEL",
- "CVP_VADL_PIXEL",
- "CVP_VADL_NON_PIXEL",
- "CVP_RGE_NON_PIXEL",
- "CVP_CDM",
- "Invalid",
- "Invalid"
- };
- static void __print_reg_details(u32 val)
- {
- u32 mid, sid;
- mid = (val >> 5) & 0xF;
- sid = (val >> 2) & 0x7;
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG3_LOW: %#x\n", val);
- dprintk(CVP_ERR, "Sub-client:%s, SID: %d\n", mid_names[mid], sid);
- }
- static void __err_log(bool logging, u32 *data, const char *name, u32 val)
- {
- if (logging)
- *data = val;
- dprintk(CVP_ERR, "%s: %#x\n", name, val);
- }
- static void __noc_error_info_iris2(struct iris_hfi_device *device)
- {
- struct msm_cvp_core *core;
- struct cvp_noc_log *noc_log;
- u32 val = 0, regi, regii, regiii;
- bool log_required = false;
- int rc;
- core = cvp_driver->cvp_core;
- if (!core->ssr_count && core->resources.max_ssr_allowed > 1)
- log_required = true;
- noc_log = &core->log.noc_log;
- if (noc_log->used) {
- dprintk(CVP_WARN, "Data already in NoC log, skip logging\n");
- return;
- }
- noc_log->used = 1;
- __disable_hw_power_collapse(device);
- val = __read_register(device, CVP_CC_MVS1_GDSCR);
- regi = __read_register(device, CVP_AON_WRAPPER_CVP_NOC_CORE_CLK_CONTROL);
- regii = __read_register(device, CVP_CC_MVS1_CBCR);
- regiii = __read_register(device, CVP_WRAPPER_CORE_CLOCK_CONFIG);
- dprintk(CVP_ERR, "noc reg check: %#x %#x %#x %#x\n",
- val, regi, regii, regiii);
- val = __read_register(device, CVP_NOC_ERR_SWID_LOW_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_swid_low,
- "CVP_NOC_ERL_MAIN_SWID_LOW", val);
- val = __read_register(device, CVP_NOC_ERR_SWID_HIGH_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_swid_high,
- "CVP_NOC_ERL_MAIN_SWID_HIGH", val);
- val = __read_register(device, CVP_NOC_ERR_MAINCTL_LOW_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_mainctl_low,
- "CVP_NOC_ERL_MAIN_MAINCTL_LOW", val);
- val = __read_register(device, CVP_NOC_ERR_ERRVLD_LOW_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_errvld_low,
- "CVP_NOC_ERL_MAIN_ERRVLD_LOW", val);
- val = __read_register(device, CVP_NOC_ERR_ERRCLR_LOW_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_errclr_low,
- "CVP_NOC_ERL_MAIN_ERRCLR_LOW", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG0_LOW_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_errlog0_low,
- "CVP_NOC_ERL_MAIN_ERRLOG0_LOW", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG0_HIGH_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_errlog0_high,
- "CVP_NOC_ERL_MAIN_ERRLOG0_HIGH", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG1_LOW_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_errlog1_low,
- "CVP_NOC_ERL_MAIN_ERRLOG1_LOW", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG1_HIGH_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_errlog1_high,
- "CVP_NOC_ERL_MAIN_ERRLOG1_HIGH", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG2_LOW_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_errlog2_low,
- "CVP_NOC_ERL_MAIN_ERRLOG2_LOW", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG2_HIGH_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_errlog2_high,
- "CVP_NOC_ERL_MAIN_ERRLOG2_HIGH", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG3_LOW_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_errlog3_low,
- "CVP_NOC_ERL_MAIN_ERRLOG3_LOW", val);
- val = __read_register(device, CVP_NOC_ERR_ERRLOG3_HIGH_OFFS);
- __err_log(log_required, &noc_log->err_ctrl_errlog3_high,
- "CVP_NOC_ERL_MAIN_ERRLOG3_HIGH", val);
- rc = call_iris_op(device, reset_control_acquire_name, device, "cvp_xo_reset");
- if (rc) {
- dprintk(CVP_WARN, "%s Fail acquire xo_reset\n", __func__);
- return;
- }
- val = __read_register(device,
- CVP_NOC_CORE_ERR_SWID_LOW_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_swid_low,
- "CVP_NOC__CORE_ERL_MAIN_SWID_LOW", val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_SWID_HIGH_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_swid_high,
- "CVP_NOC_CORE_ERL_MAIN_SWID_HIGH", val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_MAINCTL_LOW_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_mainctl_low,
- "CVP_NOC_CORE_ERL_MAIN_MAINCTL_LOW", val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_ERRVLD_LOW_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_errvld_low,
- "CVP_NOC_CORE_ERL_MAIN_ERRVLD_LOW", val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_ERRCLR_LOW_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_errclr_low,
- "CVP_NOC_CORE_ERL_MAIN_ERRCLR_LOW", val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_ERRLOG0_LOW_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_errlog0_low,
- "CVP_NOC_CORE_ERL_MAIN_ERRLOG0_LOW", val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_ERRLOG0_HIGH_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_errlog0_high,
- "CVP_NOC_CORE_ERL_MAIN_ERRLOG0_HIGH", val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_ERRLOG1_LOW_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_errlog1_low,
- "CVP_NOC_CORE_ERL_MAIN_ERRLOG1_LOW", val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_ERRLOG1_HIGH_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_errlog1_high,
- "CVP_NOC_CORE_ERL_MAIN_ERRLOG1_HIGH", val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_ERRLOG2_LOW_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_errlog2_low,
- "CVP_NOC_CORE_ERL_MAIN_ERRLOG2_LOW", val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_ERRLOG2_HIGH_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_errlog2_high,
- "CVP_NOC_CORE_ERL_MAIN_ERRLOG2_HIGH", val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_ERRLOG3_LOW_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_errlog3_low,
- "CORE ERRLOG3_LOW, below details", val);
- __print_reg_details(val);
- val = __read_register(device,
- CVP_NOC_CORE_ERR_ERRLOG3_HIGH_OFFS + device->res->noc_core_err_offset);
- __err_log(log_required, &noc_log->err_core_errlog3_high,
- "CVP_NOC_CORE_ERL_MAIN_ERRLOG3_HIGH", val);
- __write_register(device,
- CVP_NOC_CORE_ERR_ERRCLR_LOW_OFFS + device->res->noc_core_err_offset, 0x1);
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- #define CVP_SS_CLK_HALT 0x8
- #define CVP_SS_CLK_EN 0xC
- #define CVP_SS_ARP_TEST_BUS_CONTROL 0x700
- #define CVP_SS_ARP_TEST_BUS_REGISTER 0x704
- #define CVP_DMA_TEST_BUS_CONTROL 0x66A0
- #define CVP_DMA_TEST_BUS_REGISTER 0x66A4
- #define CVP_VPU_WRAPPER_CORE_CONFIG 0xB0088
- __write_register(device, CVP_SS_CLK_HALT, 0);
- __write_register(device, CVP_SS_CLK_EN, 0x3f);
- __write_register(device, CVP_VPU_WRAPPER_CORE_CONFIG, 0);
- }
- static int iris_hfi_noc_error_info(void *dev)
- {
- struct iris_hfi_device *device;
- if (!dev) {
- dprintk(CVP_ERR, "%s: null device\n", __func__);
- return -EINVAL;
- }
- device = dev;
- mutex_lock(&device->lock);
- dprintk(CVP_ERR, "%s: non error information\n", __func__);
- call_iris_op(device, noc_error_info, device);
- mutex_unlock(&device->lock);
- return 0;
- }
- static int __initialize_packetization(struct iris_hfi_device *device)
- {
- int rc = 0;
- if (!device || !device->res) {
- dprintk(CVP_ERR, "%s - invalid param\n", __func__);
- return -EINVAL;
- }
- device->packetization_type = HFI_PACKETIZATION_4XX;
- device->pkt_ops = cvp_hfi_get_pkt_ops_handle(
- device->packetization_type);
- if (!device->pkt_ops) {
- rc = -EINVAL;
- dprintk(CVP_ERR, "Failed to get pkt_ops handle\n");
- }
- return rc;
- }
- void __init_cvp_ops(struct iris_hfi_device *device)
- {
- device->hal_ops = &hal_ops;
- }
- static struct iris_hfi_device *__add_device(struct msm_cvp_platform_resources *res,
- hfi_cmd_response_callback callback)
- {
- struct iris_hfi_device *hdevice = NULL;
- int rc = 0;
- if (!res || !callback) {
- dprintk(CVP_ERR, "Invalid Parameters\n");
- return NULL;
- }
- hdevice = kzalloc(sizeof(*hdevice), GFP_KERNEL);
- if (!hdevice) {
- dprintk(CVP_ERR, "failed to allocate new device\n");
- goto exit;
- }
- hdevice->response_pkt = kmalloc_array(cvp_max_packets,
- sizeof(*hdevice->response_pkt), GFP_KERNEL);
- if (!hdevice->response_pkt) {
- dprintk(CVP_ERR, "failed to allocate response_pkt\n");
- goto err_cleanup;
- }
- hdevice->raw_packet =
- kzalloc(CVP_IFACEQ_VAR_HUGE_PKT_SIZE, GFP_KERNEL);
- if (!hdevice->raw_packet) {
- dprintk(CVP_ERR, "failed to allocate raw packet\n");
- goto err_cleanup;
- }
- rc = vm_manager.vm_ops->vm_init_reg_and_irq(hdevice, res);
- if (rc)
- goto err_cleanup;
- hdevice->res = res;
- hdevice->callback = callback;
- __init_cvp_ops(hdevice);
- hdevice->cvp_workq = create_singlethread_workqueue(
- "msm_cvp_workerq_iris");
- if (!hdevice->cvp_workq) {
- dprintk(CVP_ERR, ": create cvp workq failed\n");
- goto err_cleanup;
- }
- hdevice->iris_pm_workq = create_singlethread_workqueue(
- "pm_workerq_iris");
- if (!hdevice->iris_pm_workq) {
- dprintk(CVP_ERR, ": create pm workq failed\n");
- goto err_cleanup;
- }
- mutex_init(&hdevice->lock);
- INIT_LIST_HEAD(&hdevice->sess_head);
- return hdevice;
- err_cleanup:
- if (hdevice->iris_pm_workq)
- destroy_workqueue(hdevice->iris_pm_workq);
- if (hdevice->cvp_workq)
- destroy_workqueue(hdevice->cvp_workq);
- kfree(hdevice->response_pkt);
- kfree(hdevice->raw_packet);
- kfree(hdevice);
- exit:
- return NULL;
- }
- static struct iris_hfi_device *__get_device(struct msm_cvp_platform_resources *res,
- hfi_cmd_response_callback callback)
- {
- if (!res || !callback) {
- dprintk(CVP_ERR, "Invalid params: %pK %pK\n", res, callback);
- return NULL;
- }
- return __add_device(res, callback);
- }
- void cvp_iris_hfi_delete_device(void *device)
- {
- struct msm_cvp_core *core;
- struct iris_hfi_device *dev = NULL;
- if (!device)
- return;
- core = cvp_driver->cvp_core;
- if (core)
- dev = core->dev_ops->hfi_device_data;
- if (!dev)
- return;
- mutex_destroy(&dev->lock);
- destroy_workqueue(dev->cvp_workq);
- destroy_workqueue(dev->iris_pm_workq);
- free_irq(dev->cvp_hal_data->irq, dev);
- iounmap(dev->cvp_hal_data->register_base);
- iounmap(dev->cvp_hal_data->gcc_reg_base);
- kfree(dev->cvp_hal_data);
- kfree(dev->response_pkt);
- kfree(dev->raw_packet);
- kfree(dev);
- }
- static int iris_hfi_validate_session(void *sess, const char *func)
- {
- struct cvp_hal_session *session = sess;
- int rc = 0;
- struct iris_hfi_device *device;
- if (!session || !session->device) {
- dprintk(CVP_ERR, " %s Invalid Params %pK\n", __func__, session);
- return -EINVAL;
- }
- device = session->device;
- mutex_lock(&device->lock);
- if (!__is_session_valid(device, session, func))
- rc = -ECONNRESET;
- mutex_unlock(&device->lock);
- return rc;
- }
- static void iris_init_hfi_callbacks(struct cvp_hfi_ops *ops_tbl)
- {
- ops_tbl->core_init = iris_hfi_core_init;
- ops_tbl->core_release = iris_hfi_core_release;
- ops_tbl->core_trigger_ssr = iris_hfi_core_trigger_ssr;
- ops_tbl->session_init = iris_hfi_session_init;
- ops_tbl->session_end = iris_hfi_session_end;
- ops_tbl->session_start = iris_hfi_session_start;
- ops_tbl->session_stop = iris_hfi_session_stop;
- ops_tbl->session_abort = iris_hfi_session_abort;
- ops_tbl->session_clean = iris_hfi_session_clean;
- ops_tbl->session_set_buffers = iris_hfi_session_set_buffers;
- ops_tbl->session_release_buffers = iris_hfi_session_release_buffers;
- ops_tbl->session_send = iris_hfi_session_send;
- ops_tbl->session_flush = iris_hfi_session_flush;
- ops_tbl->scale_clocks = iris_hfi_scale_clocks;
- ops_tbl->vote_bus = iris_hfi_vote_buses;
- ops_tbl->get_fw_info = iris_hfi_get_fw_info;
- ops_tbl->get_core_capabilities = iris_hfi_get_core_capabilities;
- ops_tbl->suspend = iris_hfi_suspend;
- ops_tbl->resume = iris_hfi_resume;
- ops_tbl->flush_debug_queue = iris_hfi_flush_debug_queue;
- ops_tbl->noc_error_info = iris_hfi_noc_error_info;
- ops_tbl->validate_session = iris_hfi_validate_session;
- ops_tbl->pm_qos_update = iris_pm_qos_update;
- ops_tbl->debug_hook = iris_debug_hook;
- }
- int cvp_iris_hfi_initialize(struct cvp_hfi_ops *ops_tbl,
- struct msm_cvp_platform_resources *res,
- hfi_cmd_response_callback callback)
- {
- int rc = 0;
- if (!ops_tbl || !res || !callback) {
- dprintk(CVP_ERR, "Invalid params: %pK %pK %pK\n",
- ops_tbl, res, callback);
- rc = -EINVAL;
- goto err_iris_hfi_init;
- }
- ops_tbl->hfi_device_data = __get_device(res, callback);
- if (IS_ERR_OR_NULL(ops_tbl->hfi_device_data)) {
- rc = PTR_ERR(ops_tbl->hfi_device_data) ?: -EINVAL;
- goto err_iris_hfi_init;
- }
- iris_init_hfi_callbacks(ops_tbl);
- err_iris_hfi_init:
- return rc;
- }
- static void dump_noc_reg(struct iris_hfi_device *device)
- {
- u32 val = 0, config;
- int i;
- struct regulator_info *rinfo;
- int rc = 0;
- if (msm_cvp_fw_low_power_mode) {
- iris_hfi_for_each_regulator(device, rinfo) {
- if (strcmp(rinfo->name, "cvp-core"))
- continue;
- rc = __acquire_regulator(rinfo, device);
- if (rc)
- dprintk(CVP_WARN,
- "%s, Failed to acquire regulator control: %s\n",
- __func__, rinfo->name);
- }
- }
- val = __read_register(device, CVP_CC_MVS1_GDSCR);
- dprintk(CVP_ERR, "%s, CVP_CC_MVS1_GDSCR: 0x%x", __func__, val);
- config = __read_register(device, CVP_WRAPPER_CORE_CLOCK_CONFIG);
- dprintk(CVP_ERR, "%s, CVP_WRAPPER_CORE_CLOCK_CONFIG: 0x%x", __func__, config);
- if (config) {
- dprintk(CVP_PWR,
- "core clock config not enabled, enable it to access core\n");
- __write_register(device, CVP_WRAPPER_CORE_CLOCK_CONFIG, 0);
- }
- i = call_iris_op(device, reset_control_acquire_name, device, "cvp_xo_reset");
- if (i) {
- dprintk(CVP_WARN, "%s Fail acquire xo_reset\n", __func__);
- return;
- }
- val = __read_register(device, CVP_NOC_RGE_NIU_DECCTL_LOW
- + device->res->qos_noc_rge_niu_offset);
- dprintk(CVP_ERR, "CVP_NOC_RGE_NIU_DECCTL_LOW: 0x%x", val);
- val = __read_register(device, CVP_NOC_RGE_NIU_ENCCTL_LOW
- + device->res->qos_noc_rge_niu_offset);
- dprintk(CVP_ERR, "CVP_NOC_RGE_NIU_ENCCTL_LOW: 0x%x", val);
- val = __read_register(device, CVP_NOC_GCE_VADL_TOF_NIU_DECCTL_LOW
- + device->res->qos_noc_gce_vadl_tof_niu_offset);
- dprintk(CVP_ERR, "CVP_NOC_GCE_VADL_TOF_NIU_DECCTL_LOW: 0x%x", val);
- val = __read_register(device, CVP_NOC_GCE_VADL_TOF_NIU_ENCCTL_LOW
- + device->res->qos_noc_gce_vadl_tof_niu_offset);
- dprintk(CVP_ERR, "CVP_NOC_GCE_VADL_TOF_NIU_ENCCTL_LOW: 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_MAINCTL_LOW_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERR_MAINCTL_LOW_OFFS: 0x%x", val);
- val = __read_register(device, CVP_NOC_MAIN_SIDEBANDMANAGER_FAULTINEN0_LOW
- + device->res->noc_main_sidebandmanager_offset);
- dprintk(CVP_ERR, "CVP_NOC_MAIN_SIDEBANDMANAGER_FAULTINEN0_LOW: 0x%x", val);
- dprintk(CVP_ERR, "Dumping Core NoC registers\n");
- val = __read_register(device, CVP_NOC_CORE_ERR_SWID_LOW_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC__CORE_ERL_MAIN_SWID_LOW: 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_SWID_HIGH_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVVP_NOC_CORE_ERL_MAIN_SWID_HIGH 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_MAINCTL_LOW_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_MAINCTL_LOW 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_ERRVLD_LOW_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRVLD_LOW 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_ERRCLR_LOW_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRCLR_LOW 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG0_LOW_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG0_LOW 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG0_HIGH_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG0_HIGH 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG1_LOW_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG1_LOW 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG1_HIGH_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG1_HIGH 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG2_LOW_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG2_LOW 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG2_HIGH_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG2_HIGH 0x%x", val);
- val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG3_LOW_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CORE ERRLOG3_LOW 0x%x, below details", val);
- __print_reg_details(val);
- val = __read_register(device, CVP_NOC_CORE_ERR_ERRLOG3_HIGH_OFFS
- + device->res->noc_core_err_offset);
- dprintk(CVP_ERR, "CVP_NOC_CORE_ERL_MAIN_ERRLOG3_HIGH 0x%x", val);
- __write_register(device, CVP_NOC_CORE_ERR_ERRCLR_LOW_OFFS
- + device->res->noc_core_err_offset, 0x1);
- call_iris_op(device, reset_control_release_name, device, "cvp_xo_reset");
- if (msm_cvp_fw_low_power_mode) {
- iris_hfi_for_each_regulator(device, rinfo) {
- if (strcmp(rinfo->name, "cvp-core"))
- continue;
- rc = __hand_off_regulator(device, rinfo);
- }
- }
- __write_register(device, CVP_WRAPPER_CORE_CLOCK_CONFIG, config);
- }
|