wcd9335.c 436 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234
  1. /*
  2. * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/init.h>
  15. #include <linux/firmware.h>
  16. #include <linux/slab.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/device.h>
  19. #include <linux/printk.h>
  20. #include <linux/ratelimit.h>
  21. #include <linux/debugfs.h>
  22. #include <linux/wait.h>
  23. #include <linux/bitops.h>
  24. #include <linux/regmap.h>
  25. #include <linux/regulator/consumer.h>
  26. #include <linux/clk.h>
  27. #include <linux/delay.h>
  28. #include <linux/pm_runtime.h>
  29. #include <linux/kernel.h>
  30. #include <linux/gpio.h>
  31. #include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
  32. #include <soc/swr-wcd.h>
  33. #include <sound/pcm.h>
  34. #include <sound/pcm_params.h>
  35. #include <sound/soc.h>
  36. #include <sound/soc-dapm.h>
  37. #include <sound/tlv.h>
  38. #include <sound/info.h>
  39. #include "core.h"
  40. #include "pdata.h"
  41. #include "wcd9335.h"
  42. #include "wcd-mbhc-v2.h"
  43. #include "wcd9xxx-common-v2.h"
  44. #include "wcd9xxx-resmgr-v2.h"
  45. #include "wcd9xxx-irq.h"
  46. #include "wcd9335_registers.h"
  47. #include "wcd9335_irq.h"
  48. #include "wcd_cpe_core.h"
  49. #include "wcdcal-hwdep.h"
  50. #include "wcd-mbhc-v2-api.h"
  51. #define TASHA_RX_PORT_START_NUMBER 16
  52. #define WCD9335_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
  53. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
  54. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  55. /* Fractional Rates */
  56. #define WCD9335_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100)
  57. #define WCD9335_MIX_RATES_MASK (SNDRV_PCM_RATE_48000 |\
  58. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  59. #define TASHA_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  60. SNDRV_PCM_FMTBIT_S24_LE | \
  61. SNDRV_PCM_FMTBIT_S24_3LE)
  62. #define TASHA_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  63. SNDRV_PCM_FMTBIT_S24_LE | \
  64. SNDRV_PCM_FMTBIT_S24_3LE | \
  65. SNDRV_PCM_FMTBIT_S32_LE)
  66. #define TASHA_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
  67. /*
  68. * Timeout in milli seconds and it is the wait time for
  69. * slim channel removal interrupt to receive.
  70. */
  71. #define TASHA_SLIM_CLOSE_TIMEOUT 1000
  72. #define TASHA_SLIM_IRQ_OVERFLOW (1 << 0)
  73. #define TASHA_SLIM_IRQ_UNDERFLOW (1 << 1)
  74. #define TASHA_SLIM_IRQ_PORT_CLOSED (1 << 2)
  75. #define TASHA_MCLK_CLK_12P288MHZ 12288000
  76. #define TASHA_MCLK_CLK_9P6MHZ 9600000
  77. #define TASHA_SLIM_PGD_PORT_INT_TX_EN0 (TASHA_SLIM_PGD_PORT_INT_EN0 + 2)
  78. #define TASHA_NUM_INTERPOLATORS 9
  79. #define TASHA_NUM_DECIMATORS 9
  80. #define WCD9335_CHILD_DEVICES_MAX 6
  81. #define BYTE_BIT_MASK(nr) (1 << ((nr) % BITS_PER_BYTE))
  82. #define TASHA_MAD_AUDIO_FIRMWARE_PATH "wcd9335/wcd9335_mad_audio.bin"
  83. #define TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS (1 << 0)
  84. #define TASHA_CPE_SS_ERR_STATUS_WDOG_BITE (1 << 1)
  85. #define TASHA_CPE_FATAL_IRQS \
  86. (TASHA_CPE_SS_ERR_STATUS_WDOG_BITE | \
  87. TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS)
  88. #define SLIM_BW_CLK_GEAR_9 6200000
  89. #define SLIM_BW_UNVOTE 0
  90. #define CPE_FLL_CLK_75MHZ 75000000
  91. #define CPE_FLL_CLK_150MHZ 150000000
  92. #define WCD9335_REG_BITS 8
  93. #define WCD9335_MAX_VALID_ADC_MUX 13
  94. #define WCD9335_INVALID_ADC_MUX 9
  95. #define TASHA_DIG_CORE_REG_MIN WCD9335_CDC_ANC0_CLK_RESET_CTL
  96. #define TASHA_DIG_CORE_REG_MAX 0xDFF
  97. /* Convert from vout ctl to micbias voltage in mV */
  98. #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
  99. #define TASHA_ZDET_NUM_MEASUREMENTS 900
  100. #define TASHA_MBHC_GET_C1(c) ((c & 0xC000) >> 14)
  101. #define TASHA_MBHC_GET_X1(x) (x & 0x3FFF)
  102. /* z value compared in milliOhm */
  103. #define TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000))
  104. #define TASHA_MBHC_ZDET_CONST (86 * 16384)
  105. #define TASHA_MBHC_MOISTURE_VREF V_45_MV
  106. #define TASHA_MBHC_MOISTURE_IREF I_3P0_UA
  107. #define TASHA_VERSION_ENTRY_SIZE 17
  108. #define WCD9335_AMIC_PWR_LEVEL_LP 0
  109. #define WCD9335_AMIC_PWR_LEVEL_DEFAULT 1
  110. #define WCD9335_AMIC_PWR_LEVEL_HP 2
  111. #define WCD9335_AMIC_PWR_LVL_MASK 0x60
  112. #define WCD9335_AMIC_PWR_LVL_SHIFT 0x5
  113. #define WCD9335_DEC_PWR_LVL_MASK 0x06
  114. #define WCD9335_DEC_PWR_LVL_LP 0x02
  115. #define WCD9335_DEC_PWR_LVL_HP 0x04
  116. #define WCD9335_DEC_PWR_LVL_DF 0x00
  117. #define WCD9335_STRING_LEN 100
  118. #define CALCULATE_VOUT_D(req_mv) (((req_mv - 650) * 10) / 25)
  119. static int cpe_debug_mode;
  120. #define TASHA_MAX_MICBIAS 4
  121. #define DAPM_MICBIAS1_STANDALONE "MIC BIAS1 Standalone"
  122. #define DAPM_MICBIAS2_STANDALONE "MIC BIAS2 Standalone"
  123. #define DAPM_MICBIAS3_STANDALONE "MIC BIAS3 Standalone"
  124. #define DAPM_MICBIAS4_STANDALONE "MIC BIAS4 Standalone"
  125. #define DAPM_LDO_H_STANDALONE "LDO_H"
  126. module_param(cpe_debug_mode, int, 0664);
  127. MODULE_PARM_DESC(cpe_debug_mode, "boot cpe in debug mode");
  128. #define TASHA_DIG_CORE_COLLAPSE_TIMER_MS (5 * 1000)
  129. #define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH 64
  130. static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = {
  131. "cdc-vdd-mic-bias",
  132. };
  133. enum {
  134. POWER_COLLAPSE,
  135. POWER_RESUME,
  136. };
  137. enum tasha_sido_voltage {
  138. SIDO_VOLTAGE_SVS_MV = 950,
  139. SIDO_VOLTAGE_NOMINAL_MV = 1100,
  140. };
  141. static enum codec_variant codec_ver;
  142. static int dig_core_collapse_enable = 1;
  143. module_param(dig_core_collapse_enable, int, 0664);
  144. MODULE_PARM_DESC(dig_core_collapse_enable, "enable/disable power gating");
  145. /* dig_core_collapse timer in seconds */
  146. static int dig_core_collapse_timer = (TASHA_DIG_CORE_COLLAPSE_TIMER_MS/1000);
  147. module_param(dig_core_collapse_timer, int, 0664);
  148. MODULE_PARM_DESC(dig_core_collapse_timer, "timer for power gating");
  149. /* SVS Scaling enable/disable */
  150. static int svs_scaling_enabled = 1;
  151. module_param(svs_scaling_enabled, int, 0664);
  152. MODULE_PARM_DESC(svs_scaling_enabled, "enable/disable svs scaling");
  153. /* SVS buck setting */
  154. static int sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  155. module_param(sido_buck_svs_voltage, int, 0664);
  156. MODULE_PARM_DESC(sido_buck_svs_voltage,
  157. "setting for SVS voltage for SIDO BUCK");
  158. #define TASHA_TX_UNMUTE_DELAY_MS 40
  159. static int tx_unmute_delay = TASHA_TX_UNMUTE_DELAY_MS;
  160. module_param(tx_unmute_delay, int, 0664);
  161. MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path");
  162. static struct afe_param_slimbus_slave_port_cfg tasha_slimbus_slave_port_cfg = {
  163. .minor_version = 1,
  164. .slimbus_dev_id = AFE_SLIMBUS_DEVICE_1,
  165. .slave_dev_pgd_la = 0,
  166. .slave_dev_intfdev_la = 0,
  167. .bit_width = 16,
  168. .data_format = 0,
  169. .num_channels = 1
  170. };
  171. struct tasha_mbhc_zdet_param {
  172. u16 ldo_ctl;
  173. u16 noff;
  174. u16 nshift;
  175. u16 btn5;
  176. u16 btn6;
  177. u16 btn7;
  178. };
  179. static struct afe_param_cdc_reg_page_cfg tasha_cdc_reg_page_cfg = {
  180. .minor_version = AFE_API_VERSION_CDC_REG_PAGE_CFG,
  181. .enable = 1,
  182. .proc_id = AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_1,
  183. };
  184. static struct afe_param_cdc_reg_cfg audio_reg_cfg[] = {
  185. {
  186. 1,
  187. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_MAIN_CTL_1),
  188. HW_MAD_AUDIO_ENABLE, 0x1, WCD9335_REG_BITS, 0
  189. },
  190. {
  191. 1,
  192. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_3),
  193. HW_MAD_AUDIO_SLEEP_TIME, 0xF, WCD9335_REG_BITS, 0
  194. },
  195. {
  196. 1,
  197. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_4),
  198. HW_MAD_TX_AUDIO_SWITCH_OFF, 0x1, WCD9335_REG_BITS, 0
  199. },
  200. {
  201. 1,
  202. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  203. MAD_AUDIO_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  204. },
  205. {
  206. 1,
  207. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  208. MAD_AUDIO_INT_MASK_REG, 0x1, WCD9335_REG_BITS, 0
  209. },
  210. {
  211. 1,
  212. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  213. MAD_AUDIO_INT_STATUS_REG, 0x1, WCD9335_REG_BITS, 0
  214. },
  215. {
  216. 1,
  217. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  218. MAD_AUDIO_INT_CLEAR_REG, 0x1, WCD9335_REG_BITS, 0
  219. },
  220. {
  221. 1,
  222. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  223. VBAT_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  224. },
  225. {
  226. 1,
  227. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  228. VBAT_INT_MASK_REG, 0x08, WCD9335_REG_BITS, 0
  229. },
  230. {
  231. 1,
  232. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  233. VBAT_INT_STATUS_REG, 0x08, WCD9335_REG_BITS, 0
  234. },
  235. {
  236. 1,
  237. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  238. VBAT_INT_CLEAR_REG, 0x08, WCD9335_REG_BITS, 0
  239. },
  240. {
  241. 1,
  242. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  243. VBAT_RELEASE_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  244. },
  245. {
  246. 1,
  247. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  248. VBAT_RELEASE_INT_MASK_REG, 0x10, WCD9335_REG_BITS, 0
  249. },
  250. {
  251. 1,
  252. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  253. VBAT_RELEASE_INT_STATUS_REG, 0x10, WCD9335_REG_BITS, 0
  254. },
  255. {
  256. 1,
  257. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  258. VBAT_RELEASE_INT_CLEAR_REG, 0x10, WCD9335_REG_BITS, 0
  259. },
  260. {
  261. 1,
  262. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  263. SB_PGD_PORT_TX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  264. },
  265. {
  266. 1,
  267. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  268. SB_PGD_PORT_TX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  269. },
  270. {
  271. 1,
  272. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  273. SB_PGD_PORT_RX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  274. },
  275. {
  276. 1,
  277. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  278. SB_PGD_PORT_RX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  279. },
  280. { 1,
  281. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  282. AANC_FF_GAIN_ADAPTIVE, 0x4, WCD9335_REG_BITS, 0
  283. },
  284. { 1,
  285. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  286. AANC_FFGAIN_ADAPTIVE_EN, 0x8, WCD9335_REG_BITS, 0
  287. },
  288. {
  289. 1,
  290. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_FF_A_GAIN_CTL),
  291. AANC_GAIN_CONTROL, 0xFF, WCD9335_REG_BITS, 0
  292. },
  293. };
  294. static struct afe_param_cdc_reg_cfg_data tasha_audio_reg_cfg = {
  295. .num_registers = ARRAY_SIZE(audio_reg_cfg),
  296. .reg_data = audio_reg_cfg,
  297. };
  298. static struct afe_param_id_cdc_aanc_version tasha_cdc_aanc_version = {
  299. .cdc_aanc_minor_version = AFE_API_VERSION_CDC_AANC_VERSION,
  300. .aanc_hw_version = AANC_HW_BLOCK_VERSION_2,
  301. };
  302. enum {
  303. VI_SENSE_1,
  304. VI_SENSE_2,
  305. AIF4_SWITCH_VALUE,
  306. AUDIO_NOMINAL,
  307. CPE_NOMINAL,
  308. HPH_PA_DELAY,
  309. ANC_MIC_AMIC1,
  310. ANC_MIC_AMIC2,
  311. ANC_MIC_AMIC3,
  312. ANC_MIC_AMIC4,
  313. ANC_MIC_AMIC5,
  314. ANC_MIC_AMIC6,
  315. CLASSH_CONFIG,
  316. };
  317. enum {
  318. AIF1_PB = 0,
  319. AIF1_CAP,
  320. AIF2_PB,
  321. AIF2_CAP,
  322. AIF3_PB,
  323. AIF3_CAP,
  324. AIF4_PB,
  325. AIF_MIX1_PB,
  326. AIF4_MAD_TX,
  327. AIF4_VIFEED,
  328. AIF5_CPE_TX,
  329. NUM_CODEC_DAIS,
  330. };
  331. enum {
  332. INTn_1_MIX_INP_SEL_ZERO = 0,
  333. INTn_1_MIX_INP_SEL_DEC0,
  334. INTn_1_MIX_INP_SEL_DEC1,
  335. INTn_1_MIX_INP_SEL_IIR0,
  336. INTn_1_MIX_INP_SEL_IIR1,
  337. INTn_1_MIX_INP_SEL_RX0,
  338. INTn_1_MIX_INP_SEL_RX1,
  339. INTn_1_MIX_INP_SEL_RX2,
  340. INTn_1_MIX_INP_SEL_RX3,
  341. INTn_1_MIX_INP_SEL_RX4,
  342. INTn_1_MIX_INP_SEL_RX5,
  343. INTn_1_MIX_INP_SEL_RX6,
  344. INTn_1_MIX_INP_SEL_RX7,
  345. };
  346. #define IS_VALID_NATIVE_FIFO_PORT(inp) \
  347. ((inp >= INTn_1_MIX_INP_SEL_RX0) && \
  348. (inp <= INTn_1_MIX_INP_SEL_RX3))
  349. enum {
  350. INTn_2_INP_SEL_ZERO = 0,
  351. INTn_2_INP_SEL_RX0,
  352. INTn_2_INP_SEL_RX1,
  353. INTn_2_INP_SEL_RX2,
  354. INTn_2_INP_SEL_RX3,
  355. INTn_2_INP_SEL_RX4,
  356. INTn_2_INP_SEL_RX5,
  357. INTn_2_INP_SEL_RX6,
  358. INTn_2_INP_SEL_RX7,
  359. INTn_2_INP_SEL_PROXIMITY,
  360. };
  361. enum {
  362. INTERP_EAR = 0,
  363. INTERP_HPHL,
  364. INTERP_HPHR,
  365. INTERP_LO1,
  366. INTERP_LO2,
  367. INTERP_LO3,
  368. INTERP_LO4,
  369. INTERP_SPKR1,
  370. INTERP_SPKR2,
  371. };
  372. struct interp_sample_rate {
  373. int sample_rate;
  374. int rate_val;
  375. };
  376. static struct interp_sample_rate int_prim_sample_rate_val[] = {
  377. {8000, 0x0}, /* 8K */
  378. {16000, 0x1}, /* 16K */
  379. {24000, -EINVAL},/* 24K */
  380. {32000, 0x3}, /* 32K */
  381. {48000, 0x4}, /* 48K */
  382. {96000, 0x5}, /* 96K */
  383. {192000, 0x6}, /* 192K */
  384. {384000, 0x7}, /* 384K */
  385. {44100, 0x8}, /* 44.1K */
  386. };
  387. static struct interp_sample_rate int_mix_sample_rate_val[] = {
  388. {48000, 0x4}, /* 48K */
  389. {96000, 0x5}, /* 96K */
  390. {192000, 0x6}, /* 192K */
  391. };
  392. static const struct wcd9xxx_ch tasha_rx_chs[TASHA_RX_MAX] = {
  393. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER, 0),
  394. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 1, 1),
  395. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 2, 2),
  396. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 3, 3),
  397. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 4, 4),
  398. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 5, 5),
  399. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 6, 6),
  400. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 7, 7),
  401. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 8, 8),
  402. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 9, 9),
  403. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 10, 10),
  404. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 11, 11),
  405. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 12, 12),
  406. };
  407. static const struct wcd9xxx_ch tasha_tx_chs[TASHA_TX_MAX] = {
  408. WCD9XXX_CH(0, 0),
  409. WCD9XXX_CH(1, 1),
  410. WCD9XXX_CH(2, 2),
  411. WCD9XXX_CH(3, 3),
  412. WCD9XXX_CH(4, 4),
  413. WCD9XXX_CH(5, 5),
  414. WCD9XXX_CH(6, 6),
  415. WCD9XXX_CH(7, 7),
  416. WCD9XXX_CH(8, 8),
  417. WCD9XXX_CH(9, 9),
  418. WCD9XXX_CH(10, 10),
  419. WCD9XXX_CH(11, 11),
  420. WCD9XXX_CH(12, 12),
  421. WCD9XXX_CH(13, 13),
  422. WCD9XXX_CH(14, 14),
  423. WCD9XXX_CH(15, 15),
  424. };
  425. static const u32 vport_slim_check_table[NUM_CODEC_DAIS] = {
  426. /* Needs to define in the same order of DAI enum definitions */
  427. 0,
  428. BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  429. 0,
  430. BIT(AIF1_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  431. 0,
  432. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  433. 0,
  434. 0,
  435. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF5_CPE_TX),
  436. 0,
  437. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX),
  438. };
  439. static const u32 vport_i2s_check_table[NUM_CODEC_DAIS] = {
  440. 0, /* AIF1_PB */
  441. BIT(AIF2_CAP), /* AIF1_CAP */
  442. 0, /* AIF2_PB */
  443. BIT(AIF1_CAP), /* AIF2_CAP */
  444. };
  445. /* Codec supports 2 IIR filters */
  446. enum {
  447. IIR0 = 0,
  448. IIR1,
  449. IIR_MAX,
  450. };
  451. /* Each IIR has 5 Filter Stages */
  452. enum {
  453. BAND1 = 0,
  454. BAND2,
  455. BAND3,
  456. BAND4,
  457. BAND5,
  458. BAND_MAX,
  459. };
  460. enum {
  461. COMPANDER_1, /* HPH_L */
  462. COMPANDER_2, /* HPH_R */
  463. COMPANDER_3, /* LO1_DIFF */
  464. COMPANDER_4, /* LO2_DIFF */
  465. COMPANDER_5, /* LO3_SE */
  466. COMPANDER_6, /* LO4_SE */
  467. COMPANDER_7, /* SWR SPK CH1 */
  468. COMPANDER_8, /* SWR SPK CH2 */
  469. COMPANDER_MAX,
  470. };
  471. enum {
  472. SRC_IN_HPHL,
  473. SRC_IN_LO1,
  474. SRC_IN_HPHR,
  475. SRC_IN_LO2,
  476. SRC_IN_SPKRL,
  477. SRC_IN_LO3,
  478. SRC_IN_SPKRR,
  479. SRC_IN_LO4,
  480. };
  481. enum {
  482. SPLINE_SRC0,
  483. SPLINE_SRC1,
  484. SPLINE_SRC2,
  485. SPLINE_SRC3,
  486. SPLINE_SRC_MAX,
  487. };
  488. static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
  489. static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
  490. static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
  491. static struct snd_soc_dai_driver tasha_dai[];
  492. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv);
  493. static int tasha_config_compander(struct snd_soc_codec *, int, int);
  494. static void tasha_codec_set_tx_hold(struct snd_soc_codec *, u16, bool);
  495. static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
  496. bool enable);
  497. /* Hold instance to soundwire platform device */
  498. struct tasha_swr_ctrl_data {
  499. struct platform_device *swr_pdev;
  500. struct ida swr_ida;
  501. };
  502. struct wcd_swr_ctrl_platform_data {
  503. void *handle; /* holds codec private data */
  504. int (*read)(void *handle, int reg);
  505. int (*write)(void *handle, int reg, int val);
  506. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  507. int (*clk)(void *handle, bool enable);
  508. int (*handle_irq)(void *handle,
  509. irqreturn_t (*swrm_irq_handler)(int irq,
  510. void *data),
  511. void *swrm_handle,
  512. int action);
  513. };
  514. static struct wcd_mbhc_register
  515. wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = {
  516. WCD_MBHC_REGISTER("WCD_MBHC_L_DET_EN",
  517. WCD9335_ANA_MBHC_MECH, 0x80, 7, 0),
  518. WCD_MBHC_REGISTER("WCD_MBHC_GND_DET_EN",
  519. WCD9335_ANA_MBHC_MECH, 0x40, 6, 0),
  520. WCD_MBHC_REGISTER("WCD_MBHC_MECH_DETECTION_TYPE",
  521. WCD9335_ANA_MBHC_MECH, 0x20, 5, 0),
  522. WCD_MBHC_REGISTER("WCD_MBHC_MIC_CLAMP_CTL",
  523. WCD9335_MBHC_PLUG_DETECT_CTL, 0x30, 4, 0),
  524. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_DETECTION_TYPE",
  525. WCD9335_ANA_MBHC_ELECT, 0x08, 3, 0),
  526. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_CTRL",
  527. WCD9335_MBHC_PLUG_DETECT_CTL, 0xC0, 6, 0),
  528. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL",
  529. WCD9335_ANA_MBHC_MECH, 0x04, 2, 0),
  530. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PLUG_TYPE",
  531. WCD9335_ANA_MBHC_MECH, 0x10, 4, 0),
  532. WCD_MBHC_REGISTER("WCD_MBHC_GND_PLUG_TYPE",
  533. WCD9335_ANA_MBHC_MECH, 0x08, 3, 0),
  534. WCD_MBHC_REGISTER("WCD_MBHC_SW_HPH_LP_100K_TO_GND",
  535. WCD9335_ANA_MBHC_MECH, 0x01, 0, 0),
  536. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_SCHMT_ISRC",
  537. WCD9335_ANA_MBHC_ELECT, 0x06, 1, 0),
  538. WCD_MBHC_REGISTER("WCD_MBHC_FSM_EN",
  539. WCD9335_ANA_MBHC_ELECT, 0x80, 7, 0),
  540. WCD_MBHC_REGISTER("WCD_MBHC_INSREM_DBNC",
  541. WCD9335_MBHC_PLUG_DETECT_CTL, 0x0F, 0, 0),
  542. WCD_MBHC_REGISTER("WCD_MBHC_BTN_DBNC",
  543. WCD9335_MBHC_CTL_1, 0x03, 0, 0),
  544. WCD_MBHC_REGISTER("WCD_MBHC_HS_VREF",
  545. WCD9335_MBHC_CTL_2, 0x03, 0, 0),
  546. WCD_MBHC_REGISTER("WCD_MBHC_HS_COMP_RESULT",
  547. WCD9335_ANA_MBHC_RESULT_3, 0x08, 3, 0),
  548. WCD_MBHC_REGISTER("WCD_MBHC_MIC_SCHMT_RESULT",
  549. WCD9335_ANA_MBHC_RESULT_3, 0x20, 5, 0),
  550. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_SCHMT_RESULT",
  551. WCD9335_ANA_MBHC_RESULT_3, 0x80, 7, 0),
  552. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_SCHMT_RESULT",
  553. WCD9335_ANA_MBHC_RESULT_3, 0x40, 6, 0),
  554. WCD_MBHC_REGISTER("WCD_MBHC_OCP_FSM_EN",
  555. WCD9335_HPH_OCP_CTL, 0x10, 4, 0),
  556. WCD_MBHC_REGISTER("WCD_MBHC_BTN_RESULT",
  557. WCD9335_ANA_MBHC_RESULT_3, 0x07, 0, 0),
  558. WCD_MBHC_REGISTER("WCD_MBHC_BTN_ISRC_CTL",
  559. WCD9335_ANA_MBHC_ELECT, 0x70, 4, 0),
  560. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_RESULT",
  561. WCD9335_ANA_MBHC_RESULT_3, 0xFF, 0, 0),
  562. WCD_MBHC_REGISTER("WCD_MBHC_MICB_CTRL",
  563. WCD9335_ANA_MICB2, 0xC0, 6, 0),
  564. WCD_MBHC_REGISTER("WCD_MBHC_HPH_CNP_WG_TIME",
  565. WCD9335_HPH_CNP_WG_TIME, 0xFF, 0, 0),
  566. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_PA_EN",
  567. WCD9335_ANA_HPH, 0x40, 6, 0),
  568. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PA_EN",
  569. WCD9335_ANA_HPH, 0x80, 7, 0),
  570. WCD_MBHC_REGISTER("WCD_MBHC_HPH_PA_EN",
  571. WCD9335_ANA_HPH, 0xC0, 6, 0),
  572. WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE",
  573. WCD9335_ANA_MBHC_RESULT_3, 0x10, 4, 0),
  574. WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL",
  575. 0, 0, 0, 0),
  576. WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN",
  577. WCD9335_ANA_MBHC_ZDET, 0x01, 0, 0),
  578. /*
  579. * MBHC FSM status register is only available in Tasha 2.0.
  580. * So, init with 0 later once the version is known, then values
  581. * will be updated.
  582. */
  583. WCD_MBHC_REGISTER("WCD_MBHC_FSM_STATUS",
  584. 0, 0, 0, 0),
  585. WCD_MBHC_REGISTER("WCD_MBHC_MUX_CTL",
  586. WCD9335_MBHC_CTL_2, 0x70, 4, 0),
  587. WCD_MBHC_REGISTER("WCD_MBHC_MOISTURE_STATUS",
  588. WCD9335_MBHC_FSM_STATUS, 0X20, 5, 0),
  589. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_GND",
  590. WCD9335_HPH_PA_CTL2, 0x40, 6, 0),
  591. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_GND",
  592. WCD9335_HPH_PA_CTL2, 0x10, 4, 0),
  593. };
  594. static const struct wcd_mbhc_intr intr_ids = {
  595. .mbhc_sw_intr = WCD9335_IRQ_MBHC_SW_DET,
  596. .mbhc_btn_press_intr = WCD9335_IRQ_MBHC_BUTTON_PRESS_DET,
  597. .mbhc_btn_release_intr = WCD9335_IRQ_MBHC_BUTTON_RELEASE_DET,
  598. .mbhc_hs_ins_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
  599. .mbhc_hs_rem_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_DET,
  600. .hph_left_ocp = WCD9335_IRQ_HPH_PA_OCPL_FAULT,
  601. .hph_right_ocp = WCD9335_IRQ_HPH_PA_OCPR_FAULT,
  602. };
  603. struct wcd_vbat {
  604. bool is_enabled;
  605. bool adc_config;
  606. /* Variables to cache Vbat ADC output values */
  607. u16 dcp1;
  608. u16 dcp2;
  609. };
  610. struct hpf_work {
  611. struct tasha_priv *tasha;
  612. u8 decimator;
  613. u8 hpf_cut_off_freq;
  614. struct delayed_work dwork;
  615. };
  616. #define WCD9335_SPK_ANC_EN_DELAY_MS 350
  617. static int spk_anc_en_delay = WCD9335_SPK_ANC_EN_DELAY_MS;
  618. module_param(spk_anc_en_delay, int, 0664);
  619. MODULE_PARM_DESC(spk_anc_en_delay, "delay to enable anc in speaker path");
  620. struct spk_anc_work {
  621. struct tasha_priv *tasha;
  622. struct delayed_work dwork;
  623. };
  624. struct tx_mute_work {
  625. struct tasha_priv *tasha;
  626. u8 decimator;
  627. struct delayed_work dwork;
  628. };
  629. struct tasha_priv {
  630. struct device *dev;
  631. struct wcd9xxx *wcd9xxx;
  632. struct snd_soc_codec *codec;
  633. u32 adc_count;
  634. u32 rx_bias_count;
  635. s32 dmic_0_1_clk_cnt;
  636. s32 dmic_2_3_clk_cnt;
  637. s32 dmic_4_5_clk_cnt;
  638. s32 ldo_h_users;
  639. s32 micb_ref[TASHA_MAX_MICBIAS];
  640. s32 pullup_ref[TASHA_MAX_MICBIAS];
  641. u32 anc_slot;
  642. bool anc_func;
  643. /* Vbat module */
  644. struct wcd_vbat vbat;
  645. /* cal info for codec */
  646. struct fw_info *fw_data;
  647. /*track tasha interface type*/
  648. u8 intf_type;
  649. /* num of slim ports required */
  650. struct wcd9xxx_codec_dai_data dai[NUM_CODEC_DAIS];
  651. /* SoundWire data structure */
  652. struct tasha_swr_ctrl_data *swr_ctrl_data;
  653. int nr;
  654. /*compander*/
  655. int comp_enabled[COMPANDER_MAX];
  656. /* Maintain the status of AUX PGA */
  657. int aux_pga_cnt;
  658. u8 aux_l_gain;
  659. u8 aux_r_gain;
  660. bool spkr_pa_widget_on;
  661. struct regulator *spkdrv_reg;
  662. struct regulator *spkdrv2_reg;
  663. bool mbhc_started;
  664. /* class h specific data */
  665. struct wcd_clsh_cdc_data clsh_d;
  666. struct afe_param_cdc_slimbus_slave_cfg slimbus_slave_cfg;
  667. /*
  668. * list used to save/restore registers at start and
  669. * end of impedance measurement
  670. */
  671. struct list_head reg_save_restore;
  672. /* handle to cpe core */
  673. struct wcd_cpe_core *cpe_core;
  674. u32 current_cpe_clk_freq;
  675. enum tasha_sido_voltage sido_voltage;
  676. int sido_ccl_cnt;
  677. u32 ana_rx_supplies;
  678. /* Multiplication factor used for impedance detection */
  679. int zdet_gain_mul_fact;
  680. /* to track the status */
  681. unsigned long status_mask;
  682. struct work_struct tasha_add_child_devices_work;
  683. struct wcd_swr_ctrl_platform_data swr_plat_data;
  684. /* Port values for Rx and Tx codec_dai */
  685. unsigned int rx_port_value[TASHA_RX_MAX];
  686. unsigned int tx_port_value;
  687. unsigned int vi_feed_value;
  688. /* Tasha Interpolator Mode Select for EAR, HPH_L and HPH_R */
  689. u32 hph_mode;
  690. u16 prim_int_users[TASHA_NUM_INTERPOLATORS];
  691. int spl_src_users[SPLINE_SRC_MAX];
  692. struct wcd9xxx_resmgr_v2 *resmgr;
  693. struct delayed_work power_gate_work;
  694. struct mutex power_lock;
  695. struct mutex sido_lock;
  696. /* mbhc module */
  697. struct wcd_mbhc mbhc;
  698. struct blocking_notifier_head notifier;
  699. struct mutex micb_lock;
  700. struct clk *wcd_ext_clk;
  701. struct clk *wcd_native_clk;
  702. struct mutex swr_read_lock;
  703. struct mutex swr_write_lock;
  704. struct mutex swr_clk_lock;
  705. int swr_clk_users;
  706. int native_clk_users;
  707. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high);
  708. struct snd_info_entry *entry;
  709. struct snd_info_entry *version_entry;
  710. int power_active_ref;
  711. struct on_demand_supply on_demand_list[ON_DEMAND_SUPPLIES_MAX];
  712. int (*machine_codec_event_cb)(struct snd_soc_codec *codec,
  713. enum wcd9335_codec_event);
  714. int spkr_gain_offset;
  715. int spkr_mode;
  716. int ear_spkr_gain;
  717. struct hpf_work tx_hpf_work[TASHA_NUM_DECIMATORS];
  718. struct tx_mute_work tx_mute_dwork[TASHA_NUM_DECIMATORS];
  719. struct spk_anc_work spk_anc_dwork;
  720. struct mutex codec_mutex;
  721. int hph_l_gain;
  722. int hph_r_gain;
  723. int rx_7_count;
  724. int rx_8_count;
  725. bool clk_mode;
  726. bool clk_internal;
  727. /* Lock to prevent multiple functions voting at same time */
  728. struct mutex sb_clk_gear_lock;
  729. /* Count for functions voting or un-voting */
  730. u32 ref_count;
  731. /* Lock to protect mclk enablement */
  732. struct mutex mclk_lock;
  733. struct platform_device *pdev_child_devices
  734. [WCD9335_CHILD_DEVICES_MAX];
  735. int child_count;
  736. };
  737. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  738. bool vote);
  739. static const struct tasha_reg_mask_val tasha_spkr_default[] = {
  740. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  741. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  742. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  743. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  744. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x50},
  745. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x50},
  746. };
  747. static const struct tasha_reg_mask_val tasha_spkr_mode1[] = {
  748. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x00},
  749. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x00},
  750. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x00},
  751. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x00},
  752. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x44},
  753. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x44},
  754. };
  755. /**
  756. * tasha_set_spkr_gain_offset - offset the speaker path
  757. * gain with the given offset value.
  758. *
  759. * @codec: codec instance
  760. * @offset: Indicates speaker path gain offset value.
  761. *
  762. * Returns 0 on success or -EINVAL on error.
  763. */
  764. int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
  765. {
  766. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  767. if (!priv)
  768. return -EINVAL;
  769. priv->spkr_gain_offset = offset;
  770. return 0;
  771. }
  772. EXPORT_SYMBOL(tasha_set_spkr_gain_offset);
  773. /**
  774. * tasha_set_spkr_mode - Configures speaker compander and smartboost
  775. * settings based on speaker mode.
  776. *
  777. * @codec: codec instance
  778. * @mode: Indicates speaker configuration mode.
  779. *
  780. * Returns 0 on success or -EINVAL on error.
  781. */
  782. int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode)
  783. {
  784. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  785. int i;
  786. const struct tasha_reg_mask_val *regs;
  787. int size;
  788. if (!priv)
  789. return -EINVAL;
  790. switch (mode) {
  791. case SPKR_MODE_1:
  792. regs = tasha_spkr_mode1;
  793. size = ARRAY_SIZE(tasha_spkr_mode1);
  794. break;
  795. default:
  796. regs = tasha_spkr_default;
  797. size = ARRAY_SIZE(tasha_spkr_default);
  798. break;
  799. }
  800. priv->spkr_mode = mode;
  801. for (i = 0; i < size; i++)
  802. snd_soc_update_bits(codec, regs[i].reg,
  803. regs[i].mask, regs[i].val);
  804. return 0;
  805. }
  806. EXPORT_SYMBOL(tasha_set_spkr_mode);
  807. static void tasha_enable_sido_buck(struct snd_soc_codec *codec)
  808. {
  809. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  810. snd_soc_update_bits(codec, WCD9335_ANA_RCO, 0x80, 0x80);
  811. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x02, 0x02);
  812. /* 100us sleep needed after IREF settings */
  813. usleep_range(100, 110);
  814. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 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_codec *codec = tasha->codec;
  822. if (!codec)
  823. return;
  824. if (!TASHA_IS_2_0(tasha->wcd9xxx)) {
  825. dev_dbg(codec->dev, "%s: tasha version < 2p0, return\n",
  826. __func__);
  827. return;
  828. }
  829. dev_dbg(codec->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_update_bits(codec,
  834. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x6E);
  835. } else {
  836. if (tasha->sido_ccl_cnt == 0) {
  837. dev_dbg(codec->dev, "%s: sido_ccl already disabled\n",
  838. __func__);
  839. return;
  840. }
  841. if (--tasha->sido_ccl_cnt == 0)
  842. snd_soc_update_bits(codec,
  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_codec *codec = tasha->codec;
  895. int ret;
  896. if (!codec)
  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(codec->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(codec->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(codec->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_write(codec, WCD9335_ANA_BUCK_VOUT_D, vout_d_val & 0xFF);
  926. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x80, 0x80);
  927. /* 1 msec sleep required after SIDO Vout_D voltage change */
  928. usleep_range(1000, 1100);
  929. tasha->sido_voltage = req_mv;
  930. dev_dbg(codec->dev,
  931. "%s: updated SIDO buck Vout_D to %d, vout_d step = %u\n",
  932. __func__, tasha->sido_voltage, vout_d_val);
  933. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL,
  934. 0x80, 0x00);
  935. }
  936. static int tasha_codec_update_sido_voltage(
  937. struct tasha_priv *tasha,
  938. enum tasha_sido_voltage req_mv)
  939. {
  940. int ret = 0;
  941. if (!tasha_cdc_is_svs_enabled(tasha))
  942. return ret;
  943. mutex_lock(&tasha->sido_lock);
  944. /* enable mclk before setting SIDO voltage */
  945. ret = tasha_cdc_req_mclk_enable(tasha, true);
  946. if (ret) {
  947. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  948. __func__);
  949. goto err;
  950. }
  951. tasha_codec_apply_sido_voltage(tasha, req_mv);
  952. tasha_cdc_req_mclk_enable(tasha, false);
  953. err:
  954. mutex_unlock(&tasha->sido_lock);
  955. return ret;
  956. }
  957. int tasha_enable_efuse_sensing(struct snd_soc_codec *codec)
  958. {
  959. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  960. tasha_cdc_mclk_enable(codec, true, false);
  961. if (!TASHA_IS_2_0(priv->wcd9xxx))
  962. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  963. 0x1E, 0x02);
  964. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  965. 0x01, 0x01);
  966. /*
  967. * 5ms sleep required after enabling efuse control
  968. * before checking the status.
  969. */
  970. usleep_range(5000, 5500);
  971. if (!(snd_soc_read(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01))
  972. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  973. if (TASHA_IS_2_0(priv->wcd9xxx)) {
  974. if (!(snd_soc_read(codec,
  975. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0) & 0x40))
  976. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST,
  977. 0x04, 0x00);
  978. tasha_enable_sido_buck(codec);
  979. }
  980. tasha_cdc_mclk_enable(codec, false, false);
  981. return 0;
  982. }
  983. EXPORT_SYMBOL(tasha_enable_efuse_sensing);
  984. void *tasha_get_afe_config(struct snd_soc_codec *codec,
  985. enum afe_config_type config_type)
  986. {
  987. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  988. switch (config_type) {
  989. case AFE_SLIMBUS_SLAVE_CONFIG:
  990. return &priv->slimbus_slave_cfg;
  991. case AFE_CDC_REGISTERS_CONFIG:
  992. return &tasha_audio_reg_cfg;
  993. case AFE_SLIMBUS_SLAVE_PORT_CONFIG:
  994. return &tasha_slimbus_slave_port_cfg;
  995. case AFE_AANC_VERSION:
  996. return &tasha_cdc_aanc_version;
  997. case AFE_CLIP_BANK_SEL:
  998. return NULL;
  999. case AFE_CDC_CLIP_REGISTERS_CONFIG:
  1000. return NULL;
  1001. case AFE_CDC_REGISTER_PAGE_CONFIG:
  1002. return &tasha_cdc_reg_page_cfg;
  1003. default:
  1004. dev_err(codec->dev, "%s: Unknown config_type 0x%x\n",
  1005. __func__, config_type);
  1006. return NULL;
  1007. }
  1008. }
  1009. EXPORT_SYMBOL(tasha_get_afe_config);
  1010. /*
  1011. * tasha_event_register: Registers a machine driver callback
  1012. * function with codec private data for post ADSP sub-system
  1013. * restart (SSR). This callback function will be called from
  1014. * codec driver once codec comes out of reset after ADSP SSR.
  1015. *
  1016. * @machine_event_cb: callback function from machine driver
  1017. * @codec: Codec instance
  1018. *
  1019. * Return: none
  1020. */
  1021. void tasha_event_register(
  1022. int (*machine_event_cb)(struct snd_soc_codec *codec,
  1023. enum wcd9335_codec_event),
  1024. struct snd_soc_codec *codec)
  1025. {
  1026. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1027. if (tasha)
  1028. tasha->machine_codec_event_cb = machine_event_cb;
  1029. else
  1030. dev_dbg(codec->dev, "%s: Invalid tasha_priv data\n", __func__);
  1031. }
  1032. EXPORT_SYMBOL(tasha_event_register);
  1033. static int tasha_mbhc_request_irq(struct snd_soc_codec *codec,
  1034. int irq, irq_handler_t handler,
  1035. const char *name, void *data)
  1036. {
  1037. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1038. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1039. struct wcd9xxx_core_resource *core_res =
  1040. &wcd9xxx->core_res;
  1041. return wcd9xxx_request_irq(core_res, irq, handler, name, data);
  1042. }
  1043. static void tasha_mbhc_irq_control(struct snd_soc_codec *codec,
  1044. int irq, bool enable)
  1045. {
  1046. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1047. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1048. struct wcd9xxx_core_resource *core_res =
  1049. &wcd9xxx->core_res;
  1050. if (enable)
  1051. wcd9xxx_enable_irq(core_res, irq);
  1052. else
  1053. wcd9xxx_disable_irq(core_res, irq);
  1054. }
  1055. static int tasha_mbhc_free_irq(struct snd_soc_codec *codec,
  1056. int irq, void *data)
  1057. {
  1058. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1059. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1060. struct wcd9xxx_core_resource *core_res =
  1061. &wcd9xxx->core_res;
  1062. wcd9xxx_free_irq(core_res, irq, data);
  1063. return 0;
  1064. }
  1065. static void tasha_mbhc_clk_setup(struct snd_soc_codec *codec,
  1066. bool enable)
  1067. {
  1068. if (enable)
  1069. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1070. 0x80, 0x80);
  1071. else
  1072. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1073. 0x80, 0x00);
  1074. }
  1075. static int tasha_mbhc_btn_to_num(struct snd_soc_codec *codec)
  1076. {
  1077. return snd_soc_read(codec, WCD9335_ANA_MBHC_RESULT_3) & 0x7;
  1078. }
  1079. static void tasha_mbhc_mbhc_bias_control(struct snd_soc_codec *codec,
  1080. bool enable)
  1081. {
  1082. if (enable)
  1083. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1084. 0x01, 0x01);
  1085. else
  1086. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1087. 0x01, 0x00);
  1088. }
  1089. static void tasha_mbhc_program_btn_thr(struct snd_soc_codec *codec,
  1090. s16 *btn_low, s16 *btn_high,
  1091. int num_btn, bool is_micbias)
  1092. {
  1093. int i;
  1094. int vth;
  1095. if (num_btn > WCD_MBHC_DEF_BUTTONS) {
  1096. dev_err(codec->dev, "%s: invalid number of buttons: %d\n",
  1097. __func__, num_btn);
  1098. return;
  1099. }
  1100. /*
  1101. * Tasha just needs one set of thresholds for button detection
  1102. * due to micbias voltage ramp to pullup upon button press. So
  1103. * btn_low and is_micbias are ignored and always program button
  1104. * thresholds using btn_high.
  1105. */
  1106. for (i = 0; i < num_btn; i++) {
  1107. vth = ((btn_high[i] * 2) / 25) & 0x3F;
  1108. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN0 + i,
  1109. 0xFC, vth << 2);
  1110. dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
  1111. __func__, i, btn_high[i], vth);
  1112. }
  1113. }
  1114. static bool tasha_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
  1115. {
  1116. struct snd_soc_codec *codec = mbhc->codec;
  1117. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1118. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1119. struct wcd9xxx_core_resource *core_res =
  1120. &wcd9xxx->core_res;
  1121. if (lock)
  1122. return wcd9xxx_lock_sleep(core_res);
  1123. else {
  1124. wcd9xxx_unlock_sleep(core_res);
  1125. return 0;
  1126. }
  1127. }
  1128. static int tasha_mbhc_register_notifier(struct wcd_mbhc *mbhc,
  1129. struct notifier_block *nblock,
  1130. bool enable)
  1131. {
  1132. struct snd_soc_codec *codec = mbhc->codec;
  1133. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1134. if (enable)
  1135. return blocking_notifier_chain_register(&tasha->notifier,
  1136. nblock);
  1137. else
  1138. return blocking_notifier_chain_unregister(&tasha->notifier,
  1139. nblock);
  1140. }
  1141. static bool tasha_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
  1142. {
  1143. u8 val;
  1144. if (micb_num == MIC_BIAS_2) {
  1145. val = (snd_soc_read(mbhc->codec, WCD9335_ANA_MICB2) >> 6);
  1146. if (val == 0x01)
  1147. return true;
  1148. }
  1149. return false;
  1150. }
  1151. static bool tasha_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
  1152. {
  1153. return (snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0) ? true : false;
  1154. }
  1155. static void tasha_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec,
  1156. enum mbhc_hs_pullup_iref pull_up_cur)
  1157. {
  1158. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1159. if (!tasha)
  1160. return;
  1161. /* Default pull up current to 2uA */
  1162. if (pull_up_cur < I_OFF || pull_up_cur > I_3P0_UA ||
  1163. pull_up_cur == I_DEFAULT)
  1164. pull_up_cur = I_2P0_UA;
  1165. dev_dbg(codec->dev, "%s: HS pull up current:%d\n",
  1166. __func__, pull_up_cur);
  1167. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1168. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1169. 0xC0, pull_up_cur << 6);
  1170. else
  1171. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1172. 0xC0, 0x40);
  1173. }
  1174. static int tasha_enable_ext_mb_source(struct wcd_mbhc *mbhc,
  1175. bool turn_on)
  1176. {
  1177. struct snd_soc_codec *codec = mbhc->codec;
  1178. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1179. int ret = 0;
  1180. struct on_demand_supply *supply;
  1181. if (!tasha)
  1182. return -EINVAL;
  1183. supply = &tasha->on_demand_list[ON_DEMAND_MICBIAS];
  1184. if (!supply->supply) {
  1185. dev_dbg(codec->dev, "%s: warning supply not present ond for %s\n",
  1186. __func__, "onDemand Micbias");
  1187. return ret;
  1188. }
  1189. dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
  1190. supply->ondemand_supply_count);
  1191. if (turn_on) {
  1192. if (!(supply->ondemand_supply_count)) {
  1193. ret = snd_soc_dapm_force_enable_pin(
  1194. snd_soc_codec_get_dapm(codec),
  1195. "MICBIAS_REGULATOR");
  1196. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1197. }
  1198. supply->ondemand_supply_count++;
  1199. } else {
  1200. if (supply->ondemand_supply_count > 0)
  1201. supply->ondemand_supply_count--;
  1202. if (!(supply->ondemand_supply_count)) {
  1203. ret = snd_soc_dapm_disable_pin(
  1204. snd_soc_codec_get_dapm(codec),
  1205. "MICBIAS_REGULATOR");
  1206. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1207. }
  1208. }
  1209. if (ret)
  1210. dev_err(codec->dev, "%s: Failed to %s external micbias source\n",
  1211. __func__, turn_on ? "enable" : "disabled");
  1212. else
  1213. dev_dbg(codec->dev, "%s: %s external micbias source\n",
  1214. __func__, turn_on ? "Enabled" : "Disabled");
  1215. return ret;
  1216. }
  1217. static int tasha_micbias_control(struct snd_soc_codec *codec,
  1218. int micb_num,
  1219. int req, bool is_dapm)
  1220. {
  1221. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1222. int micb_index = micb_num - 1;
  1223. u16 micb_reg;
  1224. int pre_off_event = 0, post_off_event = 0;
  1225. int post_on_event = 0, post_dapm_off = 0;
  1226. int post_dapm_on = 0;
  1227. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  1228. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  1229. __func__, micb_index);
  1230. return -EINVAL;
  1231. }
  1232. switch (micb_num) {
  1233. case MIC_BIAS_1:
  1234. micb_reg = WCD9335_ANA_MICB1;
  1235. break;
  1236. case MIC_BIAS_2:
  1237. micb_reg = WCD9335_ANA_MICB2;
  1238. pre_off_event = WCD_EVENT_PRE_MICBIAS_2_OFF;
  1239. post_off_event = WCD_EVENT_POST_MICBIAS_2_OFF;
  1240. post_on_event = WCD_EVENT_POST_MICBIAS_2_ON;
  1241. post_dapm_on = WCD_EVENT_POST_DAPM_MICBIAS_2_ON;
  1242. post_dapm_off = WCD_EVENT_POST_DAPM_MICBIAS_2_OFF;
  1243. break;
  1244. case MIC_BIAS_3:
  1245. micb_reg = WCD9335_ANA_MICB3;
  1246. break;
  1247. case MIC_BIAS_4:
  1248. micb_reg = WCD9335_ANA_MICB4;
  1249. break;
  1250. default:
  1251. dev_err(codec->dev, "%s: Invalid micbias number: %d\n",
  1252. __func__, micb_num);
  1253. return -EINVAL;
  1254. }
  1255. mutex_lock(&tasha->micb_lock);
  1256. switch (req) {
  1257. case MICB_PULLUP_ENABLE:
  1258. tasha->pullup_ref[micb_index]++;
  1259. if ((tasha->pullup_ref[micb_index] == 1) &&
  1260. (tasha->micb_ref[micb_index] == 0))
  1261. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1262. break;
  1263. case MICB_PULLUP_DISABLE:
  1264. if (tasha->pullup_ref[micb_index] > 0)
  1265. tasha->pullup_ref[micb_index]--;
  1266. if ((tasha->pullup_ref[micb_index] == 0) &&
  1267. (tasha->micb_ref[micb_index] == 0))
  1268. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1269. break;
  1270. case MICB_ENABLE:
  1271. tasha->micb_ref[micb_index]++;
  1272. if (tasha->micb_ref[micb_index] == 1) {
  1273. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1274. if (post_on_event)
  1275. blocking_notifier_call_chain(&tasha->notifier,
  1276. post_on_event, &tasha->mbhc);
  1277. }
  1278. if (is_dapm && post_dapm_on)
  1279. blocking_notifier_call_chain(&tasha->notifier,
  1280. post_dapm_on, &tasha->mbhc);
  1281. break;
  1282. case MICB_DISABLE:
  1283. if (tasha->micb_ref[micb_index] > 0)
  1284. tasha->micb_ref[micb_index]--;
  1285. if ((tasha->micb_ref[micb_index] == 0) &&
  1286. (tasha->pullup_ref[micb_index] > 0))
  1287. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1288. else if ((tasha->micb_ref[micb_index] == 0) &&
  1289. (tasha->pullup_ref[micb_index] == 0)) {
  1290. if (pre_off_event)
  1291. blocking_notifier_call_chain(&tasha->notifier,
  1292. pre_off_event, &tasha->mbhc);
  1293. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1294. if (post_off_event)
  1295. blocking_notifier_call_chain(&tasha->notifier,
  1296. post_off_event, &tasha->mbhc);
  1297. }
  1298. if (is_dapm && post_dapm_off)
  1299. blocking_notifier_call_chain(&tasha->notifier,
  1300. post_dapm_off, &tasha->mbhc);
  1301. break;
  1302. };
  1303. dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n",
  1304. __func__, micb_num, tasha->micb_ref[micb_index],
  1305. tasha->pullup_ref[micb_index]);
  1306. mutex_unlock(&tasha->micb_lock);
  1307. return 0;
  1308. }
  1309. static int tasha_mbhc_request_micbias(struct snd_soc_codec *codec,
  1310. int micb_num, int req)
  1311. {
  1312. int ret;
  1313. /*
  1314. * If micbias is requested, make sure that there
  1315. * is vote to enable mclk
  1316. */
  1317. if (req == MICB_ENABLE)
  1318. tasha_cdc_mclk_enable(codec, true, false);
  1319. ret = tasha_micbias_control(codec, micb_num, req, false);
  1320. /*
  1321. * Release vote for mclk while requesting for
  1322. * micbias disable
  1323. */
  1324. if (req == MICB_DISABLE)
  1325. tasha_cdc_mclk_enable(codec, false, false);
  1326. return ret;
  1327. }
  1328. static void tasha_mbhc_micb_ramp_control(struct snd_soc_codec *codec,
  1329. bool enable)
  1330. {
  1331. if (enable) {
  1332. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1333. 0x1C, 0x0C);
  1334. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1335. 0x80, 0x80);
  1336. } else {
  1337. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1338. 0x80, 0x00);
  1339. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1340. 0x1C, 0x00);
  1341. }
  1342. }
  1343. static struct firmware_cal *tasha_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
  1344. enum wcd_cal_type type)
  1345. {
  1346. struct tasha_priv *tasha;
  1347. struct firmware_cal *hwdep_cal;
  1348. struct snd_soc_codec *codec = mbhc->codec;
  1349. if (!codec) {
  1350. pr_err("%s: NULL codec pointer\n", __func__);
  1351. return NULL;
  1352. }
  1353. tasha = snd_soc_codec_get_drvdata(codec);
  1354. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, type);
  1355. if (!hwdep_cal)
  1356. dev_err(codec->dev, "%s: cal not sent by %d\n",
  1357. __func__, type);
  1358. return hwdep_cal;
  1359. }
  1360. static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
  1361. int req_volt,
  1362. int micb_num)
  1363. {
  1364. int cur_vout_ctl, req_vout_ctl;
  1365. int micb_reg, micb_val, micb_en;
  1366. switch (micb_num) {
  1367. case MIC_BIAS_1:
  1368. micb_reg = WCD9335_ANA_MICB1;
  1369. break;
  1370. case MIC_BIAS_2:
  1371. micb_reg = WCD9335_ANA_MICB2;
  1372. break;
  1373. case MIC_BIAS_3:
  1374. micb_reg = WCD9335_ANA_MICB3;
  1375. break;
  1376. case MIC_BIAS_4:
  1377. micb_reg = WCD9335_ANA_MICB4;
  1378. break;
  1379. default:
  1380. return -EINVAL;
  1381. }
  1382. /*
  1383. * If requested micbias voltage is same as current micbias
  1384. * voltage, then just return. Otherwise, adjust voltage as
  1385. * per requested value. If micbias is already enabled, then
  1386. * to avoid slow micbias ramp-up or down enable pull-up
  1387. * momentarily, change the micbias value and then re-enable
  1388. * micbias.
  1389. */
  1390. micb_val = snd_soc_read(codec, micb_reg);
  1391. micb_en = (micb_val & 0xC0) >> 6;
  1392. cur_vout_ctl = micb_val & 0x3F;
  1393. req_vout_ctl = wcd9335_get_micb_vout_ctl_val(req_volt);
  1394. if (req_vout_ctl < 0)
  1395. return -EINVAL;
  1396. if (cur_vout_ctl == req_vout_ctl)
  1397. return 0;
  1398. dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n",
  1399. __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl),
  1400. req_volt, micb_en);
  1401. if (micb_en == 0x1)
  1402. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1403. snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl);
  1404. if (micb_en == 0x1) {
  1405. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1406. /*
  1407. * Add 2ms delay as per HW requirement after enabling
  1408. * micbias
  1409. */
  1410. usleep_range(2000, 2100);
  1411. }
  1412. return 0;
  1413. }
  1414. static int tasha_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
  1415. int micb_num, bool req_en)
  1416. {
  1417. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1418. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  1419. int rc, micb_mv;
  1420. if (micb_num != MIC_BIAS_2)
  1421. return -EINVAL;
  1422. /*
  1423. * If device tree micbias level is already above the minimum
  1424. * voltage needed to detect threshold microphone, then do
  1425. * not change the micbias, just return.
  1426. */
  1427. if (pdata->micbias.micb2_mv >= WCD_MBHC_THR_HS_MICB_MV)
  1428. return 0;
  1429. micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv;
  1430. mutex_lock(&tasha->micb_lock);
  1431. rc = tasha_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2);
  1432. mutex_unlock(&tasha->micb_lock);
  1433. return rc;
  1434. }
  1435. static inline void tasha_mbhc_get_result_params(struct wcd9xxx *wcd9xxx,
  1436. s16 *d1_a, u16 noff,
  1437. int32_t *zdet)
  1438. {
  1439. int i;
  1440. int val, val1;
  1441. s16 c1;
  1442. s32 x1, d1;
  1443. int32_t denom;
  1444. int minCode_param[] = {
  1445. 3277, 1639, 820, 410, 205, 103, 52, 26
  1446. };
  1447. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x20);
  1448. for (i = 0; i < TASHA_ZDET_NUM_MEASUREMENTS; i++) {
  1449. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_2, &val);
  1450. if (val & 0x80)
  1451. break;
  1452. }
  1453. val = val << 0x8;
  1454. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_1, &val1);
  1455. val |= val1;
  1456. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x00);
  1457. x1 = TASHA_MBHC_GET_X1(val);
  1458. c1 = TASHA_MBHC_GET_C1(val);
  1459. /* If ramp is not complete, give additional 5ms */
  1460. if ((c1 < 2) && x1)
  1461. usleep_range(5000, 5050);
  1462. if (!c1 || !x1) {
  1463. dev_dbg(wcd9xxx->dev,
  1464. "%s: Impedance detect ramp error, c1=%d, x1=0x%x\n",
  1465. __func__, c1, x1);
  1466. goto ramp_down;
  1467. }
  1468. d1 = d1_a[c1];
  1469. denom = (x1 * d1) - (1 << (14 - noff));
  1470. if (denom > 0)
  1471. *zdet = (TASHA_MBHC_ZDET_CONST * 1000) / denom;
  1472. else if (x1 < minCode_param[noff])
  1473. *zdet = TASHA_ZDET_FLOATING_IMPEDANCE;
  1474. dev_dbg(wcd9xxx->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
  1475. __func__, d1, c1, x1, *zdet);
  1476. ramp_down:
  1477. i = 0;
  1478. while (x1) {
  1479. regmap_bulk_read(wcd9xxx->regmap,
  1480. WCD9335_ANA_MBHC_RESULT_1, (u8 *)&val, 2);
  1481. x1 = TASHA_MBHC_GET_X1(val);
  1482. i++;
  1483. if (i == TASHA_ZDET_NUM_MEASUREMENTS)
  1484. break;
  1485. }
  1486. }
  1487. /*
  1488. * tasha_mbhc_zdet_gpio_ctrl: Register callback function for
  1489. * controlling the switch on hifi amps. Default switch state
  1490. * will put a 51ohm load in parallel to the hph load. So,
  1491. * impedance detection function will pull the gpio high
  1492. * to make the switch open.
  1493. *
  1494. * @zdet_gpio_cb: callback function from machine driver
  1495. * @codec: Codec instance
  1496. *
  1497. * Return: none
  1498. */
  1499. void tasha_mbhc_zdet_gpio_ctrl(
  1500. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
  1501. struct snd_soc_codec *codec)
  1502. {
  1503. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1504. tasha->zdet_gpio_cb = zdet_gpio_cb;
  1505. }
  1506. EXPORT_SYMBOL(tasha_mbhc_zdet_gpio_ctrl);
  1507. static void tasha_mbhc_zdet_ramp(struct snd_soc_codec *codec,
  1508. struct tasha_mbhc_zdet_param *zdet_param,
  1509. int32_t *zl, int32_t *zr, s16 *d1_a)
  1510. {
  1511. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  1512. int32_t zdet = 0;
  1513. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x70,
  1514. zdet_param->ldo_ctl << 4);
  1515. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN5, 0xFC,
  1516. zdet_param->btn5);
  1517. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN6, 0xFC,
  1518. zdet_param->btn6);
  1519. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN7, 0xFC,
  1520. zdet_param->btn7);
  1521. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x0F,
  1522. zdet_param->noff);
  1523. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x0F,
  1524. zdet_param->nshift);
  1525. if (!zl)
  1526. goto z_right;
  1527. /* Start impedance measurement for HPH_L */
  1528. regmap_update_bits(wcd9xxx->regmap,
  1529. WCD9335_ANA_MBHC_ZDET, 0x80, 0x80);
  1530. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_L, noff = %d\n",
  1531. __func__, zdet_param->noff);
  1532. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1533. regmap_update_bits(wcd9xxx->regmap,
  1534. WCD9335_ANA_MBHC_ZDET, 0x80, 0x00);
  1535. *zl = zdet;
  1536. z_right:
  1537. if (!zr)
  1538. return;
  1539. /* Start impedance measurement for HPH_R */
  1540. regmap_update_bits(wcd9xxx->regmap,
  1541. WCD9335_ANA_MBHC_ZDET, 0x40, 0x40);
  1542. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_R, noff = %d\n",
  1543. __func__, zdet_param->noff);
  1544. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1545. regmap_update_bits(wcd9xxx->regmap,
  1546. WCD9335_ANA_MBHC_ZDET, 0x40, 0x00);
  1547. *zr = zdet;
  1548. }
  1549. static inline void tasha_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
  1550. int32_t *z_val, int flag_l_r)
  1551. {
  1552. s16 q1;
  1553. int q1_cal;
  1554. if (*z_val < (TASHA_ZDET_VAL_400/1000))
  1555. q1 = snd_soc_read(codec,
  1556. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r));
  1557. else
  1558. q1 = snd_soc_read(codec,
  1559. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r));
  1560. if (q1 & 0x80)
  1561. q1_cal = (10000 - ((q1 & 0x7F) * 25));
  1562. else
  1563. q1_cal = (10000 + (q1 * 25));
  1564. if (q1_cal > 0)
  1565. *z_val = ((*z_val) * 10000) / q1_cal;
  1566. }
  1567. static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
  1568. uint32_t *zr)
  1569. {
  1570. struct snd_soc_codec *codec = mbhc->codec;
  1571. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1572. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1573. s16 reg0, reg1, reg2, reg3, reg4;
  1574. int32_t z1L, z1R, z1Ls;
  1575. int zMono, z_diff1, z_diff2;
  1576. bool is_fsm_disable = false;
  1577. bool is_change = false;
  1578. struct tasha_mbhc_zdet_param zdet_param[] = {
  1579. {4, 0, 4, 0x08, 0x14, 0x18}, /* < 32ohm */
  1580. {2, 0, 3, 0x18, 0x7C, 0x90}, /* 32ohm < Z < 400ohm */
  1581. {1, 4, 5, 0x18, 0x7C, 0x90}, /* 400ohm < Z < 1200ohm */
  1582. {1, 6, 7, 0x18, 0x7C, 0x90}, /* >1200ohm */
  1583. };
  1584. struct tasha_mbhc_zdet_param *zdet_param_ptr = NULL;
  1585. s16 d1_a[][4] = {
  1586. {0, 30, 90, 30},
  1587. {0, 30, 30, 5},
  1588. {0, 30, 30, 5},
  1589. {0, 30, 30, 5},
  1590. };
  1591. s16 *d1 = NULL;
  1592. if (!TASHA_IS_2_0(wcd9xxx)) {
  1593. dev_dbg(codec->dev, "%s: Z-det is not supported for this codec version\n",
  1594. __func__);
  1595. *zl = 0;
  1596. *zr = 0;
  1597. return;
  1598. }
  1599. WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
  1600. if (tasha->zdet_gpio_cb)
  1601. is_change = tasha->zdet_gpio_cb(codec, true);
  1602. reg0 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN5);
  1603. reg1 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN6);
  1604. reg2 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN7);
  1605. reg3 = snd_soc_read(codec, WCD9335_MBHC_CTL_1);
  1606. reg4 = snd_soc_read(codec, WCD9335_MBHC_ZDET_ANA_CTL);
  1607. if (snd_soc_read(codec, WCD9335_ANA_MBHC_ELECT) & 0x80) {
  1608. is_fsm_disable = true;
  1609. regmap_update_bits(wcd9xxx->regmap,
  1610. WCD9335_ANA_MBHC_ELECT, 0x80, 0x00);
  1611. }
  1612. /* For NO-jack, disable L_DET_EN before Z-det measurements */
  1613. if (mbhc->hphl_swh)
  1614. regmap_update_bits(wcd9xxx->regmap,
  1615. WCD9335_ANA_MBHC_MECH, 0x80, 0x00);
  1616. /* Enable AZ */
  1617. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1, 0x0C, 0x04);
  1618. /* Turn off 100k pull down on HPHL */
  1619. regmap_update_bits(wcd9xxx->regmap,
  1620. WCD9335_ANA_MBHC_MECH, 0x01, 0x00);
  1621. /* First get impedance on Left */
  1622. d1 = d1_a[1];
  1623. zdet_param_ptr = &zdet_param[1];
  1624. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1625. if (!TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
  1626. goto left_ch_impedance;
  1627. /* second ramp for left ch */
  1628. if (z1L < TASHA_ZDET_VAL_32) {
  1629. zdet_param_ptr = &zdet_param[0];
  1630. d1 = d1_a[0];
  1631. } else if ((z1L > TASHA_ZDET_VAL_400) && (z1L <= TASHA_ZDET_VAL_1200)) {
  1632. zdet_param_ptr = &zdet_param[2];
  1633. d1 = d1_a[2];
  1634. } else if (z1L > TASHA_ZDET_VAL_1200) {
  1635. zdet_param_ptr = &zdet_param[3];
  1636. d1 = d1_a[3];
  1637. }
  1638. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1639. left_ch_impedance:
  1640. if ((z1L == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1641. (z1L > TASHA_ZDET_VAL_100K)) {
  1642. *zl = TASHA_ZDET_FLOATING_IMPEDANCE;
  1643. zdet_param_ptr = &zdet_param[1];
  1644. d1 = d1_a[1];
  1645. } else {
  1646. *zl = z1L/1000;
  1647. tasha_wcd_mbhc_qfuse_cal(codec, zl, 0);
  1648. }
  1649. dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n",
  1650. __func__, *zl);
  1651. /* start of right impedance ramp and calculation */
  1652. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1653. if (TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
  1654. if (((z1R > TASHA_ZDET_VAL_1200) &&
  1655. (zdet_param_ptr->noff == 0x6)) ||
  1656. ((*zl) != TASHA_ZDET_FLOATING_IMPEDANCE))
  1657. goto right_ch_impedance;
  1658. /* second ramp for right ch */
  1659. if (z1R < TASHA_ZDET_VAL_32) {
  1660. zdet_param_ptr = &zdet_param[0];
  1661. d1 = d1_a[0];
  1662. } else if ((z1R > TASHA_ZDET_VAL_400) &&
  1663. (z1R <= TASHA_ZDET_VAL_1200)) {
  1664. zdet_param_ptr = &zdet_param[2];
  1665. d1 = d1_a[2];
  1666. } else if (z1R > TASHA_ZDET_VAL_1200) {
  1667. zdet_param_ptr = &zdet_param[3];
  1668. d1 = d1_a[3];
  1669. }
  1670. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1671. }
  1672. right_ch_impedance:
  1673. if ((z1R == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1674. (z1R > TASHA_ZDET_VAL_100K)) {
  1675. *zr = TASHA_ZDET_FLOATING_IMPEDANCE;
  1676. } else {
  1677. *zr = z1R/1000;
  1678. tasha_wcd_mbhc_qfuse_cal(codec, zr, 1);
  1679. }
  1680. dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n",
  1681. __func__, *zr);
  1682. /* mono/stereo detection */
  1683. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) &&
  1684. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE)) {
  1685. dev_dbg(codec->dev,
  1686. "%s: plug type is invalid or extension cable\n",
  1687. __func__);
  1688. goto zdet_complete;
  1689. }
  1690. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1691. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1692. ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
  1693. ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
  1694. dev_dbg(codec->dev,
  1695. "%s: Mono plug type with one ch floating or shorted to GND\n",
  1696. __func__);
  1697. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1698. goto zdet_complete;
  1699. }
  1700. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x02);
  1701. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x01);
  1702. if (*zl < (TASHA_ZDET_VAL_32/1000))
  1703. tasha_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1);
  1704. else
  1705. tasha_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1);
  1706. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x00);
  1707. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x00);
  1708. z1Ls /= 1000;
  1709. tasha_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0);
  1710. /* parallel of left Z and 9 ohm pull down resistor */
  1711. zMono = ((*zl) * 9) / ((*zl) + 9);
  1712. z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
  1713. z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
  1714. if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
  1715. dev_dbg(codec->dev, "%s: stereo plug type detected\n",
  1716. __func__);
  1717. mbhc->hph_type = WCD_MBHC_HPH_STEREO;
  1718. } else {
  1719. dev_dbg(codec->dev, "%s: MONO plug type detected\n",
  1720. __func__);
  1721. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1722. }
  1723. zdet_complete:
  1724. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN5, reg0);
  1725. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN6, reg1);
  1726. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN7, reg2);
  1727. /* Turn on 100k pull down on HPHL */
  1728. regmap_update_bits(wcd9xxx->regmap,
  1729. WCD9335_ANA_MBHC_MECH, 0x01, 0x01);
  1730. /* For NO-jack, re-enable L_DET_EN after Z-det measurements */
  1731. if (mbhc->hphl_swh)
  1732. regmap_update_bits(wcd9xxx->regmap,
  1733. WCD9335_ANA_MBHC_MECH, 0x80, 0x80);
  1734. snd_soc_write(codec, WCD9335_MBHC_ZDET_ANA_CTL, reg4);
  1735. snd_soc_write(codec, WCD9335_MBHC_CTL_1, reg3);
  1736. if (is_fsm_disable)
  1737. regmap_update_bits(wcd9xxx->regmap,
  1738. WCD9335_ANA_MBHC_ELECT, 0x80, 0x80);
  1739. if (tasha->zdet_gpio_cb && is_change)
  1740. tasha->zdet_gpio_cb(codec, false);
  1741. }
  1742. static void tasha_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable)
  1743. {
  1744. if (enable) {
  1745. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1746. 0x02, 0x02);
  1747. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1748. 0x40, 0x40);
  1749. } else {
  1750. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1751. 0x40, 0x00);
  1752. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1753. 0x02, 0x00);
  1754. }
  1755. }
  1756. static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec,
  1757. bool enable)
  1758. {
  1759. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1760. if (enable) {
  1761. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1762. 0x40, 0x40);
  1763. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1764. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1765. 0x10, 0x10);
  1766. } else {
  1767. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1768. 0x40, 0x00);
  1769. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1770. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1771. 0x10, 0x00);
  1772. }
  1773. }
  1774. static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc)
  1775. {
  1776. struct snd_soc_codec *codec = mbhc->codec;
  1777. if (mbhc->moist_vref == V_OFF)
  1778. return;
  1779. /* Donot enable moisture detection if jack type is NC */
  1780. if (!mbhc->hphl_swh) {
  1781. dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
  1782. __func__);
  1783. return;
  1784. }
  1785. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2,
  1786. 0x0C, mbhc->moist_vref << 2);
  1787. tasha_mbhc_hph_l_pull_up_control(codec, mbhc->moist_iref);
  1788. }
  1789. static void tasha_update_anc_state(struct snd_soc_codec *codec, bool enable,
  1790. int anc_num)
  1791. {
  1792. if (enable)
  1793. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1794. (20 * anc_num), 0x10, 0x10);
  1795. else
  1796. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1797. (20 * anc_num), 0x10, 0x00);
  1798. }
  1799. static bool tasha_is_anc_on(struct wcd_mbhc *mbhc)
  1800. {
  1801. bool anc_on = false;
  1802. u16 ancl, ancr;
  1803. ancl =
  1804. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX1_RX_PATH_CFG0)) & 0x10;
  1805. ancr =
  1806. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX2_RX_PATH_CFG0)) & 0x10;
  1807. anc_on = !!(ancl | ancr);
  1808. return anc_on;
  1809. }
  1810. static const struct wcd_mbhc_cb mbhc_cb = {
  1811. .request_irq = tasha_mbhc_request_irq,
  1812. .irq_control = tasha_mbhc_irq_control,
  1813. .free_irq = tasha_mbhc_free_irq,
  1814. .clk_setup = tasha_mbhc_clk_setup,
  1815. .map_btn_code_to_num = tasha_mbhc_btn_to_num,
  1816. .enable_mb_source = tasha_enable_ext_mb_source,
  1817. .mbhc_bias = tasha_mbhc_mbhc_bias_control,
  1818. .set_btn_thr = tasha_mbhc_program_btn_thr,
  1819. .lock_sleep = tasha_mbhc_lock_sleep,
  1820. .register_notifier = tasha_mbhc_register_notifier,
  1821. .micbias_enable_status = tasha_mbhc_micb_en_status,
  1822. .hph_pa_on_status = tasha_mbhc_hph_pa_on_status,
  1823. .hph_pull_up_control = tasha_mbhc_hph_l_pull_up_control,
  1824. .mbhc_micbias_control = tasha_mbhc_request_micbias,
  1825. .mbhc_micb_ramp_control = tasha_mbhc_micb_ramp_control,
  1826. .get_hwdep_fw_cal = tasha_get_hwdep_fw_cal,
  1827. .mbhc_micb_ctrl_thr_mic = tasha_mbhc_micb_ctrl_threshold_mic,
  1828. .compute_impedance = tasha_wcd_mbhc_calc_impedance,
  1829. .mbhc_gnd_det_ctrl = tasha_mbhc_gnd_det_ctrl,
  1830. .hph_pull_down_ctrl = tasha_mbhc_hph_pull_down_ctrl,
  1831. .mbhc_moisture_config = tasha_mbhc_moisture_config,
  1832. .update_anc_state = tasha_update_anc_state,
  1833. .is_anc_on = tasha_is_anc_on,
  1834. };
  1835. static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol,
  1836. struct snd_ctl_elem_value *ucontrol)
  1837. {
  1838. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1839. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1840. ucontrol->value.integer.value[0] = tasha->anc_slot;
  1841. return 0;
  1842. }
  1843. static int tasha_put_anc_slot(struct snd_kcontrol *kcontrol,
  1844. struct snd_ctl_elem_value *ucontrol)
  1845. {
  1846. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1847. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1848. tasha->anc_slot = ucontrol->value.integer.value[0];
  1849. return 0;
  1850. }
  1851. static int tasha_get_anc_func(struct snd_kcontrol *kcontrol,
  1852. struct snd_ctl_elem_value *ucontrol)
  1853. {
  1854. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1855. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1856. ucontrol->value.integer.value[0] = (tasha->anc_func == true ? 1 : 0);
  1857. return 0;
  1858. }
  1859. static int tasha_put_anc_func(struct snd_kcontrol *kcontrol,
  1860. struct snd_ctl_elem_value *ucontrol)
  1861. {
  1862. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1863. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1864. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  1865. mutex_lock(&tasha->codec_mutex);
  1866. tasha->anc_func = (!ucontrol->value.integer.value[0] ? false : true);
  1867. dev_dbg(codec->dev, "%s: anc_func %x", __func__, tasha->anc_func);
  1868. if (tasha->anc_func == true) {
  1869. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2 PA");
  1870. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2");
  1871. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1 PA");
  1872. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1");
  1873. snd_soc_dapm_enable_pin(dapm, "ANC HPHR PA");
  1874. snd_soc_dapm_enable_pin(dapm, "ANC HPHR");
  1875. snd_soc_dapm_enable_pin(dapm, "ANC HPHL PA");
  1876. snd_soc_dapm_enable_pin(dapm, "ANC HPHL");
  1877. snd_soc_dapm_enable_pin(dapm, "ANC EAR PA");
  1878. snd_soc_dapm_enable_pin(dapm, "ANC EAR");
  1879. snd_soc_dapm_enable_pin(dapm, "ANC SPK1 PA");
  1880. snd_soc_dapm_disable_pin(dapm, "LINEOUT2");
  1881. snd_soc_dapm_disable_pin(dapm, "LINEOUT2 PA");
  1882. snd_soc_dapm_disable_pin(dapm, "LINEOUT1");
  1883. snd_soc_dapm_disable_pin(dapm, "LINEOUT1 PA");
  1884. snd_soc_dapm_disable_pin(dapm, "HPHR");
  1885. snd_soc_dapm_disable_pin(dapm, "HPHL");
  1886. snd_soc_dapm_disable_pin(dapm, "HPHR PA");
  1887. snd_soc_dapm_disable_pin(dapm, "HPHL PA");
  1888. snd_soc_dapm_disable_pin(dapm, "EAR PA");
  1889. snd_soc_dapm_disable_pin(dapm, "EAR");
  1890. } else {
  1891. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  1892. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  1893. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  1894. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  1895. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  1896. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  1897. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  1898. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  1899. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  1900. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  1901. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  1902. snd_soc_dapm_enable_pin(dapm, "LINEOUT2");
  1903. snd_soc_dapm_enable_pin(dapm, "LINEOUT2 PA");
  1904. snd_soc_dapm_enable_pin(dapm, "LINEOUT1");
  1905. snd_soc_dapm_enable_pin(dapm, "LINEOUT1 PA");
  1906. snd_soc_dapm_enable_pin(dapm, "HPHR");
  1907. snd_soc_dapm_enable_pin(dapm, "HPHL");
  1908. snd_soc_dapm_enable_pin(dapm, "HPHR PA");
  1909. snd_soc_dapm_enable_pin(dapm, "HPHL PA");
  1910. snd_soc_dapm_enable_pin(dapm, "EAR PA");
  1911. snd_soc_dapm_enable_pin(dapm, "EAR");
  1912. }
  1913. mutex_unlock(&tasha->codec_mutex);
  1914. snd_soc_dapm_sync(dapm);
  1915. return 0;
  1916. }
  1917. static int tasha_get_clkmode(struct snd_kcontrol *kcontrol,
  1918. struct snd_ctl_elem_value *ucontrol)
  1919. {
  1920. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1921. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1922. ucontrol->value.enumerated.item[0] = tasha->clk_mode;
  1923. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1924. return 0;
  1925. }
  1926. static int tasha_put_clkmode(struct snd_kcontrol *kcontrol,
  1927. struct snd_ctl_elem_value *ucontrol)
  1928. {
  1929. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1930. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1931. tasha->clk_mode = ucontrol->value.enumerated.item[0];
  1932. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1933. return 0;
  1934. }
  1935. static int tasha_get_iir_enable_audio_mixer(
  1936. struct snd_kcontrol *kcontrol,
  1937. struct snd_ctl_elem_value *ucontrol)
  1938. {
  1939. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1940. int iir_idx = ((struct soc_multi_mixer_control *)
  1941. kcontrol->private_value)->reg;
  1942. int band_idx = ((struct soc_multi_mixer_control *)
  1943. kcontrol->private_value)->shift;
  1944. /* IIR filter band registers are at integer multiples of 16 */
  1945. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  1946. ucontrol->value.integer.value[0] = (snd_soc_read(codec, iir_reg) &
  1947. (1 << band_idx)) != 0;
  1948. dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
  1949. iir_idx, band_idx,
  1950. (uint32_t)ucontrol->value.integer.value[0]);
  1951. return 0;
  1952. }
  1953. static int tasha_hph_impedance_get(struct snd_kcontrol *kcontrol,
  1954. struct snd_ctl_elem_value *ucontrol)
  1955. {
  1956. uint32_t zl, zr;
  1957. bool hphr;
  1958. struct soc_multi_mixer_control *mc;
  1959. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1960. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1961. mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
  1962. hphr = mc->shift;
  1963. wcd_mbhc_get_impedance(&priv->mbhc, &zl, &zr);
  1964. dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
  1965. ucontrol->value.integer.value[0] = hphr ? zr : zl;
  1966. return 0;
  1967. }
  1968. static const struct snd_kcontrol_new impedance_detect_controls[] = {
  1969. SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
  1970. tasha_hph_impedance_get, NULL),
  1971. SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
  1972. tasha_hph_impedance_get, NULL),
  1973. };
  1974. static int tasha_get_hph_type(struct snd_kcontrol *kcontrol,
  1975. struct snd_ctl_elem_value *ucontrol)
  1976. {
  1977. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1978. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1979. struct wcd_mbhc *mbhc;
  1980. if (!priv) {
  1981. dev_dbg(codec->dev, "%s: wcd9335 private data is NULL\n",
  1982. __func__);
  1983. return 0;
  1984. }
  1985. mbhc = &priv->mbhc;
  1986. if (!mbhc) {
  1987. dev_dbg(codec->dev, "%s: mbhc not initialized\n", __func__);
  1988. return 0;
  1989. }
  1990. ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
  1991. dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
  1992. return 0;
  1993. }
  1994. static const struct snd_kcontrol_new hph_type_detect_controls[] = {
  1995. SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
  1996. tasha_get_hph_type, NULL),
  1997. };
  1998. static int tasha_vi_feed_mixer_get(struct snd_kcontrol *kcontrol,
  1999. struct snd_ctl_elem_value *ucontrol)
  2000. {
  2001. struct snd_soc_dapm_widget *widget =
  2002. snd_soc_dapm_kcontrol_widget(kcontrol);
  2003. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2004. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2005. ucontrol->value.integer.value[0] = tasha_p->vi_feed_value;
  2006. return 0;
  2007. }
  2008. static int tasha_vi_feed_mixer_put(struct snd_kcontrol *kcontrol,
  2009. struct snd_ctl_elem_value *ucontrol)
  2010. {
  2011. struct snd_soc_dapm_widget *widget =
  2012. snd_soc_dapm_kcontrol_widget(kcontrol);
  2013. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2014. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2015. struct wcd9xxx *core = tasha_p->wcd9xxx;
  2016. struct soc_multi_mixer_control *mixer =
  2017. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2018. u32 dai_id = widget->shift;
  2019. u32 port_id = mixer->shift;
  2020. u32 enable = ucontrol->value.integer.value[0];
  2021. dev_dbg(codec->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n",
  2022. __func__, enable, port_id, dai_id);
  2023. tasha_p->vi_feed_value = ucontrol->value.integer.value[0];
  2024. mutex_lock(&tasha_p->codec_mutex);
  2025. if (enable) {
  2026. if (port_id == TASHA_TX14 && !test_bit(VI_SENSE_1,
  2027. &tasha_p->status_mask)) {
  2028. list_add_tail(&core->tx_chs[TASHA_TX14].list,
  2029. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2030. set_bit(VI_SENSE_1, &tasha_p->status_mask);
  2031. }
  2032. if (port_id == TASHA_TX15 && !test_bit(VI_SENSE_2,
  2033. &tasha_p->status_mask)) {
  2034. list_add_tail(&core->tx_chs[TASHA_TX15].list,
  2035. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2036. set_bit(VI_SENSE_2, &tasha_p->status_mask);
  2037. }
  2038. } else {
  2039. if (port_id == TASHA_TX14 && test_bit(VI_SENSE_1,
  2040. &tasha_p->status_mask)) {
  2041. list_del_init(&core->tx_chs[TASHA_TX14].list);
  2042. clear_bit(VI_SENSE_1, &tasha_p->status_mask);
  2043. }
  2044. if (port_id == TASHA_TX15 && test_bit(VI_SENSE_2,
  2045. &tasha_p->status_mask)) {
  2046. list_del_init(&core->tx_chs[TASHA_TX15].list);
  2047. clear_bit(VI_SENSE_2, &tasha_p->status_mask);
  2048. }
  2049. }
  2050. mutex_unlock(&tasha_p->codec_mutex);
  2051. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL);
  2052. return 0;
  2053. }
  2054. /* virtual port entries */
  2055. static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol,
  2056. struct snd_ctl_elem_value *ucontrol)
  2057. {
  2058. struct snd_soc_dapm_widget *widget =
  2059. snd_soc_dapm_kcontrol_widget(kcontrol);
  2060. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2061. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2062. ucontrol->value.integer.value[0] = tasha_p->tx_port_value;
  2063. return 0;
  2064. }
  2065. static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol,
  2066. struct snd_ctl_elem_value *ucontrol)
  2067. {
  2068. struct snd_soc_dapm_widget *widget =
  2069. snd_soc_dapm_kcontrol_widget(kcontrol);
  2070. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2071. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2072. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2073. struct snd_soc_dapm_update *update = NULL;
  2074. struct soc_multi_mixer_control *mixer =
  2075. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2076. u32 dai_id = widget->shift;
  2077. u32 port_id = mixer->shift;
  2078. u32 enable = ucontrol->value.integer.value[0];
  2079. u32 vtable;
  2080. dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n",
  2081. __func__,
  2082. widget->name, ucontrol->id.name, tasha_p->tx_port_value,
  2083. widget->shift, ucontrol->value.integer.value[0]);
  2084. mutex_lock(&tasha_p->codec_mutex);
  2085. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2086. if (dai_id != AIF1_CAP) {
  2087. dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
  2088. __func__);
  2089. mutex_unlock(&tasha_p->codec_mutex);
  2090. return -EINVAL;
  2091. }
  2092. vtable = vport_slim_check_table[dai_id];
  2093. } else {
  2094. if (dai_id >= ARRAY_SIZE(vport_i2s_check_table)) {
  2095. dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n",
  2096. __func__, dai_id);
  2097. return -EINVAL;
  2098. }
  2099. vtable = vport_i2s_check_table[dai_id];
  2100. }
  2101. switch (dai_id) {
  2102. case AIF1_CAP:
  2103. case AIF2_CAP:
  2104. case AIF3_CAP:
  2105. /* only add to the list if value not set */
  2106. if (enable && !(tasha_p->tx_port_value & 1 << port_id)) {
  2107. if (wcd9xxx_tx_vport_validation(vtable, port_id,
  2108. tasha_p->dai, NUM_CODEC_DAIS)) {
  2109. dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n",
  2110. __func__, port_id);
  2111. mutex_unlock(&tasha_p->codec_mutex);
  2112. return 0;
  2113. }
  2114. tasha_p->tx_port_value |= 1 << port_id;
  2115. list_add_tail(&core->tx_chs[port_id].list,
  2116. &tasha_p->dai[dai_id].wcd9xxx_ch_list
  2117. );
  2118. } else if (!enable && (tasha_p->tx_port_value &
  2119. 1 << port_id)) {
  2120. tasha_p->tx_port_value &= ~(1 << port_id);
  2121. list_del_init(&core->tx_chs[port_id].list);
  2122. } else {
  2123. if (enable)
  2124. dev_dbg(codec->dev, "%s: TX%u port is used by\n"
  2125. "this virtual port\n",
  2126. __func__, port_id);
  2127. else
  2128. dev_dbg(codec->dev, "%s: TX%u port is not used by\n"
  2129. "this virtual port\n",
  2130. __func__, port_id);
  2131. /* avoid update power function */
  2132. mutex_unlock(&tasha_p->codec_mutex);
  2133. return 0;
  2134. }
  2135. break;
  2136. case AIF4_MAD_TX:
  2137. case AIF5_CPE_TX:
  2138. break;
  2139. default:
  2140. pr_err("Unknown AIF %d\n", dai_id);
  2141. mutex_unlock(&tasha_p->codec_mutex);
  2142. return -EINVAL;
  2143. }
  2144. pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__,
  2145. widget->name, widget->sname, tasha_p->tx_port_value,
  2146. widget->shift);
  2147. mutex_unlock(&tasha_p->codec_mutex);
  2148. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
  2149. return 0;
  2150. }
  2151. static int slim_rx_mux_get(struct snd_kcontrol *kcontrol,
  2152. struct snd_ctl_elem_value *ucontrol)
  2153. {
  2154. struct snd_soc_dapm_widget *widget =
  2155. snd_soc_dapm_kcontrol_widget(kcontrol);
  2156. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2157. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2158. ucontrol->value.enumerated.item[0] =
  2159. tasha_p->rx_port_value[widget->shift];
  2160. return 0;
  2161. }
  2162. static const char *const slim_rx_mux_text[] = {
  2163. "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB", "AIF_MIX1_PB"
  2164. };
  2165. static int slim_rx_mux_put(struct snd_kcontrol *kcontrol,
  2166. struct snd_ctl_elem_value *ucontrol)
  2167. {
  2168. struct snd_soc_dapm_widget *widget =
  2169. snd_soc_dapm_kcontrol_widget(kcontrol);
  2170. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2171. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2172. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2173. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  2174. struct snd_soc_dapm_update *update = NULL;
  2175. unsigned int rx_port_value;
  2176. u32 port_id = widget->shift;
  2177. tasha_p->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
  2178. rx_port_value = tasha_p->rx_port_value[port_id];
  2179. pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__,
  2180. widget->name, ucontrol->id.name, rx_port_value,
  2181. widget->shift, ucontrol->value.integer.value[0]);
  2182. mutex_lock(&tasha_p->codec_mutex);
  2183. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2184. if (rx_port_value > 2) {
  2185. dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
  2186. __func__);
  2187. goto err;
  2188. }
  2189. }
  2190. /* value need to match the Virtual port and AIF number */
  2191. switch (rx_port_value) {
  2192. case 0:
  2193. list_del_init(&core->rx_chs[port_id].list);
  2194. break;
  2195. case 1:
  2196. if (wcd9xxx_rx_vport_validation(port_id +
  2197. TASHA_RX_PORT_START_NUMBER,
  2198. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list)) {
  2199. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2200. __func__, port_id);
  2201. goto rtn;
  2202. }
  2203. list_add_tail(&core->rx_chs[port_id].list,
  2204. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list);
  2205. break;
  2206. case 2:
  2207. if (wcd9xxx_rx_vport_validation(port_id +
  2208. TASHA_RX_PORT_START_NUMBER,
  2209. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list)) {
  2210. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2211. __func__, port_id);
  2212. goto rtn;
  2213. }
  2214. list_add_tail(&core->rx_chs[port_id].list,
  2215. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list);
  2216. break;
  2217. case 3:
  2218. if (wcd9xxx_rx_vport_validation(port_id +
  2219. TASHA_RX_PORT_START_NUMBER,
  2220. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list)) {
  2221. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2222. __func__, port_id);
  2223. goto rtn;
  2224. }
  2225. list_add_tail(&core->rx_chs[port_id].list,
  2226. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list);
  2227. break;
  2228. case 4:
  2229. if (wcd9xxx_rx_vport_validation(port_id +
  2230. TASHA_RX_PORT_START_NUMBER,
  2231. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list)) {
  2232. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2233. __func__, port_id);
  2234. goto rtn;
  2235. }
  2236. list_add_tail(&core->rx_chs[port_id].list,
  2237. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list);
  2238. break;
  2239. case 5:
  2240. if (wcd9xxx_rx_vport_validation(port_id +
  2241. TASHA_RX_PORT_START_NUMBER,
  2242. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list)) {
  2243. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2244. __func__, port_id);
  2245. goto rtn;
  2246. }
  2247. list_add_tail(&core->rx_chs[port_id].list,
  2248. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list);
  2249. break;
  2250. default:
  2251. pr_err("Unknown AIF %d\n", rx_port_value);
  2252. goto err;
  2253. }
  2254. rtn:
  2255. mutex_unlock(&tasha_p->codec_mutex);
  2256. snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
  2257. rx_port_value, e, update);
  2258. return 0;
  2259. err:
  2260. mutex_unlock(&tasha_p->codec_mutex);
  2261. return -EINVAL;
  2262. }
  2263. static const struct soc_enum slim_rx_mux_enum =
  2264. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text);
  2265. static const struct snd_kcontrol_new slim_rx_mux[TASHA_RX_MAX] = {
  2266. SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum,
  2267. slim_rx_mux_get, slim_rx_mux_put),
  2268. SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
  2269. slim_rx_mux_get, slim_rx_mux_put),
  2270. SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
  2271. slim_rx_mux_get, slim_rx_mux_put),
  2272. SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
  2273. slim_rx_mux_get, slim_rx_mux_put),
  2274. SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
  2275. slim_rx_mux_get, slim_rx_mux_put),
  2276. SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
  2277. slim_rx_mux_get, slim_rx_mux_put),
  2278. SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
  2279. slim_rx_mux_get, slim_rx_mux_put),
  2280. SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
  2281. slim_rx_mux_get, slim_rx_mux_put),
  2282. };
  2283. static const struct snd_kcontrol_new aif4_vi_mixer[] = {
  2284. SOC_SINGLE_EXT("SPKR_VI_1", SND_SOC_NOPM, TASHA_TX14, 1, 0,
  2285. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2286. SOC_SINGLE_EXT("SPKR_VI_2", SND_SOC_NOPM, TASHA_TX15, 1, 0,
  2287. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2288. };
  2289. static const struct snd_kcontrol_new aif1_cap_mixer[] = {
  2290. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2291. slim_tx_mixer_get, slim_tx_mixer_put),
  2292. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2293. slim_tx_mixer_get, slim_tx_mixer_put),
  2294. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2295. slim_tx_mixer_get, slim_tx_mixer_put),
  2296. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2297. slim_tx_mixer_get, slim_tx_mixer_put),
  2298. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2299. slim_tx_mixer_get, slim_tx_mixer_put),
  2300. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2301. slim_tx_mixer_get, slim_tx_mixer_put),
  2302. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2303. slim_tx_mixer_get, slim_tx_mixer_put),
  2304. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2305. slim_tx_mixer_get, slim_tx_mixer_put),
  2306. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2307. slim_tx_mixer_get, slim_tx_mixer_put),
  2308. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2309. slim_tx_mixer_get, slim_tx_mixer_put),
  2310. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2311. slim_tx_mixer_get, slim_tx_mixer_put),
  2312. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2313. slim_tx_mixer_get, slim_tx_mixer_put),
  2314. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2315. slim_tx_mixer_get, slim_tx_mixer_put),
  2316. };
  2317. static const struct snd_kcontrol_new aif2_cap_mixer[] = {
  2318. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2319. slim_tx_mixer_get, slim_tx_mixer_put),
  2320. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2321. slim_tx_mixer_get, slim_tx_mixer_put),
  2322. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2323. slim_tx_mixer_get, slim_tx_mixer_put),
  2324. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2325. slim_tx_mixer_get, slim_tx_mixer_put),
  2326. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2327. slim_tx_mixer_get, slim_tx_mixer_put),
  2328. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2329. slim_tx_mixer_get, slim_tx_mixer_put),
  2330. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2331. slim_tx_mixer_get, slim_tx_mixer_put),
  2332. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2333. slim_tx_mixer_get, slim_tx_mixer_put),
  2334. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2335. slim_tx_mixer_get, slim_tx_mixer_put),
  2336. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2337. slim_tx_mixer_get, slim_tx_mixer_put),
  2338. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2339. slim_tx_mixer_get, slim_tx_mixer_put),
  2340. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2341. slim_tx_mixer_get, slim_tx_mixer_put),
  2342. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2343. slim_tx_mixer_get, slim_tx_mixer_put),
  2344. };
  2345. static const struct snd_kcontrol_new aif3_cap_mixer[] = {
  2346. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2347. slim_tx_mixer_get, slim_tx_mixer_put),
  2348. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2349. slim_tx_mixer_get, slim_tx_mixer_put),
  2350. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2351. slim_tx_mixer_get, slim_tx_mixer_put),
  2352. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2353. slim_tx_mixer_get, slim_tx_mixer_put),
  2354. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2355. slim_tx_mixer_get, slim_tx_mixer_put),
  2356. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2357. slim_tx_mixer_get, slim_tx_mixer_put),
  2358. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2359. slim_tx_mixer_get, slim_tx_mixer_put),
  2360. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2361. slim_tx_mixer_get, slim_tx_mixer_put),
  2362. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2363. slim_tx_mixer_get, slim_tx_mixer_put),
  2364. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2365. slim_tx_mixer_get, slim_tx_mixer_put),
  2366. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2367. slim_tx_mixer_get, slim_tx_mixer_put),
  2368. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2369. slim_tx_mixer_get, slim_tx_mixer_put),
  2370. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2371. slim_tx_mixer_get, slim_tx_mixer_put),
  2372. };
  2373. static const struct snd_kcontrol_new aif4_mad_mixer[] = {
  2374. SOC_SINGLE_EXT("SLIM TX12", SND_SOC_NOPM, TASHA_TX12, 1, 0,
  2375. slim_tx_mixer_get, slim_tx_mixer_put),
  2376. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2377. slim_tx_mixer_get, slim_tx_mixer_put),
  2378. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, 0, 1, 0,
  2379. slim_tx_mixer_get, slim_tx_mixer_put),
  2380. };
  2381. static const struct snd_kcontrol_new rx_int1_spline_mix_switch[] = {
  2382. SOC_DAPM_SINGLE("HPHL Switch", SND_SOC_NOPM, 0, 1, 0)
  2383. };
  2384. static const struct snd_kcontrol_new rx_int2_spline_mix_switch[] = {
  2385. SOC_DAPM_SINGLE("HPHR Switch", SND_SOC_NOPM, 0, 1, 0)
  2386. };
  2387. static const struct snd_kcontrol_new rx_int3_spline_mix_switch[] = {
  2388. SOC_DAPM_SINGLE("LO1 Switch", SND_SOC_NOPM, 0, 1, 0)
  2389. };
  2390. static const struct snd_kcontrol_new rx_int4_spline_mix_switch[] = {
  2391. SOC_DAPM_SINGLE("LO2 Switch", SND_SOC_NOPM, 0, 1, 0)
  2392. };
  2393. static const struct snd_kcontrol_new rx_int5_spline_mix_switch[] = {
  2394. SOC_DAPM_SINGLE("LO3 Switch", SND_SOC_NOPM, 0, 1, 0)
  2395. };
  2396. static const struct snd_kcontrol_new rx_int6_spline_mix_switch[] = {
  2397. SOC_DAPM_SINGLE("LO4 Switch", SND_SOC_NOPM, 0, 1, 0)
  2398. };
  2399. static const struct snd_kcontrol_new rx_int7_spline_mix_switch[] = {
  2400. SOC_DAPM_SINGLE("SPKRL Switch", SND_SOC_NOPM, 0, 1, 0)
  2401. };
  2402. static const struct snd_kcontrol_new rx_int8_spline_mix_switch[] = {
  2403. SOC_DAPM_SINGLE("SPKRR Switch", SND_SOC_NOPM, 0, 1, 0)
  2404. };
  2405. static const struct snd_kcontrol_new rx_int5_vbat_mix_switch[] = {
  2406. SOC_DAPM_SINGLE("LO3 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2407. };
  2408. static const struct snd_kcontrol_new rx_int6_vbat_mix_switch[] = {
  2409. SOC_DAPM_SINGLE("LO4 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2410. };
  2411. static const struct snd_kcontrol_new rx_int7_vbat_mix_switch[] = {
  2412. SOC_DAPM_SINGLE("SPKRL VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2413. };
  2414. static const struct snd_kcontrol_new rx_int8_vbat_mix_switch[] = {
  2415. SOC_DAPM_SINGLE("SPKRR VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2416. };
  2417. static const struct snd_kcontrol_new cpe_in_mix_switch[] = {
  2418. SOC_DAPM_SINGLE("MAD_BYPASS", SND_SOC_NOPM, 0, 1, 0)
  2419. };
  2420. static int tasha_put_iir_enable_audio_mixer(
  2421. struct snd_kcontrol *kcontrol,
  2422. struct snd_ctl_elem_value *ucontrol)
  2423. {
  2424. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2425. int iir_idx = ((struct soc_multi_mixer_control *)
  2426. kcontrol->private_value)->reg;
  2427. int band_idx = ((struct soc_multi_mixer_control *)
  2428. kcontrol->private_value)->shift;
  2429. bool iir_band_en_status;
  2430. int value = ucontrol->value.integer.value[0];
  2431. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  2432. /* Mask first 5 bits, 6-8 are reserved */
  2433. snd_soc_update_bits(codec, iir_reg, (1 << band_idx),
  2434. (value << band_idx));
  2435. iir_band_en_status = ((snd_soc_read(codec, iir_reg) &
  2436. (1 << band_idx)) != 0);
  2437. pr_debug("%s: IIR #%d band #%d enable %d\n", __func__,
  2438. iir_idx, band_idx, iir_band_en_status);
  2439. return 0;
  2440. }
  2441. static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec,
  2442. int iir_idx, int band_idx,
  2443. int coeff_idx)
  2444. {
  2445. uint32_t value = 0;
  2446. /* Address does not automatically update if reading */
  2447. snd_soc_write(codec,
  2448. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2449. ((band_idx * BAND_MAX + coeff_idx)
  2450. * sizeof(uint32_t)) & 0x7F);
  2451. value |= snd_soc_read(codec,
  2452. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx));
  2453. snd_soc_write(codec,
  2454. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2455. ((band_idx * BAND_MAX + coeff_idx)
  2456. * sizeof(uint32_t) + 1) & 0x7F);
  2457. value |= (snd_soc_read(codec,
  2458. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2459. 16 * iir_idx)) << 8);
  2460. snd_soc_write(codec,
  2461. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2462. ((band_idx * BAND_MAX + coeff_idx)
  2463. * sizeof(uint32_t) + 2) & 0x7F);
  2464. value |= (snd_soc_read(codec,
  2465. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2466. 16 * iir_idx)) << 16);
  2467. snd_soc_write(codec,
  2468. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2469. ((band_idx * BAND_MAX + coeff_idx)
  2470. * sizeof(uint32_t) + 3) & 0x7F);
  2471. /* Mask bits top 2 bits since they are reserved */
  2472. value |= ((snd_soc_read(codec,
  2473. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2474. 16 * iir_idx)) & 0x3F) << 24);
  2475. return value;
  2476. }
  2477. static int tasha_get_iir_band_audio_mixer(
  2478. struct snd_kcontrol *kcontrol,
  2479. struct snd_ctl_elem_value *ucontrol)
  2480. {
  2481. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2482. int iir_idx = ((struct soc_multi_mixer_control *)
  2483. kcontrol->private_value)->reg;
  2484. int band_idx = ((struct soc_multi_mixer_control *)
  2485. kcontrol->private_value)->shift;
  2486. ucontrol->value.integer.value[0] =
  2487. get_iir_band_coeff(codec, iir_idx, band_idx, 0);
  2488. ucontrol->value.integer.value[1] =
  2489. get_iir_band_coeff(codec, iir_idx, band_idx, 1);
  2490. ucontrol->value.integer.value[2] =
  2491. get_iir_band_coeff(codec, iir_idx, band_idx, 2);
  2492. ucontrol->value.integer.value[3] =
  2493. get_iir_band_coeff(codec, iir_idx, band_idx, 3);
  2494. ucontrol->value.integer.value[4] =
  2495. get_iir_band_coeff(codec, iir_idx, band_idx, 4);
  2496. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  2497. "%s: IIR #%d band #%d b1 = 0x%x\n"
  2498. "%s: IIR #%d band #%d b2 = 0x%x\n"
  2499. "%s: IIR #%d band #%d a1 = 0x%x\n"
  2500. "%s: IIR #%d band #%d a2 = 0x%x\n",
  2501. __func__, iir_idx, band_idx,
  2502. (uint32_t)ucontrol->value.integer.value[0],
  2503. __func__, iir_idx, band_idx,
  2504. (uint32_t)ucontrol->value.integer.value[1],
  2505. __func__, iir_idx, band_idx,
  2506. (uint32_t)ucontrol->value.integer.value[2],
  2507. __func__, iir_idx, band_idx,
  2508. (uint32_t)ucontrol->value.integer.value[3],
  2509. __func__, iir_idx, band_idx,
  2510. (uint32_t)ucontrol->value.integer.value[4]);
  2511. return 0;
  2512. }
  2513. static void set_iir_band_coeff(struct snd_soc_codec *codec,
  2514. int iir_idx, int band_idx,
  2515. uint32_t value)
  2516. {
  2517. snd_soc_write(codec,
  2518. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2519. (value & 0xFF));
  2520. snd_soc_write(codec,
  2521. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2522. (value >> 8) & 0xFF);
  2523. snd_soc_write(codec,
  2524. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2525. (value >> 16) & 0xFF);
  2526. /* Mask top 2 bits, 7-8 are reserved */
  2527. snd_soc_write(codec,
  2528. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2529. (value >> 24) & 0x3F);
  2530. }
  2531. static void tasha_codec_enable_int_port(struct wcd9xxx_codec_dai_data *dai,
  2532. struct snd_soc_codec *codec)
  2533. {
  2534. struct wcd9xxx_ch *ch;
  2535. int port_num = 0;
  2536. unsigned short reg = 0;
  2537. u8 val = 0;
  2538. struct tasha_priv *tasha_p;
  2539. if (!dai || !codec) {
  2540. pr_err("%s: Invalid params\n", __func__);
  2541. return;
  2542. }
  2543. tasha_p = snd_soc_codec_get_drvdata(codec);
  2544. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2545. if (ch->port >= TASHA_RX_PORT_START_NUMBER) {
  2546. port_num = ch->port - TASHA_RX_PORT_START_NUMBER;
  2547. reg = TASHA_SLIM_PGD_PORT_INT_EN0 + (port_num / 8);
  2548. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2549. reg);
  2550. if (!(val & BYTE_BIT_MASK(port_num))) {
  2551. val |= BYTE_BIT_MASK(port_num);
  2552. wcd9xxx_interface_reg_write(
  2553. tasha_p->wcd9xxx, reg, val);
  2554. val = wcd9xxx_interface_reg_read(
  2555. tasha_p->wcd9xxx, reg);
  2556. }
  2557. } else {
  2558. port_num = ch->port;
  2559. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 + (port_num / 8);
  2560. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2561. reg);
  2562. if (!(val & BYTE_BIT_MASK(port_num))) {
  2563. val |= BYTE_BIT_MASK(port_num);
  2564. wcd9xxx_interface_reg_write(tasha_p->wcd9xxx,
  2565. reg, val);
  2566. val = wcd9xxx_interface_reg_read(
  2567. tasha_p->wcd9xxx, reg);
  2568. }
  2569. }
  2570. }
  2571. }
  2572. static int tasha_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai,
  2573. bool up)
  2574. {
  2575. int ret = 0;
  2576. struct wcd9xxx_ch *ch;
  2577. if (up) {
  2578. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2579. ret = wcd9xxx_get_slave_port(ch->ch_num);
  2580. if (ret < 0) {
  2581. pr_err("%s: Invalid slave port ID: %d\n",
  2582. __func__, ret);
  2583. ret = -EINVAL;
  2584. } else {
  2585. set_bit(ret, &dai->ch_mask);
  2586. }
  2587. }
  2588. } else {
  2589. ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0),
  2590. msecs_to_jiffies(
  2591. TASHA_SLIM_CLOSE_TIMEOUT));
  2592. if (!ret) {
  2593. pr_err("%s: Slim close tx/rx wait timeout, ch_mask:0x%lx\n",
  2594. __func__, dai->ch_mask);
  2595. ret = -ETIMEDOUT;
  2596. } else {
  2597. ret = 0;
  2598. }
  2599. }
  2600. return ret;
  2601. }
  2602. static int tasha_codec_enable_slimrx(struct snd_soc_dapm_widget *w,
  2603. struct snd_kcontrol *kcontrol,
  2604. int event)
  2605. {
  2606. struct wcd9xxx *core;
  2607. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2608. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2609. int ret = 0;
  2610. struct wcd9xxx_codec_dai_data *dai;
  2611. core = dev_get_drvdata(codec->dev->parent);
  2612. dev_dbg(codec->dev, "%s: event called! codec name %s num_dai %d\n"
  2613. "stream name %s event %d\n",
  2614. __func__, codec->component.name,
  2615. codec->component.num_dai, w->sname, event);
  2616. /* Execute the callback only if interface type is slimbus */
  2617. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2618. return 0;
  2619. dai = &tasha_p->dai[w->shift];
  2620. dev_dbg(codec->dev, "%s: w->name %s w->shift %d event %d\n",
  2621. __func__, w->name, w->shift, event);
  2622. switch (event) {
  2623. case SND_SOC_DAPM_POST_PMU:
  2624. dai->bus_down_in_recovery = false;
  2625. tasha_codec_enable_int_port(dai, codec);
  2626. (void) tasha_codec_enable_slim_chmask(dai, true);
  2627. ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2628. dai->rate, dai->bit_width,
  2629. &dai->grph);
  2630. break;
  2631. case SND_SOC_DAPM_PRE_PMD:
  2632. tasha_codec_vote_max_bw(codec, true);
  2633. break;
  2634. case SND_SOC_DAPM_POST_PMD:
  2635. ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list,
  2636. dai->grph);
  2637. dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n",
  2638. __func__, ret);
  2639. if (!dai->bus_down_in_recovery)
  2640. ret = tasha_codec_enable_slim_chmask(dai, false);
  2641. else
  2642. dev_dbg(codec->dev,
  2643. "%s: bus in recovery skip enable slim_chmask",
  2644. __func__);
  2645. ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2646. dai->grph);
  2647. break;
  2648. }
  2649. return ret;
  2650. }
  2651. static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w,
  2652. struct snd_kcontrol *kcontrol,
  2653. int event)
  2654. {
  2655. struct wcd9xxx *core = NULL;
  2656. struct snd_soc_codec *codec = NULL;
  2657. struct tasha_priv *tasha_p = NULL;
  2658. int ret = 0;
  2659. struct wcd9xxx_codec_dai_data *dai = NULL;
  2660. if (!w) {
  2661. pr_err("%s invalid params\n", __func__);
  2662. return -EINVAL;
  2663. }
  2664. codec = snd_soc_dapm_to_codec(w->dapm);
  2665. tasha_p = snd_soc_codec_get_drvdata(codec);
  2666. core = tasha_p->wcd9xxx;
  2667. dev_dbg(codec->dev, "%s: num_dai %d stream name %s\n",
  2668. __func__, codec->component.num_dai, w->sname);
  2669. /* Execute the callback only if interface type is slimbus */
  2670. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2671. dev_err(codec->dev, "%s Interface is not correct", __func__);
  2672. return 0;
  2673. }
  2674. dev_dbg(codec->dev, "%s(): w->name %s event %d w->shift %d\n",
  2675. __func__, w->name, event, w->shift);
  2676. if (w->shift != AIF4_VIFEED) {
  2677. pr_err("%s Error in enabling the tx path\n", __func__);
  2678. ret = -EINVAL;
  2679. goto out_vi;
  2680. }
  2681. dai = &tasha_p->dai[w->shift];
  2682. switch (event) {
  2683. case SND_SOC_DAPM_POST_PMU:
  2684. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2685. dev_dbg(codec->dev, "%s: spkr1 enabled\n", __func__);
  2686. /* Enable V&I sensing */
  2687. snd_soc_update_bits(codec,
  2688. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2689. snd_soc_update_bits(codec,
  2690. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2691. 0x20);
  2692. snd_soc_update_bits(codec,
  2693. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x00);
  2694. snd_soc_update_bits(codec,
  2695. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x0F,
  2696. 0x00);
  2697. snd_soc_update_bits(codec,
  2698. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10);
  2699. snd_soc_update_bits(codec,
  2700. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2701. 0x10);
  2702. snd_soc_update_bits(codec,
  2703. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00);
  2704. snd_soc_update_bits(codec,
  2705. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2706. 0x00);
  2707. }
  2708. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2709. pr_debug("%s: spkr2 enabled\n", __func__);
  2710. /* Enable V&I sensing */
  2711. snd_soc_update_bits(codec,
  2712. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2713. 0x20);
  2714. snd_soc_update_bits(codec,
  2715. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2716. 0x20);
  2717. snd_soc_update_bits(codec,
  2718. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x0F,
  2719. 0x00);
  2720. snd_soc_update_bits(codec,
  2721. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x0F,
  2722. 0x00);
  2723. snd_soc_update_bits(codec,
  2724. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2725. 0x10);
  2726. snd_soc_update_bits(codec,
  2727. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2728. 0x10);
  2729. snd_soc_update_bits(codec,
  2730. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2731. 0x00);
  2732. snd_soc_update_bits(codec,
  2733. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2734. 0x00);
  2735. }
  2736. dai->bus_down_in_recovery = false;
  2737. tasha_codec_enable_int_port(dai, codec);
  2738. (void) tasha_codec_enable_slim_chmask(dai, true);
  2739. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2740. dai->rate, dai->bit_width,
  2741. &dai->grph);
  2742. break;
  2743. case SND_SOC_DAPM_POST_PMD:
  2744. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2745. dai->grph);
  2746. if (ret)
  2747. dev_err(codec->dev, "%s error in close_slim_sch_tx %d\n",
  2748. __func__, ret);
  2749. if (!dai->bus_down_in_recovery)
  2750. ret = tasha_codec_enable_slim_chmask(dai, false);
  2751. if (ret < 0) {
  2752. ret = wcd9xxx_disconnect_port(core,
  2753. &dai->wcd9xxx_ch_list,
  2754. dai->grph);
  2755. dev_dbg(codec->dev, "%s: Disconnect TX port, ret = %d\n",
  2756. __func__, ret);
  2757. }
  2758. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2759. /* Disable V&I sensing */
  2760. dev_dbg(codec->dev, "%s: spkr1 disabled\n", __func__);
  2761. snd_soc_update_bits(codec,
  2762. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2763. snd_soc_update_bits(codec,
  2764. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2765. 0x20);
  2766. snd_soc_update_bits(codec,
  2767. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00);
  2768. snd_soc_update_bits(codec,
  2769. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2770. 0x00);
  2771. }
  2772. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2773. /* Disable V&I sensing */
  2774. dev_dbg(codec->dev, "%s: spkr2 disabled\n", __func__);
  2775. snd_soc_update_bits(codec,
  2776. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2777. 0x20);
  2778. snd_soc_update_bits(codec,
  2779. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2780. 0x20);
  2781. snd_soc_update_bits(codec,
  2782. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2783. 0x00);
  2784. snd_soc_update_bits(codec,
  2785. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2786. 0x00);
  2787. }
  2788. break;
  2789. }
  2790. out_vi:
  2791. return ret;
  2792. }
  2793. /*
  2794. * __tasha_codec_enable_slimtx: Enable the slimbus slave port
  2795. * for TX path
  2796. * @codec: Handle to the codec for which the slave port is to be
  2797. * enabled.
  2798. * @dai_data: The dai specific data for dai which is enabled.
  2799. */
  2800. static int __tasha_codec_enable_slimtx(struct snd_soc_codec *codec,
  2801. int event, struct wcd9xxx_codec_dai_data *dai)
  2802. {
  2803. struct wcd9xxx *core;
  2804. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2805. int ret = 0;
  2806. /* Execute the callback only if interface type is slimbus */
  2807. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2808. return 0;
  2809. dev_dbg(codec->dev,
  2810. "%s: event = %d\n", __func__, event);
  2811. core = dev_get_drvdata(codec->dev->parent);
  2812. switch (event) {
  2813. case SND_SOC_DAPM_POST_PMU:
  2814. dai->bus_down_in_recovery = false;
  2815. tasha_codec_enable_int_port(dai, codec);
  2816. (void) tasha_codec_enable_slim_chmask(dai, true);
  2817. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2818. dai->rate, dai->bit_width,
  2819. &dai->grph);
  2820. break;
  2821. case SND_SOC_DAPM_POST_PMD:
  2822. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2823. dai->grph);
  2824. if (!dai->bus_down_in_recovery)
  2825. ret = tasha_codec_enable_slim_chmask(dai, false);
  2826. if (ret < 0) {
  2827. ret = wcd9xxx_disconnect_port(core,
  2828. &dai->wcd9xxx_ch_list,
  2829. dai->grph);
  2830. pr_debug("%s: Disconnect TX port, ret = %d\n",
  2831. __func__, ret);
  2832. }
  2833. break;
  2834. }
  2835. return ret;
  2836. }
  2837. static int tasha_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
  2838. struct snd_kcontrol *kcontrol,
  2839. int event)
  2840. {
  2841. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2842. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2843. struct wcd9xxx_codec_dai_data *dai;
  2844. dev_dbg(codec->dev,
  2845. "%s: w->name %s, w->shift = %d, num_dai %d stream name %s\n",
  2846. __func__, w->name, w->shift,
  2847. codec->component.num_dai, w->sname);
  2848. dai = &tasha_p->dai[w->shift];
  2849. return __tasha_codec_enable_slimtx(codec, event, dai);
  2850. }
  2851. static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_codec *codec, int event)
  2852. {
  2853. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2854. struct wcd9xxx_codec_dai_data *dai;
  2855. u8 bit_width, rate, buf_period;
  2856. dai = &tasha_p->dai[AIF4_MAD_TX];
  2857. switch (event) {
  2858. case SND_SOC_DAPM_POST_PMU:
  2859. switch (dai->bit_width) {
  2860. case 32:
  2861. bit_width = 0xF;
  2862. break;
  2863. case 24:
  2864. bit_width = 0xE;
  2865. break;
  2866. case 20:
  2867. bit_width = 0xD;
  2868. break;
  2869. case 16:
  2870. default:
  2871. bit_width = 0x0;
  2872. break;
  2873. }
  2874. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x0F,
  2875. bit_width);
  2876. switch (dai->rate) {
  2877. case 384000:
  2878. rate = 0x30;
  2879. break;
  2880. case 192000:
  2881. rate = 0x20;
  2882. break;
  2883. case 48000:
  2884. rate = 0x10;
  2885. break;
  2886. case 16000:
  2887. default:
  2888. rate = 0x00;
  2889. break;
  2890. }
  2891. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x70,
  2892. rate);
  2893. buf_period = (dai->rate * (dai->bit_width/8)) / (16*1000);
  2894. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD,
  2895. 0xFF, buf_period);
  2896. dev_dbg(codec->dev, "%s: PP buffer period= 0x%x\n",
  2897. __func__, buf_period);
  2898. break;
  2899. case SND_SOC_DAPM_POST_PMD:
  2900. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x3C);
  2901. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD, 0x60);
  2902. break;
  2903. default:
  2904. break;
  2905. }
  2906. }
  2907. /*
  2908. * tasha_codec_get_mad_port_id: Callback function that will be invoked
  2909. * to get the port ID for MAD.
  2910. * @codec: Handle to the codec
  2911. * @port_id: cpe port_id needs to enable
  2912. */
  2913. static int tasha_codec_get_mad_port_id(struct snd_soc_codec *codec,
  2914. u16 *port_id)
  2915. {
  2916. struct tasha_priv *tasha_p;
  2917. struct wcd9xxx_codec_dai_data *dai;
  2918. struct wcd9xxx_ch *ch;
  2919. if (!port_id || !codec)
  2920. return -EINVAL;
  2921. tasha_p = snd_soc_codec_get_drvdata(codec);
  2922. if (!tasha_p)
  2923. return -EINVAL;
  2924. dai = &tasha_p->dai[AIF4_MAD_TX];
  2925. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2926. if (ch->port == TASHA_TX12)
  2927. *port_id = WCD_CPE_AFE_OUT_PORT_2;
  2928. else if (ch->port == TASHA_TX13)
  2929. *port_id = WCD_CPE_AFE_OUT_PORT_4;
  2930. else {
  2931. dev_err(codec->dev, "%s: invalid mad_port = %d\n",
  2932. __func__, ch->port);
  2933. return -EINVAL;
  2934. }
  2935. }
  2936. dev_dbg(codec->dev, "%s: port_id = %d\n", __func__, *port_id);
  2937. return 0;
  2938. }
  2939. /*
  2940. * tasha_codec_enable_slimtx_mad: Callback function that will be invoked
  2941. * to setup the slave port for MAD.
  2942. * @codec: Handle to the codec
  2943. * @event: Indicates whether to enable or disable the slave port
  2944. */
  2945. static int tasha_codec_enable_slimtx_mad(struct snd_soc_codec *codec,
  2946. u8 event)
  2947. {
  2948. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2949. struct wcd9xxx_codec_dai_data *dai;
  2950. struct wcd9xxx_ch *ch;
  2951. int dapm_event = SND_SOC_DAPM_POST_PMU;
  2952. u16 port = 0;
  2953. int ret = 0;
  2954. dai = &tasha_p->dai[AIF4_MAD_TX];
  2955. if (event == 0)
  2956. dapm_event = SND_SOC_DAPM_POST_PMD;
  2957. dev_dbg(codec->dev,
  2958. "%s: mad_channel, event = 0x%x\n",
  2959. __func__, event);
  2960. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2961. dev_dbg(codec->dev, "%s: mad_port = %d, event = 0x%x\n",
  2962. __func__, ch->port, event);
  2963. if (ch->port == TASHA_TX13) {
  2964. tasha_codec_cpe_pp_set_cfg(codec, dapm_event);
  2965. port = TASHA_TX13;
  2966. break;
  2967. }
  2968. }
  2969. ret = __tasha_codec_enable_slimtx(codec, dapm_event, dai);
  2970. if (port == TASHA_TX13) {
  2971. switch (dapm_event) {
  2972. case SND_SOC_DAPM_POST_PMU:
  2973. snd_soc_update_bits(codec,
  2974. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2975. 0x20, 0x00);
  2976. snd_soc_update_bits(codec,
  2977. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2978. 0x03, 0x02);
  2979. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2980. 0x80, 0x80);
  2981. break;
  2982. case SND_SOC_DAPM_POST_PMD:
  2983. snd_soc_update_bits(codec,
  2984. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2985. 0x20, 0x20);
  2986. snd_soc_update_bits(codec,
  2987. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2988. 0x03, 0x00);
  2989. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2990. 0x80, 0x00);
  2991. break;
  2992. }
  2993. }
  2994. return ret;
  2995. }
  2996. static int tasha_put_iir_band_audio_mixer(
  2997. struct snd_kcontrol *kcontrol,
  2998. struct snd_ctl_elem_value *ucontrol)
  2999. {
  3000. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3001. int iir_idx = ((struct soc_multi_mixer_control *)
  3002. kcontrol->private_value)->reg;
  3003. int band_idx = ((struct soc_multi_mixer_control *)
  3004. kcontrol->private_value)->shift;
  3005. /*
  3006. * Mask top bit it is reserved
  3007. * Updates addr automatically for each B2 write
  3008. */
  3009. snd_soc_write(codec,
  3010. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  3011. (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
  3012. set_iir_band_coeff(codec, iir_idx, band_idx,
  3013. ucontrol->value.integer.value[0]);
  3014. set_iir_band_coeff(codec, iir_idx, band_idx,
  3015. ucontrol->value.integer.value[1]);
  3016. set_iir_band_coeff(codec, iir_idx, band_idx,
  3017. ucontrol->value.integer.value[2]);
  3018. set_iir_band_coeff(codec, iir_idx, band_idx,
  3019. ucontrol->value.integer.value[3]);
  3020. set_iir_band_coeff(codec, iir_idx, band_idx,
  3021. ucontrol->value.integer.value[4]);
  3022. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  3023. "%s: IIR #%d band #%d b1 = 0x%x\n"
  3024. "%s: IIR #%d band #%d b2 = 0x%x\n"
  3025. "%s: IIR #%d band #%d a1 = 0x%x\n"
  3026. "%s: IIR #%d band #%d a2 = 0x%x\n",
  3027. __func__, iir_idx, band_idx,
  3028. get_iir_band_coeff(codec, iir_idx, band_idx, 0),
  3029. __func__, iir_idx, band_idx,
  3030. get_iir_band_coeff(codec, iir_idx, band_idx, 1),
  3031. __func__, iir_idx, band_idx,
  3032. get_iir_band_coeff(codec, iir_idx, band_idx, 2),
  3033. __func__, iir_idx, band_idx,
  3034. get_iir_band_coeff(codec, iir_idx, band_idx, 3),
  3035. __func__, iir_idx, band_idx,
  3036. get_iir_band_coeff(codec, iir_idx, band_idx, 4));
  3037. return 0;
  3038. }
  3039. static int tasha_get_compander(struct snd_kcontrol *kcontrol,
  3040. struct snd_ctl_elem_value *ucontrol)
  3041. {
  3042. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3043. int comp = ((struct soc_multi_mixer_control *)
  3044. kcontrol->private_value)->shift;
  3045. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3046. ucontrol->value.integer.value[0] = tasha->comp_enabled[comp];
  3047. return 0;
  3048. }
  3049. static int tasha_set_compander(struct snd_kcontrol *kcontrol,
  3050. struct snd_ctl_elem_value *ucontrol)
  3051. {
  3052. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3053. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3054. int comp = ((struct soc_multi_mixer_control *)
  3055. kcontrol->private_value)->shift;
  3056. int value = ucontrol->value.integer.value[0];
  3057. pr_debug("%s: Compander %d enable current %d, new %d\n",
  3058. __func__, comp + 1, tasha->comp_enabled[comp], value);
  3059. tasha->comp_enabled[comp] = value;
  3060. /* Any specific register configuration for compander */
  3061. switch (comp) {
  3062. case COMPANDER_1:
  3063. /* Set Gain Source Select based on compander enable/disable */
  3064. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0x20,
  3065. (value ? 0x00:0x20));
  3066. break;
  3067. case COMPANDER_2:
  3068. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0x20,
  3069. (value ? 0x00:0x20));
  3070. break;
  3071. case COMPANDER_3:
  3072. break;
  3073. case COMPANDER_4:
  3074. break;
  3075. case COMPANDER_5:
  3076. snd_soc_update_bits(codec, WCD9335_SE_LO_LO3_GAIN, 0x20,
  3077. (value ? 0x00:0x20));
  3078. break;
  3079. case COMPANDER_6:
  3080. snd_soc_update_bits(codec, WCD9335_SE_LO_LO4_GAIN, 0x20,
  3081. (value ? 0x00:0x20));
  3082. break;
  3083. case COMPANDER_7:
  3084. break;
  3085. case COMPANDER_8:
  3086. break;
  3087. default:
  3088. /*
  3089. * if compander is not enabled for any interpolator,
  3090. * it does not cause any audio failure, so do not
  3091. * return error in this case, but just print a log
  3092. */
  3093. dev_warn(codec->dev, "%s: unknown compander: %d\n",
  3094. __func__, comp);
  3095. };
  3096. return 0;
  3097. }
  3098. static void tasha_codec_init_flyback(struct snd_soc_codec *codec)
  3099. {
  3100. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x00);
  3101. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x00);
  3102. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0x0F, 0x00);
  3103. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0xF0, 0x00);
  3104. }
  3105. static int tasha_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
  3106. struct snd_kcontrol *kcontrol, int event)
  3107. {
  3108. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3109. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3110. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3111. switch (event) {
  3112. case SND_SOC_DAPM_PRE_PMU:
  3113. tasha->rx_bias_count++;
  3114. if (tasha->rx_bias_count == 1) {
  3115. if (TASHA_IS_2_0(tasha->wcd9xxx))
  3116. tasha_codec_init_flyback(codec);
  3117. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3118. 0x01, 0x01);
  3119. }
  3120. break;
  3121. case SND_SOC_DAPM_POST_PMD:
  3122. tasha->rx_bias_count--;
  3123. if (!tasha->rx_bias_count)
  3124. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3125. 0x01, 0x00);
  3126. break;
  3127. };
  3128. dev_dbg(codec->dev, "%s: Current RX BIAS user count: %d\n", __func__,
  3129. tasha->rx_bias_count);
  3130. return 0;
  3131. }
  3132. static void tasha_realign_anc_coeff(struct snd_soc_codec *codec,
  3133. u16 reg1, u16 reg2)
  3134. {
  3135. u8 val1, val2, tmpval1, tmpval2;
  3136. snd_soc_write(codec, reg1, 0x00);
  3137. tmpval1 = snd_soc_read(codec, reg2);
  3138. tmpval2 = snd_soc_read(codec, reg2);
  3139. snd_soc_write(codec, reg1, 0x00);
  3140. snd_soc_write(codec, reg2, 0xFF);
  3141. snd_soc_write(codec, reg1, 0x01);
  3142. snd_soc_write(codec, reg2, 0xFF);
  3143. snd_soc_write(codec, reg1, 0x00);
  3144. val1 = snd_soc_read(codec, reg2);
  3145. val2 = snd_soc_read(codec, reg2);
  3146. if (val1 == 0x0F && val2 == 0xFF) {
  3147. dev_dbg(codec->dev, "%s: ANC0 co-eff index re-aligned\n",
  3148. __func__);
  3149. snd_soc_read(codec, reg2);
  3150. snd_soc_write(codec, reg1, 0x00);
  3151. snd_soc_write(codec, reg2, tmpval2);
  3152. snd_soc_write(codec, reg1, 0x01);
  3153. snd_soc_write(codec, reg2, tmpval1);
  3154. } else if (val1 == 0xFF && val2 == 0x0F) {
  3155. dev_dbg(codec->dev, "%s: ANC1 co-eff index already aligned\n",
  3156. __func__);
  3157. snd_soc_write(codec, reg1, 0x00);
  3158. snd_soc_write(codec, reg2, tmpval1);
  3159. snd_soc_write(codec, reg1, 0x01);
  3160. snd_soc_write(codec, reg2, tmpval2);
  3161. } else {
  3162. dev_err(codec->dev, "%s: ANC0 co-eff index not aligned\n",
  3163. __func__);
  3164. }
  3165. }
  3166. static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w,
  3167. struct snd_kcontrol *kcontrol, int event)
  3168. {
  3169. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3170. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3171. const char *filename;
  3172. const struct firmware *fw;
  3173. int i;
  3174. int ret = 0;
  3175. int num_anc_slots;
  3176. struct wcd9xxx_anc_header *anc_head;
  3177. struct firmware_cal *hwdep_cal = NULL;
  3178. u32 anc_writes_size = 0;
  3179. u32 anc_cal_size = 0;
  3180. int anc_size_remaining;
  3181. u32 *anc_ptr;
  3182. u16 reg;
  3183. u8 mask, val;
  3184. size_t cal_size;
  3185. const void *data;
  3186. if (!tasha->anc_func)
  3187. return 0;
  3188. switch (event) {
  3189. case SND_SOC_DAPM_PRE_PMU:
  3190. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_ANC_CAL);
  3191. if (hwdep_cal) {
  3192. data = hwdep_cal->data;
  3193. cal_size = hwdep_cal->size;
  3194. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  3195. __func__);
  3196. } else {
  3197. filename = "wcd9335/wcd9335_anc.bin";
  3198. ret = request_firmware(&fw, filename, codec->dev);
  3199. if (ret != 0) {
  3200. dev_err(codec->dev,
  3201. "Failed to acquire ANC data: %d\n", ret);
  3202. return -ENODEV;
  3203. }
  3204. if (!fw) {
  3205. dev_err(codec->dev, "failed to get anc fw");
  3206. return -ENODEV;
  3207. }
  3208. data = fw->data;
  3209. cal_size = fw->size;
  3210. dev_dbg(codec->dev,
  3211. "%s: using request_firmware calibration\n", __func__);
  3212. }
  3213. if (cal_size < sizeof(struct wcd9xxx_anc_header)) {
  3214. dev_err(codec->dev, "Not enough data\n");
  3215. ret = -ENOMEM;
  3216. goto err;
  3217. }
  3218. /* First number is the number of register writes */
  3219. anc_head = (struct wcd9xxx_anc_header *)(data);
  3220. anc_ptr = (u32 *)(data +
  3221. sizeof(struct wcd9xxx_anc_header));
  3222. anc_size_remaining = cal_size -
  3223. sizeof(struct wcd9xxx_anc_header);
  3224. num_anc_slots = anc_head->num_anc_slots;
  3225. if (tasha->anc_slot >= num_anc_slots) {
  3226. dev_err(codec->dev, "Invalid ANC slot selected\n");
  3227. ret = -EINVAL;
  3228. goto err;
  3229. }
  3230. for (i = 0; i < num_anc_slots; i++) {
  3231. if (anc_size_remaining < TASHA_PACKED_REG_SIZE) {
  3232. dev_err(codec->dev,
  3233. "Invalid register format\n");
  3234. ret = -EINVAL;
  3235. goto err;
  3236. }
  3237. anc_writes_size = (u32)(*anc_ptr);
  3238. anc_size_remaining -= sizeof(u32);
  3239. anc_ptr += 1;
  3240. if (anc_writes_size * TASHA_PACKED_REG_SIZE
  3241. > anc_size_remaining) {
  3242. dev_err(codec->dev,
  3243. "Invalid register format\n");
  3244. ret = -EINVAL;
  3245. goto err;
  3246. }
  3247. if (tasha->anc_slot == i)
  3248. break;
  3249. anc_size_remaining -= (anc_writes_size *
  3250. TASHA_PACKED_REG_SIZE);
  3251. anc_ptr += anc_writes_size;
  3252. }
  3253. if (i == num_anc_slots) {
  3254. dev_err(codec->dev, "Selected ANC slot not present\n");
  3255. ret = -EINVAL;
  3256. goto err;
  3257. }
  3258. i = 0;
  3259. anc_cal_size = anc_writes_size;
  3260. if (!strcmp(w->name, "RX INT0 DAC") ||
  3261. !strcmp(w->name, "ANC SPK1 PA"))
  3262. tasha_realign_anc_coeff(codec,
  3263. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3264. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3265. if (!strcmp(w->name, "RX INT1 DAC") ||
  3266. !strcmp(w->name, "RX INT3 DAC")) {
  3267. tasha_realign_anc_coeff(codec,
  3268. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3269. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3270. anc_writes_size = anc_cal_size / 2;
  3271. snd_soc_update_bits(codec,
  3272. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x39, 0x39);
  3273. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3274. !strcmp(w->name, "RX INT4 DAC")) {
  3275. tasha_realign_anc_coeff(codec,
  3276. WCD9335_CDC_ANC1_IIR_COEFF_1_CTL,
  3277. WCD9335_CDC_ANC1_IIR_COEFF_2_CTL);
  3278. i = anc_cal_size / 2;
  3279. snd_soc_update_bits(codec,
  3280. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x39, 0x39);
  3281. }
  3282. for (; i < anc_writes_size; i++) {
  3283. TASHA_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val);
  3284. snd_soc_write(codec, reg, (val & mask));
  3285. }
  3286. if (!strcmp(w->name, "RX INT1 DAC") ||
  3287. !strcmp(w->name, "RX INT3 DAC")) {
  3288. snd_soc_update_bits(codec,
  3289. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08);
  3290. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3291. !strcmp(w->name, "RX INT4 DAC")) {
  3292. snd_soc_update_bits(codec,
  3293. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08);
  3294. }
  3295. if (!hwdep_cal)
  3296. release_firmware(fw);
  3297. break;
  3298. case SND_SOC_DAPM_POST_PMU:
  3299. /* Remove ANC Rx from reset */
  3300. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_CLK_RESET_CTL,
  3301. 0x08, 0x00);
  3302. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_CLK_RESET_CTL,
  3303. 0x08, 0x00);
  3304. break;
  3305. case SND_SOC_DAPM_POST_PMD:
  3306. if (!strcmp(w->name, "ANC HPHL PA") ||
  3307. !strcmp(w->name, "ANC EAR PA") ||
  3308. !strcmp(w->name, "ANC SPK1 PA") ||
  3309. !strcmp(w->name, "ANC LINEOUT1 PA")) {
  3310. snd_soc_update_bits(codec,
  3311. WCD9335_CDC_ANC0_MODE_1_CTL, 0x30, 0x00);
  3312. msleep(50);
  3313. snd_soc_update_bits(codec,
  3314. WCD9335_CDC_ANC0_MODE_1_CTL, 0x01, 0x00);
  3315. snd_soc_update_bits(codec,
  3316. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x38);
  3317. snd_soc_update_bits(codec,
  3318. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x07, 0x00);
  3319. snd_soc_update_bits(codec,
  3320. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x00);
  3321. } else if (!strcmp(w->name, "ANC HPHR PA") ||
  3322. !strcmp(w->name, "ANC LINEOUT2 PA")) {
  3323. snd_soc_update_bits(codec,
  3324. WCD9335_CDC_ANC1_MODE_1_CTL, 0x30, 0x00);
  3325. msleep(50);
  3326. snd_soc_update_bits(codec,
  3327. WCD9335_CDC_ANC1_MODE_1_CTL, 0x01, 0x00);
  3328. snd_soc_update_bits(codec,
  3329. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x38);
  3330. snd_soc_update_bits(codec,
  3331. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x07, 0x00);
  3332. snd_soc_update_bits(codec,
  3333. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x00);
  3334. }
  3335. break;
  3336. }
  3337. return 0;
  3338. err:
  3339. if (!hwdep_cal)
  3340. release_firmware(fw);
  3341. return ret;
  3342. }
  3343. static void tasha_codec_clear_anc_tx_hold(struct tasha_priv *tasha)
  3344. {
  3345. if (test_and_clear_bit(ANC_MIC_AMIC1, &tasha->status_mask))
  3346. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC1, false);
  3347. if (test_and_clear_bit(ANC_MIC_AMIC2, &tasha->status_mask))
  3348. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC2, false);
  3349. if (test_and_clear_bit(ANC_MIC_AMIC3, &tasha->status_mask))
  3350. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC3, false);
  3351. if (test_and_clear_bit(ANC_MIC_AMIC4, &tasha->status_mask))
  3352. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC4, false);
  3353. if (test_and_clear_bit(ANC_MIC_AMIC5, &tasha->status_mask))
  3354. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC5, false);
  3355. if (test_and_clear_bit(ANC_MIC_AMIC6, &tasha->status_mask))
  3356. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC6, false);
  3357. }
  3358. static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha,
  3359. int mode, int event)
  3360. {
  3361. u8 scale_val = 0;
  3362. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3363. return;
  3364. switch (event) {
  3365. case SND_SOC_DAPM_POST_PMU:
  3366. switch (mode) {
  3367. case CLS_H_HIFI:
  3368. scale_val = 0x3;
  3369. break;
  3370. case CLS_H_LOHIFI:
  3371. scale_val = 0x1;
  3372. break;
  3373. }
  3374. if (tasha->anc_func) {
  3375. /* Clear Tx FE HOLD if both PAs are enabled */
  3376. if ((snd_soc_read(tasha->codec, WCD9335_ANA_HPH) &
  3377. 0xC0) == 0xC0) {
  3378. tasha_codec_clear_anc_tx_hold(tasha);
  3379. }
  3380. }
  3381. break;
  3382. case SND_SOC_DAPM_PRE_PMD:
  3383. scale_val = 0x6;
  3384. break;
  3385. }
  3386. if (scale_val)
  3387. snd_soc_update_bits(tasha->codec, WCD9335_HPH_PA_CTL1, 0x0E,
  3388. scale_val << 1);
  3389. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3390. if (tasha->comp_enabled[COMPANDER_1] ||
  3391. tasha->comp_enabled[COMPANDER_2]) {
  3392. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN,
  3393. 0x20, 0x00);
  3394. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN,
  3395. 0x20, 0x00);
  3396. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP,
  3397. 0x20, 0x20);
  3398. }
  3399. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN, 0x1F,
  3400. tasha->hph_l_gain);
  3401. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN, 0x1F,
  3402. tasha->hph_r_gain);
  3403. }
  3404. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3405. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP, 0x20,
  3406. 0x00);
  3407. }
  3408. }
  3409. static void tasha_codec_override(struct snd_soc_codec *codec,
  3410. int mode,
  3411. int event)
  3412. {
  3413. if (mode == CLS_AB) {
  3414. switch (event) {
  3415. case SND_SOC_DAPM_POST_PMU:
  3416. if (!(snd_soc_read(codec,
  3417. WCD9335_CDC_RX2_RX_PATH_CTL) & 0x10) &&
  3418. (!(snd_soc_read(codec,
  3419. WCD9335_CDC_RX1_RX_PATH_CTL) & 0x10)))
  3420. snd_soc_update_bits(codec,
  3421. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x02);
  3422. break;
  3423. case SND_SOC_DAPM_POST_PMD:
  3424. snd_soc_update_bits(codec,
  3425. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00);
  3426. break;
  3427. }
  3428. }
  3429. }
  3430. static int tasha_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
  3431. struct snd_kcontrol *kcontrol,
  3432. int event)
  3433. {
  3434. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3435. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3436. int hph_mode = tasha->hph_mode;
  3437. int ret = 0;
  3438. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3439. switch (event) {
  3440. case SND_SOC_DAPM_PRE_PMU:
  3441. if ((!(strcmp(w->name, "ANC HPHR PA"))) &&
  3442. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3443. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3444. }
  3445. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3446. break;
  3447. case SND_SOC_DAPM_POST_PMU:
  3448. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3449. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3450. != 0xC0)
  3451. /*
  3452. * If PA_EN is not set (potentially in ANC case)
  3453. * then do nothing for POST_PMU and let left
  3454. * channel handle everything.
  3455. */
  3456. break;
  3457. }
  3458. /*
  3459. * 7ms sleep is required after PA is enabled as per
  3460. * HW requirement
  3461. */
  3462. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3463. usleep_range(7000, 7100);
  3464. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3465. }
  3466. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3467. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3468. 0x10, 0x00);
  3469. /* Remove mix path mute if it is enabled */
  3470. if ((snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3471. 0x10)
  3472. snd_soc_update_bits(codec,
  3473. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3474. 0x10, 0x00);
  3475. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3476. /* Do everything needed for left channel */
  3477. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3478. 0x10, 0x00);
  3479. /* Remove mix path mute if it is enabled */
  3480. if ((snd_soc_read(codec,
  3481. WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3482. 0x10)
  3483. snd_soc_update_bits(codec,
  3484. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3485. 0x10, 0x00);
  3486. /* Remove ANC Rx from reset */
  3487. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3488. }
  3489. tasha_codec_override(codec, hph_mode, event);
  3490. break;
  3491. case SND_SOC_DAPM_PRE_PMD:
  3492. blocking_notifier_call_chain(&tasha->notifier,
  3493. WCD_EVENT_PRE_HPHR_PA_OFF,
  3494. &tasha->mbhc);
  3495. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3496. if (!(strcmp(w->name, "ANC HPHR PA")))
  3497. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x00);
  3498. break;
  3499. case SND_SOC_DAPM_POST_PMD:
  3500. /* 5ms sleep is required after PA is disabled as per
  3501. * HW requirement
  3502. */
  3503. usleep_range(5000, 5500);
  3504. tasha_codec_override(codec, hph_mode, event);
  3505. blocking_notifier_call_chain(&tasha->notifier,
  3506. WCD_EVENT_POST_HPHR_PA_OFF,
  3507. &tasha->mbhc);
  3508. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3509. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3510. snd_soc_update_bits(codec,
  3511. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x00);
  3512. }
  3513. break;
  3514. };
  3515. return ret;
  3516. }
  3517. static int tasha_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
  3518. struct snd_kcontrol *kcontrol,
  3519. int event)
  3520. {
  3521. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3522. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3523. int hph_mode = tasha->hph_mode;
  3524. int ret = 0;
  3525. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3526. switch (event) {
  3527. case SND_SOC_DAPM_PRE_PMU:
  3528. if ((!(strcmp(w->name, "ANC HPHL PA"))) &&
  3529. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3530. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3531. }
  3532. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3533. break;
  3534. case SND_SOC_DAPM_POST_PMU:
  3535. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3536. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3537. != 0xC0)
  3538. /*
  3539. * If PA_EN is not set (potentially in ANC case)
  3540. * then do nothing for POST_PMU and let right
  3541. * channel handle everything.
  3542. */
  3543. break;
  3544. }
  3545. /*
  3546. * 7ms sleep is required after PA is enabled as per
  3547. * HW requirement
  3548. */
  3549. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3550. usleep_range(7000, 7100);
  3551. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3552. }
  3553. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3554. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3555. 0x10, 0x00);
  3556. /* Remove mix path mute if it is enabled */
  3557. if ((snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3558. 0x10)
  3559. snd_soc_update_bits(codec,
  3560. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3561. 0x10, 0x00);
  3562. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3563. /* Do everything needed for right channel */
  3564. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3565. 0x10, 0x00);
  3566. /* Remove mix path mute if it is enabled */
  3567. if ((snd_soc_read(codec,
  3568. WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3569. 0x10)
  3570. snd_soc_update_bits(codec,
  3571. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3572. 0x10, 0x00);
  3573. /* Remove ANC Rx from reset */
  3574. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3575. }
  3576. tasha_codec_override(codec, hph_mode, event);
  3577. break;
  3578. case SND_SOC_DAPM_PRE_PMD:
  3579. blocking_notifier_call_chain(&tasha->notifier,
  3580. WCD_EVENT_PRE_HPHL_PA_OFF,
  3581. &tasha->mbhc);
  3582. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3583. if (!(strcmp(w->name, "ANC HPHL PA")))
  3584. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x00);
  3585. break;
  3586. case SND_SOC_DAPM_POST_PMD:
  3587. /* 5ms sleep is required after PA is disabled as per
  3588. * HW requirement
  3589. */
  3590. usleep_range(5000, 5500);
  3591. tasha_codec_override(codec, hph_mode, event);
  3592. blocking_notifier_call_chain(&tasha->notifier,
  3593. WCD_EVENT_POST_HPHL_PA_OFF,
  3594. &tasha->mbhc);
  3595. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3596. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3597. snd_soc_update_bits(codec,
  3598. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00);
  3599. }
  3600. break;
  3601. };
  3602. return ret;
  3603. }
  3604. static int tasha_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w,
  3605. struct snd_kcontrol *kcontrol,
  3606. int event)
  3607. {
  3608. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3609. u16 lineout_vol_reg = 0, lineout_mix_vol_reg = 0;
  3610. int ret = 0;
  3611. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3612. if (w->reg == WCD9335_ANA_LO_1_2) {
  3613. if (w->shift == 7) {
  3614. lineout_vol_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  3615. lineout_mix_vol_reg = WCD9335_CDC_RX3_RX_PATH_MIX_CTL;
  3616. } else if (w->shift == 6) {
  3617. lineout_vol_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  3618. lineout_mix_vol_reg = WCD9335_CDC_RX4_RX_PATH_MIX_CTL;
  3619. }
  3620. } else if (w->reg == WCD9335_ANA_LO_3_4) {
  3621. if (w->shift == 7) {
  3622. lineout_vol_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  3623. lineout_mix_vol_reg = WCD9335_CDC_RX5_RX_PATH_MIX_CTL;
  3624. } else if (w->shift == 6) {
  3625. lineout_vol_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  3626. lineout_mix_vol_reg = WCD9335_CDC_RX6_RX_PATH_MIX_CTL;
  3627. }
  3628. } else {
  3629. dev_err(codec->dev, "%s: Error enabling lineout PA\n",
  3630. __func__);
  3631. return -EINVAL;
  3632. }
  3633. switch (event) {
  3634. case SND_SOC_DAPM_POST_PMU:
  3635. /* 5ms sleep is required after PA is enabled as per
  3636. * HW requirement
  3637. */
  3638. usleep_range(5000, 5500);
  3639. snd_soc_update_bits(codec, lineout_vol_reg,
  3640. 0x10, 0x00);
  3641. /* Remove mix path mute if it is enabled */
  3642. if ((snd_soc_read(codec, lineout_mix_vol_reg)) & 0x10)
  3643. snd_soc_update_bits(codec,
  3644. lineout_mix_vol_reg,
  3645. 0x10, 0x00);
  3646. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3647. !(strcmp(w->name, "ANC LINEOUT2 PA")))
  3648. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3649. tasha_codec_override(codec, CLS_AB, event);
  3650. break;
  3651. case SND_SOC_DAPM_POST_PMD:
  3652. /* 5ms sleep is required after PA is disabled as per
  3653. * HW requirement
  3654. */
  3655. usleep_range(5000, 5500);
  3656. tasha_codec_override(codec, CLS_AB, event);
  3657. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3658. !(strcmp(w->name, "ANC LINEOUT2 PA"))) {
  3659. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3660. if (!(strcmp(w->name, "ANC LINEOUT1 PA")))
  3661. snd_soc_update_bits(codec,
  3662. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  3663. else
  3664. snd_soc_update_bits(codec,
  3665. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  3666. }
  3667. break;
  3668. };
  3669. return ret;
  3670. }
  3671. static void tasha_spk_anc_update_callback(struct work_struct *work)
  3672. {
  3673. struct spk_anc_work *spk_anc_dwork;
  3674. struct tasha_priv *tasha;
  3675. struct delayed_work *delayed_work;
  3676. struct snd_soc_codec *codec;
  3677. delayed_work = to_delayed_work(work);
  3678. spk_anc_dwork = container_of(delayed_work, struct spk_anc_work, dwork);
  3679. tasha = spk_anc_dwork->tasha;
  3680. codec = tasha->codec;
  3681. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0, 0x10, 0x10);
  3682. }
  3683. static int tasha_codec_enable_spk_anc(struct snd_soc_dapm_widget *w,
  3684. struct snd_kcontrol *kcontrol,
  3685. int event)
  3686. {
  3687. int ret = 0;
  3688. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3689. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3690. dev_dbg(codec->dev, "%s %s %d %d\n", __func__, w->name, event,
  3691. tasha->anc_func);
  3692. if (!tasha->anc_func)
  3693. return 0;
  3694. switch (event) {
  3695. case SND_SOC_DAPM_PRE_PMU:
  3696. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3697. schedule_delayed_work(&tasha->spk_anc_dwork.dwork,
  3698. msecs_to_jiffies(spk_anc_en_delay));
  3699. break;
  3700. case SND_SOC_DAPM_POST_PMD:
  3701. cancel_delayed_work_sync(&tasha->spk_anc_dwork.dwork);
  3702. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0,
  3703. 0x10, 0x00);
  3704. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3705. break;
  3706. }
  3707. return ret;
  3708. }
  3709. static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
  3710. struct snd_kcontrol *kcontrol,
  3711. int event)
  3712. {
  3713. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3714. int ret = 0;
  3715. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3716. switch (event) {
  3717. case SND_SOC_DAPM_POST_PMU:
  3718. /* 5ms sleep is required after PA is enabled as per
  3719. * HW requirement
  3720. */
  3721. usleep_range(5000, 5500);
  3722. snd_soc_update_bits(codec, WCD9335_CDC_RX0_RX_PATH_CTL,
  3723. 0x10, 0x00);
  3724. /* Remove mix path mute if it is enabled */
  3725. if ((snd_soc_read(codec, WCD9335_CDC_RX0_RX_PATH_MIX_CTL)) &
  3726. 0x10)
  3727. snd_soc_update_bits(codec,
  3728. WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  3729. 0x10, 0x00);
  3730. break;
  3731. case SND_SOC_DAPM_POST_PMD:
  3732. /* 5ms sleep is required after PA is disabled as per
  3733. * HW requirement
  3734. */
  3735. usleep_range(5000, 5500);
  3736. if (!(strcmp(w->name, "ANC EAR PA"))) {
  3737. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3738. snd_soc_update_bits(codec,
  3739. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x00);
  3740. }
  3741. break;
  3742. };
  3743. return ret;
  3744. }
  3745. static void tasha_codec_hph_mode_gain_opt(struct snd_soc_codec *codec,
  3746. u8 gain)
  3747. {
  3748. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3749. u8 hph_l_en, hph_r_en;
  3750. u8 l_val, r_val;
  3751. u8 hph_pa_status;
  3752. bool is_hphl_pa, is_hphr_pa;
  3753. hph_pa_status = snd_soc_read(codec, WCD9335_ANA_HPH);
  3754. is_hphl_pa = hph_pa_status >> 7;
  3755. is_hphr_pa = (hph_pa_status & 0x40) >> 6;
  3756. hph_l_en = snd_soc_read(codec, WCD9335_HPH_L_EN);
  3757. hph_r_en = snd_soc_read(codec, WCD9335_HPH_R_EN);
  3758. l_val = (hph_l_en & 0xC0) | 0x20 | gain;
  3759. r_val = (hph_r_en & 0xC0) | 0x20 | gain;
  3760. /*
  3761. * Set HPH_L & HPH_R gain source selection to REGISTER
  3762. * for better click and pop only if corresponding PAs are
  3763. * not enabled. Also cache the values of the HPHL/R
  3764. * PA gains to be applied after PAs are enabled
  3765. */
  3766. if ((l_val != hph_l_en) && !is_hphl_pa) {
  3767. snd_soc_write(codec, WCD9335_HPH_L_EN, l_val);
  3768. tasha->hph_l_gain = hph_l_en & 0x1F;
  3769. }
  3770. if ((r_val != hph_r_en) && !is_hphr_pa) {
  3771. snd_soc_write(codec, WCD9335_HPH_R_EN, r_val);
  3772. tasha->hph_r_gain = hph_r_en & 0x1F;
  3773. }
  3774. }
  3775. static void tasha_codec_hph_lohifi_config(struct snd_soc_codec *codec,
  3776. int event)
  3777. {
  3778. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3779. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x06);
  3780. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2,
  3781. 0xF0, 0x40);
  3782. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3783. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3784. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3785. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3786. }
  3787. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3788. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3789. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3790. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A);
  3791. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x0A);
  3792. }
  3793. }
  3794. static void tasha_codec_hph_lp_config(struct snd_soc_codec *codec,
  3795. int event)
  3796. {
  3797. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3798. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3799. tasha_codec_hph_mode_gain_opt(codec, 0x10);
  3800. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3801. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3802. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x04);
  3803. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x20);
  3804. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x07,
  3805. 0x01);
  3806. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x70,
  3807. 0x10);
  3808. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3809. 0x0F, 0x01);
  3810. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3811. 0xF0, 0x10);
  3812. }
  3813. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3814. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x88);
  3815. snd_soc_write(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x33);
  3816. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x00);
  3817. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x00);
  3818. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3819. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3820. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x80);
  3821. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x80);
  3822. }
  3823. }
  3824. static void tasha_codec_hph_hifi_config(struct snd_soc_codec *codec,
  3825. int event)
  3826. {
  3827. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3828. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3829. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3830. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3831. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3832. }
  3833. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3834. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3835. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3836. }
  3837. }
  3838. static void tasha_codec_hph_mode_config(struct snd_soc_codec *codec,
  3839. int event, int mode)
  3840. {
  3841. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3842. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3843. return;
  3844. switch (mode) {
  3845. case CLS_H_LP:
  3846. tasha_codec_hph_lp_config(codec, event);
  3847. break;
  3848. case CLS_H_LOHIFI:
  3849. tasha_codec_hph_lohifi_config(codec, event);
  3850. break;
  3851. case CLS_H_HIFI:
  3852. tasha_codec_hph_hifi_config(codec, event);
  3853. break;
  3854. }
  3855. }
  3856. static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
  3857. struct snd_kcontrol *kcontrol,
  3858. int event)
  3859. {
  3860. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3861. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3862. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3863. int hph_mode = tasha->hph_mode;
  3864. u8 dem_inp;
  3865. int ret = 0;
  3866. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3867. w->name, event, hph_mode);
  3868. switch (event) {
  3869. case SND_SOC_DAPM_PRE_PMU:
  3870. if (tasha->anc_func) {
  3871. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3872. /* 40 msec delay is needed to avoid click and pop */
  3873. msleep(40);
  3874. }
  3875. /* Read DEM INP Select */
  3876. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_SEC0) &
  3877. 0x03;
  3878. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3879. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3880. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3881. __func__, hph_mode);
  3882. return -EINVAL;
  3883. }
  3884. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3885. WCD_CLSH_EVENT_PRE_DAC,
  3886. WCD_CLSH_STATE_HPHR,
  3887. ((hph_mode == CLS_H_LOHIFI) ?
  3888. CLS_H_HIFI : hph_mode));
  3889. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3890. if (tasha->anc_func)
  3891. snd_soc_update_bits(codec,
  3892. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x10);
  3893. break;
  3894. case SND_SOC_DAPM_POST_PMU:
  3895. /* 1000us required as per HW requirement */
  3896. usleep_range(1000, 1100);
  3897. if ((hph_mode == CLS_H_LP) &&
  3898. (TASHA_IS_1_1(wcd9xxx))) {
  3899. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3900. 0x03, 0x03);
  3901. }
  3902. break;
  3903. case SND_SOC_DAPM_PRE_PMD:
  3904. if ((hph_mode == CLS_H_LP) &&
  3905. (TASHA_IS_1_1(wcd9xxx))) {
  3906. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3907. 0x03, 0x00);
  3908. }
  3909. break;
  3910. case SND_SOC_DAPM_POST_PMD:
  3911. /* 1000us required as per HW requirement */
  3912. usleep_range(1000, 1100);
  3913. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  3914. WCD_CLSH_STATE_HPHL))
  3915. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3916. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3917. WCD_CLSH_EVENT_POST_PA,
  3918. WCD_CLSH_STATE_HPHR,
  3919. ((hph_mode == CLS_H_LOHIFI) ?
  3920. CLS_H_HIFI : hph_mode));
  3921. break;
  3922. };
  3923. return ret;
  3924. }
  3925. static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
  3926. struct snd_kcontrol *kcontrol,
  3927. int event)
  3928. {
  3929. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3930. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3931. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3932. int hph_mode = tasha->hph_mode;
  3933. u8 dem_inp;
  3934. int ret = 0;
  3935. uint32_t impedl = 0, impedr = 0;
  3936. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3937. w->name, event, hph_mode);
  3938. switch (event) {
  3939. case SND_SOC_DAPM_PRE_PMU:
  3940. if (tasha->anc_func) {
  3941. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3942. /* 40 msec delay is needed to avoid click and pop */
  3943. msleep(40);
  3944. }
  3945. /* Read DEM INP Select */
  3946. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_SEC0) &
  3947. 0x03;
  3948. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3949. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3950. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3951. __func__, hph_mode);
  3952. return -EINVAL;
  3953. }
  3954. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3955. WCD_CLSH_EVENT_PRE_DAC,
  3956. WCD_CLSH_STATE_HPHL,
  3957. ((hph_mode == CLS_H_LOHIFI) ?
  3958. CLS_H_HIFI : hph_mode));
  3959. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3960. if (tasha->anc_func)
  3961. snd_soc_update_bits(codec,
  3962. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x10);
  3963. ret = wcd_mbhc_get_impedance(&tasha->mbhc,
  3964. &impedl, &impedr);
  3965. if (!ret) {
  3966. wcd_clsh_imped_config(codec, impedl, false);
  3967. set_bit(CLASSH_CONFIG, &tasha->status_mask);
  3968. } else {
  3969. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  3970. __func__, ret);
  3971. ret = 0;
  3972. }
  3973. break;
  3974. case SND_SOC_DAPM_POST_PMU:
  3975. /* 1000us required as per HW requirement */
  3976. usleep_range(1000, 1100);
  3977. if ((hph_mode == CLS_H_LP) &&
  3978. (TASHA_IS_1_1(wcd9xxx))) {
  3979. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3980. 0x03, 0x03);
  3981. }
  3982. break;
  3983. case SND_SOC_DAPM_PRE_PMD:
  3984. if ((hph_mode == CLS_H_LP) &&
  3985. (TASHA_IS_1_1(wcd9xxx))) {
  3986. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3987. 0x03, 0x00);
  3988. }
  3989. break;
  3990. case SND_SOC_DAPM_POST_PMD:
  3991. /* 1000us required as per HW requirement */
  3992. usleep_range(1000, 1100);
  3993. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  3994. WCD_CLSH_STATE_HPHR))
  3995. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3996. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3997. WCD_CLSH_EVENT_POST_PA,
  3998. WCD_CLSH_STATE_HPHL,
  3999. ((hph_mode == CLS_H_LOHIFI) ?
  4000. CLS_H_HIFI : hph_mode));
  4001. if (test_bit(CLASSH_CONFIG, &tasha->status_mask)) {
  4002. wcd_clsh_imped_config(codec, impedl, true);
  4003. clear_bit(CLASSH_CONFIG, &tasha->status_mask);
  4004. } else
  4005. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  4006. __func__, ret);
  4007. break;
  4008. };
  4009. return ret;
  4010. }
  4011. static int tasha_codec_lineout_dac_event(struct snd_soc_dapm_widget *w,
  4012. struct snd_kcontrol *kcontrol,
  4013. int event)
  4014. {
  4015. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4016. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4017. int ret = 0;
  4018. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4019. switch (event) {
  4020. case SND_SOC_DAPM_PRE_PMU:
  4021. if (tasha->anc_func &&
  4022. (!strcmp(w->name, "RX INT3 DAC") ||
  4023. !strcmp(w->name, "RX INT4 DAC")))
  4024. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4025. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4026. WCD_CLSH_EVENT_PRE_DAC,
  4027. WCD_CLSH_STATE_LO,
  4028. CLS_AB);
  4029. if (tasha->anc_func) {
  4030. if (!strcmp(w->name, "RX INT3 DAC"))
  4031. snd_soc_update_bits(codec,
  4032. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  4033. else if (!strcmp(w->name, "RX INT4 DAC"))
  4034. snd_soc_update_bits(codec,
  4035. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  4036. }
  4037. break;
  4038. case SND_SOC_DAPM_POST_PMD:
  4039. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4040. WCD_CLSH_EVENT_POST_PA,
  4041. WCD_CLSH_STATE_LO,
  4042. CLS_AB);
  4043. break;
  4044. }
  4045. return 0;
  4046. }
  4047. static const struct snd_soc_dapm_widget tasha_dapm_i2s_widgets[] = {
  4048. SND_SOC_DAPM_SUPPLY("RX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  4049. 0, 0, NULL, 0),
  4050. SND_SOC_DAPM_SUPPLY("TX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  4051. 0, 0, NULL, 0),
  4052. };
  4053. static int tasha_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
  4054. struct snd_kcontrol *kcontrol,
  4055. int event)
  4056. {
  4057. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4058. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4059. int ret = 0;
  4060. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4061. switch (event) {
  4062. case SND_SOC_DAPM_PRE_PMU:
  4063. if (tasha->anc_func)
  4064. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4065. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4066. WCD_CLSH_EVENT_PRE_DAC,
  4067. WCD_CLSH_STATE_EAR,
  4068. CLS_H_NORMAL);
  4069. if (tasha->anc_func)
  4070. snd_soc_update_bits(codec,
  4071. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x10);
  4072. break;
  4073. case SND_SOC_DAPM_POST_PMU:
  4074. break;
  4075. case SND_SOC_DAPM_PRE_PMD:
  4076. break;
  4077. case SND_SOC_DAPM_POST_PMD:
  4078. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4079. WCD_CLSH_EVENT_POST_PA,
  4080. WCD_CLSH_STATE_EAR,
  4081. CLS_H_NORMAL);
  4082. break;
  4083. };
  4084. return ret;
  4085. }
  4086. static int tasha_codec_spk_boost_event(struct snd_soc_dapm_widget *w,
  4087. struct snd_kcontrol *kcontrol,
  4088. int event)
  4089. {
  4090. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4091. u16 boost_path_ctl, boost_path_cfg1;
  4092. u16 reg, reg_mix;
  4093. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4094. if (!strcmp(w->name, "RX INT7 CHAIN")) {
  4095. boost_path_ctl = WCD9335_CDC_BOOST0_BOOST_PATH_CTL;
  4096. boost_path_cfg1 = WCD9335_CDC_RX7_RX_PATH_CFG1;
  4097. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4098. reg_mix = WCD9335_CDC_RX7_RX_PATH_MIX_CTL;
  4099. } else if (!strcmp(w->name, "RX INT8 CHAIN")) {
  4100. boost_path_ctl = WCD9335_CDC_BOOST1_BOOST_PATH_CTL;
  4101. boost_path_cfg1 = WCD9335_CDC_RX8_RX_PATH_CFG1;
  4102. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4103. reg_mix = WCD9335_CDC_RX8_RX_PATH_MIX_CTL;
  4104. } else {
  4105. dev_err(codec->dev, "%s: unknown widget: %s\n",
  4106. __func__, w->name);
  4107. return -EINVAL;
  4108. }
  4109. switch (event) {
  4110. case SND_SOC_DAPM_PRE_PMU:
  4111. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10);
  4112. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01);
  4113. snd_soc_update_bits(codec, reg, 0x10, 0x00);
  4114. if ((snd_soc_read(codec, reg_mix)) & 0x10)
  4115. snd_soc_update_bits(codec, reg_mix, 0x10, 0x00);
  4116. break;
  4117. case SND_SOC_DAPM_POST_PMD:
  4118. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00);
  4119. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00);
  4120. break;
  4121. };
  4122. return 0;
  4123. }
  4124. static u16 tasha_interp_get_primary_reg(u16 reg, u16 *ind)
  4125. {
  4126. u16 prim_int_reg = 0;
  4127. switch (reg) {
  4128. case WCD9335_CDC_RX0_RX_PATH_CTL:
  4129. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4130. prim_int_reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4131. *ind = 0;
  4132. break;
  4133. case WCD9335_CDC_RX1_RX_PATH_CTL:
  4134. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4135. prim_int_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4136. *ind = 1;
  4137. break;
  4138. case WCD9335_CDC_RX2_RX_PATH_CTL:
  4139. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4140. prim_int_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4141. *ind = 2;
  4142. break;
  4143. case WCD9335_CDC_RX3_RX_PATH_CTL:
  4144. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4145. prim_int_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4146. *ind = 3;
  4147. break;
  4148. case WCD9335_CDC_RX4_RX_PATH_CTL:
  4149. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4150. prim_int_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4151. *ind = 4;
  4152. break;
  4153. case WCD9335_CDC_RX5_RX_PATH_CTL:
  4154. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4155. prim_int_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4156. *ind = 5;
  4157. break;
  4158. case WCD9335_CDC_RX6_RX_PATH_CTL:
  4159. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4160. prim_int_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4161. *ind = 6;
  4162. break;
  4163. case WCD9335_CDC_RX7_RX_PATH_CTL:
  4164. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4165. prim_int_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4166. *ind = 7;
  4167. break;
  4168. case WCD9335_CDC_RX8_RX_PATH_CTL:
  4169. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4170. prim_int_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4171. *ind = 8;
  4172. break;
  4173. };
  4174. return prim_int_reg;
  4175. }
  4176. static void tasha_codec_hd2_control(struct snd_soc_codec *codec,
  4177. u16 prim_int_reg, int event)
  4178. {
  4179. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4180. u16 hd2_scale_reg;
  4181. u16 hd2_enable_reg = 0;
  4182. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  4183. return;
  4184. if (prim_int_reg == WCD9335_CDC_RX1_RX_PATH_CTL) {
  4185. hd2_scale_reg = WCD9335_CDC_RX1_RX_PATH_SEC3;
  4186. hd2_enable_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4187. }
  4188. if (prim_int_reg == WCD9335_CDC_RX2_RX_PATH_CTL) {
  4189. hd2_scale_reg = WCD9335_CDC_RX2_RX_PATH_SEC3;
  4190. hd2_enable_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4191. }
  4192. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) {
  4193. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x10);
  4194. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x01);
  4195. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04);
  4196. }
  4197. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
  4198. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00);
  4199. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x00);
  4200. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00);
  4201. }
  4202. }
  4203. static int tasha_codec_enable_prim_interpolator(
  4204. struct snd_soc_codec *codec,
  4205. u16 reg, int event)
  4206. {
  4207. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4208. u16 prim_int_reg;
  4209. u16 ind = 0;
  4210. prim_int_reg = tasha_interp_get_primary_reg(reg, &ind);
  4211. switch (event) {
  4212. case SND_SOC_DAPM_PRE_PMU:
  4213. tasha->prim_int_users[ind]++;
  4214. if (tasha->prim_int_users[ind] == 1) {
  4215. snd_soc_update_bits(codec, prim_int_reg,
  4216. 0x10, 0x10);
  4217. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4218. snd_soc_update_bits(codec, prim_int_reg,
  4219. 1 << 0x5, 1 << 0x5);
  4220. }
  4221. if ((reg != prim_int_reg) &&
  4222. ((snd_soc_read(codec, prim_int_reg)) & 0x10))
  4223. snd_soc_update_bits(codec, reg, 0x10, 0x10);
  4224. break;
  4225. case SND_SOC_DAPM_POST_PMD:
  4226. tasha->prim_int_users[ind]--;
  4227. if (tasha->prim_int_users[ind] == 0) {
  4228. snd_soc_update_bits(codec, prim_int_reg,
  4229. 1 << 0x5, 0 << 0x5);
  4230. snd_soc_update_bits(codec, prim_int_reg,
  4231. 0x40, 0x40);
  4232. snd_soc_update_bits(codec, prim_int_reg,
  4233. 0x40, 0x00);
  4234. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4235. }
  4236. break;
  4237. };
  4238. dev_dbg(codec->dev, "%s: primary interpolator: INT%d, users: %d\n",
  4239. __func__, ind, tasha->prim_int_users[ind]);
  4240. return 0;
  4241. }
  4242. static int tasha_codec_enable_spline_src(struct snd_soc_codec *codec,
  4243. int src_num,
  4244. int event)
  4245. {
  4246. u16 src_paired_reg = 0;
  4247. struct tasha_priv *tasha;
  4248. u16 rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4249. u16 rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4250. int *src_users, count, spl_src = SPLINE_SRC0;
  4251. u16 src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4252. tasha = snd_soc_codec_get_drvdata(codec);
  4253. switch (src_num) {
  4254. case SRC_IN_HPHL:
  4255. rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4256. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4257. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4258. rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4259. spl_src = SPLINE_SRC0;
  4260. break;
  4261. case SRC_IN_LO1:
  4262. rx_path_cfg_reg = WCD9335_CDC_RX3_RX_PATH_CFG0;
  4263. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4264. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4265. rx_path_ctl_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4266. spl_src = SPLINE_SRC0;
  4267. break;
  4268. case SRC_IN_HPHR:
  4269. rx_path_cfg_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4270. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4271. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4272. rx_path_ctl_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4273. spl_src = SPLINE_SRC1;
  4274. break;
  4275. case SRC_IN_LO2:
  4276. rx_path_cfg_reg = WCD9335_CDC_RX4_RX_PATH_CFG0;
  4277. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4278. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4279. rx_path_ctl_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4280. spl_src = SPLINE_SRC1;
  4281. break;
  4282. case SRC_IN_SPKRL:
  4283. rx_path_cfg_reg = WCD9335_CDC_RX7_RX_PATH_CFG0;
  4284. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4285. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4286. rx_path_ctl_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4287. spl_src = SPLINE_SRC2;
  4288. break;
  4289. case SRC_IN_LO3:
  4290. rx_path_cfg_reg = WCD9335_CDC_RX5_RX_PATH_CFG0;
  4291. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4292. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4293. rx_path_ctl_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4294. spl_src = SPLINE_SRC2;
  4295. break;
  4296. case SRC_IN_SPKRR:
  4297. rx_path_cfg_reg = WCD9335_CDC_RX8_RX_PATH_CFG0;
  4298. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4299. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4300. rx_path_ctl_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4301. spl_src = SPLINE_SRC3;
  4302. break;
  4303. case SRC_IN_LO4:
  4304. rx_path_cfg_reg = WCD9335_CDC_RX6_RX_PATH_CFG0;
  4305. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4306. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4307. rx_path_ctl_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4308. spl_src = SPLINE_SRC3;
  4309. break;
  4310. };
  4311. src_users = &tasha->spl_src_users[spl_src];
  4312. switch (event) {
  4313. case SND_SOC_DAPM_PRE_PMU:
  4314. count = *src_users;
  4315. count++;
  4316. if (count == 1) {
  4317. if ((snd_soc_read(codec, src_clk_reg) & 0x02) ||
  4318. (snd_soc_read(codec, src_paired_reg) & 0x02)) {
  4319. snd_soc_update_bits(codec, src_clk_reg, 0x02,
  4320. 0x00);
  4321. snd_soc_update_bits(codec, src_paired_reg,
  4322. 0x02, 0x00);
  4323. }
  4324. snd_soc_update_bits(codec, src_clk_reg, 0x01, 0x01);
  4325. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4326. 0x80);
  4327. }
  4328. *src_users = count;
  4329. break;
  4330. case SND_SOC_DAPM_POST_PMD:
  4331. count = *src_users;
  4332. count--;
  4333. if (count == 0) {
  4334. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4335. 0x00);
  4336. snd_soc_update_bits(codec, src_clk_reg, 0x03, 0x02);
  4337. /* default sample rate */
  4338. snd_soc_update_bits(codec, rx_path_ctl_reg, 0x0f,
  4339. 0x04);
  4340. }
  4341. *src_users = count;
  4342. break;
  4343. };
  4344. dev_dbg(codec->dev, "%s: Spline SRC%d, users: %d\n",
  4345. __func__, spl_src, *src_users);
  4346. return 0;
  4347. }
  4348. static int tasha_codec_enable_spline_resampler(struct snd_soc_dapm_widget *w,
  4349. struct snd_kcontrol *kcontrol,
  4350. int event)
  4351. {
  4352. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4353. int ret = 0;
  4354. u8 src_in;
  4355. src_in = snd_soc_read(codec, WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0);
  4356. if (!(src_in & 0xFF)) {
  4357. dev_err(codec->dev, "%s: Spline SRC%u input not selected\n",
  4358. __func__, w->shift);
  4359. return -EINVAL;
  4360. }
  4361. switch (w->shift) {
  4362. case SPLINE_SRC0:
  4363. ret = tasha_codec_enable_spline_src(codec,
  4364. ((src_in & 0x03) == 1) ? SRC_IN_HPHL : SRC_IN_LO1,
  4365. event);
  4366. break;
  4367. case SPLINE_SRC1:
  4368. ret = tasha_codec_enable_spline_src(codec,
  4369. ((src_in & 0x0C) == 4) ? SRC_IN_HPHR : SRC_IN_LO2,
  4370. event);
  4371. break;
  4372. case SPLINE_SRC2:
  4373. ret = tasha_codec_enable_spline_src(codec,
  4374. ((src_in & 0x30) == 0x10) ? SRC_IN_LO3 : SRC_IN_SPKRL,
  4375. event);
  4376. break;
  4377. case SPLINE_SRC3:
  4378. ret = tasha_codec_enable_spline_src(codec,
  4379. ((src_in & 0xC0) == 0x40) ? SRC_IN_LO4 : SRC_IN_SPKRR,
  4380. event);
  4381. break;
  4382. default:
  4383. dev_err(codec->dev, "%s: Invalid spline src:%u\n", __func__,
  4384. w->shift);
  4385. ret = -EINVAL;
  4386. };
  4387. return ret;
  4388. }
  4389. static int tasha_codec_enable_swr(struct snd_soc_dapm_widget *w,
  4390. struct snd_kcontrol *kcontrol, int event)
  4391. {
  4392. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4393. struct tasha_priv *tasha;
  4394. int i, ch_cnt;
  4395. tasha = snd_soc_codec_get_drvdata(codec);
  4396. if (!tasha->nr)
  4397. return 0;
  4398. switch (event) {
  4399. case SND_SOC_DAPM_PRE_PMU:
  4400. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4401. !tasha->rx_7_count)
  4402. tasha->rx_7_count++;
  4403. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4404. !tasha->rx_8_count)
  4405. tasha->rx_8_count++;
  4406. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4407. for (i = 0; i < tasha->nr; i++) {
  4408. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4409. SWR_DEVICE_UP, NULL);
  4410. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4411. SWR_SET_NUM_RX_CH, &ch_cnt);
  4412. }
  4413. break;
  4414. case SND_SOC_DAPM_POST_PMD:
  4415. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4416. tasha->rx_7_count)
  4417. tasha->rx_7_count--;
  4418. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4419. tasha->rx_8_count)
  4420. tasha->rx_8_count--;
  4421. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4422. for (i = 0; i < tasha->nr; i++)
  4423. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4424. SWR_SET_NUM_RX_CH, &ch_cnt);
  4425. break;
  4426. }
  4427. dev_dbg(tasha->dev, "%s: current swr ch cnt: %d\n",
  4428. __func__, tasha->rx_7_count + tasha->rx_8_count);
  4429. return 0;
  4430. }
  4431. static int tasha_codec_config_ear_spkr_gain(struct snd_soc_codec *codec,
  4432. int event, int gain_reg)
  4433. {
  4434. int comp_gain_offset, val;
  4435. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4436. switch (tasha->spkr_mode) {
  4437. /* Compander gain in SPKR_MODE1 case is 12 dB */
  4438. case SPKR_MODE_1:
  4439. comp_gain_offset = -12;
  4440. break;
  4441. /* Default case compander gain is 15 dB */
  4442. default:
  4443. comp_gain_offset = -15;
  4444. break;
  4445. }
  4446. switch (event) {
  4447. case SND_SOC_DAPM_POST_PMU:
  4448. /* Apply ear spkr gain only if compander is enabled */
  4449. if (tasha->comp_enabled[COMPANDER_7] &&
  4450. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4451. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4452. (tasha->ear_spkr_gain != 0)) {
  4453. /* For example, val is -8(-12+5-1) for 4dB of gain */
  4454. val = comp_gain_offset + tasha->ear_spkr_gain - 1;
  4455. snd_soc_write(codec, gain_reg, val);
  4456. dev_dbg(codec->dev, "%s: RX7 Volume %d dB\n",
  4457. __func__, val);
  4458. }
  4459. break;
  4460. case SND_SOC_DAPM_POST_PMD:
  4461. /*
  4462. * Reset RX7 volume to 0 dB if compander is enabled and
  4463. * ear_spkr_gain is non-zero.
  4464. */
  4465. if (tasha->comp_enabled[COMPANDER_7] &&
  4466. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4467. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4468. (tasha->ear_spkr_gain != 0)) {
  4469. snd_soc_write(codec, gain_reg, 0x0);
  4470. dev_dbg(codec->dev, "%s: Reset RX7 Volume to 0 dB\n",
  4471. __func__);
  4472. }
  4473. break;
  4474. }
  4475. return 0;
  4476. }
  4477. static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w,
  4478. struct snd_kcontrol *kcontrol, int event)
  4479. {
  4480. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4481. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4482. u16 gain_reg;
  4483. int offset_val = 0;
  4484. int val = 0;
  4485. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4486. switch (w->reg) {
  4487. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4488. gain_reg = WCD9335_CDC_RX0_RX_VOL_MIX_CTL;
  4489. break;
  4490. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4491. gain_reg = WCD9335_CDC_RX1_RX_VOL_MIX_CTL;
  4492. break;
  4493. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4494. gain_reg = WCD9335_CDC_RX2_RX_VOL_MIX_CTL;
  4495. break;
  4496. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4497. gain_reg = WCD9335_CDC_RX3_RX_VOL_MIX_CTL;
  4498. break;
  4499. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4500. gain_reg = WCD9335_CDC_RX4_RX_VOL_MIX_CTL;
  4501. break;
  4502. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4503. gain_reg = WCD9335_CDC_RX5_RX_VOL_MIX_CTL;
  4504. break;
  4505. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4506. gain_reg = WCD9335_CDC_RX6_RX_VOL_MIX_CTL;
  4507. break;
  4508. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4509. gain_reg = WCD9335_CDC_RX7_RX_VOL_MIX_CTL;
  4510. break;
  4511. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4512. gain_reg = WCD9335_CDC_RX8_RX_VOL_MIX_CTL;
  4513. break;
  4514. default:
  4515. dev_err(codec->dev, "%s: No gain register avail for %s\n",
  4516. __func__, w->name);
  4517. return 0;
  4518. };
  4519. switch (event) {
  4520. case SND_SOC_DAPM_POST_PMU:
  4521. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4522. (tasha->comp_enabled[COMPANDER_7] ||
  4523. tasha->comp_enabled[COMPANDER_8]) &&
  4524. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4525. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4526. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4527. 0x01, 0x01);
  4528. snd_soc_update_bits(codec,
  4529. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4530. 0x01, 0x01);
  4531. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4532. 0x01, 0x01);
  4533. snd_soc_update_bits(codec,
  4534. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4535. 0x01, 0x01);
  4536. offset_val = -2;
  4537. }
  4538. val = snd_soc_read(codec, gain_reg);
  4539. val += offset_val;
  4540. snd_soc_write(codec, gain_reg, val);
  4541. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4542. break;
  4543. case SND_SOC_DAPM_POST_PMD:
  4544. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4545. (tasha->comp_enabled[COMPANDER_7] ||
  4546. tasha->comp_enabled[COMPANDER_8]) &&
  4547. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4548. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4549. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4550. 0x01, 0x00);
  4551. snd_soc_update_bits(codec,
  4552. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4553. 0x01, 0x00);
  4554. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4555. 0x01, 0x00);
  4556. snd_soc_update_bits(codec,
  4557. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4558. 0x01, 0x00);
  4559. offset_val = 2;
  4560. val = snd_soc_read(codec, gain_reg);
  4561. val += offset_val;
  4562. snd_soc_write(codec, gain_reg, val);
  4563. }
  4564. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4565. break;
  4566. };
  4567. return 0;
  4568. }
  4569. static int __tasha_cdc_native_clk_enable(struct tasha_priv *tasha,
  4570. bool enable)
  4571. {
  4572. int ret = 0;
  4573. struct snd_soc_codec *codec = tasha->codec;
  4574. if (!tasha->wcd_native_clk) {
  4575. dev_err(tasha->dev, "%s: wcd native clock is NULL\n", __func__);
  4576. return -EINVAL;
  4577. }
  4578. dev_dbg(tasha->dev, "%s: native_clk_enable = %u\n", __func__, enable);
  4579. if (enable) {
  4580. ret = clk_prepare_enable(tasha->wcd_native_clk);
  4581. if (ret) {
  4582. dev_err(tasha->dev, "%s: native clk enable failed\n",
  4583. __func__);
  4584. goto err;
  4585. }
  4586. if (++tasha->native_clk_users == 1) {
  4587. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4588. 0x10, 0x10);
  4589. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4590. 0x80, 0x80);
  4591. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4592. 0x04, 0x00);
  4593. snd_soc_update_bits(codec,
  4594. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4595. 0x02, 0x02);
  4596. }
  4597. } else {
  4598. if (tasha->native_clk_users &&
  4599. (--tasha->native_clk_users == 0)) {
  4600. snd_soc_update_bits(codec,
  4601. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4602. 0x02, 0x00);
  4603. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4604. 0x04, 0x04);
  4605. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4606. 0x80, 0x00);
  4607. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4608. 0x10, 0x00);
  4609. }
  4610. clk_disable_unprepare(tasha->wcd_native_clk);
  4611. }
  4612. dev_dbg(codec->dev, "%s: native_clk_users: %d\n", __func__,
  4613. tasha->native_clk_users);
  4614. err:
  4615. return ret;
  4616. }
  4617. static int tasha_codec_get_native_fifo_sync_mask(struct snd_soc_codec *codec,
  4618. int interp_n)
  4619. {
  4620. int mask = 0;
  4621. u16 reg;
  4622. u8 val1, val2, inp0 = 0;
  4623. u8 inp1 = 0, inp2 = 0;
  4624. reg = WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0 + (2 * interp_n) - 2;
  4625. val1 = snd_soc_read(codec, reg);
  4626. val2 = snd_soc_read(codec, reg + 1);
  4627. inp0 = val1 & 0x0F;
  4628. inp1 = (val1 >> 4) & 0x0F;
  4629. inp2 = (val2 >> 4) & 0x0F;
  4630. if (IS_VALID_NATIVE_FIFO_PORT(inp0))
  4631. mask |= (1 << (inp0 - 5));
  4632. if (IS_VALID_NATIVE_FIFO_PORT(inp1))
  4633. mask |= (1 << (inp1 - 5));
  4634. if (IS_VALID_NATIVE_FIFO_PORT(inp2))
  4635. mask |= (1 << (inp2 - 5));
  4636. dev_dbg(codec->dev, "%s: native fifo mask: 0x%x\n", __func__, mask);
  4637. if (!mask)
  4638. dev_err(codec->dev, "native fifo err,int:%d,inp0:%d,inp1:%d,inp2:%d\n",
  4639. interp_n, inp0, inp1, inp2);
  4640. return mask;
  4641. }
  4642. static int tasha_enable_native_supply(struct snd_soc_dapm_widget *w,
  4643. struct snd_kcontrol *kcontrol, int event)
  4644. {
  4645. int mask;
  4646. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4647. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4648. u16 interp_reg;
  4649. dev_dbg(codec->dev, "%s: event: %d, shift:%d\n", __func__, event,
  4650. w->shift);
  4651. if (w->shift < INTERP_HPHL || w->shift > INTERP_LO2)
  4652. return -EINVAL;
  4653. interp_reg = WCD9335_CDC_RX1_RX_PATH_CTL + 20 * (w->shift - 1);
  4654. mask = tasha_codec_get_native_fifo_sync_mask(codec, w->shift);
  4655. if (!mask)
  4656. return -EINVAL;
  4657. switch (event) {
  4658. case SND_SOC_DAPM_PRE_PMU:
  4659. /* Adjust interpolator rate to 44P1_NATIVE */
  4660. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x09);
  4661. __tasha_cdc_native_clk_enable(tasha, true);
  4662. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4663. mask, mask);
  4664. break;
  4665. case SND_SOC_DAPM_PRE_PMD:
  4666. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4667. mask, 0x0);
  4668. __tasha_cdc_native_clk_enable(tasha, false);
  4669. /* Adjust interpolator rate to default */
  4670. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x04);
  4671. break;
  4672. }
  4673. return 0;
  4674. }
  4675. static int tasha_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
  4676. struct snd_kcontrol *kcontrol, int event)
  4677. {
  4678. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4679. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4680. u16 gain_reg;
  4681. u16 reg;
  4682. int val;
  4683. int offset_val = 0;
  4684. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4685. if (!(strcmp(w->name, "RX INT0 INTERP"))) {
  4686. reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4687. gain_reg = WCD9335_CDC_RX0_RX_VOL_CTL;
  4688. } else if (!(strcmp(w->name, "RX INT1 INTERP"))) {
  4689. reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4690. gain_reg = WCD9335_CDC_RX1_RX_VOL_CTL;
  4691. } else if (!(strcmp(w->name, "RX INT2 INTERP"))) {
  4692. reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4693. gain_reg = WCD9335_CDC_RX2_RX_VOL_CTL;
  4694. } else if (!(strcmp(w->name, "RX INT3 INTERP"))) {
  4695. reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4696. gain_reg = WCD9335_CDC_RX3_RX_VOL_CTL;
  4697. } else if (!(strcmp(w->name, "RX INT4 INTERP"))) {
  4698. reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4699. gain_reg = WCD9335_CDC_RX4_RX_VOL_CTL;
  4700. } else if (!(strcmp(w->name, "RX INT5 INTERP"))) {
  4701. reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4702. gain_reg = WCD9335_CDC_RX5_RX_VOL_CTL;
  4703. } else if (!(strcmp(w->name, "RX INT6 INTERP"))) {
  4704. reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4705. gain_reg = WCD9335_CDC_RX6_RX_VOL_CTL;
  4706. } else if (!(strcmp(w->name, "RX INT7 INTERP"))) {
  4707. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4708. gain_reg = WCD9335_CDC_RX7_RX_VOL_CTL;
  4709. } else if (!(strcmp(w->name, "RX INT8 INTERP"))) {
  4710. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4711. gain_reg = WCD9335_CDC_RX8_RX_VOL_CTL;
  4712. } else {
  4713. dev_err(codec->dev, "%s: Interpolator reg not found\n",
  4714. __func__);
  4715. return -EINVAL;
  4716. }
  4717. switch (event) {
  4718. case SND_SOC_DAPM_PRE_PMU:
  4719. tasha_codec_vote_max_bw(codec, true);
  4720. /* Reset if needed */
  4721. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4722. break;
  4723. case SND_SOC_DAPM_POST_PMU:
  4724. tasha_config_compander(codec, w->shift, event);
  4725. /* apply gain after int clk is enabled */
  4726. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4727. (tasha->comp_enabled[COMPANDER_7] ||
  4728. tasha->comp_enabled[COMPANDER_8]) &&
  4729. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4730. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4731. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4732. 0x01, 0x01);
  4733. snd_soc_update_bits(codec,
  4734. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4735. 0x01, 0x01);
  4736. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4737. 0x01, 0x01);
  4738. snd_soc_update_bits(codec,
  4739. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4740. 0x01, 0x01);
  4741. offset_val = -2;
  4742. }
  4743. val = snd_soc_read(codec, gain_reg);
  4744. val += offset_val;
  4745. snd_soc_write(codec, gain_reg, val);
  4746. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4747. break;
  4748. case SND_SOC_DAPM_POST_PMD:
  4749. tasha_config_compander(codec, w->shift, event);
  4750. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4751. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4752. (tasha->comp_enabled[COMPANDER_7] ||
  4753. tasha->comp_enabled[COMPANDER_8]) &&
  4754. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4755. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4756. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4757. 0x01, 0x00);
  4758. snd_soc_update_bits(codec,
  4759. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4760. 0x01, 0x00);
  4761. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4762. 0x01, 0x00);
  4763. snd_soc_update_bits(codec,
  4764. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4765. 0x01, 0x00);
  4766. offset_val = 2;
  4767. val = snd_soc_read(codec, gain_reg);
  4768. val += offset_val;
  4769. snd_soc_write(codec, gain_reg, val);
  4770. }
  4771. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4772. break;
  4773. };
  4774. return 0;
  4775. }
  4776. static int tasha_codec_set_iir_gain(struct snd_soc_dapm_widget *w,
  4777. struct snd_kcontrol *kcontrol, int event)
  4778. {
  4779. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4780. dev_dbg(codec->dev, "%s: event = %d\n", __func__, event);
  4781. switch (event) {
  4782. case SND_SOC_DAPM_POST_PMU: /* fall through */
  4783. case SND_SOC_DAPM_PRE_PMD:
  4784. if (strnstr(w->name, "IIR0", sizeof("IIR0"))) {
  4785. snd_soc_write(codec,
  4786. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL,
  4787. snd_soc_read(codec,
  4788. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL));
  4789. snd_soc_write(codec,
  4790. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL,
  4791. snd_soc_read(codec,
  4792. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL));
  4793. snd_soc_write(codec,
  4794. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL,
  4795. snd_soc_read(codec,
  4796. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL));
  4797. snd_soc_write(codec,
  4798. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL,
  4799. snd_soc_read(codec,
  4800. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL));
  4801. } else {
  4802. snd_soc_write(codec,
  4803. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL,
  4804. snd_soc_read(codec,
  4805. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL));
  4806. snd_soc_write(codec,
  4807. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL,
  4808. snd_soc_read(codec,
  4809. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL));
  4810. snd_soc_write(codec,
  4811. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL,
  4812. snd_soc_read(codec,
  4813. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL));
  4814. }
  4815. break;
  4816. }
  4817. return 0;
  4818. }
  4819. static int tasha_codec_enable_on_demand_supply(
  4820. struct snd_soc_dapm_widget *w,
  4821. struct snd_kcontrol *kcontrol, int event)
  4822. {
  4823. int ret = 0;
  4824. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4825. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4826. struct on_demand_supply *supply;
  4827. if (w->shift >= ON_DEMAND_SUPPLIES_MAX) {
  4828. dev_err(codec->dev, "%s: error index > MAX Demand supplies",
  4829. __func__);
  4830. ret = -EINVAL;
  4831. goto out;
  4832. }
  4833. dev_dbg(codec->dev, "%s: supply: %s event: %d\n",
  4834. __func__, on_demand_supply_name[w->shift], event);
  4835. supply = &tasha->on_demand_list[w->shift];
  4836. WARN_ONCE(!supply->supply, "%s isn't defined\n",
  4837. on_demand_supply_name[w->shift]);
  4838. if (!supply->supply) {
  4839. dev_err(codec->dev, "%s: err supply not present ond for %d",
  4840. __func__, w->shift);
  4841. goto out;
  4842. }
  4843. switch (event) {
  4844. case SND_SOC_DAPM_PRE_PMU:
  4845. ret = regulator_enable(supply->supply);
  4846. if (ret)
  4847. dev_err(codec->dev, "%s: Failed to enable %s\n",
  4848. __func__,
  4849. on_demand_supply_name[w->shift]);
  4850. break;
  4851. case SND_SOC_DAPM_POST_PMD:
  4852. ret = regulator_disable(supply->supply);
  4853. if (ret)
  4854. dev_err(codec->dev, "%s: Failed to disable %s\n",
  4855. __func__,
  4856. on_demand_supply_name[w->shift]);
  4857. break;
  4858. default:
  4859. break;
  4860. };
  4861. out:
  4862. return ret;
  4863. }
  4864. static int tasha_codec_find_amic_input(struct snd_soc_codec *codec,
  4865. int adc_mux_n)
  4866. {
  4867. u16 mask, shift, adc_mux_in_reg;
  4868. u16 amic_mux_sel_reg;
  4869. bool is_amic;
  4870. if (adc_mux_n < 0 || adc_mux_n > WCD9335_MAX_VALID_ADC_MUX ||
  4871. adc_mux_n == WCD9335_INVALID_ADC_MUX)
  4872. return 0;
  4873. /* Check whether adc mux input is AMIC or DMIC */
  4874. if (adc_mux_n < 4) {
  4875. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
  4876. 2 * adc_mux_n;
  4877. amic_mux_sel_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  4878. 2 * adc_mux_n;
  4879. mask = 0x03;
  4880. shift = 0;
  4881. } else {
  4882. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  4883. adc_mux_n - 4;
  4884. amic_mux_sel_reg = adc_mux_in_reg;
  4885. mask = 0xC0;
  4886. shift = 6;
  4887. }
  4888. is_amic = (((snd_soc_read(codec, adc_mux_in_reg) & mask) >> shift)
  4889. == 1);
  4890. if (!is_amic)
  4891. return 0;
  4892. return snd_soc_read(codec, amic_mux_sel_reg) & 0x07;
  4893. }
  4894. static void tasha_codec_set_tx_hold(struct snd_soc_codec *codec,
  4895. u16 amic_reg, bool set)
  4896. {
  4897. u8 mask = 0x20;
  4898. u8 val;
  4899. if (amic_reg == WCD9335_ANA_AMIC1 ||
  4900. amic_reg == WCD9335_ANA_AMIC3 ||
  4901. amic_reg == WCD9335_ANA_AMIC5)
  4902. mask = 0x40;
  4903. val = set ? mask : 0x00;
  4904. switch (amic_reg) {
  4905. case WCD9335_ANA_AMIC1:
  4906. case WCD9335_ANA_AMIC2:
  4907. snd_soc_update_bits(codec, WCD9335_ANA_AMIC2, mask, val);
  4908. break;
  4909. case WCD9335_ANA_AMIC3:
  4910. case WCD9335_ANA_AMIC4:
  4911. snd_soc_update_bits(codec, WCD9335_ANA_AMIC4, mask, val);
  4912. break;
  4913. case WCD9335_ANA_AMIC5:
  4914. case WCD9335_ANA_AMIC6:
  4915. snd_soc_update_bits(codec, WCD9335_ANA_AMIC6, mask, val);
  4916. break;
  4917. default:
  4918. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4919. __func__, amic_reg);
  4920. break;
  4921. }
  4922. }
  4923. static int tasha_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w,
  4924. struct snd_kcontrol *kcontrol, int event)
  4925. {
  4926. int adc_mux_n = w->shift;
  4927. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4928. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4929. int amic_n;
  4930. dev_dbg(codec->dev, "%s: event: %d\n", __func__, event);
  4931. switch (event) {
  4932. case SND_SOC_DAPM_POST_PMU:
  4933. amic_n = tasha_codec_find_amic_input(codec, adc_mux_n);
  4934. if (amic_n) {
  4935. /*
  4936. * Prevent ANC Rx pop by leaving Tx FE in HOLD
  4937. * state until PA is up. Track AMIC being used
  4938. * so we can release the HOLD later.
  4939. */
  4940. set_bit(ANC_MIC_AMIC1 + amic_n - 1,
  4941. &tasha->status_mask);
  4942. }
  4943. break;
  4944. default:
  4945. break;
  4946. }
  4947. return 0;
  4948. }
  4949. static u16 tasha_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic)
  4950. {
  4951. u16 pwr_level_reg = 0;
  4952. switch (amic) {
  4953. case 1:
  4954. case 2:
  4955. pwr_level_reg = WCD9335_ANA_AMIC1;
  4956. break;
  4957. case 3:
  4958. case 4:
  4959. pwr_level_reg = WCD9335_ANA_AMIC3;
  4960. break;
  4961. case 5:
  4962. case 6:
  4963. pwr_level_reg = WCD9335_ANA_AMIC5;
  4964. break;
  4965. default:
  4966. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4967. __func__, amic);
  4968. break;
  4969. }
  4970. return pwr_level_reg;
  4971. }
  4972. #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
  4973. #define CF_MIN_3DB_4HZ 0x0
  4974. #define CF_MIN_3DB_75HZ 0x1
  4975. #define CF_MIN_3DB_150HZ 0x2
  4976. static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work)
  4977. {
  4978. struct delayed_work *hpf_delayed_work;
  4979. struct hpf_work *hpf_work;
  4980. struct tasha_priv *tasha;
  4981. struct snd_soc_codec *codec;
  4982. u16 dec_cfg_reg, amic_reg;
  4983. u8 hpf_cut_off_freq;
  4984. int amic_n;
  4985. hpf_delayed_work = to_delayed_work(work);
  4986. hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
  4987. tasha = hpf_work->tasha;
  4988. codec = tasha->codec;
  4989. hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
  4990. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator;
  4991. dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
  4992. __func__, hpf_work->decimator, hpf_cut_off_freq);
  4993. amic_n = tasha_codec_find_amic_input(codec, hpf_work->decimator);
  4994. if (amic_n) {
  4995. amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1;
  4996. tasha_codec_set_tx_hold(codec, amic_reg, false);
  4997. }
  4998. tasha_codec_vote_max_bw(codec, true);
  4999. snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  5000. hpf_cut_off_freq << 5);
  5001. tasha_codec_vote_max_bw(codec, false);
  5002. }
  5003. static void tasha_tx_mute_update_callback(struct work_struct *work)
  5004. {
  5005. struct tx_mute_work *tx_mute_dwork;
  5006. struct tasha_priv *tasha;
  5007. struct delayed_work *delayed_work;
  5008. struct snd_soc_codec *codec;
  5009. u16 tx_vol_ctl_reg, hpf_gate_reg;
  5010. delayed_work = to_delayed_work(work);
  5011. tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
  5012. tasha = tx_mute_dwork->tasha;
  5013. codec = tasha->codec;
  5014. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  5015. 16 * tx_mute_dwork->decimator;
  5016. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 +
  5017. 16 * tx_mute_dwork->decimator;
  5018. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x01);
  5019. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5020. }
  5021. static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w,
  5022. struct snd_kcontrol *kcontrol, int event)
  5023. {
  5024. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5025. unsigned int decimator;
  5026. char *dec_adc_mux_name = NULL;
  5027. char *widget_name = NULL;
  5028. char *wname;
  5029. int ret = 0, amic_n;
  5030. u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
  5031. u16 tx_gain_ctl_reg;
  5032. char *dec;
  5033. u8 hpf_cut_off_freq;
  5034. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5035. dev_dbg(codec->dev, "%s %d\n", __func__, event);
  5036. widget_name = kstrndup(w->name, 15, GFP_KERNEL);
  5037. if (!widget_name)
  5038. return -ENOMEM;
  5039. wname = widget_name;
  5040. dec_adc_mux_name = strsep(&widget_name, " ");
  5041. if (!dec_adc_mux_name) {
  5042. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5043. __func__, w->name);
  5044. ret = -EINVAL;
  5045. goto out;
  5046. }
  5047. dec_adc_mux_name = widget_name;
  5048. dec = strpbrk(dec_adc_mux_name, "012345678");
  5049. if (!dec) {
  5050. dev_err(codec->dev, "%s: decimator index not found\n",
  5051. __func__);
  5052. ret = -EINVAL;
  5053. goto out;
  5054. }
  5055. ret = kstrtouint(dec, 10, &decimator);
  5056. if (ret < 0) {
  5057. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5058. __func__, wname);
  5059. ret = -EINVAL;
  5060. goto out;
  5061. }
  5062. dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__,
  5063. w->name, decimator);
  5064. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator;
  5065. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 + 16 * decimator;
  5066. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * decimator;
  5067. tx_gain_ctl_reg = WCD9335_CDC_TX0_TX_VOL_CTL + 16 * decimator;
  5068. switch (event) {
  5069. case SND_SOC_DAPM_PRE_PMU:
  5070. amic_n = tasha_codec_find_amic_input(codec, decimator);
  5071. if (amic_n)
  5072. pwr_level_reg = tasha_codec_get_amic_pwlvl_reg(codec,
  5073. amic_n);
  5074. if (pwr_level_reg) {
  5075. switch ((snd_soc_read(codec, pwr_level_reg) &
  5076. WCD9335_AMIC_PWR_LVL_MASK) >>
  5077. WCD9335_AMIC_PWR_LVL_SHIFT) {
  5078. case WCD9335_AMIC_PWR_LEVEL_LP:
  5079. snd_soc_update_bits(codec, dec_cfg_reg,
  5080. WCD9335_DEC_PWR_LVL_MASK,
  5081. WCD9335_DEC_PWR_LVL_LP);
  5082. break;
  5083. case WCD9335_AMIC_PWR_LEVEL_HP:
  5084. snd_soc_update_bits(codec, dec_cfg_reg,
  5085. WCD9335_DEC_PWR_LVL_MASK,
  5086. WCD9335_DEC_PWR_LVL_HP);
  5087. break;
  5088. case WCD9335_AMIC_PWR_LEVEL_DEFAULT:
  5089. default:
  5090. snd_soc_update_bits(codec, dec_cfg_reg,
  5091. WCD9335_DEC_PWR_LVL_MASK,
  5092. WCD9335_DEC_PWR_LVL_DF);
  5093. break;
  5094. }
  5095. }
  5096. hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) &
  5097. TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
  5098. tasha->tx_hpf_work[decimator].hpf_cut_off_freq =
  5099. hpf_cut_off_freq;
  5100. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
  5101. snd_soc_update_bits(codec, dec_cfg_reg,
  5102. TX_HPF_CUT_OFF_FREQ_MASK,
  5103. CF_MIN_3DB_150HZ << 5);
  5104. /* Enable TX PGA Mute */
  5105. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5106. break;
  5107. case SND_SOC_DAPM_POST_PMU:
  5108. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00);
  5109. if (decimator == 0) {
  5110. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5111. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0xA3);
  5112. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5113. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x03);
  5114. }
  5115. /* schedule work queue to Remove Mute */
  5116. schedule_delayed_work(&tasha->tx_mute_dwork[decimator].dwork,
  5117. msecs_to_jiffies(tx_unmute_delay));
  5118. if (tasha->tx_hpf_work[decimator].hpf_cut_off_freq !=
  5119. CF_MIN_3DB_150HZ)
  5120. schedule_delayed_work(
  5121. &tasha->tx_hpf_work[decimator].dwork,
  5122. msecs_to_jiffies(300));
  5123. /* apply gain after decimator is enabled */
  5124. snd_soc_write(codec, tx_gain_ctl_reg,
  5125. snd_soc_read(codec, tx_gain_ctl_reg));
  5126. break;
  5127. case SND_SOC_DAPM_PRE_PMD:
  5128. hpf_cut_off_freq =
  5129. tasha->tx_hpf_work[decimator].hpf_cut_off_freq;
  5130. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5131. if (cancel_delayed_work_sync(
  5132. &tasha->tx_hpf_work[decimator].dwork)) {
  5133. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  5134. tasha_codec_vote_max_bw(codec, true);
  5135. snd_soc_update_bits(codec, dec_cfg_reg,
  5136. TX_HPF_CUT_OFF_FREQ_MASK,
  5137. hpf_cut_off_freq << 5);
  5138. tasha_codec_vote_max_bw(codec, false);
  5139. }
  5140. }
  5141. cancel_delayed_work_sync(
  5142. &tasha->tx_mute_dwork[decimator].dwork);
  5143. break;
  5144. case SND_SOC_DAPM_POST_PMD:
  5145. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5146. break;
  5147. };
  5148. out:
  5149. kfree(wname);
  5150. return ret;
  5151. }
  5152. static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec,
  5153. unsigned int dmic, struct wcd9xxx_pdata *pdata)
  5154. {
  5155. u8 tx_stream_fs;
  5156. u8 adc_mux_index = 0, adc_mux_sel = 0;
  5157. bool dec_found = false;
  5158. u16 adc_mux_ctl_reg, tx_fs_reg;
  5159. u32 dmic_fs;
  5160. while (dec_found == 0 && adc_mux_index < WCD9335_MAX_VALID_ADC_MUX) {
  5161. if (adc_mux_index < 4) {
  5162. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  5163. (adc_mux_index * 2);
  5164. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5165. 0x78) >> 3) - 1;
  5166. } else if (adc_mux_index < 9) {
  5167. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  5168. ((adc_mux_index - 4) * 1);
  5169. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5170. 0x38) >> 3) - 1;
  5171. } else if (adc_mux_index == 9) {
  5172. ++adc_mux_index;
  5173. continue;
  5174. }
  5175. if (adc_mux_sel == dmic)
  5176. dec_found = true;
  5177. else
  5178. ++adc_mux_index;
  5179. }
  5180. if (dec_found == true && adc_mux_index <= 8) {
  5181. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index);
  5182. tx_stream_fs = snd_soc_read(codec, tx_fs_reg) & 0x0F;
  5183. dmic_fs = tx_stream_fs <= 4 ? WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ :
  5184. WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  5185. /*
  5186. * Check for ECPP path selection and DEC1 not connected to
  5187. * any other audio path to apply ECPP DMIC sample rate
  5188. */
  5189. if ((adc_mux_index == 1) &&
  5190. ((snd_soc_read(codec, WCD9335_CPE_SS_US_EC_MUX_CFG)
  5191. & 0x0F) == 0x0A) &&
  5192. ((snd_soc_read(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0)
  5193. & 0x0C) == 0x00)) {
  5194. dmic_fs = pdata->ecpp_dmic_sample_rate;
  5195. }
  5196. } else {
  5197. dmic_fs = pdata->dmic_sample_rate;
  5198. }
  5199. return dmic_fs;
  5200. }
  5201. static u8 tasha_get_dmic_clk_val(struct snd_soc_codec *codec,
  5202. u32 mclk_rate, u32 dmic_clk_rate)
  5203. {
  5204. u32 div_factor;
  5205. u8 dmic_ctl_val;
  5206. dev_dbg(codec->dev,
  5207. "%s: mclk_rate = %d, dmic_sample_rate = %d\n",
  5208. __func__, mclk_rate, dmic_clk_rate);
  5209. /* Default value to return in case of error */
  5210. if (mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  5211. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5212. else
  5213. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5214. if (dmic_clk_rate == 0) {
  5215. dev_err(codec->dev,
  5216. "%s: dmic_sample_rate cannot be 0\n",
  5217. __func__);
  5218. goto done;
  5219. }
  5220. div_factor = mclk_rate / dmic_clk_rate;
  5221. switch (div_factor) {
  5222. case 2:
  5223. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5224. break;
  5225. case 3:
  5226. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5227. break;
  5228. case 4:
  5229. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_4;
  5230. break;
  5231. case 6:
  5232. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_6;
  5233. break;
  5234. case 8:
  5235. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_8;
  5236. break;
  5237. case 16:
  5238. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_16;
  5239. break;
  5240. default:
  5241. dev_err(codec->dev,
  5242. "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n",
  5243. __func__, div_factor, mclk_rate, dmic_clk_rate);
  5244. break;
  5245. }
  5246. done:
  5247. return dmic_ctl_val;
  5248. }
  5249. static int tasha_codec_enable_adc(struct snd_soc_dapm_widget *w,
  5250. struct snd_kcontrol *kcontrol, int event)
  5251. {
  5252. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5253. dev_dbg(codec->dev, "%s: event:%d\n", __func__, event);
  5254. switch (event) {
  5255. case SND_SOC_DAPM_PRE_PMU:
  5256. tasha_codec_set_tx_hold(codec, w->reg, true);
  5257. break;
  5258. default:
  5259. break;
  5260. }
  5261. return 0;
  5262. }
  5263. static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w,
  5264. struct snd_kcontrol *kcontrol, int event)
  5265. {
  5266. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5267. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5268. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  5269. u8 dmic_clk_en = 0x01;
  5270. u16 dmic_clk_reg;
  5271. s32 *dmic_clk_cnt;
  5272. u8 dmic_rate_val, dmic_rate_shift = 1;
  5273. unsigned int dmic;
  5274. u32 dmic_sample_rate;
  5275. int ret;
  5276. char *wname;
  5277. wname = strpbrk(w->name, "012345");
  5278. if (!wname) {
  5279. dev_err(codec->dev, "%s: widget not found\n", __func__);
  5280. return -EINVAL;
  5281. }
  5282. ret = kstrtouint(wname, 10, &dmic);
  5283. if (ret < 0) {
  5284. dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n",
  5285. __func__);
  5286. return -EINVAL;
  5287. }
  5288. switch (dmic) {
  5289. case 0:
  5290. case 1:
  5291. dmic_clk_cnt = &(tasha->dmic_0_1_clk_cnt);
  5292. dmic_clk_reg = WCD9335_CPE_SS_DMIC0_CTL;
  5293. break;
  5294. case 2:
  5295. case 3:
  5296. dmic_clk_cnt = &(tasha->dmic_2_3_clk_cnt);
  5297. dmic_clk_reg = WCD9335_CPE_SS_DMIC1_CTL;
  5298. break;
  5299. case 4:
  5300. case 5:
  5301. dmic_clk_cnt = &(tasha->dmic_4_5_clk_cnt);
  5302. dmic_clk_reg = WCD9335_CPE_SS_DMIC2_CTL;
  5303. break;
  5304. default:
  5305. dev_err(codec->dev, "%s: Invalid DMIC Selection\n",
  5306. __func__);
  5307. return -EINVAL;
  5308. };
  5309. dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
  5310. __func__, event, dmic, *dmic_clk_cnt);
  5311. switch (event) {
  5312. case SND_SOC_DAPM_PRE_PMU:
  5313. dmic_sample_rate = tasha_get_dmic_sample_rate(codec, dmic,
  5314. pdata);
  5315. dmic_rate_val =
  5316. tasha_get_dmic_clk_val(codec,
  5317. pdata->mclk_rate,
  5318. dmic_sample_rate);
  5319. (*dmic_clk_cnt)++;
  5320. if (*dmic_clk_cnt == 1) {
  5321. snd_soc_update_bits(codec, dmic_clk_reg,
  5322. 0x07 << dmic_rate_shift,
  5323. dmic_rate_val << dmic_rate_shift);
  5324. snd_soc_update_bits(codec, dmic_clk_reg,
  5325. dmic_clk_en, dmic_clk_en);
  5326. }
  5327. break;
  5328. case SND_SOC_DAPM_POST_PMD:
  5329. dmic_rate_val =
  5330. tasha_get_dmic_clk_val(codec,
  5331. pdata->mclk_rate,
  5332. pdata->mad_dmic_sample_rate);
  5333. (*dmic_clk_cnt)--;
  5334. if (*dmic_clk_cnt == 0) {
  5335. snd_soc_update_bits(codec, dmic_clk_reg,
  5336. dmic_clk_en, 0);
  5337. snd_soc_update_bits(codec, dmic_clk_reg,
  5338. 0x07 << dmic_rate_shift,
  5339. dmic_rate_val << dmic_rate_shift);
  5340. }
  5341. break;
  5342. };
  5343. return 0;
  5344. }
  5345. static int __tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5346. int event)
  5347. {
  5348. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5349. int micb_num;
  5350. dev_dbg(codec->dev, "%s: wname: %s, event: %d\n",
  5351. __func__, w->name, event);
  5352. if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1")))
  5353. micb_num = MIC_BIAS_1;
  5354. else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2")))
  5355. micb_num = MIC_BIAS_2;
  5356. else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3")))
  5357. micb_num = MIC_BIAS_3;
  5358. else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4")))
  5359. micb_num = MIC_BIAS_4;
  5360. else
  5361. return -EINVAL;
  5362. switch (event) {
  5363. case SND_SOC_DAPM_PRE_PMU:
  5364. /*
  5365. * MIC BIAS can also be requested by MBHC,
  5366. * so use ref count to handle micbias pullup
  5367. * and enable requests
  5368. */
  5369. tasha_micbias_control(codec, micb_num, MICB_ENABLE, true);
  5370. break;
  5371. case SND_SOC_DAPM_POST_PMU:
  5372. /* wait for cnp time */
  5373. usleep_range(1000, 1100);
  5374. break;
  5375. case SND_SOC_DAPM_POST_PMD:
  5376. tasha_micbias_control(codec, micb_num, MICB_DISABLE, true);
  5377. break;
  5378. };
  5379. return 0;
  5380. }
  5381. static int tasha_codec_ldo_h_control(struct snd_soc_dapm_widget *w,
  5382. int event)
  5383. {
  5384. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5385. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5386. if (SND_SOC_DAPM_EVENT_ON(event)) {
  5387. tasha->ldo_h_users++;
  5388. if (tasha->ldo_h_users == 1)
  5389. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5390. 0x80, 0x80);
  5391. }
  5392. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  5393. tasha->ldo_h_users--;
  5394. if (tasha->ldo_h_users < 0)
  5395. tasha->ldo_h_users = 0;
  5396. if (tasha->ldo_h_users == 0)
  5397. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5398. 0x80, 0x00);
  5399. }
  5400. return 0;
  5401. }
  5402. static int tasha_codec_force_enable_ldo_h(struct snd_soc_dapm_widget *w,
  5403. struct snd_kcontrol *kcontrol,
  5404. int event)
  5405. {
  5406. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5407. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5408. switch (event) {
  5409. case SND_SOC_DAPM_PRE_PMU:
  5410. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5411. tasha_codec_ldo_h_control(w, event);
  5412. break;
  5413. case SND_SOC_DAPM_POST_PMD:
  5414. tasha_codec_ldo_h_control(w, event);
  5415. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5416. break;
  5417. }
  5418. return 0;
  5419. }
  5420. static int tasha_codec_force_enable_micbias(struct snd_soc_dapm_widget *w,
  5421. struct snd_kcontrol *kcontrol,
  5422. int event)
  5423. {
  5424. int ret = 0;
  5425. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5426. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5427. switch (event) {
  5428. case SND_SOC_DAPM_PRE_PMU:
  5429. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5430. tasha_cdc_mclk_enable(codec, true, true);
  5431. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_PRE_PMU);
  5432. /* Wait for 1ms for better cnp */
  5433. usleep_range(1000, 1100);
  5434. tasha_cdc_mclk_enable(codec, false, true);
  5435. break;
  5436. case SND_SOC_DAPM_POST_PMD:
  5437. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_POST_PMD);
  5438. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5439. break;
  5440. }
  5441. return ret;
  5442. }
  5443. static int tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5444. struct snd_kcontrol *kcontrol, int event)
  5445. {
  5446. return __tasha_codec_enable_micbias(w, event);
  5447. }
  5448. static int tasha_codec_enable_standalone_ldo_h(struct snd_soc_codec *codec,
  5449. bool enable)
  5450. {
  5451. int rc;
  5452. if (enable)
  5453. rc = snd_soc_dapm_force_enable_pin(
  5454. snd_soc_codec_get_dapm(codec),
  5455. DAPM_LDO_H_STANDALONE);
  5456. else
  5457. rc = snd_soc_dapm_disable_pin(
  5458. snd_soc_codec_get_dapm(codec),
  5459. DAPM_LDO_H_STANDALONE);
  5460. if (!rc)
  5461. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5462. else
  5463. dev_err(codec->dev, "%s: ldo_h force %s pin failed\n",
  5464. __func__, (enable ? "enable" : "disable"));
  5465. return rc;
  5466. }
  5467. /*
  5468. * tasha_codec_enable_standalone_micbias - enable micbias standalone
  5469. * @codec: pointer to codec instance
  5470. * @micb_num: number of micbias to be enabled
  5471. * @enable: true to enable micbias or false to disable
  5472. *
  5473. * This function is used to enable micbias (1, 2, 3 or 4) during
  5474. * standalone independent of whether TX use-case is running or not
  5475. *
  5476. * Return: error code in case of failure or 0 for success
  5477. */
  5478. int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
  5479. int micb_num,
  5480. bool enable)
  5481. {
  5482. const char * const micb_names[] = {
  5483. DAPM_MICBIAS1_STANDALONE, DAPM_MICBIAS2_STANDALONE,
  5484. DAPM_MICBIAS3_STANDALONE, DAPM_MICBIAS4_STANDALONE
  5485. };
  5486. int micb_index = micb_num - 1;
  5487. int rc;
  5488. if (!codec) {
  5489. pr_err("%s: Codec memory is NULL\n", __func__);
  5490. return -EINVAL;
  5491. }
  5492. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  5493. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  5494. __func__, micb_index);
  5495. return -EINVAL;
  5496. }
  5497. if (enable)
  5498. rc = snd_soc_dapm_force_enable_pin(
  5499. snd_soc_codec_get_dapm(codec),
  5500. micb_names[micb_index]);
  5501. else
  5502. rc = snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec),
  5503. micb_names[micb_index]);
  5504. if (!rc)
  5505. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5506. else
  5507. dev_err(codec->dev, "%s: micbias%d force %s pin failed\n",
  5508. __func__, micb_num, (enable ? "enable" : "disable"));
  5509. return rc;
  5510. }
  5511. EXPORT_SYMBOL(tasha_codec_enable_standalone_micbias);
  5512. static const char *const tasha_anc_func_text[] = {"OFF", "ON"};
  5513. static const struct soc_enum tasha_anc_func_enum =
  5514. SOC_ENUM_SINGLE_EXT(2, tasha_anc_func_text);
  5515. static const char *const tasha_clkmode_text[] = {"EXTERNAL", "INTERNAL"};
  5516. static SOC_ENUM_SINGLE_EXT_DECL(tasha_clkmode_enum, tasha_clkmode_text);
  5517. /* Cutoff frequency for high pass filter */
  5518. static const char * const cf_text[] = {
  5519. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
  5520. };
  5521. static const char * const rx_cf_text[] = {
  5522. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ",
  5523. "CF_NEG_3DB_0P48HZ"
  5524. };
  5525. static const struct soc_enum cf_dec0_enum =
  5526. SOC_ENUM_SINGLE(WCD9335_CDC_TX0_TX_PATH_CFG0, 5, 3, cf_text);
  5527. static const struct soc_enum cf_dec1_enum =
  5528. SOC_ENUM_SINGLE(WCD9335_CDC_TX1_TX_PATH_CFG0, 5, 3, cf_text);
  5529. static const struct soc_enum cf_dec2_enum =
  5530. SOC_ENUM_SINGLE(WCD9335_CDC_TX2_TX_PATH_CFG0, 5, 3, cf_text);
  5531. static const struct soc_enum cf_dec3_enum =
  5532. SOC_ENUM_SINGLE(WCD9335_CDC_TX3_TX_PATH_CFG0, 5, 3, cf_text);
  5533. static const struct soc_enum cf_dec4_enum =
  5534. SOC_ENUM_SINGLE(WCD9335_CDC_TX4_TX_PATH_CFG0, 5, 3, cf_text);
  5535. static const struct soc_enum cf_dec5_enum =
  5536. SOC_ENUM_SINGLE(WCD9335_CDC_TX5_TX_PATH_CFG0, 5, 3, cf_text);
  5537. static const struct soc_enum cf_dec6_enum =
  5538. SOC_ENUM_SINGLE(WCD9335_CDC_TX6_TX_PATH_CFG0, 5, 3, cf_text);
  5539. static const struct soc_enum cf_dec7_enum =
  5540. SOC_ENUM_SINGLE(WCD9335_CDC_TX7_TX_PATH_CFG0, 5, 3, cf_text);
  5541. static const struct soc_enum cf_dec8_enum =
  5542. SOC_ENUM_SINGLE(WCD9335_CDC_TX8_TX_PATH_CFG0, 5, 3, cf_text);
  5543. static const struct soc_enum cf_int0_1_enum =
  5544. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5545. static SOC_ENUM_SINGLE_DECL(cf_int0_2_enum, WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 2,
  5546. rx_cf_text);
  5547. static const struct soc_enum cf_int1_1_enum =
  5548. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5549. static SOC_ENUM_SINGLE_DECL(cf_int1_2_enum, WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 2,
  5550. rx_cf_text);
  5551. static const struct soc_enum cf_int2_1_enum =
  5552. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5553. static SOC_ENUM_SINGLE_DECL(cf_int2_2_enum, WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 2,
  5554. rx_cf_text);
  5555. static const struct soc_enum cf_int3_1_enum =
  5556. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5557. static SOC_ENUM_SINGLE_DECL(cf_int3_2_enum, WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 2,
  5558. rx_cf_text);
  5559. static const struct soc_enum cf_int4_1_enum =
  5560. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5561. static SOC_ENUM_SINGLE_DECL(cf_int4_2_enum, WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 2,
  5562. rx_cf_text);
  5563. static const struct soc_enum cf_int5_1_enum =
  5564. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5565. static SOC_ENUM_SINGLE_DECL(cf_int5_2_enum, WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 2,
  5566. rx_cf_text);
  5567. static const struct soc_enum cf_int6_1_enum =
  5568. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5569. static SOC_ENUM_SINGLE_DECL(cf_int6_2_enum, WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 2,
  5570. rx_cf_text);
  5571. static const struct soc_enum cf_int7_1_enum =
  5572. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5573. static SOC_ENUM_SINGLE_DECL(cf_int7_2_enum, WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 2,
  5574. rx_cf_text);
  5575. static const struct soc_enum cf_int8_1_enum =
  5576. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5577. static SOC_ENUM_SINGLE_DECL(cf_int8_2_enum, WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 2,
  5578. rx_cf_text);
  5579. static const struct snd_soc_dapm_route audio_i2s_map[] = {
  5580. {"SLIM RX0 MUX", NULL, "RX_I2S_CTL"},
  5581. {"SLIM RX1 MUX", NULL, "RX_I2S_CTL"},
  5582. {"SLIM RX2 MUX", NULL, "RX_I2S_CTL"},
  5583. {"SLIM RX3 MUX", NULL, "RX_I2S_CTL"},
  5584. {"SLIM TX6 MUX", NULL, "TX_I2S_CTL"},
  5585. {"SLIM TX7 MUX", NULL, "TX_I2S_CTL"},
  5586. {"SLIM TX8 MUX", NULL, "TX_I2S_CTL"},
  5587. {"SLIM TX11 MUX", NULL, "TX_I2S_CTL"},
  5588. };
  5589. static const struct snd_soc_dapm_route audio_map[] = {
  5590. /* MAD */
  5591. {"MAD_SEL MUX", "SPE", "MAD_CPE_INPUT"},
  5592. {"MAD_SEL MUX", "MSM", "MADINPUT"},
  5593. {"MADONOFF", "Switch", "MAD_SEL MUX"},
  5594. {"MAD_BROADCAST", "Switch", "MAD_SEL MUX"},
  5595. {"TX13 INP MUX", "CPE_TX_PP", "MADONOFF"},
  5596. /* CPE HW MAD bypass */
  5597. {"CPE IN Mixer", "MAD_BYPASS", "SLIM TX1 MUX"},
  5598. {"AIF4_MAD Mixer", "SLIM TX1", "CPE IN Mixer"},
  5599. {"AIF4_MAD Mixer", "SLIM TX12", "MADONOFF"},
  5600. {"AIF4_MAD Mixer", "SLIM TX13", "TX13 INP MUX"},
  5601. {"AIF4 MAD", NULL, "AIF4_MAD Mixer"},
  5602. {"AIF4 MAD", NULL, "AIF4"},
  5603. {"EC BUF MUX INP", "DEC1", "ADC MUX1"},
  5604. {"AIF5 CPE", NULL, "EC BUF MUX INP"},
  5605. /* SLIMBUS Connections */
  5606. {"AIF1 CAP", NULL, "AIF1_CAP Mixer"},
  5607. {"AIF2 CAP", NULL, "AIF2_CAP Mixer"},
  5608. {"AIF3 CAP", NULL, "AIF3_CAP Mixer"},
  5609. /* VI Feedback */
  5610. {"AIF4_VI Mixer", "SPKR_VI_1", "VIINPUT"},
  5611. {"AIF4_VI Mixer", "SPKR_VI_2", "VIINPUT"},
  5612. {"AIF4 VI", NULL, "AIF4_VI Mixer"},
  5613. /* SLIM_MIXER("AIF1_CAP Mixer"),*/
  5614. {"AIF1_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5615. {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5616. {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5617. {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5618. {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5619. {"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5620. {"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5621. {"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5622. {"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5623. {"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5624. {"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5625. {"AIF1_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5626. {"AIF1_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5627. /* SLIM_MIXER("AIF2_CAP Mixer"),*/
  5628. {"AIF2_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5629. {"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5630. {"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5631. {"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5632. {"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5633. {"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5634. {"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5635. {"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5636. {"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5637. {"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5638. {"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5639. {"AIF2_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5640. {"AIF2_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5641. /* SLIM_MIXER("AIF3_CAP Mixer"),*/
  5642. {"AIF3_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5643. {"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5644. {"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5645. {"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5646. {"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5647. {"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5648. {"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5649. {"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5650. {"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5651. {"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5652. {"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5653. {"AIF3_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5654. {"AIF3_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5655. {"SLIM TX0 MUX", "DEC0", "ADC MUX0"},
  5656. {"SLIM TX0 MUX", "RX_MIX_TX0", "RX MIX TX0 MUX"},
  5657. {"SLIM TX0 MUX", "DEC0_192", "ADC US MUX0"},
  5658. {"SLIM TX1 MUX", "DEC1", "ADC MUX1"},
  5659. {"SLIM TX1 MUX", "RX_MIX_TX1", "RX MIX TX1 MUX"},
  5660. {"SLIM TX1 MUX", "DEC1_192", "ADC US MUX1"},
  5661. {"SLIM TX2 MUX", "DEC2", "ADC MUX2"},
  5662. {"SLIM TX2 MUX", "RX_MIX_TX2", "RX MIX TX2 MUX"},
  5663. {"SLIM TX2 MUX", "DEC2_192", "ADC US MUX2"},
  5664. {"SLIM TX3 MUX", "DEC3", "ADC MUX3"},
  5665. {"SLIM TX3 MUX", "RX_MIX_TX3", "RX MIX TX3 MUX"},
  5666. {"SLIM TX3 MUX", "DEC3_192", "ADC US MUX3"},
  5667. {"SLIM TX4 MUX", "DEC4", "ADC MUX4"},
  5668. {"SLIM TX4 MUX", "RX_MIX_TX4", "RX MIX TX4 MUX"},
  5669. {"SLIM TX4 MUX", "DEC4_192", "ADC US MUX4"},
  5670. {"SLIM TX5 MUX", "DEC5", "ADC MUX5"},
  5671. {"SLIM TX5 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5672. {"SLIM TX5 MUX", "DEC5_192", "ADC US MUX5"},
  5673. {"SLIM TX6 MUX", "DEC6", "ADC MUX6"},
  5674. {"SLIM TX6 MUX", "RX_MIX_TX6", "RX MIX TX6 MUX"},
  5675. {"SLIM TX6 MUX", "DEC6_192", "ADC US MUX6"},
  5676. {"SLIM TX7 MUX", "DEC7", "ADC MUX7"},
  5677. {"SLIM TX7 MUX", "RX_MIX_TX7", "RX MIX TX7 MUX"},
  5678. {"SLIM TX7 MUX", "DEC7_192", "ADC US MUX7"},
  5679. {"SLIM TX8 MUX", "DEC8", "ADC MUX8"},
  5680. {"SLIM TX8 MUX", "RX_MIX_TX8", "RX MIX TX8 MUX"},
  5681. {"SLIM TX8 MUX", "DEC8_192", "ADC US MUX8"},
  5682. {"SLIM TX9 MUX", "DEC7", "ADC MUX7"},
  5683. {"SLIM TX9 MUX", "DEC7_192", "ADC US MUX7"},
  5684. {"SLIM TX10 MUX", "DEC6", "ADC MUX6"},
  5685. {"SLIM TX10 MUX", "DEC6_192", "ADC US MUX6"},
  5686. {"SLIM TX11 MUX", "DEC_0_5", "SLIM TX11 INP1 MUX"},
  5687. {"SLIM TX11 MUX", "DEC_9_12", "SLIM TX11 INP1 MUX"},
  5688. {"SLIM TX11 INP1 MUX", "DEC0", "ADC MUX0"},
  5689. {"SLIM TX11 INP1 MUX", "DEC1", "ADC MUX1"},
  5690. {"SLIM TX11 INP1 MUX", "DEC2", "ADC MUX2"},
  5691. {"SLIM TX11 INP1 MUX", "DEC3", "ADC MUX3"},
  5692. {"SLIM TX11 INP1 MUX", "DEC4", "ADC MUX4"},
  5693. {"SLIM TX11 INP1 MUX", "DEC5", "ADC MUX5"},
  5694. {"SLIM TX11 INP1 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5695. {"TX13 INP MUX", "MAD_BRDCST", "MAD_BROADCAST"},
  5696. {"TX13 INP MUX", "CDC_DEC_5", "SLIM TX13 MUX"},
  5697. {"SLIM TX13 MUX", "DEC5", "ADC MUX5"},
  5698. {"RX MIX TX0 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5699. {"RX MIX TX0 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5700. {"RX MIX TX0 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5701. {"RX MIX TX0 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5702. {"RX MIX TX0 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5703. {"RX MIX TX0 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5704. {"RX MIX TX0 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5705. {"RX MIX TX0 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5706. {"RX MIX TX0 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5707. {"RX MIX TX0 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5708. {"RX MIX TX0 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5709. {"RX MIX TX0 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5710. {"RX MIX TX0 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5711. {"RX MIX TX1 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5712. {"RX MIX TX1 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5713. {"RX MIX TX1 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5714. {"RX MIX TX1 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5715. {"RX MIX TX1 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5716. {"RX MIX TX1 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5717. {"RX MIX TX1 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5718. {"RX MIX TX1 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5719. {"RX MIX TX1 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5720. {"RX MIX TX1 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5721. {"RX MIX TX1 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5722. {"RX MIX TX1 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5723. {"RX MIX TX1 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5724. {"RX MIX TX2 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5725. {"RX MIX TX2 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5726. {"RX MIX TX2 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5727. {"RX MIX TX2 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5728. {"RX MIX TX2 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5729. {"RX MIX TX2 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5730. {"RX MIX TX2 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5731. {"RX MIX TX2 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5732. {"RX MIX TX2 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5733. {"RX MIX TX2 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5734. {"RX MIX TX2 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5735. {"RX MIX TX2 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5736. {"RX MIX TX2 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5737. {"RX MIX TX3 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5738. {"RX MIX TX3 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5739. {"RX MIX TX3 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5740. {"RX MIX TX3 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5741. {"RX MIX TX3 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5742. {"RX MIX TX3 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5743. {"RX MIX TX3 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5744. {"RX MIX TX3 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5745. {"RX MIX TX3 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5746. {"RX MIX TX3 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5747. {"RX MIX TX3 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5748. {"RX MIX TX3 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5749. {"RX MIX TX3 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5750. {"RX MIX TX4 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5751. {"RX MIX TX4 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5752. {"RX MIX TX4 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5753. {"RX MIX TX4 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5754. {"RX MIX TX4 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5755. {"RX MIX TX4 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5756. {"RX MIX TX4 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5757. {"RX MIX TX4 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5758. {"RX MIX TX4 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5759. {"RX MIX TX4 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5760. {"RX MIX TX4 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5761. {"RX MIX TX4 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5762. {"RX MIX TX4 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5763. {"RX MIX TX5 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5764. {"RX MIX TX5 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5765. {"RX MIX TX5 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5766. {"RX MIX TX5 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5767. {"RX MIX TX5 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5768. {"RX MIX TX5 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5769. {"RX MIX TX5 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5770. {"RX MIX TX5 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5771. {"RX MIX TX5 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5772. {"RX MIX TX5 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5773. {"RX MIX TX5 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5774. {"RX MIX TX5 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5775. {"RX MIX TX5 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5776. {"RX MIX TX6 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5777. {"RX MIX TX6 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5778. {"RX MIX TX6 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5779. {"RX MIX TX6 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5780. {"RX MIX TX6 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5781. {"RX MIX TX6 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5782. {"RX MIX TX6 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5783. {"RX MIX TX6 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5784. {"RX MIX TX6 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5785. {"RX MIX TX6 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5786. {"RX MIX TX6 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5787. {"RX MIX TX6 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5788. {"RX MIX TX6 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5789. {"RX MIX TX7 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5790. {"RX MIX TX7 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5791. {"RX MIX TX7 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5792. {"RX MIX TX7 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5793. {"RX MIX TX7 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5794. {"RX MIX TX7 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5795. {"RX MIX TX7 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5796. {"RX MIX TX7 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5797. {"RX MIX TX7 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5798. {"RX MIX TX7 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5799. {"RX MIX TX7 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5800. {"RX MIX TX7 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5801. {"RX MIX TX7 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5802. {"RX MIX TX8 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5803. {"RX MIX TX8 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5804. {"RX MIX TX8 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5805. {"RX MIX TX8 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5806. {"RX MIX TX8 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5807. {"RX MIX TX8 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5808. {"RX MIX TX8 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5809. {"RX MIX TX8 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5810. {"RX MIX TX8 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5811. {"RX MIX TX8 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5812. {"RX MIX TX8 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5813. {"RX MIX TX8 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5814. {"RX MIX TX8 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5815. {"ADC US MUX0", "US_Switch", "ADC MUX0"},
  5816. {"ADC US MUX1", "US_Switch", "ADC MUX1"},
  5817. {"ADC US MUX2", "US_Switch", "ADC MUX2"},
  5818. {"ADC US MUX3", "US_Switch", "ADC MUX3"},
  5819. {"ADC US MUX4", "US_Switch", "ADC MUX4"},
  5820. {"ADC US MUX5", "US_Switch", "ADC MUX5"},
  5821. {"ADC US MUX6", "US_Switch", "ADC MUX6"},
  5822. {"ADC US MUX7", "US_Switch", "ADC MUX7"},
  5823. {"ADC US MUX8", "US_Switch", "ADC MUX8"},
  5824. {"ADC MUX0", "DMIC", "DMIC MUX0"},
  5825. {"ADC MUX0", "AMIC", "AMIC MUX0"},
  5826. {"ADC MUX1", "DMIC", "DMIC MUX1"},
  5827. {"ADC MUX1", "AMIC", "AMIC MUX1"},
  5828. {"ADC MUX2", "DMIC", "DMIC MUX2"},
  5829. {"ADC MUX2", "AMIC", "AMIC MUX2"},
  5830. {"ADC MUX3", "DMIC", "DMIC MUX3"},
  5831. {"ADC MUX3", "AMIC", "AMIC MUX3"},
  5832. {"ADC MUX4", "DMIC", "DMIC MUX4"},
  5833. {"ADC MUX4", "AMIC", "AMIC MUX4"},
  5834. {"ADC MUX5", "DMIC", "DMIC MUX5"},
  5835. {"ADC MUX5", "AMIC", "AMIC MUX5"},
  5836. {"ADC MUX6", "DMIC", "DMIC MUX6"},
  5837. {"ADC MUX6", "AMIC", "AMIC MUX6"},
  5838. {"ADC MUX7", "DMIC", "DMIC MUX7"},
  5839. {"ADC MUX7", "AMIC", "AMIC MUX7"},
  5840. {"ADC MUX8", "DMIC", "DMIC MUX8"},
  5841. {"ADC MUX8", "AMIC", "AMIC MUX8"},
  5842. {"ADC MUX10", "DMIC", "DMIC MUX10"},
  5843. {"ADC MUX10", "AMIC", "AMIC MUX10"},
  5844. {"ADC MUX11", "DMIC", "DMIC MUX11"},
  5845. {"ADC MUX11", "AMIC", "AMIC MUX11"},
  5846. {"ADC MUX12", "DMIC", "DMIC MUX12"},
  5847. {"ADC MUX12", "AMIC", "AMIC MUX12"},
  5848. {"ADC MUX13", "DMIC", "DMIC MUX13"},
  5849. {"ADC MUX13", "AMIC", "AMIC MUX13"},
  5850. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX10"},
  5851. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX11"},
  5852. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX12"},
  5853. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX13"},
  5854. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX10"},
  5855. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX11"},
  5856. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX12"},
  5857. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX13"},
  5858. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX10"},
  5859. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX11"},
  5860. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX12"},
  5861. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX13"},
  5862. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX10"},
  5863. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX11"},
  5864. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX12"},
  5865. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX13"},
  5866. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX10"},
  5867. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX11"},
  5868. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX12"},
  5869. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX13"},
  5870. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX10"},
  5871. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX11"},
  5872. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX12"},
  5873. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX13"},
  5874. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX10"},
  5875. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX11"},
  5876. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX12"},
  5877. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX13"},
  5878. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX10"},
  5879. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX11"},
  5880. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX12"},
  5881. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX13"},
  5882. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX10"},
  5883. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX11"},
  5884. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX12"},
  5885. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX13"},
  5886. {"DMIC MUX0", "DMIC0", "DMIC0"},
  5887. {"DMIC MUX0", "DMIC1", "DMIC1"},
  5888. {"DMIC MUX0", "DMIC2", "DMIC2"},
  5889. {"DMIC MUX0", "DMIC3", "DMIC3"},
  5890. {"DMIC MUX0", "DMIC4", "DMIC4"},
  5891. {"DMIC MUX0", "DMIC5", "DMIC5"},
  5892. {"AMIC MUX0", "ADC1", "ADC1"},
  5893. {"AMIC MUX0", "ADC2", "ADC2"},
  5894. {"AMIC MUX0", "ADC3", "ADC3"},
  5895. {"AMIC MUX0", "ADC4", "ADC4"},
  5896. {"AMIC MUX0", "ADC5", "ADC5"},
  5897. {"AMIC MUX0", "ADC6", "ADC6"},
  5898. {"DMIC MUX1", "DMIC0", "DMIC0"},
  5899. {"DMIC MUX1", "DMIC1", "DMIC1"},
  5900. {"DMIC MUX1", "DMIC2", "DMIC2"},
  5901. {"DMIC MUX1", "DMIC3", "DMIC3"},
  5902. {"DMIC MUX1", "DMIC4", "DMIC4"},
  5903. {"DMIC MUX1", "DMIC5", "DMIC5"},
  5904. {"AMIC MUX1", "ADC1", "ADC1"},
  5905. {"AMIC MUX1", "ADC2", "ADC2"},
  5906. {"AMIC MUX1", "ADC3", "ADC3"},
  5907. {"AMIC MUX1", "ADC4", "ADC4"},
  5908. {"AMIC MUX1", "ADC5", "ADC5"},
  5909. {"AMIC MUX1", "ADC6", "ADC6"},
  5910. {"DMIC MUX2", "DMIC0", "DMIC0"},
  5911. {"DMIC MUX2", "DMIC1", "DMIC1"},
  5912. {"DMIC MUX2", "DMIC2", "DMIC2"},
  5913. {"DMIC MUX2", "DMIC3", "DMIC3"},
  5914. {"DMIC MUX2", "DMIC4", "DMIC4"},
  5915. {"DMIC MUX2", "DMIC5", "DMIC5"},
  5916. {"AMIC MUX2", "ADC1", "ADC1"},
  5917. {"AMIC MUX2", "ADC2", "ADC2"},
  5918. {"AMIC MUX2", "ADC3", "ADC3"},
  5919. {"AMIC MUX2", "ADC4", "ADC4"},
  5920. {"AMIC MUX2", "ADC5", "ADC5"},
  5921. {"AMIC MUX2", "ADC6", "ADC6"},
  5922. {"DMIC MUX3", "DMIC0", "DMIC0"},
  5923. {"DMIC MUX3", "DMIC1", "DMIC1"},
  5924. {"DMIC MUX3", "DMIC2", "DMIC2"},
  5925. {"DMIC MUX3", "DMIC3", "DMIC3"},
  5926. {"DMIC MUX3", "DMIC4", "DMIC4"},
  5927. {"DMIC MUX3", "DMIC5", "DMIC5"},
  5928. {"AMIC MUX3", "ADC1", "ADC1"},
  5929. {"AMIC MUX3", "ADC2", "ADC2"},
  5930. {"AMIC MUX3", "ADC3", "ADC3"},
  5931. {"AMIC MUX3", "ADC4", "ADC4"},
  5932. {"AMIC MUX3", "ADC5", "ADC5"},
  5933. {"AMIC MUX3", "ADC6", "ADC6"},
  5934. {"DMIC MUX4", "DMIC0", "DMIC0"},
  5935. {"DMIC MUX4", "DMIC1", "DMIC1"},
  5936. {"DMIC MUX4", "DMIC2", "DMIC2"},
  5937. {"DMIC MUX4", "DMIC3", "DMIC3"},
  5938. {"DMIC MUX4", "DMIC4", "DMIC4"},
  5939. {"DMIC MUX4", "DMIC5", "DMIC5"},
  5940. {"AMIC MUX4", "ADC1", "ADC1"},
  5941. {"AMIC MUX4", "ADC2", "ADC2"},
  5942. {"AMIC MUX4", "ADC3", "ADC3"},
  5943. {"AMIC MUX4", "ADC4", "ADC4"},
  5944. {"AMIC MUX4", "ADC5", "ADC5"},
  5945. {"AMIC MUX4", "ADC6", "ADC6"},
  5946. {"DMIC MUX5", "DMIC0", "DMIC0"},
  5947. {"DMIC MUX5", "DMIC1", "DMIC1"},
  5948. {"DMIC MUX5", "DMIC2", "DMIC2"},
  5949. {"DMIC MUX5", "DMIC3", "DMIC3"},
  5950. {"DMIC MUX5", "DMIC4", "DMIC4"},
  5951. {"DMIC MUX5", "DMIC5", "DMIC5"},
  5952. {"AMIC MUX5", "ADC1", "ADC1"},
  5953. {"AMIC MUX5", "ADC2", "ADC2"},
  5954. {"AMIC MUX5", "ADC3", "ADC3"},
  5955. {"AMIC MUX5", "ADC4", "ADC4"},
  5956. {"AMIC MUX5", "ADC5", "ADC5"},
  5957. {"AMIC MUX5", "ADC6", "ADC6"},
  5958. {"DMIC MUX6", "DMIC0", "DMIC0"},
  5959. {"DMIC MUX6", "DMIC1", "DMIC1"},
  5960. {"DMIC MUX6", "DMIC2", "DMIC2"},
  5961. {"DMIC MUX6", "DMIC3", "DMIC3"},
  5962. {"DMIC MUX6", "DMIC4", "DMIC4"},
  5963. {"DMIC MUX6", "DMIC5", "DMIC5"},
  5964. {"AMIC MUX6", "ADC1", "ADC1"},
  5965. {"AMIC MUX6", "ADC2", "ADC2"},
  5966. {"AMIC MUX6", "ADC3", "ADC3"},
  5967. {"AMIC MUX6", "ADC4", "ADC4"},
  5968. {"AMIC MUX6", "ADC5", "ADC5"},
  5969. {"AMIC MUX6", "ADC6", "ADC6"},
  5970. {"DMIC MUX7", "DMIC0", "DMIC0"},
  5971. {"DMIC MUX7", "DMIC1", "DMIC1"},
  5972. {"DMIC MUX7", "DMIC2", "DMIC2"},
  5973. {"DMIC MUX7", "DMIC3", "DMIC3"},
  5974. {"DMIC MUX7", "DMIC4", "DMIC4"},
  5975. {"DMIC MUX7", "DMIC5", "DMIC5"},
  5976. {"AMIC MUX7", "ADC1", "ADC1"},
  5977. {"AMIC MUX7", "ADC2", "ADC2"},
  5978. {"AMIC MUX7", "ADC3", "ADC3"},
  5979. {"AMIC MUX7", "ADC4", "ADC4"},
  5980. {"AMIC MUX7", "ADC5", "ADC5"},
  5981. {"AMIC MUX7", "ADC6", "ADC6"},
  5982. {"DMIC MUX8", "DMIC0", "DMIC0"},
  5983. {"DMIC MUX8", "DMIC1", "DMIC1"},
  5984. {"DMIC MUX8", "DMIC2", "DMIC2"},
  5985. {"DMIC MUX8", "DMIC3", "DMIC3"},
  5986. {"DMIC MUX8", "DMIC4", "DMIC4"},
  5987. {"DMIC MUX8", "DMIC5", "DMIC5"},
  5988. {"AMIC MUX8", "ADC1", "ADC1"},
  5989. {"AMIC MUX8", "ADC2", "ADC2"},
  5990. {"AMIC MUX8", "ADC3", "ADC3"},
  5991. {"AMIC MUX8", "ADC4", "ADC4"},
  5992. {"AMIC MUX8", "ADC5", "ADC5"},
  5993. {"AMIC MUX8", "ADC6", "ADC6"},
  5994. {"DMIC MUX10", "DMIC0", "DMIC0"},
  5995. {"DMIC MUX10", "DMIC1", "DMIC1"},
  5996. {"DMIC MUX10", "DMIC2", "DMIC2"},
  5997. {"DMIC MUX10", "DMIC3", "DMIC3"},
  5998. {"DMIC MUX10", "DMIC4", "DMIC4"},
  5999. {"DMIC MUX10", "DMIC5", "DMIC5"},
  6000. {"AMIC MUX10", "ADC1", "ADC1"},
  6001. {"AMIC MUX10", "ADC2", "ADC2"},
  6002. {"AMIC MUX10", "ADC3", "ADC3"},
  6003. {"AMIC MUX10", "ADC4", "ADC4"},
  6004. {"AMIC MUX10", "ADC5", "ADC5"},
  6005. {"AMIC MUX10", "ADC6", "ADC6"},
  6006. {"DMIC MUX11", "DMIC0", "DMIC0"},
  6007. {"DMIC MUX11", "DMIC1", "DMIC1"},
  6008. {"DMIC MUX11", "DMIC2", "DMIC2"},
  6009. {"DMIC MUX11", "DMIC3", "DMIC3"},
  6010. {"DMIC MUX11", "DMIC4", "DMIC4"},
  6011. {"DMIC MUX11", "DMIC5", "DMIC5"},
  6012. {"AMIC MUX11", "ADC1", "ADC1"},
  6013. {"AMIC MUX11", "ADC2", "ADC2"},
  6014. {"AMIC MUX11", "ADC3", "ADC3"},
  6015. {"AMIC MUX11", "ADC4", "ADC4"},
  6016. {"AMIC MUX11", "ADC5", "ADC5"},
  6017. {"AMIC MUX11", "ADC6", "ADC6"},
  6018. {"DMIC MUX12", "DMIC0", "DMIC0"},
  6019. {"DMIC MUX12", "DMIC1", "DMIC1"},
  6020. {"DMIC MUX12", "DMIC2", "DMIC2"},
  6021. {"DMIC MUX12", "DMIC3", "DMIC3"},
  6022. {"DMIC MUX12", "DMIC4", "DMIC4"},
  6023. {"DMIC MUX12", "DMIC5", "DMIC5"},
  6024. {"AMIC MUX12", "ADC1", "ADC1"},
  6025. {"AMIC MUX12", "ADC2", "ADC2"},
  6026. {"AMIC MUX12", "ADC3", "ADC3"},
  6027. {"AMIC MUX12", "ADC4", "ADC4"},
  6028. {"AMIC MUX12", "ADC5", "ADC5"},
  6029. {"AMIC MUX12", "ADC6", "ADC6"},
  6030. {"DMIC MUX13", "DMIC0", "DMIC0"},
  6031. {"DMIC MUX13", "DMIC1", "DMIC1"},
  6032. {"DMIC MUX13", "DMIC2", "DMIC2"},
  6033. {"DMIC MUX13", "DMIC3", "DMIC3"},
  6034. {"DMIC MUX13", "DMIC4", "DMIC4"},
  6035. {"DMIC MUX13", "DMIC5", "DMIC5"},
  6036. {"AMIC MUX13", "ADC1", "ADC1"},
  6037. {"AMIC MUX13", "ADC2", "ADC2"},
  6038. {"AMIC MUX13", "ADC3", "ADC3"},
  6039. {"AMIC MUX13", "ADC4", "ADC4"},
  6040. {"AMIC MUX13", "ADC5", "ADC5"},
  6041. {"AMIC MUX13", "ADC6", "ADC6"},
  6042. /* ADC Connections */
  6043. {"ADC1", NULL, "AMIC1"},
  6044. {"ADC2", NULL, "AMIC2"},
  6045. {"ADC3", NULL, "AMIC3"},
  6046. {"ADC4", NULL, "AMIC4"},
  6047. {"ADC5", NULL, "AMIC5"},
  6048. {"ADC6", NULL, "AMIC6"},
  6049. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP0"},
  6050. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP1"},
  6051. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP2"},
  6052. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP0"},
  6053. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP1"},
  6054. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP2"},
  6055. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP0"},
  6056. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP1"},
  6057. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP2"},
  6058. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP0"},
  6059. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP1"},
  6060. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP2"},
  6061. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP0"},
  6062. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP1"},
  6063. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP2"},
  6064. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP0"},
  6065. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP1"},
  6066. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP2"},
  6067. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP0"},
  6068. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP1"},
  6069. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP2"},
  6070. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP0"},
  6071. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP1"},
  6072. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP2"},
  6073. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP0"},
  6074. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP1"},
  6075. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP2"},
  6076. {"RX INT0 SEC MIX", NULL, "RX INT0_1 MIX1"},
  6077. {"RX INT0 MIX2", NULL, "RX INT0 SEC MIX"},
  6078. {"RX INT0 MIX2", NULL, "RX INT0 MIX2 INP"},
  6079. {"RX INT0 INTERP", NULL, "RX INT0 MIX2"},
  6080. {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 INTERP"},
  6081. {"RX INT0 DAC", NULL, "RX INT0 DEM MUX"},
  6082. {"RX INT0 DAC", NULL, "RX_BIAS"},
  6083. {"EAR PA", NULL, "RX INT0 DAC"},
  6084. {"EAR", NULL, "EAR PA"},
  6085. {"SPL SRC0 MUX", "SRC_IN_HPHL", "RX INT1_1 MIX1"},
  6086. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 MIX1"},
  6087. {"RX INT1 SPLINE MIX", "HPHL Switch", "SPL SRC0 MUX"},
  6088. {"RX INT1_1 NATIVE MUX", "ON", "RX INT1_1 MIX1"},
  6089. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 NATIVE MUX"},
  6090. {"RX INT1_1 NATIVE MUX", NULL, "RX INT1 NATIVE SUPPLY"},
  6091. {"RX INT1 SEC MIX", NULL, "RX INT1 SPLINE MIX"},
  6092. {"RX INT1 MIX2", NULL, "RX INT1 SEC MIX"},
  6093. {"RX INT1 MIX2", NULL, "RX INT1 MIX2 INP"},
  6094. {"RX INT1 INTERP", NULL, "RX INT1 MIX2"},
  6095. {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 INTERP"},
  6096. {"RX INT1 DAC", NULL, "RX INT1 DEM MUX"},
  6097. {"RX INT1 DAC", NULL, "RX_BIAS"},
  6098. {"HPHL PA", NULL, "RX INT1 DAC"},
  6099. {"HPHL", NULL, "HPHL PA"},
  6100. {"SPL SRC1 MUX", "SRC_IN_HPHR", "RX INT2_1 MIX1"},
  6101. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 MIX1"},
  6102. {"RX INT2 SPLINE MIX", "HPHR Switch", "SPL SRC1 MUX"},
  6103. {"RX INT2_1 NATIVE MUX", "ON", "RX INT2_1 MIX1"},
  6104. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 NATIVE MUX"},
  6105. {"RX INT2_1 NATIVE MUX", NULL, "RX INT2 NATIVE SUPPLY"},
  6106. {"RX INT2 SEC MIX", NULL, "RX INT2 SPLINE MIX"},
  6107. {"RX INT2 MIX2", NULL, "RX INT2 SEC MIX"},
  6108. {"RX INT2 MIX2", NULL, "RX INT2 MIX2 INP"},
  6109. {"RX INT2 INTERP", NULL, "RX INT2 MIX2"},
  6110. {"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 INTERP"},
  6111. {"RX INT2 DAC", NULL, "RX INT2 DEM MUX"},
  6112. {"RX INT2 DAC", NULL, "RX_BIAS"},
  6113. {"HPHR PA", NULL, "RX INT2 DAC"},
  6114. {"HPHR", NULL, "HPHR PA"},
  6115. {"SPL SRC0 MUX", "SRC_IN_LO1", "RX INT3_1 MIX1"},
  6116. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 MIX1"},
  6117. {"RX INT3 SPLINE MIX", "LO1 Switch", "SPL SRC0 MUX"},
  6118. {"RX INT3_1 NATIVE MUX", "ON", "RX INT3_1 MIX1"},
  6119. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 NATIVE MUX"},
  6120. {"RX INT3_1 NATIVE MUX", NULL, "RX INT3 NATIVE SUPPLY"},
  6121. {"RX INT3 SEC MIX", NULL, "RX INT3 SPLINE MIX"},
  6122. {"RX INT3 MIX2", NULL, "RX INT3 SEC MIX"},
  6123. {"RX INT3 MIX2", NULL, "RX INT3 MIX2 INP"},
  6124. {"RX INT3 INTERP", NULL, "RX INT3 MIX2"},
  6125. {"RX INT3 DAC", NULL, "RX INT3 INTERP"},
  6126. {"RX INT3 DAC", NULL, "RX_BIAS"},
  6127. {"LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6128. {"LINEOUT1", NULL, "LINEOUT1 PA"},
  6129. {"SPL SRC1 MUX", "SRC_IN_LO2", "RX INT4_1 MIX1"},
  6130. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 MIX1"},
  6131. {"RX INT4 SPLINE MIX", "LO2 Switch", "SPL SRC1 MUX"},
  6132. {"RX INT4_1 NATIVE MUX", "ON", "RX INT4_1 MIX1"},
  6133. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 NATIVE MUX"},
  6134. {"RX INT4_1 NATIVE MUX", NULL, "RX INT4 NATIVE SUPPLY"},
  6135. {"RX INT4 SEC MIX", NULL, "RX INT4 SPLINE MIX"},
  6136. {"RX INT4 MIX2", NULL, "RX INT4 SEC MIX"},
  6137. {"RX INT4 MIX2", NULL, "RX INT4 MIX2 INP"},
  6138. {"RX INT4 INTERP", NULL, "RX INT4 MIX2"},
  6139. {"RX INT4 DAC", NULL, "RX INT4 INTERP"},
  6140. {"RX INT4 DAC", NULL, "RX_BIAS"},
  6141. {"LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6142. {"LINEOUT2", NULL, "LINEOUT2 PA"},
  6143. {"SPL SRC2 MUX", "SRC_IN_LO3", "RX INT5_1 MIX1"},
  6144. {"RX INT5 SPLINE MIX", NULL, "RX INT5_1 MIX1"},
  6145. {"RX INT5 SPLINE MIX", "LO3 Switch", "SPL SRC2 MUX"},
  6146. {"RX INT5 SEC MIX", NULL, "RX INT5 SPLINE MIX"},
  6147. {"RX INT5 MIX2", NULL, "RX INT5 SEC MIX"},
  6148. {"RX INT5 INTERP", NULL, "RX INT5 MIX2"},
  6149. {"RX INT5 VBAT", "LO3 VBAT Enable", "RX INT5 INTERP"},
  6150. {"RX INT5 DAC", NULL, "RX INT5 VBAT"},
  6151. {"RX INT5 DAC", NULL, "RX INT5 INTERP"},
  6152. {"RX INT5 DAC", NULL, "RX_BIAS"},
  6153. {"LINEOUT3 PA", NULL, "RX INT5 DAC"},
  6154. {"LINEOUT3", NULL, "LINEOUT3 PA"},
  6155. {"SPL SRC3 MUX", "SRC_IN_LO4", "RX INT6_1 MIX1"},
  6156. {"RX INT6 SPLINE MIX", NULL, "RX INT6_1 MIX1"},
  6157. {"RX INT6 SPLINE MIX", "LO4 Switch", "SPL SRC3 MUX"},
  6158. {"RX INT6 SEC MIX", NULL, "RX INT6 SPLINE MIX"},
  6159. {"RX INT6 MIX2", NULL, "RX INT6 SEC MIX"},
  6160. {"RX INT6 INTERP", NULL, "RX INT6 MIX2"},
  6161. {"RX INT6 VBAT", "LO4 VBAT Enable", "RX INT6 INTERP"},
  6162. {"RX INT6 DAC", NULL, "RX INT6 VBAT"},
  6163. {"RX INT6 DAC", NULL, "RX INT6 INTERP"},
  6164. {"RX INT6 DAC", NULL, "RX_BIAS"},
  6165. {"LINEOUT4 PA", NULL, "RX INT6 DAC"},
  6166. {"LINEOUT4", NULL, "LINEOUT4 PA"},
  6167. {"SPL SRC2 MUX", "SRC_IN_SPKRL", "RX INT7_1 MIX1"},
  6168. {"RX INT7 SPLINE MIX", NULL, "RX INT7_1 MIX1"},
  6169. {"RX INT7 SPLINE MIX", "SPKRL Switch", "SPL SRC2 MUX"},
  6170. {"RX INT7 SEC MIX", NULL, "RX INT7 SPLINE MIX"},
  6171. {"RX INT7 MIX2", NULL, "RX INT7 SEC MIX"},
  6172. {"RX INT7 MIX2", NULL, "RX INT7 MIX2 INP"},
  6173. {"RX INT7 INTERP", NULL, "RX INT7 MIX2"},
  6174. {"RX INT7 VBAT", "SPKRL VBAT Enable", "RX INT7 INTERP"},
  6175. {"RX INT7 CHAIN", NULL, "RX INT7 VBAT"},
  6176. {"RX INT7 CHAIN", NULL, "RX INT7 INTERP"},
  6177. {"RX INT7 CHAIN", NULL, "RX_BIAS"},
  6178. {"SPK1 OUT", NULL, "RX INT7 CHAIN"},
  6179. {"ANC SPKR PA Enable", "Switch", "RX INT7 CHAIN"},
  6180. {"ANC SPK1 PA", NULL, "ANC SPKR PA Enable"},
  6181. {"SPK1 OUT", NULL, "ANC SPK1 PA"},
  6182. {"SPL SRC3 MUX", "SRC_IN_SPKRR", "RX INT8_1 MIX1"},
  6183. {"RX INT8 SPLINE MIX", NULL, "RX INT8_1 MIX1"},
  6184. {"RX INT8 SPLINE MIX", "SPKRR Switch", "SPL SRC3 MUX"},
  6185. {"RX INT8 SEC MIX", NULL, "RX INT8 SPLINE MIX"},
  6186. {"RX INT8 INTERP", NULL, "RX INT8 SEC MIX"},
  6187. {"RX INT8 VBAT", "SPKRR VBAT Enable", "RX INT8 INTERP"},
  6188. {"RX INT8 CHAIN", NULL, "RX INT8 VBAT"},
  6189. {"RX INT8 CHAIN", NULL, "RX INT8 INTERP"},
  6190. {"RX INT8 CHAIN", NULL, "RX_BIAS"},
  6191. {"SPK2 OUT", NULL, "RX INT8 CHAIN"},
  6192. {"ANC0 FB MUX", "ANC_IN_EAR", "RX INT0 MIX2"},
  6193. {"ANC0 FB MUX", "ANC_IN_HPHL", "RX INT1 MIX2"},
  6194. {"ANC0 FB MUX", "ANC_IN_LO1", "RX INT3 MIX2"},
  6195. {"ANC0 FB MUX", "ANC_IN_EAR_SPKR", "RX INT7 MIX2"},
  6196. {"ANC1 FB MUX", "ANC_IN_HPHR", "RX INT2 MIX2"},
  6197. {"ANC1 FB MUX", "ANC_IN_LO2", "RX INT4 MIX2"},
  6198. {"ANC HPHL Enable", "Switch", "ADC MUX10"},
  6199. {"ANC HPHL Enable", "Switch", "ADC MUX11"},
  6200. {"RX INT1 MIX2", NULL, "ANC HPHL Enable"},
  6201. {"ANC HPHR Enable", "Switch", "ADC MUX12"},
  6202. {"ANC HPHR Enable", "Switch", "ADC MUX13"},
  6203. {"RX INT2 MIX2", NULL, "ANC HPHR Enable"},
  6204. {"ANC EAR Enable", "Switch", "ADC MUX10"},
  6205. {"ANC EAR Enable", "Switch", "ADC MUX11"},
  6206. {"RX INT0 MIX2", NULL, "ANC EAR Enable"},
  6207. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX10"},
  6208. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX11"},
  6209. {"RX INT7 MIX2", NULL, "ANC OUT EAR SPKR Enable"},
  6210. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX10"},
  6211. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX11"},
  6212. {"RX INT3 MIX2", NULL, "ANC LINEOUT1 Enable"},
  6213. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX12"},
  6214. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX13"},
  6215. {"RX INT4 MIX2", NULL, "ANC LINEOUT2 Enable"},
  6216. {"ANC EAR PA", NULL, "RX INT0 DAC"},
  6217. {"ANC EAR", NULL, "ANC EAR PA"},
  6218. {"ANC HPHL PA", NULL, "RX INT1 DAC"},
  6219. {"ANC HPHL", NULL, "ANC HPHL PA"},
  6220. {"ANC HPHR PA", NULL, "RX INT2 DAC"},
  6221. {"ANC HPHR", NULL, "ANC HPHR PA"},
  6222. {"ANC LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6223. {"ANC LINEOUT1", NULL, "ANC LINEOUT1 PA"},
  6224. {"ANC LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6225. {"ANC LINEOUT2", NULL, "ANC LINEOUT2 PA"},
  6226. /* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/
  6227. {"SLIM RX0 MUX", "AIF1_PB", "AIF1 PB"},
  6228. {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
  6229. {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
  6230. {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
  6231. {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
  6232. {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
  6233. {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
  6234. {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
  6235. /* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/
  6236. {"SLIM RX0 MUX", "AIF2_PB", "AIF2 PB"},
  6237. {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
  6238. {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
  6239. {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
  6240. {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
  6241. {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
  6242. {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
  6243. {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
  6244. /* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/
  6245. {"SLIM RX0 MUX", "AIF3_PB", "AIF3 PB"},
  6246. {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
  6247. {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
  6248. {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
  6249. {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
  6250. {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
  6251. {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
  6252. {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
  6253. /* SLIM_MUX("AIF4_PB", "AIF4 PB"),*/
  6254. {"SLIM RX0 MUX", "AIF4_PB", "AIF4 PB"},
  6255. {"SLIM RX1 MUX", "AIF4_PB", "AIF4 PB"},
  6256. {"SLIM RX2 MUX", "AIF4_PB", "AIF4 PB"},
  6257. {"SLIM RX3 MUX", "AIF4_PB", "AIF4 PB"},
  6258. {"SLIM RX4 MUX", "AIF4_PB", "AIF4 PB"},
  6259. {"SLIM RX5 MUX", "AIF4_PB", "AIF4 PB"},
  6260. {"SLIM RX6 MUX", "AIF4_PB", "AIF4 PB"},
  6261. {"SLIM RX7 MUX", "AIF4_PB", "AIF4 PB"},
  6262. /* SLIM_MUX("AIF_MIX1_PB", "AIF MIX1 PB"),*/
  6263. {"SLIM RX0 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6264. {"SLIM RX1 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6265. {"SLIM RX2 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6266. {"SLIM RX3 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6267. {"SLIM RX4 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6268. {"SLIM RX5 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6269. {"SLIM RX6 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6270. {"SLIM RX7 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6271. {"SLIM RX0", NULL, "SLIM RX0 MUX"},
  6272. {"SLIM RX1", NULL, "SLIM RX1 MUX"},
  6273. {"SLIM RX2", NULL, "SLIM RX2 MUX"},
  6274. {"SLIM RX3", NULL, "SLIM RX3 MUX"},
  6275. {"SLIM RX4", NULL, "SLIM RX4 MUX"},
  6276. {"SLIM RX5", NULL, "SLIM RX5 MUX"},
  6277. {"SLIM RX6", NULL, "SLIM RX6 MUX"},
  6278. {"SLIM RX7", NULL, "SLIM RX7 MUX"},
  6279. {"RX INT0_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6280. {"RX INT0_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6281. {"RX INT0_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6282. {"RX INT0_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6283. {"RX INT0_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6284. {"RX INT0_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6285. {"RX INT0_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6286. {"RX INT0_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6287. {"RX INT0_1 MIX1 INP0", "IIR0", "IIR0"},
  6288. {"RX INT0_1 MIX1 INP0", "IIR1", "IIR1"},
  6289. {"RX INT0_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6290. {"RX INT0_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6291. {"RX INT0_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6292. {"RX INT0_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6293. {"RX INT0_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6294. {"RX INT0_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6295. {"RX INT0_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6296. {"RX INT0_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6297. {"RX INT0_1 MIX1 INP1", "IIR0", "IIR0"},
  6298. {"RX INT0_1 MIX1 INP1", "IIR1", "IIR1"},
  6299. {"RX INT0_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6300. {"RX INT0_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6301. {"RX INT0_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6302. {"RX INT0_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6303. {"RX INT0_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6304. {"RX INT0_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6305. {"RX INT0_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6306. {"RX INT0_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6307. {"RX INT0_1 MIX1 INP2", "IIR0", "IIR0"},
  6308. {"RX INT0_1 MIX1 INP2", "IIR1", "IIR1"},
  6309. /* MIXing path INT0 */
  6310. {"RX INT0_2 MUX", "RX0", "SLIM RX0"},
  6311. {"RX INT0_2 MUX", "RX1", "SLIM RX1"},
  6312. {"RX INT0_2 MUX", "RX2", "SLIM RX2"},
  6313. {"RX INT0_2 MUX", "RX3", "SLIM RX3"},
  6314. {"RX INT0_2 MUX", "RX4", "SLIM RX4"},
  6315. {"RX INT0_2 MUX", "RX5", "SLIM RX5"},
  6316. {"RX INT0_2 MUX", "RX6", "SLIM RX6"},
  6317. {"RX INT0_2 MUX", "RX7", "SLIM RX7"},
  6318. {"RX INT0 SEC MIX", NULL, "RX INT0_2 MUX"},
  6319. /* MIXing path INT1 */
  6320. {"RX INT1_2 MUX", "RX0", "SLIM RX0"},
  6321. {"RX INT1_2 MUX", "RX1", "SLIM RX1"},
  6322. {"RX INT1_2 MUX", "RX2", "SLIM RX2"},
  6323. {"RX INT1_2 MUX", "RX3", "SLIM RX3"},
  6324. {"RX INT1_2 MUX", "RX4", "SLIM RX4"},
  6325. {"RX INT1_2 MUX", "RX5", "SLIM RX5"},
  6326. {"RX INT1_2 MUX", "RX6", "SLIM RX6"},
  6327. {"RX INT1_2 MUX", "RX7", "SLIM RX7"},
  6328. {"RX INT1 SEC MIX", NULL, "RX INT1_2 MUX"},
  6329. /* MIXing path INT2 */
  6330. {"RX INT2_2 MUX", "RX0", "SLIM RX0"},
  6331. {"RX INT2_2 MUX", "RX1", "SLIM RX1"},
  6332. {"RX INT2_2 MUX", "RX2", "SLIM RX2"},
  6333. {"RX INT2_2 MUX", "RX3", "SLIM RX3"},
  6334. {"RX INT2_2 MUX", "RX4", "SLIM RX4"},
  6335. {"RX INT2_2 MUX", "RX5", "SLIM RX5"},
  6336. {"RX INT2_2 MUX", "RX6", "SLIM RX6"},
  6337. {"RX INT2_2 MUX", "RX7", "SLIM RX7"},
  6338. {"RX INT2 SEC MIX", NULL, "RX INT2_2 MUX"},
  6339. /* MIXing path INT3 */
  6340. {"RX INT3_2 MUX", "RX0", "SLIM RX0"},
  6341. {"RX INT3_2 MUX", "RX1", "SLIM RX1"},
  6342. {"RX INT3_2 MUX", "RX2", "SLIM RX2"},
  6343. {"RX INT3_2 MUX", "RX3", "SLIM RX3"},
  6344. {"RX INT3_2 MUX", "RX4", "SLIM RX4"},
  6345. {"RX INT3_2 MUX", "RX5", "SLIM RX5"},
  6346. {"RX INT3_2 MUX", "RX6", "SLIM RX6"},
  6347. {"RX INT3_2 MUX", "RX7", "SLIM RX7"},
  6348. {"RX INT3 SEC MIX", NULL, "RX INT3_2 MUX"},
  6349. /* MIXing path INT4 */
  6350. {"RX INT4_2 MUX", "RX0", "SLIM RX0"},
  6351. {"RX INT4_2 MUX", "RX1", "SLIM RX1"},
  6352. {"RX INT4_2 MUX", "RX2", "SLIM RX2"},
  6353. {"RX INT4_2 MUX", "RX3", "SLIM RX3"},
  6354. {"RX INT4_2 MUX", "RX4", "SLIM RX4"},
  6355. {"RX INT4_2 MUX", "RX5", "SLIM RX5"},
  6356. {"RX INT4_2 MUX", "RX6", "SLIM RX6"},
  6357. {"RX INT4_2 MUX", "RX7", "SLIM RX7"},
  6358. {"RX INT4 SEC MIX", NULL, "RX INT4_2 MUX"},
  6359. /* MIXing path INT5 */
  6360. {"RX INT5_2 MUX", "RX0", "SLIM RX0"},
  6361. {"RX INT5_2 MUX", "RX1", "SLIM RX1"},
  6362. {"RX INT5_2 MUX", "RX2", "SLIM RX2"},
  6363. {"RX INT5_2 MUX", "RX3", "SLIM RX3"},
  6364. {"RX INT5_2 MUX", "RX4", "SLIM RX4"},
  6365. {"RX INT5_2 MUX", "RX5", "SLIM RX5"},
  6366. {"RX INT5_2 MUX", "RX6", "SLIM RX6"},
  6367. {"RX INT5_2 MUX", "RX7", "SLIM RX7"},
  6368. {"RX INT5 SEC MIX", NULL, "RX INT5_2 MUX"},
  6369. /* MIXing path INT6 */
  6370. {"RX INT6_2 MUX", "RX0", "SLIM RX0"},
  6371. {"RX INT6_2 MUX", "RX1", "SLIM RX1"},
  6372. {"RX INT6_2 MUX", "RX2", "SLIM RX2"},
  6373. {"RX INT6_2 MUX", "RX3", "SLIM RX3"},
  6374. {"RX INT6_2 MUX", "RX4", "SLIM RX4"},
  6375. {"RX INT6_2 MUX", "RX5", "SLIM RX5"},
  6376. {"RX INT6_2 MUX", "RX6", "SLIM RX6"},
  6377. {"RX INT6_2 MUX", "RX7", "SLIM RX7"},
  6378. {"RX INT6 SEC MIX", NULL, "RX INT6_2 MUX"},
  6379. /* MIXing path INT7 */
  6380. {"RX INT7_2 MUX", "RX0", "SLIM RX0"},
  6381. {"RX INT7_2 MUX", "RX1", "SLIM RX1"},
  6382. {"RX INT7_2 MUX", "RX2", "SLIM RX2"},
  6383. {"RX INT7_2 MUX", "RX3", "SLIM RX3"},
  6384. {"RX INT7_2 MUX", "RX4", "SLIM RX4"},
  6385. {"RX INT7_2 MUX", "RX5", "SLIM RX5"},
  6386. {"RX INT7_2 MUX", "RX6", "SLIM RX6"},
  6387. {"RX INT7_2 MUX", "RX7", "SLIM RX7"},
  6388. {"RX INT7 SEC MIX", NULL, "RX INT7_2 MUX"},
  6389. /* MIXing path INT8 */
  6390. {"RX INT8_2 MUX", "RX0", "SLIM RX0"},
  6391. {"RX INT8_2 MUX", "RX1", "SLIM RX1"},
  6392. {"RX INT8_2 MUX", "RX2", "SLIM RX2"},
  6393. {"RX INT8_2 MUX", "RX3", "SLIM RX3"},
  6394. {"RX INT8_2 MUX", "RX4", "SLIM RX4"},
  6395. {"RX INT8_2 MUX", "RX5", "SLIM RX5"},
  6396. {"RX INT8_2 MUX", "RX6", "SLIM RX6"},
  6397. {"RX INT8_2 MUX", "RX7", "SLIM RX7"},
  6398. {"RX INT8 SEC MIX", NULL, "RX INT8_2 MUX"},
  6399. {"RX INT1_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6400. {"RX INT1_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6401. {"RX INT1_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6402. {"RX INT1_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6403. {"RX INT1_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6404. {"RX INT1_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6405. {"RX INT1_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6406. {"RX INT1_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6407. {"RX INT1_1 MIX1 INP0", "IIR0", "IIR0"},
  6408. {"RX INT1_1 MIX1 INP0", "IIR1", "IIR1"},
  6409. {"RX INT1_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6410. {"RX INT1_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6411. {"RX INT1_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6412. {"RX INT1_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6413. {"RX INT1_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6414. {"RX INT1_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6415. {"RX INT1_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6416. {"RX INT1_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6417. {"RX INT1_1 MIX1 INP1", "IIR0", "IIR0"},
  6418. {"RX INT1_1 MIX1 INP1", "IIR1", "IIR1"},
  6419. {"RX INT1_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6420. {"RX INT1_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6421. {"RX INT1_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6422. {"RX INT1_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6423. {"RX INT1_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6424. {"RX INT1_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6425. {"RX INT1_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6426. {"RX INT1_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6427. {"RX INT1_1 MIX1 INP2", "IIR0", "IIR0"},
  6428. {"RX INT1_1 MIX1 INP2", "IIR1", "IIR1"},
  6429. {"RX INT2_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6430. {"RX INT2_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6431. {"RX INT2_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6432. {"RX INT2_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6433. {"RX INT2_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6434. {"RX INT2_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6435. {"RX INT2_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6436. {"RX INT2_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6437. {"RX INT2_1 MIX1 INP0", "IIR0", "IIR0"},
  6438. {"RX INT2_1 MIX1 INP0", "IIR1", "IIR1"},
  6439. {"RX INT2_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6440. {"RX INT2_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6441. {"RX INT2_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6442. {"RX INT2_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6443. {"RX INT2_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6444. {"RX INT2_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6445. {"RX INT2_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6446. {"RX INT2_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6447. {"RX INT2_1 MIX1 INP1", "IIR0", "IIR0"},
  6448. {"RX INT2_1 MIX1 INP1", "IIR1", "IIR1"},
  6449. {"RX INT2_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6450. {"RX INT2_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6451. {"RX INT2_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6452. {"RX INT2_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6453. {"RX INT2_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6454. {"RX INT2_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6455. {"RX INT2_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6456. {"RX INT2_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6457. {"RX INT2_1 MIX1 INP2", "IIR0", "IIR0"},
  6458. {"RX INT2_1 MIX1 INP2", "IIR1", "IIR1"},
  6459. {"RX INT3_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6460. {"RX INT3_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6461. {"RX INT3_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6462. {"RX INT3_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6463. {"RX INT3_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6464. {"RX INT3_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6465. {"RX INT3_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6466. {"RX INT3_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6467. {"RX INT3_1 MIX1 INP0", "IIR0", "IIR0"},
  6468. {"RX INT3_1 MIX1 INP0", "IIR1", "IIR1"},
  6469. {"RX INT3_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6470. {"RX INT3_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6471. {"RX INT3_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6472. {"RX INT3_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6473. {"RX INT3_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6474. {"RX INT3_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6475. {"RX INT3_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6476. {"RX INT3_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6477. {"RX INT3_1 MIX1 INP1", "IIR0", "IIR0"},
  6478. {"RX INT3_1 MIX1 INP1", "IIR1", "IIR1"},
  6479. {"RX INT3_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6480. {"RX INT3_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6481. {"RX INT3_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6482. {"RX INT3_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6483. {"RX INT3_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6484. {"RX INT3_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6485. {"RX INT3_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6486. {"RX INT3_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6487. {"RX INT3_1 MIX1 INP2", "IIR0", "IIR0"},
  6488. {"RX INT3_1 MIX1 INP2", "IIR1", "IIR1"},
  6489. {"RX INT4_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6490. {"RX INT4_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6491. {"RX INT4_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6492. {"RX INT4_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6493. {"RX INT4_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6494. {"RX INT4_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6495. {"RX INT4_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6496. {"RX INT4_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6497. {"RX INT4_1 MIX1 INP0", "IIR0", "IIR0"},
  6498. {"RX INT4_1 MIX1 INP0", "IIR1", "IIR1"},
  6499. {"RX INT4_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6500. {"RX INT4_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6501. {"RX INT4_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6502. {"RX INT4_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6503. {"RX INT4_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6504. {"RX INT4_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6505. {"RX INT4_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6506. {"RX INT4_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6507. {"RX INT4_1 MIX1 INP1", "IIR0", "IIR0"},
  6508. {"RX INT4_1 MIX1 INP1", "IIR1", "IIR1"},
  6509. {"RX INT4_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6510. {"RX INT4_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6511. {"RX INT4_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6512. {"RX INT4_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6513. {"RX INT4_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6514. {"RX INT4_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6515. {"RX INT4_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6516. {"RX INT4_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6517. {"RX INT4_1 MIX1 INP2", "IIR0", "IIR0"},
  6518. {"RX INT4_1 MIX1 INP2", "IIR1", "IIR1"},
  6519. {"RX INT5_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6520. {"RX INT5_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6521. {"RX INT5_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6522. {"RX INT5_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6523. {"RX INT5_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6524. {"RX INT5_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6525. {"RX INT5_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6526. {"RX INT5_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6527. {"RX INT5_1 MIX1 INP0", "IIR0", "IIR0"},
  6528. {"RX INT5_1 MIX1 INP0", "IIR1", "IIR1"},
  6529. {"RX INT5_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6530. {"RX INT5_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6531. {"RX INT5_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6532. {"RX INT5_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6533. {"RX INT5_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6534. {"RX INT5_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6535. {"RX INT5_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6536. {"RX INT5_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6537. {"RX INT5_1 MIX1 INP1", "IIR0", "IIR0"},
  6538. {"RX INT5_1 MIX1 INP1", "IIR1", "IIR1"},
  6539. {"RX INT5_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6540. {"RX INT5_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6541. {"RX INT5_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6542. {"RX INT5_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6543. {"RX INT5_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6544. {"RX INT5_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6545. {"RX INT5_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6546. {"RX INT5_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6547. {"RX INT5_1 MIX1 INP2", "IIR0", "IIR0"},
  6548. {"RX INT5_1 MIX1 INP2", "IIR1", "IIR1"},
  6549. {"RX INT6_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6550. {"RX INT6_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6551. {"RX INT6_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6552. {"RX INT6_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6553. {"RX INT6_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6554. {"RX INT6_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6555. {"RX INT6_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6556. {"RX INT6_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6557. {"RX INT6_1 MIX1 INP0", "IIR0", "IIR0"},
  6558. {"RX INT6_1 MIX1 INP0", "IIR1", "IIR1"},
  6559. {"RX INT6_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6560. {"RX INT6_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6561. {"RX INT6_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6562. {"RX INT6_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6563. {"RX INT6_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6564. {"RX INT6_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6565. {"RX INT6_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6566. {"RX INT6_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6567. {"RX INT6_1 MIX1 INP1", "IIR0", "IIR0"},
  6568. {"RX INT6_1 MIX1 INP1", "IIR1", "IIR1"},
  6569. {"RX INT6_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6570. {"RX INT6_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6571. {"RX INT6_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6572. {"RX INT6_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6573. {"RX INT6_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6574. {"RX INT6_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6575. {"RX INT6_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6576. {"RX INT6_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6577. {"RX INT6_1 MIX1 INP2", "IIR0", "IIR0"},
  6578. {"RX INT6_1 MIX1 INP2", "IIR1", "IIR1"},
  6579. {"RX INT7_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6580. {"RX INT7_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6581. {"RX INT7_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6582. {"RX INT7_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6583. {"RX INT7_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6584. {"RX INT7_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6585. {"RX INT7_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6586. {"RX INT7_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6587. {"RX INT7_1 MIX1 INP0", "IIR0", "IIR0"},
  6588. {"RX INT7_1 MIX1 INP0", "IIR1", "IIR1"},
  6589. {"RX INT7_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6590. {"RX INT7_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6591. {"RX INT7_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6592. {"RX INT7_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6593. {"RX INT7_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6594. {"RX INT7_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6595. {"RX INT7_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6596. {"RX INT7_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6597. {"RX INT7_1 MIX1 INP1", "IIR0", "IIR0"},
  6598. {"RX INT7_1 MIX1 INP1", "IIR1", "IIR1"},
  6599. {"RX INT7_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6600. {"RX INT7_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6601. {"RX INT7_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6602. {"RX INT7_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6603. {"RX INT7_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6604. {"RX INT7_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6605. {"RX INT7_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6606. {"RX INT7_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6607. {"RX INT7_1 MIX1 INP2", "IIR0", "IIR0"},
  6608. {"RX INT7_1 MIX1 INP2", "IIR1", "IIR1"},
  6609. {"RX INT8_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6610. {"RX INT8_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6611. {"RX INT8_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6612. {"RX INT8_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6613. {"RX INT8_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6614. {"RX INT8_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6615. {"RX INT8_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6616. {"RX INT8_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6617. {"RX INT8_1 MIX1 INP0", "IIR0", "IIR0"},
  6618. {"RX INT8_1 MIX1 INP0", "IIR1", "IIR1"},
  6619. {"RX INT8_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6620. {"RX INT8_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6621. {"RX INT8_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6622. {"RX INT8_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6623. {"RX INT8_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6624. {"RX INT8_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6625. {"RX INT8_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6626. {"RX INT8_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6627. {"RX INT8_1 MIX1 INP1", "IIR0", "IIR0"},
  6628. {"RX INT8_1 MIX1 INP1", "IIR1", "IIR1"},
  6629. {"RX INT8_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6630. {"RX INT8_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6631. {"RX INT8_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6632. {"RX INT8_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6633. {"RX INT8_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6634. {"RX INT8_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6635. {"RX INT8_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6636. {"RX INT8_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6637. {"RX INT8_1 MIX1 INP2", "IIR0", "IIR0"},
  6638. {"RX INT8_1 MIX1 INP2", "IIR1", "IIR1"},
  6639. /* SRC0, SRC1 inputs to Sidetone RX Mixer
  6640. * on RX0, RX1, RX2, RX3, RX4 and RX7 chains
  6641. */
  6642. {"IIR0", NULL, "IIR0 INP0 MUX"},
  6643. {"IIR0 INP0 MUX", "DEC0", "ADC MUX0"},
  6644. {"IIR0 INP0 MUX", "DEC1", "ADC MUX1"},
  6645. {"IIR0 INP0 MUX", "DEC2", "ADC MUX2"},
  6646. {"IIR0 INP0 MUX", "DEC3", "ADC MUX3"},
  6647. {"IIR0 INP0 MUX", "DEC4", "ADC MUX4"},
  6648. {"IIR0 INP0 MUX", "DEC5", "ADC MUX5"},
  6649. {"IIR0 INP0 MUX", "DEC6", "ADC MUX6"},
  6650. {"IIR0 INP0 MUX", "DEC7", "ADC MUX7"},
  6651. {"IIR0 INP0 MUX", "DEC8", "ADC MUX8"},
  6652. {"IIR0 INP0 MUX", "RX0", "SLIM RX0"},
  6653. {"IIR0 INP0 MUX", "RX1", "SLIM RX1"},
  6654. {"IIR0 INP0 MUX", "RX2", "SLIM RX2"},
  6655. {"IIR0 INP0 MUX", "RX3", "SLIM RX3"},
  6656. {"IIR0 INP0 MUX", "RX4", "SLIM RX4"},
  6657. {"IIR0 INP0 MUX", "RX5", "SLIM RX5"},
  6658. {"IIR0 INP0 MUX", "RX6", "SLIM RX6"},
  6659. {"IIR0 INP0 MUX", "RX7", "SLIM RX7"},
  6660. {"IIR0", NULL, "IIR0 INP1 MUX"},
  6661. {"IIR0 INP1 MUX", "DEC0", "ADC MUX0"},
  6662. {"IIR0 INP1 MUX", "DEC1", "ADC MUX1"},
  6663. {"IIR0 INP1 MUX", "DEC2", "ADC MUX2"},
  6664. {"IIR0 INP1 MUX", "DEC3", "ADC MUX3"},
  6665. {"IIR0 INP1 MUX", "DEC4", "ADC MUX4"},
  6666. {"IIR0 INP1 MUX", "DEC5", "ADC MUX5"},
  6667. {"IIR0 INP1 MUX", "DEC6", "ADC MUX6"},
  6668. {"IIR0 INP1 MUX", "DEC7", "ADC MUX7"},
  6669. {"IIR0 INP1 MUX", "DEC8", "ADC MUX8"},
  6670. {"IIR0 INP1 MUX", "RX0", "SLIM RX0"},
  6671. {"IIR0 INP1 MUX", "RX1", "SLIM RX1"},
  6672. {"IIR0 INP1 MUX", "RX2", "SLIM RX2"},
  6673. {"IIR0 INP1 MUX", "RX3", "SLIM RX3"},
  6674. {"IIR0 INP1 MUX", "RX4", "SLIM RX4"},
  6675. {"IIR0 INP1 MUX", "RX5", "SLIM RX5"},
  6676. {"IIR0 INP1 MUX", "RX6", "SLIM RX6"},
  6677. {"IIR0 INP1 MUX", "RX7", "SLIM RX7"},
  6678. {"IIR0", NULL, "IIR0 INP2 MUX"},
  6679. {"IIR0 INP2 MUX", "DEC0", "ADC MUX0"},
  6680. {"IIR0 INP2 MUX", "DEC1", "ADC MUX1"},
  6681. {"IIR0 INP2 MUX", "DEC2", "ADC MUX2"},
  6682. {"IIR0 INP2 MUX", "DEC3", "ADC MUX3"},
  6683. {"IIR0 INP2 MUX", "DEC4", "ADC MUX4"},
  6684. {"IIR0 INP2 MUX", "DEC5", "ADC MUX5"},
  6685. {"IIR0 INP2 MUX", "DEC6", "ADC MUX6"},
  6686. {"IIR0 INP2 MUX", "DEC7", "ADC MUX7"},
  6687. {"IIR0 INP2 MUX", "DEC8", "ADC MUX8"},
  6688. {"IIR0 INP2 MUX", "RX0", "SLIM RX0"},
  6689. {"IIR0 INP2 MUX", "RX1", "SLIM RX1"},
  6690. {"IIR0 INP2 MUX", "RX2", "SLIM RX2"},
  6691. {"IIR0 INP2 MUX", "RX3", "SLIM RX3"},
  6692. {"IIR0 INP2 MUX", "RX4", "SLIM RX4"},
  6693. {"IIR0 INP2 MUX", "RX5", "SLIM RX5"},
  6694. {"IIR0 INP2 MUX", "RX6", "SLIM RX6"},
  6695. {"IIR0 INP2 MUX", "RX7", "SLIM RX7"},
  6696. {"IIR0", NULL, "IIR0 INP3 MUX"},
  6697. {"IIR0 INP3 MUX", "DEC0", "ADC MUX0"},
  6698. {"IIR0 INP3 MUX", "DEC1", "ADC MUX1"},
  6699. {"IIR0 INP3 MUX", "DEC2", "ADC MUX2"},
  6700. {"IIR0 INP3 MUX", "DEC3", "ADC MUX3"},
  6701. {"IIR0 INP3 MUX", "DEC4", "ADC MUX4"},
  6702. {"IIR0 INP3 MUX", "DEC5", "ADC MUX5"},
  6703. {"IIR0 INP3 MUX", "DEC6", "ADC MUX6"},
  6704. {"IIR0 INP3 MUX", "DEC7", "ADC MUX7"},
  6705. {"IIR0 INP3 MUX", "DEC8", "ADC MUX8"},
  6706. {"IIR0 INP3 MUX", "RX0", "SLIM RX0"},
  6707. {"IIR0 INP3 MUX", "RX1", "SLIM RX1"},
  6708. {"IIR0 INP3 MUX", "RX2", "SLIM RX2"},
  6709. {"IIR0 INP3 MUX", "RX3", "SLIM RX3"},
  6710. {"IIR0 INP3 MUX", "RX4", "SLIM RX4"},
  6711. {"IIR0 INP3 MUX", "RX5", "SLIM RX5"},
  6712. {"IIR0 INP3 MUX", "RX6", "SLIM RX6"},
  6713. {"IIR0 INP3 MUX", "RX7", "SLIM RX7"},
  6714. {"IIR1", NULL, "IIR1 INP0 MUX"},
  6715. {"IIR1 INP0 MUX", "DEC0", "ADC MUX0"},
  6716. {"IIR1 INP0 MUX", "DEC1", "ADC MUX1"},
  6717. {"IIR1 INP0 MUX", "DEC2", "ADC MUX2"},
  6718. {"IIR1 INP0 MUX", "DEC3", "ADC MUX3"},
  6719. {"IIR1 INP0 MUX", "DEC4", "ADC MUX4"},
  6720. {"IIR1 INP0 MUX", "DEC5", "ADC MUX5"},
  6721. {"IIR1 INP0 MUX", "DEC6", "ADC MUX6"},
  6722. {"IIR1 INP0 MUX", "DEC7", "ADC MUX7"},
  6723. {"IIR1 INP0 MUX", "DEC8", "ADC MUX8"},
  6724. {"IIR1 INP0 MUX", "RX0", "SLIM RX0"},
  6725. {"IIR1 INP0 MUX", "RX1", "SLIM RX1"},
  6726. {"IIR1 INP0 MUX", "RX2", "SLIM RX2"},
  6727. {"IIR1 INP0 MUX", "RX3", "SLIM RX3"},
  6728. {"IIR1 INP0 MUX", "RX4", "SLIM RX4"},
  6729. {"IIR1 INP0 MUX", "RX5", "SLIM RX5"},
  6730. {"IIR1 INP0 MUX", "RX6", "SLIM RX6"},
  6731. {"IIR1 INP0 MUX", "RX7", "SLIM RX7"},
  6732. {"IIR1", NULL, "IIR1 INP1 MUX"},
  6733. {"IIR1 INP1 MUX", "DEC0", "ADC MUX0"},
  6734. {"IIR1 INP1 MUX", "DEC1", "ADC MUX1"},
  6735. {"IIR1 INP1 MUX", "DEC2", "ADC MUX2"},
  6736. {"IIR1 INP1 MUX", "DEC3", "ADC MUX3"},
  6737. {"IIR1 INP1 MUX", "DEC4", "ADC MUX4"},
  6738. {"IIR1 INP1 MUX", "DEC5", "ADC MUX5"},
  6739. {"IIR1 INP1 MUX", "DEC6", "ADC MUX6"},
  6740. {"IIR1 INP1 MUX", "DEC7", "ADC MUX7"},
  6741. {"IIR1 INP1 MUX", "DEC8", "ADC MUX8"},
  6742. {"IIR1 INP1 MUX", "RX0", "SLIM RX0"},
  6743. {"IIR1 INP1 MUX", "RX1", "SLIM RX1"},
  6744. {"IIR1 INP1 MUX", "RX2", "SLIM RX2"},
  6745. {"IIR1 INP1 MUX", "RX3", "SLIM RX3"},
  6746. {"IIR1 INP1 MUX", "RX4", "SLIM RX4"},
  6747. {"IIR1 INP1 MUX", "RX5", "SLIM RX5"},
  6748. {"IIR1 INP1 MUX", "RX6", "SLIM RX6"},
  6749. {"IIR1 INP1 MUX", "RX7", "SLIM RX7"},
  6750. {"IIR1", NULL, "IIR1 INP2 MUX"},
  6751. {"IIR1 INP2 MUX", "DEC0", "ADC MUX0"},
  6752. {"IIR1 INP2 MUX", "DEC1", "ADC MUX1"},
  6753. {"IIR1 INP2 MUX", "DEC2", "ADC MUX2"},
  6754. {"IIR1 INP2 MUX", "DEC3", "ADC MUX3"},
  6755. {"IIR1 INP2 MUX", "DEC4", "ADC MUX4"},
  6756. {"IIR1 INP2 MUX", "DEC5", "ADC MUX5"},
  6757. {"IIR1 INP2 MUX", "DEC6", "ADC MUX6"},
  6758. {"IIR1 INP2 MUX", "DEC7", "ADC MUX7"},
  6759. {"IIR1 INP2 MUX", "DEC8", "ADC MUX8"},
  6760. {"IIR1 INP2 MUX", "RX0", "SLIM RX0"},
  6761. {"IIR1 INP2 MUX", "RX1", "SLIM RX1"},
  6762. {"IIR1 INP2 MUX", "RX2", "SLIM RX2"},
  6763. {"IIR1 INP2 MUX", "RX3", "SLIM RX3"},
  6764. {"IIR1 INP2 MUX", "RX4", "SLIM RX4"},
  6765. {"IIR1 INP2 MUX", "RX5", "SLIM RX5"},
  6766. {"IIR1 INP2 MUX", "RX6", "SLIM RX6"},
  6767. {"IIR1 INP2 MUX", "RX7", "SLIM RX7"},
  6768. {"IIR1", NULL, "IIR1 INP3 MUX"},
  6769. {"IIR1 INP3 MUX", "DEC0", "ADC MUX0"},
  6770. {"IIR1 INP3 MUX", "DEC1", "ADC MUX1"},
  6771. {"IIR1 INP3 MUX", "DEC2", "ADC MUX2"},
  6772. {"IIR1 INP3 MUX", "DEC3", "ADC MUX3"},
  6773. {"IIR1 INP3 MUX", "DEC4", "ADC MUX4"},
  6774. {"IIR1 INP3 MUX", "DEC5", "ADC MUX5"},
  6775. {"IIR1 INP3 MUX", "DEC6", "ADC MUX6"},
  6776. {"IIR1 INP3 MUX", "DEC7", "ADC MUX7"},
  6777. {"IIR1 INP3 MUX", "DEC8", "ADC MUX8"},
  6778. {"IIR1 INP3 MUX", "RX0", "SLIM RX0"},
  6779. {"IIR1 INP3 MUX", "RX1", "SLIM RX1"},
  6780. {"IIR1 INP3 MUX", "RX2", "SLIM RX2"},
  6781. {"IIR1 INP3 MUX", "RX3", "SLIM RX3"},
  6782. {"IIR1 INP3 MUX", "RX4", "SLIM RX4"},
  6783. {"IIR1 INP3 MUX", "RX5", "SLIM RX5"},
  6784. {"IIR1 INP3 MUX", "RX6", "SLIM RX6"},
  6785. {"IIR1 INP3 MUX", "RX7", "SLIM RX7"},
  6786. {"SRC0", NULL, "IIR0"},
  6787. {"SRC1", NULL, "IIR1"},
  6788. {"RX INT0 MIX2 INP", "SRC0", "SRC0"},
  6789. {"RX INT0 MIX2 INP", "SRC1", "SRC1"},
  6790. {"RX INT1 MIX2 INP", "SRC0", "SRC0"},
  6791. {"RX INT1 MIX2 INP", "SRC1", "SRC1"},
  6792. {"RX INT2 MIX2 INP", "SRC0", "SRC0"},
  6793. {"RX INT2 MIX2 INP", "SRC1", "SRC1"},
  6794. {"RX INT3 MIX2 INP", "SRC0", "SRC0"},
  6795. {"RX INT3 MIX2 INP", "SRC1", "SRC1"},
  6796. {"RX INT4 MIX2 INP", "SRC0", "SRC0"},
  6797. {"RX INT4 MIX2 INP", "SRC1", "SRC1"},
  6798. {"RX INT7 MIX2 INP", "SRC0", "SRC0"},
  6799. {"RX INT7 MIX2 INP", "SRC1", "SRC1"},
  6800. };
  6801. static int tasha_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol,
  6802. struct snd_ctl_elem_value *ucontrol)
  6803. {
  6804. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6805. u16 amic_reg;
  6806. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6807. amic_reg = WCD9335_ANA_AMIC1;
  6808. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6809. amic_reg = WCD9335_ANA_AMIC3;
  6810. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6811. amic_reg = WCD9335_ANA_AMIC5;
  6812. ucontrol->value.integer.value[0] =
  6813. (snd_soc_read(codec, amic_reg) & WCD9335_AMIC_PWR_LVL_MASK) >>
  6814. WCD9335_AMIC_PWR_LVL_SHIFT;
  6815. return 0;
  6816. }
  6817. static int tasha_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol,
  6818. struct snd_ctl_elem_value *ucontrol)
  6819. {
  6820. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6821. u32 mode_val;
  6822. u16 amic_reg;
  6823. mode_val = ucontrol->value.enumerated.item[0];
  6824. dev_dbg(codec->dev, "%s: mode: %d\n",
  6825. __func__, mode_val);
  6826. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6827. amic_reg = WCD9335_ANA_AMIC1;
  6828. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6829. amic_reg = WCD9335_ANA_AMIC3;
  6830. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6831. amic_reg = WCD9335_ANA_AMIC5;
  6832. snd_soc_update_bits(codec, amic_reg, WCD9335_AMIC_PWR_LVL_MASK,
  6833. mode_val << WCD9335_AMIC_PWR_LVL_SHIFT);
  6834. return 0;
  6835. }
  6836. static int tasha_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
  6837. struct snd_ctl_elem_value *ucontrol)
  6838. {
  6839. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6840. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6841. ucontrol->value.integer.value[0] = tasha->hph_mode;
  6842. return 0;
  6843. }
  6844. static int tasha_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
  6845. struct snd_ctl_elem_value *ucontrol)
  6846. {
  6847. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6848. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6849. u32 mode_val;
  6850. mode_val = ucontrol->value.enumerated.item[0];
  6851. dev_dbg(codec->dev, "%s: mode: %d\n",
  6852. __func__, mode_val);
  6853. if (mode_val == 0) {
  6854. dev_warn(codec->dev, "%s:Invalid HPH Mode, default to Cls-H HiFi\n",
  6855. __func__);
  6856. mode_val = CLS_H_HIFI;
  6857. }
  6858. tasha->hph_mode = mode_val;
  6859. return 0;
  6860. }
  6861. static const char *const tasha_conn_mad_text[] = {
  6862. "NOTUSED1", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6",
  6863. "NOTUSED2", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4",
  6864. "DMIC5", "NOTUSED3", "NOTUSED4"
  6865. };
  6866. static const struct soc_enum tasha_conn_mad_enum =
  6867. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_conn_mad_text),
  6868. tasha_conn_mad_text);
  6869. static int tasha_enable_ldo_h_get(struct snd_kcontrol *kcontrol,
  6870. struct snd_ctl_elem_value *ucontrol)
  6871. {
  6872. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6873. u8 val = 0;
  6874. if (codec)
  6875. val = snd_soc_read(codec, WCD9335_LDOH_MODE) & 0x80;
  6876. ucontrol->value.integer.value[0] = !!val;
  6877. return 0;
  6878. }
  6879. static int tasha_enable_ldo_h_put(struct snd_kcontrol *kcontrol,
  6880. struct snd_ctl_elem_value *ucontrol)
  6881. {
  6882. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6883. int value = ucontrol->value.integer.value[0];
  6884. bool enable;
  6885. enable = !!value;
  6886. if (codec)
  6887. tasha_codec_enable_standalone_ldo_h(codec, enable);
  6888. return 0;
  6889. }
  6890. static int tasha_mad_input_get(struct snd_kcontrol *kcontrol,
  6891. struct snd_ctl_elem_value *ucontrol)
  6892. {
  6893. u8 tasha_mad_input;
  6894. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6895. tasha_mad_input = snd_soc_read(codec,
  6896. WCD9335_SOC_MAD_INP_SEL) & 0x0F;
  6897. ucontrol->value.integer.value[0] = tasha_mad_input;
  6898. dev_dbg(codec->dev,
  6899. "%s: tasha_mad_input = %s\n", __func__,
  6900. tasha_conn_mad_text[tasha_mad_input]);
  6901. return 0;
  6902. }
  6903. static int tasha_mad_input_put(struct snd_kcontrol *kcontrol,
  6904. struct snd_ctl_elem_value *ucontrol)
  6905. {
  6906. u8 tasha_mad_input;
  6907. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6908. struct snd_soc_card *card = codec->component.card;
  6909. char mad_amic_input_widget[6];
  6910. const char *mad_input_widget;
  6911. const char *source_widget = NULL;
  6912. u32 adc, i, mic_bias_found = 0;
  6913. int ret = 0;
  6914. char *mad_input;
  6915. tasha_mad_input = ucontrol->value.integer.value[0];
  6916. if (tasha_mad_input >= ARRAY_SIZE(tasha_conn_mad_text)) {
  6917. dev_err(codec->dev,
  6918. "%s: tasha_mad_input = %d out of bounds\n",
  6919. __func__, tasha_mad_input);
  6920. return -EINVAL;
  6921. }
  6922. if (!strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED1") ||
  6923. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED2") ||
  6924. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED3") ||
  6925. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED4")) {
  6926. dev_err(codec->dev,
  6927. "%s: Unsupported tasha_mad_input = %s\n",
  6928. __func__, tasha_conn_mad_text[tasha_mad_input]);
  6929. return -EINVAL;
  6930. }
  6931. if (strnstr(tasha_conn_mad_text[tasha_mad_input],
  6932. "ADC", sizeof("ADC"))) {
  6933. mad_input = strpbrk(tasha_conn_mad_text[tasha_mad_input],
  6934. "123456");
  6935. if (!mad_input) {
  6936. dev_err(codec->dev, "%s: Invalid MAD input %s\n",
  6937. __func__,
  6938. tasha_conn_mad_text[tasha_mad_input]);
  6939. return -EINVAL;
  6940. }
  6941. ret = kstrtouint(mad_input, 10, &adc);
  6942. if ((ret < 0) || (adc > 6)) {
  6943. dev_err(codec->dev,
  6944. "%s: Invalid ADC = %s\n", __func__,
  6945. tasha_conn_mad_text[tasha_mad_input]);
  6946. ret = -EINVAL;
  6947. }
  6948. snprintf(mad_amic_input_widget, 6, "%s%u", "AMIC", adc);
  6949. mad_input_widget = mad_amic_input_widget;
  6950. } else {
  6951. /* DMIC type input widget*/
  6952. mad_input_widget = tasha_conn_mad_text[tasha_mad_input];
  6953. }
  6954. dev_dbg(codec->dev,
  6955. "%s: tasha input widget = %s\n", __func__,
  6956. mad_input_widget);
  6957. for (i = 0; i < card->num_of_dapm_routes; i++) {
  6958. if (!strcmp(card->of_dapm_routes[i].sink, mad_input_widget)) {
  6959. source_widget = card->of_dapm_routes[i].source;
  6960. if (!source_widget) {
  6961. dev_err(codec->dev,
  6962. "%s: invalid source widget\n",
  6963. __func__);
  6964. return -EINVAL;
  6965. }
  6966. if (strnstr(source_widget,
  6967. "MIC BIAS1", sizeof("MIC BIAS1"))) {
  6968. mic_bias_found = 1;
  6969. break;
  6970. } else if (strnstr(source_widget,
  6971. "MIC BIAS2", sizeof("MIC BIAS2"))) {
  6972. mic_bias_found = 2;
  6973. break;
  6974. } else if (strnstr(source_widget,
  6975. "MIC BIAS3", sizeof("MIC BIAS3"))) {
  6976. mic_bias_found = 3;
  6977. break;
  6978. } else if (strnstr(source_widget,
  6979. "MIC BIAS4", sizeof("MIC BIAS4"))) {
  6980. mic_bias_found = 4;
  6981. break;
  6982. }
  6983. }
  6984. }
  6985. if (!mic_bias_found) {
  6986. dev_err(codec->dev,
  6987. "%s: mic bias source not found for input = %s\n",
  6988. __func__, mad_input_widget);
  6989. return -EINVAL;
  6990. }
  6991. dev_dbg(codec->dev,
  6992. "%s: mic_bias found = %d\n", __func__,
  6993. mic_bias_found);
  6994. snd_soc_update_bits(codec, WCD9335_SOC_MAD_INP_SEL,
  6995. 0x0F, tasha_mad_input);
  6996. snd_soc_update_bits(codec, WCD9335_ANA_MAD_SETUP,
  6997. 0x07, mic_bias_found);
  6998. return 0;
  6999. }
  7000. static int tasha_pinctl_mode_get(struct snd_kcontrol *kcontrol,
  7001. struct snd_ctl_elem_value *ucontrol)
  7002. {
  7003. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7004. u16 ctl_reg;
  7005. u8 reg_val, pinctl_position;
  7006. pinctl_position = ((struct soc_multi_mixer_control *)
  7007. kcontrol->private_value)->shift;
  7008. switch (pinctl_position >> 3) {
  7009. case 0:
  7010. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7011. break;
  7012. case 1:
  7013. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7014. break;
  7015. case 2:
  7016. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7017. break;
  7018. case 3:
  7019. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7020. break;
  7021. default:
  7022. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7023. __func__, pinctl_position);
  7024. return -EINVAL;
  7025. }
  7026. reg_val = snd_soc_read(codec, ctl_reg);
  7027. reg_val = (reg_val >> (pinctl_position & 0x07)) & 0x1;
  7028. ucontrol->value.integer.value[0] = reg_val;
  7029. return 0;
  7030. }
  7031. static int tasha_pinctl_mode_put(struct snd_kcontrol *kcontrol,
  7032. struct snd_ctl_elem_value *ucontrol)
  7033. {
  7034. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7035. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7036. u16 ctl_reg, cfg_reg;
  7037. u8 ctl_val, cfg_val, pinctl_position, pinctl_mode, mask;
  7038. /* 1- high or low; 0- high Z */
  7039. pinctl_mode = ucontrol->value.integer.value[0];
  7040. pinctl_position = ((struct soc_multi_mixer_control *)
  7041. kcontrol->private_value)->shift;
  7042. switch (pinctl_position >> 3) {
  7043. case 0:
  7044. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7045. break;
  7046. case 1:
  7047. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7048. break;
  7049. case 2:
  7050. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7051. break;
  7052. case 3:
  7053. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7054. break;
  7055. default:
  7056. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7057. __func__, pinctl_position);
  7058. return -EINVAL;
  7059. }
  7060. ctl_val = pinctl_mode << (pinctl_position & 0x07);
  7061. mask = 1 << (pinctl_position & 0x07);
  7062. snd_soc_update_bits(codec, ctl_reg, mask, ctl_val);
  7063. cfg_reg = WCD9335_TLMM_BIST_MODE_PINCFG + pinctl_position;
  7064. if (!pinctl_mode) {
  7065. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  7066. cfg_val = 0x4;
  7067. else
  7068. cfg_val = 0xC;
  7069. } else {
  7070. cfg_val = 0;
  7071. }
  7072. snd_soc_update_bits(codec, cfg_reg, 0x07, cfg_val);
  7073. dev_dbg(codec->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n",
  7074. __func__, ctl_reg, mask, ctl_val, cfg_reg, cfg_val);
  7075. return 0;
  7076. }
  7077. static void wcd_vbat_adc_out_config_2_0(struct wcd_vbat *vbat,
  7078. struct snd_soc_codec *codec)
  7079. {
  7080. u8 val1, val2;
  7081. /*
  7082. * Measure dcp1 by using "ALT" branch of band gap
  7083. * voltage(Vbg) and use it in FAST mode
  7084. */
  7085. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x82, 0x82);
  7086. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7087. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x01);
  7088. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x80);
  7089. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x00);
  7090. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x20);
  7091. /* Wait 100 usec after calibration select as Vbg */
  7092. usleep_range(100, 110);
  7093. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7094. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7095. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7096. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7097. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7098. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x40, 0x40);
  7099. /* Wait 100 usec after selecting Vbg as 1.05V */
  7100. usleep_range(100, 110);
  7101. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7102. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7103. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7104. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7105. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7106. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7107. __func__, vbat->dcp1, vbat->dcp2);
  7108. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7109. /* Wait 100 usec after selecting Vbg as 0.85V */
  7110. usleep_range(100, 110);
  7111. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x00);
  7112. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x20);
  7113. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x00);
  7114. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x00);
  7115. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x00);
  7116. }
  7117. static void wcd_vbat_adc_out_config_1_x(struct wcd_vbat *vbat,
  7118. struct snd_soc_codec *codec)
  7119. {
  7120. u8 val1, val2;
  7121. /*
  7122. * Measure dcp1 by applying band gap voltage(Vbg)
  7123. * of 0.85V
  7124. */
  7125. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x20);
  7126. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7127. snd_soc_write(codec, WCD9335_BIAS_VBG_FINE_ADJ, 0x05);
  7128. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7129. /* Wait 2 sec after enabling band gap bias */
  7130. usleep_range(2000000, 2000100);
  7131. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x82);
  7132. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x87);
  7133. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7134. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0D);
  7135. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01);
  7136. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7137. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xDE);
  7138. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x3C);
  7139. /* Wait 1 msec after calibration select as Vbg */
  7140. usleep_range(1000, 1100);
  7141. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
  7142. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7143. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7144. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7145. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7146. /*
  7147. * Measure dcp2 by applying band gap voltage(Vbg)
  7148. * of 1.05V
  7149. */
  7150. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7151. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7152. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x68);
  7153. /* Wait 2 msec after selecting Vbg as 1.05V */
  7154. usleep_range(2000, 2100);
  7155. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7156. /* Wait 1 sec after enabling band gap bias */
  7157. usleep_range(1000000, 1000100);
  7158. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
  7159. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7160. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7161. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7162. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7163. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7164. __func__, vbat->dcp1, vbat->dcp2);
  7165. /* Reset the Vbat ADC configuration */
  7166. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7167. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7168. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7169. /* Wait 2 msec after selecting Vbg as 0.85V */
  7170. usleep_range(2000, 2100);
  7171. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7172. /* Wait 1 sec after enabling band gap bias */
  7173. usleep_range(1000000, 1000100);
  7174. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x1C);
  7175. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xFE);
  7176. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7177. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7178. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x00);
  7179. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x00);
  7180. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0A);
  7181. }
  7182. static void wcd_vbat_adc_out_config(struct wcd_vbat *vbat,
  7183. struct snd_soc_codec *codec)
  7184. {
  7185. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  7186. if (!vbat->adc_config) {
  7187. tasha_cdc_mclk_enable(codec, true, false);
  7188. if (TASHA_IS_2_0(wcd9xxx))
  7189. wcd_vbat_adc_out_config_2_0(vbat, codec);
  7190. else
  7191. wcd_vbat_adc_out_config_1_x(vbat, codec);
  7192. tasha_cdc_mclk_enable(codec, false, false);
  7193. vbat->adc_config = true;
  7194. }
  7195. }
  7196. static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec)
  7197. {
  7198. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7199. struct firmware_cal *hwdep_cal = NULL;
  7200. struct vbat_monitor_reg *vbat_reg_ptr = NULL;
  7201. const void *data;
  7202. size_t cal_size, vbat_size_remaining;
  7203. int ret = 0, i;
  7204. u32 vbat_writes_size = 0;
  7205. u16 reg;
  7206. u8 mask, val, old_val;
  7207. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_VBAT_CAL);
  7208. if (hwdep_cal) {
  7209. data = hwdep_cal->data;
  7210. cal_size = hwdep_cal->size;
  7211. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7212. __func__);
  7213. } else {
  7214. dev_err(codec->dev, "%s: Vbat cal not received\n",
  7215. __func__);
  7216. ret = -EINVAL;
  7217. goto done;
  7218. }
  7219. if (cal_size < sizeof(*vbat_reg_ptr)) {
  7220. dev_err(codec->dev,
  7221. "%s: Incorrect size %zd for Vbat Cal, expected %zd\n",
  7222. __func__, cal_size, sizeof(*vbat_reg_ptr));
  7223. ret = -EINVAL;
  7224. goto done;
  7225. }
  7226. vbat_reg_ptr = (struct vbat_monitor_reg *) (data);
  7227. if (!vbat_reg_ptr) {
  7228. dev_err(codec->dev,
  7229. "%s: Invalid calibration data for Vbat\n",
  7230. __func__);
  7231. ret = -EINVAL;
  7232. goto done;
  7233. }
  7234. vbat_writes_size = vbat_reg_ptr->size;
  7235. vbat_size_remaining = cal_size - sizeof(u32);
  7236. dev_dbg(codec->dev, "%s: vbat_writes_sz: %d, vbat_sz_remaining: %zd\n",
  7237. __func__, vbat_writes_size, vbat_size_remaining);
  7238. if ((vbat_writes_size * TASHA_PACKED_REG_SIZE)
  7239. > vbat_size_remaining) {
  7240. pr_err("%s: Incorrect Vbat calibration data\n", __func__);
  7241. ret = -EINVAL;
  7242. goto done;
  7243. }
  7244. for (i = 0 ; i < vbat_writes_size; i++) {
  7245. TASHA_CODEC_UNPACK_ENTRY(vbat_reg_ptr->writes[i],
  7246. reg, mask, val);
  7247. old_val = snd_soc_read(codec, reg);
  7248. snd_soc_write(codec, reg, (old_val & ~mask) | (val & mask));
  7249. }
  7250. done:
  7251. return ret;
  7252. }
  7253. static int tasha_vbat_adc_data_get(struct snd_kcontrol *kcontrol,
  7254. struct snd_ctl_elem_value *ucontrol)
  7255. {
  7256. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7257. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7258. wcd_vbat_adc_out_config(&tasha->vbat, codec);
  7259. ucontrol->value.integer.value[0] = tasha->vbat.dcp1;
  7260. ucontrol->value.integer.value[1] = tasha->vbat.dcp2;
  7261. dev_dbg(codec->dev,
  7262. "%s: Vbat ADC output values, Dcp1 : %lu, Dcp2: %lu\n",
  7263. __func__, ucontrol->value.integer.value[0],
  7264. ucontrol->value.integer.value[1]);
  7265. return 0;
  7266. }
  7267. static const char * const tasha_vbat_gsm_mode_text[] = {
  7268. "OFF", "ON"};
  7269. static const struct soc_enum tasha_vbat_gsm_mode_enum =
  7270. SOC_ENUM_SINGLE_EXT(2, tasha_vbat_gsm_mode_text);
  7271. static int tasha_vbat_gsm_mode_func_get(struct snd_kcontrol *kcontrol,
  7272. struct snd_ctl_elem_value *ucontrol)
  7273. {
  7274. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7275. ucontrol->value.integer.value[0] =
  7276. ((snd_soc_read(codec, WCD9335_CDC_VBAT_VBAT_CFG) & 0x04) ?
  7277. 1 : 0);
  7278. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7279. ucontrol->value.integer.value[0]);
  7280. return 0;
  7281. }
  7282. static int tasha_vbat_gsm_mode_func_put(struct snd_kcontrol *kcontrol,
  7283. struct snd_ctl_elem_value *ucontrol)
  7284. {
  7285. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7286. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7287. ucontrol->value.integer.value[0]);
  7288. /* Set Vbat register configuration for GSM mode bit based on value */
  7289. if (ucontrol->value.integer.value[0])
  7290. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7291. 0x04, 0x04);
  7292. else
  7293. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7294. 0x04, 0x00);
  7295. return 0;
  7296. }
  7297. static int tasha_codec_vbat_enable_event(struct snd_soc_dapm_widget *w,
  7298. struct snd_kcontrol *kcontrol,
  7299. int event)
  7300. {
  7301. int ret = 0;
  7302. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7303. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7304. u16 vbat_path_ctl, vbat_cfg, vbat_path_cfg;
  7305. vbat_path_ctl = WCD9335_CDC_VBAT_VBAT_PATH_CTL;
  7306. vbat_cfg = WCD9335_CDC_VBAT_VBAT_CFG;
  7307. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7308. if (!strcmp(w->name, "RX INT8 VBAT"))
  7309. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7310. else if (!strcmp(w->name, "RX INT7 VBAT"))
  7311. vbat_path_cfg = WCD9335_CDC_RX7_RX_PATH_CFG1;
  7312. else if (!strcmp(w->name, "RX INT6 VBAT"))
  7313. vbat_path_cfg = WCD9335_CDC_RX6_RX_PATH_CFG1;
  7314. else if (!strcmp(w->name, "RX INT5 VBAT"))
  7315. vbat_path_cfg = WCD9335_CDC_RX5_RX_PATH_CFG1;
  7316. switch (event) {
  7317. case SND_SOC_DAPM_PRE_PMU:
  7318. ret = tasha_update_vbat_reg_config(codec);
  7319. if (ret) {
  7320. dev_dbg(codec->dev,
  7321. "%s : VBAT isn't calibrated, So not enabling it\n",
  7322. __func__);
  7323. return 0;
  7324. }
  7325. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7326. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x02);
  7327. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x10);
  7328. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x01);
  7329. tasha->vbat.is_enabled = true;
  7330. break;
  7331. case SND_SOC_DAPM_POST_PMD:
  7332. if (tasha->vbat.is_enabled) {
  7333. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x00);
  7334. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x00);
  7335. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x00);
  7336. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7337. tasha->vbat.is_enabled = false;
  7338. }
  7339. break;
  7340. };
  7341. return ret;
  7342. }
  7343. static const char * const rx_hph_mode_mux_text[] = {
  7344. "CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI"
  7345. };
  7346. static const struct soc_enum rx_hph_mode_mux_enum =
  7347. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text),
  7348. rx_hph_mode_mux_text);
  7349. static const char * const amic_pwr_lvl_text[] = {
  7350. "LOW_PWR", "DEFAULT", "HIGH_PERF"
  7351. };
  7352. static const struct soc_enum amic_pwr_lvl_enum =
  7353. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amic_pwr_lvl_text),
  7354. amic_pwr_lvl_text);
  7355. static const struct snd_kcontrol_new tasha_snd_controls[] = {
  7356. SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
  7357. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7358. SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
  7359. 0, -84, 40, digital_gain),
  7360. SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
  7361. 0, -84, 40, digital_gain),
  7362. SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
  7363. 0, -84, 40, digital_gain),
  7364. SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
  7365. 0, -84, 40, digital_gain),
  7366. SOC_SINGLE_SX_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
  7367. 0, -84, 40, digital_gain),
  7368. SOC_SINGLE_SX_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
  7369. 0, -84, 40, digital_gain),
  7370. SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
  7371. 0, -84, 40, digital_gain),
  7372. SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
  7373. 0, -84, 40, digital_gain),
  7374. SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
  7375. WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
  7376. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7377. SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
  7378. WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
  7379. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7380. SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
  7381. WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
  7382. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7383. SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
  7384. WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
  7385. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7386. SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
  7387. WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
  7388. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7389. SOC_SINGLE_SX_TLV("RX5 Mix Digital Volume",
  7390. WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
  7391. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7392. SOC_SINGLE_SX_TLV("RX6 Mix Digital Volume",
  7393. WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
  7394. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7395. SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
  7396. WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
  7397. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7398. SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
  7399. WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
  7400. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7401. SOC_SINGLE_SX_TLV("DEC0 Volume", WCD9335_CDC_TX0_TX_VOL_CTL, 0,
  7402. -84, 40, digital_gain),
  7403. SOC_SINGLE_SX_TLV("DEC1 Volume", WCD9335_CDC_TX1_TX_VOL_CTL, 0,
  7404. -84, 40, digital_gain),
  7405. SOC_SINGLE_SX_TLV("DEC2 Volume", WCD9335_CDC_TX2_TX_VOL_CTL, 0,
  7406. -84, 40, digital_gain),
  7407. SOC_SINGLE_SX_TLV("DEC3 Volume", WCD9335_CDC_TX3_TX_VOL_CTL, 0,
  7408. -84, 40, digital_gain),
  7409. SOC_SINGLE_SX_TLV("DEC4 Volume", WCD9335_CDC_TX4_TX_VOL_CTL, 0,
  7410. -84, 40, digital_gain),
  7411. SOC_SINGLE_SX_TLV("DEC5 Volume", WCD9335_CDC_TX5_TX_VOL_CTL, 0,
  7412. -84, 40, digital_gain),
  7413. SOC_SINGLE_SX_TLV("DEC6 Volume", WCD9335_CDC_TX6_TX_VOL_CTL, 0,
  7414. -84, 40, digital_gain),
  7415. SOC_SINGLE_SX_TLV("DEC7 Volume", WCD9335_CDC_TX7_TX_VOL_CTL, 0,
  7416. -84, 40, digital_gain),
  7417. SOC_SINGLE_SX_TLV("DEC8 Volume", WCD9335_CDC_TX8_TX_VOL_CTL, 0,
  7418. -84, 40, digital_gain),
  7419. SOC_SINGLE_SX_TLV("IIR0 INP0 Volume",
  7420. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, -84,
  7421. 40, digital_gain),
  7422. SOC_SINGLE_SX_TLV("IIR0 INP1 Volume",
  7423. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, -84,
  7424. 40, digital_gain),
  7425. SOC_SINGLE_SX_TLV("IIR0 INP2 Volume",
  7426. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, -84,
  7427. 40, digital_gain),
  7428. SOC_SINGLE_SX_TLV("IIR0 INP3 Volume",
  7429. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, -84,
  7430. 40, digital_gain),
  7431. SOC_SINGLE_SX_TLV("IIR1 INP0 Volume",
  7432. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, -84,
  7433. 40, digital_gain),
  7434. SOC_SINGLE_SX_TLV("IIR1 INP1 Volume",
  7435. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, -84,
  7436. 40, digital_gain),
  7437. SOC_SINGLE_SX_TLV("IIR1 INP2 Volume",
  7438. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, -84,
  7439. 40, digital_gain),
  7440. SOC_SINGLE_SX_TLV("IIR1 INP3 Volume",
  7441. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, -84,
  7442. 40, digital_gain),
  7443. SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 100, 0, tasha_get_anc_slot,
  7444. tasha_put_anc_slot),
  7445. SOC_ENUM_EXT("ANC Function", tasha_anc_func_enum, tasha_get_anc_func,
  7446. tasha_put_anc_func),
  7447. SOC_ENUM_EXT("CLK MODE", tasha_clkmode_enum, tasha_get_clkmode,
  7448. tasha_put_clkmode),
  7449. SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
  7450. SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
  7451. SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
  7452. SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
  7453. SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
  7454. SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
  7455. SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
  7456. SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
  7457. SOC_ENUM("TX8 HPF cut off", cf_dec8_enum),
  7458. SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
  7459. SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
  7460. SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
  7461. SOC_ENUM("RX INT1_2 HPF cut off", cf_int1_2_enum),
  7462. SOC_ENUM("RX INT2_1 HPF cut off", cf_int2_1_enum),
  7463. SOC_ENUM("RX INT2_2 HPF cut off", cf_int2_2_enum),
  7464. SOC_ENUM("RX INT3_1 HPF cut off", cf_int3_1_enum),
  7465. SOC_ENUM("RX INT3_2 HPF cut off", cf_int3_2_enum),
  7466. SOC_ENUM("RX INT4_1 HPF cut off", cf_int4_1_enum),
  7467. SOC_ENUM("RX INT4_2 HPF cut off", cf_int4_2_enum),
  7468. SOC_ENUM("RX INT5_1 HPF cut off", cf_int5_1_enum),
  7469. SOC_ENUM("RX INT5_2 HPF cut off", cf_int5_2_enum),
  7470. SOC_ENUM("RX INT6_1 HPF cut off", cf_int6_1_enum),
  7471. SOC_ENUM("RX INT6_2 HPF cut off", cf_int6_2_enum),
  7472. SOC_ENUM("RX INT7_1 HPF cut off", cf_int7_1_enum),
  7473. SOC_ENUM("RX INT7_2 HPF cut off", cf_int7_2_enum),
  7474. SOC_ENUM("RX INT8_1 HPF cut off", cf_int8_1_enum),
  7475. SOC_ENUM("RX INT8_2 HPF cut off", cf_int8_2_enum),
  7476. SOC_SINGLE_EXT("IIR0 Enable Band1", IIR0, BAND1, 1, 0,
  7477. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7478. SOC_SINGLE_EXT("IIR0 Enable Band2", IIR0, BAND2, 1, 0,
  7479. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7480. SOC_SINGLE_EXT("IIR0 Enable Band3", IIR0, BAND3, 1, 0,
  7481. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7482. SOC_SINGLE_EXT("IIR0 Enable Band4", IIR0, BAND4, 1, 0,
  7483. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7484. SOC_SINGLE_EXT("IIR0 Enable Band5", IIR0, BAND5, 1, 0,
  7485. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7486. SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0,
  7487. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7488. SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
  7489. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7490. SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
  7491. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7492. SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
  7493. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7494. SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
  7495. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7496. SOC_SINGLE_MULTI_EXT("IIR0 Band1", IIR0, BAND1, 255, 0, 5,
  7497. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7498. SOC_SINGLE_MULTI_EXT("IIR0 Band2", IIR0, BAND2, 255, 0, 5,
  7499. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7500. SOC_SINGLE_MULTI_EXT("IIR0 Band3", IIR0, BAND3, 255, 0, 5,
  7501. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7502. SOC_SINGLE_MULTI_EXT("IIR0 Band4", IIR0, BAND4, 255, 0, 5,
  7503. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7504. SOC_SINGLE_MULTI_EXT("IIR0 Band5", IIR0, BAND5, 255, 0, 5,
  7505. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7506. SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
  7507. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7508. SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
  7509. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7510. SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
  7511. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7512. SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
  7513. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7514. SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
  7515. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7516. SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0,
  7517. tasha_get_compander, tasha_set_compander),
  7518. SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0,
  7519. tasha_get_compander, tasha_set_compander),
  7520. SOC_SINGLE_EXT("COMP3 Switch", SND_SOC_NOPM, COMPANDER_3, 1, 0,
  7521. tasha_get_compander, tasha_set_compander),
  7522. SOC_SINGLE_EXT("COMP4 Switch", SND_SOC_NOPM, COMPANDER_4, 1, 0,
  7523. tasha_get_compander, tasha_set_compander),
  7524. SOC_SINGLE_EXT("COMP5 Switch", SND_SOC_NOPM, COMPANDER_5, 1, 0,
  7525. tasha_get_compander, tasha_set_compander),
  7526. SOC_SINGLE_EXT("COMP6 Switch", SND_SOC_NOPM, COMPANDER_6, 1, 0,
  7527. tasha_get_compander, tasha_set_compander),
  7528. SOC_SINGLE_EXT("COMP7 Switch", SND_SOC_NOPM, COMPANDER_7, 1, 0,
  7529. tasha_get_compander, tasha_set_compander),
  7530. SOC_SINGLE_EXT("COMP8 Switch", SND_SOC_NOPM, COMPANDER_8, 1, 0,
  7531. tasha_get_compander, tasha_set_compander),
  7532. SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum,
  7533. tasha_rx_hph_mode_get, tasha_rx_hph_mode_put),
  7534. SOC_ENUM_EXT("MAD Input", tasha_conn_mad_enum,
  7535. tasha_mad_input_get, tasha_mad_input_put),
  7536. SOC_SINGLE_EXT("LDO_H Enable", SND_SOC_NOPM, 0, 1, 0,
  7537. tasha_enable_ldo_h_get, tasha_enable_ldo_h_put),
  7538. SOC_SINGLE_EXT("DMIC1_CLK_PIN_MODE", SND_SOC_NOPM, 17, 1, 0,
  7539. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7540. SOC_SINGLE_EXT("DMIC1_DATA_PIN_MODE", SND_SOC_NOPM, 18, 1, 0,
  7541. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7542. SOC_SINGLE_EXT("DMIC2_CLK_PIN_MODE", SND_SOC_NOPM, 19, 1, 0,
  7543. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7544. SOC_SINGLE_EXT("DMIC2_DATA_PIN_MODE", SND_SOC_NOPM, 20, 1, 0,
  7545. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7546. SOC_SINGLE_EXT("DMIC3_CLK_PIN_MODE", SND_SOC_NOPM, 21, 1, 0,
  7547. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7548. SOC_SINGLE_EXT("DMIC3_DATA_PIN_MODE", SND_SOC_NOPM, 22, 1, 0,
  7549. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7550. SOC_ENUM_EXT("AMIC_1_2 PWR MODE", amic_pwr_lvl_enum,
  7551. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7552. SOC_ENUM_EXT("AMIC_3_4 PWR MODE", amic_pwr_lvl_enum,
  7553. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7554. SOC_ENUM_EXT("AMIC_5_6 PWR MODE", amic_pwr_lvl_enum,
  7555. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7556. SOC_SINGLE_MULTI_EXT("Vbat ADC data", SND_SOC_NOPM, 0, 0xFFFF, 0, 2,
  7557. tasha_vbat_adc_data_get, NULL),
  7558. SOC_ENUM_EXT("GSM mode Enable", tasha_vbat_gsm_mode_enum,
  7559. tasha_vbat_gsm_mode_func_get,
  7560. tasha_vbat_gsm_mode_func_put),
  7561. };
  7562. static int tasha_put_dec_enum(struct snd_kcontrol *kcontrol,
  7563. struct snd_ctl_elem_value *ucontrol)
  7564. {
  7565. struct snd_soc_dapm_widget *widget =
  7566. snd_soc_dapm_kcontrol_widget(kcontrol);
  7567. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7568. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7569. unsigned int val;
  7570. u16 mic_sel_reg;
  7571. u8 mic_sel;
  7572. val = ucontrol->value.enumerated.item[0];
  7573. if (val > e->items - 1)
  7574. return -EINVAL;
  7575. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7576. widget->name, val);
  7577. switch (e->reg) {
  7578. case WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1:
  7579. mic_sel_reg = WCD9335_CDC_TX0_TX_PATH_CFG0;
  7580. break;
  7581. case WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1:
  7582. mic_sel_reg = WCD9335_CDC_TX1_TX_PATH_CFG0;
  7583. break;
  7584. case WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1:
  7585. mic_sel_reg = WCD9335_CDC_TX2_TX_PATH_CFG0;
  7586. break;
  7587. case WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1:
  7588. mic_sel_reg = WCD9335_CDC_TX3_TX_PATH_CFG0;
  7589. break;
  7590. case WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0:
  7591. mic_sel_reg = WCD9335_CDC_TX4_TX_PATH_CFG0;
  7592. break;
  7593. case WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0:
  7594. mic_sel_reg = WCD9335_CDC_TX5_TX_PATH_CFG0;
  7595. break;
  7596. case WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0:
  7597. mic_sel_reg = WCD9335_CDC_TX6_TX_PATH_CFG0;
  7598. break;
  7599. case WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0:
  7600. mic_sel_reg = WCD9335_CDC_TX7_TX_PATH_CFG0;
  7601. break;
  7602. case WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0:
  7603. mic_sel_reg = WCD9335_CDC_TX8_TX_PATH_CFG0;
  7604. break;
  7605. default:
  7606. dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n",
  7607. __func__, e->reg);
  7608. return -EINVAL;
  7609. }
  7610. /* ADC: 0, DMIC: 1 */
  7611. mic_sel = val ? 0x0 : 0x1;
  7612. snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, mic_sel << 7);
  7613. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7614. }
  7615. static int tasha_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol,
  7616. struct snd_ctl_elem_value *ucontrol)
  7617. {
  7618. struct snd_soc_dapm_widget *widget =
  7619. snd_soc_dapm_kcontrol_widget(kcontrol);
  7620. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7621. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7622. unsigned int val;
  7623. unsigned short look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7624. val = ucontrol->value.enumerated.item[0];
  7625. if (val >= e->items)
  7626. return -EINVAL;
  7627. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7628. widget->name, val);
  7629. if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0)
  7630. look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7631. else if (e->reg == WCD9335_CDC_RX1_RX_PATH_SEC0)
  7632. look_ahead_dly_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  7633. else if (e->reg == WCD9335_CDC_RX2_RX_PATH_SEC0)
  7634. look_ahead_dly_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  7635. /* Set Look Ahead Delay */
  7636. snd_soc_update_bits(codec, look_ahead_dly_reg,
  7637. 0x08, (val ? 0x08 : 0x00));
  7638. /* Set DEM INP Select */
  7639. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7640. }
  7641. static int tasha_ear_pa_gain_get(struct snd_kcontrol *kcontrol,
  7642. struct snd_ctl_elem_value *ucontrol)
  7643. {
  7644. u8 ear_pa_gain;
  7645. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7646. ear_pa_gain = snd_soc_read(codec, WCD9335_ANA_EAR);
  7647. ear_pa_gain = (ear_pa_gain & 0x70) >> 4;
  7648. ucontrol->value.integer.value[0] = ear_pa_gain;
  7649. dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__,
  7650. ear_pa_gain);
  7651. return 0;
  7652. }
  7653. static int tasha_ear_pa_gain_put(struct snd_kcontrol *kcontrol,
  7654. struct snd_ctl_elem_value *ucontrol)
  7655. {
  7656. u8 ear_pa_gain;
  7657. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7658. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7659. __func__, ucontrol->value.integer.value[0]);
  7660. ear_pa_gain = ucontrol->value.integer.value[0] << 4;
  7661. snd_soc_update_bits(codec, WCD9335_ANA_EAR, 0x70, ear_pa_gain);
  7662. return 0;
  7663. }
  7664. static int tasha_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
  7665. struct snd_ctl_elem_value *ucontrol)
  7666. {
  7667. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7668. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7669. ucontrol->value.integer.value[0] = tasha->ear_spkr_gain;
  7670. dev_dbg(codec->dev, "%s: ear_spkr_gain = %ld\n", __func__,
  7671. ucontrol->value.integer.value[0]);
  7672. return 0;
  7673. }
  7674. static int tasha_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
  7675. struct snd_ctl_elem_value *ucontrol)
  7676. {
  7677. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7678. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7679. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7680. __func__, ucontrol->value.integer.value[0]);
  7681. tasha->ear_spkr_gain = ucontrol->value.integer.value[0];
  7682. return 0;
  7683. }
  7684. static int tasha_config_compander(struct snd_soc_codec *codec, int interp_n,
  7685. int event)
  7686. {
  7687. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7688. int comp;
  7689. u16 comp_ctl0_reg, rx_path_cfg0_reg;
  7690. /* EAR does not have compander */
  7691. if (!interp_n)
  7692. return 0;
  7693. comp = interp_n - 1;
  7694. dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n",
  7695. __func__, event, comp + 1, tasha->comp_enabled[comp]);
  7696. if (!tasha->comp_enabled[comp])
  7697. return 0;
  7698. comp_ctl0_reg = WCD9335_CDC_COMPANDER1_CTL0 + (comp * 8);
  7699. rx_path_cfg0_reg = WCD9335_CDC_RX1_RX_PATH_CFG0 + (comp * 20);
  7700. if (SND_SOC_DAPM_EVENT_ON(event)) {
  7701. /* Enable Compander Clock */
  7702. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01);
  7703. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7704. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7705. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02);
  7706. }
  7707. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  7708. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04);
  7709. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00);
  7710. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7711. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7712. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00);
  7713. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00);
  7714. }
  7715. return 0;
  7716. }
  7717. static int tasha_codec_config_mad(struct snd_soc_codec *codec)
  7718. {
  7719. int ret = 0;
  7720. int idx;
  7721. const struct firmware *fw;
  7722. struct firmware_cal *hwdep_cal = NULL;
  7723. struct wcd_mad_audio_cal *mad_cal = NULL;
  7724. const void *data;
  7725. const char *filename = TASHA_MAD_AUDIO_FIRMWARE_PATH;
  7726. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7727. size_t cal_size;
  7728. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_MAD_CAL);
  7729. if (hwdep_cal) {
  7730. data = hwdep_cal->data;
  7731. cal_size = hwdep_cal->size;
  7732. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7733. __func__);
  7734. } else {
  7735. ret = request_firmware(&fw, filename, codec->dev);
  7736. if (ret || !fw) {
  7737. dev_err(codec->dev,
  7738. "%s: MAD firmware acquire failed, err = %d\n",
  7739. __func__, ret);
  7740. return -ENODEV;
  7741. }
  7742. data = fw->data;
  7743. cal_size = fw->size;
  7744. dev_dbg(codec->dev, "%s: using request_firmware calibration\n",
  7745. __func__);
  7746. }
  7747. if (cal_size < sizeof(*mad_cal)) {
  7748. dev_err(codec->dev,
  7749. "%s: Incorrect size %zd for MAD Cal, expected %zd\n",
  7750. __func__, cal_size, sizeof(*mad_cal));
  7751. ret = -ENOMEM;
  7752. goto done;
  7753. }
  7754. mad_cal = (struct wcd_mad_audio_cal *) (data);
  7755. if (!mad_cal) {
  7756. dev_err(codec->dev,
  7757. "%s: Invalid calibration data\n",
  7758. __func__);
  7759. ret = -EINVAL;
  7760. goto done;
  7761. }
  7762. snd_soc_write(codec, WCD9335_SOC_MAD_MAIN_CTL_2,
  7763. mad_cal->microphone_info.cycle_time);
  7764. snd_soc_update_bits(codec, WCD9335_SOC_MAD_MAIN_CTL_1, 0xFF << 3,
  7765. ((uint16_t)mad_cal->microphone_info.settle_time)
  7766. << 3);
  7767. /* Audio */
  7768. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_8,
  7769. mad_cal->audio_info.rms_omit_samples);
  7770. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_1,
  7771. 0x07 << 4, mad_cal->audio_info.rms_comp_time << 4);
  7772. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03 << 2,
  7773. mad_cal->audio_info.detection_mechanism << 2);
  7774. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_7,
  7775. mad_cal->audio_info.rms_diff_threshold & 0x3F);
  7776. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_5,
  7777. mad_cal->audio_info.rms_threshold_lsb);
  7778. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_6,
  7779. mad_cal->audio_info.rms_threshold_msb);
  7780. for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients);
  7781. idx++) {
  7782. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR,
  7783. 0x3F, idx);
  7784. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL,
  7785. mad_cal->audio_info.iir_coefficients[idx]);
  7786. dev_dbg(codec->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x",
  7787. __func__, idx,
  7788. mad_cal->audio_info.iir_coefficients[idx]);
  7789. }
  7790. /* Beacon */
  7791. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_8,
  7792. mad_cal->beacon_info.rms_omit_samples);
  7793. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_1,
  7794. 0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4);
  7795. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_2, 0x03 << 2,
  7796. mad_cal->beacon_info.detection_mechanism << 2);
  7797. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_7,
  7798. mad_cal->beacon_info.rms_diff_threshold & 0x1F);
  7799. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_5,
  7800. mad_cal->beacon_info.rms_threshold_lsb);
  7801. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_6,
  7802. mad_cal->beacon_info.rms_threshold_msb);
  7803. for (idx = 0; idx < ARRAY_SIZE(mad_cal->beacon_info.iir_coefficients);
  7804. idx++) {
  7805. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR,
  7806. 0x3F, idx);
  7807. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL,
  7808. mad_cal->beacon_info.iir_coefficients[idx]);
  7809. dev_dbg(codec->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x",
  7810. __func__, idx,
  7811. mad_cal->beacon_info.iir_coefficients[idx]);
  7812. }
  7813. /* Ultrasound */
  7814. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_1,
  7815. 0x07 << 4,
  7816. mad_cal->ultrasound_info.rms_comp_time << 4);
  7817. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_2, 0x03 << 2,
  7818. mad_cal->ultrasound_info.detection_mechanism << 2);
  7819. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_7,
  7820. mad_cal->ultrasound_info.rms_diff_threshold & 0x1F);
  7821. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_5,
  7822. mad_cal->ultrasound_info.rms_threshold_lsb);
  7823. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_6,
  7824. mad_cal->ultrasound_info.rms_threshold_msb);
  7825. done:
  7826. if (!hwdep_cal)
  7827. release_firmware(fw);
  7828. return ret;
  7829. }
  7830. static int tasha_codec_enable_mad(struct snd_soc_dapm_widget *w,
  7831. struct snd_kcontrol *kcontrol, int event)
  7832. {
  7833. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7834. int ret = 0;
  7835. dev_dbg(codec->dev,
  7836. "%s: event = %d\n", __func__, event);
  7837. /* Return if CPE INPUT is DEC1 */
  7838. if (snd_soc_read(codec, WCD9335_CPE_SS_SVA_CFG) & 0x01)
  7839. return ret;
  7840. switch (event) {
  7841. case SND_SOC_DAPM_PRE_PMU:
  7842. /* Turn on MAD clk */
  7843. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7844. 0x01, 0x01);
  7845. /* Undo reset for MAD */
  7846. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7847. 0x02, 0x00);
  7848. ret = tasha_codec_config_mad(codec);
  7849. if (ret)
  7850. dev_err(codec->dev,
  7851. "%s: Failed to config MAD, err = %d\n",
  7852. __func__, ret);
  7853. break;
  7854. case SND_SOC_DAPM_POST_PMD:
  7855. /* Reset the MAD block */
  7856. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7857. 0x02, 0x02);
  7858. /* Turn off MAD clk */
  7859. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7860. 0x01, 0x00);
  7861. break;
  7862. }
  7863. return ret;
  7864. }
  7865. static int tasha_codec_configure_cpe_input(struct snd_soc_dapm_widget *w,
  7866. struct snd_kcontrol *kcontrol, int event)
  7867. {
  7868. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7869. dev_dbg(codec->dev,
  7870. "%s: event = %d\n", __func__, event);
  7871. switch (event) {
  7872. case SND_SOC_DAPM_PRE_PMU:
  7873. /* Configure CPE input as DEC1 */
  7874. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7875. 0x01, 0x01);
  7876. /* Configure DEC1 Tx out with sample rate as 16K */
  7877. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7878. 0x0F, 0x01);
  7879. break;
  7880. case SND_SOC_DAPM_POST_PMD:
  7881. /* Reset DEC1 Tx out sample rate */
  7882. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7883. 0x0F, 0x04);
  7884. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7885. 0x01, 0x00);
  7886. break;
  7887. }
  7888. return 0;
  7889. }
  7890. static int tasha_codec_aif4_mixer_switch_get(struct snd_kcontrol *kcontrol,
  7891. struct snd_ctl_elem_value *ucontrol)
  7892. {
  7893. struct snd_soc_dapm_widget *widget =
  7894. snd_soc_dapm_kcontrol_widget(kcontrol);
  7895. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7896. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7897. if (test_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask))
  7898. ucontrol->value.integer.value[0] = 1;
  7899. else
  7900. ucontrol->value.integer.value[0] = 0;
  7901. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7902. __func__, ucontrol->value.integer.value[0]);
  7903. return 0;
  7904. }
  7905. static int tasha_codec_aif4_mixer_switch_put(struct snd_kcontrol *kcontrol,
  7906. struct snd_ctl_elem_value *ucontrol)
  7907. {
  7908. struct snd_soc_dapm_widget *widget =
  7909. snd_soc_dapm_kcontrol_widget(kcontrol);
  7910. struct snd_soc_dapm_update *update = NULL;
  7911. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7912. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7913. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7914. __func__, ucontrol->value.integer.value[0]);
  7915. if (ucontrol->value.integer.value[0]) {
  7916. snd_soc_dapm_mixer_update_power(widget->dapm,
  7917. kcontrol, 1, update);
  7918. set_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7919. } else {
  7920. snd_soc_dapm_mixer_update_power(widget->dapm,
  7921. kcontrol, 0, update);
  7922. clear_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7923. }
  7924. return 1;
  7925. }
  7926. static const char * const tasha_ear_pa_gain_text[] = {
  7927. "G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB",
  7928. "G_0_DB", "G_M2P5_DB", "UNDEFINED", "G_M12_DB"
  7929. };
  7930. static const char * const tasha_ear_spkr_pa_gain_text[] = {
  7931. "G_DEFAULT", "G_0_DB", "G_1_DB", "G_2_DB", "G_3_DB", "G_4_DB",
  7932. "G_5_DB", "G_6_DB"
  7933. };
  7934. static const struct soc_enum tasha_ear_pa_gain_enum =
  7935. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_pa_gain_text),
  7936. tasha_ear_pa_gain_text);
  7937. static const struct soc_enum tasha_ear_spkr_pa_gain_enum =
  7938. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_spkr_pa_gain_text),
  7939. tasha_ear_spkr_pa_gain_text);
  7940. static const struct snd_kcontrol_new tasha_analog_gain_controls[] = {
  7941. SOC_ENUM_EXT("EAR PA Gain", tasha_ear_pa_gain_enum,
  7942. tasha_ear_pa_gain_get, tasha_ear_pa_gain_put),
  7943. SOC_ENUM_EXT("EAR SPKR PA Gain", tasha_ear_spkr_pa_gain_enum,
  7944. tasha_ear_spkr_pa_gain_get, tasha_ear_spkr_pa_gain_put),
  7945. SOC_SINGLE_TLV("HPHL Volume", WCD9335_HPH_L_EN, 0, 20, 1,
  7946. line_gain),
  7947. SOC_SINGLE_TLV("HPHR Volume", WCD9335_HPH_R_EN, 0, 20, 1,
  7948. line_gain),
  7949. SOC_SINGLE_TLV("LINEOUT1 Volume", WCD9335_DIFF_LO_LO1_COMPANDER,
  7950. 3, 16, 1, line_gain),
  7951. SOC_SINGLE_TLV("LINEOUT2 Volume", WCD9335_DIFF_LO_LO2_COMPANDER,
  7952. 3, 16, 1, line_gain),
  7953. SOC_SINGLE_TLV("LINEOUT3 Volume", WCD9335_SE_LO_LO3_GAIN, 0, 20, 1,
  7954. line_gain),
  7955. SOC_SINGLE_TLV("LINEOUT4 Volume", WCD9335_SE_LO_LO4_GAIN, 0, 20, 1,
  7956. line_gain),
  7957. SOC_SINGLE_TLV("ADC1 Volume", WCD9335_ANA_AMIC1, 0, 20, 0,
  7958. analog_gain),
  7959. SOC_SINGLE_TLV("ADC2 Volume", WCD9335_ANA_AMIC2, 0, 20, 0,
  7960. analog_gain),
  7961. SOC_SINGLE_TLV("ADC3 Volume", WCD9335_ANA_AMIC3, 0, 20, 0,
  7962. analog_gain),
  7963. SOC_SINGLE_TLV("ADC4 Volume", WCD9335_ANA_AMIC4, 0, 20, 0,
  7964. analog_gain),
  7965. SOC_SINGLE_TLV("ADC5 Volume", WCD9335_ANA_AMIC5, 0, 20, 0,
  7966. analog_gain),
  7967. SOC_SINGLE_TLV("ADC6 Volume", WCD9335_ANA_AMIC6, 0, 20, 0,
  7968. analog_gain),
  7969. };
  7970. static const char * const spl_src0_mux_text[] = {
  7971. "ZERO", "SRC_IN_HPHL", "SRC_IN_LO1",
  7972. };
  7973. static const char * const spl_src1_mux_text[] = {
  7974. "ZERO", "SRC_IN_HPHR", "SRC_IN_LO2",
  7975. };
  7976. static const char * const spl_src2_mux_text[] = {
  7977. "ZERO", "SRC_IN_LO3", "SRC_IN_SPKRL",
  7978. };
  7979. static const char * const spl_src3_mux_text[] = {
  7980. "ZERO", "SRC_IN_LO4", "SRC_IN_SPKRR",
  7981. };
  7982. static const char * const rx_int0_7_mix_mux_text[] = {
  7983. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  7984. "RX6", "RX7", "PROXIMITY"
  7985. };
  7986. static const char * const rx_int_mix_mux_text[] = {
  7987. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  7988. "RX6", "RX7"
  7989. };
  7990. static const char * const rx_prim_mix_text[] = {
  7991. "ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2",
  7992. "RX3", "RX4", "RX5", "RX6", "RX7"
  7993. };
  7994. static const char * const rx_sidetone_mix_text[] = {
  7995. "ZERO", "SRC0", "SRC1", "SRC_SUM"
  7996. };
  7997. static const char * const sb_tx0_mux_text[] = {
  7998. "ZERO", "RX_MIX_TX0", "DEC0", "DEC0_192"
  7999. };
  8000. static const char * const sb_tx1_mux_text[] = {
  8001. "ZERO", "RX_MIX_TX1", "DEC1", "DEC1_192"
  8002. };
  8003. static const char * const sb_tx2_mux_text[] = {
  8004. "ZERO", "RX_MIX_TX2", "DEC2", "DEC2_192"
  8005. };
  8006. static const char * const sb_tx3_mux_text[] = {
  8007. "ZERO", "RX_MIX_TX3", "DEC3", "DEC3_192"
  8008. };
  8009. static const char * const sb_tx4_mux_text[] = {
  8010. "ZERO", "RX_MIX_TX4", "DEC4", "DEC4_192"
  8011. };
  8012. static const char * const sb_tx5_mux_text[] = {
  8013. "ZERO", "RX_MIX_TX5", "DEC5", "DEC5_192"
  8014. };
  8015. static const char * const sb_tx6_mux_text[] = {
  8016. "ZERO", "RX_MIX_TX6", "DEC6", "DEC6_192"
  8017. };
  8018. static const char * const sb_tx7_mux_text[] = {
  8019. "ZERO", "RX_MIX_TX7", "DEC7", "DEC7_192"
  8020. };
  8021. static const char * const sb_tx8_mux_text[] = {
  8022. "ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192"
  8023. };
  8024. static const char * const sb_tx9_mux_text[] = {
  8025. "ZERO", "DEC7", "DEC7_192"
  8026. };
  8027. static const char * const sb_tx10_mux_text[] = {
  8028. "ZERO", "DEC6", "DEC6_192"
  8029. };
  8030. static const char * const sb_tx11_mux_text[] = {
  8031. "DEC_0_5", "DEC_9_12", "MAD_AUDIO", "MAD_BRDCST"
  8032. };
  8033. static const char * const sb_tx11_inp1_mux_text[] = {
  8034. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4",
  8035. "DEC5", "RX_MIX_TX5", "DEC9_10", "DEC11_12"
  8036. };
  8037. static const char * const sb_tx13_mux_text[] = {
  8038. "ZERO", "DEC5", "DEC5_192"
  8039. };
  8040. static const char * const tx13_inp_mux_text[] = {
  8041. "CDC_DEC_5", "MAD_BRDCST", "CPE_TX_PP"
  8042. };
  8043. static const char * const iir_inp_mux_text[] = {
  8044. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6",
  8045. "DEC7", "DEC8", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7"
  8046. };
  8047. static const char * const rx_int_dem_inp_mux_text[] = {
  8048. "NORMAL_DSM_OUT", "CLSH_DSM_OUT",
  8049. };
  8050. static const char * const rx_int0_interp_mux_text[] = {
  8051. "ZERO", "RX INT0 MIX2",
  8052. };
  8053. static const char * const rx_int1_interp_mux_text[] = {
  8054. "ZERO", "RX INT1 MIX2",
  8055. };
  8056. static const char * const rx_int2_interp_mux_text[] = {
  8057. "ZERO", "RX INT2 MIX2",
  8058. };
  8059. static const char * const rx_int3_interp_mux_text[] = {
  8060. "ZERO", "RX INT3 MIX2",
  8061. };
  8062. static const char * const rx_int4_interp_mux_text[] = {
  8063. "ZERO", "RX INT4 MIX2",
  8064. };
  8065. static const char * const rx_int5_interp_mux_text[] = {
  8066. "ZERO", "RX INT5 MIX2",
  8067. };
  8068. static const char * const rx_int6_interp_mux_text[] = {
  8069. "ZERO", "RX INT6 MIX2",
  8070. };
  8071. static const char * const rx_int7_interp_mux_text[] = {
  8072. "ZERO", "RX INT7 MIX2",
  8073. };
  8074. static const char * const rx_int8_interp_mux_text[] = {
  8075. "ZERO", "RX INT8 SEC MIX"
  8076. };
  8077. static const char * const mad_sel_text[] = {
  8078. "SPE", "MSM"
  8079. };
  8080. static const char * const adc_mux_text[] = {
  8081. "DMIC", "AMIC", "ANC_FB_TUNE1", "ANC_FB_TUNE2"
  8082. };
  8083. static const char * const dmic_mux_text[] = {
  8084. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8085. "SMIC0", "SMIC1", "SMIC2", "SMIC3"
  8086. };
  8087. static const char * const dmic_mux_alt_text[] = {
  8088. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8089. };
  8090. static const char * const amic_mux_text[] = {
  8091. "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6"
  8092. };
  8093. static const char * const rx_echo_mux_text[] = {
  8094. "ZERO", "RX_MIX0", "RX_MIX1", "RX_MIX2", "RX_MIX3", "RX_MIX4",
  8095. "RX_MIX5", "RX_MIX6", "RX_MIX7", "RX_MIX8", "RX_MIX_VBAT5",
  8096. "RX_MIX_VBAT6", "RX_MIX_VBAT7", "RX_MIX_VBAT8"
  8097. };
  8098. static const char * const anc0_fb_mux_text[] = {
  8099. "ZERO", "ANC_IN_HPHL", "ANC_IN_EAR", "ANC_IN_EAR_SPKR",
  8100. "ANC_IN_LO1"
  8101. };
  8102. static const char * const anc1_fb_mux_text[] = {
  8103. "ZERO", "ANC_IN_HPHR", "ANC_IN_LO2"
  8104. };
  8105. static const char * const native_mux_text[] = {
  8106. "OFF", "ON",
  8107. };
  8108. static const struct soc_enum spl_src0_mux_chain_enum =
  8109. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 0, 3,
  8110. spl_src0_mux_text);
  8111. static const struct soc_enum spl_src1_mux_chain_enum =
  8112. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 2, 3,
  8113. spl_src1_mux_text);
  8114. static const struct soc_enum spl_src2_mux_chain_enum =
  8115. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 4, 3,
  8116. spl_src2_mux_text);
  8117. static const struct soc_enum spl_src3_mux_chain_enum =
  8118. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 6, 3,
  8119. spl_src3_mux_text);
  8120. static const struct soc_enum rx_int0_2_mux_chain_enum =
  8121. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 0, 10,
  8122. rx_int0_7_mix_mux_text);
  8123. static const struct soc_enum rx_int1_2_mux_chain_enum =
  8124. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 0, 9,
  8125. rx_int_mix_mux_text);
  8126. static const struct soc_enum rx_int2_2_mux_chain_enum =
  8127. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 0, 9,
  8128. rx_int_mix_mux_text);
  8129. static const struct soc_enum rx_int3_2_mux_chain_enum =
  8130. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 0, 9,
  8131. rx_int_mix_mux_text);
  8132. static const struct soc_enum rx_int4_2_mux_chain_enum =
  8133. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 0, 9,
  8134. rx_int_mix_mux_text);
  8135. static const struct soc_enum rx_int5_2_mux_chain_enum =
  8136. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 0, 9,
  8137. rx_int_mix_mux_text);
  8138. static const struct soc_enum rx_int6_2_mux_chain_enum =
  8139. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 0, 9,
  8140. rx_int_mix_mux_text);
  8141. static const struct soc_enum rx_int7_2_mux_chain_enum =
  8142. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 0, 10,
  8143. rx_int0_7_mix_mux_text);
  8144. static const struct soc_enum rx_int8_2_mux_chain_enum =
  8145. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 0, 9,
  8146. rx_int_mix_mux_text);
  8147. static const struct soc_enum int1_1_native_enum =
  8148. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8149. native_mux_text);
  8150. static const struct soc_enum int2_1_native_enum =
  8151. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8152. native_mux_text);
  8153. static const struct soc_enum int3_1_native_enum =
  8154. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8155. native_mux_text);
  8156. static const struct soc_enum int4_1_native_enum =
  8157. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8158. native_mux_text);
  8159. static const struct soc_enum rx_int0_1_mix_inp0_chain_enum =
  8160. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 0, 13,
  8161. rx_prim_mix_text);
  8162. static const struct soc_enum rx_int0_1_mix_inp1_chain_enum =
  8163. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 4, 13,
  8164. rx_prim_mix_text);
  8165. static const struct soc_enum rx_int0_1_mix_inp2_chain_enum =
  8166. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 4, 13,
  8167. rx_prim_mix_text);
  8168. static const struct soc_enum rx_int1_1_mix_inp0_chain_enum =
  8169. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 0, 13,
  8170. rx_prim_mix_text);
  8171. static const struct soc_enum rx_int1_1_mix_inp1_chain_enum =
  8172. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 4, 13,
  8173. rx_prim_mix_text);
  8174. static const struct soc_enum rx_int1_1_mix_inp2_chain_enum =
  8175. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 4, 13,
  8176. rx_prim_mix_text);
  8177. static const struct soc_enum rx_int2_1_mix_inp0_chain_enum =
  8178. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 0, 13,
  8179. rx_prim_mix_text);
  8180. static const struct soc_enum rx_int2_1_mix_inp1_chain_enum =
  8181. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 4, 13,
  8182. rx_prim_mix_text);
  8183. static const struct soc_enum rx_int2_1_mix_inp2_chain_enum =
  8184. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 4, 13,
  8185. rx_prim_mix_text);
  8186. static const struct soc_enum rx_int3_1_mix_inp0_chain_enum =
  8187. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 0, 13,
  8188. rx_prim_mix_text);
  8189. static const struct soc_enum rx_int3_1_mix_inp1_chain_enum =
  8190. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 4, 13,
  8191. rx_prim_mix_text);
  8192. static const struct soc_enum rx_int3_1_mix_inp2_chain_enum =
  8193. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 4, 13,
  8194. rx_prim_mix_text);
  8195. static const struct soc_enum rx_int4_1_mix_inp0_chain_enum =
  8196. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 0, 13,
  8197. rx_prim_mix_text);
  8198. static const struct soc_enum rx_int4_1_mix_inp1_chain_enum =
  8199. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 4, 13,
  8200. rx_prim_mix_text);
  8201. static const struct soc_enum rx_int4_1_mix_inp2_chain_enum =
  8202. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 4, 13,
  8203. rx_prim_mix_text);
  8204. static const struct soc_enum rx_int5_1_mix_inp0_chain_enum =
  8205. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 0, 13,
  8206. rx_prim_mix_text);
  8207. static const struct soc_enum rx_int5_1_mix_inp1_chain_enum =
  8208. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 4, 13,
  8209. rx_prim_mix_text);
  8210. static const struct soc_enum rx_int5_1_mix_inp2_chain_enum =
  8211. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 4, 13,
  8212. rx_prim_mix_text);
  8213. static const struct soc_enum rx_int6_1_mix_inp0_chain_enum =
  8214. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 0, 13,
  8215. rx_prim_mix_text);
  8216. static const struct soc_enum rx_int6_1_mix_inp1_chain_enum =
  8217. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 4, 13,
  8218. rx_prim_mix_text);
  8219. static const struct soc_enum rx_int6_1_mix_inp2_chain_enum =
  8220. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 4, 13,
  8221. rx_prim_mix_text);
  8222. static const struct soc_enum rx_int7_1_mix_inp0_chain_enum =
  8223. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 0, 13,
  8224. rx_prim_mix_text);
  8225. static const struct soc_enum rx_int7_1_mix_inp1_chain_enum =
  8226. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 4, 13,
  8227. rx_prim_mix_text);
  8228. static const struct soc_enum rx_int7_1_mix_inp2_chain_enum =
  8229. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 4, 13,
  8230. rx_prim_mix_text);
  8231. static const struct soc_enum rx_int8_1_mix_inp0_chain_enum =
  8232. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 0, 13,
  8233. rx_prim_mix_text);
  8234. static const struct soc_enum rx_int8_1_mix_inp1_chain_enum =
  8235. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 4, 13,
  8236. rx_prim_mix_text);
  8237. static const struct soc_enum rx_int8_1_mix_inp2_chain_enum =
  8238. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 4, 13,
  8239. rx_prim_mix_text);
  8240. static const struct soc_enum rx_int0_sidetone_mix_chain_enum =
  8241. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0, 4,
  8242. rx_sidetone_mix_text);
  8243. static const struct soc_enum rx_int1_sidetone_mix_chain_enum =
  8244. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2, 4,
  8245. rx_sidetone_mix_text);
  8246. static const struct soc_enum rx_int2_sidetone_mix_chain_enum =
  8247. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4, 4,
  8248. rx_sidetone_mix_text);
  8249. static const struct soc_enum rx_int3_sidetone_mix_chain_enum =
  8250. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6, 4,
  8251. rx_sidetone_mix_text);
  8252. static const struct soc_enum rx_int4_sidetone_mix_chain_enum =
  8253. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 0, 4,
  8254. rx_sidetone_mix_text);
  8255. static const struct soc_enum rx_int7_sidetone_mix_chain_enum =
  8256. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 2, 4,
  8257. rx_sidetone_mix_text);
  8258. static const struct soc_enum tx_adc_mux0_chain_enum =
  8259. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 0, 4,
  8260. adc_mux_text);
  8261. static const struct soc_enum tx_adc_mux1_chain_enum =
  8262. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 0, 4,
  8263. adc_mux_text);
  8264. static const struct soc_enum tx_adc_mux2_chain_enum =
  8265. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 0, 4,
  8266. adc_mux_text);
  8267. static const struct soc_enum tx_adc_mux3_chain_enum =
  8268. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 0, 4,
  8269. adc_mux_text);
  8270. static const struct soc_enum tx_adc_mux4_chain_enum =
  8271. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 6, 4,
  8272. adc_mux_text);
  8273. static const struct soc_enum tx_adc_mux5_chain_enum =
  8274. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 6, 4,
  8275. adc_mux_text);
  8276. static const struct soc_enum tx_adc_mux6_chain_enum =
  8277. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 6, 4,
  8278. adc_mux_text);
  8279. static const struct soc_enum tx_adc_mux7_chain_enum =
  8280. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 6, 4,
  8281. adc_mux_text);
  8282. static const struct soc_enum tx_adc_mux8_chain_enum =
  8283. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 6, 4,
  8284. adc_mux_text);
  8285. static const struct soc_enum tx_adc_mux10_chain_enum =
  8286. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 6, 4,
  8287. adc_mux_text);
  8288. static const struct soc_enum tx_adc_mux11_chain_enum =
  8289. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 6, 4,
  8290. adc_mux_text);
  8291. static const struct soc_enum tx_adc_mux12_chain_enum =
  8292. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 6, 4,
  8293. adc_mux_text);
  8294. static const struct soc_enum tx_adc_mux13_chain_enum =
  8295. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 6, 4,
  8296. adc_mux_text);
  8297. static const struct soc_enum tx_dmic_mux0_enum =
  8298. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 3, 11,
  8299. dmic_mux_text);
  8300. static const struct soc_enum tx_dmic_mux1_enum =
  8301. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 3, 11,
  8302. dmic_mux_text);
  8303. static const struct soc_enum tx_dmic_mux2_enum =
  8304. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 3, 11,
  8305. dmic_mux_text);
  8306. static const struct soc_enum tx_dmic_mux3_enum =
  8307. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 3, 11,
  8308. dmic_mux_text);
  8309. static const struct soc_enum tx_dmic_mux4_enum =
  8310. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 3, 7,
  8311. dmic_mux_alt_text);
  8312. static const struct soc_enum tx_dmic_mux5_enum =
  8313. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 3, 7,
  8314. dmic_mux_alt_text);
  8315. static const struct soc_enum tx_dmic_mux6_enum =
  8316. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 3, 7,
  8317. dmic_mux_alt_text);
  8318. static const struct soc_enum tx_dmic_mux7_enum =
  8319. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 3, 7,
  8320. dmic_mux_alt_text);
  8321. static const struct soc_enum tx_dmic_mux8_enum =
  8322. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 3, 7,
  8323. dmic_mux_alt_text);
  8324. static const struct soc_enum tx_dmic_mux10_enum =
  8325. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 3, 7,
  8326. dmic_mux_alt_text);
  8327. static const struct soc_enum tx_dmic_mux11_enum =
  8328. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 3, 7,
  8329. dmic_mux_alt_text);
  8330. static const struct soc_enum tx_dmic_mux12_enum =
  8331. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 3, 7,
  8332. dmic_mux_alt_text);
  8333. static const struct soc_enum tx_dmic_mux13_enum =
  8334. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 3, 7,
  8335. dmic_mux_alt_text);
  8336. static const struct soc_enum tx_amic_mux0_enum =
  8337. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 0, 7,
  8338. amic_mux_text);
  8339. static const struct soc_enum tx_amic_mux1_enum =
  8340. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 0, 7,
  8341. amic_mux_text);
  8342. static const struct soc_enum tx_amic_mux2_enum =
  8343. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 0, 7,
  8344. amic_mux_text);
  8345. static const struct soc_enum tx_amic_mux3_enum =
  8346. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 0, 7,
  8347. amic_mux_text);
  8348. static const struct soc_enum tx_amic_mux4_enum =
  8349. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 0, 7,
  8350. amic_mux_text);
  8351. static const struct soc_enum tx_amic_mux5_enum =
  8352. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 0, 7,
  8353. amic_mux_text);
  8354. static const struct soc_enum tx_amic_mux6_enum =
  8355. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 0, 7,
  8356. amic_mux_text);
  8357. static const struct soc_enum tx_amic_mux7_enum =
  8358. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 0, 7,
  8359. amic_mux_text);
  8360. static const struct soc_enum tx_amic_mux8_enum =
  8361. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 0, 7,
  8362. amic_mux_text);
  8363. static const struct soc_enum tx_amic_mux10_enum =
  8364. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 0, 7,
  8365. amic_mux_text);
  8366. static const struct soc_enum tx_amic_mux11_enum =
  8367. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 0, 7,
  8368. amic_mux_text);
  8369. static const struct soc_enum tx_amic_mux12_enum =
  8370. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 0, 7,
  8371. amic_mux_text);
  8372. static const struct soc_enum tx_amic_mux13_enum =
  8373. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 0, 7,
  8374. amic_mux_text);
  8375. static const struct soc_enum sb_tx0_mux_enum =
  8376. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 0, 4,
  8377. sb_tx0_mux_text);
  8378. static const struct soc_enum sb_tx1_mux_enum =
  8379. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 2, 4,
  8380. sb_tx1_mux_text);
  8381. static const struct soc_enum sb_tx2_mux_enum =
  8382. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 4, 4,
  8383. sb_tx2_mux_text);
  8384. static const struct soc_enum sb_tx3_mux_enum =
  8385. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 6, 4,
  8386. sb_tx3_mux_text);
  8387. static const struct soc_enum sb_tx4_mux_enum =
  8388. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 0, 4,
  8389. sb_tx4_mux_text);
  8390. static const struct soc_enum sb_tx5_mux_enum =
  8391. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 2, 4,
  8392. sb_tx5_mux_text);
  8393. static const struct soc_enum sb_tx6_mux_enum =
  8394. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 4, 4,
  8395. sb_tx6_mux_text);
  8396. static const struct soc_enum sb_tx7_mux_enum =
  8397. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 6, 4,
  8398. sb_tx7_mux_text);
  8399. static const struct soc_enum sb_tx8_mux_enum =
  8400. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 0, 4,
  8401. sb_tx8_mux_text);
  8402. static const struct soc_enum sb_tx9_mux_enum =
  8403. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 2, 3,
  8404. sb_tx9_mux_text);
  8405. static const struct soc_enum sb_tx10_mux_enum =
  8406. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 4, 3,
  8407. sb_tx10_mux_text);
  8408. static const struct soc_enum sb_tx11_mux_enum =
  8409. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX11_INP_CFG, 0, 4,
  8410. sb_tx11_mux_text);
  8411. static const struct soc_enum sb_tx11_inp1_mux_enum =
  8412. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 0, 10,
  8413. sb_tx11_inp1_mux_text);
  8414. static const struct soc_enum sb_tx13_mux_enum =
  8415. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 4, 3,
  8416. sb_tx13_mux_text);
  8417. static const struct soc_enum tx13_inp_mux_enum =
  8418. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG, 0, 3,
  8419. tx13_inp_mux_text);
  8420. static const struct soc_enum rx_mix_tx0_mux_enum =
  8421. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 0, 14,
  8422. rx_echo_mux_text);
  8423. static const struct soc_enum rx_mix_tx1_mux_enum =
  8424. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 4, 14,
  8425. rx_echo_mux_text);
  8426. static const struct soc_enum rx_mix_tx2_mux_enum =
  8427. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 0, 14,
  8428. rx_echo_mux_text);
  8429. static const struct soc_enum rx_mix_tx3_mux_enum =
  8430. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 4, 14,
  8431. rx_echo_mux_text);
  8432. static const struct soc_enum rx_mix_tx4_mux_enum =
  8433. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 0, 14,
  8434. rx_echo_mux_text);
  8435. static const struct soc_enum rx_mix_tx5_mux_enum =
  8436. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 4, 14,
  8437. rx_echo_mux_text);
  8438. static const struct soc_enum rx_mix_tx6_mux_enum =
  8439. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 0, 14,
  8440. rx_echo_mux_text);
  8441. static const struct soc_enum rx_mix_tx7_mux_enum =
  8442. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 4, 14,
  8443. rx_echo_mux_text);
  8444. static const struct soc_enum rx_mix_tx8_mux_enum =
  8445. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG4, 0, 14,
  8446. rx_echo_mux_text);
  8447. static const struct soc_enum iir0_inp0_mux_enum =
  8448. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0, 0, 18,
  8449. iir_inp_mux_text);
  8450. static const struct soc_enum iir0_inp1_mux_enum =
  8451. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1, 0, 18,
  8452. iir_inp_mux_text);
  8453. static const struct soc_enum iir0_inp2_mux_enum =
  8454. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2, 0, 18,
  8455. iir_inp_mux_text);
  8456. static const struct soc_enum iir0_inp3_mux_enum =
  8457. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3, 0, 18,
  8458. iir_inp_mux_text);
  8459. static const struct soc_enum iir1_inp0_mux_enum =
  8460. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0, 0, 18,
  8461. iir_inp_mux_text);
  8462. static const struct soc_enum iir1_inp1_mux_enum =
  8463. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1, 0, 18,
  8464. iir_inp_mux_text);
  8465. static const struct soc_enum iir1_inp2_mux_enum =
  8466. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2, 0, 18,
  8467. iir_inp_mux_text);
  8468. static const struct soc_enum iir1_inp3_mux_enum =
  8469. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3, 0, 18,
  8470. iir_inp_mux_text);
  8471. static const struct soc_enum rx_int0_dem_inp_mux_enum =
  8472. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_SEC0, 0,
  8473. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8474. rx_int_dem_inp_mux_text);
  8475. static const struct soc_enum rx_int1_dem_inp_mux_enum =
  8476. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_SEC0, 0,
  8477. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8478. rx_int_dem_inp_mux_text);
  8479. static const struct soc_enum rx_int2_dem_inp_mux_enum =
  8480. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_SEC0, 0,
  8481. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8482. rx_int_dem_inp_mux_text);
  8483. static const struct soc_enum rx_int0_interp_mux_enum =
  8484. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CTL, 5, 2,
  8485. rx_int0_interp_mux_text);
  8486. static const struct soc_enum rx_int1_interp_mux_enum =
  8487. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CTL, 5, 2,
  8488. rx_int1_interp_mux_text);
  8489. static const struct soc_enum rx_int2_interp_mux_enum =
  8490. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CTL, 5, 2,
  8491. rx_int2_interp_mux_text);
  8492. static const struct soc_enum rx_int3_interp_mux_enum =
  8493. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CTL, 5, 2,
  8494. rx_int3_interp_mux_text);
  8495. static const struct soc_enum rx_int4_interp_mux_enum =
  8496. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CTL, 5, 2,
  8497. rx_int4_interp_mux_text);
  8498. static const struct soc_enum rx_int5_interp_mux_enum =
  8499. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CTL, 5, 2,
  8500. rx_int5_interp_mux_text);
  8501. static const struct soc_enum rx_int6_interp_mux_enum =
  8502. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CTL, 5, 2,
  8503. rx_int6_interp_mux_text);
  8504. static const struct soc_enum rx_int7_interp_mux_enum =
  8505. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CTL, 5, 2,
  8506. rx_int7_interp_mux_text);
  8507. static const struct soc_enum rx_int8_interp_mux_enum =
  8508. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CTL, 5, 2,
  8509. rx_int8_interp_mux_text);
  8510. static const struct soc_enum mad_sel_enum =
  8511. SOC_ENUM_SINGLE(WCD9335_CPE_SS_CFG, 0, 2, mad_sel_text);
  8512. static const struct soc_enum anc0_fb_mux_enum =
  8513. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 0, 5,
  8514. anc0_fb_mux_text);
  8515. static const struct soc_enum anc1_fb_mux_enum =
  8516. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 3, 3,
  8517. anc1_fb_mux_text);
  8518. static const struct snd_kcontrol_new rx_int0_dem_inp_mux =
  8519. SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum,
  8520. snd_soc_dapm_get_enum_double,
  8521. tasha_int_dem_inp_mux_put);
  8522. static const struct snd_kcontrol_new rx_int1_dem_inp_mux =
  8523. SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum,
  8524. snd_soc_dapm_get_enum_double,
  8525. tasha_int_dem_inp_mux_put);
  8526. static const struct snd_kcontrol_new rx_int2_dem_inp_mux =
  8527. SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum,
  8528. snd_soc_dapm_get_enum_double,
  8529. tasha_int_dem_inp_mux_put);
  8530. static const struct snd_kcontrol_new spl_src0_mux =
  8531. SOC_DAPM_ENUM("SPL SRC0 MUX Mux", spl_src0_mux_chain_enum);
  8532. static const struct snd_kcontrol_new spl_src1_mux =
  8533. SOC_DAPM_ENUM("SPL SRC1 MUX Mux", spl_src1_mux_chain_enum);
  8534. static const struct snd_kcontrol_new spl_src2_mux =
  8535. SOC_DAPM_ENUM("SPL SRC2 MUX Mux", spl_src2_mux_chain_enum);
  8536. static const struct snd_kcontrol_new spl_src3_mux =
  8537. SOC_DAPM_ENUM("SPL SRC3 MUX Mux", spl_src3_mux_chain_enum);
  8538. static const struct snd_kcontrol_new rx_int0_2_mux =
  8539. SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum);
  8540. static const struct snd_kcontrol_new rx_int1_2_mux =
  8541. SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum);
  8542. static const struct snd_kcontrol_new rx_int2_2_mux =
  8543. SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum);
  8544. static const struct snd_kcontrol_new rx_int3_2_mux =
  8545. SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum);
  8546. static const struct snd_kcontrol_new rx_int4_2_mux =
  8547. SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum);
  8548. static const struct snd_kcontrol_new rx_int5_2_mux =
  8549. SOC_DAPM_ENUM("RX INT5_2 MUX Mux", rx_int5_2_mux_chain_enum);
  8550. static const struct snd_kcontrol_new rx_int6_2_mux =
  8551. SOC_DAPM_ENUM("RX INT6_2 MUX Mux", rx_int6_2_mux_chain_enum);
  8552. static const struct snd_kcontrol_new rx_int7_2_mux =
  8553. SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum);
  8554. static const struct snd_kcontrol_new rx_int8_2_mux =
  8555. SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum);
  8556. static const struct snd_kcontrol_new int1_1_native_mux =
  8557. SOC_DAPM_ENUM("RX INT1_1 NATIVE MUX Mux", int1_1_native_enum);
  8558. static const struct snd_kcontrol_new int2_1_native_mux =
  8559. SOC_DAPM_ENUM("RX INT2_1 NATIVE MUX Mux", int2_1_native_enum);
  8560. static const struct snd_kcontrol_new int3_1_native_mux =
  8561. SOC_DAPM_ENUM("RX INT3_1 NATIVE MUX Mux", int3_1_native_enum);
  8562. static const struct snd_kcontrol_new int4_1_native_mux =
  8563. SOC_DAPM_ENUM("RX INT4_1 NATIVE MUX Mux", int4_1_native_enum);
  8564. static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux =
  8565. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum);
  8566. static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux =
  8567. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum);
  8568. static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux =
  8569. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum);
  8570. static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux =
  8571. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum);
  8572. static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux =
  8573. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum);
  8574. static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux =
  8575. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum);
  8576. static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux =
  8577. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum);
  8578. static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux =
  8579. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum);
  8580. static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux =
  8581. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum);
  8582. static const struct snd_kcontrol_new rx_int3_1_mix_inp0_mux =
  8583. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum);
  8584. static const struct snd_kcontrol_new rx_int3_1_mix_inp1_mux =
  8585. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum);
  8586. static const struct snd_kcontrol_new rx_int3_1_mix_inp2_mux =
  8587. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum);
  8588. static const struct snd_kcontrol_new rx_int4_1_mix_inp0_mux =
  8589. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum);
  8590. static const struct snd_kcontrol_new rx_int4_1_mix_inp1_mux =
  8591. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum);
  8592. static const struct snd_kcontrol_new rx_int4_1_mix_inp2_mux =
  8593. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum);
  8594. static const struct snd_kcontrol_new rx_int5_1_mix_inp0_mux =
  8595. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP0 Mux", rx_int5_1_mix_inp0_chain_enum);
  8596. static const struct snd_kcontrol_new rx_int5_1_mix_inp1_mux =
  8597. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP1 Mux", rx_int5_1_mix_inp1_chain_enum);
  8598. static const struct snd_kcontrol_new rx_int5_1_mix_inp2_mux =
  8599. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP2 Mux", rx_int5_1_mix_inp2_chain_enum);
  8600. static const struct snd_kcontrol_new rx_int6_1_mix_inp0_mux =
  8601. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP0 Mux", rx_int6_1_mix_inp0_chain_enum);
  8602. static const struct snd_kcontrol_new rx_int6_1_mix_inp1_mux =
  8603. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP1 Mux", rx_int6_1_mix_inp1_chain_enum);
  8604. static const struct snd_kcontrol_new rx_int6_1_mix_inp2_mux =
  8605. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP2 Mux", rx_int6_1_mix_inp2_chain_enum);
  8606. static const struct snd_kcontrol_new rx_int7_1_mix_inp0_mux =
  8607. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum);
  8608. static const struct snd_kcontrol_new rx_int7_1_mix_inp1_mux =
  8609. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum);
  8610. static const struct snd_kcontrol_new rx_int7_1_mix_inp2_mux =
  8611. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum);
  8612. static const struct snd_kcontrol_new rx_int8_1_mix_inp0_mux =
  8613. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum);
  8614. static const struct snd_kcontrol_new rx_int8_1_mix_inp1_mux =
  8615. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum);
  8616. static const struct snd_kcontrol_new rx_int8_1_mix_inp2_mux =
  8617. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum);
  8618. static const struct snd_kcontrol_new rx_int0_mix2_inp_mux =
  8619. SOC_DAPM_ENUM("RX INT0 MIX2 INP Mux", rx_int0_sidetone_mix_chain_enum);
  8620. static const struct snd_kcontrol_new rx_int1_mix2_inp_mux =
  8621. SOC_DAPM_ENUM("RX INT1 MIX2 INP Mux", rx_int1_sidetone_mix_chain_enum);
  8622. static const struct snd_kcontrol_new rx_int2_mix2_inp_mux =
  8623. SOC_DAPM_ENUM("RX INT2 MIX2 INP Mux", rx_int2_sidetone_mix_chain_enum);
  8624. static const struct snd_kcontrol_new rx_int3_mix2_inp_mux =
  8625. SOC_DAPM_ENUM("RX INT3 MIX2 INP Mux", rx_int3_sidetone_mix_chain_enum);
  8626. static const struct snd_kcontrol_new rx_int4_mix2_inp_mux =
  8627. SOC_DAPM_ENUM("RX INT4 MIX2 INP Mux", rx_int4_sidetone_mix_chain_enum);
  8628. static const struct snd_kcontrol_new rx_int7_mix2_inp_mux =
  8629. SOC_DAPM_ENUM("RX INT7 MIX2 INP Mux", rx_int7_sidetone_mix_chain_enum);
  8630. static const struct snd_kcontrol_new tx_adc_mux0 =
  8631. SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_chain_enum,
  8632. snd_soc_dapm_get_enum_double,
  8633. tasha_put_dec_enum);
  8634. static const struct snd_kcontrol_new tx_adc_mux1 =
  8635. SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_chain_enum,
  8636. snd_soc_dapm_get_enum_double,
  8637. tasha_put_dec_enum);
  8638. static const struct snd_kcontrol_new tx_adc_mux2 =
  8639. SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_chain_enum,
  8640. snd_soc_dapm_get_enum_double,
  8641. tasha_put_dec_enum);
  8642. static const struct snd_kcontrol_new tx_adc_mux3 =
  8643. SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_chain_enum,
  8644. snd_soc_dapm_get_enum_double,
  8645. tasha_put_dec_enum);
  8646. static const struct snd_kcontrol_new tx_adc_mux4 =
  8647. SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_chain_enum,
  8648. snd_soc_dapm_get_enum_double,
  8649. tasha_put_dec_enum);
  8650. static const struct snd_kcontrol_new tx_adc_mux5 =
  8651. SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_chain_enum,
  8652. snd_soc_dapm_get_enum_double,
  8653. tasha_put_dec_enum);
  8654. static const struct snd_kcontrol_new tx_adc_mux6 =
  8655. SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_chain_enum,
  8656. snd_soc_dapm_get_enum_double,
  8657. tasha_put_dec_enum);
  8658. static const struct snd_kcontrol_new tx_adc_mux7 =
  8659. SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_chain_enum,
  8660. snd_soc_dapm_get_enum_double,
  8661. tasha_put_dec_enum);
  8662. static const struct snd_kcontrol_new tx_adc_mux8 =
  8663. SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_chain_enum,
  8664. snd_soc_dapm_get_enum_double,
  8665. tasha_put_dec_enum);
  8666. static const struct snd_kcontrol_new tx_adc_mux10 =
  8667. SOC_DAPM_ENUM("ADC MUX10 Mux", tx_adc_mux10_chain_enum);
  8668. static const struct snd_kcontrol_new tx_adc_mux11 =
  8669. SOC_DAPM_ENUM("ADC MUX11 Mux", tx_adc_mux11_chain_enum);
  8670. static const struct snd_kcontrol_new tx_adc_mux12 =
  8671. SOC_DAPM_ENUM("ADC MUX12 Mux", tx_adc_mux12_chain_enum);
  8672. static const struct snd_kcontrol_new tx_adc_mux13 =
  8673. SOC_DAPM_ENUM("ADC MUX13 Mux", tx_adc_mux13_chain_enum);
  8674. static const struct snd_kcontrol_new tx_dmic_mux0 =
  8675. SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum);
  8676. static const struct snd_kcontrol_new tx_dmic_mux1 =
  8677. SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum);
  8678. static const struct snd_kcontrol_new tx_dmic_mux2 =
  8679. SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum);
  8680. static const struct snd_kcontrol_new tx_dmic_mux3 =
  8681. SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum);
  8682. static const struct snd_kcontrol_new tx_dmic_mux4 =
  8683. SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum);
  8684. static const struct snd_kcontrol_new tx_dmic_mux5 =
  8685. SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum);
  8686. static const struct snd_kcontrol_new tx_dmic_mux6 =
  8687. SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum);
  8688. static const struct snd_kcontrol_new tx_dmic_mux7 =
  8689. SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum);
  8690. static const struct snd_kcontrol_new tx_dmic_mux8 =
  8691. SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum);
  8692. static const struct snd_kcontrol_new tx_dmic_mux10 =
  8693. SOC_DAPM_ENUM("DMIC MUX10 Mux", tx_dmic_mux10_enum);
  8694. static const struct snd_kcontrol_new tx_dmic_mux11 =
  8695. SOC_DAPM_ENUM("DMIC MUX11 Mux", tx_dmic_mux11_enum);
  8696. static const struct snd_kcontrol_new tx_dmic_mux12 =
  8697. SOC_DAPM_ENUM("DMIC MUX12 Mux", tx_dmic_mux12_enum);
  8698. static const struct snd_kcontrol_new tx_dmic_mux13 =
  8699. SOC_DAPM_ENUM("DMIC MUX13 Mux", tx_dmic_mux13_enum);
  8700. static const struct snd_kcontrol_new tx_amic_mux0 =
  8701. SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum);
  8702. static const struct snd_kcontrol_new tx_amic_mux1 =
  8703. SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum);
  8704. static const struct snd_kcontrol_new tx_amic_mux2 =
  8705. SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum);
  8706. static const struct snd_kcontrol_new tx_amic_mux3 =
  8707. SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum);
  8708. static const struct snd_kcontrol_new tx_amic_mux4 =
  8709. SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum);
  8710. static const struct snd_kcontrol_new tx_amic_mux5 =
  8711. SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum);
  8712. static const struct snd_kcontrol_new tx_amic_mux6 =
  8713. SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum);
  8714. static const struct snd_kcontrol_new tx_amic_mux7 =
  8715. SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum);
  8716. static const struct snd_kcontrol_new tx_amic_mux8 =
  8717. SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum);
  8718. static const struct snd_kcontrol_new tx_amic_mux10 =
  8719. SOC_DAPM_ENUM("AMIC MUX10 Mux", tx_amic_mux10_enum);
  8720. static const struct snd_kcontrol_new tx_amic_mux11 =
  8721. SOC_DAPM_ENUM("AMIC MUX11 Mux", tx_amic_mux11_enum);
  8722. static const struct snd_kcontrol_new tx_amic_mux12 =
  8723. SOC_DAPM_ENUM("AMIC MUX12 Mux", tx_amic_mux12_enum);
  8724. static const struct snd_kcontrol_new tx_amic_mux13 =
  8725. SOC_DAPM_ENUM("AMIC MUX13 Mux", tx_amic_mux13_enum);
  8726. static const struct snd_kcontrol_new sb_tx0_mux =
  8727. SOC_DAPM_ENUM("SLIM TX0 MUX Mux", sb_tx0_mux_enum);
  8728. static const struct snd_kcontrol_new sb_tx1_mux =
  8729. SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum);
  8730. static const struct snd_kcontrol_new sb_tx2_mux =
  8731. SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum);
  8732. static const struct snd_kcontrol_new sb_tx3_mux =
  8733. SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum);
  8734. static const struct snd_kcontrol_new sb_tx4_mux =
  8735. SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum);
  8736. static const struct snd_kcontrol_new sb_tx5_mux =
  8737. SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum);
  8738. static const struct snd_kcontrol_new sb_tx6_mux =
  8739. SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum);
  8740. static const struct snd_kcontrol_new sb_tx7_mux =
  8741. SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum);
  8742. static const struct snd_kcontrol_new sb_tx8_mux =
  8743. SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum);
  8744. static const struct snd_kcontrol_new sb_tx9_mux =
  8745. SOC_DAPM_ENUM("SLIM TX9 MUX Mux", sb_tx9_mux_enum);
  8746. static const struct snd_kcontrol_new sb_tx10_mux =
  8747. SOC_DAPM_ENUM("SLIM TX10 MUX Mux", sb_tx10_mux_enum);
  8748. static const struct snd_kcontrol_new sb_tx11_mux =
  8749. SOC_DAPM_ENUM("SLIM TX11 MUX Mux", sb_tx11_mux_enum);
  8750. static const struct snd_kcontrol_new sb_tx11_inp1_mux =
  8751. SOC_DAPM_ENUM("SLIM TX11 INP1 MUX Mux", sb_tx11_inp1_mux_enum);
  8752. static const struct snd_kcontrol_new sb_tx13_mux =
  8753. SOC_DAPM_ENUM("SLIM TX13 MUX Mux", sb_tx13_mux_enum);
  8754. static const struct snd_kcontrol_new tx13_inp_mux =
  8755. SOC_DAPM_ENUM("TX13 INP MUX Mux", tx13_inp_mux_enum);
  8756. static const struct snd_kcontrol_new rx_mix_tx0_mux =
  8757. SOC_DAPM_ENUM("RX MIX TX0 MUX Mux", rx_mix_tx0_mux_enum);
  8758. static const struct snd_kcontrol_new rx_mix_tx1_mux =
  8759. SOC_DAPM_ENUM("RX MIX TX1 MUX Mux", rx_mix_tx1_mux_enum);
  8760. static const struct snd_kcontrol_new rx_mix_tx2_mux =
  8761. SOC_DAPM_ENUM("RX MIX TX2 MUX Mux", rx_mix_tx2_mux_enum);
  8762. static const struct snd_kcontrol_new rx_mix_tx3_mux =
  8763. SOC_DAPM_ENUM("RX MIX TX3 MUX Mux", rx_mix_tx3_mux_enum);
  8764. static const struct snd_kcontrol_new rx_mix_tx4_mux =
  8765. SOC_DAPM_ENUM("RX MIX TX4 MUX Mux", rx_mix_tx4_mux_enum);
  8766. static const struct snd_kcontrol_new rx_mix_tx5_mux =
  8767. SOC_DAPM_ENUM("RX MIX TX5 MUX Mux", rx_mix_tx5_mux_enum);
  8768. static const struct snd_kcontrol_new rx_mix_tx6_mux =
  8769. SOC_DAPM_ENUM("RX MIX TX6 MUX Mux", rx_mix_tx6_mux_enum);
  8770. static const struct snd_kcontrol_new rx_mix_tx7_mux =
  8771. SOC_DAPM_ENUM("RX MIX TX7 MUX Mux", rx_mix_tx7_mux_enum);
  8772. static const struct snd_kcontrol_new rx_mix_tx8_mux =
  8773. SOC_DAPM_ENUM("RX MIX TX8 MUX Mux", rx_mix_tx8_mux_enum);
  8774. static const struct snd_kcontrol_new iir0_inp0_mux =
  8775. SOC_DAPM_ENUM("IIR0 INP0 Mux", iir0_inp0_mux_enum);
  8776. static const struct snd_kcontrol_new iir0_inp1_mux =
  8777. SOC_DAPM_ENUM("IIR0 INP1 Mux", iir0_inp1_mux_enum);
  8778. static const struct snd_kcontrol_new iir0_inp2_mux =
  8779. SOC_DAPM_ENUM("IIR0 INP2 Mux", iir0_inp2_mux_enum);
  8780. static const struct snd_kcontrol_new iir0_inp3_mux =
  8781. SOC_DAPM_ENUM("IIR0 INP3 Mux", iir0_inp3_mux_enum);
  8782. static const struct snd_kcontrol_new iir1_inp0_mux =
  8783. SOC_DAPM_ENUM("IIR1 INP0 Mux", iir1_inp0_mux_enum);
  8784. static const struct snd_kcontrol_new iir1_inp1_mux =
  8785. SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum);
  8786. static const struct snd_kcontrol_new iir1_inp2_mux =
  8787. SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum);
  8788. static const struct snd_kcontrol_new iir1_inp3_mux =
  8789. SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum);
  8790. static const struct snd_kcontrol_new rx_int0_interp_mux =
  8791. SOC_DAPM_ENUM("RX INT0 INTERP Mux", rx_int0_interp_mux_enum);
  8792. static const struct snd_kcontrol_new rx_int1_interp_mux =
  8793. SOC_DAPM_ENUM("RX INT1 INTERP Mux", rx_int1_interp_mux_enum);
  8794. static const struct snd_kcontrol_new rx_int2_interp_mux =
  8795. SOC_DAPM_ENUM("RX INT2 INTERP Mux", rx_int2_interp_mux_enum);
  8796. static const struct snd_kcontrol_new rx_int3_interp_mux =
  8797. SOC_DAPM_ENUM("RX INT3 INTERP Mux", rx_int3_interp_mux_enum);
  8798. static const struct snd_kcontrol_new rx_int4_interp_mux =
  8799. SOC_DAPM_ENUM("RX INT4 INTERP Mux", rx_int4_interp_mux_enum);
  8800. static const struct snd_kcontrol_new rx_int5_interp_mux =
  8801. SOC_DAPM_ENUM("RX INT5 INTERP Mux", rx_int5_interp_mux_enum);
  8802. static const struct snd_kcontrol_new rx_int6_interp_mux =
  8803. SOC_DAPM_ENUM("RX INT6 INTERP Mux", rx_int6_interp_mux_enum);
  8804. static const struct snd_kcontrol_new rx_int7_interp_mux =
  8805. SOC_DAPM_ENUM("RX INT7 INTERP Mux", rx_int7_interp_mux_enum);
  8806. static const struct snd_kcontrol_new rx_int8_interp_mux =
  8807. SOC_DAPM_ENUM("RX INT8 INTERP Mux", rx_int8_interp_mux_enum);
  8808. static const struct snd_kcontrol_new mad_sel_mux =
  8809. SOC_DAPM_ENUM("MAD_SEL MUX Mux", mad_sel_enum);
  8810. static const struct snd_kcontrol_new aif4_mad_switch =
  8811. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 5, 1, 0);
  8812. static const struct snd_kcontrol_new mad_brdcst_switch =
  8813. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 6, 1, 0);
  8814. static const struct snd_kcontrol_new aif4_switch_mixer_controls =
  8815. SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
  8816. 0, 1, 0, tasha_codec_aif4_mixer_switch_get,
  8817. tasha_codec_aif4_mixer_switch_put);
  8818. static const struct snd_kcontrol_new anc_hphl_switch =
  8819. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8820. static const struct snd_kcontrol_new anc_hphr_switch =
  8821. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8822. static const struct snd_kcontrol_new anc_ear_switch =
  8823. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8824. static const struct snd_kcontrol_new anc_ear_spkr_switch =
  8825. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8826. static const struct snd_kcontrol_new anc_lineout1_switch =
  8827. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8828. static const struct snd_kcontrol_new anc_lineout2_switch =
  8829. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8830. static const struct snd_kcontrol_new anc_spkr_pa_switch =
  8831. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8832. static const struct snd_kcontrol_new adc_us_mux0_switch =
  8833. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8834. static const struct snd_kcontrol_new adc_us_mux1_switch =
  8835. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8836. static const struct snd_kcontrol_new adc_us_mux2_switch =
  8837. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8838. static const struct snd_kcontrol_new adc_us_mux3_switch =
  8839. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8840. static const struct snd_kcontrol_new adc_us_mux4_switch =
  8841. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8842. static const struct snd_kcontrol_new adc_us_mux5_switch =
  8843. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8844. static const struct snd_kcontrol_new adc_us_mux6_switch =
  8845. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8846. static const struct snd_kcontrol_new adc_us_mux7_switch =
  8847. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8848. static const struct snd_kcontrol_new adc_us_mux8_switch =
  8849. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8850. static const struct snd_kcontrol_new anc0_fb_mux =
  8851. SOC_DAPM_ENUM("ANC0 FB MUX Mux", anc0_fb_mux_enum);
  8852. static const struct snd_kcontrol_new anc1_fb_mux =
  8853. SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum);
  8854. static int tasha_codec_ec_buf_mux_enable(struct snd_soc_dapm_widget *w,
  8855. struct snd_kcontrol *kcontrol,
  8856. int event)
  8857. {
  8858. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  8859. dev_dbg(codec->dev, "%s: event = %d name = %s\n",
  8860. __func__, event, w->name);
  8861. switch (event) {
  8862. case SND_SOC_DAPM_POST_PMU:
  8863. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x3B);
  8864. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x08);
  8865. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8866. 0x08, 0x08);
  8867. break;
  8868. case SND_SOC_DAPM_POST_PMD:
  8869. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8870. 0x08, 0x00);
  8871. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x00);
  8872. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x00);
  8873. break;
  8874. }
  8875. return 0;
  8876. };
  8877. static const char * const ec_buf_mux_text[] = {
  8878. "ZERO", "RXMIXEC", "SB_RX0", "SB_RX1", "SB_RX2", "SB_RX3",
  8879. "I2S_RX_SD0_L", "I2S_RX_SD0_R", "I2S_RX_SD1_L", "I2S_RX_SD1_R",
  8880. "DEC1"
  8881. };
  8882. static SOC_ENUM_SINGLE_DECL(ec_buf_mux_enum, WCD9335_CPE_SS_US_EC_MUX_CFG,
  8883. 0, ec_buf_mux_text);
  8884. static const struct snd_kcontrol_new ec_buf_mux =
  8885. SOC_DAPM_ENUM("EC BUF Mux", ec_buf_mux_enum);
  8886. static const struct snd_soc_dapm_widget tasha_dapm_widgets[] = {
  8887. SND_SOC_DAPM_OUTPUT("EAR"),
  8888. SND_SOC_DAPM_OUTPUT("ANC EAR"),
  8889. SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM,
  8890. AIF1_PB, 0, tasha_codec_enable_slimrx,
  8891. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8892. SND_SOC_DAPM_POST_PMD),
  8893. SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM,
  8894. AIF2_PB, 0, tasha_codec_enable_slimrx,
  8895. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8896. SND_SOC_DAPM_POST_PMD),
  8897. SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM,
  8898. AIF3_PB, 0, tasha_codec_enable_slimrx,
  8899. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8900. SND_SOC_DAPM_POST_PMD),
  8901. SND_SOC_DAPM_AIF_IN_E("AIF4 PB", "AIF4 Playback", 0, SND_SOC_NOPM,
  8902. AIF4_PB, 0, tasha_codec_enable_slimrx,
  8903. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8904. SND_SOC_DAPM_POST_PMD),
  8905. SND_SOC_DAPM_AIF_IN_E("AIF MIX1 PB", "AIF Mix Playback", 0,
  8906. SND_SOC_NOPM, AIF_MIX1_PB, 0,
  8907. tasha_codec_enable_slimrx,
  8908. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8909. SND_SOC_DAPM_POST_PMD),
  8910. SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM, TASHA_RX0, 0,
  8911. &slim_rx_mux[TASHA_RX0]),
  8912. SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TASHA_RX1, 0,
  8913. &slim_rx_mux[TASHA_RX1]),
  8914. SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TASHA_RX2, 0,
  8915. &slim_rx_mux[TASHA_RX2]),
  8916. SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TASHA_RX3, 0,
  8917. &slim_rx_mux[TASHA_RX3]),
  8918. SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TASHA_RX4, 0,
  8919. &slim_rx_mux[TASHA_RX4]),
  8920. SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TASHA_RX5, 0,
  8921. &slim_rx_mux[TASHA_RX5]),
  8922. SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, TASHA_RX6, 0,
  8923. &slim_rx_mux[TASHA_RX6]),
  8924. SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, TASHA_RX7, 0,
  8925. &slim_rx_mux[TASHA_RX7]),
  8926. SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
  8927. SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  8928. SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  8929. SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
  8930. SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
  8931. SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0),
  8932. SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0),
  8933. SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0),
  8934. SND_SOC_DAPM_MUX_E("SPL SRC0 MUX", SND_SOC_NOPM, SPLINE_SRC0, 0,
  8935. &spl_src0_mux, tasha_codec_enable_spline_resampler,
  8936. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8937. SND_SOC_DAPM_MUX_E("SPL SRC1 MUX", SND_SOC_NOPM, SPLINE_SRC1, 0,
  8938. &spl_src1_mux, tasha_codec_enable_spline_resampler,
  8939. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8940. SND_SOC_DAPM_MUX_E("SPL SRC2 MUX", SND_SOC_NOPM, SPLINE_SRC2, 0,
  8941. &spl_src2_mux, tasha_codec_enable_spline_resampler,
  8942. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8943. SND_SOC_DAPM_MUX_E("SPL SRC3 MUX", SND_SOC_NOPM, SPLINE_SRC3, 0,
  8944. &spl_src3_mux, tasha_codec_enable_spline_resampler,
  8945. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  8946. SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  8947. 5, 0, &rx_int0_2_mux, tasha_codec_enable_mix_path,
  8948. SND_SOC_DAPM_POST_PMU),
  8949. SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  8950. 5, 0, &rx_int1_2_mux, tasha_codec_enable_mix_path,
  8951. SND_SOC_DAPM_POST_PMU),
  8952. SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  8953. 5, 0, &rx_int2_2_mux, tasha_codec_enable_mix_path,
  8954. SND_SOC_DAPM_POST_PMU),
  8955. SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", WCD9335_CDC_RX3_RX_PATH_MIX_CTL,
  8956. 5, 0, &rx_int3_2_mux, tasha_codec_enable_mix_path,
  8957. SND_SOC_DAPM_POST_PMU),
  8958. SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", WCD9335_CDC_RX4_RX_PATH_MIX_CTL,
  8959. 5, 0, &rx_int4_2_mux, tasha_codec_enable_mix_path,
  8960. SND_SOC_DAPM_POST_PMU),
  8961. SND_SOC_DAPM_MUX_E("RX INT5_2 MUX", WCD9335_CDC_RX5_RX_PATH_MIX_CTL,
  8962. 5, 0, &rx_int5_2_mux, tasha_codec_enable_mix_path,
  8963. SND_SOC_DAPM_POST_PMU),
  8964. SND_SOC_DAPM_MUX_E("RX INT6_2 MUX", WCD9335_CDC_RX6_RX_PATH_MIX_CTL,
  8965. 5, 0, &rx_int6_2_mux, tasha_codec_enable_mix_path,
  8966. SND_SOC_DAPM_POST_PMU),
  8967. SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", WCD9335_CDC_RX7_RX_PATH_MIX_CTL,
  8968. 5, 0, &rx_int7_2_mux, tasha_codec_enable_mix_path,
  8969. SND_SOC_DAPM_POST_PMU),
  8970. SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", WCD9335_CDC_RX8_RX_PATH_MIX_CTL,
  8971. 5, 0, &rx_int8_2_mux, tasha_codec_enable_mix_path,
  8972. SND_SOC_DAPM_POST_PMU),
  8973. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8974. &rx_int0_1_mix_inp0_mux),
  8975. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8976. &rx_int0_1_mix_inp1_mux),
  8977. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8978. &rx_int0_1_mix_inp2_mux),
  8979. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8980. &rx_int1_1_mix_inp0_mux),
  8981. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8982. &rx_int1_1_mix_inp1_mux),
  8983. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8984. &rx_int1_1_mix_inp2_mux),
  8985. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8986. &rx_int2_1_mix_inp0_mux),
  8987. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8988. &rx_int2_1_mix_inp1_mux),
  8989. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8990. &rx_int2_1_mix_inp2_mux),
  8991. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8992. &rx_int3_1_mix_inp0_mux),
  8993. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  8994. &rx_int3_1_mix_inp1_mux),
  8995. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  8996. &rx_int3_1_mix_inp2_mux),
  8997. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  8998. &rx_int4_1_mix_inp0_mux),
  8999. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9000. &rx_int4_1_mix_inp1_mux),
  9001. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9002. &rx_int4_1_mix_inp2_mux),
  9003. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9004. &rx_int5_1_mix_inp0_mux),
  9005. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9006. &rx_int5_1_mix_inp1_mux),
  9007. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9008. &rx_int5_1_mix_inp2_mux),
  9009. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9010. &rx_int6_1_mix_inp0_mux),
  9011. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9012. &rx_int6_1_mix_inp1_mux),
  9013. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9014. &rx_int6_1_mix_inp2_mux),
  9015. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9016. &rx_int7_1_mix_inp0_mux, tasha_codec_enable_swr,
  9017. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9018. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9019. &rx_int7_1_mix_inp1_mux, tasha_codec_enable_swr,
  9020. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9021. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9022. &rx_int7_1_mix_inp2_mux, tasha_codec_enable_swr,
  9023. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9024. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9025. &rx_int8_1_mix_inp0_mux, tasha_codec_enable_swr,
  9026. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9027. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9028. &rx_int8_1_mix_inp1_mux, tasha_codec_enable_swr,
  9029. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9030. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9031. &rx_int8_1_mix_inp2_mux, tasha_codec_enable_swr,
  9032. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9033. SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9034. SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9035. SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9036. SND_SOC_DAPM_MIXER("RX INT1 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9037. rx_int1_spline_mix_switch,
  9038. ARRAY_SIZE(rx_int1_spline_mix_switch)),
  9039. SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9040. SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9041. SND_SOC_DAPM_MIXER("RX INT2 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9042. rx_int2_spline_mix_switch,
  9043. ARRAY_SIZE(rx_int2_spline_mix_switch)),
  9044. SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9045. SND_SOC_DAPM_MIXER("RX INT3_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9046. SND_SOC_DAPM_MIXER("RX INT3 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9047. rx_int3_spline_mix_switch,
  9048. ARRAY_SIZE(rx_int3_spline_mix_switch)),
  9049. SND_SOC_DAPM_MIXER("RX INT3 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9050. SND_SOC_DAPM_MIXER("RX INT4_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9051. SND_SOC_DAPM_MIXER("RX INT4 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9052. rx_int4_spline_mix_switch,
  9053. ARRAY_SIZE(rx_int4_spline_mix_switch)),
  9054. SND_SOC_DAPM_MIXER("RX INT4 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9055. SND_SOC_DAPM_MIXER("RX INT5_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9056. SND_SOC_DAPM_MIXER("RX INT5 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9057. rx_int5_spline_mix_switch,
  9058. ARRAY_SIZE(rx_int5_spline_mix_switch)),
  9059. SND_SOC_DAPM_MIXER("RX INT5 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9060. SND_SOC_DAPM_MIXER("RX INT6_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9061. SND_SOC_DAPM_MIXER("RX INT6 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9062. rx_int6_spline_mix_switch,
  9063. ARRAY_SIZE(rx_int6_spline_mix_switch)),
  9064. SND_SOC_DAPM_MIXER("RX INT6 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9065. SND_SOC_DAPM_MIXER("RX INT7_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9066. SND_SOC_DAPM_MIXER("RX INT7 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9067. SND_SOC_DAPM_MIXER("RX INT7 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9068. rx_int7_spline_mix_switch,
  9069. ARRAY_SIZE(rx_int7_spline_mix_switch)),
  9070. SND_SOC_DAPM_MIXER("RX INT8_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9071. SND_SOC_DAPM_MIXER("RX INT8 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9072. SND_SOC_DAPM_MIXER("RX INT8 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9073. rx_int8_spline_mix_switch,
  9074. ARRAY_SIZE(rx_int8_spline_mix_switch)),
  9075. SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9076. SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9077. SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9078. SND_SOC_DAPM_MIXER("RX INT3 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9079. SND_SOC_DAPM_MIXER("RX INT4 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9080. SND_SOC_DAPM_MIXER("RX INT5 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9081. SND_SOC_DAPM_MIXER("RX INT6 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9082. SND_SOC_DAPM_MIXER("RX INT7 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9083. SND_SOC_DAPM_MIXER_E("RX INT7 CHAIN", SND_SOC_NOPM, 0, 0,
  9084. NULL, 0, tasha_codec_spk_boost_event,
  9085. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9086. SND_SOC_DAPM_MIXER_E("RX INT8 CHAIN", SND_SOC_NOPM, 0, 0,
  9087. NULL, 0, tasha_codec_spk_boost_event,
  9088. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9089. SND_SOC_DAPM_MIXER_E("RX INT5 VBAT", SND_SOC_NOPM, 0, 0,
  9090. rx_int5_vbat_mix_switch,
  9091. ARRAY_SIZE(rx_int5_vbat_mix_switch),
  9092. tasha_codec_vbat_enable_event,
  9093. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9094. SND_SOC_DAPM_MIXER_E("RX INT6 VBAT", SND_SOC_NOPM, 0, 0,
  9095. rx_int6_vbat_mix_switch,
  9096. ARRAY_SIZE(rx_int6_vbat_mix_switch),
  9097. tasha_codec_vbat_enable_event,
  9098. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9099. SND_SOC_DAPM_MIXER_E("RX INT7 VBAT", SND_SOC_NOPM, 0, 0,
  9100. rx_int7_vbat_mix_switch,
  9101. ARRAY_SIZE(rx_int7_vbat_mix_switch),
  9102. tasha_codec_vbat_enable_event,
  9103. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9104. SND_SOC_DAPM_MIXER_E("RX INT8 VBAT", SND_SOC_NOPM, 0, 0,
  9105. rx_int8_vbat_mix_switch,
  9106. ARRAY_SIZE(rx_int8_vbat_mix_switch),
  9107. tasha_codec_vbat_enable_event,
  9108. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9109. SND_SOC_DAPM_MUX("RX INT0 MIX2 INP", WCD9335_CDC_RX0_RX_PATH_CFG1, 4,
  9110. 0, &rx_int0_mix2_inp_mux),
  9111. SND_SOC_DAPM_MUX("RX INT1 MIX2 INP", WCD9335_CDC_RX1_RX_PATH_CFG1, 4,
  9112. 0, &rx_int1_mix2_inp_mux),
  9113. SND_SOC_DAPM_MUX("RX INT2 MIX2 INP", WCD9335_CDC_RX2_RX_PATH_CFG1, 4,
  9114. 0, &rx_int2_mix2_inp_mux),
  9115. SND_SOC_DAPM_MUX("RX INT3 MIX2 INP", WCD9335_CDC_RX3_RX_PATH_CFG1, 4,
  9116. 0, &rx_int3_mix2_inp_mux),
  9117. SND_SOC_DAPM_MUX("RX INT4 MIX2 INP", WCD9335_CDC_RX4_RX_PATH_CFG1, 4,
  9118. 0, &rx_int4_mix2_inp_mux),
  9119. SND_SOC_DAPM_MUX("RX INT7 MIX2 INP", WCD9335_CDC_RX7_RX_PATH_CFG1, 4,
  9120. 0, &rx_int7_mix2_inp_mux),
  9121. SND_SOC_DAPM_MUX("SLIM TX0 MUX", SND_SOC_NOPM, TASHA_TX0, 0,
  9122. &sb_tx0_mux),
  9123. SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TASHA_TX1, 0,
  9124. &sb_tx1_mux),
  9125. SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TASHA_TX2, 0,
  9126. &sb_tx2_mux),
  9127. SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TASHA_TX3, 0,
  9128. &sb_tx3_mux),
  9129. SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TASHA_TX4, 0,
  9130. &sb_tx4_mux),
  9131. SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TASHA_TX5, 0,
  9132. &sb_tx5_mux),
  9133. SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, TASHA_TX6, 0,
  9134. &sb_tx6_mux),
  9135. SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, TASHA_TX7, 0,
  9136. &sb_tx7_mux),
  9137. SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, TASHA_TX8, 0,
  9138. &sb_tx8_mux),
  9139. SND_SOC_DAPM_MUX("SLIM TX9 MUX", SND_SOC_NOPM, TASHA_TX9, 0,
  9140. &sb_tx9_mux),
  9141. SND_SOC_DAPM_MUX("SLIM TX10 MUX", SND_SOC_NOPM, TASHA_TX10, 0,
  9142. &sb_tx10_mux),
  9143. SND_SOC_DAPM_MUX("SLIM TX11 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9144. &sb_tx11_mux),
  9145. SND_SOC_DAPM_MUX("SLIM TX11 INP1 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9146. &sb_tx11_inp1_mux),
  9147. SND_SOC_DAPM_MUX("SLIM TX13 MUX", SND_SOC_NOPM, TASHA_TX13, 0,
  9148. &sb_tx13_mux),
  9149. SND_SOC_DAPM_MUX("TX13 INP MUX", SND_SOC_NOPM, 0, 0,
  9150. &tx13_inp_mux),
  9151. SND_SOC_DAPM_MUX_E("ADC MUX0", WCD9335_CDC_TX0_TX_PATH_CTL, 5, 0,
  9152. &tx_adc_mux0, tasha_codec_enable_dec,
  9153. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9154. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9155. SND_SOC_DAPM_MUX_E("ADC MUX1", WCD9335_CDC_TX1_TX_PATH_CTL, 5, 0,
  9156. &tx_adc_mux1, tasha_codec_enable_dec,
  9157. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9158. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9159. SND_SOC_DAPM_MUX_E("ADC MUX2", WCD9335_CDC_TX2_TX_PATH_CTL, 5, 0,
  9160. &tx_adc_mux2, tasha_codec_enable_dec,
  9161. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9162. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9163. SND_SOC_DAPM_MUX_E("ADC MUX3", WCD9335_CDC_TX3_TX_PATH_CTL, 5, 0,
  9164. &tx_adc_mux3, tasha_codec_enable_dec,
  9165. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9166. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9167. SND_SOC_DAPM_MUX_E("ADC MUX4", WCD9335_CDC_TX4_TX_PATH_CTL, 5, 0,
  9168. &tx_adc_mux4, tasha_codec_enable_dec,
  9169. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9170. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9171. SND_SOC_DAPM_MUX_E("ADC MUX5", WCD9335_CDC_TX5_TX_PATH_CTL, 5, 0,
  9172. &tx_adc_mux5, tasha_codec_enable_dec,
  9173. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9174. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9175. SND_SOC_DAPM_MUX_E("ADC MUX6", WCD9335_CDC_TX6_TX_PATH_CTL, 5, 0,
  9176. &tx_adc_mux6, tasha_codec_enable_dec,
  9177. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9178. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9179. SND_SOC_DAPM_MUX_E("ADC MUX7", WCD9335_CDC_TX7_TX_PATH_CTL, 5, 0,
  9180. &tx_adc_mux7, tasha_codec_enable_dec,
  9181. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9182. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9183. SND_SOC_DAPM_MUX_E("ADC MUX8", WCD9335_CDC_TX8_TX_PATH_CTL, 5, 0,
  9184. &tx_adc_mux8, tasha_codec_enable_dec,
  9185. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9186. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9187. SND_SOC_DAPM_MUX_E("ADC MUX10", SND_SOC_NOPM, 10, 0,
  9188. &tx_adc_mux10, tasha_codec_tx_adc_cfg,
  9189. SND_SOC_DAPM_POST_PMU),
  9190. SND_SOC_DAPM_MUX_E("ADC MUX11", SND_SOC_NOPM, 11, 0,
  9191. &tx_adc_mux11, tasha_codec_tx_adc_cfg,
  9192. SND_SOC_DAPM_POST_PMU),
  9193. SND_SOC_DAPM_MUX_E("ADC MUX12", SND_SOC_NOPM, 12, 0,
  9194. &tx_adc_mux12, tasha_codec_tx_adc_cfg,
  9195. SND_SOC_DAPM_POST_PMU),
  9196. SND_SOC_DAPM_MUX_E("ADC MUX13", SND_SOC_NOPM, 13, 0,
  9197. &tx_adc_mux13, tasha_codec_tx_adc_cfg,
  9198. SND_SOC_DAPM_POST_PMU),
  9199. SND_SOC_DAPM_MUX("DMIC MUX0", SND_SOC_NOPM, 0, 0,
  9200. &tx_dmic_mux0),
  9201. SND_SOC_DAPM_MUX("DMIC MUX1", SND_SOC_NOPM, 0, 0,
  9202. &tx_dmic_mux1),
  9203. SND_SOC_DAPM_MUX("DMIC MUX2", SND_SOC_NOPM, 0, 0,
  9204. &tx_dmic_mux2),
  9205. SND_SOC_DAPM_MUX("DMIC MUX3", SND_SOC_NOPM, 0, 0,
  9206. &tx_dmic_mux3),
  9207. SND_SOC_DAPM_MUX("DMIC MUX4", SND_SOC_NOPM, 0, 0,
  9208. &tx_dmic_mux4),
  9209. SND_SOC_DAPM_MUX("DMIC MUX5", SND_SOC_NOPM, 0, 0,
  9210. &tx_dmic_mux5),
  9211. SND_SOC_DAPM_MUX("DMIC MUX6", SND_SOC_NOPM, 0, 0,
  9212. &tx_dmic_mux6),
  9213. SND_SOC_DAPM_MUX("DMIC MUX7", SND_SOC_NOPM, 0, 0,
  9214. &tx_dmic_mux7),
  9215. SND_SOC_DAPM_MUX("DMIC MUX8", SND_SOC_NOPM, 0, 0,
  9216. &tx_dmic_mux8),
  9217. SND_SOC_DAPM_MUX("DMIC MUX10", SND_SOC_NOPM, 0, 0,
  9218. &tx_dmic_mux10),
  9219. SND_SOC_DAPM_MUX("DMIC MUX11", SND_SOC_NOPM, 0, 0,
  9220. &tx_dmic_mux11),
  9221. SND_SOC_DAPM_MUX("DMIC MUX12", SND_SOC_NOPM, 0, 0,
  9222. &tx_dmic_mux12),
  9223. SND_SOC_DAPM_MUX("DMIC MUX13", SND_SOC_NOPM, 0, 0,
  9224. &tx_dmic_mux13),
  9225. SND_SOC_DAPM_MUX("AMIC MUX0", SND_SOC_NOPM, 0, 0,
  9226. &tx_amic_mux0),
  9227. SND_SOC_DAPM_MUX("AMIC MUX1", SND_SOC_NOPM, 0, 0,
  9228. &tx_amic_mux1),
  9229. SND_SOC_DAPM_MUX("AMIC MUX2", SND_SOC_NOPM, 0, 0,
  9230. &tx_amic_mux2),
  9231. SND_SOC_DAPM_MUX("AMIC MUX3", SND_SOC_NOPM, 0, 0,
  9232. &tx_amic_mux3),
  9233. SND_SOC_DAPM_MUX("AMIC MUX4", SND_SOC_NOPM, 0, 0,
  9234. &tx_amic_mux4),
  9235. SND_SOC_DAPM_MUX("AMIC MUX5", SND_SOC_NOPM, 0, 0,
  9236. &tx_amic_mux5),
  9237. SND_SOC_DAPM_MUX("AMIC MUX6", SND_SOC_NOPM, 0, 0,
  9238. &tx_amic_mux6),
  9239. SND_SOC_DAPM_MUX("AMIC MUX7", SND_SOC_NOPM, 0, 0,
  9240. &tx_amic_mux7),
  9241. SND_SOC_DAPM_MUX("AMIC MUX8", SND_SOC_NOPM, 0, 0,
  9242. &tx_amic_mux8),
  9243. SND_SOC_DAPM_MUX("AMIC MUX10", SND_SOC_NOPM, 0, 0,
  9244. &tx_amic_mux10),
  9245. SND_SOC_DAPM_MUX("AMIC MUX11", SND_SOC_NOPM, 0, 0,
  9246. &tx_amic_mux11),
  9247. SND_SOC_DAPM_MUX("AMIC MUX12", SND_SOC_NOPM, 0, 0,
  9248. &tx_amic_mux12),
  9249. SND_SOC_DAPM_MUX("AMIC MUX13", SND_SOC_NOPM, 0, 0,
  9250. &tx_amic_mux13),
  9251. SND_SOC_DAPM_ADC_E("ADC1", NULL, WCD9335_ANA_AMIC1, 7, 0,
  9252. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9253. SND_SOC_DAPM_ADC_E("ADC2", NULL, WCD9335_ANA_AMIC2, 7, 0,
  9254. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9255. SND_SOC_DAPM_ADC_E("ADC3", NULL, WCD9335_ANA_AMIC3, 7, 0,
  9256. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9257. SND_SOC_DAPM_ADC_E("ADC4", NULL, WCD9335_ANA_AMIC4, 7, 0,
  9258. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9259. SND_SOC_DAPM_ADC_E("ADC5", NULL, WCD9335_ANA_AMIC5, 7, 0,
  9260. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9261. SND_SOC_DAPM_ADC_E("ADC6", NULL, WCD9335_ANA_AMIC6, 7, 0,
  9262. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9263. SND_SOC_DAPM_SUPPLY("RX INT1 NATIVE SUPPLY", SND_SOC_NOPM,
  9264. INTERP_HPHL, 0, tasha_enable_native_supply,
  9265. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9266. SND_SOC_DAPM_SUPPLY("RX INT2 NATIVE SUPPLY", SND_SOC_NOPM,
  9267. INTERP_HPHR, 0, tasha_enable_native_supply,
  9268. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9269. SND_SOC_DAPM_SUPPLY("RX INT3 NATIVE SUPPLY", SND_SOC_NOPM,
  9270. INTERP_LO1, 0, tasha_enable_native_supply,
  9271. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9272. SND_SOC_DAPM_SUPPLY("RX INT4 NATIVE SUPPLY", SND_SOC_NOPM,
  9273. INTERP_LO2, 0, tasha_enable_native_supply,
  9274. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9275. SND_SOC_DAPM_INPUT("AMIC1"),
  9276. SND_SOC_DAPM_MICBIAS_E("MIC BIAS1", SND_SOC_NOPM, 0, 0,
  9277. tasha_codec_enable_micbias,
  9278. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9279. SND_SOC_DAPM_POST_PMD),
  9280. SND_SOC_DAPM_MICBIAS_E("MIC BIAS2", SND_SOC_NOPM, 0, 0,
  9281. tasha_codec_enable_micbias,
  9282. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9283. SND_SOC_DAPM_POST_PMD),
  9284. SND_SOC_DAPM_MICBIAS_E("MIC BIAS3", SND_SOC_NOPM, 0, 0,
  9285. tasha_codec_enable_micbias,
  9286. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9287. SND_SOC_DAPM_POST_PMD),
  9288. SND_SOC_DAPM_MICBIAS_E("MIC BIAS4", SND_SOC_NOPM, 0, 0,
  9289. tasha_codec_enable_micbias,
  9290. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9291. SND_SOC_DAPM_POST_PMD),
  9292. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS1_STANDALONE, SND_SOC_NOPM, 0, 0,
  9293. tasha_codec_force_enable_micbias,
  9294. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9295. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS2_STANDALONE, SND_SOC_NOPM, 0, 0,
  9296. tasha_codec_force_enable_micbias,
  9297. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9298. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS3_STANDALONE, SND_SOC_NOPM, 0, 0,
  9299. tasha_codec_force_enable_micbias,
  9300. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9301. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS4_STANDALONE, SND_SOC_NOPM, 0, 0,
  9302. tasha_codec_force_enable_micbias,
  9303. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9304. SND_SOC_DAPM_SUPPLY(DAPM_LDO_H_STANDALONE, SND_SOC_NOPM, 0, 0,
  9305. tasha_codec_force_enable_ldo_h,
  9306. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9307. SND_SOC_DAPM_MUX("ANC0 FB MUX", SND_SOC_NOPM, 0, 0, &anc0_fb_mux),
  9308. SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux),
  9309. SND_SOC_DAPM_INPUT("AMIC2"),
  9310. SND_SOC_DAPM_INPUT("AMIC3"),
  9311. SND_SOC_DAPM_INPUT("AMIC4"),
  9312. SND_SOC_DAPM_INPUT("AMIC5"),
  9313. SND_SOC_DAPM_INPUT("AMIC6"),
  9314. SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM,
  9315. AIF1_CAP, 0, tasha_codec_enable_slimtx,
  9316. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9317. SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM,
  9318. AIF2_CAP, 0, tasha_codec_enable_slimtx,
  9319. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9320. SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM,
  9321. AIF3_CAP, 0, tasha_codec_enable_slimtx,
  9322. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9323. SND_SOC_DAPM_AIF_OUT_E("AIF4 VI", "VIfeed", 0, SND_SOC_NOPM,
  9324. AIF4_VIFEED, 0, tasha_codec_enable_slimvi_feedback,
  9325. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9326. SND_SOC_DAPM_MIXER("AIF4_VI Mixer", SND_SOC_NOPM, AIF4_VIFEED, 0,
  9327. aif4_vi_mixer, ARRAY_SIZE(aif4_vi_mixer)),
  9328. SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0,
  9329. aif1_cap_mixer, ARRAY_SIZE(aif1_cap_mixer)),
  9330. SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0,
  9331. aif2_cap_mixer, ARRAY_SIZE(aif2_cap_mixer)),
  9332. SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0,
  9333. aif3_cap_mixer, ARRAY_SIZE(aif3_cap_mixer)),
  9334. SND_SOC_DAPM_MIXER("AIF4_MAD Mixer", SND_SOC_NOPM, AIF4_MAD_TX, 0,
  9335. aif4_mad_mixer, ARRAY_SIZE(aif4_mad_mixer)),
  9336. SND_SOC_DAPM_INPUT("VIINPUT"),
  9337. SND_SOC_DAPM_AIF_OUT("AIF5 CPE", "AIF5 CPE TX", 0, SND_SOC_NOPM,
  9338. AIF5_CPE_TX, 0),
  9339. SND_SOC_DAPM_MUX_E("EC BUF MUX INP", SND_SOC_NOPM, 0, 0, &ec_buf_mux,
  9340. tasha_codec_ec_buf_mux_enable,
  9341. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9342. /* Digital Mic Inputs */
  9343. SND_SOC_DAPM_ADC_E("DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  9344. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9345. SND_SOC_DAPM_POST_PMD),
  9346. SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  9347. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9348. SND_SOC_DAPM_POST_PMD),
  9349. SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  9350. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9351. SND_SOC_DAPM_POST_PMD),
  9352. SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  9353. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9354. SND_SOC_DAPM_POST_PMD),
  9355. SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  9356. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9357. SND_SOC_DAPM_POST_PMD),
  9358. SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  9359. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9360. SND_SOC_DAPM_POST_PMD),
  9361. SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux),
  9362. SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux),
  9363. SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux),
  9364. SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux),
  9365. SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux),
  9366. SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
  9367. SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux),
  9368. SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux),
  9369. SND_SOC_DAPM_MIXER_E("IIR0", WCD9335_CDC_SIDETONE_IIR0_IIR_PATH_CTL,
  9370. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9371. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9372. SND_SOC_DAPM_MIXER_E("IIR1", WCD9335_CDC_SIDETONE_IIR1_IIR_PATH_CTL,
  9373. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9374. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9375. SND_SOC_DAPM_MIXER("SRC0", WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL,
  9376. 4, 0, NULL, 0),
  9377. SND_SOC_DAPM_MIXER("SRC1", WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL,
  9378. 4, 0, NULL, 0),
  9379. SND_SOC_DAPM_MIXER_E("CPE IN Mixer", SND_SOC_NOPM, 0, 0,
  9380. cpe_in_mix_switch,
  9381. ARRAY_SIZE(cpe_in_mix_switch),
  9382. tasha_codec_configure_cpe_input,
  9383. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9384. SND_SOC_DAPM_MUX("RX INT1_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9385. &int1_1_native_mux),
  9386. SND_SOC_DAPM_MUX("RX INT2_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9387. &int2_1_native_mux),
  9388. SND_SOC_DAPM_MUX("RX INT3_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9389. &int3_1_native_mux),
  9390. SND_SOC_DAPM_MUX("RX INT4_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9391. &int4_1_native_mux),
  9392. SND_SOC_DAPM_MUX("RX MIX TX0 MUX", SND_SOC_NOPM, 0, 0,
  9393. &rx_mix_tx0_mux),
  9394. SND_SOC_DAPM_MUX("RX MIX TX1 MUX", SND_SOC_NOPM, 0, 0,
  9395. &rx_mix_tx1_mux),
  9396. SND_SOC_DAPM_MUX("RX MIX TX2 MUX", SND_SOC_NOPM, 0, 0,
  9397. &rx_mix_tx2_mux),
  9398. SND_SOC_DAPM_MUX("RX MIX TX3 MUX", SND_SOC_NOPM, 0, 0,
  9399. &rx_mix_tx3_mux),
  9400. SND_SOC_DAPM_MUX("RX MIX TX4 MUX", SND_SOC_NOPM, 0, 0,
  9401. &rx_mix_tx4_mux),
  9402. SND_SOC_DAPM_MUX("RX MIX TX5 MUX", SND_SOC_NOPM, 0, 0,
  9403. &rx_mix_tx5_mux),
  9404. SND_SOC_DAPM_MUX("RX MIX TX6 MUX", SND_SOC_NOPM, 0, 0,
  9405. &rx_mix_tx6_mux),
  9406. SND_SOC_DAPM_MUX("RX MIX TX7 MUX", SND_SOC_NOPM, 0, 0,
  9407. &rx_mix_tx7_mux),
  9408. SND_SOC_DAPM_MUX("RX MIX TX8 MUX", SND_SOC_NOPM, 0, 0,
  9409. &rx_mix_tx8_mux),
  9410. SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0,
  9411. &rx_int0_dem_inp_mux),
  9412. SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0,
  9413. &rx_int1_dem_inp_mux),
  9414. SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM, 0, 0,
  9415. &rx_int2_dem_inp_mux),
  9416. SND_SOC_DAPM_MUX_E("RX INT0 INTERP", SND_SOC_NOPM,
  9417. INTERP_EAR, 0, &rx_int0_interp_mux,
  9418. tasha_codec_enable_interpolator,
  9419. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9420. SND_SOC_DAPM_POST_PMD),
  9421. SND_SOC_DAPM_MUX_E("RX INT1 INTERP", SND_SOC_NOPM,
  9422. INTERP_HPHL, 0, &rx_int1_interp_mux,
  9423. tasha_codec_enable_interpolator,
  9424. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9425. SND_SOC_DAPM_POST_PMD),
  9426. SND_SOC_DAPM_MUX_E("RX INT2 INTERP", SND_SOC_NOPM,
  9427. INTERP_HPHR, 0, &rx_int2_interp_mux,
  9428. tasha_codec_enable_interpolator,
  9429. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9430. SND_SOC_DAPM_POST_PMD),
  9431. SND_SOC_DAPM_MUX_E("RX INT3 INTERP", SND_SOC_NOPM,
  9432. INTERP_LO1, 0, &rx_int3_interp_mux,
  9433. tasha_codec_enable_interpolator,
  9434. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9435. SND_SOC_DAPM_POST_PMD),
  9436. SND_SOC_DAPM_MUX_E("RX INT4 INTERP", SND_SOC_NOPM,
  9437. INTERP_LO2, 0, &rx_int4_interp_mux,
  9438. tasha_codec_enable_interpolator,
  9439. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9440. SND_SOC_DAPM_POST_PMD),
  9441. SND_SOC_DAPM_MUX_E("RX INT5 INTERP", SND_SOC_NOPM,
  9442. INTERP_LO3, 0, &rx_int5_interp_mux,
  9443. tasha_codec_enable_interpolator,
  9444. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9445. SND_SOC_DAPM_POST_PMD),
  9446. SND_SOC_DAPM_MUX_E("RX INT6 INTERP", SND_SOC_NOPM,
  9447. INTERP_LO4, 0, &rx_int6_interp_mux,
  9448. tasha_codec_enable_interpolator,
  9449. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9450. SND_SOC_DAPM_POST_PMD),
  9451. SND_SOC_DAPM_MUX_E("RX INT7 INTERP", SND_SOC_NOPM,
  9452. INTERP_SPKR1, 0, &rx_int7_interp_mux,
  9453. tasha_codec_enable_interpolator,
  9454. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9455. SND_SOC_DAPM_POST_PMD),
  9456. SND_SOC_DAPM_MUX_E("RX INT8 INTERP", SND_SOC_NOPM,
  9457. INTERP_SPKR2, 0, &rx_int8_interp_mux,
  9458. tasha_codec_enable_interpolator,
  9459. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9460. SND_SOC_DAPM_POST_PMD),
  9461. SND_SOC_DAPM_DAC_E("RX INT0 DAC", NULL, SND_SOC_NOPM,
  9462. 0, 0, tasha_codec_ear_dac_event,
  9463. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9464. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9465. SND_SOC_DAPM_DAC_E("RX INT1 DAC", NULL, WCD9335_ANA_HPH,
  9466. 5, 0, tasha_codec_hphl_dac_event,
  9467. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9468. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9469. SND_SOC_DAPM_DAC_E("RX INT2 DAC", NULL, WCD9335_ANA_HPH,
  9470. 4, 0, tasha_codec_hphr_dac_event,
  9471. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9472. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9473. SND_SOC_DAPM_DAC_E("RX INT3 DAC", NULL, SND_SOC_NOPM,
  9474. 0, 0, tasha_codec_lineout_dac_event,
  9475. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9476. SND_SOC_DAPM_DAC_E("RX INT4 DAC", NULL, SND_SOC_NOPM,
  9477. 0, 0, tasha_codec_lineout_dac_event,
  9478. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9479. SND_SOC_DAPM_DAC_E("RX INT5 DAC", NULL, SND_SOC_NOPM,
  9480. 0, 0, tasha_codec_lineout_dac_event,
  9481. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9482. SND_SOC_DAPM_DAC_E("RX INT6 DAC", NULL, SND_SOC_NOPM,
  9483. 0, 0, tasha_codec_lineout_dac_event,
  9484. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9485. SND_SOC_DAPM_PGA_E("HPHL PA", WCD9335_ANA_HPH, 7, 0, NULL, 0,
  9486. tasha_codec_enable_hphl_pa,
  9487. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9488. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9489. SND_SOC_DAPM_PGA_E("HPHR PA", WCD9335_ANA_HPH, 6, 0, NULL, 0,
  9490. tasha_codec_enable_hphr_pa,
  9491. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9492. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9493. SND_SOC_DAPM_PGA_E("EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9494. tasha_codec_enable_ear_pa,
  9495. SND_SOC_DAPM_POST_PMU |
  9496. SND_SOC_DAPM_POST_PMD),
  9497. SND_SOC_DAPM_PGA_E("LINEOUT1 PA", WCD9335_ANA_LO_1_2, 7, 0, NULL, 0,
  9498. tasha_codec_enable_lineout_pa,
  9499. SND_SOC_DAPM_POST_PMU |
  9500. SND_SOC_DAPM_POST_PMD),
  9501. SND_SOC_DAPM_PGA_E("LINEOUT2 PA", WCD9335_ANA_LO_1_2, 6, 0, NULL, 0,
  9502. tasha_codec_enable_lineout_pa,
  9503. SND_SOC_DAPM_POST_PMU |
  9504. SND_SOC_DAPM_POST_PMD),
  9505. SND_SOC_DAPM_PGA_E("LINEOUT3 PA", WCD9335_ANA_LO_3_4, 7, 0, NULL, 0,
  9506. tasha_codec_enable_lineout_pa,
  9507. SND_SOC_DAPM_POST_PMU |
  9508. SND_SOC_DAPM_POST_PMD),
  9509. SND_SOC_DAPM_PGA_E("LINEOUT4 PA", WCD9335_ANA_LO_3_4, 6, 0, NULL, 0,
  9510. tasha_codec_enable_lineout_pa,
  9511. SND_SOC_DAPM_POST_PMU |
  9512. SND_SOC_DAPM_POST_PMD),
  9513. SND_SOC_DAPM_PGA_E("ANC EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9514. tasha_codec_enable_ear_pa,
  9515. SND_SOC_DAPM_POST_PMU |
  9516. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9517. SND_SOC_DAPM_PGA_E("ANC HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9518. tasha_codec_enable_hphl_pa,
  9519. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9520. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9521. SND_SOC_DAPM_PGA_E("ANC HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9522. tasha_codec_enable_hphr_pa,
  9523. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9524. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9525. SND_SOC_DAPM_PGA_E("ANC LINEOUT1 PA", WCD9335_ANA_LO_1_2,
  9526. 7, 0, NULL, 0,
  9527. tasha_codec_enable_lineout_pa,
  9528. SND_SOC_DAPM_POST_PMU |
  9529. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9530. SND_SOC_DAPM_PGA_E("ANC LINEOUT2 PA", WCD9335_ANA_LO_1_2,
  9531. 6, 0, NULL, 0,
  9532. tasha_codec_enable_lineout_pa,
  9533. SND_SOC_DAPM_POST_PMU |
  9534. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9535. SND_SOC_DAPM_PGA_E("ANC SPK1 PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9536. tasha_codec_enable_spk_anc,
  9537. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9538. SND_SOC_DAPM_OUTPUT("HPHL"),
  9539. SND_SOC_DAPM_OUTPUT("HPHR"),
  9540. SND_SOC_DAPM_OUTPUT("ANC HPHL"),
  9541. SND_SOC_DAPM_OUTPUT("ANC HPHR"),
  9542. SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0,
  9543. tasha_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU |
  9544. SND_SOC_DAPM_POST_PMD),
  9545. SND_SOC_DAPM_OUTPUT("SPK1 OUT"),
  9546. SND_SOC_DAPM_OUTPUT("SPK2 OUT"),
  9547. SND_SOC_DAPM_OUTPUT("LINEOUT1"),
  9548. SND_SOC_DAPM_OUTPUT("LINEOUT2"),
  9549. SND_SOC_DAPM_OUTPUT("LINEOUT3"),
  9550. SND_SOC_DAPM_OUTPUT("LINEOUT4"),
  9551. SND_SOC_DAPM_OUTPUT("ANC LINEOUT1"),
  9552. SND_SOC_DAPM_OUTPUT("ANC LINEOUT2"),
  9553. SND_SOC_DAPM_SUPPLY("MICBIAS_REGULATOR", SND_SOC_NOPM,
  9554. ON_DEMAND_MICBIAS, 0,
  9555. tasha_codec_enable_on_demand_supply,
  9556. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9557. SND_SOC_DAPM_SWITCH("ADC US MUX0", WCD9335_CDC_TX0_TX_PATH_192_CTL, 0,
  9558. 0, &adc_us_mux0_switch),
  9559. SND_SOC_DAPM_SWITCH("ADC US MUX1", WCD9335_CDC_TX1_TX_PATH_192_CTL, 0,
  9560. 0, &adc_us_mux1_switch),
  9561. SND_SOC_DAPM_SWITCH("ADC US MUX2", WCD9335_CDC_TX2_TX_PATH_192_CTL, 0,
  9562. 0, &adc_us_mux2_switch),
  9563. SND_SOC_DAPM_SWITCH("ADC US MUX3", WCD9335_CDC_TX3_TX_PATH_192_CTL, 0,
  9564. 0, &adc_us_mux3_switch),
  9565. SND_SOC_DAPM_SWITCH("ADC US MUX4", WCD9335_CDC_TX4_TX_PATH_192_CTL, 0,
  9566. 0, &adc_us_mux4_switch),
  9567. SND_SOC_DAPM_SWITCH("ADC US MUX5", WCD9335_CDC_TX5_TX_PATH_192_CTL, 0,
  9568. 0, &adc_us_mux5_switch),
  9569. SND_SOC_DAPM_SWITCH("ADC US MUX6", WCD9335_CDC_TX6_TX_PATH_192_CTL, 0,
  9570. 0, &adc_us_mux6_switch),
  9571. SND_SOC_DAPM_SWITCH("ADC US MUX7", WCD9335_CDC_TX7_TX_PATH_192_CTL, 0,
  9572. 0, &adc_us_mux7_switch),
  9573. SND_SOC_DAPM_SWITCH("ADC US MUX8", WCD9335_CDC_TX8_TX_PATH_192_CTL, 0,
  9574. 0, &adc_us_mux8_switch),
  9575. /* MAD related widgets */
  9576. SND_SOC_DAPM_AIF_OUT_E("AIF4 MAD", "AIF4 MAD TX", 0,
  9577. SND_SOC_NOPM, 0, 0,
  9578. tasha_codec_enable_mad,
  9579. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9580. SND_SOC_DAPM_MUX("MAD_SEL MUX", SND_SOC_NOPM, 0, 0,
  9581. &mad_sel_mux),
  9582. SND_SOC_DAPM_INPUT("MAD_CPE_INPUT"),
  9583. SND_SOC_DAPM_INPUT("MADINPUT"),
  9584. SND_SOC_DAPM_SWITCH("MADONOFF", SND_SOC_NOPM, 0, 0,
  9585. &aif4_mad_switch),
  9586. SND_SOC_DAPM_SWITCH("MAD_BROADCAST", SND_SOC_NOPM, 0, 0,
  9587. &mad_brdcst_switch),
  9588. SND_SOC_DAPM_SWITCH("AIF4", SND_SOC_NOPM, 0, 0,
  9589. &aif4_switch_mixer_controls),
  9590. SND_SOC_DAPM_SWITCH("ANC HPHL Enable", SND_SOC_NOPM, 0, 0,
  9591. &anc_hphl_switch),
  9592. SND_SOC_DAPM_SWITCH("ANC HPHR Enable", SND_SOC_NOPM, 0, 0,
  9593. &anc_hphr_switch),
  9594. SND_SOC_DAPM_SWITCH("ANC EAR Enable", SND_SOC_NOPM, 0, 0,
  9595. &anc_ear_switch),
  9596. SND_SOC_DAPM_SWITCH("ANC OUT EAR SPKR Enable", SND_SOC_NOPM, 0, 0,
  9597. &anc_ear_spkr_switch),
  9598. SND_SOC_DAPM_SWITCH("ANC LINEOUT1 Enable", SND_SOC_NOPM, 0, 0,
  9599. &anc_lineout1_switch),
  9600. SND_SOC_DAPM_SWITCH("ANC LINEOUT2 Enable", SND_SOC_NOPM, 0, 0,
  9601. &anc_lineout2_switch),
  9602. SND_SOC_DAPM_SWITCH("ANC SPKR PA Enable", SND_SOC_NOPM, 0, 0,
  9603. &anc_spkr_pa_switch),
  9604. };
  9605. static int tasha_get_channel_map(struct snd_soc_dai *dai,
  9606. unsigned int *tx_num, unsigned int *tx_slot,
  9607. unsigned int *rx_num, unsigned int *rx_slot)
  9608. {
  9609. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(dai->codec);
  9610. u32 i = 0;
  9611. struct wcd9xxx_ch *ch;
  9612. switch (dai->id) {
  9613. case AIF1_PB:
  9614. case AIF2_PB:
  9615. case AIF3_PB:
  9616. case AIF4_PB:
  9617. case AIF_MIX1_PB:
  9618. if (!rx_slot || !rx_num) {
  9619. pr_err("%s: Invalid rx_slot %pK or rx_num %pK\n",
  9620. __func__, rx_slot, rx_num);
  9621. return -EINVAL;
  9622. }
  9623. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9624. list) {
  9625. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9626. __func__, i, ch->ch_num);
  9627. rx_slot[i++] = ch->ch_num;
  9628. }
  9629. pr_debug("%s: rx_num %d\n", __func__, i);
  9630. *rx_num = i;
  9631. break;
  9632. case AIF1_CAP:
  9633. case AIF2_CAP:
  9634. case AIF3_CAP:
  9635. case AIF4_MAD_TX:
  9636. case AIF4_VIFEED:
  9637. if (!tx_slot || !tx_num) {
  9638. pr_err("%s: Invalid tx_slot %pK or tx_num %pK\n",
  9639. __func__, tx_slot, tx_num);
  9640. return -EINVAL;
  9641. }
  9642. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9643. list) {
  9644. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9645. __func__, i, ch->ch_num);
  9646. tx_slot[i++] = ch->ch_num;
  9647. }
  9648. pr_debug("%s: tx_num %d\n", __func__, i);
  9649. *tx_num = i;
  9650. break;
  9651. default:
  9652. pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id);
  9653. break;
  9654. }
  9655. return 0;
  9656. }
  9657. static int tasha_set_channel_map(struct snd_soc_dai *dai,
  9658. unsigned int tx_num, unsigned int *tx_slot,
  9659. unsigned int rx_num, unsigned int *rx_slot)
  9660. {
  9661. struct tasha_priv *tasha;
  9662. struct wcd9xxx *core;
  9663. struct wcd9xxx_codec_dai_data *dai_data = NULL;
  9664. if (!dai) {
  9665. pr_err("%s: dai is empty\n", __func__);
  9666. return -EINVAL;
  9667. }
  9668. tasha = snd_soc_codec_get_drvdata(dai->codec);
  9669. core = dev_get_drvdata(dai->codec->dev->parent);
  9670. if (!tx_slot || !rx_slot) {
  9671. pr_err("%s: Invalid tx_slot=%pK, rx_slot=%pK\n",
  9672. __func__, tx_slot, rx_slot);
  9673. return -EINVAL;
  9674. }
  9675. pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n"
  9676. "tasha->intf_type %d\n",
  9677. __func__, dai->name, dai->id, tx_num, rx_num,
  9678. tasha->intf_type);
  9679. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  9680. wcd9xxx_init_slimslave(core, core->slim->laddr,
  9681. tx_num, tx_slot, rx_num, rx_slot);
  9682. /* Reserve TX12/TX13 for MAD data channel */
  9683. dai_data = &tasha->dai[AIF4_MAD_TX];
  9684. if (dai_data) {
  9685. if (TASHA_IS_2_0(tasha->wcd9xxx))
  9686. list_add_tail(&core->tx_chs[TASHA_TX13].list,
  9687. &dai_data->wcd9xxx_ch_list);
  9688. else
  9689. list_add_tail(&core->tx_chs[TASHA_TX12].list,
  9690. &dai_data->wcd9xxx_ch_list);
  9691. }
  9692. }
  9693. return 0;
  9694. }
  9695. static int tasha_startup(struct snd_pcm_substream *substream,
  9696. struct snd_soc_dai *dai)
  9697. {
  9698. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9699. substream->name, substream->stream);
  9700. return 0;
  9701. }
  9702. static void tasha_shutdown(struct snd_pcm_substream *substream,
  9703. struct snd_soc_dai *dai)
  9704. {
  9705. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  9706. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9707. substream->name, substream->stream);
  9708. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  9709. return;
  9710. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  9711. tasha_codec_vote_max_bw(dai->codec, false);
  9712. }
  9713. static int tasha_set_decimator_rate(struct snd_soc_dai *dai,
  9714. u8 tx_fs_rate_reg_val, u32 sample_rate)
  9715. {
  9716. struct snd_soc_codec *codec = dai->codec;
  9717. struct wcd9xxx_ch *ch;
  9718. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9719. u32 tx_port = 0;
  9720. u8 shift = 0, shift_val = 0, tx_mux_sel = 0;
  9721. int decimator = -1;
  9722. u16 tx_port_reg = 0, tx_fs_reg = 0;
  9723. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9724. tx_port = ch->port;
  9725. dev_dbg(codec->dev, "%s: dai->id = %d, tx_port = %d",
  9726. __func__, dai->id, tx_port);
  9727. if ((tx_port < 0) || (tx_port == 12) || (tx_port >= 14)) {
  9728. dev_err(codec->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n",
  9729. __func__, tx_port, dai->id);
  9730. return -EINVAL;
  9731. }
  9732. /* Find the SB TX MUX input - which decimator is connected */
  9733. if (tx_port < 4) {
  9734. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0;
  9735. shift = (tx_port << 1);
  9736. shift_val = 0x03;
  9737. } else if ((tx_port >= 4) && (tx_port < 8)) {
  9738. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1;
  9739. shift = ((tx_port - 4) << 1);
  9740. shift_val = 0x03;
  9741. } else if ((tx_port >= 8) && (tx_port < 11)) {
  9742. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2;
  9743. shift = ((tx_port - 8) << 1);
  9744. shift_val = 0x03;
  9745. } else if (tx_port == 11) {
  9746. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9747. shift = 0;
  9748. shift_val = 0x0F;
  9749. } else if (tx_port == 13) {
  9750. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9751. shift = 4;
  9752. shift_val = 0x03;
  9753. }
  9754. tx_mux_sel = snd_soc_read(codec, tx_port_reg) &
  9755. (shift_val << shift);
  9756. tx_mux_sel = tx_mux_sel >> shift;
  9757. if (tx_port <= 8) {
  9758. if ((tx_mux_sel == 0x2) || (tx_mux_sel == 0x3))
  9759. decimator = tx_port;
  9760. } else if (tx_port <= 10) {
  9761. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9762. decimator = ((tx_port == 9) ? 7 : 6);
  9763. } else if (tx_port == 11) {
  9764. if ((tx_mux_sel >= 1) && (tx_mux_sel < 7))
  9765. decimator = tx_mux_sel - 1;
  9766. } else if (tx_port == 13) {
  9767. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9768. decimator = 5;
  9769. }
  9770. if (decimator >= 0) {
  9771. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  9772. 16 * decimator;
  9773. dev_dbg(codec->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n",
  9774. __func__, decimator, tx_port, sample_rate);
  9775. snd_soc_update_bits(codec, tx_fs_reg, 0x0F,
  9776. tx_fs_rate_reg_val);
  9777. } else if ((tx_port <= 8) && (tx_mux_sel == 0x01)) {
  9778. /* Check if the TX Mux input is RX MIX TXn */
  9779. dev_dbg(codec->dev, "%s: RX_MIX_TX%u going to SLIM TX%u\n",
  9780. __func__, tx_port, tx_port);
  9781. } else {
  9782. dev_err(codec->dev, "%s: ERROR: Invalid decimator: %d\n",
  9783. __func__, decimator);
  9784. return -EINVAL;
  9785. }
  9786. }
  9787. return 0;
  9788. }
  9789. static int tasha_set_mix_interpolator_rate(struct snd_soc_dai *dai,
  9790. u8 int_mix_fs_rate_reg_val,
  9791. u32 sample_rate)
  9792. {
  9793. u8 int_2_inp;
  9794. u32 j;
  9795. u16 int_mux_cfg1, int_fs_reg;
  9796. u8 int_mux_cfg1_val;
  9797. struct snd_soc_codec *codec = dai->codec;
  9798. struct wcd9xxx_ch *ch;
  9799. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9800. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9801. int_2_inp = ch->port + INTn_2_INP_SEL_RX0 -
  9802. TASHA_RX_PORT_START_NUMBER;
  9803. if ((int_2_inp < INTn_2_INP_SEL_RX0) ||
  9804. (int_2_inp > INTn_2_INP_SEL_RX7)) {
  9805. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9806. __func__,
  9807. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9808. dai->id);
  9809. return -EINVAL;
  9810. }
  9811. int_mux_cfg1 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1;
  9812. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9813. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) &
  9814. 0x0F;
  9815. if (int_mux_cfg1_val == int_2_inp) {
  9816. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_MIX_CTL +
  9817. 20 * j;
  9818. pr_debug("%s: AIF_MIX_PB DAI(%d) connected to INT%u_2\n",
  9819. __func__, dai->id, j);
  9820. pr_debug("%s: set INT%u_2 sample rate to %u\n",
  9821. __func__, j, sample_rate);
  9822. snd_soc_update_bits(codec, int_fs_reg,
  9823. 0x0F, int_mix_fs_rate_reg_val);
  9824. }
  9825. int_mux_cfg1 += 2;
  9826. }
  9827. }
  9828. return 0;
  9829. }
  9830. static int tasha_set_prim_interpolator_rate(struct snd_soc_dai *dai,
  9831. u8 int_prim_fs_rate_reg_val,
  9832. u32 sample_rate)
  9833. {
  9834. u8 int_1_mix1_inp;
  9835. u32 j;
  9836. u16 int_mux_cfg0, int_mux_cfg1;
  9837. u16 int_fs_reg;
  9838. u8 int_mux_cfg0_val, int_mux_cfg1_val;
  9839. u8 inp0_sel, inp1_sel, inp2_sel;
  9840. struct snd_soc_codec *codec = dai->codec;
  9841. struct wcd9xxx_ch *ch;
  9842. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9843. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9844. int_1_mix1_inp = ch->port + INTn_1_MIX_INP_SEL_RX0 -
  9845. TASHA_RX_PORT_START_NUMBER;
  9846. if ((int_1_mix1_inp < INTn_1_MIX_INP_SEL_RX0) ||
  9847. (int_1_mix1_inp > INTn_1_MIX_INP_SEL_RX7)) {
  9848. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9849. __func__,
  9850. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9851. dai->id);
  9852. return -EINVAL;
  9853. }
  9854. int_mux_cfg0 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0;
  9855. /*
  9856. * Loop through all interpolator MUX inputs and find out
  9857. * to which interpolator input, the slim rx port
  9858. * is connected
  9859. */
  9860. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9861. int_mux_cfg1 = int_mux_cfg0 + 1;
  9862. int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0);
  9863. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1);
  9864. inp0_sel = int_mux_cfg0_val & 0x0F;
  9865. inp1_sel = (int_mux_cfg0_val >> 4) & 0x0F;
  9866. inp2_sel = (int_mux_cfg1_val >> 4) & 0x0F;
  9867. if ((inp0_sel == int_1_mix1_inp) ||
  9868. (inp1_sel == int_1_mix1_inp) ||
  9869. (inp2_sel == int_1_mix1_inp)) {
  9870. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_CTL +
  9871. 20 * j;
  9872. pr_debug("%s: AIF_PB DAI(%d) connected to INT%u_1\n",
  9873. __func__, dai->id, j);
  9874. pr_debug("%s: set INT%u_1 sample rate to %u\n",
  9875. __func__, j, sample_rate);
  9876. /* sample_rate is in Hz */
  9877. if ((j == 0) && (sample_rate == 44100)) {
  9878. pr_info("%s: Cannot set 44.1KHz on INT0\n",
  9879. __func__);
  9880. } else
  9881. snd_soc_update_bits(codec, int_fs_reg,
  9882. 0x0F, int_prim_fs_rate_reg_val);
  9883. }
  9884. int_mux_cfg0 += 2;
  9885. }
  9886. }
  9887. return 0;
  9888. }
  9889. static int tasha_set_interpolator_rate(struct snd_soc_dai *dai,
  9890. u32 sample_rate)
  9891. {
  9892. int rate_val = 0;
  9893. int i, ret;
  9894. /* set mixing path rate */
  9895. for (i = 0; i < ARRAY_SIZE(int_mix_sample_rate_val); i++) {
  9896. if (sample_rate ==
  9897. int_mix_sample_rate_val[i].sample_rate) {
  9898. rate_val =
  9899. int_mix_sample_rate_val[i].rate_val;
  9900. break;
  9901. }
  9902. }
  9903. if ((i == ARRAY_SIZE(int_mix_sample_rate_val)) ||
  9904. (rate_val < 0))
  9905. goto prim_rate;
  9906. ret = tasha_set_mix_interpolator_rate(dai,
  9907. (u8) rate_val, sample_rate);
  9908. prim_rate:
  9909. /* set primary path sample rate */
  9910. for (i = 0; i < ARRAY_SIZE(int_prim_sample_rate_val); i++) {
  9911. if (sample_rate ==
  9912. int_prim_sample_rate_val[i].sample_rate) {
  9913. rate_val =
  9914. int_prim_sample_rate_val[i].rate_val;
  9915. break;
  9916. }
  9917. }
  9918. if ((i == ARRAY_SIZE(int_prim_sample_rate_val)) ||
  9919. (rate_val < 0))
  9920. return -EINVAL;
  9921. ret = tasha_set_prim_interpolator_rate(dai,
  9922. (u8) rate_val, sample_rate);
  9923. return ret;
  9924. }
  9925. static int tasha_prepare(struct snd_pcm_substream *substream,
  9926. struct snd_soc_dai *dai)
  9927. {
  9928. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9929. substream->name, substream->stream);
  9930. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  9931. tasha_codec_vote_max_bw(dai->codec, false);
  9932. return 0;
  9933. }
  9934. static int tasha_hw_params(struct snd_pcm_substream *substream,
  9935. struct snd_pcm_hw_params *params,
  9936. struct snd_soc_dai *dai)
  9937. {
  9938. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  9939. int ret;
  9940. int tx_fs_rate = -EINVAL;
  9941. int rx_fs_rate = -EINVAL;
  9942. int i2s_bit_mode;
  9943. struct snd_soc_codec *codec = dai->codec;
  9944. pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
  9945. dai->name, dai->id, params_rate(params),
  9946. params_channels(params));
  9947. switch (substream->stream) {
  9948. case SNDRV_PCM_STREAM_PLAYBACK:
  9949. ret = tasha_set_interpolator_rate(dai, params_rate(params));
  9950. if (ret) {
  9951. pr_err("%s: cannot set sample rate: %u\n",
  9952. __func__, params_rate(params));
  9953. return ret;
  9954. }
  9955. switch (params_width(params)) {
  9956. case 16:
  9957. tasha->dai[dai->id].bit_width = 16;
  9958. i2s_bit_mode = 0x01;
  9959. break;
  9960. case 24:
  9961. tasha->dai[dai->id].bit_width = 24;
  9962. i2s_bit_mode = 0x00;
  9963. break;
  9964. default:
  9965. return -EINVAL;
  9966. }
  9967. tasha->dai[dai->id].rate = params_rate(params);
  9968. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  9969. switch (params_rate(params)) {
  9970. case 8000:
  9971. rx_fs_rate = 0;
  9972. break;
  9973. case 16000:
  9974. rx_fs_rate = 1;
  9975. break;
  9976. case 32000:
  9977. rx_fs_rate = 2;
  9978. break;
  9979. case 48000:
  9980. rx_fs_rate = 3;
  9981. break;
  9982. case 96000:
  9983. rx_fs_rate = 4;
  9984. break;
  9985. case 192000:
  9986. rx_fs_rate = 5;
  9987. break;
  9988. default:
  9989. dev_err(tasha->dev,
  9990. "%s: Invalid RX sample rate: %d\n",
  9991. __func__, params_rate(params));
  9992. return -EINVAL;
  9993. };
  9994. snd_soc_update_bits(codec,
  9995. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  9996. 0x20, i2s_bit_mode << 5);
  9997. snd_soc_update_bits(codec,
  9998. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  9999. 0x1c, (rx_fs_rate << 2));
  10000. }
  10001. break;
  10002. case SNDRV_PCM_STREAM_CAPTURE:
  10003. switch (params_rate(params)) {
  10004. case 8000:
  10005. tx_fs_rate = 0;
  10006. break;
  10007. case 16000:
  10008. tx_fs_rate = 1;
  10009. break;
  10010. case 32000:
  10011. tx_fs_rate = 3;
  10012. break;
  10013. case 48000:
  10014. tx_fs_rate = 4;
  10015. break;
  10016. case 96000:
  10017. tx_fs_rate = 5;
  10018. break;
  10019. case 192000:
  10020. tx_fs_rate = 6;
  10021. break;
  10022. case 384000:
  10023. tx_fs_rate = 7;
  10024. break;
  10025. default:
  10026. dev_err(tasha->dev, "%s: Invalid TX sample rate: %d\n",
  10027. __func__, params_rate(params));
  10028. return -EINVAL;
  10029. };
  10030. if (dai->id != AIF4_VIFEED &&
  10031. dai->id != AIF4_MAD_TX) {
  10032. ret = tasha_set_decimator_rate(dai, tx_fs_rate,
  10033. params_rate(params));
  10034. if (ret < 0) {
  10035. dev_err(tasha->dev, "%s: cannot set TX Decimator rate: %d\n",
  10036. __func__, tx_fs_rate);
  10037. return ret;
  10038. }
  10039. }
  10040. tasha->dai[dai->id].rate = params_rate(params);
  10041. switch (params_width(params)) {
  10042. case 16:
  10043. tasha->dai[dai->id].bit_width = 16;
  10044. i2s_bit_mode = 0x01;
  10045. break;
  10046. case 24:
  10047. tasha->dai[dai->id].bit_width = 24;
  10048. i2s_bit_mode = 0x00;
  10049. break;
  10050. case 32:
  10051. tasha->dai[dai->id].bit_width = 32;
  10052. i2s_bit_mode = 0x00;
  10053. break;
  10054. default:
  10055. dev_err(tasha->dev, "%s: Invalid format 0x%x\n",
  10056. __func__, params_width(params));
  10057. return -EINVAL;
  10058. };
  10059. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10060. snd_soc_update_bits(codec,
  10061. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10062. 0x20, i2s_bit_mode << 5);
  10063. if (tx_fs_rate > 1)
  10064. tx_fs_rate--;
  10065. snd_soc_update_bits(codec,
  10066. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10067. 0x1c, tx_fs_rate << 2);
  10068. snd_soc_update_bits(codec,
  10069. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG,
  10070. 0x05, 0x05);
  10071. snd_soc_update_bits(codec,
  10072. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG,
  10073. 0x05, 0x05);
  10074. snd_soc_update_bits(codec,
  10075. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG,
  10076. 0x05, 0x05);
  10077. snd_soc_update_bits(codec,
  10078. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG,
  10079. 0x05, 0x05);
  10080. }
  10081. break;
  10082. default:
  10083. pr_err("%s: Invalid stream type %d\n", __func__,
  10084. substream->stream);
  10085. return -EINVAL;
  10086. };
  10087. if (dai->id == AIF4_VIFEED)
  10088. tasha->dai[dai->id].bit_width = 32;
  10089. return 0;
  10090. }
  10091. static int tasha_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  10092. {
  10093. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  10094. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  10095. case SND_SOC_DAIFMT_CBS_CFS:
  10096. /* CPU is master */
  10097. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10098. if (dai->id == AIF1_CAP)
  10099. snd_soc_update_bits(dai->codec,
  10100. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10101. 0x2, 0);
  10102. else if (dai->id == AIF1_PB)
  10103. snd_soc_update_bits(dai->codec,
  10104. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10105. 0x2, 0);
  10106. }
  10107. break;
  10108. case SND_SOC_DAIFMT_CBM_CFM:
  10109. /* CPU is slave */
  10110. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10111. if (dai->id == AIF1_CAP)
  10112. snd_soc_update_bits(dai->codec,
  10113. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10114. 0x2, 0x2);
  10115. else if (dai->id == AIF1_PB)
  10116. snd_soc_update_bits(dai->codec,
  10117. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10118. 0x2, 0x2);
  10119. }
  10120. break;
  10121. default:
  10122. return -EINVAL;
  10123. }
  10124. return 0;
  10125. }
  10126. static int tasha_set_dai_sysclk(struct snd_soc_dai *dai,
  10127. int clk_id, unsigned int freq, int dir)
  10128. {
  10129. pr_debug("%s\n", __func__);
  10130. return 0;
  10131. }
  10132. static struct snd_soc_dai_ops tasha_dai_ops = {
  10133. .startup = tasha_startup,
  10134. .shutdown = tasha_shutdown,
  10135. .hw_params = tasha_hw_params,
  10136. .prepare = tasha_prepare,
  10137. .set_sysclk = tasha_set_dai_sysclk,
  10138. .set_fmt = tasha_set_dai_fmt,
  10139. .set_channel_map = tasha_set_channel_map,
  10140. .get_channel_map = tasha_get_channel_map,
  10141. };
  10142. static struct snd_soc_dai_driver tasha_dai[] = {
  10143. {
  10144. .name = "tasha_rx1",
  10145. .id = AIF1_PB,
  10146. .playback = {
  10147. .stream_name = "AIF1 Playback",
  10148. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10149. .formats = TASHA_FORMATS_S16_S24_LE,
  10150. .rate_max = 192000,
  10151. .rate_min = 8000,
  10152. .channels_min = 1,
  10153. .channels_max = 2,
  10154. },
  10155. .ops = &tasha_dai_ops,
  10156. },
  10157. {
  10158. .name = "tasha_tx1",
  10159. .id = AIF1_CAP,
  10160. .capture = {
  10161. .stream_name = "AIF1 Capture",
  10162. .rates = WCD9335_RATES_MASK,
  10163. .formats = TASHA_FORMATS_S16_S24_LE,
  10164. .rate_max = 192000,
  10165. .rate_min = 8000,
  10166. .channels_min = 1,
  10167. .channels_max = 4,
  10168. },
  10169. .ops = &tasha_dai_ops,
  10170. },
  10171. {
  10172. .name = "tasha_rx2",
  10173. .id = AIF2_PB,
  10174. .playback = {
  10175. .stream_name = "AIF2 Playback",
  10176. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10177. .formats = TASHA_FORMATS_S16_S24_LE,
  10178. .rate_min = 8000,
  10179. .rate_max = 192000,
  10180. .channels_min = 1,
  10181. .channels_max = 2,
  10182. },
  10183. .ops = &tasha_dai_ops,
  10184. },
  10185. {
  10186. .name = "tasha_tx2",
  10187. .id = AIF2_CAP,
  10188. .capture = {
  10189. .stream_name = "AIF2 Capture",
  10190. .rates = WCD9335_RATES_MASK,
  10191. .formats = TASHA_FORMATS_S16_S24_LE,
  10192. .rate_max = 192000,
  10193. .rate_min = 8000,
  10194. .channels_min = 1,
  10195. .channels_max = 8,
  10196. },
  10197. .ops = &tasha_dai_ops,
  10198. },
  10199. {
  10200. .name = "tasha_rx3",
  10201. .id = AIF3_PB,
  10202. .playback = {
  10203. .stream_name = "AIF3 Playback",
  10204. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10205. .formats = TASHA_FORMATS_S16_S24_LE,
  10206. .rate_min = 8000,
  10207. .rate_max = 192000,
  10208. .channels_min = 1,
  10209. .channels_max = 2,
  10210. },
  10211. .ops = &tasha_dai_ops,
  10212. },
  10213. {
  10214. .name = "tasha_tx3",
  10215. .id = AIF3_CAP,
  10216. .capture = {
  10217. .stream_name = "AIF3 Capture",
  10218. .rates = WCD9335_RATES_MASK,
  10219. .formats = TASHA_FORMATS_S16_S24_LE,
  10220. .rate_max = 48000,
  10221. .rate_min = 8000,
  10222. .channels_min = 1,
  10223. .channels_max = 2,
  10224. },
  10225. .ops = &tasha_dai_ops,
  10226. },
  10227. {
  10228. .name = "tasha_rx4",
  10229. .id = AIF4_PB,
  10230. .playback = {
  10231. .stream_name = "AIF4 Playback",
  10232. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10233. .formats = TASHA_FORMATS_S16_S24_LE,
  10234. .rate_min = 8000,
  10235. .rate_max = 192000,
  10236. .channels_min = 1,
  10237. .channels_max = 2,
  10238. },
  10239. .ops = &tasha_dai_ops,
  10240. },
  10241. {
  10242. .name = "tasha_mix_rx1",
  10243. .id = AIF_MIX1_PB,
  10244. .playback = {
  10245. .stream_name = "AIF Mix Playback",
  10246. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10247. .formats = TASHA_FORMATS_S16_S24_LE,
  10248. .rate_min = 8000,
  10249. .rate_max = 192000,
  10250. .channels_min = 1,
  10251. .channels_max = 8,
  10252. },
  10253. .ops = &tasha_dai_ops,
  10254. },
  10255. {
  10256. .name = "tasha_mad1",
  10257. .id = AIF4_MAD_TX,
  10258. .capture = {
  10259. .stream_name = "AIF4 MAD TX",
  10260. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10261. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_384000,
  10262. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10263. .rate_min = 16000,
  10264. .rate_max = 384000,
  10265. .channels_min = 1,
  10266. .channels_max = 1,
  10267. },
  10268. .ops = &tasha_dai_ops,
  10269. },
  10270. {
  10271. .name = "tasha_vifeedback",
  10272. .id = AIF4_VIFEED,
  10273. .capture = {
  10274. .stream_name = "VIfeed",
  10275. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
  10276. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10277. .rate_max = 48000,
  10278. .rate_min = 8000,
  10279. .channels_min = 1,
  10280. .channels_max = 4,
  10281. },
  10282. .ops = &tasha_dai_ops,
  10283. },
  10284. {
  10285. .name = "tasha_cpe",
  10286. .id = AIF5_CPE_TX,
  10287. .capture = {
  10288. .stream_name = "AIF5 CPE TX",
  10289. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000,
  10290. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10291. .rate_min = 16000,
  10292. .rate_max = 48000,
  10293. .channels_min = 1,
  10294. .channels_max = 1,
  10295. },
  10296. },
  10297. };
  10298. static struct snd_soc_dai_driver tasha_i2s_dai[] = {
  10299. {
  10300. .name = "tasha_i2s_rx1",
  10301. .id = AIF1_PB,
  10302. .playback = {
  10303. .stream_name = "AIF1 Playback",
  10304. .rates = WCD9335_RATES_MASK,
  10305. .formats = TASHA_FORMATS_S16_S24_LE,
  10306. .rate_max = 192000,
  10307. .rate_min = 8000,
  10308. .channels_min = 1,
  10309. .channels_max = 2,
  10310. },
  10311. .ops = &tasha_dai_ops,
  10312. },
  10313. {
  10314. .name = "tasha_i2s_tx1",
  10315. .id = AIF1_CAP,
  10316. .capture = {
  10317. .stream_name = "AIF1 Capture",
  10318. .rates = WCD9335_RATES_MASK,
  10319. .formats = TASHA_FORMATS_S16_S24_LE,
  10320. .rate_max = 192000,
  10321. .rate_min = 8000,
  10322. .channels_min = 1,
  10323. .channels_max = 4,
  10324. },
  10325. .ops = &tasha_dai_ops,
  10326. },
  10327. {
  10328. .name = "tasha_i2s_rx2",
  10329. .id = AIF2_PB,
  10330. .playback = {
  10331. .stream_name = "AIF2 Playback",
  10332. .rates = WCD9335_RATES_MASK,
  10333. .formats = TASHA_FORMATS_S16_S24_LE,
  10334. .rate_max = 192000,
  10335. .rate_min = 8000,
  10336. .channels_min = 1,
  10337. .channels_max = 2,
  10338. },
  10339. .ops = &tasha_dai_ops,
  10340. },
  10341. {
  10342. .name = "tasha_i2s_tx2",
  10343. .id = AIF2_CAP,
  10344. .capture = {
  10345. .stream_name = "AIF2 Capture",
  10346. .rates = WCD9335_RATES_MASK,
  10347. .formats = TASHA_FORMATS_S16_S24_LE,
  10348. .rate_max = 192000,
  10349. .rate_min = 8000,
  10350. .channels_min = 1,
  10351. .channels_max = 4,
  10352. },
  10353. .ops = &tasha_dai_ops,
  10354. },
  10355. };
  10356. static void tasha_codec_power_gate_digital_core(struct tasha_priv *tasha)
  10357. {
  10358. struct snd_soc_codec *codec = tasha->codec;
  10359. if (!codec)
  10360. return;
  10361. mutex_lock(&tasha->power_lock);
  10362. dev_dbg(codec->dev, "%s: Entering power gating function, %d\n",
  10363. __func__, tasha->power_active_ref);
  10364. if (tasha->power_active_ref > 0)
  10365. goto exit;
  10366. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10367. WCD_REGION_POWER_COLLAPSE_BEGIN,
  10368. WCD9XXX_DIG_CORE_REGION_1);
  10369. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10370. 0x04, 0x04);
  10371. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10372. 0x01, 0x00);
  10373. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10374. 0x02, 0x00);
  10375. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10376. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  10377. wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_DOWN,
  10378. WCD9XXX_DIG_CORE_REGION_1);
  10379. exit:
  10380. dev_dbg(codec->dev, "%s: Exiting power gating function, %d\n",
  10381. __func__, tasha->power_active_ref);
  10382. mutex_unlock(&tasha->power_lock);
  10383. }
  10384. static void tasha_codec_power_gate_work(struct work_struct *work)
  10385. {
  10386. struct tasha_priv *tasha;
  10387. struct delayed_work *dwork;
  10388. struct snd_soc_codec *codec;
  10389. dwork = to_delayed_work(work);
  10390. tasha = container_of(dwork, struct tasha_priv, power_gate_work);
  10391. codec = tasha->codec;
  10392. if (!codec)
  10393. return;
  10394. tasha_codec_power_gate_digital_core(tasha);
  10395. }
  10396. /* called under power_lock acquisition */
  10397. static int tasha_dig_core_remove_power_collapse(struct snd_soc_codec *codec)
  10398. {
  10399. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10400. tasha_codec_vote_max_bw(codec, true);
  10401. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5);
  10402. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7);
  10403. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3);
  10404. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x00);
  10405. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x02);
  10406. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10407. WCD_REGION_POWER_COLLAPSE_REMOVE,
  10408. WCD9XXX_DIG_CORE_REGION_1);
  10409. regcache_mark_dirty(codec->component.regmap);
  10410. regcache_sync_region(codec->component.regmap,
  10411. TASHA_DIG_CORE_REG_MIN, TASHA_DIG_CORE_REG_MAX);
  10412. tasha_codec_vote_max_bw(codec, false);
  10413. return 0;
  10414. }
  10415. static int tasha_dig_core_power_collapse(struct tasha_priv *tasha,
  10416. int req_state)
  10417. {
  10418. struct snd_soc_codec *codec;
  10419. int cur_state;
  10420. /* Exit if feature is disabled */
  10421. if (!dig_core_collapse_enable)
  10422. return 0;
  10423. mutex_lock(&tasha->power_lock);
  10424. if (req_state == POWER_COLLAPSE)
  10425. tasha->power_active_ref--;
  10426. else if (req_state == POWER_RESUME)
  10427. tasha->power_active_ref++;
  10428. else
  10429. goto unlock_mutex;
  10430. if (tasha->power_active_ref < 0) {
  10431. dev_dbg(tasha->dev, "%s: power_active_ref is negative\n",
  10432. __func__);
  10433. goto unlock_mutex;
  10434. }
  10435. codec = tasha->codec;
  10436. if (!codec)
  10437. goto unlock_mutex;
  10438. if (req_state == POWER_COLLAPSE) {
  10439. if (tasha->power_active_ref == 0) {
  10440. schedule_delayed_work(&tasha->power_gate_work,
  10441. msecs_to_jiffies(dig_core_collapse_timer * 1000));
  10442. }
  10443. } else if (req_state == POWER_RESUME) {
  10444. if (tasha->power_active_ref == 1) {
  10445. /*
  10446. * At this point, there can be two cases:
  10447. * 1. Core already in power collapse state
  10448. * 2. Timer kicked in and still did not expire or
  10449. * waiting for the power_lock
  10450. */
  10451. cur_state = wcd9xxx_get_current_power_state(
  10452. tasha->wcd9xxx,
  10453. WCD9XXX_DIG_CORE_REGION_1);
  10454. if (cur_state == WCD_REGION_POWER_DOWN)
  10455. tasha_dig_core_remove_power_collapse(codec);
  10456. else {
  10457. mutex_unlock(&tasha->power_lock);
  10458. cancel_delayed_work_sync(
  10459. &tasha->power_gate_work);
  10460. mutex_lock(&tasha->power_lock);
  10461. }
  10462. }
  10463. }
  10464. unlock_mutex:
  10465. mutex_unlock(&tasha->power_lock);
  10466. return 0;
  10467. }
  10468. static int __tasha_cdc_mclk_enable_locked(struct tasha_priv *tasha,
  10469. bool enable)
  10470. {
  10471. int ret = 0;
  10472. if (!tasha->wcd_ext_clk) {
  10473. dev_err(tasha->dev, "%s: wcd ext clock is NULL\n", __func__);
  10474. return -EINVAL;
  10475. }
  10476. dev_dbg(tasha->dev, "%s: mclk_enable = %u\n", __func__, enable);
  10477. if (enable) {
  10478. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10479. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10480. if (ret)
  10481. goto err;
  10482. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10483. tasha_codec_apply_sido_voltage(tasha,
  10484. SIDO_VOLTAGE_NOMINAL_MV);
  10485. } else {
  10486. if (!dig_core_collapse_enable) {
  10487. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10488. tasha_codec_update_sido_voltage(tasha,
  10489. sido_buck_svs_voltage);
  10490. }
  10491. tasha_cdc_req_mclk_enable(tasha, false);
  10492. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10493. }
  10494. err:
  10495. return ret;
  10496. }
  10497. static int __tasha_cdc_mclk_enable(struct tasha_priv *tasha,
  10498. bool enable)
  10499. {
  10500. int ret;
  10501. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10502. ret = __tasha_cdc_mclk_enable_locked(tasha, enable);
  10503. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10504. return ret;
  10505. }
  10506. int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10507. {
  10508. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10509. return __tasha_cdc_mclk_enable(tasha, enable);
  10510. }
  10511. EXPORT_SYMBOL(tasha_cdc_mclk_enable);
  10512. int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10513. {
  10514. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10515. int ret = 0;
  10516. dev_dbg(tasha->dev, "%s: clk_mode: %d, enable: %d, clk_internal: %d\n",
  10517. __func__, tasha->clk_mode, enable, tasha->clk_internal);
  10518. if (tasha->clk_mode || tasha->clk_internal) {
  10519. if (enable) {
  10520. tasha_cdc_sido_ccl_enable(tasha, true);
  10521. wcd_resmgr_enable_master_bias(tasha->resmgr);
  10522. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10523. snd_soc_update_bits(codec,
  10524. WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
  10525. 0x01, 0x01);
  10526. snd_soc_update_bits(codec,
  10527. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  10528. 0x01, 0x01);
  10529. set_bit(CPE_NOMINAL, &tasha->status_mask);
  10530. tasha_codec_update_sido_voltage(tasha,
  10531. SIDO_VOLTAGE_NOMINAL_MV);
  10532. tasha->clk_internal = true;
  10533. } else {
  10534. tasha->clk_internal = false;
  10535. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  10536. tasha_codec_update_sido_voltage(tasha,
  10537. sido_buck_svs_voltage);
  10538. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10539. wcd_resmgr_disable_master_bias(tasha->resmgr);
  10540. tasha_cdc_sido_ccl_enable(tasha, false);
  10541. }
  10542. } else {
  10543. ret = __tasha_cdc_mclk_enable(tasha, enable);
  10544. }
  10545. return ret;
  10546. }
  10547. EXPORT_SYMBOL(tasha_cdc_mclk_tx_enable);
  10548. static ssize_t tasha_codec_version_read(struct snd_info_entry *entry,
  10549. void *file_private_data, struct file *file,
  10550. char __user *buf, size_t count, loff_t pos)
  10551. {
  10552. struct tasha_priv *tasha;
  10553. struct wcd9xxx *wcd9xxx;
  10554. char buffer[TASHA_VERSION_ENTRY_SIZE];
  10555. int len = 0;
  10556. tasha = (struct tasha_priv *) entry->private_data;
  10557. if (!tasha) {
  10558. pr_err("%s: tasha priv is null\n", __func__);
  10559. return -EINVAL;
  10560. }
  10561. wcd9xxx = tasha->wcd9xxx;
  10562. if (wcd9xxx->codec_type->id_major == TASHA_MAJOR) {
  10563. if (TASHA_IS_1_0(wcd9xxx))
  10564. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_0\n");
  10565. else if (TASHA_IS_1_1(wcd9xxx))
  10566. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_1\n");
  10567. else
  10568. snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10569. } else if (wcd9xxx->codec_type->id_major == TASHA2P0_MAJOR) {
  10570. len = snprintf(buffer, sizeof(buffer), "WCD9335_2_0\n");
  10571. } else
  10572. len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10573. return simple_read_from_buffer(buf, count, &pos, buffer, len);
  10574. }
  10575. static struct snd_info_entry_ops tasha_codec_info_ops = {
  10576. .read = tasha_codec_version_read,
  10577. };
  10578. /*
  10579. * tasha_codec_info_create_codec_entry - creates wcd9335 module
  10580. * @codec_root: The parent directory
  10581. * @codec: Codec instance
  10582. *
  10583. * Creates wcd9335 module and version entry under the given
  10584. * parent directory.
  10585. *
  10586. * Return: 0 on success or negative error code on failure.
  10587. */
  10588. int tasha_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
  10589. struct snd_soc_codec *codec)
  10590. {
  10591. struct snd_info_entry *version_entry;
  10592. struct tasha_priv *tasha;
  10593. struct snd_soc_card *card;
  10594. if (!codec_root || !codec)
  10595. return -EINVAL;
  10596. tasha = snd_soc_codec_get_drvdata(codec);
  10597. card = codec->component.card;
  10598. tasha->entry = snd_info_create_subdir(codec_root->module,
  10599. "tasha", codec_root);
  10600. if (!tasha->entry) {
  10601. dev_dbg(codec->dev, "%s: failed to create wcd9335 entry\n",
  10602. __func__);
  10603. return -ENOMEM;
  10604. }
  10605. version_entry = snd_info_create_card_entry(card->snd_card,
  10606. "version",
  10607. tasha->entry);
  10608. if (!version_entry) {
  10609. dev_dbg(codec->dev, "%s: failed to create wcd9335 version entry\n",
  10610. __func__);
  10611. return -ENOMEM;
  10612. }
  10613. version_entry->private_data = tasha;
  10614. version_entry->size = TASHA_VERSION_ENTRY_SIZE;
  10615. version_entry->content = SNDRV_INFO_CONTENT_DATA;
  10616. version_entry->c.ops = &tasha_codec_info_ops;
  10617. if (snd_info_register(version_entry) < 0) {
  10618. snd_info_free_entry(version_entry);
  10619. return -ENOMEM;
  10620. }
  10621. tasha->version_entry = version_entry;
  10622. return 0;
  10623. }
  10624. EXPORT_SYMBOL(tasha_codec_info_create_codec_entry);
  10625. static int __tasha_codec_internal_rco_ctrl(
  10626. struct snd_soc_codec *codec, bool enable)
  10627. {
  10628. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10629. int ret = 0;
  10630. if (enable) {
  10631. tasha_cdc_sido_ccl_enable(tasha, true);
  10632. if (wcd_resmgr_get_clk_type(tasha->resmgr) ==
  10633. WCD_CLK_RCO) {
  10634. ret = wcd_resmgr_enable_clk_block(tasha->resmgr,
  10635. WCD_CLK_RCO);
  10636. } else {
  10637. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10638. ret |= wcd_resmgr_enable_clk_block(tasha->resmgr,
  10639. WCD_CLK_RCO);
  10640. ret |= tasha_cdc_req_mclk_enable(tasha, false);
  10641. }
  10642. } else {
  10643. ret = wcd_resmgr_disable_clk_block(tasha->resmgr,
  10644. WCD_CLK_RCO);
  10645. tasha_cdc_sido_ccl_enable(tasha, false);
  10646. }
  10647. if (ret) {
  10648. dev_err(codec->dev, "%s: Error in %s RCO\n",
  10649. __func__, (enable ? "enabling" : "disabling"));
  10650. ret = -EINVAL;
  10651. }
  10652. return ret;
  10653. }
  10654. /*
  10655. * tasha_codec_internal_rco_ctrl()
  10656. * Make sure that the caller does not acquire
  10657. * BG_CLK_LOCK.
  10658. */
  10659. static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
  10660. bool enable)
  10661. {
  10662. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10663. int ret = 0;
  10664. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10665. ret = __tasha_codec_internal_rco_ctrl(codec, enable);
  10666. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10667. return ret;
  10668. }
  10669. /*
  10670. * tasha_mbhc_hs_detect: starts mbhc insertion/removal functionality
  10671. * @codec: handle to snd_soc_codec *
  10672. * @mbhc_cfg: handle to mbhc configuration structure
  10673. * return 0 if mbhc_start is success or error code in case of failure
  10674. */
  10675. int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
  10676. struct wcd_mbhc_config *mbhc_cfg)
  10677. {
  10678. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10679. return wcd_mbhc_start(&tasha->mbhc, mbhc_cfg);
  10680. }
  10681. EXPORT_SYMBOL(tasha_mbhc_hs_detect);
  10682. /*
  10683. * tasha_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
  10684. * @codec: handle to snd_soc_codec *
  10685. */
  10686. void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
  10687. {
  10688. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10689. wcd_mbhc_stop(&tasha->mbhc);
  10690. }
  10691. EXPORT_SYMBOL(tasha_mbhc_hs_detect_exit);
  10692. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv)
  10693. {
  10694. /* min micbias voltage is 1V and maximum is 2.85V */
  10695. if (micb_mv < 1000 || micb_mv > 2850) {
  10696. pr_err("%s: unsupported micbias voltage\n", __func__);
  10697. return -EINVAL;
  10698. }
  10699. return (micb_mv - 1000) / 50;
  10700. }
  10701. static const struct tasha_reg_mask_val tasha_reg_update_reset_val_1_1[] = {
  10702. {WCD9335_RCO_CTRL_2, 0xFF, 0x47},
  10703. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10704. };
  10705. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_1[] = {
  10706. {WCD9335_FLYBACK_VNEG_DAC_CTRL_1, 0xFF, 0x65},
  10707. {WCD9335_FLYBACK_VNEG_DAC_CTRL_2, 0xFF, 0x52},
  10708. {WCD9335_FLYBACK_VNEG_DAC_CTRL_3, 0xFF, 0xAF},
  10709. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10710. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0xF4},
  10711. {WCD9335_FLYBACK_VNEG_CTRL_9, 0xFF, 0x40},
  10712. {WCD9335_FLYBACK_VNEG_CTRL_2, 0xFF, 0x4F},
  10713. {WCD9335_FLYBACK_EN, 0xFF, 0x6E},
  10714. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xF8, 0xF8},
  10715. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xF8, 0xF8},
  10716. };
  10717. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_0[] = {
  10718. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0x54},
  10719. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xFC, 0xFC},
  10720. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xFC, 0xFC},
  10721. };
  10722. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_2_0[] = {
  10723. {WCD9335_RCO_CTRL_2, 0x0F, 0x08},
  10724. {WCD9335_RX_BIAS_FLYB_MID_RST, 0xF0, 0x10},
  10725. {WCD9335_FLYBACK_CTRL_1, 0x20, 0x20},
  10726. {WCD9335_HPH_OCP_CTL, 0xFF, 0x7A},
  10727. {WCD9335_HPH_L_TEST, 0x01, 0x01},
  10728. {WCD9335_HPH_R_TEST, 0x01, 0x01},
  10729. {WCD9335_CDC_BOOST0_BOOST_CFG1, 0x3F, 0x12},
  10730. {WCD9335_CDC_BOOST0_BOOST_CFG2, 0x1C, 0x08},
  10731. {WCD9335_CDC_COMPANDER7_CTL7, 0x1E, 0x18},
  10732. {WCD9335_CDC_BOOST1_BOOST_CFG1, 0x3F, 0x12},
  10733. {WCD9335_CDC_BOOST1_BOOST_CFG2, 0x1C, 0x08},
  10734. {WCD9335_CDC_COMPANDER8_CTL7, 0x1E, 0x18},
  10735. {WCD9335_CDC_TX0_TX_PATH_SEC7, 0xFF, 0x45},
  10736. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xFC, 0xF4},
  10737. {WCD9335_HPH_REFBUFF_LP_CTL, 0x08, 0x08},
  10738. {WCD9335_HPH_REFBUFF_LP_CTL, 0x06, 0x02},
  10739. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xA0},
  10740. {WCD9335_SE_LO_COM1, 0xFF, 0xC0},
  10741. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xFC, 0xF4},
  10742. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xFC, 0xF4},
  10743. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xFC, 0xF8},
  10744. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xFC, 0xF8},
  10745. };
  10746. static const struct tasha_reg_mask_val tasha_codec_reg_defaults[] = {
  10747. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x00},
  10748. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x01},
  10749. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x04, 0x04},
  10750. };
  10751. static const struct tasha_reg_mask_val tasha_codec_reg_i2c_defaults[] = {
  10752. {WCD9335_ANA_CLK_TOP, 0x20, 0x20},
  10753. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x01},
  10754. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x00},
  10755. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x05, 0x05},
  10756. {WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG, 0x01, 0x01},
  10757. {WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG, 0x01, 0x01},
  10758. {WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG, 0x01, 0x01},
  10759. {WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG, 0x01, 0x01},
  10760. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG, 0x05, 0x05},
  10761. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG, 0x05, 0x05},
  10762. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG, 0x05, 0x05},
  10763. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG, 0x05, 0x05},
  10764. };
  10765. static const struct tasha_reg_mask_val tasha_codec_reg_init_common_val[] = {
  10766. /* Rbuckfly/R_EAR(32) */
  10767. {WCD9335_CDC_CLSH_K2_MSB, 0x0F, 0x00},
  10768. {WCD9335_CDC_CLSH_K2_LSB, 0xFF, 0x60},
  10769. {WCD9335_CPE_SS_DMIC_CFG, 0x80, 0x00},
  10770. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x70, 0x50},
  10771. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x70, 0x50},
  10772. {WCD9335_CDC_RX7_RX_PATH_CFG1, 0x08, 0x08},
  10773. {WCD9335_CDC_RX8_RX_PATH_CFG1, 0x08, 0x08},
  10774. {WCD9335_ANA_LO_1_2, 0x3C, 0X3C},
  10775. {WCD9335_DIFF_LO_COM_SWCAP_REFBUF_FREQ, 0x70, 0x00},
  10776. {WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03, 0x03},
  10777. {WCD9335_CDC_TOP_TOP_CFG1, 0x02, 0x02},
  10778. {WCD9335_CDC_TOP_TOP_CFG1, 0x01, 0x01},
  10779. {WCD9335_EAR_CMBUFF, 0x08, 0x00},
  10780. {WCD9335_CDC_TX9_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10781. {WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10782. {WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10783. {WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10784. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  10785. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  10786. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  10787. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  10788. {WCD9335_CDC_RX0_RX_PATH_CFG0, 0x01, 0x01},
  10789. {WCD9335_CDC_RX1_RX_PATH_CFG0, 0x01, 0x01},
  10790. {WCD9335_CDC_RX2_RX_PATH_CFG0, 0x01, 0x01},
  10791. {WCD9335_CDC_RX3_RX_PATH_CFG0, 0x01, 0x01},
  10792. {WCD9335_CDC_RX4_RX_PATH_CFG0, 0x01, 0x01},
  10793. {WCD9335_CDC_RX5_RX_PATH_CFG0, 0x01, 0x01},
  10794. {WCD9335_CDC_RX6_RX_PATH_CFG0, 0x01, 0x01},
  10795. {WCD9335_CDC_RX7_RX_PATH_CFG0, 0x01, 0x01},
  10796. {WCD9335_CDC_RX8_RX_PATH_CFG0, 0x01, 0x01},
  10797. {WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 0x01, 0x01},
  10798. {WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 0x01, 0x01},
  10799. {WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 0x01, 0x01},
  10800. {WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 0x01, 0x01},
  10801. {WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 0x01, 0x01},
  10802. {WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 0x01, 0x01},
  10803. {WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 0x01, 0x01},
  10804. {WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 0x01, 0x01},
  10805. {WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 0x01, 0x01},
  10806. {WCD9335_VBADC_IBIAS_FE, 0x0C, 0x08},
  10807. };
  10808. static const struct tasha_reg_mask_val tasha_codec_reg_init_1_x_val[] = {
  10809. /* Enable TX HPF Filter & Linear Phase */
  10810. {WCD9335_CDC_TX0_TX_PATH_CFG0, 0x11, 0x11},
  10811. {WCD9335_CDC_TX1_TX_PATH_CFG0, 0x11, 0x11},
  10812. {WCD9335_CDC_TX2_TX_PATH_CFG0, 0x11, 0x11},
  10813. {WCD9335_CDC_TX3_TX_PATH_CFG0, 0x11, 0x11},
  10814. {WCD9335_CDC_TX4_TX_PATH_CFG0, 0x11, 0x11},
  10815. {WCD9335_CDC_TX5_TX_PATH_CFG0, 0x11, 0x11},
  10816. {WCD9335_CDC_TX6_TX_PATH_CFG0, 0x11, 0x11},
  10817. {WCD9335_CDC_TX7_TX_PATH_CFG0, 0x11, 0x11},
  10818. {WCD9335_CDC_TX8_TX_PATH_CFG0, 0x11, 0x11},
  10819. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xF8, 0xF8},
  10820. {WCD9335_CDC_RX0_RX_PATH_SEC1, 0x08, 0x08},
  10821. {WCD9335_CDC_RX1_RX_PATH_SEC1, 0x08, 0x08},
  10822. {WCD9335_CDC_RX2_RX_PATH_SEC1, 0x08, 0x08},
  10823. {WCD9335_CDC_RX3_RX_PATH_SEC1, 0x08, 0x08},
  10824. {WCD9335_CDC_RX4_RX_PATH_SEC1, 0x08, 0x08},
  10825. {WCD9335_CDC_RX5_RX_PATH_SEC1, 0x08, 0x08},
  10826. {WCD9335_CDC_RX6_RX_PATH_SEC1, 0x08, 0x08},
  10827. {WCD9335_CDC_RX7_RX_PATH_SEC1, 0x08, 0x08},
  10828. {WCD9335_CDC_RX8_RX_PATH_SEC1, 0x08, 0x08},
  10829. {WCD9335_CDC_RX0_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10830. {WCD9335_CDC_RX1_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10831. {WCD9335_CDC_RX2_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10832. {WCD9335_CDC_RX3_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10833. {WCD9335_CDC_RX4_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10834. {WCD9335_CDC_RX5_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10835. {WCD9335_CDC_RX6_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10836. {WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10837. {WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10838. {WCD9335_CDC_TX0_TX_PATH_SEC2, 0x01, 0x01},
  10839. {WCD9335_CDC_TX1_TX_PATH_SEC2, 0x01, 0x01},
  10840. {WCD9335_CDC_TX2_TX_PATH_SEC2, 0x01, 0x01},
  10841. {WCD9335_CDC_TX3_TX_PATH_SEC2, 0x01, 0x01},
  10842. {WCD9335_CDC_TX4_TX_PATH_SEC2, 0x01, 0x01},
  10843. {WCD9335_CDC_TX5_TX_PATH_SEC2, 0x01, 0x01},
  10844. {WCD9335_CDC_TX6_TX_PATH_SEC2, 0x01, 0x01},
  10845. {WCD9335_CDC_TX7_TX_PATH_SEC2, 0x01, 0x01},
  10846. {WCD9335_CDC_TX8_TX_PATH_SEC2, 0x01, 0x01},
  10847. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xF8, 0xF0},
  10848. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xF8, 0xF0},
  10849. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xF8, 0xF8},
  10850. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xF8, 0xF8},
  10851. {WCD9335_RX_OCP_COUNT, 0xFF, 0xFF},
  10852. {WCD9335_HPH_OCP_CTL, 0xF0, 0x70},
  10853. {WCD9335_CPE_SS_CPAR_CFG, 0xFF, 0x00},
  10854. {WCD9335_FLYBACK_VNEG_CTRL_1, 0xFF, 0x63},
  10855. {WCD9335_FLYBACK_VNEG_CTRL_4, 0xFF, 0x7F},
  10856. {WCD9335_CLASSH_CTRL_VCL_1, 0xFF, 0x60},
  10857. {WCD9335_CLASSH_CTRL_CCL_5, 0xFF, 0x40},
  10858. {WCD9335_RX_TIMER_DIV, 0xFF, 0x32},
  10859. {WCD9335_SE_LO_COM2, 0xFF, 0x01},
  10860. {WCD9335_MBHC_ZDET_ANA_CTL, 0x0F, 0x07},
  10861. {WCD9335_RX_BIAS_HPH_PA, 0xF0, 0x60},
  10862. {WCD9335_HPH_RDAC_LDO_CTL, 0x88, 0x88},
  10863. {WCD9335_HPH_L_EN, 0x20, 0x20},
  10864. {WCD9335_HPH_R_EN, 0x20, 0x20},
  10865. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xD8},
  10866. {WCD9335_CDC_RX5_RX_PATH_SEC3, 0xBD, 0xBD},
  10867. {WCD9335_CDC_RX6_RX_PATH_SEC3, 0xBD, 0xBD},
  10868. {WCD9335_DIFF_LO_COM_PA_FREQ, 0x70, 0x40},
  10869. };
  10870. static void tasha_update_reg_reset_values(struct snd_soc_codec *codec)
  10871. {
  10872. u32 i;
  10873. struct wcd9xxx *tasha_core = dev_get_drvdata(codec->dev->parent);
  10874. if (TASHA_IS_1_1(tasha_core)) {
  10875. for (i = 0; i < ARRAY_SIZE(tasha_reg_update_reset_val_1_1);
  10876. i++)
  10877. snd_soc_write(codec,
  10878. tasha_reg_update_reset_val_1_1[i].reg,
  10879. tasha_reg_update_reset_val_1_1[i].val);
  10880. }
  10881. }
  10882. static void tasha_codec_init_reg(struct snd_soc_codec *codec)
  10883. {
  10884. u32 i;
  10885. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  10886. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_common_val); i++)
  10887. snd_soc_update_bits(codec,
  10888. tasha_codec_reg_init_common_val[i].reg,
  10889. tasha_codec_reg_init_common_val[i].mask,
  10890. tasha_codec_reg_init_common_val[i].val);
  10891. if (TASHA_IS_1_1(wcd9xxx) ||
  10892. TASHA_IS_1_0(wcd9xxx))
  10893. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_1_x_val); i++)
  10894. snd_soc_update_bits(codec,
  10895. tasha_codec_reg_init_1_x_val[i].reg,
  10896. tasha_codec_reg_init_1_x_val[i].mask,
  10897. tasha_codec_reg_init_1_x_val[i].val);
  10898. if (TASHA_IS_1_1(wcd9xxx)) {
  10899. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_1); i++)
  10900. snd_soc_update_bits(codec,
  10901. tasha_codec_reg_init_val_1_1[i].reg,
  10902. tasha_codec_reg_init_val_1_1[i].mask,
  10903. tasha_codec_reg_init_val_1_1[i].val);
  10904. } else if (TASHA_IS_1_0(wcd9xxx)) {
  10905. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_0); i++)
  10906. snd_soc_update_bits(codec,
  10907. tasha_codec_reg_init_val_1_0[i].reg,
  10908. tasha_codec_reg_init_val_1_0[i].mask,
  10909. tasha_codec_reg_init_val_1_0[i].val);
  10910. } else if (TASHA_IS_2_0(wcd9xxx)) {
  10911. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_2_0); i++)
  10912. snd_soc_update_bits(codec,
  10913. tasha_codec_reg_init_val_2_0[i].reg,
  10914. tasha_codec_reg_init_val_2_0[i].mask,
  10915. tasha_codec_reg_init_val_2_0[i].val);
  10916. }
  10917. }
  10918. static void tasha_update_reg_defaults(struct tasha_priv *tasha)
  10919. {
  10920. u32 i;
  10921. struct wcd9xxx *wcd9xxx;
  10922. wcd9xxx = tasha->wcd9xxx;
  10923. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_defaults); i++)
  10924. regmap_update_bits(wcd9xxx->regmap,
  10925. tasha_codec_reg_defaults[i].reg,
  10926. tasha_codec_reg_defaults[i].mask,
  10927. tasha_codec_reg_defaults[i].val);
  10928. tasha->intf_type = wcd9xxx_get_intf_type();
  10929. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  10930. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_i2c_defaults); i++)
  10931. regmap_update_bits(wcd9xxx->regmap,
  10932. tasha_codec_reg_i2c_defaults[i].reg,
  10933. tasha_codec_reg_i2c_defaults[i].mask,
  10934. tasha_codec_reg_i2c_defaults[i].val);
  10935. }
  10936. static void tasha_slim_interface_init_reg(struct snd_soc_codec *codec)
  10937. {
  10938. int i;
  10939. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  10940. for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++)
  10941. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  10942. TASHA_SLIM_PGD_PORT_INT_EN0 + i,
  10943. 0xFF);
  10944. }
  10945. static irqreturn_t tasha_slimbus_irq(int irq, void *data)
  10946. {
  10947. struct tasha_priv *priv = data;
  10948. unsigned long status = 0;
  10949. int i, j, port_id, k;
  10950. u32 bit;
  10951. u8 val, int_val = 0;
  10952. bool tx, cleared;
  10953. unsigned short reg = 0;
  10954. for (i = TASHA_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
  10955. i <= TASHA_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
  10956. val = wcd9xxx_interface_reg_read(priv->wcd9xxx, i);
  10957. status |= ((u32)val << (8 * j));
  10958. }
  10959. for_each_set_bit(j, &status, 32) {
  10960. tx = (j >= 16 ? true : false);
  10961. port_id = (tx ? j - 16 : j);
  10962. val = wcd9xxx_interface_reg_read(priv->wcd9xxx,
  10963. TASHA_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
  10964. if (val) {
  10965. if (!tx)
  10966. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  10967. (port_id / 8);
  10968. else
  10969. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  10970. (port_id / 8);
  10971. int_val = wcd9xxx_interface_reg_read(
  10972. priv->wcd9xxx, reg);
  10973. /*
  10974. * Ignore interrupts for ports for which the
  10975. * interrupts are not specifically enabled.
  10976. */
  10977. if (!(int_val & (1 << (port_id % 8))))
  10978. continue;
  10979. }
  10980. if (val & TASHA_SLIM_IRQ_OVERFLOW)
  10981. pr_err_ratelimited(
  10982. "%s: overflow error on %s port %d, value %x\n",
  10983. __func__, (tx ? "TX" : "RX"), port_id, val);
  10984. if (val & TASHA_SLIM_IRQ_UNDERFLOW)
  10985. pr_err_ratelimited(
  10986. "%s: underflow error on %s port %d, value %x\n",
  10987. __func__, (tx ? "TX" : "RX"), port_id, val);
  10988. if ((val & TASHA_SLIM_IRQ_OVERFLOW) ||
  10989. (val & TASHA_SLIM_IRQ_UNDERFLOW)) {
  10990. if (!tx)
  10991. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  10992. (port_id / 8);
  10993. else
  10994. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  10995. (port_id / 8);
  10996. int_val = wcd9xxx_interface_reg_read(
  10997. priv->wcd9xxx, reg);
  10998. if (int_val & (1 << (port_id % 8))) {
  10999. int_val = int_val ^ (1 << (port_id % 8));
  11000. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11001. reg, int_val);
  11002. }
  11003. }
  11004. if (val & TASHA_SLIM_IRQ_PORT_CLOSED) {
  11005. /*
  11006. * INT SOURCE register starts from RX to TX
  11007. * but port number in the ch_mask is in opposite way
  11008. */
  11009. bit = (tx ? j - 16 : j + 16);
  11010. pr_debug("%s: %s port %d closed value %x, bit %u\n",
  11011. __func__, (tx ? "TX" : "RX"), port_id, val,
  11012. bit);
  11013. for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) {
  11014. pr_debug("%s: priv->dai[%d].ch_mask = 0x%lx\n",
  11015. __func__, k, priv->dai[k].ch_mask);
  11016. if (test_and_clear_bit(bit,
  11017. &priv->dai[k].ch_mask)) {
  11018. cleared = true;
  11019. if (!priv->dai[k].ch_mask)
  11020. wake_up(&priv->dai[k].dai_wait);
  11021. /*
  11022. * There are cases when multiple DAIs
  11023. * might be using the same slimbus
  11024. * channel. Hence don't break here.
  11025. */
  11026. }
  11027. }
  11028. WARN(!cleared,
  11029. "Couldn't find slimbus %s port %d for closing\n",
  11030. (tx ? "TX" : "RX"), port_id);
  11031. }
  11032. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11033. TASHA_SLIM_PGD_PORT_INT_CLR_RX_0 +
  11034. (j / 8),
  11035. 1 << (j % 8));
  11036. }
  11037. return IRQ_HANDLED;
  11038. }
  11039. static int tasha_setup_irqs(struct tasha_priv *tasha)
  11040. {
  11041. int ret = 0;
  11042. struct snd_soc_codec *codec = tasha->codec;
  11043. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11044. struct wcd9xxx_core_resource *core_res =
  11045. &wcd9xxx->core_res;
  11046. ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS,
  11047. tasha_slimbus_irq, "SLIMBUS Slave", tasha);
  11048. if (ret)
  11049. pr_err("%s: Failed to request irq %d\n", __func__,
  11050. WCD9XXX_IRQ_SLIMBUS);
  11051. else
  11052. tasha_slim_interface_init_reg(codec);
  11053. return ret;
  11054. }
  11055. static void tasha_init_slim_slave_cfg(struct snd_soc_codec *codec)
  11056. {
  11057. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11058. struct afe_param_cdc_slimbus_slave_cfg *cfg;
  11059. struct wcd9xxx *wcd9xxx = priv->wcd9xxx;
  11060. uint64_t eaddr = 0;
  11061. cfg = &priv->slimbus_slave_cfg;
  11062. cfg->minor_version = 1;
  11063. cfg->tx_slave_port_offset = 0;
  11064. cfg->rx_slave_port_offset = 16;
  11065. memcpy(&eaddr, &wcd9xxx->slim->e_addr, sizeof(wcd9xxx->slim->e_addr));
  11066. WARN_ON(sizeof(wcd9xxx->slim->e_addr) != 6);
  11067. cfg->device_enum_addr_lsw = eaddr & 0xFFFFFFFF;
  11068. cfg->device_enum_addr_msw = eaddr >> 32;
  11069. dev_dbg(codec->dev, "%s: slimbus logical address 0x%llx\n",
  11070. __func__, eaddr);
  11071. }
  11072. static void tasha_cleanup_irqs(struct tasha_priv *tasha)
  11073. {
  11074. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11075. struct wcd9xxx_core_resource *core_res =
  11076. &wcd9xxx->core_res;
  11077. wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tasha);
  11078. }
  11079. static int tasha_handle_pdata(struct tasha_priv *tasha,
  11080. struct wcd9xxx_pdata *pdata)
  11081. {
  11082. struct snd_soc_codec *codec = tasha->codec;
  11083. u8 dmic_ctl_val, mad_dmic_ctl_val;
  11084. u8 anc_ctl_value;
  11085. u32 def_dmic_rate, dmic_clk_drv;
  11086. int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4;
  11087. int rc = 0;
  11088. if (!pdata) {
  11089. dev_err(codec->dev, "%s: NULL pdata\n", __func__);
  11090. return -ENODEV;
  11091. }
  11092. /* set micbias voltage */
  11093. vout_ctl_1 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb1_mv);
  11094. vout_ctl_2 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb2_mv);
  11095. vout_ctl_3 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb3_mv);
  11096. vout_ctl_4 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb4_mv);
  11097. if (vout_ctl_1 < 0 || vout_ctl_2 < 0 ||
  11098. vout_ctl_3 < 0 || vout_ctl_4 < 0) {
  11099. rc = -EINVAL;
  11100. goto done;
  11101. }
  11102. snd_soc_update_bits(codec, WCD9335_ANA_MICB1, 0x3F, vout_ctl_1);
  11103. snd_soc_update_bits(codec, WCD9335_ANA_MICB2, 0x3F, vout_ctl_2);
  11104. snd_soc_update_bits(codec, WCD9335_ANA_MICB3, 0x3F, vout_ctl_3);
  11105. snd_soc_update_bits(codec, WCD9335_ANA_MICB4, 0x3F, vout_ctl_4);
  11106. /* Set the DMIC sample rate */
  11107. switch (pdata->mclk_rate) {
  11108. case TASHA_MCLK_CLK_9P6MHZ:
  11109. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  11110. break;
  11111. case TASHA_MCLK_CLK_12P288MHZ:
  11112. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ;
  11113. break;
  11114. default:
  11115. /* should never happen */
  11116. dev_err(codec->dev, "%s: Invalid mclk_rate %d\n",
  11117. __func__, pdata->mclk_rate);
  11118. rc = -EINVAL;
  11119. goto done;
  11120. };
  11121. if (pdata->dmic_sample_rate ==
  11122. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11123. dev_info(codec->dev, "%s: dmic_rate invalid default = %d\n",
  11124. __func__, def_dmic_rate);
  11125. pdata->dmic_sample_rate = def_dmic_rate;
  11126. }
  11127. if (pdata->mad_dmic_sample_rate ==
  11128. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11129. dev_info(codec->dev, "%s: mad_dmic_rate invalid default = %d\n",
  11130. __func__, def_dmic_rate);
  11131. /*
  11132. * use dmic_sample_rate as the default for MAD
  11133. * if mad dmic sample rate is undefined
  11134. */
  11135. pdata->mad_dmic_sample_rate = pdata->dmic_sample_rate;
  11136. }
  11137. if (pdata->ecpp_dmic_sample_rate ==
  11138. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11139. dev_info(codec->dev,
  11140. "%s: ecpp_dmic_rate invalid default = %d\n",
  11141. __func__, def_dmic_rate);
  11142. /*
  11143. * use dmic_sample_rate as the default for ECPP DMIC
  11144. * if ecpp dmic sample rate is undefined
  11145. */
  11146. pdata->ecpp_dmic_sample_rate = pdata->dmic_sample_rate;
  11147. }
  11148. if (pdata->dmic_clk_drv ==
  11149. WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED) {
  11150. pdata->dmic_clk_drv = WCD9335_DMIC_CLK_DRIVE_DEFAULT;
  11151. dev_info(codec->dev,
  11152. "%s: dmic_clk_strength invalid, default = %d\n",
  11153. __func__, pdata->dmic_clk_drv);
  11154. }
  11155. switch (pdata->dmic_clk_drv) {
  11156. case 2:
  11157. dmic_clk_drv = 0;
  11158. break;
  11159. case 4:
  11160. dmic_clk_drv = 1;
  11161. break;
  11162. case 8:
  11163. dmic_clk_drv = 2;
  11164. break;
  11165. case 16:
  11166. dmic_clk_drv = 3;
  11167. break;
  11168. default:
  11169. dev_err(codec->dev,
  11170. "%s: invalid dmic_clk_drv %d, using default\n",
  11171. __func__, pdata->dmic_clk_drv);
  11172. dmic_clk_drv = 0;
  11173. break;
  11174. }
  11175. snd_soc_update_bits(codec, WCD9335_TEST_DEBUG_PAD_DRVCTL,
  11176. 0x0C, dmic_clk_drv << 2);
  11177. /*
  11178. * Default the DMIC clk rates to mad_dmic_sample_rate,
  11179. * whereas, the anc/txfe dmic rates to dmic_sample_rate
  11180. * since the anc/txfe are independent of mad block.
  11181. */
  11182. mad_dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11183. pdata->mclk_rate,
  11184. pdata->mad_dmic_sample_rate);
  11185. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC0_CTL,
  11186. 0x0E, mad_dmic_ctl_val << 1);
  11187. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC1_CTL,
  11188. 0x0E, mad_dmic_ctl_val << 1);
  11189. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC2_CTL,
  11190. 0x0E, mad_dmic_ctl_val << 1);
  11191. dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11192. pdata->mclk_rate,
  11193. pdata->dmic_sample_rate);
  11194. if (dmic_ctl_val == WCD9335_DMIC_CLK_DIV_2)
  11195. anc_ctl_value = WCD9335_ANC_DMIC_X2_FULL_RATE;
  11196. else
  11197. anc_ctl_value = WCD9335_ANC_DMIC_X2_HALF_RATE;
  11198. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11199. 0x40, anc_ctl_value << 6);
  11200. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11201. 0x20, anc_ctl_value << 5);
  11202. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11203. 0x40, anc_ctl_value << 6);
  11204. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11205. 0x20, anc_ctl_value << 5);
  11206. done:
  11207. return rc;
  11208. }
  11209. static struct wcd_cpe_core *tasha_codec_get_cpe_core(
  11210. struct snd_soc_codec *codec)
  11211. {
  11212. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11213. return priv->cpe_core;
  11214. }
  11215. static int tasha_codec_cpe_fll_update_divider(
  11216. struct snd_soc_codec *codec, u32 cpe_fll_rate)
  11217. {
  11218. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11219. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11220. u32 div_val = 0, l_val = 0;
  11221. u32 computed_cpe_fll;
  11222. if (cpe_fll_rate != CPE_FLL_CLK_75MHZ &&
  11223. cpe_fll_rate != CPE_FLL_CLK_150MHZ) {
  11224. dev_err(codec->dev,
  11225. "%s: Invalid CPE fll rate request %u\n",
  11226. __func__, cpe_fll_rate);
  11227. return -EINVAL;
  11228. }
  11229. if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_12P288MHZ) {
  11230. /* update divider to 10 and enable 5x divider */
  11231. snd_soc_write(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11232. 0x55);
  11233. div_val = 10;
  11234. } else if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_9P6MHZ) {
  11235. /* update divider to 8 and enable 2x divider */
  11236. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11237. 0x7C, 0x70);
  11238. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11239. 0xE0, 0x20);
  11240. div_val = 8;
  11241. } else {
  11242. dev_err(codec->dev,
  11243. "%s: Invalid MCLK rate %u\n",
  11244. __func__, wcd9xxx->mclk_rate);
  11245. return -EINVAL;
  11246. }
  11247. l_val = ((cpe_fll_rate / 1000) * div_val) /
  11248. (wcd9xxx->mclk_rate / 1000);
  11249. /* If l_val was integer truncated, increment l_val once */
  11250. computed_cpe_fll = (wcd9xxx->mclk_rate / div_val) * l_val;
  11251. if (computed_cpe_fll < cpe_fll_rate)
  11252. l_val++;
  11253. /* update L value LSB and MSB */
  11254. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_0,
  11255. (l_val & 0xFF));
  11256. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_1,
  11257. ((l_val >> 8) & 0xFF));
  11258. tasha->current_cpe_clk_freq = cpe_fll_rate;
  11259. dev_dbg(codec->dev,
  11260. "%s: updated l_val to %u for cpe_clk %u and mclk %u\n",
  11261. __func__, l_val, cpe_fll_rate, wcd9xxx->mclk_rate);
  11262. return 0;
  11263. }
  11264. static int __tasha_cdc_change_cpe_clk(struct snd_soc_codec *codec,
  11265. u32 clk_freq)
  11266. {
  11267. int ret = 0;
  11268. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11269. if (!tasha_cdc_is_svs_enabled(tasha)) {
  11270. dev_dbg(codec->dev,
  11271. "%s: SVS not enabled or tasha is not 2p0, return\n",
  11272. __func__);
  11273. return 0;
  11274. }
  11275. dev_dbg(codec->dev, "%s: clk_freq = %u\n", __func__, clk_freq);
  11276. if (clk_freq == CPE_FLL_CLK_75MHZ) {
  11277. /* Change to SVS */
  11278. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11279. 0x08, 0x08);
  11280. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11281. ret = -EINVAL;
  11282. goto done;
  11283. }
  11284. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11285. 0x10, 0x10);
  11286. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  11287. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  11288. } else if (clk_freq == CPE_FLL_CLK_150MHZ) {
  11289. /* change to nominal */
  11290. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11291. 0x08, 0x08);
  11292. set_bit(CPE_NOMINAL, &tasha->status_mask);
  11293. tasha_codec_update_sido_voltage(tasha, SIDO_VOLTAGE_NOMINAL_MV);
  11294. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11295. ret = -EINVAL;
  11296. goto done;
  11297. }
  11298. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11299. 0x10, 0x10);
  11300. } else {
  11301. dev_err(codec->dev,
  11302. "%s: Invalid clk_freq request %d for CPE FLL\n",
  11303. __func__, clk_freq);
  11304. ret = -EINVAL;
  11305. }
  11306. done:
  11307. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11308. 0x10, 0x00);
  11309. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11310. 0x08, 0x00);
  11311. return ret;
  11312. }
  11313. static int tasha_codec_cpe_fll_enable(struct snd_soc_codec *codec,
  11314. bool enable)
  11315. {
  11316. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11317. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11318. u8 clk_sel_reg_val = 0x00;
  11319. dev_dbg(codec->dev, "%s: enable = %s\n",
  11320. __func__, enable ? "true" : "false");
  11321. if (enable) {
  11322. if (tasha_cdc_is_svs_enabled(tasha)) {
  11323. /* FLL enable is always at SVS */
  11324. if (__tasha_cdc_change_cpe_clk(codec,
  11325. CPE_FLL_CLK_75MHZ)) {
  11326. dev_err(codec->dev,
  11327. "%s: clk change to %d failed\n",
  11328. __func__, CPE_FLL_CLK_75MHZ);
  11329. return -EINVAL;
  11330. }
  11331. } else {
  11332. if (tasha_codec_cpe_fll_update_divider(codec,
  11333. CPE_FLL_CLK_75MHZ)) {
  11334. dev_err(codec->dev,
  11335. "%s: clk change to %d failed\n",
  11336. __func__, CPE_FLL_CLK_75MHZ);
  11337. return -EINVAL;
  11338. }
  11339. }
  11340. if (TASHA_IS_1_0(wcd9xxx)) {
  11341. tasha_cdc_mclk_enable(codec, true, false);
  11342. clk_sel_reg_val = 0x02;
  11343. }
  11344. /* Setup CPE reference clk */
  11345. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11346. 0x02, clk_sel_reg_val);
  11347. /* enable CPE FLL reference clk */
  11348. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11349. 0x01, 0x01);
  11350. /* program the PLL */
  11351. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11352. 0x01, 0x01);
  11353. /* TEST clk setting */
  11354. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11355. 0x80, 0x80);
  11356. /* set FLL mode to HW controlled */
  11357. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11358. 0x60, 0x00);
  11359. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x80);
  11360. } else {
  11361. /* disable CPE FLL reference clk */
  11362. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11363. 0x01, 0x00);
  11364. /* undo TEST clk setting */
  11365. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11366. 0x80, 0x00);
  11367. /* undo FLL mode to HW control */
  11368. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x00);
  11369. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11370. 0x60, 0x20);
  11371. /* undo the PLL */
  11372. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11373. 0x01, 0x00);
  11374. if (TASHA_IS_1_0(wcd9xxx))
  11375. tasha_cdc_mclk_enable(codec, false, false);
  11376. /*
  11377. * FLL could get disabled while at nominal,
  11378. * scale it back to SVS
  11379. */
  11380. if (tasha_cdc_is_svs_enabled(tasha))
  11381. __tasha_cdc_change_cpe_clk(codec,
  11382. CPE_FLL_CLK_75MHZ);
  11383. }
  11384. return 0;
  11385. }
  11386. static void tasha_cdc_query_cpe_clk_plan(void *data,
  11387. struct cpe_svc_cfg_clk_plan *clk_freq)
  11388. {
  11389. struct snd_soc_codec *codec = data;
  11390. struct tasha_priv *tasha;
  11391. u32 cpe_clk_khz;
  11392. if (!codec) {
  11393. pr_err("%s: Invalid codec handle\n",
  11394. __func__);
  11395. return;
  11396. }
  11397. tasha = snd_soc_codec_get_drvdata(codec);
  11398. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11399. dev_dbg(codec->dev,
  11400. "%s: current_clk_freq = %u\n",
  11401. __func__, tasha->current_cpe_clk_freq);
  11402. clk_freq->current_clk_feq = cpe_clk_khz;
  11403. clk_freq->num_clk_freqs = 2;
  11404. if (tasha_cdc_is_svs_enabled(tasha)) {
  11405. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ / 1000;
  11406. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ / 1000;
  11407. } else {
  11408. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ;
  11409. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ;
  11410. }
  11411. }
  11412. static void tasha_cdc_change_cpe_clk(void *data,
  11413. u32 clk_freq)
  11414. {
  11415. struct snd_soc_codec *codec = data;
  11416. struct tasha_priv *tasha;
  11417. u32 cpe_clk_khz, req_freq = 0;
  11418. if (!codec) {
  11419. pr_err("%s: Invalid codec handle\n",
  11420. __func__);
  11421. return;
  11422. }
  11423. tasha = snd_soc_codec_get_drvdata(codec);
  11424. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11425. if (tasha_cdc_is_svs_enabled(tasha)) {
  11426. if ((clk_freq * 1000) <= CPE_FLL_CLK_75MHZ)
  11427. req_freq = CPE_FLL_CLK_75MHZ;
  11428. else
  11429. req_freq = CPE_FLL_CLK_150MHZ;
  11430. }
  11431. dev_dbg(codec->dev,
  11432. "%s: requested clk_freq = %u, current clk_freq = %u\n",
  11433. __func__, clk_freq * 1000,
  11434. tasha->current_cpe_clk_freq);
  11435. if (tasha_cdc_is_svs_enabled(tasha)) {
  11436. if (__tasha_cdc_change_cpe_clk(codec, req_freq))
  11437. dev_err(codec->dev,
  11438. "%s: clock/voltage scaling failed\n",
  11439. __func__);
  11440. }
  11441. }
  11442. static int tasha_codec_slim_reserve_bw(struct snd_soc_codec *codec,
  11443. u32 bw_ops, bool commit)
  11444. {
  11445. struct wcd9xxx *wcd9xxx;
  11446. if (!codec) {
  11447. pr_err("%s: Invalid handle to codec\n",
  11448. __func__);
  11449. return -EINVAL;
  11450. }
  11451. wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11452. if (!wcd9xxx) {
  11453. dev_err(codec->dev, "%s: Invalid parent drv_data\n",
  11454. __func__);
  11455. return -EINVAL;
  11456. }
  11457. return wcd9xxx_slim_reserve_bw(wcd9xxx, bw_ops, commit);
  11458. }
  11459. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  11460. bool vote)
  11461. {
  11462. u32 bw_ops;
  11463. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11464. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  11465. return 0;
  11466. mutex_lock(&tasha->sb_clk_gear_lock);
  11467. if (vote) {
  11468. tasha->ref_count++;
  11469. if (tasha->ref_count == 1) {
  11470. bw_ops = SLIM_BW_CLK_GEAR_9;
  11471. tasha_codec_slim_reserve_bw(codec,
  11472. bw_ops, true);
  11473. }
  11474. } else if (!vote && tasha->ref_count > 0) {
  11475. tasha->ref_count--;
  11476. if (tasha->ref_count == 0) {
  11477. bw_ops = SLIM_BW_UNVOTE;
  11478. tasha_codec_slim_reserve_bw(codec,
  11479. bw_ops, true);
  11480. }
  11481. };
  11482. dev_dbg(codec->dev, "%s Value of counter after vote or un-vote is %d\n",
  11483. __func__, tasha->ref_count);
  11484. mutex_unlock(&tasha->sb_clk_gear_lock);
  11485. return 0;
  11486. }
  11487. static int tasha_cpe_err_irq_control(struct snd_soc_codec *codec,
  11488. enum cpe_err_irq_cntl_type cntl_type, u8 *status)
  11489. {
  11490. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11491. u8 irq_bits;
  11492. if (TASHA_IS_2_0(tasha->wcd9xxx))
  11493. irq_bits = 0xFF;
  11494. else
  11495. irq_bits = 0x3F;
  11496. if (status)
  11497. irq_bits = (*status) & irq_bits;
  11498. switch (cntl_type) {
  11499. case CPE_ERR_IRQ_MASK:
  11500. snd_soc_update_bits(codec,
  11501. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11502. irq_bits, irq_bits);
  11503. break;
  11504. case CPE_ERR_IRQ_UNMASK:
  11505. snd_soc_update_bits(codec,
  11506. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11507. irq_bits, 0x00);
  11508. break;
  11509. case CPE_ERR_IRQ_CLEAR:
  11510. snd_soc_write(codec, WCD9335_CPE_SS_SS_ERROR_INT_CLEAR,
  11511. irq_bits);
  11512. break;
  11513. case CPE_ERR_IRQ_STATUS:
  11514. if (!status)
  11515. return -EINVAL;
  11516. *status = snd_soc_read(codec,
  11517. WCD9335_CPE_SS_SS_ERROR_INT_STATUS);
  11518. break;
  11519. }
  11520. return 0;
  11521. }
  11522. static const struct wcd_cpe_cdc_cb cpe_cb = {
  11523. .cdc_clk_en = tasha_codec_internal_rco_ctrl,
  11524. .cpe_clk_en = tasha_codec_cpe_fll_enable,
  11525. .get_afe_out_port_id = tasha_codec_get_mad_port_id,
  11526. .lab_cdc_ch_ctl = tasha_codec_enable_slimtx_mad,
  11527. .cdc_ext_clk = tasha_cdc_mclk_enable,
  11528. .bus_vote_bw = tasha_codec_vote_max_bw,
  11529. .cpe_err_irq_control = tasha_cpe_err_irq_control,
  11530. };
  11531. static struct cpe_svc_init_param cpe_svc_params = {
  11532. .version = CPE_SVC_INIT_PARAM_V1,
  11533. .query_freq_plans_cb = tasha_cdc_query_cpe_clk_plan,
  11534. .change_freq_plan_cb = tasha_cdc_change_cpe_clk,
  11535. };
  11536. static int tasha_cpe_initialize(struct snd_soc_codec *codec)
  11537. {
  11538. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11539. struct wcd_cpe_params cpe_params;
  11540. memset(&cpe_params, 0,
  11541. sizeof(struct wcd_cpe_params));
  11542. cpe_params.codec = codec;
  11543. cpe_params.get_cpe_core = tasha_codec_get_cpe_core;
  11544. cpe_params.cdc_cb = &cpe_cb;
  11545. cpe_params.dbg_mode = cpe_debug_mode;
  11546. cpe_params.cdc_major_ver = CPE_SVC_CODEC_WCD9335;
  11547. cpe_params.cdc_minor_ver = CPE_SVC_CODEC_V1P0;
  11548. cpe_params.cdc_id = CPE_SVC_CODEC_WCD9335;
  11549. cpe_params.cdc_irq_info.cpe_engine_irq =
  11550. WCD9335_IRQ_SVA_OUTBOX1;
  11551. cpe_params.cdc_irq_info.cpe_err_irq =
  11552. WCD9335_IRQ_SVA_ERROR;
  11553. cpe_params.cdc_irq_info.cpe_fatal_irqs =
  11554. TASHA_CPE_FATAL_IRQS;
  11555. cpe_svc_params.context = codec;
  11556. cpe_params.cpe_svc_params = &cpe_svc_params;
  11557. tasha->cpe_core = wcd_cpe_init("cpe_9335", codec,
  11558. &cpe_params);
  11559. if (IS_ERR_OR_NULL(tasha->cpe_core)) {
  11560. dev_err(codec->dev,
  11561. "%s: Failed to enable CPE\n",
  11562. __func__);
  11563. return -EINVAL;
  11564. }
  11565. return 0;
  11566. }
  11567. static const struct wcd_resmgr_cb tasha_resmgr_cb = {
  11568. .cdc_rco_ctrl = __tasha_codec_internal_rco_ctrl,
  11569. };
  11570. static int tasha_device_down(struct wcd9xxx *wcd9xxx)
  11571. {
  11572. struct snd_soc_codec *codec;
  11573. struct tasha_priv *priv;
  11574. int count;
  11575. int i = 0;
  11576. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11577. priv = snd_soc_codec_get_drvdata(codec);
  11578. wcd_cpe_ssr_event(priv->cpe_core, WCD_CPE_BUS_DOWN_EVENT);
  11579. for (i = 0; i < priv->nr; i++)
  11580. swrm_wcd_notify(priv->swr_ctrl_data[i].swr_pdev,
  11581. SWR_DEVICE_DOWN, NULL);
  11582. snd_soc_card_change_online_state(codec->component.card, 0);
  11583. for (count = 0; count < NUM_CODEC_DAIS; count++)
  11584. priv->dai[count].bus_down_in_recovery = true;
  11585. priv->resmgr->sido_input_src = SIDO_SOURCE_INTERNAL;
  11586. return 0;
  11587. }
  11588. static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx)
  11589. {
  11590. int i, ret = 0;
  11591. struct wcd9xxx *control;
  11592. struct snd_soc_codec *codec;
  11593. struct tasha_priv *tasha;
  11594. struct wcd9xxx_pdata *pdata;
  11595. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11596. tasha = snd_soc_codec_get_drvdata(codec);
  11597. control = dev_get_drvdata(codec->dev->parent);
  11598. wcd9xxx_set_power_state(tasha->wcd9xxx,
  11599. WCD_REGION_POWER_COLLAPSE_REMOVE,
  11600. WCD9XXX_DIG_CORE_REGION_1);
  11601. mutex_lock(&tasha->codec_mutex);
  11602. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11603. control->slim_slave->laddr;
  11604. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11605. control->slim->laddr;
  11606. tasha_init_slim_slave_cfg(codec);
  11607. if (tasha->machine_codec_event_cb)
  11608. tasha->machine_codec_event_cb(codec,
  11609. WCD9335_CODEC_EVENT_CODEC_UP);
  11610. snd_soc_card_change_online_state(codec->component.card, 1);
  11611. /* Class-H Init*/
  11612. wcd_clsh_init(&tasha->clsh_d);
  11613. for (i = 0; i < TASHA_MAX_MICBIAS; i++)
  11614. tasha->micb_ref[i] = 0;
  11615. tasha_update_reg_defaults(tasha);
  11616. tasha->codec = codec;
  11617. dev_dbg(codec->dev, "%s: MCLK Rate = %x\n",
  11618. __func__, control->mclk_rate);
  11619. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  11620. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11621. 0x03, 0x00);
  11622. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  11623. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11624. 0x03, 0x01);
  11625. tasha_codec_init_reg(codec);
  11626. wcd_resmgr_post_ssr_v2(tasha->resmgr);
  11627. tasha_enable_efuse_sensing(codec);
  11628. regcache_mark_dirty(codec->component.regmap);
  11629. regcache_sync(codec->component.regmap);
  11630. pdata = dev_get_platdata(codec->dev->parent);
  11631. ret = tasha_handle_pdata(tasha, pdata);
  11632. if (ret < 0)
  11633. dev_err(codec->dev, "%s: invalid pdata\n", __func__);
  11634. /* Reset reference counter for voting for max bw */
  11635. tasha->ref_count = 0;
  11636. /* MBHC Init */
  11637. wcd_mbhc_deinit(&tasha->mbhc);
  11638. tasha->mbhc_started = false;
  11639. /* Initialize MBHC module */
  11640. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11641. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11642. if (ret)
  11643. dev_err(codec->dev, "%s: mbhc initialization failed\n",
  11644. __func__);
  11645. else
  11646. tasha_mbhc_hs_detect(codec, tasha->mbhc.mbhc_cfg);
  11647. tasha_cleanup_irqs(tasha);
  11648. ret = tasha_setup_irqs(tasha);
  11649. if (ret) {
  11650. dev_err(codec->dev, "%s: tasha irq setup failed %d\n",
  11651. __func__, ret);
  11652. goto err;
  11653. }
  11654. tasha_set_spkr_mode(codec, tasha->spkr_mode);
  11655. wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT);
  11656. err:
  11657. mutex_unlock(&tasha->codec_mutex);
  11658. return ret;
  11659. }
  11660. static struct regulator *tasha_codec_find_ondemand_regulator(
  11661. struct snd_soc_codec *codec, const char *name)
  11662. {
  11663. int i;
  11664. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11665. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11666. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  11667. for (i = 0; i < wcd9xxx->num_of_supplies; ++i) {
  11668. if (pdata->regulator[i].ondemand &&
  11669. wcd9xxx->supplies[i].supply &&
  11670. !strcmp(wcd9xxx->supplies[i].supply, name))
  11671. return wcd9xxx->supplies[i].consumer;
  11672. }
  11673. dev_dbg(tasha->dev, "Warning: regulator not found:%s\n",
  11674. name);
  11675. return NULL;
  11676. }
  11677. static int tasha_codec_probe(struct snd_soc_codec *codec)
  11678. {
  11679. struct wcd9xxx *control;
  11680. struct tasha_priv *tasha;
  11681. struct wcd9xxx_pdata *pdata;
  11682. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  11683. int i, ret;
  11684. void *ptr = NULL;
  11685. struct regulator *supply;
  11686. control = dev_get_drvdata(codec->dev->parent);
  11687. dev_info(codec->dev, "%s()\n", __func__);
  11688. tasha = snd_soc_codec_get_drvdata(codec);
  11689. tasha->intf_type = wcd9xxx_get_intf_type();
  11690. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11691. control->dev_down = tasha_device_down;
  11692. control->post_reset = tasha_post_reset_cb;
  11693. control->ssr_priv = (void *)codec;
  11694. }
  11695. /* Resource Manager post Init */
  11696. ret = wcd_resmgr_post_init(tasha->resmgr, &tasha_resmgr_cb, codec);
  11697. if (ret) {
  11698. dev_err(codec->dev, "%s: wcd resmgr post init failed\n",
  11699. __func__);
  11700. goto err;
  11701. }
  11702. /* Class-H Init*/
  11703. wcd_clsh_init(&tasha->clsh_d);
  11704. /* Default HPH Mode to Class-H HiFi */
  11705. tasha->hph_mode = CLS_H_HIFI;
  11706. tasha->codec = codec;
  11707. for (i = 0; i < COMPANDER_MAX; i++)
  11708. tasha->comp_enabled[i] = 0;
  11709. tasha->spkr_gain_offset = RX_GAIN_OFFSET_0_DB;
  11710. tasha->intf_type = wcd9xxx_get_intf_type();
  11711. tasha_update_reg_reset_values(codec);
  11712. pr_debug("%s: MCLK Rate = %x\n", __func__, control->mclk_rate);
  11713. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  11714. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11715. 0x03, 0x00);
  11716. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  11717. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11718. 0x03, 0x01);
  11719. tasha_codec_init_reg(codec);
  11720. tasha_enable_efuse_sensing(codec);
  11721. pdata = dev_get_platdata(codec->dev->parent);
  11722. ret = tasha_handle_pdata(tasha, pdata);
  11723. if (ret < 0) {
  11724. pr_err("%s: bad pdata\n", __func__);
  11725. goto err;
  11726. }
  11727. supply = tasha_codec_find_ondemand_regulator(codec,
  11728. on_demand_supply_name[ON_DEMAND_MICBIAS]);
  11729. if (supply) {
  11730. tasha->on_demand_list[ON_DEMAND_MICBIAS].supply = supply;
  11731. tasha->on_demand_list[ON_DEMAND_MICBIAS].ondemand_supply_count =
  11732. 0;
  11733. }
  11734. tasha->fw_data = devm_kzalloc(codec->dev,
  11735. sizeof(*(tasha->fw_data)), GFP_KERNEL);
  11736. if (!tasha->fw_data)
  11737. goto err;
  11738. set_bit(WCD9XXX_ANC_CAL, tasha->fw_data->cal_bit);
  11739. set_bit(WCD9XXX_MBHC_CAL, tasha->fw_data->cal_bit);
  11740. set_bit(WCD9XXX_MAD_CAL, tasha->fw_data->cal_bit);
  11741. set_bit(WCD9XXX_VBAT_CAL, tasha->fw_data->cal_bit);
  11742. ret = wcd_cal_create_hwdep(tasha->fw_data,
  11743. WCD9XXX_CODEC_HWDEP_NODE, codec);
  11744. if (ret < 0) {
  11745. dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret);
  11746. goto err_hwdep;
  11747. }
  11748. /* Initialize MBHC module */
  11749. if (TASHA_IS_2_0(tasha->wcd9xxx)) {
  11750. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].reg =
  11751. WCD9335_MBHC_FSM_STATUS;
  11752. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].mask = 0x01;
  11753. }
  11754. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11755. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11756. if (ret) {
  11757. pr_err("%s: mbhc initialization failed\n", __func__);
  11758. goto err_hwdep;
  11759. }
  11760. ptr = devm_kzalloc(codec->dev, (sizeof(tasha_rx_chs) +
  11761. sizeof(tasha_tx_chs)), GFP_KERNEL);
  11762. if (!ptr) {
  11763. ret = -ENOMEM;
  11764. goto err_hwdep;
  11765. }
  11766. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  11767. snd_soc_dapm_new_controls(dapm, tasha_dapm_i2s_widgets,
  11768. ARRAY_SIZE(tasha_dapm_i2s_widgets));
  11769. snd_soc_dapm_add_routes(dapm, audio_i2s_map,
  11770. ARRAY_SIZE(audio_i2s_map));
  11771. for (i = 0; i < ARRAY_SIZE(tasha_i2s_dai); i++) {
  11772. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11773. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11774. }
  11775. } else if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11776. for (i = 0; i < NUM_CODEC_DAIS; i++) {
  11777. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11778. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11779. }
  11780. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11781. control->slim_slave->laddr;
  11782. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11783. control->slim->laddr;
  11784. tasha_slimbus_slave_port_cfg.slave_port_mapping[0] =
  11785. TASHA_TX13;
  11786. tasha_init_slim_slave_cfg(codec);
  11787. }
  11788. snd_soc_add_codec_controls(codec, impedance_detect_controls,
  11789. ARRAY_SIZE(impedance_detect_controls));
  11790. snd_soc_add_codec_controls(codec, hph_type_detect_controls,
  11791. ARRAY_SIZE(hph_type_detect_controls));
  11792. snd_soc_add_codec_controls(codec,
  11793. tasha_analog_gain_controls,
  11794. ARRAY_SIZE(tasha_analog_gain_controls));
  11795. control->num_rx_port = TASHA_RX_MAX;
  11796. control->rx_chs = ptr;
  11797. memcpy(control->rx_chs, tasha_rx_chs, sizeof(tasha_rx_chs));
  11798. control->num_tx_port = TASHA_TX_MAX;
  11799. control->tx_chs = ptr + sizeof(tasha_rx_chs);
  11800. memcpy(control->tx_chs, tasha_tx_chs, sizeof(tasha_tx_chs));
  11801. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Playback");
  11802. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Capture");
  11803. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Playback");
  11804. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Capture");
  11805. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11806. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Playback");
  11807. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Capture");
  11808. snd_soc_dapm_ignore_suspend(dapm, "AIF4 Playback");
  11809. snd_soc_dapm_ignore_suspend(dapm, "AIF Mix Playback");
  11810. snd_soc_dapm_ignore_suspend(dapm, "AIF4 MAD TX");
  11811. snd_soc_dapm_ignore_suspend(dapm, "VIfeed");
  11812. snd_soc_dapm_ignore_suspend(dapm, "AIF5 CPE TX");
  11813. }
  11814. snd_soc_dapm_sync(dapm);
  11815. ret = tasha_setup_irqs(tasha);
  11816. if (ret) {
  11817. pr_err("%s: tasha irq setup failed %d\n", __func__, ret);
  11818. goto err_pdata;
  11819. }
  11820. ret = tasha_cpe_initialize(codec);
  11821. if (ret) {
  11822. dev_err(codec->dev,
  11823. "%s: cpe initialization failed, err = %d\n",
  11824. __func__, ret);
  11825. /* Do not fail probe if CPE failed */
  11826. ret = 0;
  11827. }
  11828. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11829. tasha->tx_hpf_work[i].tasha = tasha;
  11830. tasha->tx_hpf_work[i].decimator = i;
  11831. INIT_DELAYED_WORK(&tasha->tx_hpf_work[i].dwork,
  11832. tasha_tx_hpf_corner_freq_callback);
  11833. }
  11834. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11835. tasha->tx_mute_dwork[i].tasha = tasha;
  11836. tasha->tx_mute_dwork[i].decimator = i;
  11837. INIT_DELAYED_WORK(&tasha->tx_mute_dwork[i].dwork,
  11838. tasha_tx_mute_update_callback);
  11839. }
  11840. tasha->spk_anc_dwork.tasha = tasha;
  11841. INIT_DELAYED_WORK(&tasha->spk_anc_dwork.dwork,
  11842. tasha_spk_anc_update_callback);
  11843. mutex_lock(&tasha->codec_mutex);
  11844. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  11845. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  11846. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  11847. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  11848. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  11849. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  11850. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  11851. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  11852. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  11853. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  11854. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  11855. mutex_unlock(&tasha->codec_mutex);
  11856. snd_soc_dapm_sync(dapm);
  11857. return ret;
  11858. err_pdata:
  11859. devm_kfree(codec->dev, ptr);
  11860. control->rx_chs = NULL;
  11861. control->tx_chs = NULL;
  11862. err_hwdep:
  11863. devm_kfree(codec->dev, tasha->fw_data);
  11864. tasha->fw_data = NULL;
  11865. err:
  11866. return ret;
  11867. }
  11868. static int tasha_codec_remove(struct snd_soc_codec *codec)
  11869. {
  11870. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11871. struct wcd9xxx *control;
  11872. control = dev_get_drvdata(codec->dev->parent);
  11873. control->num_rx_port = 0;
  11874. control->num_tx_port = 0;
  11875. control->rx_chs = NULL;
  11876. control->tx_chs = NULL;
  11877. tasha_cleanup_irqs(tasha);
  11878. /* Cleanup MBHC */
  11879. wcd_mbhc_deinit(&tasha->mbhc);
  11880. /* Cleanup resmgr */
  11881. return 0;
  11882. }
  11883. static struct regmap *tasha_get_regmap(struct device *dev)
  11884. {
  11885. struct wcd9xxx *control = dev_get_drvdata(dev->parent);
  11886. return control->regmap;
  11887. }
  11888. static struct snd_soc_codec_driver soc_codec_dev_tasha = {
  11889. .probe = tasha_codec_probe,
  11890. .remove = tasha_codec_remove,
  11891. .get_regmap = tasha_get_regmap,
  11892. .component_driver = {
  11893. .controls = tasha_snd_controls,
  11894. .num_controls = ARRAY_SIZE(tasha_snd_controls),
  11895. .dapm_widgets = tasha_dapm_widgets,
  11896. .num_dapm_widgets = ARRAY_SIZE(tasha_dapm_widgets),
  11897. .dapm_routes = audio_map,
  11898. .num_dapm_routes = ARRAY_SIZE(audio_map),
  11899. },
  11900. };
  11901. #ifdef CONFIG_PM
  11902. static int tasha_suspend(struct device *dev)
  11903. {
  11904. struct platform_device *pdev = to_platform_device(dev);
  11905. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  11906. dev_dbg(dev, "%s: system suspend\n", __func__);
  11907. if (cancel_delayed_work_sync(&tasha->power_gate_work))
  11908. tasha_codec_power_gate_digital_core(tasha);
  11909. return 0;
  11910. }
  11911. static int tasha_resume(struct device *dev)
  11912. {
  11913. struct platform_device *pdev = to_platform_device(dev);
  11914. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  11915. if (!tasha) {
  11916. dev_err(dev, "%s: tasha private data is NULL\n", __func__);
  11917. return -EINVAL;
  11918. }
  11919. dev_dbg(dev, "%s: system resume\n", __func__);
  11920. return 0;
  11921. }
  11922. static const struct dev_pm_ops tasha_pm_ops = {
  11923. .suspend = tasha_suspend,
  11924. .resume = tasha_resume,
  11925. };
  11926. #endif
  11927. static int tasha_swrm_read(void *handle, int reg)
  11928. {
  11929. struct tasha_priv *tasha;
  11930. struct wcd9xxx *wcd9xxx;
  11931. unsigned short swr_rd_addr_base;
  11932. unsigned short swr_rd_data_base;
  11933. int val, ret;
  11934. if (!handle) {
  11935. pr_err("%s: NULL handle\n", __func__);
  11936. return -EINVAL;
  11937. }
  11938. tasha = (struct tasha_priv *)handle;
  11939. wcd9xxx = tasha->wcd9xxx;
  11940. dev_dbg(tasha->dev, "%s: Reading soundwire register, 0x%x\n",
  11941. __func__, reg);
  11942. swr_rd_addr_base = WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0;
  11943. swr_rd_data_base = WCD9335_SWR_AHB_BRIDGE_RD_DATA_0;
  11944. /* read_lock */
  11945. mutex_lock(&tasha->swr_read_lock);
  11946. ret = regmap_bulk_write(wcd9xxx->regmap, swr_rd_addr_base,
  11947. (u8 *)&reg, 4);
  11948. if (ret < 0) {
  11949. pr_err("%s: RD Addr Failure\n", __func__);
  11950. goto err;
  11951. }
  11952. /* Check for RD status */
  11953. ret = regmap_bulk_read(wcd9xxx->regmap, swr_rd_data_base,
  11954. (u8 *)&val, 4);
  11955. if (ret < 0) {
  11956. pr_err("%s: RD Data Failure\n", __func__);
  11957. goto err;
  11958. }
  11959. ret = val;
  11960. err:
  11961. /* read_unlock */
  11962. mutex_unlock(&tasha->swr_read_lock);
  11963. return ret;
  11964. }
  11965. static int tasha_swrm_i2s_bulk_write(struct wcd9xxx *wcd9xxx,
  11966. struct wcd9xxx_reg_val *bulk_reg,
  11967. size_t len)
  11968. {
  11969. int i, ret = 0;
  11970. unsigned short swr_wr_addr_base;
  11971. unsigned short swr_wr_data_base;
  11972. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  11973. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  11974. for (i = 0; i < (len * 2); i += 2) {
  11975. /* First Write the Data to register */
  11976. ret = regmap_bulk_write(wcd9xxx->regmap,
  11977. swr_wr_data_base, bulk_reg[i].buf, 4);
  11978. if (ret < 0) {
  11979. dev_err(wcd9xxx->dev, "%s: WR Data Failure\n",
  11980. __func__);
  11981. break;
  11982. }
  11983. /* Next Write Address */
  11984. ret = regmap_bulk_write(wcd9xxx->regmap,
  11985. swr_wr_addr_base, bulk_reg[i+1].buf, 4);
  11986. if (ret < 0) {
  11987. dev_err(wcd9xxx->dev, "%s: WR Addr Failure\n",
  11988. __func__);
  11989. break;
  11990. }
  11991. }
  11992. return ret;
  11993. }
  11994. static int tasha_swrm_bulk_write(void *handle, u32 *reg, u32 *val, size_t len)
  11995. {
  11996. struct tasha_priv *tasha;
  11997. struct wcd9xxx *wcd9xxx;
  11998. struct wcd9xxx_reg_val *bulk_reg;
  11999. unsigned short swr_wr_addr_base;
  12000. unsigned short swr_wr_data_base;
  12001. int i, j, ret;
  12002. if (!handle) {
  12003. pr_err("%s: NULL handle\n", __func__);
  12004. return -EINVAL;
  12005. }
  12006. if (len <= 0) {
  12007. pr_err("%s: Invalid size: %zu\n", __func__, len);
  12008. return -EINVAL;
  12009. }
  12010. tasha = (struct tasha_priv *)handle;
  12011. wcd9xxx = tasha->wcd9xxx;
  12012. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12013. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12014. bulk_reg = kzalloc((2 * len * sizeof(struct wcd9xxx_reg_val)),
  12015. GFP_KERNEL);
  12016. if (!bulk_reg)
  12017. return -ENOMEM;
  12018. for (i = 0, j = 0; i < (len * 2); i += 2, j++) {
  12019. bulk_reg[i].reg = swr_wr_data_base;
  12020. bulk_reg[i].buf = (u8 *)(&val[j]);
  12021. bulk_reg[i].bytes = 4;
  12022. bulk_reg[i+1].reg = swr_wr_addr_base;
  12023. bulk_reg[i+1].buf = (u8 *)(&reg[j]);
  12024. bulk_reg[i+1].bytes = 4;
  12025. }
  12026. mutex_lock(&tasha->swr_write_lock);
  12027. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12028. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, len);
  12029. if (ret) {
  12030. dev_err(tasha->dev, "%s: i2s bulk write failed, ret: %d\n",
  12031. __func__, ret);
  12032. }
  12033. } else {
  12034. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg,
  12035. (len * 2), false);
  12036. if (ret) {
  12037. dev_err(tasha->dev, "%s: swrm bulk write failed, ret: %d\n",
  12038. __func__, ret);
  12039. }
  12040. }
  12041. mutex_unlock(&tasha->swr_write_lock);
  12042. kfree(bulk_reg);
  12043. return ret;
  12044. }
  12045. static int tasha_swrm_write(void *handle, int reg, int val)
  12046. {
  12047. struct tasha_priv *tasha;
  12048. struct wcd9xxx *wcd9xxx;
  12049. unsigned short swr_wr_addr_base;
  12050. unsigned short swr_wr_data_base;
  12051. struct wcd9xxx_reg_val bulk_reg[2];
  12052. int ret;
  12053. if (!handle) {
  12054. pr_err("%s: NULL handle\n", __func__);
  12055. return -EINVAL;
  12056. }
  12057. tasha = (struct tasha_priv *)handle;
  12058. wcd9xxx = tasha->wcd9xxx;
  12059. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12060. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12061. /* First Write the Data to register */
  12062. bulk_reg[0].reg = swr_wr_data_base;
  12063. bulk_reg[0].buf = (u8 *)(&val);
  12064. bulk_reg[0].bytes = 4;
  12065. bulk_reg[1].reg = swr_wr_addr_base;
  12066. bulk_reg[1].buf = (u8 *)(&reg);
  12067. bulk_reg[1].bytes = 4;
  12068. mutex_lock(&tasha->swr_write_lock);
  12069. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12070. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, 1);
  12071. if (ret) {
  12072. dev_err(tasha->dev, "%s: i2s swrm write failed, ret: %d\n",
  12073. __func__, ret);
  12074. }
  12075. } else {
  12076. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2, false);
  12077. if (ret < 0)
  12078. pr_err("%s: WR Data Failure\n", __func__);
  12079. }
  12080. mutex_unlock(&tasha->swr_write_lock);
  12081. return ret;
  12082. }
  12083. static int tasha_swrm_clock(void *handle, bool enable)
  12084. {
  12085. struct tasha_priv *tasha = (struct tasha_priv *) handle;
  12086. mutex_lock(&tasha->swr_clk_lock);
  12087. dev_dbg(tasha->dev, "%s: swrm clock %s\n",
  12088. __func__, (enable?"enable" : "disable"));
  12089. if (enable) {
  12090. tasha->swr_clk_users++;
  12091. if (tasha->swr_clk_users == 1) {
  12092. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12093. regmap_update_bits(
  12094. tasha->wcd9xxx->regmap,
  12095. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12096. 0x10, 0x00);
  12097. __tasha_cdc_mclk_enable(tasha, true);
  12098. regmap_update_bits(tasha->wcd9xxx->regmap,
  12099. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12100. 0x01, 0x01);
  12101. }
  12102. } else {
  12103. tasha->swr_clk_users--;
  12104. if (tasha->swr_clk_users == 0) {
  12105. regmap_update_bits(tasha->wcd9xxx->regmap,
  12106. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12107. 0x01, 0x00);
  12108. __tasha_cdc_mclk_enable(tasha, false);
  12109. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12110. regmap_update_bits(
  12111. tasha->wcd9xxx->regmap,
  12112. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12113. 0x10, 0x10);
  12114. }
  12115. }
  12116. dev_dbg(tasha->dev, "%s: swrm clock users %d\n",
  12117. __func__, tasha->swr_clk_users);
  12118. mutex_unlock(&tasha->swr_clk_lock);
  12119. return 0;
  12120. }
  12121. static int tasha_swrm_handle_irq(void *handle,
  12122. irqreturn_t (*swrm_irq_handler)(int irq,
  12123. void *data),
  12124. void *swrm_handle,
  12125. int action)
  12126. {
  12127. struct tasha_priv *tasha;
  12128. int ret = 0;
  12129. struct wcd9xxx *wcd9xxx;
  12130. if (!handle) {
  12131. pr_err("%s: null handle received\n", __func__);
  12132. return -EINVAL;
  12133. }
  12134. tasha = (struct tasha_priv *) handle;
  12135. wcd9xxx = tasha->wcd9xxx;
  12136. if (action) {
  12137. ret = wcd9xxx_request_irq(&wcd9xxx->core_res,
  12138. WCD9335_IRQ_SOUNDWIRE,
  12139. swrm_irq_handler,
  12140. "Tasha SWR Master", swrm_handle);
  12141. if (ret)
  12142. dev_err(tasha->dev, "%s: Failed to request irq %d\n",
  12143. __func__, WCD9335_IRQ_SOUNDWIRE);
  12144. } else
  12145. wcd9xxx_free_irq(&wcd9xxx->core_res, WCD9335_IRQ_SOUNDWIRE,
  12146. swrm_handle);
  12147. return ret;
  12148. }
  12149. static void tasha_add_child_devices(struct work_struct *work)
  12150. {
  12151. struct tasha_priv *tasha;
  12152. struct platform_device *pdev;
  12153. struct device_node *node;
  12154. struct wcd9xxx *wcd9xxx;
  12155. struct tasha_swr_ctrl_data *swr_ctrl_data = NULL, *temp;
  12156. int ret, ctrl_num = 0;
  12157. struct wcd_swr_ctrl_platform_data *platdata;
  12158. char plat_dev_name[WCD9335_STRING_LEN];
  12159. tasha = container_of(work, struct tasha_priv,
  12160. tasha_add_child_devices_work);
  12161. if (!tasha) {
  12162. pr_err("%s: Memory for WCD9335 does not exist\n",
  12163. __func__);
  12164. return;
  12165. }
  12166. wcd9xxx = tasha->wcd9xxx;
  12167. if (!wcd9xxx) {
  12168. pr_err("%s: Memory for WCD9XXX does not exist\n",
  12169. __func__);
  12170. return;
  12171. }
  12172. if (!wcd9xxx->dev->of_node) {
  12173. pr_err("%s: DT node for wcd9xxx does not exist\n",
  12174. __func__);
  12175. return;
  12176. }
  12177. platdata = &tasha->swr_plat_data;
  12178. tasha->child_count = 0;
  12179. for_each_child_of_node(wcd9xxx->dev->of_node, node) {
  12180. if (!strcmp(node->name, "swr_master"))
  12181. strlcpy(plat_dev_name, "tasha_swr_ctrl",
  12182. (WCD9335_STRING_LEN - 1));
  12183. else if (strnstr(node->name, "msm_cdc_pinctrl",
  12184. strlen("msm_cdc_pinctrl")) != NULL)
  12185. strlcpy(plat_dev_name, node->name,
  12186. (WCD9335_STRING_LEN - 1));
  12187. else
  12188. continue;
  12189. pdev = platform_device_alloc(plat_dev_name, -1);
  12190. if (!pdev) {
  12191. dev_err(wcd9xxx->dev, "%s: pdev memory alloc failed\n",
  12192. __func__);
  12193. ret = -ENOMEM;
  12194. goto err;
  12195. }
  12196. pdev->dev.parent = tasha->dev;
  12197. pdev->dev.of_node = node;
  12198. if (!strcmp(node->name, "swr_master")) {
  12199. ret = platform_device_add_data(pdev, platdata,
  12200. sizeof(*platdata));
  12201. if (ret) {
  12202. dev_err(&pdev->dev,
  12203. "%s: cannot add plat data ctrl:%d\n",
  12204. __func__, ctrl_num);
  12205. goto fail_pdev_add;
  12206. }
  12207. }
  12208. ret = platform_device_add(pdev);
  12209. if (ret) {
  12210. dev_err(&pdev->dev,
  12211. "%s: Cannot add platform device\n",
  12212. __func__);
  12213. goto fail_pdev_add;
  12214. }
  12215. if (!strcmp(node->name, "swr_master")) {
  12216. temp = krealloc(swr_ctrl_data,
  12217. (ctrl_num + 1) * sizeof(
  12218. struct tasha_swr_ctrl_data),
  12219. GFP_KERNEL);
  12220. if (!temp) {
  12221. dev_err(wcd9xxx->dev, "out of memory\n");
  12222. ret = -ENOMEM;
  12223. goto err;
  12224. }
  12225. swr_ctrl_data = temp;
  12226. swr_ctrl_data[ctrl_num].swr_pdev = pdev;
  12227. ctrl_num++;
  12228. dev_dbg(&pdev->dev,
  12229. "%s: Added soundwire ctrl device(s)\n",
  12230. __func__);
  12231. tasha->nr = ctrl_num;
  12232. tasha->swr_ctrl_data = swr_ctrl_data;
  12233. }
  12234. if (tasha->child_count < WCD9335_CHILD_DEVICES_MAX)
  12235. tasha->pdev_child_devices[tasha->child_count++] = pdev;
  12236. else
  12237. goto err;
  12238. }
  12239. return;
  12240. fail_pdev_add:
  12241. platform_device_put(pdev);
  12242. err:
  12243. return;
  12244. }
  12245. /*
  12246. * tasha_codec_ver: to get tasha codec version
  12247. * @codec: handle to snd_soc_codec *
  12248. * return enum codec_variant - version
  12249. */
  12250. enum codec_variant tasha_codec_ver(void)
  12251. {
  12252. return codec_ver;
  12253. }
  12254. EXPORT_SYMBOL(tasha_codec_ver);
  12255. static int __tasha_enable_efuse_sensing(struct tasha_priv *tasha)
  12256. {
  12257. int val, rc;
  12258. __tasha_cdc_mclk_enable(tasha, true);
  12259. regmap_update_bits(tasha->wcd9xxx->regmap,
  12260. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x1E, 0x20);
  12261. regmap_update_bits(tasha->wcd9xxx->regmap,
  12262. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x01, 0x01);
  12263. /*
  12264. * 5ms sleep required after enabling efuse control
  12265. * before checking the status.
  12266. */
  12267. usleep_range(5000, 5500);
  12268. rc = regmap_read(tasha->wcd9xxx->regmap,
  12269. WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS, &val);
  12270. if (rc || (!(val & 0x01)))
  12271. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  12272. __tasha_cdc_mclk_enable(tasha, false);
  12273. return rc;
  12274. }
  12275. void tasha_get_codec_ver(struct tasha_priv *tasha)
  12276. {
  12277. int i;
  12278. int val;
  12279. struct tasha_reg_mask_val codec_reg[] = {
  12280. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10, 0xFF, 0xFF},
  12281. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11, 0xFF, 0x83},
  12282. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12, 0xFF, 0x0A},
  12283. };
  12284. __tasha_enable_efuse_sensing(tasha);
  12285. for (i = 0; i < ARRAY_SIZE(codec_reg); i++) {
  12286. regmap_read(tasha->wcd9xxx->regmap, codec_reg[i].reg, &val);
  12287. if (!(val && codec_reg[i].val)) {
  12288. codec_ver = WCD9335;
  12289. goto ret;
  12290. }
  12291. }
  12292. codec_ver = WCD9326;
  12293. ret:
  12294. pr_debug("%s: codec is %d\n", __func__, codec_ver);
  12295. }
  12296. EXPORT_SYMBOL(tasha_get_codec_ver);
  12297. static int tasha_probe(struct platform_device *pdev)
  12298. {
  12299. int ret = 0;
  12300. struct tasha_priv *tasha;
  12301. struct clk *wcd_ext_clk, *wcd_native_clk;
  12302. struct wcd9xxx_resmgr_v2 *resmgr;
  12303. struct wcd9xxx_power_region *cdc_pwr;
  12304. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12305. if (apr_get_subsys_state() == APR_SUBSYS_DOWN) {
  12306. dev_err(&pdev->dev, "%s: dsp down\n", __func__);
  12307. return -EPROBE_DEFER;
  12308. }
  12309. }
  12310. tasha = devm_kzalloc(&pdev->dev, sizeof(struct tasha_priv),
  12311. GFP_KERNEL);
  12312. if (!tasha)
  12313. return -ENOMEM;
  12314. platform_set_drvdata(pdev, tasha);
  12315. tasha->wcd9xxx = dev_get_drvdata(pdev->dev.parent);
  12316. tasha->dev = &pdev->dev;
  12317. INIT_DELAYED_WORK(&tasha->power_gate_work, tasha_codec_power_gate_work);
  12318. mutex_init(&tasha->power_lock);
  12319. mutex_init(&tasha->sido_lock);
  12320. INIT_WORK(&tasha->tasha_add_child_devices_work,
  12321. tasha_add_child_devices);
  12322. BLOCKING_INIT_NOTIFIER_HEAD(&tasha->notifier);
  12323. mutex_init(&tasha->micb_lock);
  12324. mutex_init(&tasha->swr_read_lock);
  12325. mutex_init(&tasha->swr_write_lock);
  12326. mutex_init(&tasha->swr_clk_lock);
  12327. mutex_init(&tasha->sb_clk_gear_lock);
  12328. mutex_init(&tasha->mclk_lock);
  12329. cdc_pwr = devm_kzalloc(&pdev->dev, sizeof(struct wcd9xxx_power_region),
  12330. GFP_KERNEL);
  12331. if (!cdc_pwr) {
  12332. ret = -ENOMEM;
  12333. goto err_cdc_pwr;
  12334. }
  12335. tasha->wcd9xxx->wcd9xxx_pwr[WCD9XXX_DIG_CORE_REGION_1] = cdc_pwr;
  12336. cdc_pwr->pwr_collapse_reg_min = TASHA_DIG_CORE_REG_MIN;
  12337. cdc_pwr->pwr_collapse_reg_max = TASHA_DIG_CORE_REG_MAX;
  12338. wcd9xxx_set_power_state(tasha->wcd9xxx,
  12339. WCD_REGION_POWER_COLLAPSE_REMOVE,
  12340. WCD9XXX_DIG_CORE_REGION_1);
  12341. mutex_init(&tasha->codec_mutex);
  12342. /*
  12343. * Init resource manager so that if child nodes such as SoundWire
  12344. * requests for clock, resource manager can honor the request
  12345. */
  12346. resmgr = wcd_resmgr_init(&tasha->wcd9xxx->core_res, NULL);
  12347. if (IS_ERR(resmgr)) {
  12348. ret = PTR_ERR(resmgr);
  12349. dev_err(&pdev->dev, "%s: Failed to initialize wcd resmgr\n",
  12350. __func__);
  12351. goto err_resmgr;
  12352. }
  12353. tasha->resmgr = resmgr;
  12354. tasha->swr_plat_data.handle = (void *) tasha;
  12355. tasha->swr_plat_data.read = tasha_swrm_read;
  12356. tasha->swr_plat_data.write = tasha_swrm_write;
  12357. tasha->swr_plat_data.bulk_write = tasha_swrm_bulk_write;
  12358. tasha->swr_plat_data.clk = tasha_swrm_clock;
  12359. tasha->swr_plat_data.handle_irq = tasha_swrm_handle_irq;
  12360. /* Register for Clock */
  12361. wcd_ext_clk = clk_get(tasha->wcd9xxx->dev, "wcd_clk");
  12362. if (IS_ERR(wcd_ext_clk)) {
  12363. dev_err(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12364. __func__, "wcd_ext_clk");
  12365. goto err_clk;
  12366. }
  12367. tasha->wcd_ext_clk = wcd_ext_clk;
  12368. tasha->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV;
  12369. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  12370. tasha->sido_ccl_cnt = 0;
  12371. /* Register native clk for 44.1 playback */
  12372. wcd_native_clk = clk_get(tasha->wcd9xxx->dev, "wcd_native_clk");
  12373. if (IS_ERR(wcd_native_clk))
  12374. dev_dbg(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12375. __func__, "wcd_native_clk");
  12376. else
  12377. tasha->wcd_native_clk = wcd_native_clk;
  12378. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  12379. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12380. tasha_dai, ARRAY_SIZE(tasha_dai));
  12381. else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
  12382. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12383. tasha_i2s_dai,
  12384. ARRAY_SIZE(tasha_i2s_dai));
  12385. else
  12386. ret = -EINVAL;
  12387. if (ret) {
  12388. dev_err(&pdev->dev, "%s: Codec registration failed, ret = %d\n",
  12389. __func__, ret);
  12390. goto err_cdc_reg;
  12391. }
  12392. /* Update codec register default values */
  12393. tasha_update_reg_defaults(tasha);
  12394. schedule_work(&tasha->tasha_add_child_devices_work);
  12395. tasha_get_codec_ver(tasha);
  12396. dev_info(&pdev->dev, "%s: Tasha driver probe done\n", __func__);
  12397. return ret;
  12398. err_cdc_reg:
  12399. clk_put(tasha->wcd_ext_clk);
  12400. if (tasha->wcd_native_clk)
  12401. clk_put(tasha->wcd_native_clk);
  12402. err_clk:
  12403. wcd_resmgr_remove(tasha->resmgr);
  12404. err_resmgr:
  12405. devm_kfree(&pdev->dev, cdc_pwr);
  12406. err_cdc_pwr:
  12407. mutex_destroy(&tasha->mclk_lock);
  12408. devm_kfree(&pdev->dev, tasha);
  12409. return ret;
  12410. }
  12411. static int tasha_remove(struct platform_device *pdev)
  12412. {
  12413. struct tasha_priv *tasha;
  12414. int count = 0;
  12415. tasha = platform_get_drvdata(pdev);
  12416. if (!tasha)
  12417. return -EINVAL;
  12418. for (count = 0; count < tasha->child_count &&
  12419. count < WCD9335_CHILD_DEVICES_MAX; count++)
  12420. platform_device_unregister(tasha->pdev_child_devices[count]);
  12421. mutex_destroy(&tasha->codec_mutex);
  12422. clk_put(tasha->wcd_ext_clk);
  12423. if (tasha->wcd_native_clk)
  12424. clk_put(tasha->wcd_native_clk);
  12425. mutex_destroy(&tasha->mclk_lock);
  12426. mutex_destroy(&tasha->sb_clk_gear_lock);
  12427. snd_soc_unregister_codec(&pdev->dev);
  12428. devm_kfree(&pdev->dev, tasha);
  12429. return 0;
  12430. }
  12431. static struct platform_driver tasha_codec_driver = {
  12432. .probe = tasha_probe,
  12433. .remove = tasha_remove,
  12434. .driver = {
  12435. .name = "tasha_codec",
  12436. .owner = THIS_MODULE,
  12437. #ifdef CONFIG_PM
  12438. .pm = &tasha_pm_ops,
  12439. #endif
  12440. },
  12441. };
  12442. module_platform_driver(tasha_codec_driver);
  12443. MODULE_DESCRIPTION("Tasha Codec driver");
  12444. MODULE_LICENSE("GPL v2");