wcd9335.c 435 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205
  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. };
  587. static const struct wcd_mbhc_intr intr_ids = {
  588. .mbhc_sw_intr = WCD9335_IRQ_MBHC_SW_DET,
  589. .mbhc_btn_press_intr = WCD9335_IRQ_MBHC_BUTTON_PRESS_DET,
  590. .mbhc_btn_release_intr = WCD9335_IRQ_MBHC_BUTTON_RELEASE_DET,
  591. .mbhc_hs_ins_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
  592. .mbhc_hs_rem_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_DET,
  593. .hph_left_ocp = WCD9335_IRQ_HPH_PA_OCPL_FAULT,
  594. .hph_right_ocp = WCD9335_IRQ_HPH_PA_OCPR_FAULT,
  595. };
  596. struct wcd_vbat {
  597. bool is_enabled;
  598. bool adc_config;
  599. /* Variables to cache Vbat ADC output values */
  600. u16 dcp1;
  601. u16 dcp2;
  602. };
  603. struct hpf_work {
  604. struct tasha_priv *tasha;
  605. u8 decimator;
  606. u8 hpf_cut_off_freq;
  607. struct delayed_work dwork;
  608. };
  609. #define WCD9335_SPK_ANC_EN_DELAY_MS 350
  610. static int spk_anc_en_delay = WCD9335_SPK_ANC_EN_DELAY_MS;
  611. module_param(spk_anc_en_delay, int, 0664);
  612. MODULE_PARM_DESC(spk_anc_en_delay, "delay to enable anc in speaker path");
  613. struct spk_anc_work {
  614. struct tasha_priv *tasha;
  615. struct delayed_work dwork;
  616. };
  617. struct tx_mute_work {
  618. struct tasha_priv *tasha;
  619. u8 decimator;
  620. struct delayed_work dwork;
  621. };
  622. struct tasha_priv {
  623. struct device *dev;
  624. struct wcd9xxx *wcd9xxx;
  625. struct snd_soc_codec *codec;
  626. u32 adc_count;
  627. u32 rx_bias_count;
  628. s32 dmic_0_1_clk_cnt;
  629. s32 dmic_2_3_clk_cnt;
  630. s32 dmic_4_5_clk_cnt;
  631. s32 ldo_h_users;
  632. s32 micb_ref[TASHA_MAX_MICBIAS];
  633. s32 pullup_ref[TASHA_MAX_MICBIAS];
  634. u32 anc_slot;
  635. bool anc_func;
  636. /* Vbat module */
  637. struct wcd_vbat vbat;
  638. /* cal info for codec */
  639. struct fw_info *fw_data;
  640. /*track tasha interface type*/
  641. u8 intf_type;
  642. /* num of slim ports required */
  643. struct wcd9xxx_codec_dai_data dai[NUM_CODEC_DAIS];
  644. /* SoundWire data structure */
  645. struct tasha_swr_ctrl_data *swr_ctrl_data;
  646. int nr;
  647. /*compander*/
  648. int comp_enabled[COMPANDER_MAX];
  649. /* Maintain the status of AUX PGA */
  650. int aux_pga_cnt;
  651. u8 aux_l_gain;
  652. u8 aux_r_gain;
  653. bool spkr_pa_widget_on;
  654. struct regulator *spkdrv_reg;
  655. struct regulator *spkdrv2_reg;
  656. bool mbhc_started;
  657. /* class h specific data */
  658. struct wcd_clsh_cdc_data clsh_d;
  659. struct afe_param_cdc_slimbus_slave_cfg slimbus_slave_cfg;
  660. /*
  661. * list used to save/restore registers at start and
  662. * end of impedance measurement
  663. */
  664. struct list_head reg_save_restore;
  665. /* handle to cpe core */
  666. struct wcd_cpe_core *cpe_core;
  667. u32 current_cpe_clk_freq;
  668. enum tasha_sido_voltage sido_voltage;
  669. int sido_ccl_cnt;
  670. u32 ana_rx_supplies;
  671. /* Multiplication factor used for impedance detection */
  672. int zdet_gain_mul_fact;
  673. /* to track the status */
  674. unsigned long status_mask;
  675. struct work_struct tasha_add_child_devices_work;
  676. struct wcd_swr_ctrl_platform_data swr_plat_data;
  677. /* Port values for Rx and Tx codec_dai */
  678. unsigned int rx_port_value[TASHA_RX_MAX];
  679. unsigned int tx_port_value;
  680. unsigned int vi_feed_value;
  681. /* Tasha Interpolator Mode Select for EAR, HPH_L and HPH_R */
  682. u32 hph_mode;
  683. u16 prim_int_users[TASHA_NUM_INTERPOLATORS];
  684. int spl_src_users[SPLINE_SRC_MAX];
  685. struct wcd9xxx_resmgr_v2 *resmgr;
  686. struct delayed_work power_gate_work;
  687. struct mutex power_lock;
  688. struct mutex sido_lock;
  689. /* mbhc module */
  690. struct wcd_mbhc mbhc;
  691. struct blocking_notifier_head notifier;
  692. struct mutex micb_lock;
  693. struct clk *wcd_ext_clk;
  694. struct clk *wcd_native_clk;
  695. struct mutex swr_read_lock;
  696. struct mutex swr_write_lock;
  697. struct mutex swr_clk_lock;
  698. int swr_clk_users;
  699. int native_clk_users;
  700. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high);
  701. struct snd_info_entry *entry;
  702. struct snd_info_entry *version_entry;
  703. int power_active_ref;
  704. struct on_demand_supply on_demand_list[ON_DEMAND_SUPPLIES_MAX];
  705. int (*machine_codec_event_cb)(struct snd_soc_codec *codec,
  706. enum wcd9335_codec_event);
  707. int spkr_gain_offset;
  708. int spkr_mode;
  709. int ear_spkr_gain;
  710. struct hpf_work tx_hpf_work[TASHA_NUM_DECIMATORS];
  711. struct tx_mute_work tx_mute_dwork[TASHA_NUM_DECIMATORS];
  712. struct spk_anc_work spk_anc_dwork;
  713. struct mutex codec_mutex;
  714. int hph_l_gain;
  715. int hph_r_gain;
  716. int rx_7_count;
  717. int rx_8_count;
  718. bool clk_mode;
  719. bool clk_internal;
  720. /* Lock to prevent multiple functions voting at same time */
  721. struct mutex sb_clk_gear_lock;
  722. /* Count for functions voting or un-voting */
  723. u32 ref_count;
  724. /* Lock to protect mclk enablement */
  725. struct mutex mclk_lock;
  726. };
  727. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  728. bool vote);
  729. static const struct tasha_reg_mask_val tasha_spkr_default[] = {
  730. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  731. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  732. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  733. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  734. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x50},
  735. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x50},
  736. };
  737. static const struct tasha_reg_mask_val tasha_spkr_mode1[] = {
  738. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x00},
  739. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x00},
  740. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x00},
  741. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x00},
  742. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x44},
  743. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x44},
  744. };
  745. /**
  746. * tasha_set_spkr_gain_offset - offset the speaker path
  747. * gain with the given offset value.
  748. *
  749. * @codec: codec instance
  750. * @offset: Indicates speaker path gain offset value.
  751. *
  752. * Returns 0 on success or -EINVAL on error.
  753. */
  754. int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
  755. {
  756. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  757. if (!priv)
  758. return -EINVAL;
  759. priv->spkr_gain_offset = offset;
  760. return 0;
  761. }
  762. EXPORT_SYMBOL(tasha_set_spkr_gain_offset);
  763. /**
  764. * tasha_set_spkr_mode - Configures speaker compander and smartboost
  765. * settings based on speaker mode.
  766. *
  767. * @codec: codec instance
  768. * @mode: Indicates speaker configuration mode.
  769. *
  770. * Returns 0 on success or -EINVAL on error.
  771. */
  772. int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode)
  773. {
  774. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  775. int i;
  776. const struct tasha_reg_mask_val *regs;
  777. int size;
  778. if (!priv)
  779. return -EINVAL;
  780. switch (mode) {
  781. case SPKR_MODE_1:
  782. regs = tasha_spkr_mode1;
  783. size = ARRAY_SIZE(tasha_spkr_mode1);
  784. break;
  785. default:
  786. regs = tasha_spkr_default;
  787. size = ARRAY_SIZE(tasha_spkr_default);
  788. break;
  789. }
  790. priv->spkr_mode = mode;
  791. for (i = 0; i < size; i++)
  792. snd_soc_update_bits(codec, regs[i].reg,
  793. regs[i].mask, regs[i].val);
  794. return 0;
  795. }
  796. EXPORT_SYMBOL(tasha_set_spkr_mode);
  797. static void tasha_enable_sido_buck(struct snd_soc_codec *codec)
  798. {
  799. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  800. snd_soc_update_bits(codec, WCD9335_ANA_RCO, 0x80, 0x80);
  801. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x02, 0x02);
  802. /* 100us sleep needed after IREF settings */
  803. usleep_range(100, 110);
  804. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x04, 0x04);
  805. /* 100us sleep needed after VREF settings */
  806. usleep_range(100, 110);
  807. tasha->resmgr->sido_input_src = SIDO_SOURCE_RCO_BG;
  808. }
  809. static void tasha_cdc_sido_ccl_enable(struct tasha_priv *tasha, bool ccl_flag)
  810. {
  811. struct snd_soc_codec *codec = tasha->codec;
  812. if (!codec)
  813. return;
  814. if (!TASHA_IS_2_0(tasha->wcd9xxx)) {
  815. dev_dbg(codec->dev, "%s: tasha version < 2p0, return\n",
  816. __func__);
  817. return;
  818. }
  819. dev_dbg(codec->dev, "%s: sido_ccl_cnt=%d, ccl_flag:%d\n",
  820. __func__, tasha->sido_ccl_cnt, ccl_flag);
  821. if (ccl_flag) {
  822. if (++tasha->sido_ccl_cnt == 1)
  823. snd_soc_update_bits(codec,
  824. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x6E);
  825. } else {
  826. if (tasha->sido_ccl_cnt == 0) {
  827. dev_dbg(codec->dev, "%s: sido_ccl already disabled\n",
  828. __func__);
  829. return;
  830. }
  831. if (--tasha->sido_ccl_cnt == 0)
  832. snd_soc_update_bits(codec,
  833. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x02);
  834. }
  835. }
  836. static bool tasha_cdc_is_svs_enabled(struct tasha_priv *tasha)
  837. {
  838. if (TASHA_IS_2_0(tasha->wcd9xxx) &&
  839. svs_scaling_enabled)
  840. return true;
  841. return false;
  842. }
  843. static int tasha_cdc_req_mclk_enable(struct tasha_priv *tasha,
  844. bool enable)
  845. {
  846. int ret = 0;
  847. mutex_lock(&tasha->mclk_lock);
  848. if (enable) {
  849. tasha_cdc_sido_ccl_enable(tasha, true);
  850. ret = clk_prepare_enable(tasha->wcd_ext_clk);
  851. if (ret) {
  852. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  853. __func__);
  854. goto unlock_mutex;
  855. }
  856. /* get BG */
  857. wcd_resmgr_enable_master_bias(tasha->resmgr);
  858. /* get MCLK */
  859. wcd_resmgr_enable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  860. } else {
  861. /* put MCLK */
  862. wcd_resmgr_disable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  863. /* put BG */
  864. wcd_resmgr_disable_master_bias(tasha->resmgr);
  865. clk_disable_unprepare(tasha->wcd_ext_clk);
  866. tasha_cdc_sido_ccl_enable(tasha, false);
  867. }
  868. unlock_mutex:
  869. mutex_unlock(&tasha->mclk_lock);
  870. return ret;
  871. }
  872. static int tasha_cdc_check_sido_value(enum tasha_sido_voltage req_mv)
  873. {
  874. if ((req_mv != SIDO_VOLTAGE_SVS_MV) &&
  875. (req_mv != SIDO_VOLTAGE_NOMINAL_MV))
  876. return -EINVAL;
  877. return 0;
  878. }
  879. static void tasha_codec_apply_sido_voltage(
  880. struct tasha_priv *tasha,
  881. enum tasha_sido_voltage req_mv)
  882. {
  883. u32 vout_d_val;
  884. struct snd_soc_codec *codec = tasha->codec;
  885. int ret;
  886. if (!codec)
  887. return;
  888. if (!tasha_cdc_is_svs_enabled(tasha))
  889. return;
  890. if ((sido_buck_svs_voltage != SIDO_VOLTAGE_SVS_MV) &&
  891. (sido_buck_svs_voltage != SIDO_VOLTAGE_NOMINAL_MV))
  892. sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  893. ret = tasha_cdc_check_sido_value(req_mv);
  894. if (ret < 0) {
  895. dev_dbg(codec->dev, "%s: requested mv=%d not in range\n",
  896. __func__, req_mv);
  897. return;
  898. }
  899. if (req_mv == tasha->sido_voltage) {
  900. dev_dbg(codec->dev, "%s: Already at requested mv=%d\n",
  901. __func__, req_mv);
  902. return;
  903. }
  904. if (req_mv == sido_buck_svs_voltage) {
  905. if (test_bit(AUDIO_NOMINAL, &tasha->status_mask) ||
  906. test_bit(CPE_NOMINAL, &tasha->status_mask)) {
  907. dev_dbg(codec->dev,
  908. "%s: nominal client running, status_mask=%lu\n",
  909. __func__, tasha->status_mask);
  910. return;
  911. }
  912. }
  913. /* compute the vout_d step value */
  914. vout_d_val = CALCULATE_VOUT_D(req_mv);
  915. snd_soc_write(codec, WCD9335_ANA_BUCK_VOUT_D, vout_d_val & 0xFF);
  916. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x80, 0x80);
  917. /* 1 msec sleep required after SIDO Vout_D voltage change */
  918. usleep_range(1000, 1100);
  919. tasha->sido_voltage = req_mv;
  920. dev_dbg(codec->dev,
  921. "%s: updated SIDO buck Vout_D to %d, vout_d step = %u\n",
  922. __func__, tasha->sido_voltage, vout_d_val);
  923. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL,
  924. 0x80, 0x00);
  925. }
  926. static int tasha_codec_update_sido_voltage(
  927. struct tasha_priv *tasha,
  928. enum tasha_sido_voltage req_mv)
  929. {
  930. int ret = 0;
  931. if (!tasha_cdc_is_svs_enabled(tasha))
  932. return ret;
  933. mutex_lock(&tasha->sido_lock);
  934. /* enable mclk before setting SIDO voltage */
  935. ret = tasha_cdc_req_mclk_enable(tasha, true);
  936. if (ret) {
  937. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  938. __func__);
  939. goto err;
  940. }
  941. tasha_codec_apply_sido_voltage(tasha, req_mv);
  942. tasha_cdc_req_mclk_enable(tasha, false);
  943. err:
  944. mutex_unlock(&tasha->sido_lock);
  945. return ret;
  946. }
  947. int tasha_enable_efuse_sensing(struct snd_soc_codec *codec)
  948. {
  949. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  950. tasha_cdc_mclk_enable(codec, true, false);
  951. if (!TASHA_IS_2_0(priv->wcd9xxx))
  952. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  953. 0x1E, 0x02);
  954. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  955. 0x01, 0x01);
  956. /*
  957. * 5ms sleep required after enabling efuse control
  958. * before checking the status.
  959. */
  960. usleep_range(5000, 5500);
  961. if (!(snd_soc_read(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01))
  962. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  963. if (TASHA_IS_2_0(priv->wcd9xxx)) {
  964. if (!(snd_soc_read(codec,
  965. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0) & 0x40))
  966. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST,
  967. 0x04, 0x00);
  968. tasha_enable_sido_buck(codec);
  969. }
  970. tasha_cdc_mclk_enable(codec, false, false);
  971. return 0;
  972. }
  973. EXPORT_SYMBOL(tasha_enable_efuse_sensing);
  974. void *tasha_get_afe_config(struct snd_soc_codec *codec,
  975. enum afe_config_type config_type)
  976. {
  977. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  978. switch (config_type) {
  979. case AFE_SLIMBUS_SLAVE_CONFIG:
  980. return &priv->slimbus_slave_cfg;
  981. case AFE_CDC_REGISTERS_CONFIG:
  982. return &tasha_audio_reg_cfg;
  983. case AFE_SLIMBUS_SLAVE_PORT_CONFIG:
  984. return &tasha_slimbus_slave_port_cfg;
  985. case AFE_AANC_VERSION:
  986. return &tasha_cdc_aanc_version;
  987. case AFE_CLIP_BANK_SEL:
  988. return NULL;
  989. case AFE_CDC_CLIP_REGISTERS_CONFIG:
  990. return NULL;
  991. case AFE_CDC_REGISTER_PAGE_CONFIG:
  992. return &tasha_cdc_reg_page_cfg;
  993. default:
  994. dev_err(codec->dev, "%s: Unknown config_type 0x%x\n",
  995. __func__, config_type);
  996. return NULL;
  997. }
  998. }
  999. EXPORT_SYMBOL(tasha_get_afe_config);
  1000. /*
  1001. * tasha_event_register: Registers a machine driver callback
  1002. * function with codec private data for post ADSP sub-system
  1003. * restart (SSR). This callback function will be called from
  1004. * codec driver once codec comes out of reset after ADSP SSR.
  1005. *
  1006. * @machine_event_cb: callback function from machine driver
  1007. * @codec: Codec instance
  1008. *
  1009. * Return: none
  1010. */
  1011. void tasha_event_register(
  1012. int (*machine_event_cb)(struct snd_soc_codec *codec,
  1013. enum wcd9335_codec_event),
  1014. struct snd_soc_codec *codec)
  1015. {
  1016. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1017. if (tasha)
  1018. tasha->machine_codec_event_cb = machine_event_cb;
  1019. else
  1020. dev_dbg(codec->dev, "%s: Invalid tasha_priv data\n", __func__);
  1021. }
  1022. EXPORT_SYMBOL(tasha_event_register);
  1023. static int tasha_mbhc_request_irq(struct snd_soc_codec *codec,
  1024. int irq, irq_handler_t handler,
  1025. const char *name, void *data)
  1026. {
  1027. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1028. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1029. struct wcd9xxx_core_resource *core_res =
  1030. &wcd9xxx->core_res;
  1031. return wcd9xxx_request_irq(core_res, irq, handler, name, data);
  1032. }
  1033. static void tasha_mbhc_irq_control(struct snd_soc_codec *codec,
  1034. int irq, bool enable)
  1035. {
  1036. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1037. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1038. struct wcd9xxx_core_resource *core_res =
  1039. &wcd9xxx->core_res;
  1040. if (enable)
  1041. wcd9xxx_enable_irq(core_res, irq);
  1042. else
  1043. wcd9xxx_disable_irq(core_res, irq);
  1044. }
  1045. static int tasha_mbhc_free_irq(struct snd_soc_codec *codec,
  1046. int irq, void *data)
  1047. {
  1048. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1049. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1050. struct wcd9xxx_core_resource *core_res =
  1051. &wcd9xxx->core_res;
  1052. wcd9xxx_free_irq(core_res, irq, data);
  1053. return 0;
  1054. }
  1055. static void tasha_mbhc_clk_setup(struct snd_soc_codec *codec,
  1056. bool enable)
  1057. {
  1058. if (enable)
  1059. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1060. 0x80, 0x80);
  1061. else
  1062. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1063. 0x80, 0x00);
  1064. }
  1065. static int tasha_mbhc_btn_to_num(struct snd_soc_codec *codec)
  1066. {
  1067. return snd_soc_read(codec, WCD9335_ANA_MBHC_RESULT_3) & 0x7;
  1068. }
  1069. static void tasha_mbhc_mbhc_bias_control(struct snd_soc_codec *codec,
  1070. bool enable)
  1071. {
  1072. if (enable)
  1073. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1074. 0x01, 0x01);
  1075. else
  1076. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1077. 0x01, 0x00);
  1078. }
  1079. static void tasha_mbhc_program_btn_thr(struct snd_soc_codec *codec,
  1080. s16 *btn_low, s16 *btn_high,
  1081. int num_btn, bool is_micbias)
  1082. {
  1083. int i;
  1084. int vth;
  1085. if (num_btn > WCD_MBHC_DEF_BUTTONS) {
  1086. dev_err(codec->dev, "%s: invalid number of buttons: %d\n",
  1087. __func__, num_btn);
  1088. return;
  1089. }
  1090. /*
  1091. * Tasha just needs one set of thresholds for button detection
  1092. * due to micbias voltage ramp to pullup upon button press. So
  1093. * btn_low and is_micbias are ignored and always program button
  1094. * thresholds using btn_high.
  1095. */
  1096. for (i = 0; i < num_btn; i++) {
  1097. vth = ((btn_high[i] * 2) / 25) & 0x3F;
  1098. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN0 + i,
  1099. 0xFC, vth << 2);
  1100. dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
  1101. __func__, i, btn_high[i], vth);
  1102. }
  1103. }
  1104. static bool tasha_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
  1105. {
  1106. struct snd_soc_codec *codec = mbhc->codec;
  1107. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1108. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1109. struct wcd9xxx_core_resource *core_res =
  1110. &wcd9xxx->core_res;
  1111. if (lock)
  1112. return wcd9xxx_lock_sleep(core_res);
  1113. else {
  1114. wcd9xxx_unlock_sleep(core_res);
  1115. return 0;
  1116. }
  1117. }
  1118. static int tasha_mbhc_register_notifier(struct wcd_mbhc *mbhc,
  1119. struct notifier_block *nblock,
  1120. bool enable)
  1121. {
  1122. struct snd_soc_codec *codec = mbhc->codec;
  1123. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1124. if (enable)
  1125. return blocking_notifier_chain_register(&tasha->notifier,
  1126. nblock);
  1127. else
  1128. return blocking_notifier_chain_unregister(&tasha->notifier,
  1129. nblock);
  1130. }
  1131. static bool tasha_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
  1132. {
  1133. u8 val;
  1134. if (micb_num == MIC_BIAS_2) {
  1135. val = (snd_soc_read(mbhc->codec, WCD9335_ANA_MICB2) >> 6);
  1136. if (val == 0x01)
  1137. return true;
  1138. }
  1139. return false;
  1140. }
  1141. static bool tasha_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
  1142. {
  1143. return (snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0) ? true : false;
  1144. }
  1145. static void tasha_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec,
  1146. enum mbhc_hs_pullup_iref pull_up_cur)
  1147. {
  1148. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1149. if (!tasha)
  1150. return;
  1151. /* Default pull up current to 2uA */
  1152. if (pull_up_cur < I_OFF || pull_up_cur > I_3P0_UA ||
  1153. pull_up_cur == I_DEFAULT)
  1154. pull_up_cur = I_2P0_UA;
  1155. dev_dbg(codec->dev, "%s: HS pull up current:%d\n",
  1156. __func__, pull_up_cur);
  1157. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1158. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1159. 0xC0, pull_up_cur << 6);
  1160. else
  1161. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1162. 0xC0, 0x40);
  1163. }
  1164. static int tasha_enable_ext_mb_source(struct wcd_mbhc *mbhc,
  1165. bool turn_on)
  1166. {
  1167. struct snd_soc_codec *codec = mbhc->codec;
  1168. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1169. int ret = 0;
  1170. struct on_demand_supply *supply;
  1171. if (!tasha)
  1172. return -EINVAL;
  1173. supply = &tasha->on_demand_list[ON_DEMAND_MICBIAS];
  1174. if (!supply->supply) {
  1175. dev_dbg(codec->dev, "%s: warning supply not present ond for %s\n",
  1176. __func__, "onDemand Micbias");
  1177. return ret;
  1178. }
  1179. dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
  1180. supply->ondemand_supply_count);
  1181. if (turn_on) {
  1182. if (!(supply->ondemand_supply_count)) {
  1183. ret = snd_soc_dapm_force_enable_pin(
  1184. snd_soc_codec_get_dapm(codec),
  1185. "MICBIAS_REGULATOR");
  1186. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1187. }
  1188. supply->ondemand_supply_count++;
  1189. } else {
  1190. if (supply->ondemand_supply_count > 0)
  1191. supply->ondemand_supply_count--;
  1192. if (!(supply->ondemand_supply_count)) {
  1193. ret = snd_soc_dapm_disable_pin(
  1194. snd_soc_codec_get_dapm(codec),
  1195. "MICBIAS_REGULATOR");
  1196. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1197. }
  1198. }
  1199. if (ret)
  1200. dev_err(codec->dev, "%s: Failed to %s external micbias source\n",
  1201. __func__, turn_on ? "enable" : "disabled");
  1202. else
  1203. dev_dbg(codec->dev, "%s: %s external micbias source\n",
  1204. __func__, turn_on ? "Enabled" : "Disabled");
  1205. return ret;
  1206. }
  1207. static int tasha_micbias_control(struct snd_soc_codec *codec,
  1208. int micb_num,
  1209. int req, bool is_dapm)
  1210. {
  1211. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1212. int micb_index = micb_num - 1;
  1213. u16 micb_reg;
  1214. int pre_off_event = 0, post_off_event = 0;
  1215. int post_on_event = 0, post_dapm_off = 0;
  1216. int post_dapm_on = 0;
  1217. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  1218. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  1219. __func__, micb_index);
  1220. return -EINVAL;
  1221. }
  1222. switch (micb_num) {
  1223. case MIC_BIAS_1:
  1224. micb_reg = WCD9335_ANA_MICB1;
  1225. break;
  1226. case MIC_BIAS_2:
  1227. micb_reg = WCD9335_ANA_MICB2;
  1228. pre_off_event = WCD_EVENT_PRE_MICBIAS_2_OFF;
  1229. post_off_event = WCD_EVENT_POST_MICBIAS_2_OFF;
  1230. post_on_event = WCD_EVENT_POST_MICBIAS_2_ON;
  1231. post_dapm_on = WCD_EVENT_POST_DAPM_MICBIAS_2_ON;
  1232. post_dapm_off = WCD_EVENT_POST_DAPM_MICBIAS_2_OFF;
  1233. break;
  1234. case MIC_BIAS_3:
  1235. micb_reg = WCD9335_ANA_MICB3;
  1236. break;
  1237. case MIC_BIAS_4:
  1238. micb_reg = WCD9335_ANA_MICB4;
  1239. break;
  1240. default:
  1241. dev_err(codec->dev, "%s: Invalid micbias number: %d\n",
  1242. __func__, micb_num);
  1243. return -EINVAL;
  1244. }
  1245. mutex_lock(&tasha->micb_lock);
  1246. switch (req) {
  1247. case MICB_PULLUP_ENABLE:
  1248. tasha->pullup_ref[micb_index]++;
  1249. if ((tasha->pullup_ref[micb_index] == 1) &&
  1250. (tasha->micb_ref[micb_index] == 0))
  1251. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1252. break;
  1253. case MICB_PULLUP_DISABLE:
  1254. if (tasha->pullup_ref[micb_index] > 0)
  1255. tasha->pullup_ref[micb_index]--;
  1256. if ((tasha->pullup_ref[micb_index] == 0) &&
  1257. (tasha->micb_ref[micb_index] == 0))
  1258. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1259. break;
  1260. case MICB_ENABLE:
  1261. tasha->micb_ref[micb_index]++;
  1262. if (tasha->micb_ref[micb_index] == 1) {
  1263. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1264. if (post_on_event)
  1265. blocking_notifier_call_chain(&tasha->notifier,
  1266. post_on_event, &tasha->mbhc);
  1267. }
  1268. if (is_dapm && post_dapm_on)
  1269. blocking_notifier_call_chain(&tasha->notifier,
  1270. post_dapm_on, &tasha->mbhc);
  1271. break;
  1272. case MICB_DISABLE:
  1273. if (tasha->micb_ref[micb_index] > 0)
  1274. tasha->micb_ref[micb_index]--;
  1275. if ((tasha->micb_ref[micb_index] == 0) &&
  1276. (tasha->pullup_ref[micb_index] > 0))
  1277. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1278. else if ((tasha->micb_ref[micb_index] == 0) &&
  1279. (tasha->pullup_ref[micb_index] == 0)) {
  1280. if (pre_off_event)
  1281. blocking_notifier_call_chain(&tasha->notifier,
  1282. pre_off_event, &tasha->mbhc);
  1283. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1284. if (post_off_event)
  1285. blocking_notifier_call_chain(&tasha->notifier,
  1286. post_off_event, &tasha->mbhc);
  1287. }
  1288. if (is_dapm && post_dapm_off)
  1289. blocking_notifier_call_chain(&tasha->notifier,
  1290. post_dapm_off, &tasha->mbhc);
  1291. break;
  1292. };
  1293. dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n",
  1294. __func__, micb_num, tasha->micb_ref[micb_index],
  1295. tasha->pullup_ref[micb_index]);
  1296. mutex_unlock(&tasha->micb_lock);
  1297. return 0;
  1298. }
  1299. static int tasha_mbhc_request_micbias(struct snd_soc_codec *codec,
  1300. int micb_num, int req)
  1301. {
  1302. int ret;
  1303. /*
  1304. * If micbias is requested, make sure that there
  1305. * is vote to enable mclk
  1306. */
  1307. if (req == MICB_ENABLE)
  1308. tasha_cdc_mclk_enable(codec, true, false);
  1309. ret = tasha_micbias_control(codec, micb_num, req, false);
  1310. /*
  1311. * Release vote for mclk while requesting for
  1312. * micbias disable
  1313. */
  1314. if (req == MICB_DISABLE)
  1315. tasha_cdc_mclk_enable(codec, false, false);
  1316. return ret;
  1317. }
  1318. static void tasha_mbhc_micb_ramp_control(struct snd_soc_codec *codec,
  1319. bool enable)
  1320. {
  1321. if (enable) {
  1322. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1323. 0x1C, 0x0C);
  1324. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1325. 0x80, 0x80);
  1326. } else {
  1327. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1328. 0x80, 0x00);
  1329. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1330. 0x1C, 0x00);
  1331. }
  1332. }
  1333. static struct firmware_cal *tasha_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
  1334. enum wcd_cal_type type)
  1335. {
  1336. struct tasha_priv *tasha;
  1337. struct firmware_cal *hwdep_cal;
  1338. struct snd_soc_codec *codec = mbhc->codec;
  1339. if (!codec) {
  1340. pr_err("%s: NULL codec pointer\n", __func__);
  1341. return NULL;
  1342. }
  1343. tasha = snd_soc_codec_get_drvdata(codec);
  1344. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, type);
  1345. if (!hwdep_cal)
  1346. dev_err(codec->dev, "%s: cal not sent by %d\n",
  1347. __func__, type);
  1348. return hwdep_cal;
  1349. }
  1350. static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
  1351. int req_volt,
  1352. int micb_num)
  1353. {
  1354. int cur_vout_ctl, req_vout_ctl;
  1355. int micb_reg, micb_val, micb_en;
  1356. switch (micb_num) {
  1357. case MIC_BIAS_1:
  1358. micb_reg = WCD9335_ANA_MICB1;
  1359. break;
  1360. case MIC_BIAS_2:
  1361. micb_reg = WCD9335_ANA_MICB2;
  1362. break;
  1363. case MIC_BIAS_3:
  1364. micb_reg = WCD9335_ANA_MICB3;
  1365. break;
  1366. case MIC_BIAS_4:
  1367. micb_reg = WCD9335_ANA_MICB4;
  1368. break;
  1369. default:
  1370. return -EINVAL;
  1371. }
  1372. /*
  1373. * If requested micbias voltage is same as current micbias
  1374. * voltage, then just return. Otherwise, adjust voltage as
  1375. * per requested value. If micbias is already enabled, then
  1376. * to avoid slow micbias ramp-up or down enable pull-up
  1377. * momentarily, change the micbias value and then re-enable
  1378. * micbias.
  1379. */
  1380. micb_val = snd_soc_read(codec, micb_reg);
  1381. micb_en = (micb_val & 0xC0) >> 6;
  1382. cur_vout_ctl = micb_val & 0x3F;
  1383. req_vout_ctl = wcd9335_get_micb_vout_ctl_val(req_volt);
  1384. if (req_vout_ctl < 0)
  1385. return -EINVAL;
  1386. if (cur_vout_ctl == req_vout_ctl)
  1387. return 0;
  1388. dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n",
  1389. __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl),
  1390. req_volt, micb_en);
  1391. if (micb_en == 0x1)
  1392. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1393. snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl);
  1394. if (micb_en == 0x1) {
  1395. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1396. /*
  1397. * Add 2ms delay as per HW requirement after enabling
  1398. * micbias
  1399. */
  1400. usleep_range(2000, 2100);
  1401. }
  1402. return 0;
  1403. }
  1404. static int tasha_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
  1405. int micb_num, bool req_en)
  1406. {
  1407. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1408. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  1409. int rc, micb_mv;
  1410. if (micb_num != MIC_BIAS_2)
  1411. return -EINVAL;
  1412. /*
  1413. * If device tree micbias level is already above the minimum
  1414. * voltage needed to detect threshold microphone, then do
  1415. * not change the micbias, just return.
  1416. */
  1417. if (pdata->micbias.micb2_mv >= WCD_MBHC_THR_HS_MICB_MV)
  1418. return 0;
  1419. micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv;
  1420. mutex_lock(&tasha->micb_lock);
  1421. rc = tasha_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2);
  1422. mutex_unlock(&tasha->micb_lock);
  1423. return rc;
  1424. }
  1425. static inline void tasha_mbhc_get_result_params(struct wcd9xxx *wcd9xxx,
  1426. s16 *d1_a, u16 noff,
  1427. int32_t *zdet)
  1428. {
  1429. int i;
  1430. int val, val1;
  1431. s16 c1;
  1432. s32 x1, d1;
  1433. int32_t denom;
  1434. int minCode_param[] = {
  1435. 3277, 1639, 820, 410, 205, 103, 52, 26
  1436. };
  1437. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x20);
  1438. for (i = 0; i < TASHA_ZDET_NUM_MEASUREMENTS; i++) {
  1439. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_2, &val);
  1440. if (val & 0x80)
  1441. break;
  1442. }
  1443. val = val << 0x8;
  1444. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_1, &val1);
  1445. val |= val1;
  1446. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x00);
  1447. x1 = TASHA_MBHC_GET_X1(val);
  1448. c1 = TASHA_MBHC_GET_C1(val);
  1449. /* If ramp is not complete, give additional 5ms */
  1450. if ((c1 < 2) && x1)
  1451. usleep_range(5000, 5050);
  1452. if (!c1 || !x1) {
  1453. dev_dbg(wcd9xxx->dev,
  1454. "%s: Impedance detect ramp error, c1=%d, x1=0x%x\n",
  1455. __func__, c1, x1);
  1456. goto ramp_down;
  1457. }
  1458. d1 = d1_a[c1];
  1459. denom = (x1 * d1) - (1 << (14 - noff));
  1460. if (denom > 0)
  1461. *zdet = (TASHA_MBHC_ZDET_CONST * 1000) / denom;
  1462. else if (x1 < minCode_param[noff])
  1463. *zdet = TASHA_ZDET_FLOATING_IMPEDANCE;
  1464. dev_dbg(wcd9xxx->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
  1465. __func__, d1, c1, x1, *zdet);
  1466. ramp_down:
  1467. i = 0;
  1468. while (x1) {
  1469. regmap_bulk_read(wcd9xxx->regmap,
  1470. WCD9335_ANA_MBHC_RESULT_1, (u8 *)&val, 2);
  1471. x1 = TASHA_MBHC_GET_X1(val);
  1472. i++;
  1473. if (i == TASHA_ZDET_NUM_MEASUREMENTS)
  1474. break;
  1475. }
  1476. }
  1477. /*
  1478. * tasha_mbhc_zdet_gpio_ctrl: Register callback function for
  1479. * controlling the switch on hifi amps. Default switch state
  1480. * will put a 51ohm load in parallel to the hph load. So,
  1481. * impedance detection function will pull the gpio high
  1482. * to make the switch open.
  1483. *
  1484. * @zdet_gpio_cb: callback function from machine driver
  1485. * @codec: Codec instance
  1486. *
  1487. * Return: none
  1488. */
  1489. void tasha_mbhc_zdet_gpio_ctrl(
  1490. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
  1491. struct snd_soc_codec *codec)
  1492. {
  1493. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1494. tasha->zdet_gpio_cb = zdet_gpio_cb;
  1495. }
  1496. EXPORT_SYMBOL(tasha_mbhc_zdet_gpio_ctrl);
  1497. static void tasha_mbhc_zdet_ramp(struct snd_soc_codec *codec,
  1498. struct tasha_mbhc_zdet_param *zdet_param,
  1499. int32_t *zl, int32_t *zr, s16 *d1_a)
  1500. {
  1501. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  1502. int32_t zdet = 0;
  1503. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x70,
  1504. zdet_param->ldo_ctl << 4);
  1505. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN5, 0xFC,
  1506. zdet_param->btn5);
  1507. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN6, 0xFC,
  1508. zdet_param->btn6);
  1509. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN7, 0xFC,
  1510. zdet_param->btn7);
  1511. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x0F,
  1512. zdet_param->noff);
  1513. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x0F,
  1514. zdet_param->nshift);
  1515. if (!zl)
  1516. goto z_right;
  1517. /* Start impedance measurement for HPH_L */
  1518. regmap_update_bits(wcd9xxx->regmap,
  1519. WCD9335_ANA_MBHC_ZDET, 0x80, 0x80);
  1520. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_L, noff = %d\n",
  1521. __func__, zdet_param->noff);
  1522. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1523. regmap_update_bits(wcd9xxx->regmap,
  1524. WCD9335_ANA_MBHC_ZDET, 0x80, 0x00);
  1525. *zl = zdet;
  1526. z_right:
  1527. if (!zr)
  1528. return;
  1529. /* Start impedance measurement for HPH_R */
  1530. regmap_update_bits(wcd9xxx->regmap,
  1531. WCD9335_ANA_MBHC_ZDET, 0x40, 0x40);
  1532. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_R, noff = %d\n",
  1533. __func__, zdet_param->noff);
  1534. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1535. regmap_update_bits(wcd9xxx->regmap,
  1536. WCD9335_ANA_MBHC_ZDET, 0x40, 0x00);
  1537. *zr = zdet;
  1538. }
  1539. static inline void tasha_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
  1540. int32_t *z_val, int flag_l_r)
  1541. {
  1542. s16 q1;
  1543. int q1_cal;
  1544. if (*z_val < (TASHA_ZDET_VAL_400/1000))
  1545. q1 = snd_soc_read(codec,
  1546. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r));
  1547. else
  1548. q1 = snd_soc_read(codec,
  1549. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r));
  1550. if (q1 & 0x80)
  1551. q1_cal = (10000 - ((q1 & 0x7F) * 25));
  1552. else
  1553. q1_cal = (10000 + (q1 * 25));
  1554. if (q1_cal > 0)
  1555. *z_val = ((*z_val) * 10000) / q1_cal;
  1556. }
  1557. static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
  1558. uint32_t *zr)
  1559. {
  1560. struct snd_soc_codec *codec = mbhc->codec;
  1561. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1562. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1563. s16 reg0, reg1, reg2, reg3, reg4;
  1564. int32_t z1L, z1R, z1Ls;
  1565. int zMono, z_diff1, z_diff2;
  1566. bool is_fsm_disable = false;
  1567. bool is_change = false;
  1568. struct tasha_mbhc_zdet_param zdet_param[] = {
  1569. {4, 0, 4, 0x08, 0x14, 0x18}, /* < 32ohm */
  1570. {2, 0, 3, 0x18, 0x7C, 0x90}, /* 32ohm < Z < 400ohm */
  1571. {1, 4, 5, 0x18, 0x7C, 0x90}, /* 400ohm < Z < 1200ohm */
  1572. {1, 6, 7, 0x18, 0x7C, 0x90}, /* >1200ohm */
  1573. };
  1574. struct tasha_mbhc_zdet_param *zdet_param_ptr = NULL;
  1575. s16 d1_a[][4] = {
  1576. {0, 30, 90, 30},
  1577. {0, 30, 30, 5},
  1578. {0, 30, 30, 5},
  1579. {0, 30, 30, 5},
  1580. };
  1581. s16 *d1 = NULL;
  1582. if (!TASHA_IS_2_0(wcd9xxx)) {
  1583. dev_dbg(codec->dev, "%s: Z-det is not supported for this codec version\n",
  1584. __func__);
  1585. *zl = 0;
  1586. *zr = 0;
  1587. return;
  1588. }
  1589. WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
  1590. if (tasha->zdet_gpio_cb)
  1591. is_change = tasha->zdet_gpio_cb(codec, true);
  1592. reg0 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN5);
  1593. reg1 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN6);
  1594. reg2 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN7);
  1595. reg3 = snd_soc_read(codec, WCD9335_MBHC_CTL_1);
  1596. reg4 = snd_soc_read(codec, WCD9335_MBHC_ZDET_ANA_CTL);
  1597. if (snd_soc_read(codec, WCD9335_ANA_MBHC_ELECT) & 0x80) {
  1598. is_fsm_disable = true;
  1599. regmap_update_bits(wcd9xxx->regmap,
  1600. WCD9335_ANA_MBHC_ELECT, 0x80, 0x00);
  1601. }
  1602. /* For NO-jack, disable L_DET_EN before Z-det measurements */
  1603. if (mbhc->hphl_swh)
  1604. regmap_update_bits(wcd9xxx->regmap,
  1605. WCD9335_ANA_MBHC_MECH, 0x80, 0x00);
  1606. /* Enable AZ */
  1607. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1, 0x0C, 0x04);
  1608. /* Turn off 100k pull down on HPHL */
  1609. regmap_update_bits(wcd9xxx->regmap,
  1610. WCD9335_ANA_MBHC_MECH, 0x01, 0x00);
  1611. /* First get impedance on Left */
  1612. d1 = d1_a[1];
  1613. zdet_param_ptr = &zdet_param[1];
  1614. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1615. if (!TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
  1616. goto left_ch_impedance;
  1617. /* second ramp for left ch */
  1618. if (z1L < TASHA_ZDET_VAL_32) {
  1619. zdet_param_ptr = &zdet_param[0];
  1620. d1 = d1_a[0];
  1621. } else if ((z1L > TASHA_ZDET_VAL_400) && (z1L <= TASHA_ZDET_VAL_1200)) {
  1622. zdet_param_ptr = &zdet_param[2];
  1623. d1 = d1_a[2];
  1624. } else if (z1L > TASHA_ZDET_VAL_1200) {
  1625. zdet_param_ptr = &zdet_param[3];
  1626. d1 = d1_a[3];
  1627. }
  1628. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1629. left_ch_impedance:
  1630. if ((z1L == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1631. (z1L > TASHA_ZDET_VAL_100K)) {
  1632. *zl = TASHA_ZDET_FLOATING_IMPEDANCE;
  1633. zdet_param_ptr = &zdet_param[1];
  1634. d1 = d1_a[1];
  1635. } else {
  1636. *zl = z1L/1000;
  1637. tasha_wcd_mbhc_qfuse_cal(codec, zl, 0);
  1638. }
  1639. dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n",
  1640. __func__, *zl);
  1641. /* start of right impedance ramp and calculation */
  1642. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1643. if (TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
  1644. if (((z1R > TASHA_ZDET_VAL_1200) &&
  1645. (zdet_param_ptr->noff == 0x6)) ||
  1646. ((*zl) != TASHA_ZDET_FLOATING_IMPEDANCE))
  1647. goto right_ch_impedance;
  1648. /* second ramp for right ch */
  1649. if (z1R < TASHA_ZDET_VAL_32) {
  1650. zdet_param_ptr = &zdet_param[0];
  1651. d1 = d1_a[0];
  1652. } else if ((z1R > TASHA_ZDET_VAL_400) &&
  1653. (z1R <= TASHA_ZDET_VAL_1200)) {
  1654. zdet_param_ptr = &zdet_param[2];
  1655. d1 = d1_a[2];
  1656. } else if (z1R > TASHA_ZDET_VAL_1200) {
  1657. zdet_param_ptr = &zdet_param[3];
  1658. d1 = d1_a[3];
  1659. }
  1660. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1661. }
  1662. right_ch_impedance:
  1663. if ((z1R == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1664. (z1R > TASHA_ZDET_VAL_100K)) {
  1665. *zr = TASHA_ZDET_FLOATING_IMPEDANCE;
  1666. } else {
  1667. *zr = z1R/1000;
  1668. tasha_wcd_mbhc_qfuse_cal(codec, zr, 1);
  1669. }
  1670. dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n",
  1671. __func__, *zr);
  1672. /* mono/stereo detection */
  1673. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) &&
  1674. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE)) {
  1675. dev_dbg(codec->dev,
  1676. "%s: plug type is invalid or extension cable\n",
  1677. __func__);
  1678. goto zdet_complete;
  1679. }
  1680. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1681. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1682. ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
  1683. ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
  1684. dev_dbg(codec->dev,
  1685. "%s: Mono plug type with one ch floating or shorted to GND\n",
  1686. __func__);
  1687. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1688. goto zdet_complete;
  1689. }
  1690. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x02);
  1691. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x01);
  1692. if (*zl < (TASHA_ZDET_VAL_32/1000))
  1693. tasha_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1);
  1694. else
  1695. tasha_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1);
  1696. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x00);
  1697. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x00);
  1698. z1Ls /= 1000;
  1699. tasha_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0);
  1700. /* parallel of left Z and 9 ohm pull down resistor */
  1701. zMono = ((*zl) * 9) / ((*zl) + 9);
  1702. z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
  1703. z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
  1704. if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
  1705. dev_dbg(codec->dev, "%s: stereo plug type detected\n",
  1706. __func__);
  1707. mbhc->hph_type = WCD_MBHC_HPH_STEREO;
  1708. } else {
  1709. dev_dbg(codec->dev, "%s: MONO plug type detected\n",
  1710. __func__);
  1711. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1712. }
  1713. zdet_complete:
  1714. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN5, reg0);
  1715. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN6, reg1);
  1716. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN7, reg2);
  1717. /* Turn on 100k pull down on HPHL */
  1718. regmap_update_bits(wcd9xxx->regmap,
  1719. WCD9335_ANA_MBHC_MECH, 0x01, 0x01);
  1720. /* For NO-jack, re-enable L_DET_EN after Z-det measurements */
  1721. if (mbhc->hphl_swh)
  1722. regmap_update_bits(wcd9xxx->regmap,
  1723. WCD9335_ANA_MBHC_MECH, 0x80, 0x80);
  1724. snd_soc_write(codec, WCD9335_MBHC_ZDET_ANA_CTL, reg4);
  1725. snd_soc_write(codec, WCD9335_MBHC_CTL_1, reg3);
  1726. if (is_fsm_disable)
  1727. regmap_update_bits(wcd9xxx->regmap,
  1728. WCD9335_ANA_MBHC_ELECT, 0x80, 0x80);
  1729. if (tasha->zdet_gpio_cb && is_change)
  1730. tasha->zdet_gpio_cb(codec, false);
  1731. }
  1732. static void tasha_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable)
  1733. {
  1734. if (enable) {
  1735. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1736. 0x02, 0x02);
  1737. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1738. 0x40, 0x40);
  1739. } else {
  1740. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1741. 0x40, 0x00);
  1742. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1743. 0x02, 0x00);
  1744. }
  1745. }
  1746. static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec,
  1747. bool enable)
  1748. {
  1749. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1750. if (enable) {
  1751. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1752. 0x40, 0x40);
  1753. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1754. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1755. 0x10, 0x10);
  1756. } else {
  1757. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1758. 0x40, 0x00);
  1759. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1760. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1761. 0x10, 0x00);
  1762. }
  1763. }
  1764. static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc)
  1765. {
  1766. struct snd_soc_codec *codec = mbhc->codec;
  1767. if (mbhc->moist_vref == V_OFF)
  1768. return;
  1769. /* Donot enable moisture detection if jack type is NC */
  1770. if (!mbhc->hphl_swh) {
  1771. dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
  1772. __func__);
  1773. return;
  1774. }
  1775. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2,
  1776. 0x0C, mbhc->moist_vref << 2);
  1777. tasha_mbhc_hph_l_pull_up_control(codec, mbhc->moist_iref);
  1778. }
  1779. static void tasha_update_anc_state(struct snd_soc_codec *codec, bool enable,
  1780. int anc_num)
  1781. {
  1782. if (enable)
  1783. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1784. (20 * anc_num), 0x10, 0x10);
  1785. else
  1786. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1787. (20 * anc_num), 0x10, 0x00);
  1788. }
  1789. static bool tasha_is_anc_on(struct wcd_mbhc *mbhc)
  1790. {
  1791. bool anc_on = false;
  1792. u16 ancl, ancr;
  1793. ancl =
  1794. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX1_RX_PATH_CFG0)) & 0x10;
  1795. ancr =
  1796. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX2_RX_PATH_CFG0)) & 0x10;
  1797. anc_on = !!(ancl | ancr);
  1798. return anc_on;
  1799. }
  1800. static const struct wcd_mbhc_cb mbhc_cb = {
  1801. .request_irq = tasha_mbhc_request_irq,
  1802. .irq_control = tasha_mbhc_irq_control,
  1803. .free_irq = tasha_mbhc_free_irq,
  1804. .clk_setup = tasha_mbhc_clk_setup,
  1805. .map_btn_code_to_num = tasha_mbhc_btn_to_num,
  1806. .enable_mb_source = tasha_enable_ext_mb_source,
  1807. .mbhc_bias = tasha_mbhc_mbhc_bias_control,
  1808. .set_btn_thr = tasha_mbhc_program_btn_thr,
  1809. .lock_sleep = tasha_mbhc_lock_sleep,
  1810. .register_notifier = tasha_mbhc_register_notifier,
  1811. .micbias_enable_status = tasha_mbhc_micb_en_status,
  1812. .hph_pa_on_status = tasha_mbhc_hph_pa_on_status,
  1813. .hph_pull_up_control = tasha_mbhc_hph_l_pull_up_control,
  1814. .mbhc_micbias_control = tasha_mbhc_request_micbias,
  1815. .mbhc_micb_ramp_control = tasha_mbhc_micb_ramp_control,
  1816. .get_hwdep_fw_cal = tasha_get_hwdep_fw_cal,
  1817. .mbhc_micb_ctrl_thr_mic = tasha_mbhc_micb_ctrl_threshold_mic,
  1818. .compute_impedance = tasha_wcd_mbhc_calc_impedance,
  1819. .mbhc_gnd_det_ctrl = tasha_mbhc_gnd_det_ctrl,
  1820. .hph_pull_down_ctrl = tasha_mbhc_hph_pull_down_ctrl,
  1821. .mbhc_moisture_config = tasha_mbhc_moisture_config,
  1822. .update_anc_state = tasha_update_anc_state,
  1823. .is_anc_on = tasha_is_anc_on,
  1824. };
  1825. static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol,
  1826. struct snd_ctl_elem_value *ucontrol)
  1827. {
  1828. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1829. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1830. ucontrol->value.integer.value[0] = tasha->anc_slot;
  1831. return 0;
  1832. }
  1833. static int tasha_put_anc_slot(struct snd_kcontrol *kcontrol,
  1834. struct snd_ctl_elem_value *ucontrol)
  1835. {
  1836. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1837. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1838. tasha->anc_slot = ucontrol->value.integer.value[0];
  1839. return 0;
  1840. }
  1841. static int tasha_get_anc_func(struct snd_kcontrol *kcontrol,
  1842. struct snd_ctl_elem_value *ucontrol)
  1843. {
  1844. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1845. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1846. ucontrol->value.integer.value[0] = (tasha->anc_func == true ? 1 : 0);
  1847. return 0;
  1848. }
  1849. static int tasha_put_anc_func(struct snd_kcontrol *kcontrol,
  1850. struct snd_ctl_elem_value *ucontrol)
  1851. {
  1852. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1853. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1854. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  1855. mutex_lock(&tasha->codec_mutex);
  1856. tasha->anc_func = (!ucontrol->value.integer.value[0] ? false : true);
  1857. dev_dbg(codec->dev, "%s: anc_func %x", __func__, tasha->anc_func);
  1858. if (tasha->anc_func == true) {
  1859. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2 PA");
  1860. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2");
  1861. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1 PA");
  1862. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1");
  1863. snd_soc_dapm_enable_pin(dapm, "ANC HPHR PA");
  1864. snd_soc_dapm_enable_pin(dapm, "ANC HPHR");
  1865. snd_soc_dapm_enable_pin(dapm, "ANC HPHL PA");
  1866. snd_soc_dapm_enable_pin(dapm, "ANC HPHL");
  1867. snd_soc_dapm_enable_pin(dapm, "ANC EAR PA");
  1868. snd_soc_dapm_enable_pin(dapm, "ANC EAR");
  1869. snd_soc_dapm_enable_pin(dapm, "ANC SPK1 PA");
  1870. snd_soc_dapm_disable_pin(dapm, "LINEOUT2");
  1871. snd_soc_dapm_disable_pin(dapm, "LINEOUT2 PA");
  1872. snd_soc_dapm_disable_pin(dapm, "LINEOUT1");
  1873. snd_soc_dapm_disable_pin(dapm, "LINEOUT1 PA");
  1874. snd_soc_dapm_disable_pin(dapm, "HPHR");
  1875. snd_soc_dapm_disable_pin(dapm, "HPHL");
  1876. snd_soc_dapm_disable_pin(dapm, "HPHR PA");
  1877. snd_soc_dapm_disable_pin(dapm, "HPHL PA");
  1878. snd_soc_dapm_disable_pin(dapm, "EAR PA");
  1879. snd_soc_dapm_disable_pin(dapm, "EAR");
  1880. } else {
  1881. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  1882. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  1883. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  1884. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  1885. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  1886. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  1887. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  1888. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  1889. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  1890. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  1891. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  1892. snd_soc_dapm_enable_pin(dapm, "LINEOUT2");
  1893. snd_soc_dapm_enable_pin(dapm, "LINEOUT2 PA");
  1894. snd_soc_dapm_enable_pin(dapm, "LINEOUT1");
  1895. snd_soc_dapm_enable_pin(dapm, "LINEOUT1 PA");
  1896. snd_soc_dapm_enable_pin(dapm, "HPHR");
  1897. snd_soc_dapm_enable_pin(dapm, "HPHL");
  1898. snd_soc_dapm_enable_pin(dapm, "HPHR PA");
  1899. snd_soc_dapm_enable_pin(dapm, "HPHL PA");
  1900. snd_soc_dapm_enable_pin(dapm, "EAR PA");
  1901. snd_soc_dapm_enable_pin(dapm, "EAR");
  1902. }
  1903. mutex_unlock(&tasha->codec_mutex);
  1904. snd_soc_dapm_sync(dapm);
  1905. return 0;
  1906. }
  1907. static int tasha_get_clkmode(struct snd_kcontrol *kcontrol,
  1908. struct snd_ctl_elem_value *ucontrol)
  1909. {
  1910. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1911. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1912. ucontrol->value.enumerated.item[0] = tasha->clk_mode;
  1913. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1914. return 0;
  1915. }
  1916. static int tasha_put_clkmode(struct snd_kcontrol *kcontrol,
  1917. struct snd_ctl_elem_value *ucontrol)
  1918. {
  1919. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1920. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1921. tasha->clk_mode = ucontrol->value.enumerated.item[0];
  1922. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1923. return 0;
  1924. }
  1925. static int tasha_get_iir_enable_audio_mixer(
  1926. struct snd_kcontrol *kcontrol,
  1927. struct snd_ctl_elem_value *ucontrol)
  1928. {
  1929. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1930. int iir_idx = ((struct soc_multi_mixer_control *)
  1931. kcontrol->private_value)->reg;
  1932. int band_idx = ((struct soc_multi_mixer_control *)
  1933. kcontrol->private_value)->shift;
  1934. /* IIR filter band registers are at integer multiples of 16 */
  1935. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  1936. ucontrol->value.integer.value[0] = (snd_soc_read(codec, iir_reg) &
  1937. (1 << band_idx)) != 0;
  1938. dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
  1939. iir_idx, band_idx,
  1940. (uint32_t)ucontrol->value.integer.value[0]);
  1941. return 0;
  1942. }
  1943. static int tasha_hph_impedance_get(struct snd_kcontrol *kcontrol,
  1944. struct snd_ctl_elem_value *ucontrol)
  1945. {
  1946. uint32_t zl, zr;
  1947. bool hphr;
  1948. struct soc_multi_mixer_control *mc;
  1949. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1950. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1951. mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
  1952. hphr = mc->shift;
  1953. wcd_mbhc_get_impedance(&priv->mbhc, &zl, &zr);
  1954. dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
  1955. ucontrol->value.integer.value[0] = hphr ? zr : zl;
  1956. return 0;
  1957. }
  1958. static const struct snd_kcontrol_new impedance_detect_controls[] = {
  1959. SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
  1960. tasha_hph_impedance_get, NULL),
  1961. SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
  1962. tasha_hph_impedance_get, NULL),
  1963. };
  1964. static int tasha_get_hph_type(struct snd_kcontrol *kcontrol,
  1965. struct snd_ctl_elem_value *ucontrol)
  1966. {
  1967. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1968. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1969. struct wcd_mbhc *mbhc;
  1970. if (!priv) {
  1971. dev_dbg(codec->dev, "%s: wcd9335 private data is NULL\n",
  1972. __func__);
  1973. return 0;
  1974. }
  1975. mbhc = &priv->mbhc;
  1976. if (!mbhc) {
  1977. dev_dbg(codec->dev, "%s: mbhc not initialized\n", __func__);
  1978. return 0;
  1979. }
  1980. ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
  1981. dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
  1982. return 0;
  1983. }
  1984. static const struct snd_kcontrol_new hph_type_detect_controls[] = {
  1985. SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
  1986. tasha_get_hph_type, NULL),
  1987. };
  1988. static int tasha_vi_feed_mixer_get(struct snd_kcontrol *kcontrol,
  1989. struct snd_ctl_elem_value *ucontrol)
  1990. {
  1991. struct snd_soc_dapm_widget *widget =
  1992. snd_soc_dapm_kcontrol_widget(kcontrol);
  1993. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  1994. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  1995. ucontrol->value.integer.value[0] = tasha_p->vi_feed_value;
  1996. return 0;
  1997. }
  1998. static int tasha_vi_feed_mixer_put(struct snd_kcontrol *kcontrol,
  1999. struct snd_ctl_elem_value *ucontrol)
  2000. {
  2001. struct snd_soc_dapm_widget *widget =
  2002. snd_soc_dapm_kcontrol_widget(kcontrol);
  2003. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2004. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2005. struct wcd9xxx *core = tasha_p->wcd9xxx;
  2006. struct soc_multi_mixer_control *mixer =
  2007. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2008. u32 dai_id = widget->shift;
  2009. u32 port_id = mixer->shift;
  2010. u32 enable = ucontrol->value.integer.value[0];
  2011. dev_dbg(codec->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n",
  2012. __func__, enable, port_id, dai_id);
  2013. tasha_p->vi_feed_value = ucontrol->value.integer.value[0];
  2014. mutex_lock(&tasha_p->codec_mutex);
  2015. if (enable) {
  2016. if (port_id == TASHA_TX14 && !test_bit(VI_SENSE_1,
  2017. &tasha_p->status_mask)) {
  2018. list_add_tail(&core->tx_chs[TASHA_TX14].list,
  2019. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2020. set_bit(VI_SENSE_1, &tasha_p->status_mask);
  2021. }
  2022. if (port_id == TASHA_TX15 && !test_bit(VI_SENSE_2,
  2023. &tasha_p->status_mask)) {
  2024. list_add_tail(&core->tx_chs[TASHA_TX15].list,
  2025. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2026. set_bit(VI_SENSE_2, &tasha_p->status_mask);
  2027. }
  2028. } else {
  2029. if (port_id == TASHA_TX14 && test_bit(VI_SENSE_1,
  2030. &tasha_p->status_mask)) {
  2031. list_del_init(&core->tx_chs[TASHA_TX14].list);
  2032. clear_bit(VI_SENSE_1, &tasha_p->status_mask);
  2033. }
  2034. if (port_id == TASHA_TX15 && test_bit(VI_SENSE_2,
  2035. &tasha_p->status_mask)) {
  2036. list_del_init(&core->tx_chs[TASHA_TX15].list);
  2037. clear_bit(VI_SENSE_2, &tasha_p->status_mask);
  2038. }
  2039. }
  2040. mutex_unlock(&tasha_p->codec_mutex);
  2041. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL);
  2042. return 0;
  2043. }
  2044. /* virtual port entries */
  2045. static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol,
  2046. struct snd_ctl_elem_value *ucontrol)
  2047. {
  2048. struct snd_soc_dapm_widget *widget =
  2049. snd_soc_dapm_kcontrol_widget(kcontrol);
  2050. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2051. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2052. ucontrol->value.integer.value[0] = tasha_p->tx_port_value;
  2053. return 0;
  2054. }
  2055. static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol,
  2056. struct snd_ctl_elem_value *ucontrol)
  2057. {
  2058. struct snd_soc_dapm_widget *widget =
  2059. snd_soc_dapm_kcontrol_widget(kcontrol);
  2060. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2061. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2062. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2063. struct snd_soc_dapm_update *update = NULL;
  2064. struct soc_multi_mixer_control *mixer =
  2065. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2066. u32 dai_id = widget->shift;
  2067. u32 port_id = mixer->shift;
  2068. u32 enable = ucontrol->value.integer.value[0];
  2069. u32 vtable;
  2070. dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n",
  2071. __func__,
  2072. widget->name, ucontrol->id.name, tasha_p->tx_port_value,
  2073. widget->shift, ucontrol->value.integer.value[0]);
  2074. mutex_lock(&tasha_p->codec_mutex);
  2075. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2076. if (dai_id != AIF1_CAP) {
  2077. dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
  2078. __func__);
  2079. mutex_unlock(&tasha_p->codec_mutex);
  2080. return -EINVAL;
  2081. }
  2082. vtable = vport_slim_check_table[dai_id];
  2083. } else {
  2084. if (dai_id >= ARRAY_SIZE(vport_i2s_check_table)) {
  2085. dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n",
  2086. __func__, dai_id);
  2087. return -EINVAL;
  2088. }
  2089. vtable = vport_i2s_check_table[dai_id];
  2090. }
  2091. switch (dai_id) {
  2092. case AIF1_CAP:
  2093. case AIF2_CAP:
  2094. case AIF3_CAP:
  2095. /* only add to the list if value not set */
  2096. if (enable && !(tasha_p->tx_port_value & 1 << port_id)) {
  2097. if (wcd9xxx_tx_vport_validation(vtable, port_id,
  2098. tasha_p->dai, NUM_CODEC_DAIS)) {
  2099. dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n",
  2100. __func__, port_id);
  2101. mutex_unlock(&tasha_p->codec_mutex);
  2102. return 0;
  2103. }
  2104. tasha_p->tx_port_value |= 1 << port_id;
  2105. list_add_tail(&core->tx_chs[port_id].list,
  2106. &tasha_p->dai[dai_id].wcd9xxx_ch_list
  2107. );
  2108. } else if (!enable && (tasha_p->tx_port_value &
  2109. 1 << port_id)) {
  2110. tasha_p->tx_port_value &= ~(1 << port_id);
  2111. list_del_init(&core->tx_chs[port_id].list);
  2112. } else {
  2113. if (enable)
  2114. dev_dbg(codec->dev, "%s: TX%u port is used by\n"
  2115. "this virtual port\n",
  2116. __func__, port_id);
  2117. else
  2118. dev_dbg(codec->dev, "%s: TX%u port is not used by\n"
  2119. "this virtual port\n",
  2120. __func__, port_id);
  2121. /* avoid update power function */
  2122. mutex_unlock(&tasha_p->codec_mutex);
  2123. return 0;
  2124. }
  2125. break;
  2126. case AIF4_MAD_TX:
  2127. case AIF5_CPE_TX:
  2128. break;
  2129. default:
  2130. pr_err("Unknown AIF %d\n", dai_id);
  2131. mutex_unlock(&tasha_p->codec_mutex);
  2132. return -EINVAL;
  2133. }
  2134. pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__,
  2135. widget->name, widget->sname, tasha_p->tx_port_value,
  2136. widget->shift);
  2137. mutex_unlock(&tasha_p->codec_mutex);
  2138. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
  2139. return 0;
  2140. }
  2141. static int slim_rx_mux_get(struct snd_kcontrol *kcontrol,
  2142. struct snd_ctl_elem_value *ucontrol)
  2143. {
  2144. struct snd_soc_dapm_widget *widget =
  2145. snd_soc_dapm_kcontrol_widget(kcontrol);
  2146. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2147. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2148. ucontrol->value.enumerated.item[0] =
  2149. tasha_p->rx_port_value[widget->shift];
  2150. return 0;
  2151. }
  2152. static const char *const slim_rx_mux_text[] = {
  2153. "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB", "AIF_MIX1_PB"
  2154. };
  2155. static int slim_rx_mux_put(struct snd_kcontrol *kcontrol,
  2156. struct snd_ctl_elem_value *ucontrol)
  2157. {
  2158. struct snd_soc_dapm_widget *widget =
  2159. snd_soc_dapm_kcontrol_widget(kcontrol);
  2160. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2161. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2162. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2163. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  2164. struct snd_soc_dapm_update *update = NULL;
  2165. unsigned int rx_port_value;
  2166. u32 port_id = widget->shift;
  2167. tasha_p->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
  2168. rx_port_value = tasha_p->rx_port_value[port_id];
  2169. pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__,
  2170. widget->name, ucontrol->id.name, rx_port_value,
  2171. widget->shift, ucontrol->value.integer.value[0]);
  2172. mutex_lock(&tasha_p->codec_mutex);
  2173. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2174. if (rx_port_value > 2) {
  2175. dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
  2176. __func__);
  2177. goto err;
  2178. }
  2179. }
  2180. /* value need to match the Virtual port and AIF number */
  2181. switch (rx_port_value) {
  2182. case 0:
  2183. list_del_init(&core->rx_chs[port_id].list);
  2184. break;
  2185. case 1:
  2186. if (wcd9xxx_rx_vport_validation(port_id +
  2187. TASHA_RX_PORT_START_NUMBER,
  2188. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list)) {
  2189. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2190. __func__, port_id);
  2191. goto rtn;
  2192. }
  2193. list_add_tail(&core->rx_chs[port_id].list,
  2194. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list);
  2195. break;
  2196. case 2:
  2197. if (wcd9xxx_rx_vport_validation(port_id +
  2198. TASHA_RX_PORT_START_NUMBER,
  2199. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list)) {
  2200. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2201. __func__, port_id);
  2202. goto rtn;
  2203. }
  2204. list_add_tail(&core->rx_chs[port_id].list,
  2205. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list);
  2206. break;
  2207. case 3:
  2208. if (wcd9xxx_rx_vport_validation(port_id +
  2209. TASHA_RX_PORT_START_NUMBER,
  2210. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list)) {
  2211. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2212. __func__, port_id);
  2213. goto rtn;
  2214. }
  2215. list_add_tail(&core->rx_chs[port_id].list,
  2216. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list);
  2217. break;
  2218. case 4:
  2219. if (wcd9xxx_rx_vport_validation(port_id +
  2220. TASHA_RX_PORT_START_NUMBER,
  2221. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list)) {
  2222. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2223. __func__, port_id);
  2224. goto rtn;
  2225. }
  2226. list_add_tail(&core->rx_chs[port_id].list,
  2227. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list);
  2228. break;
  2229. case 5:
  2230. if (wcd9xxx_rx_vport_validation(port_id +
  2231. TASHA_RX_PORT_START_NUMBER,
  2232. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list)) {
  2233. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2234. __func__, port_id);
  2235. goto rtn;
  2236. }
  2237. list_add_tail(&core->rx_chs[port_id].list,
  2238. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list);
  2239. break;
  2240. default:
  2241. pr_err("Unknown AIF %d\n", rx_port_value);
  2242. goto err;
  2243. }
  2244. rtn:
  2245. mutex_unlock(&tasha_p->codec_mutex);
  2246. snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
  2247. rx_port_value, e, update);
  2248. return 0;
  2249. err:
  2250. mutex_unlock(&tasha_p->codec_mutex);
  2251. return -EINVAL;
  2252. }
  2253. static const struct soc_enum slim_rx_mux_enum =
  2254. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text);
  2255. static const struct snd_kcontrol_new slim_rx_mux[TASHA_RX_MAX] = {
  2256. SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum,
  2257. slim_rx_mux_get, slim_rx_mux_put),
  2258. SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
  2259. slim_rx_mux_get, slim_rx_mux_put),
  2260. SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
  2261. slim_rx_mux_get, slim_rx_mux_put),
  2262. SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
  2263. slim_rx_mux_get, slim_rx_mux_put),
  2264. SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
  2265. slim_rx_mux_get, slim_rx_mux_put),
  2266. SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
  2267. slim_rx_mux_get, slim_rx_mux_put),
  2268. SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
  2269. slim_rx_mux_get, slim_rx_mux_put),
  2270. SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
  2271. slim_rx_mux_get, slim_rx_mux_put),
  2272. };
  2273. static const struct snd_kcontrol_new aif4_vi_mixer[] = {
  2274. SOC_SINGLE_EXT("SPKR_VI_1", SND_SOC_NOPM, TASHA_TX14, 1, 0,
  2275. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2276. SOC_SINGLE_EXT("SPKR_VI_2", SND_SOC_NOPM, TASHA_TX15, 1, 0,
  2277. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2278. };
  2279. static const struct snd_kcontrol_new aif1_cap_mixer[] = {
  2280. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2281. slim_tx_mixer_get, slim_tx_mixer_put),
  2282. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2283. slim_tx_mixer_get, slim_tx_mixer_put),
  2284. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2285. slim_tx_mixer_get, slim_tx_mixer_put),
  2286. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2287. slim_tx_mixer_get, slim_tx_mixer_put),
  2288. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2289. slim_tx_mixer_get, slim_tx_mixer_put),
  2290. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2291. slim_tx_mixer_get, slim_tx_mixer_put),
  2292. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2293. slim_tx_mixer_get, slim_tx_mixer_put),
  2294. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2295. slim_tx_mixer_get, slim_tx_mixer_put),
  2296. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2297. slim_tx_mixer_get, slim_tx_mixer_put),
  2298. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2299. slim_tx_mixer_get, slim_tx_mixer_put),
  2300. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2301. slim_tx_mixer_get, slim_tx_mixer_put),
  2302. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2303. slim_tx_mixer_get, slim_tx_mixer_put),
  2304. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2305. slim_tx_mixer_get, slim_tx_mixer_put),
  2306. };
  2307. static const struct snd_kcontrol_new aif2_cap_mixer[] = {
  2308. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2309. slim_tx_mixer_get, slim_tx_mixer_put),
  2310. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2311. slim_tx_mixer_get, slim_tx_mixer_put),
  2312. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2313. slim_tx_mixer_get, slim_tx_mixer_put),
  2314. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2315. slim_tx_mixer_get, slim_tx_mixer_put),
  2316. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2317. slim_tx_mixer_get, slim_tx_mixer_put),
  2318. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2319. slim_tx_mixer_get, slim_tx_mixer_put),
  2320. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2321. slim_tx_mixer_get, slim_tx_mixer_put),
  2322. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2323. slim_tx_mixer_get, slim_tx_mixer_put),
  2324. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2325. slim_tx_mixer_get, slim_tx_mixer_put),
  2326. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2327. slim_tx_mixer_get, slim_tx_mixer_put),
  2328. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2329. slim_tx_mixer_get, slim_tx_mixer_put),
  2330. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2331. slim_tx_mixer_get, slim_tx_mixer_put),
  2332. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2333. slim_tx_mixer_get, slim_tx_mixer_put),
  2334. };
  2335. static const struct snd_kcontrol_new aif3_cap_mixer[] = {
  2336. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2337. slim_tx_mixer_get, slim_tx_mixer_put),
  2338. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2339. slim_tx_mixer_get, slim_tx_mixer_put),
  2340. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2341. slim_tx_mixer_get, slim_tx_mixer_put),
  2342. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2343. slim_tx_mixer_get, slim_tx_mixer_put),
  2344. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2345. slim_tx_mixer_get, slim_tx_mixer_put),
  2346. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2347. slim_tx_mixer_get, slim_tx_mixer_put),
  2348. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2349. slim_tx_mixer_get, slim_tx_mixer_put),
  2350. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2351. slim_tx_mixer_get, slim_tx_mixer_put),
  2352. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2353. slim_tx_mixer_get, slim_tx_mixer_put),
  2354. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2355. slim_tx_mixer_get, slim_tx_mixer_put),
  2356. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2357. slim_tx_mixer_get, slim_tx_mixer_put),
  2358. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2359. slim_tx_mixer_get, slim_tx_mixer_put),
  2360. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2361. slim_tx_mixer_get, slim_tx_mixer_put),
  2362. };
  2363. static const struct snd_kcontrol_new aif4_mad_mixer[] = {
  2364. SOC_SINGLE_EXT("SLIM TX12", SND_SOC_NOPM, TASHA_TX12, 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. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, 0, 1, 0,
  2369. slim_tx_mixer_get, slim_tx_mixer_put),
  2370. };
  2371. static const struct snd_kcontrol_new rx_int1_spline_mix_switch[] = {
  2372. SOC_DAPM_SINGLE("HPHL Switch", SND_SOC_NOPM, 0, 1, 0)
  2373. };
  2374. static const struct snd_kcontrol_new rx_int2_spline_mix_switch[] = {
  2375. SOC_DAPM_SINGLE("HPHR Switch", SND_SOC_NOPM, 0, 1, 0)
  2376. };
  2377. static const struct snd_kcontrol_new rx_int3_spline_mix_switch[] = {
  2378. SOC_DAPM_SINGLE("LO1 Switch", SND_SOC_NOPM, 0, 1, 0)
  2379. };
  2380. static const struct snd_kcontrol_new rx_int4_spline_mix_switch[] = {
  2381. SOC_DAPM_SINGLE("LO2 Switch", SND_SOC_NOPM, 0, 1, 0)
  2382. };
  2383. static const struct snd_kcontrol_new rx_int5_spline_mix_switch[] = {
  2384. SOC_DAPM_SINGLE("LO3 Switch", SND_SOC_NOPM, 0, 1, 0)
  2385. };
  2386. static const struct snd_kcontrol_new rx_int6_spline_mix_switch[] = {
  2387. SOC_DAPM_SINGLE("LO4 Switch", SND_SOC_NOPM, 0, 1, 0)
  2388. };
  2389. static const struct snd_kcontrol_new rx_int7_spline_mix_switch[] = {
  2390. SOC_DAPM_SINGLE("SPKRL Switch", SND_SOC_NOPM, 0, 1, 0)
  2391. };
  2392. static const struct snd_kcontrol_new rx_int8_spline_mix_switch[] = {
  2393. SOC_DAPM_SINGLE("SPKRR Switch", SND_SOC_NOPM, 0, 1, 0)
  2394. };
  2395. static const struct snd_kcontrol_new rx_int5_vbat_mix_switch[] = {
  2396. SOC_DAPM_SINGLE("LO3 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2397. };
  2398. static const struct snd_kcontrol_new rx_int6_vbat_mix_switch[] = {
  2399. SOC_DAPM_SINGLE("LO4 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2400. };
  2401. static const struct snd_kcontrol_new rx_int7_vbat_mix_switch[] = {
  2402. SOC_DAPM_SINGLE("SPKRL VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2403. };
  2404. static const struct snd_kcontrol_new rx_int8_vbat_mix_switch[] = {
  2405. SOC_DAPM_SINGLE("SPKRR VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2406. };
  2407. static const struct snd_kcontrol_new cpe_in_mix_switch[] = {
  2408. SOC_DAPM_SINGLE("MAD_BYPASS", SND_SOC_NOPM, 0, 1, 0)
  2409. };
  2410. static int tasha_put_iir_enable_audio_mixer(
  2411. struct snd_kcontrol *kcontrol,
  2412. struct snd_ctl_elem_value *ucontrol)
  2413. {
  2414. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2415. int iir_idx = ((struct soc_multi_mixer_control *)
  2416. kcontrol->private_value)->reg;
  2417. int band_idx = ((struct soc_multi_mixer_control *)
  2418. kcontrol->private_value)->shift;
  2419. bool iir_band_en_status;
  2420. int value = ucontrol->value.integer.value[0];
  2421. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  2422. /* Mask first 5 bits, 6-8 are reserved */
  2423. snd_soc_update_bits(codec, iir_reg, (1 << band_idx),
  2424. (value << band_idx));
  2425. iir_band_en_status = ((snd_soc_read(codec, iir_reg) &
  2426. (1 << band_idx)) != 0);
  2427. pr_debug("%s: IIR #%d band #%d enable %d\n", __func__,
  2428. iir_idx, band_idx, iir_band_en_status);
  2429. return 0;
  2430. }
  2431. static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec,
  2432. int iir_idx, int band_idx,
  2433. int coeff_idx)
  2434. {
  2435. uint32_t value = 0;
  2436. /* Address does not automatically update if reading */
  2437. snd_soc_write(codec,
  2438. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2439. ((band_idx * BAND_MAX + coeff_idx)
  2440. * sizeof(uint32_t)) & 0x7F);
  2441. value |= snd_soc_read(codec,
  2442. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx));
  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) + 1) & 0x7F);
  2447. value |= (snd_soc_read(codec,
  2448. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2449. 16 * iir_idx)) << 8);
  2450. snd_soc_write(codec,
  2451. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2452. ((band_idx * BAND_MAX + coeff_idx)
  2453. * sizeof(uint32_t) + 2) & 0x7F);
  2454. value |= (snd_soc_read(codec,
  2455. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2456. 16 * iir_idx)) << 16);
  2457. snd_soc_write(codec,
  2458. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2459. ((band_idx * BAND_MAX + coeff_idx)
  2460. * sizeof(uint32_t) + 3) & 0x7F);
  2461. /* Mask bits top 2 bits since they are reserved */
  2462. value |= ((snd_soc_read(codec,
  2463. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2464. 16 * iir_idx)) & 0x3F) << 24);
  2465. return value;
  2466. }
  2467. static int tasha_get_iir_band_audio_mixer(
  2468. struct snd_kcontrol *kcontrol,
  2469. struct snd_ctl_elem_value *ucontrol)
  2470. {
  2471. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2472. int iir_idx = ((struct soc_multi_mixer_control *)
  2473. kcontrol->private_value)->reg;
  2474. int band_idx = ((struct soc_multi_mixer_control *)
  2475. kcontrol->private_value)->shift;
  2476. ucontrol->value.integer.value[0] =
  2477. get_iir_band_coeff(codec, iir_idx, band_idx, 0);
  2478. ucontrol->value.integer.value[1] =
  2479. get_iir_band_coeff(codec, iir_idx, band_idx, 1);
  2480. ucontrol->value.integer.value[2] =
  2481. get_iir_band_coeff(codec, iir_idx, band_idx, 2);
  2482. ucontrol->value.integer.value[3] =
  2483. get_iir_band_coeff(codec, iir_idx, band_idx, 3);
  2484. ucontrol->value.integer.value[4] =
  2485. get_iir_band_coeff(codec, iir_idx, band_idx, 4);
  2486. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  2487. "%s: IIR #%d band #%d b1 = 0x%x\n"
  2488. "%s: IIR #%d band #%d b2 = 0x%x\n"
  2489. "%s: IIR #%d band #%d a1 = 0x%x\n"
  2490. "%s: IIR #%d band #%d a2 = 0x%x\n",
  2491. __func__, iir_idx, band_idx,
  2492. (uint32_t)ucontrol->value.integer.value[0],
  2493. __func__, iir_idx, band_idx,
  2494. (uint32_t)ucontrol->value.integer.value[1],
  2495. __func__, iir_idx, band_idx,
  2496. (uint32_t)ucontrol->value.integer.value[2],
  2497. __func__, iir_idx, band_idx,
  2498. (uint32_t)ucontrol->value.integer.value[3],
  2499. __func__, iir_idx, band_idx,
  2500. (uint32_t)ucontrol->value.integer.value[4]);
  2501. return 0;
  2502. }
  2503. static void set_iir_band_coeff(struct snd_soc_codec *codec,
  2504. int iir_idx, int band_idx,
  2505. uint32_t value)
  2506. {
  2507. snd_soc_write(codec,
  2508. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2509. (value & 0xFF));
  2510. snd_soc_write(codec,
  2511. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2512. (value >> 8) & 0xFF);
  2513. snd_soc_write(codec,
  2514. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2515. (value >> 16) & 0xFF);
  2516. /* Mask top 2 bits, 7-8 are reserved */
  2517. snd_soc_write(codec,
  2518. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2519. (value >> 24) & 0x3F);
  2520. }
  2521. static void tasha_codec_enable_int_port(struct wcd9xxx_codec_dai_data *dai,
  2522. struct snd_soc_codec *codec)
  2523. {
  2524. struct wcd9xxx_ch *ch;
  2525. int port_num = 0;
  2526. unsigned short reg = 0;
  2527. u8 val = 0;
  2528. struct tasha_priv *tasha_p;
  2529. if (!dai || !codec) {
  2530. pr_err("%s: Invalid params\n", __func__);
  2531. return;
  2532. }
  2533. tasha_p = snd_soc_codec_get_drvdata(codec);
  2534. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2535. if (ch->port >= TASHA_RX_PORT_START_NUMBER) {
  2536. port_num = ch->port - TASHA_RX_PORT_START_NUMBER;
  2537. reg = TASHA_SLIM_PGD_PORT_INT_EN0 + (port_num / 8);
  2538. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2539. reg);
  2540. if (!(val & BYTE_BIT_MASK(port_num))) {
  2541. val |= BYTE_BIT_MASK(port_num);
  2542. wcd9xxx_interface_reg_write(
  2543. tasha_p->wcd9xxx, reg, val);
  2544. val = wcd9xxx_interface_reg_read(
  2545. tasha_p->wcd9xxx, reg);
  2546. }
  2547. } else {
  2548. port_num = ch->port;
  2549. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 + (port_num / 8);
  2550. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2551. reg);
  2552. if (!(val & BYTE_BIT_MASK(port_num))) {
  2553. val |= BYTE_BIT_MASK(port_num);
  2554. wcd9xxx_interface_reg_write(tasha_p->wcd9xxx,
  2555. reg, val);
  2556. val = wcd9xxx_interface_reg_read(
  2557. tasha_p->wcd9xxx, reg);
  2558. }
  2559. }
  2560. }
  2561. }
  2562. static int tasha_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai,
  2563. bool up)
  2564. {
  2565. int ret = 0;
  2566. struct wcd9xxx_ch *ch;
  2567. if (up) {
  2568. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2569. ret = wcd9xxx_get_slave_port(ch->ch_num);
  2570. if (ret < 0) {
  2571. pr_err("%s: Invalid slave port ID: %d\n",
  2572. __func__, ret);
  2573. ret = -EINVAL;
  2574. } else {
  2575. set_bit(ret, &dai->ch_mask);
  2576. }
  2577. }
  2578. } else {
  2579. ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0),
  2580. msecs_to_jiffies(
  2581. TASHA_SLIM_CLOSE_TIMEOUT));
  2582. if (!ret) {
  2583. pr_err("%s: Slim close tx/rx wait timeout, ch_mask:0x%lx\n",
  2584. __func__, dai->ch_mask);
  2585. ret = -ETIMEDOUT;
  2586. } else {
  2587. ret = 0;
  2588. }
  2589. }
  2590. return ret;
  2591. }
  2592. static int tasha_codec_enable_slimrx(struct snd_soc_dapm_widget *w,
  2593. struct snd_kcontrol *kcontrol,
  2594. int event)
  2595. {
  2596. struct wcd9xxx *core;
  2597. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2598. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2599. int ret = 0;
  2600. struct wcd9xxx_codec_dai_data *dai;
  2601. core = dev_get_drvdata(codec->dev->parent);
  2602. dev_dbg(codec->dev, "%s: event called! codec name %s num_dai %d\n"
  2603. "stream name %s event %d\n",
  2604. __func__, codec->component.name,
  2605. codec->component.num_dai, w->sname, event);
  2606. /* Execute the callback only if interface type is slimbus */
  2607. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2608. return 0;
  2609. dai = &tasha_p->dai[w->shift];
  2610. dev_dbg(codec->dev, "%s: w->name %s w->shift %d event %d\n",
  2611. __func__, w->name, w->shift, event);
  2612. switch (event) {
  2613. case SND_SOC_DAPM_POST_PMU:
  2614. dai->bus_down_in_recovery = false;
  2615. tasha_codec_enable_int_port(dai, codec);
  2616. (void) tasha_codec_enable_slim_chmask(dai, true);
  2617. ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2618. dai->rate, dai->bit_width,
  2619. &dai->grph);
  2620. break;
  2621. case SND_SOC_DAPM_PRE_PMD:
  2622. tasha_codec_vote_max_bw(codec, true);
  2623. break;
  2624. case SND_SOC_DAPM_POST_PMD:
  2625. ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list,
  2626. dai->grph);
  2627. dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n",
  2628. __func__, ret);
  2629. if (!dai->bus_down_in_recovery)
  2630. ret = tasha_codec_enable_slim_chmask(dai, false);
  2631. else
  2632. dev_dbg(codec->dev,
  2633. "%s: bus in recovery skip enable slim_chmask",
  2634. __func__);
  2635. ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2636. dai->grph);
  2637. break;
  2638. }
  2639. return ret;
  2640. }
  2641. static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w,
  2642. struct snd_kcontrol *kcontrol,
  2643. int event)
  2644. {
  2645. struct wcd9xxx *core = NULL;
  2646. struct snd_soc_codec *codec = NULL;
  2647. struct tasha_priv *tasha_p = NULL;
  2648. int ret = 0;
  2649. struct wcd9xxx_codec_dai_data *dai = NULL;
  2650. if (!w) {
  2651. pr_err("%s invalid params\n", __func__);
  2652. return -EINVAL;
  2653. }
  2654. codec = snd_soc_dapm_to_codec(w->dapm);
  2655. tasha_p = snd_soc_codec_get_drvdata(codec);
  2656. core = tasha_p->wcd9xxx;
  2657. dev_dbg(codec->dev, "%s: num_dai %d stream name %s\n",
  2658. __func__, codec->component.num_dai, w->sname);
  2659. /* Execute the callback only if interface type is slimbus */
  2660. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2661. dev_err(codec->dev, "%s Interface is not correct", __func__);
  2662. return 0;
  2663. }
  2664. dev_dbg(codec->dev, "%s(): w->name %s event %d w->shift %d\n",
  2665. __func__, w->name, event, w->shift);
  2666. if (w->shift != AIF4_VIFEED) {
  2667. pr_err("%s Error in enabling the tx path\n", __func__);
  2668. ret = -EINVAL;
  2669. goto out_vi;
  2670. }
  2671. dai = &tasha_p->dai[w->shift];
  2672. switch (event) {
  2673. case SND_SOC_DAPM_POST_PMU:
  2674. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2675. dev_dbg(codec->dev, "%s: spkr1 enabled\n", __func__);
  2676. /* Enable V&I sensing */
  2677. snd_soc_update_bits(codec,
  2678. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2679. snd_soc_update_bits(codec,
  2680. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2681. 0x20);
  2682. snd_soc_update_bits(codec,
  2683. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x00);
  2684. snd_soc_update_bits(codec,
  2685. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x0F,
  2686. 0x00);
  2687. snd_soc_update_bits(codec,
  2688. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10);
  2689. snd_soc_update_bits(codec,
  2690. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2691. 0x10);
  2692. snd_soc_update_bits(codec,
  2693. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00);
  2694. snd_soc_update_bits(codec,
  2695. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2696. 0x00);
  2697. }
  2698. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2699. pr_debug("%s: spkr2 enabled\n", __func__);
  2700. /* Enable V&I sensing */
  2701. snd_soc_update_bits(codec,
  2702. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2703. 0x20);
  2704. snd_soc_update_bits(codec,
  2705. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2706. 0x20);
  2707. snd_soc_update_bits(codec,
  2708. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x0F,
  2709. 0x00);
  2710. snd_soc_update_bits(codec,
  2711. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x0F,
  2712. 0x00);
  2713. snd_soc_update_bits(codec,
  2714. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2715. 0x10);
  2716. snd_soc_update_bits(codec,
  2717. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2718. 0x10);
  2719. snd_soc_update_bits(codec,
  2720. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2721. 0x00);
  2722. snd_soc_update_bits(codec,
  2723. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2724. 0x00);
  2725. }
  2726. dai->bus_down_in_recovery = false;
  2727. tasha_codec_enable_int_port(dai, codec);
  2728. (void) tasha_codec_enable_slim_chmask(dai, true);
  2729. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2730. dai->rate, dai->bit_width,
  2731. &dai->grph);
  2732. break;
  2733. case SND_SOC_DAPM_POST_PMD:
  2734. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2735. dai->grph);
  2736. if (ret)
  2737. dev_err(codec->dev, "%s error in close_slim_sch_tx %d\n",
  2738. __func__, ret);
  2739. if (!dai->bus_down_in_recovery)
  2740. ret = tasha_codec_enable_slim_chmask(dai, false);
  2741. if (ret < 0) {
  2742. ret = wcd9xxx_disconnect_port(core,
  2743. &dai->wcd9xxx_ch_list,
  2744. dai->grph);
  2745. dev_dbg(codec->dev, "%s: Disconnect TX port, ret = %d\n",
  2746. __func__, ret);
  2747. }
  2748. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2749. /* Disable V&I sensing */
  2750. dev_dbg(codec->dev, "%s: spkr1 disabled\n", __func__);
  2751. snd_soc_update_bits(codec,
  2752. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2753. snd_soc_update_bits(codec,
  2754. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2755. 0x20);
  2756. snd_soc_update_bits(codec,
  2757. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00);
  2758. snd_soc_update_bits(codec,
  2759. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2760. 0x00);
  2761. }
  2762. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2763. /* Disable V&I sensing */
  2764. dev_dbg(codec->dev, "%s: spkr2 disabled\n", __func__);
  2765. snd_soc_update_bits(codec,
  2766. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2767. 0x20);
  2768. snd_soc_update_bits(codec,
  2769. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2770. 0x20);
  2771. snd_soc_update_bits(codec,
  2772. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2773. 0x00);
  2774. snd_soc_update_bits(codec,
  2775. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2776. 0x00);
  2777. }
  2778. break;
  2779. }
  2780. out_vi:
  2781. return ret;
  2782. }
  2783. /*
  2784. * __tasha_codec_enable_slimtx: Enable the slimbus slave port
  2785. * for TX path
  2786. * @codec: Handle to the codec for which the slave port is to be
  2787. * enabled.
  2788. * @dai_data: The dai specific data for dai which is enabled.
  2789. */
  2790. static int __tasha_codec_enable_slimtx(struct snd_soc_codec *codec,
  2791. int event, struct wcd9xxx_codec_dai_data *dai)
  2792. {
  2793. struct wcd9xxx *core;
  2794. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2795. int ret = 0;
  2796. /* Execute the callback only if interface type is slimbus */
  2797. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2798. return 0;
  2799. dev_dbg(codec->dev,
  2800. "%s: event = %d\n", __func__, event);
  2801. core = dev_get_drvdata(codec->dev->parent);
  2802. switch (event) {
  2803. case SND_SOC_DAPM_POST_PMU:
  2804. dai->bus_down_in_recovery = false;
  2805. tasha_codec_enable_int_port(dai, codec);
  2806. (void) tasha_codec_enable_slim_chmask(dai, true);
  2807. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2808. dai->rate, dai->bit_width,
  2809. &dai->grph);
  2810. break;
  2811. case SND_SOC_DAPM_POST_PMD:
  2812. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2813. dai->grph);
  2814. if (!dai->bus_down_in_recovery)
  2815. ret = tasha_codec_enable_slim_chmask(dai, false);
  2816. if (ret < 0) {
  2817. ret = wcd9xxx_disconnect_port(core,
  2818. &dai->wcd9xxx_ch_list,
  2819. dai->grph);
  2820. pr_debug("%s: Disconnect TX port, ret = %d\n",
  2821. __func__, ret);
  2822. }
  2823. break;
  2824. }
  2825. return ret;
  2826. }
  2827. static int tasha_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
  2828. struct snd_kcontrol *kcontrol,
  2829. int event)
  2830. {
  2831. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2832. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2833. struct wcd9xxx_codec_dai_data *dai;
  2834. dev_dbg(codec->dev,
  2835. "%s: w->name %s, w->shift = %d, num_dai %d stream name %s\n",
  2836. __func__, w->name, w->shift,
  2837. codec->component.num_dai, w->sname);
  2838. dai = &tasha_p->dai[w->shift];
  2839. return __tasha_codec_enable_slimtx(codec, event, dai);
  2840. }
  2841. static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_codec *codec, int event)
  2842. {
  2843. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2844. struct wcd9xxx_codec_dai_data *dai;
  2845. u8 bit_width, rate, buf_period;
  2846. dai = &tasha_p->dai[AIF4_MAD_TX];
  2847. switch (event) {
  2848. case SND_SOC_DAPM_POST_PMU:
  2849. switch (dai->bit_width) {
  2850. case 32:
  2851. bit_width = 0xF;
  2852. break;
  2853. case 24:
  2854. bit_width = 0xE;
  2855. break;
  2856. case 20:
  2857. bit_width = 0xD;
  2858. break;
  2859. case 16:
  2860. default:
  2861. bit_width = 0x0;
  2862. break;
  2863. }
  2864. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x0F,
  2865. bit_width);
  2866. switch (dai->rate) {
  2867. case 384000:
  2868. rate = 0x30;
  2869. break;
  2870. case 192000:
  2871. rate = 0x20;
  2872. break;
  2873. case 48000:
  2874. rate = 0x10;
  2875. break;
  2876. case 16000:
  2877. default:
  2878. rate = 0x00;
  2879. break;
  2880. }
  2881. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x70,
  2882. rate);
  2883. buf_period = (dai->rate * (dai->bit_width/8)) / (16*1000);
  2884. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD,
  2885. 0xFF, buf_period);
  2886. dev_dbg(codec->dev, "%s: PP buffer period= 0x%x\n",
  2887. __func__, buf_period);
  2888. break;
  2889. case SND_SOC_DAPM_POST_PMD:
  2890. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x3C);
  2891. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD, 0x60);
  2892. break;
  2893. default:
  2894. break;
  2895. }
  2896. }
  2897. /*
  2898. * tasha_codec_get_mad_port_id: Callback function that will be invoked
  2899. * to get the port ID for MAD.
  2900. * @codec: Handle to the codec
  2901. * @port_id: cpe port_id needs to enable
  2902. */
  2903. static int tasha_codec_get_mad_port_id(struct snd_soc_codec *codec,
  2904. u16 *port_id)
  2905. {
  2906. struct tasha_priv *tasha_p;
  2907. struct wcd9xxx_codec_dai_data *dai;
  2908. struct wcd9xxx_ch *ch;
  2909. if (!port_id || !codec)
  2910. return -EINVAL;
  2911. tasha_p = snd_soc_codec_get_drvdata(codec);
  2912. if (!tasha_p)
  2913. return -EINVAL;
  2914. dai = &tasha_p->dai[AIF4_MAD_TX];
  2915. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2916. if (ch->port == TASHA_TX12)
  2917. *port_id = WCD_CPE_AFE_OUT_PORT_2;
  2918. else if (ch->port == TASHA_TX13)
  2919. *port_id = WCD_CPE_AFE_OUT_PORT_4;
  2920. else {
  2921. dev_err(codec->dev, "%s: invalid mad_port = %d\n",
  2922. __func__, ch->port);
  2923. return -EINVAL;
  2924. }
  2925. }
  2926. dev_dbg(codec->dev, "%s: port_id = %d\n", __func__, *port_id);
  2927. return 0;
  2928. }
  2929. /*
  2930. * tasha_codec_enable_slimtx_mad: Callback function that will be invoked
  2931. * to setup the slave port for MAD.
  2932. * @codec: Handle to the codec
  2933. * @event: Indicates whether to enable or disable the slave port
  2934. */
  2935. static int tasha_codec_enable_slimtx_mad(struct snd_soc_codec *codec,
  2936. u8 event)
  2937. {
  2938. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2939. struct wcd9xxx_codec_dai_data *dai;
  2940. struct wcd9xxx_ch *ch;
  2941. int dapm_event = SND_SOC_DAPM_POST_PMU;
  2942. u16 port = 0;
  2943. int ret = 0;
  2944. dai = &tasha_p->dai[AIF4_MAD_TX];
  2945. if (event == 0)
  2946. dapm_event = SND_SOC_DAPM_POST_PMD;
  2947. dev_dbg(codec->dev,
  2948. "%s: mad_channel, event = 0x%x\n",
  2949. __func__, event);
  2950. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2951. dev_dbg(codec->dev, "%s: mad_port = %d, event = 0x%x\n",
  2952. __func__, ch->port, event);
  2953. if (ch->port == TASHA_TX13) {
  2954. tasha_codec_cpe_pp_set_cfg(codec, dapm_event);
  2955. port = TASHA_TX13;
  2956. break;
  2957. }
  2958. }
  2959. ret = __tasha_codec_enable_slimtx(codec, dapm_event, dai);
  2960. if (port == TASHA_TX13) {
  2961. switch (dapm_event) {
  2962. case SND_SOC_DAPM_POST_PMU:
  2963. snd_soc_update_bits(codec,
  2964. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2965. 0x20, 0x00);
  2966. snd_soc_update_bits(codec,
  2967. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2968. 0x03, 0x02);
  2969. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2970. 0x80, 0x80);
  2971. break;
  2972. case SND_SOC_DAPM_POST_PMD:
  2973. snd_soc_update_bits(codec,
  2974. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2975. 0x20, 0x20);
  2976. snd_soc_update_bits(codec,
  2977. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2978. 0x03, 0x00);
  2979. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2980. 0x80, 0x00);
  2981. break;
  2982. }
  2983. }
  2984. return ret;
  2985. }
  2986. static int tasha_put_iir_band_audio_mixer(
  2987. struct snd_kcontrol *kcontrol,
  2988. struct snd_ctl_elem_value *ucontrol)
  2989. {
  2990. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2991. int iir_idx = ((struct soc_multi_mixer_control *)
  2992. kcontrol->private_value)->reg;
  2993. int band_idx = ((struct soc_multi_mixer_control *)
  2994. kcontrol->private_value)->shift;
  2995. /*
  2996. * Mask top bit it is reserved
  2997. * Updates addr automatically for each B2 write
  2998. */
  2999. snd_soc_write(codec,
  3000. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  3001. (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
  3002. set_iir_band_coeff(codec, iir_idx, band_idx,
  3003. ucontrol->value.integer.value[0]);
  3004. set_iir_band_coeff(codec, iir_idx, band_idx,
  3005. ucontrol->value.integer.value[1]);
  3006. set_iir_band_coeff(codec, iir_idx, band_idx,
  3007. ucontrol->value.integer.value[2]);
  3008. set_iir_band_coeff(codec, iir_idx, band_idx,
  3009. ucontrol->value.integer.value[3]);
  3010. set_iir_band_coeff(codec, iir_idx, band_idx,
  3011. ucontrol->value.integer.value[4]);
  3012. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  3013. "%s: IIR #%d band #%d b1 = 0x%x\n"
  3014. "%s: IIR #%d band #%d b2 = 0x%x\n"
  3015. "%s: IIR #%d band #%d a1 = 0x%x\n"
  3016. "%s: IIR #%d band #%d a2 = 0x%x\n",
  3017. __func__, iir_idx, band_idx,
  3018. get_iir_band_coeff(codec, iir_idx, band_idx, 0),
  3019. __func__, iir_idx, band_idx,
  3020. get_iir_band_coeff(codec, iir_idx, band_idx, 1),
  3021. __func__, iir_idx, band_idx,
  3022. get_iir_band_coeff(codec, iir_idx, band_idx, 2),
  3023. __func__, iir_idx, band_idx,
  3024. get_iir_band_coeff(codec, iir_idx, band_idx, 3),
  3025. __func__, iir_idx, band_idx,
  3026. get_iir_band_coeff(codec, iir_idx, band_idx, 4));
  3027. return 0;
  3028. }
  3029. static int tasha_get_compander(struct snd_kcontrol *kcontrol,
  3030. struct snd_ctl_elem_value *ucontrol)
  3031. {
  3032. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3033. int comp = ((struct soc_multi_mixer_control *)
  3034. kcontrol->private_value)->shift;
  3035. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3036. ucontrol->value.integer.value[0] = tasha->comp_enabled[comp];
  3037. return 0;
  3038. }
  3039. static int tasha_set_compander(struct snd_kcontrol *kcontrol,
  3040. struct snd_ctl_elem_value *ucontrol)
  3041. {
  3042. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3043. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3044. int comp = ((struct soc_multi_mixer_control *)
  3045. kcontrol->private_value)->shift;
  3046. int value = ucontrol->value.integer.value[0];
  3047. pr_debug("%s: Compander %d enable current %d, new %d\n",
  3048. __func__, comp + 1, tasha->comp_enabled[comp], value);
  3049. tasha->comp_enabled[comp] = value;
  3050. /* Any specific register configuration for compander */
  3051. switch (comp) {
  3052. case COMPANDER_1:
  3053. /* Set Gain Source Select based on compander enable/disable */
  3054. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0x20,
  3055. (value ? 0x00:0x20));
  3056. break;
  3057. case COMPANDER_2:
  3058. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0x20,
  3059. (value ? 0x00:0x20));
  3060. break;
  3061. case COMPANDER_3:
  3062. break;
  3063. case COMPANDER_4:
  3064. break;
  3065. case COMPANDER_5:
  3066. snd_soc_update_bits(codec, WCD9335_SE_LO_LO3_GAIN, 0x20,
  3067. (value ? 0x00:0x20));
  3068. break;
  3069. case COMPANDER_6:
  3070. snd_soc_update_bits(codec, WCD9335_SE_LO_LO4_GAIN, 0x20,
  3071. (value ? 0x00:0x20));
  3072. break;
  3073. case COMPANDER_7:
  3074. break;
  3075. case COMPANDER_8:
  3076. break;
  3077. default:
  3078. /*
  3079. * if compander is not enabled for any interpolator,
  3080. * it does not cause any audio failure, so do not
  3081. * return error in this case, but just print a log
  3082. */
  3083. dev_warn(codec->dev, "%s: unknown compander: %d\n",
  3084. __func__, comp);
  3085. };
  3086. return 0;
  3087. }
  3088. static void tasha_codec_init_flyback(struct snd_soc_codec *codec)
  3089. {
  3090. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x00);
  3091. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x00);
  3092. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0x0F, 0x00);
  3093. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0xF0, 0x00);
  3094. }
  3095. static int tasha_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
  3096. struct snd_kcontrol *kcontrol, int event)
  3097. {
  3098. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3099. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3100. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3101. switch (event) {
  3102. case SND_SOC_DAPM_PRE_PMU:
  3103. tasha->rx_bias_count++;
  3104. if (tasha->rx_bias_count == 1) {
  3105. if (TASHA_IS_2_0(tasha->wcd9xxx))
  3106. tasha_codec_init_flyback(codec);
  3107. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3108. 0x01, 0x01);
  3109. }
  3110. break;
  3111. case SND_SOC_DAPM_POST_PMD:
  3112. tasha->rx_bias_count--;
  3113. if (!tasha->rx_bias_count)
  3114. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3115. 0x01, 0x00);
  3116. break;
  3117. };
  3118. dev_dbg(codec->dev, "%s: Current RX BIAS user count: %d\n", __func__,
  3119. tasha->rx_bias_count);
  3120. return 0;
  3121. }
  3122. static void tasha_realign_anc_coeff(struct snd_soc_codec *codec,
  3123. u16 reg1, u16 reg2)
  3124. {
  3125. u8 val1, val2, tmpval1, tmpval2;
  3126. snd_soc_write(codec, reg1, 0x00);
  3127. tmpval1 = snd_soc_read(codec, reg2);
  3128. tmpval2 = snd_soc_read(codec, reg2);
  3129. snd_soc_write(codec, reg1, 0x00);
  3130. snd_soc_write(codec, reg2, 0xFF);
  3131. snd_soc_write(codec, reg1, 0x01);
  3132. snd_soc_write(codec, reg2, 0xFF);
  3133. snd_soc_write(codec, reg1, 0x00);
  3134. val1 = snd_soc_read(codec, reg2);
  3135. val2 = snd_soc_read(codec, reg2);
  3136. if (val1 == 0x0F && val2 == 0xFF) {
  3137. dev_dbg(codec->dev, "%s: ANC0 co-eff index re-aligned\n",
  3138. __func__);
  3139. snd_soc_read(codec, reg2);
  3140. snd_soc_write(codec, reg1, 0x00);
  3141. snd_soc_write(codec, reg2, tmpval2);
  3142. snd_soc_write(codec, reg1, 0x01);
  3143. snd_soc_write(codec, reg2, tmpval1);
  3144. } else if (val1 == 0xFF && val2 == 0x0F) {
  3145. dev_dbg(codec->dev, "%s: ANC1 co-eff index already aligned\n",
  3146. __func__);
  3147. snd_soc_write(codec, reg1, 0x00);
  3148. snd_soc_write(codec, reg2, tmpval1);
  3149. snd_soc_write(codec, reg1, 0x01);
  3150. snd_soc_write(codec, reg2, tmpval2);
  3151. } else {
  3152. dev_err(codec->dev, "%s: ANC0 co-eff index not aligned\n",
  3153. __func__);
  3154. }
  3155. }
  3156. static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w,
  3157. struct snd_kcontrol *kcontrol, int event)
  3158. {
  3159. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3160. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3161. const char *filename;
  3162. const struct firmware *fw;
  3163. int i;
  3164. int ret = 0;
  3165. int num_anc_slots;
  3166. struct wcd9xxx_anc_header *anc_head;
  3167. struct firmware_cal *hwdep_cal = NULL;
  3168. u32 anc_writes_size = 0;
  3169. u32 anc_cal_size = 0;
  3170. int anc_size_remaining;
  3171. u32 *anc_ptr;
  3172. u16 reg;
  3173. u8 mask, val;
  3174. size_t cal_size;
  3175. const void *data;
  3176. if (!tasha->anc_func)
  3177. return 0;
  3178. switch (event) {
  3179. case SND_SOC_DAPM_PRE_PMU:
  3180. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_ANC_CAL);
  3181. if (hwdep_cal) {
  3182. data = hwdep_cal->data;
  3183. cal_size = hwdep_cal->size;
  3184. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  3185. __func__);
  3186. } else {
  3187. filename = "wcd9335/wcd9335_anc.bin";
  3188. ret = request_firmware(&fw, filename, codec->dev);
  3189. if (ret != 0) {
  3190. dev_err(codec->dev,
  3191. "Failed to acquire ANC data: %d\n", ret);
  3192. return -ENODEV;
  3193. }
  3194. if (!fw) {
  3195. dev_err(codec->dev, "failed to get anc fw");
  3196. return -ENODEV;
  3197. }
  3198. data = fw->data;
  3199. cal_size = fw->size;
  3200. dev_dbg(codec->dev,
  3201. "%s: using request_firmware calibration\n", __func__);
  3202. }
  3203. if (cal_size < sizeof(struct wcd9xxx_anc_header)) {
  3204. dev_err(codec->dev, "Not enough data\n");
  3205. ret = -ENOMEM;
  3206. goto err;
  3207. }
  3208. /* First number is the number of register writes */
  3209. anc_head = (struct wcd9xxx_anc_header *)(data);
  3210. anc_ptr = (u32 *)(data +
  3211. sizeof(struct wcd9xxx_anc_header));
  3212. anc_size_remaining = cal_size -
  3213. sizeof(struct wcd9xxx_anc_header);
  3214. num_anc_slots = anc_head->num_anc_slots;
  3215. if (tasha->anc_slot >= num_anc_slots) {
  3216. dev_err(codec->dev, "Invalid ANC slot selected\n");
  3217. ret = -EINVAL;
  3218. goto err;
  3219. }
  3220. for (i = 0; i < num_anc_slots; i++) {
  3221. if (anc_size_remaining < TASHA_PACKED_REG_SIZE) {
  3222. dev_err(codec->dev,
  3223. "Invalid register format\n");
  3224. ret = -EINVAL;
  3225. goto err;
  3226. }
  3227. anc_writes_size = (u32)(*anc_ptr);
  3228. anc_size_remaining -= sizeof(u32);
  3229. anc_ptr += 1;
  3230. if (anc_writes_size * TASHA_PACKED_REG_SIZE
  3231. > anc_size_remaining) {
  3232. dev_err(codec->dev,
  3233. "Invalid register format\n");
  3234. ret = -EINVAL;
  3235. goto err;
  3236. }
  3237. if (tasha->anc_slot == i)
  3238. break;
  3239. anc_size_remaining -= (anc_writes_size *
  3240. TASHA_PACKED_REG_SIZE);
  3241. anc_ptr += anc_writes_size;
  3242. }
  3243. if (i == num_anc_slots) {
  3244. dev_err(codec->dev, "Selected ANC slot not present\n");
  3245. ret = -EINVAL;
  3246. goto err;
  3247. }
  3248. i = 0;
  3249. anc_cal_size = anc_writes_size;
  3250. if (!strcmp(w->name, "RX INT0 DAC") ||
  3251. !strcmp(w->name, "ANC SPK1 PA"))
  3252. tasha_realign_anc_coeff(codec,
  3253. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3254. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3255. if (!strcmp(w->name, "RX INT1 DAC") ||
  3256. !strcmp(w->name, "RX INT3 DAC")) {
  3257. tasha_realign_anc_coeff(codec,
  3258. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3259. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3260. anc_writes_size = anc_cal_size / 2;
  3261. snd_soc_update_bits(codec,
  3262. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x39, 0x39);
  3263. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3264. !strcmp(w->name, "RX INT4 DAC")) {
  3265. tasha_realign_anc_coeff(codec,
  3266. WCD9335_CDC_ANC1_IIR_COEFF_1_CTL,
  3267. WCD9335_CDC_ANC1_IIR_COEFF_2_CTL);
  3268. i = anc_cal_size / 2;
  3269. snd_soc_update_bits(codec,
  3270. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x39, 0x39);
  3271. }
  3272. for (; i < anc_writes_size; i++) {
  3273. TASHA_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val);
  3274. snd_soc_write(codec, reg, (val & mask));
  3275. }
  3276. if (!strcmp(w->name, "RX INT1 DAC") ||
  3277. !strcmp(w->name, "RX INT3 DAC")) {
  3278. snd_soc_update_bits(codec,
  3279. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08);
  3280. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3281. !strcmp(w->name, "RX INT4 DAC")) {
  3282. snd_soc_update_bits(codec,
  3283. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08);
  3284. }
  3285. if (!hwdep_cal)
  3286. release_firmware(fw);
  3287. break;
  3288. case SND_SOC_DAPM_POST_PMU:
  3289. /* Remove ANC Rx from reset */
  3290. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_CLK_RESET_CTL,
  3291. 0x08, 0x00);
  3292. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_CLK_RESET_CTL,
  3293. 0x08, 0x00);
  3294. break;
  3295. case SND_SOC_DAPM_POST_PMD:
  3296. if (!strcmp(w->name, "ANC HPHL PA") ||
  3297. !strcmp(w->name, "ANC EAR PA") ||
  3298. !strcmp(w->name, "ANC SPK1 PA") ||
  3299. !strcmp(w->name, "ANC LINEOUT1 PA")) {
  3300. snd_soc_update_bits(codec,
  3301. WCD9335_CDC_ANC0_MODE_1_CTL, 0x30, 0x00);
  3302. msleep(50);
  3303. snd_soc_update_bits(codec,
  3304. WCD9335_CDC_ANC0_MODE_1_CTL, 0x01, 0x00);
  3305. snd_soc_update_bits(codec,
  3306. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x38);
  3307. snd_soc_update_bits(codec,
  3308. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x07, 0x00);
  3309. snd_soc_update_bits(codec,
  3310. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x00);
  3311. } else if (!strcmp(w->name, "ANC HPHR PA") ||
  3312. !strcmp(w->name, "ANC LINEOUT2 PA")) {
  3313. snd_soc_update_bits(codec,
  3314. WCD9335_CDC_ANC1_MODE_1_CTL, 0x30, 0x00);
  3315. msleep(50);
  3316. snd_soc_update_bits(codec,
  3317. WCD9335_CDC_ANC1_MODE_1_CTL, 0x01, 0x00);
  3318. snd_soc_update_bits(codec,
  3319. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x38);
  3320. snd_soc_update_bits(codec,
  3321. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x07, 0x00);
  3322. snd_soc_update_bits(codec,
  3323. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x00);
  3324. }
  3325. break;
  3326. }
  3327. return 0;
  3328. err:
  3329. if (!hwdep_cal)
  3330. release_firmware(fw);
  3331. return ret;
  3332. }
  3333. static void tasha_codec_clear_anc_tx_hold(struct tasha_priv *tasha)
  3334. {
  3335. if (test_and_clear_bit(ANC_MIC_AMIC1, &tasha->status_mask))
  3336. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC1, false);
  3337. if (test_and_clear_bit(ANC_MIC_AMIC2, &tasha->status_mask))
  3338. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC2, false);
  3339. if (test_and_clear_bit(ANC_MIC_AMIC3, &tasha->status_mask))
  3340. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC3, false);
  3341. if (test_and_clear_bit(ANC_MIC_AMIC4, &tasha->status_mask))
  3342. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC4, false);
  3343. if (test_and_clear_bit(ANC_MIC_AMIC5, &tasha->status_mask))
  3344. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC5, false);
  3345. if (test_and_clear_bit(ANC_MIC_AMIC6, &tasha->status_mask))
  3346. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC6, false);
  3347. }
  3348. static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha,
  3349. int mode, int event)
  3350. {
  3351. u8 scale_val = 0;
  3352. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3353. return;
  3354. switch (event) {
  3355. case SND_SOC_DAPM_POST_PMU:
  3356. switch (mode) {
  3357. case CLS_H_HIFI:
  3358. scale_val = 0x3;
  3359. break;
  3360. case CLS_H_LOHIFI:
  3361. scale_val = 0x1;
  3362. break;
  3363. }
  3364. if (tasha->anc_func) {
  3365. /* Clear Tx FE HOLD if both PAs are enabled */
  3366. if ((snd_soc_read(tasha->codec, WCD9335_ANA_HPH) &
  3367. 0xC0) == 0xC0) {
  3368. tasha_codec_clear_anc_tx_hold(tasha);
  3369. }
  3370. }
  3371. break;
  3372. case SND_SOC_DAPM_PRE_PMD:
  3373. scale_val = 0x6;
  3374. break;
  3375. }
  3376. if (scale_val)
  3377. snd_soc_update_bits(tasha->codec, WCD9335_HPH_PA_CTL1, 0x0E,
  3378. scale_val << 1);
  3379. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3380. if (tasha->comp_enabled[COMPANDER_1] ||
  3381. tasha->comp_enabled[COMPANDER_2]) {
  3382. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN,
  3383. 0x20, 0x00);
  3384. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN,
  3385. 0x20, 0x00);
  3386. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP,
  3387. 0x20, 0x20);
  3388. }
  3389. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN, 0x1F,
  3390. tasha->hph_l_gain);
  3391. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN, 0x1F,
  3392. tasha->hph_r_gain);
  3393. }
  3394. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3395. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP, 0x20,
  3396. 0x00);
  3397. }
  3398. }
  3399. static void tasha_codec_override(struct snd_soc_codec *codec,
  3400. int mode,
  3401. int event)
  3402. {
  3403. if (mode == CLS_AB) {
  3404. switch (event) {
  3405. case SND_SOC_DAPM_POST_PMU:
  3406. if (!(snd_soc_read(codec,
  3407. WCD9335_CDC_RX2_RX_PATH_CTL) & 0x10) &&
  3408. (!(snd_soc_read(codec,
  3409. WCD9335_CDC_RX1_RX_PATH_CTL) & 0x10)))
  3410. snd_soc_update_bits(codec,
  3411. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x02);
  3412. break;
  3413. case SND_SOC_DAPM_POST_PMD:
  3414. snd_soc_update_bits(codec,
  3415. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00);
  3416. break;
  3417. }
  3418. }
  3419. }
  3420. static int tasha_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
  3421. struct snd_kcontrol *kcontrol,
  3422. int event)
  3423. {
  3424. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3425. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3426. int hph_mode = tasha->hph_mode;
  3427. int ret = 0;
  3428. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3429. switch (event) {
  3430. case SND_SOC_DAPM_PRE_PMU:
  3431. if ((!(strcmp(w->name, "ANC HPHR PA"))) &&
  3432. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3433. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3434. }
  3435. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3436. break;
  3437. case SND_SOC_DAPM_POST_PMU:
  3438. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3439. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3440. != 0xC0)
  3441. /*
  3442. * If PA_EN is not set (potentially in ANC case)
  3443. * then do nothing for POST_PMU and let left
  3444. * channel handle everything.
  3445. */
  3446. break;
  3447. }
  3448. /*
  3449. * 7ms sleep is required after PA is enabled as per
  3450. * HW requirement
  3451. */
  3452. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3453. usleep_range(7000, 7100);
  3454. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3455. }
  3456. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3457. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3458. 0x10, 0x00);
  3459. /* Remove mix path mute if it is enabled */
  3460. if ((snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3461. 0x10)
  3462. snd_soc_update_bits(codec,
  3463. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3464. 0x10, 0x00);
  3465. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3466. /* Do everything needed for left channel */
  3467. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3468. 0x10, 0x00);
  3469. /* Remove mix path mute if it is enabled */
  3470. if ((snd_soc_read(codec,
  3471. WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3472. 0x10)
  3473. snd_soc_update_bits(codec,
  3474. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3475. 0x10, 0x00);
  3476. /* Remove ANC Rx from reset */
  3477. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3478. }
  3479. tasha_codec_override(codec, hph_mode, event);
  3480. break;
  3481. case SND_SOC_DAPM_PRE_PMD:
  3482. blocking_notifier_call_chain(&tasha->notifier,
  3483. WCD_EVENT_PRE_HPHR_PA_OFF,
  3484. &tasha->mbhc);
  3485. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3486. if (!(strcmp(w->name, "ANC HPHR PA")))
  3487. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x00);
  3488. break;
  3489. case SND_SOC_DAPM_POST_PMD:
  3490. /* 5ms sleep is required after PA is disabled as per
  3491. * HW requirement
  3492. */
  3493. usleep_range(5000, 5500);
  3494. tasha_codec_override(codec, hph_mode, event);
  3495. blocking_notifier_call_chain(&tasha->notifier,
  3496. WCD_EVENT_POST_HPHR_PA_OFF,
  3497. &tasha->mbhc);
  3498. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3499. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3500. snd_soc_update_bits(codec,
  3501. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x00);
  3502. }
  3503. break;
  3504. };
  3505. return ret;
  3506. }
  3507. static int tasha_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
  3508. struct snd_kcontrol *kcontrol,
  3509. int event)
  3510. {
  3511. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3512. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3513. int hph_mode = tasha->hph_mode;
  3514. int ret = 0;
  3515. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3516. switch (event) {
  3517. case SND_SOC_DAPM_PRE_PMU:
  3518. if ((!(strcmp(w->name, "ANC HPHL PA"))) &&
  3519. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3520. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3521. }
  3522. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3523. break;
  3524. case SND_SOC_DAPM_POST_PMU:
  3525. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3526. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3527. != 0xC0)
  3528. /*
  3529. * If PA_EN is not set (potentially in ANC case)
  3530. * then do nothing for POST_PMU and let right
  3531. * channel handle everything.
  3532. */
  3533. break;
  3534. }
  3535. /*
  3536. * 7ms sleep is required after PA is enabled as per
  3537. * HW requirement
  3538. */
  3539. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3540. usleep_range(7000, 7100);
  3541. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3542. }
  3543. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3544. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3545. 0x10, 0x00);
  3546. /* Remove mix path mute if it is enabled */
  3547. if ((snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3548. 0x10)
  3549. snd_soc_update_bits(codec,
  3550. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3551. 0x10, 0x00);
  3552. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3553. /* Do everything needed for right channel */
  3554. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3555. 0x10, 0x00);
  3556. /* Remove mix path mute if it is enabled */
  3557. if ((snd_soc_read(codec,
  3558. WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3559. 0x10)
  3560. snd_soc_update_bits(codec,
  3561. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3562. 0x10, 0x00);
  3563. /* Remove ANC Rx from reset */
  3564. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3565. }
  3566. tasha_codec_override(codec, hph_mode, event);
  3567. break;
  3568. case SND_SOC_DAPM_PRE_PMD:
  3569. blocking_notifier_call_chain(&tasha->notifier,
  3570. WCD_EVENT_PRE_HPHL_PA_OFF,
  3571. &tasha->mbhc);
  3572. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3573. if (!(strcmp(w->name, "ANC HPHL PA")))
  3574. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x00);
  3575. break;
  3576. case SND_SOC_DAPM_POST_PMD:
  3577. /* 5ms sleep is required after PA is disabled as per
  3578. * HW requirement
  3579. */
  3580. usleep_range(5000, 5500);
  3581. tasha_codec_override(codec, hph_mode, event);
  3582. blocking_notifier_call_chain(&tasha->notifier,
  3583. WCD_EVENT_POST_HPHL_PA_OFF,
  3584. &tasha->mbhc);
  3585. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3586. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3587. snd_soc_update_bits(codec,
  3588. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00);
  3589. }
  3590. break;
  3591. };
  3592. return ret;
  3593. }
  3594. static int tasha_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w,
  3595. struct snd_kcontrol *kcontrol,
  3596. int event)
  3597. {
  3598. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3599. u16 lineout_vol_reg = 0, lineout_mix_vol_reg = 0;
  3600. int ret = 0;
  3601. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3602. if (w->reg == WCD9335_ANA_LO_1_2) {
  3603. if (w->shift == 7) {
  3604. lineout_vol_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  3605. lineout_mix_vol_reg = WCD9335_CDC_RX3_RX_PATH_MIX_CTL;
  3606. } else if (w->shift == 6) {
  3607. lineout_vol_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  3608. lineout_mix_vol_reg = WCD9335_CDC_RX4_RX_PATH_MIX_CTL;
  3609. }
  3610. } else if (w->reg == WCD9335_ANA_LO_3_4) {
  3611. if (w->shift == 7) {
  3612. lineout_vol_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  3613. lineout_mix_vol_reg = WCD9335_CDC_RX5_RX_PATH_MIX_CTL;
  3614. } else if (w->shift == 6) {
  3615. lineout_vol_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  3616. lineout_mix_vol_reg = WCD9335_CDC_RX6_RX_PATH_MIX_CTL;
  3617. }
  3618. } else {
  3619. dev_err(codec->dev, "%s: Error enabling lineout PA\n",
  3620. __func__);
  3621. return -EINVAL;
  3622. }
  3623. switch (event) {
  3624. case SND_SOC_DAPM_POST_PMU:
  3625. /* 5ms sleep is required after PA is enabled as per
  3626. * HW requirement
  3627. */
  3628. usleep_range(5000, 5500);
  3629. snd_soc_update_bits(codec, lineout_vol_reg,
  3630. 0x10, 0x00);
  3631. /* Remove mix path mute if it is enabled */
  3632. if ((snd_soc_read(codec, lineout_mix_vol_reg)) & 0x10)
  3633. snd_soc_update_bits(codec,
  3634. lineout_mix_vol_reg,
  3635. 0x10, 0x00);
  3636. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3637. !(strcmp(w->name, "ANC LINEOUT2 PA")))
  3638. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3639. tasha_codec_override(codec, CLS_AB, event);
  3640. break;
  3641. case SND_SOC_DAPM_POST_PMD:
  3642. /* 5ms sleep is required after PA is disabled as per
  3643. * HW requirement
  3644. */
  3645. usleep_range(5000, 5500);
  3646. tasha_codec_override(codec, CLS_AB, event);
  3647. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3648. !(strcmp(w->name, "ANC LINEOUT2 PA"))) {
  3649. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3650. if (!(strcmp(w->name, "ANC LINEOUT1 PA")))
  3651. snd_soc_update_bits(codec,
  3652. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  3653. else
  3654. snd_soc_update_bits(codec,
  3655. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  3656. }
  3657. break;
  3658. };
  3659. return ret;
  3660. }
  3661. static void tasha_spk_anc_update_callback(struct work_struct *work)
  3662. {
  3663. struct spk_anc_work *spk_anc_dwork;
  3664. struct tasha_priv *tasha;
  3665. struct delayed_work *delayed_work;
  3666. struct snd_soc_codec *codec;
  3667. delayed_work = to_delayed_work(work);
  3668. spk_anc_dwork = container_of(delayed_work, struct spk_anc_work, dwork);
  3669. tasha = spk_anc_dwork->tasha;
  3670. codec = tasha->codec;
  3671. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0, 0x10, 0x10);
  3672. }
  3673. static int tasha_codec_enable_spk_anc(struct snd_soc_dapm_widget *w,
  3674. struct snd_kcontrol *kcontrol,
  3675. int event)
  3676. {
  3677. int ret = 0;
  3678. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3679. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3680. dev_dbg(codec->dev, "%s %s %d %d\n", __func__, w->name, event,
  3681. tasha->anc_func);
  3682. if (!tasha->anc_func)
  3683. return 0;
  3684. switch (event) {
  3685. case SND_SOC_DAPM_PRE_PMU:
  3686. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3687. schedule_delayed_work(&tasha->spk_anc_dwork.dwork,
  3688. msecs_to_jiffies(spk_anc_en_delay));
  3689. break;
  3690. case SND_SOC_DAPM_POST_PMD:
  3691. cancel_delayed_work_sync(&tasha->spk_anc_dwork.dwork);
  3692. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0,
  3693. 0x10, 0x00);
  3694. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3695. break;
  3696. }
  3697. return ret;
  3698. }
  3699. static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
  3700. struct snd_kcontrol *kcontrol,
  3701. int event)
  3702. {
  3703. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3704. int ret = 0;
  3705. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3706. switch (event) {
  3707. case SND_SOC_DAPM_POST_PMU:
  3708. /* 5ms sleep is required after PA is enabled as per
  3709. * HW requirement
  3710. */
  3711. usleep_range(5000, 5500);
  3712. snd_soc_update_bits(codec, WCD9335_CDC_RX0_RX_PATH_CTL,
  3713. 0x10, 0x00);
  3714. /* Remove mix path mute if it is enabled */
  3715. if ((snd_soc_read(codec, WCD9335_CDC_RX0_RX_PATH_MIX_CTL)) &
  3716. 0x10)
  3717. snd_soc_update_bits(codec,
  3718. WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  3719. 0x10, 0x00);
  3720. break;
  3721. case SND_SOC_DAPM_POST_PMD:
  3722. /* 5ms sleep is required after PA is disabled as per
  3723. * HW requirement
  3724. */
  3725. usleep_range(5000, 5500);
  3726. if (!(strcmp(w->name, "ANC EAR PA"))) {
  3727. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3728. snd_soc_update_bits(codec,
  3729. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x00);
  3730. }
  3731. break;
  3732. };
  3733. return ret;
  3734. }
  3735. static void tasha_codec_hph_mode_gain_opt(struct snd_soc_codec *codec,
  3736. u8 gain)
  3737. {
  3738. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3739. u8 hph_l_en, hph_r_en;
  3740. u8 l_val, r_val;
  3741. u8 hph_pa_status;
  3742. bool is_hphl_pa, is_hphr_pa;
  3743. hph_pa_status = snd_soc_read(codec, WCD9335_ANA_HPH);
  3744. is_hphl_pa = hph_pa_status >> 7;
  3745. is_hphr_pa = (hph_pa_status & 0x40) >> 6;
  3746. hph_l_en = snd_soc_read(codec, WCD9335_HPH_L_EN);
  3747. hph_r_en = snd_soc_read(codec, WCD9335_HPH_R_EN);
  3748. l_val = (hph_l_en & 0xC0) | 0x20 | gain;
  3749. r_val = (hph_r_en & 0xC0) | 0x20 | gain;
  3750. /*
  3751. * Set HPH_L & HPH_R gain source selection to REGISTER
  3752. * for better click and pop only if corresponding PAs are
  3753. * not enabled. Also cache the values of the HPHL/R
  3754. * PA gains to be applied after PAs are enabled
  3755. */
  3756. if ((l_val != hph_l_en) && !is_hphl_pa) {
  3757. snd_soc_write(codec, WCD9335_HPH_L_EN, l_val);
  3758. tasha->hph_l_gain = hph_l_en & 0x1F;
  3759. }
  3760. if ((r_val != hph_r_en) && !is_hphr_pa) {
  3761. snd_soc_write(codec, WCD9335_HPH_R_EN, r_val);
  3762. tasha->hph_r_gain = hph_r_en & 0x1F;
  3763. }
  3764. }
  3765. static void tasha_codec_hph_lohifi_config(struct snd_soc_codec *codec,
  3766. int event)
  3767. {
  3768. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3769. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x06);
  3770. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2,
  3771. 0xF0, 0x40);
  3772. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3773. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3774. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3775. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3776. }
  3777. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3778. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3779. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3780. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A);
  3781. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x0A);
  3782. }
  3783. }
  3784. static void tasha_codec_hph_lp_config(struct snd_soc_codec *codec,
  3785. int event)
  3786. {
  3787. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3788. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3789. tasha_codec_hph_mode_gain_opt(codec, 0x10);
  3790. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3791. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3792. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x04);
  3793. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x20);
  3794. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x07,
  3795. 0x01);
  3796. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x70,
  3797. 0x10);
  3798. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3799. 0x0F, 0x01);
  3800. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3801. 0xF0, 0x10);
  3802. }
  3803. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3804. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x88);
  3805. snd_soc_write(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x33);
  3806. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x00);
  3807. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x00);
  3808. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3809. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3810. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x80);
  3811. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x80);
  3812. }
  3813. }
  3814. static void tasha_codec_hph_hifi_config(struct snd_soc_codec *codec,
  3815. int event)
  3816. {
  3817. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3818. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3819. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3820. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3821. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3822. }
  3823. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3824. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3825. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3826. }
  3827. }
  3828. static void tasha_codec_hph_mode_config(struct snd_soc_codec *codec,
  3829. int event, int mode)
  3830. {
  3831. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3832. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3833. return;
  3834. switch (mode) {
  3835. case CLS_H_LP:
  3836. tasha_codec_hph_lp_config(codec, event);
  3837. break;
  3838. case CLS_H_LOHIFI:
  3839. tasha_codec_hph_lohifi_config(codec, event);
  3840. break;
  3841. case CLS_H_HIFI:
  3842. tasha_codec_hph_hifi_config(codec, event);
  3843. break;
  3844. }
  3845. }
  3846. static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
  3847. struct snd_kcontrol *kcontrol,
  3848. int event)
  3849. {
  3850. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3851. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3852. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3853. int hph_mode = tasha->hph_mode;
  3854. u8 dem_inp;
  3855. int ret = 0;
  3856. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3857. w->name, event, hph_mode);
  3858. switch (event) {
  3859. case SND_SOC_DAPM_PRE_PMU:
  3860. if (tasha->anc_func) {
  3861. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3862. /* 40 msec delay is needed to avoid click and pop */
  3863. msleep(40);
  3864. }
  3865. /* Read DEM INP Select */
  3866. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_SEC0) &
  3867. 0x03;
  3868. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3869. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3870. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3871. __func__, hph_mode);
  3872. return -EINVAL;
  3873. }
  3874. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3875. WCD_CLSH_EVENT_PRE_DAC,
  3876. WCD_CLSH_STATE_HPHR,
  3877. ((hph_mode == CLS_H_LOHIFI) ?
  3878. CLS_H_HIFI : hph_mode));
  3879. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3880. if (tasha->anc_func)
  3881. snd_soc_update_bits(codec,
  3882. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x10);
  3883. break;
  3884. case SND_SOC_DAPM_POST_PMU:
  3885. /* 1000us required as per HW requirement */
  3886. usleep_range(1000, 1100);
  3887. if ((hph_mode == CLS_H_LP) &&
  3888. (TASHA_IS_1_1(wcd9xxx))) {
  3889. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3890. 0x03, 0x03);
  3891. }
  3892. break;
  3893. case SND_SOC_DAPM_PRE_PMD:
  3894. if ((hph_mode == CLS_H_LP) &&
  3895. (TASHA_IS_1_1(wcd9xxx))) {
  3896. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3897. 0x03, 0x00);
  3898. }
  3899. break;
  3900. case SND_SOC_DAPM_POST_PMD:
  3901. /* 1000us required as per HW requirement */
  3902. usleep_range(1000, 1100);
  3903. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  3904. WCD_CLSH_STATE_HPHL))
  3905. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3906. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3907. WCD_CLSH_EVENT_POST_PA,
  3908. WCD_CLSH_STATE_HPHR,
  3909. ((hph_mode == CLS_H_LOHIFI) ?
  3910. CLS_H_HIFI : hph_mode));
  3911. break;
  3912. };
  3913. return ret;
  3914. }
  3915. static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
  3916. struct snd_kcontrol *kcontrol,
  3917. int event)
  3918. {
  3919. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3920. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3921. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3922. int hph_mode = tasha->hph_mode;
  3923. u8 dem_inp;
  3924. int ret = 0;
  3925. uint32_t impedl = 0, impedr = 0;
  3926. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3927. w->name, event, hph_mode);
  3928. switch (event) {
  3929. case SND_SOC_DAPM_PRE_PMU:
  3930. if (tasha->anc_func) {
  3931. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3932. /* 40 msec delay is needed to avoid click and pop */
  3933. msleep(40);
  3934. }
  3935. /* Read DEM INP Select */
  3936. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_SEC0) &
  3937. 0x03;
  3938. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3939. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3940. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3941. __func__, hph_mode);
  3942. return -EINVAL;
  3943. }
  3944. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3945. WCD_CLSH_EVENT_PRE_DAC,
  3946. WCD_CLSH_STATE_HPHL,
  3947. ((hph_mode == CLS_H_LOHIFI) ?
  3948. CLS_H_HIFI : hph_mode));
  3949. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3950. if (tasha->anc_func)
  3951. snd_soc_update_bits(codec,
  3952. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x10);
  3953. ret = wcd_mbhc_get_impedance(&tasha->mbhc,
  3954. &impedl, &impedr);
  3955. if (!ret) {
  3956. wcd_clsh_imped_config(codec, impedl, false);
  3957. set_bit(CLASSH_CONFIG, &tasha->status_mask);
  3958. } else {
  3959. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  3960. __func__, ret);
  3961. ret = 0;
  3962. }
  3963. break;
  3964. case SND_SOC_DAPM_POST_PMU:
  3965. /* 1000us required as per HW requirement */
  3966. usleep_range(1000, 1100);
  3967. if ((hph_mode == CLS_H_LP) &&
  3968. (TASHA_IS_1_1(wcd9xxx))) {
  3969. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3970. 0x03, 0x03);
  3971. }
  3972. break;
  3973. case SND_SOC_DAPM_PRE_PMD:
  3974. if ((hph_mode == CLS_H_LP) &&
  3975. (TASHA_IS_1_1(wcd9xxx))) {
  3976. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3977. 0x03, 0x00);
  3978. }
  3979. break;
  3980. case SND_SOC_DAPM_POST_PMD:
  3981. /* 1000us required as per HW requirement */
  3982. usleep_range(1000, 1100);
  3983. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  3984. WCD_CLSH_STATE_HPHR))
  3985. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3986. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3987. WCD_CLSH_EVENT_POST_PA,
  3988. WCD_CLSH_STATE_HPHL,
  3989. ((hph_mode == CLS_H_LOHIFI) ?
  3990. CLS_H_HIFI : hph_mode));
  3991. if (test_bit(CLASSH_CONFIG, &tasha->status_mask)) {
  3992. wcd_clsh_imped_config(codec, impedl, true);
  3993. clear_bit(CLASSH_CONFIG, &tasha->status_mask);
  3994. } else
  3995. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  3996. __func__, ret);
  3997. break;
  3998. };
  3999. return ret;
  4000. }
  4001. static int tasha_codec_lineout_dac_event(struct snd_soc_dapm_widget *w,
  4002. struct snd_kcontrol *kcontrol,
  4003. int event)
  4004. {
  4005. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4006. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4007. int ret = 0;
  4008. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4009. switch (event) {
  4010. case SND_SOC_DAPM_PRE_PMU:
  4011. if (tasha->anc_func &&
  4012. (!strcmp(w->name, "RX INT3 DAC") ||
  4013. !strcmp(w->name, "RX INT4 DAC")))
  4014. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4015. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4016. WCD_CLSH_EVENT_PRE_DAC,
  4017. WCD_CLSH_STATE_LO,
  4018. CLS_AB);
  4019. if (tasha->anc_func) {
  4020. if (!strcmp(w->name, "RX INT3 DAC"))
  4021. snd_soc_update_bits(codec,
  4022. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  4023. else if (!strcmp(w->name, "RX INT4 DAC"))
  4024. snd_soc_update_bits(codec,
  4025. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  4026. }
  4027. break;
  4028. case SND_SOC_DAPM_POST_PMD:
  4029. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4030. WCD_CLSH_EVENT_POST_PA,
  4031. WCD_CLSH_STATE_LO,
  4032. CLS_AB);
  4033. break;
  4034. }
  4035. return 0;
  4036. }
  4037. static const struct snd_soc_dapm_widget tasha_dapm_i2s_widgets[] = {
  4038. SND_SOC_DAPM_SUPPLY("RX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  4039. 0, 0, NULL, 0),
  4040. SND_SOC_DAPM_SUPPLY("TX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  4041. 0, 0, NULL, 0),
  4042. };
  4043. static int tasha_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
  4044. struct snd_kcontrol *kcontrol,
  4045. int event)
  4046. {
  4047. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4048. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4049. int ret = 0;
  4050. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4051. switch (event) {
  4052. case SND_SOC_DAPM_PRE_PMU:
  4053. if (tasha->anc_func)
  4054. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4055. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4056. WCD_CLSH_EVENT_PRE_DAC,
  4057. WCD_CLSH_STATE_EAR,
  4058. CLS_H_NORMAL);
  4059. if (tasha->anc_func)
  4060. snd_soc_update_bits(codec,
  4061. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x10);
  4062. break;
  4063. case SND_SOC_DAPM_POST_PMU:
  4064. break;
  4065. case SND_SOC_DAPM_PRE_PMD:
  4066. break;
  4067. case SND_SOC_DAPM_POST_PMD:
  4068. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4069. WCD_CLSH_EVENT_POST_PA,
  4070. WCD_CLSH_STATE_EAR,
  4071. CLS_H_NORMAL);
  4072. break;
  4073. };
  4074. return ret;
  4075. }
  4076. static int tasha_codec_spk_boost_event(struct snd_soc_dapm_widget *w,
  4077. struct snd_kcontrol *kcontrol,
  4078. int event)
  4079. {
  4080. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4081. u16 boost_path_ctl, boost_path_cfg1;
  4082. u16 reg, reg_mix;
  4083. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4084. if (!strcmp(w->name, "RX INT7 CHAIN")) {
  4085. boost_path_ctl = WCD9335_CDC_BOOST0_BOOST_PATH_CTL;
  4086. boost_path_cfg1 = WCD9335_CDC_RX7_RX_PATH_CFG1;
  4087. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4088. reg_mix = WCD9335_CDC_RX7_RX_PATH_MIX_CTL;
  4089. } else if (!strcmp(w->name, "RX INT8 CHAIN")) {
  4090. boost_path_ctl = WCD9335_CDC_BOOST1_BOOST_PATH_CTL;
  4091. boost_path_cfg1 = WCD9335_CDC_RX8_RX_PATH_CFG1;
  4092. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4093. reg_mix = WCD9335_CDC_RX8_RX_PATH_MIX_CTL;
  4094. } else {
  4095. dev_err(codec->dev, "%s: unknown widget: %s\n",
  4096. __func__, w->name);
  4097. return -EINVAL;
  4098. }
  4099. switch (event) {
  4100. case SND_SOC_DAPM_PRE_PMU:
  4101. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10);
  4102. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01);
  4103. snd_soc_update_bits(codec, reg, 0x10, 0x00);
  4104. if ((snd_soc_read(codec, reg_mix)) & 0x10)
  4105. snd_soc_update_bits(codec, reg_mix, 0x10, 0x00);
  4106. break;
  4107. case SND_SOC_DAPM_POST_PMD:
  4108. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00);
  4109. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00);
  4110. break;
  4111. };
  4112. return 0;
  4113. }
  4114. static u16 tasha_interp_get_primary_reg(u16 reg, u16 *ind)
  4115. {
  4116. u16 prim_int_reg = 0;
  4117. switch (reg) {
  4118. case WCD9335_CDC_RX0_RX_PATH_CTL:
  4119. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4120. prim_int_reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4121. *ind = 0;
  4122. break;
  4123. case WCD9335_CDC_RX1_RX_PATH_CTL:
  4124. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4125. prim_int_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4126. *ind = 1;
  4127. break;
  4128. case WCD9335_CDC_RX2_RX_PATH_CTL:
  4129. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4130. prim_int_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4131. *ind = 2;
  4132. break;
  4133. case WCD9335_CDC_RX3_RX_PATH_CTL:
  4134. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4135. prim_int_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4136. *ind = 3;
  4137. break;
  4138. case WCD9335_CDC_RX4_RX_PATH_CTL:
  4139. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4140. prim_int_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4141. *ind = 4;
  4142. break;
  4143. case WCD9335_CDC_RX5_RX_PATH_CTL:
  4144. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4145. prim_int_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4146. *ind = 5;
  4147. break;
  4148. case WCD9335_CDC_RX6_RX_PATH_CTL:
  4149. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4150. prim_int_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4151. *ind = 6;
  4152. break;
  4153. case WCD9335_CDC_RX7_RX_PATH_CTL:
  4154. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4155. prim_int_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4156. *ind = 7;
  4157. break;
  4158. case WCD9335_CDC_RX8_RX_PATH_CTL:
  4159. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4160. prim_int_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4161. *ind = 8;
  4162. break;
  4163. };
  4164. return prim_int_reg;
  4165. }
  4166. static void tasha_codec_hd2_control(struct snd_soc_codec *codec,
  4167. u16 prim_int_reg, int event)
  4168. {
  4169. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4170. u16 hd2_scale_reg;
  4171. u16 hd2_enable_reg = 0;
  4172. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  4173. return;
  4174. if (prim_int_reg == WCD9335_CDC_RX1_RX_PATH_CTL) {
  4175. hd2_scale_reg = WCD9335_CDC_RX1_RX_PATH_SEC3;
  4176. hd2_enable_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4177. }
  4178. if (prim_int_reg == WCD9335_CDC_RX2_RX_PATH_CTL) {
  4179. hd2_scale_reg = WCD9335_CDC_RX2_RX_PATH_SEC3;
  4180. hd2_enable_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4181. }
  4182. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) {
  4183. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x10);
  4184. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x01);
  4185. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04);
  4186. }
  4187. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
  4188. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00);
  4189. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x00);
  4190. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00);
  4191. }
  4192. }
  4193. static int tasha_codec_enable_prim_interpolator(
  4194. struct snd_soc_codec *codec,
  4195. u16 reg, int event)
  4196. {
  4197. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4198. u16 prim_int_reg;
  4199. u16 ind = 0;
  4200. prim_int_reg = tasha_interp_get_primary_reg(reg, &ind);
  4201. switch (event) {
  4202. case SND_SOC_DAPM_PRE_PMU:
  4203. tasha->prim_int_users[ind]++;
  4204. if (tasha->prim_int_users[ind] == 1) {
  4205. snd_soc_update_bits(codec, prim_int_reg,
  4206. 0x10, 0x10);
  4207. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4208. snd_soc_update_bits(codec, prim_int_reg,
  4209. 1 << 0x5, 1 << 0x5);
  4210. }
  4211. if ((reg != prim_int_reg) &&
  4212. ((snd_soc_read(codec, prim_int_reg)) & 0x10))
  4213. snd_soc_update_bits(codec, reg, 0x10, 0x10);
  4214. break;
  4215. case SND_SOC_DAPM_POST_PMD:
  4216. tasha->prim_int_users[ind]--;
  4217. if (tasha->prim_int_users[ind] == 0) {
  4218. snd_soc_update_bits(codec, prim_int_reg,
  4219. 1 << 0x5, 0 << 0x5);
  4220. snd_soc_update_bits(codec, prim_int_reg,
  4221. 0x40, 0x40);
  4222. snd_soc_update_bits(codec, prim_int_reg,
  4223. 0x40, 0x00);
  4224. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4225. }
  4226. break;
  4227. };
  4228. dev_dbg(codec->dev, "%s: primary interpolator: INT%d, users: %d\n",
  4229. __func__, ind, tasha->prim_int_users[ind]);
  4230. return 0;
  4231. }
  4232. static int tasha_codec_enable_spline_src(struct snd_soc_codec *codec,
  4233. int src_num,
  4234. int event)
  4235. {
  4236. u16 src_paired_reg = 0;
  4237. struct tasha_priv *tasha;
  4238. u16 rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4239. u16 rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4240. int *src_users, count, spl_src = SPLINE_SRC0;
  4241. u16 src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4242. tasha = snd_soc_codec_get_drvdata(codec);
  4243. switch (src_num) {
  4244. case SRC_IN_HPHL:
  4245. rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4246. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4247. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4248. rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4249. spl_src = SPLINE_SRC0;
  4250. break;
  4251. case SRC_IN_LO1:
  4252. rx_path_cfg_reg = WCD9335_CDC_RX3_RX_PATH_CFG0;
  4253. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4254. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4255. rx_path_ctl_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4256. spl_src = SPLINE_SRC0;
  4257. break;
  4258. case SRC_IN_HPHR:
  4259. rx_path_cfg_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4260. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4261. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4262. rx_path_ctl_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4263. spl_src = SPLINE_SRC1;
  4264. break;
  4265. case SRC_IN_LO2:
  4266. rx_path_cfg_reg = WCD9335_CDC_RX4_RX_PATH_CFG0;
  4267. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4268. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4269. rx_path_ctl_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4270. spl_src = SPLINE_SRC1;
  4271. break;
  4272. case SRC_IN_SPKRL:
  4273. rx_path_cfg_reg = WCD9335_CDC_RX7_RX_PATH_CFG0;
  4274. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4275. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4276. rx_path_ctl_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4277. spl_src = SPLINE_SRC2;
  4278. break;
  4279. case SRC_IN_LO3:
  4280. rx_path_cfg_reg = WCD9335_CDC_RX5_RX_PATH_CFG0;
  4281. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4282. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4283. rx_path_ctl_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4284. spl_src = SPLINE_SRC2;
  4285. break;
  4286. case SRC_IN_SPKRR:
  4287. rx_path_cfg_reg = WCD9335_CDC_RX8_RX_PATH_CFG0;
  4288. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4289. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4290. rx_path_ctl_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4291. spl_src = SPLINE_SRC3;
  4292. break;
  4293. case SRC_IN_LO4:
  4294. rx_path_cfg_reg = WCD9335_CDC_RX6_RX_PATH_CFG0;
  4295. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4296. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4297. rx_path_ctl_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4298. spl_src = SPLINE_SRC3;
  4299. break;
  4300. };
  4301. src_users = &tasha->spl_src_users[spl_src];
  4302. switch (event) {
  4303. case SND_SOC_DAPM_PRE_PMU:
  4304. count = *src_users;
  4305. count++;
  4306. if (count == 1) {
  4307. if ((snd_soc_read(codec, src_clk_reg) & 0x02) ||
  4308. (snd_soc_read(codec, src_paired_reg) & 0x02)) {
  4309. snd_soc_update_bits(codec, src_clk_reg, 0x02,
  4310. 0x00);
  4311. snd_soc_update_bits(codec, src_paired_reg,
  4312. 0x02, 0x00);
  4313. }
  4314. snd_soc_update_bits(codec, src_clk_reg, 0x01, 0x01);
  4315. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4316. 0x80);
  4317. }
  4318. *src_users = count;
  4319. break;
  4320. case SND_SOC_DAPM_POST_PMD:
  4321. count = *src_users;
  4322. count--;
  4323. if (count == 0) {
  4324. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4325. 0x00);
  4326. snd_soc_update_bits(codec, src_clk_reg, 0x03, 0x02);
  4327. /* default sample rate */
  4328. snd_soc_update_bits(codec, rx_path_ctl_reg, 0x0f,
  4329. 0x04);
  4330. }
  4331. *src_users = count;
  4332. break;
  4333. };
  4334. dev_dbg(codec->dev, "%s: Spline SRC%d, users: %d\n",
  4335. __func__, spl_src, *src_users);
  4336. return 0;
  4337. }
  4338. static int tasha_codec_enable_spline_resampler(struct snd_soc_dapm_widget *w,
  4339. struct snd_kcontrol *kcontrol,
  4340. int event)
  4341. {
  4342. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4343. int ret = 0;
  4344. u8 src_in;
  4345. src_in = snd_soc_read(codec, WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0);
  4346. if (!(src_in & 0xFF)) {
  4347. dev_err(codec->dev, "%s: Spline SRC%u input not selected\n",
  4348. __func__, w->shift);
  4349. return -EINVAL;
  4350. }
  4351. switch (w->shift) {
  4352. case SPLINE_SRC0:
  4353. ret = tasha_codec_enable_spline_src(codec,
  4354. ((src_in & 0x03) == 1) ? SRC_IN_HPHL : SRC_IN_LO1,
  4355. event);
  4356. break;
  4357. case SPLINE_SRC1:
  4358. ret = tasha_codec_enable_spline_src(codec,
  4359. ((src_in & 0x0C) == 4) ? SRC_IN_HPHR : SRC_IN_LO2,
  4360. event);
  4361. break;
  4362. case SPLINE_SRC2:
  4363. ret = tasha_codec_enable_spline_src(codec,
  4364. ((src_in & 0x30) == 0x10) ? SRC_IN_LO3 : SRC_IN_SPKRL,
  4365. event);
  4366. break;
  4367. case SPLINE_SRC3:
  4368. ret = tasha_codec_enable_spline_src(codec,
  4369. ((src_in & 0xC0) == 0x40) ? SRC_IN_LO4 : SRC_IN_SPKRR,
  4370. event);
  4371. break;
  4372. default:
  4373. dev_err(codec->dev, "%s: Invalid spline src:%u\n", __func__,
  4374. w->shift);
  4375. ret = -EINVAL;
  4376. };
  4377. return ret;
  4378. }
  4379. static int tasha_codec_enable_swr(struct snd_soc_dapm_widget *w,
  4380. struct snd_kcontrol *kcontrol, int event)
  4381. {
  4382. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4383. struct tasha_priv *tasha;
  4384. int i, ch_cnt;
  4385. tasha = snd_soc_codec_get_drvdata(codec);
  4386. if (!tasha->nr)
  4387. return 0;
  4388. switch (event) {
  4389. case SND_SOC_DAPM_PRE_PMU:
  4390. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4391. !tasha->rx_7_count)
  4392. tasha->rx_7_count++;
  4393. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4394. !tasha->rx_8_count)
  4395. tasha->rx_8_count++;
  4396. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4397. for (i = 0; i < tasha->nr; i++) {
  4398. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4399. SWR_DEVICE_UP, NULL);
  4400. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4401. SWR_SET_NUM_RX_CH, &ch_cnt);
  4402. }
  4403. break;
  4404. case SND_SOC_DAPM_POST_PMD:
  4405. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4406. tasha->rx_7_count)
  4407. tasha->rx_7_count--;
  4408. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4409. tasha->rx_8_count)
  4410. tasha->rx_8_count--;
  4411. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4412. for (i = 0; i < tasha->nr; i++)
  4413. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4414. SWR_SET_NUM_RX_CH, &ch_cnt);
  4415. break;
  4416. }
  4417. dev_dbg(tasha->dev, "%s: current swr ch cnt: %d\n",
  4418. __func__, tasha->rx_7_count + tasha->rx_8_count);
  4419. return 0;
  4420. }
  4421. static int tasha_codec_config_ear_spkr_gain(struct snd_soc_codec *codec,
  4422. int event, int gain_reg)
  4423. {
  4424. int comp_gain_offset, val;
  4425. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4426. switch (tasha->spkr_mode) {
  4427. /* Compander gain in SPKR_MODE1 case is 12 dB */
  4428. case SPKR_MODE_1:
  4429. comp_gain_offset = -12;
  4430. break;
  4431. /* Default case compander gain is 15 dB */
  4432. default:
  4433. comp_gain_offset = -15;
  4434. break;
  4435. }
  4436. switch (event) {
  4437. case SND_SOC_DAPM_POST_PMU:
  4438. /* Apply ear spkr gain only if compander is enabled */
  4439. if (tasha->comp_enabled[COMPANDER_7] &&
  4440. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4441. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4442. (tasha->ear_spkr_gain != 0)) {
  4443. /* For example, val is -8(-12+5-1) for 4dB of gain */
  4444. val = comp_gain_offset + tasha->ear_spkr_gain - 1;
  4445. snd_soc_write(codec, gain_reg, val);
  4446. dev_dbg(codec->dev, "%s: RX7 Volume %d dB\n",
  4447. __func__, val);
  4448. }
  4449. break;
  4450. case SND_SOC_DAPM_POST_PMD:
  4451. /*
  4452. * Reset RX7 volume to 0 dB if compander is enabled and
  4453. * ear_spkr_gain is non-zero.
  4454. */
  4455. if (tasha->comp_enabled[COMPANDER_7] &&
  4456. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4457. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4458. (tasha->ear_spkr_gain != 0)) {
  4459. snd_soc_write(codec, gain_reg, 0x0);
  4460. dev_dbg(codec->dev, "%s: Reset RX7 Volume to 0 dB\n",
  4461. __func__);
  4462. }
  4463. break;
  4464. }
  4465. return 0;
  4466. }
  4467. static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w,
  4468. struct snd_kcontrol *kcontrol, int event)
  4469. {
  4470. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4471. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4472. u16 gain_reg;
  4473. int offset_val = 0;
  4474. int val = 0;
  4475. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4476. switch (w->reg) {
  4477. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4478. gain_reg = WCD9335_CDC_RX0_RX_VOL_MIX_CTL;
  4479. break;
  4480. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4481. gain_reg = WCD9335_CDC_RX1_RX_VOL_MIX_CTL;
  4482. break;
  4483. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4484. gain_reg = WCD9335_CDC_RX2_RX_VOL_MIX_CTL;
  4485. break;
  4486. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4487. gain_reg = WCD9335_CDC_RX3_RX_VOL_MIX_CTL;
  4488. break;
  4489. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4490. gain_reg = WCD9335_CDC_RX4_RX_VOL_MIX_CTL;
  4491. break;
  4492. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4493. gain_reg = WCD9335_CDC_RX5_RX_VOL_MIX_CTL;
  4494. break;
  4495. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4496. gain_reg = WCD9335_CDC_RX6_RX_VOL_MIX_CTL;
  4497. break;
  4498. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4499. gain_reg = WCD9335_CDC_RX7_RX_VOL_MIX_CTL;
  4500. break;
  4501. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4502. gain_reg = WCD9335_CDC_RX8_RX_VOL_MIX_CTL;
  4503. break;
  4504. default:
  4505. dev_err(codec->dev, "%s: No gain register avail for %s\n",
  4506. __func__, w->name);
  4507. return 0;
  4508. };
  4509. switch (event) {
  4510. case SND_SOC_DAPM_POST_PMU:
  4511. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4512. (tasha->comp_enabled[COMPANDER_7] ||
  4513. tasha->comp_enabled[COMPANDER_8]) &&
  4514. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4515. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4516. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4517. 0x01, 0x01);
  4518. snd_soc_update_bits(codec,
  4519. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4520. 0x01, 0x01);
  4521. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4522. 0x01, 0x01);
  4523. snd_soc_update_bits(codec,
  4524. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4525. 0x01, 0x01);
  4526. offset_val = -2;
  4527. }
  4528. val = snd_soc_read(codec, gain_reg);
  4529. val += offset_val;
  4530. snd_soc_write(codec, gain_reg, val);
  4531. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4532. break;
  4533. case SND_SOC_DAPM_POST_PMD:
  4534. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4535. (tasha->comp_enabled[COMPANDER_7] ||
  4536. tasha->comp_enabled[COMPANDER_8]) &&
  4537. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4538. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4539. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4540. 0x01, 0x00);
  4541. snd_soc_update_bits(codec,
  4542. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4543. 0x01, 0x00);
  4544. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4545. 0x01, 0x00);
  4546. snd_soc_update_bits(codec,
  4547. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4548. 0x01, 0x00);
  4549. offset_val = 2;
  4550. val = snd_soc_read(codec, gain_reg);
  4551. val += offset_val;
  4552. snd_soc_write(codec, gain_reg, val);
  4553. }
  4554. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4555. break;
  4556. };
  4557. return 0;
  4558. }
  4559. static int __tasha_cdc_native_clk_enable(struct tasha_priv *tasha,
  4560. bool enable)
  4561. {
  4562. int ret = 0;
  4563. struct snd_soc_codec *codec = tasha->codec;
  4564. if (!tasha->wcd_native_clk) {
  4565. dev_err(tasha->dev, "%s: wcd native clock is NULL\n", __func__);
  4566. return -EINVAL;
  4567. }
  4568. dev_dbg(tasha->dev, "%s: native_clk_enable = %u\n", __func__, enable);
  4569. if (enable) {
  4570. ret = clk_prepare_enable(tasha->wcd_native_clk);
  4571. if (ret) {
  4572. dev_err(tasha->dev, "%s: native clk enable failed\n",
  4573. __func__);
  4574. goto err;
  4575. }
  4576. if (++tasha->native_clk_users == 1) {
  4577. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4578. 0x10, 0x10);
  4579. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4580. 0x80, 0x80);
  4581. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4582. 0x04, 0x00);
  4583. snd_soc_update_bits(codec,
  4584. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4585. 0x02, 0x02);
  4586. }
  4587. } else {
  4588. if (tasha->native_clk_users &&
  4589. (--tasha->native_clk_users == 0)) {
  4590. snd_soc_update_bits(codec,
  4591. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4592. 0x02, 0x00);
  4593. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4594. 0x04, 0x04);
  4595. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4596. 0x80, 0x00);
  4597. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4598. 0x10, 0x00);
  4599. }
  4600. clk_disable_unprepare(tasha->wcd_native_clk);
  4601. }
  4602. dev_dbg(codec->dev, "%s: native_clk_users: %d\n", __func__,
  4603. tasha->native_clk_users);
  4604. err:
  4605. return ret;
  4606. }
  4607. static int tasha_codec_get_native_fifo_sync_mask(struct snd_soc_codec *codec,
  4608. int interp_n)
  4609. {
  4610. int mask = 0;
  4611. u16 reg;
  4612. u8 val1, val2, inp0 = 0;
  4613. u8 inp1 = 0, inp2 = 0;
  4614. reg = WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0 + (2 * interp_n) - 2;
  4615. val1 = snd_soc_read(codec, reg);
  4616. val2 = snd_soc_read(codec, reg + 1);
  4617. inp0 = val1 & 0x0F;
  4618. inp1 = (val1 >> 4) & 0x0F;
  4619. inp2 = (val2 >> 4) & 0x0F;
  4620. if (IS_VALID_NATIVE_FIFO_PORT(inp0))
  4621. mask |= (1 << (inp0 - 5));
  4622. if (IS_VALID_NATIVE_FIFO_PORT(inp1))
  4623. mask |= (1 << (inp1 - 5));
  4624. if (IS_VALID_NATIVE_FIFO_PORT(inp2))
  4625. mask |= (1 << (inp2 - 5));
  4626. dev_dbg(codec->dev, "%s: native fifo mask: 0x%x\n", __func__, mask);
  4627. if (!mask)
  4628. dev_err(codec->dev, "native fifo err,int:%d,inp0:%d,inp1:%d,inp2:%d\n",
  4629. interp_n, inp0, inp1, inp2);
  4630. return mask;
  4631. }
  4632. static int tasha_enable_native_supply(struct snd_soc_dapm_widget *w,
  4633. struct snd_kcontrol *kcontrol, int event)
  4634. {
  4635. int mask;
  4636. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4637. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4638. u16 interp_reg;
  4639. dev_dbg(codec->dev, "%s: event: %d, shift:%d\n", __func__, event,
  4640. w->shift);
  4641. if (w->shift < INTERP_HPHL || w->shift > INTERP_LO2)
  4642. return -EINVAL;
  4643. interp_reg = WCD9335_CDC_RX1_RX_PATH_CTL + 20 * (w->shift - 1);
  4644. mask = tasha_codec_get_native_fifo_sync_mask(codec, w->shift);
  4645. if (!mask)
  4646. return -EINVAL;
  4647. switch (event) {
  4648. case SND_SOC_DAPM_PRE_PMU:
  4649. /* Adjust interpolator rate to 44P1_NATIVE */
  4650. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x09);
  4651. __tasha_cdc_native_clk_enable(tasha, true);
  4652. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4653. mask, mask);
  4654. break;
  4655. case SND_SOC_DAPM_PRE_PMD:
  4656. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4657. mask, 0x0);
  4658. __tasha_cdc_native_clk_enable(tasha, false);
  4659. /* Adjust interpolator rate to default */
  4660. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x04);
  4661. break;
  4662. }
  4663. return 0;
  4664. }
  4665. static int tasha_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
  4666. struct snd_kcontrol *kcontrol, int event)
  4667. {
  4668. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4669. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4670. u16 gain_reg;
  4671. u16 reg;
  4672. int val;
  4673. int offset_val = 0;
  4674. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4675. if (!(strcmp(w->name, "RX INT0 INTERP"))) {
  4676. reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4677. gain_reg = WCD9335_CDC_RX0_RX_VOL_CTL;
  4678. } else if (!(strcmp(w->name, "RX INT1 INTERP"))) {
  4679. reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4680. gain_reg = WCD9335_CDC_RX1_RX_VOL_CTL;
  4681. } else if (!(strcmp(w->name, "RX INT2 INTERP"))) {
  4682. reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4683. gain_reg = WCD9335_CDC_RX2_RX_VOL_CTL;
  4684. } else if (!(strcmp(w->name, "RX INT3 INTERP"))) {
  4685. reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4686. gain_reg = WCD9335_CDC_RX3_RX_VOL_CTL;
  4687. } else if (!(strcmp(w->name, "RX INT4 INTERP"))) {
  4688. reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4689. gain_reg = WCD9335_CDC_RX4_RX_VOL_CTL;
  4690. } else if (!(strcmp(w->name, "RX INT5 INTERP"))) {
  4691. reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4692. gain_reg = WCD9335_CDC_RX5_RX_VOL_CTL;
  4693. } else if (!(strcmp(w->name, "RX INT6 INTERP"))) {
  4694. reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4695. gain_reg = WCD9335_CDC_RX6_RX_VOL_CTL;
  4696. } else if (!(strcmp(w->name, "RX INT7 INTERP"))) {
  4697. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4698. gain_reg = WCD9335_CDC_RX7_RX_VOL_CTL;
  4699. } else if (!(strcmp(w->name, "RX INT8 INTERP"))) {
  4700. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4701. gain_reg = WCD9335_CDC_RX8_RX_VOL_CTL;
  4702. } else {
  4703. dev_err(codec->dev, "%s: Interpolator reg not found\n",
  4704. __func__);
  4705. return -EINVAL;
  4706. }
  4707. switch (event) {
  4708. case SND_SOC_DAPM_PRE_PMU:
  4709. tasha_codec_vote_max_bw(codec, true);
  4710. /* Reset if needed */
  4711. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4712. break;
  4713. case SND_SOC_DAPM_POST_PMU:
  4714. tasha_config_compander(codec, w->shift, event);
  4715. /* apply gain after int clk is enabled */
  4716. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4717. (tasha->comp_enabled[COMPANDER_7] ||
  4718. tasha->comp_enabled[COMPANDER_8]) &&
  4719. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4720. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4721. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4722. 0x01, 0x01);
  4723. snd_soc_update_bits(codec,
  4724. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4725. 0x01, 0x01);
  4726. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4727. 0x01, 0x01);
  4728. snd_soc_update_bits(codec,
  4729. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4730. 0x01, 0x01);
  4731. offset_val = -2;
  4732. }
  4733. val = snd_soc_read(codec, gain_reg);
  4734. val += offset_val;
  4735. snd_soc_write(codec, gain_reg, val);
  4736. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4737. break;
  4738. case SND_SOC_DAPM_POST_PMD:
  4739. tasha_config_compander(codec, w->shift, event);
  4740. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4741. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4742. (tasha->comp_enabled[COMPANDER_7] ||
  4743. tasha->comp_enabled[COMPANDER_8]) &&
  4744. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4745. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4746. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4747. 0x01, 0x00);
  4748. snd_soc_update_bits(codec,
  4749. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4750. 0x01, 0x00);
  4751. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4752. 0x01, 0x00);
  4753. snd_soc_update_bits(codec,
  4754. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4755. 0x01, 0x00);
  4756. offset_val = 2;
  4757. val = snd_soc_read(codec, gain_reg);
  4758. val += offset_val;
  4759. snd_soc_write(codec, gain_reg, val);
  4760. }
  4761. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4762. break;
  4763. };
  4764. return 0;
  4765. }
  4766. static int tasha_codec_set_iir_gain(struct snd_soc_dapm_widget *w,
  4767. struct snd_kcontrol *kcontrol, int event)
  4768. {
  4769. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4770. dev_dbg(codec->dev, "%s: event = %d\n", __func__, event);
  4771. switch (event) {
  4772. case SND_SOC_DAPM_POST_PMU: /* fall through */
  4773. case SND_SOC_DAPM_PRE_PMD:
  4774. if (strnstr(w->name, "IIR0", sizeof("IIR0"))) {
  4775. snd_soc_write(codec,
  4776. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL,
  4777. snd_soc_read(codec,
  4778. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL));
  4779. snd_soc_write(codec,
  4780. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL,
  4781. snd_soc_read(codec,
  4782. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL));
  4783. snd_soc_write(codec,
  4784. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL,
  4785. snd_soc_read(codec,
  4786. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL));
  4787. snd_soc_write(codec,
  4788. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL,
  4789. snd_soc_read(codec,
  4790. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL));
  4791. } else {
  4792. snd_soc_write(codec,
  4793. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL,
  4794. snd_soc_read(codec,
  4795. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL));
  4796. snd_soc_write(codec,
  4797. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL,
  4798. snd_soc_read(codec,
  4799. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL));
  4800. snd_soc_write(codec,
  4801. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL,
  4802. snd_soc_read(codec,
  4803. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL));
  4804. }
  4805. break;
  4806. }
  4807. return 0;
  4808. }
  4809. static int tasha_codec_enable_on_demand_supply(
  4810. struct snd_soc_dapm_widget *w,
  4811. struct snd_kcontrol *kcontrol, int event)
  4812. {
  4813. int ret = 0;
  4814. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4815. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4816. struct on_demand_supply *supply;
  4817. if (w->shift >= ON_DEMAND_SUPPLIES_MAX) {
  4818. dev_err(codec->dev, "%s: error index > MAX Demand supplies",
  4819. __func__);
  4820. ret = -EINVAL;
  4821. goto out;
  4822. }
  4823. dev_dbg(codec->dev, "%s: supply: %s event: %d\n",
  4824. __func__, on_demand_supply_name[w->shift], event);
  4825. supply = &tasha->on_demand_list[w->shift];
  4826. WARN_ONCE(!supply->supply, "%s isn't defined\n",
  4827. on_demand_supply_name[w->shift]);
  4828. if (!supply->supply) {
  4829. dev_err(codec->dev, "%s: err supply not present ond for %d",
  4830. __func__, w->shift);
  4831. goto out;
  4832. }
  4833. switch (event) {
  4834. case SND_SOC_DAPM_PRE_PMU:
  4835. ret = regulator_enable(supply->supply);
  4836. if (ret)
  4837. dev_err(codec->dev, "%s: Failed to enable %s\n",
  4838. __func__,
  4839. on_demand_supply_name[w->shift]);
  4840. break;
  4841. case SND_SOC_DAPM_POST_PMD:
  4842. ret = regulator_disable(supply->supply);
  4843. if (ret)
  4844. dev_err(codec->dev, "%s: Failed to disable %s\n",
  4845. __func__,
  4846. on_demand_supply_name[w->shift]);
  4847. break;
  4848. default:
  4849. break;
  4850. };
  4851. out:
  4852. return ret;
  4853. }
  4854. static int tasha_codec_find_amic_input(struct snd_soc_codec *codec,
  4855. int adc_mux_n)
  4856. {
  4857. u16 mask, shift, adc_mux_in_reg;
  4858. u16 amic_mux_sel_reg;
  4859. bool is_amic;
  4860. if (adc_mux_n < 0 || adc_mux_n > WCD9335_MAX_VALID_ADC_MUX ||
  4861. adc_mux_n == WCD9335_INVALID_ADC_MUX)
  4862. return 0;
  4863. /* Check whether adc mux input is AMIC or DMIC */
  4864. if (adc_mux_n < 4) {
  4865. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
  4866. 2 * adc_mux_n;
  4867. amic_mux_sel_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  4868. 2 * adc_mux_n;
  4869. mask = 0x03;
  4870. shift = 0;
  4871. } else {
  4872. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  4873. adc_mux_n - 4;
  4874. amic_mux_sel_reg = adc_mux_in_reg;
  4875. mask = 0xC0;
  4876. shift = 6;
  4877. }
  4878. is_amic = (((snd_soc_read(codec, adc_mux_in_reg) & mask) >> shift)
  4879. == 1);
  4880. if (!is_amic)
  4881. return 0;
  4882. return snd_soc_read(codec, amic_mux_sel_reg) & 0x07;
  4883. }
  4884. static void tasha_codec_set_tx_hold(struct snd_soc_codec *codec,
  4885. u16 amic_reg, bool set)
  4886. {
  4887. u8 mask = 0x20;
  4888. u8 val;
  4889. if (amic_reg == WCD9335_ANA_AMIC1 ||
  4890. amic_reg == WCD9335_ANA_AMIC3 ||
  4891. amic_reg == WCD9335_ANA_AMIC5)
  4892. mask = 0x40;
  4893. val = set ? mask : 0x00;
  4894. switch (amic_reg) {
  4895. case WCD9335_ANA_AMIC1:
  4896. case WCD9335_ANA_AMIC2:
  4897. snd_soc_update_bits(codec, WCD9335_ANA_AMIC2, mask, val);
  4898. break;
  4899. case WCD9335_ANA_AMIC3:
  4900. case WCD9335_ANA_AMIC4:
  4901. snd_soc_update_bits(codec, WCD9335_ANA_AMIC4, mask, val);
  4902. break;
  4903. case WCD9335_ANA_AMIC5:
  4904. case WCD9335_ANA_AMIC6:
  4905. snd_soc_update_bits(codec, WCD9335_ANA_AMIC6, mask, val);
  4906. break;
  4907. default:
  4908. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4909. __func__, amic_reg);
  4910. break;
  4911. }
  4912. }
  4913. static int tasha_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w,
  4914. struct snd_kcontrol *kcontrol, int event)
  4915. {
  4916. int adc_mux_n = w->shift;
  4917. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4918. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4919. int amic_n;
  4920. dev_dbg(codec->dev, "%s: event: %d\n", __func__, event);
  4921. switch (event) {
  4922. case SND_SOC_DAPM_POST_PMU:
  4923. amic_n = tasha_codec_find_amic_input(codec, adc_mux_n);
  4924. if (amic_n) {
  4925. /*
  4926. * Prevent ANC Rx pop by leaving Tx FE in HOLD
  4927. * state until PA is up. Track AMIC being used
  4928. * so we can release the HOLD later.
  4929. */
  4930. set_bit(ANC_MIC_AMIC1 + amic_n - 1,
  4931. &tasha->status_mask);
  4932. }
  4933. break;
  4934. default:
  4935. break;
  4936. }
  4937. return 0;
  4938. }
  4939. static u16 tasha_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic)
  4940. {
  4941. u16 pwr_level_reg = 0;
  4942. switch (amic) {
  4943. case 1:
  4944. case 2:
  4945. pwr_level_reg = WCD9335_ANA_AMIC1;
  4946. break;
  4947. case 3:
  4948. case 4:
  4949. pwr_level_reg = WCD9335_ANA_AMIC3;
  4950. break;
  4951. case 5:
  4952. case 6:
  4953. pwr_level_reg = WCD9335_ANA_AMIC5;
  4954. break;
  4955. default:
  4956. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4957. __func__, amic);
  4958. break;
  4959. }
  4960. return pwr_level_reg;
  4961. }
  4962. #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
  4963. #define CF_MIN_3DB_4HZ 0x0
  4964. #define CF_MIN_3DB_75HZ 0x1
  4965. #define CF_MIN_3DB_150HZ 0x2
  4966. static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work)
  4967. {
  4968. struct delayed_work *hpf_delayed_work;
  4969. struct hpf_work *hpf_work;
  4970. struct tasha_priv *tasha;
  4971. struct snd_soc_codec *codec;
  4972. u16 dec_cfg_reg, amic_reg;
  4973. u8 hpf_cut_off_freq;
  4974. int amic_n;
  4975. hpf_delayed_work = to_delayed_work(work);
  4976. hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
  4977. tasha = hpf_work->tasha;
  4978. codec = tasha->codec;
  4979. hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
  4980. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator;
  4981. dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
  4982. __func__, hpf_work->decimator, hpf_cut_off_freq);
  4983. amic_n = tasha_codec_find_amic_input(codec, hpf_work->decimator);
  4984. if (amic_n) {
  4985. amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1;
  4986. tasha_codec_set_tx_hold(codec, amic_reg, false);
  4987. }
  4988. tasha_codec_vote_max_bw(codec, true);
  4989. snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  4990. hpf_cut_off_freq << 5);
  4991. tasha_codec_vote_max_bw(codec, false);
  4992. }
  4993. static void tasha_tx_mute_update_callback(struct work_struct *work)
  4994. {
  4995. struct tx_mute_work *tx_mute_dwork;
  4996. struct tasha_priv *tasha;
  4997. struct delayed_work *delayed_work;
  4998. struct snd_soc_codec *codec;
  4999. u16 tx_vol_ctl_reg, hpf_gate_reg;
  5000. delayed_work = to_delayed_work(work);
  5001. tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
  5002. tasha = tx_mute_dwork->tasha;
  5003. codec = tasha->codec;
  5004. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  5005. 16 * tx_mute_dwork->decimator;
  5006. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 +
  5007. 16 * tx_mute_dwork->decimator;
  5008. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x01);
  5009. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5010. }
  5011. static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w,
  5012. struct snd_kcontrol *kcontrol, int event)
  5013. {
  5014. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5015. unsigned int decimator;
  5016. char *dec_adc_mux_name = NULL;
  5017. char *widget_name = NULL;
  5018. char *wname;
  5019. int ret = 0, amic_n;
  5020. u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
  5021. u16 tx_gain_ctl_reg;
  5022. char *dec;
  5023. u8 hpf_cut_off_freq;
  5024. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5025. dev_dbg(codec->dev, "%s %d\n", __func__, event);
  5026. widget_name = kstrndup(w->name, 15, GFP_KERNEL);
  5027. if (!widget_name)
  5028. return -ENOMEM;
  5029. wname = widget_name;
  5030. dec_adc_mux_name = strsep(&widget_name, " ");
  5031. if (!dec_adc_mux_name) {
  5032. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5033. __func__, w->name);
  5034. ret = -EINVAL;
  5035. goto out;
  5036. }
  5037. dec_adc_mux_name = widget_name;
  5038. dec = strpbrk(dec_adc_mux_name, "012345678");
  5039. if (!dec) {
  5040. dev_err(codec->dev, "%s: decimator index not found\n",
  5041. __func__);
  5042. ret = -EINVAL;
  5043. goto out;
  5044. }
  5045. ret = kstrtouint(dec, 10, &decimator);
  5046. if (ret < 0) {
  5047. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5048. __func__, wname);
  5049. ret = -EINVAL;
  5050. goto out;
  5051. }
  5052. dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__,
  5053. w->name, decimator);
  5054. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator;
  5055. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 + 16 * decimator;
  5056. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * decimator;
  5057. tx_gain_ctl_reg = WCD9335_CDC_TX0_TX_VOL_CTL + 16 * decimator;
  5058. switch (event) {
  5059. case SND_SOC_DAPM_PRE_PMU:
  5060. amic_n = tasha_codec_find_amic_input(codec, decimator);
  5061. if (amic_n)
  5062. pwr_level_reg = tasha_codec_get_amic_pwlvl_reg(codec,
  5063. amic_n);
  5064. if (pwr_level_reg) {
  5065. switch ((snd_soc_read(codec, pwr_level_reg) &
  5066. WCD9335_AMIC_PWR_LVL_MASK) >>
  5067. WCD9335_AMIC_PWR_LVL_SHIFT) {
  5068. case WCD9335_AMIC_PWR_LEVEL_LP:
  5069. snd_soc_update_bits(codec, dec_cfg_reg,
  5070. WCD9335_DEC_PWR_LVL_MASK,
  5071. WCD9335_DEC_PWR_LVL_LP);
  5072. break;
  5073. case WCD9335_AMIC_PWR_LEVEL_HP:
  5074. snd_soc_update_bits(codec, dec_cfg_reg,
  5075. WCD9335_DEC_PWR_LVL_MASK,
  5076. WCD9335_DEC_PWR_LVL_HP);
  5077. break;
  5078. case WCD9335_AMIC_PWR_LEVEL_DEFAULT:
  5079. default:
  5080. snd_soc_update_bits(codec, dec_cfg_reg,
  5081. WCD9335_DEC_PWR_LVL_MASK,
  5082. WCD9335_DEC_PWR_LVL_DF);
  5083. break;
  5084. }
  5085. }
  5086. hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) &
  5087. TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
  5088. tasha->tx_hpf_work[decimator].hpf_cut_off_freq =
  5089. hpf_cut_off_freq;
  5090. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
  5091. snd_soc_update_bits(codec, dec_cfg_reg,
  5092. TX_HPF_CUT_OFF_FREQ_MASK,
  5093. CF_MIN_3DB_150HZ << 5);
  5094. /* Enable TX PGA Mute */
  5095. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5096. break;
  5097. case SND_SOC_DAPM_POST_PMU:
  5098. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00);
  5099. if (decimator == 0) {
  5100. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5101. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0xA3);
  5102. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5103. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x03);
  5104. }
  5105. /* schedule work queue to Remove Mute */
  5106. schedule_delayed_work(&tasha->tx_mute_dwork[decimator].dwork,
  5107. msecs_to_jiffies(tx_unmute_delay));
  5108. if (tasha->tx_hpf_work[decimator].hpf_cut_off_freq !=
  5109. CF_MIN_3DB_150HZ)
  5110. schedule_delayed_work(
  5111. &tasha->tx_hpf_work[decimator].dwork,
  5112. msecs_to_jiffies(300));
  5113. /* apply gain after decimator is enabled */
  5114. snd_soc_write(codec, tx_gain_ctl_reg,
  5115. snd_soc_read(codec, tx_gain_ctl_reg));
  5116. break;
  5117. case SND_SOC_DAPM_PRE_PMD:
  5118. hpf_cut_off_freq =
  5119. tasha->tx_hpf_work[decimator].hpf_cut_off_freq;
  5120. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5121. if (cancel_delayed_work_sync(
  5122. &tasha->tx_hpf_work[decimator].dwork)) {
  5123. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  5124. tasha_codec_vote_max_bw(codec, true);
  5125. snd_soc_update_bits(codec, dec_cfg_reg,
  5126. TX_HPF_CUT_OFF_FREQ_MASK,
  5127. hpf_cut_off_freq << 5);
  5128. tasha_codec_vote_max_bw(codec, false);
  5129. }
  5130. }
  5131. cancel_delayed_work_sync(
  5132. &tasha->tx_mute_dwork[decimator].dwork);
  5133. break;
  5134. case SND_SOC_DAPM_POST_PMD:
  5135. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5136. break;
  5137. };
  5138. out:
  5139. kfree(wname);
  5140. return ret;
  5141. }
  5142. static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec,
  5143. unsigned int dmic, struct wcd9xxx_pdata *pdata)
  5144. {
  5145. u8 tx_stream_fs;
  5146. u8 adc_mux_index = 0, adc_mux_sel = 0;
  5147. bool dec_found = false;
  5148. u16 adc_mux_ctl_reg, tx_fs_reg;
  5149. u32 dmic_fs;
  5150. while (dec_found == 0 && adc_mux_index < WCD9335_MAX_VALID_ADC_MUX) {
  5151. if (adc_mux_index < 4) {
  5152. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  5153. (adc_mux_index * 2);
  5154. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5155. 0x78) >> 3) - 1;
  5156. } else if (adc_mux_index < 9) {
  5157. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  5158. ((adc_mux_index - 4) * 1);
  5159. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5160. 0x38) >> 3) - 1;
  5161. } else if (adc_mux_index == 9) {
  5162. ++adc_mux_index;
  5163. continue;
  5164. }
  5165. if (adc_mux_sel == dmic)
  5166. dec_found = true;
  5167. else
  5168. ++adc_mux_index;
  5169. }
  5170. if (dec_found == true && adc_mux_index <= 8) {
  5171. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index);
  5172. tx_stream_fs = snd_soc_read(codec, tx_fs_reg) & 0x0F;
  5173. dmic_fs = tx_stream_fs <= 4 ? WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ :
  5174. WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  5175. /*
  5176. * Check for ECPP path selection and DEC1 not connected to
  5177. * any other audio path to apply ECPP DMIC sample rate
  5178. */
  5179. if ((adc_mux_index == 1) &&
  5180. ((snd_soc_read(codec, WCD9335_CPE_SS_US_EC_MUX_CFG)
  5181. & 0x0F) == 0x0A) &&
  5182. ((snd_soc_read(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0)
  5183. & 0x0C) == 0x00)) {
  5184. dmic_fs = pdata->ecpp_dmic_sample_rate;
  5185. }
  5186. } else {
  5187. dmic_fs = pdata->dmic_sample_rate;
  5188. }
  5189. return dmic_fs;
  5190. }
  5191. static u8 tasha_get_dmic_clk_val(struct snd_soc_codec *codec,
  5192. u32 mclk_rate, u32 dmic_clk_rate)
  5193. {
  5194. u32 div_factor;
  5195. u8 dmic_ctl_val;
  5196. dev_dbg(codec->dev,
  5197. "%s: mclk_rate = %d, dmic_sample_rate = %d\n",
  5198. __func__, mclk_rate, dmic_clk_rate);
  5199. /* Default value to return in case of error */
  5200. if (mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  5201. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5202. else
  5203. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5204. if (dmic_clk_rate == 0) {
  5205. dev_err(codec->dev,
  5206. "%s: dmic_sample_rate cannot be 0\n",
  5207. __func__);
  5208. goto done;
  5209. }
  5210. div_factor = mclk_rate / dmic_clk_rate;
  5211. switch (div_factor) {
  5212. case 2:
  5213. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5214. break;
  5215. case 3:
  5216. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5217. break;
  5218. case 4:
  5219. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_4;
  5220. break;
  5221. case 6:
  5222. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_6;
  5223. break;
  5224. case 8:
  5225. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_8;
  5226. break;
  5227. case 16:
  5228. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_16;
  5229. break;
  5230. default:
  5231. dev_err(codec->dev,
  5232. "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n",
  5233. __func__, div_factor, mclk_rate, dmic_clk_rate);
  5234. break;
  5235. }
  5236. done:
  5237. return dmic_ctl_val;
  5238. }
  5239. static int tasha_codec_enable_adc(struct snd_soc_dapm_widget *w,
  5240. struct snd_kcontrol *kcontrol, int event)
  5241. {
  5242. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5243. dev_dbg(codec->dev, "%s: event:%d\n", __func__, event);
  5244. switch (event) {
  5245. case SND_SOC_DAPM_PRE_PMU:
  5246. tasha_codec_set_tx_hold(codec, w->reg, true);
  5247. break;
  5248. default:
  5249. break;
  5250. }
  5251. return 0;
  5252. }
  5253. static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w,
  5254. struct snd_kcontrol *kcontrol, int event)
  5255. {
  5256. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5257. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5258. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  5259. u8 dmic_clk_en = 0x01;
  5260. u16 dmic_clk_reg;
  5261. s32 *dmic_clk_cnt;
  5262. u8 dmic_rate_val, dmic_rate_shift = 1;
  5263. unsigned int dmic;
  5264. u32 dmic_sample_rate;
  5265. int ret;
  5266. char *wname;
  5267. wname = strpbrk(w->name, "012345");
  5268. if (!wname) {
  5269. dev_err(codec->dev, "%s: widget not found\n", __func__);
  5270. return -EINVAL;
  5271. }
  5272. ret = kstrtouint(wname, 10, &dmic);
  5273. if (ret < 0) {
  5274. dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n",
  5275. __func__);
  5276. return -EINVAL;
  5277. }
  5278. switch (dmic) {
  5279. case 0:
  5280. case 1:
  5281. dmic_clk_cnt = &(tasha->dmic_0_1_clk_cnt);
  5282. dmic_clk_reg = WCD9335_CPE_SS_DMIC0_CTL;
  5283. break;
  5284. case 2:
  5285. case 3:
  5286. dmic_clk_cnt = &(tasha->dmic_2_3_clk_cnt);
  5287. dmic_clk_reg = WCD9335_CPE_SS_DMIC1_CTL;
  5288. break;
  5289. case 4:
  5290. case 5:
  5291. dmic_clk_cnt = &(tasha->dmic_4_5_clk_cnt);
  5292. dmic_clk_reg = WCD9335_CPE_SS_DMIC2_CTL;
  5293. break;
  5294. default:
  5295. dev_err(codec->dev, "%s: Invalid DMIC Selection\n",
  5296. __func__);
  5297. return -EINVAL;
  5298. };
  5299. dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
  5300. __func__, event, dmic, *dmic_clk_cnt);
  5301. switch (event) {
  5302. case SND_SOC_DAPM_PRE_PMU:
  5303. dmic_sample_rate = tasha_get_dmic_sample_rate(codec, dmic,
  5304. pdata);
  5305. dmic_rate_val =
  5306. tasha_get_dmic_clk_val(codec,
  5307. pdata->mclk_rate,
  5308. dmic_sample_rate);
  5309. (*dmic_clk_cnt)++;
  5310. if (*dmic_clk_cnt == 1) {
  5311. snd_soc_update_bits(codec, dmic_clk_reg,
  5312. 0x07 << dmic_rate_shift,
  5313. dmic_rate_val << dmic_rate_shift);
  5314. snd_soc_update_bits(codec, dmic_clk_reg,
  5315. dmic_clk_en, dmic_clk_en);
  5316. }
  5317. break;
  5318. case SND_SOC_DAPM_POST_PMD:
  5319. dmic_rate_val =
  5320. tasha_get_dmic_clk_val(codec,
  5321. pdata->mclk_rate,
  5322. pdata->mad_dmic_sample_rate);
  5323. (*dmic_clk_cnt)--;
  5324. if (*dmic_clk_cnt == 0) {
  5325. snd_soc_update_bits(codec, dmic_clk_reg,
  5326. dmic_clk_en, 0);
  5327. snd_soc_update_bits(codec, dmic_clk_reg,
  5328. 0x07 << dmic_rate_shift,
  5329. dmic_rate_val << dmic_rate_shift);
  5330. }
  5331. break;
  5332. };
  5333. return 0;
  5334. }
  5335. static int __tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5336. int event)
  5337. {
  5338. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5339. int micb_num;
  5340. dev_dbg(codec->dev, "%s: wname: %s, event: %d\n",
  5341. __func__, w->name, event);
  5342. if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1")))
  5343. micb_num = MIC_BIAS_1;
  5344. else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2")))
  5345. micb_num = MIC_BIAS_2;
  5346. else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3")))
  5347. micb_num = MIC_BIAS_3;
  5348. else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4")))
  5349. micb_num = MIC_BIAS_4;
  5350. else
  5351. return -EINVAL;
  5352. switch (event) {
  5353. case SND_SOC_DAPM_PRE_PMU:
  5354. /*
  5355. * MIC BIAS can also be requested by MBHC,
  5356. * so use ref count to handle micbias pullup
  5357. * and enable requests
  5358. */
  5359. tasha_micbias_control(codec, micb_num, MICB_ENABLE, true);
  5360. break;
  5361. case SND_SOC_DAPM_POST_PMU:
  5362. /* wait for cnp time */
  5363. usleep_range(1000, 1100);
  5364. break;
  5365. case SND_SOC_DAPM_POST_PMD:
  5366. tasha_micbias_control(codec, micb_num, MICB_DISABLE, true);
  5367. break;
  5368. };
  5369. return 0;
  5370. }
  5371. static int tasha_codec_ldo_h_control(struct snd_soc_dapm_widget *w,
  5372. int event)
  5373. {
  5374. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5375. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5376. if (SND_SOC_DAPM_EVENT_ON(event)) {
  5377. tasha->ldo_h_users++;
  5378. if (tasha->ldo_h_users == 1)
  5379. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5380. 0x80, 0x80);
  5381. }
  5382. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  5383. tasha->ldo_h_users--;
  5384. if (tasha->ldo_h_users < 0)
  5385. tasha->ldo_h_users = 0;
  5386. if (tasha->ldo_h_users == 0)
  5387. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5388. 0x80, 0x00);
  5389. }
  5390. return 0;
  5391. }
  5392. static int tasha_codec_force_enable_ldo_h(struct snd_soc_dapm_widget *w,
  5393. struct snd_kcontrol *kcontrol,
  5394. int event)
  5395. {
  5396. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5397. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5398. switch (event) {
  5399. case SND_SOC_DAPM_PRE_PMU:
  5400. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5401. tasha_codec_ldo_h_control(w, event);
  5402. break;
  5403. case SND_SOC_DAPM_POST_PMD:
  5404. tasha_codec_ldo_h_control(w, event);
  5405. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5406. break;
  5407. }
  5408. return 0;
  5409. }
  5410. static int tasha_codec_force_enable_micbias(struct snd_soc_dapm_widget *w,
  5411. struct snd_kcontrol *kcontrol,
  5412. int event)
  5413. {
  5414. int ret = 0;
  5415. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5416. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5417. switch (event) {
  5418. case SND_SOC_DAPM_PRE_PMU:
  5419. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5420. tasha_cdc_mclk_enable(codec, true, true);
  5421. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_PRE_PMU);
  5422. /* Wait for 1ms for better cnp */
  5423. usleep_range(1000, 1100);
  5424. tasha_cdc_mclk_enable(codec, false, true);
  5425. break;
  5426. case SND_SOC_DAPM_POST_PMD:
  5427. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_POST_PMD);
  5428. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5429. break;
  5430. }
  5431. return ret;
  5432. }
  5433. static int tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5434. struct snd_kcontrol *kcontrol, int event)
  5435. {
  5436. return __tasha_codec_enable_micbias(w, event);
  5437. }
  5438. static int tasha_codec_enable_standalone_ldo_h(struct snd_soc_codec *codec,
  5439. bool enable)
  5440. {
  5441. int rc;
  5442. if (enable)
  5443. rc = snd_soc_dapm_force_enable_pin(
  5444. snd_soc_codec_get_dapm(codec),
  5445. DAPM_LDO_H_STANDALONE);
  5446. else
  5447. rc = snd_soc_dapm_disable_pin(
  5448. snd_soc_codec_get_dapm(codec),
  5449. DAPM_LDO_H_STANDALONE);
  5450. if (!rc)
  5451. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5452. else
  5453. dev_err(codec->dev, "%s: ldo_h force %s pin failed\n",
  5454. __func__, (enable ? "enable" : "disable"));
  5455. return rc;
  5456. }
  5457. /*
  5458. * tasha_codec_enable_standalone_micbias - enable micbias standalone
  5459. * @codec: pointer to codec instance
  5460. * @micb_num: number of micbias to be enabled
  5461. * @enable: true to enable micbias or false to disable
  5462. *
  5463. * This function is used to enable micbias (1, 2, 3 or 4) during
  5464. * standalone independent of whether TX use-case is running or not
  5465. *
  5466. * Return: error code in case of failure or 0 for success
  5467. */
  5468. int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
  5469. int micb_num,
  5470. bool enable)
  5471. {
  5472. const char * const micb_names[] = {
  5473. DAPM_MICBIAS1_STANDALONE, DAPM_MICBIAS2_STANDALONE,
  5474. DAPM_MICBIAS3_STANDALONE, DAPM_MICBIAS4_STANDALONE
  5475. };
  5476. int micb_index = micb_num - 1;
  5477. int rc;
  5478. if (!codec) {
  5479. pr_err("%s: Codec memory is NULL\n", __func__);
  5480. return -EINVAL;
  5481. }
  5482. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  5483. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  5484. __func__, micb_index);
  5485. return -EINVAL;
  5486. }
  5487. if (enable)
  5488. rc = snd_soc_dapm_force_enable_pin(
  5489. snd_soc_codec_get_dapm(codec),
  5490. micb_names[micb_index]);
  5491. else
  5492. rc = snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec),
  5493. micb_names[micb_index]);
  5494. if (!rc)
  5495. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5496. else
  5497. dev_err(codec->dev, "%s: micbias%d force %s pin failed\n",
  5498. __func__, micb_num, (enable ? "enable" : "disable"));
  5499. return rc;
  5500. }
  5501. EXPORT_SYMBOL(tasha_codec_enable_standalone_micbias);
  5502. static const char *const tasha_anc_func_text[] = {"OFF", "ON"};
  5503. static const struct soc_enum tasha_anc_func_enum =
  5504. SOC_ENUM_SINGLE_EXT(2, tasha_anc_func_text);
  5505. static const char *const tasha_clkmode_text[] = {"EXTERNAL", "INTERNAL"};
  5506. static SOC_ENUM_SINGLE_EXT_DECL(tasha_clkmode_enum, tasha_clkmode_text);
  5507. /* Cutoff frequency for high pass filter */
  5508. static const char * const cf_text[] = {
  5509. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
  5510. };
  5511. static const char * const rx_cf_text[] = {
  5512. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ",
  5513. "CF_NEG_3DB_0P48HZ"
  5514. };
  5515. static const struct soc_enum cf_dec0_enum =
  5516. SOC_ENUM_SINGLE(WCD9335_CDC_TX0_TX_PATH_CFG0, 5, 3, cf_text);
  5517. static const struct soc_enum cf_dec1_enum =
  5518. SOC_ENUM_SINGLE(WCD9335_CDC_TX1_TX_PATH_CFG0, 5, 3, cf_text);
  5519. static const struct soc_enum cf_dec2_enum =
  5520. SOC_ENUM_SINGLE(WCD9335_CDC_TX2_TX_PATH_CFG0, 5, 3, cf_text);
  5521. static const struct soc_enum cf_dec3_enum =
  5522. SOC_ENUM_SINGLE(WCD9335_CDC_TX3_TX_PATH_CFG0, 5, 3, cf_text);
  5523. static const struct soc_enum cf_dec4_enum =
  5524. SOC_ENUM_SINGLE(WCD9335_CDC_TX4_TX_PATH_CFG0, 5, 3, cf_text);
  5525. static const struct soc_enum cf_dec5_enum =
  5526. SOC_ENUM_SINGLE(WCD9335_CDC_TX5_TX_PATH_CFG0, 5, 3, cf_text);
  5527. static const struct soc_enum cf_dec6_enum =
  5528. SOC_ENUM_SINGLE(WCD9335_CDC_TX6_TX_PATH_CFG0, 5, 3, cf_text);
  5529. static const struct soc_enum cf_dec7_enum =
  5530. SOC_ENUM_SINGLE(WCD9335_CDC_TX7_TX_PATH_CFG0, 5, 3, cf_text);
  5531. static const struct soc_enum cf_dec8_enum =
  5532. SOC_ENUM_SINGLE(WCD9335_CDC_TX8_TX_PATH_CFG0, 5, 3, cf_text);
  5533. static const struct soc_enum cf_int0_1_enum =
  5534. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5535. static SOC_ENUM_SINGLE_DECL(cf_int0_2_enum, WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 2,
  5536. rx_cf_text);
  5537. static const struct soc_enum cf_int1_1_enum =
  5538. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5539. static SOC_ENUM_SINGLE_DECL(cf_int1_2_enum, WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 2,
  5540. rx_cf_text);
  5541. static const struct soc_enum cf_int2_1_enum =
  5542. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5543. static SOC_ENUM_SINGLE_DECL(cf_int2_2_enum, WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 2,
  5544. rx_cf_text);
  5545. static const struct soc_enum cf_int3_1_enum =
  5546. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5547. static SOC_ENUM_SINGLE_DECL(cf_int3_2_enum, WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 2,
  5548. rx_cf_text);
  5549. static const struct soc_enum cf_int4_1_enum =
  5550. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5551. static SOC_ENUM_SINGLE_DECL(cf_int4_2_enum, WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 2,
  5552. rx_cf_text);
  5553. static const struct soc_enum cf_int5_1_enum =
  5554. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5555. static SOC_ENUM_SINGLE_DECL(cf_int5_2_enum, WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 2,
  5556. rx_cf_text);
  5557. static const struct soc_enum cf_int6_1_enum =
  5558. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5559. static SOC_ENUM_SINGLE_DECL(cf_int6_2_enum, WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 2,
  5560. rx_cf_text);
  5561. static const struct soc_enum cf_int7_1_enum =
  5562. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5563. static SOC_ENUM_SINGLE_DECL(cf_int7_2_enum, WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 2,
  5564. rx_cf_text);
  5565. static const struct soc_enum cf_int8_1_enum =
  5566. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5567. static SOC_ENUM_SINGLE_DECL(cf_int8_2_enum, WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 2,
  5568. rx_cf_text);
  5569. static const struct snd_soc_dapm_route audio_i2s_map[] = {
  5570. {"SLIM RX0 MUX", NULL, "RX_I2S_CTL"},
  5571. {"SLIM RX1 MUX", NULL, "RX_I2S_CTL"},
  5572. {"SLIM RX2 MUX", NULL, "RX_I2S_CTL"},
  5573. {"SLIM RX3 MUX", NULL, "RX_I2S_CTL"},
  5574. {"SLIM TX6 MUX", NULL, "TX_I2S_CTL"},
  5575. {"SLIM TX7 MUX", NULL, "TX_I2S_CTL"},
  5576. {"SLIM TX8 MUX", NULL, "TX_I2S_CTL"},
  5577. {"SLIM TX11 MUX", NULL, "TX_I2S_CTL"},
  5578. };
  5579. static const struct snd_soc_dapm_route audio_map[] = {
  5580. /* MAD */
  5581. {"MAD_SEL MUX", "SPE", "MAD_CPE_INPUT"},
  5582. {"MAD_SEL MUX", "MSM", "MADINPUT"},
  5583. {"MADONOFF", "Switch", "MAD_SEL MUX"},
  5584. {"MAD_BROADCAST", "Switch", "MAD_SEL MUX"},
  5585. {"TX13 INP MUX", "CPE_TX_PP", "MADONOFF"},
  5586. /* CPE HW MAD bypass */
  5587. {"CPE IN Mixer", "MAD_BYPASS", "SLIM TX1 MUX"},
  5588. {"AIF4_MAD Mixer", "SLIM TX1", "CPE IN Mixer"},
  5589. {"AIF4_MAD Mixer", "SLIM TX12", "MADONOFF"},
  5590. {"AIF4_MAD Mixer", "SLIM TX13", "TX13 INP MUX"},
  5591. {"AIF4 MAD", NULL, "AIF4_MAD Mixer"},
  5592. {"AIF4 MAD", NULL, "AIF4"},
  5593. {"EC BUF MUX INP", "DEC1", "ADC MUX1"},
  5594. {"AIF5 CPE", NULL, "EC BUF MUX INP"},
  5595. /* SLIMBUS Connections */
  5596. {"AIF1 CAP", NULL, "AIF1_CAP Mixer"},
  5597. {"AIF2 CAP", NULL, "AIF2_CAP Mixer"},
  5598. {"AIF3 CAP", NULL, "AIF3_CAP Mixer"},
  5599. /* VI Feedback */
  5600. {"AIF4_VI Mixer", "SPKR_VI_1", "VIINPUT"},
  5601. {"AIF4_VI Mixer", "SPKR_VI_2", "VIINPUT"},
  5602. {"AIF4 VI", NULL, "AIF4_VI Mixer"},
  5603. /* SLIM_MIXER("AIF1_CAP Mixer"),*/
  5604. {"AIF1_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5605. {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5606. {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5607. {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5608. {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5609. {"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5610. {"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5611. {"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5612. {"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5613. {"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5614. {"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5615. {"AIF1_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5616. {"AIF1_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5617. /* SLIM_MIXER("AIF2_CAP Mixer"),*/
  5618. {"AIF2_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5619. {"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5620. {"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5621. {"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5622. {"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5623. {"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5624. {"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5625. {"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5626. {"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5627. {"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5628. {"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5629. {"AIF2_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5630. {"AIF2_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5631. /* SLIM_MIXER("AIF3_CAP Mixer"),*/
  5632. {"AIF3_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5633. {"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5634. {"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5635. {"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5636. {"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5637. {"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5638. {"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5639. {"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5640. {"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5641. {"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5642. {"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5643. {"AIF3_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5644. {"AIF3_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5645. {"SLIM TX0 MUX", "DEC0", "ADC MUX0"},
  5646. {"SLIM TX0 MUX", "RX_MIX_TX0", "RX MIX TX0 MUX"},
  5647. {"SLIM TX0 MUX", "DEC0_192", "ADC US MUX0"},
  5648. {"SLIM TX1 MUX", "DEC1", "ADC MUX1"},
  5649. {"SLIM TX1 MUX", "RX_MIX_TX1", "RX MIX TX1 MUX"},
  5650. {"SLIM TX1 MUX", "DEC1_192", "ADC US MUX1"},
  5651. {"SLIM TX2 MUX", "DEC2", "ADC MUX2"},
  5652. {"SLIM TX2 MUX", "RX_MIX_TX2", "RX MIX TX2 MUX"},
  5653. {"SLIM TX2 MUX", "DEC2_192", "ADC US MUX2"},
  5654. {"SLIM TX3 MUX", "DEC3", "ADC MUX3"},
  5655. {"SLIM TX3 MUX", "RX_MIX_TX3", "RX MIX TX3 MUX"},
  5656. {"SLIM TX3 MUX", "DEC3_192", "ADC US MUX3"},
  5657. {"SLIM TX4 MUX", "DEC4", "ADC MUX4"},
  5658. {"SLIM TX4 MUX", "RX_MIX_TX4", "RX MIX TX4 MUX"},
  5659. {"SLIM TX4 MUX", "DEC4_192", "ADC US MUX4"},
  5660. {"SLIM TX5 MUX", "DEC5", "ADC MUX5"},
  5661. {"SLIM TX5 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5662. {"SLIM TX5 MUX", "DEC5_192", "ADC US MUX5"},
  5663. {"SLIM TX6 MUX", "DEC6", "ADC MUX6"},
  5664. {"SLIM TX6 MUX", "RX_MIX_TX6", "RX MIX TX6 MUX"},
  5665. {"SLIM TX6 MUX", "DEC6_192", "ADC US MUX6"},
  5666. {"SLIM TX7 MUX", "DEC7", "ADC MUX7"},
  5667. {"SLIM TX7 MUX", "RX_MIX_TX7", "RX MIX TX7 MUX"},
  5668. {"SLIM TX7 MUX", "DEC7_192", "ADC US MUX7"},
  5669. {"SLIM TX8 MUX", "DEC8", "ADC MUX8"},
  5670. {"SLIM TX8 MUX", "RX_MIX_TX8", "RX MIX TX8 MUX"},
  5671. {"SLIM TX8 MUX", "DEC8_192", "ADC US MUX8"},
  5672. {"SLIM TX9 MUX", "DEC7", "ADC MUX7"},
  5673. {"SLIM TX9 MUX", "DEC7_192", "ADC US MUX7"},
  5674. {"SLIM TX10 MUX", "DEC6", "ADC MUX6"},
  5675. {"SLIM TX10 MUX", "DEC6_192", "ADC US MUX6"},
  5676. {"SLIM TX11 MUX", "DEC_0_5", "SLIM TX11 INP1 MUX"},
  5677. {"SLIM TX11 MUX", "DEC_9_12", "SLIM TX11 INP1 MUX"},
  5678. {"SLIM TX11 INP1 MUX", "DEC0", "ADC MUX0"},
  5679. {"SLIM TX11 INP1 MUX", "DEC1", "ADC MUX1"},
  5680. {"SLIM TX11 INP1 MUX", "DEC2", "ADC MUX2"},
  5681. {"SLIM TX11 INP1 MUX", "DEC3", "ADC MUX3"},
  5682. {"SLIM TX11 INP1 MUX", "DEC4", "ADC MUX4"},
  5683. {"SLIM TX11 INP1 MUX", "DEC5", "ADC MUX5"},
  5684. {"SLIM TX11 INP1 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5685. {"TX13 INP MUX", "MAD_BRDCST", "MAD_BROADCAST"},
  5686. {"TX13 INP MUX", "CDC_DEC_5", "SLIM TX13 MUX"},
  5687. {"SLIM TX13 MUX", "DEC5", "ADC MUX5"},
  5688. {"RX MIX TX0 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5689. {"RX MIX TX0 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5690. {"RX MIX TX0 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5691. {"RX MIX TX0 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5692. {"RX MIX TX0 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5693. {"RX MIX TX0 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5694. {"RX MIX TX0 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5695. {"RX MIX TX0 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5696. {"RX MIX TX0 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5697. {"RX MIX TX0 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5698. {"RX MIX TX0 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5699. {"RX MIX TX0 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5700. {"RX MIX TX0 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5701. {"RX MIX TX1 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5702. {"RX MIX TX1 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5703. {"RX MIX TX1 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5704. {"RX MIX TX1 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5705. {"RX MIX TX1 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5706. {"RX MIX TX1 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5707. {"RX MIX TX1 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5708. {"RX MIX TX1 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5709. {"RX MIX TX1 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5710. {"RX MIX TX1 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5711. {"RX MIX TX1 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5712. {"RX MIX TX1 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5713. {"RX MIX TX1 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5714. {"RX MIX TX2 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5715. {"RX MIX TX2 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5716. {"RX MIX TX2 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5717. {"RX MIX TX2 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5718. {"RX MIX TX2 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5719. {"RX MIX TX2 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5720. {"RX MIX TX2 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5721. {"RX MIX TX2 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5722. {"RX MIX TX2 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5723. {"RX MIX TX2 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5724. {"RX MIX TX2 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5725. {"RX MIX TX2 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5726. {"RX MIX TX2 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5727. {"RX MIX TX3 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5728. {"RX MIX TX3 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5729. {"RX MIX TX3 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5730. {"RX MIX TX3 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5731. {"RX MIX TX3 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5732. {"RX MIX TX3 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5733. {"RX MIX TX3 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5734. {"RX MIX TX3 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5735. {"RX MIX TX3 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5736. {"RX MIX TX3 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5737. {"RX MIX TX3 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5738. {"RX MIX TX3 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5739. {"RX MIX TX3 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5740. {"RX MIX TX4 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5741. {"RX MIX TX4 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5742. {"RX MIX TX4 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5743. {"RX MIX TX4 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5744. {"RX MIX TX4 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5745. {"RX MIX TX4 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5746. {"RX MIX TX4 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5747. {"RX MIX TX4 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5748. {"RX MIX TX4 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5749. {"RX MIX TX4 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5750. {"RX MIX TX4 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5751. {"RX MIX TX4 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5752. {"RX MIX TX4 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5753. {"RX MIX TX5 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5754. {"RX MIX TX5 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5755. {"RX MIX TX5 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5756. {"RX MIX TX5 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5757. {"RX MIX TX5 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5758. {"RX MIX TX5 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5759. {"RX MIX TX5 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5760. {"RX MIX TX5 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5761. {"RX MIX TX5 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5762. {"RX MIX TX5 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5763. {"RX MIX TX5 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5764. {"RX MIX TX5 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5765. {"RX MIX TX5 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5766. {"RX MIX TX6 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5767. {"RX MIX TX6 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5768. {"RX MIX TX6 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5769. {"RX MIX TX6 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5770. {"RX MIX TX6 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5771. {"RX MIX TX6 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5772. {"RX MIX TX6 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5773. {"RX MIX TX6 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5774. {"RX MIX TX6 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5775. {"RX MIX TX6 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5776. {"RX MIX TX6 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5777. {"RX MIX TX6 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5778. {"RX MIX TX6 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5779. {"RX MIX TX7 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5780. {"RX MIX TX7 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5781. {"RX MIX TX7 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5782. {"RX MIX TX7 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5783. {"RX MIX TX7 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5784. {"RX MIX TX7 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5785. {"RX MIX TX7 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5786. {"RX MIX TX7 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5787. {"RX MIX TX7 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5788. {"RX MIX TX7 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5789. {"RX MIX TX7 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5790. {"RX MIX TX7 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5791. {"RX MIX TX7 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5792. {"RX MIX TX8 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5793. {"RX MIX TX8 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5794. {"RX MIX TX8 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5795. {"RX MIX TX8 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5796. {"RX MIX TX8 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5797. {"RX MIX TX8 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5798. {"RX MIX TX8 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5799. {"RX MIX TX8 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5800. {"RX MIX TX8 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5801. {"RX MIX TX8 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5802. {"RX MIX TX8 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5803. {"RX MIX TX8 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5804. {"RX MIX TX8 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5805. {"ADC US MUX0", "US_Switch", "ADC MUX0"},
  5806. {"ADC US MUX1", "US_Switch", "ADC MUX1"},
  5807. {"ADC US MUX2", "US_Switch", "ADC MUX2"},
  5808. {"ADC US MUX3", "US_Switch", "ADC MUX3"},
  5809. {"ADC US MUX4", "US_Switch", "ADC MUX4"},
  5810. {"ADC US MUX5", "US_Switch", "ADC MUX5"},
  5811. {"ADC US MUX6", "US_Switch", "ADC MUX6"},
  5812. {"ADC US MUX7", "US_Switch", "ADC MUX7"},
  5813. {"ADC US MUX8", "US_Switch", "ADC MUX8"},
  5814. {"ADC MUX0", "DMIC", "DMIC MUX0"},
  5815. {"ADC MUX0", "AMIC", "AMIC MUX0"},
  5816. {"ADC MUX1", "DMIC", "DMIC MUX1"},
  5817. {"ADC MUX1", "AMIC", "AMIC MUX1"},
  5818. {"ADC MUX2", "DMIC", "DMIC MUX2"},
  5819. {"ADC MUX2", "AMIC", "AMIC MUX2"},
  5820. {"ADC MUX3", "DMIC", "DMIC MUX3"},
  5821. {"ADC MUX3", "AMIC", "AMIC MUX3"},
  5822. {"ADC MUX4", "DMIC", "DMIC MUX4"},
  5823. {"ADC MUX4", "AMIC", "AMIC MUX4"},
  5824. {"ADC MUX5", "DMIC", "DMIC MUX5"},
  5825. {"ADC MUX5", "AMIC", "AMIC MUX5"},
  5826. {"ADC MUX6", "DMIC", "DMIC MUX6"},
  5827. {"ADC MUX6", "AMIC", "AMIC MUX6"},
  5828. {"ADC MUX7", "DMIC", "DMIC MUX7"},
  5829. {"ADC MUX7", "AMIC", "AMIC MUX7"},
  5830. {"ADC MUX8", "DMIC", "DMIC MUX8"},
  5831. {"ADC MUX8", "AMIC", "AMIC MUX8"},
  5832. {"ADC MUX10", "DMIC", "DMIC MUX10"},
  5833. {"ADC MUX10", "AMIC", "AMIC MUX10"},
  5834. {"ADC MUX11", "DMIC", "DMIC MUX11"},
  5835. {"ADC MUX11", "AMIC", "AMIC MUX11"},
  5836. {"ADC MUX12", "DMIC", "DMIC MUX12"},
  5837. {"ADC MUX12", "AMIC", "AMIC MUX12"},
  5838. {"ADC MUX13", "DMIC", "DMIC MUX13"},
  5839. {"ADC MUX13", "AMIC", "AMIC MUX13"},
  5840. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX10"},
  5841. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX11"},
  5842. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX12"},
  5843. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX13"},
  5844. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX10"},
  5845. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX11"},
  5846. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX12"},
  5847. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX13"},
  5848. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX10"},
  5849. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX11"},
  5850. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX12"},
  5851. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX13"},
  5852. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX10"},
  5853. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX11"},
  5854. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX12"},
  5855. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX13"},
  5856. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX10"},
  5857. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX11"},
  5858. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX12"},
  5859. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX13"},
  5860. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX10"},
  5861. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX11"},
  5862. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX12"},
  5863. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX13"},
  5864. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX10"},
  5865. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX11"},
  5866. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX12"},
  5867. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX13"},
  5868. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX10"},
  5869. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX11"},
  5870. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX12"},
  5871. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX13"},
  5872. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX10"},
  5873. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX11"},
  5874. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX12"},
  5875. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX13"},
  5876. {"DMIC MUX0", "DMIC0", "DMIC0"},
  5877. {"DMIC MUX0", "DMIC1", "DMIC1"},
  5878. {"DMIC MUX0", "DMIC2", "DMIC2"},
  5879. {"DMIC MUX0", "DMIC3", "DMIC3"},
  5880. {"DMIC MUX0", "DMIC4", "DMIC4"},
  5881. {"DMIC MUX0", "DMIC5", "DMIC5"},
  5882. {"AMIC MUX0", "ADC1", "ADC1"},
  5883. {"AMIC MUX0", "ADC2", "ADC2"},
  5884. {"AMIC MUX0", "ADC3", "ADC3"},
  5885. {"AMIC MUX0", "ADC4", "ADC4"},
  5886. {"AMIC MUX0", "ADC5", "ADC5"},
  5887. {"AMIC MUX0", "ADC6", "ADC6"},
  5888. {"DMIC MUX1", "DMIC0", "DMIC0"},
  5889. {"DMIC MUX1", "DMIC1", "DMIC1"},
  5890. {"DMIC MUX1", "DMIC2", "DMIC2"},
  5891. {"DMIC MUX1", "DMIC3", "DMIC3"},
  5892. {"DMIC MUX1", "DMIC4", "DMIC4"},
  5893. {"DMIC MUX1", "DMIC5", "DMIC5"},
  5894. {"AMIC MUX1", "ADC1", "ADC1"},
  5895. {"AMIC MUX1", "ADC2", "ADC2"},
  5896. {"AMIC MUX1", "ADC3", "ADC3"},
  5897. {"AMIC MUX1", "ADC4", "ADC4"},
  5898. {"AMIC MUX1", "ADC5", "ADC5"},
  5899. {"AMIC MUX1", "ADC6", "ADC6"},
  5900. {"DMIC MUX2", "DMIC0", "DMIC0"},
  5901. {"DMIC MUX2", "DMIC1", "DMIC1"},
  5902. {"DMIC MUX2", "DMIC2", "DMIC2"},
  5903. {"DMIC MUX2", "DMIC3", "DMIC3"},
  5904. {"DMIC MUX2", "DMIC4", "DMIC4"},
  5905. {"DMIC MUX2", "DMIC5", "DMIC5"},
  5906. {"AMIC MUX2", "ADC1", "ADC1"},
  5907. {"AMIC MUX2", "ADC2", "ADC2"},
  5908. {"AMIC MUX2", "ADC3", "ADC3"},
  5909. {"AMIC MUX2", "ADC4", "ADC4"},
  5910. {"AMIC MUX2", "ADC5", "ADC5"},
  5911. {"AMIC MUX2", "ADC6", "ADC6"},
  5912. {"DMIC MUX3", "DMIC0", "DMIC0"},
  5913. {"DMIC MUX3", "DMIC1", "DMIC1"},
  5914. {"DMIC MUX3", "DMIC2", "DMIC2"},
  5915. {"DMIC MUX3", "DMIC3", "DMIC3"},
  5916. {"DMIC MUX3", "DMIC4", "DMIC4"},
  5917. {"DMIC MUX3", "DMIC5", "DMIC5"},
  5918. {"AMIC MUX3", "ADC1", "ADC1"},
  5919. {"AMIC MUX3", "ADC2", "ADC2"},
  5920. {"AMIC MUX3", "ADC3", "ADC3"},
  5921. {"AMIC MUX3", "ADC4", "ADC4"},
  5922. {"AMIC MUX3", "ADC5", "ADC5"},
  5923. {"AMIC MUX3", "ADC6", "ADC6"},
  5924. {"DMIC MUX4", "DMIC0", "DMIC0"},
  5925. {"DMIC MUX4", "DMIC1", "DMIC1"},
  5926. {"DMIC MUX4", "DMIC2", "DMIC2"},
  5927. {"DMIC MUX4", "DMIC3", "DMIC3"},
  5928. {"DMIC MUX4", "DMIC4", "DMIC4"},
  5929. {"DMIC MUX4", "DMIC5", "DMIC5"},
  5930. {"AMIC MUX4", "ADC1", "ADC1"},
  5931. {"AMIC MUX4", "ADC2", "ADC2"},
  5932. {"AMIC MUX4", "ADC3", "ADC3"},
  5933. {"AMIC MUX4", "ADC4", "ADC4"},
  5934. {"AMIC MUX4", "ADC5", "ADC5"},
  5935. {"AMIC MUX4", "ADC6", "ADC6"},
  5936. {"DMIC MUX5", "DMIC0", "DMIC0"},
  5937. {"DMIC MUX5", "DMIC1", "DMIC1"},
  5938. {"DMIC MUX5", "DMIC2", "DMIC2"},
  5939. {"DMIC MUX5", "DMIC3", "DMIC3"},
  5940. {"DMIC MUX5", "DMIC4", "DMIC4"},
  5941. {"DMIC MUX5", "DMIC5", "DMIC5"},
  5942. {"AMIC MUX5", "ADC1", "ADC1"},
  5943. {"AMIC MUX5", "ADC2", "ADC2"},
  5944. {"AMIC MUX5", "ADC3", "ADC3"},
  5945. {"AMIC MUX5", "ADC4", "ADC4"},
  5946. {"AMIC MUX5", "ADC5", "ADC5"},
  5947. {"AMIC MUX5", "ADC6", "ADC6"},
  5948. {"DMIC MUX6", "DMIC0", "DMIC0"},
  5949. {"DMIC MUX6", "DMIC1", "DMIC1"},
  5950. {"DMIC MUX6", "DMIC2", "DMIC2"},
  5951. {"DMIC MUX6", "DMIC3", "DMIC3"},
  5952. {"DMIC MUX6", "DMIC4", "DMIC4"},
  5953. {"DMIC MUX6", "DMIC5", "DMIC5"},
  5954. {"AMIC MUX6", "ADC1", "ADC1"},
  5955. {"AMIC MUX6", "ADC2", "ADC2"},
  5956. {"AMIC MUX6", "ADC3", "ADC3"},
  5957. {"AMIC MUX6", "ADC4", "ADC4"},
  5958. {"AMIC MUX6", "ADC5", "ADC5"},
  5959. {"AMIC MUX6", "ADC6", "ADC6"},
  5960. {"DMIC MUX7", "DMIC0", "DMIC0"},
  5961. {"DMIC MUX7", "DMIC1", "DMIC1"},
  5962. {"DMIC MUX7", "DMIC2", "DMIC2"},
  5963. {"DMIC MUX7", "DMIC3", "DMIC3"},
  5964. {"DMIC MUX7", "DMIC4", "DMIC4"},
  5965. {"DMIC MUX7", "DMIC5", "DMIC5"},
  5966. {"AMIC MUX7", "ADC1", "ADC1"},
  5967. {"AMIC MUX7", "ADC2", "ADC2"},
  5968. {"AMIC MUX7", "ADC3", "ADC3"},
  5969. {"AMIC MUX7", "ADC4", "ADC4"},
  5970. {"AMIC MUX7", "ADC5", "ADC5"},
  5971. {"AMIC MUX7", "ADC6", "ADC6"},
  5972. {"DMIC MUX8", "DMIC0", "DMIC0"},
  5973. {"DMIC MUX8", "DMIC1", "DMIC1"},
  5974. {"DMIC MUX8", "DMIC2", "DMIC2"},
  5975. {"DMIC MUX8", "DMIC3", "DMIC3"},
  5976. {"DMIC MUX8", "DMIC4", "DMIC4"},
  5977. {"DMIC MUX8", "DMIC5", "DMIC5"},
  5978. {"AMIC MUX8", "ADC1", "ADC1"},
  5979. {"AMIC MUX8", "ADC2", "ADC2"},
  5980. {"AMIC MUX8", "ADC3", "ADC3"},
  5981. {"AMIC MUX8", "ADC4", "ADC4"},
  5982. {"AMIC MUX8", "ADC5", "ADC5"},
  5983. {"AMIC MUX8", "ADC6", "ADC6"},
  5984. {"DMIC MUX10", "DMIC0", "DMIC0"},
  5985. {"DMIC MUX10", "DMIC1", "DMIC1"},
  5986. {"DMIC MUX10", "DMIC2", "DMIC2"},
  5987. {"DMIC MUX10", "DMIC3", "DMIC3"},
  5988. {"DMIC MUX10", "DMIC4", "DMIC4"},
  5989. {"DMIC MUX10", "DMIC5", "DMIC5"},
  5990. {"AMIC MUX10", "ADC1", "ADC1"},
  5991. {"AMIC MUX10", "ADC2", "ADC2"},
  5992. {"AMIC MUX10", "ADC3", "ADC3"},
  5993. {"AMIC MUX10", "ADC4", "ADC4"},
  5994. {"AMIC MUX10", "ADC5", "ADC5"},
  5995. {"AMIC MUX10", "ADC6", "ADC6"},
  5996. {"DMIC MUX11", "DMIC0", "DMIC0"},
  5997. {"DMIC MUX11", "DMIC1", "DMIC1"},
  5998. {"DMIC MUX11", "DMIC2", "DMIC2"},
  5999. {"DMIC MUX11", "DMIC3", "DMIC3"},
  6000. {"DMIC MUX11", "DMIC4", "DMIC4"},
  6001. {"DMIC MUX11", "DMIC5", "DMIC5"},
  6002. {"AMIC MUX11", "ADC1", "ADC1"},
  6003. {"AMIC MUX11", "ADC2", "ADC2"},
  6004. {"AMIC MUX11", "ADC3", "ADC3"},
  6005. {"AMIC MUX11", "ADC4", "ADC4"},
  6006. {"AMIC MUX11", "ADC5", "ADC5"},
  6007. {"AMIC MUX11", "ADC6", "ADC6"},
  6008. {"DMIC MUX12", "DMIC0", "DMIC0"},
  6009. {"DMIC MUX12", "DMIC1", "DMIC1"},
  6010. {"DMIC MUX12", "DMIC2", "DMIC2"},
  6011. {"DMIC MUX12", "DMIC3", "DMIC3"},
  6012. {"DMIC MUX12", "DMIC4", "DMIC4"},
  6013. {"DMIC MUX12", "DMIC5", "DMIC5"},
  6014. {"AMIC MUX12", "ADC1", "ADC1"},
  6015. {"AMIC MUX12", "ADC2", "ADC2"},
  6016. {"AMIC MUX12", "ADC3", "ADC3"},
  6017. {"AMIC MUX12", "ADC4", "ADC4"},
  6018. {"AMIC MUX12", "ADC5", "ADC5"},
  6019. {"AMIC MUX12", "ADC6", "ADC6"},
  6020. {"DMIC MUX13", "DMIC0", "DMIC0"},
  6021. {"DMIC MUX13", "DMIC1", "DMIC1"},
  6022. {"DMIC MUX13", "DMIC2", "DMIC2"},
  6023. {"DMIC MUX13", "DMIC3", "DMIC3"},
  6024. {"DMIC MUX13", "DMIC4", "DMIC4"},
  6025. {"DMIC MUX13", "DMIC5", "DMIC5"},
  6026. {"AMIC MUX13", "ADC1", "ADC1"},
  6027. {"AMIC MUX13", "ADC2", "ADC2"},
  6028. {"AMIC MUX13", "ADC3", "ADC3"},
  6029. {"AMIC MUX13", "ADC4", "ADC4"},
  6030. {"AMIC MUX13", "ADC5", "ADC5"},
  6031. {"AMIC MUX13", "ADC6", "ADC6"},
  6032. /* ADC Connections */
  6033. {"ADC1", NULL, "AMIC1"},
  6034. {"ADC2", NULL, "AMIC2"},
  6035. {"ADC3", NULL, "AMIC3"},
  6036. {"ADC4", NULL, "AMIC4"},
  6037. {"ADC5", NULL, "AMIC5"},
  6038. {"ADC6", NULL, "AMIC6"},
  6039. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP0"},
  6040. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP1"},
  6041. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP2"},
  6042. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP0"},
  6043. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP1"},
  6044. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP2"},
  6045. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP0"},
  6046. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP1"},
  6047. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP2"},
  6048. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP0"},
  6049. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP1"},
  6050. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP2"},
  6051. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP0"},
  6052. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP1"},
  6053. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP2"},
  6054. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP0"},
  6055. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP1"},
  6056. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP2"},
  6057. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP0"},
  6058. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP1"},
  6059. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP2"},
  6060. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP0"},
  6061. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP1"},
  6062. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP2"},
  6063. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP0"},
  6064. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP1"},
  6065. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP2"},
  6066. {"RX INT0 SEC MIX", NULL, "RX INT0_1 MIX1"},
  6067. {"RX INT0 MIX2", NULL, "RX INT0 SEC MIX"},
  6068. {"RX INT0 MIX2", NULL, "RX INT0 MIX2 INP"},
  6069. {"RX INT0 INTERP", NULL, "RX INT0 MIX2"},
  6070. {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 INTERP"},
  6071. {"RX INT0 DAC", NULL, "RX INT0 DEM MUX"},
  6072. {"RX INT0 DAC", NULL, "RX_BIAS"},
  6073. {"EAR PA", NULL, "RX INT0 DAC"},
  6074. {"EAR", NULL, "EAR PA"},
  6075. {"SPL SRC0 MUX", "SRC_IN_HPHL", "RX INT1_1 MIX1"},
  6076. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 MIX1"},
  6077. {"RX INT1 SPLINE MIX", "HPHL Switch", "SPL SRC0 MUX"},
  6078. {"RX INT1_1 NATIVE MUX", "ON", "RX INT1_1 MIX1"},
  6079. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 NATIVE MUX"},
  6080. {"RX INT1_1 NATIVE MUX", NULL, "RX INT1 NATIVE SUPPLY"},
  6081. {"RX INT1 SEC MIX", NULL, "RX INT1 SPLINE MIX"},
  6082. {"RX INT1 MIX2", NULL, "RX INT1 SEC MIX"},
  6083. {"RX INT1 MIX2", NULL, "RX INT1 MIX2 INP"},
  6084. {"RX INT1 INTERP", NULL, "RX INT1 MIX2"},
  6085. {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 INTERP"},
  6086. {"RX INT1 DAC", NULL, "RX INT1 DEM MUX"},
  6087. {"RX INT1 DAC", NULL, "RX_BIAS"},
  6088. {"HPHL PA", NULL, "RX INT1 DAC"},
  6089. {"HPHL", NULL, "HPHL PA"},
  6090. {"SPL SRC1 MUX", "SRC_IN_HPHR", "RX INT2_1 MIX1"},
  6091. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 MIX1"},
  6092. {"RX INT2 SPLINE MIX", "HPHR Switch", "SPL SRC1 MUX"},
  6093. {"RX INT2_1 NATIVE MUX", "ON", "RX INT2_1 MIX1"},
  6094. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 NATIVE MUX"},
  6095. {"RX INT2_1 NATIVE MUX", NULL, "RX INT2 NATIVE SUPPLY"},
  6096. {"RX INT2 SEC MIX", NULL, "RX INT2 SPLINE MIX"},
  6097. {"RX INT2 MIX2", NULL, "RX INT2 SEC MIX"},
  6098. {"RX INT2 MIX2", NULL, "RX INT2 MIX2 INP"},
  6099. {"RX INT2 INTERP", NULL, "RX INT2 MIX2"},
  6100. {"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 INTERP"},
  6101. {"RX INT2 DAC", NULL, "RX INT2 DEM MUX"},
  6102. {"RX INT2 DAC", NULL, "RX_BIAS"},
  6103. {"HPHR PA", NULL, "RX INT2 DAC"},
  6104. {"HPHR", NULL, "HPHR PA"},
  6105. {"SPL SRC0 MUX", "SRC_IN_LO1", "RX INT3_1 MIX1"},
  6106. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 MIX1"},
  6107. {"RX INT3 SPLINE MIX", "LO1 Switch", "SPL SRC0 MUX"},
  6108. {"RX INT3_1 NATIVE MUX", "ON", "RX INT3_1 MIX1"},
  6109. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 NATIVE MUX"},
  6110. {"RX INT3_1 NATIVE MUX", NULL, "RX INT3 NATIVE SUPPLY"},
  6111. {"RX INT3 SEC MIX", NULL, "RX INT3 SPLINE MIX"},
  6112. {"RX INT3 MIX2", NULL, "RX INT3 SEC MIX"},
  6113. {"RX INT3 MIX2", NULL, "RX INT3 MIX2 INP"},
  6114. {"RX INT3 INTERP", NULL, "RX INT3 MIX2"},
  6115. {"RX INT3 DAC", NULL, "RX INT3 INTERP"},
  6116. {"RX INT3 DAC", NULL, "RX_BIAS"},
  6117. {"LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6118. {"LINEOUT1", NULL, "LINEOUT1 PA"},
  6119. {"SPL SRC1 MUX", "SRC_IN_LO2", "RX INT4_1 MIX1"},
  6120. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 MIX1"},
  6121. {"RX INT4 SPLINE MIX", "LO2 Switch", "SPL SRC1 MUX"},
  6122. {"RX INT4_1 NATIVE MUX", "ON", "RX INT4_1 MIX1"},
  6123. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 NATIVE MUX"},
  6124. {"RX INT4_1 NATIVE MUX", NULL, "RX INT4 NATIVE SUPPLY"},
  6125. {"RX INT4 SEC MIX", NULL, "RX INT4 SPLINE MIX"},
  6126. {"RX INT4 MIX2", NULL, "RX INT4 SEC MIX"},
  6127. {"RX INT4 MIX2", NULL, "RX INT4 MIX2 INP"},
  6128. {"RX INT4 INTERP", NULL, "RX INT4 MIX2"},
  6129. {"RX INT4 DAC", NULL, "RX INT4 INTERP"},
  6130. {"RX INT4 DAC", NULL, "RX_BIAS"},
  6131. {"LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6132. {"LINEOUT2", NULL, "LINEOUT2 PA"},
  6133. {"SPL SRC2 MUX", "SRC_IN_LO3", "RX INT5_1 MIX1"},
  6134. {"RX INT5 SPLINE MIX", NULL, "RX INT5_1 MIX1"},
  6135. {"RX INT5 SPLINE MIX", "LO3 Switch", "SPL SRC2 MUX"},
  6136. {"RX INT5 SEC MIX", NULL, "RX INT5 SPLINE MIX"},
  6137. {"RX INT5 MIX2", NULL, "RX INT5 SEC MIX"},
  6138. {"RX INT5 INTERP", NULL, "RX INT5 MIX2"},
  6139. {"RX INT5 VBAT", "LO3 VBAT Enable", "RX INT5 INTERP"},
  6140. {"RX INT5 DAC", NULL, "RX INT5 VBAT"},
  6141. {"RX INT5 DAC", NULL, "RX INT5 INTERP"},
  6142. {"RX INT5 DAC", NULL, "RX_BIAS"},
  6143. {"LINEOUT3 PA", NULL, "RX INT5 DAC"},
  6144. {"LINEOUT3", NULL, "LINEOUT3 PA"},
  6145. {"SPL SRC3 MUX", "SRC_IN_LO4", "RX INT6_1 MIX1"},
  6146. {"RX INT6 SPLINE MIX", NULL, "RX INT6_1 MIX1"},
  6147. {"RX INT6 SPLINE MIX", "LO4 Switch", "SPL SRC3 MUX"},
  6148. {"RX INT6 SEC MIX", NULL, "RX INT6 SPLINE MIX"},
  6149. {"RX INT6 MIX2", NULL, "RX INT6 SEC MIX"},
  6150. {"RX INT6 INTERP", NULL, "RX INT6 MIX2"},
  6151. {"RX INT6 VBAT", "LO4 VBAT Enable", "RX INT6 INTERP"},
  6152. {"RX INT6 DAC", NULL, "RX INT6 VBAT"},
  6153. {"RX INT6 DAC", NULL, "RX INT6 INTERP"},
  6154. {"RX INT6 DAC", NULL, "RX_BIAS"},
  6155. {"LINEOUT4 PA", NULL, "RX INT6 DAC"},
  6156. {"LINEOUT4", NULL, "LINEOUT4 PA"},
  6157. {"SPL SRC2 MUX", "SRC_IN_SPKRL", "RX INT7_1 MIX1"},
  6158. {"RX INT7 SPLINE MIX", NULL, "RX INT7_1 MIX1"},
  6159. {"RX INT7 SPLINE MIX", "SPKRL Switch", "SPL SRC2 MUX"},
  6160. {"RX INT7 SEC MIX", NULL, "RX INT7 SPLINE MIX"},
  6161. {"RX INT7 MIX2", NULL, "RX INT7 SEC MIX"},
  6162. {"RX INT7 MIX2", NULL, "RX INT7 MIX2 INP"},
  6163. {"RX INT7 INTERP", NULL, "RX INT7 MIX2"},
  6164. {"RX INT7 VBAT", "SPKRL VBAT Enable", "RX INT7 INTERP"},
  6165. {"RX INT7 CHAIN", NULL, "RX INT7 VBAT"},
  6166. {"RX INT7 CHAIN", NULL, "RX INT7 INTERP"},
  6167. {"RX INT7 CHAIN", NULL, "RX_BIAS"},
  6168. {"SPK1 OUT", NULL, "RX INT7 CHAIN"},
  6169. {"ANC SPKR PA Enable", "Switch", "RX INT7 CHAIN"},
  6170. {"ANC SPK1 PA", NULL, "ANC SPKR PA Enable"},
  6171. {"SPK1 OUT", NULL, "ANC SPK1 PA"},
  6172. {"SPL SRC3 MUX", "SRC_IN_SPKRR", "RX INT8_1 MIX1"},
  6173. {"RX INT8 SPLINE MIX", NULL, "RX INT8_1 MIX1"},
  6174. {"RX INT8 SPLINE MIX", "SPKRR Switch", "SPL SRC3 MUX"},
  6175. {"RX INT8 SEC MIX", NULL, "RX INT8 SPLINE MIX"},
  6176. {"RX INT8 INTERP", NULL, "RX INT8 SEC MIX"},
  6177. {"RX INT8 VBAT", "SPKRR VBAT Enable", "RX INT8 INTERP"},
  6178. {"RX INT8 CHAIN", NULL, "RX INT8 VBAT"},
  6179. {"RX INT8 CHAIN", NULL, "RX INT8 INTERP"},
  6180. {"RX INT8 CHAIN", NULL, "RX_BIAS"},
  6181. {"SPK2 OUT", NULL, "RX INT8 CHAIN"},
  6182. {"ANC0 FB MUX", "ANC_IN_EAR", "RX INT0 MIX2"},
  6183. {"ANC0 FB MUX", "ANC_IN_HPHL", "RX INT1 MIX2"},
  6184. {"ANC0 FB MUX", "ANC_IN_LO1", "RX INT3 MIX2"},
  6185. {"ANC0 FB MUX", "ANC_IN_EAR_SPKR", "RX INT7 MIX2"},
  6186. {"ANC1 FB MUX", "ANC_IN_HPHR", "RX INT2 MIX2"},
  6187. {"ANC1 FB MUX", "ANC_IN_LO2", "RX INT4 MIX2"},
  6188. {"ANC HPHL Enable", "Switch", "ADC MUX10"},
  6189. {"ANC HPHL Enable", "Switch", "ADC MUX11"},
  6190. {"RX INT1 MIX2", NULL, "ANC HPHL Enable"},
  6191. {"ANC HPHR Enable", "Switch", "ADC MUX12"},
  6192. {"ANC HPHR Enable", "Switch", "ADC MUX13"},
  6193. {"RX INT2 MIX2", NULL, "ANC HPHR Enable"},
  6194. {"ANC EAR Enable", "Switch", "ADC MUX10"},
  6195. {"ANC EAR Enable", "Switch", "ADC MUX11"},
  6196. {"RX INT0 MIX2", NULL, "ANC EAR Enable"},
  6197. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX10"},
  6198. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX11"},
  6199. {"RX INT7 MIX2", NULL, "ANC OUT EAR SPKR Enable"},
  6200. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX10"},
  6201. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX11"},
  6202. {"RX INT3 MIX2", NULL, "ANC LINEOUT1 Enable"},
  6203. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX12"},
  6204. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX13"},
  6205. {"RX INT4 MIX2", NULL, "ANC LINEOUT2 Enable"},
  6206. {"ANC EAR PA", NULL, "RX INT0 DAC"},
  6207. {"ANC EAR", NULL, "ANC EAR PA"},
  6208. {"ANC HPHL PA", NULL, "RX INT1 DAC"},
  6209. {"ANC HPHL", NULL, "ANC HPHL PA"},
  6210. {"ANC HPHR PA", NULL, "RX INT2 DAC"},
  6211. {"ANC HPHR", NULL, "ANC HPHR PA"},
  6212. {"ANC LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6213. {"ANC LINEOUT1", NULL, "ANC LINEOUT1 PA"},
  6214. {"ANC LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6215. {"ANC LINEOUT2", NULL, "ANC LINEOUT2 PA"},
  6216. /* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/
  6217. {"SLIM RX0 MUX", "AIF1_PB", "AIF1 PB"},
  6218. {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
  6219. {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
  6220. {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
  6221. {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
  6222. {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
  6223. {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
  6224. {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
  6225. /* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/
  6226. {"SLIM RX0 MUX", "AIF2_PB", "AIF2 PB"},
  6227. {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
  6228. {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
  6229. {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
  6230. {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
  6231. {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
  6232. {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
  6233. {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
  6234. /* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/
  6235. {"SLIM RX0 MUX", "AIF3_PB", "AIF3 PB"},
  6236. {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
  6237. {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
  6238. {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
  6239. {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
  6240. {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
  6241. {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
  6242. {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
  6243. /* SLIM_MUX("AIF4_PB", "AIF4 PB"),*/
  6244. {"SLIM RX0 MUX", "AIF4_PB", "AIF4 PB"},
  6245. {"SLIM RX1 MUX", "AIF4_PB", "AIF4 PB"},
  6246. {"SLIM RX2 MUX", "AIF4_PB", "AIF4 PB"},
  6247. {"SLIM RX3 MUX", "AIF4_PB", "AIF4 PB"},
  6248. {"SLIM RX4 MUX", "AIF4_PB", "AIF4 PB"},
  6249. {"SLIM RX5 MUX", "AIF4_PB", "AIF4 PB"},
  6250. {"SLIM RX6 MUX", "AIF4_PB", "AIF4 PB"},
  6251. {"SLIM RX7 MUX", "AIF4_PB", "AIF4 PB"},
  6252. /* SLIM_MUX("AIF_MIX1_PB", "AIF MIX1 PB"),*/
  6253. {"SLIM RX0 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6254. {"SLIM RX1 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6255. {"SLIM RX2 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6256. {"SLIM RX3 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6257. {"SLIM RX4 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6258. {"SLIM RX5 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6259. {"SLIM RX6 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6260. {"SLIM RX7 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6261. {"SLIM RX0", NULL, "SLIM RX0 MUX"},
  6262. {"SLIM RX1", NULL, "SLIM RX1 MUX"},
  6263. {"SLIM RX2", NULL, "SLIM RX2 MUX"},
  6264. {"SLIM RX3", NULL, "SLIM RX3 MUX"},
  6265. {"SLIM RX4", NULL, "SLIM RX4 MUX"},
  6266. {"SLIM RX5", NULL, "SLIM RX5 MUX"},
  6267. {"SLIM RX6", NULL, "SLIM RX6 MUX"},
  6268. {"SLIM RX7", NULL, "SLIM RX7 MUX"},
  6269. {"RX INT0_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6270. {"RX INT0_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6271. {"RX INT0_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6272. {"RX INT0_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6273. {"RX INT0_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6274. {"RX INT0_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6275. {"RX INT0_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6276. {"RX INT0_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6277. {"RX INT0_1 MIX1 INP0", "IIR0", "IIR0"},
  6278. {"RX INT0_1 MIX1 INP0", "IIR1", "IIR1"},
  6279. {"RX INT0_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6280. {"RX INT0_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6281. {"RX INT0_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6282. {"RX INT0_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6283. {"RX INT0_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6284. {"RX INT0_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6285. {"RX INT0_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6286. {"RX INT0_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6287. {"RX INT0_1 MIX1 INP1", "IIR0", "IIR0"},
  6288. {"RX INT0_1 MIX1 INP1", "IIR1", "IIR1"},
  6289. {"RX INT0_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6290. {"RX INT0_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6291. {"RX INT0_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6292. {"RX INT0_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6293. {"RX INT0_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6294. {"RX INT0_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6295. {"RX INT0_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6296. {"RX INT0_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6297. {"RX INT0_1 MIX1 INP2", "IIR0", "IIR0"},
  6298. {"RX INT0_1 MIX1 INP2", "IIR1", "IIR1"},
  6299. /* MIXing path INT0 */
  6300. {"RX INT0_2 MUX", "RX0", "SLIM RX0"},
  6301. {"RX INT0_2 MUX", "RX1", "SLIM RX1"},
  6302. {"RX INT0_2 MUX", "RX2", "SLIM RX2"},
  6303. {"RX INT0_2 MUX", "RX3", "SLIM RX3"},
  6304. {"RX INT0_2 MUX", "RX4", "SLIM RX4"},
  6305. {"RX INT0_2 MUX", "RX5", "SLIM RX5"},
  6306. {"RX INT0_2 MUX", "RX6", "SLIM RX6"},
  6307. {"RX INT0_2 MUX", "RX7", "SLIM RX7"},
  6308. {"RX INT0 SEC MIX", NULL, "RX INT0_2 MUX"},
  6309. /* MIXing path INT1 */
  6310. {"RX INT1_2 MUX", "RX0", "SLIM RX0"},
  6311. {"RX INT1_2 MUX", "RX1", "SLIM RX1"},
  6312. {"RX INT1_2 MUX", "RX2", "SLIM RX2"},
  6313. {"RX INT1_2 MUX", "RX3", "SLIM RX3"},
  6314. {"RX INT1_2 MUX", "RX4", "SLIM RX4"},
  6315. {"RX INT1_2 MUX", "RX5", "SLIM RX5"},
  6316. {"RX INT1_2 MUX", "RX6", "SLIM RX6"},
  6317. {"RX INT1_2 MUX", "RX7", "SLIM RX7"},
  6318. {"RX INT1 SEC MIX", NULL, "RX INT1_2 MUX"},
  6319. /* MIXing path INT2 */
  6320. {"RX INT2_2 MUX", "RX0", "SLIM RX0"},
  6321. {"RX INT2_2 MUX", "RX1", "SLIM RX1"},
  6322. {"RX INT2_2 MUX", "RX2", "SLIM RX2"},
  6323. {"RX INT2_2 MUX", "RX3", "SLIM RX3"},
  6324. {"RX INT2_2 MUX", "RX4", "SLIM RX4"},
  6325. {"RX INT2_2 MUX", "RX5", "SLIM RX5"},
  6326. {"RX INT2_2 MUX", "RX6", "SLIM RX6"},
  6327. {"RX INT2_2 MUX", "RX7", "SLIM RX7"},
  6328. {"RX INT2 SEC MIX", NULL, "RX INT2_2 MUX"},
  6329. /* MIXing path INT3 */
  6330. {"RX INT3_2 MUX", "RX0", "SLIM RX0"},
  6331. {"RX INT3_2 MUX", "RX1", "SLIM RX1"},
  6332. {"RX INT3_2 MUX", "RX2", "SLIM RX2"},
  6333. {"RX INT3_2 MUX", "RX3", "SLIM RX3"},
  6334. {"RX INT3_2 MUX", "RX4", "SLIM RX4"},
  6335. {"RX INT3_2 MUX", "RX5", "SLIM RX5"},
  6336. {"RX INT3_2 MUX", "RX6", "SLIM RX6"},
  6337. {"RX INT3_2 MUX", "RX7", "SLIM RX7"},
  6338. {"RX INT3 SEC MIX", NULL, "RX INT3_2 MUX"},
  6339. /* MIXing path INT4 */
  6340. {"RX INT4_2 MUX", "RX0", "SLIM RX0"},
  6341. {"RX INT4_2 MUX", "RX1", "SLIM RX1"},
  6342. {"RX INT4_2 MUX", "RX2", "SLIM RX2"},
  6343. {"RX INT4_2 MUX", "RX3", "SLIM RX3"},
  6344. {"RX INT4_2 MUX", "RX4", "SLIM RX4"},
  6345. {"RX INT4_2 MUX", "RX5", "SLIM RX5"},
  6346. {"RX INT4_2 MUX", "RX6", "SLIM RX6"},
  6347. {"RX INT4_2 MUX", "RX7", "SLIM RX7"},
  6348. {"RX INT4 SEC MIX", NULL, "RX INT4_2 MUX"},
  6349. /* MIXing path INT5 */
  6350. {"RX INT5_2 MUX", "RX0", "SLIM RX0"},
  6351. {"RX INT5_2 MUX", "RX1", "SLIM RX1"},
  6352. {"RX INT5_2 MUX", "RX2", "SLIM RX2"},
  6353. {"RX INT5_2 MUX", "RX3", "SLIM RX3"},
  6354. {"RX INT5_2 MUX", "RX4", "SLIM RX4"},
  6355. {"RX INT5_2 MUX", "RX5", "SLIM RX5"},
  6356. {"RX INT5_2 MUX", "RX6", "SLIM RX6"},
  6357. {"RX INT5_2 MUX", "RX7", "SLIM RX7"},
  6358. {"RX INT5 SEC MIX", NULL, "RX INT5_2 MUX"},
  6359. /* MIXing path INT6 */
  6360. {"RX INT6_2 MUX", "RX0", "SLIM RX0"},
  6361. {"RX INT6_2 MUX", "RX1", "SLIM RX1"},
  6362. {"RX INT6_2 MUX", "RX2", "SLIM RX2"},
  6363. {"RX INT6_2 MUX", "RX3", "SLIM RX3"},
  6364. {"RX INT6_2 MUX", "RX4", "SLIM RX4"},
  6365. {"RX INT6_2 MUX", "RX5", "SLIM RX5"},
  6366. {"RX INT6_2 MUX", "RX6", "SLIM RX6"},
  6367. {"RX INT6_2 MUX", "RX7", "SLIM RX7"},
  6368. {"RX INT6 SEC MIX", NULL, "RX INT6_2 MUX"},
  6369. /* MIXing path INT7 */
  6370. {"RX INT7_2 MUX", "RX0", "SLIM RX0"},
  6371. {"RX INT7_2 MUX", "RX1", "SLIM RX1"},
  6372. {"RX INT7_2 MUX", "RX2", "SLIM RX2"},
  6373. {"RX INT7_2 MUX", "RX3", "SLIM RX3"},
  6374. {"RX INT7_2 MUX", "RX4", "SLIM RX4"},
  6375. {"RX INT7_2 MUX", "RX5", "SLIM RX5"},
  6376. {"RX INT7_2 MUX", "RX6", "SLIM RX6"},
  6377. {"RX INT7_2 MUX", "RX7", "SLIM RX7"},
  6378. {"RX INT7 SEC MIX", NULL, "RX INT7_2 MUX"},
  6379. /* MIXing path INT8 */
  6380. {"RX INT8_2 MUX", "RX0", "SLIM RX0"},
  6381. {"RX INT8_2 MUX", "RX1", "SLIM RX1"},
  6382. {"RX INT8_2 MUX", "RX2", "SLIM RX2"},
  6383. {"RX INT8_2 MUX", "RX3", "SLIM RX3"},
  6384. {"RX INT8_2 MUX", "RX4", "SLIM RX4"},
  6385. {"RX INT8_2 MUX", "RX5", "SLIM RX5"},
  6386. {"RX INT8_2 MUX", "RX6", "SLIM RX6"},
  6387. {"RX INT8_2 MUX", "RX7", "SLIM RX7"},
  6388. {"RX INT8 SEC MIX", NULL, "RX INT8_2 MUX"},
  6389. {"RX INT1_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6390. {"RX INT1_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6391. {"RX INT1_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6392. {"RX INT1_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6393. {"RX INT1_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6394. {"RX INT1_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6395. {"RX INT1_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6396. {"RX INT1_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6397. {"RX INT1_1 MIX1 INP0", "IIR0", "IIR0"},
  6398. {"RX INT1_1 MIX1 INP0", "IIR1", "IIR1"},
  6399. {"RX INT1_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6400. {"RX INT1_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6401. {"RX INT1_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6402. {"RX INT1_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6403. {"RX INT1_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6404. {"RX INT1_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6405. {"RX INT1_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6406. {"RX INT1_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6407. {"RX INT1_1 MIX1 INP1", "IIR0", "IIR0"},
  6408. {"RX INT1_1 MIX1 INP1", "IIR1", "IIR1"},
  6409. {"RX INT1_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6410. {"RX INT1_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6411. {"RX INT1_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6412. {"RX INT1_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6413. {"RX INT1_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6414. {"RX INT1_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6415. {"RX INT1_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6416. {"RX INT1_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6417. {"RX INT1_1 MIX1 INP2", "IIR0", "IIR0"},
  6418. {"RX INT1_1 MIX1 INP2", "IIR1", "IIR1"},
  6419. {"RX INT2_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6420. {"RX INT2_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6421. {"RX INT2_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6422. {"RX INT2_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6423. {"RX INT2_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6424. {"RX INT2_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6425. {"RX INT2_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6426. {"RX INT2_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6427. {"RX INT2_1 MIX1 INP0", "IIR0", "IIR0"},
  6428. {"RX INT2_1 MIX1 INP0", "IIR1", "IIR1"},
  6429. {"RX INT2_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6430. {"RX INT2_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6431. {"RX INT2_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6432. {"RX INT2_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6433. {"RX INT2_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6434. {"RX INT2_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6435. {"RX INT2_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6436. {"RX INT2_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6437. {"RX INT2_1 MIX1 INP1", "IIR0", "IIR0"},
  6438. {"RX INT2_1 MIX1 INP1", "IIR1", "IIR1"},
  6439. {"RX INT2_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6440. {"RX INT2_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6441. {"RX INT2_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6442. {"RX INT2_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6443. {"RX INT2_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6444. {"RX INT2_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6445. {"RX INT2_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6446. {"RX INT2_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6447. {"RX INT2_1 MIX1 INP2", "IIR0", "IIR0"},
  6448. {"RX INT2_1 MIX1 INP2", "IIR1", "IIR1"},
  6449. {"RX INT3_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6450. {"RX INT3_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6451. {"RX INT3_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6452. {"RX INT3_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6453. {"RX INT3_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6454. {"RX INT3_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6455. {"RX INT3_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6456. {"RX INT3_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6457. {"RX INT3_1 MIX1 INP0", "IIR0", "IIR0"},
  6458. {"RX INT3_1 MIX1 INP0", "IIR1", "IIR1"},
  6459. {"RX INT3_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6460. {"RX INT3_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6461. {"RX INT3_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6462. {"RX INT3_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6463. {"RX INT3_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6464. {"RX INT3_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6465. {"RX INT3_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6466. {"RX INT3_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6467. {"RX INT3_1 MIX1 INP1", "IIR0", "IIR0"},
  6468. {"RX INT3_1 MIX1 INP1", "IIR1", "IIR1"},
  6469. {"RX INT3_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6470. {"RX INT3_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6471. {"RX INT3_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6472. {"RX INT3_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6473. {"RX INT3_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6474. {"RX INT3_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6475. {"RX INT3_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6476. {"RX INT3_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6477. {"RX INT3_1 MIX1 INP2", "IIR0", "IIR0"},
  6478. {"RX INT3_1 MIX1 INP2", "IIR1", "IIR1"},
  6479. {"RX INT4_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6480. {"RX INT4_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6481. {"RX INT4_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6482. {"RX INT4_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6483. {"RX INT4_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6484. {"RX INT4_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6485. {"RX INT4_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6486. {"RX INT4_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6487. {"RX INT4_1 MIX1 INP0", "IIR0", "IIR0"},
  6488. {"RX INT4_1 MIX1 INP0", "IIR1", "IIR1"},
  6489. {"RX INT4_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6490. {"RX INT4_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6491. {"RX INT4_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6492. {"RX INT4_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6493. {"RX INT4_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6494. {"RX INT4_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6495. {"RX INT4_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6496. {"RX INT4_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6497. {"RX INT4_1 MIX1 INP1", "IIR0", "IIR0"},
  6498. {"RX INT4_1 MIX1 INP1", "IIR1", "IIR1"},
  6499. {"RX INT4_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6500. {"RX INT4_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6501. {"RX INT4_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6502. {"RX INT4_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6503. {"RX INT4_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6504. {"RX INT4_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6505. {"RX INT4_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6506. {"RX INT4_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6507. {"RX INT4_1 MIX1 INP2", "IIR0", "IIR0"},
  6508. {"RX INT4_1 MIX1 INP2", "IIR1", "IIR1"},
  6509. {"RX INT5_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6510. {"RX INT5_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6511. {"RX INT5_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6512. {"RX INT5_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6513. {"RX INT5_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6514. {"RX INT5_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6515. {"RX INT5_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6516. {"RX INT5_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6517. {"RX INT5_1 MIX1 INP0", "IIR0", "IIR0"},
  6518. {"RX INT5_1 MIX1 INP0", "IIR1", "IIR1"},
  6519. {"RX INT5_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6520. {"RX INT5_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6521. {"RX INT5_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6522. {"RX INT5_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6523. {"RX INT5_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6524. {"RX INT5_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6525. {"RX INT5_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6526. {"RX INT5_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6527. {"RX INT5_1 MIX1 INP1", "IIR0", "IIR0"},
  6528. {"RX INT5_1 MIX1 INP1", "IIR1", "IIR1"},
  6529. {"RX INT5_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6530. {"RX INT5_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6531. {"RX INT5_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6532. {"RX INT5_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6533. {"RX INT5_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6534. {"RX INT5_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6535. {"RX INT5_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6536. {"RX INT5_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6537. {"RX INT5_1 MIX1 INP2", "IIR0", "IIR0"},
  6538. {"RX INT5_1 MIX1 INP2", "IIR1", "IIR1"},
  6539. {"RX INT6_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6540. {"RX INT6_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6541. {"RX INT6_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6542. {"RX INT6_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6543. {"RX INT6_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6544. {"RX INT6_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6545. {"RX INT6_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6546. {"RX INT6_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6547. {"RX INT6_1 MIX1 INP0", "IIR0", "IIR0"},
  6548. {"RX INT6_1 MIX1 INP0", "IIR1", "IIR1"},
  6549. {"RX INT6_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6550. {"RX INT6_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6551. {"RX INT6_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6552. {"RX INT6_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6553. {"RX INT6_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6554. {"RX INT6_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6555. {"RX INT6_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6556. {"RX INT6_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6557. {"RX INT6_1 MIX1 INP1", "IIR0", "IIR0"},
  6558. {"RX INT6_1 MIX1 INP1", "IIR1", "IIR1"},
  6559. {"RX INT6_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6560. {"RX INT6_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6561. {"RX INT6_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6562. {"RX INT6_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6563. {"RX INT6_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6564. {"RX INT6_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6565. {"RX INT6_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6566. {"RX INT6_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6567. {"RX INT6_1 MIX1 INP2", "IIR0", "IIR0"},
  6568. {"RX INT6_1 MIX1 INP2", "IIR1", "IIR1"},
  6569. {"RX INT7_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6570. {"RX INT7_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6571. {"RX INT7_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6572. {"RX INT7_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6573. {"RX INT7_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6574. {"RX INT7_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6575. {"RX INT7_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6576. {"RX INT7_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6577. {"RX INT7_1 MIX1 INP0", "IIR0", "IIR0"},
  6578. {"RX INT7_1 MIX1 INP0", "IIR1", "IIR1"},
  6579. {"RX INT7_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6580. {"RX INT7_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6581. {"RX INT7_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6582. {"RX INT7_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6583. {"RX INT7_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6584. {"RX INT7_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6585. {"RX INT7_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6586. {"RX INT7_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6587. {"RX INT7_1 MIX1 INP1", "IIR0", "IIR0"},
  6588. {"RX INT7_1 MIX1 INP1", "IIR1", "IIR1"},
  6589. {"RX INT7_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6590. {"RX INT7_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6591. {"RX INT7_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6592. {"RX INT7_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6593. {"RX INT7_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6594. {"RX INT7_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6595. {"RX INT7_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6596. {"RX INT7_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6597. {"RX INT7_1 MIX1 INP2", "IIR0", "IIR0"},
  6598. {"RX INT7_1 MIX1 INP2", "IIR1", "IIR1"},
  6599. {"RX INT8_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6600. {"RX INT8_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6601. {"RX INT8_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6602. {"RX INT8_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6603. {"RX INT8_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6604. {"RX INT8_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6605. {"RX INT8_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6606. {"RX INT8_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6607. {"RX INT8_1 MIX1 INP0", "IIR0", "IIR0"},
  6608. {"RX INT8_1 MIX1 INP0", "IIR1", "IIR1"},
  6609. {"RX INT8_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6610. {"RX INT8_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6611. {"RX INT8_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6612. {"RX INT8_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6613. {"RX INT8_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6614. {"RX INT8_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6615. {"RX INT8_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6616. {"RX INT8_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6617. {"RX INT8_1 MIX1 INP1", "IIR0", "IIR0"},
  6618. {"RX INT8_1 MIX1 INP1", "IIR1", "IIR1"},
  6619. {"RX INT8_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6620. {"RX INT8_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6621. {"RX INT8_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6622. {"RX INT8_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6623. {"RX INT8_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6624. {"RX INT8_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6625. {"RX INT8_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6626. {"RX INT8_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6627. {"RX INT8_1 MIX1 INP2", "IIR0", "IIR0"},
  6628. {"RX INT8_1 MIX1 INP2", "IIR1", "IIR1"},
  6629. /* SRC0, SRC1 inputs to Sidetone RX Mixer
  6630. * on RX0, RX1, RX2, RX3, RX4 and RX7 chains
  6631. */
  6632. {"IIR0", NULL, "IIR0 INP0 MUX"},
  6633. {"IIR0 INP0 MUX", "DEC0", "ADC MUX0"},
  6634. {"IIR0 INP0 MUX", "DEC1", "ADC MUX1"},
  6635. {"IIR0 INP0 MUX", "DEC2", "ADC MUX2"},
  6636. {"IIR0 INP0 MUX", "DEC3", "ADC MUX3"},
  6637. {"IIR0 INP0 MUX", "DEC4", "ADC MUX4"},
  6638. {"IIR0 INP0 MUX", "DEC5", "ADC MUX5"},
  6639. {"IIR0 INP0 MUX", "DEC6", "ADC MUX6"},
  6640. {"IIR0 INP0 MUX", "DEC7", "ADC MUX7"},
  6641. {"IIR0 INP0 MUX", "DEC8", "ADC MUX8"},
  6642. {"IIR0 INP0 MUX", "RX0", "SLIM RX0"},
  6643. {"IIR0 INP0 MUX", "RX1", "SLIM RX1"},
  6644. {"IIR0 INP0 MUX", "RX2", "SLIM RX2"},
  6645. {"IIR0 INP0 MUX", "RX3", "SLIM RX3"},
  6646. {"IIR0 INP0 MUX", "RX4", "SLIM RX4"},
  6647. {"IIR0 INP0 MUX", "RX5", "SLIM RX5"},
  6648. {"IIR0 INP0 MUX", "RX6", "SLIM RX6"},
  6649. {"IIR0 INP0 MUX", "RX7", "SLIM RX7"},
  6650. {"IIR0", NULL, "IIR0 INP1 MUX"},
  6651. {"IIR0 INP1 MUX", "DEC0", "ADC MUX0"},
  6652. {"IIR0 INP1 MUX", "DEC1", "ADC MUX1"},
  6653. {"IIR0 INP1 MUX", "DEC2", "ADC MUX2"},
  6654. {"IIR0 INP1 MUX", "DEC3", "ADC MUX3"},
  6655. {"IIR0 INP1 MUX", "DEC4", "ADC MUX4"},
  6656. {"IIR0 INP1 MUX", "DEC5", "ADC MUX5"},
  6657. {"IIR0 INP1 MUX", "DEC6", "ADC MUX6"},
  6658. {"IIR0 INP1 MUX", "DEC7", "ADC MUX7"},
  6659. {"IIR0 INP1 MUX", "DEC8", "ADC MUX8"},
  6660. {"IIR0 INP1 MUX", "RX0", "SLIM RX0"},
  6661. {"IIR0 INP1 MUX", "RX1", "SLIM RX1"},
  6662. {"IIR0 INP1 MUX", "RX2", "SLIM RX2"},
  6663. {"IIR0 INP1 MUX", "RX3", "SLIM RX3"},
  6664. {"IIR0 INP1 MUX", "RX4", "SLIM RX4"},
  6665. {"IIR0 INP1 MUX", "RX5", "SLIM RX5"},
  6666. {"IIR0 INP1 MUX", "RX6", "SLIM RX6"},
  6667. {"IIR0 INP1 MUX", "RX7", "SLIM RX7"},
  6668. {"IIR0", NULL, "IIR0 INP2 MUX"},
  6669. {"IIR0 INP2 MUX", "DEC0", "ADC MUX0"},
  6670. {"IIR0 INP2 MUX", "DEC1", "ADC MUX1"},
  6671. {"IIR0 INP2 MUX", "DEC2", "ADC MUX2"},
  6672. {"IIR0 INP2 MUX", "DEC3", "ADC MUX3"},
  6673. {"IIR0 INP2 MUX", "DEC4", "ADC MUX4"},
  6674. {"IIR0 INP2 MUX", "DEC5", "ADC MUX5"},
  6675. {"IIR0 INP2 MUX", "DEC6", "ADC MUX6"},
  6676. {"IIR0 INP2 MUX", "DEC7", "ADC MUX7"},
  6677. {"IIR0 INP2 MUX", "DEC8", "ADC MUX8"},
  6678. {"IIR0 INP2 MUX", "RX0", "SLIM RX0"},
  6679. {"IIR0 INP2 MUX", "RX1", "SLIM RX1"},
  6680. {"IIR0 INP2 MUX", "RX2", "SLIM RX2"},
  6681. {"IIR0 INP2 MUX", "RX3", "SLIM RX3"},
  6682. {"IIR0 INP2 MUX", "RX4", "SLIM RX4"},
  6683. {"IIR0 INP2 MUX", "RX5", "SLIM RX5"},
  6684. {"IIR0 INP2 MUX", "RX6", "SLIM RX6"},
  6685. {"IIR0 INP2 MUX", "RX7", "SLIM RX7"},
  6686. {"IIR0", NULL, "IIR0 INP3 MUX"},
  6687. {"IIR0 INP3 MUX", "DEC0", "ADC MUX0"},
  6688. {"IIR0 INP3 MUX", "DEC1", "ADC MUX1"},
  6689. {"IIR0 INP3 MUX", "DEC2", "ADC MUX2"},
  6690. {"IIR0 INP3 MUX", "DEC3", "ADC MUX3"},
  6691. {"IIR0 INP3 MUX", "DEC4", "ADC MUX4"},
  6692. {"IIR0 INP3 MUX", "DEC5", "ADC MUX5"},
  6693. {"IIR0 INP3 MUX", "DEC6", "ADC MUX6"},
  6694. {"IIR0 INP3 MUX", "DEC7", "ADC MUX7"},
  6695. {"IIR0 INP3 MUX", "DEC8", "ADC MUX8"},
  6696. {"IIR0 INP3 MUX", "RX0", "SLIM RX0"},
  6697. {"IIR0 INP3 MUX", "RX1", "SLIM RX1"},
  6698. {"IIR0 INP3 MUX", "RX2", "SLIM RX2"},
  6699. {"IIR0 INP3 MUX", "RX3", "SLIM RX3"},
  6700. {"IIR0 INP3 MUX", "RX4", "SLIM RX4"},
  6701. {"IIR0 INP3 MUX", "RX5", "SLIM RX5"},
  6702. {"IIR0 INP3 MUX", "RX6", "SLIM RX6"},
  6703. {"IIR0 INP3 MUX", "RX7", "SLIM RX7"},
  6704. {"IIR1", NULL, "IIR1 INP0 MUX"},
  6705. {"IIR1 INP0 MUX", "DEC0", "ADC MUX0"},
  6706. {"IIR1 INP0 MUX", "DEC1", "ADC MUX1"},
  6707. {"IIR1 INP0 MUX", "DEC2", "ADC MUX2"},
  6708. {"IIR1 INP0 MUX", "DEC3", "ADC MUX3"},
  6709. {"IIR1 INP0 MUX", "DEC4", "ADC MUX4"},
  6710. {"IIR1 INP0 MUX", "DEC5", "ADC MUX5"},
  6711. {"IIR1 INP0 MUX", "DEC6", "ADC MUX6"},
  6712. {"IIR1 INP0 MUX", "DEC7", "ADC MUX7"},
  6713. {"IIR1 INP0 MUX", "DEC8", "ADC MUX8"},
  6714. {"IIR1 INP0 MUX", "RX0", "SLIM RX0"},
  6715. {"IIR1 INP0 MUX", "RX1", "SLIM RX1"},
  6716. {"IIR1 INP0 MUX", "RX2", "SLIM RX2"},
  6717. {"IIR1 INP0 MUX", "RX3", "SLIM RX3"},
  6718. {"IIR1 INP0 MUX", "RX4", "SLIM RX4"},
  6719. {"IIR1 INP0 MUX", "RX5", "SLIM RX5"},
  6720. {"IIR1 INP0 MUX", "RX6", "SLIM RX6"},
  6721. {"IIR1 INP0 MUX", "RX7", "SLIM RX7"},
  6722. {"IIR1", NULL, "IIR1 INP1 MUX"},
  6723. {"IIR1 INP1 MUX", "DEC0", "ADC MUX0"},
  6724. {"IIR1 INP1 MUX", "DEC1", "ADC MUX1"},
  6725. {"IIR1 INP1 MUX", "DEC2", "ADC MUX2"},
  6726. {"IIR1 INP1 MUX", "DEC3", "ADC MUX3"},
  6727. {"IIR1 INP1 MUX", "DEC4", "ADC MUX4"},
  6728. {"IIR1 INP1 MUX", "DEC5", "ADC MUX5"},
  6729. {"IIR1 INP1 MUX", "DEC6", "ADC MUX6"},
  6730. {"IIR1 INP1 MUX", "DEC7", "ADC MUX7"},
  6731. {"IIR1 INP1 MUX", "DEC8", "ADC MUX8"},
  6732. {"IIR1 INP1 MUX", "RX0", "SLIM RX0"},
  6733. {"IIR1 INP1 MUX", "RX1", "SLIM RX1"},
  6734. {"IIR1 INP1 MUX", "RX2", "SLIM RX2"},
  6735. {"IIR1 INP1 MUX", "RX3", "SLIM RX3"},
  6736. {"IIR1 INP1 MUX", "RX4", "SLIM RX4"},
  6737. {"IIR1 INP1 MUX", "RX5", "SLIM RX5"},
  6738. {"IIR1 INP1 MUX", "RX6", "SLIM RX6"},
  6739. {"IIR1 INP1 MUX", "RX7", "SLIM RX7"},
  6740. {"IIR1", NULL, "IIR1 INP2 MUX"},
  6741. {"IIR1 INP2 MUX", "DEC0", "ADC MUX0"},
  6742. {"IIR1 INP2 MUX", "DEC1", "ADC MUX1"},
  6743. {"IIR1 INP2 MUX", "DEC2", "ADC MUX2"},
  6744. {"IIR1 INP2 MUX", "DEC3", "ADC MUX3"},
  6745. {"IIR1 INP2 MUX", "DEC4", "ADC MUX4"},
  6746. {"IIR1 INP2 MUX", "DEC5", "ADC MUX5"},
  6747. {"IIR1 INP2 MUX", "DEC6", "ADC MUX6"},
  6748. {"IIR1 INP2 MUX", "DEC7", "ADC MUX7"},
  6749. {"IIR1 INP2 MUX", "DEC8", "ADC MUX8"},
  6750. {"IIR1 INP2 MUX", "RX0", "SLIM RX0"},
  6751. {"IIR1 INP2 MUX", "RX1", "SLIM RX1"},
  6752. {"IIR1 INP2 MUX", "RX2", "SLIM RX2"},
  6753. {"IIR1 INP2 MUX", "RX3", "SLIM RX3"},
  6754. {"IIR1 INP2 MUX", "RX4", "SLIM RX4"},
  6755. {"IIR1 INP2 MUX", "RX5", "SLIM RX5"},
  6756. {"IIR1 INP2 MUX", "RX6", "SLIM RX6"},
  6757. {"IIR1 INP2 MUX", "RX7", "SLIM RX7"},
  6758. {"IIR1", NULL, "IIR1 INP3 MUX"},
  6759. {"IIR1 INP3 MUX", "DEC0", "ADC MUX0"},
  6760. {"IIR1 INP3 MUX", "DEC1", "ADC MUX1"},
  6761. {"IIR1 INP3 MUX", "DEC2", "ADC MUX2"},
  6762. {"IIR1 INP3 MUX", "DEC3", "ADC MUX3"},
  6763. {"IIR1 INP3 MUX", "DEC4", "ADC MUX4"},
  6764. {"IIR1 INP3 MUX", "DEC5", "ADC MUX5"},
  6765. {"IIR1 INP3 MUX", "DEC6", "ADC MUX6"},
  6766. {"IIR1 INP3 MUX", "DEC7", "ADC MUX7"},
  6767. {"IIR1 INP3 MUX", "DEC8", "ADC MUX8"},
  6768. {"IIR1 INP3 MUX", "RX0", "SLIM RX0"},
  6769. {"IIR1 INP3 MUX", "RX1", "SLIM RX1"},
  6770. {"IIR1 INP3 MUX", "RX2", "SLIM RX2"},
  6771. {"IIR1 INP3 MUX", "RX3", "SLIM RX3"},
  6772. {"IIR1 INP3 MUX", "RX4", "SLIM RX4"},
  6773. {"IIR1 INP3 MUX", "RX5", "SLIM RX5"},
  6774. {"IIR1 INP3 MUX", "RX6", "SLIM RX6"},
  6775. {"IIR1 INP3 MUX", "RX7", "SLIM RX7"},
  6776. {"SRC0", NULL, "IIR0"},
  6777. {"SRC1", NULL, "IIR1"},
  6778. {"RX INT0 MIX2 INP", "SRC0", "SRC0"},
  6779. {"RX INT0 MIX2 INP", "SRC1", "SRC1"},
  6780. {"RX INT1 MIX2 INP", "SRC0", "SRC0"},
  6781. {"RX INT1 MIX2 INP", "SRC1", "SRC1"},
  6782. {"RX INT2 MIX2 INP", "SRC0", "SRC0"},
  6783. {"RX INT2 MIX2 INP", "SRC1", "SRC1"},
  6784. {"RX INT3 MIX2 INP", "SRC0", "SRC0"},
  6785. {"RX INT3 MIX2 INP", "SRC1", "SRC1"},
  6786. {"RX INT4 MIX2 INP", "SRC0", "SRC0"},
  6787. {"RX INT4 MIX2 INP", "SRC1", "SRC1"},
  6788. {"RX INT7 MIX2 INP", "SRC0", "SRC0"},
  6789. {"RX INT7 MIX2 INP", "SRC1", "SRC1"},
  6790. };
  6791. static int tasha_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol,
  6792. struct snd_ctl_elem_value *ucontrol)
  6793. {
  6794. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6795. u16 amic_reg;
  6796. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6797. amic_reg = WCD9335_ANA_AMIC1;
  6798. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6799. amic_reg = WCD9335_ANA_AMIC3;
  6800. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6801. amic_reg = WCD9335_ANA_AMIC5;
  6802. ucontrol->value.integer.value[0] =
  6803. (snd_soc_read(codec, amic_reg) & WCD9335_AMIC_PWR_LVL_MASK) >>
  6804. WCD9335_AMIC_PWR_LVL_SHIFT;
  6805. return 0;
  6806. }
  6807. static int tasha_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol,
  6808. struct snd_ctl_elem_value *ucontrol)
  6809. {
  6810. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6811. u32 mode_val;
  6812. u16 amic_reg;
  6813. mode_val = ucontrol->value.enumerated.item[0];
  6814. dev_dbg(codec->dev, "%s: mode: %d\n",
  6815. __func__, mode_val);
  6816. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6817. amic_reg = WCD9335_ANA_AMIC1;
  6818. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6819. amic_reg = WCD9335_ANA_AMIC3;
  6820. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6821. amic_reg = WCD9335_ANA_AMIC5;
  6822. snd_soc_update_bits(codec, amic_reg, WCD9335_AMIC_PWR_LVL_MASK,
  6823. mode_val << WCD9335_AMIC_PWR_LVL_SHIFT);
  6824. return 0;
  6825. }
  6826. static int tasha_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
  6827. struct snd_ctl_elem_value *ucontrol)
  6828. {
  6829. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6830. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6831. ucontrol->value.integer.value[0] = tasha->hph_mode;
  6832. return 0;
  6833. }
  6834. static int tasha_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
  6835. struct snd_ctl_elem_value *ucontrol)
  6836. {
  6837. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6838. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6839. u32 mode_val;
  6840. mode_val = ucontrol->value.enumerated.item[0];
  6841. dev_dbg(codec->dev, "%s: mode: %d\n",
  6842. __func__, mode_val);
  6843. if (mode_val == 0) {
  6844. dev_warn(codec->dev, "%s:Invalid HPH Mode, default to Cls-H HiFi\n",
  6845. __func__);
  6846. mode_val = CLS_H_HIFI;
  6847. }
  6848. tasha->hph_mode = mode_val;
  6849. return 0;
  6850. }
  6851. static const char *const tasha_conn_mad_text[] = {
  6852. "NOTUSED1", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6",
  6853. "NOTUSED2", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4",
  6854. "DMIC5", "NOTUSED3", "NOTUSED4"
  6855. };
  6856. static const struct soc_enum tasha_conn_mad_enum =
  6857. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_conn_mad_text),
  6858. tasha_conn_mad_text);
  6859. static int tasha_enable_ldo_h_get(struct snd_kcontrol *kcontrol,
  6860. struct snd_ctl_elem_value *ucontrol)
  6861. {
  6862. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6863. u8 val = 0;
  6864. if (codec)
  6865. val = snd_soc_read(codec, WCD9335_LDOH_MODE) & 0x80;
  6866. ucontrol->value.integer.value[0] = !!val;
  6867. return 0;
  6868. }
  6869. static int tasha_enable_ldo_h_put(struct snd_kcontrol *kcontrol,
  6870. struct snd_ctl_elem_value *ucontrol)
  6871. {
  6872. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6873. int value = ucontrol->value.integer.value[0];
  6874. bool enable;
  6875. enable = !!value;
  6876. if (codec)
  6877. tasha_codec_enable_standalone_ldo_h(codec, enable);
  6878. return 0;
  6879. }
  6880. static int tasha_mad_input_get(struct snd_kcontrol *kcontrol,
  6881. struct snd_ctl_elem_value *ucontrol)
  6882. {
  6883. u8 tasha_mad_input;
  6884. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6885. tasha_mad_input = snd_soc_read(codec,
  6886. WCD9335_SOC_MAD_INP_SEL) & 0x0F;
  6887. ucontrol->value.integer.value[0] = tasha_mad_input;
  6888. dev_dbg(codec->dev,
  6889. "%s: tasha_mad_input = %s\n", __func__,
  6890. tasha_conn_mad_text[tasha_mad_input]);
  6891. return 0;
  6892. }
  6893. static int tasha_mad_input_put(struct snd_kcontrol *kcontrol,
  6894. struct snd_ctl_elem_value *ucontrol)
  6895. {
  6896. u8 tasha_mad_input;
  6897. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6898. struct snd_soc_card *card = codec->component.card;
  6899. char mad_amic_input_widget[6];
  6900. const char *mad_input_widget;
  6901. const char *source_widget = NULL;
  6902. u32 adc, i, mic_bias_found = 0;
  6903. int ret = 0;
  6904. char *mad_input;
  6905. tasha_mad_input = ucontrol->value.integer.value[0];
  6906. if (tasha_mad_input >= ARRAY_SIZE(tasha_conn_mad_text)) {
  6907. dev_err(codec->dev,
  6908. "%s: tasha_mad_input = %d out of bounds\n",
  6909. __func__, tasha_mad_input);
  6910. return -EINVAL;
  6911. }
  6912. if (!strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED1") ||
  6913. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED2") ||
  6914. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED3") ||
  6915. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED4")) {
  6916. dev_err(codec->dev,
  6917. "%s: Unsupported tasha_mad_input = %s\n",
  6918. __func__, tasha_conn_mad_text[tasha_mad_input]);
  6919. return -EINVAL;
  6920. }
  6921. if (strnstr(tasha_conn_mad_text[tasha_mad_input],
  6922. "ADC", sizeof("ADC"))) {
  6923. mad_input = strpbrk(tasha_conn_mad_text[tasha_mad_input],
  6924. "123456");
  6925. if (!mad_input) {
  6926. dev_err(codec->dev, "%s: Invalid MAD input %s\n",
  6927. __func__,
  6928. tasha_conn_mad_text[tasha_mad_input]);
  6929. return -EINVAL;
  6930. }
  6931. ret = kstrtouint(mad_input, 10, &adc);
  6932. if ((ret < 0) || (adc > 6)) {
  6933. dev_err(codec->dev,
  6934. "%s: Invalid ADC = %s\n", __func__,
  6935. tasha_conn_mad_text[tasha_mad_input]);
  6936. ret = -EINVAL;
  6937. }
  6938. snprintf(mad_amic_input_widget, 6, "%s%u", "AMIC", adc);
  6939. mad_input_widget = mad_amic_input_widget;
  6940. } else {
  6941. /* DMIC type input widget*/
  6942. mad_input_widget = tasha_conn_mad_text[tasha_mad_input];
  6943. }
  6944. dev_dbg(codec->dev,
  6945. "%s: tasha input widget = %s\n", __func__,
  6946. mad_input_widget);
  6947. for (i = 0; i < card->num_of_dapm_routes; i++) {
  6948. if (!strcmp(card->of_dapm_routes[i].sink, mad_input_widget)) {
  6949. source_widget = card->of_dapm_routes[i].source;
  6950. if (!source_widget) {
  6951. dev_err(codec->dev,
  6952. "%s: invalid source widget\n",
  6953. __func__);
  6954. return -EINVAL;
  6955. }
  6956. if (strnstr(source_widget,
  6957. "MIC BIAS1", sizeof("MIC BIAS1"))) {
  6958. mic_bias_found = 1;
  6959. break;
  6960. } else if (strnstr(source_widget,
  6961. "MIC BIAS2", sizeof("MIC BIAS2"))) {
  6962. mic_bias_found = 2;
  6963. break;
  6964. } else if (strnstr(source_widget,
  6965. "MIC BIAS3", sizeof("MIC BIAS3"))) {
  6966. mic_bias_found = 3;
  6967. break;
  6968. } else if (strnstr(source_widget,
  6969. "MIC BIAS4", sizeof("MIC BIAS4"))) {
  6970. mic_bias_found = 4;
  6971. break;
  6972. }
  6973. }
  6974. }
  6975. if (!mic_bias_found) {
  6976. dev_err(codec->dev,
  6977. "%s: mic bias source not found for input = %s\n",
  6978. __func__, mad_input_widget);
  6979. return -EINVAL;
  6980. }
  6981. dev_dbg(codec->dev,
  6982. "%s: mic_bias found = %d\n", __func__,
  6983. mic_bias_found);
  6984. snd_soc_update_bits(codec, WCD9335_SOC_MAD_INP_SEL,
  6985. 0x0F, tasha_mad_input);
  6986. snd_soc_update_bits(codec, WCD9335_ANA_MAD_SETUP,
  6987. 0x07, mic_bias_found);
  6988. return 0;
  6989. }
  6990. static int tasha_pinctl_mode_get(struct snd_kcontrol *kcontrol,
  6991. struct snd_ctl_elem_value *ucontrol)
  6992. {
  6993. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6994. u16 ctl_reg;
  6995. u8 reg_val, pinctl_position;
  6996. pinctl_position = ((struct soc_multi_mixer_control *)
  6997. kcontrol->private_value)->shift;
  6998. switch (pinctl_position >> 3) {
  6999. case 0:
  7000. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7001. break;
  7002. case 1:
  7003. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7004. break;
  7005. case 2:
  7006. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7007. break;
  7008. case 3:
  7009. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7010. break;
  7011. default:
  7012. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7013. __func__, pinctl_position);
  7014. return -EINVAL;
  7015. }
  7016. reg_val = snd_soc_read(codec, ctl_reg);
  7017. reg_val = (reg_val >> (pinctl_position & 0x07)) & 0x1;
  7018. ucontrol->value.integer.value[0] = reg_val;
  7019. return 0;
  7020. }
  7021. static int tasha_pinctl_mode_put(struct snd_kcontrol *kcontrol,
  7022. struct snd_ctl_elem_value *ucontrol)
  7023. {
  7024. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7025. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7026. u16 ctl_reg, cfg_reg;
  7027. u8 ctl_val, cfg_val, pinctl_position, pinctl_mode, mask;
  7028. /* 1- high or low; 0- high Z */
  7029. pinctl_mode = ucontrol->value.integer.value[0];
  7030. pinctl_position = ((struct soc_multi_mixer_control *)
  7031. kcontrol->private_value)->shift;
  7032. switch (pinctl_position >> 3) {
  7033. case 0:
  7034. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7035. break;
  7036. case 1:
  7037. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7038. break;
  7039. case 2:
  7040. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7041. break;
  7042. case 3:
  7043. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7044. break;
  7045. default:
  7046. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7047. __func__, pinctl_position);
  7048. return -EINVAL;
  7049. }
  7050. ctl_val = pinctl_mode << (pinctl_position & 0x07);
  7051. mask = 1 << (pinctl_position & 0x07);
  7052. snd_soc_update_bits(codec, ctl_reg, mask, ctl_val);
  7053. cfg_reg = WCD9335_TLMM_BIST_MODE_PINCFG + pinctl_position;
  7054. if (!pinctl_mode) {
  7055. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  7056. cfg_val = 0x4;
  7057. else
  7058. cfg_val = 0xC;
  7059. } else {
  7060. cfg_val = 0;
  7061. }
  7062. snd_soc_update_bits(codec, cfg_reg, 0x07, cfg_val);
  7063. dev_dbg(codec->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n",
  7064. __func__, ctl_reg, mask, ctl_val, cfg_reg, cfg_val);
  7065. return 0;
  7066. }
  7067. static void wcd_vbat_adc_out_config_2_0(struct wcd_vbat *vbat,
  7068. struct snd_soc_codec *codec)
  7069. {
  7070. u8 val1, val2;
  7071. /*
  7072. * Measure dcp1 by using "ALT" branch of band gap
  7073. * voltage(Vbg) and use it in FAST mode
  7074. */
  7075. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x82, 0x82);
  7076. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7077. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x01);
  7078. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x80);
  7079. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x00);
  7080. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x20);
  7081. /* Wait 100 usec after calibration select as Vbg */
  7082. usleep_range(100, 110);
  7083. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7084. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7085. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7086. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7087. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7088. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x40, 0x40);
  7089. /* Wait 100 usec after selecting Vbg as 1.05V */
  7090. usleep_range(100, 110);
  7091. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7092. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7093. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7094. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7095. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7096. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7097. __func__, vbat->dcp1, vbat->dcp2);
  7098. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7099. /* Wait 100 usec after selecting Vbg as 0.85V */
  7100. usleep_range(100, 110);
  7101. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x00);
  7102. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x20);
  7103. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x00);
  7104. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x00);
  7105. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x00);
  7106. }
  7107. static void wcd_vbat_adc_out_config_1_x(struct wcd_vbat *vbat,
  7108. struct snd_soc_codec *codec)
  7109. {
  7110. u8 val1, val2;
  7111. /*
  7112. * Measure dcp1 by applying band gap voltage(Vbg)
  7113. * of 0.85V
  7114. */
  7115. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x20);
  7116. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7117. snd_soc_write(codec, WCD9335_BIAS_VBG_FINE_ADJ, 0x05);
  7118. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7119. /* Wait 2 sec after enabling band gap bias */
  7120. usleep_range(2000000, 2000100);
  7121. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x82);
  7122. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x87);
  7123. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7124. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0D);
  7125. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01);
  7126. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7127. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xDE);
  7128. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x3C);
  7129. /* Wait 1 msec after calibration select as Vbg */
  7130. usleep_range(1000, 1100);
  7131. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
  7132. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7133. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7134. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7135. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7136. /*
  7137. * Measure dcp2 by applying band gap voltage(Vbg)
  7138. * of 1.05V
  7139. */
  7140. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7141. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7142. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x68);
  7143. /* Wait 2 msec after selecting Vbg as 1.05V */
  7144. usleep_range(2000, 2100);
  7145. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7146. /* Wait 1 sec after enabling band gap bias */
  7147. usleep_range(1000000, 1000100);
  7148. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
  7149. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7150. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7151. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7152. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7153. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7154. __func__, vbat->dcp1, vbat->dcp2);
  7155. /* Reset the Vbat ADC configuration */
  7156. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7157. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7158. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7159. /* Wait 2 msec after selecting Vbg as 0.85V */
  7160. usleep_range(2000, 2100);
  7161. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7162. /* Wait 1 sec after enabling band gap bias */
  7163. usleep_range(1000000, 1000100);
  7164. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x1C);
  7165. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xFE);
  7166. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7167. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7168. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x00);
  7169. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x00);
  7170. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0A);
  7171. }
  7172. static void wcd_vbat_adc_out_config(struct wcd_vbat *vbat,
  7173. struct snd_soc_codec *codec)
  7174. {
  7175. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  7176. if (!vbat->adc_config) {
  7177. tasha_cdc_mclk_enable(codec, true, false);
  7178. if (TASHA_IS_2_0(wcd9xxx))
  7179. wcd_vbat_adc_out_config_2_0(vbat, codec);
  7180. else
  7181. wcd_vbat_adc_out_config_1_x(vbat, codec);
  7182. tasha_cdc_mclk_enable(codec, false, false);
  7183. vbat->adc_config = true;
  7184. }
  7185. }
  7186. static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec)
  7187. {
  7188. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7189. struct firmware_cal *hwdep_cal = NULL;
  7190. struct vbat_monitor_reg *vbat_reg_ptr = NULL;
  7191. const void *data;
  7192. size_t cal_size, vbat_size_remaining;
  7193. int ret = 0, i;
  7194. u32 vbat_writes_size = 0;
  7195. u16 reg;
  7196. u8 mask, val, old_val;
  7197. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_VBAT_CAL);
  7198. if (hwdep_cal) {
  7199. data = hwdep_cal->data;
  7200. cal_size = hwdep_cal->size;
  7201. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7202. __func__);
  7203. } else {
  7204. dev_err(codec->dev, "%s: Vbat cal not received\n",
  7205. __func__);
  7206. ret = -EINVAL;
  7207. goto done;
  7208. }
  7209. if (cal_size < sizeof(*vbat_reg_ptr)) {
  7210. dev_err(codec->dev,
  7211. "%s: Incorrect size %zd for Vbat Cal, expected %zd\n",
  7212. __func__, cal_size, sizeof(*vbat_reg_ptr));
  7213. ret = -EINVAL;
  7214. goto done;
  7215. }
  7216. vbat_reg_ptr = (struct vbat_monitor_reg *) (data);
  7217. if (!vbat_reg_ptr) {
  7218. dev_err(codec->dev,
  7219. "%s: Invalid calibration data for Vbat\n",
  7220. __func__);
  7221. ret = -EINVAL;
  7222. goto done;
  7223. }
  7224. vbat_writes_size = vbat_reg_ptr->size;
  7225. vbat_size_remaining = cal_size - sizeof(u32);
  7226. dev_dbg(codec->dev, "%s: vbat_writes_sz: %d, vbat_sz_remaining: %zd\n",
  7227. __func__, vbat_writes_size, vbat_size_remaining);
  7228. if ((vbat_writes_size * TASHA_PACKED_REG_SIZE)
  7229. > vbat_size_remaining) {
  7230. pr_err("%s: Incorrect Vbat calibration data\n", __func__);
  7231. ret = -EINVAL;
  7232. goto done;
  7233. }
  7234. for (i = 0 ; i < vbat_writes_size; i++) {
  7235. TASHA_CODEC_UNPACK_ENTRY(vbat_reg_ptr->writes[i],
  7236. reg, mask, val);
  7237. old_val = snd_soc_read(codec, reg);
  7238. snd_soc_write(codec, reg, (old_val & ~mask) | (val & mask));
  7239. }
  7240. done:
  7241. return ret;
  7242. }
  7243. static int tasha_vbat_adc_data_get(struct snd_kcontrol *kcontrol,
  7244. struct snd_ctl_elem_value *ucontrol)
  7245. {
  7246. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7247. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7248. wcd_vbat_adc_out_config(&tasha->vbat, codec);
  7249. ucontrol->value.integer.value[0] = tasha->vbat.dcp1;
  7250. ucontrol->value.integer.value[1] = tasha->vbat.dcp2;
  7251. dev_dbg(codec->dev,
  7252. "%s: Vbat ADC output values, Dcp1 : %lu, Dcp2: %lu\n",
  7253. __func__, ucontrol->value.integer.value[0],
  7254. ucontrol->value.integer.value[1]);
  7255. return 0;
  7256. }
  7257. static const char * const tasha_vbat_gsm_mode_text[] = {
  7258. "OFF", "ON"};
  7259. static const struct soc_enum tasha_vbat_gsm_mode_enum =
  7260. SOC_ENUM_SINGLE_EXT(2, tasha_vbat_gsm_mode_text);
  7261. static int tasha_vbat_gsm_mode_func_get(struct snd_kcontrol *kcontrol,
  7262. struct snd_ctl_elem_value *ucontrol)
  7263. {
  7264. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7265. ucontrol->value.integer.value[0] =
  7266. ((snd_soc_read(codec, WCD9335_CDC_VBAT_VBAT_CFG) & 0x04) ?
  7267. 1 : 0);
  7268. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7269. ucontrol->value.integer.value[0]);
  7270. return 0;
  7271. }
  7272. static int tasha_vbat_gsm_mode_func_put(struct snd_kcontrol *kcontrol,
  7273. struct snd_ctl_elem_value *ucontrol)
  7274. {
  7275. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7276. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7277. ucontrol->value.integer.value[0]);
  7278. /* Set Vbat register configuration for GSM mode bit based on value */
  7279. if (ucontrol->value.integer.value[0])
  7280. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7281. 0x04, 0x04);
  7282. else
  7283. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7284. 0x04, 0x00);
  7285. return 0;
  7286. }
  7287. static int tasha_codec_vbat_enable_event(struct snd_soc_dapm_widget *w,
  7288. struct snd_kcontrol *kcontrol,
  7289. int event)
  7290. {
  7291. int ret = 0;
  7292. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7293. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7294. u16 vbat_path_ctl, vbat_cfg, vbat_path_cfg;
  7295. vbat_path_ctl = WCD9335_CDC_VBAT_VBAT_PATH_CTL;
  7296. vbat_cfg = WCD9335_CDC_VBAT_VBAT_CFG;
  7297. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7298. if (!strcmp(w->name, "RX INT8 VBAT"))
  7299. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7300. else if (!strcmp(w->name, "RX INT7 VBAT"))
  7301. vbat_path_cfg = WCD9335_CDC_RX7_RX_PATH_CFG1;
  7302. else if (!strcmp(w->name, "RX INT6 VBAT"))
  7303. vbat_path_cfg = WCD9335_CDC_RX6_RX_PATH_CFG1;
  7304. else if (!strcmp(w->name, "RX INT5 VBAT"))
  7305. vbat_path_cfg = WCD9335_CDC_RX5_RX_PATH_CFG1;
  7306. switch (event) {
  7307. case SND_SOC_DAPM_PRE_PMU:
  7308. ret = tasha_update_vbat_reg_config(codec);
  7309. if (ret) {
  7310. dev_dbg(codec->dev,
  7311. "%s : VBAT isn't calibrated, So not enabling it\n",
  7312. __func__);
  7313. return 0;
  7314. }
  7315. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7316. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x02);
  7317. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x10);
  7318. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x01);
  7319. tasha->vbat.is_enabled = true;
  7320. break;
  7321. case SND_SOC_DAPM_POST_PMD:
  7322. if (tasha->vbat.is_enabled) {
  7323. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x00);
  7324. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x00);
  7325. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x00);
  7326. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7327. tasha->vbat.is_enabled = false;
  7328. }
  7329. break;
  7330. };
  7331. return ret;
  7332. }
  7333. static const char * const rx_hph_mode_mux_text[] = {
  7334. "CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI"
  7335. };
  7336. static const struct soc_enum rx_hph_mode_mux_enum =
  7337. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text),
  7338. rx_hph_mode_mux_text);
  7339. static const char * const amic_pwr_lvl_text[] = {
  7340. "LOW_PWR", "DEFAULT", "HIGH_PERF"
  7341. };
  7342. static const struct soc_enum amic_pwr_lvl_enum =
  7343. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amic_pwr_lvl_text),
  7344. amic_pwr_lvl_text);
  7345. static const struct snd_kcontrol_new tasha_snd_controls[] = {
  7346. SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
  7347. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7348. SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
  7349. 0, -84, 40, digital_gain),
  7350. SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
  7351. 0, -84, 40, digital_gain),
  7352. SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
  7353. 0, -84, 40, digital_gain),
  7354. SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
  7355. 0, -84, 40, digital_gain),
  7356. SOC_SINGLE_SX_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
  7357. 0, -84, 40, digital_gain),
  7358. SOC_SINGLE_SX_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
  7359. 0, -84, 40, digital_gain),
  7360. SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
  7361. 0, -84, 40, digital_gain),
  7362. SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
  7363. 0, -84, 40, digital_gain),
  7364. SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
  7365. WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
  7366. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7367. SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
  7368. WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
  7369. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7370. SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
  7371. WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
  7372. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7373. SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
  7374. WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
  7375. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7376. SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
  7377. WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
  7378. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7379. SOC_SINGLE_SX_TLV("RX5 Mix Digital Volume",
  7380. WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
  7381. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7382. SOC_SINGLE_SX_TLV("RX6 Mix Digital Volume",
  7383. WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
  7384. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7385. SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
  7386. WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
  7387. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7388. SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
  7389. WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
  7390. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7391. SOC_SINGLE_SX_TLV("DEC0 Volume", WCD9335_CDC_TX0_TX_VOL_CTL, 0,
  7392. -84, 40, digital_gain),
  7393. SOC_SINGLE_SX_TLV("DEC1 Volume", WCD9335_CDC_TX1_TX_VOL_CTL, 0,
  7394. -84, 40, digital_gain),
  7395. SOC_SINGLE_SX_TLV("DEC2 Volume", WCD9335_CDC_TX2_TX_VOL_CTL, 0,
  7396. -84, 40, digital_gain),
  7397. SOC_SINGLE_SX_TLV("DEC3 Volume", WCD9335_CDC_TX3_TX_VOL_CTL, 0,
  7398. -84, 40, digital_gain),
  7399. SOC_SINGLE_SX_TLV("DEC4 Volume", WCD9335_CDC_TX4_TX_VOL_CTL, 0,
  7400. -84, 40, digital_gain),
  7401. SOC_SINGLE_SX_TLV("DEC5 Volume", WCD9335_CDC_TX5_TX_VOL_CTL, 0,
  7402. -84, 40, digital_gain),
  7403. SOC_SINGLE_SX_TLV("DEC6 Volume", WCD9335_CDC_TX6_TX_VOL_CTL, 0,
  7404. -84, 40, digital_gain),
  7405. SOC_SINGLE_SX_TLV("DEC7 Volume", WCD9335_CDC_TX7_TX_VOL_CTL, 0,
  7406. -84, 40, digital_gain),
  7407. SOC_SINGLE_SX_TLV("DEC8 Volume", WCD9335_CDC_TX8_TX_VOL_CTL, 0,
  7408. -84, 40, digital_gain),
  7409. SOC_SINGLE_SX_TLV("IIR0 INP0 Volume",
  7410. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, -84,
  7411. 40, digital_gain),
  7412. SOC_SINGLE_SX_TLV("IIR0 INP1 Volume",
  7413. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, -84,
  7414. 40, digital_gain),
  7415. SOC_SINGLE_SX_TLV("IIR0 INP2 Volume",
  7416. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, -84,
  7417. 40, digital_gain),
  7418. SOC_SINGLE_SX_TLV("IIR0 INP3 Volume",
  7419. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, -84,
  7420. 40, digital_gain),
  7421. SOC_SINGLE_SX_TLV("IIR1 INP0 Volume",
  7422. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, -84,
  7423. 40, digital_gain),
  7424. SOC_SINGLE_SX_TLV("IIR1 INP1 Volume",
  7425. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, -84,
  7426. 40, digital_gain),
  7427. SOC_SINGLE_SX_TLV("IIR1 INP2 Volume",
  7428. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, -84,
  7429. 40, digital_gain),
  7430. SOC_SINGLE_SX_TLV("IIR1 INP3 Volume",
  7431. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, -84,
  7432. 40, digital_gain),
  7433. SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 100, 0, tasha_get_anc_slot,
  7434. tasha_put_anc_slot),
  7435. SOC_ENUM_EXT("ANC Function", tasha_anc_func_enum, tasha_get_anc_func,
  7436. tasha_put_anc_func),
  7437. SOC_ENUM_EXT("CLK MODE", tasha_clkmode_enum, tasha_get_clkmode,
  7438. tasha_put_clkmode),
  7439. SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
  7440. SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
  7441. SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
  7442. SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
  7443. SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
  7444. SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
  7445. SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
  7446. SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
  7447. SOC_ENUM("TX8 HPF cut off", cf_dec8_enum),
  7448. SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
  7449. SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
  7450. SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
  7451. SOC_ENUM("RX INT1_2 HPF cut off", cf_int1_2_enum),
  7452. SOC_ENUM("RX INT2_1 HPF cut off", cf_int2_1_enum),
  7453. SOC_ENUM("RX INT2_2 HPF cut off", cf_int2_2_enum),
  7454. SOC_ENUM("RX INT3_1 HPF cut off", cf_int3_1_enum),
  7455. SOC_ENUM("RX INT3_2 HPF cut off", cf_int3_2_enum),
  7456. SOC_ENUM("RX INT4_1 HPF cut off", cf_int4_1_enum),
  7457. SOC_ENUM("RX INT4_2 HPF cut off", cf_int4_2_enum),
  7458. SOC_ENUM("RX INT5_1 HPF cut off", cf_int5_1_enum),
  7459. SOC_ENUM("RX INT5_2 HPF cut off", cf_int5_2_enum),
  7460. SOC_ENUM("RX INT6_1 HPF cut off", cf_int6_1_enum),
  7461. SOC_ENUM("RX INT6_2 HPF cut off", cf_int6_2_enum),
  7462. SOC_ENUM("RX INT7_1 HPF cut off", cf_int7_1_enum),
  7463. SOC_ENUM("RX INT7_2 HPF cut off", cf_int7_2_enum),
  7464. SOC_ENUM("RX INT8_1 HPF cut off", cf_int8_1_enum),
  7465. SOC_ENUM("RX INT8_2 HPF cut off", cf_int8_2_enum),
  7466. SOC_SINGLE_EXT("IIR0 Enable Band1", IIR0, BAND1, 1, 0,
  7467. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7468. SOC_SINGLE_EXT("IIR0 Enable Band2", IIR0, BAND2, 1, 0,
  7469. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7470. SOC_SINGLE_EXT("IIR0 Enable Band3", IIR0, BAND3, 1, 0,
  7471. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7472. SOC_SINGLE_EXT("IIR0 Enable Band4", IIR0, BAND4, 1, 0,
  7473. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7474. SOC_SINGLE_EXT("IIR0 Enable Band5", IIR0, BAND5, 1, 0,
  7475. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7476. SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0,
  7477. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7478. SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
  7479. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7480. SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
  7481. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7482. SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
  7483. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7484. SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
  7485. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7486. SOC_SINGLE_MULTI_EXT("IIR0 Band1", IIR0, BAND1, 255, 0, 5,
  7487. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7488. SOC_SINGLE_MULTI_EXT("IIR0 Band2", IIR0, BAND2, 255, 0, 5,
  7489. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7490. SOC_SINGLE_MULTI_EXT("IIR0 Band3", IIR0, BAND3, 255, 0, 5,
  7491. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7492. SOC_SINGLE_MULTI_EXT("IIR0 Band4", IIR0, BAND4, 255, 0, 5,
  7493. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7494. SOC_SINGLE_MULTI_EXT("IIR0 Band5", IIR0, BAND5, 255, 0, 5,
  7495. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7496. SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
  7497. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7498. SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
  7499. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7500. SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
  7501. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7502. SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
  7503. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7504. SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
  7505. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7506. SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0,
  7507. tasha_get_compander, tasha_set_compander),
  7508. SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0,
  7509. tasha_get_compander, tasha_set_compander),
  7510. SOC_SINGLE_EXT("COMP3 Switch", SND_SOC_NOPM, COMPANDER_3, 1, 0,
  7511. tasha_get_compander, tasha_set_compander),
  7512. SOC_SINGLE_EXT("COMP4 Switch", SND_SOC_NOPM, COMPANDER_4, 1, 0,
  7513. tasha_get_compander, tasha_set_compander),
  7514. SOC_SINGLE_EXT("COMP5 Switch", SND_SOC_NOPM, COMPANDER_5, 1, 0,
  7515. tasha_get_compander, tasha_set_compander),
  7516. SOC_SINGLE_EXT("COMP6 Switch", SND_SOC_NOPM, COMPANDER_6, 1, 0,
  7517. tasha_get_compander, tasha_set_compander),
  7518. SOC_SINGLE_EXT("COMP7 Switch", SND_SOC_NOPM, COMPANDER_7, 1, 0,
  7519. tasha_get_compander, tasha_set_compander),
  7520. SOC_SINGLE_EXT("COMP8 Switch", SND_SOC_NOPM, COMPANDER_8, 1, 0,
  7521. tasha_get_compander, tasha_set_compander),
  7522. SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum,
  7523. tasha_rx_hph_mode_get, tasha_rx_hph_mode_put),
  7524. SOC_ENUM_EXT("MAD Input", tasha_conn_mad_enum,
  7525. tasha_mad_input_get, tasha_mad_input_put),
  7526. SOC_SINGLE_EXT("LDO_H Enable", SND_SOC_NOPM, 0, 1, 0,
  7527. tasha_enable_ldo_h_get, tasha_enable_ldo_h_put),
  7528. SOC_SINGLE_EXT("DMIC1_CLK_PIN_MODE", SND_SOC_NOPM, 17, 1, 0,
  7529. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7530. SOC_SINGLE_EXT("DMIC1_DATA_PIN_MODE", SND_SOC_NOPM, 18, 1, 0,
  7531. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7532. SOC_SINGLE_EXT("DMIC2_CLK_PIN_MODE", SND_SOC_NOPM, 19, 1, 0,
  7533. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7534. SOC_SINGLE_EXT("DMIC2_DATA_PIN_MODE", SND_SOC_NOPM, 20, 1, 0,
  7535. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7536. SOC_SINGLE_EXT("DMIC3_CLK_PIN_MODE", SND_SOC_NOPM, 21, 1, 0,
  7537. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7538. SOC_SINGLE_EXT("DMIC3_DATA_PIN_MODE", SND_SOC_NOPM, 22, 1, 0,
  7539. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7540. SOC_ENUM_EXT("AMIC_1_2 PWR MODE", amic_pwr_lvl_enum,
  7541. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7542. SOC_ENUM_EXT("AMIC_3_4 PWR MODE", amic_pwr_lvl_enum,
  7543. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7544. SOC_ENUM_EXT("AMIC_5_6 PWR MODE", amic_pwr_lvl_enum,
  7545. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7546. SOC_SINGLE_MULTI_EXT("Vbat ADC data", SND_SOC_NOPM, 0, 0xFFFF, 0, 2,
  7547. tasha_vbat_adc_data_get, NULL),
  7548. SOC_ENUM_EXT("GSM mode Enable", tasha_vbat_gsm_mode_enum,
  7549. tasha_vbat_gsm_mode_func_get,
  7550. tasha_vbat_gsm_mode_func_put),
  7551. };
  7552. static int tasha_put_dec_enum(struct snd_kcontrol *kcontrol,
  7553. struct snd_ctl_elem_value *ucontrol)
  7554. {
  7555. struct snd_soc_dapm_widget *widget =
  7556. snd_soc_dapm_kcontrol_widget(kcontrol);
  7557. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7558. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7559. unsigned int val;
  7560. u16 mic_sel_reg;
  7561. u8 mic_sel;
  7562. val = ucontrol->value.enumerated.item[0];
  7563. if (val > e->items - 1)
  7564. return -EINVAL;
  7565. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7566. widget->name, val);
  7567. switch (e->reg) {
  7568. case WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1:
  7569. mic_sel_reg = WCD9335_CDC_TX0_TX_PATH_CFG0;
  7570. break;
  7571. case WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1:
  7572. mic_sel_reg = WCD9335_CDC_TX1_TX_PATH_CFG0;
  7573. break;
  7574. case WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1:
  7575. mic_sel_reg = WCD9335_CDC_TX2_TX_PATH_CFG0;
  7576. break;
  7577. case WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1:
  7578. mic_sel_reg = WCD9335_CDC_TX3_TX_PATH_CFG0;
  7579. break;
  7580. case WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0:
  7581. mic_sel_reg = WCD9335_CDC_TX4_TX_PATH_CFG0;
  7582. break;
  7583. case WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0:
  7584. mic_sel_reg = WCD9335_CDC_TX5_TX_PATH_CFG0;
  7585. break;
  7586. case WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0:
  7587. mic_sel_reg = WCD9335_CDC_TX6_TX_PATH_CFG0;
  7588. break;
  7589. case WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0:
  7590. mic_sel_reg = WCD9335_CDC_TX7_TX_PATH_CFG0;
  7591. break;
  7592. case WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0:
  7593. mic_sel_reg = WCD9335_CDC_TX8_TX_PATH_CFG0;
  7594. break;
  7595. default:
  7596. dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n",
  7597. __func__, e->reg);
  7598. return -EINVAL;
  7599. }
  7600. /* ADC: 0, DMIC: 1 */
  7601. mic_sel = val ? 0x0 : 0x1;
  7602. snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, mic_sel << 7);
  7603. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7604. }
  7605. static int tasha_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol,
  7606. struct snd_ctl_elem_value *ucontrol)
  7607. {
  7608. struct snd_soc_dapm_widget *widget =
  7609. snd_soc_dapm_kcontrol_widget(kcontrol);
  7610. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7611. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7612. unsigned int val;
  7613. unsigned short look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7614. val = ucontrol->value.enumerated.item[0];
  7615. if (val >= e->items)
  7616. return -EINVAL;
  7617. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7618. widget->name, val);
  7619. if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0)
  7620. look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7621. else if (e->reg == WCD9335_CDC_RX1_RX_PATH_SEC0)
  7622. look_ahead_dly_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  7623. else if (e->reg == WCD9335_CDC_RX2_RX_PATH_SEC0)
  7624. look_ahead_dly_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  7625. /* Set Look Ahead Delay */
  7626. snd_soc_update_bits(codec, look_ahead_dly_reg,
  7627. 0x08, (val ? 0x08 : 0x00));
  7628. /* Set DEM INP Select */
  7629. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7630. }
  7631. static int tasha_ear_pa_gain_get(struct snd_kcontrol *kcontrol,
  7632. struct snd_ctl_elem_value *ucontrol)
  7633. {
  7634. u8 ear_pa_gain;
  7635. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7636. ear_pa_gain = snd_soc_read(codec, WCD9335_ANA_EAR);
  7637. ear_pa_gain = (ear_pa_gain & 0x70) >> 4;
  7638. ucontrol->value.integer.value[0] = ear_pa_gain;
  7639. dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__,
  7640. ear_pa_gain);
  7641. return 0;
  7642. }
  7643. static int tasha_ear_pa_gain_put(struct snd_kcontrol *kcontrol,
  7644. struct snd_ctl_elem_value *ucontrol)
  7645. {
  7646. u8 ear_pa_gain;
  7647. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7648. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7649. __func__, ucontrol->value.integer.value[0]);
  7650. ear_pa_gain = ucontrol->value.integer.value[0] << 4;
  7651. snd_soc_update_bits(codec, WCD9335_ANA_EAR, 0x70, ear_pa_gain);
  7652. return 0;
  7653. }
  7654. static int tasha_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
  7655. struct snd_ctl_elem_value *ucontrol)
  7656. {
  7657. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7658. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7659. ucontrol->value.integer.value[0] = tasha->ear_spkr_gain;
  7660. dev_dbg(codec->dev, "%s: ear_spkr_gain = %ld\n", __func__,
  7661. ucontrol->value.integer.value[0]);
  7662. return 0;
  7663. }
  7664. static int tasha_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
  7665. struct snd_ctl_elem_value *ucontrol)
  7666. {
  7667. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7668. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7669. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7670. __func__, ucontrol->value.integer.value[0]);
  7671. tasha->ear_spkr_gain = ucontrol->value.integer.value[0];
  7672. return 0;
  7673. }
  7674. static int tasha_config_compander(struct snd_soc_codec *codec, int interp_n,
  7675. int event)
  7676. {
  7677. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7678. int comp;
  7679. u16 comp_ctl0_reg, rx_path_cfg0_reg;
  7680. /* EAR does not have compander */
  7681. if (!interp_n)
  7682. return 0;
  7683. comp = interp_n - 1;
  7684. dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n",
  7685. __func__, event, comp + 1, tasha->comp_enabled[comp]);
  7686. if (!tasha->comp_enabled[comp])
  7687. return 0;
  7688. comp_ctl0_reg = WCD9335_CDC_COMPANDER1_CTL0 + (comp * 8);
  7689. rx_path_cfg0_reg = WCD9335_CDC_RX1_RX_PATH_CFG0 + (comp * 20);
  7690. if (SND_SOC_DAPM_EVENT_ON(event)) {
  7691. /* Enable Compander Clock */
  7692. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01);
  7693. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7694. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7695. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02);
  7696. }
  7697. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  7698. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04);
  7699. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00);
  7700. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7701. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7702. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00);
  7703. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00);
  7704. }
  7705. return 0;
  7706. }
  7707. static int tasha_codec_config_mad(struct snd_soc_codec *codec)
  7708. {
  7709. int ret = 0;
  7710. int idx;
  7711. const struct firmware *fw;
  7712. struct firmware_cal *hwdep_cal = NULL;
  7713. struct wcd_mad_audio_cal *mad_cal = NULL;
  7714. const void *data;
  7715. const char *filename = TASHA_MAD_AUDIO_FIRMWARE_PATH;
  7716. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7717. size_t cal_size;
  7718. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_MAD_CAL);
  7719. if (hwdep_cal) {
  7720. data = hwdep_cal->data;
  7721. cal_size = hwdep_cal->size;
  7722. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7723. __func__);
  7724. } else {
  7725. ret = request_firmware(&fw, filename, codec->dev);
  7726. if (ret || !fw) {
  7727. dev_err(codec->dev,
  7728. "%s: MAD firmware acquire failed, err = %d\n",
  7729. __func__, ret);
  7730. return -ENODEV;
  7731. }
  7732. data = fw->data;
  7733. cal_size = fw->size;
  7734. dev_dbg(codec->dev, "%s: using request_firmware calibration\n",
  7735. __func__);
  7736. }
  7737. if (cal_size < sizeof(*mad_cal)) {
  7738. dev_err(codec->dev,
  7739. "%s: Incorrect size %zd for MAD Cal, expected %zd\n",
  7740. __func__, cal_size, sizeof(*mad_cal));
  7741. ret = -ENOMEM;
  7742. goto done;
  7743. }
  7744. mad_cal = (struct wcd_mad_audio_cal *) (data);
  7745. if (!mad_cal) {
  7746. dev_err(codec->dev,
  7747. "%s: Invalid calibration data\n",
  7748. __func__);
  7749. ret = -EINVAL;
  7750. goto done;
  7751. }
  7752. snd_soc_write(codec, WCD9335_SOC_MAD_MAIN_CTL_2,
  7753. mad_cal->microphone_info.cycle_time);
  7754. snd_soc_update_bits(codec, WCD9335_SOC_MAD_MAIN_CTL_1, 0xFF << 3,
  7755. ((uint16_t)mad_cal->microphone_info.settle_time)
  7756. << 3);
  7757. /* Audio */
  7758. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_8,
  7759. mad_cal->audio_info.rms_omit_samples);
  7760. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_1,
  7761. 0x07 << 4, mad_cal->audio_info.rms_comp_time << 4);
  7762. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03 << 2,
  7763. mad_cal->audio_info.detection_mechanism << 2);
  7764. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_7,
  7765. mad_cal->audio_info.rms_diff_threshold & 0x3F);
  7766. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_5,
  7767. mad_cal->audio_info.rms_threshold_lsb);
  7768. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_6,
  7769. mad_cal->audio_info.rms_threshold_msb);
  7770. for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients);
  7771. idx++) {
  7772. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR,
  7773. 0x3F, idx);
  7774. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL,
  7775. mad_cal->audio_info.iir_coefficients[idx]);
  7776. dev_dbg(codec->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x",
  7777. __func__, idx,
  7778. mad_cal->audio_info.iir_coefficients[idx]);
  7779. }
  7780. /* Beacon */
  7781. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_8,
  7782. mad_cal->beacon_info.rms_omit_samples);
  7783. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_1,
  7784. 0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4);
  7785. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_2, 0x03 << 2,
  7786. mad_cal->beacon_info.detection_mechanism << 2);
  7787. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_7,
  7788. mad_cal->beacon_info.rms_diff_threshold & 0x1F);
  7789. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_5,
  7790. mad_cal->beacon_info.rms_threshold_lsb);
  7791. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_6,
  7792. mad_cal->beacon_info.rms_threshold_msb);
  7793. for (idx = 0; idx < ARRAY_SIZE(mad_cal->beacon_info.iir_coefficients);
  7794. idx++) {
  7795. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR,
  7796. 0x3F, idx);
  7797. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL,
  7798. mad_cal->beacon_info.iir_coefficients[idx]);
  7799. dev_dbg(codec->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x",
  7800. __func__, idx,
  7801. mad_cal->beacon_info.iir_coefficients[idx]);
  7802. }
  7803. /* Ultrasound */
  7804. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_1,
  7805. 0x07 << 4,
  7806. mad_cal->ultrasound_info.rms_comp_time << 4);
  7807. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_2, 0x03 << 2,
  7808. mad_cal->ultrasound_info.detection_mechanism << 2);
  7809. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_7,
  7810. mad_cal->ultrasound_info.rms_diff_threshold & 0x1F);
  7811. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_5,
  7812. mad_cal->ultrasound_info.rms_threshold_lsb);
  7813. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_6,
  7814. mad_cal->ultrasound_info.rms_threshold_msb);
  7815. done:
  7816. if (!hwdep_cal)
  7817. release_firmware(fw);
  7818. return ret;
  7819. }
  7820. static int tasha_codec_enable_mad(struct snd_soc_dapm_widget *w,
  7821. struct snd_kcontrol *kcontrol, int event)
  7822. {
  7823. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7824. int ret = 0;
  7825. dev_dbg(codec->dev,
  7826. "%s: event = %d\n", __func__, event);
  7827. /* Return if CPE INPUT is DEC1 */
  7828. if (snd_soc_read(codec, WCD9335_CPE_SS_SVA_CFG) & 0x01)
  7829. return ret;
  7830. switch (event) {
  7831. case SND_SOC_DAPM_PRE_PMU:
  7832. /* Turn on MAD clk */
  7833. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7834. 0x01, 0x01);
  7835. /* Undo reset for MAD */
  7836. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7837. 0x02, 0x00);
  7838. ret = tasha_codec_config_mad(codec);
  7839. if (ret)
  7840. dev_err(codec->dev,
  7841. "%s: Failed to config MAD, err = %d\n",
  7842. __func__, ret);
  7843. break;
  7844. case SND_SOC_DAPM_POST_PMD:
  7845. /* Reset the MAD block */
  7846. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7847. 0x02, 0x02);
  7848. /* Turn off MAD clk */
  7849. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7850. 0x01, 0x00);
  7851. break;
  7852. }
  7853. return ret;
  7854. }
  7855. static int tasha_codec_configure_cpe_input(struct snd_soc_dapm_widget *w,
  7856. struct snd_kcontrol *kcontrol, int event)
  7857. {
  7858. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7859. dev_dbg(codec->dev,
  7860. "%s: event = %d\n", __func__, event);
  7861. switch (event) {
  7862. case SND_SOC_DAPM_PRE_PMU:
  7863. /* Configure CPE input as DEC1 */
  7864. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7865. 0x01, 0x01);
  7866. /* Configure DEC1 Tx out with sample rate as 16K */
  7867. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7868. 0x0F, 0x01);
  7869. break;
  7870. case SND_SOC_DAPM_POST_PMD:
  7871. /* Reset DEC1 Tx out sample rate */
  7872. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7873. 0x0F, 0x04);
  7874. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7875. 0x01, 0x00);
  7876. break;
  7877. }
  7878. return 0;
  7879. }
  7880. static int tasha_codec_aif4_mixer_switch_get(struct snd_kcontrol *kcontrol,
  7881. struct snd_ctl_elem_value *ucontrol)
  7882. {
  7883. struct snd_soc_dapm_widget *widget =
  7884. snd_soc_dapm_kcontrol_widget(kcontrol);
  7885. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7886. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7887. if (test_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask))
  7888. ucontrol->value.integer.value[0] = 1;
  7889. else
  7890. ucontrol->value.integer.value[0] = 0;
  7891. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7892. __func__, ucontrol->value.integer.value[0]);
  7893. return 0;
  7894. }
  7895. static int tasha_codec_aif4_mixer_switch_put(struct snd_kcontrol *kcontrol,
  7896. struct snd_ctl_elem_value *ucontrol)
  7897. {
  7898. struct snd_soc_dapm_widget *widget =
  7899. snd_soc_dapm_kcontrol_widget(kcontrol);
  7900. struct snd_soc_dapm_update *update = NULL;
  7901. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7902. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7903. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7904. __func__, ucontrol->value.integer.value[0]);
  7905. if (ucontrol->value.integer.value[0]) {
  7906. snd_soc_dapm_mixer_update_power(widget->dapm,
  7907. kcontrol, 1, update);
  7908. set_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7909. } else {
  7910. snd_soc_dapm_mixer_update_power(widget->dapm,
  7911. kcontrol, 0, update);
  7912. clear_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7913. }
  7914. return 1;
  7915. }
  7916. static const char * const tasha_ear_pa_gain_text[] = {
  7917. "G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB",
  7918. "G_0_DB", "G_M2P5_DB", "UNDEFINED", "G_M12_DB"
  7919. };
  7920. static const char * const tasha_ear_spkr_pa_gain_text[] = {
  7921. "G_DEFAULT", "G_0_DB", "G_1_DB", "G_2_DB", "G_3_DB", "G_4_DB",
  7922. "G_5_DB", "G_6_DB"
  7923. };
  7924. static const struct soc_enum tasha_ear_pa_gain_enum =
  7925. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_pa_gain_text),
  7926. tasha_ear_pa_gain_text);
  7927. static const struct soc_enum tasha_ear_spkr_pa_gain_enum =
  7928. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_spkr_pa_gain_text),
  7929. tasha_ear_spkr_pa_gain_text);
  7930. static const struct snd_kcontrol_new tasha_analog_gain_controls[] = {
  7931. SOC_ENUM_EXT("EAR PA Gain", tasha_ear_pa_gain_enum,
  7932. tasha_ear_pa_gain_get, tasha_ear_pa_gain_put),
  7933. SOC_ENUM_EXT("EAR SPKR PA Gain", tasha_ear_spkr_pa_gain_enum,
  7934. tasha_ear_spkr_pa_gain_get, tasha_ear_spkr_pa_gain_put),
  7935. SOC_SINGLE_TLV("HPHL Volume", WCD9335_HPH_L_EN, 0, 20, 1,
  7936. line_gain),
  7937. SOC_SINGLE_TLV("HPHR Volume", WCD9335_HPH_R_EN, 0, 20, 1,
  7938. line_gain),
  7939. SOC_SINGLE_TLV("LINEOUT1 Volume", WCD9335_DIFF_LO_LO1_COMPANDER,
  7940. 3, 16, 1, line_gain),
  7941. SOC_SINGLE_TLV("LINEOUT2 Volume", WCD9335_DIFF_LO_LO2_COMPANDER,
  7942. 3, 16, 1, line_gain),
  7943. SOC_SINGLE_TLV("LINEOUT3 Volume", WCD9335_SE_LO_LO3_GAIN, 0, 20, 1,
  7944. line_gain),
  7945. SOC_SINGLE_TLV("LINEOUT4 Volume", WCD9335_SE_LO_LO4_GAIN, 0, 20, 1,
  7946. line_gain),
  7947. SOC_SINGLE_TLV("ADC1 Volume", WCD9335_ANA_AMIC1, 0, 20, 0,
  7948. analog_gain),
  7949. SOC_SINGLE_TLV("ADC2 Volume", WCD9335_ANA_AMIC2, 0, 20, 0,
  7950. analog_gain),
  7951. SOC_SINGLE_TLV("ADC3 Volume", WCD9335_ANA_AMIC3, 0, 20, 0,
  7952. analog_gain),
  7953. SOC_SINGLE_TLV("ADC4 Volume", WCD9335_ANA_AMIC4, 0, 20, 0,
  7954. analog_gain),
  7955. SOC_SINGLE_TLV("ADC5 Volume", WCD9335_ANA_AMIC5, 0, 20, 0,
  7956. analog_gain),
  7957. SOC_SINGLE_TLV("ADC6 Volume", WCD9335_ANA_AMIC6, 0, 20, 0,
  7958. analog_gain),
  7959. };
  7960. static const char * const spl_src0_mux_text[] = {
  7961. "ZERO", "SRC_IN_HPHL", "SRC_IN_LO1",
  7962. };
  7963. static const char * const spl_src1_mux_text[] = {
  7964. "ZERO", "SRC_IN_HPHR", "SRC_IN_LO2",
  7965. };
  7966. static const char * const spl_src2_mux_text[] = {
  7967. "ZERO", "SRC_IN_LO3", "SRC_IN_SPKRL",
  7968. };
  7969. static const char * const spl_src3_mux_text[] = {
  7970. "ZERO", "SRC_IN_LO4", "SRC_IN_SPKRR",
  7971. };
  7972. static const char * const rx_int0_7_mix_mux_text[] = {
  7973. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  7974. "RX6", "RX7", "PROXIMITY"
  7975. };
  7976. static const char * const rx_int_mix_mux_text[] = {
  7977. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  7978. "RX6", "RX7"
  7979. };
  7980. static const char * const rx_prim_mix_text[] = {
  7981. "ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2",
  7982. "RX3", "RX4", "RX5", "RX6", "RX7"
  7983. };
  7984. static const char * const rx_sidetone_mix_text[] = {
  7985. "ZERO", "SRC0", "SRC1", "SRC_SUM"
  7986. };
  7987. static const char * const sb_tx0_mux_text[] = {
  7988. "ZERO", "RX_MIX_TX0", "DEC0", "DEC0_192"
  7989. };
  7990. static const char * const sb_tx1_mux_text[] = {
  7991. "ZERO", "RX_MIX_TX1", "DEC1", "DEC1_192"
  7992. };
  7993. static const char * const sb_tx2_mux_text[] = {
  7994. "ZERO", "RX_MIX_TX2", "DEC2", "DEC2_192"
  7995. };
  7996. static const char * const sb_tx3_mux_text[] = {
  7997. "ZERO", "RX_MIX_TX3", "DEC3", "DEC3_192"
  7998. };
  7999. static const char * const sb_tx4_mux_text[] = {
  8000. "ZERO", "RX_MIX_TX4", "DEC4", "DEC4_192"
  8001. };
  8002. static const char * const sb_tx5_mux_text[] = {
  8003. "ZERO", "RX_MIX_TX5", "DEC5", "DEC5_192"
  8004. };
  8005. static const char * const sb_tx6_mux_text[] = {
  8006. "ZERO", "RX_MIX_TX6", "DEC6", "DEC6_192"
  8007. };
  8008. static const char * const sb_tx7_mux_text[] = {
  8009. "ZERO", "RX_MIX_TX7", "DEC7", "DEC7_192"
  8010. };
  8011. static const char * const sb_tx8_mux_text[] = {
  8012. "ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192"
  8013. };
  8014. static const char * const sb_tx9_mux_text[] = {
  8015. "ZERO", "DEC7", "DEC7_192"
  8016. };
  8017. static const char * const sb_tx10_mux_text[] = {
  8018. "ZERO", "DEC6", "DEC6_192"
  8019. };
  8020. static const char * const sb_tx11_mux_text[] = {
  8021. "DEC_0_5", "DEC_9_12", "MAD_AUDIO", "MAD_BRDCST"
  8022. };
  8023. static const char * const sb_tx11_inp1_mux_text[] = {
  8024. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4",
  8025. "DEC5", "RX_MIX_TX5", "DEC9_10", "DEC11_12"
  8026. };
  8027. static const char * const sb_tx13_mux_text[] = {
  8028. "ZERO", "DEC5", "DEC5_192"
  8029. };
  8030. static const char * const tx13_inp_mux_text[] = {
  8031. "CDC_DEC_5", "MAD_BRDCST", "CPE_TX_PP"
  8032. };
  8033. static const char * const iir_inp_mux_text[] = {
  8034. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6",
  8035. "DEC7", "DEC8", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7"
  8036. };
  8037. static const char * const rx_int_dem_inp_mux_text[] = {
  8038. "NORMAL_DSM_OUT", "CLSH_DSM_OUT",
  8039. };
  8040. static const char * const rx_int0_interp_mux_text[] = {
  8041. "ZERO", "RX INT0 MIX2",
  8042. };
  8043. static const char * const rx_int1_interp_mux_text[] = {
  8044. "ZERO", "RX INT1 MIX2",
  8045. };
  8046. static const char * const rx_int2_interp_mux_text[] = {
  8047. "ZERO", "RX INT2 MIX2",
  8048. };
  8049. static const char * const rx_int3_interp_mux_text[] = {
  8050. "ZERO", "RX INT3 MIX2",
  8051. };
  8052. static const char * const rx_int4_interp_mux_text[] = {
  8053. "ZERO", "RX INT4 MIX2",
  8054. };
  8055. static const char * const rx_int5_interp_mux_text[] = {
  8056. "ZERO", "RX INT5 MIX2",
  8057. };
  8058. static const char * const rx_int6_interp_mux_text[] = {
  8059. "ZERO", "RX INT6 MIX2",
  8060. };
  8061. static const char * const rx_int7_interp_mux_text[] = {
  8062. "ZERO", "RX INT7 MIX2",
  8063. };
  8064. static const char * const rx_int8_interp_mux_text[] = {
  8065. "ZERO", "RX INT8 SEC MIX"
  8066. };
  8067. static const char * const mad_sel_text[] = {
  8068. "SPE", "MSM"
  8069. };
  8070. static const char * const adc_mux_text[] = {
  8071. "DMIC", "AMIC", "ANC_FB_TUNE1", "ANC_FB_TUNE2"
  8072. };
  8073. static const char * const dmic_mux_text[] = {
  8074. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8075. "SMIC0", "SMIC1", "SMIC2", "SMIC3"
  8076. };
  8077. static const char * const dmic_mux_alt_text[] = {
  8078. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8079. };
  8080. static const char * const amic_mux_text[] = {
  8081. "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6"
  8082. };
  8083. static const char * const rx_echo_mux_text[] = {
  8084. "ZERO", "RX_MIX0", "RX_MIX1", "RX_MIX2", "RX_MIX3", "RX_MIX4",
  8085. "RX_MIX5", "RX_MIX6", "RX_MIX7", "RX_MIX8", "RX_MIX_VBAT5",
  8086. "RX_MIX_VBAT6", "RX_MIX_VBAT7", "RX_MIX_VBAT8"
  8087. };
  8088. static const char * const anc0_fb_mux_text[] = {
  8089. "ZERO", "ANC_IN_HPHL", "ANC_IN_EAR", "ANC_IN_EAR_SPKR",
  8090. "ANC_IN_LO1"
  8091. };
  8092. static const char * const anc1_fb_mux_text[] = {
  8093. "ZERO", "ANC_IN_HPHR", "ANC_IN_LO2"
  8094. };
  8095. static const char * const native_mux_text[] = {
  8096. "OFF", "ON",
  8097. };
  8098. static const struct soc_enum spl_src0_mux_chain_enum =
  8099. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 0, 3,
  8100. spl_src0_mux_text);
  8101. static const struct soc_enum spl_src1_mux_chain_enum =
  8102. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 2, 3,
  8103. spl_src1_mux_text);
  8104. static const struct soc_enum spl_src2_mux_chain_enum =
  8105. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 4, 3,
  8106. spl_src2_mux_text);
  8107. static const struct soc_enum spl_src3_mux_chain_enum =
  8108. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 6, 3,
  8109. spl_src3_mux_text);
  8110. static const struct soc_enum rx_int0_2_mux_chain_enum =
  8111. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 0, 10,
  8112. rx_int0_7_mix_mux_text);
  8113. static const struct soc_enum rx_int1_2_mux_chain_enum =
  8114. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 0, 9,
  8115. rx_int_mix_mux_text);
  8116. static const struct soc_enum rx_int2_2_mux_chain_enum =
  8117. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 0, 9,
  8118. rx_int_mix_mux_text);
  8119. static const struct soc_enum rx_int3_2_mux_chain_enum =
  8120. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 0, 9,
  8121. rx_int_mix_mux_text);
  8122. static const struct soc_enum rx_int4_2_mux_chain_enum =
  8123. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 0, 9,
  8124. rx_int_mix_mux_text);
  8125. static const struct soc_enum rx_int5_2_mux_chain_enum =
  8126. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 0, 9,
  8127. rx_int_mix_mux_text);
  8128. static const struct soc_enum rx_int6_2_mux_chain_enum =
  8129. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 0, 9,
  8130. rx_int_mix_mux_text);
  8131. static const struct soc_enum rx_int7_2_mux_chain_enum =
  8132. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 0, 10,
  8133. rx_int0_7_mix_mux_text);
  8134. static const struct soc_enum rx_int8_2_mux_chain_enum =
  8135. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 0, 9,
  8136. rx_int_mix_mux_text);
  8137. static const struct soc_enum int1_1_native_enum =
  8138. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8139. native_mux_text);
  8140. static const struct soc_enum int2_1_native_enum =
  8141. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8142. native_mux_text);
  8143. static const struct soc_enum int3_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 int4_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 rx_int0_1_mix_inp0_chain_enum =
  8150. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 0, 13,
  8151. rx_prim_mix_text);
  8152. static const struct soc_enum rx_int0_1_mix_inp1_chain_enum =
  8153. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 4, 13,
  8154. rx_prim_mix_text);
  8155. static const struct soc_enum rx_int0_1_mix_inp2_chain_enum =
  8156. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 4, 13,
  8157. rx_prim_mix_text);
  8158. static const struct soc_enum rx_int1_1_mix_inp0_chain_enum =
  8159. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 0, 13,
  8160. rx_prim_mix_text);
  8161. static const struct soc_enum rx_int1_1_mix_inp1_chain_enum =
  8162. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 4, 13,
  8163. rx_prim_mix_text);
  8164. static const struct soc_enum rx_int1_1_mix_inp2_chain_enum =
  8165. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 4, 13,
  8166. rx_prim_mix_text);
  8167. static const struct soc_enum rx_int2_1_mix_inp0_chain_enum =
  8168. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 0, 13,
  8169. rx_prim_mix_text);
  8170. static const struct soc_enum rx_int2_1_mix_inp1_chain_enum =
  8171. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 4, 13,
  8172. rx_prim_mix_text);
  8173. static const struct soc_enum rx_int2_1_mix_inp2_chain_enum =
  8174. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 4, 13,
  8175. rx_prim_mix_text);
  8176. static const struct soc_enum rx_int3_1_mix_inp0_chain_enum =
  8177. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 0, 13,
  8178. rx_prim_mix_text);
  8179. static const struct soc_enum rx_int3_1_mix_inp1_chain_enum =
  8180. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 4, 13,
  8181. rx_prim_mix_text);
  8182. static const struct soc_enum rx_int3_1_mix_inp2_chain_enum =
  8183. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 4, 13,
  8184. rx_prim_mix_text);
  8185. static const struct soc_enum rx_int4_1_mix_inp0_chain_enum =
  8186. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 0, 13,
  8187. rx_prim_mix_text);
  8188. static const struct soc_enum rx_int4_1_mix_inp1_chain_enum =
  8189. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 4, 13,
  8190. rx_prim_mix_text);
  8191. static const struct soc_enum rx_int4_1_mix_inp2_chain_enum =
  8192. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 4, 13,
  8193. rx_prim_mix_text);
  8194. static const struct soc_enum rx_int5_1_mix_inp0_chain_enum =
  8195. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 0, 13,
  8196. rx_prim_mix_text);
  8197. static const struct soc_enum rx_int5_1_mix_inp1_chain_enum =
  8198. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 4, 13,
  8199. rx_prim_mix_text);
  8200. static const struct soc_enum rx_int5_1_mix_inp2_chain_enum =
  8201. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 4, 13,
  8202. rx_prim_mix_text);
  8203. static const struct soc_enum rx_int6_1_mix_inp0_chain_enum =
  8204. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 0, 13,
  8205. rx_prim_mix_text);
  8206. static const struct soc_enum rx_int6_1_mix_inp1_chain_enum =
  8207. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 4, 13,
  8208. rx_prim_mix_text);
  8209. static const struct soc_enum rx_int6_1_mix_inp2_chain_enum =
  8210. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 4, 13,
  8211. rx_prim_mix_text);
  8212. static const struct soc_enum rx_int7_1_mix_inp0_chain_enum =
  8213. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 0, 13,
  8214. rx_prim_mix_text);
  8215. static const struct soc_enum rx_int7_1_mix_inp1_chain_enum =
  8216. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 4, 13,
  8217. rx_prim_mix_text);
  8218. static const struct soc_enum rx_int7_1_mix_inp2_chain_enum =
  8219. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 4, 13,
  8220. rx_prim_mix_text);
  8221. static const struct soc_enum rx_int8_1_mix_inp0_chain_enum =
  8222. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 0, 13,
  8223. rx_prim_mix_text);
  8224. static const struct soc_enum rx_int8_1_mix_inp1_chain_enum =
  8225. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 4, 13,
  8226. rx_prim_mix_text);
  8227. static const struct soc_enum rx_int8_1_mix_inp2_chain_enum =
  8228. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 4, 13,
  8229. rx_prim_mix_text);
  8230. static const struct soc_enum rx_int0_sidetone_mix_chain_enum =
  8231. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0, 4,
  8232. rx_sidetone_mix_text);
  8233. static const struct soc_enum rx_int1_sidetone_mix_chain_enum =
  8234. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2, 4,
  8235. rx_sidetone_mix_text);
  8236. static const struct soc_enum rx_int2_sidetone_mix_chain_enum =
  8237. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4, 4,
  8238. rx_sidetone_mix_text);
  8239. static const struct soc_enum rx_int3_sidetone_mix_chain_enum =
  8240. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6, 4,
  8241. rx_sidetone_mix_text);
  8242. static const struct soc_enum rx_int4_sidetone_mix_chain_enum =
  8243. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 0, 4,
  8244. rx_sidetone_mix_text);
  8245. static const struct soc_enum rx_int7_sidetone_mix_chain_enum =
  8246. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 2, 4,
  8247. rx_sidetone_mix_text);
  8248. static const struct soc_enum tx_adc_mux0_chain_enum =
  8249. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 0, 4,
  8250. adc_mux_text);
  8251. static const struct soc_enum tx_adc_mux1_chain_enum =
  8252. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 0, 4,
  8253. adc_mux_text);
  8254. static const struct soc_enum tx_adc_mux2_chain_enum =
  8255. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 0, 4,
  8256. adc_mux_text);
  8257. static const struct soc_enum tx_adc_mux3_chain_enum =
  8258. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 0, 4,
  8259. adc_mux_text);
  8260. static const struct soc_enum tx_adc_mux4_chain_enum =
  8261. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 6, 4,
  8262. adc_mux_text);
  8263. static const struct soc_enum tx_adc_mux5_chain_enum =
  8264. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 6, 4,
  8265. adc_mux_text);
  8266. static const struct soc_enum tx_adc_mux6_chain_enum =
  8267. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 6, 4,
  8268. adc_mux_text);
  8269. static const struct soc_enum tx_adc_mux7_chain_enum =
  8270. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 6, 4,
  8271. adc_mux_text);
  8272. static const struct soc_enum tx_adc_mux8_chain_enum =
  8273. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 6, 4,
  8274. adc_mux_text);
  8275. static const struct soc_enum tx_adc_mux10_chain_enum =
  8276. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 6, 4,
  8277. adc_mux_text);
  8278. static const struct soc_enum tx_adc_mux11_chain_enum =
  8279. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 6, 4,
  8280. adc_mux_text);
  8281. static const struct soc_enum tx_adc_mux12_chain_enum =
  8282. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 6, 4,
  8283. adc_mux_text);
  8284. static const struct soc_enum tx_adc_mux13_chain_enum =
  8285. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 6, 4,
  8286. adc_mux_text);
  8287. static const struct soc_enum tx_dmic_mux0_enum =
  8288. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 3, 11,
  8289. dmic_mux_text);
  8290. static const struct soc_enum tx_dmic_mux1_enum =
  8291. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 3, 11,
  8292. dmic_mux_text);
  8293. static const struct soc_enum tx_dmic_mux2_enum =
  8294. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 3, 11,
  8295. dmic_mux_text);
  8296. static const struct soc_enum tx_dmic_mux3_enum =
  8297. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 3, 11,
  8298. dmic_mux_text);
  8299. static const struct soc_enum tx_dmic_mux4_enum =
  8300. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 3, 7,
  8301. dmic_mux_alt_text);
  8302. static const struct soc_enum tx_dmic_mux5_enum =
  8303. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 3, 7,
  8304. dmic_mux_alt_text);
  8305. static const struct soc_enum tx_dmic_mux6_enum =
  8306. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 3, 7,
  8307. dmic_mux_alt_text);
  8308. static const struct soc_enum tx_dmic_mux7_enum =
  8309. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 3, 7,
  8310. dmic_mux_alt_text);
  8311. static const struct soc_enum tx_dmic_mux8_enum =
  8312. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 3, 7,
  8313. dmic_mux_alt_text);
  8314. static const struct soc_enum tx_dmic_mux10_enum =
  8315. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 3, 7,
  8316. dmic_mux_alt_text);
  8317. static const struct soc_enum tx_dmic_mux11_enum =
  8318. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 3, 7,
  8319. dmic_mux_alt_text);
  8320. static const struct soc_enum tx_dmic_mux12_enum =
  8321. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 3, 7,
  8322. dmic_mux_alt_text);
  8323. static const struct soc_enum tx_dmic_mux13_enum =
  8324. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 3, 7,
  8325. dmic_mux_alt_text);
  8326. static const struct soc_enum tx_amic_mux0_enum =
  8327. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 0, 7,
  8328. amic_mux_text);
  8329. static const struct soc_enum tx_amic_mux1_enum =
  8330. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 0, 7,
  8331. amic_mux_text);
  8332. static const struct soc_enum tx_amic_mux2_enum =
  8333. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 0, 7,
  8334. amic_mux_text);
  8335. static const struct soc_enum tx_amic_mux3_enum =
  8336. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 0, 7,
  8337. amic_mux_text);
  8338. static const struct soc_enum tx_amic_mux4_enum =
  8339. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 0, 7,
  8340. amic_mux_text);
  8341. static const struct soc_enum tx_amic_mux5_enum =
  8342. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 0, 7,
  8343. amic_mux_text);
  8344. static const struct soc_enum tx_amic_mux6_enum =
  8345. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 0, 7,
  8346. amic_mux_text);
  8347. static const struct soc_enum tx_amic_mux7_enum =
  8348. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 0, 7,
  8349. amic_mux_text);
  8350. static const struct soc_enum tx_amic_mux8_enum =
  8351. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 0, 7,
  8352. amic_mux_text);
  8353. static const struct soc_enum tx_amic_mux10_enum =
  8354. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 0, 7,
  8355. amic_mux_text);
  8356. static const struct soc_enum tx_amic_mux11_enum =
  8357. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 0, 7,
  8358. amic_mux_text);
  8359. static const struct soc_enum tx_amic_mux12_enum =
  8360. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 0, 7,
  8361. amic_mux_text);
  8362. static const struct soc_enum tx_amic_mux13_enum =
  8363. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 0, 7,
  8364. amic_mux_text);
  8365. static const struct soc_enum sb_tx0_mux_enum =
  8366. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 0, 4,
  8367. sb_tx0_mux_text);
  8368. static const struct soc_enum sb_tx1_mux_enum =
  8369. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 2, 4,
  8370. sb_tx1_mux_text);
  8371. static const struct soc_enum sb_tx2_mux_enum =
  8372. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 4, 4,
  8373. sb_tx2_mux_text);
  8374. static const struct soc_enum sb_tx3_mux_enum =
  8375. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 6, 4,
  8376. sb_tx3_mux_text);
  8377. static const struct soc_enum sb_tx4_mux_enum =
  8378. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 0, 4,
  8379. sb_tx4_mux_text);
  8380. static const struct soc_enum sb_tx5_mux_enum =
  8381. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 2, 4,
  8382. sb_tx5_mux_text);
  8383. static const struct soc_enum sb_tx6_mux_enum =
  8384. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 4, 4,
  8385. sb_tx6_mux_text);
  8386. static const struct soc_enum sb_tx7_mux_enum =
  8387. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 6, 4,
  8388. sb_tx7_mux_text);
  8389. static const struct soc_enum sb_tx8_mux_enum =
  8390. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 0, 4,
  8391. sb_tx8_mux_text);
  8392. static const struct soc_enum sb_tx9_mux_enum =
  8393. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 2, 3,
  8394. sb_tx9_mux_text);
  8395. static const struct soc_enum sb_tx10_mux_enum =
  8396. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 4, 3,
  8397. sb_tx10_mux_text);
  8398. static const struct soc_enum sb_tx11_mux_enum =
  8399. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX11_INP_CFG, 0, 4,
  8400. sb_tx11_mux_text);
  8401. static const struct soc_enum sb_tx11_inp1_mux_enum =
  8402. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 0, 10,
  8403. sb_tx11_inp1_mux_text);
  8404. static const struct soc_enum sb_tx13_mux_enum =
  8405. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 4, 3,
  8406. sb_tx13_mux_text);
  8407. static const struct soc_enum tx13_inp_mux_enum =
  8408. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG, 0, 3,
  8409. tx13_inp_mux_text);
  8410. static const struct soc_enum rx_mix_tx0_mux_enum =
  8411. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 0, 14,
  8412. rx_echo_mux_text);
  8413. static const struct soc_enum rx_mix_tx1_mux_enum =
  8414. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 4, 14,
  8415. rx_echo_mux_text);
  8416. static const struct soc_enum rx_mix_tx2_mux_enum =
  8417. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 0, 14,
  8418. rx_echo_mux_text);
  8419. static const struct soc_enum rx_mix_tx3_mux_enum =
  8420. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 4, 14,
  8421. rx_echo_mux_text);
  8422. static const struct soc_enum rx_mix_tx4_mux_enum =
  8423. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 0, 14,
  8424. rx_echo_mux_text);
  8425. static const struct soc_enum rx_mix_tx5_mux_enum =
  8426. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 4, 14,
  8427. rx_echo_mux_text);
  8428. static const struct soc_enum rx_mix_tx6_mux_enum =
  8429. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 0, 14,
  8430. rx_echo_mux_text);
  8431. static const struct soc_enum rx_mix_tx7_mux_enum =
  8432. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 4, 14,
  8433. rx_echo_mux_text);
  8434. static const struct soc_enum rx_mix_tx8_mux_enum =
  8435. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG4, 0, 14,
  8436. rx_echo_mux_text);
  8437. static const struct soc_enum iir0_inp0_mux_enum =
  8438. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0, 0, 18,
  8439. iir_inp_mux_text);
  8440. static const struct soc_enum iir0_inp1_mux_enum =
  8441. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1, 0, 18,
  8442. iir_inp_mux_text);
  8443. static const struct soc_enum iir0_inp2_mux_enum =
  8444. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2, 0, 18,
  8445. iir_inp_mux_text);
  8446. static const struct soc_enum iir0_inp3_mux_enum =
  8447. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3, 0, 18,
  8448. iir_inp_mux_text);
  8449. static const struct soc_enum iir1_inp0_mux_enum =
  8450. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0, 0, 18,
  8451. iir_inp_mux_text);
  8452. static const struct soc_enum iir1_inp1_mux_enum =
  8453. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1, 0, 18,
  8454. iir_inp_mux_text);
  8455. static const struct soc_enum iir1_inp2_mux_enum =
  8456. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2, 0, 18,
  8457. iir_inp_mux_text);
  8458. static const struct soc_enum iir1_inp3_mux_enum =
  8459. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3, 0, 18,
  8460. iir_inp_mux_text);
  8461. static const struct soc_enum rx_int0_dem_inp_mux_enum =
  8462. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_SEC0, 0,
  8463. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8464. rx_int_dem_inp_mux_text);
  8465. static const struct soc_enum rx_int1_dem_inp_mux_enum =
  8466. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_SEC0, 0,
  8467. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8468. rx_int_dem_inp_mux_text);
  8469. static const struct soc_enum rx_int2_dem_inp_mux_enum =
  8470. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_SEC0, 0,
  8471. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8472. rx_int_dem_inp_mux_text);
  8473. static const struct soc_enum rx_int0_interp_mux_enum =
  8474. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CTL, 5, 2,
  8475. rx_int0_interp_mux_text);
  8476. static const struct soc_enum rx_int1_interp_mux_enum =
  8477. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CTL, 5, 2,
  8478. rx_int1_interp_mux_text);
  8479. static const struct soc_enum rx_int2_interp_mux_enum =
  8480. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CTL, 5, 2,
  8481. rx_int2_interp_mux_text);
  8482. static const struct soc_enum rx_int3_interp_mux_enum =
  8483. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CTL, 5, 2,
  8484. rx_int3_interp_mux_text);
  8485. static const struct soc_enum rx_int4_interp_mux_enum =
  8486. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CTL, 5, 2,
  8487. rx_int4_interp_mux_text);
  8488. static const struct soc_enum rx_int5_interp_mux_enum =
  8489. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CTL, 5, 2,
  8490. rx_int5_interp_mux_text);
  8491. static const struct soc_enum rx_int6_interp_mux_enum =
  8492. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CTL, 5, 2,
  8493. rx_int6_interp_mux_text);
  8494. static const struct soc_enum rx_int7_interp_mux_enum =
  8495. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CTL, 5, 2,
  8496. rx_int7_interp_mux_text);
  8497. static const struct soc_enum rx_int8_interp_mux_enum =
  8498. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CTL, 5, 2,
  8499. rx_int8_interp_mux_text);
  8500. static const struct soc_enum mad_sel_enum =
  8501. SOC_ENUM_SINGLE(WCD9335_CPE_SS_CFG, 0, 2, mad_sel_text);
  8502. static const struct soc_enum anc0_fb_mux_enum =
  8503. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 0, 5,
  8504. anc0_fb_mux_text);
  8505. static const struct soc_enum anc1_fb_mux_enum =
  8506. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 3, 3,
  8507. anc1_fb_mux_text);
  8508. static const struct snd_kcontrol_new rx_int0_dem_inp_mux =
  8509. SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum,
  8510. snd_soc_dapm_get_enum_double,
  8511. tasha_int_dem_inp_mux_put);
  8512. static const struct snd_kcontrol_new rx_int1_dem_inp_mux =
  8513. SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum,
  8514. snd_soc_dapm_get_enum_double,
  8515. tasha_int_dem_inp_mux_put);
  8516. static const struct snd_kcontrol_new rx_int2_dem_inp_mux =
  8517. SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum,
  8518. snd_soc_dapm_get_enum_double,
  8519. tasha_int_dem_inp_mux_put);
  8520. static const struct snd_kcontrol_new spl_src0_mux =
  8521. SOC_DAPM_ENUM("SPL SRC0 MUX Mux", spl_src0_mux_chain_enum);
  8522. static const struct snd_kcontrol_new spl_src1_mux =
  8523. SOC_DAPM_ENUM("SPL SRC1 MUX Mux", spl_src1_mux_chain_enum);
  8524. static const struct snd_kcontrol_new spl_src2_mux =
  8525. SOC_DAPM_ENUM("SPL SRC2 MUX Mux", spl_src2_mux_chain_enum);
  8526. static const struct snd_kcontrol_new spl_src3_mux =
  8527. SOC_DAPM_ENUM("SPL SRC3 MUX Mux", spl_src3_mux_chain_enum);
  8528. static const struct snd_kcontrol_new rx_int0_2_mux =
  8529. SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum);
  8530. static const struct snd_kcontrol_new rx_int1_2_mux =
  8531. SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum);
  8532. static const struct snd_kcontrol_new rx_int2_2_mux =
  8533. SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum);
  8534. static const struct snd_kcontrol_new rx_int3_2_mux =
  8535. SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum);
  8536. static const struct snd_kcontrol_new rx_int4_2_mux =
  8537. SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum);
  8538. static const struct snd_kcontrol_new rx_int5_2_mux =
  8539. SOC_DAPM_ENUM("RX INT5_2 MUX Mux", rx_int5_2_mux_chain_enum);
  8540. static const struct snd_kcontrol_new rx_int6_2_mux =
  8541. SOC_DAPM_ENUM("RX INT6_2 MUX Mux", rx_int6_2_mux_chain_enum);
  8542. static const struct snd_kcontrol_new rx_int7_2_mux =
  8543. SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum);
  8544. static const struct snd_kcontrol_new rx_int8_2_mux =
  8545. SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum);
  8546. static const struct snd_kcontrol_new int1_1_native_mux =
  8547. SOC_DAPM_ENUM("RX INT1_1 NATIVE MUX Mux", int1_1_native_enum);
  8548. static const struct snd_kcontrol_new int2_1_native_mux =
  8549. SOC_DAPM_ENUM("RX INT2_1 NATIVE MUX Mux", int2_1_native_enum);
  8550. static const struct snd_kcontrol_new int3_1_native_mux =
  8551. SOC_DAPM_ENUM("RX INT3_1 NATIVE MUX Mux", int3_1_native_enum);
  8552. static const struct snd_kcontrol_new int4_1_native_mux =
  8553. SOC_DAPM_ENUM("RX INT4_1 NATIVE MUX Mux", int4_1_native_enum);
  8554. static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux =
  8555. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum);
  8556. static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux =
  8557. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum);
  8558. static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux =
  8559. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum);
  8560. static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux =
  8561. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum);
  8562. static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux =
  8563. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum);
  8564. static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux =
  8565. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum);
  8566. static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux =
  8567. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum);
  8568. static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux =
  8569. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum);
  8570. static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux =
  8571. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum);
  8572. static const struct snd_kcontrol_new rx_int3_1_mix_inp0_mux =
  8573. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum);
  8574. static const struct snd_kcontrol_new rx_int3_1_mix_inp1_mux =
  8575. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum);
  8576. static const struct snd_kcontrol_new rx_int3_1_mix_inp2_mux =
  8577. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum);
  8578. static const struct snd_kcontrol_new rx_int4_1_mix_inp0_mux =
  8579. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum);
  8580. static const struct snd_kcontrol_new rx_int4_1_mix_inp1_mux =
  8581. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum);
  8582. static const struct snd_kcontrol_new rx_int4_1_mix_inp2_mux =
  8583. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum);
  8584. static const struct snd_kcontrol_new rx_int5_1_mix_inp0_mux =
  8585. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP0 Mux", rx_int5_1_mix_inp0_chain_enum);
  8586. static const struct snd_kcontrol_new rx_int5_1_mix_inp1_mux =
  8587. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP1 Mux", rx_int5_1_mix_inp1_chain_enum);
  8588. static const struct snd_kcontrol_new rx_int5_1_mix_inp2_mux =
  8589. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP2 Mux", rx_int5_1_mix_inp2_chain_enum);
  8590. static const struct snd_kcontrol_new rx_int6_1_mix_inp0_mux =
  8591. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP0 Mux", rx_int6_1_mix_inp0_chain_enum);
  8592. static const struct snd_kcontrol_new rx_int6_1_mix_inp1_mux =
  8593. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP1 Mux", rx_int6_1_mix_inp1_chain_enum);
  8594. static const struct snd_kcontrol_new rx_int6_1_mix_inp2_mux =
  8595. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP2 Mux", rx_int6_1_mix_inp2_chain_enum);
  8596. static const struct snd_kcontrol_new rx_int7_1_mix_inp0_mux =
  8597. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum);
  8598. static const struct snd_kcontrol_new rx_int7_1_mix_inp1_mux =
  8599. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum);
  8600. static const struct snd_kcontrol_new rx_int7_1_mix_inp2_mux =
  8601. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum);
  8602. static const struct snd_kcontrol_new rx_int8_1_mix_inp0_mux =
  8603. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum);
  8604. static const struct snd_kcontrol_new rx_int8_1_mix_inp1_mux =
  8605. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum);
  8606. static const struct snd_kcontrol_new rx_int8_1_mix_inp2_mux =
  8607. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum);
  8608. static const struct snd_kcontrol_new rx_int0_mix2_inp_mux =
  8609. SOC_DAPM_ENUM("RX INT0 MIX2 INP Mux", rx_int0_sidetone_mix_chain_enum);
  8610. static const struct snd_kcontrol_new rx_int1_mix2_inp_mux =
  8611. SOC_DAPM_ENUM("RX INT1 MIX2 INP Mux", rx_int1_sidetone_mix_chain_enum);
  8612. static const struct snd_kcontrol_new rx_int2_mix2_inp_mux =
  8613. SOC_DAPM_ENUM("RX INT2 MIX2 INP Mux", rx_int2_sidetone_mix_chain_enum);
  8614. static const struct snd_kcontrol_new rx_int3_mix2_inp_mux =
  8615. SOC_DAPM_ENUM("RX INT3 MIX2 INP Mux", rx_int3_sidetone_mix_chain_enum);
  8616. static const struct snd_kcontrol_new rx_int4_mix2_inp_mux =
  8617. SOC_DAPM_ENUM("RX INT4 MIX2 INP Mux", rx_int4_sidetone_mix_chain_enum);
  8618. static const struct snd_kcontrol_new rx_int7_mix2_inp_mux =
  8619. SOC_DAPM_ENUM("RX INT7 MIX2 INP Mux", rx_int7_sidetone_mix_chain_enum);
  8620. static const struct snd_kcontrol_new tx_adc_mux0 =
  8621. SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_chain_enum,
  8622. snd_soc_dapm_get_enum_double,
  8623. tasha_put_dec_enum);
  8624. static const struct snd_kcontrol_new tx_adc_mux1 =
  8625. SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_chain_enum,
  8626. snd_soc_dapm_get_enum_double,
  8627. tasha_put_dec_enum);
  8628. static const struct snd_kcontrol_new tx_adc_mux2 =
  8629. SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_chain_enum,
  8630. snd_soc_dapm_get_enum_double,
  8631. tasha_put_dec_enum);
  8632. static const struct snd_kcontrol_new tx_adc_mux3 =
  8633. SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_chain_enum,
  8634. snd_soc_dapm_get_enum_double,
  8635. tasha_put_dec_enum);
  8636. static const struct snd_kcontrol_new tx_adc_mux4 =
  8637. SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_chain_enum,
  8638. snd_soc_dapm_get_enum_double,
  8639. tasha_put_dec_enum);
  8640. static const struct snd_kcontrol_new tx_adc_mux5 =
  8641. SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_chain_enum,
  8642. snd_soc_dapm_get_enum_double,
  8643. tasha_put_dec_enum);
  8644. static const struct snd_kcontrol_new tx_adc_mux6 =
  8645. SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_chain_enum,
  8646. snd_soc_dapm_get_enum_double,
  8647. tasha_put_dec_enum);
  8648. static const struct snd_kcontrol_new tx_adc_mux7 =
  8649. SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_chain_enum,
  8650. snd_soc_dapm_get_enum_double,
  8651. tasha_put_dec_enum);
  8652. static const struct snd_kcontrol_new tx_adc_mux8 =
  8653. SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_chain_enum,
  8654. snd_soc_dapm_get_enum_double,
  8655. tasha_put_dec_enum);
  8656. static const struct snd_kcontrol_new tx_adc_mux10 =
  8657. SOC_DAPM_ENUM("ADC MUX10 Mux", tx_adc_mux10_chain_enum);
  8658. static const struct snd_kcontrol_new tx_adc_mux11 =
  8659. SOC_DAPM_ENUM("ADC MUX11 Mux", tx_adc_mux11_chain_enum);
  8660. static const struct snd_kcontrol_new tx_adc_mux12 =
  8661. SOC_DAPM_ENUM("ADC MUX12 Mux", tx_adc_mux12_chain_enum);
  8662. static const struct snd_kcontrol_new tx_adc_mux13 =
  8663. SOC_DAPM_ENUM("ADC MUX13 Mux", tx_adc_mux13_chain_enum);
  8664. static const struct snd_kcontrol_new tx_dmic_mux0 =
  8665. SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum);
  8666. static const struct snd_kcontrol_new tx_dmic_mux1 =
  8667. SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum);
  8668. static const struct snd_kcontrol_new tx_dmic_mux2 =
  8669. SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum);
  8670. static const struct snd_kcontrol_new tx_dmic_mux3 =
  8671. SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum);
  8672. static const struct snd_kcontrol_new tx_dmic_mux4 =
  8673. SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum);
  8674. static const struct snd_kcontrol_new tx_dmic_mux5 =
  8675. SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum);
  8676. static const struct snd_kcontrol_new tx_dmic_mux6 =
  8677. SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum);
  8678. static const struct snd_kcontrol_new tx_dmic_mux7 =
  8679. SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum);
  8680. static const struct snd_kcontrol_new tx_dmic_mux8 =
  8681. SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum);
  8682. static const struct snd_kcontrol_new tx_dmic_mux10 =
  8683. SOC_DAPM_ENUM("DMIC MUX10 Mux", tx_dmic_mux10_enum);
  8684. static const struct snd_kcontrol_new tx_dmic_mux11 =
  8685. SOC_DAPM_ENUM("DMIC MUX11 Mux", tx_dmic_mux11_enum);
  8686. static const struct snd_kcontrol_new tx_dmic_mux12 =
  8687. SOC_DAPM_ENUM("DMIC MUX12 Mux", tx_dmic_mux12_enum);
  8688. static const struct snd_kcontrol_new tx_dmic_mux13 =
  8689. SOC_DAPM_ENUM("DMIC MUX13 Mux", tx_dmic_mux13_enum);
  8690. static const struct snd_kcontrol_new tx_amic_mux0 =
  8691. SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum);
  8692. static const struct snd_kcontrol_new tx_amic_mux1 =
  8693. SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum);
  8694. static const struct snd_kcontrol_new tx_amic_mux2 =
  8695. SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum);
  8696. static const struct snd_kcontrol_new tx_amic_mux3 =
  8697. SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum);
  8698. static const struct snd_kcontrol_new tx_amic_mux4 =
  8699. SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum);
  8700. static const struct snd_kcontrol_new tx_amic_mux5 =
  8701. SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum);
  8702. static const struct snd_kcontrol_new tx_amic_mux6 =
  8703. SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum);
  8704. static const struct snd_kcontrol_new tx_amic_mux7 =
  8705. SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum);
  8706. static const struct snd_kcontrol_new tx_amic_mux8 =
  8707. SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum);
  8708. static const struct snd_kcontrol_new tx_amic_mux10 =
  8709. SOC_DAPM_ENUM("AMIC MUX10 Mux", tx_amic_mux10_enum);
  8710. static const struct snd_kcontrol_new tx_amic_mux11 =
  8711. SOC_DAPM_ENUM("AMIC MUX11 Mux", tx_amic_mux11_enum);
  8712. static const struct snd_kcontrol_new tx_amic_mux12 =
  8713. SOC_DAPM_ENUM("AMIC MUX12 Mux", tx_amic_mux12_enum);
  8714. static const struct snd_kcontrol_new tx_amic_mux13 =
  8715. SOC_DAPM_ENUM("AMIC MUX13 Mux", tx_amic_mux13_enum);
  8716. static const struct snd_kcontrol_new sb_tx0_mux =
  8717. SOC_DAPM_ENUM("SLIM TX0 MUX Mux", sb_tx0_mux_enum);
  8718. static const struct snd_kcontrol_new sb_tx1_mux =
  8719. SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum);
  8720. static const struct snd_kcontrol_new sb_tx2_mux =
  8721. SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum);
  8722. static const struct snd_kcontrol_new sb_tx3_mux =
  8723. SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum);
  8724. static const struct snd_kcontrol_new sb_tx4_mux =
  8725. SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum);
  8726. static const struct snd_kcontrol_new sb_tx5_mux =
  8727. SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum);
  8728. static const struct snd_kcontrol_new sb_tx6_mux =
  8729. SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum);
  8730. static const struct snd_kcontrol_new sb_tx7_mux =
  8731. SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum);
  8732. static const struct snd_kcontrol_new sb_tx8_mux =
  8733. SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum);
  8734. static const struct snd_kcontrol_new sb_tx9_mux =
  8735. SOC_DAPM_ENUM("SLIM TX9 MUX Mux", sb_tx9_mux_enum);
  8736. static const struct snd_kcontrol_new sb_tx10_mux =
  8737. SOC_DAPM_ENUM("SLIM TX10 MUX Mux", sb_tx10_mux_enum);
  8738. static const struct snd_kcontrol_new sb_tx11_mux =
  8739. SOC_DAPM_ENUM("SLIM TX11 MUX Mux", sb_tx11_mux_enum);
  8740. static const struct snd_kcontrol_new sb_tx11_inp1_mux =
  8741. SOC_DAPM_ENUM("SLIM TX11 INP1 MUX Mux", sb_tx11_inp1_mux_enum);
  8742. static const struct snd_kcontrol_new sb_tx13_mux =
  8743. SOC_DAPM_ENUM("SLIM TX13 MUX Mux", sb_tx13_mux_enum);
  8744. static const struct snd_kcontrol_new tx13_inp_mux =
  8745. SOC_DAPM_ENUM("TX13 INP MUX Mux", tx13_inp_mux_enum);
  8746. static const struct snd_kcontrol_new rx_mix_tx0_mux =
  8747. SOC_DAPM_ENUM("RX MIX TX0 MUX Mux", rx_mix_tx0_mux_enum);
  8748. static const struct snd_kcontrol_new rx_mix_tx1_mux =
  8749. SOC_DAPM_ENUM("RX MIX TX1 MUX Mux", rx_mix_tx1_mux_enum);
  8750. static const struct snd_kcontrol_new rx_mix_tx2_mux =
  8751. SOC_DAPM_ENUM("RX MIX TX2 MUX Mux", rx_mix_tx2_mux_enum);
  8752. static const struct snd_kcontrol_new rx_mix_tx3_mux =
  8753. SOC_DAPM_ENUM("RX MIX TX3 MUX Mux", rx_mix_tx3_mux_enum);
  8754. static const struct snd_kcontrol_new rx_mix_tx4_mux =
  8755. SOC_DAPM_ENUM("RX MIX TX4 MUX Mux", rx_mix_tx4_mux_enum);
  8756. static const struct snd_kcontrol_new rx_mix_tx5_mux =
  8757. SOC_DAPM_ENUM("RX MIX TX5 MUX Mux", rx_mix_tx5_mux_enum);
  8758. static const struct snd_kcontrol_new rx_mix_tx6_mux =
  8759. SOC_DAPM_ENUM("RX MIX TX6 MUX Mux", rx_mix_tx6_mux_enum);
  8760. static const struct snd_kcontrol_new rx_mix_tx7_mux =
  8761. SOC_DAPM_ENUM("RX MIX TX7 MUX Mux", rx_mix_tx7_mux_enum);
  8762. static const struct snd_kcontrol_new rx_mix_tx8_mux =
  8763. SOC_DAPM_ENUM("RX MIX TX8 MUX Mux", rx_mix_tx8_mux_enum);
  8764. static const struct snd_kcontrol_new iir0_inp0_mux =
  8765. SOC_DAPM_ENUM("IIR0 INP0 Mux", iir0_inp0_mux_enum);
  8766. static const struct snd_kcontrol_new iir0_inp1_mux =
  8767. SOC_DAPM_ENUM("IIR0 INP1 Mux", iir0_inp1_mux_enum);
  8768. static const struct snd_kcontrol_new iir0_inp2_mux =
  8769. SOC_DAPM_ENUM("IIR0 INP2 Mux", iir0_inp2_mux_enum);
  8770. static const struct snd_kcontrol_new iir0_inp3_mux =
  8771. SOC_DAPM_ENUM("IIR0 INP3 Mux", iir0_inp3_mux_enum);
  8772. static const struct snd_kcontrol_new iir1_inp0_mux =
  8773. SOC_DAPM_ENUM("IIR1 INP0 Mux", iir1_inp0_mux_enum);
  8774. static const struct snd_kcontrol_new iir1_inp1_mux =
  8775. SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum);
  8776. static const struct snd_kcontrol_new iir1_inp2_mux =
  8777. SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum);
  8778. static const struct snd_kcontrol_new iir1_inp3_mux =
  8779. SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum);
  8780. static const struct snd_kcontrol_new rx_int0_interp_mux =
  8781. SOC_DAPM_ENUM("RX INT0 INTERP Mux", rx_int0_interp_mux_enum);
  8782. static const struct snd_kcontrol_new rx_int1_interp_mux =
  8783. SOC_DAPM_ENUM("RX INT1 INTERP Mux", rx_int1_interp_mux_enum);
  8784. static const struct snd_kcontrol_new rx_int2_interp_mux =
  8785. SOC_DAPM_ENUM("RX INT2 INTERP Mux", rx_int2_interp_mux_enum);
  8786. static const struct snd_kcontrol_new rx_int3_interp_mux =
  8787. SOC_DAPM_ENUM("RX INT3 INTERP Mux", rx_int3_interp_mux_enum);
  8788. static const struct snd_kcontrol_new rx_int4_interp_mux =
  8789. SOC_DAPM_ENUM("RX INT4 INTERP Mux", rx_int4_interp_mux_enum);
  8790. static const struct snd_kcontrol_new rx_int5_interp_mux =
  8791. SOC_DAPM_ENUM("RX INT5 INTERP Mux", rx_int5_interp_mux_enum);
  8792. static const struct snd_kcontrol_new rx_int6_interp_mux =
  8793. SOC_DAPM_ENUM("RX INT6 INTERP Mux", rx_int6_interp_mux_enum);
  8794. static const struct snd_kcontrol_new rx_int7_interp_mux =
  8795. SOC_DAPM_ENUM("RX INT7 INTERP Mux", rx_int7_interp_mux_enum);
  8796. static const struct snd_kcontrol_new rx_int8_interp_mux =
  8797. SOC_DAPM_ENUM("RX INT8 INTERP Mux", rx_int8_interp_mux_enum);
  8798. static const struct snd_kcontrol_new mad_sel_mux =
  8799. SOC_DAPM_ENUM("MAD_SEL MUX Mux", mad_sel_enum);
  8800. static const struct snd_kcontrol_new aif4_mad_switch =
  8801. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 5, 1, 0);
  8802. static const struct snd_kcontrol_new mad_brdcst_switch =
  8803. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 6, 1, 0);
  8804. static const struct snd_kcontrol_new aif4_switch_mixer_controls =
  8805. SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
  8806. 0, 1, 0, tasha_codec_aif4_mixer_switch_get,
  8807. tasha_codec_aif4_mixer_switch_put);
  8808. static const struct snd_kcontrol_new anc_hphl_switch =
  8809. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8810. static const struct snd_kcontrol_new anc_hphr_switch =
  8811. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8812. static const struct snd_kcontrol_new anc_ear_switch =
  8813. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8814. static const struct snd_kcontrol_new anc_ear_spkr_switch =
  8815. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8816. static const struct snd_kcontrol_new anc_lineout1_switch =
  8817. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8818. static const struct snd_kcontrol_new anc_lineout2_switch =
  8819. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8820. static const struct snd_kcontrol_new anc_spkr_pa_switch =
  8821. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8822. static const struct snd_kcontrol_new adc_us_mux0_switch =
  8823. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8824. static const struct snd_kcontrol_new adc_us_mux1_switch =
  8825. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8826. static const struct snd_kcontrol_new adc_us_mux2_switch =
  8827. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8828. static const struct snd_kcontrol_new adc_us_mux3_switch =
  8829. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8830. static const struct snd_kcontrol_new adc_us_mux4_switch =
  8831. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8832. static const struct snd_kcontrol_new adc_us_mux5_switch =
  8833. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8834. static const struct snd_kcontrol_new adc_us_mux6_switch =
  8835. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8836. static const struct snd_kcontrol_new adc_us_mux7_switch =
  8837. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8838. static const struct snd_kcontrol_new adc_us_mux8_switch =
  8839. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8840. static const struct snd_kcontrol_new anc0_fb_mux =
  8841. SOC_DAPM_ENUM("ANC0 FB MUX Mux", anc0_fb_mux_enum);
  8842. static const struct snd_kcontrol_new anc1_fb_mux =
  8843. SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum);
  8844. static int tasha_codec_ec_buf_mux_enable(struct snd_soc_dapm_widget *w,
  8845. struct snd_kcontrol *kcontrol,
  8846. int event)
  8847. {
  8848. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  8849. dev_dbg(codec->dev, "%s: event = %d name = %s\n",
  8850. __func__, event, w->name);
  8851. switch (event) {
  8852. case SND_SOC_DAPM_POST_PMU:
  8853. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x3B);
  8854. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x08);
  8855. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8856. 0x08, 0x08);
  8857. break;
  8858. case SND_SOC_DAPM_POST_PMD:
  8859. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8860. 0x08, 0x00);
  8861. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x00);
  8862. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x00);
  8863. break;
  8864. }
  8865. return 0;
  8866. };
  8867. static const char * const ec_buf_mux_text[] = {
  8868. "ZERO", "RXMIXEC", "SB_RX0", "SB_RX1", "SB_RX2", "SB_RX3",
  8869. "I2S_RX_SD0_L", "I2S_RX_SD0_R", "I2S_RX_SD1_L", "I2S_RX_SD1_R",
  8870. "DEC1"
  8871. };
  8872. static SOC_ENUM_SINGLE_DECL(ec_buf_mux_enum, WCD9335_CPE_SS_US_EC_MUX_CFG,
  8873. 0, ec_buf_mux_text);
  8874. static const struct snd_kcontrol_new ec_buf_mux =
  8875. SOC_DAPM_ENUM("EC BUF Mux", ec_buf_mux_enum);
  8876. static const struct snd_soc_dapm_widget tasha_dapm_widgets[] = {
  8877. SND_SOC_DAPM_OUTPUT("EAR"),
  8878. SND_SOC_DAPM_OUTPUT("ANC EAR"),
  8879. SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM,
  8880. AIF1_PB, 0, tasha_codec_enable_slimrx,
  8881. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8882. SND_SOC_DAPM_POST_PMD),
  8883. SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM,
  8884. AIF2_PB, 0, tasha_codec_enable_slimrx,
  8885. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8886. SND_SOC_DAPM_POST_PMD),
  8887. SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM,
  8888. AIF3_PB, 0, tasha_codec_enable_slimrx,
  8889. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8890. SND_SOC_DAPM_POST_PMD),
  8891. SND_SOC_DAPM_AIF_IN_E("AIF4 PB", "AIF4 Playback", 0, SND_SOC_NOPM,
  8892. AIF4_PB, 0, tasha_codec_enable_slimrx,
  8893. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8894. SND_SOC_DAPM_POST_PMD),
  8895. SND_SOC_DAPM_AIF_IN_E("AIF MIX1 PB", "AIF Mix Playback", 0,
  8896. SND_SOC_NOPM, AIF_MIX1_PB, 0,
  8897. tasha_codec_enable_slimrx,
  8898. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8899. SND_SOC_DAPM_POST_PMD),
  8900. SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM, TASHA_RX0, 0,
  8901. &slim_rx_mux[TASHA_RX0]),
  8902. SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TASHA_RX1, 0,
  8903. &slim_rx_mux[TASHA_RX1]),
  8904. SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TASHA_RX2, 0,
  8905. &slim_rx_mux[TASHA_RX2]),
  8906. SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TASHA_RX3, 0,
  8907. &slim_rx_mux[TASHA_RX3]),
  8908. SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TASHA_RX4, 0,
  8909. &slim_rx_mux[TASHA_RX4]),
  8910. SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TASHA_RX5, 0,
  8911. &slim_rx_mux[TASHA_RX5]),
  8912. SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, TASHA_RX6, 0,
  8913. &slim_rx_mux[TASHA_RX6]),
  8914. SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, TASHA_RX7, 0,
  8915. &slim_rx_mux[TASHA_RX7]),
  8916. SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
  8917. SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  8918. SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  8919. SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
  8920. SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
  8921. SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0),
  8922. SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0),
  8923. SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0),
  8924. SND_SOC_DAPM_MUX_E("SPL SRC0 MUX", SND_SOC_NOPM, SPLINE_SRC0, 0,
  8925. &spl_src0_mux, tasha_codec_enable_spline_resampler,
  8926. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8927. SND_SOC_DAPM_MUX_E("SPL SRC1 MUX", SND_SOC_NOPM, SPLINE_SRC1, 0,
  8928. &spl_src1_mux, tasha_codec_enable_spline_resampler,
  8929. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8930. SND_SOC_DAPM_MUX_E("SPL SRC2 MUX", SND_SOC_NOPM, SPLINE_SRC2, 0,
  8931. &spl_src2_mux, tasha_codec_enable_spline_resampler,
  8932. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8933. SND_SOC_DAPM_MUX_E("SPL SRC3 MUX", SND_SOC_NOPM, SPLINE_SRC3, 0,
  8934. &spl_src3_mux, tasha_codec_enable_spline_resampler,
  8935. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8936. SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  8937. 5, 0, &rx_int0_2_mux, tasha_codec_enable_mix_path,
  8938. SND_SOC_DAPM_POST_PMU),
  8939. SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  8940. 5, 0, &rx_int1_2_mux, tasha_codec_enable_mix_path,
  8941. SND_SOC_DAPM_POST_PMU),
  8942. SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  8943. 5, 0, &rx_int2_2_mux, tasha_codec_enable_mix_path,
  8944. SND_SOC_DAPM_POST_PMU),
  8945. SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", WCD9335_CDC_RX3_RX_PATH_MIX_CTL,
  8946. 5, 0, &rx_int3_2_mux, tasha_codec_enable_mix_path,
  8947. SND_SOC_DAPM_POST_PMU),
  8948. SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", WCD9335_CDC_RX4_RX_PATH_MIX_CTL,
  8949. 5, 0, &rx_int4_2_mux, tasha_codec_enable_mix_path,
  8950. SND_SOC_DAPM_POST_PMU),
  8951. SND_SOC_DAPM_MUX_E("RX INT5_2 MUX", WCD9335_CDC_RX5_RX_PATH_MIX_CTL,
  8952. 5, 0, &rx_int5_2_mux, tasha_codec_enable_mix_path,
  8953. SND_SOC_DAPM_POST_PMU),
  8954. SND_SOC_DAPM_MUX_E("RX INT6_2 MUX", WCD9335_CDC_RX6_RX_PATH_MIX_CTL,
  8955. 5, 0, &rx_int6_2_mux, tasha_codec_enable_mix_path,
  8956. SND_SOC_DAPM_POST_PMU),
  8957. SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", WCD9335_CDC_RX7_RX_PATH_MIX_CTL,
  8958. 5, 0, &rx_int7_2_mux, tasha_codec_enable_mix_path,
  8959. SND_SOC_DAPM_POST_PMU),
  8960. SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", WCD9335_CDC_RX8_RX_PATH_MIX_CTL,
  8961. 5, 0, &rx_int8_2_mux, tasha_codec_enable_mix_path,
  8962. SND_SOC_DAPM_POST_PMU),
  8963. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8964. &rx_int0_1_mix_inp0_mux),
  8965. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8966. &rx_int0_1_mix_inp1_mux),
  8967. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8968. &rx_int0_1_mix_inp2_mux),
  8969. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8970. &rx_int1_1_mix_inp0_mux),
  8971. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8972. &rx_int1_1_mix_inp1_mux),
  8973. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8974. &rx_int1_1_mix_inp2_mux),
  8975. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8976. &rx_int2_1_mix_inp0_mux),
  8977. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8978. &rx_int2_1_mix_inp1_mux),
  8979. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8980. &rx_int2_1_mix_inp2_mux),
  8981. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8982. &rx_int3_1_mix_inp0_mux),
  8983. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8984. &rx_int3_1_mix_inp1_mux),
  8985. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8986. &rx_int3_1_mix_inp2_mux),
  8987. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8988. &rx_int4_1_mix_inp0_mux),
  8989. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8990. &rx_int4_1_mix_inp1_mux),
  8991. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8992. &rx_int4_1_mix_inp2_mux),
  8993. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8994. &rx_int5_1_mix_inp0_mux),
  8995. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8996. &rx_int5_1_mix_inp1_mux),
  8997. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8998. &rx_int5_1_mix_inp2_mux),
  8999. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9000. &rx_int6_1_mix_inp0_mux),
  9001. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9002. &rx_int6_1_mix_inp1_mux),
  9003. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9004. &rx_int6_1_mix_inp2_mux),
  9005. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9006. &rx_int7_1_mix_inp0_mux, tasha_codec_enable_swr,
  9007. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9008. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9009. &rx_int7_1_mix_inp1_mux, tasha_codec_enable_swr,
  9010. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9011. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9012. &rx_int7_1_mix_inp2_mux, tasha_codec_enable_swr,
  9013. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9014. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9015. &rx_int8_1_mix_inp0_mux, tasha_codec_enable_swr,
  9016. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9017. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9018. &rx_int8_1_mix_inp1_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 INP2", SND_SOC_NOPM, 0, 0,
  9021. &rx_int8_1_mix_inp2_mux, tasha_codec_enable_swr,
  9022. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9023. SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9024. SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9025. SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9026. SND_SOC_DAPM_MIXER("RX INT1 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9027. rx_int1_spline_mix_switch,
  9028. ARRAY_SIZE(rx_int1_spline_mix_switch)),
  9029. SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9030. SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9031. SND_SOC_DAPM_MIXER("RX INT2 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9032. rx_int2_spline_mix_switch,
  9033. ARRAY_SIZE(rx_int2_spline_mix_switch)),
  9034. SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9035. SND_SOC_DAPM_MIXER("RX INT3_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9036. SND_SOC_DAPM_MIXER("RX INT3 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9037. rx_int3_spline_mix_switch,
  9038. ARRAY_SIZE(rx_int3_spline_mix_switch)),
  9039. SND_SOC_DAPM_MIXER("RX INT3 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9040. SND_SOC_DAPM_MIXER("RX INT4_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9041. SND_SOC_DAPM_MIXER("RX INT4 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9042. rx_int4_spline_mix_switch,
  9043. ARRAY_SIZE(rx_int4_spline_mix_switch)),
  9044. SND_SOC_DAPM_MIXER("RX INT4 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9045. SND_SOC_DAPM_MIXER("RX INT5_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9046. SND_SOC_DAPM_MIXER("RX INT5 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9047. rx_int5_spline_mix_switch,
  9048. ARRAY_SIZE(rx_int5_spline_mix_switch)),
  9049. SND_SOC_DAPM_MIXER("RX INT5 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9050. SND_SOC_DAPM_MIXER("RX INT6_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9051. SND_SOC_DAPM_MIXER("RX INT6 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9052. rx_int6_spline_mix_switch,
  9053. ARRAY_SIZE(rx_int6_spline_mix_switch)),
  9054. SND_SOC_DAPM_MIXER("RX INT6 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9055. SND_SOC_DAPM_MIXER("RX INT7_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9056. SND_SOC_DAPM_MIXER("RX INT7 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9057. SND_SOC_DAPM_MIXER("RX INT7 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9058. rx_int7_spline_mix_switch,
  9059. ARRAY_SIZE(rx_int7_spline_mix_switch)),
  9060. SND_SOC_DAPM_MIXER("RX INT8_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9061. SND_SOC_DAPM_MIXER("RX INT8 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9062. SND_SOC_DAPM_MIXER("RX INT8 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9063. rx_int8_spline_mix_switch,
  9064. ARRAY_SIZE(rx_int8_spline_mix_switch)),
  9065. SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9066. SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9067. SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9068. SND_SOC_DAPM_MIXER("RX INT3 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9069. SND_SOC_DAPM_MIXER("RX INT4 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9070. SND_SOC_DAPM_MIXER("RX INT5 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9071. SND_SOC_DAPM_MIXER("RX INT6 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9072. SND_SOC_DAPM_MIXER("RX INT7 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9073. SND_SOC_DAPM_MIXER_E("RX INT7 CHAIN", SND_SOC_NOPM, 0, 0,
  9074. NULL, 0, tasha_codec_spk_boost_event,
  9075. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9076. SND_SOC_DAPM_MIXER_E("RX INT8 CHAIN", SND_SOC_NOPM, 0, 0,
  9077. NULL, 0, tasha_codec_spk_boost_event,
  9078. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9079. SND_SOC_DAPM_MIXER_E("RX INT5 VBAT", SND_SOC_NOPM, 0, 0,
  9080. rx_int5_vbat_mix_switch,
  9081. ARRAY_SIZE(rx_int5_vbat_mix_switch),
  9082. tasha_codec_vbat_enable_event,
  9083. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9084. SND_SOC_DAPM_MIXER_E("RX INT6 VBAT", SND_SOC_NOPM, 0, 0,
  9085. rx_int6_vbat_mix_switch,
  9086. ARRAY_SIZE(rx_int6_vbat_mix_switch),
  9087. tasha_codec_vbat_enable_event,
  9088. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9089. SND_SOC_DAPM_MIXER_E("RX INT7 VBAT", SND_SOC_NOPM, 0, 0,
  9090. rx_int7_vbat_mix_switch,
  9091. ARRAY_SIZE(rx_int7_vbat_mix_switch),
  9092. tasha_codec_vbat_enable_event,
  9093. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9094. SND_SOC_DAPM_MIXER_E("RX INT8 VBAT", SND_SOC_NOPM, 0, 0,
  9095. rx_int8_vbat_mix_switch,
  9096. ARRAY_SIZE(rx_int8_vbat_mix_switch),
  9097. tasha_codec_vbat_enable_event,
  9098. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9099. SND_SOC_DAPM_MUX("RX INT0 MIX2 INP", WCD9335_CDC_RX0_RX_PATH_CFG1, 4,
  9100. 0, &rx_int0_mix2_inp_mux),
  9101. SND_SOC_DAPM_MUX("RX INT1 MIX2 INP", WCD9335_CDC_RX1_RX_PATH_CFG1, 4,
  9102. 0, &rx_int1_mix2_inp_mux),
  9103. SND_SOC_DAPM_MUX("RX INT2 MIX2 INP", WCD9335_CDC_RX2_RX_PATH_CFG1, 4,
  9104. 0, &rx_int2_mix2_inp_mux),
  9105. SND_SOC_DAPM_MUX("RX INT3 MIX2 INP", WCD9335_CDC_RX3_RX_PATH_CFG1, 4,
  9106. 0, &rx_int3_mix2_inp_mux),
  9107. SND_SOC_DAPM_MUX("RX INT4 MIX2 INP", WCD9335_CDC_RX4_RX_PATH_CFG1, 4,
  9108. 0, &rx_int4_mix2_inp_mux),
  9109. SND_SOC_DAPM_MUX("RX INT7 MIX2 INP", WCD9335_CDC_RX7_RX_PATH_CFG1, 4,
  9110. 0, &rx_int7_mix2_inp_mux),
  9111. SND_SOC_DAPM_MUX("SLIM TX0 MUX", SND_SOC_NOPM, TASHA_TX0, 0,
  9112. &sb_tx0_mux),
  9113. SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TASHA_TX1, 0,
  9114. &sb_tx1_mux),
  9115. SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TASHA_TX2, 0,
  9116. &sb_tx2_mux),
  9117. SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TASHA_TX3, 0,
  9118. &sb_tx3_mux),
  9119. SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TASHA_TX4, 0,
  9120. &sb_tx4_mux),
  9121. SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TASHA_TX5, 0,
  9122. &sb_tx5_mux),
  9123. SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, TASHA_TX6, 0,
  9124. &sb_tx6_mux),
  9125. SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, TASHA_TX7, 0,
  9126. &sb_tx7_mux),
  9127. SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, TASHA_TX8, 0,
  9128. &sb_tx8_mux),
  9129. SND_SOC_DAPM_MUX("SLIM TX9 MUX", SND_SOC_NOPM, TASHA_TX9, 0,
  9130. &sb_tx9_mux),
  9131. SND_SOC_DAPM_MUX("SLIM TX10 MUX", SND_SOC_NOPM, TASHA_TX10, 0,
  9132. &sb_tx10_mux),
  9133. SND_SOC_DAPM_MUX("SLIM TX11 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9134. &sb_tx11_mux),
  9135. SND_SOC_DAPM_MUX("SLIM TX11 INP1 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9136. &sb_tx11_inp1_mux),
  9137. SND_SOC_DAPM_MUX("SLIM TX13 MUX", SND_SOC_NOPM, TASHA_TX13, 0,
  9138. &sb_tx13_mux),
  9139. SND_SOC_DAPM_MUX("TX13 INP MUX", SND_SOC_NOPM, 0, 0,
  9140. &tx13_inp_mux),
  9141. SND_SOC_DAPM_MUX_E("ADC MUX0", WCD9335_CDC_TX0_TX_PATH_CTL, 5, 0,
  9142. &tx_adc_mux0, tasha_codec_enable_dec,
  9143. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9144. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9145. SND_SOC_DAPM_MUX_E("ADC MUX1", WCD9335_CDC_TX1_TX_PATH_CTL, 5, 0,
  9146. &tx_adc_mux1, tasha_codec_enable_dec,
  9147. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9148. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9149. SND_SOC_DAPM_MUX_E("ADC MUX2", WCD9335_CDC_TX2_TX_PATH_CTL, 5, 0,
  9150. &tx_adc_mux2, tasha_codec_enable_dec,
  9151. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9152. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9153. SND_SOC_DAPM_MUX_E("ADC MUX3", WCD9335_CDC_TX3_TX_PATH_CTL, 5, 0,
  9154. &tx_adc_mux3, tasha_codec_enable_dec,
  9155. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9156. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9157. SND_SOC_DAPM_MUX_E("ADC MUX4", WCD9335_CDC_TX4_TX_PATH_CTL, 5, 0,
  9158. &tx_adc_mux4, tasha_codec_enable_dec,
  9159. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9160. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9161. SND_SOC_DAPM_MUX_E("ADC MUX5", WCD9335_CDC_TX5_TX_PATH_CTL, 5, 0,
  9162. &tx_adc_mux5, tasha_codec_enable_dec,
  9163. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9164. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9165. SND_SOC_DAPM_MUX_E("ADC MUX6", WCD9335_CDC_TX6_TX_PATH_CTL, 5, 0,
  9166. &tx_adc_mux6, tasha_codec_enable_dec,
  9167. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9168. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9169. SND_SOC_DAPM_MUX_E("ADC MUX7", WCD9335_CDC_TX7_TX_PATH_CTL, 5, 0,
  9170. &tx_adc_mux7, tasha_codec_enable_dec,
  9171. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9172. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9173. SND_SOC_DAPM_MUX_E("ADC MUX8", WCD9335_CDC_TX8_TX_PATH_CTL, 5, 0,
  9174. &tx_adc_mux8, tasha_codec_enable_dec,
  9175. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9176. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9177. SND_SOC_DAPM_MUX_E("ADC MUX10", SND_SOC_NOPM, 10, 0,
  9178. &tx_adc_mux10, tasha_codec_tx_adc_cfg,
  9179. SND_SOC_DAPM_POST_PMU),
  9180. SND_SOC_DAPM_MUX_E("ADC MUX11", SND_SOC_NOPM, 11, 0,
  9181. &tx_adc_mux11, tasha_codec_tx_adc_cfg,
  9182. SND_SOC_DAPM_POST_PMU),
  9183. SND_SOC_DAPM_MUX_E("ADC MUX12", SND_SOC_NOPM, 12, 0,
  9184. &tx_adc_mux12, tasha_codec_tx_adc_cfg,
  9185. SND_SOC_DAPM_POST_PMU),
  9186. SND_SOC_DAPM_MUX_E("ADC MUX13", SND_SOC_NOPM, 13, 0,
  9187. &tx_adc_mux13, tasha_codec_tx_adc_cfg,
  9188. SND_SOC_DAPM_POST_PMU),
  9189. SND_SOC_DAPM_MUX("DMIC MUX0", SND_SOC_NOPM, 0, 0,
  9190. &tx_dmic_mux0),
  9191. SND_SOC_DAPM_MUX("DMIC MUX1", SND_SOC_NOPM, 0, 0,
  9192. &tx_dmic_mux1),
  9193. SND_SOC_DAPM_MUX("DMIC MUX2", SND_SOC_NOPM, 0, 0,
  9194. &tx_dmic_mux2),
  9195. SND_SOC_DAPM_MUX("DMIC MUX3", SND_SOC_NOPM, 0, 0,
  9196. &tx_dmic_mux3),
  9197. SND_SOC_DAPM_MUX("DMIC MUX4", SND_SOC_NOPM, 0, 0,
  9198. &tx_dmic_mux4),
  9199. SND_SOC_DAPM_MUX("DMIC MUX5", SND_SOC_NOPM, 0, 0,
  9200. &tx_dmic_mux5),
  9201. SND_SOC_DAPM_MUX("DMIC MUX6", SND_SOC_NOPM, 0, 0,
  9202. &tx_dmic_mux6),
  9203. SND_SOC_DAPM_MUX("DMIC MUX7", SND_SOC_NOPM, 0, 0,
  9204. &tx_dmic_mux7),
  9205. SND_SOC_DAPM_MUX("DMIC MUX8", SND_SOC_NOPM, 0, 0,
  9206. &tx_dmic_mux8),
  9207. SND_SOC_DAPM_MUX("DMIC MUX10", SND_SOC_NOPM, 0, 0,
  9208. &tx_dmic_mux10),
  9209. SND_SOC_DAPM_MUX("DMIC MUX11", SND_SOC_NOPM, 0, 0,
  9210. &tx_dmic_mux11),
  9211. SND_SOC_DAPM_MUX("DMIC MUX12", SND_SOC_NOPM, 0, 0,
  9212. &tx_dmic_mux12),
  9213. SND_SOC_DAPM_MUX("DMIC MUX13", SND_SOC_NOPM, 0, 0,
  9214. &tx_dmic_mux13),
  9215. SND_SOC_DAPM_MUX("AMIC MUX0", SND_SOC_NOPM, 0, 0,
  9216. &tx_amic_mux0),
  9217. SND_SOC_DAPM_MUX("AMIC MUX1", SND_SOC_NOPM, 0, 0,
  9218. &tx_amic_mux1),
  9219. SND_SOC_DAPM_MUX("AMIC MUX2", SND_SOC_NOPM, 0, 0,
  9220. &tx_amic_mux2),
  9221. SND_SOC_DAPM_MUX("AMIC MUX3", SND_SOC_NOPM, 0, 0,
  9222. &tx_amic_mux3),
  9223. SND_SOC_DAPM_MUX("AMIC MUX4", SND_SOC_NOPM, 0, 0,
  9224. &tx_amic_mux4),
  9225. SND_SOC_DAPM_MUX("AMIC MUX5", SND_SOC_NOPM, 0, 0,
  9226. &tx_amic_mux5),
  9227. SND_SOC_DAPM_MUX("AMIC MUX6", SND_SOC_NOPM, 0, 0,
  9228. &tx_amic_mux6),
  9229. SND_SOC_DAPM_MUX("AMIC MUX7", SND_SOC_NOPM, 0, 0,
  9230. &tx_amic_mux7),
  9231. SND_SOC_DAPM_MUX("AMIC MUX8", SND_SOC_NOPM, 0, 0,
  9232. &tx_amic_mux8),
  9233. SND_SOC_DAPM_MUX("AMIC MUX10", SND_SOC_NOPM, 0, 0,
  9234. &tx_amic_mux10),
  9235. SND_SOC_DAPM_MUX("AMIC MUX11", SND_SOC_NOPM, 0, 0,
  9236. &tx_amic_mux11),
  9237. SND_SOC_DAPM_MUX("AMIC MUX12", SND_SOC_NOPM, 0, 0,
  9238. &tx_amic_mux12),
  9239. SND_SOC_DAPM_MUX("AMIC MUX13", SND_SOC_NOPM, 0, 0,
  9240. &tx_amic_mux13),
  9241. SND_SOC_DAPM_ADC_E("ADC1", NULL, WCD9335_ANA_AMIC1, 7, 0,
  9242. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9243. SND_SOC_DAPM_ADC_E("ADC2", NULL, WCD9335_ANA_AMIC2, 7, 0,
  9244. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9245. SND_SOC_DAPM_ADC_E("ADC3", NULL, WCD9335_ANA_AMIC3, 7, 0,
  9246. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9247. SND_SOC_DAPM_ADC_E("ADC4", NULL, WCD9335_ANA_AMIC4, 7, 0,
  9248. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9249. SND_SOC_DAPM_ADC_E("ADC5", NULL, WCD9335_ANA_AMIC5, 7, 0,
  9250. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9251. SND_SOC_DAPM_ADC_E("ADC6", NULL, WCD9335_ANA_AMIC6, 7, 0,
  9252. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9253. SND_SOC_DAPM_SUPPLY("RX INT1 NATIVE SUPPLY", SND_SOC_NOPM,
  9254. INTERP_HPHL, 0, tasha_enable_native_supply,
  9255. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9256. SND_SOC_DAPM_SUPPLY("RX INT2 NATIVE SUPPLY", SND_SOC_NOPM,
  9257. INTERP_HPHR, 0, tasha_enable_native_supply,
  9258. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9259. SND_SOC_DAPM_SUPPLY("RX INT3 NATIVE SUPPLY", SND_SOC_NOPM,
  9260. INTERP_LO1, 0, tasha_enable_native_supply,
  9261. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9262. SND_SOC_DAPM_SUPPLY("RX INT4 NATIVE SUPPLY", SND_SOC_NOPM,
  9263. INTERP_LO2, 0, tasha_enable_native_supply,
  9264. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9265. SND_SOC_DAPM_INPUT("AMIC1"),
  9266. SND_SOC_DAPM_MICBIAS_E("MIC BIAS1", SND_SOC_NOPM, 0, 0,
  9267. tasha_codec_enable_micbias,
  9268. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9269. SND_SOC_DAPM_POST_PMD),
  9270. SND_SOC_DAPM_MICBIAS_E("MIC BIAS2", SND_SOC_NOPM, 0, 0,
  9271. tasha_codec_enable_micbias,
  9272. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9273. SND_SOC_DAPM_POST_PMD),
  9274. SND_SOC_DAPM_MICBIAS_E("MIC BIAS3", SND_SOC_NOPM, 0, 0,
  9275. tasha_codec_enable_micbias,
  9276. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9277. SND_SOC_DAPM_POST_PMD),
  9278. SND_SOC_DAPM_MICBIAS_E("MIC BIAS4", SND_SOC_NOPM, 0, 0,
  9279. tasha_codec_enable_micbias,
  9280. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9281. SND_SOC_DAPM_POST_PMD),
  9282. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS1_STANDALONE, SND_SOC_NOPM, 0, 0,
  9283. tasha_codec_force_enable_micbias,
  9284. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9285. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS2_STANDALONE, SND_SOC_NOPM, 0, 0,
  9286. tasha_codec_force_enable_micbias,
  9287. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9288. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS3_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_MICBIAS4_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_SUPPLY(DAPM_LDO_H_STANDALONE, SND_SOC_NOPM, 0, 0,
  9295. tasha_codec_force_enable_ldo_h,
  9296. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9297. SND_SOC_DAPM_MUX("ANC0 FB MUX", SND_SOC_NOPM, 0, 0, &anc0_fb_mux),
  9298. SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux),
  9299. SND_SOC_DAPM_INPUT("AMIC2"),
  9300. SND_SOC_DAPM_INPUT("AMIC3"),
  9301. SND_SOC_DAPM_INPUT("AMIC4"),
  9302. SND_SOC_DAPM_INPUT("AMIC5"),
  9303. SND_SOC_DAPM_INPUT("AMIC6"),
  9304. SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM,
  9305. AIF1_CAP, 0, tasha_codec_enable_slimtx,
  9306. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9307. SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM,
  9308. AIF2_CAP, 0, tasha_codec_enable_slimtx,
  9309. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9310. SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM,
  9311. AIF3_CAP, 0, tasha_codec_enable_slimtx,
  9312. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9313. SND_SOC_DAPM_AIF_OUT_E("AIF4 VI", "VIfeed", 0, SND_SOC_NOPM,
  9314. AIF4_VIFEED, 0, tasha_codec_enable_slimvi_feedback,
  9315. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9316. SND_SOC_DAPM_MIXER("AIF4_VI Mixer", SND_SOC_NOPM, AIF4_VIFEED, 0,
  9317. aif4_vi_mixer, ARRAY_SIZE(aif4_vi_mixer)),
  9318. SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0,
  9319. aif1_cap_mixer, ARRAY_SIZE(aif1_cap_mixer)),
  9320. SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0,
  9321. aif2_cap_mixer, ARRAY_SIZE(aif2_cap_mixer)),
  9322. SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0,
  9323. aif3_cap_mixer, ARRAY_SIZE(aif3_cap_mixer)),
  9324. SND_SOC_DAPM_MIXER("AIF4_MAD Mixer", SND_SOC_NOPM, AIF4_MAD_TX, 0,
  9325. aif4_mad_mixer, ARRAY_SIZE(aif4_mad_mixer)),
  9326. SND_SOC_DAPM_INPUT("VIINPUT"),
  9327. SND_SOC_DAPM_AIF_OUT("AIF5 CPE", "AIF5 CPE TX", 0, SND_SOC_NOPM,
  9328. AIF5_CPE_TX, 0),
  9329. SND_SOC_DAPM_MUX_E("EC BUF MUX INP", SND_SOC_NOPM, 0, 0, &ec_buf_mux,
  9330. tasha_codec_ec_buf_mux_enable,
  9331. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9332. /* Digital Mic Inputs */
  9333. SND_SOC_DAPM_ADC_E("DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  9334. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9335. SND_SOC_DAPM_POST_PMD),
  9336. SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  9337. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9338. SND_SOC_DAPM_POST_PMD),
  9339. SND_SOC_DAPM_ADC_E("DMIC2", 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("DMIC3", 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("DMIC4", 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("DMIC5", 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_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux),
  9352. SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux),
  9353. SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux),
  9354. SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux),
  9355. SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux),
  9356. SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
  9357. SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux),
  9358. SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux),
  9359. SND_SOC_DAPM_MIXER_E("IIR0", WCD9335_CDC_SIDETONE_IIR0_IIR_PATH_CTL,
  9360. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9361. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9362. SND_SOC_DAPM_MIXER_E("IIR1", WCD9335_CDC_SIDETONE_IIR1_IIR_PATH_CTL,
  9363. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9364. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9365. SND_SOC_DAPM_MIXER("SRC0", WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL,
  9366. 4, 0, NULL, 0),
  9367. SND_SOC_DAPM_MIXER("SRC1", WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL,
  9368. 4, 0, NULL, 0),
  9369. SND_SOC_DAPM_MIXER_E("CPE IN Mixer", SND_SOC_NOPM, 0, 0,
  9370. cpe_in_mix_switch,
  9371. ARRAY_SIZE(cpe_in_mix_switch),
  9372. tasha_codec_configure_cpe_input,
  9373. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9374. SND_SOC_DAPM_MUX("RX INT1_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9375. &int1_1_native_mux),
  9376. SND_SOC_DAPM_MUX("RX INT2_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9377. &int2_1_native_mux),
  9378. SND_SOC_DAPM_MUX("RX INT3_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9379. &int3_1_native_mux),
  9380. SND_SOC_DAPM_MUX("RX INT4_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9381. &int4_1_native_mux),
  9382. SND_SOC_DAPM_MUX("RX MIX TX0 MUX", SND_SOC_NOPM, 0, 0,
  9383. &rx_mix_tx0_mux),
  9384. SND_SOC_DAPM_MUX("RX MIX TX1 MUX", SND_SOC_NOPM, 0, 0,
  9385. &rx_mix_tx1_mux),
  9386. SND_SOC_DAPM_MUX("RX MIX TX2 MUX", SND_SOC_NOPM, 0, 0,
  9387. &rx_mix_tx2_mux),
  9388. SND_SOC_DAPM_MUX("RX MIX TX3 MUX", SND_SOC_NOPM, 0, 0,
  9389. &rx_mix_tx3_mux),
  9390. SND_SOC_DAPM_MUX("RX MIX TX4 MUX", SND_SOC_NOPM, 0, 0,
  9391. &rx_mix_tx4_mux),
  9392. SND_SOC_DAPM_MUX("RX MIX TX5 MUX", SND_SOC_NOPM, 0, 0,
  9393. &rx_mix_tx5_mux),
  9394. SND_SOC_DAPM_MUX("RX MIX TX6 MUX", SND_SOC_NOPM, 0, 0,
  9395. &rx_mix_tx6_mux),
  9396. SND_SOC_DAPM_MUX("RX MIX TX7 MUX", SND_SOC_NOPM, 0, 0,
  9397. &rx_mix_tx7_mux),
  9398. SND_SOC_DAPM_MUX("RX MIX TX8 MUX", SND_SOC_NOPM, 0, 0,
  9399. &rx_mix_tx8_mux),
  9400. SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0,
  9401. &rx_int0_dem_inp_mux),
  9402. SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0,
  9403. &rx_int1_dem_inp_mux),
  9404. SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM, 0, 0,
  9405. &rx_int2_dem_inp_mux),
  9406. SND_SOC_DAPM_MUX_E("RX INT0 INTERP", SND_SOC_NOPM,
  9407. INTERP_EAR, 0, &rx_int0_interp_mux,
  9408. tasha_codec_enable_interpolator,
  9409. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9410. SND_SOC_DAPM_POST_PMD),
  9411. SND_SOC_DAPM_MUX_E("RX INT1 INTERP", SND_SOC_NOPM,
  9412. INTERP_HPHL, 0, &rx_int1_interp_mux,
  9413. tasha_codec_enable_interpolator,
  9414. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9415. SND_SOC_DAPM_POST_PMD),
  9416. SND_SOC_DAPM_MUX_E("RX INT2 INTERP", SND_SOC_NOPM,
  9417. INTERP_HPHR, 0, &rx_int2_interp_mux,
  9418. tasha_codec_enable_interpolator,
  9419. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9420. SND_SOC_DAPM_POST_PMD),
  9421. SND_SOC_DAPM_MUX_E("RX INT3 INTERP", SND_SOC_NOPM,
  9422. INTERP_LO1, 0, &rx_int3_interp_mux,
  9423. tasha_codec_enable_interpolator,
  9424. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9425. SND_SOC_DAPM_POST_PMD),
  9426. SND_SOC_DAPM_MUX_E("RX INT4 INTERP", SND_SOC_NOPM,
  9427. INTERP_LO2, 0, &rx_int4_interp_mux,
  9428. tasha_codec_enable_interpolator,
  9429. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9430. SND_SOC_DAPM_POST_PMD),
  9431. SND_SOC_DAPM_MUX_E("RX INT5 INTERP", SND_SOC_NOPM,
  9432. INTERP_LO3, 0, &rx_int5_interp_mux,
  9433. tasha_codec_enable_interpolator,
  9434. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9435. SND_SOC_DAPM_POST_PMD),
  9436. SND_SOC_DAPM_MUX_E("RX INT6 INTERP", SND_SOC_NOPM,
  9437. INTERP_LO4, 0, &rx_int6_interp_mux,
  9438. tasha_codec_enable_interpolator,
  9439. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9440. SND_SOC_DAPM_POST_PMD),
  9441. SND_SOC_DAPM_MUX_E("RX INT7 INTERP", SND_SOC_NOPM,
  9442. INTERP_SPKR1, 0, &rx_int7_interp_mux,
  9443. tasha_codec_enable_interpolator,
  9444. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9445. SND_SOC_DAPM_POST_PMD),
  9446. SND_SOC_DAPM_MUX_E("RX INT8 INTERP", SND_SOC_NOPM,
  9447. INTERP_SPKR2, 0, &rx_int8_interp_mux,
  9448. tasha_codec_enable_interpolator,
  9449. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9450. SND_SOC_DAPM_POST_PMD),
  9451. SND_SOC_DAPM_DAC_E("RX INT0 DAC", NULL, SND_SOC_NOPM,
  9452. 0, 0, tasha_codec_ear_dac_event,
  9453. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9454. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9455. SND_SOC_DAPM_DAC_E("RX INT1 DAC", NULL, WCD9335_ANA_HPH,
  9456. 5, 0, tasha_codec_hphl_dac_event,
  9457. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9458. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9459. SND_SOC_DAPM_DAC_E("RX INT2 DAC", NULL, WCD9335_ANA_HPH,
  9460. 4, 0, tasha_codec_hphr_dac_event,
  9461. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9462. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9463. SND_SOC_DAPM_DAC_E("RX INT3 DAC", NULL, SND_SOC_NOPM,
  9464. 0, 0, tasha_codec_lineout_dac_event,
  9465. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9466. SND_SOC_DAPM_DAC_E("RX INT4 DAC", NULL, SND_SOC_NOPM,
  9467. 0, 0, tasha_codec_lineout_dac_event,
  9468. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9469. SND_SOC_DAPM_DAC_E("RX INT5 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 INT6 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_PGA_E("HPHL PA", WCD9335_ANA_HPH, 7, 0, NULL, 0,
  9476. tasha_codec_enable_hphl_pa,
  9477. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9478. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9479. SND_SOC_DAPM_PGA_E("HPHR PA", WCD9335_ANA_HPH, 6, 0, NULL, 0,
  9480. tasha_codec_enable_hphr_pa,
  9481. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9482. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9483. SND_SOC_DAPM_PGA_E("EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9484. tasha_codec_enable_ear_pa,
  9485. SND_SOC_DAPM_POST_PMU |
  9486. SND_SOC_DAPM_POST_PMD),
  9487. SND_SOC_DAPM_PGA_E("LINEOUT1 PA", WCD9335_ANA_LO_1_2, 7, 0, NULL, 0,
  9488. tasha_codec_enable_lineout_pa,
  9489. SND_SOC_DAPM_POST_PMU |
  9490. SND_SOC_DAPM_POST_PMD),
  9491. SND_SOC_DAPM_PGA_E("LINEOUT2 PA", WCD9335_ANA_LO_1_2, 6, 0, NULL, 0,
  9492. tasha_codec_enable_lineout_pa,
  9493. SND_SOC_DAPM_POST_PMU |
  9494. SND_SOC_DAPM_POST_PMD),
  9495. SND_SOC_DAPM_PGA_E("LINEOUT3 PA", WCD9335_ANA_LO_3_4, 7, 0, NULL, 0,
  9496. tasha_codec_enable_lineout_pa,
  9497. SND_SOC_DAPM_POST_PMU |
  9498. SND_SOC_DAPM_POST_PMD),
  9499. SND_SOC_DAPM_PGA_E("LINEOUT4 PA", WCD9335_ANA_LO_3_4, 6, 0, NULL, 0,
  9500. tasha_codec_enable_lineout_pa,
  9501. SND_SOC_DAPM_POST_PMU |
  9502. SND_SOC_DAPM_POST_PMD),
  9503. SND_SOC_DAPM_PGA_E("ANC EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9504. tasha_codec_enable_ear_pa,
  9505. SND_SOC_DAPM_POST_PMU |
  9506. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9507. SND_SOC_DAPM_PGA_E("ANC HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9508. tasha_codec_enable_hphl_pa,
  9509. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9510. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9511. SND_SOC_DAPM_PGA_E("ANC HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9512. tasha_codec_enable_hphr_pa,
  9513. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9514. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9515. SND_SOC_DAPM_PGA_E("ANC LINEOUT1 PA", WCD9335_ANA_LO_1_2,
  9516. 7, 0, NULL, 0,
  9517. tasha_codec_enable_lineout_pa,
  9518. SND_SOC_DAPM_POST_PMU |
  9519. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9520. SND_SOC_DAPM_PGA_E("ANC LINEOUT2 PA", WCD9335_ANA_LO_1_2,
  9521. 6, 0, NULL, 0,
  9522. tasha_codec_enable_lineout_pa,
  9523. SND_SOC_DAPM_POST_PMU |
  9524. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9525. SND_SOC_DAPM_PGA_E("ANC SPK1 PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9526. tasha_codec_enable_spk_anc,
  9527. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9528. SND_SOC_DAPM_OUTPUT("HPHL"),
  9529. SND_SOC_DAPM_OUTPUT("HPHR"),
  9530. SND_SOC_DAPM_OUTPUT("ANC HPHL"),
  9531. SND_SOC_DAPM_OUTPUT("ANC HPHR"),
  9532. SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0,
  9533. tasha_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU |
  9534. SND_SOC_DAPM_POST_PMD),
  9535. SND_SOC_DAPM_OUTPUT("SPK1 OUT"),
  9536. SND_SOC_DAPM_OUTPUT("SPK2 OUT"),
  9537. SND_SOC_DAPM_OUTPUT("LINEOUT1"),
  9538. SND_SOC_DAPM_OUTPUT("LINEOUT2"),
  9539. SND_SOC_DAPM_OUTPUT("LINEOUT3"),
  9540. SND_SOC_DAPM_OUTPUT("LINEOUT4"),
  9541. SND_SOC_DAPM_OUTPUT("ANC LINEOUT1"),
  9542. SND_SOC_DAPM_OUTPUT("ANC LINEOUT2"),
  9543. SND_SOC_DAPM_SUPPLY("MICBIAS_REGULATOR", SND_SOC_NOPM,
  9544. ON_DEMAND_MICBIAS, 0,
  9545. tasha_codec_enable_on_demand_supply,
  9546. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9547. SND_SOC_DAPM_SWITCH("ADC US MUX0", WCD9335_CDC_TX0_TX_PATH_192_CTL, 0,
  9548. 0, &adc_us_mux0_switch),
  9549. SND_SOC_DAPM_SWITCH("ADC US MUX1", WCD9335_CDC_TX1_TX_PATH_192_CTL, 0,
  9550. 0, &adc_us_mux1_switch),
  9551. SND_SOC_DAPM_SWITCH("ADC US MUX2", WCD9335_CDC_TX2_TX_PATH_192_CTL, 0,
  9552. 0, &adc_us_mux2_switch),
  9553. SND_SOC_DAPM_SWITCH("ADC US MUX3", WCD9335_CDC_TX3_TX_PATH_192_CTL, 0,
  9554. 0, &adc_us_mux3_switch),
  9555. SND_SOC_DAPM_SWITCH("ADC US MUX4", WCD9335_CDC_TX4_TX_PATH_192_CTL, 0,
  9556. 0, &adc_us_mux4_switch),
  9557. SND_SOC_DAPM_SWITCH("ADC US MUX5", WCD9335_CDC_TX5_TX_PATH_192_CTL, 0,
  9558. 0, &adc_us_mux5_switch),
  9559. SND_SOC_DAPM_SWITCH("ADC US MUX6", WCD9335_CDC_TX6_TX_PATH_192_CTL, 0,
  9560. 0, &adc_us_mux6_switch),
  9561. SND_SOC_DAPM_SWITCH("ADC US MUX7", WCD9335_CDC_TX7_TX_PATH_192_CTL, 0,
  9562. 0, &adc_us_mux7_switch),
  9563. SND_SOC_DAPM_SWITCH("ADC US MUX8", WCD9335_CDC_TX8_TX_PATH_192_CTL, 0,
  9564. 0, &adc_us_mux8_switch),
  9565. /* MAD related widgets */
  9566. SND_SOC_DAPM_AIF_OUT_E("AIF4 MAD", "AIF4 MAD TX", 0,
  9567. SND_SOC_NOPM, 0, 0,
  9568. tasha_codec_enable_mad,
  9569. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9570. SND_SOC_DAPM_MUX("MAD_SEL MUX", SND_SOC_NOPM, 0, 0,
  9571. &mad_sel_mux),
  9572. SND_SOC_DAPM_INPUT("MAD_CPE_INPUT"),
  9573. SND_SOC_DAPM_INPUT("MADINPUT"),
  9574. SND_SOC_DAPM_SWITCH("MADONOFF", SND_SOC_NOPM, 0, 0,
  9575. &aif4_mad_switch),
  9576. SND_SOC_DAPM_SWITCH("MAD_BROADCAST", SND_SOC_NOPM, 0, 0,
  9577. &mad_brdcst_switch),
  9578. SND_SOC_DAPM_SWITCH("AIF4", SND_SOC_NOPM, 0, 0,
  9579. &aif4_switch_mixer_controls),
  9580. SND_SOC_DAPM_SWITCH("ANC HPHL Enable", SND_SOC_NOPM, 0, 0,
  9581. &anc_hphl_switch),
  9582. SND_SOC_DAPM_SWITCH("ANC HPHR Enable", SND_SOC_NOPM, 0, 0,
  9583. &anc_hphr_switch),
  9584. SND_SOC_DAPM_SWITCH("ANC EAR Enable", SND_SOC_NOPM, 0, 0,
  9585. &anc_ear_switch),
  9586. SND_SOC_DAPM_SWITCH("ANC OUT EAR SPKR Enable", SND_SOC_NOPM, 0, 0,
  9587. &anc_ear_spkr_switch),
  9588. SND_SOC_DAPM_SWITCH("ANC LINEOUT1 Enable", SND_SOC_NOPM, 0, 0,
  9589. &anc_lineout1_switch),
  9590. SND_SOC_DAPM_SWITCH("ANC LINEOUT2 Enable", SND_SOC_NOPM, 0, 0,
  9591. &anc_lineout2_switch),
  9592. SND_SOC_DAPM_SWITCH("ANC SPKR PA Enable", SND_SOC_NOPM, 0, 0,
  9593. &anc_spkr_pa_switch),
  9594. };
  9595. static int tasha_get_channel_map(struct snd_soc_dai *dai,
  9596. unsigned int *tx_num, unsigned int *tx_slot,
  9597. unsigned int *rx_num, unsigned int *rx_slot)
  9598. {
  9599. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(dai->codec);
  9600. u32 i = 0;
  9601. struct wcd9xxx_ch *ch;
  9602. switch (dai->id) {
  9603. case AIF1_PB:
  9604. case AIF2_PB:
  9605. case AIF3_PB:
  9606. case AIF4_PB:
  9607. case AIF_MIX1_PB:
  9608. if (!rx_slot || !rx_num) {
  9609. pr_err("%s: Invalid rx_slot %pK or rx_num %pK\n",
  9610. __func__, rx_slot, rx_num);
  9611. return -EINVAL;
  9612. }
  9613. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9614. list) {
  9615. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9616. __func__, i, ch->ch_num);
  9617. rx_slot[i++] = ch->ch_num;
  9618. }
  9619. pr_debug("%s: rx_num %d\n", __func__, i);
  9620. *rx_num = i;
  9621. break;
  9622. case AIF1_CAP:
  9623. case AIF2_CAP:
  9624. case AIF3_CAP:
  9625. case AIF4_MAD_TX:
  9626. case AIF4_VIFEED:
  9627. if (!tx_slot || !tx_num) {
  9628. pr_err("%s: Invalid tx_slot %pK or tx_num %pK\n",
  9629. __func__, tx_slot, tx_num);
  9630. return -EINVAL;
  9631. }
  9632. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9633. list) {
  9634. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9635. __func__, i, ch->ch_num);
  9636. tx_slot[i++] = ch->ch_num;
  9637. }
  9638. pr_debug("%s: tx_num %d\n", __func__, i);
  9639. *tx_num = i;
  9640. break;
  9641. default:
  9642. pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id);
  9643. break;
  9644. }
  9645. return 0;
  9646. }
  9647. static int tasha_set_channel_map(struct snd_soc_dai *dai,
  9648. unsigned int tx_num, unsigned int *tx_slot,
  9649. unsigned int rx_num, unsigned int *rx_slot)
  9650. {
  9651. struct tasha_priv *tasha;
  9652. struct wcd9xxx *core;
  9653. struct wcd9xxx_codec_dai_data *dai_data = NULL;
  9654. if (!dai) {
  9655. pr_err("%s: dai is empty\n", __func__);
  9656. return -EINVAL;
  9657. }
  9658. tasha = snd_soc_codec_get_drvdata(dai->codec);
  9659. core = dev_get_drvdata(dai->codec->dev->parent);
  9660. if (!tx_slot || !rx_slot) {
  9661. pr_err("%s: Invalid tx_slot=%pK, rx_slot=%pK\n",
  9662. __func__, tx_slot, rx_slot);
  9663. return -EINVAL;
  9664. }
  9665. pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n"
  9666. "tasha->intf_type %d\n",
  9667. __func__, dai->name, dai->id, tx_num, rx_num,
  9668. tasha->intf_type);
  9669. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  9670. wcd9xxx_init_slimslave(core, core->slim->laddr,
  9671. tx_num, tx_slot, rx_num, rx_slot);
  9672. /* Reserve TX12/TX13 for MAD data channel */
  9673. dai_data = &tasha->dai[AIF4_MAD_TX];
  9674. if (dai_data) {
  9675. if (TASHA_IS_2_0(tasha->wcd9xxx))
  9676. list_add_tail(&core->tx_chs[TASHA_TX13].list,
  9677. &dai_data->wcd9xxx_ch_list);
  9678. else
  9679. list_add_tail(&core->tx_chs[TASHA_TX12].list,
  9680. &dai_data->wcd9xxx_ch_list);
  9681. }
  9682. }
  9683. return 0;
  9684. }
  9685. static int tasha_startup(struct snd_pcm_substream *substream,
  9686. struct snd_soc_dai *dai)
  9687. {
  9688. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9689. substream->name, substream->stream);
  9690. return 0;
  9691. }
  9692. static void tasha_shutdown(struct snd_pcm_substream *substream,
  9693. struct snd_soc_dai *dai)
  9694. {
  9695. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  9696. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9697. substream->name, substream->stream);
  9698. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  9699. return;
  9700. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  9701. tasha_codec_vote_max_bw(dai->codec, false);
  9702. }
  9703. static int tasha_set_decimator_rate(struct snd_soc_dai *dai,
  9704. u8 tx_fs_rate_reg_val, u32 sample_rate)
  9705. {
  9706. struct snd_soc_codec *codec = dai->codec;
  9707. struct wcd9xxx_ch *ch;
  9708. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9709. u32 tx_port = 0;
  9710. u8 shift = 0, shift_val = 0, tx_mux_sel = 0;
  9711. int decimator = -1;
  9712. u16 tx_port_reg = 0, tx_fs_reg = 0;
  9713. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9714. tx_port = ch->port;
  9715. dev_dbg(codec->dev, "%s: dai->id = %d, tx_port = %d",
  9716. __func__, dai->id, tx_port);
  9717. if ((tx_port < 0) || (tx_port == 12) || (tx_port >= 14)) {
  9718. dev_err(codec->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n",
  9719. __func__, tx_port, dai->id);
  9720. return -EINVAL;
  9721. }
  9722. /* Find the SB TX MUX input - which decimator is connected */
  9723. if (tx_port < 4) {
  9724. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0;
  9725. shift = (tx_port << 1);
  9726. shift_val = 0x03;
  9727. } else if ((tx_port >= 4) && (tx_port < 8)) {
  9728. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1;
  9729. shift = ((tx_port - 4) << 1);
  9730. shift_val = 0x03;
  9731. } else if ((tx_port >= 8) && (tx_port < 11)) {
  9732. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2;
  9733. shift = ((tx_port - 8) << 1);
  9734. shift_val = 0x03;
  9735. } else if (tx_port == 11) {
  9736. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9737. shift = 0;
  9738. shift_val = 0x0F;
  9739. } else if (tx_port == 13) {
  9740. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9741. shift = 4;
  9742. shift_val = 0x03;
  9743. }
  9744. tx_mux_sel = snd_soc_read(codec, tx_port_reg) &
  9745. (shift_val << shift);
  9746. tx_mux_sel = tx_mux_sel >> shift;
  9747. if (tx_port <= 8) {
  9748. if ((tx_mux_sel == 0x2) || (tx_mux_sel == 0x3))
  9749. decimator = tx_port;
  9750. } else if (tx_port <= 10) {
  9751. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9752. decimator = ((tx_port == 9) ? 7 : 6);
  9753. } else if (tx_port == 11) {
  9754. if ((tx_mux_sel >= 1) && (tx_mux_sel < 7))
  9755. decimator = tx_mux_sel - 1;
  9756. } else if (tx_port == 13) {
  9757. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9758. decimator = 5;
  9759. }
  9760. if (decimator >= 0) {
  9761. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  9762. 16 * decimator;
  9763. dev_dbg(codec->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n",
  9764. __func__, decimator, tx_port, sample_rate);
  9765. snd_soc_update_bits(codec, tx_fs_reg, 0x0F,
  9766. tx_fs_rate_reg_val);
  9767. } else if ((tx_port <= 8) && (tx_mux_sel == 0x01)) {
  9768. /* Check if the TX Mux input is RX MIX TXn */
  9769. dev_dbg(codec->dev, "%s: RX_MIX_TX%u going to SLIM TX%u\n",
  9770. __func__, tx_port, tx_port);
  9771. } else {
  9772. dev_err(codec->dev, "%s: ERROR: Invalid decimator: %d\n",
  9773. __func__, decimator);
  9774. return -EINVAL;
  9775. }
  9776. }
  9777. return 0;
  9778. }
  9779. static int tasha_set_mix_interpolator_rate(struct snd_soc_dai *dai,
  9780. u8 int_mix_fs_rate_reg_val,
  9781. u32 sample_rate)
  9782. {
  9783. u8 int_2_inp;
  9784. u32 j;
  9785. u16 int_mux_cfg1, int_fs_reg;
  9786. u8 int_mux_cfg1_val;
  9787. struct snd_soc_codec *codec = dai->codec;
  9788. struct wcd9xxx_ch *ch;
  9789. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9790. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9791. int_2_inp = ch->port + INTn_2_INP_SEL_RX0 -
  9792. TASHA_RX_PORT_START_NUMBER;
  9793. if ((int_2_inp < INTn_2_INP_SEL_RX0) ||
  9794. (int_2_inp > INTn_2_INP_SEL_RX7)) {
  9795. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9796. __func__,
  9797. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9798. dai->id);
  9799. return -EINVAL;
  9800. }
  9801. int_mux_cfg1 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1;
  9802. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9803. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) &
  9804. 0x0F;
  9805. if (int_mux_cfg1_val == int_2_inp) {
  9806. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_MIX_CTL +
  9807. 20 * j;
  9808. pr_debug("%s: AIF_MIX_PB DAI(%d) connected to INT%u_2\n",
  9809. __func__, dai->id, j);
  9810. pr_debug("%s: set INT%u_2 sample rate to %u\n",
  9811. __func__, j, sample_rate);
  9812. snd_soc_update_bits(codec, int_fs_reg,
  9813. 0x0F, int_mix_fs_rate_reg_val);
  9814. }
  9815. int_mux_cfg1 += 2;
  9816. }
  9817. }
  9818. return 0;
  9819. }
  9820. static int tasha_set_prim_interpolator_rate(struct snd_soc_dai *dai,
  9821. u8 int_prim_fs_rate_reg_val,
  9822. u32 sample_rate)
  9823. {
  9824. u8 int_1_mix1_inp;
  9825. u32 j;
  9826. u16 int_mux_cfg0, int_mux_cfg1;
  9827. u16 int_fs_reg;
  9828. u8 int_mux_cfg0_val, int_mux_cfg1_val;
  9829. u8 inp0_sel, inp1_sel, inp2_sel;
  9830. struct snd_soc_codec *codec = dai->codec;
  9831. struct wcd9xxx_ch *ch;
  9832. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9833. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9834. int_1_mix1_inp = ch->port + INTn_1_MIX_INP_SEL_RX0 -
  9835. TASHA_RX_PORT_START_NUMBER;
  9836. if ((int_1_mix1_inp < INTn_1_MIX_INP_SEL_RX0) ||
  9837. (int_1_mix1_inp > INTn_1_MIX_INP_SEL_RX7)) {
  9838. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9839. __func__,
  9840. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9841. dai->id);
  9842. return -EINVAL;
  9843. }
  9844. int_mux_cfg0 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0;
  9845. /*
  9846. * Loop through all interpolator MUX inputs and find out
  9847. * to which interpolator input, the slim rx port
  9848. * is connected
  9849. */
  9850. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9851. int_mux_cfg1 = int_mux_cfg0 + 1;
  9852. int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0);
  9853. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1);
  9854. inp0_sel = int_mux_cfg0_val & 0x0F;
  9855. inp1_sel = (int_mux_cfg0_val >> 4) & 0x0F;
  9856. inp2_sel = (int_mux_cfg1_val >> 4) & 0x0F;
  9857. if ((inp0_sel == int_1_mix1_inp) ||
  9858. (inp1_sel == int_1_mix1_inp) ||
  9859. (inp2_sel == int_1_mix1_inp)) {
  9860. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_CTL +
  9861. 20 * j;
  9862. pr_debug("%s: AIF_PB DAI(%d) connected to INT%u_1\n",
  9863. __func__, dai->id, j);
  9864. pr_debug("%s: set INT%u_1 sample rate to %u\n",
  9865. __func__, j, sample_rate);
  9866. /* sample_rate is in Hz */
  9867. if ((j == 0) && (sample_rate == 44100)) {
  9868. pr_info("%s: Cannot set 44.1KHz on INT0\n",
  9869. __func__);
  9870. } else
  9871. snd_soc_update_bits(codec, int_fs_reg,
  9872. 0x0F, int_prim_fs_rate_reg_val);
  9873. }
  9874. int_mux_cfg0 += 2;
  9875. }
  9876. }
  9877. return 0;
  9878. }
  9879. static int tasha_set_interpolator_rate(struct snd_soc_dai *dai,
  9880. u32 sample_rate)
  9881. {
  9882. int rate_val = 0;
  9883. int i, ret;
  9884. /* set mixing path rate */
  9885. for (i = 0; i < ARRAY_SIZE(int_mix_sample_rate_val); i++) {
  9886. if (sample_rate ==
  9887. int_mix_sample_rate_val[i].sample_rate) {
  9888. rate_val =
  9889. int_mix_sample_rate_val[i].rate_val;
  9890. break;
  9891. }
  9892. }
  9893. if ((i == ARRAY_SIZE(int_mix_sample_rate_val)) ||
  9894. (rate_val < 0))
  9895. goto prim_rate;
  9896. ret = tasha_set_mix_interpolator_rate(dai,
  9897. (u8) rate_val, sample_rate);
  9898. prim_rate:
  9899. /* set primary path sample rate */
  9900. for (i = 0; i < ARRAY_SIZE(int_prim_sample_rate_val); i++) {
  9901. if (sample_rate ==
  9902. int_prim_sample_rate_val[i].sample_rate) {
  9903. rate_val =
  9904. int_prim_sample_rate_val[i].rate_val;
  9905. break;
  9906. }
  9907. }
  9908. if ((i == ARRAY_SIZE(int_prim_sample_rate_val)) ||
  9909. (rate_val < 0))
  9910. return -EINVAL;
  9911. ret = tasha_set_prim_interpolator_rate(dai,
  9912. (u8) rate_val, sample_rate);
  9913. return ret;
  9914. }
  9915. static int tasha_prepare(struct snd_pcm_substream *substream,
  9916. struct snd_soc_dai *dai)
  9917. {
  9918. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9919. substream->name, substream->stream);
  9920. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  9921. tasha_codec_vote_max_bw(dai->codec, false);
  9922. return 0;
  9923. }
  9924. static int tasha_hw_params(struct snd_pcm_substream *substream,
  9925. struct snd_pcm_hw_params *params,
  9926. struct snd_soc_dai *dai)
  9927. {
  9928. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  9929. int ret;
  9930. int tx_fs_rate = -EINVAL;
  9931. int rx_fs_rate = -EINVAL;
  9932. int i2s_bit_mode;
  9933. struct snd_soc_codec *codec = dai->codec;
  9934. pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
  9935. dai->name, dai->id, params_rate(params),
  9936. params_channels(params));
  9937. switch (substream->stream) {
  9938. case SNDRV_PCM_STREAM_PLAYBACK:
  9939. ret = tasha_set_interpolator_rate(dai, params_rate(params));
  9940. if (ret) {
  9941. pr_err("%s: cannot set sample rate: %u\n",
  9942. __func__, params_rate(params));
  9943. return ret;
  9944. }
  9945. switch (params_width(params)) {
  9946. case 16:
  9947. tasha->dai[dai->id].bit_width = 16;
  9948. i2s_bit_mode = 0x01;
  9949. break;
  9950. case 24:
  9951. tasha->dai[dai->id].bit_width = 24;
  9952. i2s_bit_mode = 0x00;
  9953. break;
  9954. default:
  9955. return -EINVAL;
  9956. }
  9957. tasha->dai[dai->id].rate = params_rate(params);
  9958. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  9959. switch (params_rate(params)) {
  9960. case 8000:
  9961. rx_fs_rate = 0;
  9962. break;
  9963. case 16000:
  9964. rx_fs_rate = 1;
  9965. break;
  9966. case 32000:
  9967. rx_fs_rate = 2;
  9968. break;
  9969. case 48000:
  9970. rx_fs_rate = 3;
  9971. break;
  9972. case 96000:
  9973. rx_fs_rate = 4;
  9974. break;
  9975. case 192000:
  9976. rx_fs_rate = 5;
  9977. break;
  9978. default:
  9979. dev_err(tasha->dev,
  9980. "%s: Invalid RX sample rate: %d\n",
  9981. __func__, params_rate(params));
  9982. return -EINVAL;
  9983. };
  9984. snd_soc_update_bits(codec,
  9985. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  9986. 0x20, i2s_bit_mode << 5);
  9987. snd_soc_update_bits(codec,
  9988. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  9989. 0x1c, (rx_fs_rate << 2));
  9990. }
  9991. break;
  9992. case SNDRV_PCM_STREAM_CAPTURE:
  9993. switch (params_rate(params)) {
  9994. case 8000:
  9995. tx_fs_rate = 0;
  9996. break;
  9997. case 16000:
  9998. tx_fs_rate = 1;
  9999. break;
  10000. case 32000:
  10001. tx_fs_rate = 3;
  10002. break;
  10003. case 48000:
  10004. tx_fs_rate = 4;
  10005. break;
  10006. case 96000:
  10007. tx_fs_rate = 5;
  10008. break;
  10009. case 192000:
  10010. tx_fs_rate = 6;
  10011. break;
  10012. case 384000:
  10013. tx_fs_rate = 7;
  10014. break;
  10015. default:
  10016. dev_err(tasha->dev, "%s: Invalid TX sample rate: %d\n",
  10017. __func__, params_rate(params));
  10018. return -EINVAL;
  10019. };
  10020. if (dai->id != AIF4_VIFEED &&
  10021. dai->id != AIF4_MAD_TX) {
  10022. ret = tasha_set_decimator_rate(dai, tx_fs_rate,
  10023. params_rate(params));
  10024. if (ret < 0) {
  10025. dev_err(tasha->dev, "%s: cannot set TX Decimator rate: %d\n",
  10026. __func__, tx_fs_rate);
  10027. return ret;
  10028. }
  10029. }
  10030. tasha->dai[dai->id].rate = params_rate(params);
  10031. switch (params_width(params)) {
  10032. case 16:
  10033. tasha->dai[dai->id].bit_width = 16;
  10034. i2s_bit_mode = 0x01;
  10035. break;
  10036. case 24:
  10037. tasha->dai[dai->id].bit_width = 24;
  10038. i2s_bit_mode = 0x00;
  10039. break;
  10040. case 32:
  10041. tasha->dai[dai->id].bit_width = 32;
  10042. i2s_bit_mode = 0x00;
  10043. break;
  10044. default:
  10045. dev_err(tasha->dev, "%s: Invalid format 0x%x\n",
  10046. __func__, params_width(params));
  10047. return -EINVAL;
  10048. };
  10049. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10050. snd_soc_update_bits(codec,
  10051. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10052. 0x20, i2s_bit_mode << 5);
  10053. if (tx_fs_rate > 1)
  10054. tx_fs_rate--;
  10055. snd_soc_update_bits(codec,
  10056. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10057. 0x1c, tx_fs_rate << 2);
  10058. snd_soc_update_bits(codec,
  10059. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG,
  10060. 0x05, 0x05);
  10061. snd_soc_update_bits(codec,
  10062. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG,
  10063. 0x05, 0x05);
  10064. snd_soc_update_bits(codec,
  10065. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG,
  10066. 0x05, 0x05);
  10067. snd_soc_update_bits(codec,
  10068. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG,
  10069. 0x05, 0x05);
  10070. }
  10071. break;
  10072. default:
  10073. pr_err("%s: Invalid stream type %d\n", __func__,
  10074. substream->stream);
  10075. return -EINVAL;
  10076. };
  10077. if (dai->id == AIF4_VIFEED)
  10078. tasha->dai[dai->id].bit_width = 32;
  10079. return 0;
  10080. }
  10081. static int tasha_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  10082. {
  10083. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  10084. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  10085. case SND_SOC_DAIFMT_CBS_CFS:
  10086. /* CPU is master */
  10087. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10088. if (dai->id == AIF1_CAP)
  10089. snd_soc_update_bits(dai->codec,
  10090. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10091. 0x2, 0);
  10092. else if (dai->id == AIF1_PB)
  10093. snd_soc_update_bits(dai->codec,
  10094. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10095. 0x2, 0);
  10096. }
  10097. break;
  10098. case SND_SOC_DAIFMT_CBM_CFM:
  10099. /* CPU is slave */
  10100. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10101. if (dai->id == AIF1_CAP)
  10102. snd_soc_update_bits(dai->codec,
  10103. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10104. 0x2, 0x2);
  10105. else if (dai->id == AIF1_PB)
  10106. snd_soc_update_bits(dai->codec,
  10107. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10108. 0x2, 0x2);
  10109. }
  10110. break;
  10111. default:
  10112. return -EINVAL;
  10113. }
  10114. return 0;
  10115. }
  10116. static int tasha_set_dai_sysclk(struct snd_soc_dai *dai,
  10117. int clk_id, unsigned int freq, int dir)
  10118. {
  10119. pr_debug("%s\n", __func__);
  10120. return 0;
  10121. }
  10122. static struct snd_soc_dai_ops tasha_dai_ops = {
  10123. .startup = tasha_startup,
  10124. .shutdown = tasha_shutdown,
  10125. .hw_params = tasha_hw_params,
  10126. .prepare = tasha_prepare,
  10127. .set_sysclk = tasha_set_dai_sysclk,
  10128. .set_fmt = tasha_set_dai_fmt,
  10129. .set_channel_map = tasha_set_channel_map,
  10130. .get_channel_map = tasha_get_channel_map,
  10131. };
  10132. static struct snd_soc_dai_driver tasha_dai[] = {
  10133. {
  10134. .name = "tasha_rx1",
  10135. .id = AIF1_PB,
  10136. .playback = {
  10137. .stream_name = "AIF1 Playback",
  10138. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10139. .formats = TASHA_FORMATS_S16_S24_LE,
  10140. .rate_max = 192000,
  10141. .rate_min = 8000,
  10142. .channels_min = 1,
  10143. .channels_max = 2,
  10144. },
  10145. .ops = &tasha_dai_ops,
  10146. },
  10147. {
  10148. .name = "tasha_tx1",
  10149. .id = AIF1_CAP,
  10150. .capture = {
  10151. .stream_name = "AIF1 Capture",
  10152. .rates = WCD9335_RATES_MASK,
  10153. .formats = TASHA_FORMATS_S16_S24_LE,
  10154. .rate_max = 192000,
  10155. .rate_min = 8000,
  10156. .channels_min = 1,
  10157. .channels_max = 4,
  10158. },
  10159. .ops = &tasha_dai_ops,
  10160. },
  10161. {
  10162. .name = "tasha_rx2",
  10163. .id = AIF2_PB,
  10164. .playback = {
  10165. .stream_name = "AIF2 Playback",
  10166. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10167. .formats = TASHA_FORMATS_S16_S24_LE,
  10168. .rate_min = 8000,
  10169. .rate_max = 192000,
  10170. .channels_min = 1,
  10171. .channels_max = 2,
  10172. },
  10173. .ops = &tasha_dai_ops,
  10174. },
  10175. {
  10176. .name = "tasha_tx2",
  10177. .id = AIF2_CAP,
  10178. .capture = {
  10179. .stream_name = "AIF2 Capture",
  10180. .rates = WCD9335_RATES_MASK,
  10181. .formats = TASHA_FORMATS_S16_S24_LE,
  10182. .rate_max = 192000,
  10183. .rate_min = 8000,
  10184. .channels_min = 1,
  10185. .channels_max = 8,
  10186. },
  10187. .ops = &tasha_dai_ops,
  10188. },
  10189. {
  10190. .name = "tasha_rx3",
  10191. .id = AIF3_PB,
  10192. .playback = {
  10193. .stream_name = "AIF3 Playback",
  10194. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10195. .formats = TASHA_FORMATS_S16_S24_LE,
  10196. .rate_min = 8000,
  10197. .rate_max = 192000,
  10198. .channels_min = 1,
  10199. .channels_max = 2,
  10200. },
  10201. .ops = &tasha_dai_ops,
  10202. },
  10203. {
  10204. .name = "tasha_tx3",
  10205. .id = AIF3_CAP,
  10206. .capture = {
  10207. .stream_name = "AIF3 Capture",
  10208. .rates = WCD9335_RATES_MASK,
  10209. .formats = TASHA_FORMATS_S16_S24_LE,
  10210. .rate_max = 48000,
  10211. .rate_min = 8000,
  10212. .channels_min = 1,
  10213. .channels_max = 2,
  10214. },
  10215. .ops = &tasha_dai_ops,
  10216. },
  10217. {
  10218. .name = "tasha_rx4",
  10219. .id = AIF4_PB,
  10220. .playback = {
  10221. .stream_name = "AIF4 Playback",
  10222. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10223. .formats = TASHA_FORMATS_S16_S24_LE,
  10224. .rate_min = 8000,
  10225. .rate_max = 192000,
  10226. .channels_min = 1,
  10227. .channels_max = 2,
  10228. },
  10229. .ops = &tasha_dai_ops,
  10230. },
  10231. {
  10232. .name = "tasha_mix_rx1",
  10233. .id = AIF_MIX1_PB,
  10234. .playback = {
  10235. .stream_name = "AIF Mix Playback",
  10236. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10237. .formats = TASHA_FORMATS_S16_S24_LE,
  10238. .rate_min = 8000,
  10239. .rate_max = 192000,
  10240. .channels_min = 1,
  10241. .channels_max = 8,
  10242. },
  10243. .ops = &tasha_dai_ops,
  10244. },
  10245. {
  10246. .name = "tasha_mad1",
  10247. .id = AIF4_MAD_TX,
  10248. .capture = {
  10249. .stream_name = "AIF4 MAD TX",
  10250. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10251. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_384000,
  10252. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10253. .rate_min = 16000,
  10254. .rate_max = 384000,
  10255. .channels_min = 1,
  10256. .channels_max = 1,
  10257. },
  10258. .ops = &tasha_dai_ops,
  10259. },
  10260. {
  10261. .name = "tasha_vifeedback",
  10262. .id = AIF4_VIFEED,
  10263. .capture = {
  10264. .stream_name = "VIfeed",
  10265. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
  10266. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10267. .rate_max = 48000,
  10268. .rate_min = 8000,
  10269. .channels_min = 1,
  10270. .channels_max = 4,
  10271. },
  10272. .ops = &tasha_dai_ops,
  10273. },
  10274. {
  10275. .name = "tasha_cpe",
  10276. .id = AIF5_CPE_TX,
  10277. .capture = {
  10278. .stream_name = "AIF5 CPE TX",
  10279. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000,
  10280. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10281. .rate_min = 16000,
  10282. .rate_max = 48000,
  10283. .channels_min = 1,
  10284. .channels_max = 1,
  10285. },
  10286. },
  10287. };
  10288. static struct snd_soc_dai_driver tasha_i2s_dai[] = {
  10289. {
  10290. .name = "tasha_i2s_rx1",
  10291. .id = AIF1_PB,
  10292. .playback = {
  10293. .stream_name = "AIF1 Playback",
  10294. .rates = WCD9335_RATES_MASK,
  10295. .formats = TASHA_FORMATS_S16_S24_LE,
  10296. .rate_max = 192000,
  10297. .rate_min = 8000,
  10298. .channels_min = 1,
  10299. .channels_max = 2,
  10300. },
  10301. .ops = &tasha_dai_ops,
  10302. },
  10303. {
  10304. .name = "tasha_i2s_tx1",
  10305. .id = AIF1_CAP,
  10306. .capture = {
  10307. .stream_name = "AIF1 Capture",
  10308. .rates = WCD9335_RATES_MASK,
  10309. .formats = TASHA_FORMATS_S16_S24_LE,
  10310. .rate_max = 192000,
  10311. .rate_min = 8000,
  10312. .channels_min = 1,
  10313. .channels_max = 4,
  10314. },
  10315. .ops = &tasha_dai_ops,
  10316. },
  10317. {
  10318. .name = "tasha_i2s_rx2",
  10319. .id = AIF2_PB,
  10320. .playback = {
  10321. .stream_name = "AIF2 Playback",
  10322. .rates = WCD9335_RATES_MASK,
  10323. .formats = TASHA_FORMATS_S16_S24_LE,
  10324. .rate_max = 192000,
  10325. .rate_min = 8000,
  10326. .channels_min = 1,
  10327. .channels_max = 2,
  10328. },
  10329. .ops = &tasha_dai_ops,
  10330. },
  10331. {
  10332. .name = "tasha_i2s_tx2",
  10333. .id = AIF2_CAP,
  10334. .capture = {
  10335. .stream_name = "AIF2 Capture",
  10336. .rates = WCD9335_RATES_MASK,
  10337. .formats = TASHA_FORMATS_S16_S24_LE,
  10338. .rate_max = 192000,
  10339. .rate_min = 8000,
  10340. .channels_min = 1,
  10341. .channels_max = 4,
  10342. },
  10343. .ops = &tasha_dai_ops,
  10344. },
  10345. };
  10346. static void tasha_codec_power_gate_digital_core(struct tasha_priv *tasha)
  10347. {
  10348. struct snd_soc_codec *codec = tasha->codec;
  10349. if (!codec)
  10350. return;
  10351. mutex_lock(&tasha->power_lock);
  10352. dev_dbg(codec->dev, "%s: Entering power gating function, %d\n",
  10353. __func__, tasha->power_active_ref);
  10354. if (tasha->power_active_ref > 0)
  10355. goto exit;
  10356. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10357. WCD_REGION_POWER_COLLAPSE_BEGIN,
  10358. WCD9XXX_DIG_CORE_REGION_1);
  10359. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10360. 0x04, 0x04);
  10361. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10362. 0x01, 0x00);
  10363. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10364. 0x02, 0x00);
  10365. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10366. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  10367. wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_DOWN,
  10368. WCD9XXX_DIG_CORE_REGION_1);
  10369. exit:
  10370. dev_dbg(codec->dev, "%s: Exiting power gating function, %d\n",
  10371. __func__, tasha->power_active_ref);
  10372. mutex_unlock(&tasha->power_lock);
  10373. }
  10374. static void tasha_codec_power_gate_work(struct work_struct *work)
  10375. {
  10376. struct tasha_priv *tasha;
  10377. struct delayed_work *dwork;
  10378. struct snd_soc_codec *codec;
  10379. dwork = to_delayed_work(work);
  10380. tasha = container_of(dwork, struct tasha_priv, power_gate_work);
  10381. codec = tasha->codec;
  10382. if (!codec)
  10383. return;
  10384. tasha_codec_power_gate_digital_core(tasha);
  10385. }
  10386. /* called under power_lock acquisition */
  10387. static int tasha_dig_core_remove_power_collapse(struct snd_soc_codec *codec)
  10388. {
  10389. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10390. tasha_codec_vote_max_bw(codec, true);
  10391. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5);
  10392. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7);
  10393. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3);
  10394. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x00);
  10395. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x02);
  10396. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10397. WCD_REGION_POWER_COLLAPSE_REMOVE,
  10398. WCD9XXX_DIG_CORE_REGION_1);
  10399. regcache_mark_dirty(codec->component.regmap);
  10400. regcache_sync_region(codec->component.regmap,
  10401. TASHA_DIG_CORE_REG_MIN, TASHA_DIG_CORE_REG_MAX);
  10402. tasha_codec_vote_max_bw(codec, false);
  10403. return 0;
  10404. }
  10405. static int tasha_dig_core_power_collapse(struct tasha_priv *tasha,
  10406. int req_state)
  10407. {
  10408. struct snd_soc_codec *codec;
  10409. int cur_state;
  10410. /* Exit if feature is disabled */
  10411. if (!dig_core_collapse_enable)
  10412. return 0;
  10413. mutex_lock(&tasha->power_lock);
  10414. if (req_state == POWER_COLLAPSE)
  10415. tasha->power_active_ref--;
  10416. else if (req_state == POWER_RESUME)
  10417. tasha->power_active_ref++;
  10418. else
  10419. goto unlock_mutex;
  10420. if (tasha->power_active_ref < 0) {
  10421. dev_dbg(tasha->dev, "%s: power_active_ref is negative\n",
  10422. __func__);
  10423. goto unlock_mutex;
  10424. }
  10425. codec = tasha->codec;
  10426. if (!codec)
  10427. goto unlock_mutex;
  10428. if (req_state == POWER_COLLAPSE) {
  10429. if (tasha->power_active_ref == 0) {
  10430. schedule_delayed_work(&tasha->power_gate_work,
  10431. msecs_to_jiffies(dig_core_collapse_timer * 1000));
  10432. }
  10433. } else if (req_state == POWER_RESUME) {
  10434. if (tasha->power_active_ref == 1) {
  10435. /*
  10436. * At this point, there can be two cases:
  10437. * 1. Core already in power collapse state
  10438. * 2. Timer kicked in and still did not expire or
  10439. * waiting for the power_lock
  10440. */
  10441. cur_state = wcd9xxx_get_current_power_state(
  10442. tasha->wcd9xxx,
  10443. WCD9XXX_DIG_CORE_REGION_1);
  10444. if (cur_state == WCD_REGION_POWER_DOWN)
  10445. tasha_dig_core_remove_power_collapse(codec);
  10446. else {
  10447. mutex_unlock(&tasha->power_lock);
  10448. cancel_delayed_work_sync(
  10449. &tasha->power_gate_work);
  10450. mutex_lock(&tasha->power_lock);
  10451. }
  10452. }
  10453. }
  10454. unlock_mutex:
  10455. mutex_unlock(&tasha->power_lock);
  10456. return 0;
  10457. }
  10458. static int __tasha_cdc_mclk_enable_locked(struct tasha_priv *tasha,
  10459. bool enable)
  10460. {
  10461. int ret = 0;
  10462. if (!tasha->wcd_ext_clk) {
  10463. dev_err(tasha->dev, "%s: wcd ext clock is NULL\n", __func__);
  10464. return -EINVAL;
  10465. }
  10466. dev_dbg(tasha->dev, "%s: mclk_enable = %u\n", __func__, enable);
  10467. if (enable) {
  10468. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10469. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10470. if (ret)
  10471. goto err;
  10472. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10473. tasha_codec_apply_sido_voltage(tasha,
  10474. SIDO_VOLTAGE_NOMINAL_MV);
  10475. } else {
  10476. if (!dig_core_collapse_enable) {
  10477. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10478. tasha_codec_update_sido_voltage(tasha,
  10479. sido_buck_svs_voltage);
  10480. }
  10481. tasha_cdc_req_mclk_enable(tasha, false);
  10482. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10483. }
  10484. err:
  10485. return ret;
  10486. }
  10487. static int __tasha_cdc_mclk_enable(struct tasha_priv *tasha,
  10488. bool enable)
  10489. {
  10490. int ret;
  10491. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10492. ret = __tasha_cdc_mclk_enable_locked(tasha, enable);
  10493. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10494. return ret;
  10495. }
  10496. int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10497. {
  10498. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10499. return __tasha_cdc_mclk_enable(tasha, enable);
  10500. }
  10501. EXPORT_SYMBOL(tasha_cdc_mclk_enable);
  10502. int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10503. {
  10504. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10505. int ret = 0;
  10506. dev_dbg(tasha->dev, "%s: clk_mode: %d, enable: %d, clk_internal: %d\n",
  10507. __func__, tasha->clk_mode, enable, tasha->clk_internal);
  10508. if (tasha->clk_mode || tasha->clk_internal) {
  10509. if (enable) {
  10510. tasha_cdc_sido_ccl_enable(tasha, true);
  10511. wcd_resmgr_enable_master_bias(tasha->resmgr);
  10512. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10513. snd_soc_update_bits(codec,
  10514. WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
  10515. 0x01, 0x01);
  10516. snd_soc_update_bits(codec,
  10517. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  10518. 0x01, 0x01);
  10519. set_bit(CPE_NOMINAL, &tasha->status_mask);
  10520. tasha_codec_update_sido_voltage(tasha,
  10521. SIDO_VOLTAGE_NOMINAL_MV);
  10522. tasha->clk_internal = true;
  10523. } else {
  10524. tasha->clk_internal = false;
  10525. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  10526. tasha_codec_update_sido_voltage(tasha,
  10527. sido_buck_svs_voltage);
  10528. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10529. wcd_resmgr_disable_master_bias(tasha->resmgr);
  10530. tasha_cdc_sido_ccl_enable(tasha, false);
  10531. }
  10532. } else {
  10533. ret = __tasha_cdc_mclk_enable(tasha, enable);
  10534. }
  10535. return ret;
  10536. }
  10537. EXPORT_SYMBOL(tasha_cdc_mclk_tx_enable);
  10538. static ssize_t tasha_codec_version_read(struct snd_info_entry *entry,
  10539. void *file_private_data, struct file *file,
  10540. char __user *buf, size_t count, loff_t pos)
  10541. {
  10542. struct tasha_priv *tasha;
  10543. struct wcd9xxx *wcd9xxx;
  10544. char buffer[TASHA_VERSION_ENTRY_SIZE];
  10545. int len = 0;
  10546. tasha = (struct tasha_priv *) entry->private_data;
  10547. if (!tasha) {
  10548. pr_err("%s: tasha priv is null\n", __func__);
  10549. return -EINVAL;
  10550. }
  10551. wcd9xxx = tasha->wcd9xxx;
  10552. if (wcd9xxx->codec_type->id_major == TASHA_MAJOR) {
  10553. if (TASHA_IS_1_0(wcd9xxx))
  10554. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_0\n");
  10555. else if (TASHA_IS_1_1(wcd9xxx))
  10556. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_1\n");
  10557. else
  10558. snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10559. } else if (wcd9xxx->codec_type->id_major == TASHA2P0_MAJOR) {
  10560. len = snprintf(buffer, sizeof(buffer), "WCD9335_2_0\n");
  10561. } else
  10562. len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10563. return simple_read_from_buffer(buf, count, &pos, buffer, len);
  10564. }
  10565. static struct snd_info_entry_ops tasha_codec_info_ops = {
  10566. .read = tasha_codec_version_read,
  10567. };
  10568. /*
  10569. * tasha_codec_info_create_codec_entry - creates wcd9335 module
  10570. * @codec_root: The parent directory
  10571. * @codec: Codec instance
  10572. *
  10573. * Creates wcd9335 module and version entry under the given
  10574. * parent directory.
  10575. *
  10576. * Return: 0 on success or negative error code on failure.
  10577. */
  10578. int tasha_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
  10579. struct snd_soc_codec *codec)
  10580. {
  10581. struct snd_info_entry *version_entry;
  10582. struct tasha_priv *tasha;
  10583. struct snd_soc_card *card;
  10584. if (!codec_root || !codec)
  10585. return -EINVAL;
  10586. tasha = snd_soc_codec_get_drvdata(codec);
  10587. card = codec->component.card;
  10588. tasha->entry = snd_info_create_subdir(codec_root->module,
  10589. "tasha", codec_root);
  10590. if (!tasha->entry) {
  10591. dev_dbg(codec->dev, "%s: failed to create wcd9335 entry\n",
  10592. __func__);
  10593. return -ENOMEM;
  10594. }
  10595. version_entry = snd_info_create_card_entry(card->snd_card,
  10596. "version",
  10597. tasha->entry);
  10598. if (!version_entry) {
  10599. dev_dbg(codec->dev, "%s: failed to create wcd9335 version entry\n",
  10600. __func__);
  10601. return -ENOMEM;
  10602. }
  10603. version_entry->private_data = tasha;
  10604. version_entry->size = TASHA_VERSION_ENTRY_SIZE;
  10605. version_entry->content = SNDRV_INFO_CONTENT_DATA;
  10606. version_entry->c.ops = &tasha_codec_info_ops;
  10607. if (snd_info_register(version_entry) < 0) {
  10608. snd_info_free_entry(version_entry);
  10609. return -ENOMEM;
  10610. }
  10611. tasha->version_entry = version_entry;
  10612. return 0;
  10613. }
  10614. EXPORT_SYMBOL(tasha_codec_info_create_codec_entry);
  10615. static int __tasha_codec_internal_rco_ctrl(
  10616. struct snd_soc_codec *codec, bool enable)
  10617. {
  10618. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10619. int ret = 0;
  10620. if (enable) {
  10621. tasha_cdc_sido_ccl_enable(tasha, true);
  10622. if (wcd_resmgr_get_clk_type(tasha->resmgr) ==
  10623. WCD_CLK_RCO) {
  10624. ret = wcd_resmgr_enable_clk_block(tasha->resmgr,
  10625. WCD_CLK_RCO);
  10626. } else {
  10627. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10628. ret |= wcd_resmgr_enable_clk_block(tasha->resmgr,
  10629. WCD_CLK_RCO);
  10630. ret |= tasha_cdc_req_mclk_enable(tasha, false);
  10631. }
  10632. } else {
  10633. ret = wcd_resmgr_disable_clk_block(tasha->resmgr,
  10634. WCD_CLK_RCO);
  10635. tasha_cdc_sido_ccl_enable(tasha, false);
  10636. }
  10637. if (ret) {
  10638. dev_err(codec->dev, "%s: Error in %s RCO\n",
  10639. __func__, (enable ? "enabling" : "disabling"));
  10640. ret = -EINVAL;
  10641. }
  10642. return ret;
  10643. }
  10644. /*
  10645. * tasha_codec_internal_rco_ctrl()
  10646. * Make sure that the caller does not acquire
  10647. * BG_CLK_LOCK.
  10648. */
  10649. static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
  10650. bool enable)
  10651. {
  10652. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10653. int ret = 0;
  10654. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10655. ret = __tasha_codec_internal_rco_ctrl(codec, enable);
  10656. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10657. return ret;
  10658. }
  10659. /*
  10660. * tasha_mbhc_hs_detect: starts mbhc insertion/removal functionality
  10661. * @codec: handle to snd_soc_codec *
  10662. * @mbhc_cfg: handle to mbhc configuration structure
  10663. * return 0 if mbhc_start is success or error code in case of failure
  10664. */
  10665. int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
  10666. struct wcd_mbhc_config *mbhc_cfg)
  10667. {
  10668. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10669. return wcd_mbhc_start(&tasha->mbhc, mbhc_cfg);
  10670. }
  10671. EXPORT_SYMBOL(tasha_mbhc_hs_detect);
  10672. /*
  10673. * tasha_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
  10674. * @codec: handle to snd_soc_codec *
  10675. */
  10676. void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
  10677. {
  10678. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10679. wcd_mbhc_stop(&tasha->mbhc);
  10680. }
  10681. EXPORT_SYMBOL(tasha_mbhc_hs_detect_exit);
  10682. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv)
  10683. {
  10684. /* min micbias voltage is 1V and maximum is 2.85V */
  10685. if (micb_mv < 1000 || micb_mv > 2850) {
  10686. pr_err("%s: unsupported micbias voltage\n", __func__);
  10687. return -EINVAL;
  10688. }
  10689. return (micb_mv - 1000) / 50;
  10690. }
  10691. static const struct tasha_reg_mask_val tasha_reg_update_reset_val_1_1[] = {
  10692. {WCD9335_RCO_CTRL_2, 0xFF, 0x47},
  10693. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10694. };
  10695. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_1[] = {
  10696. {WCD9335_FLYBACK_VNEG_DAC_CTRL_1, 0xFF, 0x65},
  10697. {WCD9335_FLYBACK_VNEG_DAC_CTRL_2, 0xFF, 0x52},
  10698. {WCD9335_FLYBACK_VNEG_DAC_CTRL_3, 0xFF, 0xAF},
  10699. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10700. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0xF4},
  10701. {WCD9335_FLYBACK_VNEG_CTRL_9, 0xFF, 0x40},
  10702. {WCD9335_FLYBACK_VNEG_CTRL_2, 0xFF, 0x4F},
  10703. {WCD9335_FLYBACK_EN, 0xFF, 0x6E},
  10704. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xF8, 0xF8},
  10705. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xF8, 0xF8},
  10706. };
  10707. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_0[] = {
  10708. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0x54},
  10709. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xFC, 0xFC},
  10710. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xFC, 0xFC},
  10711. };
  10712. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_2_0[] = {
  10713. {WCD9335_RCO_CTRL_2, 0x0F, 0x08},
  10714. {WCD9335_RX_BIAS_FLYB_MID_RST, 0xF0, 0x10},
  10715. {WCD9335_FLYBACK_CTRL_1, 0x20, 0x20},
  10716. {WCD9335_HPH_OCP_CTL, 0xFF, 0x7A},
  10717. {WCD9335_HPH_L_TEST, 0x01, 0x01},
  10718. {WCD9335_HPH_R_TEST, 0x01, 0x01},
  10719. {WCD9335_CDC_BOOST0_BOOST_CFG1, 0x3F, 0x12},
  10720. {WCD9335_CDC_BOOST0_BOOST_CFG2, 0x1C, 0x08},
  10721. {WCD9335_CDC_COMPANDER7_CTL7, 0x1E, 0x18},
  10722. {WCD9335_CDC_BOOST1_BOOST_CFG1, 0x3F, 0x12},
  10723. {WCD9335_CDC_BOOST1_BOOST_CFG2, 0x1C, 0x08},
  10724. {WCD9335_CDC_COMPANDER8_CTL7, 0x1E, 0x18},
  10725. {WCD9335_CDC_TX0_TX_PATH_SEC7, 0xFF, 0x45},
  10726. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xFC, 0xF4},
  10727. {WCD9335_HPH_REFBUFF_LP_CTL, 0x08, 0x08},
  10728. {WCD9335_HPH_REFBUFF_LP_CTL, 0x06, 0x02},
  10729. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xA0},
  10730. {WCD9335_SE_LO_COM1, 0xFF, 0xC0},
  10731. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xFC, 0xF4},
  10732. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xFC, 0xF4},
  10733. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xFC, 0xF8},
  10734. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xFC, 0xF8},
  10735. };
  10736. static const struct tasha_reg_mask_val tasha_codec_reg_defaults[] = {
  10737. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x00},
  10738. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x01},
  10739. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x04, 0x04},
  10740. };
  10741. static const struct tasha_reg_mask_val tasha_codec_reg_i2c_defaults[] = {
  10742. {WCD9335_ANA_CLK_TOP, 0x20, 0x20},
  10743. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x01},
  10744. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x00},
  10745. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x05, 0x05},
  10746. {WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG, 0x01, 0x01},
  10747. {WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG, 0x01, 0x01},
  10748. {WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG, 0x01, 0x01},
  10749. {WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG, 0x01, 0x01},
  10750. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG, 0x05, 0x05},
  10751. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG, 0x05, 0x05},
  10752. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG, 0x05, 0x05},
  10753. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG, 0x05, 0x05},
  10754. };
  10755. static const struct tasha_reg_mask_val tasha_codec_reg_init_common_val[] = {
  10756. /* Rbuckfly/R_EAR(32) */
  10757. {WCD9335_CDC_CLSH_K2_MSB, 0x0F, 0x00},
  10758. {WCD9335_CDC_CLSH_K2_LSB, 0xFF, 0x60},
  10759. {WCD9335_CPE_SS_DMIC_CFG, 0x80, 0x00},
  10760. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x70, 0x50},
  10761. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x70, 0x50},
  10762. {WCD9335_CDC_RX7_RX_PATH_CFG1, 0x08, 0x08},
  10763. {WCD9335_CDC_RX8_RX_PATH_CFG1, 0x08, 0x08},
  10764. {WCD9335_ANA_LO_1_2, 0x3C, 0X3C},
  10765. {WCD9335_DIFF_LO_COM_SWCAP_REFBUF_FREQ, 0x70, 0x00},
  10766. {WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03, 0x03},
  10767. {WCD9335_CDC_TOP_TOP_CFG1, 0x02, 0x02},
  10768. {WCD9335_CDC_TOP_TOP_CFG1, 0x01, 0x01},
  10769. {WCD9335_EAR_CMBUFF, 0x08, 0x00},
  10770. {WCD9335_CDC_TX9_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10771. {WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10772. {WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10773. {WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10774. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  10775. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  10776. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  10777. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  10778. {WCD9335_CDC_RX0_RX_PATH_CFG0, 0x01, 0x01},
  10779. {WCD9335_CDC_RX1_RX_PATH_CFG0, 0x01, 0x01},
  10780. {WCD9335_CDC_RX2_RX_PATH_CFG0, 0x01, 0x01},
  10781. {WCD9335_CDC_RX3_RX_PATH_CFG0, 0x01, 0x01},
  10782. {WCD9335_CDC_RX4_RX_PATH_CFG0, 0x01, 0x01},
  10783. {WCD9335_CDC_RX5_RX_PATH_CFG0, 0x01, 0x01},
  10784. {WCD9335_CDC_RX6_RX_PATH_CFG0, 0x01, 0x01},
  10785. {WCD9335_CDC_RX7_RX_PATH_CFG0, 0x01, 0x01},
  10786. {WCD9335_CDC_RX8_RX_PATH_CFG0, 0x01, 0x01},
  10787. {WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 0x01, 0x01},
  10788. {WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 0x01, 0x01},
  10789. {WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 0x01, 0x01},
  10790. {WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 0x01, 0x01},
  10791. {WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 0x01, 0x01},
  10792. {WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 0x01, 0x01},
  10793. {WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 0x01, 0x01},
  10794. {WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 0x01, 0x01},
  10795. {WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 0x01, 0x01},
  10796. {WCD9335_VBADC_IBIAS_FE, 0x0C, 0x08},
  10797. };
  10798. static const struct tasha_reg_mask_val tasha_codec_reg_init_1_x_val[] = {
  10799. /* Enable TX HPF Filter & Linear Phase */
  10800. {WCD9335_CDC_TX0_TX_PATH_CFG0, 0x11, 0x11},
  10801. {WCD9335_CDC_TX1_TX_PATH_CFG0, 0x11, 0x11},
  10802. {WCD9335_CDC_TX2_TX_PATH_CFG0, 0x11, 0x11},
  10803. {WCD9335_CDC_TX3_TX_PATH_CFG0, 0x11, 0x11},
  10804. {WCD9335_CDC_TX4_TX_PATH_CFG0, 0x11, 0x11},
  10805. {WCD9335_CDC_TX5_TX_PATH_CFG0, 0x11, 0x11},
  10806. {WCD9335_CDC_TX6_TX_PATH_CFG0, 0x11, 0x11},
  10807. {WCD9335_CDC_TX7_TX_PATH_CFG0, 0x11, 0x11},
  10808. {WCD9335_CDC_TX8_TX_PATH_CFG0, 0x11, 0x11},
  10809. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xF8, 0xF8},
  10810. {WCD9335_CDC_RX0_RX_PATH_SEC1, 0x08, 0x08},
  10811. {WCD9335_CDC_RX1_RX_PATH_SEC1, 0x08, 0x08},
  10812. {WCD9335_CDC_RX2_RX_PATH_SEC1, 0x08, 0x08},
  10813. {WCD9335_CDC_RX3_RX_PATH_SEC1, 0x08, 0x08},
  10814. {WCD9335_CDC_RX4_RX_PATH_SEC1, 0x08, 0x08},
  10815. {WCD9335_CDC_RX5_RX_PATH_SEC1, 0x08, 0x08},
  10816. {WCD9335_CDC_RX6_RX_PATH_SEC1, 0x08, 0x08},
  10817. {WCD9335_CDC_RX7_RX_PATH_SEC1, 0x08, 0x08},
  10818. {WCD9335_CDC_RX8_RX_PATH_SEC1, 0x08, 0x08},
  10819. {WCD9335_CDC_RX0_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10820. {WCD9335_CDC_RX1_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10821. {WCD9335_CDC_RX2_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10822. {WCD9335_CDC_RX3_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10823. {WCD9335_CDC_RX4_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10824. {WCD9335_CDC_RX5_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10825. {WCD9335_CDC_RX6_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10826. {WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10827. {WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10828. {WCD9335_CDC_TX0_TX_PATH_SEC2, 0x01, 0x01},
  10829. {WCD9335_CDC_TX1_TX_PATH_SEC2, 0x01, 0x01},
  10830. {WCD9335_CDC_TX2_TX_PATH_SEC2, 0x01, 0x01},
  10831. {WCD9335_CDC_TX3_TX_PATH_SEC2, 0x01, 0x01},
  10832. {WCD9335_CDC_TX4_TX_PATH_SEC2, 0x01, 0x01},
  10833. {WCD9335_CDC_TX5_TX_PATH_SEC2, 0x01, 0x01},
  10834. {WCD9335_CDC_TX6_TX_PATH_SEC2, 0x01, 0x01},
  10835. {WCD9335_CDC_TX7_TX_PATH_SEC2, 0x01, 0x01},
  10836. {WCD9335_CDC_TX8_TX_PATH_SEC2, 0x01, 0x01},
  10837. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xF8, 0xF0},
  10838. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xF8, 0xF0},
  10839. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xF8, 0xF8},
  10840. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xF8, 0xF8},
  10841. {WCD9335_RX_OCP_COUNT, 0xFF, 0xFF},
  10842. {WCD9335_HPH_OCP_CTL, 0xF0, 0x70},
  10843. {WCD9335_CPE_SS_CPAR_CFG, 0xFF, 0x00},
  10844. {WCD9335_FLYBACK_VNEG_CTRL_1, 0xFF, 0x63},
  10845. {WCD9335_FLYBACK_VNEG_CTRL_4, 0xFF, 0x7F},
  10846. {WCD9335_CLASSH_CTRL_VCL_1, 0xFF, 0x60},
  10847. {WCD9335_CLASSH_CTRL_CCL_5, 0xFF, 0x40},
  10848. {WCD9335_RX_TIMER_DIV, 0xFF, 0x32},
  10849. {WCD9335_SE_LO_COM2, 0xFF, 0x01},
  10850. {WCD9335_MBHC_ZDET_ANA_CTL, 0x0F, 0x07},
  10851. {WCD9335_RX_BIAS_HPH_PA, 0xF0, 0x60},
  10852. {WCD9335_HPH_RDAC_LDO_CTL, 0x88, 0x88},
  10853. {WCD9335_HPH_L_EN, 0x20, 0x20},
  10854. {WCD9335_HPH_R_EN, 0x20, 0x20},
  10855. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xD8},
  10856. {WCD9335_CDC_RX5_RX_PATH_SEC3, 0xBD, 0xBD},
  10857. {WCD9335_CDC_RX6_RX_PATH_SEC3, 0xBD, 0xBD},
  10858. {WCD9335_DIFF_LO_COM_PA_FREQ, 0x70, 0x40},
  10859. };
  10860. static void tasha_update_reg_reset_values(struct snd_soc_codec *codec)
  10861. {
  10862. u32 i;
  10863. struct wcd9xxx *tasha_core = dev_get_drvdata(codec->dev->parent);
  10864. if (TASHA_IS_1_1(tasha_core)) {
  10865. for (i = 0; i < ARRAY_SIZE(tasha_reg_update_reset_val_1_1);
  10866. i++)
  10867. snd_soc_write(codec,
  10868. tasha_reg_update_reset_val_1_1[i].reg,
  10869. tasha_reg_update_reset_val_1_1[i].val);
  10870. }
  10871. }
  10872. static void tasha_codec_init_reg(struct snd_soc_codec *codec)
  10873. {
  10874. u32 i;
  10875. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  10876. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_common_val); i++)
  10877. snd_soc_update_bits(codec,
  10878. tasha_codec_reg_init_common_val[i].reg,
  10879. tasha_codec_reg_init_common_val[i].mask,
  10880. tasha_codec_reg_init_common_val[i].val);
  10881. if (TASHA_IS_1_1(wcd9xxx) ||
  10882. TASHA_IS_1_0(wcd9xxx))
  10883. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_1_x_val); i++)
  10884. snd_soc_update_bits(codec,
  10885. tasha_codec_reg_init_1_x_val[i].reg,
  10886. tasha_codec_reg_init_1_x_val[i].mask,
  10887. tasha_codec_reg_init_1_x_val[i].val);
  10888. if (TASHA_IS_1_1(wcd9xxx)) {
  10889. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_1); i++)
  10890. snd_soc_update_bits(codec,
  10891. tasha_codec_reg_init_val_1_1[i].reg,
  10892. tasha_codec_reg_init_val_1_1[i].mask,
  10893. tasha_codec_reg_init_val_1_1[i].val);
  10894. } else if (TASHA_IS_1_0(wcd9xxx)) {
  10895. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_0); i++)
  10896. snd_soc_update_bits(codec,
  10897. tasha_codec_reg_init_val_1_0[i].reg,
  10898. tasha_codec_reg_init_val_1_0[i].mask,
  10899. tasha_codec_reg_init_val_1_0[i].val);
  10900. } else if (TASHA_IS_2_0(wcd9xxx)) {
  10901. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_2_0); i++)
  10902. snd_soc_update_bits(codec,
  10903. tasha_codec_reg_init_val_2_0[i].reg,
  10904. tasha_codec_reg_init_val_2_0[i].mask,
  10905. tasha_codec_reg_init_val_2_0[i].val);
  10906. }
  10907. }
  10908. static void tasha_update_reg_defaults(struct tasha_priv *tasha)
  10909. {
  10910. u32 i;
  10911. struct wcd9xxx *wcd9xxx;
  10912. wcd9xxx = tasha->wcd9xxx;
  10913. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_defaults); i++)
  10914. regmap_update_bits(wcd9xxx->regmap,
  10915. tasha_codec_reg_defaults[i].reg,
  10916. tasha_codec_reg_defaults[i].mask,
  10917. tasha_codec_reg_defaults[i].val);
  10918. tasha->intf_type = wcd9xxx_get_intf_type();
  10919. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  10920. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_i2c_defaults); i++)
  10921. regmap_update_bits(wcd9xxx->regmap,
  10922. tasha_codec_reg_i2c_defaults[i].reg,
  10923. tasha_codec_reg_i2c_defaults[i].mask,
  10924. tasha_codec_reg_i2c_defaults[i].val);
  10925. }
  10926. static void tasha_slim_interface_init_reg(struct snd_soc_codec *codec)
  10927. {
  10928. int i;
  10929. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  10930. for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++)
  10931. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  10932. TASHA_SLIM_PGD_PORT_INT_EN0 + i,
  10933. 0xFF);
  10934. }
  10935. static irqreturn_t tasha_slimbus_irq(int irq, void *data)
  10936. {
  10937. struct tasha_priv *priv = data;
  10938. unsigned long status = 0;
  10939. int i, j, port_id, k;
  10940. u32 bit;
  10941. u8 val, int_val = 0;
  10942. bool tx, cleared;
  10943. unsigned short reg = 0;
  10944. for (i = TASHA_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
  10945. i <= TASHA_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
  10946. val = wcd9xxx_interface_reg_read(priv->wcd9xxx, i);
  10947. status |= ((u32)val << (8 * j));
  10948. }
  10949. for_each_set_bit(j, &status, 32) {
  10950. tx = (j >= 16 ? true : false);
  10951. port_id = (tx ? j - 16 : j);
  10952. val = wcd9xxx_interface_reg_read(priv->wcd9xxx,
  10953. TASHA_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
  10954. if (val) {
  10955. if (!tx)
  10956. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  10957. (port_id / 8);
  10958. else
  10959. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  10960. (port_id / 8);
  10961. int_val = wcd9xxx_interface_reg_read(
  10962. priv->wcd9xxx, reg);
  10963. /*
  10964. * Ignore interrupts for ports for which the
  10965. * interrupts are not specifically enabled.
  10966. */
  10967. if (!(int_val & (1 << (port_id % 8))))
  10968. continue;
  10969. }
  10970. if (val & TASHA_SLIM_IRQ_OVERFLOW)
  10971. pr_err_ratelimited(
  10972. "%s: overflow error on %s port %d, value %x\n",
  10973. __func__, (tx ? "TX" : "RX"), port_id, val);
  10974. if (val & TASHA_SLIM_IRQ_UNDERFLOW)
  10975. pr_err_ratelimited(
  10976. "%s: underflow error on %s port %d, value %x\n",
  10977. __func__, (tx ? "TX" : "RX"), port_id, val);
  10978. if ((val & TASHA_SLIM_IRQ_OVERFLOW) ||
  10979. (val & TASHA_SLIM_IRQ_UNDERFLOW)) {
  10980. if (!tx)
  10981. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  10982. (port_id / 8);
  10983. else
  10984. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  10985. (port_id / 8);
  10986. int_val = wcd9xxx_interface_reg_read(
  10987. priv->wcd9xxx, reg);
  10988. if (int_val & (1 << (port_id % 8))) {
  10989. int_val = int_val ^ (1 << (port_id % 8));
  10990. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  10991. reg, int_val);
  10992. }
  10993. }
  10994. if (val & TASHA_SLIM_IRQ_PORT_CLOSED) {
  10995. /*
  10996. * INT SOURCE register starts from RX to TX
  10997. * but port number in the ch_mask is in opposite way
  10998. */
  10999. bit = (tx ? j - 16 : j + 16);
  11000. pr_debug("%s: %s port %d closed value %x, bit %u\n",
  11001. __func__, (tx ? "TX" : "RX"), port_id, val,
  11002. bit);
  11003. for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) {
  11004. pr_debug("%s: priv->dai[%d].ch_mask = 0x%lx\n",
  11005. __func__, k, priv->dai[k].ch_mask);
  11006. if (test_and_clear_bit(bit,
  11007. &priv->dai[k].ch_mask)) {
  11008. cleared = true;
  11009. if (!priv->dai[k].ch_mask)
  11010. wake_up(&priv->dai[k].dai_wait);
  11011. /*
  11012. * There are cases when multiple DAIs
  11013. * might be using the same slimbus
  11014. * channel. Hence don't break here.
  11015. */
  11016. }
  11017. }
  11018. WARN(!cleared,
  11019. "Couldn't find slimbus %s port %d for closing\n",
  11020. (tx ? "TX" : "RX"), port_id);
  11021. }
  11022. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11023. TASHA_SLIM_PGD_PORT_INT_CLR_RX_0 +
  11024. (j / 8),
  11025. 1 << (j % 8));
  11026. }
  11027. return IRQ_HANDLED;
  11028. }
  11029. static int tasha_setup_irqs(struct tasha_priv *tasha)
  11030. {
  11031. int ret = 0;
  11032. struct snd_soc_codec *codec = tasha->codec;
  11033. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11034. struct wcd9xxx_core_resource *core_res =
  11035. &wcd9xxx->core_res;
  11036. ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS,
  11037. tasha_slimbus_irq, "SLIMBUS Slave", tasha);
  11038. if (ret)
  11039. pr_err("%s: Failed to request irq %d\n", __func__,
  11040. WCD9XXX_IRQ_SLIMBUS);
  11041. else
  11042. tasha_slim_interface_init_reg(codec);
  11043. return ret;
  11044. }
  11045. static void tasha_init_slim_slave_cfg(struct snd_soc_codec *codec)
  11046. {
  11047. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11048. struct afe_param_cdc_slimbus_slave_cfg *cfg;
  11049. struct wcd9xxx *wcd9xxx = priv->wcd9xxx;
  11050. uint64_t eaddr = 0;
  11051. cfg = &priv->slimbus_slave_cfg;
  11052. cfg->minor_version = 1;
  11053. cfg->tx_slave_port_offset = 0;
  11054. cfg->rx_slave_port_offset = 16;
  11055. memcpy(&eaddr, &wcd9xxx->slim->e_addr, sizeof(wcd9xxx->slim->e_addr));
  11056. WARN_ON(sizeof(wcd9xxx->slim->e_addr) != 6);
  11057. cfg->device_enum_addr_lsw = eaddr & 0xFFFFFFFF;
  11058. cfg->device_enum_addr_msw = eaddr >> 32;
  11059. dev_dbg(codec->dev, "%s: slimbus logical address 0x%llx\n",
  11060. __func__, eaddr);
  11061. }
  11062. static void tasha_cleanup_irqs(struct tasha_priv *tasha)
  11063. {
  11064. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11065. struct wcd9xxx_core_resource *core_res =
  11066. &wcd9xxx->core_res;
  11067. wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tasha);
  11068. }
  11069. static int tasha_handle_pdata(struct tasha_priv *tasha,
  11070. struct wcd9xxx_pdata *pdata)
  11071. {
  11072. struct snd_soc_codec *codec = tasha->codec;
  11073. u8 dmic_ctl_val, mad_dmic_ctl_val;
  11074. u8 anc_ctl_value;
  11075. u32 def_dmic_rate, dmic_clk_drv;
  11076. int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4;
  11077. int rc = 0;
  11078. if (!pdata) {
  11079. dev_err(codec->dev, "%s: NULL pdata\n", __func__);
  11080. return -ENODEV;
  11081. }
  11082. /* set micbias voltage */
  11083. vout_ctl_1 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb1_mv);
  11084. vout_ctl_2 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb2_mv);
  11085. vout_ctl_3 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb3_mv);
  11086. vout_ctl_4 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb4_mv);
  11087. if (vout_ctl_1 < 0 || vout_ctl_2 < 0 ||
  11088. vout_ctl_3 < 0 || vout_ctl_4 < 0) {
  11089. rc = -EINVAL;
  11090. goto done;
  11091. }
  11092. snd_soc_update_bits(codec, WCD9335_ANA_MICB1, 0x3F, vout_ctl_1);
  11093. snd_soc_update_bits(codec, WCD9335_ANA_MICB2, 0x3F, vout_ctl_2);
  11094. snd_soc_update_bits(codec, WCD9335_ANA_MICB3, 0x3F, vout_ctl_3);
  11095. snd_soc_update_bits(codec, WCD9335_ANA_MICB4, 0x3F, vout_ctl_4);
  11096. /* Set the DMIC sample rate */
  11097. switch (pdata->mclk_rate) {
  11098. case TASHA_MCLK_CLK_9P6MHZ:
  11099. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  11100. break;
  11101. case TASHA_MCLK_CLK_12P288MHZ:
  11102. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ;
  11103. break;
  11104. default:
  11105. /* should never happen */
  11106. dev_err(codec->dev, "%s: Invalid mclk_rate %d\n",
  11107. __func__, pdata->mclk_rate);
  11108. rc = -EINVAL;
  11109. goto done;
  11110. };
  11111. if (pdata->dmic_sample_rate ==
  11112. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11113. dev_info(codec->dev, "%s: dmic_rate invalid default = %d\n",
  11114. __func__, def_dmic_rate);
  11115. pdata->dmic_sample_rate = def_dmic_rate;
  11116. }
  11117. if (pdata->mad_dmic_sample_rate ==
  11118. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11119. dev_info(codec->dev, "%s: mad_dmic_rate invalid default = %d\n",
  11120. __func__, def_dmic_rate);
  11121. /*
  11122. * use dmic_sample_rate as the default for MAD
  11123. * if mad dmic sample rate is undefined
  11124. */
  11125. pdata->mad_dmic_sample_rate = pdata->dmic_sample_rate;
  11126. }
  11127. if (pdata->ecpp_dmic_sample_rate ==
  11128. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11129. dev_info(codec->dev,
  11130. "%s: ecpp_dmic_rate invalid default = %d\n",
  11131. __func__, def_dmic_rate);
  11132. /*
  11133. * use dmic_sample_rate as the default for ECPP DMIC
  11134. * if ecpp dmic sample rate is undefined
  11135. */
  11136. pdata->ecpp_dmic_sample_rate = pdata->dmic_sample_rate;
  11137. }
  11138. if (pdata->dmic_clk_drv ==
  11139. WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED) {
  11140. pdata->dmic_clk_drv = WCD9335_DMIC_CLK_DRIVE_DEFAULT;
  11141. dev_info(codec->dev,
  11142. "%s: dmic_clk_strength invalid, default = %d\n",
  11143. __func__, pdata->dmic_clk_drv);
  11144. }
  11145. switch (pdata->dmic_clk_drv) {
  11146. case 2:
  11147. dmic_clk_drv = 0;
  11148. break;
  11149. case 4:
  11150. dmic_clk_drv = 1;
  11151. break;
  11152. case 8:
  11153. dmic_clk_drv = 2;
  11154. break;
  11155. case 16:
  11156. dmic_clk_drv = 3;
  11157. break;
  11158. default:
  11159. dev_err(codec->dev,
  11160. "%s: invalid dmic_clk_drv %d, using default\n",
  11161. __func__, pdata->dmic_clk_drv);
  11162. dmic_clk_drv = 0;
  11163. break;
  11164. }
  11165. snd_soc_update_bits(codec, WCD9335_TEST_DEBUG_PAD_DRVCTL,
  11166. 0x0C, dmic_clk_drv << 2);
  11167. /*
  11168. * Default the DMIC clk rates to mad_dmic_sample_rate,
  11169. * whereas, the anc/txfe dmic rates to dmic_sample_rate
  11170. * since the anc/txfe are independent of mad block.
  11171. */
  11172. mad_dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11173. pdata->mclk_rate,
  11174. pdata->mad_dmic_sample_rate);
  11175. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC0_CTL,
  11176. 0x0E, mad_dmic_ctl_val << 1);
  11177. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC1_CTL,
  11178. 0x0E, mad_dmic_ctl_val << 1);
  11179. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC2_CTL,
  11180. 0x0E, mad_dmic_ctl_val << 1);
  11181. dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11182. pdata->mclk_rate,
  11183. pdata->dmic_sample_rate);
  11184. if (dmic_ctl_val == WCD9335_DMIC_CLK_DIV_2)
  11185. anc_ctl_value = WCD9335_ANC_DMIC_X2_FULL_RATE;
  11186. else
  11187. anc_ctl_value = WCD9335_ANC_DMIC_X2_HALF_RATE;
  11188. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11189. 0x40, anc_ctl_value << 6);
  11190. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11191. 0x20, anc_ctl_value << 5);
  11192. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11193. 0x40, anc_ctl_value << 6);
  11194. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11195. 0x20, anc_ctl_value << 5);
  11196. done:
  11197. return rc;
  11198. }
  11199. static struct wcd_cpe_core *tasha_codec_get_cpe_core(
  11200. struct snd_soc_codec *codec)
  11201. {
  11202. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11203. return priv->cpe_core;
  11204. }
  11205. static int tasha_codec_cpe_fll_update_divider(
  11206. struct snd_soc_codec *codec, u32 cpe_fll_rate)
  11207. {
  11208. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11209. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11210. u32 div_val = 0, l_val = 0;
  11211. u32 computed_cpe_fll;
  11212. if (cpe_fll_rate != CPE_FLL_CLK_75MHZ &&
  11213. cpe_fll_rate != CPE_FLL_CLK_150MHZ) {
  11214. dev_err(codec->dev,
  11215. "%s: Invalid CPE fll rate request %u\n",
  11216. __func__, cpe_fll_rate);
  11217. return -EINVAL;
  11218. }
  11219. if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_12P288MHZ) {
  11220. /* update divider to 10 and enable 5x divider */
  11221. snd_soc_write(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11222. 0x55);
  11223. div_val = 10;
  11224. } else if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_9P6MHZ) {
  11225. /* update divider to 8 and enable 2x divider */
  11226. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11227. 0x7C, 0x70);
  11228. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11229. 0xE0, 0x20);
  11230. div_val = 8;
  11231. } else {
  11232. dev_err(codec->dev,
  11233. "%s: Invalid MCLK rate %u\n",
  11234. __func__, wcd9xxx->mclk_rate);
  11235. return -EINVAL;
  11236. }
  11237. l_val = ((cpe_fll_rate / 1000) * div_val) /
  11238. (wcd9xxx->mclk_rate / 1000);
  11239. /* If l_val was integer truncated, increment l_val once */
  11240. computed_cpe_fll = (wcd9xxx->mclk_rate / div_val) * l_val;
  11241. if (computed_cpe_fll < cpe_fll_rate)
  11242. l_val++;
  11243. /* update L value LSB and MSB */
  11244. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_0,
  11245. (l_val & 0xFF));
  11246. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_1,
  11247. ((l_val >> 8) & 0xFF));
  11248. tasha->current_cpe_clk_freq = cpe_fll_rate;
  11249. dev_dbg(codec->dev,
  11250. "%s: updated l_val to %u for cpe_clk %u and mclk %u\n",
  11251. __func__, l_val, cpe_fll_rate, wcd9xxx->mclk_rate);
  11252. return 0;
  11253. }
  11254. static int __tasha_cdc_change_cpe_clk(struct snd_soc_codec *codec,
  11255. u32 clk_freq)
  11256. {
  11257. int ret = 0;
  11258. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11259. if (!tasha_cdc_is_svs_enabled(tasha)) {
  11260. dev_dbg(codec->dev,
  11261. "%s: SVS not enabled or tasha is not 2p0, return\n",
  11262. __func__);
  11263. return 0;
  11264. }
  11265. dev_dbg(codec->dev, "%s: clk_freq = %u\n", __func__, clk_freq);
  11266. if (clk_freq == CPE_FLL_CLK_75MHZ) {
  11267. /* Change to SVS */
  11268. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11269. 0x08, 0x08);
  11270. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11271. ret = -EINVAL;
  11272. goto done;
  11273. }
  11274. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11275. 0x10, 0x10);
  11276. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  11277. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  11278. } else if (clk_freq == CPE_FLL_CLK_150MHZ) {
  11279. /* change to nominal */
  11280. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11281. 0x08, 0x08);
  11282. set_bit(CPE_NOMINAL, &tasha->status_mask);
  11283. tasha_codec_update_sido_voltage(tasha, SIDO_VOLTAGE_NOMINAL_MV);
  11284. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11285. ret = -EINVAL;
  11286. goto done;
  11287. }
  11288. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11289. 0x10, 0x10);
  11290. } else {
  11291. dev_err(codec->dev,
  11292. "%s: Invalid clk_freq request %d for CPE FLL\n",
  11293. __func__, clk_freq);
  11294. ret = -EINVAL;
  11295. }
  11296. done:
  11297. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11298. 0x10, 0x00);
  11299. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11300. 0x08, 0x00);
  11301. return ret;
  11302. }
  11303. static int tasha_codec_cpe_fll_enable(struct snd_soc_codec *codec,
  11304. bool enable)
  11305. {
  11306. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11307. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11308. u8 clk_sel_reg_val = 0x00;
  11309. dev_dbg(codec->dev, "%s: enable = %s\n",
  11310. __func__, enable ? "true" : "false");
  11311. if (enable) {
  11312. if (tasha_cdc_is_svs_enabled(tasha)) {
  11313. /* FLL enable is always at SVS */
  11314. if (__tasha_cdc_change_cpe_clk(codec,
  11315. CPE_FLL_CLK_75MHZ)) {
  11316. dev_err(codec->dev,
  11317. "%s: clk change to %d failed\n",
  11318. __func__, CPE_FLL_CLK_75MHZ);
  11319. return -EINVAL;
  11320. }
  11321. } else {
  11322. if (tasha_codec_cpe_fll_update_divider(codec,
  11323. CPE_FLL_CLK_75MHZ)) {
  11324. dev_err(codec->dev,
  11325. "%s: clk change to %d failed\n",
  11326. __func__, CPE_FLL_CLK_75MHZ);
  11327. return -EINVAL;
  11328. }
  11329. }
  11330. if (TASHA_IS_1_0(wcd9xxx)) {
  11331. tasha_cdc_mclk_enable(codec, true, false);
  11332. clk_sel_reg_val = 0x02;
  11333. }
  11334. /* Setup CPE reference clk */
  11335. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11336. 0x02, clk_sel_reg_val);
  11337. /* enable CPE FLL reference clk */
  11338. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11339. 0x01, 0x01);
  11340. /* program the PLL */
  11341. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11342. 0x01, 0x01);
  11343. /* TEST clk setting */
  11344. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11345. 0x80, 0x80);
  11346. /* set FLL mode to HW controlled */
  11347. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11348. 0x60, 0x00);
  11349. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x80);
  11350. } else {
  11351. /* disable CPE FLL reference clk */
  11352. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11353. 0x01, 0x00);
  11354. /* undo TEST clk setting */
  11355. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11356. 0x80, 0x00);
  11357. /* undo FLL mode to HW control */
  11358. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x00);
  11359. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11360. 0x60, 0x20);
  11361. /* undo the PLL */
  11362. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11363. 0x01, 0x00);
  11364. if (TASHA_IS_1_0(wcd9xxx))
  11365. tasha_cdc_mclk_enable(codec, false, false);
  11366. /*
  11367. * FLL could get disabled while at nominal,
  11368. * scale it back to SVS
  11369. */
  11370. if (tasha_cdc_is_svs_enabled(tasha))
  11371. __tasha_cdc_change_cpe_clk(codec,
  11372. CPE_FLL_CLK_75MHZ);
  11373. }
  11374. return 0;
  11375. }
  11376. static void tasha_cdc_query_cpe_clk_plan(void *data,
  11377. struct cpe_svc_cfg_clk_plan *clk_freq)
  11378. {
  11379. struct snd_soc_codec *codec = data;
  11380. struct tasha_priv *tasha;
  11381. u32 cpe_clk_khz;
  11382. if (!codec) {
  11383. pr_err("%s: Invalid codec handle\n",
  11384. __func__);
  11385. return;
  11386. }
  11387. tasha = snd_soc_codec_get_drvdata(codec);
  11388. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11389. dev_dbg(codec->dev,
  11390. "%s: current_clk_freq = %u\n",
  11391. __func__, tasha->current_cpe_clk_freq);
  11392. clk_freq->current_clk_feq = cpe_clk_khz;
  11393. clk_freq->num_clk_freqs = 2;
  11394. if (tasha_cdc_is_svs_enabled(tasha)) {
  11395. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ / 1000;
  11396. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ / 1000;
  11397. } else {
  11398. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ;
  11399. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ;
  11400. }
  11401. }
  11402. static void tasha_cdc_change_cpe_clk(void *data,
  11403. u32 clk_freq)
  11404. {
  11405. struct snd_soc_codec *codec = data;
  11406. struct tasha_priv *tasha;
  11407. u32 cpe_clk_khz, req_freq = 0;
  11408. if (!codec) {
  11409. pr_err("%s: Invalid codec handle\n",
  11410. __func__);
  11411. return;
  11412. }
  11413. tasha = snd_soc_codec_get_drvdata(codec);
  11414. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11415. if (tasha_cdc_is_svs_enabled(tasha)) {
  11416. if ((clk_freq * 1000) <= CPE_FLL_CLK_75MHZ)
  11417. req_freq = CPE_FLL_CLK_75MHZ;
  11418. else
  11419. req_freq = CPE_FLL_CLK_150MHZ;
  11420. }
  11421. dev_dbg(codec->dev,
  11422. "%s: requested clk_freq = %u, current clk_freq = %u\n",
  11423. __func__, clk_freq * 1000,
  11424. tasha->current_cpe_clk_freq);
  11425. if (tasha_cdc_is_svs_enabled(tasha)) {
  11426. if (__tasha_cdc_change_cpe_clk(codec, req_freq))
  11427. dev_err(codec->dev,
  11428. "%s: clock/voltage scaling failed\n",
  11429. __func__);
  11430. }
  11431. }
  11432. static int tasha_codec_slim_reserve_bw(struct snd_soc_codec *codec,
  11433. u32 bw_ops, bool commit)
  11434. {
  11435. struct wcd9xxx *wcd9xxx;
  11436. if (!codec) {
  11437. pr_err("%s: Invalid handle to codec\n",
  11438. __func__);
  11439. return -EINVAL;
  11440. }
  11441. wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11442. if (!wcd9xxx) {
  11443. dev_err(codec->dev, "%s: Invalid parent drv_data\n",
  11444. __func__);
  11445. return -EINVAL;
  11446. }
  11447. return wcd9xxx_slim_reserve_bw(wcd9xxx, bw_ops, commit);
  11448. }
  11449. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  11450. bool vote)
  11451. {
  11452. u32 bw_ops;
  11453. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11454. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  11455. return 0;
  11456. mutex_lock(&tasha->sb_clk_gear_lock);
  11457. if (vote) {
  11458. tasha->ref_count++;
  11459. if (tasha->ref_count == 1) {
  11460. bw_ops = SLIM_BW_CLK_GEAR_9;
  11461. tasha_codec_slim_reserve_bw(codec,
  11462. bw_ops, true);
  11463. }
  11464. } else if (!vote && tasha->ref_count > 0) {
  11465. tasha->ref_count--;
  11466. if (tasha->ref_count == 0) {
  11467. bw_ops = SLIM_BW_UNVOTE;
  11468. tasha_codec_slim_reserve_bw(codec,
  11469. bw_ops, true);
  11470. }
  11471. };
  11472. dev_dbg(codec->dev, "%s Value of counter after vote or un-vote is %d\n",
  11473. __func__, tasha->ref_count);
  11474. mutex_unlock(&tasha->sb_clk_gear_lock);
  11475. return 0;
  11476. }
  11477. static int tasha_cpe_err_irq_control(struct snd_soc_codec *codec,
  11478. enum cpe_err_irq_cntl_type cntl_type, u8 *status)
  11479. {
  11480. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11481. u8 irq_bits;
  11482. if (TASHA_IS_2_0(tasha->wcd9xxx))
  11483. irq_bits = 0xFF;
  11484. else
  11485. irq_bits = 0x3F;
  11486. if (status)
  11487. irq_bits = (*status) & irq_bits;
  11488. switch (cntl_type) {
  11489. case CPE_ERR_IRQ_MASK:
  11490. snd_soc_update_bits(codec,
  11491. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11492. irq_bits, irq_bits);
  11493. break;
  11494. case CPE_ERR_IRQ_UNMASK:
  11495. snd_soc_update_bits(codec,
  11496. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11497. irq_bits, 0x00);
  11498. break;
  11499. case CPE_ERR_IRQ_CLEAR:
  11500. snd_soc_write(codec, WCD9335_CPE_SS_SS_ERROR_INT_CLEAR,
  11501. irq_bits);
  11502. break;
  11503. case CPE_ERR_IRQ_STATUS:
  11504. if (!status)
  11505. return -EINVAL;
  11506. *status = snd_soc_read(codec,
  11507. WCD9335_CPE_SS_SS_ERROR_INT_STATUS);
  11508. break;
  11509. }
  11510. return 0;
  11511. }
  11512. static const struct wcd_cpe_cdc_cb cpe_cb = {
  11513. .cdc_clk_en = tasha_codec_internal_rco_ctrl,
  11514. .cpe_clk_en = tasha_codec_cpe_fll_enable,
  11515. .get_afe_out_port_id = tasha_codec_get_mad_port_id,
  11516. .lab_cdc_ch_ctl = tasha_codec_enable_slimtx_mad,
  11517. .cdc_ext_clk = tasha_cdc_mclk_enable,
  11518. .bus_vote_bw = tasha_codec_vote_max_bw,
  11519. .cpe_err_irq_control = tasha_cpe_err_irq_control,
  11520. };
  11521. static struct cpe_svc_init_param cpe_svc_params = {
  11522. .version = CPE_SVC_INIT_PARAM_V1,
  11523. .query_freq_plans_cb = tasha_cdc_query_cpe_clk_plan,
  11524. .change_freq_plan_cb = tasha_cdc_change_cpe_clk,
  11525. };
  11526. static int tasha_cpe_initialize(struct snd_soc_codec *codec)
  11527. {
  11528. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11529. struct wcd_cpe_params cpe_params;
  11530. memset(&cpe_params, 0,
  11531. sizeof(struct wcd_cpe_params));
  11532. cpe_params.codec = codec;
  11533. cpe_params.get_cpe_core = tasha_codec_get_cpe_core;
  11534. cpe_params.cdc_cb = &cpe_cb;
  11535. cpe_params.dbg_mode = cpe_debug_mode;
  11536. cpe_params.cdc_major_ver = CPE_SVC_CODEC_WCD9335;
  11537. cpe_params.cdc_minor_ver = CPE_SVC_CODEC_V1P0;
  11538. cpe_params.cdc_id = CPE_SVC_CODEC_WCD9335;
  11539. cpe_params.cdc_irq_info.cpe_engine_irq =
  11540. WCD9335_IRQ_SVA_OUTBOX1;
  11541. cpe_params.cdc_irq_info.cpe_err_irq =
  11542. WCD9335_IRQ_SVA_ERROR;
  11543. cpe_params.cdc_irq_info.cpe_fatal_irqs =
  11544. TASHA_CPE_FATAL_IRQS;
  11545. cpe_svc_params.context = codec;
  11546. cpe_params.cpe_svc_params = &cpe_svc_params;
  11547. tasha->cpe_core = wcd_cpe_init("cpe_9335", codec,
  11548. &cpe_params);
  11549. if (IS_ERR_OR_NULL(tasha->cpe_core)) {
  11550. dev_err(codec->dev,
  11551. "%s: Failed to enable CPE\n",
  11552. __func__);
  11553. return -EINVAL;
  11554. }
  11555. return 0;
  11556. }
  11557. static const struct wcd_resmgr_cb tasha_resmgr_cb = {
  11558. .cdc_rco_ctrl = __tasha_codec_internal_rco_ctrl,
  11559. };
  11560. static int tasha_device_down(struct wcd9xxx *wcd9xxx)
  11561. {
  11562. struct snd_soc_codec *codec;
  11563. struct tasha_priv *priv;
  11564. int count;
  11565. int i = 0;
  11566. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11567. priv = snd_soc_codec_get_drvdata(codec);
  11568. wcd_cpe_ssr_event(priv->cpe_core, WCD_CPE_BUS_DOWN_EVENT);
  11569. for (i = 0; i < priv->nr; i++)
  11570. swrm_wcd_notify(priv->swr_ctrl_data[i].swr_pdev,
  11571. SWR_DEVICE_DOWN, NULL);
  11572. snd_soc_card_change_online_state(codec->component.card, 0);
  11573. for (count = 0; count < NUM_CODEC_DAIS; count++)
  11574. priv->dai[count].bus_down_in_recovery = true;
  11575. priv->resmgr->sido_input_src = SIDO_SOURCE_INTERNAL;
  11576. return 0;
  11577. }
  11578. static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx)
  11579. {
  11580. int i, ret = 0;
  11581. struct wcd9xxx *control;
  11582. struct snd_soc_codec *codec;
  11583. struct tasha_priv *tasha;
  11584. struct wcd9xxx_pdata *pdata;
  11585. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11586. tasha = snd_soc_codec_get_drvdata(codec);
  11587. control = dev_get_drvdata(codec->dev->parent);
  11588. wcd9xxx_set_power_state(tasha->wcd9xxx,
  11589. WCD_REGION_POWER_COLLAPSE_REMOVE,
  11590. WCD9XXX_DIG_CORE_REGION_1);
  11591. mutex_lock(&tasha->codec_mutex);
  11592. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11593. control->slim_slave->laddr;
  11594. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11595. control->slim->laddr;
  11596. tasha_init_slim_slave_cfg(codec);
  11597. if (tasha->machine_codec_event_cb)
  11598. tasha->machine_codec_event_cb(codec,
  11599. WCD9335_CODEC_EVENT_CODEC_UP);
  11600. snd_soc_card_change_online_state(codec->component.card, 1);
  11601. /* Class-H Init*/
  11602. wcd_clsh_init(&tasha->clsh_d);
  11603. for (i = 0; i < TASHA_MAX_MICBIAS; i++)
  11604. tasha->micb_ref[i] = 0;
  11605. tasha_update_reg_defaults(tasha);
  11606. tasha->codec = codec;
  11607. dev_dbg(codec->dev, "%s: MCLK Rate = %x\n",
  11608. __func__, control->mclk_rate);
  11609. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  11610. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11611. 0x03, 0x00);
  11612. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  11613. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11614. 0x03, 0x01);
  11615. tasha_codec_init_reg(codec);
  11616. wcd_resmgr_post_ssr_v2(tasha->resmgr);
  11617. tasha_enable_efuse_sensing(codec);
  11618. regcache_mark_dirty(codec->component.regmap);
  11619. regcache_sync(codec->component.regmap);
  11620. pdata = dev_get_platdata(codec->dev->parent);
  11621. ret = tasha_handle_pdata(tasha, pdata);
  11622. if (ret < 0)
  11623. dev_err(codec->dev, "%s: invalid pdata\n", __func__);
  11624. /* Reset reference counter for voting for max bw */
  11625. tasha->ref_count = 0;
  11626. /* MBHC Init */
  11627. wcd_mbhc_deinit(&tasha->mbhc);
  11628. tasha->mbhc_started = false;
  11629. /* Initialize MBHC module */
  11630. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11631. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11632. if (ret)
  11633. dev_err(codec->dev, "%s: mbhc initialization failed\n",
  11634. __func__);
  11635. else
  11636. tasha_mbhc_hs_detect(codec, tasha->mbhc.mbhc_cfg);
  11637. tasha_cleanup_irqs(tasha);
  11638. ret = tasha_setup_irqs(tasha);
  11639. if (ret) {
  11640. dev_err(codec->dev, "%s: tasha irq setup failed %d\n",
  11641. __func__, ret);
  11642. goto err;
  11643. }
  11644. tasha_set_spkr_mode(codec, tasha->spkr_mode);
  11645. wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT);
  11646. err:
  11647. mutex_unlock(&tasha->codec_mutex);
  11648. return ret;
  11649. }
  11650. static struct regulator *tasha_codec_find_ondemand_regulator(
  11651. struct snd_soc_codec *codec, const char *name)
  11652. {
  11653. int i;
  11654. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11655. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11656. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  11657. for (i = 0; i < wcd9xxx->num_of_supplies; ++i) {
  11658. if (pdata->regulator[i].ondemand &&
  11659. wcd9xxx->supplies[i].supply &&
  11660. !strcmp(wcd9xxx->supplies[i].supply, name))
  11661. return wcd9xxx->supplies[i].consumer;
  11662. }
  11663. dev_dbg(tasha->dev, "Warning: regulator not found:%s\n",
  11664. name);
  11665. return NULL;
  11666. }
  11667. static int tasha_codec_probe(struct snd_soc_codec *codec)
  11668. {
  11669. struct wcd9xxx *control;
  11670. struct tasha_priv *tasha;
  11671. struct wcd9xxx_pdata *pdata;
  11672. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  11673. int i, ret;
  11674. void *ptr = NULL;
  11675. struct regulator *supply;
  11676. control = dev_get_drvdata(codec->dev->parent);
  11677. dev_info(codec->dev, "%s()\n", __func__);
  11678. tasha = snd_soc_codec_get_drvdata(codec);
  11679. tasha->intf_type = wcd9xxx_get_intf_type();
  11680. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11681. control->dev_down = tasha_device_down;
  11682. control->post_reset = tasha_post_reset_cb;
  11683. control->ssr_priv = (void *)codec;
  11684. }
  11685. /* Resource Manager post Init */
  11686. ret = wcd_resmgr_post_init(tasha->resmgr, &tasha_resmgr_cb, codec);
  11687. if (ret) {
  11688. dev_err(codec->dev, "%s: wcd resmgr post init failed\n",
  11689. __func__);
  11690. goto err;
  11691. }
  11692. /* Class-H Init*/
  11693. wcd_clsh_init(&tasha->clsh_d);
  11694. /* Default HPH Mode to Class-H HiFi */
  11695. tasha->hph_mode = CLS_H_HIFI;
  11696. tasha->codec = codec;
  11697. for (i = 0; i < COMPANDER_MAX; i++)
  11698. tasha->comp_enabled[i] = 0;
  11699. tasha->spkr_gain_offset = RX_GAIN_OFFSET_0_DB;
  11700. tasha->intf_type = wcd9xxx_get_intf_type();
  11701. tasha_update_reg_reset_values(codec);
  11702. pr_debug("%s: MCLK Rate = %x\n", __func__, control->mclk_rate);
  11703. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  11704. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11705. 0x03, 0x00);
  11706. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  11707. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11708. 0x03, 0x01);
  11709. tasha_codec_init_reg(codec);
  11710. tasha_enable_efuse_sensing(codec);
  11711. pdata = dev_get_platdata(codec->dev->parent);
  11712. ret = tasha_handle_pdata(tasha, pdata);
  11713. if (ret < 0) {
  11714. pr_err("%s: bad pdata\n", __func__);
  11715. goto err;
  11716. }
  11717. supply = tasha_codec_find_ondemand_regulator(codec,
  11718. on_demand_supply_name[ON_DEMAND_MICBIAS]);
  11719. if (supply) {
  11720. tasha->on_demand_list[ON_DEMAND_MICBIAS].supply = supply;
  11721. tasha->on_demand_list[ON_DEMAND_MICBIAS].ondemand_supply_count =
  11722. 0;
  11723. }
  11724. tasha->fw_data = devm_kzalloc(codec->dev,
  11725. sizeof(*(tasha->fw_data)), GFP_KERNEL);
  11726. if (!tasha->fw_data)
  11727. goto err;
  11728. set_bit(WCD9XXX_ANC_CAL, tasha->fw_data->cal_bit);
  11729. set_bit(WCD9XXX_MBHC_CAL, tasha->fw_data->cal_bit);
  11730. set_bit(WCD9XXX_MAD_CAL, tasha->fw_data->cal_bit);
  11731. set_bit(WCD9XXX_VBAT_CAL, tasha->fw_data->cal_bit);
  11732. ret = wcd_cal_create_hwdep(tasha->fw_data,
  11733. WCD9XXX_CODEC_HWDEP_NODE, codec);
  11734. if (ret < 0) {
  11735. dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret);
  11736. goto err_hwdep;
  11737. }
  11738. /* Initialize MBHC module */
  11739. if (TASHA_IS_2_0(tasha->wcd9xxx)) {
  11740. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].reg =
  11741. WCD9335_MBHC_FSM_STATUS;
  11742. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].mask = 0x01;
  11743. }
  11744. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11745. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11746. if (ret) {
  11747. pr_err("%s: mbhc initialization failed\n", __func__);
  11748. goto err_hwdep;
  11749. }
  11750. ptr = devm_kzalloc(codec->dev, (sizeof(tasha_rx_chs) +
  11751. sizeof(tasha_tx_chs)), GFP_KERNEL);
  11752. if (!ptr) {
  11753. ret = -ENOMEM;
  11754. goto err_hwdep;
  11755. }
  11756. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  11757. snd_soc_dapm_new_controls(dapm, tasha_dapm_i2s_widgets,
  11758. ARRAY_SIZE(tasha_dapm_i2s_widgets));
  11759. snd_soc_dapm_add_routes(dapm, audio_i2s_map,
  11760. ARRAY_SIZE(audio_i2s_map));
  11761. for (i = 0; i < ARRAY_SIZE(tasha_i2s_dai); i++) {
  11762. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11763. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11764. }
  11765. } else if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11766. for (i = 0; i < NUM_CODEC_DAIS; i++) {
  11767. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11768. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11769. }
  11770. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11771. control->slim_slave->laddr;
  11772. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11773. control->slim->laddr;
  11774. tasha_slimbus_slave_port_cfg.slave_port_mapping[0] =
  11775. TASHA_TX13;
  11776. tasha_init_slim_slave_cfg(codec);
  11777. }
  11778. snd_soc_add_codec_controls(codec, impedance_detect_controls,
  11779. ARRAY_SIZE(impedance_detect_controls));
  11780. snd_soc_add_codec_controls(codec, hph_type_detect_controls,
  11781. ARRAY_SIZE(hph_type_detect_controls));
  11782. snd_soc_add_codec_controls(codec,
  11783. tasha_analog_gain_controls,
  11784. ARRAY_SIZE(tasha_analog_gain_controls));
  11785. control->num_rx_port = TASHA_RX_MAX;
  11786. control->rx_chs = ptr;
  11787. memcpy(control->rx_chs, tasha_rx_chs, sizeof(tasha_rx_chs));
  11788. control->num_tx_port = TASHA_TX_MAX;
  11789. control->tx_chs = ptr + sizeof(tasha_rx_chs);
  11790. memcpy(control->tx_chs, tasha_tx_chs, sizeof(tasha_tx_chs));
  11791. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Playback");
  11792. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Capture");
  11793. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Playback");
  11794. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Capture");
  11795. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11796. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Playback");
  11797. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Capture");
  11798. snd_soc_dapm_ignore_suspend(dapm, "AIF4 Playback");
  11799. snd_soc_dapm_ignore_suspend(dapm, "AIF Mix Playback");
  11800. snd_soc_dapm_ignore_suspend(dapm, "AIF4 MAD TX");
  11801. snd_soc_dapm_ignore_suspend(dapm, "VIfeed");
  11802. snd_soc_dapm_ignore_suspend(dapm, "AIF5 CPE TX");
  11803. }
  11804. snd_soc_dapm_sync(dapm);
  11805. ret = tasha_setup_irqs(tasha);
  11806. if (ret) {
  11807. pr_err("%s: tasha irq setup failed %d\n", __func__, ret);
  11808. goto err_pdata;
  11809. }
  11810. ret = tasha_cpe_initialize(codec);
  11811. if (ret) {
  11812. dev_err(codec->dev,
  11813. "%s: cpe initialization failed, err = %d\n",
  11814. __func__, ret);
  11815. /* Do not fail probe if CPE failed */
  11816. ret = 0;
  11817. }
  11818. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11819. tasha->tx_hpf_work[i].tasha = tasha;
  11820. tasha->tx_hpf_work[i].decimator = i;
  11821. INIT_DELAYED_WORK(&tasha->tx_hpf_work[i].dwork,
  11822. tasha_tx_hpf_corner_freq_callback);
  11823. }
  11824. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11825. tasha->tx_mute_dwork[i].tasha = tasha;
  11826. tasha->tx_mute_dwork[i].decimator = i;
  11827. INIT_DELAYED_WORK(&tasha->tx_mute_dwork[i].dwork,
  11828. tasha_tx_mute_update_callback);
  11829. }
  11830. tasha->spk_anc_dwork.tasha = tasha;
  11831. INIT_DELAYED_WORK(&tasha->spk_anc_dwork.dwork,
  11832. tasha_spk_anc_update_callback);
  11833. mutex_lock(&tasha->codec_mutex);
  11834. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  11835. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  11836. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  11837. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  11838. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  11839. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  11840. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  11841. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  11842. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  11843. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  11844. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  11845. mutex_unlock(&tasha->codec_mutex);
  11846. snd_soc_dapm_sync(dapm);
  11847. return ret;
  11848. err_pdata:
  11849. devm_kfree(codec->dev, ptr);
  11850. control->rx_chs = NULL;
  11851. control->tx_chs = NULL;
  11852. err_hwdep:
  11853. devm_kfree(codec->dev, tasha->fw_data);
  11854. tasha->fw_data = NULL;
  11855. err:
  11856. return ret;
  11857. }
  11858. static int tasha_codec_remove(struct snd_soc_codec *codec)
  11859. {
  11860. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11861. struct wcd9xxx *control;
  11862. control = dev_get_drvdata(codec->dev->parent);
  11863. control->rx_chs = NULL;
  11864. control->tx_chs = NULL;
  11865. tasha_cleanup_irqs(tasha);
  11866. /* Cleanup MBHC */
  11867. /* Cleanup resmgr */
  11868. return 0;
  11869. }
  11870. static struct regmap *tasha_get_regmap(struct device *dev)
  11871. {
  11872. struct wcd9xxx *control = dev_get_drvdata(dev->parent);
  11873. return control->regmap;
  11874. }
  11875. static struct snd_soc_codec_driver soc_codec_dev_tasha = {
  11876. .probe = tasha_codec_probe,
  11877. .remove = tasha_codec_remove,
  11878. .get_regmap = tasha_get_regmap,
  11879. .component_driver = {
  11880. .controls = tasha_snd_controls,
  11881. .num_controls = ARRAY_SIZE(tasha_snd_controls),
  11882. .dapm_widgets = tasha_dapm_widgets,
  11883. .num_dapm_widgets = ARRAY_SIZE(tasha_dapm_widgets),
  11884. .dapm_routes = audio_map,
  11885. .num_dapm_routes = ARRAY_SIZE(audio_map),
  11886. },
  11887. };
  11888. #ifdef CONFIG_PM
  11889. static int tasha_suspend(struct device *dev)
  11890. {
  11891. struct platform_device *pdev = to_platform_device(dev);
  11892. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  11893. dev_dbg(dev, "%s: system suspend\n", __func__);
  11894. if (cancel_delayed_work_sync(&tasha->power_gate_work))
  11895. tasha_codec_power_gate_digital_core(tasha);
  11896. return 0;
  11897. }
  11898. static int tasha_resume(struct device *dev)
  11899. {
  11900. struct platform_device *pdev = to_platform_device(dev);
  11901. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  11902. if (!tasha) {
  11903. dev_err(dev, "%s: tasha private data is NULL\n", __func__);
  11904. return -EINVAL;
  11905. }
  11906. dev_dbg(dev, "%s: system resume\n", __func__);
  11907. return 0;
  11908. }
  11909. static const struct dev_pm_ops tasha_pm_ops = {
  11910. .suspend = tasha_suspend,
  11911. .resume = tasha_resume,
  11912. };
  11913. #endif
  11914. static int tasha_swrm_read(void *handle, int reg)
  11915. {
  11916. struct tasha_priv *tasha;
  11917. struct wcd9xxx *wcd9xxx;
  11918. unsigned short swr_rd_addr_base;
  11919. unsigned short swr_rd_data_base;
  11920. int val, ret;
  11921. if (!handle) {
  11922. pr_err("%s: NULL handle\n", __func__);
  11923. return -EINVAL;
  11924. }
  11925. tasha = (struct tasha_priv *)handle;
  11926. wcd9xxx = tasha->wcd9xxx;
  11927. dev_dbg(tasha->dev, "%s: Reading soundwire register, 0x%x\n",
  11928. __func__, reg);
  11929. swr_rd_addr_base = WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0;
  11930. swr_rd_data_base = WCD9335_SWR_AHB_BRIDGE_RD_DATA_0;
  11931. /* read_lock */
  11932. mutex_lock(&tasha->swr_read_lock);
  11933. ret = regmap_bulk_write(wcd9xxx->regmap, swr_rd_addr_base,
  11934. (u8 *)&reg, 4);
  11935. if (ret < 0) {
  11936. pr_err("%s: RD Addr Failure\n", __func__);
  11937. goto err;
  11938. }
  11939. /* Check for RD status */
  11940. ret = regmap_bulk_read(wcd9xxx->regmap, swr_rd_data_base,
  11941. (u8 *)&val, 4);
  11942. if (ret < 0) {
  11943. pr_err("%s: RD Data Failure\n", __func__);
  11944. goto err;
  11945. }
  11946. ret = val;
  11947. err:
  11948. /* read_unlock */
  11949. mutex_unlock(&tasha->swr_read_lock);
  11950. return ret;
  11951. }
  11952. static int tasha_swrm_i2s_bulk_write(struct wcd9xxx *wcd9xxx,
  11953. struct wcd9xxx_reg_val *bulk_reg,
  11954. size_t len)
  11955. {
  11956. int i, ret = 0;
  11957. unsigned short swr_wr_addr_base;
  11958. unsigned short swr_wr_data_base;
  11959. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  11960. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  11961. for (i = 0; i < (len * 2); i += 2) {
  11962. /* First Write the Data to register */
  11963. ret = regmap_bulk_write(wcd9xxx->regmap,
  11964. swr_wr_data_base, bulk_reg[i].buf, 4);
  11965. if (ret < 0) {
  11966. dev_err(wcd9xxx->dev, "%s: WR Data Failure\n",
  11967. __func__);
  11968. break;
  11969. }
  11970. /* Next Write Address */
  11971. ret = regmap_bulk_write(wcd9xxx->regmap,
  11972. swr_wr_addr_base, bulk_reg[i+1].buf, 4);
  11973. if (ret < 0) {
  11974. dev_err(wcd9xxx->dev, "%s: WR Addr Failure\n",
  11975. __func__);
  11976. break;
  11977. }
  11978. }
  11979. return ret;
  11980. }
  11981. static int tasha_swrm_bulk_write(void *handle, u32 *reg, u32 *val, size_t len)
  11982. {
  11983. struct tasha_priv *tasha;
  11984. struct wcd9xxx *wcd9xxx;
  11985. struct wcd9xxx_reg_val *bulk_reg;
  11986. unsigned short swr_wr_addr_base;
  11987. unsigned short swr_wr_data_base;
  11988. int i, j, ret;
  11989. if (!handle) {
  11990. pr_err("%s: NULL handle\n", __func__);
  11991. return -EINVAL;
  11992. }
  11993. if (len <= 0) {
  11994. pr_err("%s: Invalid size: %zu\n", __func__, len);
  11995. return -EINVAL;
  11996. }
  11997. tasha = (struct tasha_priv *)handle;
  11998. wcd9xxx = tasha->wcd9xxx;
  11999. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12000. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12001. bulk_reg = kzalloc((2 * len * sizeof(struct wcd9xxx_reg_val)),
  12002. GFP_KERNEL);
  12003. if (!bulk_reg)
  12004. return -ENOMEM;
  12005. for (i = 0, j = 0; i < (len * 2); i += 2, j++) {
  12006. bulk_reg[i].reg = swr_wr_data_base;
  12007. bulk_reg[i].buf = (u8 *)(&val[j]);
  12008. bulk_reg[i].bytes = 4;
  12009. bulk_reg[i+1].reg = swr_wr_addr_base;
  12010. bulk_reg[i+1].buf = (u8 *)(&reg[j]);
  12011. bulk_reg[i+1].bytes = 4;
  12012. }
  12013. mutex_lock(&tasha->swr_write_lock);
  12014. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12015. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, len);
  12016. if (ret) {
  12017. dev_err(tasha->dev, "%s: i2s bulk write failed, ret: %d\n",
  12018. __func__, ret);
  12019. }
  12020. } else {
  12021. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg,
  12022. (len * 2), false);
  12023. if (ret) {
  12024. dev_err(tasha->dev, "%s: swrm bulk write failed, ret: %d\n",
  12025. __func__, ret);
  12026. }
  12027. }
  12028. mutex_unlock(&tasha->swr_write_lock);
  12029. kfree(bulk_reg);
  12030. return ret;
  12031. }
  12032. static int tasha_swrm_write(void *handle, int reg, int val)
  12033. {
  12034. struct tasha_priv *tasha;
  12035. struct wcd9xxx *wcd9xxx;
  12036. unsigned short swr_wr_addr_base;
  12037. unsigned short swr_wr_data_base;
  12038. struct wcd9xxx_reg_val bulk_reg[2];
  12039. int ret;
  12040. if (!handle) {
  12041. pr_err("%s: NULL handle\n", __func__);
  12042. return -EINVAL;
  12043. }
  12044. tasha = (struct tasha_priv *)handle;
  12045. wcd9xxx = tasha->wcd9xxx;
  12046. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12047. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12048. /* First Write the Data to register */
  12049. bulk_reg[0].reg = swr_wr_data_base;
  12050. bulk_reg[0].buf = (u8 *)(&val);
  12051. bulk_reg[0].bytes = 4;
  12052. bulk_reg[1].reg = swr_wr_addr_base;
  12053. bulk_reg[1].buf = (u8 *)(&reg);
  12054. bulk_reg[1].bytes = 4;
  12055. mutex_lock(&tasha->swr_write_lock);
  12056. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12057. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, 1);
  12058. if (ret) {
  12059. dev_err(tasha->dev, "%s: i2s swrm write failed, ret: %d\n",
  12060. __func__, ret);
  12061. }
  12062. } else {
  12063. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2, false);
  12064. if (ret < 0)
  12065. pr_err("%s: WR Data Failure\n", __func__);
  12066. }
  12067. mutex_unlock(&tasha->swr_write_lock);
  12068. return ret;
  12069. }
  12070. static int tasha_swrm_clock(void *handle, bool enable)
  12071. {
  12072. struct tasha_priv *tasha = (struct tasha_priv *) handle;
  12073. mutex_lock(&tasha->swr_clk_lock);
  12074. dev_dbg(tasha->dev, "%s: swrm clock %s\n",
  12075. __func__, (enable?"enable" : "disable"));
  12076. if (enable) {
  12077. tasha->swr_clk_users++;
  12078. if (tasha->swr_clk_users == 1) {
  12079. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12080. regmap_update_bits(
  12081. tasha->wcd9xxx->regmap,
  12082. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12083. 0x10, 0x00);
  12084. __tasha_cdc_mclk_enable(tasha, true);
  12085. regmap_update_bits(tasha->wcd9xxx->regmap,
  12086. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12087. 0x01, 0x01);
  12088. }
  12089. } else {
  12090. tasha->swr_clk_users--;
  12091. if (tasha->swr_clk_users == 0) {
  12092. regmap_update_bits(tasha->wcd9xxx->regmap,
  12093. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12094. 0x01, 0x00);
  12095. __tasha_cdc_mclk_enable(tasha, false);
  12096. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12097. regmap_update_bits(
  12098. tasha->wcd9xxx->regmap,
  12099. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12100. 0x10, 0x10);
  12101. }
  12102. }
  12103. dev_dbg(tasha->dev, "%s: swrm clock users %d\n",
  12104. __func__, tasha->swr_clk_users);
  12105. mutex_unlock(&tasha->swr_clk_lock);
  12106. return 0;
  12107. }
  12108. static int tasha_swrm_handle_irq(void *handle,
  12109. irqreturn_t (*swrm_irq_handler)(int irq,
  12110. void *data),
  12111. void *swrm_handle,
  12112. int action)
  12113. {
  12114. struct tasha_priv *tasha;
  12115. int ret = 0;
  12116. struct wcd9xxx *wcd9xxx;
  12117. if (!handle) {
  12118. pr_err("%s: null handle received\n", __func__);
  12119. return -EINVAL;
  12120. }
  12121. tasha = (struct tasha_priv *) handle;
  12122. wcd9xxx = tasha->wcd9xxx;
  12123. if (action) {
  12124. ret = wcd9xxx_request_irq(&wcd9xxx->core_res,
  12125. WCD9335_IRQ_SOUNDWIRE,
  12126. swrm_irq_handler,
  12127. "Tasha SWR Master", swrm_handle);
  12128. if (ret)
  12129. dev_err(tasha->dev, "%s: Failed to request irq %d\n",
  12130. __func__, WCD9335_IRQ_SOUNDWIRE);
  12131. } else
  12132. wcd9xxx_free_irq(&wcd9xxx->core_res, WCD9335_IRQ_SOUNDWIRE,
  12133. swrm_handle);
  12134. return ret;
  12135. }
  12136. static void tasha_add_child_devices(struct work_struct *work)
  12137. {
  12138. struct tasha_priv *tasha;
  12139. struct platform_device *pdev;
  12140. struct device_node *node;
  12141. struct wcd9xxx *wcd9xxx;
  12142. struct tasha_swr_ctrl_data *swr_ctrl_data = NULL, *temp;
  12143. int ret, ctrl_num = 0;
  12144. struct wcd_swr_ctrl_platform_data *platdata;
  12145. char plat_dev_name[WCD9335_STRING_LEN];
  12146. tasha = container_of(work, struct tasha_priv,
  12147. tasha_add_child_devices_work);
  12148. if (!tasha) {
  12149. pr_err("%s: Memory for WCD9335 does not exist\n",
  12150. __func__);
  12151. return;
  12152. }
  12153. wcd9xxx = tasha->wcd9xxx;
  12154. if (!wcd9xxx) {
  12155. pr_err("%s: Memory for WCD9XXX does not exist\n",
  12156. __func__);
  12157. return;
  12158. }
  12159. if (!wcd9xxx->dev->of_node) {
  12160. pr_err("%s: DT node for wcd9xxx does not exist\n",
  12161. __func__);
  12162. return;
  12163. }
  12164. platdata = &tasha->swr_plat_data;
  12165. for_each_child_of_node(wcd9xxx->dev->of_node, node) {
  12166. if (!strcmp(node->name, "swr_master"))
  12167. strlcpy(plat_dev_name, "tasha_swr_ctrl",
  12168. (WCD9335_STRING_LEN - 1));
  12169. else if (strnstr(node->name, "msm_cdc_pinctrl",
  12170. strlen("msm_cdc_pinctrl")) != NULL)
  12171. strlcpy(plat_dev_name, node->name,
  12172. (WCD9335_STRING_LEN - 1));
  12173. else
  12174. continue;
  12175. pdev = platform_device_alloc(plat_dev_name, -1);
  12176. if (!pdev) {
  12177. dev_err(wcd9xxx->dev, "%s: pdev memory alloc failed\n",
  12178. __func__);
  12179. ret = -ENOMEM;
  12180. goto err;
  12181. }
  12182. pdev->dev.parent = tasha->dev;
  12183. pdev->dev.of_node = node;
  12184. if (!strcmp(node->name, "swr_master")) {
  12185. ret = platform_device_add_data(pdev, platdata,
  12186. sizeof(*platdata));
  12187. if (ret) {
  12188. dev_err(&pdev->dev,
  12189. "%s: cannot add plat data ctrl:%d\n",
  12190. __func__, ctrl_num);
  12191. goto fail_pdev_add;
  12192. }
  12193. }
  12194. ret = platform_device_add(pdev);
  12195. if (ret) {
  12196. dev_err(&pdev->dev,
  12197. "%s: Cannot add platform device\n",
  12198. __func__);
  12199. goto fail_pdev_add;
  12200. }
  12201. if (!strcmp(node->name, "swr_master")) {
  12202. temp = krealloc(swr_ctrl_data,
  12203. (ctrl_num + 1) * sizeof(
  12204. struct tasha_swr_ctrl_data),
  12205. GFP_KERNEL);
  12206. if (!temp) {
  12207. dev_err(wcd9xxx->dev, "out of memory\n");
  12208. ret = -ENOMEM;
  12209. goto err;
  12210. }
  12211. swr_ctrl_data = temp;
  12212. swr_ctrl_data[ctrl_num].swr_pdev = pdev;
  12213. ctrl_num++;
  12214. dev_dbg(&pdev->dev,
  12215. "%s: Added soundwire ctrl device(s)\n",
  12216. __func__);
  12217. tasha->nr = ctrl_num;
  12218. tasha->swr_ctrl_data = swr_ctrl_data;
  12219. }
  12220. }
  12221. return;
  12222. fail_pdev_add:
  12223. platform_device_put(pdev);
  12224. err:
  12225. return;
  12226. }
  12227. /*
  12228. * tasha_codec_ver: to get tasha codec version
  12229. * @codec: handle to snd_soc_codec *
  12230. * return enum codec_variant - version
  12231. */
  12232. enum codec_variant tasha_codec_ver(void)
  12233. {
  12234. return codec_ver;
  12235. }
  12236. EXPORT_SYMBOL(tasha_codec_ver);
  12237. static int __tasha_enable_efuse_sensing(struct tasha_priv *tasha)
  12238. {
  12239. int val, rc;
  12240. __tasha_cdc_mclk_enable(tasha, true);
  12241. regmap_update_bits(tasha->wcd9xxx->regmap,
  12242. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x1E, 0x20);
  12243. regmap_update_bits(tasha->wcd9xxx->regmap,
  12244. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x01, 0x01);
  12245. /*
  12246. * 5ms sleep required after enabling efuse control
  12247. * before checking the status.
  12248. */
  12249. usleep_range(5000, 5500);
  12250. rc = regmap_read(tasha->wcd9xxx->regmap,
  12251. WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS, &val);
  12252. if (rc || (!(val & 0x01)))
  12253. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  12254. __tasha_cdc_mclk_enable(tasha, false);
  12255. return rc;
  12256. }
  12257. void tasha_get_codec_ver(struct tasha_priv *tasha)
  12258. {
  12259. int i;
  12260. int val;
  12261. struct tasha_reg_mask_val codec_reg[] = {
  12262. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10, 0xFF, 0xFF},
  12263. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11, 0xFF, 0x83},
  12264. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12, 0xFF, 0x0A},
  12265. };
  12266. __tasha_enable_efuse_sensing(tasha);
  12267. for (i = 0; i < ARRAY_SIZE(codec_reg); i++) {
  12268. regmap_read(tasha->wcd9xxx->regmap, codec_reg[i].reg, &val);
  12269. if (!(val && codec_reg[i].val)) {
  12270. codec_ver = WCD9335;
  12271. goto ret;
  12272. }
  12273. }
  12274. codec_ver = WCD9326;
  12275. ret:
  12276. pr_debug("%s: codec is %d\n", __func__, codec_ver);
  12277. }
  12278. EXPORT_SYMBOL(tasha_get_codec_ver);
  12279. static int tasha_probe(struct platform_device *pdev)
  12280. {
  12281. int ret = 0;
  12282. struct tasha_priv *tasha;
  12283. struct clk *wcd_ext_clk, *wcd_native_clk;
  12284. struct wcd9xxx_resmgr_v2 *resmgr;
  12285. struct wcd9xxx_power_region *cdc_pwr;
  12286. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12287. if (apr_get_subsys_state() == APR_SUBSYS_DOWN) {
  12288. dev_err(&pdev->dev, "%s: dsp down\n", __func__);
  12289. return -EPROBE_DEFER;
  12290. }
  12291. }
  12292. tasha = devm_kzalloc(&pdev->dev, sizeof(struct tasha_priv),
  12293. GFP_KERNEL);
  12294. if (!tasha)
  12295. return -ENOMEM;
  12296. platform_set_drvdata(pdev, tasha);
  12297. tasha->wcd9xxx = dev_get_drvdata(pdev->dev.parent);
  12298. tasha->dev = &pdev->dev;
  12299. INIT_DELAYED_WORK(&tasha->power_gate_work, tasha_codec_power_gate_work);
  12300. mutex_init(&tasha->power_lock);
  12301. mutex_init(&tasha->sido_lock);
  12302. INIT_WORK(&tasha->tasha_add_child_devices_work,
  12303. tasha_add_child_devices);
  12304. BLOCKING_INIT_NOTIFIER_HEAD(&tasha->notifier);
  12305. mutex_init(&tasha->micb_lock);
  12306. mutex_init(&tasha->swr_read_lock);
  12307. mutex_init(&tasha->swr_write_lock);
  12308. mutex_init(&tasha->swr_clk_lock);
  12309. mutex_init(&tasha->sb_clk_gear_lock);
  12310. mutex_init(&tasha->mclk_lock);
  12311. cdc_pwr = devm_kzalloc(&pdev->dev, sizeof(struct wcd9xxx_power_region),
  12312. GFP_KERNEL);
  12313. if (!cdc_pwr) {
  12314. ret = -ENOMEM;
  12315. goto err_cdc_pwr;
  12316. }
  12317. tasha->wcd9xxx->wcd9xxx_pwr[WCD9XXX_DIG_CORE_REGION_1] = cdc_pwr;
  12318. cdc_pwr->pwr_collapse_reg_min = TASHA_DIG_CORE_REG_MIN;
  12319. cdc_pwr->pwr_collapse_reg_max = TASHA_DIG_CORE_REG_MAX;
  12320. wcd9xxx_set_power_state(tasha->wcd9xxx,
  12321. WCD_REGION_POWER_COLLAPSE_REMOVE,
  12322. WCD9XXX_DIG_CORE_REGION_1);
  12323. mutex_init(&tasha->codec_mutex);
  12324. /*
  12325. * Init resource manager so that if child nodes such as SoundWire
  12326. * requests for clock, resource manager can honor the request
  12327. */
  12328. resmgr = wcd_resmgr_init(&tasha->wcd9xxx->core_res, NULL);
  12329. if (IS_ERR(resmgr)) {
  12330. ret = PTR_ERR(resmgr);
  12331. dev_err(&pdev->dev, "%s: Failed to initialize wcd resmgr\n",
  12332. __func__);
  12333. goto err_resmgr;
  12334. }
  12335. tasha->resmgr = resmgr;
  12336. tasha->swr_plat_data.handle = (void *) tasha;
  12337. tasha->swr_plat_data.read = tasha_swrm_read;
  12338. tasha->swr_plat_data.write = tasha_swrm_write;
  12339. tasha->swr_plat_data.bulk_write = tasha_swrm_bulk_write;
  12340. tasha->swr_plat_data.clk = tasha_swrm_clock;
  12341. tasha->swr_plat_data.handle_irq = tasha_swrm_handle_irq;
  12342. /* Register for Clock */
  12343. wcd_ext_clk = clk_get(tasha->wcd9xxx->dev, "wcd_clk");
  12344. if (IS_ERR(wcd_ext_clk)) {
  12345. dev_err(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12346. __func__, "wcd_ext_clk");
  12347. goto err_clk;
  12348. }
  12349. tasha->wcd_ext_clk = wcd_ext_clk;
  12350. tasha->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV;
  12351. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  12352. tasha->sido_ccl_cnt = 0;
  12353. /* Register native clk for 44.1 playback */
  12354. wcd_native_clk = clk_get(tasha->wcd9xxx->dev, "wcd_native_clk");
  12355. if (IS_ERR(wcd_native_clk))
  12356. dev_dbg(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12357. __func__, "wcd_native_clk");
  12358. else
  12359. tasha->wcd_native_clk = wcd_native_clk;
  12360. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  12361. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12362. tasha_dai, ARRAY_SIZE(tasha_dai));
  12363. else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
  12364. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12365. tasha_i2s_dai,
  12366. ARRAY_SIZE(tasha_i2s_dai));
  12367. else
  12368. ret = -EINVAL;
  12369. if (ret) {
  12370. dev_err(&pdev->dev, "%s: Codec registration failed, ret = %d\n",
  12371. __func__, ret);
  12372. goto err_cdc_reg;
  12373. }
  12374. /* Update codec register default values */
  12375. tasha_update_reg_defaults(tasha);
  12376. schedule_work(&tasha->tasha_add_child_devices_work);
  12377. tasha_get_codec_ver(tasha);
  12378. dev_info(&pdev->dev, "%s: Tasha driver probe done\n", __func__);
  12379. return ret;
  12380. err_cdc_reg:
  12381. clk_put(tasha->wcd_ext_clk);
  12382. if (tasha->wcd_native_clk)
  12383. clk_put(tasha->wcd_native_clk);
  12384. err_clk:
  12385. wcd_resmgr_remove(tasha->resmgr);
  12386. err_resmgr:
  12387. devm_kfree(&pdev->dev, cdc_pwr);
  12388. err_cdc_pwr:
  12389. mutex_destroy(&tasha->mclk_lock);
  12390. devm_kfree(&pdev->dev, tasha);
  12391. return ret;
  12392. }
  12393. static int tasha_remove(struct platform_device *pdev)
  12394. {
  12395. struct tasha_priv *tasha;
  12396. tasha = platform_get_drvdata(pdev);
  12397. mutex_destroy(&tasha->codec_mutex);
  12398. clk_put(tasha->wcd_ext_clk);
  12399. if (tasha->wcd_native_clk)
  12400. clk_put(tasha->wcd_native_clk);
  12401. mutex_destroy(&tasha->mclk_lock);
  12402. devm_kfree(&pdev->dev, tasha);
  12403. snd_soc_unregister_codec(&pdev->dev);
  12404. mutex_destroy(&tasha->sb_clk_gear_lock);
  12405. return 0;
  12406. }
  12407. static struct platform_driver tasha_codec_driver = {
  12408. .probe = tasha_probe,
  12409. .remove = tasha_remove,
  12410. .driver = {
  12411. .name = "tasha_codec",
  12412. .owner = THIS_MODULE,
  12413. #ifdef CONFIG_PM
  12414. .pm = &tasha_pm_ops,
  12415. #endif
  12416. },
  12417. };
  12418. module_platform_driver(tasha_codec_driver);
  12419. MODULE_DESCRIPTION("Tasha Codec driver");
  12420. MODULE_LICENSE("GPL v2");