wcd9335.c 455 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/module.h>
  6. #include <linux/init.h>
  7. #include <linux/firmware.h>
  8. #include <linux/slab.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/device.h>
  11. #include <linux/printk.h>
  12. #include <linux/ratelimit.h>
  13. #include <linux/debugfs.h>
  14. #include <linux/wait.h>
  15. #include <linux/bitops.h>
  16. #include <linux/regmap.h>
  17. #include <linux/regulator/consumer.h>
  18. #include <linux/clk.h>
  19. #include <linux/delay.h>
  20. #include <linux/pm_runtime.h>
  21. #include <linux/kernel.h>
  22. #include <linux/gpio.h>
  23. #include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
  24. #include <soc/swr-wcd.h>
  25. #include <sound/pcm.h>
  26. #include <sound/pcm_params.h>
  27. #include <sound/soc.h>
  28. #include <sound/soc-dapm.h>
  29. #include <sound/tlv.h>
  30. #include <sound/info.h>
  31. #include <asoc/core.h>
  32. #include <asoc/pdata.h>
  33. #include "wcd9335.h"
  34. #include <asoc/wcd-mbhc-v2.h>
  35. #include <asoc/wcd9xxx-common-v2.h>
  36. #include <asoc/wcd9xxx-resmgr-v2.h>
  37. #include <asoc/wcd9xxx-irq.h>
  38. #include "wcd9335_registers.h"
  39. #include "wcd9335_irq.h"
  40. #include "wcd_cpe_core.h"
  41. #include <asoc/wcdcal-hwdep.h>
  42. #include <asoc/wcd-mbhc-v2-api.h>
  43. #define DRV_NAME "tasha_codec"
  44. #define TASHA_RX_PORT_START_NUMBER 16
  45. #define WCD9335_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
  46. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
  47. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  48. /* Fractional Rates */
  49. #define WCD9335_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100)
  50. #define WCD9335_MIX_RATES_MASK (SNDRV_PCM_RATE_48000 |\
  51. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  52. #define TASHA_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  53. SNDRV_PCM_FMTBIT_S24_LE | \
  54. SNDRV_PCM_FMTBIT_S24_3LE)
  55. #define TASHA_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  56. SNDRV_PCM_FMTBIT_S24_LE | \
  57. SNDRV_PCM_FMTBIT_S24_3LE | \
  58. SNDRV_PCM_FMTBIT_S32_LE)
  59. #define TASHA_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
  60. /*
  61. * Timeout in milli seconds and it is the wait time for
  62. * slim channel removal interrupt to receive.
  63. */
  64. #define TASHA_SLIM_CLOSE_TIMEOUT 1000
  65. #define TASHA_SLIM_IRQ_OVERFLOW (1 << 0)
  66. #define TASHA_SLIM_IRQ_UNDERFLOW (1 << 1)
  67. #define TASHA_SLIM_IRQ_PORT_CLOSED (1 << 2)
  68. #define TASHA_MCLK_CLK_12P288MHZ 12288000
  69. #define TASHA_MCLK_CLK_9P6MHZ 9600000
  70. #define TASHA_SLIM_PGD_PORT_INT_TX_EN0 (TASHA_SLIM_PGD_PORT_INT_EN0 + 2)
  71. #define TASHA_NUM_INTERPOLATORS 9
  72. #define TASHA_NUM_DECIMATORS 9
  73. #define WCD9335_CHILD_DEVICES_MAX 6
  74. #define BYTE_BIT_MASK(nr) (1 << ((nr) % BITS_PER_BYTE))
  75. #define TASHA_MAD_AUDIO_FIRMWARE_PATH "wcd9335/wcd9335_mad_audio.bin"
  76. #define TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS (1 << 0)
  77. #define TASHA_CPE_SS_ERR_STATUS_WDOG_BITE (1 << 1)
  78. #define TASHA_CPE_FATAL_IRQS \
  79. (TASHA_CPE_SS_ERR_STATUS_WDOG_BITE | \
  80. TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS)
  81. #define SLIM_BW_CLK_GEAR_9 6200000
  82. #define SLIM_BW_UNVOTE 0
  83. #define CPE_FLL_CLK_75MHZ 75000000
  84. #define CPE_FLL_CLK_150MHZ 150000000
  85. #define WCD9335_REG_BITS 8
  86. #define WCD9335_MAX_VALID_ADC_MUX 13
  87. #define WCD9335_INVALID_ADC_MUX 9
  88. #define TASHA_DIG_CORE_REG_MIN WCD9335_CDC_ANC0_CLK_RESET_CTL
  89. #define TASHA_DIG_CORE_REG_MAX 0xDFF
  90. /* Convert from vout ctl to micbias voltage in mV */
  91. #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
  92. #define TASHA_ZDET_NUM_MEASUREMENTS 900
  93. #define TASHA_MBHC_GET_C1(c) ((c & 0xC000) >> 14)
  94. #define TASHA_MBHC_GET_X1(x) (x & 0x3FFF)
  95. /* z value compared in milliOhm */
  96. #define TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000))
  97. #define TASHA_MBHC_ZDET_CONST (86 * 16384)
  98. #define TASHA_MBHC_MOISTURE_VREF V_45_MV
  99. #define TASHA_MBHC_MOISTURE_IREF I_3P0_UA
  100. #define TASHA_VERSION_ENTRY_SIZE 17
  101. #define WCD9335_AMIC_PWR_LEVEL_LP 0
  102. #define WCD9335_AMIC_PWR_LEVEL_DEFAULT 1
  103. #define WCD9335_AMIC_PWR_LEVEL_HP 2
  104. #define WCD9335_AMIC_PWR_LVL_MASK 0x60
  105. #define WCD9335_AMIC_PWR_LVL_SHIFT 0x5
  106. #define WCD9335_DEC_PWR_LVL_MASK 0x06
  107. #define WCD9335_DEC_PWR_LVL_LP 0x02
  108. #define WCD9335_DEC_PWR_LVL_HP 0x04
  109. #define WCD9335_DEC_PWR_LVL_DF 0x00
  110. #define WCD9335_STRING_LEN 100
  111. #define CALCULATE_VOUT_D(req_mv) (((req_mv - 650) * 10) / 25)
  112. static int cpe_debug_mode;
  113. #define TASHA_MAX_MICBIAS 4
  114. #define DAPM_MICBIAS1_STANDALONE "MIC BIAS1 Standalone"
  115. #define DAPM_MICBIAS2_STANDALONE "MIC BIAS2 Standalone"
  116. #define DAPM_MICBIAS3_STANDALONE "MIC BIAS3 Standalone"
  117. #define DAPM_MICBIAS4_STANDALONE "MIC BIAS4 Standalone"
  118. #define DAPM_LDO_H_STANDALONE "LDO_H"
  119. module_param(cpe_debug_mode, int, 0664);
  120. MODULE_PARM_DESC(cpe_debug_mode, "boot cpe in debug mode");
  121. #define TASHA_DIG_CORE_COLLAPSE_TIMER_MS (5 * 1000)
  122. #define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH 64
  123. static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = {
  124. "cdc-vdd-mic-bias",
  125. "cdc-vdd-tx-h",
  126. "cdc-vdd-rx-h"
  127. };
  128. enum {
  129. POWER_COLLAPSE,
  130. POWER_RESUME,
  131. };
  132. enum tasha_sido_voltage {
  133. SIDO_VOLTAGE_SVS_MV = 950,
  134. SIDO_VOLTAGE_NOMINAL_MV = 1100,
  135. };
  136. static enum codec_variant codec_ver;
  137. static int dig_core_collapse_enable = 1;
  138. module_param(dig_core_collapse_enable, int, 0664);
  139. MODULE_PARM_DESC(dig_core_collapse_enable, "enable/disable power gating");
  140. /* dig_core_collapse timer in seconds */
  141. static int dig_core_collapse_timer = (TASHA_DIG_CORE_COLLAPSE_TIMER_MS/1000);
  142. module_param(dig_core_collapse_timer, int, 0664);
  143. MODULE_PARM_DESC(dig_core_collapse_timer, "timer for power gating");
  144. /* SVS Scaling enable/disable */
  145. static int svs_scaling_enabled = 1;
  146. module_param(svs_scaling_enabled, int, 0664);
  147. MODULE_PARM_DESC(svs_scaling_enabled, "enable/disable svs scaling");
  148. /* SVS buck setting */
  149. static int sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  150. module_param(sido_buck_svs_voltage, int, 0664);
  151. MODULE_PARM_DESC(sido_buck_svs_voltage,
  152. "setting for SVS voltage for SIDO BUCK");
  153. #define TASHA_TX_UNMUTE_DELAY_MS 40
  154. static int tx_unmute_delay = TASHA_TX_UNMUTE_DELAY_MS;
  155. module_param(tx_unmute_delay, int, 0664);
  156. MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path");
  157. static struct afe_param_slimbus_slave_port_cfg tasha_slimbus_slave_port_cfg = {
  158. .minor_version = 1,
  159. .slimbus_dev_id = AFE_SLIMBUS_DEVICE_1,
  160. .slave_dev_pgd_la = 0,
  161. .slave_dev_intfdev_la = 0,
  162. .bit_width = 16,
  163. .data_format = 0,
  164. .num_channels = 1
  165. };
  166. struct tasha_mbhc_zdet_param {
  167. u16 ldo_ctl;
  168. u16 noff;
  169. u16 nshift;
  170. u16 btn5;
  171. u16 btn6;
  172. u16 btn7;
  173. };
  174. static struct afe_param_cdc_reg_page_cfg tasha_cdc_reg_page_cfg = {
  175. .minor_version = AFE_API_VERSION_CDC_REG_PAGE_CFG,
  176. .enable = 1,
  177. .proc_id = AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_1,
  178. };
  179. static struct afe_param_cdc_reg_cfg audio_reg_cfg[] = {
  180. {
  181. 1,
  182. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_MAIN_CTL_1),
  183. HW_MAD_AUDIO_ENABLE, 0x1, WCD9335_REG_BITS, 0
  184. },
  185. {
  186. 1,
  187. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_3),
  188. HW_MAD_AUDIO_SLEEP_TIME, 0xF, WCD9335_REG_BITS, 0
  189. },
  190. {
  191. 1,
  192. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_4),
  193. HW_MAD_TX_AUDIO_SWITCH_OFF, 0x1, WCD9335_REG_BITS, 0
  194. },
  195. {
  196. 1,
  197. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  198. MAD_AUDIO_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  199. },
  200. {
  201. 1,
  202. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  203. MAD_AUDIO_INT_MASK_REG, 0x1, WCD9335_REG_BITS, 0
  204. },
  205. {
  206. 1,
  207. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  208. MAD_AUDIO_INT_STATUS_REG, 0x1, WCD9335_REG_BITS, 0
  209. },
  210. {
  211. 1,
  212. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  213. MAD_AUDIO_INT_CLEAR_REG, 0x1, WCD9335_REG_BITS, 0
  214. },
  215. {
  216. 1,
  217. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  218. VBAT_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  219. },
  220. {
  221. 1,
  222. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  223. VBAT_INT_MASK_REG, 0x08, WCD9335_REG_BITS, 0
  224. },
  225. {
  226. 1,
  227. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  228. VBAT_INT_STATUS_REG, 0x08, WCD9335_REG_BITS, 0
  229. },
  230. {
  231. 1,
  232. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  233. VBAT_INT_CLEAR_REG, 0x08, WCD9335_REG_BITS, 0
  234. },
  235. {
  236. 1,
  237. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  238. VBAT_RELEASE_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  239. },
  240. {
  241. 1,
  242. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  243. VBAT_RELEASE_INT_MASK_REG, 0x10, WCD9335_REG_BITS, 0
  244. },
  245. {
  246. 1,
  247. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  248. VBAT_RELEASE_INT_STATUS_REG, 0x10, WCD9335_REG_BITS, 0
  249. },
  250. {
  251. 1,
  252. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  253. VBAT_RELEASE_INT_CLEAR_REG, 0x10, WCD9335_REG_BITS, 0
  254. },
  255. {
  256. 1,
  257. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  258. SB_PGD_PORT_TX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  259. },
  260. {
  261. 1,
  262. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  263. SB_PGD_PORT_TX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  264. },
  265. {
  266. 1,
  267. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  268. SB_PGD_PORT_RX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  269. },
  270. {
  271. 1,
  272. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  273. SB_PGD_PORT_RX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  274. },
  275. { 1,
  276. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  277. AANC_FF_GAIN_ADAPTIVE, 0x4, WCD9335_REG_BITS, 0
  278. },
  279. { 1,
  280. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  281. AANC_FFGAIN_ADAPTIVE_EN, 0x8, WCD9335_REG_BITS, 0
  282. },
  283. {
  284. 1,
  285. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_FF_A_GAIN_CTL),
  286. AANC_GAIN_CONTROL, 0xFF, WCD9335_REG_BITS, 0
  287. },
  288. };
  289. static struct afe_param_cdc_reg_cfg_data tasha_audio_reg_cfg = {
  290. .num_registers = ARRAY_SIZE(audio_reg_cfg),
  291. .reg_data = audio_reg_cfg,
  292. };
  293. static struct afe_param_id_cdc_aanc_version tasha_cdc_aanc_version = {
  294. .cdc_aanc_minor_version = AFE_API_VERSION_CDC_AANC_VERSION,
  295. .aanc_hw_version = AANC_HW_BLOCK_VERSION_2,
  296. };
  297. enum {
  298. VI_SENSE_1,
  299. VI_SENSE_2,
  300. AIF4_SWITCH_VALUE,
  301. AUDIO_NOMINAL,
  302. CPE_NOMINAL,
  303. HPH_PA_DELAY,
  304. ANC_MIC_AMIC1,
  305. ANC_MIC_AMIC2,
  306. ANC_MIC_AMIC3,
  307. ANC_MIC_AMIC4,
  308. ANC_MIC_AMIC5,
  309. ANC_MIC_AMIC6,
  310. CLASSH_CONFIG,
  311. };
  312. enum {
  313. AIF1_PB = 0,
  314. AIF1_CAP,
  315. AIF2_PB,
  316. AIF2_CAP,
  317. AIF3_PB,
  318. AIF3_CAP,
  319. AIF4_PB,
  320. AIF_MIX1_PB,
  321. AIF4_MAD_TX,
  322. AIF4_VIFEED,
  323. AIF5_CPE_TX,
  324. NUM_CODEC_DAIS,
  325. };
  326. enum {
  327. INTn_1_MIX_INP_SEL_ZERO = 0,
  328. INTn_1_MIX_INP_SEL_DEC0,
  329. INTn_1_MIX_INP_SEL_DEC1,
  330. INTn_1_MIX_INP_SEL_IIR0,
  331. INTn_1_MIX_INP_SEL_IIR1,
  332. INTn_1_MIX_INP_SEL_RX0,
  333. INTn_1_MIX_INP_SEL_RX1,
  334. INTn_1_MIX_INP_SEL_RX2,
  335. INTn_1_MIX_INP_SEL_RX3,
  336. INTn_1_MIX_INP_SEL_RX4,
  337. INTn_1_MIX_INP_SEL_RX5,
  338. INTn_1_MIX_INP_SEL_RX6,
  339. INTn_1_MIX_INP_SEL_RX7,
  340. };
  341. #define IS_VALID_NATIVE_FIFO_PORT(inp) \
  342. ((inp >= INTn_1_MIX_INP_SEL_RX0) && \
  343. (inp <= INTn_1_MIX_INP_SEL_RX3))
  344. enum {
  345. INTn_2_INP_SEL_ZERO = 0,
  346. INTn_2_INP_SEL_RX0,
  347. INTn_2_INP_SEL_RX1,
  348. INTn_2_INP_SEL_RX2,
  349. INTn_2_INP_SEL_RX3,
  350. INTn_2_INP_SEL_RX4,
  351. INTn_2_INP_SEL_RX5,
  352. INTn_2_INP_SEL_RX6,
  353. INTn_2_INP_SEL_RX7,
  354. INTn_2_INP_SEL_PROXIMITY,
  355. };
  356. enum {
  357. INTERP_EAR = 0,
  358. INTERP_HPHL,
  359. INTERP_HPHR,
  360. INTERP_LO1,
  361. INTERP_LO2,
  362. INTERP_LO3,
  363. INTERP_LO4,
  364. INTERP_SPKR1,
  365. INTERP_SPKR2,
  366. };
  367. struct interp_sample_rate {
  368. int sample_rate;
  369. int rate_val;
  370. };
  371. static struct interp_sample_rate int_prim_sample_rate_val[] = {
  372. {8000, 0x0}, /* 8K */
  373. {16000, 0x1}, /* 16K */
  374. {24000, -EINVAL},/* 24K */
  375. {32000, 0x3}, /* 32K */
  376. {48000, 0x4}, /* 48K */
  377. {96000, 0x5}, /* 96K */
  378. {192000, 0x6}, /* 192K */
  379. {384000, 0x7}, /* 384K */
  380. {44100, 0x8}, /* 44.1K */
  381. };
  382. static struct interp_sample_rate int_mix_sample_rate_val[] = {
  383. {48000, 0x4}, /* 48K */
  384. {96000, 0x5}, /* 96K */
  385. {192000, 0x6}, /* 192K */
  386. };
  387. static const struct wcd9xxx_ch tasha_rx_chs[TASHA_RX_MAX] = {
  388. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER, 0),
  389. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 1, 1),
  390. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 2, 2),
  391. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 3, 3),
  392. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 4, 4),
  393. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 5, 5),
  394. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 6, 6),
  395. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 7, 7),
  396. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 8, 8),
  397. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 9, 9),
  398. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 10, 10),
  399. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 11, 11),
  400. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 12, 12),
  401. };
  402. static const struct wcd9xxx_ch tasha_tx_chs[TASHA_TX_MAX] = {
  403. WCD9XXX_CH(0, 0),
  404. WCD9XXX_CH(1, 1),
  405. WCD9XXX_CH(2, 2),
  406. WCD9XXX_CH(3, 3),
  407. WCD9XXX_CH(4, 4),
  408. WCD9XXX_CH(5, 5),
  409. WCD9XXX_CH(6, 6),
  410. WCD9XXX_CH(7, 7),
  411. WCD9XXX_CH(8, 8),
  412. WCD9XXX_CH(9, 9),
  413. WCD9XXX_CH(10, 10),
  414. WCD9XXX_CH(11, 11),
  415. WCD9XXX_CH(12, 12),
  416. WCD9XXX_CH(13, 13),
  417. WCD9XXX_CH(14, 14),
  418. WCD9XXX_CH(15, 15),
  419. };
  420. static const u32 vport_slim_check_table[NUM_CODEC_DAIS] = {
  421. /* Needs to define in the same order of DAI enum definitions */
  422. 0,
  423. BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  424. 0,
  425. BIT(AIF1_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  426. 0,
  427. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  428. 0,
  429. 0,
  430. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF5_CPE_TX),
  431. 0,
  432. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX),
  433. };
  434. static const u32 vport_i2s_check_table[NUM_CODEC_DAIS] = {
  435. 0, /* AIF1_PB */
  436. BIT(AIF2_CAP), /* AIF1_CAP */
  437. 0, /* AIF2_PB */
  438. BIT(AIF1_CAP), /* AIF2_CAP */
  439. };
  440. /* Codec supports 2 IIR filters */
  441. enum {
  442. IIR0 = 0,
  443. IIR1,
  444. IIR_MAX,
  445. };
  446. /* Each IIR has 5 Filter Stages */
  447. enum {
  448. BAND1 = 0,
  449. BAND2,
  450. BAND3,
  451. BAND4,
  452. BAND5,
  453. BAND_MAX,
  454. };
  455. enum {
  456. COMPANDER_1, /* HPH_L */
  457. COMPANDER_2, /* HPH_R */
  458. COMPANDER_3, /* LO1_DIFF */
  459. COMPANDER_4, /* LO2_DIFF */
  460. COMPANDER_5, /* LO3_SE */
  461. COMPANDER_6, /* LO4_SE */
  462. COMPANDER_7, /* SWR SPK CH1 */
  463. COMPANDER_8, /* SWR SPK CH2 */
  464. COMPANDER_MAX,
  465. };
  466. enum {
  467. SRC_IN_HPHL,
  468. SRC_IN_LO1,
  469. SRC_IN_HPHR,
  470. SRC_IN_LO2,
  471. SRC_IN_SPKRL,
  472. SRC_IN_LO3,
  473. SRC_IN_SPKRR,
  474. SRC_IN_LO4,
  475. };
  476. enum {
  477. SPLINE_SRC0,
  478. SPLINE_SRC1,
  479. SPLINE_SRC2,
  480. SPLINE_SRC3,
  481. SPLINE_SRC_MAX,
  482. };
  483. static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
  484. static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
  485. static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
  486. static struct snd_soc_dai_driver tasha_dai[];
  487. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv);
  488. static int tasha_config_compander(struct snd_soc_component *, int, int);
  489. static void tasha_codec_set_tx_hold(struct snd_soc_component *, u16, bool);
  490. static int tasha_codec_internal_rco_ctrl(struct snd_soc_component *component,
  491. bool enable);
  492. /* Hold instance to soundwire platform device */
  493. struct tasha_swr_ctrl_data {
  494. struct platform_device *swr_pdev;
  495. struct ida swr_ida;
  496. };
  497. struct wcd_swr_ctrl_platform_data {
  498. void *handle; /* holds codec private data */
  499. int (*read)(void *handle, int reg);
  500. int (*write)(void *handle, int reg, int val);
  501. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  502. int (*clk)(void *handle, bool enable);
  503. int (*handle_irq)(void *handle,
  504. irqreturn_t (*swrm_irq_handler)(int irq,
  505. void *data),
  506. void *swrm_handle,
  507. int action);
  508. };
  509. static struct wcd_mbhc_register
  510. wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = {
  511. WCD_MBHC_REGISTER("WCD_MBHC_L_DET_EN",
  512. WCD9335_ANA_MBHC_MECH, 0x80, 7, 0),
  513. WCD_MBHC_REGISTER("WCD_MBHC_GND_DET_EN",
  514. WCD9335_ANA_MBHC_MECH, 0x40, 6, 0),
  515. WCD_MBHC_REGISTER("WCD_MBHC_MECH_DETECTION_TYPE",
  516. WCD9335_ANA_MBHC_MECH, 0x20, 5, 0),
  517. WCD_MBHC_REGISTER("WCD_MBHC_MIC_CLAMP_CTL",
  518. WCD9335_MBHC_PLUG_DETECT_CTL, 0x30, 4, 0),
  519. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_DETECTION_TYPE",
  520. WCD9335_ANA_MBHC_ELECT, 0x08, 3, 0),
  521. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_CTRL",
  522. WCD9335_MBHC_PLUG_DETECT_CTL, 0xC0, 6, 0),
  523. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL",
  524. WCD9335_ANA_MBHC_MECH, 0x04, 2, 0),
  525. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PLUG_TYPE",
  526. WCD9335_ANA_MBHC_MECH, 0x10, 4, 0),
  527. WCD_MBHC_REGISTER("WCD_MBHC_GND_PLUG_TYPE",
  528. WCD9335_ANA_MBHC_MECH, 0x08, 3, 0),
  529. WCD_MBHC_REGISTER("WCD_MBHC_SW_HPH_LP_100K_TO_GND",
  530. WCD9335_ANA_MBHC_MECH, 0x01, 0, 0),
  531. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_SCHMT_ISRC",
  532. WCD9335_ANA_MBHC_ELECT, 0x06, 1, 0),
  533. WCD_MBHC_REGISTER("WCD_MBHC_FSM_EN",
  534. WCD9335_ANA_MBHC_ELECT, 0x80, 7, 0),
  535. WCD_MBHC_REGISTER("WCD_MBHC_INSREM_DBNC",
  536. WCD9335_MBHC_PLUG_DETECT_CTL, 0x0F, 0, 0),
  537. WCD_MBHC_REGISTER("WCD_MBHC_BTN_DBNC",
  538. WCD9335_MBHC_CTL_1, 0x03, 0, 0),
  539. WCD_MBHC_REGISTER("WCD_MBHC_HS_VREF",
  540. WCD9335_MBHC_CTL_2, 0x03, 0, 0),
  541. WCD_MBHC_REGISTER("WCD_MBHC_HS_COMP_RESULT",
  542. WCD9335_ANA_MBHC_RESULT_3, 0x08, 3, 0),
  543. WCD_MBHC_REGISTER("WCD_MBHC_IN2P_CLAMP_STATE",
  544. WCD9335_ANA_MBHC_RESULT_3, 0x10, 4, 0),
  545. WCD_MBHC_REGISTER("WCD_MBHC_MIC_SCHMT_RESULT",
  546. WCD9335_ANA_MBHC_RESULT_3, 0x20, 5, 0),
  547. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_SCHMT_RESULT",
  548. WCD9335_ANA_MBHC_RESULT_3, 0x80, 7, 0),
  549. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_SCHMT_RESULT",
  550. WCD9335_ANA_MBHC_RESULT_3, 0x40, 6, 0),
  551. WCD_MBHC_REGISTER("WCD_MBHC_OCP_FSM_EN",
  552. WCD9335_HPH_OCP_CTL, 0x10, 4, 0),
  553. WCD_MBHC_REGISTER("WCD_MBHC_BTN_RESULT",
  554. WCD9335_ANA_MBHC_RESULT_3, 0x07, 0, 0),
  555. WCD_MBHC_REGISTER("WCD_MBHC_BTN_ISRC_CTL",
  556. WCD9335_ANA_MBHC_ELECT, 0x70, 4, 0),
  557. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_RESULT",
  558. WCD9335_ANA_MBHC_RESULT_3, 0xFF, 0, 0),
  559. WCD_MBHC_REGISTER("WCD_MBHC_MICB_CTRL",
  560. WCD9335_ANA_MICB2, 0xC0, 6, 0),
  561. WCD_MBHC_REGISTER("WCD_MBHC_HPH_CNP_WG_TIME",
  562. WCD9335_HPH_CNP_WG_TIME, 0xFF, 0, 0),
  563. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_PA_EN",
  564. WCD9335_ANA_HPH, 0x40, 6, 0),
  565. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PA_EN",
  566. WCD9335_ANA_HPH, 0x80, 7, 0),
  567. WCD_MBHC_REGISTER("WCD_MBHC_HPH_PA_EN",
  568. WCD9335_ANA_HPH, 0xC0, 6, 0),
  569. WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE",
  570. WCD9335_ANA_MBHC_RESULT_3, 0x10, 4, 0),
  571. WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL",
  572. 0, 0, 0, 0),
  573. WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN",
  574. WCD9335_ANA_MBHC_ZDET, 0x01, 0, 0),
  575. /*
  576. * MBHC FSM status register is only available in Tasha 2.0.
  577. * So, init with 0 later once the version is known, then values
  578. * will be updated.
  579. */
  580. WCD_MBHC_REGISTER("WCD_MBHC_FSM_STATUS",
  581. 0, 0, 0, 0),
  582. WCD_MBHC_REGISTER("WCD_MBHC_MUX_CTL",
  583. WCD9335_MBHC_CTL_2, 0x70, 4, 0),
  584. WCD_MBHC_REGISTER("WCD_MBHC_MOISTURE_STATUS",
  585. WCD9335_MBHC_FSM_STATUS, 0X20, 5, 0),
  586. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_GND",
  587. WCD9335_HPH_PA_CTL2, 0x40, 6, 0),
  588. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_GND",
  589. WCD9335_HPH_PA_CTL2, 0x10, 4, 0),
  590. };
  591. static const struct wcd_mbhc_intr intr_ids = {
  592. .mbhc_sw_intr = WCD9335_IRQ_MBHC_SW_DET,
  593. .mbhc_btn_press_intr = WCD9335_IRQ_MBHC_BUTTON_PRESS_DET,
  594. .mbhc_btn_release_intr = WCD9335_IRQ_MBHC_BUTTON_RELEASE_DET,
  595. .mbhc_hs_ins_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
  596. .mbhc_hs_rem_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_DET,
  597. .hph_left_ocp = WCD9335_IRQ_HPH_PA_OCPL_FAULT,
  598. .hph_right_ocp = WCD9335_IRQ_HPH_PA_OCPR_FAULT,
  599. };
  600. struct wcd_vbat {
  601. bool is_enabled;
  602. bool adc_config;
  603. /* Variables to cache Vbat ADC output values */
  604. u16 dcp1;
  605. u16 dcp2;
  606. };
  607. struct hpf_work {
  608. struct tasha_priv *tasha;
  609. u8 decimator;
  610. u8 hpf_cut_off_freq;
  611. struct delayed_work dwork;
  612. };
  613. #define WCD9335_SPK_ANC_EN_DELAY_MS 350
  614. static int spk_anc_en_delay = WCD9335_SPK_ANC_EN_DELAY_MS;
  615. module_param(spk_anc_en_delay, int, 0664);
  616. MODULE_PARM_DESC(spk_anc_en_delay, "delay to enable anc in speaker path");
  617. struct spk_anc_work {
  618. struct tasha_priv *tasha;
  619. struct delayed_work dwork;
  620. };
  621. struct tx_mute_work {
  622. struct tasha_priv *tasha;
  623. u8 decimator;
  624. struct delayed_work dwork;
  625. };
  626. struct tasha_priv {
  627. struct device *dev;
  628. struct wcd9xxx *wcd9xxx;
  629. struct snd_soc_component *component;
  630. u32 adc_count;
  631. u32 rx_bias_count;
  632. s32 dmic_0_1_clk_cnt;
  633. s32 dmic_2_3_clk_cnt;
  634. s32 dmic_4_5_clk_cnt;
  635. s32 ldo_h_users;
  636. s32 micb_ref[TASHA_MAX_MICBIAS];
  637. s32 pullup_ref[TASHA_MAX_MICBIAS];
  638. u32 anc_slot;
  639. bool anc_func;
  640. bool is_wsa_attach;
  641. /* Vbat module */
  642. struct wcd_vbat vbat;
  643. /* cal info for codec */
  644. struct fw_info *fw_data;
  645. /*track tasha interface type*/
  646. u8 intf_type;
  647. /* num of slim ports required */
  648. struct wcd9xxx_codec_dai_data dai[NUM_CODEC_DAIS];
  649. /* SoundWire data structure */
  650. struct tasha_swr_ctrl_data *swr_ctrl_data;
  651. int nr;
  652. /*compander*/
  653. int comp_enabled[COMPANDER_MAX];
  654. /* Maintain the status of AUX PGA */
  655. int aux_pga_cnt;
  656. u8 aux_l_gain;
  657. u8 aux_r_gain;
  658. bool spkr_pa_widget_on;
  659. struct regulator *spkdrv_reg;
  660. struct regulator *spkdrv2_reg;
  661. bool mbhc_started;
  662. /* class h specific data */
  663. struct wcd_clsh_cdc_data clsh_d;
  664. struct afe_param_cdc_slimbus_slave_cfg slimbus_slave_cfg;
  665. /*
  666. * list used to save/restore registers at start and
  667. * end of impedance measurement
  668. */
  669. struct list_head reg_save_restore;
  670. /* handle to cpe core */
  671. struct wcd_cpe_core *cpe_core;
  672. u32 current_cpe_clk_freq;
  673. enum tasha_sido_voltage sido_voltage;
  674. int sido_ccl_cnt;
  675. u32 ana_rx_supplies;
  676. /* Multiplication factor used for impedance detection */
  677. int zdet_gain_mul_fact;
  678. /* to track the status */
  679. unsigned long status_mask;
  680. struct work_struct tasha_add_child_devices_work;
  681. struct wcd_swr_ctrl_platform_data swr_plat_data;
  682. /* Port values for Rx and Tx codec_dai */
  683. unsigned int rx_port_value[TASHA_RX_MAX];
  684. unsigned int tx_port_value;
  685. unsigned int vi_feed_value;
  686. /* Tasha Interpolator Mode Select for EAR, HPH_L and HPH_R */
  687. u32 hph_mode;
  688. u16 prim_int_users[TASHA_NUM_INTERPOLATORS];
  689. int spl_src_users[SPLINE_SRC_MAX];
  690. struct wcd9xxx_resmgr_v2 *resmgr;
  691. struct delayed_work power_gate_work;
  692. struct mutex power_lock;
  693. struct mutex sido_lock;
  694. /* mbhc module */
  695. struct wcd_mbhc mbhc;
  696. struct blocking_notifier_head notifier;
  697. struct mutex micb_lock;
  698. struct clk *wcd_ext_clk;
  699. struct clk *wcd_native_clk;
  700. struct mutex swr_read_lock;
  701. struct mutex swr_write_lock;
  702. struct mutex swr_clk_lock;
  703. int swr_clk_users;
  704. int native_clk_users;
  705. int (*zdet_gpio_cb)(struct snd_soc_component *component, bool high);
  706. struct snd_info_entry *entry;
  707. struct snd_info_entry *version_entry;
  708. int power_active_ref;
  709. struct on_demand_supply on_demand_list[ON_DEMAND_SUPPLIES_MAX];
  710. int (*machine_codec_event_cb)(struct snd_soc_component *component,
  711. enum wcd9335_codec_event);
  712. int spkr_gain_offset;
  713. int spkr_mode;
  714. int ear_spkr_gain;
  715. struct hpf_work tx_hpf_work[TASHA_NUM_DECIMATORS];
  716. struct tx_mute_work tx_mute_dwork[TASHA_NUM_DECIMATORS];
  717. struct spk_anc_work spk_anc_dwork;
  718. struct mutex codec_mutex;
  719. int hph_l_gain;
  720. int hph_r_gain;
  721. int rx_7_count;
  722. int rx_8_count;
  723. bool clk_mode;
  724. bool clk_internal;
  725. /* Lock to prevent multiple functions voting at same time */
  726. struct mutex sb_clk_gear_lock;
  727. /* Count for functions voting or un-voting */
  728. u32 ref_count;
  729. /* Lock to protect mclk enablement */
  730. struct mutex mclk_lock;
  731. struct platform_device *pdev_child_devices
  732. [WCD9335_CHILD_DEVICES_MAX];
  733. int child_count;
  734. };
  735. static int tasha_codec_vote_max_bw(struct snd_soc_component *component,
  736. bool vote);
  737. static const struct tasha_reg_mask_val tasha_spkr_default[] = {
  738. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  739. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  740. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  741. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  742. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x58},
  743. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x58},
  744. };
  745. static const struct tasha_reg_mask_val tasha_spkr_mode1[] = {
  746. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x00},
  747. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x00},
  748. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x00},
  749. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x00},
  750. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x44},
  751. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x44},
  752. };
  753. /**
  754. * tasha_set_spkr_gain_offset - offset the speaker path
  755. * gain with the given offset value.
  756. *
  757. * @component: codec component instance
  758. * @offset: Indicates speaker path gain offset value.
  759. *
  760. * Returns 0 on success or -EINVAL on error.
  761. */
  762. int tasha_set_spkr_gain_offset(struct snd_soc_component *component, int offset)
  763. {
  764. struct tasha_priv *priv = snd_soc_component_get_drvdata(component);
  765. if (!priv)
  766. return -EINVAL;
  767. priv->spkr_gain_offset = offset;
  768. return 0;
  769. }
  770. EXPORT_SYMBOL(tasha_set_spkr_gain_offset);
  771. /**
  772. * tasha_set_spkr_mode - Configures speaker compander and smartboost
  773. * settings based on speaker mode.
  774. *
  775. * @component: codec component instance
  776. * @mode: Indicates speaker configuration mode.
  777. *
  778. * Returns 0 on success or -EINVAL on error.
  779. */
  780. int tasha_set_spkr_mode(struct snd_soc_component *component, int mode)
  781. {
  782. struct tasha_priv *priv = snd_soc_component_get_drvdata(component);
  783. int i;
  784. const struct tasha_reg_mask_val *regs;
  785. int size;
  786. if (!priv)
  787. return -EINVAL;
  788. switch (mode) {
  789. case SPKR_MODE_1:
  790. regs = tasha_spkr_mode1;
  791. size = ARRAY_SIZE(tasha_spkr_mode1);
  792. break;
  793. default:
  794. regs = tasha_spkr_default;
  795. size = ARRAY_SIZE(tasha_spkr_default);
  796. break;
  797. }
  798. priv->spkr_mode = mode;
  799. for (i = 0; i < size; i++)
  800. snd_soc_component_update_bits(component, regs[i].reg,
  801. regs[i].mask, regs[i].val);
  802. return 0;
  803. }
  804. EXPORT_SYMBOL(tasha_set_spkr_mode);
  805. static void tasha_enable_sido_buck(struct snd_soc_component *component)
  806. {
  807. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  808. snd_soc_component_update_bits(component, WCD9335_ANA_RCO, 0x80, 0x80);
  809. snd_soc_component_update_bits(component, WCD9335_ANA_BUCK_CTL,
  810. 0x02, 0x02);
  811. /* 100us sleep needed after IREF settings */
  812. usleep_range(100, 110);
  813. snd_soc_component_update_bits(component, WCD9335_ANA_BUCK_CTL,
  814. 0x04, 0x04);
  815. /* 100us sleep needed after VREF settings */
  816. usleep_range(100, 110);
  817. tasha->resmgr->sido_input_src = SIDO_SOURCE_RCO_BG;
  818. }
  819. static void tasha_cdc_sido_ccl_enable(struct tasha_priv *tasha, bool ccl_flag)
  820. {
  821. struct snd_soc_component *component = tasha->component;
  822. if (!component)
  823. return;
  824. if (!TASHA_IS_2_0(tasha->wcd9xxx)) {
  825. dev_dbg(component->dev, "%s: tasha version < 2p0, return\n",
  826. __func__);
  827. return;
  828. }
  829. dev_dbg(component->dev, "%s: sido_ccl_cnt=%d, ccl_flag:%d\n",
  830. __func__, tasha->sido_ccl_cnt, ccl_flag);
  831. if (ccl_flag) {
  832. if (++tasha->sido_ccl_cnt == 1)
  833. snd_soc_component_update_bits(component,
  834. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x6E);
  835. } else {
  836. if (tasha->sido_ccl_cnt == 0) {
  837. dev_dbg(component->dev, "%s: sido_ccl already disabled\n",
  838. __func__);
  839. return;
  840. }
  841. if (--tasha->sido_ccl_cnt == 0)
  842. snd_soc_component_update_bits(component,
  843. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x02);
  844. }
  845. }
  846. static bool tasha_cdc_is_svs_enabled(struct tasha_priv *tasha)
  847. {
  848. if (TASHA_IS_2_0(tasha->wcd9xxx) &&
  849. svs_scaling_enabled)
  850. return true;
  851. return false;
  852. }
  853. static int tasha_cdc_req_mclk_enable(struct tasha_priv *tasha,
  854. bool enable)
  855. {
  856. int ret = 0;
  857. mutex_lock(&tasha->mclk_lock);
  858. if (enable) {
  859. tasha_cdc_sido_ccl_enable(tasha, true);
  860. ret = clk_prepare_enable(tasha->wcd_ext_clk);
  861. if (ret) {
  862. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  863. __func__);
  864. goto unlock_mutex;
  865. }
  866. /* get BG */
  867. wcd_resmgr_enable_master_bias(tasha->resmgr);
  868. /* get MCLK */
  869. wcd_resmgr_enable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  870. } else {
  871. /* put MCLK */
  872. wcd_resmgr_disable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  873. /* put BG */
  874. wcd_resmgr_disable_master_bias(tasha->resmgr);
  875. clk_disable_unprepare(tasha->wcd_ext_clk);
  876. tasha_cdc_sido_ccl_enable(tasha, false);
  877. }
  878. unlock_mutex:
  879. mutex_unlock(&tasha->mclk_lock);
  880. return ret;
  881. }
  882. static int tasha_cdc_check_sido_value(enum tasha_sido_voltage req_mv)
  883. {
  884. if ((req_mv != SIDO_VOLTAGE_SVS_MV) &&
  885. (req_mv != SIDO_VOLTAGE_NOMINAL_MV))
  886. return -EINVAL;
  887. return 0;
  888. }
  889. static void tasha_codec_apply_sido_voltage(
  890. struct tasha_priv *tasha,
  891. enum tasha_sido_voltage req_mv)
  892. {
  893. u32 vout_d_val;
  894. struct snd_soc_component *component = tasha->component;
  895. int ret;
  896. if (!component)
  897. return;
  898. if (!tasha_cdc_is_svs_enabled(tasha))
  899. return;
  900. if ((sido_buck_svs_voltage != SIDO_VOLTAGE_SVS_MV) &&
  901. (sido_buck_svs_voltage != SIDO_VOLTAGE_NOMINAL_MV))
  902. sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  903. ret = tasha_cdc_check_sido_value(req_mv);
  904. if (ret < 0) {
  905. dev_dbg(component->dev, "%s: requested mv=%d not in range\n",
  906. __func__, req_mv);
  907. return;
  908. }
  909. if (req_mv == tasha->sido_voltage) {
  910. dev_dbg(component->dev, "%s: Already at requested mv=%d\n",
  911. __func__, req_mv);
  912. return;
  913. }
  914. if (req_mv == sido_buck_svs_voltage) {
  915. if (test_bit(AUDIO_NOMINAL, &tasha->status_mask) ||
  916. test_bit(CPE_NOMINAL, &tasha->status_mask)) {
  917. dev_dbg(component->dev,
  918. "%s: nominal client running, status_mask=%lu\n",
  919. __func__, tasha->status_mask);
  920. return;
  921. }
  922. }
  923. /* compute the vout_d step value */
  924. vout_d_val = CALCULATE_VOUT_D(req_mv);
  925. snd_soc_component_write(component, WCD9335_ANA_BUCK_VOUT_D,
  926. vout_d_val & 0xFF);
  927. snd_soc_component_update_bits(component, WCD9335_ANA_BUCK_CTL,
  928. 0x80, 0x80);
  929. /* 1 msec sleep required after SIDO Vout_D voltage change */
  930. usleep_range(1000, 1100);
  931. tasha->sido_voltage = req_mv;
  932. dev_dbg(component->dev,
  933. "%s: updated SIDO buck Vout_D to %d, vout_d step = %u\n",
  934. __func__, tasha->sido_voltage, vout_d_val);
  935. snd_soc_component_update_bits(component, WCD9335_ANA_BUCK_CTL,
  936. 0x80, 0x00);
  937. }
  938. static int tasha_codec_update_sido_voltage(
  939. struct tasha_priv *tasha,
  940. enum tasha_sido_voltage req_mv)
  941. {
  942. int ret = 0;
  943. if (!tasha_cdc_is_svs_enabled(tasha))
  944. return ret;
  945. mutex_lock(&tasha->sido_lock);
  946. /* enable mclk before setting SIDO voltage */
  947. ret = tasha_cdc_req_mclk_enable(tasha, true);
  948. if (ret) {
  949. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  950. __func__);
  951. goto err;
  952. }
  953. tasha_codec_apply_sido_voltage(tasha, req_mv);
  954. tasha_cdc_req_mclk_enable(tasha, false);
  955. err:
  956. mutex_unlock(&tasha->sido_lock);
  957. return ret;
  958. }
  959. int tasha_enable_efuse_sensing(struct snd_soc_component *component)
  960. {
  961. struct tasha_priv *priv = snd_soc_component_get_drvdata(component);
  962. tasha_cdc_mclk_enable(component, true, false);
  963. if (!TASHA_IS_2_0(priv->wcd9xxx))
  964. snd_soc_component_update_bits(component,
  965. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  966. 0x1E, 0x02);
  967. snd_soc_component_update_bits(component,
  968. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  969. 0x01, 0x01);
  970. /*
  971. * 5ms sleep required after enabling efuse control
  972. * before checking the status.
  973. */
  974. usleep_range(5000, 5500);
  975. if (!(snd_soc_component_read32(
  976. component, WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01))
  977. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  978. if (TASHA_IS_2_0(priv->wcd9xxx)) {
  979. if (!(snd_soc_component_read32(component,
  980. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0) & 0x40))
  981. snd_soc_component_update_bits(component,
  982. WCD9335_HPH_R_ATEST,
  983. 0x04, 0x00);
  984. tasha_enable_sido_buck(component);
  985. }
  986. tasha_cdc_mclk_enable(component, false, false);
  987. return 0;
  988. }
  989. EXPORT_SYMBOL(tasha_enable_efuse_sensing);
  990. void *tasha_get_afe_config(struct snd_soc_component *component,
  991. enum afe_config_type config_type)
  992. {
  993. struct tasha_priv *priv = snd_soc_component_get_drvdata(component);
  994. switch (config_type) {
  995. case AFE_SLIMBUS_SLAVE_CONFIG:
  996. return &priv->slimbus_slave_cfg;
  997. case AFE_CDC_REGISTERS_CONFIG:
  998. return &tasha_audio_reg_cfg;
  999. case AFE_SLIMBUS_SLAVE_PORT_CONFIG:
  1000. return &tasha_slimbus_slave_port_cfg;
  1001. case AFE_AANC_VERSION:
  1002. return &tasha_cdc_aanc_version;
  1003. case AFE_CLIP_BANK_SEL:
  1004. return NULL;
  1005. case AFE_CDC_CLIP_REGISTERS_CONFIG:
  1006. return NULL;
  1007. case AFE_CDC_REGISTER_PAGE_CONFIG:
  1008. return &tasha_cdc_reg_page_cfg;
  1009. default:
  1010. dev_err(component->dev, "%s: Unknown config_type 0x%x\n",
  1011. __func__, config_type);
  1012. return NULL;
  1013. }
  1014. }
  1015. EXPORT_SYMBOL(tasha_get_afe_config);
  1016. /*
  1017. * tasha_event_register: Registers a machine driver callback
  1018. * function with codec private data for post ADSP sub-system
  1019. * restart (SSR). This callback function will be called from
  1020. * codec driver once codec comes out of reset after ADSP SSR.
  1021. *
  1022. * @machine_event_cb: callback function from machine driver
  1023. * @component: Codec component instance
  1024. *
  1025. * Return: none
  1026. */
  1027. void tasha_event_register(
  1028. int (*machine_event_cb)(struct snd_soc_component *component,
  1029. enum wcd9335_codec_event),
  1030. struct snd_soc_component *component)
  1031. {
  1032. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1033. if (tasha)
  1034. tasha->machine_codec_event_cb = machine_event_cb;
  1035. else
  1036. dev_dbg(component->dev, "%s: Invalid tasha_priv data\n",
  1037. __func__);
  1038. }
  1039. EXPORT_SYMBOL(tasha_event_register);
  1040. static int tasha_mbhc_request_irq(struct snd_soc_component *component,
  1041. int irq, irq_handler_t handler,
  1042. const char *name, void *data)
  1043. {
  1044. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1045. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1046. struct wcd9xxx_core_resource *core_res =
  1047. &wcd9xxx->core_res;
  1048. return wcd9xxx_request_irq(core_res, irq, handler, name, data);
  1049. }
  1050. static void tasha_mbhc_irq_control(struct snd_soc_component *component,
  1051. int irq, bool enable)
  1052. {
  1053. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1054. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1055. struct wcd9xxx_core_resource *core_res =
  1056. &wcd9xxx->core_res;
  1057. if (enable)
  1058. wcd9xxx_enable_irq(core_res, irq);
  1059. else
  1060. wcd9xxx_disable_irq(core_res, irq);
  1061. }
  1062. static int tasha_mbhc_free_irq(struct snd_soc_component *component,
  1063. int irq, void *data)
  1064. {
  1065. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1066. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1067. struct wcd9xxx_core_resource *core_res =
  1068. &wcd9xxx->core_res;
  1069. wcd9xxx_free_irq(core_res, irq, data);
  1070. return 0;
  1071. }
  1072. static void tasha_mbhc_clk_setup(struct snd_soc_component *component,
  1073. bool enable)
  1074. {
  1075. if (enable)
  1076. snd_soc_component_update_bits(component, WCD9335_MBHC_CTL_1,
  1077. 0x80, 0x80);
  1078. else
  1079. snd_soc_component_update_bits(component, WCD9335_MBHC_CTL_1,
  1080. 0x80, 0x00);
  1081. }
  1082. static int tasha_mbhc_btn_to_num(struct snd_soc_component *component)
  1083. {
  1084. return snd_soc_component_read32(
  1085. component, WCD9335_ANA_MBHC_RESULT_3) & 0x7;
  1086. }
  1087. static void tasha_mbhc_mbhc_bias_control(struct snd_soc_component *component,
  1088. bool enable)
  1089. {
  1090. if (enable)
  1091. snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_ELECT,
  1092. 0x01, 0x01);
  1093. else
  1094. snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_ELECT,
  1095. 0x01, 0x00);
  1096. }
  1097. static void tasha_mbhc_program_btn_thr(struct snd_soc_component *component,
  1098. s16 *btn_low, s16 *btn_high,
  1099. int num_btn, bool is_micbias)
  1100. {
  1101. int i;
  1102. int vth;
  1103. if (num_btn > WCD_MBHC_DEF_BUTTONS) {
  1104. dev_err(component->dev, "%s: invalid number of buttons: %d\n",
  1105. __func__, num_btn);
  1106. return;
  1107. }
  1108. /*
  1109. * Tasha just needs one set of thresholds for button detection
  1110. * due to micbias voltage ramp to pullup upon button press. So
  1111. * btn_low and is_micbias are ignored and always program button
  1112. * thresholds using btn_high.
  1113. */
  1114. for (i = 0; i < num_btn; i++) {
  1115. vth = ((btn_high[i] * 2) / 25) & 0x3F;
  1116. snd_soc_component_update_bits(
  1117. component, WCD9335_ANA_MBHC_BTN0 + i,
  1118. 0xFC, vth << 2);
  1119. dev_dbg(component->dev, "%s: btn_high[%d]: %d, vth: %d\n",
  1120. __func__, i, btn_high[i], vth);
  1121. }
  1122. }
  1123. static bool tasha_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
  1124. {
  1125. struct snd_soc_component *component = mbhc->component;
  1126. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1127. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1128. struct wcd9xxx_core_resource *core_res =
  1129. &wcd9xxx->core_res;
  1130. if (lock)
  1131. return wcd9xxx_lock_sleep(core_res);
  1132. else {
  1133. wcd9xxx_unlock_sleep(core_res);
  1134. return 0;
  1135. }
  1136. }
  1137. static int tasha_mbhc_register_notifier(struct wcd_mbhc *mbhc,
  1138. struct notifier_block *nblock,
  1139. bool enable)
  1140. {
  1141. struct snd_soc_component *component = mbhc->component;
  1142. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1143. if (enable)
  1144. return blocking_notifier_chain_register(&tasha->notifier,
  1145. nblock);
  1146. else
  1147. return blocking_notifier_chain_unregister(&tasha->notifier,
  1148. nblock);
  1149. }
  1150. static bool tasha_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
  1151. {
  1152. u8 val;
  1153. if (micb_num == MIC_BIAS_2) {
  1154. val = (snd_soc_component_read32(
  1155. mbhc->component, WCD9335_ANA_MICB2) >> 6);
  1156. if (val == 0x01)
  1157. return true;
  1158. }
  1159. return false;
  1160. }
  1161. static bool tasha_mbhc_hph_pa_on_status(struct snd_soc_component *component)
  1162. {
  1163. return (snd_soc_component_read32(component, WCD9335_ANA_HPH) & 0xC0) ?
  1164. true : false;
  1165. }
  1166. static void tasha_mbhc_hph_l_pull_up_control(
  1167. struct snd_soc_component *component,
  1168. enum mbhc_hs_pullup_iref pull_up_cur)
  1169. {
  1170. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1171. if (!tasha)
  1172. return;
  1173. /* Default pull up current to 2uA */
  1174. if (pull_up_cur < I_OFF || pull_up_cur > I_3P0_UA ||
  1175. pull_up_cur == I_DEFAULT)
  1176. pull_up_cur = I_2P0_UA;
  1177. dev_dbg(component->dev, "%s: HS pull up current:%d\n",
  1178. __func__, pull_up_cur);
  1179. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1180. snd_soc_component_update_bits(component,
  1181. WCD9335_MBHC_PLUG_DETECT_CTL,
  1182. 0xC0, pull_up_cur << 6);
  1183. else
  1184. snd_soc_component_update_bits(component,
  1185. WCD9335_MBHC_PLUG_DETECT_CTL,
  1186. 0xC0, 0x40);
  1187. }
  1188. static int tasha_enable_ext_mb_source(struct wcd_mbhc *mbhc,
  1189. bool turn_on)
  1190. {
  1191. struct snd_soc_component *component = mbhc->component;
  1192. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1193. int ret = 0;
  1194. struct on_demand_supply *supply;
  1195. if (!tasha)
  1196. return -EINVAL;
  1197. supply = &tasha->on_demand_list[ON_DEMAND_MICBIAS];
  1198. if (!supply->supply) {
  1199. dev_dbg(component->dev, "%s: warning supply not present ond for %s\n",
  1200. __func__, "onDemand Micbias");
  1201. return ret;
  1202. }
  1203. dev_dbg(component->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
  1204. supply->ondemand_supply_count);
  1205. if (turn_on) {
  1206. if (!(supply->ondemand_supply_count)) {
  1207. ret = snd_soc_dapm_force_enable_pin(
  1208. snd_soc_component_get_dapm(component),
  1209. "MICBIAS_REGULATOR");
  1210. snd_soc_dapm_sync(
  1211. snd_soc_component_get_dapm(component));
  1212. }
  1213. supply->ondemand_supply_count++;
  1214. } else {
  1215. if (supply->ondemand_supply_count > 0)
  1216. supply->ondemand_supply_count--;
  1217. if (!(supply->ondemand_supply_count)) {
  1218. ret = snd_soc_dapm_disable_pin(
  1219. snd_soc_component_get_dapm(component),
  1220. "MICBIAS_REGULATOR");
  1221. snd_soc_dapm_sync(snd_soc_component_get_dapm(component));
  1222. }
  1223. }
  1224. if (ret)
  1225. dev_err(component->dev, "%s: Failed to %s external micbias source\n",
  1226. __func__, turn_on ? "enable" : "disabled");
  1227. else
  1228. dev_dbg(component->dev, "%s: %s external micbias source\n",
  1229. __func__, turn_on ? "Enabled" : "Disabled");
  1230. return ret;
  1231. }
  1232. static int tasha_micbias_control(struct snd_soc_component *component,
  1233. int micb_num,
  1234. int req, bool is_dapm)
  1235. {
  1236. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1237. int micb_index = micb_num - 1;
  1238. u16 micb_reg;
  1239. int pre_off_event = 0, post_off_event = 0;
  1240. int post_on_event = 0, post_dapm_off = 0;
  1241. int post_dapm_on = 0;
  1242. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  1243. dev_err(component->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  1244. __func__, micb_index);
  1245. return -EINVAL;
  1246. }
  1247. switch (micb_num) {
  1248. case MIC_BIAS_1:
  1249. micb_reg = WCD9335_ANA_MICB1;
  1250. break;
  1251. case MIC_BIAS_2:
  1252. micb_reg = WCD9335_ANA_MICB2;
  1253. pre_off_event = WCD_EVENT_PRE_MICBIAS_2_OFF;
  1254. post_off_event = WCD_EVENT_POST_MICBIAS_2_OFF;
  1255. post_on_event = WCD_EVENT_POST_MICBIAS_2_ON;
  1256. post_dapm_on = WCD_EVENT_POST_DAPM_MICBIAS_2_ON;
  1257. post_dapm_off = WCD_EVENT_POST_DAPM_MICBIAS_2_OFF;
  1258. break;
  1259. case MIC_BIAS_3:
  1260. micb_reg = WCD9335_ANA_MICB3;
  1261. break;
  1262. case MIC_BIAS_4:
  1263. micb_reg = WCD9335_ANA_MICB4;
  1264. break;
  1265. default:
  1266. dev_err(component->dev, "%s: Invalid micbias number: %d\n",
  1267. __func__, micb_num);
  1268. return -EINVAL;
  1269. }
  1270. mutex_lock(&tasha->micb_lock);
  1271. switch (req) {
  1272. case MICB_PULLUP_ENABLE:
  1273. tasha->pullup_ref[micb_index]++;
  1274. if ((tasha->pullup_ref[micb_index] == 1) &&
  1275. (tasha->micb_ref[micb_index] == 0))
  1276. snd_soc_component_update_bits(component, micb_reg,
  1277. 0xC0, 0x80);
  1278. break;
  1279. case MICB_PULLUP_DISABLE:
  1280. if (tasha->pullup_ref[micb_index] > 0)
  1281. tasha->pullup_ref[micb_index]--;
  1282. if ((tasha->pullup_ref[micb_index] == 0) &&
  1283. (tasha->micb_ref[micb_index] == 0))
  1284. snd_soc_component_update_bits(component, micb_reg,
  1285. 0xC0, 0x00);
  1286. break;
  1287. case MICB_ENABLE:
  1288. tasha->micb_ref[micb_index]++;
  1289. if (tasha->micb_ref[micb_index] == 1) {
  1290. snd_soc_component_update_bits(component, micb_reg,
  1291. 0xC0, 0x40);
  1292. if (post_on_event)
  1293. blocking_notifier_call_chain(&tasha->notifier,
  1294. post_on_event, &tasha->mbhc);
  1295. }
  1296. if (is_dapm && post_dapm_on)
  1297. blocking_notifier_call_chain(&tasha->notifier,
  1298. post_dapm_on, &tasha->mbhc);
  1299. break;
  1300. case MICB_DISABLE:
  1301. if (tasha->micb_ref[micb_index] > 0)
  1302. tasha->micb_ref[micb_index]--;
  1303. if ((tasha->micb_ref[micb_index] == 0) &&
  1304. (tasha->pullup_ref[micb_index] > 0))
  1305. snd_soc_component_update_bits(component, micb_reg,
  1306. 0xC0, 0x80);
  1307. else if ((tasha->micb_ref[micb_index] == 0) &&
  1308. (tasha->pullup_ref[micb_index] == 0)) {
  1309. if (pre_off_event)
  1310. blocking_notifier_call_chain(&tasha->notifier,
  1311. pre_off_event, &tasha->mbhc);
  1312. snd_soc_component_update_bits(component, micb_reg,
  1313. 0xC0, 0x00);
  1314. if (post_off_event)
  1315. blocking_notifier_call_chain(&tasha->notifier,
  1316. post_off_event, &tasha->mbhc);
  1317. }
  1318. if (is_dapm && post_dapm_off)
  1319. blocking_notifier_call_chain(&tasha->notifier,
  1320. post_dapm_off, &tasha->mbhc);
  1321. break;
  1322. };
  1323. dev_dbg(component->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n",
  1324. __func__, micb_num, tasha->micb_ref[micb_index],
  1325. tasha->pullup_ref[micb_index]);
  1326. mutex_unlock(&tasha->micb_lock);
  1327. return 0;
  1328. }
  1329. static int tasha_mbhc_request_micbias(struct snd_soc_component *component,
  1330. int micb_num, int req)
  1331. {
  1332. int ret;
  1333. /*
  1334. * If micbias is requested, make sure that there
  1335. * is vote to enable mclk
  1336. */
  1337. if (req == MICB_ENABLE)
  1338. tasha_cdc_mclk_enable(component, true, false);
  1339. ret = tasha_micbias_control(component, micb_num, req, false);
  1340. /*
  1341. * Release vote for mclk while requesting for
  1342. * micbias disable
  1343. */
  1344. if (req == MICB_DISABLE)
  1345. tasha_cdc_mclk_enable(component, false, false);
  1346. return ret;
  1347. }
  1348. static void tasha_mbhc_micb_ramp_control(struct snd_soc_component *component,
  1349. bool enable)
  1350. {
  1351. if (enable) {
  1352. snd_soc_component_update_bits(component, WCD9335_ANA_MICB2_RAMP,
  1353. 0x1C, 0x0C);
  1354. snd_soc_component_update_bits(component, WCD9335_ANA_MICB2_RAMP,
  1355. 0x80, 0x80);
  1356. } else {
  1357. snd_soc_component_update_bits(component, WCD9335_ANA_MICB2_RAMP,
  1358. 0x80, 0x00);
  1359. snd_soc_component_update_bits(component, WCD9335_ANA_MICB2_RAMP,
  1360. 0x1C, 0x00);
  1361. }
  1362. }
  1363. static struct firmware_cal *tasha_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
  1364. enum wcd_cal_type type)
  1365. {
  1366. struct tasha_priv *tasha;
  1367. struct firmware_cal *hwdep_cal;
  1368. struct snd_soc_component *component = mbhc->component;
  1369. if (!component) {
  1370. pr_err("%s: NULL component pointer\n", __func__);
  1371. return NULL;
  1372. }
  1373. tasha = snd_soc_component_get_drvdata(component);
  1374. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, type);
  1375. if (!hwdep_cal)
  1376. dev_err(component->dev, "%s: cal not sent by %d\n",
  1377. __func__, type);
  1378. return hwdep_cal;
  1379. }
  1380. static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
  1381. int req_volt,
  1382. int micb_num)
  1383. {
  1384. int cur_vout_ctl, req_vout_ctl;
  1385. int micb_reg, micb_val, micb_en;
  1386. switch (micb_num) {
  1387. case MIC_BIAS_1:
  1388. micb_reg = WCD9335_ANA_MICB1;
  1389. break;
  1390. case MIC_BIAS_2:
  1391. micb_reg = WCD9335_ANA_MICB2;
  1392. break;
  1393. case MIC_BIAS_3:
  1394. micb_reg = WCD9335_ANA_MICB3;
  1395. break;
  1396. case MIC_BIAS_4:
  1397. micb_reg = WCD9335_ANA_MICB4;
  1398. break;
  1399. default:
  1400. return -EINVAL;
  1401. }
  1402. /*
  1403. * If requested micbias voltage is same as current micbias
  1404. * voltage, then just return. Otherwise, adjust voltage as
  1405. * per requested value. If micbias is already enabled, then
  1406. * to avoid slow micbias ramp-up or down enable pull-up
  1407. * momentarily, change the micbias value and then re-enable
  1408. * micbias.
  1409. */
  1410. micb_val = snd_soc_component_read32(component, micb_reg);
  1411. micb_en = (micb_val & 0xC0) >> 6;
  1412. cur_vout_ctl = micb_val & 0x3F;
  1413. req_vout_ctl = wcd9335_get_micb_vout_ctl_val(req_volt);
  1414. if (req_vout_ctl < 0)
  1415. return -EINVAL;
  1416. if (cur_vout_ctl == req_vout_ctl)
  1417. return 0;
  1418. dev_dbg(component->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n",
  1419. __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl),
  1420. req_volt, micb_en);
  1421. if (micb_en == 0x1)
  1422. snd_soc_component_update_bits(component, micb_reg, 0xC0, 0x80);
  1423. snd_soc_component_update_bits(component, micb_reg, 0x3F, req_vout_ctl);
  1424. if (micb_en == 0x1) {
  1425. snd_soc_component_update_bits(component, micb_reg, 0xC0, 0x40);
  1426. /*
  1427. * Add 2ms delay as per HW requirement after enabling
  1428. * micbias
  1429. */
  1430. usleep_range(2000, 2100);
  1431. }
  1432. return 0;
  1433. }
  1434. static int tasha_mbhc_micb_ctrl_threshold_mic(
  1435. struct snd_soc_component *component,
  1436. int micb_num, bool req_en)
  1437. {
  1438. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1439. struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent);
  1440. int rc, micb_mv;
  1441. if (micb_num != MIC_BIAS_2)
  1442. return -EINVAL;
  1443. /*
  1444. * If device tree micbias level is already above the minimum
  1445. * voltage needed to detect threshold microphone, then do
  1446. * not change the micbias, just return.
  1447. */
  1448. if (pdata->micbias.micb2_mv >= WCD_MBHC_THR_HS_MICB_MV)
  1449. return 0;
  1450. micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv;
  1451. mutex_lock(&tasha->micb_lock);
  1452. rc = tasha_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_2);
  1453. mutex_unlock(&tasha->micb_lock);
  1454. return rc;
  1455. }
  1456. static inline void tasha_mbhc_get_result_params(struct wcd9xxx *wcd9xxx,
  1457. s16 *d1_a, u16 noff,
  1458. int32_t *zdet)
  1459. {
  1460. int i;
  1461. int val, val1;
  1462. s16 c1;
  1463. s32 x1, d1;
  1464. int32_t denom;
  1465. int minCode_param[] = {
  1466. 3277, 1639, 820, 410, 205, 103, 52, 26
  1467. };
  1468. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x20);
  1469. for (i = 0; i < TASHA_ZDET_NUM_MEASUREMENTS; i++) {
  1470. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_2, &val);
  1471. if (val & 0x80)
  1472. break;
  1473. }
  1474. val = val << 0x8;
  1475. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_1, &val1);
  1476. val |= val1;
  1477. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x00);
  1478. x1 = TASHA_MBHC_GET_X1(val);
  1479. c1 = TASHA_MBHC_GET_C1(val);
  1480. /* If ramp is not complete, give additional 5ms */
  1481. if ((c1 < 2) && x1)
  1482. usleep_range(5000, 5050);
  1483. if (!c1 || !x1) {
  1484. dev_dbg(wcd9xxx->dev,
  1485. "%s: Impedance detect ramp error, c1=%d, x1=0x%x\n",
  1486. __func__, c1, x1);
  1487. goto ramp_down;
  1488. }
  1489. d1 = d1_a[c1];
  1490. denom = (x1 * d1) - (1 << (14 - noff));
  1491. if (denom > 0)
  1492. *zdet = (TASHA_MBHC_ZDET_CONST * 1000) / denom;
  1493. else if (x1 < minCode_param[noff])
  1494. *zdet = TASHA_ZDET_FLOATING_IMPEDANCE;
  1495. dev_dbg(wcd9xxx->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
  1496. __func__, d1, c1, x1, *zdet);
  1497. ramp_down:
  1498. i = 0;
  1499. while (x1) {
  1500. regmap_bulk_read(wcd9xxx->regmap,
  1501. WCD9335_ANA_MBHC_RESULT_1, (u8 *)&val, 2);
  1502. x1 = TASHA_MBHC_GET_X1(val);
  1503. i++;
  1504. if (i == TASHA_ZDET_NUM_MEASUREMENTS)
  1505. break;
  1506. }
  1507. }
  1508. /*
  1509. * tasha_mbhc_zdet_gpio_ctrl: Register callback function for
  1510. * controlling the switch on hifi amps. Default switch state
  1511. * will put a 51ohm load in parallel to the hph load. So,
  1512. * impedance detection function will pull the gpio high
  1513. * to make the switch open.
  1514. *
  1515. * @zdet_gpio_cb: callback function from machine driver
  1516. * @component: Codec instance
  1517. *
  1518. * Return: none
  1519. */
  1520. void tasha_mbhc_zdet_gpio_ctrl(
  1521. int (*zdet_gpio_cb)(
  1522. struct snd_soc_component *component, bool high),
  1523. struct snd_soc_component *component)
  1524. {
  1525. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1526. tasha->zdet_gpio_cb = zdet_gpio_cb;
  1527. }
  1528. EXPORT_SYMBOL(tasha_mbhc_zdet_gpio_ctrl);
  1529. static void tasha_mbhc_zdet_ramp(struct snd_soc_component *component,
  1530. struct tasha_mbhc_zdet_param *zdet_param,
  1531. int32_t *zl, int32_t *zr, s16 *d1_a)
  1532. {
  1533. struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
  1534. int32_t zdet = 0;
  1535. snd_soc_component_update_bits(component, WCD9335_MBHC_ZDET_ANA_CTL,
  1536. 0x70, zdet_param->ldo_ctl << 4);
  1537. snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_BTN5, 0xFC,
  1538. zdet_param->btn5);
  1539. snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_BTN6, 0xFC,
  1540. zdet_param->btn6);
  1541. snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_BTN7, 0xFC,
  1542. zdet_param->btn7);
  1543. snd_soc_component_update_bits(component, WCD9335_MBHC_ZDET_ANA_CTL,
  1544. 0x0F, zdet_param->noff);
  1545. snd_soc_component_update_bits(component, WCD9335_MBHC_ZDET_RAMP_CTL,
  1546. 0x0F, zdet_param->nshift);
  1547. if (!zl)
  1548. goto z_right;
  1549. /* Start impedance measurement for HPH_L */
  1550. regmap_update_bits(wcd9xxx->regmap,
  1551. WCD9335_ANA_MBHC_ZDET, 0x80, 0x80);
  1552. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_L, noff = %d\n",
  1553. __func__, zdet_param->noff);
  1554. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1555. regmap_update_bits(wcd9xxx->regmap,
  1556. WCD9335_ANA_MBHC_ZDET, 0x80, 0x00);
  1557. *zl = zdet;
  1558. z_right:
  1559. if (!zr)
  1560. return;
  1561. /* Start impedance measurement for HPH_R */
  1562. regmap_update_bits(wcd9xxx->regmap,
  1563. WCD9335_ANA_MBHC_ZDET, 0x40, 0x40);
  1564. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_R, noff = %d\n",
  1565. __func__, zdet_param->noff);
  1566. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1567. regmap_update_bits(wcd9xxx->regmap,
  1568. WCD9335_ANA_MBHC_ZDET, 0x40, 0x00);
  1569. *zr = zdet;
  1570. }
  1571. static inline void tasha_wcd_mbhc_qfuse_cal(struct snd_soc_component *component,
  1572. int32_t *z_val, int flag_l_r)
  1573. {
  1574. s16 q1;
  1575. int q1_cal;
  1576. if (*z_val < (TASHA_ZDET_VAL_400/1000))
  1577. q1 = snd_soc_component_read32(component,
  1578. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r));
  1579. else
  1580. q1 = snd_soc_component_read32(component,
  1581. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r));
  1582. if (q1 & 0x80)
  1583. q1_cal = (10000 - ((q1 & 0x7F) * 25));
  1584. else
  1585. q1_cal = (10000 + (q1 * 25));
  1586. if (q1_cal > 0)
  1587. *z_val = ((*z_val) * 10000) / q1_cal;
  1588. }
  1589. static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
  1590. uint32_t *zr)
  1591. {
  1592. struct snd_soc_component *component = mbhc->component;
  1593. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1594. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1595. s16 reg0, reg1, reg2, reg3, reg4;
  1596. int32_t z1L, z1R, z1Ls;
  1597. int zMono, z_diff1, z_diff2;
  1598. bool is_fsm_disable = false;
  1599. bool is_change = false;
  1600. struct tasha_mbhc_zdet_param zdet_param[] = {
  1601. {4, 0, 4, 0x08, 0x14, 0x18}, /* < 32ohm */
  1602. {2, 0, 3, 0x18, 0x7C, 0x90}, /* 32ohm < Z < 400ohm */
  1603. {1, 4, 5, 0x18, 0x7C, 0x90}, /* 400ohm < Z < 1200ohm */
  1604. {1, 6, 7, 0x18, 0x7C, 0x90}, /* >1200ohm */
  1605. };
  1606. struct tasha_mbhc_zdet_param *zdet_param_ptr = NULL;
  1607. s16 d1_a[][4] = {
  1608. {0, 30, 90, 30},
  1609. {0, 30, 30, 5},
  1610. {0, 30, 30, 5},
  1611. {0, 30, 30, 5},
  1612. };
  1613. s16 *d1 = NULL;
  1614. if (!TASHA_IS_2_0(wcd9xxx)) {
  1615. dev_dbg(component->dev, "%s: Z-det is not supported for this codec version\n",
  1616. __func__);
  1617. *zl = 0;
  1618. *zr = 0;
  1619. return;
  1620. }
  1621. WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
  1622. if (tasha->zdet_gpio_cb)
  1623. is_change = tasha->zdet_gpio_cb(component, true);
  1624. reg0 = snd_soc_component_read32(component, WCD9335_ANA_MBHC_BTN5);
  1625. reg1 = snd_soc_component_read32(component, WCD9335_ANA_MBHC_BTN6);
  1626. reg2 = snd_soc_component_read32(component, WCD9335_ANA_MBHC_BTN7);
  1627. reg3 = snd_soc_component_read32(component, WCD9335_MBHC_CTL_1);
  1628. reg4 = snd_soc_component_read32(component, WCD9335_MBHC_ZDET_ANA_CTL);
  1629. if (snd_soc_component_read32(
  1630. component, WCD9335_ANA_MBHC_ELECT) & 0x80) {
  1631. is_fsm_disable = true;
  1632. regmap_update_bits(wcd9xxx->regmap,
  1633. WCD9335_ANA_MBHC_ELECT, 0x80, 0x00);
  1634. }
  1635. /* For NO-jack, disable L_DET_EN before Z-det measurements */
  1636. if (mbhc->hphl_swh)
  1637. regmap_update_bits(wcd9xxx->regmap,
  1638. WCD9335_ANA_MBHC_MECH, 0x80, 0x00);
  1639. /* Enable AZ */
  1640. snd_soc_component_update_bits(component, WCD9335_MBHC_CTL_1,
  1641. 0x0C, 0x04);
  1642. /* Turn off 100k pull down on HPHL */
  1643. regmap_update_bits(wcd9xxx->regmap,
  1644. WCD9335_ANA_MBHC_MECH, 0x01, 0x00);
  1645. /* First get impedance on Left */
  1646. d1 = d1_a[1];
  1647. zdet_param_ptr = &zdet_param[1];
  1648. tasha_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1);
  1649. if (!TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
  1650. goto left_ch_impedance;
  1651. /* second ramp for left ch */
  1652. if (z1L < TASHA_ZDET_VAL_32) {
  1653. zdet_param_ptr = &zdet_param[0];
  1654. d1 = d1_a[0];
  1655. } else if ((z1L > TASHA_ZDET_VAL_400) && (z1L <= TASHA_ZDET_VAL_1200)) {
  1656. zdet_param_ptr = &zdet_param[2];
  1657. d1 = d1_a[2];
  1658. } else if (z1L > TASHA_ZDET_VAL_1200) {
  1659. zdet_param_ptr = &zdet_param[3];
  1660. d1 = d1_a[3];
  1661. }
  1662. tasha_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1);
  1663. left_ch_impedance:
  1664. if ((z1L == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1665. (z1L > TASHA_ZDET_VAL_100K)) {
  1666. *zl = TASHA_ZDET_FLOATING_IMPEDANCE;
  1667. zdet_param_ptr = &zdet_param[1];
  1668. d1 = d1_a[1];
  1669. } else {
  1670. *zl = z1L/1000;
  1671. tasha_wcd_mbhc_qfuse_cal(component, zl, 0);
  1672. }
  1673. dev_dbg(component->dev, "%s: impedance on HPH_L = %d(ohms)\n",
  1674. __func__, *zl);
  1675. /* start of right impedance ramp and calculation */
  1676. tasha_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1);
  1677. if (TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
  1678. if (((z1R > TASHA_ZDET_VAL_1200) &&
  1679. (zdet_param_ptr->noff == 0x6)) ||
  1680. ((*zl) != TASHA_ZDET_FLOATING_IMPEDANCE))
  1681. goto right_ch_impedance;
  1682. /* second ramp for right ch */
  1683. if (z1R < TASHA_ZDET_VAL_32) {
  1684. zdet_param_ptr = &zdet_param[0];
  1685. d1 = d1_a[0];
  1686. } else if ((z1R > TASHA_ZDET_VAL_400) &&
  1687. (z1R <= TASHA_ZDET_VAL_1200)) {
  1688. zdet_param_ptr = &zdet_param[2];
  1689. d1 = d1_a[2];
  1690. } else if (z1R > TASHA_ZDET_VAL_1200) {
  1691. zdet_param_ptr = &zdet_param[3];
  1692. d1 = d1_a[3];
  1693. }
  1694. tasha_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1);
  1695. }
  1696. right_ch_impedance:
  1697. if ((z1R == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1698. (z1R > TASHA_ZDET_VAL_100K)) {
  1699. *zr = TASHA_ZDET_FLOATING_IMPEDANCE;
  1700. } else {
  1701. *zr = z1R/1000;
  1702. tasha_wcd_mbhc_qfuse_cal(component, zr, 1);
  1703. }
  1704. dev_dbg(component->dev, "%s: impedance on HPH_R = %d(ohms)\n",
  1705. __func__, *zr);
  1706. /* mono/stereo detection */
  1707. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) &&
  1708. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE)) {
  1709. dev_dbg(component->dev,
  1710. "%s: plug type is invalid or extension cable\n",
  1711. __func__);
  1712. goto zdet_complete;
  1713. }
  1714. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1715. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1716. ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
  1717. ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
  1718. dev_dbg(component->dev,
  1719. "%s: Mono plug type with one ch floating or shorted to GND\n",
  1720. __func__);
  1721. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1722. goto zdet_complete;
  1723. }
  1724. snd_soc_component_update_bits(component, WCD9335_HPH_R_ATEST,
  1725. 0x02, 0x02);
  1726. snd_soc_component_update_bits(component, WCD9335_HPH_PA_CTL2,
  1727. 0x40, 0x01);
  1728. if (*zl < (TASHA_ZDET_VAL_32/1000))
  1729. tasha_mbhc_zdet_ramp(component, &zdet_param[0],
  1730. &z1Ls, NULL, d1);
  1731. else
  1732. tasha_mbhc_zdet_ramp(component, &zdet_param[1],
  1733. &z1Ls, NULL, d1);
  1734. snd_soc_component_update_bits(component, WCD9335_HPH_PA_CTL2,
  1735. 0x40, 0x00);
  1736. snd_soc_component_update_bits(component, WCD9335_HPH_R_ATEST,
  1737. 0x02, 0x00);
  1738. z1Ls /= 1000;
  1739. tasha_wcd_mbhc_qfuse_cal(component, &z1Ls, 0);
  1740. /* parallel of left Z and 9 ohm pull down resistor */
  1741. zMono = ((*zl) * 9) / ((*zl) + 9);
  1742. z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
  1743. z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
  1744. if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
  1745. dev_dbg(component->dev, "%s: stereo plug type detected\n",
  1746. __func__);
  1747. mbhc->hph_type = WCD_MBHC_HPH_STEREO;
  1748. } else {
  1749. dev_dbg(component->dev, "%s: MONO plug type detected\n",
  1750. __func__);
  1751. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1752. }
  1753. zdet_complete:
  1754. snd_soc_component_write(component, WCD9335_ANA_MBHC_BTN5, reg0);
  1755. snd_soc_component_write(component, WCD9335_ANA_MBHC_BTN6, reg1);
  1756. snd_soc_component_write(component, WCD9335_ANA_MBHC_BTN7, reg2);
  1757. /* Turn on 100k pull down on HPHL */
  1758. regmap_update_bits(wcd9xxx->regmap,
  1759. WCD9335_ANA_MBHC_MECH, 0x01, 0x01);
  1760. /* For NO-jack, re-enable L_DET_EN after Z-det measurements */
  1761. if (mbhc->hphl_swh)
  1762. regmap_update_bits(wcd9xxx->regmap,
  1763. WCD9335_ANA_MBHC_MECH, 0x80, 0x80);
  1764. snd_soc_component_write(component, WCD9335_MBHC_ZDET_ANA_CTL, reg4);
  1765. snd_soc_component_write(component, WCD9335_MBHC_CTL_1, reg3);
  1766. if (is_fsm_disable)
  1767. regmap_update_bits(wcd9xxx->regmap,
  1768. WCD9335_ANA_MBHC_ELECT, 0x80, 0x80);
  1769. if (tasha->zdet_gpio_cb && is_change)
  1770. tasha->zdet_gpio_cb(component, false);
  1771. }
  1772. static void tasha_mbhc_gnd_det_ctrl(
  1773. struct snd_soc_component *component, bool enable)
  1774. {
  1775. if (enable) {
  1776. snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_MECH,
  1777. 0x02, 0x02);
  1778. snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_MECH,
  1779. 0x40, 0x40);
  1780. } else {
  1781. snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_MECH,
  1782. 0x40, 0x00);
  1783. snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_MECH,
  1784. 0x02, 0x00);
  1785. }
  1786. }
  1787. static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_component *component,
  1788. bool enable)
  1789. {
  1790. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1791. if (enable) {
  1792. snd_soc_component_update_bits(component, WCD9335_HPH_PA_CTL2,
  1793. 0x40, 0x40);
  1794. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1795. snd_soc_component_update_bits(component,
  1796. WCD9335_HPH_PA_CTL2,
  1797. 0x10, 0x10);
  1798. } else {
  1799. snd_soc_component_update_bits(component, WCD9335_HPH_PA_CTL2,
  1800. 0x40, 0x00);
  1801. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1802. snd_soc_component_update_bits(component,
  1803. WCD9335_HPH_PA_CTL2,
  1804. 0x10, 0x00);
  1805. }
  1806. }
  1807. static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc)
  1808. {
  1809. struct snd_soc_component *component = mbhc->component;
  1810. if (mbhc->moist_vref == V_OFF)
  1811. return;
  1812. /* Donot enable moisture detection if jack type is NC */
  1813. if (!mbhc->hphl_swh) {
  1814. dev_dbg(component->dev, "%s: disable moisture detection for NC\n",
  1815. __func__);
  1816. return;
  1817. }
  1818. snd_soc_component_update_bits(component, WCD9335_MBHC_CTL_2,
  1819. 0x0C, mbhc->moist_vref << 2);
  1820. tasha_mbhc_hph_l_pull_up_control(component, mbhc->moist_iref);
  1821. }
  1822. static void tasha_update_anc_state(struct snd_soc_component *component,
  1823. bool enable, int anc_num)
  1824. {
  1825. if (enable)
  1826. snd_soc_component_update_bits(component,
  1827. WCD9335_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num),
  1828. 0x10, 0x10);
  1829. else
  1830. snd_soc_component_update_bits(component,
  1831. WCD9335_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num),
  1832. 0x10, 0x00);
  1833. }
  1834. static bool tasha_is_anc_on(struct wcd_mbhc *mbhc)
  1835. {
  1836. bool anc_on = false;
  1837. u16 ancl, ancr;
  1838. ancl =
  1839. (snd_soc_component_read32(
  1840. mbhc->component, WCD9335_CDC_RX1_RX_PATH_CFG0)) & 0x10;
  1841. ancr =
  1842. (snd_soc_component_read32(
  1843. mbhc->component, WCD9335_CDC_RX2_RX_PATH_CFG0)) & 0x10;
  1844. anc_on = !!(ancl | ancr);
  1845. return anc_on;
  1846. }
  1847. static const struct wcd_mbhc_cb mbhc_cb = {
  1848. .request_irq = tasha_mbhc_request_irq,
  1849. .irq_control = tasha_mbhc_irq_control,
  1850. .free_irq = tasha_mbhc_free_irq,
  1851. .clk_setup = tasha_mbhc_clk_setup,
  1852. .map_btn_code_to_num = tasha_mbhc_btn_to_num,
  1853. .enable_mb_source = tasha_enable_ext_mb_source,
  1854. .mbhc_bias = tasha_mbhc_mbhc_bias_control,
  1855. .set_btn_thr = tasha_mbhc_program_btn_thr,
  1856. .lock_sleep = tasha_mbhc_lock_sleep,
  1857. .register_notifier = tasha_mbhc_register_notifier,
  1858. .micbias_enable_status = tasha_mbhc_micb_en_status,
  1859. .hph_pa_on_status = tasha_mbhc_hph_pa_on_status,
  1860. .hph_pull_up_control = tasha_mbhc_hph_l_pull_up_control,
  1861. .mbhc_micbias_control = tasha_mbhc_request_micbias,
  1862. .mbhc_micb_ramp_control = tasha_mbhc_micb_ramp_control,
  1863. .get_hwdep_fw_cal = tasha_get_hwdep_fw_cal,
  1864. .mbhc_micb_ctrl_thr_mic = tasha_mbhc_micb_ctrl_threshold_mic,
  1865. .compute_impedance = tasha_wcd_mbhc_calc_impedance,
  1866. .mbhc_gnd_det_ctrl = tasha_mbhc_gnd_det_ctrl,
  1867. .hph_pull_down_ctrl = tasha_mbhc_hph_pull_down_ctrl,
  1868. .mbhc_moisture_config = tasha_mbhc_moisture_config,
  1869. .update_anc_state = tasha_update_anc_state,
  1870. .is_anc_on = tasha_is_anc_on,
  1871. };
  1872. static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol,
  1873. struct snd_ctl_elem_value *ucontrol)
  1874. {
  1875. struct snd_soc_component *component =
  1876. snd_soc_kcontrol_component(kcontrol);
  1877. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1878. ucontrol->value.integer.value[0] = tasha->anc_slot;
  1879. return 0;
  1880. }
  1881. static int tasha_put_anc_slot(struct snd_kcontrol *kcontrol,
  1882. struct snd_ctl_elem_value *ucontrol)
  1883. {
  1884. struct snd_soc_component *component =
  1885. snd_soc_kcontrol_component(kcontrol);
  1886. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1887. tasha->anc_slot = ucontrol->value.integer.value[0];
  1888. return 0;
  1889. }
  1890. static int tasha_get_anc_func(struct snd_kcontrol *kcontrol,
  1891. struct snd_ctl_elem_value *ucontrol)
  1892. {
  1893. struct snd_soc_component *component =
  1894. snd_soc_kcontrol_component(kcontrol);
  1895. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1896. ucontrol->value.integer.value[0] = (tasha->anc_func == true ? 1 : 0);
  1897. return 0;
  1898. }
  1899. static int tasha_put_anc_func(struct snd_kcontrol *kcontrol,
  1900. struct snd_ctl_elem_value *ucontrol)
  1901. {
  1902. struct snd_soc_component *component =
  1903. snd_soc_kcontrol_component(kcontrol);
  1904. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1905. struct snd_soc_dapm_context *dapm =
  1906. snd_soc_component_get_dapm(component);
  1907. mutex_lock(&tasha->codec_mutex);
  1908. tasha->anc_func = (!ucontrol->value.integer.value[0] ? false : true);
  1909. dev_dbg(component->dev, "%s: anc_func %x", __func__, tasha->anc_func);
  1910. if (tasha->anc_func == true) {
  1911. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2 PA");
  1912. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2");
  1913. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1 PA");
  1914. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1");
  1915. snd_soc_dapm_enable_pin(dapm, "ANC HPHR PA");
  1916. snd_soc_dapm_enable_pin(dapm, "ANC HPHR");
  1917. snd_soc_dapm_enable_pin(dapm, "ANC HPHL PA");
  1918. snd_soc_dapm_enable_pin(dapm, "ANC HPHL");
  1919. snd_soc_dapm_enable_pin(dapm, "ANC EAR PA");
  1920. snd_soc_dapm_enable_pin(dapm, "ANC EAR");
  1921. snd_soc_dapm_enable_pin(dapm, "ANC SPK1 PA");
  1922. snd_soc_dapm_disable_pin(dapm, "LINEOUT2");
  1923. snd_soc_dapm_disable_pin(dapm, "LINEOUT2 PA");
  1924. snd_soc_dapm_disable_pin(dapm, "LINEOUT1");
  1925. snd_soc_dapm_disable_pin(dapm, "LINEOUT1 PA");
  1926. snd_soc_dapm_disable_pin(dapm, "HPHR");
  1927. snd_soc_dapm_disable_pin(dapm, "HPHL");
  1928. snd_soc_dapm_disable_pin(dapm, "HPHR PA");
  1929. snd_soc_dapm_disable_pin(dapm, "HPHL PA");
  1930. snd_soc_dapm_disable_pin(dapm, "EAR PA");
  1931. snd_soc_dapm_disable_pin(dapm, "EAR");
  1932. } else {
  1933. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  1934. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  1935. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  1936. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  1937. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  1938. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  1939. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  1940. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  1941. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  1942. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  1943. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  1944. snd_soc_dapm_enable_pin(dapm, "LINEOUT2");
  1945. snd_soc_dapm_enable_pin(dapm, "LINEOUT2 PA");
  1946. snd_soc_dapm_enable_pin(dapm, "LINEOUT1");
  1947. snd_soc_dapm_enable_pin(dapm, "LINEOUT1 PA");
  1948. snd_soc_dapm_enable_pin(dapm, "HPHR");
  1949. snd_soc_dapm_enable_pin(dapm, "HPHL");
  1950. snd_soc_dapm_enable_pin(dapm, "HPHR PA");
  1951. snd_soc_dapm_enable_pin(dapm, "HPHL PA");
  1952. snd_soc_dapm_enable_pin(dapm, "EAR PA");
  1953. snd_soc_dapm_enable_pin(dapm, "EAR");
  1954. }
  1955. mutex_unlock(&tasha->codec_mutex);
  1956. snd_soc_dapm_sync(dapm);
  1957. return 0;
  1958. }
  1959. static int tasha_get_clkmode(struct snd_kcontrol *kcontrol,
  1960. struct snd_ctl_elem_value *ucontrol)
  1961. {
  1962. struct snd_soc_component *component =
  1963. snd_soc_kcontrol_component(kcontrol);
  1964. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1965. ucontrol->value.enumerated.item[0] = tasha->clk_mode;
  1966. dev_dbg(component->dev, "%s: clk_mode: %d\n", __func__,
  1967. tasha->clk_mode);
  1968. return 0;
  1969. }
  1970. static int tasha_put_clkmode(struct snd_kcontrol *kcontrol,
  1971. struct snd_ctl_elem_value *ucontrol)
  1972. {
  1973. struct snd_soc_component *component =
  1974. snd_soc_kcontrol_component(kcontrol);
  1975. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  1976. tasha->clk_mode = ucontrol->value.enumerated.item[0];
  1977. dev_dbg(component->dev, "%s: clk_mode: %d\n", __func__,
  1978. tasha->clk_mode);
  1979. return 0;
  1980. }
  1981. static int tasha_get_iir_enable_audio_mixer(
  1982. struct snd_kcontrol *kcontrol,
  1983. struct snd_ctl_elem_value *ucontrol)
  1984. {
  1985. struct snd_soc_component *component =
  1986. snd_soc_kcontrol_component(kcontrol);
  1987. int iir_idx = ((struct soc_multi_mixer_control *)
  1988. kcontrol->private_value)->reg;
  1989. int band_idx = ((struct soc_multi_mixer_control *)
  1990. kcontrol->private_value)->shift;
  1991. /* IIR filter band registers are at integer multiples of 16 */
  1992. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  1993. ucontrol->value.integer.value[0] = (
  1994. snd_soc_component_read32(component, iir_reg) &
  1995. (1 << band_idx)) != 0;
  1996. dev_dbg(component->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
  1997. iir_idx, band_idx,
  1998. (uint32_t)ucontrol->value.integer.value[0]);
  1999. return 0;
  2000. }
  2001. static int tasha_hph_impedance_get(struct snd_kcontrol *kcontrol,
  2002. struct snd_ctl_elem_value *ucontrol)
  2003. {
  2004. uint32_t zl, zr;
  2005. bool hphr;
  2006. struct soc_multi_mixer_control *mc;
  2007. struct snd_soc_component *component =
  2008. snd_soc_kcontrol_component(kcontrol);
  2009. struct tasha_priv *priv = snd_soc_component_get_drvdata(component);
  2010. mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
  2011. hphr = mc->shift;
  2012. wcd_mbhc_get_impedance(&priv->mbhc, &zl, &zr);
  2013. dev_dbg(component->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__,
  2014. zl, zr);
  2015. ucontrol->value.integer.value[0] = hphr ? zr : zl;
  2016. return 0;
  2017. }
  2018. static const struct snd_kcontrol_new impedance_detect_controls[] = {
  2019. SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
  2020. tasha_hph_impedance_get, NULL),
  2021. SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
  2022. tasha_hph_impedance_get, NULL),
  2023. };
  2024. static int tasha_get_hph_type(struct snd_kcontrol *kcontrol,
  2025. struct snd_ctl_elem_value *ucontrol)
  2026. {
  2027. struct snd_soc_component *component =
  2028. snd_soc_kcontrol_component(kcontrol);
  2029. struct tasha_priv *priv = snd_soc_component_get_drvdata(component);
  2030. struct wcd_mbhc *mbhc;
  2031. if (!priv) {
  2032. dev_dbg(component->dev, "%s: wcd9335 private data is NULL\n",
  2033. __func__);
  2034. return 0;
  2035. }
  2036. mbhc = &priv->mbhc;
  2037. if (!mbhc) {
  2038. dev_dbg(component->dev, "%s: mbhc not initialized\n", __func__);
  2039. return 0;
  2040. }
  2041. ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
  2042. dev_dbg(component->dev, "%s: hph_type = %u\n", __func__,
  2043. mbhc->hph_type);
  2044. return 0;
  2045. }
  2046. static const struct snd_kcontrol_new hph_type_detect_controls[] = {
  2047. SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
  2048. tasha_get_hph_type, NULL),
  2049. };
  2050. static int tasha_vi_feed_mixer_get(struct snd_kcontrol *kcontrol,
  2051. struct snd_ctl_elem_value *ucontrol)
  2052. {
  2053. struct snd_soc_dapm_widget *widget =
  2054. snd_soc_dapm_kcontrol_widget(kcontrol);
  2055. struct snd_soc_component *component =
  2056. snd_soc_dapm_to_component(widget->dapm);
  2057. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  2058. ucontrol->value.integer.value[0] = tasha_p->vi_feed_value;
  2059. return 0;
  2060. }
  2061. static int tasha_vi_feed_mixer_put(struct snd_kcontrol *kcontrol,
  2062. struct snd_ctl_elem_value *ucontrol)
  2063. {
  2064. struct snd_soc_dapm_widget *widget =
  2065. snd_soc_dapm_kcontrol_widget(kcontrol);
  2066. struct snd_soc_component *component =
  2067. snd_soc_dapm_to_component(widget->dapm);
  2068. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  2069. struct wcd9xxx *core = tasha_p->wcd9xxx;
  2070. struct soc_multi_mixer_control *mixer =
  2071. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2072. u32 dai_id = widget->shift;
  2073. u32 port_id = mixer->shift;
  2074. u32 enable = ucontrol->value.integer.value[0];
  2075. dev_dbg(component->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n",
  2076. __func__, enable, port_id, dai_id);
  2077. tasha_p->vi_feed_value = ucontrol->value.integer.value[0];
  2078. mutex_lock(&tasha_p->codec_mutex);
  2079. if (enable) {
  2080. if (port_id == TASHA_TX14 && !test_bit(VI_SENSE_1,
  2081. &tasha_p->status_mask)) {
  2082. list_add_tail(&core->tx_chs[TASHA_TX14].list,
  2083. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2084. set_bit(VI_SENSE_1, &tasha_p->status_mask);
  2085. }
  2086. if (port_id == TASHA_TX15 && !test_bit(VI_SENSE_2,
  2087. &tasha_p->status_mask)) {
  2088. list_add_tail(&core->tx_chs[TASHA_TX15].list,
  2089. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2090. set_bit(VI_SENSE_2, &tasha_p->status_mask);
  2091. }
  2092. } else {
  2093. if (port_id == TASHA_TX14 && test_bit(VI_SENSE_1,
  2094. &tasha_p->status_mask)) {
  2095. list_del_init(&core->tx_chs[TASHA_TX14].list);
  2096. clear_bit(VI_SENSE_1, &tasha_p->status_mask);
  2097. }
  2098. if (port_id == TASHA_TX15 && test_bit(VI_SENSE_2,
  2099. &tasha_p->status_mask)) {
  2100. list_del_init(&core->tx_chs[TASHA_TX15].list);
  2101. clear_bit(VI_SENSE_2, &tasha_p->status_mask);
  2102. }
  2103. }
  2104. mutex_unlock(&tasha_p->codec_mutex);
  2105. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL);
  2106. return 0;
  2107. }
  2108. /* virtual port entries */
  2109. static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol,
  2110. struct snd_ctl_elem_value *ucontrol)
  2111. {
  2112. struct snd_soc_dapm_widget *widget =
  2113. snd_soc_dapm_kcontrol_widget(kcontrol);
  2114. struct snd_soc_component *component =
  2115. snd_soc_dapm_to_component(widget->dapm);
  2116. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  2117. ucontrol->value.integer.value[0] = tasha_p->tx_port_value;
  2118. return 0;
  2119. }
  2120. static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol,
  2121. struct snd_ctl_elem_value *ucontrol)
  2122. {
  2123. struct snd_soc_dapm_widget *widget =
  2124. snd_soc_dapm_kcontrol_widget(kcontrol);
  2125. struct snd_soc_component *component =
  2126. snd_soc_dapm_to_component(widget->dapm);
  2127. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  2128. struct wcd9xxx *core = dev_get_drvdata(component->dev->parent);
  2129. struct snd_soc_dapm_update *update = NULL;
  2130. struct soc_multi_mixer_control *mixer =
  2131. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2132. u32 dai_id = widget->shift;
  2133. u32 port_id = mixer->shift;
  2134. u32 enable = ucontrol->value.integer.value[0];
  2135. u32 vtable;
  2136. dev_dbg(component->dev, "%s: wname %s cname %s value %u shift %d item %ld\n",
  2137. __func__,
  2138. widget->name, ucontrol->id.name, tasha_p->tx_port_value,
  2139. widget->shift, ucontrol->value.integer.value[0]);
  2140. mutex_lock(&tasha_p->codec_mutex);
  2141. if (tasha_p->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2142. if (dai_id != AIF1_CAP) {
  2143. dev_err(component->dev, "%s: invalid AIF for I2C mode\n",
  2144. __func__);
  2145. mutex_unlock(&tasha_p->codec_mutex);
  2146. return -EINVAL;
  2147. }
  2148. vtable = vport_slim_check_table[dai_id];
  2149. } else {
  2150. if (dai_id >= ARRAY_SIZE(vport_i2s_check_table)) {
  2151. dev_err(component->dev, "%s: dai_id: %d, out of bounds\n",
  2152. __func__, dai_id);
  2153. return -EINVAL;
  2154. }
  2155. vtable = vport_i2s_check_table[dai_id];
  2156. }
  2157. switch (dai_id) {
  2158. case AIF1_CAP:
  2159. case AIF2_CAP:
  2160. case AIF3_CAP:
  2161. /* only add to the list if value not set */
  2162. if (enable && !(tasha_p->tx_port_value & 1 << port_id)) {
  2163. if (wcd9xxx_tx_vport_validation(vtable, port_id,
  2164. tasha_p->dai, NUM_CODEC_DAIS)) {
  2165. dev_dbg(component->dev, "%s: TX%u is used by other virtual port\n",
  2166. __func__, port_id);
  2167. mutex_unlock(&tasha_p->codec_mutex);
  2168. return 0;
  2169. }
  2170. tasha_p->tx_port_value |= 1 << port_id;
  2171. list_add_tail(&core->tx_chs[port_id].list,
  2172. &tasha_p->dai[dai_id].wcd9xxx_ch_list
  2173. );
  2174. } else if (!enable && (tasha_p->tx_port_value &
  2175. 1 << port_id)) {
  2176. tasha_p->tx_port_value &= ~(1 << port_id);
  2177. list_del_init(&core->tx_chs[port_id].list);
  2178. } else {
  2179. if (enable)
  2180. dev_dbg(component->dev, "%s: TX%u port is used by\n"
  2181. "this virtual port\n",
  2182. __func__, port_id);
  2183. else
  2184. dev_dbg(component->dev, "%s: TX%u port is not used by\n"
  2185. "this virtual port\n",
  2186. __func__, port_id);
  2187. /* avoid update power function */
  2188. mutex_unlock(&tasha_p->codec_mutex);
  2189. return 0;
  2190. }
  2191. break;
  2192. case AIF4_MAD_TX:
  2193. case AIF5_CPE_TX:
  2194. break;
  2195. default:
  2196. pr_err("Unknown AIF %d\n", dai_id);
  2197. mutex_unlock(&tasha_p->codec_mutex);
  2198. return -EINVAL;
  2199. }
  2200. pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__,
  2201. widget->name, widget->sname, tasha_p->tx_port_value,
  2202. widget->shift);
  2203. mutex_unlock(&tasha_p->codec_mutex);
  2204. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
  2205. return 0;
  2206. }
  2207. static int slim_rx_mux_get(struct snd_kcontrol *kcontrol,
  2208. struct snd_ctl_elem_value *ucontrol)
  2209. {
  2210. struct snd_soc_dapm_widget *widget =
  2211. snd_soc_dapm_kcontrol_widget(kcontrol);
  2212. struct snd_soc_component *component =
  2213. snd_soc_dapm_to_component(widget->dapm);
  2214. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  2215. ucontrol->value.enumerated.item[0] =
  2216. tasha_p->rx_port_value[widget->shift];
  2217. return 0;
  2218. }
  2219. static const char *const slim_rx_mux_text[] = {
  2220. "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB", "AIF_MIX1_PB"
  2221. };
  2222. static int slim_rx_mux_put(struct snd_kcontrol *kcontrol,
  2223. struct snd_ctl_elem_value *ucontrol)
  2224. {
  2225. struct snd_soc_dapm_widget *widget =
  2226. snd_soc_dapm_kcontrol_widget(kcontrol);
  2227. struct snd_soc_component *component =
  2228. snd_soc_dapm_to_component(widget->dapm);
  2229. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  2230. struct wcd9xxx *core = dev_get_drvdata(component->dev->parent);
  2231. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  2232. struct snd_soc_dapm_update *update = NULL;
  2233. unsigned int rx_port_value;
  2234. u32 port_id = widget->shift;
  2235. tasha_p->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
  2236. rx_port_value = tasha_p->rx_port_value[port_id];
  2237. pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__,
  2238. widget->name, ucontrol->id.name, rx_port_value,
  2239. widget->shift, ucontrol->value.integer.value[0]);
  2240. mutex_lock(&tasha_p->codec_mutex);
  2241. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2242. if (rx_port_value > 2) {
  2243. dev_err(component->dev, "%s: invalid AIF for I2C mode\n",
  2244. __func__);
  2245. goto err;
  2246. }
  2247. }
  2248. /* value need to match the Virtual port and AIF number */
  2249. switch (rx_port_value) {
  2250. case 0:
  2251. list_del_init(&core->rx_chs[port_id].list);
  2252. break;
  2253. case 1:
  2254. if (wcd9xxx_rx_vport_validation(port_id +
  2255. TASHA_RX_PORT_START_NUMBER,
  2256. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list)) {
  2257. dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2258. __func__, port_id);
  2259. goto rtn;
  2260. }
  2261. list_add_tail(&core->rx_chs[port_id].list,
  2262. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list);
  2263. break;
  2264. case 2:
  2265. if (wcd9xxx_rx_vport_validation(port_id +
  2266. TASHA_RX_PORT_START_NUMBER,
  2267. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list)) {
  2268. dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2269. __func__, port_id);
  2270. goto rtn;
  2271. }
  2272. list_add_tail(&core->rx_chs[port_id].list,
  2273. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list);
  2274. break;
  2275. case 3:
  2276. if (wcd9xxx_rx_vport_validation(port_id +
  2277. TASHA_RX_PORT_START_NUMBER,
  2278. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list)) {
  2279. dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2280. __func__, port_id);
  2281. goto rtn;
  2282. }
  2283. list_add_tail(&core->rx_chs[port_id].list,
  2284. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list);
  2285. break;
  2286. case 4:
  2287. if (wcd9xxx_rx_vport_validation(port_id +
  2288. TASHA_RX_PORT_START_NUMBER,
  2289. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list)) {
  2290. dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2291. __func__, port_id);
  2292. goto rtn;
  2293. }
  2294. list_add_tail(&core->rx_chs[port_id].list,
  2295. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list);
  2296. break;
  2297. case 5:
  2298. if (wcd9xxx_rx_vport_validation(port_id +
  2299. TASHA_RX_PORT_START_NUMBER,
  2300. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list)) {
  2301. dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2302. __func__, port_id);
  2303. goto rtn;
  2304. }
  2305. list_add_tail(&core->rx_chs[port_id].list,
  2306. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list);
  2307. break;
  2308. default:
  2309. pr_err("Unknown AIF %d\n", rx_port_value);
  2310. goto err;
  2311. }
  2312. rtn:
  2313. mutex_unlock(&tasha_p->codec_mutex);
  2314. snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
  2315. rx_port_value, e, update);
  2316. return 0;
  2317. err:
  2318. mutex_unlock(&tasha_p->codec_mutex);
  2319. return -EINVAL;
  2320. }
  2321. static const struct soc_enum slim_rx_mux_enum =
  2322. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text);
  2323. static const struct snd_kcontrol_new slim_rx_mux[TASHA_RX_MAX] = {
  2324. SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum,
  2325. slim_rx_mux_get, slim_rx_mux_put),
  2326. SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
  2327. slim_rx_mux_get, slim_rx_mux_put),
  2328. SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
  2329. slim_rx_mux_get, slim_rx_mux_put),
  2330. SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
  2331. slim_rx_mux_get, slim_rx_mux_put),
  2332. SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
  2333. slim_rx_mux_get, slim_rx_mux_put),
  2334. SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
  2335. slim_rx_mux_get, slim_rx_mux_put),
  2336. SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
  2337. slim_rx_mux_get, slim_rx_mux_put),
  2338. SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
  2339. slim_rx_mux_get, slim_rx_mux_put),
  2340. };
  2341. static const struct snd_kcontrol_new aif4_vi_mixer[] = {
  2342. SOC_SINGLE_EXT("SPKR_VI_1", SND_SOC_NOPM, TASHA_TX14, 1, 0,
  2343. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2344. SOC_SINGLE_EXT("SPKR_VI_2", SND_SOC_NOPM, TASHA_TX15, 1, 0,
  2345. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2346. };
  2347. static const struct snd_kcontrol_new aif1_cap_mixer[] = {
  2348. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2349. slim_tx_mixer_get, slim_tx_mixer_put),
  2350. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2351. slim_tx_mixer_get, slim_tx_mixer_put),
  2352. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2353. slim_tx_mixer_get, slim_tx_mixer_put),
  2354. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2355. slim_tx_mixer_get, slim_tx_mixer_put),
  2356. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2357. slim_tx_mixer_get, slim_tx_mixer_put),
  2358. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2359. slim_tx_mixer_get, slim_tx_mixer_put),
  2360. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2361. slim_tx_mixer_get, slim_tx_mixer_put),
  2362. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2363. slim_tx_mixer_get, slim_tx_mixer_put),
  2364. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2365. slim_tx_mixer_get, slim_tx_mixer_put),
  2366. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2367. slim_tx_mixer_get, slim_tx_mixer_put),
  2368. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2369. slim_tx_mixer_get, slim_tx_mixer_put),
  2370. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2371. slim_tx_mixer_get, slim_tx_mixer_put),
  2372. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2373. slim_tx_mixer_get, slim_tx_mixer_put),
  2374. };
  2375. static const struct snd_kcontrol_new aif2_cap_mixer[] = {
  2376. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2377. slim_tx_mixer_get, slim_tx_mixer_put),
  2378. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2379. slim_tx_mixer_get, slim_tx_mixer_put),
  2380. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2381. slim_tx_mixer_get, slim_tx_mixer_put),
  2382. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2383. slim_tx_mixer_get, slim_tx_mixer_put),
  2384. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2385. slim_tx_mixer_get, slim_tx_mixer_put),
  2386. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2387. slim_tx_mixer_get, slim_tx_mixer_put),
  2388. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2389. slim_tx_mixer_get, slim_tx_mixer_put),
  2390. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2391. slim_tx_mixer_get, slim_tx_mixer_put),
  2392. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2393. slim_tx_mixer_get, slim_tx_mixer_put),
  2394. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2395. slim_tx_mixer_get, slim_tx_mixer_put),
  2396. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2397. slim_tx_mixer_get, slim_tx_mixer_put),
  2398. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2399. slim_tx_mixer_get, slim_tx_mixer_put),
  2400. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2401. slim_tx_mixer_get, slim_tx_mixer_put),
  2402. };
  2403. static const struct snd_kcontrol_new aif3_cap_mixer[] = {
  2404. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2405. slim_tx_mixer_get, slim_tx_mixer_put),
  2406. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2407. slim_tx_mixer_get, slim_tx_mixer_put),
  2408. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2409. slim_tx_mixer_get, slim_tx_mixer_put),
  2410. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2411. slim_tx_mixer_get, slim_tx_mixer_put),
  2412. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2413. slim_tx_mixer_get, slim_tx_mixer_put),
  2414. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2415. slim_tx_mixer_get, slim_tx_mixer_put),
  2416. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2417. slim_tx_mixer_get, slim_tx_mixer_put),
  2418. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2419. slim_tx_mixer_get, slim_tx_mixer_put),
  2420. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2421. slim_tx_mixer_get, slim_tx_mixer_put),
  2422. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2423. slim_tx_mixer_get, slim_tx_mixer_put),
  2424. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2425. slim_tx_mixer_get, slim_tx_mixer_put),
  2426. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2427. slim_tx_mixer_get, slim_tx_mixer_put),
  2428. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2429. slim_tx_mixer_get, slim_tx_mixer_put),
  2430. };
  2431. static const struct snd_kcontrol_new aif4_mad_mixer[] = {
  2432. SOC_SINGLE_EXT("SLIM TX12", SND_SOC_NOPM, TASHA_TX12, 1, 0,
  2433. slim_tx_mixer_get, slim_tx_mixer_put),
  2434. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2435. slim_tx_mixer_get, slim_tx_mixer_put),
  2436. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, 0, 1, 0,
  2437. slim_tx_mixer_get, slim_tx_mixer_put),
  2438. };
  2439. static const struct snd_kcontrol_new rx_int1_spline_mix_switch[] = {
  2440. SOC_DAPM_SINGLE("HPHL Switch", SND_SOC_NOPM, 0, 1, 0)
  2441. };
  2442. static const struct snd_kcontrol_new rx_int2_spline_mix_switch[] = {
  2443. SOC_DAPM_SINGLE("HPHR Switch", SND_SOC_NOPM, 0, 1, 0)
  2444. };
  2445. static const struct snd_kcontrol_new rx_int3_spline_mix_switch[] = {
  2446. SOC_DAPM_SINGLE("LO1 Switch", SND_SOC_NOPM, 0, 1, 0)
  2447. };
  2448. static const struct snd_kcontrol_new rx_int4_spline_mix_switch[] = {
  2449. SOC_DAPM_SINGLE("LO2 Switch", SND_SOC_NOPM, 0, 1, 0)
  2450. };
  2451. static const struct snd_kcontrol_new rx_int5_spline_mix_switch[] = {
  2452. SOC_DAPM_SINGLE("LO3 Switch", SND_SOC_NOPM, 0, 1, 0)
  2453. };
  2454. static const struct snd_kcontrol_new rx_int6_spline_mix_switch[] = {
  2455. SOC_DAPM_SINGLE("LO4 Switch", SND_SOC_NOPM, 0, 1, 0)
  2456. };
  2457. static const struct snd_kcontrol_new rx_int7_spline_mix_switch[] = {
  2458. SOC_DAPM_SINGLE("SPKRL Switch", SND_SOC_NOPM, 0, 1, 0)
  2459. };
  2460. static const struct snd_kcontrol_new rx_int8_spline_mix_switch[] = {
  2461. SOC_DAPM_SINGLE("SPKRR Switch", SND_SOC_NOPM, 0, 1, 0)
  2462. };
  2463. static const struct snd_kcontrol_new rx_int5_vbat_mix_switch[] = {
  2464. SOC_DAPM_SINGLE("LO3 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2465. };
  2466. static const struct snd_kcontrol_new rx_int6_vbat_mix_switch[] = {
  2467. SOC_DAPM_SINGLE("LO4 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2468. };
  2469. static const struct snd_kcontrol_new rx_int7_vbat_mix_switch[] = {
  2470. SOC_DAPM_SINGLE("SPKRL VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2471. };
  2472. static const struct snd_kcontrol_new rx_int8_vbat_mix_switch[] = {
  2473. SOC_DAPM_SINGLE("SPKRR VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2474. };
  2475. static const struct snd_kcontrol_new cpe_in_mix_switch[] = {
  2476. SOC_DAPM_SINGLE("MAD_BYPASS", SND_SOC_NOPM, 0, 1, 0)
  2477. };
  2478. static int tasha_put_iir_enable_audio_mixer(
  2479. struct snd_kcontrol *kcontrol,
  2480. struct snd_ctl_elem_value *ucontrol)
  2481. {
  2482. struct snd_soc_component *component =
  2483. snd_soc_kcontrol_component(kcontrol);
  2484. int iir_idx = ((struct soc_multi_mixer_control *)
  2485. kcontrol->private_value)->reg;
  2486. int band_idx = ((struct soc_multi_mixer_control *)
  2487. kcontrol->private_value)->shift;
  2488. bool iir_band_en_status;
  2489. int value = ucontrol->value.integer.value[0];
  2490. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  2491. /* Mask first 5 bits, 6-8 are reserved */
  2492. snd_soc_component_update_bits(component, iir_reg, (1 << band_idx),
  2493. (value << band_idx));
  2494. iir_band_en_status = ((snd_soc_component_read32(component, iir_reg) &
  2495. (1 << band_idx)) != 0);
  2496. pr_debug("%s: IIR #%d band #%d enable %d\n", __func__,
  2497. iir_idx, band_idx, iir_band_en_status);
  2498. return 0;
  2499. }
  2500. static uint32_t get_iir_band_coeff(struct snd_soc_component *component,
  2501. int iir_idx, int band_idx,
  2502. int coeff_idx)
  2503. {
  2504. uint32_t value = 0;
  2505. /* Address does not automatically update if reading */
  2506. snd_soc_component_write(component,
  2507. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2508. ((band_idx * BAND_MAX + coeff_idx)
  2509. * sizeof(uint32_t)) & 0x7F);
  2510. value |= snd_soc_component_read32(component,
  2511. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx));
  2512. snd_soc_component_write(component,
  2513. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2514. ((band_idx * BAND_MAX + coeff_idx)
  2515. * sizeof(uint32_t) + 1) & 0x7F);
  2516. value |= (snd_soc_component_read32(component,
  2517. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2518. 16 * iir_idx)) << 8);
  2519. snd_soc_component_write(component,
  2520. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2521. ((band_idx * BAND_MAX + coeff_idx)
  2522. * sizeof(uint32_t) + 2) & 0x7F);
  2523. value |= (snd_soc_component_read32(component,
  2524. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2525. 16 * iir_idx)) << 16);
  2526. snd_soc_component_write(component,
  2527. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2528. ((band_idx * BAND_MAX + coeff_idx)
  2529. * sizeof(uint32_t) + 3) & 0x7F);
  2530. /* Mask bits top 2 bits since they are reserved */
  2531. value |= ((snd_soc_component_read32(component,
  2532. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2533. 16 * iir_idx)) & 0x3F) << 24);
  2534. return value;
  2535. }
  2536. static int tasha_get_iir_band_audio_mixer(
  2537. struct snd_kcontrol *kcontrol,
  2538. struct snd_ctl_elem_value *ucontrol)
  2539. {
  2540. struct snd_soc_component *component =
  2541. snd_soc_kcontrol_component(kcontrol);
  2542. int iir_idx = ((struct soc_multi_mixer_control *)
  2543. kcontrol->private_value)->reg;
  2544. int band_idx = ((struct soc_multi_mixer_control *)
  2545. kcontrol->private_value)->shift;
  2546. ucontrol->value.integer.value[0] =
  2547. get_iir_band_coeff(component, iir_idx, band_idx, 0);
  2548. ucontrol->value.integer.value[1] =
  2549. get_iir_band_coeff(component, iir_idx, band_idx, 1);
  2550. ucontrol->value.integer.value[2] =
  2551. get_iir_band_coeff(component, iir_idx, band_idx, 2);
  2552. ucontrol->value.integer.value[3] =
  2553. get_iir_band_coeff(component, iir_idx, band_idx, 3);
  2554. ucontrol->value.integer.value[4] =
  2555. get_iir_band_coeff(component, iir_idx, band_idx, 4);
  2556. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  2557. "%s: IIR #%d band #%d b1 = 0x%x\n"
  2558. "%s: IIR #%d band #%d b2 = 0x%x\n"
  2559. "%s: IIR #%d band #%d a1 = 0x%x\n"
  2560. "%s: IIR #%d band #%d a2 = 0x%x\n",
  2561. __func__, iir_idx, band_idx,
  2562. (uint32_t)ucontrol->value.integer.value[0],
  2563. __func__, iir_idx, band_idx,
  2564. (uint32_t)ucontrol->value.integer.value[1],
  2565. __func__, iir_idx, band_idx,
  2566. (uint32_t)ucontrol->value.integer.value[2],
  2567. __func__, iir_idx, band_idx,
  2568. (uint32_t)ucontrol->value.integer.value[3],
  2569. __func__, iir_idx, band_idx,
  2570. (uint32_t)ucontrol->value.integer.value[4]);
  2571. return 0;
  2572. }
  2573. static void set_iir_band_coeff(struct snd_soc_component *component,
  2574. int iir_idx, int band_idx,
  2575. uint32_t value)
  2576. {
  2577. snd_soc_component_write(component,
  2578. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2579. (value & 0xFF));
  2580. snd_soc_component_write(component,
  2581. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2582. (value >> 8) & 0xFF);
  2583. snd_soc_component_write(component,
  2584. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2585. (value >> 16) & 0xFF);
  2586. /* Mask top 2 bits, 7-8 are reserved */
  2587. snd_soc_component_write(component,
  2588. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2589. (value >> 24) & 0x3F);
  2590. }
  2591. static void tasha_codec_enable_int_port(struct wcd9xxx_codec_dai_data *dai,
  2592. struct snd_soc_component *component)
  2593. {
  2594. struct wcd9xxx_ch *ch;
  2595. int port_num = 0;
  2596. unsigned short reg = 0;
  2597. u8 val = 0;
  2598. struct tasha_priv *tasha_p;
  2599. if (!dai || !component) {
  2600. pr_err("%s: Invalid params\n", __func__);
  2601. return;
  2602. }
  2603. tasha_p = snd_soc_component_get_drvdata(component);
  2604. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2605. if (ch->port >= TASHA_RX_PORT_START_NUMBER) {
  2606. port_num = ch->port - TASHA_RX_PORT_START_NUMBER;
  2607. reg = TASHA_SLIM_PGD_PORT_INT_EN0 + (port_num / 8);
  2608. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2609. reg);
  2610. if (!(val & BYTE_BIT_MASK(port_num))) {
  2611. val |= BYTE_BIT_MASK(port_num);
  2612. wcd9xxx_interface_reg_write(
  2613. tasha_p->wcd9xxx, reg, val);
  2614. val = wcd9xxx_interface_reg_read(
  2615. tasha_p->wcd9xxx, reg);
  2616. }
  2617. } else {
  2618. port_num = ch->port;
  2619. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 + (port_num / 8);
  2620. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2621. reg);
  2622. if (!(val & BYTE_BIT_MASK(port_num))) {
  2623. val |= BYTE_BIT_MASK(port_num);
  2624. wcd9xxx_interface_reg_write(tasha_p->wcd9xxx,
  2625. reg, val);
  2626. val = wcd9xxx_interface_reg_read(
  2627. tasha_p->wcd9xxx, reg);
  2628. }
  2629. }
  2630. }
  2631. }
  2632. static int tasha_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai,
  2633. bool up)
  2634. {
  2635. int ret = 0;
  2636. struct wcd9xxx_ch *ch;
  2637. if (up) {
  2638. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2639. ret = wcd9xxx_get_slave_port(ch->ch_num);
  2640. if (ret < 0) {
  2641. pr_err("%s: Invalid slave port ID: %d\n",
  2642. __func__, ret);
  2643. ret = -EINVAL;
  2644. } else {
  2645. set_bit(ret, &dai->ch_mask);
  2646. }
  2647. }
  2648. } else {
  2649. ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0),
  2650. msecs_to_jiffies(
  2651. TASHA_SLIM_CLOSE_TIMEOUT));
  2652. if (!ret) {
  2653. pr_err("%s: Slim close tx/rx wait timeout, ch_mask:0x%lx\n",
  2654. __func__, dai->ch_mask);
  2655. ret = -ETIMEDOUT;
  2656. } else {
  2657. ret = 0;
  2658. }
  2659. }
  2660. return ret;
  2661. }
  2662. static int tasha_codec_enable_slimrx(struct snd_soc_dapm_widget *w,
  2663. struct snd_kcontrol *kcontrol,
  2664. int event)
  2665. {
  2666. struct wcd9xxx *core;
  2667. struct snd_soc_component *component =
  2668. snd_soc_dapm_to_component(w->dapm);
  2669. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  2670. int ret = 0;
  2671. struct wcd9xxx_codec_dai_data *dai;
  2672. core = dev_get_drvdata(component->dev->parent);
  2673. dev_dbg(component->dev, "%s: event called! component name %s num_dai %d\n"
  2674. "stream name %s event %d\n",
  2675. __func__, component->name,
  2676. component->num_dai, w->sname, event);
  2677. /* Execute the callback only if interface type is slimbus */
  2678. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2679. return 0;
  2680. dai = &tasha_p->dai[w->shift];
  2681. dev_dbg(component->dev, "%s: w->name %s w->shift %d event %d\n",
  2682. __func__, w->name, w->shift, event);
  2683. switch (event) {
  2684. case SND_SOC_DAPM_POST_PMU:
  2685. dai->bus_down_in_recovery = false;
  2686. tasha_codec_enable_int_port(dai, component);
  2687. (void) tasha_codec_enable_slim_chmask(dai, true);
  2688. ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2689. dai->rate, dai->bit_width,
  2690. &dai->grph);
  2691. break;
  2692. case SND_SOC_DAPM_PRE_PMD:
  2693. tasha_codec_vote_max_bw(component, true);
  2694. break;
  2695. case SND_SOC_DAPM_POST_PMD:
  2696. ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list,
  2697. dai->grph);
  2698. dev_dbg(component->dev, "%s: Disconnect RX port, ret = %d\n",
  2699. __func__, ret);
  2700. if (!dai->bus_down_in_recovery)
  2701. ret = tasha_codec_enable_slim_chmask(dai, false);
  2702. else
  2703. dev_dbg(component->dev,
  2704. "%s: bus in recovery skip enable slim_chmask",
  2705. __func__);
  2706. ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2707. dai->grph);
  2708. break;
  2709. }
  2710. return ret;
  2711. }
  2712. static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w,
  2713. struct snd_kcontrol *kcontrol,
  2714. int event)
  2715. {
  2716. struct wcd9xxx *core = NULL;
  2717. struct snd_soc_component *component = NULL;
  2718. struct tasha_priv *tasha_p = NULL;
  2719. int ret = 0;
  2720. struct wcd9xxx_codec_dai_data *dai = NULL;
  2721. if (!w) {
  2722. pr_err("%s invalid params\n", __func__);
  2723. return -EINVAL;
  2724. }
  2725. component = snd_soc_dapm_to_component(w->dapm);
  2726. tasha_p = snd_soc_component_get_drvdata(component);
  2727. core = tasha_p->wcd9xxx;
  2728. dev_dbg(component->dev, "%s: num_dai %d stream name %s\n",
  2729. __func__, component->num_dai, w->sname);
  2730. /* Execute the callback only if interface type is slimbus */
  2731. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2732. dev_err(component->dev, "%s Interface is not correct",
  2733. __func__);
  2734. return 0;
  2735. }
  2736. dev_dbg(component->dev, "%s(): w->name %s event %d w->shift %d\n",
  2737. __func__, w->name, event, w->shift);
  2738. if (w->shift != AIF4_VIFEED) {
  2739. pr_err("%s Error in enabling the tx path\n", __func__);
  2740. ret = -EINVAL;
  2741. goto out_vi;
  2742. }
  2743. dai = &tasha_p->dai[w->shift];
  2744. switch (event) {
  2745. case SND_SOC_DAPM_POST_PMU:
  2746. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2747. dev_dbg(component->dev, "%s: spkr1 enabled\n",
  2748. __func__);
  2749. /* Enable V&I sensing */
  2750. snd_soc_component_update_bits(component,
  2751. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2752. snd_soc_component_update_bits(component,
  2753. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2754. 0x20);
  2755. snd_soc_component_update_bits(component,
  2756. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x00);
  2757. snd_soc_component_update_bits(component,
  2758. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x0F,
  2759. 0x00);
  2760. snd_soc_component_update_bits(component,
  2761. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10);
  2762. snd_soc_component_update_bits(component,
  2763. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2764. 0x10);
  2765. snd_soc_component_update_bits(component,
  2766. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00);
  2767. snd_soc_component_update_bits(component,
  2768. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2769. 0x00);
  2770. }
  2771. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2772. pr_debug("%s: spkr2 enabled\n", __func__);
  2773. /* Enable V&I sensing */
  2774. snd_soc_component_update_bits(component,
  2775. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2776. 0x20);
  2777. snd_soc_component_update_bits(component,
  2778. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2779. 0x20);
  2780. snd_soc_component_update_bits(component,
  2781. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x0F,
  2782. 0x00);
  2783. snd_soc_component_update_bits(component,
  2784. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x0F,
  2785. 0x00);
  2786. snd_soc_component_update_bits(component,
  2787. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2788. 0x10);
  2789. snd_soc_component_update_bits(component,
  2790. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2791. 0x10);
  2792. snd_soc_component_update_bits(component,
  2793. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2794. 0x00);
  2795. snd_soc_component_update_bits(component,
  2796. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2797. 0x00);
  2798. }
  2799. dai->bus_down_in_recovery = false;
  2800. tasha_codec_enable_int_port(dai, component);
  2801. (void) tasha_codec_enable_slim_chmask(dai, true);
  2802. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2803. dai->rate, dai->bit_width,
  2804. &dai->grph);
  2805. break;
  2806. case SND_SOC_DAPM_POST_PMD:
  2807. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2808. dai->grph);
  2809. if (ret)
  2810. dev_err(component->dev, "%s error in close_slim_sch_tx %d\n",
  2811. __func__, ret);
  2812. if (!dai->bus_down_in_recovery)
  2813. ret = tasha_codec_enable_slim_chmask(dai, false);
  2814. if (ret < 0) {
  2815. ret = wcd9xxx_disconnect_port(core,
  2816. &dai->wcd9xxx_ch_list,
  2817. dai->grph);
  2818. dev_dbg(component->dev, "%s: Disconnect TX port, ret = %d\n",
  2819. __func__, ret);
  2820. }
  2821. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2822. /* Disable V&I sensing */
  2823. dev_dbg(component->dev, "%s: spkr1 disabled\n",
  2824. __func__);
  2825. snd_soc_component_update_bits(component,
  2826. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2827. snd_soc_component_update_bits(component,
  2828. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2829. 0x20);
  2830. snd_soc_component_update_bits(component,
  2831. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00);
  2832. snd_soc_component_update_bits(component,
  2833. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2834. 0x00);
  2835. }
  2836. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2837. /* Disable V&I sensing */
  2838. dev_dbg(component->dev, "%s: spkr2 disabled\n",
  2839. __func__);
  2840. snd_soc_component_update_bits(component,
  2841. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2842. 0x20);
  2843. snd_soc_component_update_bits(component,
  2844. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2845. 0x20);
  2846. snd_soc_component_update_bits(component,
  2847. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2848. 0x00);
  2849. snd_soc_component_update_bits(component,
  2850. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2851. 0x00);
  2852. }
  2853. break;
  2854. }
  2855. out_vi:
  2856. return ret;
  2857. }
  2858. /*
  2859. * __tasha_codec_enable_slimtx: Enable the slimbus slave port
  2860. * for TX path
  2861. * @component: Handle to the codec for which the slave port is to be
  2862. * enabled.
  2863. * @dai_data: The dai specific data for dai which is enabled.
  2864. */
  2865. static int __tasha_codec_enable_slimtx(struct snd_soc_component *component,
  2866. int event, struct wcd9xxx_codec_dai_data *dai)
  2867. {
  2868. struct wcd9xxx *core;
  2869. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  2870. int ret = 0;
  2871. /* Execute the callback only if interface type is slimbus */
  2872. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2873. return 0;
  2874. dev_dbg(component->dev,
  2875. "%s: event = %d\n", __func__, event);
  2876. core = dev_get_drvdata(component->dev->parent);
  2877. switch (event) {
  2878. case SND_SOC_DAPM_POST_PMU:
  2879. dai->bus_down_in_recovery = false;
  2880. tasha_codec_enable_int_port(dai, component);
  2881. (void) tasha_codec_enable_slim_chmask(dai, true);
  2882. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2883. dai->rate, dai->bit_width,
  2884. &dai->grph);
  2885. break;
  2886. case SND_SOC_DAPM_POST_PMD:
  2887. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2888. dai->grph);
  2889. if (!dai->bus_down_in_recovery)
  2890. ret = tasha_codec_enable_slim_chmask(dai, false);
  2891. if (ret < 0) {
  2892. ret = wcd9xxx_disconnect_port(core,
  2893. &dai->wcd9xxx_ch_list,
  2894. dai->grph);
  2895. pr_debug("%s: Disconnect TX port, ret = %d\n",
  2896. __func__, ret);
  2897. }
  2898. break;
  2899. }
  2900. return ret;
  2901. }
  2902. static int tasha_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
  2903. struct snd_kcontrol *kcontrol,
  2904. int event)
  2905. {
  2906. struct snd_soc_component *component =
  2907. snd_soc_dapm_to_component(w->dapm);
  2908. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  2909. struct wcd9xxx_codec_dai_data *dai;
  2910. dev_dbg(component->dev,
  2911. "%s: w->name %s, w->shift = %d, num_dai %d stream name %s\n",
  2912. __func__, w->name, w->shift,
  2913. component->num_dai, w->sname);
  2914. dai = &tasha_p->dai[w->shift];
  2915. return __tasha_codec_enable_slimtx(component, event, dai);
  2916. }
  2917. static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_component *component,
  2918. int event)
  2919. {
  2920. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  2921. struct wcd9xxx_codec_dai_data *dai;
  2922. u8 bit_width, rate, buf_period;
  2923. dai = &tasha_p->dai[AIF4_MAD_TX];
  2924. switch (event) {
  2925. case SND_SOC_DAPM_POST_PMU:
  2926. switch (dai->bit_width) {
  2927. case 32:
  2928. bit_width = 0xF;
  2929. break;
  2930. case 24:
  2931. bit_width = 0xE;
  2932. break;
  2933. case 20:
  2934. bit_width = 0xD;
  2935. break;
  2936. case 16:
  2937. default:
  2938. bit_width = 0x0;
  2939. break;
  2940. }
  2941. snd_soc_component_update_bits(component,
  2942. WCD9335_CPE_SS_TX_PP_CFG, 0x0F, bit_width);
  2943. switch (dai->rate) {
  2944. case 384000:
  2945. rate = 0x30;
  2946. break;
  2947. case 192000:
  2948. rate = 0x20;
  2949. break;
  2950. case 48000:
  2951. rate = 0x10;
  2952. break;
  2953. case 16000:
  2954. default:
  2955. rate = 0x00;
  2956. break;
  2957. }
  2958. snd_soc_component_update_bits(component,
  2959. WCD9335_CPE_SS_TX_PP_CFG, 0x70, rate);
  2960. buf_period = (dai->rate * (dai->bit_width/8)) / (16*1000);
  2961. snd_soc_component_update_bits(component,
  2962. WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD,
  2963. 0xFF, buf_period);
  2964. dev_dbg(component->dev, "%s: PP buffer period= 0x%x\n",
  2965. __func__, buf_period);
  2966. break;
  2967. case SND_SOC_DAPM_POST_PMD:
  2968. snd_soc_component_write(component, WCD9335_CPE_SS_TX_PP_CFG,
  2969. 0x3C);
  2970. snd_soc_component_write(component,
  2971. WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD,
  2972. 0x60);
  2973. break;
  2974. default:
  2975. break;
  2976. }
  2977. }
  2978. /*
  2979. * tasha_codec_get_mad_port_id: Callback function that will be invoked
  2980. * to get the port ID for MAD.
  2981. * @component: Handle to the codec
  2982. * @port_id: cpe port_id needs to enable
  2983. */
  2984. static int tasha_codec_get_mad_port_id(struct snd_soc_component *component,
  2985. u16 *port_id)
  2986. {
  2987. struct tasha_priv *tasha_p;
  2988. struct wcd9xxx_codec_dai_data *dai;
  2989. struct wcd9xxx_ch *ch;
  2990. if (!port_id || !component)
  2991. return -EINVAL;
  2992. tasha_p = snd_soc_component_get_drvdata(component);
  2993. if (!tasha_p)
  2994. return -EINVAL;
  2995. dai = &tasha_p->dai[AIF4_MAD_TX];
  2996. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2997. if (ch->port == TASHA_TX12)
  2998. *port_id = WCD_CPE_AFE_OUT_PORT_2;
  2999. else if (ch->port == TASHA_TX13)
  3000. *port_id = WCD_CPE_AFE_OUT_PORT_4;
  3001. else {
  3002. dev_err(component->dev, "%s: invalid mad_port = %d\n",
  3003. __func__, ch->port);
  3004. return -EINVAL;
  3005. }
  3006. }
  3007. dev_dbg(component->dev, "%s: port_id = %d\n", __func__, *port_id);
  3008. return 0;
  3009. }
  3010. /*
  3011. * tasha_codec_enable_slimtx_mad: Callback function that will be invoked
  3012. * to setup the slave port for MAD.
  3013. * @component: Handle to the codec
  3014. * @event: Indicates whether to enable or disable the slave port
  3015. */
  3016. static int tasha_codec_enable_slimtx_mad(struct snd_soc_component *component,
  3017. u8 event)
  3018. {
  3019. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  3020. struct wcd9xxx_codec_dai_data *dai;
  3021. struct wcd9xxx_ch *ch;
  3022. int dapm_event = SND_SOC_DAPM_POST_PMU;
  3023. u16 port = 0;
  3024. int ret = 0;
  3025. dai = &tasha_p->dai[AIF4_MAD_TX];
  3026. if (event == 0)
  3027. dapm_event = SND_SOC_DAPM_POST_PMD;
  3028. dev_dbg(component->dev,
  3029. "%s: mad_channel, event = 0x%x\n",
  3030. __func__, event);
  3031. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  3032. dev_dbg(component->dev, "%s: mad_port = %d, event = 0x%x\n",
  3033. __func__, ch->port, event);
  3034. if (ch->port == TASHA_TX13) {
  3035. tasha_codec_cpe_pp_set_cfg(component, dapm_event);
  3036. port = TASHA_TX13;
  3037. break;
  3038. }
  3039. }
  3040. ret = __tasha_codec_enable_slimtx(component, dapm_event, dai);
  3041. if (port == TASHA_TX13) {
  3042. switch (dapm_event) {
  3043. case SND_SOC_DAPM_POST_PMU:
  3044. snd_soc_component_update_bits(component,
  3045. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  3046. 0x20, 0x00);
  3047. snd_soc_component_update_bits(component,
  3048. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  3049. 0x03, 0x02);
  3050. snd_soc_component_update_bits(component,
  3051. WCD9335_CPE_SS_CFG,
  3052. 0x80, 0x80);
  3053. break;
  3054. case SND_SOC_DAPM_POST_PMD:
  3055. snd_soc_component_update_bits(component,
  3056. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  3057. 0x20, 0x20);
  3058. snd_soc_component_update_bits(component,
  3059. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  3060. 0x03, 0x00);
  3061. snd_soc_component_update_bits(component,
  3062. WCD9335_CPE_SS_CFG,
  3063. 0x80, 0x00);
  3064. break;
  3065. }
  3066. }
  3067. return ret;
  3068. }
  3069. static int tasha_put_iir_band_audio_mixer(
  3070. struct snd_kcontrol *kcontrol,
  3071. struct snd_ctl_elem_value *ucontrol)
  3072. {
  3073. struct snd_soc_component *component =
  3074. snd_soc_kcontrol_component(kcontrol);
  3075. int iir_idx = ((struct soc_multi_mixer_control *)
  3076. kcontrol->private_value)->reg;
  3077. int band_idx = ((struct soc_multi_mixer_control *)
  3078. kcontrol->private_value)->shift;
  3079. /*
  3080. * Mask top bit it is reserved
  3081. * Updates addr automatically for each B2 write
  3082. */
  3083. snd_soc_component_write(component,
  3084. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  3085. (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
  3086. set_iir_band_coeff(component, iir_idx, band_idx,
  3087. ucontrol->value.integer.value[0]);
  3088. set_iir_band_coeff(component, iir_idx, band_idx,
  3089. ucontrol->value.integer.value[1]);
  3090. set_iir_band_coeff(component, iir_idx, band_idx,
  3091. ucontrol->value.integer.value[2]);
  3092. set_iir_band_coeff(component, iir_idx, band_idx,
  3093. ucontrol->value.integer.value[3]);
  3094. set_iir_band_coeff(component, iir_idx, band_idx,
  3095. ucontrol->value.integer.value[4]);
  3096. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  3097. "%s: IIR #%d band #%d b1 = 0x%x\n"
  3098. "%s: IIR #%d band #%d b2 = 0x%x\n"
  3099. "%s: IIR #%d band #%d a1 = 0x%x\n"
  3100. "%s: IIR #%d band #%d a2 = 0x%x\n",
  3101. __func__, iir_idx, band_idx,
  3102. get_iir_band_coeff(component, iir_idx, band_idx, 0),
  3103. __func__, iir_idx, band_idx,
  3104. get_iir_band_coeff(component, iir_idx, band_idx, 1),
  3105. __func__, iir_idx, band_idx,
  3106. get_iir_band_coeff(component, iir_idx, band_idx, 2),
  3107. __func__, iir_idx, band_idx,
  3108. get_iir_band_coeff(component, iir_idx, band_idx, 3),
  3109. __func__, iir_idx, band_idx,
  3110. get_iir_band_coeff(component, iir_idx, band_idx, 4));
  3111. return 0;
  3112. }
  3113. static int tasha_get_compander(struct snd_kcontrol *kcontrol,
  3114. struct snd_ctl_elem_value *ucontrol)
  3115. {
  3116. struct snd_soc_component *component =
  3117. snd_soc_kcontrol_component(kcontrol);
  3118. int comp = ((struct soc_multi_mixer_control *)
  3119. kcontrol->private_value)->shift;
  3120. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  3121. ucontrol->value.integer.value[0] = tasha->comp_enabled[comp];
  3122. return 0;
  3123. }
  3124. static int tasha_set_compander(struct snd_kcontrol *kcontrol,
  3125. struct snd_ctl_elem_value *ucontrol)
  3126. {
  3127. struct snd_soc_component *component =
  3128. snd_soc_kcontrol_component(kcontrol);
  3129. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  3130. int comp = ((struct soc_multi_mixer_control *)
  3131. kcontrol->private_value)->shift;
  3132. int value = ucontrol->value.integer.value[0];
  3133. pr_debug("%s: Compander %d enable current %d, new %d\n",
  3134. __func__, comp + 1, tasha->comp_enabled[comp], value);
  3135. tasha->comp_enabled[comp] = value;
  3136. /* Any specific register configuration for compander */
  3137. switch (comp) {
  3138. case COMPANDER_1:
  3139. /* Set Gain Source Select based on compander enable/disable */
  3140. snd_soc_component_update_bits(component, WCD9335_HPH_L_EN, 0x20,
  3141. (value ? 0x00:0x20));
  3142. break;
  3143. case COMPANDER_2:
  3144. snd_soc_component_update_bits(component, WCD9335_HPH_R_EN, 0x20,
  3145. (value ? 0x00:0x20));
  3146. break;
  3147. case COMPANDER_3:
  3148. break;
  3149. case COMPANDER_4:
  3150. break;
  3151. case COMPANDER_5:
  3152. snd_soc_component_update_bits(component, WCD9335_SE_LO_LO3_GAIN,
  3153. 0x20, (value ? 0x00:0x20));
  3154. break;
  3155. case COMPANDER_6:
  3156. snd_soc_component_update_bits(component, WCD9335_SE_LO_LO4_GAIN,
  3157. 0x20, (value ? 0x00:0x20));
  3158. break;
  3159. case COMPANDER_7:
  3160. break;
  3161. case COMPANDER_8:
  3162. break;
  3163. default:
  3164. /*
  3165. * if compander is not enabled for any interpolator,
  3166. * it does not cause any audio failure, so do not
  3167. * return error in this case, but just print a log
  3168. */
  3169. dev_warn(component->dev, "%s: unknown compander: %d\n",
  3170. __func__, comp);
  3171. };
  3172. return 0;
  3173. }
  3174. static void tasha_codec_init_flyback(struct snd_soc_component *component)
  3175. {
  3176. snd_soc_component_update_bits(component, WCD9335_HPH_L_EN, 0xC0, 0x00);
  3177. snd_soc_component_update_bits(component, WCD9335_HPH_R_EN, 0xC0, 0x00);
  3178. snd_soc_component_update_bits(component, WCD9335_RX_BIAS_FLYB_BUFF,
  3179. 0x0F, 0x00);
  3180. snd_soc_component_update_bits(component, WCD9335_RX_BIAS_FLYB_BUFF,
  3181. 0xF0, 0x00);
  3182. }
  3183. static int tasha_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
  3184. struct snd_kcontrol *kcontrol, int event)
  3185. {
  3186. struct snd_soc_component *component =
  3187. snd_soc_dapm_to_component(w->dapm);
  3188. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  3189. dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event);
  3190. switch (event) {
  3191. case SND_SOC_DAPM_PRE_PMU:
  3192. tasha->rx_bias_count++;
  3193. if (tasha->rx_bias_count == 1) {
  3194. if (TASHA_IS_2_0(tasha->wcd9xxx))
  3195. tasha_codec_init_flyback(component);
  3196. snd_soc_component_update_bits(component,
  3197. WCD9335_ANA_RX_SUPPLIES,
  3198. 0x01, 0x01);
  3199. }
  3200. break;
  3201. case SND_SOC_DAPM_POST_PMD:
  3202. tasha->rx_bias_count--;
  3203. if (!tasha->rx_bias_count)
  3204. snd_soc_component_update_bits(component,
  3205. WCD9335_ANA_RX_SUPPLIES,
  3206. 0x01, 0x00);
  3207. break;
  3208. };
  3209. dev_dbg(component->dev, "%s: Current RX BIAS user count: %d\n",
  3210. __func__, tasha->rx_bias_count);
  3211. return 0;
  3212. }
  3213. static void tasha_realign_anc_coeff(struct snd_soc_component *component,
  3214. u16 reg1, u16 reg2)
  3215. {
  3216. u8 val1, val2, tmpval1, tmpval2;
  3217. snd_soc_component_write(component, reg1, 0x00);
  3218. tmpval1 = snd_soc_component_read32(component, reg2);
  3219. tmpval2 = snd_soc_component_read32(component, reg2);
  3220. snd_soc_component_write(component, reg1, 0x00);
  3221. snd_soc_component_write(component, reg2, 0xFF);
  3222. snd_soc_component_write(component, reg1, 0x01);
  3223. snd_soc_component_write(component, reg2, 0xFF);
  3224. snd_soc_component_write(component, reg1, 0x00);
  3225. val1 = snd_soc_component_read32(component, reg2);
  3226. val2 = snd_soc_component_read32(component, reg2);
  3227. if (val1 == 0x0F && val2 == 0xFF) {
  3228. dev_dbg(component->dev, "%s: ANC0 co-eff index re-aligned\n",
  3229. __func__);
  3230. snd_soc_component_read32(component, reg2);
  3231. snd_soc_component_write(component, reg1, 0x00);
  3232. snd_soc_component_write(component, reg2, tmpval2);
  3233. snd_soc_component_write(component, reg1, 0x01);
  3234. snd_soc_component_write(component, reg2, tmpval1);
  3235. } else if (val1 == 0xFF && val2 == 0x0F) {
  3236. dev_dbg(component->dev, "%s: ANC1 co-eff index already aligned\n",
  3237. __func__);
  3238. snd_soc_component_write(component, reg1, 0x00);
  3239. snd_soc_component_write(component, reg2, tmpval1);
  3240. snd_soc_component_write(component, reg1, 0x01);
  3241. snd_soc_component_write(component, reg2, tmpval2);
  3242. } else {
  3243. dev_err(component->dev, "%s: ANC0 co-eff index not aligned\n",
  3244. __func__);
  3245. }
  3246. }
  3247. static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w,
  3248. struct snd_kcontrol *kcontrol, int event)
  3249. {
  3250. struct snd_soc_component *component =
  3251. snd_soc_dapm_to_component(w->dapm);
  3252. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  3253. const char *filename;
  3254. const struct firmware *fw;
  3255. int i;
  3256. int ret = 0;
  3257. int num_anc_slots;
  3258. struct wcd9xxx_anc_header *anc_head;
  3259. struct firmware_cal *hwdep_cal = NULL;
  3260. u32 anc_writes_size = 0;
  3261. u32 anc_cal_size = 0;
  3262. int anc_size_remaining;
  3263. u32 *anc_ptr;
  3264. u16 reg;
  3265. u8 mask, val;
  3266. size_t cal_size;
  3267. const void *data;
  3268. if (!tasha->anc_func)
  3269. return 0;
  3270. switch (event) {
  3271. case SND_SOC_DAPM_PRE_PMU:
  3272. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_ANC_CAL);
  3273. if (hwdep_cal) {
  3274. data = hwdep_cal->data;
  3275. cal_size = hwdep_cal->size;
  3276. dev_dbg(component->dev, "%s: using hwdep calibration\n",
  3277. __func__);
  3278. } else {
  3279. filename = "wcd9335/wcd9335_anc.bin";
  3280. ret = request_firmware(&fw, filename, component->dev);
  3281. if (ret != 0) {
  3282. dev_err(component->dev,
  3283. "Failed to acquire ANC data: %d\n", ret);
  3284. return -ENODEV;
  3285. }
  3286. if (!fw) {
  3287. dev_err(component->dev, "failed to get anc fw");
  3288. return -ENODEV;
  3289. }
  3290. data = fw->data;
  3291. cal_size = fw->size;
  3292. dev_dbg(component->dev,
  3293. "%s: using request_firmware calibration\n", __func__);
  3294. }
  3295. if (cal_size < sizeof(struct wcd9xxx_anc_header)) {
  3296. dev_err(component->dev, "Not enough data\n");
  3297. ret = -ENOMEM;
  3298. goto err;
  3299. }
  3300. /* First number is the number of register writes */
  3301. anc_head = (struct wcd9xxx_anc_header *)(data);
  3302. anc_ptr = (u32 *)(data +
  3303. sizeof(struct wcd9xxx_anc_header));
  3304. anc_size_remaining = cal_size -
  3305. sizeof(struct wcd9xxx_anc_header);
  3306. num_anc_slots = anc_head->num_anc_slots;
  3307. if (tasha->anc_slot >= num_anc_slots) {
  3308. dev_err(component->dev, "Invalid ANC slot selected\n");
  3309. ret = -EINVAL;
  3310. goto err;
  3311. }
  3312. for (i = 0; i < num_anc_slots; i++) {
  3313. if (anc_size_remaining < TASHA_PACKED_REG_SIZE) {
  3314. dev_err(component->dev,
  3315. "Invalid register format\n");
  3316. ret = -EINVAL;
  3317. goto err;
  3318. }
  3319. anc_writes_size = (u32)(*anc_ptr);
  3320. anc_size_remaining -= sizeof(u32);
  3321. anc_ptr += 1;
  3322. if (anc_writes_size * TASHA_PACKED_REG_SIZE
  3323. > anc_size_remaining) {
  3324. dev_err(component->dev,
  3325. "Invalid register format\n");
  3326. ret = -EINVAL;
  3327. goto err;
  3328. }
  3329. if (tasha->anc_slot == i)
  3330. break;
  3331. anc_size_remaining -= (anc_writes_size *
  3332. TASHA_PACKED_REG_SIZE);
  3333. anc_ptr += anc_writes_size;
  3334. }
  3335. if (i == num_anc_slots) {
  3336. dev_err(component->dev, "Selected ANC slot not present\n");
  3337. ret = -EINVAL;
  3338. goto err;
  3339. }
  3340. i = 0;
  3341. anc_cal_size = anc_writes_size;
  3342. if (!strcmp(w->name, "RX INT0 DAC") ||
  3343. !strcmp(w->name, "ANC SPK1 PA"))
  3344. tasha_realign_anc_coeff(component,
  3345. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3346. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3347. if (!strcmp(w->name, "RX INT1 DAC") ||
  3348. !strcmp(w->name, "RX INT3 DAC")) {
  3349. tasha_realign_anc_coeff(component,
  3350. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3351. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3352. anc_writes_size = anc_cal_size / 2;
  3353. snd_soc_component_update_bits(component,
  3354. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x39, 0x39);
  3355. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3356. !strcmp(w->name, "RX INT4 DAC")) {
  3357. tasha_realign_anc_coeff(component,
  3358. WCD9335_CDC_ANC1_IIR_COEFF_1_CTL,
  3359. WCD9335_CDC_ANC1_IIR_COEFF_2_CTL);
  3360. i = anc_cal_size / 2;
  3361. snd_soc_component_update_bits(component,
  3362. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x39, 0x39);
  3363. }
  3364. for (; i < anc_writes_size; i++) {
  3365. TASHA_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val);
  3366. snd_soc_component_write(component, reg, (val & mask));
  3367. }
  3368. if (!strcmp(w->name, "RX INT1 DAC") ||
  3369. !strcmp(w->name, "RX INT3 DAC")) {
  3370. snd_soc_component_update_bits(component,
  3371. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08);
  3372. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3373. !strcmp(w->name, "RX INT4 DAC")) {
  3374. snd_soc_component_update_bits(component,
  3375. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08);
  3376. }
  3377. if (!hwdep_cal)
  3378. release_firmware(fw);
  3379. break;
  3380. case SND_SOC_DAPM_POST_PMU:
  3381. /* Remove ANC Rx from reset */
  3382. snd_soc_component_update_bits(component,
  3383. WCD9335_CDC_ANC0_CLK_RESET_CTL,
  3384. 0x08, 0x00);
  3385. snd_soc_component_update_bits(component,
  3386. WCD9335_CDC_ANC1_CLK_RESET_CTL,
  3387. 0x08, 0x00);
  3388. break;
  3389. case SND_SOC_DAPM_POST_PMD:
  3390. if (!strcmp(w->name, "ANC HPHL PA") ||
  3391. !strcmp(w->name, "ANC EAR PA") ||
  3392. !strcmp(w->name, "ANC SPK1 PA") ||
  3393. !strcmp(w->name, "ANC LINEOUT1 PA")) {
  3394. snd_soc_component_update_bits(component,
  3395. WCD9335_CDC_ANC0_MODE_1_CTL, 0x30, 0x00);
  3396. msleep(50);
  3397. snd_soc_component_update_bits(component,
  3398. WCD9335_CDC_ANC0_MODE_1_CTL, 0x01, 0x00);
  3399. snd_soc_component_update_bits(component,
  3400. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x38);
  3401. snd_soc_component_update_bits(component,
  3402. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x07, 0x00);
  3403. snd_soc_component_update_bits(component,
  3404. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x00);
  3405. } else if (!strcmp(w->name, "ANC HPHR PA") ||
  3406. !strcmp(w->name, "ANC LINEOUT2 PA")) {
  3407. snd_soc_component_update_bits(component,
  3408. WCD9335_CDC_ANC1_MODE_1_CTL, 0x30, 0x00);
  3409. msleep(50);
  3410. snd_soc_component_update_bits(component,
  3411. WCD9335_CDC_ANC1_MODE_1_CTL, 0x01, 0x00);
  3412. snd_soc_component_update_bits(component,
  3413. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x38);
  3414. snd_soc_component_update_bits(component,
  3415. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x07, 0x00);
  3416. snd_soc_component_update_bits(component,
  3417. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x00);
  3418. }
  3419. break;
  3420. }
  3421. return 0;
  3422. err:
  3423. if (!hwdep_cal)
  3424. release_firmware(fw);
  3425. return ret;
  3426. }
  3427. static void tasha_codec_clear_anc_tx_hold(struct tasha_priv *tasha)
  3428. {
  3429. if (test_and_clear_bit(ANC_MIC_AMIC1, &tasha->status_mask))
  3430. tasha_codec_set_tx_hold(tasha->component,
  3431. WCD9335_ANA_AMIC1, false);
  3432. if (test_and_clear_bit(ANC_MIC_AMIC2, &tasha->status_mask))
  3433. tasha_codec_set_tx_hold(tasha->component,
  3434. WCD9335_ANA_AMIC2, false);
  3435. if (test_and_clear_bit(ANC_MIC_AMIC3, &tasha->status_mask))
  3436. tasha_codec_set_tx_hold(tasha->component,
  3437. WCD9335_ANA_AMIC3, false);
  3438. if (test_and_clear_bit(ANC_MIC_AMIC4, &tasha->status_mask))
  3439. tasha_codec_set_tx_hold(tasha->component,
  3440. WCD9335_ANA_AMIC4, false);
  3441. if (test_and_clear_bit(ANC_MIC_AMIC5, &tasha->status_mask))
  3442. tasha_codec_set_tx_hold(tasha->component,
  3443. WCD9335_ANA_AMIC5, false);
  3444. if (test_and_clear_bit(ANC_MIC_AMIC6, &tasha->status_mask))
  3445. tasha_codec_set_tx_hold(tasha->component,
  3446. WCD9335_ANA_AMIC6, false);
  3447. }
  3448. static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha,
  3449. int mode, int event)
  3450. {
  3451. u8 scale_val = 0;
  3452. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3453. return;
  3454. switch (event) {
  3455. case SND_SOC_DAPM_POST_PMU:
  3456. switch (mode) {
  3457. case CLS_H_HIFI:
  3458. scale_val = 0x3;
  3459. break;
  3460. case CLS_H_LOHIFI:
  3461. scale_val = 0x1;
  3462. break;
  3463. }
  3464. if (tasha->anc_func) {
  3465. /* Clear Tx FE HOLD if both PAs are enabled */
  3466. if ((snd_soc_component_read32(
  3467. tasha->component, WCD9335_ANA_HPH) &
  3468. 0xC0) == 0xC0) {
  3469. tasha_codec_clear_anc_tx_hold(tasha);
  3470. }
  3471. }
  3472. break;
  3473. case SND_SOC_DAPM_PRE_PMD:
  3474. scale_val = 0x6;
  3475. break;
  3476. }
  3477. if (scale_val)
  3478. snd_soc_component_update_bits(tasha->component,
  3479. WCD9335_HPH_PA_CTL1, 0x0E,
  3480. scale_val << 1);
  3481. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3482. if (tasha->comp_enabled[COMPANDER_1] ||
  3483. tasha->comp_enabled[COMPANDER_2]) {
  3484. snd_soc_component_update_bits(tasha->component,
  3485. WCD9335_HPH_L_EN,
  3486. 0x20, 0x00);
  3487. snd_soc_component_update_bits(tasha->component,
  3488. WCD9335_HPH_R_EN,
  3489. 0x20, 0x00);
  3490. snd_soc_component_update_bits(tasha->component,
  3491. WCD9335_HPH_AUTO_CHOP,
  3492. 0x20, 0x20);
  3493. }
  3494. snd_soc_component_update_bits(tasha->component,
  3495. WCD9335_HPH_L_EN, 0x1F,
  3496. tasha->hph_l_gain);
  3497. snd_soc_component_update_bits(tasha->component,
  3498. WCD9335_HPH_R_EN, 0x1F,
  3499. tasha->hph_r_gain);
  3500. }
  3501. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3502. snd_soc_component_update_bits(tasha->component,
  3503. WCD9335_HPH_AUTO_CHOP, 0x20,
  3504. 0x00);
  3505. }
  3506. }
  3507. static void tasha_codec_override(struct snd_soc_component *component,
  3508. int mode,
  3509. int event)
  3510. {
  3511. if (mode == CLS_AB) {
  3512. switch (event) {
  3513. case SND_SOC_DAPM_POST_PMU:
  3514. if (!(snd_soc_component_read32(component,
  3515. WCD9335_CDC_RX2_RX_PATH_CTL) & 0x10) &&
  3516. (!(snd_soc_component_read32(component,
  3517. WCD9335_CDC_RX1_RX_PATH_CTL) & 0x10)))
  3518. snd_soc_component_update_bits(component,
  3519. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x02);
  3520. break;
  3521. case SND_SOC_DAPM_POST_PMD:
  3522. snd_soc_component_update_bits(component,
  3523. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00);
  3524. break;
  3525. }
  3526. }
  3527. }
  3528. static int tasha_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
  3529. struct snd_kcontrol *kcontrol,
  3530. int event)
  3531. {
  3532. struct snd_soc_component *component =
  3533. snd_soc_dapm_to_component(w->dapm);
  3534. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  3535. int hph_mode = tasha->hph_mode;
  3536. int ret = 0;
  3537. dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event);
  3538. switch (event) {
  3539. case SND_SOC_DAPM_PRE_PMU:
  3540. if ((!(strcmp(w->name, "ANC HPHR PA"))) &&
  3541. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3542. snd_soc_component_update_bits(
  3543. component, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3544. }
  3545. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3546. if (!(strcmp(w->name, "HPHR PA")))
  3547. snd_soc_component_update_bits(
  3548. component, WCD9335_ANA_HPH, 0x40, 0x40);
  3549. break;
  3550. case SND_SOC_DAPM_POST_PMU:
  3551. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3552. if ((snd_soc_component_read32(
  3553. component, WCD9335_ANA_HPH) & 0xC0) != 0xC0)
  3554. /*
  3555. * If PA_EN is not set (potentially in ANC case)
  3556. * then do nothing for POST_PMU and let left
  3557. * channel handle everything.
  3558. */
  3559. break;
  3560. }
  3561. /*
  3562. * 7ms sleep is required after PA is enabled as per
  3563. * HW requirement
  3564. */
  3565. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3566. usleep_range(7000, 7100);
  3567. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3568. }
  3569. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3570. snd_soc_component_update_bits(component,
  3571. WCD9335_CDC_RX2_RX_PATH_CTL,
  3572. 0x10, 0x00);
  3573. /* Remove mix path mute if it is enabled */
  3574. if ((snd_soc_component_read32(
  3575. component, WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) & 0x10)
  3576. snd_soc_component_update_bits(component,
  3577. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3578. 0x10, 0x00);
  3579. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3580. /* Do everything needed for left channel */
  3581. snd_soc_component_update_bits(component,
  3582. WCD9335_CDC_RX1_RX_PATH_CTL,
  3583. 0x10, 0x00);
  3584. /* Remove mix path mute if it is enabled */
  3585. if ((snd_soc_component_read32(component,
  3586. WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3587. 0x10)
  3588. snd_soc_component_update_bits(component,
  3589. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3590. 0x10, 0x00);
  3591. /* Remove ANC Rx from reset */
  3592. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3593. }
  3594. tasha_codec_override(component, hph_mode, event);
  3595. break;
  3596. case SND_SOC_DAPM_PRE_PMD:
  3597. blocking_notifier_call_chain(&tasha->notifier,
  3598. WCD_EVENT_PRE_HPHR_PA_OFF,
  3599. &tasha->mbhc);
  3600. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3601. if (!(strcmp(w->name, "ANC HPHR PA")) ||
  3602. !(strcmp(w->name, "HPHR PA")))
  3603. snd_soc_component_update_bits(component,
  3604. WCD9335_ANA_HPH, 0x40, 0x00);
  3605. break;
  3606. case SND_SOC_DAPM_POST_PMD:
  3607. /* 5ms sleep is required after PA is disabled as per
  3608. * HW requirement
  3609. */
  3610. usleep_range(5000, 5500);
  3611. tasha_codec_override(component, hph_mode, event);
  3612. blocking_notifier_call_chain(&tasha->notifier,
  3613. WCD_EVENT_POST_HPHR_PA_OFF,
  3614. &tasha->mbhc);
  3615. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3616. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3617. snd_soc_component_update_bits(component,
  3618. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x00);
  3619. }
  3620. break;
  3621. };
  3622. return ret;
  3623. }
  3624. static int tasha_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
  3625. struct snd_kcontrol *kcontrol,
  3626. int event)
  3627. {
  3628. struct snd_soc_component *component =
  3629. snd_soc_dapm_to_component(w->dapm);
  3630. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  3631. int hph_mode = tasha->hph_mode;
  3632. int ret = 0;
  3633. dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event);
  3634. switch (event) {
  3635. case SND_SOC_DAPM_PRE_PMU:
  3636. if ((!(strcmp(w->name, "ANC HPHL PA"))) &&
  3637. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3638. snd_soc_component_update_bits(component,
  3639. WCD9335_ANA_HPH, 0xC0, 0xC0);
  3640. }
  3641. if (!(strcmp(w->name, "HPHL PA")))
  3642. snd_soc_component_update_bits(component,
  3643. WCD9335_ANA_HPH, 0x80, 0x80);
  3644. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3645. break;
  3646. case SND_SOC_DAPM_POST_PMU:
  3647. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3648. if ((snd_soc_component_read32(
  3649. component, WCD9335_ANA_HPH) & 0xC0) != 0xC0)
  3650. /*
  3651. * If PA_EN is not set (potentially in ANC case)
  3652. * then do nothing for POST_PMU and let right
  3653. * channel handle everything.
  3654. */
  3655. break;
  3656. }
  3657. /*
  3658. * 7ms sleep is required after PA is enabled as per
  3659. * HW requirement
  3660. */
  3661. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3662. usleep_range(7000, 7100);
  3663. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3664. }
  3665. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3666. snd_soc_component_update_bits(component,
  3667. WCD9335_CDC_RX1_RX_PATH_CTL,
  3668. 0x10, 0x00);
  3669. /* Remove mix path mute if it is enabled */
  3670. if ((snd_soc_component_read32(
  3671. component, WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) & 0x10)
  3672. snd_soc_component_update_bits(component,
  3673. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3674. 0x10, 0x00);
  3675. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3676. /* Do everything needed for right channel */
  3677. snd_soc_component_update_bits(component,
  3678. WCD9335_CDC_RX2_RX_PATH_CTL,
  3679. 0x10, 0x00);
  3680. /* Remove mix path mute if it is enabled */
  3681. if ((snd_soc_component_read32(component,
  3682. WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3683. 0x10)
  3684. snd_soc_component_update_bits(component,
  3685. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3686. 0x10, 0x00);
  3687. /* Remove ANC Rx from reset */
  3688. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3689. }
  3690. tasha_codec_override(component, hph_mode, event);
  3691. break;
  3692. case SND_SOC_DAPM_PRE_PMD:
  3693. blocking_notifier_call_chain(&tasha->notifier,
  3694. WCD_EVENT_PRE_HPHL_PA_OFF,
  3695. &tasha->mbhc);
  3696. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3697. if (!(strcmp(w->name, "ANC HPHL PA")) ||
  3698. !(strcmp(w->name, "HPHL PA")))
  3699. snd_soc_component_update_bits(component,
  3700. WCD9335_ANA_HPH, 0x80, 0x00);
  3701. break;
  3702. case SND_SOC_DAPM_POST_PMD:
  3703. /* 5ms sleep is required after PA is disabled as per
  3704. * HW requirement
  3705. */
  3706. usleep_range(5000, 5500);
  3707. tasha_codec_override(component, hph_mode, event);
  3708. blocking_notifier_call_chain(&tasha->notifier,
  3709. WCD_EVENT_POST_HPHL_PA_OFF,
  3710. &tasha->mbhc);
  3711. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3712. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3713. snd_soc_component_update_bits(component,
  3714. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00);
  3715. }
  3716. break;
  3717. };
  3718. return ret;
  3719. }
  3720. static int tasha_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w,
  3721. struct snd_kcontrol *kcontrol,
  3722. int event)
  3723. {
  3724. struct snd_soc_component *component =
  3725. snd_soc_dapm_to_component(w->dapm);
  3726. u16 lineout_vol_reg = 0, lineout_mix_vol_reg = 0;
  3727. int ret = 0;
  3728. dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event);
  3729. if (w->reg == WCD9335_ANA_LO_1_2) {
  3730. if (w->shift == 7) {
  3731. lineout_vol_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  3732. lineout_mix_vol_reg = WCD9335_CDC_RX3_RX_PATH_MIX_CTL;
  3733. } else if (w->shift == 6) {
  3734. lineout_vol_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  3735. lineout_mix_vol_reg = WCD9335_CDC_RX4_RX_PATH_MIX_CTL;
  3736. }
  3737. } else if (w->reg == WCD9335_ANA_LO_3_4) {
  3738. if (w->shift == 7) {
  3739. lineout_vol_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  3740. lineout_mix_vol_reg = WCD9335_CDC_RX5_RX_PATH_MIX_CTL;
  3741. } else if (w->shift == 6) {
  3742. lineout_vol_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  3743. lineout_mix_vol_reg = WCD9335_CDC_RX6_RX_PATH_MIX_CTL;
  3744. }
  3745. } else {
  3746. dev_err(component->dev, "%s: Error enabling lineout PA\n",
  3747. __func__);
  3748. return -EINVAL;
  3749. }
  3750. switch (event) {
  3751. case SND_SOC_DAPM_POST_PMU:
  3752. /* 5ms sleep is required after PA is enabled as per
  3753. * HW requirement
  3754. */
  3755. usleep_range(5000, 5500);
  3756. snd_soc_component_update_bits(component, lineout_vol_reg,
  3757. 0x10, 0x00);
  3758. /* Remove mix path mute if it is enabled */
  3759. if ((snd_soc_component_read32(
  3760. component, lineout_mix_vol_reg)) & 0x10)
  3761. snd_soc_component_update_bits(component,
  3762. lineout_mix_vol_reg,
  3763. 0x10, 0x00);
  3764. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3765. !(strcmp(w->name, "ANC LINEOUT2 PA")))
  3766. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3767. tasha_codec_override(component, CLS_AB, event);
  3768. break;
  3769. case SND_SOC_DAPM_POST_PMD:
  3770. /* 5ms sleep is required after PA is disabled as per
  3771. * HW requirement
  3772. */
  3773. usleep_range(5000, 5500);
  3774. tasha_codec_override(component, CLS_AB, event);
  3775. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3776. !(strcmp(w->name, "ANC LINEOUT2 PA"))) {
  3777. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3778. if (!(strcmp(w->name, "ANC LINEOUT1 PA")))
  3779. snd_soc_component_update_bits(component,
  3780. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  3781. else
  3782. snd_soc_component_update_bits(component,
  3783. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  3784. }
  3785. break;
  3786. };
  3787. return ret;
  3788. }
  3789. static void tasha_spk_anc_update_callback(struct work_struct *work)
  3790. {
  3791. struct spk_anc_work *spk_anc_dwork;
  3792. struct tasha_priv *tasha;
  3793. struct delayed_work *delayed_work;
  3794. struct snd_soc_component *component;
  3795. delayed_work = to_delayed_work(work);
  3796. spk_anc_dwork = container_of(delayed_work, struct spk_anc_work, dwork);
  3797. tasha = spk_anc_dwork->tasha;
  3798. component = tasha->component;
  3799. snd_soc_component_update_bits(component, WCD9335_CDC_RX7_RX_PATH_CFG0,
  3800. 0x10, 0x10);
  3801. }
  3802. static int tasha_codec_enable_spk_anc(struct snd_soc_dapm_widget *w,
  3803. struct snd_kcontrol *kcontrol,
  3804. int event)
  3805. {
  3806. int ret = 0;
  3807. struct snd_soc_component *component =
  3808. snd_soc_dapm_to_component(w->dapm);
  3809. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  3810. dev_dbg(component->dev, "%s %s %d %d\n", __func__, w->name, event,
  3811. tasha->anc_func);
  3812. if (!tasha->anc_func)
  3813. return 0;
  3814. switch (event) {
  3815. case SND_SOC_DAPM_PRE_PMU:
  3816. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3817. schedule_delayed_work(&tasha->spk_anc_dwork.dwork,
  3818. msecs_to_jiffies(spk_anc_en_delay));
  3819. break;
  3820. case SND_SOC_DAPM_POST_PMD:
  3821. cancel_delayed_work_sync(&tasha->spk_anc_dwork.dwork);
  3822. snd_soc_component_update_bits(component,
  3823. WCD9335_CDC_RX7_RX_PATH_CFG0,
  3824. 0x10, 0x00);
  3825. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3826. break;
  3827. }
  3828. return ret;
  3829. }
  3830. static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
  3831. struct snd_kcontrol *kcontrol,
  3832. int event)
  3833. {
  3834. struct snd_soc_component *component =
  3835. snd_soc_dapm_to_component(w->dapm);
  3836. int ret = 0;
  3837. dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event);
  3838. switch (event) {
  3839. case SND_SOC_DAPM_POST_PMU:
  3840. /* 5ms sleep is required after PA is enabled as per
  3841. * HW requirement
  3842. */
  3843. usleep_range(5000, 5500);
  3844. snd_soc_component_update_bits(component,
  3845. WCD9335_CDC_RX0_RX_PATH_CTL,
  3846. 0x10, 0x00);
  3847. /* Remove mix path mute if it is enabled */
  3848. if ((snd_soc_component_read32(
  3849. component, WCD9335_CDC_RX0_RX_PATH_MIX_CTL)) & 0x10)
  3850. snd_soc_component_update_bits(component,
  3851. WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  3852. 0x10, 0x00);
  3853. break;
  3854. case SND_SOC_DAPM_POST_PMD:
  3855. /* 5ms sleep is required after PA is disabled as per
  3856. * HW requirement
  3857. */
  3858. usleep_range(5000, 5500);
  3859. if (!(strcmp(w->name, "ANC EAR PA"))) {
  3860. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3861. snd_soc_component_update_bits(component,
  3862. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x00);
  3863. }
  3864. break;
  3865. };
  3866. return ret;
  3867. }
  3868. static void tasha_codec_hph_mode_gain_opt(struct snd_soc_component *component,
  3869. u8 gain)
  3870. {
  3871. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  3872. u8 hph_l_en, hph_r_en;
  3873. u8 l_val, r_val;
  3874. u8 hph_pa_status;
  3875. bool is_hphl_pa, is_hphr_pa;
  3876. hph_pa_status = snd_soc_component_read32(component, WCD9335_ANA_HPH);
  3877. is_hphl_pa = hph_pa_status >> 7;
  3878. is_hphr_pa = (hph_pa_status & 0x40) >> 6;
  3879. hph_l_en = snd_soc_component_read32(component, WCD9335_HPH_L_EN);
  3880. hph_r_en = snd_soc_component_read32(component, WCD9335_HPH_R_EN);
  3881. l_val = (hph_l_en & 0xC0) | 0x20 | gain;
  3882. r_val = (hph_r_en & 0xC0) | 0x20 | gain;
  3883. /*
  3884. * Set HPH_L & HPH_R gain source selection to REGISTER
  3885. * for better click and pop only if corresponding PAs are
  3886. * not enabled. Also cache the values of the HPHL/R
  3887. * PA gains to be applied after PAs are enabled
  3888. */
  3889. if ((l_val != hph_l_en) && !is_hphl_pa) {
  3890. snd_soc_component_write(component, WCD9335_HPH_L_EN, l_val);
  3891. tasha->hph_l_gain = hph_l_en & 0x1F;
  3892. }
  3893. if ((r_val != hph_r_en) && !is_hphr_pa) {
  3894. snd_soc_component_write(component, WCD9335_HPH_R_EN, r_val);
  3895. tasha->hph_r_gain = hph_r_en & 0x1F;
  3896. }
  3897. }
  3898. static void tasha_codec_hph_lohifi_config(struct snd_soc_component *component,
  3899. int event)
  3900. {
  3901. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3902. snd_soc_component_update_bits(component,
  3903. WCD9335_RX_BIAS_HPH_PA,
  3904. 0x0F, 0x06);
  3905. snd_soc_component_update_bits(component,
  3906. WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2,
  3907. 0xF0, 0x40);
  3908. snd_soc_component_update_bits(component,
  3909. WCD9335_HPH_CNP_WG_CTL,
  3910. 0x07, 0x03);
  3911. snd_soc_component_update_bits(component,
  3912. WCD9335_HPH_PA_CTL2,
  3913. 0x08, 0x08);
  3914. snd_soc_component_update_bits(component,
  3915. WCD9335_HPH_PA_CTL1,
  3916. 0x0E, 0x0C);
  3917. tasha_codec_hph_mode_gain_opt(component, 0x11);
  3918. }
  3919. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3920. snd_soc_component_update_bits(component,
  3921. WCD9335_HPH_PA_CTL2,
  3922. 0x08, 0x00);
  3923. snd_soc_component_update_bits(component,
  3924. WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3925. snd_soc_component_write(component,
  3926. WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A);
  3927. snd_soc_component_update_bits(component,
  3928. WCD9335_RX_BIAS_HPH_PA,
  3929. 0x0F, 0x0A);
  3930. }
  3931. }
  3932. static void tasha_codec_hph_lp_config(struct snd_soc_component *component,
  3933. int event)
  3934. {
  3935. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3936. snd_soc_component_update_bits(component,
  3937. WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3938. tasha_codec_hph_mode_gain_opt(component, 0x10);
  3939. snd_soc_component_update_bits(component,
  3940. WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3941. snd_soc_component_update_bits(component,
  3942. WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3943. snd_soc_component_update_bits(component,
  3944. WCD9335_HPH_PA_CTL2, 0x04, 0x04);
  3945. snd_soc_component_update_bits(component,
  3946. WCD9335_HPH_PA_CTL2, 0x20, 0x20);
  3947. snd_soc_component_update_bits(component,
  3948. WCD9335_HPH_RDAC_LDO_CTL, 0x07, 0x01);
  3949. snd_soc_component_update_bits(component,
  3950. WCD9335_HPH_RDAC_LDO_CTL, 0x70, 0x10);
  3951. snd_soc_component_update_bits(component,
  3952. WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x0F, 0x01);
  3953. snd_soc_component_update_bits(component,
  3954. WCD9335_RX_BIAS_HPH_RDAC_LDO, 0xF0, 0x10);
  3955. }
  3956. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3957. snd_soc_component_write(component,
  3958. WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x88);
  3959. snd_soc_component_write(component,
  3960. WCD9335_HPH_RDAC_LDO_CTL, 0x33);
  3961. snd_soc_component_update_bits(component,
  3962. WCD9335_HPH_PA_CTL2, 0x20, 0x00);
  3963. snd_soc_component_update_bits(component,
  3964. WCD9335_HPH_PA_CTL2, 0x04, 0x00);
  3965. snd_soc_component_update_bits(component,
  3966. WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3967. snd_soc_component_update_bits(component,
  3968. WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3969. snd_soc_component_update_bits(component,
  3970. WCD9335_HPH_R_EN, 0xC0, 0x80);
  3971. snd_soc_component_update_bits(component,
  3972. WCD9335_HPH_L_EN, 0xC0, 0x80);
  3973. }
  3974. }
  3975. static void tasha_codec_hph_hifi_config(struct snd_soc_component *component,
  3976. int event)
  3977. {
  3978. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3979. snd_soc_component_update_bits(component,
  3980. WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3981. snd_soc_component_update_bits(component,
  3982. WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3983. snd_soc_component_update_bits(component,
  3984. WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3985. tasha_codec_hph_mode_gain_opt(component, 0x11);
  3986. }
  3987. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3988. snd_soc_component_update_bits(component,
  3989. WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3990. snd_soc_component_update_bits(component,
  3991. WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3992. }
  3993. }
  3994. static void tasha_codec_hph_mode_config(struct snd_soc_component *component,
  3995. int event, int mode)
  3996. {
  3997. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  3998. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3999. return;
  4000. switch (mode) {
  4001. case CLS_H_LP:
  4002. tasha_codec_hph_lp_config(component, event);
  4003. break;
  4004. case CLS_H_LOHIFI:
  4005. tasha_codec_hph_lohifi_config(component, event);
  4006. break;
  4007. case CLS_H_HIFI:
  4008. tasha_codec_hph_hifi_config(component, event);
  4009. break;
  4010. }
  4011. }
  4012. static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
  4013. struct snd_kcontrol *kcontrol,
  4014. int event)
  4015. {
  4016. struct snd_soc_component *component =
  4017. snd_soc_dapm_to_component(w->dapm);
  4018. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  4019. struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
  4020. int hph_mode = tasha->hph_mode;
  4021. u8 dem_inp;
  4022. int ret = 0;
  4023. dev_dbg(component->dev, "%s wname: %s event: %d hph_mode: %d\n",
  4024. __func__, w->name, event, hph_mode);
  4025. switch (event) {
  4026. case SND_SOC_DAPM_PRE_PMU:
  4027. if (tasha->anc_func) {
  4028. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4029. /* 40 msec delay is needed to avoid click and pop */
  4030. msleep(40);
  4031. }
  4032. /* Read DEM INP Select */
  4033. dem_inp = snd_soc_component_read32(
  4034. component, WCD9335_CDC_RX2_RX_PATH_SEC0) &
  4035. 0x03;
  4036. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  4037. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  4038. dev_err(component->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  4039. __func__, hph_mode);
  4040. return -EINVAL;
  4041. }
  4042. wcd_clsh_fsm(component, &tasha->clsh_d,
  4043. WCD_CLSH_EVENT_PRE_DAC,
  4044. WCD_CLSH_STATE_HPHR,
  4045. ((hph_mode == CLS_H_LOHIFI) ?
  4046. CLS_H_HIFI : hph_mode));
  4047. if (!(strcmp(w->name, "RX INT2 DAC")))
  4048. snd_soc_component_update_bits(component,
  4049. WCD9335_ANA_HPH, 0x10, 0x10);
  4050. tasha_codec_hph_mode_config(component, event, hph_mode);
  4051. if (tasha->anc_func)
  4052. snd_soc_component_update_bits(component,
  4053. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x10);
  4054. break;
  4055. case SND_SOC_DAPM_POST_PMU:
  4056. /* 1000us required as per HW requirement */
  4057. usleep_range(1000, 1100);
  4058. if ((hph_mode == CLS_H_LP) &&
  4059. (TASHA_IS_1_1(wcd9xxx))) {
  4060. snd_soc_component_update_bits(component,
  4061. WCD9335_HPH_L_DAC_CTL, 0x03, 0x03);
  4062. }
  4063. break;
  4064. case SND_SOC_DAPM_PRE_PMD:
  4065. if ((hph_mode == CLS_H_LP) &&
  4066. (TASHA_IS_1_1(wcd9xxx))) {
  4067. snd_soc_component_update_bits(component,
  4068. WCD9335_HPH_L_DAC_CTL,
  4069. 0x03, 0x00);
  4070. }
  4071. if (!(strcmp(w->name, "RX INT2 DAC")))
  4072. snd_soc_component_update_bits(component,
  4073. WCD9335_ANA_HPH, 0x10, 0x00);
  4074. break;
  4075. case SND_SOC_DAPM_POST_PMD:
  4076. /* 1000us required as per HW requirement */
  4077. usleep_range(1000, 1100);
  4078. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  4079. WCD_CLSH_STATE_HPHL))
  4080. tasha_codec_hph_mode_config(component, event, hph_mode);
  4081. wcd_clsh_fsm(component, &tasha->clsh_d,
  4082. WCD_CLSH_EVENT_POST_PA,
  4083. WCD_CLSH_STATE_HPHR,
  4084. ((hph_mode == CLS_H_LOHIFI) ?
  4085. CLS_H_HIFI : hph_mode));
  4086. break;
  4087. };
  4088. return ret;
  4089. }
  4090. static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
  4091. struct snd_kcontrol *kcontrol,
  4092. int event)
  4093. {
  4094. struct snd_soc_component *component =
  4095. snd_soc_dapm_to_component(w->dapm);
  4096. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  4097. struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
  4098. int hph_mode = tasha->hph_mode;
  4099. u8 dem_inp;
  4100. int ret = 0;
  4101. uint32_t impedl = 0, impedr = 0;
  4102. dev_dbg(component->dev, "%s wname: %s event: %d hph_mode: %d\n",
  4103. __func__, w->name, event, hph_mode);
  4104. switch (event) {
  4105. case SND_SOC_DAPM_PRE_PMU:
  4106. if (tasha->anc_func) {
  4107. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4108. /* 40 msec delay is needed to avoid click and pop */
  4109. msleep(40);
  4110. }
  4111. /* Read DEM INP Select */
  4112. dem_inp = snd_soc_component_read32(
  4113. component, WCD9335_CDC_RX1_RX_PATH_SEC0) &
  4114. 0x03;
  4115. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  4116. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  4117. dev_err(component->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  4118. __func__, hph_mode);
  4119. return -EINVAL;
  4120. }
  4121. wcd_clsh_fsm(component, &tasha->clsh_d,
  4122. WCD_CLSH_EVENT_PRE_DAC,
  4123. WCD_CLSH_STATE_HPHL,
  4124. ((hph_mode == CLS_H_LOHIFI) ?
  4125. CLS_H_HIFI : hph_mode));
  4126. if (!(strcmp(w->name, "RX INT1 DAC")))
  4127. snd_soc_component_update_bits(component,
  4128. WCD9335_ANA_HPH, 0x20, 0x20);
  4129. tasha_codec_hph_mode_config(component, event, hph_mode);
  4130. if (tasha->anc_func)
  4131. snd_soc_component_update_bits(component,
  4132. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x10);
  4133. ret = wcd_mbhc_get_impedance(&tasha->mbhc,
  4134. &impedl, &impedr);
  4135. if (!ret) {
  4136. wcd_clsh_imped_config(component, impedl, false);
  4137. set_bit(CLASSH_CONFIG, &tasha->status_mask);
  4138. } else {
  4139. dev_dbg(component->dev, "%s: Failed to get mbhc impedance %d\n",
  4140. __func__, ret);
  4141. ret = 0;
  4142. }
  4143. break;
  4144. case SND_SOC_DAPM_POST_PMU:
  4145. /* 1000us required as per HW requirement */
  4146. usleep_range(1000, 1100);
  4147. if ((hph_mode == CLS_H_LP) &&
  4148. (TASHA_IS_1_1(wcd9xxx))) {
  4149. snd_soc_component_update_bits(component,
  4150. WCD9335_HPH_L_DAC_CTL,
  4151. 0x03, 0x03);
  4152. }
  4153. break;
  4154. case SND_SOC_DAPM_PRE_PMD:
  4155. if (!(strcmp(w->name, "RX INT1 DAC")))
  4156. snd_soc_component_update_bits(component,
  4157. WCD9335_ANA_HPH, 0x20, 0x00);
  4158. if ((hph_mode == CLS_H_LP) &&
  4159. (TASHA_IS_1_1(wcd9xxx))) {
  4160. snd_soc_component_update_bits(component,
  4161. WCD9335_HPH_L_DAC_CTL,
  4162. 0x03, 0x00);
  4163. }
  4164. break;
  4165. case SND_SOC_DAPM_POST_PMD:
  4166. /* 1000us required as per HW requirement */
  4167. usleep_range(1000, 1100);
  4168. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  4169. WCD_CLSH_STATE_HPHR))
  4170. tasha_codec_hph_mode_config(component, event, hph_mode);
  4171. wcd_clsh_fsm(component, &tasha->clsh_d,
  4172. WCD_CLSH_EVENT_POST_PA,
  4173. WCD_CLSH_STATE_HPHL,
  4174. ((hph_mode == CLS_H_LOHIFI) ?
  4175. CLS_H_HIFI : hph_mode));
  4176. if (test_bit(CLASSH_CONFIG, &tasha->status_mask)) {
  4177. wcd_clsh_imped_config(component, impedl, true);
  4178. clear_bit(CLASSH_CONFIG, &tasha->status_mask);
  4179. } else
  4180. dev_dbg(component->dev, "%s: Failed to get mbhc impedance %d\n",
  4181. __func__, ret);
  4182. break;
  4183. };
  4184. return ret;
  4185. }
  4186. static int tasha_codec_lineout_dac_event(struct snd_soc_dapm_widget *w,
  4187. struct snd_kcontrol *kcontrol,
  4188. int event)
  4189. {
  4190. struct snd_soc_component *component =
  4191. snd_soc_dapm_to_component(w->dapm);
  4192. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  4193. int ret = 0;
  4194. dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event);
  4195. switch (event) {
  4196. case SND_SOC_DAPM_PRE_PMU:
  4197. if (tasha->anc_func &&
  4198. (!strcmp(w->name, "RX INT3 DAC") ||
  4199. !strcmp(w->name, "RX INT4 DAC")))
  4200. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4201. wcd_clsh_fsm(component, &tasha->clsh_d,
  4202. WCD_CLSH_EVENT_PRE_DAC,
  4203. WCD_CLSH_STATE_LO,
  4204. CLS_AB);
  4205. if (tasha->anc_func) {
  4206. if (!strcmp(w->name, "RX INT3 DAC"))
  4207. snd_soc_component_update_bits(component,
  4208. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  4209. else if (!strcmp(w->name, "RX INT4 DAC"))
  4210. snd_soc_component_update_bits(component,
  4211. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  4212. }
  4213. break;
  4214. case SND_SOC_DAPM_POST_PMD:
  4215. wcd_clsh_fsm(component, &tasha->clsh_d,
  4216. WCD_CLSH_EVENT_POST_PA,
  4217. WCD_CLSH_STATE_LO,
  4218. CLS_AB);
  4219. break;
  4220. }
  4221. return 0;
  4222. }
  4223. static const struct snd_soc_dapm_widget tasha_dapm_i2s_widgets[] = {
  4224. SND_SOC_DAPM_SUPPLY("RX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  4225. 0, 0, NULL, 0),
  4226. SND_SOC_DAPM_SUPPLY("TX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  4227. 0, 0, NULL, 0),
  4228. };
  4229. static int tasha_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
  4230. struct snd_kcontrol *kcontrol,
  4231. int event)
  4232. {
  4233. struct snd_soc_component *component =
  4234. snd_soc_dapm_to_component(w->dapm);
  4235. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  4236. int ret = 0;
  4237. dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event);
  4238. switch (event) {
  4239. case SND_SOC_DAPM_PRE_PMU:
  4240. if (tasha->anc_func)
  4241. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4242. wcd_clsh_fsm(component, &tasha->clsh_d,
  4243. WCD_CLSH_EVENT_PRE_DAC,
  4244. WCD_CLSH_STATE_EAR,
  4245. CLS_H_NORMAL);
  4246. if (tasha->anc_func)
  4247. snd_soc_component_update_bits(component,
  4248. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x10);
  4249. break;
  4250. case SND_SOC_DAPM_POST_PMU:
  4251. break;
  4252. case SND_SOC_DAPM_PRE_PMD:
  4253. break;
  4254. case SND_SOC_DAPM_POST_PMD:
  4255. wcd_clsh_fsm(component, &tasha->clsh_d,
  4256. WCD_CLSH_EVENT_POST_PA,
  4257. WCD_CLSH_STATE_EAR,
  4258. CLS_H_NORMAL);
  4259. break;
  4260. };
  4261. return ret;
  4262. }
  4263. static int tasha_codec_spk_boost_event(struct snd_soc_dapm_widget *w,
  4264. struct snd_kcontrol *kcontrol,
  4265. int event)
  4266. {
  4267. struct snd_soc_component *component =
  4268. snd_soc_dapm_to_component(w->dapm);
  4269. u16 boost_path_ctl, boost_path_cfg1;
  4270. u16 reg, reg_mix;
  4271. dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event);
  4272. if (!strcmp(w->name, "RX INT7 CHAIN")) {
  4273. boost_path_ctl = WCD9335_CDC_BOOST0_BOOST_PATH_CTL;
  4274. boost_path_cfg1 = WCD9335_CDC_RX7_RX_PATH_CFG1;
  4275. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4276. reg_mix = WCD9335_CDC_RX7_RX_PATH_MIX_CTL;
  4277. } else if (!strcmp(w->name, "RX INT8 CHAIN")) {
  4278. boost_path_ctl = WCD9335_CDC_BOOST1_BOOST_PATH_CTL;
  4279. boost_path_cfg1 = WCD9335_CDC_RX8_RX_PATH_CFG1;
  4280. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4281. reg_mix = WCD9335_CDC_RX8_RX_PATH_MIX_CTL;
  4282. } else {
  4283. dev_err(component->dev, "%s: unknown widget: %s\n",
  4284. __func__, w->name);
  4285. return -EINVAL;
  4286. }
  4287. switch (event) {
  4288. case SND_SOC_DAPM_PRE_PMU:
  4289. snd_soc_component_update_bits(component, boost_path_ctl,
  4290. 0x10, 0x10);
  4291. snd_soc_component_update_bits(component, boost_path_cfg1,
  4292. 0x01, 0x01);
  4293. snd_soc_component_update_bits(component, reg, 0x10, 0x00);
  4294. if ((snd_soc_component_read32(component, reg_mix)) & 0x10)
  4295. snd_soc_component_update_bits(component, reg_mix,
  4296. 0x10, 0x00);
  4297. break;
  4298. case SND_SOC_DAPM_POST_PMD:
  4299. snd_soc_component_update_bits(component, boost_path_cfg1,
  4300. 0x01, 0x00);
  4301. snd_soc_component_update_bits(component, boost_path_ctl,
  4302. 0x10, 0x00);
  4303. break;
  4304. };
  4305. return 0;
  4306. }
  4307. static u16 tasha_interp_get_primary_reg(u16 reg, u16 *ind)
  4308. {
  4309. u16 prim_int_reg = 0;
  4310. switch (reg) {
  4311. case WCD9335_CDC_RX0_RX_PATH_CTL:
  4312. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4313. prim_int_reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4314. *ind = 0;
  4315. break;
  4316. case WCD9335_CDC_RX1_RX_PATH_CTL:
  4317. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4318. prim_int_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4319. *ind = 1;
  4320. break;
  4321. case WCD9335_CDC_RX2_RX_PATH_CTL:
  4322. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4323. prim_int_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4324. *ind = 2;
  4325. break;
  4326. case WCD9335_CDC_RX3_RX_PATH_CTL:
  4327. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4328. prim_int_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4329. *ind = 3;
  4330. break;
  4331. case WCD9335_CDC_RX4_RX_PATH_CTL:
  4332. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4333. prim_int_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4334. *ind = 4;
  4335. break;
  4336. case WCD9335_CDC_RX5_RX_PATH_CTL:
  4337. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4338. prim_int_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4339. *ind = 5;
  4340. break;
  4341. case WCD9335_CDC_RX6_RX_PATH_CTL:
  4342. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4343. prim_int_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4344. *ind = 6;
  4345. break;
  4346. case WCD9335_CDC_RX7_RX_PATH_CTL:
  4347. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4348. prim_int_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4349. *ind = 7;
  4350. break;
  4351. case WCD9335_CDC_RX8_RX_PATH_CTL:
  4352. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4353. prim_int_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4354. *ind = 8;
  4355. break;
  4356. };
  4357. return prim_int_reg;
  4358. }
  4359. static void tasha_codec_hd2_control(struct snd_soc_component *component,
  4360. u16 prim_int_reg, int event)
  4361. {
  4362. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  4363. u16 hd2_scale_reg;
  4364. u16 hd2_enable_reg = 0;
  4365. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  4366. return;
  4367. if (prim_int_reg == WCD9335_CDC_RX1_RX_PATH_CTL) {
  4368. hd2_scale_reg = WCD9335_CDC_RX1_RX_PATH_SEC3;
  4369. hd2_enable_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4370. }
  4371. if (prim_int_reg == WCD9335_CDC_RX2_RX_PATH_CTL) {
  4372. hd2_scale_reg = WCD9335_CDC_RX2_RX_PATH_SEC3;
  4373. hd2_enable_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4374. }
  4375. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) {
  4376. snd_soc_component_update_bits(component, hd2_scale_reg,
  4377. 0x3C, 0x10);
  4378. snd_soc_component_update_bits(component, hd2_scale_reg,
  4379. 0x03, 0x01);
  4380. snd_soc_component_update_bits(component, hd2_enable_reg,
  4381. 0x04, 0x04);
  4382. }
  4383. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
  4384. snd_soc_component_update_bits(component, hd2_enable_reg,
  4385. 0x04, 0x00);
  4386. snd_soc_component_update_bits(component, hd2_scale_reg,
  4387. 0x03, 0x00);
  4388. snd_soc_component_update_bits(component, hd2_scale_reg,
  4389. 0x3C, 0x00);
  4390. }
  4391. }
  4392. static int tasha_codec_enable_prim_interpolator(
  4393. struct snd_soc_component *component,
  4394. u16 reg, int event)
  4395. {
  4396. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  4397. u16 prim_int_reg;
  4398. u16 ind = 0;
  4399. prim_int_reg = tasha_interp_get_primary_reg(reg, &ind);
  4400. switch (event) {
  4401. case SND_SOC_DAPM_PRE_PMU:
  4402. tasha->prim_int_users[ind]++;
  4403. if (tasha->prim_int_users[ind] == 1) {
  4404. snd_soc_component_update_bits(component, prim_int_reg,
  4405. 0x10, 0x10);
  4406. tasha_codec_hd2_control(component, prim_int_reg, event);
  4407. snd_soc_component_update_bits(component, prim_int_reg,
  4408. 1 << 0x5, 1 << 0x5);
  4409. }
  4410. if ((reg != prim_int_reg) &&
  4411. ((snd_soc_component_read32(
  4412. component, prim_int_reg)) & 0x10))
  4413. snd_soc_component_update_bits(component, reg,
  4414. 0x10, 0x10);
  4415. break;
  4416. case SND_SOC_DAPM_POST_PMD:
  4417. tasha->prim_int_users[ind]--;
  4418. if (tasha->prim_int_users[ind] == 0) {
  4419. snd_soc_component_update_bits(component, prim_int_reg,
  4420. 1 << 0x5, 0 << 0x5);
  4421. snd_soc_component_update_bits(component, prim_int_reg,
  4422. 0x40, 0x40);
  4423. snd_soc_component_update_bits(component, prim_int_reg,
  4424. 0x40, 0x00);
  4425. tasha_codec_hd2_control(component, prim_int_reg, event);
  4426. }
  4427. break;
  4428. };
  4429. dev_dbg(component->dev, "%s: primary interpolator: INT%d, users: %d\n",
  4430. __func__, ind, tasha->prim_int_users[ind]);
  4431. return 0;
  4432. }
  4433. static int tasha_codec_enable_spline_src(struct snd_soc_component *component,
  4434. int src_num,
  4435. int event)
  4436. {
  4437. u16 src_paired_reg = 0;
  4438. struct tasha_priv *tasha;
  4439. u16 rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4440. u16 rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4441. int *src_users, count, spl_src = SPLINE_SRC0;
  4442. u16 src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4443. tasha = snd_soc_component_get_drvdata(component);
  4444. switch (src_num) {
  4445. case SRC_IN_HPHL:
  4446. rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4447. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4448. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4449. rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4450. spl_src = SPLINE_SRC0;
  4451. break;
  4452. case SRC_IN_LO1:
  4453. rx_path_cfg_reg = WCD9335_CDC_RX3_RX_PATH_CFG0;
  4454. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4455. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4456. rx_path_ctl_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4457. spl_src = SPLINE_SRC0;
  4458. break;
  4459. case SRC_IN_HPHR:
  4460. rx_path_cfg_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4461. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4462. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4463. rx_path_ctl_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4464. spl_src = SPLINE_SRC1;
  4465. break;
  4466. case SRC_IN_LO2:
  4467. rx_path_cfg_reg = WCD9335_CDC_RX4_RX_PATH_CFG0;
  4468. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4469. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4470. rx_path_ctl_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4471. spl_src = SPLINE_SRC1;
  4472. break;
  4473. case SRC_IN_SPKRL:
  4474. rx_path_cfg_reg = WCD9335_CDC_RX7_RX_PATH_CFG0;
  4475. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4476. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4477. rx_path_ctl_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4478. spl_src = SPLINE_SRC2;
  4479. break;
  4480. case SRC_IN_LO3:
  4481. rx_path_cfg_reg = WCD9335_CDC_RX5_RX_PATH_CFG0;
  4482. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4483. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4484. rx_path_ctl_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4485. spl_src = SPLINE_SRC2;
  4486. break;
  4487. case SRC_IN_SPKRR:
  4488. rx_path_cfg_reg = WCD9335_CDC_RX8_RX_PATH_CFG0;
  4489. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4490. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4491. rx_path_ctl_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4492. spl_src = SPLINE_SRC3;
  4493. break;
  4494. case SRC_IN_LO4:
  4495. rx_path_cfg_reg = WCD9335_CDC_RX6_RX_PATH_CFG0;
  4496. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4497. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4498. rx_path_ctl_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4499. spl_src = SPLINE_SRC3;
  4500. break;
  4501. };
  4502. src_users = &tasha->spl_src_users[spl_src];
  4503. switch (event) {
  4504. case SND_SOC_DAPM_PRE_PMU:
  4505. count = *src_users;
  4506. count++;
  4507. if (count == 1) {
  4508. if ((snd_soc_component_read32(
  4509. component, src_clk_reg) & 0x02) ||
  4510. (snd_soc_component_read32(
  4511. component, src_paired_reg) & 0x02)) {
  4512. snd_soc_component_update_bits(component,
  4513. src_clk_reg, 0x02, 0x00);
  4514. snd_soc_component_update_bits(component,
  4515. src_paired_reg, 0x02, 0x00);
  4516. }
  4517. snd_soc_component_update_bits(component, src_clk_reg,
  4518. 0x01, 0x01);
  4519. snd_soc_component_update_bits(component,
  4520. rx_path_cfg_reg, 0x80, 0x80);
  4521. }
  4522. *src_users = count;
  4523. break;
  4524. case SND_SOC_DAPM_POST_PMD:
  4525. count = *src_users;
  4526. count--;
  4527. if (count == 0) {
  4528. snd_soc_component_update_bits(component,
  4529. rx_path_cfg_reg, 0x80, 0x00);
  4530. snd_soc_component_update_bits(component,
  4531. src_clk_reg, 0x03, 0x02);
  4532. /* default sample rate */
  4533. snd_soc_component_update_bits(component,
  4534. rx_path_ctl_reg, 0x0f, 0x04);
  4535. }
  4536. *src_users = count;
  4537. break;
  4538. };
  4539. dev_dbg(component->dev, "%s: Spline SRC%d, users: %d\n",
  4540. __func__, spl_src, *src_users);
  4541. return 0;
  4542. }
  4543. static int tasha_codec_enable_spline_resampler(struct snd_soc_dapm_widget *w,
  4544. struct snd_kcontrol *kcontrol,
  4545. int event)
  4546. {
  4547. struct snd_soc_component *component =
  4548. snd_soc_dapm_to_component(w->dapm);
  4549. int ret = 0;
  4550. u8 src_in;
  4551. src_in = snd_soc_component_read32(
  4552. component, WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0);
  4553. if (!(src_in & 0xFF)) {
  4554. dev_err(component->dev, "%s: Spline SRC%u input not selected\n",
  4555. __func__, w->shift);
  4556. return -EINVAL;
  4557. }
  4558. switch (w->shift) {
  4559. case SPLINE_SRC0:
  4560. ret = tasha_codec_enable_spline_src(component,
  4561. ((src_in & 0x03) == 1) ? SRC_IN_HPHL : SRC_IN_LO1,
  4562. event);
  4563. break;
  4564. case SPLINE_SRC1:
  4565. ret = tasha_codec_enable_spline_src(component,
  4566. ((src_in & 0x0C) == 4) ? SRC_IN_HPHR : SRC_IN_LO2,
  4567. event);
  4568. break;
  4569. case SPLINE_SRC2:
  4570. ret = tasha_codec_enable_spline_src(component,
  4571. ((src_in & 0x30) == 0x10) ? SRC_IN_LO3 : SRC_IN_SPKRL,
  4572. event);
  4573. break;
  4574. case SPLINE_SRC3:
  4575. ret = tasha_codec_enable_spline_src(component,
  4576. ((src_in & 0xC0) == 0x40) ? SRC_IN_LO4 : SRC_IN_SPKRR,
  4577. event);
  4578. break;
  4579. default:
  4580. dev_err(component->dev, "%s: Invalid spline src:%u\n", __func__,
  4581. w->shift);
  4582. ret = -EINVAL;
  4583. };
  4584. return ret;
  4585. }
  4586. static int tasha_codec_enable_swr(struct snd_soc_dapm_widget *w,
  4587. struct snd_kcontrol *kcontrol, int event)
  4588. {
  4589. struct snd_soc_component *component =
  4590. snd_soc_dapm_to_component(w->dapm);
  4591. struct tasha_priv *tasha;
  4592. int i, ch_cnt;
  4593. tasha = snd_soc_component_get_drvdata(component);
  4594. if (!tasha->nr)
  4595. return 0;
  4596. switch (event) {
  4597. case SND_SOC_DAPM_PRE_PMU:
  4598. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4599. !tasha->rx_7_count)
  4600. tasha->rx_7_count++;
  4601. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4602. !tasha->rx_8_count)
  4603. tasha->rx_8_count++;
  4604. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4605. for (i = 0; i < tasha->nr; i++) {
  4606. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4607. SWR_DEVICE_UP, NULL);
  4608. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4609. SWR_SET_NUM_RX_CH, &ch_cnt);
  4610. }
  4611. break;
  4612. case SND_SOC_DAPM_POST_PMD:
  4613. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4614. tasha->rx_7_count)
  4615. tasha->rx_7_count--;
  4616. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4617. tasha->rx_8_count)
  4618. tasha->rx_8_count--;
  4619. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4620. for (i = 0; i < tasha->nr; i++)
  4621. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4622. SWR_SET_NUM_RX_CH, &ch_cnt);
  4623. break;
  4624. }
  4625. dev_dbg(tasha->dev, "%s: current swr ch cnt: %d\n",
  4626. __func__, tasha->rx_7_count + tasha->rx_8_count);
  4627. return 0;
  4628. }
  4629. static int tasha_codec_config_ear_spkr_gain(struct snd_soc_component *component,
  4630. int event, int gain_reg)
  4631. {
  4632. int comp_gain_offset, val;
  4633. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  4634. switch (tasha->spkr_mode) {
  4635. /* Compander gain in SPKR_MODE1 case is 12 dB */
  4636. case SPKR_MODE_1:
  4637. comp_gain_offset = -12;
  4638. break;
  4639. /* Default case compander gain is 15 dB */
  4640. default:
  4641. comp_gain_offset = -15;
  4642. break;
  4643. }
  4644. switch (event) {
  4645. case SND_SOC_DAPM_POST_PMU:
  4646. /* Apply ear spkr gain only if compander is enabled */
  4647. if (tasha->comp_enabled[COMPANDER_7] &&
  4648. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4649. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4650. (tasha->ear_spkr_gain != 0)) {
  4651. /* For example, val is -8(-12+5-1) for 4dB of gain */
  4652. val = comp_gain_offset + tasha->ear_spkr_gain - 1;
  4653. snd_soc_component_write(component, gain_reg, val);
  4654. dev_dbg(component->dev, "%s: RX7 Volume %d dB\n",
  4655. __func__, val);
  4656. }
  4657. break;
  4658. case SND_SOC_DAPM_POST_PMD:
  4659. /*
  4660. * Reset RX7 volume to 0 dB if compander is enabled and
  4661. * ear_spkr_gain is non-zero.
  4662. */
  4663. if (tasha->comp_enabled[COMPANDER_7] &&
  4664. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4665. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4666. (tasha->ear_spkr_gain != 0)) {
  4667. snd_soc_component_write(component, gain_reg, 0x0);
  4668. dev_dbg(component->dev, "%s: Reset RX7 Volume to 0 dB\n",
  4669. __func__);
  4670. }
  4671. break;
  4672. }
  4673. return 0;
  4674. }
  4675. static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w,
  4676. struct snd_kcontrol *kcontrol, int event)
  4677. {
  4678. struct snd_soc_component *component =
  4679. snd_soc_dapm_to_component(w->dapm);
  4680. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  4681. u16 gain_reg;
  4682. int offset_val = 0;
  4683. int val = 0;
  4684. dev_dbg(component->dev, "%s %d %s\n", __func__, event, w->name);
  4685. switch (w->reg) {
  4686. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4687. gain_reg = WCD9335_CDC_RX0_RX_VOL_MIX_CTL;
  4688. break;
  4689. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4690. gain_reg = WCD9335_CDC_RX1_RX_VOL_MIX_CTL;
  4691. break;
  4692. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4693. gain_reg = WCD9335_CDC_RX2_RX_VOL_MIX_CTL;
  4694. break;
  4695. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4696. gain_reg = WCD9335_CDC_RX3_RX_VOL_MIX_CTL;
  4697. break;
  4698. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4699. gain_reg = WCD9335_CDC_RX4_RX_VOL_MIX_CTL;
  4700. break;
  4701. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4702. gain_reg = WCD9335_CDC_RX5_RX_VOL_MIX_CTL;
  4703. break;
  4704. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4705. gain_reg = WCD9335_CDC_RX6_RX_VOL_MIX_CTL;
  4706. break;
  4707. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4708. gain_reg = WCD9335_CDC_RX7_RX_VOL_MIX_CTL;
  4709. break;
  4710. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4711. gain_reg = WCD9335_CDC_RX8_RX_VOL_MIX_CTL;
  4712. break;
  4713. default:
  4714. dev_err(component->dev, "%s: No gain register avail for %s\n",
  4715. __func__, w->name);
  4716. return 0;
  4717. };
  4718. switch (event) {
  4719. case SND_SOC_DAPM_POST_PMU:
  4720. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4721. (tasha->comp_enabled[COMPANDER_7] ||
  4722. tasha->comp_enabled[COMPANDER_8]) &&
  4723. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4724. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4725. snd_soc_component_update_bits(component,
  4726. WCD9335_CDC_RX7_RX_PATH_SEC1,
  4727. 0x01, 0x01);
  4728. snd_soc_component_update_bits(component,
  4729. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4730. 0x01, 0x01);
  4731. snd_soc_component_update_bits(component,
  4732. WCD9335_CDC_RX8_RX_PATH_SEC1,
  4733. 0x01, 0x01);
  4734. snd_soc_component_update_bits(component,
  4735. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4736. 0x01, 0x01);
  4737. offset_val = -2;
  4738. }
  4739. val = snd_soc_component_read32(component, gain_reg);
  4740. val += offset_val;
  4741. snd_soc_component_write(component, gain_reg, val);
  4742. tasha_codec_config_ear_spkr_gain(component, event, gain_reg);
  4743. break;
  4744. case SND_SOC_DAPM_POST_PMD:
  4745. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4746. (tasha->comp_enabled[COMPANDER_7] ||
  4747. tasha->comp_enabled[COMPANDER_8]) &&
  4748. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4749. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4750. snd_soc_component_update_bits(component,
  4751. WCD9335_CDC_RX7_RX_PATH_SEC1,
  4752. 0x01, 0x00);
  4753. snd_soc_component_update_bits(component,
  4754. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4755. 0x01, 0x00);
  4756. snd_soc_component_update_bits(component,
  4757. WCD9335_CDC_RX8_RX_PATH_SEC1,
  4758. 0x01, 0x00);
  4759. snd_soc_component_update_bits(component,
  4760. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4761. 0x01, 0x00);
  4762. offset_val = 2;
  4763. val = snd_soc_component_read32(component, gain_reg);
  4764. val += offset_val;
  4765. snd_soc_component_write(component, gain_reg, val);
  4766. }
  4767. tasha_codec_config_ear_spkr_gain(component, event, gain_reg);
  4768. break;
  4769. };
  4770. return 0;
  4771. }
  4772. static int __tasha_cdc_native_clk_enable(struct tasha_priv *tasha,
  4773. bool enable)
  4774. {
  4775. int ret = 0;
  4776. struct snd_soc_component *component = tasha->component;
  4777. if (!tasha->wcd_native_clk) {
  4778. dev_err(tasha->dev, "%s: wcd native clock is NULL\n",
  4779. __func__);
  4780. return -EINVAL;
  4781. }
  4782. dev_dbg(tasha->dev, "%s: native_clk_enable = %u\n",
  4783. __func__, enable);
  4784. if (enable) {
  4785. ret = clk_prepare_enable(tasha->wcd_native_clk);
  4786. if (ret) {
  4787. dev_err(tasha->dev, "%s: native clk enable failed\n",
  4788. __func__);
  4789. goto err;
  4790. }
  4791. if (++tasha->native_clk_users == 1) {
  4792. snd_soc_component_update_bits(component,
  4793. WCD9335_CLOCK_TEST_CTL,
  4794. 0x10, 0x10);
  4795. snd_soc_component_update_bits(component,
  4796. WCD9335_CLOCK_TEST_CTL,
  4797. 0x80, 0x80);
  4798. snd_soc_component_update_bits(component,
  4799. WCD9335_CODEC_RPM_CLK_GATE,
  4800. 0x04, 0x00);
  4801. snd_soc_component_update_bits(component,
  4802. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4803. 0x02, 0x02);
  4804. }
  4805. } else {
  4806. if (tasha->native_clk_users &&
  4807. (--tasha->native_clk_users == 0)) {
  4808. snd_soc_component_update_bits(component,
  4809. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4810. 0x02, 0x00);
  4811. snd_soc_component_update_bits(component,
  4812. WCD9335_CODEC_RPM_CLK_GATE,
  4813. 0x04, 0x04);
  4814. snd_soc_component_update_bits(component,
  4815. WCD9335_CLOCK_TEST_CTL,
  4816. 0x80, 0x00);
  4817. snd_soc_component_update_bits(component,
  4818. WCD9335_CLOCK_TEST_CTL,
  4819. 0x10, 0x00);
  4820. }
  4821. clk_disable_unprepare(tasha->wcd_native_clk);
  4822. }
  4823. dev_dbg(component->dev, "%s: native_clk_users: %d\n", __func__,
  4824. tasha->native_clk_users);
  4825. err:
  4826. return ret;
  4827. }
  4828. static int tasha_codec_get_native_fifo_sync_mask(
  4829. struct snd_soc_component *component,
  4830. int interp_n)
  4831. {
  4832. int mask = 0;
  4833. u16 reg;
  4834. u8 val1, val2, inp0 = 0;
  4835. u8 inp1 = 0, inp2 = 0;
  4836. reg = WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0 + (2 * interp_n) - 2;
  4837. val1 = snd_soc_component_read32(component, reg);
  4838. val2 = snd_soc_component_read32(component, reg + 1);
  4839. inp0 = val1 & 0x0F;
  4840. inp1 = (val1 >> 4) & 0x0F;
  4841. inp2 = (val2 >> 4) & 0x0F;
  4842. if (IS_VALID_NATIVE_FIFO_PORT(inp0))
  4843. mask |= (1 << (inp0 - 5));
  4844. if (IS_VALID_NATIVE_FIFO_PORT(inp1))
  4845. mask |= (1 << (inp1 - 5));
  4846. if (IS_VALID_NATIVE_FIFO_PORT(inp2))
  4847. mask |= (1 << (inp2 - 5));
  4848. dev_dbg(component->dev, "%s: native fifo mask: 0x%x\n", __func__, mask);
  4849. if (!mask)
  4850. dev_err(component->dev, "native fifo err,int:%d,inp0:%d,inp1:%d,inp2:%d\n",
  4851. interp_n, inp0, inp1, inp2);
  4852. return mask;
  4853. }
  4854. static int tasha_enable_native_supply(struct snd_soc_dapm_widget *w,
  4855. struct snd_kcontrol *kcontrol, int event)
  4856. {
  4857. int mask;
  4858. struct snd_soc_component *component =
  4859. snd_soc_dapm_to_component(w->dapm);
  4860. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  4861. u16 interp_reg;
  4862. dev_dbg(component->dev, "%s: event: %d, shift:%d\n", __func__, event,
  4863. w->shift);
  4864. if (w->shift < INTERP_HPHL || w->shift > INTERP_LO2)
  4865. return -EINVAL;
  4866. interp_reg = WCD9335_CDC_RX1_RX_PATH_CTL + 20 * (w->shift - 1);
  4867. mask = tasha_codec_get_native_fifo_sync_mask(component, w->shift);
  4868. if (!mask)
  4869. return -EINVAL;
  4870. switch (event) {
  4871. case SND_SOC_DAPM_PRE_PMU:
  4872. /* Adjust interpolator rate to 44P1_NATIVE */
  4873. snd_soc_component_update_bits(component, interp_reg,
  4874. 0x0F, 0x09);
  4875. __tasha_cdc_native_clk_enable(tasha, true);
  4876. snd_soc_component_update_bits(component,
  4877. WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4878. mask, mask);
  4879. break;
  4880. case SND_SOC_DAPM_PRE_PMD:
  4881. snd_soc_component_update_bits(component,
  4882. WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4883. mask, 0x0);
  4884. __tasha_cdc_native_clk_enable(tasha, false);
  4885. /* Adjust interpolator rate to default */
  4886. snd_soc_component_update_bits(component, interp_reg,
  4887. 0x0F, 0x04);
  4888. break;
  4889. }
  4890. return 0;
  4891. }
  4892. static int tasha_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
  4893. struct snd_kcontrol *kcontrol, int event)
  4894. {
  4895. struct snd_soc_component *component =
  4896. snd_soc_dapm_to_component(w->dapm);
  4897. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  4898. u16 gain_reg;
  4899. u16 reg;
  4900. int val;
  4901. int offset_val = 0;
  4902. dev_dbg(component->dev, "%s %d %s\n", __func__, event, w->name);
  4903. if (!(strcmp(w->name, "RX INT0 INTERP"))) {
  4904. reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4905. gain_reg = WCD9335_CDC_RX0_RX_VOL_CTL;
  4906. } else if (!(strcmp(w->name, "RX INT1 INTERP"))) {
  4907. reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4908. gain_reg = WCD9335_CDC_RX1_RX_VOL_CTL;
  4909. } else if (!(strcmp(w->name, "RX INT2 INTERP"))) {
  4910. reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4911. gain_reg = WCD9335_CDC_RX2_RX_VOL_CTL;
  4912. } else if (!(strcmp(w->name, "RX INT3 INTERP"))) {
  4913. reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4914. gain_reg = WCD9335_CDC_RX3_RX_VOL_CTL;
  4915. } else if (!(strcmp(w->name, "RX INT4 INTERP"))) {
  4916. reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4917. gain_reg = WCD9335_CDC_RX4_RX_VOL_CTL;
  4918. } else if (!(strcmp(w->name, "RX INT5 INTERP"))) {
  4919. reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4920. gain_reg = WCD9335_CDC_RX5_RX_VOL_CTL;
  4921. } else if (!(strcmp(w->name, "RX INT6 INTERP"))) {
  4922. reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4923. gain_reg = WCD9335_CDC_RX6_RX_VOL_CTL;
  4924. } else if (!(strcmp(w->name, "RX INT7 INTERP"))) {
  4925. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4926. gain_reg = WCD9335_CDC_RX7_RX_VOL_CTL;
  4927. } else if (!(strcmp(w->name, "RX INT8 INTERP"))) {
  4928. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4929. gain_reg = WCD9335_CDC_RX8_RX_VOL_CTL;
  4930. } else {
  4931. dev_err(component->dev, "%s: Interpolator reg not found\n",
  4932. __func__);
  4933. return -EINVAL;
  4934. }
  4935. switch (event) {
  4936. case SND_SOC_DAPM_PRE_PMU:
  4937. tasha_codec_vote_max_bw(component, true);
  4938. /* Reset if needed */
  4939. tasha_codec_enable_prim_interpolator(component, reg, event);
  4940. break;
  4941. case SND_SOC_DAPM_POST_PMU:
  4942. tasha_config_compander(component, w->shift, event);
  4943. /* apply gain after int clk is enabled */
  4944. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4945. (tasha->comp_enabled[COMPANDER_7] ||
  4946. tasha->comp_enabled[COMPANDER_8]) &&
  4947. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4948. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4949. snd_soc_component_update_bits(component,
  4950. WCD9335_CDC_RX7_RX_PATH_SEC1,
  4951. 0x01, 0x01);
  4952. snd_soc_component_update_bits(component,
  4953. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4954. 0x01, 0x01);
  4955. snd_soc_component_update_bits(component,
  4956. WCD9335_CDC_RX8_RX_PATH_SEC1,
  4957. 0x01, 0x01);
  4958. snd_soc_component_update_bits(component,
  4959. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4960. 0x01, 0x01);
  4961. offset_val = -2;
  4962. }
  4963. val = snd_soc_component_read32(component, gain_reg);
  4964. val += offset_val;
  4965. snd_soc_component_write(component, gain_reg, val);
  4966. tasha_codec_config_ear_spkr_gain(component, event, gain_reg);
  4967. break;
  4968. case SND_SOC_DAPM_POST_PMD:
  4969. tasha_config_compander(component, w->shift, event);
  4970. tasha_codec_enable_prim_interpolator(component, reg, event);
  4971. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4972. (tasha->comp_enabled[COMPANDER_7] ||
  4973. tasha->comp_enabled[COMPANDER_8]) &&
  4974. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4975. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4976. snd_soc_component_update_bits(component,
  4977. WCD9335_CDC_RX7_RX_PATH_SEC1,
  4978. 0x01, 0x00);
  4979. snd_soc_component_update_bits(component,
  4980. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4981. 0x01, 0x00);
  4982. snd_soc_component_update_bits(component,
  4983. WCD9335_CDC_RX8_RX_PATH_SEC1,
  4984. 0x01, 0x00);
  4985. snd_soc_component_update_bits(component,
  4986. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4987. 0x01, 0x00);
  4988. offset_val = 2;
  4989. val = snd_soc_component_read32(component, gain_reg);
  4990. val += offset_val;
  4991. snd_soc_component_write(component, gain_reg, val);
  4992. }
  4993. tasha_codec_config_ear_spkr_gain(component, event, gain_reg);
  4994. break;
  4995. };
  4996. return 0;
  4997. }
  4998. static int tasha_codec_set_iir_gain(struct snd_soc_dapm_widget *w,
  4999. struct snd_kcontrol *kcontrol, int event)
  5000. {
  5001. struct snd_soc_component *component =
  5002. snd_soc_dapm_to_component(w->dapm);
  5003. dev_dbg(component->dev, "%s: event = %d\n", __func__, event);
  5004. switch (event) {
  5005. case SND_SOC_DAPM_POST_PMU: /* fall through */
  5006. case SND_SOC_DAPM_PRE_PMD:
  5007. if (strnstr(w->name, "IIR0", sizeof("IIR0"))) {
  5008. snd_soc_component_write(component,
  5009. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL,
  5010. snd_soc_component_read32(component,
  5011. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL));
  5012. snd_soc_component_write(component,
  5013. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL,
  5014. snd_soc_component_read32(component,
  5015. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL));
  5016. snd_soc_component_write(component,
  5017. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL,
  5018. snd_soc_component_read32(component,
  5019. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL));
  5020. snd_soc_component_write(component,
  5021. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL,
  5022. snd_soc_component_read32(component,
  5023. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL));
  5024. } else {
  5025. snd_soc_component_write(component,
  5026. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL,
  5027. snd_soc_component_read32(component,
  5028. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL));
  5029. snd_soc_component_write(component,
  5030. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL,
  5031. snd_soc_component_read32(component,
  5032. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL));
  5033. snd_soc_component_write(component,
  5034. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL,
  5035. snd_soc_component_read32(component,
  5036. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL));
  5037. }
  5038. break;
  5039. }
  5040. return 0;
  5041. }
  5042. static int tasha_codec_enable_on_demand_supply(
  5043. struct snd_soc_dapm_widget *w,
  5044. struct snd_kcontrol *kcontrol, int event)
  5045. {
  5046. int ret = 0;
  5047. struct snd_soc_component *component =
  5048. snd_soc_dapm_to_component(w->dapm);
  5049. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  5050. struct on_demand_supply *supply;
  5051. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  5052. struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent);
  5053. const char *supply_name;
  5054. if (w->shift >= ON_DEMAND_SUPPLIES_MAX) {
  5055. dev_err(component->dev, "%s: error index > MAX Demand supplies",
  5056. __func__);
  5057. ret = -EINVAL;
  5058. goto out;
  5059. }
  5060. dev_dbg(component->dev, "%s: supply: %s event: %d\n",
  5061. __func__, on_demand_supply_name[w->shift], event);
  5062. supply = &tasha->on_demand_list[w->shift];
  5063. supply_name = on_demand_supply_name[w->shift];
  5064. WARN_ONCE(!supply->supply, "%s isn't defined\n",
  5065. on_demand_supply_name[w->shift]);
  5066. if (!supply->supply) {
  5067. dev_err(component->dev, "%s: err supply not present ond for %d",
  5068. __func__, w->shift);
  5069. goto out;
  5070. }
  5071. switch (event) {
  5072. case SND_SOC_DAPM_PRE_PMU:
  5073. if (pdata->vote_regulator_on_demand) {
  5074. ret = wcd9xxx_vote_ondemand_regulator(wcd9xxx, pdata,
  5075. supply_name,
  5076. true);
  5077. if (ret)
  5078. dev_err(component->dev, "%s: Failed to vote %s\n",
  5079. __func__,
  5080. on_demand_supply_name[w->shift]);
  5081. }
  5082. ret = regulator_enable(supply->supply);
  5083. if (ret)
  5084. dev_err(component->dev, "%s: Failed to enable %s\n",
  5085. __func__,
  5086. on_demand_supply_name[w->shift]);
  5087. break;
  5088. case SND_SOC_DAPM_POST_PMD:
  5089. ret = regulator_disable(supply->supply);
  5090. if (ret)
  5091. dev_err(component->dev, "%s: Failed to disable %s\n",
  5092. __func__,
  5093. on_demand_supply_name[w->shift]);
  5094. if (pdata->vote_regulator_on_demand) {
  5095. ret = wcd9xxx_vote_ondemand_regulator(wcd9xxx, pdata,
  5096. supply_name,
  5097. false);
  5098. if (ret)
  5099. dev_err(component->dev, "%s: Failed to unvote %s\n",
  5100. __func__,
  5101. on_demand_supply_name[w->shift]);
  5102. }
  5103. break;
  5104. default:
  5105. break;
  5106. };
  5107. out:
  5108. return ret;
  5109. }
  5110. static int tasha_codec_find_amic_input(struct snd_soc_component *component,
  5111. int adc_mux_n)
  5112. {
  5113. u16 mask, shift, adc_mux_in_reg;
  5114. u16 amic_mux_sel_reg;
  5115. bool is_amic;
  5116. if (adc_mux_n < 0 || adc_mux_n > WCD9335_MAX_VALID_ADC_MUX ||
  5117. adc_mux_n == WCD9335_INVALID_ADC_MUX)
  5118. return 0;
  5119. /* Check whether adc mux input is AMIC or DMIC */
  5120. if (adc_mux_n < 4) {
  5121. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
  5122. 2 * adc_mux_n;
  5123. amic_mux_sel_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  5124. 2 * adc_mux_n;
  5125. mask = 0x03;
  5126. shift = 0;
  5127. } else {
  5128. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  5129. adc_mux_n - 4;
  5130. amic_mux_sel_reg = adc_mux_in_reg;
  5131. mask = 0xC0;
  5132. shift = 6;
  5133. }
  5134. is_amic = (((snd_soc_component_read32(
  5135. component, adc_mux_in_reg) & mask) >> shift) == 1);
  5136. if (!is_amic)
  5137. return 0;
  5138. return snd_soc_component_read32(component, amic_mux_sel_reg) & 0x07;
  5139. }
  5140. static void tasha_codec_set_tx_hold(struct snd_soc_component *component,
  5141. u16 amic_reg, bool set)
  5142. {
  5143. u8 mask = 0x20;
  5144. u8 val;
  5145. if (amic_reg == WCD9335_ANA_AMIC1 ||
  5146. amic_reg == WCD9335_ANA_AMIC3 ||
  5147. amic_reg == WCD9335_ANA_AMIC5)
  5148. mask = 0x40;
  5149. val = set ? mask : 0x00;
  5150. switch (amic_reg) {
  5151. case WCD9335_ANA_AMIC1:
  5152. case WCD9335_ANA_AMIC2:
  5153. snd_soc_component_update_bits(component, WCD9335_ANA_AMIC2,
  5154. mask, val);
  5155. break;
  5156. case WCD9335_ANA_AMIC3:
  5157. case WCD9335_ANA_AMIC4:
  5158. snd_soc_component_update_bits(component, WCD9335_ANA_AMIC4,
  5159. mask, val);
  5160. break;
  5161. case WCD9335_ANA_AMIC5:
  5162. case WCD9335_ANA_AMIC6:
  5163. snd_soc_component_update_bits(component, WCD9335_ANA_AMIC6,
  5164. mask, val);
  5165. break;
  5166. default:
  5167. dev_dbg(component->dev, "%s: invalid amic: %d\n",
  5168. __func__, amic_reg);
  5169. break;
  5170. }
  5171. }
  5172. static int tasha_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w,
  5173. struct snd_kcontrol *kcontrol, int event)
  5174. {
  5175. int adc_mux_n = w->shift;
  5176. struct snd_soc_component *component =
  5177. snd_soc_dapm_to_component(w->dapm);
  5178. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  5179. int amic_n;
  5180. dev_dbg(component->dev, "%s: event: %d\n", __func__, event);
  5181. switch (event) {
  5182. case SND_SOC_DAPM_POST_PMU:
  5183. amic_n = tasha_codec_find_amic_input(component, adc_mux_n);
  5184. if (amic_n) {
  5185. /*
  5186. * Prevent ANC Rx pop by leaving Tx FE in HOLD
  5187. * state until PA is up. Track AMIC being used
  5188. * so we can release the HOLD later.
  5189. */
  5190. set_bit(ANC_MIC_AMIC1 + amic_n - 1,
  5191. &tasha->status_mask);
  5192. }
  5193. break;
  5194. default:
  5195. break;
  5196. }
  5197. return 0;
  5198. }
  5199. static u16 tasha_codec_get_amic_pwlvl_reg(
  5200. struct snd_soc_component *component, int amic)
  5201. {
  5202. u16 pwr_level_reg = 0;
  5203. switch (amic) {
  5204. case 1:
  5205. case 2:
  5206. pwr_level_reg = WCD9335_ANA_AMIC1;
  5207. break;
  5208. case 3:
  5209. case 4:
  5210. pwr_level_reg = WCD9335_ANA_AMIC3;
  5211. break;
  5212. case 5:
  5213. case 6:
  5214. pwr_level_reg = WCD9335_ANA_AMIC5;
  5215. break;
  5216. default:
  5217. dev_dbg(component->dev, "%s: invalid amic: %d\n",
  5218. __func__, amic);
  5219. break;
  5220. }
  5221. return pwr_level_reg;
  5222. }
  5223. #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
  5224. #define CF_MIN_3DB_4HZ 0x0
  5225. #define CF_MIN_3DB_75HZ 0x1
  5226. #define CF_MIN_3DB_150HZ 0x2
  5227. static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work)
  5228. {
  5229. struct delayed_work *hpf_delayed_work;
  5230. struct hpf_work *hpf_work;
  5231. struct tasha_priv *tasha;
  5232. struct snd_soc_component *component;
  5233. u16 dec_cfg_reg, amic_reg;
  5234. u8 hpf_cut_off_freq;
  5235. int amic_n;
  5236. hpf_delayed_work = to_delayed_work(work);
  5237. hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
  5238. tasha = hpf_work->tasha;
  5239. component = tasha->component;
  5240. hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
  5241. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator;
  5242. dev_dbg(component->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
  5243. __func__, hpf_work->decimator, hpf_cut_off_freq);
  5244. amic_n = tasha_codec_find_amic_input(component, hpf_work->decimator);
  5245. if (amic_n) {
  5246. amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1;
  5247. tasha_codec_set_tx_hold(component, amic_reg, false);
  5248. }
  5249. tasha_codec_vote_max_bw(component, true);
  5250. snd_soc_component_update_bits(component, dec_cfg_reg,
  5251. TX_HPF_CUT_OFF_FREQ_MASK,
  5252. hpf_cut_off_freq << 5);
  5253. tasha_codec_vote_max_bw(component, false);
  5254. }
  5255. static void tasha_tx_mute_update_callback(struct work_struct *work)
  5256. {
  5257. struct tx_mute_work *tx_mute_dwork;
  5258. struct tasha_priv *tasha;
  5259. struct delayed_work *delayed_work;
  5260. struct snd_soc_component *component;
  5261. u16 tx_vol_ctl_reg, hpf_gate_reg;
  5262. delayed_work = to_delayed_work(work);
  5263. tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
  5264. tasha = tx_mute_dwork->tasha;
  5265. component = tasha->component;
  5266. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  5267. 16 * tx_mute_dwork->decimator;
  5268. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 +
  5269. 16 * tx_mute_dwork->decimator;
  5270. snd_soc_component_update_bits(component, hpf_gate_reg, 0x01, 0x01);
  5271. snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00);
  5272. }
  5273. static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w,
  5274. struct snd_kcontrol *kcontrol, int event)
  5275. {
  5276. struct snd_soc_component *component =
  5277. snd_soc_dapm_to_component(w->dapm);
  5278. unsigned int decimator;
  5279. char *dec_adc_mux_name = NULL;
  5280. char *widget_name = NULL;
  5281. char *wname;
  5282. int ret = 0, amic_n;
  5283. u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
  5284. u16 tx_gain_ctl_reg;
  5285. char *dec;
  5286. u8 hpf_cut_off_freq;
  5287. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  5288. dev_dbg(component->dev, "%s %d\n", __func__, event);
  5289. widget_name = kstrndup(w->name, 15, GFP_KERNEL);
  5290. if (!widget_name)
  5291. return -ENOMEM;
  5292. wname = widget_name;
  5293. dec_adc_mux_name = strsep(&widget_name, " ");
  5294. if (!dec_adc_mux_name) {
  5295. dev_err(component->dev, "%s: Invalid decimator = %s\n",
  5296. __func__, w->name);
  5297. ret = -EINVAL;
  5298. goto out;
  5299. }
  5300. dec_adc_mux_name = widget_name;
  5301. dec = strpbrk(dec_adc_mux_name, "012345678");
  5302. if (!dec) {
  5303. dev_err(component->dev, "%s: decimator index not found\n",
  5304. __func__);
  5305. ret = -EINVAL;
  5306. goto out;
  5307. }
  5308. ret = kstrtouint(dec, 10, &decimator);
  5309. if (ret < 0) {
  5310. dev_err(component->dev, "%s: Invalid decimator = %s\n",
  5311. __func__, wname);
  5312. ret = -EINVAL;
  5313. goto out;
  5314. }
  5315. dev_dbg(component->dev, "%s(): widget = %s decimator = %u\n", __func__,
  5316. w->name, decimator);
  5317. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator;
  5318. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 + 16 * decimator;
  5319. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * decimator;
  5320. tx_gain_ctl_reg = WCD9335_CDC_TX0_TX_VOL_CTL + 16 * decimator;
  5321. switch (event) {
  5322. case SND_SOC_DAPM_PRE_PMU:
  5323. amic_n = tasha_codec_find_amic_input(component, decimator);
  5324. if (amic_n)
  5325. pwr_level_reg = tasha_codec_get_amic_pwlvl_reg(
  5326. component, amic_n);
  5327. if (pwr_level_reg) {
  5328. switch (
  5329. (snd_soc_component_read32(component, pwr_level_reg) &
  5330. WCD9335_AMIC_PWR_LVL_MASK) >>
  5331. WCD9335_AMIC_PWR_LVL_SHIFT) {
  5332. case WCD9335_AMIC_PWR_LEVEL_LP:
  5333. snd_soc_component_update_bits(
  5334. component, dec_cfg_reg,
  5335. WCD9335_DEC_PWR_LVL_MASK,
  5336. WCD9335_DEC_PWR_LVL_LP);
  5337. break;
  5338. case WCD9335_AMIC_PWR_LEVEL_HP:
  5339. snd_soc_component_update_bits(
  5340. component, dec_cfg_reg,
  5341. WCD9335_DEC_PWR_LVL_MASK,
  5342. WCD9335_DEC_PWR_LVL_HP);
  5343. break;
  5344. case WCD9335_AMIC_PWR_LEVEL_DEFAULT:
  5345. default:
  5346. snd_soc_component_update_bits(
  5347. component, dec_cfg_reg,
  5348. WCD9335_DEC_PWR_LVL_MASK,
  5349. WCD9335_DEC_PWR_LVL_DF);
  5350. break;
  5351. }
  5352. }
  5353. hpf_cut_off_freq = (
  5354. snd_soc_component_read32(component, dec_cfg_reg) &
  5355. TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
  5356. tasha->tx_hpf_work[decimator].hpf_cut_off_freq =
  5357. hpf_cut_off_freq;
  5358. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
  5359. snd_soc_component_update_bits(component, dec_cfg_reg,
  5360. TX_HPF_CUT_OFF_FREQ_MASK,
  5361. CF_MIN_3DB_150HZ << 5);
  5362. /* Enable TX PGA Mute */
  5363. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  5364. 0x10, 0x10);
  5365. break;
  5366. case SND_SOC_DAPM_POST_PMU:
  5367. snd_soc_component_update_bits(component, hpf_gate_reg,
  5368. 0x01, 0x00);
  5369. if (decimator == 0) {
  5370. snd_soc_component_write(component,
  5371. WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5372. snd_soc_component_write(component,
  5373. WCD9335_MBHC_ZDET_RAMP_CTL, 0xA3);
  5374. snd_soc_component_write(component,
  5375. WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5376. snd_soc_component_write(component,
  5377. WCD9335_MBHC_ZDET_RAMP_CTL, 0x03);
  5378. }
  5379. /* schedule work queue to Remove Mute */
  5380. schedule_delayed_work(&tasha->tx_mute_dwork[decimator].dwork,
  5381. msecs_to_jiffies(tx_unmute_delay));
  5382. if (tasha->tx_hpf_work[decimator].hpf_cut_off_freq !=
  5383. CF_MIN_3DB_150HZ)
  5384. schedule_delayed_work(
  5385. &tasha->tx_hpf_work[decimator].dwork,
  5386. msecs_to_jiffies(300));
  5387. /* apply gain after decimator is enabled */
  5388. snd_soc_component_write(component, tx_gain_ctl_reg,
  5389. snd_soc_component_read32(
  5390. component, tx_gain_ctl_reg));
  5391. break;
  5392. case SND_SOC_DAPM_PRE_PMD:
  5393. hpf_cut_off_freq =
  5394. tasha->tx_hpf_work[decimator].hpf_cut_off_freq;
  5395. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  5396. 0x10, 0x10);
  5397. if (cancel_delayed_work_sync(
  5398. &tasha->tx_hpf_work[decimator].dwork)) {
  5399. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  5400. tasha_codec_vote_max_bw(component, true);
  5401. snd_soc_component_update_bits(component,
  5402. dec_cfg_reg,
  5403. TX_HPF_CUT_OFF_FREQ_MASK,
  5404. hpf_cut_off_freq << 5);
  5405. tasha_codec_vote_max_bw(component, false);
  5406. }
  5407. }
  5408. cancel_delayed_work_sync(
  5409. &tasha->tx_mute_dwork[decimator].dwork);
  5410. break;
  5411. case SND_SOC_DAPM_POST_PMD:
  5412. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  5413. 0x10, 0x00);
  5414. break;
  5415. };
  5416. out:
  5417. kfree(wname);
  5418. return ret;
  5419. }
  5420. static u32 tasha_get_dmic_sample_rate(struct snd_soc_component *component,
  5421. unsigned int dmic, struct wcd9xxx_pdata *pdata)
  5422. {
  5423. u8 tx_stream_fs;
  5424. u8 adc_mux_index = 0, adc_mux_sel = 0;
  5425. bool dec_found = false;
  5426. u16 adc_mux_ctl_reg, tx_fs_reg;
  5427. u32 dmic_fs;
  5428. while (dec_found == 0 && adc_mux_index < WCD9335_MAX_VALID_ADC_MUX) {
  5429. if (adc_mux_index < 4) {
  5430. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  5431. (adc_mux_index * 2);
  5432. adc_mux_sel = ((snd_soc_component_read32(component,
  5433. adc_mux_ctl_reg) & 0x78) >> 3) - 1;
  5434. } else if (adc_mux_index < 9) {
  5435. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  5436. ((adc_mux_index - 4) * 1);
  5437. adc_mux_sel = ((snd_soc_component_read32(
  5438. component, adc_mux_ctl_reg) & 0x38) >> 3) - 1;
  5439. } else if (adc_mux_index == 9) {
  5440. ++adc_mux_index;
  5441. continue;
  5442. }
  5443. if (adc_mux_sel == dmic)
  5444. dec_found = true;
  5445. else
  5446. ++adc_mux_index;
  5447. }
  5448. if (dec_found == true && adc_mux_index <= 8) {
  5449. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index);
  5450. tx_stream_fs =
  5451. snd_soc_component_read32(component, tx_fs_reg) & 0x0F;
  5452. dmic_fs = tx_stream_fs <= 4 ? WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ :
  5453. WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  5454. /*
  5455. * Check for ECPP path selection and DEC1 not connected to
  5456. * any other audio path to apply ECPP DMIC sample rate
  5457. */
  5458. if ((adc_mux_index == 1) &&
  5459. ((snd_soc_component_read32(
  5460. component, WCD9335_CPE_SS_US_EC_MUX_CFG)
  5461. & 0x0F) == 0x0A) &&
  5462. ((snd_soc_component_read32(
  5463. component, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0)
  5464. & 0x0C) == 0x00)) {
  5465. dmic_fs = pdata->ecpp_dmic_sample_rate;
  5466. }
  5467. } else {
  5468. dmic_fs = pdata->dmic_sample_rate;
  5469. }
  5470. return dmic_fs;
  5471. }
  5472. static u8 tasha_get_dmic_clk_val(struct snd_soc_component *component,
  5473. u32 mclk_rate, u32 dmic_clk_rate)
  5474. {
  5475. u32 div_factor;
  5476. u8 dmic_ctl_val;
  5477. dev_dbg(component->dev,
  5478. "%s: mclk_rate = %d, dmic_sample_rate = %d\n",
  5479. __func__, mclk_rate, dmic_clk_rate);
  5480. /* Default value to return in case of error */
  5481. if (mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  5482. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5483. else
  5484. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5485. if (dmic_clk_rate == 0) {
  5486. dev_err(component->dev,
  5487. "%s: dmic_sample_rate cannot be 0\n",
  5488. __func__);
  5489. goto done;
  5490. }
  5491. div_factor = mclk_rate / dmic_clk_rate;
  5492. switch (div_factor) {
  5493. case 2:
  5494. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5495. break;
  5496. case 3:
  5497. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5498. break;
  5499. case 4:
  5500. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_4;
  5501. break;
  5502. case 6:
  5503. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_6;
  5504. break;
  5505. case 8:
  5506. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_8;
  5507. break;
  5508. case 16:
  5509. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_16;
  5510. break;
  5511. default:
  5512. dev_err(component->dev,
  5513. "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n",
  5514. __func__, div_factor, mclk_rate, dmic_clk_rate);
  5515. break;
  5516. }
  5517. done:
  5518. return dmic_ctl_val;
  5519. }
  5520. static int tasha_codec_enable_adc(struct snd_soc_dapm_widget *w,
  5521. struct snd_kcontrol *kcontrol, int event)
  5522. {
  5523. struct snd_soc_component *component =
  5524. snd_soc_dapm_to_component(w->dapm);
  5525. dev_dbg(component->dev, "%s: event:%d\n", __func__, event);
  5526. switch (event) {
  5527. case SND_SOC_DAPM_PRE_PMU:
  5528. tasha_codec_set_tx_hold(component, w->reg, true);
  5529. break;
  5530. default:
  5531. break;
  5532. }
  5533. return 0;
  5534. }
  5535. static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w,
  5536. struct snd_kcontrol *kcontrol, int event)
  5537. {
  5538. struct snd_soc_component *component =
  5539. snd_soc_dapm_to_component(w->dapm);
  5540. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  5541. struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent);
  5542. u8 dmic_clk_en = 0x01;
  5543. u16 dmic_clk_reg;
  5544. s32 *dmic_clk_cnt;
  5545. u8 dmic_rate_val, dmic_rate_shift = 1;
  5546. unsigned int dmic;
  5547. u32 dmic_sample_rate;
  5548. int ret;
  5549. char *wname;
  5550. wname = strpbrk(w->name, "012345");
  5551. if (!wname) {
  5552. dev_err(component->dev, "%s: widget not found\n", __func__);
  5553. return -EINVAL;
  5554. }
  5555. ret = kstrtouint(wname, 10, &dmic);
  5556. if (ret < 0) {
  5557. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  5558. __func__);
  5559. return -EINVAL;
  5560. }
  5561. switch (dmic) {
  5562. case 0:
  5563. case 1:
  5564. dmic_clk_cnt = &(tasha->dmic_0_1_clk_cnt);
  5565. dmic_clk_reg = WCD9335_CPE_SS_DMIC0_CTL;
  5566. break;
  5567. case 2:
  5568. case 3:
  5569. dmic_clk_cnt = &(tasha->dmic_2_3_clk_cnt);
  5570. dmic_clk_reg = WCD9335_CPE_SS_DMIC1_CTL;
  5571. break;
  5572. case 4:
  5573. case 5:
  5574. dmic_clk_cnt = &(tasha->dmic_4_5_clk_cnt);
  5575. dmic_clk_reg = WCD9335_CPE_SS_DMIC2_CTL;
  5576. break;
  5577. default:
  5578. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  5579. __func__);
  5580. return -EINVAL;
  5581. };
  5582. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
  5583. __func__, event, dmic, *dmic_clk_cnt);
  5584. switch (event) {
  5585. case SND_SOC_DAPM_PRE_PMU:
  5586. dmic_sample_rate = tasha_get_dmic_sample_rate(component, dmic,
  5587. pdata);
  5588. dmic_rate_val =
  5589. tasha_get_dmic_clk_val(component,
  5590. pdata->mclk_rate,
  5591. dmic_sample_rate);
  5592. (*dmic_clk_cnt)++;
  5593. if (*dmic_clk_cnt == 1) {
  5594. snd_soc_component_update_bits(component, dmic_clk_reg,
  5595. 0x07 << dmic_rate_shift,
  5596. dmic_rate_val << dmic_rate_shift);
  5597. snd_soc_component_update_bits(component, dmic_clk_reg,
  5598. dmic_clk_en, dmic_clk_en);
  5599. }
  5600. break;
  5601. case SND_SOC_DAPM_POST_PMD:
  5602. dmic_rate_val =
  5603. tasha_get_dmic_clk_val(component,
  5604. pdata->mclk_rate,
  5605. pdata->mad_dmic_sample_rate);
  5606. (*dmic_clk_cnt)--;
  5607. if (*dmic_clk_cnt == 0) {
  5608. snd_soc_component_update_bits(component, dmic_clk_reg,
  5609. dmic_clk_en, 0);
  5610. snd_soc_component_update_bits(component, dmic_clk_reg,
  5611. 0x07 << dmic_rate_shift,
  5612. dmic_rate_val << dmic_rate_shift);
  5613. }
  5614. break;
  5615. };
  5616. return 0;
  5617. }
  5618. static int __tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5619. int event)
  5620. {
  5621. struct snd_soc_component *component =
  5622. snd_soc_dapm_to_component(w->dapm);
  5623. int micb_num;
  5624. dev_dbg(component->dev, "%s: wname: %s, event: %d\n",
  5625. __func__, w->name, event);
  5626. if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1")))
  5627. micb_num = MIC_BIAS_1;
  5628. else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2")))
  5629. micb_num = MIC_BIAS_2;
  5630. else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3")))
  5631. micb_num = MIC_BIAS_3;
  5632. else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4")))
  5633. micb_num = MIC_BIAS_4;
  5634. else
  5635. return -EINVAL;
  5636. switch (event) {
  5637. case SND_SOC_DAPM_PRE_PMU:
  5638. /*
  5639. * MIC BIAS can also be requested by MBHC,
  5640. * so use ref count to handle micbias pullup
  5641. * and enable requests
  5642. */
  5643. tasha_micbias_control(component, micb_num, MICB_ENABLE, true);
  5644. break;
  5645. case SND_SOC_DAPM_POST_PMU:
  5646. /* wait for cnp time */
  5647. usleep_range(1000, 1100);
  5648. break;
  5649. case SND_SOC_DAPM_POST_PMD:
  5650. tasha_micbias_control(component, micb_num, MICB_DISABLE, true);
  5651. break;
  5652. };
  5653. return 0;
  5654. }
  5655. static int tasha_codec_ldo_h_control(struct snd_soc_dapm_widget *w,
  5656. int event)
  5657. {
  5658. struct snd_soc_component *component =
  5659. snd_soc_dapm_to_component(w->dapm);
  5660. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  5661. if (SND_SOC_DAPM_EVENT_ON(event)) {
  5662. tasha->ldo_h_users++;
  5663. if (tasha->ldo_h_users == 1)
  5664. snd_soc_component_update_bits(component,
  5665. WCD9335_LDOH_MODE,
  5666. 0x80, 0x80);
  5667. }
  5668. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  5669. tasha->ldo_h_users--;
  5670. if (tasha->ldo_h_users < 0)
  5671. tasha->ldo_h_users = 0;
  5672. if (tasha->ldo_h_users == 0)
  5673. snd_soc_component_update_bits(component,
  5674. WCD9335_LDOH_MODE,
  5675. 0x80, 0x00);
  5676. }
  5677. return 0;
  5678. }
  5679. static int tasha_codec_force_enable_ldo_h(struct snd_soc_dapm_widget *w,
  5680. struct snd_kcontrol *kcontrol,
  5681. int event)
  5682. {
  5683. struct snd_soc_component *component =
  5684. snd_soc_dapm_to_component(w->dapm);
  5685. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  5686. switch (event) {
  5687. case SND_SOC_DAPM_PRE_PMU:
  5688. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5689. tasha_codec_ldo_h_control(w, event);
  5690. break;
  5691. case SND_SOC_DAPM_POST_PMD:
  5692. tasha_codec_ldo_h_control(w, event);
  5693. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5694. break;
  5695. }
  5696. return 0;
  5697. }
  5698. static int tasha_codec_force_enable_micbias(struct snd_soc_dapm_widget *w,
  5699. struct snd_kcontrol *kcontrol,
  5700. int event)
  5701. {
  5702. int ret = 0;
  5703. struct snd_soc_component *component =
  5704. snd_soc_dapm_to_component(w->dapm);
  5705. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  5706. switch (event) {
  5707. case SND_SOC_DAPM_PRE_PMU:
  5708. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5709. tasha_cdc_mclk_enable(component, true, true);
  5710. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_PRE_PMU);
  5711. /* Wait for 1ms for better cnp */
  5712. usleep_range(1000, 1100);
  5713. tasha_cdc_mclk_enable(component, false, true);
  5714. break;
  5715. case SND_SOC_DAPM_POST_PMD:
  5716. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_POST_PMD);
  5717. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5718. break;
  5719. }
  5720. return ret;
  5721. }
  5722. static int tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5723. struct snd_kcontrol *kcontrol, int event)
  5724. {
  5725. return __tasha_codec_enable_micbias(w, event);
  5726. }
  5727. static int tasha_codec_enable_standalone_ldo_h(
  5728. struct snd_soc_component *component,
  5729. bool enable)
  5730. {
  5731. int rc;
  5732. if (enable)
  5733. rc = snd_soc_dapm_force_enable_pin(
  5734. snd_soc_component_get_dapm(component),
  5735. DAPM_LDO_H_STANDALONE);
  5736. else
  5737. rc = snd_soc_dapm_disable_pin(
  5738. snd_soc_component_get_dapm(component),
  5739. DAPM_LDO_H_STANDALONE);
  5740. if (!rc)
  5741. snd_soc_dapm_sync(snd_soc_component_get_dapm(component));
  5742. else
  5743. dev_err(component->dev, "%s: ldo_h force %s pin failed\n",
  5744. __func__, (enable ? "enable" : "disable"));
  5745. return rc;
  5746. }
  5747. /*
  5748. * tasha_codec_enable_standalone_micbias - enable micbias standalone
  5749. * @component: pointer to codec instance
  5750. * @micb_num: number of micbias to be enabled
  5751. * @enable: true to enable micbias or false to disable
  5752. *
  5753. * This function is used to enable micbias (1, 2, 3 or 4) during
  5754. * standalone independent of whether TX use-case is running or not
  5755. *
  5756. * Return: error code in case of failure or 0 for success
  5757. */
  5758. int tasha_codec_enable_standalone_micbias(struct snd_soc_component *component,
  5759. int micb_num,
  5760. bool enable)
  5761. {
  5762. const char * const micb_names[] = {
  5763. DAPM_MICBIAS1_STANDALONE, DAPM_MICBIAS2_STANDALONE,
  5764. DAPM_MICBIAS3_STANDALONE, DAPM_MICBIAS4_STANDALONE
  5765. };
  5766. int micb_index = micb_num - 1;
  5767. int rc;
  5768. if (!component) {
  5769. pr_err("%s: Component memory is NULL\n", __func__);
  5770. return -EINVAL;
  5771. }
  5772. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  5773. dev_err(component->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  5774. __func__, micb_index);
  5775. return -EINVAL;
  5776. }
  5777. if (enable)
  5778. rc = snd_soc_dapm_force_enable_pin(
  5779. snd_soc_component_get_dapm(component),
  5780. micb_names[micb_index]);
  5781. else
  5782. rc = snd_soc_dapm_disable_pin(
  5783. snd_soc_component_get_dapm(component),
  5784. micb_names[micb_index]);
  5785. if (!rc)
  5786. snd_soc_dapm_sync(snd_soc_component_get_dapm(component));
  5787. else
  5788. dev_err(component->dev, "%s: micbias%d force %s pin failed\n",
  5789. __func__, micb_num, (enable ? "enable" : "disable"));
  5790. return rc;
  5791. }
  5792. EXPORT_SYMBOL(tasha_codec_enable_standalone_micbias);
  5793. static const char *const tasha_anc_func_text[] = {"OFF", "ON"};
  5794. static const struct soc_enum tasha_anc_func_enum =
  5795. SOC_ENUM_SINGLE_EXT(2, tasha_anc_func_text);
  5796. static const char *const tasha_clkmode_text[] = {"EXTERNAL", "INTERNAL"};
  5797. static SOC_ENUM_SINGLE_EXT_DECL(tasha_clkmode_enum, tasha_clkmode_text);
  5798. /* Cutoff frequency for high pass filter */
  5799. static const char * const cf_text[] = {
  5800. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
  5801. };
  5802. static const char * const rx_cf_text[] = {
  5803. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ",
  5804. "CF_NEG_3DB_0P48HZ"
  5805. };
  5806. static const struct soc_enum cf_dec0_enum =
  5807. SOC_ENUM_SINGLE(WCD9335_CDC_TX0_TX_PATH_CFG0, 5, 3, cf_text);
  5808. static const struct soc_enum cf_dec1_enum =
  5809. SOC_ENUM_SINGLE(WCD9335_CDC_TX1_TX_PATH_CFG0, 5, 3, cf_text);
  5810. static const struct soc_enum cf_dec2_enum =
  5811. SOC_ENUM_SINGLE(WCD9335_CDC_TX2_TX_PATH_CFG0, 5, 3, cf_text);
  5812. static const struct soc_enum cf_dec3_enum =
  5813. SOC_ENUM_SINGLE(WCD9335_CDC_TX3_TX_PATH_CFG0, 5, 3, cf_text);
  5814. static const struct soc_enum cf_dec4_enum =
  5815. SOC_ENUM_SINGLE(WCD9335_CDC_TX4_TX_PATH_CFG0, 5, 3, cf_text);
  5816. static const struct soc_enum cf_dec5_enum =
  5817. SOC_ENUM_SINGLE(WCD9335_CDC_TX5_TX_PATH_CFG0, 5, 3, cf_text);
  5818. static const struct soc_enum cf_dec6_enum =
  5819. SOC_ENUM_SINGLE(WCD9335_CDC_TX6_TX_PATH_CFG0, 5, 3, cf_text);
  5820. static const struct soc_enum cf_dec7_enum =
  5821. SOC_ENUM_SINGLE(WCD9335_CDC_TX7_TX_PATH_CFG0, 5, 3, cf_text);
  5822. static const struct soc_enum cf_dec8_enum =
  5823. SOC_ENUM_SINGLE(WCD9335_CDC_TX8_TX_PATH_CFG0, 5, 3, cf_text);
  5824. static const struct soc_enum cf_int0_1_enum =
  5825. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5826. static SOC_ENUM_SINGLE_DECL(cf_int0_2_enum, WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 2,
  5827. rx_cf_text);
  5828. static const struct soc_enum cf_int1_1_enum =
  5829. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5830. static SOC_ENUM_SINGLE_DECL(cf_int1_2_enum, WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 2,
  5831. rx_cf_text);
  5832. static const struct soc_enum cf_int2_1_enum =
  5833. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5834. static SOC_ENUM_SINGLE_DECL(cf_int2_2_enum, WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 2,
  5835. rx_cf_text);
  5836. static const struct soc_enum cf_int3_1_enum =
  5837. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5838. static SOC_ENUM_SINGLE_DECL(cf_int3_2_enum, WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 2,
  5839. rx_cf_text);
  5840. static const struct soc_enum cf_int4_1_enum =
  5841. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5842. static SOC_ENUM_SINGLE_DECL(cf_int4_2_enum, WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 2,
  5843. rx_cf_text);
  5844. static const struct soc_enum cf_int5_1_enum =
  5845. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5846. static SOC_ENUM_SINGLE_DECL(cf_int5_2_enum, WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 2,
  5847. rx_cf_text);
  5848. static const struct soc_enum cf_int6_1_enum =
  5849. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5850. static SOC_ENUM_SINGLE_DECL(cf_int6_2_enum, WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 2,
  5851. rx_cf_text);
  5852. static const struct soc_enum cf_int7_1_enum =
  5853. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5854. static SOC_ENUM_SINGLE_DECL(cf_int7_2_enum, WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 2,
  5855. rx_cf_text);
  5856. static const struct soc_enum cf_int8_1_enum =
  5857. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5858. static SOC_ENUM_SINGLE_DECL(cf_int8_2_enum, WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 2,
  5859. rx_cf_text);
  5860. static const struct snd_soc_dapm_route audio_i2s_map[] = {
  5861. {"SLIM RX0 MUX", NULL, "RX_I2S_CTL"},
  5862. {"SLIM RX1 MUX", NULL, "RX_I2S_CTL"},
  5863. {"SLIM RX2 MUX", NULL, "RX_I2S_CTL"},
  5864. {"SLIM RX3 MUX", NULL, "RX_I2S_CTL"},
  5865. {"SLIM TX6 MUX", NULL, "TX_I2S_CTL"},
  5866. {"SLIM TX7 MUX", NULL, "TX_I2S_CTL"},
  5867. {"SLIM TX8 MUX", NULL, "TX_I2S_CTL"},
  5868. {"SLIM TX11 MUX", NULL, "TX_I2S_CTL"},
  5869. };
  5870. static const struct snd_soc_dapm_route audio_map[] = {
  5871. /* MAD */
  5872. {"MAD_SEL MUX", "SPE", "MAD_CPE_INPUT"},
  5873. {"MAD_SEL MUX", "MSM", "MADINPUT"},
  5874. {"MADONOFF", "Switch", "MAD_SEL MUX"},
  5875. {"MAD_BROADCAST", "Switch", "MAD_SEL MUX"},
  5876. {"TX13 INP MUX", "CPE_TX_PP", "MADONOFF"},
  5877. /* CPE HW MAD bypass */
  5878. {"CPE IN Mixer", "MAD_BYPASS", "SLIM TX1 MUX"},
  5879. {"AIF4_MAD Mixer", "SLIM TX1", "CPE IN Mixer"},
  5880. {"AIF4_MAD Mixer", "SLIM TX12", "MADONOFF"},
  5881. {"AIF4_MAD Mixer", "SLIM TX13", "TX13 INP MUX"},
  5882. {"AIF4 MAD", NULL, "AIF4_MAD Mixer"},
  5883. {"AIF4 MAD", NULL, "AIF4"},
  5884. {"EC BUF MUX INP", "DEC1", "ADC MUX1"},
  5885. {"AIF5 CPE", NULL, "EC BUF MUX INP"},
  5886. /* SLIMBUS Connections */
  5887. {"AIF1 CAP", NULL, "AIF1_CAP Mixer"},
  5888. {"AIF2 CAP", NULL, "AIF2_CAP Mixer"},
  5889. {"AIF3 CAP", NULL, "AIF3_CAP Mixer"},
  5890. /* VI Feedback */
  5891. {"AIF4_VI Mixer", "SPKR_VI_1", "VIINPUT"},
  5892. {"AIF4_VI Mixer", "SPKR_VI_2", "VIINPUT"},
  5893. {"AIF4 VI", NULL, "AIF4_VI Mixer"},
  5894. /* SLIM_MIXER("AIF1_CAP Mixer"),*/
  5895. {"AIF1_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5896. {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5897. {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5898. {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5899. {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5900. {"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5901. {"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5902. {"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5903. {"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5904. {"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5905. {"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5906. {"AIF1_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5907. {"AIF1_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5908. /* SLIM_MIXER("AIF2_CAP Mixer"),*/
  5909. {"AIF2_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5910. {"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5911. {"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5912. {"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5913. {"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5914. {"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5915. {"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5916. {"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5917. {"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5918. {"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5919. {"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5920. {"AIF2_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5921. {"AIF2_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5922. /* SLIM_MIXER("AIF3_CAP Mixer"),*/
  5923. {"AIF3_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5924. {"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5925. {"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5926. {"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5927. {"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5928. {"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5929. {"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5930. {"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5931. {"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5932. {"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5933. {"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5934. {"AIF3_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5935. {"AIF3_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5936. {"SLIM TX0 MUX", "DEC0", "ADC MUX0"},
  5937. {"SLIM TX0 MUX", "RX_MIX_TX0", "RX MIX TX0 MUX"},
  5938. {"SLIM TX0 MUX", "DEC0_192", "ADC US MUX0"},
  5939. {"SLIM TX1 MUX", "DEC1", "ADC MUX1"},
  5940. {"SLIM TX1 MUX", "RX_MIX_TX1", "RX MIX TX1 MUX"},
  5941. {"SLIM TX1 MUX", "DEC1_192", "ADC US MUX1"},
  5942. {"SLIM TX2 MUX", "DEC2", "ADC MUX2"},
  5943. {"SLIM TX2 MUX", "RX_MIX_TX2", "RX MIX TX2 MUX"},
  5944. {"SLIM TX2 MUX", "DEC2_192", "ADC US MUX2"},
  5945. {"SLIM TX3 MUX", "DEC3", "ADC MUX3"},
  5946. {"SLIM TX3 MUX", "RX_MIX_TX3", "RX MIX TX3 MUX"},
  5947. {"SLIM TX3 MUX", "DEC3_192", "ADC US MUX3"},
  5948. {"SLIM TX4 MUX", "DEC4", "ADC MUX4"},
  5949. {"SLIM TX4 MUX", "RX_MIX_TX4", "RX MIX TX4 MUX"},
  5950. {"SLIM TX4 MUX", "DEC4_192", "ADC US MUX4"},
  5951. {"SLIM TX5 MUX", "DEC5", "ADC MUX5"},
  5952. {"SLIM TX5 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5953. {"SLIM TX5 MUX", "DEC5_192", "ADC US MUX5"},
  5954. {"SLIM TX6 MUX", "DEC6", "ADC MUX6"},
  5955. {"SLIM TX6 MUX", "RX_MIX_TX6", "RX MIX TX6 MUX"},
  5956. {"SLIM TX6 MUX", "DEC6_192", "ADC US MUX6"},
  5957. {"SLIM TX7 MUX", "DEC7", "ADC MUX7"},
  5958. {"SLIM TX7 MUX", "RX_MIX_TX7", "RX MIX TX7 MUX"},
  5959. {"SLIM TX7 MUX", "DEC7_192", "ADC US MUX7"},
  5960. {"SLIM TX8 MUX", "DEC8", "ADC MUX8"},
  5961. {"SLIM TX8 MUX", "RX_MIX_TX8", "RX MIX TX8 MUX"},
  5962. {"SLIM TX8 MUX", "DEC8_192", "ADC US MUX8"},
  5963. {"SLIM TX9 MUX", "DEC7", "ADC MUX7"},
  5964. {"SLIM TX9 MUX", "DEC7_192", "ADC US MUX7"},
  5965. {"SLIM TX10 MUX", "DEC6", "ADC MUX6"},
  5966. {"SLIM TX10 MUX", "DEC6_192", "ADC US MUX6"},
  5967. {"SLIM TX11 MUX", "DEC_0_5", "SLIM TX11 INP1 MUX"},
  5968. {"SLIM TX11 MUX", "DEC_9_12", "SLIM TX11 INP1 MUX"},
  5969. {"SLIM TX11 INP1 MUX", "DEC0", "ADC MUX0"},
  5970. {"SLIM TX11 INP1 MUX", "DEC1", "ADC MUX1"},
  5971. {"SLIM TX11 INP1 MUX", "DEC2", "ADC MUX2"},
  5972. {"SLIM TX11 INP1 MUX", "DEC3", "ADC MUX3"},
  5973. {"SLIM TX11 INP1 MUX", "DEC4", "ADC MUX4"},
  5974. {"SLIM TX11 INP1 MUX", "DEC5", "ADC MUX5"},
  5975. {"SLIM TX11 INP1 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5976. {"TX13 INP MUX", "MAD_BRDCST", "MAD_BROADCAST"},
  5977. {"TX13 INP MUX", "CDC_DEC_5", "SLIM TX13 MUX"},
  5978. {"SLIM TX13 MUX", "DEC5", "ADC MUX5"},
  5979. {"RX MIX TX0 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5980. {"RX MIX TX0 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5981. {"RX MIX TX0 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5982. {"RX MIX TX0 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5983. {"RX MIX TX0 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5984. {"RX MIX TX0 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5985. {"RX MIX TX0 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5986. {"RX MIX TX0 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5987. {"RX MIX TX0 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5988. {"RX MIX TX0 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5989. {"RX MIX TX0 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5990. {"RX MIX TX0 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5991. {"RX MIX TX0 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5992. {"RX MIX TX1 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5993. {"RX MIX TX1 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5994. {"RX MIX TX1 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5995. {"RX MIX TX1 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5996. {"RX MIX TX1 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5997. {"RX MIX TX1 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5998. {"RX MIX TX1 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5999. {"RX MIX TX1 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  6000. {"RX MIX TX1 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  6001. {"RX MIX TX1 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  6002. {"RX MIX TX1 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  6003. {"RX MIX TX1 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  6004. {"RX MIX TX1 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  6005. {"RX MIX TX2 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  6006. {"RX MIX TX2 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  6007. {"RX MIX TX2 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  6008. {"RX MIX TX2 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  6009. {"RX MIX TX2 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  6010. {"RX MIX TX2 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  6011. {"RX MIX TX2 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  6012. {"RX MIX TX2 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  6013. {"RX MIX TX2 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  6014. {"RX MIX TX2 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  6015. {"RX MIX TX2 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  6016. {"RX MIX TX2 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  6017. {"RX MIX TX2 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  6018. {"RX MIX TX3 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  6019. {"RX MIX TX3 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  6020. {"RX MIX TX3 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  6021. {"RX MIX TX3 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  6022. {"RX MIX TX3 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  6023. {"RX MIX TX3 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  6024. {"RX MIX TX3 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  6025. {"RX MIX TX3 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  6026. {"RX MIX TX3 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  6027. {"RX MIX TX3 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  6028. {"RX MIX TX3 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  6029. {"RX MIX TX3 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  6030. {"RX MIX TX3 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  6031. {"RX MIX TX4 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  6032. {"RX MIX TX4 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  6033. {"RX MIX TX4 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  6034. {"RX MIX TX4 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  6035. {"RX MIX TX4 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  6036. {"RX MIX TX4 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  6037. {"RX MIX TX4 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  6038. {"RX MIX TX4 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  6039. {"RX MIX TX4 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  6040. {"RX MIX TX4 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  6041. {"RX MIX TX4 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  6042. {"RX MIX TX4 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  6043. {"RX MIX TX4 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  6044. {"RX MIX TX5 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  6045. {"RX MIX TX5 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  6046. {"RX MIX TX5 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  6047. {"RX MIX TX5 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  6048. {"RX MIX TX5 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  6049. {"RX MIX TX5 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  6050. {"RX MIX TX5 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  6051. {"RX MIX TX5 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  6052. {"RX MIX TX5 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  6053. {"RX MIX TX5 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  6054. {"RX MIX TX5 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  6055. {"RX MIX TX5 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  6056. {"RX MIX TX5 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  6057. {"RX MIX TX6 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  6058. {"RX MIX TX6 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  6059. {"RX MIX TX6 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  6060. {"RX MIX TX6 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  6061. {"RX MIX TX6 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  6062. {"RX MIX TX6 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  6063. {"RX MIX TX6 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  6064. {"RX MIX TX6 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  6065. {"RX MIX TX6 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  6066. {"RX MIX TX6 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  6067. {"RX MIX TX6 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  6068. {"RX MIX TX6 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  6069. {"RX MIX TX6 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  6070. {"RX MIX TX7 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  6071. {"RX MIX TX7 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  6072. {"RX MIX TX7 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  6073. {"RX MIX TX7 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  6074. {"RX MIX TX7 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  6075. {"RX MIX TX7 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  6076. {"RX MIX TX7 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  6077. {"RX MIX TX7 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  6078. {"RX MIX TX7 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  6079. {"RX MIX TX7 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  6080. {"RX MIX TX7 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  6081. {"RX MIX TX7 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  6082. {"RX MIX TX7 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  6083. {"RX MIX TX8 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  6084. {"RX MIX TX8 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  6085. {"RX MIX TX8 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  6086. {"RX MIX TX8 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  6087. {"RX MIX TX8 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  6088. {"RX MIX TX8 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  6089. {"RX MIX TX8 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  6090. {"RX MIX TX8 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  6091. {"RX MIX TX8 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  6092. {"RX MIX TX8 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  6093. {"RX MIX TX8 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  6094. {"RX MIX TX8 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  6095. {"RX MIX TX8 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  6096. {"ADC US MUX0", "US_Switch", "ADC MUX0"},
  6097. {"ADC US MUX1", "US_Switch", "ADC MUX1"},
  6098. {"ADC US MUX2", "US_Switch", "ADC MUX2"},
  6099. {"ADC US MUX3", "US_Switch", "ADC MUX3"},
  6100. {"ADC US MUX4", "US_Switch", "ADC MUX4"},
  6101. {"ADC US MUX5", "US_Switch", "ADC MUX5"},
  6102. {"ADC US MUX6", "US_Switch", "ADC MUX6"},
  6103. {"ADC US MUX7", "US_Switch", "ADC MUX7"},
  6104. {"ADC US MUX8", "US_Switch", "ADC MUX8"},
  6105. {"ADC MUX0", "DMIC", "DMIC MUX0"},
  6106. {"ADC MUX0", "AMIC", "AMIC MUX0"},
  6107. {"ADC MUX1", "DMIC", "DMIC MUX1"},
  6108. {"ADC MUX1", "AMIC", "AMIC MUX1"},
  6109. {"ADC MUX2", "DMIC", "DMIC MUX2"},
  6110. {"ADC MUX2", "AMIC", "AMIC MUX2"},
  6111. {"ADC MUX3", "DMIC", "DMIC MUX3"},
  6112. {"ADC MUX3", "AMIC", "AMIC MUX3"},
  6113. {"ADC MUX4", "DMIC", "DMIC MUX4"},
  6114. {"ADC MUX4", "AMIC", "AMIC MUX4"},
  6115. {"ADC MUX5", "DMIC", "DMIC MUX5"},
  6116. {"ADC MUX5", "AMIC", "AMIC MUX5"},
  6117. {"ADC MUX6", "DMIC", "DMIC MUX6"},
  6118. {"ADC MUX6", "AMIC", "AMIC MUX6"},
  6119. {"ADC MUX7", "DMIC", "DMIC MUX7"},
  6120. {"ADC MUX7", "AMIC", "AMIC MUX7"},
  6121. {"ADC MUX8", "DMIC", "DMIC MUX8"},
  6122. {"ADC MUX8", "AMIC", "AMIC MUX8"},
  6123. {"ADC MUX10", "DMIC", "DMIC MUX10"},
  6124. {"ADC MUX10", "AMIC", "AMIC MUX10"},
  6125. {"ADC MUX11", "DMIC", "DMIC MUX11"},
  6126. {"ADC MUX11", "AMIC", "AMIC MUX11"},
  6127. {"ADC MUX12", "DMIC", "DMIC MUX12"},
  6128. {"ADC MUX12", "AMIC", "AMIC MUX12"},
  6129. {"ADC MUX13", "DMIC", "DMIC MUX13"},
  6130. {"ADC MUX13", "AMIC", "AMIC MUX13"},
  6131. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX10"},
  6132. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX11"},
  6133. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX12"},
  6134. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX13"},
  6135. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX10"},
  6136. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX11"},
  6137. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX12"},
  6138. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX13"},
  6139. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX10"},
  6140. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX11"},
  6141. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX12"},
  6142. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX13"},
  6143. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX10"},
  6144. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX11"},
  6145. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX12"},
  6146. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX13"},
  6147. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX10"},
  6148. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX11"},
  6149. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX12"},
  6150. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX13"},
  6151. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX10"},
  6152. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX11"},
  6153. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX12"},
  6154. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX13"},
  6155. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX10"},
  6156. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX11"},
  6157. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX12"},
  6158. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX13"},
  6159. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX10"},
  6160. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX11"},
  6161. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX12"},
  6162. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX13"},
  6163. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX10"},
  6164. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX11"},
  6165. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX12"},
  6166. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX13"},
  6167. {"DMIC MUX0", "DMIC0", "DMIC0"},
  6168. {"DMIC MUX0", "DMIC1", "DMIC1"},
  6169. {"DMIC MUX0", "DMIC2", "DMIC2"},
  6170. {"DMIC MUX0", "DMIC3", "DMIC3"},
  6171. {"DMIC MUX0", "DMIC4", "DMIC4"},
  6172. {"DMIC MUX0", "DMIC5", "DMIC5"},
  6173. {"AMIC MUX0", "ADC1", "ADC1"},
  6174. {"AMIC MUX0", "ADC2", "ADC2"},
  6175. {"AMIC MUX0", "ADC3", "ADC3"},
  6176. {"AMIC MUX0", "ADC4", "ADC4"},
  6177. {"AMIC MUX0", "ADC5", "ADC5"},
  6178. {"AMIC MUX0", "ADC6", "ADC6"},
  6179. {"DMIC MUX1", "DMIC0", "DMIC0"},
  6180. {"DMIC MUX1", "DMIC1", "DMIC1"},
  6181. {"DMIC MUX1", "DMIC2", "DMIC2"},
  6182. {"DMIC MUX1", "DMIC3", "DMIC3"},
  6183. {"DMIC MUX1", "DMIC4", "DMIC4"},
  6184. {"DMIC MUX1", "DMIC5", "DMIC5"},
  6185. {"AMIC MUX1", "ADC1", "ADC1"},
  6186. {"AMIC MUX1", "ADC2", "ADC2"},
  6187. {"AMIC MUX1", "ADC3", "ADC3"},
  6188. {"AMIC MUX1", "ADC4", "ADC4"},
  6189. {"AMIC MUX1", "ADC5", "ADC5"},
  6190. {"AMIC MUX1", "ADC6", "ADC6"},
  6191. {"DMIC MUX2", "DMIC0", "DMIC0"},
  6192. {"DMIC MUX2", "DMIC1", "DMIC1"},
  6193. {"DMIC MUX2", "DMIC2", "DMIC2"},
  6194. {"DMIC MUX2", "DMIC3", "DMIC3"},
  6195. {"DMIC MUX2", "DMIC4", "DMIC4"},
  6196. {"DMIC MUX2", "DMIC5", "DMIC5"},
  6197. {"AMIC MUX2", "ADC1", "ADC1"},
  6198. {"AMIC MUX2", "ADC2", "ADC2"},
  6199. {"AMIC MUX2", "ADC3", "ADC3"},
  6200. {"AMIC MUX2", "ADC4", "ADC4"},
  6201. {"AMIC MUX2", "ADC5", "ADC5"},
  6202. {"AMIC MUX2", "ADC6", "ADC6"},
  6203. {"DMIC MUX3", "DMIC0", "DMIC0"},
  6204. {"DMIC MUX3", "DMIC1", "DMIC1"},
  6205. {"DMIC MUX3", "DMIC2", "DMIC2"},
  6206. {"DMIC MUX3", "DMIC3", "DMIC3"},
  6207. {"DMIC MUX3", "DMIC4", "DMIC4"},
  6208. {"DMIC MUX3", "DMIC5", "DMIC5"},
  6209. {"AMIC MUX3", "ADC1", "ADC1"},
  6210. {"AMIC MUX3", "ADC2", "ADC2"},
  6211. {"AMIC MUX3", "ADC3", "ADC3"},
  6212. {"AMIC MUX3", "ADC4", "ADC4"},
  6213. {"AMIC MUX3", "ADC5", "ADC5"},
  6214. {"AMIC MUX3", "ADC6", "ADC6"},
  6215. {"DMIC MUX4", "DMIC0", "DMIC0"},
  6216. {"DMIC MUX4", "DMIC1", "DMIC1"},
  6217. {"DMIC MUX4", "DMIC2", "DMIC2"},
  6218. {"DMIC MUX4", "DMIC3", "DMIC3"},
  6219. {"DMIC MUX4", "DMIC4", "DMIC4"},
  6220. {"DMIC MUX4", "DMIC5", "DMIC5"},
  6221. {"AMIC MUX4", "ADC1", "ADC1"},
  6222. {"AMIC MUX4", "ADC2", "ADC2"},
  6223. {"AMIC MUX4", "ADC3", "ADC3"},
  6224. {"AMIC MUX4", "ADC4", "ADC4"},
  6225. {"AMIC MUX4", "ADC5", "ADC5"},
  6226. {"AMIC MUX4", "ADC6", "ADC6"},
  6227. {"DMIC MUX5", "DMIC0", "DMIC0"},
  6228. {"DMIC MUX5", "DMIC1", "DMIC1"},
  6229. {"DMIC MUX5", "DMIC2", "DMIC2"},
  6230. {"DMIC MUX5", "DMIC3", "DMIC3"},
  6231. {"DMIC MUX5", "DMIC4", "DMIC4"},
  6232. {"DMIC MUX5", "DMIC5", "DMIC5"},
  6233. {"AMIC MUX5", "ADC1", "ADC1"},
  6234. {"AMIC MUX5", "ADC2", "ADC2"},
  6235. {"AMIC MUX5", "ADC3", "ADC3"},
  6236. {"AMIC MUX5", "ADC4", "ADC4"},
  6237. {"AMIC MUX5", "ADC5", "ADC5"},
  6238. {"AMIC MUX5", "ADC6", "ADC6"},
  6239. {"DMIC MUX6", "DMIC0", "DMIC0"},
  6240. {"DMIC MUX6", "DMIC1", "DMIC1"},
  6241. {"DMIC MUX6", "DMIC2", "DMIC2"},
  6242. {"DMIC MUX6", "DMIC3", "DMIC3"},
  6243. {"DMIC MUX6", "DMIC4", "DMIC4"},
  6244. {"DMIC MUX6", "DMIC5", "DMIC5"},
  6245. {"AMIC MUX6", "ADC1", "ADC1"},
  6246. {"AMIC MUX6", "ADC2", "ADC2"},
  6247. {"AMIC MUX6", "ADC3", "ADC3"},
  6248. {"AMIC MUX6", "ADC4", "ADC4"},
  6249. {"AMIC MUX6", "ADC5", "ADC5"},
  6250. {"AMIC MUX6", "ADC6", "ADC6"},
  6251. {"DMIC MUX7", "DMIC0", "DMIC0"},
  6252. {"DMIC MUX7", "DMIC1", "DMIC1"},
  6253. {"DMIC MUX7", "DMIC2", "DMIC2"},
  6254. {"DMIC MUX7", "DMIC3", "DMIC3"},
  6255. {"DMIC MUX7", "DMIC4", "DMIC4"},
  6256. {"DMIC MUX7", "DMIC5", "DMIC5"},
  6257. {"AMIC MUX7", "ADC1", "ADC1"},
  6258. {"AMIC MUX7", "ADC2", "ADC2"},
  6259. {"AMIC MUX7", "ADC3", "ADC3"},
  6260. {"AMIC MUX7", "ADC4", "ADC4"},
  6261. {"AMIC MUX7", "ADC5", "ADC5"},
  6262. {"AMIC MUX7", "ADC6", "ADC6"},
  6263. {"DMIC MUX8", "DMIC0", "DMIC0"},
  6264. {"DMIC MUX8", "DMIC1", "DMIC1"},
  6265. {"DMIC MUX8", "DMIC2", "DMIC2"},
  6266. {"DMIC MUX8", "DMIC3", "DMIC3"},
  6267. {"DMIC MUX8", "DMIC4", "DMIC4"},
  6268. {"DMIC MUX8", "DMIC5", "DMIC5"},
  6269. {"AMIC MUX8", "ADC1", "ADC1"},
  6270. {"AMIC MUX8", "ADC2", "ADC2"},
  6271. {"AMIC MUX8", "ADC3", "ADC3"},
  6272. {"AMIC MUX8", "ADC4", "ADC4"},
  6273. {"AMIC MUX8", "ADC5", "ADC5"},
  6274. {"AMIC MUX8", "ADC6", "ADC6"},
  6275. {"DMIC MUX10", "DMIC0", "DMIC0"},
  6276. {"DMIC MUX10", "DMIC1", "DMIC1"},
  6277. {"DMIC MUX10", "DMIC2", "DMIC2"},
  6278. {"DMIC MUX10", "DMIC3", "DMIC3"},
  6279. {"DMIC MUX10", "DMIC4", "DMIC4"},
  6280. {"DMIC MUX10", "DMIC5", "DMIC5"},
  6281. {"AMIC MUX10", "ADC1", "ADC1"},
  6282. {"AMIC MUX10", "ADC2", "ADC2"},
  6283. {"AMIC MUX10", "ADC3", "ADC3"},
  6284. {"AMIC MUX10", "ADC4", "ADC4"},
  6285. {"AMIC MUX10", "ADC5", "ADC5"},
  6286. {"AMIC MUX10", "ADC6", "ADC6"},
  6287. {"DMIC MUX11", "DMIC0", "DMIC0"},
  6288. {"DMIC MUX11", "DMIC1", "DMIC1"},
  6289. {"DMIC MUX11", "DMIC2", "DMIC2"},
  6290. {"DMIC MUX11", "DMIC3", "DMIC3"},
  6291. {"DMIC MUX11", "DMIC4", "DMIC4"},
  6292. {"DMIC MUX11", "DMIC5", "DMIC5"},
  6293. {"AMIC MUX11", "ADC1", "ADC1"},
  6294. {"AMIC MUX11", "ADC2", "ADC2"},
  6295. {"AMIC MUX11", "ADC3", "ADC3"},
  6296. {"AMIC MUX11", "ADC4", "ADC4"},
  6297. {"AMIC MUX11", "ADC5", "ADC5"},
  6298. {"AMIC MUX11", "ADC6", "ADC6"},
  6299. {"DMIC MUX12", "DMIC0", "DMIC0"},
  6300. {"DMIC MUX12", "DMIC1", "DMIC1"},
  6301. {"DMIC MUX12", "DMIC2", "DMIC2"},
  6302. {"DMIC MUX12", "DMIC3", "DMIC3"},
  6303. {"DMIC MUX12", "DMIC4", "DMIC4"},
  6304. {"DMIC MUX12", "DMIC5", "DMIC5"},
  6305. {"AMIC MUX12", "ADC1", "ADC1"},
  6306. {"AMIC MUX12", "ADC2", "ADC2"},
  6307. {"AMIC MUX12", "ADC3", "ADC3"},
  6308. {"AMIC MUX12", "ADC4", "ADC4"},
  6309. {"AMIC MUX12", "ADC5", "ADC5"},
  6310. {"AMIC MUX12", "ADC6", "ADC6"},
  6311. {"DMIC MUX13", "DMIC0", "DMIC0"},
  6312. {"DMIC MUX13", "DMIC1", "DMIC1"},
  6313. {"DMIC MUX13", "DMIC2", "DMIC2"},
  6314. {"DMIC MUX13", "DMIC3", "DMIC3"},
  6315. {"DMIC MUX13", "DMIC4", "DMIC4"},
  6316. {"DMIC MUX13", "DMIC5", "DMIC5"},
  6317. {"AMIC MUX13", "ADC1", "ADC1"},
  6318. {"AMIC MUX13", "ADC2", "ADC2"},
  6319. {"AMIC MUX13", "ADC3", "ADC3"},
  6320. {"AMIC MUX13", "ADC4", "ADC4"},
  6321. {"AMIC MUX13", "ADC5", "ADC5"},
  6322. {"AMIC MUX13", "ADC6", "ADC6"},
  6323. /* ADC Connections */
  6324. {"ADC1", NULL, "AMIC1"},
  6325. {"ADC2", NULL, "AMIC2"},
  6326. {"ADC3", NULL, "AMIC3"},
  6327. {"ADC4", NULL, "AMIC4"},
  6328. {"ADC5", NULL, "AMIC5"},
  6329. {"ADC6", NULL, "AMIC6"},
  6330. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP0"},
  6331. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP1"},
  6332. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP2"},
  6333. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP0"},
  6334. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP1"},
  6335. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP2"},
  6336. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP0"},
  6337. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP1"},
  6338. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP2"},
  6339. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP0"},
  6340. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP1"},
  6341. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP2"},
  6342. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP0"},
  6343. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP1"},
  6344. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP2"},
  6345. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP0"},
  6346. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP1"},
  6347. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP2"},
  6348. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP0"},
  6349. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP1"},
  6350. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP2"},
  6351. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP0"},
  6352. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP1"},
  6353. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP2"},
  6354. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP0"},
  6355. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP1"},
  6356. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP2"},
  6357. {"RX INT0 SEC MIX", NULL, "RX INT0_1 MIX1"},
  6358. {"RX INT0 MIX2", NULL, "RX INT0 SEC MIX"},
  6359. {"RX INT0 MIX2", NULL, "RX INT0 MIX2 INP"},
  6360. {"RX INT0 INTERP", NULL, "RX INT0 MIX2"},
  6361. {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 INTERP"},
  6362. {"RX INT0 DAC", NULL, "RX INT0 DEM MUX"},
  6363. {"RX INT0 DAC", NULL, "RX_BIAS"},
  6364. {"EAR PA", NULL, "RX INT0 DAC"},
  6365. {"EAR", NULL, "EAR PA"},
  6366. {"SPL SRC0 MUX", "SRC_IN_HPHL", "RX INT1_1 MIX1"},
  6367. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 MIX1"},
  6368. {"RX INT1 SPLINE MIX", "HPHL Switch", "SPL SRC0 MUX"},
  6369. {"RX INT1_1 NATIVE MUX", "ON", "RX INT1_1 MIX1"},
  6370. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 NATIVE MUX"},
  6371. {"RX INT1_1 NATIVE MUX", NULL, "RX INT1 NATIVE SUPPLY"},
  6372. {"RX INT1 SEC MIX", NULL, "RX INT1 SPLINE MIX"},
  6373. {"RX INT1 MIX2", NULL, "RX INT1 SEC MIX"},
  6374. {"RX INT1 MIX2", NULL, "RX INT1 MIX2 INP"},
  6375. {"RX INT1 INTERP", NULL, "RX INT1 MIX2"},
  6376. {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 INTERP"},
  6377. {"RX INT1 DAC", NULL, "RX INT1 DEM MUX"},
  6378. {"RX INT1 DAC", NULL, "RX_BIAS"},
  6379. {"HPHL PA", NULL, "RX INT1 DAC"},
  6380. {"HPHL", NULL, "HPHL PA"},
  6381. {"SPL SRC1 MUX", "SRC_IN_HPHR", "RX INT2_1 MIX1"},
  6382. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 MIX1"},
  6383. {"RX INT2 SPLINE MIX", "HPHR Switch", "SPL SRC1 MUX"},
  6384. {"RX INT2_1 NATIVE MUX", "ON", "RX INT2_1 MIX1"},
  6385. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 NATIVE MUX"},
  6386. {"RX INT2_1 NATIVE MUX", NULL, "RX INT2 NATIVE SUPPLY"},
  6387. {"RX INT2 SEC MIX", NULL, "RX INT2 SPLINE MIX"},
  6388. {"RX INT2 MIX2", NULL, "RX INT2 SEC MIX"},
  6389. {"RX INT2 MIX2", NULL, "RX INT2 MIX2 INP"},
  6390. {"RX INT2 INTERP", NULL, "RX INT2 MIX2"},
  6391. {"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 INTERP"},
  6392. {"RX INT2 DAC", NULL, "RX INT2 DEM MUX"},
  6393. {"RX INT2 DAC", NULL, "RX_BIAS"},
  6394. {"HPHR PA", NULL, "RX INT2 DAC"},
  6395. {"HPHR", NULL, "HPHR PA"},
  6396. {"SPL SRC0 MUX", "SRC_IN_LO1", "RX INT3_1 MIX1"},
  6397. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 MIX1"},
  6398. {"RX INT3 SPLINE MIX", "LO1 Switch", "SPL SRC0 MUX"},
  6399. {"RX INT3_1 NATIVE MUX", "ON", "RX INT3_1 MIX1"},
  6400. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 NATIVE MUX"},
  6401. {"RX INT3_1 NATIVE MUX", NULL, "RX INT3 NATIVE SUPPLY"},
  6402. {"RX INT3 SEC MIX", NULL, "RX INT3 SPLINE MIX"},
  6403. {"RX INT3 MIX2", NULL, "RX INT3 SEC MIX"},
  6404. {"RX INT3 MIX2", NULL, "RX INT3 MIX2 INP"},
  6405. {"RX INT3 INTERP", NULL, "RX INT3 MIX2"},
  6406. {"RX INT3 DAC", NULL, "RX INT3 INTERP"},
  6407. {"RX INT3 DAC", NULL, "RX_BIAS"},
  6408. {"LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6409. {"LINEOUT1", NULL, "LINEOUT1 PA"},
  6410. {"SPL SRC1 MUX", "SRC_IN_LO2", "RX INT4_1 MIX1"},
  6411. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 MIX1"},
  6412. {"RX INT4 SPLINE MIX", "LO2 Switch", "SPL SRC1 MUX"},
  6413. {"RX INT4_1 NATIVE MUX", "ON", "RX INT4_1 MIX1"},
  6414. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 NATIVE MUX"},
  6415. {"RX INT4_1 NATIVE MUX", NULL, "RX INT4 NATIVE SUPPLY"},
  6416. {"RX INT4 SEC MIX", NULL, "RX INT4 SPLINE MIX"},
  6417. {"RX INT4 MIX2", NULL, "RX INT4 SEC MIX"},
  6418. {"RX INT4 MIX2", NULL, "RX INT4 MIX2 INP"},
  6419. {"RX INT4 INTERP", NULL, "RX INT4 MIX2"},
  6420. {"RX INT4 DAC", NULL, "RX INT4 INTERP"},
  6421. {"RX INT4 DAC", NULL, "RX_BIAS"},
  6422. {"LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6423. {"LINEOUT2", NULL, "LINEOUT2 PA"},
  6424. {"SPL SRC2 MUX", "SRC_IN_LO3", "RX INT5_1 MIX1"},
  6425. {"RX INT5 SPLINE MIX", NULL, "RX INT5_1 MIX1"},
  6426. {"RX INT5 SPLINE MIX", "LO3 Switch", "SPL SRC2 MUX"},
  6427. {"RX INT5 SEC MIX", NULL, "RX INT5 SPLINE MIX"},
  6428. {"RX INT5 MIX2", NULL, "RX INT5 SEC MIX"},
  6429. {"RX INT5 INTERP", NULL, "RX INT5 MIX2"},
  6430. {"RX INT5 VBAT", "LO3 VBAT Enable", "RX INT5 INTERP"},
  6431. {"RX INT5 DAC", NULL, "RX INT5 VBAT"},
  6432. {"RX INT5 DAC", NULL, "RX INT5 INTERP"},
  6433. {"RX INT5 DAC", NULL, "RX_BIAS"},
  6434. {"LINEOUT3 PA", NULL, "RX INT5 DAC"},
  6435. {"LINEOUT3", NULL, "LINEOUT3 PA"},
  6436. {"SPL SRC3 MUX", "SRC_IN_LO4", "RX INT6_1 MIX1"},
  6437. {"RX INT6 SPLINE MIX", NULL, "RX INT6_1 MIX1"},
  6438. {"RX INT6 SPLINE MIX", "LO4 Switch", "SPL SRC3 MUX"},
  6439. {"RX INT6 SEC MIX", NULL, "RX INT6 SPLINE MIX"},
  6440. {"RX INT6 MIX2", NULL, "RX INT6 SEC MIX"},
  6441. {"RX INT6 INTERP", NULL, "RX INT6 MIX2"},
  6442. {"RX INT6 VBAT", "LO4 VBAT Enable", "RX INT6 INTERP"},
  6443. {"RX INT6 DAC", NULL, "RX INT6 VBAT"},
  6444. {"RX INT6 DAC", NULL, "RX INT6 INTERP"},
  6445. {"RX INT6 DAC", NULL, "RX_BIAS"},
  6446. {"LINEOUT4 PA", NULL, "RX INT6 DAC"},
  6447. {"LINEOUT4", NULL, "LINEOUT4 PA"},
  6448. {"SPL SRC2 MUX", "SRC_IN_SPKRL", "RX INT7_1 MIX1"},
  6449. {"RX INT7 SPLINE MIX", NULL, "RX INT7_1 MIX1"},
  6450. {"RX INT7 SPLINE MIX", "SPKRL Switch", "SPL SRC2 MUX"},
  6451. {"RX INT7 SEC MIX", NULL, "RX INT7 SPLINE MIX"},
  6452. {"RX INT7 MIX2", NULL, "RX INT7 SEC MIX"},
  6453. {"RX INT7 MIX2", NULL, "RX INT7 MIX2 INP"},
  6454. {"RX INT7 INTERP", NULL, "RX INT7 MIX2"},
  6455. {"RX INT7 VBAT", "SPKRL VBAT Enable", "RX INT7 INTERP"},
  6456. {"RX INT7 CHAIN", NULL, "RX INT7 VBAT"},
  6457. {"RX INT7 CHAIN", NULL, "RX INT7 INTERP"},
  6458. {"RX INT7 CHAIN", NULL, "RX_BIAS"},
  6459. {"SPK1 OUT", NULL, "RX INT7 CHAIN"},
  6460. {"ANC SPKR PA Enable", "Switch", "RX INT7 CHAIN"},
  6461. {"ANC SPK1 PA", NULL, "ANC SPKR PA Enable"},
  6462. {"SPK1 OUT", NULL, "ANC SPK1 PA"},
  6463. {"SPL SRC3 MUX", "SRC_IN_SPKRR", "RX INT8_1 MIX1"},
  6464. {"RX INT8 SPLINE MIX", NULL, "RX INT8_1 MIX1"},
  6465. {"RX INT8 SPLINE MIX", "SPKRR Switch", "SPL SRC3 MUX"},
  6466. {"RX INT8 SEC MIX", NULL, "RX INT8 SPLINE MIX"},
  6467. {"RX INT8 INTERP", NULL, "RX INT8 SEC MIX"},
  6468. {"RX INT8 VBAT", "SPKRR VBAT Enable", "RX INT8 INTERP"},
  6469. {"RX INT8 CHAIN", NULL, "RX INT8 VBAT"},
  6470. {"RX INT8 CHAIN", NULL, "RX INT8 INTERP"},
  6471. {"RX INT8 CHAIN", NULL, "RX_BIAS"},
  6472. {"SPK2 OUT", NULL, "RX INT8 CHAIN"},
  6473. {"ANC0 FB MUX", "ANC_IN_EAR", "RX INT0 MIX2"},
  6474. {"ANC0 FB MUX", "ANC_IN_HPHL", "RX INT1 MIX2"},
  6475. {"ANC0 FB MUX", "ANC_IN_LO1", "RX INT3 MIX2"},
  6476. {"ANC0 FB MUX", "ANC_IN_EAR_SPKR", "RX INT7 MIX2"},
  6477. {"ANC1 FB MUX", "ANC_IN_HPHR", "RX INT2 MIX2"},
  6478. {"ANC1 FB MUX", "ANC_IN_LO2", "RX INT4 MIX2"},
  6479. {"ANC HPHL Enable", "Switch", "ADC MUX10"},
  6480. {"ANC HPHL Enable", "Switch", "ADC MUX11"},
  6481. {"RX INT1 MIX2", NULL, "ANC HPHL Enable"},
  6482. {"ANC HPHR Enable", "Switch", "ADC MUX12"},
  6483. {"ANC HPHR Enable", "Switch", "ADC MUX13"},
  6484. {"RX INT2 MIX2", NULL, "ANC HPHR Enable"},
  6485. {"ANC EAR Enable", "Switch", "ADC MUX10"},
  6486. {"ANC EAR Enable", "Switch", "ADC MUX11"},
  6487. {"RX INT0 MIX2", NULL, "ANC EAR Enable"},
  6488. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX10"},
  6489. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX11"},
  6490. {"RX INT7 MIX2", NULL, "ANC OUT EAR SPKR Enable"},
  6491. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX10"},
  6492. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX11"},
  6493. {"RX INT3 MIX2", NULL, "ANC LINEOUT1 Enable"},
  6494. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX12"},
  6495. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX13"},
  6496. {"RX INT4 MIX2", NULL, "ANC LINEOUT2 Enable"},
  6497. {"ANC EAR PA", NULL, "RX INT0 DAC"},
  6498. {"ANC EAR", NULL, "ANC EAR PA"},
  6499. {"ANC HPHL PA", NULL, "RX INT1 DAC"},
  6500. {"ANC HPHL", NULL, "ANC HPHL PA"},
  6501. {"ANC HPHR PA", NULL, "RX INT2 DAC"},
  6502. {"ANC HPHR", NULL, "ANC HPHR PA"},
  6503. {"ANC LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6504. {"ANC LINEOUT1", NULL, "ANC LINEOUT1 PA"},
  6505. {"ANC LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6506. {"ANC LINEOUT2", NULL, "ANC LINEOUT2 PA"},
  6507. /* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/
  6508. {"SLIM RX0 MUX", "AIF1_PB", "AIF1 PB"},
  6509. {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
  6510. {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
  6511. {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
  6512. {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
  6513. {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
  6514. {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
  6515. {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
  6516. /* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/
  6517. {"SLIM RX0 MUX", "AIF2_PB", "AIF2 PB"},
  6518. {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
  6519. {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
  6520. {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
  6521. {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
  6522. {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
  6523. {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
  6524. {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
  6525. /* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/
  6526. {"SLIM RX0 MUX", "AIF3_PB", "AIF3 PB"},
  6527. {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
  6528. {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
  6529. {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
  6530. {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
  6531. {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
  6532. {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
  6533. {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
  6534. /* SLIM_MUX("AIF4_PB", "AIF4 PB"),*/
  6535. {"SLIM RX0 MUX", "AIF4_PB", "AIF4 PB"},
  6536. {"SLIM RX1 MUX", "AIF4_PB", "AIF4 PB"},
  6537. {"SLIM RX2 MUX", "AIF4_PB", "AIF4 PB"},
  6538. {"SLIM RX3 MUX", "AIF4_PB", "AIF4 PB"},
  6539. {"SLIM RX4 MUX", "AIF4_PB", "AIF4 PB"},
  6540. {"SLIM RX5 MUX", "AIF4_PB", "AIF4 PB"},
  6541. {"SLIM RX6 MUX", "AIF4_PB", "AIF4 PB"},
  6542. {"SLIM RX7 MUX", "AIF4_PB", "AIF4 PB"},
  6543. /* SLIM_MUX("AIF_MIX1_PB", "AIF MIX1 PB"),*/
  6544. {"SLIM RX0 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6545. {"SLIM RX1 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6546. {"SLIM RX2 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6547. {"SLIM RX3 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6548. {"SLIM RX4 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6549. {"SLIM RX5 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6550. {"SLIM RX6 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6551. {"SLIM RX7 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6552. {"SLIM RX0", NULL, "SLIM RX0 MUX"},
  6553. {"SLIM RX1", NULL, "SLIM RX1 MUX"},
  6554. {"SLIM RX2", NULL, "SLIM RX2 MUX"},
  6555. {"SLIM RX3", NULL, "SLIM RX3 MUX"},
  6556. {"SLIM RX4", NULL, "SLIM RX4 MUX"},
  6557. {"SLIM RX5", NULL, "SLIM RX5 MUX"},
  6558. {"SLIM RX6", NULL, "SLIM RX6 MUX"},
  6559. {"SLIM RX7", NULL, "SLIM RX7 MUX"},
  6560. {"RX INT0_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6561. {"RX INT0_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6562. {"RX INT0_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6563. {"RX INT0_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6564. {"RX INT0_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6565. {"RX INT0_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6566. {"RX INT0_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6567. {"RX INT0_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6568. {"RX INT0_1 MIX1 INP0", "IIR0", "IIR0"},
  6569. {"RX INT0_1 MIX1 INP0", "IIR1", "IIR1"},
  6570. {"RX INT0_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6571. {"RX INT0_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6572. {"RX INT0_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6573. {"RX INT0_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6574. {"RX INT0_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6575. {"RX INT0_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6576. {"RX INT0_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6577. {"RX INT0_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6578. {"RX INT0_1 MIX1 INP1", "IIR0", "IIR0"},
  6579. {"RX INT0_1 MIX1 INP1", "IIR1", "IIR1"},
  6580. {"RX INT0_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6581. {"RX INT0_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6582. {"RX INT0_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6583. {"RX INT0_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6584. {"RX INT0_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6585. {"RX INT0_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6586. {"RX INT0_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6587. {"RX INT0_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6588. {"RX INT0_1 MIX1 INP2", "IIR0", "IIR0"},
  6589. {"RX INT0_1 MIX1 INP2", "IIR1", "IIR1"},
  6590. /* MIXing path INT0 */
  6591. {"RX INT0_2 MUX", "RX0", "SLIM RX0"},
  6592. {"RX INT0_2 MUX", "RX1", "SLIM RX1"},
  6593. {"RX INT0_2 MUX", "RX2", "SLIM RX2"},
  6594. {"RX INT0_2 MUX", "RX3", "SLIM RX3"},
  6595. {"RX INT0_2 MUX", "RX4", "SLIM RX4"},
  6596. {"RX INT0_2 MUX", "RX5", "SLIM RX5"},
  6597. {"RX INT0_2 MUX", "RX6", "SLIM RX6"},
  6598. {"RX INT0_2 MUX", "RX7", "SLIM RX7"},
  6599. {"RX INT0 SEC MIX", NULL, "RX INT0_2 MUX"},
  6600. /* MIXing path INT1 */
  6601. {"RX INT1_2 MUX", "RX0", "SLIM RX0"},
  6602. {"RX INT1_2 MUX", "RX1", "SLIM RX1"},
  6603. {"RX INT1_2 MUX", "RX2", "SLIM RX2"},
  6604. {"RX INT1_2 MUX", "RX3", "SLIM RX3"},
  6605. {"RX INT1_2 MUX", "RX4", "SLIM RX4"},
  6606. {"RX INT1_2 MUX", "RX5", "SLIM RX5"},
  6607. {"RX INT1_2 MUX", "RX6", "SLIM RX6"},
  6608. {"RX INT1_2 MUX", "RX7", "SLIM RX7"},
  6609. {"RX INT1 SEC MIX", NULL, "RX INT1_2 MUX"},
  6610. /* MIXing path INT2 */
  6611. {"RX INT2_2 MUX", "RX0", "SLIM RX0"},
  6612. {"RX INT2_2 MUX", "RX1", "SLIM RX1"},
  6613. {"RX INT2_2 MUX", "RX2", "SLIM RX2"},
  6614. {"RX INT2_2 MUX", "RX3", "SLIM RX3"},
  6615. {"RX INT2_2 MUX", "RX4", "SLIM RX4"},
  6616. {"RX INT2_2 MUX", "RX5", "SLIM RX5"},
  6617. {"RX INT2_2 MUX", "RX6", "SLIM RX6"},
  6618. {"RX INT2_2 MUX", "RX7", "SLIM RX7"},
  6619. {"RX INT2 SEC MIX", NULL, "RX INT2_2 MUX"},
  6620. /* MIXing path INT3 */
  6621. {"RX INT3_2 MUX", "RX0", "SLIM RX0"},
  6622. {"RX INT3_2 MUX", "RX1", "SLIM RX1"},
  6623. {"RX INT3_2 MUX", "RX2", "SLIM RX2"},
  6624. {"RX INT3_2 MUX", "RX3", "SLIM RX3"},
  6625. {"RX INT3_2 MUX", "RX4", "SLIM RX4"},
  6626. {"RX INT3_2 MUX", "RX5", "SLIM RX5"},
  6627. {"RX INT3_2 MUX", "RX6", "SLIM RX6"},
  6628. {"RX INT3_2 MUX", "RX7", "SLIM RX7"},
  6629. {"RX INT3 SEC MIX", NULL, "RX INT3_2 MUX"},
  6630. /* MIXing path INT4 */
  6631. {"RX INT4_2 MUX", "RX0", "SLIM RX0"},
  6632. {"RX INT4_2 MUX", "RX1", "SLIM RX1"},
  6633. {"RX INT4_2 MUX", "RX2", "SLIM RX2"},
  6634. {"RX INT4_2 MUX", "RX3", "SLIM RX3"},
  6635. {"RX INT4_2 MUX", "RX4", "SLIM RX4"},
  6636. {"RX INT4_2 MUX", "RX5", "SLIM RX5"},
  6637. {"RX INT4_2 MUX", "RX6", "SLIM RX6"},
  6638. {"RX INT4_2 MUX", "RX7", "SLIM RX7"},
  6639. {"RX INT4 SEC MIX", NULL, "RX INT4_2 MUX"},
  6640. /* MIXing path INT5 */
  6641. {"RX INT5_2 MUX", "RX0", "SLIM RX0"},
  6642. {"RX INT5_2 MUX", "RX1", "SLIM RX1"},
  6643. {"RX INT5_2 MUX", "RX2", "SLIM RX2"},
  6644. {"RX INT5_2 MUX", "RX3", "SLIM RX3"},
  6645. {"RX INT5_2 MUX", "RX4", "SLIM RX4"},
  6646. {"RX INT5_2 MUX", "RX5", "SLIM RX5"},
  6647. {"RX INT5_2 MUX", "RX6", "SLIM RX6"},
  6648. {"RX INT5_2 MUX", "RX7", "SLIM RX7"},
  6649. {"RX INT5 SEC MIX", NULL, "RX INT5_2 MUX"},
  6650. /* MIXing path INT6 */
  6651. {"RX INT6_2 MUX", "RX0", "SLIM RX0"},
  6652. {"RX INT6_2 MUX", "RX1", "SLIM RX1"},
  6653. {"RX INT6_2 MUX", "RX2", "SLIM RX2"},
  6654. {"RX INT6_2 MUX", "RX3", "SLIM RX3"},
  6655. {"RX INT6_2 MUX", "RX4", "SLIM RX4"},
  6656. {"RX INT6_2 MUX", "RX5", "SLIM RX5"},
  6657. {"RX INT6_2 MUX", "RX6", "SLIM RX6"},
  6658. {"RX INT6_2 MUX", "RX7", "SLIM RX7"},
  6659. {"RX INT6 SEC MIX", NULL, "RX INT6_2 MUX"},
  6660. /* MIXing path INT7 */
  6661. {"RX INT7_2 MUX", "RX0", "SLIM RX0"},
  6662. {"RX INT7_2 MUX", "RX1", "SLIM RX1"},
  6663. {"RX INT7_2 MUX", "RX2", "SLIM RX2"},
  6664. {"RX INT7_2 MUX", "RX3", "SLIM RX3"},
  6665. {"RX INT7_2 MUX", "RX4", "SLIM RX4"},
  6666. {"RX INT7_2 MUX", "RX5", "SLIM RX5"},
  6667. {"RX INT7_2 MUX", "RX6", "SLIM RX6"},
  6668. {"RX INT7_2 MUX", "RX7", "SLIM RX7"},
  6669. {"RX INT7 SEC MIX", NULL, "RX INT7_2 MUX"},
  6670. /* MIXing path INT8 */
  6671. {"RX INT8_2 MUX", "RX0", "SLIM RX0"},
  6672. {"RX INT8_2 MUX", "RX1", "SLIM RX1"},
  6673. {"RX INT8_2 MUX", "RX2", "SLIM RX2"},
  6674. {"RX INT8_2 MUX", "RX3", "SLIM RX3"},
  6675. {"RX INT8_2 MUX", "RX4", "SLIM RX4"},
  6676. {"RX INT8_2 MUX", "RX5", "SLIM RX5"},
  6677. {"RX INT8_2 MUX", "RX6", "SLIM RX6"},
  6678. {"RX INT8_2 MUX", "RX7", "SLIM RX7"},
  6679. {"RX INT8 SEC MIX", NULL, "RX INT8_2 MUX"},
  6680. {"RX INT1_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6681. {"RX INT1_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6682. {"RX INT1_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6683. {"RX INT1_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6684. {"RX INT1_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6685. {"RX INT1_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6686. {"RX INT1_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6687. {"RX INT1_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6688. {"RX INT1_1 MIX1 INP0", "IIR0", "IIR0"},
  6689. {"RX INT1_1 MIX1 INP0", "IIR1", "IIR1"},
  6690. {"RX INT1_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6691. {"RX INT1_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6692. {"RX INT1_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6693. {"RX INT1_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6694. {"RX INT1_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6695. {"RX INT1_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6696. {"RX INT1_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6697. {"RX INT1_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6698. {"RX INT1_1 MIX1 INP1", "IIR0", "IIR0"},
  6699. {"RX INT1_1 MIX1 INP1", "IIR1", "IIR1"},
  6700. {"RX INT1_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6701. {"RX INT1_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6702. {"RX INT1_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6703. {"RX INT1_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6704. {"RX INT1_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6705. {"RX INT1_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6706. {"RX INT1_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6707. {"RX INT1_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6708. {"RX INT1_1 MIX1 INP2", "IIR0", "IIR0"},
  6709. {"RX INT1_1 MIX1 INP2", "IIR1", "IIR1"},
  6710. {"RX INT2_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6711. {"RX INT2_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6712. {"RX INT2_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6713. {"RX INT2_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6714. {"RX INT2_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6715. {"RX INT2_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6716. {"RX INT2_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6717. {"RX INT2_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6718. {"RX INT2_1 MIX1 INP0", "IIR0", "IIR0"},
  6719. {"RX INT2_1 MIX1 INP0", "IIR1", "IIR1"},
  6720. {"RX INT2_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6721. {"RX INT2_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6722. {"RX INT2_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6723. {"RX INT2_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6724. {"RX INT2_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6725. {"RX INT2_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6726. {"RX INT2_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6727. {"RX INT2_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6728. {"RX INT2_1 MIX1 INP1", "IIR0", "IIR0"},
  6729. {"RX INT2_1 MIX1 INP1", "IIR1", "IIR1"},
  6730. {"RX INT2_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6731. {"RX INT2_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6732. {"RX INT2_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6733. {"RX INT2_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6734. {"RX INT2_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6735. {"RX INT2_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6736. {"RX INT2_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6737. {"RX INT2_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6738. {"RX INT2_1 MIX1 INP2", "IIR0", "IIR0"},
  6739. {"RX INT2_1 MIX1 INP2", "IIR1", "IIR1"},
  6740. {"RX INT3_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6741. {"RX INT3_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6742. {"RX INT3_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6743. {"RX INT3_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6744. {"RX INT3_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6745. {"RX INT3_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6746. {"RX INT3_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6747. {"RX INT3_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6748. {"RX INT3_1 MIX1 INP0", "IIR0", "IIR0"},
  6749. {"RX INT3_1 MIX1 INP0", "IIR1", "IIR1"},
  6750. {"RX INT3_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6751. {"RX INT3_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6752. {"RX INT3_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6753. {"RX INT3_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6754. {"RX INT3_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6755. {"RX INT3_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6756. {"RX INT3_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6757. {"RX INT3_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6758. {"RX INT3_1 MIX1 INP1", "IIR0", "IIR0"},
  6759. {"RX INT3_1 MIX1 INP1", "IIR1", "IIR1"},
  6760. {"RX INT3_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6761. {"RX INT3_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6762. {"RX INT3_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6763. {"RX INT3_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6764. {"RX INT3_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6765. {"RX INT3_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6766. {"RX INT3_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6767. {"RX INT3_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6768. {"RX INT3_1 MIX1 INP2", "IIR0", "IIR0"},
  6769. {"RX INT3_1 MIX1 INP2", "IIR1", "IIR1"},
  6770. {"RX INT4_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6771. {"RX INT4_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6772. {"RX INT4_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6773. {"RX INT4_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6774. {"RX INT4_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6775. {"RX INT4_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6776. {"RX INT4_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6777. {"RX INT4_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6778. {"RX INT4_1 MIX1 INP0", "IIR0", "IIR0"},
  6779. {"RX INT4_1 MIX1 INP0", "IIR1", "IIR1"},
  6780. {"RX INT4_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6781. {"RX INT4_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6782. {"RX INT4_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6783. {"RX INT4_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6784. {"RX INT4_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6785. {"RX INT4_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6786. {"RX INT4_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6787. {"RX INT4_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6788. {"RX INT4_1 MIX1 INP1", "IIR0", "IIR0"},
  6789. {"RX INT4_1 MIX1 INP1", "IIR1", "IIR1"},
  6790. {"RX INT4_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6791. {"RX INT4_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6792. {"RX INT4_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6793. {"RX INT4_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6794. {"RX INT4_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6795. {"RX INT4_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6796. {"RX INT4_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6797. {"RX INT4_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6798. {"RX INT4_1 MIX1 INP2", "IIR0", "IIR0"},
  6799. {"RX INT4_1 MIX1 INP2", "IIR1", "IIR1"},
  6800. {"RX INT5_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6801. {"RX INT5_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6802. {"RX INT5_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6803. {"RX INT5_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6804. {"RX INT5_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6805. {"RX INT5_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6806. {"RX INT5_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6807. {"RX INT5_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6808. {"RX INT5_1 MIX1 INP0", "IIR0", "IIR0"},
  6809. {"RX INT5_1 MIX1 INP0", "IIR1", "IIR1"},
  6810. {"RX INT5_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6811. {"RX INT5_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6812. {"RX INT5_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6813. {"RX INT5_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6814. {"RX INT5_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6815. {"RX INT5_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6816. {"RX INT5_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6817. {"RX INT5_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6818. {"RX INT5_1 MIX1 INP1", "IIR0", "IIR0"},
  6819. {"RX INT5_1 MIX1 INP1", "IIR1", "IIR1"},
  6820. {"RX INT5_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6821. {"RX INT5_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6822. {"RX INT5_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6823. {"RX INT5_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6824. {"RX INT5_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6825. {"RX INT5_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6826. {"RX INT5_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6827. {"RX INT5_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6828. {"RX INT5_1 MIX1 INP2", "IIR0", "IIR0"},
  6829. {"RX INT5_1 MIX1 INP2", "IIR1", "IIR1"},
  6830. {"RX INT6_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6831. {"RX INT6_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6832. {"RX INT6_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6833. {"RX INT6_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6834. {"RX INT6_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6835. {"RX INT6_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6836. {"RX INT6_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6837. {"RX INT6_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6838. {"RX INT6_1 MIX1 INP0", "IIR0", "IIR0"},
  6839. {"RX INT6_1 MIX1 INP0", "IIR1", "IIR1"},
  6840. {"RX INT6_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6841. {"RX INT6_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6842. {"RX INT6_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6843. {"RX INT6_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6844. {"RX INT6_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6845. {"RX INT6_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6846. {"RX INT6_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6847. {"RX INT6_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6848. {"RX INT6_1 MIX1 INP1", "IIR0", "IIR0"},
  6849. {"RX INT6_1 MIX1 INP1", "IIR1", "IIR1"},
  6850. {"RX INT6_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6851. {"RX INT6_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6852. {"RX INT6_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6853. {"RX INT6_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6854. {"RX INT6_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6855. {"RX INT6_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6856. {"RX INT6_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6857. {"RX INT6_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6858. {"RX INT6_1 MIX1 INP2", "IIR0", "IIR0"},
  6859. {"RX INT6_1 MIX1 INP2", "IIR1", "IIR1"},
  6860. {"RX INT7_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6861. {"RX INT7_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6862. {"RX INT7_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6863. {"RX INT7_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6864. {"RX INT7_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6865. {"RX INT7_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6866. {"RX INT7_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6867. {"RX INT7_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6868. {"RX INT7_1 MIX1 INP0", "IIR0", "IIR0"},
  6869. {"RX INT7_1 MIX1 INP0", "IIR1", "IIR1"},
  6870. {"RX INT7_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6871. {"RX INT7_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6872. {"RX INT7_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6873. {"RX INT7_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6874. {"RX INT7_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6875. {"RX INT7_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6876. {"RX INT7_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6877. {"RX INT7_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6878. {"RX INT7_1 MIX1 INP1", "IIR0", "IIR0"},
  6879. {"RX INT7_1 MIX1 INP1", "IIR1", "IIR1"},
  6880. {"RX INT7_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6881. {"RX INT7_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6882. {"RX INT7_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6883. {"RX INT7_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6884. {"RX INT7_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6885. {"RX INT7_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6886. {"RX INT7_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6887. {"RX INT7_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6888. {"RX INT7_1 MIX1 INP2", "IIR0", "IIR0"},
  6889. {"RX INT7_1 MIX1 INP2", "IIR1", "IIR1"},
  6890. {"RX INT8_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6891. {"RX INT8_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6892. {"RX INT8_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6893. {"RX INT8_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6894. {"RX INT8_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6895. {"RX INT8_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6896. {"RX INT8_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6897. {"RX INT8_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6898. {"RX INT8_1 MIX1 INP0", "IIR0", "IIR0"},
  6899. {"RX INT8_1 MIX1 INP0", "IIR1", "IIR1"},
  6900. {"RX INT8_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6901. {"RX INT8_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6902. {"RX INT8_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6903. {"RX INT8_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6904. {"RX INT8_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6905. {"RX INT8_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6906. {"RX INT8_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6907. {"RX INT8_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6908. {"RX INT8_1 MIX1 INP1", "IIR0", "IIR0"},
  6909. {"RX INT8_1 MIX1 INP1", "IIR1", "IIR1"},
  6910. {"RX INT8_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6911. {"RX INT8_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6912. {"RX INT8_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6913. {"RX INT8_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6914. {"RX INT8_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6915. {"RX INT8_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6916. {"RX INT8_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6917. {"RX INT8_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6918. {"RX INT8_1 MIX1 INP2", "IIR0", "IIR0"},
  6919. {"RX INT8_1 MIX1 INP2", "IIR1", "IIR1"},
  6920. /* SRC0, SRC1 inputs to Sidetone RX Mixer
  6921. * on RX0, RX1, RX2, RX3, RX4 and RX7 chains
  6922. */
  6923. {"IIR0", NULL, "IIR0 INP0 MUX"},
  6924. {"IIR0 INP0 MUX", "DEC0", "ADC MUX0"},
  6925. {"IIR0 INP0 MUX", "DEC1", "ADC MUX1"},
  6926. {"IIR0 INP0 MUX", "DEC2", "ADC MUX2"},
  6927. {"IIR0 INP0 MUX", "DEC3", "ADC MUX3"},
  6928. {"IIR0 INP0 MUX", "DEC4", "ADC MUX4"},
  6929. {"IIR0 INP0 MUX", "DEC5", "ADC MUX5"},
  6930. {"IIR0 INP0 MUX", "DEC6", "ADC MUX6"},
  6931. {"IIR0 INP0 MUX", "DEC7", "ADC MUX7"},
  6932. {"IIR0 INP0 MUX", "DEC8", "ADC MUX8"},
  6933. {"IIR0 INP0 MUX", "RX0", "SLIM RX0"},
  6934. {"IIR0 INP0 MUX", "RX1", "SLIM RX1"},
  6935. {"IIR0 INP0 MUX", "RX2", "SLIM RX2"},
  6936. {"IIR0 INP0 MUX", "RX3", "SLIM RX3"},
  6937. {"IIR0 INP0 MUX", "RX4", "SLIM RX4"},
  6938. {"IIR0 INP0 MUX", "RX5", "SLIM RX5"},
  6939. {"IIR0 INP0 MUX", "RX6", "SLIM RX6"},
  6940. {"IIR0 INP0 MUX", "RX7", "SLIM RX7"},
  6941. {"IIR0", NULL, "IIR0 INP1 MUX"},
  6942. {"IIR0 INP1 MUX", "DEC0", "ADC MUX0"},
  6943. {"IIR0 INP1 MUX", "DEC1", "ADC MUX1"},
  6944. {"IIR0 INP1 MUX", "DEC2", "ADC MUX2"},
  6945. {"IIR0 INP1 MUX", "DEC3", "ADC MUX3"},
  6946. {"IIR0 INP1 MUX", "DEC4", "ADC MUX4"},
  6947. {"IIR0 INP1 MUX", "DEC5", "ADC MUX5"},
  6948. {"IIR0 INP1 MUX", "DEC6", "ADC MUX6"},
  6949. {"IIR0 INP1 MUX", "DEC7", "ADC MUX7"},
  6950. {"IIR0 INP1 MUX", "DEC8", "ADC MUX8"},
  6951. {"IIR0 INP1 MUX", "RX0", "SLIM RX0"},
  6952. {"IIR0 INP1 MUX", "RX1", "SLIM RX1"},
  6953. {"IIR0 INP1 MUX", "RX2", "SLIM RX2"},
  6954. {"IIR0 INP1 MUX", "RX3", "SLIM RX3"},
  6955. {"IIR0 INP1 MUX", "RX4", "SLIM RX4"},
  6956. {"IIR0 INP1 MUX", "RX5", "SLIM RX5"},
  6957. {"IIR0 INP1 MUX", "RX6", "SLIM RX6"},
  6958. {"IIR0 INP1 MUX", "RX7", "SLIM RX7"},
  6959. {"IIR0", NULL, "IIR0 INP2 MUX"},
  6960. {"IIR0 INP2 MUX", "DEC0", "ADC MUX0"},
  6961. {"IIR0 INP2 MUX", "DEC1", "ADC MUX1"},
  6962. {"IIR0 INP2 MUX", "DEC2", "ADC MUX2"},
  6963. {"IIR0 INP2 MUX", "DEC3", "ADC MUX3"},
  6964. {"IIR0 INP2 MUX", "DEC4", "ADC MUX4"},
  6965. {"IIR0 INP2 MUX", "DEC5", "ADC MUX5"},
  6966. {"IIR0 INP2 MUX", "DEC6", "ADC MUX6"},
  6967. {"IIR0 INP2 MUX", "DEC7", "ADC MUX7"},
  6968. {"IIR0 INP2 MUX", "DEC8", "ADC MUX8"},
  6969. {"IIR0 INP2 MUX", "RX0", "SLIM RX0"},
  6970. {"IIR0 INP2 MUX", "RX1", "SLIM RX1"},
  6971. {"IIR0 INP2 MUX", "RX2", "SLIM RX2"},
  6972. {"IIR0 INP2 MUX", "RX3", "SLIM RX3"},
  6973. {"IIR0 INP2 MUX", "RX4", "SLIM RX4"},
  6974. {"IIR0 INP2 MUX", "RX5", "SLIM RX5"},
  6975. {"IIR0 INP2 MUX", "RX6", "SLIM RX6"},
  6976. {"IIR0 INP2 MUX", "RX7", "SLIM RX7"},
  6977. {"IIR0", NULL, "IIR0 INP3 MUX"},
  6978. {"IIR0 INP3 MUX", "DEC0", "ADC MUX0"},
  6979. {"IIR0 INP3 MUX", "DEC1", "ADC MUX1"},
  6980. {"IIR0 INP3 MUX", "DEC2", "ADC MUX2"},
  6981. {"IIR0 INP3 MUX", "DEC3", "ADC MUX3"},
  6982. {"IIR0 INP3 MUX", "DEC4", "ADC MUX4"},
  6983. {"IIR0 INP3 MUX", "DEC5", "ADC MUX5"},
  6984. {"IIR0 INP3 MUX", "DEC6", "ADC MUX6"},
  6985. {"IIR0 INP3 MUX", "DEC7", "ADC MUX7"},
  6986. {"IIR0 INP3 MUX", "DEC8", "ADC MUX8"},
  6987. {"IIR0 INP3 MUX", "RX0", "SLIM RX0"},
  6988. {"IIR0 INP3 MUX", "RX1", "SLIM RX1"},
  6989. {"IIR0 INP3 MUX", "RX2", "SLIM RX2"},
  6990. {"IIR0 INP3 MUX", "RX3", "SLIM RX3"},
  6991. {"IIR0 INP3 MUX", "RX4", "SLIM RX4"},
  6992. {"IIR0 INP3 MUX", "RX5", "SLIM RX5"},
  6993. {"IIR0 INP3 MUX", "RX6", "SLIM RX6"},
  6994. {"IIR0 INP3 MUX", "RX7", "SLIM RX7"},
  6995. {"IIR1", NULL, "IIR1 INP0 MUX"},
  6996. {"IIR1 INP0 MUX", "DEC0", "ADC MUX0"},
  6997. {"IIR1 INP0 MUX", "DEC1", "ADC MUX1"},
  6998. {"IIR1 INP0 MUX", "DEC2", "ADC MUX2"},
  6999. {"IIR1 INP0 MUX", "DEC3", "ADC MUX3"},
  7000. {"IIR1 INP0 MUX", "DEC4", "ADC MUX4"},
  7001. {"IIR1 INP0 MUX", "DEC5", "ADC MUX5"},
  7002. {"IIR1 INP0 MUX", "DEC6", "ADC MUX6"},
  7003. {"IIR1 INP0 MUX", "DEC7", "ADC MUX7"},
  7004. {"IIR1 INP0 MUX", "DEC8", "ADC MUX8"},
  7005. {"IIR1 INP0 MUX", "RX0", "SLIM RX0"},
  7006. {"IIR1 INP0 MUX", "RX1", "SLIM RX1"},
  7007. {"IIR1 INP0 MUX", "RX2", "SLIM RX2"},
  7008. {"IIR1 INP0 MUX", "RX3", "SLIM RX3"},
  7009. {"IIR1 INP0 MUX", "RX4", "SLIM RX4"},
  7010. {"IIR1 INP0 MUX", "RX5", "SLIM RX5"},
  7011. {"IIR1 INP0 MUX", "RX6", "SLIM RX6"},
  7012. {"IIR1 INP0 MUX", "RX7", "SLIM RX7"},
  7013. {"IIR1", NULL, "IIR1 INP1 MUX"},
  7014. {"IIR1 INP1 MUX", "DEC0", "ADC MUX0"},
  7015. {"IIR1 INP1 MUX", "DEC1", "ADC MUX1"},
  7016. {"IIR1 INP1 MUX", "DEC2", "ADC MUX2"},
  7017. {"IIR1 INP1 MUX", "DEC3", "ADC MUX3"},
  7018. {"IIR1 INP1 MUX", "DEC4", "ADC MUX4"},
  7019. {"IIR1 INP1 MUX", "DEC5", "ADC MUX5"},
  7020. {"IIR1 INP1 MUX", "DEC6", "ADC MUX6"},
  7021. {"IIR1 INP1 MUX", "DEC7", "ADC MUX7"},
  7022. {"IIR1 INP1 MUX", "DEC8", "ADC MUX8"},
  7023. {"IIR1 INP1 MUX", "RX0", "SLIM RX0"},
  7024. {"IIR1 INP1 MUX", "RX1", "SLIM RX1"},
  7025. {"IIR1 INP1 MUX", "RX2", "SLIM RX2"},
  7026. {"IIR1 INP1 MUX", "RX3", "SLIM RX3"},
  7027. {"IIR1 INP1 MUX", "RX4", "SLIM RX4"},
  7028. {"IIR1 INP1 MUX", "RX5", "SLIM RX5"},
  7029. {"IIR1 INP1 MUX", "RX6", "SLIM RX6"},
  7030. {"IIR1 INP1 MUX", "RX7", "SLIM RX7"},
  7031. {"IIR1", NULL, "IIR1 INP2 MUX"},
  7032. {"IIR1 INP2 MUX", "DEC0", "ADC MUX0"},
  7033. {"IIR1 INP2 MUX", "DEC1", "ADC MUX1"},
  7034. {"IIR1 INP2 MUX", "DEC2", "ADC MUX2"},
  7035. {"IIR1 INP2 MUX", "DEC3", "ADC MUX3"},
  7036. {"IIR1 INP2 MUX", "DEC4", "ADC MUX4"},
  7037. {"IIR1 INP2 MUX", "DEC5", "ADC MUX5"},
  7038. {"IIR1 INP2 MUX", "DEC6", "ADC MUX6"},
  7039. {"IIR1 INP2 MUX", "DEC7", "ADC MUX7"},
  7040. {"IIR1 INP2 MUX", "DEC8", "ADC MUX8"},
  7041. {"IIR1 INP2 MUX", "RX0", "SLIM RX0"},
  7042. {"IIR1 INP2 MUX", "RX1", "SLIM RX1"},
  7043. {"IIR1 INP2 MUX", "RX2", "SLIM RX2"},
  7044. {"IIR1 INP2 MUX", "RX3", "SLIM RX3"},
  7045. {"IIR1 INP2 MUX", "RX4", "SLIM RX4"},
  7046. {"IIR1 INP2 MUX", "RX5", "SLIM RX5"},
  7047. {"IIR1 INP2 MUX", "RX6", "SLIM RX6"},
  7048. {"IIR1 INP2 MUX", "RX7", "SLIM RX7"},
  7049. {"IIR1", NULL, "IIR1 INP3 MUX"},
  7050. {"IIR1 INP3 MUX", "DEC0", "ADC MUX0"},
  7051. {"IIR1 INP3 MUX", "DEC1", "ADC MUX1"},
  7052. {"IIR1 INP3 MUX", "DEC2", "ADC MUX2"},
  7053. {"IIR1 INP3 MUX", "DEC3", "ADC MUX3"},
  7054. {"IIR1 INP3 MUX", "DEC4", "ADC MUX4"},
  7055. {"IIR1 INP3 MUX", "DEC5", "ADC MUX5"},
  7056. {"IIR1 INP3 MUX", "DEC6", "ADC MUX6"},
  7057. {"IIR1 INP3 MUX", "DEC7", "ADC MUX7"},
  7058. {"IIR1 INP3 MUX", "DEC8", "ADC MUX8"},
  7059. {"IIR1 INP3 MUX", "RX0", "SLIM RX0"},
  7060. {"IIR1 INP3 MUX", "RX1", "SLIM RX1"},
  7061. {"IIR1 INP3 MUX", "RX2", "SLIM RX2"},
  7062. {"IIR1 INP3 MUX", "RX3", "SLIM RX3"},
  7063. {"IIR1 INP3 MUX", "RX4", "SLIM RX4"},
  7064. {"IIR1 INP3 MUX", "RX5", "SLIM RX5"},
  7065. {"IIR1 INP3 MUX", "RX6", "SLIM RX6"},
  7066. {"IIR1 INP3 MUX", "RX7", "SLIM RX7"},
  7067. {"SRC0", NULL, "IIR0"},
  7068. {"SRC1", NULL, "IIR1"},
  7069. {"RX INT0 MIX2 INP", "SRC0", "SRC0"},
  7070. {"RX INT0 MIX2 INP", "SRC1", "SRC1"},
  7071. {"RX INT1 MIX2 INP", "SRC0", "SRC0"},
  7072. {"RX INT1 MIX2 INP", "SRC1", "SRC1"},
  7073. {"RX INT2 MIX2 INP", "SRC0", "SRC0"},
  7074. {"RX INT2 MIX2 INP", "SRC1", "SRC1"},
  7075. {"RX INT3 MIX2 INP", "SRC0", "SRC0"},
  7076. {"RX INT3 MIX2 INP", "SRC1", "SRC1"},
  7077. {"RX INT4 MIX2 INP", "SRC0", "SRC0"},
  7078. {"RX INT4 MIX2 INP", "SRC1", "SRC1"},
  7079. {"RX INT7 MIX2 INP", "SRC0", "SRC0"},
  7080. {"RX INT7 MIX2 INP", "SRC1", "SRC1"},
  7081. };
  7082. static int tasha_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol,
  7083. struct snd_ctl_elem_value *ucontrol)
  7084. {
  7085. struct snd_soc_component *component =
  7086. snd_soc_kcontrol_component(kcontrol);
  7087. u16 amic_reg;
  7088. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  7089. amic_reg = WCD9335_ANA_AMIC1;
  7090. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  7091. amic_reg = WCD9335_ANA_AMIC3;
  7092. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  7093. amic_reg = WCD9335_ANA_AMIC5;
  7094. ucontrol->value.integer.value[0] =
  7095. (snd_soc_component_read32(component, amic_reg) &
  7096. WCD9335_AMIC_PWR_LVL_MASK) >>
  7097. WCD9335_AMIC_PWR_LVL_SHIFT;
  7098. return 0;
  7099. }
  7100. static int tasha_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol,
  7101. struct snd_ctl_elem_value *ucontrol)
  7102. {
  7103. struct snd_soc_component *component =
  7104. snd_soc_kcontrol_component(kcontrol);
  7105. u32 mode_val;
  7106. u16 amic_reg;
  7107. mode_val = ucontrol->value.enumerated.item[0];
  7108. dev_dbg(component->dev, "%s: mode: %d\n",
  7109. __func__, mode_val);
  7110. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  7111. amic_reg = WCD9335_ANA_AMIC1;
  7112. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  7113. amic_reg = WCD9335_ANA_AMIC3;
  7114. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  7115. amic_reg = WCD9335_ANA_AMIC5;
  7116. snd_soc_component_update_bits(component, amic_reg,
  7117. WCD9335_AMIC_PWR_LVL_MASK,
  7118. mode_val << WCD9335_AMIC_PWR_LVL_SHIFT);
  7119. return 0;
  7120. }
  7121. static int tasha_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
  7122. struct snd_ctl_elem_value *ucontrol)
  7123. {
  7124. struct snd_soc_component *component =
  7125. snd_soc_kcontrol_component(kcontrol);
  7126. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  7127. ucontrol->value.integer.value[0] = tasha->hph_mode;
  7128. return 0;
  7129. }
  7130. static int tasha_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
  7131. struct snd_ctl_elem_value *ucontrol)
  7132. {
  7133. struct snd_soc_component *component =
  7134. snd_soc_kcontrol_component(kcontrol);
  7135. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  7136. u32 mode_val;
  7137. mode_val = ucontrol->value.enumerated.item[0];
  7138. dev_dbg(component->dev, "%s: mode: %d\n",
  7139. __func__, mode_val);
  7140. if (mode_val == 0) {
  7141. dev_warn(component->dev, "%s:Invalid HPH Mode, default to Cls-H HiFi\n",
  7142. __func__);
  7143. mode_val = CLS_H_HIFI;
  7144. }
  7145. tasha->hph_mode = mode_val;
  7146. return 0;
  7147. }
  7148. static const char *const tasha_conn_mad_text[] = {
  7149. "NOTUSED1", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6",
  7150. "NOTUSED2", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4",
  7151. "DMIC5", "NOTUSED3", "NOTUSED4"
  7152. };
  7153. static const struct soc_enum tasha_conn_mad_enum =
  7154. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_conn_mad_text),
  7155. tasha_conn_mad_text);
  7156. static int tasha_enable_ldo_h_get(struct snd_kcontrol *kcontrol,
  7157. struct snd_ctl_elem_value *ucontrol)
  7158. {
  7159. struct snd_soc_component *component =
  7160. snd_soc_kcontrol_component(kcontrol);
  7161. u8 val = 0;
  7162. if (component)
  7163. val = snd_soc_component_read32(component, WCD9335_LDOH_MODE) &
  7164. 0x80;
  7165. ucontrol->value.integer.value[0] = !!val;
  7166. return 0;
  7167. }
  7168. static int tasha_enable_ldo_h_put(struct snd_kcontrol *kcontrol,
  7169. struct snd_ctl_elem_value *ucontrol)
  7170. {
  7171. struct snd_soc_component *component =
  7172. snd_soc_kcontrol_component(kcontrol);
  7173. int value = ucontrol->value.integer.value[0];
  7174. bool enable;
  7175. enable = !!value;
  7176. if (component)
  7177. tasha_codec_enable_standalone_ldo_h(component, enable);
  7178. return 0;
  7179. }
  7180. static int tasha_mad_input_get(struct snd_kcontrol *kcontrol,
  7181. struct snd_ctl_elem_value *ucontrol)
  7182. {
  7183. u8 tasha_mad_input;
  7184. struct snd_soc_component *component =
  7185. snd_soc_kcontrol_component(kcontrol);
  7186. tasha_mad_input = snd_soc_component_read32(component,
  7187. WCD9335_SOC_MAD_INP_SEL) & 0x0F;
  7188. ucontrol->value.integer.value[0] = tasha_mad_input;
  7189. dev_dbg(component->dev,
  7190. "%s: tasha_mad_input = %s\n", __func__,
  7191. tasha_conn_mad_text[tasha_mad_input]);
  7192. return 0;
  7193. }
  7194. static int tasha_mad_input_put(struct snd_kcontrol *kcontrol,
  7195. struct snd_ctl_elem_value *ucontrol)
  7196. {
  7197. u8 tasha_mad_input;
  7198. struct snd_soc_component *component =
  7199. snd_soc_kcontrol_component(kcontrol);
  7200. struct snd_soc_card *card = component->card;
  7201. char mad_amic_input_widget[6];
  7202. const char *mad_input_widget;
  7203. const char *source_widget = NULL;
  7204. u32 adc, i, mic_bias_found = 0;
  7205. int ret = 0;
  7206. char *mad_input;
  7207. tasha_mad_input = ucontrol->value.integer.value[0];
  7208. if (tasha_mad_input >= ARRAY_SIZE(tasha_conn_mad_text)) {
  7209. dev_err(component->dev,
  7210. "%s: tasha_mad_input = %d out of bounds\n",
  7211. __func__, tasha_mad_input);
  7212. return -EINVAL;
  7213. }
  7214. if (!strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED1") ||
  7215. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED2") ||
  7216. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED3") ||
  7217. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED4")) {
  7218. dev_err(component->dev,
  7219. "%s: Unsupported tasha_mad_input = %s\n",
  7220. __func__, tasha_conn_mad_text[tasha_mad_input]);
  7221. return -EINVAL;
  7222. }
  7223. if (strnstr(tasha_conn_mad_text[tasha_mad_input],
  7224. "ADC", sizeof("ADC"))) {
  7225. mad_input = strpbrk(tasha_conn_mad_text[tasha_mad_input],
  7226. "123456");
  7227. if (!mad_input) {
  7228. dev_err(component->dev, "%s: Invalid MAD input %s\n",
  7229. __func__,
  7230. tasha_conn_mad_text[tasha_mad_input]);
  7231. return -EINVAL;
  7232. }
  7233. ret = kstrtouint(mad_input, 10, &adc);
  7234. if ((ret < 0) || (adc > 6)) {
  7235. dev_err(component->dev,
  7236. "%s: Invalid ADC = %s\n", __func__,
  7237. tasha_conn_mad_text[tasha_mad_input]);
  7238. ret = -EINVAL;
  7239. }
  7240. snprintf(mad_amic_input_widget, 6, "%s%u", "AMIC", adc);
  7241. mad_input_widget = mad_amic_input_widget;
  7242. } else {
  7243. /* DMIC type input widget*/
  7244. mad_input_widget = tasha_conn_mad_text[tasha_mad_input];
  7245. }
  7246. dev_dbg(component->dev,
  7247. "%s: tasha input widget = %s\n", __func__,
  7248. mad_input_widget);
  7249. for (i = 0; i < card->num_of_dapm_routes; i++) {
  7250. if (!strcmp(card->of_dapm_routes[i].sink, mad_input_widget)) {
  7251. source_widget = card->of_dapm_routes[i].source;
  7252. if (!source_widget) {
  7253. dev_err(component->dev,
  7254. "%s: invalid source widget\n",
  7255. __func__);
  7256. return -EINVAL;
  7257. }
  7258. if (strnstr(source_widget,
  7259. "MIC BIAS1", sizeof("MIC BIAS1"))) {
  7260. mic_bias_found = 1;
  7261. break;
  7262. } else if (strnstr(source_widget,
  7263. "MIC BIAS2", sizeof("MIC BIAS2"))) {
  7264. mic_bias_found = 2;
  7265. break;
  7266. } else if (strnstr(source_widget,
  7267. "MIC BIAS3", sizeof("MIC BIAS3"))) {
  7268. mic_bias_found = 3;
  7269. break;
  7270. } else if (strnstr(source_widget,
  7271. "MIC BIAS4", sizeof("MIC BIAS4"))) {
  7272. mic_bias_found = 4;
  7273. break;
  7274. }
  7275. }
  7276. }
  7277. if (!mic_bias_found) {
  7278. dev_err(component->dev,
  7279. "%s: mic bias source not found for input = %s\n",
  7280. __func__, mad_input_widget);
  7281. return -EINVAL;
  7282. }
  7283. dev_dbg(component->dev,
  7284. "%s: mic_bias found = %d\n", __func__,
  7285. mic_bias_found);
  7286. snd_soc_component_update_bits(component, WCD9335_SOC_MAD_INP_SEL,
  7287. 0x0F, tasha_mad_input);
  7288. snd_soc_component_update_bits(component, WCD9335_ANA_MAD_SETUP,
  7289. 0x07, mic_bias_found);
  7290. return 0;
  7291. }
  7292. static int tasha_pinctl_mode_get(struct snd_kcontrol *kcontrol,
  7293. struct snd_ctl_elem_value *ucontrol)
  7294. {
  7295. struct snd_soc_component *component =
  7296. snd_soc_kcontrol_component(kcontrol);
  7297. u16 ctl_reg;
  7298. u8 reg_val, pinctl_position;
  7299. pinctl_position = ((struct soc_multi_mixer_control *)
  7300. kcontrol->private_value)->shift;
  7301. switch (pinctl_position >> 3) {
  7302. case 0:
  7303. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7304. break;
  7305. case 1:
  7306. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7307. break;
  7308. case 2:
  7309. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7310. break;
  7311. case 3:
  7312. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7313. break;
  7314. default:
  7315. dev_err(component->dev, "%s: Invalid pinctl position = %d\n",
  7316. __func__, pinctl_position);
  7317. return -EINVAL;
  7318. }
  7319. reg_val = snd_soc_component_read32(component, ctl_reg);
  7320. reg_val = (reg_val >> (pinctl_position & 0x07)) & 0x1;
  7321. ucontrol->value.integer.value[0] = reg_val;
  7322. return 0;
  7323. }
  7324. static int tasha_pinctl_mode_put(struct snd_kcontrol *kcontrol,
  7325. struct snd_ctl_elem_value *ucontrol)
  7326. {
  7327. struct snd_soc_component *component =
  7328. snd_soc_kcontrol_component(kcontrol);
  7329. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  7330. u16 ctl_reg, cfg_reg;
  7331. u8 ctl_val, cfg_val, pinctl_position, pinctl_mode, mask;
  7332. /* 1- high or low; 0- high Z */
  7333. pinctl_mode = ucontrol->value.integer.value[0];
  7334. pinctl_position = ((struct soc_multi_mixer_control *)
  7335. kcontrol->private_value)->shift;
  7336. switch (pinctl_position >> 3) {
  7337. case 0:
  7338. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7339. break;
  7340. case 1:
  7341. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7342. break;
  7343. case 2:
  7344. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7345. break;
  7346. case 3:
  7347. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7348. break;
  7349. default:
  7350. dev_err(component->dev, "%s: Invalid pinctl position = %d\n",
  7351. __func__, pinctl_position);
  7352. return -EINVAL;
  7353. }
  7354. ctl_val = pinctl_mode << (pinctl_position & 0x07);
  7355. mask = 1 << (pinctl_position & 0x07);
  7356. snd_soc_component_update_bits(component, ctl_reg, mask, ctl_val);
  7357. cfg_reg = WCD9335_TLMM_BIST_MODE_PINCFG + pinctl_position;
  7358. if (!pinctl_mode) {
  7359. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  7360. cfg_val = 0x4;
  7361. else
  7362. cfg_val = 0xC;
  7363. } else {
  7364. cfg_val = 0;
  7365. }
  7366. snd_soc_component_update_bits(component, cfg_reg, 0x07, cfg_val);
  7367. dev_dbg(component->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n",
  7368. __func__, ctl_reg, mask, ctl_val, cfg_reg, cfg_val);
  7369. return 0;
  7370. }
  7371. static void wcd_vbat_adc_out_config_2_0(struct wcd_vbat *vbat,
  7372. struct snd_soc_component *component)
  7373. {
  7374. u8 val1, val2;
  7375. /*
  7376. * Measure dcp1 by using "ALT" branch of band gap
  7377. * voltage(Vbg) and use it in FAST mode
  7378. */
  7379. snd_soc_component_update_bits(component, WCD9335_BIAS_CTL,
  7380. 0x82, 0x82);
  7381. snd_soc_component_update_bits(component, WCD9335_CDC_VBAT_VBAT_PATH_CTL,
  7382. 0x10, 0x10);
  7383. snd_soc_component_update_bits(component, WCD9335_CDC_VBAT_VBAT_DEBUG1,
  7384. 0x01, 0x01);
  7385. snd_soc_component_update_bits(component, WCD9335_ANA_VBADC,
  7386. 0x80, 0x80);
  7387. snd_soc_component_update_bits(component, WCD9335_VBADC_SUBBLOCK_EN,
  7388. 0x20, 0x00);
  7389. snd_soc_component_update_bits(component, WCD9335_VBADC_FE_CTRL,
  7390. 0x20, 0x20);
  7391. /* Wait 100 usec after calibration select as Vbg */
  7392. usleep_range(100, 110);
  7393. snd_soc_component_update_bits(component, WCD9335_VBADC_ADC_IO,
  7394. 0x40, 0x40);
  7395. val1 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTMSB);
  7396. val2 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTLSB);
  7397. snd_soc_component_update_bits(component, WCD9335_VBADC_ADC_IO,
  7398. 0x40, 0x00);
  7399. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7400. snd_soc_component_update_bits(component, WCD9335_BIAS_CTL, 0x40, 0x40);
  7401. /* Wait 100 usec after selecting Vbg as 1.05V */
  7402. usleep_range(100, 110);
  7403. snd_soc_component_update_bits(component, WCD9335_VBADC_ADC_IO,
  7404. 0x40, 0x40);
  7405. val1 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTMSB);
  7406. val2 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTLSB);
  7407. snd_soc_component_update_bits(component, WCD9335_VBADC_ADC_IO,
  7408. 0x40, 0x00);
  7409. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7410. dev_dbg(component->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7411. __func__, vbat->dcp1, vbat->dcp2);
  7412. snd_soc_component_write(component, WCD9335_BIAS_CTL, 0x28);
  7413. /* Wait 100 usec after selecting Vbg as 0.85V */
  7414. usleep_range(100, 110);
  7415. snd_soc_component_update_bits(component, WCD9335_VBADC_FE_CTRL,
  7416. 0x20, 0x00);
  7417. snd_soc_component_update_bits(component, WCD9335_VBADC_SUBBLOCK_EN,
  7418. 0x20, 0x20);
  7419. snd_soc_component_update_bits(component, WCD9335_ANA_VBADC,
  7420. 0x80, 0x00);
  7421. snd_soc_component_update_bits(component, WCD9335_CDC_VBAT_VBAT_PATH_CTL,
  7422. 0x10, 0x00);
  7423. snd_soc_component_update_bits(component, WCD9335_CDC_VBAT_VBAT_DEBUG1,
  7424. 0x01, 0x00);
  7425. }
  7426. static void wcd_vbat_adc_out_config_1_x(struct wcd_vbat *vbat,
  7427. struct snd_soc_component *component)
  7428. {
  7429. u8 val1, val2;
  7430. /*
  7431. * Measure dcp1 by applying band gap voltage(Vbg)
  7432. * of 0.85V
  7433. */
  7434. snd_soc_component_write(component, WCD9335_ANA_BIAS, 0x20);
  7435. snd_soc_component_write(component, WCD9335_BIAS_CTL, 0x28);
  7436. snd_soc_component_write(component, WCD9335_BIAS_VBG_FINE_ADJ, 0x05);
  7437. snd_soc_component_write(component, WCD9335_ANA_BIAS, 0xA0);
  7438. /* Wait 2 sec after enabling band gap bias */
  7439. usleep_range(2000000, 2000100);
  7440. snd_soc_component_write(component, WCD9335_ANA_CLK_TOP, 0x82);
  7441. snd_soc_component_write(component, WCD9335_ANA_CLK_TOP, 0x87);
  7442. snd_soc_component_update_bits(component, WCD9335_CDC_VBAT_VBAT_PATH_CTL,
  7443. 0x10, 0x10);
  7444. snd_soc_component_write(component, WCD9335_CDC_VBAT_VBAT_CFG, 0x0D);
  7445. snd_soc_component_write(component, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01);
  7446. snd_soc_component_write(component, WCD9335_ANA_VBADC, 0x80);
  7447. snd_soc_component_write(component, WCD9335_VBADC_SUBBLOCK_EN, 0xDE);
  7448. snd_soc_component_write(component, WCD9335_VBADC_FE_CTRL, 0x3C);
  7449. /* Wait 1 msec after calibration select as Vbg */
  7450. usleep_range(1000, 1100);
  7451. snd_soc_component_write(component, WCD9335_VBADC_ADC_IO, 0xC0);
  7452. val1 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTMSB);
  7453. val2 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTLSB);
  7454. snd_soc_component_write(component, WCD9335_VBADC_ADC_IO, 0x80);
  7455. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7456. /*
  7457. * Measure dcp2 by applying band gap voltage(Vbg)
  7458. * of 1.05V
  7459. */
  7460. snd_soc_component_write(component, WCD9335_ANA_BIAS, 0x80);
  7461. snd_soc_component_write(component, WCD9335_ANA_BIAS, 0xC0);
  7462. snd_soc_component_write(component, WCD9335_BIAS_CTL, 0x68);
  7463. /* Wait 2 msec after selecting Vbg as 1.05V */
  7464. usleep_range(2000, 2100);
  7465. snd_soc_component_write(component, WCD9335_ANA_BIAS, 0x80);
  7466. /* Wait 1 sec after enabling band gap bias */
  7467. usleep_range(1000000, 1000100);
  7468. snd_soc_component_write(component, WCD9335_VBADC_ADC_IO, 0xC0);
  7469. val1 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTMSB);
  7470. val2 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTLSB);
  7471. snd_soc_component_write(component, WCD9335_VBADC_ADC_IO, 0x80);
  7472. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7473. dev_dbg(component->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7474. __func__, vbat->dcp1, vbat->dcp2);
  7475. /* Reset the Vbat ADC configuration */
  7476. snd_soc_component_write(component, WCD9335_ANA_BIAS, 0x80);
  7477. snd_soc_component_write(component, WCD9335_ANA_BIAS, 0xC0);
  7478. snd_soc_component_write(component, WCD9335_BIAS_CTL, 0x28);
  7479. /* Wait 2 msec after selecting Vbg as 0.85V */
  7480. usleep_range(2000, 2100);
  7481. snd_soc_component_write(component, WCD9335_ANA_BIAS, 0xA0);
  7482. /* Wait 1 sec after enabling band gap bias */
  7483. usleep_range(1000000, 1000100);
  7484. snd_soc_component_write(component, WCD9335_VBADC_FE_CTRL, 0x1C);
  7485. snd_soc_component_write(component, WCD9335_VBADC_SUBBLOCK_EN, 0xFE);
  7486. snd_soc_component_write(component, WCD9335_VBADC_ADC_IO, 0x80);
  7487. snd_soc_component_write(component, WCD9335_ANA_VBADC, 0x00);
  7488. snd_soc_component_write(component, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x00);
  7489. snd_soc_component_write(component, WCD9335_CDC_VBAT_VBAT_PATH_CTL,
  7490. 0x00);
  7491. snd_soc_component_write(component, WCD9335_CDC_VBAT_VBAT_CFG, 0x0A);
  7492. }
  7493. static void wcd_vbat_adc_out_config(struct wcd_vbat *vbat,
  7494. struct snd_soc_component *component)
  7495. {
  7496. struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
  7497. if (!vbat->adc_config) {
  7498. tasha_cdc_mclk_enable(component, true, false);
  7499. if (TASHA_IS_2_0(wcd9xxx))
  7500. wcd_vbat_adc_out_config_2_0(vbat, component);
  7501. else
  7502. wcd_vbat_adc_out_config_1_x(vbat, component);
  7503. tasha_cdc_mclk_enable(component, false, false);
  7504. vbat->adc_config = true;
  7505. }
  7506. }
  7507. static int tasha_update_vbat_reg_config(struct snd_soc_component *component)
  7508. {
  7509. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  7510. struct firmware_cal *hwdep_cal = NULL;
  7511. struct vbat_monitor_reg *vbat_reg_ptr = NULL;
  7512. const void *data;
  7513. size_t cal_size, vbat_size_remaining;
  7514. int ret = 0, i;
  7515. u32 vbat_writes_size = 0;
  7516. u16 reg;
  7517. u8 mask, val, old_val;
  7518. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_VBAT_CAL);
  7519. if (hwdep_cal) {
  7520. data = hwdep_cal->data;
  7521. cal_size = hwdep_cal->size;
  7522. dev_dbg(component->dev, "%s: using hwdep calibration\n",
  7523. __func__);
  7524. } else {
  7525. dev_err(component->dev, "%s: Vbat cal not received\n",
  7526. __func__);
  7527. ret = -EINVAL;
  7528. goto done;
  7529. }
  7530. if (cal_size < sizeof(*vbat_reg_ptr)) {
  7531. dev_err(component->dev,
  7532. "%s: Incorrect size %zd for Vbat Cal, expected %zd\n",
  7533. __func__, cal_size, sizeof(*vbat_reg_ptr));
  7534. ret = -EINVAL;
  7535. goto done;
  7536. }
  7537. vbat_reg_ptr = (struct vbat_monitor_reg *) (data);
  7538. if (!vbat_reg_ptr) {
  7539. dev_err(component->dev,
  7540. "%s: Invalid calibration data for Vbat\n",
  7541. __func__);
  7542. ret = -EINVAL;
  7543. goto done;
  7544. }
  7545. vbat_writes_size = vbat_reg_ptr->size;
  7546. vbat_size_remaining = cal_size - sizeof(u32);
  7547. dev_dbg(component->dev, "%s: vbat_writes_sz: %d, vbat_sz_remaining: %zd\n",
  7548. __func__, vbat_writes_size, vbat_size_remaining);
  7549. if ((vbat_writes_size * TASHA_PACKED_REG_SIZE)
  7550. > vbat_size_remaining) {
  7551. pr_err("%s: Incorrect Vbat calibration data\n", __func__);
  7552. ret = -EINVAL;
  7553. goto done;
  7554. }
  7555. for (i = 0 ; i < vbat_writes_size; i++) {
  7556. TASHA_CODEC_UNPACK_ENTRY(vbat_reg_ptr->writes[i],
  7557. reg, mask, val);
  7558. old_val = snd_soc_component_read32(component, reg);
  7559. snd_soc_component_write(component, reg, (old_val & ~mask) |
  7560. (val & mask));
  7561. }
  7562. done:
  7563. return ret;
  7564. }
  7565. static int tasha_vbat_adc_data_get(struct snd_kcontrol *kcontrol,
  7566. struct snd_ctl_elem_value *ucontrol)
  7567. {
  7568. struct snd_soc_component *component =
  7569. snd_soc_kcontrol_component(kcontrol);
  7570. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  7571. wcd_vbat_adc_out_config(&tasha->vbat, component);
  7572. ucontrol->value.integer.value[0] = tasha->vbat.dcp1;
  7573. ucontrol->value.integer.value[1] = tasha->vbat.dcp2;
  7574. dev_dbg(component->dev,
  7575. "%s: Vbat ADC output values, Dcp1 : %lu, Dcp2: %lu\n",
  7576. __func__, ucontrol->value.integer.value[0],
  7577. ucontrol->value.integer.value[1]);
  7578. return 0;
  7579. }
  7580. static const char * const tasha_vbat_gsm_mode_text[] = {
  7581. "OFF", "ON"};
  7582. static const struct soc_enum tasha_vbat_gsm_mode_enum =
  7583. SOC_ENUM_SINGLE_EXT(2, tasha_vbat_gsm_mode_text);
  7584. static int tasha_vbat_gsm_mode_func_get(struct snd_kcontrol *kcontrol,
  7585. struct snd_ctl_elem_value *ucontrol)
  7586. {
  7587. struct snd_soc_component *component =
  7588. snd_soc_kcontrol_component(kcontrol);
  7589. ucontrol->value.integer.value[0] =
  7590. ((snd_soc_component_read32(
  7591. component, WCD9335_CDC_VBAT_VBAT_CFG) & 0x04) ? 1 : 0);
  7592. dev_dbg(component->dev, "%s: value: %lu\n", __func__,
  7593. ucontrol->value.integer.value[0]);
  7594. return 0;
  7595. }
  7596. static int tasha_vbat_gsm_mode_func_put(struct snd_kcontrol *kcontrol,
  7597. struct snd_ctl_elem_value *ucontrol)
  7598. {
  7599. struct snd_soc_component *component =
  7600. snd_soc_kcontrol_component(kcontrol);
  7601. dev_dbg(component->dev, "%s: value: %lu\n", __func__,
  7602. ucontrol->value.integer.value[0]);
  7603. /* Set Vbat register configuration for GSM mode bit based on value */
  7604. if (ucontrol->value.integer.value[0])
  7605. snd_soc_component_update_bits(component,
  7606. WCD9335_CDC_VBAT_VBAT_CFG,
  7607. 0x04, 0x04);
  7608. else
  7609. snd_soc_component_update_bits(component,
  7610. WCD9335_CDC_VBAT_VBAT_CFG,
  7611. 0x04, 0x00);
  7612. return 0;
  7613. }
  7614. static int tasha_codec_vbat_enable_event(struct snd_soc_dapm_widget *w,
  7615. struct snd_kcontrol *kcontrol,
  7616. int event)
  7617. {
  7618. int ret = 0;
  7619. struct snd_soc_component *component =
  7620. snd_soc_dapm_to_component(w->dapm);
  7621. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  7622. u16 vbat_path_ctl, vbat_cfg, vbat_path_cfg;
  7623. vbat_path_ctl = WCD9335_CDC_VBAT_VBAT_PATH_CTL;
  7624. vbat_cfg = WCD9335_CDC_VBAT_VBAT_CFG;
  7625. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7626. if (!strcmp(w->name, "RX INT8 VBAT"))
  7627. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7628. else if (!strcmp(w->name, "RX INT7 VBAT"))
  7629. vbat_path_cfg = WCD9335_CDC_RX7_RX_PATH_CFG1;
  7630. else if (!strcmp(w->name, "RX INT6 VBAT"))
  7631. vbat_path_cfg = WCD9335_CDC_RX6_RX_PATH_CFG1;
  7632. else if (!strcmp(w->name, "RX INT5 VBAT"))
  7633. vbat_path_cfg = WCD9335_CDC_RX5_RX_PATH_CFG1;
  7634. switch (event) {
  7635. case SND_SOC_DAPM_PRE_PMU:
  7636. ret = tasha_update_vbat_reg_config(component);
  7637. if (ret) {
  7638. dev_dbg(component->dev,
  7639. "%s : VBAT isn't calibrated, So not enabling it\n",
  7640. __func__);
  7641. return 0;
  7642. }
  7643. snd_soc_component_write(component, WCD9335_ANA_VBADC, 0x80);
  7644. snd_soc_component_update_bits(component, vbat_path_cfg,
  7645. 0x02, 0x02);
  7646. snd_soc_component_update_bits(component, vbat_path_ctl,
  7647. 0x10, 0x10);
  7648. snd_soc_component_update_bits(component, vbat_cfg, 0x01, 0x01);
  7649. tasha->vbat.is_enabled = true;
  7650. break;
  7651. case SND_SOC_DAPM_POST_PMD:
  7652. if (tasha->vbat.is_enabled) {
  7653. snd_soc_component_update_bits(component, vbat_cfg,
  7654. 0x01, 0x00);
  7655. snd_soc_component_update_bits(component, vbat_path_ctl,
  7656. 0x10, 0x00);
  7657. snd_soc_component_update_bits(component, vbat_path_cfg,
  7658. 0x02, 0x00);
  7659. snd_soc_component_write(component, WCD9335_ANA_VBADC,
  7660. 0x00);
  7661. tasha->vbat.is_enabled = false;
  7662. }
  7663. break;
  7664. };
  7665. return ret;
  7666. }
  7667. static const char * const rx_hph_mode_mux_text[] = {
  7668. "CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI"
  7669. };
  7670. static const struct soc_enum rx_hph_mode_mux_enum =
  7671. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text),
  7672. rx_hph_mode_mux_text);
  7673. static const char * const amic_pwr_lvl_text[] = {
  7674. "LOW_PWR", "DEFAULT", "HIGH_PERF"
  7675. };
  7676. static const struct soc_enum amic_pwr_lvl_enum =
  7677. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amic_pwr_lvl_text),
  7678. amic_pwr_lvl_text);
  7679. static const struct snd_kcontrol_new tasha_snd_controls[] = {
  7680. SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
  7681. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7682. SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
  7683. 0, -84, 40, digital_gain),
  7684. SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
  7685. 0, -84, 40, digital_gain),
  7686. SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
  7687. 0, -84, 40, digital_gain),
  7688. SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
  7689. 0, -84, 40, digital_gain),
  7690. SOC_SINGLE_SX_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
  7691. 0, -84, 40, digital_gain),
  7692. SOC_SINGLE_SX_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
  7693. 0, -84, 40, digital_gain),
  7694. SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
  7695. 0, -84, 40, digital_gain),
  7696. SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
  7697. 0, -84, 40, digital_gain),
  7698. SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
  7699. WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
  7700. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7701. SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
  7702. WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
  7703. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7704. SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
  7705. WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
  7706. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7707. SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
  7708. WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
  7709. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7710. SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
  7711. WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
  7712. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7713. SOC_SINGLE_SX_TLV("RX5 Mix Digital Volume",
  7714. WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
  7715. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7716. SOC_SINGLE_SX_TLV("RX6 Mix Digital Volume",
  7717. WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
  7718. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7719. SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
  7720. WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
  7721. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7722. SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
  7723. WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
  7724. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7725. SOC_SINGLE_SX_TLV("DEC0 Volume", WCD9335_CDC_TX0_TX_VOL_CTL, 0,
  7726. -84, 40, digital_gain),
  7727. SOC_SINGLE_SX_TLV("DEC1 Volume", WCD9335_CDC_TX1_TX_VOL_CTL, 0,
  7728. -84, 40, digital_gain),
  7729. SOC_SINGLE_SX_TLV("DEC2 Volume", WCD9335_CDC_TX2_TX_VOL_CTL, 0,
  7730. -84, 40, digital_gain),
  7731. SOC_SINGLE_SX_TLV("DEC3 Volume", WCD9335_CDC_TX3_TX_VOL_CTL, 0,
  7732. -84, 40, digital_gain),
  7733. SOC_SINGLE_SX_TLV("DEC4 Volume", WCD9335_CDC_TX4_TX_VOL_CTL, 0,
  7734. -84, 40, digital_gain),
  7735. SOC_SINGLE_SX_TLV("DEC5 Volume", WCD9335_CDC_TX5_TX_VOL_CTL, 0,
  7736. -84, 40, digital_gain),
  7737. SOC_SINGLE_SX_TLV("DEC6 Volume", WCD9335_CDC_TX6_TX_VOL_CTL, 0,
  7738. -84, 40, digital_gain),
  7739. SOC_SINGLE_SX_TLV("DEC7 Volume", WCD9335_CDC_TX7_TX_VOL_CTL, 0,
  7740. -84, 40, digital_gain),
  7741. SOC_SINGLE_SX_TLV("DEC8 Volume", WCD9335_CDC_TX8_TX_VOL_CTL, 0,
  7742. -84, 40, digital_gain),
  7743. SOC_SINGLE_SX_TLV("IIR0 INP0 Volume",
  7744. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, -84,
  7745. 40, digital_gain),
  7746. SOC_SINGLE_SX_TLV("IIR0 INP1 Volume",
  7747. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, -84,
  7748. 40, digital_gain),
  7749. SOC_SINGLE_SX_TLV("IIR0 INP2 Volume",
  7750. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, -84,
  7751. 40, digital_gain),
  7752. SOC_SINGLE_SX_TLV("IIR0 INP3 Volume",
  7753. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, -84,
  7754. 40, digital_gain),
  7755. SOC_SINGLE_SX_TLV("IIR1 INP0 Volume",
  7756. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, -84,
  7757. 40, digital_gain),
  7758. SOC_SINGLE_SX_TLV("IIR1 INP1 Volume",
  7759. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, -84,
  7760. 40, digital_gain),
  7761. SOC_SINGLE_SX_TLV("IIR1 INP2 Volume",
  7762. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, -84,
  7763. 40, digital_gain),
  7764. SOC_SINGLE_SX_TLV("IIR1 INP3 Volume",
  7765. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, -84,
  7766. 40, digital_gain),
  7767. SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 100, 0, tasha_get_anc_slot,
  7768. tasha_put_anc_slot),
  7769. SOC_ENUM_EXT("ANC Function", tasha_anc_func_enum, tasha_get_anc_func,
  7770. tasha_put_anc_func),
  7771. SOC_ENUM_EXT("CLK MODE", tasha_clkmode_enum, tasha_get_clkmode,
  7772. tasha_put_clkmode),
  7773. SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
  7774. SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
  7775. SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
  7776. SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
  7777. SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
  7778. SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
  7779. SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
  7780. SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
  7781. SOC_ENUM("TX8 HPF cut off", cf_dec8_enum),
  7782. SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
  7783. SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
  7784. SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
  7785. SOC_ENUM("RX INT1_2 HPF cut off", cf_int1_2_enum),
  7786. SOC_ENUM("RX INT2_1 HPF cut off", cf_int2_1_enum),
  7787. SOC_ENUM("RX INT2_2 HPF cut off", cf_int2_2_enum),
  7788. SOC_ENUM("RX INT3_1 HPF cut off", cf_int3_1_enum),
  7789. SOC_ENUM("RX INT3_2 HPF cut off", cf_int3_2_enum),
  7790. SOC_ENUM("RX INT4_1 HPF cut off", cf_int4_1_enum),
  7791. SOC_ENUM("RX INT4_2 HPF cut off", cf_int4_2_enum),
  7792. SOC_ENUM("RX INT5_1 HPF cut off", cf_int5_1_enum),
  7793. SOC_ENUM("RX INT5_2 HPF cut off", cf_int5_2_enum),
  7794. SOC_ENUM("RX INT6_1 HPF cut off", cf_int6_1_enum),
  7795. SOC_ENUM("RX INT6_2 HPF cut off", cf_int6_2_enum),
  7796. SOC_ENUM("RX INT7_1 HPF cut off", cf_int7_1_enum),
  7797. SOC_ENUM("RX INT7_2 HPF cut off", cf_int7_2_enum),
  7798. SOC_ENUM("RX INT8_1 HPF cut off", cf_int8_1_enum),
  7799. SOC_ENUM("RX INT8_2 HPF cut off", cf_int8_2_enum),
  7800. SOC_SINGLE_EXT("IIR0 Enable Band1", IIR0, BAND1, 1, 0,
  7801. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7802. SOC_SINGLE_EXT("IIR0 Enable Band2", IIR0, BAND2, 1, 0,
  7803. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7804. SOC_SINGLE_EXT("IIR0 Enable Band3", IIR0, BAND3, 1, 0,
  7805. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7806. SOC_SINGLE_EXT("IIR0 Enable Band4", IIR0, BAND4, 1, 0,
  7807. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7808. SOC_SINGLE_EXT("IIR0 Enable Band5", IIR0, BAND5, 1, 0,
  7809. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7810. SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0,
  7811. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7812. SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
  7813. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7814. SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
  7815. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7816. SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
  7817. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7818. SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
  7819. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7820. SOC_SINGLE_MULTI_EXT("IIR0 Band1", IIR0, BAND1, 255, 0, 5,
  7821. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7822. SOC_SINGLE_MULTI_EXT("IIR0 Band2", IIR0, BAND2, 255, 0, 5,
  7823. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7824. SOC_SINGLE_MULTI_EXT("IIR0 Band3", IIR0, BAND3, 255, 0, 5,
  7825. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7826. SOC_SINGLE_MULTI_EXT("IIR0 Band4", IIR0, BAND4, 255, 0, 5,
  7827. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7828. SOC_SINGLE_MULTI_EXT("IIR0 Band5", IIR0, BAND5, 255, 0, 5,
  7829. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7830. SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
  7831. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7832. SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
  7833. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7834. SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
  7835. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7836. SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
  7837. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7838. SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
  7839. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7840. SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0,
  7841. tasha_get_compander, tasha_set_compander),
  7842. SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0,
  7843. tasha_get_compander, tasha_set_compander),
  7844. SOC_SINGLE_EXT("COMP3 Switch", SND_SOC_NOPM, COMPANDER_3, 1, 0,
  7845. tasha_get_compander, tasha_set_compander),
  7846. SOC_SINGLE_EXT("COMP4 Switch", SND_SOC_NOPM, COMPANDER_4, 1, 0,
  7847. tasha_get_compander, tasha_set_compander),
  7848. SOC_SINGLE_EXT("COMP5 Switch", SND_SOC_NOPM, COMPANDER_5, 1, 0,
  7849. tasha_get_compander, tasha_set_compander),
  7850. SOC_SINGLE_EXT("COMP6 Switch", SND_SOC_NOPM, COMPANDER_6, 1, 0,
  7851. tasha_get_compander, tasha_set_compander),
  7852. SOC_SINGLE_EXT("COMP7 Switch", SND_SOC_NOPM, COMPANDER_7, 1, 0,
  7853. tasha_get_compander, tasha_set_compander),
  7854. SOC_SINGLE_EXT("COMP8 Switch", SND_SOC_NOPM, COMPANDER_8, 1, 0,
  7855. tasha_get_compander, tasha_set_compander),
  7856. SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum,
  7857. tasha_rx_hph_mode_get, tasha_rx_hph_mode_put),
  7858. SOC_ENUM_EXT("MAD Input", tasha_conn_mad_enum,
  7859. tasha_mad_input_get, tasha_mad_input_put),
  7860. SOC_SINGLE_EXT("LDO_H Enable", SND_SOC_NOPM, 0, 1, 0,
  7861. tasha_enable_ldo_h_get, tasha_enable_ldo_h_put),
  7862. SOC_SINGLE_EXT("DMIC1_CLK_PIN_MODE", SND_SOC_NOPM, 17, 1, 0,
  7863. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7864. SOC_SINGLE_EXT("DMIC1_DATA_PIN_MODE", SND_SOC_NOPM, 18, 1, 0,
  7865. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7866. SOC_SINGLE_EXT("DMIC2_CLK_PIN_MODE", SND_SOC_NOPM, 19, 1, 0,
  7867. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7868. SOC_SINGLE_EXT("DMIC2_DATA_PIN_MODE", SND_SOC_NOPM, 20, 1, 0,
  7869. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7870. SOC_SINGLE_EXT("DMIC3_CLK_PIN_MODE", SND_SOC_NOPM, 21, 1, 0,
  7871. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7872. SOC_SINGLE_EXT("DMIC3_DATA_PIN_MODE", SND_SOC_NOPM, 22, 1, 0,
  7873. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7874. SOC_ENUM_EXT("AMIC_1_2 PWR MODE", amic_pwr_lvl_enum,
  7875. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7876. SOC_ENUM_EXT("AMIC_3_4 PWR MODE", amic_pwr_lvl_enum,
  7877. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7878. SOC_ENUM_EXT("AMIC_5_6 PWR MODE", amic_pwr_lvl_enum,
  7879. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7880. SOC_SINGLE_MULTI_EXT("Vbat ADC data", SND_SOC_NOPM, 0, 0xFFFF, 0, 2,
  7881. tasha_vbat_adc_data_get, NULL),
  7882. SOC_ENUM_EXT("GSM mode Enable", tasha_vbat_gsm_mode_enum,
  7883. tasha_vbat_gsm_mode_func_get,
  7884. tasha_vbat_gsm_mode_func_put),
  7885. };
  7886. static int tasha_put_dec_enum(struct snd_kcontrol *kcontrol,
  7887. struct snd_ctl_elem_value *ucontrol)
  7888. {
  7889. struct snd_soc_dapm_widget *widget =
  7890. snd_soc_dapm_kcontrol_widget(kcontrol);
  7891. struct snd_soc_component *component =
  7892. snd_soc_dapm_to_component(widget->dapm);
  7893. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7894. unsigned int val;
  7895. u16 mic_sel_reg;
  7896. u8 mic_sel;
  7897. val = ucontrol->value.enumerated.item[0];
  7898. if (val > e->items - 1)
  7899. return -EINVAL;
  7900. dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7901. widget->name, val);
  7902. switch (e->reg) {
  7903. case WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1:
  7904. mic_sel_reg = WCD9335_CDC_TX0_TX_PATH_CFG0;
  7905. break;
  7906. case WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1:
  7907. mic_sel_reg = WCD9335_CDC_TX1_TX_PATH_CFG0;
  7908. break;
  7909. case WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1:
  7910. mic_sel_reg = WCD9335_CDC_TX2_TX_PATH_CFG0;
  7911. break;
  7912. case WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1:
  7913. mic_sel_reg = WCD9335_CDC_TX3_TX_PATH_CFG0;
  7914. break;
  7915. case WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0:
  7916. mic_sel_reg = WCD9335_CDC_TX4_TX_PATH_CFG0;
  7917. break;
  7918. case WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0:
  7919. mic_sel_reg = WCD9335_CDC_TX5_TX_PATH_CFG0;
  7920. break;
  7921. case WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0:
  7922. mic_sel_reg = WCD9335_CDC_TX6_TX_PATH_CFG0;
  7923. break;
  7924. case WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0:
  7925. mic_sel_reg = WCD9335_CDC_TX7_TX_PATH_CFG0;
  7926. break;
  7927. case WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0:
  7928. mic_sel_reg = WCD9335_CDC_TX8_TX_PATH_CFG0;
  7929. break;
  7930. default:
  7931. dev_err(component->dev, "%s: e->reg: 0x%x not expected\n",
  7932. __func__, e->reg);
  7933. return -EINVAL;
  7934. }
  7935. /* ADC: 0, DMIC: 1 */
  7936. mic_sel = val ? 0x0 : 0x1;
  7937. snd_soc_component_update_bits(component, mic_sel_reg,
  7938. 1 << 7, mic_sel << 7);
  7939. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7940. }
  7941. static int tasha_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol,
  7942. struct snd_ctl_elem_value *ucontrol)
  7943. {
  7944. struct snd_soc_dapm_widget *widget =
  7945. snd_soc_dapm_kcontrol_widget(kcontrol);
  7946. struct snd_soc_component *component =
  7947. snd_soc_dapm_to_component(widget->dapm);
  7948. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7949. unsigned int val;
  7950. unsigned short look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7951. val = ucontrol->value.enumerated.item[0];
  7952. if (val >= e->items)
  7953. return -EINVAL;
  7954. dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7955. widget->name, val);
  7956. if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0)
  7957. look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7958. else if (e->reg == WCD9335_CDC_RX1_RX_PATH_SEC0)
  7959. look_ahead_dly_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  7960. else if (e->reg == WCD9335_CDC_RX2_RX_PATH_SEC0)
  7961. look_ahead_dly_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  7962. /* Set Look Ahead Delay */
  7963. snd_soc_component_update_bits(component, look_ahead_dly_reg,
  7964. 0x08, (val ? 0x08 : 0x00));
  7965. /* Set DEM INP Select */
  7966. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7967. }
  7968. static int tasha_ear_pa_gain_get(struct snd_kcontrol *kcontrol,
  7969. struct snd_ctl_elem_value *ucontrol)
  7970. {
  7971. u8 ear_pa_gain;
  7972. struct snd_soc_component *component =
  7973. snd_soc_kcontrol_component(kcontrol);
  7974. ear_pa_gain = snd_soc_component_read32(component, WCD9335_ANA_EAR);
  7975. ear_pa_gain = (ear_pa_gain & 0x70) >> 4;
  7976. ucontrol->value.integer.value[0] = ear_pa_gain;
  7977. dev_dbg(component->dev, "%s: ear_pa_gain = 0x%x\n", __func__,
  7978. ear_pa_gain);
  7979. return 0;
  7980. }
  7981. static int tasha_ear_pa_gain_put(struct snd_kcontrol *kcontrol,
  7982. struct snd_ctl_elem_value *ucontrol)
  7983. {
  7984. u8 ear_pa_gain;
  7985. struct snd_soc_component *component =
  7986. snd_soc_kcontrol_component(kcontrol);
  7987. dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7988. __func__, ucontrol->value.integer.value[0]);
  7989. ear_pa_gain = ucontrol->value.integer.value[0] << 4;
  7990. snd_soc_component_update_bits(component, WCD9335_ANA_EAR,
  7991. 0x70, ear_pa_gain);
  7992. return 0;
  7993. }
  7994. static int tasha_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
  7995. struct snd_ctl_elem_value *ucontrol)
  7996. {
  7997. struct snd_soc_component *component =
  7998. snd_soc_kcontrol_component(kcontrol);
  7999. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  8000. ucontrol->value.integer.value[0] = tasha->ear_spkr_gain;
  8001. dev_dbg(component->dev, "%s: ear_spkr_gain = %ld\n", __func__,
  8002. ucontrol->value.integer.value[0]);
  8003. return 0;
  8004. }
  8005. static int tasha_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
  8006. struct snd_ctl_elem_value *ucontrol)
  8007. {
  8008. struct snd_soc_component *component =
  8009. snd_soc_kcontrol_component(kcontrol);
  8010. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  8011. dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  8012. __func__, ucontrol->value.integer.value[0]);
  8013. tasha->ear_spkr_gain = ucontrol->value.integer.value[0];
  8014. return 0;
  8015. }
  8016. static int tasha_spkr_left_boost_stage_get(struct snd_kcontrol *kcontrol,
  8017. struct snd_ctl_elem_value *ucontrol)
  8018. {
  8019. u8 bst_state_max = 0;
  8020. struct snd_soc_component *component =
  8021. snd_soc_kcontrol_component(kcontrol);
  8022. bst_state_max = snd_soc_component_read32(
  8023. component, WCD9335_CDC_BOOST0_BOOST_CTL);
  8024. bst_state_max = (bst_state_max & 0x0c) >> 2;
  8025. ucontrol->value.integer.value[0] = bst_state_max;
  8026. dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  8027. __func__, ucontrol->value.integer.value[0]);
  8028. return 0;
  8029. }
  8030. static int tasha_spkr_left_boost_stage_put(struct snd_kcontrol *kcontrol,
  8031. struct snd_ctl_elem_value *ucontrol)
  8032. {
  8033. u8 bst_state_max;
  8034. struct snd_soc_component *component =
  8035. snd_soc_kcontrol_component(kcontrol);
  8036. dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  8037. __func__, ucontrol->value.integer.value[0]);
  8038. bst_state_max = ucontrol->value.integer.value[0] << 2;
  8039. snd_soc_component_update_bits(component, WCD9335_CDC_BOOST0_BOOST_CTL,
  8040. 0x0c, bst_state_max);
  8041. return 0;
  8042. }
  8043. static int tasha_spkr_right_boost_stage_get(struct snd_kcontrol *kcontrol,
  8044. struct snd_ctl_elem_value *ucontrol)
  8045. {
  8046. u8 bst_state_max = 0;
  8047. struct snd_soc_component *component =
  8048. snd_soc_kcontrol_component(kcontrol);
  8049. bst_state_max = snd_soc_component_read32(
  8050. component, WCD9335_CDC_BOOST1_BOOST_CTL);
  8051. bst_state_max = (bst_state_max & 0x0c) >> 2;
  8052. ucontrol->value.integer.value[0] = bst_state_max;
  8053. dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  8054. __func__, ucontrol->value.integer.value[0]);
  8055. return 0;
  8056. }
  8057. static int tasha_spkr_right_boost_stage_put(struct snd_kcontrol *kcontrol,
  8058. struct snd_ctl_elem_value *ucontrol)
  8059. {
  8060. u8 bst_state_max;
  8061. struct snd_soc_component *component =
  8062. snd_soc_kcontrol_component(kcontrol);
  8063. dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  8064. __func__, ucontrol->value.integer.value[0]);
  8065. bst_state_max = ucontrol->value.integer.value[0] << 2;
  8066. snd_soc_component_update_bits(component, WCD9335_CDC_BOOST1_BOOST_CTL,
  8067. 0x0c, bst_state_max);
  8068. return 0;
  8069. }
  8070. static int tasha_config_compander(struct snd_soc_component *component,
  8071. int interp_n, int event)
  8072. {
  8073. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  8074. int comp;
  8075. u16 comp_ctl0_reg, rx_path_cfg0_reg;
  8076. /* EAR does not have compander */
  8077. if (!interp_n)
  8078. return 0;
  8079. comp = interp_n - 1;
  8080. dev_dbg(component->dev, "%s: event %d compander %d, enabled %d\n",
  8081. __func__, event, comp + 1, tasha->comp_enabled[comp]);
  8082. if (!tasha->comp_enabled[comp])
  8083. return 0;
  8084. comp_ctl0_reg = WCD9335_CDC_COMPANDER1_CTL0 + (comp * 8);
  8085. rx_path_cfg0_reg = WCD9335_CDC_RX1_RX_PATH_CFG0 + (comp * 20);
  8086. if (SND_SOC_DAPM_EVENT_ON(event)) {
  8087. /* Enable Compander Clock */
  8088. snd_soc_component_update_bits(component, comp_ctl0_reg,
  8089. 0x01, 0x01);
  8090. snd_soc_component_update_bits(component, comp_ctl0_reg,
  8091. 0x02, 0x02);
  8092. snd_soc_component_update_bits(component, comp_ctl0_reg,
  8093. 0x02, 0x00);
  8094. snd_soc_component_update_bits(component, rx_path_cfg0_reg,
  8095. 0x02, 0x02);
  8096. }
  8097. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  8098. snd_soc_component_update_bits(component, comp_ctl0_reg,
  8099. 0x04, 0x04);
  8100. snd_soc_component_update_bits(component, rx_path_cfg0_reg,
  8101. 0x02, 0x00);
  8102. snd_soc_component_update_bits(component, comp_ctl0_reg,
  8103. 0x02, 0x02);
  8104. snd_soc_component_update_bits(component, comp_ctl0_reg,
  8105. 0x02, 0x00);
  8106. snd_soc_component_update_bits(component, comp_ctl0_reg,
  8107. 0x01, 0x00);
  8108. snd_soc_component_update_bits(component, comp_ctl0_reg,
  8109. 0x04, 0x00);
  8110. }
  8111. return 0;
  8112. }
  8113. static int tasha_codec_config_mad(struct snd_soc_component *component)
  8114. {
  8115. int ret = 0;
  8116. int idx;
  8117. const struct firmware *fw;
  8118. struct firmware_cal *hwdep_cal = NULL;
  8119. struct wcd_mad_audio_cal *mad_cal = NULL;
  8120. const void *data;
  8121. const char *filename = TASHA_MAD_AUDIO_FIRMWARE_PATH;
  8122. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  8123. size_t cal_size;
  8124. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_MAD_CAL);
  8125. if (hwdep_cal) {
  8126. data = hwdep_cal->data;
  8127. cal_size = hwdep_cal->size;
  8128. dev_dbg(component->dev, "%s: using hwdep calibration\n",
  8129. __func__);
  8130. } else {
  8131. ret = request_firmware(&fw, filename, component->dev);
  8132. if (ret || !fw) {
  8133. dev_err(component->dev,
  8134. "%s: MAD firmware acquire failed, err = %d\n",
  8135. __func__, ret);
  8136. return -ENODEV;
  8137. }
  8138. data = fw->data;
  8139. cal_size = fw->size;
  8140. dev_dbg(component->dev, "%s: using request_firmware calibration\n",
  8141. __func__);
  8142. }
  8143. if (cal_size < sizeof(*mad_cal)) {
  8144. dev_err(component->dev,
  8145. "%s: Incorrect size %zd for MAD Cal, expected %zd\n",
  8146. __func__, cal_size, sizeof(*mad_cal));
  8147. ret = -ENOMEM;
  8148. goto done;
  8149. }
  8150. mad_cal = (struct wcd_mad_audio_cal *) (data);
  8151. if (!mad_cal) {
  8152. dev_err(component->dev,
  8153. "%s: Invalid calibration data\n",
  8154. __func__);
  8155. ret = -EINVAL;
  8156. goto done;
  8157. }
  8158. snd_soc_component_write(component, WCD9335_SOC_MAD_MAIN_CTL_2,
  8159. mad_cal->microphone_info.cycle_time);
  8160. snd_soc_component_update_bits(component, WCD9335_SOC_MAD_MAIN_CTL_1,
  8161. 0xFF << 3,
  8162. ((uint16_t)mad_cal->microphone_info.settle_time) << 3);
  8163. /* Audio */
  8164. snd_soc_component_write(component, WCD9335_SOC_MAD_AUDIO_CTL_8,
  8165. mad_cal->audio_info.rms_omit_samples);
  8166. snd_soc_component_update_bits(component, WCD9335_SOC_MAD_AUDIO_CTL_1,
  8167. 0x07 << 4, mad_cal->audio_info.rms_comp_time << 4);
  8168. snd_soc_component_update_bits(component, WCD9335_SOC_MAD_AUDIO_CTL_2,
  8169. 0x03 << 2,
  8170. mad_cal->audio_info.detection_mechanism << 2);
  8171. snd_soc_component_write(component, WCD9335_SOC_MAD_AUDIO_CTL_7,
  8172. mad_cal->audio_info.rms_diff_threshold & 0x3F);
  8173. snd_soc_component_write(component, WCD9335_SOC_MAD_AUDIO_CTL_5,
  8174. mad_cal->audio_info.rms_threshold_lsb);
  8175. snd_soc_component_write(component, WCD9335_SOC_MAD_AUDIO_CTL_6,
  8176. mad_cal->audio_info.rms_threshold_msb);
  8177. for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients);
  8178. idx++) {
  8179. snd_soc_component_update_bits(component,
  8180. WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR, 0x3F, idx);
  8181. snd_soc_component_write(component,
  8182. WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL,
  8183. mad_cal->audio_info.iir_coefficients[idx]);
  8184. dev_dbg(component->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x",
  8185. __func__, idx,
  8186. mad_cal->audio_info.iir_coefficients[idx]);
  8187. }
  8188. /* Beacon */
  8189. snd_soc_component_write(component, WCD9335_SOC_MAD_BEACON_CTL_8,
  8190. mad_cal->beacon_info.rms_omit_samples);
  8191. snd_soc_component_update_bits(component, WCD9335_SOC_MAD_BEACON_CTL_1,
  8192. 0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4);
  8193. snd_soc_component_update_bits(component, WCD9335_SOC_MAD_BEACON_CTL_2,
  8194. 0x03 << 2,
  8195. mad_cal->beacon_info.detection_mechanism << 2);
  8196. snd_soc_component_write(component, WCD9335_SOC_MAD_BEACON_CTL_7,
  8197. mad_cal->beacon_info.rms_diff_threshold & 0x1F);
  8198. snd_soc_component_write(component, WCD9335_SOC_MAD_BEACON_CTL_5,
  8199. mad_cal->beacon_info.rms_threshold_lsb);
  8200. snd_soc_component_write(component, WCD9335_SOC_MAD_BEACON_CTL_6,
  8201. mad_cal->beacon_info.rms_threshold_msb);
  8202. for (idx = 0; idx < ARRAY_SIZE(mad_cal->beacon_info.iir_coefficients);
  8203. idx++) {
  8204. snd_soc_component_update_bits(component,
  8205. WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR,
  8206. 0x3F, idx);
  8207. snd_soc_component_write(component,
  8208. WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL,
  8209. mad_cal->beacon_info.iir_coefficients[idx]);
  8210. dev_dbg(component->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x",
  8211. __func__, idx,
  8212. mad_cal->beacon_info.iir_coefficients[idx]);
  8213. }
  8214. /* Ultrasound */
  8215. snd_soc_component_update_bits(component, WCD9335_SOC_MAD_ULTR_CTL_1,
  8216. 0x07 << 4,
  8217. mad_cal->ultrasound_info.rms_comp_time << 4);
  8218. snd_soc_component_update_bits(component, WCD9335_SOC_MAD_ULTR_CTL_2,
  8219. 0x03 << 2,
  8220. mad_cal->ultrasound_info.detection_mechanism << 2);
  8221. snd_soc_component_write(component, WCD9335_SOC_MAD_ULTR_CTL_7,
  8222. mad_cal->ultrasound_info.rms_diff_threshold & 0x1F);
  8223. snd_soc_component_write(component, WCD9335_SOC_MAD_ULTR_CTL_5,
  8224. mad_cal->ultrasound_info.rms_threshold_lsb);
  8225. snd_soc_component_write(component, WCD9335_SOC_MAD_ULTR_CTL_6,
  8226. mad_cal->ultrasound_info.rms_threshold_msb);
  8227. done:
  8228. if (!hwdep_cal)
  8229. release_firmware(fw);
  8230. return ret;
  8231. }
  8232. static int tasha_codec_enable_mad(struct snd_soc_dapm_widget *w,
  8233. struct snd_kcontrol *kcontrol, int event)
  8234. {
  8235. struct snd_soc_component *component =
  8236. snd_soc_dapm_to_component(w->dapm);
  8237. int ret = 0;
  8238. dev_dbg(component->dev,
  8239. "%s: event = %d\n", __func__, event);
  8240. /* Return if CPE INPUT is DEC1 */
  8241. if (snd_soc_component_read32(component, WCD9335_CPE_SS_SVA_CFG) & 0x01)
  8242. return ret;
  8243. switch (event) {
  8244. case SND_SOC_DAPM_PRE_PMU:
  8245. /* Turn on MAD clk */
  8246. snd_soc_component_update_bits(component, WCD9335_CPE_SS_MAD_CTL,
  8247. 0x01, 0x01);
  8248. /* Undo reset for MAD */
  8249. snd_soc_component_update_bits(component, WCD9335_CPE_SS_MAD_CTL,
  8250. 0x02, 0x00);
  8251. ret = tasha_codec_config_mad(component);
  8252. if (ret)
  8253. dev_err(component->dev,
  8254. "%s: Failed to config MAD, err = %d\n",
  8255. __func__, ret);
  8256. break;
  8257. case SND_SOC_DAPM_POST_PMD:
  8258. /* Reset the MAD block */
  8259. snd_soc_component_update_bits(component, WCD9335_CPE_SS_MAD_CTL,
  8260. 0x02, 0x02);
  8261. /* Turn off MAD clk */
  8262. snd_soc_component_update_bits(component, WCD9335_CPE_SS_MAD_CTL,
  8263. 0x01, 0x00);
  8264. break;
  8265. }
  8266. return ret;
  8267. }
  8268. static int tasha_codec_configure_cpe_input(struct snd_soc_dapm_widget *w,
  8269. struct snd_kcontrol *kcontrol, int event)
  8270. {
  8271. struct snd_soc_component *component =
  8272. snd_soc_dapm_to_component(w->dapm);
  8273. dev_dbg(component->dev,
  8274. "%s: event = %d\n", __func__, event);
  8275. switch (event) {
  8276. case SND_SOC_DAPM_PRE_PMU:
  8277. /* Configure CPE input as DEC1 */
  8278. snd_soc_component_update_bits(component, WCD9335_CPE_SS_SVA_CFG,
  8279. 0x01, 0x01);
  8280. /* Configure DEC1 Tx out with sample rate as 16K */
  8281. snd_soc_component_update_bits(component,
  8282. WCD9335_CDC_TX1_TX_PATH_CTL,
  8283. 0x0F, 0x01);
  8284. break;
  8285. case SND_SOC_DAPM_POST_PMD:
  8286. /* Reset DEC1 Tx out sample rate */
  8287. snd_soc_component_update_bits(component,
  8288. WCD9335_CDC_TX1_TX_PATH_CTL,
  8289. 0x0F, 0x04);
  8290. snd_soc_component_update_bits(component, WCD9335_CPE_SS_SVA_CFG,
  8291. 0x01, 0x00);
  8292. break;
  8293. }
  8294. return 0;
  8295. }
  8296. static int tasha_codec_aif4_mixer_switch_get(struct snd_kcontrol *kcontrol,
  8297. struct snd_ctl_elem_value *ucontrol)
  8298. {
  8299. struct snd_soc_dapm_widget *widget =
  8300. snd_soc_dapm_kcontrol_widget(kcontrol);
  8301. struct snd_soc_component *component =
  8302. snd_soc_dapm_to_component(widget->dapm);
  8303. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  8304. if (test_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask))
  8305. ucontrol->value.integer.value[0] = 1;
  8306. else
  8307. ucontrol->value.integer.value[0] = 0;
  8308. dev_dbg(component->dev, "%s: AIF4 switch value = %ld\n",
  8309. __func__, ucontrol->value.integer.value[0]);
  8310. return 0;
  8311. }
  8312. static int tasha_codec_aif4_mixer_switch_put(struct snd_kcontrol *kcontrol,
  8313. struct snd_ctl_elem_value *ucontrol)
  8314. {
  8315. struct snd_soc_dapm_widget *widget =
  8316. snd_soc_dapm_kcontrol_widget(kcontrol);
  8317. struct snd_soc_dapm_update *update = NULL;
  8318. struct snd_soc_component *component =
  8319. snd_soc_dapm_to_component(widget->dapm);
  8320. struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component);
  8321. dev_dbg(component->dev, "%s: AIF4 switch value = %ld\n",
  8322. __func__, ucontrol->value.integer.value[0]);
  8323. if (ucontrol->value.integer.value[0]) {
  8324. snd_soc_dapm_mixer_update_power(widget->dapm,
  8325. kcontrol, 1, update);
  8326. set_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  8327. } else {
  8328. snd_soc_dapm_mixer_update_power(widget->dapm,
  8329. kcontrol, 0, update);
  8330. clear_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  8331. }
  8332. return 1;
  8333. }
  8334. static const char * const tasha_ear_pa_gain_text[] = {
  8335. "G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB",
  8336. "G_0_DB", "G_M2P5_DB", "UNDEFINED", "G_M12_DB"
  8337. };
  8338. static const char * const tasha_ear_spkr_pa_gain_text[] = {
  8339. "G_DEFAULT", "G_0_DB", "G_1_DB", "G_2_DB", "G_3_DB", "G_4_DB",
  8340. "G_5_DB", "G_6_DB"
  8341. };
  8342. static const char * const tasha_speaker_boost_stage_text[] = {
  8343. "NO_MAX_STATE", "MAX_STATE_1", "MAX_STATE_2"
  8344. };
  8345. static const struct soc_enum tasha_ear_pa_gain_enum =
  8346. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_pa_gain_text),
  8347. tasha_ear_pa_gain_text);
  8348. static const struct soc_enum tasha_ear_spkr_pa_gain_enum =
  8349. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_spkr_pa_gain_text),
  8350. tasha_ear_spkr_pa_gain_text);
  8351. static const struct soc_enum tasha_spkr_boost_stage_enum =
  8352. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_speaker_boost_stage_text),
  8353. tasha_speaker_boost_stage_text);
  8354. static const struct snd_kcontrol_new tasha_analog_gain_controls[] = {
  8355. SOC_ENUM_EXT("EAR PA Gain", tasha_ear_pa_gain_enum,
  8356. tasha_ear_pa_gain_get, tasha_ear_pa_gain_put),
  8357. SOC_SINGLE_TLV("HPHL Volume", WCD9335_HPH_L_EN, 0, 20, 1,
  8358. line_gain),
  8359. SOC_SINGLE_TLV("HPHR Volume", WCD9335_HPH_R_EN, 0, 20, 1,
  8360. line_gain),
  8361. SOC_SINGLE_TLV("LINEOUT1 Volume", WCD9335_DIFF_LO_LO1_COMPANDER,
  8362. 3, 16, 1, line_gain),
  8363. SOC_SINGLE_TLV("LINEOUT2 Volume", WCD9335_DIFF_LO_LO2_COMPANDER,
  8364. 3, 16, 1, line_gain),
  8365. SOC_SINGLE_TLV("LINEOUT3 Volume", WCD9335_SE_LO_LO3_GAIN, 0, 20, 1,
  8366. line_gain),
  8367. SOC_SINGLE_TLV("LINEOUT4 Volume", WCD9335_SE_LO_LO4_GAIN, 0, 20, 1,
  8368. line_gain),
  8369. SOC_SINGLE_TLV("ADC1 Volume", WCD9335_ANA_AMIC1, 0, 20, 0,
  8370. analog_gain),
  8371. SOC_SINGLE_TLV("ADC2 Volume", WCD9335_ANA_AMIC2, 0, 20, 0,
  8372. analog_gain),
  8373. SOC_SINGLE_TLV("ADC3 Volume", WCD9335_ANA_AMIC3, 0, 20, 0,
  8374. analog_gain),
  8375. SOC_SINGLE_TLV("ADC4 Volume", WCD9335_ANA_AMIC4, 0, 20, 0,
  8376. analog_gain),
  8377. SOC_SINGLE_TLV("ADC5 Volume", WCD9335_ANA_AMIC5, 0, 20, 0,
  8378. analog_gain),
  8379. SOC_SINGLE_TLV("ADC6 Volume", WCD9335_ANA_AMIC6, 0, 20, 0,
  8380. analog_gain),
  8381. };
  8382. static const struct snd_kcontrol_new tasha_spkr_wsa_controls[] = {
  8383. SOC_ENUM_EXT("EAR SPKR PA Gain", tasha_ear_spkr_pa_gain_enum,
  8384. tasha_ear_spkr_pa_gain_get, tasha_ear_spkr_pa_gain_put),
  8385. SOC_ENUM_EXT("SPKR Left Boost Max State", tasha_spkr_boost_stage_enum,
  8386. tasha_spkr_left_boost_stage_get,
  8387. tasha_spkr_left_boost_stage_put),
  8388. SOC_ENUM_EXT("SPKR Right Boost Max State", tasha_spkr_boost_stage_enum,
  8389. tasha_spkr_right_boost_stage_get,
  8390. tasha_spkr_right_boost_stage_put),
  8391. };
  8392. static const char * const spl_src0_mux_text[] = {
  8393. "ZERO", "SRC_IN_HPHL", "SRC_IN_LO1",
  8394. };
  8395. static const char * const spl_src1_mux_text[] = {
  8396. "ZERO", "SRC_IN_HPHR", "SRC_IN_LO2",
  8397. };
  8398. static const char * const spl_src2_mux_text[] = {
  8399. "ZERO", "SRC_IN_LO3", "SRC_IN_SPKRL",
  8400. };
  8401. static const char * const spl_src3_mux_text[] = {
  8402. "ZERO", "SRC_IN_LO4", "SRC_IN_SPKRR",
  8403. };
  8404. static const char * const rx_int0_7_mix_mux_text[] = {
  8405. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  8406. "RX6", "RX7", "PROXIMITY"
  8407. };
  8408. static const char * const rx_int_mix_mux_text[] = {
  8409. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  8410. "RX6", "RX7"
  8411. };
  8412. static const char * const rx_prim_mix_text[] = {
  8413. "ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2",
  8414. "RX3", "RX4", "RX5", "RX6", "RX7"
  8415. };
  8416. static const char * const rx_sidetone_mix_text[] = {
  8417. "ZERO", "SRC0", "SRC1", "SRC_SUM"
  8418. };
  8419. static const char * const sb_tx0_mux_text[] = {
  8420. "ZERO", "RX_MIX_TX0", "DEC0", "DEC0_192"
  8421. };
  8422. static const char * const sb_tx1_mux_text[] = {
  8423. "ZERO", "RX_MIX_TX1", "DEC1", "DEC1_192"
  8424. };
  8425. static const char * const sb_tx2_mux_text[] = {
  8426. "ZERO", "RX_MIX_TX2", "DEC2", "DEC2_192"
  8427. };
  8428. static const char * const sb_tx3_mux_text[] = {
  8429. "ZERO", "RX_MIX_TX3", "DEC3", "DEC3_192"
  8430. };
  8431. static const char * const sb_tx4_mux_text[] = {
  8432. "ZERO", "RX_MIX_TX4", "DEC4", "DEC4_192"
  8433. };
  8434. static const char * const sb_tx5_mux_text[] = {
  8435. "ZERO", "RX_MIX_TX5", "DEC5", "DEC5_192"
  8436. };
  8437. static const char * const sb_tx6_mux_text[] = {
  8438. "ZERO", "RX_MIX_TX6", "DEC6", "DEC6_192"
  8439. };
  8440. static const char * const sb_tx7_mux_text[] = {
  8441. "ZERO", "RX_MIX_TX7", "DEC7", "DEC7_192"
  8442. };
  8443. static const char * const sb_tx8_mux_text[] = {
  8444. "ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192"
  8445. };
  8446. static const char * const sb_tx9_mux_text[] = {
  8447. "ZERO", "DEC7", "DEC7_192"
  8448. };
  8449. static const char * const sb_tx10_mux_text[] = {
  8450. "ZERO", "DEC6", "DEC6_192"
  8451. };
  8452. static const char * const sb_tx11_mux_text[] = {
  8453. "DEC_0_5", "DEC_9_12", "MAD_AUDIO", "MAD_BRDCST"
  8454. };
  8455. static const char * const sb_tx11_inp1_mux_text[] = {
  8456. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4",
  8457. "DEC5", "RX_MIX_TX5", "DEC9_10", "DEC11_12"
  8458. };
  8459. static const char * const sb_tx13_mux_text[] = {
  8460. "ZERO", "DEC5", "DEC5_192"
  8461. };
  8462. static const char * const tx13_inp_mux_text[] = {
  8463. "CDC_DEC_5", "MAD_BRDCST", "CPE_TX_PP"
  8464. };
  8465. static const char * const iir_inp_mux_text[] = {
  8466. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6",
  8467. "DEC7", "DEC8", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7"
  8468. };
  8469. static const char * const rx_int_dem_inp_mux_text[] = {
  8470. "NORMAL_DSM_OUT", "CLSH_DSM_OUT",
  8471. };
  8472. static const char * const rx_int0_interp_mux_text[] = {
  8473. "ZERO", "RX INT0 MIX2",
  8474. };
  8475. static const char * const rx_int1_interp_mux_text[] = {
  8476. "ZERO", "RX INT1 MIX2",
  8477. };
  8478. static const char * const rx_int2_interp_mux_text[] = {
  8479. "ZERO", "RX INT2 MIX2",
  8480. };
  8481. static const char * const rx_int3_interp_mux_text[] = {
  8482. "ZERO", "RX INT3 MIX2",
  8483. };
  8484. static const char * const rx_int4_interp_mux_text[] = {
  8485. "ZERO", "RX INT4 MIX2",
  8486. };
  8487. static const char * const rx_int5_interp_mux_text[] = {
  8488. "ZERO", "RX INT5 MIX2",
  8489. };
  8490. static const char * const rx_int6_interp_mux_text[] = {
  8491. "ZERO", "RX INT6 MIX2",
  8492. };
  8493. static const char * const rx_int7_interp_mux_text[] = {
  8494. "ZERO", "RX INT7 MIX2",
  8495. };
  8496. static const char * const rx_int8_interp_mux_text[] = {
  8497. "ZERO", "RX INT8 SEC MIX"
  8498. };
  8499. static const char * const mad_sel_text[] = {
  8500. "SPE", "MSM"
  8501. };
  8502. static const char * const adc_mux_text[] = {
  8503. "DMIC", "AMIC", "ANC_FB_TUNE1", "ANC_FB_TUNE2"
  8504. };
  8505. static const char * const dmic_mux_text[] = {
  8506. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8507. "SMIC0", "SMIC1", "SMIC2", "SMIC3"
  8508. };
  8509. static const char * const dmic_mux_alt_text[] = {
  8510. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8511. };
  8512. static const char * const amic_mux_text[] = {
  8513. "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6"
  8514. };
  8515. static const char * const rx_echo_mux_text[] = {
  8516. "ZERO", "RX_MIX0", "RX_MIX1", "RX_MIX2", "RX_MIX3", "RX_MIX4",
  8517. "RX_MIX5", "RX_MIX6", "RX_MIX7", "RX_MIX8", "RX_MIX_VBAT5",
  8518. "RX_MIX_VBAT6", "RX_MIX_VBAT7", "RX_MIX_VBAT8"
  8519. };
  8520. static const char * const anc0_fb_mux_text[] = {
  8521. "ZERO", "ANC_IN_HPHL", "ANC_IN_EAR", "ANC_IN_EAR_SPKR",
  8522. "ANC_IN_LO1"
  8523. };
  8524. static const char * const anc1_fb_mux_text[] = {
  8525. "ZERO", "ANC_IN_HPHR", "ANC_IN_LO2"
  8526. };
  8527. static const char * const native_mux_text[] = {
  8528. "OFF", "ON",
  8529. };
  8530. static const struct soc_enum spl_src0_mux_chain_enum =
  8531. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 0, 3,
  8532. spl_src0_mux_text);
  8533. static const struct soc_enum spl_src1_mux_chain_enum =
  8534. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 2, 3,
  8535. spl_src1_mux_text);
  8536. static const struct soc_enum spl_src2_mux_chain_enum =
  8537. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 4, 3,
  8538. spl_src2_mux_text);
  8539. static const struct soc_enum spl_src3_mux_chain_enum =
  8540. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 6, 3,
  8541. spl_src3_mux_text);
  8542. static const struct soc_enum rx_int0_2_mux_chain_enum =
  8543. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 0, 10,
  8544. rx_int0_7_mix_mux_text);
  8545. static const struct soc_enum rx_int1_2_mux_chain_enum =
  8546. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 0, 9,
  8547. rx_int_mix_mux_text);
  8548. static const struct soc_enum rx_int2_2_mux_chain_enum =
  8549. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 0, 9,
  8550. rx_int_mix_mux_text);
  8551. static const struct soc_enum rx_int3_2_mux_chain_enum =
  8552. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 0, 9,
  8553. rx_int_mix_mux_text);
  8554. static const struct soc_enum rx_int4_2_mux_chain_enum =
  8555. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 0, 9,
  8556. rx_int_mix_mux_text);
  8557. static const struct soc_enum rx_int5_2_mux_chain_enum =
  8558. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 0, 9,
  8559. rx_int_mix_mux_text);
  8560. static const struct soc_enum rx_int6_2_mux_chain_enum =
  8561. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 0, 9,
  8562. rx_int_mix_mux_text);
  8563. static const struct soc_enum rx_int7_2_mux_chain_enum =
  8564. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 0, 10,
  8565. rx_int0_7_mix_mux_text);
  8566. static const struct soc_enum rx_int8_2_mux_chain_enum =
  8567. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 0, 9,
  8568. rx_int_mix_mux_text);
  8569. static const struct soc_enum int1_1_native_enum =
  8570. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8571. native_mux_text);
  8572. static const struct soc_enum int2_1_native_enum =
  8573. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8574. native_mux_text);
  8575. static const struct soc_enum int3_1_native_enum =
  8576. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8577. native_mux_text);
  8578. static const struct soc_enum int4_1_native_enum =
  8579. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8580. native_mux_text);
  8581. static const struct soc_enum rx_int0_1_mix_inp0_chain_enum =
  8582. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 0, 13,
  8583. rx_prim_mix_text);
  8584. static const struct soc_enum rx_int0_1_mix_inp1_chain_enum =
  8585. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 4, 13,
  8586. rx_prim_mix_text);
  8587. static const struct soc_enum rx_int0_1_mix_inp2_chain_enum =
  8588. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 4, 13,
  8589. rx_prim_mix_text);
  8590. static const struct soc_enum rx_int1_1_mix_inp0_chain_enum =
  8591. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 0, 13,
  8592. rx_prim_mix_text);
  8593. static const struct soc_enum rx_int1_1_mix_inp1_chain_enum =
  8594. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 4, 13,
  8595. rx_prim_mix_text);
  8596. static const struct soc_enum rx_int1_1_mix_inp2_chain_enum =
  8597. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 4, 13,
  8598. rx_prim_mix_text);
  8599. static const struct soc_enum rx_int2_1_mix_inp0_chain_enum =
  8600. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 0, 13,
  8601. rx_prim_mix_text);
  8602. static const struct soc_enum rx_int2_1_mix_inp1_chain_enum =
  8603. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 4, 13,
  8604. rx_prim_mix_text);
  8605. static const struct soc_enum rx_int2_1_mix_inp2_chain_enum =
  8606. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 4, 13,
  8607. rx_prim_mix_text);
  8608. static const struct soc_enum rx_int3_1_mix_inp0_chain_enum =
  8609. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 0, 13,
  8610. rx_prim_mix_text);
  8611. static const struct soc_enum rx_int3_1_mix_inp1_chain_enum =
  8612. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 4, 13,
  8613. rx_prim_mix_text);
  8614. static const struct soc_enum rx_int3_1_mix_inp2_chain_enum =
  8615. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 4, 13,
  8616. rx_prim_mix_text);
  8617. static const struct soc_enum rx_int4_1_mix_inp0_chain_enum =
  8618. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 0, 13,
  8619. rx_prim_mix_text);
  8620. static const struct soc_enum rx_int4_1_mix_inp1_chain_enum =
  8621. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 4, 13,
  8622. rx_prim_mix_text);
  8623. static const struct soc_enum rx_int4_1_mix_inp2_chain_enum =
  8624. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 4, 13,
  8625. rx_prim_mix_text);
  8626. static const struct soc_enum rx_int5_1_mix_inp0_chain_enum =
  8627. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 0, 13,
  8628. rx_prim_mix_text);
  8629. static const struct soc_enum rx_int5_1_mix_inp1_chain_enum =
  8630. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 4, 13,
  8631. rx_prim_mix_text);
  8632. static const struct soc_enum rx_int5_1_mix_inp2_chain_enum =
  8633. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 4, 13,
  8634. rx_prim_mix_text);
  8635. static const struct soc_enum rx_int6_1_mix_inp0_chain_enum =
  8636. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 0, 13,
  8637. rx_prim_mix_text);
  8638. static const struct soc_enum rx_int6_1_mix_inp1_chain_enum =
  8639. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 4, 13,
  8640. rx_prim_mix_text);
  8641. static const struct soc_enum rx_int6_1_mix_inp2_chain_enum =
  8642. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 4, 13,
  8643. rx_prim_mix_text);
  8644. static const struct soc_enum rx_int7_1_mix_inp0_chain_enum =
  8645. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 0, 13,
  8646. rx_prim_mix_text);
  8647. static const struct soc_enum rx_int7_1_mix_inp1_chain_enum =
  8648. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 4, 13,
  8649. rx_prim_mix_text);
  8650. static const struct soc_enum rx_int7_1_mix_inp2_chain_enum =
  8651. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 4, 13,
  8652. rx_prim_mix_text);
  8653. static const struct soc_enum rx_int8_1_mix_inp0_chain_enum =
  8654. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 0, 13,
  8655. rx_prim_mix_text);
  8656. static const struct soc_enum rx_int8_1_mix_inp1_chain_enum =
  8657. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 4, 13,
  8658. rx_prim_mix_text);
  8659. static const struct soc_enum rx_int8_1_mix_inp2_chain_enum =
  8660. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 4, 13,
  8661. rx_prim_mix_text);
  8662. static const struct soc_enum rx_int0_sidetone_mix_chain_enum =
  8663. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0, 4,
  8664. rx_sidetone_mix_text);
  8665. static const struct soc_enum rx_int1_sidetone_mix_chain_enum =
  8666. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2, 4,
  8667. rx_sidetone_mix_text);
  8668. static const struct soc_enum rx_int2_sidetone_mix_chain_enum =
  8669. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4, 4,
  8670. rx_sidetone_mix_text);
  8671. static const struct soc_enum rx_int3_sidetone_mix_chain_enum =
  8672. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6, 4,
  8673. rx_sidetone_mix_text);
  8674. static const struct soc_enum rx_int4_sidetone_mix_chain_enum =
  8675. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 0, 4,
  8676. rx_sidetone_mix_text);
  8677. static const struct soc_enum rx_int7_sidetone_mix_chain_enum =
  8678. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 2, 4,
  8679. rx_sidetone_mix_text);
  8680. static const struct soc_enum tx_adc_mux0_chain_enum =
  8681. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 0, 4,
  8682. adc_mux_text);
  8683. static const struct soc_enum tx_adc_mux1_chain_enum =
  8684. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 0, 4,
  8685. adc_mux_text);
  8686. static const struct soc_enum tx_adc_mux2_chain_enum =
  8687. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 0, 4,
  8688. adc_mux_text);
  8689. static const struct soc_enum tx_adc_mux3_chain_enum =
  8690. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 0, 4,
  8691. adc_mux_text);
  8692. static const struct soc_enum tx_adc_mux4_chain_enum =
  8693. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 6, 4,
  8694. adc_mux_text);
  8695. static const struct soc_enum tx_adc_mux5_chain_enum =
  8696. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 6, 4,
  8697. adc_mux_text);
  8698. static const struct soc_enum tx_adc_mux6_chain_enum =
  8699. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 6, 4,
  8700. adc_mux_text);
  8701. static const struct soc_enum tx_adc_mux7_chain_enum =
  8702. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 6, 4,
  8703. adc_mux_text);
  8704. static const struct soc_enum tx_adc_mux8_chain_enum =
  8705. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 6, 4,
  8706. adc_mux_text);
  8707. static const struct soc_enum tx_adc_mux10_chain_enum =
  8708. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 6, 4,
  8709. adc_mux_text);
  8710. static const struct soc_enum tx_adc_mux11_chain_enum =
  8711. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 6, 4,
  8712. adc_mux_text);
  8713. static const struct soc_enum tx_adc_mux12_chain_enum =
  8714. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 6, 4,
  8715. adc_mux_text);
  8716. static const struct soc_enum tx_adc_mux13_chain_enum =
  8717. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 6, 4,
  8718. adc_mux_text);
  8719. static const struct soc_enum tx_dmic_mux0_enum =
  8720. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 3, 11,
  8721. dmic_mux_text);
  8722. static const struct soc_enum tx_dmic_mux1_enum =
  8723. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 3, 11,
  8724. dmic_mux_text);
  8725. static const struct soc_enum tx_dmic_mux2_enum =
  8726. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 3, 11,
  8727. dmic_mux_text);
  8728. static const struct soc_enum tx_dmic_mux3_enum =
  8729. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 3, 11,
  8730. dmic_mux_text);
  8731. static const struct soc_enum tx_dmic_mux4_enum =
  8732. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 3, 7,
  8733. dmic_mux_alt_text);
  8734. static const struct soc_enum tx_dmic_mux5_enum =
  8735. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 3, 7,
  8736. dmic_mux_alt_text);
  8737. static const struct soc_enum tx_dmic_mux6_enum =
  8738. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 3, 7,
  8739. dmic_mux_alt_text);
  8740. static const struct soc_enum tx_dmic_mux7_enum =
  8741. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 3, 7,
  8742. dmic_mux_alt_text);
  8743. static const struct soc_enum tx_dmic_mux8_enum =
  8744. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 3, 7,
  8745. dmic_mux_alt_text);
  8746. static const struct soc_enum tx_dmic_mux10_enum =
  8747. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 3, 7,
  8748. dmic_mux_alt_text);
  8749. static const struct soc_enum tx_dmic_mux11_enum =
  8750. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 3, 7,
  8751. dmic_mux_alt_text);
  8752. static const struct soc_enum tx_dmic_mux12_enum =
  8753. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 3, 7,
  8754. dmic_mux_alt_text);
  8755. static const struct soc_enum tx_dmic_mux13_enum =
  8756. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 3, 7,
  8757. dmic_mux_alt_text);
  8758. static const struct soc_enum tx_amic_mux0_enum =
  8759. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 0, 7,
  8760. amic_mux_text);
  8761. static const struct soc_enum tx_amic_mux1_enum =
  8762. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 0, 7,
  8763. amic_mux_text);
  8764. static const struct soc_enum tx_amic_mux2_enum =
  8765. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 0, 7,
  8766. amic_mux_text);
  8767. static const struct soc_enum tx_amic_mux3_enum =
  8768. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 0, 7,
  8769. amic_mux_text);
  8770. static const struct soc_enum tx_amic_mux4_enum =
  8771. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 0, 7,
  8772. amic_mux_text);
  8773. static const struct soc_enum tx_amic_mux5_enum =
  8774. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 0, 7,
  8775. amic_mux_text);
  8776. static const struct soc_enum tx_amic_mux6_enum =
  8777. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 0, 7,
  8778. amic_mux_text);
  8779. static const struct soc_enum tx_amic_mux7_enum =
  8780. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 0, 7,
  8781. amic_mux_text);
  8782. static const struct soc_enum tx_amic_mux8_enum =
  8783. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 0, 7,
  8784. amic_mux_text);
  8785. static const struct soc_enum tx_amic_mux10_enum =
  8786. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 0, 7,
  8787. amic_mux_text);
  8788. static const struct soc_enum tx_amic_mux11_enum =
  8789. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 0, 7,
  8790. amic_mux_text);
  8791. static const struct soc_enum tx_amic_mux12_enum =
  8792. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 0, 7,
  8793. amic_mux_text);
  8794. static const struct soc_enum tx_amic_mux13_enum =
  8795. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 0, 7,
  8796. amic_mux_text);
  8797. static const struct soc_enum sb_tx0_mux_enum =
  8798. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 0, 4,
  8799. sb_tx0_mux_text);
  8800. static const struct soc_enum sb_tx1_mux_enum =
  8801. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 2, 4,
  8802. sb_tx1_mux_text);
  8803. static const struct soc_enum sb_tx2_mux_enum =
  8804. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 4, 4,
  8805. sb_tx2_mux_text);
  8806. static const struct soc_enum sb_tx3_mux_enum =
  8807. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 6, 4,
  8808. sb_tx3_mux_text);
  8809. static const struct soc_enum sb_tx4_mux_enum =
  8810. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 0, 4,
  8811. sb_tx4_mux_text);
  8812. static const struct soc_enum sb_tx5_mux_enum =
  8813. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 2, 4,
  8814. sb_tx5_mux_text);
  8815. static const struct soc_enum sb_tx6_mux_enum =
  8816. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 4, 4,
  8817. sb_tx6_mux_text);
  8818. static const struct soc_enum sb_tx7_mux_enum =
  8819. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 6, 4,
  8820. sb_tx7_mux_text);
  8821. static const struct soc_enum sb_tx8_mux_enum =
  8822. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 0, 4,
  8823. sb_tx8_mux_text);
  8824. static const struct soc_enum sb_tx9_mux_enum =
  8825. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 2, 3,
  8826. sb_tx9_mux_text);
  8827. static const struct soc_enum sb_tx10_mux_enum =
  8828. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 4, 3,
  8829. sb_tx10_mux_text);
  8830. static const struct soc_enum sb_tx11_mux_enum =
  8831. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX11_INP_CFG, 0, 4,
  8832. sb_tx11_mux_text);
  8833. static const struct soc_enum sb_tx11_inp1_mux_enum =
  8834. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 0, 10,
  8835. sb_tx11_inp1_mux_text);
  8836. static const struct soc_enum sb_tx13_mux_enum =
  8837. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 4, 3,
  8838. sb_tx13_mux_text);
  8839. static const struct soc_enum tx13_inp_mux_enum =
  8840. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG, 0, 3,
  8841. tx13_inp_mux_text);
  8842. static const struct soc_enum rx_mix_tx0_mux_enum =
  8843. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 0, 14,
  8844. rx_echo_mux_text);
  8845. static const struct soc_enum rx_mix_tx1_mux_enum =
  8846. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 4, 14,
  8847. rx_echo_mux_text);
  8848. static const struct soc_enum rx_mix_tx2_mux_enum =
  8849. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 0, 14,
  8850. rx_echo_mux_text);
  8851. static const struct soc_enum rx_mix_tx3_mux_enum =
  8852. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 4, 14,
  8853. rx_echo_mux_text);
  8854. static const struct soc_enum rx_mix_tx4_mux_enum =
  8855. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 0, 14,
  8856. rx_echo_mux_text);
  8857. static const struct soc_enum rx_mix_tx5_mux_enum =
  8858. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 4, 14,
  8859. rx_echo_mux_text);
  8860. static const struct soc_enum rx_mix_tx6_mux_enum =
  8861. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 0, 14,
  8862. rx_echo_mux_text);
  8863. static const struct soc_enum rx_mix_tx7_mux_enum =
  8864. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 4, 14,
  8865. rx_echo_mux_text);
  8866. static const struct soc_enum rx_mix_tx8_mux_enum =
  8867. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG4, 0, 14,
  8868. rx_echo_mux_text);
  8869. static const struct soc_enum iir0_inp0_mux_enum =
  8870. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0, 0, 18,
  8871. iir_inp_mux_text);
  8872. static const struct soc_enum iir0_inp1_mux_enum =
  8873. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1, 0, 18,
  8874. iir_inp_mux_text);
  8875. static const struct soc_enum iir0_inp2_mux_enum =
  8876. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2, 0, 18,
  8877. iir_inp_mux_text);
  8878. static const struct soc_enum iir0_inp3_mux_enum =
  8879. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3, 0, 18,
  8880. iir_inp_mux_text);
  8881. static const struct soc_enum iir1_inp0_mux_enum =
  8882. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0, 0, 18,
  8883. iir_inp_mux_text);
  8884. static const struct soc_enum iir1_inp1_mux_enum =
  8885. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1, 0, 18,
  8886. iir_inp_mux_text);
  8887. static const struct soc_enum iir1_inp2_mux_enum =
  8888. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2, 0, 18,
  8889. iir_inp_mux_text);
  8890. static const struct soc_enum iir1_inp3_mux_enum =
  8891. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3, 0, 18,
  8892. iir_inp_mux_text);
  8893. static const struct soc_enum rx_int0_dem_inp_mux_enum =
  8894. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_SEC0, 0,
  8895. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8896. rx_int_dem_inp_mux_text);
  8897. static const struct soc_enum rx_int1_dem_inp_mux_enum =
  8898. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_SEC0, 0,
  8899. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8900. rx_int_dem_inp_mux_text);
  8901. static const struct soc_enum rx_int2_dem_inp_mux_enum =
  8902. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_SEC0, 0,
  8903. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8904. rx_int_dem_inp_mux_text);
  8905. static const struct soc_enum rx_int0_interp_mux_enum =
  8906. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CTL, 5, 2,
  8907. rx_int0_interp_mux_text);
  8908. static const struct soc_enum rx_int1_interp_mux_enum =
  8909. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CTL, 5, 2,
  8910. rx_int1_interp_mux_text);
  8911. static const struct soc_enum rx_int2_interp_mux_enum =
  8912. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CTL, 5, 2,
  8913. rx_int2_interp_mux_text);
  8914. static const struct soc_enum rx_int3_interp_mux_enum =
  8915. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CTL, 5, 2,
  8916. rx_int3_interp_mux_text);
  8917. static const struct soc_enum rx_int4_interp_mux_enum =
  8918. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CTL, 5, 2,
  8919. rx_int4_interp_mux_text);
  8920. static const struct soc_enum rx_int5_interp_mux_enum =
  8921. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CTL, 5, 2,
  8922. rx_int5_interp_mux_text);
  8923. static const struct soc_enum rx_int6_interp_mux_enum =
  8924. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CTL, 5, 2,
  8925. rx_int6_interp_mux_text);
  8926. static const struct soc_enum rx_int7_interp_mux_enum =
  8927. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CTL, 5, 2,
  8928. rx_int7_interp_mux_text);
  8929. static const struct soc_enum rx_int8_interp_mux_enum =
  8930. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CTL, 5, 2,
  8931. rx_int8_interp_mux_text);
  8932. static const struct soc_enum mad_sel_enum =
  8933. SOC_ENUM_SINGLE(WCD9335_CPE_SS_CFG, 0, 2, mad_sel_text);
  8934. static const struct soc_enum anc0_fb_mux_enum =
  8935. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 0, 5,
  8936. anc0_fb_mux_text);
  8937. static const struct soc_enum anc1_fb_mux_enum =
  8938. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 3, 3,
  8939. anc1_fb_mux_text);
  8940. static const struct snd_kcontrol_new rx_int0_dem_inp_mux =
  8941. SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum,
  8942. snd_soc_dapm_get_enum_double,
  8943. tasha_int_dem_inp_mux_put);
  8944. static const struct snd_kcontrol_new rx_int1_dem_inp_mux =
  8945. SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum,
  8946. snd_soc_dapm_get_enum_double,
  8947. tasha_int_dem_inp_mux_put);
  8948. static const struct snd_kcontrol_new rx_int2_dem_inp_mux =
  8949. SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum,
  8950. snd_soc_dapm_get_enum_double,
  8951. tasha_int_dem_inp_mux_put);
  8952. static const struct snd_kcontrol_new spl_src0_mux =
  8953. SOC_DAPM_ENUM("SPL SRC0 MUX Mux", spl_src0_mux_chain_enum);
  8954. static const struct snd_kcontrol_new spl_src1_mux =
  8955. SOC_DAPM_ENUM("SPL SRC1 MUX Mux", spl_src1_mux_chain_enum);
  8956. static const struct snd_kcontrol_new spl_src2_mux =
  8957. SOC_DAPM_ENUM("SPL SRC2 MUX Mux", spl_src2_mux_chain_enum);
  8958. static const struct snd_kcontrol_new spl_src3_mux =
  8959. SOC_DAPM_ENUM("SPL SRC3 MUX Mux", spl_src3_mux_chain_enum);
  8960. static const struct snd_kcontrol_new rx_int0_2_mux =
  8961. SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum);
  8962. static const struct snd_kcontrol_new rx_int1_2_mux =
  8963. SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum);
  8964. static const struct snd_kcontrol_new rx_int2_2_mux =
  8965. SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum);
  8966. static const struct snd_kcontrol_new rx_int3_2_mux =
  8967. SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum);
  8968. static const struct snd_kcontrol_new rx_int4_2_mux =
  8969. SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum);
  8970. static const struct snd_kcontrol_new rx_int5_2_mux =
  8971. SOC_DAPM_ENUM("RX INT5_2 MUX Mux", rx_int5_2_mux_chain_enum);
  8972. static const struct snd_kcontrol_new rx_int6_2_mux =
  8973. SOC_DAPM_ENUM("RX INT6_2 MUX Mux", rx_int6_2_mux_chain_enum);
  8974. static const struct snd_kcontrol_new rx_int7_2_mux =
  8975. SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum);
  8976. static const struct snd_kcontrol_new rx_int8_2_mux =
  8977. SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum);
  8978. static const struct snd_kcontrol_new int1_1_native_mux =
  8979. SOC_DAPM_ENUM("RX INT1_1 NATIVE MUX Mux", int1_1_native_enum);
  8980. static const struct snd_kcontrol_new int2_1_native_mux =
  8981. SOC_DAPM_ENUM("RX INT2_1 NATIVE MUX Mux", int2_1_native_enum);
  8982. static const struct snd_kcontrol_new int3_1_native_mux =
  8983. SOC_DAPM_ENUM("RX INT3_1 NATIVE MUX Mux", int3_1_native_enum);
  8984. static const struct snd_kcontrol_new int4_1_native_mux =
  8985. SOC_DAPM_ENUM("RX INT4_1 NATIVE MUX Mux", int4_1_native_enum);
  8986. static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux =
  8987. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum);
  8988. static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux =
  8989. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum);
  8990. static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux =
  8991. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum);
  8992. static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux =
  8993. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum);
  8994. static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux =
  8995. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum);
  8996. static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux =
  8997. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum);
  8998. static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux =
  8999. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum);
  9000. static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux =
  9001. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum);
  9002. static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux =
  9003. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum);
  9004. static const struct snd_kcontrol_new rx_int3_1_mix_inp0_mux =
  9005. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum);
  9006. static const struct snd_kcontrol_new rx_int3_1_mix_inp1_mux =
  9007. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum);
  9008. static const struct snd_kcontrol_new rx_int3_1_mix_inp2_mux =
  9009. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum);
  9010. static const struct snd_kcontrol_new rx_int4_1_mix_inp0_mux =
  9011. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum);
  9012. static const struct snd_kcontrol_new rx_int4_1_mix_inp1_mux =
  9013. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum);
  9014. static const struct snd_kcontrol_new rx_int4_1_mix_inp2_mux =
  9015. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum);
  9016. static const struct snd_kcontrol_new rx_int5_1_mix_inp0_mux =
  9017. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP0 Mux", rx_int5_1_mix_inp0_chain_enum);
  9018. static const struct snd_kcontrol_new rx_int5_1_mix_inp1_mux =
  9019. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP1 Mux", rx_int5_1_mix_inp1_chain_enum);
  9020. static const struct snd_kcontrol_new rx_int5_1_mix_inp2_mux =
  9021. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP2 Mux", rx_int5_1_mix_inp2_chain_enum);
  9022. static const struct snd_kcontrol_new rx_int6_1_mix_inp0_mux =
  9023. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP0 Mux", rx_int6_1_mix_inp0_chain_enum);
  9024. static const struct snd_kcontrol_new rx_int6_1_mix_inp1_mux =
  9025. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP1 Mux", rx_int6_1_mix_inp1_chain_enum);
  9026. static const struct snd_kcontrol_new rx_int6_1_mix_inp2_mux =
  9027. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP2 Mux", rx_int6_1_mix_inp2_chain_enum);
  9028. static const struct snd_kcontrol_new rx_int7_1_mix_inp0_mux =
  9029. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum);
  9030. static const struct snd_kcontrol_new rx_int7_1_mix_inp1_mux =
  9031. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum);
  9032. static const struct snd_kcontrol_new rx_int7_1_mix_inp2_mux =
  9033. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum);
  9034. static const struct snd_kcontrol_new rx_int8_1_mix_inp0_mux =
  9035. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum);
  9036. static const struct snd_kcontrol_new rx_int8_1_mix_inp1_mux =
  9037. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum);
  9038. static const struct snd_kcontrol_new rx_int8_1_mix_inp2_mux =
  9039. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum);
  9040. static const struct snd_kcontrol_new rx_int0_mix2_inp_mux =
  9041. SOC_DAPM_ENUM("RX INT0 MIX2 INP Mux", rx_int0_sidetone_mix_chain_enum);
  9042. static const struct snd_kcontrol_new rx_int1_mix2_inp_mux =
  9043. SOC_DAPM_ENUM("RX INT1 MIX2 INP Mux", rx_int1_sidetone_mix_chain_enum);
  9044. static const struct snd_kcontrol_new rx_int2_mix2_inp_mux =
  9045. SOC_DAPM_ENUM("RX INT2 MIX2 INP Mux", rx_int2_sidetone_mix_chain_enum);
  9046. static const struct snd_kcontrol_new rx_int3_mix2_inp_mux =
  9047. SOC_DAPM_ENUM("RX INT3 MIX2 INP Mux", rx_int3_sidetone_mix_chain_enum);
  9048. static const struct snd_kcontrol_new rx_int4_mix2_inp_mux =
  9049. SOC_DAPM_ENUM("RX INT4 MIX2 INP Mux", rx_int4_sidetone_mix_chain_enum);
  9050. static const struct snd_kcontrol_new rx_int7_mix2_inp_mux =
  9051. SOC_DAPM_ENUM("RX INT7 MIX2 INP Mux", rx_int7_sidetone_mix_chain_enum);
  9052. static const struct snd_kcontrol_new tx_adc_mux0 =
  9053. SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_chain_enum,
  9054. snd_soc_dapm_get_enum_double,
  9055. tasha_put_dec_enum);
  9056. static const struct snd_kcontrol_new tx_adc_mux1 =
  9057. SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_chain_enum,
  9058. snd_soc_dapm_get_enum_double,
  9059. tasha_put_dec_enum);
  9060. static const struct snd_kcontrol_new tx_adc_mux2 =
  9061. SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_chain_enum,
  9062. snd_soc_dapm_get_enum_double,
  9063. tasha_put_dec_enum);
  9064. static const struct snd_kcontrol_new tx_adc_mux3 =
  9065. SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_chain_enum,
  9066. snd_soc_dapm_get_enum_double,
  9067. tasha_put_dec_enum);
  9068. static const struct snd_kcontrol_new tx_adc_mux4 =
  9069. SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_chain_enum,
  9070. snd_soc_dapm_get_enum_double,
  9071. tasha_put_dec_enum);
  9072. static const struct snd_kcontrol_new tx_adc_mux5 =
  9073. SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_chain_enum,
  9074. snd_soc_dapm_get_enum_double,
  9075. tasha_put_dec_enum);
  9076. static const struct snd_kcontrol_new tx_adc_mux6 =
  9077. SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_chain_enum,
  9078. snd_soc_dapm_get_enum_double,
  9079. tasha_put_dec_enum);
  9080. static const struct snd_kcontrol_new tx_adc_mux7 =
  9081. SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_chain_enum,
  9082. snd_soc_dapm_get_enum_double,
  9083. tasha_put_dec_enum);
  9084. static const struct snd_kcontrol_new tx_adc_mux8 =
  9085. SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_chain_enum,
  9086. snd_soc_dapm_get_enum_double,
  9087. tasha_put_dec_enum);
  9088. static const struct snd_kcontrol_new tx_adc_mux10 =
  9089. SOC_DAPM_ENUM("ADC MUX10 Mux", tx_adc_mux10_chain_enum);
  9090. static const struct snd_kcontrol_new tx_adc_mux11 =
  9091. SOC_DAPM_ENUM("ADC MUX11 Mux", tx_adc_mux11_chain_enum);
  9092. static const struct snd_kcontrol_new tx_adc_mux12 =
  9093. SOC_DAPM_ENUM("ADC MUX12 Mux", tx_adc_mux12_chain_enum);
  9094. static const struct snd_kcontrol_new tx_adc_mux13 =
  9095. SOC_DAPM_ENUM("ADC MUX13 Mux", tx_adc_mux13_chain_enum);
  9096. static const struct snd_kcontrol_new tx_dmic_mux0 =
  9097. SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum);
  9098. static const struct snd_kcontrol_new tx_dmic_mux1 =
  9099. SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum);
  9100. static const struct snd_kcontrol_new tx_dmic_mux2 =
  9101. SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum);
  9102. static const struct snd_kcontrol_new tx_dmic_mux3 =
  9103. SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum);
  9104. static const struct snd_kcontrol_new tx_dmic_mux4 =
  9105. SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum);
  9106. static const struct snd_kcontrol_new tx_dmic_mux5 =
  9107. SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum);
  9108. static const struct snd_kcontrol_new tx_dmic_mux6 =
  9109. SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum);
  9110. static const struct snd_kcontrol_new tx_dmic_mux7 =
  9111. SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum);
  9112. static const struct snd_kcontrol_new tx_dmic_mux8 =
  9113. SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum);
  9114. static const struct snd_kcontrol_new tx_dmic_mux10 =
  9115. SOC_DAPM_ENUM("DMIC MUX10 Mux", tx_dmic_mux10_enum);
  9116. static const struct snd_kcontrol_new tx_dmic_mux11 =
  9117. SOC_DAPM_ENUM("DMIC MUX11 Mux", tx_dmic_mux11_enum);
  9118. static const struct snd_kcontrol_new tx_dmic_mux12 =
  9119. SOC_DAPM_ENUM("DMIC MUX12 Mux", tx_dmic_mux12_enum);
  9120. static const struct snd_kcontrol_new tx_dmic_mux13 =
  9121. SOC_DAPM_ENUM("DMIC MUX13 Mux", tx_dmic_mux13_enum);
  9122. static const struct snd_kcontrol_new tx_amic_mux0 =
  9123. SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum);
  9124. static const struct snd_kcontrol_new tx_amic_mux1 =
  9125. SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum);
  9126. static const struct snd_kcontrol_new tx_amic_mux2 =
  9127. SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum);
  9128. static const struct snd_kcontrol_new tx_amic_mux3 =
  9129. SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum);
  9130. static const struct snd_kcontrol_new tx_amic_mux4 =
  9131. SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum);
  9132. static const struct snd_kcontrol_new tx_amic_mux5 =
  9133. SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum);
  9134. static const struct snd_kcontrol_new tx_amic_mux6 =
  9135. SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum);
  9136. static const struct snd_kcontrol_new tx_amic_mux7 =
  9137. SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum);
  9138. static const struct snd_kcontrol_new tx_amic_mux8 =
  9139. SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum);
  9140. static const struct snd_kcontrol_new tx_amic_mux10 =
  9141. SOC_DAPM_ENUM("AMIC MUX10 Mux", tx_amic_mux10_enum);
  9142. static const struct snd_kcontrol_new tx_amic_mux11 =
  9143. SOC_DAPM_ENUM("AMIC MUX11 Mux", tx_amic_mux11_enum);
  9144. static const struct snd_kcontrol_new tx_amic_mux12 =
  9145. SOC_DAPM_ENUM("AMIC MUX12 Mux", tx_amic_mux12_enum);
  9146. static const struct snd_kcontrol_new tx_amic_mux13 =
  9147. SOC_DAPM_ENUM("AMIC MUX13 Mux", tx_amic_mux13_enum);
  9148. static const struct snd_kcontrol_new sb_tx0_mux =
  9149. SOC_DAPM_ENUM("SLIM TX0 MUX Mux", sb_tx0_mux_enum);
  9150. static const struct snd_kcontrol_new sb_tx1_mux =
  9151. SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum);
  9152. static const struct snd_kcontrol_new sb_tx2_mux =
  9153. SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum);
  9154. static const struct snd_kcontrol_new sb_tx3_mux =
  9155. SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum);
  9156. static const struct snd_kcontrol_new sb_tx4_mux =
  9157. SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum);
  9158. static const struct snd_kcontrol_new sb_tx5_mux =
  9159. SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum);
  9160. static const struct snd_kcontrol_new sb_tx6_mux =
  9161. SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum);
  9162. static const struct snd_kcontrol_new sb_tx7_mux =
  9163. SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum);
  9164. static const struct snd_kcontrol_new sb_tx8_mux =
  9165. SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum);
  9166. static const struct snd_kcontrol_new sb_tx9_mux =
  9167. SOC_DAPM_ENUM("SLIM TX9 MUX Mux", sb_tx9_mux_enum);
  9168. static const struct snd_kcontrol_new sb_tx10_mux =
  9169. SOC_DAPM_ENUM("SLIM TX10 MUX Mux", sb_tx10_mux_enum);
  9170. static const struct snd_kcontrol_new sb_tx11_mux =
  9171. SOC_DAPM_ENUM("SLIM TX11 MUX Mux", sb_tx11_mux_enum);
  9172. static const struct snd_kcontrol_new sb_tx11_inp1_mux =
  9173. SOC_DAPM_ENUM("SLIM TX11 INP1 MUX Mux", sb_tx11_inp1_mux_enum);
  9174. static const struct snd_kcontrol_new sb_tx13_mux =
  9175. SOC_DAPM_ENUM("SLIM TX13 MUX Mux", sb_tx13_mux_enum);
  9176. static const struct snd_kcontrol_new tx13_inp_mux =
  9177. SOC_DAPM_ENUM("TX13 INP MUX Mux", tx13_inp_mux_enum);
  9178. static const struct snd_kcontrol_new rx_mix_tx0_mux =
  9179. SOC_DAPM_ENUM("RX MIX TX0 MUX Mux", rx_mix_tx0_mux_enum);
  9180. static const struct snd_kcontrol_new rx_mix_tx1_mux =
  9181. SOC_DAPM_ENUM("RX MIX TX1 MUX Mux", rx_mix_tx1_mux_enum);
  9182. static const struct snd_kcontrol_new rx_mix_tx2_mux =
  9183. SOC_DAPM_ENUM("RX MIX TX2 MUX Mux", rx_mix_tx2_mux_enum);
  9184. static const struct snd_kcontrol_new rx_mix_tx3_mux =
  9185. SOC_DAPM_ENUM("RX MIX TX3 MUX Mux", rx_mix_tx3_mux_enum);
  9186. static const struct snd_kcontrol_new rx_mix_tx4_mux =
  9187. SOC_DAPM_ENUM("RX MIX TX4 MUX Mux", rx_mix_tx4_mux_enum);
  9188. static const struct snd_kcontrol_new rx_mix_tx5_mux =
  9189. SOC_DAPM_ENUM("RX MIX TX5 MUX Mux", rx_mix_tx5_mux_enum);
  9190. static const struct snd_kcontrol_new rx_mix_tx6_mux =
  9191. SOC_DAPM_ENUM("RX MIX TX6 MUX Mux", rx_mix_tx6_mux_enum);
  9192. static const struct snd_kcontrol_new rx_mix_tx7_mux =
  9193. SOC_DAPM_ENUM("RX MIX TX7 MUX Mux", rx_mix_tx7_mux_enum);
  9194. static const struct snd_kcontrol_new rx_mix_tx8_mux =
  9195. SOC_DAPM_ENUM("RX MIX TX8 MUX Mux", rx_mix_tx8_mux_enum);
  9196. static const struct snd_kcontrol_new iir0_inp0_mux =
  9197. SOC_DAPM_ENUM("IIR0 INP0 Mux", iir0_inp0_mux_enum);
  9198. static const struct snd_kcontrol_new iir0_inp1_mux =
  9199. SOC_DAPM_ENUM("IIR0 INP1 Mux", iir0_inp1_mux_enum);
  9200. static const struct snd_kcontrol_new iir0_inp2_mux =
  9201. SOC_DAPM_ENUM("IIR0 INP2 Mux", iir0_inp2_mux_enum);
  9202. static const struct snd_kcontrol_new iir0_inp3_mux =
  9203. SOC_DAPM_ENUM("IIR0 INP3 Mux", iir0_inp3_mux_enum);
  9204. static const struct snd_kcontrol_new iir1_inp0_mux =
  9205. SOC_DAPM_ENUM("IIR1 INP0 Mux", iir1_inp0_mux_enum);
  9206. static const struct snd_kcontrol_new iir1_inp1_mux =
  9207. SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum);
  9208. static const struct snd_kcontrol_new iir1_inp2_mux =
  9209. SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum);
  9210. static const struct snd_kcontrol_new iir1_inp3_mux =
  9211. SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum);
  9212. static const struct snd_kcontrol_new rx_int0_interp_mux =
  9213. SOC_DAPM_ENUM("RX INT0 INTERP Mux", rx_int0_interp_mux_enum);
  9214. static const struct snd_kcontrol_new rx_int1_interp_mux =
  9215. SOC_DAPM_ENUM("RX INT1 INTERP Mux", rx_int1_interp_mux_enum);
  9216. static const struct snd_kcontrol_new rx_int2_interp_mux =
  9217. SOC_DAPM_ENUM("RX INT2 INTERP Mux", rx_int2_interp_mux_enum);
  9218. static const struct snd_kcontrol_new rx_int3_interp_mux =
  9219. SOC_DAPM_ENUM("RX INT3 INTERP Mux", rx_int3_interp_mux_enum);
  9220. static const struct snd_kcontrol_new rx_int4_interp_mux =
  9221. SOC_DAPM_ENUM("RX INT4 INTERP Mux", rx_int4_interp_mux_enum);
  9222. static const struct snd_kcontrol_new rx_int5_interp_mux =
  9223. SOC_DAPM_ENUM("RX INT5 INTERP Mux", rx_int5_interp_mux_enum);
  9224. static const struct snd_kcontrol_new rx_int6_interp_mux =
  9225. SOC_DAPM_ENUM("RX INT6 INTERP Mux", rx_int6_interp_mux_enum);
  9226. static const struct snd_kcontrol_new rx_int7_interp_mux =
  9227. SOC_DAPM_ENUM("RX INT7 INTERP Mux", rx_int7_interp_mux_enum);
  9228. static const struct snd_kcontrol_new rx_int8_interp_mux =
  9229. SOC_DAPM_ENUM("RX INT8 INTERP Mux", rx_int8_interp_mux_enum);
  9230. static const struct snd_kcontrol_new mad_sel_mux =
  9231. SOC_DAPM_ENUM("MAD_SEL MUX Mux", mad_sel_enum);
  9232. static const struct snd_kcontrol_new aif4_mad_switch =
  9233. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 5, 1, 0);
  9234. static const struct snd_kcontrol_new mad_brdcst_switch =
  9235. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 6, 1, 0);
  9236. static const struct snd_kcontrol_new aif4_switch_mixer_controls =
  9237. SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
  9238. 0, 1, 0, tasha_codec_aif4_mixer_switch_get,
  9239. tasha_codec_aif4_mixer_switch_put);
  9240. static const struct snd_kcontrol_new anc_hphl_switch =
  9241. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  9242. static const struct snd_kcontrol_new anc_hphr_switch =
  9243. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  9244. static const struct snd_kcontrol_new anc_ear_switch =
  9245. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  9246. static const struct snd_kcontrol_new anc_ear_spkr_switch =
  9247. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  9248. static const struct snd_kcontrol_new anc_lineout1_switch =
  9249. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  9250. static const struct snd_kcontrol_new anc_lineout2_switch =
  9251. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  9252. static const struct snd_kcontrol_new anc_spkr_pa_switch =
  9253. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  9254. static const struct snd_kcontrol_new adc_us_mux0_switch =
  9255. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  9256. static const struct snd_kcontrol_new adc_us_mux1_switch =
  9257. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  9258. static const struct snd_kcontrol_new adc_us_mux2_switch =
  9259. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  9260. static const struct snd_kcontrol_new adc_us_mux3_switch =
  9261. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  9262. static const struct snd_kcontrol_new adc_us_mux4_switch =
  9263. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  9264. static const struct snd_kcontrol_new adc_us_mux5_switch =
  9265. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  9266. static const struct snd_kcontrol_new adc_us_mux6_switch =
  9267. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  9268. static const struct snd_kcontrol_new adc_us_mux7_switch =
  9269. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  9270. static const struct snd_kcontrol_new adc_us_mux8_switch =
  9271. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  9272. static const struct snd_kcontrol_new anc0_fb_mux =
  9273. SOC_DAPM_ENUM("ANC0 FB MUX Mux", anc0_fb_mux_enum);
  9274. static const struct snd_kcontrol_new anc1_fb_mux =
  9275. SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum);
  9276. static int tasha_codec_ec_buf_mux_enable(struct snd_soc_dapm_widget *w,
  9277. struct snd_kcontrol *kcontrol,
  9278. int event)
  9279. {
  9280. struct snd_soc_component *component =
  9281. snd_soc_dapm_to_component(w->dapm);
  9282. dev_dbg(component->dev, "%s: event = %d name = %s\n",
  9283. __func__, event, w->name);
  9284. switch (event) {
  9285. case SND_SOC_DAPM_POST_PMU:
  9286. snd_soc_component_write(component,
  9287. WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x3B);
  9288. snd_soc_component_update_bits(component,
  9289. WCD9335_CPE_SS_CFG, 0x08, 0x08);
  9290. snd_soc_component_update_bits(component,
  9291. WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 0x08, 0x08);
  9292. break;
  9293. case SND_SOC_DAPM_POST_PMD:
  9294. snd_soc_component_update_bits(component,
  9295. WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  9296. 0x08, 0x00);
  9297. snd_soc_component_update_bits(component,
  9298. WCD9335_CPE_SS_CFG, 0x08, 0x00);
  9299. snd_soc_component_write(component,
  9300. WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x00);
  9301. break;
  9302. }
  9303. return 0;
  9304. };
  9305. static const char * const ec_buf_mux_text[] = {
  9306. "ZERO", "RXMIXEC", "SB_RX0", "SB_RX1", "SB_RX2", "SB_RX3",
  9307. "I2S_RX_SD0_L", "I2S_RX_SD0_R", "I2S_RX_SD1_L", "I2S_RX_SD1_R",
  9308. "DEC1"
  9309. };
  9310. static SOC_ENUM_SINGLE_DECL(ec_buf_mux_enum, WCD9335_CPE_SS_US_EC_MUX_CFG,
  9311. 0, ec_buf_mux_text);
  9312. static const struct snd_kcontrol_new ec_buf_mux =
  9313. SOC_DAPM_ENUM("EC BUF Mux", ec_buf_mux_enum);
  9314. static const struct snd_soc_dapm_widget tasha_dapm_widgets[] = {
  9315. SND_SOC_DAPM_OUTPUT("EAR"),
  9316. SND_SOC_DAPM_OUTPUT("ANC EAR"),
  9317. SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM,
  9318. AIF1_PB, 0, tasha_codec_enable_slimrx,
  9319. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  9320. SND_SOC_DAPM_POST_PMD),
  9321. SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM,
  9322. AIF2_PB, 0, tasha_codec_enable_slimrx,
  9323. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  9324. SND_SOC_DAPM_POST_PMD),
  9325. SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM,
  9326. AIF3_PB, 0, tasha_codec_enable_slimrx,
  9327. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  9328. SND_SOC_DAPM_POST_PMD),
  9329. SND_SOC_DAPM_AIF_IN_E("AIF4 PB", "AIF4 Playback", 0, SND_SOC_NOPM,
  9330. AIF4_PB, 0, tasha_codec_enable_slimrx,
  9331. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  9332. SND_SOC_DAPM_POST_PMD),
  9333. SND_SOC_DAPM_AIF_IN_E("AIF MIX1 PB", "AIF Mix Playback", 0,
  9334. SND_SOC_NOPM, AIF_MIX1_PB, 0,
  9335. tasha_codec_enable_slimrx,
  9336. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  9337. SND_SOC_DAPM_POST_PMD),
  9338. SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM, TASHA_RX0, 0,
  9339. &slim_rx_mux[TASHA_RX0]),
  9340. SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TASHA_RX1, 0,
  9341. &slim_rx_mux[TASHA_RX1]),
  9342. SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TASHA_RX2, 0,
  9343. &slim_rx_mux[TASHA_RX2]),
  9344. SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TASHA_RX3, 0,
  9345. &slim_rx_mux[TASHA_RX3]),
  9346. SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TASHA_RX4, 0,
  9347. &slim_rx_mux[TASHA_RX4]),
  9348. SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TASHA_RX5, 0,
  9349. &slim_rx_mux[TASHA_RX5]),
  9350. SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, TASHA_RX6, 0,
  9351. &slim_rx_mux[TASHA_RX6]),
  9352. SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, TASHA_RX7, 0,
  9353. &slim_rx_mux[TASHA_RX7]),
  9354. SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
  9355. SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9356. SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9357. SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
  9358. SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
  9359. SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0),
  9360. SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0),
  9361. SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0),
  9362. SND_SOC_DAPM_MUX_E("SPL SRC0 MUX", SND_SOC_NOPM, SPLINE_SRC0, 0,
  9363. &spl_src0_mux, tasha_codec_enable_spline_resampler,
  9364. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9365. SND_SOC_DAPM_MUX_E("SPL SRC1 MUX", SND_SOC_NOPM, SPLINE_SRC1, 0,
  9366. &spl_src1_mux, tasha_codec_enable_spline_resampler,
  9367. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9368. SND_SOC_DAPM_MUX_E("SPL SRC2 MUX", SND_SOC_NOPM, SPLINE_SRC2, 0,
  9369. &spl_src2_mux, tasha_codec_enable_spline_resampler,
  9370. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9371. SND_SOC_DAPM_MUX_E("SPL SRC3 MUX", SND_SOC_NOPM, SPLINE_SRC3, 0,
  9372. &spl_src3_mux, tasha_codec_enable_spline_resampler,
  9373. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9374. SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  9375. 5, 0, &rx_int0_2_mux, tasha_codec_enable_mix_path,
  9376. SND_SOC_DAPM_POST_PMU),
  9377. SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  9378. 5, 0, &rx_int1_2_mux, tasha_codec_enable_mix_path,
  9379. SND_SOC_DAPM_POST_PMU),
  9380. SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  9381. 5, 0, &rx_int2_2_mux, tasha_codec_enable_mix_path,
  9382. SND_SOC_DAPM_POST_PMU),
  9383. SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", WCD9335_CDC_RX3_RX_PATH_MIX_CTL,
  9384. 5, 0, &rx_int3_2_mux, tasha_codec_enable_mix_path,
  9385. SND_SOC_DAPM_POST_PMU),
  9386. SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", WCD9335_CDC_RX4_RX_PATH_MIX_CTL,
  9387. 5, 0, &rx_int4_2_mux, tasha_codec_enable_mix_path,
  9388. SND_SOC_DAPM_POST_PMU),
  9389. SND_SOC_DAPM_MUX_E("RX INT5_2 MUX", WCD9335_CDC_RX5_RX_PATH_MIX_CTL,
  9390. 5, 0, &rx_int5_2_mux, tasha_codec_enable_mix_path,
  9391. SND_SOC_DAPM_POST_PMU),
  9392. SND_SOC_DAPM_MUX_E("RX INT6_2 MUX", WCD9335_CDC_RX6_RX_PATH_MIX_CTL,
  9393. 5, 0, &rx_int6_2_mux, tasha_codec_enable_mix_path,
  9394. SND_SOC_DAPM_POST_PMU),
  9395. SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", WCD9335_CDC_RX7_RX_PATH_MIX_CTL,
  9396. 5, 0, &rx_int7_2_mux, tasha_codec_enable_mix_path,
  9397. SND_SOC_DAPM_POST_PMU),
  9398. SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", WCD9335_CDC_RX8_RX_PATH_MIX_CTL,
  9399. 5, 0, &rx_int8_2_mux, tasha_codec_enable_mix_path,
  9400. SND_SOC_DAPM_POST_PMU),
  9401. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9402. &rx_int0_1_mix_inp0_mux),
  9403. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9404. &rx_int0_1_mix_inp1_mux),
  9405. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9406. &rx_int0_1_mix_inp2_mux),
  9407. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9408. &rx_int1_1_mix_inp0_mux),
  9409. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9410. &rx_int1_1_mix_inp1_mux),
  9411. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9412. &rx_int1_1_mix_inp2_mux),
  9413. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9414. &rx_int2_1_mix_inp0_mux),
  9415. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9416. &rx_int2_1_mix_inp1_mux),
  9417. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9418. &rx_int2_1_mix_inp2_mux),
  9419. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9420. &rx_int3_1_mix_inp0_mux),
  9421. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9422. &rx_int3_1_mix_inp1_mux),
  9423. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9424. &rx_int3_1_mix_inp2_mux),
  9425. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9426. &rx_int4_1_mix_inp0_mux),
  9427. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9428. &rx_int4_1_mix_inp1_mux),
  9429. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9430. &rx_int4_1_mix_inp2_mux),
  9431. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9432. &rx_int5_1_mix_inp0_mux),
  9433. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9434. &rx_int5_1_mix_inp1_mux),
  9435. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9436. &rx_int5_1_mix_inp2_mux),
  9437. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9438. &rx_int6_1_mix_inp0_mux),
  9439. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9440. &rx_int6_1_mix_inp1_mux),
  9441. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9442. &rx_int6_1_mix_inp2_mux),
  9443. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9444. &rx_int7_1_mix_inp0_mux, tasha_codec_enable_swr,
  9445. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9446. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9447. &rx_int7_1_mix_inp1_mux, tasha_codec_enable_swr,
  9448. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9449. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9450. &rx_int7_1_mix_inp2_mux, tasha_codec_enable_swr,
  9451. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9452. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9453. &rx_int8_1_mix_inp0_mux, tasha_codec_enable_swr,
  9454. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9455. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9456. &rx_int8_1_mix_inp1_mux, tasha_codec_enable_swr,
  9457. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9458. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9459. &rx_int8_1_mix_inp2_mux, tasha_codec_enable_swr,
  9460. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9461. SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9462. SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9463. SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9464. SND_SOC_DAPM_MIXER("RX INT1 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9465. rx_int1_spline_mix_switch,
  9466. ARRAY_SIZE(rx_int1_spline_mix_switch)),
  9467. SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9468. SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9469. SND_SOC_DAPM_MIXER("RX INT2 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9470. rx_int2_spline_mix_switch,
  9471. ARRAY_SIZE(rx_int2_spline_mix_switch)),
  9472. SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9473. SND_SOC_DAPM_MIXER("RX INT3_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9474. SND_SOC_DAPM_MIXER("RX INT3 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9475. rx_int3_spline_mix_switch,
  9476. ARRAY_SIZE(rx_int3_spline_mix_switch)),
  9477. SND_SOC_DAPM_MIXER("RX INT3 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9478. SND_SOC_DAPM_MIXER("RX INT4_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9479. SND_SOC_DAPM_MIXER("RX INT4 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9480. rx_int4_spline_mix_switch,
  9481. ARRAY_SIZE(rx_int4_spline_mix_switch)),
  9482. SND_SOC_DAPM_MIXER("RX INT4 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9483. SND_SOC_DAPM_MIXER("RX INT5_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9484. SND_SOC_DAPM_MIXER("RX INT5 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9485. rx_int5_spline_mix_switch,
  9486. ARRAY_SIZE(rx_int5_spline_mix_switch)),
  9487. SND_SOC_DAPM_MIXER("RX INT5 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9488. SND_SOC_DAPM_MIXER("RX INT6_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9489. SND_SOC_DAPM_MIXER("RX INT6 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9490. rx_int6_spline_mix_switch,
  9491. ARRAY_SIZE(rx_int6_spline_mix_switch)),
  9492. SND_SOC_DAPM_MIXER("RX INT6 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9493. SND_SOC_DAPM_MIXER("RX INT7_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9494. SND_SOC_DAPM_MIXER("RX INT7 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9495. SND_SOC_DAPM_MIXER("RX INT7 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9496. rx_int7_spline_mix_switch,
  9497. ARRAY_SIZE(rx_int7_spline_mix_switch)),
  9498. SND_SOC_DAPM_MIXER("RX INT8_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9499. SND_SOC_DAPM_MIXER("RX INT8 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9500. SND_SOC_DAPM_MIXER("RX INT8 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9501. rx_int8_spline_mix_switch,
  9502. ARRAY_SIZE(rx_int8_spline_mix_switch)),
  9503. SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9504. SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9505. SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9506. SND_SOC_DAPM_MIXER("RX INT3 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9507. SND_SOC_DAPM_MIXER("RX INT4 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9508. SND_SOC_DAPM_MIXER("RX INT5 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9509. SND_SOC_DAPM_MIXER("RX INT6 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9510. SND_SOC_DAPM_MIXER("RX INT7 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9511. SND_SOC_DAPM_MIXER_E("RX INT7 CHAIN", SND_SOC_NOPM, 0, 0,
  9512. NULL, 0, tasha_codec_spk_boost_event,
  9513. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9514. SND_SOC_DAPM_MIXER_E("RX INT8 CHAIN", SND_SOC_NOPM, 0, 0,
  9515. NULL, 0, tasha_codec_spk_boost_event,
  9516. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9517. SND_SOC_DAPM_MIXER_E("RX INT5 VBAT", SND_SOC_NOPM, 0, 0,
  9518. rx_int5_vbat_mix_switch,
  9519. ARRAY_SIZE(rx_int5_vbat_mix_switch),
  9520. tasha_codec_vbat_enable_event,
  9521. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9522. SND_SOC_DAPM_MIXER_E("RX INT6 VBAT", SND_SOC_NOPM, 0, 0,
  9523. rx_int6_vbat_mix_switch,
  9524. ARRAY_SIZE(rx_int6_vbat_mix_switch),
  9525. tasha_codec_vbat_enable_event,
  9526. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9527. SND_SOC_DAPM_MIXER_E("RX INT7 VBAT", SND_SOC_NOPM, 0, 0,
  9528. rx_int7_vbat_mix_switch,
  9529. ARRAY_SIZE(rx_int7_vbat_mix_switch),
  9530. tasha_codec_vbat_enable_event,
  9531. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9532. SND_SOC_DAPM_MIXER_E("RX INT8 VBAT", SND_SOC_NOPM, 0, 0,
  9533. rx_int8_vbat_mix_switch,
  9534. ARRAY_SIZE(rx_int8_vbat_mix_switch),
  9535. tasha_codec_vbat_enable_event,
  9536. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9537. SND_SOC_DAPM_MUX("RX INT0 MIX2 INP", WCD9335_CDC_RX0_RX_PATH_CFG1, 4,
  9538. 0, &rx_int0_mix2_inp_mux),
  9539. SND_SOC_DAPM_MUX("RX INT1 MIX2 INP", WCD9335_CDC_RX1_RX_PATH_CFG1, 4,
  9540. 0, &rx_int1_mix2_inp_mux),
  9541. SND_SOC_DAPM_MUX("RX INT2 MIX2 INP", WCD9335_CDC_RX2_RX_PATH_CFG1, 4,
  9542. 0, &rx_int2_mix2_inp_mux),
  9543. SND_SOC_DAPM_MUX("RX INT3 MIX2 INP", WCD9335_CDC_RX3_RX_PATH_CFG1, 4,
  9544. 0, &rx_int3_mix2_inp_mux),
  9545. SND_SOC_DAPM_MUX("RX INT4 MIX2 INP", WCD9335_CDC_RX4_RX_PATH_CFG1, 4,
  9546. 0, &rx_int4_mix2_inp_mux),
  9547. SND_SOC_DAPM_MUX("RX INT7 MIX2 INP", WCD9335_CDC_RX7_RX_PATH_CFG1, 4,
  9548. 0, &rx_int7_mix2_inp_mux),
  9549. SND_SOC_DAPM_MUX("SLIM TX0 MUX", SND_SOC_NOPM, TASHA_TX0, 0,
  9550. &sb_tx0_mux),
  9551. SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TASHA_TX1, 0,
  9552. &sb_tx1_mux),
  9553. SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TASHA_TX2, 0,
  9554. &sb_tx2_mux),
  9555. SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TASHA_TX3, 0,
  9556. &sb_tx3_mux),
  9557. SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TASHA_TX4, 0,
  9558. &sb_tx4_mux),
  9559. SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TASHA_TX5, 0,
  9560. &sb_tx5_mux),
  9561. SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, TASHA_TX6, 0,
  9562. &sb_tx6_mux),
  9563. SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, TASHA_TX7, 0,
  9564. &sb_tx7_mux),
  9565. SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, TASHA_TX8, 0,
  9566. &sb_tx8_mux),
  9567. SND_SOC_DAPM_MUX("SLIM TX9 MUX", SND_SOC_NOPM, TASHA_TX9, 0,
  9568. &sb_tx9_mux),
  9569. SND_SOC_DAPM_MUX("SLIM TX10 MUX", SND_SOC_NOPM, TASHA_TX10, 0,
  9570. &sb_tx10_mux),
  9571. SND_SOC_DAPM_MUX("SLIM TX11 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9572. &sb_tx11_mux),
  9573. SND_SOC_DAPM_MUX("SLIM TX11 INP1 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9574. &sb_tx11_inp1_mux),
  9575. SND_SOC_DAPM_MUX("SLIM TX13 MUX", SND_SOC_NOPM, TASHA_TX13, 0,
  9576. &sb_tx13_mux),
  9577. SND_SOC_DAPM_MUX("TX13 INP MUX", SND_SOC_NOPM, 0, 0,
  9578. &tx13_inp_mux),
  9579. SND_SOC_DAPM_MUX_E("ADC MUX0", WCD9335_CDC_TX0_TX_PATH_CTL, 5, 0,
  9580. &tx_adc_mux0, tasha_codec_enable_dec,
  9581. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9582. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9583. SND_SOC_DAPM_MUX_E("ADC MUX1", WCD9335_CDC_TX1_TX_PATH_CTL, 5, 0,
  9584. &tx_adc_mux1, tasha_codec_enable_dec,
  9585. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9586. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9587. SND_SOC_DAPM_MUX_E("ADC MUX2", WCD9335_CDC_TX2_TX_PATH_CTL, 5, 0,
  9588. &tx_adc_mux2, tasha_codec_enable_dec,
  9589. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9590. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9591. SND_SOC_DAPM_MUX_E("ADC MUX3", WCD9335_CDC_TX3_TX_PATH_CTL, 5, 0,
  9592. &tx_adc_mux3, tasha_codec_enable_dec,
  9593. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9594. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9595. SND_SOC_DAPM_MUX_E("ADC MUX4", WCD9335_CDC_TX4_TX_PATH_CTL, 5, 0,
  9596. &tx_adc_mux4, tasha_codec_enable_dec,
  9597. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9598. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9599. SND_SOC_DAPM_MUX_E("ADC MUX5", WCD9335_CDC_TX5_TX_PATH_CTL, 5, 0,
  9600. &tx_adc_mux5, tasha_codec_enable_dec,
  9601. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9602. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9603. SND_SOC_DAPM_MUX_E("ADC MUX6", WCD9335_CDC_TX6_TX_PATH_CTL, 5, 0,
  9604. &tx_adc_mux6, tasha_codec_enable_dec,
  9605. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9606. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9607. SND_SOC_DAPM_MUX_E("ADC MUX7", WCD9335_CDC_TX7_TX_PATH_CTL, 5, 0,
  9608. &tx_adc_mux7, tasha_codec_enable_dec,
  9609. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9610. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9611. SND_SOC_DAPM_MUX_E("ADC MUX8", WCD9335_CDC_TX8_TX_PATH_CTL, 5, 0,
  9612. &tx_adc_mux8, tasha_codec_enable_dec,
  9613. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9614. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9615. SND_SOC_DAPM_MUX_E("ADC MUX10", SND_SOC_NOPM, 10, 0,
  9616. &tx_adc_mux10, tasha_codec_tx_adc_cfg,
  9617. SND_SOC_DAPM_POST_PMU),
  9618. SND_SOC_DAPM_MUX_E("ADC MUX11", SND_SOC_NOPM, 11, 0,
  9619. &tx_adc_mux11, tasha_codec_tx_adc_cfg,
  9620. SND_SOC_DAPM_POST_PMU),
  9621. SND_SOC_DAPM_MUX_E("ADC MUX12", SND_SOC_NOPM, 12, 0,
  9622. &tx_adc_mux12, tasha_codec_tx_adc_cfg,
  9623. SND_SOC_DAPM_POST_PMU),
  9624. SND_SOC_DAPM_MUX_E("ADC MUX13", SND_SOC_NOPM, 13, 0,
  9625. &tx_adc_mux13, tasha_codec_tx_adc_cfg,
  9626. SND_SOC_DAPM_POST_PMU),
  9627. SND_SOC_DAPM_MUX("DMIC MUX0", SND_SOC_NOPM, 0, 0,
  9628. &tx_dmic_mux0),
  9629. SND_SOC_DAPM_MUX("DMIC MUX1", SND_SOC_NOPM, 0, 0,
  9630. &tx_dmic_mux1),
  9631. SND_SOC_DAPM_MUX("DMIC MUX2", SND_SOC_NOPM, 0, 0,
  9632. &tx_dmic_mux2),
  9633. SND_SOC_DAPM_MUX("DMIC MUX3", SND_SOC_NOPM, 0, 0,
  9634. &tx_dmic_mux3),
  9635. SND_SOC_DAPM_MUX("DMIC MUX4", SND_SOC_NOPM, 0, 0,
  9636. &tx_dmic_mux4),
  9637. SND_SOC_DAPM_MUX("DMIC MUX5", SND_SOC_NOPM, 0, 0,
  9638. &tx_dmic_mux5),
  9639. SND_SOC_DAPM_MUX("DMIC MUX6", SND_SOC_NOPM, 0, 0,
  9640. &tx_dmic_mux6),
  9641. SND_SOC_DAPM_MUX("DMIC MUX7", SND_SOC_NOPM, 0, 0,
  9642. &tx_dmic_mux7),
  9643. SND_SOC_DAPM_MUX("DMIC MUX8", SND_SOC_NOPM, 0, 0,
  9644. &tx_dmic_mux8),
  9645. SND_SOC_DAPM_MUX("DMIC MUX10", SND_SOC_NOPM, 0, 0,
  9646. &tx_dmic_mux10),
  9647. SND_SOC_DAPM_MUX("DMIC MUX11", SND_SOC_NOPM, 0, 0,
  9648. &tx_dmic_mux11),
  9649. SND_SOC_DAPM_MUX("DMIC MUX12", SND_SOC_NOPM, 0, 0,
  9650. &tx_dmic_mux12),
  9651. SND_SOC_DAPM_MUX("DMIC MUX13", SND_SOC_NOPM, 0, 0,
  9652. &tx_dmic_mux13),
  9653. SND_SOC_DAPM_MUX("AMIC MUX0", SND_SOC_NOPM, 0, 0,
  9654. &tx_amic_mux0),
  9655. SND_SOC_DAPM_MUX("AMIC MUX1", SND_SOC_NOPM, 0, 0,
  9656. &tx_amic_mux1),
  9657. SND_SOC_DAPM_MUX("AMIC MUX2", SND_SOC_NOPM, 0, 0,
  9658. &tx_amic_mux2),
  9659. SND_SOC_DAPM_MUX("AMIC MUX3", SND_SOC_NOPM, 0, 0,
  9660. &tx_amic_mux3),
  9661. SND_SOC_DAPM_MUX("AMIC MUX4", SND_SOC_NOPM, 0, 0,
  9662. &tx_amic_mux4),
  9663. SND_SOC_DAPM_MUX("AMIC MUX5", SND_SOC_NOPM, 0, 0,
  9664. &tx_amic_mux5),
  9665. SND_SOC_DAPM_MUX("AMIC MUX6", SND_SOC_NOPM, 0, 0,
  9666. &tx_amic_mux6),
  9667. SND_SOC_DAPM_MUX("AMIC MUX7", SND_SOC_NOPM, 0, 0,
  9668. &tx_amic_mux7),
  9669. SND_SOC_DAPM_MUX("AMIC MUX8", SND_SOC_NOPM, 0, 0,
  9670. &tx_amic_mux8),
  9671. SND_SOC_DAPM_MUX("AMIC MUX10", SND_SOC_NOPM, 0, 0,
  9672. &tx_amic_mux10),
  9673. SND_SOC_DAPM_MUX("AMIC MUX11", SND_SOC_NOPM, 0, 0,
  9674. &tx_amic_mux11),
  9675. SND_SOC_DAPM_MUX("AMIC MUX12", SND_SOC_NOPM, 0, 0,
  9676. &tx_amic_mux12),
  9677. SND_SOC_DAPM_MUX("AMIC MUX13", SND_SOC_NOPM, 0, 0,
  9678. &tx_amic_mux13),
  9679. SND_SOC_DAPM_ADC_E("ADC1", NULL, WCD9335_ANA_AMIC1, 7, 0,
  9680. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9681. SND_SOC_DAPM_ADC_E("ADC2", NULL, WCD9335_ANA_AMIC2, 7, 0,
  9682. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9683. SND_SOC_DAPM_ADC_E("ADC3", NULL, WCD9335_ANA_AMIC3, 7, 0,
  9684. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9685. SND_SOC_DAPM_ADC_E("ADC4", NULL, WCD9335_ANA_AMIC4, 7, 0,
  9686. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9687. SND_SOC_DAPM_ADC_E("ADC5", NULL, WCD9335_ANA_AMIC5, 7, 0,
  9688. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9689. SND_SOC_DAPM_ADC_E("ADC6", NULL, WCD9335_ANA_AMIC6, 7, 0,
  9690. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9691. SND_SOC_DAPM_SUPPLY("RX INT1 NATIVE SUPPLY", SND_SOC_NOPM,
  9692. INTERP_HPHL, 0, tasha_enable_native_supply,
  9693. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9694. SND_SOC_DAPM_SUPPLY("RX INT2 NATIVE SUPPLY", SND_SOC_NOPM,
  9695. INTERP_HPHR, 0, tasha_enable_native_supply,
  9696. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9697. SND_SOC_DAPM_SUPPLY("RX INT3 NATIVE SUPPLY", SND_SOC_NOPM,
  9698. INTERP_LO1, 0, tasha_enable_native_supply,
  9699. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9700. SND_SOC_DAPM_SUPPLY("RX INT4 NATIVE SUPPLY", SND_SOC_NOPM,
  9701. INTERP_LO2, 0, tasha_enable_native_supply,
  9702. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9703. SND_SOC_DAPM_INPUT("AMIC1"),
  9704. SND_SOC_DAPM_MICBIAS_E("MIC BIAS1", SND_SOC_NOPM, 0, 0,
  9705. tasha_codec_enable_micbias,
  9706. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9707. SND_SOC_DAPM_POST_PMD),
  9708. SND_SOC_DAPM_MICBIAS_E("MIC BIAS2", SND_SOC_NOPM, 0, 0,
  9709. tasha_codec_enable_micbias,
  9710. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9711. SND_SOC_DAPM_POST_PMD),
  9712. SND_SOC_DAPM_MICBIAS_E("MIC BIAS3", SND_SOC_NOPM, 0, 0,
  9713. tasha_codec_enable_micbias,
  9714. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9715. SND_SOC_DAPM_POST_PMD),
  9716. SND_SOC_DAPM_MICBIAS_E("MIC BIAS4", SND_SOC_NOPM, 0, 0,
  9717. tasha_codec_enable_micbias,
  9718. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9719. SND_SOC_DAPM_POST_PMD),
  9720. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS1_STANDALONE, SND_SOC_NOPM, 0, 0,
  9721. tasha_codec_force_enable_micbias,
  9722. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9723. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS2_STANDALONE, SND_SOC_NOPM, 0, 0,
  9724. tasha_codec_force_enable_micbias,
  9725. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9726. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS3_STANDALONE, SND_SOC_NOPM, 0, 0,
  9727. tasha_codec_force_enable_micbias,
  9728. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9729. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS4_STANDALONE, SND_SOC_NOPM, 0, 0,
  9730. tasha_codec_force_enable_micbias,
  9731. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9732. SND_SOC_DAPM_SUPPLY(DAPM_LDO_H_STANDALONE, SND_SOC_NOPM, 0, 0,
  9733. tasha_codec_force_enable_ldo_h,
  9734. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9735. SND_SOC_DAPM_SUPPLY("tx regulator", SND_SOC_NOPM,
  9736. ON_DEMAND_TX_SUPPLY, 0,
  9737. tasha_codec_enable_on_demand_supply,
  9738. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9739. SND_SOC_DAPM_SUPPLY("rx regulator", SND_SOC_NOPM,
  9740. ON_DEMAND_RX_SUPPLY, 0,
  9741. tasha_codec_enable_on_demand_supply,
  9742. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9743. SND_SOC_DAPM_MUX("ANC0 FB MUX", SND_SOC_NOPM, 0, 0, &anc0_fb_mux),
  9744. SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux),
  9745. SND_SOC_DAPM_INPUT("AMIC2"),
  9746. SND_SOC_DAPM_INPUT("AMIC3"),
  9747. SND_SOC_DAPM_INPUT("AMIC4"),
  9748. SND_SOC_DAPM_INPUT("AMIC5"),
  9749. SND_SOC_DAPM_INPUT("AMIC6"),
  9750. SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM,
  9751. AIF1_CAP, 0, tasha_codec_enable_slimtx,
  9752. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9753. SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM,
  9754. AIF2_CAP, 0, tasha_codec_enable_slimtx,
  9755. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9756. SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM,
  9757. AIF3_CAP, 0, tasha_codec_enable_slimtx,
  9758. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9759. SND_SOC_DAPM_AIF_OUT_E("AIF4 VI", "VIfeed", 0, SND_SOC_NOPM,
  9760. AIF4_VIFEED, 0, tasha_codec_enable_slimvi_feedback,
  9761. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9762. SND_SOC_DAPM_MIXER("AIF4_VI Mixer", SND_SOC_NOPM, AIF4_VIFEED, 0,
  9763. aif4_vi_mixer, ARRAY_SIZE(aif4_vi_mixer)),
  9764. SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0,
  9765. aif1_cap_mixer, ARRAY_SIZE(aif1_cap_mixer)),
  9766. SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0,
  9767. aif2_cap_mixer, ARRAY_SIZE(aif2_cap_mixer)),
  9768. SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0,
  9769. aif3_cap_mixer, ARRAY_SIZE(aif3_cap_mixer)),
  9770. SND_SOC_DAPM_MIXER("AIF4_MAD Mixer", SND_SOC_NOPM, AIF4_MAD_TX, 0,
  9771. aif4_mad_mixer, ARRAY_SIZE(aif4_mad_mixer)),
  9772. SND_SOC_DAPM_INPUT("VIINPUT"),
  9773. SND_SOC_DAPM_AIF_OUT("AIF5 CPE", "AIF5 CPE TX", 0, SND_SOC_NOPM,
  9774. AIF5_CPE_TX, 0),
  9775. SND_SOC_DAPM_MUX_E("EC BUF MUX INP", SND_SOC_NOPM, 0, 0, &ec_buf_mux,
  9776. tasha_codec_ec_buf_mux_enable,
  9777. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9778. /* Digital Mic Inputs */
  9779. SND_SOC_DAPM_ADC_E("DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  9780. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9781. SND_SOC_DAPM_POST_PMD),
  9782. SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  9783. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9784. SND_SOC_DAPM_POST_PMD),
  9785. SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  9786. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9787. SND_SOC_DAPM_POST_PMD),
  9788. SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  9789. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9790. SND_SOC_DAPM_POST_PMD),
  9791. SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  9792. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9793. SND_SOC_DAPM_POST_PMD),
  9794. SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  9795. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9796. SND_SOC_DAPM_POST_PMD),
  9797. SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux),
  9798. SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux),
  9799. SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux),
  9800. SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux),
  9801. SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux),
  9802. SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
  9803. SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux),
  9804. SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux),
  9805. SND_SOC_DAPM_MIXER_E("IIR0", WCD9335_CDC_SIDETONE_IIR0_IIR_PATH_CTL,
  9806. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9807. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9808. SND_SOC_DAPM_MIXER_E("IIR1", WCD9335_CDC_SIDETONE_IIR1_IIR_PATH_CTL,
  9809. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9810. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9811. SND_SOC_DAPM_MIXER("SRC0", WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL,
  9812. 4, 0, NULL, 0),
  9813. SND_SOC_DAPM_MIXER("SRC1", WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL,
  9814. 4, 0, NULL, 0),
  9815. SND_SOC_DAPM_MIXER_E("CPE IN Mixer", SND_SOC_NOPM, 0, 0,
  9816. cpe_in_mix_switch,
  9817. ARRAY_SIZE(cpe_in_mix_switch),
  9818. tasha_codec_configure_cpe_input,
  9819. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9820. SND_SOC_DAPM_MUX("RX INT1_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9821. &int1_1_native_mux),
  9822. SND_SOC_DAPM_MUX("RX INT2_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9823. &int2_1_native_mux),
  9824. SND_SOC_DAPM_MUX("RX INT3_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9825. &int3_1_native_mux),
  9826. SND_SOC_DAPM_MUX("RX INT4_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9827. &int4_1_native_mux),
  9828. SND_SOC_DAPM_MUX("RX MIX TX0 MUX", SND_SOC_NOPM, 0, 0,
  9829. &rx_mix_tx0_mux),
  9830. SND_SOC_DAPM_MUX("RX MIX TX1 MUX", SND_SOC_NOPM, 0, 0,
  9831. &rx_mix_tx1_mux),
  9832. SND_SOC_DAPM_MUX("RX MIX TX2 MUX", SND_SOC_NOPM, 0, 0,
  9833. &rx_mix_tx2_mux),
  9834. SND_SOC_DAPM_MUX("RX MIX TX3 MUX", SND_SOC_NOPM, 0, 0,
  9835. &rx_mix_tx3_mux),
  9836. SND_SOC_DAPM_MUX("RX MIX TX4 MUX", SND_SOC_NOPM, 0, 0,
  9837. &rx_mix_tx4_mux),
  9838. SND_SOC_DAPM_MUX("RX MIX TX5 MUX", SND_SOC_NOPM, 0, 0,
  9839. &rx_mix_tx5_mux),
  9840. SND_SOC_DAPM_MUX("RX MIX TX6 MUX", SND_SOC_NOPM, 0, 0,
  9841. &rx_mix_tx6_mux),
  9842. SND_SOC_DAPM_MUX("RX MIX TX7 MUX", SND_SOC_NOPM, 0, 0,
  9843. &rx_mix_tx7_mux),
  9844. SND_SOC_DAPM_MUX("RX MIX TX8 MUX", SND_SOC_NOPM, 0, 0,
  9845. &rx_mix_tx8_mux),
  9846. SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0,
  9847. &rx_int0_dem_inp_mux),
  9848. SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0,
  9849. &rx_int1_dem_inp_mux),
  9850. SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM, 0, 0,
  9851. &rx_int2_dem_inp_mux),
  9852. SND_SOC_DAPM_MUX_E("RX INT0 INTERP", SND_SOC_NOPM,
  9853. INTERP_EAR, 0, &rx_int0_interp_mux,
  9854. tasha_codec_enable_interpolator,
  9855. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9856. SND_SOC_DAPM_POST_PMD),
  9857. SND_SOC_DAPM_MUX_E("RX INT1 INTERP", SND_SOC_NOPM,
  9858. INTERP_HPHL, 0, &rx_int1_interp_mux,
  9859. tasha_codec_enable_interpolator,
  9860. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9861. SND_SOC_DAPM_POST_PMD),
  9862. SND_SOC_DAPM_MUX_E("RX INT2 INTERP", SND_SOC_NOPM,
  9863. INTERP_HPHR, 0, &rx_int2_interp_mux,
  9864. tasha_codec_enable_interpolator,
  9865. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9866. SND_SOC_DAPM_POST_PMD),
  9867. SND_SOC_DAPM_MUX_E("RX INT3 INTERP", SND_SOC_NOPM,
  9868. INTERP_LO1, 0, &rx_int3_interp_mux,
  9869. tasha_codec_enable_interpolator,
  9870. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9871. SND_SOC_DAPM_POST_PMD),
  9872. SND_SOC_DAPM_MUX_E("RX INT4 INTERP", SND_SOC_NOPM,
  9873. INTERP_LO2, 0, &rx_int4_interp_mux,
  9874. tasha_codec_enable_interpolator,
  9875. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9876. SND_SOC_DAPM_POST_PMD),
  9877. SND_SOC_DAPM_MUX_E("RX INT5 INTERP", SND_SOC_NOPM,
  9878. INTERP_LO3, 0, &rx_int5_interp_mux,
  9879. tasha_codec_enable_interpolator,
  9880. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9881. SND_SOC_DAPM_POST_PMD),
  9882. SND_SOC_DAPM_MUX_E("RX INT6 INTERP", SND_SOC_NOPM,
  9883. INTERP_LO4, 0, &rx_int6_interp_mux,
  9884. tasha_codec_enable_interpolator,
  9885. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9886. SND_SOC_DAPM_POST_PMD),
  9887. SND_SOC_DAPM_MUX_E("RX INT7 INTERP", SND_SOC_NOPM,
  9888. INTERP_SPKR1, 0, &rx_int7_interp_mux,
  9889. tasha_codec_enable_interpolator,
  9890. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9891. SND_SOC_DAPM_POST_PMD),
  9892. SND_SOC_DAPM_MUX_E("RX INT8 INTERP", SND_SOC_NOPM,
  9893. INTERP_SPKR2, 0, &rx_int8_interp_mux,
  9894. tasha_codec_enable_interpolator,
  9895. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9896. SND_SOC_DAPM_POST_PMD),
  9897. SND_SOC_DAPM_DAC_E("RX INT0 DAC", NULL, SND_SOC_NOPM,
  9898. 0, 0, tasha_codec_ear_dac_event,
  9899. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9900. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9901. SND_SOC_DAPM_DAC_E("RX INT1 DAC", NULL, SND_SOC_NOPM,
  9902. 0, 0, tasha_codec_hphl_dac_event,
  9903. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9904. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9905. SND_SOC_DAPM_DAC_E("RX INT2 DAC", NULL, SND_SOC_NOPM,
  9906. 0, 0, tasha_codec_hphr_dac_event,
  9907. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9908. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9909. SND_SOC_DAPM_DAC_E("RX INT3 DAC", NULL, SND_SOC_NOPM,
  9910. 0, 0, tasha_codec_lineout_dac_event,
  9911. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9912. SND_SOC_DAPM_DAC_E("RX INT4 DAC", NULL, SND_SOC_NOPM,
  9913. 0, 0, tasha_codec_lineout_dac_event,
  9914. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9915. SND_SOC_DAPM_DAC_E("RX INT5 DAC", NULL, SND_SOC_NOPM,
  9916. 0, 0, tasha_codec_lineout_dac_event,
  9917. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9918. SND_SOC_DAPM_DAC_E("RX INT6 DAC", NULL, SND_SOC_NOPM,
  9919. 0, 0, tasha_codec_lineout_dac_event,
  9920. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9921. SND_SOC_DAPM_PGA_E("HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9922. tasha_codec_enable_hphl_pa,
  9923. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9924. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9925. SND_SOC_DAPM_PGA_E("HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9926. tasha_codec_enable_hphr_pa,
  9927. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9928. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9929. SND_SOC_DAPM_PGA_E("EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9930. tasha_codec_enable_ear_pa,
  9931. SND_SOC_DAPM_POST_PMU |
  9932. SND_SOC_DAPM_POST_PMD),
  9933. SND_SOC_DAPM_PGA_E("LINEOUT1 PA", WCD9335_ANA_LO_1_2, 7, 0, NULL, 0,
  9934. tasha_codec_enable_lineout_pa,
  9935. SND_SOC_DAPM_POST_PMU |
  9936. SND_SOC_DAPM_POST_PMD),
  9937. SND_SOC_DAPM_PGA_E("LINEOUT2 PA", WCD9335_ANA_LO_1_2, 6, 0, NULL, 0,
  9938. tasha_codec_enable_lineout_pa,
  9939. SND_SOC_DAPM_POST_PMU |
  9940. SND_SOC_DAPM_POST_PMD),
  9941. SND_SOC_DAPM_PGA_E("LINEOUT3 PA", WCD9335_ANA_LO_3_4, 7, 0, NULL, 0,
  9942. tasha_codec_enable_lineout_pa,
  9943. SND_SOC_DAPM_POST_PMU |
  9944. SND_SOC_DAPM_POST_PMD),
  9945. SND_SOC_DAPM_PGA_E("LINEOUT4 PA", WCD9335_ANA_LO_3_4, 6, 0, NULL, 0,
  9946. tasha_codec_enable_lineout_pa,
  9947. SND_SOC_DAPM_POST_PMU |
  9948. SND_SOC_DAPM_POST_PMD),
  9949. SND_SOC_DAPM_PGA_E("ANC EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9950. tasha_codec_enable_ear_pa,
  9951. SND_SOC_DAPM_POST_PMU |
  9952. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9953. SND_SOC_DAPM_PGA_E("ANC HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9954. tasha_codec_enable_hphl_pa,
  9955. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9956. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9957. SND_SOC_DAPM_PGA_E("ANC HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9958. tasha_codec_enable_hphr_pa,
  9959. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9960. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9961. SND_SOC_DAPM_PGA_E("ANC LINEOUT1 PA", WCD9335_ANA_LO_1_2,
  9962. 7, 0, NULL, 0,
  9963. tasha_codec_enable_lineout_pa,
  9964. SND_SOC_DAPM_POST_PMU |
  9965. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9966. SND_SOC_DAPM_PGA_E("ANC LINEOUT2 PA", WCD9335_ANA_LO_1_2,
  9967. 6, 0, NULL, 0,
  9968. tasha_codec_enable_lineout_pa,
  9969. SND_SOC_DAPM_POST_PMU |
  9970. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9971. SND_SOC_DAPM_PGA_E("ANC SPK1 PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9972. tasha_codec_enable_spk_anc,
  9973. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9974. SND_SOC_DAPM_OUTPUT("HPHL"),
  9975. SND_SOC_DAPM_OUTPUT("HPHR"),
  9976. SND_SOC_DAPM_OUTPUT("ANC HPHL"),
  9977. SND_SOC_DAPM_OUTPUT("ANC HPHR"),
  9978. SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0,
  9979. tasha_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU |
  9980. SND_SOC_DAPM_POST_PMD),
  9981. SND_SOC_DAPM_OUTPUT("SPK1 OUT"),
  9982. SND_SOC_DAPM_OUTPUT("SPK2 OUT"),
  9983. SND_SOC_DAPM_OUTPUT("LINEOUT1"),
  9984. SND_SOC_DAPM_OUTPUT("LINEOUT2"),
  9985. SND_SOC_DAPM_OUTPUT("LINEOUT3"),
  9986. SND_SOC_DAPM_OUTPUT("LINEOUT4"),
  9987. SND_SOC_DAPM_OUTPUT("ANC LINEOUT1"),
  9988. SND_SOC_DAPM_OUTPUT("ANC LINEOUT2"),
  9989. SND_SOC_DAPM_SUPPLY("MICBIAS_REGULATOR", SND_SOC_NOPM,
  9990. ON_DEMAND_MICBIAS, 0,
  9991. tasha_codec_enable_on_demand_supply,
  9992. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9993. SND_SOC_DAPM_SWITCH("ADC US MUX0", WCD9335_CDC_TX0_TX_PATH_192_CTL, 0,
  9994. 0, &adc_us_mux0_switch),
  9995. SND_SOC_DAPM_SWITCH("ADC US MUX1", WCD9335_CDC_TX1_TX_PATH_192_CTL, 0,
  9996. 0, &adc_us_mux1_switch),
  9997. SND_SOC_DAPM_SWITCH("ADC US MUX2", WCD9335_CDC_TX2_TX_PATH_192_CTL, 0,
  9998. 0, &adc_us_mux2_switch),
  9999. SND_SOC_DAPM_SWITCH("ADC US MUX3", WCD9335_CDC_TX3_TX_PATH_192_CTL, 0,
  10000. 0, &adc_us_mux3_switch),
  10001. SND_SOC_DAPM_SWITCH("ADC US MUX4", WCD9335_CDC_TX4_TX_PATH_192_CTL, 0,
  10002. 0, &adc_us_mux4_switch),
  10003. SND_SOC_DAPM_SWITCH("ADC US MUX5", WCD9335_CDC_TX5_TX_PATH_192_CTL, 0,
  10004. 0, &adc_us_mux5_switch),
  10005. SND_SOC_DAPM_SWITCH("ADC US MUX6", WCD9335_CDC_TX6_TX_PATH_192_CTL, 0,
  10006. 0, &adc_us_mux6_switch),
  10007. SND_SOC_DAPM_SWITCH("ADC US MUX7", WCD9335_CDC_TX7_TX_PATH_192_CTL, 0,
  10008. 0, &adc_us_mux7_switch),
  10009. SND_SOC_DAPM_SWITCH("ADC US MUX8", WCD9335_CDC_TX8_TX_PATH_192_CTL, 0,
  10010. 0, &adc_us_mux8_switch),
  10011. /* MAD related widgets */
  10012. SND_SOC_DAPM_AIF_OUT_E("AIF4 MAD", "AIF4 MAD TX", 0,
  10013. SND_SOC_NOPM, 0, 0,
  10014. tasha_codec_enable_mad,
  10015. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  10016. SND_SOC_DAPM_MUX("MAD_SEL MUX", SND_SOC_NOPM, 0, 0,
  10017. &mad_sel_mux),
  10018. SND_SOC_DAPM_INPUT("MAD_CPE_INPUT"),
  10019. SND_SOC_DAPM_INPUT("MADINPUT"),
  10020. SND_SOC_DAPM_SWITCH("MADONOFF", SND_SOC_NOPM, 0, 0,
  10021. &aif4_mad_switch),
  10022. SND_SOC_DAPM_SWITCH("MAD_BROADCAST", SND_SOC_NOPM, 0, 0,
  10023. &mad_brdcst_switch),
  10024. SND_SOC_DAPM_SWITCH("AIF4", SND_SOC_NOPM, 0, 0,
  10025. &aif4_switch_mixer_controls),
  10026. SND_SOC_DAPM_SWITCH("ANC HPHL Enable", SND_SOC_NOPM, 0, 0,
  10027. &anc_hphl_switch),
  10028. SND_SOC_DAPM_SWITCH("ANC HPHR Enable", SND_SOC_NOPM, 0, 0,
  10029. &anc_hphr_switch),
  10030. SND_SOC_DAPM_SWITCH("ANC EAR Enable", SND_SOC_NOPM, 0, 0,
  10031. &anc_ear_switch),
  10032. SND_SOC_DAPM_SWITCH("ANC OUT EAR SPKR Enable", SND_SOC_NOPM, 0, 0,
  10033. &anc_ear_spkr_switch),
  10034. SND_SOC_DAPM_SWITCH("ANC LINEOUT1 Enable", SND_SOC_NOPM, 0, 0,
  10035. &anc_lineout1_switch),
  10036. SND_SOC_DAPM_SWITCH("ANC LINEOUT2 Enable", SND_SOC_NOPM, 0, 0,
  10037. &anc_lineout2_switch),
  10038. SND_SOC_DAPM_SWITCH("ANC SPKR PA Enable", SND_SOC_NOPM, 0, 0,
  10039. &anc_spkr_pa_switch),
  10040. };
  10041. static int tasha_get_channel_map(struct snd_soc_dai *dai,
  10042. unsigned int *tx_num, unsigned int *tx_slot,
  10043. unsigned int *rx_num, unsigned int *rx_slot)
  10044. {
  10045. struct tasha_priv *tasha_p =
  10046. snd_soc_component_get_drvdata(dai->component);
  10047. u32 i = 0;
  10048. struct wcd9xxx_ch *ch;
  10049. switch (dai->id) {
  10050. case AIF1_PB:
  10051. case AIF2_PB:
  10052. case AIF3_PB:
  10053. case AIF4_PB:
  10054. case AIF_MIX1_PB:
  10055. if (!rx_slot || !rx_num) {
  10056. pr_err("%s: Invalid rx_slot %pK or rx_num %pK\n",
  10057. __func__, rx_slot, rx_num);
  10058. return -EINVAL;
  10059. }
  10060. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  10061. list) {
  10062. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  10063. __func__, i, ch->ch_num);
  10064. rx_slot[i++] = ch->ch_num;
  10065. }
  10066. pr_debug("%s: rx_num %d\n", __func__, i);
  10067. *rx_num = i;
  10068. break;
  10069. case AIF1_CAP:
  10070. case AIF2_CAP:
  10071. case AIF3_CAP:
  10072. case AIF4_MAD_TX:
  10073. case AIF4_VIFEED:
  10074. if (!tx_slot || !tx_num) {
  10075. pr_err("%s: Invalid tx_slot %pK or tx_num %pK\n",
  10076. __func__, tx_slot, tx_num);
  10077. return -EINVAL;
  10078. }
  10079. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  10080. list) {
  10081. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  10082. __func__, i, ch->ch_num);
  10083. tx_slot[i++] = ch->ch_num;
  10084. }
  10085. pr_debug("%s: tx_num %d\n", __func__, i);
  10086. *tx_num = i;
  10087. break;
  10088. default:
  10089. pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id);
  10090. break;
  10091. }
  10092. return 0;
  10093. }
  10094. static int tasha_set_channel_map(struct snd_soc_dai *dai,
  10095. unsigned int tx_num, unsigned int *tx_slot,
  10096. unsigned int rx_num, unsigned int *rx_slot)
  10097. {
  10098. struct tasha_priv *tasha;
  10099. struct wcd9xxx *core;
  10100. struct wcd9xxx_codec_dai_data *dai_data = NULL;
  10101. if (!dai) {
  10102. pr_err("%s: dai is empty\n", __func__);
  10103. return -EINVAL;
  10104. }
  10105. tasha = snd_soc_component_get_drvdata(dai->component);
  10106. core = dev_get_drvdata(dai->component->dev->parent);
  10107. if (!tx_slot || !rx_slot) {
  10108. pr_err("%s: Invalid tx_slot=%pK, rx_slot=%pK\n",
  10109. __func__, tx_slot, rx_slot);
  10110. return -EINVAL;
  10111. }
  10112. pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n"
  10113. "tasha->intf_type %d\n",
  10114. __func__, dai->name, dai->id, tx_num, rx_num,
  10115. tasha->intf_type);
  10116. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  10117. wcd9xxx_init_slimslave(core, core->slim->laddr,
  10118. tx_num, tx_slot, rx_num, rx_slot);
  10119. /* Reserve TX12/TX13 for MAD data channel */
  10120. dai_data = &tasha->dai[AIF4_MAD_TX];
  10121. if (dai_data) {
  10122. if (TASHA_IS_2_0(tasha->wcd9xxx))
  10123. list_add_tail(&core->tx_chs[TASHA_TX13].list,
  10124. &dai_data->wcd9xxx_ch_list);
  10125. else
  10126. list_add_tail(&core->tx_chs[TASHA_TX12].list,
  10127. &dai_data->wcd9xxx_ch_list);
  10128. }
  10129. }
  10130. return 0;
  10131. }
  10132. static int tasha_startup(struct snd_pcm_substream *substream,
  10133. struct snd_soc_dai *dai)
  10134. {
  10135. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  10136. substream->name, substream->stream);
  10137. return 0;
  10138. }
  10139. static void tasha_shutdown(struct snd_pcm_substream *substream,
  10140. struct snd_soc_dai *dai)
  10141. {
  10142. struct tasha_priv *tasha =
  10143. snd_soc_component_get_drvdata(dai->component);
  10144. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  10145. substream->name, substream->stream);
  10146. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  10147. return;
  10148. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  10149. tasha_codec_vote_max_bw(dai->component, false);
  10150. }
  10151. static int tasha_set_decimator_rate(struct snd_soc_dai *dai,
  10152. u8 tx_fs_rate_reg_val, u32 sample_rate)
  10153. {
  10154. struct snd_soc_component *component = dai->component;
  10155. struct wcd9xxx_ch *ch;
  10156. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  10157. u32 tx_port = 0;
  10158. u8 shift = 0, shift_val = 0, tx_mux_sel = 0;
  10159. int decimator = -1;
  10160. u16 tx_port_reg = 0, tx_fs_reg = 0;
  10161. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  10162. tx_port = ch->port;
  10163. dev_dbg(component->dev, "%s: dai->id = %d, tx_port = %d",
  10164. __func__, dai->id, tx_port);
  10165. if ((tx_port < 0) || (tx_port == 12) || (tx_port >= 14)) {
  10166. dev_err(component->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n",
  10167. __func__, tx_port, dai->id);
  10168. return -EINVAL;
  10169. }
  10170. /* Find the SB TX MUX input - which decimator is connected */
  10171. if (tx_port < 4) {
  10172. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0;
  10173. shift = (tx_port << 1);
  10174. shift_val = 0x03;
  10175. } else if ((tx_port >= 4) && (tx_port < 8)) {
  10176. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1;
  10177. shift = ((tx_port - 4) << 1);
  10178. shift_val = 0x03;
  10179. } else if ((tx_port >= 8) && (tx_port < 11)) {
  10180. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2;
  10181. shift = ((tx_port - 8) << 1);
  10182. shift_val = 0x03;
  10183. } else if (tx_port == 11) {
  10184. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  10185. shift = 0;
  10186. shift_val = 0x0F;
  10187. } else if (tx_port == 13) {
  10188. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  10189. shift = 4;
  10190. shift_val = 0x03;
  10191. }
  10192. tx_mux_sel = snd_soc_component_read32(component, tx_port_reg) &
  10193. (shift_val << shift);
  10194. tx_mux_sel = tx_mux_sel >> shift;
  10195. if (tx_port <= 8) {
  10196. if ((tx_mux_sel == 0x2) || (tx_mux_sel == 0x3))
  10197. decimator = tx_port;
  10198. } else if (tx_port <= 10) {
  10199. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  10200. decimator = ((tx_port == 9) ? 7 : 6);
  10201. } else if (tx_port == 11) {
  10202. if ((tx_mux_sel >= 1) && (tx_mux_sel < 7))
  10203. decimator = tx_mux_sel - 1;
  10204. } else if (tx_port == 13) {
  10205. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  10206. decimator = 5;
  10207. }
  10208. if (decimator >= 0) {
  10209. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  10210. 16 * decimator;
  10211. dev_dbg(component->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n",
  10212. __func__, decimator, tx_port, sample_rate);
  10213. snd_soc_component_update_bits(component, tx_fs_reg,
  10214. 0x0F, tx_fs_rate_reg_val);
  10215. } else if ((tx_port <= 8) && (tx_mux_sel == 0x01)) {
  10216. /* Check if the TX Mux input is RX MIX TXn */
  10217. dev_dbg(component->dev, "%s: RX_MIX_TX%u going to SLIM TX%u\n",
  10218. __func__, tx_port, tx_port);
  10219. } else {
  10220. dev_err(component->dev, "%s: ERROR: Invalid decimator: %d\n",
  10221. __func__, decimator);
  10222. return -EINVAL;
  10223. }
  10224. }
  10225. return 0;
  10226. }
  10227. static int tasha_set_mix_interpolator_rate(struct snd_soc_dai *dai,
  10228. u8 int_mix_fs_rate_reg_val,
  10229. u32 sample_rate)
  10230. {
  10231. u8 int_2_inp;
  10232. u32 j;
  10233. u16 int_mux_cfg1, int_fs_reg;
  10234. u8 int_mux_cfg1_val;
  10235. struct snd_soc_component *component = dai->component;
  10236. struct wcd9xxx_ch *ch;
  10237. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  10238. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  10239. int_2_inp = ch->port + INTn_2_INP_SEL_RX0 -
  10240. TASHA_RX_PORT_START_NUMBER;
  10241. if ((int_2_inp < INTn_2_INP_SEL_RX0) ||
  10242. (int_2_inp > INTn_2_INP_SEL_RX7)) {
  10243. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  10244. __func__,
  10245. (ch->port - TASHA_RX_PORT_START_NUMBER),
  10246. dai->id);
  10247. return -EINVAL;
  10248. }
  10249. int_mux_cfg1 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1;
  10250. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  10251. int_mux_cfg1_val = snd_soc_component_read32(
  10252. component, int_mux_cfg1) &
  10253. 0x0F;
  10254. if (int_mux_cfg1_val == int_2_inp) {
  10255. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_MIX_CTL +
  10256. 20 * j;
  10257. pr_debug("%s: AIF_MIX_PB DAI(%d) connected to INT%u_2\n",
  10258. __func__, dai->id, j);
  10259. pr_debug("%s: set INT%u_2 sample rate to %u\n",
  10260. __func__, j, sample_rate);
  10261. snd_soc_component_update_bits(component,
  10262. int_fs_reg,
  10263. 0x0F, int_mix_fs_rate_reg_val);
  10264. }
  10265. int_mux_cfg1 += 2;
  10266. }
  10267. }
  10268. return 0;
  10269. }
  10270. static int tasha_set_prim_interpolator_rate(struct snd_soc_dai *dai,
  10271. u8 int_prim_fs_rate_reg_val,
  10272. u32 sample_rate)
  10273. {
  10274. u8 int_1_mix1_inp;
  10275. u32 j;
  10276. u16 int_mux_cfg0, int_mux_cfg1;
  10277. u16 int_fs_reg;
  10278. u8 int_mux_cfg0_val, int_mux_cfg1_val;
  10279. u8 inp0_sel, inp1_sel, inp2_sel;
  10280. struct snd_soc_component *component = dai->component;
  10281. struct wcd9xxx_ch *ch;
  10282. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  10283. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  10284. int_1_mix1_inp = ch->port + INTn_1_MIX_INP_SEL_RX0 -
  10285. TASHA_RX_PORT_START_NUMBER;
  10286. if ((int_1_mix1_inp < INTn_1_MIX_INP_SEL_RX0) ||
  10287. (int_1_mix1_inp > INTn_1_MIX_INP_SEL_RX7)) {
  10288. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  10289. __func__,
  10290. (ch->port - TASHA_RX_PORT_START_NUMBER),
  10291. dai->id);
  10292. return -EINVAL;
  10293. }
  10294. int_mux_cfg0 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0;
  10295. /*
  10296. * Loop through all interpolator MUX inputs and find out
  10297. * to which interpolator input, the slim rx port
  10298. * is connected
  10299. */
  10300. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  10301. int_mux_cfg1 = int_mux_cfg0 + 1;
  10302. int_mux_cfg0_val = snd_soc_component_read32(component,
  10303. int_mux_cfg0);
  10304. int_mux_cfg1_val = snd_soc_component_read32(component,
  10305. int_mux_cfg1);
  10306. inp0_sel = int_mux_cfg0_val & 0x0F;
  10307. inp1_sel = (int_mux_cfg0_val >> 4) & 0x0F;
  10308. inp2_sel = (int_mux_cfg1_val >> 4) & 0x0F;
  10309. if ((inp0_sel == int_1_mix1_inp) ||
  10310. (inp1_sel == int_1_mix1_inp) ||
  10311. (inp2_sel == int_1_mix1_inp)) {
  10312. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_CTL +
  10313. 20 * j;
  10314. pr_debug("%s: AIF_PB DAI(%d) connected to INT%u_1\n",
  10315. __func__, dai->id, j);
  10316. pr_debug("%s: set INT%u_1 sample rate to %u\n",
  10317. __func__, j, sample_rate);
  10318. /* sample_rate is in Hz */
  10319. if ((j == 0) && (sample_rate == 44100)) {
  10320. pr_info("%s: Cannot set 44.1KHz on INT0\n",
  10321. __func__);
  10322. } else
  10323. snd_soc_component_update_bits(
  10324. component, int_fs_reg,
  10325. 0x0F, int_prim_fs_rate_reg_val);
  10326. }
  10327. int_mux_cfg0 += 2;
  10328. }
  10329. }
  10330. return 0;
  10331. }
  10332. static int tasha_set_interpolator_rate(struct snd_soc_dai *dai,
  10333. u32 sample_rate)
  10334. {
  10335. int rate_val = 0;
  10336. int i, ret;
  10337. /* set mixing path rate */
  10338. for (i = 0; i < ARRAY_SIZE(int_mix_sample_rate_val); i++) {
  10339. if (sample_rate ==
  10340. int_mix_sample_rate_val[i].sample_rate) {
  10341. rate_val =
  10342. int_mix_sample_rate_val[i].rate_val;
  10343. break;
  10344. }
  10345. }
  10346. if ((i == ARRAY_SIZE(int_mix_sample_rate_val)) ||
  10347. (rate_val < 0))
  10348. goto prim_rate;
  10349. ret = tasha_set_mix_interpolator_rate(dai,
  10350. (u8) rate_val, sample_rate);
  10351. prim_rate:
  10352. /* set primary path sample rate */
  10353. for (i = 0; i < ARRAY_SIZE(int_prim_sample_rate_val); i++) {
  10354. if (sample_rate ==
  10355. int_prim_sample_rate_val[i].sample_rate) {
  10356. rate_val =
  10357. int_prim_sample_rate_val[i].rate_val;
  10358. break;
  10359. }
  10360. }
  10361. if ((i == ARRAY_SIZE(int_prim_sample_rate_val)) ||
  10362. (rate_val < 0))
  10363. return -EINVAL;
  10364. ret = tasha_set_prim_interpolator_rate(dai,
  10365. (u8) rate_val, sample_rate);
  10366. return ret;
  10367. }
  10368. static int tasha_prepare(struct snd_pcm_substream *substream,
  10369. struct snd_soc_dai *dai)
  10370. {
  10371. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  10372. substream->name, substream->stream);
  10373. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  10374. tasha_codec_vote_max_bw(dai->component, false);
  10375. return 0;
  10376. }
  10377. static int tasha_hw_params(struct snd_pcm_substream *substream,
  10378. struct snd_pcm_hw_params *params,
  10379. struct snd_soc_dai *dai)
  10380. {
  10381. struct tasha_priv *tasha =
  10382. snd_soc_component_get_drvdata(dai->component);
  10383. int ret;
  10384. int tx_fs_rate = -EINVAL;
  10385. int rx_fs_rate = -EINVAL;
  10386. int i2s_bit_mode;
  10387. struct snd_soc_component *component = dai->component;
  10388. pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
  10389. dai->name, dai->id, params_rate(params),
  10390. params_channels(params));
  10391. switch (substream->stream) {
  10392. case SNDRV_PCM_STREAM_PLAYBACK:
  10393. ret = tasha_set_interpolator_rate(dai, params_rate(params));
  10394. if (ret) {
  10395. pr_err("%s: cannot set sample rate: %u\n",
  10396. __func__, params_rate(params));
  10397. return ret;
  10398. }
  10399. switch (params_width(params)) {
  10400. case 16:
  10401. tasha->dai[dai->id].bit_width = 16;
  10402. i2s_bit_mode = 0x01;
  10403. break;
  10404. case 24:
  10405. tasha->dai[dai->id].bit_width = 24;
  10406. i2s_bit_mode = 0x00;
  10407. break;
  10408. default:
  10409. return -EINVAL;
  10410. }
  10411. tasha->dai[dai->id].rate = params_rate(params);
  10412. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10413. switch (params_rate(params)) {
  10414. case 8000:
  10415. rx_fs_rate = 0;
  10416. break;
  10417. case 16000:
  10418. rx_fs_rate = 1;
  10419. break;
  10420. case 32000:
  10421. rx_fs_rate = 2;
  10422. break;
  10423. case 48000:
  10424. rx_fs_rate = 3;
  10425. break;
  10426. case 96000:
  10427. rx_fs_rate = 4;
  10428. break;
  10429. case 192000:
  10430. rx_fs_rate = 5;
  10431. break;
  10432. default:
  10433. dev_err(tasha->dev,
  10434. "%s: Invalid RX sample rate: %d\n",
  10435. __func__, params_rate(params));
  10436. return -EINVAL;
  10437. };
  10438. snd_soc_component_update_bits(component,
  10439. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10440. 0x20, i2s_bit_mode << 5);
  10441. snd_soc_component_update_bits(component,
  10442. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10443. 0x1c, (rx_fs_rate << 2));
  10444. }
  10445. break;
  10446. case SNDRV_PCM_STREAM_CAPTURE:
  10447. switch (params_rate(params)) {
  10448. case 8000:
  10449. tx_fs_rate = 0;
  10450. break;
  10451. case 16000:
  10452. tx_fs_rate = 1;
  10453. break;
  10454. case 32000:
  10455. tx_fs_rate = 3;
  10456. break;
  10457. case 48000:
  10458. tx_fs_rate = 4;
  10459. break;
  10460. case 96000:
  10461. tx_fs_rate = 5;
  10462. break;
  10463. case 192000:
  10464. tx_fs_rate = 6;
  10465. break;
  10466. case 384000:
  10467. tx_fs_rate = 7;
  10468. break;
  10469. default:
  10470. dev_err(tasha->dev, "%s: Invalid TX sample rate: %d\n",
  10471. __func__, params_rate(params));
  10472. return -EINVAL;
  10473. };
  10474. if (dai->id != AIF4_VIFEED &&
  10475. dai->id != AIF4_MAD_TX) {
  10476. ret = tasha_set_decimator_rate(dai, tx_fs_rate,
  10477. params_rate(params));
  10478. if (ret < 0) {
  10479. dev_err(tasha->dev, "%s: cannot set TX Decimator rate: %d\n",
  10480. __func__, tx_fs_rate);
  10481. return ret;
  10482. }
  10483. }
  10484. tasha->dai[dai->id].rate = params_rate(params);
  10485. switch (params_width(params)) {
  10486. case 16:
  10487. tasha->dai[dai->id].bit_width = 16;
  10488. i2s_bit_mode = 0x01;
  10489. break;
  10490. case 24:
  10491. tasha->dai[dai->id].bit_width = 24;
  10492. i2s_bit_mode = 0x00;
  10493. break;
  10494. case 32:
  10495. tasha->dai[dai->id].bit_width = 32;
  10496. i2s_bit_mode = 0x00;
  10497. break;
  10498. default:
  10499. dev_err(tasha->dev, "%s: Invalid format 0x%x\n",
  10500. __func__, params_width(params));
  10501. return -EINVAL;
  10502. };
  10503. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10504. snd_soc_component_update_bits(component,
  10505. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10506. 0x20, i2s_bit_mode << 5);
  10507. if (tx_fs_rate > 1)
  10508. tx_fs_rate--;
  10509. snd_soc_component_update_bits(component,
  10510. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10511. 0x1c, tx_fs_rate << 2);
  10512. snd_soc_component_update_bits(component,
  10513. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG,
  10514. 0x05, 0x05);
  10515. snd_soc_component_update_bits(component,
  10516. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG,
  10517. 0x05, 0x05);
  10518. snd_soc_component_update_bits(component,
  10519. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG,
  10520. 0x05, 0x05);
  10521. snd_soc_component_update_bits(component,
  10522. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG,
  10523. 0x05, 0x05);
  10524. }
  10525. break;
  10526. default:
  10527. pr_err("%s: Invalid stream type %d\n", __func__,
  10528. substream->stream);
  10529. return -EINVAL;
  10530. };
  10531. if (dai->id == AIF4_VIFEED)
  10532. tasha->dai[dai->id].bit_width = 32;
  10533. return 0;
  10534. }
  10535. static int tasha_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  10536. {
  10537. struct tasha_priv *tasha =
  10538. snd_soc_component_get_drvdata(dai->component);
  10539. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  10540. case SND_SOC_DAIFMT_CBS_CFS:
  10541. /* CPU is master */
  10542. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10543. if (dai->id == AIF1_CAP)
  10544. snd_soc_component_update_bits(dai->component,
  10545. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10546. 0x2, 0);
  10547. else if (dai->id == AIF1_PB)
  10548. snd_soc_component_update_bits(dai->component,
  10549. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10550. 0x2, 0);
  10551. }
  10552. break;
  10553. case SND_SOC_DAIFMT_CBM_CFM:
  10554. /* CPU is slave */
  10555. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10556. if (dai->id == AIF1_CAP)
  10557. snd_soc_component_update_bits(dai->component,
  10558. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10559. 0x2, 0x2);
  10560. else if (dai->id == AIF1_PB)
  10561. snd_soc_component_update_bits(dai->component,
  10562. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10563. 0x2, 0x2);
  10564. }
  10565. break;
  10566. default:
  10567. return -EINVAL;
  10568. }
  10569. return 0;
  10570. }
  10571. static int tasha_set_dai_sysclk(struct snd_soc_dai *dai,
  10572. int clk_id, unsigned int freq, int dir)
  10573. {
  10574. pr_debug("%s\n", __func__);
  10575. return 0;
  10576. }
  10577. static struct snd_soc_dai_ops tasha_dai_ops = {
  10578. .startup = tasha_startup,
  10579. .shutdown = tasha_shutdown,
  10580. .hw_params = tasha_hw_params,
  10581. .prepare = tasha_prepare,
  10582. .set_sysclk = tasha_set_dai_sysclk,
  10583. .set_fmt = tasha_set_dai_fmt,
  10584. .set_channel_map = tasha_set_channel_map,
  10585. .get_channel_map = tasha_get_channel_map,
  10586. };
  10587. static struct snd_soc_dai_driver tasha_dai[] = {
  10588. {
  10589. .name = "tasha_rx1",
  10590. .id = AIF1_PB,
  10591. .playback = {
  10592. .stream_name = "AIF1 Playback",
  10593. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10594. .formats = TASHA_FORMATS_S16_S24_LE,
  10595. .rate_max = 192000,
  10596. .rate_min = 8000,
  10597. .channels_min = 1,
  10598. .channels_max = 2,
  10599. },
  10600. .ops = &tasha_dai_ops,
  10601. },
  10602. {
  10603. .name = "tasha_tx1",
  10604. .id = AIF1_CAP,
  10605. .capture = {
  10606. .stream_name = "AIF1 Capture",
  10607. .rates = WCD9335_RATES_MASK,
  10608. .formats = TASHA_FORMATS_S16_S24_LE,
  10609. .rate_max = 192000,
  10610. .rate_min = 8000,
  10611. .channels_min = 1,
  10612. .channels_max = 4,
  10613. },
  10614. .ops = &tasha_dai_ops,
  10615. },
  10616. {
  10617. .name = "tasha_rx2",
  10618. .id = AIF2_PB,
  10619. .playback = {
  10620. .stream_name = "AIF2 Playback",
  10621. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10622. .formats = TASHA_FORMATS_S16_S24_LE,
  10623. .rate_min = 8000,
  10624. .rate_max = 192000,
  10625. .channels_min = 1,
  10626. .channels_max = 2,
  10627. },
  10628. .ops = &tasha_dai_ops,
  10629. },
  10630. {
  10631. .name = "tasha_tx2",
  10632. .id = AIF2_CAP,
  10633. .capture = {
  10634. .stream_name = "AIF2 Capture",
  10635. .rates = WCD9335_RATES_MASK,
  10636. .formats = TASHA_FORMATS_S16_S24_LE,
  10637. .rate_max = 192000,
  10638. .rate_min = 8000,
  10639. .channels_min = 1,
  10640. .channels_max = 8,
  10641. },
  10642. .ops = &tasha_dai_ops,
  10643. },
  10644. {
  10645. .name = "tasha_rx3",
  10646. .id = AIF3_PB,
  10647. .playback = {
  10648. .stream_name = "AIF3 Playback",
  10649. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10650. .formats = TASHA_FORMATS_S16_S24_LE,
  10651. .rate_min = 8000,
  10652. .rate_max = 192000,
  10653. .channels_min = 1,
  10654. .channels_max = 2,
  10655. },
  10656. .ops = &tasha_dai_ops,
  10657. },
  10658. {
  10659. .name = "tasha_tx3",
  10660. .id = AIF3_CAP,
  10661. .capture = {
  10662. .stream_name = "AIF3 Capture",
  10663. .rates = WCD9335_RATES_MASK,
  10664. .formats = TASHA_FORMATS_S16_S24_LE,
  10665. .rate_max = 48000,
  10666. .rate_min = 8000,
  10667. .channels_min = 1,
  10668. .channels_max = 2,
  10669. },
  10670. .ops = &tasha_dai_ops,
  10671. },
  10672. {
  10673. .name = "tasha_rx4",
  10674. .id = AIF4_PB,
  10675. .playback = {
  10676. .stream_name = "AIF4 Playback",
  10677. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10678. .formats = TASHA_FORMATS_S16_S24_LE,
  10679. .rate_min = 8000,
  10680. .rate_max = 192000,
  10681. .channels_min = 1,
  10682. .channels_max = 2,
  10683. },
  10684. .ops = &tasha_dai_ops,
  10685. },
  10686. {
  10687. .name = "tasha_mix_rx1",
  10688. .id = AIF_MIX1_PB,
  10689. .playback = {
  10690. .stream_name = "AIF Mix Playback",
  10691. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10692. .formats = TASHA_FORMATS_S16_S24_LE,
  10693. .rate_min = 8000,
  10694. .rate_max = 192000,
  10695. .channels_min = 1,
  10696. .channels_max = 8,
  10697. },
  10698. .ops = &tasha_dai_ops,
  10699. },
  10700. {
  10701. .name = "tasha_mad1",
  10702. .id = AIF4_MAD_TX,
  10703. .capture = {
  10704. .stream_name = "AIF4 MAD TX",
  10705. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10706. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_384000,
  10707. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10708. .rate_min = 16000,
  10709. .rate_max = 384000,
  10710. .channels_min = 1,
  10711. .channels_max = 1,
  10712. },
  10713. .ops = &tasha_dai_ops,
  10714. },
  10715. {
  10716. .name = "tasha_vifeedback",
  10717. .id = AIF4_VIFEED,
  10718. .capture = {
  10719. .stream_name = "VIfeed",
  10720. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
  10721. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10722. .rate_max = 48000,
  10723. .rate_min = 8000,
  10724. .channels_min = 1,
  10725. .channels_max = 4,
  10726. },
  10727. .ops = &tasha_dai_ops,
  10728. },
  10729. {
  10730. .name = "tasha_cpe",
  10731. .id = AIF5_CPE_TX,
  10732. .capture = {
  10733. .stream_name = "AIF5 CPE TX",
  10734. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000,
  10735. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10736. .rate_min = 16000,
  10737. .rate_max = 48000,
  10738. .channels_min = 1,
  10739. .channels_max = 1,
  10740. },
  10741. },
  10742. };
  10743. static struct snd_soc_dai_driver tasha_i2s_dai[] = {
  10744. {
  10745. .name = "tasha_i2s_rx1",
  10746. .id = AIF1_PB,
  10747. .playback = {
  10748. .stream_name = "AIF1 Playback",
  10749. .rates = WCD9335_RATES_MASK,
  10750. .formats = TASHA_FORMATS_S16_S24_LE,
  10751. .rate_max = 192000,
  10752. .rate_min = 8000,
  10753. .channels_min = 1,
  10754. .channels_max = 2,
  10755. },
  10756. .ops = &tasha_dai_ops,
  10757. },
  10758. {
  10759. .name = "tasha_i2s_tx1",
  10760. .id = AIF1_CAP,
  10761. .capture = {
  10762. .stream_name = "AIF1 Capture",
  10763. .rates = WCD9335_RATES_MASK,
  10764. .formats = TASHA_FORMATS_S16_S24_LE,
  10765. .rate_max = 192000,
  10766. .rate_min = 8000,
  10767. .channels_min = 1,
  10768. .channels_max = 4,
  10769. },
  10770. .ops = &tasha_dai_ops,
  10771. },
  10772. {
  10773. .name = "tasha_i2s_rx2",
  10774. .id = AIF2_PB,
  10775. .playback = {
  10776. .stream_name = "AIF2 Playback",
  10777. .rates = WCD9335_RATES_MASK,
  10778. .formats = TASHA_FORMATS_S16_S24_LE,
  10779. .rate_max = 192000,
  10780. .rate_min = 8000,
  10781. .channels_min = 1,
  10782. .channels_max = 2,
  10783. },
  10784. .ops = &tasha_dai_ops,
  10785. },
  10786. {
  10787. .name = "tasha_i2s_tx2",
  10788. .id = AIF2_CAP,
  10789. .capture = {
  10790. .stream_name = "AIF2 Capture",
  10791. .rates = WCD9335_RATES_MASK,
  10792. .formats = TASHA_FORMATS_S16_S24_LE,
  10793. .rate_max = 192000,
  10794. .rate_min = 8000,
  10795. .channels_min = 1,
  10796. .channels_max = 4,
  10797. },
  10798. .ops = &tasha_dai_ops,
  10799. },
  10800. {
  10801. .name = "tasha_mad1",
  10802. .id = AIF4_MAD_TX,
  10803. .capture = {
  10804. .stream_name = "AIF4 MAD TX",
  10805. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10806. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_384000,
  10807. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10808. .rate_min = 16000,
  10809. .rate_max = 384000,
  10810. .channels_min = 1,
  10811. .channels_max = 1,
  10812. },
  10813. .ops = &tasha_dai_ops,
  10814. },
  10815. };
  10816. static void tasha_codec_power_gate_digital_core(struct tasha_priv *tasha)
  10817. {
  10818. struct snd_soc_component *component = tasha->component;
  10819. if (!component)
  10820. return;
  10821. mutex_lock(&tasha->power_lock);
  10822. dev_dbg(component->dev, "%s: Entering power gating function, %d\n",
  10823. __func__, tasha->power_active_ref);
  10824. if (tasha->power_active_ref > 0)
  10825. goto exit;
  10826. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10827. WCD_REGION_POWER_COLLAPSE_BEGIN,
  10828. WCD9XXX_DIG_CORE_REGION_1);
  10829. snd_soc_component_update_bits(component,
  10830. WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10831. 0x04, 0x04);
  10832. snd_soc_component_update_bits(component,
  10833. WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10834. 0x01, 0x00);
  10835. snd_soc_component_update_bits(component,
  10836. WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10837. 0x02, 0x00);
  10838. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10839. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  10840. wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_DOWN,
  10841. WCD9XXX_DIG_CORE_REGION_1);
  10842. exit:
  10843. dev_dbg(component->dev, "%s: Exiting power gating function, %d\n",
  10844. __func__, tasha->power_active_ref);
  10845. mutex_unlock(&tasha->power_lock);
  10846. }
  10847. static void tasha_codec_power_gate_work(struct work_struct *work)
  10848. {
  10849. struct tasha_priv *tasha;
  10850. struct delayed_work *dwork;
  10851. struct snd_soc_component *component;
  10852. dwork = to_delayed_work(work);
  10853. tasha = container_of(dwork, struct tasha_priv, power_gate_work);
  10854. component = tasha->component;
  10855. if (!component)
  10856. return;
  10857. tasha_codec_power_gate_digital_core(tasha);
  10858. }
  10859. /* called under power_lock acquisition */
  10860. static int tasha_dig_core_remove_power_collapse(
  10861. struct snd_soc_component *component)
  10862. {
  10863. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  10864. tasha_codec_vote_max_bw(component, true);
  10865. snd_soc_component_write(component,
  10866. WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5);
  10867. snd_soc_component_write(component,
  10868. WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7);
  10869. snd_soc_component_write(component,
  10870. WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3);
  10871. snd_soc_component_update_bits(component, WCD9335_CODEC_RPM_RST_CTL,
  10872. 0x02, 0x00);
  10873. snd_soc_component_update_bits(component, WCD9335_CODEC_RPM_RST_CTL,
  10874. 0x02, 0x02);
  10875. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10876. WCD_REGION_POWER_COLLAPSE_REMOVE,
  10877. WCD9XXX_DIG_CORE_REGION_1);
  10878. regcache_mark_dirty(component->regmap);
  10879. regcache_sync_region(component->regmap,
  10880. TASHA_DIG_CORE_REG_MIN, TASHA_DIG_CORE_REG_MAX);
  10881. tasha_codec_vote_max_bw(component, false);
  10882. return 0;
  10883. }
  10884. static int tasha_dig_core_power_collapse(struct tasha_priv *tasha,
  10885. int req_state)
  10886. {
  10887. struct snd_soc_component *component;
  10888. int cur_state;
  10889. /* Exit if feature is disabled */
  10890. if (!dig_core_collapse_enable)
  10891. return 0;
  10892. mutex_lock(&tasha->power_lock);
  10893. if (req_state == POWER_COLLAPSE)
  10894. tasha->power_active_ref--;
  10895. else if (req_state == POWER_RESUME)
  10896. tasha->power_active_ref++;
  10897. else
  10898. goto unlock_mutex;
  10899. if (tasha->power_active_ref < 0) {
  10900. dev_dbg(tasha->dev, "%s: power_active_ref is negative\n",
  10901. __func__);
  10902. goto unlock_mutex;
  10903. }
  10904. component = tasha->component;
  10905. if (!component)
  10906. goto unlock_mutex;
  10907. if (req_state == POWER_COLLAPSE) {
  10908. if (tasha->power_active_ref == 0) {
  10909. schedule_delayed_work(&tasha->power_gate_work,
  10910. msecs_to_jiffies(dig_core_collapse_timer * 1000));
  10911. }
  10912. } else if (req_state == POWER_RESUME) {
  10913. if (tasha->power_active_ref == 1) {
  10914. /*
  10915. * At this point, there can be two cases:
  10916. * 1. Core already in power collapse state
  10917. * 2. Timer kicked in and still did not expire or
  10918. * waiting for the power_lock
  10919. */
  10920. cur_state = wcd9xxx_get_current_power_state(
  10921. tasha->wcd9xxx,
  10922. WCD9XXX_DIG_CORE_REGION_1);
  10923. if (cur_state == WCD_REGION_POWER_DOWN)
  10924. tasha_dig_core_remove_power_collapse(component);
  10925. else {
  10926. mutex_unlock(&tasha->power_lock);
  10927. cancel_delayed_work_sync(
  10928. &tasha->power_gate_work);
  10929. mutex_lock(&tasha->power_lock);
  10930. }
  10931. }
  10932. }
  10933. unlock_mutex:
  10934. mutex_unlock(&tasha->power_lock);
  10935. return 0;
  10936. }
  10937. static int __tasha_cdc_mclk_enable_locked(struct tasha_priv *tasha,
  10938. bool enable)
  10939. {
  10940. int ret = 0;
  10941. if (!tasha->wcd_ext_clk) {
  10942. dev_err(tasha->dev, "%s: wcd ext clock is NULL\n", __func__);
  10943. return -EINVAL;
  10944. }
  10945. dev_dbg(tasha->dev, "%s: mclk_enable = %u\n", __func__, enable);
  10946. if (enable) {
  10947. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10948. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10949. if (ret)
  10950. goto err;
  10951. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10952. tasha_codec_apply_sido_voltage(tasha,
  10953. SIDO_VOLTAGE_NOMINAL_MV);
  10954. } else {
  10955. if (!dig_core_collapse_enable) {
  10956. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10957. tasha_codec_update_sido_voltage(tasha,
  10958. sido_buck_svs_voltage);
  10959. }
  10960. tasha_cdc_req_mclk_enable(tasha, false);
  10961. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10962. }
  10963. err:
  10964. return ret;
  10965. }
  10966. static int __tasha_cdc_mclk_enable(struct tasha_priv *tasha,
  10967. bool enable)
  10968. {
  10969. int ret;
  10970. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10971. ret = __tasha_cdc_mclk_enable_locked(tasha, enable);
  10972. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10973. return ret;
  10974. }
  10975. int tasha_cdc_mclk_enable(struct snd_soc_component *component,
  10976. int enable, bool dapm)
  10977. {
  10978. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  10979. return __tasha_cdc_mclk_enable(tasha, enable);
  10980. }
  10981. EXPORT_SYMBOL(tasha_cdc_mclk_enable);
  10982. int tasha_cdc_mclk_tx_enable(struct snd_soc_component *component,
  10983. int enable, bool dapm)
  10984. {
  10985. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  10986. int ret = 0;
  10987. dev_dbg(tasha->dev, "%s: clk_mode: %d, enable: %d, clk_internal: %d\n",
  10988. __func__, tasha->clk_mode, enable, tasha->clk_internal);
  10989. if (tasha->clk_mode || tasha->clk_internal) {
  10990. if (enable) {
  10991. tasha_cdc_sido_ccl_enable(tasha, true);
  10992. wcd_resmgr_enable_master_bias(tasha->resmgr);
  10993. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10994. snd_soc_component_update_bits(component,
  10995. WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
  10996. 0x01, 0x01);
  10997. snd_soc_component_update_bits(component,
  10998. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  10999. 0x01, 0x01);
  11000. set_bit(CPE_NOMINAL, &tasha->status_mask);
  11001. tasha_codec_update_sido_voltage(tasha,
  11002. SIDO_VOLTAGE_NOMINAL_MV);
  11003. tasha->clk_internal = true;
  11004. } else {
  11005. tasha->clk_internal = false;
  11006. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  11007. tasha_codec_update_sido_voltage(tasha,
  11008. sido_buck_svs_voltage);
  11009. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  11010. wcd_resmgr_disable_master_bias(tasha->resmgr);
  11011. tasha_cdc_sido_ccl_enable(tasha, false);
  11012. }
  11013. } else {
  11014. ret = __tasha_cdc_mclk_enable(tasha, enable);
  11015. }
  11016. return ret;
  11017. }
  11018. EXPORT_SYMBOL(tasha_cdc_mclk_tx_enable);
  11019. static ssize_t tasha_codec_version_read(struct snd_info_entry *entry,
  11020. void *file_private_data, struct file *file,
  11021. char __user *buf, size_t count, loff_t pos)
  11022. {
  11023. struct tasha_priv *tasha;
  11024. struct wcd9xxx *wcd9xxx;
  11025. char buffer[TASHA_VERSION_ENTRY_SIZE];
  11026. int len = 0;
  11027. tasha = (struct tasha_priv *) entry->private_data;
  11028. if (!tasha) {
  11029. pr_err("%s: tasha priv is null\n", __func__);
  11030. return -EINVAL;
  11031. }
  11032. wcd9xxx = tasha->wcd9xxx;
  11033. if (wcd9xxx->codec_type->id_major == TASHA_MAJOR) {
  11034. if (TASHA_IS_1_0(wcd9xxx))
  11035. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_0\n");
  11036. else if (TASHA_IS_1_1(wcd9xxx))
  11037. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_1\n");
  11038. else
  11039. snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  11040. } else if (wcd9xxx->codec_type->id_major == TASHA2P0_MAJOR) {
  11041. len = snprintf(buffer, sizeof(buffer), "WCD9335_2_0\n");
  11042. } else
  11043. len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  11044. return simple_read_from_buffer(buf, count, &pos, buffer, len);
  11045. }
  11046. static struct snd_info_entry_ops tasha_codec_info_ops = {
  11047. .read = tasha_codec_version_read,
  11048. };
  11049. /*
  11050. * tasha_codec_info_create_codec_entry - creates wcd9335 module
  11051. * @codec_root: The parent directory
  11052. * @component: Codec instance
  11053. *
  11054. * Creates wcd9335 module and version entry under the given
  11055. * parent directory.
  11056. *
  11057. * Return: 0 on success or negative error code on failure.
  11058. */
  11059. int tasha_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
  11060. struct snd_soc_component *component)
  11061. {
  11062. struct snd_info_entry *version_entry;
  11063. struct tasha_priv *tasha;
  11064. struct snd_soc_card *card;
  11065. if (!codec_root || !component)
  11066. return -EINVAL;
  11067. tasha = snd_soc_component_get_drvdata(component);
  11068. card = component->card;
  11069. tasha->entry = snd_info_create_subdir(codec_root->module,
  11070. "tasha", codec_root);
  11071. if (!tasha->entry) {
  11072. dev_dbg(component->dev, "%s: failed to create wcd9335 entry\n",
  11073. __func__);
  11074. return -ENOMEM;
  11075. }
  11076. version_entry = snd_info_create_card_entry(card->snd_card,
  11077. "version",
  11078. tasha->entry);
  11079. if (!version_entry) {
  11080. dev_dbg(component->dev, "%s: failed to create wcd9335 version entry\n",
  11081. __func__);
  11082. return -ENOMEM;
  11083. }
  11084. version_entry->private_data = tasha;
  11085. version_entry->size = TASHA_VERSION_ENTRY_SIZE;
  11086. version_entry->content = SNDRV_INFO_CONTENT_DATA;
  11087. version_entry->c.ops = &tasha_codec_info_ops;
  11088. if (snd_info_register(version_entry) < 0) {
  11089. snd_info_free_entry(version_entry);
  11090. return -ENOMEM;
  11091. }
  11092. tasha->version_entry = version_entry;
  11093. return 0;
  11094. }
  11095. EXPORT_SYMBOL(tasha_codec_info_create_codec_entry);
  11096. static int __tasha_codec_internal_rco_ctrl(
  11097. struct snd_soc_component *component, bool enable)
  11098. {
  11099. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  11100. int ret = 0;
  11101. if (enable) {
  11102. tasha_cdc_sido_ccl_enable(tasha, true);
  11103. if (wcd_resmgr_get_clk_type(tasha->resmgr) ==
  11104. WCD_CLK_RCO) {
  11105. ret = wcd_resmgr_enable_clk_block(tasha->resmgr,
  11106. WCD_CLK_RCO);
  11107. } else {
  11108. ret = tasha_cdc_req_mclk_enable(tasha, true);
  11109. ret |= wcd_resmgr_enable_clk_block(tasha->resmgr,
  11110. WCD_CLK_RCO);
  11111. ret |= tasha_cdc_req_mclk_enable(tasha, false);
  11112. }
  11113. } else {
  11114. ret = wcd_resmgr_disable_clk_block(tasha->resmgr,
  11115. WCD_CLK_RCO);
  11116. tasha_cdc_sido_ccl_enable(tasha, false);
  11117. }
  11118. if (ret) {
  11119. dev_err(component->dev, "%s: Error in %s RCO\n",
  11120. __func__, (enable ? "enabling" : "disabling"));
  11121. ret = -EINVAL;
  11122. }
  11123. return ret;
  11124. }
  11125. /*
  11126. * tasha_codec_internal_rco_ctrl()
  11127. * Make sure that the caller does not acquire
  11128. * BG_CLK_LOCK.
  11129. */
  11130. static int tasha_codec_internal_rco_ctrl(struct snd_soc_component *component,
  11131. bool enable)
  11132. {
  11133. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  11134. int ret = 0;
  11135. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  11136. ret = __tasha_codec_internal_rco_ctrl(component, enable);
  11137. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  11138. return ret;
  11139. }
  11140. /*
  11141. * tasha_mbhc_hs_detect: starts mbhc insertion/removal functionality
  11142. * @component: handle to snd_soc_component *
  11143. * @mbhc_cfg: handle to mbhc configuration structure
  11144. * return 0 if mbhc_start is success or error code in case of failure
  11145. */
  11146. int tasha_mbhc_hs_detect(struct snd_soc_component *component,
  11147. struct wcd_mbhc_config *mbhc_cfg)
  11148. {
  11149. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  11150. return wcd_mbhc_start(&tasha->mbhc, mbhc_cfg);
  11151. }
  11152. EXPORT_SYMBOL(tasha_mbhc_hs_detect);
  11153. /*
  11154. * tasha_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
  11155. * @component: handle to snd_soc_component *
  11156. */
  11157. void tasha_mbhc_hs_detect_exit(struct snd_soc_component *component)
  11158. {
  11159. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  11160. wcd_mbhc_stop(&tasha->mbhc);
  11161. }
  11162. EXPORT_SYMBOL(tasha_mbhc_hs_detect_exit);
  11163. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv)
  11164. {
  11165. /* min micbias voltage is 1V and maximum is 2.85V */
  11166. if (micb_mv < 1000 || micb_mv > 2850) {
  11167. pr_err("%s: unsupported micbias voltage\n", __func__);
  11168. return -EINVAL;
  11169. }
  11170. return (micb_mv - 1000) / 50;
  11171. }
  11172. static const struct tasha_reg_mask_val tasha_reg_update_reset_val_1_1[] = {
  11173. {WCD9335_RCO_CTRL_2, 0xFF, 0x47},
  11174. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  11175. };
  11176. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_1[] = {
  11177. {WCD9335_FLYBACK_VNEG_DAC_CTRL_1, 0xFF, 0x65},
  11178. {WCD9335_FLYBACK_VNEG_DAC_CTRL_2, 0xFF, 0x52},
  11179. {WCD9335_FLYBACK_VNEG_DAC_CTRL_3, 0xFF, 0xAF},
  11180. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  11181. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0xF4},
  11182. {WCD9335_FLYBACK_VNEG_CTRL_9, 0xFF, 0x40},
  11183. {WCD9335_FLYBACK_VNEG_CTRL_2, 0xFF, 0x4F},
  11184. {WCD9335_FLYBACK_EN, 0xFF, 0x6E},
  11185. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xF8, 0xF8},
  11186. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xF8, 0xF8},
  11187. };
  11188. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_0[] = {
  11189. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0x54},
  11190. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xFC, 0xFC},
  11191. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xFC, 0xFC},
  11192. };
  11193. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_2_0[] = {
  11194. {WCD9335_RCO_CTRL_2, 0x0F, 0x08},
  11195. {WCD9335_RX_BIAS_FLYB_MID_RST, 0xF0, 0x10},
  11196. {WCD9335_FLYBACK_CTRL_1, 0x20, 0x20},
  11197. {WCD9335_HPH_OCP_CTL, 0xFF, 0x7A},
  11198. {WCD9335_HPH_L_TEST, 0x01, 0x01},
  11199. {WCD9335_HPH_R_TEST, 0x01, 0x01},
  11200. {WCD9335_CDC_BOOST0_BOOST_CFG1, 0x3F, 0x12},
  11201. {WCD9335_CDC_BOOST0_BOOST_CFG2, 0x1C, 0x08},
  11202. {WCD9335_CDC_COMPANDER7_CTL7, 0x1E, 0x18},
  11203. {WCD9335_CDC_BOOST1_BOOST_CFG1, 0x3F, 0x12},
  11204. {WCD9335_CDC_BOOST1_BOOST_CFG2, 0x1C, 0x08},
  11205. {WCD9335_CDC_COMPANDER8_CTL7, 0x1E, 0x18},
  11206. {WCD9335_CDC_TX0_TX_PATH_SEC7, 0xFF, 0x45},
  11207. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xFC, 0xF4},
  11208. {WCD9335_HPH_REFBUFF_LP_CTL, 0x08, 0x08},
  11209. {WCD9335_HPH_REFBUFF_LP_CTL, 0x06, 0x02},
  11210. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xA0},
  11211. {WCD9335_SE_LO_COM1, 0xFF, 0xC0},
  11212. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xFC, 0xF4},
  11213. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xFC, 0xF4},
  11214. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xFC, 0xF8},
  11215. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xFC, 0xF8},
  11216. };
  11217. static const struct tasha_reg_mask_val tasha_codec_reg_defaults[] = {
  11218. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x00},
  11219. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x01},
  11220. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x04, 0x04},
  11221. };
  11222. static const struct tasha_reg_mask_val tasha_codec_reg_i2c_defaults[] = {
  11223. {WCD9335_ANA_CLK_TOP, 0x20, 0x20},
  11224. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x01},
  11225. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x00},
  11226. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x05, 0x05},
  11227. {WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG, 0x01, 0x01},
  11228. {WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG, 0x01, 0x01},
  11229. {WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG, 0x01, 0x01},
  11230. {WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG, 0x01, 0x01},
  11231. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG, 0x05, 0x05},
  11232. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG, 0x05, 0x05},
  11233. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG, 0x05, 0x05},
  11234. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG, 0x05, 0x05},
  11235. };
  11236. static const struct tasha_reg_mask_val tasha_codec_reg_init_common_val[] = {
  11237. /* Rbuckfly/R_EAR(32) */
  11238. {WCD9335_CDC_CLSH_K2_MSB, 0x0F, 0x00},
  11239. {WCD9335_CDC_CLSH_K2_LSB, 0xFF, 0x60},
  11240. {WCD9335_CPE_SS_DMIC_CFG, 0x80, 0x00},
  11241. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x58},
  11242. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x58},
  11243. {WCD9335_CDC_RX7_RX_PATH_CFG1, 0x08, 0x08},
  11244. {WCD9335_CDC_RX8_RX_PATH_CFG1, 0x08, 0x08},
  11245. {WCD9335_ANA_LO_1_2, 0x3C, 0X3C},
  11246. {WCD9335_DIFF_LO_COM_SWCAP_REFBUF_FREQ, 0x70, 0x00},
  11247. {WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03, 0x03},
  11248. {WCD9335_CDC_TOP_TOP_CFG1, 0x02, 0x02},
  11249. {WCD9335_CDC_TOP_TOP_CFG1, 0x01, 0x01},
  11250. {WCD9335_EAR_CMBUFF, 0x08, 0x00},
  11251. {WCD9335_CDC_TX9_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  11252. {WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  11253. {WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  11254. {WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  11255. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  11256. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  11257. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  11258. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  11259. {WCD9335_CDC_RX0_RX_PATH_CFG0, 0x01, 0x01},
  11260. {WCD9335_CDC_RX1_RX_PATH_CFG0, 0x01, 0x01},
  11261. {WCD9335_CDC_RX2_RX_PATH_CFG0, 0x01, 0x01},
  11262. {WCD9335_CDC_RX3_RX_PATH_CFG0, 0x01, 0x01},
  11263. {WCD9335_CDC_RX4_RX_PATH_CFG0, 0x01, 0x01},
  11264. {WCD9335_CDC_RX5_RX_PATH_CFG0, 0x01, 0x01},
  11265. {WCD9335_CDC_RX6_RX_PATH_CFG0, 0x01, 0x01},
  11266. {WCD9335_CDC_RX7_RX_PATH_CFG0, 0x01, 0x01},
  11267. {WCD9335_CDC_RX8_RX_PATH_CFG0, 0x01, 0x01},
  11268. {WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 0x01, 0x01},
  11269. {WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 0x01, 0x01},
  11270. {WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 0x01, 0x01},
  11271. {WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 0x01, 0x01},
  11272. {WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 0x01, 0x01},
  11273. {WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 0x01, 0x01},
  11274. {WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 0x01, 0x01},
  11275. {WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 0x01, 0x01},
  11276. {WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 0x01, 0x01},
  11277. {WCD9335_VBADC_IBIAS_FE, 0x0C, 0x08},
  11278. };
  11279. static const struct tasha_reg_mask_val tasha_codec_reg_init_1_x_val[] = {
  11280. /* Enable TX HPF Filter & Linear Phase */
  11281. {WCD9335_CDC_TX0_TX_PATH_CFG0, 0x11, 0x11},
  11282. {WCD9335_CDC_TX1_TX_PATH_CFG0, 0x11, 0x11},
  11283. {WCD9335_CDC_TX2_TX_PATH_CFG0, 0x11, 0x11},
  11284. {WCD9335_CDC_TX3_TX_PATH_CFG0, 0x11, 0x11},
  11285. {WCD9335_CDC_TX4_TX_PATH_CFG0, 0x11, 0x11},
  11286. {WCD9335_CDC_TX5_TX_PATH_CFG0, 0x11, 0x11},
  11287. {WCD9335_CDC_TX6_TX_PATH_CFG0, 0x11, 0x11},
  11288. {WCD9335_CDC_TX7_TX_PATH_CFG0, 0x11, 0x11},
  11289. {WCD9335_CDC_TX8_TX_PATH_CFG0, 0x11, 0x11},
  11290. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xF8, 0xF8},
  11291. {WCD9335_CDC_RX0_RX_PATH_SEC1, 0x08, 0x08},
  11292. {WCD9335_CDC_RX1_RX_PATH_SEC1, 0x08, 0x08},
  11293. {WCD9335_CDC_RX2_RX_PATH_SEC1, 0x08, 0x08},
  11294. {WCD9335_CDC_RX3_RX_PATH_SEC1, 0x08, 0x08},
  11295. {WCD9335_CDC_RX4_RX_PATH_SEC1, 0x08, 0x08},
  11296. {WCD9335_CDC_RX5_RX_PATH_SEC1, 0x08, 0x08},
  11297. {WCD9335_CDC_RX6_RX_PATH_SEC1, 0x08, 0x08},
  11298. {WCD9335_CDC_RX7_RX_PATH_SEC1, 0x08, 0x08},
  11299. {WCD9335_CDC_RX8_RX_PATH_SEC1, 0x08, 0x08},
  11300. {WCD9335_CDC_RX0_RX_PATH_MIX_SEC0, 0x08, 0x08},
  11301. {WCD9335_CDC_RX1_RX_PATH_MIX_SEC0, 0x08, 0x08},
  11302. {WCD9335_CDC_RX2_RX_PATH_MIX_SEC0, 0x08, 0x08},
  11303. {WCD9335_CDC_RX3_RX_PATH_MIX_SEC0, 0x08, 0x08},
  11304. {WCD9335_CDC_RX4_RX_PATH_MIX_SEC0, 0x08, 0x08},
  11305. {WCD9335_CDC_RX5_RX_PATH_MIX_SEC0, 0x08, 0x08},
  11306. {WCD9335_CDC_RX6_RX_PATH_MIX_SEC0, 0x08, 0x08},
  11307. {WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, 0x08, 0x08},
  11308. {WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, 0x08, 0x08},
  11309. {WCD9335_CDC_TX0_TX_PATH_SEC2, 0x01, 0x01},
  11310. {WCD9335_CDC_TX1_TX_PATH_SEC2, 0x01, 0x01},
  11311. {WCD9335_CDC_TX2_TX_PATH_SEC2, 0x01, 0x01},
  11312. {WCD9335_CDC_TX3_TX_PATH_SEC2, 0x01, 0x01},
  11313. {WCD9335_CDC_TX4_TX_PATH_SEC2, 0x01, 0x01},
  11314. {WCD9335_CDC_TX5_TX_PATH_SEC2, 0x01, 0x01},
  11315. {WCD9335_CDC_TX6_TX_PATH_SEC2, 0x01, 0x01},
  11316. {WCD9335_CDC_TX7_TX_PATH_SEC2, 0x01, 0x01},
  11317. {WCD9335_CDC_TX8_TX_PATH_SEC2, 0x01, 0x01},
  11318. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xF8, 0xF0},
  11319. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xF8, 0xF0},
  11320. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xF8, 0xF8},
  11321. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xF8, 0xF8},
  11322. {WCD9335_RX_OCP_COUNT, 0xFF, 0xFF},
  11323. {WCD9335_HPH_OCP_CTL, 0xF0, 0x70},
  11324. {WCD9335_CPE_SS_CPAR_CFG, 0xFF, 0x00},
  11325. {WCD9335_FLYBACK_VNEG_CTRL_1, 0xFF, 0x63},
  11326. {WCD9335_FLYBACK_VNEG_CTRL_4, 0xFF, 0x7F},
  11327. {WCD9335_CLASSH_CTRL_VCL_1, 0xFF, 0x60},
  11328. {WCD9335_CLASSH_CTRL_CCL_5, 0xFF, 0x40},
  11329. {WCD9335_RX_TIMER_DIV, 0xFF, 0x32},
  11330. {WCD9335_SE_LO_COM2, 0xFF, 0x01},
  11331. {WCD9335_MBHC_ZDET_ANA_CTL, 0x0F, 0x07},
  11332. {WCD9335_RX_BIAS_HPH_PA, 0xF0, 0x60},
  11333. {WCD9335_HPH_RDAC_LDO_CTL, 0x88, 0x88},
  11334. {WCD9335_HPH_L_EN, 0x20, 0x20},
  11335. {WCD9335_HPH_R_EN, 0x20, 0x20},
  11336. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xD8},
  11337. {WCD9335_CDC_RX5_RX_PATH_SEC3, 0xBD, 0xBD},
  11338. {WCD9335_CDC_RX6_RX_PATH_SEC3, 0xBD, 0xBD},
  11339. {WCD9335_DIFF_LO_COM_PA_FREQ, 0x70, 0x40},
  11340. };
  11341. static void tasha_update_reg_reset_values(struct snd_soc_component *component)
  11342. {
  11343. u32 i;
  11344. struct wcd9xxx *tasha_core = dev_get_drvdata(component->dev->parent);
  11345. if (TASHA_IS_1_1(tasha_core)) {
  11346. for (i = 0; i < ARRAY_SIZE(tasha_reg_update_reset_val_1_1);
  11347. i++)
  11348. snd_soc_component_write(component,
  11349. tasha_reg_update_reset_val_1_1[i].reg,
  11350. tasha_reg_update_reset_val_1_1[i].val);
  11351. }
  11352. }
  11353. static void tasha_codec_init_reg(struct snd_soc_component *component)
  11354. {
  11355. u32 i;
  11356. struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
  11357. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_common_val); i++)
  11358. snd_soc_component_update_bits(component,
  11359. tasha_codec_reg_init_common_val[i].reg,
  11360. tasha_codec_reg_init_common_val[i].mask,
  11361. tasha_codec_reg_init_common_val[i].val);
  11362. if (TASHA_IS_1_1(wcd9xxx) ||
  11363. TASHA_IS_1_0(wcd9xxx))
  11364. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_1_x_val); i++)
  11365. snd_soc_component_update_bits(component,
  11366. tasha_codec_reg_init_1_x_val[i].reg,
  11367. tasha_codec_reg_init_1_x_val[i].mask,
  11368. tasha_codec_reg_init_1_x_val[i].val);
  11369. if (TASHA_IS_1_1(wcd9xxx)) {
  11370. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_1); i++)
  11371. snd_soc_component_update_bits(component,
  11372. tasha_codec_reg_init_val_1_1[i].reg,
  11373. tasha_codec_reg_init_val_1_1[i].mask,
  11374. tasha_codec_reg_init_val_1_1[i].val);
  11375. } else if (TASHA_IS_1_0(wcd9xxx)) {
  11376. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_0); i++)
  11377. snd_soc_component_update_bits(component,
  11378. tasha_codec_reg_init_val_1_0[i].reg,
  11379. tasha_codec_reg_init_val_1_0[i].mask,
  11380. tasha_codec_reg_init_val_1_0[i].val);
  11381. } else if (TASHA_IS_2_0(wcd9xxx)) {
  11382. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_2_0); i++)
  11383. snd_soc_component_update_bits(component,
  11384. tasha_codec_reg_init_val_2_0[i].reg,
  11385. tasha_codec_reg_init_val_2_0[i].mask,
  11386. tasha_codec_reg_init_val_2_0[i].val);
  11387. }
  11388. }
  11389. static void tasha_update_reg_defaults(struct tasha_priv *tasha)
  11390. {
  11391. u32 i;
  11392. struct wcd9xxx *wcd9xxx;
  11393. wcd9xxx = tasha->wcd9xxx;
  11394. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_defaults); i++)
  11395. regmap_update_bits(wcd9xxx->regmap,
  11396. tasha_codec_reg_defaults[i].reg,
  11397. tasha_codec_reg_defaults[i].mask,
  11398. tasha_codec_reg_defaults[i].val);
  11399. tasha->intf_type = wcd9xxx_get_intf_type();
  11400. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  11401. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_i2c_defaults); i++)
  11402. regmap_update_bits(wcd9xxx->regmap,
  11403. tasha_codec_reg_i2c_defaults[i].reg,
  11404. tasha_codec_reg_i2c_defaults[i].mask,
  11405. tasha_codec_reg_i2c_defaults[i].val);
  11406. }
  11407. static void tasha_slim_interface_init_reg(struct snd_soc_component *component)
  11408. {
  11409. int i;
  11410. struct tasha_priv *priv = snd_soc_component_get_drvdata(component);
  11411. for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++)
  11412. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11413. TASHA_SLIM_PGD_PORT_INT_EN0 + i,
  11414. 0xFF);
  11415. }
  11416. static irqreturn_t tasha_slimbus_irq(int irq, void *data)
  11417. {
  11418. struct tasha_priv *priv = data;
  11419. unsigned long status = 0;
  11420. int i, j, port_id, k;
  11421. u32 bit;
  11422. u8 val, int_val = 0;
  11423. bool tx, cleared;
  11424. unsigned short reg = 0;
  11425. for (i = TASHA_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
  11426. i <= TASHA_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
  11427. val = wcd9xxx_interface_reg_read(priv->wcd9xxx, i);
  11428. status |= ((u32)val << (8 * j));
  11429. }
  11430. for_each_set_bit(j, &status, 32) {
  11431. tx = (j >= 16 ? true : false);
  11432. port_id = (tx ? j - 16 : j);
  11433. val = wcd9xxx_interface_reg_read(priv->wcd9xxx,
  11434. TASHA_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
  11435. if (val) {
  11436. if (!tx)
  11437. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  11438. (port_id / 8);
  11439. else
  11440. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  11441. (port_id / 8);
  11442. int_val = wcd9xxx_interface_reg_read(
  11443. priv->wcd9xxx, reg);
  11444. /*
  11445. * Ignore interrupts for ports for which the
  11446. * interrupts are not specifically enabled.
  11447. */
  11448. if (!(int_val & (1 << (port_id % 8))))
  11449. continue;
  11450. }
  11451. if (val & TASHA_SLIM_IRQ_OVERFLOW)
  11452. pr_err_ratelimited(
  11453. "%s: overflow error on %s port %d, value %x\n",
  11454. __func__, (tx ? "TX" : "RX"), port_id, val);
  11455. if (val & TASHA_SLIM_IRQ_UNDERFLOW)
  11456. pr_err_ratelimited(
  11457. "%s: underflow error on %s port %d, value %x\n",
  11458. __func__, (tx ? "TX" : "RX"), port_id, val);
  11459. if ((val & TASHA_SLIM_IRQ_OVERFLOW) ||
  11460. (val & TASHA_SLIM_IRQ_UNDERFLOW)) {
  11461. if (!tx)
  11462. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  11463. (port_id / 8);
  11464. else
  11465. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  11466. (port_id / 8);
  11467. int_val = wcd9xxx_interface_reg_read(
  11468. priv->wcd9xxx, reg);
  11469. if (int_val & (1 << (port_id % 8))) {
  11470. int_val = int_val ^ (1 << (port_id % 8));
  11471. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11472. reg, int_val);
  11473. }
  11474. }
  11475. if (val & TASHA_SLIM_IRQ_PORT_CLOSED) {
  11476. /*
  11477. * INT SOURCE register starts from RX to TX
  11478. * but port number in the ch_mask is in opposite way
  11479. */
  11480. bit = (tx ? j - 16 : j + 16);
  11481. pr_debug("%s: %s port %d closed value %x, bit %u\n",
  11482. __func__, (tx ? "TX" : "RX"), port_id, val,
  11483. bit);
  11484. for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) {
  11485. pr_debug("%s: priv->dai[%d].ch_mask = 0x%lx\n",
  11486. __func__, k, priv->dai[k].ch_mask);
  11487. if (test_and_clear_bit(bit,
  11488. &priv->dai[k].ch_mask)) {
  11489. cleared = true;
  11490. if (!priv->dai[k].ch_mask)
  11491. wake_up(&priv->dai[k].dai_wait);
  11492. /*
  11493. * There are cases when multiple DAIs
  11494. * might be using the same slimbus
  11495. * channel. Hence don't break here.
  11496. */
  11497. }
  11498. }
  11499. WARN(!cleared,
  11500. "Couldn't find slimbus %s port %d for closing\n",
  11501. (tx ? "TX" : "RX"), port_id);
  11502. }
  11503. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11504. TASHA_SLIM_PGD_PORT_INT_CLR_RX_0 +
  11505. (j / 8),
  11506. 1 << (j % 8));
  11507. }
  11508. return IRQ_HANDLED;
  11509. }
  11510. static int tasha_setup_irqs(struct tasha_priv *tasha)
  11511. {
  11512. int ret = 0;
  11513. struct snd_soc_component *component = tasha->component;
  11514. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11515. struct wcd9xxx_core_resource *core_res =
  11516. &wcd9xxx->core_res;
  11517. ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS,
  11518. tasha_slimbus_irq, "SLIMBUS Slave", tasha);
  11519. if (ret)
  11520. pr_err("%s: Failed to request irq %d\n", __func__,
  11521. WCD9XXX_IRQ_SLIMBUS);
  11522. else
  11523. tasha_slim_interface_init_reg(component);
  11524. return ret;
  11525. }
  11526. static void tasha_init_slim_slave_cfg(struct snd_soc_component *component)
  11527. {
  11528. struct tasha_priv *priv = snd_soc_component_get_drvdata(component);
  11529. struct afe_param_cdc_slimbus_slave_cfg *cfg;
  11530. struct wcd9xxx *wcd9xxx = priv->wcd9xxx;
  11531. uint64_t eaddr = 0;
  11532. cfg = &priv->slimbus_slave_cfg;
  11533. cfg->minor_version = 1;
  11534. cfg->tx_slave_port_offset = 0;
  11535. cfg->rx_slave_port_offset = 16;
  11536. memcpy(&eaddr, &wcd9xxx->slim->e_addr, sizeof(wcd9xxx->slim->e_addr));
  11537. WARN_ON(sizeof(wcd9xxx->slim->e_addr) != 6);
  11538. cfg->device_enum_addr_lsw = eaddr & 0xFFFFFFFF;
  11539. cfg->device_enum_addr_msw = eaddr >> 32;
  11540. dev_dbg(component->dev, "%s: slimbus logical address 0x%llx\n",
  11541. __func__, eaddr);
  11542. }
  11543. static void tasha_cleanup_irqs(struct tasha_priv *tasha)
  11544. {
  11545. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11546. struct wcd9xxx_core_resource *core_res =
  11547. &wcd9xxx->core_res;
  11548. wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tasha);
  11549. }
  11550. static int tasha_handle_pdata(struct tasha_priv *tasha,
  11551. struct wcd9xxx_pdata *pdata)
  11552. {
  11553. struct snd_soc_component *component = tasha->component;
  11554. u8 dmic_ctl_val, mad_dmic_ctl_val;
  11555. u8 anc_ctl_value;
  11556. u32 def_dmic_rate, dmic_clk_drv;
  11557. int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4;
  11558. int rc = 0;
  11559. if (!pdata) {
  11560. dev_err(component->dev, "%s: NULL pdata\n", __func__);
  11561. return -ENODEV;
  11562. }
  11563. /* set micbias voltage */
  11564. vout_ctl_1 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb1_mv);
  11565. vout_ctl_2 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb2_mv);
  11566. vout_ctl_3 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb3_mv);
  11567. vout_ctl_4 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb4_mv);
  11568. if (vout_ctl_1 < 0 || vout_ctl_2 < 0 ||
  11569. vout_ctl_3 < 0 || vout_ctl_4 < 0) {
  11570. rc = -EINVAL;
  11571. goto done;
  11572. }
  11573. snd_soc_component_update_bits(component, WCD9335_ANA_MICB1,
  11574. 0x3F, vout_ctl_1);
  11575. snd_soc_component_update_bits(component, WCD9335_ANA_MICB2,
  11576. 0x3F, vout_ctl_2);
  11577. snd_soc_component_update_bits(component, WCD9335_ANA_MICB3,
  11578. 0x3F, vout_ctl_3);
  11579. snd_soc_component_update_bits(component, WCD9335_ANA_MICB4,
  11580. 0x3F, vout_ctl_4);
  11581. /* Set the DMIC sample rate */
  11582. switch (pdata->mclk_rate) {
  11583. case TASHA_MCLK_CLK_9P6MHZ:
  11584. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  11585. break;
  11586. case TASHA_MCLK_CLK_12P288MHZ:
  11587. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ;
  11588. break;
  11589. default:
  11590. /* should never happen */
  11591. dev_err(component->dev, "%s: Invalid mclk_rate %d\n",
  11592. __func__, pdata->mclk_rate);
  11593. rc = -EINVAL;
  11594. goto done;
  11595. };
  11596. if (pdata->dmic_sample_rate ==
  11597. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11598. dev_info(component->dev, "%s: dmic_rate invalid default = %d\n",
  11599. __func__, def_dmic_rate);
  11600. pdata->dmic_sample_rate = def_dmic_rate;
  11601. }
  11602. if (pdata->mad_dmic_sample_rate ==
  11603. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11604. dev_info(component->dev, "%s: mad_dmic_rate invalid default = %d\n",
  11605. __func__, def_dmic_rate);
  11606. /*
  11607. * use dmic_sample_rate as the default for MAD
  11608. * if mad dmic sample rate is undefined
  11609. */
  11610. pdata->mad_dmic_sample_rate = pdata->dmic_sample_rate;
  11611. }
  11612. if (pdata->ecpp_dmic_sample_rate ==
  11613. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11614. dev_info(component->dev,
  11615. "%s: ecpp_dmic_rate invalid default = %d\n",
  11616. __func__, def_dmic_rate);
  11617. /*
  11618. * use dmic_sample_rate as the default for ECPP DMIC
  11619. * if ecpp dmic sample rate is undefined
  11620. */
  11621. pdata->ecpp_dmic_sample_rate = pdata->dmic_sample_rate;
  11622. }
  11623. if (pdata->dmic_clk_drv ==
  11624. WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED) {
  11625. pdata->dmic_clk_drv = WCD9335_DMIC_CLK_DRIVE_DEFAULT;
  11626. dev_info(component->dev,
  11627. "%s: dmic_clk_strength invalid, default = %d\n",
  11628. __func__, pdata->dmic_clk_drv);
  11629. }
  11630. switch (pdata->dmic_clk_drv) {
  11631. case 2:
  11632. dmic_clk_drv = 0;
  11633. break;
  11634. case 4:
  11635. dmic_clk_drv = 1;
  11636. break;
  11637. case 8:
  11638. dmic_clk_drv = 2;
  11639. break;
  11640. case 16:
  11641. dmic_clk_drv = 3;
  11642. break;
  11643. default:
  11644. dev_err(component->dev,
  11645. "%s: invalid dmic_clk_drv %d, using default\n",
  11646. __func__, pdata->dmic_clk_drv);
  11647. dmic_clk_drv = 0;
  11648. break;
  11649. }
  11650. snd_soc_component_update_bits(component, WCD9335_TEST_DEBUG_PAD_DRVCTL,
  11651. 0x0C, dmic_clk_drv << 2);
  11652. /*
  11653. * Default the DMIC clk rates to mad_dmic_sample_rate,
  11654. * whereas, the anc/txfe dmic rates to dmic_sample_rate
  11655. * since the anc/txfe are independent of mad block.
  11656. */
  11657. mad_dmic_ctl_val = tasha_get_dmic_clk_val(tasha->component,
  11658. pdata->mclk_rate,
  11659. pdata->mad_dmic_sample_rate);
  11660. snd_soc_component_update_bits(component, WCD9335_CPE_SS_DMIC0_CTL,
  11661. 0x0E, mad_dmic_ctl_val << 1);
  11662. snd_soc_component_update_bits(component, WCD9335_CPE_SS_DMIC1_CTL,
  11663. 0x0E, mad_dmic_ctl_val << 1);
  11664. snd_soc_component_update_bits(component, WCD9335_CPE_SS_DMIC2_CTL,
  11665. 0x0E, mad_dmic_ctl_val << 1);
  11666. dmic_ctl_val = tasha_get_dmic_clk_val(tasha->component,
  11667. pdata->mclk_rate,
  11668. pdata->dmic_sample_rate);
  11669. if (dmic_ctl_val == WCD9335_DMIC_CLK_DIV_2)
  11670. anc_ctl_value = WCD9335_ANC_DMIC_X2_FULL_RATE;
  11671. else
  11672. anc_ctl_value = WCD9335_ANC_DMIC_X2_HALF_RATE;
  11673. snd_soc_component_update_bits(component, WCD9335_CDC_ANC0_MODE_2_CTL,
  11674. 0x40, anc_ctl_value << 6);
  11675. snd_soc_component_update_bits(component, WCD9335_CDC_ANC0_MODE_2_CTL,
  11676. 0x20, anc_ctl_value << 5);
  11677. snd_soc_component_update_bits(component, WCD9335_CDC_ANC1_MODE_2_CTL,
  11678. 0x40, anc_ctl_value << 6);
  11679. snd_soc_component_update_bits(component, WCD9335_CDC_ANC1_MODE_2_CTL,
  11680. 0x20, anc_ctl_value << 5);
  11681. done:
  11682. return rc;
  11683. }
  11684. static struct wcd_cpe_core *tasha_codec_get_cpe_core(
  11685. struct snd_soc_component *component)
  11686. {
  11687. struct tasha_priv *priv = snd_soc_component_get_drvdata(component);
  11688. return priv->cpe_core;
  11689. }
  11690. static int tasha_codec_cpe_fll_update_divider(
  11691. struct snd_soc_component *component, u32 cpe_fll_rate)
  11692. {
  11693. struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
  11694. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  11695. u32 div_val = 0, l_val = 0;
  11696. u32 computed_cpe_fll;
  11697. if (cpe_fll_rate != CPE_FLL_CLK_75MHZ &&
  11698. cpe_fll_rate != CPE_FLL_CLK_150MHZ) {
  11699. dev_err(component->dev,
  11700. "%s: Invalid CPE fll rate request %u\n",
  11701. __func__, cpe_fll_rate);
  11702. return -EINVAL;
  11703. }
  11704. if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_12P288MHZ) {
  11705. /* update divider to 10 and enable 5x divider */
  11706. snd_soc_component_write(component, WCD9335_CPE_FLL_USER_CTL_1,
  11707. 0x55);
  11708. div_val = 10;
  11709. } else if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_9P6MHZ) {
  11710. /* update divider to 8 and enable 2x divider */
  11711. snd_soc_component_update_bits(component,
  11712. WCD9335_CPE_FLL_USER_CTL_0,
  11713. 0x7C, 0x70);
  11714. snd_soc_component_update_bits(component,
  11715. WCD9335_CPE_FLL_USER_CTL_1,
  11716. 0xE0, 0x20);
  11717. div_val = 8;
  11718. } else {
  11719. dev_err(component->dev,
  11720. "%s: Invalid MCLK rate %u\n",
  11721. __func__, wcd9xxx->mclk_rate);
  11722. return -EINVAL;
  11723. }
  11724. l_val = ((cpe_fll_rate / 1000) * div_val) /
  11725. (wcd9xxx->mclk_rate / 1000);
  11726. /* If l_val was integer truncated, increment l_val once */
  11727. computed_cpe_fll = (wcd9xxx->mclk_rate / div_val) * l_val;
  11728. if (computed_cpe_fll < cpe_fll_rate)
  11729. l_val++;
  11730. /* update L value LSB and MSB */
  11731. snd_soc_component_write(component, WCD9335_CPE_FLL_L_VAL_CTL_0,
  11732. (l_val & 0xFF));
  11733. snd_soc_component_write(component, WCD9335_CPE_FLL_L_VAL_CTL_1,
  11734. ((l_val >> 8) & 0xFF));
  11735. tasha->current_cpe_clk_freq = cpe_fll_rate;
  11736. dev_dbg(component->dev,
  11737. "%s: updated l_val to %u for cpe_clk %u and mclk %u\n",
  11738. __func__, l_val, cpe_fll_rate, wcd9xxx->mclk_rate);
  11739. return 0;
  11740. }
  11741. static int __tasha_cdc_change_cpe_clk(struct snd_soc_component *component,
  11742. u32 clk_freq)
  11743. {
  11744. int ret = 0;
  11745. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  11746. if (!tasha_cdc_is_svs_enabled(tasha)) {
  11747. dev_dbg(component->dev,
  11748. "%s: SVS not enabled or tasha is not 2p0, return\n",
  11749. __func__);
  11750. return 0;
  11751. }
  11752. dev_dbg(component->dev, "%s: clk_freq = %u\n", __func__, clk_freq);
  11753. if (clk_freq == CPE_FLL_CLK_75MHZ) {
  11754. /* Change to SVS */
  11755. snd_soc_component_update_bits(component,
  11756. WCD9335_CPE_FLL_FLL_MODE,
  11757. 0x08, 0x08);
  11758. if (tasha_codec_cpe_fll_update_divider(component, clk_freq)) {
  11759. ret = -EINVAL;
  11760. goto done;
  11761. }
  11762. snd_soc_component_update_bits(component,
  11763. WCD9335_CPE_FLL_FLL_MODE,
  11764. 0x10, 0x10);
  11765. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  11766. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  11767. } else if (clk_freq == CPE_FLL_CLK_150MHZ) {
  11768. /* change to nominal */
  11769. snd_soc_component_update_bits(component,
  11770. WCD9335_CPE_FLL_FLL_MODE,
  11771. 0x08, 0x08);
  11772. set_bit(CPE_NOMINAL, &tasha->status_mask);
  11773. tasha_codec_update_sido_voltage(tasha, SIDO_VOLTAGE_NOMINAL_MV);
  11774. if (tasha_codec_cpe_fll_update_divider(component, clk_freq)) {
  11775. ret = -EINVAL;
  11776. goto done;
  11777. }
  11778. snd_soc_component_update_bits(component,
  11779. WCD9335_CPE_FLL_FLL_MODE,
  11780. 0x10, 0x10);
  11781. } else {
  11782. dev_err(component->dev,
  11783. "%s: Invalid clk_freq request %d for CPE FLL\n",
  11784. __func__, clk_freq);
  11785. ret = -EINVAL;
  11786. }
  11787. done:
  11788. snd_soc_component_update_bits(component, WCD9335_CPE_FLL_FLL_MODE,
  11789. 0x10, 0x00);
  11790. snd_soc_component_update_bits(component, WCD9335_CPE_FLL_FLL_MODE,
  11791. 0x08, 0x00);
  11792. return ret;
  11793. }
  11794. static int tasha_codec_cpe_fll_enable(struct snd_soc_component *component,
  11795. bool enable)
  11796. {
  11797. struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
  11798. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  11799. u8 clk_sel_reg_val = 0x00;
  11800. dev_dbg(component->dev, "%s: enable = %s\n",
  11801. __func__, enable ? "true" : "false");
  11802. if (enable) {
  11803. if (tasha_cdc_is_svs_enabled(tasha)) {
  11804. /* FLL enable is always at SVS */
  11805. if (__tasha_cdc_change_cpe_clk(component,
  11806. CPE_FLL_CLK_75MHZ)) {
  11807. dev_err(component->dev,
  11808. "%s: clk change to %d failed\n",
  11809. __func__, CPE_FLL_CLK_75MHZ);
  11810. return -EINVAL;
  11811. }
  11812. } else {
  11813. if (tasha_codec_cpe_fll_update_divider(component,
  11814. CPE_FLL_CLK_75MHZ)) {
  11815. dev_err(component->dev,
  11816. "%s: clk change to %d failed\n",
  11817. __func__, CPE_FLL_CLK_75MHZ);
  11818. return -EINVAL;
  11819. }
  11820. }
  11821. if (TASHA_IS_1_0(wcd9xxx)) {
  11822. tasha_cdc_mclk_enable(component, true, false);
  11823. clk_sel_reg_val = 0x02;
  11824. }
  11825. /* Setup CPE reference clk */
  11826. snd_soc_component_update_bits(component, WCD9335_ANA_CLK_TOP,
  11827. 0x02, clk_sel_reg_val);
  11828. /* enable CPE FLL reference clk */
  11829. snd_soc_component_update_bits(component, WCD9335_ANA_CLK_TOP,
  11830. 0x01, 0x01);
  11831. /* program the PLL */
  11832. snd_soc_component_update_bits(component,
  11833. WCD9335_CPE_FLL_USER_CTL_0,
  11834. 0x01, 0x01);
  11835. /* TEST clk setting */
  11836. snd_soc_component_update_bits(component,
  11837. WCD9335_CPE_FLL_TEST_CTL_0,
  11838. 0x80, 0x80);
  11839. /* set FLL mode to HW controlled */
  11840. snd_soc_component_update_bits(component,
  11841. WCD9335_CPE_FLL_FLL_MODE,
  11842. 0x60, 0x00);
  11843. snd_soc_component_write(component, WCD9335_CPE_FLL_FLL_MODE,
  11844. 0x80);
  11845. } else {
  11846. /* disable CPE FLL reference clk */
  11847. snd_soc_component_update_bits(component, WCD9335_ANA_CLK_TOP,
  11848. 0x01, 0x00);
  11849. /* undo TEST clk setting */
  11850. snd_soc_component_update_bits(component,
  11851. WCD9335_CPE_FLL_TEST_CTL_0,
  11852. 0x80, 0x00);
  11853. /* undo FLL mode to HW control */
  11854. snd_soc_component_write(component,
  11855. WCD9335_CPE_FLL_FLL_MODE, 0x00);
  11856. snd_soc_component_update_bits(component,
  11857. WCD9335_CPE_FLL_FLL_MODE,
  11858. 0x60, 0x20);
  11859. /* undo the PLL */
  11860. snd_soc_component_update_bits(component,
  11861. WCD9335_CPE_FLL_USER_CTL_0,
  11862. 0x01, 0x00);
  11863. if (TASHA_IS_1_0(wcd9xxx))
  11864. tasha_cdc_mclk_enable(component, false, false);
  11865. /*
  11866. * FLL could get disabled while at nominal,
  11867. * scale it back to SVS
  11868. */
  11869. if (tasha_cdc_is_svs_enabled(tasha))
  11870. __tasha_cdc_change_cpe_clk(component,
  11871. CPE_FLL_CLK_75MHZ);
  11872. }
  11873. return 0;
  11874. }
  11875. static void tasha_cdc_query_cpe_clk_plan(void *data,
  11876. struct cpe_svc_cfg_clk_plan *clk_freq)
  11877. {
  11878. struct snd_soc_component *component = data;
  11879. struct tasha_priv *tasha;
  11880. u32 cpe_clk_khz;
  11881. if (!component) {
  11882. pr_err("%s: Invalid component handle\n",
  11883. __func__);
  11884. return;
  11885. }
  11886. tasha = snd_soc_component_get_drvdata(component);
  11887. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11888. dev_dbg(component->dev,
  11889. "%s: current_clk_freq = %u\n",
  11890. __func__, tasha->current_cpe_clk_freq);
  11891. clk_freq->current_clk_feq = cpe_clk_khz;
  11892. clk_freq->num_clk_freqs = 2;
  11893. if (tasha_cdc_is_svs_enabled(tasha)) {
  11894. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ / 1000;
  11895. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ / 1000;
  11896. } else {
  11897. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ;
  11898. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ;
  11899. }
  11900. }
  11901. static void tasha_cdc_change_cpe_clk(void *data,
  11902. u32 clk_freq)
  11903. {
  11904. struct snd_soc_component *component = data;
  11905. struct tasha_priv *tasha;
  11906. u32 cpe_clk_khz, req_freq = 0;
  11907. if (!component) {
  11908. pr_err("%s: Invalid codec handle\n",
  11909. __func__);
  11910. return;
  11911. }
  11912. tasha = snd_soc_component_get_drvdata(component);
  11913. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11914. if (tasha_cdc_is_svs_enabled(tasha)) {
  11915. if ((clk_freq * 1000) <= CPE_FLL_CLK_75MHZ)
  11916. req_freq = CPE_FLL_CLK_75MHZ;
  11917. else
  11918. req_freq = CPE_FLL_CLK_150MHZ;
  11919. }
  11920. dev_dbg(component->dev,
  11921. "%s: requested clk_freq = %u, current clk_freq = %u\n",
  11922. __func__, clk_freq * 1000,
  11923. tasha->current_cpe_clk_freq);
  11924. if (tasha_cdc_is_svs_enabled(tasha)) {
  11925. if (__tasha_cdc_change_cpe_clk(component, req_freq))
  11926. dev_err(component->dev,
  11927. "%s: clock/voltage scaling failed\n",
  11928. __func__);
  11929. }
  11930. }
  11931. static int tasha_codec_slim_reserve_bw(struct snd_soc_component *component,
  11932. u32 bw_ops, bool commit)
  11933. {
  11934. struct wcd9xxx *wcd9xxx;
  11935. if (!component) {
  11936. pr_err("%s: Invalid handle to codec\n",
  11937. __func__);
  11938. return -EINVAL;
  11939. }
  11940. wcd9xxx = dev_get_drvdata(component->dev->parent);
  11941. if (!wcd9xxx) {
  11942. dev_err(component->dev, "%s: Invalid parent drv_data\n",
  11943. __func__);
  11944. return -EINVAL;
  11945. }
  11946. return wcd9xxx_slim_reserve_bw(wcd9xxx, bw_ops, commit);
  11947. }
  11948. static int tasha_codec_vote_max_bw(struct snd_soc_component *component,
  11949. bool vote)
  11950. {
  11951. u32 bw_ops;
  11952. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  11953. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  11954. return 0;
  11955. mutex_lock(&tasha->sb_clk_gear_lock);
  11956. if (vote) {
  11957. tasha->ref_count++;
  11958. if (tasha->ref_count == 1) {
  11959. bw_ops = SLIM_BW_CLK_GEAR_9;
  11960. tasha_codec_slim_reserve_bw(component,
  11961. bw_ops, true);
  11962. }
  11963. } else if (!vote && tasha->ref_count > 0) {
  11964. tasha->ref_count--;
  11965. if (tasha->ref_count == 0) {
  11966. bw_ops = SLIM_BW_UNVOTE;
  11967. tasha_codec_slim_reserve_bw(component,
  11968. bw_ops, true);
  11969. }
  11970. };
  11971. dev_dbg(component->dev, "%s Value of counter after vote or un-vote is %d\n",
  11972. __func__, tasha->ref_count);
  11973. mutex_unlock(&tasha->sb_clk_gear_lock);
  11974. return 0;
  11975. }
  11976. static int tasha_cpe_err_irq_control(struct snd_soc_component *component,
  11977. enum cpe_err_irq_cntl_type cntl_type, u8 *status)
  11978. {
  11979. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  11980. u8 irq_bits;
  11981. if (TASHA_IS_2_0(tasha->wcd9xxx))
  11982. irq_bits = 0xFF;
  11983. else
  11984. irq_bits = 0x3F;
  11985. if (status)
  11986. irq_bits = (*status) & irq_bits;
  11987. switch (cntl_type) {
  11988. case CPE_ERR_IRQ_MASK:
  11989. snd_soc_component_update_bits(component,
  11990. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11991. irq_bits, irq_bits);
  11992. break;
  11993. case CPE_ERR_IRQ_UNMASK:
  11994. snd_soc_component_update_bits(component,
  11995. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11996. irq_bits, 0x00);
  11997. break;
  11998. case CPE_ERR_IRQ_CLEAR:
  11999. snd_soc_component_write(component,
  12000. WCD9335_CPE_SS_SS_ERROR_INT_CLEAR,
  12001. irq_bits);
  12002. break;
  12003. case CPE_ERR_IRQ_STATUS:
  12004. if (!status)
  12005. return -EINVAL;
  12006. *status = snd_soc_component_read32(component,
  12007. WCD9335_CPE_SS_SS_ERROR_INT_STATUS);
  12008. break;
  12009. }
  12010. return 0;
  12011. }
  12012. static const struct wcd_cpe_cdc_cb cpe_cb = {
  12013. .cdc_clk_en = tasha_codec_internal_rco_ctrl,
  12014. .cpe_clk_en = tasha_codec_cpe_fll_enable,
  12015. .get_afe_out_port_id = tasha_codec_get_mad_port_id,
  12016. .lab_cdc_ch_ctl = tasha_codec_enable_slimtx_mad,
  12017. .cdc_ext_clk = tasha_cdc_mclk_enable,
  12018. .bus_vote_bw = tasha_codec_vote_max_bw,
  12019. .cpe_err_irq_control = tasha_cpe_err_irq_control,
  12020. };
  12021. static struct cpe_svc_init_param cpe_svc_params = {
  12022. .version = CPE_SVC_INIT_PARAM_V1,
  12023. .query_freq_plans_cb = tasha_cdc_query_cpe_clk_plan,
  12024. .change_freq_plan_cb = tasha_cdc_change_cpe_clk,
  12025. };
  12026. static int tasha_cpe_initialize(struct snd_soc_component *component)
  12027. {
  12028. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  12029. struct wcd_cpe_params cpe_params;
  12030. memset(&cpe_params, 0,
  12031. sizeof(struct wcd_cpe_params));
  12032. cpe_params.component = component;
  12033. cpe_params.get_cpe_core = tasha_codec_get_cpe_core;
  12034. cpe_params.cdc_cb = &cpe_cb;
  12035. cpe_params.dbg_mode = cpe_debug_mode;
  12036. cpe_params.cdc_major_ver = CPE_SVC_CODEC_WCD9335;
  12037. cpe_params.cdc_minor_ver = CPE_SVC_CODEC_V1P0;
  12038. cpe_params.cdc_id = CPE_SVC_CODEC_WCD9335;
  12039. cpe_params.cdc_irq_info.cpe_engine_irq =
  12040. WCD9335_IRQ_SVA_OUTBOX1;
  12041. cpe_params.cdc_irq_info.cpe_err_irq =
  12042. WCD9335_IRQ_SVA_ERROR;
  12043. cpe_params.cdc_irq_info.cpe_fatal_irqs =
  12044. TASHA_CPE_FATAL_IRQS;
  12045. cpe_svc_params.context = component;
  12046. cpe_params.cpe_svc_params = &cpe_svc_params;
  12047. tasha->cpe_core = wcd_cpe_init("cpe_9335", component,
  12048. &cpe_params);
  12049. if (IS_ERR_OR_NULL(tasha->cpe_core)) {
  12050. dev_err(component->dev,
  12051. "%s: Failed to enable CPE\n",
  12052. __func__);
  12053. return -EINVAL;
  12054. }
  12055. return 0;
  12056. }
  12057. static const struct wcd_resmgr_cb tasha_resmgr_cb = {
  12058. .cdc_rco_ctrl = __tasha_codec_internal_rco_ctrl,
  12059. };
  12060. static int tasha_device_down(struct wcd9xxx *wcd9xxx)
  12061. {
  12062. struct snd_soc_component *component;
  12063. struct tasha_priv *priv;
  12064. int count;
  12065. int i = 0;
  12066. component = (struct snd_soc_component *)(wcd9xxx->ssr_priv);
  12067. priv = snd_soc_component_get_drvdata(component);
  12068. wcd_cpe_ssr_event(priv->cpe_core, WCD_CPE_BUS_DOWN_EVENT);
  12069. for (i = 0; i < priv->nr; i++)
  12070. swrm_wcd_notify(priv->swr_ctrl_data[i].swr_pdev,
  12071. SWR_DEVICE_DOWN, NULL);
  12072. snd_soc_card_change_online_state(component->card, 0);
  12073. for (count = 0; count < NUM_CODEC_DAIS; count++)
  12074. priv->dai[count].bus_down_in_recovery = true;
  12075. priv->resmgr->sido_input_src = SIDO_SOURCE_INTERNAL;
  12076. return 0;
  12077. }
  12078. static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx)
  12079. {
  12080. int i, ret = 0;
  12081. struct wcd9xxx *control;
  12082. struct snd_soc_component *component;
  12083. struct tasha_priv *tasha;
  12084. struct wcd9xxx_pdata *pdata;
  12085. component = (struct snd_soc_component *)(wcd9xxx->ssr_priv);
  12086. tasha = snd_soc_component_get_drvdata(component);
  12087. control = dev_get_drvdata(component->dev->parent);
  12088. wcd9xxx_set_power_state(tasha->wcd9xxx,
  12089. WCD_REGION_POWER_COLLAPSE_REMOVE,
  12090. WCD9XXX_DIG_CORE_REGION_1);
  12091. mutex_lock(&tasha->codec_mutex);
  12092. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  12093. control->slim_slave->laddr;
  12094. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  12095. control->slim->laddr;
  12096. tasha_init_slim_slave_cfg(component);
  12097. if (tasha->machine_codec_event_cb)
  12098. tasha->machine_codec_event_cb(component,
  12099. WCD9335_CODEC_EVENT_CODEC_UP);
  12100. snd_soc_card_change_online_state(component->card, 1);
  12101. /* Class-H Init*/
  12102. wcd_clsh_init(&tasha->clsh_d);
  12103. for (i = 0; i < TASHA_MAX_MICBIAS; i++)
  12104. tasha->micb_ref[i] = 0;
  12105. tasha_update_reg_defaults(tasha);
  12106. tasha->component = component;
  12107. dev_dbg(component->dev, "%s: MCLK Rate = %x\n",
  12108. __func__, control->mclk_rate);
  12109. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  12110. snd_soc_component_update_bits(component,
  12111. WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  12112. 0x03, 0x00);
  12113. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  12114. snd_soc_component_update_bits(component,
  12115. WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  12116. 0x03, 0x01);
  12117. tasha_codec_init_reg(component);
  12118. wcd_resmgr_post_ssr_v2(tasha->resmgr);
  12119. tasha_enable_efuse_sensing(component);
  12120. regcache_mark_dirty(component->regmap);
  12121. regcache_sync(component->regmap);
  12122. pdata = dev_get_platdata(component->dev->parent);
  12123. ret = tasha_handle_pdata(tasha, pdata);
  12124. if (ret < 0)
  12125. dev_err(component->dev, "%s: invalid pdata\n", __func__);
  12126. /* Reset reference counter for voting for max bw */
  12127. tasha->ref_count = 0;
  12128. /* MBHC Init */
  12129. wcd_mbhc_deinit(&tasha->mbhc);
  12130. tasha->mbhc_started = false;
  12131. /* Initialize MBHC module */
  12132. ret = wcd_mbhc_init(&tasha->mbhc, component, &mbhc_cb, &intr_ids,
  12133. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  12134. if (ret)
  12135. dev_err(component->dev, "%s: mbhc initialization failed\n",
  12136. __func__);
  12137. else
  12138. tasha_mbhc_hs_detect(component, tasha->mbhc.mbhc_cfg);
  12139. tasha_cleanup_irqs(tasha);
  12140. ret = tasha_setup_irqs(tasha);
  12141. if (ret) {
  12142. dev_err(component->dev, "%s: tasha irq setup failed %d\n",
  12143. __func__, ret);
  12144. goto err;
  12145. }
  12146. tasha_set_spkr_mode(component, tasha->spkr_mode);
  12147. wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT);
  12148. err:
  12149. mutex_unlock(&tasha->codec_mutex);
  12150. return ret;
  12151. }
  12152. static struct regulator *tasha_codec_find_ondemand_regulator(
  12153. struct snd_soc_component *component, const char *name)
  12154. {
  12155. int i;
  12156. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  12157. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  12158. struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent);
  12159. for (i = 0; i < wcd9xxx->num_of_supplies; ++i) {
  12160. if (pdata->regulator[i].ondemand &&
  12161. wcd9xxx->supplies[i].supply &&
  12162. !strcmp(wcd9xxx->supplies[i].supply, name))
  12163. return wcd9xxx->supplies[i].consumer;
  12164. }
  12165. dev_dbg(tasha->dev, "Warning: regulator not found:%s\n",
  12166. name);
  12167. return NULL;
  12168. }
  12169. static int tasha_codec_probe(struct snd_soc_component *component)
  12170. {
  12171. struct wcd9xxx *control;
  12172. struct tasha_priv *tasha;
  12173. struct wcd9xxx_pdata *pdata;
  12174. struct snd_soc_dapm_context *dapm =
  12175. snd_soc_component_get_dapm(component);
  12176. int i, ret;
  12177. void *ptr = NULL;
  12178. struct regulator *supply;
  12179. control = dev_get_drvdata(component->dev->parent);
  12180. snd_soc_component_init_regmap(component, control->regmap);
  12181. dev_info(component->dev, "%s()\n", __func__);
  12182. tasha = snd_soc_component_get_drvdata(component);
  12183. tasha->intf_type = wcd9xxx_get_intf_type();
  12184. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  12185. control->dev_down = tasha_device_down;
  12186. control->post_reset = tasha_post_reset_cb;
  12187. control->ssr_priv = (void *)component;
  12188. }
  12189. /* Resource Manager post Init */
  12190. ret = wcd_resmgr_post_init(tasha->resmgr, &tasha_resmgr_cb, component);
  12191. if (ret) {
  12192. dev_err(component->dev, "%s: wcd resmgr post init failed\n",
  12193. __func__);
  12194. goto err;
  12195. }
  12196. /* Class-H Init*/
  12197. wcd_clsh_init(&tasha->clsh_d);
  12198. /* Default HPH Mode to Class-H HiFi */
  12199. tasha->hph_mode = CLS_H_HIFI;
  12200. tasha->component = component;
  12201. for (i = 0; i < COMPANDER_MAX; i++)
  12202. tasha->comp_enabled[i] = 0;
  12203. tasha->spkr_gain_offset = RX_GAIN_OFFSET_0_DB;
  12204. tasha->intf_type = wcd9xxx_get_intf_type();
  12205. tasha_update_reg_reset_values(component);
  12206. pr_debug("%s: MCLK Rate = %x\n", __func__, control->mclk_rate);
  12207. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  12208. snd_soc_component_update_bits(component,
  12209. WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  12210. 0x03, 0x00);
  12211. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  12212. snd_soc_component_update_bits(component,
  12213. WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  12214. 0x03, 0x01);
  12215. tasha_codec_init_reg(component);
  12216. tasha_enable_efuse_sensing(component);
  12217. pdata = dev_get_platdata(component->dev->parent);
  12218. ret = tasha_handle_pdata(tasha, pdata);
  12219. if (ret < 0) {
  12220. pr_err("%s: bad pdata\n", __func__);
  12221. goto err;
  12222. }
  12223. for (i = ON_DEMAND_MICBIAS; i < ON_DEMAND_SUPPLIES_MAX; i++) {
  12224. supply = tasha_codec_find_ondemand_regulator(component,
  12225. on_demand_supply_name[i]);
  12226. if (supply) {
  12227. tasha->on_demand_list[i].supply = supply;
  12228. tasha->on_demand_list[i].ondemand_supply_count =
  12229. 0;
  12230. }
  12231. }
  12232. tasha->fw_data = devm_kzalloc(component->dev,
  12233. sizeof(*(tasha->fw_data)), GFP_KERNEL);
  12234. if (!tasha->fw_data)
  12235. goto err;
  12236. set_bit(WCD9XXX_ANC_CAL, tasha->fw_data->cal_bit);
  12237. set_bit(WCD9XXX_MBHC_CAL, tasha->fw_data->cal_bit);
  12238. set_bit(WCD9XXX_MAD_CAL, tasha->fw_data->cal_bit);
  12239. set_bit(WCD9XXX_VBAT_CAL, tasha->fw_data->cal_bit);
  12240. ret = wcd_cal_create_hwdep(tasha->fw_data,
  12241. WCD9XXX_CODEC_HWDEP_NODE, component);
  12242. if (ret < 0) {
  12243. dev_err(component->dev, "%s hwdep failed %d\n", __func__, ret);
  12244. goto err_hwdep;
  12245. }
  12246. /* Initialize MBHC module */
  12247. if (TASHA_IS_2_0(tasha->wcd9xxx)) {
  12248. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].reg =
  12249. WCD9335_MBHC_FSM_STATUS;
  12250. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].mask = 0x01;
  12251. }
  12252. ret = wcd_mbhc_init(&tasha->mbhc, component, &mbhc_cb, &intr_ids,
  12253. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  12254. if (ret) {
  12255. pr_err("%s: mbhc initialization failed\n", __func__);
  12256. goto err_hwdep;
  12257. }
  12258. ptr = devm_kzalloc(component->dev, (sizeof(tasha_rx_chs) +
  12259. sizeof(tasha_tx_chs)), GFP_KERNEL);
  12260. if (!ptr) {
  12261. ret = -ENOMEM;
  12262. goto err_hwdep;
  12263. }
  12264. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  12265. snd_soc_dapm_new_controls(dapm, tasha_dapm_i2s_widgets,
  12266. ARRAY_SIZE(tasha_dapm_i2s_widgets));
  12267. snd_soc_dapm_add_routes(dapm, audio_i2s_map,
  12268. ARRAY_SIZE(audio_i2s_map));
  12269. for (i = 0; i < ARRAY_SIZE(tasha_i2s_dai); i++) {
  12270. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  12271. init_waitqueue_head(&tasha->dai[i].dai_wait);
  12272. }
  12273. } else if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  12274. for (i = 0; i < NUM_CODEC_DAIS; i++) {
  12275. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  12276. init_waitqueue_head(&tasha->dai[i].dai_wait);
  12277. }
  12278. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  12279. control->slim_slave->laddr;
  12280. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  12281. control->slim->laddr;
  12282. tasha_slimbus_slave_port_cfg.slave_port_mapping[0] =
  12283. TASHA_TX13;
  12284. tasha_init_slim_slave_cfg(component);
  12285. }
  12286. snd_soc_add_component_controls(component, impedance_detect_controls,
  12287. ARRAY_SIZE(impedance_detect_controls));
  12288. snd_soc_add_component_controls(component, hph_type_detect_controls,
  12289. ARRAY_SIZE(hph_type_detect_controls));
  12290. snd_soc_add_component_controls(component,
  12291. tasha_analog_gain_controls,
  12292. ARRAY_SIZE(tasha_analog_gain_controls));
  12293. if (tasha->is_wsa_attach)
  12294. snd_soc_add_component_controls(component,
  12295. tasha_spkr_wsa_controls,
  12296. ARRAY_SIZE(tasha_spkr_wsa_controls));
  12297. control->num_rx_port = TASHA_RX_MAX;
  12298. control->rx_chs = ptr;
  12299. memcpy(control->rx_chs, tasha_rx_chs, sizeof(tasha_rx_chs));
  12300. control->num_tx_port = TASHA_TX_MAX;
  12301. control->tx_chs = ptr + sizeof(tasha_rx_chs);
  12302. memcpy(control->tx_chs, tasha_tx_chs, sizeof(tasha_tx_chs));
  12303. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Playback");
  12304. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Capture");
  12305. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Playback");
  12306. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Capture");
  12307. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  12308. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Playback");
  12309. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Capture");
  12310. snd_soc_dapm_ignore_suspend(dapm, "AIF4 Playback");
  12311. snd_soc_dapm_ignore_suspend(dapm, "AIF Mix Playback");
  12312. snd_soc_dapm_ignore_suspend(dapm, "AIF4 MAD TX");
  12313. snd_soc_dapm_ignore_suspend(dapm, "VIfeed");
  12314. snd_soc_dapm_ignore_suspend(dapm, "AIF5 CPE TX");
  12315. }
  12316. snd_soc_dapm_sync(dapm);
  12317. ret = tasha_setup_irqs(tasha);
  12318. if (ret) {
  12319. pr_err("%s: tasha irq setup failed %d\n", __func__, ret);
  12320. goto err_pdata;
  12321. }
  12322. ret = tasha_cpe_initialize(component);
  12323. if (ret) {
  12324. dev_err(component->dev,
  12325. "%s: cpe initialization failed, err = %d\n",
  12326. __func__, ret);
  12327. /* Do not fail probe if CPE failed */
  12328. ret = 0;
  12329. }
  12330. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  12331. tasha->tx_hpf_work[i].tasha = tasha;
  12332. tasha->tx_hpf_work[i].decimator = i;
  12333. INIT_DELAYED_WORK(&tasha->tx_hpf_work[i].dwork,
  12334. tasha_tx_hpf_corner_freq_callback);
  12335. }
  12336. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  12337. tasha->tx_mute_dwork[i].tasha = tasha;
  12338. tasha->tx_mute_dwork[i].decimator = i;
  12339. INIT_DELAYED_WORK(&tasha->tx_mute_dwork[i].dwork,
  12340. tasha_tx_mute_update_callback);
  12341. }
  12342. tasha->spk_anc_dwork.tasha = tasha;
  12343. INIT_DELAYED_WORK(&tasha->spk_anc_dwork.dwork,
  12344. tasha_spk_anc_update_callback);
  12345. mutex_lock(&tasha->codec_mutex);
  12346. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  12347. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  12348. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  12349. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  12350. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  12351. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  12352. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  12353. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  12354. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  12355. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  12356. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  12357. mutex_unlock(&tasha->codec_mutex);
  12358. snd_soc_dapm_sync(dapm);
  12359. return ret;
  12360. err_pdata:
  12361. devm_kfree(component->dev, ptr);
  12362. control->rx_chs = NULL;
  12363. control->tx_chs = NULL;
  12364. err_hwdep:
  12365. devm_kfree(component->dev, tasha->fw_data);
  12366. tasha->fw_data = NULL;
  12367. err:
  12368. return ret;
  12369. }
  12370. static void tasha_codec_remove(struct snd_soc_component *component)
  12371. {
  12372. struct tasha_priv *tasha = snd_soc_component_get_drvdata(component);
  12373. struct wcd9xxx *control;
  12374. control = dev_get_drvdata(component->dev->parent);
  12375. control->num_rx_port = 0;
  12376. control->num_tx_port = 0;
  12377. control->rx_chs = NULL;
  12378. control->tx_chs = NULL;
  12379. tasha_cleanup_irqs(tasha);
  12380. /* Cleanup MBHC */
  12381. wcd_mbhc_deinit(&tasha->mbhc);
  12382. /* Cleanup resmgr */
  12383. return;
  12384. }
  12385. static const struct snd_soc_component_driver soc_codec_dev_tasha = {
  12386. .name = DRV_NAME,
  12387. .probe = tasha_codec_probe,
  12388. .remove = tasha_codec_remove,
  12389. .controls = tasha_snd_controls,
  12390. .num_controls = ARRAY_SIZE(tasha_snd_controls),
  12391. .dapm_widgets = tasha_dapm_widgets,
  12392. .num_dapm_widgets = ARRAY_SIZE(tasha_dapm_widgets),
  12393. .dapm_routes = audio_map,
  12394. .num_dapm_routes = ARRAY_SIZE(audio_map),
  12395. };
  12396. #ifdef CONFIG_PM
  12397. static int tasha_suspend(struct device *dev)
  12398. {
  12399. struct platform_device *pdev = to_platform_device(dev);
  12400. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  12401. dev_dbg(dev, "%s: system suspend\n", __func__);
  12402. if (cancel_delayed_work_sync(&tasha->power_gate_work))
  12403. tasha_codec_power_gate_digital_core(tasha);
  12404. return 0;
  12405. }
  12406. static int tasha_resume(struct device *dev)
  12407. {
  12408. struct platform_device *pdev = to_platform_device(dev);
  12409. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  12410. if (!tasha) {
  12411. dev_err(dev, "%s: tasha private data is NULL\n", __func__);
  12412. return -EINVAL;
  12413. }
  12414. dev_dbg(dev, "%s: system resume\n", __func__);
  12415. return 0;
  12416. }
  12417. static const struct dev_pm_ops tasha_pm_ops = {
  12418. .suspend = tasha_suspend,
  12419. .resume = tasha_resume,
  12420. };
  12421. #endif
  12422. static int tasha_swrm_read(void *handle, int reg)
  12423. {
  12424. struct tasha_priv *tasha;
  12425. struct wcd9xxx *wcd9xxx;
  12426. unsigned short swr_rd_addr_base;
  12427. unsigned short swr_rd_data_base;
  12428. int val, ret;
  12429. if (!handle) {
  12430. pr_err("%s: NULL handle\n", __func__);
  12431. return -EINVAL;
  12432. }
  12433. tasha = (struct tasha_priv *)handle;
  12434. wcd9xxx = tasha->wcd9xxx;
  12435. dev_dbg(tasha->dev, "%s: Reading soundwire register, 0x%x\n",
  12436. __func__, reg);
  12437. swr_rd_addr_base = WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0;
  12438. swr_rd_data_base = WCD9335_SWR_AHB_BRIDGE_RD_DATA_0;
  12439. /* read_lock */
  12440. mutex_lock(&tasha->swr_read_lock);
  12441. ret = regmap_bulk_write(wcd9xxx->regmap, swr_rd_addr_base,
  12442. (u8 *)&reg, 4);
  12443. if (ret < 0) {
  12444. pr_err("%s: RD Addr Failure\n", __func__);
  12445. goto err;
  12446. }
  12447. /* Check for RD status */
  12448. ret = regmap_bulk_read(wcd9xxx->regmap, swr_rd_data_base,
  12449. (u8 *)&val, 4);
  12450. if (ret < 0) {
  12451. pr_err("%s: RD Data Failure\n", __func__);
  12452. goto err;
  12453. }
  12454. ret = val;
  12455. err:
  12456. /* read_unlock */
  12457. mutex_unlock(&tasha->swr_read_lock);
  12458. return ret;
  12459. }
  12460. static int tasha_swrm_i2s_bulk_write(struct wcd9xxx *wcd9xxx,
  12461. struct wcd9xxx_reg_val *bulk_reg,
  12462. size_t len)
  12463. {
  12464. int i, ret = 0;
  12465. unsigned short swr_wr_addr_base;
  12466. unsigned short swr_wr_data_base;
  12467. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12468. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12469. for (i = 0; i < (len * 2); i += 2) {
  12470. /* First Write the Data to register */
  12471. ret = regmap_bulk_write(wcd9xxx->regmap,
  12472. swr_wr_data_base, bulk_reg[i].buf, 4);
  12473. if (ret < 0) {
  12474. dev_err(wcd9xxx->dev, "%s: WR Data Failure\n",
  12475. __func__);
  12476. break;
  12477. }
  12478. /* Next Write Address */
  12479. ret = regmap_bulk_write(wcd9xxx->regmap,
  12480. swr_wr_addr_base, bulk_reg[i+1].buf, 4);
  12481. if (ret < 0) {
  12482. dev_err(wcd9xxx->dev, "%s: WR Addr Failure\n",
  12483. __func__);
  12484. break;
  12485. }
  12486. }
  12487. return ret;
  12488. }
  12489. static int tasha_swrm_bulk_write(void *handle, u32 *reg, u32 *val, size_t len)
  12490. {
  12491. struct tasha_priv *tasha;
  12492. struct wcd9xxx *wcd9xxx;
  12493. struct wcd9xxx_reg_val *bulk_reg;
  12494. unsigned short swr_wr_addr_base;
  12495. unsigned short swr_wr_data_base;
  12496. int i, j, ret;
  12497. if (!handle) {
  12498. pr_err("%s: NULL handle\n", __func__);
  12499. return -EINVAL;
  12500. }
  12501. if (len <= 0) {
  12502. pr_err("%s: Invalid size: %zu\n", __func__, len);
  12503. return -EINVAL;
  12504. }
  12505. tasha = (struct tasha_priv *)handle;
  12506. wcd9xxx = tasha->wcd9xxx;
  12507. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12508. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12509. bulk_reg = kzalloc((2 * len * sizeof(struct wcd9xxx_reg_val)),
  12510. GFP_KERNEL);
  12511. if (!bulk_reg)
  12512. return -ENOMEM;
  12513. for (i = 0, j = 0; i < (len * 2); i += 2, j++) {
  12514. bulk_reg[i].reg = swr_wr_data_base;
  12515. bulk_reg[i].buf = (u8 *)(&val[j]);
  12516. bulk_reg[i].bytes = 4;
  12517. bulk_reg[i+1].reg = swr_wr_addr_base;
  12518. bulk_reg[i+1].buf = (u8 *)(&reg[j]);
  12519. bulk_reg[i+1].bytes = 4;
  12520. }
  12521. mutex_lock(&tasha->swr_write_lock);
  12522. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12523. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, len);
  12524. if (ret) {
  12525. dev_err(tasha->dev, "%s: i2s bulk write failed, ret: %d\n",
  12526. __func__, ret);
  12527. }
  12528. } else {
  12529. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg,
  12530. (len * 2), false);
  12531. if (ret) {
  12532. dev_err(tasha->dev, "%s: swrm bulk write failed, ret: %d\n",
  12533. __func__, ret);
  12534. }
  12535. }
  12536. mutex_unlock(&tasha->swr_write_lock);
  12537. kfree(bulk_reg);
  12538. return ret;
  12539. }
  12540. static int tasha_swrm_write(void *handle, int reg, int val)
  12541. {
  12542. struct tasha_priv *tasha;
  12543. struct wcd9xxx *wcd9xxx;
  12544. unsigned short swr_wr_addr_base;
  12545. unsigned short swr_wr_data_base;
  12546. struct wcd9xxx_reg_val bulk_reg[2];
  12547. int ret;
  12548. if (!handle) {
  12549. pr_err("%s: NULL handle\n", __func__);
  12550. return -EINVAL;
  12551. }
  12552. tasha = (struct tasha_priv *)handle;
  12553. wcd9xxx = tasha->wcd9xxx;
  12554. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12555. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12556. /* First Write the Data to register */
  12557. bulk_reg[0].reg = swr_wr_data_base;
  12558. bulk_reg[0].buf = (u8 *)(&val);
  12559. bulk_reg[0].bytes = 4;
  12560. bulk_reg[1].reg = swr_wr_addr_base;
  12561. bulk_reg[1].buf = (u8 *)(&reg);
  12562. bulk_reg[1].bytes = 4;
  12563. mutex_lock(&tasha->swr_write_lock);
  12564. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12565. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, 1);
  12566. if (ret) {
  12567. dev_err(tasha->dev, "%s: i2s swrm write failed, ret: %d\n",
  12568. __func__, ret);
  12569. }
  12570. } else {
  12571. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2, false);
  12572. if (ret < 0)
  12573. pr_err("%s: WR Data Failure\n", __func__);
  12574. }
  12575. mutex_unlock(&tasha->swr_write_lock);
  12576. return ret;
  12577. }
  12578. static int tasha_swrm_clock(void *handle, bool enable)
  12579. {
  12580. struct tasha_priv *tasha = (struct tasha_priv *) handle;
  12581. mutex_lock(&tasha->swr_clk_lock);
  12582. dev_dbg(tasha->dev, "%s: swrm clock %s\n",
  12583. __func__, (enable?"enable" : "disable"));
  12584. if (enable) {
  12585. tasha->swr_clk_users++;
  12586. if (tasha->swr_clk_users == 1) {
  12587. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12588. regmap_update_bits(
  12589. tasha->wcd9xxx->regmap,
  12590. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12591. 0x10, 0x00);
  12592. __tasha_cdc_mclk_enable(tasha, true);
  12593. regmap_update_bits(tasha->wcd9xxx->regmap,
  12594. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12595. 0x01, 0x01);
  12596. }
  12597. } else {
  12598. tasha->swr_clk_users--;
  12599. if (tasha->swr_clk_users == 0) {
  12600. regmap_update_bits(tasha->wcd9xxx->regmap,
  12601. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12602. 0x01, 0x00);
  12603. __tasha_cdc_mclk_enable(tasha, false);
  12604. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12605. regmap_update_bits(
  12606. tasha->wcd9xxx->regmap,
  12607. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12608. 0x10, 0x10);
  12609. }
  12610. }
  12611. dev_dbg(tasha->dev, "%s: swrm clock users %d\n",
  12612. __func__, tasha->swr_clk_users);
  12613. mutex_unlock(&tasha->swr_clk_lock);
  12614. return 0;
  12615. }
  12616. static int tasha_swrm_handle_irq(void *handle,
  12617. irqreturn_t (*swrm_irq_handler)(int irq,
  12618. void *data),
  12619. void *swrm_handle,
  12620. int action)
  12621. {
  12622. struct tasha_priv *tasha;
  12623. int ret = 0;
  12624. struct wcd9xxx *wcd9xxx;
  12625. if (!handle) {
  12626. pr_err("%s: null handle received\n", __func__);
  12627. return -EINVAL;
  12628. }
  12629. tasha = (struct tasha_priv *) handle;
  12630. wcd9xxx = tasha->wcd9xxx;
  12631. if (action) {
  12632. ret = wcd9xxx_request_irq(&wcd9xxx->core_res,
  12633. WCD9335_IRQ_SOUNDWIRE,
  12634. swrm_irq_handler,
  12635. "Tasha SWR Master", swrm_handle);
  12636. if (ret)
  12637. dev_err(tasha->dev, "%s: Failed to request irq %d\n",
  12638. __func__, WCD9335_IRQ_SOUNDWIRE);
  12639. } else
  12640. wcd9xxx_free_irq(&wcd9xxx->core_res, WCD9335_IRQ_SOUNDWIRE,
  12641. swrm_handle);
  12642. return ret;
  12643. }
  12644. static void tasha_add_child_devices(struct work_struct *work)
  12645. {
  12646. struct tasha_priv *tasha;
  12647. struct platform_device *pdev;
  12648. struct device_node *node;
  12649. struct wcd9xxx *wcd9xxx;
  12650. struct tasha_swr_ctrl_data *swr_ctrl_data = NULL, *temp;
  12651. int ret, ctrl_num = 0;
  12652. struct wcd_swr_ctrl_platform_data *platdata;
  12653. char plat_dev_name[WCD9335_STRING_LEN];
  12654. tasha = container_of(work, struct tasha_priv,
  12655. tasha_add_child_devices_work);
  12656. if (!tasha) {
  12657. pr_err("%s: Memory for WCD9335 does not exist\n",
  12658. __func__);
  12659. return;
  12660. }
  12661. wcd9xxx = tasha->wcd9xxx;
  12662. if (!wcd9xxx) {
  12663. pr_err("%s: Memory for WCD9XXX does not exist\n",
  12664. __func__);
  12665. return;
  12666. }
  12667. if (!wcd9xxx->dev->of_node) {
  12668. pr_err("%s: DT node for wcd9xxx does not exist\n",
  12669. __func__);
  12670. return;
  12671. }
  12672. platdata = &tasha->swr_plat_data;
  12673. tasha->child_count = 0;
  12674. for_each_child_of_node(wcd9xxx->dev->of_node, node) {
  12675. if (!strcmp(node->name, "swr_master"))
  12676. strlcpy(plat_dev_name, "tasha_swr_ctrl",
  12677. (WCD9335_STRING_LEN - 1));
  12678. else if (strnstr(node->name, "msm_cdc_pinctrl",
  12679. strlen("msm_cdc_pinctrl")) != NULL)
  12680. strlcpy(plat_dev_name, node->name,
  12681. (WCD9335_STRING_LEN - 1));
  12682. else
  12683. continue;
  12684. pdev = platform_device_alloc(plat_dev_name, -1);
  12685. if (!pdev) {
  12686. dev_err(wcd9xxx->dev, "%s: pdev memory alloc failed\n",
  12687. __func__);
  12688. ret = -ENOMEM;
  12689. goto err;
  12690. }
  12691. pdev->dev.parent = tasha->dev;
  12692. pdev->dev.of_node = node;
  12693. if (!strcmp(node->name, "swr_master")) {
  12694. ret = platform_device_add_data(pdev, platdata,
  12695. sizeof(*platdata));
  12696. if (ret) {
  12697. dev_err(&pdev->dev,
  12698. "%s: cannot add plat data ctrl:%d\n",
  12699. __func__, ctrl_num);
  12700. goto fail_pdev_add;
  12701. }
  12702. tasha->is_wsa_attach = true;
  12703. }
  12704. ret = platform_device_add(pdev);
  12705. if (ret) {
  12706. dev_err(&pdev->dev,
  12707. "%s: Cannot add platform device\n",
  12708. __func__);
  12709. goto fail_pdev_add;
  12710. }
  12711. if (!strcmp(node->name, "swr_master")) {
  12712. temp = krealloc(swr_ctrl_data,
  12713. (ctrl_num + 1) * sizeof(
  12714. struct tasha_swr_ctrl_data),
  12715. GFP_KERNEL);
  12716. if (!temp) {
  12717. dev_err(wcd9xxx->dev, "out of memory\n");
  12718. ret = -ENOMEM;
  12719. goto err;
  12720. }
  12721. swr_ctrl_data = temp;
  12722. swr_ctrl_data[ctrl_num].swr_pdev = pdev;
  12723. ctrl_num++;
  12724. dev_dbg(&pdev->dev,
  12725. "%s: Added soundwire ctrl device(s)\n",
  12726. __func__);
  12727. tasha->nr = ctrl_num;
  12728. tasha->swr_ctrl_data = swr_ctrl_data;
  12729. }
  12730. if (tasha->child_count < WCD9335_CHILD_DEVICES_MAX)
  12731. tasha->pdev_child_devices[tasha->child_count++] = pdev;
  12732. else
  12733. goto err;
  12734. }
  12735. return;
  12736. fail_pdev_add:
  12737. platform_device_put(pdev);
  12738. err:
  12739. return;
  12740. }
  12741. /*
  12742. * tasha_codec_ver: to get tasha codec version
  12743. * @codec: handle to snd_soc_component *
  12744. * return enum codec_variant - version
  12745. */
  12746. enum codec_variant tasha_codec_ver(void)
  12747. {
  12748. return codec_ver;
  12749. }
  12750. EXPORT_SYMBOL(tasha_codec_ver);
  12751. static int __tasha_enable_efuse_sensing(struct tasha_priv *tasha)
  12752. {
  12753. int val, rc;
  12754. __tasha_cdc_mclk_enable(tasha, true);
  12755. regmap_update_bits(tasha->wcd9xxx->regmap,
  12756. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x1E, 0x20);
  12757. regmap_update_bits(tasha->wcd9xxx->regmap,
  12758. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x01, 0x01);
  12759. /*
  12760. * 5ms sleep required after enabling efuse control
  12761. * before checking the status.
  12762. */
  12763. usleep_range(5000, 5500);
  12764. rc = regmap_read(tasha->wcd9xxx->regmap,
  12765. WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS, &val);
  12766. if (rc || (!(val & 0x01)))
  12767. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  12768. __tasha_cdc_mclk_enable(tasha, false);
  12769. return rc;
  12770. }
  12771. void tasha_get_codec_ver(struct tasha_priv *tasha)
  12772. {
  12773. int i;
  12774. int val;
  12775. struct tasha_reg_mask_val codec_reg[] = {
  12776. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10, 0xFF, 0xFF},
  12777. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11, 0xFF, 0x83},
  12778. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12, 0xFF, 0x0A},
  12779. };
  12780. __tasha_enable_efuse_sensing(tasha);
  12781. for (i = 0; i < ARRAY_SIZE(codec_reg); i++) {
  12782. regmap_read(tasha->wcd9xxx->regmap, codec_reg[i].reg, &val);
  12783. if (!(val && codec_reg[i].val)) {
  12784. codec_ver = WCD9335;
  12785. goto ret;
  12786. }
  12787. }
  12788. codec_ver = WCD9326;
  12789. ret:
  12790. pr_debug("%s: codec is %d\n", __func__, codec_ver);
  12791. }
  12792. EXPORT_SYMBOL(tasha_get_codec_ver);
  12793. static int tasha_probe(struct platform_device *pdev)
  12794. {
  12795. int ret = 0;
  12796. struct tasha_priv *tasha;
  12797. struct clk *wcd_ext_clk, *wcd_native_clk;
  12798. struct wcd9xxx_resmgr_v2 *resmgr;
  12799. struct wcd9xxx_power_region *cdc_pwr;
  12800. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12801. if (apr_get_subsys_state() == APR_SUBSYS_DOWN) {
  12802. dev_err(&pdev->dev, "%s: dsp down\n", __func__);
  12803. return -EPROBE_DEFER;
  12804. }
  12805. }
  12806. tasha = devm_kzalloc(&pdev->dev, sizeof(struct tasha_priv),
  12807. GFP_KERNEL);
  12808. if (!tasha)
  12809. return -ENOMEM;
  12810. platform_set_drvdata(pdev, tasha);
  12811. tasha->wcd9xxx = dev_get_drvdata(pdev->dev.parent);
  12812. tasha->dev = &pdev->dev;
  12813. INIT_DELAYED_WORK(&tasha->power_gate_work, tasha_codec_power_gate_work);
  12814. mutex_init(&tasha->power_lock);
  12815. mutex_init(&tasha->sido_lock);
  12816. INIT_WORK(&tasha->tasha_add_child_devices_work,
  12817. tasha_add_child_devices);
  12818. BLOCKING_INIT_NOTIFIER_HEAD(&tasha->notifier);
  12819. mutex_init(&tasha->micb_lock);
  12820. mutex_init(&tasha->swr_read_lock);
  12821. mutex_init(&tasha->swr_write_lock);
  12822. mutex_init(&tasha->swr_clk_lock);
  12823. mutex_init(&tasha->sb_clk_gear_lock);
  12824. mutex_init(&tasha->mclk_lock);
  12825. cdc_pwr = devm_kzalloc(&pdev->dev, sizeof(struct wcd9xxx_power_region),
  12826. GFP_KERNEL);
  12827. if (!cdc_pwr) {
  12828. ret = -ENOMEM;
  12829. goto err_cdc_pwr;
  12830. }
  12831. tasha->wcd9xxx->wcd9xxx_pwr[WCD9XXX_DIG_CORE_REGION_1] = cdc_pwr;
  12832. cdc_pwr->pwr_collapse_reg_min = TASHA_DIG_CORE_REG_MIN;
  12833. cdc_pwr->pwr_collapse_reg_max = TASHA_DIG_CORE_REG_MAX;
  12834. wcd9xxx_set_power_state(tasha->wcd9xxx,
  12835. WCD_REGION_POWER_COLLAPSE_REMOVE,
  12836. WCD9XXX_DIG_CORE_REGION_1);
  12837. mutex_init(&tasha->codec_mutex);
  12838. /*
  12839. * Init resource manager so that if child nodes such as SoundWire
  12840. * requests for clock, resource manager can honor the request
  12841. */
  12842. resmgr = wcd_resmgr_init(&tasha->wcd9xxx->core_res, NULL);
  12843. if (IS_ERR(resmgr)) {
  12844. ret = PTR_ERR(resmgr);
  12845. dev_err(&pdev->dev, "%s: Failed to initialize wcd resmgr\n",
  12846. __func__);
  12847. goto err_resmgr;
  12848. }
  12849. tasha->resmgr = resmgr;
  12850. tasha->swr_plat_data.handle = (void *) tasha;
  12851. tasha->swr_plat_data.read = tasha_swrm_read;
  12852. tasha->swr_plat_data.write = tasha_swrm_write;
  12853. tasha->swr_plat_data.bulk_write = tasha_swrm_bulk_write;
  12854. tasha->swr_plat_data.clk = tasha_swrm_clock;
  12855. tasha->swr_plat_data.handle_irq = tasha_swrm_handle_irq;
  12856. /* Register for Clock */
  12857. wcd_ext_clk = clk_get(tasha->wcd9xxx->dev, "wcd_clk");
  12858. if (IS_ERR(wcd_ext_clk)) {
  12859. dev_err(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12860. __func__, "wcd_ext_clk");
  12861. goto err_clk;
  12862. }
  12863. tasha->wcd_ext_clk = wcd_ext_clk;
  12864. tasha->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV;
  12865. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  12866. tasha->sido_ccl_cnt = 0;
  12867. /* Register native clk for 44.1 playback */
  12868. wcd_native_clk = clk_get(tasha->wcd9xxx->dev, "wcd_native_clk");
  12869. if (IS_ERR(wcd_native_clk))
  12870. dev_dbg(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12871. __func__, "wcd_native_clk");
  12872. else
  12873. tasha->wcd_native_clk = wcd_native_clk;
  12874. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  12875. ret = snd_soc_register_component(&pdev->dev,
  12876. &soc_codec_dev_tasha,
  12877. tasha_dai, ARRAY_SIZE(tasha_dai));
  12878. else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
  12879. ret = snd_soc_register_component(&pdev->dev,
  12880. &soc_codec_dev_tasha,
  12881. tasha_i2s_dai,
  12882. ARRAY_SIZE(tasha_i2s_dai));
  12883. else
  12884. ret = -EINVAL;
  12885. if (ret) {
  12886. dev_err(&pdev->dev, "%s: Codec registration failed, ret = %d\n",
  12887. __func__, ret);
  12888. goto err_cdc_reg;
  12889. }
  12890. /* Update codec register default values */
  12891. tasha_update_reg_defaults(tasha);
  12892. schedule_work(&tasha->tasha_add_child_devices_work);
  12893. tasha_get_codec_ver(tasha);
  12894. dev_info(&pdev->dev, "%s: Tasha driver probe done\n", __func__);
  12895. return ret;
  12896. err_cdc_reg:
  12897. clk_put(tasha->wcd_ext_clk);
  12898. if (tasha->wcd_native_clk)
  12899. clk_put(tasha->wcd_native_clk);
  12900. err_clk:
  12901. wcd_resmgr_remove(tasha->resmgr);
  12902. err_resmgr:
  12903. devm_kfree(&pdev->dev, cdc_pwr);
  12904. err_cdc_pwr:
  12905. mutex_destroy(&tasha->mclk_lock);
  12906. devm_kfree(&pdev->dev, tasha);
  12907. return ret;
  12908. }
  12909. static int tasha_remove(struct platform_device *pdev)
  12910. {
  12911. struct tasha_priv *tasha;
  12912. int count = 0;
  12913. tasha = platform_get_drvdata(pdev);
  12914. if (!tasha)
  12915. return -EINVAL;
  12916. for (count = 0; count < tasha->child_count &&
  12917. count < WCD9335_CHILD_DEVICES_MAX; count++)
  12918. platform_device_unregister(tasha->pdev_child_devices[count]);
  12919. mutex_destroy(&tasha->codec_mutex);
  12920. clk_put(tasha->wcd_ext_clk);
  12921. if (tasha->wcd_native_clk)
  12922. clk_put(tasha->wcd_native_clk);
  12923. mutex_destroy(&tasha->mclk_lock);
  12924. mutex_destroy(&tasha->sb_clk_gear_lock);
  12925. snd_soc_unregister_component(&pdev->dev);
  12926. devm_kfree(&pdev->dev, tasha);
  12927. return 0;
  12928. }
  12929. static struct platform_driver tasha_codec_driver = {
  12930. .probe = tasha_probe,
  12931. .remove = tasha_remove,
  12932. .driver = {
  12933. .name = "tasha_codec",
  12934. .owner = THIS_MODULE,
  12935. #ifdef CONFIG_PM
  12936. .pm = &tasha_pm_ops,
  12937. #endif
  12938. },
  12939. };
  12940. module_platform_driver(tasha_codec_driver);
  12941. MODULE_DESCRIPTION("Tasha Codec driver");
  12942. MODULE_LICENSE("GPL v2");