310-msm-adhoc-bus-support.patch 314 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026
  1. From: Christian Lamparter <[email protected]>
  2. Subject: BUS: add MSM_BUS
  3. --- a/drivers/bus/Makefile
  4. +++ b/drivers/bus/Makefile
  5. @@ -11,6 +11,7 @@ obj-$(CONFIG_BRCMSTB_GISB_ARB) += brcmst
  6. obj-$(CONFIG_IMX_WEIM) += imx-weim.o
  7. obj-$(CONFIG_MIPS_CDMM) += mips_cdmm.o
  8. obj-$(CONFIG_MVEBU_MBUS) += mvebu-mbus.o
  9. +obj-$(CONFIG_BUS_TOPOLOGY_ADHOC)+= msm_bus/
  10. # Interconnect bus driver for OMAP SoCs.
  11. obj-$(CONFIG_OMAP_INTERCONNECT) += omap_l3_smx.o omap_l3_noc.o
  12. --- a/drivers/bus/Kconfig
  13. +++ b/drivers/bus/Kconfig
  14. @@ -93,6 +93,8 @@ config MVEBU_MBUS
  15. Driver needed for the MBus configuration on Marvell EBU SoCs
  16. (Kirkwood, Dove, Orion5x, MV78XX0 and Armada 370/XP).
  17. +source "drivers/bus/msm_bus/Kconfig"
  18. +
  19. config OMAP_INTERCONNECT
  20. tristate "OMAP INTERCONNECT DRIVER"
  21. depends on ARCH_OMAP2PLUS
  22. --- /dev/null
  23. +++ b/include/dt-bindings/msm/msm-bus-ids.h
  24. @@ -0,0 +1,869 @@
  25. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  26. + *
  27. + * This program is free software; you can redistribute it and/or modify
  28. + * it under the terms of the GNU General Public License version 2 and
  29. + * only version 2 as published by the Free Software Foundation.
  30. + *
  31. + * This program is distributed in the hope that it will be useful,
  32. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  33. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  34. + * GNU General Public License for more details.
  35. + */
  36. +
  37. +#ifndef __MSM_BUS_IDS_H
  38. +#define __MSM_BUS_IDS_H
  39. +
  40. +/* Topology related enums */
  41. +#define MSM_BUS_FAB_DEFAULT 0
  42. +#define MSM_BUS_FAB_APPSS 0
  43. +#define MSM_BUS_FAB_SYSTEM 1024
  44. +#define MSM_BUS_FAB_MMSS 2048
  45. +#define MSM_BUS_FAB_SYSTEM_FPB 3072
  46. +#define MSM_BUS_FAB_CPSS_FPB 4096
  47. +
  48. +#define MSM_BUS_FAB_BIMC 0
  49. +#define MSM_BUS_FAB_SYS_NOC 1024
  50. +#define MSM_BUS_FAB_MMSS_NOC 2048
  51. +#define MSM_BUS_FAB_OCMEM_NOC 3072
  52. +#define MSM_BUS_FAB_PERIPH_NOC 4096
  53. +#define MSM_BUS_FAB_CONFIG_NOC 5120
  54. +#define MSM_BUS_FAB_OCMEM_VNOC 6144
  55. +#define MSM_BUS_FAB_MMSS_AHB 2049
  56. +#define MSM_BUS_FAB_A0_NOC 6145
  57. +#define MSM_BUS_FAB_A1_NOC 6146
  58. +#define MSM_BUS_FAB_A2_NOC 6147
  59. +
  60. +#define MSM_BUS_MASTER_FIRST 1
  61. +#define MSM_BUS_MASTER_AMPSS_M0 1
  62. +#define MSM_BUS_MASTER_AMPSS_M1 2
  63. +#define MSM_BUS_APPSS_MASTER_FAB_MMSS 3
  64. +#define MSM_BUS_APPSS_MASTER_FAB_SYSTEM 4
  65. +#define MSM_BUS_SYSTEM_MASTER_FAB_APPSS 5
  66. +#define MSM_BUS_MASTER_SPS 6
  67. +#define MSM_BUS_MASTER_ADM_PORT0 7
  68. +#define MSM_BUS_MASTER_ADM_PORT1 8
  69. +#define MSM_BUS_SYSTEM_MASTER_ADM1_PORT0 9
  70. +#define MSM_BUS_MASTER_ADM1_PORT1 10
  71. +#define MSM_BUS_MASTER_LPASS_PROC 11
  72. +#define MSM_BUS_MASTER_MSS_PROCI 12
  73. +#define MSM_BUS_MASTER_MSS_PROCD 13
  74. +#define MSM_BUS_MASTER_MSS_MDM_PORT0 14
  75. +#define MSM_BUS_MASTER_LPASS 15
  76. +#define MSM_BUS_SYSTEM_MASTER_CPSS_FPB 16
  77. +#define MSM_BUS_SYSTEM_MASTER_SYSTEM_FPB 17
  78. +#define MSM_BUS_SYSTEM_MASTER_MMSS_FPB 18
  79. +#define MSM_BUS_MASTER_ADM1_CI 19
  80. +#define MSM_BUS_MASTER_ADM0_CI 20
  81. +#define MSM_BUS_MASTER_MSS_MDM_PORT1 21
  82. +#define MSM_BUS_MASTER_MDP_PORT0 22
  83. +#define MSM_BUS_MASTER_MDP_PORT1 23
  84. +#define MSM_BUS_MMSS_MASTER_ADM1_PORT0 24
  85. +#define MSM_BUS_MASTER_ROTATOR 25
  86. +#define MSM_BUS_MASTER_GRAPHICS_3D 26
  87. +#define MSM_BUS_MASTER_JPEG_DEC 27
  88. +#define MSM_BUS_MASTER_GRAPHICS_2D_CORE0 28
  89. +#define MSM_BUS_MASTER_VFE 29
  90. +#define MSM_BUS_MASTER_VPE 30
  91. +#define MSM_BUS_MASTER_JPEG_ENC 31
  92. +#define MSM_BUS_MASTER_GRAPHICS_2D_CORE1 32
  93. +#define MSM_BUS_MMSS_MASTER_APPS_FAB 33
  94. +#define MSM_BUS_MASTER_HD_CODEC_PORT0 34
  95. +#define MSM_BUS_MASTER_HD_CODEC_PORT1 35
  96. +#define MSM_BUS_MASTER_SPDM 36
  97. +#define MSM_BUS_MASTER_RPM 37
  98. +#define MSM_BUS_MASTER_MSS 38
  99. +#define MSM_BUS_MASTER_RIVA 39
  100. +#define MSM_BUS_MASTER_SNOC_VMEM 40
  101. +#define MSM_BUS_MASTER_MSS_SW_PROC 41
  102. +#define MSM_BUS_MASTER_MSS_FW_PROC 42
  103. +#define MSM_BUS_MASTER_HMSS 43
  104. +#define MSM_BUS_MASTER_GSS_NAV 44
  105. +#define MSM_BUS_MASTER_PCIE 45
  106. +#define MSM_BUS_MASTER_SATA 46
  107. +#define MSM_BUS_MASTER_CRYPTO 47
  108. +#define MSM_BUS_MASTER_VIDEO_CAP 48
  109. +#define MSM_BUS_MASTER_GRAPHICS_3D_PORT1 49
  110. +#define MSM_BUS_MASTER_VIDEO_ENC 50
  111. +#define MSM_BUS_MASTER_VIDEO_DEC 51
  112. +#define MSM_BUS_MASTER_LPASS_AHB 52
  113. +#define MSM_BUS_MASTER_QDSS_BAM 53
  114. +#define MSM_BUS_MASTER_SNOC_CFG 54
  115. +#define MSM_BUS_MASTER_CRYPTO_CORE0 55
  116. +#define MSM_BUS_MASTER_CRYPTO_CORE1 56
  117. +#define MSM_BUS_MASTER_MSS_NAV 57
  118. +#define MSM_BUS_MASTER_OCMEM_DMA 58
  119. +#define MSM_BUS_MASTER_WCSS 59
  120. +#define MSM_BUS_MASTER_QDSS_ETR 60
  121. +#define MSM_BUS_MASTER_USB3 61
  122. +#define MSM_BUS_MASTER_JPEG 62
  123. +#define MSM_BUS_MASTER_VIDEO_P0 63
  124. +#define MSM_BUS_MASTER_VIDEO_P1 64
  125. +#define MSM_BUS_MASTER_MSS_PROC 65
  126. +#define MSM_BUS_MASTER_JPEG_OCMEM 66
  127. +#define MSM_BUS_MASTER_MDP_OCMEM 67
  128. +#define MSM_BUS_MASTER_VIDEO_P0_OCMEM 68
  129. +#define MSM_BUS_MASTER_VIDEO_P1_OCMEM 69
  130. +#define MSM_BUS_MASTER_VFE_OCMEM 70
  131. +#define MSM_BUS_MASTER_CNOC_ONOC_CFG 71
  132. +#define MSM_BUS_MASTER_RPM_INST 72
  133. +#define MSM_BUS_MASTER_RPM_DATA 73
  134. +#define MSM_BUS_MASTER_RPM_SYS 74
  135. +#define MSM_BUS_MASTER_DEHR 75
  136. +#define MSM_BUS_MASTER_QDSS_DAP 76
  137. +#define MSM_BUS_MASTER_TIC 77
  138. +#define MSM_BUS_MASTER_SDCC_1 78
  139. +#define MSM_BUS_MASTER_SDCC_3 79
  140. +#define MSM_BUS_MASTER_SDCC_4 80
  141. +#define MSM_BUS_MASTER_SDCC_2 81
  142. +#define MSM_BUS_MASTER_TSIF 82
  143. +#define MSM_BUS_MASTER_BAM_DMA 83
  144. +#define MSM_BUS_MASTER_BLSP_2 84
  145. +#define MSM_BUS_MASTER_USB_HSIC 85
  146. +#define MSM_BUS_MASTER_BLSP_1 86
  147. +#define MSM_BUS_MASTER_USB_HS 87
  148. +#define MSM_BUS_MASTER_PNOC_CFG 88
  149. +#define MSM_BUS_MASTER_V_OCMEM_GFX3D 89
  150. +#define MSM_BUS_MASTER_IPA 90
  151. +#define MSM_BUS_MASTER_QPIC 91
  152. +#define MSM_BUS_MASTER_MDPE 92
  153. +#define MSM_BUS_MASTER_USB_HS2 93
  154. +#define MSM_BUS_MASTER_VPU 94
  155. +#define MSM_BUS_MASTER_UFS 95
  156. +#define MSM_BUS_MASTER_BCAST 96
  157. +#define MSM_BUS_MASTER_CRYPTO_CORE2 97
  158. +#define MSM_BUS_MASTER_EMAC 98
  159. +#define MSM_BUS_MASTER_VPU_1 99
  160. +#define MSM_BUS_MASTER_PCIE_1 100
  161. +#define MSM_BUS_MASTER_USB3_1 101
  162. +#define MSM_BUS_MASTER_CNOC_MNOC_MMSS_CFG 102
  163. +#define MSM_BUS_MASTER_CNOC_MNOC_CFG 103
  164. +#define MSM_BUS_MASTER_TCU_0 104
  165. +#define MSM_BUS_MASTER_TCU_1 105
  166. +#define MSM_BUS_MASTER_CPP 106
  167. +#define MSM_BUS_MASTER_AUDIO 107
  168. +#define MSM_BUS_MASTER_PCIE_2 108
  169. +#define MSM_BUS_MASTER_BLSP_BAM 109
  170. +#define MSM_BUS_MASTER_USB2_BAM 110
  171. +#define MSM_BUS_MASTER_ADDS_DMA0 111
  172. +#define MSM_BUS_MASTER_ADDS_DMA1 112
  173. +#define MSM_BUS_MASTER_ADDS_DMA2 113
  174. +#define MSM_BUS_MASTER_ADDS_DMA3 114
  175. +#define MSM_BUS_MASTER_QPIC_BAM 115
  176. +#define MSM_BUS_MASTER_SDCC_BAM 116
  177. +#define MSM_BUS_MASTER_DDRC_SNOC 117
  178. +#define MSM_BUS_MASTER_WSS_0 118
  179. +#define MSM_BUS_MASTER_WSS_1 119
  180. +#define MSM_BUS_MASTER_ESS 120
  181. +#define MSM_BUS_MASTER_QDSS_BAMNDP 121
  182. +#define MSM_BUS_MASTER_QDSS_SNOC_CFG 122
  183. +#define MSM_BUS_MASTER_LAST 130
  184. +
  185. +#define MSM_BUS_SYSTEM_FPB_MASTER_SYSTEM MSM_BUS_SYSTEM_MASTER_SYSTEM_FPB
  186. +#define MSM_BUS_CPSS_FPB_MASTER_SYSTEM MSM_BUS_SYSTEM_MASTER_CPSS_FPB
  187. +
  188. +#define MSM_BUS_SNOC_MM_INT_0 10000
  189. +#define MSM_BUS_SNOC_MM_INT_1 10001
  190. +#define MSM_BUS_SNOC_MM_INT_2 10002
  191. +#define MSM_BUS_SNOC_MM_INT_BIMC 10003
  192. +#define MSM_BUS_SNOC_INT_0 10004
  193. +#define MSM_BUS_SNOC_INT_1 10005
  194. +#define MSM_BUS_SNOC_INT_BIMC 10006
  195. +#define MSM_BUS_SNOC_BIMC_0_MAS 10007
  196. +#define MSM_BUS_SNOC_BIMC_1_MAS 10008
  197. +#define MSM_BUS_SNOC_QDSS_INT 10009
  198. +#define MSM_BUS_PNOC_SNOC_MAS 10010
  199. +#define MSM_BUS_PNOC_SNOC_SLV 10011
  200. +#define MSM_BUS_PNOC_INT_0 10012
  201. +#define MSM_BUS_PNOC_INT_1 10013
  202. +#define MSM_BUS_PNOC_M_0 10014
  203. +#define MSM_BUS_PNOC_M_1 10015
  204. +#define MSM_BUS_BIMC_SNOC_MAS 10016
  205. +#define MSM_BUS_BIMC_SNOC_SLV 10017
  206. +#define MSM_BUS_PNOC_SLV_0 10018
  207. +#define MSM_BUS_PNOC_SLV_1 10019
  208. +#define MSM_BUS_PNOC_SLV_2 10020
  209. +#define MSM_BUS_PNOC_SLV_3 10021
  210. +#define MSM_BUS_PNOC_SLV_4 10022
  211. +#define MSM_BUS_PNOC_SLV_8 10023
  212. +#define MSM_BUS_PNOC_SLV_9 10024
  213. +#define MSM_BUS_SNOC_BIMC_0_SLV 10025
  214. +#define MSM_BUS_SNOC_BIMC_1_SLV 10026
  215. +#define MSM_BUS_MNOC_BIMC_MAS 10027
  216. +#define MSM_BUS_MNOC_BIMC_SLV 10028
  217. +#define MSM_BUS_BIMC_MNOC_MAS 10029
  218. +#define MSM_BUS_BIMC_MNOC_SLV 10030
  219. +#define MSM_BUS_SNOC_BIMC_MAS 10031
  220. +#define MSM_BUS_SNOC_BIMC_SLV 10032
  221. +#define MSM_BUS_CNOC_SNOC_MAS 10033
  222. +#define MSM_BUS_CNOC_SNOC_SLV 10034
  223. +#define MSM_BUS_SNOC_CNOC_MAS 10035
  224. +#define MSM_BUS_SNOC_CNOC_SLV 10036
  225. +#define MSM_BUS_OVNOC_SNOC_MAS 10037
  226. +#define MSM_BUS_OVNOC_SNOC_SLV 10038
  227. +#define MSM_BUS_SNOC_OVNOC_MAS 10039
  228. +#define MSM_BUS_SNOC_OVNOC_SLV 10040
  229. +#define MSM_BUS_SNOC_PNOC_MAS 10041
  230. +#define MSM_BUS_SNOC_PNOC_SLV 10042
  231. +#define MSM_BUS_BIMC_INT_APPS_EBI 10043
  232. +#define MSM_BUS_BIMC_INT_APPS_SNOC 10044
  233. +#define MSM_BUS_SNOC_BIMC_2_MAS 10045
  234. +#define MSM_BUS_SNOC_BIMC_2_SLV 10046
  235. +#define MSM_BUS_PNOC_SLV_5 10047
  236. +#define MSM_BUS_PNOC_SLV_6 10048
  237. +#define MSM_BUS_PNOC_INT_2 10049
  238. +#define MSM_BUS_PNOC_INT_3 10050
  239. +#define MSM_BUS_PNOC_INT_4 10051
  240. +#define MSM_BUS_PNOC_INT_5 10052
  241. +#define MSM_BUS_PNOC_INT_6 10053
  242. +#define MSM_BUS_PNOC_INT_7 10054
  243. +#define MSM_BUS_BIMC_SNOC_1_MAS 10055
  244. +#define MSM_BUS_BIMC_SNOC_1_SLV 10056
  245. +#define MSM_BUS_PNOC_A1NOC_MAS 10057
  246. +#define MSM_BUS_PNOC_A1NOC_SLV 10058
  247. +#define MSM_BUS_CNOC_A1NOC_MAS 10059
  248. +#define MSM_BUS_A0NOC_SNOC_MAS 10060
  249. +#define MSM_BUS_A0NOC_SNOC_SLV 10061
  250. +#define MSM_BUS_A1NOC_SNOC_SLV 10062
  251. +#define MSM_BUS_A1NOC_SNOC_MAS 10063
  252. +#define MSM_BUS_A2NOC_SNOC_MAS 10064
  253. +#define MSM_BUS_A2NOC_SNOC_SLV 10065
  254. +#define MSM_BUS_PNOC_SLV_7 10066
  255. +#define MSM_BUS_INT_LAST 10067
  256. +
  257. +#define MSM_BUS_SLAVE_FIRST 512
  258. +#define MSM_BUS_SLAVE_EBI_CH0 512
  259. +#define MSM_BUS_SLAVE_EBI_CH1 513
  260. +#define MSM_BUS_SLAVE_AMPSS_L2 514
  261. +#define MSM_BUS_APPSS_SLAVE_FAB_MMSS 515
  262. +#define MSM_BUS_APPSS_SLAVE_FAB_SYSTEM 516
  263. +#define MSM_BUS_SYSTEM_SLAVE_FAB_APPS 517
  264. +#define MSM_BUS_SLAVE_SPS 518
  265. +#define MSM_BUS_SLAVE_SYSTEM_IMEM 519
  266. +#define MSM_BUS_SLAVE_AMPSS 520
  267. +#define MSM_BUS_SLAVE_MSS 521
  268. +#define MSM_BUS_SLAVE_LPASS 522
  269. +#define MSM_BUS_SYSTEM_SLAVE_CPSS_FPB 523
  270. +#define MSM_BUS_SYSTEM_SLAVE_SYSTEM_FPB 524
  271. +#define MSM_BUS_SYSTEM_SLAVE_MMSS_FPB 525
  272. +#define MSM_BUS_SLAVE_CORESIGHT 526
  273. +#define MSM_BUS_SLAVE_RIVA 527
  274. +#define MSM_BUS_SLAVE_SMI 528
  275. +#define MSM_BUS_MMSS_SLAVE_FAB_APPS 529
  276. +#define MSM_BUS_MMSS_SLAVE_FAB_APPS_1 530
  277. +#define MSM_BUS_SLAVE_MM_IMEM 531
  278. +#define MSM_BUS_SLAVE_CRYPTO 532
  279. +#define MSM_BUS_SLAVE_SPDM 533
  280. +#define MSM_BUS_SLAVE_RPM 534
  281. +#define MSM_BUS_SLAVE_RPM_MSG_RAM 535
  282. +#define MSM_BUS_SLAVE_MPM 536
  283. +#define MSM_BUS_SLAVE_PMIC1_SSBI1_A 537
  284. +#define MSM_BUS_SLAVE_PMIC1_SSBI1_B 538
  285. +#define MSM_BUS_SLAVE_PMIC1_SSBI1_C 539
  286. +#define MSM_BUS_SLAVE_PMIC2_SSBI2_A 540
  287. +#define MSM_BUS_SLAVE_PMIC2_SSBI2_B 541
  288. +#define MSM_BUS_SLAVE_GSBI1_UART 542
  289. +#define MSM_BUS_SLAVE_GSBI2_UART 543
  290. +#define MSM_BUS_SLAVE_GSBI3_UART 544
  291. +#define MSM_BUS_SLAVE_GSBI4_UART 545
  292. +#define MSM_BUS_SLAVE_GSBI5_UART 546
  293. +#define MSM_BUS_SLAVE_GSBI6_UART 547
  294. +#define MSM_BUS_SLAVE_GSBI7_UART 548
  295. +#define MSM_BUS_SLAVE_GSBI8_UART 549
  296. +#define MSM_BUS_SLAVE_GSBI9_UART 550
  297. +#define MSM_BUS_SLAVE_GSBI10_UART 551
  298. +#define MSM_BUS_SLAVE_GSBI11_UART 552
  299. +#define MSM_BUS_SLAVE_GSBI12_UART 553
  300. +#define MSM_BUS_SLAVE_GSBI1_QUP 554
  301. +#define MSM_BUS_SLAVE_GSBI2_QUP 555
  302. +#define MSM_BUS_SLAVE_GSBI3_QUP 556
  303. +#define MSM_BUS_SLAVE_GSBI4_QUP 557
  304. +#define MSM_BUS_SLAVE_GSBI5_QUP 558
  305. +#define MSM_BUS_SLAVE_GSBI6_QUP 559
  306. +#define MSM_BUS_SLAVE_GSBI7_QUP 560
  307. +#define MSM_BUS_SLAVE_GSBI8_QUP 561
  308. +#define MSM_BUS_SLAVE_GSBI9_QUP 562
  309. +#define MSM_BUS_SLAVE_GSBI10_QUP 563
  310. +#define MSM_BUS_SLAVE_GSBI11_QUP 564
  311. +#define MSM_BUS_SLAVE_GSBI12_QUP 565
  312. +#define MSM_BUS_SLAVE_EBI2_NAND 566
  313. +#define MSM_BUS_SLAVE_EBI2_CS0 567
  314. +#define MSM_BUS_SLAVE_EBI2_CS1 568
  315. +#define MSM_BUS_SLAVE_EBI2_CS2 569
  316. +#define MSM_BUS_SLAVE_EBI2_CS3 570
  317. +#define MSM_BUS_SLAVE_EBI2_CS4 571
  318. +#define MSM_BUS_SLAVE_EBI2_CS5 572
  319. +#define MSM_BUS_SLAVE_USB_FS1 573
  320. +#define MSM_BUS_SLAVE_USB_FS2 574
  321. +#define MSM_BUS_SLAVE_TSIF 575
  322. +#define MSM_BUS_SLAVE_MSM_TSSC 576
  323. +#define MSM_BUS_SLAVE_MSM_PDM 577
  324. +#define MSM_BUS_SLAVE_MSM_DIMEM 578
  325. +#define MSM_BUS_SLAVE_MSM_TCSR 579
  326. +#define MSM_BUS_SLAVE_MSM_PRNG 580
  327. +#define MSM_BUS_SLAVE_GSS 581
  328. +#define MSM_BUS_SLAVE_SATA 582
  329. +#define MSM_BUS_SLAVE_USB3 583
  330. +#define MSM_BUS_SLAVE_WCSS 584
  331. +#define MSM_BUS_SLAVE_OCIMEM 585
  332. +#define MSM_BUS_SLAVE_SNOC_OCMEM 586
  333. +#define MSM_BUS_SLAVE_SERVICE_SNOC 587
  334. +#define MSM_BUS_SLAVE_QDSS_STM 588
  335. +#define MSM_BUS_SLAVE_CAMERA_CFG 589
  336. +#define MSM_BUS_SLAVE_DISPLAY_CFG 590
  337. +#define MSM_BUS_SLAVE_OCMEM_CFG 591
  338. +#define MSM_BUS_SLAVE_CPR_CFG 592
  339. +#define MSM_BUS_SLAVE_CPR_XPU_CFG 593
  340. +#define MSM_BUS_SLAVE_MISC_CFG 594
  341. +#define MSM_BUS_SLAVE_MISC_XPU_CFG 595
  342. +#define MSM_BUS_SLAVE_VENUS_CFG 596
  343. +#define MSM_BUS_SLAVE_MISC_VENUS_CFG 597
  344. +#define MSM_BUS_SLAVE_GRAPHICS_3D_CFG 598
  345. +#define MSM_BUS_SLAVE_MMSS_CLK_CFG 599
  346. +#define MSM_BUS_SLAVE_MMSS_CLK_XPU_CFG 600
  347. +#define MSM_BUS_SLAVE_MNOC_MPU_CFG 601
  348. +#define MSM_BUS_SLAVE_ONOC_MPU_CFG 602
  349. +#define MSM_BUS_SLAVE_SERVICE_MNOC 603
  350. +#define MSM_BUS_SLAVE_OCMEM 604
  351. +#define MSM_BUS_SLAVE_SERVICE_ONOC 605
  352. +#define MSM_BUS_SLAVE_SDCC_1 606
  353. +#define MSM_BUS_SLAVE_SDCC_3 607
  354. +#define MSM_BUS_SLAVE_SDCC_2 608
  355. +#define MSM_BUS_SLAVE_SDCC_4 609
  356. +#define MSM_BUS_SLAVE_BAM_DMA 610
  357. +#define MSM_BUS_SLAVE_BLSP_2 611
  358. +#define MSM_BUS_SLAVE_USB_HSIC 612
  359. +#define MSM_BUS_SLAVE_BLSP_1 613
  360. +#define MSM_BUS_SLAVE_USB_HS 614
  361. +#define MSM_BUS_SLAVE_PDM 615
  362. +#define MSM_BUS_SLAVE_PERIPH_APU_CFG 616
  363. +#define MSM_BUS_SLAVE_PNOC_MPU_CFG 617
  364. +#define MSM_BUS_SLAVE_PRNG 618
  365. +#define MSM_BUS_SLAVE_SERVICE_PNOC 619
  366. +#define MSM_BUS_SLAVE_CLK_CTL 620
  367. +#define MSM_BUS_SLAVE_CNOC_MSS 621
  368. +#define MSM_BUS_SLAVE_SECURITY 622
  369. +#define MSM_BUS_SLAVE_TCSR 623
  370. +#define MSM_BUS_SLAVE_TLMM 624
  371. +#define MSM_BUS_SLAVE_CRYPTO_0_CFG 625
  372. +#define MSM_BUS_SLAVE_CRYPTO_1_CFG 626
  373. +#define MSM_BUS_SLAVE_IMEM_CFG 627
  374. +#define MSM_BUS_SLAVE_MESSAGE_RAM 628
  375. +#define MSM_BUS_SLAVE_BIMC_CFG 629
  376. +#define MSM_BUS_SLAVE_BOOT_ROM 630
  377. +#define MSM_BUS_SLAVE_CNOC_MNOC_MMSS_CFG 631
  378. +#define MSM_BUS_SLAVE_PMIC_ARB 632
  379. +#define MSM_BUS_SLAVE_SPDM_WRAPPER 633
  380. +#define MSM_BUS_SLAVE_DEHR_CFG 634
  381. +#define MSM_BUS_SLAVE_QDSS_CFG 635
  382. +#define MSM_BUS_SLAVE_RBCPR_CFG 636
  383. +#define MSM_BUS_SLAVE_RBCPR_QDSS_APU_CFG 637
  384. +#define MSM_BUS_SLAVE_SNOC_MPU_CFG 638
  385. +#define MSM_BUS_SLAVE_CNOC_ONOC_CFG 639
  386. +#define MSM_BUS_SLAVE_CNOC_MNOC_CFG 640
  387. +#define MSM_BUS_SLAVE_PNOC_CFG 641
  388. +#define MSM_BUS_SLAVE_SNOC_CFG 642
  389. +#define MSM_BUS_SLAVE_EBI1_DLL_CFG 643
  390. +#define MSM_BUS_SLAVE_PHY_APU_CFG 644
  391. +#define MSM_BUS_SLAVE_EBI1_PHY_CFG 645
  392. +#define MSM_BUS_SLAVE_SERVICE_CNOC 646
  393. +#define MSM_BUS_SLAVE_IPS_CFG 647
  394. +#define MSM_BUS_SLAVE_QPIC 648
  395. +#define MSM_BUS_SLAVE_DSI_CFG 649
  396. +#define MSM_BUS_SLAVE_UFS_CFG 650
  397. +#define MSM_BUS_SLAVE_RBCPR_CX_CFG 651
  398. +#define MSM_BUS_SLAVE_RBCPR_MX_CFG 652
  399. +#define MSM_BUS_SLAVE_PCIE_CFG 653
  400. +#define MSM_BUS_SLAVE_USB_PHYS_CFG 654
  401. +#define MSM_BUS_SLAVE_VIDEO_CAP_CFG 655
  402. +#define MSM_BUS_SLAVE_AVSYNC_CFG 656
  403. +#define MSM_BUS_SLAVE_CRYPTO_2_CFG 657
  404. +#define MSM_BUS_SLAVE_VPU_CFG 658
  405. +#define MSM_BUS_SLAVE_BCAST_CFG 659
  406. +#define MSM_BUS_SLAVE_KLM_CFG 660
  407. +#define MSM_BUS_SLAVE_GENI_IR_CFG 661
  408. +#define MSM_BUS_SLAVE_OCMEM_GFX 662
  409. +#define MSM_BUS_SLAVE_CATS_128 663
  410. +#define MSM_BUS_SLAVE_OCMEM_64 664
  411. +#define MSM_BUS_SLAVE_PCIE_0 665
  412. +#define MSM_BUS_SLAVE_PCIE_1 666
  413. +#define MSM_BUS_SLAVE_PCIE_0_CFG 667
  414. +#define MSM_BUS_SLAVE_PCIE_1_CFG 668
  415. +#define MSM_BUS_SLAVE_SRVC_MNOC 669
  416. +#define MSM_BUS_SLAVE_USB_HS2 670
  417. +#define MSM_BUS_SLAVE_AUDIO 671
  418. +#define MSM_BUS_SLAVE_TCU 672
  419. +#define MSM_BUS_SLAVE_APPSS 673
  420. +#define MSM_BUS_SLAVE_PCIE_PARF 674
  421. +#define MSM_BUS_SLAVE_USB3_PHY_CFG 675
  422. +#define MSM_BUS_SLAVE_IPA_CFG 676
  423. +#define MSM_BUS_SLAVE_A0NOC_SNOC 677
  424. +#define MSM_BUS_SLAVE_A1NOC_SNOC 678
  425. +#define MSM_BUS_SLAVE_A2NOC_SNOC 679
  426. +#define MSM_BUS_SLAVE_HMSS_L3 680
  427. +#define MSM_BUS_SLAVE_PIMEM_CFG 681
  428. +#define MSM_BUS_SLAVE_DCC_CFG 682
  429. +#define MSM_BUS_SLAVE_QDSS_RBCPR_APU_CFG 683
  430. +#define MSM_BUS_SLAVE_PCIE_2_CFG 684
  431. +#define MSM_BUS_SLAVE_PCIE20_AHB2PHY 685
  432. +#define MSM_BUS_SLAVE_A0NOC_CFG 686
  433. +#define MSM_BUS_SLAVE_A1NOC_CFG 687
  434. +#define MSM_BUS_SLAVE_A2NOC_CFG 688
  435. +#define MSM_BUS_SLAVE_A1NOC_MPU_CFG 689
  436. +#define MSM_BUS_SLAVE_A2NOC_MPU_CFG 690
  437. +#define MSM_BUS_SLAVE_A0NOC_SMMU_CFG 691
  438. +#define MSM_BUS_SLAVE_A1NOC_SMMU_CFG 692
  439. +#define MSM_BUS_SLAVE_A2NOC_SMMU_CFG 693
  440. +#define MSM_BUS_SLAVE_LPASS_SMMU_CFG 694
  441. +#define MSM_BUS_SLAVE_MMAGIC_CFG 695
  442. +#define MSM_BUS_SLAVE_VENUS_THROTTLE_CFG 696
  443. +#define MSM_BUS_SLAVE_SSC_CFG 697
  444. +#define MSM_BUS_SLAVE_DSA_CFG 698
  445. +#define MSM_BUS_SLAVE_DSA_MPU_CFG 699
  446. +#define MSM_BUS_SLAVE_DISPLAY_THROTTLE_CFG 700
  447. +#define MSM_BUS_SLAVE_SMMU_CPP_CFG 701
  448. +#define MSM_BUS_SLAVE_SMMU_JPEG_CFG 702
  449. +#define MSM_BUS_SLAVE_SMMU_MDP_CFG 703
  450. +#define MSM_BUS_SLAVE_SMMU_ROTATOR_CFG 704
  451. +#define MSM_BUS_SLAVE_SMMU_VENUS_CFG 705
  452. +#define MSM_BUS_SLAVE_SMMU_VFE_CFG 706
  453. +#define MSM_BUS_SLAVE_A0NOC_MPU_CFG 707
  454. +#define MSM_BUS_SLAVE_VMEM_CFG 708
  455. +#define MSM_BUS_SLAVE_CAMERA_THROTTLE_CFG 700
  456. +#define MSM_BUS_SLAVE_VMEM 709
  457. +#define MSM_BUS_SLAVE_AHB2PHY 710
  458. +#define MSM_BUS_SLAVE_PIMEM 711
  459. +#define MSM_BUS_SLAVE_SNOC_VMEM 712
  460. +#define MSM_BUS_SLAVE_PCIE_2 713
  461. +#define MSM_BUS_SLAVE_RBCPR_MX 714
  462. +#define MSM_BUS_SLAVE_RBCPR_CX 715
  463. +#define MSM_BUS_SLAVE_PRNG_APU_CFG 716
  464. +#define MSM_BUS_SLAVE_PERIPH_MPU_CFG 717
  465. +#define MSM_BUS_SLAVE_GCNT 718
  466. +#define MSM_BUS_SLAVE_ADSS_CFG 719
  467. +#define MSM_BUS_SLAVE_ADSS_VMIDMT_CFG 720
  468. +#define MSM_BUS_SLAVE_QHSS_APU_CFG 721
  469. +#define MSM_BUS_SLAVE_MDIO 722
  470. +#define MSM_BUS_SLAVE_FEPHY_CFG 723
  471. +#define MSM_BUS_SLAVE_SRIF 724
  472. +#define MSM_BUS_SLAVE_LAST 730
  473. +#define MSM_BUS_SLAVE_DDRC_CFG 731
  474. +#define MSM_BUS_SLAVE_DDRC_APU_CFG 732
  475. +#define MSM_BUS_SLAVE_MPU0_CFG 733
  476. +#define MSM_BUS_SLAVE_MPU1_CFG 734
  477. +#define MSM_BUS_SLAVE_MPU2_CFG 734
  478. +#define MSM_BUS_SLAVE_ESS_VMIDMT_CFG 735
  479. +#define MSM_BUS_SLAVE_ESS_APU_CFG 736
  480. +#define MSM_BUS_SLAVE_USB2_CFG 737
  481. +#define MSM_BUS_SLAVE_BLSP_CFG 738
  482. +#define MSM_BUS_SLAVE_QPIC_CFG 739
  483. +#define MSM_BUS_SLAVE_SDCC_CFG 740
  484. +#define MSM_BUS_SLAVE_WSS0_VMIDMT_CFG 741
  485. +#define MSM_BUS_SLAVE_WSS0_APU_CFG 742
  486. +#define MSM_BUS_SLAVE_WSS1_VMIDMT_CFG 743
  487. +#define MSM_BUS_SLAVE_WSS1_APU_CFG 744
  488. +#define MSM_BUS_SLAVE_SRVC_PCNOC 745
  489. +#define MSM_BUS_SLAVE_SNOC_DDRC 746
  490. +#define MSM_BUS_SLAVE_A7SS 747
  491. +#define MSM_BUS_SLAVE_WSS0_CFG 748
  492. +#define MSM_BUS_SLAVE_WSS1_CFG 749
  493. +#define MSM_BUS_SLAVE_PCIE 750
  494. +#define MSM_BUS_SLAVE_USB3_CFG 751
  495. +#define MSM_BUS_SLAVE_CRYPTO_CFG 752
  496. +#define MSM_BUS_SLAVE_ESS_CFG 753
  497. +#define MSM_BUS_SLAVE_SRVC_SNOC 754
  498. +
  499. +#define MSM_BUS_SYSTEM_FPB_SLAVE_SYSTEM MSM_BUS_SYSTEM_SLAVE_SYSTEM_FPB
  500. +#define MSM_BUS_CPSS_FPB_SLAVE_SYSTEM MSM_BUS_SYSTEM_SLAVE_CPSS_FPB
  501. +
  502. +/*
  503. + * ID's used in RPM messages
  504. + */
  505. +#define ICBID_MASTER_APPSS_PROC 0
  506. +#define ICBID_MASTER_MSS_PROC 1
  507. +#define ICBID_MASTER_MNOC_BIMC 2
  508. +#define ICBID_MASTER_SNOC_BIMC 3
  509. +#define ICBID_MASTER_SNOC_BIMC_0 ICBID_MASTER_SNOC_BIMC
  510. +#define ICBID_MASTER_CNOC_MNOC_MMSS_CFG 4
  511. +#define ICBID_MASTER_CNOC_MNOC_CFG 5
  512. +#define ICBID_MASTER_GFX3D 6
  513. +#define ICBID_MASTER_JPEG 7
  514. +#define ICBID_MASTER_MDP 8
  515. +#define ICBID_MASTER_MDP0 ICBID_MASTER_MDP
  516. +#define ICBID_MASTER_MDPS ICBID_MASTER_MDP
  517. +#define ICBID_MASTER_VIDEO 9
  518. +#define ICBID_MASTER_VIDEO_P0 ICBID_MASTER_VIDEO
  519. +#define ICBID_MASTER_VIDEO_P1 10
  520. +#define ICBID_MASTER_VFE 11
  521. +#define ICBID_MASTER_CNOC_ONOC_CFG 12
  522. +#define ICBID_MASTER_JPEG_OCMEM 13
  523. +#define ICBID_MASTER_MDP_OCMEM 14
  524. +#define ICBID_MASTER_VIDEO_P0_OCMEM 15
  525. +#define ICBID_MASTER_VIDEO_P1_OCMEM 16
  526. +#define ICBID_MASTER_VFE_OCMEM 17
  527. +#define ICBID_MASTER_LPASS_AHB 18
  528. +#define ICBID_MASTER_QDSS_BAM 19
  529. +#define ICBID_MASTER_SNOC_CFG 20
  530. +#define ICBID_MASTER_BIMC_SNOC 21
  531. +#define ICBID_MASTER_CNOC_SNOC 22
  532. +#define ICBID_MASTER_CRYPTO 23
  533. +#define ICBID_MASTER_CRYPTO_CORE0 ICBID_MASTER_CRYPTO
  534. +#define ICBID_MASTER_CRYPTO_CORE1 24
  535. +#define ICBID_MASTER_LPASS_PROC 25
  536. +#define ICBID_MASTER_MSS 26
  537. +#define ICBID_MASTER_MSS_NAV 27
  538. +#define ICBID_MASTER_OCMEM_DMA 28
  539. +#define ICBID_MASTER_PNOC_SNOC 29
  540. +#define ICBID_MASTER_WCSS 30
  541. +#define ICBID_MASTER_QDSS_ETR 31
  542. +#define ICBID_MASTER_USB3 32
  543. +#define ICBID_MASTER_USB3_0 ICBID_MASTER_USB3
  544. +#define ICBID_MASTER_SDCC_1 33
  545. +#define ICBID_MASTER_SDCC_3 34
  546. +#define ICBID_MASTER_SDCC_2 35
  547. +#define ICBID_MASTER_SDCC_4 36
  548. +#define ICBID_MASTER_TSIF 37
  549. +#define ICBID_MASTER_BAM_DMA 38
  550. +#define ICBID_MASTER_BLSP_2 39
  551. +#define ICBID_MASTER_USB_HSIC 40
  552. +#define ICBID_MASTER_BLSP_1 41
  553. +#define ICBID_MASTER_USB_HS 42
  554. +#define ICBID_MASTER_USB_HS1 ICBID_MASTER_USB_HS
  555. +#define ICBID_MASTER_PNOC_CFG 43
  556. +#define ICBID_MASTER_SNOC_PNOC 44
  557. +#define ICBID_MASTER_RPM_INST 45
  558. +#define ICBID_MASTER_RPM_DATA 46
  559. +#define ICBID_MASTER_RPM_SYS 47
  560. +#define ICBID_MASTER_DEHR 48
  561. +#define ICBID_MASTER_QDSS_DAP 49
  562. +#define ICBID_MASTER_SPDM 50
  563. +#define ICBID_MASTER_TIC 51
  564. +#define ICBID_MASTER_SNOC_CNOC 52
  565. +#define ICBID_MASTER_GFX3D_OCMEM 53
  566. +#define ICBID_MASTER_GFX3D_GMEM ICBID_MASTER_GFX3D_OCMEM
  567. +#define ICBID_MASTER_OVIRT_SNOC 54
  568. +#define ICBID_MASTER_SNOC_OVIRT 55
  569. +#define ICBID_MASTER_SNOC_GVIRT ICBID_MASTER_SNOC_OVIRT
  570. +#define ICBID_MASTER_ONOC_OVIRT 56
  571. +#define ICBID_MASTER_USB_HS2 57
  572. +#define ICBID_MASTER_QPIC 58
  573. +#define ICBID_MASTER_IPA 59
  574. +#define ICBID_MASTER_DSI 60
  575. +#define ICBID_MASTER_MDP1 61
  576. +#define ICBID_MASTER_MDPE ICBID_MASTER_MDP1
  577. +#define ICBID_MASTER_VPU_PROC 62
  578. +#define ICBID_MASTER_VPU 63
  579. +#define ICBID_MASTER_VPU0 ICBID_MASTER_VPU
  580. +#define ICBID_MASTER_CRYPTO_CORE2 64
  581. +#define ICBID_MASTER_PCIE_0 65
  582. +#define ICBID_MASTER_PCIE_1 66
  583. +#define ICBID_MASTER_SATA 67
  584. +#define ICBID_MASTER_UFS 68
  585. +#define ICBID_MASTER_USB3_1 69
  586. +#define ICBID_MASTER_VIDEO_OCMEM 70
  587. +#define ICBID_MASTER_VPU1 71
  588. +#define ICBID_MASTER_VCAP 72
  589. +#define ICBID_MASTER_EMAC 73
  590. +#define ICBID_MASTER_BCAST 74
  591. +#define ICBID_MASTER_MMSS_PROC 75
  592. +#define ICBID_MASTER_SNOC_BIMC_1 76
  593. +#define ICBID_MASTER_SNOC_PCNOC 77
  594. +#define ICBID_MASTER_AUDIO 78
  595. +#define ICBID_MASTER_MM_INT_0 79
  596. +#define ICBID_MASTER_MM_INT_1 80
  597. +#define ICBID_MASTER_MM_INT_2 81
  598. +#define ICBID_MASTER_MM_INT_BIMC 82
  599. +#define ICBID_MASTER_MSS_INT 83
  600. +#define ICBID_MASTER_PCNOC_CFG 84
  601. +#define ICBID_MASTER_PCNOC_INT_0 85
  602. +#define ICBID_MASTER_PCNOC_INT_1 86
  603. +#define ICBID_MASTER_PCNOC_M_0 87
  604. +#define ICBID_MASTER_PCNOC_M_1 88
  605. +#define ICBID_MASTER_PCNOC_S_0 89
  606. +#define ICBID_MASTER_PCNOC_S_1 90
  607. +#define ICBID_MASTER_PCNOC_S_2 91
  608. +#define ICBID_MASTER_PCNOC_S_3 92
  609. +#define ICBID_MASTER_PCNOC_S_4 93
  610. +#define ICBID_MASTER_PCNOC_S_6 94
  611. +#define ICBID_MASTER_PCNOC_S_7 95
  612. +#define ICBID_MASTER_PCNOC_S_8 96
  613. +#define ICBID_MASTER_PCNOC_S_9 97
  614. +#define ICBID_MASTER_QDSS_INT 98
  615. +#define ICBID_MASTER_SNOC_INT_0 99
  616. +#define ICBID_MASTER_SNOC_INT_1 100
  617. +#define ICBID_MASTER_SNOC_INT_BIMC 101
  618. +#define ICBID_MASTER_TCU_0 102
  619. +#define ICBID_MASTER_TCU_1 103
  620. +#define ICBID_MASTER_BIMC_INT_0 104
  621. +#define ICBID_MASTER_BIMC_INT_1 105
  622. +#define ICBID_MASTER_CAMERA 106
  623. +#define ICBID_MASTER_RICA 107
  624. +#define ICBID_MASTER_PCNOC_S_5 129
  625. +#define ICBID_MASTER_PCNOC_INT_2 124
  626. +#define ICBID_MASTER_PCNOC_INT_3 125
  627. +#define ICBID_MASTER_PCNOC_INT_4 126
  628. +#define ICBID_MASTER_PCNOC_INT_5 127
  629. +#define ICBID_MASTER_PCNOC_INT_6 128
  630. +#define ICBID_MASTER_PCIE_2 119
  631. +#define ICBID_MASTER_MASTER_CNOC_A1NOC 116
  632. +#define ICBID_MASTER_A0NOC_SNOC 110
  633. +#define ICBID_MASTER_A1NOC_SNOC 111
  634. +#define ICBID_MASTER_A2NOC_SNOC 112
  635. +#define ICBID_MASTER_PNOC_A1NOC 117
  636. +#define ICBID_MASTER_ROTATOR 120
  637. +#define ICBID_MASTER_SNOC_VMEM 114
  638. +#define ICBID_MASTER_VENUS_VMEM 121
  639. +#define ICBID_MASTER_HMSS 118
  640. +#define ICBID_MASTER_BIMC_SNOC_1 109
  641. +#define ICBID_MASTER_CNOC_A1NOC 116
  642. +#define ICBID_MASTER_CPP 115
  643. +#define ICBID_MASTER_BLSP_BAM 130
  644. +#define ICBID_MASTER_USB2_BAM 131
  645. +#define ICBID_MASTER_ADSS_DMA0 132
  646. +#define ICBID_MASTER_ADSS_DMA1 133
  647. +#define ICBID_MASTER_ADSS_DMA2 134
  648. +#define ICBID_MASTER_ADSS_DMA3 135
  649. +#define ICBID_MASTER_QPIC_BAM 136
  650. +#define ICBID_MASTER_SDCC_BAM 137
  651. +#define ICBID_MASTER_DDRC_SNOC 138
  652. +#define ICBID_MASTER_WSS_0 139
  653. +#define ICBID_MASTER_WSS_1 140
  654. +#define ICBID_MASTER_ESS 141
  655. +#define ICBID_MASTER_PCIE 142
  656. +#define ICBID_MASTER_QDSS_BAMNDP 143
  657. +#define ICBID_MASTER_QDSS_SNOC_CFG 144
  658. +
  659. +#define ICBID_SLAVE_EBI1 0
  660. +#define ICBID_SLAVE_APPSS_L2 1
  661. +#define ICBID_SLAVE_BIMC_SNOC 2
  662. +#define ICBID_SLAVE_CAMERA_CFG 3
  663. +#define ICBID_SLAVE_DISPLAY_CFG 4
  664. +#define ICBID_SLAVE_OCMEM_CFG 5
  665. +#define ICBID_SLAVE_CPR_CFG 6
  666. +#define ICBID_SLAVE_CPR_XPU_CFG 7
  667. +#define ICBID_SLAVE_MISC_CFG 8
  668. +#define ICBID_SLAVE_MISC_XPU_CFG 9
  669. +#define ICBID_SLAVE_VENUS_CFG 10
  670. +#define ICBID_SLAVE_GFX3D_CFG 11
  671. +#define ICBID_SLAVE_MMSS_CLK_CFG 12
  672. +#define ICBID_SLAVE_MMSS_CLK_XPU_CFG 13
  673. +#define ICBID_SLAVE_MNOC_MPU_CFG 14
  674. +#define ICBID_SLAVE_ONOC_MPU_CFG 15
  675. +#define ICBID_SLAVE_MNOC_BIMC 16
  676. +#define ICBID_SLAVE_SERVICE_MNOC 17
  677. +#define ICBID_SLAVE_OCMEM 18
  678. +#define ICBID_SLAVE_GMEM ICBID_SLAVE_OCMEM
  679. +#define ICBID_SLAVE_SERVICE_ONOC 19
  680. +#define ICBID_SLAVE_APPSS 20
  681. +#define ICBID_SLAVE_LPASS 21
  682. +#define ICBID_SLAVE_USB3 22
  683. +#define ICBID_SLAVE_USB3_0 ICBID_SLAVE_USB3
  684. +#define ICBID_SLAVE_WCSS 23
  685. +#define ICBID_SLAVE_SNOC_BIMC 24
  686. +#define ICBID_SLAVE_SNOC_BIMC_0 ICBID_SLAVE_SNOC_BIMC
  687. +#define ICBID_SLAVE_SNOC_CNOC 25
  688. +#define ICBID_SLAVE_IMEM 26
  689. +#define ICBID_SLAVE_OCIMEM ICBID_SLAVE_IMEM
  690. +#define ICBID_SLAVE_SNOC_OVIRT 27
  691. +#define ICBID_SLAVE_SNOC_GVIRT ICBID_SLAVE_SNOC_OVIRT
  692. +#define ICBID_SLAVE_SNOC_PNOC 28
  693. +#define ICBID_SLAVE_SNOC_PCNOC ICBID_SLAVE_SNOC_PNOC
  694. +#define ICBID_SLAVE_SERVICE_SNOC 29
  695. +#define ICBID_SLAVE_QDSS_STM 30
  696. +#define ICBID_SLAVE_SDCC_1 31
  697. +#define ICBID_SLAVE_SDCC_3 32
  698. +#define ICBID_SLAVE_SDCC_2 33
  699. +#define ICBID_SLAVE_SDCC_4 34
  700. +#define ICBID_SLAVE_TSIF 35
  701. +#define ICBID_SLAVE_BAM_DMA 36
  702. +#define ICBID_SLAVE_BLSP_2 37
  703. +#define ICBID_SLAVE_USB_HSIC 38
  704. +#define ICBID_SLAVE_BLSP_1 39
  705. +#define ICBID_SLAVE_USB_HS 40
  706. +#define ICBID_SLAVE_USB_HS1 ICBID_SLAVE_USB_HS
  707. +#define ICBID_SLAVE_PDM 41
  708. +#define ICBID_SLAVE_PERIPH_APU_CFG 42
  709. +#define ICBID_SLAVE_PNOC_MPU_CFG 43
  710. +#define ICBID_SLAVE_PRNG 44
  711. +#define ICBID_SLAVE_PNOC_SNOC 45
  712. +#define ICBID_SLAVE_PCNOC_SNOC ICBID_SLAVE_PNOC_SNOC
  713. +#define ICBID_SLAVE_SERVICE_PNOC 46
  714. +#define ICBID_SLAVE_CLK_CTL 47
  715. +#define ICBID_SLAVE_CNOC_MSS 48
  716. +#define ICBID_SLAVE_PCNOC_MSS ICBID_SLAVE_CNOC_MSS
  717. +#define ICBID_SLAVE_SECURITY 49
  718. +#define ICBID_SLAVE_TCSR 50
  719. +#define ICBID_SLAVE_TLMM 51
  720. +#define ICBID_SLAVE_CRYPTO_0_CFG 52
  721. +#define ICBID_SLAVE_CRYPTO_1_CFG 53
  722. +#define ICBID_SLAVE_IMEM_CFG 54
  723. +#define ICBID_SLAVE_MESSAGE_RAM 55
  724. +#define ICBID_SLAVE_BIMC_CFG 56
  725. +#define ICBID_SLAVE_BOOT_ROM 57
  726. +#define ICBID_SLAVE_CNOC_MNOC_MMSS_CFG 58
  727. +#define ICBID_SLAVE_PMIC_ARB 59
  728. +#define ICBID_SLAVE_SPDM_WRAPPER 60
  729. +#define ICBID_SLAVE_DEHR_CFG 61
  730. +#define ICBID_SLAVE_MPM 62
  731. +#define ICBID_SLAVE_QDSS_CFG 63
  732. +#define ICBID_SLAVE_RBCPR_CFG 64
  733. +#define ICBID_SLAVE_RBCPR_CX_CFG ICBID_SLAVE_RBCPR_CFG
  734. +#define ICBID_SLAVE_RBCPR_QDSS_APU_CFG 65
  735. +#define ICBID_SLAVE_CNOC_MNOC_CFG 66
  736. +#define ICBID_SLAVE_SNOC_MPU_CFG 67
  737. +#define ICBID_SLAVE_CNOC_ONOC_CFG 68
  738. +#define ICBID_SLAVE_PNOC_CFG 69
  739. +#define ICBID_SLAVE_SNOC_CFG 70
  740. +#define ICBID_SLAVE_EBI1_DLL_CFG 71
  741. +#define ICBID_SLAVE_PHY_APU_CFG 72
  742. +#define ICBID_SLAVE_EBI1_PHY_CFG 73
  743. +#define ICBID_SLAVE_RPM 74
  744. +#define ICBID_SLAVE_CNOC_SNOC 75
  745. +#define ICBID_SLAVE_SERVICE_CNOC 76
  746. +#define ICBID_SLAVE_OVIRT_SNOC 77
  747. +#define ICBID_SLAVE_OVIRT_OCMEM 78
  748. +#define ICBID_SLAVE_USB_HS2 79
  749. +#define ICBID_SLAVE_QPIC 80
  750. +#define ICBID_SLAVE_IPS_CFG 81
  751. +#define ICBID_SLAVE_DSI_CFG 82
  752. +#define ICBID_SLAVE_USB3_1 83
  753. +#define ICBID_SLAVE_PCIE_0 84
  754. +#define ICBID_SLAVE_PCIE_1 85
  755. +#define ICBID_SLAVE_PSS_SMMU_CFG 86
  756. +#define ICBID_SLAVE_CRYPTO_2_CFG 87
  757. +#define ICBID_SLAVE_PCIE_0_CFG 88
  758. +#define ICBID_SLAVE_PCIE_1_CFG 89
  759. +#define ICBID_SLAVE_SATA_CFG 90
  760. +#define ICBID_SLAVE_SPSS_GENI_IR 91
  761. +#define ICBID_SLAVE_UFS_CFG 92
  762. +#define ICBID_SLAVE_AVSYNC_CFG 93
  763. +#define ICBID_SLAVE_VPU_CFG 94
  764. +#define ICBID_SLAVE_USB_PHY_CFG 95
  765. +#define ICBID_SLAVE_RBCPR_MX_CFG 96
  766. +#define ICBID_SLAVE_PCIE_PARF 97
  767. +#define ICBID_SLAVE_VCAP_CFG 98
  768. +#define ICBID_SLAVE_EMAC_CFG 99
  769. +#define ICBID_SLAVE_BCAST_CFG 100
  770. +#define ICBID_SLAVE_KLM_CFG 101
  771. +#define ICBID_SLAVE_DISPLAY_PWM 102
  772. +#define ICBID_SLAVE_GENI 103
  773. +#define ICBID_SLAVE_SNOC_BIMC_1 104
  774. +#define ICBID_SLAVE_AUDIO 105
  775. +#define ICBID_SLAVE_CATS_0 106
  776. +#define ICBID_SLAVE_CATS_1 107
  777. +#define ICBID_SLAVE_MM_INT_0 108
  778. +#define ICBID_SLAVE_MM_INT_1 109
  779. +#define ICBID_SLAVE_MM_INT_2 110
  780. +#define ICBID_SLAVE_MM_INT_BIMC 111
  781. +#define ICBID_SLAVE_MMU_MODEM_XPU_CFG 112
  782. +#define ICBID_SLAVE_MSS_INT 113
  783. +#define ICBID_SLAVE_PCNOC_INT_0 114
  784. +#define ICBID_SLAVE_PCNOC_INT_1 115
  785. +#define ICBID_SLAVE_PCNOC_M_0 116
  786. +#define ICBID_SLAVE_PCNOC_M_1 117
  787. +#define ICBID_SLAVE_PCNOC_S_0 118
  788. +#define ICBID_SLAVE_PCNOC_S_1 119
  789. +#define ICBID_SLAVE_PCNOC_S_2 120
  790. +#define ICBID_SLAVE_PCNOC_S_3 121
  791. +#define ICBID_SLAVE_PCNOC_S_4 122
  792. +#define ICBID_SLAVE_PCNOC_S_6 123
  793. +#define ICBID_SLAVE_PCNOC_S_7 124
  794. +#define ICBID_SLAVE_PCNOC_S_8 125
  795. +#define ICBID_SLAVE_PCNOC_S_9 126
  796. +#define ICBID_SLAVE_PRNG_XPU_CFG 127
  797. +#define ICBID_SLAVE_QDSS_INT 128
  798. +#define ICBID_SLAVE_RPM_XPU_CFG 129
  799. +#define ICBID_SLAVE_SNOC_INT_0 130
  800. +#define ICBID_SLAVE_SNOC_INT_1 131
  801. +#define ICBID_SLAVE_SNOC_INT_BIMC 132
  802. +#define ICBID_SLAVE_TCU 133
  803. +#define ICBID_SLAVE_BIMC_INT_0 134
  804. +#define ICBID_SLAVE_BIMC_INT_1 135
  805. +#define ICBID_SLAVE_RICA_CFG 136
  806. +#define ICBID_SLAVE_PCNOC_S_5 189
  807. +#define ICBID_SLAVE_PCNOC_S_7 124
  808. +#define ICBID_SLAVE_PCNOC_INT_2 184
  809. +#define ICBID_SLAVE_PCNOC_INT_3 185
  810. +#define ICBID_SLAVE_PCNOC_INT_4 186
  811. +#define ICBID_SLAVE_PCNOC_INT_5 187
  812. +#define ICBID_SLAVE_PCNOC_INT_6 188
  813. +#define ICBID_SLAVE_USB3_PHY_CFG 182
  814. +#define ICBID_SLAVE_IPA_CFG 183
  815. +
  816. +#define ICBID_SLAVE_A0NOC_SNOC 141
  817. +#define ICBID_SLAVE_A1NOC_SNOC 142
  818. +#define ICBID_SLAVE_A2NOC_SNOC 143
  819. +#define ICBID_SLAVE_BIMC_SNOC_1 138
  820. +#define ICBID_SLAVE_PIMEM 167
  821. +#define ICBID_SLAVE_PIMEM_CFG 168
  822. +#define ICBID_SLAVE_DCC_CFG 155
  823. +#define ICBID_SLAVE_QDSS_RBCPR_APU_CFG 168
  824. +#define ICBID_SLAVE_A0NOC_CFG 144
  825. +#define ICBID_SLAVE_PCIE_2_CFG 165
  826. +#define ICBID_SLAVE_PCIE20_AHB2PHY 163
  827. +#define ICBID_SLAVE_PCIE_2 164
  828. +#define ICBID_SLAVE_A1NOC_CFG 147
  829. +#define ICBID_SLAVE_A1NOC_MPU_CFG 148
  830. +#define ICBID_SLAVE_A1NOC_SMMU_CFG 149
  831. +#define ICBID_SLAVE_A2NOC_CFG 150
  832. +#define ICBID_SLAVE_A2NOC_MPU_CFG 151
  833. +#define ICBID_SLAVE_A2NOC_SMMU_CFG 152
  834. +#define ICBID_SLAVE_AHB2PHY 153
  835. +#define ICBID_SLAVE_HMSS_L3 161
  836. +#define ICBID_SLAVE_LPASS_SMMU_CFG 161
  837. +#define ICBID_SLAVE_MMAGIC_CFG 162
  838. +#define ICBID_SLAVE_SSC_CFG 177
  839. +#define ICBID_SLAVE_VENUS_THROTTLE_CFG 178
  840. +#define ICBID_SLAVE_DISPLAY_THROTTLE_CFG 156
  841. +#define ICBID_SLAVE_CAMERA_THROTTLE_CFG 154
  842. +#define ICBID_SLAVE_DSA_CFG 157
  843. +#define ICBID_SLAVE_DSA_MPU_CFG 158
  844. +#define ICBID_SLAVE_SMMU_CPP_CFG 171
  845. +#define ICBID_SLAVE_SMMU_JPEG_CFG 172
  846. +#define ICBID_SLAVE_SMMU_MDP_CFG 173
  847. +#define ICBID_SLAVE_SMMU_ROTATOR_CFG 174
  848. +#define ICBID_SLAVE_SMMU_VENUS_CFG 175
  849. +#define ICBID_SLAVE_SMMU_VFE_CFG 176
  850. +#define ICBID_SLAVE_A0NOC_MPU_CFG 145
  851. +#define ICBID_SLAVE_A0NOC_SMMU_CFG 146
  852. +#define ICBID_SLAVE_VMEM_CFG 180
  853. +#define ICBID_SLAVE_VMEM 179
  854. +#define ICBID_SLAVE_PNOC_A1NOC 139
  855. +#define ICBID_SLAVE_SNOC_VMEM 140
  856. +#define ICBID_SLAVE_RBCPR_MX 170
  857. +#define ICBID_SLAVE_RBCPR_CX 169
  858. +#define ICBID_SLAVE_PRNG_APU_CFG 190
  859. +#define ICBID_SLAVE_PERIPH_MPU_CFG 191
  860. +#define ICBID_SLAVE_GCNT 192
  861. +#define ICBID_SLAVE_ADSS_CFG 193
  862. +#define ICBID_SLAVE_ADSS_APU 194
  863. +#define ICBID_SLAVE_ADSS_VMIDMT_CFG 195
  864. +#define ICBID_SLAVE_QHSS_APU_CFG 196
  865. +#define ICBID_SLAVE_MDIO 197
  866. +#define ICBID_SLAVE_FEPHY_CFG 198
  867. +#define ICBID_SLAVE_SRIF 199
  868. +#define ICBID_SLAVE_DDRC_CFG 200
  869. +#define ICBID_SLAVE_DDRC_APU_CFG 201
  870. +#define ICBID_SLAVE_DDRC_MPU0_CFG 202
  871. +#define ICBID_SLAVE_DDRC_MPU1_CFG 203
  872. +#define ICBID_SLAVE_DDRC_MPU2_CFG 210
  873. +#define ICBID_SLAVE_ESS_VMIDMT_CFG 211
  874. +#define ICBID_SLAVE_ESS_APU_CFG 212
  875. +#define ICBID_SLAVE_USB2_CFG 213
  876. +#define ICBID_SLAVE_BLSP_CFG 214
  877. +#define ICBID_SLAVE_QPIC_CFG 215
  878. +#define ICBID_SLAVE_SDCC_CFG 216
  879. +#define ICBID_SLAVE_WSS0_VMIDMT_CFG 217
  880. +#define ICBID_SLAVE_WSS0_APU_CFG 218
  881. +#define ICBID_SLAVE_WSS1_VMIDMT_CFG 219
  882. +#define ICBID_SLAVE_WSS1_APU_CFG 220
  883. +#define ICBID_SLAVE_SRVC_PCNOC 221
  884. +#define ICBID_SLAVE_SNOC_DDRC 222
  885. +#define ICBID_SLAVE_A7SS 223
  886. +#define ICBID_SLAVE_WSS0_CFG 224
  887. +#define ICBID_SLAVE_WSS1_CFG 225
  888. +#define ICBID_SLAVE_PCIE 226
  889. +#define ICBID_SLAVE_USB3_CFG 227
  890. +#define ICBID_SLAVE_CRYPTO_CFG 228
  891. +#define ICBID_SLAVE_ESS_CFG 229
  892. +#define ICBID_SLAVE_SRVC_SNOC 230
  893. +#endif
  894. --- /dev/null
  895. +++ b/include/dt-bindings/msm/msm-bus-rule-ops.h
  896. @@ -0,0 +1,32 @@
  897. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  898. + *
  899. + * This program is free software; you can redistribute it and/or modify
  900. + * it under the terms of the GNU General Public License version 2 and
  901. + * only version 2 as published by the Free Software Foundation.
  902. + *
  903. + * This program is distributed in the hope that it will be useful,
  904. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  905. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  906. + * GNU General Public License for more details.
  907. + */
  908. +
  909. +#ifndef __MSM_BUS_RULE_OPS_H
  910. +#define __MSM_BUS_RULE_OPS_H
  911. +
  912. +#define FLD_IB 0
  913. +#define FLD_AB 1
  914. +#define FLD_CLK 2
  915. +
  916. +#define OP_LE 0
  917. +#define OP_LT 1
  918. +#define OP_GE 2
  919. +#define OP_GT 3
  920. +#define OP_NOOP 4
  921. +
  922. +#define RULE_STATE_NOT_APPLIED 0
  923. +#define RULE_STATE_APPLIED 1
  924. +
  925. +#define THROTTLE_ON 0
  926. +#define THROTTLE_OFF 1
  927. +
  928. +#endif
  929. --- /dev/null
  930. +++ b/drivers/bus/msm_bus/Kconfig
  931. @@ -0,0 +1,19 @@
  932. +config BUS_TOPOLOGY_ADHOC
  933. + bool "ad-hoc bus scaling topology"
  934. + depends on ARCH_QCOM
  935. + default n
  936. + help
  937. + This option enables a driver that can handle adhoc bus topologies.
  938. + Adhoc bus topology driver allows one to many connections and maintains
  939. + directionality of connections by explicitly listing device connections
  940. + thus avoiding illegal routes.
  941. +
  942. +config MSM_BUS_SCALING
  943. + bool "Bus scaling driver"
  944. + depends on BUS_TOPOLOGY_ADHOC
  945. + default n
  946. + help
  947. + This option enables bus scaling on MSM devices. Bus scaling
  948. + allows devices to request the clocks be set to rates sufficient
  949. + for the active devices needs without keeping the clocks at max
  950. + frequency when a slower speed is sufficient.
  951. --- /dev/null
  952. +++ b/drivers/bus/msm_bus/Makefile
  953. @@ -0,0 +1,12 @@
  954. +#
  955. +# Makefile for msm-bus driver specific files
  956. +#
  957. +obj-y += msm_bus_bimc.o msm_bus_noc.o msm_bus_core.o msm_bus_client_api.o \
  958. + msm_bus_id.o
  959. +obj-$(CONFIG_OF) += msm_bus_of.o
  960. +
  961. +obj-y += msm_bus_fabric_adhoc.o msm_bus_arb_adhoc.o msm_bus_rules.o
  962. +obj-$(CONFIG_OF) += msm_bus_of_adhoc.o
  963. +obj-$(CONFIG_CORESIGHT) += msm_buspm_coresight_adhoc.o
  964. +
  965. +obj-$(CONFIG_DEBUG_FS) += msm_bus_dbg.o
  966. --- /dev/null
  967. +++ b/drivers/bus/msm_bus/msm-bus-board.h
  968. @@ -0,0 +1,198 @@
  969. +/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
  970. + *
  971. + * This program is free software; you can redistribute it and/or modify
  972. + * it under the terms of the GNU General Public License version 2 and
  973. + * only version 2 as published by the Free Software Foundation.
  974. + *
  975. + * This program is distributed in the hope that it will be useful,
  976. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  977. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  978. + * GNU General Public License for more details.
  979. + */
  980. +
  981. +#ifndef __ASM_ARCH_MSM_BUS_BOARD_H
  982. +#define __ASM_ARCH_MSM_BUS_BOARD_H
  983. +
  984. +#include <linux/types.h>
  985. +#include <linux/input.h>
  986. +
  987. +enum context {
  988. + DUAL_CTX,
  989. + ACTIVE_CTX,
  990. + NUM_CTX
  991. +};
  992. +
  993. +struct msm_bus_fabric_registration {
  994. + unsigned int id;
  995. + const char *name;
  996. + struct msm_bus_node_info *info;
  997. + unsigned int len;
  998. + int ahb;
  999. + const char *fabclk[NUM_CTX];
  1000. + const char *iface_clk;
  1001. + unsigned int offset;
  1002. + unsigned int haltid;
  1003. + unsigned int rpm_enabled;
  1004. + unsigned int nmasters;
  1005. + unsigned int nslaves;
  1006. + unsigned int ntieredslaves;
  1007. + bool il_flag;
  1008. + const struct msm_bus_board_algorithm *board_algo;
  1009. + int hw_sel;
  1010. + void *hw_data;
  1011. + uint32_t qos_freq;
  1012. + uint32_t qos_baseoffset;
  1013. + u64 nr_lim_thresh;
  1014. + uint32_t eff_fact;
  1015. + uint32_t qos_delta;
  1016. + bool virt;
  1017. +};
  1018. +
  1019. +struct msm_bus_device_node_registration {
  1020. + struct msm_bus_node_device_type *info;
  1021. + unsigned int num_devices;
  1022. + bool virt;
  1023. +};
  1024. +
  1025. +enum msm_bus_bw_tier_type {
  1026. + MSM_BUS_BW_TIER1 = 1,
  1027. + MSM_BUS_BW_TIER2,
  1028. + MSM_BUS_BW_COUNT,
  1029. + MSM_BUS_BW_SIZE = 0x7FFFFFFF,
  1030. +};
  1031. +
  1032. +struct msm_bus_halt_vector {
  1033. + uint32_t haltval;
  1034. + uint32_t haltmask;
  1035. +};
  1036. +
  1037. +extern struct msm_bus_fabric_registration msm_bus_apps_fabric_pdata;
  1038. +extern struct msm_bus_fabric_registration msm_bus_sys_fabric_pdata;
  1039. +extern struct msm_bus_fabric_registration msm_bus_mm_fabric_pdata;
  1040. +extern struct msm_bus_fabric_registration msm_bus_sys_fpb_pdata;
  1041. +extern struct msm_bus_fabric_registration msm_bus_cpss_fpb_pdata;
  1042. +extern struct msm_bus_fabric_registration msm_bus_def_fab_pdata;
  1043. +
  1044. +extern struct msm_bus_fabric_registration msm_bus_8960_apps_fabric_pdata;
  1045. +extern struct msm_bus_fabric_registration msm_bus_8960_sys_fabric_pdata;
  1046. +extern struct msm_bus_fabric_registration msm_bus_8960_mm_fabric_pdata;
  1047. +extern struct msm_bus_fabric_registration msm_bus_8960_sg_mm_fabric_pdata;
  1048. +extern struct msm_bus_fabric_registration msm_bus_8960_sys_fpb_pdata;
  1049. +extern struct msm_bus_fabric_registration msm_bus_8960_cpss_fpb_pdata;
  1050. +
  1051. +extern struct msm_bus_fabric_registration msm_bus_8064_apps_fabric_pdata;
  1052. +extern struct msm_bus_fabric_registration msm_bus_8064_sys_fabric_pdata;
  1053. +extern struct msm_bus_fabric_registration msm_bus_8064_mm_fabric_pdata;
  1054. +extern struct msm_bus_fabric_registration msm_bus_8064_sys_fpb_pdata;
  1055. +extern struct msm_bus_fabric_registration msm_bus_8064_cpss_fpb_pdata;
  1056. +
  1057. +extern struct msm_bus_fabric_registration msm_bus_9615_sys_fabric_pdata;
  1058. +extern struct msm_bus_fabric_registration msm_bus_9615_def_fab_pdata;
  1059. +
  1060. +extern struct msm_bus_fabric_registration msm_bus_8930_apps_fabric_pdata;
  1061. +extern struct msm_bus_fabric_registration msm_bus_8930_sys_fabric_pdata;
  1062. +extern struct msm_bus_fabric_registration msm_bus_8930_mm_fabric_pdata;
  1063. +extern struct msm_bus_fabric_registration msm_bus_8930_sys_fpb_pdata;
  1064. +extern struct msm_bus_fabric_registration msm_bus_8930_cpss_fpb_pdata;
  1065. +
  1066. +extern struct msm_bus_fabric_registration msm_bus_8974_sys_noc_pdata;
  1067. +extern struct msm_bus_fabric_registration msm_bus_8974_mmss_noc_pdata;
  1068. +extern struct msm_bus_fabric_registration msm_bus_8974_bimc_pdata;
  1069. +extern struct msm_bus_fabric_registration msm_bus_8974_ocmem_noc_pdata;
  1070. +extern struct msm_bus_fabric_registration msm_bus_8974_periph_noc_pdata;
  1071. +extern struct msm_bus_fabric_registration msm_bus_8974_config_noc_pdata;
  1072. +extern struct msm_bus_fabric_registration msm_bus_8974_ocmem_vnoc_pdata;
  1073. +
  1074. +extern struct msm_bus_fabric_registration msm_bus_9625_sys_noc_pdata;
  1075. +extern struct msm_bus_fabric_registration msm_bus_9625_bimc_pdata;
  1076. +extern struct msm_bus_fabric_registration msm_bus_9625_periph_noc_pdata;
  1077. +extern struct msm_bus_fabric_registration msm_bus_9625_config_noc_pdata;
  1078. +
  1079. +extern int msm_bus_device_match_adhoc(struct device *dev, void *id);
  1080. +
  1081. +void msm_bus_rpm_set_mt_mask(void);
  1082. +int msm_bus_board_rpm_get_il_ids(uint16_t *id);
  1083. +int msm_bus_board_get_iid(int id);
  1084. +
  1085. +#define NFAB_MSM8226 6
  1086. +#define NFAB_MSM8610 5
  1087. +
  1088. +/*
  1089. + * These macros specify the convention followed for allocating
  1090. + * ids to fabrics, masters and slaves for 8x60.
  1091. + *
  1092. + * A node can be identified as a master/slave/fabric by using
  1093. + * these ids.
  1094. + */
  1095. +#define FABRIC_ID_KEY 1024
  1096. +#define SLAVE_ID_KEY ((FABRIC_ID_KEY) >> 1)
  1097. +#define MAX_FAB_KEY 7168 /* OR(All fabric ids) */
  1098. +#define INT_NODE_START 10000
  1099. +
  1100. +#define GET_FABID(id) ((id) & MAX_FAB_KEY)
  1101. +
  1102. +#define NODE_ID(id) ((id) & (FABRIC_ID_KEY - 1))
  1103. +#define IS_SLAVE(id) ((NODE_ID(id)) >= SLAVE_ID_KEY ? 1 : 0)
  1104. +#define CHECK_ID(iid, id) (((iid & id) != id) ? -ENXIO : iid)
  1105. +
  1106. +/*
  1107. + * The following macros are used to format the data for port halt
  1108. + * and unhalt requests.
  1109. + */
  1110. +#define MSM_BUS_CLK_HALT 0x1
  1111. +#define MSM_BUS_CLK_HALT_MASK 0x1
  1112. +#define MSM_BUS_CLK_HALT_FIELDSIZE 0x1
  1113. +#define MSM_BUS_CLK_UNHALT 0x0
  1114. +
  1115. +#define MSM_BUS_MASTER_SHIFT(master, fieldsize) \
  1116. + ((master) * (fieldsize))
  1117. +
  1118. +#define MSM_BUS_SET_BITFIELD(word, fieldmask, fieldvalue) \
  1119. + { \
  1120. + (word) &= ~(fieldmask); \
  1121. + (word) |= (fieldvalue); \
  1122. + }
  1123. +
  1124. +
  1125. +#define MSM_BUS_MASTER_HALT(u32haltmask, u32haltval, master) \
  1126. + MSM_BUS_SET_BITFIELD(u32haltmask, \
  1127. + MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\
  1128. + MSM_BUS_CLK_HALT_FIELDSIZE), \
  1129. + MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\
  1130. + MSM_BUS_CLK_HALT_FIELDSIZE))\
  1131. + MSM_BUS_SET_BITFIELD(u32haltval, \
  1132. + MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\
  1133. + MSM_BUS_CLK_HALT_FIELDSIZE), \
  1134. + MSM_BUS_CLK_HALT<<MSM_BUS_MASTER_SHIFT((master),\
  1135. + MSM_BUS_CLK_HALT_FIELDSIZE))\
  1136. +
  1137. +#define MSM_BUS_MASTER_UNHALT(u32haltmask, u32haltval, master) \
  1138. + MSM_BUS_SET_BITFIELD(u32haltmask, \
  1139. + MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\
  1140. + MSM_BUS_CLK_HALT_FIELDSIZE), \
  1141. + MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\
  1142. + MSM_BUS_CLK_HALT_FIELDSIZE))\
  1143. + MSM_BUS_SET_BITFIELD(u32haltval, \
  1144. + MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\
  1145. + MSM_BUS_CLK_HALT_FIELDSIZE), \
  1146. + MSM_BUS_CLK_UNHALT<<MSM_BUS_MASTER_SHIFT((master),\
  1147. + MSM_BUS_CLK_HALT_FIELDSIZE))\
  1148. +
  1149. +#define RPM_BUS_SLAVE_REQ 0x766c7362
  1150. +#define RPM_BUS_MASTER_REQ 0x73616d62
  1151. +
  1152. +enum msm_bus_rpm_slave_field_type {
  1153. + RPM_SLAVE_FIELD_BW = 0x00007762,
  1154. +};
  1155. +
  1156. +enum msm_bus_rpm_mas_field_type {
  1157. + RPM_MASTER_FIELD_BW = 0x00007762,
  1158. + RPM_MASTER_FIELD_BW_T0 = 0x30747762,
  1159. + RPM_MASTER_FIELD_BW_T1 = 0x31747762,
  1160. + RPM_MASTER_FIELD_BW_T2 = 0x32747762,
  1161. +};
  1162. +
  1163. +#include <dt-bindings/msm/msm-bus-ids.h>
  1164. +
  1165. +
  1166. +#endif /*__ASM_ARCH_MSM_BUS_BOARD_H */
  1167. --- /dev/null
  1168. +++ b/drivers/bus/msm_bus/msm-bus.h
  1169. @@ -0,0 +1,139 @@
  1170. +/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
  1171. + *
  1172. + * This program is free software; you can redistribute it and/or modify
  1173. + * it under the terms of the GNU General Public License version 2 and
  1174. + * only version 2 as published by the Free Software Foundation.
  1175. + *
  1176. + * This program is distributed in the hope that it will be useful,
  1177. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1178. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1179. + * GNU General Public License for more details.
  1180. + */
  1181. +
  1182. +#ifndef _ARCH_ARM_MACH_MSM_BUS_H
  1183. +#define _ARCH_ARM_MACH_MSM_BUS_H
  1184. +
  1185. +#include <linux/types.h>
  1186. +#include <linux/input.h>
  1187. +#include <linux/platform_device.h>
  1188. +
  1189. +/*
  1190. + * Macros for clients to convert their data to ib and ab
  1191. + * Ws : Time window over which to transfer the data in SECONDS
  1192. + * Bs : Size of the data block in bytes
  1193. + * Per : Recurrence period
  1194. + * Tb : Throughput bandwidth to prevent stalling
  1195. + * R : Ratio of actual bandwidth used to Tb
  1196. + * Ib : Instantaneous bandwidth
  1197. + * Ab : Arbitrated bandwidth
  1198. + *
  1199. + * IB_RECURRBLOCK and AB_RECURRBLOCK:
  1200. + * These are used if the requirement is to transfer a
  1201. + * recurring block of data over a known time window.
  1202. + *
  1203. + * IB_THROUGHPUTBW and AB_THROUGHPUTBW:
  1204. + * These are used for CPU style masters. Here the requirement
  1205. + * is to have minimum throughput bandwidth available to avoid
  1206. + * stalling.
  1207. + */
  1208. +#define IB_RECURRBLOCK(Ws, Bs) ((Ws) == 0 ? 0 : ((Bs)/(Ws)))
  1209. +#define AB_RECURRBLOCK(Ws, Per) ((Ws) == 0 ? 0 : ((Bs)/(Per)))
  1210. +#define IB_THROUGHPUTBW(Tb) (Tb)
  1211. +#define AB_THROUGHPUTBW(Tb, R) ((Tb) * (R))
  1212. +
  1213. +struct msm_bus_vectors {
  1214. + int src; /* Master */
  1215. + int dst; /* Slave */
  1216. + uint64_t ab; /* Arbitrated bandwidth */
  1217. + uint64_t ib; /* Instantaneous bandwidth */
  1218. +};
  1219. +
  1220. +struct msm_bus_paths {
  1221. + int num_paths;
  1222. + struct msm_bus_vectors *vectors;
  1223. +};
  1224. +
  1225. +struct msm_bus_scale_pdata {
  1226. + struct msm_bus_paths *usecase;
  1227. + int num_usecases;
  1228. + const char *name;
  1229. + /*
  1230. + * If the active_only flag is set to 1, the BW request is applied
  1231. + * only when at least one CPU is active (powered on). If the flag
  1232. + * is set to 0, then the BW request is always applied irrespective
  1233. + * of the CPU state.
  1234. + */
  1235. + unsigned int active_only;
  1236. +};
  1237. +
  1238. +/* Scaling APIs */
  1239. +
  1240. +/*
  1241. + * This function returns a handle to the client. This should be used to
  1242. + * call msm_bus_scale_client_update_request.
  1243. + * The function returns 0 if bus driver is unable to register a client
  1244. + */
  1245. +
  1246. +#if (defined(CONFIG_MSM_BUS_SCALING) || defined(CONFIG_BUS_TOPOLOGY_ADHOC))
  1247. +int __init msm_bus_fabric_init_driver(void);
  1248. +uint32_t msm_bus_scale_register_client(struct msm_bus_scale_pdata *pdata);
  1249. +int msm_bus_scale_client_update_request(uint32_t cl, unsigned int index);
  1250. +void msm_bus_scale_unregister_client(uint32_t cl);
  1251. +/* AXI Port configuration APIs */
  1252. +int msm_bus_axi_porthalt(int master_port);
  1253. +int msm_bus_axi_portunhalt(int master_port);
  1254. +
  1255. +#else
  1256. +static inline int __init msm_bus_fabric_init_driver(void) { return 0; }
  1257. +
  1258. +static inline uint32_t
  1259. +msm_bus_scale_register_client(struct msm_bus_scale_pdata *pdata)
  1260. +{
  1261. + return 1;
  1262. +}
  1263. +
  1264. +static inline int
  1265. +msm_bus_scale_client_update_request(uint32_t cl, unsigned int index)
  1266. +{
  1267. + return 0;
  1268. +}
  1269. +
  1270. +static inline void
  1271. +msm_bus_scale_unregister_client(uint32_t cl)
  1272. +{
  1273. +}
  1274. +
  1275. +static inline int msm_bus_axi_porthalt(int master_port)
  1276. +{
  1277. + return 0;
  1278. +}
  1279. +
  1280. +static inline int msm_bus_axi_portunhalt(int master_port)
  1281. +{
  1282. + return 0;
  1283. +}
  1284. +#endif
  1285. +
  1286. +#if defined(CONFIG_OF) && defined(CONFIG_MSM_BUS_SCALING)
  1287. +struct msm_bus_scale_pdata *msm_bus_pdata_from_node(
  1288. + struct platform_device *pdev, struct device_node *of_node);
  1289. +struct msm_bus_scale_pdata *msm_bus_cl_get_pdata(struct platform_device *pdev);
  1290. +void msm_bus_cl_clear_pdata(struct msm_bus_scale_pdata *pdata);
  1291. +#else
  1292. +static inline struct msm_bus_scale_pdata
  1293. +*msm_bus_cl_get_pdata(struct platform_device *pdev)
  1294. +{
  1295. + return NULL;
  1296. +}
  1297. +
  1298. +static inline struct msm_bus_scale_pdata *msm_bus_pdata_from_node(
  1299. + struct platform_device *pdev, struct device_node *of_node)
  1300. +{
  1301. + return NULL;
  1302. +}
  1303. +
  1304. +static inline void msm_bus_cl_clear_pdata(struct msm_bus_scale_pdata *pdata)
  1305. +{
  1306. +}
  1307. +#endif
  1308. +#endif /*_ARCH_ARM_MACH_MSM_BUS_H*/
  1309. --- /dev/null
  1310. +++ b/drivers/bus/msm_bus/msm_bus_adhoc.h
  1311. @@ -0,0 +1,141 @@
  1312. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  1313. + *
  1314. + * This program is free software; you can redistribute it and/or modify
  1315. + * it under the terms of the GNU General Public License version 2 and
  1316. + * only version 2 as published by the Free Software Foundation.
  1317. + *
  1318. + * This program is distributed in the hope that it will be useful,
  1319. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1320. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1321. + * GNU General Public License for more details.
  1322. + */
  1323. +
  1324. +#ifndef _ARCH_ARM_MACH_MSM_BUS_ADHOC_H
  1325. +#define _ARCH_ARM_MACH_MSM_BUS_ADHOC_H
  1326. +
  1327. +#include <linux/types.h>
  1328. +#include <linux/device.h>
  1329. +#include "msm-bus-board.h"
  1330. +#include "msm-bus.h"
  1331. +#include "msm_bus_rules.h"
  1332. +#include "msm_bus_core.h"
  1333. +
  1334. +struct msm_bus_node_device_type;
  1335. +struct link_node {
  1336. + uint64_t lnode_ib[NUM_CTX];
  1337. + uint64_t lnode_ab[NUM_CTX];
  1338. + int next;
  1339. + struct device *next_dev;
  1340. + struct list_head link;
  1341. + uint32_t in_use;
  1342. +};
  1343. +
  1344. +/* New types introduced for adhoc topology */
  1345. +struct msm_bus_noc_ops {
  1346. + int (*qos_init)(struct msm_bus_node_device_type *dev,
  1347. + void __iomem *qos_base, uint32_t qos_off,
  1348. + uint32_t qos_delta, uint32_t qos_freq);
  1349. + int (*set_bw)(struct msm_bus_node_device_type *dev,
  1350. + void __iomem *qos_base, uint32_t qos_off,
  1351. + uint32_t qos_delta, uint32_t qos_freq);
  1352. + int (*limit_mport)(struct msm_bus_node_device_type *dev,
  1353. + void __iomem *qos_base, uint32_t qos_off,
  1354. + uint32_t qos_delta, uint32_t qos_freq, bool enable_lim,
  1355. + uint64_t lim_bw);
  1356. + bool (*update_bw_reg)(int mode);
  1357. +};
  1358. +
  1359. +struct nodebw {
  1360. + uint64_t ab[NUM_CTX];
  1361. + bool dirty;
  1362. +};
  1363. +
  1364. +struct msm_bus_fab_device_type {
  1365. + void __iomem *qos_base;
  1366. + phys_addr_t pqos_base;
  1367. + size_t qos_range;
  1368. + uint32_t base_offset;
  1369. + uint32_t qos_freq;
  1370. + uint32_t qos_off;
  1371. + uint32_t util_fact;
  1372. + uint32_t vrail_comp;
  1373. + struct msm_bus_noc_ops noc_ops;
  1374. + enum msm_bus_hw_sel bus_type;
  1375. + bool bypass_qos_prg;
  1376. +};
  1377. +
  1378. +struct qos_params_type {
  1379. + int mode;
  1380. + unsigned int prio_lvl;
  1381. + unsigned int prio_rd;
  1382. + unsigned int prio_wr;
  1383. + unsigned int prio1;
  1384. + unsigned int prio0;
  1385. + unsigned int gp;
  1386. + unsigned int thmp;
  1387. + unsigned int ws;
  1388. + int cur_mode;
  1389. + u64 bw_buffer;
  1390. +};
  1391. +
  1392. +struct msm_bus_node_info_type {
  1393. + const char *name;
  1394. + unsigned int id;
  1395. + int mas_rpm_id;
  1396. + int slv_rpm_id;
  1397. + int num_ports;
  1398. + int num_qports;
  1399. + int *qport;
  1400. + struct qos_params_type qos_params;
  1401. + unsigned int num_connections;
  1402. + unsigned int num_blist;
  1403. + bool is_fab_dev;
  1404. + bool virt_dev;
  1405. + bool is_traversed;
  1406. + unsigned int *connections;
  1407. + unsigned int *black_listed_connections;
  1408. + struct device **dev_connections;
  1409. + struct device **black_connections;
  1410. + unsigned int bus_device_id;
  1411. + struct device *bus_device;
  1412. + unsigned int buswidth;
  1413. + struct rule_update_path_info rule;
  1414. + uint64_t lim_bw;
  1415. + uint32_t util_fact;
  1416. + uint32_t vrail_comp;
  1417. +};
  1418. +
  1419. +struct msm_bus_node_device_type {
  1420. + struct msm_bus_node_info_type *node_info;
  1421. + struct msm_bus_fab_device_type *fabdev;
  1422. + int num_lnodes;
  1423. + struct link_node *lnode_list;
  1424. + uint64_t cur_clk_hz[NUM_CTX];
  1425. + struct nodebw node_ab;
  1426. + struct list_head link;
  1427. + unsigned int ap_owned;
  1428. + struct nodeclk clk[NUM_CTX];
  1429. + struct nodeclk qos_clk;
  1430. +};
  1431. +
  1432. +int msm_bus_enable_limiter(struct msm_bus_node_device_type *nodedev,
  1433. + bool throttle_en, uint64_t lim_bw);
  1434. +int msm_bus_update_clks(struct msm_bus_node_device_type *nodedev,
  1435. + int ctx, int **dirty_nodes, int *num_dirty);
  1436. +int msm_bus_commit_data(int *dirty_nodes, int ctx, int num_dirty);
  1437. +int msm_bus_update_bw(struct msm_bus_node_device_type *nodedev, int ctx,
  1438. + int64_t add_bw, int **dirty_nodes, int *num_dirty);
  1439. +void *msm_bus_realloc_devmem(struct device *dev, void *p, size_t old_size,
  1440. + size_t new_size, gfp_t flags);
  1441. +
  1442. +extern struct msm_bus_device_node_registration
  1443. + *msm_bus_of_to_pdata(struct platform_device *pdev);
  1444. +extern void msm_bus_arb_setops_adhoc(struct msm_bus_arb_ops *arb_ops);
  1445. +extern int msm_bus_bimc_set_ops(struct msm_bus_node_device_type *bus_dev);
  1446. +extern int msm_bus_noc_set_ops(struct msm_bus_node_device_type *bus_dev);
  1447. +extern int msm_bus_of_get_static_rules(struct platform_device *pdev,
  1448. + struct bus_rule_type **static_rule);
  1449. +extern int msm_rules_update_path(struct list_head *input_list,
  1450. + struct list_head *output_list);
  1451. +extern void print_all_rules(void);
  1452. +#endif /* _ARCH_ARM_MACH_MSM_BUS_ADHOC_H */
  1453. --- /dev/null
  1454. +++ b/drivers/bus/msm_bus/msm_bus_arb_adhoc.c
  1455. @@ -0,0 +1,998 @@
  1456. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  1457. + *
  1458. + * This program is Mree software; you can redistribute it and/or modify
  1459. + * it under the terms of the GNU General Public License version 2 and
  1460. + * only version 2 as published by the Free Software Foundation.
  1461. + *
  1462. + * This program is distributed in the hope that it will be useful,
  1463. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1464. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1465. + * GNU General Public License for more details.
  1466. + */
  1467. +#include <linux/kernel.h>
  1468. +#include <linux/init.h>
  1469. +#include <linux/list.h>
  1470. +#include <linux/module.h>
  1471. +#include <linux/slab.h>
  1472. +#include <linux/mutex.h>
  1473. +#include <linux/clk.h>
  1474. +#include "msm-bus.h"
  1475. +#include "msm_bus_core.h"
  1476. +#include "msm_bus_adhoc.h"
  1477. +
  1478. +#define NUM_CL_HANDLES 50
  1479. +#define NUM_LNODES 3
  1480. +
  1481. +struct bus_search_type {
  1482. + struct list_head link;
  1483. + struct list_head node_list;
  1484. +};
  1485. +
  1486. +struct handle_type {
  1487. + int num_entries;
  1488. + struct msm_bus_client **cl_list;
  1489. +};
  1490. +
  1491. +static struct handle_type handle_list;
  1492. +struct list_head input_list;
  1493. +struct list_head apply_list;
  1494. +
  1495. +DEFINE_MUTEX(msm_bus_adhoc_lock);
  1496. +
  1497. +static bool chk_bl_list(struct list_head *black_list, unsigned int id)
  1498. +{
  1499. + struct msm_bus_node_device_type *bus_node = NULL;
  1500. +
  1501. + list_for_each_entry(bus_node, black_list, link) {
  1502. + if (bus_node->node_info->id == id)
  1503. + return true;
  1504. + }
  1505. + return false;
  1506. +}
  1507. +
  1508. +static void copy_remaining_nodes(struct list_head *edge_list, struct list_head
  1509. + *traverse_list, struct list_head *route_list)
  1510. +{
  1511. + struct bus_search_type *search_node;
  1512. +
  1513. + if (list_empty(edge_list) && list_empty(traverse_list))
  1514. + return;
  1515. +
  1516. + search_node = kzalloc(sizeof(struct bus_search_type), GFP_KERNEL);
  1517. + INIT_LIST_HEAD(&search_node->node_list);
  1518. + list_splice_init(edge_list, traverse_list);
  1519. + list_splice_init(traverse_list, &search_node->node_list);
  1520. + list_add_tail(&search_node->link, route_list);
  1521. +}
  1522. +
  1523. +/*
  1524. + * Duplicate instantiaion from msm_bus_arb.c. Todo there needs to be a
  1525. + * "util" file for these common func/macros.
  1526. + *
  1527. + * */
  1528. +uint64_t msm_bus_div64(unsigned int w, uint64_t bw)
  1529. +{
  1530. + uint64_t *b = &bw;
  1531. +
  1532. + if ((bw > 0) && (bw < w))
  1533. + return 1;
  1534. +
  1535. + switch (w) {
  1536. + case 0:
  1537. + WARN(1, "AXI: Divide by 0 attempted\n");
  1538. + case 1: return bw;
  1539. + case 2: return (bw >> 1);
  1540. + case 4: return (bw >> 2);
  1541. + case 8: return (bw >> 3);
  1542. + case 16: return (bw >> 4);
  1543. + case 32: return (bw >> 5);
  1544. + }
  1545. +
  1546. + do_div(*b, w);
  1547. + return *b;
  1548. +}
  1549. +
  1550. +int msm_bus_device_match_adhoc(struct device *dev, void *id)
  1551. +{
  1552. + int ret = 0;
  1553. + struct msm_bus_node_device_type *bnode = dev->platform_data;
  1554. +
  1555. + if (bnode)
  1556. + ret = (bnode->node_info->id == *(unsigned int *)id);
  1557. + else
  1558. + ret = 0;
  1559. +
  1560. + return ret;
  1561. +}
  1562. +
  1563. +static int gen_lnode(struct device *dev,
  1564. + int next_hop, int prev_idx)
  1565. +{
  1566. + struct link_node *lnode;
  1567. + struct msm_bus_node_device_type *cur_dev = NULL;
  1568. + int lnode_idx = -1;
  1569. +
  1570. + if (!dev)
  1571. + goto exit_gen_lnode;
  1572. +
  1573. + cur_dev = dev->platform_data;
  1574. + if (!cur_dev) {
  1575. + MSM_BUS_ERR("%s: Null device ptr", __func__);
  1576. + goto exit_gen_lnode;
  1577. + }
  1578. +
  1579. + if (!cur_dev->num_lnodes) {
  1580. + cur_dev->lnode_list = devm_kzalloc(dev,
  1581. + sizeof(struct link_node) * NUM_LNODES,
  1582. + GFP_KERNEL);
  1583. + if (!cur_dev->lnode_list)
  1584. + goto exit_gen_lnode;
  1585. +
  1586. + lnode = cur_dev->lnode_list;
  1587. + cur_dev->num_lnodes = NUM_LNODES;
  1588. + lnode_idx = 0;
  1589. + } else {
  1590. + int i;
  1591. + for (i = 0; i < cur_dev->num_lnodes; i++) {
  1592. + if (!cur_dev->lnode_list[i].in_use)
  1593. + break;
  1594. + }
  1595. +
  1596. + if (i < cur_dev->num_lnodes) {
  1597. + lnode = &cur_dev->lnode_list[i];
  1598. + lnode_idx = i;
  1599. + } else {
  1600. + struct link_node *realloc_list;
  1601. + size_t cur_size = sizeof(struct link_node) *
  1602. + cur_dev->num_lnodes;
  1603. +
  1604. + cur_dev->num_lnodes += NUM_LNODES;
  1605. + realloc_list = msm_bus_realloc_devmem(
  1606. + dev,
  1607. + cur_dev->lnode_list,
  1608. + cur_size,
  1609. + sizeof(struct link_node) *
  1610. + cur_dev->num_lnodes, GFP_KERNEL);
  1611. +
  1612. + if (!realloc_list)
  1613. + goto exit_gen_lnode;
  1614. +
  1615. + cur_dev->lnode_list = realloc_list;
  1616. + lnode = &cur_dev->lnode_list[i];
  1617. + lnode_idx = i;
  1618. + }
  1619. + }
  1620. +
  1621. + lnode->in_use = 1;
  1622. + if (next_hop == cur_dev->node_info->id) {
  1623. + lnode->next = -1;
  1624. + lnode->next_dev = NULL;
  1625. + } else {
  1626. + lnode->next = prev_idx;
  1627. + lnode->next_dev = bus_find_device(&msm_bus_type, NULL,
  1628. + (void *) &next_hop,
  1629. + msm_bus_device_match_adhoc);
  1630. + }
  1631. +
  1632. + memset(lnode->lnode_ib, 0, sizeof(uint64_t) * NUM_CTX);
  1633. + memset(lnode->lnode_ab, 0, sizeof(uint64_t) * NUM_CTX);
  1634. +
  1635. +exit_gen_lnode:
  1636. + return lnode_idx;
  1637. +}
  1638. +
  1639. +static int remove_lnode(struct msm_bus_node_device_type *cur_dev,
  1640. + int lnode_idx)
  1641. +{
  1642. + int ret = 0;
  1643. +
  1644. + if (!cur_dev) {
  1645. + MSM_BUS_ERR("%s: Null device ptr", __func__);
  1646. + ret = -ENODEV;
  1647. + goto exit_remove_lnode;
  1648. + }
  1649. +
  1650. + if (lnode_idx != -1) {
  1651. + if (!cur_dev->num_lnodes ||
  1652. + (lnode_idx > (cur_dev->num_lnodes - 1))) {
  1653. + MSM_BUS_ERR("%s: Invalid Idx %d, num_lnodes %d",
  1654. + __func__, lnode_idx, cur_dev->num_lnodes);
  1655. + ret = -ENODEV;
  1656. + goto exit_remove_lnode;
  1657. + }
  1658. +
  1659. + cur_dev->lnode_list[lnode_idx].next = -1;
  1660. + cur_dev->lnode_list[lnode_idx].next_dev = NULL;
  1661. + cur_dev->lnode_list[lnode_idx].in_use = 0;
  1662. + }
  1663. +
  1664. +exit_remove_lnode:
  1665. + return ret;
  1666. +}
  1667. +
  1668. +static int prune_path(struct list_head *route_list, int dest, int src,
  1669. + struct list_head *black_list, int found)
  1670. +{
  1671. + struct bus_search_type *search_node, *temp_search_node;
  1672. + struct msm_bus_node_device_type *bus_node;
  1673. + struct list_head *bl_list;
  1674. + struct list_head *temp_bl_list;
  1675. + int search_dev_id = dest;
  1676. + struct device *dest_dev = bus_find_device(&msm_bus_type, NULL,
  1677. + (void *) &dest,
  1678. + msm_bus_device_match_adhoc);
  1679. + int lnode_hop = -1;
  1680. +
  1681. + if (!found)
  1682. + goto reset_links;
  1683. +
  1684. + if (!dest_dev) {
  1685. + MSM_BUS_ERR("%s: Can't find dest dev %d", __func__, dest);
  1686. + goto exit_prune_path;
  1687. + }
  1688. +
  1689. + lnode_hop = gen_lnode(dest_dev, search_dev_id, lnode_hop);
  1690. +
  1691. + list_for_each_entry_reverse(search_node, route_list, link) {
  1692. + list_for_each_entry(bus_node, &search_node->node_list, link) {
  1693. + unsigned int i;
  1694. + for (i = 0; i < bus_node->node_info->num_connections;
  1695. + i++) {
  1696. + if (bus_node->node_info->connections[i] ==
  1697. + search_dev_id) {
  1698. + dest_dev = bus_find_device(
  1699. + &msm_bus_type,
  1700. + NULL,
  1701. + (void *)
  1702. + &bus_node->node_info->
  1703. + id,
  1704. + msm_bus_device_match_adhoc);
  1705. +
  1706. + if (!dest_dev) {
  1707. + lnode_hop = -1;
  1708. + goto reset_links;
  1709. + }
  1710. +
  1711. + lnode_hop = gen_lnode(dest_dev,
  1712. + search_dev_id,
  1713. + lnode_hop);
  1714. + search_dev_id =
  1715. + bus_node->node_info->id;
  1716. + break;
  1717. + }
  1718. + }
  1719. + }
  1720. + }
  1721. +reset_links:
  1722. + list_for_each_entry_safe(search_node, temp_search_node, route_list,
  1723. + link) {
  1724. + list_for_each_entry(bus_node, &search_node->node_list,
  1725. + link)
  1726. + bus_node->node_info->is_traversed = false;
  1727. +
  1728. + list_del(&search_node->link);
  1729. + kfree(search_node);
  1730. + }
  1731. +
  1732. + list_for_each_safe(bl_list, temp_bl_list, black_list)
  1733. + list_del(bl_list);
  1734. +
  1735. +exit_prune_path:
  1736. + return lnode_hop;
  1737. +}
  1738. +
  1739. +static void setup_bl_list(struct msm_bus_node_device_type *node,
  1740. + struct list_head *black_list)
  1741. +{
  1742. + unsigned int i;
  1743. +
  1744. + for (i = 0; i < node->node_info->num_blist; i++) {
  1745. + struct msm_bus_node_device_type *bdev;
  1746. + bdev = node->node_info->black_connections[i]->platform_data;
  1747. + list_add_tail(&bdev->link, black_list);
  1748. + }
  1749. +}
  1750. +
  1751. +static int getpath(int src, int dest)
  1752. +{
  1753. + struct list_head traverse_list;
  1754. + struct list_head edge_list;
  1755. + struct list_head route_list;
  1756. + struct list_head black_list;
  1757. + struct device *src_dev = bus_find_device(&msm_bus_type, NULL,
  1758. + (void *) &src,
  1759. + msm_bus_device_match_adhoc);
  1760. + struct msm_bus_node_device_type *src_node;
  1761. + struct bus_search_type *search_node;
  1762. + int found = 0;
  1763. + int depth_index = 0;
  1764. + int first_hop = -1;
  1765. +
  1766. + INIT_LIST_HEAD(&traverse_list);
  1767. + INIT_LIST_HEAD(&edge_list);
  1768. + INIT_LIST_HEAD(&route_list);
  1769. + INIT_LIST_HEAD(&black_list);
  1770. +
  1771. + if (!src_dev) {
  1772. + MSM_BUS_ERR("%s: Cannot locate src dev %d", __func__, src);
  1773. + goto exit_getpath;
  1774. + }
  1775. +
  1776. + src_node = src_dev->platform_data;
  1777. + if (!src_node) {
  1778. + MSM_BUS_ERR("%s:Fatal, Source dev %d not found", __func__, src);
  1779. + goto exit_getpath;
  1780. + }
  1781. + list_add_tail(&src_node->link, &traverse_list);
  1782. +
  1783. + while ((!found && !list_empty(&traverse_list))) {
  1784. + struct msm_bus_node_device_type *bus_node = NULL;
  1785. + /* Locate dest_id in the traverse list */
  1786. + list_for_each_entry(bus_node, &traverse_list, link) {
  1787. + if (bus_node->node_info->id == dest) {
  1788. + found = 1;
  1789. + break;
  1790. + }
  1791. + }
  1792. +
  1793. + if (!found) {
  1794. + unsigned int i;
  1795. + /* Setup the new edge list */
  1796. + list_for_each_entry(bus_node, &traverse_list, link) {
  1797. + /* Setup list of black-listed nodes */
  1798. + setup_bl_list(bus_node, &black_list);
  1799. +
  1800. + for (i = 0; i < bus_node->node_info->
  1801. + num_connections; i++) {
  1802. + bool skip;
  1803. + struct msm_bus_node_device_type
  1804. + *node_conn;
  1805. + node_conn = bus_node->node_info->
  1806. + dev_connections[i]->
  1807. + platform_data;
  1808. + if (node_conn->node_info->
  1809. + is_traversed) {
  1810. + MSM_BUS_ERR("Circ Path %d\n",
  1811. + node_conn->node_info->id);
  1812. + goto reset_traversed;
  1813. + }
  1814. + skip = chk_bl_list(&black_list,
  1815. + bus_node->node_info->
  1816. + connections[i]);
  1817. + if (!skip) {
  1818. + list_add_tail(&node_conn->link,
  1819. + &edge_list);
  1820. + node_conn->node_info->
  1821. + is_traversed = true;
  1822. + }
  1823. + }
  1824. + }
  1825. +
  1826. + /* Keep tabs of the previous search list */
  1827. + search_node = kzalloc(sizeof(struct bus_search_type),
  1828. + GFP_KERNEL);
  1829. + INIT_LIST_HEAD(&search_node->node_list);
  1830. + list_splice_init(&traverse_list,
  1831. + &search_node->node_list);
  1832. + /* Add the previous search list to a route list */
  1833. + list_add_tail(&search_node->link, &route_list);
  1834. + /* Advancing the list depth */
  1835. + depth_index++;
  1836. + list_splice_init(&edge_list, &traverse_list);
  1837. + }
  1838. + }
  1839. +reset_traversed:
  1840. + copy_remaining_nodes(&edge_list, &traverse_list, &route_list);
  1841. + first_hop = prune_path(&route_list, dest, src, &black_list, found);
  1842. +
  1843. +exit_getpath:
  1844. + return first_hop;
  1845. +}
  1846. +
  1847. +static uint64_t arbitrate_bus_req(struct msm_bus_node_device_type *bus_dev,
  1848. + int ctx)
  1849. +{
  1850. + int i;
  1851. + uint64_t max_ib = 0;
  1852. + uint64_t sum_ab = 0;
  1853. + uint64_t bw_max_hz;
  1854. + struct msm_bus_node_device_type *fab_dev = NULL;
  1855. + uint32_t util_fact = 0;
  1856. + uint32_t vrail_comp = 0;
  1857. +
  1858. + /* Find max ib */
  1859. + for (i = 0; i < bus_dev->num_lnodes; i++) {
  1860. + max_ib = max(max_ib, bus_dev->lnode_list[i].lnode_ib[ctx]);
  1861. + sum_ab += bus_dev->lnode_list[i].lnode_ab[ctx];
  1862. + }
  1863. + /*
  1864. + * Account for Util factor and vrail comp. The new aggregation
  1865. + * formula is:
  1866. + * Freq_hz = max((sum(ab) * util_fact)/num_chan, max(ib)/vrail_comp)
  1867. + * / bus-width
  1868. + * util_fact and vrail comp are obtained from fabric/Node's dts
  1869. + * properties.
  1870. + * They default to 100 if absent.
  1871. + */
  1872. + fab_dev = bus_dev->node_info->bus_device->platform_data;
  1873. + /* Don't do this for virtual fabrics */
  1874. + if (fab_dev && fab_dev->fabdev) {
  1875. + util_fact = bus_dev->node_info->util_fact ?
  1876. + bus_dev->node_info->util_fact :
  1877. + fab_dev->fabdev->util_fact;
  1878. + vrail_comp = bus_dev->node_info->vrail_comp ?
  1879. + bus_dev->node_info->vrail_comp :
  1880. + fab_dev->fabdev->vrail_comp;
  1881. + sum_ab *= util_fact;
  1882. + sum_ab = msm_bus_div64(100, sum_ab);
  1883. + max_ib *= 100;
  1884. + max_ib = msm_bus_div64(vrail_comp, max_ib);
  1885. + }
  1886. +
  1887. + /* Account for multiple channels if any */
  1888. + if (bus_dev->node_info->num_qports > 1)
  1889. + sum_ab = msm_bus_div64(bus_dev->node_info->num_qports,
  1890. + sum_ab);
  1891. +
  1892. + if (!bus_dev->node_info->buswidth) {
  1893. + MSM_BUS_WARN("No bus width found for %d. Using default\n",
  1894. + bus_dev->node_info->id);
  1895. + bus_dev->node_info->buswidth = 8;
  1896. + }
  1897. +
  1898. + bw_max_hz = max(max_ib, sum_ab);
  1899. + bw_max_hz = msm_bus_div64(bus_dev->node_info->buswidth,
  1900. + bw_max_hz);
  1901. +
  1902. + return bw_max_hz;
  1903. +}
  1904. +
  1905. +static void del_inp_list(struct list_head *list)
  1906. +{
  1907. + struct rule_update_path_info *rule_node;
  1908. + struct rule_update_path_info *rule_node_tmp;
  1909. +
  1910. + list_for_each_entry_safe(rule_node, rule_node_tmp, list, link)
  1911. + list_del(&rule_node->link);
  1912. +}
  1913. +
  1914. +static void del_op_list(struct list_head *list)
  1915. +{
  1916. + struct rule_apply_rcm_info *rule;
  1917. + struct rule_apply_rcm_info *rule_tmp;
  1918. +
  1919. + list_for_each_entry_safe(rule, rule_tmp, list, link)
  1920. + list_del(&rule->link);
  1921. +}
  1922. +
  1923. +static int msm_bus_apply_rules(struct list_head *list, bool after_clk_commit)
  1924. +{
  1925. + struct rule_apply_rcm_info *rule;
  1926. + struct device *dev = NULL;
  1927. + struct msm_bus_node_device_type *dev_info = NULL;
  1928. + int ret = 0;
  1929. + bool throttle_en = false;
  1930. +
  1931. + list_for_each_entry(rule, list, link) {
  1932. + if (!rule)
  1933. + break;
  1934. +
  1935. + if (rule && (rule->after_clk_commit != after_clk_commit))
  1936. + continue;
  1937. +
  1938. + dev = bus_find_device(&msm_bus_type, NULL,
  1939. + (void *) &rule->id,
  1940. + msm_bus_device_match_adhoc);
  1941. +
  1942. + if (!dev) {
  1943. + MSM_BUS_ERR("Can't find dev node for %d", rule->id);
  1944. + continue;
  1945. + }
  1946. + dev_info = dev->platform_data;
  1947. +
  1948. + throttle_en = ((rule->throttle == THROTTLE_ON) ? true : false);
  1949. + ret = msm_bus_enable_limiter(dev_info, throttle_en,
  1950. + rule->lim_bw);
  1951. + if (ret)
  1952. + MSM_BUS_ERR("Failed to set limiter for %d", rule->id);
  1953. + }
  1954. +
  1955. + return ret;
  1956. +}
  1957. +
  1958. +static uint64_t get_node_aggab(struct msm_bus_node_device_type *bus_dev)
  1959. +{
  1960. + int i;
  1961. + int ctx;
  1962. + uint64_t max_agg_ab = 0;
  1963. + uint64_t agg_ab = 0;
  1964. +
  1965. + for (ctx = 0; ctx < NUM_CTX; ctx++) {
  1966. + for (i = 0; i < bus_dev->num_lnodes; i++)
  1967. + agg_ab += bus_dev->lnode_list[i].lnode_ab[ctx];
  1968. +
  1969. + if (bus_dev->node_info->num_qports > 1)
  1970. + agg_ab = msm_bus_div64(bus_dev->node_info->num_qports,
  1971. + agg_ab);
  1972. +
  1973. + max_agg_ab = max(max_agg_ab, agg_ab);
  1974. + }
  1975. +
  1976. + return max_agg_ab;
  1977. +}
  1978. +
  1979. +static uint64_t get_node_ib(struct msm_bus_node_device_type *bus_dev)
  1980. +{
  1981. + int i;
  1982. + int ctx;
  1983. + uint64_t max_ib = 0;
  1984. +
  1985. + for (ctx = 0; ctx < NUM_CTX; ctx++) {
  1986. + for (i = 0; i < bus_dev->num_lnodes; i++)
  1987. + max_ib = max(max_ib,
  1988. + bus_dev->lnode_list[i].lnode_ib[ctx]);
  1989. + }
  1990. + return max_ib;
  1991. +}
  1992. +
  1993. +static int update_path(int src, int dest, uint64_t req_ib, uint64_t req_bw,
  1994. + uint64_t cur_ib, uint64_t cur_bw, int src_idx, int ctx)
  1995. +{
  1996. + struct device *src_dev = NULL;
  1997. + struct device *next_dev = NULL;
  1998. + struct link_node *lnode = NULL;
  1999. + struct msm_bus_node_device_type *dev_info = NULL;
  2000. + int curr_idx;
  2001. + int ret = 0;
  2002. + int *dirty_nodes = NULL;
  2003. + int num_dirty = 0;
  2004. + struct rule_update_path_info *rule_node;
  2005. + bool rules_registered = msm_rule_are_rules_registered();
  2006. +
  2007. + src_dev = bus_find_device(&msm_bus_type, NULL,
  2008. + (void *) &src,
  2009. + msm_bus_device_match_adhoc);
  2010. +
  2011. + if (!src_dev) {
  2012. + MSM_BUS_ERR("%s: Can't find source device %d", __func__, src);
  2013. + ret = -ENODEV;
  2014. + goto exit_update_path;
  2015. + }
  2016. +
  2017. + next_dev = src_dev;
  2018. +
  2019. + if (src_idx < 0) {
  2020. + MSM_BUS_ERR("%s: Invalid lnode idx %d", __func__, src_idx);
  2021. + ret = -ENXIO;
  2022. + goto exit_update_path;
  2023. + }
  2024. + curr_idx = src_idx;
  2025. +
  2026. + INIT_LIST_HEAD(&input_list);
  2027. + INIT_LIST_HEAD(&apply_list);
  2028. +
  2029. + while (next_dev) {
  2030. + dev_info = next_dev->platform_data;
  2031. +
  2032. + if (curr_idx >= dev_info->num_lnodes) {
  2033. + MSM_BUS_ERR("%s: Invalid lnode Idx %d num lnodes %d",
  2034. + __func__, curr_idx, dev_info->num_lnodes);
  2035. + ret = -ENXIO;
  2036. + goto exit_update_path;
  2037. + }
  2038. +
  2039. + lnode = &dev_info->lnode_list[curr_idx];
  2040. + lnode->lnode_ib[ctx] = req_ib;
  2041. + lnode->lnode_ab[ctx] = req_bw;
  2042. +
  2043. + dev_info->cur_clk_hz[ctx] = arbitrate_bus_req(dev_info, ctx);
  2044. +
  2045. + /* Start updating the clocks at the first hop.
  2046. + * Its ok to figure out the aggregated
  2047. + * request at this node.
  2048. + */
  2049. + if (src_dev != next_dev) {
  2050. + ret = msm_bus_update_clks(dev_info, ctx, &dirty_nodes,
  2051. + &num_dirty);
  2052. + if (ret) {
  2053. + MSM_BUS_ERR("%s: Failed to update clks dev %d",
  2054. + __func__, dev_info->node_info->id);
  2055. + goto exit_update_path;
  2056. + }
  2057. + }
  2058. +
  2059. + ret = msm_bus_update_bw(dev_info, ctx, req_bw, &dirty_nodes,
  2060. + &num_dirty);
  2061. + if (ret) {
  2062. + MSM_BUS_ERR("%s: Failed to update bw dev %d",
  2063. + __func__, dev_info->node_info->id);
  2064. + goto exit_update_path;
  2065. + }
  2066. +
  2067. + if (rules_registered) {
  2068. + rule_node = &dev_info->node_info->rule;
  2069. + rule_node->id = dev_info->node_info->id;
  2070. + rule_node->ib = get_node_ib(dev_info);
  2071. + rule_node->ab = get_node_aggab(dev_info);
  2072. + rule_node->clk = max(dev_info->cur_clk_hz[ACTIVE_CTX],
  2073. + dev_info->cur_clk_hz[DUAL_CTX]);
  2074. + list_add_tail(&rule_node->link, &input_list);
  2075. + }
  2076. +
  2077. + next_dev = lnode->next_dev;
  2078. + curr_idx = lnode->next;
  2079. + }
  2080. +
  2081. + if (rules_registered) {
  2082. + msm_rules_update_path(&input_list, &apply_list);
  2083. + msm_bus_apply_rules(&apply_list, false);
  2084. + }
  2085. +
  2086. + msm_bus_commit_data(dirty_nodes, ctx, num_dirty);
  2087. +
  2088. + if (rules_registered) {
  2089. + msm_bus_apply_rules(&apply_list, true);
  2090. + del_inp_list(&input_list);
  2091. + del_op_list(&apply_list);
  2092. + }
  2093. +exit_update_path:
  2094. + return ret;
  2095. +}
  2096. +
  2097. +static int remove_path(int src, int dst, uint64_t cur_ib, uint64_t cur_ab,
  2098. + int src_idx, int active_only)
  2099. +{
  2100. + struct device *src_dev = NULL;
  2101. + struct device *next_dev = NULL;
  2102. + struct link_node *lnode = NULL;
  2103. + struct msm_bus_node_device_type *dev_info = NULL;
  2104. + int ret = 0;
  2105. + int cur_idx = src_idx;
  2106. + int next_idx;
  2107. +
  2108. + /* Update the current path to zero out all request from
  2109. + * this cient on all paths
  2110. + */
  2111. +
  2112. + ret = update_path(src, dst, 0, 0, cur_ib, cur_ab, src_idx,
  2113. + active_only);
  2114. + if (ret) {
  2115. + MSM_BUS_ERR("%s: Error zeroing out path ctx %d",
  2116. + __func__, ACTIVE_CTX);
  2117. + goto exit_remove_path;
  2118. + }
  2119. +
  2120. + src_dev = bus_find_device(&msm_bus_type, NULL,
  2121. + (void *) &src,
  2122. + msm_bus_device_match_adhoc);
  2123. + if (!src_dev) {
  2124. + MSM_BUS_ERR("%s: Can't find source device %d", __func__, src);
  2125. + ret = -ENODEV;
  2126. + goto exit_remove_path;
  2127. + }
  2128. +
  2129. + next_dev = src_dev;
  2130. +
  2131. + while (next_dev) {
  2132. + dev_info = next_dev->platform_data;
  2133. + lnode = &dev_info->lnode_list[cur_idx];
  2134. + next_idx = lnode->next;
  2135. + next_dev = lnode->next_dev;
  2136. + remove_lnode(dev_info, cur_idx);
  2137. + cur_idx = next_idx;
  2138. + }
  2139. +
  2140. +exit_remove_path:
  2141. + return ret;
  2142. +}
  2143. +
  2144. +static void getpath_debug(int src, int curr, int active_only)
  2145. +{
  2146. + struct device *dev_node;
  2147. + struct device *dev_it;
  2148. + unsigned int hop = 1;
  2149. + int idx;
  2150. + struct msm_bus_node_device_type *devinfo;
  2151. + int i;
  2152. +
  2153. + dev_node = bus_find_device(&msm_bus_type, NULL,
  2154. + (void *) &src,
  2155. + msm_bus_device_match_adhoc);
  2156. +
  2157. + if (!dev_node) {
  2158. + MSM_BUS_ERR("SRC NOT FOUND %d", src);
  2159. + return;
  2160. + }
  2161. +
  2162. + idx = curr;
  2163. + devinfo = dev_node->platform_data;
  2164. + dev_it = dev_node;
  2165. +
  2166. + MSM_BUS_ERR("Route list Src %d", src);
  2167. + while (dev_it) {
  2168. + struct msm_bus_node_device_type *busdev =
  2169. + devinfo->node_info->bus_device->platform_data;
  2170. +
  2171. + MSM_BUS_ERR("Hop[%d] at Device %d ctx %d", hop,
  2172. + devinfo->node_info->id, active_only);
  2173. +
  2174. + for (i = 0; i < NUM_CTX; i++) {
  2175. + MSM_BUS_ERR("dev info sel ib %llu",
  2176. + devinfo->cur_clk_hz[i]);
  2177. + MSM_BUS_ERR("dev info sel ab %llu",
  2178. + devinfo->node_ab.ab[i]);
  2179. + }
  2180. +
  2181. + dev_it = devinfo->lnode_list[idx].next_dev;
  2182. + idx = devinfo->lnode_list[idx].next;
  2183. + if (dev_it)
  2184. + devinfo = dev_it->platform_data;
  2185. +
  2186. + MSM_BUS_ERR("Bus Device %d", busdev->node_info->id);
  2187. + MSM_BUS_ERR("Bus Clock %llu", busdev->clk[active_only].rate);
  2188. +
  2189. + if (idx < 0)
  2190. + break;
  2191. + hop++;
  2192. + }
  2193. +}
  2194. +
  2195. +static void unregister_client_adhoc(uint32_t cl)
  2196. +{
  2197. + int i;
  2198. + struct msm_bus_scale_pdata *pdata;
  2199. + int lnode, src, curr, dest;
  2200. + uint64_t cur_clk, cur_bw;
  2201. + struct msm_bus_client *client;
  2202. +
  2203. + mutex_lock(&msm_bus_adhoc_lock);
  2204. + if (!cl) {
  2205. + MSM_BUS_ERR("%s: Null cl handle passed unregister\n",
  2206. + __func__);
  2207. + goto exit_unregister_client;
  2208. + }
  2209. + client = handle_list.cl_list[cl];
  2210. + pdata = client->pdata;
  2211. + if (!pdata) {
  2212. + MSM_BUS_ERR("%s: Null pdata passed to unregister\n",
  2213. + __func__);
  2214. + goto exit_unregister_client;
  2215. + }
  2216. +
  2217. + curr = client->curr;
  2218. + if (curr >= pdata->num_usecases) {
  2219. + MSM_BUS_ERR("Invalid index Defaulting curr to 0");
  2220. + curr = 0;
  2221. + }
  2222. +
  2223. + MSM_BUS_DBG("%s: Unregistering client %p", __func__, client);
  2224. +
  2225. + for (i = 0; i < pdata->usecase->num_paths; i++) {
  2226. + src = client->pdata->usecase[curr].vectors[i].src;
  2227. + dest = client->pdata->usecase[curr].vectors[i].dst;
  2228. +
  2229. + lnode = client->src_pnode[i];
  2230. + cur_clk = client->pdata->usecase[curr].vectors[i].ib;
  2231. + cur_bw = client->pdata->usecase[curr].vectors[i].ab;
  2232. + remove_path(src, dest, cur_clk, cur_bw, lnode,
  2233. + pdata->active_only);
  2234. + }
  2235. + msm_bus_dbg_client_data(client->pdata, MSM_BUS_DBG_UNREGISTER, cl);
  2236. + kfree(client->src_pnode);
  2237. + kfree(client);
  2238. + handle_list.cl_list[cl] = NULL;
  2239. +exit_unregister_client:
  2240. + mutex_unlock(&msm_bus_adhoc_lock);
  2241. + return;
  2242. +}
  2243. +
  2244. +static int alloc_handle_lst(int size)
  2245. +{
  2246. + int ret = 0;
  2247. + struct msm_bus_client **t_cl_list;
  2248. +
  2249. + if (!handle_list.num_entries) {
  2250. + t_cl_list = kzalloc(sizeof(struct msm_bus_client *)
  2251. + * NUM_CL_HANDLES, GFP_KERNEL);
  2252. + if (ZERO_OR_NULL_PTR(t_cl_list)) {
  2253. + ret = -ENOMEM;
  2254. + MSM_BUS_ERR("%s: Failed to allocate handles list",
  2255. + __func__);
  2256. + goto exit_alloc_handle_lst;
  2257. + }
  2258. + handle_list.cl_list = t_cl_list;
  2259. + handle_list.num_entries += NUM_CL_HANDLES;
  2260. + } else {
  2261. + t_cl_list = krealloc(handle_list.cl_list,
  2262. + sizeof(struct msm_bus_client *) *
  2263. + handle_list.num_entries + NUM_CL_HANDLES,
  2264. + GFP_KERNEL);
  2265. + if (ZERO_OR_NULL_PTR(t_cl_list)) {
  2266. + ret = -ENOMEM;
  2267. + MSM_BUS_ERR("%s: Failed to allocate handles list",
  2268. + __func__);
  2269. + goto exit_alloc_handle_lst;
  2270. + }
  2271. +
  2272. + memset(&handle_list.cl_list[handle_list.num_entries], 0,
  2273. + NUM_CL_HANDLES * sizeof(struct msm_bus_client *));
  2274. + handle_list.num_entries += NUM_CL_HANDLES;
  2275. + handle_list.cl_list = t_cl_list;
  2276. + }
  2277. +exit_alloc_handle_lst:
  2278. + return ret;
  2279. +}
  2280. +
  2281. +static uint32_t gen_handle(struct msm_bus_client *client)
  2282. +{
  2283. + uint32_t handle = 0;
  2284. + int i;
  2285. + int ret = 0;
  2286. +
  2287. + for (i = 0; i < handle_list.num_entries; i++) {
  2288. + if (i && !handle_list.cl_list[i]) {
  2289. + handle = i;
  2290. + break;
  2291. + }
  2292. + }
  2293. +
  2294. + if (!handle) {
  2295. + ret = alloc_handle_lst(NUM_CL_HANDLES);
  2296. +
  2297. + if (ret) {
  2298. + MSM_BUS_ERR("%s: Failed to allocate handle list",
  2299. + __func__);
  2300. + goto exit_gen_handle;
  2301. + }
  2302. + handle = i + 1;
  2303. + }
  2304. + handle_list.cl_list[handle] = client;
  2305. +exit_gen_handle:
  2306. + return handle;
  2307. +}
  2308. +
  2309. +static uint32_t register_client_adhoc(struct msm_bus_scale_pdata *pdata)
  2310. +{
  2311. + int src, dest;
  2312. + int i;
  2313. + struct msm_bus_client *client = NULL;
  2314. + int *lnode;
  2315. + uint32_t handle = 0;
  2316. +
  2317. + mutex_lock(&msm_bus_adhoc_lock);
  2318. + client = kzalloc(sizeof(struct msm_bus_client), GFP_KERNEL);
  2319. + if (!client) {
  2320. + MSM_BUS_ERR("%s: Error allocating client data", __func__);
  2321. + goto exit_register_client;
  2322. + }
  2323. + client->pdata = pdata;
  2324. +
  2325. + lnode = kzalloc(pdata->usecase->num_paths * sizeof(int), GFP_KERNEL);
  2326. + if (ZERO_OR_NULL_PTR(lnode)) {
  2327. + MSM_BUS_ERR("%s: Error allocating pathnode ptr!", __func__);
  2328. + goto exit_register_client;
  2329. + }
  2330. + client->src_pnode = lnode;
  2331. +
  2332. + for (i = 0; i < pdata->usecase->num_paths; i++) {
  2333. + src = pdata->usecase->vectors[i].src;
  2334. + dest = pdata->usecase->vectors[i].dst;
  2335. +
  2336. + if ((src < 0) || (dest < 0)) {
  2337. + MSM_BUS_ERR("%s:Invalid src/dst.src %d dest %d",
  2338. + __func__, src, dest);
  2339. + goto exit_register_client;
  2340. + }
  2341. +
  2342. + lnode[i] = getpath(src, dest);
  2343. + if (lnode[i] < 0) {
  2344. + MSM_BUS_ERR("%s:Failed to find path.src %d dest %d",
  2345. + __func__, src, dest);
  2346. + goto exit_register_client;
  2347. + }
  2348. + }
  2349. +
  2350. + handle = gen_handle(client);
  2351. + msm_bus_dbg_client_data(client->pdata, MSM_BUS_DBG_REGISTER,
  2352. + handle);
  2353. + MSM_BUS_DBG("%s:Client handle %d %s", __func__, handle,
  2354. + client->pdata->name);
  2355. +exit_register_client:
  2356. + mutex_unlock(&msm_bus_adhoc_lock);
  2357. + return handle;
  2358. +}
  2359. +
  2360. +static int update_request_adhoc(uint32_t cl, unsigned int index)
  2361. +{
  2362. + int i, ret = 0;
  2363. + struct msm_bus_scale_pdata *pdata;
  2364. + int lnode, src, curr, dest;
  2365. + uint64_t req_clk, req_bw, curr_clk, curr_bw;
  2366. + struct msm_bus_client *client;
  2367. + const char *test_cl = "Null";
  2368. + bool log_transaction = false;
  2369. +
  2370. + mutex_lock(&msm_bus_adhoc_lock);
  2371. +
  2372. + if (!cl) {
  2373. + MSM_BUS_ERR("%s: Invalid client handle %d", __func__, cl);
  2374. + ret = -ENXIO;
  2375. + goto exit_update_request;
  2376. + }
  2377. +
  2378. + client = handle_list.cl_list[cl];
  2379. + pdata = client->pdata;
  2380. + if (!pdata) {
  2381. + MSM_BUS_ERR("%s: Client data Null.[client didn't register]",
  2382. + __func__);
  2383. + ret = -ENXIO;
  2384. + goto exit_update_request;
  2385. + }
  2386. +
  2387. + if (index >= pdata->num_usecases) {
  2388. + MSM_BUS_ERR("Client %u passed invalid index: %d\n",
  2389. + cl, index);
  2390. + ret = -ENXIO;
  2391. + goto exit_update_request;
  2392. + }
  2393. +
  2394. + if (client->curr == index) {
  2395. + MSM_BUS_DBG("%s: Not updating client request idx %d unchanged",
  2396. + __func__, index);
  2397. + goto exit_update_request;
  2398. + }
  2399. +
  2400. + curr = client->curr;
  2401. + client->curr = index;
  2402. +
  2403. + if (!strcmp(test_cl, pdata->name))
  2404. + log_transaction = true;
  2405. +
  2406. + MSM_BUS_DBG("%s: cl: %u index: %d curr: %d num_paths: %d\n", __func__,
  2407. + cl, index, client->curr, client->pdata->usecase->num_paths);
  2408. +
  2409. + for (i = 0; i < pdata->usecase->num_paths; i++) {
  2410. + src = client->pdata->usecase[index].vectors[i].src;
  2411. + dest = client->pdata->usecase[index].vectors[i].dst;
  2412. +
  2413. + lnode = client->src_pnode[i];
  2414. + req_clk = client->pdata->usecase[index].vectors[i].ib;
  2415. + req_bw = client->pdata->usecase[index].vectors[i].ab;
  2416. + if (curr < 0) {
  2417. + curr_clk = 0;
  2418. + curr_bw = 0;
  2419. + } else {
  2420. + curr_clk = client->pdata->usecase[curr].vectors[i].ib;
  2421. + curr_bw = client->pdata->usecase[curr].vectors[i].ab;
  2422. + MSM_BUS_DBG("%s:ab: %llu ib: %llu\n", __func__,
  2423. + curr_bw, curr_clk);
  2424. + }
  2425. +
  2426. + ret = update_path(src, dest, req_clk, req_bw,
  2427. + curr_clk, curr_bw, lnode, pdata->active_only);
  2428. +
  2429. + if (ret) {
  2430. + MSM_BUS_ERR("%s: Update path failed! %d ctx %d\n",
  2431. + __func__, ret, ACTIVE_CTX);
  2432. + goto exit_update_request;
  2433. + }
  2434. +
  2435. + if (log_transaction)
  2436. + getpath_debug(src, lnode, pdata->active_only);
  2437. + }
  2438. + msm_bus_dbg_client_data(client->pdata, index , cl);
  2439. +exit_update_request:
  2440. + mutex_unlock(&msm_bus_adhoc_lock);
  2441. + return ret;
  2442. +}
  2443. +
  2444. +/**
  2445. + * msm_bus_arb_setops_adhoc() : Setup the bus arbitration ops
  2446. + * @ arb_ops: pointer to the arb ops.
  2447. + */
  2448. +void msm_bus_arb_setops_adhoc(struct msm_bus_arb_ops *arb_ops)
  2449. +{
  2450. + arb_ops->register_client = register_client_adhoc;
  2451. + arb_ops->update_request = update_request_adhoc;
  2452. + arb_ops->unregister_client = unregister_client_adhoc;
  2453. +}
  2454. --- /dev/null
  2455. +++ b/drivers/bus/msm_bus/msm_bus_bimc.c
  2456. @@ -0,0 +1,2112 @@
  2457. +/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  2458. + *
  2459. + * This program is free software; you can redistribute it and/or modify
  2460. + * it under the terms of the GNU General Public License version 2 and
  2461. + * only version 2 as published by the Free Software Foundation.
  2462. + *
  2463. + * This program is distributed in the hope that it will be useful,
  2464. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2465. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2466. + * GNU General Public License for more details.
  2467. + */
  2468. +
  2469. +#define pr_fmt(fmt) "AXI: BIMC: %s(): " fmt, __func__
  2470. +
  2471. +#include <linux/slab.h>
  2472. +#include <linux/io.h>
  2473. +#include "msm-bus-board.h"
  2474. +#include "msm_bus_core.h"
  2475. +#include "msm_bus_bimc.h"
  2476. +#include "msm_bus_adhoc.h"
  2477. +#include <trace/events/trace_msm_bus.h>
  2478. +
  2479. +enum msm_bus_bimc_slave_block {
  2480. + SLAVE_BLOCK_RESERVED = 0,
  2481. + SLAVE_BLOCK_SLAVE_WAY,
  2482. + SLAVE_BLOCK_XPU,
  2483. + SLAVE_BLOCK_ARBITER,
  2484. + SLAVE_BLOCK_SCMO,
  2485. +};
  2486. +
  2487. +enum bke_sw {
  2488. + BKE_OFF = 0,
  2489. + BKE_ON = 1,
  2490. +};
  2491. +
  2492. +/* M_Generic */
  2493. +
  2494. +#define M_REG_BASE(b) ((b) + 0x00008000)
  2495. +
  2496. +#define M_COMPONENT_INFO_ADDR(b, n) \
  2497. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000000)
  2498. +enum bimc_m_component_info {
  2499. + M_COMPONENT_INFO_RMSK = 0xffffff,
  2500. + M_COMPONENT_INFO_INSTANCE_BMSK = 0xff0000,
  2501. + M_COMPONENT_INFO_INSTANCE_SHFT = 0x10,
  2502. + M_COMPONENT_INFO_SUB_TYPE_BMSK = 0xff00,
  2503. + M_COMPONENT_INFO_SUB_TYPE_SHFT = 0x8,
  2504. + M_COMPONENT_INFO_TYPE_BMSK = 0xff,
  2505. + M_COMPONENT_INFO_TYPE_SHFT = 0x0,
  2506. +};
  2507. +
  2508. +#define M_CONFIG_INFO_0_ADDR(b, n) \
  2509. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000020)
  2510. +enum bimc_m_config_info_0 {
  2511. + M_CONFIG_INFO_0_RMSK = 0xff00ffff,
  2512. + M_CONFIG_INFO_0_SYNC_MODE_BMSK = 0xff000000,
  2513. + M_CONFIG_INFO_0_SYNC_MODE_SHFT = 0x18,
  2514. + M_CONFIG_INFO_0_CONNECTION_TYPE_BMSK = 0xff00,
  2515. + M_CONFIG_INFO_0_CONNECTION_TYPE_SHFT = 0x8,
  2516. + M_CONFIG_INFO_0_FUNC_BMSK = 0xff,
  2517. + M_CONFIG_INFO_0_FUNC_SHFT = 0x0,
  2518. +};
  2519. +
  2520. +#define M_CONFIG_INFO_1_ADDR(b, n) \
  2521. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000030)
  2522. +enum bimc_m_config_info_1 {
  2523. + M_CONFIG_INFO_1_RMSK = 0xffffffff,
  2524. + M_CONFIG_INFO_1_SWAY_CONNECTIVITY_BMSK = 0xffffffff,
  2525. + M_CONFIG_INFO_1_SWAY_CONNECTIVITY_SHFT = 0x0,
  2526. +};
  2527. +
  2528. +#define M_CONFIG_INFO_2_ADDR(b, n) \
  2529. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000040)
  2530. +enum bimc_m_config_info_2 {
  2531. + M_CONFIG_INFO_2_RMSK = 0xffffffff,
  2532. + M_CONFIG_INFO_2_M_DATA_WIDTH_BMSK = 0xffff0000,
  2533. + M_CONFIG_INFO_2_M_DATA_WIDTH_SHFT = 0x10,
  2534. + M_CONFIG_INFO_2_M_TID_WIDTH_BMSK = 0xff00,
  2535. + M_CONFIG_INFO_2_M_TID_WIDTH_SHFT = 0x8,
  2536. + M_CONFIG_INFO_2_M_MID_WIDTH_BMSK = 0xff,
  2537. + M_CONFIG_INFO_2_M_MID_WIDTH_SHFT = 0x0,
  2538. +};
  2539. +
  2540. +#define M_CONFIG_INFO_3_ADDR(b, n) \
  2541. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000050)
  2542. +enum bimc_m_config_info_3 {
  2543. + M_CONFIG_INFO_3_RMSK = 0xffffffff,
  2544. + M_CONFIG_INFO_3_RCH_DEPTH_BMSK = 0xff000000,
  2545. + M_CONFIG_INFO_3_RCH_DEPTH_SHFT = 0x18,
  2546. + M_CONFIG_INFO_3_BCH_DEPTH_BMSK = 0xff0000,
  2547. + M_CONFIG_INFO_3_BCH_DEPTH_SHFT = 0x10,
  2548. + M_CONFIG_INFO_3_WCH_DEPTH_BMSK = 0xff00,
  2549. + M_CONFIG_INFO_3_WCH_DEPTH_SHFT = 0x8,
  2550. + M_CONFIG_INFO_3_ACH_DEPTH_BMSK = 0xff,
  2551. + M_CONFIG_INFO_3_ACH_DEPTH_SHFT = 0x0,
  2552. +};
  2553. +
  2554. +#define M_CONFIG_INFO_4_ADDR(b, n) \
  2555. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000060)
  2556. +enum bimc_m_config_info_4 {
  2557. + M_CONFIG_INFO_4_RMSK = 0xffff,
  2558. + M_CONFIG_INFO_4_REORDER_BUF_DEPTH_BMSK = 0xff00,
  2559. + M_CONFIG_INFO_4_REORDER_BUF_DEPTH_SHFT = 0x8,
  2560. + M_CONFIG_INFO_4_REORDER_TABLE_DEPTH_BMSK = 0xff,
  2561. + M_CONFIG_INFO_4_REORDER_TABLE_DEPTH_SHFT = 0x0,
  2562. +};
  2563. +
  2564. +#define M_CONFIG_INFO_5_ADDR(b, n) \
  2565. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000070)
  2566. +enum bimc_m_config_info_5 {
  2567. + M_CONFIG_INFO_5_RMSK = 0x111,
  2568. + M_CONFIG_INFO_5_MP2ARB_PIPELINE_EN_BMSK = 0x100,
  2569. + M_CONFIG_INFO_5_MP2ARB_PIPELINE_EN_SHFT = 0x8,
  2570. + M_CONFIG_INFO_5_MPBUF_PIPELINE_EN_BMSK = 0x10,
  2571. + M_CONFIG_INFO_5_MPBUF_PIPELINE_EN_SHFT = 0x4,
  2572. + M_CONFIG_INFO_5_M2MP_PIPELINE_EN_BMSK = 0x1,
  2573. + M_CONFIG_INFO_5_M2MP_PIPELINE_EN_SHFT = 0x0,
  2574. +};
  2575. +
  2576. +#define M_INT_STATUS_ADDR(b, n) \
  2577. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000100)
  2578. +enum bimc_m_int_status {
  2579. + M_INT_STATUS_RMSK = 0x3,
  2580. +};
  2581. +
  2582. +#define M_INT_CLR_ADDR(b, n) \
  2583. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000108)
  2584. +enum bimc_m_int_clr {
  2585. + M_INT_CLR_RMSK = 0x3,
  2586. +};
  2587. +
  2588. +#define M_INT_EN_ADDR(b, n) \
  2589. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x0000010c)
  2590. +enum bimc_m_int_en {
  2591. + M_INT_EN_RMSK = 0x3,
  2592. +};
  2593. +
  2594. +#define M_CLK_CTRL_ADDR(b, n) \
  2595. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000200)
  2596. +enum bimc_m_clk_ctrl {
  2597. + M_CLK_CTRL_RMSK = 0x3,
  2598. + M_CLK_CTRL_MAS_CLK_GATING_EN_BMSK = 0x2,
  2599. + M_CLK_CTRL_MAS_CLK_GATING_EN_SHFT = 0x1,
  2600. + M_CLK_CTRL_CORE_CLK_GATING_EN_BMSK = 0x1,
  2601. + M_CLK_CTRL_CORE_CLK_GATING_EN_SHFT = 0x0,
  2602. +};
  2603. +
  2604. +#define M_MODE_ADDR(b, n) \
  2605. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000210)
  2606. +enum bimc_m_mode {
  2607. + M_MODE_RMSK = 0xf0000011,
  2608. + M_MODE_WR_GATHER_BEATS_BMSK = 0xf0000000,
  2609. + M_MODE_WR_GATHER_BEATS_SHFT = 0x1c,
  2610. + M_MODE_NARROW_WR_BMSK = 0x10,
  2611. + M_MODE_NARROW_WR_SHFT = 0x4,
  2612. + M_MODE_ORDERING_MODEL_BMSK = 0x1,
  2613. + M_MODE_ORDERING_MODEL_SHFT = 0x0,
  2614. +};
  2615. +
  2616. +#define M_PRIOLVL_OVERRIDE_ADDR(b, n) \
  2617. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000230)
  2618. +enum bimc_m_priolvl_override {
  2619. + M_PRIOLVL_OVERRIDE_RMSK = 0x301,
  2620. + M_PRIOLVL_OVERRIDE_BMSK = 0x300,
  2621. + M_PRIOLVL_OVERRIDE_SHFT = 0x8,
  2622. + M_PRIOLVL_OVERRIDE_OVERRIDE_PRIOLVL_BMSK = 0x1,
  2623. + M_PRIOLVL_OVERRIDE_OVERRIDE_PRIOLVL_SHFT = 0x0,
  2624. +};
  2625. +
  2626. +#define M_RD_CMD_OVERRIDE_ADDR(b, n) \
  2627. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000240)
  2628. +enum bimc_m_read_command_override {
  2629. + M_RD_CMD_OVERRIDE_RMSK = 0x3071f7f,
  2630. + M_RD_CMD_OVERRIDE_AREQPRIO_BMSK = 0x3000000,
  2631. + M_RD_CMD_OVERRIDE_AREQPRIO_SHFT = 0x18,
  2632. + M_RD_CMD_OVERRIDE_AMEMTYPE_BMSK = 0x70000,
  2633. + M_RD_CMD_OVERRIDE_AMEMTYPE_SHFT = 0x10,
  2634. + M_RD_CMD_OVERRIDE_ATRANSIENT_BMSK = 0x1000,
  2635. + M_RD_CMD_OVERRIDE_ATRANSIENT_SHFT = 0xc,
  2636. + M_RD_CMD_OVERRIDE_ASHARED_BMSK = 0x800,
  2637. + M_RD_CMD_OVERRIDE_ASHARED_SHFT = 0xb,
  2638. + M_RD_CMD_OVERRIDE_AREDIRECT_BMSK = 0x400,
  2639. + M_RD_CMD_OVERRIDE_AREDIRECT_SHFT = 0xa,
  2640. + M_RD_CMD_OVERRIDE_AOOO_BMSK = 0x200,
  2641. + M_RD_CMD_OVERRIDE_AOOO_SHFT = 0x9,
  2642. + M_RD_CMD_OVERRIDE_AINNERSHARED_BMSK = 0x100,
  2643. + M_RD_CMD_OVERRIDE_AINNERSHARED_SHFT = 0x8,
  2644. + M_RD_CMD_OVERRIDE_OVERRIDE_AREQPRIO_BMSK = 0x40,
  2645. + M_RD_CMD_OVERRIDE_OVERRIDE_AREQPRIO_SHFT = 0x6,
  2646. + M_RD_CMD_OVERRIDE_OVERRIDE_ATRANSIENT_BMSK = 0x20,
  2647. + M_RD_CMD_OVERRIDE_OVERRIDE_ATRANSIENT_SHFT = 0x5,
  2648. + M_RD_CMD_OVERRIDE_OVERRIDE_AMEMTYPE_BMSK = 0x10,
  2649. + M_RD_CMD_OVERRIDE_OVERRIDE_AMEMTYPE_SHFT = 0x4,
  2650. + M_RD_CMD_OVERRIDE_OVERRIDE_ASHARED_BMSK = 0x8,
  2651. + M_RD_CMD_OVERRIDE_OVERRIDE_ASHARED_SHFT = 0x3,
  2652. + M_RD_CMD_OVERRIDE_OVERRIDE_AREDIRECT_BMSK = 0x4,
  2653. + M_RD_CMD_OVERRIDE_OVERRIDE_AREDIRECT_SHFT = 0x2,
  2654. + M_RD_CMD_OVERRIDE_OVERRIDE_AOOO_BMSK = 0x2,
  2655. + M_RD_CMD_OVERRIDE_OVERRIDE_AOOO_SHFT = 0x1,
  2656. + M_RD_CMD_OVERRIDE_OVERRIDE_AINNERSHARED_BMSK = 0x1,
  2657. + M_RD_CMD_OVERRIDE_OVERRIDE_AINNERSHARED_SHFT = 0x0,
  2658. +};
  2659. +
  2660. +#define M_WR_CMD_OVERRIDE_ADDR(b, n) \
  2661. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000250)
  2662. +enum bimc_m_write_command_override {
  2663. + M_WR_CMD_OVERRIDE_RMSK = 0x3071f7f,
  2664. + M_WR_CMD_OVERRIDE_AREQPRIO_BMSK = 0x3000000,
  2665. + M_WR_CMD_OVERRIDE_AREQPRIO_SHFT = 0x18,
  2666. + M_WR_CMD_OVERRIDE_AMEMTYPE_BMSK = 0x70000,
  2667. + M_WR_CMD_OVERRIDE_AMEMTYPE_SHFT = 0x10,
  2668. + M_WR_CMD_OVERRIDE_ATRANSIENT_BMSK = 0x1000,
  2669. + M_WR_CMD_OVERRIDE_ATRANSIENT_SHFT = 0xc,
  2670. + M_WR_CMD_OVERRIDE_ASHARED_BMSK = 0x800,
  2671. + M_WR_CMD_OVERRIDE_ASHARED_SHFT = 0xb,
  2672. + M_WR_CMD_OVERRIDE_AREDIRECT_BMSK = 0x400,
  2673. + M_WR_CMD_OVERRIDE_AREDIRECT_SHFT = 0xa,
  2674. + M_WR_CMD_OVERRIDE_AOOO_BMSK = 0x200,
  2675. + M_WR_CMD_OVERRIDE_AOOO_SHFT = 0x9,
  2676. + M_WR_CMD_OVERRIDE_AINNERSHARED_BMSK = 0x100,
  2677. + M_WR_CMD_OVERRIDE_AINNERSHARED_SHFT = 0x8,
  2678. + M_WR_CMD_OVERRIDE_OVERRIDE_AREQPRIO_BMSK = 0x40,
  2679. + M_WR_CMD_OVERRIDE_OVERRIDE_AREQPRIO_SHFT = 0x6,
  2680. + M_WR_CMD_OVERRIDE_OVERRIDE_ATRANSIENT_BMSK = 0x20,
  2681. + M_WR_CMD_OVERRIDE_OVERRIDE_ATRANSIENT_SHFT = 0x5,
  2682. + M_WR_CMD_OVERRIDE_OVERRIDE_AMEMTYPE_BMSK = 0x10,
  2683. + M_WR_CMD_OVERRIDE_OVERRIDE_AMEMTYPE_SHFT = 0x4,
  2684. + M_WR_CMD_OVERRIDE_OVERRIDE_ASHARED_BMSK = 0x8,
  2685. + M_WR_CMD_OVERRIDE_OVERRIDE_ASHARED_SHFT = 0x3,
  2686. + M_WR_CMD_OVERRIDE_OVERRIDE_AREDIRECT_BMSK = 0x4,
  2687. + M_WR_CMD_OVERRIDE_OVERRIDE_AREDIRECT_SHFT = 0x2,
  2688. + M_WR_CMD_OVERRIDE_OVERRIDE_AOOO_BMSK = 0x2,
  2689. + M_WR_CMD_OVERRIDE_OVERRIDE_AOOO_SHFT = 0x1,
  2690. + M_WR_CMD_OVERRIDE_OVERRIDE_AINNERSHARED_BMSK = 0x1,
  2691. + M_WR_CMD_OVERRIDE_OVERRIDE_AINNERSHARED_SHFT = 0x0,
  2692. +};
  2693. +
  2694. +#define M_BKE_EN_ADDR(b, n) \
  2695. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000300)
  2696. +enum bimc_m_bke_en {
  2697. + M_BKE_EN_RMSK = 0x1,
  2698. + M_BKE_EN_EN_BMSK = 0x1,
  2699. + M_BKE_EN_EN_SHFT = 0x0,
  2700. +};
  2701. +
  2702. +/* Grant Period registers */
  2703. +#define M_BKE_GP_ADDR(b, n) \
  2704. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000304)
  2705. +enum bimc_m_bke_grant_period {
  2706. + M_BKE_GP_RMSK = 0x3ff,
  2707. + M_BKE_GP_GP_BMSK = 0x3ff,
  2708. + M_BKE_GP_GP_SHFT = 0x0,
  2709. +};
  2710. +
  2711. +/* Grant count register.
  2712. + * The Grant count register represents a signed 16 bit
  2713. + * value, range 0-0x7fff
  2714. + */
  2715. +#define M_BKE_GC_ADDR(b, n) \
  2716. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000308)
  2717. +enum bimc_m_bke_grant_count {
  2718. + M_BKE_GC_RMSK = 0xffff,
  2719. + M_BKE_GC_GC_BMSK = 0xffff,
  2720. + M_BKE_GC_GC_SHFT = 0x0,
  2721. +};
  2722. +
  2723. +/* Threshold High Registers */
  2724. +#define M_BKE_THH_ADDR(b, n) \
  2725. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000320)
  2726. +enum bimc_m_bke_thresh_high {
  2727. + M_BKE_THH_RMSK = 0xffff,
  2728. + M_BKE_THH_THRESH_BMSK = 0xffff,
  2729. + M_BKE_THH_THRESH_SHFT = 0x0,
  2730. +};
  2731. +
  2732. +/* Threshold Medium Registers */
  2733. +#define M_BKE_THM_ADDR(b, n) \
  2734. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000324)
  2735. +enum bimc_m_bke_thresh_medium {
  2736. + M_BKE_THM_RMSK = 0xffff,
  2737. + M_BKE_THM_THRESH_BMSK = 0xffff,
  2738. + M_BKE_THM_THRESH_SHFT = 0x0,
  2739. +};
  2740. +
  2741. +/* Threshold Low Registers */
  2742. +#define M_BKE_THL_ADDR(b, n) \
  2743. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000328)
  2744. +enum bimc_m_bke_thresh_low {
  2745. + M_BKE_THL_RMSK = 0xffff,
  2746. + M_BKE_THL_THRESH_BMSK = 0xffff,
  2747. + M_BKE_THL_THRESH_SHFT = 0x0,
  2748. +};
  2749. +
  2750. +#define M_BKE_HEALTH_0_CONFIG_ADDR(b, n) \
  2751. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000340)
  2752. +enum bimc_m_bke_health_0 {
  2753. + M_BKE_HEALTH_0_CONFIG_RMSK = 0x80000303,
  2754. + M_BKE_HEALTH_0_CONFIG_LIMIT_CMDS_BMSK = 0x80000000,
  2755. + M_BKE_HEALTH_0_CONFIG_LIMIT_CMDS_SHFT = 0x1f,
  2756. + M_BKE_HEALTH_0_CONFIG_AREQPRIO_BMSK = 0x300,
  2757. + M_BKE_HEALTH_0_CONFIG_AREQPRIO_SHFT = 0x8,
  2758. + M_BKE_HEALTH_0_CONFIG_PRIOLVL_BMSK = 0x3,
  2759. + M_BKE_HEALTH_0_CONFIG_PRIOLVL_SHFT = 0x0,
  2760. +};
  2761. +
  2762. +#define M_BKE_HEALTH_1_CONFIG_ADDR(b, n) \
  2763. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000344)
  2764. +enum bimc_m_bke_health_1 {
  2765. + M_BKE_HEALTH_1_CONFIG_RMSK = 0x80000303,
  2766. + M_BKE_HEALTH_1_CONFIG_LIMIT_CMDS_BMSK = 0x80000000,
  2767. + M_BKE_HEALTH_1_CONFIG_LIMIT_CMDS_SHFT = 0x1f,
  2768. + M_BKE_HEALTH_1_CONFIG_AREQPRIO_BMSK = 0x300,
  2769. + M_BKE_HEALTH_1_CONFIG_AREQPRIO_SHFT = 0x8,
  2770. + M_BKE_HEALTH_1_CONFIG_PRIOLVL_BMSK = 0x3,
  2771. + M_BKE_HEALTH_1_CONFIG_PRIOLVL_SHFT = 0x0,
  2772. +};
  2773. +
  2774. +#define M_BKE_HEALTH_2_CONFIG_ADDR(b, n) \
  2775. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000348)
  2776. +enum bimc_m_bke_health_2 {
  2777. + M_BKE_HEALTH_2_CONFIG_RMSK = 0x80000303,
  2778. + M_BKE_HEALTH_2_CONFIG_LIMIT_CMDS_BMSK = 0x80000000,
  2779. + M_BKE_HEALTH_2_CONFIG_LIMIT_CMDS_SHFT = 0x1f,
  2780. + M_BKE_HEALTH_2_CONFIG_AREQPRIO_BMSK = 0x300,
  2781. + M_BKE_HEALTH_2_CONFIG_AREQPRIO_SHFT = 0x8,
  2782. + M_BKE_HEALTH_2_CONFIG_PRIOLVL_BMSK = 0x3,
  2783. + M_BKE_HEALTH_2_CONFIG_PRIOLVL_SHFT = 0x0,
  2784. +};
  2785. +
  2786. +#define M_BKE_HEALTH_3_CONFIG_ADDR(b, n) \
  2787. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x0000034c)
  2788. +enum bimc_m_bke_health_3 {
  2789. + M_BKE_HEALTH_3_CONFIG_RMSK = 0x303,
  2790. + M_BKE_HEALTH_3_CONFIG_AREQPRIO_BMSK = 0x300,
  2791. + M_BKE_HEALTH_3_CONFIG_AREQPRIO_SHFT = 0x8,
  2792. + M_BKE_HEALTH_3_CONFIG_PRIOLVL_BMSK = 0x3,
  2793. + M_BKE_HEALTH_3_CONFIG_PRIOLVL_SHFT = 0x0,
  2794. +};
  2795. +
  2796. +#define M_BUF_STATUS_ADDR(b, n) \
  2797. + (M_REG_BASE(b) + (0x4000 * (n)) + 0x00000400)
  2798. +enum bimc_m_buf_status {
  2799. + M_BUF_STATUS_RMSK = 0xf03f030,
  2800. + M_BUF_STATUS_RCH_DATA_WR_FULL_BMSK = 0x8000000,
  2801. + M_BUF_STATUS_RCH_DATA_WR_FULL_SHFT = 0x1b,
  2802. + M_BUF_STATUS_RCH_DATA_WR_EMPTY_BMSK = 0x4000000,
  2803. + M_BUF_STATUS_RCH_DATA_WR_EMPTY_SHFT = 0x1a,
  2804. + M_BUF_STATUS_RCH_CTRL_WR_FULL_BMSK = 0x2000000,
  2805. + M_BUF_STATUS_RCH_CTRL_WR_FULL_SHFT = 0x19,
  2806. + M_BUF_STATUS_RCH_CTRL_WR_EMPTY_BMSK = 0x1000000,
  2807. + M_BUF_STATUS_RCH_CTRL_WR_EMPTY_SHFT = 0x18,
  2808. + M_BUF_STATUS_BCH_WR_FULL_BMSK = 0x20000,
  2809. + M_BUF_STATUS_BCH_WR_FULL_SHFT = 0x11,
  2810. + M_BUF_STATUS_BCH_WR_EMPTY_BMSK = 0x10000,
  2811. + M_BUF_STATUS_BCH_WR_EMPTY_SHFT = 0x10,
  2812. + M_BUF_STATUS_WCH_DATA_RD_FULL_BMSK = 0x8000,
  2813. + M_BUF_STATUS_WCH_DATA_RD_FULL_SHFT = 0xf,
  2814. + M_BUF_STATUS_WCH_DATA_RD_EMPTY_BMSK = 0x4000,
  2815. + M_BUF_STATUS_WCH_DATA_RD_EMPTY_SHFT = 0xe,
  2816. + M_BUF_STATUS_WCH_CTRL_RD_FULL_BMSK = 0x2000,
  2817. + M_BUF_STATUS_WCH_CTRL_RD_FULL_SHFT = 0xd,
  2818. + M_BUF_STATUS_WCH_CTRL_RD_EMPTY_BMSK = 0x1000,
  2819. + M_BUF_STATUS_WCH_CTRL_RD_EMPTY_SHFT = 0xc,
  2820. + M_BUF_STATUS_ACH_RD_FULL_BMSK = 0x20,
  2821. + M_BUF_STATUS_ACH_RD_FULL_SHFT = 0x5,
  2822. + M_BUF_STATUS_ACH_RD_EMPTY_BMSK = 0x10,
  2823. + M_BUF_STATUS_ACH_RD_EMPTY_SHFT = 0x4,
  2824. +};
  2825. +/*BIMC Generic */
  2826. +
  2827. +#define S_REG_BASE(b) ((b) + 0x00048000)
  2828. +
  2829. +#define S_COMPONENT_INFO_ADDR(b, n) \
  2830. + (S_REG_BASE(b) + (0x8000 * (n)) + 0x00000000)
  2831. +enum bimc_s_component_info {
  2832. + S_COMPONENT_INFO_RMSK = 0xffffff,
  2833. + S_COMPONENT_INFO_INSTANCE_BMSK = 0xff0000,
  2834. + S_COMPONENT_INFO_INSTANCE_SHFT = 0x10,
  2835. + S_COMPONENT_INFO_SUB_TYPE_BMSK = 0xff00,
  2836. + S_COMPONENT_INFO_SUB_TYPE_SHFT = 0x8,
  2837. + S_COMPONENT_INFO_TYPE_BMSK = 0xff,
  2838. + S_COMPONENT_INFO_TYPE_SHFT = 0x0,
  2839. +};
  2840. +
  2841. +#define S_HW_INFO_ADDR(b, n) \
  2842. + (S_REG_BASE(b) + (0x80000 * (n)) + 0x00000010)
  2843. +enum bimc_s_hw_info {
  2844. + S_HW_INFO_RMSK = 0xffffffff,
  2845. + S_HW_INFO_MAJOR_BMSK = 0xff000000,
  2846. + S_HW_INFO_MAJOR_SHFT = 0x18,
  2847. + S_HW_INFO_BRANCH_BMSK = 0xff0000,
  2848. + S_HW_INFO_BRANCH_SHFT = 0x10,
  2849. + S_HW_INFO_MINOR_BMSK = 0xff00,
  2850. + S_HW_INFO_MINOR_SHFT = 0x8,
  2851. + S_HW_INFO_ECO_BMSK = 0xff,
  2852. + S_HW_INFO_ECO_SHFT = 0x0,
  2853. +};
  2854. +
  2855. +
  2856. +/* S_SCMO_GENERIC */
  2857. +
  2858. +#define S_SCMO_REG_BASE(b) ((b) + 0x00048000)
  2859. +
  2860. +#define S_SCMO_CONFIG_INFO_0_ADDR(b, n) \
  2861. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000020)
  2862. +enum bimc_s_scmo_config_info_0 {
  2863. + S_SCMO_CONFIG_INFO_0_RMSK = 0xffffffff,
  2864. + S_SCMO_CONFIG_INFO_0_DATA_WIDTH_BMSK = 0xffff0000,
  2865. + S_SCMO_CONFIG_INFO_0_DATA_WIDTH_SHFT = 0x10,
  2866. + S_SCMO_CONFIG_INFO_0_TID_WIDTH_BMSK = 0xff00,
  2867. + S_SCMO_CONFIG_INFO_0_TID_WIDTH_SHFT = 0x8,
  2868. + S_SCMO_CONFIG_INFO_0_MID_WIDTH_BMSK = 0xff,
  2869. + S_SCMO_CONFIG_INFO_0_MID_WIDTH_SHFT = 0x0,
  2870. +};
  2871. +
  2872. +#define S_SCMO_CONFIG_INFO_1_ADDR(b, n) \
  2873. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000030)
  2874. +enum bimc_s_scmo_config_info_1 {
  2875. + S_SCMO_CONFIG_INFO_1_RMSK = 0xffffffff,
  2876. + S_SCMO_CONFIG_INFO_1_MPORT_CONNECTIVITY_BMSK = 0xffffffff,
  2877. + S_SCMO_CONFIG_INFO_1_MPORT_CONNECTIVITY_SHFT = 0x0,
  2878. +};
  2879. +
  2880. +#define S_SCMO_CONFIG_INFO_2_ADDR(b, n) \
  2881. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000040)
  2882. +enum bimc_s_scmo_config_info_2 {
  2883. + S_SCMO_CONFIG_INFO_2_RMSK = 0xff00ff,
  2884. + S_SCMO_CONFIG_INFO_2_NUM_GLOBAL_MONS_BMSK = 0xff0000,
  2885. + S_SCMO_CONFIG_INFO_2_NUM_GLOBAL_MONS_SHFT = 0x10,
  2886. + S_SCMO_CONFIG_INFO_2_VMID_WIDTH_BMSK = 0xff,
  2887. + S_SCMO_CONFIG_INFO_2_VMID_WIDTH_SHFT = 0x0,
  2888. +};
  2889. +
  2890. +#define S_SCMO_CONFIG_INFO_3_ADDR(b, n) \
  2891. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000050)
  2892. +enum bimc_s_scmo_config_info_3 {
  2893. + S_SCMO_CONFIG_INFO_3_RMSK = 0xffffffff,
  2894. + S_SCMO_CONFIG_INFO_3_RCH0_CTRL_DEPTH_BMSK = 0xff000000,
  2895. + S_SCMO_CONFIG_INFO_3_RCH0_CTRL_DEPTH_SHFT = 0x18,
  2896. + S_SCMO_CONFIG_INFO_3_RCH0_DEPTH_BMSK = 0xff0000,
  2897. + S_SCMO_CONFIG_INFO_3_RCH0_DEPTH_SHFT = 0x10,
  2898. + S_SCMO_CONFIG_INFO_3_BCH_DEPTH_BMSK = 0xff00,
  2899. + S_SCMO_CONFIG_INFO_3_BCH_DEPTH_SHFT = 0x8,
  2900. + S_SCMO_CONFIG_INFO_3_WCH_DEPTH_BMSK = 0xff,
  2901. + S_SCMO_CONFIG_INFO_3_WCH_DEPTH_SHFT = 0x0,
  2902. +};
  2903. +
  2904. +#define S_SCMO_CONFIG_INFO_4_ADDR(b, n) \
  2905. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000060)
  2906. +enum bimc_s_scmo_config_info_4 {
  2907. + S_SCMO_CONFIG_INFO_4_RMSK = 0xffff,
  2908. + S_SCMO_CONFIG_INFO_4_RCH1_CTRL_DEPTH_BMSK = 0xff00,
  2909. + S_SCMO_CONFIG_INFO_4_RCH1_CTRL_DEPTH_SHFT = 0x8,
  2910. + S_SCMO_CONFIG_INFO_4_RCH1_DEPTH_BMSK = 0xff,
  2911. + S_SCMO_CONFIG_INFO_4_RCH1_DEPTH_SHFT = 0x0,
  2912. +};
  2913. +
  2914. +#define S_SCMO_CONFIG_INFO_5_ADDR(b, n) \
  2915. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000070)
  2916. +enum bimc_s_scmo_config_info_5 {
  2917. + S_SCMO_CONFIG_INFO_5_RMSK = 0xffff,
  2918. + S_SCMO_CONFIG_INFO_5_DPE_CQ_DEPTH_BMSK = 0xff00,
  2919. + S_SCMO_CONFIG_INFO_5_DPE_CQ_DEPTH_SHFT = 0x8,
  2920. + S_SCMO_CONFIG_INFO_5_DDR_BUS_WIDTH_BMSK = 0xff,
  2921. + S_SCMO_CONFIG_INFO_5_DDR_BUS_WIDTH_SHFT = 0x0,
  2922. +};
  2923. +
  2924. +#define S_SCMO_CONFIG_INFO_6_ADDR(b, n) \
  2925. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000080)
  2926. +enum bimc_s_scmo_config_info_6 {
  2927. + S_SCMO_CONFIG_INFO_6_RMSK = 0x1111,
  2928. + S_SCMO_CONFIG_INFO_6_WBUFC_PIPE_BMSK = 0x1000,
  2929. + S_SCMO_CONFIG_INFO_6_WBUFC_PIPE_SHFT = 0xc,
  2930. + S_SCMO_CONFIG_INFO_6_RDOPT_PIPE_BMSK = 0x100,
  2931. + S_SCMO_CONFIG_INFO_6_RDOPT_PIPE_SHFT = 0x8,
  2932. + S_SCMO_CONFIG_INFO_6_ACHAN_INTF_PIPE_BMSK = 0x10,
  2933. + S_SCMO_CONFIG_INFO_6_ACHAN_INTF_PIPE_SHFT = 0x4,
  2934. + S_SCMO_CONFIG_INFO_6_ADDR_DECODE_HT_BMSK = 0x1,
  2935. + S_SCMO_CONFIG_INFO_6_ADDR_DECODE_HT_SHFT = 0x0,
  2936. +};
  2937. +
  2938. +#define S_SCMO_INT_STATUS_ADDR(b, n) \
  2939. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000100)
  2940. +enum bimc_s_scmo_int_status {
  2941. + S_SCMO_INT_STATUS_RMSK = 0x1,
  2942. + S_SCMO_INT_STATUS_ERR_OCCURED_BMSK = 0x1,
  2943. + S_SCMO_INT_STATUS_ERR_OCCURED_SHFT = 0x0,
  2944. +};
  2945. +
  2946. +#define S_SCMO_INT_CLR_ADDR(b, n) \
  2947. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000108)
  2948. +enum bimc_s_scmo_int_clr {
  2949. + S_SCMO_INT_CLR_RMSK = 0x1,
  2950. + S_SCMO_INT_CLR_IRQ_CLR_BMSK = 0x1,
  2951. + S_SCMO_INT_CLR_IRQ_CLR_SHFT = 0x0,
  2952. +};
  2953. +
  2954. +#define S_SCMO_INT_EN_ADDR(b, n) \
  2955. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x0000010c)
  2956. +enum bimc_s_scmo_int_en {
  2957. + S_SCMO_INT_EN_RMSK = 0x1,
  2958. + S_SCMO_INT_EN_IRQ_EN_BMSK = 0x1,
  2959. + S_SCMO_INT_EN_IRQ_EN_SHFT = 0x0,
  2960. +};
  2961. +
  2962. +#define S_SCMO_ESYN_ADDR_ADDR(b, n) \
  2963. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000120)
  2964. +enum bimc_s_scmo_esyn_addr {
  2965. + S_SCMO_ESYN_ADDR_RMSK = 0xffffffff,
  2966. + S_SCMO_ESYN_ADDR_ESYN_ADDR_ERR_ADDR_BMSK = 0xffffffff,
  2967. + S_SCMO_ESYN_ADDR_ESYN_ADDR_ERR_ADDR_SHFT = 0x0,
  2968. +};
  2969. +
  2970. +#define S_SCMO_ESYN_APACKET_0_ADDR(b, n) \
  2971. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000128)
  2972. +enum bimc_s_scmo_esyn_apacket_0 {
  2973. + S_SCMO_ESYN_APACKET_0_RMSK = 0xff1fffff,
  2974. + S_SCMO_ESYN_APACKET_0_ERR_ATID_BMSK = 0xff000000,
  2975. + S_SCMO_ESYN_APACKET_0_ERR_ATID_SHFT = 0x18,
  2976. + S_SCMO_ESYN_APACKET_0_ERR_AVMID_BMSK = 0x1f0000,
  2977. + S_SCMO_ESYN_APACKET_0_ERR_AVMID_SHFT = 0x10,
  2978. + S_SCMO_ESYN_APACKET_0_ERR_AMID_BMSK = 0xffff,
  2979. + S_SCMO_ESYN_APACKET_0_ERR_AMID_SHFT = 0x0,
  2980. +};
  2981. +
  2982. +#define S_SCMO_ESYN_APACKET_1_ADDR(b, n) \
  2983. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x0000012c)
  2984. +enum bimc_s_scmo_esyn_apacket_1 {
  2985. + S_SCMO_ESYN_APACKET_1_RMSK = 0x10ff117,
  2986. + S_SCMO_ESYN_APACKET_1_ERR_CODE_BMSK = 0x1000000,
  2987. + S_SCMO_ESYN_APACKET_1_ERR_CODE_SHFT = 0x18,
  2988. + S_SCMO_ESYN_APACKET_1_ERR_ALEN_BMSK = 0xf0000,
  2989. + S_SCMO_ESYN_APACKET_1_ERR_ALEN_SHFT = 0x10,
  2990. + S_SCMO_ESYN_APACKET_1_ERR_ASIZE_BMSK = 0xe000,
  2991. + S_SCMO_ESYN_APACKET_1_ERR_ASIZE_SHFT = 0xd,
  2992. + S_SCMO_ESYN_APACKET_1_ERR_ABURST_BMSK = 0x1000,
  2993. + S_SCMO_ESYN_APACKET_1_ERR_ABURST_SHFT = 0xc,
  2994. + S_SCMO_ESYN_APACKET_1_ERR_AEXCLUSIVE_BMSK = 0x100,
  2995. + S_SCMO_ESYN_APACKET_1_ERR_AEXCLUSIVE_SHFT = 0x8,
  2996. + S_SCMO_ESYN_APACKET_1_ERR_APRONTS_BMSK = 0x10,
  2997. + S_SCMO_ESYN_APACKET_1_ERR_APRONTS_SHFT = 0x4,
  2998. + S_SCMO_ESYN_APACKET_1_ERR_AOOORD_BMSK = 0x4,
  2999. + S_SCMO_ESYN_APACKET_1_ERR_AOOORD_SHFT = 0x2,
  3000. + S_SCMO_ESYN_APACKET_1_ERR_AOOOWR_BMSK = 0x2,
  3001. + S_SCMO_ESYN_APACKET_1_ERR_AOOOWR_SHFT = 0x1,
  3002. + S_SCMO_ESYN_APACKET_1_ERR_AWRITE_BMSK = 0x1,
  3003. + S_SCMO_ESYN_APACKET_1_ERR_AWRITE_SHFT = 0x0,
  3004. +};
  3005. +
  3006. +#define S_SCMO_CLK_CTRL_ADDR(b, n) \
  3007. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000200)
  3008. +enum bimc_s_scmo_clk_ctrl {
  3009. + S_SCMO_CLK_CTRL_RMSK = 0xffff1111,
  3010. + S_SCMO_CLK_CTRL_PEN_CMD_CG_EN_BMSK = 0x10000,
  3011. + S_SCMO_CLK_CTRL_PEN_CMD_CG_EN_SHFT = 0x10,
  3012. + S_SCMO_CLK_CTRL_RCH_CG_EN_BMSK = 0x1000,
  3013. + S_SCMO_CLK_CTRL_RCH_CG_EN_SHFT = 0xc,
  3014. + S_SCMO_CLK_CTRL_FLUSH_CG_EN_BMSK = 0x100,
  3015. + S_SCMO_CLK_CTRL_FLUSH_CG_EN_SHFT = 0x8,
  3016. + S_SCMO_CLK_CTRL_WCH_CG_EN_BMSK = 0x10,
  3017. + S_SCMO_CLK_CTRL_WCH_CG_EN_SHFT = 0x4,
  3018. + S_SCMO_CLK_CTRL_ACH_CG_EN_BMSK = 0x1,
  3019. + S_SCMO_CLK_CTRL_ACH_CG_EN_SHFT = 0x0,
  3020. +};
  3021. +
  3022. +#define S_SCMO_SLV_INTERLEAVE_CFG_ADDR(b, n) \
  3023. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000400)
  3024. +enum bimc_s_scmo_slv_interleave_cfg {
  3025. + S_SCMO_SLV_INTERLEAVE_CFG_RMSK = 0xff,
  3026. + S_SCMO_SLV_INTERLEAVE_CFG_INTERLEAVE_CS1_BMSK = 0x10,
  3027. + S_SCMO_SLV_INTERLEAVE_CFG_INTERLEAVE_CS1_SHFT = 0x4,
  3028. + S_SCMO_SLV_INTERLEAVE_CFG_INTERLEAVE_CS0_BMSK = 0x1,
  3029. + S_SCMO_SLV_INTERLEAVE_CFG_INTERLEAVE_CS0_SHFT = 0x0,
  3030. +};
  3031. +
  3032. +#define S_SCMO_ADDR_BASE_CSn_ADDR(b, n, o) \
  3033. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000410 + 0x4 * (o))
  3034. +enum bimc_s_scmo_addr_base_csn {
  3035. + S_SCMO_ADDR_BASE_CSn_RMSK = 0xffff,
  3036. + S_SCMO_ADDR_BASE_CSn_MAXn = 1,
  3037. + S_SCMO_ADDR_BASE_CSn_ADDR_BASE_BMSK = 0xfc,
  3038. + S_SCMO_ADDR_BASE_CSn_ADDR_BASE_SHFT = 0x2,
  3039. +};
  3040. +
  3041. +#define S_SCMO_ADDR_MAP_CSn_ADDR(b, n, o) \
  3042. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000420 + 0x4 * (o))
  3043. +enum bimc_s_scmo_addr_map_csn {
  3044. + S_SCMO_ADDR_MAP_CSn_RMSK = 0xffff,
  3045. + S_SCMO_ADDR_MAP_CSn_MAXn = 1,
  3046. + S_SCMO_ADDR_MAP_CSn_RANK_EN_BMSK = 0x8000,
  3047. + S_SCMO_ADDR_MAP_CSn_RANK_EN_SHFT = 0xf,
  3048. + S_SCMO_ADDR_MAP_CSn_ADDR_MODE_BMSK = 0x1000,
  3049. + S_SCMO_ADDR_MAP_CSn_ADDR_MODE_SHFT = 0xc,
  3050. + S_SCMO_ADDR_MAP_CSn_BANK_SIZE_BMSK = 0x100,
  3051. + S_SCMO_ADDR_MAP_CSn_BANK_SIZE_SHFT = 0x8,
  3052. + S_SCMO_ADDR_MAP_CSn_ROW_SIZE_BMSK = 0x30,
  3053. + S_SCMO_ADDR_MAP_CSn_ROW_SIZE_SHFT = 0x4,
  3054. + S_SCMO_ADDR_MAP_CSn_COL_SIZE_BMSK = 0x3,
  3055. + S_SCMO_ADDR_MAP_CSn_COL_SIZE_SHFT = 0x0,
  3056. +};
  3057. +
  3058. +#define S_SCMO_ADDR_MASK_CSn_ADDR(b, n, o) \
  3059. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000430 + 0x4 * (0))
  3060. +enum bimc_s_scmo_addr_mask_csn {
  3061. + S_SCMO_ADDR_MASK_CSn_RMSK = 0xffff,
  3062. + S_SCMO_ADDR_MASK_CSn_MAXn = 1,
  3063. + S_SCMO_ADDR_MASK_CSn_ADDR_MASK_BMSK = 0xfc,
  3064. + S_SCMO_ADDR_MASK_CSn_ADDR_MASK_SHFT = 0x2,
  3065. +};
  3066. +
  3067. +#define S_SCMO_SLV_STATUS_ADDR(b, n) \
  3068. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000450)
  3069. +enum bimc_s_scmo_slv_status {
  3070. + S_SCMO_SLV_STATUS_RMSK = 0xff3,
  3071. + S_SCMO_SLV_STATUS_GLOBAL_MONS_IN_USE_BMSK = 0xff0,
  3072. + S_SCMO_SLV_STATUS_GLOBAL_MONS_IN_USE_SHFT = 0x4,
  3073. + S_SCMO_SLV_STATUS_SLAVE_IDLE_BMSK = 0x3,
  3074. + S_SCMO_SLV_STATUS_SLAVE_IDLE_SHFT = 0x0,
  3075. +};
  3076. +
  3077. +#define S_SCMO_CMD_BUF_CFG_ADDR(b, n) \
  3078. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000500)
  3079. +enum bimc_s_scmo_cmd_buf_cfg {
  3080. + S_SCMO_CMD_BUF_CFG_RMSK = 0xf1f,
  3081. + S_SCMO_CMD_BUF_CFG_CMD_ORDERING_BMSK = 0x300,
  3082. + S_SCMO_CMD_BUF_CFG_CMD_ORDERING_SHFT = 0x8,
  3083. + S_SCMO_CMD_BUF_CFG_HP_CMD_AREQPRIO_MAP_BMSK = 0x10,
  3084. + S_SCMO_CMD_BUF_CFG_HP_CMD_AREQPRIO_MAP_SHFT = 0x4,
  3085. + S_SCMO_CMD_BUF_CFG_HP_CMD_Q_DEPTH_BMSK = 0x7,
  3086. + S_SCMO_CMD_BUF_CFG_HP_CMD_Q_DEPTH_SHFT = 0x0,
  3087. +};
  3088. +
  3089. +#define S_SCM_CMD_BUF_STATUS_ADDR(b, n) \
  3090. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000520)
  3091. +enum bimc_s_scm_cmd_buf_status {
  3092. + S_SCMO_CMD_BUF_STATUS_RMSK = 0x77,
  3093. + S_SCMO_CMD_BUF_STATUS_HP_CMD_BUF_ENTRIES_IN_USE_BMSK = 0x70,
  3094. + S_SCMO_CMD_BUF_STATUS_HP_CMD_BUF_ENTRIES_IN_USE_SHFT = 0x4,
  3095. + S_SCMO_CMD_BUF_STATUS_LP_CMD_BUF_ENTRIES_IN_USE_BMSK = 0x7,
  3096. + S_SCMO_CMD_BUF_STATUS_LP_CMD_BUF_ENTRIES_IN_USE_SHFT = 0x0,
  3097. +};
  3098. +
  3099. +#define S_SCMO_RCH_SEL_ADDR(b, n) \
  3100. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000540)
  3101. +enum bimc_s_scmo_rch_sel {
  3102. + S_SCMO_RCH_SEL_RMSK = 0xffffffff,
  3103. + S_SCMO_CMD_BUF_STATUS_RCH_PORTS_BMSK = 0xffffffff,
  3104. + S_SCMO_CMD_BUF_STATUS_RCH_PORTS_SHFT = 0x0,
  3105. +};
  3106. +
  3107. +#define S_SCMO_RCH_BKPR_CFG_ADDR(b, n) \
  3108. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000544)
  3109. +enum bimc_s_scmo_rch_bkpr_cfg {
  3110. + S_SCMO_RCH_BKPR_CFG_RMSK = 0xffffffff,
  3111. + S_SCMO_RCH_BKPR_CFG_RCH1_FIFO_BKPR_HI_TH_BMSK = 0x3f000000,
  3112. + S_SCMO_RCH_BKPR_CFG_RCH1_FIFO_BKPR_HI_TH_SHFT = 0x18,
  3113. + S_SCMO_RCH_BKPR_CFG_RCH1_FIFO_BKPR_LO_TH_BMSK = 0x3f0000,
  3114. + S_SCMO_RCH_BKPR_CFG_RCH1_FIFO_BKPR_LO_TH_SHFT = 0x10,
  3115. + S_SCMO_RCH_BKPR_CFG_RCH0_FIFO_BKPR_HI_TH_BMSK = 0x3f00,
  3116. + S_SCMO_RCH_BKPR_CFG_RCH0_FIFO_BKPR_HI_TH_SHFT = 0x8,
  3117. + S_SCMO_RCH_BKPR_CFG_RCH0_FIFO_BKPR_LO_TH_BMSK = 0x3f,
  3118. + S_SCMO_RCH_BKPR_CFG_RCH0_FIFO_BKPR_LO_TH_SHFT = 0x0,
  3119. +};
  3120. +
  3121. +#define S_SCMO_RCH_STATUS_ADDR(b, n) \
  3122. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000560)
  3123. +enum bimc_s_scmo_rch_status {
  3124. + S_SCMO_RCH_STATUS_RMSK = 0x33333,
  3125. + S_SCMO_RCH_STATUS_PRQ_FIFO_FULL_BMSK = 0x20000,
  3126. + S_SCMO_RCH_STATUS_PRQ_FIFO_FULL_SHFT = 0x11,
  3127. + S_SCMO_RCH_STATUS_PRQ_FIFO_EMPTY_BMSK = 0x10000,
  3128. + S_SCMO_RCH_STATUS_PRQ_FIFO_EMPTY_SHFT = 0x10,
  3129. + S_SCMO_RCH_STATUS_RCH1_QUAL_FIFO_FULL_BMSK = 0x2000,
  3130. + S_SCMO_RCH_STATUS_RCH1_QUAL_FIFO_FULL_SHFT = 0xd,
  3131. + S_SCMO_RCH_STATUS_RCH1_QUAL_FIFO_EMPTY_BMSK = 0x1000,
  3132. + S_SCMO_RCH_STATUS_RCH1_QUAL_FIFO_EMPTY_SHFT = 0xc,
  3133. + S_SCMO_RCH_STATUS_RCH1_DATA_FIFO_FULL_BMSK = 0x200,
  3134. + S_SCMO_RCH_STATUS_RCH1_DATA_FIFO_FULL_SHFT = 0x9,
  3135. + S_SCMO_RCH_STATUS_RCH1_DATA_FIFO_EMPTY_BMSK = 0x100,
  3136. + S_SCMO_RCH_STATUS_RCH1_DATA_FIFO_EMPTY_SHFT = 0x8,
  3137. + S_SCMO_RCH_STATUS_RCH0_QUAL_FIFO_FULL_BMSK = 0x20,
  3138. + S_SCMO_RCH_STATUS_RCH0_QUAL_FIFO_FULL_SHFT = 0x5,
  3139. + S_SCMO_RCH_STATUS_RCH0_QUAL_FIFO_EMPTY_BMSK = 0x10,
  3140. + S_SCMO_RCH_STATUS_RCH0_QUAL_FIFO_EMPTY_SHFT = 0x4,
  3141. + S_SCMO_RCH_STATUS_RCH0_DATA_FIFO_FULL_BMSK = 0x2,
  3142. + S_SCMO_RCH_STATUS_RCH0_DATA_FIFO_FULL_SHFT = 0x1,
  3143. + S_SCMO_RCH_STATUS_RCH0_DATA_FIFO_EMPTY_BMSK = 0x1,
  3144. + S_SCMO_RCH_STATUS_RCH0_DATA_FIFO_EMPTY_SHFT = 0x0,
  3145. +};
  3146. +
  3147. +#define S_SCMO_WCH_BUF_CFG_ADDR(b, n) \
  3148. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000580)
  3149. +enum bimc_s_scmo_wch_buf_cfg {
  3150. + S_SCMO_WCH_BUF_CFG_RMSK = 0xff,
  3151. + S_SCMO_WCH_BUF_CFG_WRITE_BLOCK_READ_BMSK = 0x10,
  3152. + S_SCMO_WCH_BUF_CFG_WRITE_BLOCK_READ_SHFT = 0x4,
  3153. + S_SCMO_WCH_BUF_CFG_COALESCE_EN_BMSK = 0x1,
  3154. + S_SCMO_WCH_BUF_CFG_COALESCE_EN_SHFT = 0x0,
  3155. +};
  3156. +
  3157. +#define S_SCMO_WCH_STATUS_ADDR(b, n) \
  3158. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x000005a0)
  3159. +enum bimc_s_scmo_wch_status {
  3160. + S_SCMO_WCH_STATUS_RMSK = 0x333,
  3161. + S_SCMO_WCH_STATUS_BRESP_FIFO_FULL_BMSK = 0x200,
  3162. + S_SCMO_WCH_STATUS_BRESP_FIFO_FULL_SHFT = 0x9,
  3163. + S_SCMO_WCH_STATUS_BRESP_FIFO_EMPTY_BMSK = 0x100,
  3164. + S_SCMO_WCH_STATUS_BRESP_FIFO_EMPTY_SHFT = 0x8,
  3165. + S_SCMO_WCH_STATUS_WDATA_FIFO_FULL_BMSK = 0x20,
  3166. + S_SCMO_WCH_STATUS_WDATA_FIFO_FULL_SHFT = 0x5,
  3167. + S_SCMO_WCH_STATUS_WDATA_FIFO_EMPTY_BMSK = 0x10,
  3168. + S_SCMO_WCH_STATUS_WDATA_FIFO_EMPTY_SHFT = 0x4,
  3169. + S_SCMO_WCH_STATUS_WBUF_FULL_BMSK = 0x2,
  3170. + S_SCMO_WCH_STATUS_WBUF_FULL_SHFT = 0x1,
  3171. + S_SCMO_WCH_STATUS_WBUF_EMPTY_BMSK = 0x1,
  3172. + S_SCMO_WCH_STATUS_WBUF_EMPTY_SHFT = 0x0,
  3173. +};
  3174. +
  3175. +#define S_SCMO_FLUSH_CFG_ADDR(b, n) \
  3176. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x000005c0)
  3177. +enum bimc_s_scmo_flush_cfg {
  3178. + S_SCMO_FLUSH_CFG_RMSK = 0xffffffff,
  3179. + S_SCMO_FLUSH_CFG_FLUSH_IN_ORDER_BMSK = 0x10000000,
  3180. + S_SCMO_FLUSH_CFG_FLUSH_IN_ORDER_SHFT = 0x1c,
  3181. + S_SCMO_FLUSH_CFG_FLUSH_IDLE_DELAY_BMSK = 0x3ff0000,
  3182. + S_SCMO_FLUSH_CFG_FLUSH_IDLE_DELAY_SHFT = 0x10,
  3183. + S_SCMO_FLUSH_CFG_FLUSH_UPPER_LIMIT_BMSK = 0xf00,
  3184. + S_SCMO_FLUSH_CFG_FLUSH_UPPER_LIMIT_SHFT = 0x8,
  3185. + S_SCMO_FLUSH_CFG_FLUSH_LOWER_LIMIT_BMSK = 0xf,
  3186. + S_SCMO_FLUSH_CFG_FLUSH_LOWER_LIMIT_SHFT = 0x0,
  3187. +};
  3188. +
  3189. +#define S_SCMO_FLUSH_CMD_ADDR(b, n) \
  3190. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x000005c4)
  3191. +enum bimc_s_scmo_flush_cmd {
  3192. + S_SCMO_FLUSH_CMD_RMSK = 0xf,
  3193. + S_SCMO_FLUSH_CMD_FLUSH_ALL_BUF_BMSK = 0x3,
  3194. + S_SCMO_FLUSH_CMD_FLUSH_ALL_BUF_SHFT = 0x0,
  3195. +};
  3196. +
  3197. +#define S_SCMO_CMD_OPT_CFG0_ADDR(b, n) \
  3198. + (S_SCM0_REG_BASE(b) + (0x8000 * (n)) + 0x00000700)
  3199. +enum bimc_s_scmo_cmd_opt_cfg0 {
  3200. + S_SCMO_CMD_OPT_CFG0_RMSK = 0xffffff,
  3201. + S_SCMO_CMD_OPT_CFG0_IGNORE_BANK_UNAVL_BMSK = 0x100000,
  3202. + S_SCMO_CMD_OPT_CFG0_IGNORE_BANK_UNAVL_SHFT = 0x14,
  3203. + S_SCMO_CMD_OPT_CFG0_MASK_CMDOUT_PRI_BMSK = 0x10000,
  3204. + S_SCMO_CMD_OPT_CFG0_MASK_CMDOUT_PRI_SHFT = 0x10,
  3205. + S_SCMO_CMD_OPT_CFG0_DPE_CMD_REORDERING_BMSK = 0x1000,
  3206. + S_SCMO_CMD_OPT_CFG0_DPE_CMD_REORDERING_SHFT = 0xc,
  3207. + S_SCMO_CMD_OPT_CFG0_WR_OPT_EN_BMSK = 0x100,
  3208. + S_SCMO_CMD_OPT_CFG0_WR_OPT_EN_SHFT = 0x8,
  3209. + S_SCMO_CMD_OPT_CFG0_RD_OPT_EN_BMSK = 0x10,
  3210. + S_SCMO_CMD_OPT_CFG0_RD_OPT_EN_SHFT = 0x4,
  3211. + S_SCMO_CMD_OPT_CFG0_PAGE_MGMT_POLICY_BMSK = 0x1,
  3212. + S_SCMO_CMD_OPT_CFG0_PAGE_MGMT_POLICY_SHFT = 0x0,
  3213. +};
  3214. +
  3215. +#define S_SCMO_CMD_OPT_CFG1_ADDR(b, n) \
  3216. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000704)
  3217. +enum bimc_s_scmo_cmd_opt_cfg1 {
  3218. + S_SCMO_CMD_OPT_CFG1_RMSK = 0xffffffff,
  3219. + S_SCMO_CMD_OPT_CFG1_HSTP_CMD_TIMEOUT_BMSK = 0x1f000000,
  3220. + S_SCMO_CMD_OPT_CFG1_HSTP_CMD_TIMEOUT_SHFT = 0x18,
  3221. + S_SCMO_CMD_OPT_CFG1_HP_CMD_TIMEOUT_BMSK = 0x1f0000,
  3222. + S_SCMO_CMD_OPT_CFG1_HP_CMD_TIMEOUT_SHFT = 0x10,
  3223. + S_SCMO_CMD_OPT_CFG1_MP_CMD_TIMEOUT_BMSK = 0x1f00,
  3224. + S_SCMO_CMD_OPT_CFG1_MP_CMD_TIMEOUT_SHFT = 0x8,
  3225. + S_SCMO_CMD_OPT_CFG1_LP_CMD_TIMEOUT_BMSK = 0x1f,
  3226. + S_SCMO_CMD_OPT_CFG1_LP_CMD_TIMEOUT_SHFT = 0x0,
  3227. +};
  3228. +
  3229. +#define S_SCMO_CMD_OPT_CFG2_ADDR(b, n) \
  3230. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x00000708)
  3231. +enum bimc_s_scmo_cmd_opt_cfg2 {
  3232. + S_SCMO_CMD_OPT_CFG2_RMSK = 0xff,
  3233. + S_SCMO_CMD_OPT_CFG2_RWOPT_CMD_TIMEOUT_BMSK = 0xf,
  3234. + S_SCMO_CMD_OPT_CFG2_RWOPT_CMD_TIMEOUT_SHFT = 0x0,
  3235. +};
  3236. +
  3237. +#define S_SCMO_CMD_OPT_CFG3_ADDR(b, n) \
  3238. + (S_SCMO_REG_BASE(b) + (0x8000 * (n)) + 0x0000070c)
  3239. +enum bimc_s_scmo_cmd_opt_cfg3 {
  3240. + S_SCMO_CMD_OPT_CFG3_RMSK = 0xff,
  3241. + S_SCMO_CMD_OPT_CFG3_FLUSH_CMD_TIMEOUT_BMSK = 0xf,
  3242. + S_SCMO_CMD_OPT_CFG3_FLUSH_CMD_TIMEOUT_SHFT = 0x0,
  3243. +};
  3244. +
  3245. +/* S_SWAY_GENERIC */
  3246. +#define S_SWAY_REG_BASE(b) ((b) + 0x00048000)
  3247. +
  3248. +#define S_SWAY_CONFIG_INFO_0_ADDR(b, n) \
  3249. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000020)
  3250. +enum bimc_s_sway_config_info_0 {
  3251. + S_SWAY_CONFIG_INFO_0_RMSK = 0xff0000ff,
  3252. + S_SWAY_CONFIG_INFO_0_SYNC_MODE_BMSK = 0xff000000,
  3253. + S_SWAY_CONFIG_INFO_0_SYNC_MODE_SHFT = 0x18,
  3254. + S_SWAY_CONFIG_INFO_0_FUNC_BMSK = 0xff,
  3255. + S_SWAY_CONFIG_INFO_0_FUNC_SHFT = 0x0,
  3256. +};
  3257. +
  3258. +#define S_SWAY_CONFIG_INFO_1_ADDR(b, n) \
  3259. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000030)
  3260. +enum bimc_s_sway_config_info_1 {
  3261. + S_SWAY_CONFIG_INFO_1_RMSK = 0xffffffff,
  3262. + S_SWAY_CONFIG_INFO_1_MPORT_CONNECTIVITY_BMSK = 0xffffffff,
  3263. + S_SWAY_CONFIG_INFO_1_MPORT_CONNECTIVITY_SHFT = 0x0,
  3264. +};
  3265. +
  3266. +#define S_SWAY_CONFIG_INFO_2_ADDR(b, n) \
  3267. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000040)
  3268. +enum bimc_s_sway_config_info_2 {
  3269. + S_SWAY_CONFIG_INFO_2_RMSK = 0xffff0000,
  3270. + S_SWAY_CONFIG_INFO_2_MPORT_CONNECTIVITY_BMSK = 0xffff0000,
  3271. + S_SWAY_CONFIG_INFO_2_MPORT_CONNECTIVITY_SHFT = 0x10,
  3272. +};
  3273. +
  3274. +#define S_SWAY_CONFIG_INFO_3_ADDR(b, n) \
  3275. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000050)
  3276. +enum bimc_s_sway_config_info_3 {
  3277. + S_SWAY_CONFIG_INFO_3_RMSK = 0xffffffff,
  3278. + S_SWAY_CONFIG_INFO_3_RCH0_DEPTH_BMSK = 0xff000000,
  3279. + S_SWAY_CONFIG_INFO_3_RCH0_DEPTH_SHFT = 0x18,
  3280. + S_SWAY_CONFIG_INFO_3_BCH_DEPTH_BMSK = 0xff0000,
  3281. + S_SWAY_CONFIG_INFO_3_BCH_DEPTH_SHFT = 0x10,
  3282. + S_SWAY_CONFIG_INFO_3_WCH_DEPTH_BMSK = 0xff,
  3283. + S_SWAY_CONFIG_INFO_3_WCH_DEPTH_SHFT = 0x0,
  3284. +};
  3285. +
  3286. +#define S_SWAY_CONFIG_INFO_4_ADDR(b, n) \
  3287. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000060)
  3288. +enum bimc_s_sway_config_info_4 {
  3289. + S_SWAY_CONFIG_INFO_4_RMSK = 0x800000ff,
  3290. + S_SWAY_CONFIG_INFO_4_DUAL_RCH_EN_BMSK = 0x80000000,
  3291. + S_SWAY_CONFIG_INFO_4_DUAL_RCH_EN_SHFT = 0x1f,
  3292. + S_SWAY_CONFIG_INFO_4_RCH1_DEPTH_BMSK = 0xff,
  3293. + S_SWAY_CONFIG_INFO_4_RCH1_DEPTH_SHFT = 0x0,
  3294. +};
  3295. +
  3296. +#define S_SWAY_CONFIG_INFO_5_ADDR(b, n) \
  3297. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000070)
  3298. +enum bimc_s_sway_config_info_5 {
  3299. + S_SWAY_CONFIG_INFO_5_RMSK = 0x800000ff,
  3300. + S_SWAY_CONFIG_INFO_5_QCH_EN_BMSK = 0x80000000,
  3301. + S_SWAY_CONFIG_INFO_5_QCH_EN_SHFT = 0x1f,
  3302. + S_SWAY_CONFIG_INFO_5_QCH_DEPTH_BMSK = 0xff,
  3303. + S_SWAY_CONFIG_INFO_5_QCH_DEPTH_SHFT = 0x0,
  3304. +};
  3305. +
  3306. +#define S_SWAY_CONFIG_INFO_6_ADDR(b, n) \
  3307. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000080)
  3308. +enum bimc_s_sway_config_info_6 {
  3309. + S_SWAY_CONFIG_INFO_6_RMSK = 0x1,
  3310. + S_SWAY_CONFIG_INFO_6_S2SW_PIPELINE_EN_BMSK = 0x1,
  3311. + S_SWAY_CONFIG_INFO_6_S2SW_PIPELINE_EN_SHFT = 0x0,
  3312. +};
  3313. +
  3314. +#define S_SWAY_INT_STATUS_ADDR(b, n) \
  3315. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000100)
  3316. +enum bimc_s_sway_int_status {
  3317. + S_SWAY_INT_STATUS_RMSK = 0x3,
  3318. + S_SWAY_INT_STATUS_RFU_BMSK = 0x3,
  3319. + S_SWAY_INT_STATUS_RFU_SHFT = 0x0,
  3320. +};
  3321. +
  3322. +#define S_SWAY_INT_CLR_ADDR(b, n) \
  3323. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000108)
  3324. +enum bimc_s_sway_int_clr {
  3325. + S_SWAY_INT_CLR_RMSK = 0x3,
  3326. + S_SWAY_INT_CLR_RFU_BMSK = 0x3,
  3327. + S_SWAY_INT_CLR_RFU_SHFT = 0x0,
  3328. +};
  3329. +
  3330. +
  3331. +#define S_SWAY_INT_EN_ADDR(b, n) \
  3332. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x0000010c)
  3333. +enum bimc_s_sway_int_en {
  3334. + S_SWAY_INT_EN_RMSK = 0x3,
  3335. + S_SWAY_INT_EN_RFU_BMSK = 0x3,
  3336. + S_SWAY_INT_EN_RFU_SHFT = 0x0,
  3337. +};
  3338. +
  3339. +#define S_SWAY_CLK_CTRL_ADDR(b, n) \
  3340. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000200)
  3341. +enum bimc_s_sway_clk_ctrl {
  3342. + S_SWAY_CLK_CTRL_RMSK = 0x3,
  3343. + S_SWAY_CLK_CTRL_SLAVE_CLK_GATING_EN_BMSK = 0x2,
  3344. + S_SWAY_CLK_CTRL_SLAVE_CLK_GATING_EN_SHFT = 0x1,
  3345. + S_SWAY_CLK_CTRL_CORE_CLK_GATING_EN_BMSK = 0x1,
  3346. + S_SWAY_CLK_CTRL_CORE_CLK_GATING_EN_SHFT = 0x0,
  3347. +};
  3348. +
  3349. +#define S_SWAY_RCH_SEL_ADDR(b, n) \
  3350. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000210)
  3351. +enum bimc_s_sway_rch_sel {
  3352. + S_SWAY_RCH_SEL_RMSK = 0x7f,
  3353. + S_SWAY_RCH_SEL_UNUSED_BMSK = 0x7f,
  3354. + S_SWAY_RCH_SEL_UNUSED_SHFT = 0x0,
  3355. +};
  3356. +
  3357. +
  3358. +#define S_SWAY_MAX_OUTSTANDING_REQS_ADDR(b, n) \
  3359. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000220)
  3360. +enum bimc_s_sway_max_outstanding_reqs {
  3361. + S_SWAY_MAX_OUTSTANDING_REQS_RMSK = 0xffff,
  3362. + S_SWAY_MAX_OUTSTANDING_REQS_WRITE_BMSK = 0xff00,
  3363. + S_SWAY_MAX_OUTSTANDING_REQS_WRITE_SHFT = 0x8,
  3364. + S_SWAY_MAX_OUTSTANDING_REQS_READ_BMSK = 0xff,
  3365. + S_SWAY_MAX_OUTSTANDING_REQS_READ_SHFT = 0x0,
  3366. +};
  3367. +
  3368. +
  3369. +#define S_SWAY_BUF_STATUS_0_ADDR(b, n) \
  3370. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000400)
  3371. +enum bimc_s_sway_buf_status_0 {
  3372. + S_SWAY_BUF_STATUS_0_RMSK = 0xf0300f03,
  3373. + S_SWAY_BUF_STATUS_0_RCH0_DATA_RD_FULL_BMSK = 0x80000000,
  3374. + S_SWAY_BUF_STATUS_0_RCH0_DATA_RD_FULL_SHFT = 0x1f,
  3375. + S_SWAY_BUF_STATUS_0_RCH0_DATA_RD_EMPTY_BMSK = 0x40000000,
  3376. + S_SWAY_BUF_STATUS_0_RCH0_DATA_RD_EMPTY_SHFT = 0x1e,
  3377. + S_SWAY_BUF_STATUS_0_RCH0_CTRL_RD_FULL_BMSK = 0x20000000,
  3378. + S_SWAY_BUF_STATUS_0_RCH0_CTRL_RD_FULL_SHFT = 0x1d,
  3379. + S_SWAY_BUF_STATUS_0_RCH0_CTRL_RD_EMPTY_BMSK = 0x10000000,
  3380. + S_SWAY_BUF_STATUS_0_RCH0_CTRL_RD_EMPTY_SHFT = 0x1c,
  3381. + S_SWAY_BUF_STATUS_0_BCH_RD_FULL_BMSK = 0x200000,
  3382. + S_SWAY_BUF_STATUS_0_BCH_RD_FULL_SHFT = 0x15,
  3383. + S_SWAY_BUF_STATUS_0_BCH_RD_EMPTY_BMSK = 0x100000,
  3384. + S_SWAY_BUF_STATUS_0_BCH_RD_EMPTY_SHFT = 0x14,
  3385. + S_SWAY_BUF_STATUS_0_WCH_DATA_WR_FULL_BMSK = 0x800,
  3386. + S_SWAY_BUF_STATUS_0_WCH_DATA_WR_FULL_SHFT = 0xb,
  3387. + S_SWAY_BUF_STATUS_0_WCH_DATA_WR_EMPTY_BMSK = 0x400,
  3388. + S_SWAY_BUF_STATUS_0_WCH_DATA_WR_EMPTY_SHFT = 0xa,
  3389. + S_SWAY_BUF_STATUS_0_WCH_CTRL_WR_FULL_BMSK = 0x200,
  3390. + S_SWAY_BUF_STATUS_0_WCH_CTRL_WR_FULL_SHFT = 0x9,
  3391. + S_SWAY_BUF_STATUS_0_WCH_CTRL_WR_EMPTY_BMSK = 0x100,
  3392. + S_SWAY_BUF_STATUS_0_WCH_CTRL_WR_EMPTY_SHFT = 0x8,
  3393. + S_SWAY_BUF_STATUS_0_ACH_WR_FULL_BMSK = 0x2,
  3394. + S_SWAY_BUF_STATUS_0_ACH_WR_FULL_SHFT = 0x1,
  3395. + S_SWAY_BUF_STATUS_0_ACH_WR_EMPTY_BMSK = 0x1,
  3396. + S_SWAY_BUF_STATUS_0_ACH_WR_EMPTY_SHFT = 0x0,
  3397. +};
  3398. +
  3399. +#define S_SWAY_BUF_STATUS_1_ADDR(b, n) \
  3400. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000410)
  3401. +enum bimc_s_sway_buf_status_1 {
  3402. + S_SWAY_BUF_STATUS_1_RMSK = 0xf0,
  3403. + S_SWAY_BUF_STATUS_1_RCH1_DATA_RD_FULL_BMSK = 0x80,
  3404. + S_SWAY_BUF_STATUS_1_RCH1_DATA_RD_FULL_SHFT = 0x7,
  3405. + S_SWAY_BUF_STATUS_1_RCH1_DATA_RD_EMPTY_BMSK = 0x40,
  3406. + S_SWAY_BUF_STATUS_1_RCH1_DATA_RD_EMPTY_SHFT = 0x6,
  3407. + S_SWAY_BUF_STATUS_1_RCH1_CTRL_RD_FULL_BMSK = 0x20,
  3408. + S_SWAY_BUF_STATUS_1_RCH1_CTRL_RD_FULL_SHFT = 0x5,
  3409. + S_SWAY_BUF_STATUS_1_RCH1_CTRL_RD_EMPTY_BMSK = 0x10,
  3410. + S_SWAY_BUF_STATUS_1_RCH1_CTRL_RD_EMPTY_SHFT = 0x4,
  3411. +};
  3412. +
  3413. +#define S_SWAY_BUF_STATUS_2_ADDR(b, n) \
  3414. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000420)
  3415. +enum bimc_s_sway_buf_status_2 {
  3416. + S_SWAY_BUF_STATUS_2_RMSK = 0x30,
  3417. + S_SWAY_BUF_STATUS_2_QCH_RD_FULL_BMSK = 0x20,
  3418. + S_SWAY_BUF_STATUS_2_QCH_RD_FULL_SHFT = 0x5,
  3419. + S_SWAY_BUF_STATUS_2_QCH_RD_EMPTY_BMSK = 0x10,
  3420. + S_SWAY_BUF_STATUS_2_QCH_RD_EMPTY_SHFT = 0x4,
  3421. +};
  3422. +
  3423. +/* S_ARB_GENERIC */
  3424. +
  3425. +#define S_ARB_REG_BASE(b) ((b) + 0x00049000)
  3426. +
  3427. +#define S_ARB_COMPONENT_INFO_ADDR(b, n) \
  3428. + (S_SWAY_REG_BASE(b) + (0x8000 * (n)) + 0x00000000)
  3429. +enum bimc_s_arb_component_info {
  3430. + S_ARB_COMPONENT_INFO_RMSK = 0xffffff,
  3431. + S_ARB_COMPONENT_INFO_INSTANCE_BMSK = 0xff0000,
  3432. + S_ARB_COMPONENT_INFO_INSTANCE_SHFT = 0x10,
  3433. + S_ARB_COMPONENT_INFO_SUB_TYPE_BMSK = 0xff00,
  3434. + S_ARB_COMPONENT_INFO_SUB_TYPE_SHFT = 0x8,
  3435. + S_ARB_COMPONENT_INFO_TYPE_BMSK = 0xff,
  3436. + S_ARB_COMPONENT_INFO_TYPE_SHFT = 0x0,
  3437. +};
  3438. +
  3439. +#define S_ARB_CONFIG_INFO_0_ADDR(b, n) \
  3440. + (S_ARB_REG_BASE(b) + (0x8000 * (n)) + 0x00000020)
  3441. +enum bimc_s_arb_config_info_0 {
  3442. + S_ARB_CONFIG_INFO_0_RMSK = 0x800000ff,
  3443. + S_ARB_CONFIG_INFO_0_ARB2SW_PIPELINE_EN_BMSK = 0x80000000,
  3444. + S_ARB_CONFIG_INFO_0_ARB2SW_PIPELINE_EN_SHFT = 0x1f,
  3445. + S_ARB_CONFIG_INFO_0_FUNC_BMSK = 0xff,
  3446. + S_ARB_CONFIG_INFO_0_FUNC_SHFT = 0x0,
  3447. +};
  3448. +
  3449. +#define S_ARB_CONFIG_INFO_1_ADDR(b, n) \
  3450. + (S_ARB_REG_BASE(b) + (0x8000 * (n)) + 0x00000030)
  3451. +enum bimc_s_arb_config_info_1 {
  3452. + S_ARB_CONFIG_INFO_1_RMSK = 0xffffffff,
  3453. + S_ARB_CONFIG_INFO_1_MPORT_CONNECTIVITY_BMSK = 0xffffffff,
  3454. + S_ARB_CONFIG_INFO_1_MPORT_CONNECTIVITY_SHFT = 0x0,
  3455. +};
  3456. +
  3457. +#define S_ARB_CLK_CTRL_ADDR(b) \
  3458. + (S_ARB_REG_BASE(b) + (0x8000 * (n)) + 0x00000200)
  3459. +enum bimc_s_arb_clk_ctrl {
  3460. + S_ARB_CLK_CTRL_RMSK = 0x1,
  3461. + S_ARB_CLK_CTRL_SLAVE_CLK_GATING_EN_BMSK = 0x2,
  3462. + S_ARB_CLK_CTRL_SLAVE_CLK_GATING_EN_SHFT = 0x1,
  3463. + S_ARB_CLK_CTRL_CORE_CLK_GATING_EN_BMSK = 0x1,
  3464. + S_ARB_CLK_CTRL_CORE_CLK_GATING_EN_SHFT = 0x0,
  3465. + S_ARB_CLK_CTRL_CLK_GATING_EN_BMSK = 0x1,
  3466. + S_ARB_CLK_CTRL_CLK_GATING_EN_SHFT = 0x0,
  3467. +};
  3468. +
  3469. +#define S_ARB_MODE_ADDR(b, n) \
  3470. + (S_ARB_REG_BASE(b) + (0x8000 * (n)) + 0x00000210)
  3471. +enum bimc_s_arb_mode {
  3472. + S_ARB_MODE_RMSK = 0xf0000001,
  3473. + S_ARB_MODE_WR_GRANTS_AHEAD_BMSK = 0xf0000000,
  3474. + S_ARB_MODE_WR_GRANTS_AHEAD_SHFT = 0x1c,
  3475. + S_ARB_MODE_PRIO_RR_EN_BMSK = 0x1,
  3476. + S_ARB_MODE_PRIO_RR_EN_SHFT = 0x0,
  3477. +};
  3478. +
  3479. +#define BKE_HEALTH_MASK \
  3480. + (M_BKE_HEALTH_0_CONFIG_LIMIT_CMDS_BMSK |\
  3481. + M_BKE_HEALTH_0_CONFIG_AREQPRIO_BMSK |\
  3482. + M_BKE_HEALTH_0_CONFIG_PRIOLVL_BMSK)
  3483. +
  3484. +#define BKE_HEALTH_VAL(limit, areq, plvl) \
  3485. + ((((limit) << M_BKE_HEALTH_0_CONFIG_LIMIT_CMDS_SHFT) & \
  3486. + M_BKE_HEALTH_0_CONFIG_LIMIT_CMDS_BMSK) | \
  3487. + (((areq) << M_BKE_HEALTH_0_CONFIG_AREQPRIO_SHFT) & \
  3488. + M_BKE_HEALTH_0_CONFIG_AREQPRIO_BMSK) | \
  3489. + (((plvl) << M_BKE_HEALTH_0_CONFIG_PRIOLVL_SHFT) & \
  3490. + M_BKE_HEALTH_0_CONFIG_PRIOLVL_BMSK))
  3491. +
  3492. +#define MAX_GRANT_PERIOD \
  3493. + (M_BKE_GP_GP_BMSK >> \
  3494. + M_BKE_GP_GP_SHFT)
  3495. +
  3496. +#define MAX_GC \
  3497. + (M_BKE_GC_GC_BMSK >> \
  3498. + (M_BKE_GC_GC_SHFT + 1))
  3499. +
  3500. +static int bimc_div(int64_t *a, uint32_t b)
  3501. +{
  3502. + if ((*a > 0) && (*a < b)) {
  3503. + *a = 0;
  3504. + return 1;
  3505. + } else {
  3506. + return do_div(*a, b);
  3507. + }
  3508. +}
  3509. +
  3510. +#define ENABLE(val) ((val) == 1 ? 1 : 0)
  3511. +void msm_bus_bimc_set_mas_clk_gate(struct msm_bus_bimc_info *binfo,
  3512. + uint32_t mas_index, struct msm_bus_bimc_clk_gate *bgate)
  3513. +{
  3514. + uint32_t val, mask, reg_val;
  3515. + void __iomem *addr;
  3516. +
  3517. + reg_val = readl_relaxed(M_CLK_CTRL_ADDR(binfo->base,
  3518. + mas_index)) & M_CLK_CTRL_RMSK;
  3519. + addr = M_CLK_CTRL_ADDR(binfo->base, mas_index);
  3520. + mask = (M_CLK_CTRL_MAS_CLK_GATING_EN_BMSK |
  3521. + M_CLK_CTRL_CORE_CLK_GATING_EN_BMSK);
  3522. + val = (bgate->core_clk_gate_en <<
  3523. + M_CLK_CTRL_MAS_CLK_GATING_EN_SHFT) |
  3524. + bgate->port_clk_gate_en;
  3525. + writel_relaxed(((reg_val & (~mask)) | (val & mask)), addr);
  3526. + /* Ensure clock gating enable mask is set before exiting */
  3527. + wmb();
  3528. +}
  3529. +
  3530. +void msm_bus_bimc_arb_en(struct msm_bus_bimc_info *binfo,
  3531. + uint32_t slv_index, bool en)
  3532. +{
  3533. + uint32_t reg_val, reg_mask_val, enable, val;
  3534. +
  3535. + reg_mask_val = (readl_relaxed(S_ARB_CONFIG_INFO_0_ADDR(binfo->
  3536. + base, slv_index)) & S_ARB_CONFIG_INFO_0_FUNC_BMSK)
  3537. + >> S_ARB_CONFIG_INFO_0_FUNC_SHFT;
  3538. + enable = ENABLE(en);
  3539. + val = enable << S_ARB_MODE_PRIO_RR_EN_SHFT;
  3540. + if (reg_mask_val == BIMC_ARB_MODE_PRIORITY_RR) {
  3541. + reg_val = readl_relaxed(S_ARB_CONFIG_INFO_0_ADDR(binfo->
  3542. + base, slv_index)) & S_ARB_MODE_RMSK;
  3543. + writel_relaxed(((reg_val & (~(S_ARB_MODE_PRIO_RR_EN_BMSK))) |
  3544. + (val & S_ARB_MODE_PRIO_RR_EN_BMSK)),
  3545. + S_ARB_MODE_ADDR(binfo->base, slv_index));
  3546. + /* Ensure arbitration mode is set before returning */
  3547. + wmb();
  3548. + }
  3549. +}
  3550. +
  3551. +static void set_qos_mode(void __iomem *baddr, uint32_t index, uint32_t val0,
  3552. + uint32_t val1, uint32_t val2)
  3553. +{
  3554. + uint32_t reg_val, val;
  3555. +
  3556. + reg_val = readl_relaxed(M_PRIOLVL_OVERRIDE_ADDR(baddr,
  3557. + index)) & M_PRIOLVL_OVERRIDE_RMSK;
  3558. + val = val0 << M_PRIOLVL_OVERRIDE_OVERRIDE_PRIOLVL_SHFT;
  3559. + writel_relaxed(((reg_val & ~(M_PRIOLVL_OVERRIDE_OVERRIDE_PRIOLVL_BMSK))
  3560. + | (val & M_PRIOLVL_OVERRIDE_OVERRIDE_PRIOLVL_BMSK)),
  3561. + M_PRIOLVL_OVERRIDE_ADDR(baddr, index));
  3562. + reg_val = readl_relaxed(M_RD_CMD_OVERRIDE_ADDR(baddr, index)) &
  3563. + M_RD_CMD_OVERRIDE_RMSK;
  3564. + val = val1 << M_RD_CMD_OVERRIDE_OVERRIDE_AREQPRIO_SHFT;
  3565. + writel_relaxed(((reg_val & ~(M_RD_CMD_OVERRIDE_OVERRIDE_AREQPRIO_BMSK
  3566. + )) | (val & M_RD_CMD_OVERRIDE_OVERRIDE_AREQPRIO_BMSK)),
  3567. + M_RD_CMD_OVERRIDE_ADDR(baddr, index));
  3568. + reg_val = readl_relaxed(M_WR_CMD_OVERRIDE_ADDR(baddr, index)) &
  3569. + M_WR_CMD_OVERRIDE_RMSK;
  3570. + val = val2 << M_WR_CMD_OVERRIDE_OVERRIDE_AREQPRIO_SHFT;
  3571. + writel_relaxed(((reg_val & ~(M_WR_CMD_OVERRIDE_OVERRIDE_AREQPRIO_BMSK
  3572. + )) | (val & M_WR_CMD_OVERRIDE_OVERRIDE_AREQPRIO_BMSK)),
  3573. + M_WR_CMD_OVERRIDE_ADDR(baddr, index));
  3574. + /* Ensure the priority register writes go through */
  3575. + wmb();
  3576. +}
  3577. +
  3578. +static void msm_bus_bimc_set_qos_mode(void __iomem *base,
  3579. + uint32_t mas_index, uint8_t qmode_sel)
  3580. +{
  3581. + uint32_t reg_val, val;
  3582. +
  3583. + switch (qmode_sel) {
  3584. + case BIMC_QOS_MODE_FIXED:
  3585. + reg_val = readl_relaxed(M_BKE_EN_ADDR(base,
  3586. + mas_index));
  3587. + writel_relaxed((reg_val & (~M_BKE_EN_EN_BMSK)),
  3588. + M_BKE_EN_ADDR(base, mas_index));
  3589. + /* Ensure that the book-keeping register writes
  3590. + * go through before setting QoS mode.
  3591. + * QoS mode registers might write beyond 1K
  3592. + * boundary in future
  3593. + */
  3594. + wmb();
  3595. + set_qos_mode(base, mas_index, 1, 1, 1);
  3596. + break;
  3597. +
  3598. + case BIMC_QOS_MODE_BYPASS:
  3599. + reg_val = readl_relaxed(M_BKE_EN_ADDR(base,
  3600. + mas_index));
  3601. + writel_relaxed((reg_val & (~M_BKE_EN_EN_BMSK)),
  3602. + M_BKE_EN_ADDR(base, mas_index));
  3603. + /* Ensure that the book-keeping register writes
  3604. + * go through before setting QoS mode.
  3605. + * QoS mode registers might write beyond 1K
  3606. + * boundary in future
  3607. + */
  3608. + wmb();
  3609. + set_qos_mode(base, mas_index, 0, 0, 0);
  3610. + break;
  3611. +
  3612. + case BIMC_QOS_MODE_REGULATOR:
  3613. + case BIMC_QOS_MODE_LIMITER:
  3614. + set_qos_mode(base, mas_index, 0, 0, 0);
  3615. + reg_val = readl_relaxed(M_BKE_EN_ADDR(base,
  3616. + mas_index));
  3617. + val = 1 << M_BKE_EN_EN_SHFT;
  3618. + /* Ensure that the book-keeping register writes
  3619. + * go through before setting QoS mode.
  3620. + * QoS mode registers might write beyond 1K
  3621. + * boundary in future
  3622. + */
  3623. + wmb();
  3624. + writel_relaxed(((reg_val & (~M_BKE_EN_EN_BMSK)) | (val &
  3625. + M_BKE_EN_EN_BMSK)), M_BKE_EN_ADDR(base,
  3626. + mas_index));
  3627. + break;
  3628. + default:
  3629. + break;
  3630. + }
  3631. +}
  3632. +
  3633. +static void set_qos_prio_rl(void __iomem *addr, uint32_t rmsk,
  3634. + uint8_t index, struct msm_bus_bimc_qos_mode *qmode)
  3635. +{
  3636. + uint32_t reg_val, val0, val;
  3637. +
  3638. + /* Note, addr is already passed with right mas_index */
  3639. + reg_val = readl_relaxed(addr) & rmsk;
  3640. + val0 = BKE_HEALTH_VAL(qmode->rl.qhealth[index].limit_commands,
  3641. + qmode->rl.qhealth[index].areq_prio,
  3642. + qmode->rl.qhealth[index].prio_level);
  3643. + val = ((reg_val & (~(BKE_HEALTH_MASK))) | (val0 & BKE_HEALTH_MASK));
  3644. + writel_relaxed(val, addr);
  3645. + /* Ensure that priority for regulator/limiter modes are
  3646. + * set before returning
  3647. + */
  3648. + wmb();
  3649. +
  3650. +}
  3651. +
  3652. +static void msm_bus_bimc_set_qos_prio(void __iomem *base,
  3653. + uint32_t mas_index, uint8_t qmode_sel,
  3654. + struct msm_bus_bimc_qos_mode *qmode)
  3655. +{
  3656. + uint32_t reg_val, val;
  3657. +
  3658. + switch (qmode_sel) {
  3659. + case BIMC_QOS_MODE_FIXED:
  3660. + reg_val = readl_relaxed(M_PRIOLVL_OVERRIDE_ADDR(
  3661. + base, mas_index)) & M_PRIOLVL_OVERRIDE_RMSK;
  3662. + val = qmode->fixed.prio_level <<
  3663. + M_PRIOLVL_OVERRIDE_SHFT;
  3664. + writel_relaxed(((reg_val &
  3665. + ~(M_PRIOLVL_OVERRIDE_BMSK)) | (val
  3666. + & M_PRIOLVL_OVERRIDE_BMSK)),
  3667. + M_PRIOLVL_OVERRIDE_ADDR(base, mas_index));
  3668. +
  3669. + reg_val = readl_relaxed(M_RD_CMD_OVERRIDE_ADDR(
  3670. + base, mas_index)) & M_RD_CMD_OVERRIDE_RMSK;
  3671. + val = qmode->fixed.areq_prio_rd <<
  3672. + M_RD_CMD_OVERRIDE_AREQPRIO_SHFT;
  3673. + writel_relaxed(((reg_val & ~(M_RD_CMD_OVERRIDE_AREQPRIO_BMSK))
  3674. + | (val & M_RD_CMD_OVERRIDE_AREQPRIO_BMSK)),
  3675. + M_RD_CMD_OVERRIDE_ADDR(base, mas_index));
  3676. +
  3677. + reg_val = readl_relaxed(M_WR_CMD_OVERRIDE_ADDR(
  3678. + base, mas_index)) & M_WR_CMD_OVERRIDE_RMSK;
  3679. + val = qmode->fixed.areq_prio_wr <<
  3680. + M_WR_CMD_OVERRIDE_AREQPRIO_SHFT;
  3681. + writel_relaxed(((reg_val & ~(M_WR_CMD_OVERRIDE_AREQPRIO_BMSK))
  3682. + | (val & M_WR_CMD_OVERRIDE_AREQPRIO_BMSK)),
  3683. + M_WR_CMD_OVERRIDE_ADDR(base, mas_index));
  3684. + /* Ensure that fixed mode register writes go through
  3685. + * before returning
  3686. + */
  3687. + wmb();
  3688. + break;
  3689. +
  3690. + case BIMC_QOS_MODE_REGULATOR:
  3691. + case BIMC_QOS_MODE_LIMITER:
  3692. + set_qos_prio_rl(M_BKE_HEALTH_3_CONFIG_ADDR(base,
  3693. + mas_index), M_BKE_HEALTH_3_CONFIG_RMSK, 3, qmode);
  3694. + set_qos_prio_rl(M_BKE_HEALTH_2_CONFIG_ADDR(base,
  3695. + mas_index), M_BKE_HEALTH_2_CONFIG_RMSK, 2, qmode);
  3696. + set_qos_prio_rl(M_BKE_HEALTH_1_CONFIG_ADDR(base,
  3697. + mas_index), M_BKE_HEALTH_1_CONFIG_RMSK, 1, qmode);
  3698. + set_qos_prio_rl(M_BKE_HEALTH_0_CONFIG_ADDR(base,
  3699. + mas_index), M_BKE_HEALTH_0_CONFIG_RMSK, 0 , qmode);
  3700. + break;
  3701. + case BIMC_QOS_MODE_BYPASS:
  3702. + default:
  3703. + break;
  3704. + }
  3705. +}
  3706. +
  3707. +static void set_qos_bw_regs(void __iomem *baddr, uint32_t mas_index,
  3708. + int32_t th, int32_t tm, int32_t tl, uint32_t gp,
  3709. + uint32_t gc)
  3710. +{
  3711. + int32_t reg_val, val;
  3712. + int32_t bke_reg_val;
  3713. + int16_t val2;
  3714. +
  3715. + /* Disable BKE before writing to registers as per spec */
  3716. + bke_reg_val = readl_relaxed(M_BKE_EN_ADDR(baddr, mas_index));
  3717. + writel_relaxed((bke_reg_val & ~(M_BKE_EN_EN_BMSK)),
  3718. + M_BKE_EN_ADDR(baddr, mas_index));
  3719. +
  3720. + /* Write values of registers calculated */
  3721. + reg_val = readl_relaxed(M_BKE_GP_ADDR(baddr, mas_index))
  3722. + & M_BKE_GP_RMSK;
  3723. + val = gp << M_BKE_GP_GP_SHFT;
  3724. + writel_relaxed(((reg_val & ~(M_BKE_GP_GP_BMSK)) | (val &
  3725. + M_BKE_GP_GP_BMSK)), M_BKE_GP_ADDR(baddr, mas_index));
  3726. +
  3727. + reg_val = readl_relaxed(M_BKE_GC_ADDR(baddr, mas_index)) &
  3728. + M_BKE_GC_RMSK;
  3729. + val = gc << M_BKE_GC_GC_SHFT;
  3730. + writel_relaxed(((reg_val & ~(M_BKE_GC_GC_BMSK)) | (val &
  3731. + M_BKE_GC_GC_BMSK)), M_BKE_GC_ADDR(baddr, mas_index));
  3732. +
  3733. + reg_val = readl_relaxed(M_BKE_THH_ADDR(baddr, mas_index)) &
  3734. + M_BKE_THH_RMSK;
  3735. + val = th << M_BKE_THH_THRESH_SHFT;
  3736. + writel_relaxed(((reg_val & ~(M_BKE_THH_THRESH_BMSK)) | (val &
  3737. + M_BKE_THH_THRESH_BMSK)), M_BKE_THH_ADDR(baddr, mas_index));
  3738. +
  3739. + reg_val = readl_relaxed(M_BKE_THM_ADDR(baddr, mas_index)) &
  3740. + M_BKE_THM_RMSK;
  3741. + val2 = tm << M_BKE_THM_THRESH_SHFT;
  3742. + writel_relaxed(((reg_val & ~(M_BKE_THM_THRESH_BMSK)) | (val2 &
  3743. + M_BKE_THM_THRESH_BMSK)), M_BKE_THM_ADDR(baddr, mas_index));
  3744. +
  3745. + reg_val = readl_relaxed(M_BKE_THL_ADDR(baddr, mas_index)) &
  3746. + M_BKE_THL_RMSK;
  3747. + val2 = tl << M_BKE_THL_THRESH_SHFT;
  3748. + writel_relaxed(((reg_val & ~(M_BKE_THL_THRESH_BMSK)) |
  3749. + (val2 & M_BKE_THL_THRESH_BMSK)), M_BKE_THL_ADDR(baddr,
  3750. + mas_index));
  3751. +
  3752. + /* Ensure that all bandwidth register writes have completed
  3753. + * before returning
  3754. + */
  3755. + wmb();
  3756. +}
  3757. +
  3758. +static void msm_bus_bimc_set_qos_bw(void __iomem *base, uint32_t qos_freq,
  3759. + uint32_t mas_index, struct msm_bus_bimc_qos_bw *qbw)
  3760. +{
  3761. + uint32_t bke_en;
  3762. +
  3763. + /* Validate QOS Frequency */
  3764. + if (qos_freq == 0) {
  3765. + MSM_BUS_DBG("Zero frequency\n");
  3766. + return;
  3767. + }
  3768. +
  3769. + /* Get enable bit for BKE before programming the period */
  3770. + bke_en = (readl_relaxed(M_BKE_EN_ADDR(base, mas_index)) &
  3771. + M_BKE_EN_EN_BMSK) >> M_BKE_EN_EN_SHFT;
  3772. +
  3773. + /* Only calculate if there's a requested bandwidth and window */
  3774. + if (qbw->bw && qbw->ws) {
  3775. + int64_t th, tm, tl;
  3776. + uint32_t gp, gc;
  3777. + int64_t gp_nominal, gp_required, gp_calc, data, temp;
  3778. + int64_t win = qbw->ws * qos_freq;
  3779. + temp = win;
  3780. + /*
  3781. + * Calculate nominal grant period defined by requested
  3782. + * window size.
  3783. + * Ceil this value to max grant period.
  3784. + */
  3785. + bimc_div(&temp, 1000000);
  3786. + gp_nominal = min_t(uint64_t, MAX_GRANT_PERIOD, temp);
  3787. + /*
  3788. + * Calculate max window size, defined by bw request.
  3789. + * Units: (KHz, MB/s)
  3790. + */
  3791. + gp_calc = MAX_GC * qos_freq * 1000;
  3792. + gp_required = gp_calc;
  3793. + bimc_div(&gp_required, qbw->bw);
  3794. +
  3795. + /* User min of two grant periods */
  3796. + gp = min_t(int64_t, gp_nominal, gp_required);
  3797. +
  3798. + /* Calculate bandwith in grants and ceil. */
  3799. + temp = qbw->bw * gp;
  3800. + data = qos_freq * 1000;
  3801. + bimc_div(&temp, data);
  3802. + gc = min_t(int64_t, MAX_GC, temp);
  3803. +
  3804. + /* Calculate thresholds */
  3805. + th = qbw->bw - qbw->thh;
  3806. + tm = qbw->bw - qbw->thm;
  3807. + tl = qbw->bw - qbw->thl;
  3808. +
  3809. + th = th * gp;
  3810. + bimc_div(&th, data);
  3811. + tm = tm * gp;
  3812. + bimc_div(&tm, data);
  3813. + tl = tl * gp;
  3814. + bimc_div(&tl, data);
  3815. +
  3816. + MSM_BUS_DBG("BIMC: BW: mas_index: %d, th: %llu tm: %llu\n",
  3817. + mas_index, th, tm);
  3818. + MSM_BUS_DBG("BIMC: tl: %llu gp:%u gc: %u bke_en: %u\n",
  3819. + tl, gp, gc, bke_en);
  3820. + set_qos_bw_regs(base, mas_index, th, tm, tl, gp, gc);
  3821. + } else
  3822. + /* Clear bandwidth registers */
  3823. + set_qos_bw_regs(base, mas_index, 0, 0, 0, 0, 0);
  3824. +}
  3825. +
  3826. +static int msm_bus_bimc_allocate_commit_data(struct msm_bus_fabric_registration
  3827. + *fab_pdata, void **cdata, int ctx)
  3828. +{
  3829. + struct msm_bus_bimc_commit **cd = (struct msm_bus_bimc_commit **)cdata;
  3830. + struct msm_bus_bimc_info *binfo =
  3831. + (struct msm_bus_bimc_info *)fab_pdata->hw_data;
  3832. +
  3833. + MSM_BUS_DBG("Allocating BIMC commit data\n");
  3834. + *cd = kzalloc(sizeof(struct msm_bus_bimc_commit), GFP_KERNEL);
  3835. + if (!*cd) {
  3836. + MSM_BUS_DBG("Couldn't alloc mem for cdata\n");
  3837. + return -ENOMEM;
  3838. + }
  3839. +
  3840. + (*cd)->mas = binfo->cdata[ctx].mas;
  3841. + (*cd)->slv = binfo->cdata[ctx].slv;
  3842. +
  3843. + return 0;
  3844. +}
  3845. +
  3846. +static void *msm_bus_bimc_allocate_bimc_data(struct platform_device *pdev,
  3847. + struct msm_bus_fabric_registration *fab_pdata)
  3848. +{
  3849. + struct resource *bimc_mem;
  3850. + struct resource *bimc_io;
  3851. + struct msm_bus_bimc_info *binfo;
  3852. + int i;
  3853. +
  3854. + MSM_BUS_DBG("Allocating BIMC data\n");
  3855. + binfo = kzalloc(sizeof(struct msm_bus_bimc_info), GFP_KERNEL);
  3856. + if (!binfo) {
  3857. + WARN(!binfo, "Couldn't alloc mem for bimc_info\n");
  3858. + return NULL;
  3859. + }
  3860. +
  3861. + binfo->qos_freq = fab_pdata->qos_freq;
  3862. +
  3863. + binfo->params.nmasters = fab_pdata->nmasters;
  3864. + binfo->params.nslaves = fab_pdata->nslaves;
  3865. + binfo->params.bus_id = fab_pdata->id;
  3866. +
  3867. + for (i = 0; i < NUM_CTX; i++) {
  3868. + binfo->cdata[i].mas = kzalloc(sizeof(struct
  3869. + msm_bus_node_hw_info) * fab_pdata->nmasters * 2,
  3870. + GFP_KERNEL);
  3871. + if (!binfo->cdata[i].mas) {
  3872. + MSM_BUS_ERR("Couldn't alloc mem for bimc master hw\n");
  3873. + kfree(binfo);
  3874. + return NULL;
  3875. + }
  3876. +
  3877. + binfo->cdata[i].slv = kzalloc(sizeof(struct
  3878. + msm_bus_node_hw_info) * fab_pdata->nslaves * 2,
  3879. + GFP_KERNEL);
  3880. + if (!binfo->cdata[i].slv) {
  3881. + MSM_BUS_DBG("Couldn't alloc mem for bimc slave hw\n");
  3882. + kfree(binfo->cdata[i].mas);
  3883. + kfree(binfo);
  3884. + return NULL;
  3885. + }
  3886. + }
  3887. +
  3888. + if (fab_pdata->virt) {
  3889. + MSM_BUS_DBG("Don't get memory regions for virtual fabric\n");
  3890. + goto skip_mem;
  3891. + }
  3892. +
  3893. + bimc_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  3894. + if (!bimc_mem) {
  3895. + MSM_BUS_ERR("Cannot get BIMC Base address\n");
  3896. + kfree(binfo);
  3897. + return NULL;
  3898. + }
  3899. +
  3900. + bimc_io = request_mem_region(bimc_mem->start,
  3901. + resource_size(bimc_mem), pdev->name);
  3902. + if (!bimc_io) {
  3903. + MSM_BUS_ERR("BIMC memory unavailable\n");
  3904. + kfree(binfo);
  3905. + return NULL;
  3906. + }
  3907. +
  3908. + binfo->base = ioremap(bimc_mem->start, resource_size(bimc_mem));
  3909. + if (!binfo->base) {
  3910. + MSM_BUS_ERR("IOremap failed for BIMC!\n");
  3911. + release_mem_region(bimc_mem->start, resource_size(bimc_mem));
  3912. + kfree(binfo);
  3913. + return NULL;
  3914. + }
  3915. +
  3916. +skip_mem:
  3917. + fab_pdata->hw_data = (void *)binfo;
  3918. + return (void *)binfo;
  3919. +}
  3920. +
  3921. +static void free_commit_data(void *cdata)
  3922. +{
  3923. + struct msm_bus_bimc_commit *cd = (struct msm_bus_bimc_commit *)cdata;
  3924. +
  3925. + kfree(cd->mas);
  3926. + kfree(cd->slv);
  3927. + kfree(cd);
  3928. +}
  3929. +
  3930. +static void bke_switch(
  3931. + void __iomem *baddr, uint32_t mas_index, bool req, int mode)
  3932. +{
  3933. + uint32_t reg_val, val, cur_val;
  3934. +
  3935. + val = req << M_BKE_EN_EN_SHFT;
  3936. + reg_val = readl_relaxed(M_BKE_EN_ADDR(baddr, mas_index));
  3937. + cur_val = reg_val & M_BKE_EN_RMSK;
  3938. + if (val == cur_val)
  3939. + return;
  3940. +
  3941. + if (!req && mode == BIMC_QOS_MODE_FIXED)
  3942. + set_qos_mode(baddr, mas_index, 1, 1, 1);
  3943. +
  3944. + writel_relaxed(((reg_val & ~(M_BKE_EN_EN_BMSK)) | (val &
  3945. + M_BKE_EN_EN_BMSK)), M_BKE_EN_ADDR(baddr, mas_index));
  3946. + /* Make sure BKE on/off goes through before changing priorities */
  3947. + wmb();
  3948. +
  3949. + if (req)
  3950. + set_qos_mode(baddr, mas_index, 0, 0, 0);
  3951. +}
  3952. +
  3953. +static void bimc_set_static_qos_bw(void __iomem *base, unsigned int qos_freq,
  3954. + int mport, struct msm_bus_bimc_qos_bw *qbw)
  3955. +{
  3956. + int32_t bw_mbps, thh = 0, thm, thl, gc;
  3957. + int32_t gp;
  3958. + u64 temp;
  3959. +
  3960. + if (qos_freq == 0) {
  3961. + MSM_BUS_DBG("No QoS Frequency.\n");
  3962. + return;
  3963. + }
  3964. +
  3965. + if (!(qbw->bw && qbw->gp)) {
  3966. + MSM_BUS_DBG("No QoS Bandwidth or Window size\n");
  3967. + return;
  3968. + }
  3969. +
  3970. + /* Convert bandwidth to MBPS */
  3971. + temp = qbw->bw;
  3972. + bimc_div(&temp, 1000000);
  3973. + bw_mbps = temp;
  3974. +
  3975. + /* Grant period in clock cycles
  3976. + * Grant period from bandwidth structure
  3977. + * is in nano seconds, QoS freq is in KHz.
  3978. + * Divide by 1000 to get clock cycles.
  3979. + */
  3980. + gp = (qos_freq * qbw->gp) / (1000 * NSEC_PER_USEC);
  3981. +
  3982. + /* Grant count = BW in MBps * Grant period
  3983. + * in micro seconds
  3984. + */
  3985. + gc = bw_mbps * (qbw->gp / NSEC_PER_USEC);
  3986. + gc = min(gc, MAX_GC);
  3987. +
  3988. + /* Medium threshold = -((Medium Threshold percentage *
  3989. + * Grant count) / 100)
  3990. + */
  3991. + thm = -((qbw->thmp * gc) / 100);
  3992. + qbw->thm = thm;
  3993. +
  3994. + /* Low threshold = -(Grant count) */
  3995. + thl = -gc;
  3996. + qbw->thl = thl;
  3997. +
  3998. + MSM_BUS_DBG("%s: BKE parameters: gp %d, gc %d, thm %d thl %d thh %d",
  3999. + __func__, gp, gc, thm, thl, thh);
  4000. +
  4001. + trace_bus_bke_params(gc, gp, thl, thm, thl);
  4002. + set_qos_bw_regs(base, mport, thh, thm, thl, gp, gc);
  4003. +}
  4004. +
  4005. +static void msm_bus_bimc_config_master(
  4006. + struct msm_bus_fabric_registration *fab_pdata,
  4007. + struct msm_bus_inode_info *info,
  4008. + uint64_t req_clk, uint64_t req_bw)
  4009. +{
  4010. + int mode, i, ports;
  4011. + struct msm_bus_bimc_info *binfo;
  4012. + uint64_t bw = 0;
  4013. +
  4014. + binfo = (struct msm_bus_bimc_info *)fab_pdata->hw_data;
  4015. + ports = info->node_info->num_mports;
  4016. +
  4017. + /**
  4018. + * Here check the details of dual configuration.
  4019. + * Take actions based on different modes.
  4020. + * Check for threshold if limiter mode, etc.
  4021. + */
  4022. +
  4023. + if (req_clk <= info->node_info->th[0]) {
  4024. + mode = info->node_info->mode;
  4025. + bw = info->node_info->bimc_bw[0];
  4026. + } else if ((info->node_info->num_thresh > 1) &&
  4027. + (req_clk <= info->node_info->th[1])) {
  4028. + mode = info->node_info->mode;
  4029. + bw = info->node_info->bimc_bw[1];
  4030. + } else
  4031. + mode = info->node_info->mode_thresh;
  4032. +
  4033. + switch (mode) {
  4034. + case BIMC_QOS_MODE_BYPASS:
  4035. + case BIMC_QOS_MODE_FIXED:
  4036. + for (i = 0; i < ports; i++)
  4037. + bke_switch(binfo->base, info->node_info->qport[i],
  4038. + BKE_OFF, mode);
  4039. + break;
  4040. + case BIMC_QOS_MODE_REGULATOR:
  4041. + case BIMC_QOS_MODE_LIMITER:
  4042. + for (i = 0; i < ports; i++) {
  4043. + /* If not in fixed mode, update bandwidth */
  4044. + if ((info->node_info->cur_lim_bw != bw)
  4045. + && (mode != BIMC_QOS_MODE_FIXED)) {
  4046. + struct msm_bus_bimc_qos_bw qbw;
  4047. + qbw.ws = info->node_info->ws;
  4048. + qbw.bw = bw;
  4049. + qbw.gp = info->node_info->bimc_gp;
  4050. + qbw.thmp = info->node_info->bimc_thmp;
  4051. + bimc_set_static_qos_bw(binfo->base,
  4052. + binfo->qos_freq,
  4053. + info->node_info->qport[i], &qbw);
  4054. + info->node_info->cur_lim_bw = bw;
  4055. + MSM_BUS_DBG("%s: Qos is %d reqclk %llu bw %llu",
  4056. + __func__, mode, req_clk, bw);
  4057. + }
  4058. + bke_switch(binfo->base, info->node_info->qport[i],
  4059. + BKE_ON, mode);
  4060. + }
  4061. + break;
  4062. + default:
  4063. + break;
  4064. + }
  4065. +}
  4066. +
  4067. +static void msm_bus_bimc_update_bw(struct msm_bus_inode_info *hop,
  4068. + struct msm_bus_inode_info *info,
  4069. + struct msm_bus_fabric_registration *fab_pdata,
  4070. + void *sel_cdata, int *master_tiers,
  4071. + int64_t add_bw)
  4072. +{
  4073. + struct msm_bus_bimc_info *binfo;
  4074. + struct msm_bus_bimc_qos_bw qbw;
  4075. + int i;
  4076. + int64_t bw;
  4077. + int ports = info->node_info->num_mports;
  4078. + struct msm_bus_bimc_commit *sel_cd =
  4079. + (struct msm_bus_bimc_commit *)sel_cdata;
  4080. +
  4081. + MSM_BUS_DBG("BIMC: Update bw for ID %d, with IID: %d: %lld\n",
  4082. + info->node_info->id, info->node_info->priv_id, add_bw);
  4083. +
  4084. + binfo = (struct msm_bus_bimc_info *)fab_pdata->hw_data;
  4085. +
  4086. + if (info->node_info->num_mports == 0) {
  4087. + MSM_BUS_DBG("BIMC: Skip Master BW\n");
  4088. + goto skip_mas_bw;
  4089. + }
  4090. +
  4091. + ports = info->node_info->num_mports;
  4092. + bw = INTERLEAVED_BW(fab_pdata, add_bw, ports);
  4093. +
  4094. + for (i = 0; i < ports; i++) {
  4095. + sel_cd->mas[info->node_info->masterp[i]].bw += bw;
  4096. + sel_cd->mas[info->node_info->masterp[i]].hw_id =
  4097. + info->node_info->mas_hw_id;
  4098. + MSM_BUS_DBG("BIMC: Update mas_bw for ID: %d -> %llu\n",
  4099. + info->node_info->priv_id,
  4100. + sel_cd->mas[info->node_info->masterp[i]].bw);
  4101. + if (info->node_info->hw_sel == MSM_BUS_RPM)
  4102. + sel_cd->mas[info->node_info->masterp[i]].dirty = 1;
  4103. + else {
  4104. + if (!info->node_info->qport) {
  4105. + MSM_BUS_DBG("No qos ports to update!\n");
  4106. + break;
  4107. + }
  4108. + if (!(info->node_info->mode == BIMC_QOS_MODE_REGULATOR)
  4109. + || (info->node_info->mode ==
  4110. + BIMC_QOS_MODE_LIMITER)) {
  4111. + MSM_BUS_DBG("Skip QoS reg programming\n");
  4112. + break;
  4113. + }
  4114. +
  4115. + MSM_BUS_DBG("qport: %d\n", info->node_info->qport[i]);
  4116. + qbw.bw = sel_cd->mas[info->node_info->masterp[i]].bw;
  4117. + qbw.ws = info->node_info->ws;
  4118. + /* Threshold low = 90% of bw */
  4119. + qbw.thl = div_s64((90 * bw), 100);
  4120. + /* Threshold medium = bw */
  4121. + qbw.thm = bw;
  4122. + /* Threshold high = 10% more than bw */
  4123. + qbw.thh = div_s64((110 * bw), 100);
  4124. + /* Check if info is a shared master.
  4125. + * If it is, mark it dirty
  4126. + * If it isn't, then set QOS Bandwidth.
  4127. + * Also if dual-conf is set, don't program bw regs.
  4128. + **/
  4129. + if (!info->node_info->dual_conf &&
  4130. + ((info->node_info->mode == BIMC_QOS_MODE_LIMITER) ||
  4131. + (info->node_info->mode == BIMC_QOS_MODE_REGULATOR)))
  4132. + msm_bus_bimc_set_qos_bw(binfo->base,
  4133. + binfo->qos_freq,
  4134. + info->node_info->qport[i], &qbw);
  4135. + }
  4136. + }
  4137. +
  4138. +skip_mas_bw:
  4139. + ports = hop->node_info->num_sports;
  4140. + MSM_BUS_DBG("BIMC: ID: %d, Sports: %d\n", hop->node_info->priv_id,
  4141. + ports);
  4142. +
  4143. + for (i = 0; i < ports; i++) {
  4144. + sel_cd->slv[hop->node_info->slavep[i]].bw += add_bw;
  4145. + sel_cd->slv[hop->node_info->slavep[i]].hw_id =
  4146. + hop->node_info->slv_hw_id;
  4147. + MSM_BUS_DBG("BIMC: Update slave_bw: ID: %d -> %llu\n",
  4148. + hop->node_info->priv_id,
  4149. + sel_cd->slv[hop->node_info->slavep[i]].bw);
  4150. + MSM_BUS_DBG("BIMC: Update slave_bw: index: %d\n",
  4151. + hop->node_info->slavep[i]);
  4152. + /* Check if hop is a shared slave.
  4153. + * If it is, mark it dirty
  4154. + * If it isn't, then nothing to be done as the
  4155. + * slaves are in bypass mode.
  4156. + **/
  4157. + if (hop->node_info->hw_sel == MSM_BUS_RPM) {
  4158. + MSM_BUS_DBG("Slave dirty: %d, slavep: %d\n",
  4159. + hop->node_info->priv_id,
  4160. + hop->node_info->slavep[i]);
  4161. + sel_cd->slv[hop->node_info->slavep[i]].dirty = 1;
  4162. + }
  4163. + }
  4164. +}
  4165. +
  4166. +static int msm_bus_bimc_commit(struct msm_bus_fabric_registration
  4167. + *fab_pdata, void *hw_data, void **cdata)
  4168. +{
  4169. + MSM_BUS_DBG("\nReached BIMC Commit\n");
  4170. + msm_bus_remote_hw_commit(fab_pdata, hw_data, cdata);
  4171. + return 0;
  4172. +}
  4173. +
  4174. +static void msm_bus_bimc_config_limiter(
  4175. + struct msm_bus_fabric_registration *fab_pdata,
  4176. + struct msm_bus_inode_info *info)
  4177. +{
  4178. + struct msm_bus_bimc_info *binfo;
  4179. + int mode, i, ports;
  4180. +
  4181. + binfo = (struct msm_bus_bimc_info *)fab_pdata->hw_data;
  4182. + ports = info->node_info->num_mports;
  4183. +
  4184. + if (!info->node_info->qport) {
  4185. + MSM_BUS_DBG("No QoS Ports to init\n");
  4186. + return;
  4187. + }
  4188. +
  4189. + if (info->cur_lim_bw)
  4190. + mode = BIMC_QOS_MODE_LIMITER;
  4191. + else
  4192. + mode = info->node_info->mode;
  4193. +
  4194. + switch (mode) {
  4195. + case BIMC_QOS_MODE_BYPASS:
  4196. + case BIMC_QOS_MODE_FIXED:
  4197. + for (i = 0; i < ports; i++)
  4198. + bke_switch(binfo->base, info->node_info->qport[i],
  4199. + BKE_OFF, mode);
  4200. + break;
  4201. + case BIMC_QOS_MODE_REGULATOR:
  4202. + case BIMC_QOS_MODE_LIMITER:
  4203. + if (info->cur_lim_bw != info->cur_prg_bw) {
  4204. + MSM_BUS_DBG("Enabled BKE throttling node %d to %llu\n",
  4205. + info->node_info->id, info->cur_lim_bw);
  4206. + trace_bus_bimc_config_limiter(info->node_info->id,
  4207. + info->cur_lim_bw);
  4208. + for (i = 0; i < ports; i++) {
  4209. + /* If not in fixed mode, update bandwidth */
  4210. + struct msm_bus_bimc_qos_bw qbw;
  4211. +
  4212. + qbw.ws = info->node_info->ws;
  4213. + qbw.bw = info->cur_lim_bw;
  4214. + qbw.gp = info->node_info->bimc_gp;
  4215. + qbw.thmp = info->node_info->bimc_thmp;
  4216. + bimc_set_static_qos_bw(binfo->base,
  4217. + binfo->qos_freq,
  4218. + info->node_info->qport[i], &qbw);
  4219. + bke_switch(binfo->base,
  4220. + info->node_info->qport[i],
  4221. + BKE_ON, mode);
  4222. + info->cur_prg_bw = qbw.bw;
  4223. + }
  4224. + }
  4225. + break;
  4226. + default:
  4227. + break;
  4228. + }
  4229. +}
  4230. +
  4231. +static void bimc_init_mas_reg(struct msm_bus_bimc_info *binfo,
  4232. + struct msm_bus_inode_info *info,
  4233. + struct msm_bus_bimc_qos_mode *qmode, int mode)
  4234. +{
  4235. + int i;
  4236. +
  4237. + switch (mode) {
  4238. + case BIMC_QOS_MODE_FIXED:
  4239. + qmode->fixed.prio_level = info->node_info->prio_lvl;
  4240. + qmode->fixed.areq_prio_rd = info->node_info->prio_rd;
  4241. + qmode->fixed.areq_prio_wr = info->node_info->prio_wr;
  4242. + break;
  4243. + case BIMC_QOS_MODE_LIMITER:
  4244. + qmode->rl.qhealth[0].limit_commands = 1;
  4245. + qmode->rl.qhealth[1].limit_commands = 0;
  4246. + qmode->rl.qhealth[2].limit_commands = 0;
  4247. + qmode->rl.qhealth[3].limit_commands = 0;
  4248. + break;
  4249. + default:
  4250. + break;
  4251. + }
  4252. +
  4253. + if (!info->node_info->qport) {
  4254. + MSM_BUS_DBG("No QoS Ports to init\n");
  4255. + return;
  4256. + }
  4257. +
  4258. + for (i = 0; i < info->node_info->num_mports; i++) {
  4259. + /* If not in bypass mode, update priority */
  4260. + if (mode != BIMC_QOS_MODE_BYPASS) {
  4261. + msm_bus_bimc_set_qos_prio(binfo->base,
  4262. + info->node_info->
  4263. + qport[i], mode, qmode);
  4264. +
  4265. + /* If not in fixed mode, update bandwidth */
  4266. + if (mode != BIMC_QOS_MODE_FIXED) {
  4267. + struct msm_bus_bimc_qos_bw qbw;
  4268. + qbw.ws = info->node_info->ws;
  4269. + qbw.bw = info->node_info->bimc_bw[0];
  4270. + qbw.gp = info->node_info->bimc_gp;
  4271. + qbw.thmp = info->node_info->bimc_thmp;
  4272. + bimc_set_static_qos_bw(binfo->base,
  4273. + binfo->qos_freq,
  4274. + info->node_info->qport[i], &qbw);
  4275. + }
  4276. + }
  4277. +
  4278. + /* set mode */
  4279. + msm_bus_bimc_set_qos_mode(binfo->base,
  4280. + info->node_info->qport[i],
  4281. + mode);
  4282. + }
  4283. +}
  4284. +
  4285. +static void init_health_regs(struct msm_bus_bimc_info *binfo,
  4286. + struct msm_bus_inode_info *info,
  4287. + struct msm_bus_bimc_qos_mode *qmode,
  4288. + int mode)
  4289. +{
  4290. + int i;
  4291. +
  4292. + if (mode == BIMC_QOS_MODE_LIMITER) {
  4293. + qmode->rl.qhealth[0].limit_commands = 1;
  4294. + qmode->rl.qhealth[1].limit_commands = 0;
  4295. + qmode->rl.qhealth[2].limit_commands = 0;
  4296. + qmode->rl.qhealth[3].limit_commands = 0;
  4297. +
  4298. + if (!info->node_info->qport) {
  4299. + MSM_BUS_DBG("No QoS Ports to init\n");
  4300. + return;
  4301. + }
  4302. +
  4303. + for (i = 0; i < info->node_info->num_mports; i++) {
  4304. + /* If not in bypass mode, update priority */
  4305. + if (mode != BIMC_QOS_MODE_BYPASS)
  4306. + msm_bus_bimc_set_qos_prio(binfo->base,
  4307. + info->node_info->qport[i], mode, qmode);
  4308. + }
  4309. + }
  4310. +}
  4311. +
  4312. +
  4313. +static int msm_bus_bimc_mas_init(struct msm_bus_bimc_info *binfo,
  4314. + struct msm_bus_inode_info *info)
  4315. +{
  4316. + struct msm_bus_bimc_qos_mode *qmode;
  4317. + qmode = kzalloc(sizeof(struct msm_bus_bimc_qos_mode),
  4318. + GFP_KERNEL);
  4319. + if (!qmode) {
  4320. + MSM_BUS_WARN("Couldn't alloc prio data for node: %d\n",
  4321. + info->node_info->id);
  4322. + return -ENOMEM;
  4323. + }
  4324. +
  4325. + info->hw_data = (void *)qmode;
  4326. +
  4327. + /**
  4328. + * If the master supports dual configuration,
  4329. + * configure registers for both modes
  4330. + */
  4331. + if (info->node_info->dual_conf)
  4332. + bimc_init_mas_reg(binfo, info, qmode,
  4333. + info->node_info->mode_thresh);
  4334. + else if (info->node_info->nr_lim)
  4335. + init_health_regs(binfo, info, qmode, BIMC_QOS_MODE_LIMITER);
  4336. +
  4337. + bimc_init_mas_reg(binfo, info, qmode, info->node_info->mode);
  4338. + return 0;
  4339. +}
  4340. +
  4341. +static void msm_bus_bimc_node_init(void *hw_data,
  4342. + struct msm_bus_inode_info *info)
  4343. +{
  4344. + struct msm_bus_bimc_info *binfo =
  4345. + (struct msm_bus_bimc_info *)hw_data;
  4346. +
  4347. + if (!IS_SLAVE(info->node_info->priv_id) &&
  4348. + (info->node_info->hw_sel != MSM_BUS_RPM))
  4349. + msm_bus_bimc_mas_init(binfo, info);
  4350. +}
  4351. +
  4352. +static int msm_bus_bimc_port_halt(uint32_t haltid, uint8_t mport)
  4353. +{
  4354. + return 0;
  4355. +}
  4356. +
  4357. +static int msm_bus_bimc_port_unhalt(uint32_t haltid, uint8_t mport)
  4358. +{
  4359. + return 0;
  4360. +}
  4361. +
  4362. +static int msm_bus_bimc_limit_mport(struct msm_bus_node_device_type *info,
  4363. + void __iomem *qos_base, uint32_t qos_off,
  4364. + uint32_t qos_delta, uint32_t qos_freq,
  4365. + bool enable_lim, u64 lim_bw)
  4366. +{
  4367. + int mode;
  4368. + int i;
  4369. +
  4370. + if (ZERO_OR_NULL_PTR(info->node_info->qport)) {
  4371. + MSM_BUS_DBG("No QoS Ports to limit\n");
  4372. + return 0;
  4373. + }
  4374. +
  4375. + if (enable_lim && lim_bw) {
  4376. + mode = BIMC_QOS_MODE_LIMITER;
  4377. +
  4378. + if (!info->node_info->lim_bw) {
  4379. + struct msm_bus_bimc_qos_mode qmode;
  4380. + qmode.rl.qhealth[0].limit_commands = 1;
  4381. + qmode.rl.qhealth[1].limit_commands = 0;
  4382. + qmode.rl.qhealth[2].limit_commands = 0;
  4383. + qmode.rl.qhealth[3].limit_commands = 0;
  4384. +
  4385. + for (i = 0; i < info->node_info->num_qports; i++) {
  4386. + /* If not in bypass mode, update priority */
  4387. + if (mode != BIMC_QOS_MODE_BYPASS)
  4388. + msm_bus_bimc_set_qos_prio(qos_base,
  4389. + info->node_info->qport[i], mode,
  4390. + &qmode);
  4391. + }
  4392. + }
  4393. +
  4394. + for (i = 0; i < info->node_info->num_qports; i++) {
  4395. + struct msm_bus_bimc_qos_bw qbw;
  4396. + /* If not in fixed mode, update bandwidth */
  4397. + if ((info->node_info->lim_bw != lim_bw)) {
  4398. + qbw.ws = info->node_info->qos_params.ws;
  4399. + qbw.bw = lim_bw;
  4400. + qbw.gp = info->node_info->qos_params.gp;
  4401. + qbw.thmp = info->node_info->qos_params.thmp;
  4402. + bimc_set_static_qos_bw(qos_base, qos_freq,
  4403. + info->node_info->qport[i], &qbw);
  4404. + }
  4405. + bke_switch(qos_base, info->node_info->qport[i],
  4406. + BKE_ON, mode);
  4407. + }
  4408. + info->node_info->lim_bw = lim_bw;
  4409. + } else {
  4410. + mode = info->node_info->qos_params.mode;
  4411. + for (i = 0; i < info->node_info->num_qports; i++) {
  4412. + bke_switch(qos_base, info->node_info->qport[i],
  4413. + BKE_OFF, mode);
  4414. + }
  4415. + }
  4416. + info->node_info->qos_params.cur_mode = mode;
  4417. + return 0;
  4418. +}
  4419. +
  4420. +static bool msm_bus_bimc_update_bw_reg(int mode)
  4421. +{
  4422. + bool ret = false;
  4423. +
  4424. + if ((mode == BIMC_QOS_MODE_LIMITER)
  4425. + || (mode == BIMC_QOS_MODE_REGULATOR))
  4426. + ret = true;
  4427. +
  4428. + return ret;
  4429. +}
  4430. +
  4431. +static int msm_bus_bimc_qos_init(struct msm_bus_node_device_type *info,
  4432. + void __iomem *qos_base,
  4433. + uint32_t qos_off, uint32_t qos_delta,
  4434. + uint32_t qos_freq)
  4435. +{
  4436. + int i;
  4437. + struct msm_bus_bimc_qos_mode qmode;
  4438. +
  4439. + switch (info->node_info->qos_params.mode) {
  4440. + case BIMC_QOS_MODE_FIXED:
  4441. + qmode.fixed.prio_level = info->node_info->qos_params.prio_lvl;
  4442. + qmode.fixed.areq_prio_rd = info->node_info->qos_params.prio_rd;
  4443. + qmode.fixed.areq_prio_wr = info->node_info->qos_params.prio_wr;
  4444. + break;
  4445. + case BIMC_QOS_MODE_LIMITER:
  4446. + qmode.rl.qhealth[0].limit_commands = 1;
  4447. + qmode.rl.qhealth[1].limit_commands = 0;
  4448. + qmode.rl.qhealth[2].limit_commands = 0;
  4449. + qmode.rl.qhealth[3].limit_commands = 0;
  4450. + break;
  4451. + default:
  4452. + break;
  4453. + }
  4454. +
  4455. + if (ZERO_OR_NULL_PTR(info->node_info->qport)) {
  4456. + MSM_BUS_DBG("No QoS Ports to init\n");
  4457. + return 0;
  4458. + }
  4459. +
  4460. + for (i = 0; i < info->node_info->num_qports; i++) {
  4461. + /* If not in bypass mode, update priority */
  4462. + if (info->node_info->qos_params.mode != BIMC_QOS_MODE_BYPASS)
  4463. + msm_bus_bimc_set_qos_prio(qos_base, info->node_info->
  4464. + qport[i], info->node_info->qos_params.mode,
  4465. + &qmode);
  4466. +
  4467. + /* set mode */
  4468. + if (info->node_info->qos_params.mode == BIMC_QOS_MODE_LIMITER)
  4469. + bke_switch(qos_base, info->node_info->qport[i],
  4470. + BKE_OFF, BIMC_QOS_MODE_FIXED);
  4471. + else
  4472. + msm_bus_bimc_set_qos_mode(qos_base,
  4473. + info->node_info->qport[i],
  4474. + info->node_info->qos_params.mode);
  4475. + }
  4476. +
  4477. + return 0;
  4478. +}
  4479. +
  4480. +static int msm_bus_bimc_set_bw(struct msm_bus_node_device_type *dev,
  4481. + void __iomem *qos_base, uint32_t qos_off,
  4482. + uint32_t qos_delta, uint32_t qos_freq)
  4483. +{
  4484. + struct msm_bus_bimc_qos_bw qbw;
  4485. + int i;
  4486. + int64_t bw = 0;
  4487. + int ret = 0;
  4488. + struct msm_bus_node_info_type *info = dev->node_info;
  4489. +
  4490. + if (info && info->num_qports &&
  4491. + ((info->qos_params.mode == BIMC_QOS_MODE_LIMITER) ||
  4492. + (info->qos_params.mode == BIMC_QOS_MODE_REGULATOR))) {
  4493. + bw = msm_bus_div64(info->num_qports,
  4494. + dev->node_ab.ab[DUAL_CTX]);
  4495. +
  4496. + for (i = 0; i < info->num_qports; i++) {
  4497. + MSM_BUS_DBG("BIMC: Update mas_bw for ID: %d -> %llu\n",
  4498. + info->id, bw);
  4499. +
  4500. + if (!info->qport) {
  4501. + MSM_BUS_DBG("No qos ports to update!\n");
  4502. + break;
  4503. + }
  4504. +
  4505. + qbw.bw = bw + info->qos_params.bw_buffer;
  4506. + trace_bus_bimc_config_limiter(info->id, bw);
  4507. +
  4508. + /* Default to gp of 5us */
  4509. + qbw.gp = (info->qos_params.gp ?
  4510. + info->qos_params.gp : 5000);
  4511. + /* Default to thmp of 50% */
  4512. + qbw.thmp = (info->qos_params.thmp ?
  4513. + info->qos_params.thmp : 50);
  4514. + /*
  4515. + * If the BW vote is 0 then set the QoS mode to
  4516. + * Fixed.
  4517. + */
  4518. + if (bw) {
  4519. + bimc_set_static_qos_bw(qos_base, qos_freq,
  4520. + info->qport[i], &qbw);
  4521. + bke_switch(qos_base, info->qport[i],
  4522. + BKE_ON, info->qos_params.mode);
  4523. + } else {
  4524. + bke_switch(qos_base, info->qport[i],
  4525. + BKE_OFF, BIMC_QOS_MODE_FIXED);
  4526. + }
  4527. + }
  4528. + }
  4529. + return ret;
  4530. +}
  4531. +
  4532. +int msm_bus_bimc_hw_init(struct msm_bus_fabric_registration *pdata,
  4533. + struct msm_bus_hw_algorithm *hw_algo)
  4534. +{
  4535. + /* Set interleaving to true by default */
  4536. + MSM_BUS_DBG("\nInitializing BIMC...\n");
  4537. + pdata->il_flag = true;
  4538. + hw_algo->allocate_commit_data = msm_bus_bimc_allocate_commit_data;
  4539. + hw_algo->allocate_hw_data = msm_bus_bimc_allocate_bimc_data;
  4540. + hw_algo->node_init = msm_bus_bimc_node_init;
  4541. + hw_algo->free_commit_data = free_commit_data;
  4542. + hw_algo->update_bw = msm_bus_bimc_update_bw;
  4543. + hw_algo->commit = msm_bus_bimc_commit;
  4544. + hw_algo->port_halt = msm_bus_bimc_port_halt;
  4545. + hw_algo->port_unhalt = msm_bus_bimc_port_unhalt;
  4546. + hw_algo->config_master = msm_bus_bimc_config_master;
  4547. + hw_algo->config_limiter = msm_bus_bimc_config_limiter;
  4548. + hw_algo->update_bw_reg = msm_bus_bimc_update_bw_reg;
  4549. + /* BIMC slaves are shared. Slave registers are set through RPM */
  4550. + if (!pdata->ahb)
  4551. + pdata->rpm_enabled = 1;
  4552. + return 0;
  4553. +}
  4554. +
  4555. +int msm_bus_bimc_set_ops(struct msm_bus_node_device_type *bus_dev)
  4556. +{
  4557. + if (!bus_dev)
  4558. + return -ENODEV;
  4559. + else {
  4560. + bus_dev->fabdev->noc_ops.qos_init = msm_bus_bimc_qos_init;
  4561. + bus_dev->fabdev->noc_ops.set_bw = msm_bus_bimc_set_bw;
  4562. + bus_dev->fabdev->noc_ops.limit_mport = msm_bus_bimc_limit_mport;
  4563. + bus_dev->fabdev->noc_ops.update_bw_reg =
  4564. + msm_bus_bimc_update_bw_reg;
  4565. + }
  4566. + return 0;
  4567. +}
  4568. +EXPORT_SYMBOL(msm_bus_bimc_set_ops);
  4569. --- /dev/null
  4570. +++ b/drivers/bus/msm_bus/msm_bus_bimc.h
  4571. @@ -0,0 +1,127 @@
  4572. +/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
  4573. + *
  4574. + * This program is free software; you can redistribute it and/or modify
  4575. + * it under the terms of the GNU General Public License version 2 and
  4576. + * only version 2 as published by the Free Software Foundation.
  4577. + *
  4578. + * This program is distributed in the hope that it will be useful,
  4579. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4580. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4581. + * GNU General Public License for more details.
  4582. + */
  4583. +
  4584. +#ifndef _ARCH_ARM_MACH_MSM_BUS_BIMC_H
  4585. +#define _ARCH_ARM_MACH_MSM_BUS_BIMC_H
  4586. +
  4587. +struct msm_bus_bimc_params {
  4588. + uint32_t bus_id;
  4589. + uint32_t addr_width;
  4590. + uint32_t data_width;
  4591. + uint32_t nmasters;
  4592. + uint32_t nslaves;
  4593. +};
  4594. +
  4595. +struct msm_bus_bimc_commit {
  4596. + struct msm_bus_node_hw_info *mas;
  4597. + struct msm_bus_node_hw_info *slv;
  4598. +};
  4599. +
  4600. +struct msm_bus_bimc_info {
  4601. + void __iomem *base;
  4602. + uint32_t base_addr;
  4603. + uint32_t qos_freq;
  4604. + struct msm_bus_bimc_params params;
  4605. + struct msm_bus_bimc_commit cdata[NUM_CTX];
  4606. +};
  4607. +
  4608. +struct msm_bus_bimc_node {
  4609. + uint32_t conn_mask;
  4610. + uint32_t data_width;
  4611. + uint8_t slv_arb_mode;
  4612. +};
  4613. +
  4614. +enum msm_bus_bimc_arb_mode {
  4615. + BIMC_ARB_MODE_RR = 0,
  4616. + BIMC_ARB_MODE_PRIORITY_RR,
  4617. + BIMC_ARB_MODE_TIERED_RR,
  4618. +};
  4619. +
  4620. +
  4621. +enum msm_bus_bimc_interleave {
  4622. + BIMC_INTERLEAVE_NONE = 0,
  4623. + BIMC_INTERLEAVE_ODD,
  4624. + BIMC_INTERLEAVE_EVEN,
  4625. +};
  4626. +
  4627. +struct msm_bus_bimc_slave_seg {
  4628. + bool enable;
  4629. + uint64_t start_addr;
  4630. + uint64_t seg_size;
  4631. + uint8_t interleave;
  4632. +};
  4633. +
  4634. +enum msm_bus_bimc_qos_mode_type {
  4635. + BIMC_QOS_MODE_FIXED = 0,
  4636. + BIMC_QOS_MODE_LIMITER,
  4637. + BIMC_QOS_MODE_BYPASS,
  4638. + BIMC_QOS_MODE_REGULATOR,
  4639. +};
  4640. +
  4641. +struct msm_bus_bimc_qos_health {
  4642. + bool limit_commands;
  4643. + uint32_t areq_prio;
  4644. + uint32_t prio_level;
  4645. +};
  4646. +
  4647. +struct msm_bus_bimc_mode_fixed {
  4648. + uint32_t prio_level;
  4649. + uint32_t areq_prio_rd;
  4650. + uint32_t areq_prio_wr;
  4651. +};
  4652. +
  4653. +struct msm_bus_bimc_mode_rl {
  4654. + uint8_t qhealthnum;
  4655. + struct msm_bus_bimc_qos_health qhealth[4];
  4656. +};
  4657. +
  4658. +struct msm_bus_bimc_qos_mode {
  4659. + uint8_t mode;
  4660. + struct msm_bus_bimc_mode_fixed fixed;
  4661. + struct msm_bus_bimc_mode_rl rl;
  4662. +};
  4663. +
  4664. +struct msm_bus_bimc_qos_bw {
  4665. + uint64_t bw; /* bw is in Bytes/sec */
  4666. + uint32_t ws; /* Window size in nano seconds*/
  4667. + int64_t thh; /* Threshold high, bytes per second */
  4668. + int64_t thm; /* Threshold medium, bytes per second */
  4669. + int64_t thl; /* Threshold low, bytes per second */
  4670. + u32 gp; /* Grant Period in micro seconds */
  4671. + u32 thmp; /* Threshold medium in percentage */
  4672. +};
  4673. +
  4674. +struct msm_bus_bimc_clk_gate {
  4675. + bool core_clk_gate_en;
  4676. + bool arb_clk_gate_en; /* For arbiter */
  4677. + bool port_clk_gate_en; /* For regs on BIMC core clock */
  4678. +};
  4679. +
  4680. +void msm_bus_bimc_set_slave_seg(struct msm_bus_bimc_info *binfo,
  4681. + uint32_t slv_index, uint32_t seg_index,
  4682. + struct msm_bus_bimc_slave_seg *bsseg);
  4683. +void msm_bus_bimc_set_slave_clk_gate(struct msm_bus_bimc_info *binfo,
  4684. + uint32_t slv_index, struct msm_bus_bimc_clk_gate *bgate);
  4685. +void msm_bus_bimc_set_mas_clk_gate(struct msm_bus_bimc_info *binfo,
  4686. + uint32_t mas_index, struct msm_bus_bimc_clk_gate *bgate);
  4687. +void msm_bus_bimc_arb_en(struct msm_bus_bimc_info *binfo,
  4688. + uint32_t slv_index, bool en);
  4689. +void msm_bus_bimc_get_params(struct msm_bus_bimc_info *binfo,
  4690. + struct msm_bus_bimc_params *params);
  4691. +void msm_bus_bimc_get_mas_params(struct msm_bus_bimc_info *binfo,
  4692. + uint32_t mas_index, struct msm_bus_bimc_node *mparams);
  4693. +void msm_bus_bimc_get_slv_params(struct msm_bus_bimc_info *binfo,
  4694. + uint32_t slv_index, struct msm_bus_bimc_node *sparams);
  4695. +bool msm_bus_bimc_get_arb_en(struct msm_bus_bimc_info *binfo,
  4696. + uint32_t slv_index);
  4697. +
  4698. +#endif /*_ARCH_ARM_MACH_MSM_BUS_BIMC_H*/
  4699. --- /dev/null
  4700. +++ b/drivers/bus/msm_bus/msm_bus_client_api.c
  4701. @@ -0,0 +1,83 @@
  4702. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  4703. + *
  4704. + * This program is free software; you can redistribute it and/or modify
  4705. + * it under the terms of the GNU General Public License version 2 and
  4706. + * only version 2 as published by the Free Software Foundation.
  4707. + *
  4708. + * This program is distributed in the hope that it will be useful,
  4709. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4710. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4711. + * GNU General Public License for more details.
  4712. + */
  4713. +
  4714. +#define pr_fmt(fmt) "AXI: %s(): " fmt, __func__
  4715. +
  4716. +#include <linux/kernel.h>
  4717. +#include <linux/init.h>
  4718. +#include <linux/list.h>
  4719. +#include <linux/module.h>
  4720. +#include <linux/slab.h>
  4721. +#include <linux/mutex.h>
  4722. +#include <linux/radix-tree.h>
  4723. +#include <linux/clk.h>
  4724. +#include "msm-bus.h"
  4725. +#include "msm_bus_core.h"
  4726. +
  4727. +struct msm_bus_arb_ops arb_ops;
  4728. +
  4729. +/**
  4730. + * msm_bus_scale_register_client() - Register the clients with the msm bus
  4731. + * driver
  4732. + * @pdata: Platform data of the client, containing src, dest, ab, ib.
  4733. + * Return non-zero value in case of success, 0 in case of failure.
  4734. + *
  4735. + * Client data contains the vectors specifying arbitrated bandwidth (ab)
  4736. + * and instantaneous bandwidth (ib) requested between a particular
  4737. + * src and dest.
  4738. + */
  4739. +uint32_t msm_bus_scale_register_client(struct msm_bus_scale_pdata *pdata)
  4740. +{
  4741. + if (arb_ops.register_client)
  4742. + return arb_ops.register_client(pdata);
  4743. + else {
  4744. + pr_err("%s: Bus driver not ready.",
  4745. + __func__);
  4746. + return 0;
  4747. + }
  4748. +}
  4749. +EXPORT_SYMBOL(msm_bus_scale_register_client);
  4750. +
  4751. +/**
  4752. + * msm_bus_scale_client_update_request() - Update the request for bandwidth
  4753. + * from a particular client
  4754. + *
  4755. + * cl: Handle to the client
  4756. + * index: Index into the vector, to which the bw and clock values need to be
  4757. + * updated
  4758. + */
  4759. +int msm_bus_scale_client_update_request(uint32_t cl, unsigned int index)
  4760. +{
  4761. + if (arb_ops.update_request)
  4762. + return arb_ops.update_request(cl, index);
  4763. + else {
  4764. + pr_err("%s: Bus driver not ready.",
  4765. + __func__);
  4766. + return -EPROBE_DEFER;
  4767. + }
  4768. +}
  4769. +EXPORT_SYMBOL(msm_bus_scale_client_update_request);
  4770. +
  4771. +/**
  4772. + * msm_bus_scale_unregister_client() - Unregister the client from the bus driver
  4773. + * @cl: Handle to the client
  4774. + */
  4775. +void msm_bus_scale_unregister_client(uint32_t cl)
  4776. +{
  4777. + if (arb_ops.unregister_client)
  4778. + arb_ops.unregister_client(cl);
  4779. + else {
  4780. + pr_err("%s: Bus driver not ready.",
  4781. + __func__);
  4782. + }
  4783. +}
  4784. +EXPORT_SYMBOL(msm_bus_scale_unregister_client);
  4785. --- /dev/null
  4786. +++ b/drivers/bus/msm_bus/msm_bus_core.c
  4787. @@ -0,0 +1,125 @@
  4788. +/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
  4789. + *
  4790. + * This program is free software; you can redistribute it and/or modify
  4791. + * it under the terms of the GNU General Public License version 2 and
  4792. + * only version 2 as published by the Free Software Foundation.
  4793. + *
  4794. + * This program is distributed in the hope that it will be useful,
  4795. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4796. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4797. + * GNU General Public License for more details.
  4798. + */
  4799. +
  4800. +#define pr_fmt(fmt) "AXI: %s(): " fmt, __func__
  4801. +
  4802. +#include <linux/kernel.h>
  4803. +#include <linux/init.h>
  4804. +#include <linux/module.h>
  4805. +#include <linux/slab.h>
  4806. +#include <linux/mutex.h>
  4807. +#include <linux/radix-tree.h>
  4808. +#include <linux/clk.h>
  4809. +#include "msm-bus-board.h"
  4810. +#include "msm-bus.h"
  4811. +#include "msm_bus_core.h"
  4812. +
  4813. +static atomic_t num_fab = ATOMIC_INIT(0);
  4814. +
  4815. +int msm_bus_get_num_fab(void)
  4816. +{
  4817. + return atomic_read(&num_fab);
  4818. +}
  4819. +
  4820. +int msm_bus_device_match(struct device *dev, void *id)
  4821. +{
  4822. + struct msm_bus_fabric_device *fabdev = to_msm_bus_fabric_device(dev);
  4823. +
  4824. + if (!fabdev) {
  4825. + MSM_BUS_WARN("Fabric %p returning 0\n", fabdev);
  4826. + return 0;
  4827. + }
  4828. + return fabdev->id == *(int *)id;
  4829. +}
  4830. +
  4831. +static void msm_bus_release(struct device *device)
  4832. +{
  4833. +}
  4834. +
  4835. +struct bus_type msm_bus_type = {
  4836. + .name = "msm-bus-type",
  4837. +};
  4838. +EXPORT_SYMBOL(msm_bus_type);
  4839. +
  4840. +/**
  4841. + * msm_bus_get_fabric_device() - This function is used to search for
  4842. + * the fabric device on the bus
  4843. + * @fabid: Fabric id
  4844. + * Function returns: Pointer to the fabric device
  4845. + */
  4846. +struct msm_bus_fabric_device *msm_bus_get_fabric_device(int fabid)
  4847. +{
  4848. + struct device *dev;
  4849. + struct msm_bus_fabric_device *fabric;
  4850. + dev = bus_find_device(&msm_bus_type, NULL, (void *)&fabid,
  4851. + msm_bus_device_match);
  4852. + if (!dev)
  4853. + return NULL;
  4854. + fabric = to_msm_bus_fabric_device(dev);
  4855. + return fabric;
  4856. +}
  4857. +
  4858. +/**
  4859. + * msm_bus_fabric_device_register() - Registers a fabric on msm bus
  4860. + * @fabdev: Fabric device to be registered
  4861. + */
  4862. +int msm_bus_fabric_device_register(struct msm_bus_fabric_device *fabdev)
  4863. +{
  4864. + int ret = 0;
  4865. + fabdev->dev.bus = &msm_bus_type;
  4866. + fabdev->dev.release = msm_bus_release;
  4867. + ret = dev_set_name(&fabdev->dev, fabdev->name);
  4868. + if (ret) {
  4869. + MSM_BUS_ERR("error setting dev name\n");
  4870. + goto err;
  4871. + }
  4872. +
  4873. + ret = device_register(&fabdev->dev);
  4874. + if (ret < 0) {
  4875. + MSM_BUS_ERR("error registering device%d %s\n",
  4876. + ret, fabdev->name);
  4877. + goto err;
  4878. + }
  4879. + atomic_inc(&num_fab);
  4880. +err:
  4881. + return ret;
  4882. +}
  4883. +
  4884. +/**
  4885. + * msm_bus_fabric_device_unregister() - Unregisters the fabric
  4886. + * devices from the msm bus
  4887. + */
  4888. +void msm_bus_fabric_device_unregister(struct msm_bus_fabric_device *fabdev)
  4889. +{
  4890. + device_unregister(&fabdev->dev);
  4891. + atomic_dec(&num_fab);
  4892. +}
  4893. +
  4894. +static void __exit msm_bus_exit(void)
  4895. +{
  4896. + bus_unregister(&msm_bus_type);
  4897. +}
  4898. +
  4899. +static int __init msm_bus_init(void)
  4900. +{
  4901. + int retval = 0;
  4902. + retval = bus_register(&msm_bus_type);
  4903. + if (retval)
  4904. + MSM_BUS_ERR("bus_register error! %d\n",
  4905. + retval);
  4906. + return retval;
  4907. +}
  4908. +postcore_initcall(msm_bus_init);
  4909. +module_exit(msm_bus_exit);
  4910. +MODULE_LICENSE("GPL v2");
  4911. +MODULE_VERSION("0.2");
  4912. +MODULE_ALIAS("platform:msm_bus");
  4913. --- /dev/null
  4914. +++ b/drivers/bus/msm_bus/msm_bus_core.h
  4915. @@ -0,0 +1,375 @@
  4916. +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
  4917. + *
  4918. + * This program is free software; you can redistribute it and/or modify
  4919. + * it under the terms of the GNU General Public License version 2 and
  4920. + * only version 2 as published by the Free Software Foundation.
  4921. + *
  4922. + * This program is distributed in the hope that it will be useful,
  4923. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4924. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4925. + * GNU General Public License for more details.
  4926. + */
  4927. +
  4928. +#ifndef _ARCH_ARM_MACH_MSM_BUS_CORE_H
  4929. +#define _ARCH_ARM_MACH_MSM_BUS_CORE_H
  4930. +
  4931. +#include <linux/types.h>
  4932. +#include <linux/device.h>
  4933. +#include <linux/radix-tree.h>
  4934. +#include <linux/platform_device.h>
  4935. +#include "msm-bus-board.h"
  4936. +#include "msm-bus.h"
  4937. +
  4938. +#define MSM_BUS_DBG(msg, ...) \
  4939. + pr_debug(msg, ## __VA_ARGS__)
  4940. +#define MSM_BUS_ERR(msg, ...) \
  4941. + pr_err(msg, ## __VA_ARGS__)
  4942. +#define MSM_BUS_WARN(msg, ...) \
  4943. + pr_warn(msg, ## __VA_ARGS__)
  4944. +#define MSM_FAB_ERR(msg, ...) \
  4945. + dev_err(&fabric->fabdev.dev, msg, ## __VA_ARGS__)
  4946. +
  4947. +#define IS_MASTER_VALID(mas) \
  4948. + (((mas >= MSM_BUS_MASTER_FIRST) && (mas <= MSM_BUS_MASTER_LAST)) \
  4949. + ? 1 : 0)
  4950. +#define IS_SLAVE_VALID(slv) \
  4951. + (((slv >= MSM_BUS_SLAVE_FIRST) && (slv <= MSM_BUS_SLAVE_LAST)) ? 1 : 0)
  4952. +
  4953. +#define INTERLEAVED_BW(fab_pdata, bw, ports) \
  4954. + ((fab_pdata->il_flag) ? ((bw < 0) \
  4955. + ? -msm_bus_div64((ports), (-bw)) : msm_bus_div64((ports), (bw))) : (bw))
  4956. +#define INTERLEAVED_VAL(fab_pdata, n) \
  4957. + ((fab_pdata->il_flag) ? (n) : 1)
  4958. +#define KBTOB(a) (a * 1000ULL)
  4959. +
  4960. +enum msm_bus_dbg_op_type {
  4961. + MSM_BUS_DBG_UNREGISTER = -2,
  4962. + MSM_BUS_DBG_REGISTER,
  4963. + MSM_BUS_DBG_OP = 1,
  4964. +};
  4965. +
  4966. +enum msm_bus_hw_sel {
  4967. + MSM_BUS_RPM = 0,
  4968. + MSM_BUS_NOC,
  4969. + MSM_BUS_BIMC,
  4970. +};
  4971. +
  4972. +struct msm_bus_arb_ops {
  4973. + uint32_t (*register_client)(struct msm_bus_scale_pdata *pdata);
  4974. + int (*update_request)(uint32_t cl, unsigned int index);
  4975. + void (*unregister_client)(uint32_t cl);
  4976. +};
  4977. +
  4978. +enum {
  4979. + SLAVE_NODE,
  4980. + MASTER_NODE,
  4981. + CLK_NODE,
  4982. + NR_LIM_NODE,
  4983. +};
  4984. +
  4985. +
  4986. +extern struct bus_type msm_bus_type;
  4987. +extern struct msm_bus_arb_ops arb_ops;
  4988. +extern void msm_bus_arb_setops_legacy(struct msm_bus_arb_ops *arb_ops);
  4989. +
  4990. +struct msm_bus_node_info {
  4991. + unsigned int id;
  4992. + unsigned int priv_id;
  4993. + unsigned int mas_hw_id;
  4994. + unsigned int slv_hw_id;
  4995. + int gateway;
  4996. + int *masterp;
  4997. + int *qport;
  4998. + int num_mports;
  4999. + int *slavep;
  5000. + int num_sports;
  5001. + int *tier;
  5002. + int num_tiers;
  5003. + int ahb;
  5004. + int hw_sel;
  5005. + const char *slaveclk[NUM_CTX];
  5006. + const char *memclk[NUM_CTX];
  5007. + const char *iface_clk_node;
  5008. + unsigned int buswidth;
  5009. + unsigned int ws;
  5010. + unsigned int mode;
  5011. + unsigned int perm_mode;
  5012. + unsigned int prio_lvl;
  5013. + unsigned int prio_rd;
  5014. + unsigned int prio_wr;
  5015. + unsigned int prio1;
  5016. + unsigned int prio0;
  5017. + unsigned int num_thresh;
  5018. + u64 *th;
  5019. + u64 cur_lim_bw;
  5020. + unsigned int mode_thresh;
  5021. + bool dual_conf;
  5022. + u64 *bimc_bw;
  5023. + bool nr_lim;
  5024. + u32 ff;
  5025. + bool rt_mas;
  5026. + u32 bimc_gp;
  5027. + u32 bimc_thmp;
  5028. + u64 floor_bw;
  5029. + const char *name;
  5030. +};
  5031. +
  5032. +struct path_node {
  5033. + uint64_t clk[NUM_CTX];
  5034. + uint64_t bw[NUM_CTX];
  5035. + uint64_t *sel_clk;
  5036. + uint64_t *sel_bw;
  5037. + int next;
  5038. +};
  5039. +
  5040. +struct msm_bus_link_info {
  5041. + uint64_t clk[NUM_CTX];
  5042. + uint64_t *sel_clk;
  5043. + uint64_t memclk;
  5044. + int64_t bw[NUM_CTX];
  5045. + int64_t *sel_bw;
  5046. + int *tier;
  5047. + int num_tiers;
  5048. +};
  5049. +
  5050. +struct nodeclk {
  5051. + struct clk *clk;
  5052. + uint64_t rate;
  5053. + bool dirty;
  5054. + bool enable;
  5055. +};
  5056. +
  5057. +struct msm_bus_inode_info {
  5058. + struct msm_bus_node_info *node_info;
  5059. + uint64_t max_bw;
  5060. + uint64_t max_clk;
  5061. + uint64_t cur_lim_bw;
  5062. + uint64_t cur_prg_bw;
  5063. + struct msm_bus_link_info link_info;
  5064. + int num_pnodes;
  5065. + struct path_node *pnode;
  5066. + int commit_index;
  5067. + struct nodeclk nodeclk[NUM_CTX];
  5068. + struct nodeclk memclk[NUM_CTX];
  5069. + struct nodeclk iface_clk;
  5070. + void *hw_data;
  5071. +};
  5072. +
  5073. +struct msm_bus_node_hw_info {
  5074. + bool dirty;
  5075. + unsigned int hw_id;
  5076. + uint64_t bw;
  5077. +};
  5078. +
  5079. +struct msm_bus_hw_algorithm {
  5080. + int (*allocate_commit_data)(struct msm_bus_fabric_registration
  5081. + *fab_pdata, void **cdata, int ctx);
  5082. + void *(*allocate_hw_data)(struct platform_device *pdev,
  5083. + struct msm_bus_fabric_registration *fab_pdata);
  5084. + void (*node_init)(void *hw_data, struct msm_bus_inode_info *info);
  5085. + void (*free_commit_data)(void *cdata);
  5086. + void (*update_bw)(struct msm_bus_inode_info *hop,
  5087. + struct msm_bus_inode_info *info,
  5088. + struct msm_bus_fabric_registration *fab_pdata,
  5089. + void *sel_cdata, int *master_tiers,
  5090. + int64_t add_bw);
  5091. + void (*fill_cdata_buffer)(int *curr, char *buf, const int max_size,
  5092. + void *cdata, int nmasters, int nslaves, int ntslaves);
  5093. + int (*commit)(struct msm_bus_fabric_registration
  5094. + *fab_pdata, void *hw_data, void **cdata);
  5095. + int (*port_unhalt)(uint32_t haltid, uint8_t mport);
  5096. + int (*port_halt)(uint32_t haltid, uint8_t mport);
  5097. + void (*config_master)(struct msm_bus_fabric_registration *fab_pdata,
  5098. + struct msm_bus_inode_info *info,
  5099. + uint64_t req_clk, uint64_t req_bw);
  5100. + void (*config_limiter)(struct msm_bus_fabric_registration *fab_pdata,
  5101. + struct msm_bus_inode_info *info);
  5102. + bool (*update_bw_reg)(int mode);
  5103. +};
  5104. +
  5105. +struct msm_bus_fabric_device {
  5106. + int id;
  5107. + const char *name;
  5108. + struct device dev;
  5109. + const struct msm_bus_fab_algorithm *algo;
  5110. + const struct msm_bus_board_algorithm *board_algo;
  5111. + struct msm_bus_hw_algorithm hw_algo;
  5112. + int visited;
  5113. + int num_nr_lim;
  5114. + u64 nr_lim_thresh;
  5115. + u32 eff_fact;
  5116. +};
  5117. +#define to_msm_bus_fabric_device(d) container_of(d, \
  5118. + struct msm_bus_fabric_device, d)
  5119. +
  5120. +struct msm_bus_fabric {
  5121. + struct msm_bus_fabric_device fabdev;
  5122. + int ahb;
  5123. + void *cdata[NUM_CTX];
  5124. + bool arb_dirty;
  5125. + bool clk_dirty;
  5126. + struct radix_tree_root fab_tree;
  5127. + int num_nodes;
  5128. + struct list_head gateways;
  5129. + struct msm_bus_inode_info info;
  5130. + struct msm_bus_fabric_registration *pdata;
  5131. + void *hw_data;
  5132. +};
  5133. +#define to_msm_bus_fabric(d) container_of(d, \
  5134. + struct msm_bus_fabric, d)
  5135. +
  5136. +
  5137. +struct msm_bus_fab_algorithm {
  5138. + int (*update_clks)(struct msm_bus_fabric_device *fabdev,
  5139. + struct msm_bus_inode_info *pme, int index,
  5140. + uint64_t curr_clk, uint64_t req_clk,
  5141. + uint64_t bwsum, int flag, int ctx,
  5142. + unsigned int cl_active_flag);
  5143. + int (*port_halt)(struct msm_bus_fabric_device *fabdev, int portid);
  5144. + int (*port_unhalt)(struct msm_bus_fabric_device *fabdev, int portid);
  5145. + int (*commit)(struct msm_bus_fabric_device *fabdev);
  5146. + struct msm_bus_inode_info *(*find_node)(struct msm_bus_fabric_device
  5147. + *fabdev, int id);
  5148. + struct msm_bus_inode_info *(*find_gw_node)(struct msm_bus_fabric_device
  5149. + *fabdev, int id);
  5150. + struct list_head *(*get_gw_list)(struct msm_bus_fabric_device *fabdev);
  5151. + void (*update_bw)(struct msm_bus_fabric_device *fabdev, struct
  5152. + msm_bus_inode_info * hop, struct msm_bus_inode_info *info,
  5153. + int64_t add_bw, int *master_tiers, int ctx);
  5154. + void (*config_master)(struct msm_bus_fabric_device *fabdev,
  5155. + struct msm_bus_inode_info *info, uint64_t req_clk,
  5156. + uint64_t req_bw);
  5157. + void (*config_limiter)(struct msm_bus_fabric_device *fabdev,
  5158. + struct msm_bus_inode_info *info);
  5159. +};
  5160. +
  5161. +struct msm_bus_board_algorithm {
  5162. + int board_nfab;
  5163. + void (*assign_iids)(struct msm_bus_fabric_registration *fabreg,
  5164. + int fabid);
  5165. + int (*get_iid)(int id);
  5166. +};
  5167. +
  5168. +/**
  5169. + * Used to store the list of fabrics and other info to be
  5170. + * maintained outside the fabric structure.
  5171. + * Used while calculating path, and to find fabric ptrs
  5172. + */
  5173. +struct msm_bus_fabnodeinfo {
  5174. + struct list_head list;
  5175. + struct msm_bus_inode_info *info;
  5176. +};
  5177. +
  5178. +struct msm_bus_client {
  5179. + int id;
  5180. + struct msm_bus_scale_pdata *pdata;
  5181. + int *src_pnode;
  5182. + int curr;
  5183. +};
  5184. +
  5185. +uint64_t msm_bus_div64(unsigned int width, uint64_t bw);
  5186. +int msm_bus_fabric_device_register(struct msm_bus_fabric_device *fabric);
  5187. +void msm_bus_fabric_device_unregister(struct msm_bus_fabric_device *fabric);
  5188. +struct msm_bus_fabric_device *msm_bus_get_fabric_device(int fabid);
  5189. +int msm_bus_get_num_fab(void);
  5190. +
  5191. +
  5192. +int msm_bus_hw_fab_init(struct msm_bus_fabric_registration *pdata,
  5193. + struct msm_bus_hw_algorithm *hw_algo);
  5194. +void msm_bus_board_init(struct msm_bus_fabric_registration *pdata);
  5195. +void msm_bus_board_set_nfab(struct msm_bus_fabric_registration *pdata,
  5196. + int nfab);
  5197. +#if defined(CONFIG_MSM_RPM_SMD)
  5198. +int msm_bus_rpm_hw_init(struct msm_bus_fabric_registration *pdata,
  5199. + struct msm_bus_hw_algorithm *hw_algo);
  5200. +int msm_bus_remote_hw_commit(struct msm_bus_fabric_registration
  5201. + *fab_pdata, void *hw_data, void **cdata);
  5202. +void msm_bus_rpm_fill_cdata_buffer(int *curr, char *buf, const int max_size,
  5203. + void *cdata, int nmasters, int nslaves, int ntslaves);
  5204. +#else
  5205. +static inline int msm_bus_rpm_hw_init(struct msm_bus_fabric_registration *pdata,
  5206. + struct msm_bus_hw_algorithm *hw_algo)
  5207. +{
  5208. + return 0;
  5209. +}
  5210. +static inline int msm_bus_remote_hw_commit(struct msm_bus_fabric_registration
  5211. + *fab_pdata, void *hw_data, void **cdata)
  5212. +{
  5213. + return 0;
  5214. +}
  5215. +static inline void msm_bus_rpm_fill_cdata_buffer(int *curr, char *buf,
  5216. + const int max_size, void *cdata, int nmasters, int nslaves,
  5217. + int ntslaves)
  5218. +{
  5219. +}
  5220. +#endif
  5221. +
  5222. +int msm_bus_noc_hw_init(struct msm_bus_fabric_registration *pdata,
  5223. + struct msm_bus_hw_algorithm *hw_algo);
  5224. +int msm_bus_bimc_hw_init(struct msm_bus_fabric_registration *pdata,
  5225. + struct msm_bus_hw_algorithm *hw_algo);
  5226. +#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_MSM_BUS_SCALING)
  5227. +void msm_bus_dbg_client_data(struct msm_bus_scale_pdata *pdata, int index,
  5228. + uint32_t cl);
  5229. +void msm_bus_dbg_commit_data(const char *fabname, void *cdata,
  5230. + int nmasters, int nslaves, int ntslaves, int op);
  5231. +#else
  5232. +static inline void msm_bus_dbg_client_data(struct msm_bus_scale_pdata *pdata,
  5233. + int index, uint32_t cl)
  5234. +{
  5235. +}
  5236. +static inline void msm_bus_dbg_commit_data(const char *fabname,
  5237. + void *cdata, int nmasters, int nslaves, int ntslaves,
  5238. + int op)
  5239. +{
  5240. +}
  5241. +#endif
  5242. +
  5243. +#ifdef CONFIG_CORESIGHT
  5244. +int msmbus_coresight_init(struct platform_device *pdev);
  5245. +void msmbus_coresight_remove(struct platform_device *pdev);
  5246. +int msmbus_coresight_init_adhoc(struct platform_device *pdev,
  5247. + struct device_node *of_node);
  5248. +void msmbus_coresight_remove_adhoc(struct platform_device *pdev);
  5249. +#else
  5250. +static inline int msmbus_coresight_init(struct platform_device *pdev)
  5251. +{
  5252. + return 0;
  5253. +}
  5254. +
  5255. +static inline void msmbus_coresight_remove(struct platform_device *pdev)
  5256. +{
  5257. +}
  5258. +
  5259. +static inline int msmbus_coresight_init_adhoc(struct platform_device *pdev,
  5260. + struct device_node *of_node)
  5261. +{
  5262. + return 0;
  5263. +}
  5264. +
  5265. +static inline void msmbus_coresight_remove_adhoc(struct platform_device *pdev)
  5266. +{
  5267. +}
  5268. +#endif
  5269. +
  5270. +
  5271. +#ifdef CONFIG_OF
  5272. +void msm_bus_of_get_nfab(struct platform_device *pdev,
  5273. + struct msm_bus_fabric_registration *pdata);
  5274. +struct msm_bus_fabric_registration
  5275. + *msm_bus_of_get_fab_data(struct platform_device *pdev);
  5276. +#else
  5277. +static inline void msm_bus_of_get_nfab(struct platform_device *pdev,
  5278. + struct msm_bus_fabric_registration *pdata)
  5279. +{
  5280. + return;
  5281. +}
  5282. +
  5283. +static inline struct msm_bus_fabric_registration
  5284. + *msm_bus_of_get_fab_data(struct platform_device *pdev)
  5285. +{
  5286. + return NULL;
  5287. +}
  5288. +#endif
  5289. +
  5290. +#endif /*_ARCH_ARM_MACH_MSM_BUS_CORE_H*/
  5291. --- /dev/null
  5292. +++ b/drivers/bus/msm_bus/msm_bus_dbg.c
  5293. @@ -0,0 +1,810 @@
  5294. +/* Copyright (c) 2010-2012, 2014, The Linux Foundation. All rights reserved.
  5295. + *
  5296. + * This program is free software; you can redistribute it and/or modify
  5297. + * it under the terms of the GNU General Public License version 2 and
  5298. + * only version 2 as published by the Free Software Foundation.
  5299. + *
  5300. + * This program is distributed in the hope that it will be useful,
  5301. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  5302. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5303. + * GNU General Public License for more details.
  5304. + *
  5305. + */
  5306. +
  5307. +#define pr_fmt(fmt) "AXI: %s(): " fmt, __func__
  5308. +
  5309. +#include <linux/kernel.h>
  5310. +#include <linux/module.h>
  5311. +#include <linux/seq_file.h>
  5312. +#include <linux/debugfs.h>
  5313. +#include <linux/slab.h>
  5314. +#include <linux/mutex.h>
  5315. +#include <linux/string.h>
  5316. +#include <linux/uaccess.h>
  5317. +#include <linux/hrtimer.h>
  5318. +#include "msm-bus-board.h"
  5319. +#include "msm-bus.h"
  5320. +#include "msm_bus_rules.h"
  5321. +#include "msm_bus_core.h"
  5322. +#include "msm_bus_adhoc.h"
  5323. +
  5324. +#define CREATE_TRACE_POINTS
  5325. +#include <trace/events/trace_msm_bus.h>
  5326. +
  5327. +#define MAX_BUFF_SIZE 4096
  5328. +#define FILL_LIMIT 128
  5329. +
  5330. +static struct dentry *clients;
  5331. +static struct dentry *dir;
  5332. +static DEFINE_MUTEX(msm_bus_dbg_fablist_lock);
  5333. +struct msm_bus_dbg_state {
  5334. + uint32_t cl;
  5335. + uint8_t enable;
  5336. + uint8_t current_index;
  5337. +} clstate;
  5338. +
  5339. +struct msm_bus_cldata {
  5340. + const struct msm_bus_scale_pdata *pdata;
  5341. + int index;
  5342. + uint32_t clid;
  5343. + int size;
  5344. + struct dentry *file;
  5345. + struct list_head list;
  5346. + char buffer[MAX_BUFF_SIZE];
  5347. +};
  5348. +
  5349. +struct msm_bus_fab_list {
  5350. + const char *name;
  5351. + int size;
  5352. + struct dentry *file;
  5353. + struct list_head list;
  5354. + char buffer[MAX_BUFF_SIZE];
  5355. +};
  5356. +
  5357. +static char *rules_buf;
  5358. +
  5359. +LIST_HEAD(fabdata_list);
  5360. +LIST_HEAD(cl_list);
  5361. +
  5362. +/**
  5363. + * The following structures and funtions are used for
  5364. + * the test-client which can be created at run-time.
  5365. + */
  5366. +
  5367. +static struct msm_bus_vectors init_vectors[1];
  5368. +static struct msm_bus_vectors current_vectors[1];
  5369. +static struct msm_bus_vectors requested_vectors[1];
  5370. +
  5371. +static struct msm_bus_paths shell_client_usecases[] = {
  5372. + {
  5373. + .num_paths = ARRAY_SIZE(init_vectors),
  5374. + .vectors = init_vectors,
  5375. + },
  5376. + {
  5377. + .num_paths = ARRAY_SIZE(current_vectors),
  5378. + .vectors = current_vectors,
  5379. + },
  5380. + {
  5381. + .num_paths = ARRAY_SIZE(requested_vectors),
  5382. + .vectors = requested_vectors,
  5383. + },
  5384. +};
  5385. +
  5386. +static struct msm_bus_scale_pdata shell_client = {
  5387. + .usecase = shell_client_usecases,
  5388. + .num_usecases = ARRAY_SIZE(shell_client_usecases),
  5389. + .name = "test-client",
  5390. +};
  5391. +
  5392. +static void msm_bus_dbg_init_vectors(void)
  5393. +{
  5394. + init_vectors[0].src = -1;
  5395. + init_vectors[0].dst = -1;
  5396. + init_vectors[0].ab = 0;
  5397. + init_vectors[0].ib = 0;
  5398. + current_vectors[0].src = -1;
  5399. + current_vectors[0].dst = -1;
  5400. + current_vectors[0].ab = 0;
  5401. + current_vectors[0].ib = 0;
  5402. + requested_vectors[0].src = -1;
  5403. + requested_vectors[0].dst = -1;
  5404. + requested_vectors[0].ab = 0;
  5405. + requested_vectors[0].ib = 0;
  5406. + clstate.enable = 0;
  5407. + clstate.current_index = 0;
  5408. +}
  5409. +
  5410. +static int msm_bus_dbg_update_cl_request(uint32_t cl)
  5411. +{
  5412. + int ret = 0;
  5413. +
  5414. + if (clstate.current_index < 2)
  5415. + clstate.current_index = 2;
  5416. + else {
  5417. + clstate.current_index = 1;
  5418. + current_vectors[0].ab = requested_vectors[0].ab;
  5419. + current_vectors[0].ib = requested_vectors[0].ib;
  5420. + }
  5421. +
  5422. + if (clstate.enable) {
  5423. + MSM_BUS_DBG("Updating request for shell client, index: %d\n",
  5424. + clstate.current_index);
  5425. + ret = msm_bus_scale_client_update_request(clstate.cl,
  5426. + clstate.current_index);
  5427. + } else
  5428. + MSM_BUS_DBG("Enable bit not set. Skipping update request\n");
  5429. +
  5430. + return ret;
  5431. +}
  5432. +
  5433. +static void msm_bus_dbg_unregister_client(uint32_t cl)
  5434. +{
  5435. + MSM_BUS_DBG("Unregistering shell client\n");
  5436. + msm_bus_scale_unregister_client(clstate.cl);
  5437. + clstate.cl = 0;
  5438. +}
  5439. +
  5440. +static uint32_t msm_bus_dbg_register_client(void)
  5441. +{
  5442. + int ret = 0;
  5443. +
  5444. + if (init_vectors[0].src != requested_vectors[0].src) {
  5445. + MSM_BUS_DBG("Shell client master changed. Unregistering\n");
  5446. + msm_bus_dbg_unregister_client(clstate.cl);
  5447. + }
  5448. + if (init_vectors[0].dst != requested_vectors[0].dst) {
  5449. + MSM_BUS_DBG("Shell client slave changed. Unregistering\n");
  5450. + msm_bus_dbg_unregister_client(clstate.cl);
  5451. + }
  5452. +
  5453. + current_vectors[0].src = init_vectors[0].src;
  5454. + requested_vectors[0].src = init_vectors[0].src;
  5455. + current_vectors[0].dst = init_vectors[0].dst;
  5456. + requested_vectors[0].dst = init_vectors[0].dst;
  5457. +
  5458. + if (!clstate.enable) {
  5459. + MSM_BUS_DBG("Enable bit not set, skipping registration: cl "
  5460. + "%d\n", clstate.cl);
  5461. + return 0;
  5462. + }
  5463. +
  5464. + if (clstate.cl) {
  5465. + MSM_BUS_DBG("Client registered, skipping registration\n");
  5466. + return clstate.cl;
  5467. + }
  5468. +
  5469. + MSM_BUS_DBG("Registering shell client\n");
  5470. + ret = msm_bus_scale_register_client(&shell_client);
  5471. + return ret;
  5472. +}
  5473. +
  5474. +static int msm_bus_dbg_mas_get(void *data, u64 *val)
  5475. +{
  5476. + *val = init_vectors[0].src;
  5477. + MSM_BUS_DBG("Get master: %llu\n", *val);
  5478. + return 0;
  5479. +}
  5480. +
  5481. +static int msm_bus_dbg_mas_set(void *data, u64 val)
  5482. +{
  5483. + init_vectors[0].src = val;
  5484. + MSM_BUS_DBG("Set master: %llu\n", val);
  5485. + clstate.cl = msm_bus_dbg_register_client();
  5486. + return 0;
  5487. +}
  5488. +DEFINE_SIMPLE_ATTRIBUTE(shell_client_mas_fops, msm_bus_dbg_mas_get,
  5489. + msm_bus_dbg_mas_set, "%llu\n");
  5490. +
  5491. +static int msm_bus_dbg_slv_get(void *data, u64 *val)
  5492. +{
  5493. + *val = init_vectors[0].dst;
  5494. + MSM_BUS_DBG("Get slave: %llu\n", *val);
  5495. + return 0;
  5496. +}
  5497. +
  5498. +static int msm_bus_dbg_slv_set(void *data, u64 val)
  5499. +{
  5500. + init_vectors[0].dst = val;
  5501. + MSM_BUS_DBG("Set slave: %llu\n", val);
  5502. + clstate.cl = msm_bus_dbg_register_client();
  5503. + return 0;
  5504. +}
  5505. +DEFINE_SIMPLE_ATTRIBUTE(shell_client_slv_fops, msm_bus_dbg_slv_get,
  5506. + msm_bus_dbg_slv_set, "%llu\n");
  5507. +
  5508. +static int msm_bus_dbg_ab_get(void *data, u64 *val)
  5509. +{
  5510. + *val = requested_vectors[0].ab;
  5511. + MSM_BUS_DBG("Get ab: %llu\n", *val);
  5512. + return 0;
  5513. +}
  5514. +
  5515. +static int msm_bus_dbg_ab_set(void *data, u64 val)
  5516. +{
  5517. + requested_vectors[0].ab = val;
  5518. + MSM_BUS_DBG("Set ab: %llu\n", val);
  5519. + return 0;
  5520. +}
  5521. +DEFINE_SIMPLE_ATTRIBUTE(shell_client_ab_fops, msm_bus_dbg_ab_get,
  5522. + msm_bus_dbg_ab_set, "%llu\n");
  5523. +
  5524. +static int msm_bus_dbg_ib_get(void *data, u64 *val)
  5525. +{
  5526. + *val = requested_vectors[0].ib;
  5527. + MSM_BUS_DBG("Get ib: %llu\n", *val);
  5528. + return 0;
  5529. +}
  5530. +
  5531. +static int msm_bus_dbg_ib_set(void *data, u64 val)
  5532. +{
  5533. + requested_vectors[0].ib = val;
  5534. + MSM_BUS_DBG("Set ib: %llu\n", val);
  5535. + return 0;
  5536. +}
  5537. +DEFINE_SIMPLE_ATTRIBUTE(shell_client_ib_fops, msm_bus_dbg_ib_get,
  5538. + msm_bus_dbg_ib_set, "%llu\n");
  5539. +
  5540. +static int msm_bus_dbg_en_get(void *data, u64 *val)
  5541. +{
  5542. + *val = clstate.enable;
  5543. + MSM_BUS_DBG("Get enable: %llu\n", *val);
  5544. + return 0;
  5545. +}
  5546. +
  5547. +static int msm_bus_dbg_en_set(void *data, u64 val)
  5548. +{
  5549. + int ret = 0;
  5550. +
  5551. + clstate.enable = val;
  5552. + if (clstate.enable) {
  5553. + if (!clstate.cl) {
  5554. + MSM_BUS_DBG("client: %u\n", clstate.cl);
  5555. + clstate.cl = msm_bus_dbg_register_client();
  5556. + if (clstate.cl)
  5557. + ret = msm_bus_dbg_update_cl_request(clstate.cl);
  5558. + } else {
  5559. + MSM_BUS_DBG("update request for cl: %u\n", clstate.cl);
  5560. + ret = msm_bus_dbg_update_cl_request(clstate.cl);
  5561. + }
  5562. + }
  5563. +
  5564. + MSM_BUS_DBG("Set enable: %llu\n", val);
  5565. + return ret;
  5566. +}
  5567. +DEFINE_SIMPLE_ATTRIBUTE(shell_client_en_fops, msm_bus_dbg_en_get,
  5568. + msm_bus_dbg_en_set, "%llu\n");
  5569. +
  5570. +/**
  5571. + * The following funtions are used for viewing the client data
  5572. + * and changing the client request at run-time
  5573. + */
  5574. +
  5575. +static ssize_t client_data_read(struct file *file, char __user *buf,
  5576. + size_t count, loff_t *ppos)
  5577. +{
  5578. + int bsize = 0;
  5579. + uint32_t cl = (uint32_t)(uintptr_t)file->private_data;
  5580. + struct msm_bus_cldata *cldata = NULL;
  5581. + int found = 0;
  5582. +
  5583. + list_for_each_entry(cldata, &cl_list, list) {
  5584. + if (cldata->clid == cl) {
  5585. + found = 1;
  5586. + break;
  5587. + }
  5588. + }
  5589. + if (!found)
  5590. + return 0;
  5591. +
  5592. + bsize = cldata->size;
  5593. + return simple_read_from_buffer(buf, count, ppos,
  5594. + cldata->buffer, bsize);
  5595. +}
  5596. +
  5597. +static int client_data_open(struct inode *inode, struct file *file)
  5598. +{
  5599. + file->private_data = inode->i_private;
  5600. + return 0;
  5601. +}
  5602. +
  5603. +static const struct file_operations client_data_fops = {
  5604. + .open = client_data_open,
  5605. + .read = client_data_read,
  5606. +};
  5607. +
  5608. +struct dentry *msm_bus_dbg_create(const char *name, mode_t mode,
  5609. + struct dentry *dent, uint32_t clid)
  5610. +{
  5611. + if (dent == NULL) {
  5612. + MSM_BUS_DBG("debugfs not ready yet\n");
  5613. + return NULL;
  5614. + }
  5615. + return debugfs_create_file(name, mode, dent, (void *)(uintptr_t)clid,
  5616. + &client_data_fops);
  5617. +}
  5618. +
  5619. +#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_MSM_BUS_SCALING)
  5620. +static int msm_bus_dbg_record_client(const struct msm_bus_scale_pdata *pdata,
  5621. + int index, uint32_t clid, struct dentry *file)
  5622. +{
  5623. + struct msm_bus_cldata *cldata;
  5624. +
  5625. + cldata = kmalloc(sizeof(struct msm_bus_cldata), GFP_KERNEL);
  5626. + if (!cldata) {
  5627. + MSM_BUS_DBG("Failed to allocate memory for client data\n");
  5628. + return -ENOMEM;
  5629. + }
  5630. + cldata->pdata = pdata;
  5631. + cldata->index = index;
  5632. + cldata->clid = clid;
  5633. + cldata->file = file;
  5634. + cldata->size = 0;
  5635. + list_add_tail(&cldata->list, &cl_list);
  5636. + return 0;
  5637. +}
  5638. +
  5639. +static void msm_bus_dbg_free_client(uint32_t clid)
  5640. +{
  5641. + struct msm_bus_cldata *cldata = NULL;
  5642. +
  5643. + list_for_each_entry(cldata, &cl_list, list) {
  5644. + if (cldata->clid == clid) {
  5645. + debugfs_remove(cldata->file);
  5646. + list_del(&cldata->list);
  5647. + kfree(cldata);
  5648. + break;
  5649. + }
  5650. + }
  5651. +}
  5652. +
  5653. +static int msm_bus_dbg_fill_cl_buffer(const struct msm_bus_scale_pdata *pdata,
  5654. + int index, uint32_t clid)
  5655. +{
  5656. + int i = 0, j;
  5657. + char *buf = NULL;
  5658. + struct msm_bus_cldata *cldata = NULL;
  5659. + struct timespec ts;
  5660. + int found = 0;
  5661. +
  5662. + list_for_each_entry(cldata, &cl_list, list) {
  5663. + if (cldata->clid == clid) {
  5664. + found = 1;
  5665. + break;
  5666. + }
  5667. + }
  5668. +
  5669. + if (!found)
  5670. + return -ENOENT;
  5671. +
  5672. + if (cldata->file == NULL) {
  5673. + if (pdata->name == NULL) {
  5674. + MSM_BUS_DBG("Client doesn't have a name\n");
  5675. + return -EINVAL;
  5676. + }
  5677. + cldata->file = msm_bus_dbg_create(pdata->name, S_IRUGO,
  5678. + clients, clid);
  5679. + }
  5680. +
  5681. + if (cldata->size < (MAX_BUFF_SIZE - FILL_LIMIT))
  5682. + i = cldata->size;
  5683. + else {
  5684. + i = 0;
  5685. + cldata->size = 0;
  5686. + }
  5687. + buf = cldata->buffer;
  5688. + ts = ktime_to_timespec(ktime_get());
  5689. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "\n%d.%d\n",
  5690. + (int)ts.tv_sec, (int)ts.tv_nsec);
  5691. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "curr : %d\n", index);
  5692. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "masters: ");
  5693. +
  5694. + for (j = 0; j < pdata->usecase->num_paths; j++)
  5695. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "%d ",
  5696. + pdata->usecase[index].vectors[j].src);
  5697. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "\nslaves : ");
  5698. + for (j = 0; j < pdata->usecase->num_paths; j++)
  5699. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "%d ",
  5700. + pdata->usecase[index].vectors[j].dst);
  5701. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "\nab : ");
  5702. + for (j = 0; j < pdata->usecase->num_paths; j++)
  5703. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "%llu ",
  5704. + pdata->usecase[index].vectors[j].ab);
  5705. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "\nib : ");
  5706. + for (j = 0; j < pdata->usecase->num_paths; j++)
  5707. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "%llu ",
  5708. + pdata->usecase[index].vectors[j].ib);
  5709. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "\n");
  5710. +
  5711. + for (j = 0; j < pdata->usecase->num_paths; j++)
  5712. + trace_bus_update_request((int)ts.tv_sec, (int)ts.tv_nsec,
  5713. + pdata->name, index,
  5714. + pdata->usecase[index].vectors[j].src,
  5715. + pdata->usecase[index].vectors[j].dst,
  5716. + pdata->usecase[index].vectors[j].ab,
  5717. + pdata->usecase[index].vectors[j].ib);
  5718. +
  5719. + cldata->size = i;
  5720. + return i;
  5721. +}
  5722. +#endif
  5723. +
  5724. +static int msm_bus_dbg_update_request(struct msm_bus_cldata *cldata, int index)
  5725. +{
  5726. + int ret = 0;
  5727. +
  5728. + if ((index < 0) || (index > cldata->pdata->num_usecases)) {
  5729. + MSM_BUS_DBG("Invalid index!\n");
  5730. + return -EINVAL;
  5731. + }
  5732. + ret = msm_bus_scale_client_update_request(cldata->clid, index);
  5733. + return ret;
  5734. +}
  5735. +
  5736. +static ssize_t msm_bus_dbg_update_request_write(struct file *file,
  5737. + const char __user *ubuf, size_t cnt, loff_t *ppos)
  5738. +{
  5739. + struct msm_bus_cldata *cldata;
  5740. + unsigned long index = 0;
  5741. + int ret = 0;
  5742. + char *chid;
  5743. + char *buf = kmalloc((sizeof(char) * (cnt + 1)), GFP_KERNEL);
  5744. + int found = 0;
  5745. +
  5746. + if (!buf || IS_ERR(buf)) {
  5747. + MSM_BUS_ERR("Memory allocation for buffer failed\n");
  5748. + return -ENOMEM;
  5749. + }
  5750. + if (cnt == 0) {
  5751. + kfree(buf);
  5752. + return 0;
  5753. + }
  5754. + if (copy_from_user(buf, ubuf, cnt)) {
  5755. + kfree(buf);
  5756. + return -EFAULT;
  5757. + }
  5758. + buf[cnt] = '\0';
  5759. + chid = buf;
  5760. + MSM_BUS_DBG("buffer: %s\n size: %zu\n", buf, sizeof(ubuf));
  5761. +
  5762. + list_for_each_entry(cldata, &cl_list, list) {
  5763. + if (strnstr(chid, cldata->pdata->name, cnt)) {
  5764. + found = 1;
  5765. + cldata = cldata;
  5766. + strsep(&chid, " ");
  5767. + if (chid) {
  5768. + ret = kstrtoul(chid, 10, &index);
  5769. + if (ret) {
  5770. + MSM_BUS_DBG("Index conversion"
  5771. + " failed\n");
  5772. + return -EFAULT;
  5773. + }
  5774. + } else {
  5775. + MSM_BUS_DBG("Error parsing input. Index not"
  5776. + " found\n");
  5777. + found = 0;
  5778. + }
  5779. + break;
  5780. + }
  5781. + }
  5782. +
  5783. + if (found)
  5784. + msm_bus_dbg_update_request(cldata, index);
  5785. + kfree(buf);
  5786. + return cnt;
  5787. +}
  5788. +
  5789. +/**
  5790. + * The following funtions are used for viewing the commit data
  5791. + * for each fabric
  5792. + */
  5793. +static ssize_t fabric_data_read(struct file *file, char __user *buf,
  5794. + size_t count, loff_t *ppos)
  5795. +{
  5796. + struct msm_bus_fab_list *fablist = NULL;
  5797. + int bsize = 0;
  5798. + ssize_t ret;
  5799. + const char *name = file->private_data;
  5800. + int found = 0;
  5801. +
  5802. + mutex_lock(&msm_bus_dbg_fablist_lock);
  5803. + list_for_each_entry(fablist, &fabdata_list, list) {
  5804. + if (strcmp(fablist->name, name) == 0) {
  5805. + found = 1;
  5806. + break;
  5807. + }
  5808. + }
  5809. + if (!found)
  5810. + return -ENOENT;
  5811. + bsize = fablist->size;
  5812. + ret = simple_read_from_buffer(buf, count, ppos,
  5813. + fablist->buffer, bsize);
  5814. + mutex_unlock(&msm_bus_dbg_fablist_lock);
  5815. + return ret;
  5816. +}
  5817. +
  5818. +static const struct file_operations fabric_data_fops = {
  5819. + .open = client_data_open,
  5820. + .read = fabric_data_read,
  5821. +};
  5822. +
  5823. +static ssize_t rules_dbg_read(struct file *file, char __user *buf,
  5824. + size_t count, loff_t *ppos)
  5825. +{
  5826. + ssize_t ret;
  5827. + memset(rules_buf, 0, MAX_BUFF_SIZE);
  5828. + print_rules_buf(rules_buf, MAX_BUFF_SIZE);
  5829. + ret = simple_read_from_buffer(buf, count, ppos,
  5830. + rules_buf, MAX_BUFF_SIZE);
  5831. + return ret;
  5832. +}
  5833. +
  5834. +static int rules_dbg_open(struct inode *inode, struct file *file)
  5835. +{
  5836. + file->private_data = inode->i_private;
  5837. + return 0;
  5838. +}
  5839. +
  5840. +static const struct file_operations rules_dbg_fops = {
  5841. + .open = rules_dbg_open,
  5842. + .read = rules_dbg_read,
  5843. +};
  5844. +
  5845. +#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_MSM_BUS_SCALING)
  5846. +static int msm_bus_dbg_record_fabric(const char *fabname, struct dentry *file)
  5847. +{
  5848. + struct msm_bus_fab_list *fablist;
  5849. + int ret = 0;
  5850. +
  5851. + mutex_lock(&msm_bus_dbg_fablist_lock);
  5852. + fablist = kmalloc(sizeof(struct msm_bus_fab_list), GFP_KERNEL);
  5853. + if (!fablist) {
  5854. + MSM_BUS_DBG("Failed to allocate memory for commit data\n");
  5855. + ret = -ENOMEM;
  5856. + goto err;
  5857. + }
  5858. +
  5859. + fablist->name = fabname;
  5860. + fablist->size = 0;
  5861. + list_add_tail(&fablist->list, &fabdata_list);
  5862. +err:
  5863. + mutex_unlock(&msm_bus_dbg_fablist_lock);
  5864. + return ret;
  5865. +}
  5866. +
  5867. +static void msm_bus_dbg_free_fabric(const char *fabname)
  5868. +{
  5869. + struct msm_bus_fab_list *fablist = NULL;
  5870. +
  5871. + mutex_lock(&msm_bus_dbg_fablist_lock);
  5872. + list_for_each_entry(fablist, &fabdata_list, list) {
  5873. + if (strcmp(fablist->name, fabname) == 0) {
  5874. + debugfs_remove(fablist->file);
  5875. + list_del(&fablist->list);
  5876. + kfree(fablist);
  5877. + break;
  5878. + }
  5879. + }
  5880. + mutex_unlock(&msm_bus_dbg_fablist_lock);
  5881. +}
  5882. +
  5883. +static int msm_bus_dbg_fill_fab_buffer(const char *fabname,
  5884. + void *cdata, int nmasters, int nslaves,
  5885. + int ntslaves)
  5886. +{
  5887. + int i;
  5888. + char *buf = NULL;
  5889. + struct msm_bus_fab_list *fablist = NULL;
  5890. + struct timespec ts;
  5891. + int found = 0;
  5892. +
  5893. + mutex_lock(&msm_bus_dbg_fablist_lock);
  5894. + list_for_each_entry(fablist, &fabdata_list, list) {
  5895. + if (strcmp(fablist->name, fabname) == 0) {
  5896. + found = 1;
  5897. + break;
  5898. + }
  5899. + }
  5900. + if (!found)
  5901. + return -ENOENT;
  5902. +
  5903. + if (fablist->file == NULL) {
  5904. + MSM_BUS_DBG("Fabric dbg entry does not exist\n");
  5905. + mutex_unlock(&msm_bus_dbg_fablist_lock);
  5906. + return -EFAULT;
  5907. + }
  5908. +
  5909. + if (fablist->size < MAX_BUFF_SIZE - 256)
  5910. + i = fablist->size;
  5911. + else {
  5912. + i = 0;
  5913. + fablist->size = 0;
  5914. + }
  5915. + buf = fablist->buffer;
  5916. + mutex_unlock(&msm_bus_dbg_fablist_lock);
  5917. + ts = ktime_to_timespec(ktime_get());
  5918. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "\n%d.%d\n",
  5919. + (int)ts.tv_sec, (int)ts.tv_nsec);
  5920. +
  5921. + msm_bus_rpm_fill_cdata_buffer(&i, buf, MAX_BUFF_SIZE, cdata,
  5922. + nmasters, nslaves, ntslaves);
  5923. + i += scnprintf(buf + i, MAX_BUFF_SIZE - i, "\n");
  5924. + mutex_lock(&msm_bus_dbg_fablist_lock);
  5925. + fablist->size = i;
  5926. + mutex_unlock(&msm_bus_dbg_fablist_lock);
  5927. + return 0;
  5928. +}
  5929. +#endif
  5930. +
  5931. +static const struct file_operations msm_bus_dbg_update_request_fops = {
  5932. + .open = client_data_open,
  5933. + .write = msm_bus_dbg_update_request_write,
  5934. +};
  5935. +
  5936. +#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_MSM_BUS_SCALING)
  5937. +/**
  5938. + * msm_bus_dbg_client_data() - Add debug data for clients
  5939. + * @pdata: Platform data of the client
  5940. + * @index: The current index or operation to be performed
  5941. + * @clid: Client handle obtained during registration
  5942. + */
  5943. +void msm_bus_dbg_client_data(struct msm_bus_scale_pdata *pdata, int index,
  5944. + uint32_t clid)
  5945. +{
  5946. + struct dentry *file = NULL;
  5947. +
  5948. + if (index == MSM_BUS_DBG_REGISTER) {
  5949. + msm_bus_dbg_record_client(pdata, index, clid, file);
  5950. + if (!pdata->name) {
  5951. + MSM_BUS_DBG("Cannot create debugfs entry. Null name\n");
  5952. + return;
  5953. + }
  5954. + } else if (index == MSM_BUS_DBG_UNREGISTER) {
  5955. + msm_bus_dbg_free_client(clid);
  5956. + MSM_BUS_DBG("Client %d unregistered\n", clid);
  5957. + } else
  5958. + msm_bus_dbg_fill_cl_buffer(pdata, index, clid);
  5959. +}
  5960. +EXPORT_SYMBOL(msm_bus_dbg_client_data);
  5961. +
  5962. +/**
  5963. + * msm_bus_dbg_commit_data() - Add commit data from fabrics
  5964. + * @fabname: Fabric name specified in platform data
  5965. + * @cdata: Commit Data
  5966. + * @nmasters: Number of masters attached to fabric
  5967. + * @nslaves: Number of slaves attached to fabric
  5968. + * @ntslaves: Number of tiered slaves attached to fabric
  5969. + * @op: Operation to be performed
  5970. + */
  5971. +void msm_bus_dbg_commit_data(const char *fabname, void *cdata,
  5972. + int nmasters, int nslaves, int ntslaves, int op)
  5973. +{
  5974. + struct dentry *file = NULL;
  5975. +
  5976. + if (op == MSM_BUS_DBG_REGISTER)
  5977. + msm_bus_dbg_record_fabric(fabname, file);
  5978. + else if (op == MSM_BUS_DBG_UNREGISTER)
  5979. + msm_bus_dbg_free_fabric(fabname);
  5980. + else
  5981. + msm_bus_dbg_fill_fab_buffer(fabname, cdata, nmasters,
  5982. + nslaves, ntslaves);
  5983. +}
  5984. +EXPORT_SYMBOL(msm_bus_dbg_commit_data);
  5985. +#endif
  5986. +
  5987. +static int __init msm_bus_debugfs_init(void)
  5988. +{
  5989. + struct dentry *commit, *shell_client, *rules_dbg;
  5990. + struct msm_bus_fab_list *fablist;
  5991. + struct msm_bus_cldata *cldata = NULL;
  5992. + uint64_t val = 0;
  5993. +
  5994. + dir = debugfs_create_dir("msm-bus-dbg", NULL);
  5995. + if ((!dir) || IS_ERR(dir)) {
  5996. + MSM_BUS_ERR("Couldn't create msm-bus-dbg\n");
  5997. + goto err;
  5998. + }
  5999. +
  6000. + clients = debugfs_create_dir("client-data", dir);
  6001. + if ((!dir) || IS_ERR(dir)) {
  6002. + MSM_BUS_ERR("Couldn't create clients\n");
  6003. + goto err;
  6004. + }
  6005. +
  6006. + shell_client = debugfs_create_dir("shell-client", dir);
  6007. + if ((!dir) || IS_ERR(dir)) {
  6008. + MSM_BUS_ERR("Couldn't create clients\n");
  6009. + goto err;
  6010. + }
  6011. +
  6012. + commit = debugfs_create_dir("commit-data", dir);
  6013. + if ((!dir) || IS_ERR(dir)) {
  6014. + MSM_BUS_ERR("Couldn't create commit\n");
  6015. + goto err;
  6016. + }
  6017. +
  6018. + rules_dbg = debugfs_create_dir("rules-dbg", dir);
  6019. + if ((!rules_dbg) || IS_ERR(rules_dbg)) {
  6020. + MSM_BUS_ERR("Couldn't create rules-dbg\n");
  6021. + goto err;
  6022. + }
  6023. +
  6024. + if (debugfs_create_file("print_rules", S_IRUGO | S_IWUSR,
  6025. + rules_dbg, &val, &rules_dbg_fops) == NULL)
  6026. + goto err;
  6027. +
  6028. + if (debugfs_create_file("update_request", S_IRUGO | S_IWUSR,
  6029. + shell_client, &val, &shell_client_en_fops) == NULL)
  6030. + goto err;
  6031. + if (debugfs_create_file("ib", S_IRUGO | S_IWUSR, shell_client, &val,
  6032. + &shell_client_ib_fops) == NULL)
  6033. + goto err;
  6034. + if (debugfs_create_file("ab", S_IRUGO | S_IWUSR, shell_client, &val,
  6035. + &shell_client_ab_fops) == NULL)
  6036. + goto err;
  6037. + if (debugfs_create_file("slv", S_IRUGO | S_IWUSR, shell_client,
  6038. + &val, &shell_client_slv_fops) == NULL)
  6039. + goto err;
  6040. + if (debugfs_create_file("mas", S_IRUGO | S_IWUSR, shell_client,
  6041. + &val, &shell_client_mas_fops) == NULL)
  6042. + goto err;
  6043. + if (debugfs_create_file("update-request", S_IRUGO | S_IWUSR,
  6044. + clients, NULL, &msm_bus_dbg_update_request_fops) == NULL)
  6045. + goto err;
  6046. +
  6047. + rules_buf = kzalloc(MAX_BUFF_SIZE, GFP_KERNEL);
  6048. + if (!rules_buf) {
  6049. + MSM_BUS_ERR("Failed to alloc rules_buf");
  6050. + goto err;
  6051. + }
  6052. +
  6053. + list_for_each_entry(cldata, &cl_list, list) {
  6054. + if (cldata->pdata->name == NULL) {
  6055. + MSM_BUS_DBG("Client name not found\n");
  6056. + continue;
  6057. + }
  6058. + cldata->file = msm_bus_dbg_create(cldata->
  6059. + pdata->name, S_IRUGO, clients, cldata->clid);
  6060. + }
  6061. +
  6062. + mutex_lock(&msm_bus_dbg_fablist_lock);
  6063. + list_for_each_entry(fablist, &fabdata_list, list) {
  6064. + fablist->file = debugfs_create_file(fablist->name, S_IRUGO,
  6065. + commit, (void *)fablist->name, &fabric_data_fops);
  6066. + if (fablist->file == NULL) {
  6067. + MSM_BUS_DBG("Cannot create files for commit data\n");
  6068. + kfree(rules_buf);
  6069. + goto err;
  6070. + }
  6071. + }
  6072. + mutex_unlock(&msm_bus_dbg_fablist_lock);
  6073. +
  6074. + msm_bus_dbg_init_vectors();
  6075. + return 0;
  6076. +err:
  6077. + debugfs_remove_recursive(dir);
  6078. + return -ENODEV;
  6079. +}
  6080. +late_initcall(msm_bus_debugfs_init);
  6081. +
  6082. +static void __exit msm_bus_dbg_teardown(void)
  6083. +{
  6084. + struct msm_bus_fab_list *fablist = NULL, *fablist_temp;
  6085. + struct msm_bus_cldata *cldata = NULL, *cldata_temp;
  6086. +
  6087. + debugfs_remove_recursive(dir);
  6088. + list_for_each_entry_safe(cldata, cldata_temp, &cl_list, list) {
  6089. + list_del(&cldata->list);
  6090. + kfree(cldata);
  6091. + }
  6092. + mutex_lock(&msm_bus_dbg_fablist_lock);
  6093. + list_for_each_entry_safe(fablist, fablist_temp, &fabdata_list, list) {
  6094. + list_del(&fablist->list);
  6095. + kfree(fablist);
  6096. + }
  6097. + kfree(rules_buf);
  6098. + mutex_unlock(&msm_bus_dbg_fablist_lock);
  6099. +}
  6100. +module_exit(msm_bus_dbg_teardown);
  6101. +MODULE_DESCRIPTION("Debugfs for msm bus scaling client");
  6102. +MODULE_LICENSE("GPL v2");
  6103. +MODULE_AUTHOR("Gagan Mac <[email protected]>");
  6104. --- /dev/null
  6105. +++ b/drivers/bus/msm_bus/msm_bus_fabric_adhoc.c
  6106. @@ -0,0 +1,1281 @@
  6107. +/* Copyright (c) 2014, Linux Foundation. All rights reserved.
  6108. + *
  6109. + * This program is free software; you can redistribute it and/or modify
  6110. + * it under the terms of the GNU General Public License version 2 and
  6111. + * only version 2 as published by the Free Software Foundation.
  6112. + *
  6113. + * This program is distributed in the hope that it will be useful,
  6114. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6115. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6116. + * GNU General Public License for more details.
  6117. + */
  6118. +
  6119. +#include <linux/clk.h>
  6120. +#include <linux/device.h>
  6121. +#include <linux/init.h>
  6122. +#include <linux/io.h>
  6123. +#include <linux/kernel.h>
  6124. +#include <linux/module.h>
  6125. +#include <linux/slab.h>
  6126. +#include "rpm-smd.h"
  6127. +#include "msm_bus_core.h"
  6128. +#include "msm_bus_adhoc.h"
  6129. +#include "msm_bus_noc.h"
  6130. +#include "msm_bus_bimc.h"
  6131. +
  6132. +ssize_t vrail_show(struct device *dev, struct device_attribute *attr,
  6133. + char *buf)
  6134. +{
  6135. + struct msm_bus_node_info_type *node_info = NULL;
  6136. + struct msm_bus_node_device_type *bus_node = NULL;
  6137. +
  6138. + bus_node = dev->platform_data;
  6139. + if (!bus_node)
  6140. + return -EINVAL;
  6141. + node_info = bus_node->node_info;
  6142. +
  6143. + return snprintf(buf, PAGE_SIZE, "%u", node_info->vrail_comp);
  6144. +}
  6145. +
  6146. +ssize_t vrail_store(struct device *dev, struct device_attribute *attr,
  6147. + const char *buf, size_t count)
  6148. +{
  6149. + struct msm_bus_node_info_type *node_info = NULL;
  6150. + struct msm_bus_node_device_type *bus_node = NULL;
  6151. + int ret = 0;
  6152. +
  6153. + bus_node = dev->platform_data;
  6154. + if (!bus_node)
  6155. + return -EINVAL;
  6156. + node_info = bus_node->node_info;
  6157. +
  6158. + ret = sscanf(buf, "%u", &node_info->vrail_comp);
  6159. + if (ret != 1)
  6160. + return -EINVAL;
  6161. + return count;
  6162. +}
  6163. +
  6164. +DEVICE_ATTR(vrail, 0600, vrail_show, vrail_store);
  6165. +
  6166. +struct static_rules_type {
  6167. + int num_rules;
  6168. + struct bus_rule_type *rules;
  6169. +};
  6170. +
  6171. +static struct static_rules_type static_rules;
  6172. +
  6173. +static int enable_nodeclk(struct nodeclk *nclk)
  6174. +{
  6175. + int ret = 0;
  6176. +
  6177. + if (!nclk->enable) {
  6178. + ret = clk_prepare_enable(nclk->clk);
  6179. +
  6180. + if (ret) {
  6181. + MSM_BUS_ERR("%s: failed to enable clk ", __func__);
  6182. + nclk->enable = false;
  6183. + } else
  6184. + nclk->enable = true;
  6185. + }
  6186. + return ret;
  6187. +}
  6188. +
  6189. +static int disable_nodeclk(struct nodeclk *nclk)
  6190. +{
  6191. + int ret = 0;
  6192. +
  6193. + if (nclk->enable) {
  6194. + clk_disable_unprepare(nclk->clk);
  6195. + nclk->enable = false;
  6196. + }
  6197. + return ret;
  6198. +}
  6199. +
  6200. +static int setrate_nodeclk(struct nodeclk *nclk, long rate)
  6201. +{
  6202. + int ret = 0;
  6203. +
  6204. + ret = clk_set_rate(nclk->clk, rate);
  6205. +
  6206. + if (ret)
  6207. + MSM_BUS_ERR("%s: failed to setrate clk", __func__);
  6208. + return ret;
  6209. +}
  6210. +
  6211. +static int msm_bus_agg_fab_clks(struct device *bus_dev, void *data)
  6212. +{
  6213. + struct msm_bus_node_device_type *node = NULL;
  6214. + int ret = 0;
  6215. + int ctx = *(int *)data;
  6216. +
  6217. + if (ctx >= NUM_CTX) {
  6218. + MSM_BUS_ERR("%s: Invalid Context %d", __func__, ctx);
  6219. + goto exit_agg_fab_clks;
  6220. + }
  6221. +
  6222. + node = bus_dev->platform_data;
  6223. + if (!node) {
  6224. + MSM_BUS_ERR("%s: Can't get device info", __func__);
  6225. + goto exit_agg_fab_clks;
  6226. + }
  6227. +
  6228. + if (!node->node_info->is_fab_dev) {
  6229. + struct msm_bus_node_device_type *bus_dev = NULL;
  6230. +
  6231. + bus_dev = node->node_info->bus_device->platform_data;
  6232. +
  6233. + if (node->cur_clk_hz[ctx] >= bus_dev->cur_clk_hz[ctx])
  6234. + bus_dev->cur_clk_hz[ctx] = node->cur_clk_hz[ctx];
  6235. + }
  6236. +
  6237. +exit_agg_fab_clks:
  6238. + return ret;
  6239. +}
  6240. +
  6241. +static int msm_bus_reset_fab_clks(struct device *bus_dev, void *data)
  6242. +{
  6243. + struct msm_bus_node_device_type *node = NULL;
  6244. + int ret = 0;
  6245. + int ctx = *(int *)data;
  6246. +
  6247. + if (ctx >= NUM_CTX) {
  6248. + MSM_BUS_ERR("%s: Invalid Context %d", __func__, ctx);
  6249. + goto exit_reset_fab_clks;
  6250. + }
  6251. +
  6252. + node = bus_dev->platform_data;
  6253. + if (!node) {
  6254. + MSM_BUS_ERR("%s: Can't get device info", __func__);
  6255. + goto exit_reset_fab_clks;
  6256. + }
  6257. +
  6258. + if (node->node_info->is_fab_dev) {
  6259. + node->cur_clk_hz[ctx] = 0;
  6260. + MSM_BUS_DBG("Resetting for node %d", node->node_info->id);
  6261. + }
  6262. +exit_reset_fab_clks:
  6263. + return ret;
  6264. +}
  6265. +
  6266. +
  6267. +static int send_rpm_msg(struct device *device)
  6268. +{
  6269. + int ret = 0;
  6270. + int ctx;
  6271. + int rsc_type;
  6272. + struct msm_bus_node_device_type *ndev =
  6273. + device->platform_data;
  6274. + struct msm_rpm_kvp rpm_kvp;
  6275. +
  6276. + if (!ndev) {
  6277. + MSM_BUS_ERR("%s: Error getting node info.", __func__);
  6278. + ret = -ENODEV;
  6279. + goto exit_send_rpm_msg;
  6280. + }
  6281. +
  6282. + rpm_kvp.length = sizeof(uint64_t);
  6283. + rpm_kvp.key = RPM_MASTER_FIELD_BW;
  6284. +
  6285. + for (ctx = MSM_RPM_CTX_ACTIVE_SET; ctx <= MSM_RPM_CTX_SLEEP_SET;
  6286. + ctx++) {
  6287. + if (ctx == MSM_RPM_CTX_ACTIVE_SET)
  6288. + rpm_kvp.data =
  6289. + (uint8_t *)&ndev->node_ab.ab[MSM_RPM_CTX_ACTIVE_SET];
  6290. + else {
  6291. + rpm_kvp.data =
  6292. + (uint8_t *) &ndev->node_ab.ab[MSM_RPM_CTX_SLEEP_SET];
  6293. + }
  6294. +
  6295. + if (ndev->node_info->mas_rpm_id != -1) {
  6296. + rsc_type = RPM_BUS_MASTER_REQ;
  6297. + ret = msm_rpm_send_message(ctx, rsc_type,
  6298. + ndev->node_info->mas_rpm_id, &rpm_kvp, 1);
  6299. + if (ret) {
  6300. + MSM_BUS_ERR("%s: Failed to send RPM message:",
  6301. + __func__);
  6302. + MSM_BUS_ERR("%s:Node Id %d RPM id %d",
  6303. + __func__, ndev->node_info->id,
  6304. + ndev->node_info->mas_rpm_id);
  6305. + goto exit_send_rpm_msg;
  6306. + }
  6307. + }
  6308. +
  6309. + if (ndev->node_info->slv_rpm_id != -1) {
  6310. + rsc_type = RPM_BUS_SLAVE_REQ;
  6311. + ret = msm_rpm_send_message(ctx, rsc_type,
  6312. + ndev->node_info->slv_rpm_id, &rpm_kvp, 1);
  6313. + if (ret) {
  6314. + MSM_BUS_ERR("%s: Failed to send RPM message:",
  6315. + __func__);
  6316. + MSM_BUS_ERR("%s: Node Id %d RPM id %d",
  6317. + __func__, ndev->node_info->id,
  6318. + ndev->node_info->slv_rpm_id);
  6319. + goto exit_send_rpm_msg;
  6320. + }
  6321. + }
  6322. + }
  6323. +exit_send_rpm_msg:
  6324. + return ret;
  6325. +}
  6326. +
  6327. +static int flush_bw_data(struct device *node_device, int ctx)
  6328. +{
  6329. + struct msm_bus_node_device_type *node_info;
  6330. + int ret = 0;
  6331. +
  6332. + node_info = node_device->platform_data;
  6333. + if (!node_info) {
  6334. + MSM_BUS_ERR("%s: Unable to find bus device for device",
  6335. + __func__);
  6336. + ret = -ENODEV;
  6337. + goto exit_flush_bw_data;
  6338. + }
  6339. +
  6340. + if (node_info->node_ab.dirty) {
  6341. + if (node_info->ap_owned) {
  6342. + struct msm_bus_node_device_type *bus_device =
  6343. + node_info->node_info->bus_device->platform_data;
  6344. + struct msm_bus_fab_device_type *fabdev =
  6345. + bus_device->fabdev;
  6346. +
  6347. + if (fabdev && fabdev->noc_ops.update_bw_reg &&
  6348. + fabdev->noc_ops.update_bw_reg
  6349. + (node_info->node_info->qos_params.mode))
  6350. + ret = fabdev->noc_ops.set_bw(node_info,
  6351. + fabdev->qos_base,
  6352. + fabdev->base_offset,
  6353. + fabdev->qos_off,
  6354. + fabdev->qos_freq);
  6355. + } else {
  6356. + ret = send_rpm_msg(node_device);
  6357. +
  6358. + if (ret)
  6359. + MSM_BUS_ERR("%s: Failed to send RPM msg for%d",
  6360. + __func__, node_info->node_info->id);
  6361. + }
  6362. + node_info->node_ab.dirty = false;
  6363. + }
  6364. +
  6365. +exit_flush_bw_data:
  6366. + return ret;
  6367. +
  6368. +}
  6369. +
  6370. +static int flush_clk_data(struct device *node_device, int ctx)
  6371. +{
  6372. + struct msm_bus_node_device_type *node;
  6373. + struct nodeclk *nodeclk = NULL;
  6374. + int ret = 0;
  6375. +
  6376. + node = node_device->platform_data;
  6377. + if (!node) {
  6378. + MSM_BUS_ERR("Unable to find bus device");
  6379. + ret = -ENODEV;
  6380. + goto exit_flush_clk_data;
  6381. + }
  6382. +
  6383. + nodeclk = &node->clk[ctx];
  6384. + if (node->node_info->is_fab_dev) {
  6385. + if (nodeclk->rate != node->cur_clk_hz[ctx]) {
  6386. + nodeclk->rate = node->cur_clk_hz[ctx];
  6387. + nodeclk->dirty = true;
  6388. + }
  6389. + }
  6390. +
  6391. + if (nodeclk && nodeclk->clk && nodeclk->dirty) {
  6392. + long rounded_rate;
  6393. +
  6394. + if (nodeclk->rate) {
  6395. + rounded_rate = clk_round_rate(nodeclk->clk,
  6396. + nodeclk->rate);
  6397. + ret = setrate_nodeclk(nodeclk, rounded_rate);
  6398. +
  6399. + if (ret) {
  6400. + MSM_BUS_ERR("%s: Failed to set_rate %lu for %d",
  6401. + __func__, rounded_rate,
  6402. + node->node_info->id);
  6403. + ret = -ENODEV;
  6404. + goto exit_flush_clk_data;
  6405. + }
  6406. +
  6407. + ret = enable_nodeclk(nodeclk);
  6408. + } else
  6409. + ret = disable_nodeclk(nodeclk);
  6410. +
  6411. + if (ret) {
  6412. + MSM_BUS_ERR("%s: Failed to enable for %d", __func__,
  6413. + node->node_info->id);
  6414. + ret = -ENODEV;
  6415. + goto exit_flush_clk_data;
  6416. + }
  6417. + MSM_BUS_DBG("%s: Updated %d clk to %llu", __func__,
  6418. + node->node_info->id, nodeclk->rate);
  6419. +
  6420. + }
  6421. +exit_flush_clk_data:
  6422. + /* Reset the aggregated clock rate for fab devices*/
  6423. + if (node && node->node_info->is_fab_dev)
  6424. + node->cur_clk_hz[ctx] = 0;
  6425. +
  6426. + if (nodeclk)
  6427. + nodeclk->dirty = 0;
  6428. + return ret;
  6429. +}
  6430. +
  6431. +int msm_bus_commit_data(int *dirty_nodes, int ctx, int num_dirty)
  6432. +{
  6433. + int ret = 0;
  6434. + int i = 0;
  6435. +
  6436. + /* Aggregate the bus clocks */
  6437. + bus_for_each_dev(&msm_bus_type, NULL, (void *)&ctx,
  6438. + msm_bus_agg_fab_clks);
  6439. +
  6440. + for (i = 0; i < num_dirty; i++) {
  6441. + struct device *node_device =
  6442. + bus_find_device(&msm_bus_type, NULL,
  6443. + (void *)&dirty_nodes[i],
  6444. + msm_bus_device_match_adhoc);
  6445. +
  6446. + if (!node_device) {
  6447. + MSM_BUS_ERR("Can't find device for %d", dirty_nodes[i]);
  6448. + continue;
  6449. + }
  6450. +
  6451. + ret = flush_bw_data(node_device, ctx);
  6452. + if (ret)
  6453. + MSM_BUS_ERR("%s: Error flushing bw data for node %d",
  6454. + __func__, dirty_nodes[i]);
  6455. +
  6456. + ret = flush_clk_data(node_device, ctx);
  6457. + if (ret)
  6458. + MSM_BUS_ERR("%s: Error flushing clk data for node %d",
  6459. + __func__, dirty_nodes[i]);
  6460. + }
  6461. + kfree(dirty_nodes);
  6462. + /* Aggregate the bus clocks */
  6463. + bus_for_each_dev(&msm_bus_type, NULL, (void *)&ctx,
  6464. + msm_bus_reset_fab_clks);
  6465. + return ret;
  6466. +}
  6467. +
  6468. +void *msm_bus_realloc_devmem(struct device *dev, void *p, size_t old_size,
  6469. + size_t new_size, gfp_t flags)
  6470. +{
  6471. + void *ret;
  6472. + size_t copy_size = old_size;
  6473. +
  6474. + if (!new_size) {
  6475. + devm_kfree(dev, p);
  6476. + return ZERO_SIZE_PTR;
  6477. + }
  6478. +
  6479. + if (new_size < old_size)
  6480. + copy_size = new_size;
  6481. +
  6482. + ret = devm_kzalloc(dev, new_size, flags);
  6483. + if (!ret) {
  6484. + MSM_BUS_ERR("%s: Error Reallocating memory", __func__);
  6485. + goto exit_realloc_devmem;
  6486. + }
  6487. +
  6488. + memcpy(ret, p, copy_size);
  6489. + devm_kfree(dev, p);
  6490. +exit_realloc_devmem:
  6491. + return ret;
  6492. +}
  6493. +
  6494. +
  6495. +static int add_dirty_node(int **dirty_nodes, int id, int *num_dirty)
  6496. +{
  6497. + int i;
  6498. + int found = 0;
  6499. + int ret = 0;
  6500. + int *dnode = NULL;
  6501. +
  6502. + for (i = 0; i < *num_dirty; i++) {
  6503. + if ((*dirty_nodes)[i] == id) {
  6504. + found = 1;
  6505. + break;
  6506. + }
  6507. + }
  6508. +
  6509. + if (!found) {
  6510. + (*num_dirty)++;
  6511. + dnode =
  6512. + krealloc(*dirty_nodes, sizeof(int) * (*num_dirty),
  6513. + GFP_KERNEL);
  6514. +
  6515. + if (ZERO_OR_NULL_PTR(dnode)) {
  6516. + MSM_BUS_ERR("%s: Failure allocating dirty nodes array",
  6517. + __func__);
  6518. + ret = -ENOMEM;
  6519. + } else {
  6520. + *dirty_nodes = dnode;
  6521. + (*dirty_nodes)[(*num_dirty) - 1] = id;
  6522. + }
  6523. + }
  6524. +
  6525. + return ret;
  6526. +}
  6527. +
  6528. +int msm_bus_update_bw(struct msm_bus_node_device_type *nodedev, int ctx,
  6529. + int64_t add_bw, int **dirty_nodes, int *num_dirty)
  6530. +{
  6531. + int ret = 0;
  6532. + int i, j;
  6533. + uint64_t cur_ab_slp = 0;
  6534. + uint64_t cur_ab_act = 0;
  6535. +
  6536. + if (nodedev->node_info->virt_dev)
  6537. + goto exit_update_bw;
  6538. +
  6539. + for (i = 0; i < NUM_CTX; i++) {
  6540. + for (j = 0; j < nodedev->num_lnodes; j++) {
  6541. + if (i == DUAL_CTX) {
  6542. + cur_ab_act +=
  6543. + nodedev->lnode_list[j].lnode_ab[i];
  6544. + cur_ab_slp +=
  6545. + nodedev->lnode_list[j].lnode_ab[i];
  6546. + } else
  6547. + cur_ab_act +=
  6548. + nodedev->lnode_list[j].lnode_ab[i];
  6549. + }
  6550. + }
  6551. +
  6552. + if (nodedev->node_ab.ab[MSM_RPM_CTX_ACTIVE_SET] != cur_ab_act) {
  6553. + nodedev->node_ab.ab[MSM_RPM_CTX_ACTIVE_SET] = cur_ab_act;
  6554. + nodedev->node_ab.ab[MSM_RPM_CTX_SLEEP_SET] = cur_ab_slp;
  6555. + nodedev->node_ab.dirty = true;
  6556. + ret = add_dirty_node(dirty_nodes, nodedev->node_info->id,
  6557. + num_dirty);
  6558. +
  6559. + if (ret) {
  6560. + MSM_BUS_ERR("%s: Failed to add dirty node %d", __func__,
  6561. + nodedev->node_info->id);
  6562. + goto exit_update_bw;
  6563. + }
  6564. + }
  6565. +
  6566. +exit_update_bw:
  6567. + return ret;
  6568. +}
  6569. +
  6570. +int msm_bus_update_clks(struct msm_bus_node_device_type *nodedev,
  6571. + int ctx, int **dirty_nodes, int *num_dirty)
  6572. +{
  6573. + int status = 0;
  6574. + struct nodeclk *nodeclk;
  6575. + struct nodeclk *busclk;
  6576. + struct msm_bus_node_device_type *bus_info = NULL;
  6577. + uint64_t req_clk;
  6578. +
  6579. + bus_info = nodedev->node_info->bus_device->platform_data;
  6580. +
  6581. + if (!bus_info) {
  6582. + MSM_BUS_ERR("%s: Unable to find bus device for device %d",
  6583. + __func__, nodedev->node_info->id);
  6584. + status = -ENODEV;
  6585. + goto exit_set_clks;
  6586. + }
  6587. +
  6588. + req_clk = nodedev->cur_clk_hz[ctx];
  6589. + busclk = &bus_info->clk[ctx];
  6590. +
  6591. + if (busclk->rate != req_clk) {
  6592. + busclk->rate = req_clk;
  6593. + busclk->dirty = 1;
  6594. + MSM_BUS_DBG("%s: Modifying bus clk %d Rate %llu", __func__,
  6595. + bus_info->node_info->id, req_clk);
  6596. + status = add_dirty_node(dirty_nodes, bus_info->node_info->id,
  6597. + num_dirty);
  6598. +
  6599. + if (status) {
  6600. + MSM_BUS_ERR("%s: Failed to add dirty node %d", __func__,
  6601. + bus_info->node_info->id);
  6602. + goto exit_set_clks;
  6603. + }
  6604. + }
  6605. +
  6606. + req_clk = nodedev->cur_clk_hz[ctx];
  6607. + nodeclk = &nodedev->clk[ctx];
  6608. +
  6609. + if (IS_ERR_OR_NULL(nodeclk))
  6610. + goto exit_set_clks;
  6611. +
  6612. + if (!nodeclk->dirty || (nodeclk->dirty && (nodeclk->rate < req_clk))) {
  6613. + nodeclk->rate = req_clk;
  6614. + nodeclk->dirty = 1;
  6615. + MSM_BUS_DBG("%s: Modifying node clk %d Rate %llu", __func__,
  6616. + nodedev->node_info->id, req_clk);
  6617. + status = add_dirty_node(dirty_nodes, nodedev->node_info->id,
  6618. + num_dirty);
  6619. + if (status) {
  6620. + MSM_BUS_ERR("%s: Failed to add dirty node %d", __func__,
  6621. + nodedev->node_info->id);
  6622. + goto exit_set_clks;
  6623. + }
  6624. + }
  6625. +
  6626. +exit_set_clks:
  6627. + return status;
  6628. +}
  6629. +
  6630. +static void msm_bus_fab_init_noc_ops(struct msm_bus_node_device_type *bus_dev)
  6631. +{
  6632. + switch (bus_dev->fabdev->bus_type) {
  6633. + case MSM_BUS_NOC:
  6634. + msm_bus_noc_set_ops(bus_dev);
  6635. + break;
  6636. + case MSM_BUS_BIMC:
  6637. + msm_bus_bimc_set_ops(bus_dev);
  6638. + break;
  6639. + default:
  6640. + MSM_BUS_ERR("%s: Invalid Bus type", __func__);
  6641. + }
  6642. +}
  6643. +
  6644. +static int msm_bus_qos_disable_clk(struct msm_bus_node_device_type *node,
  6645. + int disable_bus_qos_clk)
  6646. +{
  6647. + struct msm_bus_node_device_type *bus_node = NULL;
  6648. + int ret = 0;
  6649. +
  6650. + if (!node) {
  6651. + ret = -ENXIO;
  6652. + goto exit_disable_qos_clk;
  6653. + }
  6654. +
  6655. + bus_node = node->node_info->bus_device->platform_data;
  6656. +
  6657. + if (!bus_node) {
  6658. + ret = -ENXIO;
  6659. + goto exit_disable_qos_clk;
  6660. + }
  6661. +
  6662. + if (disable_bus_qos_clk)
  6663. + ret = disable_nodeclk(&bus_node->clk[DUAL_CTX]);
  6664. +
  6665. + if (ret) {
  6666. + MSM_BUS_ERR("%s: Failed to disable bus clk, node %d",
  6667. + __func__, node->node_info->id);
  6668. + goto exit_disable_qos_clk;
  6669. + }
  6670. +
  6671. + if (!IS_ERR_OR_NULL(node->qos_clk.clk)) {
  6672. + ret = disable_nodeclk(&node->qos_clk);
  6673. +
  6674. + if (ret) {
  6675. + MSM_BUS_ERR("%s: Failed to disable mas qos clk,node %d",
  6676. + __func__, node->node_info->id);
  6677. + goto exit_disable_qos_clk;
  6678. + }
  6679. + }
  6680. +
  6681. +exit_disable_qos_clk:
  6682. + return ret;
  6683. +}
  6684. +
  6685. +static int msm_bus_qos_enable_clk(struct msm_bus_node_device_type *node)
  6686. +{
  6687. + struct msm_bus_node_device_type *bus_node = NULL;
  6688. + long rounded_rate;
  6689. + int ret = 0;
  6690. + int bus_qos_enabled = 0;
  6691. +
  6692. + if (!node) {
  6693. + ret = -ENXIO;
  6694. + goto exit_enable_qos_clk;
  6695. + }
  6696. +
  6697. + bus_node = node->node_info->bus_device->platform_data;
  6698. +
  6699. + if (!bus_node) {
  6700. + ret = -ENXIO;
  6701. + goto exit_enable_qos_clk;
  6702. + }
  6703. +
  6704. + /* Check if the bus clk is already set before trying to set it
  6705. + * Do this only during
  6706. + * a. Bootup
  6707. + * b. Only for bus clks
  6708. + **/
  6709. + if (!clk_get_rate(bus_node->clk[DUAL_CTX].clk)) {
  6710. + rounded_rate = clk_round_rate(bus_node->clk[DUAL_CTX].clk, 1);
  6711. + ret = setrate_nodeclk(&bus_node->clk[DUAL_CTX], rounded_rate);
  6712. + if (ret) {
  6713. + MSM_BUS_ERR("%s: Failed to set bus clk, node %d",
  6714. + __func__, node->node_info->id);
  6715. + goto exit_enable_qos_clk;
  6716. + }
  6717. +
  6718. + ret = enable_nodeclk(&bus_node->clk[DUAL_CTX]);
  6719. + if (ret) {
  6720. + MSM_BUS_ERR("%s: Failed to enable bus clk, node %d",
  6721. + __func__, node->node_info->id);
  6722. + goto exit_enable_qos_clk;
  6723. + }
  6724. + bus_qos_enabled = 1;
  6725. + }
  6726. +
  6727. + if (!IS_ERR_OR_NULL(node->qos_clk.clk)) {
  6728. + rounded_rate = clk_round_rate(node->qos_clk.clk, 1);
  6729. + ret = setrate_nodeclk(&node->qos_clk, rounded_rate);
  6730. + if (ret) {
  6731. + MSM_BUS_ERR("%s: Failed to enable mas qos clk, node %d",
  6732. + __func__, node->node_info->id);
  6733. + goto exit_enable_qos_clk;
  6734. + }
  6735. +
  6736. + ret = enable_nodeclk(&node->qos_clk);
  6737. + if (ret) {
  6738. + MSM_BUS_ERR("Err enable mas qos clk, node %d ret %d",
  6739. + node->node_info->id, ret);
  6740. + goto exit_enable_qos_clk;
  6741. + }
  6742. + }
  6743. + ret = bus_qos_enabled;
  6744. +
  6745. +exit_enable_qos_clk:
  6746. + return ret;
  6747. +}
  6748. +
  6749. +int msm_bus_enable_limiter(struct msm_bus_node_device_type *node_dev,
  6750. + bool enable, uint64_t lim_bw)
  6751. +{
  6752. + int ret = 0;
  6753. + struct msm_bus_node_device_type *bus_node_dev;
  6754. +
  6755. + if (!node_dev) {
  6756. + MSM_BUS_ERR("No device specified");
  6757. + ret = -ENXIO;
  6758. + goto exit_enable_limiter;
  6759. + }
  6760. +
  6761. + if (!node_dev->ap_owned) {
  6762. + MSM_BUS_ERR("Device is not AP owned %d.",
  6763. + node_dev->node_info->id);
  6764. + ret = -ENXIO;
  6765. + goto exit_enable_limiter;
  6766. + }
  6767. +
  6768. + bus_node_dev = node_dev->node_info->bus_device->platform_data;
  6769. + if (!bus_node_dev) {
  6770. + MSM_BUS_ERR("Unable to get bus device infofor %d",
  6771. + node_dev->node_info->id);
  6772. + ret = -ENXIO;
  6773. + goto exit_enable_limiter;
  6774. + }
  6775. + if (bus_node_dev->fabdev &&
  6776. + bus_node_dev->fabdev->noc_ops.limit_mport) {
  6777. + ret = msm_bus_qos_enable_clk(node_dev);
  6778. + if (ret < 0) {
  6779. + MSM_BUS_ERR("Can't Enable QoS clk %d",
  6780. + node_dev->node_info->id);
  6781. + goto exit_enable_limiter;
  6782. + }
  6783. + bus_node_dev->fabdev->noc_ops.limit_mport(
  6784. + node_dev,
  6785. + bus_node_dev->fabdev->qos_base,
  6786. + bus_node_dev->fabdev->base_offset,
  6787. + bus_node_dev->fabdev->qos_off,
  6788. + bus_node_dev->fabdev->qos_freq,
  6789. + enable, lim_bw);
  6790. + msm_bus_qos_disable_clk(node_dev, ret);
  6791. + }
  6792. +
  6793. +exit_enable_limiter:
  6794. + return ret;
  6795. +}
  6796. +
  6797. +static int msm_bus_dev_init_qos(struct device *dev, void *data)
  6798. +{
  6799. + int ret = 0;
  6800. + struct msm_bus_node_device_type *node_dev = NULL;
  6801. +
  6802. + node_dev = dev->platform_data;
  6803. +
  6804. + if (!node_dev) {
  6805. + MSM_BUS_ERR("%s: Unable to get node device info" , __func__);
  6806. + ret = -ENXIO;
  6807. + goto exit_init_qos;
  6808. + }
  6809. +
  6810. + MSM_BUS_DBG("Device = %d", node_dev->node_info->id);
  6811. +
  6812. + if (node_dev->ap_owned) {
  6813. + struct msm_bus_node_device_type *bus_node_info;
  6814. +
  6815. + bus_node_info = node_dev->node_info->bus_device->platform_data;
  6816. +
  6817. + if (!bus_node_info) {
  6818. + MSM_BUS_ERR("%s: Unable to get bus device infofor %d",
  6819. + __func__,
  6820. + node_dev->node_info->id);
  6821. + ret = -ENXIO;
  6822. + goto exit_init_qos;
  6823. + }
  6824. +
  6825. + if (bus_node_info->fabdev &&
  6826. + bus_node_info->fabdev->noc_ops.qos_init) {
  6827. + int ret = 0;
  6828. +
  6829. + if (node_dev->ap_owned &&
  6830. + (node_dev->node_info->qos_params.mode) != -1) {
  6831. +
  6832. + if (bus_node_info->fabdev->bypass_qos_prg)
  6833. + goto exit_init_qos;
  6834. +
  6835. + ret = msm_bus_qos_enable_clk(node_dev);
  6836. + if (ret < 0) {
  6837. + MSM_BUS_ERR("Can't Enable QoS clk %d",
  6838. + node_dev->node_info->id);
  6839. + goto exit_init_qos;
  6840. + }
  6841. +
  6842. + bus_node_info->fabdev->noc_ops.qos_init(
  6843. + node_dev,
  6844. + bus_node_info->fabdev->qos_base,
  6845. + bus_node_info->fabdev->base_offset,
  6846. + bus_node_info->fabdev->qos_off,
  6847. + bus_node_info->fabdev->qos_freq);
  6848. + msm_bus_qos_disable_clk(node_dev, ret);
  6849. + }
  6850. + } else
  6851. + MSM_BUS_ERR("%s: Skipping QOS init for %d",
  6852. + __func__, node_dev->node_info->id);
  6853. + }
  6854. +exit_init_qos:
  6855. + return ret;
  6856. +}
  6857. +
  6858. +static int msm_bus_fabric_init(struct device *dev,
  6859. + struct msm_bus_node_device_type *pdata)
  6860. +{
  6861. + struct msm_bus_fab_device_type *fabdev;
  6862. + struct msm_bus_node_device_type *node_dev = NULL;
  6863. + int ret = 0;
  6864. +
  6865. + node_dev = dev->platform_data;
  6866. + if (!node_dev) {
  6867. + MSM_BUS_ERR("%s: Unable to get bus device info" , __func__);
  6868. + ret = -ENXIO;
  6869. + goto exit_fabric_init;
  6870. + }
  6871. +
  6872. + if (node_dev->node_info->virt_dev) {
  6873. + MSM_BUS_ERR("%s: Skip Fab init for virtual device %d", __func__,
  6874. + node_dev->node_info->id);
  6875. + goto exit_fabric_init;
  6876. + }
  6877. +
  6878. + fabdev = devm_kzalloc(dev, sizeof(struct msm_bus_fab_device_type),
  6879. + GFP_KERNEL);
  6880. + if (!fabdev) {
  6881. + MSM_BUS_ERR("Fabric alloc failed\n");
  6882. + ret = -ENOMEM;
  6883. + goto exit_fabric_init;
  6884. + }
  6885. +
  6886. + node_dev->fabdev = fabdev;
  6887. + fabdev->pqos_base = pdata->fabdev->pqos_base;
  6888. + fabdev->qos_range = pdata->fabdev->qos_range;
  6889. + fabdev->base_offset = pdata->fabdev->base_offset;
  6890. + fabdev->qos_off = pdata->fabdev->qos_off;
  6891. + fabdev->qos_freq = pdata->fabdev->qos_freq;
  6892. + fabdev->bus_type = pdata->fabdev->bus_type;
  6893. + fabdev->bypass_qos_prg = pdata->fabdev->bypass_qos_prg;
  6894. + fabdev->util_fact = pdata->fabdev->util_fact;
  6895. + fabdev->vrail_comp = pdata->fabdev->vrail_comp;
  6896. + msm_bus_fab_init_noc_ops(node_dev);
  6897. +
  6898. + fabdev->qos_base = devm_ioremap(dev,
  6899. + fabdev->pqos_base, fabdev->qos_range);
  6900. + if (!fabdev->qos_base) {
  6901. + MSM_BUS_ERR("%s: Error remapping address 0x%zx :bus device %d",
  6902. + __func__,
  6903. + (size_t)fabdev->pqos_base, node_dev->node_info->id);
  6904. + ret = -ENOMEM;
  6905. + goto exit_fabric_init;
  6906. + }
  6907. +
  6908. + /*if (msmbus_coresight_init(pdev))
  6909. + pr_warn("Coresight support absent for bus: %d\n", pdata->id);*/
  6910. +exit_fabric_init:
  6911. + return ret;
  6912. +}
  6913. +
  6914. +static int msm_bus_init_clk(struct device *bus_dev,
  6915. + struct msm_bus_node_device_type *pdata)
  6916. +{
  6917. + unsigned int ctx;
  6918. + int ret = 0;
  6919. + struct msm_bus_node_device_type *node_dev = bus_dev->platform_data;
  6920. +
  6921. + for (ctx = 0; ctx < NUM_CTX; ctx++) {
  6922. + if (!IS_ERR_OR_NULL(pdata->clk[ctx].clk)) {
  6923. + node_dev->clk[ctx].clk = pdata->clk[ctx].clk;
  6924. + node_dev->clk[ctx].enable = false;
  6925. + node_dev->clk[ctx].dirty = false;
  6926. + MSM_BUS_ERR("%s: Valid node clk node %d ctx %d",
  6927. + __func__, node_dev->node_info->id, ctx);
  6928. + }
  6929. + }
  6930. +
  6931. + if (!IS_ERR_OR_NULL(pdata->qos_clk.clk)) {
  6932. + node_dev->qos_clk.clk = pdata->qos_clk.clk;
  6933. + node_dev->qos_clk.enable = false;
  6934. + MSM_BUS_ERR("%s: Valid Iface clk node %d", __func__,
  6935. + node_dev->node_info->id);
  6936. + }
  6937. +
  6938. + return ret;
  6939. +}
  6940. +
  6941. +static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata,
  6942. + struct device *bus_dev)
  6943. +{
  6944. + int ret = 0;
  6945. + struct msm_bus_node_info_type *node_info = NULL;
  6946. + struct msm_bus_node_info_type *pdata_node_info = NULL;
  6947. + struct msm_bus_node_device_type *bus_node = NULL;
  6948. +
  6949. + bus_node = bus_dev->platform_data;
  6950. +
  6951. + if (!bus_node || !pdata) {
  6952. + ret = -ENXIO;
  6953. + MSM_BUS_ERR("%s: Invalid pointers pdata %p, bus_node %p",
  6954. + __func__, pdata, bus_node);
  6955. + goto exit_copy_node_info;
  6956. + }
  6957. +
  6958. + node_info = bus_node->node_info;
  6959. + pdata_node_info = pdata->node_info;
  6960. +
  6961. + node_info->name = pdata_node_info->name;
  6962. + node_info->id = pdata_node_info->id;
  6963. + node_info->bus_device_id = pdata_node_info->bus_device_id;
  6964. + node_info->mas_rpm_id = pdata_node_info->mas_rpm_id;
  6965. + node_info->slv_rpm_id = pdata_node_info->slv_rpm_id;
  6966. + node_info->num_connections = pdata_node_info->num_connections;
  6967. + node_info->num_blist = pdata_node_info->num_blist;
  6968. + node_info->num_qports = pdata_node_info->num_qports;
  6969. + node_info->buswidth = pdata_node_info->buswidth;
  6970. + node_info->virt_dev = pdata_node_info->virt_dev;
  6971. + node_info->is_fab_dev = pdata_node_info->is_fab_dev;
  6972. + node_info->qos_params.mode = pdata_node_info->qos_params.mode;
  6973. + node_info->qos_params.prio1 = pdata_node_info->qos_params.prio1;
  6974. + node_info->qos_params.prio0 = pdata_node_info->qos_params.prio0;
  6975. + node_info->qos_params.prio_lvl = pdata_node_info->qos_params.prio_lvl;
  6976. + node_info->qos_params.prio_rd = pdata_node_info->qos_params.prio_rd;
  6977. + node_info->qos_params.prio_wr = pdata_node_info->qos_params.prio_wr;
  6978. + node_info->qos_params.gp = pdata_node_info->qos_params.gp;
  6979. + node_info->qos_params.thmp = pdata_node_info->qos_params.thmp;
  6980. + node_info->qos_params.ws = pdata_node_info->qos_params.ws;
  6981. + node_info->qos_params.bw_buffer = pdata_node_info->qos_params.bw_buffer;
  6982. + node_info->util_fact = pdata_node_info->util_fact;
  6983. + node_info->vrail_comp = pdata_node_info->vrail_comp;
  6984. +
  6985. + node_info->dev_connections = devm_kzalloc(bus_dev,
  6986. + sizeof(struct device *) *
  6987. + pdata_node_info->num_connections,
  6988. + GFP_KERNEL);
  6989. + if (!node_info->dev_connections) {
  6990. + MSM_BUS_ERR("%s:Bus dev connections alloc failed\n", __func__);
  6991. + ret = -ENOMEM;
  6992. + goto exit_copy_node_info;
  6993. + }
  6994. +
  6995. + node_info->connections = devm_kzalloc(bus_dev,
  6996. + sizeof(int) * pdata_node_info->num_connections,
  6997. + GFP_KERNEL);
  6998. + if (!node_info->connections) {
  6999. + MSM_BUS_ERR("%s:Bus connections alloc failed\n", __func__);
  7000. + devm_kfree(bus_dev, node_info->dev_connections);
  7001. + ret = -ENOMEM;
  7002. + goto exit_copy_node_info;
  7003. + }
  7004. +
  7005. + memcpy(node_info->connections,
  7006. + pdata_node_info->connections,
  7007. + sizeof(int) * pdata_node_info->num_connections);
  7008. +
  7009. + node_info->black_connections = devm_kzalloc(bus_dev,
  7010. + sizeof(struct device *) *
  7011. + pdata_node_info->num_blist,
  7012. + GFP_KERNEL);
  7013. + if (!node_info->black_connections) {
  7014. + MSM_BUS_ERR("%s: Bus black connections alloc failed\n",
  7015. + __func__);
  7016. + devm_kfree(bus_dev, node_info->dev_connections);
  7017. + devm_kfree(bus_dev, node_info->connections);
  7018. + ret = -ENOMEM;
  7019. + goto exit_copy_node_info;
  7020. + }
  7021. +
  7022. + node_info->black_listed_connections = devm_kzalloc(bus_dev,
  7023. + pdata_node_info->num_blist * sizeof(int),
  7024. + GFP_KERNEL);
  7025. + if (!node_info->black_listed_connections) {
  7026. + MSM_BUS_ERR("%s:Bus black list connections alloc failed\n",
  7027. + __func__);
  7028. + devm_kfree(bus_dev, node_info->black_connections);
  7029. + devm_kfree(bus_dev, node_info->dev_connections);
  7030. + devm_kfree(bus_dev, node_info->connections);
  7031. + ret = -ENOMEM;
  7032. + goto exit_copy_node_info;
  7033. + }
  7034. +
  7035. + memcpy(node_info->black_listed_connections,
  7036. + pdata_node_info->black_listed_connections,
  7037. + sizeof(int) * pdata_node_info->num_blist);
  7038. +
  7039. + node_info->qport = devm_kzalloc(bus_dev,
  7040. + sizeof(int) * pdata_node_info->num_qports,
  7041. + GFP_KERNEL);
  7042. + if (!node_info->qport) {
  7043. + MSM_BUS_ERR("%s:Bus qport allocation failed\n", __func__);
  7044. + devm_kfree(bus_dev, node_info->dev_connections);
  7045. + devm_kfree(bus_dev, node_info->connections);
  7046. + devm_kfree(bus_dev, node_info->black_listed_connections);
  7047. + ret = -ENOMEM;
  7048. + goto exit_copy_node_info;
  7049. + }
  7050. +
  7051. + memcpy(node_info->qport,
  7052. + pdata_node_info->qport,
  7053. + sizeof(int) * pdata_node_info->num_qports);
  7054. +
  7055. +exit_copy_node_info:
  7056. + return ret;
  7057. +}
  7058. +
  7059. +static struct device *msm_bus_device_init(
  7060. + struct msm_bus_node_device_type *pdata)
  7061. +{
  7062. + struct device *bus_dev = NULL;
  7063. + struct msm_bus_node_device_type *bus_node = NULL;
  7064. + struct msm_bus_node_info_type *node_info = NULL;
  7065. + int ret = 0;
  7066. +
  7067. + bus_dev = kzalloc(sizeof(struct device), GFP_KERNEL);
  7068. + if (!bus_dev) {
  7069. + MSM_BUS_ERR("%s:Device alloc failed\n", __func__);
  7070. + bus_dev = NULL;
  7071. + goto exit_device_init;
  7072. + }
  7073. + /**
  7074. + * Init here so we can use devm calls
  7075. + */
  7076. + device_initialize(bus_dev);
  7077. +
  7078. + bus_node = devm_kzalloc(bus_dev,
  7079. + sizeof(struct msm_bus_node_device_type), GFP_KERNEL);
  7080. + if (!bus_node) {
  7081. + MSM_BUS_ERR("%s:Bus node alloc failed\n", __func__);
  7082. + kfree(bus_dev);
  7083. + bus_dev = NULL;
  7084. + goto exit_device_init;
  7085. + }
  7086. +
  7087. + node_info = devm_kzalloc(bus_dev,
  7088. + sizeof(struct msm_bus_node_info_type), GFP_KERNEL);
  7089. + if (!node_info) {
  7090. + MSM_BUS_ERR("%s:Bus node info alloc failed\n", __func__);
  7091. + devm_kfree(bus_dev, bus_node);
  7092. + kfree(bus_dev);
  7093. + bus_dev = NULL;
  7094. + goto exit_device_init;
  7095. + }
  7096. +
  7097. + bus_node->node_info = node_info;
  7098. + bus_node->ap_owned = pdata->ap_owned;
  7099. + bus_dev->platform_data = bus_node;
  7100. +
  7101. + if (msm_bus_copy_node_info(pdata, bus_dev) < 0) {
  7102. + devm_kfree(bus_dev, bus_node);
  7103. + devm_kfree(bus_dev, node_info);
  7104. + kfree(bus_dev);
  7105. + bus_dev = NULL;
  7106. + goto exit_device_init;
  7107. + }
  7108. +
  7109. + bus_dev->bus = &msm_bus_type;
  7110. + dev_set_name(bus_dev, bus_node->node_info->name);
  7111. +
  7112. + ret = device_add(bus_dev);
  7113. + if (ret < 0) {
  7114. + MSM_BUS_ERR("%s: Error registering device %d",
  7115. + __func__, pdata->node_info->id);
  7116. + devm_kfree(bus_dev, bus_node);
  7117. + devm_kfree(bus_dev, node_info->dev_connections);
  7118. + devm_kfree(bus_dev, node_info->connections);
  7119. + devm_kfree(bus_dev, node_info->black_connections);
  7120. + devm_kfree(bus_dev, node_info->black_listed_connections);
  7121. + devm_kfree(bus_dev, node_info);
  7122. + kfree(bus_dev);
  7123. + bus_dev = NULL;
  7124. + goto exit_device_init;
  7125. + }
  7126. + device_create_file(bus_dev, &dev_attr_vrail);
  7127. +
  7128. +exit_device_init:
  7129. + return bus_dev;
  7130. +}
  7131. +
  7132. +static int msm_bus_setup_dev_conn(struct device *bus_dev, void *data)
  7133. +{
  7134. + struct msm_bus_node_device_type *bus_node = NULL;
  7135. + int ret = 0;
  7136. + int j;
  7137. +
  7138. + bus_node = bus_dev->platform_data;
  7139. + if (!bus_node) {
  7140. + MSM_BUS_ERR("%s: Can't get device info", __func__);
  7141. + ret = -ENODEV;
  7142. + goto exit_setup_dev_conn;
  7143. + }
  7144. +
  7145. + /* Setup parent bus device for this node */
  7146. + if (!bus_node->node_info->is_fab_dev) {
  7147. + struct device *bus_parent_device =
  7148. + bus_find_device(&msm_bus_type, NULL,
  7149. + (void *)&bus_node->node_info->bus_device_id,
  7150. + msm_bus_device_match_adhoc);
  7151. +
  7152. + if (!bus_parent_device) {
  7153. + MSM_BUS_ERR("%s: Error finding parentdev %d parent %d",
  7154. + __func__,
  7155. + bus_node->node_info->id,
  7156. + bus_node->node_info->bus_device_id);
  7157. + ret = -ENXIO;
  7158. + goto exit_setup_dev_conn;
  7159. + }
  7160. + bus_node->node_info->bus_device = bus_parent_device;
  7161. + }
  7162. +
  7163. + bus_node->node_info->is_traversed = false;
  7164. +
  7165. + for (j = 0; j < bus_node->node_info->num_connections; j++) {
  7166. + bus_node->node_info->dev_connections[j] =
  7167. + bus_find_device(&msm_bus_type, NULL,
  7168. + (void *)&bus_node->node_info->connections[j],
  7169. + msm_bus_device_match_adhoc);
  7170. +
  7171. + if (!bus_node->node_info->dev_connections[j]) {
  7172. + MSM_BUS_ERR("%s: Error finding conn %d for device %d",
  7173. + __func__, bus_node->node_info->connections[j],
  7174. + bus_node->node_info->id);
  7175. + ret = -ENODEV;
  7176. + goto exit_setup_dev_conn;
  7177. + }
  7178. + }
  7179. +
  7180. + for (j = 0; j < bus_node->node_info->num_blist; j++) {
  7181. + bus_node->node_info->black_connections[j] =
  7182. + bus_find_device(&msm_bus_type, NULL,
  7183. + (void *)&bus_node->node_info->
  7184. + black_listed_connections[j],
  7185. + msm_bus_device_match_adhoc);
  7186. +
  7187. + if (!bus_node->node_info->black_connections[j]) {
  7188. + MSM_BUS_ERR("%s: Error finding conn %d for device %d\n",
  7189. + __func__, bus_node->node_info->
  7190. + black_listed_connections[j],
  7191. + bus_node->node_info->id);
  7192. + ret = -ENODEV;
  7193. + goto exit_setup_dev_conn;
  7194. + }
  7195. + }
  7196. +
  7197. +exit_setup_dev_conn:
  7198. + return ret;
  7199. +}
  7200. +
  7201. +static int msm_bus_node_debug(struct device *bus_dev, void *data)
  7202. +{
  7203. + int j;
  7204. + int ret = 0;
  7205. + struct msm_bus_node_device_type *bus_node = NULL;
  7206. +
  7207. + bus_node = bus_dev->platform_data;
  7208. + if (!bus_node) {
  7209. + MSM_BUS_ERR("%s: Can't get device info", __func__);
  7210. + ret = -ENODEV;
  7211. + goto exit_node_debug;
  7212. + }
  7213. +
  7214. + MSM_BUS_DBG("Device = %d buswidth %u", bus_node->node_info->id,
  7215. + bus_node->node_info->buswidth);
  7216. + for (j = 0; j < bus_node->node_info->num_connections; j++) {
  7217. + struct msm_bus_node_device_type *bdev =
  7218. + (struct msm_bus_node_device_type *)
  7219. + bus_node->node_info->dev_connections[j]->platform_data;
  7220. + MSM_BUS_DBG("\n\t Connection[%d] %d", j, bdev->node_info->id);
  7221. + }
  7222. +
  7223. +exit_node_debug:
  7224. + return ret;
  7225. +}
  7226. +
  7227. +static int msm_bus_device_probe(struct platform_device *pdev)
  7228. +{
  7229. + unsigned int i, ret;
  7230. + struct msm_bus_device_node_registration *pdata;
  7231. +
  7232. + /* If possible, get pdata from device-tree */
  7233. + if (pdev->dev.of_node)
  7234. + pdata = msm_bus_of_to_pdata(pdev);
  7235. + else {
  7236. + pdata = (struct msm_bus_device_node_registration *)pdev->
  7237. + dev.platform_data;
  7238. + }
  7239. +
  7240. + if (IS_ERR_OR_NULL(pdata)) {
  7241. + MSM_BUS_ERR("No platform data found");
  7242. + ret = -ENODATA;
  7243. + goto exit_device_probe;
  7244. + }
  7245. +
  7246. + for (i = 0; i < pdata->num_devices; i++) {
  7247. + struct device *node_dev = NULL;
  7248. +
  7249. + node_dev = msm_bus_device_init(&pdata->info[i]);
  7250. +
  7251. + if (!node_dev) {
  7252. + MSM_BUS_ERR("%s: Error during dev init for %d",
  7253. + __func__, pdata->info[i].node_info->id);
  7254. + ret = -ENXIO;
  7255. + goto exit_device_probe;
  7256. + }
  7257. +
  7258. + ret = msm_bus_init_clk(node_dev, &pdata->info[i]);
  7259. + /*Is this a fabric device ?*/
  7260. + if (pdata->info[i].node_info->is_fab_dev) {
  7261. + MSM_BUS_DBG("%s: %d is a fab", __func__,
  7262. + pdata->info[i].node_info->id);
  7263. + ret = msm_bus_fabric_init(node_dev, &pdata->info[i]);
  7264. + if (ret) {
  7265. + MSM_BUS_ERR("%s: Error intializing fab %d",
  7266. + __func__, pdata->info[i].node_info->id);
  7267. + goto exit_device_probe;
  7268. + }
  7269. + }
  7270. + }
  7271. +
  7272. + ret = bus_for_each_dev(&msm_bus_type, NULL, NULL,
  7273. + msm_bus_setup_dev_conn);
  7274. + if (ret) {
  7275. + MSM_BUS_ERR("%s: Error setting up dev connections", __func__);
  7276. + goto exit_device_probe;
  7277. + }
  7278. +
  7279. + ret = bus_for_each_dev(&msm_bus_type, NULL, NULL, msm_bus_dev_init_qos);
  7280. + if (ret) {
  7281. + MSM_BUS_ERR("%s: Error during qos init", __func__);
  7282. + goto exit_device_probe;
  7283. + }
  7284. +
  7285. + bus_for_each_dev(&msm_bus_type, NULL, NULL, msm_bus_node_debug);
  7286. +
  7287. + /* Register the arb layer ops */
  7288. + msm_bus_arb_setops_adhoc(&arb_ops);
  7289. + devm_kfree(&pdev->dev, pdata->info);
  7290. + devm_kfree(&pdev->dev, pdata);
  7291. +exit_device_probe:
  7292. + return ret;
  7293. +}
  7294. +
  7295. +static int msm_bus_device_rules_probe(struct platform_device *pdev)
  7296. +{
  7297. + struct bus_rule_type *rule_data = NULL;
  7298. + int num_rules = 0;
  7299. +
  7300. + num_rules = msm_bus_of_get_static_rules(pdev, &rule_data);
  7301. +
  7302. + if (!rule_data)
  7303. + goto exit_rules_probe;
  7304. +
  7305. + msm_rule_register(num_rules, rule_data, NULL);
  7306. + static_rules.num_rules = num_rules;
  7307. + static_rules.rules = rule_data;
  7308. + pdev->dev.platform_data = &static_rules;
  7309. +
  7310. +exit_rules_probe:
  7311. + return 0;
  7312. +}
  7313. +
  7314. +int msm_bus_device_rules_remove(struct platform_device *pdev)
  7315. +{
  7316. + struct static_rules_type *static_rules = NULL;
  7317. +
  7318. + static_rules = pdev->dev.platform_data;
  7319. + if (static_rules)
  7320. + msm_rule_unregister(static_rules->num_rules,
  7321. + static_rules->rules, NULL);
  7322. + return 0;
  7323. +}
  7324. +
  7325. +static int msm_bus_free_dev(struct device *dev, void *data)
  7326. +{
  7327. + struct msm_bus_node_device_type *bus_node = NULL;
  7328. +
  7329. + bus_node = dev->platform_data;
  7330. +
  7331. + if (bus_node)
  7332. + MSM_BUS_ERR("\n%s: Removing device %d", __func__,
  7333. + bus_node->node_info->id);
  7334. + device_unregister(dev);
  7335. + return 0;
  7336. +}
  7337. +
  7338. +int msm_bus_device_remove(struct platform_device *pdev)
  7339. +{
  7340. + bus_for_each_dev(&msm_bus_type, NULL, NULL, msm_bus_free_dev);
  7341. + return 0;
  7342. +}
  7343. +
  7344. +static struct of_device_id rules_match[] = {
  7345. + {.compatible = "qcom,msm-bus-static-bw-rules"},
  7346. + {}
  7347. +};
  7348. +
  7349. +static struct platform_driver msm_bus_rules_driver = {
  7350. + .probe = msm_bus_device_rules_probe,
  7351. + .remove = msm_bus_device_rules_remove,
  7352. + .driver = {
  7353. + .name = "msm_bus_rules_device",
  7354. + .owner = THIS_MODULE,
  7355. + .of_match_table = rules_match,
  7356. + },
  7357. +};
  7358. +
  7359. +static struct of_device_id fabric_match[] = {
  7360. + {.compatible = "qcom,msm-bus-device"},
  7361. + {}
  7362. +};
  7363. +
  7364. +static struct platform_driver msm_bus_device_driver = {
  7365. + .probe = msm_bus_device_probe,
  7366. + .remove = msm_bus_device_remove,
  7367. + .driver = {
  7368. + .name = "msm_bus_device",
  7369. + .owner = THIS_MODULE,
  7370. + .of_match_table = fabric_match,
  7371. + },
  7372. +};
  7373. +
  7374. +int __init msm_bus_device_init_driver(void)
  7375. +{
  7376. + int rc;
  7377. +
  7378. + MSM_BUS_ERR("msm_bus_fabric_init_driver\n");
  7379. + rc = platform_driver_register(&msm_bus_device_driver);
  7380. +
  7381. + if (rc) {
  7382. + MSM_BUS_ERR("Failed to register bus device driver");
  7383. + return rc;
  7384. + }
  7385. + return platform_driver_register(&msm_bus_rules_driver);
  7386. +}
  7387. +subsys_initcall(msm_bus_device_init_driver);
  7388. --- /dev/null
  7389. +++ b/drivers/bus/msm_bus/msm_bus_id.c
  7390. @@ -0,0 +1,94 @@
  7391. +/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
  7392. + *
  7393. + * This program is free software; you can redistribute it and/or modify
  7394. + * it under the terms of the GNU General Public License version 2 and
  7395. + * only version 2 as published by the Free Software Foundation.
  7396. + *
  7397. + * This program is distributed in the hope that it will be useful,
  7398. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7399. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7400. + * GNU General Public License for more details.
  7401. + *
  7402. + */
  7403. +
  7404. +#include <linux/kernel.h>
  7405. +#include <linux/init.h>
  7406. +#include <linux/device.h>
  7407. +#include <linux/module.h>
  7408. +#include "msm-bus.h"
  7409. +#include "msm-bus-board.h"
  7410. +#include "msm_bus_core.h"
  7411. +#include "msm_bus_noc.h"
  7412. +#include "msm_bus_bimc.h"
  7413. +
  7414. +static uint32_t master_iids[MSM_BUS_MASTER_LAST];
  7415. +static uint32_t slave_iids[MSM_BUS_SLAVE_LAST - SLAVE_ID_KEY];
  7416. +
  7417. +static void msm_bus_assign_iids(struct msm_bus_fabric_registration
  7418. + *fabreg, int fabid)
  7419. +{
  7420. + int i;
  7421. + for (i = 0; i < fabreg->len; i++) {
  7422. + if (!fabreg->info[i].gateway) {
  7423. + fabreg->info[i].priv_id = fabid + fabreg->info[i].id;
  7424. + if (fabreg->info[i].id < SLAVE_ID_KEY) {
  7425. + if (fabreg->info[i].id >= MSM_BUS_MASTER_LAST) {
  7426. + WARN(1, "id %d exceeds array size!\n",
  7427. + fabreg->info[i].id);
  7428. + continue;
  7429. + }
  7430. +
  7431. + master_iids[fabreg->info[i].id] =
  7432. + fabreg->info[i].priv_id;
  7433. + } else {
  7434. + if ((fabreg->info[i].id - SLAVE_ID_KEY) >=
  7435. + (MSM_BUS_SLAVE_LAST - SLAVE_ID_KEY)) {
  7436. + WARN(1, "id %d exceeds array size!\n",
  7437. + fabreg->info[i].id);
  7438. + continue;
  7439. + }
  7440. +
  7441. + slave_iids[fabreg->info[i].id - (SLAVE_ID_KEY)]
  7442. + = fabreg->info[i].priv_id;
  7443. + }
  7444. + } else {
  7445. + fabreg->info[i].priv_id = fabreg->info[i].id;
  7446. + }
  7447. + }
  7448. +}
  7449. +
  7450. +static int msm_bus_get_iid(int id)
  7451. +{
  7452. + if ((id < SLAVE_ID_KEY && id >= MSM_BUS_MASTER_LAST) ||
  7453. + id >= MSM_BUS_SLAVE_LAST) {
  7454. + MSM_BUS_ERR("Cannot get iid. Invalid id %d passed\n", id);
  7455. + return -EINVAL;
  7456. + }
  7457. +
  7458. + return CHECK_ID(((id < SLAVE_ID_KEY) ? master_iids[id] :
  7459. + slave_iids[id - SLAVE_ID_KEY]), id);
  7460. +}
  7461. +
  7462. +static struct msm_bus_board_algorithm msm_bus_id_algo = {
  7463. + .get_iid = msm_bus_get_iid,
  7464. + .assign_iids = msm_bus_assign_iids,
  7465. +};
  7466. +
  7467. +int msm_bus_board_rpm_get_il_ids(uint16_t *id)
  7468. +{
  7469. + return -ENXIO;
  7470. +}
  7471. +
  7472. +void msm_bus_board_init(struct msm_bus_fabric_registration *pdata)
  7473. +{
  7474. + pdata->board_algo = &msm_bus_id_algo;
  7475. +}
  7476. +
  7477. +void msm_bus_board_set_nfab(struct msm_bus_fabric_registration *pdata,
  7478. + int nfab)
  7479. +{
  7480. + if (nfab <= 0)
  7481. + return;
  7482. +
  7483. + msm_bus_id_algo.board_nfab = nfab;
  7484. +}
  7485. --- /dev/null
  7486. +++ b/drivers/bus/msm_bus/msm_bus_noc.c
  7487. @@ -0,0 +1,770 @@
  7488. +/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  7489. + *
  7490. + * This program is free software; you can redistribute it and/or modify
  7491. + * it under the terms of the GNU General Public License version 2 and
  7492. + * only version 2 as published by the Free Software Foundation.
  7493. + *
  7494. + * This program is distributed in the hope that it will be useful,
  7495. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7496. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7497. + * GNU General Public License for more details.
  7498. + */
  7499. +
  7500. +#define pr_fmt(fmt) "AXI: NOC: %s(): " fmt, __func__
  7501. +
  7502. +#include <linux/slab.h>
  7503. +#include <linux/io.h>
  7504. +#include "msm-bus-board.h"
  7505. +#include "msm_bus_core.h"
  7506. +#include "msm_bus_noc.h"
  7507. +#include "msm_bus_adhoc.h"
  7508. +
  7509. +/* NOC_QOS generic */
  7510. +#define __CLZ(x) ((8 * sizeof(uint32_t)) - 1 - __fls(x))
  7511. +#define SAT_SCALE 16 /* 16 bytes minimum for saturation */
  7512. +#define BW_SCALE 256 /* 1/256 byte per cycle unit */
  7513. +#define QOS_DEFAULT_BASEOFFSET 0x00003000
  7514. +#define QOS_DEFAULT_DELTA 0x80
  7515. +#define MAX_BW_FIELD (NOC_QOS_BWn_BW_BMSK >> NOC_QOS_BWn_BW_SHFT)
  7516. +#define MAX_SAT_FIELD (NOC_QOS_SATn_SAT_BMSK >> NOC_QOS_SATn_SAT_SHFT)
  7517. +
  7518. +#define NOC_QOS_REG_BASE(b, o) ((b) + (o))
  7519. +
  7520. +#define NOC_QOS_ID_COREIDn_ADDR(b, o, n, d) \
  7521. + (NOC_QOS_REG_BASE(b, o) + (d) * (n))
  7522. +enum noc_qos_id_coreidn {
  7523. + NOC_QOS_ID_COREIDn_RMSK = 0xffffffff,
  7524. + NOC_QOS_ID_COREIDn_MAXn = 32,
  7525. + NOC_QOS_ID_COREIDn_CORECHSUM_BMSK = 0xffffff00,
  7526. + NOC_QOS_ID_COREIDn_CORECHSUM_SHFT = 0x8,
  7527. + NOC_QOS_ID_COREIDn_CORETYPEID_BMSK = 0xff,
  7528. + NOC_QOS_ID_COREIDn_CORETYPEID_SHFT = 0x0,
  7529. +};
  7530. +
  7531. +#define NOC_QOS_ID_REVISIONIDn_ADDR(b, o, n, d) \
  7532. + (NOC_QOS_REG_BASE(b, o) + 0x4 + (d) * (n))
  7533. +enum noc_qos_id_revisionidn {
  7534. + NOC_QOS_ID_REVISIONIDn_RMSK = 0xffffffff,
  7535. + NOC_QOS_ID_REVISIONIDn_MAXn = 32,
  7536. + NOC_QOS_ID_REVISIONIDn_FLEXNOCID_BMSK = 0xffffff00,
  7537. + NOC_QOS_ID_REVISIONIDn_FLEXNOCID_SHFT = 0x8,
  7538. + NOC_QOS_ID_REVISIONIDn_USERID_BMSK = 0xff,
  7539. + NOC_QOS_ID_REVISIONIDn_USERID_SHFT = 0x0,
  7540. +};
  7541. +
  7542. +#define NOC_QOS_PRIORITYn_ADDR(b, o, n, d) \
  7543. + (NOC_QOS_REG_BASE(b, o) + 0x8 + (d) * (n))
  7544. +enum noc_qos_id_priorityn {
  7545. + NOC_QOS_PRIORITYn_RMSK = 0x0000000f,
  7546. + NOC_QOS_PRIORITYn_MAXn = 32,
  7547. + NOC_QOS_PRIORITYn_P1_BMSK = 0xc,
  7548. + NOC_QOS_PRIORITYn_P1_SHFT = 0x2,
  7549. + NOC_QOS_PRIORITYn_P0_BMSK = 0x3,
  7550. + NOC_QOS_PRIORITYn_P0_SHFT = 0x0,
  7551. +};
  7552. +
  7553. +#define NOC_QOS_MODEn_ADDR(b, o, n, d) \
  7554. + (NOC_QOS_REG_BASE(b, o) + 0xC + (d) * (n))
  7555. +enum noc_qos_id_moden_rmsk {
  7556. + NOC_QOS_MODEn_RMSK = 0x00000003,
  7557. + NOC_QOS_MODEn_MAXn = 32,
  7558. + NOC_QOS_MODEn_MODE_BMSK = 0x3,
  7559. + NOC_QOS_MODEn_MODE_SHFT = 0x0,
  7560. +};
  7561. +
  7562. +#define NOC_QOS_BWn_ADDR(b, o, n, d) \
  7563. + (NOC_QOS_REG_BASE(b, o) + 0x10 + (d) * (n))
  7564. +enum noc_qos_id_bwn {
  7565. + NOC_QOS_BWn_RMSK = 0x0000ffff,
  7566. + NOC_QOS_BWn_MAXn = 32,
  7567. + NOC_QOS_BWn_BW_BMSK = 0xffff,
  7568. + NOC_QOS_BWn_BW_SHFT = 0x0,
  7569. +};
  7570. +
  7571. +/* QOS Saturation registers */
  7572. +#define NOC_QOS_SATn_ADDR(b, o, n, d) \
  7573. + (NOC_QOS_REG_BASE(b, o) + 0x14 + (d) * (n))
  7574. +enum noc_qos_id_saturationn {
  7575. + NOC_QOS_SATn_RMSK = 0x000003ff,
  7576. + NOC_QOS_SATn_MAXn = 32,
  7577. + NOC_QOS_SATn_SAT_BMSK = 0x3ff,
  7578. + NOC_QOS_SATn_SAT_SHFT = 0x0,
  7579. +};
  7580. +
  7581. +static int noc_div(uint64_t *a, uint32_t b)
  7582. +{
  7583. + if ((*a > 0) && (*a < b))
  7584. + return 1;
  7585. + else
  7586. + return do_div(*a, b);
  7587. +}
  7588. +
  7589. +/**
  7590. + * Calculates bw hardware is using from register values
  7591. + * bw returned is in bytes/sec
  7592. + */
  7593. +static uint64_t noc_bw(uint32_t bw_field, uint32_t qos_freq)
  7594. +{
  7595. + uint64_t res;
  7596. + uint32_t rem, scale;
  7597. +
  7598. + res = 2 * qos_freq * bw_field;
  7599. + scale = BW_SCALE * 1000;
  7600. + rem = noc_div(&res, scale);
  7601. + MSM_BUS_DBG("NOC: Calculated bw: %llu\n", res * 1000000ULL);
  7602. + return res * 1000000ULL;
  7603. +}
  7604. +
  7605. +static uint32_t noc_bw_ceil(long int bw_field, uint32_t qos_freq)
  7606. +{
  7607. + uint64_t bw_temp = 2 * qos_freq * bw_field;
  7608. + uint32_t scale = 1000 * BW_SCALE;
  7609. + noc_div(&bw_temp, scale);
  7610. + return bw_temp * 1000000;
  7611. +}
  7612. +#define MAX_BW(timebase) noc_bw_ceil(MAX_BW_FIELD, (timebase))
  7613. +
  7614. +/**
  7615. + * Calculates ws hardware is using from register values
  7616. + * ws returned is in nanoseconds
  7617. + */
  7618. +static uint32_t noc_ws(uint64_t bw, uint32_t sat, uint32_t qos_freq)
  7619. +{
  7620. + if (bw && qos_freq) {
  7621. + uint32_t bwf = bw * qos_freq;
  7622. + uint64_t scale = 1000000000000LL * BW_SCALE *
  7623. + SAT_SCALE * sat;
  7624. + noc_div(&scale, bwf);
  7625. + MSM_BUS_DBG("NOC: Calculated ws: %llu\n", scale);
  7626. + return scale;
  7627. + }
  7628. +
  7629. + return 0;
  7630. +}
  7631. +#define MAX_WS(bw, timebase) noc_ws((bw), MAX_SAT_FIELD, (timebase))
  7632. +
  7633. +/* Calculate bandwidth field value for requested bandwidth */
  7634. +static uint32_t noc_bw_field(uint64_t bw, uint32_t qos_freq)
  7635. +{
  7636. + uint32_t bw_field = 0;
  7637. +
  7638. + if (bw) {
  7639. + uint32_t rem;
  7640. + uint64_t bw_capped = min_t(uint64_t, bw, MAX_BW(qos_freq));
  7641. + uint64_t bwc = bw_capped * BW_SCALE;
  7642. + uint64_t qf = 2 * qos_freq * 1000;
  7643. +
  7644. + rem = noc_div(&bwc, qf);
  7645. + bw_field = (uint32_t)min_t(uint64_t, bwc, MAX_BW_FIELD);
  7646. + }
  7647. +
  7648. + MSM_BUS_DBG("NOC: bw_field: %u\n", bw_field);
  7649. + return bw_field;
  7650. +}
  7651. +
  7652. +static uint32_t noc_sat_field(uint64_t bw, uint32_t ws, uint32_t qos_freq)
  7653. +{
  7654. + uint32_t sat_field = 0, win;
  7655. +
  7656. + if (bw) {
  7657. + /* Limit to max bw and scale bw to 100 KB increments */
  7658. + uint64_t tbw, tscale;
  7659. + uint64_t bw_scaled = min_t(uint64_t, bw, MAX_BW(qos_freq));
  7660. + uint32_t rem = noc_div(&bw_scaled, 100000);
  7661. +
  7662. + /**
  7663. + * Calculate saturation from windows size.
  7664. + * WS must be at least one arb period.
  7665. + * Saturation must not exceed max field size
  7666. + *
  7667. + * Bandwidth is in 100KB increments
  7668. + * Window size is in ns
  7669. + * qos_freq is in KHz
  7670. + */
  7671. + win = max(ws, 1000000 / qos_freq);
  7672. + tbw = bw_scaled * win * qos_freq;
  7673. + tscale = 10000000ULL * BW_SCALE * SAT_SCALE;
  7674. + rem = noc_div(&tbw, tscale);
  7675. + sat_field = (uint32_t)min_t(uint64_t, tbw, MAX_SAT_FIELD);
  7676. + }
  7677. +
  7678. + MSM_BUS_DBG("NOC: sat_field: %d\n", sat_field);
  7679. + return sat_field;
  7680. +}
  7681. +
  7682. +static void noc_set_qos_mode(void __iomem *base, uint32_t qos_off,
  7683. + uint32_t mport, uint32_t qos_delta, uint8_t mode,
  7684. + uint8_t perm_mode)
  7685. +{
  7686. + if (mode < NOC_QOS_MODE_MAX &&
  7687. + ((1 << mode) & perm_mode)) {
  7688. + uint32_t reg_val;
  7689. +
  7690. + reg_val = readl_relaxed(NOC_QOS_MODEn_ADDR(base, qos_off,
  7691. + mport, qos_delta)) & NOC_QOS_MODEn_RMSK;
  7692. + writel_relaxed(((reg_val & (~(NOC_QOS_MODEn_MODE_BMSK))) |
  7693. + (mode & NOC_QOS_MODEn_MODE_BMSK)),
  7694. + NOC_QOS_MODEn_ADDR(base, qos_off, mport, qos_delta));
  7695. + }
  7696. + /* Ensure qos mode is set before exiting */
  7697. + wmb();
  7698. +}
  7699. +
  7700. +static void noc_set_qos_priority(void __iomem *base, uint32_t qos_off,
  7701. + uint32_t mport, uint32_t qos_delta,
  7702. + struct msm_bus_noc_qos_priority *priority)
  7703. +{
  7704. + uint32_t reg_val, val;
  7705. +
  7706. + reg_val = readl_relaxed(NOC_QOS_PRIORITYn_ADDR(base, qos_off, mport,
  7707. + qos_delta)) & NOC_QOS_PRIORITYn_RMSK;
  7708. + val = priority->p1 << NOC_QOS_PRIORITYn_P1_SHFT;
  7709. + writel_relaxed(((reg_val & (~(NOC_QOS_PRIORITYn_P1_BMSK))) |
  7710. + (val & NOC_QOS_PRIORITYn_P1_BMSK)),
  7711. + NOC_QOS_PRIORITYn_ADDR(base, qos_off, mport, qos_delta));
  7712. +
  7713. + reg_val = readl_relaxed(NOC_QOS_PRIORITYn_ADDR(base, qos_off, mport,
  7714. + qos_delta))
  7715. + & NOC_QOS_PRIORITYn_RMSK;
  7716. + writel_relaxed(((reg_val & (~(NOC_QOS_PRIORITYn_P0_BMSK))) |
  7717. + (priority->p0 & NOC_QOS_PRIORITYn_P0_BMSK)),
  7718. + NOC_QOS_PRIORITYn_ADDR(base, qos_off, mport, qos_delta));
  7719. + /* Ensure qos priority is set before exiting */
  7720. + wmb();
  7721. +}
  7722. +
  7723. +static void msm_bus_noc_set_qos_bw(void __iomem *base, uint32_t qos_off,
  7724. + uint32_t qos_freq, uint32_t mport, uint32_t qos_delta,
  7725. + uint8_t perm_mode, struct msm_bus_noc_qos_bw *qbw)
  7726. +{
  7727. + uint32_t reg_val, val, mode;
  7728. +
  7729. + if (!qos_freq) {
  7730. + MSM_BUS_DBG("Zero QoS Freq\n");
  7731. + return;
  7732. + }
  7733. +
  7734. +
  7735. + /* If Limiter or Regulator modes are not supported, bw not available*/
  7736. + if (perm_mode & (NOC_QOS_PERM_MODE_LIMITER |
  7737. + NOC_QOS_PERM_MODE_REGULATOR)) {
  7738. + uint32_t bw_val = noc_bw_field(qbw->bw, qos_freq);
  7739. + uint32_t sat_val = noc_sat_field(qbw->bw, qbw->ws,
  7740. + qos_freq);
  7741. +
  7742. + MSM_BUS_DBG("NOC: BW: perm_mode: %d bw_val: %d, sat_val: %d\n",
  7743. + perm_mode, bw_val, sat_val);
  7744. + /*
  7745. + * If in Limiter/Regulator mode, first go to fixed mode.
  7746. + * Clear QoS accumulator
  7747. + **/
  7748. + mode = readl_relaxed(NOC_QOS_MODEn_ADDR(base, qos_off,
  7749. + mport, qos_delta)) & NOC_QOS_MODEn_MODE_BMSK;
  7750. + if (mode == NOC_QOS_MODE_REGULATOR || mode ==
  7751. + NOC_QOS_MODE_LIMITER) {
  7752. + reg_val = readl_relaxed(NOC_QOS_MODEn_ADDR(
  7753. + base, qos_off, mport, qos_delta));
  7754. + val = NOC_QOS_MODE_FIXED;
  7755. + writel_relaxed((reg_val & (~(NOC_QOS_MODEn_MODE_BMSK)))
  7756. + | (val & NOC_QOS_MODEn_MODE_BMSK),
  7757. + NOC_QOS_MODEn_ADDR(base, qos_off, mport,
  7758. + qos_delta));
  7759. + }
  7760. +
  7761. + reg_val = readl_relaxed(NOC_QOS_BWn_ADDR(base, qos_off, mport,
  7762. + qos_delta));
  7763. + val = bw_val << NOC_QOS_BWn_BW_SHFT;
  7764. + writel_relaxed(((reg_val & (~(NOC_QOS_BWn_BW_BMSK))) |
  7765. + (val & NOC_QOS_BWn_BW_BMSK)),
  7766. + NOC_QOS_BWn_ADDR(base, qos_off, mport, qos_delta));
  7767. +
  7768. + MSM_BUS_DBG("NOC: BW: Wrote value: 0x%x\n", ((reg_val &
  7769. + (~NOC_QOS_BWn_BW_BMSK)) | (val &
  7770. + NOC_QOS_BWn_BW_BMSK)));
  7771. +
  7772. + reg_val = readl_relaxed(NOC_QOS_SATn_ADDR(base, qos_off,
  7773. + mport, qos_delta));
  7774. + val = sat_val << NOC_QOS_SATn_SAT_SHFT;
  7775. + writel_relaxed(((reg_val & (~(NOC_QOS_SATn_SAT_BMSK))) |
  7776. + (val & NOC_QOS_SATn_SAT_BMSK)),
  7777. + NOC_QOS_SATn_ADDR(base, qos_off, mport, qos_delta));
  7778. +
  7779. + MSM_BUS_DBG("NOC: SAT: Wrote value: 0x%x\n", ((reg_val &
  7780. + (~NOC_QOS_SATn_SAT_BMSK)) | (val &
  7781. + NOC_QOS_SATn_SAT_BMSK)));
  7782. +
  7783. + /* Set mode back to what it was initially */
  7784. + reg_val = readl_relaxed(NOC_QOS_MODEn_ADDR(base, qos_off,
  7785. + mport, qos_delta));
  7786. + writel_relaxed((reg_val & (~(NOC_QOS_MODEn_MODE_BMSK)))
  7787. + | (mode & NOC_QOS_MODEn_MODE_BMSK),
  7788. + NOC_QOS_MODEn_ADDR(base, qos_off, mport, qos_delta));
  7789. + /* Ensure that all writes for bandwidth registers have
  7790. + * completed before returning
  7791. + */
  7792. + wmb();
  7793. + }
  7794. +}
  7795. +
  7796. +uint8_t msm_bus_noc_get_qos_mode(void __iomem *base, uint32_t qos_off,
  7797. + uint32_t mport, uint32_t qos_delta, uint32_t mode, uint32_t perm_mode)
  7798. +{
  7799. + if (NOC_QOS_MODES_ALL_PERM == perm_mode)
  7800. + return readl_relaxed(NOC_QOS_MODEn_ADDR(base, qos_off,
  7801. + mport, qos_delta)) & NOC_QOS_MODEn_MODE_BMSK;
  7802. + else
  7803. + return 31 - __CLZ(mode &
  7804. + NOC_QOS_MODES_ALL_PERM);
  7805. +}
  7806. +
  7807. +void msm_bus_noc_get_qos_priority(void __iomem *base, uint32_t qos_off,
  7808. + uint32_t mport, uint32_t qos_delta,
  7809. + struct msm_bus_noc_qos_priority *priority)
  7810. +{
  7811. + priority->p1 = (readl_relaxed(NOC_QOS_PRIORITYn_ADDR(base, qos_off,
  7812. + mport, qos_delta)) & NOC_QOS_PRIORITYn_P1_BMSK) >>
  7813. + NOC_QOS_PRIORITYn_P1_SHFT;
  7814. +
  7815. + priority->p0 = (readl_relaxed(NOC_QOS_PRIORITYn_ADDR(base, qos_off,
  7816. + mport, qos_delta)) & NOC_QOS_PRIORITYn_P0_BMSK) >>
  7817. + NOC_QOS_PRIORITYn_P0_SHFT;
  7818. +}
  7819. +
  7820. +void msm_bus_noc_get_qos_bw(void __iomem *base, uint32_t qos_off,
  7821. + uint32_t qos_freq,
  7822. + uint32_t mport, uint32_t qos_delta, uint8_t perm_mode,
  7823. + struct msm_bus_noc_qos_bw *qbw)
  7824. +{
  7825. + if (perm_mode & (NOC_QOS_PERM_MODE_LIMITER |
  7826. + NOC_QOS_PERM_MODE_REGULATOR)) {
  7827. + uint32_t bw_val = readl_relaxed(NOC_QOS_BWn_ADDR(
  7828. + base, qos_off, mport, qos_delta)) & NOC_QOS_BWn_BW_BMSK;
  7829. + uint32_t sat = readl_relaxed(NOC_QOS_SATn_ADDR(
  7830. + base, qos_off, mport, qos_delta))
  7831. + & NOC_QOS_SATn_SAT_BMSK;
  7832. +
  7833. + qbw->bw = noc_bw(bw_val, qos_freq);
  7834. + qbw->ws = noc_ws(qbw->bw, sat, qos_freq);
  7835. + } else {
  7836. + qbw->bw = 0;
  7837. + qbw->ws = 0;
  7838. + }
  7839. +}
  7840. +
  7841. +static int msm_bus_noc_mas_init(struct msm_bus_noc_info *ninfo,
  7842. + struct msm_bus_inode_info *info)
  7843. +{
  7844. + int i;
  7845. + struct msm_bus_noc_qos_priority *prio;
  7846. + prio = kzalloc(sizeof(struct msm_bus_noc_qos_priority),
  7847. + GFP_KERNEL);
  7848. + if (!prio) {
  7849. + MSM_BUS_WARN("Couldn't alloc prio data for node: %d\n",
  7850. + info->node_info->id);
  7851. + return -ENOMEM;
  7852. + }
  7853. +
  7854. + prio->read_prio = info->node_info->prio_rd;
  7855. + prio->write_prio = info->node_info->prio_wr;
  7856. + prio->p1 = info->node_info->prio1;
  7857. + prio->p0 = info->node_info->prio0;
  7858. + info->hw_data = (void *)prio;
  7859. +
  7860. + if (!info->node_info->qport) {
  7861. + MSM_BUS_DBG("No QoS Ports to init\n");
  7862. + return 0;
  7863. + }
  7864. +
  7865. + for (i = 0; i < info->node_info->num_mports; i++) {
  7866. + if (info->node_info->mode != NOC_QOS_MODE_BYPASS) {
  7867. + noc_set_qos_priority(ninfo->base, ninfo->qos_baseoffset,
  7868. + info->node_info->qport[i], ninfo->qos_delta,
  7869. + prio);
  7870. +
  7871. + if (info->node_info->mode != NOC_QOS_MODE_FIXED) {
  7872. + struct msm_bus_noc_qos_bw qbw;
  7873. + qbw.ws = info->node_info->ws;
  7874. + qbw.bw = 0;
  7875. + msm_bus_noc_set_qos_bw(ninfo->base,
  7876. + ninfo->qos_baseoffset,
  7877. + ninfo->qos_freq, info->node_info->
  7878. + qport[i], ninfo->qos_delta,
  7879. + info->node_info->perm_mode,
  7880. + &qbw);
  7881. + }
  7882. + }
  7883. +
  7884. + noc_set_qos_mode(ninfo->base, ninfo->qos_baseoffset,
  7885. + info->node_info->qport[i], ninfo->qos_delta,
  7886. + info->node_info->mode,
  7887. + info->node_info->perm_mode);
  7888. + }
  7889. +
  7890. + return 0;
  7891. +}
  7892. +
  7893. +static void msm_bus_noc_node_init(void *hw_data,
  7894. + struct msm_bus_inode_info *info)
  7895. +{
  7896. + struct msm_bus_noc_info *ninfo =
  7897. + (struct msm_bus_noc_info *)hw_data;
  7898. +
  7899. + if (!IS_SLAVE(info->node_info->priv_id))
  7900. + if (info->node_info->hw_sel != MSM_BUS_RPM)
  7901. + msm_bus_noc_mas_init(ninfo, info);
  7902. +}
  7903. +
  7904. +static int msm_bus_noc_allocate_commit_data(struct msm_bus_fabric_registration
  7905. + *fab_pdata, void **cdata, int ctx)
  7906. +{
  7907. + struct msm_bus_noc_commit **cd = (struct msm_bus_noc_commit **)cdata;
  7908. + struct msm_bus_noc_info *ninfo =
  7909. + (struct msm_bus_noc_info *)fab_pdata->hw_data;
  7910. +
  7911. + *cd = kzalloc(sizeof(struct msm_bus_noc_commit), GFP_KERNEL);
  7912. + if (!*cd) {
  7913. + MSM_BUS_DBG("Couldn't alloc mem for cdata\n");
  7914. + return -ENOMEM;
  7915. + }
  7916. +
  7917. + (*cd)->mas = ninfo->cdata[ctx].mas;
  7918. + (*cd)->slv = ninfo->cdata[ctx].slv;
  7919. +
  7920. + return 0;
  7921. +}
  7922. +
  7923. +static void *msm_bus_noc_allocate_noc_data(struct platform_device *pdev,
  7924. + struct msm_bus_fabric_registration *fab_pdata)
  7925. +{
  7926. + struct resource *noc_mem;
  7927. + struct resource *noc_io;
  7928. + struct msm_bus_noc_info *ninfo;
  7929. + int i;
  7930. +
  7931. + ninfo = kzalloc(sizeof(struct msm_bus_noc_info), GFP_KERNEL);
  7932. + if (!ninfo) {
  7933. + MSM_BUS_DBG("Couldn't alloc mem for noc info\n");
  7934. + return NULL;
  7935. + }
  7936. +
  7937. + ninfo->nmasters = fab_pdata->nmasters;
  7938. + ninfo->nqos_masters = fab_pdata->nmasters;
  7939. + ninfo->nslaves = fab_pdata->nslaves;
  7940. + ninfo->qos_freq = fab_pdata->qos_freq;
  7941. +
  7942. + if (!fab_pdata->qos_baseoffset)
  7943. + ninfo->qos_baseoffset = QOS_DEFAULT_BASEOFFSET;
  7944. + else
  7945. + ninfo->qos_baseoffset = fab_pdata->qos_baseoffset;
  7946. +
  7947. + if (!fab_pdata->qos_delta)
  7948. + ninfo->qos_delta = QOS_DEFAULT_DELTA;
  7949. + else
  7950. + ninfo->qos_delta = fab_pdata->qos_delta;
  7951. +
  7952. + ninfo->mas_modes = kzalloc(sizeof(uint32_t) * fab_pdata->nmasters,
  7953. + GFP_KERNEL);
  7954. + if (!ninfo->mas_modes) {
  7955. + MSM_BUS_DBG("Couldn't alloc mem for noc master-modes\n");
  7956. + kfree(ninfo);
  7957. + return NULL;
  7958. + }
  7959. +
  7960. + for (i = 0; i < NUM_CTX; i++) {
  7961. + ninfo->cdata[i].mas = kzalloc(sizeof(struct
  7962. + msm_bus_node_hw_info) * fab_pdata->nmasters * 2,
  7963. + GFP_KERNEL);
  7964. + if (!ninfo->cdata[i].mas) {
  7965. + MSM_BUS_DBG("Couldn't alloc mem for noc master-bw\n");
  7966. + kfree(ninfo->mas_modes);
  7967. + kfree(ninfo);
  7968. + return NULL;
  7969. + }
  7970. +
  7971. + ninfo->cdata[i].slv = kzalloc(sizeof(struct
  7972. + msm_bus_node_hw_info) * fab_pdata->nslaves * 2,
  7973. + GFP_KERNEL);
  7974. + if (!ninfo->cdata[i].slv) {
  7975. + MSM_BUS_DBG("Couldn't alloc mem for noc master-bw\n");
  7976. + kfree(ninfo->cdata[i].mas);
  7977. + goto err;
  7978. + }
  7979. + }
  7980. +
  7981. + /* If it's a virtual fabric, don't get memory info */
  7982. + if (fab_pdata->virt)
  7983. + goto skip_mem;
  7984. +
  7985. + noc_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  7986. + if (!noc_mem && !fab_pdata->virt) {
  7987. + MSM_BUS_ERR("Cannot get NoC Base address\n");
  7988. + goto err;
  7989. + }
  7990. +
  7991. + noc_io = request_mem_region(noc_mem->start,
  7992. + resource_size(noc_mem), pdev->name);
  7993. + if (!noc_io) {
  7994. + MSM_BUS_ERR("NoC memory unavailable\n");
  7995. + goto err;
  7996. + }
  7997. +
  7998. + ninfo->base = ioremap(noc_mem->start, resource_size(noc_mem));
  7999. + if (!ninfo->base) {
  8000. + MSM_BUS_ERR("IOremap failed for NoC!\n");
  8001. + release_mem_region(noc_mem->start, resource_size(noc_mem));
  8002. + goto err;
  8003. + }
  8004. +
  8005. +skip_mem:
  8006. + fab_pdata->hw_data = (void *)ninfo;
  8007. + return (void *)ninfo;
  8008. +
  8009. +err:
  8010. + kfree(ninfo->mas_modes);
  8011. + kfree(ninfo);
  8012. + return NULL;
  8013. +}
  8014. +
  8015. +static void free_commit_data(void *cdata)
  8016. +{
  8017. + struct msm_bus_noc_commit *cd = (struct msm_bus_noc_commit *)cdata;
  8018. +
  8019. + kfree(cd->mas);
  8020. + kfree(cd->slv);
  8021. + kfree(cd);
  8022. +}
  8023. +
  8024. +static bool msm_bus_noc_update_bw_reg(int mode)
  8025. +{
  8026. + bool ret = false;
  8027. +
  8028. + if ((mode == NOC_QOS_MODE_LIMITER) ||
  8029. + (mode == NOC_QOS_MODE_REGULATOR))
  8030. + ret = true;
  8031. +
  8032. + return ret;
  8033. +}
  8034. +
  8035. +static void msm_bus_noc_update_bw(struct msm_bus_inode_info *hop,
  8036. + struct msm_bus_inode_info *info,
  8037. + struct msm_bus_fabric_registration *fab_pdata,
  8038. + void *sel_cdata, int *master_tiers,
  8039. + int64_t add_bw)
  8040. +{
  8041. + struct msm_bus_noc_info *ninfo;
  8042. + struct msm_bus_noc_qos_bw qos_bw;
  8043. + int i, ports;
  8044. + int64_t bw;
  8045. + struct msm_bus_noc_commit *sel_cd =
  8046. + (struct msm_bus_noc_commit *)sel_cdata;
  8047. +
  8048. + ninfo = (struct msm_bus_noc_info *)fab_pdata->hw_data;
  8049. + if (!ninfo->qos_freq) {
  8050. + MSM_BUS_DBG("NOC: No qos frequency to update bw\n");
  8051. + return;
  8052. + }
  8053. +
  8054. + if (info->node_info->num_mports == 0) {
  8055. + MSM_BUS_DBG("NOC: Skip Master BW\n");
  8056. + goto skip_mas_bw;
  8057. + }
  8058. +
  8059. + ports = info->node_info->num_mports;
  8060. + bw = INTERLEAVED_BW(fab_pdata, add_bw, ports);
  8061. +
  8062. + MSM_BUS_DBG("NOC: Update bw for: %d: %lld\n",
  8063. + info->node_info->priv_id, add_bw);
  8064. + for (i = 0; i < ports; i++) {
  8065. + sel_cd->mas[info->node_info->masterp[i]].bw += bw;
  8066. + sel_cd->mas[info->node_info->masterp[i]].hw_id =
  8067. + info->node_info->mas_hw_id;
  8068. + MSM_BUS_DBG("NOC: Update mas_bw: ID: %d, BW: %llu ports:%d\n",
  8069. + info->node_info->priv_id,
  8070. + sel_cd->mas[info->node_info->masterp[i]].bw,
  8071. + ports);
  8072. + /* Check if info is a shared master.
  8073. + * If it is, mark it dirty
  8074. + * If it isn't, then set QOS Bandwidth
  8075. + **/
  8076. + if (info->node_info->hw_sel == MSM_BUS_RPM)
  8077. + sel_cd->mas[info->node_info->masterp[i]].dirty = 1;
  8078. + else {
  8079. + if (!info->node_info->qport) {
  8080. + MSM_BUS_DBG("No qos ports to update!\n");
  8081. + break;
  8082. + }
  8083. +
  8084. + if (!(info->node_info->mode == NOC_QOS_MODE_REGULATOR)
  8085. + || (info->node_info->mode ==
  8086. + NOC_QOS_MODE_LIMITER)) {
  8087. + MSM_BUS_DBG("Skip QoS reg programming\n");
  8088. + break;
  8089. + }
  8090. + qos_bw.bw = sel_cd->mas[info->node_info->masterp[i]].
  8091. + bw;
  8092. + qos_bw.ws = info->node_info->ws;
  8093. + msm_bus_noc_set_qos_bw(ninfo->base,
  8094. + ninfo->qos_baseoffset,
  8095. + ninfo->qos_freq,
  8096. + info->node_info->qport[i], ninfo->qos_delta,
  8097. + info->node_info->perm_mode, &qos_bw);
  8098. + MSM_BUS_DBG("NOC: QoS: Update mas_bw: ws: %u\n",
  8099. + qos_bw.ws);
  8100. + }
  8101. + }
  8102. +
  8103. +skip_mas_bw:
  8104. + ports = hop->node_info->num_sports;
  8105. + for (i = 0; i < ports; i++) {
  8106. + sel_cd->slv[hop->node_info->slavep[i]].bw += add_bw;
  8107. + sel_cd->slv[hop->node_info->slavep[i]].hw_id =
  8108. + hop->node_info->slv_hw_id;
  8109. + MSM_BUS_DBG("NOC: Update slave_bw for ID: %d -> %llu\n",
  8110. + hop->node_info->priv_id,
  8111. + sel_cd->slv[hop->node_info->slavep[i]].bw);
  8112. + MSM_BUS_DBG("NOC: Update slave_bw for hw_id: %d, index: %d\n",
  8113. + hop->node_info->slv_hw_id, hop->node_info->slavep[i]);
  8114. + /* Check if hop is a shared slave.
  8115. + * If it is, mark it dirty
  8116. + * If it isn't, then nothing to be done as the
  8117. + * slaves are in bypass mode.
  8118. + **/
  8119. + if (hop->node_info->hw_sel == MSM_BUS_RPM)
  8120. + sel_cd->slv[hop->node_info->slavep[i]].dirty = 1;
  8121. + }
  8122. +}
  8123. +
  8124. +static int msm_bus_noc_commit(struct msm_bus_fabric_registration
  8125. + *fab_pdata, void *hw_data, void **cdata)
  8126. +{
  8127. + MSM_BUS_DBG("\nReached NOC Commit\n");
  8128. + msm_bus_remote_hw_commit(fab_pdata, hw_data, cdata);
  8129. + return 0;
  8130. +}
  8131. +
  8132. +static int msm_bus_noc_port_halt(uint32_t haltid, uint8_t mport)
  8133. +{
  8134. + return 0;
  8135. +}
  8136. +
  8137. +static int msm_bus_noc_port_unhalt(uint32_t haltid, uint8_t mport)
  8138. +{
  8139. + return 0;
  8140. +}
  8141. +
  8142. +static int msm_bus_noc_qos_init(struct msm_bus_node_device_type *info,
  8143. + void __iomem *qos_base,
  8144. + uint32_t qos_off, uint32_t qos_delta,
  8145. + uint32_t qos_freq)
  8146. +{
  8147. + struct msm_bus_noc_qos_priority prio;
  8148. + int ret = 0;
  8149. + int i;
  8150. +
  8151. + prio.p1 = info->node_info->qos_params.prio1;
  8152. + prio.p0 = info->node_info->qos_params.prio0;
  8153. +
  8154. + if (!info->node_info->qport) {
  8155. + MSM_BUS_DBG("No QoS Ports to init\n");
  8156. + ret = 0;
  8157. + goto err_qos_init;
  8158. + }
  8159. +
  8160. + for (i = 0; i < info->node_info->num_qports; i++) {
  8161. + if (info->node_info->qos_params.mode != NOC_QOS_MODE_BYPASS) {
  8162. + noc_set_qos_priority(qos_base, qos_off,
  8163. + info->node_info->qport[i], qos_delta,
  8164. + &prio);
  8165. +
  8166. + if (info->node_info->qos_params.mode !=
  8167. + NOC_QOS_MODE_FIXED) {
  8168. + struct msm_bus_noc_qos_bw qbw;
  8169. + qbw.ws = info->node_info->qos_params.ws;
  8170. + qbw.bw = 0;
  8171. + msm_bus_noc_set_qos_bw(qos_base, qos_off,
  8172. + qos_freq,
  8173. + info->node_info->qport[i],
  8174. + qos_delta,
  8175. + info->node_info->qos_params.mode,
  8176. + &qbw);
  8177. + }
  8178. + }
  8179. +
  8180. + noc_set_qos_mode(qos_base, qos_off, info->node_info->qport[i],
  8181. + qos_delta, info->node_info->qos_params.mode,
  8182. + (1 << info->node_info->qos_params.mode));
  8183. + }
  8184. +err_qos_init:
  8185. + return ret;
  8186. +}
  8187. +
  8188. +static int msm_bus_noc_set_bw(struct msm_bus_node_device_type *dev,
  8189. + void __iomem *qos_base,
  8190. + uint32_t qos_off, uint32_t qos_delta,
  8191. + uint32_t qos_freq)
  8192. +{
  8193. + int ret = 0;
  8194. + uint64_t bw = 0;
  8195. + int i;
  8196. + struct msm_bus_node_info_type *info = dev->node_info;
  8197. +
  8198. + if (info && info->num_qports &&
  8199. + ((info->qos_params.mode == NOC_QOS_MODE_REGULATOR) ||
  8200. + (info->qos_params.mode ==
  8201. + NOC_QOS_MODE_LIMITER))) {
  8202. + struct msm_bus_noc_qos_bw qos_bw;
  8203. +
  8204. + bw = msm_bus_div64(info->num_qports,
  8205. + dev->node_ab.ab[DUAL_CTX]);
  8206. +
  8207. + for (i = 0; i < info->num_qports; i++) {
  8208. + if (!info->qport) {
  8209. + MSM_BUS_DBG("No qos ports to update!\n");
  8210. + break;
  8211. + }
  8212. +
  8213. + qos_bw.bw = bw;
  8214. + qos_bw.ws = info->qos_params.ws;
  8215. + msm_bus_noc_set_qos_bw(qos_base, qos_off, qos_freq,
  8216. + info->qport[i], qos_delta,
  8217. + info->qos_params.mode, &qos_bw);
  8218. + MSM_BUS_DBG("NOC: QoS: Update mas_bw: ws: %u\n",
  8219. + qos_bw.ws);
  8220. + }
  8221. + }
  8222. + return ret;
  8223. +}
  8224. +int msm_bus_noc_hw_init(struct msm_bus_fabric_registration *pdata,
  8225. + struct msm_bus_hw_algorithm *hw_algo)
  8226. +{
  8227. + /* Set interleaving to true by default */
  8228. + pdata->il_flag = true;
  8229. + hw_algo->allocate_commit_data = msm_bus_noc_allocate_commit_data;
  8230. + hw_algo->allocate_hw_data = msm_bus_noc_allocate_noc_data;
  8231. + hw_algo->node_init = msm_bus_noc_node_init;
  8232. + hw_algo->free_commit_data = free_commit_data;
  8233. + hw_algo->update_bw = msm_bus_noc_update_bw;
  8234. + hw_algo->commit = msm_bus_noc_commit;
  8235. + hw_algo->port_halt = msm_bus_noc_port_halt;
  8236. + hw_algo->port_unhalt = msm_bus_noc_port_unhalt;
  8237. + hw_algo->update_bw_reg = msm_bus_noc_update_bw_reg;
  8238. + hw_algo->config_master = NULL;
  8239. + hw_algo->config_limiter = NULL;
  8240. +
  8241. + return 0;
  8242. +}
  8243. +
  8244. +int msm_bus_noc_set_ops(struct msm_bus_node_device_type *bus_dev)
  8245. +{
  8246. + if (!bus_dev)
  8247. + return -ENODEV;
  8248. + else {
  8249. + bus_dev->fabdev->noc_ops.qos_init = msm_bus_noc_qos_init;
  8250. + bus_dev->fabdev->noc_ops.set_bw = msm_bus_noc_set_bw;
  8251. + bus_dev->fabdev->noc_ops.limit_mport = NULL;
  8252. + bus_dev->fabdev->noc_ops.update_bw_reg =
  8253. + msm_bus_noc_update_bw_reg;
  8254. + }
  8255. + return 0;
  8256. +}
  8257. +EXPORT_SYMBOL(msm_bus_noc_set_ops);
  8258. --- /dev/null
  8259. +++ b/drivers/bus/msm_bus/msm_bus_noc.h
  8260. @@ -0,0 +1,76 @@
  8261. +/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  8262. + *
  8263. + * This program is free software; you can redistribute it and/or modify
  8264. + * it under the terms of the GNU General Public License version 2 and
  8265. + * only version 2 as published by the Free Software Foundation.
  8266. + *
  8267. + * This program is distributed in the hope that it will be useful,
  8268. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8269. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8270. + * GNU General Public License for more details.
  8271. + */
  8272. +
  8273. +#ifndef _ARCH_ARM_MACH_MSM_BUS_BIMC_H
  8274. +#define _ARCH_ARM_MACH_MSM_BUS_BIMC_H
  8275. +
  8276. +enum msm_bus_noc_qos_mode_type {
  8277. + NOC_QOS_MODE_FIXED = 0,
  8278. + NOC_QOS_MODE_LIMITER,
  8279. + NOC_QOS_MODE_BYPASS,
  8280. + NOC_QOS_MODE_REGULATOR,
  8281. + NOC_QOS_MODE_MAX,
  8282. +};
  8283. +
  8284. +enum msm_bus_noc_qos_mode_perm {
  8285. + NOC_QOS_PERM_MODE_FIXED = (1 << NOC_QOS_MODE_FIXED),
  8286. + NOC_QOS_PERM_MODE_LIMITER = (1 << NOC_QOS_MODE_LIMITER),
  8287. + NOC_QOS_PERM_MODE_BYPASS = (1 << NOC_QOS_MODE_BYPASS),
  8288. + NOC_QOS_PERM_MODE_REGULATOR = (1 << NOC_QOS_MODE_REGULATOR),
  8289. +};
  8290. +
  8291. +#define NOC_QOS_MODES_ALL_PERM (NOC_QOS_PERM_MODE_FIXED | \
  8292. + NOC_QOS_PERM_MODE_LIMITER | NOC_QOS_PERM_MODE_BYPASS | \
  8293. + NOC_QOS_PERM_MODE_REGULATOR)
  8294. +
  8295. +struct msm_bus_noc_commit {
  8296. + struct msm_bus_node_hw_info *mas;
  8297. + struct msm_bus_node_hw_info *slv;
  8298. +};
  8299. +
  8300. +struct msm_bus_noc_info {
  8301. + void __iomem *base;
  8302. + uint32_t base_addr;
  8303. + uint32_t nmasters;
  8304. + uint32_t nqos_masters;
  8305. + uint32_t nslaves;
  8306. + uint32_t qos_freq; /* QOS Clock in KHz */
  8307. + uint32_t qos_baseoffset;
  8308. + uint32_t qos_delta;
  8309. + uint32_t *mas_modes;
  8310. + struct msm_bus_noc_commit cdata[NUM_CTX];
  8311. +};
  8312. +
  8313. +struct msm_bus_noc_qos_priority {
  8314. + uint32_t high_prio;
  8315. + uint32_t low_prio;
  8316. + uint32_t read_prio;
  8317. + uint32_t write_prio;
  8318. + uint32_t p1;
  8319. + uint32_t p0;
  8320. +};
  8321. +
  8322. +struct msm_bus_noc_qos_bw {
  8323. + uint64_t bw; /* Bandwidth in bytes per second */
  8324. + uint32_t ws; /* Window size in nano seconds */
  8325. +};
  8326. +
  8327. +void msm_bus_noc_init(struct msm_bus_noc_info *ninfo);
  8328. +uint8_t msm_bus_noc_get_qos_mode(void __iomem *base, uint32_t qos_off,
  8329. + uint32_t mport, uint32_t qos_delta, uint32_t mode, uint32_t perm_mode);
  8330. +void msm_bus_noc_get_qos_priority(void __iomem *base, uint32_t qos_off,
  8331. + uint32_t mport, uint32_t qos_delta,
  8332. + struct msm_bus_noc_qos_priority *qprio);
  8333. +void msm_bus_noc_get_qos_bw(void __iomem *base, uint32_t qos_off,
  8334. + uint32_t qos_freq, uint32_t mport, uint32_t qos_delta,
  8335. + uint8_t perm_mode, struct msm_bus_noc_qos_bw *qbw);
  8336. +#endif /*_ARCH_ARM_MACH_MSM_BUS_NOC_H */
  8337. --- /dev/null
  8338. +++ b/drivers/bus/msm_bus/msm_bus_of.c
  8339. @@ -0,0 +1,705 @@
  8340. +/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  8341. + *
  8342. + * This program is free software; you can redistribute it and/or modify
  8343. + * it under the terms of the GNU General Public License version 2 and
  8344. + * only version 2 as published by the Free Software Foundation.
  8345. + *
  8346. + * This program is distributed in the hope that it will be useful,
  8347. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8348. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8349. + * GNU General Public License for more details.
  8350. + */
  8351. +
  8352. +#define pr_fmt(fmt) "AXI: %s(): " fmt, __func__
  8353. +
  8354. +#include <linux/module.h>
  8355. +#include <linux/slab.h>
  8356. +#include <linux/string.h>
  8357. +#include <linux/of.h>
  8358. +#include <linux/of_device.h>
  8359. +#include <linux/platform_device.h>
  8360. +#include "msm-bus.h"
  8361. +#include "msm-bus-board.h"
  8362. +#include "msm_bus_core.h"
  8363. +
  8364. +static const char * const hw_sel_name[] = {"RPM", "NoC", "BIMC", NULL};
  8365. +static const char * const mode_sel_name[] = {"Fixed", "Limiter", "Bypass",
  8366. + "Regulator", NULL};
  8367. +
  8368. +static int get_num(const char *const str[], const char *name)
  8369. +{
  8370. + int i = 0;
  8371. +
  8372. + do {
  8373. + if (!strcmp(name, str[i]))
  8374. + return i;
  8375. +
  8376. + i++;
  8377. + } while (str[i] != NULL);
  8378. +
  8379. + pr_err("Error: string %s not found\n", name);
  8380. + return -EINVAL;
  8381. +}
  8382. +
  8383. +#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_MSM_BUS_SCALING)
  8384. +static struct msm_bus_scale_pdata *get_pdata(struct platform_device *pdev,
  8385. + struct device_node *of_node)
  8386. +{
  8387. + struct msm_bus_scale_pdata *pdata = NULL;
  8388. + struct msm_bus_paths *usecase = NULL;
  8389. + int i = 0, j, ret, num_usecases = 0, num_paths, len;
  8390. + const uint32_t *vec_arr = NULL;
  8391. + bool mem_err = false;
  8392. +
  8393. + if (!pdev) {
  8394. + pr_err("Error: Null Platform device\n");
  8395. + return NULL;
  8396. + }
  8397. +
  8398. + pdata = devm_kzalloc(&pdev->dev, sizeof(struct msm_bus_scale_pdata),
  8399. + GFP_KERNEL);
  8400. + if (!pdata) {
  8401. + pr_err("Error: Memory allocation for pdata failed\n");
  8402. + mem_err = true;
  8403. + goto err;
  8404. + }
  8405. +
  8406. + ret = of_property_read_string(of_node, "qcom,msm-bus,name",
  8407. + &pdata->name);
  8408. + if (ret) {
  8409. + pr_err("Error: Client name not found\n");
  8410. + goto err;
  8411. + }
  8412. +
  8413. + ret = of_property_read_u32(of_node, "qcom,msm-bus,num-cases",
  8414. + &num_usecases);
  8415. + if (ret) {
  8416. + pr_err("Error: num-usecases not found\n");
  8417. + goto err;
  8418. + }
  8419. +
  8420. + pdata->num_usecases = num_usecases;
  8421. +
  8422. + if (of_property_read_bool(of_node, "qcom,msm-bus,active-only"))
  8423. + pdata->active_only = 1;
  8424. + else {
  8425. + pr_debug("active_only flag absent.\n");
  8426. + pr_debug("Using dual context by default\n");
  8427. + }
  8428. +
  8429. + usecase = devm_kzalloc(&pdev->dev, (sizeof(struct msm_bus_paths) *
  8430. + pdata->num_usecases), GFP_KERNEL);
  8431. + if (!usecase) {
  8432. + pr_err("Error: Memory allocation for paths failed\n");
  8433. + mem_err = true;
  8434. + goto err;
  8435. + }
  8436. +
  8437. + ret = of_property_read_u32(of_node, "qcom,msm-bus,num-paths",
  8438. + &num_paths);
  8439. + if (ret) {
  8440. + pr_err("Error: num_paths not found\n");
  8441. + goto err;
  8442. + }
  8443. +
  8444. + vec_arr = of_get_property(of_node, "qcom,msm-bus,vectors-KBps", &len);
  8445. + if (vec_arr == NULL) {
  8446. + pr_err("Error: Vector array not found\n");
  8447. + goto err;
  8448. + }
  8449. +
  8450. + if (len != num_usecases * num_paths * sizeof(uint32_t) * 4) {
  8451. + pr_err("Error: Length-error on getting vectors\n");
  8452. + goto err;
  8453. + }
  8454. +
  8455. + for (i = 0; i < num_usecases; i++) {
  8456. + usecase[i].num_paths = num_paths;
  8457. + usecase[i].vectors = devm_kzalloc(&pdev->dev, num_paths *
  8458. + sizeof(struct msm_bus_vectors), GFP_KERNEL);
  8459. + if (!usecase[i].vectors) {
  8460. + mem_err = true;
  8461. + pr_err("Error: Mem alloc failure in vectors\n");
  8462. + goto err;
  8463. + }
  8464. +
  8465. + for (j = 0; j < num_paths; j++) {
  8466. + int index = ((i * num_paths) + j) * 4;
  8467. + usecase[i].vectors[j].src = be32_to_cpu(vec_arr[index]);
  8468. + usecase[i].vectors[j].dst =
  8469. + be32_to_cpu(vec_arr[index + 1]);
  8470. + usecase[i].vectors[j].ab = (uint64_t)
  8471. + KBTOB(be32_to_cpu(vec_arr[index + 2]));
  8472. + usecase[i].vectors[j].ib = (uint64_t)
  8473. + KBTOB(be32_to_cpu(vec_arr[index + 3]));
  8474. + }
  8475. + }
  8476. +
  8477. + pdata->usecase = usecase;
  8478. + return pdata;
  8479. +err:
  8480. + if (mem_err) {
  8481. + for (; i > 0; i--)
  8482. + kfree(usecase[i-1].vectors);
  8483. +
  8484. + kfree(usecase);
  8485. + kfree(pdata);
  8486. + }
  8487. +
  8488. + return NULL;
  8489. +}
  8490. +
  8491. +/**
  8492. + * msm_bus_cl_get_pdata() - Generate bus client data from device tree
  8493. + * provided by clients.
  8494. + *
  8495. + * of_node: Device tree node to extract information from
  8496. + *
  8497. + * The function returns a valid pointer to the allocated bus-scale-pdata
  8498. + * if the vectors were correctly read from the client's device node.
  8499. + * Any error in reading or parsing the device node will return NULL
  8500. + * to the caller.
  8501. + */
  8502. +struct msm_bus_scale_pdata *msm_bus_cl_get_pdata(struct platform_device *pdev)
  8503. +{
  8504. + struct device_node *of_node;
  8505. + struct msm_bus_scale_pdata *pdata = NULL;
  8506. +
  8507. + if (!pdev) {
  8508. + pr_err("Error: Null Platform device\n");
  8509. + return NULL;
  8510. + }
  8511. +
  8512. + of_node = pdev->dev.of_node;
  8513. + pdata = get_pdata(pdev, of_node);
  8514. + if (!pdata) {
  8515. + pr_err("client has to provide missing entry for successful registration\n");
  8516. + return NULL;
  8517. + }
  8518. +
  8519. + return pdata;
  8520. +}
  8521. +EXPORT_SYMBOL(msm_bus_cl_get_pdata);
  8522. +
  8523. +/**
  8524. + * msm_bus_cl_pdata_from_node() - Generate bus client data from device tree
  8525. + * node provided by clients. This function should be used when a client
  8526. + * driver needs to register multiple bus-clients from a single device-tree
  8527. + * node associated with the platform-device.
  8528. + *
  8529. + * of_node: The subnode containing information about the bus scaling
  8530. + * data
  8531. + *
  8532. + * pdev: Platform device associated with the device-tree node
  8533. + *
  8534. + * The function returns a valid pointer to the allocated bus-scale-pdata
  8535. + * if the vectors were correctly read from the client's device node.
  8536. + * Any error in reading or parsing the device node will return NULL
  8537. + * to the caller.
  8538. + */
  8539. +struct msm_bus_scale_pdata *msm_bus_pdata_from_node(
  8540. + struct platform_device *pdev, struct device_node *of_node)
  8541. +{
  8542. + struct msm_bus_scale_pdata *pdata = NULL;
  8543. +
  8544. + if (!pdev) {
  8545. + pr_err("Error: Null Platform device\n");
  8546. + return NULL;
  8547. + }
  8548. +
  8549. + if (!of_node) {
  8550. + pr_err("Error: Null of_node passed to bus driver\n");
  8551. + return NULL;
  8552. + }
  8553. +
  8554. + pdata = get_pdata(pdev, of_node);
  8555. + if (!pdata) {
  8556. + pr_err("client has to provide missing entry for successful registration\n");
  8557. + return NULL;
  8558. + }
  8559. +
  8560. + return pdata;
  8561. +}
  8562. +EXPORT_SYMBOL(msm_bus_pdata_from_node);
  8563. +
  8564. +/**
  8565. + * msm_bus_cl_clear_pdata() - Clear pdata allocated from device-tree
  8566. + * of_node: Device tree node to extract information from
  8567. + */
  8568. +void msm_bus_cl_clear_pdata(struct msm_bus_scale_pdata *pdata)
  8569. +{
  8570. + int i;
  8571. +
  8572. + for (i = 0; i < pdata->num_usecases; i++)
  8573. + kfree(pdata->usecase[i].vectors);
  8574. +
  8575. + kfree(pdata->usecase);
  8576. + kfree(pdata);
  8577. +}
  8578. +EXPORT_SYMBOL(msm_bus_cl_clear_pdata);
  8579. +#endif
  8580. +
  8581. +static int *get_arr(struct platform_device *pdev,
  8582. + const struct device_node *node, const char *prop,
  8583. + int *nports)
  8584. +{
  8585. + int size = 0, ret;
  8586. + int *arr = NULL;
  8587. +
  8588. + if (of_get_property(node, prop, &size)) {
  8589. + *nports = size / sizeof(int);
  8590. + } else {
  8591. + pr_debug("Property %s not available\n", prop);
  8592. + *nports = 0;
  8593. + return NULL;
  8594. + }
  8595. +
  8596. + if (!size) {
  8597. + *nports = 0;
  8598. + return NULL;
  8599. + }
  8600. +
  8601. + arr = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
  8602. + if (ZERO_OR_NULL_PTR(arr)) {
  8603. + pr_err("Error: Failed to alloc mem for %s\n", prop);
  8604. + return NULL;
  8605. + }
  8606. +
  8607. + ret = of_property_read_u32_array(node, prop, (u32 *)arr, *nports);
  8608. + if (ret) {
  8609. + pr_err("Error in reading property: %s\n", prop);
  8610. + goto err;
  8611. + }
  8612. +
  8613. + return arr;
  8614. +err:
  8615. + devm_kfree(&pdev->dev, arr);
  8616. + return NULL;
  8617. +}
  8618. +
  8619. +static u64 *get_th_params(struct platform_device *pdev,
  8620. + const struct device_node *node, const char *prop,
  8621. + int *nports)
  8622. +{
  8623. + int size = 0, ret;
  8624. + u64 *ret_arr = NULL;
  8625. + int *arr = NULL;
  8626. + int i;
  8627. +
  8628. + if (of_get_property(node, prop, &size)) {
  8629. + *nports = size / sizeof(int);
  8630. + } else {
  8631. + pr_debug("Property %s not available\n", prop);
  8632. + *nports = 0;
  8633. + return NULL;
  8634. + }
  8635. +
  8636. + if (!size) {
  8637. + *nports = 0;
  8638. + return NULL;
  8639. + }
  8640. +
  8641. + ret_arr = devm_kzalloc(&pdev->dev, (*nports * sizeof(u64)),
  8642. + GFP_KERNEL);
  8643. + if (ZERO_OR_NULL_PTR(ret_arr)) {
  8644. + pr_err("Error: Failed to alloc mem for ret arr %s\n", prop);
  8645. + return NULL;
  8646. + }
  8647. +
  8648. + arr = kzalloc(size, GFP_KERNEL);
  8649. + if ((ZERO_OR_NULL_PTR(arr))) {
  8650. + pr_err("Error: Failed to alloc temp mem for %s\n", prop);
  8651. + return NULL;
  8652. + }
  8653. +
  8654. + ret = of_property_read_u32_array(node, prop, (u32 *)arr, *nports);
  8655. + if (ret) {
  8656. + pr_err("Error in reading property: %s\n", prop);
  8657. + goto err;
  8658. + }
  8659. +
  8660. + for (i = 0; i < *nports; i++)
  8661. + ret_arr[i] = (uint64_t)KBTOB(arr[i]);
  8662. +
  8663. + MSM_BUS_DBG("%s: num entries %d prop %s", __func__, *nports, prop);
  8664. +
  8665. + for (i = 0; i < *nports; i++)
  8666. + MSM_BUS_DBG("Th %d val %llu", i, ret_arr[i]);
  8667. +
  8668. + kfree(arr);
  8669. + return ret_arr;
  8670. +err:
  8671. + kfree(arr);
  8672. + devm_kfree(&pdev->dev, ret_arr);
  8673. + return NULL;
  8674. +}
  8675. +
  8676. +static struct msm_bus_node_info *get_nodes(struct device_node *of_node,
  8677. + struct platform_device *pdev,
  8678. + struct msm_bus_fabric_registration *pdata)
  8679. +{
  8680. + struct msm_bus_node_info *info;
  8681. + struct device_node *child_node = NULL;
  8682. + int i = 0, ret;
  8683. + int num_bw = 0;
  8684. + u32 temp;
  8685. +
  8686. + for_each_child_of_node(of_node, child_node) {
  8687. + i++;
  8688. + }
  8689. +
  8690. + pdata->len = i;
  8691. + info = (struct msm_bus_node_info *)
  8692. + devm_kzalloc(&pdev->dev, sizeof(struct msm_bus_node_info) *
  8693. + pdata->len, GFP_KERNEL);
  8694. + if (ZERO_OR_NULL_PTR(info)) {
  8695. + pr_err("Failed to alloc memory for nodes: %d\n", pdata->len);
  8696. + goto err;
  8697. + }
  8698. +
  8699. + i = 0;
  8700. + child_node = NULL;
  8701. + for_each_child_of_node(of_node, child_node) {
  8702. + const char *sel_str;
  8703. +
  8704. + ret = of_property_read_string(child_node, "label",
  8705. + &info[i].name);
  8706. + if (ret)
  8707. + pr_err("Error reading node label\n");
  8708. +
  8709. + ret = of_property_read_u32(child_node, "cell-id", &info[i].id);
  8710. + if (ret) {
  8711. + pr_err("Error reading node id\n");
  8712. + goto err;
  8713. + }
  8714. +
  8715. + if (of_property_read_bool(child_node, "qcom,gateway"))
  8716. + info[i].gateway = 1;
  8717. +
  8718. + of_property_read_u32(child_node, "qcom,mas-hw-id",
  8719. + &info[i].mas_hw_id);
  8720. +
  8721. + of_property_read_u32(child_node, "qcom,slv-hw-id",
  8722. + &info[i].slv_hw_id);
  8723. + info[i].masterp = get_arr(pdev, child_node,
  8724. + "qcom,masterp", &info[i].num_mports);
  8725. + /* No need to store number of qports */
  8726. + info[i].qport = get_arr(pdev, child_node,
  8727. + "qcom,qport", &ret);
  8728. + pdata->nmasters += info[i].num_mports;
  8729. +
  8730. +
  8731. + info[i].slavep = get_arr(pdev, child_node,
  8732. + "qcom,slavep", &info[i].num_sports);
  8733. + pdata->nslaves += info[i].num_sports;
  8734. +
  8735. +
  8736. + info[i].tier = get_arr(pdev, child_node,
  8737. + "qcom,tier", &info[i].num_tiers);
  8738. +
  8739. + if (of_property_read_bool(child_node, "qcom,ahb"))
  8740. + info[i].ahb = 1;
  8741. +
  8742. + ret = of_property_read_string(child_node, "qcom,hw-sel",
  8743. + &sel_str);
  8744. + if (ret)
  8745. + info[i].hw_sel = 0;
  8746. + else {
  8747. + ret = get_num(hw_sel_name, sel_str);
  8748. + if (ret < 0) {
  8749. + pr_err("Invalid hw-sel\n");
  8750. + goto err;
  8751. + }
  8752. +
  8753. + info[i].hw_sel = ret;
  8754. + }
  8755. +
  8756. + of_property_read_u32(child_node, "qcom,buswidth",
  8757. + &info[i].buswidth);
  8758. + of_property_read_u32(child_node, "qcom,ws", &info[i].ws);
  8759. +
  8760. + info[i].dual_conf =
  8761. + of_property_read_bool(child_node, "qcom,dual-conf");
  8762. +
  8763. +
  8764. + info[i].th = get_th_params(pdev, child_node, "qcom,thresh",
  8765. + &info[i].num_thresh);
  8766. +
  8767. + info[i].bimc_bw = get_th_params(pdev, child_node,
  8768. + "qcom,bimc,bw", &num_bw);
  8769. +
  8770. + if (num_bw != info[i].num_thresh) {
  8771. + pr_err("%s:num_bw %d must equal num_thresh %d",
  8772. + __func__, num_bw, info[i].num_thresh);
  8773. + pr_err("%s:Err setting up dual conf for %s",
  8774. + __func__, info[i].name);
  8775. + goto err;
  8776. + }
  8777. +
  8778. + of_property_read_u32(child_node, "qcom,bimc,gp",
  8779. + &info[i].bimc_gp);
  8780. + of_property_read_u32(child_node, "qcom,bimc,thmp",
  8781. + &info[i].bimc_thmp);
  8782. +
  8783. + ret = of_property_read_string(child_node, "qcom,mode-thresh",
  8784. + &sel_str);
  8785. + if (ret)
  8786. + info[i].mode_thresh = 0;
  8787. + else {
  8788. + ret = get_num(mode_sel_name, sel_str);
  8789. + if (ret < 0) {
  8790. + pr_err("Unknown mode :%s\n", sel_str);
  8791. + goto err;
  8792. + }
  8793. +
  8794. + info[i].mode_thresh = ret;
  8795. + MSM_BUS_DBG("AXI: THreshold mode set: %d\n",
  8796. + info[i].mode_thresh);
  8797. + }
  8798. +
  8799. + ret = of_property_read_string(child_node, "qcom,mode",
  8800. + &sel_str);
  8801. +
  8802. + if (ret)
  8803. + info[i].mode = 0;
  8804. + else {
  8805. + ret = get_num(mode_sel_name, sel_str);
  8806. + if (ret < 0) {
  8807. + pr_err("Unknown mode :%s\n", sel_str);
  8808. + goto err;
  8809. + }
  8810. +
  8811. + info[i].mode = ret;
  8812. + }
  8813. +
  8814. + info[i].nr_lim =
  8815. + of_property_read_bool(child_node, "qcom,nr-lim");
  8816. +
  8817. + ret = of_property_read_u32(child_node, "qcom,ff",
  8818. + &info[i].ff);
  8819. + if (ret) {
  8820. + pr_debug("fudge factor not present %d", info[i].id);
  8821. + info[i].ff = 0;
  8822. + }
  8823. +
  8824. + ret = of_property_read_u32(child_node, "qcom,floor-bw",
  8825. + &temp);
  8826. + if (ret) {
  8827. + pr_debug("fabdev floor bw not present %d", info[i].id);
  8828. + info[i].floor_bw = 0;
  8829. + } else {
  8830. + info[i].floor_bw = KBTOB(temp);
  8831. + }
  8832. +
  8833. + info[i].rt_mas =
  8834. + of_property_read_bool(child_node, "qcom,rt-mas");
  8835. +
  8836. + ret = of_property_read_string(child_node, "qcom,perm-mode",
  8837. + &sel_str);
  8838. + if (ret)
  8839. + info[i].perm_mode = 0;
  8840. + else {
  8841. + ret = get_num(mode_sel_name, sel_str);
  8842. + if (ret < 0)
  8843. + goto err;
  8844. +
  8845. + info[i].perm_mode = 1 << ret;
  8846. + }
  8847. +
  8848. + of_property_read_u32(child_node, "qcom,prio-lvl",
  8849. + &info[i].prio_lvl);
  8850. + of_property_read_u32(child_node, "qcom,prio-rd",
  8851. + &info[i].prio_rd);
  8852. + of_property_read_u32(child_node, "qcom,prio-wr",
  8853. + &info[i].prio_wr);
  8854. + of_property_read_u32(child_node, "qcom,prio0", &info[i].prio0);
  8855. + of_property_read_u32(child_node, "qcom,prio1", &info[i].prio1);
  8856. + ret = of_property_read_string(child_node, "qcom,slaveclk-dual",
  8857. + &info[i].slaveclk[DUAL_CTX]);
  8858. + if (!ret)
  8859. + pr_debug("Got slaveclk_dual: %s\n",
  8860. + info[i].slaveclk[DUAL_CTX]);
  8861. + else
  8862. + info[i].slaveclk[DUAL_CTX] = NULL;
  8863. +
  8864. + ret = of_property_read_string(child_node,
  8865. + "qcom,slaveclk-active", &info[i].slaveclk[ACTIVE_CTX]);
  8866. + if (!ret)
  8867. + pr_debug("Got slaveclk_active\n");
  8868. + else
  8869. + info[i].slaveclk[ACTIVE_CTX] = NULL;
  8870. +
  8871. + ret = of_property_read_string(child_node, "qcom,memclk-dual",
  8872. + &info[i].memclk[DUAL_CTX]);
  8873. + if (!ret)
  8874. + pr_debug("Got memclk_dual\n");
  8875. + else
  8876. + info[i].memclk[DUAL_CTX] = NULL;
  8877. +
  8878. + ret = of_property_read_string(child_node, "qcom,memclk-active",
  8879. + &info[i].memclk[ACTIVE_CTX]);
  8880. + if (!ret)
  8881. + pr_debug("Got memclk_active\n");
  8882. + else
  8883. + info[i].memclk[ACTIVE_CTX] = NULL;
  8884. +
  8885. + ret = of_property_read_string(child_node, "qcom,iface-clk-node",
  8886. + &info[i].iface_clk_node);
  8887. + if (!ret)
  8888. + pr_debug("Got iface_clk_node\n");
  8889. + else
  8890. + info[i].iface_clk_node = NULL;
  8891. +
  8892. + pr_debug("Node name: %s\n", info[i].name);
  8893. + of_node_put(child_node);
  8894. + i++;
  8895. + }
  8896. +
  8897. + pr_debug("Bus %d added: %d masters\n", pdata->id, pdata->nmasters);
  8898. + pr_debug("Bus %d added: %d slaves\n", pdata->id, pdata->nslaves);
  8899. + return info;
  8900. +err:
  8901. + return NULL;
  8902. +}
  8903. +
  8904. +void msm_bus_of_get_nfab(struct platform_device *pdev,
  8905. + struct msm_bus_fabric_registration *pdata)
  8906. +{
  8907. + struct device_node *of_node;
  8908. + int ret, nfab = 0;
  8909. +
  8910. + if (!pdev) {
  8911. + pr_err("Error: Null platform device\n");
  8912. + return;
  8913. + }
  8914. +
  8915. + of_node = pdev->dev.of_node;
  8916. + ret = of_property_read_u32(of_node, "qcom,nfab",
  8917. + &nfab);
  8918. + if (!ret)
  8919. + pr_debug("Fab_of: Read number of buses: %u\n", nfab);
  8920. +
  8921. + msm_bus_board_set_nfab(pdata, nfab);
  8922. +}
  8923. +
  8924. +struct msm_bus_fabric_registration
  8925. + *msm_bus_of_get_fab_data(struct platform_device *pdev)
  8926. +{
  8927. + struct device_node *of_node;
  8928. + struct msm_bus_fabric_registration *pdata;
  8929. + bool mem_err = false;
  8930. + int ret = 0;
  8931. + const char *sel_str;
  8932. + u32 temp;
  8933. +
  8934. + if (!pdev) {
  8935. + pr_err("Error: Null platform device\n");
  8936. + return NULL;
  8937. + }
  8938. +
  8939. + of_node = pdev->dev.of_node;
  8940. + pdata = devm_kzalloc(&pdev->dev,
  8941. + sizeof(struct msm_bus_fabric_registration), GFP_KERNEL);
  8942. + if (!pdata) {
  8943. + pr_err("Error: Memory allocation for pdata failed\n");
  8944. + mem_err = true;
  8945. + goto err;
  8946. + }
  8947. +
  8948. + ret = of_property_read_string(of_node, "label", &pdata->name);
  8949. + if (ret) {
  8950. + pr_err("Error: label not found\n");
  8951. + goto err;
  8952. + }
  8953. + pr_debug("Fab_of: Read name: %s\n", pdata->name);
  8954. +
  8955. + ret = of_property_read_u32(of_node, "cell-id",
  8956. + &pdata->id);
  8957. + if (ret) {
  8958. + pr_err("Error: num-usecases not found\n");
  8959. + goto err;
  8960. + }
  8961. + pr_debug("Fab_of: Read id: %u\n", pdata->id);
  8962. +
  8963. + if (of_property_read_bool(of_node, "qcom,ahb"))
  8964. + pdata->ahb = 1;
  8965. +
  8966. + ret = of_property_read_string(of_node, "qcom,fabclk-dual",
  8967. + &pdata->fabclk[DUAL_CTX]);
  8968. + if (ret) {
  8969. + pr_debug("fabclk_dual not available\n");
  8970. + pdata->fabclk[DUAL_CTX] = NULL;
  8971. + } else
  8972. + pr_debug("Fab_of: Read clk dual ctx: %s\n",
  8973. + pdata->fabclk[DUAL_CTX]);
  8974. + ret = of_property_read_string(of_node, "qcom,fabclk-active",
  8975. + &pdata->fabclk[ACTIVE_CTX]);
  8976. + if (ret) {
  8977. + pr_debug("Error: fabclk_active not available\n");
  8978. + pdata->fabclk[ACTIVE_CTX] = NULL;
  8979. + } else
  8980. + pr_debug("Fab_of: Read clk act ctx: %s\n",
  8981. + pdata->fabclk[ACTIVE_CTX]);
  8982. +
  8983. + ret = of_property_read_u32(of_node, "qcom,ntieredslaves",
  8984. + &pdata->ntieredslaves);
  8985. + if (ret) {
  8986. + pr_err("Error: ntieredslaves not found\n");
  8987. + goto err;
  8988. + }
  8989. +
  8990. + ret = of_property_read_u32(of_node, "qcom,qos-freq", &pdata->qos_freq);
  8991. + if (ret)
  8992. + pr_debug("qos_freq not available\n");
  8993. +
  8994. + ret = of_property_read_string(of_node, "qcom,hw-sel", &sel_str);
  8995. + if (ret) {
  8996. + pr_err("Error: hw_sel not found\n");
  8997. + goto err;
  8998. + } else {
  8999. + ret = get_num(hw_sel_name, sel_str);
  9000. + if (ret < 0)
  9001. + goto err;
  9002. +
  9003. + pdata->hw_sel = ret;
  9004. + }
  9005. +
  9006. + if (of_property_read_bool(of_node, "qcom,virt"))
  9007. + pdata->virt = true;
  9008. +
  9009. + ret = of_property_read_u32(of_node, "qcom,qos-baseoffset",
  9010. + &pdata->qos_baseoffset);
  9011. + if (ret)
  9012. + pr_debug("%s:qos_baseoffset not available\n", __func__);
  9013. +
  9014. + ret = of_property_read_u32(of_node, "qcom,qos-delta",
  9015. + &pdata->qos_delta);
  9016. + if (ret)
  9017. + pr_debug("%s:qos_delta not available\n", __func__);
  9018. +
  9019. + if (of_property_read_bool(of_node, "qcom,rpm-en"))
  9020. + pdata->rpm_enabled = 1;
  9021. +
  9022. + ret = of_property_read_u32(of_node, "qcom,nr-lim-thresh",
  9023. + &temp);
  9024. +
  9025. + if (ret) {
  9026. + pr_err("nr-lim threshold not specified");
  9027. + pdata->nr_lim_thresh = 0;
  9028. + } else {
  9029. + pdata->nr_lim_thresh = KBTOB(temp);
  9030. + }
  9031. +
  9032. + ret = of_property_read_u32(of_node, "qcom,eff-fact",
  9033. + &pdata->eff_fact);
  9034. + if (ret) {
  9035. + pr_err("Fab eff-factor not present");
  9036. + pdata->eff_fact = 0;
  9037. + }
  9038. +
  9039. + pdata->info = get_nodes(of_node, pdev, pdata);
  9040. + return pdata;
  9041. +err:
  9042. + return NULL;
  9043. +}
  9044. +EXPORT_SYMBOL(msm_bus_of_get_fab_data);
  9045. --- /dev/null
  9046. +++ b/drivers/bus/msm_bus/msm_bus_of_adhoc.c
  9047. @@ -0,0 +1,641 @@
  9048. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  9049. + *
  9050. + * This program is free software; you can redistribute it and/or modify
  9051. + * it under the terms of the GNU General Public License version 2 and
  9052. + * only version 2 as published by the Free Software Foundation.
  9053. + *
  9054. + * This program is distributed in the hope that it will be useful,
  9055. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9056. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9057. + * GNU General Public License for more details.
  9058. + */
  9059. +
  9060. +#define pr_fmt(fmt) "AXI: %s(): " fmt, __func__
  9061. +
  9062. +#include <linux/clk.h>
  9063. +#include <linux/device.h>
  9064. +#include <linux/module.h>
  9065. +#include <linux/slab.h>
  9066. +#include <linux/string.h>
  9067. +#include <linux/of.h>
  9068. +#include <linux/of_device.h>
  9069. +#include <linux/platform_device.h>
  9070. +#include "msm-bus.h"
  9071. +#include "msm-bus-board.h"
  9072. +#include "msm_bus_rules.h"
  9073. +#include "msm_bus_core.h"
  9074. +#include "msm_bus_adhoc.h"
  9075. +
  9076. +#define DEFAULT_QOS_FREQ 19200
  9077. +#define DEFAULT_UTIL_FACT 100
  9078. +#define DEFAULT_VRAIL_COMP 100
  9079. +
  9080. +static int get_qos_mode(struct platform_device *pdev,
  9081. + struct device_node *node, const char *qos_mode)
  9082. +{
  9083. + const char *qos_names[] = {"fixed", "limiter", "bypass", "regulator"};
  9084. + int i = 0;
  9085. + int ret = -1;
  9086. +
  9087. + if (!qos_mode)
  9088. + goto exit_get_qos_mode;
  9089. +
  9090. + for (i = 0; i < ARRAY_SIZE(qos_names); i++) {
  9091. + if (!strcmp(qos_mode, qos_names[i]))
  9092. + break;
  9093. + }
  9094. + if (i == ARRAY_SIZE(qos_names))
  9095. + dev_err(&pdev->dev, "Cannot match mode qos %s using Bypass",
  9096. + qos_mode);
  9097. + else
  9098. + ret = i;
  9099. +
  9100. +exit_get_qos_mode:
  9101. + return ret;
  9102. +}
  9103. +
  9104. +static int *get_arr(struct platform_device *pdev,
  9105. + struct device_node *node, const char *prop,
  9106. + int *nports)
  9107. +{
  9108. + int size = 0, ret;
  9109. + int *arr = NULL;
  9110. +
  9111. + if (of_get_property(node, prop, &size)) {
  9112. + *nports = size / sizeof(int);
  9113. + } else {
  9114. + dev_dbg(&pdev->dev, "Property %s not available\n", prop);
  9115. + *nports = 0;
  9116. + return NULL;
  9117. + }
  9118. +
  9119. + arr = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
  9120. + if ((size > 0) && ZERO_OR_NULL_PTR(arr)) {
  9121. + dev_err(&pdev->dev, "Error: Failed to alloc mem for %s\n",
  9122. + prop);
  9123. + return NULL;
  9124. + }
  9125. +
  9126. + ret = of_property_read_u32_array(node, prop, (u32 *)arr, *nports);
  9127. + if (ret) {
  9128. + dev_err(&pdev->dev, "Error in reading property: %s\n", prop);
  9129. + goto arr_err;
  9130. + }
  9131. +
  9132. + return arr;
  9133. +arr_err:
  9134. + devm_kfree(&pdev->dev, arr);
  9135. + return NULL;
  9136. +}
  9137. +
  9138. +static struct msm_bus_fab_device_type *get_fab_device_info(
  9139. + struct device_node *dev_node,
  9140. + struct platform_device *pdev)
  9141. +{
  9142. + struct msm_bus_fab_device_type *fab_dev;
  9143. + unsigned int ret;
  9144. + struct resource *res;
  9145. + const char *base_name;
  9146. +
  9147. + fab_dev = devm_kzalloc(&pdev->dev,
  9148. + sizeof(struct msm_bus_fab_device_type),
  9149. + GFP_KERNEL);
  9150. + if (!fab_dev) {
  9151. + dev_err(&pdev->dev,
  9152. + "Error: Unable to allocate memory for fab_dev\n");
  9153. + return NULL;
  9154. + }
  9155. +
  9156. + ret = of_property_read_string(dev_node, "qcom,base-name", &base_name);
  9157. + if (ret) {
  9158. + dev_err(&pdev->dev, "Error: Unable to get base address name\n");
  9159. + goto fab_dev_err;
  9160. + }
  9161. +
  9162. + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, base_name);
  9163. + if (!res) {
  9164. + dev_err(&pdev->dev, "Error getting qos base addr %s\n",
  9165. + base_name);
  9166. + goto fab_dev_err;
  9167. + }
  9168. + fab_dev->pqos_base = res->start;
  9169. + fab_dev->qos_range = resource_size(res);
  9170. + fab_dev->bypass_qos_prg = of_property_read_bool(dev_node,
  9171. + "qcom,bypass-qos-prg");
  9172. +
  9173. + ret = of_property_read_u32(dev_node, "qcom,base-offset",
  9174. + &fab_dev->base_offset);
  9175. + if (ret)
  9176. + dev_dbg(&pdev->dev, "Bus base offset is missing\n");
  9177. +
  9178. + ret = of_property_read_u32(dev_node, "qcom,qos-off",
  9179. + &fab_dev->qos_off);
  9180. + if (ret)
  9181. + dev_dbg(&pdev->dev, "Bus qos off is missing\n");
  9182. +
  9183. +
  9184. + ret = of_property_read_u32(dev_node, "qcom,bus-type",
  9185. + &fab_dev->bus_type);
  9186. + if (ret) {
  9187. + dev_warn(&pdev->dev, "Bus type is missing\n");
  9188. + goto fab_dev_err;
  9189. + }
  9190. +
  9191. + ret = of_property_read_u32(dev_node, "qcom,qos-freq",
  9192. + &fab_dev->qos_freq);
  9193. + if (ret) {
  9194. + dev_dbg(&pdev->dev, "Bus qos freq is missing\n");
  9195. + fab_dev->qos_freq = DEFAULT_QOS_FREQ;
  9196. + }
  9197. +
  9198. + ret = of_property_read_u32(dev_node, "qcom,util-fact",
  9199. + &fab_dev->util_fact);
  9200. + if (ret) {
  9201. + dev_info(&pdev->dev, "Util-fact is missing, default to %d\n",
  9202. + DEFAULT_UTIL_FACT);
  9203. + fab_dev->util_fact = DEFAULT_UTIL_FACT;
  9204. + }
  9205. +
  9206. + ret = of_property_read_u32(dev_node, "qcom,vrail-comp",
  9207. + &fab_dev->vrail_comp);
  9208. + if (ret) {
  9209. + dev_info(&pdev->dev, "Vrail-comp is missing, default to %d\n",
  9210. + DEFAULT_VRAIL_COMP);
  9211. + fab_dev->vrail_comp = DEFAULT_VRAIL_COMP;
  9212. + }
  9213. +
  9214. + return fab_dev;
  9215. +
  9216. +fab_dev_err:
  9217. + devm_kfree(&pdev->dev, fab_dev);
  9218. + fab_dev = 0;
  9219. + return NULL;
  9220. +}
  9221. +
  9222. +static void get_qos_params(
  9223. + struct device_node * const dev_node,
  9224. + struct platform_device * const pdev,
  9225. + struct msm_bus_node_info_type *node_info)
  9226. +{
  9227. + const char *qos_mode = NULL;
  9228. + unsigned int ret;
  9229. + unsigned int temp;
  9230. +
  9231. + ret = of_property_read_string(dev_node, "qcom,qos-mode", &qos_mode);
  9232. +
  9233. + if (ret)
  9234. + node_info->qos_params.mode = -1;
  9235. + else
  9236. + node_info->qos_params.mode = get_qos_mode(pdev, dev_node,
  9237. + qos_mode);
  9238. +
  9239. + of_property_read_u32(dev_node, "qcom,prio-lvl",
  9240. + &node_info->qos_params.prio_lvl);
  9241. +
  9242. + of_property_read_u32(dev_node, "qcom,prio1",
  9243. + &node_info->qos_params.prio1);
  9244. +
  9245. + of_property_read_u32(dev_node, "qcom,prio0",
  9246. + &node_info->qos_params.prio0);
  9247. +
  9248. + of_property_read_u32(dev_node, "qcom,prio-rd",
  9249. + &node_info->qos_params.prio_rd);
  9250. +
  9251. + of_property_read_u32(dev_node, "qcom,prio-wr",
  9252. + &node_info->qos_params.prio_wr);
  9253. +
  9254. + of_property_read_u32(dev_node, "qcom,gp",
  9255. + &node_info->qos_params.gp);
  9256. +
  9257. + of_property_read_u32(dev_node, "qcom,thmp",
  9258. + &node_info->qos_params.thmp);
  9259. +
  9260. + of_property_read_u32(dev_node, "qcom,ws",
  9261. + &node_info->qos_params.ws);
  9262. +
  9263. + ret = of_property_read_u32(dev_node, "qcom,bw_buffer", &temp);
  9264. +
  9265. + if (ret)
  9266. + node_info->qos_params.bw_buffer = 0;
  9267. + else
  9268. + node_info->qos_params.bw_buffer = KBTOB(temp);
  9269. +
  9270. +}
  9271. +
  9272. +
  9273. +static struct msm_bus_node_info_type *get_node_info_data(
  9274. + struct device_node * const dev_node,
  9275. + struct platform_device * const pdev)
  9276. +{
  9277. + struct msm_bus_node_info_type *node_info;
  9278. + unsigned int ret;
  9279. + int size;
  9280. + int i;
  9281. + struct device_node *con_node;
  9282. + struct device_node *bus_dev;
  9283. +
  9284. + node_info = devm_kzalloc(&pdev->dev,
  9285. + sizeof(struct msm_bus_node_info_type),
  9286. + GFP_KERNEL);
  9287. + if (!node_info) {
  9288. + dev_err(&pdev->dev,
  9289. + "Error: Unable to allocate memory for node_info\n");
  9290. + return NULL;
  9291. + }
  9292. +
  9293. + ret = of_property_read_u32(dev_node, "cell-id", &node_info->id);
  9294. + if (ret) {
  9295. + dev_warn(&pdev->dev, "Bus node is missing cell-id\n");
  9296. + goto node_info_err;
  9297. + }
  9298. + ret = of_property_read_string(dev_node, "label", &node_info->name);
  9299. + if (ret) {
  9300. + dev_warn(&pdev->dev, "Bus node is missing name\n");
  9301. + goto node_info_err;
  9302. + }
  9303. + node_info->qport = get_arr(pdev, dev_node, "qcom,qport",
  9304. + &node_info->num_qports);
  9305. +
  9306. + if (of_get_property(dev_node, "qcom,connections", &size)) {
  9307. + node_info->num_connections = size / sizeof(int);
  9308. + node_info->connections = devm_kzalloc(&pdev->dev, size,
  9309. + GFP_KERNEL);
  9310. + } else {
  9311. + node_info->num_connections = 0;
  9312. + node_info->connections = 0;
  9313. + }
  9314. +
  9315. + for (i = 0; i < node_info->num_connections; i++) {
  9316. + con_node = of_parse_phandle(dev_node, "qcom,connections", i);
  9317. + if (IS_ERR_OR_NULL(con_node))
  9318. + goto node_info_err;
  9319. +
  9320. + if (of_property_read_u32(con_node, "cell-id",
  9321. + &node_info->connections[i]))
  9322. + goto node_info_err;
  9323. + of_node_put(con_node);
  9324. + }
  9325. +
  9326. + if (of_get_property(dev_node, "qcom,blacklist", &size)) {
  9327. + node_info->num_blist = size/sizeof(u32);
  9328. + node_info->black_listed_connections = devm_kzalloc(&pdev->dev,
  9329. + size, GFP_KERNEL);
  9330. + } else {
  9331. + node_info->num_blist = 0;
  9332. + node_info->black_listed_connections = 0;
  9333. + }
  9334. +
  9335. + for (i = 0; i < node_info->num_blist; i++) {
  9336. + con_node = of_parse_phandle(dev_node, "qcom,blacklist", i);
  9337. + if (IS_ERR_OR_NULL(con_node))
  9338. + goto node_info_err;
  9339. +
  9340. + if (of_property_read_u32(con_node, "cell-id",
  9341. + &node_info->black_listed_connections[i]))
  9342. + goto node_info_err;
  9343. + of_node_put(con_node);
  9344. + }
  9345. +
  9346. + bus_dev = of_parse_phandle(dev_node, "qcom,bus-dev", 0);
  9347. + if (!IS_ERR_OR_NULL(bus_dev)) {
  9348. + if (of_property_read_u32(bus_dev, "cell-id",
  9349. + &node_info->bus_device_id)) {
  9350. + dev_err(&pdev->dev, "Can't find bus device. Node %d",
  9351. + node_info->id);
  9352. + goto node_info_err;
  9353. + }
  9354. +
  9355. + of_node_put(bus_dev);
  9356. + } else
  9357. + dev_dbg(&pdev->dev, "Can't find bdev phandle for %d",
  9358. + node_info->id);
  9359. +
  9360. + node_info->is_fab_dev = of_property_read_bool(dev_node, "qcom,fab-dev");
  9361. + node_info->virt_dev = of_property_read_bool(dev_node, "qcom,virt-dev");
  9362. +
  9363. + ret = of_property_read_u32(dev_node, "qcom,buswidth",
  9364. + &node_info->buswidth);
  9365. + if (ret) {
  9366. + dev_dbg(&pdev->dev, "Using default 8 bytes %d", node_info->id);
  9367. + node_info->buswidth = 8;
  9368. + }
  9369. +
  9370. + ret = of_property_read_u32(dev_node, "qcom,mas-rpm-id",
  9371. + &node_info->mas_rpm_id);
  9372. + if (ret) {
  9373. + dev_dbg(&pdev->dev, "mas rpm id is missing\n");
  9374. + node_info->mas_rpm_id = -1;
  9375. + }
  9376. +
  9377. + ret = of_property_read_u32(dev_node, "qcom,slv-rpm-id",
  9378. + &node_info->slv_rpm_id);
  9379. + if (ret) {
  9380. + dev_dbg(&pdev->dev, "slv rpm id is missing\n");
  9381. + node_info->slv_rpm_id = -1;
  9382. + }
  9383. + ret = of_property_read_u32(dev_node, "qcom,util-fact",
  9384. + &node_info->util_fact);
  9385. + if (ret)
  9386. + node_info->util_fact = 0;
  9387. + ret = of_property_read_u32(dev_node, "qcom,vrail-comp",
  9388. + &node_info->vrail_comp);
  9389. + if (ret)
  9390. + node_info->vrail_comp = 0;
  9391. + get_qos_params(dev_node, pdev, node_info);
  9392. +
  9393. + return node_info;
  9394. +
  9395. +node_info_err:
  9396. + devm_kfree(&pdev->dev, node_info);
  9397. + node_info = 0;
  9398. + return NULL;
  9399. +}
  9400. +
  9401. +static unsigned int get_bus_node_device_data(
  9402. + struct device_node * const dev_node,
  9403. + struct platform_device * const pdev,
  9404. + struct msm_bus_node_device_type * const node_device)
  9405. +{
  9406. + node_device->node_info = get_node_info_data(dev_node, pdev);
  9407. + if (IS_ERR_OR_NULL(node_device->node_info)) {
  9408. + dev_err(&pdev->dev, "Error: Node info missing\n");
  9409. + return -ENODATA;
  9410. + }
  9411. + node_device->ap_owned = of_property_read_bool(dev_node,
  9412. + "qcom,ap-owned");
  9413. +
  9414. + if (node_device->node_info->is_fab_dev) {
  9415. + dev_dbg(&pdev->dev, "Dev %d\n", node_device->node_info->id);
  9416. +
  9417. + if (!node_device->node_info->virt_dev) {
  9418. + node_device->fabdev =
  9419. + get_fab_device_info(dev_node, pdev);
  9420. + if (IS_ERR_OR_NULL(node_device->fabdev)) {
  9421. + dev_err(&pdev->dev,
  9422. + "Error: Fabric device info missing\n");
  9423. + devm_kfree(&pdev->dev, node_device->node_info);
  9424. + return -ENODATA;
  9425. + }
  9426. + }
  9427. + node_device->clk[DUAL_CTX].clk = of_clk_get_by_name(dev_node,
  9428. + "bus_clk");
  9429. +
  9430. + if (IS_ERR_OR_NULL(node_device->clk[DUAL_CTX].clk))
  9431. + dev_dbg(&pdev->dev,
  9432. + "%s:Failed to get bus clk for bus%d ctx%d",
  9433. + __func__, node_device->node_info->id,
  9434. + DUAL_CTX);
  9435. +
  9436. + node_device->clk[ACTIVE_CTX].clk = of_clk_get_by_name(dev_node,
  9437. + "bus_a_clk");
  9438. + if (IS_ERR_OR_NULL(node_device->clk[ACTIVE_CTX].clk))
  9439. + dev_err(&pdev->dev,
  9440. + "Failed to get bus clk for bus%d ctx%d",
  9441. + node_device->node_info->id, ACTIVE_CTX);
  9442. + if (msmbus_coresight_init_adhoc(pdev, dev_node))
  9443. + dev_warn(&pdev->dev,
  9444. + "Coresight support absent for bus: %d\n",
  9445. + node_device->node_info->id);
  9446. + } else {
  9447. + node_device->qos_clk.clk = of_clk_get_by_name(dev_node,
  9448. + "bus_qos_clk");
  9449. +
  9450. + if (IS_ERR_OR_NULL(node_device->qos_clk.clk))
  9451. + dev_dbg(&pdev->dev,
  9452. + "%s:Failed to get bus qos clk for mas%d",
  9453. + __func__, node_device->node_info->id);
  9454. +
  9455. + node_device->clk[DUAL_CTX].clk = of_clk_get_by_name(dev_node,
  9456. + "node_clk");
  9457. +
  9458. + if (IS_ERR_OR_NULL(node_device->clk[DUAL_CTX].clk))
  9459. + dev_dbg(&pdev->dev,
  9460. + "%s:Failed to get bus clk for bus%d ctx%d",
  9461. + __func__, node_device->node_info->id,
  9462. + DUAL_CTX);
  9463. +
  9464. + }
  9465. + return 0;
  9466. +}
  9467. +
  9468. +struct msm_bus_device_node_registration
  9469. + *msm_bus_of_to_pdata(struct platform_device *pdev)
  9470. +{
  9471. + struct device_node *of_node, *child_node;
  9472. + struct msm_bus_device_node_registration *pdata;
  9473. + unsigned int i = 0, j;
  9474. + unsigned int ret;
  9475. +
  9476. + if (!pdev) {
  9477. + pr_err("Error: Null platform device\n");
  9478. + return NULL;
  9479. + }
  9480. +
  9481. + of_node = pdev->dev.of_node;
  9482. +
  9483. + pdata = devm_kzalloc(&pdev->dev,
  9484. + sizeof(struct msm_bus_device_node_registration),
  9485. + GFP_KERNEL);
  9486. + if (!pdata) {
  9487. + dev_err(&pdev->dev,
  9488. + "Error: Memory allocation for pdata failed\n");
  9489. + return NULL;
  9490. + }
  9491. +
  9492. + pdata->num_devices = of_get_child_count(of_node);
  9493. +
  9494. + pdata->info = devm_kzalloc(&pdev->dev,
  9495. + sizeof(struct msm_bus_node_device_type) *
  9496. + pdata->num_devices, GFP_KERNEL);
  9497. +
  9498. + if (!pdata->info) {
  9499. + dev_err(&pdev->dev,
  9500. + "Error: Memory allocation for pdata->info failed\n");
  9501. + goto node_reg_err;
  9502. + }
  9503. +
  9504. + ret = 0;
  9505. + for_each_child_of_node(of_node, child_node) {
  9506. + ret = get_bus_node_device_data(child_node, pdev,
  9507. + &pdata->info[i]);
  9508. + if (ret) {
  9509. + dev_err(&pdev->dev, "Error: unable to initialize bus nodes\n");
  9510. + goto node_reg_err_1;
  9511. + }
  9512. + i++;
  9513. + }
  9514. +
  9515. + dev_dbg(&pdev->dev, "bus topology:\n");
  9516. + for (i = 0; i < pdata->num_devices; i++) {
  9517. + dev_dbg(&pdev->dev, "id %d\nnum_qports %d\nnum_connections %d",
  9518. + pdata->info[i].node_info->id,
  9519. + pdata->info[i].node_info->num_qports,
  9520. + pdata->info[i].node_info->num_connections);
  9521. + dev_dbg(&pdev->dev, "\nbus_device_id %d\n buswidth %d\n",
  9522. + pdata->info[i].node_info->bus_device_id,
  9523. + pdata->info[i].node_info->buswidth);
  9524. + for (j = 0; j < pdata->info[i].node_info->num_connections;
  9525. + j++) {
  9526. + dev_dbg(&pdev->dev, "connection[%d]: %d\n", j,
  9527. + pdata->info[i].node_info->connections[j]);
  9528. + }
  9529. + for (j = 0; j < pdata->info[i].node_info->num_blist;
  9530. + j++) {
  9531. + dev_dbg(&pdev->dev, "black_listed_node[%d]: %d\n", j,
  9532. + pdata->info[i].node_info->
  9533. + black_listed_connections[j]);
  9534. + }
  9535. + if (pdata->info[i].fabdev)
  9536. + dev_dbg(&pdev->dev, "base_addr %zu\nbus_type %d\n",
  9537. + (size_t)pdata->info[i].
  9538. + fabdev->pqos_base,
  9539. + pdata->info[i].fabdev->bus_type);
  9540. + }
  9541. + return pdata;
  9542. +
  9543. +node_reg_err_1:
  9544. + devm_kfree(&pdev->dev, pdata->info);
  9545. +node_reg_err:
  9546. + devm_kfree(&pdev->dev, pdata);
  9547. + pdata = NULL;
  9548. + return NULL;
  9549. +}
  9550. +
  9551. +static int msm_bus_of_get_ids(struct platform_device *pdev,
  9552. + struct device_node *dev_node, int **dev_ids,
  9553. + int *num_ids, char *prop_name)
  9554. +{
  9555. + int ret = 0;
  9556. + int size, i;
  9557. + struct device_node *rule_node;
  9558. + int *ids = NULL;
  9559. +
  9560. + if (of_get_property(dev_node, prop_name, &size)) {
  9561. + *num_ids = size / sizeof(int);
  9562. + ids = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
  9563. + } else {
  9564. + dev_err(&pdev->dev, "No rule nodes, skipping node");
  9565. + ret = -ENXIO;
  9566. + goto exit_get_ids;
  9567. + }
  9568. +
  9569. + *dev_ids = ids;
  9570. + for (i = 0; i < *num_ids; i++) {
  9571. + rule_node = of_parse_phandle(dev_node, prop_name, i);
  9572. + if (IS_ERR_OR_NULL(rule_node)) {
  9573. + dev_err(&pdev->dev, "Can't get rule node id");
  9574. + ret = -ENXIO;
  9575. + goto err_get_ids;
  9576. + }
  9577. +
  9578. + if (of_property_read_u32(rule_node, "cell-id",
  9579. + &ids[i])) {
  9580. + dev_err(&pdev->dev, "Can't get rule node id");
  9581. + ret = -ENXIO;
  9582. + goto err_get_ids;
  9583. + }
  9584. + of_node_put(rule_node);
  9585. + }
  9586. +exit_get_ids:
  9587. + return ret;
  9588. +err_get_ids:
  9589. + devm_kfree(&pdev->dev, ids);
  9590. + of_node_put(rule_node);
  9591. + ids = NULL;
  9592. + return ret;
  9593. +}
  9594. +
  9595. +int msm_bus_of_get_static_rules(struct platform_device *pdev,
  9596. + struct bus_rule_type **static_rules)
  9597. +{
  9598. + int ret = 0;
  9599. + struct device_node *of_node, *child_node;
  9600. + int num_rules = 0;
  9601. + int rule_idx = 0;
  9602. + int bw_fld = 0;
  9603. + int i;
  9604. + struct bus_rule_type *static_rule = NULL;
  9605. +
  9606. + of_node = pdev->dev.of_node;
  9607. + num_rules = of_get_child_count(of_node);
  9608. + static_rule = devm_kzalloc(&pdev->dev,
  9609. + sizeof(struct bus_rule_type) * num_rules,
  9610. + GFP_KERNEL);
  9611. +
  9612. + if (IS_ERR_OR_NULL(static_rule)) {
  9613. + ret = -ENOMEM;
  9614. + goto exit_static_rules;
  9615. + }
  9616. +
  9617. + *static_rules = static_rule;
  9618. + for_each_child_of_node(of_node, child_node) {
  9619. + ret = msm_bus_of_get_ids(pdev, child_node,
  9620. + &static_rule[rule_idx].src_id,
  9621. + &static_rule[rule_idx].num_src,
  9622. + "qcom,src-nodes");
  9623. +
  9624. + ret = msm_bus_of_get_ids(pdev, child_node,
  9625. + &static_rule[rule_idx].dst_node,
  9626. + &static_rule[rule_idx].num_dst,
  9627. + "qcom,dest-node");
  9628. +
  9629. + ret = of_property_read_u32(child_node, "qcom,src-field",
  9630. + &static_rule[rule_idx].src_field);
  9631. + if (ret) {
  9632. + dev_err(&pdev->dev, "src-field missing");
  9633. + ret = -ENXIO;
  9634. + goto err_static_rules;
  9635. + }
  9636. +
  9637. + ret = of_property_read_u32(child_node, "qcom,src-op",
  9638. + &static_rule[rule_idx].op);
  9639. + if (ret) {
  9640. + dev_err(&pdev->dev, "src-op missing");
  9641. + ret = -ENXIO;
  9642. + goto err_static_rules;
  9643. + }
  9644. +
  9645. + ret = of_property_read_u32(child_node, "qcom,mode",
  9646. + &static_rule[rule_idx].mode);
  9647. + if (ret) {
  9648. + dev_err(&pdev->dev, "mode missing");
  9649. + ret = -ENXIO;
  9650. + goto err_static_rules;
  9651. + }
  9652. +
  9653. + ret = of_property_read_u32(child_node, "qcom,thresh", &bw_fld);
  9654. + if (ret) {
  9655. + dev_err(&pdev->dev, "thresh missing");
  9656. + ret = -ENXIO;
  9657. + goto err_static_rules;
  9658. + } else
  9659. + static_rule[rule_idx].thresh = KBTOB(bw_fld);
  9660. +
  9661. + ret = of_property_read_u32(child_node, "qcom,dest-bw",
  9662. + &bw_fld);
  9663. + if (ret)
  9664. + static_rule[rule_idx].dst_bw = 0;
  9665. + else
  9666. + static_rule[rule_idx].dst_bw = KBTOB(bw_fld);
  9667. +
  9668. + rule_idx++;
  9669. + }
  9670. + ret = rule_idx;
  9671. +exit_static_rules:
  9672. + return ret;
  9673. +err_static_rules:
  9674. + for (i = 0; i < num_rules; i++) {
  9675. + if (!IS_ERR_OR_NULL(static_rule)) {
  9676. + if (!IS_ERR_OR_NULL(static_rule[i].src_id))
  9677. + devm_kfree(&pdev->dev,
  9678. + static_rule[i].src_id);
  9679. + if (!IS_ERR_OR_NULL(static_rule[i].dst_node))
  9680. + devm_kfree(&pdev->dev,
  9681. + static_rule[i].dst_node);
  9682. + devm_kfree(&pdev->dev, static_rule);
  9683. + }
  9684. + }
  9685. + devm_kfree(&pdev->dev, *static_rules);
  9686. + static_rules = NULL;
  9687. + return ret;
  9688. +}
  9689. --- /dev/null
  9690. +++ b/drivers/bus/msm_bus/msm_bus_rules.c
  9691. @@ -0,0 +1,624 @@
  9692. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  9693. + *
  9694. + * This program is free software; you can redistribute it and/or modify
  9695. + * it under the terms of the GNU General Public License version 2 and
  9696. + * only version 2 as published by the Free Software Foundation.
  9697. + *
  9698. + * This program is distributed in the hope that it will be useful,
  9699. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9700. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9701. + * GNU General Public License for more details.
  9702. + */
  9703. +
  9704. +#include <linux/list_sort.h>
  9705. +#include <linux/slab.h>
  9706. +#include <linux/types.h>
  9707. +#include "msm-bus-board.h"
  9708. +#include "msm_bus_rules.h"
  9709. +#include <trace/events/trace_msm_bus.h>
  9710. +
  9711. +struct node_vote_info {
  9712. + int id;
  9713. + u64 ib;
  9714. + u64 ab;
  9715. + u64 clk;
  9716. +};
  9717. +
  9718. +struct rules_def {
  9719. + int rule_id;
  9720. + int num_src;
  9721. + int state;
  9722. + struct node_vote_info *src_info;
  9723. + struct bus_rule_type rule_ops;
  9724. + bool state_change;
  9725. + struct list_head link;
  9726. +};
  9727. +
  9728. +struct rule_node_info {
  9729. + int id;
  9730. + void *data;
  9731. + struct raw_notifier_head rule_notify_list;
  9732. + int cur_rule;
  9733. + int num_rules;
  9734. + struct list_head node_rules;
  9735. + struct list_head link;
  9736. + struct rule_apply_rcm_info apply;
  9737. +};
  9738. +
  9739. +DEFINE_MUTEX(msm_bus_rules_lock);
  9740. +static LIST_HEAD(node_list);
  9741. +static struct rule_node_info *get_node(u32 id, void *data);
  9742. +
  9743. +#define LE(op1, op2) (op1 <= op2)
  9744. +#define LT(op1, op2) (op1 < op2)
  9745. +#define GE(op1, op2) (op1 >= op2)
  9746. +#define GT(op1, op2) (op1 > op2)
  9747. +#define NB_ID (0x201)
  9748. +
  9749. +static struct rule_node_info *get_node(u32 id, void *data)
  9750. +{
  9751. + struct rule_node_info *node_it = NULL;
  9752. + struct rule_node_info *node_match = NULL;
  9753. +
  9754. + list_for_each_entry(node_it, &node_list, link) {
  9755. + if (node_it->id == id) {
  9756. + if ((id == NB_ID)) {
  9757. + if ((node_it->data == data)) {
  9758. + node_match = node_it;
  9759. + break;
  9760. + }
  9761. + } else {
  9762. + node_match = node_it;
  9763. + break;
  9764. + }
  9765. + }
  9766. + }
  9767. + return node_match;
  9768. +}
  9769. +
  9770. +static struct rule_node_info *gen_node(u32 id, void *data)
  9771. +{
  9772. + struct rule_node_info *node_it = NULL;
  9773. + struct rule_node_info *node_match = NULL;
  9774. +
  9775. + list_for_each_entry(node_it, &node_list, link) {
  9776. + if (node_it->id == id) {
  9777. + node_match = node_it;
  9778. + break;
  9779. + }
  9780. + }
  9781. +
  9782. + if (!node_match) {
  9783. + node_match = kzalloc(sizeof(struct rule_node_info), GFP_KERNEL);
  9784. + if (!node_match) {
  9785. + pr_err("%s: Cannot allocate memory", __func__);
  9786. + goto exit_node_match;
  9787. + }
  9788. +
  9789. + node_match->id = id;
  9790. + node_match->cur_rule = -1;
  9791. + node_match->num_rules = 0;
  9792. + node_match->data = data;
  9793. + list_add_tail(&node_match->link, &node_list);
  9794. + INIT_LIST_HEAD(&node_match->node_rules);
  9795. + RAW_INIT_NOTIFIER_HEAD(&node_match->rule_notify_list);
  9796. + pr_debug("Added new node %d to list\n", id);
  9797. + }
  9798. +exit_node_match:
  9799. + return node_match;
  9800. +}
  9801. +
  9802. +static bool do_compare_op(u64 op1, u64 op2, int op)
  9803. +{
  9804. + bool ret = false;
  9805. +
  9806. + switch (op) {
  9807. + case OP_LE:
  9808. + ret = LE(op1, op2);
  9809. + break;
  9810. + case OP_LT:
  9811. + ret = LT(op1, op2);
  9812. + break;
  9813. + case OP_GT:
  9814. + ret = GT(op1, op2);
  9815. + break;
  9816. + case OP_GE:
  9817. + ret = GE(op1, op2);
  9818. + break;
  9819. + case OP_NOOP:
  9820. + ret = true;
  9821. + break;
  9822. + default:
  9823. + pr_info("Invalid OP %d", op);
  9824. + break;
  9825. + }
  9826. + return ret;
  9827. +}
  9828. +
  9829. +static void update_src_id_vote(struct rule_update_path_info *inp_node,
  9830. + struct rule_node_info *rule_node)
  9831. +{
  9832. + struct rules_def *rule;
  9833. + int i;
  9834. +
  9835. + list_for_each_entry(rule, &rule_node->node_rules, link) {
  9836. + for (i = 0; i < rule->num_src; i++) {
  9837. + if (rule->src_info[i].id == inp_node->id) {
  9838. + rule->src_info[i].ib = inp_node->ib;
  9839. + rule->src_info[i].ab = inp_node->ab;
  9840. + rule->src_info[i].clk = inp_node->clk;
  9841. + }
  9842. + }
  9843. + }
  9844. +}
  9845. +
  9846. +static u64 get_field(struct rules_def *rule, int src_id)
  9847. +{
  9848. + u64 field = 0;
  9849. + int i;
  9850. +
  9851. + for (i = 0; i < rule->num_src; i++) {
  9852. + switch (rule->rule_ops.src_field) {
  9853. + case FLD_IB:
  9854. + field += rule->src_info[i].ib;
  9855. + break;
  9856. + case FLD_AB:
  9857. + field += rule->src_info[i].ab;
  9858. + break;
  9859. + case FLD_CLK:
  9860. + field += rule->src_info[i].clk;
  9861. + break;
  9862. + }
  9863. + }
  9864. +
  9865. + return field;
  9866. +}
  9867. +
  9868. +static bool check_rule(struct rules_def *rule,
  9869. + struct rule_update_path_info *inp)
  9870. +{
  9871. + bool ret = false;
  9872. +
  9873. + if (!rule)
  9874. + return ret;
  9875. +
  9876. + switch (rule->rule_ops.op) {
  9877. + case OP_LE:
  9878. + case OP_LT:
  9879. + case OP_GT:
  9880. + case OP_GE:
  9881. + {
  9882. + u64 src_field = get_field(rule, inp->id);
  9883. + if (!src_field)
  9884. + ret = false;
  9885. + else
  9886. + ret = do_compare_op(src_field, rule->rule_ops.thresh,
  9887. + rule->rule_ops.op);
  9888. + break;
  9889. + }
  9890. + default:
  9891. + pr_err("Unsupported op %d", rule->rule_ops.op);
  9892. + break;
  9893. + }
  9894. + return ret;
  9895. +}
  9896. +
  9897. +static void match_rule(struct rule_update_path_info *inp_node,
  9898. + struct rule_node_info *node)
  9899. +{
  9900. + struct rules_def *rule;
  9901. + int i;
  9902. +
  9903. + list_for_each_entry(rule, &node->node_rules, link) {
  9904. + for (i = 0; i < rule->num_src; i++) {
  9905. + if (rule->src_info[i].id == inp_node->id) {
  9906. + if (check_rule(rule, inp_node)) {
  9907. + trace_bus_rules_matches(node->cur_rule,
  9908. + inp_node->id, inp_node->ab,
  9909. + inp_node->ib, inp_node->clk);
  9910. + if (rule->state ==
  9911. + RULE_STATE_NOT_APPLIED)
  9912. + rule->state_change = true;
  9913. + rule->state = RULE_STATE_APPLIED;
  9914. + } else {
  9915. + if (rule->state ==
  9916. + RULE_STATE_APPLIED)
  9917. + rule->state_change = true;
  9918. + rule->state = RULE_STATE_NOT_APPLIED;
  9919. + }
  9920. + }
  9921. + }
  9922. + }
  9923. +}
  9924. +
  9925. +static void apply_rule(struct rule_node_info *node,
  9926. + struct list_head *output_list)
  9927. +{
  9928. + struct rules_def *rule;
  9929. +
  9930. + node->cur_rule = -1;
  9931. + list_for_each_entry(rule, &node->node_rules, link) {
  9932. + if ((rule->state == RULE_STATE_APPLIED) &&
  9933. + (node->cur_rule == -1))
  9934. + node->cur_rule = rule->rule_id;
  9935. +
  9936. + if (node->id == NB_ID) {
  9937. + if (rule->state_change) {
  9938. + rule->state_change = false;
  9939. + raw_notifier_call_chain(&node->rule_notify_list,
  9940. + rule->state, (void *)&rule->rule_ops);
  9941. + }
  9942. + } else {
  9943. + if ((rule->state == RULE_STATE_APPLIED) &&
  9944. + (node->cur_rule == rule->rule_id)) {
  9945. + node->apply.id = rule->rule_ops.dst_node[0];
  9946. + node->apply.throttle = rule->rule_ops.mode;
  9947. + node->apply.lim_bw = rule->rule_ops.dst_bw;
  9948. + list_add_tail(&node->apply.link, output_list);
  9949. + }
  9950. + rule->state_change = false;
  9951. + }
  9952. + }
  9953. +
  9954. +}
  9955. +
  9956. +int msm_rules_update_path(struct list_head *input_list,
  9957. + struct list_head *output_list)
  9958. +{
  9959. + int ret = 0;
  9960. + struct rule_update_path_info *inp_node;
  9961. + struct rule_node_info *node_it = NULL;
  9962. +
  9963. + mutex_lock(&msm_bus_rules_lock);
  9964. + list_for_each_entry(inp_node, input_list, link) {
  9965. + list_for_each_entry(node_it, &node_list, link) {
  9966. + update_src_id_vote(inp_node, node_it);
  9967. + match_rule(inp_node, node_it);
  9968. + }
  9969. + }
  9970. +
  9971. + list_for_each_entry(node_it, &node_list, link)
  9972. + apply_rule(node_it, output_list);
  9973. +
  9974. + mutex_unlock(&msm_bus_rules_lock);
  9975. + return ret;
  9976. +}
  9977. +
  9978. +static bool ops_equal(int op1, int op2)
  9979. +{
  9980. + bool ret = false;
  9981. +
  9982. + switch (op1) {
  9983. + case OP_GT:
  9984. + case OP_GE:
  9985. + case OP_LT:
  9986. + case OP_LE:
  9987. + if (abs(op1 - op2) <= 1)
  9988. + ret = true;
  9989. + break;
  9990. + default:
  9991. + ret = (op1 == op2);
  9992. + }
  9993. +
  9994. + return ret;
  9995. +}
  9996. +
  9997. +static int node_rules_compare(void *priv, struct list_head *a,
  9998. + struct list_head *b)
  9999. +{
  10000. + struct rules_def *ra = container_of(a, struct rules_def, link);
  10001. + struct rules_def *rb = container_of(b, struct rules_def, link);
  10002. + int ret = -1;
  10003. + int64_t th_diff = 0;
  10004. +
  10005. +
  10006. + if (ra->rule_ops.mode == rb->rule_ops.mode) {
  10007. + if (ops_equal(ra->rule_ops.op, rb->rule_ops.op)) {
  10008. + if ((ra->rule_ops.op == OP_LT) ||
  10009. + (ra->rule_ops.op == OP_LE)) {
  10010. + th_diff = ra->rule_ops.thresh -
  10011. + rb->rule_ops.thresh;
  10012. + if (th_diff > 0)
  10013. + ret = 1;
  10014. + else
  10015. + ret = -1;
  10016. + } else if ((ra->rule_ops.op == OP_GT) ||
  10017. + (ra->rule_ops.op == OP_GE)) {
  10018. + th_diff = rb->rule_ops.thresh -
  10019. + ra->rule_ops.thresh;
  10020. + if (th_diff > 0)
  10021. + ret = 1;
  10022. + else
  10023. + ret = -1;
  10024. + }
  10025. + } else
  10026. + ret = ra->rule_ops.op - rb->rule_ops.op;
  10027. + } else if ((ra->rule_ops.mode == THROTTLE_OFF) &&
  10028. + (rb->rule_ops.mode == THROTTLE_ON)) {
  10029. + ret = 1;
  10030. + } else if ((ra->rule_ops.mode == THROTTLE_ON) &&
  10031. + (rb->rule_ops.mode == THROTTLE_OFF)) {
  10032. + ret = -1;
  10033. + }
  10034. +
  10035. + return ret;
  10036. +}
  10037. +
  10038. +static void print_rules(struct rule_node_info *node_it)
  10039. +{
  10040. + struct rules_def *node_rule = NULL;
  10041. + int i;
  10042. +
  10043. + if (!node_it) {
  10044. + pr_err("%s: no node for found", __func__);
  10045. + return;
  10046. + }
  10047. +
  10048. + pr_info("\n Now printing rules for Node %d cur rule %d\n",
  10049. + node_it->id, node_it->cur_rule);
  10050. + list_for_each_entry(node_rule, &node_it->node_rules, link) {
  10051. + pr_info("\n num Rules %d rule Id %d\n",
  10052. + node_it->num_rules, node_rule->rule_id);
  10053. + pr_info("Rule: src_field %d\n", node_rule->rule_ops.src_field);
  10054. + for (i = 0; i < node_rule->rule_ops.num_src; i++)
  10055. + pr_info("Rule: src %d\n",
  10056. + node_rule->rule_ops.src_id[i]);
  10057. + for (i = 0; i < node_rule->rule_ops.num_dst; i++)
  10058. + pr_info("Rule: dst %d dst_bw %llu\n",
  10059. + node_rule->rule_ops.dst_node[i],
  10060. + node_rule->rule_ops.dst_bw);
  10061. + pr_info("Rule: thresh %llu op %d mode %d State %d\n",
  10062. + node_rule->rule_ops.thresh,
  10063. + node_rule->rule_ops.op,
  10064. + node_rule->rule_ops.mode,
  10065. + node_rule->state);
  10066. + }
  10067. +}
  10068. +
  10069. +void print_all_rules(void)
  10070. +{
  10071. + struct rule_node_info *node_it = NULL;
  10072. +
  10073. + list_for_each_entry(node_it, &node_list, link)
  10074. + print_rules(node_it);
  10075. +}
  10076. +
  10077. +void print_rules_buf(char *buf, int max_buf)
  10078. +{
  10079. + struct rule_node_info *node_it = NULL;
  10080. + struct rules_def *node_rule = NULL;
  10081. + int i;
  10082. + int cnt = 0;
  10083. +
  10084. + list_for_each_entry(node_it, &node_list, link) {
  10085. + cnt += scnprintf(buf + cnt, max_buf - cnt,
  10086. + "\n Now printing rules for Node %d cur_rule %d\n",
  10087. + node_it->id, node_it->cur_rule);
  10088. + list_for_each_entry(node_rule, &node_it->node_rules, link) {
  10089. + cnt += scnprintf(buf + cnt, max_buf - cnt,
  10090. + "\nNum Rules:%d ruleId %d STATE:%d change:%d\n",
  10091. + node_it->num_rules, node_rule->rule_id,
  10092. + node_rule->state, node_rule->state_change);
  10093. + cnt += scnprintf(buf + cnt, max_buf - cnt,
  10094. + "Src_field %d\n",
  10095. + node_rule->rule_ops.src_field);
  10096. + for (i = 0; i < node_rule->rule_ops.num_src; i++)
  10097. + cnt += scnprintf(buf + cnt, max_buf - cnt,
  10098. + "Src %d Cur Ib %llu Ab %llu\n",
  10099. + node_rule->rule_ops.src_id[i],
  10100. + node_rule->src_info[i].ib,
  10101. + node_rule->src_info[i].ab);
  10102. + for (i = 0; i < node_rule->rule_ops.num_dst; i++)
  10103. + cnt += scnprintf(buf + cnt, max_buf - cnt,
  10104. + "Dst %d dst_bw %llu\n",
  10105. + node_rule->rule_ops.dst_node[0],
  10106. + node_rule->rule_ops.dst_bw);
  10107. + cnt += scnprintf(buf + cnt, max_buf - cnt,
  10108. + "Thresh %llu op %d mode %d\n",
  10109. + node_rule->rule_ops.thresh,
  10110. + node_rule->rule_ops.op,
  10111. + node_rule->rule_ops.mode);
  10112. + }
  10113. + }
  10114. +}
  10115. +
  10116. +static int copy_rule(struct bus_rule_type *src, struct rules_def *node_rule,
  10117. + struct notifier_block *nb)
  10118. +{
  10119. + int i;
  10120. + int ret = 0;
  10121. +
  10122. + memcpy(&node_rule->rule_ops, src,
  10123. + sizeof(struct bus_rule_type));
  10124. + node_rule->rule_ops.src_id = kzalloc(
  10125. + (sizeof(int) * node_rule->rule_ops.num_src),
  10126. + GFP_KERNEL);
  10127. + if (!node_rule->rule_ops.src_id) {
  10128. + pr_err("%s:Failed to allocate for src_id",
  10129. + __func__);
  10130. + return -ENOMEM;
  10131. + }
  10132. + memcpy(node_rule->rule_ops.src_id, src->src_id,
  10133. + sizeof(int) * src->num_src);
  10134. +
  10135. +
  10136. + if (!nb) {
  10137. + node_rule->rule_ops.dst_node = kzalloc(
  10138. + (sizeof(int) * node_rule->rule_ops.num_dst),
  10139. + GFP_KERNEL);
  10140. + if (!node_rule->rule_ops.dst_node) {
  10141. + pr_err("%s:Failed to allocate for src_id",
  10142. + __func__);
  10143. + return -ENOMEM;
  10144. + }
  10145. + memcpy(node_rule->rule_ops.dst_node, src->dst_node,
  10146. + sizeof(int) * src->num_dst);
  10147. + }
  10148. +
  10149. + node_rule->num_src = src->num_src;
  10150. + node_rule->src_info = kzalloc(
  10151. + (sizeof(struct node_vote_info) * node_rule->rule_ops.num_src),
  10152. + GFP_KERNEL);
  10153. + if (!node_rule->src_info) {
  10154. + pr_err("%s:Failed to allocate for src_id",
  10155. + __func__);
  10156. + return -ENOMEM;
  10157. + }
  10158. + for (i = 0; i < src->num_src; i++)
  10159. + node_rule->src_info[i].id = src->src_id[i];
  10160. +
  10161. + return ret;
  10162. +}
  10163. +
  10164. +void msm_rule_register(int num_rules, struct bus_rule_type *rule,
  10165. + struct notifier_block *nb)
  10166. +{
  10167. + struct rule_node_info *node = NULL;
  10168. + int i, j;
  10169. + struct rules_def *node_rule = NULL;
  10170. + int num_dst = 0;
  10171. +
  10172. + if (!rule)
  10173. + return;
  10174. +
  10175. + mutex_lock(&msm_bus_rules_lock);
  10176. + for (i = 0; i < num_rules; i++) {
  10177. + if (nb)
  10178. + num_dst = 1;
  10179. + else
  10180. + num_dst = rule[i].num_dst;
  10181. +
  10182. + for (j = 0; j < num_dst; j++) {
  10183. + int id = 0;
  10184. +
  10185. + if (nb)
  10186. + id = NB_ID;
  10187. + else
  10188. + id = rule[i].dst_node[j];
  10189. +
  10190. + node = gen_node(id, nb);
  10191. + if (!node) {
  10192. + pr_info("Error getting rule");
  10193. + goto exit_rule_register;
  10194. + }
  10195. + node_rule = kzalloc(sizeof(struct rules_def),
  10196. + GFP_KERNEL);
  10197. + if (!node_rule) {
  10198. + pr_err("%s: Failed to allocate for rule",
  10199. + __func__);
  10200. + goto exit_rule_register;
  10201. + }
  10202. +
  10203. + if (copy_rule(&rule[i], node_rule, nb)) {
  10204. + pr_err("Error copying rule");
  10205. + goto exit_rule_register;
  10206. + }
  10207. +
  10208. + node_rule->rule_id = node->num_rules++;
  10209. + if (nb)
  10210. + node->data = nb;
  10211. +
  10212. + list_add_tail(&node_rule->link, &node->node_rules);
  10213. + }
  10214. + }
  10215. + list_sort(NULL, &node->node_rules, node_rules_compare);
  10216. +
  10217. + if (nb)
  10218. + raw_notifier_chain_register(&node->rule_notify_list, nb);
  10219. +exit_rule_register:
  10220. + mutex_unlock(&msm_bus_rules_lock);
  10221. + return;
  10222. +}
  10223. +
  10224. +static int comp_rules(struct bus_rule_type *rulea, struct bus_rule_type *ruleb)
  10225. +{
  10226. + int ret = 1;
  10227. +
  10228. + if (rulea->num_src == ruleb->num_src)
  10229. + ret = memcmp(rulea->src_id, ruleb->src_id,
  10230. + (sizeof(int) * rulea->num_src));
  10231. + if (!ret && (rulea->num_dst == ruleb->num_dst))
  10232. + ret = memcmp(rulea->dst_node, ruleb->dst_node,
  10233. + (sizeof(int) * rulea->num_dst));
  10234. + if (!ret && (rulea->dst_bw == ruleb->dst_bw) &&
  10235. + (rulea->op == ruleb->op) && (rulea->thresh == ruleb->thresh))
  10236. + ret = 0;
  10237. +
  10238. + return ret;
  10239. +}
  10240. +
  10241. +void msm_rule_unregister(int num_rules, struct bus_rule_type *rule,
  10242. + struct notifier_block *nb)
  10243. +{
  10244. + int i;
  10245. + struct rule_node_info *node = NULL;
  10246. + struct rule_node_info *node_tmp = NULL;
  10247. + struct rules_def *node_rule;
  10248. + struct rules_def *node_rule_tmp;
  10249. + bool match_found = false;
  10250. +
  10251. + if (!rule)
  10252. + return;
  10253. +
  10254. + mutex_lock(&msm_bus_rules_lock);
  10255. + if (nb) {
  10256. + node = get_node(NB_ID, nb);
  10257. + if (!node) {
  10258. + pr_err("%s: Can't find node", __func__);
  10259. + goto exit_unregister_rule;
  10260. + }
  10261. +
  10262. + list_for_each_entry_safe(node_rule, node_rule_tmp,
  10263. + &node->node_rules, link) {
  10264. + list_del(&node_rule->link);
  10265. + kfree(node_rule);
  10266. + node->num_rules--;
  10267. + }
  10268. + raw_notifier_chain_unregister(&node->rule_notify_list, nb);
  10269. + } else {
  10270. + for (i = 0; i < num_rules; i++) {
  10271. + match_found = false;
  10272. +
  10273. + list_for_each_entry(node, &node_list, link) {
  10274. + list_for_each_entry_safe(node_rule,
  10275. + node_rule_tmp, &node->node_rules, link) {
  10276. + if (comp_rules(&node_rule->rule_ops,
  10277. + &rule[i]) == 0) {
  10278. + list_del(&node_rule->link);
  10279. + kfree(node_rule);
  10280. + match_found = true;
  10281. + node->num_rules--;
  10282. + list_sort(NULL,
  10283. + &node->node_rules,
  10284. + node_rules_compare);
  10285. + break;
  10286. + }
  10287. + }
  10288. + }
  10289. + }
  10290. + }
  10291. +
  10292. + list_for_each_entry_safe(node, node_tmp,
  10293. + &node_list, link) {
  10294. + if (!node->num_rules) {
  10295. + pr_debug("Deleting Rule node %d", node->id);
  10296. + list_del(&node->link);
  10297. + kfree(node);
  10298. + }
  10299. + }
  10300. +exit_unregister_rule:
  10301. + mutex_unlock(&msm_bus_rules_lock);
  10302. +}
  10303. +
  10304. +bool msm_rule_are_rules_registered(void)
  10305. +{
  10306. + bool ret = false;
  10307. +
  10308. + if (list_empty(&node_list))
  10309. + ret = false;
  10310. + else
  10311. + ret = true;
  10312. +
  10313. + return ret;
  10314. +}
  10315. +
  10316. --- /dev/null
  10317. +++ b/drivers/bus/msm_bus/msm_bus_rules.h
  10318. @@ -0,0 +1,77 @@
  10319. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  10320. + *
  10321. + * This program is free software; you can redistribute it and/or modify
  10322. + * it under the terms of the GNU General Public License version 2 and
  10323. + * only version 2 as published by the Free Software Foundation.
  10324. + *
  10325. + * This program is distributed in the hope that it will be useful,
  10326. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10327. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10328. + * GNU General Public License for more details.
  10329. + */
  10330. +
  10331. +#ifndef _ARCH_ARM_MACH_MSM_BUS_RULES_H
  10332. +#define _ARCH_ARM_MACH_MSM_BUS_RULES_H
  10333. +
  10334. +#include <linux/types.h>
  10335. +#include <linux/list.h>
  10336. +#include <linux/notifier.h>
  10337. +#include <dt-bindings/msm/msm-bus-rule-ops.h>
  10338. +
  10339. +#define MAX_NODES (5)
  10340. +
  10341. +struct rule_update_path_info {
  10342. + u32 id;
  10343. + u64 ab;
  10344. + u64 ib;
  10345. + u64 clk;
  10346. + struct list_head link;
  10347. +};
  10348. +
  10349. +struct rule_apply_rcm_info {
  10350. + u32 id;
  10351. + u64 lim_bw;
  10352. + int throttle;
  10353. + bool after_clk_commit;
  10354. + struct list_head link;
  10355. +};
  10356. +
  10357. +struct bus_rule_type {
  10358. + int num_src;
  10359. + int *src_id;
  10360. + int src_field;
  10361. + int op;
  10362. + u64 thresh;
  10363. + int num_dst;
  10364. + int *dst_node;
  10365. + u64 dst_bw;
  10366. + int mode;
  10367. + void *client_data;
  10368. +};
  10369. +
  10370. +#if (defined(CONFIG_BUS_TOPOLOGY_ADHOC))
  10371. +void msm_rule_register(int num_rules, struct bus_rule_type *rule,
  10372. + struct notifier_block *nb);
  10373. +void msm_rule_unregister(int num_rules, struct bus_rule_type *rule,
  10374. + struct notifier_block *nb);
  10375. +void print_rules_buf(char *buf, int count);
  10376. +bool msm_rule_are_rules_registered(void);
  10377. +#else
  10378. +static inline void msm_rule_register(int num_rules, struct bus_rule_type *rule,
  10379. + struct notifier_block *nb)
  10380. +{
  10381. +}
  10382. +static inline void msm_rule_unregister(int num_rules,
  10383. + struct bus_rule_type *rule,
  10384. + struct notifier_block *nb)
  10385. +{
  10386. +}
  10387. +static inline void print_rules_buf(char *buf, int count)
  10388. +{
  10389. +}
  10390. +static inline bool msm_rule_are_rules_registered(void)
  10391. +{
  10392. + return false;
  10393. +}
  10394. +#endif /* defined(CONFIG_BUS_TOPOLOGY_ADHOC) */
  10395. +#endif /* _ARCH_ARM_MACH_MSM_BUS_RULES_H */
  10396. --- /dev/null
  10397. +++ b/drivers/bus/msm_bus/msm_buspm_coresight_adhoc.c
  10398. @@ -0,0 +1,189 @@
  10399. +/* Copyright (c) 2014 The Linux Foundation. All rights reserved.
  10400. + *
  10401. + * This program is free software; you can redistribute it and/or modify
  10402. + * it under the terms of the GNU General Public License version 2 and
  10403. + * only version 2 as published by the Free Software Foundation.
  10404. + *
  10405. + * This program is distributed in the hope that it will be useful,
  10406. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10407. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10408. + * GNU General Public License for more details.
  10409. + */
  10410. +
  10411. +#include <linux/clk.h>
  10412. +#include <linux/module.h>
  10413. +#include <linux/device.h>
  10414. +#include <linux/platform_device.h>
  10415. +#include <linux/err.h>
  10416. +#include <linux/slab.h>
  10417. +#include <linux/errno.h>
  10418. +#include <linux/uaccess.h>
  10419. +#include <linux/miscdevice.h>
  10420. +#include <linux/of_coresight.h>
  10421. +#include <linux/coresight.h>
  10422. +#include <linux/io.h>
  10423. +#include <linux/of.h>
  10424. +#include <linux/list.h>
  10425. +
  10426. +struct msmbus_coresight_adhoc_clock_drvdata {
  10427. + int id;
  10428. + struct clk *clk;
  10429. + struct list_head list;
  10430. +};
  10431. +
  10432. +struct msmbus_coresight_adhoc_drvdata {
  10433. + struct device *dev;
  10434. + struct coresight_device *csdev;
  10435. + struct coresight_desc *desc;
  10436. + struct list_head clocks;
  10437. +};
  10438. +
  10439. +static int msmbus_coresight_enable_adhoc(struct coresight_device *csdev)
  10440. +{
  10441. + struct msmbus_coresight_adhoc_clock_drvdata *clk;
  10442. + struct msmbus_coresight_adhoc_drvdata *drvdata =
  10443. + dev_get_drvdata(csdev->dev.parent);
  10444. + long rate;
  10445. +
  10446. + list_for_each_entry(clk, &drvdata->clocks, list) {
  10447. + if (clk->id == csdev->id) {
  10448. + rate = clk_round_rate(clk->clk, 1L);
  10449. + clk_set_rate(clk->clk, rate);
  10450. + return clk_prepare_enable(clk->clk);
  10451. + }
  10452. + }
  10453. +
  10454. + return -ENOENT;
  10455. +}
  10456. +
  10457. +static void msmbus_coresight_disable_adhoc(struct coresight_device *csdev)
  10458. +{
  10459. + struct msmbus_coresight_adhoc_clock_drvdata *clk;
  10460. + struct msmbus_coresight_adhoc_drvdata *drvdata =
  10461. + dev_get_drvdata(csdev->dev.parent);
  10462. +
  10463. + list_for_each_entry(clk, &drvdata->clocks, list) {
  10464. + if (clk->id == csdev->id)
  10465. + clk_disable_unprepare(clk->clk);
  10466. + }
  10467. +}
  10468. +
  10469. +static const struct coresight_ops_source msmbus_coresight_adhoc_source_ops = {
  10470. + .enable = msmbus_coresight_enable_adhoc,
  10471. + .disable = msmbus_coresight_disable_adhoc,
  10472. +};
  10473. +
  10474. +static const struct coresight_ops msmbus_coresight_cs_ops = {
  10475. + .source_ops = &msmbus_coresight_adhoc_source_ops,
  10476. +};
  10477. +
  10478. +void msmbus_coresight_remove_adhoc(struct platform_device *pdev)
  10479. +{
  10480. + struct msmbus_coresight_adhoc_clock_drvdata *clk, *next_clk;
  10481. + struct msmbus_coresight_adhoc_drvdata *drvdata =
  10482. + platform_get_drvdata(pdev);
  10483. +
  10484. + msmbus_coresight_disable_adhoc(drvdata->csdev);
  10485. + coresight_unregister(drvdata->csdev);
  10486. + list_for_each_entry_safe(clk, next_clk, &drvdata->clocks, list) {
  10487. + list_del(&clk->list);
  10488. + devm_kfree(&pdev->dev, clk);
  10489. + }
  10490. + devm_kfree(&pdev->dev, drvdata->desc);
  10491. + devm_kfree(&pdev->dev, drvdata);
  10492. + platform_set_drvdata(pdev, NULL);
  10493. +}
  10494. +EXPORT_SYMBOL(msmbus_coresight_remove_adhoc);
  10495. +
  10496. +static int buspm_of_get_clk_adhoc(struct device_node *of_node,
  10497. + struct msmbus_coresight_adhoc_drvdata *drvdata, int id)
  10498. +{
  10499. + struct msmbus_coresight_adhoc_clock_drvdata *clk;
  10500. + clk = devm_kzalloc(drvdata->dev, sizeof(*clk), GFP_KERNEL);
  10501. +
  10502. + if (!clk)
  10503. + return -ENOMEM;
  10504. +
  10505. + clk->id = id;
  10506. +
  10507. + clk->clk = of_clk_get_by_name(of_node, "bus_clk");
  10508. + if (IS_ERR(clk->clk)) {
  10509. + pr_err("Error: unable to get clock for coresight node %d\n",
  10510. + id);
  10511. + goto err;
  10512. + }
  10513. +
  10514. + list_add(&clk->list, &drvdata->clocks);
  10515. + return 0;
  10516. +
  10517. +err:
  10518. + devm_kfree(drvdata->dev, clk);
  10519. + return -EINVAL;
  10520. +}
  10521. +
  10522. +int msmbus_coresight_init_adhoc(struct platform_device *pdev,
  10523. + struct device_node *of_node)
  10524. +{
  10525. + int ret;
  10526. + struct device *dev = &pdev->dev;
  10527. + struct coresight_platform_data *pdata;
  10528. + struct msmbus_coresight_adhoc_drvdata *drvdata;
  10529. + struct coresight_desc *desc;
  10530. +
  10531. + pdata = of_get_coresight_platform_data(dev, of_node);
  10532. + if (IS_ERR(pdata))
  10533. + return PTR_ERR(pdata);
  10534. +
  10535. + drvdata = platform_get_drvdata(pdev);
  10536. + if (IS_ERR_OR_NULL(drvdata)) {
  10537. + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
  10538. + if (!drvdata) {
  10539. + pr_err("coresight: Alloc for drvdata failed\n");
  10540. + return -ENOMEM;
  10541. + }
  10542. + INIT_LIST_HEAD(&drvdata->clocks);
  10543. + drvdata->dev = &pdev->dev;
  10544. + platform_set_drvdata(pdev, drvdata);
  10545. + }
  10546. + ret = buspm_of_get_clk_adhoc(of_node, drvdata, pdata->id);
  10547. + if (ret) {
  10548. + pr_err("Error getting clocks\n");
  10549. + ret = -ENXIO;
  10550. + goto err1;
  10551. + }
  10552. +
  10553. + desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
  10554. + if (!desc) {
  10555. + pr_err("coresight: Error allocating memory\n");
  10556. + ret = -ENOMEM;
  10557. + goto err1;
  10558. + }
  10559. +
  10560. + desc->type = CORESIGHT_DEV_TYPE_SOURCE;
  10561. + desc->subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_BUS;
  10562. + desc->ops = &msmbus_coresight_cs_ops;
  10563. + desc->pdata = pdata;
  10564. + desc->dev = &pdev->dev;
  10565. + desc->owner = THIS_MODULE;
  10566. + drvdata->desc = desc;
  10567. + drvdata->csdev = coresight_register(desc);
  10568. + if (IS_ERR(drvdata->csdev)) {
  10569. + pr_err("coresight: Coresight register failed\n");
  10570. + ret = PTR_ERR(drvdata->csdev);
  10571. + goto err0;
  10572. + }
  10573. +
  10574. + dev_info(dev, "msmbus_coresight initialized\n");
  10575. +
  10576. + return 0;
  10577. +err0:
  10578. + devm_kfree(dev, desc);
  10579. +err1:
  10580. + devm_kfree(dev, drvdata);
  10581. + platform_set_drvdata(pdev, NULL);
  10582. + return ret;
  10583. +}
  10584. +EXPORT_SYMBOL(msmbus_coresight_init_adhoc);
  10585. +
  10586. +MODULE_LICENSE("GPL v2");
  10587. +MODULE_DESCRIPTION("MSM BusPM Adhoc CoreSight Driver");
  10588. --- /dev/null
  10589. +++ b/drivers/bus/msm_bus/rpm-smd.h
  10590. @@ -0,0 +1,268 @@
  10591. +/* Copyright (c) 2012, 2014, The Linux Foundation. All rights reserved.
  10592. + *
  10593. + * This program is free software; you can redistribute it and/or modify
  10594. + * it under the terms of the GNU General Public License version 2 and
  10595. + * only version 2 as published by the Free Software Foundation.
  10596. + *
  10597. + * This program is distributed in the hope that it will be useful,
  10598. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10599. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10600. + * GNU General Public License for more details.
  10601. + *
  10602. + */
  10603. +
  10604. +#ifndef __ARCH_ARM_MACH_MSM_RPM_SMD_H
  10605. +#define __ARCH_ARM_MACH_MSM_RPM_SMD_H
  10606. +
  10607. +/**
  10608. + * enum msm_rpm_set - RPM enumerations for sleep/active set
  10609. + * %MSM_RPM_CTX_SET_0: Set resource parameters for active mode.
  10610. + * %MSM_RPM_CTX_SET_SLEEP: Set resource parameters for sleep.
  10611. + */
  10612. +enum msm_rpm_set {
  10613. + MSM_RPM_CTX_ACTIVE_SET,
  10614. + MSM_RPM_CTX_SLEEP_SET,
  10615. +};
  10616. +
  10617. +struct msm_rpm_request;
  10618. +
  10619. +struct msm_rpm_kvp {
  10620. + uint32_t key;
  10621. + uint32_t length;
  10622. + uint8_t *data;
  10623. +};
  10624. +#ifdef CONFIG_MSM_RPM_SMD
  10625. +/**
  10626. + * msm_rpm_request() - Creates a parent element to identify the
  10627. + * resource on the RPM, that stores the KVPs for different fields modified
  10628. + * for a hardware resource
  10629. + *
  10630. + * @set: if the device is setting the active/sleep set parameter
  10631. + * for the resource
  10632. + * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
  10633. + * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
  10634. + * @num_elements: number of KVPs pairs associated with the resource
  10635. + *
  10636. + * returns pointer to a msm_rpm_request on success, NULL on error
  10637. + */
  10638. +struct msm_rpm_request *msm_rpm_create_request(
  10639. + enum msm_rpm_set set, uint32_t rsc_type,
  10640. + uint32_t rsc_id, int num_elements);
  10641. +
  10642. +/**
  10643. + * msm_rpm_request_noirq() - Creates a parent element to identify the
  10644. + * resource on the RPM, that stores the KVPs for different fields modified
  10645. + * for a hardware resource. This function is similar to msm_rpm_create_request
  10646. + * except that it has to be called with interrupts masked.
  10647. + *
  10648. + * @set: if the device is setting the active/sleep set parameter
  10649. + * for the resource
  10650. + * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
  10651. + * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
  10652. + * @num_elements: number of KVPs pairs associated with the resource
  10653. + *
  10654. + * returns pointer to a msm_rpm_request on success, NULL on error
  10655. + */
  10656. +struct msm_rpm_request *msm_rpm_create_request_noirq(
  10657. + enum msm_rpm_set set, uint32_t rsc_type,
  10658. + uint32_t rsc_id, int num_elements);
  10659. +
  10660. +/**
  10661. + * msm_rpm_add_kvp_data() - Adds a Key value pair to a existing RPM resource.
  10662. + *
  10663. + * @handle: RPM resource handle to which the data should be appended
  10664. + * @key: unsigned integer identify the parameter modified
  10665. + * @data: byte array that contains the value corresponding to key.
  10666. + * @size: size of data in bytes.
  10667. + *
  10668. + * returns 0 on success or errno
  10669. + */
  10670. +int msm_rpm_add_kvp_data(struct msm_rpm_request *handle,
  10671. + uint32_t key, const uint8_t *data, int size);
  10672. +
  10673. +/**
  10674. + * msm_rpm_add_kvp_data_noirq() - Adds a Key value pair to a existing RPM
  10675. + * resource. This function is similar to msm_rpm_add_kvp_data except that it
  10676. + * has to be called with interrupts masked.
  10677. + *
  10678. + * @handle: RPM resource handle to which the data should be appended
  10679. + * @key: unsigned integer identify the parameter modified
  10680. + * @data: byte array that contains the value corresponding to key.
  10681. + * @size: size of data in bytes.
  10682. + *
  10683. + * returns 0 on success or errno
  10684. + */
  10685. +int msm_rpm_add_kvp_data_noirq(struct msm_rpm_request *handle,
  10686. + uint32_t key, const uint8_t *data, int size);
  10687. +
  10688. +/** msm_rpm_free_request() - clean up the RPM request handle created with
  10689. + * msm_rpm_create_request
  10690. + *
  10691. + * @handle: RPM resource handle to be cleared.
  10692. + */
  10693. +
  10694. +void msm_rpm_free_request(struct msm_rpm_request *handle);
  10695. +
  10696. +/**
  10697. + * msm_rpm_send_request() - Send the RPM messages using SMD. The function
  10698. + * assigns a message id before sending the data out to the RPM. RPM hardware
  10699. + * uses the message id to acknowledge the messages.
  10700. + *
  10701. + * @handle: pointer to the msm_rpm_request for the resource being modified.
  10702. + *
  10703. + * returns non-zero message id on success and zero on a failed transaction.
  10704. + * The drivers use message id to wait for ACK from RPM.
  10705. + */
  10706. +int msm_rpm_send_request(struct msm_rpm_request *handle);
  10707. +
  10708. +/**
  10709. + * msm_rpm_send_request_noirq() - Send the RPM messages using SMD. The
  10710. + * function assigns a message id before sending the data out to the RPM.
  10711. + * RPM hardware uses the message id to acknowledge the messages. This function
  10712. + * is similar to msm_rpm_send_request except that it has to be called with
  10713. + * interrupts masked.
  10714. + *
  10715. + * @handle: pointer to the msm_rpm_request for the resource being modified.
  10716. + *
  10717. + * returns non-zero message id on success and zero on a failed transaction.
  10718. + * The drivers use message id to wait for ACK from RPM.
  10719. + */
  10720. +int msm_rpm_send_request_noirq(struct msm_rpm_request *handle);
  10721. +
  10722. +/**
  10723. + * msm_rpm_wait_for_ack() - A blocking call that waits for acknowledgment of
  10724. + * a message from RPM.
  10725. + *
  10726. + * @msg_id: the return from msm_rpm_send_requests
  10727. + *
  10728. + * returns 0 on success or errno
  10729. + */
  10730. +int msm_rpm_wait_for_ack(uint32_t msg_id);
  10731. +
  10732. +/**
  10733. + * msm_rpm_wait_for_ack_noirq() - A blocking call that waits for acknowledgment
  10734. + * of a message from RPM. This function is similar to msm_rpm_wait_for_ack
  10735. + * except that it has to be called with interrupts masked.
  10736. + *
  10737. + * @msg_id: the return from msm_rpm_send_request
  10738. + *
  10739. + * returns 0 on success or errno
  10740. + */
  10741. +int msm_rpm_wait_for_ack_noirq(uint32_t msg_id);
  10742. +
  10743. +/**
  10744. + * msm_rpm_send_message() -Wrapper function for clients to send data given an
  10745. + * array of key value pairs.
  10746. + *
  10747. + * @set: if the device is setting the active/sleep set parameter
  10748. + * for the resource
  10749. + * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
  10750. + * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
  10751. + * @kvp: array of KVP data.
  10752. + * @nelem: number of KVPs pairs associated with the message.
  10753. + *
  10754. + * returns 0 on success and errno on failure.
  10755. + */
  10756. +int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type,
  10757. + uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems);
  10758. +
  10759. +/**
  10760. + * msm_rpm_send_message_noirq() -Wrapper function for clients to send data
  10761. + * given an array of key value pairs. This function is similar to the
  10762. + * msm_rpm_send_message() except that it has to be called with interrupts
  10763. + * disabled. Clients should choose the irq version when possible for system
  10764. + * performance.
  10765. + *
  10766. + * @set: if the device is setting the active/sleep set parameter
  10767. + * for the resource
  10768. + * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
  10769. + * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
  10770. + * @kvp: array of KVP data.
  10771. + * @nelem: number of KVPs pairs associated with the message.
  10772. + *
  10773. + * returns 0 on success and errno on failure.
  10774. + */
  10775. +int msm_rpm_send_message_noirq(enum msm_rpm_set set, uint32_t rsc_type,
  10776. + uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems);
  10777. +
  10778. +/**
  10779. + * msm_rpm_driver_init() - Initialization function that registers for a
  10780. + * rpm platform driver.
  10781. + *
  10782. + * returns 0 on success.
  10783. + */
  10784. +int __init msm_rpm_driver_init(void);
  10785. +
  10786. +#else
  10787. +
  10788. +static inline struct msm_rpm_request *msm_rpm_create_request(
  10789. + enum msm_rpm_set set, uint32_t rsc_type,
  10790. + uint32_t rsc_id, int num_elements)
  10791. +{
  10792. + return NULL;
  10793. +}
  10794. +
  10795. +static inline struct msm_rpm_request *msm_rpm_create_request_noirq(
  10796. + enum msm_rpm_set set, uint32_t rsc_type,
  10797. + uint32_t rsc_id, int num_elements)
  10798. +{
  10799. + return NULL;
  10800. +
  10801. +}
  10802. +static inline uint32_t msm_rpm_add_kvp_data(struct msm_rpm_request *handle,
  10803. + uint32_t key, const uint8_t *data, int count)
  10804. +{
  10805. + return 0;
  10806. +}
  10807. +static inline uint32_t msm_rpm_add_kvp_data_noirq(
  10808. + struct msm_rpm_request *handle, uint32_t key,
  10809. + const uint8_t *data, int count)
  10810. +{
  10811. + return 0;
  10812. +}
  10813. +
  10814. +static inline void msm_rpm_free_request(struct msm_rpm_request *handle)
  10815. +{
  10816. + return;
  10817. +}
  10818. +
  10819. +static inline int msm_rpm_send_request(struct msm_rpm_request *handle)
  10820. +{
  10821. + return 0;
  10822. +}
  10823. +
  10824. +static inline int msm_rpm_send_request_noirq(struct msm_rpm_request *handle)
  10825. +{
  10826. + return 0;
  10827. +
  10828. +}
  10829. +
  10830. +static inline int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type,
  10831. + uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems)
  10832. +{
  10833. + return 0;
  10834. +}
  10835. +
  10836. +static inline int msm_rpm_send_message_noirq(enum msm_rpm_set set,
  10837. + uint32_t rsc_type, uint32_t rsc_id, struct msm_rpm_kvp *kvp,
  10838. + int nelems)
  10839. +{
  10840. + return 0;
  10841. +}
  10842. +
  10843. +static inline int msm_rpm_wait_for_ack(uint32_t msg_id)
  10844. +{
  10845. + return 0;
  10846. +
  10847. +}
  10848. +static inline int msm_rpm_wait_for_ack_noirq(uint32_t msg_id)
  10849. +{
  10850. + return 0;
  10851. +}
  10852. +
  10853. +static inline int __init msm_rpm_driver_init(void)
  10854. +{
  10855. + return 0;
  10856. +}
  10857. +#endif
  10858. +#endif /*__ARCH_ARM_MACH_MSM_RPM_SMD_H*/
  10859. --- /dev/null
  10860. +++ b/include/trace/events/trace_msm_bus.h
  10861. @@ -0,0 +1,163 @@
  10862. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  10863. + *
  10864. + * This program is free software; you can redistribute it and/or modify
  10865. + * it under the terms of the GNU General Public License version 2 and
  10866. + * only version 2 as published by the Free Software Foundation.
  10867. + *
  10868. + * This program is distributed in the hope that it will be useful,
  10869. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10870. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10871. + * GNU General Public License for more details.
  10872. + */
  10873. +
  10874. +#undef TRACE_SYSTEM
  10875. +#define TRACE_SYSTEM msm_bus
  10876. +
  10877. +#if !defined(_TRACE_MSM_BUS_H) || defined(TRACE_HEADER_MULTI_READ)
  10878. +#define _TRACE_MSM_BUS_H
  10879. +
  10880. +#include <linux/tracepoint.h>
  10881. +
  10882. +TRACE_EVENT(bus_update_request,
  10883. +
  10884. + TP_PROTO(int sec, int nsec, const char *name, unsigned int index,
  10885. + int src, int dest, unsigned long long ab,
  10886. + unsigned long long ib),
  10887. +
  10888. + TP_ARGS(sec, nsec, name, index, src, dest, ab, ib),
  10889. +
  10890. + TP_STRUCT__entry(
  10891. + __field(int, sec)
  10892. + __field(int, nsec)
  10893. + __string(name, name)
  10894. + __field(u32, index)
  10895. + __field(int, src)
  10896. + __field(int, dest)
  10897. + __field(u64, ab)
  10898. + __field(u64, ib)
  10899. + ),
  10900. +
  10901. + TP_fast_assign(
  10902. + __entry->sec = sec;
  10903. + __entry->nsec = nsec;
  10904. + __assign_str(name, name);
  10905. + __entry->index = index;
  10906. + __entry->src = src;
  10907. + __entry->dest = dest;
  10908. + __entry->ab = ab;
  10909. + __entry->ib = ib;
  10910. + ),
  10911. +
  10912. + TP_printk("time= %d.%d name=%s index=%u src=%d dest=%d ab=%llu ib=%llu",
  10913. + __entry->sec,
  10914. + __entry->nsec,
  10915. + __get_str(name),
  10916. + (unsigned int)__entry->index,
  10917. + __entry->src,
  10918. + __entry->dest,
  10919. + (unsigned long long)__entry->ab,
  10920. + (unsigned long long)__entry->ib)
  10921. +);
  10922. +
  10923. +TRACE_EVENT(bus_bimc_config_limiter,
  10924. +
  10925. + TP_PROTO(int mas_id, unsigned long long cur_lim_bw),
  10926. +
  10927. + TP_ARGS(mas_id, cur_lim_bw),
  10928. +
  10929. + TP_STRUCT__entry(
  10930. + __field(int, mas_id)
  10931. + __field(u64, cur_lim_bw)
  10932. + ),
  10933. +
  10934. + TP_fast_assign(
  10935. + __entry->mas_id = mas_id;
  10936. + __entry->cur_lim_bw = cur_lim_bw;
  10937. + ),
  10938. +
  10939. + TP_printk("Master=%d cur_lim_bw=%llu",
  10940. + __entry->mas_id,
  10941. + (unsigned long long)__entry->cur_lim_bw)
  10942. +);
  10943. +
  10944. +TRACE_EVENT(bus_avail_bw,
  10945. +
  10946. + TP_PROTO(unsigned long long cur_bimc_bw, unsigned long long cur_mdp_bw),
  10947. +
  10948. + TP_ARGS(cur_bimc_bw, cur_mdp_bw),
  10949. +
  10950. + TP_STRUCT__entry(
  10951. + __field(u64, cur_bimc_bw)
  10952. + __field(u64, cur_mdp_bw)
  10953. + ),
  10954. +
  10955. + TP_fast_assign(
  10956. + __entry->cur_bimc_bw = cur_bimc_bw;
  10957. + __entry->cur_mdp_bw = cur_mdp_bw;
  10958. + ),
  10959. +
  10960. + TP_printk("cur_bimc_bw = %llu cur_mdp_bw = %llu",
  10961. + (unsigned long long)__entry->cur_bimc_bw,
  10962. + (unsigned long long)__entry->cur_mdp_bw)
  10963. +);
  10964. +
  10965. +TRACE_EVENT(bus_rules_matches,
  10966. +
  10967. + TP_PROTO(int node_id, int rule_id, unsigned long long node_ab,
  10968. + unsigned long long node_ib, unsigned long long node_clk),
  10969. +
  10970. + TP_ARGS(node_id, rule_id, node_ab, node_ib, node_clk),
  10971. +
  10972. + TP_STRUCT__entry(
  10973. + __field(int, node_id)
  10974. + __field(int, rule_id)
  10975. + __field(u64, node_ab)
  10976. + __field(u64, node_ib)
  10977. + __field(u64, node_clk)
  10978. + ),
  10979. +
  10980. + TP_fast_assign(
  10981. + __entry->node_id = node_id;
  10982. + __entry->rule_id = rule_id;
  10983. + __entry->node_ab = node_ab;
  10984. + __entry->node_ib = node_ib;
  10985. + __entry->node_clk = node_clk;
  10986. + ),
  10987. +
  10988. + TP_printk("Rule match node%d rule%d node-ab%llu:ib%llu:clk%llu",
  10989. + __entry->node_id, __entry->rule_id,
  10990. + (unsigned long long)__entry->node_ab,
  10991. + (unsigned long long)__entry->node_ib,
  10992. + (unsigned long long)__entry->node_clk)
  10993. +);
  10994. +
  10995. +TRACE_EVENT(bus_bke_params,
  10996. +
  10997. + TP_PROTO(u32 gc, u32 gp, u32 thl, u32 thm, u32 thh),
  10998. +
  10999. + TP_ARGS(gc, gp, thl, thm, thh),
  11000. +
  11001. + TP_STRUCT__entry(
  11002. + __field(u32, gc)
  11003. + __field(u32, gp)
  11004. + __field(u32, thl)
  11005. + __field(u32, thm)
  11006. + __field(u32, thh)
  11007. + ),
  11008. +
  11009. + TP_fast_assign(
  11010. + __entry->gc = gc;
  11011. + __entry->gp = gp;
  11012. + __entry->thl = thl;
  11013. + __entry->thm = thm;
  11014. + __entry->thh = thh;
  11015. + ),
  11016. +
  11017. + TP_printk("BKE Params GC=0x%x GP=0x%x THL=0x%x THM=0x%x THH=0x%x",
  11018. + __entry->gc, __entry->gp, __entry->thl, __entry->thm,
  11019. + __entry->thh)
  11020. +);
  11021. +
  11022. +#endif
  11023. +#define TRACE_INCLUDE_FILE trace_msm_bus
  11024. +#include <trace/define_trace.h>