wcd9335.c 440 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334
  1. /*
  2. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/init.h>
  15. #include <linux/firmware.h>
  16. #include <linux/slab.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/device.h>
  19. #include <linux/printk.h>
  20. #include <linux/ratelimit.h>
  21. #include <linux/debugfs.h>
  22. #include <linux/wait.h>
  23. #include <linux/bitops.h>
  24. #include <linux/regmap.h>
  25. #include <linux/regulator/consumer.h>
  26. #include <linux/clk.h>
  27. #include <linux/delay.h>
  28. #include <linux/pm_runtime.h>
  29. #include <linux/kernel.h>
  30. #include <linux/gpio.h>
  31. #include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
  32. #include <soc/swr-wcd.h>
  33. #include <sound/pcm.h>
  34. #include <sound/pcm_params.h>
  35. #include <sound/soc.h>
  36. #include <sound/soc-dapm.h>
  37. #include <sound/tlv.h>
  38. #include <sound/info.h>
  39. #include "core.h"
  40. #include "pdata.h"
  41. #include "wcd9335.h"
  42. #include "wcd-mbhc-v2.h"
  43. #include "wcd9xxx-common-v2.h"
  44. #include "wcd9xxx-resmgr-v2.h"
  45. #include "wcd9xxx-irq.h"
  46. #include "wcd9335_registers.h"
  47. #include "wcd9335_irq.h"
  48. #include "wcd_cpe_core.h"
  49. #include "wcdcal-hwdep.h"
  50. #include "wcd-mbhc-v2-api.h"
  51. #define TASHA_RX_PORT_START_NUMBER 16
  52. #define WCD9335_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
  53. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
  54. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  55. /* Fractional Rates */
  56. #define WCD9335_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100)
  57. #define WCD9335_MIX_RATES_MASK (SNDRV_PCM_RATE_48000 |\
  58. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  59. #define TASHA_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  60. SNDRV_PCM_FMTBIT_S24_LE | \
  61. SNDRV_PCM_FMTBIT_S24_3LE)
  62. #define TASHA_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  63. SNDRV_PCM_FMTBIT_S24_LE | \
  64. SNDRV_PCM_FMTBIT_S24_3LE | \
  65. SNDRV_PCM_FMTBIT_S32_LE)
  66. #define TASHA_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
  67. /*
  68. * Timeout in milli seconds and it is the wait time for
  69. * slim channel removal interrupt to receive.
  70. */
  71. #define TASHA_SLIM_CLOSE_TIMEOUT 1000
  72. #define TASHA_SLIM_IRQ_OVERFLOW (1 << 0)
  73. #define TASHA_SLIM_IRQ_UNDERFLOW (1 << 1)
  74. #define TASHA_SLIM_IRQ_PORT_CLOSED (1 << 2)
  75. #define TASHA_MCLK_CLK_12P288MHZ 12288000
  76. #define TASHA_MCLK_CLK_9P6MHZ 9600000
  77. #define TASHA_SLIM_PGD_PORT_INT_TX_EN0 (TASHA_SLIM_PGD_PORT_INT_EN0 + 2)
  78. #define TASHA_NUM_INTERPOLATORS 9
  79. #define TASHA_NUM_DECIMATORS 9
  80. #define WCD9335_CHILD_DEVICES_MAX 6
  81. #define BYTE_BIT_MASK(nr) (1 << ((nr) % BITS_PER_BYTE))
  82. #define TASHA_MAD_AUDIO_FIRMWARE_PATH "wcd9335/wcd9335_mad_audio.bin"
  83. #define TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS (1 << 0)
  84. #define TASHA_CPE_SS_ERR_STATUS_WDOG_BITE (1 << 1)
  85. #define TASHA_CPE_FATAL_IRQS \
  86. (TASHA_CPE_SS_ERR_STATUS_WDOG_BITE | \
  87. TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS)
  88. #define SLIM_BW_CLK_GEAR_9 6200000
  89. #define SLIM_BW_UNVOTE 0
  90. #define CPE_FLL_CLK_75MHZ 75000000
  91. #define CPE_FLL_CLK_150MHZ 150000000
  92. #define WCD9335_REG_BITS 8
  93. #define WCD9335_MAX_VALID_ADC_MUX 13
  94. #define WCD9335_INVALID_ADC_MUX 9
  95. #define TASHA_DIG_CORE_REG_MIN WCD9335_CDC_ANC0_CLK_RESET_CTL
  96. #define TASHA_DIG_CORE_REG_MAX 0xDFF
  97. /* Convert from vout ctl to micbias voltage in mV */
  98. #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
  99. #define TASHA_ZDET_NUM_MEASUREMENTS 900
  100. #define TASHA_MBHC_GET_C1(c) ((c & 0xC000) >> 14)
  101. #define TASHA_MBHC_GET_X1(x) (x & 0x3FFF)
  102. /* z value compared in milliOhm */
  103. #define TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000))
  104. #define TASHA_MBHC_ZDET_CONST (86 * 16384)
  105. #define TASHA_MBHC_MOISTURE_VREF V_45_MV
  106. #define TASHA_MBHC_MOISTURE_IREF I_3P0_UA
  107. #define TASHA_VERSION_ENTRY_SIZE 17
  108. #define WCD9335_AMIC_PWR_LEVEL_LP 0
  109. #define WCD9335_AMIC_PWR_LEVEL_DEFAULT 1
  110. #define WCD9335_AMIC_PWR_LEVEL_HP 2
  111. #define WCD9335_AMIC_PWR_LVL_MASK 0x60
  112. #define WCD9335_AMIC_PWR_LVL_SHIFT 0x5
  113. #define WCD9335_DEC_PWR_LVL_MASK 0x06
  114. #define WCD9335_DEC_PWR_LVL_LP 0x02
  115. #define WCD9335_DEC_PWR_LVL_HP 0x04
  116. #define WCD9335_DEC_PWR_LVL_DF 0x00
  117. #define WCD9335_STRING_LEN 100
  118. #define CALCULATE_VOUT_D(req_mv) (((req_mv - 650) * 10) / 25)
  119. static int cpe_debug_mode;
  120. #define TASHA_MAX_MICBIAS 4
  121. #define DAPM_MICBIAS1_STANDALONE "MIC BIAS1 Standalone"
  122. #define DAPM_MICBIAS2_STANDALONE "MIC BIAS2 Standalone"
  123. #define DAPM_MICBIAS3_STANDALONE "MIC BIAS3 Standalone"
  124. #define DAPM_MICBIAS4_STANDALONE "MIC BIAS4 Standalone"
  125. #define DAPM_LDO_H_STANDALONE "LDO_H"
  126. module_param(cpe_debug_mode, int, 0664);
  127. MODULE_PARM_DESC(cpe_debug_mode, "boot cpe in debug mode");
  128. #define TASHA_DIG_CORE_COLLAPSE_TIMER_MS (5 * 1000)
  129. #define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH 64
  130. static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = {
  131. "cdc-vdd-mic-bias",
  132. };
  133. enum {
  134. POWER_COLLAPSE,
  135. POWER_RESUME,
  136. };
  137. enum tasha_sido_voltage {
  138. SIDO_VOLTAGE_SVS_MV = 950,
  139. SIDO_VOLTAGE_NOMINAL_MV = 1100,
  140. };
  141. static enum codec_variant codec_ver;
  142. static int dig_core_collapse_enable = 1;
  143. module_param(dig_core_collapse_enable, int, 0664);
  144. MODULE_PARM_DESC(dig_core_collapse_enable, "enable/disable power gating");
  145. /* dig_core_collapse timer in seconds */
  146. static int dig_core_collapse_timer = (TASHA_DIG_CORE_COLLAPSE_TIMER_MS/1000);
  147. module_param(dig_core_collapse_timer, int, 0664);
  148. MODULE_PARM_DESC(dig_core_collapse_timer, "timer for power gating");
  149. /* SVS Scaling enable/disable */
  150. static int svs_scaling_enabled = 1;
  151. module_param(svs_scaling_enabled, int, 0664);
  152. MODULE_PARM_DESC(svs_scaling_enabled, "enable/disable svs scaling");
  153. /* SVS buck setting */
  154. static int sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  155. module_param(sido_buck_svs_voltage, int, 0664);
  156. MODULE_PARM_DESC(sido_buck_svs_voltage,
  157. "setting for SVS voltage for SIDO BUCK");
  158. #define TASHA_TX_UNMUTE_DELAY_MS 40
  159. static int tx_unmute_delay = TASHA_TX_UNMUTE_DELAY_MS;
  160. module_param(tx_unmute_delay, int, 0664);
  161. MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path");
  162. static struct afe_param_slimbus_slave_port_cfg tasha_slimbus_slave_port_cfg = {
  163. .minor_version = 1,
  164. .slimbus_dev_id = AFE_SLIMBUS_DEVICE_1,
  165. .slave_dev_pgd_la = 0,
  166. .slave_dev_intfdev_la = 0,
  167. .bit_width = 16,
  168. .data_format = 0,
  169. .num_channels = 1
  170. };
  171. struct tasha_mbhc_zdet_param {
  172. u16 ldo_ctl;
  173. u16 noff;
  174. u16 nshift;
  175. u16 btn5;
  176. u16 btn6;
  177. u16 btn7;
  178. };
  179. static struct afe_param_cdc_reg_page_cfg tasha_cdc_reg_page_cfg = {
  180. .minor_version = AFE_API_VERSION_CDC_REG_PAGE_CFG,
  181. .enable = 1,
  182. .proc_id = AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_1,
  183. };
  184. static struct afe_param_cdc_reg_cfg audio_reg_cfg[] = {
  185. {
  186. 1,
  187. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_MAIN_CTL_1),
  188. HW_MAD_AUDIO_ENABLE, 0x1, WCD9335_REG_BITS, 0
  189. },
  190. {
  191. 1,
  192. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_3),
  193. HW_MAD_AUDIO_SLEEP_TIME, 0xF, WCD9335_REG_BITS, 0
  194. },
  195. {
  196. 1,
  197. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_4),
  198. HW_MAD_TX_AUDIO_SWITCH_OFF, 0x1, WCD9335_REG_BITS, 0
  199. },
  200. {
  201. 1,
  202. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  203. MAD_AUDIO_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  204. },
  205. {
  206. 1,
  207. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  208. MAD_AUDIO_INT_MASK_REG, 0x1, WCD9335_REG_BITS, 0
  209. },
  210. {
  211. 1,
  212. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  213. MAD_AUDIO_INT_STATUS_REG, 0x1, WCD9335_REG_BITS, 0
  214. },
  215. {
  216. 1,
  217. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  218. MAD_AUDIO_INT_CLEAR_REG, 0x1, WCD9335_REG_BITS, 0
  219. },
  220. {
  221. 1,
  222. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  223. VBAT_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  224. },
  225. {
  226. 1,
  227. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  228. VBAT_INT_MASK_REG, 0x08, WCD9335_REG_BITS, 0
  229. },
  230. {
  231. 1,
  232. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  233. VBAT_INT_STATUS_REG, 0x08, WCD9335_REG_BITS, 0
  234. },
  235. {
  236. 1,
  237. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  238. VBAT_INT_CLEAR_REG, 0x08, WCD9335_REG_BITS, 0
  239. },
  240. {
  241. 1,
  242. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  243. VBAT_RELEASE_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  244. },
  245. {
  246. 1,
  247. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  248. VBAT_RELEASE_INT_MASK_REG, 0x10, WCD9335_REG_BITS, 0
  249. },
  250. {
  251. 1,
  252. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  253. VBAT_RELEASE_INT_STATUS_REG, 0x10, WCD9335_REG_BITS, 0
  254. },
  255. {
  256. 1,
  257. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  258. VBAT_RELEASE_INT_CLEAR_REG, 0x10, WCD9335_REG_BITS, 0
  259. },
  260. {
  261. 1,
  262. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  263. SB_PGD_PORT_TX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  264. },
  265. {
  266. 1,
  267. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  268. SB_PGD_PORT_TX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  269. },
  270. {
  271. 1,
  272. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  273. SB_PGD_PORT_RX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  274. },
  275. {
  276. 1,
  277. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  278. SB_PGD_PORT_RX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  279. },
  280. { 1,
  281. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  282. AANC_FF_GAIN_ADAPTIVE, 0x4, WCD9335_REG_BITS, 0
  283. },
  284. { 1,
  285. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  286. AANC_FFGAIN_ADAPTIVE_EN, 0x8, WCD9335_REG_BITS, 0
  287. },
  288. {
  289. 1,
  290. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_FF_A_GAIN_CTL),
  291. AANC_GAIN_CONTROL, 0xFF, WCD9335_REG_BITS, 0
  292. },
  293. };
  294. static struct afe_param_cdc_reg_cfg_data tasha_audio_reg_cfg = {
  295. .num_registers = ARRAY_SIZE(audio_reg_cfg),
  296. .reg_data = audio_reg_cfg,
  297. };
  298. static struct afe_param_id_cdc_aanc_version tasha_cdc_aanc_version = {
  299. .cdc_aanc_minor_version = AFE_API_VERSION_CDC_AANC_VERSION,
  300. .aanc_hw_version = AANC_HW_BLOCK_VERSION_2,
  301. };
  302. enum {
  303. VI_SENSE_1,
  304. VI_SENSE_2,
  305. AIF4_SWITCH_VALUE,
  306. AUDIO_NOMINAL,
  307. CPE_NOMINAL,
  308. HPH_PA_DELAY,
  309. ANC_MIC_AMIC1,
  310. ANC_MIC_AMIC2,
  311. ANC_MIC_AMIC3,
  312. ANC_MIC_AMIC4,
  313. ANC_MIC_AMIC5,
  314. ANC_MIC_AMIC6,
  315. CLASSH_CONFIG,
  316. };
  317. enum {
  318. AIF1_PB = 0,
  319. AIF1_CAP,
  320. AIF2_PB,
  321. AIF2_CAP,
  322. AIF3_PB,
  323. AIF3_CAP,
  324. AIF4_PB,
  325. AIF_MIX1_PB,
  326. AIF4_MAD_TX,
  327. AIF4_VIFEED,
  328. AIF5_CPE_TX,
  329. NUM_CODEC_DAIS,
  330. };
  331. enum {
  332. INTn_1_MIX_INP_SEL_ZERO = 0,
  333. INTn_1_MIX_INP_SEL_DEC0,
  334. INTn_1_MIX_INP_SEL_DEC1,
  335. INTn_1_MIX_INP_SEL_IIR0,
  336. INTn_1_MIX_INP_SEL_IIR1,
  337. INTn_1_MIX_INP_SEL_RX0,
  338. INTn_1_MIX_INP_SEL_RX1,
  339. INTn_1_MIX_INP_SEL_RX2,
  340. INTn_1_MIX_INP_SEL_RX3,
  341. INTn_1_MIX_INP_SEL_RX4,
  342. INTn_1_MIX_INP_SEL_RX5,
  343. INTn_1_MIX_INP_SEL_RX6,
  344. INTn_1_MIX_INP_SEL_RX7,
  345. };
  346. #define IS_VALID_NATIVE_FIFO_PORT(inp) \
  347. ((inp >= INTn_1_MIX_INP_SEL_RX0) && \
  348. (inp <= INTn_1_MIX_INP_SEL_RX3))
  349. enum {
  350. INTn_2_INP_SEL_ZERO = 0,
  351. INTn_2_INP_SEL_RX0,
  352. INTn_2_INP_SEL_RX1,
  353. INTn_2_INP_SEL_RX2,
  354. INTn_2_INP_SEL_RX3,
  355. INTn_2_INP_SEL_RX4,
  356. INTn_2_INP_SEL_RX5,
  357. INTn_2_INP_SEL_RX6,
  358. INTn_2_INP_SEL_RX7,
  359. INTn_2_INP_SEL_PROXIMITY,
  360. };
  361. enum {
  362. INTERP_EAR = 0,
  363. INTERP_HPHL,
  364. INTERP_HPHR,
  365. INTERP_LO1,
  366. INTERP_LO2,
  367. INTERP_LO3,
  368. INTERP_LO4,
  369. INTERP_SPKR1,
  370. INTERP_SPKR2,
  371. };
  372. struct interp_sample_rate {
  373. int sample_rate;
  374. int rate_val;
  375. };
  376. static struct interp_sample_rate int_prim_sample_rate_val[] = {
  377. {8000, 0x0}, /* 8K */
  378. {16000, 0x1}, /* 16K */
  379. {24000, -EINVAL},/* 24K */
  380. {32000, 0x3}, /* 32K */
  381. {48000, 0x4}, /* 48K */
  382. {96000, 0x5}, /* 96K */
  383. {192000, 0x6}, /* 192K */
  384. {384000, 0x7}, /* 384K */
  385. {44100, 0x8}, /* 44.1K */
  386. };
  387. static struct interp_sample_rate int_mix_sample_rate_val[] = {
  388. {48000, 0x4}, /* 48K */
  389. {96000, 0x5}, /* 96K */
  390. {192000, 0x6}, /* 192K */
  391. };
  392. static const struct wcd9xxx_ch tasha_rx_chs[TASHA_RX_MAX] = {
  393. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER, 0),
  394. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 1, 1),
  395. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 2, 2),
  396. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 3, 3),
  397. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 4, 4),
  398. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 5, 5),
  399. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 6, 6),
  400. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 7, 7),
  401. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 8, 8),
  402. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 9, 9),
  403. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 10, 10),
  404. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 11, 11),
  405. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 12, 12),
  406. };
  407. static const struct wcd9xxx_ch tasha_tx_chs[TASHA_TX_MAX] = {
  408. WCD9XXX_CH(0, 0),
  409. WCD9XXX_CH(1, 1),
  410. WCD9XXX_CH(2, 2),
  411. WCD9XXX_CH(3, 3),
  412. WCD9XXX_CH(4, 4),
  413. WCD9XXX_CH(5, 5),
  414. WCD9XXX_CH(6, 6),
  415. WCD9XXX_CH(7, 7),
  416. WCD9XXX_CH(8, 8),
  417. WCD9XXX_CH(9, 9),
  418. WCD9XXX_CH(10, 10),
  419. WCD9XXX_CH(11, 11),
  420. WCD9XXX_CH(12, 12),
  421. WCD9XXX_CH(13, 13),
  422. WCD9XXX_CH(14, 14),
  423. WCD9XXX_CH(15, 15),
  424. };
  425. static const u32 vport_slim_check_table[NUM_CODEC_DAIS] = {
  426. /* Needs to define in the same order of DAI enum definitions */
  427. 0,
  428. BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  429. 0,
  430. BIT(AIF1_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  431. 0,
  432. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  433. 0,
  434. 0,
  435. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF5_CPE_TX),
  436. 0,
  437. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX),
  438. };
  439. static const u32 vport_i2s_check_table[NUM_CODEC_DAIS] = {
  440. 0, /* AIF1_PB */
  441. BIT(AIF2_CAP), /* AIF1_CAP */
  442. 0, /* AIF2_PB */
  443. BIT(AIF1_CAP), /* AIF2_CAP */
  444. };
  445. /* Codec supports 2 IIR filters */
  446. enum {
  447. IIR0 = 0,
  448. IIR1,
  449. IIR_MAX,
  450. };
  451. /* Each IIR has 5 Filter Stages */
  452. enum {
  453. BAND1 = 0,
  454. BAND2,
  455. BAND3,
  456. BAND4,
  457. BAND5,
  458. BAND_MAX,
  459. };
  460. enum {
  461. COMPANDER_1, /* HPH_L */
  462. COMPANDER_2, /* HPH_R */
  463. COMPANDER_3, /* LO1_DIFF */
  464. COMPANDER_4, /* LO2_DIFF */
  465. COMPANDER_5, /* LO3_SE */
  466. COMPANDER_6, /* LO4_SE */
  467. COMPANDER_7, /* SWR SPK CH1 */
  468. COMPANDER_8, /* SWR SPK CH2 */
  469. COMPANDER_MAX,
  470. };
  471. enum {
  472. SRC_IN_HPHL,
  473. SRC_IN_LO1,
  474. SRC_IN_HPHR,
  475. SRC_IN_LO2,
  476. SRC_IN_SPKRL,
  477. SRC_IN_LO3,
  478. SRC_IN_SPKRR,
  479. SRC_IN_LO4,
  480. };
  481. enum {
  482. SPLINE_SRC0,
  483. SPLINE_SRC1,
  484. SPLINE_SRC2,
  485. SPLINE_SRC3,
  486. SPLINE_SRC_MAX,
  487. };
  488. static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
  489. static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
  490. static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
  491. static struct snd_soc_dai_driver tasha_dai[];
  492. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv);
  493. static int tasha_config_compander(struct snd_soc_codec *, int, int);
  494. static void tasha_codec_set_tx_hold(struct snd_soc_codec *, u16, bool);
  495. static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
  496. bool enable);
  497. /* Hold instance to soundwire platform device */
  498. struct tasha_swr_ctrl_data {
  499. struct platform_device *swr_pdev;
  500. struct ida swr_ida;
  501. };
  502. struct wcd_swr_ctrl_platform_data {
  503. void *handle; /* holds codec private data */
  504. int (*read)(void *handle, int reg);
  505. int (*write)(void *handle, int reg, int val);
  506. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  507. int (*clk)(void *handle, bool enable);
  508. int (*handle_irq)(void *handle,
  509. irqreturn_t (*swrm_irq_handler)(int irq,
  510. void *data),
  511. void *swrm_handle,
  512. int action);
  513. };
  514. static struct wcd_mbhc_register
  515. wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = {
  516. WCD_MBHC_REGISTER("WCD_MBHC_L_DET_EN",
  517. WCD9335_ANA_MBHC_MECH, 0x80, 7, 0),
  518. WCD_MBHC_REGISTER("WCD_MBHC_GND_DET_EN",
  519. WCD9335_ANA_MBHC_MECH, 0x40, 6, 0),
  520. WCD_MBHC_REGISTER("WCD_MBHC_MECH_DETECTION_TYPE",
  521. WCD9335_ANA_MBHC_MECH, 0x20, 5, 0),
  522. WCD_MBHC_REGISTER("WCD_MBHC_MIC_CLAMP_CTL",
  523. WCD9335_MBHC_PLUG_DETECT_CTL, 0x30, 4, 0),
  524. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_DETECTION_TYPE",
  525. WCD9335_ANA_MBHC_ELECT, 0x08, 3, 0),
  526. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_CTRL",
  527. WCD9335_MBHC_PLUG_DETECT_CTL, 0xC0, 6, 0),
  528. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL",
  529. WCD9335_ANA_MBHC_MECH, 0x04, 2, 0),
  530. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PLUG_TYPE",
  531. WCD9335_ANA_MBHC_MECH, 0x10, 4, 0),
  532. WCD_MBHC_REGISTER("WCD_MBHC_GND_PLUG_TYPE",
  533. WCD9335_ANA_MBHC_MECH, 0x08, 3, 0),
  534. WCD_MBHC_REGISTER("WCD_MBHC_SW_HPH_LP_100K_TO_GND",
  535. WCD9335_ANA_MBHC_MECH, 0x01, 0, 0),
  536. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_SCHMT_ISRC",
  537. WCD9335_ANA_MBHC_ELECT, 0x06, 1, 0),
  538. WCD_MBHC_REGISTER("WCD_MBHC_FSM_EN",
  539. WCD9335_ANA_MBHC_ELECT, 0x80, 7, 0),
  540. WCD_MBHC_REGISTER("WCD_MBHC_INSREM_DBNC",
  541. WCD9335_MBHC_PLUG_DETECT_CTL, 0x0F, 0, 0),
  542. WCD_MBHC_REGISTER("WCD_MBHC_BTN_DBNC",
  543. WCD9335_MBHC_CTL_1, 0x03, 0, 0),
  544. WCD_MBHC_REGISTER("WCD_MBHC_HS_VREF",
  545. WCD9335_MBHC_CTL_2, 0x03, 0, 0),
  546. WCD_MBHC_REGISTER("WCD_MBHC_HS_COMP_RESULT",
  547. WCD9335_ANA_MBHC_RESULT_3, 0x08, 3, 0),
  548. WCD_MBHC_REGISTER("WCD_MBHC_MIC_SCHMT_RESULT",
  549. WCD9335_ANA_MBHC_RESULT_3, 0x20, 5, 0),
  550. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_SCHMT_RESULT",
  551. WCD9335_ANA_MBHC_RESULT_3, 0x80, 7, 0),
  552. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_SCHMT_RESULT",
  553. WCD9335_ANA_MBHC_RESULT_3, 0x40, 6, 0),
  554. WCD_MBHC_REGISTER("WCD_MBHC_OCP_FSM_EN",
  555. WCD9335_HPH_OCP_CTL, 0x10, 4, 0),
  556. WCD_MBHC_REGISTER("WCD_MBHC_BTN_RESULT",
  557. WCD9335_ANA_MBHC_RESULT_3, 0x07, 0, 0),
  558. WCD_MBHC_REGISTER("WCD_MBHC_BTN_ISRC_CTL",
  559. WCD9335_ANA_MBHC_ELECT, 0x70, 4, 0),
  560. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_RESULT",
  561. WCD9335_ANA_MBHC_RESULT_3, 0xFF, 0, 0),
  562. WCD_MBHC_REGISTER("WCD_MBHC_MICB_CTRL",
  563. WCD9335_ANA_MICB2, 0xC0, 6, 0),
  564. WCD_MBHC_REGISTER("WCD_MBHC_HPH_CNP_WG_TIME",
  565. WCD9335_HPH_CNP_WG_TIME, 0xFF, 0, 0),
  566. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_PA_EN",
  567. WCD9335_ANA_HPH, 0x40, 6, 0),
  568. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PA_EN",
  569. WCD9335_ANA_HPH, 0x80, 7, 0),
  570. WCD_MBHC_REGISTER("WCD_MBHC_HPH_PA_EN",
  571. WCD9335_ANA_HPH, 0xC0, 6, 0),
  572. WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE",
  573. WCD9335_ANA_MBHC_RESULT_3, 0x10, 4, 0),
  574. WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL",
  575. 0, 0, 0, 0),
  576. WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN",
  577. WCD9335_ANA_MBHC_ZDET, 0x01, 0, 0),
  578. /*
  579. * MBHC FSM status register is only available in Tasha 2.0.
  580. * So, init with 0 later once the version is known, then values
  581. * will be updated.
  582. */
  583. WCD_MBHC_REGISTER("WCD_MBHC_FSM_STATUS",
  584. 0, 0, 0, 0),
  585. WCD_MBHC_REGISTER("WCD_MBHC_MUX_CTL",
  586. WCD9335_MBHC_CTL_2, 0x70, 4, 0),
  587. WCD_MBHC_REGISTER("WCD_MBHC_MOISTURE_STATUS",
  588. WCD9335_MBHC_FSM_STATUS, 0X20, 5, 0),
  589. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_GND",
  590. WCD9335_HPH_PA_CTL2, 0x40, 6, 0),
  591. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_GND",
  592. WCD9335_HPH_PA_CTL2, 0x10, 4, 0),
  593. };
  594. static const struct wcd_mbhc_intr intr_ids = {
  595. .mbhc_sw_intr = WCD9335_IRQ_MBHC_SW_DET,
  596. .mbhc_btn_press_intr = WCD9335_IRQ_MBHC_BUTTON_PRESS_DET,
  597. .mbhc_btn_release_intr = WCD9335_IRQ_MBHC_BUTTON_RELEASE_DET,
  598. .mbhc_hs_ins_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
  599. .mbhc_hs_rem_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_DET,
  600. .hph_left_ocp = WCD9335_IRQ_HPH_PA_OCPL_FAULT,
  601. .hph_right_ocp = WCD9335_IRQ_HPH_PA_OCPR_FAULT,
  602. };
  603. struct wcd_vbat {
  604. bool is_enabled;
  605. bool adc_config;
  606. /* Variables to cache Vbat ADC output values */
  607. u16 dcp1;
  608. u16 dcp2;
  609. };
  610. struct hpf_work {
  611. struct tasha_priv *tasha;
  612. u8 decimator;
  613. u8 hpf_cut_off_freq;
  614. struct delayed_work dwork;
  615. };
  616. #define WCD9335_SPK_ANC_EN_DELAY_MS 350
  617. static int spk_anc_en_delay = WCD9335_SPK_ANC_EN_DELAY_MS;
  618. module_param(spk_anc_en_delay, int, 0664);
  619. MODULE_PARM_DESC(spk_anc_en_delay, "delay to enable anc in speaker path");
  620. struct spk_anc_work {
  621. struct tasha_priv *tasha;
  622. struct delayed_work dwork;
  623. };
  624. struct tx_mute_work {
  625. struct tasha_priv *tasha;
  626. u8 decimator;
  627. struct delayed_work dwork;
  628. };
  629. struct tasha_priv {
  630. struct device *dev;
  631. struct wcd9xxx *wcd9xxx;
  632. struct snd_soc_codec *codec;
  633. u32 adc_count;
  634. u32 rx_bias_count;
  635. s32 dmic_0_1_clk_cnt;
  636. s32 dmic_2_3_clk_cnt;
  637. s32 dmic_4_5_clk_cnt;
  638. s32 ldo_h_users;
  639. s32 micb_ref[TASHA_MAX_MICBIAS];
  640. s32 pullup_ref[TASHA_MAX_MICBIAS];
  641. u32 anc_slot;
  642. bool anc_func;
  643. bool is_wsa_attach;
  644. /* Vbat module */
  645. struct wcd_vbat vbat;
  646. /* cal info for codec */
  647. struct fw_info *fw_data;
  648. /*track tasha interface type*/
  649. u8 intf_type;
  650. /* num of slim ports required */
  651. struct wcd9xxx_codec_dai_data dai[NUM_CODEC_DAIS];
  652. /* SoundWire data structure */
  653. struct tasha_swr_ctrl_data *swr_ctrl_data;
  654. int nr;
  655. /*compander*/
  656. int comp_enabled[COMPANDER_MAX];
  657. /* Maintain the status of AUX PGA */
  658. int aux_pga_cnt;
  659. u8 aux_l_gain;
  660. u8 aux_r_gain;
  661. bool spkr_pa_widget_on;
  662. struct regulator *spkdrv_reg;
  663. struct regulator *spkdrv2_reg;
  664. bool mbhc_started;
  665. /* class h specific data */
  666. struct wcd_clsh_cdc_data clsh_d;
  667. struct afe_param_cdc_slimbus_slave_cfg slimbus_slave_cfg;
  668. /*
  669. * list used to save/restore registers at start and
  670. * end of impedance measurement
  671. */
  672. struct list_head reg_save_restore;
  673. /* handle to cpe core */
  674. struct wcd_cpe_core *cpe_core;
  675. u32 current_cpe_clk_freq;
  676. enum tasha_sido_voltage sido_voltage;
  677. int sido_ccl_cnt;
  678. u32 ana_rx_supplies;
  679. /* Multiplication factor used for impedance detection */
  680. int zdet_gain_mul_fact;
  681. /* to track the status */
  682. unsigned long status_mask;
  683. struct work_struct tasha_add_child_devices_work;
  684. struct wcd_swr_ctrl_platform_data swr_plat_data;
  685. /* Port values for Rx and Tx codec_dai */
  686. unsigned int rx_port_value[TASHA_RX_MAX];
  687. unsigned int tx_port_value;
  688. unsigned int vi_feed_value;
  689. /* Tasha Interpolator Mode Select for EAR, HPH_L and HPH_R */
  690. u32 hph_mode;
  691. u16 prim_int_users[TASHA_NUM_INTERPOLATORS];
  692. int spl_src_users[SPLINE_SRC_MAX];
  693. struct wcd9xxx_resmgr_v2 *resmgr;
  694. struct delayed_work power_gate_work;
  695. struct mutex power_lock;
  696. struct mutex sido_lock;
  697. /* mbhc module */
  698. struct wcd_mbhc mbhc;
  699. struct blocking_notifier_head notifier;
  700. struct mutex micb_lock;
  701. struct clk *wcd_ext_clk;
  702. struct clk *wcd_native_clk;
  703. struct mutex swr_read_lock;
  704. struct mutex swr_write_lock;
  705. struct mutex swr_clk_lock;
  706. int swr_clk_users;
  707. int native_clk_users;
  708. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high);
  709. struct snd_info_entry *entry;
  710. struct snd_info_entry *version_entry;
  711. int power_active_ref;
  712. struct on_demand_supply on_demand_list[ON_DEMAND_SUPPLIES_MAX];
  713. int (*machine_codec_event_cb)(struct snd_soc_codec *codec,
  714. enum wcd9335_codec_event);
  715. int spkr_gain_offset;
  716. int spkr_mode;
  717. int ear_spkr_gain;
  718. struct hpf_work tx_hpf_work[TASHA_NUM_DECIMATORS];
  719. struct tx_mute_work tx_mute_dwork[TASHA_NUM_DECIMATORS];
  720. struct spk_anc_work spk_anc_dwork;
  721. struct mutex codec_mutex;
  722. int hph_l_gain;
  723. int hph_r_gain;
  724. int rx_7_count;
  725. int rx_8_count;
  726. bool clk_mode;
  727. bool clk_internal;
  728. /* Lock to prevent multiple functions voting at same time */
  729. struct mutex sb_clk_gear_lock;
  730. /* Count for functions voting or un-voting */
  731. u32 ref_count;
  732. /* Lock to protect mclk enablement */
  733. struct mutex mclk_lock;
  734. struct platform_device *pdev_child_devices
  735. [WCD9335_CHILD_DEVICES_MAX];
  736. int child_count;
  737. };
  738. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  739. bool vote);
  740. static const struct tasha_reg_mask_val tasha_spkr_default[] = {
  741. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  742. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  743. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  744. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  745. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x58},
  746. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x58},
  747. };
  748. static const struct tasha_reg_mask_val tasha_spkr_mode1[] = {
  749. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x00},
  750. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x00},
  751. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x00},
  752. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x00},
  753. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x44},
  754. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x44},
  755. };
  756. /**
  757. * tasha_set_spkr_gain_offset - offset the speaker path
  758. * gain with the given offset value.
  759. *
  760. * @codec: codec instance
  761. * @offset: Indicates speaker path gain offset value.
  762. *
  763. * Returns 0 on success or -EINVAL on error.
  764. */
  765. int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
  766. {
  767. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  768. if (!priv)
  769. return -EINVAL;
  770. priv->spkr_gain_offset = offset;
  771. return 0;
  772. }
  773. EXPORT_SYMBOL(tasha_set_spkr_gain_offset);
  774. /**
  775. * tasha_set_spkr_mode - Configures speaker compander and smartboost
  776. * settings based on speaker mode.
  777. *
  778. * @codec: codec instance
  779. * @mode: Indicates speaker configuration mode.
  780. *
  781. * Returns 0 on success or -EINVAL on error.
  782. */
  783. int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode)
  784. {
  785. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  786. int i;
  787. const struct tasha_reg_mask_val *regs;
  788. int size;
  789. if (!priv)
  790. return -EINVAL;
  791. switch (mode) {
  792. case SPKR_MODE_1:
  793. regs = tasha_spkr_mode1;
  794. size = ARRAY_SIZE(tasha_spkr_mode1);
  795. break;
  796. default:
  797. regs = tasha_spkr_default;
  798. size = ARRAY_SIZE(tasha_spkr_default);
  799. break;
  800. }
  801. priv->spkr_mode = mode;
  802. for (i = 0; i < size; i++)
  803. snd_soc_update_bits(codec, regs[i].reg,
  804. regs[i].mask, regs[i].val);
  805. return 0;
  806. }
  807. EXPORT_SYMBOL(tasha_set_spkr_mode);
  808. static void tasha_enable_sido_buck(struct snd_soc_codec *codec)
  809. {
  810. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  811. snd_soc_update_bits(codec, WCD9335_ANA_RCO, 0x80, 0x80);
  812. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x02, 0x02);
  813. /* 100us sleep needed after IREF settings */
  814. usleep_range(100, 110);
  815. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x04, 0x04);
  816. /* 100us sleep needed after VREF settings */
  817. usleep_range(100, 110);
  818. tasha->resmgr->sido_input_src = SIDO_SOURCE_RCO_BG;
  819. }
  820. static void tasha_cdc_sido_ccl_enable(struct tasha_priv *tasha, bool ccl_flag)
  821. {
  822. struct snd_soc_codec *codec = tasha->codec;
  823. if (!codec)
  824. return;
  825. if (!TASHA_IS_2_0(tasha->wcd9xxx)) {
  826. dev_dbg(codec->dev, "%s: tasha version < 2p0, return\n",
  827. __func__);
  828. return;
  829. }
  830. dev_dbg(codec->dev, "%s: sido_ccl_cnt=%d, ccl_flag:%d\n",
  831. __func__, tasha->sido_ccl_cnt, ccl_flag);
  832. if (ccl_flag) {
  833. if (++tasha->sido_ccl_cnt == 1)
  834. snd_soc_update_bits(codec,
  835. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x6E);
  836. } else {
  837. if (tasha->sido_ccl_cnt == 0) {
  838. dev_dbg(codec->dev, "%s: sido_ccl already disabled\n",
  839. __func__);
  840. return;
  841. }
  842. if (--tasha->sido_ccl_cnt == 0)
  843. snd_soc_update_bits(codec,
  844. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x02);
  845. }
  846. }
  847. static bool tasha_cdc_is_svs_enabled(struct tasha_priv *tasha)
  848. {
  849. if (TASHA_IS_2_0(tasha->wcd9xxx) &&
  850. svs_scaling_enabled)
  851. return true;
  852. return false;
  853. }
  854. static int tasha_cdc_req_mclk_enable(struct tasha_priv *tasha,
  855. bool enable)
  856. {
  857. int ret = 0;
  858. mutex_lock(&tasha->mclk_lock);
  859. if (enable) {
  860. tasha_cdc_sido_ccl_enable(tasha, true);
  861. ret = clk_prepare_enable(tasha->wcd_ext_clk);
  862. if (ret) {
  863. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  864. __func__);
  865. goto unlock_mutex;
  866. }
  867. /* get BG */
  868. wcd_resmgr_enable_master_bias(tasha->resmgr);
  869. /* get MCLK */
  870. wcd_resmgr_enable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  871. } else {
  872. /* put MCLK */
  873. wcd_resmgr_disable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  874. /* put BG */
  875. wcd_resmgr_disable_master_bias(tasha->resmgr);
  876. clk_disable_unprepare(tasha->wcd_ext_clk);
  877. tasha_cdc_sido_ccl_enable(tasha, false);
  878. }
  879. unlock_mutex:
  880. mutex_unlock(&tasha->mclk_lock);
  881. return ret;
  882. }
  883. static int tasha_cdc_check_sido_value(enum tasha_sido_voltage req_mv)
  884. {
  885. if ((req_mv != SIDO_VOLTAGE_SVS_MV) &&
  886. (req_mv != SIDO_VOLTAGE_NOMINAL_MV))
  887. return -EINVAL;
  888. return 0;
  889. }
  890. static void tasha_codec_apply_sido_voltage(
  891. struct tasha_priv *tasha,
  892. enum tasha_sido_voltage req_mv)
  893. {
  894. u32 vout_d_val;
  895. struct snd_soc_codec *codec = tasha->codec;
  896. int ret;
  897. if (!codec)
  898. return;
  899. if (!tasha_cdc_is_svs_enabled(tasha))
  900. return;
  901. if ((sido_buck_svs_voltage != SIDO_VOLTAGE_SVS_MV) &&
  902. (sido_buck_svs_voltage != SIDO_VOLTAGE_NOMINAL_MV))
  903. sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  904. ret = tasha_cdc_check_sido_value(req_mv);
  905. if (ret < 0) {
  906. dev_dbg(codec->dev, "%s: requested mv=%d not in range\n",
  907. __func__, req_mv);
  908. return;
  909. }
  910. if (req_mv == tasha->sido_voltage) {
  911. dev_dbg(codec->dev, "%s: Already at requested mv=%d\n",
  912. __func__, req_mv);
  913. return;
  914. }
  915. if (req_mv == sido_buck_svs_voltage) {
  916. if (test_bit(AUDIO_NOMINAL, &tasha->status_mask) ||
  917. test_bit(CPE_NOMINAL, &tasha->status_mask)) {
  918. dev_dbg(codec->dev,
  919. "%s: nominal client running, status_mask=%lu\n",
  920. __func__, tasha->status_mask);
  921. return;
  922. }
  923. }
  924. /* compute the vout_d step value */
  925. vout_d_val = CALCULATE_VOUT_D(req_mv);
  926. snd_soc_write(codec, WCD9335_ANA_BUCK_VOUT_D, vout_d_val & 0xFF);
  927. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x80, 0x80);
  928. /* 1 msec sleep required after SIDO Vout_D voltage change */
  929. usleep_range(1000, 1100);
  930. tasha->sido_voltage = req_mv;
  931. dev_dbg(codec->dev,
  932. "%s: updated SIDO buck Vout_D to %d, vout_d step = %u\n",
  933. __func__, tasha->sido_voltage, vout_d_val);
  934. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL,
  935. 0x80, 0x00);
  936. }
  937. static int tasha_codec_update_sido_voltage(
  938. struct tasha_priv *tasha,
  939. enum tasha_sido_voltage req_mv)
  940. {
  941. int ret = 0;
  942. if (!tasha_cdc_is_svs_enabled(tasha))
  943. return ret;
  944. mutex_lock(&tasha->sido_lock);
  945. /* enable mclk before setting SIDO voltage */
  946. ret = tasha_cdc_req_mclk_enable(tasha, true);
  947. if (ret) {
  948. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  949. __func__);
  950. goto err;
  951. }
  952. tasha_codec_apply_sido_voltage(tasha, req_mv);
  953. tasha_cdc_req_mclk_enable(tasha, false);
  954. err:
  955. mutex_unlock(&tasha->sido_lock);
  956. return ret;
  957. }
  958. int tasha_enable_efuse_sensing(struct snd_soc_codec *codec)
  959. {
  960. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  961. tasha_cdc_mclk_enable(codec, true, false);
  962. if (!TASHA_IS_2_0(priv->wcd9xxx))
  963. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  964. 0x1E, 0x02);
  965. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  966. 0x01, 0x01);
  967. /*
  968. * 5ms sleep required after enabling efuse control
  969. * before checking the status.
  970. */
  971. usleep_range(5000, 5500);
  972. if (!(snd_soc_read(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01))
  973. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  974. if (TASHA_IS_2_0(priv->wcd9xxx)) {
  975. if (!(snd_soc_read(codec,
  976. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0) & 0x40))
  977. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST,
  978. 0x04, 0x00);
  979. tasha_enable_sido_buck(codec);
  980. }
  981. tasha_cdc_mclk_enable(codec, false, false);
  982. return 0;
  983. }
  984. EXPORT_SYMBOL(tasha_enable_efuse_sensing);
  985. void *tasha_get_afe_config(struct snd_soc_codec *codec,
  986. enum afe_config_type config_type)
  987. {
  988. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  989. switch (config_type) {
  990. case AFE_SLIMBUS_SLAVE_CONFIG:
  991. return &priv->slimbus_slave_cfg;
  992. case AFE_CDC_REGISTERS_CONFIG:
  993. return &tasha_audio_reg_cfg;
  994. case AFE_SLIMBUS_SLAVE_PORT_CONFIG:
  995. return &tasha_slimbus_slave_port_cfg;
  996. case AFE_AANC_VERSION:
  997. return &tasha_cdc_aanc_version;
  998. case AFE_CLIP_BANK_SEL:
  999. return NULL;
  1000. case AFE_CDC_CLIP_REGISTERS_CONFIG:
  1001. return NULL;
  1002. case AFE_CDC_REGISTER_PAGE_CONFIG:
  1003. return &tasha_cdc_reg_page_cfg;
  1004. default:
  1005. dev_err(codec->dev, "%s: Unknown config_type 0x%x\n",
  1006. __func__, config_type);
  1007. return NULL;
  1008. }
  1009. }
  1010. EXPORT_SYMBOL(tasha_get_afe_config);
  1011. /*
  1012. * tasha_event_register: Registers a machine driver callback
  1013. * function with codec private data for post ADSP sub-system
  1014. * restart (SSR). This callback function will be called from
  1015. * codec driver once codec comes out of reset after ADSP SSR.
  1016. *
  1017. * @machine_event_cb: callback function from machine driver
  1018. * @codec: Codec instance
  1019. *
  1020. * Return: none
  1021. */
  1022. void tasha_event_register(
  1023. int (*machine_event_cb)(struct snd_soc_codec *codec,
  1024. enum wcd9335_codec_event),
  1025. struct snd_soc_codec *codec)
  1026. {
  1027. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1028. if (tasha)
  1029. tasha->machine_codec_event_cb = machine_event_cb;
  1030. else
  1031. dev_dbg(codec->dev, "%s: Invalid tasha_priv data\n", __func__);
  1032. }
  1033. EXPORT_SYMBOL(tasha_event_register);
  1034. static int tasha_mbhc_request_irq(struct snd_soc_codec *codec,
  1035. int irq, irq_handler_t handler,
  1036. const char *name, void *data)
  1037. {
  1038. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1039. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1040. struct wcd9xxx_core_resource *core_res =
  1041. &wcd9xxx->core_res;
  1042. return wcd9xxx_request_irq(core_res, irq, handler, name, data);
  1043. }
  1044. static void tasha_mbhc_irq_control(struct snd_soc_codec *codec,
  1045. int irq, bool enable)
  1046. {
  1047. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1048. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1049. struct wcd9xxx_core_resource *core_res =
  1050. &wcd9xxx->core_res;
  1051. if (enable)
  1052. wcd9xxx_enable_irq(core_res, irq);
  1053. else
  1054. wcd9xxx_disable_irq(core_res, irq);
  1055. }
  1056. static int tasha_mbhc_free_irq(struct snd_soc_codec *codec,
  1057. int irq, void *data)
  1058. {
  1059. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1060. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1061. struct wcd9xxx_core_resource *core_res =
  1062. &wcd9xxx->core_res;
  1063. wcd9xxx_free_irq(core_res, irq, data);
  1064. return 0;
  1065. }
  1066. static void tasha_mbhc_clk_setup(struct snd_soc_codec *codec,
  1067. bool enable)
  1068. {
  1069. if (enable)
  1070. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1071. 0x80, 0x80);
  1072. else
  1073. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1074. 0x80, 0x00);
  1075. }
  1076. static int tasha_mbhc_btn_to_num(struct snd_soc_codec *codec)
  1077. {
  1078. return snd_soc_read(codec, WCD9335_ANA_MBHC_RESULT_3) & 0x7;
  1079. }
  1080. static void tasha_mbhc_mbhc_bias_control(struct snd_soc_codec *codec,
  1081. bool enable)
  1082. {
  1083. if (enable)
  1084. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1085. 0x01, 0x01);
  1086. else
  1087. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1088. 0x01, 0x00);
  1089. }
  1090. static void tasha_mbhc_program_btn_thr(struct snd_soc_codec *codec,
  1091. s16 *btn_low, s16 *btn_high,
  1092. int num_btn, bool is_micbias)
  1093. {
  1094. int i;
  1095. int vth;
  1096. if (num_btn > WCD_MBHC_DEF_BUTTONS) {
  1097. dev_err(codec->dev, "%s: invalid number of buttons: %d\n",
  1098. __func__, num_btn);
  1099. return;
  1100. }
  1101. /*
  1102. * Tasha just needs one set of thresholds for button detection
  1103. * due to micbias voltage ramp to pullup upon button press. So
  1104. * btn_low and is_micbias are ignored and always program button
  1105. * thresholds using btn_high.
  1106. */
  1107. for (i = 0; i < num_btn; i++) {
  1108. vth = ((btn_high[i] * 2) / 25) & 0x3F;
  1109. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN0 + i,
  1110. 0xFC, vth << 2);
  1111. dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
  1112. __func__, i, btn_high[i], vth);
  1113. }
  1114. }
  1115. static bool tasha_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
  1116. {
  1117. struct snd_soc_codec *codec = mbhc->codec;
  1118. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1119. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1120. struct wcd9xxx_core_resource *core_res =
  1121. &wcd9xxx->core_res;
  1122. if (lock)
  1123. return wcd9xxx_lock_sleep(core_res);
  1124. else {
  1125. wcd9xxx_unlock_sleep(core_res);
  1126. return 0;
  1127. }
  1128. }
  1129. static int tasha_mbhc_register_notifier(struct wcd_mbhc *mbhc,
  1130. struct notifier_block *nblock,
  1131. bool enable)
  1132. {
  1133. struct snd_soc_codec *codec = mbhc->codec;
  1134. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1135. if (enable)
  1136. return blocking_notifier_chain_register(&tasha->notifier,
  1137. nblock);
  1138. else
  1139. return blocking_notifier_chain_unregister(&tasha->notifier,
  1140. nblock);
  1141. }
  1142. static bool tasha_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
  1143. {
  1144. u8 val;
  1145. if (micb_num == MIC_BIAS_2) {
  1146. val = (snd_soc_read(mbhc->codec, WCD9335_ANA_MICB2) >> 6);
  1147. if (val == 0x01)
  1148. return true;
  1149. }
  1150. return false;
  1151. }
  1152. static bool tasha_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
  1153. {
  1154. return (snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0) ? true : false;
  1155. }
  1156. static void tasha_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec,
  1157. enum mbhc_hs_pullup_iref pull_up_cur)
  1158. {
  1159. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1160. if (!tasha)
  1161. return;
  1162. /* Default pull up current to 2uA */
  1163. if (pull_up_cur < I_OFF || pull_up_cur > I_3P0_UA ||
  1164. pull_up_cur == I_DEFAULT)
  1165. pull_up_cur = I_2P0_UA;
  1166. dev_dbg(codec->dev, "%s: HS pull up current:%d\n",
  1167. __func__, pull_up_cur);
  1168. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1169. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1170. 0xC0, pull_up_cur << 6);
  1171. else
  1172. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1173. 0xC0, 0x40);
  1174. }
  1175. static int tasha_enable_ext_mb_source(struct wcd_mbhc *mbhc,
  1176. bool turn_on)
  1177. {
  1178. struct snd_soc_codec *codec = mbhc->codec;
  1179. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1180. int ret = 0;
  1181. struct on_demand_supply *supply;
  1182. if (!tasha)
  1183. return -EINVAL;
  1184. supply = &tasha->on_demand_list[ON_DEMAND_MICBIAS];
  1185. if (!supply->supply) {
  1186. dev_dbg(codec->dev, "%s: warning supply not present ond for %s\n",
  1187. __func__, "onDemand Micbias");
  1188. return ret;
  1189. }
  1190. dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
  1191. supply->ondemand_supply_count);
  1192. if (turn_on) {
  1193. if (!(supply->ondemand_supply_count)) {
  1194. ret = snd_soc_dapm_force_enable_pin(
  1195. snd_soc_codec_get_dapm(codec),
  1196. "MICBIAS_REGULATOR");
  1197. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1198. }
  1199. supply->ondemand_supply_count++;
  1200. } else {
  1201. if (supply->ondemand_supply_count > 0)
  1202. supply->ondemand_supply_count--;
  1203. if (!(supply->ondemand_supply_count)) {
  1204. ret = snd_soc_dapm_disable_pin(
  1205. snd_soc_codec_get_dapm(codec),
  1206. "MICBIAS_REGULATOR");
  1207. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1208. }
  1209. }
  1210. if (ret)
  1211. dev_err(codec->dev, "%s: Failed to %s external micbias source\n",
  1212. __func__, turn_on ? "enable" : "disabled");
  1213. else
  1214. dev_dbg(codec->dev, "%s: %s external micbias source\n",
  1215. __func__, turn_on ? "Enabled" : "Disabled");
  1216. return ret;
  1217. }
  1218. static int tasha_micbias_control(struct snd_soc_codec *codec,
  1219. int micb_num,
  1220. int req, bool is_dapm)
  1221. {
  1222. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1223. int micb_index = micb_num - 1;
  1224. u16 micb_reg;
  1225. int pre_off_event = 0, post_off_event = 0;
  1226. int post_on_event = 0, post_dapm_off = 0;
  1227. int post_dapm_on = 0;
  1228. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  1229. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  1230. __func__, micb_index);
  1231. return -EINVAL;
  1232. }
  1233. switch (micb_num) {
  1234. case MIC_BIAS_1:
  1235. micb_reg = WCD9335_ANA_MICB1;
  1236. break;
  1237. case MIC_BIAS_2:
  1238. micb_reg = WCD9335_ANA_MICB2;
  1239. pre_off_event = WCD_EVENT_PRE_MICBIAS_2_OFF;
  1240. post_off_event = WCD_EVENT_POST_MICBIAS_2_OFF;
  1241. post_on_event = WCD_EVENT_POST_MICBIAS_2_ON;
  1242. post_dapm_on = WCD_EVENT_POST_DAPM_MICBIAS_2_ON;
  1243. post_dapm_off = WCD_EVENT_POST_DAPM_MICBIAS_2_OFF;
  1244. break;
  1245. case MIC_BIAS_3:
  1246. micb_reg = WCD9335_ANA_MICB3;
  1247. break;
  1248. case MIC_BIAS_4:
  1249. micb_reg = WCD9335_ANA_MICB4;
  1250. break;
  1251. default:
  1252. dev_err(codec->dev, "%s: Invalid micbias number: %d\n",
  1253. __func__, micb_num);
  1254. return -EINVAL;
  1255. }
  1256. mutex_lock(&tasha->micb_lock);
  1257. switch (req) {
  1258. case MICB_PULLUP_ENABLE:
  1259. tasha->pullup_ref[micb_index]++;
  1260. if ((tasha->pullup_ref[micb_index] == 1) &&
  1261. (tasha->micb_ref[micb_index] == 0))
  1262. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1263. break;
  1264. case MICB_PULLUP_DISABLE:
  1265. if (tasha->pullup_ref[micb_index] > 0)
  1266. tasha->pullup_ref[micb_index]--;
  1267. if ((tasha->pullup_ref[micb_index] == 0) &&
  1268. (tasha->micb_ref[micb_index] == 0))
  1269. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1270. break;
  1271. case MICB_ENABLE:
  1272. tasha->micb_ref[micb_index]++;
  1273. if (tasha->micb_ref[micb_index] == 1) {
  1274. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1275. if (post_on_event)
  1276. blocking_notifier_call_chain(&tasha->notifier,
  1277. post_on_event, &tasha->mbhc);
  1278. }
  1279. if (is_dapm && post_dapm_on)
  1280. blocking_notifier_call_chain(&tasha->notifier,
  1281. post_dapm_on, &tasha->mbhc);
  1282. break;
  1283. case MICB_DISABLE:
  1284. if (tasha->micb_ref[micb_index] > 0)
  1285. tasha->micb_ref[micb_index]--;
  1286. if ((tasha->micb_ref[micb_index] == 0) &&
  1287. (tasha->pullup_ref[micb_index] > 0))
  1288. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1289. else if ((tasha->micb_ref[micb_index] == 0) &&
  1290. (tasha->pullup_ref[micb_index] == 0)) {
  1291. if (pre_off_event)
  1292. blocking_notifier_call_chain(&tasha->notifier,
  1293. pre_off_event, &tasha->mbhc);
  1294. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1295. if (post_off_event)
  1296. blocking_notifier_call_chain(&tasha->notifier,
  1297. post_off_event, &tasha->mbhc);
  1298. }
  1299. if (is_dapm && post_dapm_off)
  1300. blocking_notifier_call_chain(&tasha->notifier,
  1301. post_dapm_off, &tasha->mbhc);
  1302. break;
  1303. };
  1304. dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n",
  1305. __func__, micb_num, tasha->micb_ref[micb_index],
  1306. tasha->pullup_ref[micb_index]);
  1307. mutex_unlock(&tasha->micb_lock);
  1308. return 0;
  1309. }
  1310. static int tasha_mbhc_request_micbias(struct snd_soc_codec *codec,
  1311. int micb_num, int req)
  1312. {
  1313. int ret;
  1314. /*
  1315. * If micbias is requested, make sure that there
  1316. * is vote to enable mclk
  1317. */
  1318. if (req == MICB_ENABLE)
  1319. tasha_cdc_mclk_enable(codec, true, false);
  1320. ret = tasha_micbias_control(codec, micb_num, req, false);
  1321. /*
  1322. * Release vote for mclk while requesting for
  1323. * micbias disable
  1324. */
  1325. if (req == MICB_DISABLE)
  1326. tasha_cdc_mclk_enable(codec, false, false);
  1327. return ret;
  1328. }
  1329. static void tasha_mbhc_micb_ramp_control(struct snd_soc_codec *codec,
  1330. bool enable)
  1331. {
  1332. if (enable) {
  1333. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1334. 0x1C, 0x0C);
  1335. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1336. 0x80, 0x80);
  1337. } else {
  1338. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1339. 0x80, 0x00);
  1340. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1341. 0x1C, 0x00);
  1342. }
  1343. }
  1344. static struct firmware_cal *tasha_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
  1345. enum wcd_cal_type type)
  1346. {
  1347. struct tasha_priv *tasha;
  1348. struct firmware_cal *hwdep_cal;
  1349. struct snd_soc_codec *codec = mbhc->codec;
  1350. if (!codec) {
  1351. pr_err("%s: NULL codec pointer\n", __func__);
  1352. return NULL;
  1353. }
  1354. tasha = snd_soc_codec_get_drvdata(codec);
  1355. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, type);
  1356. if (!hwdep_cal)
  1357. dev_err(codec->dev, "%s: cal not sent by %d\n",
  1358. __func__, type);
  1359. return hwdep_cal;
  1360. }
  1361. static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
  1362. int req_volt,
  1363. int micb_num)
  1364. {
  1365. int cur_vout_ctl, req_vout_ctl;
  1366. int micb_reg, micb_val, micb_en;
  1367. switch (micb_num) {
  1368. case MIC_BIAS_1:
  1369. micb_reg = WCD9335_ANA_MICB1;
  1370. break;
  1371. case MIC_BIAS_2:
  1372. micb_reg = WCD9335_ANA_MICB2;
  1373. break;
  1374. case MIC_BIAS_3:
  1375. micb_reg = WCD9335_ANA_MICB3;
  1376. break;
  1377. case MIC_BIAS_4:
  1378. micb_reg = WCD9335_ANA_MICB4;
  1379. break;
  1380. default:
  1381. return -EINVAL;
  1382. }
  1383. /*
  1384. * If requested micbias voltage is same as current micbias
  1385. * voltage, then just return. Otherwise, adjust voltage as
  1386. * per requested value. If micbias is already enabled, then
  1387. * to avoid slow micbias ramp-up or down enable pull-up
  1388. * momentarily, change the micbias value and then re-enable
  1389. * micbias.
  1390. */
  1391. micb_val = snd_soc_read(codec, micb_reg);
  1392. micb_en = (micb_val & 0xC0) >> 6;
  1393. cur_vout_ctl = micb_val & 0x3F;
  1394. req_vout_ctl = wcd9335_get_micb_vout_ctl_val(req_volt);
  1395. if (req_vout_ctl < 0)
  1396. return -EINVAL;
  1397. if (cur_vout_ctl == req_vout_ctl)
  1398. return 0;
  1399. dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n",
  1400. __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl),
  1401. req_volt, micb_en);
  1402. if (micb_en == 0x1)
  1403. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1404. snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl);
  1405. if (micb_en == 0x1) {
  1406. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1407. /*
  1408. * Add 2ms delay as per HW requirement after enabling
  1409. * micbias
  1410. */
  1411. usleep_range(2000, 2100);
  1412. }
  1413. return 0;
  1414. }
  1415. static int tasha_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
  1416. int micb_num, bool req_en)
  1417. {
  1418. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1419. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  1420. int rc, micb_mv;
  1421. if (micb_num != MIC_BIAS_2)
  1422. return -EINVAL;
  1423. /*
  1424. * If device tree micbias level is already above the minimum
  1425. * voltage needed to detect threshold microphone, then do
  1426. * not change the micbias, just return.
  1427. */
  1428. if (pdata->micbias.micb2_mv >= WCD_MBHC_THR_HS_MICB_MV)
  1429. return 0;
  1430. micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv;
  1431. mutex_lock(&tasha->micb_lock);
  1432. rc = tasha_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2);
  1433. mutex_unlock(&tasha->micb_lock);
  1434. return rc;
  1435. }
  1436. static inline void tasha_mbhc_get_result_params(struct wcd9xxx *wcd9xxx,
  1437. s16 *d1_a, u16 noff,
  1438. int32_t *zdet)
  1439. {
  1440. int i;
  1441. int val, val1;
  1442. s16 c1;
  1443. s32 x1, d1;
  1444. int32_t denom;
  1445. int minCode_param[] = {
  1446. 3277, 1639, 820, 410, 205, 103, 52, 26
  1447. };
  1448. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x20);
  1449. for (i = 0; i < TASHA_ZDET_NUM_MEASUREMENTS; i++) {
  1450. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_2, &val);
  1451. if (val & 0x80)
  1452. break;
  1453. }
  1454. val = val << 0x8;
  1455. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_1, &val1);
  1456. val |= val1;
  1457. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x00);
  1458. x1 = TASHA_MBHC_GET_X1(val);
  1459. c1 = TASHA_MBHC_GET_C1(val);
  1460. /* If ramp is not complete, give additional 5ms */
  1461. if ((c1 < 2) && x1)
  1462. usleep_range(5000, 5050);
  1463. if (!c1 || !x1) {
  1464. dev_dbg(wcd9xxx->dev,
  1465. "%s: Impedance detect ramp error, c1=%d, x1=0x%x\n",
  1466. __func__, c1, x1);
  1467. goto ramp_down;
  1468. }
  1469. d1 = d1_a[c1];
  1470. denom = (x1 * d1) - (1 << (14 - noff));
  1471. if (denom > 0)
  1472. *zdet = (TASHA_MBHC_ZDET_CONST * 1000) / denom;
  1473. else if (x1 < minCode_param[noff])
  1474. *zdet = TASHA_ZDET_FLOATING_IMPEDANCE;
  1475. dev_dbg(wcd9xxx->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
  1476. __func__, d1, c1, x1, *zdet);
  1477. ramp_down:
  1478. i = 0;
  1479. while (x1) {
  1480. regmap_bulk_read(wcd9xxx->regmap,
  1481. WCD9335_ANA_MBHC_RESULT_1, (u8 *)&val, 2);
  1482. x1 = TASHA_MBHC_GET_X1(val);
  1483. i++;
  1484. if (i == TASHA_ZDET_NUM_MEASUREMENTS)
  1485. break;
  1486. }
  1487. }
  1488. /*
  1489. * tasha_mbhc_zdet_gpio_ctrl: Register callback function for
  1490. * controlling the switch on hifi amps. Default switch state
  1491. * will put a 51ohm load in parallel to the hph load. So,
  1492. * impedance detection function will pull the gpio high
  1493. * to make the switch open.
  1494. *
  1495. * @zdet_gpio_cb: callback function from machine driver
  1496. * @codec: Codec instance
  1497. *
  1498. * Return: none
  1499. */
  1500. void tasha_mbhc_zdet_gpio_ctrl(
  1501. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
  1502. struct snd_soc_codec *codec)
  1503. {
  1504. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1505. tasha->zdet_gpio_cb = zdet_gpio_cb;
  1506. }
  1507. EXPORT_SYMBOL(tasha_mbhc_zdet_gpio_ctrl);
  1508. static void tasha_mbhc_zdet_ramp(struct snd_soc_codec *codec,
  1509. struct tasha_mbhc_zdet_param *zdet_param,
  1510. int32_t *zl, int32_t *zr, s16 *d1_a)
  1511. {
  1512. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  1513. int32_t zdet = 0;
  1514. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x70,
  1515. zdet_param->ldo_ctl << 4);
  1516. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN5, 0xFC,
  1517. zdet_param->btn5);
  1518. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN6, 0xFC,
  1519. zdet_param->btn6);
  1520. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN7, 0xFC,
  1521. zdet_param->btn7);
  1522. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x0F,
  1523. zdet_param->noff);
  1524. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x0F,
  1525. zdet_param->nshift);
  1526. if (!zl)
  1527. goto z_right;
  1528. /* Start impedance measurement for HPH_L */
  1529. regmap_update_bits(wcd9xxx->regmap,
  1530. WCD9335_ANA_MBHC_ZDET, 0x80, 0x80);
  1531. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_L, noff = %d\n",
  1532. __func__, zdet_param->noff);
  1533. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1534. regmap_update_bits(wcd9xxx->regmap,
  1535. WCD9335_ANA_MBHC_ZDET, 0x80, 0x00);
  1536. *zl = zdet;
  1537. z_right:
  1538. if (!zr)
  1539. return;
  1540. /* Start impedance measurement for HPH_R */
  1541. regmap_update_bits(wcd9xxx->regmap,
  1542. WCD9335_ANA_MBHC_ZDET, 0x40, 0x40);
  1543. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_R, noff = %d\n",
  1544. __func__, zdet_param->noff);
  1545. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1546. regmap_update_bits(wcd9xxx->regmap,
  1547. WCD9335_ANA_MBHC_ZDET, 0x40, 0x00);
  1548. *zr = zdet;
  1549. }
  1550. static inline void tasha_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
  1551. int32_t *z_val, int flag_l_r)
  1552. {
  1553. s16 q1;
  1554. int q1_cal;
  1555. if (*z_val < (TASHA_ZDET_VAL_400/1000))
  1556. q1 = snd_soc_read(codec,
  1557. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r));
  1558. else
  1559. q1 = snd_soc_read(codec,
  1560. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r));
  1561. if (q1 & 0x80)
  1562. q1_cal = (10000 - ((q1 & 0x7F) * 25));
  1563. else
  1564. q1_cal = (10000 + (q1 * 25));
  1565. if (q1_cal > 0)
  1566. *z_val = ((*z_val) * 10000) / q1_cal;
  1567. }
  1568. static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
  1569. uint32_t *zr)
  1570. {
  1571. struct snd_soc_codec *codec = mbhc->codec;
  1572. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1573. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1574. s16 reg0, reg1, reg2, reg3, reg4;
  1575. int32_t z1L, z1R, z1Ls;
  1576. int zMono, z_diff1, z_diff2;
  1577. bool is_fsm_disable = false;
  1578. bool is_change = false;
  1579. struct tasha_mbhc_zdet_param zdet_param[] = {
  1580. {4, 0, 4, 0x08, 0x14, 0x18}, /* < 32ohm */
  1581. {2, 0, 3, 0x18, 0x7C, 0x90}, /* 32ohm < Z < 400ohm */
  1582. {1, 4, 5, 0x18, 0x7C, 0x90}, /* 400ohm < Z < 1200ohm */
  1583. {1, 6, 7, 0x18, 0x7C, 0x90}, /* >1200ohm */
  1584. };
  1585. struct tasha_mbhc_zdet_param *zdet_param_ptr = NULL;
  1586. s16 d1_a[][4] = {
  1587. {0, 30, 90, 30},
  1588. {0, 30, 30, 5},
  1589. {0, 30, 30, 5},
  1590. {0, 30, 30, 5},
  1591. };
  1592. s16 *d1 = NULL;
  1593. if (!TASHA_IS_2_0(wcd9xxx)) {
  1594. dev_dbg(codec->dev, "%s: Z-det is not supported for this codec version\n",
  1595. __func__);
  1596. *zl = 0;
  1597. *zr = 0;
  1598. return;
  1599. }
  1600. WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
  1601. if (tasha->zdet_gpio_cb)
  1602. is_change = tasha->zdet_gpio_cb(codec, true);
  1603. reg0 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN5);
  1604. reg1 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN6);
  1605. reg2 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN7);
  1606. reg3 = snd_soc_read(codec, WCD9335_MBHC_CTL_1);
  1607. reg4 = snd_soc_read(codec, WCD9335_MBHC_ZDET_ANA_CTL);
  1608. if (snd_soc_read(codec, WCD9335_ANA_MBHC_ELECT) & 0x80) {
  1609. is_fsm_disable = true;
  1610. regmap_update_bits(wcd9xxx->regmap,
  1611. WCD9335_ANA_MBHC_ELECT, 0x80, 0x00);
  1612. }
  1613. /* For NO-jack, disable L_DET_EN before Z-det measurements */
  1614. if (mbhc->hphl_swh)
  1615. regmap_update_bits(wcd9xxx->regmap,
  1616. WCD9335_ANA_MBHC_MECH, 0x80, 0x00);
  1617. /* Enable AZ */
  1618. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1, 0x0C, 0x04);
  1619. /* Turn off 100k pull down on HPHL */
  1620. regmap_update_bits(wcd9xxx->regmap,
  1621. WCD9335_ANA_MBHC_MECH, 0x01, 0x00);
  1622. /* First get impedance on Left */
  1623. d1 = d1_a[1];
  1624. zdet_param_ptr = &zdet_param[1];
  1625. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1626. if (!TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
  1627. goto left_ch_impedance;
  1628. /* second ramp for left ch */
  1629. if (z1L < TASHA_ZDET_VAL_32) {
  1630. zdet_param_ptr = &zdet_param[0];
  1631. d1 = d1_a[0];
  1632. } else if ((z1L > TASHA_ZDET_VAL_400) && (z1L <= TASHA_ZDET_VAL_1200)) {
  1633. zdet_param_ptr = &zdet_param[2];
  1634. d1 = d1_a[2];
  1635. } else if (z1L > TASHA_ZDET_VAL_1200) {
  1636. zdet_param_ptr = &zdet_param[3];
  1637. d1 = d1_a[3];
  1638. }
  1639. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1640. left_ch_impedance:
  1641. if ((z1L == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1642. (z1L > TASHA_ZDET_VAL_100K)) {
  1643. *zl = TASHA_ZDET_FLOATING_IMPEDANCE;
  1644. zdet_param_ptr = &zdet_param[1];
  1645. d1 = d1_a[1];
  1646. } else {
  1647. *zl = z1L/1000;
  1648. tasha_wcd_mbhc_qfuse_cal(codec, zl, 0);
  1649. }
  1650. dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n",
  1651. __func__, *zl);
  1652. /* start of right impedance ramp and calculation */
  1653. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1654. if (TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
  1655. if (((z1R > TASHA_ZDET_VAL_1200) &&
  1656. (zdet_param_ptr->noff == 0x6)) ||
  1657. ((*zl) != TASHA_ZDET_FLOATING_IMPEDANCE))
  1658. goto right_ch_impedance;
  1659. /* second ramp for right ch */
  1660. if (z1R < TASHA_ZDET_VAL_32) {
  1661. zdet_param_ptr = &zdet_param[0];
  1662. d1 = d1_a[0];
  1663. } else if ((z1R > TASHA_ZDET_VAL_400) &&
  1664. (z1R <= TASHA_ZDET_VAL_1200)) {
  1665. zdet_param_ptr = &zdet_param[2];
  1666. d1 = d1_a[2];
  1667. } else if (z1R > TASHA_ZDET_VAL_1200) {
  1668. zdet_param_ptr = &zdet_param[3];
  1669. d1 = d1_a[3];
  1670. }
  1671. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1672. }
  1673. right_ch_impedance:
  1674. if ((z1R == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1675. (z1R > TASHA_ZDET_VAL_100K)) {
  1676. *zr = TASHA_ZDET_FLOATING_IMPEDANCE;
  1677. } else {
  1678. *zr = z1R/1000;
  1679. tasha_wcd_mbhc_qfuse_cal(codec, zr, 1);
  1680. }
  1681. dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n",
  1682. __func__, *zr);
  1683. /* mono/stereo detection */
  1684. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) &&
  1685. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE)) {
  1686. dev_dbg(codec->dev,
  1687. "%s: plug type is invalid or extension cable\n",
  1688. __func__);
  1689. goto zdet_complete;
  1690. }
  1691. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1692. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1693. ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
  1694. ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
  1695. dev_dbg(codec->dev,
  1696. "%s: Mono plug type with one ch floating or shorted to GND\n",
  1697. __func__);
  1698. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1699. goto zdet_complete;
  1700. }
  1701. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x02);
  1702. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x01);
  1703. if (*zl < (TASHA_ZDET_VAL_32/1000))
  1704. tasha_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1);
  1705. else
  1706. tasha_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1);
  1707. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x00);
  1708. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x00);
  1709. z1Ls /= 1000;
  1710. tasha_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0);
  1711. /* parallel of left Z and 9 ohm pull down resistor */
  1712. zMono = ((*zl) * 9) / ((*zl) + 9);
  1713. z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
  1714. z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
  1715. if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
  1716. dev_dbg(codec->dev, "%s: stereo plug type detected\n",
  1717. __func__);
  1718. mbhc->hph_type = WCD_MBHC_HPH_STEREO;
  1719. } else {
  1720. dev_dbg(codec->dev, "%s: MONO plug type detected\n",
  1721. __func__);
  1722. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1723. }
  1724. zdet_complete:
  1725. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN5, reg0);
  1726. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN6, reg1);
  1727. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN7, reg2);
  1728. /* Turn on 100k pull down on HPHL */
  1729. regmap_update_bits(wcd9xxx->regmap,
  1730. WCD9335_ANA_MBHC_MECH, 0x01, 0x01);
  1731. /* For NO-jack, re-enable L_DET_EN after Z-det measurements */
  1732. if (mbhc->hphl_swh)
  1733. regmap_update_bits(wcd9xxx->regmap,
  1734. WCD9335_ANA_MBHC_MECH, 0x80, 0x80);
  1735. snd_soc_write(codec, WCD9335_MBHC_ZDET_ANA_CTL, reg4);
  1736. snd_soc_write(codec, WCD9335_MBHC_CTL_1, reg3);
  1737. if (is_fsm_disable)
  1738. regmap_update_bits(wcd9xxx->regmap,
  1739. WCD9335_ANA_MBHC_ELECT, 0x80, 0x80);
  1740. if (tasha->zdet_gpio_cb && is_change)
  1741. tasha->zdet_gpio_cb(codec, false);
  1742. }
  1743. static void tasha_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable)
  1744. {
  1745. if (enable) {
  1746. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1747. 0x02, 0x02);
  1748. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1749. 0x40, 0x40);
  1750. } else {
  1751. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1752. 0x40, 0x00);
  1753. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1754. 0x02, 0x00);
  1755. }
  1756. }
  1757. static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec,
  1758. bool enable)
  1759. {
  1760. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1761. if (enable) {
  1762. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1763. 0x40, 0x40);
  1764. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1765. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1766. 0x10, 0x10);
  1767. } else {
  1768. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1769. 0x40, 0x00);
  1770. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1771. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1772. 0x10, 0x00);
  1773. }
  1774. }
  1775. static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc)
  1776. {
  1777. struct snd_soc_codec *codec = mbhc->codec;
  1778. if (mbhc->moist_vref == V_OFF)
  1779. return;
  1780. /* Donot enable moisture detection if jack type is NC */
  1781. if (!mbhc->hphl_swh) {
  1782. dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
  1783. __func__);
  1784. return;
  1785. }
  1786. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2,
  1787. 0x0C, mbhc->moist_vref << 2);
  1788. tasha_mbhc_hph_l_pull_up_control(codec, mbhc->moist_iref);
  1789. }
  1790. static void tasha_update_anc_state(struct snd_soc_codec *codec, bool enable,
  1791. int anc_num)
  1792. {
  1793. if (enable)
  1794. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1795. (20 * anc_num), 0x10, 0x10);
  1796. else
  1797. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1798. (20 * anc_num), 0x10, 0x00);
  1799. }
  1800. static bool tasha_is_anc_on(struct wcd_mbhc *mbhc)
  1801. {
  1802. bool anc_on = false;
  1803. u16 ancl, ancr;
  1804. ancl =
  1805. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX1_RX_PATH_CFG0)) & 0x10;
  1806. ancr =
  1807. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX2_RX_PATH_CFG0)) & 0x10;
  1808. anc_on = !!(ancl | ancr);
  1809. return anc_on;
  1810. }
  1811. static const struct wcd_mbhc_cb mbhc_cb = {
  1812. .request_irq = tasha_mbhc_request_irq,
  1813. .irq_control = tasha_mbhc_irq_control,
  1814. .free_irq = tasha_mbhc_free_irq,
  1815. .clk_setup = tasha_mbhc_clk_setup,
  1816. .map_btn_code_to_num = tasha_mbhc_btn_to_num,
  1817. .enable_mb_source = tasha_enable_ext_mb_source,
  1818. .mbhc_bias = tasha_mbhc_mbhc_bias_control,
  1819. .set_btn_thr = tasha_mbhc_program_btn_thr,
  1820. .lock_sleep = tasha_mbhc_lock_sleep,
  1821. .register_notifier = tasha_mbhc_register_notifier,
  1822. .micbias_enable_status = tasha_mbhc_micb_en_status,
  1823. .hph_pa_on_status = tasha_mbhc_hph_pa_on_status,
  1824. .hph_pull_up_control = tasha_mbhc_hph_l_pull_up_control,
  1825. .mbhc_micbias_control = tasha_mbhc_request_micbias,
  1826. .mbhc_micb_ramp_control = tasha_mbhc_micb_ramp_control,
  1827. .get_hwdep_fw_cal = tasha_get_hwdep_fw_cal,
  1828. .mbhc_micb_ctrl_thr_mic = tasha_mbhc_micb_ctrl_threshold_mic,
  1829. .compute_impedance = tasha_wcd_mbhc_calc_impedance,
  1830. .mbhc_gnd_det_ctrl = tasha_mbhc_gnd_det_ctrl,
  1831. .hph_pull_down_ctrl = tasha_mbhc_hph_pull_down_ctrl,
  1832. .mbhc_moisture_config = tasha_mbhc_moisture_config,
  1833. .update_anc_state = tasha_update_anc_state,
  1834. .is_anc_on = tasha_is_anc_on,
  1835. };
  1836. static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol,
  1837. struct snd_ctl_elem_value *ucontrol)
  1838. {
  1839. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1840. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1841. ucontrol->value.integer.value[0] = tasha->anc_slot;
  1842. return 0;
  1843. }
  1844. static int tasha_put_anc_slot(struct snd_kcontrol *kcontrol,
  1845. struct snd_ctl_elem_value *ucontrol)
  1846. {
  1847. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1848. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1849. tasha->anc_slot = ucontrol->value.integer.value[0];
  1850. return 0;
  1851. }
  1852. static int tasha_get_anc_func(struct snd_kcontrol *kcontrol,
  1853. struct snd_ctl_elem_value *ucontrol)
  1854. {
  1855. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1856. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1857. ucontrol->value.integer.value[0] = (tasha->anc_func == true ? 1 : 0);
  1858. return 0;
  1859. }
  1860. static int tasha_put_anc_func(struct snd_kcontrol *kcontrol,
  1861. struct snd_ctl_elem_value *ucontrol)
  1862. {
  1863. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1864. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1865. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  1866. mutex_lock(&tasha->codec_mutex);
  1867. tasha->anc_func = (!ucontrol->value.integer.value[0] ? false : true);
  1868. dev_dbg(codec->dev, "%s: anc_func %x", __func__, tasha->anc_func);
  1869. if (tasha->anc_func == true) {
  1870. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2 PA");
  1871. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2");
  1872. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1 PA");
  1873. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1");
  1874. snd_soc_dapm_enable_pin(dapm, "ANC HPHR PA");
  1875. snd_soc_dapm_enable_pin(dapm, "ANC HPHR");
  1876. snd_soc_dapm_enable_pin(dapm, "ANC HPHL PA");
  1877. snd_soc_dapm_enable_pin(dapm, "ANC HPHL");
  1878. snd_soc_dapm_enable_pin(dapm, "ANC EAR PA");
  1879. snd_soc_dapm_enable_pin(dapm, "ANC EAR");
  1880. snd_soc_dapm_enable_pin(dapm, "ANC SPK1 PA");
  1881. snd_soc_dapm_disable_pin(dapm, "LINEOUT2");
  1882. snd_soc_dapm_disable_pin(dapm, "LINEOUT2 PA");
  1883. snd_soc_dapm_disable_pin(dapm, "LINEOUT1");
  1884. snd_soc_dapm_disable_pin(dapm, "LINEOUT1 PA");
  1885. snd_soc_dapm_disable_pin(dapm, "HPHR");
  1886. snd_soc_dapm_disable_pin(dapm, "HPHL");
  1887. snd_soc_dapm_disable_pin(dapm, "HPHR PA");
  1888. snd_soc_dapm_disable_pin(dapm, "HPHL PA");
  1889. snd_soc_dapm_disable_pin(dapm, "EAR PA");
  1890. snd_soc_dapm_disable_pin(dapm, "EAR");
  1891. } else {
  1892. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  1893. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  1894. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  1895. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  1896. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  1897. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  1898. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  1899. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  1900. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  1901. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  1902. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  1903. snd_soc_dapm_enable_pin(dapm, "LINEOUT2");
  1904. snd_soc_dapm_enable_pin(dapm, "LINEOUT2 PA");
  1905. snd_soc_dapm_enable_pin(dapm, "LINEOUT1");
  1906. snd_soc_dapm_enable_pin(dapm, "LINEOUT1 PA");
  1907. snd_soc_dapm_enable_pin(dapm, "HPHR");
  1908. snd_soc_dapm_enable_pin(dapm, "HPHL");
  1909. snd_soc_dapm_enable_pin(dapm, "HPHR PA");
  1910. snd_soc_dapm_enable_pin(dapm, "HPHL PA");
  1911. snd_soc_dapm_enable_pin(dapm, "EAR PA");
  1912. snd_soc_dapm_enable_pin(dapm, "EAR");
  1913. }
  1914. mutex_unlock(&tasha->codec_mutex);
  1915. snd_soc_dapm_sync(dapm);
  1916. return 0;
  1917. }
  1918. static int tasha_get_clkmode(struct snd_kcontrol *kcontrol,
  1919. struct snd_ctl_elem_value *ucontrol)
  1920. {
  1921. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1922. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1923. ucontrol->value.enumerated.item[0] = tasha->clk_mode;
  1924. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1925. return 0;
  1926. }
  1927. static int tasha_put_clkmode(struct snd_kcontrol *kcontrol,
  1928. struct snd_ctl_elem_value *ucontrol)
  1929. {
  1930. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1931. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1932. tasha->clk_mode = ucontrol->value.enumerated.item[0];
  1933. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1934. return 0;
  1935. }
  1936. static int tasha_get_iir_enable_audio_mixer(
  1937. struct snd_kcontrol *kcontrol,
  1938. struct snd_ctl_elem_value *ucontrol)
  1939. {
  1940. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1941. int iir_idx = ((struct soc_multi_mixer_control *)
  1942. kcontrol->private_value)->reg;
  1943. int band_idx = ((struct soc_multi_mixer_control *)
  1944. kcontrol->private_value)->shift;
  1945. /* IIR filter band registers are at integer multiples of 16 */
  1946. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  1947. ucontrol->value.integer.value[0] = (snd_soc_read(codec, iir_reg) &
  1948. (1 << band_idx)) != 0;
  1949. dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
  1950. iir_idx, band_idx,
  1951. (uint32_t)ucontrol->value.integer.value[0]);
  1952. return 0;
  1953. }
  1954. static int tasha_hph_impedance_get(struct snd_kcontrol *kcontrol,
  1955. struct snd_ctl_elem_value *ucontrol)
  1956. {
  1957. uint32_t zl, zr;
  1958. bool hphr;
  1959. struct soc_multi_mixer_control *mc;
  1960. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1961. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1962. mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
  1963. hphr = mc->shift;
  1964. wcd_mbhc_get_impedance(&priv->mbhc, &zl, &zr);
  1965. dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
  1966. ucontrol->value.integer.value[0] = hphr ? zr : zl;
  1967. return 0;
  1968. }
  1969. static const struct snd_kcontrol_new impedance_detect_controls[] = {
  1970. SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
  1971. tasha_hph_impedance_get, NULL),
  1972. SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
  1973. tasha_hph_impedance_get, NULL),
  1974. };
  1975. static int tasha_get_hph_type(struct snd_kcontrol *kcontrol,
  1976. struct snd_ctl_elem_value *ucontrol)
  1977. {
  1978. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1979. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1980. struct wcd_mbhc *mbhc;
  1981. if (!priv) {
  1982. dev_dbg(codec->dev, "%s: wcd9335 private data is NULL\n",
  1983. __func__);
  1984. return 0;
  1985. }
  1986. mbhc = &priv->mbhc;
  1987. if (!mbhc) {
  1988. dev_dbg(codec->dev, "%s: mbhc not initialized\n", __func__);
  1989. return 0;
  1990. }
  1991. ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
  1992. dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
  1993. return 0;
  1994. }
  1995. static const struct snd_kcontrol_new hph_type_detect_controls[] = {
  1996. SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
  1997. tasha_get_hph_type, NULL),
  1998. };
  1999. static int tasha_vi_feed_mixer_get(struct snd_kcontrol *kcontrol,
  2000. struct snd_ctl_elem_value *ucontrol)
  2001. {
  2002. struct snd_soc_dapm_widget *widget =
  2003. snd_soc_dapm_kcontrol_widget(kcontrol);
  2004. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2005. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2006. ucontrol->value.integer.value[0] = tasha_p->vi_feed_value;
  2007. return 0;
  2008. }
  2009. static int tasha_vi_feed_mixer_put(struct snd_kcontrol *kcontrol,
  2010. struct snd_ctl_elem_value *ucontrol)
  2011. {
  2012. struct snd_soc_dapm_widget *widget =
  2013. snd_soc_dapm_kcontrol_widget(kcontrol);
  2014. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2015. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2016. struct wcd9xxx *core = tasha_p->wcd9xxx;
  2017. struct soc_multi_mixer_control *mixer =
  2018. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2019. u32 dai_id = widget->shift;
  2020. u32 port_id = mixer->shift;
  2021. u32 enable = ucontrol->value.integer.value[0];
  2022. dev_dbg(codec->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n",
  2023. __func__, enable, port_id, dai_id);
  2024. tasha_p->vi_feed_value = ucontrol->value.integer.value[0];
  2025. mutex_lock(&tasha_p->codec_mutex);
  2026. if (enable) {
  2027. if (port_id == TASHA_TX14 && !test_bit(VI_SENSE_1,
  2028. &tasha_p->status_mask)) {
  2029. list_add_tail(&core->tx_chs[TASHA_TX14].list,
  2030. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2031. set_bit(VI_SENSE_1, &tasha_p->status_mask);
  2032. }
  2033. if (port_id == TASHA_TX15 && !test_bit(VI_SENSE_2,
  2034. &tasha_p->status_mask)) {
  2035. list_add_tail(&core->tx_chs[TASHA_TX15].list,
  2036. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2037. set_bit(VI_SENSE_2, &tasha_p->status_mask);
  2038. }
  2039. } else {
  2040. if (port_id == TASHA_TX14 && test_bit(VI_SENSE_1,
  2041. &tasha_p->status_mask)) {
  2042. list_del_init(&core->tx_chs[TASHA_TX14].list);
  2043. clear_bit(VI_SENSE_1, &tasha_p->status_mask);
  2044. }
  2045. if (port_id == TASHA_TX15 && test_bit(VI_SENSE_2,
  2046. &tasha_p->status_mask)) {
  2047. list_del_init(&core->tx_chs[TASHA_TX15].list);
  2048. clear_bit(VI_SENSE_2, &tasha_p->status_mask);
  2049. }
  2050. }
  2051. mutex_unlock(&tasha_p->codec_mutex);
  2052. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL);
  2053. return 0;
  2054. }
  2055. /* virtual port entries */
  2056. static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol,
  2057. struct snd_ctl_elem_value *ucontrol)
  2058. {
  2059. struct snd_soc_dapm_widget *widget =
  2060. snd_soc_dapm_kcontrol_widget(kcontrol);
  2061. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2062. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2063. ucontrol->value.integer.value[0] = tasha_p->tx_port_value;
  2064. return 0;
  2065. }
  2066. static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol,
  2067. struct snd_ctl_elem_value *ucontrol)
  2068. {
  2069. struct snd_soc_dapm_widget *widget =
  2070. snd_soc_dapm_kcontrol_widget(kcontrol);
  2071. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2072. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2073. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2074. struct snd_soc_dapm_update *update = NULL;
  2075. struct soc_multi_mixer_control *mixer =
  2076. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2077. u32 dai_id = widget->shift;
  2078. u32 port_id = mixer->shift;
  2079. u32 enable = ucontrol->value.integer.value[0];
  2080. u32 vtable;
  2081. dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n",
  2082. __func__,
  2083. widget->name, ucontrol->id.name, tasha_p->tx_port_value,
  2084. widget->shift, ucontrol->value.integer.value[0]);
  2085. mutex_lock(&tasha_p->codec_mutex);
  2086. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2087. if (dai_id != AIF1_CAP) {
  2088. dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
  2089. __func__);
  2090. mutex_unlock(&tasha_p->codec_mutex);
  2091. return -EINVAL;
  2092. }
  2093. vtable = vport_slim_check_table[dai_id];
  2094. } else {
  2095. if (dai_id >= ARRAY_SIZE(vport_i2s_check_table)) {
  2096. dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n",
  2097. __func__, dai_id);
  2098. return -EINVAL;
  2099. }
  2100. vtable = vport_i2s_check_table[dai_id];
  2101. }
  2102. switch (dai_id) {
  2103. case AIF1_CAP:
  2104. case AIF2_CAP:
  2105. case AIF3_CAP:
  2106. /* only add to the list if value not set */
  2107. if (enable && !(tasha_p->tx_port_value & 1 << port_id)) {
  2108. if (wcd9xxx_tx_vport_validation(vtable, port_id,
  2109. tasha_p->dai, NUM_CODEC_DAIS)) {
  2110. dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n",
  2111. __func__, port_id);
  2112. mutex_unlock(&tasha_p->codec_mutex);
  2113. return 0;
  2114. }
  2115. tasha_p->tx_port_value |= 1 << port_id;
  2116. list_add_tail(&core->tx_chs[port_id].list,
  2117. &tasha_p->dai[dai_id].wcd9xxx_ch_list
  2118. );
  2119. } else if (!enable && (tasha_p->tx_port_value &
  2120. 1 << port_id)) {
  2121. tasha_p->tx_port_value &= ~(1 << port_id);
  2122. list_del_init(&core->tx_chs[port_id].list);
  2123. } else {
  2124. if (enable)
  2125. dev_dbg(codec->dev, "%s: TX%u port is used by\n"
  2126. "this virtual port\n",
  2127. __func__, port_id);
  2128. else
  2129. dev_dbg(codec->dev, "%s: TX%u port is not used by\n"
  2130. "this virtual port\n",
  2131. __func__, port_id);
  2132. /* avoid update power function */
  2133. mutex_unlock(&tasha_p->codec_mutex);
  2134. return 0;
  2135. }
  2136. break;
  2137. case AIF4_MAD_TX:
  2138. case AIF5_CPE_TX:
  2139. break;
  2140. default:
  2141. pr_err("Unknown AIF %d\n", dai_id);
  2142. mutex_unlock(&tasha_p->codec_mutex);
  2143. return -EINVAL;
  2144. }
  2145. pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__,
  2146. widget->name, widget->sname, tasha_p->tx_port_value,
  2147. widget->shift);
  2148. mutex_unlock(&tasha_p->codec_mutex);
  2149. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
  2150. return 0;
  2151. }
  2152. static int slim_rx_mux_get(struct snd_kcontrol *kcontrol,
  2153. struct snd_ctl_elem_value *ucontrol)
  2154. {
  2155. struct snd_soc_dapm_widget *widget =
  2156. snd_soc_dapm_kcontrol_widget(kcontrol);
  2157. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2158. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2159. ucontrol->value.enumerated.item[0] =
  2160. tasha_p->rx_port_value[widget->shift];
  2161. return 0;
  2162. }
  2163. static const char *const slim_rx_mux_text[] = {
  2164. "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB", "AIF_MIX1_PB"
  2165. };
  2166. static int slim_rx_mux_put(struct snd_kcontrol *kcontrol,
  2167. struct snd_ctl_elem_value *ucontrol)
  2168. {
  2169. struct snd_soc_dapm_widget *widget =
  2170. snd_soc_dapm_kcontrol_widget(kcontrol);
  2171. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2172. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2173. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2174. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  2175. struct snd_soc_dapm_update *update = NULL;
  2176. unsigned int rx_port_value;
  2177. u32 port_id = widget->shift;
  2178. tasha_p->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
  2179. rx_port_value = tasha_p->rx_port_value[port_id];
  2180. pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__,
  2181. widget->name, ucontrol->id.name, rx_port_value,
  2182. widget->shift, ucontrol->value.integer.value[0]);
  2183. mutex_lock(&tasha_p->codec_mutex);
  2184. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2185. if (rx_port_value > 2) {
  2186. dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
  2187. __func__);
  2188. goto err;
  2189. }
  2190. }
  2191. /* value need to match the Virtual port and AIF number */
  2192. switch (rx_port_value) {
  2193. case 0:
  2194. list_del_init(&core->rx_chs[port_id].list);
  2195. break;
  2196. case 1:
  2197. if (wcd9xxx_rx_vport_validation(port_id +
  2198. TASHA_RX_PORT_START_NUMBER,
  2199. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list)) {
  2200. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2201. __func__, port_id);
  2202. goto rtn;
  2203. }
  2204. list_add_tail(&core->rx_chs[port_id].list,
  2205. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list);
  2206. break;
  2207. case 2:
  2208. if (wcd9xxx_rx_vport_validation(port_id +
  2209. TASHA_RX_PORT_START_NUMBER,
  2210. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list)) {
  2211. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2212. __func__, port_id);
  2213. goto rtn;
  2214. }
  2215. list_add_tail(&core->rx_chs[port_id].list,
  2216. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list);
  2217. break;
  2218. case 3:
  2219. if (wcd9xxx_rx_vport_validation(port_id +
  2220. TASHA_RX_PORT_START_NUMBER,
  2221. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list)) {
  2222. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2223. __func__, port_id);
  2224. goto rtn;
  2225. }
  2226. list_add_tail(&core->rx_chs[port_id].list,
  2227. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list);
  2228. break;
  2229. case 4:
  2230. if (wcd9xxx_rx_vport_validation(port_id +
  2231. TASHA_RX_PORT_START_NUMBER,
  2232. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list)) {
  2233. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2234. __func__, port_id);
  2235. goto rtn;
  2236. }
  2237. list_add_tail(&core->rx_chs[port_id].list,
  2238. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list);
  2239. break;
  2240. case 5:
  2241. if (wcd9xxx_rx_vport_validation(port_id +
  2242. TASHA_RX_PORT_START_NUMBER,
  2243. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list)) {
  2244. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2245. __func__, port_id);
  2246. goto rtn;
  2247. }
  2248. list_add_tail(&core->rx_chs[port_id].list,
  2249. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list);
  2250. break;
  2251. default:
  2252. pr_err("Unknown AIF %d\n", rx_port_value);
  2253. goto err;
  2254. }
  2255. rtn:
  2256. mutex_unlock(&tasha_p->codec_mutex);
  2257. snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
  2258. rx_port_value, e, update);
  2259. return 0;
  2260. err:
  2261. mutex_unlock(&tasha_p->codec_mutex);
  2262. return -EINVAL;
  2263. }
  2264. static const struct soc_enum slim_rx_mux_enum =
  2265. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text);
  2266. static const struct snd_kcontrol_new slim_rx_mux[TASHA_RX_MAX] = {
  2267. SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum,
  2268. slim_rx_mux_get, slim_rx_mux_put),
  2269. SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
  2270. slim_rx_mux_get, slim_rx_mux_put),
  2271. SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
  2272. slim_rx_mux_get, slim_rx_mux_put),
  2273. SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
  2274. slim_rx_mux_get, slim_rx_mux_put),
  2275. SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
  2276. slim_rx_mux_get, slim_rx_mux_put),
  2277. SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
  2278. slim_rx_mux_get, slim_rx_mux_put),
  2279. SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
  2280. slim_rx_mux_get, slim_rx_mux_put),
  2281. SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
  2282. slim_rx_mux_get, slim_rx_mux_put),
  2283. };
  2284. static const struct snd_kcontrol_new aif4_vi_mixer[] = {
  2285. SOC_SINGLE_EXT("SPKR_VI_1", SND_SOC_NOPM, TASHA_TX14, 1, 0,
  2286. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2287. SOC_SINGLE_EXT("SPKR_VI_2", SND_SOC_NOPM, TASHA_TX15, 1, 0,
  2288. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2289. };
  2290. static const struct snd_kcontrol_new aif1_cap_mixer[] = {
  2291. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2292. slim_tx_mixer_get, slim_tx_mixer_put),
  2293. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2294. slim_tx_mixer_get, slim_tx_mixer_put),
  2295. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2296. slim_tx_mixer_get, slim_tx_mixer_put),
  2297. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2298. slim_tx_mixer_get, slim_tx_mixer_put),
  2299. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2300. slim_tx_mixer_get, slim_tx_mixer_put),
  2301. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2302. slim_tx_mixer_get, slim_tx_mixer_put),
  2303. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2304. slim_tx_mixer_get, slim_tx_mixer_put),
  2305. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2306. slim_tx_mixer_get, slim_tx_mixer_put),
  2307. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2308. slim_tx_mixer_get, slim_tx_mixer_put),
  2309. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2310. slim_tx_mixer_get, slim_tx_mixer_put),
  2311. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2312. slim_tx_mixer_get, slim_tx_mixer_put),
  2313. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2314. slim_tx_mixer_get, slim_tx_mixer_put),
  2315. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2316. slim_tx_mixer_get, slim_tx_mixer_put),
  2317. };
  2318. static const struct snd_kcontrol_new aif2_cap_mixer[] = {
  2319. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2320. slim_tx_mixer_get, slim_tx_mixer_put),
  2321. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2322. slim_tx_mixer_get, slim_tx_mixer_put),
  2323. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2324. slim_tx_mixer_get, slim_tx_mixer_put),
  2325. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2326. slim_tx_mixer_get, slim_tx_mixer_put),
  2327. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2328. slim_tx_mixer_get, slim_tx_mixer_put),
  2329. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2330. slim_tx_mixer_get, slim_tx_mixer_put),
  2331. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2332. slim_tx_mixer_get, slim_tx_mixer_put),
  2333. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2334. slim_tx_mixer_get, slim_tx_mixer_put),
  2335. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2336. slim_tx_mixer_get, slim_tx_mixer_put),
  2337. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2338. slim_tx_mixer_get, slim_tx_mixer_put),
  2339. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2340. slim_tx_mixer_get, slim_tx_mixer_put),
  2341. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2342. slim_tx_mixer_get, slim_tx_mixer_put),
  2343. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2344. slim_tx_mixer_get, slim_tx_mixer_put),
  2345. };
  2346. static const struct snd_kcontrol_new aif3_cap_mixer[] = {
  2347. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2348. slim_tx_mixer_get, slim_tx_mixer_put),
  2349. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2350. slim_tx_mixer_get, slim_tx_mixer_put),
  2351. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2352. slim_tx_mixer_get, slim_tx_mixer_put),
  2353. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2354. slim_tx_mixer_get, slim_tx_mixer_put),
  2355. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2356. slim_tx_mixer_get, slim_tx_mixer_put),
  2357. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2358. slim_tx_mixer_get, slim_tx_mixer_put),
  2359. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2360. slim_tx_mixer_get, slim_tx_mixer_put),
  2361. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2362. slim_tx_mixer_get, slim_tx_mixer_put),
  2363. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2364. slim_tx_mixer_get, slim_tx_mixer_put),
  2365. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2366. slim_tx_mixer_get, slim_tx_mixer_put),
  2367. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2368. slim_tx_mixer_get, slim_tx_mixer_put),
  2369. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2370. slim_tx_mixer_get, slim_tx_mixer_put),
  2371. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2372. slim_tx_mixer_get, slim_tx_mixer_put),
  2373. };
  2374. static const struct snd_kcontrol_new aif4_mad_mixer[] = {
  2375. SOC_SINGLE_EXT("SLIM TX12", SND_SOC_NOPM, TASHA_TX12, 1, 0,
  2376. slim_tx_mixer_get, slim_tx_mixer_put),
  2377. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2378. slim_tx_mixer_get, slim_tx_mixer_put),
  2379. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, 0, 1, 0,
  2380. slim_tx_mixer_get, slim_tx_mixer_put),
  2381. };
  2382. static const struct snd_kcontrol_new rx_int1_spline_mix_switch[] = {
  2383. SOC_DAPM_SINGLE("HPHL Switch", SND_SOC_NOPM, 0, 1, 0)
  2384. };
  2385. static const struct snd_kcontrol_new rx_int2_spline_mix_switch[] = {
  2386. SOC_DAPM_SINGLE("HPHR Switch", SND_SOC_NOPM, 0, 1, 0)
  2387. };
  2388. static const struct snd_kcontrol_new rx_int3_spline_mix_switch[] = {
  2389. SOC_DAPM_SINGLE("LO1 Switch", SND_SOC_NOPM, 0, 1, 0)
  2390. };
  2391. static const struct snd_kcontrol_new rx_int4_spline_mix_switch[] = {
  2392. SOC_DAPM_SINGLE("LO2 Switch", SND_SOC_NOPM, 0, 1, 0)
  2393. };
  2394. static const struct snd_kcontrol_new rx_int5_spline_mix_switch[] = {
  2395. SOC_DAPM_SINGLE("LO3 Switch", SND_SOC_NOPM, 0, 1, 0)
  2396. };
  2397. static const struct snd_kcontrol_new rx_int6_spline_mix_switch[] = {
  2398. SOC_DAPM_SINGLE("LO4 Switch", SND_SOC_NOPM, 0, 1, 0)
  2399. };
  2400. static const struct snd_kcontrol_new rx_int7_spline_mix_switch[] = {
  2401. SOC_DAPM_SINGLE("SPKRL Switch", SND_SOC_NOPM, 0, 1, 0)
  2402. };
  2403. static const struct snd_kcontrol_new rx_int8_spline_mix_switch[] = {
  2404. SOC_DAPM_SINGLE("SPKRR Switch", SND_SOC_NOPM, 0, 1, 0)
  2405. };
  2406. static const struct snd_kcontrol_new rx_int5_vbat_mix_switch[] = {
  2407. SOC_DAPM_SINGLE("LO3 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2408. };
  2409. static const struct snd_kcontrol_new rx_int6_vbat_mix_switch[] = {
  2410. SOC_DAPM_SINGLE("LO4 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2411. };
  2412. static const struct snd_kcontrol_new rx_int7_vbat_mix_switch[] = {
  2413. SOC_DAPM_SINGLE("SPKRL VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2414. };
  2415. static const struct snd_kcontrol_new rx_int8_vbat_mix_switch[] = {
  2416. SOC_DAPM_SINGLE("SPKRR VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2417. };
  2418. static const struct snd_kcontrol_new cpe_in_mix_switch[] = {
  2419. SOC_DAPM_SINGLE("MAD_BYPASS", SND_SOC_NOPM, 0, 1, 0)
  2420. };
  2421. static int tasha_put_iir_enable_audio_mixer(
  2422. struct snd_kcontrol *kcontrol,
  2423. struct snd_ctl_elem_value *ucontrol)
  2424. {
  2425. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2426. int iir_idx = ((struct soc_multi_mixer_control *)
  2427. kcontrol->private_value)->reg;
  2428. int band_idx = ((struct soc_multi_mixer_control *)
  2429. kcontrol->private_value)->shift;
  2430. bool iir_band_en_status;
  2431. int value = ucontrol->value.integer.value[0];
  2432. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  2433. /* Mask first 5 bits, 6-8 are reserved */
  2434. snd_soc_update_bits(codec, iir_reg, (1 << band_idx),
  2435. (value << band_idx));
  2436. iir_band_en_status = ((snd_soc_read(codec, iir_reg) &
  2437. (1 << band_idx)) != 0);
  2438. pr_debug("%s: IIR #%d band #%d enable %d\n", __func__,
  2439. iir_idx, band_idx, iir_band_en_status);
  2440. return 0;
  2441. }
  2442. static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec,
  2443. int iir_idx, int band_idx,
  2444. int coeff_idx)
  2445. {
  2446. uint32_t value = 0;
  2447. /* Address does not automatically update if reading */
  2448. snd_soc_write(codec,
  2449. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2450. ((band_idx * BAND_MAX + coeff_idx)
  2451. * sizeof(uint32_t)) & 0x7F);
  2452. value |= snd_soc_read(codec,
  2453. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx));
  2454. snd_soc_write(codec,
  2455. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2456. ((band_idx * BAND_MAX + coeff_idx)
  2457. * sizeof(uint32_t) + 1) & 0x7F);
  2458. value |= (snd_soc_read(codec,
  2459. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2460. 16 * iir_idx)) << 8);
  2461. snd_soc_write(codec,
  2462. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2463. ((band_idx * BAND_MAX + coeff_idx)
  2464. * sizeof(uint32_t) + 2) & 0x7F);
  2465. value |= (snd_soc_read(codec,
  2466. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2467. 16 * iir_idx)) << 16);
  2468. snd_soc_write(codec,
  2469. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2470. ((band_idx * BAND_MAX + coeff_idx)
  2471. * sizeof(uint32_t) + 3) & 0x7F);
  2472. /* Mask bits top 2 bits since they are reserved */
  2473. value |= ((snd_soc_read(codec,
  2474. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2475. 16 * iir_idx)) & 0x3F) << 24);
  2476. return value;
  2477. }
  2478. static int tasha_get_iir_band_audio_mixer(
  2479. struct snd_kcontrol *kcontrol,
  2480. struct snd_ctl_elem_value *ucontrol)
  2481. {
  2482. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2483. int iir_idx = ((struct soc_multi_mixer_control *)
  2484. kcontrol->private_value)->reg;
  2485. int band_idx = ((struct soc_multi_mixer_control *)
  2486. kcontrol->private_value)->shift;
  2487. ucontrol->value.integer.value[0] =
  2488. get_iir_band_coeff(codec, iir_idx, band_idx, 0);
  2489. ucontrol->value.integer.value[1] =
  2490. get_iir_band_coeff(codec, iir_idx, band_idx, 1);
  2491. ucontrol->value.integer.value[2] =
  2492. get_iir_band_coeff(codec, iir_idx, band_idx, 2);
  2493. ucontrol->value.integer.value[3] =
  2494. get_iir_band_coeff(codec, iir_idx, band_idx, 3);
  2495. ucontrol->value.integer.value[4] =
  2496. get_iir_band_coeff(codec, iir_idx, band_idx, 4);
  2497. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  2498. "%s: IIR #%d band #%d b1 = 0x%x\n"
  2499. "%s: IIR #%d band #%d b2 = 0x%x\n"
  2500. "%s: IIR #%d band #%d a1 = 0x%x\n"
  2501. "%s: IIR #%d band #%d a2 = 0x%x\n",
  2502. __func__, iir_idx, band_idx,
  2503. (uint32_t)ucontrol->value.integer.value[0],
  2504. __func__, iir_idx, band_idx,
  2505. (uint32_t)ucontrol->value.integer.value[1],
  2506. __func__, iir_idx, band_idx,
  2507. (uint32_t)ucontrol->value.integer.value[2],
  2508. __func__, iir_idx, band_idx,
  2509. (uint32_t)ucontrol->value.integer.value[3],
  2510. __func__, iir_idx, band_idx,
  2511. (uint32_t)ucontrol->value.integer.value[4]);
  2512. return 0;
  2513. }
  2514. static void set_iir_band_coeff(struct snd_soc_codec *codec,
  2515. int iir_idx, int band_idx,
  2516. uint32_t value)
  2517. {
  2518. snd_soc_write(codec,
  2519. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2520. (value & 0xFF));
  2521. snd_soc_write(codec,
  2522. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2523. (value >> 8) & 0xFF);
  2524. snd_soc_write(codec,
  2525. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2526. (value >> 16) & 0xFF);
  2527. /* Mask top 2 bits, 7-8 are reserved */
  2528. snd_soc_write(codec,
  2529. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2530. (value >> 24) & 0x3F);
  2531. }
  2532. static void tasha_codec_enable_int_port(struct wcd9xxx_codec_dai_data *dai,
  2533. struct snd_soc_codec *codec)
  2534. {
  2535. struct wcd9xxx_ch *ch;
  2536. int port_num = 0;
  2537. unsigned short reg = 0;
  2538. u8 val = 0;
  2539. struct tasha_priv *tasha_p;
  2540. if (!dai || !codec) {
  2541. pr_err("%s: Invalid params\n", __func__);
  2542. return;
  2543. }
  2544. tasha_p = snd_soc_codec_get_drvdata(codec);
  2545. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2546. if (ch->port >= TASHA_RX_PORT_START_NUMBER) {
  2547. port_num = ch->port - TASHA_RX_PORT_START_NUMBER;
  2548. reg = TASHA_SLIM_PGD_PORT_INT_EN0 + (port_num / 8);
  2549. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2550. reg);
  2551. if (!(val & BYTE_BIT_MASK(port_num))) {
  2552. val |= BYTE_BIT_MASK(port_num);
  2553. wcd9xxx_interface_reg_write(
  2554. tasha_p->wcd9xxx, reg, val);
  2555. val = wcd9xxx_interface_reg_read(
  2556. tasha_p->wcd9xxx, reg);
  2557. }
  2558. } else {
  2559. port_num = ch->port;
  2560. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 + (port_num / 8);
  2561. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2562. reg);
  2563. if (!(val & BYTE_BIT_MASK(port_num))) {
  2564. val |= BYTE_BIT_MASK(port_num);
  2565. wcd9xxx_interface_reg_write(tasha_p->wcd9xxx,
  2566. reg, val);
  2567. val = wcd9xxx_interface_reg_read(
  2568. tasha_p->wcd9xxx, reg);
  2569. }
  2570. }
  2571. }
  2572. }
  2573. static int tasha_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai,
  2574. bool up)
  2575. {
  2576. int ret = 0;
  2577. struct wcd9xxx_ch *ch;
  2578. if (up) {
  2579. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2580. ret = wcd9xxx_get_slave_port(ch->ch_num);
  2581. if (ret < 0) {
  2582. pr_err("%s: Invalid slave port ID: %d\n",
  2583. __func__, ret);
  2584. ret = -EINVAL;
  2585. } else {
  2586. set_bit(ret, &dai->ch_mask);
  2587. }
  2588. }
  2589. } else {
  2590. ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0),
  2591. msecs_to_jiffies(
  2592. TASHA_SLIM_CLOSE_TIMEOUT));
  2593. if (!ret) {
  2594. pr_err("%s: Slim close tx/rx wait timeout, ch_mask:0x%lx\n",
  2595. __func__, dai->ch_mask);
  2596. ret = -ETIMEDOUT;
  2597. } else {
  2598. ret = 0;
  2599. }
  2600. }
  2601. return ret;
  2602. }
  2603. static int tasha_codec_enable_slimrx(struct snd_soc_dapm_widget *w,
  2604. struct snd_kcontrol *kcontrol,
  2605. int event)
  2606. {
  2607. struct wcd9xxx *core;
  2608. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2609. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2610. int ret = 0;
  2611. struct wcd9xxx_codec_dai_data *dai;
  2612. core = dev_get_drvdata(codec->dev->parent);
  2613. dev_dbg(codec->dev, "%s: event called! codec name %s num_dai %d\n"
  2614. "stream name %s event %d\n",
  2615. __func__, codec->component.name,
  2616. codec->component.num_dai, w->sname, event);
  2617. /* Execute the callback only if interface type is slimbus */
  2618. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2619. return 0;
  2620. dai = &tasha_p->dai[w->shift];
  2621. dev_dbg(codec->dev, "%s: w->name %s w->shift %d event %d\n",
  2622. __func__, w->name, w->shift, event);
  2623. switch (event) {
  2624. case SND_SOC_DAPM_POST_PMU:
  2625. dai->bus_down_in_recovery = false;
  2626. tasha_codec_enable_int_port(dai, codec);
  2627. (void) tasha_codec_enable_slim_chmask(dai, true);
  2628. ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2629. dai->rate, dai->bit_width,
  2630. &dai->grph);
  2631. break;
  2632. case SND_SOC_DAPM_PRE_PMD:
  2633. tasha_codec_vote_max_bw(codec, true);
  2634. break;
  2635. case SND_SOC_DAPM_POST_PMD:
  2636. ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list,
  2637. dai->grph);
  2638. dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n",
  2639. __func__, ret);
  2640. if (!dai->bus_down_in_recovery)
  2641. ret = tasha_codec_enable_slim_chmask(dai, false);
  2642. else
  2643. dev_dbg(codec->dev,
  2644. "%s: bus in recovery skip enable slim_chmask",
  2645. __func__);
  2646. ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2647. dai->grph);
  2648. break;
  2649. }
  2650. return ret;
  2651. }
  2652. static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w,
  2653. struct snd_kcontrol *kcontrol,
  2654. int event)
  2655. {
  2656. struct wcd9xxx *core = NULL;
  2657. struct snd_soc_codec *codec = NULL;
  2658. struct tasha_priv *tasha_p = NULL;
  2659. int ret = 0;
  2660. struct wcd9xxx_codec_dai_data *dai = NULL;
  2661. if (!w) {
  2662. pr_err("%s invalid params\n", __func__);
  2663. return -EINVAL;
  2664. }
  2665. codec = snd_soc_dapm_to_codec(w->dapm);
  2666. tasha_p = snd_soc_codec_get_drvdata(codec);
  2667. core = tasha_p->wcd9xxx;
  2668. dev_dbg(codec->dev, "%s: num_dai %d stream name %s\n",
  2669. __func__, codec->component.num_dai, w->sname);
  2670. /* Execute the callback only if interface type is slimbus */
  2671. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2672. dev_err(codec->dev, "%s Interface is not correct", __func__);
  2673. return 0;
  2674. }
  2675. dev_dbg(codec->dev, "%s(): w->name %s event %d w->shift %d\n",
  2676. __func__, w->name, event, w->shift);
  2677. if (w->shift != AIF4_VIFEED) {
  2678. pr_err("%s Error in enabling the tx path\n", __func__);
  2679. ret = -EINVAL;
  2680. goto out_vi;
  2681. }
  2682. dai = &tasha_p->dai[w->shift];
  2683. switch (event) {
  2684. case SND_SOC_DAPM_POST_PMU:
  2685. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2686. dev_dbg(codec->dev, "%s: spkr1 enabled\n", __func__);
  2687. /* Enable V&I sensing */
  2688. snd_soc_update_bits(codec,
  2689. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2690. snd_soc_update_bits(codec,
  2691. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2692. 0x20);
  2693. snd_soc_update_bits(codec,
  2694. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x00);
  2695. snd_soc_update_bits(codec,
  2696. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x0F,
  2697. 0x00);
  2698. snd_soc_update_bits(codec,
  2699. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10);
  2700. snd_soc_update_bits(codec,
  2701. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2702. 0x10);
  2703. snd_soc_update_bits(codec,
  2704. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00);
  2705. snd_soc_update_bits(codec,
  2706. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2707. 0x00);
  2708. }
  2709. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2710. pr_debug("%s: spkr2 enabled\n", __func__);
  2711. /* Enable V&I sensing */
  2712. snd_soc_update_bits(codec,
  2713. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2714. 0x20);
  2715. snd_soc_update_bits(codec,
  2716. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2717. 0x20);
  2718. snd_soc_update_bits(codec,
  2719. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x0F,
  2720. 0x00);
  2721. snd_soc_update_bits(codec,
  2722. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x0F,
  2723. 0x00);
  2724. snd_soc_update_bits(codec,
  2725. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2726. 0x10);
  2727. snd_soc_update_bits(codec,
  2728. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2729. 0x10);
  2730. snd_soc_update_bits(codec,
  2731. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2732. 0x00);
  2733. snd_soc_update_bits(codec,
  2734. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2735. 0x00);
  2736. }
  2737. dai->bus_down_in_recovery = false;
  2738. tasha_codec_enable_int_port(dai, codec);
  2739. (void) tasha_codec_enable_slim_chmask(dai, true);
  2740. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2741. dai->rate, dai->bit_width,
  2742. &dai->grph);
  2743. break;
  2744. case SND_SOC_DAPM_POST_PMD:
  2745. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2746. dai->grph);
  2747. if (ret)
  2748. dev_err(codec->dev, "%s error in close_slim_sch_tx %d\n",
  2749. __func__, ret);
  2750. if (!dai->bus_down_in_recovery)
  2751. ret = tasha_codec_enable_slim_chmask(dai, false);
  2752. if (ret < 0) {
  2753. ret = wcd9xxx_disconnect_port(core,
  2754. &dai->wcd9xxx_ch_list,
  2755. dai->grph);
  2756. dev_dbg(codec->dev, "%s: Disconnect TX port, ret = %d\n",
  2757. __func__, ret);
  2758. }
  2759. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2760. /* Disable V&I sensing */
  2761. dev_dbg(codec->dev, "%s: spkr1 disabled\n", __func__);
  2762. snd_soc_update_bits(codec,
  2763. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2764. snd_soc_update_bits(codec,
  2765. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2766. 0x20);
  2767. snd_soc_update_bits(codec,
  2768. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00);
  2769. snd_soc_update_bits(codec,
  2770. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2771. 0x00);
  2772. }
  2773. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2774. /* Disable V&I sensing */
  2775. dev_dbg(codec->dev, "%s: spkr2 disabled\n", __func__);
  2776. snd_soc_update_bits(codec,
  2777. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2778. 0x20);
  2779. snd_soc_update_bits(codec,
  2780. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2781. 0x20);
  2782. snd_soc_update_bits(codec,
  2783. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2784. 0x00);
  2785. snd_soc_update_bits(codec,
  2786. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2787. 0x00);
  2788. }
  2789. break;
  2790. }
  2791. out_vi:
  2792. return ret;
  2793. }
  2794. /*
  2795. * __tasha_codec_enable_slimtx: Enable the slimbus slave port
  2796. * for TX path
  2797. * @codec: Handle to the codec for which the slave port is to be
  2798. * enabled.
  2799. * @dai_data: The dai specific data for dai which is enabled.
  2800. */
  2801. static int __tasha_codec_enable_slimtx(struct snd_soc_codec *codec,
  2802. int event, struct wcd9xxx_codec_dai_data *dai)
  2803. {
  2804. struct wcd9xxx *core;
  2805. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2806. int ret = 0;
  2807. /* Execute the callback only if interface type is slimbus */
  2808. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2809. return 0;
  2810. dev_dbg(codec->dev,
  2811. "%s: event = %d\n", __func__, event);
  2812. core = dev_get_drvdata(codec->dev->parent);
  2813. switch (event) {
  2814. case SND_SOC_DAPM_POST_PMU:
  2815. dai->bus_down_in_recovery = false;
  2816. tasha_codec_enable_int_port(dai, codec);
  2817. (void) tasha_codec_enable_slim_chmask(dai, true);
  2818. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2819. dai->rate, dai->bit_width,
  2820. &dai->grph);
  2821. break;
  2822. case SND_SOC_DAPM_POST_PMD:
  2823. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2824. dai->grph);
  2825. if (!dai->bus_down_in_recovery)
  2826. ret = tasha_codec_enable_slim_chmask(dai, false);
  2827. if (ret < 0) {
  2828. ret = wcd9xxx_disconnect_port(core,
  2829. &dai->wcd9xxx_ch_list,
  2830. dai->grph);
  2831. pr_debug("%s: Disconnect TX port, ret = %d\n",
  2832. __func__, ret);
  2833. }
  2834. break;
  2835. }
  2836. return ret;
  2837. }
  2838. static int tasha_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
  2839. struct snd_kcontrol *kcontrol,
  2840. int event)
  2841. {
  2842. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2843. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2844. struct wcd9xxx_codec_dai_data *dai;
  2845. dev_dbg(codec->dev,
  2846. "%s: w->name %s, w->shift = %d, num_dai %d stream name %s\n",
  2847. __func__, w->name, w->shift,
  2848. codec->component.num_dai, w->sname);
  2849. dai = &tasha_p->dai[w->shift];
  2850. return __tasha_codec_enable_slimtx(codec, event, dai);
  2851. }
  2852. static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_codec *codec, int event)
  2853. {
  2854. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2855. struct wcd9xxx_codec_dai_data *dai;
  2856. u8 bit_width, rate, buf_period;
  2857. dai = &tasha_p->dai[AIF4_MAD_TX];
  2858. switch (event) {
  2859. case SND_SOC_DAPM_POST_PMU:
  2860. switch (dai->bit_width) {
  2861. case 32:
  2862. bit_width = 0xF;
  2863. break;
  2864. case 24:
  2865. bit_width = 0xE;
  2866. break;
  2867. case 20:
  2868. bit_width = 0xD;
  2869. break;
  2870. case 16:
  2871. default:
  2872. bit_width = 0x0;
  2873. break;
  2874. }
  2875. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x0F,
  2876. bit_width);
  2877. switch (dai->rate) {
  2878. case 384000:
  2879. rate = 0x30;
  2880. break;
  2881. case 192000:
  2882. rate = 0x20;
  2883. break;
  2884. case 48000:
  2885. rate = 0x10;
  2886. break;
  2887. case 16000:
  2888. default:
  2889. rate = 0x00;
  2890. break;
  2891. }
  2892. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x70,
  2893. rate);
  2894. buf_period = (dai->rate * (dai->bit_width/8)) / (16*1000);
  2895. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD,
  2896. 0xFF, buf_period);
  2897. dev_dbg(codec->dev, "%s: PP buffer period= 0x%x\n",
  2898. __func__, buf_period);
  2899. break;
  2900. case SND_SOC_DAPM_POST_PMD:
  2901. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x3C);
  2902. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD, 0x60);
  2903. break;
  2904. default:
  2905. break;
  2906. }
  2907. }
  2908. /*
  2909. * tasha_codec_get_mad_port_id: Callback function that will be invoked
  2910. * to get the port ID for MAD.
  2911. * @codec: Handle to the codec
  2912. * @port_id: cpe port_id needs to enable
  2913. */
  2914. static int tasha_codec_get_mad_port_id(struct snd_soc_codec *codec,
  2915. u16 *port_id)
  2916. {
  2917. struct tasha_priv *tasha_p;
  2918. struct wcd9xxx_codec_dai_data *dai;
  2919. struct wcd9xxx_ch *ch;
  2920. if (!port_id || !codec)
  2921. return -EINVAL;
  2922. tasha_p = snd_soc_codec_get_drvdata(codec);
  2923. if (!tasha_p)
  2924. return -EINVAL;
  2925. dai = &tasha_p->dai[AIF4_MAD_TX];
  2926. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2927. if (ch->port == TASHA_TX12)
  2928. *port_id = WCD_CPE_AFE_OUT_PORT_2;
  2929. else if (ch->port == TASHA_TX13)
  2930. *port_id = WCD_CPE_AFE_OUT_PORT_4;
  2931. else {
  2932. dev_err(codec->dev, "%s: invalid mad_port = %d\n",
  2933. __func__, ch->port);
  2934. return -EINVAL;
  2935. }
  2936. }
  2937. dev_dbg(codec->dev, "%s: port_id = %d\n", __func__, *port_id);
  2938. return 0;
  2939. }
  2940. /*
  2941. * tasha_codec_enable_slimtx_mad: Callback function that will be invoked
  2942. * to setup the slave port for MAD.
  2943. * @codec: Handle to the codec
  2944. * @event: Indicates whether to enable or disable the slave port
  2945. */
  2946. static int tasha_codec_enable_slimtx_mad(struct snd_soc_codec *codec,
  2947. u8 event)
  2948. {
  2949. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2950. struct wcd9xxx_codec_dai_data *dai;
  2951. struct wcd9xxx_ch *ch;
  2952. int dapm_event = SND_SOC_DAPM_POST_PMU;
  2953. u16 port = 0;
  2954. int ret = 0;
  2955. dai = &tasha_p->dai[AIF4_MAD_TX];
  2956. if (event == 0)
  2957. dapm_event = SND_SOC_DAPM_POST_PMD;
  2958. dev_dbg(codec->dev,
  2959. "%s: mad_channel, event = 0x%x\n",
  2960. __func__, event);
  2961. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2962. dev_dbg(codec->dev, "%s: mad_port = %d, event = 0x%x\n",
  2963. __func__, ch->port, event);
  2964. if (ch->port == TASHA_TX13) {
  2965. tasha_codec_cpe_pp_set_cfg(codec, dapm_event);
  2966. port = TASHA_TX13;
  2967. break;
  2968. }
  2969. }
  2970. ret = __tasha_codec_enable_slimtx(codec, dapm_event, dai);
  2971. if (port == TASHA_TX13) {
  2972. switch (dapm_event) {
  2973. case SND_SOC_DAPM_POST_PMU:
  2974. snd_soc_update_bits(codec,
  2975. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2976. 0x20, 0x00);
  2977. snd_soc_update_bits(codec,
  2978. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2979. 0x03, 0x02);
  2980. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2981. 0x80, 0x80);
  2982. break;
  2983. case SND_SOC_DAPM_POST_PMD:
  2984. snd_soc_update_bits(codec,
  2985. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2986. 0x20, 0x20);
  2987. snd_soc_update_bits(codec,
  2988. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2989. 0x03, 0x00);
  2990. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2991. 0x80, 0x00);
  2992. break;
  2993. }
  2994. }
  2995. return ret;
  2996. }
  2997. static int tasha_put_iir_band_audio_mixer(
  2998. struct snd_kcontrol *kcontrol,
  2999. struct snd_ctl_elem_value *ucontrol)
  3000. {
  3001. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3002. int iir_idx = ((struct soc_multi_mixer_control *)
  3003. kcontrol->private_value)->reg;
  3004. int band_idx = ((struct soc_multi_mixer_control *)
  3005. kcontrol->private_value)->shift;
  3006. /*
  3007. * Mask top bit it is reserved
  3008. * Updates addr automatically for each B2 write
  3009. */
  3010. snd_soc_write(codec,
  3011. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  3012. (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
  3013. set_iir_band_coeff(codec, iir_idx, band_idx,
  3014. ucontrol->value.integer.value[0]);
  3015. set_iir_band_coeff(codec, iir_idx, band_idx,
  3016. ucontrol->value.integer.value[1]);
  3017. set_iir_band_coeff(codec, iir_idx, band_idx,
  3018. ucontrol->value.integer.value[2]);
  3019. set_iir_band_coeff(codec, iir_idx, band_idx,
  3020. ucontrol->value.integer.value[3]);
  3021. set_iir_band_coeff(codec, iir_idx, band_idx,
  3022. ucontrol->value.integer.value[4]);
  3023. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  3024. "%s: IIR #%d band #%d b1 = 0x%x\n"
  3025. "%s: IIR #%d band #%d b2 = 0x%x\n"
  3026. "%s: IIR #%d band #%d a1 = 0x%x\n"
  3027. "%s: IIR #%d band #%d a2 = 0x%x\n",
  3028. __func__, iir_idx, band_idx,
  3029. get_iir_band_coeff(codec, iir_idx, band_idx, 0),
  3030. __func__, iir_idx, band_idx,
  3031. get_iir_band_coeff(codec, iir_idx, band_idx, 1),
  3032. __func__, iir_idx, band_idx,
  3033. get_iir_band_coeff(codec, iir_idx, band_idx, 2),
  3034. __func__, iir_idx, band_idx,
  3035. get_iir_band_coeff(codec, iir_idx, band_idx, 3),
  3036. __func__, iir_idx, band_idx,
  3037. get_iir_band_coeff(codec, iir_idx, band_idx, 4));
  3038. return 0;
  3039. }
  3040. static int tasha_get_compander(struct snd_kcontrol *kcontrol,
  3041. struct snd_ctl_elem_value *ucontrol)
  3042. {
  3043. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3044. int comp = ((struct soc_multi_mixer_control *)
  3045. kcontrol->private_value)->shift;
  3046. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3047. ucontrol->value.integer.value[0] = tasha->comp_enabled[comp];
  3048. return 0;
  3049. }
  3050. static int tasha_set_compander(struct snd_kcontrol *kcontrol,
  3051. struct snd_ctl_elem_value *ucontrol)
  3052. {
  3053. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3054. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3055. int comp = ((struct soc_multi_mixer_control *)
  3056. kcontrol->private_value)->shift;
  3057. int value = ucontrol->value.integer.value[0];
  3058. pr_debug("%s: Compander %d enable current %d, new %d\n",
  3059. __func__, comp + 1, tasha->comp_enabled[comp], value);
  3060. tasha->comp_enabled[comp] = value;
  3061. /* Any specific register configuration for compander */
  3062. switch (comp) {
  3063. case COMPANDER_1:
  3064. /* Set Gain Source Select based on compander enable/disable */
  3065. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0x20,
  3066. (value ? 0x00:0x20));
  3067. break;
  3068. case COMPANDER_2:
  3069. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0x20,
  3070. (value ? 0x00:0x20));
  3071. break;
  3072. case COMPANDER_3:
  3073. break;
  3074. case COMPANDER_4:
  3075. break;
  3076. case COMPANDER_5:
  3077. snd_soc_update_bits(codec, WCD9335_SE_LO_LO3_GAIN, 0x20,
  3078. (value ? 0x00:0x20));
  3079. break;
  3080. case COMPANDER_6:
  3081. snd_soc_update_bits(codec, WCD9335_SE_LO_LO4_GAIN, 0x20,
  3082. (value ? 0x00:0x20));
  3083. break;
  3084. case COMPANDER_7:
  3085. break;
  3086. case COMPANDER_8:
  3087. break;
  3088. default:
  3089. /*
  3090. * if compander is not enabled for any interpolator,
  3091. * it does not cause any audio failure, so do not
  3092. * return error in this case, but just print a log
  3093. */
  3094. dev_warn(codec->dev, "%s: unknown compander: %d\n",
  3095. __func__, comp);
  3096. };
  3097. return 0;
  3098. }
  3099. static void tasha_codec_init_flyback(struct snd_soc_codec *codec)
  3100. {
  3101. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x00);
  3102. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x00);
  3103. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0x0F, 0x00);
  3104. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0xF0, 0x00);
  3105. }
  3106. static int tasha_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
  3107. struct snd_kcontrol *kcontrol, int event)
  3108. {
  3109. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3110. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3111. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3112. switch (event) {
  3113. case SND_SOC_DAPM_PRE_PMU:
  3114. tasha->rx_bias_count++;
  3115. if (tasha->rx_bias_count == 1) {
  3116. if (TASHA_IS_2_0(tasha->wcd9xxx))
  3117. tasha_codec_init_flyback(codec);
  3118. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3119. 0x01, 0x01);
  3120. }
  3121. break;
  3122. case SND_SOC_DAPM_POST_PMD:
  3123. tasha->rx_bias_count--;
  3124. if (!tasha->rx_bias_count)
  3125. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3126. 0x01, 0x00);
  3127. break;
  3128. };
  3129. dev_dbg(codec->dev, "%s: Current RX BIAS user count: %d\n", __func__,
  3130. tasha->rx_bias_count);
  3131. return 0;
  3132. }
  3133. static void tasha_realign_anc_coeff(struct snd_soc_codec *codec,
  3134. u16 reg1, u16 reg2)
  3135. {
  3136. u8 val1, val2, tmpval1, tmpval2;
  3137. snd_soc_write(codec, reg1, 0x00);
  3138. tmpval1 = snd_soc_read(codec, reg2);
  3139. tmpval2 = snd_soc_read(codec, reg2);
  3140. snd_soc_write(codec, reg1, 0x00);
  3141. snd_soc_write(codec, reg2, 0xFF);
  3142. snd_soc_write(codec, reg1, 0x01);
  3143. snd_soc_write(codec, reg2, 0xFF);
  3144. snd_soc_write(codec, reg1, 0x00);
  3145. val1 = snd_soc_read(codec, reg2);
  3146. val2 = snd_soc_read(codec, reg2);
  3147. if (val1 == 0x0F && val2 == 0xFF) {
  3148. dev_dbg(codec->dev, "%s: ANC0 co-eff index re-aligned\n",
  3149. __func__);
  3150. snd_soc_read(codec, reg2);
  3151. snd_soc_write(codec, reg1, 0x00);
  3152. snd_soc_write(codec, reg2, tmpval2);
  3153. snd_soc_write(codec, reg1, 0x01);
  3154. snd_soc_write(codec, reg2, tmpval1);
  3155. } else if (val1 == 0xFF && val2 == 0x0F) {
  3156. dev_dbg(codec->dev, "%s: ANC1 co-eff index already aligned\n",
  3157. __func__);
  3158. snd_soc_write(codec, reg1, 0x00);
  3159. snd_soc_write(codec, reg2, tmpval1);
  3160. snd_soc_write(codec, reg1, 0x01);
  3161. snd_soc_write(codec, reg2, tmpval2);
  3162. } else {
  3163. dev_err(codec->dev, "%s: ANC0 co-eff index not aligned\n",
  3164. __func__);
  3165. }
  3166. }
  3167. static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w,
  3168. struct snd_kcontrol *kcontrol, int event)
  3169. {
  3170. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3171. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3172. const char *filename;
  3173. const struct firmware *fw;
  3174. int i;
  3175. int ret = 0;
  3176. int num_anc_slots;
  3177. struct wcd9xxx_anc_header *anc_head;
  3178. struct firmware_cal *hwdep_cal = NULL;
  3179. u32 anc_writes_size = 0;
  3180. u32 anc_cal_size = 0;
  3181. int anc_size_remaining;
  3182. u32 *anc_ptr;
  3183. u16 reg;
  3184. u8 mask, val;
  3185. size_t cal_size;
  3186. const void *data;
  3187. if (!tasha->anc_func)
  3188. return 0;
  3189. switch (event) {
  3190. case SND_SOC_DAPM_PRE_PMU:
  3191. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_ANC_CAL);
  3192. if (hwdep_cal) {
  3193. data = hwdep_cal->data;
  3194. cal_size = hwdep_cal->size;
  3195. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  3196. __func__);
  3197. } else {
  3198. filename = "wcd9335/wcd9335_anc.bin";
  3199. ret = request_firmware(&fw, filename, codec->dev);
  3200. if (ret != 0) {
  3201. dev_err(codec->dev,
  3202. "Failed to acquire ANC data: %d\n", ret);
  3203. return -ENODEV;
  3204. }
  3205. if (!fw) {
  3206. dev_err(codec->dev, "failed to get anc fw");
  3207. return -ENODEV;
  3208. }
  3209. data = fw->data;
  3210. cal_size = fw->size;
  3211. dev_dbg(codec->dev,
  3212. "%s: using request_firmware calibration\n", __func__);
  3213. }
  3214. if (cal_size < sizeof(struct wcd9xxx_anc_header)) {
  3215. dev_err(codec->dev, "Not enough data\n");
  3216. ret = -ENOMEM;
  3217. goto err;
  3218. }
  3219. /* First number is the number of register writes */
  3220. anc_head = (struct wcd9xxx_anc_header *)(data);
  3221. anc_ptr = (u32 *)(data +
  3222. sizeof(struct wcd9xxx_anc_header));
  3223. anc_size_remaining = cal_size -
  3224. sizeof(struct wcd9xxx_anc_header);
  3225. num_anc_slots = anc_head->num_anc_slots;
  3226. if (tasha->anc_slot >= num_anc_slots) {
  3227. dev_err(codec->dev, "Invalid ANC slot selected\n");
  3228. ret = -EINVAL;
  3229. goto err;
  3230. }
  3231. for (i = 0; i < num_anc_slots; i++) {
  3232. if (anc_size_remaining < TASHA_PACKED_REG_SIZE) {
  3233. dev_err(codec->dev,
  3234. "Invalid register format\n");
  3235. ret = -EINVAL;
  3236. goto err;
  3237. }
  3238. anc_writes_size = (u32)(*anc_ptr);
  3239. anc_size_remaining -= sizeof(u32);
  3240. anc_ptr += 1;
  3241. if (anc_writes_size * TASHA_PACKED_REG_SIZE
  3242. > anc_size_remaining) {
  3243. dev_err(codec->dev,
  3244. "Invalid register format\n");
  3245. ret = -EINVAL;
  3246. goto err;
  3247. }
  3248. if (tasha->anc_slot == i)
  3249. break;
  3250. anc_size_remaining -= (anc_writes_size *
  3251. TASHA_PACKED_REG_SIZE);
  3252. anc_ptr += anc_writes_size;
  3253. }
  3254. if (i == num_anc_slots) {
  3255. dev_err(codec->dev, "Selected ANC slot not present\n");
  3256. ret = -EINVAL;
  3257. goto err;
  3258. }
  3259. i = 0;
  3260. anc_cal_size = anc_writes_size;
  3261. if (!strcmp(w->name, "RX INT0 DAC") ||
  3262. !strcmp(w->name, "ANC SPK1 PA"))
  3263. tasha_realign_anc_coeff(codec,
  3264. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3265. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3266. if (!strcmp(w->name, "RX INT1 DAC") ||
  3267. !strcmp(w->name, "RX INT3 DAC")) {
  3268. tasha_realign_anc_coeff(codec,
  3269. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3270. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3271. anc_writes_size = anc_cal_size / 2;
  3272. snd_soc_update_bits(codec,
  3273. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x39, 0x39);
  3274. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3275. !strcmp(w->name, "RX INT4 DAC")) {
  3276. tasha_realign_anc_coeff(codec,
  3277. WCD9335_CDC_ANC1_IIR_COEFF_1_CTL,
  3278. WCD9335_CDC_ANC1_IIR_COEFF_2_CTL);
  3279. i = anc_cal_size / 2;
  3280. snd_soc_update_bits(codec,
  3281. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x39, 0x39);
  3282. }
  3283. for (; i < anc_writes_size; i++) {
  3284. TASHA_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val);
  3285. snd_soc_write(codec, reg, (val & mask));
  3286. }
  3287. if (!strcmp(w->name, "RX INT1 DAC") ||
  3288. !strcmp(w->name, "RX INT3 DAC")) {
  3289. snd_soc_update_bits(codec,
  3290. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08);
  3291. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3292. !strcmp(w->name, "RX INT4 DAC")) {
  3293. snd_soc_update_bits(codec,
  3294. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08);
  3295. }
  3296. if (!hwdep_cal)
  3297. release_firmware(fw);
  3298. break;
  3299. case SND_SOC_DAPM_POST_PMU:
  3300. /* Remove ANC Rx from reset */
  3301. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_CLK_RESET_CTL,
  3302. 0x08, 0x00);
  3303. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_CLK_RESET_CTL,
  3304. 0x08, 0x00);
  3305. break;
  3306. case SND_SOC_DAPM_POST_PMD:
  3307. if (!strcmp(w->name, "ANC HPHL PA") ||
  3308. !strcmp(w->name, "ANC EAR PA") ||
  3309. !strcmp(w->name, "ANC SPK1 PA") ||
  3310. !strcmp(w->name, "ANC LINEOUT1 PA")) {
  3311. snd_soc_update_bits(codec,
  3312. WCD9335_CDC_ANC0_MODE_1_CTL, 0x30, 0x00);
  3313. msleep(50);
  3314. snd_soc_update_bits(codec,
  3315. WCD9335_CDC_ANC0_MODE_1_CTL, 0x01, 0x00);
  3316. snd_soc_update_bits(codec,
  3317. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x38);
  3318. snd_soc_update_bits(codec,
  3319. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x07, 0x00);
  3320. snd_soc_update_bits(codec,
  3321. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x00);
  3322. } else if (!strcmp(w->name, "ANC HPHR PA") ||
  3323. !strcmp(w->name, "ANC LINEOUT2 PA")) {
  3324. snd_soc_update_bits(codec,
  3325. WCD9335_CDC_ANC1_MODE_1_CTL, 0x30, 0x00);
  3326. msleep(50);
  3327. snd_soc_update_bits(codec,
  3328. WCD9335_CDC_ANC1_MODE_1_CTL, 0x01, 0x00);
  3329. snd_soc_update_bits(codec,
  3330. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x38);
  3331. snd_soc_update_bits(codec,
  3332. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x07, 0x00);
  3333. snd_soc_update_bits(codec,
  3334. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x00);
  3335. }
  3336. break;
  3337. }
  3338. return 0;
  3339. err:
  3340. if (!hwdep_cal)
  3341. release_firmware(fw);
  3342. return ret;
  3343. }
  3344. static void tasha_codec_clear_anc_tx_hold(struct tasha_priv *tasha)
  3345. {
  3346. if (test_and_clear_bit(ANC_MIC_AMIC1, &tasha->status_mask))
  3347. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC1, false);
  3348. if (test_and_clear_bit(ANC_MIC_AMIC2, &tasha->status_mask))
  3349. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC2, false);
  3350. if (test_and_clear_bit(ANC_MIC_AMIC3, &tasha->status_mask))
  3351. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC3, false);
  3352. if (test_and_clear_bit(ANC_MIC_AMIC4, &tasha->status_mask))
  3353. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC4, false);
  3354. if (test_and_clear_bit(ANC_MIC_AMIC5, &tasha->status_mask))
  3355. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC5, false);
  3356. if (test_and_clear_bit(ANC_MIC_AMIC6, &tasha->status_mask))
  3357. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC6, false);
  3358. }
  3359. static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha,
  3360. int mode, int event)
  3361. {
  3362. u8 scale_val = 0;
  3363. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3364. return;
  3365. switch (event) {
  3366. case SND_SOC_DAPM_POST_PMU:
  3367. switch (mode) {
  3368. case CLS_H_HIFI:
  3369. scale_val = 0x3;
  3370. break;
  3371. case CLS_H_LOHIFI:
  3372. scale_val = 0x1;
  3373. break;
  3374. }
  3375. if (tasha->anc_func) {
  3376. /* Clear Tx FE HOLD if both PAs are enabled */
  3377. if ((snd_soc_read(tasha->codec, WCD9335_ANA_HPH) &
  3378. 0xC0) == 0xC0) {
  3379. tasha_codec_clear_anc_tx_hold(tasha);
  3380. }
  3381. }
  3382. break;
  3383. case SND_SOC_DAPM_PRE_PMD:
  3384. scale_val = 0x6;
  3385. break;
  3386. }
  3387. if (scale_val)
  3388. snd_soc_update_bits(tasha->codec, WCD9335_HPH_PA_CTL1, 0x0E,
  3389. scale_val << 1);
  3390. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3391. if (tasha->comp_enabled[COMPANDER_1] ||
  3392. tasha->comp_enabled[COMPANDER_2]) {
  3393. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN,
  3394. 0x20, 0x00);
  3395. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN,
  3396. 0x20, 0x00);
  3397. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP,
  3398. 0x20, 0x20);
  3399. }
  3400. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN, 0x1F,
  3401. tasha->hph_l_gain);
  3402. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN, 0x1F,
  3403. tasha->hph_r_gain);
  3404. }
  3405. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3406. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP, 0x20,
  3407. 0x00);
  3408. }
  3409. }
  3410. static void tasha_codec_override(struct snd_soc_codec *codec,
  3411. int mode,
  3412. int event)
  3413. {
  3414. if (mode == CLS_AB) {
  3415. switch (event) {
  3416. case SND_SOC_DAPM_POST_PMU:
  3417. if (!(snd_soc_read(codec,
  3418. WCD9335_CDC_RX2_RX_PATH_CTL) & 0x10) &&
  3419. (!(snd_soc_read(codec,
  3420. WCD9335_CDC_RX1_RX_PATH_CTL) & 0x10)))
  3421. snd_soc_update_bits(codec,
  3422. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x02);
  3423. break;
  3424. case SND_SOC_DAPM_POST_PMD:
  3425. snd_soc_update_bits(codec,
  3426. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00);
  3427. break;
  3428. }
  3429. }
  3430. }
  3431. static int tasha_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
  3432. struct snd_kcontrol *kcontrol,
  3433. int event)
  3434. {
  3435. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3436. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3437. int hph_mode = tasha->hph_mode;
  3438. int ret = 0;
  3439. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3440. switch (event) {
  3441. case SND_SOC_DAPM_PRE_PMU:
  3442. if ((!(strcmp(w->name, "ANC HPHR PA"))) &&
  3443. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3444. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3445. }
  3446. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3447. if (!(strcmp(w->name, "HPHR PA")))
  3448. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x40);
  3449. break;
  3450. case SND_SOC_DAPM_POST_PMU:
  3451. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3452. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3453. != 0xC0)
  3454. /*
  3455. * If PA_EN is not set (potentially in ANC case)
  3456. * then do nothing for POST_PMU and let left
  3457. * channel handle everything.
  3458. */
  3459. break;
  3460. }
  3461. /*
  3462. * 7ms sleep is required after PA is enabled as per
  3463. * HW requirement
  3464. */
  3465. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3466. usleep_range(7000, 7100);
  3467. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3468. }
  3469. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3470. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3471. 0x10, 0x00);
  3472. /* Remove mix path mute if it is enabled */
  3473. if ((snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3474. 0x10)
  3475. snd_soc_update_bits(codec,
  3476. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3477. 0x10, 0x00);
  3478. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3479. /* Do everything needed for left channel */
  3480. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3481. 0x10, 0x00);
  3482. /* Remove mix path mute if it is enabled */
  3483. if ((snd_soc_read(codec,
  3484. WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3485. 0x10)
  3486. snd_soc_update_bits(codec,
  3487. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3488. 0x10, 0x00);
  3489. /* Remove ANC Rx from reset */
  3490. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3491. }
  3492. tasha_codec_override(codec, hph_mode, event);
  3493. break;
  3494. case SND_SOC_DAPM_PRE_PMD:
  3495. blocking_notifier_call_chain(&tasha->notifier,
  3496. WCD_EVENT_PRE_HPHR_PA_OFF,
  3497. &tasha->mbhc);
  3498. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3499. if (!(strcmp(w->name, "ANC HPHR PA")) ||
  3500. !(strcmp(w->name, "HPHR PA")))
  3501. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x00);
  3502. break;
  3503. case SND_SOC_DAPM_POST_PMD:
  3504. /* 5ms sleep is required after PA is disabled as per
  3505. * HW requirement
  3506. */
  3507. usleep_range(5000, 5500);
  3508. tasha_codec_override(codec, hph_mode, event);
  3509. blocking_notifier_call_chain(&tasha->notifier,
  3510. WCD_EVENT_POST_HPHR_PA_OFF,
  3511. &tasha->mbhc);
  3512. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3513. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3514. snd_soc_update_bits(codec,
  3515. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x00);
  3516. }
  3517. break;
  3518. };
  3519. return ret;
  3520. }
  3521. static int tasha_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
  3522. struct snd_kcontrol *kcontrol,
  3523. int event)
  3524. {
  3525. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3526. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3527. int hph_mode = tasha->hph_mode;
  3528. int ret = 0;
  3529. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3530. switch (event) {
  3531. case SND_SOC_DAPM_PRE_PMU:
  3532. if ((!(strcmp(w->name, "ANC HPHL PA"))) &&
  3533. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3534. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3535. }
  3536. if (!(strcmp(w->name, "HPHL PA")))
  3537. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x80);
  3538. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3539. break;
  3540. case SND_SOC_DAPM_POST_PMU:
  3541. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3542. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3543. != 0xC0)
  3544. /*
  3545. * If PA_EN is not set (potentially in ANC case)
  3546. * then do nothing for POST_PMU and let right
  3547. * channel handle everything.
  3548. */
  3549. break;
  3550. }
  3551. /*
  3552. * 7ms sleep is required after PA is enabled as per
  3553. * HW requirement
  3554. */
  3555. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3556. usleep_range(7000, 7100);
  3557. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3558. }
  3559. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3560. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3561. 0x10, 0x00);
  3562. /* Remove mix path mute if it is enabled */
  3563. if ((snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3564. 0x10)
  3565. snd_soc_update_bits(codec,
  3566. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3567. 0x10, 0x00);
  3568. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3569. /* Do everything needed for right channel */
  3570. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3571. 0x10, 0x00);
  3572. /* Remove mix path mute if it is enabled */
  3573. if ((snd_soc_read(codec,
  3574. WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3575. 0x10)
  3576. snd_soc_update_bits(codec,
  3577. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3578. 0x10, 0x00);
  3579. /* Remove ANC Rx from reset */
  3580. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3581. }
  3582. tasha_codec_override(codec, hph_mode, event);
  3583. break;
  3584. case SND_SOC_DAPM_PRE_PMD:
  3585. blocking_notifier_call_chain(&tasha->notifier,
  3586. WCD_EVENT_PRE_HPHL_PA_OFF,
  3587. &tasha->mbhc);
  3588. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3589. if (!(strcmp(w->name, "ANC HPHL PA")) ||
  3590. !(strcmp(w->name, "HPHL PA")))
  3591. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x00);
  3592. break;
  3593. case SND_SOC_DAPM_POST_PMD:
  3594. /* 5ms sleep is required after PA is disabled as per
  3595. * HW requirement
  3596. */
  3597. usleep_range(5000, 5500);
  3598. tasha_codec_override(codec, hph_mode, event);
  3599. blocking_notifier_call_chain(&tasha->notifier,
  3600. WCD_EVENT_POST_HPHL_PA_OFF,
  3601. &tasha->mbhc);
  3602. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3603. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3604. snd_soc_update_bits(codec,
  3605. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00);
  3606. }
  3607. break;
  3608. };
  3609. return ret;
  3610. }
  3611. static int tasha_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w,
  3612. struct snd_kcontrol *kcontrol,
  3613. int event)
  3614. {
  3615. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3616. u16 lineout_vol_reg = 0, lineout_mix_vol_reg = 0;
  3617. int ret = 0;
  3618. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3619. if (w->reg == WCD9335_ANA_LO_1_2) {
  3620. if (w->shift == 7) {
  3621. lineout_vol_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  3622. lineout_mix_vol_reg = WCD9335_CDC_RX3_RX_PATH_MIX_CTL;
  3623. } else if (w->shift == 6) {
  3624. lineout_vol_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  3625. lineout_mix_vol_reg = WCD9335_CDC_RX4_RX_PATH_MIX_CTL;
  3626. }
  3627. } else if (w->reg == WCD9335_ANA_LO_3_4) {
  3628. if (w->shift == 7) {
  3629. lineout_vol_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  3630. lineout_mix_vol_reg = WCD9335_CDC_RX5_RX_PATH_MIX_CTL;
  3631. } else if (w->shift == 6) {
  3632. lineout_vol_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  3633. lineout_mix_vol_reg = WCD9335_CDC_RX6_RX_PATH_MIX_CTL;
  3634. }
  3635. } else {
  3636. dev_err(codec->dev, "%s: Error enabling lineout PA\n",
  3637. __func__);
  3638. return -EINVAL;
  3639. }
  3640. switch (event) {
  3641. case SND_SOC_DAPM_POST_PMU:
  3642. /* 5ms sleep is required after PA is enabled as per
  3643. * HW requirement
  3644. */
  3645. usleep_range(5000, 5500);
  3646. snd_soc_update_bits(codec, lineout_vol_reg,
  3647. 0x10, 0x00);
  3648. /* Remove mix path mute if it is enabled */
  3649. if ((snd_soc_read(codec, lineout_mix_vol_reg)) & 0x10)
  3650. snd_soc_update_bits(codec,
  3651. lineout_mix_vol_reg,
  3652. 0x10, 0x00);
  3653. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3654. !(strcmp(w->name, "ANC LINEOUT2 PA")))
  3655. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3656. tasha_codec_override(codec, CLS_AB, event);
  3657. break;
  3658. case SND_SOC_DAPM_POST_PMD:
  3659. /* 5ms sleep is required after PA is disabled as per
  3660. * HW requirement
  3661. */
  3662. usleep_range(5000, 5500);
  3663. tasha_codec_override(codec, CLS_AB, event);
  3664. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3665. !(strcmp(w->name, "ANC LINEOUT2 PA"))) {
  3666. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3667. if (!(strcmp(w->name, "ANC LINEOUT1 PA")))
  3668. snd_soc_update_bits(codec,
  3669. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  3670. else
  3671. snd_soc_update_bits(codec,
  3672. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  3673. }
  3674. break;
  3675. };
  3676. return ret;
  3677. }
  3678. static void tasha_spk_anc_update_callback(struct work_struct *work)
  3679. {
  3680. struct spk_anc_work *spk_anc_dwork;
  3681. struct tasha_priv *tasha;
  3682. struct delayed_work *delayed_work;
  3683. struct snd_soc_codec *codec;
  3684. delayed_work = to_delayed_work(work);
  3685. spk_anc_dwork = container_of(delayed_work, struct spk_anc_work, dwork);
  3686. tasha = spk_anc_dwork->tasha;
  3687. codec = tasha->codec;
  3688. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0, 0x10, 0x10);
  3689. }
  3690. static int tasha_codec_enable_spk_anc(struct snd_soc_dapm_widget *w,
  3691. struct snd_kcontrol *kcontrol,
  3692. int event)
  3693. {
  3694. int ret = 0;
  3695. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3696. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3697. dev_dbg(codec->dev, "%s %s %d %d\n", __func__, w->name, event,
  3698. tasha->anc_func);
  3699. if (!tasha->anc_func)
  3700. return 0;
  3701. switch (event) {
  3702. case SND_SOC_DAPM_PRE_PMU:
  3703. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3704. schedule_delayed_work(&tasha->spk_anc_dwork.dwork,
  3705. msecs_to_jiffies(spk_anc_en_delay));
  3706. break;
  3707. case SND_SOC_DAPM_POST_PMD:
  3708. cancel_delayed_work_sync(&tasha->spk_anc_dwork.dwork);
  3709. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0,
  3710. 0x10, 0x00);
  3711. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3712. break;
  3713. }
  3714. return ret;
  3715. }
  3716. static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
  3717. struct snd_kcontrol *kcontrol,
  3718. int event)
  3719. {
  3720. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3721. int ret = 0;
  3722. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3723. switch (event) {
  3724. case SND_SOC_DAPM_POST_PMU:
  3725. /* 5ms sleep is required after PA is enabled as per
  3726. * HW requirement
  3727. */
  3728. usleep_range(5000, 5500);
  3729. snd_soc_update_bits(codec, WCD9335_CDC_RX0_RX_PATH_CTL,
  3730. 0x10, 0x00);
  3731. /* Remove mix path mute if it is enabled */
  3732. if ((snd_soc_read(codec, WCD9335_CDC_RX0_RX_PATH_MIX_CTL)) &
  3733. 0x10)
  3734. snd_soc_update_bits(codec,
  3735. WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  3736. 0x10, 0x00);
  3737. break;
  3738. case SND_SOC_DAPM_POST_PMD:
  3739. /* 5ms sleep is required after PA is disabled as per
  3740. * HW requirement
  3741. */
  3742. usleep_range(5000, 5500);
  3743. if (!(strcmp(w->name, "ANC EAR PA"))) {
  3744. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3745. snd_soc_update_bits(codec,
  3746. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x00);
  3747. }
  3748. break;
  3749. };
  3750. return ret;
  3751. }
  3752. static void tasha_codec_hph_mode_gain_opt(struct snd_soc_codec *codec,
  3753. u8 gain)
  3754. {
  3755. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3756. u8 hph_l_en, hph_r_en;
  3757. u8 l_val, r_val;
  3758. u8 hph_pa_status;
  3759. bool is_hphl_pa, is_hphr_pa;
  3760. hph_pa_status = snd_soc_read(codec, WCD9335_ANA_HPH);
  3761. is_hphl_pa = hph_pa_status >> 7;
  3762. is_hphr_pa = (hph_pa_status & 0x40) >> 6;
  3763. hph_l_en = snd_soc_read(codec, WCD9335_HPH_L_EN);
  3764. hph_r_en = snd_soc_read(codec, WCD9335_HPH_R_EN);
  3765. l_val = (hph_l_en & 0xC0) | 0x20 | gain;
  3766. r_val = (hph_r_en & 0xC0) | 0x20 | gain;
  3767. /*
  3768. * Set HPH_L & HPH_R gain source selection to REGISTER
  3769. * for better click and pop only if corresponding PAs are
  3770. * not enabled. Also cache the values of the HPHL/R
  3771. * PA gains to be applied after PAs are enabled
  3772. */
  3773. if ((l_val != hph_l_en) && !is_hphl_pa) {
  3774. snd_soc_write(codec, WCD9335_HPH_L_EN, l_val);
  3775. tasha->hph_l_gain = hph_l_en & 0x1F;
  3776. }
  3777. if ((r_val != hph_r_en) && !is_hphr_pa) {
  3778. snd_soc_write(codec, WCD9335_HPH_R_EN, r_val);
  3779. tasha->hph_r_gain = hph_r_en & 0x1F;
  3780. }
  3781. }
  3782. static void tasha_codec_hph_lohifi_config(struct snd_soc_codec *codec,
  3783. int event)
  3784. {
  3785. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3786. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x06);
  3787. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2,
  3788. 0xF0, 0x40);
  3789. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3790. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3791. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3792. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3793. }
  3794. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3795. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3796. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3797. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A);
  3798. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x0A);
  3799. }
  3800. }
  3801. static void tasha_codec_hph_lp_config(struct snd_soc_codec *codec,
  3802. int event)
  3803. {
  3804. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3805. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3806. tasha_codec_hph_mode_gain_opt(codec, 0x10);
  3807. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3808. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3809. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x04);
  3810. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x20);
  3811. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x07,
  3812. 0x01);
  3813. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x70,
  3814. 0x10);
  3815. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3816. 0x0F, 0x01);
  3817. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3818. 0xF0, 0x10);
  3819. }
  3820. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3821. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x88);
  3822. snd_soc_write(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x33);
  3823. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x00);
  3824. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x00);
  3825. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3826. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3827. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x80);
  3828. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x80);
  3829. }
  3830. }
  3831. static void tasha_codec_hph_hifi_config(struct snd_soc_codec *codec,
  3832. int event)
  3833. {
  3834. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3835. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3836. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3837. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3838. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3839. }
  3840. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3841. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3842. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3843. }
  3844. }
  3845. static void tasha_codec_hph_mode_config(struct snd_soc_codec *codec,
  3846. int event, int mode)
  3847. {
  3848. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3849. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3850. return;
  3851. switch (mode) {
  3852. case CLS_H_LP:
  3853. tasha_codec_hph_lp_config(codec, event);
  3854. break;
  3855. case CLS_H_LOHIFI:
  3856. tasha_codec_hph_lohifi_config(codec, event);
  3857. break;
  3858. case CLS_H_HIFI:
  3859. tasha_codec_hph_hifi_config(codec, event);
  3860. break;
  3861. }
  3862. }
  3863. static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
  3864. struct snd_kcontrol *kcontrol,
  3865. int event)
  3866. {
  3867. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3868. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3869. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3870. int hph_mode = tasha->hph_mode;
  3871. u8 dem_inp;
  3872. int ret = 0;
  3873. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3874. w->name, event, hph_mode);
  3875. switch (event) {
  3876. case SND_SOC_DAPM_PRE_PMU:
  3877. if (tasha->anc_func) {
  3878. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3879. /* 40 msec delay is needed to avoid click and pop */
  3880. msleep(40);
  3881. }
  3882. /* Read DEM INP Select */
  3883. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_SEC0) &
  3884. 0x03;
  3885. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3886. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3887. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3888. __func__, hph_mode);
  3889. return -EINVAL;
  3890. }
  3891. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3892. WCD_CLSH_EVENT_PRE_DAC,
  3893. WCD_CLSH_STATE_HPHR,
  3894. ((hph_mode == CLS_H_LOHIFI) ?
  3895. CLS_H_HIFI : hph_mode));
  3896. if (!(strcmp(w->name, "RX INT2 DAC")))
  3897. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x10, 0x10);
  3898. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3899. if (tasha->anc_func)
  3900. snd_soc_update_bits(codec,
  3901. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x10);
  3902. break;
  3903. case SND_SOC_DAPM_POST_PMU:
  3904. /* 1000us required as per HW requirement */
  3905. usleep_range(1000, 1100);
  3906. if ((hph_mode == CLS_H_LP) &&
  3907. (TASHA_IS_1_1(wcd9xxx))) {
  3908. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3909. 0x03, 0x03);
  3910. }
  3911. break;
  3912. case SND_SOC_DAPM_PRE_PMD:
  3913. if ((hph_mode == CLS_H_LP) &&
  3914. (TASHA_IS_1_1(wcd9xxx))) {
  3915. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3916. 0x03, 0x00);
  3917. }
  3918. if (!(strcmp(w->name, "RX INT2 DAC")))
  3919. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x10, 0x00);
  3920. break;
  3921. case SND_SOC_DAPM_POST_PMD:
  3922. /* 1000us required as per HW requirement */
  3923. usleep_range(1000, 1100);
  3924. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  3925. WCD_CLSH_STATE_HPHL))
  3926. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3927. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3928. WCD_CLSH_EVENT_POST_PA,
  3929. WCD_CLSH_STATE_HPHR,
  3930. ((hph_mode == CLS_H_LOHIFI) ?
  3931. CLS_H_HIFI : hph_mode));
  3932. break;
  3933. };
  3934. return ret;
  3935. }
  3936. static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
  3937. struct snd_kcontrol *kcontrol,
  3938. int event)
  3939. {
  3940. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3941. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3942. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3943. int hph_mode = tasha->hph_mode;
  3944. u8 dem_inp;
  3945. int ret = 0;
  3946. uint32_t impedl = 0, impedr = 0;
  3947. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3948. w->name, event, hph_mode);
  3949. switch (event) {
  3950. case SND_SOC_DAPM_PRE_PMU:
  3951. if (tasha->anc_func) {
  3952. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3953. /* 40 msec delay is needed to avoid click and pop */
  3954. msleep(40);
  3955. }
  3956. /* Read DEM INP Select */
  3957. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_SEC0) &
  3958. 0x03;
  3959. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3960. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3961. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3962. __func__, hph_mode);
  3963. return -EINVAL;
  3964. }
  3965. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3966. WCD_CLSH_EVENT_PRE_DAC,
  3967. WCD_CLSH_STATE_HPHL,
  3968. ((hph_mode == CLS_H_LOHIFI) ?
  3969. CLS_H_HIFI : hph_mode));
  3970. if (!(strcmp(w->name, "RX INT1 DAC")))
  3971. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x20, 0x20);
  3972. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3973. if (tasha->anc_func)
  3974. snd_soc_update_bits(codec,
  3975. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x10);
  3976. ret = wcd_mbhc_get_impedance(&tasha->mbhc,
  3977. &impedl, &impedr);
  3978. if (!ret) {
  3979. wcd_clsh_imped_config(codec, impedl, false);
  3980. set_bit(CLASSH_CONFIG, &tasha->status_mask);
  3981. } else {
  3982. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  3983. __func__, ret);
  3984. ret = 0;
  3985. }
  3986. break;
  3987. case SND_SOC_DAPM_POST_PMU:
  3988. /* 1000us required as per HW requirement */
  3989. usleep_range(1000, 1100);
  3990. if ((hph_mode == CLS_H_LP) &&
  3991. (TASHA_IS_1_1(wcd9xxx))) {
  3992. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3993. 0x03, 0x03);
  3994. }
  3995. break;
  3996. case SND_SOC_DAPM_PRE_PMD:
  3997. if (!(strcmp(w->name, "RX INT1 DAC")))
  3998. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x20, 0x00);
  3999. if ((hph_mode == CLS_H_LP) &&
  4000. (TASHA_IS_1_1(wcd9xxx))) {
  4001. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  4002. 0x03, 0x00);
  4003. }
  4004. break;
  4005. case SND_SOC_DAPM_POST_PMD:
  4006. /* 1000us required as per HW requirement */
  4007. usleep_range(1000, 1100);
  4008. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  4009. WCD_CLSH_STATE_HPHR))
  4010. tasha_codec_hph_mode_config(codec, event, hph_mode);
  4011. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4012. WCD_CLSH_EVENT_POST_PA,
  4013. WCD_CLSH_STATE_HPHL,
  4014. ((hph_mode == CLS_H_LOHIFI) ?
  4015. CLS_H_HIFI : hph_mode));
  4016. if (test_bit(CLASSH_CONFIG, &tasha->status_mask)) {
  4017. wcd_clsh_imped_config(codec, impedl, true);
  4018. clear_bit(CLASSH_CONFIG, &tasha->status_mask);
  4019. } else
  4020. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  4021. __func__, ret);
  4022. break;
  4023. };
  4024. return ret;
  4025. }
  4026. static int tasha_codec_lineout_dac_event(struct snd_soc_dapm_widget *w,
  4027. struct snd_kcontrol *kcontrol,
  4028. int event)
  4029. {
  4030. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4031. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4032. int ret = 0;
  4033. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4034. switch (event) {
  4035. case SND_SOC_DAPM_PRE_PMU:
  4036. if (tasha->anc_func &&
  4037. (!strcmp(w->name, "RX INT3 DAC") ||
  4038. !strcmp(w->name, "RX INT4 DAC")))
  4039. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4040. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4041. WCD_CLSH_EVENT_PRE_DAC,
  4042. WCD_CLSH_STATE_LO,
  4043. CLS_AB);
  4044. if (tasha->anc_func) {
  4045. if (!strcmp(w->name, "RX INT3 DAC"))
  4046. snd_soc_update_bits(codec,
  4047. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  4048. else if (!strcmp(w->name, "RX INT4 DAC"))
  4049. snd_soc_update_bits(codec,
  4050. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  4051. }
  4052. break;
  4053. case SND_SOC_DAPM_POST_PMD:
  4054. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4055. WCD_CLSH_EVENT_POST_PA,
  4056. WCD_CLSH_STATE_LO,
  4057. CLS_AB);
  4058. break;
  4059. }
  4060. return 0;
  4061. }
  4062. static const struct snd_soc_dapm_widget tasha_dapm_i2s_widgets[] = {
  4063. SND_SOC_DAPM_SUPPLY("RX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  4064. 0, 0, NULL, 0),
  4065. SND_SOC_DAPM_SUPPLY("TX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  4066. 0, 0, NULL, 0),
  4067. };
  4068. static int tasha_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
  4069. struct snd_kcontrol *kcontrol,
  4070. int event)
  4071. {
  4072. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4073. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4074. int ret = 0;
  4075. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4076. switch (event) {
  4077. case SND_SOC_DAPM_PRE_PMU:
  4078. if (tasha->anc_func)
  4079. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4080. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4081. WCD_CLSH_EVENT_PRE_DAC,
  4082. WCD_CLSH_STATE_EAR,
  4083. CLS_H_NORMAL);
  4084. if (tasha->anc_func)
  4085. snd_soc_update_bits(codec,
  4086. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x10);
  4087. break;
  4088. case SND_SOC_DAPM_POST_PMU:
  4089. break;
  4090. case SND_SOC_DAPM_PRE_PMD:
  4091. break;
  4092. case SND_SOC_DAPM_POST_PMD:
  4093. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4094. WCD_CLSH_EVENT_POST_PA,
  4095. WCD_CLSH_STATE_EAR,
  4096. CLS_H_NORMAL);
  4097. break;
  4098. };
  4099. return ret;
  4100. }
  4101. static int tasha_codec_spk_boost_event(struct snd_soc_dapm_widget *w,
  4102. struct snd_kcontrol *kcontrol,
  4103. int event)
  4104. {
  4105. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4106. u16 boost_path_ctl, boost_path_cfg1;
  4107. u16 reg, reg_mix;
  4108. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4109. if (!strcmp(w->name, "RX INT7 CHAIN")) {
  4110. boost_path_ctl = WCD9335_CDC_BOOST0_BOOST_PATH_CTL;
  4111. boost_path_cfg1 = WCD9335_CDC_RX7_RX_PATH_CFG1;
  4112. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4113. reg_mix = WCD9335_CDC_RX7_RX_PATH_MIX_CTL;
  4114. } else if (!strcmp(w->name, "RX INT8 CHAIN")) {
  4115. boost_path_ctl = WCD9335_CDC_BOOST1_BOOST_PATH_CTL;
  4116. boost_path_cfg1 = WCD9335_CDC_RX8_RX_PATH_CFG1;
  4117. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4118. reg_mix = WCD9335_CDC_RX8_RX_PATH_MIX_CTL;
  4119. } else {
  4120. dev_err(codec->dev, "%s: unknown widget: %s\n",
  4121. __func__, w->name);
  4122. return -EINVAL;
  4123. }
  4124. switch (event) {
  4125. case SND_SOC_DAPM_PRE_PMU:
  4126. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10);
  4127. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01);
  4128. snd_soc_update_bits(codec, reg, 0x10, 0x00);
  4129. if ((snd_soc_read(codec, reg_mix)) & 0x10)
  4130. snd_soc_update_bits(codec, reg_mix, 0x10, 0x00);
  4131. break;
  4132. case SND_SOC_DAPM_POST_PMD:
  4133. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00);
  4134. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00);
  4135. break;
  4136. };
  4137. return 0;
  4138. }
  4139. static u16 tasha_interp_get_primary_reg(u16 reg, u16 *ind)
  4140. {
  4141. u16 prim_int_reg = 0;
  4142. switch (reg) {
  4143. case WCD9335_CDC_RX0_RX_PATH_CTL:
  4144. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4145. prim_int_reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4146. *ind = 0;
  4147. break;
  4148. case WCD9335_CDC_RX1_RX_PATH_CTL:
  4149. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4150. prim_int_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4151. *ind = 1;
  4152. break;
  4153. case WCD9335_CDC_RX2_RX_PATH_CTL:
  4154. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4155. prim_int_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4156. *ind = 2;
  4157. break;
  4158. case WCD9335_CDC_RX3_RX_PATH_CTL:
  4159. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4160. prim_int_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4161. *ind = 3;
  4162. break;
  4163. case WCD9335_CDC_RX4_RX_PATH_CTL:
  4164. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4165. prim_int_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4166. *ind = 4;
  4167. break;
  4168. case WCD9335_CDC_RX5_RX_PATH_CTL:
  4169. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4170. prim_int_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4171. *ind = 5;
  4172. break;
  4173. case WCD9335_CDC_RX6_RX_PATH_CTL:
  4174. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4175. prim_int_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4176. *ind = 6;
  4177. break;
  4178. case WCD9335_CDC_RX7_RX_PATH_CTL:
  4179. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4180. prim_int_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4181. *ind = 7;
  4182. break;
  4183. case WCD9335_CDC_RX8_RX_PATH_CTL:
  4184. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4185. prim_int_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4186. *ind = 8;
  4187. break;
  4188. };
  4189. return prim_int_reg;
  4190. }
  4191. static void tasha_codec_hd2_control(struct snd_soc_codec *codec,
  4192. u16 prim_int_reg, int event)
  4193. {
  4194. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4195. u16 hd2_scale_reg;
  4196. u16 hd2_enable_reg = 0;
  4197. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  4198. return;
  4199. if (prim_int_reg == WCD9335_CDC_RX1_RX_PATH_CTL) {
  4200. hd2_scale_reg = WCD9335_CDC_RX1_RX_PATH_SEC3;
  4201. hd2_enable_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4202. }
  4203. if (prim_int_reg == WCD9335_CDC_RX2_RX_PATH_CTL) {
  4204. hd2_scale_reg = WCD9335_CDC_RX2_RX_PATH_SEC3;
  4205. hd2_enable_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4206. }
  4207. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) {
  4208. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x10);
  4209. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x01);
  4210. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04);
  4211. }
  4212. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
  4213. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00);
  4214. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x00);
  4215. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00);
  4216. }
  4217. }
  4218. static int tasha_codec_enable_prim_interpolator(
  4219. struct snd_soc_codec *codec,
  4220. u16 reg, int event)
  4221. {
  4222. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4223. u16 prim_int_reg;
  4224. u16 ind = 0;
  4225. prim_int_reg = tasha_interp_get_primary_reg(reg, &ind);
  4226. switch (event) {
  4227. case SND_SOC_DAPM_PRE_PMU:
  4228. tasha->prim_int_users[ind]++;
  4229. if (tasha->prim_int_users[ind] == 1) {
  4230. snd_soc_update_bits(codec, prim_int_reg,
  4231. 0x10, 0x10);
  4232. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4233. snd_soc_update_bits(codec, prim_int_reg,
  4234. 1 << 0x5, 1 << 0x5);
  4235. }
  4236. if ((reg != prim_int_reg) &&
  4237. ((snd_soc_read(codec, prim_int_reg)) & 0x10))
  4238. snd_soc_update_bits(codec, reg, 0x10, 0x10);
  4239. break;
  4240. case SND_SOC_DAPM_POST_PMD:
  4241. tasha->prim_int_users[ind]--;
  4242. if (tasha->prim_int_users[ind] == 0) {
  4243. snd_soc_update_bits(codec, prim_int_reg,
  4244. 1 << 0x5, 0 << 0x5);
  4245. snd_soc_update_bits(codec, prim_int_reg,
  4246. 0x40, 0x40);
  4247. snd_soc_update_bits(codec, prim_int_reg,
  4248. 0x40, 0x00);
  4249. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4250. }
  4251. break;
  4252. };
  4253. dev_dbg(codec->dev, "%s: primary interpolator: INT%d, users: %d\n",
  4254. __func__, ind, tasha->prim_int_users[ind]);
  4255. return 0;
  4256. }
  4257. static int tasha_codec_enable_spline_src(struct snd_soc_codec *codec,
  4258. int src_num,
  4259. int event)
  4260. {
  4261. u16 src_paired_reg = 0;
  4262. struct tasha_priv *tasha;
  4263. u16 rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4264. u16 rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4265. int *src_users, count, spl_src = SPLINE_SRC0;
  4266. u16 src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4267. tasha = snd_soc_codec_get_drvdata(codec);
  4268. switch (src_num) {
  4269. case SRC_IN_HPHL:
  4270. rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4271. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4272. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4273. rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4274. spl_src = SPLINE_SRC0;
  4275. break;
  4276. case SRC_IN_LO1:
  4277. rx_path_cfg_reg = WCD9335_CDC_RX3_RX_PATH_CFG0;
  4278. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4279. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4280. rx_path_ctl_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4281. spl_src = SPLINE_SRC0;
  4282. break;
  4283. case SRC_IN_HPHR:
  4284. rx_path_cfg_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4285. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4286. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4287. rx_path_ctl_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4288. spl_src = SPLINE_SRC1;
  4289. break;
  4290. case SRC_IN_LO2:
  4291. rx_path_cfg_reg = WCD9335_CDC_RX4_RX_PATH_CFG0;
  4292. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4293. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4294. rx_path_ctl_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4295. spl_src = SPLINE_SRC1;
  4296. break;
  4297. case SRC_IN_SPKRL:
  4298. rx_path_cfg_reg = WCD9335_CDC_RX7_RX_PATH_CFG0;
  4299. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4300. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4301. rx_path_ctl_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4302. spl_src = SPLINE_SRC2;
  4303. break;
  4304. case SRC_IN_LO3:
  4305. rx_path_cfg_reg = WCD9335_CDC_RX5_RX_PATH_CFG0;
  4306. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4307. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4308. rx_path_ctl_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4309. spl_src = SPLINE_SRC2;
  4310. break;
  4311. case SRC_IN_SPKRR:
  4312. rx_path_cfg_reg = WCD9335_CDC_RX8_RX_PATH_CFG0;
  4313. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4314. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4315. rx_path_ctl_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4316. spl_src = SPLINE_SRC3;
  4317. break;
  4318. case SRC_IN_LO4:
  4319. rx_path_cfg_reg = WCD9335_CDC_RX6_RX_PATH_CFG0;
  4320. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4321. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4322. rx_path_ctl_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4323. spl_src = SPLINE_SRC3;
  4324. break;
  4325. };
  4326. src_users = &tasha->spl_src_users[spl_src];
  4327. switch (event) {
  4328. case SND_SOC_DAPM_PRE_PMU:
  4329. count = *src_users;
  4330. count++;
  4331. if (count == 1) {
  4332. if ((snd_soc_read(codec, src_clk_reg) & 0x02) ||
  4333. (snd_soc_read(codec, src_paired_reg) & 0x02)) {
  4334. snd_soc_update_bits(codec, src_clk_reg, 0x02,
  4335. 0x00);
  4336. snd_soc_update_bits(codec, src_paired_reg,
  4337. 0x02, 0x00);
  4338. }
  4339. snd_soc_update_bits(codec, src_clk_reg, 0x01, 0x01);
  4340. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4341. 0x80);
  4342. }
  4343. *src_users = count;
  4344. break;
  4345. case SND_SOC_DAPM_POST_PMD:
  4346. count = *src_users;
  4347. count--;
  4348. if (count == 0) {
  4349. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4350. 0x00);
  4351. snd_soc_update_bits(codec, src_clk_reg, 0x03, 0x02);
  4352. /* default sample rate */
  4353. snd_soc_update_bits(codec, rx_path_ctl_reg, 0x0f,
  4354. 0x04);
  4355. }
  4356. *src_users = count;
  4357. break;
  4358. };
  4359. dev_dbg(codec->dev, "%s: Spline SRC%d, users: %d\n",
  4360. __func__, spl_src, *src_users);
  4361. return 0;
  4362. }
  4363. static int tasha_codec_enable_spline_resampler(struct snd_soc_dapm_widget *w,
  4364. struct snd_kcontrol *kcontrol,
  4365. int event)
  4366. {
  4367. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4368. int ret = 0;
  4369. u8 src_in;
  4370. src_in = snd_soc_read(codec, WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0);
  4371. if (!(src_in & 0xFF)) {
  4372. dev_err(codec->dev, "%s: Spline SRC%u input not selected\n",
  4373. __func__, w->shift);
  4374. return -EINVAL;
  4375. }
  4376. switch (w->shift) {
  4377. case SPLINE_SRC0:
  4378. ret = tasha_codec_enable_spline_src(codec,
  4379. ((src_in & 0x03) == 1) ? SRC_IN_HPHL : SRC_IN_LO1,
  4380. event);
  4381. break;
  4382. case SPLINE_SRC1:
  4383. ret = tasha_codec_enable_spline_src(codec,
  4384. ((src_in & 0x0C) == 4) ? SRC_IN_HPHR : SRC_IN_LO2,
  4385. event);
  4386. break;
  4387. case SPLINE_SRC2:
  4388. ret = tasha_codec_enable_spline_src(codec,
  4389. ((src_in & 0x30) == 0x10) ? SRC_IN_LO3 : SRC_IN_SPKRL,
  4390. event);
  4391. break;
  4392. case SPLINE_SRC3:
  4393. ret = tasha_codec_enable_spline_src(codec,
  4394. ((src_in & 0xC0) == 0x40) ? SRC_IN_LO4 : SRC_IN_SPKRR,
  4395. event);
  4396. break;
  4397. default:
  4398. dev_err(codec->dev, "%s: Invalid spline src:%u\n", __func__,
  4399. w->shift);
  4400. ret = -EINVAL;
  4401. };
  4402. return ret;
  4403. }
  4404. static int tasha_codec_enable_swr(struct snd_soc_dapm_widget *w,
  4405. struct snd_kcontrol *kcontrol, int event)
  4406. {
  4407. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4408. struct tasha_priv *tasha;
  4409. int i, ch_cnt;
  4410. tasha = snd_soc_codec_get_drvdata(codec);
  4411. if (!tasha->nr)
  4412. return 0;
  4413. switch (event) {
  4414. case SND_SOC_DAPM_PRE_PMU:
  4415. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4416. !tasha->rx_7_count)
  4417. tasha->rx_7_count++;
  4418. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4419. !tasha->rx_8_count)
  4420. tasha->rx_8_count++;
  4421. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4422. for (i = 0; i < tasha->nr; i++) {
  4423. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4424. SWR_DEVICE_UP, NULL);
  4425. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4426. SWR_SET_NUM_RX_CH, &ch_cnt);
  4427. }
  4428. break;
  4429. case SND_SOC_DAPM_POST_PMD:
  4430. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4431. tasha->rx_7_count)
  4432. tasha->rx_7_count--;
  4433. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4434. tasha->rx_8_count)
  4435. tasha->rx_8_count--;
  4436. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4437. for (i = 0; i < tasha->nr; i++)
  4438. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4439. SWR_SET_NUM_RX_CH, &ch_cnt);
  4440. break;
  4441. }
  4442. dev_dbg(tasha->dev, "%s: current swr ch cnt: %d\n",
  4443. __func__, tasha->rx_7_count + tasha->rx_8_count);
  4444. return 0;
  4445. }
  4446. static int tasha_codec_config_ear_spkr_gain(struct snd_soc_codec *codec,
  4447. int event, int gain_reg)
  4448. {
  4449. int comp_gain_offset, val;
  4450. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4451. switch (tasha->spkr_mode) {
  4452. /* Compander gain in SPKR_MODE1 case is 12 dB */
  4453. case SPKR_MODE_1:
  4454. comp_gain_offset = -12;
  4455. break;
  4456. /* Default case compander gain is 15 dB */
  4457. default:
  4458. comp_gain_offset = -15;
  4459. break;
  4460. }
  4461. switch (event) {
  4462. case SND_SOC_DAPM_POST_PMU:
  4463. /* Apply ear spkr gain only if compander is enabled */
  4464. if (tasha->comp_enabled[COMPANDER_7] &&
  4465. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4466. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4467. (tasha->ear_spkr_gain != 0)) {
  4468. /* For example, val is -8(-12+5-1) for 4dB of gain */
  4469. val = comp_gain_offset + tasha->ear_spkr_gain - 1;
  4470. snd_soc_write(codec, gain_reg, val);
  4471. dev_dbg(codec->dev, "%s: RX7 Volume %d dB\n",
  4472. __func__, val);
  4473. }
  4474. break;
  4475. case SND_SOC_DAPM_POST_PMD:
  4476. /*
  4477. * Reset RX7 volume to 0 dB if compander is enabled and
  4478. * ear_spkr_gain is non-zero.
  4479. */
  4480. if (tasha->comp_enabled[COMPANDER_7] &&
  4481. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4482. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4483. (tasha->ear_spkr_gain != 0)) {
  4484. snd_soc_write(codec, gain_reg, 0x0);
  4485. dev_dbg(codec->dev, "%s: Reset RX7 Volume to 0 dB\n",
  4486. __func__);
  4487. }
  4488. break;
  4489. }
  4490. return 0;
  4491. }
  4492. static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w,
  4493. struct snd_kcontrol *kcontrol, int event)
  4494. {
  4495. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4496. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4497. u16 gain_reg;
  4498. int offset_val = 0;
  4499. int val = 0;
  4500. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4501. switch (w->reg) {
  4502. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4503. gain_reg = WCD9335_CDC_RX0_RX_VOL_MIX_CTL;
  4504. break;
  4505. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4506. gain_reg = WCD9335_CDC_RX1_RX_VOL_MIX_CTL;
  4507. break;
  4508. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4509. gain_reg = WCD9335_CDC_RX2_RX_VOL_MIX_CTL;
  4510. break;
  4511. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4512. gain_reg = WCD9335_CDC_RX3_RX_VOL_MIX_CTL;
  4513. break;
  4514. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4515. gain_reg = WCD9335_CDC_RX4_RX_VOL_MIX_CTL;
  4516. break;
  4517. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4518. gain_reg = WCD9335_CDC_RX5_RX_VOL_MIX_CTL;
  4519. break;
  4520. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4521. gain_reg = WCD9335_CDC_RX6_RX_VOL_MIX_CTL;
  4522. break;
  4523. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4524. gain_reg = WCD9335_CDC_RX7_RX_VOL_MIX_CTL;
  4525. break;
  4526. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4527. gain_reg = WCD9335_CDC_RX8_RX_VOL_MIX_CTL;
  4528. break;
  4529. default:
  4530. dev_err(codec->dev, "%s: No gain register avail for %s\n",
  4531. __func__, w->name);
  4532. return 0;
  4533. };
  4534. switch (event) {
  4535. case SND_SOC_DAPM_POST_PMU:
  4536. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4537. (tasha->comp_enabled[COMPANDER_7] ||
  4538. tasha->comp_enabled[COMPANDER_8]) &&
  4539. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4540. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4541. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4542. 0x01, 0x01);
  4543. snd_soc_update_bits(codec,
  4544. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4545. 0x01, 0x01);
  4546. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4547. 0x01, 0x01);
  4548. snd_soc_update_bits(codec,
  4549. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4550. 0x01, 0x01);
  4551. offset_val = -2;
  4552. }
  4553. val = snd_soc_read(codec, gain_reg);
  4554. val += offset_val;
  4555. snd_soc_write(codec, gain_reg, val);
  4556. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4557. break;
  4558. case SND_SOC_DAPM_POST_PMD:
  4559. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4560. (tasha->comp_enabled[COMPANDER_7] ||
  4561. tasha->comp_enabled[COMPANDER_8]) &&
  4562. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4563. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4564. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4565. 0x01, 0x00);
  4566. snd_soc_update_bits(codec,
  4567. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4568. 0x01, 0x00);
  4569. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4570. 0x01, 0x00);
  4571. snd_soc_update_bits(codec,
  4572. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4573. 0x01, 0x00);
  4574. offset_val = 2;
  4575. val = snd_soc_read(codec, gain_reg);
  4576. val += offset_val;
  4577. snd_soc_write(codec, gain_reg, val);
  4578. }
  4579. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4580. break;
  4581. };
  4582. return 0;
  4583. }
  4584. static int __tasha_cdc_native_clk_enable(struct tasha_priv *tasha,
  4585. bool enable)
  4586. {
  4587. int ret = 0;
  4588. struct snd_soc_codec *codec = tasha->codec;
  4589. if (!tasha->wcd_native_clk) {
  4590. dev_err(tasha->dev, "%s: wcd native clock is NULL\n", __func__);
  4591. return -EINVAL;
  4592. }
  4593. dev_dbg(tasha->dev, "%s: native_clk_enable = %u\n", __func__, enable);
  4594. if (enable) {
  4595. ret = clk_prepare_enable(tasha->wcd_native_clk);
  4596. if (ret) {
  4597. dev_err(tasha->dev, "%s: native clk enable failed\n",
  4598. __func__);
  4599. goto err;
  4600. }
  4601. if (++tasha->native_clk_users == 1) {
  4602. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4603. 0x10, 0x10);
  4604. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4605. 0x80, 0x80);
  4606. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4607. 0x04, 0x00);
  4608. snd_soc_update_bits(codec,
  4609. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4610. 0x02, 0x02);
  4611. }
  4612. } else {
  4613. if (tasha->native_clk_users &&
  4614. (--tasha->native_clk_users == 0)) {
  4615. snd_soc_update_bits(codec,
  4616. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4617. 0x02, 0x00);
  4618. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4619. 0x04, 0x04);
  4620. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4621. 0x80, 0x00);
  4622. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4623. 0x10, 0x00);
  4624. }
  4625. clk_disable_unprepare(tasha->wcd_native_clk);
  4626. }
  4627. dev_dbg(codec->dev, "%s: native_clk_users: %d\n", __func__,
  4628. tasha->native_clk_users);
  4629. err:
  4630. return ret;
  4631. }
  4632. static int tasha_codec_get_native_fifo_sync_mask(struct snd_soc_codec *codec,
  4633. int interp_n)
  4634. {
  4635. int mask = 0;
  4636. u16 reg;
  4637. u8 val1, val2, inp0 = 0;
  4638. u8 inp1 = 0, inp2 = 0;
  4639. reg = WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0 + (2 * interp_n) - 2;
  4640. val1 = snd_soc_read(codec, reg);
  4641. val2 = snd_soc_read(codec, reg + 1);
  4642. inp0 = val1 & 0x0F;
  4643. inp1 = (val1 >> 4) & 0x0F;
  4644. inp2 = (val2 >> 4) & 0x0F;
  4645. if (IS_VALID_NATIVE_FIFO_PORT(inp0))
  4646. mask |= (1 << (inp0 - 5));
  4647. if (IS_VALID_NATIVE_FIFO_PORT(inp1))
  4648. mask |= (1 << (inp1 - 5));
  4649. if (IS_VALID_NATIVE_FIFO_PORT(inp2))
  4650. mask |= (1 << (inp2 - 5));
  4651. dev_dbg(codec->dev, "%s: native fifo mask: 0x%x\n", __func__, mask);
  4652. if (!mask)
  4653. dev_err(codec->dev, "native fifo err,int:%d,inp0:%d,inp1:%d,inp2:%d\n",
  4654. interp_n, inp0, inp1, inp2);
  4655. return mask;
  4656. }
  4657. static int tasha_enable_native_supply(struct snd_soc_dapm_widget *w,
  4658. struct snd_kcontrol *kcontrol, int event)
  4659. {
  4660. int mask;
  4661. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4662. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4663. u16 interp_reg;
  4664. dev_dbg(codec->dev, "%s: event: %d, shift:%d\n", __func__, event,
  4665. w->shift);
  4666. if (w->shift < INTERP_HPHL || w->shift > INTERP_LO2)
  4667. return -EINVAL;
  4668. interp_reg = WCD9335_CDC_RX1_RX_PATH_CTL + 20 * (w->shift - 1);
  4669. mask = tasha_codec_get_native_fifo_sync_mask(codec, w->shift);
  4670. if (!mask)
  4671. return -EINVAL;
  4672. switch (event) {
  4673. case SND_SOC_DAPM_PRE_PMU:
  4674. /* Adjust interpolator rate to 44P1_NATIVE */
  4675. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x09);
  4676. __tasha_cdc_native_clk_enable(tasha, true);
  4677. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4678. mask, mask);
  4679. break;
  4680. case SND_SOC_DAPM_PRE_PMD:
  4681. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4682. mask, 0x0);
  4683. __tasha_cdc_native_clk_enable(tasha, false);
  4684. /* Adjust interpolator rate to default */
  4685. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x04);
  4686. break;
  4687. }
  4688. return 0;
  4689. }
  4690. static int tasha_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
  4691. struct snd_kcontrol *kcontrol, int event)
  4692. {
  4693. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4694. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4695. u16 gain_reg;
  4696. u16 reg;
  4697. int val;
  4698. int offset_val = 0;
  4699. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4700. if (!(strcmp(w->name, "RX INT0 INTERP"))) {
  4701. reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4702. gain_reg = WCD9335_CDC_RX0_RX_VOL_CTL;
  4703. } else if (!(strcmp(w->name, "RX INT1 INTERP"))) {
  4704. reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4705. gain_reg = WCD9335_CDC_RX1_RX_VOL_CTL;
  4706. } else if (!(strcmp(w->name, "RX INT2 INTERP"))) {
  4707. reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4708. gain_reg = WCD9335_CDC_RX2_RX_VOL_CTL;
  4709. } else if (!(strcmp(w->name, "RX INT3 INTERP"))) {
  4710. reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4711. gain_reg = WCD9335_CDC_RX3_RX_VOL_CTL;
  4712. } else if (!(strcmp(w->name, "RX INT4 INTERP"))) {
  4713. reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4714. gain_reg = WCD9335_CDC_RX4_RX_VOL_CTL;
  4715. } else if (!(strcmp(w->name, "RX INT5 INTERP"))) {
  4716. reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4717. gain_reg = WCD9335_CDC_RX5_RX_VOL_CTL;
  4718. } else if (!(strcmp(w->name, "RX INT6 INTERP"))) {
  4719. reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4720. gain_reg = WCD9335_CDC_RX6_RX_VOL_CTL;
  4721. } else if (!(strcmp(w->name, "RX INT7 INTERP"))) {
  4722. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4723. gain_reg = WCD9335_CDC_RX7_RX_VOL_CTL;
  4724. } else if (!(strcmp(w->name, "RX INT8 INTERP"))) {
  4725. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4726. gain_reg = WCD9335_CDC_RX8_RX_VOL_CTL;
  4727. } else {
  4728. dev_err(codec->dev, "%s: Interpolator reg not found\n",
  4729. __func__);
  4730. return -EINVAL;
  4731. }
  4732. switch (event) {
  4733. case SND_SOC_DAPM_PRE_PMU:
  4734. tasha_codec_vote_max_bw(codec, true);
  4735. /* Reset if needed */
  4736. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4737. break;
  4738. case SND_SOC_DAPM_POST_PMU:
  4739. tasha_config_compander(codec, w->shift, event);
  4740. /* apply gain after int clk is enabled */
  4741. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4742. (tasha->comp_enabled[COMPANDER_7] ||
  4743. tasha->comp_enabled[COMPANDER_8]) &&
  4744. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4745. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4746. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4747. 0x01, 0x01);
  4748. snd_soc_update_bits(codec,
  4749. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4750. 0x01, 0x01);
  4751. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4752. 0x01, 0x01);
  4753. snd_soc_update_bits(codec,
  4754. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4755. 0x01, 0x01);
  4756. offset_val = -2;
  4757. }
  4758. val = snd_soc_read(codec, gain_reg);
  4759. val += offset_val;
  4760. snd_soc_write(codec, gain_reg, val);
  4761. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4762. break;
  4763. case SND_SOC_DAPM_POST_PMD:
  4764. tasha_config_compander(codec, w->shift, event);
  4765. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4766. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4767. (tasha->comp_enabled[COMPANDER_7] ||
  4768. tasha->comp_enabled[COMPANDER_8]) &&
  4769. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4770. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4771. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4772. 0x01, 0x00);
  4773. snd_soc_update_bits(codec,
  4774. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4775. 0x01, 0x00);
  4776. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4777. 0x01, 0x00);
  4778. snd_soc_update_bits(codec,
  4779. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4780. 0x01, 0x00);
  4781. offset_val = 2;
  4782. val = snd_soc_read(codec, gain_reg);
  4783. val += offset_val;
  4784. snd_soc_write(codec, gain_reg, val);
  4785. }
  4786. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4787. break;
  4788. };
  4789. return 0;
  4790. }
  4791. static int tasha_codec_set_iir_gain(struct snd_soc_dapm_widget *w,
  4792. struct snd_kcontrol *kcontrol, int event)
  4793. {
  4794. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4795. dev_dbg(codec->dev, "%s: event = %d\n", __func__, event);
  4796. switch (event) {
  4797. case SND_SOC_DAPM_POST_PMU: /* fall through */
  4798. case SND_SOC_DAPM_PRE_PMD:
  4799. if (strnstr(w->name, "IIR0", sizeof("IIR0"))) {
  4800. snd_soc_write(codec,
  4801. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL,
  4802. snd_soc_read(codec,
  4803. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL));
  4804. snd_soc_write(codec,
  4805. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL,
  4806. snd_soc_read(codec,
  4807. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL));
  4808. snd_soc_write(codec,
  4809. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL,
  4810. snd_soc_read(codec,
  4811. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL));
  4812. snd_soc_write(codec,
  4813. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL,
  4814. snd_soc_read(codec,
  4815. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL));
  4816. } else {
  4817. snd_soc_write(codec,
  4818. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL,
  4819. snd_soc_read(codec,
  4820. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL));
  4821. snd_soc_write(codec,
  4822. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL,
  4823. snd_soc_read(codec,
  4824. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL));
  4825. snd_soc_write(codec,
  4826. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL,
  4827. snd_soc_read(codec,
  4828. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL));
  4829. }
  4830. break;
  4831. }
  4832. return 0;
  4833. }
  4834. static int tasha_codec_enable_on_demand_supply(
  4835. struct snd_soc_dapm_widget *w,
  4836. struct snd_kcontrol *kcontrol, int event)
  4837. {
  4838. int ret = 0;
  4839. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4840. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4841. struct on_demand_supply *supply;
  4842. if (w->shift >= ON_DEMAND_SUPPLIES_MAX) {
  4843. dev_err(codec->dev, "%s: error index > MAX Demand supplies",
  4844. __func__);
  4845. ret = -EINVAL;
  4846. goto out;
  4847. }
  4848. dev_dbg(codec->dev, "%s: supply: %s event: %d\n",
  4849. __func__, on_demand_supply_name[w->shift], event);
  4850. supply = &tasha->on_demand_list[w->shift];
  4851. WARN_ONCE(!supply->supply, "%s isn't defined\n",
  4852. on_demand_supply_name[w->shift]);
  4853. if (!supply->supply) {
  4854. dev_err(codec->dev, "%s: err supply not present ond for %d",
  4855. __func__, w->shift);
  4856. goto out;
  4857. }
  4858. switch (event) {
  4859. case SND_SOC_DAPM_PRE_PMU:
  4860. ret = regulator_enable(supply->supply);
  4861. if (ret)
  4862. dev_err(codec->dev, "%s: Failed to enable %s\n",
  4863. __func__,
  4864. on_demand_supply_name[w->shift]);
  4865. break;
  4866. case SND_SOC_DAPM_POST_PMD:
  4867. ret = regulator_disable(supply->supply);
  4868. if (ret)
  4869. dev_err(codec->dev, "%s: Failed to disable %s\n",
  4870. __func__,
  4871. on_demand_supply_name[w->shift]);
  4872. break;
  4873. default:
  4874. break;
  4875. };
  4876. out:
  4877. return ret;
  4878. }
  4879. static int tasha_codec_find_amic_input(struct snd_soc_codec *codec,
  4880. int adc_mux_n)
  4881. {
  4882. u16 mask, shift, adc_mux_in_reg;
  4883. u16 amic_mux_sel_reg;
  4884. bool is_amic;
  4885. if (adc_mux_n < 0 || adc_mux_n > WCD9335_MAX_VALID_ADC_MUX ||
  4886. adc_mux_n == WCD9335_INVALID_ADC_MUX)
  4887. return 0;
  4888. /* Check whether adc mux input is AMIC or DMIC */
  4889. if (adc_mux_n < 4) {
  4890. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
  4891. 2 * adc_mux_n;
  4892. amic_mux_sel_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  4893. 2 * adc_mux_n;
  4894. mask = 0x03;
  4895. shift = 0;
  4896. } else {
  4897. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  4898. adc_mux_n - 4;
  4899. amic_mux_sel_reg = adc_mux_in_reg;
  4900. mask = 0xC0;
  4901. shift = 6;
  4902. }
  4903. is_amic = (((snd_soc_read(codec, adc_mux_in_reg) & mask) >> shift)
  4904. == 1);
  4905. if (!is_amic)
  4906. return 0;
  4907. return snd_soc_read(codec, amic_mux_sel_reg) & 0x07;
  4908. }
  4909. static void tasha_codec_set_tx_hold(struct snd_soc_codec *codec,
  4910. u16 amic_reg, bool set)
  4911. {
  4912. u8 mask = 0x20;
  4913. u8 val;
  4914. if (amic_reg == WCD9335_ANA_AMIC1 ||
  4915. amic_reg == WCD9335_ANA_AMIC3 ||
  4916. amic_reg == WCD9335_ANA_AMIC5)
  4917. mask = 0x40;
  4918. val = set ? mask : 0x00;
  4919. switch (amic_reg) {
  4920. case WCD9335_ANA_AMIC1:
  4921. case WCD9335_ANA_AMIC2:
  4922. snd_soc_update_bits(codec, WCD9335_ANA_AMIC2, mask, val);
  4923. break;
  4924. case WCD9335_ANA_AMIC3:
  4925. case WCD9335_ANA_AMIC4:
  4926. snd_soc_update_bits(codec, WCD9335_ANA_AMIC4, mask, val);
  4927. break;
  4928. case WCD9335_ANA_AMIC5:
  4929. case WCD9335_ANA_AMIC6:
  4930. snd_soc_update_bits(codec, WCD9335_ANA_AMIC6, mask, val);
  4931. break;
  4932. default:
  4933. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4934. __func__, amic_reg);
  4935. break;
  4936. }
  4937. }
  4938. static int tasha_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w,
  4939. struct snd_kcontrol *kcontrol, int event)
  4940. {
  4941. int adc_mux_n = w->shift;
  4942. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4943. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4944. int amic_n;
  4945. dev_dbg(codec->dev, "%s: event: %d\n", __func__, event);
  4946. switch (event) {
  4947. case SND_SOC_DAPM_POST_PMU:
  4948. amic_n = tasha_codec_find_amic_input(codec, adc_mux_n);
  4949. if (amic_n) {
  4950. /*
  4951. * Prevent ANC Rx pop by leaving Tx FE in HOLD
  4952. * state until PA is up. Track AMIC being used
  4953. * so we can release the HOLD later.
  4954. */
  4955. set_bit(ANC_MIC_AMIC1 + amic_n - 1,
  4956. &tasha->status_mask);
  4957. }
  4958. break;
  4959. default:
  4960. break;
  4961. }
  4962. return 0;
  4963. }
  4964. static u16 tasha_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic)
  4965. {
  4966. u16 pwr_level_reg = 0;
  4967. switch (amic) {
  4968. case 1:
  4969. case 2:
  4970. pwr_level_reg = WCD9335_ANA_AMIC1;
  4971. break;
  4972. case 3:
  4973. case 4:
  4974. pwr_level_reg = WCD9335_ANA_AMIC3;
  4975. break;
  4976. case 5:
  4977. case 6:
  4978. pwr_level_reg = WCD9335_ANA_AMIC5;
  4979. break;
  4980. default:
  4981. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4982. __func__, amic);
  4983. break;
  4984. }
  4985. return pwr_level_reg;
  4986. }
  4987. #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
  4988. #define CF_MIN_3DB_4HZ 0x0
  4989. #define CF_MIN_3DB_75HZ 0x1
  4990. #define CF_MIN_3DB_150HZ 0x2
  4991. static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work)
  4992. {
  4993. struct delayed_work *hpf_delayed_work;
  4994. struct hpf_work *hpf_work;
  4995. struct tasha_priv *tasha;
  4996. struct snd_soc_codec *codec;
  4997. u16 dec_cfg_reg, amic_reg;
  4998. u8 hpf_cut_off_freq;
  4999. int amic_n;
  5000. hpf_delayed_work = to_delayed_work(work);
  5001. hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
  5002. tasha = hpf_work->tasha;
  5003. codec = tasha->codec;
  5004. hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
  5005. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator;
  5006. dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
  5007. __func__, hpf_work->decimator, hpf_cut_off_freq);
  5008. amic_n = tasha_codec_find_amic_input(codec, hpf_work->decimator);
  5009. if (amic_n) {
  5010. amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1;
  5011. tasha_codec_set_tx_hold(codec, amic_reg, false);
  5012. }
  5013. tasha_codec_vote_max_bw(codec, true);
  5014. snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  5015. hpf_cut_off_freq << 5);
  5016. tasha_codec_vote_max_bw(codec, false);
  5017. }
  5018. static void tasha_tx_mute_update_callback(struct work_struct *work)
  5019. {
  5020. struct tx_mute_work *tx_mute_dwork;
  5021. struct tasha_priv *tasha;
  5022. struct delayed_work *delayed_work;
  5023. struct snd_soc_codec *codec;
  5024. u16 tx_vol_ctl_reg, hpf_gate_reg;
  5025. delayed_work = to_delayed_work(work);
  5026. tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
  5027. tasha = tx_mute_dwork->tasha;
  5028. codec = tasha->codec;
  5029. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  5030. 16 * tx_mute_dwork->decimator;
  5031. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 +
  5032. 16 * tx_mute_dwork->decimator;
  5033. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x01);
  5034. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5035. }
  5036. static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w,
  5037. struct snd_kcontrol *kcontrol, int event)
  5038. {
  5039. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5040. unsigned int decimator;
  5041. char *dec_adc_mux_name = NULL;
  5042. char *widget_name = NULL;
  5043. char *wname;
  5044. int ret = 0, amic_n;
  5045. u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
  5046. u16 tx_gain_ctl_reg;
  5047. char *dec;
  5048. u8 hpf_cut_off_freq;
  5049. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5050. dev_dbg(codec->dev, "%s %d\n", __func__, event);
  5051. widget_name = kstrndup(w->name, 15, GFP_KERNEL);
  5052. if (!widget_name)
  5053. return -ENOMEM;
  5054. wname = widget_name;
  5055. dec_adc_mux_name = strsep(&widget_name, " ");
  5056. if (!dec_adc_mux_name) {
  5057. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5058. __func__, w->name);
  5059. ret = -EINVAL;
  5060. goto out;
  5061. }
  5062. dec_adc_mux_name = widget_name;
  5063. dec = strpbrk(dec_adc_mux_name, "012345678");
  5064. if (!dec) {
  5065. dev_err(codec->dev, "%s: decimator index not found\n",
  5066. __func__);
  5067. ret = -EINVAL;
  5068. goto out;
  5069. }
  5070. ret = kstrtouint(dec, 10, &decimator);
  5071. if (ret < 0) {
  5072. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5073. __func__, wname);
  5074. ret = -EINVAL;
  5075. goto out;
  5076. }
  5077. dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__,
  5078. w->name, decimator);
  5079. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator;
  5080. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 + 16 * decimator;
  5081. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * decimator;
  5082. tx_gain_ctl_reg = WCD9335_CDC_TX0_TX_VOL_CTL + 16 * decimator;
  5083. switch (event) {
  5084. case SND_SOC_DAPM_PRE_PMU:
  5085. amic_n = tasha_codec_find_amic_input(codec, decimator);
  5086. if (amic_n)
  5087. pwr_level_reg = tasha_codec_get_amic_pwlvl_reg(codec,
  5088. amic_n);
  5089. if (pwr_level_reg) {
  5090. switch ((snd_soc_read(codec, pwr_level_reg) &
  5091. WCD9335_AMIC_PWR_LVL_MASK) >>
  5092. WCD9335_AMIC_PWR_LVL_SHIFT) {
  5093. case WCD9335_AMIC_PWR_LEVEL_LP:
  5094. snd_soc_update_bits(codec, dec_cfg_reg,
  5095. WCD9335_DEC_PWR_LVL_MASK,
  5096. WCD9335_DEC_PWR_LVL_LP);
  5097. break;
  5098. case WCD9335_AMIC_PWR_LEVEL_HP:
  5099. snd_soc_update_bits(codec, dec_cfg_reg,
  5100. WCD9335_DEC_PWR_LVL_MASK,
  5101. WCD9335_DEC_PWR_LVL_HP);
  5102. break;
  5103. case WCD9335_AMIC_PWR_LEVEL_DEFAULT:
  5104. default:
  5105. snd_soc_update_bits(codec, dec_cfg_reg,
  5106. WCD9335_DEC_PWR_LVL_MASK,
  5107. WCD9335_DEC_PWR_LVL_DF);
  5108. break;
  5109. }
  5110. }
  5111. hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) &
  5112. TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
  5113. tasha->tx_hpf_work[decimator].hpf_cut_off_freq =
  5114. hpf_cut_off_freq;
  5115. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
  5116. snd_soc_update_bits(codec, dec_cfg_reg,
  5117. TX_HPF_CUT_OFF_FREQ_MASK,
  5118. CF_MIN_3DB_150HZ << 5);
  5119. /* Enable TX PGA Mute */
  5120. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5121. break;
  5122. case SND_SOC_DAPM_POST_PMU:
  5123. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00);
  5124. if (decimator == 0) {
  5125. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5126. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0xA3);
  5127. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5128. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x03);
  5129. }
  5130. /* schedule work queue to Remove Mute */
  5131. schedule_delayed_work(&tasha->tx_mute_dwork[decimator].dwork,
  5132. msecs_to_jiffies(tx_unmute_delay));
  5133. if (tasha->tx_hpf_work[decimator].hpf_cut_off_freq !=
  5134. CF_MIN_3DB_150HZ)
  5135. schedule_delayed_work(
  5136. &tasha->tx_hpf_work[decimator].dwork,
  5137. msecs_to_jiffies(300));
  5138. /* apply gain after decimator is enabled */
  5139. snd_soc_write(codec, tx_gain_ctl_reg,
  5140. snd_soc_read(codec, tx_gain_ctl_reg));
  5141. break;
  5142. case SND_SOC_DAPM_PRE_PMD:
  5143. hpf_cut_off_freq =
  5144. tasha->tx_hpf_work[decimator].hpf_cut_off_freq;
  5145. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5146. if (cancel_delayed_work_sync(
  5147. &tasha->tx_hpf_work[decimator].dwork)) {
  5148. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  5149. tasha_codec_vote_max_bw(codec, true);
  5150. snd_soc_update_bits(codec, dec_cfg_reg,
  5151. TX_HPF_CUT_OFF_FREQ_MASK,
  5152. hpf_cut_off_freq << 5);
  5153. tasha_codec_vote_max_bw(codec, false);
  5154. }
  5155. }
  5156. cancel_delayed_work_sync(
  5157. &tasha->tx_mute_dwork[decimator].dwork);
  5158. break;
  5159. case SND_SOC_DAPM_POST_PMD:
  5160. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5161. break;
  5162. };
  5163. out:
  5164. kfree(wname);
  5165. return ret;
  5166. }
  5167. static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec,
  5168. unsigned int dmic, struct wcd9xxx_pdata *pdata)
  5169. {
  5170. u8 tx_stream_fs;
  5171. u8 adc_mux_index = 0, adc_mux_sel = 0;
  5172. bool dec_found = false;
  5173. u16 adc_mux_ctl_reg, tx_fs_reg;
  5174. u32 dmic_fs;
  5175. while (dec_found == 0 && adc_mux_index < WCD9335_MAX_VALID_ADC_MUX) {
  5176. if (adc_mux_index < 4) {
  5177. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  5178. (adc_mux_index * 2);
  5179. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5180. 0x78) >> 3) - 1;
  5181. } else if (adc_mux_index < 9) {
  5182. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  5183. ((adc_mux_index - 4) * 1);
  5184. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5185. 0x38) >> 3) - 1;
  5186. } else if (adc_mux_index == 9) {
  5187. ++adc_mux_index;
  5188. continue;
  5189. }
  5190. if (adc_mux_sel == dmic)
  5191. dec_found = true;
  5192. else
  5193. ++adc_mux_index;
  5194. }
  5195. if (dec_found == true && adc_mux_index <= 8) {
  5196. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index);
  5197. tx_stream_fs = snd_soc_read(codec, tx_fs_reg) & 0x0F;
  5198. dmic_fs = tx_stream_fs <= 4 ? WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ :
  5199. WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  5200. /*
  5201. * Check for ECPP path selection and DEC1 not connected to
  5202. * any other audio path to apply ECPP DMIC sample rate
  5203. */
  5204. if ((adc_mux_index == 1) &&
  5205. ((snd_soc_read(codec, WCD9335_CPE_SS_US_EC_MUX_CFG)
  5206. & 0x0F) == 0x0A) &&
  5207. ((snd_soc_read(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0)
  5208. & 0x0C) == 0x00)) {
  5209. dmic_fs = pdata->ecpp_dmic_sample_rate;
  5210. }
  5211. } else {
  5212. dmic_fs = pdata->dmic_sample_rate;
  5213. }
  5214. return dmic_fs;
  5215. }
  5216. static u8 tasha_get_dmic_clk_val(struct snd_soc_codec *codec,
  5217. u32 mclk_rate, u32 dmic_clk_rate)
  5218. {
  5219. u32 div_factor;
  5220. u8 dmic_ctl_val;
  5221. dev_dbg(codec->dev,
  5222. "%s: mclk_rate = %d, dmic_sample_rate = %d\n",
  5223. __func__, mclk_rate, dmic_clk_rate);
  5224. /* Default value to return in case of error */
  5225. if (mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  5226. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5227. else
  5228. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5229. if (dmic_clk_rate == 0) {
  5230. dev_err(codec->dev,
  5231. "%s: dmic_sample_rate cannot be 0\n",
  5232. __func__);
  5233. goto done;
  5234. }
  5235. div_factor = mclk_rate / dmic_clk_rate;
  5236. switch (div_factor) {
  5237. case 2:
  5238. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5239. break;
  5240. case 3:
  5241. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5242. break;
  5243. case 4:
  5244. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_4;
  5245. break;
  5246. case 6:
  5247. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_6;
  5248. break;
  5249. case 8:
  5250. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_8;
  5251. break;
  5252. case 16:
  5253. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_16;
  5254. break;
  5255. default:
  5256. dev_err(codec->dev,
  5257. "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n",
  5258. __func__, div_factor, mclk_rate, dmic_clk_rate);
  5259. break;
  5260. }
  5261. done:
  5262. return dmic_ctl_val;
  5263. }
  5264. static int tasha_codec_enable_adc(struct snd_soc_dapm_widget *w,
  5265. struct snd_kcontrol *kcontrol, int event)
  5266. {
  5267. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5268. dev_dbg(codec->dev, "%s: event:%d\n", __func__, event);
  5269. switch (event) {
  5270. case SND_SOC_DAPM_PRE_PMU:
  5271. tasha_codec_set_tx_hold(codec, w->reg, true);
  5272. break;
  5273. default:
  5274. break;
  5275. }
  5276. return 0;
  5277. }
  5278. static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w,
  5279. struct snd_kcontrol *kcontrol, int event)
  5280. {
  5281. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5282. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5283. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  5284. u8 dmic_clk_en = 0x01;
  5285. u16 dmic_clk_reg;
  5286. s32 *dmic_clk_cnt;
  5287. u8 dmic_rate_val, dmic_rate_shift = 1;
  5288. unsigned int dmic;
  5289. u32 dmic_sample_rate;
  5290. int ret;
  5291. char *wname;
  5292. wname = strpbrk(w->name, "012345");
  5293. if (!wname) {
  5294. dev_err(codec->dev, "%s: widget not found\n", __func__);
  5295. return -EINVAL;
  5296. }
  5297. ret = kstrtouint(wname, 10, &dmic);
  5298. if (ret < 0) {
  5299. dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n",
  5300. __func__);
  5301. return -EINVAL;
  5302. }
  5303. switch (dmic) {
  5304. case 0:
  5305. case 1:
  5306. dmic_clk_cnt = &(tasha->dmic_0_1_clk_cnt);
  5307. dmic_clk_reg = WCD9335_CPE_SS_DMIC0_CTL;
  5308. break;
  5309. case 2:
  5310. case 3:
  5311. dmic_clk_cnt = &(tasha->dmic_2_3_clk_cnt);
  5312. dmic_clk_reg = WCD9335_CPE_SS_DMIC1_CTL;
  5313. break;
  5314. case 4:
  5315. case 5:
  5316. dmic_clk_cnt = &(tasha->dmic_4_5_clk_cnt);
  5317. dmic_clk_reg = WCD9335_CPE_SS_DMIC2_CTL;
  5318. break;
  5319. default:
  5320. dev_err(codec->dev, "%s: Invalid DMIC Selection\n",
  5321. __func__);
  5322. return -EINVAL;
  5323. };
  5324. dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
  5325. __func__, event, dmic, *dmic_clk_cnt);
  5326. switch (event) {
  5327. case SND_SOC_DAPM_PRE_PMU:
  5328. dmic_sample_rate = tasha_get_dmic_sample_rate(codec, dmic,
  5329. pdata);
  5330. dmic_rate_val =
  5331. tasha_get_dmic_clk_val(codec,
  5332. pdata->mclk_rate,
  5333. dmic_sample_rate);
  5334. (*dmic_clk_cnt)++;
  5335. if (*dmic_clk_cnt == 1) {
  5336. snd_soc_update_bits(codec, dmic_clk_reg,
  5337. 0x07 << dmic_rate_shift,
  5338. dmic_rate_val << dmic_rate_shift);
  5339. snd_soc_update_bits(codec, dmic_clk_reg,
  5340. dmic_clk_en, dmic_clk_en);
  5341. }
  5342. break;
  5343. case SND_SOC_DAPM_POST_PMD:
  5344. dmic_rate_val =
  5345. tasha_get_dmic_clk_val(codec,
  5346. pdata->mclk_rate,
  5347. pdata->mad_dmic_sample_rate);
  5348. (*dmic_clk_cnt)--;
  5349. if (*dmic_clk_cnt == 0) {
  5350. snd_soc_update_bits(codec, dmic_clk_reg,
  5351. dmic_clk_en, 0);
  5352. snd_soc_update_bits(codec, dmic_clk_reg,
  5353. 0x07 << dmic_rate_shift,
  5354. dmic_rate_val << dmic_rate_shift);
  5355. }
  5356. break;
  5357. };
  5358. return 0;
  5359. }
  5360. static int __tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5361. int event)
  5362. {
  5363. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5364. int micb_num;
  5365. dev_dbg(codec->dev, "%s: wname: %s, event: %d\n",
  5366. __func__, w->name, event);
  5367. if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1")))
  5368. micb_num = MIC_BIAS_1;
  5369. else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2")))
  5370. micb_num = MIC_BIAS_2;
  5371. else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3")))
  5372. micb_num = MIC_BIAS_3;
  5373. else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4")))
  5374. micb_num = MIC_BIAS_4;
  5375. else
  5376. return -EINVAL;
  5377. switch (event) {
  5378. case SND_SOC_DAPM_PRE_PMU:
  5379. /*
  5380. * MIC BIAS can also be requested by MBHC,
  5381. * so use ref count to handle micbias pullup
  5382. * and enable requests
  5383. */
  5384. tasha_micbias_control(codec, micb_num, MICB_ENABLE, true);
  5385. break;
  5386. case SND_SOC_DAPM_POST_PMU:
  5387. /* wait for cnp time */
  5388. usleep_range(1000, 1100);
  5389. break;
  5390. case SND_SOC_DAPM_POST_PMD:
  5391. tasha_micbias_control(codec, micb_num, MICB_DISABLE, true);
  5392. break;
  5393. };
  5394. return 0;
  5395. }
  5396. static int tasha_codec_ldo_h_control(struct snd_soc_dapm_widget *w,
  5397. int event)
  5398. {
  5399. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5400. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5401. if (SND_SOC_DAPM_EVENT_ON(event)) {
  5402. tasha->ldo_h_users++;
  5403. if (tasha->ldo_h_users == 1)
  5404. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5405. 0x80, 0x80);
  5406. }
  5407. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  5408. tasha->ldo_h_users--;
  5409. if (tasha->ldo_h_users < 0)
  5410. tasha->ldo_h_users = 0;
  5411. if (tasha->ldo_h_users == 0)
  5412. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5413. 0x80, 0x00);
  5414. }
  5415. return 0;
  5416. }
  5417. static int tasha_codec_force_enable_ldo_h(struct snd_soc_dapm_widget *w,
  5418. struct snd_kcontrol *kcontrol,
  5419. int event)
  5420. {
  5421. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5422. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5423. switch (event) {
  5424. case SND_SOC_DAPM_PRE_PMU:
  5425. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5426. tasha_codec_ldo_h_control(w, event);
  5427. break;
  5428. case SND_SOC_DAPM_POST_PMD:
  5429. tasha_codec_ldo_h_control(w, event);
  5430. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5431. break;
  5432. }
  5433. return 0;
  5434. }
  5435. static int tasha_codec_force_enable_micbias(struct snd_soc_dapm_widget *w,
  5436. struct snd_kcontrol *kcontrol,
  5437. int event)
  5438. {
  5439. int ret = 0;
  5440. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5441. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5442. switch (event) {
  5443. case SND_SOC_DAPM_PRE_PMU:
  5444. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5445. tasha_cdc_mclk_enable(codec, true, true);
  5446. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_PRE_PMU);
  5447. /* Wait for 1ms for better cnp */
  5448. usleep_range(1000, 1100);
  5449. tasha_cdc_mclk_enable(codec, false, true);
  5450. break;
  5451. case SND_SOC_DAPM_POST_PMD:
  5452. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_POST_PMD);
  5453. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5454. break;
  5455. }
  5456. return ret;
  5457. }
  5458. static int tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5459. struct snd_kcontrol *kcontrol, int event)
  5460. {
  5461. return __tasha_codec_enable_micbias(w, event);
  5462. }
  5463. static int tasha_codec_enable_standalone_ldo_h(struct snd_soc_codec *codec,
  5464. bool enable)
  5465. {
  5466. int rc;
  5467. if (enable)
  5468. rc = snd_soc_dapm_force_enable_pin(
  5469. snd_soc_codec_get_dapm(codec),
  5470. DAPM_LDO_H_STANDALONE);
  5471. else
  5472. rc = snd_soc_dapm_disable_pin(
  5473. snd_soc_codec_get_dapm(codec),
  5474. DAPM_LDO_H_STANDALONE);
  5475. if (!rc)
  5476. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5477. else
  5478. dev_err(codec->dev, "%s: ldo_h force %s pin failed\n",
  5479. __func__, (enable ? "enable" : "disable"));
  5480. return rc;
  5481. }
  5482. /*
  5483. * tasha_codec_enable_standalone_micbias - enable micbias standalone
  5484. * @codec: pointer to codec instance
  5485. * @micb_num: number of micbias to be enabled
  5486. * @enable: true to enable micbias or false to disable
  5487. *
  5488. * This function is used to enable micbias (1, 2, 3 or 4) during
  5489. * standalone independent of whether TX use-case is running or not
  5490. *
  5491. * Return: error code in case of failure or 0 for success
  5492. */
  5493. int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
  5494. int micb_num,
  5495. bool enable)
  5496. {
  5497. const char * const micb_names[] = {
  5498. DAPM_MICBIAS1_STANDALONE, DAPM_MICBIAS2_STANDALONE,
  5499. DAPM_MICBIAS3_STANDALONE, DAPM_MICBIAS4_STANDALONE
  5500. };
  5501. int micb_index = micb_num - 1;
  5502. int rc;
  5503. if (!codec) {
  5504. pr_err("%s: Codec memory is NULL\n", __func__);
  5505. return -EINVAL;
  5506. }
  5507. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  5508. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  5509. __func__, micb_index);
  5510. return -EINVAL;
  5511. }
  5512. if (enable)
  5513. rc = snd_soc_dapm_force_enable_pin(
  5514. snd_soc_codec_get_dapm(codec),
  5515. micb_names[micb_index]);
  5516. else
  5517. rc = snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec),
  5518. micb_names[micb_index]);
  5519. if (!rc)
  5520. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5521. else
  5522. dev_err(codec->dev, "%s: micbias%d force %s pin failed\n",
  5523. __func__, micb_num, (enable ? "enable" : "disable"));
  5524. return rc;
  5525. }
  5526. EXPORT_SYMBOL(tasha_codec_enable_standalone_micbias);
  5527. static const char *const tasha_anc_func_text[] = {"OFF", "ON"};
  5528. static const struct soc_enum tasha_anc_func_enum =
  5529. SOC_ENUM_SINGLE_EXT(2, tasha_anc_func_text);
  5530. static const char *const tasha_clkmode_text[] = {"EXTERNAL", "INTERNAL"};
  5531. static SOC_ENUM_SINGLE_EXT_DECL(tasha_clkmode_enum, tasha_clkmode_text);
  5532. /* Cutoff frequency for high pass filter */
  5533. static const char * const cf_text[] = {
  5534. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
  5535. };
  5536. static const char * const rx_cf_text[] = {
  5537. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ",
  5538. "CF_NEG_3DB_0P48HZ"
  5539. };
  5540. static const struct soc_enum cf_dec0_enum =
  5541. SOC_ENUM_SINGLE(WCD9335_CDC_TX0_TX_PATH_CFG0, 5, 3, cf_text);
  5542. static const struct soc_enum cf_dec1_enum =
  5543. SOC_ENUM_SINGLE(WCD9335_CDC_TX1_TX_PATH_CFG0, 5, 3, cf_text);
  5544. static const struct soc_enum cf_dec2_enum =
  5545. SOC_ENUM_SINGLE(WCD9335_CDC_TX2_TX_PATH_CFG0, 5, 3, cf_text);
  5546. static const struct soc_enum cf_dec3_enum =
  5547. SOC_ENUM_SINGLE(WCD9335_CDC_TX3_TX_PATH_CFG0, 5, 3, cf_text);
  5548. static const struct soc_enum cf_dec4_enum =
  5549. SOC_ENUM_SINGLE(WCD9335_CDC_TX4_TX_PATH_CFG0, 5, 3, cf_text);
  5550. static const struct soc_enum cf_dec5_enum =
  5551. SOC_ENUM_SINGLE(WCD9335_CDC_TX5_TX_PATH_CFG0, 5, 3, cf_text);
  5552. static const struct soc_enum cf_dec6_enum =
  5553. SOC_ENUM_SINGLE(WCD9335_CDC_TX6_TX_PATH_CFG0, 5, 3, cf_text);
  5554. static const struct soc_enum cf_dec7_enum =
  5555. SOC_ENUM_SINGLE(WCD9335_CDC_TX7_TX_PATH_CFG0, 5, 3, cf_text);
  5556. static const struct soc_enum cf_dec8_enum =
  5557. SOC_ENUM_SINGLE(WCD9335_CDC_TX8_TX_PATH_CFG0, 5, 3, cf_text);
  5558. static const struct soc_enum cf_int0_1_enum =
  5559. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5560. static SOC_ENUM_SINGLE_DECL(cf_int0_2_enum, WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 2,
  5561. rx_cf_text);
  5562. static const struct soc_enum cf_int1_1_enum =
  5563. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5564. static SOC_ENUM_SINGLE_DECL(cf_int1_2_enum, WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 2,
  5565. rx_cf_text);
  5566. static const struct soc_enum cf_int2_1_enum =
  5567. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5568. static SOC_ENUM_SINGLE_DECL(cf_int2_2_enum, WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 2,
  5569. rx_cf_text);
  5570. static const struct soc_enum cf_int3_1_enum =
  5571. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5572. static SOC_ENUM_SINGLE_DECL(cf_int3_2_enum, WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 2,
  5573. rx_cf_text);
  5574. static const struct soc_enum cf_int4_1_enum =
  5575. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5576. static SOC_ENUM_SINGLE_DECL(cf_int4_2_enum, WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 2,
  5577. rx_cf_text);
  5578. static const struct soc_enum cf_int5_1_enum =
  5579. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5580. static SOC_ENUM_SINGLE_DECL(cf_int5_2_enum, WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 2,
  5581. rx_cf_text);
  5582. static const struct soc_enum cf_int6_1_enum =
  5583. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5584. static SOC_ENUM_SINGLE_DECL(cf_int6_2_enum, WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 2,
  5585. rx_cf_text);
  5586. static const struct soc_enum cf_int7_1_enum =
  5587. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5588. static SOC_ENUM_SINGLE_DECL(cf_int7_2_enum, WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 2,
  5589. rx_cf_text);
  5590. static const struct soc_enum cf_int8_1_enum =
  5591. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5592. static SOC_ENUM_SINGLE_DECL(cf_int8_2_enum, WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 2,
  5593. rx_cf_text);
  5594. static const struct snd_soc_dapm_route audio_i2s_map[] = {
  5595. {"SLIM RX0 MUX", NULL, "RX_I2S_CTL"},
  5596. {"SLIM RX1 MUX", NULL, "RX_I2S_CTL"},
  5597. {"SLIM RX2 MUX", NULL, "RX_I2S_CTL"},
  5598. {"SLIM RX3 MUX", NULL, "RX_I2S_CTL"},
  5599. {"SLIM TX6 MUX", NULL, "TX_I2S_CTL"},
  5600. {"SLIM TX7 MUX", NULL, "TX_I2S_CTL"},
  5601. {"SLIM TX8 MUX", NULL, "TX_I2S_CTL"},
  5602. {"SLIM TX11 MUX", NULL, "TX_I2S_CTL"},
  5603. };
  5604. static const struct snd_soc_dapm_route audio_map[] = {
  5605. /* MAD */
  5606. {"MAD_SEL MUX", "SPE", "MAD_CPE_INPUT"},
  5607. {"MAD_SEL MUX", "MSM", "MADINPUT"},
  5608. {"MADONOFF", "Switch", "MAD_SEL MUX"},
  5609. {"MAD_BROADCAST", "Switch", "MAD_SEL MUX"},
  5610. {"TX13 INP MUX", "CPE_TX_PP", "MADONOFF"},
  5611. /* CPE HW MAD bypass */
  5612. {"CPE IN Mixer", "MAD_BYPASS", "SLIM TX1 MUX"},
  5613. {"AIF4_MAD Mixer", "SLIM TX1", "CPE IN Mixer"},
  5614. {"AIF4_MAD Mixer", "SLIM TX12", "MADONOFF"},
  5615. {"AIF4_MAD Mixer", "SLIM TX13", "TX13 INP MUX"},
  5616. {"AIF4 MAD", NULL, "AIF4_MAD Mixer"},
  5617. {"AIF4 MAD", NULL, "AIF4"},
  5618. {"EC BUF MUX INP", "DEC1", "ADC MUX1"},
  5619. {"AIF5 CPE", NULL, "EC BUF MUX INP"},
  5620. /* SLIMBUS Connections */
  5621. {"AIF1 CAP", NULL, "AIF1_CAP Mixer"},
  5622. {"AIF2 CAP", NULL, "AIF2_CAP Mixer"},
  5623. {"AIF3 CAP", NULL, "AIF3_CAP Mixer"},
  5624. /* VI Feedback */
  5625. {"AIF4_VI Mixer", "SPKR_VI_1", "VIINPUT"},
  5626. {"AIF4_VI Mixer", "SPKR_VI_2", "VIINPUT"},
  5627. {"AIF4 VI", NULL, "AIF4_VI Mixer"},
  5628. /* SLIM_MIXER("AIF1_CAP Mixer"),*/
  5629. {"AIF1_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5630. {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5631. {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5632. {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5633. {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5634. {"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5635. {"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5636. {"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5637. {"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5638. {"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5639. {"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5640. {"AIF1_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5641. {"AIF1_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5642. /* SLIM_MIXER("AIF2_CAP Mixer"),*/
  5643. {"AIF2_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5644. {"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5645. {"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5646. {"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5647. {"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5648. {"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5649. {"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5650. {"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5651. {"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5652. {"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5653. {"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5654. {"AIF2_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5655. {"AIF2_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5656. /* SLIM_MIXER("AIF3_CAP Mixer"),*/
  5657. {"AIF3_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5658. {"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5659. {"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5660. {"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5661. {"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5662. {"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5663. {"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5664. {"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5665. {"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5666. {"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5667. {"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5668. {"AIF3_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5669. {"AIF3_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5670. {"SLIM TX0 MUX", "DEC0", "ADC MUX0"},
  5671. {"SLIM TX0 MUX", "RX_MIX_TX0", "RX MIX TX0 MUX"},
  5672. {"SLIM TX0 MUX", "DEC0_192", "ADC US MUX0"},
  5673. {"SLIM TX1 MUX", "DEC1", "ADC MUX1"},
  5674. {"SLIM TX1 MUX", "RX_MIX_TX1", "RX MIX TX1 MUX"},
  5675. {"SLIM TX1 MUX", "DEC1_192", "ADC US MUX1"},
  5676. {"SLIM TX2 MUX", "DEC2", "ADC MUX2"},
  5677. {"SLIM TX2 MUX", "RX_MIX_TX2", "RX MIX TX2 MUX"},
  5678. {"SLIM TX2 MUX", "DEC2_192", "ADC US MUX2"},
  5679. {"SLIM TX3 MUX", "DEC3", "ADC MUX3"},
  5680. {"SLIM TX3 MUX", "RX_MIX_TX3", "RX MIX TX3 MUX"},
  5681. {"SLIM TX3 MUX", "DEC3_192", "ADC US MUX3"},
  5682. {"SLIM TX4 MUX", "DEC4", "ADC MUX4"},
  5683. {"SLIM TX4 MUX", "RX_MIX_TX4", "RX MIX TX4 MUX"},
  5684. {"SLIM TX4 MUX", "DEC4_192", "ADC US MUX4"},
  5685. {"SLIM TX5 MUX", "DEC5", "ADC MUX5"},
  5686. {"SLIM TX5 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5687. {"SLIM TX5 MUX", "DEC5_192", "ADC US MUX5"},
  5688. {"SLIM TX6 MUX", "DEC6", "ADC MUX6"},
  5689. {"SLIM TX6 MUX", "RX_MIX_TX6", "RX MIX TX6 MUX"},
  5690. {"SLIM TX6 MUX", "DEC6_192", "ADC US MUX6"},
  5691. {"SLIM TX7 MUX", "DEC7", "ADC MUX7"},
  5692. {"SLIM TX7 MUX", "RX_MIX_TX7", "RX MIX TX7 MUX"},
  5693. {"SLIM TX7 MUX", "DEC7_192", "ADC US MUX7"},
  5694. {"SLIM TX8 MUX", "DEC8", "ADC MUX8"},
  5695. {"SLIM TX8 MUX", "RX_MIX_TX8", "RX MIX TX8 MUX"},
  5696. {"SLIM TX8 MUX", "DEC8_192", "ADC US MUX8"},
  5697. {"SLIM TX9 MUX", "DEC7", "ADC MUX7"},
  5698. {"SLIM TX9 MUX", "DEC7_192", "ADC US MUX7"},
  5699. {"SLIM TX10 MUX", "DEC6", "ADC MUX6"},
  5700. {"SLIM TX10 MUX", "DEC6_192", "ADC US MUX6"},
  5701. {"SLIM TX11 MUX", "DEC_0_5", "SLIM TX11 INP1 MUX"},
  5702. {"SLIM TX11 MUX", "DEC_9_12", "SLIM TX11 INP1 MUX"},
  5703. {"SLIM TX11 INP1 MUX", "DEC0", "ADC MUX0"},
  5704. {"SLIM TX11 INP1 MUX", "DEC1", "ADC MUX1"},
  5705. {"SLIM TX11 INP1 MUX", "DEC2", "ADC MUX2"},
  5706. {"SLIM TX11 INP1 MUX", "DEC3", "ADC MUX3"},
  5707. {"SLIM TX11 INP1 MUX", "DEC4", "ADC MUX4"},
  5708. {"SLIM TX11 INP1 MUX", "DEC5", "ADC MUX5"},
  5709. {"SLIM TX11 INP1 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5710. {"TX13 INP MUX", "MAD_BRDCST", "MAD_BROADCAST"},
  5711. {"TX13 INP MUX", "CDC_DEC_5", "SLIM TX13 MUX"},
  5712. {"SLIM TX13 MUX", "DEC5", "ADC MUX5"},
  5713. {"RX MIX TX0 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5714. {"RX MIX TX0 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5715. {"RX MIX TX0 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5716. {"RX MIX TX0 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5717. {"RX MIX TX0 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5718. {"RX MIX TX0 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5719. {"RX MIX TX0 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5720. {"RX MIX TX0 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5721. {"RX MIX TX0 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5722. {"RX MIX TX0 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5723. {"RX MIX TX0 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5724. {"RX MIX TX0 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5725. {"RX MIX TX0 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5726. {"RX MIX TX1 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5727. {"RX MIX TX1 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5728. {"RX MIX TX1 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5729. {"RX MIX TX1 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5730. {"RX MIX TX1 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5731. {"RX MIX TX1 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5732. {"RX MIX TX1 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5733. {"RX MIX TX1 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5734. {"RX MIX TX1 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5735. {"RX MIX TX1 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5736. {"RX MIX TX1 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5737. {"RX MIX TX1 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5738. {"RX MIX TX1 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5739. {"RX MIX TX2 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5740. {"RX MIX TX2 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5741. {"RX MIX TX2 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5742. {"RX MIX TX2 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5743. {"RX MIX TX2 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5744. {"RX MIX TX2 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5745. {"RX MIX TX2 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5746. {"RX MIX TX2 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5747. {"RX MIX TX2 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5748. {"RX MIX TX2 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5749. {"RX MIX TX2 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5750. {"RX MIX TX2 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5751. {"RX MIX TX2 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5752. {"RX MIX TX3 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5753. {"RX MIX TX3 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5754. {"RX MIX TX3 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5755. {"RX MIX TX3 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5756. {"RX MIX TX3 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5757. {"RX MIX TX3 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5758. {"RX MIX TX3 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5759. {"RX MIX TX3 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5760. {"RX MIX TX3 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5761. {"RX MIX TX3 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5762. {"RX MIX TX3 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5763. {"RX MIX TX3 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5764. {"RX MIX TX3 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5765. {"RX MIX TX4 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5766. {"RX MIX TX4 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5767. {"RX MIX TX4 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5768. {"RX MIX TX4 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5769. {"RX MIX TX4 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5770. {"RX MIX TX4 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5771. {"RX MIX TX4 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5772. {"RX MIX TX4 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5773. {"RX MIX TX4 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5774. {"RX MIX TX4 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5775. {"RX MIX TX4 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5776. {"RX MIX TX4 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5777. {"RX MIX TX4 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5778. {"RX MIX TX5 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5779. {"RX MIX TX5 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5780. {"RX MIX TX5 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5781. {"RX MIX TX5 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5782. {"RX MIX TX5 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5783. {"RX MIX TX5 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5784. {"RX MIX TX5 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5785. {"RX MIX TX5 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5786. {"RX MIX TX5 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5787. {"RX MIX TX5 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5788. {"RX MIX TX5 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5789. {"RX MIX TX5 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5790. {"RX MIX TX5 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5791. {"RX MIX TX6 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5792. {"RX MIX TX6 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5793. {"RX MIX TX6 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5794. {"RX MIX TX6 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5795. {"RX MIX TX6 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5796. {"RX MIX TX6 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5797. {"RX MIX TX6 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5798. {"RX MIX TX6 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5799. {"RX MIX TX6 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5800. {"RX MIX TX6 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5801. {"RX MIX TX6 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5802. {"RX MIX TX6 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5803. {"RX MIX TX6 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5804. {"RX MIX TX7 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5805. {"RX MIX TX7 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5806. {"RX MIX TX7 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5807. {"RX MIX TX7 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5808. {"RX MIX TX7 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5809. {"RX MIX TX7 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5810. {"RX MIX TX7 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5811. {"RX MIX TX7 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5812. {"RX MIX TX7 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5813. {"RX MIX TX7 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5814. {"RX MIX TX7 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5815. {"RX MIX TX7 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5816. {"RX MIX TX7 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5817. {"RX MIX TX8 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5818. {"RX MIX TX8 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5819. {"RX MIX TX8 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5820. {"RX MIX TX8 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5821. {"RX MIX TX8 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5822. {"RX MIX TX8 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5823. {"RX MIX TX8 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5824. {"RX MIX TX8 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5825. {"RX MIX TX8 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5826. {"RX MIX TX8 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5827. {"RX MIX TX8 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5828. {"RX MIX TX8 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5829. {"RX MIX TX8 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5830. {"ADC US MUX0", "US_Switch", "ADC MUX0"},
  5831. {"ADC US MUX1", "US_Switch", "ADC MUX1"},
  5832. {"ADC US MUX2", "US_Switch", "ADC MUX2"},
  5833. {"ADC US MUX3", "US_Switch", "ADC MUX3"},
  5834. {"ADC US MUX4", "US_Switch", "ADC MUX4"},
  5835. {"ADC US MUX5", "US_Switch", "ADC MUX5"},
  5836. {"ADC US MUX6", "US_Switch", "ADC MUX6"},
  5837. {"ADC US MUX7", "US_Switch", "ADC MUX7"},
  5838. {"ADC US MUX8", "US_Switch", "ADC MUX8"},
  5839. {"ADC MUX0", "DMIC", "DMIC MUX0"},
  5840. {"ADC MUX0", "AMIC", "AMIC MUX0"},
  5841. {"ADC MUX1", "DMIC", "DMIC MUX1"},
  5842. {"ADC MUX1", "AMIC", "AMIC MUX1"},
  5843. {"ADC MUX2", "DMIC", "DMIC MUX2"},
  5844. {"ADC MUX2", "AMIC", "AMIC MUX2"},
  5845. {"ADC MUX3", "DMIC", "DMIC MUX3"},
  5846. {"ADC MUX3", "AMIC", "AMIC MUX3"},
  5847. {"ADC MUX4", "DMIC", "DMIC MUX4"},
  5848. {"ADC MUX4", "AMIC", "AMIC MUX4"},
  5849. {"ADC MUX5", "DMIC", "DMIC MUX5"},
  5850. {"ADC MUX5", "AMIC", "AMIC MUX5"},
  5851. {"ADC MUX6", "DMIC", "DMIC MUX6"},
  5852. {"ADC MUX6", "AMIC", "AMIC MUX6"},
  5853. {"ADC MUX7", "DMIC", "DMIC MUX7"},
  5854. {"ADC MUX7", "AMIC", "AMIC MUX7"},
  5855. {"ADC MUX8", "DMIC", "DMIC MUX8"},
  5856. {"ADC MUX8", "AMIC", "AMIC MUX8"},
  5857. {"ADC MUX10", "DMIC", "DMIC MUX10"},
  5858. {"ADC MUX10", "AMIC", "AMIC MUX10"},
  5859. {"ADC MUX11", "DMIC", "DMIC MUX11"},
  5860. {"ADC MUX11", "AMIC", "AMIC MUX11"},
  5861. {"ADC MUX12", "DMIC", "DMIC MUX12"},
  5862. {"ADC MUX12", "AMIC", "AMIC MUX12"},
  5863. {"ADC MUX13", "DMIC", "DMIC MUX13"},
  5864. {"ADC MUX13", "AMIC", "AMIC MUX13"},
  5865. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX10"},
  5866. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX11"},
  5867. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX12"},
  5868. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX13"},
  5869. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX10"},
  5870. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX11"},
  5871. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX12"},
  5872. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX13"},
  5873. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX10"},
  5874. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX11"},
  5875. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX12"},
  5876. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX13"},
  5877. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX10"},
  5878. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX11"},
  5879. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX12"},
  5880. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX13"},
  5881. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX10"},
  5882. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX11"},
  5883. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX12"},
  5884. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX13"},
  5885. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX10"},
  5886. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX11"},
  5887. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX12"},
  5888. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX13"},
  5889. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX10"},
  5890. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX11"},
  5891. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX12"},
  5892. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX13"},
  5893. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX10"},
  5894. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX11"},
  5895. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX12"},
  5896. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX13"},
  5897. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX10"},
  5898. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX11"},
  5899. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX12"},
  5900. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX13"},
  5901. {"DMIC MUX0", "DMIC0", "DMIC0"},
  5902. {"DMIC MUX0", "DMIC1", "DMIC1"},
  5903. {"DMIC MUX0", "DMIC2", "DMIC2"},
  5904. {"DMIC MUX0", "DMIC3", "DMIC3"},
  5905. {"DMIC MUX0", "DMIC4", "DMIC4"},
  5906. {"DMIC MUX0", "DMIC5", "DMIC5"},
  5907. {"AMIC MUX0", "ADC1", "ADC1"},
  5908. {"AMIC MUX0", "ADC2", "ADC2"},
  5909. {"AMIC MUX0", "ADC3", "ADC3"},
  5910. {"AMIC MUX0", "ADC4", "ADC4"},
  5911. {"AMIC MUX0", "ADC5", "ADC5"},
  5912. {"AMIC MUX0", "ADC6", "ADC6"},
  5913. {"DMIC MUX1", "DMIC0", "DMIC0"},
  5914. {"DMIC MUX1", "DMIC1", "DMIC1"},
  5915. {"DMIC MUX1", "DMIC2", "DMIC2"},
  5916. {"DMIC MUX1", "DMIC3", "DMIC3"},
  5917. {"DMIC MUX1", "DMIC4", "DMIC4"},
  5918. {"DMIC MUX1", "DMIC5", "DMIC5"},
  5919. {"AMIC MUX1", "ADC1", "ADC1"},
  5920. {"AMIC MUX1", "ADC2", "ADC2"},
  5921. {"AMIC MUX1", "ADC3", "ADC3"},
  5922. {"AMIC MUX1", "ADC4", "ADC4"},
  5923. {"AMIC MUX1", "ADC5", "ADC5"},
  5924. {"AMIC MUX1", "ADC6", "ADC6"},
  5925. {"DMIC MUX2", "DMIC0", "DMIC0"},
  5926. {"DMIC MUX2", "DMIC1", "DMIC1"},
  5927. {"DMIC MUX2", "DMIC2", "DMIC2"},
  5928. {"DMIC MUX2", "DMIC3", "DMIC3"},
  5929. {"DMIC MUX2", "DMIC4", "DMIC4"},
  5930. {"DMIC MUX2", "DMIC5", "DMIC5"},
  5931. {"AMIC MUX2", "ADC1", "ADC1"},
  5932. {"AMIC MUX2", "ADC2", "ADC2"},
  5933. {"AMIC MUX2", "ADC3", "ADC3"},
  5934. {"AMIC MUX2", "ADC4", "ADC4"},
  5935. {"AMIC MUX2", "ADC5", "ADC5"},
  5936. {"AMIC MUX2", "ADC6", "ADC6"},
  5937. {"DMIC MUX3", "DMIC0", "DMIC0"},
  5938. {"DMIC MUX3", "DMIC1", "DMIC1"},
  5939. {"DMIC MUX3", "DMIC2", "DMIC2"},
  5940. {"DMIC MUX3", "DMIC3", "DMIC3"},
  5941. {"DMIC MUX3", "DMIC4", "DMIC4"},
  5942. {"DMIC MUX3", "DMIC5", "DMIC5"},
  5943. {"AMIC MUX3", "ADC1", "ADC1"},
  5944. {"AMIC MUX3", "ADC2", "ADC2"},
  5945. {"AMIC MUX3", "ADC3", "ADC3"},
  5946. {"AMIC MUX3", "ADC4", "ADC4"},
  5947. {"AMIC MUX3", "ADC5", "ADC5"},
  5948. {"AMIC MUX3", "ADC6", "ADC6"},
  5949. {"DMIC MUX4", "DMIC0", "DMIC0"},
  5950. {"DMIC MUX4", "DMIC1", "DMIC1"},
  5951. {"DMIC MUX4", "DMIC2", "DMIC2"},
  5952. {"DMIC MUX4", "DMIC3", "DMIC3"},
  5953. {"DMIC MUX4", "DMIC4", "DMIC4"},
  5954. {"DMIC MUX4", "DMIC5", "DMIC5"},
  5955. {"AMIC MUX4", "ADC1", "ADC1"},
  5956. {"AMIC MUX4", "ADC2", "ADC2"},
  5957. {"AMIC MUX4", "ADC3", "ADC3"},
  5958. {"AMIC MUX4", "ADC4", "ADC4"},
  5959. {"AMIC MUX4", "ADC5", "ADC5"},
  5960. {"AMIC MUX4", "ADC6", "ADC6"},
  5961. {"DMIC MUX5", "DMIC0", "DMIC0"},
  5962. {"DMIC MUX5", "DMIC1", "DMIC1"},
  5963. {"DMIC MUX5", "DMIC2", "DMIC2"},
  5964. {"DMIC MUX5", "DMIC3", "DMIC3"},
  5965. {"DMIC MUX5", "DMIC4", "DMIC4"},
  5966. {"DMIC MUX5", "DMIC5", "DMIC5"},
  5967. {"AMIC MUX5", "ADC1", "ADC1"},
  5968. {"AMIC MUX5", "ADC2", "ADC2"},
  5969. {"AMIC MUX5", "ADC3", "ADC3"},
  5970. {"AMIC MUX5", "ADC4", "ADC4"},
  5971. {"AMIC MUX5", "ADC5", "ADC5"},
  5972. {"AMIC MUX5", "ADC6", "ADC6"},
  5973. {"DMIC MUX6", "DMIC0", "DMIC0"},
  5974. {"DMIC MUX6", "DMIC1", "DMIC1"},
  5975. {"DMIC MUX6", "DMIC2", "DMIC2"},
  5976. {"DMIC MUX6", "DMIC3", "DMIC3"},
  5977. {"DMIC MUX6", "DMIC4", "DMIC4"},
  5978. {"DMIC MUX6", "DMIC5", "DMIC5"},
  5979. {"AMIC MUX6", "ADC1", "ADC1"},
  5980. {"AMIC MUX6", "ADC2", "ADC2"},
  5981. {"AMIC MUX6", "ADC3", "ADC3"},
  5982. {"AMIC MUX6", "ADC4", "ADC4"},
  5983. {"AMIC MUX6", "ADC5", "ADC5"},
  5984. {"AMIC MUX6", "ADC6", "ADC6"},
  5985. {"DMIC MUX7", "DMIC0", "DMIC0"},
  5986. {"DMIC MUX7", "DMIC1", "DMIC1"},
  5987. {"DMIC MUX7", "DMIC2", "DMIC2"},
  5988. {"DMIC MUX7", "DMIC3", "DMIC3"},
  5989. {"DMIC MUX7", "DMIC4", "DMIC4"},
  5990. {"DMIC MUX7", "DMIC5", "DMIC5"},
  5991. {"AMIC MUX7", "ADC1", "ADC1"},
  5992. {"AMIC MUX7", "ADC2", "ADC2"},
  5993. {"AMIC MUX7", "ADC3", "ADC3"},
  5994. {"AMIC MUX7", "ADC4", "ADC4"},
  5995. {"AMIC MUX7", "ADC5", "ADC5"},
  5996. {"AMIC MUX7", "ADC6", "ADC6"},
  5997. {"DMIC MUX8", "DMIC0", "DMIC0"},
  5998. {"DMIC MUX8", "DMIC1", "DMIC1"},
  5999. {"DMIC MUX8", "DMIC2", "DMIC2"},
  6000. {"DMIC MUX8", "DMIC3", "DMIC3"},
  6001. {"DMIC MUX8", "DMIC4", "DMIC4"},
  6002. {"DMIC MUX8", "DMIC5", "DMIC5"},
  6003. {"AMIC MUX8", "ADC1", "ADC1"},
  6004. {"AMIC MUX8", "ADC2", "ADC2"},
  6005. {"AMIC MUX8", "ADC3", "ADC3"},
  6006. {"AMIC MUX8", "ADC4", "ADC4"},
  6007. {"AMIC MUX8", "ADC5", "ADC5"},
  6008. {"AMIC MUX8", "ADC6", "ADC6"},
  6009. {"DMIC MUX10", "DMIC0", "DMIC0"},
  6010. {"DMIC MUX10", "DMIC1", "DMIC1"},
  6011. {"DMIC MUX10", "DMIC2", "DMIC2"},
  6012. {"DMIC MUX10", "DMIC3", "DMIC3"},
  6013. {"DMIC MUX10", "DMIC4", "DMIC4"},
  6014. {"DMIC MUX10", "DMIC5", "DMIC5"},
  6015. {"AMIC MUX10", "ADC1", "ADC1"},
  6016. {"AMIC MUX10", "ADC2", "ADC2"},
  6017. {"AMIC MUX10", "ADC3", "ADC3"},
  6018. {"AMIC MUX10", "ADC4", "ADC4"},
  6019. {"AMIC MUX10", "ADC5", "ADC5"},
  6020. {"AMIC MUX10", "ADC6", "ADC6"},
  6021. {"DMIC MUX11", "DMIC0", "DMIC0"},
  6022. {"DMIC MUX11", "DMIC1", "DMIC1"},
  6023. {"DMIC MUX11", "DMIC2", "DMIC2"},
  6024. {"DMIC MUX11", "DMIC3", "DMIC3"},
  6025. {"DMIC MUX11", "DMIC4", "DMIC4"},
  6026. {"DMIC MUX11", "DMIC5", "DMIC5"},
  6027. {"AMIC MUX11", "ADC1", "ADC1"},
  6028. {"AMIC MUX11", "ADC2", "ADC2"},
  6029. {"AMIC MUX11", "ADC3", "ADC3"},
  6030. {"AMIC MUX11", "ADC4", "ADC4"},
  6031. {"AMIC MUX11", "ADC5", "ADC5"},
  6032. {"AMIC MUX11", "ADC6", "ADC6"},
  6033. {"DMIC MUX12", "DMIC0", "DMIC0"},
  6034. {"DMIC MUX12", "DMIC1", "DMIC1"},
  6035. {"DMIC MUX12", "DMIC2", "DMIC2"},
  6036. {"DMIC MUX12", "DMIC3", "DMIC3"},
  6037. {"DMIC MUX12", "DMIC4", "DMIC4"},
  6038. {"DMIC MUX12", "DMIC5", "DMIC5"},
  6039. {"AMIC MUX12", "ADC1", "ADC1"},
  6040. {"AMIC MUX12", "ADC2", "ADC2"},
  6041. {"AMIC MUX12", "ADC3", "ADC3"},
  6042. {"AMIC MUX12", "ADC4", "ADC4"},
  6043. {"AMIC MUX12", "ADC5", "ADC5"},
  6044. {"AMIC MUX12", "ADC6", "ADC6"},
  6045. {"DMIC MUX13", "DMIC0", "DMIC0"},
  6046. {"DMIC MUX13", "DMIC1", "DMIC1"},
  6047. {"DMIC MUX13", "DMIC2", "DMIC2"},
  6048. {"DMIC MUX13", "DMIC3", "DMIC3"},
  6049. {"DMIC MUX13", "DMIC4", "DMIC4"},
  6050. {"DMIC MUX13", "DMIC5", "DMIC5"},
  6051. {"AMIC MUX13", "ADC1", "ADC1"},
  6052. {"AMIC MUX13", "ADC2", "ADC2"},
  6053. {"AMIC MUX13", "ADC3", "ADC3"},
  6054. {"AMIC MUX13", "ADC4", "ADC4"},
  6055. {"AMIC MUX13", "ADC5", "ADC5"},
  6056. {"AMIC MUX13", "ADC6", "ADC6"},
  6057. /* ADC Connections */
  6058. {"ADC1", NULL, "AMIC1"},
  6059. {"ADC2", NULL, "AMIC2"},
  6060. {"ADC3", NULL, "AMIC3"},
  6061. {"ADC4", NULL, "AMIC4"},
  6062. {"ADC5", NULL, "AMIC5"},
  6063. {"ADC6", NULL, "AMIC6"},
  6064. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP0"},
  6065. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP1"},
  6066. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP2"},
  6067. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP0"},
  6068. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP1"},
  6069. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP2"},
  6070. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP0"},
  6071. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP1"},
  6072. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP2"},
  6073. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP0"},
  6074. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP1"},
  6075. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP2"},
  6076. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP0"},
  6077. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP1"},
  6078. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP2"},
  6079. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP0"},
  6080. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP1"},
  6081. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP2"},
  6082. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP0"},
  6083. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP1"},
  6084. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP2"},
  6085. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP0"},
  6086. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP1"},
  6087. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP2"},
  6088. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP0"},
  6089. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP1"},
  6090. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP2"},
  6091. {"RX INT0 SEC MIX", NULL, "RX INT0_1 MIX1"},
  6092. {"RX INT0 MIX2", NULL, "RX INT0 SEC MIX"},
  6093. {"RX INT0 MIX2", NULL, "RX INT0 MIX2 INP"},
  6094. {"RX INT0 INTERP", NULL, "RX INT0 MIX2"},
  6095. {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 INTERP"},
  6096. {"RX INT0 DAC", NULL, "RX INT0 DEM MUX"},
  6097. {"RX INT0 DAC", NULL, "RX_BIAS"},
  6098. {"EAR PA", NULL, "RX INT0 DAC"},
  6099. {"EAR", NULL, "EAR PA"},
  6100. {"SPL SRC0 MUX", "SRC_IN_HPHL", "RX INT1_1 MIX1"},
  6101. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 MIX1"},
  6102. {"RX INT1 SPLINE MIX", "HPHL Switch", "SPL SRC0 MUX"},
  6103. {"RX INT1_1 NATIVE MUX", "ON", "RX INT1_1 MIX1"},
  6104. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 NATIVE MUX"},
  6105. {"RX INT1_1 NATIVE MUX", NULL, "RX INT1 NATIVE SUPPLY"},
  6106. {"RX INT1 SEC MIX", NULL, "RX INT1 SPLINE MIX"},
  6107. {"RX INT1 MIX2", NULL, "RX INT1 SEC MIX"},
  6108. {"RX INT1 MIX2", NULL, "RX INT1 MIX2 INP"},
  6109. {"RX INT1 INTERP", NULL, "RX INT1 MIX2"},
  6110. {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 INTERP"},
  6111. {"RX INT1 DAC", NULL, "RX INT1 DEM MUX"},
  6112. {"RX INT1 DAC", NULL, "RX_BIAS"},
  6113. {"HPHL PA", NULL, "RX INT1 DAC"},
  6114. {"HPHL", NULL, "HPHL PA"},
  6115. {"SPL SRC1 MUX", "SRC_IN_HPHR", "RX INT2_1 MIX1"},
  6116. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 MIX1"},
  6117. {"RX INT2 SPLINE MIX", "HPHR Switch", "SPL SRC1 MUX"},
  6118. {"RX INT2_1 NATIVE MUX", "ON", "RX INT2_1 MIX1"},
  6119. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 NATIVE MUX"},
  6120. {"RX INT2_1 NATIVE MUX", NULL, "RX INT2 NATIVE SUPPLY"},
  6121. {"RX INT2 SEC MIX", NULL, "RX INT2 SPLINE MIX"},
  6122. {"RX INT2 MIX2", NULL, "RX INT2 SEC MIX"},
  6123. {"RX INT2 MIX2", NULL, "RX INT2 MIX2 INP"},
  6124. {"RX INT2 INTERP", NULL, "RX INT2 MIX2"},
  6125. {"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 INTERP"},
  6126. {"RX INT2 DAC", NULL, "RX INT2 DEM MUX"},
  6127. {"RX INT2 DAC", NULL, "RX_BIAS"},
  6128. {"HPHR PA", NULL, "RX INT2 DAC"},
  6129. {"HPHR", NULL, "HPHR PA"},
  6130. {"SPL SRC0 MUX", "SRC_IN_LO1", "RX INT3_1 MIX1"},
  6131. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 MIX1"},
  6132. {"RX INT3 SPLINE MIX", "LO1 Switch", "SPL SRC0 MUX"},
  6133. {"RX INT3_1 NATIVE MUX", "ON", "RX INT3_1 MIX1"},
  6134. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 NATIVE MUX"},
  6135. {"RX INT3_1 NATIVE MUX", NULL, "RX INT3 NATIVE SUPPLY"},
  6136. {"RX INT3 SEC MIX", NULL, "RX INT3 SPLINE MIX"},
  6137. {"RX INT3 MIX2", NULL, "RX INT3 SEC MIX"},
  6138. {"RX INT3 MIX2", NULL, "RX INT3 MIX2 INP"},
  6139. {"RX INT3 INTERP", NULL, "RX INT3 MIX2"},
  6140. {"RX INT3 DAC", NULL, "RX INT3 INTERP"},
  6141. {"RX INT3 DAC", NULL, "RX_BIAS"},
  6142. {"LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6143. {"LINEOUT1", NULL, "LINEOUT1 PA"},
  6144. {"SPL SRC1 MUX", "SRC_IN_LO2", "RX INT4_1 MIX1"},
  6145. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 MIX1"},
  6146. {"RX INT4 SPLINE MIX", "LO2 Switch", "SPL SRC1 MUX"},
  6147. {"RX INT4_1 NATIVE MUX", "ON", "RX INT4_1 MIX1"},
  6148. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 NATIVE MUX"},
  6149. {"RX INT4_1 NATIVE MUX", NULL, "RX INT4 NATIVE SUPPLY"},
  6150. {"RX INT4 SEC MIX", NULL, "RX INT4 SPLINE MIX"},
  6151. {"RX INT4 MIX2", NULL, "RX INT4 SEC MIX"},
  6152. {"RX INT4 MIX2", NULL, "RX INT4 MIX2 INP"},
  6153. {"RX INT4 INTERP", NULL, "RX INT4 MIX2"},
  6154. {"RX INT4 DAC", NULL, "RX INT4 INTERP"},
  6155. {"RX INT4 DAC", NULL, "RX_BIAS"},
  6156. {"LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6157. {"LINEOUT2", NULL, "LINEOUT2 PA"},
  6158. {"SPL SRC2 MUX", "SRC_IN_LO3", "RX INT5_1 MIX1"},
  6159. {"RX INT5 SPLINE MIX", NULL, "RX INT5_1 MIX1"},
  6160. {"RX INT5 SPLINE MIX", "LO3 Switch", "SPL SRC2 MUX"},
  6161. {"RX INT5 SEC MIX", NULL, "RX INT5 SPLINE MIX"},
  6162. {"RX INT5 MIX2", NULL, "RX INT5 SEC MIX"},
  6163. {"RX INT5 INTERP", NULL, "RX INT5 MIX2"},
  6164. {"RX INT5 VBAT", "LO3 VBAT Enable", "RX INT5 INTERP"},
  6165. {"RX INT5 DAC", NULL, "RX INT5 VBAT"},
  6166. {"RX INT5 DAC", NULL, "RX INT5 INTERP"},
  6167. {"RX INT5 DAC", NULL, "RX_BIAS"},
  6168. {"LINEOUT3 PA", NULL, "RX INT5 DAC"},
  6169. {"LINEOUT3", NULL, "LINEOUT3 PA"},
  6170. {"SPL SRC3 MUX", "SRC_IN_LO4", "RX INT6_1 MIX1"},
  6171. {"RX INT6 SPLINE MIX", NULL, "RX INT6_1 MIX1"},
  6172. {"RX INT6 SPLINE MIX", "LO4 Switch", "SPL SRC3 MUX"},
  6173. {"RX INT6 SEC MIX", NULL, "RX INT6 SPLINE MIX"},
  6174. {"RX INT6 MIX2", NULL, "RX INT6 SEC MIX"},
  6175. {"RX INT6 INTERP", NULL, "RX INT6 MIX2"},
  6176. {"RX INT6 VBAT", "LO4 VBAT Enable", "RX INT6 INTERP"},
  6177. {"RX INT6 DAC", NULL, "RX INT6 VBAT"},
  6178. {"RX INT6 DAC", NULL, "RX INT6 INTERP"},
  6179. {"RX INT6 DAC", NULL, "RX_BIAS"},
  6180. {"LINEOUT4 PA", NULL, "RX INT6 DAC"},
  6181. {"LINEOUT4", NULL, "LINEOUT4 PA"},
  6182. {"SPL SRC2 MUX", "SRC_IN_SPKRL", "RX INT7_1 MIX1"},
  6183. {"RX INT7 SPLINE MIX", NULL, "RX INT7_1 MIX1"},
  6184. {"RX INT7 SPLINE MIX", "SPKRL Switch", "SPL SRC2 MUX"},
  6185. {"RX INT7 SEC MIX", NULL, "RX INT7 SPLINE MIX"},
  6186. {"RX INT7 MIX2", NULL, "RX INT7 SEC MIX"},
  6187. {"RX INT7 MIX2", NULL, "RX INT7 MIX2 INP"},
  6188. {"RX INT7 INTERP", NULL, "RX INT7 MIX2"},
  6189. {"RX INT7 VBAT", "SPKRL VBAT Enable", "RX INT7 INTERP"},
  6190. {"RX INT7 CHAIN", NULL, "RX INT7 VBAT"},
  6191. {"RX INT7 CHAIN", NULL, "RX INT7 INTERP"},
  6192. {"RX INT7 CHAIN", NULL, "RX_BIAS"},
  6193. {"SPK1 OUT", NULL, "RX INT7 CHAIN"},
  6194. {"ANC SPKR PA Enable", "Switch", "RX INT7 CHAIN"},
  6195. {"ANC SPK1 PA", NULL, "ANC SPKR PA Enable"},
  6196. {"SPK1 OUT", NULL, "ANC SPK1 PA"},
  6197. {"SPL SRC3 MUX", "SRC_IN_SPKRR", "RX INT8_1 MIX1"},
  6198. {"RX INT8 SPLINE MIX", NULL, "RX INT8_1 MIX1"},
  6199. {"RX INT8 SPLINE MIX", "SPKRR Switch", "SPL SRC3 MUX"},
  6200. {"RX INT8 SEC MIX", NULL, "RX INT8 SPLINE MIX"},
  6201. {"RX INT8 INTERP", NULL, "RX INT8 SEC MIX"},
  6202. {"RX INT8 VBAT", "SPKRR VBAT Enable", "RX INT8 INTERP"},
  6203. {"RX INT8 CHAIN", NULL, "RX INT8 VBAT"},
  6204. {"RX INT8 CHAIN", NULL, "RX INT8 INTERP"},
  6205. {"RX INT8 CHAIN", NULL, "RX_BIAS"},
  6206. {"SPK2 OUT", NULL, "RX INT8 CHAIN"},
  6207. {"ANC0 FB MUX", "ANC_IN_EAR", "RX INT0 MIX2"},
  6208. {"ANC0 FB MUX", "ANC_IN_HPHL", "RX INT1 MIX2"},
  6209. {"ANC0 FB MUX", "ANC_IN_LO1", "RX INT3 MIX2"},
  6210. {"ANC0 FB MUX", "ANC_IN_EAR_SPKR", "RX INT7 MIX2"},
  6211. {"ANC1 FB MUX", "ANC_IN_HPHR", "RX INT2 MIX2"},
  6212. {"ANC1 FB MUX", "ANC_IN_LO2", "RX INT4 MIX2"},
  6213. {"ANC HPHL Enable", "Switch", "ADC MUX10"},
  6214. {"ANC HPHL Enable", "Switch", "ADC MUX11"},
  6215. {"RX INT1 MIX2", NULL, "ANC HPHL Enable"},
  6216. {"ANC HPHR Enable", "Switch", "ADC MUX12"},
  6217. {"ANC HPHR Enable", "Switch", "ADC MUX13"},
  6218. {"RX INT2 MIX2", NULL, "ANC HPHR Enable"},
  6219. {"ANC EAR Enable", "Switch", "ADC MUX10"},
  6220. {"ANC EAR Enable", "Switch", "ADC MUX11"},
  6221. {"RX INT0 MIX2", NULL, "ANC EAR Enable"},
  6222. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX10"},
  6223. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX11"},
  6224. {"RX INT7 MIX2", NULL, "ANC OUT EAR SPKR Enable"},
  6225. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX10"},
  6226. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX11"},
  6227. {"RX INT3 MIX2", NULL, "ANC LINEOUT1 Enable"},
  6228. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX12"},
  6229. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX13"},
  6230. {"RX INT4 MIX2", NULL, "ANC LINEOUT2 Enable"},
  6231. {"ANC EAR PA", NULL, "RX INT0 DAC"},
  6232. {"ANC EAR", NULL, "ANC EAR PA"},
  6233. {"ANC HPHL PA", NULL, "RX INT1 DAC"},
  6234. {"ANC HPHL", NULL, "ANC HPHL PA"},
  6235. {"ANC HPHR PA", NULL, "RX INT2 DAC"},
  6236. {"ANC HPHR", NULL, "ANC HPHR PA"},
  6237. {"ANC LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6238. {"ANC LINEOUT1", NULL, "ANC LINEOUT1 PA"},
  6239. {"ANC LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6240. {"ANC LINEOUT2", NULL, "ANC LINEOUT2 PA"},
  6241. /* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/
  6242. {"SLIM RX0 MUX", "AIF1_PB", "AIF1 PB"},
  6243. {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
  6244. {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
  6245. {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
  6246. {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
  6247. {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
  6248. {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
  6249. {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
  6250. /* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/
  6251. {"SLIM RX0 MUX", "AIF2_PB", "AIF2 PB"},
  6252. {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
  6253. {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
  6254. {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
  6255. {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
  6256. {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
  6257. {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
  6258. {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
  6259. /* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/
  6260. {"SLIM RX0 MUX", "AIF3_PB", "AIF3 PB"},
  6261. {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
  6262. {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
  6263. {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
  6264. {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
  6265. {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
  6266. {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
  6267. {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
  6268. /* SLIM_MUX("AIF4_PB", "AIF4 PB"),*/
  6269. {"SLIM RX0 MUX", "AIF4_PB", "AIF4 PB"},
  6270. {"SLIM RX1 MUX", "AIF4_PB", "AIF4 PB"},
  6271. {"SLIM RX2 MUX", "AIF4_PB", "AIF4 PB"},
  6272. {"SLIM RX3 MUX", "AIF4_PB", "AIF4 PB"},
  6273. {"SLIM RX4 MUX", "AIF4_PB", "AIF4 PB"},
  6274. {"SLIM RX5 MUX", "AIF4_PB", "AIF4 PB"},
  6275. {"SLIM RX6 MUX", "AIF4_PB", "AIF4 PB"},
  6276. {"SLIM RX7 MUX", "AIF4_PB", "AIF4 PB"},
  6277. /* SLIM_MUX("AIF_MIX1_PB", "AIF MIX1 PB"),*/
  6278. {"SLIM RX0 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6279. {"SLIM RX1 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6280. {"SLIM RX2 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6281. {"SLIM RX3 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6282. {"SLIM RX4 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6283. {"SLIM RX5 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6284. {"SLIM RX6 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6285. {"SLIM RX7 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6286. {"SLIM RX0", NULL, "SLIM RX0 MUX"},
  6287. {"SLIM RX1", NULL, "SLIM RX1 MUX"},
  6288. {"SLIM RX2", NULL, "SLIM RX2 MUX"},
  6289. {"SLIM RX3", NULL, "SLIM RX3 MUX"},
  6290. {"SLIM RX4", NULL, "SLIM RX4 MUX"},
  6291. {"SLIM RX5", NULL, "SLIM RX5 MUX"},
  6292. {"SLIM RX6", NULL, "SLIM RX6 MUX"},
  6293. {"SLIM RX7", NULL, "SLIM RX7 MUX"},
  6294. {"RX INT0_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6295. {"RX INT0_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6296. {"RX INT0_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6297. {"RX INT0_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6298. {"RX INT0_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6299. {"RX INT0_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6300. {"RX INT0_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6301. {"RX INT0_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6302. {"RX INT0_1 MIX1 INP0", "IIR0", "IIR0"},
  6303. {"RX INT0_1 MIX1 INP0", "IIR1", "IIR1"},
  6304. {"RX INT0_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6305. {"RX INT0_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6306. {"RX INT0_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6307. {"RX INT0_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6308. {"RX INT0_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6309. {"RX INT0_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6310. {"RX INT0_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6311. {"RX INT0_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6312. {"RX INT0_1 MIX1 INP1", "IIR0", "IIR0"},
  6313. {"RX INT0_1 MIX1 INP1", "IIR1", "IIR1"},
  6314. {"RX INT0_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6315. {"RX INT0_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6316. {"RX INT0_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6317. {"RX INT0_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6318. {"RX INT0_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6319. {"RX INT0_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6320. {"RX INT0_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6321. {"RX INT0_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6322. {"RX INT0_1 MIX1 INP2", "IIR0", "IIR0"},
  6323. {"RX INT0_1 MIX1 INP2", "IIR1", "IIR1"},
  6324. /* MIXing path INT0 */
  6325. {"RX INT0_2 MUX", "RX0", "SLIM RX0"},
  6326. {"RX INT0_2 MUX", "RX1", "SLIM RX1"},
  6327. {"RX INT0_2 MUX", "RX2", "SLIM RX2"},
  6328. {"RX INT0_2 MUX", "RX3", "SLIM RX3"},
  6329. {"RX INT0_2 MUX", "RX4", "SLIM RX4"},
  6330. {"RX INT0_2 MUX", "RX5", "SLIM RX5"},
  6331. {"RX INT0_2 MUX", "RX6", "SLIM RX6"},
  6332. {"RX INT0_2 MUX", "RX7", "SLIM RX7"},
  6333. {"RX INT0 SEC MIX", NULL, "RX INT0_2 MUX"},
  6334. /* MIXing path INT1 */
  6335. {"RX INT1_2 MUX", "RX0", "SLIM RX0"},
  6336. {"RX INT1_2 MUX", "RX1", "SLIM RX1"},
  6337. {"RX INT1_2 MUX", "RX2", "SLIM RX2"},
  6338. {"RX INT1_2 MUX", "RX3", "SLIM RX3"},
  6339. {"RX INT1_2 MUX", "RX4", "SLIM RX4"},
  6340. {"RX INT1_2 MUX", "RX5", "SLIM RX5"},
  6341. {"RX INT1_2 MUX", "RX6", "SLIM RX6"},
  6342. {"RX INT1_2 MUX", "RX7", "SLIM RX7"},
  6343. {"RX INT1 SEC MIX", NULL, "RX INT1_2 MUX"},
  6344. /* MIXing path INT2 */
  6345. {"RX INT2_2 MUX", "RX0", "SLIM RX0"},
  6346. {"RX INT2_2 MUX", "RX1", "SLIM RX1"},
  6347. {"RX INT2_2 MUX", "RX2", "SLIM RX2"},
  6348. {"RX INT2_2 MUX", "RX3", "SLIM RX3"},
  6349. {"RX INT2_2 MUX", "RX4", "SLIM RX4"},
  6350. {"RX INT2_2 MUX", "RX5", "SLIM RX5"},
  6351. {"RX INT2_2 MUX", "RX6", "SLIM RX6"},
  6352. {"RX INT2_2 MUX", "RX7", "SLIM RX7"},
  6353. {"RX INT2 SEC MIX", NULL, "RX INT2_2 MUX"},
  6354. /* MIXing path INT3 */
  6355. {"RX INT3_2 MUX", "RX0", "SLIM RX0"},
  6356. {"RX INT3_2 MUX", "RX1", "SLIM RX1"},
  6357. {"RX INT3_2 MUX", "RX2", "SLIM RX2"},
  6358. {"RX INT3_2 MUX", "RX3", "SLIM RX3"},
  6359. {"RX INT3_2 MUX", "RX4", "SLIM RX4"},
  6360. {"RX INT3_2 MUX", "RX5", "SLIM RX5"},
  6361. {"RX INT3_2 MUX", "RX6", "SLIM RX6"},
  6362. {"RX INT3_2 MUX", "RX7", "SLIM RX7"},
  6363. {"RX INT3 SEC MIX", NULL, "RX INT3_2 MUX"},
  6364. /* MIXing path INT4 */
  6365. {"RX INT4_2 MUX", "RX0", "SLIM RX0"},
  6366. {"RX INT4_2 MUX", "RX1", "SLIM RX1"},
  6367. {"RX INT4_2 MUX", "RX2", "SLIM RX2"},
  6368. {"RX INT4_2 MUX", "RX3", "SLIM RX3"},
  6369. {"RX INT4_2 MUX", "RX4", "SLIM RX4"},
  6370. {"RX INT4_2 MUX", "RX5", "SLIM RX5"},
  6371. {"RX INT4_2 MUX", "RX6", "SLIM RX6"},
  6372. {"RX INT4_2 MUX", "RX7", "SLIM RX7"},
  6373. {"RX INT4 SEC MIX", NULL, "RX INT4_2 MUX"},
  6374. /* MIXing path INT5 */
  6375. {"RX INT5_2 MUX", "RX0", "SLIM RX0"},
  6376. {"RX INT5_2 MUX", "RX1", "SLIM RX1"},
  6377. {"RX INT5_2 MUX", "RX2", "SLIM RX2"},
  6378. {"RX INT5_2 MUX", "RX3", "SLIM RX3"},
  6379. {"RX INT5_2 MUX", "RX4", "SLIM RX4"},
  6380. {"RX INT5_2 MUX", "RX5", "SLIM RX5"},
  6381. {"RX INT5_2 MUX", "RX6", "SLIM RX6"},
  6382. {"RX INT5_2 MUX", "RX7", "SLIM RX7"},
  6383. {"RX INT5 SEC MIX", NULL, "RX INT5_2 MUX"},
  6384. /* MIXing path INT6 */
  6385. {"RX INT6_2 MUX", "RX0", "SLIM RX0"},
  6386. {"RX INT6_2 MUX", "RX1", "SLIM RX1"},
  6387. {"RX INT6_2 MUX", "RX2", "SLIM RX2"},
  6388. {"RX INT6_2 MUX", "RX3", "SLIM RX3"},
  6389. {"RX INT6_2 MUX", "RX4", "SLIM RX4"},
  6390. {"RX INT6_2 MUX", "RX5", "SLIM RX5"},
  6391. {"RX INT6_2 MUX", "RX6", "SLIM RX6"},
  6392. {"RX INT6_2 MUX", "RX7", "SLIM RX7"},
  6393. {"RX INT6 SEC MIX", NULL, "RX INT6_2 MUX"},
  6394. /* MIXing path INT7 */
  6395. {"RX INT7_2 MUX", "RX0", "SLIM RX0"},
  6396. {"RX INT7_2 MUX", "RX1", "SLIM RX1"},
  6397. {"RX INT7_2 MUX", "RX2", "SLIM RX2"},
  6398. {"RX INT7_2 MUX", "RX3", "SLIM RX3"},
  6399. {"RX INT7_2 MUX", "RX4", "SLIM RX4"},
  6400. {"RX INT7_2 MUX", "RX5", "SLIM RX5"},
  6401. {"RX INT7_2 MUX", "RX6", "SLIM RX6"},
  6402. {"RX INT7_2 MUX", "RX7", "SLIM RX7"},
  6403. {"RX INT7 SEC MIX", NULL, "RX INT7_2 MUX"},
  6404. /* MIXing path INT8 */
  6405. {"RX INT8_2 MUX", "RX0", "SLIM RX0"},
  6406. {"RX INT8_2 MUX", "RX1", "SLIM RX1"},
  6407. {"RX INT8_2 MUX", "RX2", "SLIM RX2"},
  6408. {"RX INT8_2 MUX", "RX3", "SLIM RX3"},
  6409. {"RX INT8_2 MUX", "RX4", "SLIM RX4"},
  6410. {"RX INT8_2 MUX", "RX5", "SLIM RX5"},
  6411. {"RX INT8_2 MUX", "RX6", "SLIM RX6"},
  6412. {"RX INT8_2 MUX", "RX7", "SLIM RX7"},
  6413. {"RX INT8 SEC MIX", NULL, "RX INT8_2 MUX"},
  6414. {"RX INT1_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6415. {"RX INT1_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6416. {"RX INT1_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6417. {"RX INT1_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6418. {"RX INT1_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6419. {"RX INT1_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6420. {"RX INT1_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6421. {"RX INT1_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6422. {"RX INT1_1 MIX1 INP0", "IIR0", "IIR0"},
  6423. {"RX INT1_1 MIX1 INP0", "IIR1", "IIR1"},
  6424. {"RX INT1_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6425. {"RX INT1_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6426. {"RX INT1_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6427. {"RX INT1_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6428. {"RX INT1_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6429. {"RX INT1_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6430. {"RX INT1_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6431. {"RX INT1_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6432. {"RX INT1_1 MIX1 INP1", "IIR0", "IIR0"},
  6433. {"RX INT1_1 MIX1 INP1", "IIR1", "IIR1"},
  6434. {"RX INT1_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6435. {"RX INT1_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6436. {"RX INT1_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6437. {"RX INT1_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6438. {"RX INT1_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6439. {"RX INT1_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6440. {"RX INT1_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6441. {"RX INT1_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6442. {"RX INT1_1 MIX1 INP2", "IIR0", "IIR0"},
  6443. {"RX INT1_1 MIX1 INP2", "IIR1", "IIR1"},
  6444. {"RX INT2_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6445. {"RX INT2_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6446. {"RX INT2_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6447. {"RX INT2_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6448. {"RX INT2_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6449. {"RX INT2_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6450. {"RX INT2_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6451. {"RX INT2_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6452. {"RX INT2_1 MIX1 INP0", "IIR0", "IIR0"},
  6453. {"RX INT2_1 MIX1 INP0", "IIR1", "IIR1"},
  6454. {"RX INT2_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6455. {"RX INT2_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6456. {"RX INT2_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6457. {"RX INT2_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6458. {"RX INT2_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6459. {"RX INT2_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6460. {"RX INT2_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6461. {"RX INT2_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6462. {"RX INT2_1 MIX1 INP1", "IIR0", "IIR0"},
  6463. {"RX INT2_1 MIX1 INP1", "IIR1", "IIR1"},
  6464. {"RX INT2_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6465. {"RX INT2_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6466. {"RX INT2_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6467. {"RX INT2_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6468. {"RX INT2_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6469. {"RX INT2_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6470. {"RX INT2_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6471. {"RX INT2_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6472. {"RX INT2_1 MIX1 INP2", "IIR0", "IIR0"},
  6473. {"RX INT2_1 MIX1 INP2", "IIR1", "IIR1"},
  6474. {"RX INT3_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6475. {"RX INT3_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6476. {"RX INT3_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6477. {"RX INT3_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6478. {"RX INT3_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6479. {"RX INT3_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6480. {"RX INT3_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6481. {"RX INT3_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6482. {"RX INT3_1 MIX1 INP0", "IIR0", "IIR0"},
  6483. {"RX INT3_1 MIX1 INP0", "IIR1", "IIR1"},
  6484. {"RX INT3_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6485. {"RX INT3_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6486. {"RX INT3_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6487. {"RX INT3_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6488. {"RX INT3_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6489. {"RX INT3_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6490. {"RX INT3_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6491. {"RX INT3_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6492. {"RX INT3_1 MIX1 INP1", "IIR0", "IIR0"},
  6493. {"RX INT3_1 MIX1 INP1", "IIR1", "IIR1"},
  6494. {"RX INT3_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6495. {"RX INT3_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6496. {"RX INT3_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6497. {"RX INT3_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6498. {"RX INT3_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6499. {"RX INT3_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6500. {"RX INT3_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6501. {"RX INT3_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6502. {"RX INT3_1 MIX1 INP2", "IIR0", "IIR0"},
  6503. {"RX INT3_1 MIX1 INP2", "IIR1", "IIR1"},
  6504. {"RX INT4_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6505. {"RX INT4_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6506. {"RX INT4_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6507. {"RX INT4_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6508. {"RX INT4_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6509. {"RX INT4_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6510. {"RX INT4_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6511. {"RX INT4_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6512. {"RX INT4_1 MIX1 INP0", "IIR0", "IIR0"},
  6513. {"RX INT4_1 MIX1 INP0", "IIR1", "IIR1"},
  6514. {"RX INT4_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6515. {"RX INT4_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6516. {"RX INT4_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6517. {"RX INT4_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6518. {"RX INT4_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6519. {"RX INT4_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6520. {"RX INT4_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6521. {"RX INT4_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6522. {"RX INT4_1 MIX1 INP1", "IIR0", "IIR0"},
  6523. {"RX INT4_1 MIX1 INP1", "IIR1", "IIR1"},
  6524. {"RX INT4_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6525. {"RX INT4_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6526. {"RX INT4_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6527. {"RX INT4_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6528. {"RX INT4_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6529. {"RX INT4_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6530. {"RX INT4_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6531. {"RX INT4_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6532. {"RX INT4_1 MIX1 INP2", "IIR0", "IIR0"},
  6533. {"RX INT4_1 MIX1 INP2", "IIR1", "IIR1"},
  6534. {"RX INT5_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6535. {"RX INT5_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6536. {"RX INT5_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6537. {"RX INT5_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6538. {"RX INT5_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6539. {"RX INT5_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6540. {"RX INT5_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6541. {"RX INT5_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6542. {"RX INT5_1 MIX1 INP0", "IIR0", "IIR0"},
  6543. {"RX INT5_1 MIX1 INP0", "IIR1", "IIR1"},
  6544. {"RX INT5_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6545. {"RX INT5_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6546. {"RX INT5_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6547. {"RX INT5_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6548. {"RX INT5_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6549. {"RX INT5_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6550. {"RX INT5_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6551. {"RX INT5_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6552. {"RX INT5_1 MIX1 INP1", "IIR0", "IIR0"},
  6553. {"RX INT5_1 MIX1 INP1", "IIR1", "IIR1"},
  6554. {"RX INT5_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6555. {"RX INT5_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6556. {"RX INT5_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6557. {"RX INT5_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6558. {"RX INT5_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6559. {"RX INT5_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6560. {"RX INT5_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6561. {"RX INT5_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6562. {"RX INT5_1 MIX1 INP2", "IIR0", "IIR0"},
  6563. {"RX INT5_1 MIX1 INP2", "IIR1", "IIR1"},
  6564. {"RX INT6_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6565. {"RX INT6_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6566. {"RX INT6_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6567. {"RX INT6_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6568. {"RX INT6_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6569. {"RX INT6_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6570. {"RX INT6_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6571. {"RX INT6_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6572. {"RX INT6_1 MIX1 INP0", "IIR0", "IIR0"},
  6573. {"RX INT6_1 MIX1 INP0", "IIR1", "IIR1"},
  6574. {"RX INT6_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6575. {"RX INT6_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6576. {"RX INT6_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6577. {"RX INT6_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6578. {"RX INT6_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6579. {"RX INT6_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6580. {"RX INT6_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6581. {"RX INT6_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6582. {"RX INT6_1 MIX1 INP1", "IIR0", "IIR0"},
  6583. {"RX INT6_1 MIX1 INP1", "IIR1", "IIR1"},
  6584. {"RX INT6_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6585. {"RX INT6_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6586. {"RX INT6_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6587. {"RX INT6_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6588. {"RX INT6_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6589. {"RX INT6_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6590. {"RX INT6_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6591. {"RX INT6_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6592. {"RX INT6_1 MIX1 INP2", "IIR0", "IIR0"},
  6593. {"RX INT6_1 MIX1 INP2", "IIR1", "IIR1"},
  6594. {"RX INT7_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6595. {"RX INT7_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6596. {"RX INT7_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6597. {"RX INT7_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6598. {"RX INT7_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6599. {"RX INT7_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6600. {"RX INT7_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6601. {"RX INT7_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6602. {"RX INT7_1 MIX1 INP0", "IIR0", "IIR0"},
  6603. {"RX INT7_1 MIX1 INP0", "IIR1", "IIR1"},
  6604. {"RX INT7_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6605. {"RX INT7_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6606. {"RX INT7_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6607. {"RX INT7_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6608. {"RX INT7_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6609. {"RX INT7_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6610. {"RX INT7_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6611. {"RX INT7_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6612. {"RX INT7_1 MIX1 INP1", "IIR0", "IIR0"},
  6613. {"RX INT7_1 MIX1 INP1", "IIR1", "IIR1"},
  6614. {"RX INT7_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6615. {"RX INT7_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6616. {"RX INT7_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6617. {"RX INT7_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6618. {"RX INT7_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6619. {"RX INT7_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6620. {"RX INT7_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6621. {"RX INT7_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6622. {"RX INT7_1 MIX1 INP2", "IIR0", "IIR0"},
  6623. {"RX INT7_1 MIX1 INP2", "IIR1", "IIR1"},
  6624. {"RX INT8_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6625. {"RX INT8_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6626. {"RX INT8_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6627. {"RX INT8_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6628. {"RX INT8_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6629. {"RX INT8_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6630. {"RX INT8_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6631. {"RX INT8_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6632. {"RX INT8_1 MIX1 INP0", "IIR0", "IIR0"},
  6633. {"RX INT8_1 MIX1 INP0", "IIR1", "IIR1"},
  6634. {"RX INT8_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6635. {"RX INT8_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6636. {"RX INT8_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6637. {"RX INT8_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6638. {"RX INT8_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6639. {"RX INT8_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6640. {"RX INT8_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6641. {"RX INT8_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6642. {"RX INT8_1 MIX1 INP1", "IIR0", "IIR0"},
  6643. {"RX INT8_1 MIX1 INP1", "IIR1", "IIR1"},
  6644. {"RX INT8_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6645. {"RX INT8_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6646. {"RX INT8_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6647. {"RX INT8_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6648. {"RX INT8_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6649. {"RX INT8_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6650. {"RX INT8_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6651. {"RX INT8_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6652. {"RX INT8_1 MIX1 INP2", "IIR0", "IIR0"},
  6653. {"RX INT8_1 MIX1 INP2", "IIR1", "IIR1"},
  6654. /* SRC0, SRC1 inputs to Sidetone RX Mixer
  6655. * on RX0, RX1, RX2, RX3, RX4 and RX7 chains
  6656. */
  6657. {"IIR0", NULL, "IIR0 INP0 MUX"},
  6658. {"IIR0 INP0 MUX", "DEC0", "ADC MUX0"},
  6659. {"IIR0 INP0 MUX", "DEC1", "ADC MUX1"},
  6660. {"IIR0 INP0 MUX", "DEC2", "ADC MUX2"},
  6661. {"IIR0 INP0 MUX", "DEC3", "ADC MUX3"},
  6662. {"IIR0 INP0 MUX", "DEC4", "ADC MUX4"},
  6663. {"IIR0 INP0 MUX", "DEC5", "ADC MUX5"},
  6664. {"IIR0 INP0 MUX", "DEC6", "ADC MUX6"},
  6665. {"IIR0 INP0 MUX", "DEC7", "ADC MUX7"},
  6666. {"IIR0 INP0 MUX", "DEC8", "ADC MUX8"},
  6667. {"IIR0 INP0 MUX", "RX0", "SLIM RX0"},
  6668. {"IIR0 INP0 MUX", "RX1", "SLIM RX1"},
  6669. {"IIR0 INP0 MUX", "RX2", "SLIM RX2"},
  6670. {"IIR0 INP0 MUX", "RX3", "SLIM RX3"},
  6671. {"IIR0 INP0 MUX", "RX4", "SLIM RX4"},
  6672. {"IIR0 INP0 MUX", "RX5", "SLIM RX5"},
  6673. {"IIR0 INP0 MUX", "RX6", "SLIM RX6"},
  6674. {"IIR0 INP0 MUX", "RX7", "SLIM RX7"},
  6675. {"IIR0", NULL, "IIR0 INP1 MUX"},
  6676. {"IIR0 INP1 MUX", "DEC0", "ADC MUX0"},
  6677. {"IIR0 INP1 MUX", "DEC1", "ADC MUX1"},
  6678. {"IIR0 INP1 MUX", "DEC2", "ADC MUX2"},
  6679. {"IIR0 INP1 MUX", "DEC3", "ADC MUX3"},
  6680. {"IIR0 INP1 MUX", "DEC4", "ADC MUX4"},
  6681. {"IIR0 INP1 MUX", "DEC5", "ADC MUX5"},
  6682. {"IIR0 INP1 MUX", "DEC6", "ADC MUX6"},
  6683. {"IIR0 INP1 MUX", "DEC7", "ADC MUX7"},
  6684. {"IIR0 INP1 MUX", "DEC8", "ADC MUX8"},
  6685. {"IIR0 INP1 MUX", "RX0", "SLIM RX0"},
  6686. {"IIR0 INP1 MUX", "RX1", "SLIM RX1"},
  6687. {"IIR0 INP1 MUX", "RX2", "SLIM RX2"},
  6688. {"IIR0 INP1 MUX", "RX3", "SLIM RX3"},
  6689. {"IIR0 INP1 MUX", "RX4", "SLIM RX4"},
  6690. {"IIR0 INP1 MUX", "RX5", "SLIM RX5"},
  6691. {"IIR0 INP1 MUX", "RX6", "SLIM RX6"},
  6692. {"IIR0 INP1 MUX", "RX7", "SLIM RX7"},
  6693. {"IIR0", NULL, "IIR0 INP2 MUX"},
  6694. {"IIR0 INP2 MUX", "DEC0", "ADC MUX0"},
  6695. {"IIR0 INP2 MUX", "DEC1", "ADC MUX1"},
  6696. {"IIR0 INP2 MUX", "DEC2", "ADC MUX2"},
  6697. {"IIR0 INP2 MUX", "DEC3", "ADC MUX3"},
  6698. {"IIR0 INP2 MUX", "DEC4", "ADC MUX4"},
  6699. {"IIR0 INP2 MUX", "DEC5", "ADC MUX5"},
  6700. {"IIR0 INP2 MUX", "DEC6", "ADC MUX6"},
  6701. {"IIR0 INP2 MUX", "DEC7", "ADC MUX7"},
  6702. {"IIR0 INP2 MUX", "DEC8", "ADC MUX8"},
  6703. {"IIR0 INP2 MUX", "RX0", "SLIM RX0"},
  6704. {"IIR0 INP2 MUX", "RX1", "SLIM RX1"},
  6705. {"IIR0 INP2 MUX", "RX2", "SLIM RX2"},
  6706. {"IIR0 INP2 MUX", "RX3", "SLIM RX3"},
  6707. {"IIR0 INP2 MUX", "RX4", "SLIM RX4"},
  6708. {"IIR0 INP2 MUX", "RX5", "SLIM RX5"},
  6709. {"IIR0 INP2 MUX", "RX6", "SLIM RX6"},
  6710. {"IIR0 INP2 MUX", "RX7", "SLIM RX7"},
  6711. {"IIR0", NULL, "IIR0 INP3 MUX"},
  6712. {"IIR0 INP3 MUX", "DEC0", "ADC MUX0"},
  6713. {"IIR0 INP3 MUX", "DEC1", "ADC MUX1"},
  6714. {"IIR0 INP3 MUX", "DEC2", "ADC MUX2"},
  6715. {"IIR0 INP3 MUX", "DEC3", "ADC MUX3"},
  6716. {"IIR0 INP3 MUX", "DEC4", "ADC MUX4"},
  6717. {"IIR0 INP3 MUX", "DEC5", "ADC MUX5"},
  6718. {"IIR0 INP3 MUX", "DEC6", "ADC MUX6"},
  6719. {"IIR0 INP3 MUX", "DEC7", "ADC MUX7"},
  6720. {"IIR0 INP3 MUX", "DEC8", "ADC MUX8"},
  6721. {"IIR0 INP3 MUX", "RX0", "SLIM RX0"},
  6722. {"IIR0 INP3 MUX", "RX1", "SLIM RX1"},
  6723. {"IIR0 INP3 MUX", "RX2", "SLIM RX2"},
  6724. {"IIR0 INP3 MUX", "RX3", "SLIM RX3"},
  6725. {"IIR0 INP3 MUX", "RX4", "SLIM RX4"},
  6726. {"IIR0 INP3 MUX", "RX5", "SLIM RX5"},
  6727. {"IIR0 INP3 MUX", "RX6", "SLIM RX6"},
  6728. {"IIR0 INP3 MUX", "RX7", "SLIM RX7"},
  6729. {"IIR1", NULL, "IIR1 INP0 MUX"},
  6730. {"IIR1 INP0 MUX", "DEC0", "ADC MUX0"},
  6731. {"IIR1 INP0 MUX", "DEC1", "ADC MUX1"},
  6732. {"IIR1 INP0 MUX", "DEC2", "ADC MUX2"},
  6733. {"IIR1 INP0 MUX", "DEC3", "ADC MUX3"},
  6734. {"IIR1 INP0 MUX", "DEC4", "ADC MUX4"},
  6735. {"IIR1 INP0 MUX", "DEC5", "ADC MUX5"},
  6736. {"IIR1 INP0 MUX", "DEC6", "ADC MUX6"},
  6737. {"IIR1 INP0 MUX", "DEC7", "ADC MUX7"},
  6738. {"IIR1 INP0 MUX", "DEC8", "ADC MUX8"},
  6739. {"IIR1 INP0 MUX", "RX0", "SLIM RX0"},
  6740. {"IIR1 INP0 MUX", "RX1", "SLIM RX1"},
  6741. {"IIR1 INP0 MUX", "RX2", "SLIM RX2"},
  6742. {"IIR1 INP0 MUX", "RX3", "SLIM RX3"},
  6743. {"IIR1 INP0 MUX", "RX4", "SLIM RX4"},
  6744. {"IIR1 INP0 MUX", "RX5", "SLIM RX5"},
  6745. {"IIR1 INP0 MUX", "RX6", "SLIM RX6"},
  6746. {"IIR1 INP0 MUX", "RX7", "SLIM RX7"},
  6747. {"IIR1", NULL, "IIR1 INP1 MUX"},
  6748. {"IIR1 INP1 MUX", "DEC0", "ADC MUX0"},
  6749. {"IIR1 INP1 MUX", "DEC1", "ADC MUX1"},
  6750. {"IIR1 INP1 MUX", "DEC2", "ADC MUX2"},
  6751. {"IIR1 INP1 MUX", "DEC3", "ADC MUX3"},
  6752. {"IIR1 INP1 MUX", "DEC4", "ADC MUX4"},
  6753. {"IIR1 INP1 MUX", "DEC5", "ADC MUX5"},
  6754. {"IIR1 INP1 MUX", "DEC6", "ADC MUX6"},
  6755. {"IIR1 INP1 MUX", "DEC7", "ADC MUX7"},
  6756. {"IIR1 INP1 MUX", "DEC8", "ADC MUX8"},
  6757. {"IIR1 INP1 MUX", "RX0", "SLIM RX0"},
  6758. {"IIR1 INP1 MUX", "RX1", "SLIM RX1"},
  6759. {"IIR1 INP1 MUX", "RX2", "SLIM RX2"},
  6760. {"IIR1 INP1 MUX", "RX3", "SLIM RX3"},
  6761. {"IIR1 INP1 MUX", "RX4", "SLIM RX4"},
  6762. {"IIR1 INP1 MUX", "RX5", "SLIM RX5"},
  6763. {"IIR1 INP1 MUX", "RX6", "SLIM RX6"},
  6764. {"IIR1 INP1 MUX", "RX7", "SLIM RX7"},
  6765. {"IIR1", NULL, "IIR1 INP2 MUX"},
  6766. {"IIR1 INP2 MUX", "DEC0", "ADC MUX0"},
  6767. {"IIR1 INP2 MUX", "DEC1", "ADC MUX1"},
  6768. {"IIR1 INP2 MUX", "DEC2", "ADC MUX2"},
  6769. {"IIR1 INP2 MUX", "DEC3", "ADC MUX3"},
  6770. {"IIR1 INP2 MUX", "DEC4", "ADC MUX4"},
  6771. {"IIR1 INP2 MUX", "DEC5", "ADC MUX5"},
  6772. {"IIR1 INP2 MUX", "DEC6", "ADC MUX6"},
  6773. {"IIR1 INP2 MUX", "DEC7", "ADC MUX7"},
  6774. {"IIR1 INP2 MUX", "DEC8", "ADC MUX8"},
  6775. {"IIR1 INP2 MUX", "RX0", "SLIM RX0"},
  6776. {"IIR1 INP2 MUX", "RX1", "SLIM RX1"},
  6777. {"IIR1 INP2 MUX", "RX2", "SLIM RX2"},
  6778. {"IIR1 INP2 MUX", "RX3", "SLIM RX3"},
  6779. {"IIR1 INP2 MUX", "RX4", "SLIM RX4"},
  6780. {"IIR1 INP2 MUX", "RX5", "SLIM RX5"},
  6781. {"IIR1 INP2 MUX", "RX6", "SLIM RX6"},
  6782. {"IIR1 INP2 MUX", "RX7", "SLIM RX7"},
  6783. {"IIR1", NULL, "IIR1 INP3 MUX"},
  6784. {"IIR1 INP3 MUX", "DEC0", "ADC MUX0"},
  6785. {"IIR1 INP3 MUX", "DEC1", "ADC MUX1"},
  6786. {"IIR1 INP3 MUX", "DEC2", "ADC MUX2"},
  6787. {"IIR1 INP3 MUX", "DEC3", "ADC MUX3"},
  6788. {"IIR1 INP3 MUX", "DEC4", "ADC MUX4"},
  6789. {"IIR1 INP3 MUX", "DEC5", "ADC MUX5"},
  6790. {"IIR1 INP3 MUX", "DEC6", "ADC MUX6"},
  6791. {"IIR1 INP3 MUX", "DEC7", "ADC MUX7"},
  6792. {"IIR1 INP3 MUX", "DEC8", "ADC MUX8"},
  6793. {"IIR1 INP3 MUX", "RX0", "SLIM RX0"},
  6794. {"IIR1 INP3 MUX", "RX1", "SLIM RX1"},
  6795. {"IIR1 INP3 MUX", "RX2", "SLIM RX2"},
  6796. {"IIR1 INP3 MUX", "RX3", "SLIM RX3"},
  6797. {"IIR1 INP3 MUX", "RX4", "SLIM RX4"},
  6798. {"IIR1 INP3 MUX", "RX5", "SLIM RX5"},
  6799. {"IIR1 INP3 MUX", "RX6", "SLIM RX6"},
  6800. {"IIR1 INP3 MUX", "RX7", "SLIM RX7"},
  6801. {"SRC0", NULL, "IIR0"},
  6802. {"SRC1", NULL, "IIR1"},
  6803. {"RX INT0 MIX2 INP", "SRC0", "SRC0"},
  6804. {"RX INT0 MIX2 INP", "SRC1", "SRC1"},
  6805. {"RX INT1 MIX2 INP", "SRC0", "SRC0"},
  6806. {"RX INT1 MIX2 INP", "SRC1", "SRC1"},
  6807. {"RX INT2 MIX2 INP", "SRC0", "SRC0"},
  6808. {"RX INT2 MIX2 INP", "SRC1", "SRC1"},
  6809. {"RX INT3 MIX2 INP", "SRC0", "SRC0"},
  6810. {"RX INT3 MIX2 INP", "SRC1", "SRC1"},
  6811. {"RX INT4 MIX2 INP", "SRC0", "SRC0"},
  6812. {"RX INT4 MIX2 INP", "SRC1", "SRC1"},
  6813. {"RX INT7 MIX2 INP", "SRC0", "SRC0"},
  6814. {"RX INT7 MIX2 INP", "SRC1", "SRC1"},
  6815. };
  6816. static int tasha_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol,
  6817. struct snd_ctl_elem_value *ucontrol)
  6818. {
  6819. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6820. u16 amic_reg;
  6821. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6822. amic_reg = WCD9335_ANA_AMIC1;
  6823. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6824. amic_reg = WCD9335_ANA_AMIC3;
  6825. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6826. amic_reg = WCD9335_ANA_AMIC5;
  6827. ucontrol->value.integer.value[0] =
  6828. (snd_soc_read(codec, amic_reg) & WCD9335_AMIC_PWR_LVL_MASK) >>
  6829. WCD9335_AMIC_PWR_LVL_SHIFT;
  6830. return 0;
  6831. }
  6832. static int tasha_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol,
  6833. struct snd_ctl_elem_value *ucontrol)
  6834. {
  6835. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6836. u32 mode_val;
  6837. u16 amic_reg;
  6838. mode_val = ucontrol->value.enumerated.item[0];
  6839. dev_dbg(codec->dev, "%s: mode: %d\n",
  6840. __func__, mode_val);
  6841. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6842. amic_reg = WCD9335_ANA_AMIC1;
  6843. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6844. amic_reg = WCD9335_ANA_AMIC3;
  6845. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6846. amic_reg = WCD9335_ANA_AMIC5;
  6847. snd_soc_update_bits(codec, amic_reg, WCD9335_AMIC_PWR_LVL_MASK,
  6848. mode_val << WCD9335_AMIC_PWR_LVL_SHIFT);
  6849. return 0;
  6850. }
  6851. static int tasha_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
  6852. struct snd_ctl_elem_value *ucontrol)
  6853. {
  6854. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6855. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6856. ucontrol->value.integer.value[0] = tasha->hph_mode;
  6857. return 0;
  6858. }
  6859. static int tasha_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
  6860. struct snd_ctl_elem_value *ucontrol)
  6861. {
  6862. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6863. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6864. u32 mode_val;
  6865. mode_val = ucontrol->value.enumerated.item[0];
  6866. dev_dbg(codec->dev, "%s: mode: %d\n",
  6867. __func__, mode_val);
  6868. if (mode_val == 0) {
  6869. dev_warn(codec->dev, "%s:Invalid HPH Mode, default to Cls-H HiFi\n",
  6870. __func__);
  6871. mode_val = CLS_H_HIFI;
  6872. }
  6873. tasha->hph_mode = mode_val;
  6874. return 0;
  6875. }
  6876. static const char *const tasha_conn_mad_text[] = {
  6877. "NOTUSED1", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6",
  6878. "NOTUSED2", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4",
  6879. "DMIC5", "NOTUSED3", "NOTUSED4"
  6880. };
  6881. static const struct soc_enum tasha_conn_mad_enum =
  6882. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_conn_mad_text),
  6883. tasha_conn_mad_text);
  6884. static int tasha_enable_ldo_h_get(struct snd_kcontrol *kcontrol,
  6885. struct snd_ctl_elem_value *ucontrol)
  6886. {
  6887. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6888. u8 val = 0;
  6889. if (codec)
  6890. val = snd_soc_read(codec, WCD9335_LDOH_MODE) & 0x80;
  6891. ucontrol->value.integer.value[0] = !!val;
  6892. return 0;
  6893. }
  6894. static int tasha_enable_ldo_h_put(struct snd_kcontrol *kcontrol,
  6895. struct snd_ctl_elem_value *ucontrol)
  6896. {
  6897. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6898. int value = ucontrol->value.integer.value[0];
  6899. bool enable;
  6900. enable = !!value;
  6901. if (codec)
  6902. tasha_codec_enable_standalone_ldo_h(codec, enable);
  6903. return 0;
  6904. }
  6905. static int tasha_mad_input_get(struct snd_kcontrol *kcontrol,
  6906. struct snd_ctl_elem_value *ucontrol)
  6907. {
  6908. u8 tasha_mad_input;
  6909. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6910. tasha_mad_input = snd_soc_read(codec,
  6911. WCD9335_SOC_MAD_INP_SEL) & 0x0F;
  6912. ucontrol->value.integer.value[0] = tasha_mad_input;
  6913. dev_dbg(codec->dev,
  6914. "%s: tasha_mad_input = %s\n", __func__,
  6915. tasha_conn_mad_text[tasha_mad_input]);
  6916. return 0;
  6917. }
  6918. static int tasha_mad_input_put(struct snd_kcontrol *kcontrol,
  6919. struct snd_ctl_elem_value *ucontrol)
  6920. {
  6921. u8 tasha_mad_input;
  6922. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6923. struct snd_soc_card *card = codec->component.card;
  6924. char mad_amic_input_widget[6];
  6925. const char *mad_input_widget;
  6926. const char *source_widget = NULL;
  6927. u32 adc, i, mic_bias_found = 0;
  6928. int ret = 0;
  6929. char *mad_input;
  6930. tasha_mad_input = ucontrol->value.integer.value[0];
  6931. if (tasha_mad_input >= ARRAY_SIZE(tasha_conn_mad_text)) {
  6932. dev_err(codec->dev,
  6933. "%s: tasha_mad_input = %d out of bounds\n",
  6934. __func__, tasha_mad_input);
  6935. return -EINVAL;
  6936. }
  6937. if (!strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED1") ||
  6938. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED2") ||
  6939. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED3") ||
  6940. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED4")) {
  6941. dev_err(codec->dev,
  6942. "%s: Unsupported tasha_mad_input = %s\n",
  6943. __func__, tasha_conn_mad_text[tasha_mad_input]);
  6944. return -EINVAL;
  6945. }
  6946. if (strnstr(tasha_conn_mad_text[tasha_mad_input],
  6947. "ADC", sizeof("ADC"))) {
  6948. mad_input = strpbrk(tasha_conn_mad_text[tasha_mad_input],
  6949. "123456");
  6950. if (!mad_input) {
  6951. dev_err(codec->dev, "%s: Invalid MAD input %s\n",
  6952. __func__,
  6953. tasha_conn_mad_text[tasha_mad_input]);
  6954. return -EINVAL;
  6955. }
  6956. ret = kstrtouint(mad_input, 10, &adc);
  6957. if ((ret < 0) || (adc > 6)) {
  6958. dev_err(codec->dev,
  6959. "%s: Invalid ADC = %s\n", __func__,
  6960. tasha_conn_mad_text[tasha_mad_input]);
  6961. ret = -EINVAL;
  6962. }
  6963. snprintf(mad_amic_input_widget, 6, "%s%u", "AMIC", adc);
  6964. mad_input_widget = mad_amic_input_widget;
  6965. } else {
  6966. /* DMIC type input widget*/
  6967. mad_input_widget = tasha_conn_mad_text[tasha_mad_input];
  6968. }
  6969. dev_dbg(codec->dev,
  6970. "%s: tasha input widget = %s\n", __func__,
  6971. mad_input_widget);
  6972. for (i = 0; i < card->num_of_dapm_routes; i++) {
  6973. if (!strcmp(card->of_dapm_routes[i].sink, mad_input_widget)) {
  6974. source_widget = card->of_dapm_routes[i].source;
  6975. if (!source_widget) {
  6976. dev_err(codec->dev,
  6977. "%s: invalid source widget\n",
  6978. __func__);
  6979. return -EINVAL;
  6980. }
  6981. if (strnstr(source_widget,
  6982. "MIC BIAS1", sizeof("MIC BIAS1"))) {
  6983. mic_bias_found = 1;
  6984. break;
  6985. } else if (strnstr(source_widget,
  6986. "MIC BIAS2", sizeof("MIC BIAS2"))) {
  6987. mic_bias_found = 2;
  6988. break;
  6989. } else if (strnstr(source_widget,
  6990. "MIC BIAS3", sizeof("MIC BIAS3"))) {
  6991. mic_bias_found = 3;
  6992. break;
  6993. } else if (strnstr(source_widget,
  6994. "MIC BIAS4", sizeof("MIC BIAS4"))) {
  6995. mic_bias_found = 4;
  6996. break;
  6997. }
  6998. }
  6999. }
  7000. if (!mic_bias_found) {
  7001. dev_err(codec->dev,
  7002. "%s: mic bias source not found for input = %s\n",
  7003. __func__, mad_input_widget);
  7004. return -EINVAL;
  7005. }
  7006. dev_dbg(codec->dev,
  7007. "%s: mic_bias found = %d\n", __func__,
  7008. mic_bias_found);
  7009. snd_soc_update_bits(codec, WCD9335_SOC_MAD_INP_SEL,
  7010. 0x0F, tasha_mad_input);
  7011. snd_soc_update_bits(codec, WCD9335_ANA_MAD_SETUP,
  7012. 0x07, mic_bias_found);
  7013. return 0;
  7014. }
  7015. static int tasha_pinctl_mode_get(struct snd_kcontrol *kcontrol,
  7016. struct snd_ctl_elem_value *ucontrol)
  7017. {
  7018. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7019. u16 ctl_reg;
  7020. u8 reg_val, pinctl_position;
  7021. pinctl_position = ((struct soc_multi_mixer_control *)
  7022. kcontrol->private_value)->shift;
  7023. switch (pinctl_position >> 3) {
  7024. case 0:
  7025. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7026. break;
  7027. case 1:
  7028. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7029. break;
  7030. case 2:
  7031. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7032. break;
  7033. case 3:
  7034. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7035. break;
  7036. default:
  7037. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7038. __func__, pinctl_position);
  7039. return -EINVAL;
  7040. }
  7041. reg_val = snd_soc_read(codec, ctl_reg);
  7042. reg_val = (reg_val >> (pinctl_position & 0x07)) & 0x1;
  7043. ucontrol->value.integer.value[0] = reg_val;
  7044. return 0;
  7045. }
  7046. static int tasha_pinctl_mode_put(struct snd_kcontrol *kcontrol,
  7047. struct snd_ctl_elem_value *ucontrol)
  7048. {
  7049. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7050. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7051. u16 ctl_reg, cfg_reg;
  7052. u8 ctl_val, cfg_val, pinctl_position, pinctl_mode, mask;
  7053. /* 1- high or low; 0- high Z */
  7054. pinctl_mode = ucontrol->value.integer.value[0];
  7055. pinctl_position = ((struct soc_multi_mixer_control *)
  7056. kcontrol->private_value)->shift;
  7057. switch (pinctl_position >> 3) {
  7058. case 0:
  7059. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7060. break;
  7061. case 1:
  7062. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7063. break;
  7064. case 2:
  7065. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7066. break;
  7067. case 3:
  7068. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7069. break;
  7070. default:
  7071. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7072. __func__, pinctl_position);
  7073. return -EINVAL;
  7074. }
  7075. ctl_val = pinctl_mode << (pinctl_position & 0x07);
  7076. mask = 1 << (pinctl_position & 0x07);
  7077. snd_soc_update_bits(codec, ctl_reg, mask, ctl_val);
  7078. cfg_reg = WCD9335_TLMM_BIST_MODE_PINCFG + pinctl_position;
  7079. if (!pinctl_mode) {
  7080. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  7081. cfg_val = 0x4;
  7082. else
  7083. cfg_val = 0xC;
  7084. } else {
  7085. cfg_val = 0;
  7086. }
  7087. snd_soc_update_bits(codec, cfg_reg, 0x07, cfg_val);
  7088. dev_dbg(codec->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n",
  7089. __func__, ctl_reg, mask, ctl_val, cfg_reg, cfg_val);
  7090. return 0;
  7091. }
  7092. static void wcd_vbat_adc_out_config_2_0(struct wcd_vbat *vbat,
  7093. struct snd_soc_codec *codec)
  7094. {
  7095. u8 val1, val2;
  7096. /*
  7097. * Measure dcp1 by using "ALT" branch of band gap
  7098. * voltage(Vbg) and use it in FAST mode
  7099. */
  7100. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x82, 0x82);
  7101. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7102. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x01);
  7103. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x80);
  7104. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x00);
  7105. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x20);
  7106. /* Wait 100 usec after calibration select as Vbg */
  7107. usleep_range(100, 110);
  7108. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7109. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7110. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7111. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7112. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7113. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x40, 0x40);
  7114. /* Wait 100 usec after selecting Vbg as 1.05V */
  7115. usleep_range(100, 110);
  7116. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7117. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7118. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7119. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7120. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7121. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7122. __func__, vbat->dcp1, vbat->dcp2);
  7123. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7124. /* Wait 100 usec after selecting Vbg as 0.85V */
  7125. usleep_range(100, 110);
  7126. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x00);
  7127. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x20);
  7128. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x00);
  7129. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x00);
  7130. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x00);
  7131. }
  7132. static void wcd_vbat_adc_out_config_1_x(struct wcd_vbat *vbat,
  7133. struct snd_soc_codec *codec)
  7134. {
  7135. u8 val1, val2;
  7136. /*
  7137. * Measure dcp1 by applying band gap voltage(Vbg)
  7138. * of 0.85V
  7139. */
  7140. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x20);
  7141. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7142. snd_soc_write(codec, WCD9335_BIAS_VBG_FINE_ADJ, 0x05);
  7143. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7144. /* Wait 2 sec after enabling band gap bias */
  7145. usleep_range(2000000, 2000100);
  7146. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x82);
  7147. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x87);
  7148. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7149. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0D);
  7150. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01);
  7151. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7152. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xDE);
  7153. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x3C);
  7154. /* Wait 1 msec after calibration select as Vbg */
  7155. usleep_range(1000, 1100);
  7156. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
  7157. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7158. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7159. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7160. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7161. /*
  7162. * Measure dcp2 by applying band gap voltage(Vbg)
  7163. * of 1.05V
  7164. */
  7165. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7166. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7167. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x68);
  7168. /* Wait 2 msec after selecting Vbg as 1.05V */
  7169. usleep_range(2000, 2100);
  7170. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7171. /* Wait 1 sec after enabling band gap bias */
  7172. usleep_range(1000000, 1000100);
  7173. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
  7174. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7175. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7176. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7177. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7178. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7179. __func__, vbat->dcp1, vbat->dcp2);
  7180. /* Reset the Vbat ADC configuration */
  7181. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7182. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7183. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7184. /* Wait 2 msec after selecting Vbg as 0.85V */
  7185. usleep_range(2000, 2100);
  7186. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7187. /* Wait 1 sec after enabling band gap bias */
  7188. usleep_range(1000000, 1000100);
  7189. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x1C);
  7190. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xFE);
  7191. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7192. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7193. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x00);
  7194. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x00);
  7195. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0A);
  7196. }
  7197. static void wcd_vbat_adc_out_config(struct wcd_vbat *vbat,
  7198. struct snd_soc_codec *codec)
  7199. {
  7200. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  7201. if (!vbat->adc_config) {
  7202. tasha_cdc_mclk_enable(codec, true, false);
  7203. if (TASHA_IS_2_0(wcd9xxx))
  7204. wcd_vbat_adc_out_config_2_0(vbat, codec);
  7205. else
  7206. wcd_vbat_adc_out_config_1_x(vbat, codec);
  7207. tasha_cdc_mclk_enable(codec, false, false);
  7208. vbat->adc_config = true;
  7209. }
  7210. }
  7211. static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec)
  7212. {
  7213. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7214. struct firmware_cal *hwdep_cal = NULL;
  7215. struct vbat_monitor_reg *vbat_reg_ptr = NULL;
  7216. const void *data;
  7217. size_t cal_size, vbat_size_remaining;
  7218. int ret = 0, i;
  7219. u32 vbat_writes_size = 0;
  7220. u16 reg;
  7221. u8 mask, val, old_val;
  7222. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_VBAT_CAL);
  7223. if (hwdep_cal) {
  7224. data = hwdep_cal->data;
  7225. cal_size = hwdep_cal->size;
  7226. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7227. __func__);
  7228. } else {
  7229. dev_err(codec->dev, "%s: Vbat cal not received\n",
  7230. __func__);
  7231. ret = -EINVAL;
  7232. goto done;
  7233. }
  7234. if (cal_size < sizeof(*vbat_reg_ptr)) {
  7235. dev_err(codec->dev,
  7236. "%s: Incorrect size %zd for Vbat Cal, expected %zd\n",
  7237. __func__, cal_size, sizeof(*vbat_reg_ptr));
  7238. ret = -EINVAL;
  7239. goto done;
  7240. }
  7241. vbat_reg_ptr = (struct vbat_monitor_reg *) (data);
  7242. if (!vbat_reg_ptr) {
  7243. dev_err(codec->dev,
  7244. "%s: Invalid calibration data for Vbat\n",
  7245. __func__);
  7246. ret = -EINVAL;
  7247. goto done;
  7248. }
  7249. vbat_writes_size = vbat_reg_ptr->size;
  7250. vbat_size_remaining = cal_size - sizeof(u32);
  7251. dev_dbg(codec->dev, "%s: vbat_writes_sz: %d, vbat_sz_remaining: %zd\n",
  7252. __func__, vbat_writes_size, vbat_size_remaining);
  7253. if ((vbat_writes_size * TASHA_PACKED_REG_SIZE)
  7254. > vbat_size_remaining) {
  7255. pr_err("%s: Incorrect Vbat calibration data\n", __func__);
  7256. ret = -EINVAL;
  7257. goto done;
  7258. }
  7259. for (i = 0 ; i < vbat_writes_size; i++) {
  7260. TASHA_CODEC_UNPACK_ENTRY(vbat_reg_ptr->writes[i],
  7261. reg, mask, val);
  7262. old_val = snd_soc_read(codec, reg);
  7263. snd_soc_write(codec, reg, (old_val & ~mask) | (val & mask));
  7264. }
  7265. done:
  7266. return ret;
  7267. }
  7268. static int tasha_vbat_adc_data_get(struct snd_kcontrol *kcontrol,
  7269. struct snd_ctl_elem_value *ucontrol)
  7270. {
  7271. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7272. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7273. wcd_vbat_adc_out_config(&tasha->vbat, codec);
  7274. ucontrol->value.integer.value[0] = tasha->vbat.dcp1;
  7275. ucontrol->value.integer.value[1] = tasha->vbat.dcp2;
  7276. dev_dbg(codec->dev,
  7277. "%s: Vbat ADC output values, Dcp1 : %lu, Dcp2: %lu\n",
  7278. __func__, ucontrol->value.integer.value[0],
  7279. ucontrol->value.integer.value[1]);
  7280. return 0;
  7281. }
  7282. static const char * const tasha_vbat_gsm_mode_text[] = {
  7283. "OFF", "ON"};
  7284. static const struct soc_enum tasha_vbat_gsm_mode_enum =
  7285. SOC_ENUM_SINGLE_EXT(2, tasha_vbat_gsm_mode_text);
  7286. static int tasha_vbat_gsm_mode_func_get(struct snd_kcontrol *kcontrol,
  7287. struct snd_ctl_elem_value *ucontrol)
  7288. {
  7289. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7290. ucontrol->value.integer.value[0] =
  7291. ((snd_soc_read(codec, WCD9335_CDC_VBAT_VBAT_CFG) & 0x04) ?
  7292. 1 : 0);
  7293. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7294. ucontrol->value.integer.value[0]);
  7295. return 0;
  7296. }
  7297. static int tasha_vbat_gsm_mode_func_put(struct snd_kcontrol *kcontrol,
  7298. struct snd_ctl_elem_value *ucontrol)
  7299. {
  7300. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7301. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7302. ucontrol->value.integer.value[0]);
  7303. /* Set Vbat register configuration for GSM mode bit based on value */
  7304. if (ucontrol->value.integer.value[0])
  7305. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7306. 0x04, 0x04);
  7307. else
  7308. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7309. 0x04, 0x00);
  7310. return 0;
  7311. }
  7312. static int tasha_codec_vbat_enable_event(struct snd_soc_dapm_widget *w,
  7313. struct snd_kcontrol *kcontrol,
  7314. int event)
  7315. {
  7316. int ret = 0;
  7317. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7318. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7319. u16 vbat_path_ctl, vbat_cfg, vbat_path_cfg;
  7320. vbat_path_ctl = WCD9335_CDC_VBAT_VBAT_PATH_CTL;
  7321. vbat_cfg = WCD9335_CDC_VBAT_VBAT_CFG;
  7322. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7323. if (!strcmp(w->name, "RX INT8 VBAT"))
  7324. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7325. else if (!strcmp(w->name, "RX INT7 VBAT"))
  7326. vbat_path_cfg = WCD9335_CDC_RX7_RX_PATH_CFG1;
  7327. else if (!strcmp(w->name, "RX INT6 VBAT"))
  7328. vbat_path_cfg = WCD9335_CDC_RX6_RX_PATH_CFG1;
  7329. else if (!strcmp(w->name, "RX INT5 VBAT"))
  7330. vbat_path_cfg = WCD9335_CDC_RX5_RX_PATH_CFG1;
  7331. switch (event) {
  7332. case SND_SOC_DAPM_PRE_PMU:
  7333. ret = tasha_update_vbat_reg_config(codec);
  7334. if (ret) {
  7335. dev_dbg(codec->dev,
  7336. "%s : VBAT isn't calibrated, So not enabling it\n",
  7337. __func__);
  7338. return 0;
  7339. }
  7340. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7341. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x02);
  7342. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x10);
  7343. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x01);
  7344. tasha->vbat.is_enabled = true;
  7345. break;
  7346. case SND_SOC_DAPM_POST_PMD:
  7347. if (tasha->vbat.is_enabled) {
  7348. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x00);
  7349. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x00);
  7350. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x00);
  7351. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7352. tasha->vbat.is_enabled = false;
  7353. }
  7354. break;
  7355. };
  7356. return ret;
  7357. }
  7358. static const char * const rx_hph_mode_mux_text[] = {
  7359. "CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI"
  7360. };
  7361. static const struct soc_enum rx_hph_mode_mux_enum =
  7362. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text),
  7363. rx_hph_mode_mux_text);
  7364. static const char * const amic_pwr_lvl_text[] = {
  7365. "LOW_PWR", "DEFAULT", "HIGH_PERF"
  7366. };
  7367. static const struct soc_enum amic_pwr_lvl_enum =
  7368. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amic_pwr_lvl_text),
  7369. amic_pwr_lvl_text);
  7370. static const struct snd_kcontrol_new tasha_snd_controls[] = {
  7371. SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
  7372. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7373. SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
  7374. 0, -84, 40, digital_gain),
  7375. SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
  7376. 0, -84, 40, digital_gain),
  7377. SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
  7378. 0, -84, 40, digital_gain),
  7379. SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
  7380. 0, -84, 40, digital_gain),
  7381. SOC_SINGLE_SX_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
  7382. 0, -84, 40, digital_gain),
  7383. SOC_SINGLE_SX_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
  7384. 0, -84, 40, digital_gain),
  7385. SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
  7386. 0, -84, 40, digital_gain),
  7387. SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
  7388. 0, -84, 40, digital_gain),
  7389. SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
  7390. WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
  7391. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7392. SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
  7393. WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
  7394. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7395. SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
  7396. WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
  7397. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7398. SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
  7399. WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
  7400. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7401. SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
  7402. WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
  7403. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7404. SOC_SINGLE_SX_TLV("RX5 Mix Digital Volume",
  7405. WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
  7406. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7407. SOC_SINGLE_SX_TLV("RX6 Mix Digital Volume",
  7408. WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
  7409. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7410. SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
  7411. WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
  7412. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7413. SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
  7414. WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
  7415. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7416. SOC_SINGLE_SX_TLV("DEC0 Volume", WCD9335_CDC_TX0_TX_VOL_CTL, 0,
  7417. -84, 40, digital_gain),
  7418. SOC_SINGLE_SX_TLV("DEC1 Volume", WCD9335_CDC_TX1_TX_VOL_CTL, 0,
  7419. -84, 40, digital_gain),
  7420. SOC_SINGLE_SX_TLV("DEC2 Volume", WCD9335_CDC_TX2_TX_VOL_CTL, 0,
  7421. -84, 40, digital_gain),
  7422. SOC_SINGLE_SX_TLV("DEC3 Volume", WCD9335_CDC_TX3_TX_VOL_CTL, 0,
  7423. -84, 40, digital_gain),
  7424. SOC_SINGLE_SX_TLV("DEC4 Volume", WCD9335_CDC_TX4_TX_VOL_CTL, 0,
  7425. -84, 40, digital_gain),
  7426. SOC_SINGLE_SX_TLV("DEC5 Volume", WCD9335_CDC_TX5_TX_VOL_CTL, 0,
  7427. -84, 40, digital_gain),
  7428. SOC_SINGLE_SX_TLV("DEC6 Volume", WCD9335_CDC_TX6_TX_VOL_CTL, 0,
  7429. -84, 40, digital_gain),
  7430. SOC_SINGLE_SX_TLV("DEC7 Volume", WCD9335_CDC_TX7_TX_VOL_CTL, 0,
  7431. -84, 40, digital_gain),
  7432. SOC_SINGLE_SX_TLV("DEC8 Volume", WCD9335_CDC_TX8_TX_VOL_CTL, 0,
  7433. -84, 40, digital_gain),
  7434. SOC_SINGLE_SX_TLV("IIR0 INP0 Volume",
  7435. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, -84,
  7436. 40, digital_gain),
  7437. SOC_SINGLE_SX_TLV("IIR0 INP1 Volume",
  7438. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, -84,
  7439. 40, digital_gain),
  7440. SOC_SINGLE_SX_TLV("IIR0 INP2 Volume",
  7441. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, -84,
  7442. 40, digital_gain),
  7443. SOC_SINGLE_SX_TLV("IIR0 INP3 Volume",
  7444. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, -84,
  7445. 40, digital_gain),
  7446. SOC_SINGLE_SX_TLV("IIR1 INP0 Volume",
  7447. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, -84,
  7448. 40, digital_gain),
  7449. SOC_SINGLE_SX_TLV("IIR1 INP1 Volume",
  7450. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, -84,
  7451. 40, digital_gain),
  7452. SOC_SINGLE_SX_TLV("IIR1 INP2 Volume",
  7453. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, -84,
  7454. 40, digital_gain),
  7455. SOC_SINGLE_SX_TLV("IIR1 INP3 Volume",
  7456. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, -84,
  7457. 40, digital_gain),
  7458. SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 100, 0, tasha_get_anc_slot,
  7459. tasha_put_anc_slot),
  7460. SOC_ENUM_EXT("ANC Function", tasha_anc_func_enum, tasha_get_anc_func,
  7461. tasha_put_anc_func),
  7462. SOC_ENUM_EXT("CLK MODE", tasha_clkmode_enum, tasha_get_clkmode,
  7463. tasha_put_clkmode),
  7464. SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
  7465. SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
  7466. SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
  7467. SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
  7468. SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
  7469. SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
  7470. SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
  7471. SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
  7472. SOC_ENUM("TX8 HPF cut off", cf_dec8_enum),
  7473. SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
  7474. SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
  7475. SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
  7476. SOC_ENUM("RX INT1_2 HPF cut off", cf_int1_2_enum),
  7477. SOC_ENUM("RX INT2_1 HPF cut off", cf_int2_1_enum),
  7478. SOC_ENUM("RX INT2_2 HPF cut off", cf_int2_2_enum),
  7479. SOC_ENUM("RX INT3_1 HPF cut off", cf_int3_1_enum),
  7480. SOC_ENUM("RX INT3_2 HPF cut off", cf_int3_2_enum),
  7481. SOC_ENUM("RX INT4_1 HPF cut off", cf_int4_1_enum),
  7482. SOC_ENUM("RX INT4_2 HPF cut off", cf_int4_2_enum),
  7483. SOC_ENUM("RX INT5_1 HPF cut off", cf_int5_1_enum),
  7484. SOC_ENUM("RX INT5_2 HPF cut off", cf_int5_2_enum),
  7485. SOC_ENUM("RX INT6_1 HPF cut off", cf_int6_1_enum),
  7486. SOC_ENUM("RX INT6_2 HPF cut off", cf_int6_2_enum),
  7487. SOC_ENUM("RX INT7_1 HPF cut off", cf_int7_1_enum),
  7488. SOC_ENUM("RX INT7_2 HPF cut off", cf_int7_2_enum),
  7489. SOC_ENUM("RX INT8_1 HPF cut off", cf_int8_1_enum),
  7490. SOC_ENUM("RX INT8_2 HPF cut off", cf_int8_2_enum),
  7491. SOC_SINGLE_EXT("IIR0 Enable Band1", IIR0, BAND1, 1, 0,
  7492. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7493. SOC_SINGLE_EXT("IIR0 Enable Band2", IIR0, BAND2, 1, 0,
  7494. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7495. SOC_SINGLE_EXT("IIR0 Enable Band3", IIR0, BAND3, 1, 0,
  7496. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7497. SOC_SINGLE_EXT("IIR0 Enable Band4", IIR0, BAND4, 1, 0,
  7498. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7499. SOC_SINGLE_EXT("IIR0 Enable Band5", IIR0, BAND5, 1, 0,
  7500. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7501. SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0,
  7502. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7503. SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
  7504. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7505. SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
  7506. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7507. SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
  7508. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7509. SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
  7510. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7511. SOC_SINGLE_MULTI_EXT("IIR0 Band1", IIR0, BAND1, 255, 0, 5,
  7512. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7513. SOC_SINGLE_MULTI_EXT("IIR0 Band2", IIR0, BAND2, 255, 0, 5,
  7514. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7515. SOC_SINGLE_MULTI_EXT("IIR0 Band3", IIR0, BAND3, 255, 0, 5,
  7516. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7517. SOC_SINGLE_MULTI_EXT("IIR0 Band4", IIR0, BAND4, 255, 0, 5,
  7518. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7519. SOC_SINGLE_MULTI_EXT("IIR0 Band5", IIR0, BAND5, 255, 0, 5,
  7520. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7521. SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
  7522. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7523. SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
  7524. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7525. SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
  7526. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7527. SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
  7528. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7529. SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
  7530. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7531. SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0,
  7532. tasha_get_compander, tasha_set_compander),
  7533. SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0,
  7534. tasha_get_compander, tasha_set_compander),
  7535. SOC_SINGLE_EXT("COMP3 Switch", SND_SOC_NOPM, COMPANDER_3, 1, 0,
  7536. tasha_get_compander, tasha_set_compander),
  7537. SOC_SINGLE_EXT("COMP4 Switch", SND_SOC_NOPM, COMPANDER_4, 1, 0,
  7538. tasha_get_compander, tasha_set_compander),
  7539. SOC_SINGLE_EXT("COMP5 Switch", SND_SOC_NOPM, COMPANDER_5, 1, 0,
  7540. tasha_get_compander, tasha_set_compander),
  7541. SOC_SINGLE_EXT("COMP6 Switch", SND_SOC_NOPM, COMPANDER_6, 1, 0,
  7542. tasha_get_compander, tasha_set_compander),
  7543. SOC_SINGLE_EXT("COMP7 Switch", SND_SOC_NOPM, COMPANDER_7, 1, 0,
  7544. tasha_get_compander, tasha_set_compander),
  7545. SOC_SINGLE_EXT("COMP8 Switch", SND_SOC_NOPM, COMPANDER_8, 1, 0,
  7546. tasha_get_compander, tasha_set_compander),
  7547. SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum,
  7548. tasha_rx_hph_mode_get, tasha_rx_hph_mode_put),
  7549. SOC_ENUM_EXT("MAD Input", tasha_conn_mad_enum,
  7550. tasha_mad_input_get, tasha_mad_input_put),
  7551. SOC_SINGLE_EXT("LDO_H Enable", SND_SOC_NOPM, 0, 1, 0,
  7552. tasha_enable_ldo_h_get, tasha_enable_ldo_h_put),
  7553. SOC_SINGLE_EXT("DMIC1_CLK_PIN_MODE", SND_SOC_NOPM, 17, 1, 0,
  7554. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7555. SOC_SINGLE_EXT("DMIC1_DATA_PIN_MODE", SND_SOC_NOPM, 18, 1, 0,
  7556. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7557. SOC_SINGLE_EXT("DMIC2_CLK_PIN_MODE", SND_SOC_NOPM, 19, 1, 0,
  7558. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7559. SOC_SINGLE_EXT("DMIC2_DATA_PIN_MODE", SND_SOC_NOPM, 20, 1, 0,
  7560. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7561. SOC_SINGLE_EXT("DMIC3_CLK_PIN_MODE", SND_SOC_NOPM, 21, 1, 0,
  7562. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7563. SOC_SINGLE_EXT("DMIC3_DATA_PIN_MODE", SND_SOC_NOPM, 22, 1, 0,
  7564. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7565. SOC_ENUM_EXT("AMIC_1_2 PWR MODE", amic_pwr_lvl_enum,
  7566. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7567. SOC_ENUM_EXT("AMIC_3_4 PWR MODE", amic_pwr_lvl_enum,
  7568. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7569. SOC_ENUM_EXT("AMIC_5_6 PWR MODE", amic_pwr_lvl_enum,
  7570. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7571. SOC_SINGLE_MULTI_EXT("Vbat ADC data", SND_SOC_NOPM, 0, 0xFFFF, 0, 2,
  7572. tasha_vbat_adc_data_get, NULL),
  7573. SOC_ENUM_EXT("GSM mode Enable", tasha_vbat_gsm_mode_enum,
  7574. tasha_vbat_gsm_mode_func_get,
  7575. tasha_vbat_gsm_mode_func_put),
  7576. };
  7577. static int tasha_put_dec_enum(struct snd_kcontrol *kcontrol,
  7578. struct snd_ctl_elem_value *ucontrol)
  7579. {
  7580. struct snd_soc_dapm_widget *widget =
  7581. snd_soc_dapm_kcontrol_widget(kcontrol);
  7582. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7583. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7584. unsigned int val;
  7585. u16 mic_sel_reg;
  7586. u8 mic_sel;
  7587. val = ucontrol->value.enumerated.item[0];
  7588. if (val > e->items - 1)
  7589. return -EINVAL;
  7590. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7591. widget->name, val);
  7592. switch (e->reg) {
  7593. case WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1:
  7594. mic_sel_reg = WCD9335_CDC_TX0_TX_PATH_CFG0;
  7595. break;
  7596. case WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1:
  7597. mic_sel_reg = WCD9335_CDC_TX1_TX_PATH_CFG0;
  7598. break;
  7599. case WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1:
  7600. mic_sel_reg = WCD9335_CDC_TX2_TX_PATH_CFG0;
  7601. break;
  7602. case WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1:
  7603. mic_sel_reg = WCD9335_CDC_TX3_TX_PATH_CFG0;
  7604. break;
  7605. case WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0:
  7606. mic_sel_reg = WCD9335_CDC_TX4_TX_PATH_CFG0;
  7607. break;
  7608. case WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0:
  7609. mic_sel_reg = WCD9335_CDC_TX5_TX_PATH_CFG0;
  7610. break;
  7611. case WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0:
  7612. mic_sel_reg = WCD9335_CDC_TX6_TX_PATH_CFG0;
  7613. break;
  7614. case WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0:
  7615. mic_sel_reg = WCD9335_CDC_TX7_TX_PATH_CFG0;
  7616. break;
  7617. case WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0:
  7618. mic_sel_reg = WCD9335_CDC_TX8_TX_PATH_CFG0;
  7619. break;
  7620. default:
  7621. dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n",
  7622. __func__, e->reg);
  7623. return -EINVAL;
  7624. }
  7625. /* ADC: 0, DMIC: 1 */
  7626. mic_sel = val ? 0x0 : 0x1;
  7627. snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, mic_sel << 7);
  7628. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7629. }
  7630. static int tasha_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol,
  7631. struct snd_ctl_elem_value *ucontrol)
  7632. {
  7633. struct snd_soc_dapm_widget *widget =
  7634. snd_soc_dapm_kcontrol_widget(kcontrol);
  7635. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7636. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7637. unsigned int val;
  7638. unsigned short look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7639. val = ucontrol->value.enumerated.item[0];
  7640. if (val >= e->items)
  7641. return -EINVAL;
  7642. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7643. widget->name, val);
  7644. if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0)
  7645. look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7646. else if (e->reg == WCD9335_CDC_RX1_RX_PATH_SEC0)
  7647. look_ahead_dly_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  7648. else if (e->reg == WCD9335_CDC_RX2_RX_PATH_SEC0)
  7649. look_ahead_dly_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  7650. /* Set Look Ahead Delay */
  7651. snd_soc_update_bits(codec, look_ahead_dly_reg,
  7652. 0x08, (val ? 0x08 : 0x00));
  7653. /* Set DEM INP Select */
  7654. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7655. }
  7656. static int tasha_ear_pa_gain_get(struct snd_kcontrol *kcontrol,
  7657. struct snd_ctl_elem_value *ucontrol)
  7658. {
  7659. u8 ear_pa_gain;
  7660. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7661. ear_pa_gain = snd_soc_read(codec, WCD9335_ANA_EAR);
  7662. ear_pa_gain = (ear_pa_gain & 0x70) >> 4;
  7663. ucontrol->value.integer.value[0] = ear_pa_gain;
  7664. dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__,
  7665. ear_pa_gain);
  7666. return 0;
  7667. }
  7668. static int tasha_ear_pa_gain_put(struct snd_kcontrol *kcontrol,
  7669. struct snd_ctl_elem_value *ucontrol)
  7670. {
  7671. u8 ear_pa_gain;
  7672. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7673. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7674. __func__, ucontrol->value.integer.value[0]);
  7675. ear_pa_gain = ucontrol->value.integer.value[0] << 4;
  7676. snd_soc_update_bits(codec, WCD9335_ANA_EAR, 0x70, ear_pa_gain);
  7677. return 0;
  7678. }
  7679. static int tasha_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
  7680. struct snd_ctl_elem_value *ucontrol)
  7681. {
  7682. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7683. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7684. ucontrol->value.integer.value[0] = tasha->ear_spkr_gain;
  7685. dev_dbg(codec->dev, "%s: ear_spkr_gain = %ld\n", __func__,
  7686. ucontrol->value.integer.value[0]);
  7687. return 0;
  7688. }
  7689. static int tasha_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
  7690. struct snd_ctl_elem_value *ucontrol)
  7691. {
  7692. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7693. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7694. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7695. __func__, ucontrol->value.integer.value[0]);
  7696. tasha->ear_spkr_gain = ucontrol->value.integer.value[0];
  7697. return 0;
  7698. }
  7699. static int tasha_spkr_left_boost_stage_get(struct snd_kcontrol *kcontrol,
  7700. struct snd_ctl_elem_value *ucontrol)
  7701. {
  7702. u8 bst_state_max = 0;
  7703. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7704. bst_state_max = snd_soc_read(codec, WCD9335_CDC_BOOST0_BOOST_CTL);
  7705. bst_state_max = (bst_state_max & 0x0c) >> 2;
  7706. ucontrol->value.integer.value[0] = bst_state_max;
  7707. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7708. __func__, ucontrol->value.integer.value[0]);
  7709. return 0;
  7710. }
  7711. static int tasha_spkr_left_boost_stage_put(struct snd_kcontrol *kcontrol,
  7712. struct snd_ctl_elem_value *ucontrol)
  7713. {
  7714. u8 bst_state_max;
  7715. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7716. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7717. __func__, ucontrol->value.integer.value[0]);
  7718. bst_state_max = ucontrol->value.integer.value[0] << 2;
  7719. snd_soc_update_bits(codec, WCD9335_CDC_BOOST0_BOOST_CTL,
  7720. 0x0c, bst_state_max);
  7721. return 0;
  7722. }
  7723. static int tasha_spkr_right_boost_stage_get(struct snd_kcontrol *kcontrol,
  7724. struct snd_ctl_elem_value *ucontrol)
  7725. {
  7726. u8 bst_state_max = 0;
  7727. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7728. bst_state_max = snd_soc_read(codec, WCD9335_CDC_BOOST1_BOOST_CTL);
  7729. bst_state_max = (bst_state_max & 0x0c) >> 2;
  7730. ucontrol->value.integer.value[0] = bst_state_max;
  7731. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7732. __func__, ucontrol->value.integer.value[0]);
  7733. return 0;
  7734. }
  7735. static int tasha_spkr_right_boost_stage_put(struct snd_kcontrol *kcontrol,
  7736. struct snd_ctl_elem_value *ucontrol)
  7737. {
  7738. u8 bst_state_max;
  7739. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7740. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7741. __func__, ucontrol->value.integer.value[0]);
  7742. bst_state_max = ucontrol->value.integer.value[0] << 2;
  7743. snd_soc_update_bits(codec, WCD9335_CDC_BOOST1_BOOST_CTL,
  7744. 0x0c, bst_state_max);
  7745. return 0;
  7746. }
  7747. static int tasha_config_compander(struct snd_soc_codec *codec, int interp_n,
  7748. int event)
  7749. {
  7750. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7751. int comp;
  7752. u16 comp_ctl0_reg, rx_path_cfg0_reg;
  7753. /* EAR does not have compander */
  7754. if (!interp_n)
  7755. return 0;
  7756. comp = interp_n - 1;
  7757. dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n",
  7758. __func__, event, comp + 1, tasha->comp_enabled[comp]);
  7759. if (!tasha->comp_enabled[comp])
  7760. return 0;
  7761. comp_ctl0_reg = WCD9335_CDC_COMPANDER1_CTL0 + (comp * 8);
  7762. rx_path_cfg0_reg = WCD9335_CDC_RX1_RX_PATH_CFG0 + (comp * 20);
  7763. if (SND_SOC_DAPM_EVENT_ON(event)) {
  7764. /* Enable Compander Clock */
  7765. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01);
  7766. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7767. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7768. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02);
  7769. }
  7770. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  7771. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04);
  7772. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00);
  7773. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7774. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7775. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00);
  7776. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00);
  7777. }
  7778. return 0;
  7779. }
  7780. static int tasha_codec_config_mad(struct snd_soc_codec *codec)
  7781. {
  7782. int ret = 0;
  7783. int idx;
  7784. const struct firmware *fw;
  7785. struct firmware_cal *hwdep_cal = NULL;
  7786. struct wcd_mad_audio_cal *mad_cal = NULL;
  7787. const void *data;
  7788. const char *filename = TASHA_MAD_AUDIO_FIRMWARE_PATH;
  7789. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7790. size_t cal_size;
  7791. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_MAD_CAL);
  7792. if (hwdep_cal) {
  7793. data = hwdep_cal->data;
  7794. cal_size = hwdep_cal->size;
  7795. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7796. __func__);
  7797. } else {
  7798. ret = request_firmware(&fw, filename, codec->dev);
  7799. if (ret || !fw) {
  7800. dev_err(codec->dev,
  7801. "%s: MAD firmware acquire failed, err = %d\n",
  7802. __func__, ret);
  7803. return -ENODEV;
  7804. }
  7805. data = fw->data;
  7806. cal_size = fw->size;
  7807. dev_dbg(codec->dev, "%s: using request_firmware calibration\n",
  7808. __func__);
  7809. }
  7810. if (cal_size < sizeof(*mad_cal)) {
  7811. dev_err(codec->dev,
  7812. "%s: Incorrect size %zd for MAD Cal, expected %zd\n",
  7813. __func__, cal_size, sizeof(*mad_cal));
  7814. ret = -ENOMEM;
  7815. goto done;
  7816. }
  7817. mad_cal = (struct wcd_mad_audio_cal *) (data);
  7818. if (!mad_cal) {
  7819. dev_err(codec->dev,
  7820. "%s: Invalid calibration data\n",
  7821. __func__);
  7822. ret = -EINVAL;
  7823. goto done;
  7824. }
  7825. snd_soc_write(codec, WCD9335_SOC_MAD_MAIN_CTL_2,
  7826. mad_cal->microphone_info.cycle_time);
  7827. snd_soc_update_bits(codec, WCD9335_SOC_MAD_MAIN_CTL_1, 0xFF << 3,
  7828. ((uint16_t)mad_cal->microphone_info.settle_time)
  7829. << 3);
  7830. /* Audio */
  7831. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_8,
  7832. mad_cal->audio_info.rms_omit_samples);
  7833. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_1,
  7834. 0x07 << 4, mad_cal->audio_info.rms_comp_time << 4);
  7835. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03 << 2,
  7836. mad_cal->audio_info.detection_mechanism << 2);
  7837. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_7,
  7838. mad_cal->audio_info.rms_diff_threshold & 0x3F);
  7839. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_5,
  7840. mad_cal->audio_info.rms_threshold_lsb);
  7841. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_6,
  7842. mad_cal->audio_info.rms_threshold_msb);
  7843. for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients);
  7844. idx++) {
  7845. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR,
  7846. 0x3F, idx);
  7847. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL,
  7848. mad_cal->audio_info.iir_coefficients[idx]);
  7849. dev_dbg(codec->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x",
  7850. __func__, idx,
  7851. mad_cal->audio_info.iir_coefficients[idx]);
  7852. }
  7853. /* Beacon */
  7854. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_8,
  7855. mad_cal->beacon_info.rms_omit_samples);
  7856. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_1,
  7857. 0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4);
  7858. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_2, 0x03 << 2,
  7859. mad_cal->beacon_info.detection_mechanism << 2);
  7860. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_7,
  7861. mad_cal->beacon_info.rms_diff_threshold & 0x1F);
  7862. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_5,
  7863. mad_cal->beacon_info.rms_threshold_lsb);
  7864. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_6,
  7865. mad_cal->beacon_info.rms_threshold_msb);
  7866. for (idx = 0; idx < ARRAY_SIZE(mad_cal->beacon_info.iir_coefficients);
  7867. idx++) {
  7868. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR,
  7869. 0x3F, idx);
  7870. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL,
  7871. mad_cal->beacon_info.iir_coefficients[idx]);
  7872. dev_dbg(codec->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x",
  7873. __func__, idx,
  7874. mad_cal->beacon_info.iir_coefficients[idx]);
  7875. }
  7876. /* Ultrasound */
  7877. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_1,
  7878. 0x07 << 4,
  7879. mad_cal->ultrasound_info.rms_comp_time << 4);
  7880. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_2, 0x03 << 2,
  7881. mad_cal->ultrasound_info.detection_mechanism << 2);
  7882. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_7,
  7883. mad_cal->ultrasound_info.rms_diff_threshold & 0x1F);
  7884. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_5,
  7885. mad_cal->ultrasound_info.rms_threshold_lsb);
  7886. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_6,
  7887. mad_cal->ultrasound_info.rms_threshold_msb);
  7888. done:
  7889. if (!hwdep_cal)
  7890. release_firmware(fw);
  7891. return ret;
  7892. }
  7893. static int tasha_codec_enable_mad(struct snd_soc_dapm_widget *w,
  7894. struct snd_kcontrol *kcontrol, int event)
  7895. {
  7896. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7897. int ret = 0;
  7898. dev_dbg(codec->dev,
  7899. "%s: event = %d\n", __func__, event);
  7900. /* Return if CPE INPUT is DEC1 */
  7901. if (snd_soc_read(codec, WCD9335_CPE_SS_SVA_CFG) & 0x01)
  7902. return ret;
  7903. switch (event) {
  7904. case SND_SOC_DAPM_PRE_PMU:
  7905. /* Turn on MAD clk */
  7906. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7907. 0x01, 0x01);
  7908. /* Undo reset for MAD */
  7909. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7910. 0x02, 0x00);
  7911. ret = tasha_codec_config_mad(codec);
  7912. if (ret)
  7913. dev_err(codec->dev,
  7914. "%s: Failed to config MAD, err = %d\n",
  7915. __func__, ret);
  7916. break;
  7917. case SND_SOC_DAPM_POST_PMD:
  7918. /* Reset the MAD block */
  7919. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7920. 0x02, 0x02);
  7921. /* Turn off MAD clk */
  7922. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7923. 0x01, 0x00);
  7924. break;
  7925. }
  7926. return ret;
  7927. }
  7928. static int tasha_codec_configure_cpe_input(struct snd_soc_dapm_widget *w,
  7929. struct snd_kcontrol *kcontrol, int event)
  7930. {
  7931. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7932. dev_dbg(codec->dev,
  7933. "%s: event = %d\n", __func__, event);
  7934. switch (event) {
  7935. case SND_SOC_DAPM_PRE_PMU:
  7936. /* Configure CPE input as DEC1 */
  7937. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7938. 0x01, 0x01);
  7939. /* Configure DEC1 Tx out with sample rate as 16K */
  7940. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7941. 0x0F, 0x01);
  7942. break;
  7943. case SND_SOC_DAPM_POST_PMD:
  7944. /* Reset DEC1 Tx out sample rate */
  7945. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7946. 0x0F, 0x04);
  7947. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7948. 0x01, 0x00);
  7949. break;
  7950. }
  7951. return 0;
  7952. }
  7953. static int tasha_codec_aif4_mixer_switch_get(struct snd_kcontrol *kcontrol,
  7954. struct snd_ctl_elem_value *ucontrol)
  7955. {
  7956. struct snd_soc_dapm_widget *widget =
  7957. snd_soc_dapm_kcontrol_widget(kcontrol);
  7958. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7959. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7960. if (test_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask))
  7961. ucontrol->value.integer.value[0] = 1;
  7962. else
  7963. ucontrol->value.integer.value[0] = 0;
  7964. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7965. __func__, ucontrol->value.integer.value[0]);
  7966. return 0;
  7967. }
  7968. static int tasha_codec_aif4_mixer_switch_put(struct snd_kcontrol *kcontrol,
  7969. struct snd_ctl_elem_value *ucontrol)
  7970. {
  7971. struct snd_soc_dapm_widget *widget =
  7972. snd_soc_dapm_kcontrol_widget(kcontrol);
  7973. struct snd_soc_dapm_update *update = NULL;
  7974. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7975. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7976. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7977. __func__, ucontrol->value.integer.value[0]);
  7978. if (ucontrol->value.integer.value[0]) {
  7979. snd_soc_dapm_mixer_update_power(widget->dapm,
  7980. kcontrol, 1, update);
  7981. set_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7982. } else {
  7983. snd_soc_dapm_mixer_update_power(widget->dapm,
  7984. kcontrol, 0, update);
  7985. clear_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7986. }
  7987. return 1;
  7988. }
  7989. static const char * const tasha_ear_pa_gain_text[] = {
  7990. "G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB",
  7991. "G_0_DB", "G_M2P5_DB", "UNDEFINED", "G_M12_DB"
  7992. };
  7993. static const char * const tasha_ear_spkr_pa_gain_text[] = {
  7994. "G_DEFAULT", "G_0_DB", "G_1_DB", "G_2_DB", "G_3_DB", "G_4_DB",
  7995. "G_5_DB", "G_6_DB"
  7996. };
  7997. static const char * const tasha_speaker_boost_stage_text[] = {
  7998. "NO_MAX_STATE", "MAX_STATE_1", "MAX_STATE_2"
  7999. };
  8000. static const struct soc_enum tasha_ear_pa_gain_enum =
  8001. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_pa_gain_text),
  8002. tasha_ear_pa_gain_text);
  8003. static const struct soc_enum tasha_ear_spkr_pa_gain_enum =
  8004. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_spkr_pa_gain_text),
  8005. tasha_ear_spkr_pa_gain_text);
  8006. static const struct soc_enum tasha_spkr_boost_stage_enum =
  8007. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_speaker_boost_stage_text),
  8008. tasha_speaker_boost_stage_text);
  8009. static const struct snd_kcontrol_new tasha_analog_gain_controls[] = {
  8010. SOC_ENUM_EXT("EAR PA Gain", tasha_ear_pa_gain_enum,
  8011. tasha_ear_pa_gain_get, tasha_ear_pa_gain_put),
  8012. SOC_SINGLE_TLV("HPHL Volume", WCD9335_HPH_L_EN, 0, 20, 1,
  8013. line_gain),
  8014. SOC_SINGLE_TLV("HPHR Volume", WCD9335_HPH_R_EN, 0, 20, 1,
  8015. line_gain),
  8016. SOC_SINGLE_TLV("LINEOUT1 Volume", WCD9335_DIFF_LO_LO1_COMPANDER,
  8017. 3, 16, 1, line_gain),
  8018. SOC_SINGLE_TLV("LINEOUT2 Volume", WCD9335_DIFF_LO_LO2_COMPANDER,
  8019. 3, 16, 1, line_gain),
  8020. SOC_SINGLE_TLV("LINEOUT3 Volume", WCD9335_SE_LO_LO3_GAIN, 0, 20, 1,
  8021. line_gain),
  8022. SOC_SINGLE_TLV("LINEOUT4 Volume", WCD9335_SE_LO_LO4_GAIN, 0, 20, 1,
  8023. line_gain),
  8024. SOC_SINGLE_TLV("ADC1 Volume", WCD9335_ANA_AMIC1, 0, 20, 0,
  8025. analog_gain),
  8026. SOC_SINGLE_TLV("ADC2 Volume", WCD9335_ANA_AMIC2, 0, 20, 0,
  8027. analog_gain),
  8028. SOC_SINGLE_TLV("ADC3 Volume", WCD9335_ANA_AMIC3, 0, 20, 0,
  8029. analog_gain),
  8030. SOC_SINGLE_TLV("ADC4 Volume", WCD9335_ANA_AMIC4, 0, 20, 0,
  8031. analog_gain),
  8032. SOC_SINGLE_TLV("ADC5 Volume", WCD9335_ANA_AMIC5, 0, 20, 0,
  8033. analog_gain),
  8034. SOC_SINGLE_TLV("ADC6 Volume", WCD9335_ANA_AMIC6, 0, 20, 0,
  8035. analog_gain),
  8036. };
  8037. static const struct snd_kcontrol_new tasha_spkr_wsa_controls[] = {
  8038. SOC_ENUM_EXT("EAR SPKR PA Gain", tasha_ear_spkr_pa_gain_enum,
  8039. tasha_ear_spkr_pa_gain_get, tasha_ear_spkr_pa_gain_put),
  8040. SOC_ENUM_EXT("SPKR Left Boost Max State", tasha_spkr_boost_stage_enum,
  8041. tasha_spkr_left_boost_stage_get,
  8042. tasha_spkr_left_boost_stage_put),
  8043. SOC_ENUM_EXT("SPKR Right Boost Max State", tasha_spkr_boost_stage_enum,
  8044. tasha_spkr_right_boost_stage_get,
  8045. tasha_spkr_right_boost_stage_put),
  8046. };
  8047. static const char * const spl_src0_mux_text[] = {
  8048. "ZERO", "SRC_IN_HPHL", "SRC_IN_LO1",
  8049. };
  8050. static const char * const spl_src1_mux_text[] = {
  8051. "ZERO", "SRC_IN_HPHR", "SRC_IN_LO2",
  8052. };
  8053. static const char * const spl_src2_mux_text[] = {
  8054. "ZERO", "SRC_IN_LO3", "SRC_IN_SPKRL",
  8055. };
  8056. static const char * const spl_src3_mux_text[] = {
  8057. "ZERO", "SRC_IN_LO4", "SRC_IN_SPKRR",
  8058. };
  8059. static const char * const rx_int0_7_mix_mux_text[] = {
  8060. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  8061. "RX6", "RX7", "PROXIMITY"
  8062. };
  8063. static const char * const rx_int_mix_mux_text[] = {
  8064. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  8065. "RX6", "RX7"
  8066. };
  8067. static const char * const rx_prim_mix_text[] = {
  8068. "ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2",
  8069. "RX3", "RX4", "RX5", "RX6", "RX7"
  8070. };
  8071. static const char * const rx_sidetone_mix_text[] = {
  8072. "ZERO", "SRC0", "SRC1", "SRC_SUM"
  8073. };
  8074. static const char * const sb_tx0_mux_text[] = {
  8075. "ZERO", "RX_MIX_TX0", "DEC0", "DEC0_192"
  8076. };
  8077. static const char * const sb_tx1_mux_text[] = {
  8078. "ZERO", "RX_MIX_TX1", "DEC1", "DEC1_192"
  8079. };
  8080. static const char * const sb_tx2_mux_text[] = {
  8081. "ZERO", "RX_MIX_TX2", "DEC2", "DEC2_192"
  8082. };
  8083. static const char * const sb_tx3_mux_text[] = {
  8084. "ZERO", "RX_MIX_TX3", "DEC3", "DEC3_192"
  8085. };
  8086. static const char * const sb_tx4_mux_text[] = {
  8087. "ZERO", "RX_MIX_TX4", "DEC4", "DEC4_192"
  8088. };
  8089. static const char * const sb_tx5_mux_text[] = {
  8090. "ZERO", "RX_MIX_TX5", "DEC5", "DEC5_192"
  8091. };
  8092. static const char * const sb_tx6_mux_text[] = {
  8093. "ZERO", "RX_MIX_TX6", "DEC6", "DEC6_192"
  8094. };
  8095. static const char * const sb_tx7_mux_text[] = {
  8096. "ZERO", "RX_MIX_TX7", "DEC7", "DEC7_192"
  8097. };
  8098. static const char * const sb_tx8_mux_text[] = {
  8099. "ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192"
  8100. };
  8101. static const char * const sb_tx9_mux_text[] = {
  8102. "ZERO", "DEC7", "DEC7_192"
  8103. };
  8104. static const char * const sb_tx10_mux_text[] = {
  8105. "ZERO", "DEC6", "DEC6_192"
  8106. };
  8107. static const char * const sb_tx11_mux_text[] = {
  8108. "DEC_0_5", "DEC_9_12", "MAD_AUDIO", "MAD_BRDCST"
  8109. };
  8110. static const char * const sb_tx11_inp1_mux_text[] = {
  8111. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4",
  8112. "DEC5", "RX_MIX_TX5", "DEC9_10", "DEC11_12"
  8113. };
  8114. static const char * const sb_tx13_mux_text[] = {
  8115. "ZERO", "DEC5", "DEC5_192"
  8116. };
  8117. static const char * const tx13_inp_mux_text[] = {
  8118. "CDC_DEC_5", "MAD_BRDCST", "CPE_TX_PP"
  8119. };
  8120. static const char * const iir_inp_mux_text[] = {
  8121. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6",
  8122. "DEC7", "DEC8", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7"
  8123. };
  8124. static const char * const rx_int_dem_inp_mux_text[] = {
  8125. "NORMAL_DSM_OUT", "CLSH_DSM_OUT",
  8126. };
  8127. static const char * const rx_int0_interp_mux_text[] = {
  8128. "ZERO", "RX INT0 MIX2",
  8129. };
  8130. static const char * const rx_int1_interp_mux_text[] = {
  8131. "ZERO", "RX INT1 MIX2",
  8132. };
  8133. static const char * const rx_int2_interp_mux_text[] = {
  8134. "ZERO", "RX INT2 MIX2",
  8135. };
  8136. static const char * const rx_int3_interp_mux_text[] = {
  8137. "ZERO", "RX INT3 MIX2",
  8138. };
  8139. static const char * const rx_int4_interp_mux_text[] = {
  8140. "ZERO", "RX INT4 MIX2",
  8141. };
  8142. static const char * const rx_int5_interp_mux_text[] = {
  8143. "ZERO", "RX INT5 MIX2",
  8144. };
  8145. static const char * const rx_int6_interp_mux_text[] = {
  8146. "ZERO", "RX INT6 MIX2",
  8147. };
  8148. static const char * const rx_int7_interp_mux_text[] = {
  8149. "ZERO", "RX INT7 MIX2",
  8150. };
  8151. static const char * const rx_int8_interp_mux_text[] = {
  8152. "ZERO", "RX INT8 SEC MIX"
  8153. };
  8154. static const char * const mad_sel_text[] = {
  8155. "SPE", "MSM"
  8156. };
  8157. static const char * const adc_mux_text[] = {
  8158. "DMIC", "AMIC", "ANC_FB_TUNE1", "ANC_FB_TUNE2"
  8159. };
  8160. static const char * const dmic_mux_text[] = {
  8161. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8162. "SMIC0", "SMIC1", "SMIC2", "SMIC3"
  8163. };
  8164. static const char * const dmic_mux_alt_text[] = {
  8165. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8166. };
  8167. static const char * const amic_mux_text[] = {
  8168. "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6"
  8169. };
  8170. static const char * const rx_echo_mux_text[] = {
  8171. "ZERO", "RX_MIX0", "RX_MIX1", "RX_MIX2", "RX_MIX3", "RX_MIX4",
  8172. "RX_MIX5", "RX_MIX6", "RX_MIX7", "RX_MIX8", "RX_MIX_VBAT5",
  8173. "RX_MIX_VBAT6", "RX_MIX_VBAT7", "RX_MIX_VBAT8"
  8174. };
  8175. static const char * const anc0_fb_mux_text[] = {
  8176. "ZERO", "ANC_IN_HPHL", "ANC_IN_EAR", "ANC_IN_EAR_SPKR",
  8177. "ANC_IN_LO1"
  8178. };
  8179. static const char * const anc1_fb_mux_text[] = {
  8180. "ZERO", "ANC_IN_HPHR", "ANC_IN_LO2"
  8181. };
  8182. static const char * const native_mux_text[] = {
  8183. "OFF", "ON",
  8184. };
  8185. static const struct soc_enum spl_src0_mux_chain_enum =
  8186. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 0, 3,
  8187. spl_src0_mux_text);
  8188. static const struct soc_enum spl_src1_mux_chain_enum =
  8189. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 2, 3,
  8190. spl_src1_mux_text);
  8191. static const struct soc_enum spl_src2_mux_chain_enum =
  8192. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 4, 3,
  8193. spl_src2_mux_text);
  8194. static const struct soc_enum spl_src3_mux_chain_enum =
  8195. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 6, 3,
  8196. spl_src3_mux_text);
  8197. static const struct soc_enum rx_int0_2_mux_chain_enum =
  8198. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 0, 10,
  8199. rx_int0_7_mix_mux_text);
  8200. static const struct soc_enum rx_int1_2_mux_chain_enum =
  8201. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 0, 9,
  8202. rx_int_mix_mux_text);
  8203. static const struct soc_enum rx_int2_2_mux_chain_enum =
  8204. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 0, 9,
  8205. rx_int_mix_mux_text);
  8206. static const struct soc_enum rx_int3_2_mux_chain_enum =
  8207. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 0, 9,
  8208. rx_int_mix_mux_text);
  8209. static const struct soc_enum rx_int4_2_mux_chain_enum =
  8210. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 0, 9,
  8211. rx_int_mix_mux_text);
  8212. static const struct soc_enum rx_int5_2_mux_chain_enum =
  8213. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 0, 9,
  8214. rx_int_mix_mux_text);
  8215. static const struct soc_enum rx_int6_2_mux_chain_enum =
  8216. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 0, 9,
  8217. rx_int_mix_mux_text);
  8218. static const struct soc_enum rx_int7_2_mux_chain_enum =
  8219. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 0, 10,
  8220. rx_int0_7_mix_mux_text);
  8221. static const struct soc_enum rx_int8_2_mux_chain_enum =
  8222. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 0, 9,
  8223. rx_int_mix_mux_text);
  8224. static const struct soc_enum int1_1_native_enum =
  8225. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8226. native_mux_text);
  8227. static const struct soc_enum int2_1_native_enum =
  8228. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8229. native_mux_text);
  8230. static const struct soc_enum int3_1_native_enum =
  8231. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8232. native_mux_text);
  8233. static const struct soc_enum int4_1_native_enum =
  8234. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8235. native_mux_text);
  8236. static const struct soc_enum rx_int0_1_mix_inp0_chain_enum =
  8237. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 0, 13,
  8238. rx_prim_mix_text);
  8239. static const struct soc_enum rx_int0_1_mix_inp1_chain_enum =
  8240. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 4, 13,
  8241. rx_prim_mix_text);
  8242. static const struct soc_enum rx_int0_1_mix_inp2_chain_enum =
  8243. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 4, 13,
  8244. rx_prim_mix_text);
  8245. static const struct soc_enum rx_int1_1_mix_inp0_chain_enum =
  8246. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 0, 13,
  8247. rx_prim_mix_text);
  8248. static const struct soc_enum rx_int1_1_mix_inp1_chain_enum =
  8249. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 4, 13,
  8250. rx_prim_mix_text);
  8251. static const struct soc_enum rx_int1_1_mix_inp2_chain_enum =
  8252. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 4, 13,
  8253. rx_prim_mix_text);
  8254. static const struct soc_enum rx_int2_1_mix_inp0_chain_enum =
  8255. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 0, 13,
  8256. rx_prim_mix_text);
  8257. static const struct soc_enum rx_int2_1_mix_inp1_chain_enum =
  8258. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 4, 13,
  8259. rx_prim_mix_text);
  8260. static const struct soc_enum rx_int2_1_mix_inp2_chain_enum =
  8261. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 4, 13,
  8262. rx_prim_mix_text);
  8263. static const struct soc_enum rx_int3_1_mix_inp0_chain_enum =
  8264. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 0, 13,
  8265. rx_prim_mix_text);
  8266. static const struct soc_enum rx_int3_1_mix_inp1_chain_enum =
  8267. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 4, 13,
  8268. rx_prim_mix_text);
  8269. static const struct soc_enum rx_int3_1_mix_inp2_chain_enum =
  8270. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 4, 13,
  8271. rx_prim_mix_text);
  8272. static const struct soc_enum rx_int4_1_mix_inp0_chain_enum =
  8273. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 0, 13,
  8274. rx_prim_mix_text);
  8275. static const struct soc_enum rx_int4_1_mix_inp1_chain_enum =
  8276. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 4, 13,
  8277. rx_prim_mix_text);
  8278. static const struct soc_enum rx_int4_1_mix_inp2_chain_enum =
  8279. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 4, 13,
  8280. rx_prim_mix_text);
  8281. static const struct soc_enum rx_int5_1_mix_inp0_chain_enum =
  8282. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 0, 13,
  8283. rx_prim_mix_text);
  8284. static const struct soc_enum rx_int5_1_mix_inp1_chain_enum =
  8285. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 4, 13,
  8286. rx_prim_mix_text);
  8287. static const struct soc_enum rx_int5_1_mix_inp2_chain_enum =
  8288. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 4, 13,
  8289. rx_prim_mix_text);
  8290. static const struct soc_enum rx_int6_1_mix_inp0_chain_enum =
  8291. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 0, 13,
  8292. rx_prim_mix_text);
  8293. static const struct soc_enum rx_int6_1_mix_inp1_chain_enum =
  8294. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 4, 13,
  8295. rx_prim_mix_text);
  8296. static const struct soc_enum rx_int6_1_mix_inp2_chain_enum =
  8297. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 4, 13,
  8298. rx_prim_mix_text);
  8299. static const struct soc_enum rx_int7_1_mix_inp0_chain_enum =
  8300. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 0, 13,
  8301. rx_prim_mix_text);
  8302. static const struct soc_enum rx_int7_1_mix_inp1_chain_enum =
  8303. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 4, 13,
  8304. rx_prim_mix_text);
  8305. static const struct soc_enum rx_int7_1_mix_inp2_chain_enum =
  8306. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 4, 13,
  8307. rx_prim_mix_text);
  8308. static const struct soc_enum rx_int8_1_mix_inp0_chain_enum =
  8309. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 0, 13,
  8310. rx_prim_mix_text);
  8311. static const struct soc_enum rx_int8_1_mix_inp1_chain_enum =
  8312. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 4, 13,
  8313. rx_prim_mix_text);
  8314. static const struct soc_enum rx_int8_1_mix_inp2_chain_enum =
  8315. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 4, 13,
  8316. rx_prim_mix_text);
  8317. static const struct soc_enum rx_int0_sidetone_mix_chain_enum =
  8318. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0, 4,
  8319. rx_sidetone_mix_text);
  8320. static const struct soc_enum rx_int1_sidetone_mix_chain_enum =
  8321. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2, 4,
  8322. rx_sidetone_mix_text);
  8323. static const struct soc_enum rx_int2_sidetone_mix_chain_enum =
  8324. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4, 4,
  8325. rx_sidetone_mix_text);
  8326. static const struct soc_enum rx_int3_sidetone_mix_chain_enum =
  8327. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6, 4,
  8328. rx_sidetone_mix_text);
  8329. static const struct soc_enum rx_int4_sidetone_mix_chain_enum =
  8330. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 0, 4,
  8331. rx_sidetone_mix_text);
  8332. static const struct soc_enum rx_int7_sidetone_mix_chain_enum =
  8333. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 2, 4,
  8334. rx_sidetone_mix_text);
  8335. static const struct soc_enum tx_adc_mux0_chain_enum =
  8336. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 0, 4,
  8337. adc_mux_text);
  8338. static const struct soc_enum tx_adc_mux1_chain_enum =
  8339. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 0, 4,
  8340. adc_mux_text);
  8341. static const struct soc_enum tx_adc_mux2_chain_enum =
  8342. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 0, 4,
  8343. adc_mux_text);
  8344. static const struct soc_enum tx_adc_mux3_chain_enum =
  8345. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 0, 4,
  8346. adc_mux_text);
  8347. static const struct soc_enum tx_adc_mux4_chain_enum =
  8348. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 6, 4,
  8349. adc_mux_text);
  8350. static const struct soc_enum tx_adc_mux5_chain_enum =
  8351. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 6, 4,
  8352. adc_mux_text);
  8353. static const struct soc_enum tx_adc_mux6_chain_enum =
  8354. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 6, 4,
  8355. adc_mux_text);
  8356. static const struct soc_enum tx_adc_mux7_chain_enum =
  8357. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 6, 4,
  8358. adc_mux_text);
  8359. static const struct soc_enum tx_adc_mux8_chain_enum =
  8360. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 6, 4,
  8361. adc_mux_text);
  8362. static const struct soc_enum tx_adc_mux10_chain_enum =
  8363. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 6, 4,
  8364. adc_mux_text);
  8365. static const struct soc_enum tx_adc_mux11_chain_enum =
  8366. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 6, 4,
  8367. adc_mux_text);
  8368. static const struct soc_enum tx_adc_mux12_chain_enum =
  8369. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 6, 4,
  8370. adc_mux_text);
  8371. static const struct soc_enum tx_adc_mux13_chain_enum =
  8372. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 6, 4,
  8373. adc_mux_text);
  8374. static const struct soc_enum tx_dmic_mux0_enum =
  8375. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 3, 11,
  8376. dmic_mux_text);
  8377. static const struct soc_enum tx_dmic_mux1_enum =
  8378. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 3, 11,
  8379. dmic_mux_text);
  8380. static const struct soc_enum tx_dmic_mux2_enum =
  8381. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 3, 11,
  8382. dmic_mux_text);
  8383. static const struct soc_enum tx_dmic_mux3_enum =
  8384. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 3, 11,
  8385. dmic_mux_text);
  8386. static const struct soc_enum tx_dmic_mux4_enum =
  8387. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 3, 7,
  8388. dmic_mux_alt_text);
  8389. static const struct soc_enum tx_dmic_mux5_enum =
  8390. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 3, 7,
  8391. dmic_mux_alt_text);
  8392. static const struct soc_enum tx_dmic_mux6_enum =
  8393. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 3, 7,
  8394. dmic_mux_alt_text);
  8395. static const struct soc_enum tx_dmic_mux7_enum =
  8396. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 3, 7,
  8397. dmic_mux_alt_text);
  8398. static const struct soc_enum tx_dmic_mux8_enum =
  8399. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 3, 7,
  8400. dmic_mux_alt_text);
  8401. static const struct soc_enum tx_dmic_mux10_enum =
  8402. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 3, 7,
  8403. dmic_mux_alt_text);
  8404. static const struct soc_enum tx_dmic_mux11_enum =
  8405. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 3, 7,
  8406. dmic_mux_alt_text);
  8407. static const struct soc_enum tx_dmic_mux12_enum =
  8408. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 3, 7,
  8409. dmic_mux_alt_text);
  8410. static const struct soc_enum tx_dmic_mux13_enum =
  8411. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 3, 7,
  8412. dmic_mux_alt_text);
  8413. static const struct soc_enum tx_amic_mux0_enum =
  8414. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 0, 7,
  8415. amic_mux_text);
  8416. static const struct soc_enum tx_amic_mux1_enum =
  8417. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 0, 7,
  8418. amic_mux_text);
  8419. static const struct soc_enum tx_amic_mux2_enum =
  8420. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 0, 7,
  8421. amic_mux_text);
  8422. static const struct soc_enum tx_amic_mux3_enum =
  8423. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 0, 7,
  8424. amic_mux_text);
  8425. static const struct soc_enum tx_amic_mux4_enum =
  8426. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 0, 7,
  8427. amic_mux_text);
  8428. static const struct soc_enum tx_amic_mux5_enum =
  8429. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 0, 7,
  8430. amic_mux_text);
  8431. static const struct soc_enum tx_amic_mux6_enum =
  8432. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 0, 7,
  8433. amic_mux_text);
  8434. static const struct soc_enum tx_amic_mux7_enum =
  8435. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 0, 7,
  8436. amic_mux_text);
  8437. static const struct soc_enum tx_amic_mux8_enum =
  8438. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 0, 7,
  8439. amic_mux_text);
  8440. static const struct soc_enum tx_amic_mux10_enum =
  8441. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 0, 7,
  8442. amic_mux_text);
  8443. static const struct soc_enum tx_amic_mux11_enum =
  8444. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 0, 7,
  8445. amic_mux_text);
  8446. static const struct soc_enum tx_amic_mux12_enum =
  8447. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 0, 7,
  8448. amic_mux_text);
  8449. static const struct soc_enum tx_amic_mux13_enum =
  8450. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 0, 7,
  8451. amic_mux_text);
  8452. static const struct soc_enum sb_tx0_mux_enum =
  8453. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 0, 4,
  8454. sb_tx0_mux_text);
  8455. static const struct soc_enum sb_tx1_mux_enum =
  8456. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 2, 4,
  8457. sb_tx1_mux_text);
  8458. static const struct soc_enum sb_tx2_mux_enum =
  8459. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 4, 4,
  8460. sb_tx2_mux_text);
  8461. static const struct soc_enum sb_tx3_mux_enum =
  8462. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 6, 4,
  8463. sb_tx3_mux_text);
  8464. static const struct soc_enum sb_tx4_mux_enum =
  8465. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 0, 4,
  8466. sb_tx4_mux_text);
  8467. static const struct soc_enum sb_tx5_mux_enum =
  8468. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 2, 4,
  8469. sb_tx5_mux_text);
  8470. static const struct soc_enum sb_tx6_mux_enum =
  8471. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 4, 4,
  8472. sb_tx6_mux_text);
  8473. static const struct soc_enum sb_tx7_mux_enum =
  8474. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 6, 4,
  8475. sb_tx7_mux_text);
  8476. static const struct soc_enum sb_tx8_mux_enum =
  8477. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 0, 4,
  8478. sb_tx8_mux_text);
  8479. static const struct soc_enum sb_tx9_mux_enum =
  8480. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 2, 3,
  8481. sb_tx9_mux_text);
  8482. static const struct soc_enum sb_tx10_mux_enum =
  8483. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 4, 3,
  8484. sb_tx10_mux_text);
  8485. static const struct soc_enum sb_tx11_mux_enum =
  8486. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX11_INP_CFG, 0, 4,
  8487. sb_tx11_mux_text);
  8488. static const struct soc_enum sb_tx11_inp1_mux_enum =
  8489. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 0, 10,
  8490. sb_tx11_inp1_mux_text);
  8491. static const struct soc_enum sb_tx13_mux_enum =
  8492. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 4, 3,
  8493. sb_tx13_mux_text);
  8494. static const struct soc_enum tx13_inp_mux_enum =
  8495. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG, 0, 3,
  8496. tx13_inp_mux_text);
  8497. static const struct soc_enum rx_mix_tx0_mux_enum =
  8498. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 0, 14,
  8499. rx_echo_mux_text);
  8500. static const struct soc_enum rx_mix_tx1_mux_enum =
  8501. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 4, 14,
  8502. rx_echo_mux_text);
  8503. static const struct soc_enum rx_mix_tx2_mux_enum =
  8504. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 0, 14,
  8505. rx_echo_mux_text);
  8506. static const struct soc_enum rx_mix_tx3_mux_enum =
  8507. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 4, 14,
  8508. rx_echo_mux_text);
  8509. static const struct soc_enum rx_mix_tx4_mux_enum =
  8510. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 0, 14,
  8511. rx_echo_mux_text);
  8512. static const struct soc_enum rx_mix_tx5_mux_enum =
  8513. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 4, 14,
  8514. rx_echo_mux_text);
  8515. static const struct soc_enum rx_mix_tx6_mux_enum =
  8516. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 0, 14,
  8517. rx_echo_mux_text);
  8518. static const struct soc_enum rx_mix_tx7_mux_enum =
  8519. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 4, 14,
  8520. rx_echo_mux_text);
  8521. static const struct soc_enum rx_mix_tx8_mux_enum =
  8522. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG4, 0, 14,
  8523. rx_echo_mux_text);
  8524. static const struct soc_enum iir0_inp0_mux_enum =
  8525. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0, 0, 18,
  8526. iir_inp_mux_text);
  8527. static const struct soc_enum iir0_inp1_mux_enum =
  8528. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1, 0, 18,
  8529. iir_inp_mux_text);
  8530. static const struct soc_enum iir0_inp2_mux_enum =
  8531. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2, 0, 18,
  8532. iir_inp_mux_text);
  8533. static const struct soc_enum iir0_inp3_mux_enum =
  8534. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3, 0, 18,
  8535. iir_inp_mux_text);
  8536. static const struct soc_enum iir1_inp0_mux_enum =
  8537. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0, 0, 18,
  8538. iir_inp_mux_text);
  8539. static const struct soc_enum iir1_inp1_mux_enum =
  8540. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1, 0, 18,
  8541. iir_inp_mux_text);
  8542. static const struct soc_enum iir1_inp2_mux_enum =
  8543. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2, 0, 18,
  8544. iir_inp_mux_text);
  8545. static const struct soc_enum iir1_inp3_mux_enum =
  8546. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3, 0, 18,
  8547. iir_inp_mux_text);
  8548. static const struct soc_enum rx_int0_dem_inp_mux_enum =
  8549. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_SEC0, 0,
  8550. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8551. rx_int_dem_inp_mux_text);
  8552. static const struct soc_enum rx_int1_dem_inp_mux_enum =
  8553. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_SEC0, 0,
  8554. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8555. rx_int_dem_inp_mux_text);
  8556. static const struct soc_enum rx_int2_dem_inp_mux_enum =
  8557. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_SEC0, 0,
  8558. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8559. rx_int_dem_inp_mux_text);
  8560. static const struct soc_enum rx_int0_interp_mux_enum =
  8561. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CTL, 5, 2,
  8562. rx_int0_interp_mux_text);
  8563. static const struct soc_enum rx_int1_interp_mux_enum =
  8564. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CTL, 5, 2,
  8565. rx_int1_interp_mux_text);
  8566. static const struct soc_enum rx_int2_interp_mux_enum =
  8567. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CTL, 5, 2,
  8568. rx_int2_interp_mux_text);
  8569. static const struct soc_enum rx_int3_interp_mux_enum =
  8570. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CTL, 5, 2,
  8571. rx_int3_interp_mux_text);
  8572. static const struct soc_enum rx_int4_interp_mux_enum =
  8573. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CTL, 5, 2,
  8574. rx_int4_interp_mux_text);
  8575. static const struct soc_enum rx_int5_interp_mux_enum =
  8576. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CTL, 5, 2,
  8577. rx_int5_interp_mux_text);
  8578. static const struct soc_enum rx_int6_interp_mux_enum =
  8579. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CTL, 5, 2,
  8580. rx_int6_interp_mux_text);
  8581. static const struct soc_enum rx_int7_interp_mux_enum =
  8582. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CTL, 5, 2,
  8583. rx_int7_interp_mux_text);
  8584. static const struct soc_enum rx_int8_interp_mux_enum =
  8585. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CTL, 5, 2,
  8586. rx_int8_interp_mux_text);
  8587. static const struct soc_enum mad_sel_enum =
  8588. SOC_ENUM_SINGLE(WCD9335_CPE_SS_CFG, 0, 2, mad_sel_text);
  8589. static const struct soc_enum anc0_fb_mux_enum =
  8590. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 0, 5,
  8591. anc0_fb_mux_text);
  8592. static const struct soc_enum anc1_fb_mux_enum =
  8593. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 3, 3,
  8594. anc1_fb_mux_text);
  8595. static const struct snd_kcontrol_new rx_int0_dem_inp_mux =
  8596. SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum,
  8597. snd_soc_dapm_get_enum_double,
  8598. tasha_int_dem_inp_mux_put);
  8599. static const struct snd_kcontrol_new rx_int1_dem_inp_mux =
  8600. SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum,
  8601. snd_soc_dapm_get_enum_double,
  8602. tasha_int_dem_inp_mux_put);
  8603. static const struct snd_kcontrol_new rx_int2_dem_inp_mux =
  8604. SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum,
  8605. snd_soc_dapm_get_enum_double,
  8606. tasha_int_dem_inp_mux_put);
  8607. static const struct snd_kcontrol_new spl_src0_mux =
  8608. SOC_DAPM_ENUM("SPL SRC0 MUX Mux", spl_src0_mux_chain_enum);
  8609. static const struct snd_kcontrol_new spl_src1_mux =
  8610. SOC_DAPM_ENUM("SPL SRC1 MUX Mux", spl_src1_mux_chain_enum);
  8611. static const struct snd_kcontrol_new spl_src2_mux =
  8612. SOC_DAPM_ENUM("SPL SRC2 MUX Mux", spl_src2_mux_chain_enum);
  8613. static const struct snd_kcontrol_new spl_src3_mux =
  8614. SOC_DAPM_ENUM("SPL SRC3 MUX Mux", spl_src3_mux_chain_enum);
  8615. static const struct snd_kcontrol_new rx_int0_2_mux =
  8616. SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum);
  8617. static const struct snd_kcontrol_new rx_int1_2_mux =
  8618. SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum);
  8619. static const struct snd_kcontrol_new rx_int2_2_mux =
  8620. SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum);
  8621. static const struct snd_kcontrol_new rx_int3_2_mux =
  8622. SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum);
  8623. static const struct snd_kcontrol_new rx_int4_2_mux =
  8624. SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum);
  8625. static const struct snd_kcontrol_new rx_int5_2_mux =
  8626. SOC_DAPM_ENUM("RX INT5_2 MUX Mux", rx_int5_2_mux_chain_enum);
  8627. static const struct snd_kcontrol_new rx_int6_2_mux =
  8628. SOC_DAPM_ENUM("RX INT6_2 MUX Mux", rx_int6_2_mux_chain_enum);
  8629. static const struct snd_kcontrol_new rx_int7_2_mux =
  8630. SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum);
  8631. static const struct snd_kcontrol_new rx_int8_2_mux =
  8632. SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum);
  8633. static const struct snd_kcontrol_new int1_1_native_mux =
  8634. SOC_DAPM_ENUM("RX INT1_1 NATIVE MUX Mux", int1_1_native_enum);
  8635. static const struct snd_kcontrol_new int2_1_native_mux =
  8636. SOC_DAPM_ENUM("RX INT2_1 NATIVE MUX Mux", int2_1_native_enum);
  8637. static const struct snd_kcontrol_new int3_1_native_mux =
  8638. SOC_DAPM_ENUM("RX INT3_1 NATIVE MUX Mux", int3_1_native_enum);
  8639. static const struct snd_kcontrol_new int4_1_native_mux =
  8640. SOC_DAPM_ENUM("RX INT4_1 NATIVE MUX Mux", int4_1_native_enum);
  8641. static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux =
  8642. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum);
  8643. static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux =
  8644. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum);
  8645. static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux =
  8646. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum);
  8647. static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux =
  8648. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum);
  8649. static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux =
  8650. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum);
  8651. static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux =
  8652. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum);
  8653. static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux =
  8654. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum);
  8655. static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux =
  8656. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum);
  8657. static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux =
  8658. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum);
  8659. static const struct snd_kcontrol_new rx_int3_1_mix_inp0_mux =
  8660. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum);
  8661. static const struct snd_kcontrol_new rx_int3_1_mix_inp1_mux =
  8662. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum);
  8663. static const struct snd_kcontrol_new rx_int3_1_mix_inp2_mux =
  8664. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum);
  8665. static const struct snd_kcontrol_new rx_int4_1_mix_inp0_mux =
  8666. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum);
  8667. static const struct snd_kcontrol_new rx_int4_1_mix_inp1_mux =
  8668. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum);
  8669. static const struct snd_kcontrol_new rx_int4_1_mix_inp2_mux =
  8670. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum);
  8671. static const struct snd_kcontrol_new rx_int5_1_mix_inp0_mux =
  8672. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP0 Mux", rx_int5_1_mix_inp0_chain_enum);
  8673. static const struct snd_kcontrol_new rx_int5_1_mix_inp1_mux =
  8674. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP1 Mux", rx_int5_1_mix_inp1_chain_enum);
  8675. static const struct snd_kcontrol_new rx_int5_1_mix_inp2_mux =
  8676. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP2 Mux", rx_int5_1_mix_inp2_chain_enum);
  8677. static const struct snd_kcontrol_new rx_int6_1_mix_inp0_mux =
  8678. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP0 Mux", rx_int6_1_mix_inp0_chain_enum);
  8679. static const struct snd_kcontrol_new rx_int6_1_mix_inp1_mux =
  8680. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP1 Mux", rx_int6_1_mix_inp1_chain_enum);
  8681. static const struct snd_kcontrol_new rx_int6_1_mix_inp2_mux =
  8682. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP2 Mux", rx_int6_1_mix_inp2_chain_enum);
  8683. static const struct snd_kcontrol_new rx_int7_1_mix_inp0_mux =
  8684. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum);
  8685. static const struct snd_kcontrol_new rx_int7_1_mix_inp1_mux =
  8686. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum);
  8687. static const struct snd_kcontrol_new rx_int7_1_mix_inp2_mux =
  8688. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum);
  8689. static const struct snd_kcontrol_new rx_int8_1_mix_inp0_mux =
  8690. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum);
  8691. static const struct snd_kcontrol_new rx_int8_1_mix_inp1_mux =
  8692. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum);
  8693. static const struct snd_kcontrol_new rx_int8_1_mix_inp2_mux =
  8694. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum);
  8695. static const struct snd_kcontrol_new rx_int0_mix2_inp_mux =
  8696. SOC_DAPM_ENUM("RX INT0 MIX2 INP Mux", rx_int0_sidetone_mix_chain_enum);
  8697. static const struct snd_kcontrol_new rx_int1_mix2_inp_mux =
  8698. SOC_DAPM_ENUM("RX INT1 MIX2 INP Mux", rx_int1_sidetone_mix_chain_enum);
  8699. static const struct snd_kcontrol_new rx_int2_mix2_inp_mux =
  8700. SOC_DAPM_ENUM("RX INT2 MIX2 INP Mux", rx_int2_sidetone_mix_chain_enum);
  8701. static const struct snd_kcontrol_new rx_int3_mix2_inp_mux =
  8702. SOC_DAPM_ENUM("RX INT3 MIX2 INP Mux", rx_int3_sidetone_mix_chain_enum);
  8703. static const struct snd_kcontrol_new rx_int4_mix2_inp_mux =
  8704. SOC_DAPM_ENUM("RX INT4 MIX2 INP Mux", rx_int4_sidetone_mix_chain_enum);
  8705. static const struct snd_kcontrol_new rx_int7_mix2_inp_mux =
  8706. SOC_DAPM_ENUM("RX INT7 MIX2 INP Mux", rx_int7_sidetone_mix_chain_enum);
  8707. static const struct snd_kcontrol_new tx_adc_mux0 =
  8708. SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_chain_enum,
  8709. snd_soc_dapm_get_enum_double,
  8710. tasha_put_dec_enum);
  8711. static const struct snd_kcontrol_new tx_adc_mux1 =
  8712. SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_chain_enum,
  8713. snd_soc_dapm_get_enum_double,
  8714. tasha_put_dec_enum);
  8715. static const struct snd_kcontrol_new tx_adc_mux2 =
  8716. SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_chain_enum,
  8717. snd_soc_dapm_get_enum_double,
  8718. tasha_put_dec_enum);
  8719. static const struct snd_kcontrol_new tx_adc_mux3 =
  8720. SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_chain_enum,
  8721. snd_soc_dapm_get_enum_double,
  8722. tasha_put_dec_enum);
  8723. static const struct snd_kcontrol_new tx_adc_mux4 =
  8724. SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_chain_enum,
  8725. snd_soc_dapm_get_enum_double,
  8726. tasha_put_dec_enum);
  8727. static const struct snd_kcontrol_new tx_adc_mux5 =
  8728. SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_chain_enum,
  8729. snd_soc_dapm_get_enum_double,
  8730. tasha_put_dec_enum);
  8731. static const struct snd_kcontrol_new tx_adc_mux6 =
  8732. SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_chain_enum,
  8733. snd_soc_dapm_get_enum_double,
  8734. tasha_put_dec_enum);
  8735. static const struct snd_kcontrol_new tx_adc_mux7 =
  8736. SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_chain_enum,
  8737. snd_soc_dapm_get_enum_double,
  8738. tasha_put_dec_enum);
  8739. static const struct snd_kcontrol_new tx_adc_mux8 =
  8740. SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_chain_enum,
  8741. snd_soc_dapm_get_enum_double,
  8742. tasha_put_dec_enum);
  8743. static const struct snd_kcontrol_new tx_adc_mux10 =
  8744. SOC_DAPM_ENUM("ADC MUX10 Mux", tx_adc_mux10_chain_enum);
  8745. static const struct snd_kcontrol_new tx_adc_mux11 =
  8746. SOC_DAPM_ENUM("ADC MUX11 Mux", tx_adc_mux11_chain_enum);
  8747. static const struct snd_kcontrol_new tx_adc_mux12 =
  8748. SOC_DAPM_ENUM("ADC MUX12 Mux", tx_adc_mux12_chain_enum);
  8749. static const struct snd_kcontrol_new tx_adc_mux13 =
  8750. SOC_DAPM_ENUM("ADC MUX13 Mux", tx_adc_mux13_chain_enum);
  8751. static const struct snd_kcontrol_new tx_dmic_mux0 =
  8752. SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum);
  8753. static const struct snd_kcontrol_new tx_dmic_mux1 =
  8754. SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum);
  8755. static const struct snd_kcontrol_new tx_dmic_mux2 =
  8756. SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum);
  8757. static const struct snd_kcontrol_new tx_dmic_mux3 =
  8758. SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum);
  8759. static const struct snd_kcontrol_new tx_dmic_mux4 =
  8760. SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum);
  8761. static const struct snd_kcontrol_new tx_dmic_mux5 =
  8762. SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum);
  8763. static const struct snd_kcontrol_new tx_dmic_mux6 =
  8764. SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum);
  8765. static const struct snd_kcontrol_new tx_dmic_mux7 =
  8766. SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum);
  8767. static const struct snd_kcontrol_new tx_dmic_mux8 =
  8768. SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum);
  8769. static const struct snd_kcontrol_new tx_dmic_mux10 =
  8770. SOC_DAPM_ENUM("DMIC MUX10 Mux", tx_dmic_mux10_enum);
  8771. static const struct snd_kcontrol_new tx_dmic_mux11 =
  8772. SOC_DAPM_ENUM("DMIC MUX11 Mux", tx_dmic_mux11_enum);
  8773. static const struct snd_kcontrol_new tx_dmic_mux12 =
  8774. SOC_DAPM_ENUM("DMIC MUX12 Mux", tx_dmic_mux12_enum);
  8775. static const struct snd_kcontrol_new tx_dmic_mux13 =
  8776. SOC_DAPM_ENUM("DMIC MUX13 Mux", tx_dmic_mux13_enum);
  8777. static const struct snd_kcontrol_new tx_amic_mux0 =
  8778. SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum);
  8779. static const struct snd_kcontrol_new tx_amic_mux1 =
  8780. SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum);
  8781. static const struct snd_kcontrol_new tx_amic_mux2 =
  8782. SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum);
  8783. static const struct snd_kcontrol_new tx_amic_mux3 =
  8784. SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum);
  8785. static const struct snd_kcontrol_new tx_amic_mux4 =
  8786. SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum);
  8787. static const struct snd_kcontrol_new tx_amic_mux5 =
  8788. SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum);
  8789. static const struct snd_kcontrol_new tx_amic_mux6 =
  8790. SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum);
  8791. static const struct snd_kcontrol_new tx_amic_mux7 =
  8792. SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum);
  8793. static const struct snd_kcontrol_new tx_amic_mux8 =
  8794. SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum);
  8795. static const struct snd_kcontrol_new tx_amic_mux10 =
  8796. SOC_DAPM_ENUM("AMIC MUX10 Mux", tx_amic_mux10_enum);
  8797. static const struct snd_kcontrol_new tx_amic_mux11 =
  8798. SOC_DAPM_ENUM("AMIC MUX11 Mux", tx_amic_mux11_enum);
  8799. static const struct snd_kcontrol_new tx_amic_mux12 =
  8800. SOC_DAPM_ENUM("AMIC MUX12 Mux", tx_amic_mux12_enum);
  8801. static const struct snd_kcontrol_new tx_amic_mux13 =
  8802. SOC_DAPM_ENUM("AMIC MUX13 Mux", tx_amic_mux13_enum);
  8803. static const struct snd_kcontrol_new sb_tx0_mux =
  8804. SOC_DAPM_ENUM("SLIM TX0 MUX Mux", sb_tx0_mux_enum);
  8805. static const struct snd_kcontrol_new sb_tx1_mux =
  8806. SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum);
  8807. static const struct snd_kcontrol_new sb_tx2_mux =
  8808. SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum);
  8809. static const struct snd_kcontrol_new sb_tx3_mux =
  8810. SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum);
  8811. static const struct snd_kcontrol_new sb_tx4_mux =
  8812. SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum);
  8813. static const struct snd_kcontrol_new sb_tx5_mux =
  8814. SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum);
  8815. static const struct snd_kcontrol_new sb_tx6_mux =
  8816. SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum);
  8817. static const struct snd_kcontrol_new sb_tx7_mux =
  8818. SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum);
  8819. static const struct snd_kcontrol_new sb_tx8_mux =
  8820. SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum);
  8821. static const struct snd_kcontrol_new sb_tx9_mux =
  8822. SOC_DAPM_ENUM("SLIM TX9 MUX Mux", sb_tx9_mux_enum);
  8823. static const struct snd_kcontrol_new sb_tx10_mux =
  8824. SOC_DAPM_ENUM("SLIM TX10 MUX Mux", sb_tx10_mux_enum);
  8825. static const struct snd_kcontrol_new sb_tx11_mux =
  8826. SOC_DAPM_ENUM("SLIM TX11 MUX Mux", sb_tx11_mux_enum);
  8827. static const struct snd_kcontrol_new sb_tx11_inp1_mux =
  8828. SOC_DAPM_ENUM("SLIM TX11 INP1 MUX Mux", sb_tx11_inp1_mux_enum);
  8829. static const struct snd_kcontrol_new sb_tx13_mux =
  8830. SOC_DAPM_ENUM("SLIM TX13 MUX Mux", sb_tx13_mux_enum);
  8831. static const struct snd_kcontrol_new tx13_inp_mux =
  8832. SOC_DAPM_ENUM("TX13 INP MUX Mux", tx13_inp_mux_enum);
  8833. static const struct snd_kcontrol_new rx_mix_tx0_mux =
  8834. SOC_DAPM_ENUM("RX MIX TX0 MUX Mux", rx_mix_tx0_mux_enum);
  8835. static const struct snd_kcontrol_new rx_mix_tx1_mux =
  8836. SOC_DAPM_ENUM("RX MIX TX1 MUX Mux", rx_mix_tx1_mux_enum);
  8837. static const struct snd_kcontrol_new rx_mix_tx2_mux =
  8838. SOC_DAPM_ENUM("RX MIX TX2 MUX Mux", rx_mix_tx2_mux_enum);
  8839. static const struct snd_kcontrol_new rx_mix_tx3_mux =
  8840. SOC_DAPM_ENUM("RX MIX TX3 MUX Mux", rx_mix_tx3_mux_enum);
  8841. static const struct snd_kcontrol_new rx_mix_tx4_mux =
  8842. SOC_DAPM_ENUM("RX MIX TX4 MUX Mux", rx_mix_tx4_mux_enum);
  8843. static const struct snd_kcontrol_new rx_mix_tx5_mux =
  8844. SOC_DAPM_ENUM("RX MIX TX5 MUX Mux", rx_mix_tx5_mux_enum);
  8845. static const struct snd_kcontrol_new rx_mix_tx6_mux =
  8846. SOC_DAPM_ENUM("RX MIX TX6 MUX Mux", rx_mix_tx6_mux_enum);
  8847. static const struct snd_kcontrol_new rx_mix_tx7_mux =
  8848. SOC_DAPM_ENUM("RX MIX TX7 MUX Mux", rx_mix_tx7_mux_enum);
  8849. static const struct snd_kcontrol_new rx_mix_tx8_mux =
  8850. SOC_DAPM_ENUM("RX MIX TX8 MUX Mux", rx_mix_tx8_mux_enum);
  8851. static const struct snd_kcontrol_new iir0_inp0_mux =
  8852. SOC_DAPM_ENUM("IIR0 INP0 Mux", iir0_inp0_mux_enum);
  8853. static const struct snd_kcontrol_new iir0_inp1_mux =
  8854. SOC_DAPM_ENUM("IIR0 INP1 Mux", iir0_inp1_mux_enum);
  8855. static const struct snd_kcontrol_new iir0_inp2_mux =
  8856. SOC_DAPM_ENUM("IIR0 INP2 Mux", iir0_inp2_mux_enum);
  8857. static const struct snd_kcontrol_new iir0_inp3_mux =
  8858. SOC_DAPM_ENUM("IIR0 INP3 Mux", iir0_inp3_mux_enum);
  8859. static const struct snd_kcontrol_new iir1_inp0_mux =
  8860. SOC_DAPM_ENUM("IIR1 INP0 Mux", iir1_inp0_mux_enum);
  8861. static const struct snd_kcontrol_new iir1_inp1_mux =
  8862. SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum);
  8863. static const struct snd_kcontrol_new iir1_inp2_mux =
  8864. SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum);
  8865. static const struct snd_kcontrol_new iir1_inp3_mux =
  8866. SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum);
  8867. static const struct snd_kcontrol_new rx_int0_interp_mux =
  8868. SOC_DAPM_ENUM("RX INT0 INTERP Mux", rx_int0_interp_mux_enum);
  8869. static const struct snd_kcontrol_new rx_int1_interp_mux =
  8870. SOC_DAPM_ENUM("RX INT1 INTERP Mux", rx_int1_interp_mux_enum);
  8871. static const struct snd_kcontrol_new rx_int2_interp_mux =
  8872. SOC_DAPM_ENUM("RX INT2 INTERP Mux", rx_int2_interp_mux_enum);
  8873. static const struct snd_kcontrol_new rx_int3_interp_mux =
  8874. SOC_DAPM_ENUM("RX INT3 INTERP Mux", rx_int3_interp_mux_enum);
  8875. static const struct snd_kcontrol_new rx_int4_interp_mux =
  8876. SOC_DAPM_ENUM("RX INT4 INTERP Mux", rx_int4_interp_mux_enum);
  8877. static const struct snd_kcontrol_new rx_int5_interp_mux =
  8878. SOC_DAPM_ENUM("RX INT5 INTERP Mux", rx_int5_interp_mux_enum);
  8879. static const struct snd_kcontrol_new rx_int6_interp_mux =
  8880. SOC_DAPM_ENUM("RX INT6 INTERP Mux", rx_int6_interp_mux_enum);
  8881. static const struct snd_kcontrol_new rx_int7_interp_mux =
  8882. SOC_DAPM_ENUM("RX INT7 INTERP Mux", rx_int7_interp_mux_enum);
  8883. static const struct snd_kcontrol_new rx_int8_interp_mux =
  8884. SOC_DAPM_ENUM("RX INT8 INTERP Mux", rx_int8_interp_mux_enum);
  8885. static const struct snd_kcontrol_new mad_sel_mux =
  8886. SOC_DAPM_ENUM("MAD_SEL MUX Mux", mad_sel_enum);
  8887. static const struct snd_kcontrol_new aif4_mad_switch =
  8888. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 5, 1, 0);
  8889. static const struct snd_kcontrol_new mad_brdcst_switch =
  8890. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 6, 1, 0);
  8891. static const struct snd_kcontrol_new aif4_switch_mixer_controls =
  8892. SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
  8893. 0, 1, 0, tasha_codec_aif4_mixer_switch_get,
  8894. tasha_codec_aif4_mixer_switch_put);
  8895. static const struct snd_kcontrol_new anc_hphl_switch =
  8896. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8897. static const struct snd_kcontrol_new anc_hphr_switch =
  8898. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8899. static const struct snd_kcontrol_new anc_ear_switch =
  8900. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8901. static const struct snd_kcontrol_new anc_ear_spkr_switch =
  8902. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8903. static const struct snd_kcontrol_new anc_lineout1_switch =
  8904. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8905. static const struct snd_kcontrol_new anc_lineout2_switch =
  8906. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8907. static const struct snd_kcontrol_new anc_spkr_pa_switch =
  8908. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8909. static const struct snd_kcontrol_new adc_us_mux0_switch =
  8910. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8911. static const struct snd_kcontrol_new adc_us_mux1_switch =
  8912. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8913. static const struct snd_kcontrol_new adc_us_mux2_switch =
  8914. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8915. static const struct snd_kcontrol_new adc_us_mux3_switch =
  8916. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8917. static const struct snd_kcontrol_new adc_us_mux4_switch =
  8918. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8919. static const struct snd_kcontrol_new adc_us_mux5_switch =
  8920. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8921. static const struct snd_kcontrol_new adc_us_mux6_switch =
  8922. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8923. static const struct snd_kcontrol_new adc_us_mux7_switch =
  8924. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8925. static const struct snd_kcontrol_new adc_us_mux8_switch =
  8926. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8927. static const struct snd_kcontrol_new anc0_fb_mux =
  8928. SOC_DAPM_ENUM("ANC0 FB MUX Mux", anc0_fb_mux_enum);
  8929. static const struct snd_kcontrol_new anc1_fb_mux =
  8930. SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum);
  8931. static int tasha_codec_ec_buf_mux_enable(struct snd_soc_dapm_widget *w,
  8932. struct snd_kcontrol *kcontrol,
  8933. int event)
  8934. {
  8935. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  8936. dev_dbg(codec->dev, "%s: event = %d name = %s\n",
  8937. __func__, event, w->name);
  8938. switch (event) {
  8939. case SND_SOC_DAPM_POST_PMU:
  8940. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x3B);
  8941. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x08);
  8942. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8943. 0x08, 0x08);
  8944. break;
  8945. case SND_SOC_DAPM_POST_PMD:
  8946. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8947. 0x08, 0x00);
  8948. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x00);
  8949. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x00);
  8950. break;
  8951. }
  8952. return 0;
  8953. };
  8954. static const char * const ec_buf_mux_text[] = {
  8955. "ZERO", "RXMIXEC", "SB_RX0", "SB_RX1", "SB_RX2", "SB_RX3",
  8956. "I2S_RX_SD0_L", "I2S_RX_SD0_R", "I2S_RX_SD1_L", "I2S_RX_SD1_R",
  8957. "DEC1"
  8958. };
  8959. static SOC_ENUM_SINGLE_DECL(ec_buf_mux_enum, WCD9335_CPE_SS_US_EC_MUX_CFG,
  8960. 0, ec_buf_mux_text);
  8961. static const struct snd_kcontrol_new ec_buf_mux =
  8962. SOC_DAPM_ENUM("EC BUF Mux", ec_buf_mux_enum);
  8963. static const struct snd_soc_dapm_widget tasha_dapm_widgets[] = {
  8964. SND_SOC_DAPM_OUTPUT("EAR"),
  8965. SND_SOC_DAPM_OUTPUT("ANC EAR"),
  8966. SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM,
  8967. AIF1_PB, 0, tasha_codec_enable_slimrx,
  8968. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8969. SND_SOC_DAPM_POST_PMD),
  8970. SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM,
  8971. AIF2_PB, 0, tasha_codec_enable_slimrx,
  8972. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8973. SND_SOC_DAPM_POST_PMD),
  8974. SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM,
  8975. AIF3_PB, 0, tasha_codec_enable_slimrx,
  8976. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8977. SND_SOC_DAPM_POST_PMD),
  8978. SND_SOC_DAPM_AIF_IN_E("AIF4 PB", "AIF4 Playback", 0, SND_SOC_NOPM,
  8979. AIF4_PB, 0, tasha_codec_enable_slimrx,
  8980. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8981. SND_SOC_DAPM_POST_PMD),
  8982. SND_SOC_DAPM_AIF_IN_E("AIF MIX1 PB", "AIF Mix Playback", 0,
  8983. SND_SOC_NOPM, AIF_MIX1_PB, 0,
  8984. tasha_codec_enable_slimrx,
  8985. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8986. SND_SOC_DAPM_POST_PMD),
  8987. SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM, TASHA_RX0, 0,
  8988. &slim_rx_mux[TASHA_RX0]),
  8989. SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TASHA_RX1, 0,
  8990. &slim_rx_mux[TASHA_RX1]),
  8991. SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TASHA_RX2, 0,
  8992. &slim_rx_mux[TASHA_RX2]),
  8993. SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TASHA_RX3, 0,
  8994. &slim_rx_mux[TASHA_RX3]),
  8995. SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TASHA_RX4, 0,
  8996. &slim_rx_mux[TASHA_RX4]),
  8997. SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TASHA_RX5, 0,
  8998. &slim_rx_mux[TASHA_RX5]),
  8999. SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, TASHA_RX6, 0,
  9000. &slim_rx_mux[TASHA_RX6]),
  9001. SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, TASHA_RX7, 0,
  9002. &slim_rx_mux[TASHA_RX7]),
  9003. SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
  9004. SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9005. SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9006. SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
  9007. SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
  9008. SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0),
  9009. SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0),
  9010. SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0),
  9011. SND_SOC_DAPM_MUX_E("SPL SRC0 MUX", SND_SOC_NOPM, SPLINE_SRC0, 0,
  9012. &spl_src0_mux, tasha_codec_enable_spline_resampler,
  9013. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9014. SND_SOC_DAPM_MUX_E("SPL SRC1 MUX", SND_SOC_NOPM, SPLINE_SRC1, 0,
  9015. &spl_src1_mux, tasha_codec_enable_spline_resampler,
  9016. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9017. SND_SOC_DAPM_MUX_E("SPL SRC2 MUX", SND_SOC_NOPM, SPLINE_SRC2, 0,
  9018. &spl_src2_mux, tasha_codec_enable_spline_resampler,
  9019. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9020. SND_SOC_DAPM_MUX_E("SPL SRC3 MUX", SND_SOC_NOPM, SPLINE_SRC3, 0,
  9021. &spl_src3_mux, tasha_codec_enable_spline_resampler,
  9022. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9023. SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  9024. 5, 0, &rx_int0_2_mux, tasha_codec_enable_mix_path,
  9025. SND_SOC_DAPM_POST_PMU),
  9026. SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  9027. 5, 0, &rx_int1_2_mux, tasha_codec_enable_mix_path,
  9028. SND_SOC_DAPM_POST_PMU),
  9029. SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  9030. 5, 0, &rx_int2_2_mux, tasha_codec_enable_mix_path,
  9031. SND_SOC_DAPM_POST_PMU),
  9032. SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", WCD9335_CDC_RX3_RX_PATH_MIX_CTL,
  9033. 5, 0, &rx_int3_2_mux, tasha_codec_enable_mix_path,
  9034. SND_SOC_DAPM_POST_PMU),
  9035. SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", WCD9335_CDC_RX4_RX_PATH_MIX_CTL,
  9036. 5, 0, &rx_int4_2_mux, tasha_codec_enable_mix_path,
  9037. SND_SOC_DAPM_POST_PMU),
  9038. SND_SOC_DAPM_MUX_E("RX INT5_2 MUX", WCD9335_CDC_RX5_RX_PATH_MIX_CTL,
  9039. 5, 0, &rx_int5_2_mux, tasha_codec_enable_mix_path,
  9040. SND_SOC_DAPM_POST_PMU),
  9041. SND_SOC_DAPM_MUX_E("RX INT6_2 MUX", WCD9335_CDC_RX6_RX_PATH_MIX_CTL,
  9042. 5, 0, &rx_int6_2_mux, tasha_codec_enable_mix_path,
  9043. SND_SOC_DAPM_POST_PMU),
  9044. SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", WCD9335_CDC_RX7_RX_PATH_MIX_CTL,
  9045. 5, 0, &rx_int7_2_mux, tasha_codec_enable_mix_path,
  9046. SND_SOC_DAPM_POST_PMU),
  9047. SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", WCD9335_CDC_RX8_RX_PATH_MIX_CTL,
  9048. 5, 0, &rx_int8_2_mux, tasha_codec_enable_mix_path,
  9049. SND_SOC_DAPM_POST_PMU),
  9050. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9051. &rx_int0_1_mix_inp0_mux),
  9052. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9053. &rx_int0_1_mix_inp1_mux),
  9054. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9055. &rx_int0_1_mix_inp2_mux),
  9056. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9057. &rx_int1_1_mix_inp0_mux),
  9058. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9059. &rx_int1_1_mix_inp1_mux),
  9060. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9061. &rx_int1_1_mix_inp2_mux),
  9062. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9063. &rx_int2_1_mix_inp0_mux),
  9064. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9065. &rx_int2_1_mix_inp1_mux),
  9066. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9067. &rx_int2_1_mix_inp2_mux),
  9068. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9069. &rx_int3_1_mix_inp0_mux),
  9070. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9071. &rx_int3_1_mix_inp1_mux),
  9072. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9073. &rx_int3_1_mix_inp2_mux),
  9074. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9075. &rx_int4_1_mix_inp0_mux),
  9076. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9077. &rx_int4_1_mix_inp1_mux),
  9078. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9079. &rx_int4_1_mix_inp2_mux),
  9080. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9081. &rx_int5_1_mix_inp0_mux),
  9082. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9083. &rx_int5_1_mix_inp1_mux),
  9084. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9085. &rx_int5_1_mix_inp2_mux),
  9086. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9087. &rx_int6_1_mix_inp0_mux),
  9088. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9089. &rx_int6_1_mix_inp1_mux),
  9090. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9091. &rx_int6_1_mix_inp2_mux),
  9092. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9093. &rx_int7_1_mix_inp0_mux, tasha_codec_enable_swr,
  9094. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9095. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9096. &rx_int7_1_mix_inp1_mux, tasha_codec_enable_swr,
  9097. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9098. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9099. &rx_int7_1_mix_inp2_mux, tasha_codec_enable_swr,
  9100. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9101. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9102. &rx_int8_1_mix_inp0_mux, tasha_codec_enable_swr,
  9103. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9104. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9105. &rx_int8_1_mix_inp1_mux, tasha_codec_enable_swr,
  9106. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9107. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9108. &rx_int8_1_mix_inp2_mux, tasha_codec_enable_swr,
  9109. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9110. SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9111. SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9112. SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9113. SND_SOC_DAPM_MIXER("RX INT1 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9114. rx_int1_spline_mix_switch,
  9115. ARRAY_SIZE(rx_int1_spline_mix_switch)),
  9116. SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9117. SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9118. SND_SOC_DAPM_MIXER("RX INT2 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9119. rx_int2_spline_mix_switch,
  9120. ARRAY_SIZE(rx_int2_spline_mix_switch)),
  9121. SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9122. SND_SOC_DAPM_MIXER("RX INT3_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9123. SND_SOC_DAPM_MIXER("RX INT3 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9124. rx_int3_spline_mix_switch,
  9125. ARRAY_SIZE(rx_int3_spline_mix_switch)),
  9126. SND_SOC_DAPM_MIXER("RX INT3 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9127. SND_SOC_DAPM_MIXER("RX INT4_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9128. SND_SOC_DAPM_MIXER("RX INT4 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9129. rx_int4_spline_mix_switch,
  9130. ARRAY_SIZE(rx_int4_spline_mix_switch)),
  9131. SND_SOC_DAPM_MIXER("RX INT4 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9132. SND_SOC_DAPM_MIXER("RX INT5_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9133. SND_SOC_DAPM_MIXER("RX INT5 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9134. rx_int5_spline_mix_switch,
  9135. ARRAY_SIZE(rx_int5_spline_mix_switch)),
  9136. SND_SOC_DAPM_MIXER("RX INT5 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9137. SND_SOC_DAPM_MIXER("RX INT6_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9138. SND_SOC_DAPM_MIXER("RX INT6 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9139. rx_int6_spline_mix_switch,
  9140. ARRAY_SIZE(rx_int6_spline_mix_switch)),
  9141. SND_SOC_DAPM_MIXER("RX INT6 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9142. SND_SOC_DAPM_MIXER("RX INT7_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9143. SND_SOC_DAPM_MIXER("RX INT7 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9144. SND_SOC_DAPM_MIXER("RX INT7 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9145. rx_int7_spline_mix_switch,
  9146. ARRAY_SIZE(rx_int7_spline_mix_switch)),
  9147. SND_SOC_DAPM_MIXER("RX INT8_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9148. SND_SOC_DAPM_MIXER("RX INT8 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9149. SND_SOC_DAPM_MIXER("RX INT8 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9150. rx_int8_spline_mix_switch,
  9151. ARRAY_SIZE(rx_int8_spline_mix_switch)),
  9152. SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9153. SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9154. SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9155. SND_SOC_DAPM_MIXER("RX INT3 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9156. SND_SOC_DAPM_MIXER("RX INT4 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9157. SND_SOC_DAPM_MIXER("RX INT5 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9158. SND_SOC_DAPM_MIXER("RX INT6 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9159. SND_SOC_DAPM_MIXER("RX INT7 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9160. SND_SOC_DAPM_MIXER_E("RX INT7 CHAIN", SND_SOC_NOPM, 0, 0,
  9161. NULL, 0, tasha_codec_spk_boost_event,
  9162. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9163. SND_SOC_DAPM_MIXER_E("RX INT8 CHAIN", SND_SOC_NOPM, 0, 0,
  9164. NULL, 0, tasha_codec_spk_boost_event,
  9165. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9166. SND_SOC_DAPM_MIXER_E("RX INT5 VBAT", SND_SOC_NOPM, 0, 0,
  9167. rx_int5_vbat_mix_switch,
  9168. ARRAY_SIZE(rx_int5_vbat_mix_switch),
  9169. tasha_codec_vbat_enable_event,
  9170. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9171. SND_SOC_DAPM_MIXER_E("RX INT6 VBAT", SND_SOC_NOPM, 0, 0,
  9172. rx_int6_vbat_mix_switch,
  9173. ARRAY_SIZE(rx_int6_vbat_mix_switch),
  9174. tasha_codec_vbat_enable_event,
  9175. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9176. SND_SOC_DAPM_MIXER_E("RX INT7 VBAT", SND_SOC_NOPM, 0, 0,
  9177. rx_int7_vbat_mix_switch,
  9178. ARRAY_SIZE(rx_int7_vbat_mix_switch),
  9179. tasha_codec_vbat_enable_event,
  9180. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9181. SND_SOC_DAPM_MIXER_E("RX INT8 VBAT", SND_SOC_NOPM, 0, 0,
  9182. rx_int8_vbat_mix_switch,
  9183. ARRAY_SIZE(rx_int8_vbat_mix_switch),
  9184. tasha_codec_vbat_enable_event,
  9185. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9186. SND_SOC_DAPM_MUX("RX INT0 MIX2 INP", WCD9335_CDC_RX0_RX_PATH_CFG1, 4,
  9187. 0, &rx_int0_mix2_inp_mux),
  9188. SND_SOC_DAPM_MUX("RX INT1 MIX2 INP", WCD9335_CDC_RX1_RX_PATH_CFG1, 4,
  9189. 0, &rx_int1_mix2_inp_mux),
  9190. SND_SOC_DAPM_MUX("RX INT2 MIX2 INP", WCD9335_CDC_RX2_RX_PATH_CFG1, 4,
  9191. 0, &rx_int2_mix2_inp_mux),
  9192. SND_SOC_DAPM_MUX("RX INT3 MIX2 INP", WCD9335_CDC_RX3_RX_PATH_CFG1, 4,
  9193. 0, &rx_int3_mix2_inp_mux),
  9194. SND_SOC_DAPM_MUX("RX INT4 MIX2 INP", WCD9335_CDC_RX4_RX_PATH_CFG1, 4,
  9195. 0, &rx_int4_mix2_inp_mux),
  9196. SND_SOC_DAPM_MUX("RX INT7 MIX2 INP", WCD9335_CDC_RX7_RX_PATH_CFG1, 4,
  9197. 0, &rx_int7_mix2_inp_mux),
  9198. SND_SOC_DAPM_MUX("SLIM TX0 MUX", SND_SOC_NOPM, TASHA_TX0, 0,
  9199. &sb_tx0_mux),
  9200. SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TASHA_TX1, 0,
  9201. &sb_tx1_mux),
  9202. SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TASHA_TX2, 0,
  9203. &sb_tx2_mux),
  9204. SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TASHA_TX3, 0,
  9205. &sb_tx3_mux),
  9206. SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TASHA_TX4, 0,
  9207. &sb_tx4_mux),
  9208. SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TASHA_TX5, 0,
  9209. &sb_tx5_mux),
  9210. SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, TASHA_TX6, 0,
  9211. &sb_tx6_mux),
  9212. SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, TASHA_TX7, 0,
  9213. &sb_tx7_mux),
  9214. SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, TASHA_TX8, 0,
  9215. &sb_tx8_mux),
  9216. SND_SOC_DAPM_MUX("SLIM TX9 MUX", SND_SOC_NOPM, TASHA_TX9, 0,
  9217. &sb_tx9_mux),
  9218. SND_SOC_DAPM_MUX("SLIM TX10 MUX", SND_SOC_NOPM, TASHA_TX10, 0,
  9219. &sb_tx10_mux),
  9220. SND_SOC_DAPM_MUX("SLIM TX11 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9221. &sb_tx11_mux),
  9222. SND_SOC_DAPM_MUX("SLIM TX11 INP1 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9223. &sb_tx11_inp1_mux),
  9224. SND_SOC_DAPM_MUX("SLIM TX13 MUX", SND_SOC_NOPM, TASHA_TX13, 0,
  9225. &sb_tx13_mux),
  9226. SND_SOC_DAPM_MUX("TX13 INP MUX", SND_SOC_NOPM, 0, 0,
  9227. &tx13_inp_mux),
  9228. SND_SOC_DAPM_MUX_E("ADC MUX0", WCD9335_CDC_TX0_TX_PATH_CTL, 5, 0,
  9229. &tx_adc_mux0, tasha_codec_enable_dec,
  9230. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9231. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9232. SND_SOC_DAPM_MUX_E("ADC MUX1", WCD9335_CDC_TX1_TX_PATH_CTL, 5, 0,
  9233. &tx_adc_mux1, tasha_codec_enable_dec,
  9234. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9235. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9236. SND_SOC_DAPM_MUX_E("ADC MUX2", WCD9335_CDC_TX2_TX_PATH_CTL, 5, 0,
  9237. &tx_adc_mux2, tasha_codec_enable_dec,
  9238. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9239. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9240. SND_SOC_DAPM_MUX_E("ADC MUX3", WCD9335_CDC_TX3_TX_PATH_CTL, 5, 0,
  9241. &tx_adc_mux3, tasha_codec_enable_dec,
  9242. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9243. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9244. SND_SOC_DAPM_MUX_E("ADC MUX4", WCD9335_CDC_TX4_TX_PATH_CTL, 5, 0,
  9245. &tx_adc_mux4, tasha_codec_enable_dec,
  9246. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9247. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9248. SND_SOC_DAPM_MUX_E("ADC MUX5", WCD9335_CDC_TX5_TX_PATH_CTL, 5, 0,
  9249. &tx_adc_mux5, tasha_codec_enable_dec,
  9250. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9251. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9252. SND_SOC_DAPM_MUX_E("ADC MUX6", WCD9335_CDC_TX6_TX_PATH_CTL, 5, 0,
  9253. &tx_adc_mux6, tasha_codec_enable_dec,
  9254. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9255. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9256. SND_SOC_DAPM_MUX_E("ADC MUX7", WCD9335_CDC_TX7_TX_PATH_CTL, 5, 0,
  9257. &tx_adc_mux7, tasha_codec_enable_dec,
  9258. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9259. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9260. SND_SOC_DAPM_MUX_E("ADC MUX8", WCD9335_CDC_TX8_TX_PATH_CTL, 5, 0,
  9261. &tx_adc_mux8, tasha_codec_enable_dec,
  9262. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9263. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9264. SND_SOC_DAPM_MUX_E("ADC MUX10", SND_SOC_NOPM, 10, 0,
  9265. &tx_adc_mux10, tasha_codec_tx_adc_cfg,
  9266. SND_SOC_DAPM_POST_PMU),
  9267. SND_SOC_DAPM_MUX_E("ADC MUX11", SND_SOC_NOPM, 11, 0,
  9268. &tx_adc_mux11, tasha_codec_tx_adc_cfg,
  9269. SND_SOC_DAPM_POST_PMU),
  9270. SND_SOC_DAPM_MUX_E("ADC MUX12", SND_SOC_NOPM, 12, 0,
  9271. &tx_adc_mux12, tasha_codec_tx_adc_cfg,
  9272. SND_SOC_DAPM_POST_PMU),
  9273. SND_SOC_DAPM_MUX_E("ADC MUX13", SND_SOC_NOPM, 13, 0,
  9274. &tx_adc_mux13, tasha_codec_tx_adc_cfg,
  9275. SND_SOC_DAPM_POST_PMU),
  9276. SND_SOC_DAPM_MUX("DMIC MUX0", SND_SOC_NOPM, 0, 0,
  9277. &tx_dmic_mux0),
  9278. SND_SOC_DAPM_MUX("DMIC MUX1", SND_SOC_NOPM, 0, 0,
  9279. &tx_dmic_mux1),
  9280. SND_SOC_DAPM_MUX("DMIC MUX2", SND_SOC_NOPM, 0, 0,
  9281. &tx_dmic_mux2),
  9282. SND_SOC_DAPM_MUX("DMIC MUX3", SND_SOC_NOPM, 0, 0,
  9283. &tx_dmic_mux3),
  9284. SND_SOC_DAPM_MUX("DMIC MUX4", SND_SOC_NOPM, 0, 0,
  9285. &tx_dmic_mux4),
  9286. SND_SOC_DAPM_MUX("DMIC MUX5", SND_SOC_NOPM, 0, 0,
  9287. &tx_dmic_mux5),
  9288. SND_SOC_DAPM_MUX("DMIC MUX6", SND_SOC_NOPM, 0, 0,
  9289. &tx_dmic_mux6),
  9290. SND_SOC_DAPM_MUX("DMIC MUX7", SND_SOC_NOPM, 0, 0,
  9291. &tx_dmic_mux7),
  9292. SND_SOC_DAPM_MUX("DMIC MUX8", SND_SOC_NOPM, 0, 0,
  9293. &tx_dmic_mux8),
  9294. SND_SOC_DAPM_MUX("DMIC MUX10", SND_SOC_NOPM, 0, 0,
  9295. &tx_dmic_mux10),
  9296. SND_SOC_DAPM_MUX("DMIC MUX11", SND_SOC_NOPM, 0, 0,
  9297. &tx_dmic_mux11),
  9298. SND_SOC_DAPM_MUX("DMIC MUX12", SND_SOC_NOPM, 0, 0,
  9299. &tx_dmic_mux12),
  9300. SND_SOC_DAPM_MUX("DMIC MUX13", SND_SOC_NOPM, 0, 0,
  9301. &tx_dmic_mux13),
  9302. SND_SOC_DAPM_MUX("AMIC MUX0", SND_SOC_NOPM, 0, 0,
  9303. &tx_amic_mux0),
  9304. SND_SOC_DAPM_MUX("AMIC MUX1", SND_SOC_NOPM, 0, 0,
  9305. &tx_amic_mux1),
  9306. SND_SOC_DAPM_MUX("AMIC MUX2", SND_SOC_NOPM, 0, 0,
  9307. &tx_amic_mux2),
  9308. SND_SOC_DAPM_MUX("AMIC MUX3", SND_SOC_NOPM, 0, 0,
  9309. &tx_amic_mux3),
  9310. SND_SOC_DAPM_MUX("AMIC MUX4", SND_SOC_NOPM, 0, 0,
  9311. &tx_amic_mux4),
  9312. SND_SOC_DAPM_MUX("AMIC MUX5", SND_SOC_NOPM, 0, 0,
  9313. &tx_amic_mux5),
  9314. SND_SOC_DAPM_MUX("AMIC MUX6", SND_SOC_NOPM, 0, 0,
  9315. &tx_amic_mux6),
  9316. SND_SOC_DAPM_MUX("AMIC MUX7", SND_SOC_NOPM, 0, 0,
  9317. &tx_amic_mux7),
  9318. SND_SOC_DAPM_MUX("AMIC MUX8", SND_SOC_NOPM, 0, 0,
  9319. &tx_amic_mux8),
  9320. SND_SOC_DAPM_MUX("AMIC MUX10", SND_SOC_NOPM, 0, 0,
  9321. &tx_amic_mux10),
  9322. SND_SOC_DAPM_MUX("AMIC MUX11", SND_SOC_NOPM, 0, 0,
  9323. &tx_amic_mux11),
  9324. SND_SOC_DAPM_MUX("AMIC MUX12", SND_SOC_NOPM, 0, 0,
  9325. &tx_amic_mux12),
  9326. SND_SOC_DAPM_MUX("AMIC MUX13", SND_SOC_NOPM, 0, 0,
  9327. &tx_amic_mux13),
  9328. SND_SOC_DAPM_ADC_E("ADC1", NULL, WCD9335_ANA_AMIC1, 7, 0,
  9329. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9330. SND_SOC_DAPM_ADC_E("ADC2", NULL, WCD9335_ANA_AMIC2, 7, 0,
  9331. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9332. SND_SOC_DAPM_ADC_E("ADC3", NULL, WCD9335_ANA_AMIC3, 7, 0,
  9333. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9334. SND_SOC_DAPM_ADC_E("ADC4", NULL, WCD9335_ANA_AMIC4, 7, 0,
  9335. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9336. SND_SOC_DAPM_ADC_E("ADC5", NULL, WCD9335_ANA_AMIC5, 7, 0,
  9337. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9338. SND_SOC_DAPM_ADC_E("ADC6", NULL, WCD9335_ANA_AMIC6, 7, 0,
  9339. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9340. SND_SOC_DAPM_SUPPLY("RX INT1 NATIVE SUPPLY", SND_SOC_NOPM,
  9341. INTERP_HPHL, 0, tasha_enable_native_supply,
  9342. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9343. SND_SOC_DAPM_SUPPLY("RX INT2 NATIVE SUPPLY", SND_SOC_NOPM,
  9344. INTERP_HPHR, 0, tasha_enable_native_supply,
  9345. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9346. SND_SOC_DAPM_SUPPLY("RX INT3 NATIVE SUPPLY", SND_SOC_NOPM,
  9347. INTERP_LO1, 0, tasha_enable_native_supply,
  9348. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9349. SND_SOC_DAPM_SUPPLY("RX INT4 NATIVE SUPPLY", SND_SOC_NOPM,
  9350. INTERP_LO2, 0, tasha_enable_native_supply,
  9351. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9352. SND_SOC_DAPM_INPUT("AMIC1"),
  9353. SND_SOC_DAPM_MICBIAS_E("MIC BIAS1", SND_SOC_NOPM, 0, 0,
  9354. tasha_codec_enable_micbias,
  9355. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9356. SND_SOC_DAPM_POST_PMD),
  9357. SND_SOC_DAPM_MICBIAS_E("MIC BIAS2", SND_SOC_NOPM, 0, 0,
  9358. tasha_codec_enable_micbias,
  9359. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9360. SND_SOC_DAPM_POST_PMD),
  9361. SND_SOC_DAPM_MICBIAS_E("MIC BIAS3", SND_SOC_NOPM, 0, 0,
  9362. tasha_codec_enable_micbias,
  9363. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9364. SND_SOC_DAPM_POST_PMD),
  9365. SND_SOC_DAPM_MICBIAS_E("MIC BIAS4", SND_SOC_NOPM, 0, 0,
  9366. tasha_codec_enable_micbias,
  9367. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9368. SND_SOC_DAPM_POST_PMD),
  9369. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS1_STANDALONE, SND_SOC_NOPM, 0, 0,
  9370. tasha_codec_force_enable_micbias,
  9371. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9372. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS2_STANDALONE, SND_SOC_NOPM, 0, 0,
  9373. tasha_codec_force_enable_micbias,
  9374. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9375. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS3_STANDALONE, SND_SOC_NOPM, 0, 0,
  9376. tasha_codec_force_enable_micbias,
  9377. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9378. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS4_STANDALONE, SND_SOC_NOPM, 0, 0,
  9379. tasha_codec_force_enable_micbias,
  9380. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9381. SND_SOC_DAPM_SUPPLY(DAPM_LDO_H_STANDALONE, SND_SOC_NOPM, 0, 0,
  9382. tasha_codec_force_enable_ldo_h,
  9383. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9384. SND_SOC_DAPM_MUX("ANC0 FB MUX", SND_SOC_NOPM, 0, 0, &anc0_fb_mux),
  9385. SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux),
  9386. SND_SOC_DAPM_INPUT("AMIC2"),
  9387. SND_SOC_DAPM_INPUT("AMIC3"),
  9388. SND_SOC_DAPM_INPUT("AMIC4"),
  9389. SND_SOC_DAPM_INPUT("AMIC5"),
  9390. SND_SOC_DAPM_INPUT("AMIC6"),
  9391. SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM,
  9392. AIF1_CAP, 0, tasha_codec_enable_slimtx,
  9393. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9394. SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM,
  9395. AIF2_CAP, 0, tasha_codec_enable_slimtx,
  9396. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9397. SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM,
  9398. AIF3_CAP, 0, tasha_codec_enable_slimtx,
  9399. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9400. SND_SOC_DAPM_AIF_OUT_E("AIF4 VI", "VIfeed", 0, SND_SOC_NOPM,
  9401. AIF4_VIFEED, 0, tasha_codec_enable_slimvi_feedback,
  9402. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9403. SND_SOC_DAPM_MIXER("AIF4_VI Mixer", SND_SOC_NOPM, AIF4_VIFEED, 0,
  9404. aif4_vi_mixer, ARRAY_SIZE(aif4_vi_mixer)),
  9405. SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0,
  9406. aif1_cap_mixer, ARRAY_SIZE(aif1_cap_mixer)),
  9407. SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0,
  9408. aif2_cap_mixer, ARRAY_SIZE(aif2_cap_mixer)),
  9409. SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0,
  9410. aif3_cap_mixer, ARRAY_SIZE(aif3_cap_mixer)),
  9411. SND_SOC_DAPM_MIXER("AIF4_MAD Mixer", SND_SOC_NOPM, AIF4_MAD_TX, 0,
  9412. aif4_mad_mixer, ARRAY_SIZE(aif4_mad_mixer)),
  9413. SND_SOC_DAPM_INPUT("VIINPUT"),
  9414. SND_SOC_DAPM_AIF_OUT("AIF5 CPE", "AIF5 CPE TX", 0, SND_SOC_NOPM,
  9415. AIF5_CPE_TX, 0),
  9416. SND_SOC_DAPM_MUX_E("EC BUF MUX INP", SND_SOC_NOPM, 0, 0, &ec_buf_mux,
  9417. tasha_codec_ec_buf_mux_enable,
  9418. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9419. /* Digital Mic Inputs */
  9420. SND_SOC_DAPM_ADC_E("DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  9421. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9422. SND_SOC_DAPM_POST_PMD),
  9423. SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  9424. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9425. SND_SOC_DAPM_POST_PMD),
  9426. SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  9427. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9428. SND_SOC_DAPM_POST_PMD),
  9429. SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  9430. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9431. SND_SOC_DAPM_POST_PMD),
  9432. SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  9433. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9434. SND_SOC_DAPM_POST_PMD),
  9435. SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  9436. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9437. SND_SOC_DAPM_POST_PMD),
  9438. SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux),
  9439. SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux),
  9440. SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux),
  9441. SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux),
  9442. SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux),
  9443. SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
  9444. SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux),
  9445. SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux),
  9446. SND_SOC_DAPM_MIXER_E("IIR0", WCD9335_CDC_SIDETONE_IIR0_IIR_PATH_CTL,
  9447. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9448. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9449. SND_SOC_DAPM_MIXER_E("IIR1", WCD9335_CDC_SIDETONE_IIR1_IIR_PATH_CTL,
  9450. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9451. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9452. SND_SOC_DAPM_MIXER("SRC0", WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL,
  9453. 4, 0, NULL, 0),
  9454. SND_SOC_DAPM_MIXER("SRC1", WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL,
  9455. 4, 0, NULL, 0),
  9456. SND_SOC_DAPM_MIXER_E("CPE IN Mixer", SND_SOC_NOPM, 0, 0,
  9457. cpe_in_mix_switch,
  9458. ARRAY_SIZE(cpe_in_mix_switch),
  9459. tasha_codec_configure_cpe_input,
  9460. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9461. SND_SOC_DAPM_MUX("RX INT1_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9462. &int1_1_native_mux),
  9463. SND_SOC_DAPM_MUX("RX INT2_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9464. &int2_1_native_mux),
  9465. SND_SOC_DAPM_MUX("RX INT3_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9466. &int3_1_native_mux),
  9467. SND_SOC_DAPM_MUX("RX INT4_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9468. &int4_1_native_mux),
  9469. SND_SOC_DAPM_MUX("RX MIX TX0 MUX", SND_SOC_NOPM, 0, 0,
  9470. &rx_mix_tx0_mux),
  9471. SND_SOC_DAPM_MUX("RX MIX TX1 MUX", SND_SOC_NOPM, 0, 0,
  9472. &rx_mix_tx1_mux),
  9473. SND_SOC_DAPM_MUX("RX MIX TX2 MUX", SND_SOC_NOPM, 0, 0,
  9474. &rx_mix_tx2_mux),
  9475. SND_SOC_DAPM_MUX("RX MIX TX3 MUX", SND_SOC_NOPM, 0, 0,
  9476. &rx_mix_tx3_mux),
  9477. SND_SOC_DAPM_MUX("RX MIX TX4 MUX", SND_SOC_NOPM, 0, 0,
  9478. &rx_mix_tx4_mux),
  9479. SND_SOC_DAPM_MUX("RX MIX TX5 MUX", SND_SOC_NOPM, 0, 0,
  9480. &rx_mix_tx5_mux),
  9481. SND_SOC_DAPM_MUX("RX MIX TX6 MUX", SND_SOC_NOPM, 0, 0,
  9482. &rx_mix_tx6_mux),
  9483. SND_SOC_DAPM_MUX("RX MIX TX7 MUX", SND_SOC_NOPM, 0, 0,
  9484. &rx_mix_tx7_mux),
  9485. SND_SOC_DAPM_MUX("RX MIX TX8 MUX", SND_SOC_NOPM, 0, 0,
  9486. &rx_mix_tx8_mux),
  9487. SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0,
  9488. &rx_int0_dem_inp_mux),
  9489. SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0,
  9490. &rx_int1_dem_inp_mux),
  9491. SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM, 0, 0,
  9492. &rx_int2_dem_inp_mux),
  9493. SND_SOC_DAPM_MUX_E("RX INT0 INTERP", SND_SOC_NOPM,
  9494. INTERP_EAR, 0, &rx_int0_interp_mux,
  9495. tasha_codec_enable_interpolator,
  9496. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9497. SND_SOC_DAPM_POST_PMD),
  9498. SND_SOC_DAPM_MUX_E("RX INT1 INTERP", SND_SOC_NOPM,
  9499. INTERP_HPHL, 0, &rx_int1_interp_mux,
  9500. tasha_codec_enable_interpolator,
  9501. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9502. SND_SOC_DAPM_POST_PMD),
  9503. SND_SOC_DAPM_MUX_E("RX INT2 INTERP", SND_SOC_NOPM,
  9504. INTERP_HPHR, 0, &rx_int2_interp_mux,
  9505. tasha_codec_enable_interpolator,
  9506. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9507. SND_SOC_DAPM_POST_PMD),
  9508. SND_SOC_DAPM_MUX_E("RX INT3 INTERP", SND_SOC_NOPM,
  9509. INTERP_LO1, 0, &rx_int3_interp_mux,
  9510. tasha_codec_enable_interpolator,
  9511. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9512. SND_SOC_DAPM_POST_PMD),
  9513. SND_SOC_DAPM_MUX_E("RX INT4 INTERP", SND_SOC_NOPM,
  9514. INTERP_LO2, 0, &rx_int4_interp_mux,
  9515. tasha_codec_enable_interpolator,
  9516. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9517. SND_SOC_DAPM_POST_PMD),
  9518. SND_SOC_DAPM_MUX_E("RX INT5 INTERP", SND_SOC_NOPM,
  9519. INTERP_LO3, 0, &rx_int5_interp_mux,
  9520. tasha_codec_enable_interpolator,
  9521. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9522. SND_SOC_DAPM_POST_PMD),
  9523. SND_SOC_DAPM_MUX_E("RX INT6 INTERP", SND_SOC_NOPM,
  9524. INTERP_LO4, 0, &rx_int6_interp_mux,
  9525. tasha_codec_enable_interpolator,
  9526. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9527. SND_SOC_DAPM_POST_PMD),
  9528. SND_SOC_DAPM_MUX_E("RX INT7 INTERP", SND_SOC_NOPM,
  9529. INTERP_SPKR1, 0, &rx_int7_interp_mux,
  9530. tasha_codec_enable_interpolator,
  9531. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9532. SND_SOC_DAPM_POST_PMD),
  9533. SND_SOC_DAPM_MUX_E("RX INT8 INTERP", SND_SOC_NOPM,
  9534. INTERP_SPKR2, 0, &rx_int8_interp_mux,
  9535. tasha_codec_enable_interpolator,
  9536. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9537. SND_SOC_DAPM_POST_PMD),
  9538. SND_SOC_DAPM_DAC_E("RX INT0 DAC", NULL, SND_SOC_NOPM,
  9539. 0, 0, tasha_codec_ear_dac_event,
  9540. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9541. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9542. SND_SOC_DAPM_DAC_E("RX INT1 DAC", NULL, SND_SOC_NOPM,
  9543. 0, 0, tasha_codec_hphl_dac_event,
  9544. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9545. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9546. SND_SOC_DAPM_DAC_E("RX INT2 DAC", NULL, SND_SOC_NOPM,
  9547. 0, 0, tasha_codec_hphr_dac_event,
  9548. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9549. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9550. SND_SOC_DAPM_DAC_E("RX INT3 DAC", NULL, SND_SOC_NOPM,
  9551. 0, 0, tasha_codec_lineout_dac_event,
  9552. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9553. SND_SOC_DAPM_DAC_E("RX INT4 DAC", NULL, SND_SOC_NOPM,
  9554. 0, 0, tasha_codec_lineout_dac_event,
  9555. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9556. SND_SOC_DAPM_DAC_E("RX INT5 DAC", NULL, SND_SOC_NOPM,
  9557. 0, 0, tasha_codec_lineout_dac_event,
  9558. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9559. SND_SOC_DAPM_DAC_E("RX INT6 DAC", NULL, SND_SOC_NOPM,
  9560. 0, 0, tasha_codec_lineout_dac_event,
  9561. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9562. SND_SOC_DAPM_PGA_E("HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9563. tasha_codec_enable_hphl_pa,
  9564. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9565. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9566. SND_SOC_DAPM_PGA_E("HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9567. tasha_codec_enable_hphr_pa,
  9568. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9569. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9570. SND_SOC_DAPM_PGA_E("EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9571. tasha_codec_enable_ear_pa,
  9572. SND_SOC_DAPM_POST_PMU |
  9573. SND_SOC_DAPM_POST_PMD),
  9574. SND_SOC_DAPM_PGA_E("LINEOUT1 PA", WCD9335_ANA_LO_1_2, 7, 0, NULL, 0,
  9575. tasha_codec_enable_lineout_pa,
  9576. SND_SOC_DAPM_POST_PMU |
  9577. SND_SOC_DAPM_POST_PMD),
  9578. SND_SOC_DAPM_PGA_E("LINEOUT2 PA", WCD9335_ANA_LO_1_2, 6, 0, NULL, 0,
  9579. tasha_codec_enable_lineout_pa,
  9580. SND_SOC_DAPM_POST_PMU |
  9581. SND_SOC_DAPM_POST_PMD),
  9582. SND_SOC_DAPM_PGA_E("LINEOUT3 PA", WCD9335_ANA_LO_3_4, 7, 0, NULL, 0,
  9583. tasha_codec_enable_lineout_pa,
  9584. SND_SOC_DAPM_POST_PMU |
  9585. SND_SOC_DAPM_POST_PMD),
  9586. SND_SOC_DAPM_PGA_E("LINEOUT4 PA", WCD9335_ANA_LO_3_4, 6, 0, NULL, 0,
  9587. tasha_codec_enable_lineout_pa,
  9588. SND_SOC_DAPM_POST_PMU |
  9589. SND_SOC_DAPM_POST_PMD),
  9590. SND_SOC_DAPM_PGA_E("ANC EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9591. tasha_codec_enable_ear_pa,
  9592. SND_SOC_DAPM_POST_PMU |
  9593. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9594. SND_SOC_DAPM_PGA_E("ANC HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9595. tasha_codec_enable_hphl_pa,
  9596. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9597. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9598. SND_SOC_DAPM_PGA_E("ANC HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9599. tasha_codec_enable_hphr_pa,
  9600. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9601. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9602. SND_SOC_DAPM_PGA_E("ANC LINEOUT1 PA", WCD9335_ANA_LO_1_2,
  9603. 7, 0, NULL, 0,
  9604. tasha_codec_enable_lineout_pa,
  9605. SND_SOC_DAPM_POST_PMU |
  9606. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9607. SND_SOC_DAPM_PGA_E("ANC LINEOUT2 PA", WCD9335_ANA_LO_1_2,
  9608. 6, 0, NULL, 0,
  9609. tasha_codec_enable_lineout_pa,
  9610. SND_SOC_DAPM_POST_PMU |
  9611. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9612. SND_SOC_DAPM_PGA_E("ANC SPK1 PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9613. tasha_codec_enable_spk_anc,
  9614. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9615. SND_SOC_DAPM_OUTPUT("HPHL"),
  9616. SND_SOC_DAPM_OUTPUT("HPHR"),
  9617. SND_SOC_DAPM_OUTPUT("ANC HPHL"),
  9618. SND_SOC_DAPM_OUTPUT("ANC HPHR"),
  9619. SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0,
  9620. tasha_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU |
  9621. SND_SOC_DAPM_POST_PMD),
  9622. SND_SOC_DAPM_OUTPUT("SPK1 OUT"),
  9623. SND_SOC_DAPM_OUTPUT("SPK2 OUT"),
  9624. SND_SOC_DAPM_OUTPUT("LINEOUT1"),
  9625. SND_SOC_DAPM_OUTPUT("LINEOUT2"),
  9626. SND_SOC_DAPM_OUTPUT("LINEOUT3"),
  9627. SND_SOC_DAPM_OUTPUT("LINEOUT4"),
  9628. SND_SOC_DAPM_OUTPUT("ANC LINEOUT1"),
  9629. SND_SOC_DAPM_OUTPUT("ANC LINEOUT2"),
  9630. SND_SOC_DAPM_SUPPLY("MICBIAS_REGULATOR", SND_SOC_NOPM,
  9631. ON_DEMAND_MICBIAS, 0,
  9632. tasha_codec_enable_on_demand_supply,
  9633. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9634. SND_SOC_DAPM_SWITCH("ADC US MUX0", WCD9335_CDC_TX0_TX_PATH_192_CTL, 0,
  9635. 0, &adc_us_mux0_switch),
  9636. SND_SOC_DAPM_SWITCH("ADC US MUX1", WCD9335_CDC_TX1_TX_PATH_192_CTL, 0,
  9637. 0, &adc_us_mux1_switch),
  9638. SND_SOC_DAPM_SWITCH("ADC US MUX2", WCD9335_CDC_TX2_TX_PATH_192_CTL, 0,
  9639. 0, &adc_us_mux2_switch),
  9640. SND_SOC_DAPM_SWITCH("ADC US MUX3", WCD9335_CDC_TX3_TX_PATH_192_CTL, 0,
  9641. 0, &adc_us_mux3_switch),
  9642. SND_SOC_DAPM_SWITCH("ADC US MUX4", WCD9335_CDC_TX4_TX_PATH_192_CTL, 0,
  9643. 0, &adc_us_mux4_switch),
  9644. SND_SOC_DAPM_SWITCH("ADC US MUX5", WCD9335_CDC_TX5_TX_PATH_192_CTL, 0,
  9645. 0, &adc_us_mux5_switch),
  9646. SND_SOC_DAPM_SWITCH("ADC US MUX6", WCD9335_CDC_TX6_TX_PATH_192_CTL, 0,
  9647. 0, &adc_us_mux6_switch),
  9648. SND_SOC_DAPM_SWITCH("ADC US MUX7", WCD9335_CDC_TX7_TX_PATH_192_CTL, 0,
  9649. 0, &adc_us_mux7_switch),
  9650. SND_SOC_DAPM_SWITCH("ADC US MUX8", WCD9335_CDC_TX8_TX_PATH_192_CTL, 0,
  9651. 0, &adc_us_mux8_switch),
  9652. /* MAD related widgets */
  9653. SND_SOC_DAPM_AIF_OUT_E("AIF4 MAD", "AIF4 MAD TX", 0,
  9654. SND_SOC_NOPM, 0, 0,
  9655. tasha_codec_enable_mad,
  9656. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9657. SND_SOC_DAPM_MUX("MAD_SEL MUX", SND_SOC_NOPM, 0, 0,
  9658. &mad_sel_mux),
  9659. SND_SOC_DAPM_INPUT("MAD_CPE_INPUT"),
  9660. SND_SOC_DAPM_INPUT("MADINPUT"),
  9661. SND_SOC_DAPM_SWITCH("MADONOFF", SND_SOC_NOPM, 0, 0,
  9662. &aif4_mad_switch),
  9663. SND_SOC_DAPM_SWITCH("MAD_BROADCAST", SND_SOC_NOPM, 0, 0,
  9664. &mad_brdcst_switch),
  9665. SND_SOC_DAPM_SWITCH("AIF4", SND_SOC_NOPM, 0, 0,
  9666. &aif4_switch_mixer_controls),
  9667. SND_SOC_DAPM_SWITCH("ANC HPHL Enable", SND_SOC_NOPM, 0, 0,
  9668. &anc_hphl_switch),
  9669. SND_SOC_DAPM_SWITCH("ANC HPHR Enable", SND_SOC_NOPM, 0, 0,
  9670. &anc_hphr_switch),
  9671. SND_SOC_DAPM_SWITCH("ANC EAR Enable", SND_SOC_NOPM, 0, 0,
  9672. &anc_ear_switch),
  9673. SND_SOC_DAPM_SWITCH("ANC OUT EAR SPKR Enable", SND_SOC_NOPM, 0, 0,
  9674. &anc_ear_spkr_switch),
  9675. SND_SOC_DAPM_SWITCH("ANC LINEOUT1 Enable", SND_SOC_NOPM, 0, 0,
  9676. &anc_lineout1_switch),
  9677. SND_SOC_DAPM_SWITCH("ANC LINEOUT2 Enable", SND_SOC_NOPM, 0, 0,
  9678. &anc_lineout2_switch),
  9679. SND_SOC_DAPM_SWITCH("ANC SPKR PA Enable", SND_SOC_NOPM, 0, 0,
  9680. &anc_spkr_pa_switch),
  9681. };
  9682. static int tasha_get_channel_map(struct snd_soc_dai *dai,
  9683. unsigned int *tx_num, unsigned int *tx_slot,
  9684. unsigned int *rx_num, unsigned int *rx_slot)
  9685. {
  9686. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(dai->codec);
  9687. u32 i = 0;
  9688. struct wcd9xxx_ch *ch;
  9689. switch (dai->id) {
  9690. case AIF1_PB:
  9691. case AIF2_PB:
  9692. case AIF3_PB:
  9693. case AIF4_PB:
  9694. case AIF_MIX1_PB:
  9695. if (!rx_slot || !rx_num) {
  9696. pr_err("%s: Invalid rx_slot %pK or rx_num %pK\n",
  9697. __func__, rx_slot, rx_num);
  9698. return -EINVAL;
  9699. }
  9700. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9701. list) {
  9702. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9703. __func__, i, ch->ch_num);
  9704. rx_slot[i++] = ch->ch_num;
  9705. }
  9706. pr_debug("%s: rx_num %d\n", __func__, i);
  9707. *rx_num = i;
  9708. break;
  9709. case AIF1_CAP:
  9710. case AIF2_CAP:
  9711. case AIF3_CAP:
  9712. case AIF4_MAD_TX:
  9713. case AIF4_VIFEED:
  9714. if (!tx_slot || !tx_num) {
  9715. pr_err("%s: Invalid tx_slot %pK or tx_num %pK\n",
  9716. __func__, tx_slot, tx_num);
  9717. return -EINVAL;
  9718. }
  9719. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9720. list) {
  9721. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9722. __func__, i, ch->ch_num);
  9723. tx_slot[i++] = ch->ch_num;
  9724. }
  9725. pr_debug("%s: tx_num %d\n", __func__, i);
  9726. *tx_num = i;
  9727. break;
  9728. default:
  9729. pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id);
  9730. break;
  9731. }
  9732. return 0;
  9733. }
  9734. static int tasha_set_channel_map(struct snd_soc_dai *dai,
  9735. unsigned int tx_num, unsigned int *tx_slot,
  9736. unsigned int rx_num, unsigned int *rx_slot)
  9737. {
  9738. struct tasha_priv *tasha;
  9739. struct wcd9xxx *core;
  9740. struct wcd9xxx_codec_dai_data *dai_data = NULL;
  9741. if (!dai) {
  9742. pr_err("%s: dai is empty\n", __func__);
  9743. return -EINVAL;
  9744. }
  9745. tasha = snd_soc_codec_get_drvdata(dai->codec);
  9746. core = dev_get_drvdata(dai->codec->dev->parent);
  9747. if (!tx_slot || !rx_slot) {
  9748. pr_err("%s: Invalid tx_slot=%pK, rx_slot=%pK\n",
  9749. __func__, tx_slot, rx_slot);
  9750. return -EINVAL;
  9751. }
  9752. pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n"
  9753. "tasha->intf_type %d\n",
  9754. __func__, dai->name, dai->id, tx_num, rx_num,
  9755. tasha->intf_type);
  9756. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  9757. wcd9xxx_init_slimslave(core, core->slim->laddr,
  9758. tx_num, tx_slot, rx_num, rx_slot);
  9759. /* Reserve TX12/TX13 for MAD data channel */
  9760. dai_data = &tasha->dai[AIF4_MAD_TX];
  9761. if (dai_data) {
  9762. if (TASHA_IS_2_0(tasha->wcd9xxx))
  9763. list_add_tail(&core->tx_chs[TASHA_TX13].list,
  9764. &dai_data->wcd9xxx_ch_list);
  9765. else
  9766. list_add_tail(&core->tx_chs[TASHA_TX12].list,
  9767. &dai_data->wcd9xxx_ch_list);
  9768. }
  9769. }
  9770. return 0;
  9771. }
  9772. static int tasha_startup(struct snd_pcm_substream *substream,
  9773. struct snd_soc_dai *dai)
  9774. {
  9775. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9776. substream->name, substream->stream);
  9777. return 0;
  9778. }
  9779. static void tasha_shutdown(struct snd_pcm_substream *substream,
  9780. struct snd_soc_dai *dai)
  9781. {
  9782. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  9783. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9784. substream->name, substream->stream);
  9785. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  9786. return;
  9787. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  9788. tasha_codec_vote_max_bw(dai->codec, false);
  9789. }
  9790. static int tasha_set_decimator_rate(struct snd_soc_dai *dai,
  9791. u8 tx_fs_rate_reg_val, u32 sample_rate)
  9792. {
  9793. struct snd_soc_codec *codec = dai->codec;
  9794. struct wcd9xxx_ch *ch;
  9795. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9796. u32 tx_port = 0;
  9797. u8 shift = 0, shift_val = 0, tx_mux_sel = 0;
  9798. int decimator = -1;
  9799. u16 tx_port_reg = 0, tx_fs_reg = 0;
  9800. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9801. tx_port = ch->port;
  9802. dev_dbg(codec->dev, "%s: dai->id = %d, tx_port = %d",
  9803. __func__, dai->id, tx_port);
  9804. if ((tx_port < 0) || (tx_port == 12) || (tx_port >= 14)) {
  9805. dev_err(codec->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n",
  9806. __func__, tx_port, dai->id);
  9807. return -EINVAL;
  9808. }
  9809. /* Find the SB TX MUX input - which decimator is connected */
  9810. if (tx_port < 4) {
  9811. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0;
  9812. shift = (tx_port << 1);
  9813. shift_val = 0x03;
  9814. } else if ((tx_port >= 4) && (tx_port < 8)) {
  9815. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1;
  9816. shift = ((tx_port - 4) << 1);
  9817. shift_val = 0x03;
  9818. } else if ((tx_port >= 8) && (tx_port < 11)) {
  9819. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2;
  9820. shift = ((tx_port - 8) << 1);
  9821. shift_val = 0x03;
  9822. } else if (tx_port == 11) {
  9823. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9824. shift = 0;
  9825. shift_val = 0x0F;
  9826. } else if (tx_port == 13) {
  9827. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9828. shift = 4;
  9829. shift_val = 0x03;
  9830. }
  9831. tx_mux_sel = snd_soc_read(codec, tx_port_reg) &
  9832. (shift_val << shift);
  9833. tx_mux_sel = tx_mux_sel >> shift;
  9834. if (tx_port <= 8) {
  9835. if ((tx_mux_sel == 0x2) || (tx_mux_sel == 0x3))
  9836. decimator = tx_port;
  9837. } else if (tx_port <= 10) {
  9838. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9839. decimator = ((tx_port == 9) ? 7 : 6);
  9840. } else if (tx_port == 11) {
  9841. if ((tx_mux_sel >= 1) && (tx_mux_sel < 7))
  9842. decimator = tx_mux_sel - 1;
  9843. } else if (tx_port == 13) {
  9844. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9845. decimator = 5;
  9846. }
  9847. if (decimator >= 0) {
  9848. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  9849. 16 * decimator;
  9850. dev_dbg(codec->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n",
  9851. __func__, decimator, tx_port, sample_rate);
  9852. snd_soc_update_bits(codec, tx_fs_reg, 0x0F,
  9853. tx_fs_rate_reg_val);
  9854. } else if ((tx_port <= 8) && (tx_mux_sel == 0x01)) {
  9855. /* Check if the TX Mux input is RX MIX TXn */
  9856. dev_dbg(codec->dev, "%s: RX_MIX_TX%u going to SLIM TX%u\n",
  9857. __func__, tx_port, tx_port);
  9858. } else {
  9859. dev_err(codec->dev, "%s: ERROR: Invalid decimator: %d\n",
  9860. __func__, decimator);
  9861. return -EINVAL;
  9862. }
  9863. }
  9864. return 0;
  9865. }
  9866. static int tasha_set_mix_interpolator_rate(struct snd_soc_dai *dai,
  9867. u8 int_mix_fs_rate_reg_val,
  9868. u32 sample_rate)
  9869. {
  9870. u8 int_2_inp;
  9871. u32 j;
  9872. u16 int_mux_cfg1, int_fs_reg;
  9873. u8 int_mux_cfg1_val;
  9874. struct snd_soc_codec *codec = dai->codec;
  9875. struct wcd9xxx_ch *ch;
  9876. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9877. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9878. int_2_inp = ch->port + INTn_2_INP_SEL_RX0 -
  9879. TASHA_RX_PORT_START_NUMBER;
  9880. if ((int_2_inp < INTn_2_INP_SEL_RX0) ||
  9881. (int_2_inp > INTn_2_INP_SEL_RX7)) {
  9882. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9883. __func__,
  9884. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9885. dai->id);
  9886. return -EINVAL;
  9887. }
  9888. int_mux_cfg1 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1;
  9889. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9890. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) &
  9891. 0x0F;
  9892. if (int_mux_cfg1_val == int_2_inp) {
  9893. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_MIX_CTL +
  9894. 20 * j;
  9895. pr_debug("%s: AIF_MIX_PB DAI(%d) connected to INT%u_2\n",
  9896. __func__, dai->id, j);
  9897. pr_debug("%s: set INT%u_2 sample rate to %u\n",
  9898. __func__, j, sample_rate);
  9899. snd_soc_update_bits(codec, int_fs_reg,
  9900. 0x0F, int_mix_fs_rate_reg_val);
  9901. }
  9902. int_mux_cfg1 += 2;
  9903. }
  9904. }
  9905. return 0;
  9906. }
  9907. static int tasha_set_prim_interpolator_rate(struct snd_soc_dai *dai,
  9908. u8 int_prim_fs_rate_reg_val,
  9909. u32 sample_rate)
  9910. {
  9911. u8 int_1_mix1_inp;
  9912. u32 j;
  9913. u16 int_mux_cfg0, int_mux_cfg1;
  9914. u16 int_fs_reg;
  9915. u8 int_mux_cfg0_val, int_mux_cfg1_val;
  9916. u8 inp0_sel, inp1_sel, inp2_sel;
  9917. struct snd_soc_codec *codec = dai->codec;
  9918. struct wcd9xxx_ch *ch;
  9919. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9920. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9921. int_1_mix1_inp = ch->port + INTn_1_MIX_INP_SEL_RX0 -
  9922. TASHA_RX_PORT_START_NUMBER;
  9923. if ((int_1_mix1_inp < INTn_1_MIX_INP_SEL_RX0) ||
  9924. (int_1_mix1_inp > INTn_1_MIX_INP_SEL_RX7)) {
  9925. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9926. __func__,
  9927. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9928. dai->id);
  9929. return -EINVAL;
  9930. }
  9931. int_mux_cfg0 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0;
  9932. /*
  9933. * Loop through all interpolator MUX inputs and find out
  9934. * to which interpolator input, the slim rx port
  9935. * is connected
  9936. */
  9937. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9938. int_mux_cfg1 = int_mux_cfg0 + 1;
  9939. int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0);
  9940. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1);
  9941. inp0_sel = int_mux_cfg0_val & 0x0F;
  9942. inp1_sel = (int_mux_cfg0_val >> 4) & 0x0F;
  9943. inp2_sel = (int_mux_cfg1_val >> 4) & 0x0F;
  9944. if ((inp0_sel == int_1_mix1_inp) ||
  9945. (inp1_sel == int_1_mix1_inp) ||
  9946. (inp2_sel == int_1_mix1_inp)) {
  9947. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_CTL +
  9948. 20 * j;
  9949. pr_debug("%s: AIF_PB DAI(%d) connected to INT%u_1\n",
  9950. __func__, dai->id, j);
  9951. pr_debug("%s: set INT%u_1 sample rate to %u\n",
  9952. __func__, j, sample_rate);
  9953. /* sample_rate is in Hz */
  9954. if ((j == 0) && (sample_rate == 44100)) {
  9955. pr_info("%s: Cannot set 44.1KHz on INT0\n",
  9956. __func__);
  9957. } else
  9958. snd_soc_update_bits(codec, int_fs_reg,
  9959. 0x0F, int_prim_fs_rate_reg_val);
  9960. }
  9961. int_mux_cfg0 += 2;
  9962. }
  9963. }
  9964. return 0;
  9965. }
  9966. static int tasha_set_interpolator_rate(struct snd_soc_dai *dai,
  9967. u32 sample_rate)
  9968. {
  9969. int rate_val = 0;
  9970. int i, ret;
  9971. /* set mixing path rate */
  9972. for (i = 0; i < ARRAY_SIZE(int_mix_sample_rate_val); i++) {
  9973. if (sample_rate ==
  9974. int_mix_sample_rate_val[i].sample_rate) {
  9975. rate_val =
  9976. int_mix_sample_rate_val[i].rate_val;
  9977. break;
  9978. }
  9979. }
  9980. if ((i == ARRAY_SIZE(int_mix_sample_rate_val)) ||
  9981. (rate_val < 0))
  9982. goto prim_rate;
  9983. ret = tasha_set_mix_interpolator_rate(dai,
  9984. (u8) rate_val, sample_rate);
  9985. prim_rate:
  9986. /* set primary path sample rate */
  9987. for (i = 0; i < ARRAY_SIZE(int_prim_sample_rate_val); i++) {
  9988. if (sample_rate ==
  9989. int_prim_sample_rate_val[i].sample_rate) {
  9990. rate_val =
  9991. int_prim_sample_rate_val[i].rate_val;
  9992. break;
  9993. }
  9994. }
  9995. if ((i == ARRAY_SIZE(int_prim_sample_rate_val)) ||
  9996. (rate_val < 0))
  9997. return -EINVAL;
  9998. ret = tasha_set_prim_interpolator_rate(dai,
  9999. (u8) rate_val, sample_rate);
  10000. return ret;
  10001. }
  10002. static int tasha_prepare(struct snd_pcm_substream *substream,
  10003. struct snd_soc_dai *dai)
  10004. {
  10005. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  10006. substream->name, substream->stream);
  10007. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  10008. tasha_codec_vote_max_bw(dai->codec, false);
  10009. return 0;
  10010. }
  10011. static int tasha_hw_params(struct snd_pcm_substream *substream,
  10012. struct snd_pcm_hw_params *params,
  10013. struct snd_soc_dai *dai)
  10014. {
  10015. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  10016. int ret;
  10017. int tx_fs_rate = -EINVAL;
  10018. int rx_fs_rate = -EINVAL;
  10019. int i2s_bit_mode;
  10020. struct snd_soc_codec *codec = dai->codec;
  10021. pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
  10022. dai->name, dai->id, params_rate(params),
  10023. params_channels(params));
  10024. switch (substream->stream) {
  10025. case SNDRV_PCM_STREAM_PLAYBACK:
  10026. ret = tasha_set_interpolator_rate(dai, params_rate(params));
  10027. if (ret) {
  10028. pr_err("%s: cannot set sample rate: %u\n",
  10029. __func__, params_rate(params));
  10030. return ret;
  10031. }
  10032. switch (params_width(params)) {
  10033. case 16:
  10034. tasha->dai[dai->id].bit_width = 16;
  10035. i2s_bit_mode = 0x01;
  10036. break;
  10037. case 24:
  10038. tasha->dai[dai->id].bit_width = 24;
  10039. i2s_bit_mode = 0x00;
  10040. break;
  10041. default:
  10042. return -EINVAL;
  10043. }
  10044. tasha->dai[dai->id].rate = params_rate(params);
  10045. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10046. switch (params_rate(params)) {
  10047. case 8000:
  10048. rx_fs_rate = 0;
  10049. break;
  10050. case 16000:
  10051. rx_fs_rate = 1;
  10052. break;
  10053. case 32000:
  10054. rx_fs_rate = 2;
  10055. break;
  10056. case 48000:
  10057. rx_fs_rate = 3;
  10058. break;
  10059. case 96000:
  10060. rx_fs_rate = 4;
  10061. break;
  10062. case 192000:
  10063. rx_fs_rate = 5;
  10064. break;
  10065. default:
  10066. dev_err(tasha->dev,
  10067. "%s: Invalid RX sample rate: %d\n",
  10068. __func__, params_rate(params));
  10069. return -EINVAL;
  10070. };
  10071. snd_soc_update_bits(codec,
  10072. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10073. 0x20, i2s_bit_mode << 5);
  10074. snd_soc_update_bits(codec,
  10075. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10076. 0x1c, (rx_fs_rate << 2));
  10077. }
  10078. break;
  10079. case SNDRV_PCM_STREAM_CAPTURE:
  10080. switch (params_rate(params)) {
  10081. case 8000:
  10082. tx_fs_rate = 0;
  10083. break;
  10084. case 16000:
  10085. tx_fs_rate = 1;
  10086. break;
  10087. case 32000:
  10088. tx_fs_rate = 3;
  10089. break;
  10090. case 48000:
  10091. tx_fs_rate = 4;
  10092. break;
  10093. case 96000:
  10094. tx_fs_rate = 5;
  10095. break;
  10096. case 192000:
  10097. tx_fs_rate = 6;
  10098. break;
  10099. case 384000:
  10100. tx_fs_rate = 7;
  10101. break;
  10102. default:
  10103. dev_err(tasha->dev, "%s: Invalid TX sample rate: %d\n",
  10104. __func__, params_rate(params));
  10105. return -EINVAL;
  10106. };
  10107. if (dai->id != AIF4_VIFEED &&
  10108. dai->id != AIF4_MAD_TX) {
  10109. ret = tasha_set_decimator_rate(dai, tx_fs_rate,
  10110. params_rate(params));
  10111. if (ret < 0) {
  10112. dev_err(tasha->dev, "%s: cannot set TX Decimator rate: %d\n",
  10113. __func__, tx_fs_rate);
  10114. return ret;
  10115. }
  10116. }
  10117. tasha->dai[dai->id].rate = params_rate(params);
  10118. switch (params_width(params)) {
  10119. case 16:
  10120. tasha->dai[dai->id].bit_width = 16;
  10121. i2s_bit_mode = 0x01;
  10122. break;
  10123. case 24:
  10124. tasha->dai[dai->id].bit_width = 24;
  10125. i2s_bit_mode = 0x00;
  10126. break;
  10127. case 32:
  10128. tasha->dai[dai->id].bit_width = 32;
  10129. i2s_bit_mode = 0x00;
  10130. break;
  10131. default:
  10132. dev_err(tasha->dev, "%s: Invalid format 0x%x\n",
  10133. __func__, params_width(params));
  10134. return -EINVAL;
  10135. };
  10136. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10137. snd_soc_update_bits(codec,
  10138. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10139. 0x20, i2s_bit_mode << 5);
  10140. if (tx_fs_rate > 1)
  10141. tx_fs_rate--;
  10142. snd_soc_update_bits(codec,
  10143. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10144. 0x1c, tx_fs_rate << 2);
  10145. snd_soc_update_bits(codec,
  10146. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG,
  10147. 0x05, 0x05);
  10148. snd_soc_update_bits(codec,
  10149. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG,
  10150. 0x05, 0x05);
  10151. snd_soc_update_bits(codec,
  10152. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG,
  10153. 0x05, 0x05);
  10154. snd_soc_update_bits(codec,
  10155. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG,
  10156. 0x05, 0x05);
  10157. }
  10158. break;
  10159. default:
  10160. pr_err("%s: Invalid stream type %d\n", __func__,
  10161. substream->stream);
  10162. return -EINVAL;
  10163. };
  10164. if (dai->id == AIF4_VIFEED)
  10165. tasha->dai[dai->id].bit_width = 32;
  10166. return 0;
  10167. }
  10168. static int tasha_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  10169. {
  10170. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  10171. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  10172. case SND_SOC_DAIFMT_CBS_CFS:
  10173. /* CPU is master */
  10174. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10175. if (dai->id == AIF1_CAP)
  10176. snd_soc_update_bits(dai->codec,
  10177. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10178. 0x2, 0);
  10179. else if (dai->id == AIF1_PB)
  10180. snd_soc_update_bits(dai->codec,
  10181. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10182. 0x2, 0);
  10183. }
  10184. break;
  10185. case SND_SOC_DAIFMT_CBM_CFM:
  10186. /* CPU is slave */
  10187. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10188. if (dai->id == AIF1_CAP)
  10189. snd_soc_update_bits(dai->codec,
  10190. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10191. 0x2, 0x2);
  10192. else if (dai->id == AIF1_PB)
  10193. snd_soc_update_bits(dai->codec,
  10194. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10195. 0x2, 0x2);
  10196. }
  10197. break;
  10198. default:
  10199. return -EINVAL;
  10200. }
  10201. return 0;
  10202. }
  10203. static int tasha_set_dai_sysclk(struct snd_soc_dai *dai,
  10204. int clk_id, unsigned int freq, int dir)
  10205. {
  10206. pr_debug("%s\n", __func__);
  10207. return 0;
  10208. }
  10209. static struct snd_soc_dai_ops tasha_dai_ops = {
  10210. .startup = tasha_startup,
  10211. .shutdown = tasha_shutdown,
  10212. .hw_params = tasha_hw_params,
  10213. .prepare = tasha_prepare,
  10214. .set_sysclk = tasha_set_dai_sysclk,
  10215. .set_fmt = tasha_set_dai_fmt,
  10216. .set_channel_map = tasha_set_channel_map,
  10217. .get_channel_map = tasha_get_channel_map,
  10218. };
  10219. static struct snd_soc_dai_driver tasha_dai[] = {
  10220. {
  10221. .name = "tasha_rx1",
  10222. .id = AIF1_PB,
  10223. .playback = {
  10224. .stream_name = "AIF1 Playback",
  10225. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10226. .formats = TASHA_FORMATS_S16_S24_LE,
  10227. .rate_max = 192000,
  10228. .rate_min = 8000,
  10229. .channels_min = 1,
  10230. .channels_max = 2,
  10231. },
  10232. .ops = &tasha_dai_ops,
  10233. },
  10234. {
  10235. .name = "tasha_tx1",
  10236. .id = AIF1_CAP,
  10237. .capture = {
  10238. .stream_name = "AIF1 Capture",
  10239. .rates = WCD9335_RATES_MASK,
  10240. .formats = TASHA_FORMATS_S16_S24_LE,
  10241. .rate_max = 192000,
  10242. .rate_min = 8000,
  10243. .channels_min = 1,
  10244. .channels_max = 4,
  10245. },
  10246. .ops = &tasha_dai_ops,
  10247. },
  10248. {
  10249. .name = "tasha_rx2",
  10250. .id = AIF2_PB,
  10251. .playback = {
  10252. .stream_name = "AIF2 Playback",
  10253. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10254. .formats = TASHA_FORMATS_S16_S24_LE,
  10255. .rate_min = 8000,
  10256. .rate_max = 192000,
  10257. .channels_min = 1,
  10258. .channels_max = 2,
  10259. },
  10260. .ops = &tasha_dai_ops,
  10261. },
  10262. {
  10263. .name = "tasha_tx2",
  10264. .id = AIF2_CAP,
  10265. .capture = {
  10266. .stream_name = "AIF2 Capture",
  10267. .rates = WCD9335_RATES_MASK,
  10268. .formats = TASHA_FORMATS_S16_S24_LE,
  10269. .rate_max = 192000,
  10270. .rate_min = 8000,
  10271. .channels_min = 1,
  10272. .channels_max = 8,
  10273. },
  10274. .ops = &tasha_dai_ops,
  10275. },
  10276. {
  10277. .name = "tasha_rx3",
  10278. .id = AIF3_PB,
  10279. .playback = {
  10280. .stream_name = "AIF3 Playback",
  10281. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10282. .formats = TASHA_FORMATS_S16_S24_LE,
  10283. .rate_min = 8000,
  10284. .rate_max = 192000,
  10285. .channels_min = 1,
  10286. .channels_max = 2,
  10287. },
  10288. .ops = &tasha_dai_ops,
  10289. },
  10290. {
  10291. .name = "tasha_tx3",
  10292. .id = AIF3_CAP,
  10293. .capture = {
  10294. .stream_name = "AIF3 Capture",
  10295. .rates = WCD9335_RATES_MASK,
  10296. .formats = TASHA_FORMATS_S16_S24_LE,
  10297. .rate_max = 48000,
  10298. .rate_min = 8000,
  10299. .channels_min = 1,
  10300. .channels_max = 2,
  10301. },
  10302. .ops = &tasha_dai_ops,
  10303. },
  10304. {
  10305. .name = "tasha_rx4",
  10306. .id = AIF4_PB,
  10307. .playback = {
  10308. .stream_name = "AIF4 Playback",
  10309. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10310. .formats = TASHA_FORMATS_S16_S24_LE,
  10311. .rate_min = 8000,
  10312. .rate_max = 192000,
  10313. .channels_min = 1,
  10314. .channels_max = 2,
  10315. },
  10316. .ops = &tasha_dai_ops,
  10317. },
  10318. {
  10319. .name = "tasha_mix_rx1",
  10320. .id = AIF_MIX1_PB,
  10321. .playback = {
  10322. .stream_name = "AIF Mix Playback",
  10323. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10324. .formats = TASHA_FORMATS_S16_S24_LE,
  10325. .rate_min = 8000,
  10326. .rate_max = 192000,
  10327. .channels_min = 1,
  10328. .channels_max = 8,
  10329. },
  10330. .ops = &tasha_dai_ops,
  10331. },
  10332. {
  10333. .name = "tasha_mad1",
  10334. .id = AIF4_MAD_TX,
  10335. .capture = {
  10336. .stream_name = "AIF4 MAD TX",
  10337. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10338. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_384000,
  10339. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10340. .rate_min = 16000,
  10341. .rate_max = 384000,
  10342. .channels_min = 1,
  10343. .channels_max = 1,
  10344. },
  10345. .ops = &tasha_dai_ops,
  10346. },
  10347. {
  10348. .name = "tasha_vifeedback",
  10349. .id = AIF4_VIFEED,
  10350. .capture = {
  10351. .stream_name = "VIfeed",
  10352. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
  10353. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10354. .rate_max = 48000,
  10355. .rate_min = 8000,
  10356. .channels_min = 1,
  10357. .channels_max = 4,
  10358. },
  10359. .ops = &tasha_dai_ops,
  10360. },
  10361. {
  10362. .name = "tasha_cpe",
  10363. .id = AIF5_CPE_TX,
  10364. .capture = {
  10365. .stream_name = "AIF5 CPE TX",
  10366. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000,
  10367. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10368. .rate_min = 16000,
  10369. .rate_max = 48000,
  10370. .channels_min = 1,
  10371. .channels_max = 1,
  10372. },
  10373. },
  10374. };
  10375. static struct snd_soc_dai_driver tasha_i2s_dai[] = {
  10376. {
  10377. .name = "tasha_i2s_rx1",
  10378. .id = AIF1_PB,
  10379. .playback = {
  10380. .stream_name = "AIF1 Playback",
  10381. .rates = WCD9335_RATES_MASK,
  10382. .formats = TASHA_FORMATS_S16_S24_LE,
  10383. .rate_max = 192000,
  10384. .rate_min = 8000,
  10385. .channels_min = 1,
  10386. .channels_max = 2,
  10387. },
  10388. .ops = &tasha_dai_ops,
  10389. },
  10390. {
  10391. .name = "tasha_i2s_tx1",
  10392. .id = AIF1_CAP,
  10393. .capture = {
  10394. .stream_name = "AIF1 Capture",
  10395. .rates = WCD9335_RATES_MASK,
  10396. .formats = TASHA_FORMATS_S16_S24_LE,
  10397. .rate_max = 192000,
  10398. .rate_min = 8000,
  10399. .channels_min = 1,
  10400. .channels_max = 4,
  10401. },
  10402. .ops = &tasha_dai_ops,
  10403. },
  10404. {
  10405. .name = "tasha_i2s_rx2",
  10406. .id = AIF2_PB,
  10407. .playback = {
  10408. .stream_name = "AIF2 Playback",
  10409. .rates = WCD9335_RATES_MASK,
  10410. .formats = TASHA_FORMATS_S16_S24_LE,
  10411. .rate_max = 192000,
  10412. .rate_min = 8000,
  10413. .channels_min = 1,
  10414. .channels_max = 2,
  10415. },
  10416. .ops = &tasha_dai_ops,
  10417. },
  10418. {
  10419. .name = "tasha_i2s_tx2",
  10420. .id = AIF2_CAP,
  10421. .capture = {
  10422. .stream_name = "AIF2 Capture",
  10423. .rates = WCD9335_RATES_MASK,
  10424. .formats = TASHA_FORMATS_S16_S24_LE,
  10425. .rate_max = 192000,
  10426. .rate_min = 8000,
  10427. .channels_min = 1,
  10428. .channels_max = 4,
  10429. },
  10430. .ops = &tasha_dai_ops,
  10431. },
  10432. };
  10433. static void tasha_codec_power_gate_digital_core(struct tasha_priv *tasha)
  10434. {
  10435. struct snd_soc_codec *codec = tasha->codec;
  10436. if (!codec)
  10437. return;
  10438. mutex_lock(&tasha->power_lock);
  10439. dev_dbg(codec->dev, "%s: Entering power gating function, %d\n",
  10440. __func__, tasha->power_active_ref);
  10441. if (tasha->power_active_ref > 0)
  10442. goto exit;
  10443. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10444. WCD_REGION_POWER_COLLAPSE_BEGIN,
  10445. WCD9XXX_DIG_CORE_REGION_1);
  10446. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10447. 0x04, 0x04);
  10448. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10449. 0x01, 0x00);
  10450. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10451. 0x02, 0x00);
  10452. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10453. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  10454. wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_DOWN,
  10455. WCD9XXX_DIG_CORE_REGION_1);
  10456. exit:
  10457. dev_dbg(codec->dev, "%s: Exiting power gating function, %d\n",
  10458. __func__, tasha->power_active_ref);
  10459. mutex_unlock(&tasha->power_lock);
  10460. }
  10461. static void tasha_codec_power_gate_work(struct work_struct *work)
  10462. {
  10463. struct tasha_priv *tasha;
  10464. struct delayed_work *dwork;
  10465. struct snd_soc_codec *codec;
  10466. dwork = to_delayed_work(work);
  10467. tasha = container_of(dwork, struct tasha_priv, power_gate_work);
  10468. codec = tasha->codec;
  10469. if (!codec)
  10470. return;
  10471. tasha_codec_power_gate_digital_core(tasha);
  10472. }
  10473. /* called under power_lock acquisition */
  10474. static int tasha_dig_core_remove_power_collapse(struct snd_soc_codec *codec)
  10475. {
  10476. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10477. tasha_codec_vote_max_bw(codec, true);
  10478. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5);
  10479. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7);
  10480. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3);
  10481. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x00);
  10482. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x02);
  10483. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10484. WCD_REGION_POWER_COLLAPSE_REMOVE,
  10485. WCD9XXX_DIG_CORE_REGION_1);
  10486. regcache_mark_dirty(codec->component.regmap);
  10487. regcache_sync_region(codec->component.regmap,
  10488. TASHA_DIG_CORE_REG_MIN, TASHA_DIG_CORE_REG_MAX);
  10489. tasha_codec_vote_max_bw(codec, false);
  10490. return 0;
  10491. }
  10492. static int tasha_dig_core_power_collapse(struct tasha_priv *tasha,
  10493. int req_state)
  10494. {
  10495. struct snd_soc_codec *codec;
  10496. int cur_state;
  10497. /* Exit if feature is disabled */
  10498. if (!dig_core_collapse_enable)
  10499. return 0;
  10500. mutex_lock(&tasha->power_lock);
  10501. if (req_state == POWER_COLLAPSE)
  10502. tasha->power_active_ref--;
  10503. else if (req_state == POWER_RESUME)
  10504. tasha->power_active_ref++;
  10505. else
  10506. goto unlock_mutex;
  10507. if (tasha->power_active_ref < 0) {
  10508. dev_dbg(tasha->dev, "%s: power_active_ref is negative\n",
  10509. __func__);
  10510. goto unlock_mutex;
  10511. }
  10512. codec = tasha->codec;
  10513. if (!codec)
  10514. goto unlock_mutex;
  10515. if (req_state == POWER_COLLAPSE) {
  10516. if (tasha->power_active_ref == 0) {
  10517. schedule_delayed_work(&tasha->power_gate_work,
  10518. msecs_to_jiffies(dig_core_collapse_timer * 1000));
  10519. }
  10520. } else if (req_state == POWER_RESUME) {
  10521. if (tasha->power_active_ref == 1) {
  10522. /*
  10523. * At this point, there can be two cases:
  10524. * 1. Core already in power collapse state
  10525. * 2. Timer kicked in and still did not expire or
  10526. * waiting for the power_lock
  10527. */
  10528. cur_state = wcd9xxx_get_current_power_state(
  10529. tasha->wcd9xxx,
  10530. WCD9XXX_DIG_CORE_REGION_1);
  10531. if (cur_state == WCD_REGION_POWER_DOWN)
  10532. tasha_dig_core_remove_power_collapse(codec);
  10533. else {
  10534. mutex_unlock(&tasha->power_lock);
  10535. cancel_delayed_work_sync(
  10536. &tasha->power_gate_work);
  10537. mutex_lock(&tasha->power_lock);
  10538. }
  10539. }
  10540. }
  10541. unlock_mutex:
  10542. mutex_unlock(&tasha->power_lock);
  10543. return 0;
  10544. }
  10545. static int __tasha_cdc_mclk_enable_locked(struct tasha_priv *tasha,
  10546. bool enable)
  10547. {
  10548. int ret = 0;
  10549. if (!tasha->wcd_ext_clk) {
  10550. dev_err(tasha->dev, "%s: wcd ext clock is NULL\n", __func__);
  10551. return -EINVAL;
  10552. }
  10553. dev_dbg(tasha->dev, "%s: mclk_enable = %u\n", __func__, enable);
  10554. if (enable) {
  10555. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10556. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10557. if (ret)
  10558. goto err;
  10559. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10560. tasha_codec_apply_sido_voltage(tasha,
  10561. SIDO_VOLTAGE_NOMINAL_MV);
  10562. } else {
  10563. if (!dig_core_collapse_enable) {
  10564. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10565. tasha_codec_update_sido_voltage(tasha,
  10566. sido_buck_svs_voltage);
  10567. }
  10568. tasha_cdc_req_mclk_enable(tasha, false);
  10569. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10570. }
  10571. err:
  10572. return ret;
  10573. }
  10574. static int __tasha_cdc_mclk_enable(struct tasha_priv *tasha,
  10575. bool enable)
  10576. {
  10577. int ret;
  10578. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10579. ret = __tasha_cdc_mclk_enable_locked(tasha, enable);
  10580. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10581. return ret;
  10582. }
  10583. int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10584. {
  10585. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10586. return __tasha_cdc_mclk_enable(tasha, enable);
  10587. }
  10588. EXPORT_SYMBOL(tasha_cdc_mclk_enable);
  10589. int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10590. {
  10591. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10592. int ret = 0;
  10593. dev_dbg(tasha->dev, "%s: clk_mode: %d, enable: %d, clk_internal: %d\n",
  10594. __func__, tasha->clk_mode, enable, tasha->clk_internal);
  10595. if (tasha->clk_mode || tasha->clk_internal) {
  10596. if (enable) {
  10597. tasha_cdc_sido_ccl_enable(tasha, true);
  10598. wcd_resmgr_enable_master_bias(tasha->resmgr);
  10599. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10600. snd_soc_update_bits(codec,
  10601. WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
  10602. 0x01, 0x01);
  10603. snd_soc_update_bits(codec,
  10604. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  10605. 0x01, 0x01);
  10606. set_bit(CPE_NOMINAL, &tasha->status_mask);
  10607. tasha_codec_update_sido_voltage(tasha,
  10608. SIDO_VOLTAGE_NOMINAL_MV);
  10609. tasha->clk_internal = true;
  10610. } else {
  10611. tasha->clk_internal = false;
  10612. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  10613. tasha_codec_update_sido_voltage(tasha,
  10614. sido_buck_svs_voltage);
  10615. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10616. wcd_resmgr_disable_master_bias(tasha->resmgr);
  10617. tasha_cdc_sido_ccl_enable(tasha, false);
  10618. }
  10619. } else {
  10620. ret = __tasha_cdc_mclk_enable(tasha, enable);
  10621. }
  10622. return ret;
  10623. }
  10624. EXPORT_SYMBOL(tasha_cdc_mclk_tx_enable);
  10625. static ssize_t tasha_codec_version_read(struct snd_info_entry *entry,
  10626. void *file_private_data, struct file *file,
  10627. char __user *buf, size_t count, loff_t pos)
  10628. {
  10629. struct tasha_priv *tasha;
  10630. struct wcd9xxx *wcd9xxx;
  10631. char buffer[TASHA_VERSION_ENTRY_SIZE];
  10632. int len = 0;
  10633. tasha = (struct tasha_priv *) entry->private_data;
  10634. if (!tasha) {
  10635. pr_err("%s: tasha priv is null\n", __func__);
  10636. return -EINVAL;
  10637. }
  10638. wcd9xxx = tasha->wcd9xxx;
  10639. if (wcd9xxx->codec_type->id_major == TASHA_MAJOR) {
  10640. if (TASHA_IS_1_0(wcd9xxx))
  10641. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_0\n");
  10642. else if (TASHA_IS_1_1(wcd9xxx))
  10643. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_1\n");
  10644. else
  10645. snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10646. } else if (wcd9xxx->codec_type->id_major == TASHA2P0_MAJOR) {
  10647. len = snprintf(buffer, sizeof(buffer), "WCD9335_2_0\n");
  10648. } else
  10649. len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10650. return simple_read_from_buffer(buf, count, &pos, buffer, len);
  10651. }
  10652. static struct snd_info_entry_ops tasha_codec_info_ops = {
  10653. .read = tasha_codec_version_read,
  10654. };
  10655. /*
  10656. * tasha_codec_info_create_codec_entry - creates wcd9335 module
  10657. * @codec_root: The parent directory
  10658. * @codec: Codec instance
  10659. *
  10660. * Creates wcd9335 module and version entry under the given
  10661. * parent directory.
  10662. *
  10663. * Return: 0 on success or negative error code on failure.
  10664. */
  10665. int tasha_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
  10666. struct snd_soc_codec *codec)
  10667. {
  10668. struct snd_info_entry *version_entry;
  10669. struct tasha_priv *tasha;
  10670. struct snd_soc_card *card;
  10671. if (!codec_root || !codec)
  10672. return -EINVAL;
  10673. tasha = snd_soc_codec_get_drvdata(codec);
  10674. card = codec->component.card;
  10675. tasha->entry = snd_info_create_subdir(codec_root->module,
  10676. "tasha", codec_root);
  10677. if (!tasha->entry) {
  10678. dev_dbg(codec->dev, "%s: failed to create wcd9335 entry\n",
  10679. __func__);
  10680. return -ENOMEM;
  10681. }
  10682. version_entry = snd_info_create_card_entry(card->snd_card,
  10683. "version",
  10684. tasha->entry);
  10685. if (!version_entry) {
  10686. dev_dbg(codec->dev, "%s: failed to create wcd9335 version entry\n",
  10687. __func__);
  10688. return -ENOMEM;
  10689. }
  10690. version_entry->private_data = tasha;
  10691. version_entry->size = TASHA_VERSION_ENTRY_SIZE;
  10692. version_entry->content = SNDRV_INFO_CONTENT_DATA;
  10693. version_entry->c.ops = &tasha_codec_info_ops;
  10694. if (snd_info_register(version_entry) < 0) {
  10695. snd_info_free_entry(version_entry);
  10696. return -ENOMEM;
  10697. }
  10698. tasha->version_entry = version_entry;
  10699. return 0;
  10700. }
  10701. EXPORT_SYMBOL(tasha_codec_info_create_codec_entry);
  10702. static int __tasha_codec_internal_rco_ctrl(
  10703. struct snd_soc_codec *codec, bool enable)
  10704. {
  10705. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10706. int ret = 0;
  10707. if (enable) {
  10708. tasha_cdc_sido_ccl_enable(tasha, true);
  10709. if (wcd_resmgr_get_clk_type(tasha->resmgr) ==
  10710. WCD_CLK_RCO) {
  10711. ret = wcd_resmgr_enable_clk_block(tasha->resmgr,
  10712. WCD_CLK_RCO);
  10713. } else {
  10714. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10715. ret |= wcd_resmgr_enable_clk_block(tasha->resmgr,
  10716. WCD_CLK_RCO);
  10717. ret |= tasha_cdc_req_mclk_enable(tasha, false);
  10718. }
  10719. } else {
  10720. ret = wcd_resmgr_disable_clk_block(tasha->resmgr,
  10721. WCD_CLK_RCO);
  10722. tasha_cdc_sido_ccl_enable(tasha, false);
  10723. }
  10724. if (ret) {
  10725. dev_err(codec->dev, "%s: Error in %s RCO\n",
  10726. __func__, (enable ? "enabling" : "disabling"));
  10727. ret = -EINVAL;
  10728. }
  10729. return ret;
  10730. }
  10731. /*
  10732. * tasha_codec_internal_rco_ctrl()
  10733. * Make sure that the caller does not acquire
  10734. * BG_CLK_LOCK.
  10735. */
  10736. static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
  10737. bool enable)
  10738. {
  10739. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10740. int ret = 0;
  10741. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10742. ret = __tasha_codec_internal_rco_ctrl(codec, enable);
  10743. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10744. return ret;
  10745. }
  10746. /*
  10747. * tasha_mbhc_hs_detect: starts mbhc insertion/removal functionality
  10748. * @codec: handle to snd_soc_codec *
  10749. * @mbhc_cfg: handle to mbhc configuration structure
  10750. * return 0 if mbhc_start is success or error code in case of failure
  10751. */
  10752. int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
  10753. struct wcd_mbhc_config *mbhc_cfg)
  10754. {
  10755. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10756. return wcd_mbhc_start(&tasha->mbhc, mbhc_cfg);
  10757. }
  10758. EXPORT_SYMBOL(tasha_mbhc_hs_detect);
  10759. /*
  10760. * tasha_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
  10761. * @codec: handle to snd_soc_codec *
  10762. */
  10763. void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
  10764. {
  10765. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10766. wcd_mbhc_stop(&tasha->mbhc);
  10767. }
  10768. EXPORT_SYMBOL(tasha_mbhc_hs_detect_exit);
  10769. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv)
  10770. {
  10771. /* min micbias voltage is 1V and maximum is 2.85V */
  10772. if (micb_mv < 1000 || micb_mv > 2850) {
  10773. pr_err("%s: unsupported micbias voltage\n", __func__);
  10774. return -EINVAL;
  10775. }
  10776. return (micb_mv - 1000) / 50;
  10777. }
  10778. static const struct tasha_reg_mask_val tasha_reg_update_reset_val_1_1[] = {
  10779. {WCD9335_RCO_CTRL_2, 0xFF, 0x47},
  10780. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10781. };
  10782. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_1[] = {
  10783. {WCD9335_FLYBACK_VNEG_DAC_CTRL_1, 0xFF, 0x65},
  10784. {WCD9335_FLYBACK_VNEG_DAC_CTRL_2, 0xFF, 0x52},
  10785. {WCD9335_FLYBACK_VNEG_DAC_CTRL_3, 0xFF, 0xAF},
  10786. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10787. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0xF4},
  10788. {WCD9335_FLYBACK_VNEG_CTRL_9, 0xFF, 0x40},
  10789. {WCD9335_FLYBACK_VNEG_CTRL_2, 0xFF, 0x4F},
  10790. {WCD9335_FLYBACK_EN, 0xFF, 0x6E},
  10791. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xF8, 0xF8},
  10792. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xF8, 0xF8},
  10793. };
  10794. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_0[] = {
  10795. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0x54},
  10796. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xFC, 0xFC},
  10797. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xFC, 0xFC},
  10798. };
  10799. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_2_0[] = {
  10800. {WCD9335_RCO_CTRL_2, 0x0F, 0x08},
  10801. {WCD9335_RX_BIAS_FLYB_MID_RST, 0xF0, 0x10},
  10802. {WCD9335_FLYBACK_CTRL_1, 0x20, 0x20},
  10803. {WCD9335_HPH_OCP_CTL, 0xFF, 0x7A},
  10804. {WCD9335_HPH_L_TEST, 0x01, 0x01},
  10805. {WCD9335_HPH_R_TEST, 0x01, 0x01},
  10806. {WCD9335_CDC_BOOST0_BOOST_CFG1, 0x3F, 0x12},
  10807. {WCD9335_CDC_BOOST0_BOOST_CFG2, 0x1C, 0x08},
  10808. {WCD9335_CDC_COMPANDER7_CTL7, 0x1E, 0x18},
  10809. {WCD9335_CDC_BOOST1_BOOST_CFG1, 0x3F, 0x12},
  10810. {WCD9335_CDC_BOOST1_BOOST_CFG2, 0x1C, 0x08},
  10811. {WCD9335_CDC_COMPANDER8_CTL7, 0x1E, 0x18},
  10812. {WCD9335_CDC_TX0_TX_PATH_SEC7, 0xFF, 0x45},
  10813. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xFC, 0xF4},
  10814. {WCD9335_HPH_REFBUFF_LP_CTL, 0x08, 0x08},
  10815. {WCD9335_HPH_REFBUFF_LP_CTL, 0x06, 0x02},
  10816. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xA0},
  10817. {WCD9335_SE_LO_COM1, 0xFF, 0xC0},
  10818. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xFC, 0xF4},
  10819. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xFC, 0xF4},
  10820. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xFC, 0xF8},
  10821. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xFC, 0xF8},
  10822. };
  10823. static const struct tasha_reg_mask_val tasha_codec_reg_defaults[] = {
  10824. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x00},
  10825. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x01},
  10826. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x04, 0x04},
  10827. };
  10828. static const struct tasha_reg_mask_val tasha_codec_reg_i2c_defaults[] = {
  10829. {WCD9335_ANA_CLK_TOP, 0x20, 0x20},
  10830. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x01},
  10831. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x00},
  10832. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x05, 0x05},
  10833. {WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG, 0x01, 0x01},
  10834. {WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG, 0x01, 0x01},
  10835. {WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG, 0x01, 0x01},
  10836. {WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG, 0x01, 0x01},
  10837. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG, 0x05, 0x05},
  10838. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG, 0x05, 0x05},
  10839. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG, 0x05, 0x05},
  10840. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG, 0x05, 0x05},
  10841. };
  10842. static const struct tasha_reg_mask_val tasha_codec_reg_init_common_val[] = {
  10843. /* Rbuckfly/R_EAR(32) */
  10844. {WCD9335_CDC_CLSH_K2_MSB, 0x0F, 0x00},
  10845. {WCD9335_CDC_CLSH_K2_LSB, 0xFF, 0x60},
  10846. {WCD9335_CPE_SS_DMIC_CFG, 0x80, 0x00},
  10847. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x58},
  10848. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x58},
  10849. {WCD9335_CDC_RX7_RX_PATH_CFG1, 0x08, 0x08},
  10850. {WCD9335_CDC_RX8_RX_PATH_CFG1, 0x08, 0x08},
  10851. {WCD9335_ANA_LO_1_2, 0x3C, 0X3C},
  10852. {WCD9335_DIFF_LO_COM_SWCAP_REFBUF_FREQ, 0x70, 0x00},
  10853. {WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03, 0x03},
  10854. {WCD9335_CDC_TOP_TOP_CFG1, 0x02, 0x02},
  10855. {WCD9335_CDC_TOP_TOP_CFG1, 0x01, 0x01},
  10856. {WCD9335_EAR_CMBUFF, 0x08, 0x00},
  10857. {WCD9335_CDC_TX9_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10858. {WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10859. {WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10860. {WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10861. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  10862. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  10863. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  10864. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  10865. {WCD9335_CDC_RX0_RX_PATH_CFG0, 0x01, 0x01},
  10866. {WCD9335_CDC_RX1_RX_PATH_CFG0, 0x01, 0x01},
  10867. {WCD9335_CDC_RX2_RX_PATH_CFG0, 0x01, 0x01},
  10868. {WCD9335_CDC_RX3_RX_PATH_CFG0, 0x01, 0x01},
  10869. {WCD9335_CDC_RX4_RX_PATH_CFG0, 0x01, 0x01},
  10870. {WCD9335_CDC_RX5_RX_PATH_CFG0, 0x01, 0x01},
  10871. {WCD9335_CDC_RX6_RX_PATH_CFG0, 0x01, 0x01},
  10872. {WCD9335_CDC_RX7_RX_PATH_CFG0, 0x01, 0x01},
  10873. {WCD9335_CDC_RX8_RX_PATH_CFG0, 0x01, 0x01},
  10874. {WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 0x01, 0x01},
  10875. {WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 0x01, 0x01},
  10876. {WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 0x01, 0x01},
  10877. {WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 0x01, 0x01},
  10878. {WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 0x01, 0x01},
  10879. {WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 0x01, 0x01},
  10880. {WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 0x01, 0x01},
  10881. {WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 0x01, 0x01},
  10882. {WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 0x01, 0x01},
  10883. {WCD9335_VBADC_IBIAS_FE, 0x0C, 0x08},
  10884. };
  10885. static const struct tasha_reg_mask_val tasha_codec_reg_init_1_x_val[] = {
  10886. /* Enable TX HPF Filter & Linear Phase */
  10887. {WCD9335_CDC_TX0_TX_PATH_CFG0, 0x11, 0x11},
  10888. {WCD9335_CDC_TX1_TX_PATH_CFG0, 0x11, 0x11},
  10889. {WCD9335_CDC_TX2_TX_PATH_CFG0, 0x11, 0x11},
  10890. {WCD9335_CDC_TX3_TX_PATH_CFG0, 0x11, 0x11},
  10891. {WCD9335_CDC_TX4_TX_PATH_CFG0, 0x11, 0x11},
  10892. {WCD9335_CDC_TX5_TX_PATH_CFG0, 0x11, 0x11},
  10893. {WCD9335_CDC_TX6_TX_PATH_CFG0, 0x11, 0x11},
  10894. {WCD9335_CDC_TX7_TX_PATH_CFG0, 0x11, 0x11},
  10895. {WCD9335_CDC_TX8_TX_PATH_CFG0, 0x11, 0x11},
  10896. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xF8, 0xF8},
  10897. {WCD9335_CDC_RX0_RX_PATH_SEC1, 0x08, 0x08},
  10898. {WCD9335_CDC_RX1_RX_PATH_SEC1, 0x08, 0x08},
  10899. {WCD9335_CDC_RX2_RX_PATH_SEC1, 0x08, 0x08},
  10900. {WCD9335_CDC_RX3_RX_PATH_SEC1, 0x08, 0x08},
  10901. {WCD9335_CDC_RX4_RX_PATH_SEC1, 0x08, 0x08},
  10902. {WCD9335_CDC_RX5_RX_PATH_SEC1, 0x08, 0x08},
  10903. {WCD9335_CDC_RX6_RX_PATH_SEC1, 0x08, 0x08},
  10904. {WCD9335_CDC_RX7_RX_PATH_SEC1, 0x08, 0x08},
  10905. {WCD9335_CDC_RX8_RX_PATH_SEC1, 0x08, 0x08},
  10906. {WCD9335_CDC_RX0_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10907. {WCD9335_CDC_RX1_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10908. {WCD9335_CDC_RX2_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10909. {WCD9335_CDC_RX3_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10910. {WCD9335_CDC_RX4_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10911. {WCD9335_CDC_RX5_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10912. {WCD9335_CDC_RX6_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10913. {WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10914. {WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10915. {WCD9335_CDC_TX0_TX_PATH_SEC2, 0x01, 0x01},
  10916. {WCD9335_CDC_TX1_TX_PATH_SEC2, 0x01, 0x01},
  10917. {WCD9335_CDC_TX2_TX_PATH_SEC2, 0x01, 0x01},
  10918. {WCD9335_CDC_TX3_TX_PATH_SEC2, 0x01, 0x01},
  10919. {WCD9335_CDC_TX4_TX_PATH_SEC2, 0x01, 0x01},
  10920. {WCD9335_CDC_TX5_TX_PATH_SEC2, 0x01, 0x01},
  10921. {WCD9335_CDC_TX6_TX_PATH_SEC2, 0x01, 0x01},
  10922. {WCD9335_CDC_TX7_TX_PATH_SEC2, 0x01, 0x01},
  10923. {WCD9335_CDC_TX8_TX_PATH_SEC2, 0x01, 0x01},
  10924. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xF8, 0xF0},
  10925. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xF8, 0xF0},
  10926. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xF8, 0xF8},
  10927. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xF8, 0xF8},
  10928. {WCD9335_RX_OCP_COUNT, 0xFF, 0xFF},
  10929. {WCD9335_HPH_OCP_CTL, 0xF0, 0x70},
  10930. {WCD9335_CPE_SS_CPAR_CFG, 0xFF, 0x00},
  10931. {WCD9335_FLYBACK_VNEG_CTRL_1, 0xFF, 0x63},
  10932. {WCD9335_FLYBACK_VNEG_CTRL_4, 0xFF, 0x7F},
  10933. {WCD9335_CLASSH_CTRL_VCL_1, 0xFF, 0x60},
  10934. {WCD9335_CLASSH_CTRL_CCL_5, 0xFF, 0x40},
  10935. {WCD9335_RX_TIMER_DIV, 0xFF, 0x32},
  10936. {WCD9335_SE_LO_COM2, 0xFF, 0x01},
  10937. {WCD9335_MBHC_ZDET_ANA_CTL, 0x0F, 0x07},
  10938. {WCD9335_RX_BIAS_HPH_PA, 0xF0, 0x60},
  10939. {WCD9335_HPH_RDAC_LDO_CTL, 0x88, 0x88},
  10940. {WCD9335_HPH_L_EN, 0x20, 0x20},
  10941. {WCD9335_HPH_R_EN, 0x20, 0x20},
  10942. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xD8},
  10943. {WCD9335_CDC_RX5_RX_PATH_SEC3, 0xBD, 0xBD},
  10944. {WCD9335_CDC_RX6_RX_PATH_SEC3, 0xBD, 0xBD},
  10945. {WCD9335_DIFF_LO_COM_PA_FREQ, 0x70, 0x40},
  10946. };
  10947. static void tasha_update_reg_reset_values(struct snd_soc_codec *codec)
  10948. {
  10949. u32 i;
  10950. struct wcd9xxx *tasha_core = dev_get_drvdata(codec->dev->parent);
  10951. if (TASHA_IS_1_1(tasha_core)) {
  10952. for (i = 0; i < ARRAY_SIZE(tasha_reg_update_reset_val_1_1);
  10953. i++)
  10954. snd_soc_write(codec,
  10955. tasha_reg_update_reset_val_1_1[i].reg,
  10956. tasha_reg_update_reset_val_1_1[i].val);
  10957. }
  10958. }
  10959. static void tasha_codec_init_reg(struct snd_soc_codec *codec)
  10960. {
  10961. u32 i;
  10962. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  10963. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_common_val); i++)
  10964. snd_soc_update_bits(codec,
  10965. tasha_codec_reg_init_common_val[i].reg,
  10966. tasha_codec_reg_init_common_val[i].mask,
  10967. tasha_codec_reg_init_common_val[i].val);
  10968. if (TASHA_IS_1_1(wcd9xxx) ||
  10969. TASHA_IS_1_0(wcd9xxx))
  10970. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_1_x_val); i++)
  10971. snd_soc_update_bits(codec,
  10972. tasha_codec_reg_init_1_x_val[i].reg,
  10973. tasha_codec_reg_init_1_x_val[i].mask,
  10974. tasha_codec_reg_init_1_x_val[i].val);
  10975. if (TASHA_IS_1_1(wcd9xxx)) {
  10976. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_1); i++)
  10977. snd_soc_update_bits(codec,
  10978. tasha_codec_reg_init_val_1_1[i].reg,
  10979. tasha_codec_reg_init_val_1_1[i].mask,
  10980. tasha_codec_reg_init_val_1_1[i].val);
  10981. } else if (TASHA_IS_1_0(wcd9xxx)) {
  10982. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_0); i++)
  10983. snd_soc_update_bits(codec,
  10984. tasha_codec_reg_init_val_1_0[i].reg,
  10985. tasha_codec_reg_init_val_1_0[i].mask,
  10986. tasha_codec_reg_init_val_1_0[i].val);
  10987. } else if (TASHA_IS_2_0(wcd9xxx)) {
  10988. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_2_0); i++)
  10989. snd_soc_update_bits(codec,
  10990. tasha_codec_reg_init_val_2_0[i].reg,
  10991. tasha_codec_reg_init_val_2_0[i].mask,
  10992. tasha_codec_reg_init_val_2_0[i].val);
  10993. }
  10994. }
  10995. static void tasha_update_reg_defaults(struct tasha_priv *tasha)
  10996. {
  10997. u32 i;
  10998. struct wcd9xxx *wcd9xxx;
  10999. wcd9xxx = tasha->wcd9xxx;
  11000. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_defaults); i++)
  11001. regmap_update_bits(wcd9xxx->regmap,
  11002. tasha_codec_reg_defaults[i].reg,
  11003. tasha_codec_reg_defaults[i].mask,
  11004. tasha_codec_reg_defaults[i].val);
  11005. tasha->intf_type = wcd9xxx_get_intf_type();
  11006. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  11007. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_i2c_defaults); i++)
  11008. regmap_update_bits(wcd9xxx->regmap,
  11009. tasha_codec_reg_i2c_defaults[i].reg,
  11010. tasha_codec_reg_i2c_defaults[i].mask,
  11011. tasha_codec_reg_i2c_defaults[i].val);
  11012. }
  11013. static void tasha_slim_interface_init_reg(struct snd_soc_codec *codec)
  11014. {
  11015. int i;
  11016. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11017. for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++)
  11018. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11019. TASHA_SLIM_PGD_PORT_INT_EN0 + i,
  11020. 0xFF);
  11021. }
  11022. static irqreturn_t tasha_slimbus_irq(int irq, void *data)
  11023. {
  11024. struct tasha_priv *priv = data;
  11025. unsigned long status = 0;
  11026. int i, j, port_id, k;
  11027. u32 bit;
  11028. u8 val, int_val = 0;
  11029. bool tx, cleared;
  11030. unsigned short reg = 0;
  11031. for (i = TASHA_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
  11032. i <= TASHA_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
  11033. val = wcd9xxx_interface_reg_read(priv->wcd9xxx, i);
  11034. status |= ((u32)val << (8 * j));
  11035. }
  11036. for_each_set_bit(j, &status, 32) {
  11037. tx = (j >= 16 ? true : false);
  11038. port_id = (tx ? j - 16 : j);
  11039. val = wcd9xxx_interface_reg_read(priv->wcd9xxx,
  11040. TASHA_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
  11041. if (val) {
  11042. if (!tx)
  11043. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  11044. (port_id / 8);
  11045. else
  11046. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  11047. (port_id / 8);
  11048. int_val = wcd9xxx_interface_reg_read(
  11049. priv->wcd9xxx, reg);
  11050. /*
  11051. * Ignore interrupts for ports for which the
  11052. * interrupts are not specifically enabled.
  11053. */
  11054. if (!(int_val & (1 << (port_id % 8))))
  11055. continue;
  11056. }
  11057. if (val & TASHA_SLIM_IRQ_OVERFLOW)
  11058. pr_err_ratelimited(
  11059. "%s: overflow error on %s port %d, value %x\n",
  11060. __func__, (tx ? "TX" : "RX"), port_id, val);
  11061. if (val & TASHA_SLIM_IRQ_UNDERFLOW)
  11062. pr_err_ratelimited(
  11063. "%s: underflow error on %s port %d, value %x\n",
  11064. __func__, (tx ? "TX" : "RX"), port_id, val);
  11065. if ((val & TASHA_SLIM_IRQ_OVERFLOW) ||
  11066. (val & TASHA_SLIM_IRQ_UNDERFLOW)) {
  11067. if (!tx)
  11068. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  11069. (port_id / 8);
  11070. else
  11071. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  11072. (port_id / 8);
  11073. int_val = wcd9xxx_interface_reg_read(
  11074. priv->wcd9xxx, reg);
  11075. if (int_val & (1 << (port_id % 8))) {
  11076. int_val = int_val ^ (1 << (port_id % 8));
  11077. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11078. reg, int_val);
  11079. }
  11080. }
  11081. if (val & TASHA_SLIM_IRQ_PORT_CLOSED) {
  11082. /*
  11083. * INT SOURCE register starts from RX to TX
  11084. * but port number in the ch_mask is in opposite way
  11085. */
  11086. bit = (tx ? j - 16 : j + 16);
  11087. pr_debug("%s: %s port %d closed value %x, bit %u\n",
  11088. __func__, (tx ? "TX" : "RX"), port_id, val,
  11089. bit);
  11090. for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) {
  11091. pr_debug("%s: priv->dai[%d].ch_mask = 0x%lx\n",
  11092. __func__, k, priv->dai[k].ch_mask);
  11093. if (test_and_clear_bit(bit,
  11094. &priv->dai[k].ch_mask)) {
  11095. cleared = true;
  11096. if (!priv->dai[k].ch_mask)
  11097. wake_up(&priv->dai[k].dai_wait);
  11098. /*
  11099. * There are cases when multiple DAIs
  11100. * might be using the same slimbus
  11101. * channel. Hence don't break here.
  11102. */
  11103. }
  11104. }
  11105. WARN(!cleared,
  11106. "Couldn't find slimbus %s port %d for closing\n",
  11107. (tx ? "TX" : "RX"), port_id);
  11108. }
  11109. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11110. TASHA_SLIM_PGD_PORT_INT_CLR_RX_0 +
  11111. (j / 8),
  11112. 1 << (j % 8));
  11113. }
  11114. return IRQ_HANDLED;
  11115. }
  11116. static int tasha_setup_irqs(struct tasha_priv *tasha)
  11117. {
  11118. int ret = 0;
  11119. struct snd_soc_codec *codec = tasha->codec;
  11120. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11121. struct wcd9xxx_core_resource *core_res =
  11122. &wcd9xxx->core_res;
  11123. ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS,
  11124. tasha_slimbus_irq, "SLIMBUS Slave", tasha);
  11125. if (ret)
  11126. pr_err("%s: Failed to request irq %d\n", __func__,
  11127. WCD9XXX_IRQ_SLIMBUS);
  11128. else
  11129. tasha_slim_interface_init_reg(codec);
  11130. return ret;
  11131. }
  11132. static void tasha_init_slim_slave_cfg(struct snd_soc_codec *codec)
  11133. {
  11134. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11135. struct afe_param_cdc_slimbus_slave_cfg *cfg;
  11136. struct wcd9xxx *wcd9xxx = priv->wcd9xxx;
  11137. uint64_t eaddr = 0;
  11138. cfg = &priv->slimbus_slave_cfg;
  11139. cfg->minor_version = 1;
  11140. cfg->tx_slave_port_offset = 0;
  11141. cfg->rx_slave_port_offset = 16;
  11142. memcpy(&eaddr, &wcd9xxx->slim->e_addr, sizeof(wcd9xxx->slim->e_addr));
  11143. WARN_ON(sizeof(wcd9xxx->slim->e_addr) != 6);
  11144. cfg->device_enum_addr_lsw = eaddr & 0xFFFFFFFF;
  11145. cfg->device_enum_addr_msw = eaddr >> 32;
  11146. dev_dbg(codec->dev, "%s: slimbus logical address 0x%llx\n",
  11147. __func__, eaddr);
  11148. }
  11149. static void tasha_cleanup_irqs(struct tasha_priv *tasha)
  11150. {
  11151. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11152. struct wcd9xxx_core_resource *core_res =
  11153. &wcd9xxx->core_res;
  11154. wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tasha);
  11155. }
  11156. static int tasha_handle_pdata(struct tasha_priv *tasha,
  11157. struct wcd9xxx_pdata *pdata)
  11158. {
  11159. struct snd_soc_codec *codec = tasha->codec;
  11160. u8 dmic_ctl_val, mad_dmic_ctl_val;
  11161. u8 anc_ctl_value;
  11162. u32 def_dmic_rate, dmic_clk_drv;
  11163. int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4;
  11164. int rc = 0;
  11165. if (!pdata) {
  11166. dev_err(codec->dev, "%s: NULL pdata\n", __func__);
  11167. return -ENODEV;
  11168. }
  11169. /* set micbias voltage */
  11170. vout_ctl_1 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb1_mv);
  11171. vout_ctl_2 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb2_mv);
  11172. vout_ctl_3 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb3_mv);
  11173. vout_ctl_4 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb4_mv);
  11174. if (vout_ctl_1 < 0 || vout_ctl_2 < 0 ||
  11175. vout_ctl_3 < 0 || vout_ctl_4 < 0) {
  11176. rc = -EINVAL;
  11177. goto done;
  11178. }
  11179. snd_soc_update_bits(codec, WCD9335_ANA_MICB1, 0x3F, vout_ctl_1);
  11180. snd_soc_update_bits(codec, WCD9335_ANA_MICB2, 0x3F, vout_ctl_2);
  11181. snd_soc_update_bits(codec, WCD9335_ANA_MICB3, 0x3F, vout_ctl_3);
  11182. snd_soc_update_bits(codec, WCD9335_ANA_MICB4, 0x3F, vout_ctl_4);
  11183. /* Set the DMIC sample rate */
  11184. switch (pdata->mclk_rate) {
  11185. case TASHA_MCLK_CLK_9P6MHZ:
  11186. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  11187. break;
  11188. case TASHA_MCLK_CLK_12P288MHZ:
  11189. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ;
  11190. break;
  11191. default:
  11192. /* should never happen */
  11193. dev_err(codec->dev, "%s: Invalid mclk_rate %d\n",
  11194. __func__, pdata->mclk_rate);
  11195. rc = -EINVAL;
  11196. goto done;
  11197. };
  11198. if (pdata->dmic_sample_rate ==
  11199. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11200. dev_info(codec->dev, "%s: dmic_rate invalid default = %d\n",
  11201. __func__, def_dmic_rate);
  11202. pdata->dmic_sample_rate = def_dmic_rate;
  11203. }
  11204. if (pdata->mad_dmic_sample_rate ==
  11205. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11206. dev_info(codec->dev, "%s: mad_dmic_rate invalid default = %d\n",
  11207. __func__, def_dmic_rate);
  11208. /*
  11209. * use dmic_sample_rate as the default for MAD
  11210. * if mad dmic sample rate is undefined
  11211. */
  11212. pdata->mad_dmic_sample_rate = pdata->dmic_sample_rate;
  11213. }
  11214. if (pdata->ecpp_dmic_sample_rate ==
  11215. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11216. dev_info(codec->dev,
  11217. "%s: ecpp_dmic_rate invalid default = %d\n",
  11218. __func__, def_dmic_rate);
  11219. /*
  11220. * use dmic_sample_rate as the default for ECPP DMIC
  11221. * if ecpp dmic sample rate is undefined
  11222. */
  11223. pdata->ecpp_dmic_sample_rate = pdata->dmic_sample_rate;
  11224. }
  11225. if (pdata->dmic_clk_drv ==
  11226. WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED) {
  11227. pdata->dmic_clk_drv = WCD9335_DMIC_CLK_DRIVE_DEFAULT;
  11228. dev_info(codec->dev,
  11229. "%s: dmic_clk_strength invalid, default = %d\n",
  11230. __func__, pdata->dmic_clk_drv);
  11231. }
  11232. switch (pdata->dmic_clk_drv) {
  11233. case 2:
  11234. dmic_clk_drv = 0;
  11235. break;
  11236. case 4:
  11237. dmic_clk_drv = 1;
  11238. break;
  11239. case 8:
  11240. dmic_clk_drv = 2;
  11241. break;
  11242. case 16:
  11243. dmic_clk_drv = 3;
  11244. break;
  11245. default:
  11246. dev_err(codec->dev,
  11247. "%s: invalid dmic_clk_drv %d, using default\n",
  11248. __func__, pdata->dmic_clk_drv);
  11249. dmic_clk_drv = 0;
  11250. break;
  11251. }
  11252. snd_soc_update_bits(codec, WCD9335_TEST_DEBUG_PAD_DRVCTL,
  11253. 0x0C, dmic_clk_drv << 2);
  11254. /*
  11255. * Default the DMIC clk rates to mad_dmic_sample_rate,
  11256. * whereas, the anc/txfe dmic rates to dmic_sample_rate
  11257. * since the anc/txfe are independent of mad block.
  11258. */
  11259. mad_dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11260. pdata->mclk_rate,
  11261. pdata->mad_dmic_sample_rate);
  11262. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC0_CTL,
  11263. 0x0E, mad_dmic_ctl_val << 1);
  11264. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC1_CTL,
  11265. 0x0E, mad_dmic_ctl_val << 1);
  11266. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC2_CTL,
  11267. 0x0E, mad_dmic_ctl_val << 1);
  11268. dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11269. pdata->mclk_rate,
  11270. pdata->dmic_sample_rate);
  11271. if (dmic_ctl_val == WCD9335_DMIC_CLK_DIV_2)
  11272. anc_ctl_value = WCD9335_ANC_DMIC_X2_FULL_RATE;
  11273. else
  11274. anc_ctl_value = WCD9335_ANC_DMIC_X2_HALF_RATE;
  11275. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11276. 0x40, anc_ctl_value << 6);
  11277. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11278. 0x20, anc_ctl_value << 5);
  11279. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11280. 0x40, anc_ctl_value << 6);
  11281. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11282. 0x20, anc_ctl_value << 5);
  11283. done:
  11284. return rc;
  11285. }
  11286. static struct wcd_cpe_core *tasha_codec_get_cpe_core(
  11287. struct snd_soc_codec *codec)
  11288. {
  11289. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11290. return priv->cpe_core;
  11291. }
  11292. static int tasha_codec_cpe_fll_update_divider(
  11293. struct snd_soc_codec *codec, u32 cpe_fll_rate)
  11294. {
  11295. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11296. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11297. u32 div_val = 0, l_val = 0;
  11298. u32 computed_cpe_fll;
  11299. if (cpe_fll_rate != CPE_FLL_CLK_75MHZ &&
  11300. cpe_fll_rate != CPE_FLL_CLK_150MHZ) {
  11301. dev_err(codec->dev,
  11302. "%s: Invalid CPE fll rate request %u\n",
  11303. __func__, cpe_fll_rate);
  11304. return -EINVAL;
  11305. }
  11306. if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_12P288MHZ) {
  11307. /* update divider to 10 and enable 5x divider */
  11308. snd_soc_write(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11309. 0x55);
  11310. div_val = 10;
  11311. } else if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_9P6MHZ) {
  11312. /* update divider to 8 and enable 2x divider */
  11313. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11314. 0x7C, 0x70);
  11315. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11316. 0xE0, 0x20);
  11317. div_val = 8;
  11318. } else {
  11319. dev_err(codec->dev,
  11320. "%s: Invalid MCLK rate %u\n",
  11321. __func__, wcd9xxx->mclk_rate);
  11322. return -EINVAL;
  11323. }
  11324. l_val = ((cpe_fll_rate / 1000) * div_val) /
  11325. (wcd9xxx->mclk_rate / 1000);
  11326. /* If l_val was integer truncated, increment l_val once */
  11327. computed_cpe_fll = (wcd9xxx->mclk_rate / div_val) * l_val;
  11328. if (computed_cpe_fll < cpe_fll_rate)
  11329. l_val++;
  11330. /* update L value LSB and MSB */
  11331. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_0,
  11332. (l_val & 0xFF));
  11333. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_1,
  11334. ((l_val >> 8) & 0xFF));
  11335. tasha->current_cpe_clk_freq = cpe_fll_rate;
  11336. dev_dbg(codec->dev,
  11337. "%s: updated l_val to %u for cpe_clk %u and mclk %u\n",
  11338. __func__, l_val, cpe_fll_rate, wcd9xxx->mclk_rate);
  11339. return 0;
  11340. }
  11341. static int __tasha_cdc_change_cpe_clk(struct snd_soc_codec *codec,
  11342. u32 clk_freq)
  11343. {
  11344. int ret = 0;
  11345. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11346. if (!tasha_cdc_is_svs_enabled(tasha)) {
  11347. dev_dbg(codec->dev,
  11348. "%s: SVS not enabled or tasha is not 2p0, return\n",
  11349. __func__);
  11350. return 0;
  11351. }
  11352. dev_dbg(codec->dev, "%s: clk_freq = %u\n", __func__, clk_freq);
  11353. if (clk_freq == CPE_FLL_CLK_75MHZ) {
  11354. /* Change to SVS */
  11355. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11356. 0x08, 0x08);
  11357. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11358. ret = -EINVAL;
  11359. goto done;
  11360. }
  11361. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11362. 0x10, 0x10);
  11363. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  11364. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  11365. } else if (clk_freq == CPE_FLL_CLK_150MHZ) {
  11366. /* change to nominal */
  11367. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11368. 0x08, 0x08);
  11369. set_bit(CPE_NOMINAL, &tasha->status_mask);
  11370. tasha_codec_update_sido_voltage(tasha, SIDO_VOLTAGE_NOMINAL_MV);
  11371. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11372. ret = -EINVAL;
  11373. goto done;
  11374. }
  11375. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11376. 0x10, 0x10);
  11377. } else {
  11378. dev_err(codec->dev,
  11379. "%s: Invalid clk_freq request %d for CPE FLL\n",
  11380. __func__, clk_freq);
  11381. ret = -EINVAL;
  11382. }
  11383. done:
  11384. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11385. 0x10, 0x00);
  11386. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11387. 0x08, 0x00);
  11388. return ret;
  11389. }
  11390. static int tasha_codec_cpe_fll_enable(struct snd_soc_codec *codec,
  11391. bool enable)
  11392. {
  11393. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11394. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11395. u8 clk_sel_reg_val = 0x00;
  11396. dev_dbg(codec->dev, "%s: enable = %s\n",
  11397. __func__, enable ? "true" : "false");
  11398. if (enable) {
  11399. if (tasha_cdc_is_svs_enabled(tasha)) {
  11400. /* FLL enable is always at SVS */
  11401. if (__tasha_cdc_change_cpe_clk(codec,
  11402. CPE_FLL_CLK_75MHZ)) {
  11403. dev_err(codec->dev,
  11404. "%s: clk change to %d failed\n",
  11405. __func__, CPE_FLL_CLK_75MHZ);
  11406. return -EINVAL;
  11407. }
  11408. } else {
  11409. if (tasha_codec_cpe_fll_update_divider(codec,
  11410. CPE_FLL_CLK_75MHZ)) {
  11411. dev_err(codec->dev,
  11412. "%s: clk change to %d failed\n",
  11413. __func__, CPE_FLL_CLK_75MHZ);
  11414. return -EINVAL;
  11415. }
  11416. }
  11417. if (TASHA_IS_1_0(wcd9xxx)) {
  11418. tasha_cdc_mclk_enable(codec, true, false);
  11419. clk_sel_reg_val = 0x02;
  11420. }
  11421. /* Setup CPE reference clk */
  11422. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11423. 0x02, clk_sel_reg_val);
  11424. /* enable CPE FLL reference clk */
  11425. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11426. 0x01, 0x01);
  11427. /* program the PLL */
  11428. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11429. 0x01, 0x01);
  11430. /* TEST clk setting */
  11431. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11432. 0x80, 0x80);
  11433. /* set FLL mode to HW controlled */
  11434. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11435. 0x60, 0x00);
  11436. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x80);
  11437. } else {
  11438. /* disable CPE FLL reference clk */
  11439. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11440. 0x01, 0x00);
  11441. /* undo TEST clk setting */
  11442. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11443. 0x80, 0x00);
  11444. /* undo FLL mode to HW control */
  11445. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x00);
  11446. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11447. 0x60, 0x20);
  11448. /* undo the PLL */
  11449. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11450. 0x01, 0x00);
  11451. if (TASHA_IS_1_0(wcd9xxx))
  11452. tasha_cdc_mclk_enable(codec, false, false);
  11453. /*
  11454. * FLL could get disabled while at nominal,
  11455. * scale it back to SVS
  11456. */
  11457. if (tasha_cdc_is_svs_enabled(tasha))
  11458. __tasha_cdc_change_cpe_clk(codec,
  11459. CPE_FLL_CLK_75MHZ);
  11460. }
  11461. return 0;
  11462. }
  11463. static void tasha_cdc_query_cpe_clk_plan(void *data,
  11464. struct cpe_svc_cfg_clk_plan *clk_freq)
  11465. {
  11466. struct snd_soc_codec *codec = data;
  11467. struct tasha_priv *tasha;
  11468. u32 cpe_clk_khz;
  11469. if (!codec) {
  11470. pr_err("%s: Invalid codec handle\n",
  11471. __func__);
  11472. return;
  11473. }
  11474. tasha = snd_soc_codec_get_drvdata(codec);
  11475. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11476. dev_dbg(codec->dev,
  11477. "%s: current_clk_freq = %u\n",
  11478. __func__, tasha->current_cpe_clk_freq);
  11479. clk_freq->current_clk_feq = cpe_clk_khz;
  11480. clk_freq->num_clk_freqs = 2;
  11481. if (tasha_cdc_is_svs_enabled(tasha)) {
  11482. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ / 1000;
  11483. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ / 1000;
  11484. } else {
  11485. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ;
  11486. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ;
  11487. }
  11488. }
  11489. static void tasha_cdc_change_cpe_clk(void *data,
  11490. u32 clk_freq)
  11491. {
  11492. struct snd_soc_codec *codec = data;
  11493. struct tasha_priv *tasha;
  11494. u32 cpe_clk_khz, req_freq = 0;
  11495. if (!codec) {
  11496. pr_err("%s: Invalid codec handle\n",
  11497. __func__);
  11498. return;
  11499. }
  11500. tasha = snd_soc_codec_get_drvdata(codec);
  11501. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11502. if (tasha_cdc_is_svs_enabled(tasha)) {
  11503. if ((clk_freq * 1000) <= CPE_FLL_CLK_75MHZ)
  11504. req_freq = CPE_FLL_CLK_75MHZ;
  11505. else
  11506. req_freq = CPE_FLL_CLK_150MHZ;
  11507. }
  11508. dev_dbg(codec->dev,
  11509. "%s: requested clk_freq = %u, current clk_freq = %u\n",
  11510. __func__, clk_freq * 1000,
  11511. tasha->current_cpe_clk_freq);
  11512. if (tasha_cdc_is_svs_enabled(tasha)) {
  11513. if (__tasha_cdc_change_cpe_clk(codec, req_freq))
  11514. dev_err(codec->dev,
  11515. "%s: clock/voltage scaling failed\n",
  11516. __func__);
  11517. }
  11518. }
  11519. static int tasha_codec_slim_reserve_bw(struct snd_soc_codec *codec,
  11520. u32 bw_ops, bool commit)
  11521. {
  11522. struct wcd9xxx *wcd9xxx;
  11523. if (!codec) {
  11524. pr_err("%s: Invalid handle to codec\n",
  11525. __func__);
  11526. return -EINVAL;
  11527. }
  11528. wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11529. if (!wcd9xxx) {
  11530. dev_err(codec->dev, "%s: Invalid parent drv_data\n",
  11531. __func__);
  11532. return -EINVAL;
  11533. }
  11534. return wcd9xxx_slim_reserve_bw(wcd9xxx, bw_ops, commit);
  11535. }
  11536. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  11537. bool vote)
  11538. {
  11539. u32 bw_ops;
  11540. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11541. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  11542. return 0;
  11543. mutex_lock(&tasha->sb_clk_gear_lock);
  11544. if (vote) {
  11545. tasha->ref_count++;
  11546. if (tasha->ref_count == 1) {
  11547. bw_ops = SLIM_BW_CLK_GEAR_9;
  11548. tasha_codec_slim_reserve_bw(codec,
  11549. bw_ops, true);
  11550. }
  11551. } else if (!vote && tasha->ref_count > 0) {
  11552. tasha->ref_count--;
  11553. if (tasha->ref_count == 0) {
  11554. bw_ops = SLIM_BW_UNVOTE;
  11555. tasha_codec_slim_reserve_bw(codec,
  11556. bw_ops, true);
  11557. }
  11558. };
  11559. dev_dbg(codec->dev, "%s Value of counter after vote or un-vote is %d\n",
  11560. __func__, tasha->ref_count);
  11561. mutex_unlock(&tasha->sb_clk_gear_lock);
  11562. return 0;
  11563. }
  11564. static int tasha_cpe_err_irq_control(struct snd_soc_codec *codec,
  11565. enum cpe_err_irq_cntl_type cntl_type, u8 *status)
  11566. {
  11567. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11568. u8 irq_bits;
  11569. if (TASHA_IS_2_0(tasha->wcd9xxx))
  11570. irq_bits = 0xFF;
  11571. else
  11572. irq_bits = 0x3F;
  11573. if (status)
  11574. irq_bits = (*status) & irq_bits;
  11575. switch (cntl_type) {
  11576. case CPE_ERR_IRQ_MASK:
  11577. snd_soc_update_bits(codec,
  11578. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11579. irq_bits, irq_bits);
  11580. break;
  11581. case CPE_ERR_IRQ_UNMASK:
  11582. snd_soc_update_bits(codec,
  11583. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11584. irq_bits, 0x00);
  11585. break;
  11586. case CPE_ERR_IRQ_CLEAR:
  11587. snd_soc_write(codec, WCD9335_CPE_SS_SS_ERROR_INT_CLEAR,
  11588. irq_bits);
  11589. break;
  11590. case CPE_ERR_IRQ_STATUS:
  11591. if (!status)
  11592. return -EINVAL;
  11593. *status = snd_soc_read(codec,
  11594. WCD9335_CPE_SS_SS_ERROR_INT_STATUS);
  11595. break;
  11596. }
  11597. return 0;
  11598. }
  11599. static const struct wcd_cpe_cdc_cb cpe_cb = {
  11600. .cdc_clk_en = tasha_codec_internal_rco_ctrl,
  11601. .cpe_clk_en = tasha_codec_cpe_fll_enable,
  11602. .get_afe_out_port_id = tasha_codec_get_mad_port_id,
  11603. .lab_cdc_ch_ctl = tasha_codec_enable_slimtx_mad,
  11604. .cdc_ext_clk = tasha_cdc_mclk_enable,
  11605. .bus_vote_bw = tasha_codec_vote_max_bw,
  11606. .cpe_err_irq_control = tasha_cpe_err_irq_control,
  11607. };
  11608. static struct cpe_svc_init_param cpe_svc_params = {
  11609. .version = CPE_SVC_INIT_PARAM_V1,
  11610. .query_freq_plans_cb = tasha_cdc_query_cpe_clk_plan,
  11611. .change_freq_plan_cb = tasha_cdc_change_cpe_clk,
  11612. };
  11613. static int tasha_cpe_initialize(struct snd_soc_codec *codec)
  11614. {
  11615. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11616. struct wcd_cpe_params cpe_params;
  11617. memset(&cpe_params, 0,
  11618. sizeof(struct wcd_cpe_params));
  11619. cpe_params.codec = codec;
  11620. cpe_params.get_cpe_core = tasha_codec_get_cpe_core;
  11621. cpe_params.cdc_cb = &cpe_cb;
  11622. cpe_params.dbg_mode = cpe_debug_mode;
  11623. cpe_params.cdc_major_ver = CPE_SVC_CODEC_WCD9335;
  11624. cpe_params.cdc_minor_ver = CPE_SVC_CODEC_V1P0;
  11625. cpe_params.cdc_id = CPE_SVC_CODEC_WCD9335;
  11626. cpe_params.cdc_irq_info.cpe_engine_irq =
  11627. WCD9335_IRQ_SVA_OUTBOX1;
  11628. cpe_params.cdc_irq_info.cpe_err_irq =
  11629. WCD9335_IRQ_SVA_ERROR;
  11630. cpe_params.cdc_irq_info.cpe_fatal_irqs =
  11631. TASHA_CPE_FATAL_IRQS;
  11632. cpe_svc_params.context = codec;
  11633. cpe_params.cpe_svc_params = &cpe_svc_params;
  11634. tasha->cpe_core = wcd_cpe_init("cpe_9335", codec,
  11635. &cpe_params);
  11636. if (IS_ERR_OR_NULL(tasha->cpe_core)) {
  11637. dev_err(codec->dev,
  11638. "%s: Failed to enable CPE\n",
  11639. __func__);
  11640. return -EINVAL;
  11641. }
  11642. return 0;
  11643. }
  11644. static const struct wcd_resmgr_cb tasha_resmgr_cb = {
  11645. .cdc_rco_ctrl = __tasha_codec_internal_rco_ctrl,
  11646. };
  11647. static int tasha_device_down(struct wcd9xxx *wcd9xxx)
  11648. {
  11649. struct snd_soc_codec *codec;
  11650. struct tasha_priv *priv;
  11651. int count;
  11652. int i = 0;
  11653. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11654. priv = snd_soc_codec_get_drvdata(codec);
  11655. wcd_cpe_ssr_event(priv->cpe_core, WCD_CPE_BUS_DOWN_EVENT);
  11656. for (i = 0; i < priv->nr; i++)
  11657. swrm_wcd_notify(priv->swr_ctrl_data[i].swr_pdev,
  11658. SWR_DEVICE_DOWN, NULL);
  11659. snd_soc_card_change_online_state(codec->component.card, 0);
  11660. for (count = 0; count < NUM_CODEC_DAIS; count++)
  11661. priv->dai[count].bus_down_in_recovery = true;
  11662. priv->resmgr->sido_input_src = SIDO_SOURCE_INTERNAL;
  11663. return 0;
  11664. }
  11665. static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx)
  11666. {
  11667. int i, ret = 0;
  11668. struct wcd9xxx *control;
  11669. struct snd_soc_codec *codec;
  11670. struct tasha_priv *tasha;
  11671. struct wcd9xxx_pdata *pdata;
  11672. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11673. tasha = snd_soc_codec_get_drvdata(codec);
  11674. control = dev_get_drvdata(codec->dev->parent);
  11675. wcd9xxx_set_power_state(tasha->wcd9xxx,
  11676. WCD_REGION_POWER_COLLAPSE_REMOVE,
  11677. WCD9XXX_DIG_CORE_REGION_1);
  11678. mutex_lock(&tasha->codec_mutex);
  11679. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11680. control->slim_slave->laddr;
  11681. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11682. control->slim->laddr;
  11683. tasha_init_slim_slave_cfg(codec);
  11684. if (tasha->machine_codec_event_cb)
  11685. tasha->machine_codec_event_cb(codec,
  11686. WCD9335_CODEC_EVENT_CODEC_UP);
  11687. snd_soc_card_change_online_state(codec->component.card, 1);
  11688. /* Class-H Init*/
  11689. wcd_clsh_init(&tasha->clsh_d);
  11690. for (i = 0; i < TASHA_MAX_MICBIAS; i++)
  11691. tasha->micb_ref[i] = 0;
  11692. tasha_update_reg_defaults(tasha);
  11693. tasha->codec = codec;
  11694. dev_dbg(codec->dev, "%s: MCLK Rate = %x\n",
  11695. __func__, control->mclk_rate);
  11696. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  11697. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11698. 0x03, 0x00);
  11699. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  11700. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11701. 0x03, 0x01);
  11702. tasha_codec_init_reg(codec);
  11703. wcd_resmgr_post_ssr_v2(tasha->resmgr);
  11704. tasha_enable_efuse_sensing(codec);
  11705. regcache_mark_dirty(codec->component.regmap);
  11706. regcache_sync(codec->component.regmap);
  11707. pdata = dev_get_platdata(codec->dev->parent);
  11708. ret = tasha_handle_pdata(tasha, pdata);
  11709. if (ret < 0)
  11710. dev_err(codec->dev, "%s: invalid pdata\n", __func__);
  11711. /* Reset reference counter for voting for max bw */
  11712. tasha->ref_count = 0;
  11713. /* MBHC Init */
  11714. wcd_mbhc_deinit(&tasha->mbhc);
  11715. tasha->mbhc_started = false;
  11716. /* Initialize MBHC module */
  11717. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11718. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11719. if (ret)
  11720. dev_err(codec->dev, "%s: mbhc initialization failed\n",
  11721. __func__);
  11722. else
  11723. tasha_mbhc_hs_detect(codec, tasha->mbhc.mbhc_cfg);
  11724. tasha_cleanup_irqs(tasha);
  11725. ret = tasha_setup_irqs(tasha);
  11726. if (ret) {
  11727. dev_err(codec->dev, "%s: tasha irq setup failed %d\n",
  11728. __func__, ret);
  11729. goto err;
  11730. }
  11731. tasha_set_spkr_mode(codec, tasha->spkr_mode);
  11732. wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT);
  11733. err:
  11734. mutex_unlock(&tasha->codec_mutex);
  11735. return ret;
  11736. }
  11737. static struct regulator *tasha_codec_find_ondemand_regulator(
  11738. struct snd_soc_codec *codec, const char *name)
  11739. {
  11740. int i;
  11741. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11742. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11743. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  11744. for (i = 0; i < wcd9xxx->num_of_supplies; ++i) {
  11745. if (pdata->regulator[i].ondemand &&
  11746. wcd9xxx->supplies[i].supply &&
  11747. !strcmp(wcd9xxx->supplies[i].supply, name))
  11748. return wcd9xxx->supplies[i].consumer;
  11749. }
  11750. dev_dbg(tasha->dev, "Warning: regulator not found:%s\n",
  11751. name);
  11752. return NULL;
  11753. }
  11754. static int tasha_codec_probe(struct snd_soc_codec *codec)
  11755. {
  11756. struct wcd9xxx *control;
  11757. struct tasha_priv *tasha;
  11758. struct wcd9xxx_pdata *pdata;
  11759. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  11760. int i, ret;
  11761. void *ptr = NULL;
  11762. struct regulator *supply;
  11763. control = dev_get_drvdata(codec->dev->parent);
  11764. dev_info(codec->dev, "%s()\n", __func__);
  11765. tasha = snd_soc_codec_get_drvdata(codec);
  11766. tasha->intf_type = wcd9xxx_get_intf_type();
  11767. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11768. control->dev_down = tasha_device_down;
  11769. control->post_reset = tasha_post_reset_cb;
  11770. control->ssr_priv = (void *)codec;
  11771. }
  11772. /* Resource Manager post Init */
  11773. ret = wcd_resmgr_post_init(tasha->resmgr, &tasha_resmgr_cb, codec);
  11774. if (ret) {
  11775. dev_err(codec->dev, "%s: wcd resmgr post init failed\n",
  11776. __func__);
  11777. goto err;
  11778. }
  11779. /* Class-H Init*/
  11780. wcd_clsh_init(&tasha->clsh_d);
  11781. /* Default HPH Mode to Class-H HiFi */
  11782. tasha->hph_mode = CLS_H_HIFI;
  11783. tasha->codec = codec;
  11784. for (i = 0; i < COMPANDER_MAX; i++)
  11785. tasha->comp_enabled[i] = 0;
  11786. tasha->spkr_gain_offset = RX_GAIN_OFFSET_0_DB;
  11787. tasha->intf_type = wcd9xxx_get_intf_type();
  11788. tasha_update_reg_reset_values(codec);
  11789. pr_debug("%s: MCLK Rate = %x\n", __func__, control->mclk_rate);
  11790. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  11791. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11792. 0x03, 0x00);
  11793. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  11794. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11795. 0x03, 0x01);
  11796. tasha_codec_init_reg(codec);
  11797. tasha_enable_efuse_sensing(codec);
  11798. pdata = dev_get_platdata(codec->dev->parent);
  11799. ret = tasha_handle_pdata(tasha, pdata);
  11800. if (ret < 0) {
  11801. pr_err("%s: bad pdata\n", __func__);
  11802. goto err;
  11803. }
  11804. supply = tasha_codec_find_ondemand_regulator(codec,
  11805. on_demand_supply_name[ON_DEMAND_MICBIAS]);
  11806. if (supply) {
  11807. tasha->on_demand_list[ON_DEMAND_MICBIAS].supply = supply;
  11808. tasha->on_demand_list[ON_DEMAND_MICBIAS].ondemand_supply_count =
  11809. 0;
  11810. }
  11811. tasha->fw_data = devm_kzalloc(codec->dev,
  11812. sizeof(*(tasha->fw_data)), GFP_KERNEL);
  11813. if (!tasha->fw_data)
  11814. goto err;
  11815. set_bit(WCD9XXX_ANC_CAL, tasha->fw_data->cal_bit);
  11816. set_bit(WCD9XXX_MBHC_CAL, tasha->fw_data->cal_bit);
  11817. set_bit(WCD9XXX_MAD_CAL, tasha->fw_data->cal_bit);
  11818. set_bit(WCD9XXX_VBAT_CAL, tasha->fw_data->cal_bit);
  11819. ret = wcd_cal_create_hwdep(tasha->fw_data,
  11820. WCD9XXX_CODEC_HWDEP_NODE, codec);
  11821. if (ret < 0) {
  11822. dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret);
  11823. goto err_hwdep;
  11824. }
  11825. /* Initialize MBHC module */
  11826. if (TASHA_IS_2_0(tasha->wcd9xxx)) {
  11827. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].reg =
  11828. WCD9335_MBHC_FSM_STATUS;
  11829. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].mask = 0x01;
  11830. }
  11831. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11832. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11833. if (ret) {
  11834. pr_err("%s: mbhc initialization failed\n", __func__);
  11835. goto err_hwdep;
  11836. }
  11837. ptr = devm_kzalloc(codec->dev, (sizeof(tasha_rx_chs) +
  11838. sizeof(tasha_tx_chs)), GFP_KERNEL);
  11839. if (!ptr) {
  11840. ret = -ENOMEM;
  11841. goto err_hwdep;
  11842. }
  11843. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  11844. snd_soc_dapm_new_controls(dapm, tasha_dapm_i2s_widgets,
  11845. ARRAY_SIZE(tasha_dapm_i2s_widgets));
  11846. snd_soc_dapm_add_routes(dapm, audio_i2s_map,
  11847. ARRAY_SIZE(audio_i2s_map));
  11848. for (i = 0; i < ARRAY_SIZE(tasha_i2s_dai); i++) {
  11849. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11850. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11851. }
  11852. } else if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11853. for (i = 0; i < NUM_CODEC_DAIS; i++) {
  11854. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11855. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11856. }
  11857. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11858. control->slim_slave->laddr;
  11859. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11860. control->slim->laddr;
  11861. tasha_slimbus_slave_port_cfg.slave_port_mapping[0] =
  11862. TASHA_TX13;
  11863. tasha_init_slim_slave_cfg(codec);
  11864. }
  11865. snd_soc_add_codec_controls(codec, impedance_detect_controls,
  11866. ARRAY_SIZE(impedance_detect_controls));
  11867. snd_soc_add_codec_controls(codec, hph_type_detect_controls,
  11868. ARRAY_SIZE(hph_type_detect_controls));
  11869. snd_soc_add_codec_controls(codec,
  11870. tasha_analog_gain_controls,
  11871. ARRAY_SIZE(tasha_analog_gain_controls));
  11872. if (tasha->is_wsa_attach)
  11873. snd_soc_add_codec_controls(codec,
  11874. tasha_spkr_wsa_controls,
  11875. ARRAY_SIZE(tasha_spkr_wsa_controls));
  11876. control->num_rx_port = TASHA_RX_MAX;
  11877. control->rx_chs = ptr;
  11878. memcpy(control->rx_chs, tasha_rx_chs, sizeof(tasha_rx_chs));
  11879. control->num_tx_port = TASHA_TX_MAX;
  11880. control->tx_chs = ptr + sizeof(tasha_rx_chs);
  11881. memcpy(control->tx_chs, tasha_tx_chs, sizeof(tasha_tx_chs));
  11882. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Playback");
  11883. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Capture");
  11884. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Playback");
  11885. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Capture");
  11886. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11887. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Playback");
  11888. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Capture");
  11889. snd_soc_dapm_ignore_suspend(dapm, "AIF4 Playback");
  11890. snd_soc_dapm_ignore_suspend(dapm, "AIF Mix Playback");
  11891. snd_soc_dapm_ignore_suspend(dapm, "AIF4 MAD TX");
  11892. snd_soc_dapm_ignore_suspend(dapm, "VIfeed");
  11893. snd_soc_dapm_ignore_suspend(dapm, "AIF5 CPE TX");
  11894. }
  11895. snd_soc_dapm_sync(dapm);
  11896. ret = tasha_setup_irqs(tasha);
  11897. if (ret) {
  11898. pr_err("%s: tasha irq setup failed %d\n", __func__, ret);
  11899. goto err_pdata;
  11900. }
  11901. ret = tasha_cpe_initialize(codec);
  11902. if (ret) {
  11903. dev_err(codec->dev,
  11904. "%s: cpe initialization failed, err = %d\n",
  11905. __func__, ret);
  11906. /* Do not fail probe if CPE failed */
  11907. ret = 0;
  11908. }
  11909. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11910. tasha->tx_hpf_work[i].tasha = tasha;
  11911. tasha->tx_hpf_work[i].decimator = i;
  11912. INIT_DELAYED_WORK(&tasha->tx_hpf_work[i].dwork,
  11913. tasha_tx_hpf_corner_freq_callback);
  11914. }
  11915. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11916. tasha->tx_mute_dwork[i].tasha = tasha;
  11917. tasha->tx_mute_dwork[i].decimator = i;
  11918. INIT_DELAYED_WORK(&tasha->tx_mute_dwork[i].dwork,
  11919. tasha_tx_mute_update_callback);
  11920. }
  11921. tasha->spk_anc_dwork.tasha = tasha;
  11922. INIT_DELAYED_WORK(&tasha->spk_anc_dwork.dwork,
  11923. tasha_spk_anc_update_callback);
  11924. mutex_lock(&tasha->codec_mutex);
  11925. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  11926. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  11927. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  11928. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  11929. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  11930. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  11931. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  11932. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  11933. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  11934. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  11935. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  11936. mutex_unlock(&tasha->codec_mutex);
  11937. snd_soc_dapm_sync(dapm);
  11938. return ret;
  11939. err_pdata:
  11940. devm_kfree(codec->dev, ptr);
  11941. control->rx_chs = NULL;
  11942. control->tx_chs = NULL;
  11943. err_hwdep:
  11944. devm_kfree(codec->dev, tasha->fw_data);
  11945. tasha->fw_data = NULL;
  11946. err:
  11947. return ret;
  11948. }
  11949. static int tasha_codec_remove(struct snd_soc_codec *codec)
  11950. {
  11951. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11952. struct wcd9xxx *control;
  11953. control = dev_get_drvdata(codec->dev->parent);
  11954. control->num_rx_port = 0;
  11955. control->num_tx_port = 0;
  11956. control->rx_chs = NULL;
  11957. control->tx_chs = NULL;
  11958. tasha_cleanup_irqs(tasha);
  11959. /* Cleanup MBHC */
  11960. wcd_mbhc_deinit(&tasha->mbhc);
  11961. /* Cleanup resmgr */
  11962. return 0;
  11963. }
  11964. static struct regmap *tasha_get_regmap(struct device *dev)
  11965. {
  11966. struct wcd9xxx *control = dev_get_drvdata(dev->parent);
  11967. return control->regmap;
  11968. }
  11969. static struct snd_soc_codec_driver soc_codec_dev_tasha = {
  11970. .probe = tasha_codec_probe,
  11971. .remove = tasha_codec_remove,
  11972. .get_regmap = tasha_get_regmap,
  11973. .component_driver = {
  11974. .controls = tasha_snd_controls,
  11975. .num_controls = ARRAY_SIZE(tasha_snd_controls),
  11976. .dapm_widgets = tasha_dapm_widgets,
  11977. .num_dapm_widgets = ARRAY_SIZE(tasha_dapm_widgets),
  11978. .dapm_routes = audio_map,
  11979. .num_dapm_routes = ARRAY_SIZE(audio_map),
  11980. },
  11981. };
  11982. #ifdef CONFIG_PM
  11983. static int tasha_suspend(struct device *dev)
  11984. {
  11985. struct platform_device *pdev = to_platform_device(dev);
  11986. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  11987. dev_dbg(dev, "%s: system suspend\n", __func__);
  11988. if (cancel_delayed_work_sync(&tasha->power_gate_work))
  11989. tasha_codec_power_gate_digital_core(tasha);
  11990. return 0;
  11991. }
  11992. static int tasha_resume(struct device *dev)
  11993. {
  11994. struct platform_device *pdev = to_platform_device(dev);
  11995. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  11996. if (!tasha) {
  11997. dev_err(dev, "%s: tasha private data is NULL\n", __func__);
  11998. return -EINVAL;
  11999. }
  12000. dev_dbg(dev, "%s: system resume\n", __func__);
  12001. return 0;
  12002. }
  12003. static const struct dev_pm_ops tasha_pm_ops = {
  12004. .suspend = tasha_suspend,
  12005. .resume = tasha_resume,
  12006. };
  12007. #endif
  12008. static int tasha_swrm_read(void *handle, int reg)
  12009. {
  12010. struct tasha_priv *tasha;
  12011. struct wcd9xxx *wcd9xxx;
  12012. unsigned short swr_rd_addr_base;
  12013. unsigned short swr_rd_data_base;
  12014. int val, ret;
  12015. if (!handle) {
  12016. pr_err("%s: NULL handle\n", __func__);
  12017. return -EINVAL;
  12018. }
  12019. tasha = (struct tasha_priv *)handle;
  12020. wcd9xxx = tasha->wcd9xxx;
  12021. dev_dbg(tasha->dev, "%s: Reading soundwire register, 0x%x\n",
  12022. __func__, reg);
  12023. swr_rd_addr_base = WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0;
  12024. swr_rd_data_base = WCD9335_SWR_AHB_BRIDGE_RD_DATA_0;
  12025. /* read_lock */
  12026. mutex_lock(&tasha->swr_read_lock);
  12027. ret = regmap_bulk_write(wcd9xxx->regmap, swr_rd_addr_base,
  12028. (u8 *)&reg, 4);
  12029. if (ret < 0) {
  12030. pr_err("%s: RD Addr Failure\n", __func__);
  12031. goto err;
  12032. }
  12033. /* Check for RD status */
  12034. ret = regmap_bulk_read(wcd9xxx->regmap, swr_rd_data_base,
  12035. (u8 *)&val, 4);
  12036. if (ret < 0) {
  12037. pr_err("%s: RD Data Failure\n", __func__);
  12038. goto err;
  12039. }
  12040. ret = val;
  12041. err:
  12042. /* read_unlock */
  12043. mutex_unlock(&tasha->swr_read_lock);
  12044. return ret;
  12045. }
  12046. static int tasha_swrm_i2s_bulk_write(struct wcd9xxx *wcd9xxx,
  12047. struct wcd9xxx_reg_val *bulk_reg,
  12048. size_t len)
  12049. {
  12050. int i, ret = 0;
  12051. unsigned short swr_wr_addr_base;
  12052. unsigned short swr_wr_data_base;
  12053. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12054. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12055. for (i = 0; i < (len * 2); i += 2) {
  12056. /* First Write the Data to register */
  12057. ret = regmap_bulk_write(wcd9xxx->regmap,
  12058. swr_wr_data_base, bulk_reg[i].buf, 4);
  12059. if (ret < 0) {
  12060. dev_err(wcd9xxx->dev, "%s: WR Data Failure\n",
  12061. __func__);
  12062. break;
  12063. }
  12064. /* Next Write Address */
  12065. ret = regmap_bulk_write(wcd9xxx->regmap,
  12066. swr_wr_addr_base, bulk_reg[i+1].buf, 4);
  12067. if (ret < 0) {
  12068. dev_err(wcd9xxx->dev, "%s: WR Addr Failure\n",
  12069. __func__);
  12070. break;
  12071. }
  12072. }
  12073. return ret;
  12074. }
  12075. static int tasha_swrm_bulk_write(void *handle, u32 *reg, u32 *val, size_t len)
  12076. {
  12077. struct tasha_priv *tasha;
  12078. struct wcd9xxx *wcd9xxx;
  12079. struct wcd9xxx_reg_val *bulk_reg;
  12080. unsigned short swr_wr_addr_base;
  12081. unsigned short swr_wr_data_base;
  12082. int i, j, ret;
  12083. if (!handle) {
  12084. pr_err("%s: NULL handle\n", __func__);
  12085. return -EINVAL;
  12086. }
  12087. if (len <= 0) {
  12088. pr_err("%s: Invalid size: %zu\n", __func__, len);
  12089. return -EINVAL;
  12090. }
  12091. tasha = (struct tasha_priv *)handle;
  12092. wcd9xxx = tasha->wcd9xxx;
  12093. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12094. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12095. bulk_reg = kzalloc((2 * len * sizeof(struct wcd9xxx_reg_val)),
  12096. GFP_KERNEL);
  12097. if (!bulk_reg)
  12098. return -ENOMEM;
  12099. for (i = 0, j = 0; i < (len * 2); i += 2, j++) {
  12100. bulk_reg[i].reg = swr_wr_data_base;
  12101. bulk_reg[i].buf = (u8 *)(&val[j]);
  12102. bulk_reg[i].bytes = 4;
  12103. bulk_reg[i+1].reg = swr_wr_addr_base;
  12104. bulk_reg[i+1].buf = (u8 *)(&reg[j]);
  12105. bulk_reg[i+1].bytes = 4;
  12106. }
  12107. mutex_lock(&tasha->swr_write_lock);
  12108. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12109. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, len);
  12110. if (ret) {
  12111. dev_err(tasha->dev, "%s: i2s bulk write failed, ret: %d\n",
  12112. __func__, ret);
  12113. }
  12114. } else {
  12115. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg,
  12116. (len * 2), false);
  12117. if (ret) {
  12118. dev_err(tasha->dev, "%s: swrm bulk write failed, ret: %d\n",
  12119. __func__, ret);
  12120. }
  12121. }
  12122. mutex_unlock(&tasha->swr_write_lock);
  12123. kfree(bulk_reg);
  12124. return ret;
  12125. }
  12126. static int tasha_swrm_write(void *handle, int reg, int val)
  12127. {
  12128. struct tasha_priv *tasha;
  12129. struct wcd9xxx *wcd9xxx;
  12130. unsigned short swr_wr_addr_base;
  12131. unsigned short swr_wr_data_base;
  12132. struct wcd9xxx_reg_val bulk_reg[2];
  12133. int ret;
  12134. if (!handle) {
  12135. pr_err("%s: NULL handle\n", __func__);
  12136. return -EINVAL;
  12137. }
  12138. tasha = (struct tasha_priv *)handle;
  12139. wcd9xxx = tasha->wcd9xxx;
  12140. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12141. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12142. /* First Write the Data to register */
  12143. bulk_reg[0].reg = swr_wr_data_base;
  12144. bulk_reg[0].buf = (u8 *)(&val);
  12145. bulk_reg[0].bytes = 4;
  12146. bulk_reg[1].reg = swr_wr_addr_base;
  12147. bulk_reg[1].buf = (u8 *)(&reg);
  12148. bulk_reg[1].bytes = 4;
  12149. mutex_lock(&tasha->swr_write_lock);
  12150. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12151. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, 1);
  12152. if (ret) {
  12153. dev_err(tasha->dev, "%s: i2s swrm write failed, ret: %d\n",
  12154. __func__, ret);
  12155. }
  12156. } else {
  12157. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2, false);
  12158. if (ret < 0)
  12159. pr_err("%s: WR Data Failure\n", __func__);
  12160. }
  12161. mutex_unlock(&tasha->swr_write_lock);
  12162. return ret;
  12163. }
  12164. static int tasha_swrm_clock(void *handle, bool enable)
  12165. {
  12166. struct tasha_priv *tasha = (struct tasha_priv *) handle;
  12167. mutex_lock(&tasha->swr_clk_lock);
  12168. dev_dbg(tasha->dev, "%s: swrm clock %s\n",
  12169. __func__, (enable?"enable" : "disable"));
  12170. if (enable) {
  12171. tasha->swr_clk_users++;
  12172. if (tasha->swr_clk_users == 1) {
  12173. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12174. regmap_update_bits(
  12175. tasha->wcd9xxx->regmap,
  12176. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12177. 0x10, 0x00);
  12178. __tasha_cdc_mclk_enable(tasha, true);
  12179. regmap_update_bits(tasha->wcd9xxx->regmap,
  12180. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12181. 0x01, 0x01);
  12182. }
  12183. } else {
  12184. tasha->swr_clk_users--;
  12185. if (tasha->swr_clk_users == 0) {
  12186. regmap_update_bits(tasha->wcd9xxx->regmap,
  12187. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12188. 0x01, 0x00);
  12189. __tasha_cdc_mclk_enable(tasha, false);
  12190. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12191. regmap_update_bits(
  12192. tasha->wcd9xxx->regmap,
  12193. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12194. 0x10, 0x10);
  12195. }
  12196. }
  12197. dev_dbg(tasha->dev, "%s: swrm clock users %d\n",
  12198. __func__, tasha->swr_clk_users);
  12199. mutex_unlock(&tasha->swr_clk_lock);
  12200. return 0;
  12201. }
  12202. static int tasha_swrm_handle_irq(void *handle,
  12203. irqreturn_t (*swrm_irq_handler)(int irq,
  12204. void *data),
  12205. void *swrm_handle,
  12206. int action)
  12207. {
  12208. struct tasha_priv *tasha;
  12209. int ret = 0;
  12210. struct wcd9xxx *wcd9xxx;
  12211. if (!handle) {
  12212. pr_err("%s: null handle received\n", __func__);
  12213. return -EINVAL;
  12214. }
  12215. tasha = (struct tasha_priv *) handle;
  12216. wcd9xxx = tasha->wcd9xxx;
  12217. if (action) {
  12218. ret = wcd9xxx_request_irq(&wcd9xxx->core_res,
  12219. WCD9335_IRQ_SOUNDWIRE,
  12220. swrm_irq_handler,
  12221. "Tasha SWR Master", swrm_handle);
  12222. if (ret)
  12223. dev_err(tasha->dev, "%s: Failed to request irq %d\n",
  12224. __func__, WCD9335_IRQ_SOUNDWIRE);
  12225. } else
  12226. wcd9xxx_free_irq(&wcd9xxx->core_res, WCD9335_IRQ_SOUNDWIRE,
  12227. swrm_handle);
  12228. return ret;
  12229. }
  12230. static void tasha_add_child_devices(struct work_struct *work)
  12231. {
  12232. struct tasha_priv *tasha;
  12233. struct platform_device *pdev;
  12234. struct device_node *node;
  12235. struct wcd9xxx *wcd9xxx;
  12236. struct tasha_swr_ctrl_data *swr_ctrl_data = NULL, *temp;
  12237. int ret, ctrl_num = 0;
  12238. struct wcd_swr_ctrl_platform_data *platdata;
  12239. char plat_dev_name[WCD9335_STRING_LEN];
  12240. tasha = container_of(work, struct tasha_priv,
  12241. tasha_add_child_devices_work);
  12242. if (!tasha) {
  12243. pr_err("%s: Memory for WCD9335 does not exist\n",
  12244. __func__);
  12245. return;
  12246. }
  12247. wcd9xxx = tasha->wcd9xxx;
  12248. if (!wcd9xxx) {
  12249. pr_err("%s: Memory for WCD9XXX does not exist\n",
  12250. __func__);
  12251. return;
  12252. }
  12253. if (!wcd9xxx->dev->of_node) {
  12254. pr_err("%s: DT node for wcd9xxx does not exist\n",
  12255. __func__);
  12256. return;
  12257. }
  12258. platdata = &tasha->swr_plat_data;
  12259. tasha->child_count = 0;
  12260. for_each_child_of_node(wcd9xxx->dev->of_node, node) {
  12261. if (!strcmp(node->name, "swr_master"))
  12262. strlcpy(plat_dev_name, "tasha_swr_ctrl",
  12263. (WCD9335_STRING_LEN - 1));
  12264. else if (strnstr(node->name, "msm_cdc_pinctrl",
  12265. strlen("msm_cdc_pinctrl")) != NULL)
  12266. strlcpy(plat_dev_name, node->name,
  12267. (WCD9335_STRING_LEN - 1));
  12268. else
  12269. continue;
  12270. pdev = platform_device_alloc(plat_dev_name, -1);
  12271. if (!pdev) {
  12272. dev_err(wcd9xxx->dev, "%s: pdev memory alloc failed\n",
  12273. __func__);
  12274. ret = -ENOMEM;
  12275. goto err;
  12276. }
  12277. pdev->dev.parent = tasha->dev;
  12278. pdev->dev.of_node = node;
  12279. if (!strcmp(node->name, "swr_master")) {
  12280. ret = platform_device_add_data(pdev, platdata,
  12281. sizeof(*platdata));
  12282. if (ret) {
  12283. dev_err(&pdev->dev,
  12284. "%s: cannot add plat data ctrl:%d\n",
  12285. __func__, ctrl_num);
  12286. goto fail_pdev_add;
  12287. }
  12288. tasha->is_wsa_attach = true;
  12289. }
  12290. ret = platform_device_add(pdev);
  12291. if (ret) {
  12292. dev_err(&pdev->dev,
  12293. "%s: Cannot add platform device\n",
  12294. __func__);
  12295. goto fail_pdev_add;
  12296. }
  12297. if (!strcmp(node->name, "swr_master")) {
  12298. temp = krealloc(swr_ctrl_data,
  12299. (ctrl_num + 1) * sizeof(
  12300. struct tasha_swr_ctrl_data),
  12301. GFP_KERNEL);
  12302. if (!temp) {
  12303. dev_err(wcd9xxx->dev, "out of memory\n");
  12304. ret = -ENOMEM;
  12305. goto err;
  12306. }
  12307. swr_ctrl_data = temp;
  12308. swr_ctrl_data[ctrl_num].swr_pdev = pdev;
  12309. ctrl_num++;
  12310. dev_dbg(&pdev->dev,
  12311. "%s: Added soundwire ctrl device(s)\n",
  12312. __func__);
  12313. tasha->nr = ctrl_num;
  12314. tasha->swr_ctrl_data = swr_ctrl_data;
  12315. }
  12316. if (tasha->child_count < WCD9335_CHILD_DEVICES_MAX)
  12317. tasha->pdev_child_devices[tasha->child_count++] = pdev;
  12318. else
  12319. goto err;
  12320. }
  12321. return;
  12322. fail_pdev_add:
  12323. platform_device_put(pdev);
  12324. err:
  12325. return;
  12326. }
  12327. /*
  12328. * tasha_codec_ver: to get tasha codec version
  12329. * @codec: handle to snd_soc_codec *
  12330. * return enum codec_variant - version
  12331. */
  12332. enum codec_variant tasha_codec_ver(void)
  12333. {
  12334. return codec_ver;
  12335. }
  12336. EXPORT_SYMBOL(tasha_codec_ver);
  12337. static int __tasha_enable_efuse_sensing(struct tasha_priv *tasha)
  12338. {
  12339. int val, rc;
  12340. __tasha_cdc_mclk_enable(tasha, true);
  12341. regmap_update_bits(tasha->wcd9xxx->regmap,
  12342. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x1E, 0x20);
  12343. regmap_update_bits(tasha->wcd9xxx->regmap,
  12344. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x01, 0x01);
  12345. /*
  12346. * 5ms sleep required after enabling efuse control
  12347. * before checking the status.
  12348. */
  12349. usleep_range(5000, 5500);
  12350. rc = regmap_read(tasha->wcd9xxx->regmap,
  12351. WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS, &val);
  12352. if (rc || (!(val & 0x01)))
  12353. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  12354. __tasha_cdc_mclk_enable(tasha, false);
  12355. return rc;
  12356. }
  12357. void tasha_get_codec_ver(struct tasha_priv *tasha)
  12358. {
  12359. int i;
  12360. int val;
  12361. struct tasha_reg_mask_val codec_reg[] = {
  12362. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10, 0xFF, 0xFF},
  12363. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11, 0xFF, 0x83},
  12364. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12, 0xFF, 0x0A},
  12365. };
  12366. __tasha_enable_efuse_sensing(tasha);
  12367. for (i = 0; i < ARRAY_SIZE(codec_reg); i++) {
  12368. regmap_read(tasha->wcd9xxx->regmap, codec_reg[i].reg, &val);
  12369. if (!(val && codec_reg[i].val)) {
  12370. codec_ver = WCD9335;
  12371. goto ret;
  12372. }
  12373. }
  12374. codec_ver = WCD9326;
  12375. ret:
  12376. pr_debug("%s: codec is %d\n", __func__, codec_ver);
  12377. }
  12378. EXPORT_SYMBOL(tasha_get_codec_ver);
  12379. static int tasha_probe(struct platform_device *pdev)
  12380. {
  12381. int ret = 0;
  12382. struct tasha_priv *tasha;
  12383. struct clk *wcd_ext_clk, *wcd_native_clk;
  12384. struct wcd9xxx_resmgr_v2 *resmgr;
  12385. struct wcd9xxx_power_region *cdc_pwr;
  12386. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12387. if (apr_get_subsys_state() == APR_SUBSYS_DOWN) {
  12388. dev_err(&pdev->dev, "%s: dsp down\n", __func__);
  12389. return -EPROBE_DEFER;
  12390. }
  12391. }
  12392. tasha = devm_kzalloc(&pdev->dev, sizeof(struct tasha_priv),
  12393. GFP_KERNEL);
  12394. if (!tasha)
  12395. return -ENOMEM;
  12396. platform_set_drvdata(pdev, tasha);
  12397. tasha->wcd9xxx = dev_get_drvdata(pdev->dev.parent);
  12398. tasha->dev = &pdev->dev;
  12399. INIT_DELAYED_WORK(&tasha->power_gate_work, tasha_codec_power_gate_work);
  12400. mutex_init(&tasha->power_lock);
  12401. mutex_init(&tasha->sido_lock);
  12402. INIT_WORK(&tasha->tasha_add_child_devices_work,
  12403. tasha_add_child_devices);
  12404. BLOCKING_INIT_NOTIFIER_HEAD(&tasha->notifier);
  12405. mutex_init(&tasha->micb_lock);
  12406. mutex_init(&tasha->swr_read_lock);
  12407. mutex_init(&tasha->swr_write_lock);
  12408. mutex_init(&tasha->swr_clk_lock);
  12409. mutex_init(&tasha->sb_clk_gear_lock);
  12410. mutex_init(&tasha->mclk_lock);
  12411. cdc_pwr = devm_kzalloc(&pdev->dev, sizeof(struct wcd9xxx_power_region),
  12412. GFP_KERNEL);
  12413. if (!cdc_pwr) {
  12414. ret = -ENOMEM;
  12415. goto err_cdc_pwr;
  12416. }
  12417. tasha->wcd9xxx->wcd9xxx_pwr[WCD9XXX_DIG_CORE_REGION_1] = cdc_pwr;
  12418. cdc_pwr->pwr_collapse_reg_min = TASHA_DIG_CORE_REG_MIN;
  12419. cdc_pwr->pwr_collapse_reg_max = TASHA_DIG_CORE_REG_MAX;
  12420. wcd9xxx_set_power_state(tasha->wcd9xxx,
  12421. WCD_REGION_POWER_COLLAPSE_REMOVE,
  12422. WCD9XXX_DIG_CORE_REGION_1);
  12423. mutex_init(&tasha->codec_mutex);
  12424. /*
  12425. * Init resource manager so that if child nodes such as SoundWire
  12426. * requests for clock, resource manager can honor the request
  12427. */
  12428. resmgr = wcd_resmgr_init(&tasha->wcd9xxx->core_res, NULL);
  12429. if (IS_ERR(resmgr)) {
  12430. ret = PTR_ERR(resmgr);
  12431. dev_err(&pdev->dev, "%s: Failed to initialize wcd resmgr\n",
  12432. __func__);
  12433. goto err_resmgr;
  12434. }
  12435. tasha->resmgr = resmgr;
  12436. tasha->swr_plat_data.handle = (void *) tasha;
  12437. tasha->swr_plat_data.read = tasha_swrm_read;
  12438. tasha->swr_plat_data.write = tasha_swrm_write;
  12439. tasha->swr_plat_data.bulk_write = tasha_swrm_bulk_write;
  12440. tasha->swr_plat_data.clk = tasha_swrm_clock;
  12441. tasha->swr_plat_data.handle_irq = tasha_swrm_handle_irq;
  12442. /* Register for Clock */
  12443. wcd_ext_clk = clk_get(tasha->wcd9xxx->dev, "wcd_clk");
  12444. if (IS_ERR(wcd_ext_clk)) {
  12445. dev_err(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12446. __func__, "wcd_ext_clk");
  12447. goto err_clk;
  12448. }
  12449. tasha->wcd_ext_clk = wcd_ext_clk;
  12450. tasha->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV;
  12451. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  12452. tasha->sido_ccl_cnt = 0;
  12453. /* Register native clk for 44.1 playback */
  12454. wcd_native_clk = clk_get(tasha->wcd9xxx->dev, "wcd_native_clk");
  12455. if (IS_ERR(wcd_native_clk))
  12456. dev_dbg(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12457. __func__, "wcd_native_clk");
  12458. else
  12459. tasha->wcd_native_clk = wcd_native_clk;
  12460. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  12461. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12462. tasha_dai, ARRAY_SIZE(tasha_dai));
  12463. else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
  12464. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12465. tasha_i2s_dai,
  12466. ARRAY_SIZE(tasha_i2s_dai));
  12467. else
  12468. ret = -EINVAL;
  12469. if (ret) {
  12470. dev_err(&pdev->dev, "%s: Codec registration failed, ret = %d\n",
  12471. __func__, ret);
  12472. goto err_cdc_reg;
  12473. }
  12474. /* Update codec register default values */
  12475. tasha_update_reg_defaults(tasha);
  12476. schedule_work(&tasha->tasha_add_child_devices_work);
  12477. tasha_get_codec_ver(tasha);
  12478. dev_info(&pdev->dev, "%s: Tasha driver probe done\n", __func__);
  12479. return ret;
  12480. err_cdc_reg:
  12481. clk_put(tasha->wcd_ext_clk);
  12482. if (tasha->wcd_native_clk)
  12483. clk_put(tasha->wcd_native_clk);
  12484. err_clk:
  12485. wcd_resmgr_remove(tasha->resmgr);
  12486. err_resmgr:
  12487. devm_kfree(&pdev->dev, cdc_pwr);
  12488. err_cdc_pwr:
  12489. mutex_destroy(&tasha->mclk_lock);
  12490. devm_kfree(&pdev->dev, tasha);
  12491. return ret;
  12492. }
  12493. static int tasha_remove(struct platform_device *pdev)
  12494. {
  12495. struct tasha_priv *tasha;
  12496. int count = 0;
  12497. tasha = platform_get_drvdata(pdev);
  12498. if (!tasha)
  12499. return -EINVAL;
  12500. for (count = 0; count < tasha->child_count &&
  12501. count < WCD9335_CHILD_DEVICES_MAX; count++)
  12502. platform_device_unregister(tasha->pdev_child_devices[count]);
  12503. mutex_destroy(&tasha->codec_mutex);
  12504. clk_put(tasha->wcd_ext_clk);
  12505. if (tasha->wcd_native_clk)
  12506. clk_put(tasha->wcd_native_clk);
  12507. mutex_destroy(&tasha->mclk_lock);
  12508. mutex_destroy(&tasha->sb_clk_gear_lock);
  12509. snd_soc_unregister_codec(&pdev->dev);
  12510. devm_kfree(&pdev->dev, tasha);
  12511. return 0;
  12512. }
  12513. static struct platform_driver tasha_codec_driver = {
  12514. .probe = tasha_probe,
  12515. .remove = tasha_remove,
  12516. .driver = {
  12517. .name = "tasha_codec",
  12518. .owner = THIS_MODULE,
  12519. #ifdef CONFIG_PM
  12520. .pm = &tasha_pm_ops,
  12521. #endif
  12522. },
  12523. };
  12524. module_platform_driver(tasha_codec_driver);
  12525. MODULE_DESCRIPTION("Tasha Codec driver");
  12526. MODULE_LICENSE("GPL v2");