wcd9335.c 436 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211
  1. /*
  2. * Copyright (c) 2015-2017, 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 BYTE_BIT_MASK(nr) (1 << ((nr) % BITS_PER_BYTE))
  81. #define TASHA_MAD_AUDIO_FIRMWARE_PATH "wcd9335/wcd9335_mad_audio.bin"
  82. #define TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS (1 << 0)
  83. #define TASHA_CPE_SS_ERR_STATUS_WDOG_BITE (1 << 1)
  84. #define TASHA_CPE_FATAL_IRQS \
  85. (TASHA_CPE_SS_ERR_STATUS_WDOG_BITE | \
  86. TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS)
  87. #define SLIM_BW_CLK_GEAR_9 6200000
  88. #define SLIM_BW_UNVOTE 0
  89. #define CPE_FLL_CLK_75MHZ 75000000
  90. #define CPE_FLL_CLK_150MHZ 150000000
  91. #define WCD9335_REG_BITS 8
  92. #define WCD9335_MAX_VALID_ADC_MUX 13
  93. #define WCD9335_INVALID_ADC_MUX 9
  94. #define TASHA_DIG_CORE_REG_MIN WCD9335_CDC_ANC0_CLK_RESET_CTL
  95. #define TASHA_DIG_CORE_REG_MAX 0xDFF
  96. /* Convert from vout ctl to micbias voltage in mV */
  97. #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
  98. #define TASHA_ZDET_NUM_MEASUREMENTS 900
  99. #define TASHA_MBHC_GET_C1(c) ((c & 0xC000) >> 14)
  100. #define TASHA_MBHC_GET_X1(x) (x & 0x3FFF)
  101. /* z value compared in milliOhm */
  102. #define TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000))
  103. #define TASHA_MBHC_ZDET_CONST (86 * 16384)
  104. #define TASHA_MBHC_MOISTURE_VREF V_45_MV
  105. #define TASHA_MBHC_MOISTURE_IREF I_3P0_UA
  106. #define TASHA_VERSION_ENTRY_SIZE 17
  107. #define WCD9335_AMIC_PWR_LEVEL_LP 0
  108. #define WCD9335_AMIC_PWR_LEVEL_DEFAULT 1
  109. #define WCD9335_AMIC_PWR_LEVEL_HP 2
  110. #define WCD9335_AMIC_PWR_LVL_MASK 0x60
  111. #define WCD9335_AMIC_PWR_LVL_SHIFT 0x5
  112. #define WCD9335_DEC_PWR_LVL_MASK 0x06
  113. #define WCD9335_DEC_PWR_LVL_LP 0x02
  114. #define WCD9335_DEC_PWR_LVL_HP 0x04
  115. #define WCD9335_DEC_PWR_LVL_DF 0x00
  116. #define WCD9335_STRING_LEN 100
  117. #define CALCULATE_VOUT_D(req_mv) (((req_mv - 650) * 10) / 25)
  118. static int cpe_debug_mode;
  119. #define TASHA_MAX_MICBIAS 4
  120. #define DAPM_MICBIAS1_STANDALONE "MIC BIAS1 Standalone"
  121. #define DAPM_MICBIAS2_STANDALONE "MIC BIAS2 Standalone"
  122. #define DAPM_MICBIAS3_STANDALONE "MIC BIAS3 Standalone"
  123. #define DAPM_MICBIAS4_STANDALONE "MIC BIAS4 Standalone"
  124. #define DAPM_LDO_H_STANDALONE "LDO_H"
  125. module_param(cpe_debug_mode, int, 0664);
  126. MODULE_PARM_DESC(cpe_debug_mode, "boot cpe in debug mode");
  127. #define TASHA_DIG_CORE_COLLAPSE_TIMER_MS (5 * 1000)
  128. #define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH 64
  129. static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = {
  130. "cdc-vdd-mic-bias",
  131. };
  132. enum {
  133. POWER_COLLAPSE,
  134. POWER_RESUME,
  135. };
  136. enum tasha_sido_voltage {
  137. SIDO_VOLTAGE_SVS_MV = 950,
  138. SIDO_VOLTAGE_NOMINAL_MV = 1100,
  139. };
  140. static enum codec_variant codec_ver;
  141. static int dig_core_collapse_enable = 1;
  142. module_param(dig_core_collapse_enable, int, 0664);
  143. MODULE_PARM_DESC(dig_core_collapse_enable, "enable/disable power gating");
  144. /* dig_core_collapse timer in seconds */
  145. static int dig_core_collapse_timer = (TASHA_DIG_CORE_COLLAPSE_TIMER_MS/1000);
  146. module_param(dig_core_collapse_timer, int, 0664);
  147. MODULE_PARM_DESC(dig_core_collapse_timer, "timer for power gating");
  148. /* SVS Scaling enable/disable */
  149. static int svs_scaling_enabled = 1;
  150. module_param(svs_scaling_enabled, int, 0664);
  151. MODULE_PARM_DESC(svs_scaling_enabled, "enable/disable svs scaling");
  152. /* SVS buck setting */
  153. static int sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  154. module_param(sido_buck_svs_voltage, int, 0664);
  155. MODULE_PARM_DESC(sido_buck_svs_voltage,
  156. "setting for SVS voltage for SIDO BUCK");
  157. #define TASHA_TX_UNMUTE_DELAY_MS 40
  158. static int tx_unmute_delay = TASHA_TX_UNMUTE_DELAY_MS;
  159. module_param(tx_unmute_delay, int, 0664);
  160. MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path");
  161. static struct afe_param_slimbus_slave_port_cfg tasha_slimbus_slave_port_cfg = {
  162. .minor_version = 1,
  163. .slimbus_dev_id = AFE_SLIMBUS_DEVICE_1,
  164. .slave_dev_pgd_la = 0,
  165. .slave_dev_intfdev_la = 0,
  166. .bit_width = 16,
  167. .data_format = 0,
  168. .num_channels = 1
  169. };
  170. struct tasha_mbhc_zdet_param {
  171. u16 ldo_ctl;
  172. u16 noff;
  173. u16 nshift;
  174. u16 btn5;
  175. u16 btn6;
  176. u16 btn7;
  177. };
  178. static struct afe_param_cdc_reg_page_cfg tasha_cdc_reg_page_cfg = {
  179. .minor_version = AFE_API_VERSION_CDC_REG_PAGE_CFG,
  180. .enable = 1,
  181. .proc_id = AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_1,
  182. };
  183. static struct afe_param_cdc_reg_cfg audio_reg_cfg[] = {
  184. {
  185. 1,
  186. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_MAIN_CTL_1),
  187. HW_MAD_AUDIO_ENABLE, 0x1, WCD9335_REG_BITS, 0
  188. },
  189. {
  190. 1,
  191. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_3),
  192. HW_MAD_AUDIO_SLEEP_TIME, 0xF, WCD9335_REG_BITS, 0
  193. },
  194. {
  195. 1,
  196. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_4),
  197. HW_MAD_TX_AUDIO_SWITCH_OFF, 0x1, WCD9335_REG_BITS, 0
  198. },
  199. {
  200. 1,
  201. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  202. MAD_AUDIO_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  203. },
  204. {
  205. 1,
  206. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  207. MAD_AUDIO_INT_MASK_REG, 0x1, WCD9335_REG_BITS, 0
  208. },
  209. {
  210. 1,
  211. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  212. MAD_AUDIO_INT_STATUS_REG, 0x1, WCD9335_REG_BITS, 0
  213. },
  214. {
  215. 1,
  216. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  217. MAD_AUDIO_INT_CLEAR_REG, 0x1, WCD9335_REG_BITS, 0
  218. },
  219. {
  220. 1,
  221. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  222. VBAT_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  223. },
  224. {
  225. 1,
  226. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  227. VBAT_INT_MASK_REG, 0x08, WCD9335_REG_BITS, 0
  228. },
  229. {
  230. 1,
  231. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  232. VBAT_INT_STATUS_REG, 0x08, WCD9335_REG_BITS, 0
  233. },
  234. {
  235. 1,
  236. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  237. VBAT_INT_CLEAR_REG, 0x08, WCD9335_REG_BITS, 0
  238. },
  239. {
  240. 1,
  241. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  242. VBAT_RELEASE_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  243. },
  244. {
  245. 1,
  246. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  247. VBAT_RELEASE_INT_MASK_REG, 0x10, WCD9335_REG_BITS, 0
  248. },
  249. {
  250. 1,
  251. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  252. VBAT_RELEASE_INT_STATUS_REG, 0x10, WCD9335_REG_BITS, 0
  253. },
  254. {
  255. 1,
  256. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  257. VBAT_RELEASE_INT_CLEAR_REG, 0x10, WCD9335_REG_BITS, 0
  258. },
  259. {
  260. 1,
  261. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  262. SB_PGD_PORT_TX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  263. },
  264. {
  265. 1,
  266. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  267. SB_PGD_PORT_TX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  268. },
  269. {
  270. 1,
  271. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  272. SB_PGD_PORT_RX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  273. },
  274. {
  275. 1,
  276. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  277. SB_PGD_PORT_RX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  278. },
  279. { 1,
  280. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  281. AANC_FF_GAIN_ADAPTIVE, 0x4, WCD9335_REG_BITS, 0
  282. },
  283. { 1,
  284. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  285. AANC_FFGAIN_ADAPTIVE_EN, 0x8, WCD9335_REG_BITS, 0
  286. },
  287. {
  288. 1,
  289. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_FF_A_GAIN_CTL),
  290. AANC_GAIN_CONTROL, 0xFF, WCD9335_REG_BITS, 0
  291. },
  292. };
  293. static struct afe_param_cdc_reg_cfg_data tasha_audio_reg_cfg = {
  294. .num_registers = ARRAY_SIZE(audio_reg_cfg),
  295. .reg_data = audio_reg_cfg,
  296. };
  297. static struct afe_param_id_cdc_aanc_version tasha_cdc_aanc_version = {
  298. .cdc_aanc_minor_version = AFE_API_VERSION_CDC_AANC_VERSION,
  299. .aanc_hw_version = AANC_HW_BLOCK_VERSION_2,
  300. };
  301. enum {
  302. VI_SENSE_1,
  303. VI_SENSE_2,
  304. AIF4_SWITCH_VALUE,
  305. AUDIO_NOMINAL,
  306. CPE_NOMINAL,
  307. HPH_PA_DELAY,
  308. ANC_MIC_AMIC1,
  309. ANC_MIC_AMIC2,
  310. ANC_MIC_AMIC3,
  311. ANC_MIC_AMIC4,
  312. ANC_MIC_AMIC5,
  313. ANC_MIC_AMIC6,
  314. CLASSH_CONFIG,
  315. };
  316. enum {
  317. AIF1_PB = 0,
  318. AIF1_CAP,
  319. AIF2_PB,
  320. AIF2_CAP,
  321. AIF3_PB,
  322. AIF3_CAP,
  323. AIF4_PB,
  324. AIF_MIX1_PB,
  325. AIF4_MAD_TX,
  326. AIF4_VIFEED,
  327. AIF5_CPE_TX,
  328. NUM_CODEC_DAIS,
  329. };
  330. enum {
  331. INTn_1_MIX_INP_SEL_ZERO = 0,
  332. INTn_1_MIX_INP_SEL_DEC0,
  333. INTn_1_MIX_INP_SEL_DEC1,
  334. INTn_1_MIX_INP_SEL_IIR0,
  335. INTn_1_MIX_INP_SEL_IIR1,
  336. INTn_1_MIX_INP_SEL_RX0,
  337. INTn_1_MIX_INP_SEL_RX1,
  338. INTn_1_MIX_INP_SEL_RX2,
  339. INTn_1_MIX_INP_SEL_RX3,
  340. INTn_1_MIX_INP_SEL_RX4,
  341. INTn_1_MIX_INP_SEL_RX5,
  342. INTn_1_MIX_INP_SEL_RX6,
  343. INTn_1_MIX_INP_SEL_RX7,
  344. };
  345. #define IS_VALID_NATIVE_FIFO_PORT(inp) \
  346. ((inp >= INTn_1_MIX_INP_SEL_RX0) && \
  347. (inp <= INTn_1_MIX_INP_SEL_RX3))
  348. enum {
  349. INTn_2_INP_SEL_ZERO = 0,
  350. INTn_2_INP_SEL_RX0,
  351. INTn_2_INP_SEL_RX1,
  352. INTn_2_INP_SEL_RX2,
  353. INTn_2_INP_SEL_RX3,
  354. INTn_2_INP_SEL_RX4,
  355. INTn_2_INP_SEL_RX5,
  356. INTn_2_INP_SEL_RX6,
  357. INTn_2_INP_SEL_RX7,
  358. INTn_2_INP_SEL_PROXIMITY,
  359. };
  360. enum {
  361. INTERP_EAR = 0,
  362. INTERP_HPHL,
  363. INTERP_HPHR,
  364. INTERP_LO1,
  365. INTERP_LO2,
  366. INTERP_LO3,
  367. INTERP_LO4,
  368. INTERP_SPKR1,
  369. INTERP_SPKR2,
  370. };
  371. struct interp_sample_rate {
  372. int sample_rate;
  373. int rate_val;
  374. };
  375. static struct interp_sample_rate int_prim_sample_rate_val[] = {
  376. {8000, 0x0}, /* 8K */
  377. {16000, 0x1}, /* 16K */
  378. {24000, -EINVAL},/* 24K */
  379. {32000, 0x3}, /* 32K */
  380. {48000, 0x4}, /* 48K */
  381. {96000, 0x5}, /* 96K */
  382. {192000, 0x6}, /* 192K */
  383. {384000, 0x7}, /* 384K */
  384. {44100, 0x8}, /* 44.1K */
  385. };
  386. static struct interp_sample_rate int_mix_sample_rate_val[] = {
  387. {48000, 0x4}, /* 48K */
  388. {96000, 0x5}, /* 96K */
  389. {192000, 0x6}, /* 192K */
  390. };
  391. static const struct wcd9xxx_ch tasha_rx_chs[TASHA_RX_MAX] = {
  392. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER, 0),
  393. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 1, 1),
  394. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 2, 2),
  395. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 3, 3),
  396. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 4, 4),
  397. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 5, 5),
  398. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 6, 6),
  399. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 7, 7),
  400. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 8, 8),
  401. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 9, 9),
  402. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 10, 10),
  403. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 11, 11),
  404. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 12, 12),
  405. };
  406. static const struct wcd9xxx_ch tasha_tx_chs[TASHA_TX_MAX] = {
  407. WCD9XXX_CH(0, 0),
  408. WCD9XXX_CH(1, 1),
  409. WCD9XXX_CH(2, 2),
  410. WCD9XXX_CH(3, 3),
  411. WCD9XXX_CH(4, 4),
  412. WCD9XXX_CH(5, 5),
  413. WCD9XXX_CH(6, 6),
  414. WCD9XXX_CH(7, 7),
  415. WCD9XXX_CH(8, 8),
  416. WCD9XXX_CH(9, 9),
  417. WCD9XXX_CH(10, 10),
  418. WCD9XXX_CH(11, 11),
  419. WCD9XXX_CH(12, 12),
  420. WCD9XXX_CH(13, 13),
  421. WCD9XXX_CH(14, 14),
  422. WCD9XXX_CH(15, 15),
  423. };
  424. static const u32 vport_slim_check_table[NUM_CODEC_DAIS] = {
  425. /* Needs to define in the same order of DAI enum definitions */
  426. 0,
  427. BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  428. 0,
  429. BIT(AIF1_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  430. 0,
  431. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  432. 0,
  433. 0,
  434. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF5_CPE_TX),
  435. 0,
  436. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX),
  437. };
  438. static const u32 vport_i2s_check_table[NUM_CODEC_DAIS] = {
  439. 0, /* AIF1_PB */
  440. BIT(AIF2_CAP), /* AIF1_CAP */
  441. 0, /* AIF2_PB */
  442. BIT(AIF1_CAP), /* AIF2_CAP */
  443. };
  444. /* Codec supports 2 IIR filters */
  445. enum {
  446. IIR0 = 0,
  447. IIR1,
  448. IIR_MAX,
  449. };
  450. /* Each IIR has 5 Filter Stages */
  451. enum {
  452. BAND1 = 0,
  453. BAND2,
  454. BAND3,
  455. BAND4,
  456. BAND5,
  457. BAND_MAX,
  458. };
  459. enum {
  460. COMPANDER_1, /* HPH_L */
  461. COMPANDER_2, /* HPH_R */
  462. COMPANDER_3, /* LO1_DIFF */
  463. COMPANDER_4, /* LO2_DIFF */
  464. COMPANDER_5, /* LO3_SE */
  465. COMPANDER_6, /* LO4_SE */
  466. COMPANDER_7, /* SWR SPK CH1 */
  467. COMPANDER_8, /* SWR SPK CH2 */
  468. COMPANDER_MAX,
  469. };
  470. enum {
  471. SRC_IN_HPHL,
  472. SRC_IN_LO1,
  473. SRC_IN_HPHR,
  474. SRC_IN_LO2,
  475. SRC_IN_SPKRL,
  476. SRC_IN_LO3,
  477. SRC_IN_SPKRR,
  478. SRC_IN_LO4,
  479. };
  480. enum {
  481. SPLINE_SRC0,
  482. SPLINE_SRC1,
  483. SPLINE_SRC2,
  484. SPLINE_SRC3,
  485. SPLINE_SRC_MAX,
  486. };
  487. static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
  488. static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
  489. static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
  490. static struct snd_soc_dai_driver tasha_dai[];
  491. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv);
  492. static int tasha_config_compander(struct snd_soc_codec *, int, int);
  493. static void tasha_codec_set_tx_hold(struct snd_soc_codec *, u16, bool);
  494. static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
  495. bool enable);
  496. /* Hold instance to soundwire platform device */
  497. struct tasha_swr_ctrl_data {
  498. struct platform_device *swr_pdev;
  499. struct ida swr_ida;
  500. };
  501. struct wcd_swr_ctrl_platform_data {
  502. void *handle; /* holds codec private data */
  503. int (*read)(void *handle, int reg);
  504. int (*write)(void *handle, int reg, int val);
  505. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  506. int (*clk)(void *handle, bool enable);
  507. int (*handle_irq)(void *handle,
  508. irqreturn_t (*swrm_irq_handler)(int irq,
  509. void *data),
  510. void *swrm_handle,
  511. int action);
  512. };
  513. static struct wcd_mbhc_register
  514. wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = {
  515. WCD_MBHC_REGISTER("WCD_MBHC_L_DET_EN",
  516. WCD9335_ANA_MBHC_MECH, 0x80, 7, 0),
  517. WCD_MBHC_REGISTER("WCD_MBHC_GND_DET_EN",
  518. WCD9335_ANA_MBHC_MECH, 0x40, 6, 0),
  519. WCD_MBHC_REGISTER("WCD_MBHC_MECH_DETECTION_TYPE",
  520. WCD9335_ANA_MBHC_MECH, 0x20, 5, 0),
  521. WCD_MBHC_REGISTER("WCD_MBHC_MIC_CLAMP_CTL",
  522. WCD9335_MBHC_PLUG_DETECT_CTL, 0x30, 4, 0),
  523. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_DETECTION_TYPE",
  524. WCD9335_ANA_MBHC_ELECT, 0x08, 3, 0),
  525. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_CTRL",
  526. WCD9335_MBHC_PLUG_DETECT_CTL, 0xC0, 6, 0),
  527. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL",
  528. WCD9335_ANA_MBHC_MECH, 0x04, 2, 0),
  529. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PLUG_TYPE",
  530. WCD9335_ANA_MBHC_MECH, 0x10, 4, 0),
  531. WCD_MBHC_REGISTER("WCD_MBHC_GND_PLUG_TYPE",
  532. WCD9335_ANA_MBHC_MECH, 0x08, 3, 0),
  533. WCD_MBHC_REGISTER("WCD_MBHC_SW_HPH_LP_100K_TO_GND",
  534. WCD9335_ANA_MBHC_MECH, 0x01, 0, 0),
  535. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_SCHMT_ISRC",
  536. WCD9335_ANA_MBHC_ELECT, 0x06, 1, 0),
  537. WCD_MBHC_REGISTER("WCD_MBHC_FSM_EN",
  538. WCD9335_ANA_MBHC_ELECT, 0x80, 7, 0),
  539. WCD_MBHC_REGISTER("WCD_MBHC_INSREM_DBNC",
  540. WCD9335_MBHC_PLUG_DETECT_CTL, 0x0F, 0, 0),
  541. WCD_MBHC_REGISTER("WCD_MBHC_BTN_DBNC",
  542. WCD9335_MBHC_CTL_1, 0x03, 0, 0),
  543. WCD_MBHC_REGISTER("WCD_MBHC_HS_VREF",
  544. WCD9335_MBHC_CTL_2, 0x03, 0, 0),
  545. WCD_MBHC_REGISTER("WCD_MBHC_HS_COMP_RESULT",
  546. WCD9335_ANA_MBHC_RESULT_3, 0x08, 3, 0),
  547. WCD_MBHC_REGISTER("WCD_MBHC_MIC_SCHMT_RESULT",
  548. WCD9335_ANA_MBHC_RESULT_3, 0x20, 5, 0),
  549. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_SCHMT_RESULT",
  550. WCD9335_ANA_MBHC_RESULT_3, 0x80, 7, 0),
  551. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_SCHMT_RESULT",
  552. WCD9335_ANA_MBHC_RESULT_3, 0x40, 6, 0),
  553. WCD_MBHC_REGISTER("WCD_MBHC_OCP_FSM_EN",
  554. WCD9335_HPH_OCP_CTL, 0x10, 4, 0),
  555. WCD_MBHC_REGISTER("WCD_MBHC_BTN_RESULT",
  556. WCD9335_ANA_MBHC_RESULT_3, 0x07, 0, 0),
  557. WCD_MBHC_REGISTER("WCD_MBHC_BTN_ISRC_CTL",
  558. WCD9335_ANA_MBHC_ELECT, 0x70, 4, 0),
  559. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_RESULT",
  560. WCD9335_ANA_MBHC_RESULT_3, 0xFF, 0, 0),
  561. WCD_MBHC_REGISTER("WCD_MBHC_MICB_CTRL",
  562. WCD9335_ANA_MICB2, 0xC0, 6, 0),
  563. WCD_MBHC_REGISTER("WCD_MBHC_HPH_CNP_WG_TIME",
  564. WCD9335_HPH_CNP_WG_TIME, 0xFF, 0, 0),
  565. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_PA_EN",
  566. WCD9335_ANA_HPH, 0x40, 6, 0),
  567. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PA_EN",
  568. WCD9335_ANA_HPH, 0x80, 7, 0),
  569. WCD_MBHC_REGISTER("WCD_MBHC_HPH_PA_EN",
  570. WCD9335_ANA_HPH, 0xC0, 6, 0),
  571. WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE",
  572. WCD9335_ANA_MBHC_RESULT_3, 0x10, 4, 0),
  573. WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL",
  574. 0, 0, 0, 0),
  575. WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN",
  576. WCD9335_ANA_MBHC_ZDET, 0x01, 0, 0),
  577. /*
  578. * MBHC FSM status register is only available in Tasha 2.0.
  579. * So, init with 0 later once the version is known, then values
  580. * will be updated.
  581. */
  582. WCD_MBHC_REGISTER("WCD_MBHC_FSM_STATUS",
  583. 0, 0, 0, 0),
  584. WCD_MBHC_REGISTER("WCD_MBHC_MUX_CTL",
  585. WCD9335_MBHC_CTL_2, 0x70, 4, 0),
  586. WCD_MBHC_REGISTER("WCD_MBHC_MOISTURE_STATUS",
  587. WCD9335_MBHC_FSM_STATUS, 0X20, 5, 0),
  588. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_GND",
  589. WCD9335_HPH_PA_CTL2, 0x40, 6, 0),
  590. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_GND",
  591. WCD9335_HPH_PA_CTL2, 0x10, 4, 0),
  592. };
  593. static const struct wcd_mbhc_intr intr_ids = {
  594. .mbhc_sw_intr = WCD9335_IRQ_MBHC_SW_DET,
  595. .mbhc_btn_press_intr = WCD9335_IRQ_MBHC_BUTTON_PRESS_DET,
  596. .mbhc_btn_release_intr = WCD9335_IRQ_MBHC_BUTTON_RELEASE_DET,
  597. .mbhc_hs_ins_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
  598. .mbhc_hs_rem_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_DET,
  599. .hph_left_ocp = WCD9335_IRQ_HPH_PA_OCPL_FAULT,
  600. .hph_right_ocp = WCD9335_IRQ_HPH_PA_OCPR_FAULT,
  601. };
  602. struct wcd_vbat {
  603. bool is_enabled;
  604. bool adc_config;
  605. /* Variables to cache Vbat ADC output values */
  606. u16 dcp1;
  607. u16 dcp2;
  608. };
  609. struct hpf_work {
  610. struct tasha_priv *tasha;
  611. u8 decimator;
  612. u8 hpf_cut_off_freq;
  613. struct delayed_work dwork;
  614. };
  615. #define WCD9335_SPK_ANC_EN_DELAY_MS 350
  616. static int spk_anc_en_delay = WCD9335_SPK_ANC_EN_DELAY_MS;
  617. module_param(spk_anc_en_delay, int, 0664);
  618. MODULE_PARM_DESC(spk_anc_en_delay, "delay to enable anc in speaker path");
  619. struct spk_anc_work {
  620. struct tasha_priv *tasha;
  621. struct delayed_work dwork;
  622. };
  623. struct tx_mute_work {
  624. struct tasha_priv *tasha;
  625. u8 decimator;
  626. struct delayed_work dwork;
  627. };
  628. struct tasha_priv {
  629. struct device *dev;
  630. struct wcd9xxx *wcd9xxx;
  631. struct snd_soc_codec *codec;
  632. u32 adc_count;
  633. u32 rx_bias_count;
  634. s32 dmic_0_1_clk_cnt;
  635. s32 dmic_2_3_clk_cnt;
  636. s32 dmic_4_5_clk_cnt;
  637. s32 ldo_h_users;
  638. s32 micb_ref[TASHA_MAX_MICBIAS];
  639. s32 pullup_ref[TASHA_MAX_MICBIAS];
  640. u32 anc_slot;
  641. bool anc_func;
  642. /* Vbat module */
  643. struct wcd_vbat vbat;
  644. /* cal info for codec */
  645. struct fw_info *fw_data;
  646. /*track tasha interface type*/
  647. u8 intf_type;
  648. /* num of slim ports required */
  649. struct wcd9xxx_codec_dai_data dai[NUM_CODEC_DAIS];
  650. /* SoundWire data structure */
  651. struct tasha_swr_ctrl_data *swr_ctrl_data;
  652. int nr;
  653. /*compander*/
  654. int comp_enabled[COMPANDER_MAX];
  655. /* Maintain the status of AUX PGA */
  656. int aux_pga_cnt;
  657. u8 aux_l_gain;
  658. u8 aux_r_gain;
  659. bool spkr_pa_widget_on;
  660. struct regulator *spkdrv_reg;
  661. struct regulator *spkdrv2_reg;
  662. bool mbhc_started;
  663. /* class h specific data */
  664. struct wcd_clsh_cdc_data clsh_d;
  665. struct afe_param_cdc_slimbus_slave_cfg slimbus_slave_cfg;
  666. /*
  667. * list used to save/restore registers at start and
  668. * end of impedance measurement
  669. */
  670. struct list_head reg_save_restore;
  671. /* handle to cpe core */
  672. struct wcd_cpe_core *cpe_core;
  673. u32 current_cpe_clk_freq;
  674. enum tasha_sido_voltage sido_voltage;
  675. int sido_ccl_cnt;
  676. u32 ana_rx_supplies;
  677. /* Multiplication factor used for impedance detection */
  678. int zdet_gain_mul_fact;
  679. /* to track the status */
  680. unsigned long status_mask;
  681. struct work_struct tasha_add_child_devices_work;
  682. struct wcd_swr_ctrl_platform_data swr_plat_data;
  683. /* Port values for Rx and Tx codec_dai */
  684. unsigned int rx_port_value[TASHA_RX_MAX];
  685. unsigned int tx_port_value;
  686. unsigned int vi_feed_value;
  687. /* Tasha Interpolator Mode Select for EAR, HPH_L and HPH_R */
  688. u32 hph_mode;
  689. u16 prim_int_users[TASHA_NUM_INTERPOLATORS];
  690. int spl_src_users[SPLINE_SRC_MAX];
  691. struct wcd9xxx_resmgr_v2 *resmgr;
  692. struct delayed_work power_gate_work;
  693. struct mutex power_lock;
  694. struct mutex sido_lock;
  695. /* mbhc module */
  696. struct wcd_mbhc mbhc;
  697. struct blocking_notifier_head notifier;
  698. struct mutex micb_lock;
  699. struct clk *wcd_ext_clk;
  700. struct clk *wcd_native_clk;
  701. struct mutex swr_read_lock;
  702. struct mutex swr_write_lock;
  703. struct mutex swr_clk_lock;
  704. int swr_clk_users;
  705. int native_clk_users;
  706. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high);
  707. struct snd_info_entry *entry;
  708. struct snd_info_entry *version_entry;
  709. int power_active_ref;
  710. struct on_demand_supply on_demand_list[ON_DEMAND_SUPPLIES_MAX];
  711. int (*machine_codec_event_cb)(struct snd_soc_codec *codec,
  712. enum wcd9335_codec_event);
  713. int spkr_gain_offset;
  714. int spkr_mode;
  715. int ear_spkr_gain;
  716. struct hpf_work tx_hpf_work[TASHA_NUM_DECIMATORS];
  717. struct tx_mute_work tx_mute_dwork[TASHA_NUM_DECIMATORS];
  718. struct spk_anc_work spk_anc_dwork;
  719. struct mutex codec_mutex;
  720. int hph_l_gain;
  721. int hph_r_gain;
  722. int rx_7_count;
  723. int rx_8_count;
  724. bool clk_mode;
  725. bool clk_internal;
  726. /* Lock to prevent multiple functions voting at same time */
  727. struct mutex sb_clk_gear_lock;
  728. /* Count for functions voting or un-voting */
  729. u32 ref_count;
  730. /* Lock to protect mclk enablement */
  731. struct mutex mclk_lock;
  732. };
  733. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  734. bool vote);
  735. static const struct tasha_reg_mask_val tasha_spkr_default[] = {
  736. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  737. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  738. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  739. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  740. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x50},
  741. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x50},
  742. };
  743. static const struct tasha_reg_mask_val tasha_spkr_mode1[] = {
  744. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x00},
  745. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x00},
  746. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x00},
  747. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x00},
  748. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x44},
  749. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x44},
  750. };
  751. /**
  752. * tasha_set_spkr_gain_offset - offset the speaker path
  753. * gain with the given offset value.
  754. *
  755. * @codec: codec instance
  756. * @offset: Indicates speaker path gain offset value.
  757. *
  758. * Returns 0 on success or -EINVAL on error.
  759. */
  760. int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
  761. {
  762. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  763. if (!priv)
  764. return -EINVAL;
  765. priv->spkr_gain_offset = offset;
  766. return 0;
  767. }
  768. EXPORT_SYMBOL(tasha_set_spkr_gain_offset);
  769. /**
  770. * tasha_set_spkr_mode - Configures speaker compander and smartboost
  771. * settings based on speaker mode.
  772. *
  773. * @codec: codec instance
  774. * @mode: Indicates speaker configuration mode.
  775. *
  776. * Returns 0 on success or -EINVAL on error.
  777. */
  778. int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode)
  779. {
  780. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  781. int i;
  782. const struct tasha_reg_mask_val *regs;
  783. int size;
  784. if (!priv)
  785. return -EINVAL;
  786. switch (mode) {
  787. case SPKR_MODE_1:
  788. regs = tasha_spkr_mode1;
  789. size = ARRAY_SIZE(tasha_spkr_mode1);
  790. break;
  791. default:
  792. regs = tasha_spkr_default;
  793. size = ARRAY_SIZE(tasha_spkr_default);
  794. break;
  795. }
  796. priv->spkr_mode = mode;
  797. for (i = 0; i < size; i++)
  798. snd_soc_update_bits(codec, regs[i].reg,
  799. regs[i].mask, regs[i].val);
  800. return 0;
  801. }
  802. EXPORT_SYMBOL(tasha_set_spkr_mode);
  803. static void tasha_enable_sido_buck(struct snd_soc_codec *codec)
  804. {
  805. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  806. snd_soc_update_bits(codec, WCD9335_ANA_RCO, 0x80, 0x80);
  807. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x02, 0x02);
  808. /* 100us sleep needed after IREF settings */
  809. usleep_range(100, 110);
  810. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x04, 0x04);
  811. /* 100us sleep needed after VREF settings */
  812. usleep_range(100, 110);
  813. tasha->resmgr->sido_input_src = SIDO_SOURCE_RCO_BG;
  814. }
  815. static void tasha_cdc_sido_ccl_enable(struct tasha_priv *tasha, bool ccl_flag)
  816. {
  817. struct snd_soc_codec *codec = tasha->codec;
  818. if (!codec)
  819. return;
  820. if (!TASHA_IS_2_0(tasha->wcd9xxx)) {
  821. dev_dbg(codec->dev, "%s: tasha version < 2p0, return\n",
  822. __func__);
  823. return;
  824. }
  825. dev_dbg(codec->dev, "%s: sido_ccl_cnt=%d, ccl_flag:%d\n",
  826. __func__, tasha->sido_ccl_cnt, ccl_flag);
  827. if (ccl_flag) {
  828. if (++tasha->sido_ccl_cnt == 1)
  829. snd_soc_update_bits(codec,
  830. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x6E);
  831. } else {
  832. if (tasha->sido_ccl_cnt == 0) {
  833. dev_dbg(codec->dev, "%s: sido_ccl already disabled\n",
  834. __func__);
  835. return;
  836. }
  837. if (--tasha->sido_ccl_cnt == 0)
  838. snd_soc_update_bits(codec,
  839. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x02);
  840. }
  841. }
  842. static bool tasha_cdc_is_svs_enabled(struct tasha_priv *tasha)
  843. {
  844. if (TASHA_IS_2_0(tasha->wcd9xxx) &&
  845. svs_scaling_enabled)
  846. return true;
  847. return false;
  848. }
  849. static int tasha_cdc_req_mclk_enable(struct tasha_priv *tasha,
  850. bool enable)
  851. {
  852. int ret = 0;
  853. mutex_lock(&tasha->mclk_lock);
  854. if (enable) {
  855. tasha_cdc_sido_ccl_enable(tasha, true);
  856. ret = clk_prepare_enable(tasha->wcd_ext_clk);
  857. if (ret) {
  858. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  859. __func__);
  860. goto unlock_mutex;
  861. }
  862. /* get BG */
  863. wcd_resmgr_enable_master_bias(tasha->resmgr);
  864. /* get MCLK */
  865. wcd_resmgr_enable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  866. } else {
  867. /* put MCLK */
  868. wcd_resmgr_disable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  869. /* put BG */
  870. wcd_resmgr_disable_master_bias(tasha->resmgr);
  871. clk_disable_unprepare(tasha->wcd_ext_clk);
  872. tasha_cdc_sido_ccl_enable(tasha, false);
  873. }
  874. unlock_mutex:
  875. mutex_unlock(&tasha->mclk_lock);
  876. return ret;
  877. }
  878. static int tasha_cdc_check_sido_value(enum tasha_sido_voltage req_mv)
  879. {
  880. if ((req_mv != SIDO_VOLTAGE_SVS_MV) &&
  881. (req_mv != SIDO_VOLTAGE_NOMINAL_MV))
  882. return -EINVAL;
  883. return 0;
  884. }
  885. static void tasha_codec_apply_sido_voltage(
  886. struct tasha_priv *tasha,
  887. enum tasha_sido_voltage req_mv)
  888. {
  889. u32 vout_d_val;
  890. struct snd_soc_codec *codec = tasha->codec;
  891. int ret;
  892. if (!codec)
  893. return;
  894. if (!tasha_cdc_is_svs_enabled(tasha))
  895. return;
  896. if ((sido_buck_svs_voltage != SIDO_VOLTAGE_SVS_MV) &&
  897. (sido_buck_svs_voltage != SIDO_VOLTAGE_NOMINAL_MV))
  898. sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  899. ret = tasha_cdc_check_sido_value(req_mv);
  900. if (ret < 0) {
  901. dev_dbg(codec->dev, "%s: requested mv=%d not in range\n",
  902. __func__, req_mv);
  903. return;
  904. }
  905. if (req_mv == tasha->sido_voltage) {
  906. dev_dbg(codec->dev, "%s: Already at requested mv=%d\n",
  907. __func__, req_mv);
  908. return;
  909. }
  910. if (req_mv == sido_buck_svs_voltage) {
  911. if (test_bit(AUDIO_NOMINAL, &tasha->status_mask) ||
  912. test_bit(CPE_NOMINAL, &tasha->status_mask)) {
  913. dev_dbg(codec->dev,
  914. "%s: nominal client running, status_mask=%lu\n",
  915. __func__, tasha->status_mask);
  916. return;
  917. }
  918. }
  919. /* compute the vout_d step value */
  920. vout_d_val = CALCULATE_VOUT_D(req_mv);
  921. snd_soc_write(codec, WCD9335_ANA_BUCK_VOUT_D, vout_d_val & 0xFF);
  922. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x80, 0x80);
  923. /* 1 msec sleep required after SIDO Vout_D voltage change */
  924. usleep_range(1000, 1100);
  925. tasha->sido_voltage = req_mv;
  926. dev_dbg(codec->dev,
  927. "%s: updated SIDO buck Vout_D to %d, vout_d step = %u\n",
  928. __func__, tasha->sido_voltage, vout_d_val);
  929. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL,
  930. 0x80, 0x00);
  931. }
  932. static int tasha_codec_update_sido_voltage(
  933. struct tasha_priv *tasha,
  934. enum tasha_sido_voltage req_mv)
  935. {
  936. int ret = 0;
  937. if (!tasha_cdc_is_svs_enabled(tasha))
  938. return ret;
  939. mutex_lock(&tasha->sido_lock);
  940. /* enable mclk before setting SIDO voltage */
  941. ret = tasha_cdc_req_mclk_enable(tasha, true);
  942. if (ret) {
  943. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  944. __func__);
  945. goto err;
  946. }
  947. tasha_codec_apply_sido_voltage(tasha, req_mv);
  948. tasha_cdc_req_mclk_enable(tasha, false);
  949. err:
  950. mutex_unlock(&tasha->sido_lock);
  951. return ret;
  952. }
  953. int tasha_enable_efuse_sensing(struct snd_soc_codec *codec)
  954. {
  955. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  956. tasha_cdc_mclk_enable(codec, true, false);
  957. if (!TASHA_IS_2_0(priv->wcd9xxx))
  958. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  959. 0x1E, 0x02);
  960. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  961. 0x01, 0x01);
  962. /*
  963. * 5ms sleep required after enabling efuse control
  964. * before checking the status.
  965. */
  966. usleep_range(5000, 5500);
  967. if (!(snd_soc_read(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01))
  968. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  969. if (TASHA_IS_2_0(priv->wcd9xxx)) {
  970. if (!(snd_soc_read(codec,
  971. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0) & 0x40))
  972. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST,
  973. 0x04, 0x00);
  974. tasha_enable_sido_buck(codec);
  975. }
  976. tasha_cdc_mclk_enable(codec, false, false);
  977. return 0;
  978. }
  979. EXPORT_SYMBOL(tasha_enable_efuse_sensing);
  980. void *tasha_get_afe_config(struct snd_soc_codec *codec,
  981. enum afe_config_type config_type)
  982. {
  983. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  984. switch (config_type) {
  985. case AFE_SLIMBUS_SLAVE_CONFIG:
  986. return &priv->slimbus_slave_cfg;
  987. case AFE_CDC_REGISTERS_CONFIG:
  988. return &tasha_audio_reg_cfg;
  989. case AFE_SLIMBUS_SLAVE_PORT_CONFIG:
  990. return &tasha_slimbus_slave_port_cfg;
  991. case AFE_AANC_VERSION:
  992. return &tasha_cdc_aanc_version;
  993. case AFE_CLIP_BANK_SEL:
  994. return NULL;
  995. case AFE_CDC_CLIP_REGISTERS_CONFIG:
  996. return NULL;
  997. case AFE_CDC_REGISTER_PAGE_CONFIG:
  998. return &tasha_cdc_reg_page_cfg;
  999. default:
  1000. dev_err(codec->dev, "%s: Unknown config_type 0x%x\n",
  1001. __func__, config_type);
  1002. return NULL;
  1003. }
  1004. }
  1005. EXPORT_SYMBOL(tasha_get_afe_config);
  1006. /*
  1007. * tasha_event_register: Registers a machine driver callback
  1008. * function with codec private data for post ADSP sub-system
  1009. * restart (SSR). This callback function will be called from
  1010. * codec driver once codec comes out of reset after ADSP SSR.
  1011. *
  1012. * @machine_event_cb: callback function from machine driver
  1013. * @codec: Codec instance
  1014. *
  1015. * Return: none
  1016. */
  1017. void tasha_event_register(
  1018. int (*machine_event_cb)(struct snd_soc_codec *codec,
  1019. enum wcd9335_codec_event),
  1020. struct snd_soc_codec *codec)
  1021. {
  1022. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1023. if (tasha)
  1024. tasha->machine_codec_event_cb = machine_event_cb;
  1025. else
  1026. dev_dbg(codec->dev, "%s: Invalid tasha_priv data\n", __func__);
  1027. }
  1028. EXPORT_SYMBOL(tasha_event_register);
  1029. static int tasha_mbhc_request_irq(struct snd_soc_codec *codec,
  1030. int irq, irq_handler_t handler,
  1031. const char *name, void *data)
  1032. {
  1033. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1034. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1035. struct wcd9xxx_core_resource *core_res =
  1036. &wcd9xxx->core_res;
  1037. return wcd9xxx_request_irq(core_res, irq, handler, name, data);
  1038. }
  1039. static void tasha_mbhc_irq_control(struct snd_soc_codec *codec,
  1040. int irq, bool enable)
  1041. {
  1042. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1043. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1044. struct wcd9xxx_core_resource *core_res =
  1045. &wcd9xxx->core_res;
  1046. if (enable)
  1047. wcd9xxx_enable_irq(core_res, irq);
  1048. else
  1049. wcd9xxx_disable_irq(core_res, irq);
  1050. }
  1051. static int tasha_mbhc_free_irq(struct snd_soc_codec *codec,
  1052. int irq, void *data)
  1053. {
  1054. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1055. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1056. struct wcd9xxx_core_resource *core_res =
  1057. &wcd9xxx->core_res;
  1058. wcd9xxx_free_irq(core_res, irq, data);
  1059. return 0;
  1060. }
  1061. static void tasha_mbhc_clk_setup(struct snd_soc_codec *codec,
  1062. bool enable)
  1063. {
  1064. if (enable)
  1065. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1066. 0x80, 0x80);
  1067. else
  1068. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1069. 0x80, 0x00);
  1070. }
  1071. static int tasha_mbhc_btn_to_num(struct snd_soc_codec *codec)
  1072. {
  1073. return snd_soc_read(codec, WCD9335_ANA_MBHC_RESULT_3) & 0x7;
  1074. }
  1075. static void tasha_mbhc_mbhc_bias_control(struct snd_soc_codec *codec,
  1076. bool enable)
  1077. {
  1078. if (enable)
  1079. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1080. 0x01, 0x01);
  1081. else
  1082. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1083. 0x01, 0x00);
  1084. }
  1085. static void tasha_mbhc_program_btn_thr(struct snd_soc_codec *codec,
  1086. s16 *btn_low, s16 *btn_high,
  1087. int num_btn, bool is_micbias)
  1088. {
  1089. int i;
  1090. int vth;
  1091. if (num_btn > WCD_MBHC_DEF_BUTTONS) {
  1092. dev_err(codec->dev, "%s: invalid number of buttons: %d\n",
  1093. __func__, num_btn);
  1094. return;
  1095. }
  1096. /*
  1097. * Tasha just needs one set of thresholds for button detection
  1098. * due to micbias voltage ramp to pullup upon button press. So
  1099. * btn_low and is_micbias are ignored and always program button
  1100. * thresholds using btn_high.
  1101. */
  1102. for (i = 0; i < num_btn; i++) {
  1103. vth = ((btn_high[i] * 2) / 25) & 0x3F;
  1104. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN0 + i,
  1105. 0xFC, vth << 2);
  1106. dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
  1107. __func__, i, btn_high[i], vth);
  1108. }
  1109. }
  1110. static bool tasha_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
  1111. {
  1112. struct snd_soc_codec *codec = mbhc->codec;
  1113. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1114. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1115. struct wcd9xxx_core_resource *core_res =
  1116. &wcd9xxx->core_res;
  1117. if (lock)
  1118. return wcd9xxx_lock_sleep(core_res);
  1119. else {
  1120. wcd9xxx_unlock_sleep(core_res);
  1121. return 0;
  1122. }
  1123. }
  1124. static int tasha_mbhc_register_notifier(struct wcd_mbhc *mbhc,
  1125. struct notifier_block *nblock,
  1126. bool enable)
  1127. {
  1128. struct snd_soc_codec *codec = mbhc->codec;
  1129. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1130. if (enable)
  1131. return blocking_notifier_chain_register(&tasha->notifier,
  1132. nblock);
  1133. else
  1134. return blocking_notifier_chain_unregister(&tasha->notifier,
  1135. nblock);
  1136. }
  1137. static bool tasha_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
  1138. {
  1139. u8 val;
  1140. if (micb_num == MIC_BIAS_2) {
  1141. val = (snd_soc_read(mbhc->codec, WCD9335_ANA_MICB2) >> 6);
  1142. if (val == 0x01)
  1143. return true;
  1144. }
  1145. return false;
  1146. }
  1147. static bool tasha_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
  1148. {
  1149. return (snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0) ? true : false;
  1150. }
  1151. static void tasha_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec,
  1152. enum mbhc_hs_pullup_iref pull_up_cur)
  1153. {
  1154. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1155. if (!tasha)
  1156. return;
  1157. /* Default pull up current to 2uA */
  1158. if (pull_up_cur < I_OFF || pull_up_cur > I_3P0_UA ||
  1159. pull_up_cur == I_DEFAULT)
  1160. pull_up_cur = I_2P0_UA;
  1161. dev_dbg(codec->dev, "%s: HS pull up current:%d\n",
  1162. __func__, pull_up_cur);
  1163. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1164. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1165. 0xC0, pull_up_cur << 6);
  1166. else
  1167. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1168. 0xC0, 0x40);
  1169. }
  1170. static int tasha_enable_ext_mb_source(struct wcd_mbhc *mbhc,
  1171. bool turn_on)
  1172. {
  1173. struct snd_soc_codec *codec = mbhc->codec;
  1174. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1175. int ret = 0;
  1176. struct on_demand_supply *supply;
  1177. if (!tasha)
  1178. return -EINVAL;
  1179. supply = &tasha->on_demand_list[ON_DEMAND_MICBIAS];
  1180. if (!supply->supply) {
  1181. dev_dbg(codec->dev, "%s: warning supply not present ond for %s\n",
  1182. __func__, "onDemand Micbias");
  1183. return ret;
  1184. }
  1185. dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
  1186. supply->ondemand_supply_count);
  1187. if (turn_on) {
  1188. if (!(supply->ondemand_supply_count)) {
  1189. ret = snd_soc_dapm_force_enable_pin(
  1190. snd_soc_codec_get_dapm(codec),
  1191. "MICBIAS_REGULATOR");
  1192. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1193. }
  1194. supply->ondemand_supply_count++;
  1195. } else {
  1196. if (supply->ondemand_supply_count > 0)
  1197. supply->ondemand_supply_count--;
  1198. if (!(supply->ondemand_supply_count)) {
  1199. ret = snd_soc_dapm_disable_pin(
  1200. snd_soc_codec_get_dapm(codec),
  1201. "MICBIAS_REGULATOR");
  1202. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1203. }
  1204. }
  1205. if (ret)
  1206. dev_err(codec->dev, "%s: Failed to %s external micbias source\n",
  1207. __func__, turn_on ? "enable" : "disabled");
  1208. else
  1209. dev_dbg(codec->dev, "%s: %s external micbias source\n",
  1210. __func__, turn_on ? "Enabled" : "Disabled");
  1211. return ret;
  1212. }
  1213. static int tasha_micbias_control(struct snd_soc_codec *codec,
  1214. int micb_num,
  1215. int req, bool is_dapm)
  1216. {
  1217. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1218. int micb_index = micb_num - 1;
  1219. u16 micb_reg;
  1220. int pre_off_event = 0, post_off_event = 0;
  1221. int post_on_event = 0, post_dapm_off = 0;
  1222. int post_dapm_on = 0;
  1223. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  1224. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  1225. __func__, micb_index);
  1226. return -EINVAL;
  1227. }
  1228. switch (micb_num) {
  1229. case MIC_BIAS_1:
  1230. micb_reg = WCD9335_ANA_MICB1;
  1231. break;
  1232. case MIC_BIAS_2:
  1233. micb_reg = WCD9335_ANA_MICB2;
  1234. pre_off_event = WCD_EVENT_PRE_MICBIAS_2_OFF;
  1235. post_off_event = WCD_EVENT_POST_MICBIAS_2_OFF;
  1236. post_on_event = WCD_EVENT_POST_MICBIAS_2_ON;
  1237. post_dapm_on = WCD_EVENT_POST_DAPM_MICBIAS_2_ON;
  1238. post_dapm_off = WCD_EVENT_POST_DAPM_MICBIAS_2_OFF;
  1239. break;
  1240. case MIC_BIAS_3:
  1241. micb_reg = WCD9335_ANA_MICB3;
  1242. break;
  1243. case MIC_BIAS_4:
  1244. micb_reg = WCD9335_ANA_MICB4;
  1245. break;
  1246. default:
  1247. dev_err(codec->dev, "%s: Invalid micbias number: %d\n",
  1248. __func__, micb_num);
  1249. return -EINVAL;
  1250. }
  1251. mutex_lock(&tasha->micb_lock);
  1252. switch (req) {
  1253. case MICB_PULLUP_ENABLE:
  1254. tasha->pullup_ref[micb_index]++;
  1255. if ((tasha->pullup_ref[micb_index] == 1) &&
  1256. (tasha->micb_ref[micb_index] == 0))
  1257. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1258. break;
  1259. case MICB_PULLUP_DISABLE:
  1260. if (tasha->pullup_ref[micb_index] > 0)
  1261. tasha->pullup_ref[micb_index]--;
  1262. if ((tasha->pullup_ref[micb_index] == 0) &&
  1263. (tasha->micb_ref[micb_index] == 0))
  1264. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1265. break;
  1266. case MICB_ENABLE:
  1267. tasha->micb_ref[micb_index]++;
  1268. if (tasha->micb_ref[micb_index] == 1) {
  1269. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1270. if (post_on_event)
  1271. blocking_notifier_call_chain(&tasha->notifier,
  1272. post_on_event, &tasha->mbhc);
  1273. }
  1274. if (is_dapm && post_dapm_on)
  1275. blocking_notifier_call_chain(&tasha->notifier,
  1276. post_dapm_on, &tasha->mbhc);
  1277. break;
  1278. case MICB_DISABLE:
  1279. if (tasha->micb_ref[micb_index] > 0)
  1280. tasha->micb_ref[micb_index]--;
  1281. if ((tasha->micb_ref[micb_index] == 0) &&
  1282. (tasha->pullup_ref[micb_index] > 0))
  1283. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1284. else if ((tasha->micb_ref[micb_index] == 0) &&
  1285. (tasha->pullup_ref[micb_index] == 0)) {
  1286. if (pre_off_event)
  1287. blocking_notifier_call_chain(&tasha->notifier,
  1288. pre_off_event, &tasha->mbhc);
  1289. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1290. if (post_off_event)
  1291. blocking_notifier_call_chain(&tasha->notifier,
  1292. post_off_event, &tasha->mbhc);
  1293. }
  1294. if (is_dapm && post_dapm_off)
  1295. blocking_notifier_call_chain(&tasha->notifier,
  1296. post_dapm_off, &tasha->mbhc);
  1297. break;
  1298. };
  1299. dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n",
  1300. __func__, micb_num, tasha->micb_ref[micb_index],
  1301. tasha->pullup_ref[micb_index]);
  1302. mutex_unlock(&tasha->micb_lock);
  1303. return 0;
  1304. }
  1305. static int tasha_mbhc_request_micbias(struct snd_soc_codec *codec,
  1306. int micb_num, int req)
  1307. {
  1308. int ret;
  1309. /*
  1310. * If micbias is requested, make sure that there
  1311. * is vote to enable mclk
  1312. */
  1313. if (req == MICB_ENABLE)
  1314. tasha_cdc_mclk_enable(codec, true, false);
  1315. ret = tasha_micbias_control(codec, micb_num, req, false);
  1316. /*
  1317. * Release vote for mclk while requesting for
  1318. * micbias disable
  1319. */
  1320. if (req == MICB_DISABLE)
  1321. tasha_cdc_mclk_enable(codec, false, false);
  1322. return ret;
  1323. }
  1324. static void tasha_mbhc_micb_ramp_control(struct snd_soc_codec *codec,
  1325. bool enable)
  1326. {
  1327. if (enable) {
  1328. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1329. 0x1C, 0x0C);
  1330. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1331. 0x80, 0x80);
  1332. } else {
  1333. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1334. 0x80, 0x00);
  1335. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1336. 0x1C, 0x00);
  1337. }
  1338. }
  1339. static struct firmware_cal *tasha_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
  1340. enum wcd_cal_type type)
  1341. {
  1342. struct tasha_priv *tasha;
  1343. struct firmware_cal *hwdep_cal;
  1344. struct snd_soc_codec *codec = mbhc->codec;
  1345. if (!codec) {
  1346. pr_err("%s: NULL codec pointer\n", __func__);
  1347. return NULL;
  1348. }
  1349. tasha = snd_soc_codec_get_drvdata(codec);
  1350. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, type);
  1351. if (!hwdep_cal)
  1352. dev_err(codec->dev, "%s: cal not sent by %d\n",
  1353. __func__, type);
  1354. return hwdep_cal;
  1355. }
  1356. static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
  1357. int req_volt,
  1358. int micb_num)
  1359. {
  1360. int cur_vout_ctl, req_vout_ctl;
  1361. int micb_reg, micb_val, micb_en;
  1362. switch (micb_num) {
  1363. case MIC_BIAS_1:
  1364. micb_reg = WCD9335_ANA_MICB1;
  1365. break;
  1366. case MIC_BIAS_2:
  1367. micb_reg = WCD9335_ANA_MICB2;
  1368. break;
  1369. case MIC_BIAS_3:
  1370. micb_reg = WCD9335_ANA_MICB3;
  1371. break;
  1372. case MIC_BIAS_4:
  1373. micb_reg = WCD9335_ANA_MICB4;
  1374. break;
  1375. default:
  1376. return -EINVAL;
  1377. }
  1378. /*
  1379. * If requested micbias voltage is same as current micbias
  1380. * voltage, then just return. Otherwise, adjust voltage as
  1381. * per requested value. If micbias is already enabled, then
  1382. * to avoid slow micbias ramp-up or down enable pull-up
  1383. * momentarily, change the micbias value and then re-enable
  1384. * micbias.
  1385. */
  1386. micb_val = snd_soc_read(codec, micb_reg);
  1387. micb_en = (micb_val & 0xC0) >> 6;
  1388. cur_vout_ctl = micb_val & 0x3F;
  1389. req_vout_ctl = wcd9335_get_micb_vout_ctl_val(req_volt);
  1390. if (req_vout_ctl < 0)
  1391. return -EINVAL;
  1392. if (cur_vout_ctl == req_vout_ctl)
  1393. return 0;
  1394. dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n",
  1395. __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl),
  1396. req_volt, micb_en);
  1397. if (micb_en == 0x1)
  1398. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1399. snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl);
  1400. if (micb_en == 0x1) {
  1401. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1402. /*
  1403. * Add 2ms delay as per HW requirement after enabling
  1404. * micbias
  1405. */
  1406. usleep_range(2000, 2100);
  1407. }
  1408. return 0;
  1409. }
  1410. static int tasha_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
  1411. int micb_num, bool req_en)
  1412. {
  1413. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1414. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  1415. int rc, micb_mv;
  1416. if (micb_num != MIC_BIAS_2)
  1417. return -EINVAL;
  1418. /*
  1419. * If device tree micbias level is already above the minimum
  1420. * voltage needed to detect threshold microphone, then do
  1421. * not change the micbias, just return.
  1422. */
  1423. if (pdata->micbias.micb2_mv >= WCD_MBHC_THR_HS_MICB_MV)
  1424. return 0;
  1425. micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv;
  1426. mutex_lock(&tasha->micb_lock);
  1427. rc = tasha_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2);
  1428. mutex_unlock(&tasha->micb_lock);
  1429. return rc;
  1430. }
  1431. static inline void tasha_mbhc_get_result_params(struct wcd9xxx *wcd9xxx,
  1432. s16 *d1_a, u16 noff,
  1433. int32_t *zdet)
  1434. {
  1435. int i;
  1436. int val, val1;
  1437. s16 c1;
  1438. s32 x1, d1;
  1439. int32_t denom;
  1440. int minCode_param[] = {
  1441. 3277, 1639, 820, 410, 205, 103, 52, 26
  1442. };
  1443. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x20);
  1444. for (i = 0; i < TASHA_ZDET_NUM_MEASUREMENTS; i++) {
  1445. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_2, &val);
  1446. if (val & 0x80)
  1447. break;
  1448. }
  1449. val = val << 0x8;
  1450. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_1, &val1);
  1451. val |= val1;
  1452. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x00);
  1453. x1 = TASHA_MBHC_GET_X1(val);
  1454. c1 = TASHA_MBHC_GET_C1(val);
  1455. /* If ramp is not complete, give additional 5ms */
  1456. if ((c1 < 2) && x1)
  1457. usleep_range(5000, 5050);
  1458. if (!c1 || !x1) {
  1459. dev_dbg(wcd9xxx->dev,
  1460. "%s: Impedance detect ramp error, c1=%d, x1=0x%x\n",
  1461. __func__, c1, x1);
  1462. goto ramp_down;
  1463. }
  1464. d1 = d1_a[c1];
  1465. denom = (x1 * d1) - (1 << (14 - noff));
  1466. if (denom > 0)
  1467. *zdet = (TASHA_MBHC_ZDET_CONST * 1000) / denom;
  1468. else if (x1 < minCode_param[noff])
  1469. *zdet = TASHA_ZDET_FLOATING_IMPEDANCE;
  1470. dev_dbg(wcd9xxx->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
  1471. __func__, d1, c1, x1, *zdet);
  1472. ramp_down:
  1473. i = 0;
  1474. while (x1) {
  1475. regmap_bulk_read(wcd9xxx->regmap,
  1476. WCD9335_ANA_MBHC_RESULT_1, (u8 *)&val, 2);
  1477. x1 = TASHA_MBHC_GET_X1(val);
  1478. i++;
  1479. if (i == TASHA_ZDET_NUM_MEASUREMENTS)
  1480. break;
  1481. }
  1482. }
  1483. /*
  1484. * tasha_mbhc_zdet_gpio_ctrl: Register callback function for
  1485. * controlling the switch on hifi amps. Default switch state
  1486. * will put a 51ohm load in parallel to the hph load. So,
  1487. * impedance detection function will pull the gpio high
  1488. * to make the switch open.
  1489. *
  1490. * @zdet_gpio_cb: callback function from machine driver
  1491. * @codec: Codec instance
  1492. *
  1493. * Return: none
  1494. */
  1495. void tasha_mbhc_zdet_gpio_ctrl(
  1496. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
  1497. struct snd_soc_codec *codec)
  1498. {
  1499. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1500. tasha->zdet_gpio_cb = zdet_gpio_cb;
  1501. }
  1502. EXPORT_SYMBOL(tasha_mbhc_zdet_gpio_ctrl);
  1503. static void tasha_mbhc_zdet_ramp(struct snd_soc_codec *codec,
  1504. struct tasha_mbhc_zdet_param *zdet_param,
  1505. int32_t *zl, int32_t *zr, s16 *d1_a)
  1506. {
  1507. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  1508. int32_t zdet = 0;
  1509. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x70,
  1510. zdet_param->ldo_ctl << 4);
  1511. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN5, 0xFC,
  1512. zdet_param->btn5);
  1513. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN6, 0xFC,
  1514. zdet_param->btn6);
  1515. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN7, 0xFC,
  1516. zdet_param->btn7);
  1517. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x0F,
  1518. zdet_param->noff);
  1519. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x0F,
  1520. zdet_param->nshift);
  1521. if (!zl)
  1522. goto z_right;
  1523. /* Start impedance measurement for HPH_L */
  1524. regmap_update_bits(wcd9xxx->regmap,
  1525. WCD9335_ANA_MBHC_ZDET, 0x80, 0x80);
  1526. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_L, noff = %d\n",
  1527. __func__, zdet_param->noff);
  1528. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1529. regmap_update_bits(wcd9xxx->regmap,
  1530. WCD9335_ANA_MBHC_ZDET, 0x80, 0x00);
  1531. *zl = zdet;
  1532. z_right:
  1533. if (!zr)
  1534. return;
  1535. /* Start impedance measurement for HPH_R */
  1536. regmap_update_bits(wcd9xxx->regmap,
  1537. WCD9335_ANA_MBHC_ZDET, 0x40, 0x40);
  1538. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_R, noff = %d\n",
  1539. __func__, zdet_param->noff);
  1540. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1541. regmap_update_bits(wcd9xxx->regmap,
  1542. WCD9335_ANA_MBHC_ZDET, 0x40, 0x00);
  1543. *zr = zdet;
  1544. }
  1545. static inline void tasha_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
  1546. int32_t *z_val, int flag_l_r)
  1547. {
  1548. s16 q1;
  1549. int q1_cal;
  1550. if (*z_val < (TASHA_ZDET_VAL_400/1000))
  1551. q1 = snd_soc_read(codec,
  1552. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r));
  1553. else
  1554. q1 = snd_soc_read(codec,
  1555. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r));
  1556. if (q1 & 0x80)
  1557. q1_cal = (10000 - ((q1 & 0x7F) * 25));
  1558. else
  1559. q1_cal = (10000 + (q1 * 25));
  1560. if (q1_cal > 0)
  1561. *z_val = ((*z_val) * 10000) / q1_cal;
  1562. }
  1563. static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
  1564. uint32_t *zr)
  1565. {
  1566. struct snd_soc_codec *codec = mbhc->codec;
  1567. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1568. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1569. s16 reg0, reg1, reg2, reg3, reg4;
  1570. int32_t z1L, z1R, z1Ls;
  1571. int zMono, z_diff1, z_diff2;
  1572. bool is_fsm_disable = false;
  1573. bool is_change = false;
  1574. struct tasha_mbhc_zdet_param zdet_param[] = {
  1575. {4, 0, 4, 0x08, 0x14, 0x18}, /* < 32ohm */
  1576. {2, 0, 3, 0x18, 0x7C, 0x90}, /* 32ohm < Z < 400ohm */
  1577. {1, 4, 5, 0x18, 0x7C, 0x90}, /* 400ohm < Z < 1200ohm */
  1578. {1, 6, 7, 0x18, 0x7C, 0x90}, /* >1200ohm */
  1579. };
  1580. struct tasha_mbhc_zdet_param *zdet_param_ptr = NULL;
  1581. s16 d1_a[][4] = {
  1582. {0, 30, 90, 30},
  1583. {0, 30, 30, 5},
  1584. {0, 30, 30, 5},
  1585. {0, 30, 30, 5},
  1586. };
  1587. s16 *d1 = NULL;
  1588. if (!TASHA_IS_2_0(wcd9xxx)) {
  1589. dev_dbg(codec->dev, "%s: Z-det is not supported for this codec version\n",
  1590. __func__);
  1591. *zl = 0;
  1592. *zr = 0;
  1593. return;
  1594. }
  1595. WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
  1596. if (tasha->zdet_gpio_cb)
  1597. is_change = tasha->zdet_gpio_cb(codec, true);
  1598. reg0 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN5);
  1599. reg1 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN6);
  1600. reg2 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN7);
  1601. reg3 = snd_soc_read(codec, WCD9335_MBHC_CTL_1);
  1602. reg4 = snd_soc_read(codec, WCD9335_MBHC_ZDET_ANA_CTL);
  1603. if (snd_soc_read(codec, WCD9335_ANA_MBHC_ELECT) & 0x80) {
  1604. is_fsm_disable = true;
  1605. regmap_update_bits(wcd9xxx->regmap,
  1606. WCD9335_ANA_MBHC_ELECT, 0x80, 0x00);
  1607. }
  1608. /* For NO-jack, disable L_DET_EN before Z-det measurements */
  1609. if (mbhc->hphl_swh)
  1610. regmap_update_bits(wcd9xxx->regmap,
  1611. WCD9335_ANA_MBHC_MECH, 0x80, 0x00);
  1612. /* Enable AZ */
  1613. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1, 0x0C, 0x04);
  1614. /* Turn off 100k pull down on HPHL */
  1615. regmap_update_bits(wcd9xxx->regmap,
  1616. WCD9335_ANA_MBHC_MECH, 0x01, 0x00);
  1617. /* First get impedance on Left */
  1618. d1 = d1_a[1];
  1619. zdet_param_ptr = &zdet_param[1];
  1620. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1621. if (!TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
  1622. goto left_ch_impedance;
  1623. /* second ramp for left ch */
  1624. if (z1L < TASHA_ZDET_VAL_32) {
  1625. zdet_param_ptr = &zdet_param[0];
  1626. d1 = d1_a[0];
  1627. } else if ((z1L > TASHA_ZDET_VAL_400) && (z1L <= TASHA_ZDET_VAL_1200)) {
  1628. zdet_param_ptr = &zdet_param[2];
  1629. d1 = d1_a[2];
  1630. } else if (z1L > TASHA_ZDET_VAL_1200) {
  1631. zdet_param_ptr = &zdet_param[3];
  1632. d1 = d1_a[3];
  1633. }
  1634. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1635. left_ch_impedance:
  1636. if ((z1L == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1637. (z1L > TASHA_ZDET_VAL_100K)) {
  1638. *zl = TASHA_ZDET_FLOATING_IMPEDANCE;
  1639. zdet_param_ptr = &zdet_param[1];
  1640. d1 = d1_a[1];
  1641. } else {
  1642. *zl = z1L/1000;
  1643. tasha_wcd_mbhc_qfuse_cal(codec, zl, 0);
  1644. }
  1645. dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n",
  1646. __func__, *zl);
  1647. /* start of right impedance ramp and calculation */
  1648. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1649. if (TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
  1650. if (((z1R > TASHA_ZDET_VAL_1200) &&
  1651. (zdet_param_ptr->noff == 0x6)) ||
  1652. ((*zl) != TASHA_ZDET_FLOATING_IMPEDANCE))
  1653. goto right_ch_impedance;
  1654. /* second ramp for right ch */
  1655. if (z1R < TASHA_ZDET_VAL_32) {
  1656. zdet_param_ptr = &zdet_param[0];
  1657. d1 = d1_a[0];
  1658. } else if ((z1R > TASHA_ZDET_VAL_400) &&
  1659. (z1R <= TASHA_ZDET_VAL_1200)) {
  1660. zdet_param_ptr = &zdet_param[2];
  1661. d1 = d1_a[2];
  1662. } else if (z1R > TASHA_ZDET_VAL_1200) {
  1663. zdet_param_ptr = &zdet_param[3];
  1664. d1 = d1_a[3];
  1665. }
  1666. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1667. }
  1668. right_ch_impedance:
  1669. if ((z1R == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1670. (z1R > TASHA_ZDET_VAL_100K)) {
  1671. *zr = TASHA_ZDET_FLOATING_IMPEDANCE;
  1672. } else {
  1673. *zr = z1R/1000;
  1674. tasha_wcd_mbhc_qfuse_cal(codec, zr, 1);
  1675. }
  1676. dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n",
  1677. __func__, *zr);
  1678. /* mono/stereo detection */
  1679. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) &&
  1680. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE)) {
  1681. dev_dbg(codec->dev,
  1682. "%s: plug type is invalid or extension cable\n",
  1683. __func__);
  1684. goto zdet_complete;
  1685. }
  1686. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1687. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1688. ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
  1689. ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
  1690. dev_dbg(codec->dev,
  1691. "%s: Mono plug type with one ch floating or shorted to GND\n",
  1692. __func__);
  1693. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1694. goto zdet_complete;
  1695. }
  1696. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x02);
  1697. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x01);
  1698. if (*zl < (TASHA_ZDET_VAL_32/1000))
  1699. tasha_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1);
  1700. else
  1701. tasha_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1);
  1702. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x00);
  1703. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x00);
  1704. z1Ls /= 1000;
  1705. tasha_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0);
  1706. /* parallel of left Z and 9 ohm pull down resistor */
  1707. zMono = ((*zl) * 9) / ((*zl) + 9);
  1708. z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
  1709. z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
  1710. if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
  1711. dev_dbg(codec->dev, "%s: stereo plug type detected\n",
  1712. __func__);
  1713. mbhc->hph_type = WCD_MBHC_HPH_STEREO;
  1714. } else {
  1715. dev_dbg(codec->dev, "%s: MONO plug type detected\n",
  1716. __func__);
  1717. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1718. }
  1719. zdet_complete:
  1720. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN5, reg0);
  1721. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN6, reg1);
  1722. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN7, reg2);
  1723. /* Turn on 100k pull down on HPHL */
  1724. regmap_update_bits(wcd9xxx->regmap,
  1725. WCD9335_ANA_MBHC_MECH, 0x01, 0x01);
  1726. /* For NO-jack, re-enable L_DET_EN after Z-det measurements */
  1727. if (mbhc->hphl_swh)
  1728. regmap_update_bits(wcd9xxx->regmap,
  1729. WCD9335_ANA_MBHC_MECH, 0x80, 0x80);
  1730. snd_soc_write(codec, WCD9335_MBHC_ZDET_ANA_CTL, reg4);
  1731. snd_soc_write(codec, WCD9335_MBHC_CTL_1, reg3);
  1732. if (is_fsm_disable)
  1733. regmap_update_bits(wcd9xxx->regmap,
  1734. WCD9335_ANA_MBHC_ELECT, 0x80, 0x80);
  1735. if (tasha->zdet_gpio_cb && is_change)
  1736. tasha->zdet_gpio_cb(codec, false);
  1737. }
  1738. static void tasha_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable)
  1739. {
  1740. if (enable) {
  1741. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1742. 0x02, 0x02);
  1743. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1744. 0x40, 0x40);
  1745. } else {
  1746. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1747. 0x40, 0x00);
  1748. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1749. 0x02, 0x00);
  1750. }
  1751. }
  1752. static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec,
  1753. bool enable)
  1754. {
  1755. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1756. if (enable) {
  1757. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1758. 0x40, 0x40);
  1759. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1760. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1761. 0x10, 0x10);
  1762. } else {
  1763. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1764. 0x40, 0x00);
  1765. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1766. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1767. 0x10, 0x00);
  1768. }
  1769. }
  1770. static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc)
  1771. {
  1772. struct snd_soc_codec *codec = mbhc->codec;
  1773. if (mbhc->moist_vref == V_OFF)
  1774. return;
  1775. /* Donot enable moisture detection if jack type is NC */
  1776. if (!mbhc->hphl_swh) {
  1777. dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
  1778. __func__);
  1779. return;
  1780. }
  1781. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2,
  1782. 0x0C, mbhc->moist_vref << 2);
  1783. tasha_mbhc_hph_l_pull_up_control(codec, mbhc->moist_iref);
  1784. }
  1785. static void tasha_update_anc_state(struct snd_soc_codec *codec, bool enable,
  1786. int anc_num)
  1787. {
  1788. if (enable)
  1789. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1790. (20 * anc_num), 0x10, 0x10);
  1791. else
  1792. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1793. (20 * anc_num), 0x10, 0x00);
  1794. }
  1795. static bool tasha_is_anc_on(struct wcd_mbhc *mbhc)
  1796. {
  1797. bool anc_on = false;
  1798. u16 ancl, ancr;
  1799. ancl =
  1800. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX1_RX_PATH_CFG0)) & 0x10;
  1801. ancr =
  1802. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX2_RX_PATH_CFG0)) & 0x10;
  1803. anc_on = !!(ancl | ancr);
  1804. return anc_on;
  1805. }
  1806. static const struct wcd_mbhc_cb mbhc_cb = {
  1807. .request_irq = tasha_mbhc_request_irq,
  1808. .irq_control = tasha_mbhc_irq_control,
  1809. .free_irq = tasha_mbhc_free_irq,
  1810. .clk_setup = tasha_mbhc_clk_setup,
  1811. .map_btn_code_to_num = tasha_mbhc_btn_to_num,
  1812. .enable_mb_source = tasha_enable_ext_mb_source,
  1813. .mbhc_bias = tasha_mbhc_mbhc_bias_control,
  1814. .set_btn_thr = tasha_mbhc_program_btn_thr,
  1815. .lock_sleep = tasha_mbhc_lock_sleep,
  1816. .register_notifier = tasha_mbhc_register_notifier,
  1817. .micbias_enable_status = tasha_mbhc_micb_en_status,
  1818. .hph_pa_on_status = tasha_mbhc_hph_pa_on_status,
  1819. .hph_pull_up_control = tasha_mbhc_hph_l_pull_up_control,
  1820. .mbhc_micbias_control = tasha_mbhc_request_micbias,
  1821. .mbhc_micb_ramp_control = tasha_mbhc_micb_ramp_control,
  1822. .get_hwdep_fw_cal = tasha_get_hwdep_fw_cal,
  1823. .mbhc_micb_ctrl_thr_mic = tasha_mbhc_micb_ctrl_threshold_mic,
  1824. .compute_impedance = tasha_wcd_mbhc_calc_impedance,
  1825. .mbhc_gnd_det_ctrl = tasha_mbhc_gnd_det_ctrl,
  1826. .hph_pull_down_ctrl = tasha_mbhc_hph_pull_down_ctrl,
  1827. .mbhc_moisture_config = tasha_mbhc_moisture_config,
  1828. .update_anc_state = tasha_update_anc_state,
  1829. .is_anc_on = tasha_is_anc_on,
  1830. };
  1831. static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol,
  1832. struct snd_ctl_elem_value *ucontrol)
  1833. {
  1834. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1835. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1836. ucontrol->value.integer.value[0] = tasha->anc_slot;
  1837. return 0;
  1838. }
  1839. static int tasha_put_anc_slot(struct snd_kcontrol *kcontrol,
  1840. struct snd_ctl_elem_value *ucontrol)
  1841. {
  1842. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1843. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1844. tasha->anc_slot = ucontrol->value.integer.value[0];
  1845. return 0;
  1846. }
  1847. static int tasha_get_anc_func(struct snd_kcontrol *kcontrol,
  1848. struct snd_ctl_elem_value *ucontrol)
  1849. {
  1850. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1851. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1852. ucontrol->value.integer.value[0] = (tasha->anc_func == true ? 1 : 0);
  1853. return 0;
  1854. }
  1855. static int tasha_put_anc_func(struct snd_kcontrol *kcontrol,
  1856. struct snd_ctl_elem_value *ucontrol)
  1857. {
  1858. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1859. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1860. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  1861. mutex_lock(&tasha->codec_mutex);
  1862. tasha->anc_func = (!ucontrol->value.integer.value[0] ? false : true);
  1863. dev_dbg(codec->dev, "%s: anc_func %x", __func__, tasha->anc_func);
  1864. if (tasha->anc_func == true) {
  1865. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2 PA");
  1866. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2");
  1867. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1 PA");
  1868. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1");
  1869. snd_soc_dapm_enable_pin(dapm, "ANC HPHR PA");
  1870. snd_soc_dapm_enable_pin(dapm, "ANC HPHR");
  1871. snd_soc_dapm_enable_pin(dapm, "ANC HPHL PA");
  1872. snd_soc_dapm_enable_pin(dapm, "ANC HPHL");
  1873. snd_soc_dapm_enable_pin(dapm, "ANC EAR PA");
  1874. snd_soc_dapm_enable_pin(dapm, "ANC EAR");
  1875. snd_soc_dapm_enable_pin(dapm, "ANC SPK1 PA");
  1876. snd_soc_dapm_disable_pin(dapm, "LINEOUT2");
  1877. snd_soc_dapm_disable_pin(dapm, "LINEOUT2 PA");
  1878. snd_soc_dapm_disable_pin(dapm, "LINEOUT1");
  1879. snd_soc_dapm_disable_pin(dapm, "LINEOUT1 PA");
  1880. snd_soc_dapm_disable_pin(dapm, "HPHR");
  1881. snd_soc_dapm_disable_pin(dapm, "HPHL");
  1882. snd_soc_dapm_disable_pin(dapm, "HPHR PA");
  1883. snd_soc_dapm_disable_pin(dapm, "HPHL PA");
  1884. snd_soc_dapm_disable_pin(dapm, "EAR PA");
  1885. snd_soc_dapm_disable_pin(dapm, "EAR");
  1886. } else {
  1887. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  1888. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  1889. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  1890. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  1891. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  1892. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  1893. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  1894. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  1895. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  1896. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  1897. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  1898. snd_soc_dapm_enable_pin(dapm, "LINEOUT2");
  1899. snd_soc_dapm_enable_pin(dapm, "LINEOUT2 PA");
  1900. snd_soc_dapm_enable_pin(dapm, "LINEOUT1");
  1901. snd_soc_dapm_enable_pin(dapm, "LINEOUT1 PA");
  1902. snd_soc_dapm_enable_pin(dapm, "HPHR");
  1903. snd_soc_dapm_enable_pin(dapm, "HPHL");
  1904. snd_soc_dapm_enable_pin(dapm, "HPHR PA");
  1905. snd_soc_dapm_enable_pin(dapm, "HPHL PA");
  1906. snd_soc_dapm_enable_pin(dapm, "EAR PA");
  1907. snd_soc_dapm_enable_pin(dapm, "EAR");
  1908. }
  1909. mutex_unlock(&tasha->codec_mutex);
  1910. snd_soc_dapm_sync(dapm);
  1911. return 0;
  1912. }
  1913. static int tasha_get_clkmode(struct snd_kcontrol *kcontrol,
  1914. struct snd_ctl_elem_value *ucontrol)
  1915. {
  1916. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1917. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1918. ucontrol->value.enumerated.item[0] = tasha->clk_mode;
  1919. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1920. return 0;
  1921. }
  1922. static int tasha_put_clkmode(struct snd_kcontrol *kcontrol,
  1923. struct snd_ctl_elem_value *ucontrol)
  1924. {
  1925. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1926. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1927. tasha->clk_mode = ucontrol->value.enumerated.item[0];
  1928. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1929. return 0;
  1930. }
  1931. static int tasha_get_iir_enable_audio_mixer(
  1932. struct snd_kcontrol *kcontrol,
  1933. struct snd_ctl_elem_value *ucontrol)
  1934. {
  1935. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1936. int iir_idx = ((struct soc_multi_mixer_control *)
  1937. kcontrol->private_value)->reg;
  1938. int band_idx = ((struct soc_multi_mixer_control *)
  1939. kcontrol->private_value)->shift;
  1940. /* IIR filter band registers are at integer multiples of 16 */
  1941. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  1942. ucontrol->value.integer.value[0] = (snd_soc_read(codec, iir_reg) &
  1943. (1 << band_idx)) != 0;
  1944. dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
  1945. iir_idx, band_idx,
  1946. (uint32_t)ucontrol->value.integer.value[0]);
  1947. return 0;
  1948. }
  1949. static int tasha_hph_impedance_get(struct snd_kcontrol *kcontrol,
  1950. struct snd_ctl_elem_value *ucontrol)
  1951. {
  1952. uint32_t zl, zr;
  1953. bool hphr;
  1954. struct soc_multi_mixer_control *mc;
  1955. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1956. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1957. mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
  1958. hphr = mc->shift;
  1959. wcd_mbhc_get_impedance(&priv->mbhc, &zl, &zr);
  1960. dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
  1961. ucontrol->value.integer.value[0] = hphr ? zr : zl;
  1962. return 0;
  1963. }
  1964. static const struct snd_kcontrol_new impedance_detect_controls[] = {
  1965. SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
  1966. tasha_hph_impedance_get, NULL),
  1967. SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
  1968. tasha_hph_impedance_get, NULL),
  1969. };
  1970. static int tasha_get_hph_type(struct snd_kcontrol *kcontrol,
  1971. struct snd_ctl_elem_value *ucontrol)
  1972. {
  1973. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1974. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1975. struct wcd_mbhc *mbhc;
  1976. if (!priv) {
  1977. dev_dbg(codec->dev, "%s: wcd9335 private data is NULL\n",
  1978. __func__);
  1979. return 0;
  1980. }
  1981. mbhc = &priv->mbhc;
  1982. if (!mbhc) {
  1983. dev_dbg(codec->dev, "%s: mbhc not initialized\n", __func__);
  1984. return 0;
  1985. }
  1986. ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
  1987. dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
  1988. return 0;
  1989. }
  1990. static const struct snd_kcontrol_new hph_type_detect_controls[] = {
  1991. SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
  1992. tasha_get_hph_type, NULL),
  1993. };
  1994. static int tasha_vi_feed_mixer_get(struct snd_kcontrol *kcontrol,
  1995. struct snd_ctl_elem_value *ucontrol)
  1996. {
  1997. struct snd_soc_dapm_widget *widget =
  1998. snd_soc_dapm_kcontrol_widget(kcontrol);
  1999. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2000. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2001. ucontrol->value.integer.value[0] = tasha_p->vi_feed_value;
  2002. return 0;
  2003. }
  2004. static int tasha_vi_feed_mixer_put(struct snd_kcontrol *kcontrol,
  2005. struct snd_ctl_elem_value *ucontrol)
  2006. {
  2007. struct snd_soc_dapm_widget *widget =
  2008. snd_soc_dapm_kcontrol_widget(kcontrol);
  2009. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2010. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2011. struct wcd9xxx *core = tasha_p->wcd9xxx;
  2012. struct soc_multi_mixer_control *mixer =
  2013. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2014. u32 dai_id = widget->shift;
  2015. u32 port_id = mixer->shift;
  2016. u32 enable = ucontrol->value.integer.value[0];
  2017. dev_dbg(codec->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n",
  2018. __func__, enable, port_id, dai_id);
  2019. tasha_p->vi_feed_value = ucontrol->value.integer.value[0];
  2020. mutex_lock(&tasha_p->codec_mutex);
  2021. if (enable) {
  2022. if (port_id == TASHA_TX14 && !test_bit(VI_SENSE_1,
  2023. &tasha_p->status_mask)) {
  2024. list_add_tail(&core->tx_chs[TASHA_TX14].list,
  2025. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2026. set_bit(VI_SENSE_1, &tasha_p->status_mask);
  2027. }
  2028. if (port_id == TASHA_TX15 && !test_bit(VI_SENSE_2,
  2029. &tasha_p->status_mask)) {
  2030. list_add_tail(&core->tx_chs[TASHA_TX15].list,
  2031. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2032. set_bit(VI_SENSE_2, &tasha_p->status_mask);
  2033. }
  2034. } else {
  2035. if (port_id == TASHA_TX14 && test_bit(VI_SENSE_1,
  2036. &tasha_p->status_mask)) {
  2037. list_del_init(&core->tx_chs[TASHA_TX14].list);
  2038. clear_bit(VI_SENSE_1, &tasha_p->status_mask);
  2039. }
  2040. if (port_id == TASHA_TX15 && test_bit(VI_SENSE_2,
  2041. &tasha_p->status_mask)) {
  2042. list_del_init(&core->tx_chs[TASHA_TX15].list);
  2043. clear_bit(VI_SENSE_2, &tasha_p->status_mask);
  2044. }
  2045. }
  2046. mutex_unlock(&tasha_p->codec_mutex);
  2047. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL);
  2048. return 0;
  2049. }
  2050. /* virtual port entries */
  2051. static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol,
  2052. struct snd_ctl_elem_value *ucontrol)
  2053. {
  2054. struct snd_soc_dapm_widget *widget =
  2055. snd_soc_dapm_kcontrol_widget(kcontrol);
  2056. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2057. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2058. ucontrol->value.integer.value[0] = tasha_p->tx_port_value;
  2059. return 0;
  2060. }
  2061. static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol,
  2062. struct snd_ctl_elem_value *ucontrol)
  2063. {
  2064. struct snd_soc_dapm_widget *widget =
  2065. snd_soc_dapm_kcontrol_widget(kcontrol);
  2066. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2067. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2068. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2069. struct snd_soc_dapm_update *update = NULL;
  2070. struct soc_multi_mixer_control *mixer =
  2071. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2072. u32 dai_id = widget->shift;
  2073. u32 port_id = mixer->shift;
  2074. u32 enable = ucontrol->value.integer.value[0];
  2075. u32 vtable;
  2076. dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n",
  2077. __func__,
  2078. widget->name, ucontrol->id.name, tasha_p->tx_port_value,
  2079. widget->shift, ucontrol->value.integer.value[0]);
  2080. mutex_lock(&tasha_p->codec_mutex);
  2081. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2082. if (dai_id != AIF1_CAP) {
  2083. dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
  2084. __func__);
  2085. mutex_unlock(&tasha_p->codec_mutex);
  2086. return -EINVAL;
  2087. }
  2088. vtable = vport_slim_check_table[dai_id];
  2089. } else {
  2090. if (dai_id >= ARRAY_SIZE(vport_i2s_check_table)) {
  2091. dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n",
  2092. __func__, dai_id);
  2093. return -EINVAL;
  2094. }
  2095. vtable = vport_i2s_check_table[dai_id];
  2096. }
  2097. switch (dai_id) {
  2098. case AIF1_CAP:
  2099. case AIF2_CAP:
  2100. case AIF3_CAP:
  2101. /* only add to the list if value not set */
  2102. if (enable && !(tasha_p->tx_port_value & 1 << port_id)) {
  2103. if (wcd9xxx_tx_vport_validation(vtable, port_id,
  2104. tasha_p->dai, NUM_CODEC_DAIS)) {
  2105. dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n",
  2106. __func__, port_id);
  2107. mutex_unlock(&tasha_p->codec_mutex);
  2108. return 0;
  2109. }
  2110. tasha_p->tx_port_value |= 1 << port_id;
  2111. list_add_tail(&core->tx_chs[port_id].list,
  2112. &tasha_p->dai[dai_id].wcd9xxx_ch_list
  2113. );
  2114. } else if (!enable && (tasha_p->tx_port_value &
  2115. 1 << port_id)) {
  2116. tasha_p->tx_port_value &= ~(1 << port_id);
  2117. list_del_init(&core->tx_chs[port_id].list);
  2118. } else {
  2119. if (enable)
  2120. dev_dbg(codec->dev, "%s: TX%u port is used by\n"
  2121. "this virtual port\n",
  2122. __func__, port_id);
  2123. else
  2124. dev_dbg(codec->dev, "%s: TX%u port is not used by\n"
  2125. "this virtual port\n",
  2126. __func__, port_id);
  2127. /* avoid update power function */
  2128. mutex_unlock(&tasha_p->codec_mutex);
  2129. return 0;
  2130. }
  2131. break;
  2132. case AIF4_MAD_TX:
  2133. case AIF5_CPE_TX:
  2134. break;
  2135. default:
  2136. pr_err("Unknown AIF %d\n", dai_id);
  2137. mutex_unlock(&tasha_p->codec_mutex);
  2138. return -EINVAL;
  2139. }
  2140. pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__,
  2141. widget->name, widget->sname, tasha_p->tx_port_value,
  2142. widget->shift);
  2143. mutex_unlock(&tasha_p->codec_mutex);
  2144. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
  2145. return 0;
  2146. }
  2147. static int slim_rx_mux_get(struct snd_kcontrol *kcontrol,
  2148. struct snd_ctl_elem_value *ucontrol)
  2149. {
  2150. struct snd_soc_dapm_widget *widget =
  2151. snd_soc_dapm_kcontrol_widget(kcontrol);
  2152. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2153. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2154. ucontrol->value.enumerated.item[0] =
  2155. tasha_p->rx_port_value[widget->shift];
  2156. return 0;
  2157. }
  2158. static const char *const slim_rx_mux_text[] = {
  2159. "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB", "AIF_MIX1_PB"
  2160. };
  2161. static int slim_rx_mux_put(struct snd_kcontrol *kcontrol,
  2162. struct snd_ctl_elem_value *ucontrol)
  2163. {
  2164. struct snd_soc_dapm_widget *widget =
  2165. snd_soc_dapm_kcontrol_widget(kcontrol);
  2166. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2167. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2168. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2169. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  2170. struct snd_soc_dapm_update *update = NULL;
  2171. unsigned int rx_port_value;
  2172. u32 port_id = widget->shift;
  2173. tasha_p->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
  2174. rx_port_value = tasha_p->rx_port_value[port_id];
  2175. pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__,
  2176. widget->name, ucontrol->id.name, rx_port_value,
  2177. widget->shift, ucontrol->value.integer.value[0]);
  2178. mutex_lock(&tasha_p->codec_mutex);
  2179. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2180. if (rx_port_value > 2) {
  2181. dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
  2182. __func__);
  2183. goto err;
  2184. }
  2185. }
  2186. /* value need to match the Virtual port and AIF number */
  2187. switch (rx_port_value) {
  2188. case 0:
  2189. list_del_init(&core->rx_chs[port_id].list);
  2190. break;
  2191. case 1:
  2192. if (wcd9xxx_rx_vport_validation(port_id +
  2193. TASHA_RX_PORT_START_NUMBER,
  2194. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list)) {
  2195. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2196. __func__, port_id);
  2197. goto rtn;
  2198. }
  2199. list_add_tail(&core->rx_chs[port_id].list,
  2200. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list);
  2201. break;
  2202. case 2:
  2203. if (wcd9xxx_rx_vport_validation(port_id +
  2204. TASHA_RX_PORT_START_NUMBER,
  2205. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list)) {
  2206. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2207. __func__, port_id);
  2208. goto rtn;
  2209. }
  2210. list_add_tail(&core->rx_chs[port_id].list,
  2211. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list);
  2212. break;
  2213. case 3:
  2214. if (wcd9xxx_rx_vport_validation(port_id +
  2215. TASHA_RX_PORT_START_NUMBER,
  2216. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list)) {
  2217. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2218. __func__, port_id);
  2219. goto rtn;
  2220. }
  2221. list_add_tail(&core->rx_chs[port_id].list,
  2222. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list);
  2223. break;
  2224. case 4:
  2225. if (wcd9xxx_rx_vport_validation(port_id +
  2226. TASHA_RX_PORT_START_NUMBER,
  2227. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list)) {
  2228. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2229. __func__, port_id);
  2230. goto rtn;
  2231. }
  2232. list_add_tail(&core->rx_chs[port_id].list,
  2233. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list);
  2234. break;
  2235. case 5:
  2236. if (wcd9xxx_rx_vport_validation(port_id +
  2237. TASHA_RX_PORT_START_NUMBER,
  2238. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list)) {
  2239. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2240. __func__, port_id);
  2241. goto rtn;
  2242. }
  2243. list_add_tail(&core->rx_chs[port_id].list,
  2244. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list);
  2245. break;
  2246. default:
  2247. pr_err("Unknown AIF %d\n", rx_port_value);
  2248. goto err;
  2249. }
  2250. rtn:
  2251. mutex_unlock(&tasha_p->codec_mutex);
  2252. snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
  2253. rx_port_value, e, update);
  2254. return 0;
  2255. err:
  2256. mutex_unlock(&tasha_p->codec_mutex);
  2257. return -EINVAL;
  2258. }
  2259. static const struct soc_enum slim_rx_mux_enum =
  2260. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text);
  2261. static const struct snd_kcontrol_new slim_rx_mux[TASHA_RX_MAX] = {
  2262. SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum,
  2263. slim_rx_mux_get, slim_rx_mux_put),
  2264. SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
  2265. slim_rx_mux_get, slim_rx_mux_put),
  2266. SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
  2267. slim_rx_mux_get, slim_rx_mux_put),
  2268. SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
  2269. slim_rx_mux_get, slim_rx_mux_put),
  2270. SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
  2271. slim_rx_mux_get, slim_rx_mux_put),
  2272. SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
  2273. slim_rx_mux_get, slim_rx_mux_put),
  2274. SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
  2275. slim_rx_mux_get, slim_rx_mux_put),
  2276. SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
  2277. slim_rx_mux_get, slim_rx_mux_put),
  2278. };
  2279. static const struct snd_kcontrol_new aif4_vi_mixer[] = {
  2280. SOC_SINGLE_EXT("SPKR_VI_1", SND_SOC_NOPM, TASHA_TX14, 1, 0,
  2281. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2282. SOC_SINGLE_EXT("SPKR_VI_2", SND_SOC_NOPM, TASHA_TX15, 1, 0,
  2283. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2284. };
  2285. static const struct snd_kcontrol_new aif1_cap_mixer[] = {
  2286. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2287. slim_tx_mixer_get, slim_tx_mixer_put),
  2288. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2289. slim_tx_mixer_get, slim_tx_mixer_put),
  2290. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2291. slim_tx_mixer_get, slim_tx_mixer_put),
  2292. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2293. slim_tx_mixer_get, slim_tx_mixer_put),
  2294. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2295. slim_tx_mixer_get, slim_tx_mixer_put),
  2296. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2297. slim_tx_mixer_get, slim_tx_mixer_put),
  2298. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2299. slim_tx_mixer_get, slim_tx_mixer_put),
  2300. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2301. slim_tx_mixer_get, slim_tx_mixer_put),
  2302. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2303. slim_tx_mixer_get, slim_tx_mixer_put),
  2304. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2305. slim_tx_mixer_get, slim_tx_mixer_put),
  2306. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2307. slim_tx_mixer_get, slim_tx_mixer_put),
  2308. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2309. slim_tx_mixer_get, slim_tx_mixer_put),
  2310. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2311. slim_tx_mixer_get, slim_tx_mixer_put),
  2312. };
  2313. static const struct snd_kcontrol_new aif2_cap_mixer[] = {
  2314. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2315. slim_tx_mixer_get, slim_tx_mixer_put),
  2316. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2317. slim_tx_mixer_get, slim_tx_mixer_put),
  2318. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2319. slim_tx_mixer_get, slim_tx_mixer_put),
  2320. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2321. slim_tx_mixer_get, slim_tx_mixer_put),
  2322. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2323. slim_tx_mixer_get, slim_tx_mixer_put),
  2324. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2325. slim_tx_mixer_get, slim_tx_mixer_put),
  2326. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2327. slim_tx_mixer_get, slim_tx_mixer_put),
  2328. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2329. slim_tx_mixer_get, slim_tx_mixer_put),
  2330. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2331. slim_tx_mixer_get, slim_tx_mixer_put),
  2332. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2333. slim_tx_mixer_get, slim_tx_mixer_put),
  2334. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2335. slim_tx_mixer_get, slim_tx_mixer_put),
  2336. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2337. slim_tx_mixer_get, slim_tx_mixer_put),
  2338. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2339. slim_tx_mixer_get, slim_tx_mixer_put),
  2340. };
  2341. static const struct snd_kcontrol_new aif3_cap_mixer[] = {
  2342. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2343. slim_tx_mixer_get, slim_tx_mixer_put),
  2344. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2345. slim_tx_mixer_get, slim_tx_mixer_put),
  2346. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2347. slim_tx_mixer_get, slim_tx_mixer_put),
  2348. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2349. slim_tx_mixer_get, slim_tx_mixer_put),
  2350. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2351. slim_tx_mixer_get, slim_tx_mixer_put),
  2352. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2353. slim_tx_mixer_get, slim_tx_mixer_put),
  2354. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2355. slim_tx_mixer_get, slim_tx_mixer_put),
  2356. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2357. slim_tx_mixer_get, slim_tx_mixer_put),
  2358. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2359. slim_tx_mixer_get, slim_tx_mixer_put),
  2360. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2361. slim_tx_mixer_get, slim_tx_mixer_put),
  2362. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2363. slim_tx_mixer_get, slim_tx_mixer_put),
  2364. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2365. slim_tx_mixer_get, slim_tx_mixer_put),
  2366. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2367. slim_tx_mixer_get, slim_tx_mixer_put),
  2368. };
  2369. static const struct snd_kcontrol_new aif4_mad_mixer[] = {
  2370. SOC_SINGLE_EXT("SLIM TX12", SND_SOC_NOPM, TASHA_TX12, 1, 0,
  2371. slim_tx_mixer_get, slim_tx_mixer_put),
  2372. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2373. slim_tx_mixer_get, slim_tx_mixer_put),
  2374. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, 0, 1, 0,
  2375. slim_tx_mixer_get, slim_tx_mixer_put),
  2376. };
  2377. static const struct snd_kcontrol_new rx_int1_spline_mix_switch[] = {
  2378. SOC_DAPM_SINGLE("HPHL Switch", SND_SOC_NOPM, 0, 1, 0)
  2379. };
  2380. static const struct snd_kcontrol_new rx_int2_spline_mix_switch[] = {
  2381. SOC_DAPM_SINGLE("HPHR Switch", SND_SOC_NOPM, 0, 1, 0)
  2382. };
  2383. static const struct snd_kcontrol_new rx_int3_spline_mix_switch[] = {
  2384. SOC_DAPM_SINGLE("LO1 Switch", SND_SOC_NOPM, 0, 1, 0)
  2385. };
  2386. static const struct snd_kcontrol_new rx_int4_spline_mix_switch[] = {
  2387. SOC_DAPM_SINGLE("LO2 Switch", SND_SOC_NOPM, 0, 1, 0)
  2388. };
  2389. static const struct snd_kcontrol_new rx_int5_spline_mix_switch[] = {
  2390. SOC_DAPM_SINGLE("LO3 Switch", SND_SOC_NOPM, 0, 1, 0)
  2391. };
  2392. static const struct snd_kcontrol_new rx_int6_spline_mix_switch[] = {
  2393. SOC_DAPM_SINGLE("LO4 Switch", SND_SOC_NOPM, 0, 1, 0)
  2394. };
  2395. static const struct snd_kcontrol_new rx_int7_spline_mix_switch[] = {
  2396. SOC_DAPM_SINGLE("SPKRL Switch", SND_SOC_NOPM, 0, 1, 0)
  2397. };
  2398. static const struct snd_kcontrol_new rx_int8_spline_mix_switch[] = {
  2399. SOC_DAPM_SINGLE("SPKRR Switch", SND_SOC_NOPM, 0, 1, 0)
  2400. };
  2401. static const struct snd_kcontrol_new rx_int5_vbat_mix_switch[] = {
  2402. SOC_DAPM_SINGLE("LO3 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2403. };
  2404. static const struct snd_kcontrol_new rx_int6_vbat_mix_switch[] = {
  2405. SOC_DAPM_SINGLE("LO4 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2406. };
  2407. static const struct snd_kcontrol_new rx_int7_vbat_mix_switch[] = {
  2408. SOC_DAPM_SINGLE("SPKRL VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2409. };
  2410. static const struct snd_kcontrol_new rx_int8_vbat_mix_switch[] = {
  2411. SOC_DAPM_SINGLE("SPKRR VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2412. };
  2413. static const struct snd_kcontrol_new cpe_in_mix_switch[] = {
  2414. SOC_DAPM_SINGLE("MAD_BYPASS", SND_SOC_NOPM, 0, 1, 0)
  2415. };
  2416. static int tasha_put_iir_enable_audio_mixer(
  2417. struct snd_kcontrol *kcontrol,
  2418. struct snd_ctl_elem_value *ucontrol)
  2419. {
  2420. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2421. int iir_idx = ((struct soc_multi_mixer_control *)
  2422. kcontrol->private_value)->reg;
  2423. int band_idx = ((struct soc_multi_mixer_control *)
  2424. kcontrol->private_value)->shift;
  2425. bool iir_band_en_status;
  2426. int value = ucontrol->value.integer.value[0];
  2427. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  2428. /* Mask first 5 bits, 6-8 are reserved */
  2429. snd_soc_update_bits(codec, iir_reg, (1 << band_idx),
  2430. (value << band_idx));
  2431. iir_band_en_status = ((snd_soc_read(codec, iir_reg) &
  2432. (1 << band_idx)) != 0);
  2433. pr_debug("%s: IIR #%d band #%d enable %d\n", __func__,
  2434. iir_idx, band_idx, iir_band_en_status);
  2435. return 0;
  2436. }
  2437. static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec,
  2438. int iir_idx, int band_idx,
  2439. int coeff_idx)
  2440. {
  2441. uint32_t value = 0;
  2442. /* Address does not automatically update if reading */
  2443. snd_soc_write(codec,
  2444. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2445. ((band_idx * BAND_MAX + coeff_idx)
  2446. * sizeof(uint32_t)) & 0x7F);
  2447. value |= snd_soc_read(codec,
  2448. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx));
  2449. snd_soc_write(codec,
  2450. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2451. ((band_idx * BAND_MAX + coeff_idx)
  2452. * sizeof(uint32_t) + 1) & 0x7F);
  2453. value |= (snd_soc_read(codec,
  2454. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2455. 16 * iir_idx)) << 8);
  2456. snd_soc_write(codec,
  2457. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2458. ((band_idx * BAND_MAX + coeff_idx)
  2459. * sizeof(uint32_t) + 2) & 0x7F);
  2460. value |= (snd_soc_read(codec,
  2461. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2462. 16 * iir_idx)) << 16);
  2463. snd_soc_write(codec,
  2464. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2465. ((band_idx * BAND_MAX + coeff_idx)
  2466. * sizeof(uint32_t) + 3) & 0x7F);
  2467. /* Mask bits top 2 bits since they are reserved */
  2468. value |= ((snd_soc_read(codec,
  2469. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2470. 16 * iir_idx)) & 0x3F) << 24);
  2471. return value;
  2472. }
  2473. static int tasha_get_iir_band_audio_mixer(
  2474. struct snd_kcontrol *kcontrol,
  2475. struct snd_ctl_elem_value *ucontrol)
  2476. {
  2477. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2478. int iir_idx = ((struct soc_multi_mixer_control *)
  2479. kcontrol->private_value)->reg;
  2480. int band_idx = ((struct soc_multi_mixer_control *)
  2481. kcontrol->private_value)->shift;
  2482. ucontrol->value.integer.value[0] =
  2483. get_iir_band_coeff(codec, iir_idx, band_idx, 0);
  2484. ucontrol->value.integer.value[1] =
  2485. get_iir_band_coeff(codec, iir_idx, band_idx, 1);
  2486. ucontrol->value.integer.value[2] =
  2487. get_iir_band_coeff(codec, iir_idx, band_idx, 2);
  2488. ucontrol->value.integer.value[3] =
  2489. get_iir_band_coeff(codec, iir_idx, band_idx, 3);
  2490. ucontrol->value.integer.value[4] =
  2491. get_iir_band_coeff(codec, iir_idx, band_idx, 4);
  2492. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  2493. "%s: IIR #%d band #%d b1 = 0x%x\n"
  2494. "%s: IIR #%d band #%d b2 = 0x%x\n"
  2495. "%s: IIR #%d band #%d a1 = 0x%x\n"
  2496. "%s: IIR #%d band #%d a2 = 0x%x\n",
  2497. __func__, iir_idx, band_idx,
  2498. (uint32_t)ucontrol->value.integer.value[0],
  2499. __func__, iir_idx, band_idx,
  2500. (uint32_t)ucontrol->value.integer.value[1],
  2501. __func__, iir_idx, band_idx,
  2502. (uint32_t)ucontrol->value.integer.value[2],
  2503. __func__, iir_idx, band_idx,
  2504. (uint32_t)ucontrol->value.integer.value[3],
  2505. __func__, iir_idx, band_idx,
  2506. (uint32_t)ucontrol->value.integer.value[4]);
  2507. return 0;
  2508. }
  2509. static void set_iir_band_coeff(struct snd_soc_codec *codec,
  2510. int iir_idx, int band_idx,
  2511. uint32_t value)
  2512. {
  2513. snd_soc_write(codec,
  2514. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2515. (value & 0xFF));
  2516. snd_soc_write(codec,
  2517. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2518. (value >> 8) & 0xFF);
  2519. snd_soc_write(codec,
  2520. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2521. (value >> 16) & 0xFF);
  2522. /* Mask top 2 bits, 7-8 are reserved */
  2523. snd_soc_write(codec,
  2524. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2525. (value >> 24) & 0x3F);
  2526. }
  2527. static void tasha_codec_enable_int_port(struct wcd9xxx_codec_dai_data *dai,
  2528. struct snd_soc_codec *codec)
  2529. {
  2530. struct wcd9xxx_ch *ch;
  2531. int port_num = 0;
  2532. unsigned short reg = 0;
  2533. u8 val = 0;
  2534. struct tasha_priv *tasha_p;
  2535. if (!dai || !codec) {
  2536. pr_err("%s: Invalid params\n", __func__);
  2537. return;
  2538. }
  2539. tasha_p = snd_soc_codec_get_drvdata(codec);
  2540. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2541. if (ch->port >= TASHA_RX_PORT_START_NUMBER) {
  2542. port_num = ch->port - TASHA_RX_PORT_START_NUMBER;
  2543. reg = TASHA_SLIM_PGD_PORT_INT_EN0 + (port_num / 8);
  2544. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2545. reg);
  2546. if (!(val & BYTE_BIT_MASK(port_num))) {
  2547. val |= BYTE_BIT_MASK(port_num);
  2548. wcd9xxx_interface_reg_write(
  2549. tasha_p->wcd9xxx, reg, val);
  2550. val = wcd9xxx_interface_reg_read(
  2551. tasha_p->wcd9xxx, reg);
  2552. }
  2553. } else {
  2554. port_num = ch->port;
  2555. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 + (port_num / 8);
  2556. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2557. reg);
  2558. if (!(val & BYTE_BIT_MASK(port_num))) {
  2559. val |= BYTE_BIT_MASK(port_num);
  2560. wcd9xxx_interface_reg_write(tasha_p->wcd9xxx,
  2561. reg, val);
  2562. val = wcd9xxx_interface_reg_read(
  2563. tasha_p->wcd9xxx, reg);
  2564. }
  2565. }
  2566. }
  2567. }
  2568. static int tasha_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai,
  2569. bool up)
  2570. {
  2571. int ret = 0;
  2572. struct wcd9xxx_ch *ch;
  2573. if (up) {
  2574. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2575. ret = wcd9xxx_get_slave_port(ch->ch_num);
  2576. if (ret < 0) {
  2577. pr_err("%s: Invalid slave port ID: %d\n",
  2578. __func__, ret);
  2579. ret = -EINVAL;
  2580. } else {
  2581. set_bit(ret, &dai->ch_mask);
  2582. }
  2583. }
  2584. } else {
  2585. ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0),
  2586. msecs_to_jiffies(
  2587. TASHA_SLIM_CLOSE_TIMEOUT));
  2588. if (!ret) {
  2589. pr_err("%s: Slim close tx/rx wait timeout, ch_mask:0x%lx\n",
  2590. __func__, dai->ch_mask);
  2591. ret = -ETIMEDOUT;
  2592. } else {
  2593. ret = 0;
  2594. }
  2595. }
  2596. return ret;
  2597. }
  2598. static int tasha_codec_enable_slimrx(struct snd_soc_dapm_widget *w,
  2599. struct snd_kcontrol *kcontrol,
  2600. int event)
  2601. {
  2602. struct wcd9xxx *core;
  2603. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2604. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2605. int ret = 0;
  2606. struct wcd9xxx_codec_dai_data *dai;
  2607. core = dev_get_drvdata(codec->dev->parent);
  2608. dev_dbg(codec->dev, "%s: event called! codec name %s num_dai %d\n"
  2609. "stream name %s event %d\n",
  2610. __func__, codec->component.name,
  2611. codec->component.num_dai, w->sname, event);
  2612. /* Execute the callback only if interface type is slimbus */
  2613. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2614. return 0;
  2615. dai = &tasha_p->dai[w->shift];
  2616. dev_dbg(codec->dev, "%s: w->name %s w->shift %d event %d\n",
  2617. __func__, w->name, w->shift, event);
  2618. switch (event) {
  2619. case SND_SOC_DAPM_POST_PMU:
  2620. dai->bus_down_in_recovery = false;
  2621. tasha_codec_enable_int_port(dai, codec);
  2622. (void) tasha_codec_enable_slim_chmask(dai, true);
  2623. ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2624. dai->rate, dai->bit_width,
  2625. &dai->grph);
  2626. break;
  2627. case SND_SOC_DAPM_PRE_PMD:
  2628. tasha_codec_vote_max_bw(codec, true);
  2629. break;
  2630. case SND_SOC_DAPM_POST_PMD:
  2631. ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list,
  2632. dai->grph);
  2633. dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n",
  2634. __func__, ret);
  2635. if (!dai->bus_down_in_recovery)
  2636. ret = tasha_codec_enable_slim_chmask(dai, false);
  2637. else
  2638. dev_dbg(codec->dev,
  2639. "%s: bus in recovery skip enable slim_chmask",
  2640. __func__);
  2641. ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2642. dai->grph);
  2643. break;
  2644. }
  2645. return ret;
  2646. }
  2647. static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w,
  2648. struct snd_kcontrol *kcontrol,
  2649. int event)
  2650. {
  2651. struct wcd9xxx *core = NULL;
  2652. struct snd_soc_codec *codec = NULL;
  2653. struct tasha_priv *tasha_p = NULL;
  2654. int ret = 0;
  2655. struct wcd9xxx_codec_dai_data *dai = NULL;
  2656. if (!w) {
  2657. pr_err("%s invalid params\n", __func__);
  2658. return -EINVAL;
  2659. }
  2660. codec = snd_soc_dapm_to_codec(w->dapm);
  2661. tasha_p = snd_soc_codec_get_drvdata(codec);
  2662. core = tasha_p->wcd9xxx;
  2663. dev_dbg(codec->dev, "%s: num_dai %d stream name %s\n",
  2664. __func__, codec->component.num_dai, w->sname);
  2665. /* Execute the callback only if interface type is slimbus */
  2666. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2667. dev_err(codec->dev, "%s Interface is not correct", __func__);
  2668. return 0;
  2669. }
  2670. dev_dbg(codec->dev, "%s(): w->name %s event %d w->shift %d\n",
  2671. __func__, w->name, event, w->shift);
  2672. if (w->shift != AIF4_VIFEED) {
  2673. pr_err("%s Error in enabling the tx path\n", __func__);
  2674. ret = -EINVAL;
  2675. goto out_vi;
  2676. }
  2677. dai = &tasha_p->dai[w->shift];
  2678. switch (event) {
  2679. case SND_SOC_DAPM_POST_PMU:
  2680. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2681. dev_dbg(codec->dev, "%s: spkr1 enabled\n", __func__);
  2682. /* Enable V&I sensing */
  2683. snd_soc_update_bits(codec,
  2684. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2685. snd_soc_update_bits(codec,
  2686. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2687. 0x20);
  2688. snd_soc_update_bits(codec,
  2689. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x00);
  2690. snd_soc_update_bits(codec,
  2691. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x0F,
  2692. 0x00);
  2693. snd_soc_update_bits(codec,
  2694. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10);
  2695. snd_soc_update_bits(codec,
  2696. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2697. 0x10);
  2698. snd_soc_update_bits(codec,
  2699. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00);
  2700. snd_soc_update_bits(codec,
  2701. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2702. 0x00);
  2703. }
  2704. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2705. pr_debug("%s: spkr2 enabled\n", __func__);
  2706. /* Enable V&I sensing */
  2707. snd_soc_update_bits(codec,
  2708. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2709. 0x20);
  2710. snd_soc_update_bits(codec,
  2711. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2712. 0x20);
  2713. snd_soc_update_bits(codec,
  2714. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x0F,
  2715. 0x00);
  2716. snd_soc_update_bits(codec,
  2717. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x0F,
  2718. 0x00);
  2719. snd_soc_update_bits(codec,
  2720. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2721. 0x10);
  2722. snd_soc_update_bits(codec,
  2723. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2724. 0x10);
  2725. snd_soc_update_bits(codec,
  2726. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2727. 0x00);
  2728. snd_soc_update_bits(codec,
  2729. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2730. 0x00);
  2731. }
  2732. dai->bus_down_in_recovery = false;
  2733. tasha_codec_enable_int_port(dai, codec);
  2734. (void) tasha_codec_enable_slim_chmask(dai, true);
  2735. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2736. dai->rate, dai->bit_width,
  2737. &dai->grph);
  2738. break;
  2739. case SND_SOC_DAPM_POST_PMD:
  2740. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2741. dai->grph);
  2742. if (ret)
  2743. dev_err(codec->dev, "%s error in close_slim_sch_tx %d\n",
  2744. __func__, ret);
  2745. if (!dai->bus_down_in_recovery)
  2746. ret = tasha_codec_enable_slim_chmask(dai, false);
  2747. if (ret < 0) {
  2748. ret = wcd9xxx_disconnect_port(core,
  2749. &dai->wcd9xxx_ch_list,
  2750. dai->grph);
  2751. dev_dbg(codec->dev, "%s: Disconnect TX port, ret = %d\n",
  2752. __func__, ret);
  2753. }
  2754. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2755. /* Disable V&I sensing */
  2756. dev_dbg(codec->dev, "%s: spkr1 disabled\n", __func__);
  2757. snd_soc_update_bits(codec,
  2758. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2759. snd_soc_update_bits(codec,
  2760. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2761. 0x20);
  2762. snd_soc_update_bits(codec,
  2763. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00);
  2764. snd_soc_update_bits(codec,
  2765. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2766. 0x00);
  2767. }
  2768. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2769. /* Disable V&I sensing */
  2770. dev_dbg(codec->dev, "%s: spkr2 disabled\n", __func__);
  2771. snd_soc_update_bits(codec,
  2772. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2773. 0x20);
  2774. snd_soc_update_bits(codec,
  2775. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2776. 0x20);
  2777. snd_soc_update_bits(codec,
  2778. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2779. 0x00);
  2780. snd_soc_update_bits(codec,
  2781. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2782. 0x00);
  2783. }
  2784. break;
  2785. }
  2786. out_vi:
  2787. return ret;
  2788. }
  2789. /*
  2790. * __tasha_codec_enable_slimtx: Enable the slimbus slave port
  2791. * for TX path
  2792. * @codec: Handle to the codec for which the slave port is to be
  2793. * enabled.
  2794. * @dai_data: The dai specific data for dai which is enabled.
  2795. */
  2796. static int __tasha_codec_enable_slimtx(struct snd_soc_codec *codec,
  2797. int event, struct wcd9xxx_codec_dai_data *dai)
  2798. {
  2799. struct wcd9xxx *core;
  2800. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2801. int ret = 0;
  2802. /* Execute the callback only if interface type is slimbus */
  2803. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2804. return 0;
  2805. dev_dbg(codec->dev,
  2806. "%s: event = %d\n", __func__, event);
  2807. core = dev_get_drvdata(codec->dev->parent);
  2808. switch (event) {
  2809. case SND_SOC_DAPM_POST_PMU:
  2810. dai->bus_down_in_recovery = false;
  2811. tasha_codec_enable_int_port(dai, codec);
  2812. (void) tasha_codec_enable_slim_chmask(dai, true);
  2813. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2814. dai->rate, dai->bit_width,
  2815. &dai->grph);
  2816. break;
  2817. case SND_SOC_DAPM_POST_PMD:
  2818. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2819. dai->grph);
  2820. if (!dai->bus_down_in_recovery)
  2821. ret = tasha_codec_enable_slim_chmask(dai, false);
  2822. if (ret < 0) {
  2823. ret = wcd9xxx_disconnect_port(core,
  2824. &dai->wcd9xxx_ch_list,
  2825. dai->grph);
  2826. pr_debug("%s: Disconnect TX port, ret = %d\n",
  2827. __func__, ret);
  2828. }
  2829. break;
  2830. }
  2831. return ret;
  2832. }
  2833. static int tasha_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
  2834. struct snd_kcontrol *kcontrol,
  2835. int event)
  2836. {
  2837. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2838. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2839. struct wcd9xxx_codec_dai_data *dai;
  2840. dev_dbg(codec->dev,
  2841. "%s: w->name %s, w->shift = %d, num_dai %d stream name %s\n",
  2842. __func__, w->name, w->shift,
  2843. codec->component.num_dai, w->sname);
  2844. dai = &tasha_p->dai[w->shift];
  2845. return __tasha_codec_enable_slimtx(codec, event, dai);
  2846. }
  2847. static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_codec *codec, int event)
  2848. {
  2849. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2850. struct wcd9xxx_codec_dai_data *dai;
  2851. u8 bit_width, rate, buf_period;
  2852. dai = &tasha_p->dai[AIF4_MAD_TX];
  2853. switch (event) {
  2854. case SND_SOC_DAPM_POST_PMU:
  2855. switch (dai->bit_width) {
  2856. case 32:
  2857. bit_width = 0xF;
  2858. break;
  2859. case 24:
  2860. bit_width = 0xE;
  2861. break;
  2862. case 20:
  2863. bit_width = 0xD;
  2864. break;
  2865. case 16:
  2866. default:
  2867. bit_width = 0x0;
  2868. break;
  2869. }
  2870. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x0F,
  2871. bit_width);
  2872. switch (dai->rate) {
  2873. case 384000:
  2874. rate = 0x30;
  2875. break;
  2876. case 192000:
  2877. rate = 0x20;
  2878. break;
  2879. case 48000:
  2880. rate = 0x10;
  2881. break;
  2882. case 16000:
  2883. default:
  2884. rate = 0x00;
  2885. break;
  2886. }
  2887. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x70,
  2888. rate);
  2889. buf_period = (dai->rate * (dai->bit_width/8)) / (16*1000);
  2890. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD,
  2891. 0xFF, buf_period);
  2892. dev_dbg(codec->dev, "%s: PP buffer period= 0x%x\n",
  2893. __func__, buf_period);
  2894. break;
  2895. case SND_SOC_DAPM_POST_PMD:
  2896. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x3C);
  2897. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD, 0x60);
  2898. break;
  2899. default:
  2900. break;
  2901. }
  2902. }
  2903. /*
  2904. * tasha_codec_get_mad_port_id: Callback function that will be invoked
  2905. * to get the port ID for MAD.
  2906. * @codec: Handle to the codec
  2907. * @port_id: cpe port_id needs to enable
  2908. */
  2909. static int tasha_codec_get_mad_port_id(struct snd_soc_codec *codec,
  2910. u16 *port_id)
  2911. {
  2912. struct tasha_priv *tasha_p;
  2913. struct wcd9xxx_codec_dai_data *dai;
  2914. struct wcd9xxx_ch *ch;
  2915. if (!port_id || !codec)
  2916. return -EINVAL;
  2917. tasha_p = snd_soc_codec_get_drvdata(codec);
  2918. if (!tasha_p)
  2919. return -EINVAL;
  2920. dai = &tasha_p->dai[AIF4_MAD_TX];
  2921. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2922. if (ch->port == TASHA_TX12)
  2923. *port_id = WCD_CPE_AFE_OUT_PORT_2;
  2924. else if (ch->port == TASHA_TX13)
  2925. *port_id = WCD_CPE_AFE_OUT_PORT_4;
  2926. else {
  2927. dev_err(codec->dev, "%s: invalid mad_port = %d\n",
  2928. __func__, ch->port);
  2929. return -EINVAL;
  2930. }
  2931. }
  2932. dev_dbg(codec->dev, "%s: port_id = %d\n", __func__, *port_id);
  2933. return 0;
  2934. }
  2935. /*
  2936. * tasha_codec_enable_slimtx_mad: Callback function that will be invoked
  2937. * to setup the slave port for MAD.
  2938. * @codec: Handle to the codec
  2939. * @event: Indicates whether to enable or disable the slave port
  2940. */
  2941. static int tasha_codec_enable_slimtx_mad(struct snd_soc_codec *codec,
  2942. u8 event)
  2943. {
  2944. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2945. struct wcd9xxx_codec_dai_data *dai;
  2946. struct wcd9xxx_ch *ch;
  2947. int dapm_event = SND_SOC_DAPM_POST_PMU;
  2948. u16 port = 0;
  2949. int ret = 0;
  2950. dai = &tasha_p->dai[AIF4_MAD_TX];
  2951. if (event == 0)
  2952. dapm_event = SND_SOC_DAPM_POST_PMD;
  2953. dev_dbg(codec->dev,
  2954. "%s: mad_channel, event = 0x%x\n",
  2955. __func__, event);
  2956. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2957. dev_dbg(codec->dev, "%s: mad_port = %d, event = 0x%x\n",
  2958. __func__, ch->port, event);
  2959. if (ch->port == TASHA_TX13) {
  2960. tasha_codec_cpe_pp_set_cfg(codec, dapm_event);
  2961. port = TASHA_TX13;
  2962. break;
  2963. }
  2964. }
  2965. ret = __tasha_codec_enable_slimtx(codec, dapm_event, dai);
  2966. if (port == TASHA_TX13) {
  2967. switch (dapm_event) {
  2968. case SND_SOC_DAPM_POST_PMU:
  2969. snd_soc_update_bits(codec,
  2970. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2971. 0x20, 0x00);
  2972. snd_soc_update_bits(codec,
  2973. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2974. 0x03, 0x02);
  2975. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2976. 0x80, 0x80);
  2977. break;
  2978. case SND_SOC_DAPM_POST_PMD:
  2979. snd_soc_update_bits(codec,
  2980. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2981. 0x20, 0x20);
  2982. snd_soc_update_bits(codec,
  2983. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2984. 0x03, 0x00);
  2985. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2986. 0x80, 0x00);
  2987. break;
  2988. }
  2989. }
  2990. return ret;
  2991. }
  2992. static int tasha_put_iir_band_audio_mixer(
  2993. struct snd_kcontrol *kcontrol,
  2994. struct snd_ctl_elem_value *ucontrol)
  2995. {
  2996. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2997. int iir_idx = ((struct soc_multi_mixer_control *)
  2998. kcontrol->private_value)->reg;
  2999. int band_idx = ((struct soc_multi_mixer_control *)
  3000. kcontrol->private_value)->shift;
  3001. /*
  3002. * Mask top bit it is reserved
  3003. * Updates addr automatically for each B2 write
  3004. */
  3005. snd_soc_write(codec,
  3006. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  3007. (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
  3008. set_iir_band_coeff(codec, iir_idx, band_idx,
  3009. ucontrol->value.integer.value[0]);
  3010. set_iir_band_coeff(codec, iir_idx, band_idx,
  3011. ucontrol->value.integer.value[1]);
  3012. set_iir_band_coeff(codec, iir_idx, band_idx,
  3013. ucontrol->value.integer.value[2]);
  3014. set_iir_band_coeff(codec, iir_idx, band_idx,
  3015. ucontrol->value.integer.value[3]);
  3016. set_iir_band_coeff(codec, iir_idx, band_idx,
  3017. ucontrol->value.integer.value[4]);
  3018. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  3019. "%s: IIR #%d band #%d b1 = 0x%x\n"
  3020. "%s: IIR #%d band #%d b2 = 0x%x\n"
  3021. "%s: IIR #%d band #%d a1 = 0x%x\n"
  3022. "%s: IIR #%d band #%d a2 = 0x%x\n",
  3023. __func__, iir_idx, band_idx,
  3024. get_iir_band_coeff(codec, iir_idx, band_idx, 0),
  3025. __func__, iir_idx, band_idx,
  3026. get_iir_band_coeff(codec, iir_idx, band_idx, 1),
  3027. __func__, iir_idx, band_idx,
  3028. get_iir_band_coeff(codec, iir_idx, band_idx, 2),
  3029. __func__, iir_idx, band_idx,
  3030. get_iir_band_coeff(codec, iir_idx, band_idx, 3),
  3031. __func__, iir_idx, band_idx,
  3032. get_iir_band_coeff(codec, iir_idx, band_idx, 4));
  3033. return 0;
  3034. }
  3035. static int tasha_get_compander(struct snd_kcontrol *kcontrol,
  3036. struct snd_ctl_elem_value *ucontrol)
  3037. {
  3038. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3039. int comp = ((struct soc_multi_mixer_control *)
  3040. kcontrol->private_value)->shift;
  3041. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3042. ucontrol->value.integer.value[0] = tasha->comp_enabled[comp];
  3043. return 0;
  3044. }
  3045. static int tasha_set_compander(struct snd_kcontrol *kcontrol,
  3046. struct snd_ctl_elem_value *ucontrol)
  3047. {
  3048. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3049. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3050. int comp = ((struct soc_multi_mixer_control *)
  3051. kcontrol->private_value)->shift;
  3052. int value = ucontrol->value.integer.value[0];
  3053. pr_debug("%s: Compander %d enable current %d, new %d\n",
  3054. __func__, comp + 1, tasha->comp_enabled[comp], value);
  3055. tasha->comp_enabled[comp] = value;
  3056. /* Any specific register configuration for compander */
  3057. switch (comp) {
  3058. case COMPANDER_1:
  3059. /* Set Gain Source Select based on compander enable/disable */
  3060. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0x20,
  3061. (value ? 0x00:0x20));
  3062. break;
  3063. case COMPANDER_2:
  3064. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0x20,
  3065. (value ? 0x00:0x20));
  3066. break;
  3067. case COMPANDER_3:
  3068. break;
  3069. case COMPANDER_4:
  3070. break;
  3071. case COMPANDER_5:
  3072. snd_soc_update_bits(codec, WCD9335_SE_LO_LO3_GAIN, 0x20,
  3073. (value ? 0x00:0x20));
  3074. break;
  3075. case COMPANDER_6:
  3076. snd_soc_update_bits(codec, WCD9335_SE_LO_LO4_GAIN, 0x20,
  3077. (value ? 0x00:0x20));
  3078. break;
  3079. case COMPANDER_7:
  3080. break;
  3081. case COMPANDER_8:
  3082. break;
  3083. default:
  3084. /*
  3085. * if compander is not enabled for any interpolator,
  3086. * it does not cause any audio failure, so do not
  3087. * return error in this case, but just print a log
  3088. */
  3089. dev_warn(codec->dev, "%s: unknown compander: %d\n",
  3090. __func__, comp);
  3091. };
  3092. return 0;
  3093. }
  3094. static void tasha_codec_init_flyback(struct snd_soc_codec *codec)
  3095. {
  3096. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x00);
  3097. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x00);
  3098. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0x0F, 0x00);
  3099. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0xF0, 0x00);
  3100. }
  3101. static int tasha_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
  3102. struct snd_kcontrol *kcontrol, int event)
  3103. {
  3104. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3105. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3106. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3107. switch (event) {
  3108. case SND_SOC_DAPM_PRE_PMU:
  3109. tasha->rx_bias_count++;
  3110. if (tasha->rx_bias_count == 1) {
  3111. if (TASHA_IS_2_0(tasha->wcd9xxx))
  3112. tasha_codec_init_flyback(codec);
  3113. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3114. 0x01, 0x01);
  3115. }
  3116. break;
  3117. case SND_SOC_DAPM_POST_PMD:
  3118. tasha->rx_bias_count--;
  3119. if (!tasha->rx_bias_count)
  3120. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3121. 0x01, 0x00);
  3122. break;
  3123. };
  3124. dev_dbg(codec->dev, "%s: Current RX BIAS user count: %d\n", __func__,
  3125. tasha->rx_bias_count);
  3126. return 0;
  3127. }
  3128. static void tasha_realign_anc_coeff(struct snd_soc_codec *codec,
  3129. u16 reg1, u16 reg2)
  3130. {
  3131. u8 val1, val2, tmpval1, tmpval2;
  3132. snd_soc_write(codec, reg1, 0x00);
  3133. tmpval1 = snd_soc_read(codec, reg2);
  3134. tmpval2 = snd_soc_read(codec, reg2);
  3135. snd_soc_write(codec, reg1, 0x00);
  3136. snd_soc_write(codec, reg2, 0xFF);
  3137. snd_soc_write(codec, reg1, 0x01);
  3138. snd_soc_write(codec, reg2, 0xFF);
  3139. snd_soc_write(codec, reg1, 0x00);
  3140. val1 = snd_soc_read(codec, reg2);
  3141. val2 = snd_soc_read(codec, reg2);
  3142. if (val1 == 0x0F && val2 == 0xFF) {
  3143. dev_dbg(codec->dev, "%s: ANC0 co-eff index re-aligned\n",
  3144. __func__);
  3145. snd_soc_read(codec, reg2);
  3146. snd_soc_write(codec, reg1, 0x00);
  3147. snd_soc_write(codec, reg2, tmpval2);
  3148. snd_soc_write(codec, reg1, 0x01);
  3149. snd_soc_write(codec, reg2, tmpval1);
  3150. } else if (val1 == 0xFF && val2 == 0x0F) {
  3151. dev_dbg(codec->dev, "%s: ANC1 co-eff index already aligned\n",
  3152. __func__);
  3153. snd_soc_write(codec, reg1, 0x00);
  3154. snd_soc_write(codec, reg2, tmpval1);
  3155. snd_soc_write(codec, reg1, 0x01);
  3156. snd_soc_write(codec, reg2, tmpval2);
  3157. } else {
  3158. dev_err(codec->dev, "%s: ANC0 co-eff index not aligned\n",
  3159. __func__);
  3160. }
  3161. }
  3162. static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w,
  3163. struct snd_kcontrol *kcontrol, int event)
  3164. {
  3165. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3166. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3167. const char *filename;
  3168. const struct firmware *fw;
  3169. int i;
  3170. int ret = 0;
  3171. int num_anc_slots;
  3172. struct wcd9xxx_anc_header *anc_head;
  3173. struct firmware_cal *hwdep_cal = NULL;
  3174. u32 anc_writes_size = 0;
  3175. u32 anc_cal_size = 0;
  3176. int anc_size_remaining;
  3177. u32 *anc_ptr;
  3178. u16 reg;
  3179. u8 mask, val;
  3180. size_t cal_size;
  3181. const void *data;
  3182. if (!tasha->anc_func)
  3183. return 0;
  3184. switch (event) {
  3185. case SND_SOC_DAPM_PRE_PMU:
  3186. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_ANC_CAL);
  3187. if (hwdep_cal) {
  3188. data = hwdep_cal->data;
  3189. cal_size = hwdep_cal->size;
  3190. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  3191. __func__);
  3192. } else {
  3193. filename = "wcd9335/wcd9335_anc.bin";
  3194. ret = request_firmware(&fw, filename, codec->dev);
  3195. if (ret != 0) {
  3196. dev_err(codec->dev,
  3197. "Failed to acquire ANC data: %d\n", ret);
  3198. return -ENODEV;
  3199. }
  3200. if (!fw) {
  3201. dev_err(codec->dev, "failed to get anc fw");
  3202. return -ENODEV;
  3203. }
  3204. data = fw->data;
  3205. cal_size = fw->size;
  3206. dev_dbg(codec->dev,
  3207. "%s: using request_firmware calibration\n", __func__);
  3208. }
  3209. if (cal_size < sizeof(struct wcd9xxx_anc_header)) {
  3210. dev_err(codec->dev, "Not enough data\n");
  3211. ret = -ENOMEM;
  3212. goto err;
  3213. }
  3214. /* First number is the number of register writes */
  3215. anc_head = (struct wcd9xxx_anc_header *)(data);
  3216. anc_ptr = (u32 *)(data +
  3217. sizeof(struct wcd9xxx_anc_header));
  3218. anc_size_remaining = cal_size -
  3219. sizeof(struct wcd9xxx_anc_header);
  3220. num_anc_slots = anc_head->num_anc_slots;
  3221. if (tasha->anc_slot >= num_anc_slots) {
  3222. dev_err(codec->dev, "Invalid ANC slot selected\n");
  3223. ret = -EINVAL;
  3224. goto err;
  3225. }
  3226. for (i = 0; i < num_anc_slots; i++) {
  3227. if (anc_size_remaining < TASHA_PACKED_REG_SIZE) {
  3228. dev_err(codec->dev,
  3229. "Invalid register format\n");
  3230. ret = -EINVAL;
  3231. goto err;
  3232. }
  3233. anc_writes_size = (u32)(*anc_ptr);
  3234. anc_size_remaining -= sizeof(u32);
  3235. anc_ptr += 1;
  3236. if (anc_writes_size * TASHA_PACKED_REG_SIZE
  3237. > anc_size_remaining) {
  3238. dev_err(codec->dev,
  3239. "Invalid register format\n");
  3240. ret = -EINVAL;
  3241. goto err;
  3242. }
  3243. if (tasha->anc_slot == i)
  3244. break;
  3245. anc_size_remaining -= (anc_writes_size *
  3246. TASHA_PACKED_REG_SIZE);
  3247. anc_ptr += anc_writes_size;
  3248. }
  3249. if (i == num_anc_slots) {
  3250. dev_err(codec->dev, "Selected ANC slot not present\n");
  3251. ret = -EINVAL;
  3252. goto err;
  3253. }
  3254. i = 0;
  3255. anc_cal_size = anc_writes_size;
  3256. if (!strcmp(w->name, "RX INT0 DAC") ||
  3257. !strcmp(w->name, "ANC SPK1 PA"))
  3258. tasha_realign_anc_coeff(codec,
  3259. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3260. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3261. if (!strcmp(w->name, "RX INT1 DAC") ||
  3262. !strcmp(w->name, "RX INT3 DAC")) {
  3263. tasha_realign_anc_coeff(codec,
  3264. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3265. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3266. anc_writes_size = anc_cal_size / 2;
  3267. snd_soc_update_bits(codec,
  3268. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x39, 0x39);
  3269. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3270. !strcmp(w->name, "RX INT4 DAC")) {
  3271. tasha_realign_anc_coeff(codec,
  3272. WCD9335_CDC_ANC1_IIR_COEFF_1_CTL,
  3273. WCD9335_CDC_ANC1_IIR_COEFF_2_CTL);
  3274. i = anc_cal_size / 2;
  3275. snd_soc_update_bits(codec,
  3276. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x39, 0x39);
  3277. }
  3278. for (; i < anc_writes_size; i++) {
  3279. TASHA_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val);
  3280. snd_soc_write(codec, reg, (val & mask));
  3281. }
  3282. if (!strcmp(w->name, "RX INT1 DAC") ||
  3283. !strcmp(w->name, "RX INT3 DAC")) {
  3284. snd_soc_update_bits(codec,
  3285. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08);
  3286. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3287. !strcmp(w->name, "RX INT4 DAC")) {
  3288. snd_soc_update_bits(codec,
  3289. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08);
  3290. }
  3291. if (!hwdep_cal)
  3292. release_firmware(fw);
  3293. break;
  3294. case SND_SOC_DAPM_POST_PMU:
  3295. /* Remove ANC Rx from reset */
  3296. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_CLK_RESET_CTL,
  3297. 0x08, 0x00);
  3298. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_CLK_RESET_CTL,
  3299. 0x08, 0x00);
  3300. break;
  3301. case SND_SOC_DAPM_POST_PMD:
  3302. if (!strcmp(w->name, "ANC HPHL PA") ||
  3303. !strcmp(w->name, "ANC EAR PA") ||
  3304. !strcmp(w->name, "ANC SPK1 PA") ||
  3305. !strcmp(w->name, "ANC LINEOUT1 PA")) {
  3306. snd_soc_update_bits(codec,
  3307. WCD9335_CDC_ANC0_MODE_1_CTL, 0x30, 0x00);
  3308. msleep(50);
  3309. snd_soc_update_bits(codec,
  3310. WCD9335_CDC_ANC0_MODE_1_CTL, 0x01, 0x00);
  3311. snd_soc_update_bits(codec,
  3312. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x38);
  3313. snd_soc_update_bits(codec,
  3314. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x07, 0x00);
  3315. snd_soc_update_bits(codec,
  3316. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x00);
  3317. } else if (!strcmp(w->name, "ANC HPHR PA") ||
  3318. !strcmp(w->name, "ANC LINEOUT2 PA")) {
  3319. snd_soc_update_bits(codec,
  3320. WCD9335_CDC_ANC1_MODE_1_CTL, 0x30, 0x00);
  3321. msleep(50);
  3322. snd_soc_update_bits(codec,
  3323. WCD9335_CDC_ANC1_MODE_1_CTL, 0x01, 0x00);
  3324. snd_soc_update_bits(codec,
  3325. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x38);
  3326. snd_soc_update_bits(codec,
  3327. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x07, 0x00);
  3328. snd_soc_update_bits(codec,
  3329. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x00);
  3330. }
  3331. break;
  3332. }
  3333. return 0;
  3334. err:
  3335. if (!hwdep_cal)
  3336. release_firmware(fw);
  3337. return ret;
  3338. }
  3339. static void tasha_codec_clear_anc_tx_hold(struct tasha_priv *tasha)
  3340. {
  3341. if (test_and_clear_bit(ANC_MIC_AMIC1, &tasha->status_mask))
  3342. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC1, false);
  3343. if (test_and_clear_bit(ANC_MIC_AMIC2, &tasha->status_mask))
  3344. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC2, false);
  3345. if (test_and_clear_bit(ANC_MIC_AMIC3, &tasha->status_mask))
  3346. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC3, false);
  3347. if (test_and_clear_bit(ANC_MIC_AMIC4, &tasha->status_mask))
  3348. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC4, false);
  3349. if (test_and_clear_bit(ANC_MIC_AMIC5, &tasha->status_mask))
  3350. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC5, false);
  3351. if (test_and_clear_bit(ANC_MIC_AMIC6, &tasha->status_mask))
  3352. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC6, false);
  3353. }
  3354. static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha,
  3355. int mode, int event)
  3356. {
  3357. u8 scale_val = 0;
  3358. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3359. return;
  3360. switch (event) {
  3361. case SND_SOC_DAPM_POST_PMU:
  3362. switch (mode) {
  3363. case CLS_H_HIFI:
  3364. scale_val = 0x3;
  3365. break;
  3366. case CLS_H_LOHIFI:
  3367. scale_val = 0x1;
  3368. break;
  3369. }
  3370. if (tasha->anc_func) {
  3371. /* Clear Tx FE HOLD if both PAs are enabled */
  3372. if ((snd_soc_read(tasha->codec, WCD9335_ANA_HPH) &
  3373. 0xC0) == 0xC0) {
  3374. tasha_codec_clear_anc_tx_hold(tasha);
  3375. }
  3376. }
  3377. break;
  3378. case SND_SOC_DAPM_PRE_PMD:
  3379. scale_val = 0x6;
  3380. break;
  3381. }
  3382. if (scale_val)
  3383. snd_soc_update_bits(tasha->codec, WCD9335_HPH_PA_CTL1, 0x0E,
  3384. scale_val << 1);
  3385. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3386. if (tasha->comp_enabled[COMPANDER_1] ||
  3387. tasha->comp_enabled[COMPANDER_2]) {
  3388. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN,
  3389. 0x20, 0x00);
  3390. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN,
  3391. 0x20, 0x00);
  3392. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP,
  3393. 0x20, 0x20);
  3394. }
  3395. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN, 0x1F,
  3396. tasha->hph_l_gain);
  3397. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN, 0x1F,
  3398. tasha->hph_r_gain);
  3399. }
  3400. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3401. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP, 0x20,
  3402. 0x00);
  3403. }
  3404. }
  3405. static void tasha_codec_override(struct snd_soc_codec *codec,
  3406. int mode,
  3407. int event)
  3408. {
  3409. if (mode == CLS_AB) {
  3410. switch (event) {
  3411. case SND_SOC_DAPM_POST_PMU:
  3412. if (!(snd_soc_read(codec,
  3413. WCD9335_CDC_RX2_RX_PATH_CTL) & 0x10) &&
  3414. (!(snd_soc_read(codec,
  3415. WCD9335_CDC_RX1_RX_PATH_CTL) & 0x10)))
  3416. snd_soc_update_bits(codec,
  3417. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x02);
  3418. break;
  3419. case SND_SOC_DAPM_POST_PMD:
  3420. snd_soc_update_bits(codec,
  3421. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00);
  3422. break;
  3423. }
  3424. }
  3425. }
  3426. static int tasha_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
  3427. struct snd_kcontrol *kcontrol,
  3428. int event)
  3429. {
  3430. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3431. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3432. int hph_mode = tasha->hph_mode;
  3433. int ret = 0;
  3434. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3435. switch (event) {
  3436. case SND_SOC_DAPM_PRE_PMU:
  3437. if ((!(strcmp(w->name, "ANC HPHR PA"))) &&
  3438. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3439. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3440. }
  3441. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3442. break;
  3443. case SND_SOC_DAPM_POST_PMU:
  3444. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3445. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3446. != 0xC0)
  3447. /*
  3448. * If PA_EN is not set (potentially in ANC case)
  3449. * then do nothing for POST_PMU and let left
  3450. * channel handle everything.
  3451. */
  3452. break;
  3453. }
  3454. /*
  3455. * 7ms sleep is required after PA is enabled as per
  3456. * HW requirement
  3457. */
  3458. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3459. usleep_range(7000, 7100);
  3460. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3461. }
  3462. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3463. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3464. 0x10, 0x00);
  3465. /* Remove mix path mute if it is enabled */
  3466. if ((snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3467. 0x10)
  3468. snd_soc_update_bits(codec,
  3469. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3470. 0x10, 0x00);
  3471. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3472. /* Do everything needed for left channel */
  3473. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3474. 0x10, 0x00);
  3475. /* Remove mix path mute if it is enabled */
  3476. if ((snd_soc_read(codec,
  3477. WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3478. 0x10)
  3479. snd_soc_update_bits(codec,
  3480. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3481. 0x10, 0x00);
  3482. /* Remove ANC Rx from reset */
  3483. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3484. }
  3485. tasha_codec_override(codec, hph_mode, event);
  3486. break;
  3487. case SND_SOC_DAPM_PRE_PMD:
  3488. blocking_notifier_call_chain(&tasha->notifier,
  3489. WCD_EVENT_PRE_HPHR_PA_OFF,
  3490. &tasha->mbhc);
  3491. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3492. if (!(strcmp(w->name, "ANC HPHR PA")))
  3493. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x00);
  3494. break;
  3495. case SND_SOC_DAPM_POST_PMD:
  3496. /* 5ms sleep is required after PA is disabled as per
  3497. * HW requirement
  3498. */
  3499. usleep_range(5000, 5500);
  3500. tasha_codec_override(codec, hph_mode, event);
  3501. blocking_notifier_call_chain(&tasha->notifier,
  3502. WCD_EVENT_POST_HPHR_PA_OFF,
  3503. &tasha->mbhc);
  3504. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3505. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3506. snd_soc_update_bits(codec,
  3507. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x00);
  3508. }
  3509. break;
  3510. };
  3511. return ret;
  3512. }
  3513. static int tasha_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
  3514. struct snd_kcontrol *kcontrol,
  3515. int event)
  3516. {
  3517. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3518. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3519. int hph_mode = tasha->hph_mode;
  3520. int ret = 0;
  3521. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3522. switch (event) {
  3523. case SND_SOC_DAPM_PRE_PMU:
  3524. if ((!(strcmp(w->name, "ANC HPHL PA"))) &&
  3525. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3526. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3527. }
  3528. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3529. break;
  3530. case SND_SOC_DAPM_POST_PMU:
  3531. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3532. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3533. != 0xC0)
  3534. /*
  3535. * If PA_EN is not set (potentially in ANC case)
  3536. * then do nothing for POST_PMU and let right
  3537. * channel handle everything.
  3538. */
  3539. break;
  3540. }
  3541. /*
  3542. * 7ms sleep is required after PA is enabled as per
  3543. * HW requirement
  3544. */
  3545. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3546. usleep_range(7000, 7100);
  3547. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3548. }
  3549. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3550. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3551. 0x10, 0x00);
  3552. /* Remove mix path mute if it is enabled */
  3553. if ((snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3554. 0x10)
  3555. snd_soc_update_bits(codec,
  3556. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3557. 0x10, 0x00);
  3558. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3559. /* Do everything needed for right channel */
  3560. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3561. 0x10, 0x00);
  3562. /* Remove mix path mute if it is enabled */
  3563. if ((snd_soc_read(codec,
  3564. WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3565. 0x10)
  3566. snd_soc_update_bits(codec,
  3567. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3568. 0x10, 0x00);
  3569. /* Remove ANC Rx from reset */
  3570. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3571. }
  3572. tasha_codec_override(codec, hph_mode, event);
  3573. break;
  3574. case SND_SOC_DAPM_PRE_PMD:
  3575. blocking_notifier_call_chain(&tasha->notifier,
  3576. WCD_EVENT_PRE_HPHL_PA_OFF,
  3577. &tasha->mbhc);
  3578. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3579. if (!(strcmp(w->name, "ANC HPHL PA")))
  3580. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x00);
  3581. break;
  3582. case SND_SOC_DAPM_POST_PMD:
  3583. /* 5ms sleep is required after PA is disabled as per
  3584. * HW requirement
  3585. */
  3586. usleep_range(5000, 5500);
  3587. tasha_codec_override(codec, hph_mode, event);
  3588. blocking_notifier_call_chain(&tasha->notifier,
  3589. WCD_EVENT_POST_HPHL_PA_OFF,
  3590. &tasha->mbhc);
  3591. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3592. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3593. snd_soc_update_bits(codec,
  3594. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00);
  3595. }
  3596. break;
  3597. };
  3598. return ret;
  3599. }
  3600. static int tasha_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w,
  3601. struct snd_kcontrol *kcontrol,
  3602. int event)
  3603. {
  3604. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3605. u16 lineout_vol_reg = 0, lineout_mix_vol_reg = 0;
  3606. int ret = 0;
  3607. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3608. if (w->reg == WCD9335_ANA_LO_1_2) {
  3609. if (w->shift == 7) {
  3610. lineout_vol_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  3611. lineout_mix_vol_reg = WCD9335_CDC_RX3_RX_PATH_MIX_CTL;
  3612. } else if (w->shift == 6) {
  3613. lineout_vol_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  3614. lineout_mix_vol_reg = WCD9335_CDC_RX4_RX_PATH_MIX_CTL;
  3615. }
  3616. } else if (w->reg == WCD9335_ANA_LO_3_4) {
  3617. if (w->shift == 7) {
  3618. lineout_vol_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  3619. lineout_mix_vol_reg = WCD9335_CDC_RX5_RX_PATH_MIX_CTL;
  3620. } else if (w->shift == 6) {
  3621. lineout_vol_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  3622. lineout_mix_vol_reg = WCD9335_CDC_RX6_RX_PATH_MIX_CTL;
  3623. }
  3624. } else {
  3625. dev_err(codec->dev, "%s: Error enabling lineout PA\n",
  3626. __func__);
  3627. return -EINVAL;
  3628. }
  3629. switch (event) {
  3630. case SND_SOC_DAPM_POST_PMU:
  3631. /* 5ms sleep is required after PA is enabled as per
  3632. * HW requirement
  3633. */
  3634. usleep_range(5000, 5500);
  3635. snd_soc_update_bits(codec, lineout_vol_reg,
  3636. 0x10, 0x00);
  3637. /* Remove mix path mute if it is enabled */
  3638. if ((snd_soc_read(codec, lineout_mix_vol_reg)) & 0x10)
  3639. snd_soc_update_bits(codec,
  3640. lineout_mix_vol_reg,
  3641. 0x10, 0x00);
  3642. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3643. !(strcmp(w->name, "ANC LINEOUT2 PA")))
  3644. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3645. tasha_codec_override(codec, CLS_AB, event);
  3646. break;
  3647. case SND_SOC_DAPM_POST_PMD:
  3648. /* 5ms sleep is required after PA is disabled as per
  3649. * HW requirement
  3650. */
  3651. usleep_range(5000, 5500);
  3652. tasha_codec_override(codec, CLS_AB, event);
  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. if (!(strcmp(w->name, "ANC LINEOUT1 PA")))
  3657. snd_soc_update_bits(codec,
  3658. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  3659. else
  3660. snd_soc_update_bits(codec,
  3661. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  3662. }
  3663. break;
  3664. };
  3665. return ret;
  3666. }
  3667. static void tasha_spk_anc_update_callback(struct work_struct *work)
  3668. {
  3669. struct spk_anc_work *spk_anc_dwork;
  3670. struct tasha_priv *tasha;
  3671. struct delayed_work *delayed_work;
  3672. struct snd_soc_codec *codec;
  3673. delayed_work = to_delayed_work(work);
  3674. spk_anc_dwork = container_of(delayed_work, struct spk_anc_work, dwork);
  3675. tasha = spk_anc_dwork->tasha;
  3676. codec = tasha->codec;
  3677. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0, 0x10, 0x10);
  3678. }
  3679. static int tasha_codec_enable_spk_anc(struct snd_soc_dapm_widget *w,
  3680. struct snd_kcontrol *kcontrol,
  3681. int event)
  3682. {
  3683. int ret = 0;
  3684. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3685. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3686. dev_dbg(codec->dev, "%s %s %d %d\n", __func__, w->name, event,
  3687. tasha->anc_func);
  3688. if (!tasha->anc_func)
  3689. return 0;
  3690. switch (event) {
  3691. case SND_SOC_DAPM_PRE_PMU:
  3692. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3693. schedule_delayed_work(&tasha->spk_anc_dwork.dwork,
  3694. msecs_to_jiffies(spk_anc_en_delay));
  3695. break;
  3696. case SND_SOC_DAPM_POST_PMD:
  3697. cancel_delayed_work_sync(&tasha->spk_anc_dwork.dwork);
  3698. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0,
  3699. 0x10, 0x00);
  3700. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3701. break;
  3702. }
  3703. return ret;
  3704. }
  3705. static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
  3706. struct snd_kcontrol *kcontrol,
  3707. int event)
  3708. {
  3709. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3710. int ret = 0;
  3711. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3712. switch (event) {
  3713. case SND_SOC_DAPM_POST_PMU:
  3714. /* 5ms sleep is required after PA is enabled as per
  3715. * HW requirement
  3716. */
  3717. usleep_range(5000, 5500);
  3718. snd_soc_update_bits(codec, WCD9335_CDC_RX0_RX_PATH_CTL,
  3719. 0x10, 0x00);
  3720. /* Remove mix path mute if it is enabled */
  3721. if ((snd_soc_read(codec, WCD9335_CDC_RX0_RX_PATH_MIX_CTL)) &
  3722. 0x10)
  3723. snd_soc_update_bits(codec,
  3724. WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  3725. 0x10, 0x00);
  3726. break;
  3727. case SND_SOC_DAPM_POST_PMD:
  3728. /* 5ms sleep is required after PA is disabled as per
  3729. * HW requirement
  3730. */
  3731. usleep_range(5000, 5500);
  3732. if (!(strcmp(w->name, "ANC EAR PA"))) {
  3733. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3734. snd_soc_update_bits(codec,
  3735. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x00);
  3736. }
  3737. break;
  3738. };
  3739. return ret;
  3740. }
  3741. static void tasha_codec_hph_mode_gain_opt(struct snd_soc_codec *codec,
  3742. u8 gain)
  3743. {
  3744. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3745. u8 hph_l_en, hph_r_en;
  3746. u8 l_val, r_val;
  3747. u8 hph_pa_status;
  3748. bool is_hphl_pa, is_hphr_pa;
  3749. hph_pa_status = snd_soc_read(codec, WCD9335_ANA_HPH);
  3750. is_hphl_pa = hph_pa_status >> 7;
  3751. is_hphr_pa = (hph_pa_status & 0x40) >> 6;
  3752. hph_l_en = snd_soc_read(codec, WCD9335_HPH_L_EN);
  3753. hph_r_en = snd_soc_read(codec, WCD9335_HPH_R_EN);
  3754. l_val = (hph_l_en & 0xC0) | 0x20 | gain;
  3755. r_val = (hph_r_en & 0xC0) | 0x20 | gain;
  3756. /*
  3757. * Set HPH_L & HPH_R gain source selection to REGISTER
  3758. * for better click and pop only if corresponding PAs are
  3759. * not enabled. Also cache the values of the HPHL/R
  3760. * PA gains to be applied after PAs are enabled
  3761. */
  3762. if ((l_val != hph_l_en) && !is_hphl_pa) {
  3763. snd_soc_write(codec, WCD9335_HPH_L_EN, l_val);
  3764. tasha->hph_l_gain = hph_l_en & 0x1F;
  3765. }
  3766. if ((r_val != hph_r_en) && !is_hphr_pa) {
  3767. snd_soc_write(codec, WCD9335_HPH_R_EN, r_val);
  3768. tasha->hph_r_gain = hph_r_en & 0x1F;
  3769. }
  3770. }
  3771. static void tasha_codec_hph_lohifi_config(struct snd_soc_codec *codec,
  3772. int event)
  3773. {
  3774. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3775. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x06);
  3776. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2,
  3777. 0xF0, 0x40);
  3778. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3779. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3780. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3781. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3782. }
  3783. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3784. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3785. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3786. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A);
  3787. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x0A);
  3788. }
  3789. }
  3790. static void tasha_codec_hph_lp_config(struct snd_soc_codec *codec,
  3791. int event)
  3792. {
  3793. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3794. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3795. tasha_codec_hph_mode_gain_opt(codec, 0x10);
  3796. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3797. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3798. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x04);
  3799. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x20);
  3800. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x07,
  3801. 0x01);
  3802. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x70,
  3803. 0x10);
  3804. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3805. 0x0F, 0x01);
  3806. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3807. 0xF0, 0x10);
  3808. }
  3809. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3810. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x88);
  3811. snd_soc_write(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x33);
  3812. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x00);
  3813. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x00);
  3814. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3815. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3816. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x80);
  3817. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x80);
  3818. }
  3819. }
  3820. static void tasha_codec_hph_hifi_config(struct snd_soc_codec *codec,
  3821. int event)
  3822. {
  3823. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3824. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3825. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3826. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3827. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3828. }
  3829. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3830. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3831. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3832. }
  3833. }
  3834. static void tasha_codec_hph_mode_config(struct snd_soc_codec *codec,
  3835. int event, int mode)
  3836. {
  3837. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3838. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3839. return;
  3840. switch (mode) {
  3841. case CLS_H_LP:
  3842. tasha_codec_hph_lp_config(codec, event);
  3843. break;
  3844. case CLS_H_LOHIFI:
  3845. tasha_codec_hph_lohifi_config(codec, event);
  3846. break;
  3847. case CLS_H_HIFI:
  3848. tasha_codec_hph_hifi_config(codec, event);
  3849. break;
  3850. }
  3851. }
  3852. static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
  3853. struct snd_kcontrol *kcontrol,
  3854. int event)
  3855. {
  3856. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3857. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3858. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3859. int hph_mode = tasha->hph_mode;
  3860. u8 dem_inp;
  3861. int ret = 0;
  3862. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3863. w->name, event, hph_mode);
  3864. switch (event) {
  3865. case SND_SOC_DAPM_PRE_PMU:
  3866. if (tasha->anc_func) {
  3867. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3868. /* 40 msec delay is needed to avoid click and pop */
  3869. msleep(40);
  3870. }
  3871. /* Read DEM INP Select */
  3872. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_SEC0) &
  3873. 0x03;
  3874. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3875. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3876. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3877. __func__, hph_mode);
  3878. return -EINVAL;
  3879. }
  3880. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3881. WCD_CLSH_EVENT_PRE_DAC,
  3882. WCD_CLSH_STATE_HPHR,
  3883. ((hph_mode == CLS_H_LOHIFI) ?
  3884. CLS_H_HIFI : hph_mode));
  3885. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3886. if (tasha->anc_func)
  3887. snd_soc_update_bits(codec,
  3888. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x10);
  3889. break;
  3890. case SND_SOC_DAPM_POST_PMU:
  3891. /* 1000us required as per HW requirement */
  3892. usleep_range(1000, 1100);
  3893. if ((hph_mode == CLS_H_LP) &&
  3894. (TASHA_IS_1_1(wcd9xxx))) {
  3895. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3896. 0x03, 0x03);
  3897. }
  3898. break;
  3899. case SND_SOC_DAPM_PRE_PMD:
  3900. if ((hph_mode == CLS_H_LP) &&
  3901. (TASHA_IS_1_1(wcd9xxx))) {
  3902. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3903. 0x03, 0x00);
  3904. }
  3905. break;
  3906. case SND_SOC_DAPM_POST_PMD:
  3907. /* 1000us required as per HW requirement */
  3908. usleep_range(1000, 1100);
  3909. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  3910. WCD_CLSH_STATE_HPHL))
  3911. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3912. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3913. WCD_CLSH_EVENT_POST_PA,
  3914. WCD_CLSH_STATE_HPHR,
  3915. ((hph_mode == CLS_H_LOHIFI) ?
  3916. CLS_H_HIFI : hph_mode));
  3917. break;
  3918. };
  3919. return ret;
  3920. }
  3921. static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
  3922. struct snd_kcontrol *kcontrol,
  3923. int event)
  3924. {
  3925. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3926. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3927. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3928. int hph_mode = tasha->hph_mode;
  3929. u8 dem_inp;
  3930. int ret = 0;
  3931. uint32_t impedl = 0, impedr = 0;
  3932. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3933. w->name, event, hph_mode);
  3934. switch (event) {
  3935. case SND_SOC_DAPM_PRE_PMU:
  3936. if (tasha->anc_func) {
  3937. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3938. /* 40 msec delay is needed to avoid click and pop */
  3939. msleep(40);
  3940. }
  3941. /* Read DEM INP Select */
  3942. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_SEC0) &
  3943. 0x03;
  3944. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3945. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3946. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3947. __func__, hph_mode);
  3948. return -EINVAL;
  3949. }
  3950. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3951. WCD_CLSH_EVENT_PRE_DAC,
  3952. WCD_CLSH_STATE_HPHL,
  3953. ((hph_mode == CLS_H_LOHIFI) ?
  3954. CLS_H_HIFI : hph_mode));
  3955. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3956. if (tasha->anc_func)
  3957. snd_soc_update_bits(codec,
  3958. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x10);
  3959. ret = wcd_mbhc_get_impedance(&tasha->mbhc,
  3960. &impedl, &impedr);
  3961. if (!ret) {
  3962. wcd_clsh_imped_config(codec, impedl, false);
  3963. set_bit(CLASSH_CONFIG, &tasha->status_mask);
  3964. } else {
  3965. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  3966. __func__, ret);
  3967. ret = 0;
  3968. }
  3969. break;
  3970. case SND_SOC_DAPM_POST_PMU:
  3971. /* 1000us required as per HW requirement */
  3972. usleep_range(1000, 1100);
  3973. if ((hph_mode == CLS_H_LP) &&
  3974. (TASHA_IS_1_1(wcd9xxx))) {
  3975. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3976. 0x03, 0x03);
  3977. }
  3978. break;
  3979. case SND_SOC_DAPM_PRE_PMD:
  3980. if ((hph_mode == CLS_H_LP) &&
  3981. (TASHA_IS_1_1(wcd9xxx))) {
  3982. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3983. 0x03, 0x00);
  3984. }
  3985. break;
  3986. case SND_SOC_DAPM_POST_PMD:
  3987. /* 1000us required as per HW requirement */
  3988. usleep_range(1000, 1100);
  3989. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  3990. WCD_CLSH_STATE_HPHR))
  3991. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3992. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3993. WCD_CLSH_EVENT_POST_PA,
  3994. WCD_CLSH_STATE_HPHL,
  3995. ((hph_mode == CLS_H_LOHIFI) ?
  3996. CLS_H_HIFI : hph_mode));
  3997. if (test_bit(CLASSH_CONFIG, &tasha->status_mask)) {
  3998. wcd_clsh_imped_config(codec, impedl, true);
  3999. clear_bit(CLASSH_CONFIG, &tasha->status_mask);
  4000. } else
  4001. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  4002. __func__, ret);
  4003. break;
  4004. };
  4005. return ret;
  4006. }
  4007. static int tasha_codec_lineout_dac_event(struct snd_soc_dapm_widget *w,
  4008. struct snd_kcontrol *kcontrol,
  4009. int event)
  4010. {
  4011. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4012. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4013. int ret = 0;
  4014. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4015. switch (event) {
  4016. case SND_SOC_DAPM_PRE_PMU:
  4017. if (tasha->anc_func &&
  4018. (!strcmp(w->name, "RX INT3 DAC") ||
  4019. !strcmp(w->name, "RX INT4 DAC")))
  4020. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4021. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4022. WCD_CLSH_EVENT_PRE_DAC,
  4023. WCD_CLSH_STATE_LO,
  4024. CLS_AB);
  4025. if (tasha->anc_func) {
  4026. if (!strcmp(w->name, "RX INT3 DAC"))
  4027. snd_soc_update_bits(codec,
  4028. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  4029. else if (!strcmp(w->name, "RX INT4 DAC"))
  4030. snd_soc_update_bits(codec,
  4031. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  4032. }
  4033. break;
  4034. case SND_SOC_DAPM_POST_PMD:
  4035. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4036. WCD_CLSH_EVENT_POST_PA,
  4037. WCD_CLSH_STATE_LO,
  4038. CLS_AB);
  4039. break;
  4040. }
  4041. return 0;
  4042. }
  4043. static const struct snd_soc_dapm_widget tasha_dapm_i2s_widgets[] = {
  4044. SND_SOC_DAPM_SUPPLY("RX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  4045. 0, 0, NULL, 0),
  4046. SND_SOC_DAPM_SUPPLY("TX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  4047. 0, 0, NULL, 0),
  4048. };
  4049. static int tasha_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
  4050. struct snd_kcontrol *kcontrol,
  4051. int event)
  4052. {
  4053. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4054. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4055. int ret = 0;
  4056. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4057. switch (event) {
  4058. case SND_SOC_DAPM_PRE_PMU:
  4059. if (tasha->anc_func)
  4060. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4061. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4062. WCD_CLSH_EVENT_PRE_DAC,
  4063. WCD_CLSH_STATE_EAR,
  4064. CLS_H_NORMAL);
  4065. if (tasha->anc_func)
  4066. snd_soc_update_bits(codec,
  4067. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x10);
  4068. break;
  4069. case SND_SOC_DAPM_POST_PMU:
  4070. break;
  4071. case SND_SOC_DAPM_PRE_PMD:
  4072. break;
  4073. case SND_SOC_DAPM_POST_PMD:
  4074. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4075. WCD_CLSH_EVENT_POST_PA,
  4076. WCD_CLSH_STATE_EAR,
  4077. CLS_H_NORMAL);
  4078. break;
  4079. };
  4080. return ret;
  4081. }
  4082. static int tasha_codec_spk_boost_event(struct snd_soc_dapm_widget *w,
  4083. struct snd_kcontrol *kcontrol,
  4084. int event)
  4085. {
  4086. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4087. u16 boost_path_ctl, boost_path_cfg1;
  4088. u16 reg, reg_mix;
  4089. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4090. if (!strcmp(w->name, "RX INT7 CHAIN")) {
  4091. boost_path_ctl = WCD9335_CDC_BOOST0_BOOST_PATH_CTL;
  4092. boost_path_cfg1 = WCD9335_CDC_RX7_RX_PATH_CFG1;
  4093. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4094. reg_mix = WCD9335_CDC_RX7_RX_PATH_MIX_CTL;
  4095. } else if (!strcmp(w->name, "RX INT8 CHAIN")) {
  4096. boost_path_ctl = WCD9335_CDC_BOOST1_BOOST_PATH_CTL;
  4097. boost_path_cfg1 = WCD9335_CDC_RX8_RX_PATH_CFG1;
  4098. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4099. reg_mix = WCD9335_CDC_RX8_RX_PATH_MIX_CTL;
  4100. } else {
  4101. dev_err(codec->dev, "%s: unknown widget: %s\n",
  4102. __func__, w->name);
  4103. return -EINVAL;
  4104. }
  4105. switch (event) {
  4106. case SND_SOC_DAPM_PRE_PMU:
  4107. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10);
  4108. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01);
  4109. snd_soc_update_bits(codec, reg, 0x10, 0x00);
  4110. if ((snd_soc_read(codec, reg_mix)) & 0x10)
  4111. snd_soc_update_bits(codec, reg_mix, 0x10, 0x00);
  4112. break;
  4113. case SND_SOC_DAPM_POST_PMD:
  4114. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00);
  4115. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00);
  4116. break;
  4117. };
  4118. return 0;
  4119. }
  4120. static u16 tasha_interp_get_primary_reg(u16 reg, u16 *ind)
  4121. {
  4122. u16 prim_int_reg = 0;
  4123. switch (reg) {
  4124. case WCD9335_CDC_RX0_RX_PATH_CTL:
  4125. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4126. prim_int_reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4127. *ind = 0;
  4128. break;
  4129. case WCD9335_CDC_RX1_RX_PATH_CTL:
  4130. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4131. prim_int_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4132. *ind = 1;
  4133. break;
  4134. case WCD9335_CDC_RX2_RX_PATH_CTL:
  4135. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4136. prim_int_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4137. *ind = 2;
  4138. break;
  4139. case WCD9335_CDC_RX3_RX_PATH_CTL:
  4140. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4141. prim_int_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4142. *ind = 3;
  4143. break;
  4144. case WCD9335_CDC_RX4_RX_PATH_CTL:
  4145. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4146. prim_int_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4147. *ind = 4;
  4148. break;
  4149. case WCD9335_CDC_RX5_RX_PATH_CTL:
  4150. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4151. prim_int_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4152. *ind = 5;
  4153. break;
  4154. case WCD9335_CDC_RX6_RX_PATH_CTL:
  4155. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4156. prim_int_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4157. *ind = 6;
  4158. break;
  4159. case WCD9335_CDC_RX7_RX_PATH_CTL:
  4160. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4161. prim_int_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4162. *ind = 7;
  4163. break;
  4164. case WCD9335_CDC_RX8_RX_PATH_CTL:
  4165. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4166. prim_int_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4167. *ind = 8;
  4168. break;
  4169. };
  4170. return prim_int_reg;
  4171. }
  4172. static void tasha_codec_hd2_control(struct snd_soc_codec *codec,
  4173. u16 prim_int_reg, int event)
  4174. {
  4175. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4176. u16 hd2_scale_reg;
  4177. u16 hd2_enable_reg = 0;
  4178. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  4179. return;
  4180. if (prim_int_reg == WCD9335_CDC_RX1_RX_PATH_CTL) {
  4181. hd2_scale_reg = WCD9335_CDC_RX1_RX_PATH_SEC3;
  4182. hd2_enable_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4183. }
  4184. if (prim_int_reg == WCD9335_CDC_RX2_RX_PATH_CTL) {
  4185. hd2_scale_reg = WCD9335_CDC_RX2_RX_PATH_SEC3;
  4186. hd2_enable_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4187. }
  4188. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) {
  4189. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x10);
  4190. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x01);
  4191. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04);
  4192. }
  4193. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
  4194. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00);
  4195. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x00);
  4196. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00);
  4197. }
  4198. }
  4199. static int tasha_codec_enable_prim_interpolator(
  4200. struct snd_soc_codec *codec,
  4201. u16 reg, int event)
  4202. {
  4203. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4204. u16 prim_int_reg;
  4205. u16 ind = 0;
  4206. prim_int_reg = tasha_interp_get_primary_reg(reg, &ind);
  4207. switch (event) {
  4208. case SND_SOC_DAPM_PRE_PMU:
  4209. tasha->prim_int_users[ind]++;
  4210. if (tasha->prim_int_users[ind] == 1) {
  4211. snd_soc_update_bits(codec, prim_int_reg,
  4212. 0x10, 0x10);
  4213. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4214. snd_soc_update_bits(codec, prim_int_reg,
  4215. 1 << 0x5, 1 << 0x5);
  4216. }
  4217. if ((reg != prim_int_reg) &&
  4218. ((snd_soc_read(codec, prim_int_reg)) & 0x10))
  4219. snd_soc_update_bits(codec, reg, 0x10, 0x10);
  4220. break;
  4221. case SND_SOC_DAPM_POST_PMD:
  4222. tasha->prim_int_users[ind]--;
  4223. if (tasha->prim_int_users[ind] == 0) {
  4224. snd_soc_update_bits(codec, prim_int_reg,
  4225. 1 << 0x5, 0 << 0x5);
  4226. snd_soc_update_bits(codec, prim_int_reg,
  4227. 0x40, 0x40);
  4228. snd_soc_update_bits(codec, prim_int_reg,
  4229. 0x40, 0x00);
  4230. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4231. }
  4232. break;
  4233. };
  4234. dev_dbg(codec->dev, "%s: primary interpolator: INT%d, users: %d\n",
  4235. __func__, ind, tasha->prim_int_users[ind]);
  4236. return 0;
  4237. }
  4238. static int tasha_codec_enable_spline_src(struct snd_soc_codec *codec,
  4239. int src_num,
  4240. int event)
  4241. {
  4242. u16 src_paired_reg = 0;
  4243. struct tasha_priv *tasha;
  4244. u16 rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4245. u16 rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4246. int *src_users, count, spl_src = SPLINE_SRC0;
  4247. u16 src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4248. tasha = snd_soc_codec_get_drvdata(codec);
  4249. switch (src_num) {
  4250. case SRC_IN_HPHL:
  4251. rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4252. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4253. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4254. rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4255. spl_src = SPLINE_SRC0;
  4256. break;
  4257. case SRC_IN_LO1:
  4258. rx_path_cfg_reg = WCD9335_CDC_RX3_RX_PATH_CFG0;
  4259. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4260. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4261. rx_path_ctl_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4262. spl_src = SPLINE_SRC0;
  4263. break;
  4264. case SRC_IN_HPHR:
  4265. rx_path_cfg_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4266. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4267. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4268. rx_path_ctl_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4269. spl_src = SPLINE_SRC1;
  4270. break;
  4271. case SRC_IN_LO2:
  4272. rx_path_cfg_reg = WCD9335_CDC_RX4_RX_PATH_CFG0;
  4273. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4274. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4275. rx_path_ctl_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4276. spl_src = SPLINE_SRC1;
  4277. break;
  4278. case SRC_IN_SPKRL:
  4279. rx_path_cfg_reg = WCD9335_CDC_RX7_RX_PATH_CFG0;
  4280. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4281. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4282. rx_path_ctl_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4283. spl_src = SPLINE_SRC2;
  4284. break;
  4285. case SRC_IN_LO3:
  4286. rx_path_cfg_reg = WCD9335_CDC_RX5_RX_PATH_CFG0;
  4287. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4288. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4289. rx_path_ctl_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4290. spl_src = SPLINE_SRC2;
  4291. break;
  4292. case SRC_IN_SPKRR:
  4293. rx_path_cfg_reg = WCD9335_CDC_RX8_RX_PATH_CFG0;
  4294. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4295. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4296. rx_path_ctl_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4297. spl_src = SPLINE_SRC3;
  4298. break;
  4299. case SRC_IN_LO4:
  4300. rx_path_cfg_reg = WCD9335_CDC_RX6_RX_PATH_CFG0;
  4301. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4302. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4303. rx_path_ctl_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4304. spl_src = SPLINE_SRC3;
  4305. break;
  4306. };
  4307. src_users = &tasha->spl_src_users[spl_src];
  4308. switch (event) {
  4309. case SND_SOC_DAPM_PRE_PMU:
  4310. count = *src_users;
  4311. count++;
  4312. if (count == 1) {
  4313. if ((snd_soc_read(codec, src_clk_reg) & 0x02) ||
  4314. (snd_soc_read(codec, src_paired_reg) & 0x02)) {
  4315. snd_soc_update_bits(codec, src_clk_reg, 0x02,
  4316. 0x00);
  4317. snd_soc_update_bits(codec, src_paired_reg,
  4318. 0x02, 0x00);
  4319. }
  4320. snd_soc_update_bits(codec, src_clk_reg, 0x01, 0x01);
  4321. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4322. 0x80);
  4323. }
  4324. *src_users = count;
  4325. break;
  4326. case SND_SOC_DAPM_POST_PMD:
  4327. count = *src_users;
  4328. count--;
  4329. if (count == 0) {
  4330. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4331. 0x00);
  4332. snd_soc_update_bits(codec, src_clk_reg, 0x03, 0x02);
  4333. /* default sample rate */
  4334. snd_soc_update_bits(codec, rx_path_ctl_reg, 0x0f,
  4335. 0x04);
  4336. }
  4337. *src_users = count;
  4338. break;
  4339. };
  4340. dev_dbg(codec->dev, "%s: Spline SRC%d, users: %d\n",
  4341. __func__, spl_src, *src_users);
  4342. return 0;
  4343. }
  4344. static int tasha_codec_enable_spline_resampler(struct snd_soc_dapm_widget *w,
  4345. struct snd_kcontrol *kcontrol,
  4346. int event)
  4347. {
  4348. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4349. int ret = 0;
  4350. u8 src_in;
  4351. src_in = snd_soc_read(codec, WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0);
  4352. if (!(src_in & 0xFF)) {
  4353. dev_err(codec->dev, "%s: Spline SRC%u input not selected\n",
  4354. __func__, w->shift);
  4355. return -EINVAL;
  4356. }
  4357. switch (w->shift) {
  4358. case SPLINE_SRC0:
  4359. ret = tasha_codec_enable_spline_src(codec,
  4360. ((src_in & 0x03) == 1) ? SRC_IN_HPHL : SRC_IN_LO1,
  4361. event);
  4362. break;
  4363. case SPLINE_SRC1:
  4364. ret = tasha_codec_enable_spline_src(codec,
  4365. ((src_in & 0x0C) == 4) ? SRC_IN_HPHR : SRC_IN_LO2,
  4366. event);
  4367. break;
  4368. case SPLINE_SRC2:
  4369. ret = tasha_codec_enable_spline_src(codec,
  4370. ((src_in & 0x30) == 0x10) ? SRC_IN_LO3 : SRC_IN_SPKRL,
  4371. event);
  4372. break;
  4373. case SPLINE_SRC3:
  4374. ret = tasha_codec_enable_spline_src(codec,
  4375. ((src_in & 0xC0) == 0x40) ? SRC_IN_LO4 : SRC_IN_SPKRR,
  4376. event);
  4377. break;
  4378. default:
  4379. dev_err(codec->dev, "%s: Invalid spline src:%u\n", __func__,
  4380. w->shift);
  4381. ret = -EINVAL;
  4382. };
  4383. return ret;
  4384. }
  4385. static int tasha_codec_enable_swr(struct snd_soc_dapm_widget *w,
  4386. struct snd_kcontrol *kcontrol, int event)
  4387. {
  4388. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4389. struct tasha_priv *tasha;
  4390. int i, ch_cnt;
  4391. tasha = snd_soc_codec_get_drvdata(codec);
  4392. if (!tasha->nr)
  4393. return 0;
  4394. switch (event) {
  4395. case SND_SOC_DAPM_PRE_PMU:
  4396. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4397. !tasha->rx_7_count)
  4398. tasha->rx_7_count++;
  4399. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4400. !tasha->rx_8_count)
  4401. tasha->rx_8_count++;
  4402. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4403. for (i = 0; i < tasha->nr; i++) {
  4404. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4405. SWR_DEVICE_UP, NULL);
  4406. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4407. SWR_SET_NUM_RX_CH, &ch_cnt);
  4408. }
  4409. break;
  4410. case SND_SOC_DAPM_POST_PMD:
  4411. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4412. tasha->rx_7_count)
  4413. tasha->rx_7_count--;
  4414. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4415. tasha->rx_8_count)
  4416. tasha->rx_8_count--;
  4417. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4418. for (i = 0; i < tasha->nr; i++)
  4419. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4420. SWR_SET_NUM_RX_CH, &ch_cnt);
  4421. break;
  4422. }
  4423. dev_dbg(tasha->dev, "%s: current swr ch cnt: %d\n",
  4424. __func__, tasha->rx_7_count + tasha->rx_8_count);
  4425. return 0;
  4426. }
  4427. static int tasha_codec_config_ear_spkr_gain(struct snd_soc_codec *codec,
  4428. int event, int gain_reg)
  4429. {
  4430. int comp_gain_offset, val;
  4431. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4432. switch (tasha->spkr_mode) {
  4433. /* Compander gain in SPKR_MODE1 case is 12 dB */
  4434. case SPKR_MODE_1:
  4435. comp_gain_offset = -12;
  4436. break;
  4437. /* Default case compander gain is 15 dB */
  4438. default:
  4439. comp_gain_offset = -15;
  4440. break;
  4441. }
  4442. switch (event) {
  4443. case SND_SOC_DAPM_POST_PMU:
  4444. /* Apply ear spkr gain only if compander is enabled */
  4445. if (tasha->comp_enabled[COMPANDER_7] &&
  4446. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4447. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4448. (tasha->ear_spkr_gain != 0)) {
  4449. /* For example, val is -8(-12+5-1) for 4dB of gain */
  4450. val = comp_gain_offset + tasha->ear_spkr_gain - 1;
  4451. snd_soc_write(codec, gain_reg, val);
  4452. dev_dbg(codec->dev, "%s: RX7 Volume %d dB\n",
  4453. __func__, val);
  4454. }
  4455. break;
  4456. case SND_SOC_DAPM_POST_PMD:
  4457. /*
  4458. * Reset RX7 volume to 0 dB if compander is enabled and
  4459. * ear_spkr_gain is non-zero.
  4460. */
  4461. if (tasha->comp_enabled[COMPANDER_7] &&
  4462. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4463. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4464. (tasha->ear_spkr_gain != 0)) {
  4465. snd_soc_write(codec, gain_reg, 0x0);
  4466. dev_dbg(codec->dev, "%s: Reset RX7 Volume to 0 dB\n",
  4467. __func__);
  4468. }
  4469. break;
  4470. }
  4471. return 0;
  4472. }
  4473. static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w,
  4474. struct snd_kcontrol *kcontrol, int event)
  4475. {
  4476. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4477. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4478. u16 gain_reg;
  4479. int offset_val = 0;
  4480. int val = 0;
  4481. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4482. switch (w->reg) {
  4483. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4484. gain_reg = WCD9335_CDC_RX0_RX_VOL_MIX_CTL;
  4485. break;
  4486. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4487. gain_reg = WCD9335_CDC_RX1_RX_VOL_MIX_CTL;
  4488. break;
  4489. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4490. gain_reg = WCD9335_CDC_RX2_RX_VOL_MIX_CTL;
  4491. break;
  4492. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4493. gain_reg = WCD9335_CDC_RX3_RX_VOL_MIX_CTL;
  4494. break;
  4495. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4496. gain_reg = WCD9335_CDC_RX4_RX_VOL_MIX_CTL;
  4497. break;
  4498. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4499. gain_reg = WCD9335_CDC_RX5_RX_VOL_MIX_CTL;
  4500. break;
  4501. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4502. gain_reg = WCD9335_CDC_RX6_RX_VOL_MIX_CTL;
  4503. break;
  4504. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4505. gain_reg = WCD9335_CDC_RX7_RX_VOL_MIX_CTL;
  4506. break;
  4507. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4508. gain_reg = WCD9335_CDC_RX8_RX_VOL_MIX_CTL;
  4509. break;
  4510. default:
  4511. dev_err(codec->dev, "%s: No gain register avail for %s\n",
  4512. __func__, w->name);
  4513. return 0;
  4514. };
  4515. switch (event) {
  4516. case SND_SOC_DAPM_POST_PMU:
  4517. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4518. (tasha->comp_enabled[COMPANDER_7] ||
  4519. tasha->comp_enabled[COMPANDER_8]) &&
  4520. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4521. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4522. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4523. 0x01, 0x01);
  4524. snd_soc_update_bits(codec,
  4525. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4526. 0x01, 0x01);
  4527. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4528. 0x01, 0x01);
  4529. snd_soc_update_bits(codec,
  4530. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4531. 0x01, 0x01);
  4532. offset_val = -2;
  4533. }
  4534. val = snd_soc_read(codec, gain_reg);
  4535. val += offset_val;
  4536. snd_soc_write(codec, gain_reg, val);
  4537. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4538. break;
  4539. case SND_SOC_DAPM_POST_PMD:
  4540. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4541. (tasha->comp_enabled[COMPANDER_7] ||
  4542. tasha->comp_enabled[COMPANDER_8]) &&
  4543. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4544. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4545. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4546. 0x01, 0x00);
  4547. snd_soc_update_bits(codec,
  4548. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4549. 0x01, 0x00);
  4550. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4551. 0x01, 0x00);
  4552. snd_soc_update_bits(codec,
  4553. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4554. 0x01, 0x00);
  4555. offset_val = 2;
  4556. val = snd_soc_read(codec, gain_reg);
  4557. val += offset_val;
  4558. snd_soc_write(codec, gain_reg, val);
  4559. }
  4560. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4561. break;
  4562. };
  4563. return 0;
  4564. }
  4565. static int __tasha_cdc_native_clk_enable(struct tasha_priv *tasha,
  4566. bool enable)
  4567. {
  4568. int ret = 0;
  4569. struct snd_soc_codec *codec = tasha->codec;
  4570. if (!tasha->wcd_native_clk) {
  4571. dev_err(tasha->dev, "%s: wcd native clock is NULL\n", __func__);
  4572. return -EINVAL;
  4573. }
  4574. dev_dbg(tasha->dev, "%s: native_clk_enable = %u\n", __func__, enable);
  4575. if (enable) {
  4576. ret = clk_prepare_enable(tasha->wcd_native_clk);
  4577. if (ret) {
  4578. dev_err(tasha->dev, "%s: native clk enable failed\n",
  4579. __func__);
  4580. goto err;
  4581. }
  4582. if (++tasha->native_clk_users == 1) {
  4583. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4584. 0x10, 0x10);
  4585. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4586. 0x80, 0x80);
  4587. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4588. 0x04, 0x00);
  4589. snd_soc_update_bits(codec,
  4590. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4591. 0x02, 0x02);
  4592. }
  4593. } else {
  4594. if (tasha->native_clk_users &&
  4595. (--tasha->native_clk_users == 0)) {
  4596. snd_soc_update_bits(codec,
  4597. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4598. 0x02, 0x00);
  4599. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4600. 0x04, 0x04);
  4601. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4602. 0x80, 0x00);
  4603. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4604. 0x10, 0x00);
  4605. }
  4606. clk_disable_unprepare(tasha->wcd_native_clk);
  4607. }
  4608. dev_dbg(codec->dev, "%s: native_clk_users: %d\n", __func__,
  4609. tasha->native_clk_users);
  4610. err:
  4611. return ret;
  4612. }
  4613. static int tasha_codec_get_native_fifo_sync_mask(struct snd_soc_codec *codec,
  4614. int interp_n)
  4615. {
  4616. int mask = 0;
  4617. u16 reg;
  4618. u8 val1, val2, inp0 = 0;
  4619. u8 inp1 = 0, inp2 = 0;
  4620. reg = WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0 + (2 * interp_n) - 2;
  4621. val1 = snd_soc_read(codec, reg);
  4622. val2 = snd_soc_read(codec, reg + 1);
  4623. inp0 = val1 & 0x0F;
  4624. inp1 = (val1 >> 4) & 0x0F;
  4625. inp2 = (val2 >> 4) & 0x0F;
  4626. if (IS_VALID_NATIVE_FIFO_PORT(inp0))
  4627. mask |= (1 << (inp0 - 5));
  4628. if (IS_VALID_NATIVE_FIFO_PORT(inp1))
  4629. mask |= (1 << (inp1 - 5));
  4630. if (IS_VALID_NATIVE_FIFO_PORT(inp2))
  4631. mask |= (1 << (inp2 - 5));
  4632. dev_dbg(codec->dev, "%s: native fifo mask: 0x%x\n", __func__, mask);
  4633. if (!mask)
  4634. dev_err(codec->dev, "native fifo err,int:%d,inp0:%d,inp1:%d,inp2:%d\n",
  4635. interp_n, inp0, inp1, inp2);
  4636. return mask;
  4637. }
  4638. static int tasha_enable_native_supply(struct snd_soc_dapm_widget *w,
  4639. struct snd_kcontrol *kcontrol, int event)
  4640. {
  4641. int mask;
  4642. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4643. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4644. u16 interp_reg;
  4645. dev_dbg(codec->dev, "%s: event: %d, shift:%d\n", __func__, event,
  4646. w->shift);
  4647. if (w->shift < INTERP_HPHL || w->shift > INTERP_LO2)
  4648. return -EINVAL;
  4649. interp_reg = WCD9335_CDC_RX1_RX_PATH_CTL + 20 * (w->shift - 1);
  4650. mask = tasha_codec_get_native_fifo_sync_mask(codec, w->shift);
  4651. if (!mask)
  4652. return -EINVAL;
  4653. switch (event) {
  4654. case SND_SOC_DAPM_PRE_PMU:
  4655. /* Adjust interpolator rate to 44P1_NATIVE */
  4656. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x09);
  4657. __tasha_cdc_native_clk_enable(tasha, true);
  4658. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4659. mask, mask);
  4660. break;
  4661. case SND_SOC_DAPM_PRE_PMD:
  4662. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4663. mask, 0x0);
  4664. __tasha_cdc_native_clk_enable(tasha, false);
  4665. /* Adjust interpolator rate to default */
  4666. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x04);
  4667. break;
  4668. }
  4669. return 0;
  4670. }
  4671. static int tasha_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
  4672. struct snd_kcontrol *kcontrol, int event)
  4673. {
  4674. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4675. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4676. u16 gain_reg;
  4677. u16 reg;
  4678. int val;
  4679. int offset_val = 0;
  4680. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4681. if (!(strcmp(w->name, "RX INT0 INTERP"))) {
  4682. reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4683. gain_reg = WCD9335_CDC_RX0_RX_VOL_CTL;
  4684. } else if (!(strcmp(w->name, "RX INT1 INTERP"))) {
  4685. reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4686. gain_reg = WCD9335_CDC_RX1_RX_VOL_CTL;
  4687. } else if (!(strcmp(w->name, "RX INT2 INTERP"))) {
  4688. reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4689. gain_reg = WCD9335_CDC_RX2_RX_VOL_CTL;
  4690. } else if (!(strcmp(w->name, "RX INT3 INTERP"))) {
  4691. reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4692. gain_reg = WCD9335_CDC_RX3_RX_VOL_CTL;
  4693. } else if (!(strcmp(w->name, "RX INT4 INTERP"))) {
  4694. reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4695. gain_reg = WCD9335_CDC_RX4_RX_VOL_CTL;
  4696. } else if (!(strcmp(w->name, "RX INT5 INTERP"))) {
  4697. reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4698. gain_reg = WCD9335_CDC_RX5_RX_VOL_CTL;
  4699. } else if (!(strcmp(w->name, "RX INT6 INTERP"))) {
  4700. reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4701. gain_reg = WCD9335_CDC_RX6_RX_VOL_CTL;
  4702. } else if (!(strcmp(w->name, "RX INT7 INTERP"))) {
  4703. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4704. gain_reg = WCD9335_CDC_RX7_RX_VOL_CTL;
  4705. } else if (!(strcmp(w->name, "RX INT8 INTERP"))) {
  4706. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4707. gain_reg = WCD9335_CDC_RX8_RX_VOL_CTL;
  4708. } else {
  4709. dev_err(codec->dev, "%s: Interpolator reg not found\n",
  4710. __func__);
  4711. return -EINVAL;
  4712. }
  4713. switch (event) {
  4714. case SND_SOC_DAPM_PRE_PMU:
  4715. tasha_codec_vote_max_bw(codec, true);
  4716. /* Reset if needed */
  4717. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4718. break;
  4719. case SND_SOC_DAPM_POST_PMU:
  4720. tasha_config_compander(codec, w->shift, event);
  4721. /* apply gain after int clk is enabled */
  4722. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4723. (tasha->comp_enabled[COMPANDER_7] ||
  4724. tasha->comp_enabled[COMPANDER_8]) &&
  4725. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4726. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4727. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4728. 0x01, 0x01);
  4729. snd_soc_update_bits(codec,
  4730. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4731. 0x01, 0x01);
  4732. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4733. 0x01, 0x01);
  4734. snd_soc_update_bits(codec,
  4735. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4736. 0x01, 0x01);
  4737. offset_val = -2;
  4738. }
  4739. val = snd_soc_read(codec, gain_reg);
  4740. val += offset_val;
  4741. snd_soc_write(codec, gain_reg, val);
  4742. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4743. break;
  4744. case SND_SOC_DAPM_POST_PMD:
  4745. tasha_config_compander(codec, w->shift, event);
  4746. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4747. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4748. (tasha->comp_enabled[COMPANDER_7] ||
  4749. tasha->comp_enabled[COMPANDER_8]) &&
  4750. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4751. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4752. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4753. 0x01, 0x00);
  4754. snd_soc_update_bits(codec,
  4755. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4756. 0x01, 0x00);
  4757. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4758. 0x01, 0x00);
  4759. snd_soc_update_bits(codec,
  4760. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4761. 0x01, 0x00);
  4762. offset_val = 2;
  4763. val = snd_soc_read(codec, gain_reg);
  4764. val += offset_val;
  4765. snd_soc_write(codec, gain_reg, val);
  4766. }
  4767. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4768. break;
  4769. };
  4770. return 0;
  4771. }
  4772. static int tasha_codec_set_iir_gain(struct snd_soc_dapm_widget *w,
  4773. struct snd_kcontrol *kcontrol, int event)
  4774. {
  4775. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4776. dev_dbg(codec->dev, "%s: event = %d\n", __func__, event);
  4777. switch (event) {
  4778. case SND_SOC_DAPM_POST_PMU: /* fall through */
  4779. case SND_SOC_DAPM_PRE_PMD:
  4780. if (strnstr(w->name, "IIR0", sizeof("IIR0"))) {
  4781. snd_soc_write(codec,
  4782. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL,
  4783. snd_soc_read(codec,
  4784. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL));
  4785. snd_soc_write(codec,
  4786. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL,
  4787. snd_soc_read(codec,
  4788. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL));
  4789. snd_soc_write(codec,
  4790. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL,
  4791. snd_soc_read(codec,
  4792. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL));
  4793. snd_soc_write(codec,
  4794. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL,
  4795. snd_soc_read(codec,
  4796. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL));
  4797. } else {
  4798. snd_soc_write(codec,
  4799. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL,
  4800. snd_soc_read(codec,
  4801. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL));
  4802. snd_soc_write(codec,
  4803. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL,
  4804. snd_soc_read(codec,
  4805. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL));
  4806. snd_soc_write(codec,
  4807. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL,
  4808. snd_soc_read(codec,
  4809. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL));
  4810. }
  4811. break;
  4812. }
  4813. return 0;
  4814. }
  4815. static int tasha_codec_enable_on_demand_supply(
  4816. struct snd_soc_dapm_widget *w,
  4817. struct snd_kcontrol *kcontrol, int event)
  4818. {
  4819. int ret = 0;
  4820. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4821. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4822. struct on_demand_supply *supply;
  4823. if (w->shift >= ON_DEMAND_SUPPLIES_MAX) {
  4824. dev_err(codec->dev, "%s: error index > MAX Demand supplies",
  4825. __func__);
  4826. ret = -EINVAL;
  4827. goto out;
  4828. }
  4829. dev_dbg(codec->dev, "%s: supply: %s event: %d\n",
  4830. __func__, on_demand_supply_name[w->shift], event);
  4831. supply = &tasha->on_demand_list[w->shift];
  4832. WARN_ONCE(!supply->supply, "%s isn't defined\n",
  4833. on_demand_supply_name[w->shift]);
  4834. if (!supply->supply) {
  4835. dev_err(codec->dev, "%s: err supply not present ond for %d",
  4836. __func__, w->shift);
  4837. goto out;
  4838. }
  4839. switch (event) {
  4840. case SND_SOC_DAPM_PRE_PMU:
  4841. ret = regulator_enable(supply->supply);
  4842. if (ret)
  4843. dev_err(codec->dev, "%s: Failed to enable %s\n",
  4844. __func__,
  4845. on_demand_supply_name[w->shift]);
  4846. break;
  4847. case SND_SOC_DAPM_POST_PMD:
  4848. ret = regulator_disable(supply->supply);
  4849. if (ret)
  4850. dev_err(codec->dev, "%s: Failed to disable %s\n",
  4851. __func__,
  4852. on_demand_supply_name[w->shift]);
  4853. break;
  4854. default:
  4855. break;
  4856. };
  4857. out:
  4858. return ret;
  4859. }
  4860. static int tasha_codec_find_amic_input(struct snd_soc_codec *codec,
  4861. int adc_mux_n)
  4862. {
  4863. u16 mask, shift, adc_mux_in_reg;
  4864. u16 amic_mux_sel_reg;
  4865. bool is_amic;
  4866. if (adc_mux_n < 0 || adc_mux_n > WCD9335_MAX_VALID_ADC_MUX ||
  4867. adc_mux_n == WCD9335_INVALID_ADC_MUX)
  4868. return 0;
  4869. /* Check whether adc mux input is AMIC or DMIC */
  4870. if (adc_mux_n < 4) {
  4871. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
  4872. 2 * adc_mux_n;
  4873. amic_mux_sel_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  4874. 2 * adc_mux_n;
  4875. mask = 0x03;
  4876. shift = 0;
  4877. } else {
  4878. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  4879. adc_mux_n - 4;
  4880. amic_mux_sel_reg = adc_mux_in_reg;
  4881. mask = 0xC0;
  4882. shift = 6;
  4883. }
  4884. is_amic = (((snd_soc_read(codec, adc_mux_in_reg) & mask) >> shift)
  4885. == 1);
  4886. if (!is_amic)
  4887. return 0;
  4888. return snd_soc_read(codec, amic_mux_sel_reg) & 0x07;
  4889. }
  4890. static void tasha_codec_set_tx_hold(struct snd_soc_codec *codec,
  4891. u16 amic_reg, bool set)
  4892. {
  4893. u8 mask = 0x20;
  4894. u8 val;
  4895. if (amic_reg == WCD9335_ANA_AMIC1 ||
  4896. amic_reg == WCD9335_ANA_AMIC3 ||
  4897. amic_reg == WCD9335_ANA_AMIC5)
  4898. mask = 0x40;
  4899. val = set ? mask : 0x00;
  4900. switch (amic_reg) {
  4901. case WCD9335_ANA_AMIC1:
  4902. case WCD9335_ANA_AMIC2:
  4903. snd_soc_update_bits(codec, WCD9335_ANA_AMIC2, mask, val);
  4904. break;
  4905. case WCD9335_ANA_AMIC3:
  4906. case WCD9335_ANA_AMIC4:
  4907. snd_soc_update_bits(codec, WCD9335_ANA_AMIC4, mask, val);
  4908. break;
  4909. case WCD9335_ANA_AMIC5:
  4910. case WCD9335_ANA_AMIC6:
  4911. snd_soc_update_bits(codec, WCD9335_ANA_AMIC6, mask, val);
  4912. break;
  4913. default:
  4914. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4915. __func__, amic_reg);
  4916. break;
  4917. }
  4918. }
  4919. static int tasha_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w,
  4920. struct snd_kcontrol *kcontrol, int event)
  4921. {
  4922. int adc_mux_n = w->shift;
  4923. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4924. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4925. int amic_n;
  4926. dev_dbg(codec->dev, "%s: event: %d\n", __func__, event);
  4927. switch (event) {
  4928. case SND_SOC_DAPM_POST_PMU:
  4929. amic_n = tasha_codec_find_amic_input(codec, adc_mux_n);
  4930. if (amic_n) {
  4931. /*
  4932. * Prevent ANC Rx pop by leaving Tx FE in HOLD
  4933. * state until PA is up. Track AMIC being used
  4934. * so we can release the HOLD later.
  4935. */
  4936. set_bit(ANC_MIC_AMIC1 + amic_n - 1,
  4937. &tasha->status_mask);
  4938. }
  4939. break;
  4940. default:
  4941. break;
  4942. }
  4943. return 0;
  4944. }
  4945. static u16 tasha_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic)
  4946. {
  4947. u16 pwr_level_reg = 0;
  4948. switch (amic) {
  4949. case 1:
  4950. case 2:
  4951. pwr_level_reg = WCD9335_ANA_AMIC1;
  4952. break;
  4953. case 3:
  4954. case 4:
  4955. pwr_level_reg = WCD9335_ANA_AMIC3;
  4956. break;
  4957. case 5:
  4958. case 6:
  4959. pwr_level_reg = WCD9335_ANA_AMIC5;
  4960. break;
  4961. default:
  4962. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4963. __func__, amic);
  4964. break;
  4965. }
  4966. return pwr_level_reg;
  4967. }
  4968. #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
  4969. #define CF_MIN_3DB_4HZ 0x0
  4970. #define CF_MIN_3DB_75HZ 0x1
  4971. #define CF_MIN_3DB_150HZ 0x2
  4972. static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work)
  4973. {
  4974. struct delayed_work *hpf_delayed_work;
  4975. struct hpf_work *hpf_work;
  4976. struct tasha_priv *tasha;
  4977. struct snd_soc_codec *codec;
  4978. u16 dec_cfg_reg, amic_reg;
  4979. u8 hpf_cut_off_freq;
  4980. int amic_n;
  4981. hpf_delayed_work = to_delayed_work(work);
  4982. hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
  4983. tasha = hpf_work->tasha;
  4984. codec = tasha->codec;
  4985. hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
  4986. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator;
  4987. dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
  4988. __func__, hpf_work->decimator, hpf_cut_off_freq);
  4989. amic_n = tasha_codec_find_amic_input(codec, hpf_work->decimator);
  4990. if (amic_n) {
  4991. amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1;
  4992. tasha_codec_set_tx_hold(codec, amic_reg, false);
  4993. }
  4994. tasha_codec_vote_max_bw(codec, true);
  4995. snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  4996. hpf_cut_off_freq << 5);
  4997. tasha_codec_vote_max_bw(codec, false);
  4998. }
  4999. static void tasha_tx_mute_update_callback(struct work_struct *work)
  5000. {
  5001. struct tx_mute_work *tx_mute_dwork;
  5002. struct tasha_priv *tasha;
  5003. struct delayed_work *delayed_work;
  5004. struct snd_soc_codec *codec;
  5005. u16 tx_vol_ctl_reg, hpf_gate_reg;
  5006. delayed_work = to_delayed_work(work);
  5007. tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
  5008. tasha = tx_mute_dwork->tasha;
  5009. codec = tasha->codec;
  5010. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  5011. 16 * tx_mute_dwork->decimator;
  5012. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 +
  5013. 16 * tx_mute_dwork->decimator;
  5014. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x01);
  5015. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5016. }
  5017. static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w,
  5018. struct snd_kcontrol *kcontrol, int event)
  5019. {
  5020. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5021. unsigned int decimator;
  5022. char *dec_adc_mux_name = NULL;
  5023. char *widget_name = NULL;
  5024. char *wname;
  5025. int ret = 0, amic_n;
  5026. u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
  5027. u16 tx_gain_ctl_reg;
  5028. char *dec;
  5029. u8 hpf_cut_off_freq;
  5030. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5031. dev_dbg(codec->dev, "%s %d\n", __func__, event);
  5032. widget_name = kstrndup(w->name, 15, GFP_KERNEL);
  5033. if (!widget_name)
  5034. return -ENOMEM;
  5035. wname = widget_name;
  5036. dec_adc_mux_name = strsep(&widget_name, " ");
  5037. if (!dec_adc_mux_name) {
  5038. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5039. __func__, w->name);
  5040. ret = -EINVAL;
  5041. goto out;
  5042. }
  5043. dec_adc_mux_name = widget_name;
  5044. dec = strpbrk(dec_adc_mux_name, "012345678");
  5045. if (!dec) {
  5046. dev_err(codec->dev, "%s: decimator index not found\n",
  5047. __func__);
  5048. ret = -EINVAL;
  5049. goto out;
  5050. }
  5051. ret = kstrtouint(dec, 10, &decimator);
  5052. if (ret < 0) {
  5053. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5054. __func__, wname);
  5055. ret = -EINVAL;
  5056. goto out;
  5057. }
  5058. dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__,
  5059. w->name, decimator);
  5060. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator;
  5061. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 + 16 * decimator;
  5062. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * decimator;
  5063. tx_gain_ctl_reg = WCD9335_CDC_TX0_TX_VOL_CTL + 16 * decimator;
  5064. switch (event) {
  5065. case SND_SOC_DAPM_PRE_PMU:
  5066. amic_n = tasha_codec_find_amic_input(codec, decimator);
  5067. if (amic_n)
  5068. pwr_level_reg = tasha_codec_get_amic_pwlvl_reg(codec,
  5069. amic_n);
  5070. if (pwr_level_reg) {
  5071. switch ((snd_soc_read(codec, pwr_level_reg) &
  5072. WCD9335_AMIC_PWR_LVL_MASK) >>
  5073. WCD9335_AMIC_PWR_LVL_SHIFT) {
  5074. case WCD9335_AMIC_PWR_LEVEL_LP:
  5075. snd_soc_update_bits(codec, dec_cfg_reg,
  5076. WCD9335_DEC_PWR_LVL_MASK,
  5077. WCD9335_DEC_PWR_LVL_LP);
  5078. break;
  5079. case WCD9335_AMIC_PWR_LEVEL_HP:
  5080. snd_soc_update_bits(codec, dec_cfg_reg,
  5081. WCD9335_DEC_PWR_LVL_MASK,
  5082. WCD9335_DEC_PWR_LVL_HP);
  5083. break;
  5084. case WCD9335_AMIC_PWR_LEVEL_DEFAULT:
  5085. default:
  5086. snd_soc_update_bits(codec, dec_cfg_reg,
  5087. WCD9335_DEC_PWR_LVL_MASK,
  5088. WCD9335_DEC_PWR_LVL_DF);
  5089. break;
  5090. }
  5091. }
  5092. hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) &
  5093. TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
  5094. tasha->tx_hpf_work[decimator].hpf_cut_off_freq =
  5095. hpf_cut_off_freq;
  5096. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
  5097. snd_soc_update_bits(codec, dec_cfg_reg,
  5098. TX_HPF_CUT_OFF_FREQ_MASK,
  5099. CF_MIN_3DB_150HZ << 5);
  5100. /* Enable TX PGA Mute */
  5101. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5102. break;
  5103. case SND_SOC_DAPM_POST_PMU:
  5104. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00);
  5105. if (decimator == 0) {
  5106. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5107. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0xA3);
  5108. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5109. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x03);
  5110. }
  5111. /* schedule work queue to Remove Mute */
  5112. schedule_delayed_work(&tasha->tx_mute_dwork[decimator].dwork,
  5113. msecs_to_jiffies(tx_unmute_delay));
  5114. if (tasha->tx_hpf_work[decimator].hpf_cut_off_freq !=
  5115. CF_MIN_3DB_150HZ)
  5116. schedule_delayed_work(
  5117. &tasha->tx_hpf_work[decimator].dwork,
  5118. msecs_to_jiffies(300));
  5119. /* apply gain after decimator is enabled */
  5120. snd_soc_write(codec, tx_gain_ctl_reg,
  5121. snd_soc_read(codec, tx_gain_ctl_reg));
  5122. break;
  5123. case SND_SOC_DAPM_PRE_PMD:
  5124. hpf_cut_off_freq =
  5125. tasha->tx_hpf_work[decimator].hpf_cut_off_freq;
  5126. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5127. if (cancel_delayed_work_sync(
  5128. &tasha->tx_hpf_work[decimator].dwork)) {
  5129. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  5130. tasha_codec_vote_max_bw(codec, true);
  5131. snd_soc_update_bits(codec, dec_cfg_reg,
  5132. TX_HPF_CUT_OFF_FREQ_MASK,
  5133. hpf_cut_off_freq << 5);
  5134. tasha_codec_vote_max_bw(codec, false);
  5135. }
  5136. }
  5137. cancel_delayed_work_sync(
  5138. &tasha->tx_mute_dwork[decimator].dwork);
  5139. break;
  5140. case SND_SOC_DAPM_POST_PMD:
  5141. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5142. break;
  5143. };
  5144. out:
  5145. kfree(wname);
  5146. return ret;
  5147. }
  5148. static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec,
  5149. unsigned int dmic, struct wcd9xxx_pdata *pdata)
  5150. {
  5151. u8 tx_stream_fs;
  5152. u8 adc_mux_index = 0, adc_mux_sel = 0;
  5153. bool dec_found = false;
  5154. u16 adc_mux_ctl_reg, tx_fs_reg;
  5155. u32 dmic_fs;
  5156. while (dec_found == 0 && adc_mux_index < WCD9335_MAX_VALID_ADC_MUX) {
  5157. if (adc_mux_index < 4) {
  5158. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  5159. (adc_mux_index * 2);
  5160. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5161. 0x78) >> 3) - 1;
  5162. } else if (adc_mux_index < 9) {
  5163. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  5164. ((adc_mux_index - 4) * 1);
  5165. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5166. 0x38) >> 3) - 1;
  5167. } else if (adc_mux_index == 9) {
  5168. ++adc_mux_index;
  5169. continue;
  5170. }
  5171. if (adc_mux_sel == dmic)
  5172. dec_found = true;
  5173. else
  5174. ++adc_mux_index;
  5175. }
  5176. if (dec_found == true && adc_mux_index <= 8) {
  5177. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index);
  5178. tx_stream_fs = snd_soc_read(codec, tx_fs_reg) & 0x0F;
  5179. dmic_fs = tx_stream_fs <= 4 ? WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ :
  5180. WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  5181. /*
  5182. * Check for ECPP path selection and DEC1 not connected to
  5183. * any other audio path to apply ECPP DMIC sample rate
  5184. */
  5185. if ((adc_mux_index == 1) &&
  5186. ((snd_soc_read(codec, WCD9335_CPE_SS_US_EC_MUX_CFG)
  5187. & 0x0F) == 0x0A) &&
  5188. ((snd_soc_read(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0)
  5189. & 0x0C) == 0x00)) {
  5190. dmic_fs = pdata->ecpp_dmic_sample_rate;
  5191. }
  5192. } else {
  5193. dmic_fs = pdata->dmic_sample_rate;
  5194. }
  5195. return dmic_fs;
  5196. }
  5197. static u8 tasha_get_dmic_clk_val(struct snd_soc_codec *codec,
  5198. u32 mclk_rate, u32 dmic_clk_rate)
  5199. {
  5200. u32 div_factor;
  5201. u8 dmic_ctl_val;
  5202. dev_dbg(codec->dev,
  5203. "%s: mclk_rate = %d, dmic_sample_rate = %d\n",
  5204. __func__, mclk_rate, dmic_clk_rate);
  5205. /* Default value to return in case of error */
  5206. if (mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  5207. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5208. else
  5209. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5210. if (dmic_clk_rate == 0) {
  5211. dev_err(codec->dev,
  5212. "%s: dmic_sample_rate cannot be 0\n",
  5213. __func__);
  5214. goto done;
  5215. }
  5216. div_factor = mclk_rate / dmic_clk_rate;
  5217. switch (div_factor) {
  5218. case 2:
  5219. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5220. break;
  5221. case 3:
  5222. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5223. break;
  5224. case 4:
  5225. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_4;
  5226. break;
  5227. case 6:
  5228. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_6;
  5229. break;
  5230. case 8:
  5231. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_8;
  5232. break;
  5233. case 16:
  5234. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_16;
  5235. break;
  5236. default:
  5237. dev_err(codec->dev,
  5238. "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n",
  5239. __func__, div_factor, mclk_rate, dmic_clk_rate);
  5240. break;
  5241. }
  5242. done:
  5243. return dmic_ctl_val;
  5244. }
  5245. static int tasha_codec_enable_adc(struct snd_soc_dapm_widget *w,
  5246. struct snd_kcontrol *kcontrol, int event)
  5247. {
  5248. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5249. dev_dbg(codec->dev, "%s: event:%d\n", __func__, event);
  5250. switch (event) {
  5251. case SND_SOC_DAPM_PRE_PMU:
  5252. tasha_codec_set_tx_hold(codec, w->reg, true);
  5253. break;
  5254. default:
  5255. break;
  5256. }
  5257. return 0;
  5258. }
  5259. static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w,
  5260. struct snd_kcontrol *kcontrol, int event)
  5261. {
  5262. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5263. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5264. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  5265. u8 dmic_clk_en = 0x01;
  5266. u16 dmic_clk_reg;
  5267. s32 *dmic_clk_cnt;
  5268. u8 dmic_rate_val, dmic_rate_shift = 1;
  5269. unsigned int dmic;
  5270. u32 dmic_sample_rate;
  5271. int ret;
  5272. char *wname;
  5273. wname = strpbrk(w->name, "012345");
  5274. if (!wname) {
  5275. dev_err(codec->dev, "%s: widget not found\n", __func__);
  5276. return -EINVAL;
  5277. }
  5278. ret = kstrtouint(wname, 10, &dmic);
  5279. if (ret < 0) {
  5280. dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n",
  5281. __func__);
  5282. return -EINVAL;
  5283. }
  5284. switch (dmic) {
  5285. case 0:
  5286. case 1:
  5287. dmic_clk_cnt = &(tasha->dmic_0_1_clk_cnt);
  5288. dmic_clk_reg = WCD9335_CPE_SS_DMIC0_CTL;
  5289. break;
  5290. case 2:
  5291. case 3:
  5292. dmic_clk_cnt = &(tasha->dmic_2_3_clk_cnt);
  5293. dmic_clk_reg = WCD9335_CPE_SS_DMIC1_CTL;
  5294. break;
  5295. case 4:
  5296. case 5:
  5297. dmic_clk_cnt = &(tasha->dmic_4_5_clk_cnt);
  5298. dmic_clk_reg = WCD9335_CPE_SS_DMIC2_CTL;
  5299. break;
  5300. default:
  5301. dev_err(codec->dev, "%s: Invalid DMIC Selection\n",
  5302. __func__);
  5303. return -EINVAL;
  5304. };
  5305. dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
  5306. __func__, event, dmic, *dmic_clk_cnt);
  5307. switch (event) {
  5308. case SND_SOC_DAPM_PRE_PMU:
  5309. dmic_sample_rate = tasha_get_dmic_sample_rate(codec, dmic,
  5310. pdata);
  5311. dmic_rate_val =
  5312. tasha_get_dmic_clk_val(codec,
  5313. pdata->mclk_rate,
  5314. dmic_sample_rate);
  5315. (*dmic_clk_cnt)++;
  5316. if (*dmic_clk_cnt == 1) {
  5317. snd_soc_update_bits(codec, dmic_clk_reg,
  5318. 0x07 << dmic_rate_shift,
  5319. dmic_rate_val << dmic_rate_shift);
  5320. snd_soc_update_bits(codec, dmic_clk_reg,
  5321. dmic_clk_en, dmic_clk_en);
  5322. }
  5323. break;
  5324. case SND_SOC_DAPM_POST_PMD:
  5325. dmic_rate_val =
  5326. tasha_get_dmic_clk_val(codec,
  5327. pdata->mclk_rate,
  5328. pdata->mad_dmic_sample_rate);
  5329. (*dmic_clk_cnt)--;
  5330. if (*dmic_clk_cnt == 0) {
  5331. snd_soc_update_bits(codec, dmic_clk_reg,
  5332. dmic_clk_en, 0);
  5333. snd_soc_update_bits(codec, dmic_clk_reg,
  5334. 0x07 << dmic_rate_shift,
  5335. dmic_rate_val << dmic_rate_shift);
  5336. }
  5337. break;
  5338. };
  5339. return 0;
  5340. }
  5341. static int __tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5342. int event)
  5343. {
  5344. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5345. int micb_num;
  5346. dev_dbg(codec->dev, "%s: wname: %s, event: %d\n",
  5347. __func__, w->name, event);
  5348. if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1")))
  5349. micb_num = MIC_BIAS_1;
  5350. else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2")))
  5351. micb_num = MIC_BIAS_2;
  5352. else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3")))
  5353. micb_num = MIC_BIAS_3;
  5354. else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4")))
  5355. micb_num = MIC_BIAS_4;
  5356. else
  5357. return -EINVAL;
  5358. switch (event) {
  5359. case SND_SOC_DAPM_PRE_PMU:
  5360. /*
  5361. * MIC BIAS can also be requested by MBHC,
  5362. * so use ref count to handle micbias pullup
  5363. * and enable requests
  5364. */
  5365. tasha_micbias_control(codec, micb_num, MICB_ENABLE, true);
  5366. break;
  5367. case SND_SOC_DAPM_POST_PMU:
  5368. /* wait for cnp time */
  5369. usleep_range(1000, 1100);
  5370. break;
  5371. case SND_SOC_DAPM_POST_PMD:
  5372. tasha_micbias_control(codec, micb_num, MICB_DISABLE, true);
  5373. break;
  5374. };
  5375. return 0;
  5376. }
  5377. static int tasha_codec_ldo_h_control(struct snd_soc_dapm_widget *w,
  5378. int event)
  5379. {
  5380. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5381. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5382. if (SND_SOC_DAPM_EVENT_ON(event)) {
  5383. tasha->ldo_h_users++;
  5384. if (tasha->ldo_h_users == 1)
  5385. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5386. 0x80, 0x80);
  5387. }
  5388. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  5389. tasha->ldo_h_users--;
  5390. if (tasha->ldo_h_users < 0)
  5391. tasha->ldo_h_users = 0;
  5392. if (tasha->ldo_h_users == 0)
  5393. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5394. 0x80, 0x00);
  5395. }
  5396. return 0;
  5397. }
  5398. static int tasha_codec_force_enable_ldo_h(struct snd_soc_dapm_widget *w,
  5399. struct snd_kcontrol *kcontrol,
  5400. int event)
  5401. {
  5402. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5403. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5404. switch (event) {
  5405. case SND_SOC_DAPM_PRE_PMU:
  5406. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5407. tasha_codec_ldo_h_control(w, event);
  5408. break;
  5409. case SND_SOC_DAPM_POST_PMD:
  5410. tasha_codec_ldo_h_control(w, event);
  5411. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5412. break;
  5413. }
  5414. return 0;
  5415. }
  5416. static int tasha_codec_force_enable_micbias(struct snd_soc_dapm_widget *w,
  5417. struct snd_kcontrol *kcontrol,
  5418. int event)
  5419. {
  5420. int ret = 0;
  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_cdc_mclk_enable(codec, true, true);
  5427. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_PRE_PMU);
  5428. /* Wait for 1ms for better cnp */
  5429. usleep_range(1000, 1100);
  5430. tasha_cdc_mclk_enable(codec, false, true);
  5431. break;
  5432. case SND_SOC_DAPM_POST_PMD:
  5433. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_POST_PMD);
  5434. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5435. break;
  5436. }
  5437. return ret;
  5438. }
  5439. static int tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5440. struct snd_kcontrol *kcontrol, int event)
  5441. {
  5442. return __tasha_codec_enable_micbias(w, event);
  5443. }
  5444. static int tasha_codec_enable_standalone_ldo_h(struct snd_soc_codec *codec,
  5445. bool enable)
  5446. {
  5447. int rc;
  5448. if (enable)
  5449. rc = snd_soc_dapm_force_enable_pin(
  5450. snd_soc_codec_get_dapm(codec),
  5451. DAPM_LDO_H_STANDALONE);
  5452. else
  5453. rc = snd_soc_dapm_disable_pin(
  5454. snd_soc_codec_get_dapm(codec),
  5455. DAPM_LDO_H_STANDALONE);
  5456. if (!rc)
  5457. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5458. else
  5459. dev_err(codec->dev, "%s: ldo_h force %s pin failed\n",
  5460. __func__, (enable ? "enable" : "disable"));
  5461. return rc;
  5462. }
  5463. /*
  5464. * tasha_codec_enable_standalone_micbias - enable micbias standalone
  5465. * @codec: pointer to codec instance
  5466. * @micb_num: number of micbias to be enabled
  5467. * @enable: true to enable micbias or false to disable
  5468. *
  5469. * This function is used to enable micbias (1, 2, 3 or 4) during
  5470. * standalone independent of whether TX use-case is running or not
  5471. *
  5472. * Return: error code in case of failure or 0 for success
  5473. */
  5474. int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
  5475. int micb_num,
  5476. bool enable)
  5477. {
  5478. const char * const micb_names[] = {
  5479. DAPM_MICBIAS1_STANDALONE, DAPM_MICBIAS2_STANDALONE,
  5480. DAPM_MICBIAS3_STANDALONE, DAPM_MICBIAS4_STANDALONE
  5481. };
  5482. int micb_index = micb_num - 1;
  5483. int rc;
  5484. if (!codec) {
  5485. pr_err("%s: Codec memory is NULL\n", __func__);
  5486. return -EINVAL;
  5487. }
  5488. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  5489. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  5490. __func__, micb_index);
  5491. return -EINVAL;
  5492. }
  5493. if (enable)
  5494. rc = snd_soc_dapm_force_enable_pin(
  5495. snd_soc_codec_get_dapm(codec),
  5496. micb_names[micb_index]);
  5497. else
  5498. rc = snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec),
  5499. micb_names[micb_index]);
  5500. if (!rc)
  5501. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5502. else
  5503. dev_err(codec->dev, "%s: micbias%d force %s pin failed\n",
  5504. __func__, micb_num, (enable ? "enable" : "disable"));
  5505. return rc;
  5506. }
  5507. EXPORT_SYMBOL(tasha_codec_enable_standalone_micbias);
  5508. static const char *const tasha_anc_func_text[] = {"OFF", "ON"};
  5509. static const struct soc_enum tasha_anc_func_enum =
  5510. SOC_ENUM_SINGLE_EXT(2, tasha_anc_func_text);
  5511. static const char *const tasha_clkmode_text[] = {"EXTERNAL", "INTERNAL"};
  5512. static SOC_ENUM_SINGLE_EXT_DECL(tasha_clkmode_enum, tasha_clkmode_text);
  5513. /* Cutoff frequency for high pass filter */
  5514. static const char * const cf_text[] = {
  5515. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
  5516. };
  5517. static const char * const rx_cf_text[] = {
  5518. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ",
  5519. "CF_NEG_3DB_0P48HZ"
  5520. };
  5521. static const struct soc_enum cf_dec0_enum =
  5522. SOC_ENUM_SINGLE(WCD9335_CDC_TX0_TX_PATH_CFG0, 5, 3, cf_text);
  5523. static const struct soc_enum cf_dec1_enum =
  5524. SOC_ENUM_SINGLE(WCD9335_CDC_TX1_TX_PATH_CFG0, 5, 3, cf_text);
  5525. static const struct soc_enum cf_dec2_enum =
  5526. SOC_ENUM_SINGLE(WCD9335_CDC_TX2_TX_PATH_CFG0, 5, 3, cf_text);
  5527. static const struct soc_enum cf_dec3_enum =
  5528. SOC_ENUM_SINGLE(WCD9335_CDC_TX3_TX_PATH_CFG0, 5, 3, cf_text);
  5529. static const struct soc_enum cf_dec4_enum =
  5530. SOC_ENUM_SINGLE(WCD9335_CDC_TX4_TX_PATH_CFG0, 5, 3, cf_text);
  5531. static const struct soc_enum cf_dec5_enum =
  5532. SOC_ENUM_SINGLE(WCD9335_CDC_TX5_TX_PATH_CFG0, 5, 3, cf_text);
  5533. static const struct soc_enum cf_dec6_enum =
  5534. SOC_ENUM_SINGLE(WCD9335_CDC_TX6_TX_PATH_CFG0, 5, 3, cf_text);
  5535. static const struct soc_enum cf_dec7_enum =
  5536. SOC_ENUM_SINGLE(WCD9335_CDC_TX7_TX_PATH_CFG0, 5, 3, cf_text);
  5537. static const struct soc_enum cf_dec8_enum =
  5538. SOC_ENUM_SINGLE(WCD9335_CDC_TX8_TX_PATH_CFG0, 5, 3, cf_text);
  5539. static const struct soc_enum cf_int0_1_enum =
  5540. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5541. static SOC_ENUM_SINGLE_DECL(cf_int0_2_enum, WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 2,
  5542. rx_cf_text);
  5543. static const struct soc_enum cf_int1_1_enum =
  5544. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5545. static SOC_ENUM_SINGLE_DECL(cf_int1_2_enum, WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 2,
  5546. rx_cf_text);
  5547. static const struct soc_enum cf_int2_1_enum =
  5548. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5549. static SOC_ENUM_SINGLE_DECL(cf_int2_2_enum, WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 2,
  5550. rx_cf_text);
  5551. static const struct soc_enum cf_int3_1_enum =
  5552. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5553. static SOC_ENUM_SINGLE_DECL(cf_int3_2_enum, WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 2,
  5554. rx_cf_text);
  5555. static const struct soc_enum cf_int4_1_enum =
  5556. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5557. static SOC_ENUM_SINGLE_DECL(cf_int4_2_enum, WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 2,
  5558. rx_cf_text);
  5559. static const struct soc_enum cf_int5_1_enum =
  5560. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5561. static SOC_ENUM_SINGLE_DECL(cf_int5_2_enum, WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 2,
  5562. rx_cf_text);
  5563. static const struct soc_enum cf_int6_1_enum =
  5564. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5565. static SOC_ENUM_SINGLE_DECL(cf_int6_2_enum, WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 2,
  5566. rx_cf_text);
  5567. static const struct soc_enum cf_int7_1_enum =
  5568. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5569. static SOC_ENUM_SINGLE_DECL(cf_int7_2_enum, WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 2,
  5570. rx_cf_text);
  5571. static const struct soc_enum cf_int8_1_enum =
  5572. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5573. static SOC_ENUM_SINGLE_DECL(cf_int8_2_enum, WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 2,
  5574. rx_cf_text);
  5575. static const struct snd_soc_dapm_route audio_i2s_map[] = {
  5576. {"SLIM RX0 MUX", NULL, "RX_I2S_CTL"},
  5577. {"SLIM RX1 MUX", NULL, "RX_I2S_CTL"},
  5578. {"SLIM RX2 MUX", NULL, "RX_I2S_CTL"},
  5579. {"SLIM RX3 MUX", NULL, "RX_I2S_CTL"},
  5580. {"SLIM TX6 MUX", NULL, "TX_I2S_CTL"},
  5581. {"SLIM TX7 MUX", NULL, "TX_I2S_CTL"},
  5582. {"SLIM TX8 MUX", NULL, "TX_I2S_CTL"},
  5583. {"SLIM TX11 MUX", NULL, "TX_I2S_CTL"},
  5584. };
  5585. static const struct snd_soc_dapm_route audio_map[] = {
  5586. /* MAD */
  5587. {"MAD_SEL MUX", "SPE", "MAD_CPE_INPUT"},
  5588. {"MAD_SEL MUX", "MSM", "MADINPUT"},
  5589. {"MADONOFF", "Switch", "MAD_SEL MUX"},
  5590. {"MAD_BROADCAST", "Switch", "MAD_SEL MUX"},
  5591. {"TX13 INP MUX", "CPE_TX_PP", "MADONOFF"},
  5592. /* CPE HW MAD bypass */
  5593. {"CPE IN Mixer", "MAD_BYPASS", "SLIM TX1 MUX"},
  5594. {"AIF4_MAD Mixer", "SLIM TX1", "CPE IN Mixer"},
  5595. {"AIF4_MAD Mixer", "SLIM TX12", "MADONOFF"},
  5596. {"AIF4_MAD Mixer", "SLIM TX13", "TX13 INP MUX"},
  5597. {"AIF4 MAD", NULL, "AIF4_MAD Mixer"},
  5598. {"AIF4 MAD", NULL, "AIF4"},
  5599. {"EC BUF MUX INP", "DEC1", "ADC MUX1"},
  5600. {"AIF5 CPE", NULL, "EC BUF MUX INP"},
  5601. /* SLIMBUS Connections */
  5602. {"AIF1 CAP", NULL, "AIF1_CAP Mixer"},
  5603. {"AIF2 CAP", NULL, "AIF2_CAP Mixer"},
  5604. {"AIF3 CAP", NULL, "AIF3_CAP Mixer"},
  5605. /* VI Feedback */
  5606. {"AIF4_VI Mixer", "SPKR_VI_1", "VIINPUT"},
  5607. {"AIF4_VI Mixer", "SPKR_VI_2", "VIINPUT"},
  5608. {"AIF4 VI", NULL, "AIF4_VI Mixer"},
  5609. /* SLIM_MIXER("AIF1_CAP Mixer"),*/
  5610. {"AIF1_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5611. {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5612. {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5613. {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5614. {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5615. {"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5616. {"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5617. {"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5618. {"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5619. {"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5620. {"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5621. {"AIF1_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5622. {"AIF1_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5623. /* SLIM_MIXER("AIF2_CAP Mixer"),*/
  5624. {"AIF2_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5625. {"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5626. {"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5627. {"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5628. {"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5629. {"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5630. {"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5631. {"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5632. {"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5633. {"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5634. {"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5635. {"AIF2_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5636. {"AIF2_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5637. /* SLIM_MIXER("AIF3_CAP Mixer"),*/
  5638. {"AIF3_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5639. {"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5640. {"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5641. {"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5642. {"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5643. {"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5644. {"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5645. {"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5646. {"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5647. {"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5648. {"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5649. {"AIF3_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5650. {"AIF3_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5651. {"SLIM TX0 MUX", "DEC0", "ADC MUX0"},
  5652. {"SLIM TX0 MUX", "RX_MIX_TX0", "RX MIX TX0 MUX"},
  5653. {"SLIM TX0 MUX", "DEC0_192", "ADC US MUX0"},
  5654. {"SLIM TX1 MUX", "DEC1", "ADC MUX1"},
  5655. {"SLIM TX1 MUX", "RX_MIX_TX1", "RX MIX TX1 MUX"},
  5656. {"SLIM TX1 MUX", "DEC1_192", "ADC US MUX1"},
  5657. {"SLIM TX2 MUX", "DEC2", "ADC MUX2"},
  5658. {"SLIM TX2 MUX", "RX_MIX_TX2", "RX MIX TX2 MUX"},
  5659. {"SLIM TX2 MUX", "DEC2_192", "ADC US MUX2"},
  5660. {"SLIM TX3 MUX", "DEC3", "ADC MUX3"},
  5661. {"SLIM TX3 MUX", "RX_MIX_TX3", "RX MIX TX3 MUX"},
  5662. {"SLIM TX3 MUX", "DEC3_192", "ADC US MUX3"},
  5663. {"SLIM TX4 MUX", "DEC4", "ADC MUX4"},
  5664. {"SLIM TX4 MUX", "RX_MIX_TX4", "RX MIX TX4 MUX"},
  5665. {"SLIM TX4 MUX", "DEC4_192", "ADC US MUX4"},
  5666. {"SLIM TX5 MUX", "DEC5", "ADC MUX5"},
  5667. {"SLIM TX5 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5668. {"SLIM TX5 MUX", "DEC5_192", "ADC US MUX5"},
  5669. {"SLIM TX6 MUX", "DEC6", "ADC MUX6"},
  5670. {"SLIM TX6 MUX", "RX_MIX_TX6", "RX MIX TX6 MUX"},
  5671. {"SLIM TX6 MUX", "DEC6_192", "ADC US MUX6"},
  5672. {"SLIM TX7 MUX", "DEC7", "ADC MUX7"},
  5673. {"SLIM TX7 MUX", "RX_MIX_TX7", "RX MIX TX7 MUX"},
  5674. {"SLIM TX7 MUX", "DEC7_192", "ADC US MUX7"},
  5675. {"SLIM TX8 MUX", "DEC8", "ADC MUX8"},
  5676. {"SLIM TX8 MUX", "RX_MIX_TX8", "RX MIX TX8 MUX"},
  5677. {"SLIM TX8 MUX", "DEC8_192", "ADC US MUX8"},
  5678. {"SLIM TX9 MUX", "DEC7", "ADC MUX7"},
  5679. {"SLIM TX9 MUX", "DEC7_192", "ADC US MUX7"},
  5680. {"SLIM TX10 MUX", "DEC6", "ADC MUX6"},
  5681. {"SLIM TX10 MUX", "DEC6_192", "ADC US MUX6"},
  5682. {"SLIM TX11 MUX", "DEC_0_5", "SLIM TX11 INP1 MUX"},
  5683. {"SLIM TX11 MUX", "DEC_9_12", "SLIM TX11 INP1 MUX"},
  5684. {"SLIM TX11 INP1 MUX", "DEC0", "ADC MUX0"},
  5685. {"SLIM TX11 INP1 MUX", "DEC1", "ADC MUX1"},
  5686. {"SLIM TX11 INP1 MUX", "DEC2", "ADC MUX2"},
  5687. {"SLIM TX11 INP1 MUX", "DEC3", "ADC MUX3"},
  5688. {"SLIM TX11 INP1 MUX", "DEC4", "ADC MUX4"},
  5689. {"SLIM TX11 INP1 MUX", "DEC5", "ADC MUX5"},
  5690. {"SLIM TX11 INP1 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5691. {"TX13 INP MUX", "MAD_BRDCST", "MAD_BROADCAST"},
  5692. {"TX13 INP MUX", "CDC_DEC_5", "SLIM TX13 MUX"},
  5693. {"SLIM TX13 MUX", "DEC5", "ADC MUX5"},
  5694. {"RX MIX TX0 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5695. {"RX MIX TX0 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5696. {"RX MIX TX0 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5697. {"RX MIX TX0 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5698. {"RX MIX TX0 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5699. {"RX MIX TX0 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5700. {"RX MIX TX0 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5701. {"RX MIX TX0 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5702. {"RX MIX TX0 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5703. {"RX MIX TX0 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5704. {"RX MIX TX0 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5705. {"RX MIX TX0 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5706. {"RX MIX TX0 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5707. {"RX MIX TX1 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5708. {"RX MIX TX1 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5709. {"RX MIX TX1 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5710. {"RX MIX TX1 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5711. {"RX MIX TX1 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5712. {"RX MIX TX1 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5713. {"RX MIX TX1 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5714. {"RX MIX TX1 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5715. {"RX MIX TX1 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5716. {"RX MIX TX1 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5717. {"RX MIX TX1 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5718. {"RX MIX TX1 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5719. {"RX MIX TX1 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5720. {"RX MIX TX2 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5721. {"RX MIX TX2 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5722. {"RX MIX TX2 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5723. {"RX MIX TX2 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5724. {"RX MIX TX2 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5725. {"RX MIX TX2 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5726. {"RX MIX TX2 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5727. {"RX MIX TX2 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5728. {"RX MIX TX2 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5729. {"RX MIX TX2 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5730. {"RX MIX TX2 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5731. {"RX MIX TX2 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5732. {"RX MIX TX2 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5733. {"RX MIX TX3 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5734. {"RX MIX TX3 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5735. {"RX MIX TX3 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5736. {"RX MIX TX3 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5737. {"RX MIX TX3 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5738. {"RX MIX TX3 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5739. {"RX MIX TX3 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5740. {"RX MIX TX3 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5741. {"RX MIX TX3 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5742. {"RX MIX TX3 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5743. {"RX MIX TX3 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5744. {"RX MIX TX3 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5745. {"RX MIX TX3 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5746. {"RX MIX TX4 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5747. {"RX MIX TX4 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5748. {"RX MIX TX4 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5749. {"RX MIX TX4 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5750. {"RX MIX TX4 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5751. {"RX MIX TX4 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5752. {"RX MIX TX4 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5753. {"RX MIX TX4 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5754. {"RX MIX TX4 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5755. {"RX MIX TX4 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5756. {"RX MIX TX4 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5757. {"RX MIX TX4 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5758. {"RX MIX TX4 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5759. {"RX MIX TX5 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5760. {"RX MIX TX5 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5761. {"RX MIX TX5 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5762. {"RX MIX TX5 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5763. {"RX MIX TX5 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5764. {"RX MIX TX5 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5765. {"RX MIX TX5 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5766. {"RX MIX TX5 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5767. {"RX MIX TX5 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5768. {"RX MIX TX5 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5769. {"RX MIX TX5 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5770. {"RX MIX TX5 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5771. {"RX MIX TX5 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5772. {"RX MIX TX6 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5773. {"RX MIX TX6 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5774. {"RX MIX TX6 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5775. {"RX MIX TX6 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5776. {"RX MIX TX6 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5777. {"RX MIX TX6 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5778. {"RX MIX TX6 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5779. {"RX MIX TX6 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5780. {"RX MIX TX6 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5781. {"RX MIX TX6 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5782. {"RX MIX TX6 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5783. {"RX MIX TX6 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5784. {"RX MIX TX6 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5785. {"RX MIX TX7 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5786. {"RX MIX TX7 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5787. {"RX MIX TX7 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5788. {"RX MIX TX7 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5789. {"RX MIX TX7 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5790. {"RX MIX TX7 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5791. {"RX MIX TX7 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5792. {"RX MIX TX7 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5793. {"RX MIX TX7 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5794. {"RX MIX TX7 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5795. {"RX MIX TX7 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5796. {"RX MIX TX7 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5797. {"RX MIX TX7 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5798. {"RX MIX TX8 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5799. {"RX MIX TX8 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5800. {"RX MIX TX8 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5801. {"RX MIX TX8 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5802. {"RX MIX TX8 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5803. {"RX MIX TX8 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5804. {"RX MIX TX8 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5805. {"RX MIX TX8 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5806. {"RX MIX TX8 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5807. {"RX MIX TX8 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5808. {"RX MIX TX8 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5809. {"RX MIX TX8 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5810. {"RX MIX TX8 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5811. {"ADC US MUX0", "US_Switch", "ADC MUX0"},
  5812. {"ADC US MUX1", "US_Switch", "ADC MUX1"},
  5813. {"ADC US MUX2", "US_Switch", "ADC MUX2"},
  5814. {"ADC US MUX3", "US_Switch", "ADC MUX3"},
  5815. {"ADC US MUX4", "US_Switch", "ADC MUX4"},
  5816. {"ADC US MUX5", "US_Switch", "ADC MUX5"},
  5817. {"ADC US MUX6", "US_Switch", "ADC MUX6"},
  5818. {"ADC US MUX7", "US_Switch", "ADC MUX7"},
  5819. {"ADC US MUX8", "US_Switch", "ADC MUX8"},
  5820. {"ADC MUX0", "DMIC", "DMIC MUX0"},
  5821. {"ADC MUX0", "AMIC", "AMIC MUX0"},
  5822. {"ADC MUX1", "DMIC", "DMIC MUX1"},
  5823. {"ADC MUX1", "AMIC", "AMIC MUX1"},
  5824. {"ADC MUX2", "DMIC", "DMIC MUX2"},
  5825. {"ADC MUX2", "AMIC", "AMIC MUX2"},
  5826. {"ADC MUX3", "DMIC", "DMIC MUX3"},
  5827. {"ADC MUX3", "AMIC", "AMIC MUX3"},
  5828. {"ADC MUX4", "DMIC", "DMIC MUX4"},
  5829. {"ADC MUX4", "AMIC", "AMIC MUX4"},
  5830. {"ADC MUX5", "DMIC", "DMIC MUX5"},
  5831. {"ADC MUX5", "AMIC", "AMIC MUX5"},
  5832. {"ADC MUX6", "DMIC", "DMIC MUX6"},
  5833. {"ADC MUX6", "AMIC", "AMIC MUX6"},
  5834. {"ADC MUX7", "DMIC", "DMIC MUX7"},
  5835. {"ADC MUX7", "AMIC", "AMIC MUX7"},
  5836. {"ADC MUX8", "DMIC", "DMIC MUX8"},
  5837. {"ADC MUX8", "AMIC", "AMIC MUX8"},
  5838. {"ADC MUX10", "DMIC", "DMIC MUX10"},
  5839. {"ADC MUX10", "AMIC", "AMIC MUX10"},
  5840. {"ADC MUX11", "DMIC", "DMIC MUX11"},
  5841. {"ADC MUX11", "AMIC", "AMIC MUX11"},
  5842. {"ADC MUX12", "DMIC", "DMIC MUX12"},
  5843. {"ADC MUX12", "AMIC", "AMIC MUX12"},
  5844. {"ADC MUX13", "DMIC", "DMIC MUX13"},
  5845. {"ADC MUX13", "AMIC", "AMIC MUX13"},
  5846. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX10"},
  5847. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX11"},
  5848. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX12"},
  5849. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX13"},
  5850. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX10"},
  5851. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX11"},
  5852. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX12"},
  5853. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX13"},
  5854. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX10"},
  5855. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX11"},
  5856. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX12"},
  5857. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX13"},
  5858. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX10"},
  5859. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX11"},
  5860. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX12"},
  5861. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX13"},
  5862. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX10"},
  5863. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX11"},
  5864. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX12"},
  5865. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX13"},
  5866. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX10"},
  5867. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX11"},
  5868. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX12"},
  5869. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX13"},
  5870. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX10"},
  5871. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX11"},
  5872. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX12"},
  5873. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX13"},
  5874. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX10"},
  5875. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX11"},
  5876. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX12"},
  5877. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX13"},
  5878. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX10"},
  5879. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX11"},
  5880. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX12"},
  5881. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX13"},
  5882. {"DMIC MUX0", "DMIC0", "DMIC0"},
  5883. {"DMIC MUX0", "DMIC1", "DMIC1"},
  5884. {"DMIC MUX0", "DMIC2", "DMIC2"},
  5885. {"DMIC MUX0", "DMIC3", "DMIC3"},
  5886. {"DMIC MUX0", "DMIC4", "DMIC4"},
  5887. {"DMIC MUX0", "DMIC5", "DMIC5"},
  5888. {"AMIC MUX0", "ADC1", "ADC1"},
  5889. {"AMIC MUX0", "ADC2", "ADC2"},
  5890. {"AMIC MUX0", "ADC3", "ADC3"},
  5891. {"AMIC MUX0", "ADC4", "ADC4"},
  5892. {"AMIC MUX0", "ADC5", "ADC5"},
  5893. {"AMIC MUX0", "ADC6", "ADC6"},
  5894. {"DMIC MUX1", "DMIC0", "DMIC0"},
  5895. {"DMIC MUX1", "DMIC1", "DMIC1"},
  5896. {"DMIC MUX1", "DMIC2", "DMIC2"},
  5897. {"DMIC MUX1", "DMIC3", "DMIC3"},
  5898. {"DMIC MUX1", "DMIC4", "DMIC4"},
  5899. {"DMIC MUX1", "DMIC5", "DMIC5"},
  5900. {"AMIC MUX1", "ADC1", "ADC1"},
  5901. {"AMIC MUX1", "ADC2", "ADC2"},
  5902. {"AMIC MUX1", "ADC3", "ADC3"},
  5903. {"AMIC MUX1", "ADC4", "ADC4"},
  5904. {"AMIC MUX1", "ADC5", "ADC5"},
  5905. {"AMIC MUX1", "ADC6", "ADC6"},
  5906. {"DMIC MUX2", "DMIC0", "DMIC0"},
  5907. {"DMIC MUX2", "DMIC1", "DMIC1"},
  5908. {"DMIC MUX2", "DMIC2", "DMIC2"},
  5909. {"DMIC MUX2", "DMIC3", "DMIC3"},
  5910. {"DMIC MUX2", "DMIC4", "DMIC4"},
  5911. {"DMIC MUX2", "DMIC5", "DMIC5"},
  5912. {"AMIC MUX2", "ADC1", "ADC1"},
  5913. {"AMIC MUX2", "ADC2", "ADC2"},
  5914. {"AMIC MUX2", "ADC3", "ADC3"},
  5915. {"AMIC MUX2", "ADC4", "ADC4"},
  5916. {"AMIC MUX2", "ADC5", "ADC5"},
  5917. {"AMIC MUX2", "ADC6", "ADC6"},
  5918. {"DMIC MUX3", "DMIC0", "DMIC0"},
  5919. {"DMIC MUX3", "DMIC1", "DMIC1"},
  5920. {"DMIC MUX3", "DMIC2", "DMIC2"},
  5921. {"DMIC MUX3", "DMIC3", "DMIC3"},
  5922. {"DMIC MUX3", "DMIC4", "DMIC4"},
  5923. {"DMIC MUX3", "DMIC5", "DMIC5"},
  5924. {"AMIC MUX3", "ADC1", "ADC1"},
  5925. {"AMIC MUX3", "ADC2", "ADC2"},
  5926. {"AMIC MUX3", "ADC3", "ADC3"},
  5927. {"AMIC MUX3", "ADC4", "ADC4"},
  5928. {"AMIC MUX3", "ADC5", "ADC5"},
  5929. {"AMIC MUX3", "ADC6", "ADC6"},
  5930. {"DMIC MUX4", "DMIC0", "DMIC0"},
  5931. {"DMIC MUX4", "DMIC1", "DMIC1"},
  5932. {"DMIC MUX4", "DMIC2", "DMIC2"},
  5933. {"DMIC MUX4", "DMIC3", "DMIC3"},
  5934. {"DMIC MUX4", "DMIC4", "DMIC4"},
  5935. {"DMIC MUX4", "DMIC5", "DMIC5"},
  5936. {"AMIC MUX4", "ADC1", "ADC1"},
  5937. {"AMIC MUX4", "ADC2", "ADC2"},
  5938. {"AMIC MUX4", "ADC3", "ADC3"},
  5939. {"AMIC MUX4", "ADC4", "ADC4"},
  5940. {"AMIC MUX4", "ADC5", "ADC5"},
  5941. {"AMIC MUX4", "ADC6", "ADC6"},
  5942. {"DMIC MUX5", "DMIC0", "DMIC0"},
  5943. {"DMIC MUX5", "DMIC1", "DMIC1"},
  5944. {"DMIC MUX5", "DMIC2", "DMIC2"},
  5945. {"DMIC MUX5", "DMIC3", "DMIC3"},
  5946. {"DMIC MUX5", "DMIC4", "DMIC4"},
  5947. {"DMIC MUX5", "DMIC5", "DMIC5"},
  5948. {"AMIC MUX5", "ADC1", "ADC1"},
  5949. {"AMIC MUX5", "ADC2", "ADC2"},
  5950. {"AMIC MUX5", "ADC3", "ADC3"},
  5951. {"AMIC MUX5", "ADC4", "ADC4"},
  5952. {"AMIC MUX5", "ADC5", "ADC5"},
  5953. {"AMIC MUX5", "ADC6", "ADC6"},
  5954. {"DMIC MUX6", "DMIC0", "DMIC0"},
  5955. {"DMIC MUX6", "DMIC1", "DMIC1"},
  5956. {"DMIC MUX6", "DMIC2", "DMIC2"},
  5957. {"DMIC MUX6", "DMIC3", "DMIC3"},
  5958. {"DMIC MUX6", "DMIC4", "DMIC4"},
  5959. {"DMIC MUX6", "DMIC5", "DMIC5"},
  5960. {"AMIC MUX6", "ADC1", "ADC1"},
  5961. {"AMIC MUX6", "ADC2", "ADC2"},
  5962. {"AMIC MUX6", "ADC3", "ADC3"},
  5963. {"AMIC MUX6", "ADC4", "ADC4"},
  5964. {"AMIC MUX6", "ADC5", "ADC5"},
  5965. {"AMIC MUX6", "ADC6", "ADC6"},
  5966. {"DMIC MUX7", "DMIC0", "DMIC0"},
  5967. {"DMIC MUX7", "DMIC1", "DMIC1"},
  5968. {"DMIC MUX7", "DMIC2", "DMIC2"},
  5969. {"DMIC MUX7", "DMIC3", "DMIC3"},
  5970. {"DMIC MUX7", "DMIC4", "DMIC4"},
  5971. {"DMIC MUX7", "DMIC5", "DMIC5"},
  5972. {"AMIC MUX7", "ADC1", "ADC1"},
  5973. {"AMIC MUX7", "ADC2", "ADC2"},
  5974. {"AMIC MUX7", "ADC3", "ADC3"},
  5975. {"AMIC MUX7", "ADC4", "ADC4"},
  5976. {"AMIC MUX7", "ADC5", "ADC5"},
  5977. {"AMIC MUX7", "ADC6", "ADC6"},
  5978. {"DMIC MUX8", "DMIC0", "DMIC0"},
  5979. {"DMIC MUX8", "DMIC1", "DMIC1"},
  5980. {"DMIC MUX8", "DMIC2", "DMIC2"},
  5981. {"DMIC MUX8", "DMIC3", "DMIC3"},
  5982. {"DMIC MUX8", "DMIC4", "DMIC4"},
  5983. {"DMIC MUX8", "DMIC5", "DMIC5"},
  5984. {"AMIC MUX8", "ADC1", "ADC1"},
  5985. {"AMIC MUX8", "ADC2", "ADC2"},
  5986. {"AMIC MUX8", "ADC3", "ADC3"},
  5987. {"AMIC MUX8", "ADC4", "ADC4"},
  5988. {"AMIC MUX8", "ADC5", "ADC5"},
  5989. {"AMIC MUX8", "ADC6", "ADC6"},
  5990. {"DMIC MUX10", "DMIC0", "DMIC0"},
  5991. {"DMIC MUX10", "DMIC1", "DMIC1"},
  5992. {"DMIC MUX10", "DMIC2", "DMIC2"},
  5993. {"DMIC MUX10", "DMIC3", "DMIC3"},
  5994. {"DMIC MUX10", "DMIC4", "DMIC4"},
  5995. {"DMIC MUX10", "DMIC5", "DMIC5"},
  5996. {"AMIC MUX10", "ADC1", "ADC1"},
  5997. {"AMIC MUX10", "ADC2", "ADC2"},
  5998. {"AMIC MUX10", "ADC3", "ADC3"},
  5999. {"AMIC MUX10", "ADC4", "ADC4"},
  6000. {"AMIC MUX10", "ADC5", "ADC5"},
  6001. {"AMIC MUX10", "ADC6", "ADC6"},
  6002. {"DMIC MUX11", "DMIC0", "DMIC0"},
  6003. {"DMIC MUX11", "DMIC1", "DMIC1"},
  6004. {"DMIC MUX11", "DMIC2", "DMIC2"},
  6005. {"DMIC MUX11", "DMIC3", "DMIC3"},
  6006. {"DMIC MUX11", "DMIC4", "DMIC4"},
  6007. {"DMIC MUX11", "DMIC5", "DMIC5"},
  6008. {"AMIC MUX11", "ADC1", "ADC1"},
  6009. {"AMIC MUX11", "ADC2", "ADC2"},
  6010. {"AMIC MUX11", "ADC3", "ADC3"},
  6011. {"AMIC MUX11", "ADC4", "ADC4"},
  6012. {"AMIC MUX11", "ADC5", "ADC5"},
  6013. {"AMIC MUX11", "ADC6", "ADC6"},
  6014. {"DMIC MUX12", "DMIC0", "DMIC0"},
  6015. {"DMIC MUX12", "DMIC1", "DMIC1"},
  6016. {"DMIC MUX12", "DMIC2", "DMIC2"},
  6017. {"DMIC MUX12", "DMIC3", "DMIC3"},
  6018. {"DMIC MUX12", "DMIC4", "DMIC4"},
  6019. {"DMIC MUX12", "DMIC5", "DMIC5"},
  6020. {"AMIC MUX12", "ADC1", "ADC1"},
  6021. {"AMIC MUX12", "ADC2", "ADC2"},
  6022. {"AMIC MUX12", "ADC3", "ADC3"},
  6023. {"AMIC MUX12", "ADC4", "ADC4"},
  6024. {"AMIC MUX12", "ADC5", "ADC5"},
  6025. {"AMIC MUX12", "ADC6", "ADC6"},
  6026. {"DMIC MUX13", "DMIC0", "DMIC0"},
  6027. {"DMIC MUX13", "DMIC1", "DMIC1"},
  6028. {"DMIC MUX13", "DMIC2", "DMIC2"},
  6029. {"DMIC MUX13", "DMIC3", "DMIC3"},
  6030. {"DMIC MUX13", "DMIC4", "DMIC4"},
  6031. {"DMIC MUX13", "DMIC5", "DMIC5"},
  6032. {"AMIC MUX13", "ADC1", "ADC1"},
  6033. {"AMIC MUX13", "ADC2", "ADC2"},
  6034. {"AMIC MUX13", "ADC3", "ADC3"},
  6035. {"AMIC MUX13", "ADC4", "ADC4"},
  6036. {"AMIC MUX13", "ADC5", "ADC5"},
  6037. {"AMIC MUX13", "ADC6", "ADC6"},
  6038. /* ADC Connections */
  6039. {"ADC1", NULL, "AMIC1"},
  6040. {"ADC2", NULL, "AMIC2"},
  6041. {"ADC3", NULL, "AMIC3"},
  6042. {"ADC4", NULL, "AMIC4"},
  6043. {"ADC5", NULL, "AMIC5"},
  6044. {"ADC6", NULL, "AMIC6"},
  6045. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP0"},
  6046. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP1"},
  6047. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP2"},
  6048. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP0"},
  6049. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP1"},
  6050. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP2"},
  6051. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP0"},
  6052. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP1"},
  6053. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP2"},
  6054. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP0"},
  6055. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP1"},
  6056. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP2"},
  6057. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP0"},
  6058. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP1"},
  6059. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP2"},
  6060. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP0"},
  6061. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP1"},
  6062. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP2"},
  6063. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP0"},
  6064. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP1"},
  6065. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP2"},
  6066. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP0"},
  6067. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP1"},
  6068. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP2"},
  6069. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP0"},
  6070. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP1"},
  6071. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP2"},
  6072. {"RX INT0 SEC MIX", NULL, "RX INT0_1 MIX1"},
  6073. {"RX INT0 MIX2", NULL, "RX INT0 SEC MIX"},
  6074. {"RX INT0 MIX2", NULL, "RX INT0 MIX2 INP"},
  6075. {"RX INT0 INTERP", NULL, "RX INT0 MIX2"},
  6076. {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 INTERP"},
  6077. {"RX INT0 DAC", NULL, "RX INT0 DEM MUX"},
  6078. {"RX INT0 DAC", NULL, "RX_BIAS"},
  6079. {"EAR PA", NULL, "RX INT0 DAC"},
  6080. {"EAR", NULL, "EAR PA"},
  6081. {"SPL SRC0 MUX", "SRC_IN_HPHL", "RX INT1_1 MIX1"},
  6082. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 MIX1"},
  6083. {"RX INT1 SPLINE MIX", "HPHL Switch", "SPL SRC0 MUX"},
  6084. {"RX INT1_1 NATIVE MUX", "ON", "RX INT1_1 MIX1"},
  6085. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 NATIVE MUX"},
  6086. {"RX INT1_1 NATIVE MUX", NULL, "RX INT1 NATIVE SUPPLY"},
  6087. {"RX INT1 SEC MIX", NULL, "RX INT1 SPLINE MIX"},
  6088. {"RX INT1 MIX2", NULL, "RX INT1 SEC MIX"},
  6089. {"RX INT1 MIX2", NULL, "RX INT1 MIX2 INP"},
  6090. {"RX INT1 INTERP", NULL, "RX INT1 MIX2"},
  6091. {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 INTERP"},
  6092. {"RX INT1 DAC", NULL, "RX INT1 DEM MUX"},
  6093. {"RX INT1 DAC", NULL, "RX_BIAS"},
  6094. {"HPHL PA", NULL, "RX INT1 DAC"},
  6095. {"HPHL", NULL, "HPHL PA"},
  6096. {"SPL SRC1 MUX", "SRC_IN_HPHR", "RX INT2_1 MIX1"},
  6097. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 MIX1"},
  6098. {"RX INT2 SPLINE MIX", "HPHR Switch", "SPL SRC1 MUX"},
  6099. {"RX INT2_1 NATIVE MUX", "ON", "RX INT2_1 MIX1"},
  6100. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 NATIVE MUX"},
  6101. {"RX INT2_1 NATIVE MUX", NULL, "RX INT2 NATIVE SUPPLY"},
  6102. {"RX INT2 SEC MIX", NULL, "RX INT2 SPLINE MIX"},
  6103. {"RX INT2 MIX2", NULL, "RX INT2 SEC MIX"},
  6104. {"RX INT2 MIX2", NULL, "RX INT2 MIX2 INP"},
  6105. {"RX INT2 INTERP", NULL, "RX INT2 MIX2"},
  6106. {"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 INTERP"},
  6107. {"RX INT2 DAC", NULL, "RX INT2 DEM MUX"},
  6108. {"RX INT2 DAC", NULL, "RX_BIAS"},
  6109. {"HPHR PA", NULL, "RX INT2 DAC"},
  6110. {"HPHR", NULL, "HPHR PA"},
  6111. {"SPL SRC0 MUX", "SRC_IN_LO1", "RX INT3_1 MIX1"},
  6112. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 MIX1"},
  6113. {"RX INT3 SPLINE MIX", "LO1 Switch", "SPL SRC0 MUX"},
  6114. {"RX INT3_1 NATIVE MUX", "ON", "RX INT3_1 MIX1"},
  6115. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 NATIVE MUX"},
  6116. {"RX INT3_1 NATIVE MUX", NULL, "RX INT3 NATIVE SUPPLY"},
  6117. {"RX INT3 SEC MIX", NULL, "RX INT3 SPLINE MIX"},
  6118. {"RX INT3 MIX2", NULL, "RX INT3 SEC MIX"},
  6119. {"RX INT3 MIX2", NULL, "RX INT3 MIX2 INP"},
  6120. {"RX INT3 INTERP", NULL, "RX INT3 MIX2"},
  6121. {"RX INT3 DAC", NULL, "RX INT3 INTERP"},
  6122. {"RX INT3 DAC", NULL, "RX_BIAS"},
  6123. {"LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6124. {"LINEOUT1", NULL, "LINEOUT1 PA"},
  6125. {"SPL SRC1 MUX", "SRC_IN_LO2", "RX INT4_1 MIX1"},
  6126. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 MIX1"},
  6127. {"RX INT4 SPLINE MIX", "LO2 Switch", "SPL SRC1 MUX"},
  6128. {"RX INT4_1 NATIVE MUX", "ON", "RX INT4_1 MIX1"},
  6129. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 NATIVE MUX"},
  6130. {"RX INT4_1 NATIVE MUX", NULL, "RX INT4 NATIVE SUPPLY"},
  6131. {"RX INT4 SEC MIX", NULL, "RX INT4 SPLINE MIX"},
  6132. {"RX INT4 MIX2", NULL, "RX INT4 SEC MIX"},
  6133. {"RX INT4 MIX2", NULL, "RX INT4 MIX2 INP"},
  6134. {"RX INT4 INTERP", NULL, "RX INT4 MIX2"},
  6135. {"RX INT4 DAC", NULL, "RX INT4 INTERP"},
  6136. {"RX INT4 DAC", NULL, "RX_BIAS"},
  6137. {"LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6138. {"LINEOUT2", NULL, "LINEOUT2 PA"},
  6139. {"SPL SRC2 MUX", "SRC_IN_LO3", "RX INT5_1 MIX1"},
  6140. {"RX INT5 SPLINE MIX", NULL, "RX INT5_1 MIX1"},
  6141. {"RX INT5 SPLINE MIX", "LO3 Switch", "SPL SRC2 MUX"},
  6142. {"RX INT5 SEC MIX", NULL, "RX INT5 SPLINE MIX"},
  6143. {"RX INT5 MIX2", NULL, "RX INT5 SEC MIX"},
  6144. {"RX INT5 INTERP", NULL, "RX INT5 MIX2"},
  6145. {"RX INT5 VBAT", "LO3 VBAT Enable", "RX INT5 INTERP"},
  6146. {"RX INT5 DAC", NULL, "RX INT5 VBAT"},
  6147. {"RX INT5 DAC", NULL, "RX INT5 INTERP"},
  6148. {"RX INT5 DAC", NULL, "RX_BIAS"},
  6149. {"LINEOUT3 PA", NULL, "RX INT5 DAC"},
  6150. {"LINEOUT3", NULL, "LINEOUT3 PA"},
  6151. {"SPL SRC3 MUX", "SRC_IN_LO4", "RX INT6_1 MIX1"},
  6152. {"RX INT6 SPLINE MIX", NULL, "RX INT6_1 MIX1"},
  6153. {"RX INT6 SPLINE MIX", "LO4 Switch", "SPL SRC3 MUX"},
  6154. {"RX INT6 SEC MIX", NULL, "RX INT6 SPLINE MIX"},
  6155. {"RX INT6 MIX2", NULL, "RX INT6 SEC MIX"},
  6156. {"RX INT6 INTERP", NULL, "RX INT6 MIX2"},
  6157. {"RX INT6 VBAT", "LO4 VBAT Enable", "RX INT6 INTERP"},
  6158. {"RX INT6 DAC", NULL, "RX INT6 VBAT"},
  6159. {"RX INT6 DAC", NULL, "RX INT6 INTERP"},
  6160. {"RX INT6 DAC", NULL, "RX_BIAS"},
  6161. {"LINEOUT4 PA", NULL, "RX INT6 DAC"},
  6162. {"LINEOUT4", NULL, "LINEOUT4 PA"},
  6163. {"SPL SRC2 MUX", "SRC_IN_SPKRL", "RX INT7_1 MIX1"},
  6164. {"RX INT7 SPLINE MIX", NULL, "RX INT7_1 MIX1"},
  6165. {"RX INT7 SPLINE MIX", "SPKRL Switch", "SPL SRC2 MUX"},
  6166. {"RX INT7 SEC MIX", NULL, "RX INT7 SPLINE MIX"},
  6167. {"RX INT7 MIX2", NULL, "RX INT7 SEC MIX"},
  6168. {"RX INT7 MIX2", NULL, "RX INT7 MIX2 INP"},
  6169. {"RX INT7 INTERP", NULL, "RX INT7 MIX2"},
  6170. {"RX INT7 VBAT", "SPKRL VBAT Enable", "RX INT7 INTERP"},
  6171. {"RX INT7 CHAIN", NULL, "RX INT7 VBAT"},
  6172. {"RX INT7 CHAIN", NULL, "RX INT7 INTERP"},
  6173. {"RX INT7 CHAIN", NULL, "RX_BIAS"},
  6174. {"SPK1 OUT", NULL, "RX INT7 CHAIN"},
  6175. {"ANC SPKR PA Enable", "Switch", "RX INT7 CHAIN"},
  6176. {"ANC SPK1 PA", NULL, "ANC SPKR PA Enable"},
  6177. {"SPK1 OUT", NULL, "ANC SPK1 PA"},
  6178. {"SPL SRC3 MUX", "SRC_IN_SPKRR", "RX INT8_1 MIX1"},
  6179. {"RX INT8 SPLINE MIX", NULL, "RX INT8_1 MIX1"},
  6180. {"RX INT8 SPLINE MIX", "SPKRR Switch", "SPL SRC3 MUX"},
  6181. {"RX INT8 SEC MIX", NULL, "RX INT8 SPLINE MIX"},
  6182. {"RX INT8 INTERP", NULL, "RX INT8 SEC MIX"},
  6183. {"RX INT8 VBAT", "SPKRR VBAT Enable", "RX INT8 INTERP"},
  6184. {"RX INT8 CHAIN", NULL, "RX INT8 VBAT"},
  6185. {"RX INT8 CHAIN", NULL, "RX INT8 INTERP"},
  6186. {"RX INT8 CHAIN", NULL, "RX_BIAS"},
  6187. {"SPK2 OUT", NULL, "RX INT8 CHAIN"},
  6188. {"ANC0 FB MUX", "ANC_IN_EAR", "RX INT0 MIX2"},
  6189. {"ANC0 FB MUX", "ANC_IN_HPHL", "RX INT1 MIX2"},
  6190. {"ANC0 FB MUX", "ANC_IN_LO1", "RX INT3 MIX2"},
  6191. {"ANC0 FB MUX", "ANC_IN_EAR_SPKR", "RX INT7 MIX2"},
  6192. {"ANC1 FB MUX", "ANC_IN_HPHR", "RX INT2 MIX2"},
  6193. {"ANC1 FB MUX", "ANC_IN_LO2", "RX INT4 MIX2"},
  6194. {"ANC HPHL Enable", "Switch", "ADC MUX10"},
  6195. {"ANC HPHL Enable", "Switch", "ADC MUX11"},
  6196. {"RX INT1 MIX2", NULL, "ANC HPHL Enable"},
  6197. {"ANC HPHR Enable", "Switch", "ADC MUX12"},
  6198. {"ANC HPHR Enable", "Switch", "ADC MUX13"},
  6199. {"RX INT2 MIX2", NULL, "ANC HPHR Enable"},
  6200. {"ANC EAR Enable", "Switch", "ADC MUX10"},
  6201. {"ANC EAR Enable", "Switch", "ADC MUX11"},
  6202. {"RX INT0 MIX2", NULL, "ANC EAR Enable"},
  6203. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX10"},
  6204. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX11"},
  6205. {"RX INT7 MIX2", NULL, "ANC OUT EAR SPKR Enable"},
  6206. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX10"},
  6207. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX11"},
  6208. {"RX INT3 MIX2", NULL, "ANC LINEOUT1 Enable"},
  6209. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX12"},
  6210. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX13"},
  6211. {"RX INT4 MIX2", NULL, "ANC LINEOUT2 Enable"},
  6212. {"ANC EAR PA", NULL, "RX INT0 DAC"},
  6213. {"ANC EAR", NULL, "ANC EAR PA"},
  6214. {"ANC HPHL PA", NULL, "RX INT1 DAC"},
  6215. {"ANC HPHL", NULL, "ANC HPHL PA"},
  6216. {"ANC HPHR PA", NULL, "RX INT2 DAC"},
  6217. {"ANC HPHR", NULL, "ANC HPHR PA"},
  6218. {"ANC LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6219. {"ANC LINEOUT1", NULL, "ANC LINEOUT1 PA"},
  6220. {"ANC LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6221. {"ANC LINEOUT2", NULL, "ANC LINEOUT2 PA"},
  6222. /* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/
  6223. {"SLIM RX0 MUX", "AIF1_PB", "AIF1 PB"},
  6224. {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
  6225. {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
  6226. {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
  6227. {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
  6228. {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
  6229. {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
  6230. {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
  6231. /* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/
  6232. {"SLIM RX0 MUX", "AIF2_PB", "AIF2 PB"},
  6233. {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
  6234. {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
  6235. {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
  6236. {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
  6237. {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
  6238. {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
  6239. {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
  6240. /* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/
  6241. {"SLIM RX0 MUX", "AIF3_PB", "AIF3 PB"},
  6242. {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
  6243. {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
  6244. {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
  6245. {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
  6246. {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
  6247. {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
  6248. {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
  6249. /* SLIM_MUX("AIF4_PB", "AIF4 PB"),*/
  6250. {"SLIM RX0 MUX", "AIF4_PB", "AIF4 PB"},
  6251. {"SLIM RX1 MUX", "AIF4_PB", "AIF4 PB"},
  6252. {"SLIM RX2 MUX", "AIF4_PB", "AIF4 PB"},
  6253. {"SLIM RX3 MUX", "AIF4_PB", "AIF4 PB"},
  6254. {"SLIM RX4 MUX", "AIF4_PB", "AIF4 PB"},
  6255. {"SLIM RX5 MUX", "AIF4_PB", "AIF4 PB"},
  6256. {"SLIM RX6 MUX", "AIF4_PB", "AIF4 PB"},
  6257. {"SLIM RX7 MUX", "AIF4_PB", "AIF4 PB"},
  6258. /* SLIM_MUX("AIF_MIX1_PB", "AIF MIX1 PB"),*/
  6259. {"SLIM RX0 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6260. {"SLIM RX1 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6261. {"SLIM RX2 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6262. {"SLIM RX3 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6263. {"SLIM RX4 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6264. {"SLIM RX5 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6265. {"SLIM RX6 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6266. {"SLIM RX7 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6267. {"SLIM RX0", NULL, "SLIM RX0 MUX"},
  6268. {"SLIM RX1", NULL, "SLIM RX1 MUX"},
  6269. {"SLIM RX2", NULL, "SLIM RX2 MUX"},
  6270. {"SLIM RX3", NULL, "SLIM RX3 MUX"},
  6271. {"SLIM RX4", NULL, "SLIM RX4 MUX"},
  6272. {"SLIM RX5", NULL, "SLIM RX5 MUX"},
  6273. {"SLIM RX6", NULL, "SLIM RX6 MUX"},
  6274. {"SLIM RX7", NULL, "SLIM RX7 MUX"},
  6275. {"RX INT0_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6276. {"RX INT0_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6277. {"RX INT0_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6278. {"RX INT0_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6279. {"RX INT0_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6280. {"RX INT0_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6281. {"RX INT0_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6282. {"RX INT0_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6283. {"RX INT0_1 MIX1 INP0", "IIR0", "IIR0"},
  6284. {"RX INT0_1 MIX1 INP0", "IIR1", "IIR1"},
  6285. {"RX INT0_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6286. {"RX INT0_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6287. {"RX INT0_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6288. {"RX INT0_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6289. {"RX INT0_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6290. {"RX INT0_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6291. {"RX INT0_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6292. {"RX INT0_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6293. {"RX INT0_1 MIX1 INP1", "IIR0", "IIR0"},
  6294. {"RX INT0_1 MIX1 INP1", "IIR1", "IIR1"},
  6295. {"RX INT0_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6296. {"RX INT0_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6297. {"RX INT0_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6298. {"RX INT0_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6299. {"RX INT0_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6300. {"RX INT0_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6301. {"RX INT0_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6302. {"RX INT0_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6303. {"RX INT0_1 MIX1 INP2", "IIR0", "IIR0"},
  6304. {"RX INT0_1 MIX1 INP2", "IIR1", "IIR1"},
  6305. /* MIXing path INT0 */
  6306. {"RX INT0_2 MUX", "RX0", "SLIM RX0"},
  6307. {"RX INT0_2 MUX", "RX1", "SLIM RX1"},
  6308. {"RX INT0_2 MUX", "RX2", "SLIM RX2"},
  6309. {"RX INT0_2 MUX", "RX3", "SLIM RX3"},
  6310. {"RX INT0_2 MUX", "RX4", "SLIM RX4"},
  6311. {"RX INT0_2 MUX", "RX5", "SLIM RX5"},
  6312. {"RX INT0_2 MUX", "RX6", "SLIM RX6"},
  6313. {"RX INT0_2 MUX", "RX7", "SLIM RX7"},
  6314. {"RX INT0 SEC MIX", NULL, "RX INT0_2 MUX"},
  6315. /* MIXing path INT1 */
  6316. {"RX INT1_2 MUX", "RX0", "SLIM RX0"},
  6317. {"RX INT1_2 MUX", "RX1", "SLIM RX1"},
  6318. {"RX INT1_2 MUX", "RX2", "SLIM RX2"},
  6319. {"RX INT1_2 MUX", "RX3", "SLIM RX3"},
  6320. {"RX INT1_2 MUX", "RX4", "SLIM RX4"},
  6321. {"RX INT1_2 MUX", "RX5", "SLIM RX5"},
  6322. {"RX INT1_2 MUX", "RX6", "SLIM RX6"},
  6323. {"RX INT1_2 MUX", "RX7", "SLIM RX7"},
  6324. {"RX INT1 SEC MIX", NULL, "RX INT1_2 MUX"},
  6325. /* MIXing path INT2 */
  6326. {"RX INT2_2 MUX", "RX0", "SLIM RX0"},
  6327. {"RX INT2_2 MUX", "RX1", "SLIM RX1"},
  6328. {"RX INT2_2 MUX", "RX2", "SLIM RX2"},
  6329. {"RX INT2_2 MUX", "RX3", "SLIM RX3"},
  6330. {"RX INT2_2 MUX", "RX4", "SLIM RX4"},
  6331. {"RX INT2_2 MUX", "RX5", "SLIM RX5"},
  6332. {"RX INT2_2 MUX", "RX6", "SLIM RX6"},
  6333. {"RX INT2_2 MUX", "RX7", "SLIM RX7"},
  6334. {"RX INT2 SEC MIX", NULL, "RX INT2_2 MUX"},
  6335. /* MIXing path INT3 */
  6336. {"RX INT3_2 MUX", "RX0", "SLIM RX0"},
  6337. {"RX INT3_2 MUX", "RX1", "SLIM RX1"},
  6338. {"RX INT3_2 MUX", "RX2", "SLIM RX2"},
  6339. {"RX INT3_2 MUX", "RX3", "SLIM RX3"},
  6340. {"RX INT3_2 MUX", "RX4", "SLIM RX4"},
  6341. {"RX INT3_2 MUX", "RX5", "SLIM RX5"},
  6342. {"RX INT3_2 MUX", "RX6", "SLIM RX6"},
  6343. {"RX INT3_2 MUX", "RX7", "SLIM RX7"},
  6344. {"RX INT3 SEC MIX", NULL, "RX INT3_2 MUX"},
  6345. /* MIXing path INT4 */
  6346. {"RX INT4_2 MUX", "RX0", "SLIM RX0"},
  6347. {"RX INT4_2 MUX", "RX1", "SLIM RX1"},
  6348. {"RX INT4_2 MUX", "RX2", "SLIM RX2"},
  6349. {"RX INT4_2 MUX", "RX3", "SLIM RX3"},
  6350. {"RX INT4_2 MUX", "RX4", "SLIM RX4"},
  6351. {"RX INT4_2 MUX", "RX5", "SLIM RX5"},
  6352. {"RX INT4_2 MUX", "RX6", "SLIM RX6"},
  6353. {"RX INT4_2 MUX", "RX7", "SLIM RX7"},
  6354. {"RX INT4 SEC MIX", NULL, "RX INT4_2 MUX"},
  6355. /* MIXing path INT5 */
  6356. {"RX INT5_2 MUX", "RX0", "SLIM RX0"},
  6357. {"RX INT5_2 MUX", "RX1", "SLIM RX1"},
  6358. {"RX INT5_2 MUX", "RX2", "SLIM RX2"},
  6359. {"RX INT5_2 MUX", "RX3", "SLIM RX3"},
  6360. {"RX INT5_2 MUX", "RX4", "SLIM RX4"},
  6361. {"RX INT5_2 MUX", "RX5", "SLIM RX5"},
  6362. {"RX INT5_2 MUX", "RX6", "SLIM RX6"},
  6363. {"RX INT5_2 MUX", "RX7", "SLIM RX7"},
  6364. {"RX INT5 SEC MIX", NULL, "RX INT5_2 MUX"},
  6365. /* MIXing path INT6 */
  6366. {"RX INT6_2 MUX", "RX0", "SLIM RX0"},
  6367. {"RX INT6_2 MUX", "RX1", "SLIM RX1"},
  6368. {"RX INT6_2 MUX", "RX2", "SLIM RX2"},
  6369. {"RX INT6_2 MUX", "RX3", "SLIM RX3"},
  6370. {"RX INT6_2 MUX", "RX4", "SLIM RX4"},
  6371. {"RX INT6_2 MUX", "RX5", "SLIM RX5"},
  6372. {"RX INT6_2 MUX", "RX6", "SLIM RX6"},
  6373. {"RX INT6_2 MUX", "RX7", "SLIM RX7"},
  6374. {"RX INT6 SEC MIX", NULL, "RX INT6_2 MUX"},
  6375. /* MIXing path INT7 */
  6376. {"RX INT7_2 MUX", "RX0", "SLIM RX0"},
  6377. {"RX INT7_2 MUX", "RX1", "SLIM RX1"},
  6378. {"RX INT7_2 MUX", "RX2", "SLIM RX2"},
  6379. {"RX INT7_2 MUX", "RX3", "SLIM RX3"},
  6380. {"RX INT7_2 MUX", "RX4", "SLIM RX4"},
  6381. {"RX INT7_2 MUX", "RX5", "SLIM RX5"},
  6382. {"RX INT7_2 MUX", "RX6", "SLIM RX6"},
  6383. {"RX INT7_2 MUX", "RX7", "SLIM RX7"},
  6384. {"RX INT7 SEC MIX", NULL, "RX INT7_2 MUX"},
  6385. /* MIXing path INT8 */
  6386. {"RX INT8_2 MUX", "RX0", "SLIM RX0"},
  6387. {"RX INT8_2 MUX", "RX1", "SLIM RX1"},
  6388. {"RX INT8_2 MUX", "RX2", "SLIM RX2"},
  6389. {"RX INT8_2 MUX", "RX3", "SLIM RX3"},
  6390. {"RX INT8_2 MUX", "RX4", "SLIM RX4"},
  6391. {"RX INT8_2 MUX", "RX5", "SLIM RX5"},
  6392. {"RX INT8_2 MUX", "RX6", "SLIM RX6"},
  6393. {"RX INT8_2 MUX", "RX7", "SLIM RX7"},
  6394. {"RX INT8 SEC MIX", NULL, "RX INT8_2 MUX"},
  6395. {"RX INT1_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6396. {"RX INT1_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6397. {"RX INT1_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6398. {"RX INT1_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6399. {"RX INT1_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6400. {"RX INT1_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6401. {"RX INT1_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6402. {"RX INT1_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6403. {"RX INT1_1 MIX1 INP0", "IIR0", "IIR0"},
  6404. {"RX INT1_1 MIX1 INP0", "IIR1", "IIR1"},
  6405. {"RX INT1_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6406. {"RX INT1_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6407. {"RX INT1_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6408. {"RX INT1_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6409. {"RX INT1_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6410. {"RX INT1_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6411. {"RX INT1_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6412. {"RX INT1_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6413. {"RX INT1_1 MIX1 INP1", "IIR0", "IIR0"},
  6414. {"RX INT1_1 MIX1 INP1", "IIR1", "IIR1"},
  6415. {"RX INT1_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6416. {"RX INT1_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6417. {"RX INT1_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6418. {"RX INT1_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6419. {"RX INT1_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6420. {"RX INT1_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6421. {"RX INT1_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6422. {"RX INT1_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6423. {"RX INT1_1 MIX1 INP2", "IIR0", "IIR0"},
  6424. {"RX INT1_1 MIX1 INP2", "IIR1", "IIR1"},
  6425. {"RX INT2_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6426. {"RX INT2_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6427. {"RX INT2_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6428. {"RX INT2_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6429. {"RX INT2_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6430. {"RX INT2_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6431. {"RX INT2_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6432. {"RX INT2_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6433. {"RX INT2_1 MIX1 INP0", "IIR0", "IIR0"},
  6434. {"RX INT2_1 MIX1 INP0", "IIR1", "IIR1"},
  6435. {"RX INT2_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6436. {"RX INT2_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6437. {"RX INT2_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6438. {"RX INT2_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6439. {"RX INT2_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6440. {"RX INT2_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6441. {"RX INT2_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6442. {"RX INT2_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6443. {"RX INT2_1 MIX1 INP1", "IIR0", "IIR0"},
  6444. {"RX INT2_1 MIX1 INP1", "IIR1", "IIR1"},
  6445. {"RX INT2_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6446. {"RX INT2_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6447. {"RX INT2_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6448. {"RX INT2_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6449. {"RX INT2_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6450. {"RX INT2_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6451. {"RX INT2_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6452. {"RX INT2_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6453. {"RX INT2_1 MIX1 INP2", "IIR0", "IIR0"},
  6454. {"RX INT2_1 MIX1 INP2", "IIR1", "IIR1"},
  6455. {"RX INT3_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6456. {"RX INT3_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6457. {"RX INT3_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6458. {"RX INT3_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6459. {"RX INT3_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6460. {"RX INT3_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6461. {"RX INT3_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6462. {"RX INT3_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6463. {"RX INT3_1 MIX1 INP0", "IIR0", "IIR0"},
  6464. {"RX INT3_1 MIX1 INP0", "IIR1", "IIR1"},
  6465. {"RX INT3_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6466. {"RX INT3_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6467. {"RX INT3_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6468. {"RX INT3_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6469. {"RX INT3_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6470. {"RX INT3_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6471. {"RX INT3_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6472. {"RX INT3_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6473. {"RX INT3_1 MIX1 INP1", "IIR0", "IIR0"},
  6474. {"RX INT3_1 MIX1 INP1", "IIR1", "IIR1"},
  6475. {"RX INT3_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6476. {"RX INT3_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6477. {"RX INT3_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6478. {"RX INT3_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6479. {"RX INT3_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6480. {"RX INT3_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6481. {"RX INT3_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6482. {"RX INT3_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6483. {"RX INT3_1 MIX1 INP2", "IIR0", "IIR0"},
  6484. {"RX INT3_1 MIX1 INP2", "IIR1", "IIR1"},
  6485. {"RX INT4_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6486. {"RX INT4_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6487. {"RX INT4_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6488. {"RX INT4_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6489. {"RX INT4_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6490. {"RX INT4_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6491. {"RX INT4_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6492. {"RX INT4_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6493. {"RX INT4_1 MIX1 INP0", "IIR0", "IIR0"},
  6494. {"RX INT4_1 MIX1 INP0", "IIR1", "IIR1"},
  6495. {"RX INT4_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6496. {"RX INT4_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6497. {"RX INT4_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6498. {"RX INT4_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6499. {"RX INT4_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6500. {"RX INT4_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6501. {"RX INT4_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6502. {"RX INT4_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6503. {"RX INT4_1 MIX1 INP1", "IIR0", "IIR0"},
  6504. {"RX INT4_1 MIX1 INP1", "IIR1", "IIR1"},
  6505. {"RX INT4_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6506. {"RX INT4_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6507. {"RX INT4_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6508. {"RX INT4_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6509. {"RX INT4_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6510. {"RX INT4_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6511. {"RX INT4_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6512. {"RX INT4_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6513. {"RX INT4_1 MIX1 INP2", "IIR0", "IIR0"},
  6514. {"RX INT4_1 MIX1 INP2", "IIR1", "IIR1"},
  6515. {"RX INT5_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6516. {"RX INT5_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6517. {"RX INT5_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6518. {"RX INT5_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6519. {"RX INT5_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6520. {"RX INT5_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6521. {"RX INT5_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6522. {"RX INT5_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6523. {"RX INT5_1 MIX1 INP0", "IIR0", "IIR0"},
  6524. {"RX INT5_1 MIX1 INP0", "IIR1", "IIR1"},
  6525. {"RX INT5_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6526. {"RX INT5_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6527. {"RX INT5_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6528. {"RX INT5_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6529. {"RX INT5_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6530. {"RX INT5_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6531. {"RX INT5_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6532. {"RX INT5_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6533. {"RX INT5_1 MIX1 INP1", "IIR0", "IIR0"},
  6534. {"RX INT5_1 MIX1 INP1", "IIR1", "IIR1"},
  6535. {"RX INT5_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6536. {"RX INT5_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6537. {"RX INT5_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6538. {"RX INT5_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6539. {"RX INT5_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6540. {"RX INT5_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6541. {"RX INT5_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6542. {"RX INT5_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6543. {"RX INT5_1 MIX1 INP2", "IIR0", "IIR0"},
  6544. {"RX INT5_1 MIX1 INP2", "IIR1", "IIR1"},
  6545. {"RX INT6_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6546. {"RX INT6_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6547. {"RX INT6_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6548. {"RX INT6_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6549. {"RX INT6_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6550. {"RX INT6_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6551. {"RX INT6_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6552. {"RX INT6_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6553. {"RX INT6_1 MIX1 INP0", "IIR0", "IIR0"},
  6554. {"RX INT6_1 MIX1 INP0", "IIR1", "IIR1"},
  6555. {"RX INT6_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6556. {"RX INT6_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6557. {"RX INT6_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6558. {"RX INT6_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6559. {"RX INT6_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6560. {"RX INT6_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6561. {"RX INT6_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6562. {"RX INT6_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6563. {"RX INT6_1 MIX1 INP1", "IIR0", "IIR0"},
  6564. {"RX INT6_1 MIX1 INP1", "IIR1", "IIR1"},
  6565. {"RX INT6_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6566. {"RX INT6_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6567. {"RX INT6_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6568. {"RX INT6_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6569. {"RX INT6_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6570. {"RX INT6_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6571. {"RX INT6_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6572. {"RX INT6_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6573. {"RX INT6_1 MIX1 INP2", "IIR0", "IIR0"},
  6574. {"RX INT6_1 MIX1 INP2", "IIR1", "IIR1"},
  6575. {"RX INT7_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6576. {"RX INT7_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6577. {"RX INT7_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6578. {"RX INT7_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6579. {"RX INT7_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6580. {"RX INT7_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6581. {"RX INT7_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6582. {"RX INT7_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6583. {"RX INT7_1 MIX1 INP0", "IIR0", "IIR0"},
  6584. {"RX INT7_1 MIX1 INP0", "IIR1", "IIR1"},
  6585. {"RX INT7_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6586. {"RX INT7_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6587. {"RX INT7_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6588. {"RX INT7_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6589. {"RX INT7_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6590. {"RX INT7_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6591. {"RX INT7_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6592. {"RX INT7_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6593. {"RX INT7_1 MIX1 INP1", "IIR0", "IIR0"},
  6594. {"RX INT7_1 MIX1 INP1", "IIR1", "IIR1"},
  6595. {"RX INT7_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6596. {"RX INT7_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6597. {"RX INT7_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6598. {"RX INT7_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6599. {"RX INT7_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6600. {"RX INT7_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6601. {"RX INT7_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6602. {"RX INT7_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6603. {"RX INT7_1 MIX1 INP2", "IIR0", "IIR0"},
  6604. {"RX INT7_1 MIX1 INP2", "IIR1", "IIR1"},
  6605. {"RX INT8_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6606. {"RX INT8_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6607. {"RX INT8_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6608. {"RX INT8_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6609. {"RX INT8_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6610. {"RX INT8_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6611. {"RX INT8_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6612. {"RX INT8_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6613. {"RX INT8_1 MIX1 INP0", "IIR0", "IIR0"},
  6614. {"RX INT8_1 MIX1 INP0", "IIR1", "IIR1"},
  6615. {"RX INT8_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6616. {"RX INT8_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6617. {"RX INT8_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6618. {"RX INT8_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6619. {"RX INT8_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6620. {"RX INT8_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6621. {"RX INT8_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6622. {"RX INT8_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6623. {"RX INT8_1 MIX1 INP1", "IIR0", "IIR0"},
  6624. {"RX INT8_1 MIX1 INP1", "IIR1", "IIR1"},
  6625. {"RX INT8_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6626. {"RX INT8_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6627. {"RX INT8_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6628. {"RX INT8_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6629. {"RX INT8_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6630. {"RX INT8_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6631. {"RX INT8_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6632. {"RX INT8_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6633. {"RX INT8_1 MIX1 INP2", "IIR0", "IIR0"},
  6634. {"RX INT8_1 MIX1 INP2", "IIR1", "IIR1"},
  6635. /* SRC0, SRC1 inputs to Sidetone RX Mixer
  6636. * on RX0, RX1, RX2, RX3, RX4 and RX7 chains
  6637. */
  6638. {"IIR0", NULL, "IIR0 INP0 MUX"},
  6639. {"IIR0 INP0 MUX", "DEC0", "ADC MUX0"},
  6640. {"IIR0 INP0 MUX", "DEC1", "ADC MUX1"},
  6641. {"IIR0 INP0 MUX", "DEC2", "ADC MUX2"},
  6642. {"IIR0 INP0 MUX", "DEC3", "ADC MUX3"},
  6643. {"IIR0 INP0 MUX", "DEC4", "ADC MUX4"},
  6644. {"IIR0 INP0 MUX", "DEC5", "ADC MUX5"},
  6645. {"IIR0 INP0 MUX", "DEC6", "ADC MUX6"},
  6646. {"IIR0 INP0 MUX", "DEC7", "ADC MUX7"},
  6647. {"IIR0 INP0 MUX", "DEC8", "ADC MUX8"},
  6648. {"IIR0 INP0 MUX", "RX0", "SLIM RX0"},
  6649. {"IIR0 INP0 MUX", "RX1", "SLIM RX1"},
  6650. {"IIR0 INP0 MUX", "RX2", "SLIM RX2"},
  6651. {"IIR0 INP0 MUX", "RX3", "SLIM RX3"},
  6652. {"IIR0 INP0 MUX", "RX4", "SLIM RX4"},
  6653. {"IIR0 INP0 MUX", "RX5", "SLIM RX5"},
  6654. {"IIR0 INP0 MUX", "RX6", "SLIM RX6"},
  6655. {"IIR0 INP0 MUX", "RX7", "SLIM RX7"},
  6656. {"IIR0", NULL, "IIR0 INP1 MUX"},
  6657. {"IIR0 INP1 MUX", "DEC0", "ADC MUX0"},
  6658. {"IIR0 INP1 MUX", "DEC1", "ADC MUX1"},
  6659. {"IIR0 INP1 MUX", "DEC2", "ADC MUX2"},
  6660. {"IIR0 INP1 MUX", "DEC3", "ADC MUX3"},
  6661. {"IIR0 INP1 MUX", "DEC4", "ADC MUX4"},
  6662. {"IIR0 INP1 MUX", "DEC5", "ADC MUX5"},
  6663. {"IIR0 INP1 MUX", "DEC6", "ADC MUX6"},
  6664. {"IIR0 INP1 MUX", "DEC7", "ADC MUX7"},
  6665. {"IIR0 INP1 MUX", "DEC8", "ADC MUX8"},
  6666. {"IIR0 INP1 MUX", "RX0", "SLIM RX0"},
  6667. {"IIR0 INP1 MUX", "RX1", "SLIM RX1"},
  6668. {"IIR0 INP1 MUX", "RX2", "SLIM RX2"},
  6669. {"IIR0 INP1 MUX", "RX3", "SLIM RX3"},
  6670. {"IIR0 INP1 MUX", "RX4", "SLIM RX4"},
  6671. {"IIR0 INP1 MUX", "RX5", "SLIM RX5"},
  6672. {"IIR0 INP1 MUX", "RX6", "SLIM RX6"},
  6673. {"IIR0 INP1 MUX", "RX7", "SLIM RX7"},
  6674. {"IIR0", NULL, "IIR0 INP2 MUX"},
  6675. {"IIR0 INP2 MUX", "DEC0", "ADC MUX0"},
  6676. {"IIR0 INP2 MUX", "DEC1", "ADC MUX1"},
  6677. {"IIR0 INP2 MUX", "DEC2", "ADC MUX2"},
  6678. {"IIR0 INP2 MUX", "DEC3", "ADC MUX3"},
  6679. {"IIR0 INP2 MUX", "DEC4", "ADC MUX4"},
  6680. {"IIR0 INP2 MUX", "DEC5", "ADC MUX5"},
  6681. {"IIR0 INP2 MUX", "DEC6", "ADC MUX6"},
  6682. {"IIR0 INP2 MUX", "DEC7", "ADC MUX7"},
  6683. {"IIR0 INP2 MUX", "DEC8", "ADC MUX8"},
  6684. {"IIR0 INP2 MUX", "RX0", "SLIM RX0"},
  6685. {"IIR0 INP2 MUX", "RX1", "SLIM RX1"},
  6686. {"IIR0 INP2 MUX", "RX2", "SLIM RX2"},
  6687. {"IIR0 INP2 MUX", "RX3", "SLIM RX3"},
  6688. {"IIR0 INP2 MUX", "RX4", "SLIM RX4"},
  6689. {"IIR0 INP2 MUX", "RX5", "SLIM RX5"},
  6690. {"IIR0 INP2 MUX", "RX6", "SLIM RX6"},
  6691. {"IIR0 INP2 MUX", "RX7", "SLIM RX7"},
  6692. {"IIR0", NULL, "IIR0 INP3 MUX"},
  6693. {"IIR0 INP3 MUX", "DEC0", "ADC MUX0"},
  6694. {"IIR0 INP3 MUX", "DEC1", "ADC MUX1"},
  6695. {"IIR0 INP3 MUX", "DEC2", "ADC MUX2"},
  6696. {"IIR0 INP3 MUX", "DEC3", "ADC MUX3"},
  6697. {"IIR0 INP3 MUX", "DEC4", "ADC MUX4"},
  6698. {"IIR0 INP3 MUX", "DEC5", "ADC MUX5"},
  6699. {"IIR0 INP3 MUX", "DEC6", "ADC MUX6"},
  6700. {"IIR0 INP3 MUX", "DEC7", "ADC MUX7"},
  6701. {"IIR0 INP3 MUX", "DEC8", "ADC MUX8"},
  6702. {"IIR0 INP3 MUX", "RX0", "SLIM RX0"},
  6703. {"IIR0 INP3 MUX", "RX1", "SLIM RX1"},
  6704. {"IIR0 INP3 MUX", "RX2", "SLIM RX2"},
  6705. {"IIR0 INP3 MUX", "RX3", "SLIM RX3"},
  6706. {"IIR0 INP3 MUX", "RX4", "SLIM RX4"},
  6707. {"IIR0 INP3 MUX", "RX5", "SLIM RX5"},
  6708. {"IIR0 INP3 MUX", "RX6", "SLIM RX6"},
  6709. {"IIR0 INP3 MUX", "RX7", "SLIM RX7"},
  6710. {"IIR1", NULL, "IIR1 INP0 MUX"},
  6711. {"IIR1 INP0 MUX", "DEC0", "ADC MUX0"},
  6712. {"IIR1 INP0 MUX", "DEC1", "ADC MUX1"},
  6713. {"IIR1 INP0 MUX", "DEC2", "ADC MUX2"},
  6714. {"IIR1 INP0 MUX", "DEC3", "ADC MUX3"},
  6715. {"IIR1 INP0 MUX", "DEC4", "ADC MUX4"},
  6716. {"IIR1 INP0 MUX", "DEC5", "ADC MUX5"},
  6717. {"IIR1 INP0 MUX", "DEC6", "ADC MUX6"},
  6718. {"IIR1 INP0 MUX", "DEC7", "ADC MUX7"},
  6719. {"IIR1 INP0 MUX", "DEC8", "ADC MUX8"},
  6720. {"IIR1 INP0 MUX", "RX0", "SLIM RX0"},
  6721. {"IIR1 INP0 MUX", "RX1", "SLIM RX1"},
  6722. {"IIR1 INP0 MUX", "RX2", "SLIM RX2"},
  6723. {"IIR1 INP0 MUX", "RX3", "SLIM RX3"},
  6724. {"IIR1 INP0 MUX", "RX4", "SLIM RX4"},
  6725. {"IIR1 INP0 MUX", "RX5", "SLIM RX5"},
  6726. {"IIR1 INP0 MUX", "RX6", "SLIM RX6"},
  6727. {"IIR1 INP0 MUX", "RX7", "SLIM RX7"},
  6728. {"IIR1", NULL, "IIR1 INP1 MUX"},
  6729. {"IIR1 INP1 MUX", "DEC0", "ADC MUX0"},
  6730. {"IIR1 INP1 MUX", "DEC1", "ADC MUX1"},
  6731. {"IIR1 INP1 MUX", "DEC2", "ADC MUX2"},
  6732. {"IIR1 INP1 MUX", "DEC3", "ADC MUX3"},
  6733. {"IIR1 INP1 MUX", "DEC4", "ADC MUX4"},
  6734. {"IIR1 INP1 MUX", "DEC5", "ADC MUX5"},
  6735. {"IIR1 INP1 MUX", "DEC6", "ADC MUX6"},
  6736. {"IIR1 INP1 MUX", "DEC7", "ADC MUX7"},
  6737. {"IIR1 INP1 MUX", "DEC8", "ADC MUX8"},
  6738. {"IIR1 INP1 MUX", "RX0", "SLIM RX0"},
  6739. {"IIR1 INP1 MUX", "RX1", "SLIM RX1"},
  6740. {"IIR1 INP1 MUX", "RX2", "SLIM RX2"},
  6741. {"IIR1 INP1 MUX", "RX3", "SLIM RX3"},
  6742. {"IIR1 INP1 MUX", "RX4", "SLIM RX4"},
  6743. {"IIR1 INP1 MUX", "RX5", "SLIM RX5"},
  6744. {"IIR1 INP1 MUX", "RX6", "SLIM RX6"},
  6745. {"IIR1 INP1 MUX", "RX7", "SLIM RX7"},
  6746. {"IIR1", NULL, "IIR1 INP2 MUX"},
  6747. {"IIR1 INP2 MUX", "DEC0", "ADC MUX0"},
  6748. {"IIR1 INP2 MUX", "DEC1", "ADC MUX1"},
  6749. {"IIR1 INP2 MUX", "DEC2", "ADC MUX2"},
  6750. {"IIR1 INP2 MUX", "DEC3", "ADC MUX3"},
  6751. {"IIR1 INP2 MUX", "DEC4", "ADC MUX4"},
  6752. {"IIR1 INP2 MUX", "DEC5", "ADC MUX5"},
  6753. {"IIR1 INP2 MUX", "DEC6", "ADC MUX6"},
  6754. {"IIR1 INP2 MUX", "DEC7", "ADC MUX7"},
  6755. {"IIR1 INP2 MUX", "DEC8", "ADC MUX8"},
  6756. {"IIR1 INP2 MUX", "RX0", "SLIM RX0"},
  6757. {"IIR1 INP2 MUX", "RX1", "SLIM RX1"},
  6758. {"IIR1 INP2 MUX", "RX2", "SLIM RX2"},
  6759. {"IIR1 INP2 MUX", "RX3", "SLIM RX3"},
  6760. {"IIR1 INP2 MUX", "RX4", "SLIM RX4"},
  6761. {"IIR1 INP2 MUX", "RX5", "SLIM RX5"},
  6762. {"IIR1 INP2 MUX", "RX6", "SLIM RX6"},
  6763. {"IIR1 INP2 MUX", "RX7", "SLIM RX7"},
  6764. {"IIR1", NULL, "IIR1 INP3 MUX"},
  6765. {"IIR1 INP3 MUX", "DEC0", "ADC MUX0"},
  6766. {"IIR1 INP3 MUX", "DEC1", "ADC MUX1"},
  6767. {"IIR1 INP3 MUX", "DEC2", "ADC MUX2"},
  6768. {"IIR1 INP3 MUX", "DEC3", "ADC MUX3"},
  6769. {"IIR1 INP3 MUX", "DEC4", "ADC MUX4"},
  6770. {"IIR1 INP3 MUX", "DEC5", "ADC MUX5"},
  6771. {"IIR1 INP3 MUX", "DEC6", "ADC MUX6"},
  6772. {"IIR1 INP3 MUX", "DEC7", "ADC MUX7"},
  6773. {"IIR1 INP3 MUX", "DEC8", "ADC MUX8"},
  6774. {"IIR1 INP3 MUX", "RX0", "SLIM RX0"},
  6775. {"IIR1 INP3 MUX", "RX1", "SLIM RX1"},
  6776. {"IIR1 INP3 MUX", "RX2", "SLIM RX2"},
  6777. {"IIR1 INP3 MUX", "RX3", "SLIM RX3"},
  6778. {"IIR1 INP3 MUX", "RX4", "SLIM RX4"},
  6779. {"IIR1 INP3 MUX", "RX5", "SLIM RX5"},
  6780. {"IIR1 INP3 MUX", "RX6", "SLIM RX6"},
  6781. {"IIR1 INP3 MUX", "RX7", "SLIM RX7"},
  6782. {"SRC0", NULL, "IIR0"},
  6783. {"SRC1", NULL, "IIR1"},
  6784. {"RX INT0 MIX2 INP", "SRC0", "SRC0"},
  6785. {"RX INT0 MIX2 INP", "SRC1", "SRC1"},
  6786. {"RX INT1 MIX2 INP", "SRC0", "SRC0"},
  6787. {"RX INT1 MIX2 INP", "SRC1", "SRC1"},
  6788. {"RX INT2 MIX2 INP", "SRC0", "SRC0"},
  6789. {"RX INT2 MIX2 INP", "SRC1", "SRC1"},
  6790. {"RX INT3 MIX2 INP", "SRC0", "SRC0"},
  6791. {"RX INT3 MIX2 INP", "SRC1", "SRC1"},
  6792. {"RX INT4 MIX2 INP", "SRC0", "SRC0"},
  6793. {"RX INT4 MIX2 INP", "SRC1", "SRC1"},
  6794. {"RX INT7 MIX2 INP", "SRC0", "SRC0"},
  6795. {"RX INT7 MIX2 INP", "SRC1", "SRC1"},
  6796. };
  6797. static int tasha_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol,
  6798. struct snd_ctl_elem_value *ucontrol)
  6799. {
  6800. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6801. u16 amic_reg;
  6802. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6803. amic_reg = WCD9335_ANA_AMIC1;
  6804. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6805. amic_reg = WCD9335_ANA_AMIC3;
  6806. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6807. amic_reg = WCD9335_ANA_AMIC5;
  6808. ucontrol->value.integer.value[0] =
  6809. (snd_soc_read(codec, amic_reg) & WCD9335_AMIC_PWR_LVL_MASK) >>
  6810. WCD9335_AMIC_PWR_LVL_SHIFT;
  6811. return 0;
  6812. }
  6813. static int tasha_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol,
  6814. struct snd_ctl_elem_value *ucontrol)
  6815. {
  6816. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6817. u32 mode_val;
  6818. u16 amic_reg;
  6819. mode_val = ucontrol->value.enumerated.item[0];
  6820. dev_dbg(codec->dev, "%s: mode: %d\n",
  6821. __func__, mode_val);
  6822. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6823. amic_reg = WCD9335_ANA_AMIC1;
  6824. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6825. amic_reg = WCD9335_ANA_AMIC3;
  6826. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6827. amic_reg = WCD9335_ANA_AMIC5;
  6828. snd_soc_update_bits(codec, amic_reg, WCD9335_AMIC_PWR_LVL_MASK,
  6829. mode_val << WCD9335_AMIC_PWR_LVL_SHIFT);
  6830. return 0;
  6831. }
  6832. static int tasha_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
  6833. struct snd_ctl_elem_value *ucontrol)
  6834. {
  6835. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6836. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6837. ucontrol->value.integer.value[0] = tasha->hph_mode;
  6838. return 0;
  6839. }
  6840. static int tasha_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
  6841. struct snd_ctl_elem_value *ucontrol)
  6842. {
  6843. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6844. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6845. u32 mode_val;
  6846. mode_val = ucontrol->value.enumerated.item[0];
  6847. dev_dbg(codec->dev, "%s: mode: %d\n",
  6848. __func__, mode_val);
  6849. if (mode_val == 0) {
  6850. dev_warn(codec->dev, "%s:Invalid HPH Mode, default to Cls-H HiFi\n",
  6851. __func__);
  6852. mode_val = CLS_H_HIFI;
  6853. }
  6854. tasha->hph_mode = mode_val;
  6855. return 0;
  6856. }
  6857. static const char *const tasha_conn_mad_text[] = {
  6858. "NOTUSED1", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6",
  6859. "NOTUSED2", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4",
  6860. "DMIC5", "NOTUSED3", "NOTUSED4"
  6861. };
  6862. static const struct soc_enum tasha_conn_mad_enum =
  6863. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_conn_mad_text),
  6864. tasha_conn_mad_text);
  6865. static int tasha_enable_ldo_h_get(struct snd_kcontrol *kcontrol,
  6866. struct snd_ctl_elem_value *ucontrol)
  6867. {
  6868. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6869. u8 val = 0;
  6870. if (codec)
  6871. val = snd_soc_read(codec, WCD9335_LDOH_MODE) & 0x80;
  6872. ucontrol->value.integer.value[0] = !!val;
  6873. return 0;
  6874. }
  6875. static int tasha_enable_ldo_h_put(struct snd_kcontrol *kcontrol,
  6876. struct snd_ctl_elem_value *ucontrol)
  6877. {
  6878. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6879. int value = ucontrol->value.integer.value[0];
  6880. bool enable;
  6881. enable = !!value;
  6882. if (codec)
  6883. tasha_codec_enable_standalone_ldo_h(codec, enable);
  6884. return 0;
  6885. }
  6886. static int tasha_mad_input_get(struct snd_kcontrol *kcontrol,
  6887. struct snd_ctl_elem_value *ucontrol)
  6888. {
  6889. u8 tasha_mad_input;
  6890. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6891. tasha_mad_input = snd_soc_read(codec,
  6892. WCD9335_SOC_MAD_INP_SEL) & 0x0F;
  6893. ucontrol->value.integer.value[0] = tasha_mad_input;
  6894. dev_dbg(codec->dev,
  6895. "%s: tasha_mad_input = %s\n", __func__,
  6896. tasha_conn_mad_text[tasha_mad_input]);
  6897. return 0;
  6898. }
  6899. static int tasha_mad_input_put(struct snd_kcontrol *kcontrol,
  6900. struct snd_ctl_elem_value *ucontrol)
  6901. {
  6902. u8 tasha_mad_input;
  6903. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6904. struct snd_soc_card *card = codec->component.card;
  6905. char mad_amic_input_widget[6];
  6906. const char *mad_input_widget;
  6907. const char *source_widget = NULL;
  6908. u32 adc, i, mic_bias_found = 0;
  6909. int ret = 0;
  6910. char *mad_input;
  6911. tasha_mad_input = ucontrol->value.integer.value[0];
  6912. if (tasha_mad_input >= ARRAY_SIZE(tasha_conn_mad_text)) {
  6913. dev_err(codec->dev,
  6914. "%s: tasha_mad_input = %d out of bounds\n",
  6915. __func__, tasha_mad_input);
  6916. return -EINVAL;
  6917. }
  6918. if (!strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED1") ||
  6919. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED2") ||
  6920. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED3") ||
  6921. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED4")) {
  6922. dev_err(codec->dev,
  6923. "%s: Unsupported tasha_mad_input = %s\n",
  6924. __func__, tasha_conn_mad_text[tasha_mad_input]);
  6925. return -EINVAL;
  6926. }
  6927. if (strnstr(tasha_conn_mad_text[tasha_mad_input],
  6928. "ADC", sizeof("ADC"))) {
  6929. mad_input = strpbrk(tasha_conn_mad_text[tasha_mad_input],
  6930. "123456");
  6931. if (!mad_input) {
  6932. dev_err(codec->dev, "%s: Invalid MAD input %s\n",
  6933. __func__,
  6934. tasha_conn_mad_text[tasha_mad_input]);
  6935. return -EINVAL;
  6936. }
  6937. ret = kstrtouint(mad_input, 10, &adc);
  6938. if ((ret < 0) || (adc > 6)) {
  6939. dev_err(codec->dev,
  6940. "%s: Invalid ADC = %s\n", __func__,
  6941. tasha_conn_mad_text[tasha_mad_input]);
  6942. ret = -EINVAL;
  6943. }
  6944. snprintf(mad_amic_input_widget, 6, "%s%u", "AMIC", adc);
  6945. mad_input_widget = mad_amic_input_widget;
  6946. } else {
  6947. /* DMIC type input widget*/
  6948. mad_input_widget = tasha_conn_mad_text[tasha_mad_input];
  6949. }
  6950. dev_dbg(codec->dev,
  6951. "%s: tasha input widget = %s\n", __func__,
  6952. mad_input_widget);
  6953. for (i = 0; i < card->num_of_dapm_routes; i++) {
  6954. if (!strcmp(card->of_dapm_routes[i].sink, mad_input_widget)) {
  6955. source_widget = card->of_dapm_routes[i].source;
  6956. if (!source_widget) {
  6957. dev_err(codec->dev,
  6958. "%s: invalid source widget\n",
  6959. __func__);
  6960. return -EINVAL;
  6961. }
  6962. if (strnstr(source_widget,
  6963. "MIC BIAS1", sizeof("MIC BIAS1"))) {
  6964. mic_bias_found = 1;
  6965. break;
  6966. } else if (strnstr(source_widget,
  6967. "MIC BIAS2", sizeof("MIC BIAS2"))) {
  6968. mic_bias_found = 2;
  6969. break;
  6970. } else if (strnstr(source_widget,
  6971. "MIC BIAS3", sizeof("MIC BIAS3"))) {
  6972. mic_bias_found = 3;
  6973. break;
  6974. } else if (strnstr(source_widget,
  6975. "MIC BIAS4", sizeof("MIC BIAS4"))) {
  6976. mic_bias_found = 4;
  6977. break;
  6978. }
  6979. }
  6980. }
  6981. if (!mic_bias_found) {
  6982. dev_err(codec->dev,
  6983. "%s: mic bias source not found for input = %s\n",
  6984. __func__, mad_input_widget);
  6985. return -EINVAL;
  6986. }
  6987. dev_dbg(codec->dev,
  6988. "%s: mic_bias found = %d\n", __func__,
  6989. mic_bias_found);
  6990. snd_soc_update_bits(codec, WCD9335_SOC_MAD_INP_SEL,
  6991. 0x0F, tasha_mad_input);
  6992. snd_soc_update_bits(codec, WCD9335_ANA_MAD_SETUP,
  6993. 0x07, mic_bias_found);
  6994. return 0;
  6995. }
  6996. static int tasha_pinctl_mode_get(struct snd_kcontrol *kcontrol,
  6997. struct snd_ctl_elem_value *ucontrol)
  6998. {
  6999. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7000. u16 ctl_reg;
  7001. u8 reg_val, pinctl_position;
  7002. pinctl_position = ((struct soc_multi_mixer_control *)
  7003. kcontrol->private_value)->shift;
  7004. switch (pinctl_position >> 3) {
  7005. case 0:
  7006. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7007. break;
  7008. case 1:
  7009. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7010. break;
  7011. case 2:
  7012. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7013. break;
  7014. case 3:
  7015. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7016. break;
  7017. default:
  7018. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7019. __func__, pinctl_position);
  7020. return -EINVAL;
  7021. }
  7022. reg_val = snd_soc_read(codec, ctl_reg);
  7023. reg_val = (reg_val >> (pinctl_position & 0x07)) & 0x1;
  7024. ucontrol->value.integer.value[0] = reg_val;
  7025. return 0;
  7026. }
  7027. static int tasha_pinctl_mode_put(struct snd_kcontrol *kcontrol,
  7028. struct snd_ctl_elem_value *ucontrol)
  7029. {
  7030. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7031. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7032. u16 ctl_reg, cfg_reg;
  7033. u8 ctl_val, cfg_val, pinctl_position, pinctl_mode, mask;
  7034. /* 1- high or low; 0- high Z */
  7035. pinctl_mode = ucontrol->value.integer.value[0];
  7036. pinctl_position = ((struct soc_multi_mixer_control *)
  7037. kcontrol->private_value)->shift;
  7038. switch (pinctl_position >> 3) {
  7039. case 0:
  7040. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7041. break;
  7042. case 1:
  7043. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7044. break;
  7045. case 2:
  7046. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7047. break;
  7048. case 3:
  7049. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7050. break;
  7051. default:
  7052. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7053. __func__, pinctl_position);
  7054. return -EINVAL;
  7055. }
  7056. ctl_val = pinctl_mode << (pinctl_position & 0x07);
  7057. mask = 1 << (pinctl_position & 0x07);
  7058. snd_soc_update_bits(codec, ctl_reg, mask, ctl_val);
  7059. cfg_reg = WCD9335_TLMM_BIST_MODE_PINCFG + pinctl_position;
  7060. if (!pinctl_mode) {
  7061. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  7062. cfg_val = 0x4;
  7063. else
  7064. cfg_val = 0xC;
  7065. } else {
  7066. cfg_val = 0;
  7067. }
  7068. snd_soc_update_bits(codec, cfg_reg, 0x07, cfg_val);
  7069. dev_dbg(codec->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n",
  7070. __func__, ctl_reg, mask, ctl_val, cfg_reg, cfg_val);
  7071. return 0;
  7072. }
  7073. static void wcd_vbat_adc_out_config_2_0(struct wcd_vbat *vbat,
  7074. struct snd_soc_codec *codec)
  7075. {
  7076. u8 val1, val2;
  7077. /*
  7078. * Measure dcp1 by using "ALT" branch of band gap
  7079. * voltage(Vbg) and use it in FAST mode
  7080. */
  7081. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x82, 0x82);
  7082. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7083. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x01);
  7084. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x80);
  7085. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x00);
  7086. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x20);
  7087. /* Wait 100 usec after calibration select as Vbg */
  7088. usleep_range(100, 110);
  7089. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7090. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7091. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7092. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7093. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7094. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x40, 0x40);
  7095. /* Wait 100 usec after selecting Vbg as 1.05V */
  7096. usleep_range(100, 110);
  7097. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7098. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7099. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7100. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7101. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7102. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7103. __func__, vbat->dcp1, vbat->dcp2);
  7104. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7105. /* Wait 100 usec after selecting Vbg as 0.85V */
  7106. usleep_range(100, 110);
  7107. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x00);
  7108. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x20);
  7109. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x00);
  7110. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x00);
  7111. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x00);
  7112. }
  7113. static void wcd_vbat_adc_out_config_1_x(struct wcd_vbat *vbat,
  7114. struct snd_soc_codec *codec)
  7115. {
  7116. u8 val1, val2;
  7117. /*
  7118. * Measure dcp1 by applying band gap voltage(Vbg)
  7119. * of 0.85V
  7120. */
  7121. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x20);
  7122. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7123. snd_soc_write(codec, WCD9335_BIAS_VBG_FINE_ADJ, 0x05);
  7124. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7125. /* Wait 2 sec after enabling band gap bias */
  7126. usleep_range(2000000, 2000100);
  7127. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x82);
  7128. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x87);
  7129. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7130. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0D);
  7131. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01);
  7132. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7133. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xDE);
  7134. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x3C);
  7135. /* Wait 1 msec after calibration select as Vbg */
  7136. usleep_range(1000, 1100);
  7137. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
  7138. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7139. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7140. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7141. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7142. /*
  7143. * Measure dcp2 by applying band gap voltage(Vbg)
  7144. * of 1.05V
  7145. */
  7146. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7147. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7148. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x68);
  7149. /* Wait 2 msec after selecting Vbg as 1.05V */
  7150. usleep_range(2000, 2100);
  7151. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7152. /* Wait 1 sec after enabling band gap bias */
  7153. usleep_range(1000000, 1000100);
  7154. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
  7155. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7156. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7157. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7158. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7159. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7160. __func__, vbat->dcp1, vbat->dcp2);
  7161. /* Reset the Vbat ADC configuration */
  7162. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7163. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7164. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7165. /* Wait 2 msec after selecting Vbg as 0.85V */
  7166. usleep_range(2000, 2100);
  7167. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7168. /* Wait 1 sec after enabling band gap bias */
  7169. usleep_range(1000000, 1000100);
  7170. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x1C);
  7171. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xFE);
  7172. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7173. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7174. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x00);
  7175. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x00);
  7176. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0A);
  7177. }
  7178. static void wcd_vbat_adc_out_config(struct wcd_vbat *vbat,
  7179. struct snd_soc_codec *codec)
  7180. {
  7181. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  7182. if (!vbat->adc_config) {
  7183. tasha_cdc_mclk_enable(codec, true, false);
  7184. if (TASHA_IS_2_0(wcd9xxx))
  7185. wcd_vbat_adc_out_config_2_0(vbat, codec);
  7186. else
  7187. wcd_vbat_adc_out_config_1_x(vbat, codec);
  7188. tasha_cdc_mclk_enable(codec, false, false);
  7189. vbat->adc_config = true;
  7190. }
  7191. }
  7192. static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec)
  7193. {
  7194. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7195. struct firmware_cal *hwdep_cal = NULL;
  7196. struct vbat_monitor_reg *vbat_reg_ptr = NULL;
  7197. const void *data;
  7198. size_t cal_size, vbat_size_remaining;
  7199. int ret = 0, i;
  7200. u32 vbat_writes_size = 0;
  7201. u16 reg;
  7202. u8 mask, val, old_val;
  7203. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_VBAT_CAL);
  7204. if (hwdep_cal) {
  7205. data = hwdep_cal->data;
  7206. cal_size = hwdep_cal->size;
  7207. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7208. __func__);
  7209. } else {
  7210. dev_err(codec->dev, "%s: Vbat cal not received\n",
  7211. __func__);
  7212. ret = -EINVAL;
  7213. goto done;
  7214. }
  7215. if (cal_size < sizeof(*vbat_reg_ptr)) {
  7216. dev_err(codec->dev,
  7217. "%s: Incorrect size %zd for Vbat Cal, expected %zd\n",
  7218. __func__, cal_size, sizeof(*vbat_reg_ptr));
  7219. ret = -EINVAL;
  7220. goto done;
  7221. }
  7222. vbat_reg_ptr = (struct vbat_monitor_reg *) (data);
  7223. if (!vbat_reg_ptr) {
  7224. dev_err(codec->dev,
  7225. "%s: Invalid calibration data for Vbat\n",
  7226. __func__);
  7227. ret = -EINVAL;
  7228. goto done;
  7229. }
  7230. vbat_writes_size = vbat_reg_ptr->size;
  7231. vbat_size_remaining = cal_size - sizeof(u32);
  7232. dev_dbg(codec->dev, "%s: vbat_writes_sz: %d, vbat_sz_remaining: %zd\n",
  7233. __func__, vbat_writes_size, vbat_size_remaining);
  7234. if ((vbat_writes_size * TASHA_PACKED_REG_SIZE)
  7235. > vbat_size_remaining) {
  7236. pr_err("%s: Incorrect Vbat calibration data\n", __func__);
  7237. ret = -EINVAL;
  7238. goto done;
  7239. }
  7240. for (i = 0 ; i < vbat_writes_size; i++) {
  7241. TASHA_CODEC_UNPACK_ENTRY(vbat_reg_ptr->writes[i],
  7242. reg, mask, val);
  7243. old_val = snd_soc_read(codec, reg);
  7244. snd_soc_write(codec, reg, (old_val & ~mask) | (val & mask));
  7245. }
  7246. done:
  7247. return ret;
  7248. }
  7249. static int tasha_vbat_adc_data_get(struct snd_kcontrol *kcontrol,
  7250. struct snd_ctl_elem_value *ucontrol)
  7251. {
  7252. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7253. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7254. wcd_vbat_adc_out_config(&tasha->vbat, codec);
  7255. ucontrol->value.integer.value[0] = tasha->vbat.dcp1;
  7256. ucontrol->value.integer.value[1] = tasha->vbat.dcp2;
  7257. dev_dbg(codec->dev,
  7258. "%s: Vbat ADC output values, Dcp1 : %lu, Dcp2: %lu\n",
  7259. __func__, ucontrol->value.integer.value[0],
  7260. ucontrol->value.integer.value[1]);
  7261. return 0;
  7262. }
  7263. static const char * const tasha_vbat_gsm_mode_text[] = {
  7264. "OFF", "ON"};
  7265. static const struct soc_enum tasha_vbat_gsm_mode_enum =
  7266. SOC_ENUM_SINGLE_EXT(2, tasha_vbat_gsm_mode_text);
  7267. static int tasha_vbat_gsm_mode_func_get(struct snd_kcontrol *kcontrol,
  7268. struct snd_ctl_elem_value *ucontrol)
  7269. {
  7270. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7271. ucontrol->value.integer.value[0] =
  7272. ((snd_soc_read(codec, WCD9335_CDC_VBAT_VBAT_CFG) & 0x04) ?
  7273. 1 : 0);
  7274. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7275. ucontrol->value.integer.value[0]);
  7276. return 0;
  7277. }
  7278. static int tasha_vbat_gsm_mode_func_put(struct snd_kcontrol *kcontrol,
  7279. struct snd_ctl_elem_value *ucontrol)
  7280. {
  7281. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7282. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7283. ucontrol->value.integer.value[0]);
  7284. /* Set Vbat register configuration for GSM mode bit based on value */
  7285. if (ucontrol->value.integer.value[0])
  7286. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7287. 0x04, 0x04);
  7288. else
  7289. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7290. 0x04, 0x00);
  7291. return 0;
  7292. }
  7293. static int tasha_codec_vbat_enable_event(struct snd_soc_dapm_widget *w,
  7294. struct snd_kcontrol *kcontrol,
  7295. int event)
  7296. {
  7297. int ret = 0;
  7298. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7299. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7300. u16 vbat_path_ctl, vbat_cfg, vbat_path_cfg;
  7301. vbat_path_ctl = WCD9335_CDC_VBAT_VBAT_PATH_CTL;
  7302. vbat_cfg = WCD9335_CDC_VBAT_VBAT_CFG;
  7303. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7304. if (!strcmp(w->name, "RX INT8 VBAT"))
  7305. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7306. else if (!strcmp(w->name, "RX INT7 VBAT"))
  7307. vbat_path_cfg = WCD9335_CDC_RX7_RX_PATH_CFG1;
  7308. else if (!strcmp(w->name, "RX INT6 VBAT"))
  7309. vbat_path_cfg = WCD9335_CDC_RX6_RX_PATH_CFG1;
  7310. else if (!strcmp(w->name, "RX INT5 VBAT"))
  7311. vbat_path_cfg = WCD9335_CDC_RX5_RX_PATH_CFG1;
  7312. switch (event) {
  7313. case SND_SOC_DAPM_PRE_PMU:
  7314. ret = tasha_update_vbat_reg_config(codec);
  7315. if (ret) {
  7316. dev_dbg(codec->dev,
  7317. "%s : VBAT isn't calibrated, So not enabling it\n",
  7318. __func__);
  7319. return 0;
  7320. }
  7321. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7322. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x02);
  7323. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x10);
  7324. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x01);
  7325. tasha->vbat.is_enabled = true;
  7326. break;
  7327. case SND_SOC_DAPM_POST_PMD:
  7328. if (tasha->vbat.is_enabled) {
  7329. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x00);
  7330. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x00);
  7331. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x00);
  7332. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7333. tasha->vbat.is_enabled = false;
  7334. }
  7335. break;
  7336. };
  7337. return ret;
  7338. }
  7339. static const char * const rx_hph_mode_mux_text[] = {
  7340. "CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI"
  7341. };
  7342. static const struct soc_enum rx_hph_mode_mux_enum =
  7343. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text),
  7344. rx_hph_mode_mux_text);
  7345. static const char * const amic_pwr_lvl_text[] = {
  7346. "LOW_PWR", "DEFAULT", "HIGH_PERF"
  7347. };
  7348. static const struct soc_enum amic_pwr_lvl_enum =
  7349. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amic_pwr_lvl_text),
  7350. amic_pwr_lvl_text);
  7351. static const struct snd_kcontrol_new tasha_snd_controls[] = {
  7352. SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
  7353. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7354. SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
  7355. 0, -84, 40, digital_gain),
  7356. SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
  7357. 0, -84, 40, digital_gain),
  7358. SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
  7359. 0, -84, 40, digital_gain),
  7360. SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
  7361. 0, -84, 40, digital_gain),
  7362. SOC_SINGLE_SX_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
  7363. 0, -84, 40, digital_gain),
  7364. SOC_SINGLE_SX_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
  7365. 0, -84, 40, digital_gain),
  7366. SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
  7367. 0, -84, 40, digital_gain),
  7368. SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
  7369. 0, -84, 40, digital_gain),
  7370. SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
  7371. WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
  7372. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7373. SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
  7374. WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
  7375. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7376. SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
  7377. WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
  7378. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7379. SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
  7380. WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
  7381. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7382. SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
  7383. WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
  7384. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7385. SOC_SINGLE_SX_TLV("RX5 Mix Digital Volume",
  7386. WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
  7387. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7388. SOC_SINGLE_SX_TLV("RX6 Mix Digital Volume",
  7389. WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
  7390. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7391. SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
  7392. WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
  7393. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7394. SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
  7395. WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
  7396. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7397. SOC_SINGLE_SX_TLV("DEC0 Volume", WCD9335_CDC_TX0_TX_VOL_CTL, 0,
  7398. -84, 40, digital_gain),
  7399. SOC_SINGLE_SX_TLV("DEC1 Volume", WCD9335_CDC_TX1_TX_VOL_CTL, 0,
  7400. -84, 40, digital_gain),
  7401. SOC_SINGLE_SX_TLV("DEC2 Volume", WCD9335_CDC_TX2_TX_VOL_CTL, 0,
  7402. -84, 40, digital_gain),
  7403. SOC_SINGLE_SX_TLV("DEC3 Volume", WCD9335_CDC_TX3_TX_VOL_CTL, 0,
  7404. -84, 40, digital_gain),
  7405. SOC_SINGLE_SX_TLV("DEC4 Volume", WCD9335_CDC_TX4_TX_VOL_CTL, 0,
  7406. -84, 40, digital_gain),
  7407. SOC_SINGLE_SX_TLV("DEC5 Volume", WCD9335_CDC_TX5_TX_VOL_CTL, 0,
  7408. -84, 40, digital_gain),
  7409. SOC_SINGLE_SX_TLV("DEC6 Volume", WCD9335_CDC_TX6_TX_VOL_CTL, 0,
  7410. -84, 40, digital_gain),
  7411. SOC_SINGLE_SX_TLV("DEC7 Volume", WCD9335_CDC_TX7_TX_VOL_CTL, 0,
  7412. -84, 40, digital_gain),
  7413. SOC_SINGLE_SX_TLV("DEC8 Volume", WCD9335_CDC_TX8_TX_VOL_CTL, 0,
  7414. -84, 40, digital_gain),
  7415. SOC_SINGLE_SX_TLV("IIR0 INP0 Volume",
  7416. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, -84,
  7417. 40, digital_gain),
  7418. SOC_SINGLE_SX_TLV("IIR0 INP1 Volume",
  7419. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, -84,
  7420. 40, digital_gain),
  7421. SOC_SINGLE_SX_TLV("IIR0 INP2 Volume",
  7422. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, -84,
  7423. 40, digital_gain),
  7424. SOC_SINGLE_SX_TLV("IIR0 INP3 Volume",
  7425. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, -84,
  7426. 40, digital_gain),
  7427. SOC_SINGLE_SX_TLV("IIR1 INP0 Volume",
  7428. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, -84,
  7429. 40, digital_gain),
  7430. SOC_SINGLE_SX_TLV("IIR1 INP1 Volume",
  7431. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, -84,
  7432. 40, digital_gain),
  7433. SOC_SINGLE_SX_TLV("IIR1 INP2 Volume",
  7434. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, -84,
  7435. 40, digital_gain),
  7436. SOC_SINGLE_SX_TLV("IIR1 INP3 Volume",
  7437. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, -84,
  7438. 40, digital_gain),
  7439. SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 100, 0, tasha_get_anc_slot,
  7440. tasha_put_anc_slot),
  7441. SOC_ENUM_EXT("ANC Function", tasha_anc_func_enum, tasha_get_anc_func,
  7442. tasha_put_anc_func),
  7443. SOC_ENUM_EXT("CLK MODE", tasha_clkmode_enum, tasha_get_clkmode,
  7444. tasha_put_clkmode),
  7445. SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
  7446. SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
  7447. SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
  7448. SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
  7449. SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
  7450. SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
  7451. SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
  7452. SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
  7453. SOC_ENUM("TX8 HPF cut off", cf_dec8_enum),
  7454. SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
  7455. SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
  7456. SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
  7457. SOC_ENUM("RX INT1_2 HPF cut off", cf_int1_2_enum),
  7458. SOC_ENUM("RX INT2_1 HPF cut off", cf_int2_1_enum),
  7459. SOC_ENUM("RX INT2_2 HPF cut off", cf_int2_2_enum),
  7460. SOC_ENUM("RX INT3_1 HPF cut off", cf_int3_1_enum),
  7461. SOC_ENUM("RX INT3_2 HPF cut off", cf_int3_2_enum),
  7462. SOC_ENUM("RX INT4_1 HPF cut off", cf_int4_1_enum),
  7463. SOC_ENUM("RX INT4_2 HPF cut off", cf_int4_2_enum),
  7464. SOC_ENUM("RX INT5_1 HPF cut off", cf_int5_1_enum),
  7465. SOC_ENUM("RX INT5_2 HPF cut off", cf_int5_2_enum),
  7466. SOC_ENUM("RX INT6_1 HPF cut off", cf_int6_1_enum),
  7467. SOC_ENUM("RX INT6_2 HPF cut off", cf_int6_2_enum),
  7468. SOC_ENUM("RX INT7_1 HPF cut off", cf_int7_1_enum),
  7469. SOC_ENUM("RX INT7_2 HPF cut off", cf_int7_2_enum),
  7470. SOC_ENUM("RX INT8_1 HPF cut off", cf_int8_1_enum),
  7471. SOC_ENUM("RX INT8_2 HPF cut off", cf_int8_2_enum),
  7472. SOC_SINGLE_EXT("IIR0 Enable Band1", IIR0, BAND1, 1, 0,
  7473. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7474. SOC_SINGLE_EXT("IIR0 Enable Band2", IIR0, BAND2, 1, 0,
  7475. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7476. SOC_SINGLE_EXT("IIR0 Enable Band3", IIR0, BAND3, 1, 0,
  7477. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7478. SOC_SINGLE_EXT("IIR0 Enable Band4", IIR0, BAND4, 1, 0,
  7479. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7480. SOC_SINGLE_EXT("IIR0 Enable Band5", IIR0, BAND5, 1, 0,
  7481. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7482. SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0,
  7483. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7484. SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
  7485. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7486. SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
  7487. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7488. SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
  7489. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7490. SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
  7491. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7492. SOC_SINGLE_MULTI_EXT("IIR0 Band1", IIR0, BAND1, 255, 0, 5,
  7493. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7494. SOC_SINGLE_MULTI_EXT("IIR0 Band2", IIR0, BAND2, 255, 0, 5,
  7495. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7496. SOC_SINGLE_MULTI_EXT("IIR0 Band3", IIR0, BAND3, 255, 0, 5,
  7497. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7498. SOC_SINGLE_MULTI_EXT("IIR0 Band4", IIR0, BAND4, 255, 0, 5,
  7499. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7500. SOC_SINGLE_MULTI_EXT("IIR0 Band5", IIR0, BAND5, 255, 0, 5,
  7501. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7502. SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
  7503. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7504. SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
  7505. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7506. SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
  7507. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7508. SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
  7509. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7510. SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
  7511. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7512. SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0,
  7513. tasha_get_compander, tasha_set_compander),
  7514. SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0,
  7515. tasha_get_compander, tasha_set_compander),
  7516. SOC_SINGLE_EXT("COMP3 Switch", SND_SOC_NOPM, COMPANDER_3, 1, 0,
  7517. tasha_get_compander, tasha_set_compander),
  7518. SOC_SINGLE_EXT("COMP4 Switch", SND_SOC_NOPM, COMPANDER_4, 1, 0,
  7519. tasha_get_compander, tasha_set_compander),
  7520. SOC_SINGLE_EXT("COMP5 Switch", SND_SOC_NOPM, COMPANDER_5, 1, 0,
  7521. tasha_get_compander, tasha_set_compander),
  7522. SOC_SINGLE_EXT("COMP6 Switch", SND_SOC_NOPM, COMPANDER_6, 1, 0,
  7523. tasha_get_compander, tasha_set_compander),
  7524. SOC_SINGLE_EXT("COMP7 Switch", SND_SOC_NOPM, COMPANDER_7, 1, 0,
  7525. tasha_get_compander, tasha_set_compander),
  7526. SOC_SINGLE_EXT("COMP8 Switch", SND_SOC_NOPM, COMPANDER_8, 1, 0,
  7527. tasha_get_compander, tasha_set_compander),
  7528. SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum,
  7529. tasha_rx_hph_mode_get, tasha_rx_hph_mode_put),
  7530. SOC_ENUM_EXT("MAD Input", tasha_conn_mad_enum,
  7531. tasha_mad_input_get, tasha_mad_input_put),
  7532. SOC_SINGLE_EXT("LDO_H Enable", SND_SOC_NOPM, 0, 1, 0,
  7533. tasha_enable_ldo_h_get, tasha_enable_ldo_h_put),
  7534. SOC_SINGLE_EXT("DMIC1_CLK_PIN_MODE", SND_SOC_NOPM, 17, 1, 0,
  7535. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7536. SOC_SINGLE_EXT("DMIC1_DATA_PIN_MODE", SND_SOC_NOPM, 18, 1, 0,
  7537. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7538. SOC_SINGLE_EXT("DMIC2_CLK_PIN_MODE", SND_SOC_NOPM, 19, 1, 0,
  7539. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7540. SOC_SINGLE_EXT("DMIC2_DATA_PIN_MODE", SND_SOC_NOPM, 20, 1, 0,
  7541. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7542. SOC_SINGLE_EXT("DMIC3_CLK_PIN_MODE", SND_SOC_NOPM, 21, 1, 0,
  7543. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7544. SOC_SINGLE_EXT("DMIC3_DATA_PIN_MODE", SND_SOC_NOPM, 22, 1, 0,
  7545. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7546. SOC_ENUM_EXT("AMIC_1_2 PWR MODE", amic_pwr_lvl_enum,
  7547. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7548. SOC_ENUM_EXT("AMIC_3_4 PWR MODE", amic_pwr_lvl_enum,
  7549. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7550. SOC_ENUM_EXT("AMIC_5_6 PWR MODE", amic_pwr_lvl_enum,
  7551. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7552. SOC_SINGLE_MULTI_EXT("Vbat ADC data", SND_SOC_NOPM, 0, 0xFFFF, 0, 2,
  7553. tasha_vbat_adc_data_get, NULL),
  7554. SOC_ENUM_EXT("GSM mode Enable", tasha_vbat_gsm_mode_enum,
  7555. tasha_vbat_gsm_mode_func_get,
  7556. tasha_vbat_gsm_mode_func_put),
  7557. };
  7558. static int tasha_put_dec_enum(struct snd_kcontrol *kcontrol,
  7559. struct snd_ctl_elem_value *ucontrol)
  7560. {
  7561. struct snd_soc_dapm_widget *widget =
  7562. snd_soc_dapm_kcontrol_widget(kcontrol);
  7563. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7564. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7565. unsigned int val;
  7566. u16 mic_sel_reg;
  7567. u8 mic_sel;
  7568. val = ucontrol->value.enumerated.item[0];
  7569. if (val > e->items - 1)
  7570. return -EINVAL;
  7571. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7572. widget->name, val);
  7573. switch (e->reg) {
  7574. case WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1:
  7575. mic_sel_reg = WCD9335_CDC_TX0_TX_PATH_CFG0;
  7576. break;
  7577. case WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1:
  7578. mic_sel_reg = WCD9335_CDC_TX1_TX_PATH_CFG0;
  7579. break;
  7580. case WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1:
  7581. mic_sel_reg = WCD9335_CDC_TX2_TX_PATH_CFG0;
  7582. break;
  7583. case WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1:
  7584. mic_sel_reg = WCD9335_CDC_TX3_TX_PATH_CFG0;
  7585. break;
  7586. case WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0:
  7587. mic_sel_reg = WCD9335_CDC_TX4_TX_PATH_CFG0;
  7588. break;
  7589. case WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0:
  7590. mic_sel_reg = WCD9335_CDC_TX5_TX_PATH_CFG0;
  7591. break;
  7592. case WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0:
  7593. mic_sel_reg = WCD9335_CDC_TX6_TX_PATH_CFG0;
  7594. break;
  7595. case WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0:
  7596. mic_sel_reg = WCD9335_CDC_TX7_TX_PATH_CFG0;
  7597. break;
  7598. case WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0:
  7599. mic_sel_reg = WCD9335_CDC_TX8_TX_PATH_CFG0;
  7600. break;
  7601. default:
  7602. dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n",
  7603. __func__, e->reg);
  7604. return -EINVAL;
  7605. }
  7606. /* ADC: 0, DMIC: 1 */
  7607. mic_sel = val ? 0x0 : 0x1;
  7608. snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, mic_sel << 7);
  7609. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7610. }
  7611. static int tasha_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol,
  7612. struct snd_ctl_elem_value *ucontrol)
  7613. {
  7614. struct snd_soc_dapm_widget *widget =
  7615. snd_soc_dapm_kcontrol_widget(kcontrol);
  7616. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7617. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7618. unsigned int val;
  7619. unsigned short look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7620. val = ucontrol->value.enumerated.item[0];
  7621. if (val >= e->items)
  7622. return -EINVAL;
  7623. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7624. widget->name, val);
  7625. if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0)
  7626. look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7627. else if (e->reg == WCD9335_CDC_RX1_RX_PATH_SEC0)
  7628. look_ahead_dly_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  7629. else if (e->reg == WCD9335_CDC_RX2_RX_PATH_SEC0)
  7630. look_ahead_dly_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  7631. /* Set Look Ahead Delay */
  7632. snd_soc_update_bits(codec, look_ahead_dly_reg,
  7633. 0x08, (val ? 0x08 : 0x00));
  7634. /* Set DEM INP Select */
  7635. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7636. }
  7637. static int tasha_ear_pa_gain_get(struct snd_kcontrol *kcontrol,
  7638. struct snd_ctl_elem_value *ucontrol)
  7639. {
  7640. u8 ear_pa_gain;
  7641. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7642. ear_pa_gain = snd_soc_read(codec, WCD9335_ANA_EAR);
  7643. ear_pa_gain = (ear_pa_gain & 0x70) >> 4;
  7644. ucontrol->value.integer.value[0] = ear_pa_gain;
  7645. dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__,
  7646. ear_pa_gain);
  7647. return 0;
  7648. }
  7649. static int tasha_ear_pa_gain_put(struct snd_kcontrol *kcontrol,
  7650. struct snd_ctl_elem_value *ucontrol)
  7651. {
  7652. u8 ear_pa_gain;
  7653. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7654. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7655. __func__, ucontrol->value.integer.value[0]);
  7656. ear_pa_gain = ucontrol->value.integer.value[0] << 4;
  7657. snd_soc_update_bits(codec, WCD9335_ANA_EAR, 0x70, ear_pa_gain);
  7658. return 0;
  7659. }
  7660. static int tasha_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
  7661. struct snd_ctl_elem_value *ucontrol)
  7662. {
  7663. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7664. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7665. ucontrol->value.integer.value[0] = tasha->ear_spkr_gain;
  7666. dev_dbg(codec->dev, "%s: ear_spkr_gain = %ld\n", __func__,
  7667. ucontrol->value.integer.value[0]);
  7668. return 0;
  7669. }
  7670. static int tasha_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
  7671. struct snd_ctl_elem_value *ucontrol)
  7672. {
  7673. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7674. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7675. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7676. __func__, ucontrol->value.integer.value[0]);
  7677. tasha->ear_spkr_gain = ucontrol->value.integer.value[0];
  7678. return 0;
  7679. }
  7680. static int tasha_config_compander(struct snd_soc_codec *codec, int interp_n,
  7681. int event)
  7682. {
  7683. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7684. int comp;
  7685. u16 comp_ctl0_reg, rx_path_cfg0_reg;
  7686. /* EAR does not have compander */
  7687. if (!interp_n)
  7688. return 0;
  7689. comp = interp_n - 1;
  7690. dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n",
  7691. __func__, event, comp + 1, tasha->comp_enabled[comp]);
  7692. if (!tasha->comp_enabled[comp])
  7693. return 0;
  7694. comp_ctl0_reg = WCD9335_CDC_COMPANDER1_CTL0 + (comp * 8);
  7695. rx_path_cfg0_reg = WCD9335_CDC_RX1_RX_PATH_CFG0 + (comp * 20);
  7696. if (SND_SOC_DAPM_EVENT_ON(event)) {
  7697. /* Enable Compander Clock */
  7698. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01);
  7699. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7700. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7701. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02);
  7702. }
  7703. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  7704. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04);
  7705. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00);
  7706. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7707. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7708. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00);
  7709. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00);
  7710. }
  7711. return 0;
  7712. }
  7713. static int tasha_codec_config_mad(struct snd_soc_codec *codec)
  7714. {
  7715. int ret = 0;
  7716. int idx;
  7717. const struct firmware *fw;
  7718. struct firmware_cal *hwdep_cal = NULL;
  7719. struct wcd_mad_audio_cal *mad_cal = NULL;
  7720. const void *data;
  7721. const char *filename = TASHA_MAD_AUDIO_FIRMWARE_PATH;
  7722. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7723. size_t cal_size;
  7724. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_MAD_CAL);
  7725. if (hwdep_cal) {
  7726. data = hwdep_cal->data;
  7727. cal_size = hwdep_cal->size;
  7728. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7729. __func__);
  7730. } else {
  7731. ret = request_firmware(&fw, filename, codec->dev);
  7732. if (ret || !fw) {
  7733. dev_err(codec->dev,
  7734. "%s: MAD firmware acquire failed, err = %d\n",
  7735. __func__, ret);
  7736. return -ENODEV;
  7737. }
  7738. data = fw->data;
  7739. cal_size = fw->size;
  7740. dev_dbg(codec->dev, "%s: using request_firmware calibration\n",
  7741. __func__);
  7742. }
  7743. if (cal_size < sizeof(*mad_cal)) {
  7744. dev_err(codec->dev,
  7745. "%s: Incorrect size %zd for MAD Cal, expected %zd\n",
  7746. __func__, cal_size, sizeof(*mad_cal));
  7747. ret = -ENOMEM;
  7748. goto done;
  7749. }
  7750. mad_cal = (struct wcd_mad_audio_cal *) (data);
  7751. if (!mad_cal) {
  7752. dev_err(codec->dev,
  7753. "%s: Invalid calibration data\n",
  7754. __func__);
  7755. ret = -EINVAL;
  7756. goto done;
  7757. }
  7758. snd_soc_write(codec, WCD9335_SOC_MAD_MAIN_CTL_2,
  7759. mad_cal->microphone_info.cycle_time);
  7760. snd_soc_update_bits(codec, WCD9335_SOC_MAD_MAIN_CTL_1, 0xFF << 3,
  7761. ((uint16_t)mad_cal->microphone_info.settle_time)
  7762. << 3);
  7763. /* Audio */
  7764. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_8,
  7765. mad_cal->audio_info.rms_omit_samples);
  7766. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_1,
  7767. 0x07 << 4, mad_cal->audio_info.rms_comp_time << 4);
  7768. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03 << 2,
  7769. mad_cal->audio_info.detection_mechanism << 2);
  7770. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_7,
  7771. mad_cal->audio_info.rms_diff_threshold & 0x3F);
  7772. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_5,
  7773. mad_cal->audio_info.rms_threshold_lsb);
  7774. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_6,
  7775. mad_cal->audio_info.rms_threshold_msb);
  7776. for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients);
  7777. idx++) {
  7778. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR,
  7779. 0x3F, idx);
  7780. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL,
  7781. mad_cal->audio_info.iir_coefficients[idx]);
  7782. dev_dbg(codec->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x",
  7783. __func__, idx,
  7784. mad_cal->audio_info.iir_coefficients[idx]);
  7785. }
  7786. /* Beacon */
  7787. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_8,
  7788. mad_cal->beacon_info.rms_omit_samples);
  7789. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_1,
  7790. 0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4);
  7791. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_2, 0x03 << 2,
  7792. mad_cal->beacon_info.detection_mechanism << 2);
  7793. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_7,
  7794. mad_cal->beacon_info.rms_diff_threshold & 0x1F);
  7795. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_5,
  7796. mad_cal->beacon_info.rms_threshold_lsb);
  7797. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_6,
  7798. mad_cal->beacon_info.rms_threshold_msb);
  7799. for (idx = 0; idx < ARRAY_SIZE(mad_cal->beacon_info.iir_coefficients);
  7800. idx++) {
  7801. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR,
  7802. 0x3F, idx);
  7803. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL,
  7804. mad_cal->beacon_info.iir_coefficients[idx]);
  7805. dev_dbg(codec->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x",
  7806. __func__, idx,
  7807. mad_cal->beacon_info.iir_coefficients[idx]);
  7808. }
  7809. /* Ultrasound */
  7810. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_1,
  7811. 0x07 << 4,
  7812. mad_cal->ultrasound_info.rms_comp_time << 4);
  7813. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_2, 0x03 << 2,
  7814. mad_cal->ultrasound_info.detection_mechanism << 2);
  7815. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_7,
  7816. mad_cal->ultrasound_info.rms_diff_threshold & 0x1F);
  7817. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_5,
  7818. mad_cal->ultrasound_info.rms_threshold_lsb);
  7819. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_6,
  7820. mad_cal->ultrasound_info.rms_threshold_msb);
  7821. done:
  7822. if (!hwdep_cal)
  7823. release_firmware(fw);
  7824. return ret;
  7825. }
  7826. static int tasha_codec_enable_mad(struct snd_soc_dapm_widget *w,
  7827. struct snd_kcontrol *kcontrol, int event)
  7828. {
  7829. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7830. int ret = 0;
  7831. dev_dbg(codec->dev,
  7832. "%s: event = %d\n", __func__, event);
  7833. /* Return if CPE INPUT is DEC1 */
  7834. if (snd_soc_read(codec, WCD9335_CPE_SS_SVA_CFG) & 0x01)
  7835. return ret;
  7836. switch (event) {
  7837. case SND_SOC_DAPM_PRE_PMU:
  7838. /* Turn on MAD clk */
  7839. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7840. 0x01, 0x01);
  7841. /* Undo reset for MAD */
  7842. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7843. 0x02, 0x00);
  7844. ret = tasha_codec_config_mad(codec);
  7845. if (ret)
  7846. dev_err(codec->dev,
  7847. "%s: Failed to config MAD, err = %d\n",
  7848. __func__, ret);
  7849. break;
  7850. case SND_SOC_DAPM_POST_PMD:
  7851. /* Reset the MAD block */
  7852. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7853. 0x02, 0x02);
  7854. /* Turn off MAD clk */
  7855. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7856. 0x01, 0x00);
  7857. break;
  7858. }
  7859. return ret;
  7860. }
  7861. static int tasha_codec_configure_cpe_input(struct snd_soc_dapm_widget *w,
  7862. struct snd_kcontrol *kcontrol, int event)
  7863. {
  7864. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7865. dev_dbg(codec->dev,
  7866. "%s: event = %d\n", __func__, event);
  7867. switch (event) {
  7868. case SND_SOC_DAPM_PRE_PMU:
  7869. /* Configure CPE input as DEC1 */
  7870. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7871. 0x01, 0x01);
  7872. /* Configure DEC1 Tx out with sample rate as 16K */
  7873. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7874. 0x0F, 0x01);
  7875. break;
  7876. case SND_SOC_DAPM_POST_PMD:
  7877. /* Reset DEC1 Tx out sample rate */
  7878. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7879. 0x0F, 0x04);
  7880. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7881. 0x01, 0x00);
  7882. break;
  7883. }
  7884. return 0;
  7885. }
  7886. static int tasha_codec_aif4_mixer_switch_get(struct snd_kcontrol *kcontrol,
  7887. struct snd_ctl_elem_value *ucontrol)
  7888. {
  7889. struct snd_soc_dapm_widget *widget =
  7890. snd_soc_dapm_kcontrol_widget(kcontrol);
  7891. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7892. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7893. if (test_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask))
  7894. ucontrol->value.integer.value[0] = 1;
  7895. else
  7896. ucontrol->value.integer.value[0] = 0;
  7897. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7898. __func__, ucontrol->value.integer.value[0]);
  7899. return 0;
  7900. }
  7901. static int tasha_codec_aif4_mixer_switch_put(struct snd_kcontrol *kcontrol,
  7902. struct snd_ctl_elem_value *ucontrol)
  7903. {
  7904. struct snd_soc_dapm_widget *widget =
  7905. snd_soc_dapm_kcontrol_widget(kcontrol);
  7906. struct snd_soc_dapm_update *update = NULL;
  7907. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7908. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7909. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7910. __func__, ucontrol->value.integer.value[0]);
  7911. if (ucontrol->value.integer.value[0]) {
  7912. snd_soc_dapm_mixer_update_power(widget->dapm,
  7913. kcontrol, 1, update);
  7914. set_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7915. } else {
  7916. snd_soc_dapm_mixer_update_power(widget->dapm,
  7917. kcontrol, 0, update);
  7918. clear_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7919. }
  7920. return 1;
  7921. }
  7922. static const char * const tasha_ear_pa_gain_text[] = {
  7923. "G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB",
  7924. "G_0_DB", "G_M2P5_DB", "UNDEFINED", "G_M12_DB"
  7925. };
  7926. static const char * const tasha_ear_spkr_pa_gain_text[] = {
  7927. "G_DEFAULT", "G_0_DB", "G_1_DB", "G_2_DB", "G_3_DB", "G_4_DB",
  7928. "G_5_DB", "G_6_DB"
  7929. };
  7930. static const struct soc_enum tasha_ear_pa_gain_enum =
  7931. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_pa_gain_text),
  7932. tasha_ear_pa_gain_text);
  7933. static const struct soc_enum tasha_ear_spkr_pa_gain_enum =
  7934. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_spkr_pa_gain_text),
  7935. tasha_ear_spkr_pa_gain_text);
  7936. static const struct snd_kcontrol_new tasha_analog_gain_controls[] = {
  7937. SOC_ENUM_EXT("EAR PA Gain", tasha_ear_pa_gain_enum,
  7938. tasha_ear_pa_gain_get, tasha_ear_pa_gain_put),
  7939. SOC_ENUM_EXT("EAR SPKR PA Gain", tasha_ear_spkr_pa_gain_enum,
  7940. tasha_ear_spkr_pa_gain_get, tasha_ear_spkr_pa_gain_put),
  7941. SOC_SINGLE_TLV("HPHL Volume", WCD9335_HPH_L_EN, 0, 20, 1,
  7942. line_gain),
  7943. SOC_SINGLE_TLV("HPHR Volume", WCD9335_HPH_R_EN, 0, 20, 1,
  7944. line_gain),
  7945. SOC_SINGLE_TLV("LINEOUT1 Volume", WCD9335_DIFF_LO_LO1_COMPANDER,
  7946. 3, 16, 1, line_gain),
  7947. SOC_SINGLE_TLV("LINEOUT2 Volume", WCD9335_DIFF_LO_LO2_COMPANDER,
  7948. 3, 16, 1, line_gain),
  7949. SOC_SINGLE_TLV("LINEOUT3 Volume", WCD9335_SE_LO_LO3_GAIN, 0, 20, 1,
  7950. line_gain),
  7951. SOC_SINGLE_TLV("LINEOUT4 Volume", WCD9335_SE_LO_LO4_GAIN, 0, 20, 1,
  7952. line_gain),
  7953. SOC_SINGLE_TLV("ADC1 Volume", WCD9335_ANA_AMIC1, 0, 20, 0,
  7954. analog_gain),
  7955. SOC_SINGLE_TLV("ADC2 Volume", WCD9335_ANA_AMIC2, 0, 20, 0,
  7956. analog_gain),
  7957. SOC_SINGLE_TLV("ADC3 Volume", WCD9335_ANA_AMIC3, 0, 20, 0,
  7958. analog_gain),
  7959. SOC_SINGLE_TLV("ADC4 Volume", WCD9335_ANA_AMIC4, 0, 20, 0,
  7960. analog_gain),
  7961. SOC_SINGLE_TLV("ADC5 Volume", WCD9335_ANA_AMIC5, 0, 20, 0,
  7962. analog_gain),
  7963. SOC_SINGLE_TLV("ADC6 Volume", WCD9335_ANA_AMIC6, 0, 20, 0,
  7964. analog_gain),
  7965. };
  7966. static const char * const spl_src0_mux_text[] = {
  7967. "ZERO", "SRC_IN_HPHL", "SRC_IN_LO1",
  7968. };
  7969. static const char * const spl_src1_mux_text[] = {
  7970. "ZERO", "SRC_IN_HPHR", "SRC_IN_LO2",
  7971. };
  7972. static const char * const spl_src2_mux_text[] = {
  7973. "ZERO", "SRC_IN_LO3", "SRC_IN_SPKRL",
  7974. };
  7975. static const char * const spl_src3_mux_text[] = {
  7976. "ZERO", "SRC_IN_LO4", "SRC_IN_SPKRR",
  7977. };
  7978. static const char * const rx_int0_7_mix_mux_text[] = {
  7979. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  7980. "RX6", "RX7", "PROXIMITY"
  7981. };
  7982. static const char * const rx_int_mix_mux_text[] = {
  7983. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  7984. "RX6", "RX7"
  7985. };
  7986. static const char * const rx_prim_mix_text[] = {
  7987. "ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2",
  7988. "RX3", "RX4", "RX5", "RX6", "RX7"
  7989. };
  7990. static const char * const rx_sidetone_mix_text[] = {
  7991. "ZERO", "SRC0", "SRC1", "SRC_SUM"
  7992. };
  7993. static const char * const sb_tx0_mux_text[] = {
  7994. "ZERO", "RX_MIX_TX0", "DEC0", "DEC0_192"
  7995. };
  7996. static const char * const sb_tx1_mux_text[] = {
  7997. "ZERO", "RX_MIX_TX1", "DEC1", "DEC1_192"
  7998. };
  7999. static const char * const sb_tx2_mux_text[] = {
  8000. "ZERO", "RX_MIX_TX2", "DEC2", "DEC2_192"
  8001. };
  8002. static const char * const sb_tx3_mux_text[] = {
  8003. "ZERO", "RX_MIX_TX3", "DEC3", "DEC3_192"
  8004. };
  8005. static const char * const sb_tx4_mux_text[] = {
  8006. "ZERO", "RX_MIX_TX4", "DEC4", "DEC4_192"
  8007. };
  8008. static const char * const sb_tx5_mux_text[] = {
  8009. "ZERO", "RX_MIX_TX5", "DEC5", "DEC5_192"
  8010. };
  8011. static const char * const sb_tx6_mux_text[] = {
  8012. "ZERO", "RX_MIX_TX6", "DEC6", "DEC6_192"
  8013. };
  8014. static const char * const sb_tx7_mux_text[] = {
  8015. "ZERO", "RX_MIX_TX7", "DEC7", "DEC7_192"
  8016. };
  8017. static const char * const sb_tx8_mux_text[] = {
  8018. "ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192"
  8019. };
  8020. static const char * const sb_tx9_mux_text[] = {
  8021. "ZERO", "DEC7", "DEC7_192"
  8022. };
  8023. static const char * const sb_tx10_mux_text[] = {
  8024. "ZERO", "DEC6", "DEC6_192"
  8025. };
  8026. static const char * const sb_tx11_mux_text[] = {
  8027. "DEC_0_5", "DEC_9_12", "MAD_AUDIO", "MAD_BRDCST"
  8028. };
  8029. static const char * const sb_tx11_inp1_mux_text[] = {
  8030. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4",
  8031. "DEC5", "RX_MIX_TX5", "DEC9_10", "DEC11_12"
  8032. };
  8033. static const char * const sb_tx13_mux_text[] = {
  8034. "ZERO", "DEC5", "DEC5_192"
  8035. };
  8036. static const char * const tx13_inp_mux_text[] = {
  8037. "CDC_DEC_5", "MAD_BRDCST", "CPE_TX_PP"
  8038. };
  8039. static const char * const iir_inp_mux_text[] = {
  8040. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6",
  8041. "DEC7", "DEC8", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7"
  8042. };
  8043. static const char * const rx_int_dem_inp_mux_text[] = {
  8044. "NORMAL_DSM_OUT", "CLSH_DSM_OUT",
  8045. };
  8046. static const char * const rx_int0_interp_mux_text[] = {
  8047. "ZERO", "RX INT0 MIX2",
  8048. };
  8049. static const char * const rx_int1_interp_mux_text[] = {
  8050. "ZERO", "RX INT1 MIX2",
  8051. };
  8052. static const char * const rx_int2_interp_mux_text[] = {
  8053. "ZERO", "RX INT2 MIX2",
  8054. };
  8055. static const char * const rx_int3_interp_mux_text[] = {
  8056. "ZERO", "RX INT3 MIX2",
  8057. };
  8058. static const char * const rx_int4_interp_mux_text[] = {
  8059. "ZERO", "RX INT4 MIX2",
  8060. };
  8061. static const char * const rx_int5_interp_mux_text[] = {
  8062. "ZERO", "RX INT5 MIX2",
  8063. };
  8064. static const char * const rx_int6_interp_mux_text[] = {
  8065. "ZERO", "RX INT6 MIX2",
  8066. };
  8067. static const char * const rx_int7_interp_mux_text[] = {
  8068. "ZERO", "RX INT7 MIX2",
  8069. };
  8070. static const char * const rx_int8_interp_mux_text[] = {
  8071. "ZERO", "RX INT8 SEC MIX"
  8072. };
  8073. static const char * const mad_sel_text[] = {
  8074. "SPE", "MSM"
  8075. };
  8076. static const char * const adc_mux_text[] = {
  8077. "DMIC", "AMIC", "ANC_FB_TUNE1", "ANC_FB_TUNE2"
  8078. };
  8079. static const char * const dmic_mux_text[] = {
  8080. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8081. "SMIC0", "SMIC1", "SMIC2", "SMIC3"
  8082. };
  8083. static const char * const dmic_mux_alt_text[] = {
  8084. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8085. };
  8086. static const char * const amic_mux_text[] = {
  8087. "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6"
  8088. };
  8089. static const char * const rx_echo_mux_text[] = {
  8090. "ZERO", "RX_MIX0", "RX_MIX1", "RX_MIX2", "RX_MIX3", "RX_MIX4",
  8091. "RX_MIX5", "RX_MIX6", "RX_MIX7", "RX_MIX8", "RX_MIX_VBAT5",
  8092. "RX_MIX_VBAT6", "RX_MIX_VBAT7", "RX_MIX_VBAT8"
  8093. };
  8094. static const char * const anc0_fb_mux_text[] = {
  8095. "ZERO", "ANC_IN_HPHL", "ANC_IN_EAR", "ANC_IN_EAR_SPKR",
  8096. "ANC_IN_LO1"
  8097. };
  8098. static const char * const anc1_fb_mux_text[] = {
  8099. "ZERO", "ANC_IN_HPHR", "ANC_IN_LO2"
  8100. };
  8101. static const char * const native_mux_text[] = {
  8102. "OFF", "ON",
  8103. };
  8104. static const struct soc_enum spl_src0_mux_chain_enum =
  8105. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 0, 3,
  8106. spl_src0_mux_text);
  8107. static const struct soc_enum spl_src1_mux_chain_enum =
  8108. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 2, 3,
  8109. spl_src1_mux_text);
  8110. static const struct soc_enum spl_src2_mux_chain_enum =
  8111. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 4, 3,
  8112. spl_src2_mux_text);
  8113. static const struct soc_enum spl_src3_mux_chain_enum =
  8114. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 6, 3,
  8115. spl_src3_mux_text);
  8116. static const struct soc_enum rx_int0_2_mux_chain_enum =
  8117. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 0, 10,
  8118. rx_int0_7_mix_mux_text);
  8119. static const struct soc_enum rx_int1_2_mux_chain_enum =
  8120. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 0, 9,
  8121. rx_int_mix_mux_text);
  8122. static const struct soc_enum rx_int2_2_mux_chain_enum =
  8123. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 0, 9,
  8124. rx_int_mix_mux_text);
  8125. static const struct soc_enum rx_int3_2_mux_chain_enum =
  8126. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 0, 9,
  8127. rx_int_mix_mux_text);
  8128. static const struct soc_enum rx_int4_2_mux_chain_enum =
  8129. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 0, 9,
  8130. rx_int_mix_mux_text);
  8131. static const struct soc_enum rx_int5_2_mux_chain_enum =
  8132. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 0, 9,
  8133. rx_int_mix_mux_text);
  8134. static const struct soc_enum rx_int6_2_mux_chain_enum =
  8135. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 0, 9,
  8136. rx_int_mix_mux_text);
  8137. static const struct soc_enum rx_int7_2_mux_chain_enum =
  8138. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 0, 10,
  8139. rx_int0_7_mix_mux_text);
  8140. static const struct soc_enum rx_int8_2_mux_chain_enum =
  8141. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 0, 9,
  8142. rx_int_mix_mux_text);
  8143. static const struct soc_enum int1_1_native_enum =
  8144. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8145. native_mux_text);
  8146. static const struct soc_enum int2_1_native_enum =
  8147. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8148. native_mux_text);
  8149. static const struct soc_enum int3_1_native_enum =
  8150. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8151. native_mux_text);
  8152. static const struct soc_enum int4_1_native_enum =
  8153. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8154. native_mux_text);
  8155. static const struct soc_enum rx_int0_1_mix_inp0_chain_enum =
  8156. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 0, 13,
  8157. rx_prim_mix_text);
  8158. static const struct soc_enum rx_int0_1_mix_inp1_chain_enum =
  8159. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 4, 13,
  8160. rx_prim_mix_text);
  8161. static const struct soc_enum rx_int0_1_mix_inp2_chain_enum =
  8162. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 4, 13,
  8163. rx_prim_mix_text);
  8164. static const struct soc_enum rx_int1_1_mix_inp0_chain_enum =
  8165. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 0, 13,
  8166. rx_prim_mix_text);
  8167. static const struct soc_enum rx_int1_1_mix_inp1_chain_enum =
  8168. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 4, 13,
  8169. rx_prim_mix_text);
  8170. static const struct soc_enum rx_int1_1_mix_inp2_chain_enum =
  8171. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 4, 13,
  8172. rx_prim_mix_text);
  8173. static const struct soc_enum rx_int2_1_mix_inp0_chain_enum =
  8174. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 0, 13,
  8175. rx_prim_mix_text);
  8176. static const struct soc_enum rx_int2_1_mix_inp1_chain_enum =
  8177. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 4, 13,
  8178. rx_prim_mix_text);
  8179. static const struct soc_enum rx_int2_1_mix_inp2_chain_enum =
  8180. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 4, 13,
  8181. rx_prim_mix_text);
  8182. static const struct soc_enum rx_int3_1_mix_inp0_chain_enum =
  8183. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 0, 13,
  8184. rx_prim_mix_text);
  8185. static const struct soc_enum rx_int3_1_mix_inp1_chain_enum =
  8186. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 4, 13,
  8187. rx_prim_mix_text);
  8188. static const struct soc_enum rx_int3_1_mix_inp2_chain_enum =
  8189. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 4, 13,
  8190. rx_prim_mix_text);
  8191. static const struct soc_enum rx_int4_1_mix_inp0_chain_enum =
  8192. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 0, 13,
  8193. rx_prim_mix_text);
  8194. static const struct soc_enum rx_int4_1_mix_inp1_chain_enum =
  8195. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 4, 13,
  8196. rx_prim_mix_text);
  8197. static const struct soc_enum rx_int4_1_mix_inp2_chain_enum =
  8198. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 4, 13,
  8199. rx_prim_mix_text);
  8200. static const struct soc_enum rx_int5_1_mix_inp0_chain_enum =
  8201. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 0, 13,
  8202. rx_prim_mix_text);
  8203. static const struct soc_enum rx_int5_1_mix_inp1_chain_enum =
  8204. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 4, 13,
  8205. rx_prim_mix_text);
  8206. static const struct soc_enum rx_int5_1_mix_inp2_chain_enum =
  8207. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 4, 13,
  8208. rx_prim_mix_text);
  8209. static const struct soc_enum rx_int6_1_mix_inp0_chain_enum =
  8210. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 0, 13,
  8211. rx_prim_mix_text);
  8212. static const struct soc_enum rx_int6_1_mix_inp1_chain_enum =
  8213. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 4, 13,
  8214. rx_prim_mix_text);
  8215. static const struct soc_enum rx_int6_1_mix_inp2_chain_enum =
  8216. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 4, 13,
  8217. rx_prim_mix_text);
  8218. static const struct soc_enum rx_int7_1_mix_inp0_chain_enum =
  8219. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 0, 13,
  8220. rx_prim_mix_text);
  8221. static const struct soc_enum rx_int7_1_mix_inp1_chain_enum =
  8222. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 4, 13,
  8223. rx_prim_mix_text);
  8224. static const struct soc_enum rx_int7_1_mix_inp2_chain_enum =
  8225. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 4, 13,
  8226. rx_prim_mix_text);
  8227. static const struct soc_enum rx_int8_1_mix_inp0_chain_enum =
  8228. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 0, 13,
  8229. rx_prim_mix_text);
  8230. static const struct soc_enum rx_int8_1_mix_inp1_chain_enum =
  8231. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 4, 13,
  8232. rx_prim_mix_text);
  8233. static const struct soc_enum rx_int8_1_mix_inp2_chain_enum =
  8234. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 4, 13,
  8235. rx_prim_mix_text);
  8236. static const struct soc_enum rx_int0_sidetone_mix_chain_enum =
  8237. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0, 4,
  8238. rx_sidetone_mix_text);
  8239. static const struct soc_enum rx_int1_sidetone_mix_chain_enum =
  8240. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2, 4,
  8241. rx_sidetone_mix_text);
  8242. static const struct soc_enum rx_int2_sidetone_mix_chain_enum =
  8243. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4, 4,
  8244. rx_sidetone_mix_text);
  8245. static const struct soc_enum rx_int3_sidetone_mix_chain_enum =
  8246. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6, 4,
  8247. rx_sidetone_mix_text);
  8248. static const struct soc_enum rx_int4_sidetone_mix_chain_enum =
  8249. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 0, 4,
  8250. rx_sidetone_mix_text);
  8251. static const struct soc_enum rx_int7_sidetone_mix_chain_enum =
  8252. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 2, 4,
  8253. rx_sidetone_mix_text);
  8254. static const struct soc_enum tx_adc_mux0_chain_enum =
  8255. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 0, 4,
  8256. adc_mux_text);
  8257. static const struct soc_enum tx_adc_mux1_chain_enum =
  8258. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 0, 4,
  8259. adc_mux_text);
  8260. static const struct soc_enum tx_adc_mux2_chain_enum =
  8261. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 0, 4,
  8262. adc_mux_text);
  8263. static const struct soc_enum tx_adc_mux3_chain_enum =
  8264. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 0, 4,
  8265. adc_mux_text);
  8266. static const struct soc_enum tx_adc_mux4_chain_enum =
  8267. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 6, 4,
  8268. adc_mux_text);
  8269. static const struct soc_enum tx_adc_mux5_chain_enum =
  8270. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 6, 4,
  8271. adc_mux_text);
  8272. static const struct soc_enum tx_adc_mux6_chain_enum =
  8273. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 6, 4,
  8274. adc_mux_text);
  8275. static const struct soc_enum tx_adc_mux7_chain_enum =
  8276. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 6, 4,
  8277. adc_mux_text);
  8278. static const struct soc_enum tx_adc_mux8_chain_enum =
  8279. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 6, 4,
  8280. adc_mux_text);
  8281. static const struct soc_enum tx_adc_mux10_chain_enum =
  8282. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 6, 4,
  8283. adc_mux_text);
  8284. static const struct soc_enum tx_adc_mux11_chain_enum =
  8285. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 6, 4,
  8286. adc_mux_text);
  8287. static const struct soc_enum tx_adc_mux12_chain_enum =
  8288. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 6, 4,
  8289. adc_mux_text);
  8290. static const struct soc_enum tx_adc_mux13_chain_enum =
  8291. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 6, 4,
  8292. adc_mux_text);
  8293. static const struct soc_enum tx_dmic_mux0_enum =
  8294. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 3, 11,
  8295. dmic_mux_text);
  8296. static const struct soc_enum tx_dmic_mux1_enum =
  8297. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 3, 11,
  8298. dmic_mux_text);
  8299. static const struct soc_enum tx_dmic_mux2_enum =
  8300. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 3, 11,
  8301. dmic_mux_text);
  8302. static const struct soc_enum tx_dmic_mux3_enum =
  8303. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 3, 11,
  8304. dmic_mux_text);
  8305. static const struct soc_enum tx_dmic_mux4_enum =
  8306. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 3, 7,
  8307. dmic_mux_alt_text);
  8308. static const struct soc_enum tx_dmic_mux5_enum =
  8309. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 3, 7,
  8310. dmic_mux_alt_text);
  8311. static const struct soc_enum tx_dmic_mux6_enum =
  8312. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 3, 7,
  8313. dmic_mux_alt_text);
  8314. static const struct soc_enum tx_dmic_mux7_enum =
  8315. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 3, 7,
  8316. dmic_mux_alt_text);
  8317. static const struct soc_enum tx_dmic_mux8_enum =
  8318. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 3, 7,
  8319. dmic_mux_alt_text);
  8320. static const struct soc_enum tx_dmic_mux10_enum =
  8321. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 3, 7,
  8322. dmic_mux_alt_text);
  8323. static const struct soc_enum tx_dmic_mux11_enum =
  8324. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 3, 7,
  8325. dmic_mux_alt_text);
  8326. static const struct soc_enum tx_dmic_mux12_enum =
  8327. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 3, 7,
  8328. dmic_mux_alt_text);
  8329. static const struct soc_enum tx_dmic_mux13_enum =
  8330. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 3, 7,
  8331. dmic_mux_alt_text);
  8332. static const struct soc_enum tx_amic_mux0_enum =
  8333. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 0, 7,
  8334. amic_mux_text);
  8335. static const struct soc_enum tx_amic_mux1_enum =
  8336. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 0, 7,
  8337. amic_mux_text);
  8338. static const struct soc_enum tx_amic_mux2_enum =
  8339. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 0, 7,
  8340. amic_mux_text);
  8341. static const struct soc_enum tx_amic_mux3_enum =
  8342. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 0, 7,
  8343. amic_mux_text);
  8344. static const struct soc_enum tx_amic_mux4_enum =
  8345. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 0, 7,
  8346. amic_mux_text);
  8347. static const struct soc_enum tx_amic_mux5_enum =
  8348. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 0, 7,
  8349. amic_mux_text);
  8350. static const struct soc_enum tx_amic_mux6_enum =
  8351. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 0, 7,
  8352. amic_mux_text);
  8353. static const struct soc_enum tx_amic_mux7_enum =
  8354. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 0, 7,
  8355. amic_mux_text);
  8356. static const struct soc_enum tx_amic_mux8_enum =
  8357. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 0, 7,
  8358. amic_mux_text);
  8359. static const struct soc_enum tx_amic_mux10_enum =
  8360. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 0, 7,
  8361. amic_mux_text);
  8362. static const struct soc_enum tx_amic_mux11_enum =
  8363. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 0, 7,
  8364. amic_mux_text);
  8365. static const struct soc_enum tx_amic_mux12_enum =
  8366. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 0, 7,
  8367. amic_mux_text);
  8368. static const struct soc_enum tx_amic_mux13_enum =
  8369. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 0, 7,
  8370. amic_mux_text);
  8371. static const struct soc_enum sb_tx0_mux_enum =
  8372. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 0, 4,
  8373. sb_tx0_mux_text);
  8374. static const struct soc_enum sb_tx1_mux_enum =
  8375. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 2, 4,
  8376. sb_tx1_mux_text);
  8377. static const struct soc_enum sb_tx2_mux_enum =
  8378. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 4, 4,
  8379. sb_tx2_mux_text);
  8380. static const struct soc_enum sb_tx3_mux_enum =
  8381. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 6, 4,
  8382. sb_tx3_mux_text);
  8383. static const struct soc_enum sb_tx4_mux_enum =
  8384. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 0, 4,
  8385. sb_tx4_mux_text);
  8386. static const struct soc_enum sb_tx5_mux_enum =
  8387. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 2, 4,
  8388. sb_tx5_mux_text);
  8389. static const struct soc_enum sb_tx6_mux_enum =
  8390. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 4, 4,
  8391. sb_tx6_mux_text);
  8392. static const struct soc_enum sb_tx7_mux_enum =
  8393. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 6, 4,
  8394. sb_tx7_mux_text);
  8395. static const struct soc_enum sb_tx8_mux_enum =
  8396. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 0, 4,
  8397. sb_tx8_mux_text);
  8398. static const struct soc_enum sb_tx9_mux_enum =
  8399. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 2, 3,
  8400. sb_tx9_mux_text);
  8401. static const struct soc_enum sb_tx10_mux_enum =
  8402. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 4, 3,
  8403. sb_tx10_mux_text);
  8404. static const struct soc_enum sb_tx11_mux_enum =
  8405. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX11_INP_CFG, 0, 4,
  8406. sb_tx11_mux_text);
  8407. static const struct soc_enum sb_tx11_inp1_mux_enum =
  8408. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 0, 10,
  8409. sb_tx11_inp1_mux_text);
  8410. static const struct soc_enum sb_tx13_mux_enum =
  8411. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 4, 3,
  8412. sb_tx13_mux_text);
  8413. static const struct soc_enum tx13_inp_mux_enum =
  8414. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG, 0, 3,
  8415. tx13_inp_mux_text);
  8416. static const struct soc_enum rx_mix_tx0_mux_enum =
  8417. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 0, 14,
  8418. rx_echo_mux_text);
  8419. static const struct soc_enum rx_mix_tx1_mux_enum =
  8420. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 4, 14,
  8421. rx_echo_mux_text);
  8422. static const struct soc_enum rx_mix_tx2_mux_enum =
  8423. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 0, 14,
  8424. rx_echo_mux_text);
  8425. static const struct soc_enum rx_mix_tx3_mux_enum =
  8426. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 4, 14,
  8427. rx_echo_mux_text);
  8428. static const struct soc_enum rx_mix_tx4_mux_enum =
  8429. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 0, 14,
  8430. rx_echo_mux_text);
  8431. static const struct soc_enum rx_mix_tx5_mux_enum =
  8432. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 4, 14,
  8433. rx_echo_mux_text);
  8434. static const struct soc_enum rx_mix_tx6_mux_enum =
  8435. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 0, 14,
  8436. rx_echo_mux_text);
  8437. static const struct soc_enum rx_mix_tx7_mux_enum =
  8438. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 4, 14,
  8439. rx_echo_mux_text);
  8440. static const struct soc_enum rx_mix_tx8_mux_enum =
  8441. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG4, 0, 14,
  8442. rx_echo_mux_text);
  8443. static const struct soc_enum iir0_inp0_mux_enum =
  8444. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0, 0, 18,
  8445. iir_inp_mux_text);
  8446. static const struct soc_enum iir0_inp1_mux_enum =
  8447. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1, 0, 18,
  8448. iir_inp_mux_text);
  8449. static const struct soc_enum iir0_inp2_mux_enum =
  8450. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2, 0, 18,
  8451. iir_inp_mux_text);
  8452. static const struct soc_enum iir0_inp3_mux_enum =
  8453. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3, 0, 18,
  8454. iir_inp_mux_text);
  8455. static const struct soc_enum iir1_inp0_mux_enum =
  8456. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0, 0, 18,
  8457. iir_inp_mux_text);
  8458. static const struct soc_enum iir1_inp1_mux_enum =
  8459. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1, 0, 18,
  8460. iir_inp_mux_text);
  8461. static const struct soc_enum iir1_inp2_mux_enum =
  8462. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2, 0, 18,
  8463. iir_inp_mux_text);
  8464. static const struct soc_enum iir1_inp3_mux_enum =
  8465. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3, 0, 18,
  8466. iir_inp_mux_text);
  8467. static const struct soc_enum rx_int0_dem_inp_mux_enum =
  8468. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_SEC0, 0,
  8469. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8470. rx_int_dem_inp_mux_text);
  8471. static const struct soc_enum rx_int1_dem_inp_mux_enum =
  8472. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_SEC0, 0,
  8473. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8474. rx_int_dem_inp_mux_text);
  8475. static const struct soc_enum rx_int2_dem_inp_mux_enum =
  8476. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_SEC0, 0,
  8477. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8478. rx_int_dem_inp_mux_text);
  8479. static const struct soc_enum rx_int0_interp_mux_enum =
  8480. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CTL, 5, 2,
  8481. rx_int0_interp_mux_text);
  8482. static const struct soc_enum rx_int1_interp_mux_enum =
  8483. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CTL, 5, 2,
  8484. rx_int1_interp_mux_text);
  8485. static const struct soc_enum rx_int2_interp_mux_enum =
  8486. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CTL, 5, 2,
  8487. rx_int2_interp_mux_text);
  8488. static const struct soc_enum rx_int3_interp_mux_enum =
  8489. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CTL, 5, 2,
  8490. rx_int3_interp_mux_text);
  8491. static const struct soc_enum rx_int4_interp_mux_enum =
  8492. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CTL, 5, 2,
  8493. rx_int4_interp_mux_text);
  8494. static const struct soc_enum rx_int5_interp_mux_enum =
  8495. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CTL, 5, 2,
  8496. rx_int5_interp_mux_text);
  8497. static const struct soc_enum rx_int6_interp_mux_enum =
  8498. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CTL, 5, 2,
  8499. rx_int6_interp_mux_text);
  8500. static const struct soc_enum rx_int7_interp_mux_enum =
  8501. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CTL, 5, 2,
  8502. rx_int7_interp_mux_text);
  8503. static const struct soc_enum rx_int8_interp_mux_enum =
  8504. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CTL, 5, 2,
  8505. rx_int8_interp_mux_text);
  8506. static const struct soc_enum mad_sel_enum =
  8507. SOC_ENUM_SINGLE(WCD9335_CPE_SS_CFG, 0, 2, mad_sel_text);
  8508. static const struct soc_enum anc0_fb_mux_enum =
  8509. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 0, 5,
  8510. anc0_fb_mux_text);
  8511. static const struct soc_enum anc1_fb_mux_enum =
  8512. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 3, 3,
  8513. anc1_fb_mux_text);
  8514. static const struct snd_kcontrol_new rx_int0_dem_inp_mux =
  8515. SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum,
  8516. snd_soc_dapm_get_enum_double,
  8517. tasha_int_dem_inp_mux_put);
  8518. static const struct snd_kcontrol_new rx_int1_dem_inp_mux =
  8519. SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum,
  8520. snd_soc_dapm_get_enum_double,
  8521. tasha_int_dem_inp_mux_put);
  8522. static const struct snd_kcontrol_new rx_int2_dem_inp_mux =
  8523. SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum,
  8524. snd_soc_dapm_get_enum_double,
  8525. tasha_int_dem_inp_mux_put);
  8526. static const struct snd_kcontrol_new spl_src0_mux =
  8527. SOC_DAPM_ENUM("SPL SRC0 MUX Mux", spl_src0_mux_chain_enum);
  8528. static const struct snd_kcontrol_new spl_src1_mux =
  8529. SOC_DAPM_ENUM("SPL SRC1 MUX Mux", spl_src1_mux_chain_enum);
  8530. static const struct snd_kcontrol_new spl_src2_mux =
  8531. SOC_DAPM_ENUM("SPL SRC2 MUX Mux", spl_src2_mux_chain_enum);
  8532. static const struct snd_kcontrol_new spl_src3_mux =
  8533. SOC_DAPM_ENUM("SPL SRC3 MUX Mux", spl_src3_mux_chain_enum);
  8534. static const struct snd_kcontrol_new rx_int0_2_mux =
  8535. SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum);
  8536. static const struct snd_kcontrol_new rx_int1_2_mux =
  8537. SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum);
  8538. static const struct snd_kcontrol_new rx_int2_2_mux =
  8539. SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum);
  8540. static const struct snd_kcontrol_new rx_int3_2_mux =
  8541. SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum);
  8542. static const struct snd_kcontrol_new rx_int4_2_mux =
  8543. SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum);
  8544. static const struct snd_kcontrol_new rx_int5_2_mux =
  8545. SOC_DAPM_ENUM("RX INT5_2 MUX Mux", rx_int5_2_mux_chain_enum);
  8546. static const struct snd_kcontrol_new rx_int6_2_mux =
  8547. SOC_DAPM_ENUM("RX INT6_2 MUX Mux", rx_int6_2_mux_chain_enum);
  8548. static const struct snd_kcontrol_new rx_int7_2_mux =
  8549. SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum);
  8550. static const struct snd_kcontrol_new rx_int8_2_mux =
  8551. SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum);
  8552. static const struct snd_kcontrol_new int1_1_native_mux =
  8553. SOC_DAPM_ENUM("RX INT1_1 NATIVE MUX Mux", int1_1_native_enum);
  8554. static const struct snd_kcontrol_new int2_1_native_mux =
  8555. SOC_DAPM_ENUM("RX INT2_1 NATIVE MUX Mux", int2_1_native_enum);
  8556. static const struct snd_kcontrol_new int3_1_native_mux =
  8557. SOC_DAPM_ENUM("RX INT3_1 NATIVE MUX Mux", int3_1_native_enum);
  8558. static const struct snd_kcontrol_new int4_1_native_mux =
  8559. SOC_DAPM_ENUM("RX INT4_1 NATIVE MUX Mux", int4_1_native_enum);
  8560. static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux =
  8561. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum);
  8562. static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux =
  8563. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum);
  8564. static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux =
  8565. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum);
  8566. static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux =
  8567. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum);
  8568. static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux =
  8569. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum);
  8570. static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux =
  8571. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum);
  8572. static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux =
  8573. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum);
  8574. static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux =
  8575. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum);
  8576. static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux =
  8577. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum);
  8578. static const struct snd_kcontrol_new rx_int3_1_mix_inp0_mux =
  8579. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum);
  8580. static const struct snd_kcontrol_new rx_int3_1_mix_inp1_mux =
  8581. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum);
  8582. static const struct snd_kcontrol_new rx_int3_1_mix_inp2_mux =
  8583. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum);
  8584. static const struct snd_kcontrol_new rx_int4_1_mix_inp0_mux =
  8585. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum);
  8586. static const struct snd_kcontrol_new rx_int4_1_mix_inp1_mux =
  8587. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum);
  8588. static const struct snd_kcontrol_new rx_int4_1_mix_inp2_mux =
  8589. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum);
  8590. static const struct snd_kcontrol_new rx_int5_1_mix_inp0_mux =
  8591. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP0 Mux", rx_int5_1_mix_inp0_chain_enum);
  8592. static const struct snd_kcontrol_new rx_int5_1_mix_inp1_mux =
  8593. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP1 Mux", rx_int5_1_mix_inp1_chain_enum);
  8594. static const struct snd_kcontrol_new rx_int5_1_mix_inp2_mux =
  8595. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP2 Mux", rx_int5_1_mix_inp2_chain_enum);
  8596. static const struct snd_kcontrol_new rx_int6_1_mix_inp0_mux =
  8597. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP0 Mux", rx_int6_1_mix_inp0_chain_enum);
  8598. static const struct snd_kcontrol_new rx_int6_1_mix_inp1_mux =
  8599. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP1 Mux", rx_int6_1_mix_inp1_chain_enum);
  8600. static const struct snd_kcontrol_new rx_int6_1_mix_inp2_mux =
  8601. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP2 Mux", rx_int6_1_mix_inp2_chain_enum);
  8602. static const struct snd_kcontrol_new rx_int7_1_mix_inp0_mux =
  8603. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum);
  8604. static const struct snd_kcontrol_new rx_int7_1_mix_inp1_mux =
  8605. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum);
  8606. static const struct snd_kcontrol_new rx_int7_1_mix_inp2_mux =
  8607. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum);
  8608. static const struct snd_kcontrol_new rx_int8_1_mix_inp0_mux =
  8609. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum);
  8610. static const struct snd_kcontrol_new rx_int8_1_mix_inp1_mux =
  8611. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum);
  8612. static const struct snd_kcontrol_new rx_int8_1_mix_inp2_mux =
  8613. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum);
  8614. static const struct snd_kcontrol_new rx_int0_mix2_inp_mux =
  8615. SOC_DAPM_ENUM("RX INT0 MIX2 INP Mux", rx_int0_sidetone_mix_chain_enum);
  8616. static const struct snd_kcontrol_new rx_int1_mix2_inp_mux =
  8617. SOC_DAPM_ENUM("RX INT1 MIX2 INP Mux", rx_int1_sidetone_mix_chain_enum);
  8618. static const struct snd_kcontrol_new rx_int2_mix2_inp_mux =
  8619. SOC_DAPM_ENUM("RX INT2 MIX2 INP Mux", rx_int2_sidetone_mix_chain_enum);
  8620. static const struct snd_kcontrol_new rx_int3_mix2_inp_mux =
  8621. SOC_DAPM_ENUM("RX INT3 MIX2 INP Mux", rx_int3_sidetone_mix_chain_enum);
  8622. static const struct snd_kcontrol_new rx_int4_mix2_inp_mux =
  8623. SOC_DAPM_ENUM("RX INT4 MIX2 INP Mux", rx_int4_sidetone_mix_chain_enum);
  8624. static const struct snd_kcontrol_new rx_int7_mix2_inp_mux =
  8625. SOC_DAPM_ENUM("RX INT7 MIX2 INP Mux", rx_int7_sidetone_mix_chain_enum);
  8626. static const struct snd_kcontrol_new tx_adc_mux0 =
  8627. SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_chain_enum,
  8628. snd_soc_dapm_get_enum_double,
  8629. tasha_put_dec_enum);
  8630. static const struct snd_kcontrol_new tx_adc_mux1 =
  8631. SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_chain_enum,
  8632. snd_soc_dapm_get_enum_double,
  8633. tasha_put_dec_enum);
  8634. static const struct snd_kcontrol_new tx_adc_mux2 =
  8635. SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_chain_enum,
  8636. snd_soc_dapm_get_enum_double,
  8637. tasha_put_dec_enum);
  8638. static const struct snd_kcontrol_new tx_adc_mux3 =
  8639. SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_chain_enum,
  8640. snd_soc_dapm_get_enum_double,
  8641. tasha_put_dec_enum);
  8642. static const struct snd_kcontrol_new tx_adc_mux4 =
  8643. SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_chain_enum,
  8644. snd_soc_dapm_get_enum_double,
  8645. tasha_put_dec_enum);
  8646. static const struct snd_kcontrol_new tx_adc_mux5 =
  8647. SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_chain_enum,
  8648. snd_soc_dapm_get_enum_double,
  8649. tasha_put_dec_enum);
  8650. static const struct snd_kcontrol_new tx_adc_mux6 =
  8651. SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_chain_enum,
  8652. snd_soc_dapm_get_enum_double,
  8653. tasha_put_dec_enum);
  8654. static const struct snd_kcontrol_new tx_adc_mux7 =
  8655. SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_chain_enum,
  8656. snd_soc_dapm_get_enum_double,
  8657. tasha_put_dec_enum);
  8658. static const struct snd_kcontrol_new tx_adc_mux8 =
  8659. SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_chain_enum,
  8660. snd_soc_dapm_get_enum_double,
  8661. tasha_put_dec_enum);
  8662. static const struct snd_kcontrol_new tx_adc_mux10 =
  8663. SOC_DAPM_ENUM("ADC MUX10 Mux", tx_adc_mux10_chain_enum);
  8664. static const struct snd_kcontrol_new tx_adc_mux11 =
  8665. SOC_DAPM_ENUM("ADC MUX11 Mux", tx_adc_mux11_chain_enum);
  8666. static const struct snd_kcontrol_new tx_adc_mux12 =
  8667. SOC_DAPM_ENUM("ADC MUX12 Mux", tx_adc_mux12_chain_enum);
  8668. static const struct snd_kcontrol_new tx_adc_mux13 =
  8669. SOC_DAPM_ENUM("ADC MUX13 Mux", tx_adc_mux13_chain_enum);
  8670. static const struct snd_kcontrol_new tx_dmic_mux0 =
  8671. SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum);
  8672. static const struct snd_kcontrol_new tx_dmic_mux1 =
  8673. SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum);
  8674. static const struct snd_kcontrol_new tx_dmic_mux2 =
  8675. SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum);
  8676. static const struct snd_kcontrol_new tx_dmic_mux3 =
  8677. SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum);
  8678. static const struct snd_kcontrol_new tx_dmic_mux4 =
  8679. SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum);
  8680. static const struct snd_kcontrol_new tx_dmic_mux5 =
  8681. SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum);
  8682. static const struct snd_kcontrol_new tx_dmic_mux6 =
  8683. SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum);
  8684. static const struct snd_kcontrol_new tx_dmic_mux7 =
  8685. SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum);
  8686. static const struct snd_kcontrol_new tx_dmic_mux8 =
  8687. SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum);
  8688. static const struct snd_kcontrol_new tx_dmic_mux10 =
  8689. SOC_DAPM_ENUM("DMIC MUX10 Mux", tx_dmic_mux10_enum);
  8690. static const struct snd_kcontrol_new tx_dmic_mux11 =
  8691. SOC_DAPM_ENUM("DMIC MUX11 Mux", tx_dmic_mux11_enum);
  8692. static const struct snd_kcontrol_new tx_dmic_mux12 =
  8693. SOC_DAPM_ENUM("DMIC MUX12 Mux", tx_dmic_mux12_enum);
  8694. static const struct snd_kcontrol_new tx_dmic_mux13 =
  8695. SOC_DAPM_ENUM("DMIC MUX13 Mux", tx_dmic_mux13_enum);
  8696. static const struct snd_kcontrol_new tx_amic_mux0 =
  8697. SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum);
  8698. static const struct snd_kcontrol_new tx_amic_mux1 =
  8699. SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum);
  8700. static const struct snd_kcontrol_new tx_amic_mux2 =
  8701. SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum);
  8702. static const struct snd_kcontrol_new tx_amic_mux3 =
  8703. SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum);
  8704. static const struct snd_kcontrol_new tx_amic_mux4 =
  8705. SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum);
  8706. static const struct snd_kcontrol_new tx_amic_mux5 =
  8707. SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum);
  8708. static const struct snd_kcontrol_new tx_amic_mux6 =
  8709. SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum);
  8710. static const struct snd_kcontrol_new tx_amic_mux7 =
  8711. SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum);
  8712. static const struct snd_kcontrol_new tx_amic_mux8 =
  8713. SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum);
  8714. static const struct snd_kcontrol_new tx_amic_mux10 =
  8715. SOC_DAPM_ENUM("AMIC MUX10 Mux", tx_amic_mux10_enum);
  8716. static const struct snd_kcontrol_new tx_amic_mux11 =
  8717. SOC_DAPM_ENUM("AMIC MUX11 Mux", tx_amic_mux11_enum);
  8718. static const struct snd_kcontrol_new tx_amic_mux12 =
  8719. SOC_DAPM_ENUM("AMIC MUX12 Mux", tx_amic_mux12_enum);
  8720. static const struct snd_kcontrol_new tx_amic_mux13 =
  8721. SOC_DAPM_ENUM("AMIC MUX13 Mux", tx_amic_mux13_enum);
  8722. static const struct snd_kcontrol_new sb_tx0_mux =
  8723. SOC_DAPM_ENUM("SLIM TX0 MUX Mux", sb_tx0_mux_enum);
  8724. static const struct snd_kcontrol_new sb_tx1_mux =
  8725. SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum);
  8726. static const struct snd_kcontrol_new sb_tx2_mux =
  8727. SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum);
  8728. static const struct snd_kcontrol_new sb_tx3_mux =
  8729. SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum);
  8730. static const struct snd_kcontrol_new sb_tx4_mux =
  8731. SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum);
  8732. static const struct snd_kcontrol_new sb_tx5_mux =
  8733. SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum);
  8734. static const struct snd_kcontrol_new sb_tx6_mux =
  8735. SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum);
  8736. static const struct snd_kcontrol_new sb_tx7_mux =
  8737. SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum);
  8738. static const struct snd_kcontrol_new sb_tx8_mux =
  8739. SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum);
  8740. static const struct snd_kcontrol_new sb_tx9_mux =
  8741. SOC_DAPM_ENUM("SLIM TX9 MUX Mux", sb_tx9_mux_enum);
  8742. static const struct snd_kcontrol_new sb_tx10_mux =
  8743. SOC_DAPM_ENUM("SLIM TX10 MUX Mux", sb_tx10_mux_enum);
  8744. static const struct snd_kcontrol_new sb_tx11_mux =
  8745. SOC_DAPM_ENUM("SLIM TX11 MUX Mux", sb_tx11_mux_enum);
  8746. static const struct snd_kcontrol_new sb_tx11_inp1_mux =
  8747. SOC_DAPM_ENUM("SLIM TX11 INP1 MUX Mux", sb_tx11_inp1_mux_enum);
  8748. static const struct snd_kcontrol_new sb_tx13_mux =
  8749. SOC_DAPM_ENUM("SLIM TX13 MUX Mux", sb_tx13_mux_enum);
  8750. static const struct snd_kcontrol_new tx13_inp_mux =
  8751. SOC_DAPM_ENUM("TX13 INP MUX Mux", tx13_inp_mux_enum);
  8752. static const struct snd_kcontrol_new rx_mix_tx0_mux =
  8753. SOC_DAPM_ENUM("RX MIX TX0 MUX Mux", rx_mix_tx0_mux_enum);
  8754. static const struct snd_kcontrol_new rx_mix_tx1_mux =
  8755. SOC_DAPM_ENUM("RX MIX TX1 MUX Mux", rx_mix_tx1_mux_enum);
  8756. static const struct snd_kcontrol_new rx_mix_tx2_mux =
  8757. SOC_DAPM_ENUM("RX MIX TX2 MUX Mux", rx_mix_tx2_mux_enum);
  8758. static const struct snd_kcontrol_new rx_mix_tx3_mux =
  8759. SOC_DAPM_ENUM("RX MIX TX3 MUX Mux", rx_mix_tx3_mux_enum);
  8760. static const struct snd_kcontrol_new rx_mix_tx4_mux =
  8761. SOC_DAPM_ENUM("RX MIX TX4 MUX Mux", rx_mix_tx4_mux_enum);
  8762. static const struct snd_kcontrol_new rx_mix_tx5_mux =
  8763. SOC_DAPM_ENUM("RX MIX TX5 MUX Mux", rx_mix_tx5_mux_enum);
  8764. static const struct snd_kcontrol_new rx_mix_tx6_mux =
  8765. SOC_DAPM_ENUM("RX MIX TX6 MUX Mux", rx_mix_tx6_mux_enum);
  8766. static const struct snd_kcontrol_new rx_mix_tx7_mux =
  8767. SOC_DAPM_ENUM("RX MIX TX7 MUX Mux", rx_mix_tx7_mux_enum);
  8768. static const struct snd_kcontrol_new rx_mix_tx8_mux =
  8769. SOC_DAPM_ENUM("RX MIX TX8 MUX Mux", rx_mix_tx8_mux_enum);
  8770. static const struct snd_kcontrol_new iir0_inp0_mux =
  8771. SOC_DAPM_ENUM("IIR0 INP0 Mux", iir0_inp0_mux_enum);
  8772. static const struct snd_kcontrol_new iir0_inp1_mux =
  8773. SOC_DAPM_ENUM("IIR0 INP1 Mux", iir0_inp1_mux_enum);
  8774. static const struct snd_kcontrol_new iir0_inp2_mux =
  8775. SOC_DAPM_ENUM("IIR0 INP2 Mux", iir0_inp2_mux_enum);
  8776. static const struct snd_kcontrol_new iir0_inp3_mux =
  8777. SOC_DAPM_ENUM("IIR0 INP3 Mux", iir0_inp3_mux_enum);
  8778. static const struct snd_kcontrol_new iir1_inp0_mux =
  8779. SOC_DAPM_ENUM("IIR1 INP0 Mux", iir1_inp0_mux_enum);
  8780. static const struct snd_kcontrol_new iir1_inp1_mux =
  8781. SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum);
  8782. static const struct snd_kcontrol_new iir1_inp2_mux =
  8783. SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum);
  8784. static const struct snd_kcontrol_new iir1_inp3_mux =
  8785. SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum);
  8786. static const struct snd_kcontrol_new rx_int0_interp_mux =
  8787. SOC_DAPM_ENUM("RX INT0 INTERP Mux", rx_int0_interp_mux_enum);
  8788. static const struct snd_kcontrol_new rx_int1_interp_mux =
  8789. SOC_DAPM_ENUM("RX INT1 INTERP Mux", rx_int1_interp_mux_enum);
  8790. static const struct snd_kcontrol_new rx_int2_interp_mux =
  8791. SOC_DAPM_ENUM("RX INT2 INTERP Mux", rx_int2_interp_mux_enum);
  8792. static const struct snd_kcontrol_new rx_int3_interp_mux =
  8793. SOC_DAPM_ENUM("RX INT3 INTERP Mux", rx_int3_interp_mux_enum);
  8794. static const struct snd_kcontrol_new rx_int4_interp_mux =
  8795. SOC_DAPM_ENUM("RX INT4 INTERP Mux", rx_int4_interp_mux_enum);
  8796. static const struct snd_kcontrol_new rx_int5_interp_mux =
  8797. SOC_DAPM_ENUM("RX INT5 INTERP Mux", rx_int5_interp_mux_enum);
  8798. static const struct snd_kcontrol_new rx_int6_interp_mux =
  8799. SOC_DAPM_ENUM("RX INT6 INTERP Mux", rx_int6_interp_mux_enum);
  8800. static const struct snd_kcontrol_new rx_int7_interp_mux =
  8801. SOC_DAPM_ENUM("RX INT7 INTERP Mux", rx_int7_interp_mux_enum);
  8802. static const struct snd_kcontrol_new rx_int8_interp_mux =
  8803. SOC_DAPM_ENUM("RX INT8 INTERP Mux", rx_int8_interp_mux_enum);
  8804. static const struct snd_kcontrol_new mad_sel_mux =
  8805. SOC_DAPM_ENUM("MAD_SEL MUX Mux", mad_sel_enum);
  8806. static const struct snd_kcontrol_new aif4_mad_switch =
  8807. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 5, 1, 0);
  8808. static const struct snd_kcontrol_new mad_brdcst_switch =
  8809. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 6, 1, 0);
  8810. static const struct snd_kcontrol_new aif4_switch_mixer_controls =
  8811. SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
  8812. 0, 1, 0, tasha_codec_aif4_mixer_switch_get,
  8813. tasha_codec_aif4_mixer_switch_put);
  8814. static const struct snd_kcontrol_new anc_hphl_switch =
  8815. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8816. static const struct snd_kcontrol_new anc_hphr_switch =
  8817. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8818. static const struct snd_kcontrol_new anc_ear_switch =
  8819. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8820. static const struct snd_kcontrol_new anc_ear_spkr_switch =
  8821. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8822. static const struct snd_kcontrol_new anc_lineout1_switch =
  8823. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8824. static const struct snd_kcontrol_new anc_lineout2_switch =
  8825. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8826. static const struct snd_kcontrol_new anc_spkr_pa_switch =
  8827. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8828. static const struct snd_kcontrol_new adc_us_mux0_switch =
  8829. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8830. static const struct snd_kcontrol_new adc_us_mux1_switch =
  8831. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8832. static const struct snd_kcontrol_new adc_us_mux2_switch =
  8833. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8834. static const struct snd_kcontrol_new adc_us_mux3_switch =
  8835. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8836. static const struct snd_kcontrol_new adc_us_mux4_switch =
  8837. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8838. static const struct snd_kcontrol_new adc_us_mux5_switch =
  8839. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8840. static const struct snd_kcontrol_new adc_us_mux6_switch =
  8841. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8842. static const struct snd_kcontrol_new adc_us_mux7_switch =
  8843. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8844. static const struct snd_kcontrol_new adc_us_mux8_switch =
  8845. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8846. static const struct snd_kcontrol_new anc0_fb_mux =
  8847. SOC_DAPM_ENUM("ANC0 FB MUX Mux", anc0_fb_mux_enum);
  8848. static const struct snd_kcontrol_new anc1_fb_mux =
  8849. SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum);
  8850. static int tasha_codec_ec_buf_mux_enable(struct snd_soc_dapm_widget *w,
  8851. struct snd_kcontrol *kcontrol,
  8852. int event)
  8853. {
  8854. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  8855. dev_dbg(codec->dev, "%s: event = %d name = %s\n",
  8856. __func__, event, w->name);
  8857. switch (event) {
  8858. case SND_SOC_DAPM_POST_PMU:
  8859. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x3B);
  8860. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x08);
  8861. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8862. 0x08, 0x08);
  8863. break;
  8864. case SND_SOC_DAPM_POST_PMD:
  8865. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8866. 0x08, 0x00);
  8867. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x00);
  8868. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x00);
  8869. break;
  8870. }
  8871. return 0;
  8872. };
  8873. static const char * const ec_buf_mux_text[] = {
  8874. "ZERO", "RXMIXEC", "SB_RX0", "SB_RX1", "SB_RX2", "SB_RX3",
  8875. "I2S_RX_SD0_L", "I2S_RX_SD0_R", "I2S_RX_SD1_L", "I2S_RX_SD1_R",
  8876. "DEC1"
  8877. };
  8878. static SOC_ENUM_SINGLE_DECL(ec_buf_mux_enum, WCD9335_CPE_SS_US_EC_MUX_CFG,
  8879. 0, ec_buf_mux_text);
  8880. static const struct snd_kcontrol_new ec_buf_mux =
  8881. SOC_DAPM_ENUM("EC BUF Mux", ec_buf_mux_enum);
  8882. static const struct snd_soc_dapm_widget tasha_dapm_widgets[] = {
  8883. SND_SOC_DAPM_OUTPUT("EAR"),
  8884. SND_SOC_DAPM_OUTPUT("ANC EAR"),
  8885. SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM,
  8886. AIF1_PB, 0, tasha_codec_enable_slimrx,
  8887. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8888. SND_SOC_DAPM_POST_PMD),
  8889. SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM,
  8890. AIF2_PB, 0, tasha_codec_enable_slimrx,
  8891. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8892. SND_SOC_DAPM_POST_PMD),
  8893. SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM,
  8894. AIF3_PB, 0, tasha_codec_enable_slimrx,
  8895. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8896. SND_SOC_DAPM_POST_PMD),
  8897. SND_SOC_DAPM_AIF_IN_E("AIF4 PB", "AIF4 Playback", 0, SND_SOC_NOPM,
  8898. AIF4_PB, 0, tasha_codec_enable_slimrx,
  8899. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8900. SND_SOC_DAPM_POST_PMD),
  8901. SND_SOC_DAPM_AIF_IN_E("AIF MIX1 PB", "AIF Mix Playback", 0,
  8902. SND_SOC_NOPM, AIF_MIX1_PB, 0,
  8903. tasha_codec_enable_slimrx,
  8904. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8905. SND_SOC_DAPM_POST_PMD),
  8906. SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM, TASHA_RX0, 0,
  8907. &slim_rx_mux[TASHA_RX0]),
  8908. SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TASHA_RX1, 0,
  8909. &slim_rx_mux[TASHA_RX1]),
  8910. SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TASHA_RX2, 0,
  8911. &slim_rx_mux[TASHA_RX2]),
  8912. SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TASHA_RX3, 0,
  8913. &slim_rx_mux[TASHA_RX3]),
  8914. SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TASHA_RX4, 0,
  8915. &slim_rx_mux[TASHA_RX4]),
  8916. SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TASHA_RX5, 0,
  8917. &slim_rx_mux[TASHA_RX5]),
  8918. SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, TASHA_RX6, 0,
  8919. &slim_rx_mux[TASHA_RX6]),
  8920. SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, TASHA_RX7, 0,
  8921. &slim_rx_mux[TASHA_RX7]),
  8922. SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
  8923. SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  8924. SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  8925. SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
  8926. SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
  8927. SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0),
  8928. SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0),
  8929. SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0),
  8930. SND_SOC_DAPM_MUX_E("SPL SRC0 MUX", SND_SOC_NOPM, SPLINE_SRC0, 0,
  8931. &spl_src0_mux, tasha_codec_enable_spline_resampler,
  8932. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8933. SND_SOC_DAPM_MUX_E("SPL SRC1 MUX", SND_SOC_NOPM, SPLINE_SRC1, 0,
  8934. &spl_src1_mux, tasha_codec_enable_spline_resampler,
  8935. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8936. SND_SOC_DAPM_MUX_E("SPL SRC2 MUX", SND_SOC_NOPM, SPLINE_SRC2, 0,
  8937. &spl_src2_mux, tasha_codec_enable_spline_resampler,
  8938. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8939. SND_SOC_DAPM_MUX_E("SPL SRC3 MUX", SND_SOC_NOPM, SPLINE_SRC3, 0,
  8940. &spl_src3_mux, tasha_codec_enable_spline_resampler,
  8941. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8942. SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  8943. 5, 0, &rx_int0_2_mux, tasha_codec_enable_mix_path,
  8944. SND_SOC_DAPM_POST_PMU),
  8945. SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  8946. 5, 0, &rx_int1_2_mux, tasha_codec_enable_mix_path,
  8947. SND_SOC_DAPM_POST_PMU),
  8948. SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  8949. 5, 0, &rx_int2_2_mux, tasha_codec_enable_mix_path,
  8950. SND_SOC_DAPM_POST_PMU),
  8951. SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", WCD9335_CDC_RX3_RX_PATH_MIX_CTL,
  8952. 5, 0, &rx_int3_2_mux, tasha_codec_enable_mix_path,
  8953. SND_SOC_DAPM_POST_PMU),
  8954. SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", WCD9335_CDC_RX4_RX_PATH_MIX_CTL,
  8955. 5, 0, &rx_int4_2_mux, tasha_codec_enable_mix_path,
  8956. SND_SOC_DAPM_POST_PMU),
  8957. SND_SOC_DAPM_MUX_E("RX INT5_2 MUX", WCD9335_CDC_RX5_RX_PATH_MIX_CTL,
  8958. 5, 0, &rx_int5_2_mux, tasha_codec_enable_mix_path,
  8959. SND_SOC_DAPM_POST_PMU),
  8960. SND_SOC_DAPM_MUX_E("RX INT6_2 MUX", WCD9335_CDC_RX6_RX_PATH_MIX_CTL,
  8961. 5, 0, &rx_int6_2_mux, tasha_codec_enable_mix_path,
  8962. SND_SOC_DAPM_POST_PMU),
  8963. SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", WCD9335_CDC_RX7_RX_PATH_MIX_CTL,
  8964. 5, 0, &rx_int7_2_mux, tasha_codec_enable_mix_path,
  8965. SND_SOC_DAPM_POST_PMU),
  8966. SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", WCD9335_CDC_RX8_RX_PATH_MIX_CTL,
  8967. 5, 0, &rx_int8_2_mux, tasha_codec_enable_mix_path,
  8968. SND_SOC_DAPM_POST_PMU),
  8969. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8970. &rx_int0_1_mix_inp0_mux),
  8971. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8972. &rx_int0_1_mix_inp1_mux),
  8973. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8974. &rx_int0_1_mix_inp2_mux),
  8975. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8976. &rx_int1_1_mix_inp0_mux),
  8977. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8978. &rx_int1_1_mix_inp1_mux),
  8979. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8980. &rx_int1_1_mix_inp2_mux),
  8981. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8982. &rx_int2_1_mix_inp0_mux),
  8983. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8984. &rx_int2_1_mix_inp1_mux),
  8985. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8986. &rx_int2_1_mix_inp2_mux),
  8987. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8988. &rx_int3_1_mix_inp0_mux),
  8989. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8990. &rx_int3_1_mix_inp1_mux),
  8991. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8992. &rx_int3_1_mix_inp2_mux),
  8993. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8994. &rx_int4_1_mix_inp0_mux),
  8995. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8996. &rx_int4_1_mix_inp1_mux),
  8997. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8998. &rx_int4_1_mix_inp2_mux),
  8999. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9000. &rx_int5_1_mix_inp0_mux),
  9001. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9002. &rx_int5_1_mix_inp1_mux),
  9003. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9004. &rx_int5_1_mix_inp2_mux),
  9005. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9006. &rx_int6_1_mix_inp0_mux),
  9007. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9008. &rx_int6_1_mix_inp1_mux),
  9009. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9010. &rx_int6_1_mix_inp2_mux),
  9011. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9012. &rx_int7_1_mix_inp0_mux, tasha_codec_enable_swr,
  9013. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9014. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9015. &rx_int7_1_mix_inp1_mux, tasha_codec_enable_swr,
  9016. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9017. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9018. &rx_int7_1_mix_inp2_mux, tasha_codec_enable_swr,
  9019. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9020. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9021. &rx_int8_1_mix_inp0_mux, tasha_codec_enable_swr,
  9022. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9023. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9024. &rx_int8_1_mix_inp1_mux, tasha_codec_enable_swr,
  9025. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9026. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9027. &rx_int8_1_mix_inp2_mux, tasha_codec_enable_swr,
  9028. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9029. SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9030. SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9031. SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9032. SND_SOC_DAPM_MIXER("RX INT1 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9033. rx_int1_spline_mix_switch,
  9034. ARRAY_SIZE(rx_int1_spline_mix_switch)),
  9035. SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9036. SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9037. SND_SOC_DAPM_MIXER("RX INT2 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9038. rx_int2_spline_mix_switch,
  9039. ARRAY_SIZE(rx_int2_spline_mix_switch)),
  9040. SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9041. SND_SOC_DAPM_MIXER("RX INT3_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9042. SND_SOC_DAPM_MIXER("RX INT3 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9043. rx_int3_spline_mix_switch,
  9044. ARRAY_SIZE(rx_int3_spline_mix_switch)),
  9045. SND_SOC_DAPM_MIXER("RX INT3 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9046. SND_SOC_DAPM_MIXER("RX INT4_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9047. SND_SOC_DAPM_MIXER("RX INT4 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9048. rx_int4_spline_mix_switch,
  9049. ARRAY_SIZE(rx_int4_spline_mix_switch)),
  9050. SND_SOC_DAPM_MIXER("RX INT4 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9051. SND_SOC_DAPM_MIXER("RX INT5_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9052. SND_SOC_DAPM_MIXER("RX INT5 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9053. rx_int5_spline_mix_switch,
  9054. ARRAY_SIZE(rx_int5_spline_mix_switch)),
  9055. SND_SOC_DAPM_MIXER("RX INT5 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9056. SND_SOC_DAPM_MIXER("RX INT6_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9057. SND_SOC_DAPM_MIXER("RX INT6 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9058. rx_int6_spline_mix_switch,
  9059. ARRAY_SIZE(rx_int6_spline_mix_switch)),
  9060. SND_SOC_DAPM_MIXER("RX INT6 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9061. SND_SOC_DAPM_MIXER("RX INT7_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9062. SND_SOC_DAPM_MIXER("RX INT7 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9063. SND_SOC_DAPM_MIXER("RX INT7 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9064. rx_int7_spline_mix_switch,
  9065. ARRAY_SIZE(rx_int7_spline_mix_switch)),
  9066. SND_SOC_DAPM_MIXER("RX INT8_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9067. SND_SOC_DAPM_MIXER("RX INT8 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9068. SND_SOC_DAPM_MIXER("RX INT8 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9069. rx_int8_spline_mix_switch,
  9070. ARRAY_SIZE(rx_int8_spline_mix_switch)),
  9071. SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9072. SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9073. SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9074. SND_SOC_DAPM_MIXER("RX INT3 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9075. SND_SOC_DAPM_MIXER("RX INT4 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9076. SND_SOC_DAPM_MIXER("RX INT5 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9077. SND_SOC_DAPM_MIXER("RX INT6 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9078. SND_SOC_DAPM_MIXER("RX INT7 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9079. SND_SOC_DAPM_MIXER_E("RX INT7 CHAIN", SND_SOC_NOPM, 0, 0,
  9080. NULL, 0, tasha_codec_spk_boost_event,
  9081. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9082. SND_SOC_DAPM_MIXER_E("RX INT8 CHAIN", SND_SOC_NOPM, 0, 0,
  9083. NULL, 0, tasha_codec_spk_boost_event,
  9084. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9085. SND_SOC_DAPM_MIXER_E("RX INT5 VBAT", SND_SOC_NOPM, 0, 0,
  9086. rx_int5_vbat_mix_switch,
  9087. ARRAY_SIZE(rx_int5_vbat_mix_switch),
  9088. tasha_codec_vbat_enable_event,
  9089. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9090. SND_SOC_DAPM_MIXER_E("RX INT6 VBAT", SND_SOC_NOPM, 0, 0,
  9091. rx_int6_vbat_mix_switch,
  9092. ARRAY_SIZE(rx_int6_vbat_mix_switch),
  9093. tasha_codec_vbat_enable_event,
  9094. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9095. SND_SOC_DAPM_MIXER_E("RX INT7 VBAT", SND_SOC_NOPM, 0, 0,
  9096. rx_int7_vbat_mix_switch,
  9097. ARRAY_SIZE(rx_int7_vbat_mix_switch),
  9098. tasha_codec_vbat_enable_event,
  9099. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9100. SND_SOC_DAPM_MIXER_E("RX INT8 VBAT", SND_SOC_NOPM, 0, 0,
  9101. rx_int8_vbat_mix_switch,
  9102. ARRAY_SIZE(rx_int8_vbat_mix_switch),
  9103. tasha_codec_vbat_enable_event,
  9104. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9105. SND_SOC_DAPM_MUX("RX INT0 MIX2 INP", WCD9335_CDC_RX0_RX_PATH_CFG1, 4,
  9106. 0, &rx_int0_mix2_inp_mux),
  9107. SND_SOC_DAPM_MUX("RX INT1 MIX2 INP", WCD9335_CDC_RX1_RX_PATH_CFG1, 4,
  9108. 0, &rx_int1_mix2_inp_mux),
  9109. SND_SOC_DAPM_MUX("RX INT2 MIX2 INP", WCD9335_CDC_RX2_RX_PATH_CFG1, 4,
  9110. 0, &rx_int2_mix2_inp_mux),
  9111. SND_SOC_DAPM_MUX("RX INT3 MIX2 INP", WCD9335_CDC_RX3_RX_PATH_CFG1, 4,
  9112. 0, &rx_int3_mix2_inp_mux),
  9113. SND_SOC_DAPM_MUX("RX INT4 MIX2 INP", WCD9335_CDC_RX4_RX_PATH_CFG1, 4,
  9114. 0, &rx_int4_mix2_inp_mux),
  9115. SND_SOC_DAPM_MUX("RX INT7 MIX2 INP", WCD9335_CDC_RX7_RX_PATH_CFG1, 4,
  9116. 0, &rx_int7_mix2_inp_mux),
  9117. SND_SOC_DAPM_MUX("SLIM TX0 MUX", SND_SOC_NOPM, TASHA_TX0, 0,
  9118. &sb_tx0_mux),
  9119. SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TASHA_TX1, 0,
  9120. &sb_tx1_mux),
  9121. SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TASHA_TX2, 0,
  9122. &sb_tx2_mux),
  9123. SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TASHA_TX3, 0,
  9124. &sb_tx3_mux),
  9125. SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TASHA_TX4, 0,
  9126. &sb_tx4_mux),
  9127. SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TASHA_TX5, 0,
  9128. &sb_tx5_mux),
  9129. SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, TASHA_TX6, 0,
  9130. &sb_tx6_mux),
  9131. SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, TASHA_TX7, 0,
  9132. &sb_tx7_mux),
  9133. SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, TASHA_TX8, 0,
  9134. &sb_tx8_mux),
  9135. SND_SOC_DAPM_MUX("SLIM TX9 MUX", SND_SOC_NOPM, TASHA_TX9, 0,
  9136. &sb_tx9_mux),
  9137. SND_SOC_DAPM_MUX("SLIM TX10 MUX", SND_SOC_NOPM, TASHA_TX10, 0,
  9138. &sb_tx10_mux),
  9139. SND_SOC_DAPM_MUX("SLIM TX11 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9140. &sb_tx11_mux),
  9141. SND_SOC_DAPM_MUX("SLIM TX11 INP1 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9142. &sb_tx11_inp1_mux),
  9143. SND_SOC_DAPM_MUX("SLIM TX13 MUX", SND_SOC_NOPM, TASHA_TX13, 0,
  9144. &sb_tx13_mux),
  9145. SND_SOC_DAPM_MUX("TX13 INP MUX", SND_SOC_NOPM, 0, 0,
  9146. &tx13_inp_mux),
  9147. SND_SOC_DAPM_MUX_E("ADC MUX0", WCD9335_CDC_TX0_TX_PATH_CTL, 5, 0,
  9148. &tx_adc_mux0, tasha_codec_enable_dec,
  9149. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9150. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9151. SND_SOC_DAPM_MUX_E("ADC MUX1", WCD9335_CDC_TX1_TX_PATH_CTL, 5, 0,
  9152. &tx_adc_mux1, tasha_codec_enable_dec,
  9153. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9154. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9155. SND_SOC_DAPM_MUX_E("ADC MUX2", WCD9335_CDC_TX2_TX_PATH_CTL, 5, 0,
  9156. &tx_adc_mux2, tasha_codec_enable_dec,
  9157. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9158. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9159. SND_SOC_DAPM_MUX_E("ADC MUX3", WCD9335_CDC_TX3_TX_PATH_CTL, 5, 0,
  9160. &tx_adc_mux3, tasha_codec_enable_dec,
  9161. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9162. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9163. SND_SOC_DAPM_MUX_E("ADC MUX4", WCD9335_CDC_TX4_TX_PATH_CTL, 5, 0,
  9164. &tx_adc_mux4, tasha_codec_enable_dec,
  9165. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9166. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9167. SND_SOC_DAPM_MUX_E("ADC MUX5", WCD9335_CDC_TX5_TX_PATH_CTL, 5, 0,
  9168. &tx_adc_mux5, tasha_codec_enable_dec,
  9169. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9170. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9171. SND_SOC_DAPM_MUX_E("ADC MUX6", WCD9335_CDC_TX6_TX_PATH_CTL, 5, 0,
  9172. &tx_adc_mux6, tasha_codec_enable_dec,
  9173. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9174. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9175. SND_SOC_DAPM_MUX_E("ADC MUX7", WCD9335_CDC_TX7_TX_PATH_CTL, 5, 0,
  9176. &tx_adc_mux7, tasha_codec_enable_dec,
  9177. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9178. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9179. SND_SOC_DAPM_MUX_E("ADC MUX8", WCD9335_CDC_TX8_TX_PATH_CTL, 5, 0,
  9180. &tx_adc_mux8, tasha_codec_enable_dec,
  9181. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9182. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9183. SND_SOC_DAPM_MUX_E("ADC MUX10", SND_SOC_NOPM, 10, 0,
  9184. &tx_adc_mux10, tasha_codec_tx_adc_cfg,
  9185. SND_SOC_DAPM_POST_PMU),
  9186. SND_SOC_DAPM_MUX_E("ADC MUX11", SND_SOC_NOPM, 11, 0,
  9187. &tx_adc_mux11, tasha_codec_tx_adc_cfg,
  9188. SND_SOC_DAPM_POST_PMU),
  9189. SND_SOC_DAPM_MUX_E("ADC MUX12", SND_SOC_NOPM, 12, 0,
  9190. &tx_adc_mux12, tasha_codec_tx_adc_cfg,
  9191. SND_SOC_DAPM_POST_PMU),
  9192. SND_SOC_DAPM_MUX_E("ADC MUX13", SND_SOC_NOPM, 13, 0,
  9193. &tx_adc_mux13, tasha_codec_tx_adc_cfg,
  9194. SND_SOC_DAPM_POST_PMU),
  9195. SND_SOC_DAPM_MUX("DMIC MUX0", SND_SOC_NOPM, 0, 0,
  9196. &tx_dmic_mux0),
  9197. SND_SOC_DAPM_MUX("DMIC MUX1", SND_SOC_NOPM, 0, 0,
  9198. &tx_dmic_mux1),
  9199. SND_SOC_DAPM_MUX("DMIC MUX2", SND_SOC_NOPM, 0, 0,
  9200. &tx_dmic_mux2),
  9201. SND_SOC_DAPM_MUX("DMIC MUX3", SND_SOC_NOPM, 0, 0,
  9202. &tx_dmic_mux3),
  9203. SND_SOC_DAPM_MUX("DMIC MUX4", SND_SOC_NOPM, 0, 0,
  9204. &tx_dmic_mux4),
  9205. SND_SOC_DAPM_MUX("DMIC MUX5", SND_SOC_NOPM, 0, 0,
  9206. &tx_dmic_mux5),
  9207. SND_SOC_DAPM_MUX("DMIC MUX6", SND_SOC_NOPM, 0, 0,
  9208. &tx_dmic_mux6),
  9209. SND_SOC_DAPM_MUX("DMIC MUX7", SND_SOC_NOPM, 0, 0,
  9210. &tx_dmic_mux7),
  9211. SND_SOC_DAPM_MUX("DMIC MUX8", SND_SOC_NOPM, 0, 0,
  9212. &tx_dmic_mux8),
  9213. SND_SOC_DAPM_MUX("DMIC MUX10", SND_SOC_NOPM, 0, 0,
  9214. &tx_dmic_mux10),
  9215. SND_SOC_DAPM_MUX("DMIC MUX11", SND_SOC_NOPM, 0, 0,
  9216. &tx_dmic_mux11),
  9217. SND_SOC_DAPM_MUX("DMIC MUX12", SND_SOC_NOPM, 0, 0,
  9218. &tx_dmic_mux12),
  9219. SND_SOC_DAPM_MUX("DMIC MUX13", SND_SOC_NOPM, 0, 0,
  9220. &tx_dmic_mux13),
  9221. SND_SOC_DAPM_MUX("AMIC MUX0", SND_SOC_NOPM, 0, 0,
  9222. &tx_amic_mux0),
  9223. SND_SOC_DAPM_MUX("AMIC MUX1", SND_SOC_NOPM, 0, 0,
  9224. &tx_amic_mux1),
  9225. SND_SOC_DAPM_MUX("AMIC MUX2", SND_SOC_NOPM, 0, 0,
  9226. &tx_amic_mux2),
  9227. SND_SOC_DAPM_MUX("AMIC MUX3", SND_SOC_NOPM, 0, 0,
  9228. &tx_amic_mux3),
  9229. SND_SOC_DAPM_MUX("AMIC MUX4", SND_SOC_NOPM, 0, 0,
  9230. &tx_amic_mux4),
  9231. SND_SOC_DAPM_MUX("AMIC MUX5", SND_SOC_NOPM, 0, 0,
  9232. &tx_amic_mux5),
  9233. SND_SOC_DAPM_MUX("AMIC MUX6", SND_SOC_NOPM, 0, 0,
  9234. &tx_amic_mux6),
  9235. SND_SOC_DAPM_MUX("AMIC MUX7", SND_SOC_NOPM, 0, 0,
  9236. &tx_amic_mux7),
  9237. SND_SOC_DAPM_MUX("AMIC MUX8", SND_SOC_NOPM, 0, 0,
  9238. &tx_amic_mux8),
  9239. SND_SOC_DAPM_MUX("AMIC MUX10", SND_SOC_NOPM, 0, 0,
  9240. &tx_amic_mux10),
  9241. SND_SOC_DAPM_MUX("AMIC MUX11", SND_SOC_NOPM, 0, 0,
  9242. &tx_amic_mux11),
  9243. SND_SOC_DAPM_MUX("AMIC MUX12", SND_SOC_NOPM, 0, 0,
  9244. &tx_amic_mux12),
  9245. SND_SOC_DAPM_MUX("AMIC MUX13", SND_SOC_NOPM, 0, 0,
  9246. &tx_amic_mux13),
  9247. SND_SOC_DAPM_ADC_E("ADC1", NULL, WCD9335_ANA_AMIC1, 7, 0,
  9248. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9249. SND_SOC_DAPM_ADC_E("ADC2", NULL, WCD9335_ANA_AMIC2, 7, 0,
  9250. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9251. SND_SOC_DAPM_ADC_E("ADC3", NULL, WCD9335_ANA_AMIC3, 7, 0,
  9252. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9253. SND_SOC_DAPM_ADC_E("ADC4", NULL, WCD9335_ANA_AMIC4, 7, 0,
  9254. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9255. SND_SOC_DAPM_ADC_E("ADC5", NULL, WCD9335_ANA_AMIC5, 7, 0,
  9256. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9257. SND_SOC_DAPM_ADC_E("ADC6", NULL, WCD9335_ANA_AMIC6, 7, 0,
  9258. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9259. SND_SOC_DAPM_SUPPLY("RX INT1 NATIVE SUPPLY", SND_SOC_NOPM,
  9260. INTERP_HPHL, 0, tasha_enable_native_supply,
  9261. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9262. SND_SOC_DAPM_SUPPLY("RX INT2 NATIVE SUPPLY", SND_SOC_NOPM,
  9263. INTERP_HPHR, 0, tasha_enable_native_supply,
  9264. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9265. SND_SOC_DAPM_SUPPLY("RX INT3 NATIVE SUPPLY", SND_SOC_NOPM,
  9266. INTERP_LO1, 0, tasha_enable_native_supply,
  9267. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9268. SND_SOC_DAPM_SUPPLY("RX INT4 NATIVE SUPPLY", SND_SOC_NOPM,
  9269. INTERP_LO2, 0, tasha_enable_native_supply,
  9270. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9271. SND_SOC_DAPM_INPUT("AMIC1"),
  9272. SND_SOC_DAPM_MICBIAS_E("MIC BIAS1", SND_SOC_NOPM, 0, 0,
  9273. tasha_codec_enable_micbias,
  9274. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9275. SND_SOC_DAPM_POST_PMD),
  9276. SND_SOC_DAPM_MICBIAS_E("MIC BIAS2", SND_SOC_NOPM, 0, 0,
  9277. tasha_codec_enable_micbias,
  9278. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9279. SND_SOC_DAPM_POST_PMD),
  9280. SND_SOC_DAPM_MICBIAS_E("MIC BIAS3", SND_SOC_NOPM, 0, 0,
  9281. tasha_codec_enable_micbias,
  9282. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9283. SND_SOC_DAPM_POST_PMD),
  9284. SND_SOC_DAPM_MICBIAS_E("MIC BIAS4", SND_SOC_NOPM, 0, 0,
  9285. tasha_codec_enable_micbias,
  9286. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9287. SND_SOC_DAPM_POST_PMD),
  9288. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS1_STANDALONE, SND_SOC_NOPM, 0, 0,
  9289. tasha_codec_force_enable_micbias,
  9290. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9291. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS2_STANDALONE, SND_SOC_NOPM, 0, 0,
  9292. tasha_codec_force_enable_micbias,
  9293. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9294. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS3_STANDALONE, SND_SOC_NOPM, 0, 0,
  9295. tasha_codec_force_enable_micbias,
  9296. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9297. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS4_STANDALONE, SND_SOC_NOPM, 0, 0,
  9298. tasha_codec_force_enable_micbias,
  9299. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9300. SND_SOC_DAPM_SUPPLY(DAPM_LDO_H_STANDALONE, SND_SOC_NOPM, 0, 0,
  9301. tasha_codec_force_enable_ldo_h,
  9302. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9303. SND_SOC_DAPM_MUX("ANC0 FB MUX", SND_SOC_NOPM, 0, 0, &anc0_fb_mux),
  9304. SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux),
  9305. SND_SOC_DAPM_INPUT("AMIC2"),
  9306. SND_SOC_DAPM_INPUT("AMIC3"),
  9307. SND_SOC_DAPM_INPUT("AMIC4"),
  9308. SND_SOC_DAPM_INPUT("AMIC5"),
  9309. SND_SOC_DAPM_INPUT("AMIC6"),
  9310. SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM,
  9311. AIF1_CAP, 0, tasha_codec_enable_slimtx,
  9312. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9313. SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM,
  9314. AIF2_CAP, 0, tasha_codec_enable_slimtx,
  9315. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9316. SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM,
  9317. AIF3_CAP, 0, tasha_codec_enable_slimtx,
  9318. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9319. SND_SOC_DAPM_AIF_OUT_E("AIF4 VI", "VIfeed", 0, SND_SOC_NOPM,
  9320. AIF4_VIFEED, 0, tasha_codec_enable_slimvi_feedback,
  9321. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9322. SND_SOC_DAPM_MIXER("AIF4_VI Mixer", SND_SOC_NOPM, AIF4_VIFEED, 0,
  9323. aif4_vi_mixer, ARRAY_SIZE(aif4_vi_mixer)),
  9324. SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0,
  9325. aif1_cap_mixer, ARRAY_SIZE(aif1_cap_mixer)),
  9326. SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0,
  9327. aif2_cap_mixer, ARRAY_SIZE(aif2_cap_mixer)),
  9328. SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0,
  9329. aif3_cap_mixer, ARRAY_SIZE(aif3_cap_mixer)),
  9330. SND_SOC_DAPM_MIXER("AIF4_MAD Mixer", SND_SOC_NOPM, AIF4_MAD_TX, 0,
  9331. aif4_mad_mixer, ARRAY_SIZE(aif4_mad_mixer)),
  9332. SND_SOC_DAPM_INPUT("VIINPUT"),
  9333. SND_SOC_DAPM_AIF_OUT("AIF5 CPE", "AIF5 CPE TX", 0, SND_SOC_NOPM,
  9334. AIF5_CPE_TX, 0),
  9335. SND_SOC_DAPM_MUX_E("EC BUF MUX INP", SND_SOC_NOPM, 0, 0, &ec_buf_mux,
  9336. tasha_codec_ec_buf_mux_enable,
  9337. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9338. /* Digital Mic Inputs */
  9339. SND_SOC_DAPM_ADC_E("DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  9340. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9341. SND_SOC_DAPM_POST_PMD),
  9342. SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  9343. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9344. SND_SOC_DAPM_POST_PMD),
  9345. SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  9346. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9347. SND_SOC_DAPM_POST_PMD),
  9348. SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  9349. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9350. SND_SOC_DAPM_POST_PMD),
  9351. SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  9352. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9353. SND_SOC_DAPM_POST_PMD),
  9354. SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  9355. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9356. SND_SOC_DAPM_POST_PMD),
  9357. SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux),
  9358. SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux),
  9359. SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux),
  9360. SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux),
  9361. SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux),
  9362. SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
  9363. SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux),
  9364. SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux),
  9365. SND_SOC_DAPM_MIXER_E("IIR0", WCD9335_CDC_SIDETONE_IIR0_IIR_PATH_CTL,
  9366. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9367. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9368. SND_SOC_DAPM_MIXER_E("IIR1", WCD9335_CDC_SIDETONE_IIR1_IIR_PATH_CTL,
  9369. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9370. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9371. SND_SOC_DAPM_MIXER("SRC0", WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL,
  9372. 4, 0, NULL, 0),
  9373. SND_SOC_DAPM_MIXER("SRC1", WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL,
  9374. 4, 0, NULL, 0),
  9375. SND_SOC_DAPM_MIXER_E("CPE IN Mixer", SND_SOC_NOPM, 0, 0,
  9376. cpe_in_mix_switch,
  9377. ARRAY_SIZE(cpe_in_mix_switch),
  9378. tasha_codec_configure_cpe_input,
  9379. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9380. SND_SOC_DAPM_MUX("RX INT1_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9381. &int1_1_native_mux),
  9382. SND_SOC_DAPM_MUX("RX INT2_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9383. &int2_1_native_mux),
  9384. SND_SOC_DAPM_MUX("RX INT3_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9385. &int3_1_native_mux),
  9386. SND_SOC_DAPM_MUX("RX INT4_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9387. &int4_1_native_mux),
  9388. SND_SOC_DAPM_MUX("RX MIX TX0 MUX", SND_SOC_NOPM, 0, 0,
  9389. &rx_mix_tx0_mux),
  9390. SND_SOC_DAPM_MUX("RX MIX TX1 MUX", SND_SOC_NOPM, 0, 0,
  9391. &rx_mix_tx1_mux),
  9392. SND_SOC_DAPM_MUX("RX MIX TX2 MUX", SND_SOC_NOPM, 0, 0,
  9393. &rx_mix_tx2_mux),
  9394. SND_SOC_DAPM_MUX("RX MIX TX3 MUX", SND_SOC_NOPM, 0, 0,
  9395. &rx_mix_tx3_mux),
  9396. SND_SOC_DAPM_MUX("RX MIX TX4 MUX", SND_SOC_NOPM, 0, 0,
  9397. &rx_mix_tx4_mux),
  9398. SND_SOC_DAPM_MUX("RX MIX TX5 MUX", SND_SOC_NOPM, 0, 0,
  9399. &rx_mix_tx5_mux),
  9400. SND_SOC_DAPM_MUX("RX MIX TX6 MUX", SND_SOC_NOPM, 0, 0,
  9401. &rx_mix_tx6_mux),
  9402. SND_SOC_DAPM_MUX("RX MIX TX7 MUX", SND_SOC_NOPM, 0, 0,
  9403. &rx_mix_tx7_mux),
  9404. SND_SOC_DAPM_MUX("RX MIX TX8 MUX", SND_SOC_NOPM, 0, 0,
  9405. &rx_mix_tx8_mux),
  9406. SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0,
  9407. &rx_int0_dem_inp_mux),
  9408. SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0,
  9409. &rx_int1_dem_inp_mux),
  9410. SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM, 0, 0,
  9411. &rx_int2_dem_inp_mux),
  9412. SND_SOC_DAPM_MUX_E("RX INT0 INTERP", SND_SOC_NOPM,
  9413. INTERP_EAR, 0, &rx_int0_interp_mux,
  9414. tasha_codec_enable_interpolator,
  9415. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9416. SND_SOC_DAPM_POST_PMD),
  9417. SND_SOC_DAPM_MUX_E("RX INT1 INTERP", SND_SOC_NOPM,
  9418. INTERP_HPHL, 0, &rx_int1_interp_mux,
  9419. tasha_codec_enable_interpolator,
  9420. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9421. SND_SOC_DAPM_POST_PMD),
  9422. SND_SOC_DAPM_MUX_E("RX INT2 INTERP", SND_SOC_NOPM,
  9423. INTERP_HPHR, 0, &rx_int2_interp_mux,
  9424. tasha_codec_enable_interpolator,
  9425. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9426. SND_SOC_DAPM_POST_PMD),
  9427. SND_SOC_DAPM_MUX_E("RX INT3 INTERP", SND_SOC_NOPM,
  9428. INTERP_LO1, 0, &rx_int3_interp_mux,
  9429. tasha_codec_enable_interpolator,
  9430. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9431. SND_SOC_DAPM_POST_PMD),
  9432. SND_SOC_DAPM_MUX_E("RX INT4 INTERP", SND_SOC_NOPM,
  9433. INTERP_LO2, 0, &rx_int4_interp_mux,
  9434. tasha_codec_enable_interpolator,
  9435. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9436. SND_SOC_DAPM_POST_PMD),
  9437. SND_SOC_DAPM_MUX_E("RX INT5 INTERP", SND_SOC_NOPM,
  9438. INTERP_LO3, 0, &rx_int5_interp_mux,
  9439. tasha_codec_enable_interpolator,
  9440. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9441. SND_SOC_DAPM_POST_PMD),
  9442. SND_SOC_DAPM_MUX_E("RX INT6 INTERP", SND_SOC_NOPM,
  9443. INTERP_LO4, 0, &rx_int6_interp_mux,
  9444. tasha_codec_enable_interpolator,
  9445. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9446. SND_SOC_DAPM_POST_PMD),
  9447. SND_SOC_DAPM_MUX_E("RX INT7 INTERP", SND_SOC_NOPM,
  9448. INTERP_SPKR1, 0, &rx_int7_interp_mux,
  9449. tasha_codec_enable_interpolator,
  9450. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9451. SND_SOC_DAPM_POST_PMD),
  9452. SND_SOC_DAPM_MUX_E("RX INT8 INTERP", SND_SOC_NOPM,
  9453. INTERP_SPKR2, 0, &rx_int8_interp_mux,
  9454. tasha_codec_enable_interpolator,
  9455. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9456. SND_SOC_DAPM_POST_PMD),
  9457. SND_SOC_DAPM_DAC_E("RX INT0 DAC", NULL, SND_SOC_NOPM,
  9458. 0, 0, tasha_codec_ear_dac_event,
  9459. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9460. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9461. SND_SOC_DAPM_DAC_E("RX INT1 DAC", NULL, WCD9335_ANA_HPH,
  9462. 5, 0, tasha_codec_hphl_dac_event,
  9463. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9464. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9465. SND_SOC_DAPM_DAC_E("RX INT2 DAC", NULL, WCD9335_ANA_HPH,
  9466. 4, 0, tasha_codec_hphr_dac_event,
  9467. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9468. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9469. SND_SOC_DAPM_DAC_E("RX INT3 DAC", NULL, SND_SOC_NOPM,
  9470. 0, 0, tasha_codec_lineout_dac_event,
  9471. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9472. SND_SOC_DAPM_DAC_E("RX INT4 DAC", NULL, SND_SOC_NOPM,
  9473. 0, 0, tasha_codec_lineout_dac_event,
  9474. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9475. SND_SOC_DAPM_DAC_E("RX INT5 DAC", NULL, SND_SOC_NOPM,
  9476. 0, 0, tasha_codec_lineout_dac_event,
  9477. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9478. SND_SOC_DAPM_DAC_E("RX INT6 DAC", NULL, SND_SOC_NOPM,
  9479. 0, 0, tasha_codec_lineout_dac_event,
  9480. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9481. SND_SOC_DAPM_PGA_E("HPHL PA", WCD9335_ANA_HPH, 7, 0, NULL, 0,
  9482. tasha_codec_enable_hphl_pa,
  9483. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9484. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9485. SND_SOC_DAPM_PGA_E("HPHR PA", WCD9335_ANA_HPH, 6, 0, NULL, 0,
  9486. tasha_codec_enable_hphr_pa,
  9487. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9488. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9489. SND_SOC_DAPM_PGA_E("EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9490. tasha_codec_enable_ear_pa,
  9491. SND_SOC_DAPM_POST_PMU |
  9492. SND_SOC_DAPM_POST_PMD),
  9493. SND_SOC_DAPM_PGA_E("LINEOUT1 PA", WCD9335_ANA_LO_1_2, 7, 0, NULL, 0,
  9494. tasha_codec_enable_lineout_pa,
  9495. SND_SOC_DAPM_POST_PMU |
  9496. SND_SOC_DAPM_POST_PMD),
  9497. SND_SOC_DAPM_PGA_E("LINEOUT2 PA", WCD9335_ANA_LO_1_2, 6, 0, NULL, 0,
  9498. tasha_codec_enable_lineout_pa,
  9499. SND_SOC_DAPM_POST_PMU |
  9500. SND_SOC_DAPM_POST_PMD),
  9501. SND_SOC_DAPM_PGA_E("LINEOUT3 PA", WCD9335_ANA_LO_3_4, 7, 0, NULL, 0,
  9502. tasha_codec_enable_lineout_pa,
  9503. SND_SOC_DAPM_POST_PMU |
  9504. SND_SOC_DAPM_POST_PMD),
  9505. SND_SOC_DAPM_PGA_E("LINEOUT4 PA", WCD9335_ANA_LO_3_4, 6, 0, NULL, 0,
  9506. tasha_codec_enable_lineout_pa,
  9507. SND_SOC_DAPM_POST_PMU |
  9508. SND_SOC_DAPM_POST_PMD),
  9509. SND_SOC_DAPM_PGA_E("ANC EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9510. tasha_codec_enable_ear_pa,
  9511. SND_SOC_DAPM_POST_PMU |
  9512. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9513. SND_SOC_DAPM_PGA_E("ANC HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9514. tasha_codec_enable_hphl_pa,
  9515. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9516. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9517. SND_SOC_DAPM_PGA_E("ANC HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9518. tasha_codec_enable_hphr_pa,
  9519. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9520. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9521. SND_SOC_DAPM_PGA_E("ANC LINEOUT1 PA", WCD9335_ANA_LO_1_2,
  9522. 7, 0, NULL, 0,
  9523. tasha_codec_enable_lineout_pa,
  9524. SND_SOC_DAPM_POST_PMU |
  9525. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9526. SND_SOC_DAPM_PGA_E("ANC LINEOUT2 PA", WCD9335_ANA_LO_1_2,
  9527. 6, 0, NULL, 0,
  9528. tasha_codec_enable_lineout_pa,
  9529. SND_SOC_DAPM_POST_PMU |
  9530. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9531. SND_SOC_DAPM_PGA_E("ANC SPK1 PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9532. tasha_codec_enable_spk_anc,
  9533. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9534. SND_SOC_DAPM_OUTPUT("HPHL"),
  9535. SND_SOC_DAPM_OUTPUT("HPHR"),
  9536. SND_SOC_DAPM_OUTPUT("ANC HPHL"),
  9537. SND_SOC_DAPM_OUTPUT("ANC HPHR"),
  9538. SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0,
  9539. tasha_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU |
  9540. SND_SOC_DAPM_POST_PMD),
  9541. SND_SOC_DAPM_OUTPUT("SPK1 OUT"),
  9542. SND_SOC_DAPM_OUTPUT("SPK2 OUT"),
  9543. SND_SOC_DAPM_OUTPUT("LINEOUT1"),
  9544. SND_SOC_DAPM_OUTPUT("LINEOUT2"),
  9545. SND_SOC_DAPM_OUTPUT("LINEOUT3"),
  9546. SND_SOC_DAPM_OUTPUT("LINEOUT4"),
  9547. SND_SOC_DAPM_OUTPUT("ANC LINEOUT1"),
  9548. SND_SOC_DAPM_OUTPUT("ANC LINEOUT2"),
  9549. SND_SOC_DAPM_SUPPLY("MICBIAS_REGULATOR", SND_SOC_NOPM,
  9550. ON_DEMAND_MICBIAS, 0,
  9551. tasha_codec_enable_on_demand_supply,
  9552. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9553. SND_SOC_DAPM_SWITCH("ADC US MUX0", WCD9335_CDC_TX0_TX_PATH_192_CTL, 0,
  9554. 0, &adc_us_mux0_switch),
  9555. SND_SOC_DAPM_SWITCH("ADC US MUX1", WCD9335_CDC_TX1_TX_PATH_192_CTL, 0,
  9556. 0, &adc_us_mux1_switch),
  9557. SND_SOC_DAPM_SWITCH("ADC US MUX2", WCD9335_CDC_TX2_TX_PATH_192_CTL, 0,
  9558. 0, &adc_us_mux2_switch),
  9559. SND_SOC_DAPM_SWITCH("ADC US MUX3", WCD9335_CDC_TX3_TX_PATH_192_CTL, 0,
  9560. 0, &adc_us_mux3_switch),
  9561. SND_SOC_DAPM_SWITCH("ADC US MUX4", WCD9335_CDC_TX4_TX_PATH_192_CTL, 0,
  9562. 0, &adc_us_mux4_switch),
  9563. SND_SOC_DAPM_SWITCH("ADC US MUX5", WCD9335_CDC_TX5_TX_PATH_192_CTL, 0,
  9564. 0, &adc_us_mux5_switch),
  9565. SND_SOC_DAPM_SWITCH("ADC US MUX6", WCD9335_CDC_TX6_TX_PATH_192_CTL, 0,
  9566. 0, &adc_us_mux6_switch),
  9567. SND_SOC_DAPM_SWITCH("ADC US MUX7", WCD9335_CDC_TX7_TX_PATH_192_CTL, 0,
  9568. 0, &adc_us_mux7_switch),
  9569. SND_SOC_DAPM_SWITCH("ADC US MUX8", WCD9335_CDC_TX8_TX_PATH_192_CTL, 0,
  9570. 0, &adc_us_mux8_switch),
  9571. /* MAD related widgets */
  9572. SND_SOC_DAPM_AIF_OUT_E("AIF4 MAD", "AIF4 MAD TX", 0,
  9573. SND_SOC_NOPM, 0, 0,
  9574. tasha_codec_enable_mad,
  9575. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9576. SND_SOC_DAPM_MUX("MAD_SEL MUX", SND_SOC_NOPM, 0, 0,
  9577. &mad_sel_mux),
  9578. SND_SOC_DAPM_INPUT("MAD_CPE_INPUT"),
  9579. SND_SOC_DAPM_INPUT("MADINPUT"),
  9580. SND_SOC_DAPM_SWITCH("MADONOFF", SND_SOC_NOPM, 0, 0,
  9581. &aif4_mad_switch),
  9582. SND_SOC_DAPM_SWITCH("MAD_BROADCAST", SND_SOC_NOPM, 0, 0,
  9583. &mad_brdcst_switch),
  9584. SND_SOC_DAPM_SWITCH("AIF4", SND_SOC_NOPM, 0, 0,
  9585. &aif4_switch_mixer_controls),
  9586. SND_SOC_DAPM_SWITCH("ANC HPHL Enable", SND_SOC_NOPM, 0, 0,
  9587. &anc_hphl_switch),
  9588. SND_SOC_DAPM_SWITCH("ANC HPHR Enable", SND_SOC_NOPM, 0, 0,
  9589. &anc_hphr_switch),
  9590. SND_SOC_DAPM_SWITCH("ANC EAR Enable", SND_SOC_NOPM, 0, 0,
  9591. &anc_ear_switch),
  9592. SND_SOC_DAPM_SWITCH("ANC OUT EAR SPKR Enable", SND_SOC_NOPM, 0, 0,
  9593. &anc_ear_spkr_switch),
  9594. SND_SOC_DAPM_SWITCH("ANC LINEOUT1 Enable", SND_SOC_NOPM, 0, 0,
  9595. &anc_lineout1_switch),
  9596. SND_SOC_DAPM_SWITCH("ANC LINEOUT2 Enable", SND_SOC_NOPM, 0, 0,
  9597. &anc_lineout2_switch),
  9598. SND_SOC_DAPM_SWITCH("ANC SPKR PA Enable", SND_SOC_NOPM, 0, 0,
  9599. &anc_spkr_pa_switch),
  9600. };
  9601. static int tasha_get_channel_map(struct snd_soc_dai *dai,
  9602. unsigned int *tx_num, unsigned int *tx_slot,
  9603. unsigned int *rx_num, unsigned int *rx_slot)
  9604. {
  9605. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(dai->codec);
  9606. u32 i = 0;
  9607. struct wcd9xxx_ch *ch;
  9608. switch (dai->id) {
  9609. case AIF1_PB:
  9610. case AIF2_PB:
  9611. case AIF3_PB:
  9612. case AIF4_PB:
  9613. case AIF_MIX1_PB:
  9614. if (!rx_slot || !rx_num) {
  9615. pr_err("%s: Invalid rx_slot %pK or rx_num %pK\n",
  9616. __func__, rx_slot, rx_num);
  9617. return -EINVAL;
  9618. }
  9619. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9620. list) {
  9621. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9622. __func__, i, ch->ch_num);
  9623. rx_slot[i++] = ch->ch_num;
  9624. }
  9625. pr_debug("%s: rx_num %d\n", __func__, i);
  9626. *rx_num = i;
  9627. break;
  9628. case AIF1_CAP:
  9629. case AIF2_CAP:
  9630. case AIF3_CAP:
  9631. case AIF4_MAD_TX:
  9632. case AIF4_VIFEED:
  9633. if (!tx_slot || !tx_num) {
  9634. pr_err("%s: Invalid tx_slot %pK or tx_num %pK\n",
  9635. __func__, tx_slot, tx_num);
  9636. return -EINVAL;
  9637. }
  9638. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9639. list) {
  9640. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9641. __func__, i, ch->ch_num);
  9642. tx_slot[i++] = ch->ch_num;
  9643. }
  9644. pr_debug("%s: tx_num %d\n", __func__, i);
  9645. *tx_num = i;
  9646. break;
  9647. default:
  9648. pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id);
  9649. break;
  9650. }
  9651. return 0;
  9652. }
  9653. static int tasha_set_channel_map(struct snd_soc_dai *dai,
  9654. unsigned int tx_num, unsigned int *tx_slot,
  9655. unsigned int rx_num, unsigned int *rx_slot)
  9656. {
  9657. struct tasha_priv *tasha;
  9658. struct wcd9xxx *core;
  9659. struct wcd9xxx_codec_dai_data *dai_data = NULL;
  9660. if (!dai) {
  9661. pr_err("%s: dai is empty\n", __func__);
  9662. return -EINVAL;
  9663. }
  9664. tasha = snd_soc_codec_get_drvdata(dai->codec);
  9665. core = dev_get_drvdata(dai->codec->dev->parent);
  9666. if (!tx_slot || !rx_slot) {
  9667. pr_err("%s: Invalid tx_slot=%pK, rx_slot=%pK\n",
  9668. __func__, tx_slot, rx_slot);
  9669. return -EINVAL;
  9670. }
  9671. pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n"
  9672. "tasha->intf_type %d\n",
  9673. __func__, dai->name, dai->id, tx_num, rx_num,
  9674. tasha->intf_type);
  9675. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  9676. wcd9xxx_init_slimslave(core, core->slim->laddr,
  9677. tx_num, tx_slot, rx_num, rx_slot);
  9678. /* Reserve TX12/TX13 for MAD data channel */
  9679. dai_data = &tasha->dai[AIF4_MAD_TX];
  9680. if (dai_data) {
  9681. if (TASHA_IS_2_0(tasha->wcd9xxx))
  9682. list_add_tail(&core->tx_chs[TASHA_TX13].list,
  9683. &dai_data->wcd9xxx_ch_list);
  9684. else
  9685. list_add_tail(&core->tx_chs[TASHA_TX12].list,
  9686. &dai_data->wcd9xxx_ch_list);
  9687. }
  9688. }
  9689. return 0;
  9690. }
  9691. static int tasha_startup(struct snd_pcm_substream *substream,
  9692. struct snd_soc_dai *dai)
  9693. {
  9694. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9695. substream->name, substream->stream);
  9696. return 0;
  9697. }
  9698. static void tasha_shutdown(struct snd_pcm_substream *substream,
  9699. struct snd_soc_dai *dai)
  9700. {
  9701. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  9702. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9703. substream->name, substream->stream);
  9704. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  9705. return;
  9706. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  9707. tasha_codec_vote_max_bw(dai->codec, false);
  9708. }
  9709. static int tasha_set_decimator_rate(struct snd_soc_dai *dai,
  9710. u8 tx_fs_rate_reg_val, u32 sample_rate)
  9711. {
  9712. struct snd_soc_codec *codec = dai->codec;
  9713. struct wcd9xxx_ch *ch;
  9714. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9715. u32 tx_port = 0;
  9716. u8 shift = 0, shift_val = 0, tx_mux_sel = 0;
  9717. int decimator = -1;
  9718. u16 tx_port_reg = 0, tx_fs_reg = 0;
  9719. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9720. tx_port = ch->port;
  9721. dev_dbg(codec->dev, "%s: dai->id = %d, tx_port = %d",
  9722. __func__, dai->id, tx_port);
  9723. if ((tx_port < 0) || (tx_port == 12) || (tx_port >= 14)) {
  9724. dev_err(codec->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n",
  9725. __func__, tx_port, dai->id);
  9726. return -EINVAL;
  9727. }
  9728. /* Find the SB TX MUX input - which decimator is connected */
  9729. if (tx_port < 4) {
  9730. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0;
  9731. shift = (tx_port << 1);
  9732. shift_val = 0x03;
  9733. } else if ((tx_port >= 4) && (tx_port < 8)) {
  9734. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1;
  9735. shift = ((tx_port - 4) << 1);
  9736. shift_val = 0x03;
  9737. } else if ((tx_port >= 8) && (tx_port < 11)) {
  9738. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2;
  9739. shift = ((tx_port - 8) << 1);
  9740. shift_val = 0x03;
  9741. } else if (tx_port == 11) {
  9742. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9743. shift = 0;
  9744. shift_val = 0x0F;
  9745. } else if (tx_port == 13) {
  9746. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9747. shift = 4;
  9748. shift_val = 0x03;
  9749. }
  9750. tx_mux_sel = snd_soc_read(codec, tx_port_reg) &
  9751. (shift_val << shift);
  9752. tx_mux_sel = tx_mux_sel >> shift;
  9753. if (tx_port <= 8) {
  9754. if ((tx_mux_sel == 0x2) || (tx_mux_sel == 0x3))
  9755. decimator = tx_port;
  9756. } else if (tx_port <= 10) {
  9757. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9758. decimator = ((tx_port == 9) ? 7 : 6);
  9759. } else if (tx_port == 11) {
  9760. if ((tx_mux_sel >= 1) && (tx_mux_sel < 7))
  9761. decimator = tx_mux_sel - 1;
  9762. } else if (tx_port == 13) {
  9763. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9764. decimator = 5;
  9765. }
  9766. if (decimator >= 0) {
  9767. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  9768. 16 * decimator;
  9769. dev_dbg(codec->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n",
  9770. __func__, decimator, tx_port, sample_rate);
  9771. snd_soc_update_bits(codec, tx_fs_reg, 0x0F,
  9772. tx_fs_rate_reg_val);
  9773. } else if ((tx_port <= 8) && (tx_mux_sel == 0x01)) {
  9774. /* Check if the TX Mux input is RX MIX TXn */
  9775. dev_dbg(codec->dev, "%s: RX_MIX_TX%u going to SLIM TX%u\n",
  9776. __func__, tx_port, tx_port);
  9777. } else {
  9778. dev_err(codec->dev, "%s: ERROR: Invalid decimator: %d\n",
  9779. __func__, decimator);
  9780. return -EINVAL;
  9781. }
  9782. }
  9783. return 0;
  9784. }
  9785. static int tasha_set_mix_interpolator_rate(struct snd_soc_dai *dai,
  9786. u8 int_mix_fs_rate_reg_val,
  9787. u32 sample_rate)
  9788. {
  9789. u8 int_2_inp;
  9790. u32 j;
  9791. u16 int_mux_cfg1, int_fs_reg;
  9792. u8 int_mux_cfg1_val;
  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. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9797. int_2_inp = ch->port + INTn_2_INP_SEL_RX0 -
  9798. TASHA_RX_PORT_START_NUMBER;
  9799. if ((int_2_inp < INTn_2_INP_SEL_RX0) ||
  9800. (int_2_inp > INTn_2_INP_SEL_RX7)) {
  9801. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9802. __func__,
  9803. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9804. dai->id);
  9805. return -EINVAL;
  9806. }
  9807. int_mux_cfg1 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1;
  9808. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9809. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) &
  9810. 0x0F;
  9811. if (int_mux_cfg1_val == int_2_inp) {
  9812. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_MIX_CTL +
  9813. 20 * j;
  9814. pr_debug("%s: AIF_MIX_PB DAI(%d) connected to INT%u_2\n",
  9815. __func__, dai->id, j);
  9816. pr_debug("%s: set INT%u_2 sample rate to %u\n",
  9817. __func__, j, sample_rate);
  9818. snd_soc_update_bits(codec, int_fs_reg,
  9819. 0x0F, int_mix_fs_rate_reg_val);
  9820. }
  9821. int_mux_cfg1 += 2;
  9822. }
  9823. }
  9824. return 0;
  9825. }
  9826. static int tasha_set_prim_interpolator_rate(struct snd_soc_dai *dai,
  9827. u8 int_prim_fs_rate_reg_val,
  9828. u32 sample_rate)
  9829. {
  9830. u8 int_1_mix1_inp;
  9831. u32 j;
  9832. u16 int_mux_cfg0, int_mux_cfg1;
  9833. u16 int_fs_reg;
  9834. u8 int_mux_cfg0_val, int_mux_cfg1_val;
  9835. u8 inp0_sel, inp1_sel, inp2_sel;
  9836. struct snd_soc_codec *codec = dai->codec;
  9837. struct wcd9xxx_ch *ch;
  9838. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9839. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9840. int_1_mix1_inp = ch->port + INTn_1_MIX_INP_SEL_RX0 -
  9841. TASHA_RX_PORT_START_NUMBER;
  9842. if ((int_1_mix1_inp < INTn_1_MIX_INP_SEL_RX0) ||
  9843. (int_1_mix1_inp > INTn_1_MIX_INP_SEL_RX7)) {
  9844. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9845. __func__,
  9846. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9847. dai->id);
  9848. return -EINVAL;
  9849. }
  9850. int_mux_cfg0 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0;
  9851. /*
  9852. * Loop through all interpolator MUX inputs and find out
  9853. * to which interpolator input, the slim rx port
  9854. * is connected
  9855. */
  9856. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9857. int_mux_cfg1 = int_mux_cfg0 + 1;
  9858. int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0);
  9859. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1);
  9860. inp0_sel = int_mux_cfg0_val & 0x0F;
  9861. inp1_sel = (int_mux_cfg0_val >> 4) & 0x0F;
  9862. inp2_sel = (int_mux_cfg1_val >> 4) & 0x0F;
  9863. if ((inp0_sel == int_1_mix1_inp) ||
  9864. (inp1_sel == int_1_mix1_inp) ||
  9865. (inp2_sel == int_1_mix1_inp)) {
  9866. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_CTL +
  9867. 20 * j;
  9868. pr_debug("%s: AIF_PB DAI(%d) connected to INT%u_1\n",
  9869. __func__, dai->id, j);
  9870. pr_debug("%s: set INT%u_1 sample rate to %u\n",
  9871. __func__, j, sample_rate);
  9872. /* sample_rate is in Hz */
  9873. if ((j == 0) && (sample_rate == 44100)) {
  9874. pr_info("%s: Cannot set 44.1KHz on INT0\n",
  9875. __func__);
  9876. } else
  9877. snd_soc_update_bits(codec, int_fs_reg,
  9878. 0x0F, int_prim_fs_rate_reg_val);
  9879. }
  9880. int_mux_cfg0 += 2;
  9881. }
  9882. }
  9883. return 0;
  9884. }
  9885. static int tasha_set_interpolator_rate(struct snd_soc_dai *dai,
  9886. u32 sample_rate)
  9887. {
  9888. int rate_val = 0;
  9889. int i, ret;
  9890. /* set mixing path rate */
  9891. for (i = 0; i < ARRAY_SIZE(int_mix_sample_rate_val); i++) {
  9892. if (sample_rate ==
  9893. int_mix_sample_rate_val[i].sample_rate) {
  9894. rate_val =
  9895. int_mix_sample_rate_val[i].rate_val;
  9896. break;
  9897. }
  9898. }
  9899. if ((i == ARRAY_SIZE(int_mix_sample_rate_val)) ||
  9900. (rate_val < 0))
  9901. goto prim_rate;
  9902. ret = tasha_set_mix_interpolator_rate(dai,
  9903. (u8) rate_val, sample_rate);
  9904. prim_rate:
  9905. /* set primary path sample rate */
  9906. for (i = 0; i < ARRAY_SIZE(int_prim_sample_rate_val); i++) {
  9907. if (sample_rate ==
  9908. int_prim_sample_rate_val[i].sample_rate) {
  9909. rate_val =
  9910. int_prim_sample_rate_val[i].rate_val;
  9911. break;
  9912. }
  9913. }
  9914. if ((i == ARRAY_SIZE(int_prim_sample_rate_val)) ||
  9915. (rate_val < 0))
  9916. return -EINVAL;
  9917. ret = tasha_set_prim_interpolator_rate(dai,
  9918. (u8) rate_val, sample_rate);
  9919. return ret;
  9920. }
  9921. static int tasha_prepare(struct snd_pcm_substream *substream,
  9922. struct snd_soc_dai *dai)
  9923. {
  9924. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9925. substream->name, substream->stream);
  9926. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  9927. tasha_codec_vote_max_bw(dai->codec, false);
  9928. return 0;
  9929. }
  9930. static int tasha_hw_params(struct snd_pcm_substream *substream,
  9931. struct snd_pcm_hw_params *params,
  9932. struct snd_soc_dai *dai)
  9933. {
  9934. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  9935. int ret;
  9936. int tx_fs_rate = -EINVAL;
  9937. int rx_fs_rate = -EINVAL;
  9938. int i2s_bit_mode;
  9939. struct snd_soc_codec *codec = dai->codec;
  9940. pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
  9941. dai->name, dai->id, params_rate(params),
  9942. params_channels(params));
  9943. switch (substream->stream) {
  9944. case SNDRV_PCM_STREAM_PLAYBACK:
  9945. ret = tasha_set_interpolator_rate(dai, params_rate(params));
  9946. if (ret) {
  9947. pr_err("%s: cannot set sample rate: %u\n",
  9948. __func__, params_rate(params));
  9949. return ret;
  9950. }
  9951. switch (params_width(params)) {
  9952. case 16:
  9953. tasha->dai[dai->id].bit_width = 16;
  9954. i2s_bit_mode = 0x01;
  9955. break;
  9956. case 24:
  9957. tasha->dai[dai->id].bit_width = 24;
  9958. i2s_bit_mode = 0x00;
  9959. break;
  9960. default:
  9961. return -EINVAL;
  9962. }
  9963. tasha->dai[dai->id].rate = params_rate(params);
  9964. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  9965. switch (params_rate(params)) {
  9966. case 8000:
  9967. rx_fs_rate = 0;
  9968. break;
  9969. case 16000:
  9970. rx_fs_rate = 1;
  9971. break;
  9972. case 32000:
  9973. rx_fs_rate = 2;
  9974. break;
  9975. case 48000:
  9976. rx_fs_rate = 3;
  9977. break;
  9978. case 96000:
  9979. rx_fs_rate = 4;
  9980. break;
  9981. case 192000:
  9982. rx_fs_rate = 5;
  9983. break;
  9984. default:
  9985. dev_err(tasha->dev,
  9986. "%s: Invalid RX sample rate: %d\n",
  9987. __func__, params_rate(params));
  9988. return -EINVAL;
  9989. };
  9990. snd_soc_update_bits(codec,
  9991. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  9992. 0x20, i2s_bit_mode << 5);
  9993. snd_soc_update_bits(codec,
  9994. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  9995. 0x1c, (rx_fs_rate << 2));
  9996. }
  9997. break;
  9998. case SNDRV_PCM_STREAM_CAPTURE:
  9999. switch (params_rate(params)) {
  10000. case 8000:
  10001. tx_fs_rate = 0;
  10002. break;
  10003. case 16000:
  10004. tx_fs_rate = 1;
  10005. break;
  10006. case 32000:
  10007. tx_fs_rate = 3;
  10008. break;
  10009. case 48000:
  10010. tx_fs_rate = 4;
  10011. break;
  10012. case 96000:
  10013. tx_fs_rate = 5;
  10014. break;
  10015. case 192000:
  10016. tx_fs_rate = 6;
  10017. break;
  10018. case 384000:
  10019. tx_fs_rate = 7;
  10020. break;
  10021. default:
  10022. dev_err(tasha->dev, "%s: Invalid TX sample rate: %d\n",
  10023. __func__, params_rate(params));
  10024. return -EINVAL;
  10025. };
  10026. if (dai->id != AIF4_VIFEED &&
  10027. dai->id != AIF4_MAD_TX) {
  10028. ret = tasha_set_decimator_rate(dai, tx_fs_rate,
  10029. params_rate(params));
  10030. if (ret < 0) {
  10031. dev_err(tasha->dev, "%s: cannot set TX Decimator rate: %d\n",
  10032. __func__, tx_fs_rate);
  10033. return ret;
  10034. }
  10035. }
  10036. tasha->dai[dai->id].rate = params_rate(params);
  10037. switch (params_width(params)) {
  10038. case 16:
  10039. tasha->dai[dai->id].bit_width = 16;
  10040. i2s_bit_mode = 0x01;
  10041. break;
  10042. case 24:
  10043. tasha->dai[dai->id].bit_width = 24;
  10044. i2s_bit_mode = 0x00;
  10045. break;
  10046. case 32:
  10047. tasha->dai[dai->id].bit_width = 32;
  10048. i2s_bit_mode = 0x00;
  10049. break;
  10050. default:
  10051. dev_err(tasha->dev, "%s: Invalid format 0x%x\n",
  10052. __func__, params_width(params));
  10053. return -EINVAL;
  10054. };
  10055. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10056. snd_soc_update_bits(codec,
  10057. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10058. 0x20, i2s_bit_mode << 5);
  10059. if (tx_fs_rate > 1)
  10060. tx_fs_rate--;
  10061. snd_soc_update_bits(codec,
  10062. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10063. 0x1c, tx_fs_rate << 2);
  10064. snd_soc_update_bits(codec,
  10065. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG,
  10066. 0x05, 0x05);
  10067. snd_soc_update_bits(codec,
  10068. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG,
  10069. 0x05, 0x05);
  10070. snd_soc_update_bits(codec,
  10071. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG,
  10072. 0x05, 0x05);
  10073. snd_soc_update_bits(codec,
  10074. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG,
  10075. 0x05, 0x05);
  10076. }
  10077. break;
  10078. default:
  10079. pr_err("%s: Invalid stream type %d\n", __func__,
  10080. substream->stream);
  10081. return -EINVAL;
  10082. };
  10083. if (dai->id == AIF4_VIFEED)
  10084. tasha->dai[dai->id].bit_width = 32;
  10085. return 0;
  10086. }
  10087. static int tasha_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  10088. {
  10089. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  10090. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  10091. case SND_SOC_DAIFMT_CBS_CFS:
  10092. /* CPU is master */
  10093. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10094. if (dai->id == AIF1_CAP)
  10095. snd_soc_update_bits(dai->codec,
  10096. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10097. 0x2, 0);
  10098. else if (dai->id == AIF1_PB)
  10099. snd_soc_update_bits(dai->codec,
  10100. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10101. 0x2, 0);
  10102. }
  10103. break;
  10104. case SND_SOC_DAIFMT_CBM_CFM:
  10105. /* CPU is slave */
  10106. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10107. if (dai->id == AIF1_CAP)
  10108. snd_soc_update_bits(dai->codec,
  10109. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10110. 0x2, 0x2);
  10111. else if (dai->id == AIF1_PB)
  10112. snd_soc_update_bits(dai->codec,
  10113. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10114. 0x2, 0x2);
  10115. }
  10116. break;
  10117. default:
  10118. return -EINVAL;
  10119. }
  10120. return 0;
  10121. }
  10122. static int tasha_set_dai_sysclk(struct snd_soc_dai *dai,
  10123. int clk_id, unsigned int freq, int dir)
  10124. {
  10125. pr_debug("%s\n", __func__);
  10126. return 0;
  10127. }
  10128. static struct snd_soc_dai_ops tasha_dai_ops = {
  10129. .startup = tasha_startup,
  10130. .shutdown = tasha_shutdown,
  10131. .hw_params = tasha_hw_params,
  10132. .prepare = tasha_prepare,
  10133. .set_sysclk = tasha_set_dai_sysclk,
  10134. .set_fmt = tasha_set_dai_fmt,
  10135. .set_channel_map = tasha_set_channel_map,
  10136. .get_channel_map = tasha_get_channel_map,
  10137. };
  10138. static struct snd_soc_dai_driver tasha_dai[] = {
  10139. {
  10140. .name = "tasha_rx1",
  10141. .id = AIF1_PB,
  10142. .playback = {
  10143. .stream_name = "AIF1 Playback",
  10144. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10145. .formats = TASHA_FORMATS_S16_S24_LE,
  10146. .rate_max = 192000,
  10147. .rate_min = 8000,
  10148. .channels_min = 1,
  10149. .channels_max = 2,
  10150. },
  10151. .ops = &tasha_dai_ops,
  10152. },
  10153. {
  10154. .name = "tasha_tx1",
  10155. .id = AIF1_CAP,
  10156. .capture = {
  10157. .stream_name = "AIF1 Capture",
  10158. .rates = WCD9335_RATES_MASK,
  10159. .formats = TASHA_FORMATS_S16_S24_LE,
  10160. .rate_max = 192000,
  10161. .rate_min = 8000,
  10162. .channels_min = 1,
  10163. .channels_max = 4,
  10164. },
  10165. .ops = &tasha_dai_ops,
  10166. },
  10167. {
  10168. .name = "tasha_rx2",
  10169. .id = AIF2_PB,
  10170. .playback = {
  10171. .stream_name = "AIF2 Playback",
  10172. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10173. .formats = TASHA_FORMATS_S16_S24_LE,
  10174. .rate_min = 8000,
  10175. .rate_max = 192000,
  10176. .channels_min = 1,
  10177. .channels_max = 2,
  10178. },
  10179. .ops = &tasha_dai_ops,
  10180. },
  10181. {
  10182. .name = "tasha_tx2",
  10183. .id = AIF2_CAP,
  10184. .capture = {
  10185. .stream_name = "AIF2 Capture",
  10186. .rates = WCD9335_RATES_MASK,
  10187. .formats = TASHA_FORMATS_S16_S24_LE,
  10188. .rate_max = 192000,
  10189. .rate_min = 8000,
  10190. .channels_min = 1,
  10191. .channels_max = 8,
  10192. },
  10193. .ops = &tasha_dai_ops,
  10194. },
  10195. {
  10196. .name = "tasha_rx3",
  10197. .id = AIF3_PB,
  10198. .playback = {
  10199. .stream_name = "AIF3 Playback",
  10200. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10201. .formats = TASHA_FORMATS_S16_S24_LE,
  10202. .rate_min = 8000,
  10203. .rate_max = 192000,
  10204. .channels_min = 1,
  10205. .channels_max = 2,
  10206. },
  10207. .ops = &tasha_dai_ops,
  10208. },
  10209. {
  10210. .name = "tasha_tx3",
  10211. .id = AIF3_CAP,
  10212. .capture = {
  10213. .stream_name = "AIF3 Capture",
  10214. .rates = WCD9335_RATES_MASK,
  10215. .formats = TASHA_FORMATS_S16_S24_LE,
  10216. .rate_max = 48000,
  10217. .rate_min = 8000,
  10218. .channels_min = 1,
  10219. .channels_max = 2,
  10220. },
  10221. .ops = &tasha_dai_ops,
  10222. },
  10223. {
  10224. .name = "tasha_rx4",
  10225. .id = AIF4_PB,
  10226. .playback = {
  10227. .stream_name = "AIF4 Playback",
  10228. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10229. .formats = TASHA_FORMATS_S16_S24_LE,
  10230. .rate_min = 8000,
  10231. .rate_max = 192000,
  10232. .channels_min = 1,
  10233. .channels_max = 2,
  10234. },
  10235. .ops = &tasha_dai_ops,
  10236. },
  10237. {
  10238. .name = "tasha_mix_rx1",
  10239. .id = AIF_MIX1_PB,
  10240. .playback = {
  10241. .stream_name = "AIF Mix Playback",
  10242. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10243. .formats = TASHA_FORMATS_S16_S24_LE,
  10244. .rate_min = 8000,
  10245. .rate_max = 192000,
  10246. .channels_min = 1,
  10247. .channels_max = 8,
  10248. },
  10249. .ops = &tasha_dai_ops,
  10250. },
  10251. {
  10252. .name = "tasha_mad1",
  10253. .id = AIF4_MAD_TX,
  10254. .capture = {
  10255. .stream_name = "AIF4 MAD TX",
  10256. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10257. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_384000,
  10258. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10259. .rate_min = 16000,
  10260. .rate_max = 384000,
  10261. .channels_min = 1,
  10262. .channels_max = 1,
  10263. },
  10264. .ops = &tasha_dai_ops,
  10265. },
  10266. {
  10267. .name = "tasha_vifeedback",
  10268. .id = AIF4_VIFEED,
  10269. .capture = {
  10270. .stream_name = "VIfeed",
  10271. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
  10272. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10273. .rate_max = 48000,
  10274. .rate_min = 8000,
  10275. .channels_min = 1,
  10276. .channels_max = 4,
  10277. },
  10278. .ops = &tasha_dai_ops,
  10279. },
  10280. {
  10281. .name = "tasha_cpe",
  10282. .id = AIF5_CPE_TX,
  10283. .capture = {
  10284. .stream_name = "AIF5 CPE TX",
  10285. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000,
  10286. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10287. .rate_min = 16000,
  10288. .rate_max = 48000,
  10289. .channels_min = 1,
  10290. .channels_max = 1,
  10291. },
  10292. },
  10293. };
  10294. static struct snd_soc_dai_driver tasha_i2s_dai[] = {
  10295. {
  10296. .name = "tasha_i2s_rx1",
  10297. .id = AIF1_PB,
  10298. .playback = {
  10299. .stream_name = "AIF1 Playback",
  10300. .rates = WCD9335_RATES_MASK,
  10301. .formats = TASHA_FORMATS_S16_S24_LE,
  10302. .rate_max = 192000,
  10303. .rate_min = 8000,
  10304. .channels_min = 1,
  10305. .channels_max = 2,
  10306. },
  10307. .ops = &tasha_dai_ops,
  10308. },
  10309. {
  10310. .name = "tasha_i2s_tx1",
  10311. .id = AIF1_CAP,
  10312. .capture = {
  10313. .stream_name = "AIF1 Capture",
  10314. .rates = WCD9335_RATES_MASK,
  10315. .formats = TASHA_FORMATS_S16_S24_LE,
  10316. .rate_max = 192000,
  10317. .rate_min = 8000,
  10318. .channels_min = 1,
  10319. .channels_max = 4,
  10320. },
  10321. .ops = &tasha_dai_ops,
  10322. },
  10323. {
  10324. .name = "tasha_i2s_rx2",
  10325. .id = AIF2_PB,
  10326. .playback = {
  10327. .stream_name = "AIF2 Playback",
  10328. .rates = WCD9335_RATES_MASK,
  10329. .formats = TASHA_FORMATS_S16_S24_LE,
  10330. .rate_max = 192000,
  10331. .rate_min = 8000,
  10332. .channels_min = 1,
  10333. .channels_max = 2,
  10334. },
  10335. .ops = &tasha_dai_ops,
  10336. },
  10337. {
  10338. .name = "tasha_i2s_tx2",
  10339. .id = AIF2_CAP,
  10340. .capture = {
  10341. .stream_name = "AIF2 Capture",
  10342. .rates = WCD9335_RATES_MASK,
  10343. .formats = TASHA_FORMATS_S16_S24_LE,
  10344. .rate_max = 192000,
  10345. .rate_min = 8000,
  10346. .channels_min = 1,
  10347. .channels_max = 4,
  10348. },
  10349. .ops = &tasha_dai_ops,
  10350. },
  10351. };
  10352. static void tasha_codec_power_gate_digital_core(struct tasha_priv *tasha)
  10353. {
  10354. struct snd_soc_codec *codec = tasha->codec;
  10355. if (!codec)
  10356. return;
  10357. mutex_lock(&tasha->power_lock);
  10358. dev_dbg(codec->dev, "%s: Entering power gating function, %d\n",
  10359. __func__, tasha->power_active_ref);
  10360. if (tasha->power_active_ref > 0)
  10361. goto exit;
  10362. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10363. WCD_REGION_POWER_COLLAPSE_BEGIN,
  10364. WCD9XXX_DIG_CORE_REGION_1);
  10365. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10366. 0x04, 0x04);
  10367. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10368. 0x01, 0x00);
  10369. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10370. 0x02, 0x00);
  10371. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10372. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  10373. wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_DOWN,
  10374. WCD9XXX_DIG_CORE_REGION_1);
  10375. exit:
  10376. dev_dbg(codec->dev, "%s: Exiting power gating function, %d\n",
  10377. __func__, tasha->power_active_ref);
  10378. mutex_unlock(&tasha->power_lock);
  10379. }
  10380. static void tasha_codec_power_gate_work(struct work_struct *work)
  10381. {
  10382. struct tasha_priv *tasha;
  10383. struct delayed_work *dwork;
  10384. struct snd_soc_codec *codec;
  10385. dwork = to_delayed_work(work);
  10386. tasha = container_of(dwork, struct tasha_priv, power_gate_work);
  10387. codec = tasha->codec;
  10388. if (!codec)
  10389. return;
  10390. tasha_codec_power_gate_digital_core(tasha);
  10391. }
  10392. /* called under power_lock acquisition */
  10393. static int tasha_dig_core_remove_power_collapse(struct snd_soc_codec *codec)
  10394. {
  10395. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10396. tasha_codec_vote_max_bw(codec, true);
  10397. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5);
  10398. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7);
  10399. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3);
  10400. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x00);
  10401. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x02);
  10402. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10403. WCD_REGION_POWER_COLLAPSE_REMOVE,
  10404. WCD9XXX_DIG_CORE_REGION_1);
  10405. regcache_mark_dirty(codec->component.regmap);
  10406. regcache_sync_region(codec->component.regmap,
  10407. TASHA_DIG_CORE_REG_MIN, TASHA_DIG_CORE_REG_MAX);
  10408. tasha_codec_vote_max_bw(codec, false);
  10409. return 0;
  10410. }
  10411. static int tasha_dig_core_power_collapse(struct tasha_priv *tasha,
  10412. int req_state)
  10413. {
  10414. struct snd_soc_codec *codec;
  10415. int cur_state;
  10416. /* Exit if feature is disabled */
  10417. if (!dig_core_collapse_enable)
  10418. return 0;
  10419. mutex_lock(&tasha->power_lock);
  10420. if (req_state == POWER_COLLAPSE)
  10421. tasha->power_active_ref--;
  10422. else if (req_state == POWER_RESUME)
  10423. tasha->power_active_ref++;
  10424. else
  10425. goto unlock_mutex;
  10426. if (tasha->power_active_ref < 0) {
  10427. dev_dbg(tasha->dev, "%s: power_active_ref is negative\n",
  10428. __func__);
  10429. goto unlock_mutex;
  10430. }
  10431. codec = tasha->codec;
  10432. if (!codec)
  10433. goto unlock_mutex;
  10434. if (req_state == POWER_COLLAPSE) {
  10435. if (tasha->power_active_ref == 0) {
  10436. schedule_delayed_work(&tasha->power_gate_work,
  10437. msecs_to_jiffies(dig_core_collapse_timer * 1000));
  10438. }
  10439. } else if (req_state == POWER_RESUME) {
  10440. if (tasha->power_active_ref == 1) {
  10441. /*
  10442. * At this point, there can be two cases:
  10443. * 1. Core already in power collapse state
  10444. * 2. Timer kicked in and still did not expire or
  10445. * waiting for the power_lock
  10446. */
  10447. cur_state = wcd9xxx_get_current_power_state(
  10448. tasha->wcd9xxx,
  10449. WCD9XXX_DIG_CORE_REGION_1);
  10450. if (cur_state == WCD_REGION_POWER_DOWN)
  10451. tasha_dig_core_remove_power_collapse(codec);
  10452. else {
  10453. mutex_unlock(&tasha->power_lock);
  10454. cancel_delayed_work_sync(
  10455. &tasha->power_gate_work);
  10456. mutex_lock(&tasha->power_lock);
  10457. }
  10458. }
  10459. }
  10460. unlock_mutex:
  10461. mutex_unlock(&tasha->power_lock);
  10462. return 0;
  10463. }
  10464. static int __tasha_cdc_mclk_enable_locked(struct tasha_priv *tasha,
  10465. bool enable)
  10466. {
  10467. int ret = 0;
  10468. if (!tasha->wcd_ext_clk) {
  10469. dev_err(tasha->dev, "%s: wcd ext clock is NULL\n", __func__);
  10470. return -EINVAL;
  10471. }
  10472. dev_dbg(tasha->dev, "%s: mclk_enable = %u\n", __func__, enable);
  10473. if (enable) {
  10474. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10475. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10476. if (ret)
  10477. goto err;
  10478. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10479. tasha_codec_apply_sido_voltage(tasha,
  10480. SIDO_VOLTAGE_NOMINAL_MV);
  10481. } else {
  10482. if (!dig_core_collapse_enable) {
  10483. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10484. tasha_codec_update_sido_voltage(tasha,
  10485. sido_buck_svs_voltage);
  10486. }
  10487. tasha_cdc_req_mclk_enable(tasha, false);
  10488. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10489. }
  10490. err:
  10491. return ret;
  10492. }
  10493. static int __tasha_cdc_mclk_enable(struct tasha_priv *tasha,
  10494. bool enable)
  10495. {
  10496. int ret;
  10497. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10498. ret = __tasha_cdc_mclk_enable_locked(tasha, enable);
  10499. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10500. return ret;
  10501. }
  10502. int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10503. {
  10504. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10505. return __tasha_cdc_mclk_enable(tasha, enable);
  10506. }
  10507. EXPORT_SYMBOL(tasha_cdc_mclk_enable);
  10508. int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10509. {
  10510. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10511. int ret = 0;
  10512. dev_dbg(tasha->dev, "%s: clk_mode: %d, enable: %d, clk_internal: %d\n",
  10513. __func__, tasha->clk_mode, enable, tasha->clk_internal);
  10514. if (tasha->clk_mode || tasha->clk_internal) {
  10515. if (enable) {
  10516. tasha_cdc_sido_ccl_enable(tasha, true);
  10517. wcd_resmgr_enable_master_bias(tasha->resmgr);
  10518. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10519. snd_soc_update_bits(codec,
  10520. WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
  10521. 0x01, 0x01);
  10522. snd_soc_update_bits(codec,
  10523. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  10524. 0x01, 0x01);
  10525. set_bit(CPE_NOMINAL, &tasha->status_mask);
  10526. tasha_codec_update_sido_voltage(tasha,
  10527. SIDO_VOLTAGE_NOMINAL_MV);
  10528. tasha->clk_internal = true;
  10529. } else {
  10530. tasha->clk_internal = false;
  10531. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  10532. tasha_codec_update_sido_voltage(tasha,
  10533. sido_buck_svs_voltage);
  10534. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10535. wcd_resmgr_disable_master_bias(tasha->resmgr);
  10536. tasha_cdc_sido_ccl_enable(tasha, false);
  10537. }
  10538. } else {
  10539. ret = __tasha_cdc_mclk_enable(tasha, enable);
  10540. }
  10541. return ret;
  10542. }
  10543. EXPORT_SYMBOL(tasha_cdc_mclk_tx_enable);
  10544. static ssize_t tasha_codec_version_read(struct snd_info_entry *entry,
  10545. void *file_private_data, struct file *file,
  10546. char __user *buf, size_t count, loff_t pos)
  10547. {
  10548. struct tasha_priv *tasha;
  10549. struct wcd9xxx *wcd9xxx;
  10550. char buffer[TASHA_VERSION_ENTRY_SIZE];
  10551. int len = 0;
  10552. tasha = (struct tasha_priv *) entry->private_data;
  10553. if (!tasha) {
  10554. pr_err("%s: tasha priv is null\n", __func__);
  10555. return -EINVAL;
  10556. }
  10557. wcd9xxx = tasha->wcd9xxx;
  10558. if (wcd9xxx->codec_type->id_major == TASHA_MAJOR) {
  10559. if (TASHA_IS_1_0(wcd9xxx))
  10560. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_0\n");
  10561. else if (TASHA_IS_1_1(wcd9xxx))
  10562. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_1\n");
  10563. else
  10564. snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10565. } else if (wcd9xxx->codec_type->id_major == TASHA2P0_MAJOR) {
  10566. len = snprintf(buffer, sizeof(buffer), "WCD9335_2_0\n");
  10567. } else
  10568. len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10569. return simple_read_from_buffer(buf, count, &pos, buffer, len);
  10570. }
  10571. static struct snd_info_entry_ops tasha_codec_info_ops = {
  10572. .read = tasha_codec_version_read,
  10573. };
  10574. /*
  10575. * tasha_codec_info_create_codec_entry - creates wcd9335 module
  10576. * @codec_root: The parent directory
  10577. * @codec: Codec instance
  10578. *
  10579. * Creates wcd9335 module and version entry under the given
  10580. * parent directory.
  10581. *
  10582. * Return: 0 on success or negative error code on failure.
  10583. */
  10584. int tasha_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
  10585. struct snd_soc_codec *codec)
  10586. {
  10587. struct snd_info_entry *version_entry;
  10588. struct tasha_priv *tasha;
  10589. struct snd_soc_card *card;
  10590. if (!codec_root || !codec)
  10591. return -EINVAL;
  10592. tasha = snd_soc_codec_get_drvdata(codec);
  10593. card = codec->component.card;
  10594. tasha->entry = snd_info_create_subdir(codec_root->module,
  10595. "tasha", codec_root);
  10596. if (!tasha->entry) {
  10597. dev_dbg(codec->dev, "%s: failed to create wcd9335 entry\n",
  10598. __func__);
  10599. return -ENOMEM;
  10600. }
  10601. version_entry = snd_info_create_card_entry(card->snd_card,
  10602. "version",
  10603. tasha->entry);
  10604. if (!version_entry) {
  10605. dev_dbg(codec->dev, "%s: failed to create wcd9335 version entry\n",
  10606. __func__);
  10607. return -ENOMEM;
  10608. }
  10609. version_entry->private_data = tasha;
  10610. version_entry->size = TASHA_VERSION_ENTRY_SIZE;
  10611. version_entry->content = SNDRV_INFO_CONTENT_DATA;
  10612. version_entry->c.ops = &tasha_codec_info_ops;
  10613. if (snd_info_register(version_entry) < 0) {
  10614. snd_info_free_entry(version_entry);
  10615. return -ENOMEM;
  10616. }
  10617. tasha->version_entry = version_entry;
  10618. return 0;
  10619. }
  10620. EXPORT_SYMBOL(tasha_codec_info_create_codec_entry);
  10621. static int __tasha_codec_internal_rco_ctrl(
  10622. struct snd_soc_codec *codec, bool enable)
  10623. {
  10624. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10625. int ret = 0;
  10626. if (enable) {
  10627. tasha_cdc_sido_ccl_enable(tasha, true);
  10628. if (wcd_resmgr_get_clk_type(tasha->resmgr) ==
  10629. WCD_CLK_RCO) {
  10630. ret = wcd_resmgr_enable_clk_block(tasha->resmgr,
  10631. WCD_CLK_RCO);
  10632. } else {
  10633. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10634. ret |= wcd_resmgr_enable_clk_block(tasha->resmgr,
  10635. WCD_CLK_RCO);
  10636. ret |= tasha_cdc_req_mclk_enable(tasha, false);
  10637. }
  10638. } else {
  10639. ret = wcd_resmgr_disable_clk_block(tasha->resmgr,
  10640. WCD_CLK_RCO);
  10641. tasha_cdc_sido_ccl_enable(tasha, false);
  10642. }
  10643. if (ret) {
  10644. dev_err(codec->dev, "%s: Error in %s RCO\n",
  10645. __func__, (enable ? "enabling" : "disabling"));
  10646. ret = -EINVAL;
  10647. }
  10648. return ret;
  10649. }
  10650. /*
  10651. * tasha_codec_internal_rco_ctrl()
  10652. * Make sure that the caller does not acquire
  10653. * BG_CLK_LOCK.
  10654. */
  10655. static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
  10656. bool enable)
  10657. {
  10658. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10659. int ret = 0;
  10660. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10661. ret = __tasha_codec_internal_rco_ctrl(codec, enable);
  10662. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10663. return ret;
  10664. }
  10665. /*
  10666. * tasha_mbhc_hs_detect: starts mbhc insertion/removal functionality
  10667. * @codec: handle to snd_soc_codec *
  10668. * @mbhc_cfg: handle to mbhc configuration structure
  10669. * return 0 if mbhc_start is success or error code in case of failure
  10670. */
  10671. int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
  10672. struct wcd_mbhc_config *mbhc_cfg)
  10673. {
  10674. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10675. return wcd_mbhc_start(&tasha->mbhc, mbhc_cfg);
  10676. }
  10677. EXPORT_SYMBOL(tasha_mbhc_hs_detect);
  10678. /*
  10679. * tasha_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
  10680. * @codec: handle to snd_soc_codec *
  10681. */
  10682. void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
  10683. {
  10684. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10685. wcd_mbhc_stop(&tasha->mbhc);
  10686. }
  10687. EXPORT_SYMBOL(tasha_mbhc_hs_detect_exit);
  10688. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv)
  10689. {
  10690. /* min micbias voltage is 1V and maximum is 2.85V */
  10691. if (micb_mv < 1000 || micb_mv > 2850) {
  10692. pr_err("%s: unsupported micbias voltage\n", __func__);
  10693. return -EINVAL;
  10694. }
  10695. return (micb_mv - 1000) / 50;
  10696. }
  10697. static const struct tasha_reg_mask_val tasha_reg_update_reset_val_1_1[] = {
  10698. {WCD9335_RCO_CTRL_2, 0xFF, 0x47},
  10699. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10700. };
  10701. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_1[] = {
  10702. {WCD9335_FLYBACK_VNEG_DAC_CTRL_1, 0xFF, 0x65},
  10703. {WCD9335_FLYBACK_VNEG_DAC_CTRL_2, 0xFF, 0x52},
  10704. {WCD9335_FLYBACK_VNEG_DAC_CTRL_3, 0xFF, 0xAF},
  10705. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10706. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0xF4},
  10707. {WCD9335_FLYBACK_VNEG_CTRL_9, 0xFF, 0x40},
  10708. {WCD9335_FLYBACK_VNEG_CTRL_2, 0xFF, 0x4F},
  10709. {WCD9335_FLYBACK_EN, 0xFF, 0x6E},
  10710. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xF8, 0xF8},
  10711. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xF8, 0xF8},
  10712. };
  10713. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_0[] = {
  10714. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0x54},
  10715. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xFC, 0xFC},
  10716. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xFC, 0xFC},
  10717. };
  10718. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_2_0[] = {
  10719. {WCD9335_RCO_CTRL_2, 0x0F, 0x08},
  10720. {WCD9335_RX_BIAS_FLYB_MID_RST, 0xF0, 0x10},
  10721. {WCD9335_FLYBACK_CTRL_1, 0x20, 0x20},
  10722. {WCD9335_HPH_OCP_CTL, 0xFF, 0x7A},
  10723. {WCD9335_HPH_L_TEST, 0x01, 0x01},
  10724. {WCD9335_HPH_R_TEST, 0x01, 0x01},
  10725. {WCD9335_CDC_BOOST0_BOOST_CFG1, 0x3F, 0x12},
  10726. {WCD9335_CDC_BOOST0_BOOST_CFG2, 0x1C, 0x08},
  10727. {WCD9335_CDC_COMPANDER7_CTL7, 0x1E, 0x18},
  10728. {WCD9335_CDC_BOOST1_BOOST_CFG1, 0x3F, 0x12},
  10729. {WCD9335_CDC_BOOST1_BOOST_CFG2, 0x1C, 0x08},
  10730. {WCD9335_CDC_COMPANDER8_CTL7, 0x1E, 0x18},
  10731. {WCD9335_CDC_TX0_TX_PATH_SEC7, 0xFF, 0x45},
  10732. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xFC, 0xF4},
  10733. {WCD9335_HPH_REFBUFF_LP_CTL, 0x08, 0x08},
  10734. {WCD9335_HPH_REFBUFF_LP_CTL, 0x06, 0x02},
  10735. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xA0},
  10736. {WCD9335_SE_LO_COM1, 0xFF, 0xC0},
  10737. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xFC, 0xF4},
  10738. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xFC, 0xF4},
  10739. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xFC, 0xF8},
  10740. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xFC, 0xF8},
  10741. };
  10742. static const struct tasha_reg_mask_val tasha_codec_reg_defaults[] = {
  10743. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x00},
  10744. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x01},
  10745. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x04, 0x04},
  10746. };
  10747. static const struct tasha_reg_mask_val tasha_codec_reg_i2c_defaults[] = {
  10748. {WCD9335_ANA_CLK_TOP, 0x20, 0x20},
  10749. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x01},
  10750. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x00},
  10751. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x05, 0x05},
  10752. {WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG, 0x01, 0x01},
  10753. {WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG, 0x01, 0x01},
  10754. {WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG, 0x01, 0x01},
  10755. {WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG, 0x01, 0x01},
  10756. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG, 0x05, 0x05},
  10757. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG, 0x05, 0x05},
  10758. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG, 0x05, 0x05},
  10759. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG, 0x05, 0x05},
  10760. };
  10761. static const struct tasha_reg_mask_val tasha_codec_reg_init_common_val[] = {
  10762. /* Rbuckfly/R_EAR(32) */
  10763. {WCD9335_CDC_CLSH_K2_MSB, 0x0F, 0x00},
  10764. {WCD9335_CDC_CLSH_K2_LSB, 0xFF, 0x60},
  10765. {WCD9335_CPE_SS_DMIC_CFG, 0x80, 0x00},
  10766. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x70, 0x50},
  10767. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x70, 0x50},
  10768. {WCD9335_CDC_RX7_RX_PATH_CFG1, 0x08, 0x08},
  10769. {WCD9335_CDC_RX8_RX_PATH_CFG1, 0x08, 0x08},
  10770. {WCD9335_ANA_LO_1_2, 0x3C, 0X3C},
  10771. {WCD9335_DIFF_LO_COM_SWCAP_REFBUF_FREQ, 0x70, 0x00},
  10772. {WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03, 0x03},
  10773. {WCD9335_CDC_TOP_TOP_CFG1, 0x02, 0x02},
  10774. {WCD9335_CDC_TOP_TOP_CFG1, 0x01, 0x01},
  10775. {WCD9335_EAR_CMBUFF, 0x08, 0x00},
  10776. {WCD9335_CDC_TX9_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10777. {WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10778. {WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10779. {WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10780. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  10781. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  10782. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  10783. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  10784. {WCD9335_CDC_RX0_RX_PATH_CFG0, 0x01, 0x01},
  10785. {WCD9335_CDC_RX1_RX_PATH_CFG0, 0x01, 0x01},
  10786. {WCD9335_CDC_RX2_RX_PATH_CFG0, 0x01, 0x01},
  10787. {WCD9335_CDC_RX3_RX_PATH_CFG0, 0x01, 0x01},
  10788. {WCD9335_CDC_RX4_RX_PATH_CFG0, 0x01, 0x01},
  10789. {WCD9335_CDC_RX5_RX_PATH_CFG0, 0x01, 0x01},
  10790. {WCD9335_CDC_RX6_RX_PATH_CFG0, 0x01, 0x01},
  10791. {WCD9335_CDC_RX7_RX_PATH_CFG0, 0x01, 0x01},
  10792. {WCD9335_CDC_RX8_RX_PATH_CFG0, 0x01, 0x01},
  10793. {WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 0x01, 0x01},
  10794. {WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 0x01, 0x01},
  10795. {WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 0x01, 0x01},
  10796. {WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 0x01, 0x01},
  10797. {WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 0x01, 0x01},
  10798. {WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 0x01, 0x01},
  10799. {WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 0x01, 0x01},
  10800. {WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 0x01, 0x01},
  10801. {WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 0x01, 0x01},
  10802. {WCD9335_VBADC_IBIAS_FE, 0x0C, 0x08},
  10803. };
  10804. static const struct tasha_reg_mask_val tasha_codec_reg_init_1_x_val[] = {
  10805. /* Enable TX HPF Filter & Linear Phase */
  10806. {WCD9335_CDC_TX0_TX_PATH_CFG0, 0x11, 0x11},
  10807. {WCD9335_CDC_TX1_TX_PATH_CFG0, 0x11, 0x11},
  10808. {WCD9335_CDC_TX2_TX_PATH_CFG0, 0x11, 0x11},
  10809. {WCD9335_CDC_TX3_TX_PATH_CFG0, 0x11, 0x11},
  10810. {WCD9335_CDC_TX4_TX_PATH_CFG0, 0x11, 0x11},
  10811. {WCD9335_CDC_TX5_TX_PATH_CFG0, 0x11, 0x11},
  10812. {WCD9335_CDC_TX6_TX_PATH_CFG0, 0x11, 0x11},
  10813. {WCD9335_CDC_TX7_TX_PATH_CFG0, 0x11, 0x11},
  10814. {WCD9335_CDC_TX8_TX_PATH_CFG0, 0x11, 0x11},
  10815. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xF8, 0xF8},
  10816. {WCD9335_CDC_RX0_RX_PATH_SEC1, 0x08, 0x08},
  10817. {WCD9335_CDC_RX1_RX_PATH_SEC1, 0x08, 0x08},
  10818. {WCD9335_CDC_RX2_RX_PATH_SEC1, 0x08, 0x08},
  10819. {WCD9335_CDC_RX3_RX_PATH_SEC1, 0x08, 0x08},
  10820. {WCD9335_CDC_RX4_RX_PATH_SEC1, 0x08, 0x08},
  10821. {WCD9335_CDC_RX5_RX_PATH_SEC1, 0x08, 0x08},
  10822. {WCD9335_CDC_RX6_RX_PATH_SEC1, 0x08, 0x08},
  10823. {WCD9335_CDC_RX7_RX_PATH_SEC1, 0x08, 0x08},
  10824. {WCD9335_CDC_RX8_RX_PATH_SEC1, 0x08, 0x08},
  10825. {WCD9335_CDC_RX0_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10826. {WCD9335_CDC_RX1_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10827. {WCD9335_CDC_RX2_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10828. {WCD9335_CDC_RX3_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10829. {WCD9335_CDC_RX4_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10830. {WCD9335_CDC_RX5_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10831. {WCD9335_CDC_RX6_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10832. {WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10833. {WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10834. {WCD9335_CDC_TX0_TX_PATH_SEC2, 0x01, 0x01},
  10835. {WCD9335_CDC_TX1_TX_PATH_SEC2, 0x01, 0x01},
  10836. {WCD9335_CDC_TX2_TX_PATH_SEC2, 0x01, 0x01},
  10837. {WCD9335_CDC_TX3_TX_PATH_SEC2, 0x01, 0x01},
  10838. {WCD9335_CDC_TX4_TX_PATH_SEC2, 0x01, 0x01},
  10839. {WCD9335_CDC_TX5_TX_PATH_SEC2, 0x01, 0x01},
  10840. {WCD9335_CDC_TX6_TX_PATH_SEC2, 0x01, 0x01},
  10841. {WCD9335_CDC_TX7_TX_PATH_SEC2, 0x01, 0x01},
  10842. {WCD9335_CDC_TX8_TX_PATH_SEC2, 0x01, 0x01},
  10843. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xF8, 0xF0},
  10844. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xF8, 0xF0},
  10845. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xF8, 0xF8},
  10846. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xF8, 0xF8},
  10847. {WCD9335_RX_OCP_COUNT, 0xFF, 0xFF},
  10848. {WCD9335_HPH_OCP_CTL, 0xF0, 0x70},
  10849. {WCD9335_CPE_SS_CPAR_CFG, 0xFF, 0x00},
  10850. {WCD9335_FLYBACK_VNEG_CTRL_1, 0xFF, 0x63},
  10851. {WCD9335_FLYBACK_VNEG_CTRL_4, 0xFF, 0x7F},
  10852. {WCD9335_CLASSH_CTRL_VCL_1, 0xFF, 0x60},
  10853. {WCD9335_CLASSH_CTRL_CCL_5, 0xFF, 0x40},
  10854. {WCD9335_RX_TIMER_DIV, 0xFF, 0x32},
  10855. {WCD9335_SE_LO_COM2, 0xFF, 0x01},
  10856. {WCD9335_MBHC_ZDET_ANA_CTL, 0x0F, 0x07},
  10857. {WCD9335_RX_BIAS_HPH_PA, 0xF0, 0x60},
  10858. {WCD9335_HPH_RDAC_LDO_CTL, 0x88, 0x88},
  10859. {WCD9335_HPH_L_EN, 0x20, 0x20},
  10860. {WCD9335_HPH_R_EN, 0x20, 0x20},
  10861. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xD8},
  10862. {WCD9335_CDC_RX5_RX_PATH_SEC3, 0xBD, 0xBD},
  10863. {WCD9335_CDC_RX6_RX_PATH_SEC3, 0xBD, 0xBD},
  10864. {WCD9335_DIFF_LO_COM_PA_FREQ, 0x70, 0x40},
  10865. };
  10866. static void tasha_update_reg_reset_values(struct snd_soc_codec *codec)
  10867. {
  10868. u32 i;
  10869. struct wcd9xxx *tasha_core = dev_get_drvdata(codec->dev->parent);
  10870. if (TASHA_IS_1_1(tasha_core)) {
  10871. for (i = 0; i < ARRAY_SIZE(tasha_reg_update_reset_val_1_1);
  10872. i++)
  10873. snd_soc_write(codec,
  10874. tasha_reg_update_reset_val_1_1[i].reg,
  10875. tasha_reg_update_reset_val_1_1[i].val);
  10876. }
  10877. }
  10878. static void tasha_codec_init_reg(struct snd_soc_codec *codec)
  10879. {
  10880. u32 i;
  10881. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  10882. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_common_val); i++)
  10883. snd_soc_update_bits(codec,
  10884. tasha_codec_reg_init_common_val[i].reg,
  10885. tasha_codec_reg_init_common_val[i].mask,
  10886. tasha_codec_reg_init_common_val[i].val);
  10887. if (TASHA_IS_1_1(wcd9xxx) ||
  10888. TASHA_IS_1_0(wcd9xxx))
  10889. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_1_x_val); i++)
  10890. snd_soc_update_bits(codec,
  10891. tasha_codec_reg_init_1_x_val[i].reg,
  10892. tasha_codec_reg_init_1_x_val[i].mask,
  10893. tasha_codec_reg_init_1_x_val[i].val);
  10894. if (TASHA_IS_1_1(wcd9xxx)) {
  10895. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_1); i++)
  10896. snd_soc_update_bits(codec,
  10897. tasha_codec_reg_init_val_1_1[i].reg,
  10898. tasha_codec_reg_init_val_1_1[i].mask,
  10899. tasha_codec_reg_init_val_1_1[i].val);
  10900. } else if (TASHA_IS_1_0(wcd9xxx)) {
  10901. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_0); i++)
  10902. snd_soc_update_bits(codec,
  10903. tasha_codec_reg_init_val_1_0[i].reg,
  10904. tasha_codec_reg_init_val_1_0[i].mask,
  10905. tasha_codec_reg_init_val_1_0[i].val);
  10906. } else if (TASHA_IS_2_0(wcd9xxx)) {
  10907. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_2_0); i++)
  10908. snd_soc_update_bits(codec,
  10909. tasha_codec_reg_init_val_2_0[i].reg,
  10910. tasha_codec_reg_init_val_2_0[i].mask,
  10911. tasha_codec_reg_init_val_2_0[i].val);
  10912. }
  10913. }
  10914. static void tasha_update_reg_defaults(struct tasha_priv *tasha)
  10915. {
  10916. u32 i;
  10917. struct wcd9xxx *wcd9xxx;
  10918. wcd9xxx = tasha->wcd9xxx;
  10919. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_defaults); i++)
  10920. regmap_update_bits(wcd9xxx->regmap,
  10921. tasha_codec_reg_defaults[i].reg,
  10922. tasha_codec_reg_defaults[i].mask,
  10923. tasha_codec_reg_defaults[i].val);
  10924. tasha->intf_type = wcd9xxx_get_intf_type();
  10925. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  10926. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_i2c_defaults); i++)
  10927. regmap_update_bits(wcd9xxx->regmap,
  10928. tasha_codec_reg_i2c_defaults[i].reg,
  10929. tasha_codec_reg_i2c_defaults[i].mask,
  10930. tasha_codec_reg_i2c_defaults[i].val);
  10931. }
  10932. static void tasha_slim_interface_init_reg(struct snd_soc_codec *codec)
  10933. {
  10934. int i;
  10935. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  10936. for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++)
  10937. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  10938. TASHA_SLIM_PGD_PORT_INT_EN0 + i,
  10939. 0xFF);
  10940. }
  10941. static irqreturn_t tasha_slimbus_irq(int irq, void *data)
  10942. {
  10943. struct tasha_priv *priv = data;
  10944. unsigned long status = 0;
  10945. int i, j, port_id, k;
  10946. u32 bit;
  10947. u8 val, int_val = 0;
  10948. bool tx, cleared;
  10949. unsigned short reg = 0;
  10950. for (i = TASHA_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
  10951. i <= TASHA_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
  10952. val = wcd9xxx_interface_reg_read(priv->wcd9xxx, i);
  10953. status |= ((u32)val << (8 * j));
  10954. }
  10955. for_each_set_bit(j, &status, 32) {
  10956. tx = (j >= 16 ? true : false);
  10957. port_id = (tx ? j - 16 : j);
  10958. val = wcd9xxx_interface_reg_read(priv->wcd9xxx,
  10959. TASHA_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
  10960. if (val) {
  10961. if (!tx)
  10962. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  10963. (port_id / 8);
  10964. else
  10965. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  10966. (port_id / 8);
  10967. int_val = wcd9xxx_interface_reg_read(
  10968. priv->wcd9xxx, reg);
  10969. /*
  10970. * Ignore interrupts for ports for which the
  10971. * interrupts are not specifically enabled.
  10972. */
  10973. if (!(int_val & (1 << (port_id % 8))))
  10974. continue;
  10975. }
  10976. if (val & TASHA_SLIM_IRQ_OVERFLOW)
  10977. pr_err_ratelimited(
  10978. "%s: overflow error on %s port %d, value %x\n",
  10979. __func__, (tx ? "TX" : "RX"), port_id, val);
  10980. if (val & TASHA_SLIM_IRQ_UNDERFLOW)
  10981. pr_err_ratelimited(
  10982. "%s: underflow error on %s port %d, value %x\n",
  10983. __func__, (tx ? "TX" : "RX"), port_id, val);
  10984. if ((val & TASHA_SLIM_IRQ_OVERFLOW) ||
  10985. (val & TASHA_SLIM_IRQ_UNDERFLOW)) {
  10986. if (!tx)
  10987. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  10988. (port_id / 8);
  10989. else
  10990. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  10991. (port_id / 8);
  10992. int_val = wcd9xxx_interface_reg_read(
  10993. priv->wcd9xxx, reg);
  10994. if (int_val & (1 << (port_id % 8))) {
  10995. int_val = int_val ^ (1 << (port_id % 8));
  10996. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  10997. reg, int_val);
  10998. }
  10999. }
  11000. if (val & TASHA_SLIM_IRQ_PORT_CLOSED) {
  11001. /*
  11002. * INT SOURCE register starts from RX to TX
  11003. * but port number in the ch_mask is in opposite way
  11004. */
  11005. bit = (tx ? j - 16 : j + 16);
  11006. pr_debug("%s: %s port %d closed value %x, bit %u\n",
  11007. __func__, (tx ? "TX" : "RX"), port_id, val,
  11008. bit);
  11009. for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) {
  11010. pr_debug("%s: priv->dai[%d].ch_mask = 0x%lx\n",
  11011. __func__, k, priv->dai[k].ch_mask);
  11012. if (test_and_clear_bit(bit,
  11013. &priv->dai[k].ch_mask)) {
  11014. cleared = true;
  11015. if (!priv->dai[k].ch_mask)
  11016. wake_up(&priv->dai[k].dai_wait);
  11017. /*
  11018. * There are cases when multiple DAIs
  11019. * might be using the same slimbus
  11020. * channel. Hence don't break here.
  11021. */
  11022. }
  11023. }
  11024. WARN(!cleared,
  11025. "Couldn't find slimbus %s port %d for closing\n",
  11026. (tx ? "TX" : "RX"), port_id);
  11027. }
  11028. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11029. TASHA_SLIM_PGD_PORT_INT_CLR_RX_0 +
  11030. (j / 8),
  11031. 1 << (j % 8));
  11032. }
  11033. return IRQ_HANDLED;
  11034. }
  11035. static int tasha_setup_irqs(struct tasha_priv *tasha)
  11036. {
  11037. int ret = 0;
  11038. struct snd_soc_codec *codec = tasha->codec;
  11039. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11040. struct wcd9xxx_core_resource *core_res =
  11041. &wcd9xxx->core_res;
  11042. ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS,
  11043. tasha_slimbus_irq, "SLIMBUS Slave", tasha);
  11044. if (ret)
  11045. pr_err("%s: Failed to request irq %d\n", __func__,
  11046. WCD9XXX_IRQ_SLIMBUS);
  11047. else
  11048. tasha_slim_interface_init_reg(codec);
  11049. return ret;
  11050. }
  11051. static void tasha_init_slim_slave_cfg(struct snd_soc_codec *codec)
  11052. {
  11053. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11054. struct afe_param_cdc_slimbus_slave_cfg *cfg;
  11055. struct wcd9xxx *wcd9xxx = priv->wcd9xxx;
  11056. uint64_t eaddr = 0;
  11057. cfg = &priv->slimbus_slave_cfg;
  11058. cfg->minor_version = 1;
  11059. cfg->tx_slave_port_offset = 0;
  11060. cfg->rx_slave_port_offset = 16;
  11061. memcpy(&eaddr, &wcd9xxx->slim->e_addr, sizeof(wcd9xxx->slim->e_addr));
  11062. WARN_ON(sizeof(wcd9xxx->slim->e_addr) != 6);
  11063. cfg->device_enum_addr_lsw = eaddr & 0xFFFFFFFF;
  11064. cfg->device_enum_addr_msw = eaddr >> 32;
  11065. dev_dbg(codec->dev, "%s: slimbus logical address 0x%llx\n",
  11066. __func__, eaddr);
  11067. }
  11068. static void tasha_cleanup_irqs(struct tasha_priv *tasha)
  11069. {
  11070. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11071. struct wcd9xxx_core_resource *core_res =
  11072. &wcd9xxx->core_res;
  11073. wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tasha);
  11074. }
  11075. static int tasha_handle_pdata(struct tasha_priv *tasha,
  11076. struct wcd9xxx_pdata *pdata)
  11077. {
  11078. struct snd_soc_codec *codec = tasha->codec;
  11079. u8 dmic_ctl_val, mad_dmic_ctl_val;
  11080. u8 anc_ctl_value;
  11081. u32 def_dmic_rate, dmic_clk_drv;
  11082. int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4;
  11083. int rc = 0;
  11084. if (!pdata) {
  11085. dev_err(codec->dev, "%s: NULL pdata\n", __func__);
  11086. return -ENODEV;
  11087. }
  11088. /* set micbias voltage */
  11089. vout_ctl_1 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb1_mv);
  11090. vout_ctl_2 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb2_mv);
  11091. vout_ctl_3 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb3_mv);
  11092. vout_ctl_4 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb4_mv);
  11093. if (vout_ctl_1 < 0 || vout_ctl_2 < 0 ||
  11094. vout_ctl_3 < 0 || vout_ctl_4 < 0) {
  11095. rc = -EINVAL;
  11096. goto done;
  11097. }
  11098. snd_soc_update_bits(codec, WCD9335_ANA_MICB1, 0x3F, vout_ctl_1);
  11099. snd_soc_update_bits(codec, WCD9335_ANA_MICB2, 0x3F, vout_ctl_2);
  11100. snd_soc_update_bits(codec, WCD9335_ANA_MICB3, 0x3F, vout_ctl_3);
  11101. snd_soc_update_bits(codec, WCD9335_ANA_MICB4, 0x3F, vout_ctl_4);
  11102. /* Set the DMIC sample rate */
  11103. switch (pdata->mclk_rate) {
  11104. case TASHA_MCLK_CLK_9P6MHZ:
  11105. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  11106. break;
  11107. case TASHA_MCLK_CLK_12P288MHZ:
  11108. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ;
  11109. break;
  11110. default:
  11111. /* should never happen */
  11112. dev_err(codec->dev, "%s: Invalid mclk_rate %d\n",
  11113. __func__, pdata->mclk_rate);
  11114. rc = -EINVAL;
  11115. goto done;
  11116. };
  11117. if (pdata->dmic_sample_rate ==
  11118. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11119. dev_info(codec->dev, "%s: dmic_rate invalid default = %d\n",
  11120. __func__, def_dmic_rate);
  11121. pdata->dmic_sample_rate = def_dmic_rate;
  11122. }
  11123. if (pdata->mad_dmic_sample_rate ==
  11124. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11125. dev_info(codec->dev, "%s: mad_dmic_rate invalid default = %d\n",
  11126. __func__, def_dmic_rate);
  11127. /*
  11128. * use dmic_sample_rate as the default for MAD
  11129. * if mad dmic sample rate is undefined
  11130. */
  11131. pdata->mad_dmic_sample_rate = pdata->dmic_sample_rate;
  11132. }
  11133. if (pdata->ecpp_dmic_sample_rate ==
  11134. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11135. dev_info(codec->dev,
  11136. "%s: ecpp_dmic_rate invalid default = %d\n",
  11137. __func__, def_dmic_rate);
  11138. /*
  11139. * use dmic_sample_rate as the default for ECPP DMIC
  11140. * if ecpp dmic sample rate is undefined
  11141. */
  11142. pdata->ecpp_dmic_sample_rate = pdata->dmic_sample_rate;
  11143. }
  11144. if (pdata->dmic_clk_drv ==
  11145. WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED) {
  11146. pdata->dmic_clk_drv = WCD9335_DMIC_CLK_DRIVE_DEFAULT;
  11147. dev_info(codec->dev,
  11148. "%s: dmic_clk_strength invalid, default = %d\n",
  11149. __func__, pdata->dmic_clk_drv);
  11150. }
  11151. switch (pdata->dmic_clk_drv) {
  11152. case 2:
  11153. dmic_clk_drv = 0;
  11154. break;
  11155. case 4:
  11156. dmic_clk_drv = 1;
  11157. break;
  11158. case 8:
  11159. dmic_clk_drv = 2;
  11160. break;
  11161. case 16:
  11162. dmic_clk_drv = 3;
  11163. break;
  11164. default:
  11165. dev_err(codec->dev,
  11166. "%s: invalid dmic_clk_drv %d, using default\n",
  11167. __func__, pdata->dmic_clk_drv);
  11168. dmic_clk_drv = 0;
  11169. break;
  11170. }
  11171. snd_soc_update_bits(codec, WCD9335_TEST_DEBUG_PAD_DRVCTL,
  11172. 0x0C, dmic_clk_drv << 2);
  11173. /*
  11174. * Default the DMIC clk rates to mad_dmic_sample_rate,
  11175. * whereas, the anc/txfe dmic rates to dmic_sample_rate
  11176. * since the anc/txfe are independent of mad block.
  11177. */
  11178. mad_dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11179. pdata->mclk_rate,
  11180. pdata->mad_dmic_sample_rate);
  11181. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC0_CTL,
  11182. 0x0E, mad_dmic_ctl_val << 1);
  11183. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC1_CTL,
  11184. 0x0E, mad_dmic_ctl_val << 1);
  11185. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC2_CTL,
  11186. 0x0E, mad_dmic_ctl_val << 1);
  11187. dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11188. pdata->mclk_rate,
  11189. pdata->dmic_sample_rate);
  11190. if (dmic_ctl_val == WCD9335_DMIC_CLK_DIV_2)
  11191. anc_ctl_value = WCD9335_ANC_DMIC_X2_FULL_RATE;
  11192. else
  11193. anc_ctl_value = WCD9335_ANC_DMIC_X2_HALF_RATE;
  11194. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11195. 0x40, anc_ctl_value << 6);
  11196. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11197. 0x20, anc_ctl_value << 5);
  11198. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11199. 0x40, anc_ctl_value << 6);
  11200. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11201. 0x20, anc_ctl_value << 5);
  11202. done:
  11203. return rc;
  11204. }
  11205. static struct wcd_cpe_core *tasha_codec_get_cpe_core(
  11206. struct snd_soc_codec *codec)
  11207. {
  11208. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11209. return priv->cpe_core;
  11210. }
  11211. static int tasha_codec_cpe_fll_update_divider(
  11212. struct snd_soc_codec *codec, u32 cpe_fll_rate)
  11213. {
  11214. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11215. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11216. u32 div_val = 0, l_val = 0;
  11217. u32 computed_cpe_fll;
  11218. if (cpe_fll_rate != CPE_FLL_CLK_75MHZ &&
  11219. cpe_fll_rate != CPE_FLL_CLK_150MHZ) {
  11220. dev_err(codec->dev,
  11221. "%s: Invalid CPE fll rate request %u\n",
  11222. __func__, cpe_fll_rate);
  11223. return -EINVAL;
  11224. }
  11225. if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_12P288MHZ) {
  11226. /* update divider to 10 and enable 5x divider */
  11227. snd_soc_write(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11228. 0x55);
  11229. div_val = 10;
  11230. } else if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_9P6MHZ) {
  11231. /* update divider to 8 and enable 2x divider */
  11232. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11233. 0x7C, 0x70);
  11234. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11235. 0xE0, 0x20);
  11236. div_val = 8;
  11237. } else {
  11238. dev_err(codec->dev,
  11239. "%s: Invalid MCLK rate %u\n",
  11240. __func__, wcd9xxx->mclk_rate);
  11241. return -EINVAL;
  11242. }
  11243. l_val = ((cpe_fll_rate / 1000) * div_val) /
  11244. (wcd9xxx->mclk_rate / 1000);
  11245. /* If l_val was integer truncated, increment l_val once */
  11246. computed_cpe_fll = (wcd9xxx->mclk_rate / div_val) * l_val;
  11247. if (computed_cpe_fll < cpe_fll_rate)
  11248. l_val++;
  11249. /* update L value LSB and MSB */
  11250. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_0,
  11251. (l_val & 0xFF));
  11252. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_1,
  11253. ((l_val >> 8) & 0xFF));
  11254. tasha->current_cpe_clk_freq = cpe_fll_rate;
  11255. dev_dbg(codec->dev,
  11256. "%s: updated l_val to %u for cpe_clk %u and mclk %u\n",
  11257. __func__, l_val, cpe_fll_rate, wcd9xxx->mclk_rate);
  11258. return 0;
  11259. }
  11260. static int __tasha_cdc_change_cpe_clk(struct snd_soc_codec *codec,
  11261. u32 clk_freq)
  11262. {
  11263. int ret = 0;
  11264. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11265. if (!tasha_cdc_is_svs_enabled(tasha)) {
  11266. dev_dbg(codec->dev,
  11267. "%s: SVS not enabled or tasha is not 2p0, return\n",
  11268. __func__);
  11269. return 0;
  11270. }
  11271. dev_dbg(codec->dev, "%s: clk_freq = %u\n", __func__, clk_freq);
  11272. if (clk_freq == CPE_FLL_CLK_75MHZ) {
  11273. /* Change to SVS */
  11274. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11275. 0x08, 0x08);
  11276. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11277. ret = -EINVAL;
  11278. goto done;
  11279. }
  11280. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11281. 0x10, 0x10);
  11282. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  11283. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  11284. } else if (clk_freq == CPE_FLL_CLK_150MHZ) {
  11285. /* change to nominal */
  11286. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11287. 0x08, 0x08);
  11288. set_bit(CPE_NOMINAL, &tasha->status_mask);
  11289. tasha_codec_update_sido_voltage(tasha, SIDO_VOLTAGE_NOMINAL_MV);
  11290. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11291. ret = -EINVAL;
  11292. goto done;
  11293. }
  11294. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11295. 0x10, 0x10);
  11296. } else {
  11297. dev_err(codec->dev,
  11298. "%s: Invalid clk_freq request %d for CPE FLL\n",
  11299. __func__, clk_freq);
  11300. ret = -EINVAL;
  11301. }
  11302. done:
  11303. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11304. 0x10, 0x00);
  11305. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11306. 0x08, 0x00);
  11307. return ret;
  11308. }
  11309. static int tasha_codec_cpe_fll_enable(struct snd_soc_codec *codec,
  11310. bool enable)
  11311. {
  11312. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11313. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11314. u8 clk_sel_reg_val = 0x00;
  11315. dev_dbg(codec->dev, "%s: enable = %s\n",
  11316. __func__, enable ? "true" : "false");
  11317. if (enable) {
  11318. if (tasha_cdc_is_svs_enabled(tasha)) {
  11319. /* FLL enable is always at SVS */
  11320. if (__tasha_cdc_change_cpe_clk(codec,
  11321. CPE_FLL_CLK_75MHZ)) {
  11322. dev_err(codec->dev,
  11323. "%s: clk change to %d failed\n",
  11324. __func__, CPE_FLL_CLK_75MHZ);
  11325. return -EINVAL;
  11326. }
  11327. } else {
  11328. if (tasha_codec_cpe_fll_update_divider(codec,
  11329. CPE_FLL_CLK_75MHZ)) {
  11330. dev_err(codec->dev,
  11331. "%s: clk change to %d failed\n",
  11332. __func__, CPE_FLL_CLK_75MHZ);
  11333. return -EINVAL;
  11334. }
  11335. }
  11336. if (TASHA_IS_1_0(wcd9xxx)) {
  11337. tasha_cdc_mclk_enable(codec, true, false);
  11338. clk_sel_reg_val = 0x02;
  11339. }
  11340. /* Setup CPE reference clk */
  11341. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11342. 0x02, clk_sel_reg_val);
  11343. /* enable CPE FLL reference clk */
  11344. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11345. 0x01, 0x01);
  11346. /* program the PLL */
  11347. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11348. 0x01, 0x01);
  11349. /* TEST clk setting */
  11350. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11351. 0x80, 0x80);
  11352. /* set FLL mode to HW controlled */
  11353. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11354. 0x60, 0x00);
  11355. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x80);
  11356. } else {
  11357. /* disable CPE FLL reference clk */
  11358. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11359. 0x01, 0x00);
  11360. /* undo TEST clk setting */
  11361. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11362. 0x80, 0x00);
  11363. /* undo FLL mode to HW control */
  11364. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x00);
  11365. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11366. 0x60, 0x20);
  11367. /* undo the PLL */
  11368. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11369. 0x01, 0x00);
  11370. if (TASHA_IS_1_0(wcd9xxx))
  11371. tasha_cdc_mclk_enable(codec, false, false);
  11372. /*
  11373. * FLL could get disabled while at nominal,
  11374. * scale it back to SVS
  11375. */
  11376. if (tasha_cdc_is_svs_enabled(tasha))
  11377. __tasha_cdc_change_cpe_clk(codec,
  11378. CPE_FLL_CLK_75MHZ);
  11379. }
  11380. return 0;
  11381. }
  11382. static void tasha_cdc_query_cpe_clk_plan(void *data,
  11383. struct cpe_svc_cfg_clk_plan *clk_freq)
  11384. {
  11385. struct snd_soc_codec *codec = data;
  11386. struct tasha_priv *tasha;
  11387. u32 cpe_clk_khz;
  11388. if (!codec) {
  11389. pr_err("%s: Invalid codec handle\n",
  11390. __func__);
  11391. return;
  11392. }
  11393. tasha = snd_soc_codec_get_drvdata(codec);
  11394. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11395. dev_dbg(codec->dev,
  11396. "%s: current_clk_freq = %u\n",
  11397. __func__, tasha->current_cpe_clk_freq);
  11398. clk_freq->current_clk_feq = cpe_clk_khz;
  11399. clk_freq->num_clk_freqs = 2;
  11400. if (tasha_cdc_is_svs_enabled(tasha)) {
  11401. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ / 1000;
  11402. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ / 1000;
  11403. } else {
  11404. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ;
  11405. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ;
  11406. }
  11407. }
  11408. static void tasha_cdc_change_cpe_clk(void *data,
  11409. u32 clk_freq)
  11410. {
  11411. struct snd_soc_codec *codec = data;
  11412. struct tasha_priv *tasha;
  11413. u32 cpe_clk_khz, req_freq = 0;
  11414. if (!codec) {
  11415. pr_err("%s: Invalid codec handle\n",
  11416. __func__);
  11417. return;
  11418. }
  11419. tasha = snd_soc_codec_get_drvdata(codec);
  11420. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11421. if (tasha_cdc_is_svs_enabled(tasha)) {
  11422. if ((clk_freq * 1000) <= CPE_FLL_CLK_75MHZ)
  11423. req_freq = CPE_FLL_CLK_75MHZ;
  11424. else
  11425. req_freq = CPE_FLL_CLK_150MHZ;
  11426. }
  11427. dev_dbg(codec->dev,
  11428. "%s: requested clk_freq = %u, current clk_freq = %u\n",
  11429. __func__, clk_freq * 1000,
  11430. tasha->current_cpe_clk_freq);
  11431. if (tasha_cdc_is_svs_enabled(tasha)) {
  11432. if (__tasha_cdc_change_cpe_clk(codec, req_freq))
  11433. dev_err(codec->dev,
  11434. "%s: clock/voltage scaling failed\n",
  11435. __func__);
  11436. }
  11437. }
  11438. static int tasha_codec_slim_reserve_bw(struct snd_soc_codec *codec,
  11439. u32 bw_ops, bool commit)
  11440. {
  11441. struct wcd9xxx *wcd9xxx;
  11442. if (!codec) {
  11443. pr_err("%s: Invalid handle to codec\n",
  11444. __func__);
  11445. return -EINVAL;
  11446. }
  11447. wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11448. if (!wcd9xxx) {
  11449. dev_err(codec->dev, "%s: Invalid parent drv_data\n",
  11450. __func__);
  11451. return -EINVAL;
  11452. }
  11453. return wcd9xxx_slim_reserve_bw(wcd9xxx, bw_ops, commit);
  11454. }
  11455. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  11456. bool vote)
  11457. {
  11458. u32 bw_ops;
  11459. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11460. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  11461. return 0;
  11462. mutex_lock(&tasha->sb_clk_gear_lock);
  11463. if (vote) {
  11464. tasha->ref_count++;
  11465. if (tasha->ref_count == 1) {
  11466. bw_ops = SLIM_BW_CLK_GEAR_9;
  11467. tasha_codec_slim_reserve_bw(codec,
  11468. bw_ops, true);
  11469. }
  11470. } else if (!vote && tasha->ref_count > 0) {
  11471. tasha->ref_count--;
  11472. if (tasha->ref_count == 0) {
  11473. bw_ops = SLIM_BW_UNVOTE;
  11474. tasha_codec_slim_reserve_bw(codec,
  11475. bw_ops, true);
  11476. }
  11477. };
  11478. dev_dbg(codec->dev, "%s Value of counter after vote or un-vote is %d\n",
  11479. __func__, tasha->ref_count);
  11480. mutex_unlock(&tasha->sb_clk_gear_lock);
  11481. return 0;
  11482. }
  11483. static int tasha_cpe_err_irq_control(struct snd_soc_codec *codec,
  11484. enum cpe_err_irq_cntl_type cntl_type, u8 *status)
  11485. {
  11486. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11487. u8 irq_bits;
  11488. if (TASHA_IS_2_0(tasha->wcd9xxx))
  11489. irq_bits = 0xFF;
  11490. else
  11491. irq_bits = 0x3F;
  11492. if (status)
  11493. irq_bits = (*status) & irq_bits;
  11494. switch (cntl_type) {
  11495. case CPE_ERR_IRQ_MASK:
  11496. snd_soc_update_bits(codec,
  11497. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11498. irq_bits, irq_bits);
  11499. break;
  11500. case CPE_ERR_IRQ_UNMASK:
  11501. snd_soc_update_bits(codec,
  11502. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11503. irq_bits, 0x00);
  11504. break;
  11505. case CPE_ERR_IRQ_CLEAR:
  11506. snd_soc_write(codec, WCD9335_CPE_SS_SS_ERROR_INT_CLEAR,
  11507. irq_bits);
  11508. break;
  11509. case CPE_ERR_IRQ_STATUS:
  11510. if (!status)
  11511. return -EINVAL;
  11512. *status = snd_soc_read(codec,
  11513. WCD9335_CPE_SS_SS_ERROR_INT_STATUS);
  11514. break;
  11515. }
  11516. return 0;
  11517. }
  11518. static const struct wcd_cpe_cdc_cb cpe_cb = {
  11519. .cdc_clk_en = tasha_codec_internal_rco_ctrl,
  11520. .cpe_clk_en = tasha_codec_cpe_fll_enable,
  11521. .get_afe_out_port_id = tasha_codec_get_mad_port_id,
  11522. .lab_cdc_ch_ctl = tasha_codec_enable_slimtx_mad,
  11523. .cdc_ext_clk = tasha_cdc_mclk_enable,
  11524. .bus_vote_bw = tasha_codec_vote_max_bw,
  11525. .cpe_err_irq_control = tasha_cpe_err_irq_control,
  11526. };
  11527. static struct cpe_svc_init_param cpe_svc_params = {
  11528. .version = CPE_SVC_INIT_PARAM_V1,
  11529. .query_freq_plans_cb = tasha_cdc_query_cpe_clk_plan,
  11530. .change_freq_plan_cb = tasha_cdc_change_cpe_clk,
  11531. };
  11532. static int tasha_cpe_initialize(struct snd_soc_codec *codec)
  11533. {
  11534. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11535. struct wcd_cpe_params cpe_params;
  11536. memset(&cpe_params, 0,
  11537. sizeof(struct wcd_cpe_params));
  11538. cpe_params.codec = codec;
  11539. cpe_params.get_cpe_core = tasha_codec_get_cpe_core;
  11540. cpe_params.cdc_cb = &cpe_cb;
  11541. cpe_params.dbg_mode = cpe_debug_mode;
  11542. cpe_params.cdc_major_ver = CPE_SVC_CODEC_WCD9335;
  11543. cpe_params.cdc_minor_ver = CPE_SVC_CODEC_V1P0;
  11544. cpe_params.cdc_id = CPE_SVC_CODEC_WCD9335;
  11545. cpe_params.cdc_irq_info.cpe_engine_irq =
  11546. WCD9335_IRQ_SVA_OUTBOX1;
  11547. cpe_params.cdc_irq_info.cpe_err_irq =
  11548. WCD9335_IRQ_SVA_ERROR;
  11549. cpe_params.cdc_irq_info.cpe_fatal_irqs =
  11550. TASHA_CPE_FATAL_IRQS;
  11551. cpe_svc_params.context = codec;
  11552. cpe_params.cpe_svc_params = &cpe_svc_params;
  11553. tasha->cpe_core = wcd_cpe_init("cpe_9335", codec,
  11554. &cpe_params);
  11555. if (IS_ERR_OR_NULL(tasha->cpe_core)) {
  11556. dev_err(codec->dev,
  11557. "%s: Failed to enable CPE\n",
  11558. __func__);
  11559. return -EINVAL;
  11560. }
  11561. return 0;
  11562. }
  11563. static const struct wcd_resmgr_cb tasha_resmgr_cb = {
  11564. .cdc_rco_ctrl = __tasha_codec_internal_rco_ctrl,
  11565. };
  11566. static int tasha_device_down(struct wcd9xxx *wcd9xxx)
  11567. {
  11568. struct snd_soc_codec *codec;
  11569. struct tasha_priv *priv;
  11570. int count;
  11571. int i = 0;
  11572. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11573. priv = snd_soc_codec_get_drvdata(codec);
  11574. wcd_cpe_ssr_event(priv->cpe_core, WCD_CPE_BUS_DOWN_EVENT);
  11575. for (i = 0; i < priv->nr; i++)
  11576. swrm_wcd_notify(priv->swr_ctrl_data[i].swr_pdev,
  11577. SWR_DEVICE_DOWN, NULL);
  11578. snd_soc_card_change_online_state(codec->component.card, 0);
  11579. for (count = 0; count < NUM_CODEC_DAIS; count++)
  11580. priv->dai[count].bus_down_in_recovery = true;
  11581. priv->resmgr->sido_input_src = SIDO_SOURCE_INTERNAL;
  11582. return 0;
  11583. }
  11584. static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx)
  11585. {
  11586. int i, ret = 0;
  11587. struct wcd9xxx *control;
  11588. struct snd_soc_codec *codec;
  11589. struct tasha_priv *tasha;
  11590. struct wcd9xxx_pdata *pdata;
  11591. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11592. tasha = snd_soc_codec_get_drvdata(codec);
  11593. control = dev_get_drvdata(codec->dev->parent);
  11594. wcd9xxx_set_power_state(tasha->wcd9xxx,
  11595. WCD_REGION_POWER_COLLAPSE_REMOVE,
  11596. WCD9XXX_DIG_CORE_REGION_1);
  11597. mutex_lock(&tasha->codec_mutex);
  11598. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11599. control->slim_slave->laddr;
  11600. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11601. control->slim->laddr;
  11602. tasha_init_slim_slave_cfg(codec);
  11603. if (tasha->machine_codec_event_cb)
  11604. tasha->machine_codec_event_cb(codec,
  11605. WCD9335_CODEC_EVENT_CODEC_UP);
  11606. snd_soc_card_change_online_state(codec->component.card, 1);
  11607. /* Class-H Init*/
  11608. wcd_clsh_init(&tasha->clsh_d);
  11609. for (i = 0; i < TASHA_MAX_MICBIAS; i++)
  11610. tasha->micb_ref[i] = 0;
  11611. tasha_update_reg_defaults(tasha);
  11612. tasha->codec = codec;
  11613. dev_dbg(codec->dev, "%s: MCLK Rate = %x\n",
  11614. __func__, control->mclk_rate);
  11615. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  11616. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11617. 0x03, 0x00);
  11618. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  11619. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11620. 0x03, 0x01);
  11621. tasha_codec_init_reg(codec);
  11622. wcd_resmgr_post_ssr_v2(tasha->resmgr);
  11623. tasha_enable_efuse_sensing(codec);
  11624. regcache_mark_dirty(codec->component.regmap);
  11625. regcache_sync(codec->component.regmap);
  11626. pdata = dev_get_platdata(codec->dev->parent);
  11627. ret = tasha_handle_pdata(tasha, pdata);
  11628. if (ret < 0)
  11629. dev_err(codec->dev, "%s: invalid pdata\n", __func__);
  11630. /* Reset reference counter for voting for max bw */
  11631. tasha->ref_count = 0;
  11632. /* MBHC Init */
  11633. wcd_mbhc_deinit(&tasha->mbhc);
  11634. tasha->mbhc_started = false;
  11635. /* Initialize MBHC module */
  11636. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11637. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11638. if (ret)
  11639. dev_err(codec->dev, "%s: mbhc initialization failed\n",
  11640. __func__);
  11641. else
  11642. tasha_mbhc_hs_detect(codec, tasha->mbhc.mbhc_cfg);
  11643. tasha_cleanup_irqs(tasha);
  11644. ret = tasha_setup_irqs(tasha);
  11645. if (ret) {
  11646. dev_err(codec->dev, "%s: tasha irq setup failed %d\n",
  11647. __func__, ret);
  11648. goto err;
  11649. }
  11650. tasha_set_spkr_mode(codec, tasha->spkr_mode);
  11651. wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT);
  11652. err:
  11653. mutex_unlock(&tasha->codec_mutex);
  11654. return ret;
  11655. }
  11656. static struct regulator *tasha_codec_find_ondemand_regulator(
  11657. struct snd_soc_codec *codec, const char *name)
  11658. {
  11659. int i;
  11660. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11661. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11662. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  11663. for (i = 0; i < wcd9xxx->num_of_supplies; ++i) {
  11664. if (pdata->regulator[i].ondemand &&
  11665. wcd9xxx->supplies[i].supply &&
  11666. !strcmp(wcd9xxx->supplies[i].supply, name))
  11667. return wcd9xxx->supplies[i].consumer;
  11668. }
  11669. dev_dbg(tasha->dev, "Warning: regulator not found:%s\n",
  11670. name);
  11671. return NULL;
  11672. }
  11673. static int tasha_codec_probe(struct snd_soc_codec *codec)
  11674. {
  11675. struct wcd9xxx *control;
  11676. struct tasha_priv *tasha;
  11677. struct wcd9xxx_pdata *pdata;
  11678. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  11679. int i, ret;
  11680. void *ptr = NULL;
  11681. struct regulator *supply;
  11682. control = dev_get_drvdata(codec->dev->parent);
  11683. dev_info(codec->dev, "%s()\n", __func__);
  11684. tasha = snd_soc_codec_get_drvdata(codec);
  11685. tasha->intf_type = wcd9xxx_get_intf_type();
  11686. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11687. control->dev_down = tasha_device_down;
  11688. control->post_reset = tasha_post_reset_cb;
  11689. control->ssr_priv = (void *)codec;
  11690. }
  11691. /* Resource Manager post Init */
  11692. ret = wcd_resmgr_post_init(tasha->resmgr, &tasha_resmgr_cb, codec);
  11693. if (ret) {
  11694. dev_err(codec->dev, "%s: wcd resmgr post init failed\n",
  11695. __func__);
  11696. goto err;
  11697. }
  11698. /* Class-H Init*/
  11699. wcd_clsh_init(&tasha->clsh_d);
  11700. /* Default HPH Mode to Class-H HiFi */
  11701. tasha->hph_mode = CLS_H_HIFI;
  11702. tasha->codec = codec;
  11703. for (i = 0; i < COMPANDER_MAX; i++)
  11704. tasha->comp_enabled[i] = 0;
  11705. tasha->spkr_gain_offset = RX_GAIN_OFFSET_0_DB;
  11706. tasha->intf_type = wcd9xxx_get_intf_type();
  11707. tasha_update_reg_reset_values(codec);
  11708. pr_debug("%s: MCLK Rate = %x\n", __func__, control->mclk_rate);
  11709. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  11710. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11711. 0x03, 0x00);
  11712. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  11713. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11714. 0x03, 0x01);
  11715. tasha_codec_init_reg(codec);
  11716. tasha_enable_efuse_sensing(codec);
  11717. pdata = dev_get_platdata(codec->dev->parent);
  11718. ret = tasha_handle_pdata(tasha, pdata);
  11719. if (ret < 0) {
  11720. pr_err("%s: bad pdata\n", __func__);
  11721. goto err;
  11722. }
  11723. supply = tasha_codec_find_ondemand_regulator(codec,
  11724. on_demand_supply_name[ON_DEMAND_MICBIAS]);
  11725. if (supply) {
  11726. tasha->on_demand_list[ON_DEMAND_MICBIAS].supply = supply;
  11727. tasha->on_demand_list[ON_DEMAND_MICBIAS].ondemand_supply_count =
  11728. 0;
  11729. }
  11730. tasha->fw_data = devm_kzalloc(codec->dev,
  11731. sizeof(*(tasha->fw_data)), GFP_KERNEL);
  11732. if (!tasha->fw_data)
  11733. goto err;
  11734. set_bit(WCD9XXX_ANC_CAL, tasha->fw_data->cal_bit);
  11735. set_bit(WCD9XXX_MBHC_CAL, tasha->fw_data->cal_bit);
  11736. set_bit(WCD9XXX_MAD_CAL, tasha->fw_data->cal_bit);
  11737. set_bit(WCD9XXX_VBAT_CAL, tasha->fw_data->cal_bit);
  11738. ret = wcd_cal_create_hwdep(tasha->fw_data,
  11739. WCD9XXX_CODEC_HWDEP_NODE, codec);
  11740. if (ret < 0) {
  11741. dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret);
  11742. goto err_hwdep;
  11743. }
  11744. /* Initialize MBHC module */
  11745. if (TASHA_IS_2_0(tasha->wcd9xxx)) {
  11746. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].reg =
  11747. WCD9335_MBHC_FSM_STATUS;
  11748. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].mask = 0x01;
  11749. }
  11750. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11751. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11752. if (ret) {
  11753. pr_err("%s: mbhc initialization failed\n", __func__);
  11754. goto err_hwdep;
  11755. }
  11756. ptr = devm_kzalloc(codec->dev, (sizeof(tasha_rx_chs) +
  11757. sizeof(tasha_tx_chs)), GFP_KERNEL);
  11758. if (!ptr) {
  11759. ret = -ENOMEM;
  11760. goto err_hwdep;
  11761. }
  11762. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  11763. snd_soc_dapm_new_controls(dapm, tasha_dapm_i2s_widgets,
  11764. ARRAY_SIZE(tasha_dapm_i2s_widgets));
  11765. snd_soc_dapm_add_routes(dapm, audio_i2s_map,
  11766. ARRAY_SIZE(audio_i2s_map));
  11767. for (i = 0; i < ARRAY_SIZE(tasha_i2s_dai); i++) {
  11768. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11769. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11770. }
  11771. } else if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11772. for (i = 0; i < NUM_CODEC_DAIS; i++) {
  11773. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11774. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11775. }
  11776. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11777. control->slim_slave->laddr;
  11778. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11779. control->slim->laddr;
  11780. tasha_slimbus_slave_port_cfg.slave_port_mapping[0] =
  11781. TASHA_TX13;
  11782. tasha_init_slim_slave_cfg(codec);
  11783. }
  11784. snd_soc_add_codec_controls(codec, impedance_detect_controls,
  11785. ARRAY_SIZE(impedance_detect_controls));
  11786. snd_soc_add_codec_controls(codec, hph_type_detect_controls,
  11787. ARRAY_SIZE(hph_type_detect_controls));
  11788. snd_soc_add_codec_controls(codec,
  11789. tasha_analog_gain_controls,
  11790. ARRAY_SIZE(tasha_analog_gain_controls));
  11791. control->num_rx_port = TASHA_RX_MAX;
  11792. control->rx_chs = ptr;
  11793. memcpy(control->rx_chs, tasha_rx_chs, sizeof(tasha_rx_chs));
  11794. control->num_tx_port = TASHA_TX_MAX;
  11795. control->tx_chs = ptr + sizeof(tasha_rx_chs);
  11796. memcpy(control->tx_chs, tasha_tx_chs, sizeof(tasha_tx_chs));
  11797. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Playback");
  11798. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Capture");
  11799. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Playback");
  11800. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Capture");
  11801. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11802. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Playback");
  11803. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Capture");
  11804. snd_soc_dapm_ignore_suspend(dapm, "AIF4 Playback");
  11805. snd_soc_dapm_ignore_suspend(dapm, "AIF Mix Playback");
  11806. snd_soc_dapm_ignore_suspend(dapm, "AIF4 MAD TX");
  11807. snd_soc_dapm_ignore_suspend(dapm, "VIfeed");
  11808. snd_soc_dapm_ignore_suspend(dapm, "AIF5 CPE TX");
  11809. }
  11810. snd_soc_dapm_sync(dapm);
  11811. ret = tasha_setup_irqs(tasha);
  11812. if (ret) {
  11813. pr_err("%s: tasha irq setup failed %d\n", __func__, ret);
  11814. goto err_pdata;
  11815. }
  11816. ret = tasha_cpe_initialize(codec);
  11817. if (ret) {
  11818. dev_err(codec->dev,
  11819. "%s: cpe initialization failed, err = %d\n",
  11820. __func__, ret);
  11821. /* Do not fail probe if CPE failed */
  11822. ret = 0;
  11823. }
  11824. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11825. tasha->tx_hpf_work[i].tasha = tasha;
  11826. tasha->tx_hpf_work[i].decimator = i;
  11827. INIT_DELAYED_WORK(&tasha->tx_hpf_work[i].dwork,
  11828. tasha_tx_hpf_corner_freq_callback);
  11829. }
  11830. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11831. tasha->tx_mute_dwork[i].tasha = tasha;
  11832. tasha->tx_mute_dwork[i].decimator = i;
  11833. INIT_DELAYED_WORK(&tasha->tx_mute_dwork[i].dwork,
  11834. tasha_tx_mute_update_callback);
  11835. }
  11836. tasha->spk_anc_dwork.tasha = tasha;
  11837. INIT_DELAYED_WORK(&tasha->spk_anc_dwork.dwork,
  11838. tasha_spk_anc_update_callback);
  11839. mutex_lock(&tasha->codec_mutex);
  11840. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  11841. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  11842. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  11843. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  11844. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  11845. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  11846. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  11847. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  11848. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  11849. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  11850. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  11851. mutex_unlock(&tasha->codec_mutex);
  11852. snd_soc_dapm_sync(dapm);
  11853. return ret;
  11854. err_pdata:
  11855. devm_kfree(codec->dev, ptr);
  11856. control->rx_chs = NULL;
  11857. control->tx_chs = NULL;
  11858. err_hwdep:
  11859. devm_kfree(codec->dev, tasha->fw_data);
  11860. tasha->fw_data = NULL;
  11861. err:
  11862. return ret;
  11863. }
  11864. static int tasha_codec_remove(struct snd_soc_codec *codec)
  11865. {
  11866. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11867. struct wcd9xxx *control;
  11868. control = dev_get_drvdata(codec->dev->parent);
  11869. control->rx_chs = NULL;
  11870. control->tx_chs = NULL;
  11871. tasha_cleanup_irqs(tasha);
  11872. /* Cleanup MBHC */
  11873. /* Cleanup resmgr */
  11874. return 0;
  11875. }
  11876. static struct regmap *tasha_get_regmap(struct device *dev)
  11877. {
  11878. struct wcd9xxx *control = dev_get_drvdata(dev->parent);
  11879. return control->regmap;
  11880. }
  11881. static struct snd_soc_codec_driver soc_codec_dev_tasha = {
  11882. .probe = tasha_codec_probe,
  11883. .remove = tasha_codec_remove,
  11884. .get_regmap = tasha_get_regmap,
  11885. .component_driver = {
  11886. .controls = tasha_snd_controls,
  11887. .num_controls = ARRAY_SIZE(tasha_snd_controls),
  11888. .dapm_widgets = tasha_dapm_widgets,
  11889. .num_dapm_widgets = ARRAY_SIZE(tasha_dapm_widgets),
  11890. .dapm_routes = audio_map,
  11891. .num_dapm_routes = ARRAY_SIZE(audio_map),
  11892. },
  11893. };
  11894. #ifdef CONFIG_PM
  11895. static int tasha_suspend(struct device *dev)
  11896. {
  11897. struct platform_device *pdev = to_platform_device(dev);
  11898. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  11899. dev_dbg(dev, "%s: system suspend\n", __func__);
  11900. if (cancel_delayed_work_sync(&tasha->power_gate_work))
  11901. tasha_codec_power_gate_digital_core(tasha);
  11902. return 0;
  11903. }
  11904. static int tasha_resume(struct device *dev)
  11905. {
  11906. struct platform_device *pdev = to_platform_device(dev);
  11907. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  11908. if (!tasha) {
  11909. dev_err(dev, "%s: tasha private data is NULL\n", __func__);
  11910. return -EINVAL;
  11911. }
  11912. dev_dbg(dev, "%s: system resume\n", __func__);
  11913. return 0;
  11914. }
  11915. static const struct dev_pm_ops tasha_pm_ops = {
  11916. .suspend = tasha_suspend,
  11917. .resume = tasha_resume,
  11918. };
  11919. #endif
  11920. static int tasha_swrm_read(void *handle, int reg)
  11921. {
  11922. struct tasha_priv *tasha;
  11923. struct wcd9xxx *wcd9xxx;
  11924. unsigned short swr_rd_addr_base;
  11925. unsigned short swr_rd_data_base;
  11926. int val, ret;
  11927. if (!handle) {
  11928. pr_err("%s: NULL handle\n", __func__);
  11929. return -EINVAL;
  11930. }
  11931. tasha = (struct tasha_priv *)handle;
  11932. wcd9xxx = tasha->wcd9xxx;
  11933. dev_dbg(tasha->dev, "%s: Reading soundwire register, 0x%x\n",
  11934. __func__, reg);
  11935. swr_rd_addr_base = WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0;
  11936. swr_rd_data_base = WCD9335_SWR_AHB_BRIDGE_RD_DATA_0;
  11937. /* read_lock */
  11938. mutex_lock(&tasha->swr_read_lock);
  11939. ret = regmap_bulk_write(wcd9xxx->regmap, swr_rd_addr_base,
  11940. (u8 *)&reg, 4);
  11941. if (ret < 0) {
  11942. pr_err("%s: RD Addr Failure\n", __func__);
  11943. goto err;
  11944. }
  11945. /* Check for RD status */
  11946. ret = regmap_bulk_read(wcd9xxx->regmap, swr_rd_data_base,
  11947. (u8 *)&val, 4);
  11948. if (ret < 0) {
  11949. pr_err("%s: RD Data Failure\n", __func__);
  11950. goto err;
  11951. }
  11952. ret = val;
  11953. err:
  11954. /* read_unlock */
  11955. mutex_unlock(&tasha->swr_read_lock);
  11956. return ret;
  11957. }
  11958. static int tasha_swrm_i2s_bulk_write(struct wcd9xxx *wcd9xxx,
  11959. struct wcd9xxx_reg_val *bulk_reg,
  11960. size_t len)
  11961. {
  11962. int i, ret = 0;
  11963. unsigned short swr_wr_addr_base;
  11964. unsigned short swr_wr_data_base;
  11965. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  11966. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  11967. for (i = 0; i < (len * 2); i += 2) {
  11968. /* First Write the Data to register */
  11969. ret = regmap_bulk_write(wcd9xxx->regmap,
  11970. swr_wr_data_base, bulk_reg[i].buf, 4);
  11971. if (ret < 0) {
  11972. dev_err(wcd9xxx->dev, "%s: WR Data Failure\n",
  11973. __func__);
  11974. break;
  11975. }
  11976. /* Next Write Address */
  11977. ret = regmap_bulk_write(wcd9xxx->regmap,
  11978. swr_wr_addr_base, bulk_reg[i+1].buf, 4);
  11979. if (ret < 0) {
  11980. dev_err(wcd9xxx->dev, "%s: WR Addr Failure\n",
  11981. __func__);
  11982. break;
  11983. }
  11984. }
  11985. return ret;
  11986. }
  11987. static int tasha_swrm_bulk_write(void *handle, u32 *reg, u32 *val, size_t len)
  11988. {
  11989. struct tasha_priv *tasha;
  11990. struct wcd9xxx *wcd9xxx;
  11991. struct wcd9xxx_reg_val *bulk_reg;
  11992. unsigned short swr_wr_addr_base;
  11993. unsigned short swr_wr_data_base;
  11994. int i, j, ret;
  11995. if (!handle) {
  11996. pr_err("%s: NULL handle\n", __func__);
  11997. return -EINVAL;
  11998. }
  11999. if (len <= 0) {
  12000. pr_err("%s: Invalid size: %zu\n", __func__, len);
  12001. return -EINVAL;
  12002. }
  12003. tasha = (struct tasha_priv *)handle;
  12004. wcd9xxx = tasha->wcd9xxx;
  12005. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12006. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12007. bulk_reg = kzalloc((2 * len * sizeof(struct wcd9xxx_reg_val)),
  12008. GFP_KERNEL);
  12009. if (!bulk_reg)
  12010. return -ENOMEM;
  12011. for (i = 0, j = 0; i < (len * 2); i += 2, j++) {
  12012. bulk_reg[i].reg = swr_wr_data_base;
  12013. bulk_reg[i].buf = (u8 *)(&val[j]);
  12014. bulk_reg[i].bytes = 4;
  12015. bulk_reg[i+1].reg = swr_wr_addr_base;
  12016. bulk_reg[i+1].buf = (u8 *)(&reg[j]);
  12017. bulk_reg[i+1].bytes = 4;
  12018. }
  12019. mutex_lock(&tasha->swr_write_lock);
  12020. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12021. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, len);
  12022. if (ret) {
  12023. dev_err(tasha->dev, "%s: i2s bulk write failed, ret: %d\n",
  12024. __func__, ret);
  12025. }
  12026. } else {
  12027. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg,
  12028. (len * 2), false);
  12029. if (ret) {
  12030. dev_err(tasha->dev, "%s: swrm bulk write failed, ret: %d\n",
  12031. __func__, ret);
  12032. }
  12033. }
  12034. mutex_unlock(&tasha->swr_write_lock);
  12035. kfree(bulk_reg);
  12036. return ret;
  12037. }
  12038. static int tasha_swrm_write(void *handle, int reg, int val)
  12039. {
  12040. struct tasha_priv *tasha;
  12041. struct wcd9xxx *wcd9xxx;
  12042. unsigned short swr_wr_addr_base;
  12043. unsigned short swr_wr_data_base;
  12044. struct wcd9xxx_reg_val bulk_reg[2];
  12045. int ret;
  12046. if (!handle) {
  12047. pr_err("%s: NULL handle\n", __func__);
  12048. return -EINVAL;
  12049. }
  12050. tasha = (struct tasha_priv *)handle;
  12051. wcd9xxx = tasha->wcd9xxx;
  12052. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12053. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12054. /* First Write the Data to register */
  12055. bulk_reg[0].reg = swr_wr_data_base;
  12056. bulk_reg[0].buf = (u8 *)(&val);
  12057. bulk_reg[0].bytes = 4;
  12058. bulk_reg[1].reg = swr_wr_addr_base;
  12059. bulk_reg[1].buf = (u8 *)(&reg);
  12060. bulk_reg[1].bytes = 4;
  12061. mutex_lock(&tasha->swr_write_lock);
  12062. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12063. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, 1);
  12064. if (ret) {
  12065. dev_err(tasha->dev, "%s: i2s swrm write failed, ret: %d\n",
  12066. __func__, ret);
  12067. }
  12068. } else {
  12069. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2, false);
  12070. if (ret < 0)
  12071. pr_err("%s: WR Data Failure\n", __func__);
  12072. }
  12073. mutex_unlock(&tasha->swr_write_lock);
  12074. return ret;
  12075. }
  12076. static int tasha_swrm_clock(void *handle, bool enable)
  12077. {
  12078. struct tasha_priv *tasha = (struct tasha_priv *) handle;
  12079. mutex_lock(&tasha->swr_clk_lock);
  12080. dev_dbg(tasha->dev, "%s: swrm clock %s\n",
  12081. __func__, (enable?"enable" : "disable"));
  12082. if (enable) {
  12083. tasha->swr_clk_users++;
  12084. if (tasha->swr_clk_users == 1) {
  12085. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12086. regmap_update_bits(
  12087. tasha->wcd9xxx->regmap,
  12088. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12089. 0x10, 0x00);
  12090. __tasha_cdc_mclk_enable(tasha, true);
  12091. regmap_update_bits(tasha->wcd9xxx->regmap,
  12092. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12093. 0x01, 0x01);
  12094. }
  12095. } else {
  12096. tasha->swr_clk_users--;
  12097. if (tasha->swr_clk_users == 0) {
  12098. regmap_update_bits(tasha->wcd9xxx->regmap,
  12099. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12100. 0x01, 0x00);
  12101. __tasha_cdc_mclk_enable(tasha, false);
  12102. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12103. regmap_update_bits(
  12104. tasha->wcd9xxx->regmap,
  12105. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12106. 0x10, 0x10);
  12107. }
  12108. }
  12109. dev_dbg(tasha->dev, "%s: swrm clock users %d\n",
  12110. __func__, tasha->swr_clk_users);
  12111. mutex_unlock(&tasha->swr_clk_lock);
  12112. return 0;
  12113. }
  12114. static int tasha_swrm_handle_irq(void *handle,
  12115. irqreturn_t (*swrm_irq_handler)(int irq,
  12116. void *data),
  12117. void *swrm_handle,
  12118. int action)
  12119. {
  12120. struct tasha_priv *tasha;
  12121. int ret = 0;
  12122. struct wcd9xxx *wcd9xxx;
  12123. if (!handle) {
  12124. pr_err("%s: null handle received\n", __func__);
  12125. return -EINVAL;
  12126. }
  12127. tasha = (struct tasha_priv *) handle;
  12128. wcd9xxx = tasha->wcd9xxx;
  12129. if (action) {
  12130. ret = wcd9xxx_request_irq(&wcd9xxx->core_res,
  12131. WCD9335_IRQ_SOUNDWIRE,
  12132. swrm_irq_handler,
  12133. "Tasha SWR Master", swrm_handle);
  12134. if (ret)
  12135. dev_err(tasha->dev, "%s: Failed to request irq %d\n",
  12136. __func__, WCD9335_IRQ_SOUNDWIRE);
  12137. } else
  12138. wcd9xxx_free_irq(&wcd9xxx->core_res, WCD9335_IRQ_SOUNDWIRE,
  12139. swrm_handle);
  12140. return ret;
  12141. }
  12142. static void tasha_add_child_devices(struct work_struct *work)
  12143. {
  12144. struct tasha_priv *tasha;
  12145. struct platform_device *pdev;
  12146. struct device_node *node;
  12147. struct wcd9xxx *wcd9xxx;
  12148. struct tasha_swr_ctrl_data *swr_ctrl_data = NULL, *temp;
  12149. int ret, ctrl_num = 0;
  12150. struct wcd_swr_ctrl_platform_data *platdata;
  12151. char plat_dev_name[WCD9335_STRING_LEN];
  12152. tasha = container_of(work, struct tasha_priv,
  12153. tasha_add_child_devices_work);
  12154. if (!tasha) {
  12155. pr_err("%s: Memory for WCD9335 does not exist\n",
  12156. __func__);
  12157. return;
  12158. }
  12159. wcd9xxx = tasha->wcd9xxx;
  12160. if (!wcd9xxx) {
  12161. pr_err("%s: Memory for WCD9XXX does not exist\n",
  12162. __func__);
  12163. return;
  12164. }
  12165. if (!wcd9xxx->dev->of_node) {
  12166. pr_err("%s: DT node for wcd9xxx does not exist\n",
  12167. __func__);
  12168. return;
  12169. }
  12170. platdata = &tasha->swr_plat_data;
  12171. for_each_child_of_node(wcd9xxx->dev->of_node, node) {
  12172. if (!strcmp(node->name, "swr_master"))
  12173. strlcpy(plat_dev_name, "tasha_swr_ctrl",
  12174. (WCD9335_STRING_LEN - 1));
  12175. else if (strnstr(node->name, "msm_cdc_pinctrl",
  12176. strlen("msm_cdc_pinctrl")) != NULL)
  12177. strlcpy(plat_dev_name, node->name,
  12178. (WCD9335_STRING_LEN - 1));
  12179. else
  12180. continue;
  12181. pdev = platform_device_alloc(plat_dev_name, -1);
  12182. if (!pdev) {
  12183. dev_err(wcd9xxx->dev, "%s: pdev memory alloc failed\n",
  12184. __func__);
  12185. ret = -ENOMEM;
  12186. goto err;
  12187. }
  12188. pdev->dev.parent = tasha->dev;
  12189. pdev->dev.of_node = node;
  12190. if (!strcmp(node->name, "swr_master")) {
  12191. ret = platform_device_add_data(pdev, platdata,
  12192. sizeof(*platdata));
  12193. if (ret) {
  12194. dev_err(&pdev->dev,
  12195. "%s: cannot add plat data ctrl:%d\n",
  12196. __func__, ctrl_num);
  12197. goto fail_pdev_add;
  12198. }
  12199. }
  12200. ret = platform_device_add(pdev);
  12201. if (ret) {
  12202. dev_err(&pdev->dev,
  12203. "%s: Cannot add platform device\n",
  12204. __func__);
  12205. goto fail_pdev_add;
  12206. }
  12207. if (!strcmp(node->name, "swr_master")) {
  12208. temp = krealloc(swr_ctrl_data,
  12209. (ctrl_num + 1) * sizeof(
  12210. struct tasha_swr_ctrl_data),
  12211. GFP_KERNEL);
  12212. if (!temp) {
  12213. dev_err(wcd9xxx->dev, "out of memory\n");
  12214. ret = -ENOMEM;
  12215. goto err;
  12216. }
  12217. swr_ctrl_data = temp;
  12218. swr_ctrl_data[ctrl_num].swr_pdev = pdev;
  12219. ctrl_num++;
  12220. dev_dbg(&pdev->dev,
  12221. "%s: Added soundwire ctrl device(s)\n",
  12222. __func__);
  12223. tasha->nr = ctrl_num;
  12224. tasha->swr_ctrl_data = swr_ctrl_data;
  12225. }
  12226. }
  12227. return;
  12228. fail_pdev_add:
  12229. platform_device_put(pdev);
  12230. err:
  12231. return;
  12232. }
  12233. /*
  12234. * tasha_codec_ver: to get tasha codec version
  12235. * @codec: handle to snd_soc_codec *
  12236. * return enum codec_variant - version
  12237. */
  12238. enum codec_variant tasha_codec_ver(void)
  12239. {
  12240. return codec_ver;
  12241. }
  12242. EXPORT_SYMBOL(tasha_codec_ver);
  12243. static int __tasha_enable_efuse_sensing(struct tasha_priv *tasha)
  12244. {
  12245. int val, rc;
  12246. __tasha_cdc_mclk_enable(tasha, true);
  12247. regmap_update_bits(tasha->wcd9xxx->regmap,
  12248. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x1E, 0x20);
  12249. regmap_update_bits(tasha->wcd9xxx->regmap,
  12250. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x01, 0x01);
  12251. /*
  12252. * 5ms sleep required after enabling efuse control
  12253. * before checking the status.
  12254. */
  12255. usleep_range(5000, 5500);
  12256. rc = regmap_read(tasha->wcd9xxx->regmap,
  12257. WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS, &val);
  12258. if (rc || (!(val & 0x01)))
  12259. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  12260. __tasha_cdc_mclk_enable(tasha, false);
  12261. return rc;
  12262. }
  12263. void tasha_get_codec_ver(struct tasha_priv *tasha)
  12264. {
  12265. int i;
  12266. int val;
  12267. struct tasha_reg_mask_val codec_reg[] = {
  12268. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10, 0xFF, 0xFF},
  12269. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11, 0xFF, 0x83},
  12270. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12, 0xFF, 0x0A},
  12271. };
  12272. __tasha_enable_efuse_sensing(tasha);
  12273. for (i = 0; i < ARRAY_SIZE(codec_reg); i++) {
  12274. regmap_read(tasha->wcd9xxx->regmap, codec_reg[i].reg, &val);
  12275. if (!(val && codec_reg[i].val)) {
  12276. codec_ver = WCD9335;
  12277. goto ret;
  12278. }
  12279. }
  12280. codec_ver = WCD9326;
  12281. ret:
  12282. pr_debug("%s: codec is %d\n", __func__, codec_ver);
  12283. }
  12284. EXPORT_SYMBOL(tasha_get_codec_ver);
  12285. static int tasha_probe(struct platform_device *pdev)
  12286. {
  12287. int ret = 0;
  12288. struct tasha_priv *tasha;
  12289. struct clk *wcd_ext_clk, *wcd_native_clk;
  12290. struct wcd9xxx_resmgr_v2 *resmgr;
  12291. struct wcd9xxx_power_region *cdc_pwr;
  12292. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12293. if (apr_get_subsys_state() == APR_SUBSYS_DOWN) {
  12294. dev_err(&pdev->dev, "%s: dsp down\n", __func__);
  12295. return -EPROBE_DEFER;
  12296. }
  12297. }
  12298. tasha = devm_kzalloc(&pdev->dev, sizeof(struct tasha_priv),
  12299. GFP_KERNEL);
  12300. if (!tasha)
  12301. return -ENOMEM;
  12302. platform_set_drvdata(pdev, tasha);
  12303. tasha->wcd9xxx = dev_get_drvdata(pdev->dev.parent);
  12304. tasha->dev = &pdev->dev;
  12305. INIT_DELAYED_WORK(&tasha->power_gate_work, tasha_codec_power_gate_work);
  12306. mutex_init(&tasha->power_lock);
  12307. mutex_init(&tasha->sido_lock);
  12308. INIT_WORK(&tasha->tasha_add_child_devices_work,
  12309. tasha_add_child_devices);
  12310. BLOCKING_INIT_NOTIFIER_HEAD(&tasha->notifier);
  12311. mutex_init(&tasha->micb_lock);
  12312. mutex_init(&tasha->swr_read_lock);
  12313. mutex_init(&tasha->swr_write_lock);
  12314. mutex_init(&tasha->swr_clk_lock);
  12315. mutex_init(&tasha->sb_clk_gear_lock);
  12316. mutex_init(&tasha->mclk_lock);
  12317. cdc_pwr = devm_kzalloc(&pdev->dev, sizeof(struct wcd9xxx_power_region),
  12318. GFP_KERNEL);
  12319. if (!cdc_pwr) {
  12320. ret = -ENOMEM;
  12321. goto err_cdc_pwr;
  12322. }
  12323. tasha->wcd9xxx->wcd9xxx_pwr[WCD9XXX_DIG_CORE_REGION_1] = cdc_pwr;
  12324. cdc_pwr->pwr_collapse_reg_min = TASHA_DIG_CORE_REG_MIN;
  12325. cdc_pwr->pwr_collapse_reg_max = TASHA_DIG_CORE_REG_MAX;
  12326. wcd9xxx_set_power_state(tasha->wcd9xxx,
  12327. WCD_REGION_POWER_COLLAPSE_REMOVE,
  12328. WCD9XXX_DIG_CORE_REGION_1);
  12329. mutex_init(&tasha->codec_mutex);
  12330. /*
  12331. * Init resource manager so that if child nodes such as SoundWire
  12332. * requests for clock, resource manager can honor the request
  12333. */
  12334. resmgr = wcd_resmgr_init(&tasha->wcd9xxx->core_res, NULL);
  12335. if (IS_ERR(resmgr)) {
  12336. ret = PTR_ERR(resmgr);
  12337. dev_err(&pdev->dev, "%s: Failed to initialize wcd resmgr\n",
  12338. __func__);
  12339. goto err_resmgr;
  12340. }
  12341. tasha->resmgr = resmgr;
  12342. tasha->swr_plat_data.handle = (void *) tasha;
  12343. tasha->swr_plat_data.read = tasha_swrm_read;
  12344. tasha->swr_plat_data.write = tasha_swrm_write;
  12345. tasha->swr_plat_data.bulk_write = tasha_swrm_bulk_write;
  12346. tasha->swr_plat_data.clk = tasha_swrm_clock;
  12347. tasha->swr_plat_data.handle_irq = tasha_swrm_handle_irq;
  12348. /* Register for Clock */
  12349. wcd_ext_clk = clk_get(tasha->wcd9xxx->dev, "wcd_clk");
  12350. if (IS_ERR(wcd_ext_clk)) {
  12351. dev_err(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12352. __func__, "wcd_ext_clk");
  12353. goto err_clk;
  12354. }
  12355. tasha->wcd_ext_clk = wcd_ext_clk;
  12356. tasha->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV;
  12357. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  12358. tasha->sido_ccl_cnt = 0;
  12359. /* Register native clk for 44.1 playback */
  12360. wcd_native_clk = clk_get(tasha->wcd9xxx->dev, "wcd_native_clk");
  12361. if (IS_ERR(wcd_native_clk))
  12362. dev_dbg(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12363. __func__, "wcd_native_clk");
  12364. else
  12365. tasha->wcd_native_clk = wcd_native_clk;
  12366. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  12367. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12368. tasha_dai, ARRAY_SIZE(tasha_dai));
  12369. else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
  12370. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12371. tasha_i2s_dai,
  12372. ARRAY_SIZE(tasha_i2s_dai));
  12373. else
  12374. ret = -EINVAL;
  12375. if (ret) {
  12376. dev_err(&pdev->dev, "%s: Codec registration failed, ret = %d\n",
  12377. __func__, ret);
  12378. goto err_cdc_reg;
  12379. }
  12380. /* Update codec register default values */
  12381. tasha_update_reg_defaults(tasha);
  12382. schedule_work(&tasha->tasha_add_child_devices_work);
  12383. tasha_get_codec_ver(tasha);
  12384. dev_info(&pdev->dev, "%s: Tasha driver probe done\n", __func__);
  12385. return ret;
  12386. err_cdc_reg:
  12387. clk_put(tasha->wcd_ext_clk);
  12388. if (tasha->wcd_native_clk)
  12389. clk_put(tasha->wcd_native_clk);
  12390. err_clk:
  12391. wcd_resmgr_remove(tasha->resmgr);
  12392. err_resmgr:
  12393. devm_kfree(&pdev->dev, cdc_pwr);
  12394. err_cdc_pwr:
  12395. mutex_destroy(&tasha->mclk_lock);
  12396. devm_kfree(&pdev->dev, tasha);
  12397. return ret;
  12398. }
  12399. static int tasha_remove(struct platform_device *pdev)
  12400. {
  12401. struct tasha_priv *tasha;
  12402. tasha = platform_get_drvdata(pdev);
  12403. mutex_destroy(&tasha->codec_mutex);
  12404. clk_put(tasha->wcd_ext_clk);
  12405. if (tasha->wcd_native_clk)
  12406. clk_put(tasha->wcd_native_clk);
  12407. mutex_destroy(&tasha->mclk_lock);
  12408. devm_kfree(&pdev->dev, tasha);
  12409. snd_soc_unregister_codec(&pdev->dev);
  12410. mutex_destroy(&tasha->sb_clk_gear_lock);
  12411. return 0;
  12412. }
  12413. static struct platform_driver tasha_codec_driver = {
  12414. .probe = tasha_probe,
  12415. .remove = tasha_remove,
  12416. .driver = {
  12417. .name = "tasha_codec",
  12418. .owner = THIS_MODULE,
  12419. #ifdef CONFIG_PM
  12420. .pm = &tasha_pm_ops,
  12421. #endif
  12422. },
  12423. };
  12424. module_platform_driver(tasha_codec_driver);
  12425. MODULE_DESCRIPTION("Tasha Codec driver");
  12426. MODULE_LICENSE("GPL v2");