wcd9335.c 440 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351
  1. /*
  2. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/init.h>
  15. #include <linux/firmware.h>
  16. #include <linux/slab.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/device.h>
  19. #include <linux/printk.h>
  20. #include <linux/ratelimit.h>
  21. #include <linux/debugfs.h>
  22. #include <linux/wait.h>
  23. #include <linux/bitops.h>
  24. #include <linux/regmap.h>
  25. #include <linux/regulator/consumer.h>
  26. #include <linux/clk.h>
  27. #include <linux/delay.h>
  28. #include <linux/pm_runtime.h>
  29. #include <linux/kernel.h>
  30. #include <linux/gpio.h>
  31. #include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
  32. #include <soc/swr-wcd.h>
  33. #include <sound/pcm.h>
  34. #include <sound/pcm_params.h>
  35. #include <sound/soc.h>
  36. #include <sound/soc-dapm.h>
  37. #include <sound/tlv.h>
  38. #include <sound/info.h>
  39. #include "core.h"
  40. #include "pdata.h"
  41. #include "wcd9335.h"
  42. #include "wcd-mbhc-v2.h"
  43. #include "wcd9xxx-common-v2.h"
  44. #include "wcd9xxx-resmgr-v2.h"
  45. #include "wcd9xxx-irq.h"
  46. #include "wcd9335_registers.h"
  47. #include "wcd9335_irq.h"
  48. #include "wcd_cpe_core.h"
  49. #include "wcdcal-hwdep.h"
  50. #include "wcd-mbhc-v2-api.h"
  51. #define TASHA_RX_PORT_START_NUMBER 16
  52. #define WCD9335_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
  53. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
  54. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  55. /* Fractional Rates */
  56. #define WCD9335_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100)
  57. #define WCD9335_MIX_RATES_MASK (SNDRV_PCM_RATE_48000 |\
  58. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  59. #define TASHA_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  60. SNDRV_PCM_FMTBIT_S24_LE | \
  61. SNDRV_PCM_FMTBIT_S24_3LE)
  62. #define TASHA_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  63. SNDRV_PCM_FMTBIT_S24_LE | \
  64. SNDRV_PCM_FMTBIT_S24_3LE | \
  65. SNDRV_PCM_FMTBIT_S32_LE)
  66. #define TASHA_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
  67. /*
  68. * Timeout in milli seconds and it is the wait time for
  69. * slim channel removal interrupt to receive.
  70. */
  71. #define TASHA_SLIM_CLOSE_TIMEOUT 1000
  72. #define TASHA_SLIM_IRQ_OVERFLOW (1 << 0)
  73. #define TASHA_SLIM_IRQ_UNDERFLOW (1 << 1)
  74. #define TASHA_SLIM_IRQ_PORT_CLOSED (1 << 2)
  75. #define TASHA_MCLK_CLK_12P288MHZ 12288000
  76. #define TASHA_MCLK_CLK_9P6MHZ 9600000
  77. #define TASHA_SLIM_PGD_PORT_INT_TX_EN0 (TASHA_SLIM_PGD_PORT_INT_EN0 + 2)
  78. #define TASHA_NUM_INTERPOLATORS 9
  79. #define TASHA_NUM_DECIMATORS 9
  80. #define WCD9335_CHILD_DEVICES_MAX 6
  81. #define BYTE_BIT_MASK(nr) (1 << ((nr) % BITS_PER_BYTE))
  82. #define TASHA_MAD_AUDIO_FIRMWARE_PATH "wcd9335/wcd9335_mad_audio.bin"
  83. #define TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS (1 << 0)
  84. #define TASHA_CPE_SS_ERR_STATUS_WDOG_BITE (1 << 1)
  85. #define TASHA_CPE_FATAL_IRQS \
  86. (TASHA_CPE_SS_ERR_STATUS_WDOG_BITE | \
  87. TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS)
  88. #define SLIM_BW_CLK_GEAR_9 6200000
  89. #define SLIM_BW_UNVOTE 0
  90. #define CPE_FLL_CLK_75MHZ 75000000
  91. #define CPE_FLL_CLK_150MHZ 150000000
  92. #define WCD9335_REG_BITS 8
  93. #define WCD9335_MAX_VALID_ADC_MUX 13
  94. #define WCD9335_INVALID_ADC_MUX 9
  95. #define TASHA_DIG_CORE_REG_MIN WCD9335_CDC_ANC0_CLK_RESET_CTL
  96. #define TASHA_DIG_CORE_REG_MAX 0xDFF
  97. /* Convert from vout ctl to micbias voltage in mV */
  98. #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
  99. #define TASHA_ZDET_NUM_MEASUREMENTS 900
  100. #define TASHA_MBHC_GET_C1(c) ((c & 0xC000) >> 14)
  101. #define TASHA_MBHC_GET_X1(x) (x & 0x3FFF)
  102. /* z value compared in milliOhm */
  103. #define TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000))
  104. #define TASHA_MBHC_ZDET_CONST (86 * 16384)
  105. #define TASHA_MBHC_MOISTURE_VREF V_45_MV
  106. #define TASHA_MBHC_MOISTURE_IREF I_3P0_UA
  107. #define TASHA_VERSION_ENTRY_SIZE 17
  108. #define WCD9335_AMIC_PWR_LEVEL_LP 0
  109. #define WCD9335_AMIC_PWR_LEVEL_DEFAULT 1
  110. #define WCD9335_AMIC_PWR_LEVEL_HP 2
  111. #define WCD9335_AMIC_PWR_LVL_MASK 0x60
  112. #define WCD9335_AMIC_PWR_LVL_SHIFT 0x5
  113. #define WCD9335_DEC_PWR_LVL_MASK 0x06
  114. #define WCD9335_DEC_PWR_LVL_LP 0x02
  115. #define WCD9335_DEC_PWR_LVL_HP 0x04
  116. #define WCD9335_DEC_PWR_LVL_DF 0x00
  117. #define WCD9335_STRING_LEN 100
  118. #define CALCULATE_VOUT_D(req_mv) (((req_mv - 650) * 10) / 25)
  119. static int cpe_debug_mode;
  120. #define TASHA_MAX_MICBIAS 4
  121. #define DAPM_MICBIAS1_STANDALONE "MIC BIAS1 Standalone"
  122. #define DAPM_MICBIAS2_STANDALONE "MIC BIAS2 Standalone"
  123. #define DAPM_MICBIAS3_STANDALONE "MIC BIAS3 Standalone"
  124. #define DAPM_MICBIAS4_STANDALONE "MIC BIAS4 Standalone"
  125. #define DAPM_LDO_H_STANDALONE "LDO_H"
  126. module_param(cpe_debug_mode, int, 0664);
  127. MODULE_PARM_DESC(cpe_debug_mode, "boot cpe in debug mode");
  128. #define TASHA_DIG_CORE_COLLAPSE_TIMER_MS (5 * 1000)
  129. #define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH 64
  130. static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = {
  131. "cdc-vdd-mic-bias",
  132. };
  133. enum {
  134. POWER_COLLAPSE,
  135. POWER_RESUME,
  136. };
  137. enum tasha_sido_voltage {
  138. SIDO_VOLTAGE_SVS_MV = 950,
  139. SIDO_VOLTAGE_NOMINAL_MV = 1100,
  140. };
  141. static enum codec_variant codec_ver;
  142. static int dig_core_collapse_enable = 1;
  143. module_param(dig_core_collapse_enable, int, 0664);
  144. MODULE_PARM_DESC(dig_core_collapse_enable, "enable/disable power gating");
  145. /* dig_core_collapse timer in seconds */
  146. static int dig_core_collapse_timer = (TASHA_DIG_CORE_COLLAPSE_TIMER_MS/1000);
  147. module_param(dig_core_collapse_timer, int, 0664);
  148. MODULE_PARM_DESC(dig_core_collapse_timer, "timer for power gating");
  149. /* SVS Scaling enable/disable */
  150. static int svs_scaling_enabled = 1;
  151. module_param(svs_scaling_enabled, int, 0664);
  152. MODULE_PARM_DESC(svs_scaling_enabled, "enable/disable svs scaling");
  153. /* SVS buck setting */
  154. static int sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  155. module_param(sido_buck_svs_voltage, int, 0664);
  156. MODULE_PARM_DESC(sido_buck_svs_voltage,
  157. "setting for SVS voltage for SIDO BUCK");
  158. #define TASHA_TX_UNMUTE_DELAY_MS 40
  159. static int tx_unmute_delay = TASHA_TX_UNMUTE_DELAY_MS;
  160. module_param(tx_unmute_delay, int, 0664);
  161. MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path");
  162. static struct afe_param_slimbus_slave_port_cfg tasha_slimbus_slave_port_cfg = {
  163. .minor_version = 1,
  164. .slimbus_dev_id = AFE_SLIMBUS_DEVICE_1,
  165. .slave_dev_pgd_la = 0,
  166. .slave_dev_intfdev_la = 0,
  167. .bit_width = 16,
  168. .data_format = 0,
  169. .num_channels = 1
  170. };
  171. struct tasha_mbhc_zdet_param {
  172. u16 ldo_ctl;
  173. u16 noff;
  174. u16 nshift;
  175. u16 btn5;
  176. u16 btn6;
  177. u16 btn7;
  178. };
  179. static struct afe_param_cdc_reg_page_cfg tasha_cdc_reg_page_cfg = {
  180. .minor_version = AFE_API_VERSION_CDC_REG_PAGE_CFG,
  181. .enable = 1,
  182. .proc_id = AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_1,
  183. };
  184. static struct afe_param_cdc_reg_cfg audio_reg_cfg[] = {
  185. {
  186. 1,
  187. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_MAIN_CTL_1),
  188. HW_MAD_AUDIO_ENABLE, 0x1, WCD9335_REG_BITS, 0
  189. },
  190. {
  191. 1,
  192. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_3),
  193. HW_MAD_AUDIO_SLEEP_TIME, 0xF, WCD9335_REG_BITS, 0
  194. },
  195. {
  196. 1,
  197. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_4),
  198. HW_MAD_TX_AUDIO_SWITCH_OFF, 0x1, WCD9335_REG_BITS, 0
  199. },
  200. {
  201. 1,
  202. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  203. MAD_AUDIO_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  204. },
  205. {
  206. 1,
  207. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  208. MAD_AUDIO_INT_MASK_REG, 0x1, WCD9335_REG_BITS, 0
  209. },
  210. {
  211. 1,
  212. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  213. MAD_AUDIO_INT_STATUS_REG, 0x1, WCD9335_REG_BITS, 0
  214. },
  215. {
  216. 1,
  217. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  218. MAD_AUDIO_INT_CLEAR_REG, 0x1, WCD9335_REG_BITS, 0
  219. },
  220. {
  221. 1,
  222. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  223. VBAT_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  224. },
  225. {
  226. 1,
  227. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  228. VBAT_INT_MASK_REG, 0x08, WCD9335_REG_BITS, 0
  229. },
  230. {
  231. 1,
  232. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  233. VBAT_INT_STATUS_REG, 0x08, WCD9335_REG_BITS, 0
  234. },
  235. {
  236. 1,
  237. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  238. VBAT_INT_CLEAR_REG, 0x08, WCD9335_REG_BITS, 0
  239. },
  240. {
  241. 1,
  242. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  243. VBAT_RELEASE_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  244. },
  245. {
  246. 1,
  247. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  248. VBAT_RELEASE_INT_MASK_REG, 0x10, WCD9335_REG_BITS, 0
  249. },
  250. {
  251. 1,
  252. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  253. VBAT_RELEASE_INT_STATUS_REG, 0x10, WCD9335_REG_BITS, 0
  254. },
  255. {
  256. 1,
  257. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  258. VBAT_RELEASE_INT_CLEAR_REG, 0x10, WCD9335_REG_BITS, 0
  259. },
  260. {
  261. 1,
  262. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  263. SB_PGD_PORT_TX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  264. },
  265. {
  266. 1,
  267. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  268. SB_PGD_PORT_TX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  269. },
  270. {
  271. 1,
  272. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  273. SB_PGD_PORT_RX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  274. },
  275. {
  276. 1,
  277. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  278. SB_PGD_PORT_RX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  279. },
  280. { 1,
  281. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  282. AANC_FF_GAIN_ADAPTIVE, 0x4, WCD9335_REG_BITS, 0
  283. },
  284. { 1,
  285. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  286. AANC_FFGAIN_ADAPTIVE_EN, 0x8, WCD9335_REG_BITS, 0
  287. },
  288. {
  289. 1,
  290. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_FF_A_GAIN_CTL),
  291. AANC_GAIN_CONTROL, 0xFF, WCD9335_REG_BITS, 0
  292. },
  293. };
  294. static struct afe_param_cdc_reg_cfg_data tasha_audio_reg_cfg = {
  295. .num_registers = ARRAY_SIZE(audio_reg_cfg),
  296. .reg_data = audio_reg_cfg,
  297. };
  298. static struct afe_param_id_cdc_aanc_version tasha_cdc_aanc_version = {
  299. .cdc_aanc_minor_version = AFE_API_VERSION_CDC_AANC_VERSION,
  300. .aanc_hw_version = AANC_HW_BLOCK_VERSION_2,
  301. };
  302. enum {
  303. VI_SENSE_1,
  304. VI_SENSE_2,
  305. AIF4_SWITCH_VALUE,
  306. AUDIO_NOMINAL,
  307. CPE_NOMINAL,
  308. HPH_PA_DELAY,
  309. ANC_MIC_AMIC1,
  310. ANC_MIC_AMIC2,
  311. ANC_MIC_AMIC3,
  312. ANC_MIC_AMIC4,
  313. ANC_MIC_AMIC5,
  314. ANC_MIC_AMIC6,
  315. CLASSH_CONFIG,
  316. };
  317. enum {
  318. AIF1_PB = 0,
  319. AIF1_CAP,
  320. AIF2_PB,
  321. AIF2_CAP,
  322. AIF3_PB,
  323. AIF3_CAP,
  324. AIF4_PB,
  325. AIF_MIX1_PB,
  326. AIF4_MAD_TX,
  327. AIF4_VIFEED,
  328. AIF5_CPE_TX,
  329. NUM_CODEC_DAIS,
  330. };
  331. enum {
  332. INTn_1_MIX_INP_SEL_ZERO = 0,
  333. INTn_1_MIX_INP_SEL_DEC0,
  334. INTn_1_MIX_INP_SEL_DEC1,
  335. INTn_1_MIX_INP_SEL_IIR0,
  336. INTn_1_MIX_INP_SEL_IIR1,
  337. INTn_1_MIX_INP_SEL_RX0,
  338. INTn_1_MIX_INP_SEL_RX1,
  339. INTn_1_MIX_INP_SEL_RX2,
  340. INTn_1_MIX_INP_SEL_RX3,
  341. INTn_1_MIX_INP_SEL_RX4,
  342. INTn_1_MIX_INP_SEL_RX5,
  343. INTn_1_MIX_INP_SEL_RX6,
  344. INTn_1_MIX_INP_SEL_RX7,
  345. };
  346. #define IS_VALID_NATIVE_FIFO_PORT(inp) \
  347. ((inp >= INTn_1_MIX_INP_SEL_RX0) && \
  348. (inp <= INTn_1_MIX_INP_SEL_RX3))
  349. enum {
  350. INTn_2_INP_SEL_ZERO = 0,
  351. INTn_2_INP_SEL_RX0,
  352. INTn_2_INP_SEL_RX1,
  353. INTn_2_INP_SEL_RX2,
  354. INTn_2_INP_SEL_RX3,
  355. INTn_2_INP_SEL_RX4,
  356. INTn_2_INP_SEL_RX5,
  357. INTn_2_INP_SEL_RX6,
  358. INTn_2_INP_SEL_RX7,
  359. INTn_2_INP_SEL_PROXIMITY,
  360. };
  361. enum {
  362. INTERP_EAR = 0,
  363. INTERP_HPHL,
  364. INTERP_HPHR,
  365. INTERP_LO1,
  366. INTERP_LO2,
  367. INTERP_LO3,
  368. INTERP_LO4,
  369. INTERP_SPKR1,
  370. INTERP_SPKR2,
  371. };
  372. struct interp_sample_rate {
  373. int sample_rate;
  374. int rate_val;
  375. };
  376. static struct interp_sample_rate int_prim_sample_rate_val[] = {
  377. {8000, 0x0}, /* 8K */
  378. {16000, 0x1}, /* 16K */
  379. {24000, -EINVAL},/* 24K */
  380. {32000, 0x3}, /* 32K */
  381. {48000, 0x4}, /* 48K */
  382. {96000, 0x5}, /* 96K */
  383. {192000, 0x6}, /* 192K */
  384. {384000, 0x7}, /* 384K */
  385. {44100, 0x8}, /* 44.1K */
  386. };
  387. static struct interp_sample_rate int_mix_sample_rate_val[] = {
  388. {48000, 0x4}, /* 48K */
  389. {96000, 0x5}, /* 96K */
  390. {192000, 0x6}, /* 192K */
  391. };
  392. static const struct wcd9xxx_ch tasha_rx_chs[TASHA_RX_MAX] = {
  393. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER, 0),
  394. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 1, 1),
  395. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 2, 2),
  396. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 3, 3),
  397. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 4, 4),
  398. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 5, 5),
  399. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 6, 6),
  400. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 7, 7),
  401. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 8, 8),
  402. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 9, 9),
  403. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 10, 10),
  404. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 11, 11),
  405. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 12, 12),
  406. };
  407. static const struct wcd9xxx_ch tasha_tx_chs[TASHA_TX_MAX] = {
  408. WCD9XXX_CH(0, 0),
  409. WCD9XXX_CH(1, 1),
  410. WCD9XXX_CH(2, 2),
  411. WCD9XXX_CH(3, 3),
  412. WCD9XXX_CH(4, 4),
  413. WCD9XXX_CH(5, 5),
  414. WCD9XXX_CH(6, 6),
  415. WCD9XXX_CH(7, 7),
  416. WCD9XXX_CH(8, 8),
  417. WCD9XXX_CH(9, 9),
  418. WCD9XXX_CH(10, 10),
  419. WCD9XXX_CH(11, 11),
  420. WCD9XXX_CH(12, 12),
  421. WCD9XXX_CH(13, 13),
  422. WCD9XXX_CH(14, 14),
  423. WCD9XXX_CH(15, 15),
  424. };
  425. static const u32 vport_slim_check_table[NUM_CODEC_DAIS] = {
  426. /* Needs to define in the same order of DAI enum definitions */
  427. 0,
  428. BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  429. 0,
  430. BIT(AIF1_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  431. 0,
  432. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  433. 0,
  434. 0,
  435. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF5_CPE_TX),
  436. 0,
  437. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX),
  438. };
  439. static const u32 vport_i2s_check_table[NUM_CODEC_DAIS] = {
  440. 0, /* AIF1_PB */
  441. BIT(AIF2_CAP), /* AIF1_CAP */
  442. 0, /* AIF2_PB */
  443. BIT(AIF1_CAP), /* AIF2_CAP */
  444. };
  445. /* Codec supports 2 IIR filters */
  446. enum {
  447. IIR0 = 0,
  448. IIR1,
  449. IIR_MAX,
  450. };
  451. /* Each IIR has 5 Filter Stages */
  452. enum {
  453. BAND1 = 0,
  454. BAND2,
  455. BAND3,
  456. BAND4,
  457. BAND5,
  458. BAND_MAX,
  459. };
  460. enum {
  461. COMPANDER_1, /* HPH_L */
  462. COMPANDER_2, /* HPH_R */
  463. COMPANDER_3, /* LO1_DIFF */
  464. COMPANDER_4, /* LO2_DIFF */
  465. COMPANDER_5, /* LO3_SE */
  466. COMPANDER_6, /* LO4_SE */
  467. COMPANDER_7, /* SWR SPK CH1 */
  468. COMPANDER_8, /* SWR SPK CH2 */
  469. COMPANDER_MAX,
  470. };
  471. enum {
  472. SRC_IN_HPHL,
  473. SRC_IN_LO1,
  474. SRC_IN_HPHR,
  475. SRC_IN_LO2,
  476. SRC_IN_SPKRL,
  477. SRC_IN_LO3,
  478. SRC_IN_SPKRR,
  479. SRC_IN_LO4,
  480. };
  481. enum {
  482. SPLINE_SRC0,
  483. SPLINE_SRC1,
  484. SPLINE_SRC2,
  485. SPLINE_SRC3,
  486. SPLINE_SRC_MAX,
  487. };
  488. static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
  489. static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
  490. static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
  491. static struct snd_soc_dai_driver tasha_dai[];
  492. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv);
  493. static int tasha_config_compander(struct snd_soc_codec *, int, int);
  494. static void tasha_codec_set_tx_hold(struct snd_soc_codec *, u16, bool);
  495. static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
  496. bool enable);
  497. /* Hold instance to soundwire platform device */
  498. struct tasha_swr_ctrl_data {
  499. struct platform_device *swr_pdev;
  500. struct ida swr_ida;
  501. };
  502. struct wcd_swr_ctrl_platform_data {
  503. void *handle; /* holds codec private data */
  504. int (*read)(void *handle, int reg);
  505. int (*write)(void *handle, int reg, int val);
  506. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  507. int (*clk)(void *handle, bool enable);
  508. int (*handle_irq)(void *handle,
  509. irqreturn_t (*swrm_irq_handler)(int irq,
  510. void *data),
  511. void *swrm_handle,
  512. int action);
  513. };
  514. static struct wcd_mbhc_register
  515. wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = {
  516. WCD_MBHC_REGISTER("WCD_MBHC_L_DET_EN",
  517. WCD9335_ANA_MBHC_MECH, 0x80, 7, 0),
  518. WCD_MBHC_REGISTER("WCD_MBHC_GND_DET_EN",
  519. WCD9335_ANA_MBHC_MECH, 0x40, 6, 0),
  520. WCD_MBHC_REGISTER("WCD_MBHC_MECH_DETECTION_TYPE",
  521. WCD9335_ANA_MBHC_MECH, 0x20, 5, 0),
  522. WCD_MBHC_REGISTER("WCD_MBHC_MIC_CLAMP_CTL",
  523. WCD9335_MBHC_PLUG_DETECT_CTL, 0x30, 4, 0),
  524. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_DETECTION_TYPE",
  525. WCD9335_ANA_MBHC_ELECT, 0x08, 3, 0),
  526. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_CTRL",
  527. WCD9335_MBHC_PLUG_DETECT_CTL, 0xC0, 6, 0),
  528. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL",
  529. WCD9335_ANA_MBHC_MECH, 0x04, 2, 0),
  530. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PLUG_TYPE",
  531. WCD9335_ANA_MBHC_MECH, 0x10, 4, 0),
  532. WCD_MBHC_REGISTER("WCD_MBHC_GND_PLUG_TYPE",
  533. WCD9335_ANA_MBHC_MECH, 0x08, 3, 0),
  534. WCD_MBHC_REGISTER("WCD_MBHC_SW_HPH_LP_100K_TO_GND",
  535. WCD9335_ANA_MBHC_MECH, 0x01, 0, 0),
  536. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_SCHMT_ISRC",
  537. WCD9335_ANA_MBHC_ELECT, 0x06, 1, 0),
  538. WCD_MBHC_REGISTER("WCD_MBHC_FSM_EN",
  539. WCD9335_ANA_MBHC_ELECT, 0x80, 7, 0),
  540. WCD_MBHC_REGISTER("WCD_MBHC_INSREM_DBNC",
  541. WCD9335_MBHC_PLUG_DETECT_CTL, 0x0F, 0, 0),
  542. WCD_MBHC_REGISTER("WCD_MBHC_BTN_DBNC",
  543. WCD9335_MBHC_CTL_1, 0x03, 0, 0),
  544. WCD_MBHC_REGISTER("WCD_MBHC_HS_VREF",
  545. WCD9335_MBHC_CTL_2, 0x03, 0, 0),
  546. WCD_MBHC_REGISTER("WCD_MBHC_HS_COMP_RESULT",
  547. WCD9335_ANA_MBHC_RESULT_3, 0x08, 3, 0),
  548. WCD_MBHC_REGISTER("WCD_MBHC_IN2P_CLAMP_STATE",
  549. WCD9335_ANA_MBHC_RESULT_3, 0x10, 4, 0),
  550. WCD_MBHC_REGISTER("WCD_MBHC_MIC_SCHMT_RESULT",
  551. WCD9335_ANA_MBHC_RESULT_3, 0x20, 5, 0),
  552. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_SCHMT_RESULT",
  553. WCD9335_ANA_MBHC_RESULT_3, 0x80, 7, 0),
  554. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_SCHMT_RESULT",
  555. WCD9335_ANA_MBHC_RESULT_3, 0x40, 6, 0),
  556. WCD_MBHC_REGISTER("WCD_MBHC_OCP_FSM_EN",
  557. WCD9335_HPH_OCP_CTL, 0x10, 4, 0),
  558. WCD_MBHC_REGISTER("WCD_MBHC_BTN_RESULT",
  559. WCD9335_ANA_MBHC_RESULT_3, 0x07, 0, 0),
  560. WCD_MBHC_REGISTER("WCD_MBHC_BTN_ISRC_CTL",
  561. WCD9335_ANA_MBHC_ELECT, 0x70, 4, 0),
  562. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_RESULT",
  563. WCD9335_ANA_MBHC_RESULT_3, 0xFF, 0, 0),
  564. WCD_MBHC_REGISTER("WCD_MBHC_MICB_CTRL",
  565. WCD9335_ANA_MICB2, 0xC0, 6, 0),
  566. WCD_MBHC_REGISTER("WCD_MBHC_HPH_CNP_WG_TIME",
  567. WCD9335_HPH_CNP_WG_TIME, 0xFF, 0, 0),
  568. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_PA_EN",
  569. WCD9335_ANA_HPH, 0x40, 6, 0),
  570. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PA_EN",
  571. WCD9335_ANA_HPH, 0x80, 7, 0),
  572. WCD_MBHC_REGISTER("WCD_MBHC_HPH_PA_EN",
  573. WCD9335_ANA_HPH, 0xC0, 6, 0),
  574. WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE",
  575. WCD9335_ANA_MBHC_RESULT_3, 0x10, 4, 0),
  576. WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL",
  577. 0, 0, 0, 0),
  578. WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN",
  579. WCD9335_ANA_MBHC_ZDET, 0x01, 0, 0),
  580. /*
  581. * MBHC FSM status register is only available in Tasha 2.0.
  582. * So, init with 0 later once the version is known, then values
  583. * will be updated.
  584. */
  585. WCD_MBHC_REGISTER("WCD_MBHC_FSM_STATUS",
  586. 0, 0, 0, 0),
  587. WCD_MBHC_REGISTER("WCD_MBHC_MUX_CTL",
  588. WCD9335_MBHC_CTL_2, 0x70, 4, 0),
  589. WCD_MBHC_REGISTER("WCD_MBHC_MOISTURE_STATUS",
  590. WCD9335_MBHC_FSM_STATUS, 0X20, 5, 0),
  591. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_GND",
  592. WCD9335_HPH_PA_CTL2, 0x40, 6, 0),
  593. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_GND",
  594. WCD9335_HPH_PA_CTL2, 0x10, 4, 0),
  595. };
  596. static const struct wcd_mbhc_intr intr_ids = {
  597. .mbhc_sw_intr = WCD9335_IRQ_MBHC_SW_DET,
  598. .mbhc_btn_press_intr = WCD9335_IRQ_MBHC_BUTTON_PRESS_DET,
  599. .mbhc_btn_release_intr = WCD9335_IRQ_MBHC_BUTTON_RELEASE_DET,
  600. .mbhc_hs_ins_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
  601. .mbhc_hs_rem_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_DET,
  602. .hph_left_ocp = WCD9335_IRQ_HPH_PA_OCPL_FAULT,
  603. .hph_right_ocp = WCD9335_IRQ_HPH_PA_OCPR_FAULT,
  604. };
  605. struct wcd_vbat {
  606. bool is_enabled;
  607. bool adc_config;
  608. /* Variables to cache Vbat ADC output values */
  609. u16 dcp1;
  610. u16 dcp2;
  611. };
  612. struct hpf_work {
  613. struct tasha_priv *tasha;
  614. u8 decimator;
  615. u8 hpf_cut_off_freq;
  616. struct delayed_work dwork;
  617. };
  618. #define WCD9335_SPK_ANC_EN_DELAY_MS 350
  619. static int spk_anc_en_delay = WCD9335_SPK_ANC_EN_DELAY_MS;
  620. module_param(spk_anc_en_delay, int, 0664);
  621. MODULE_PARM_DESC(spk_anc_en_delay, "delay to enable anc in speaker path");
  622. struct spk_anc_work {
  623. struct tasha_priv *tasha;
  624. struct delayed_work dwork;
  625. };
  626. struct tx_mute_work {
  627. struct tasha_priv *tasha;
  628. u8 decimator;
  629. struct delayed_work dwork;
  630. };
  631. struct tasha_priv {
  632. struct device *dev;
  633. struct wcd9xxx *wcd9xxx;
  634. struct snd_soc_codec *codec;
  635. u32 adc_count;
  636. u32 rx_bias_count;
  637. s32 dmic_0_1_clk_cnt;
  638. s32 dmic_2_3_clk_cnt;
  639. s32 dmic_4_5_clk_cnt;
  640. s32 ldo_h_users;
  641. s32 micb_ref[TASHA_MAX_MICBIAS];
  642. s32 pullup_ref[TASHA_MAX_MICBIAS];
  643. u32 anc_slot;
  644. bool anc_func;
  645. bool is_wsa_attach;
  646. /* Vbat module */
  647. struct wcd_vbat vbat;
  648. /* cal info for codec */
  649. struct fw_info *fw_data;
  650. /*track tasha interface type*/
  651. u8 intf_type;
  652. /* num of slim ports required */
  653. struct wcd9xxx_codec_dai_data dai[NUM_CODEC_DAIS];
  654. /* SoundWire data structure */
  655. struct tasha_swr_ctrl_data *swr_ctrl_data;
  656. int nr;
  657. /*compander*/
  658. int comp_enabled[COMPANDER_MAX];
  659. /* Maintain the status of AUX PGA */
  660. int aux_pga_cnt;
  661. u8 aux_l_gain;
  662. u8 aux_r_gain;
  663. bool spkr_pa_widget_on;
  664. struct regulator *spkdrv_reg;
  665. struct regulator *spkdrv2_reg;
  666. bool mbhc_started;
  667. /* class h specific data */
  668. struct wcd_clsh_cdc_data clsh_d;
  669. struct afe_param_cdc_slimbus_slave_cfg slimbus_slave_cfg;
  670. /*
  671. * list used to save/restore registers at start and
  672. * end of impedance measurement
  673. */
  674. struct list_head reg_save_restore;
  675. /* handle to cpe core */
  676. struct wcd_cpe_core *cpe_core;
  677. u32 current_cpe_clk_freq;
  678. enum tasha_sido_voltage sido_voltage;
  679. int sido_ccl_cnt;
  680. u32 ana_rx_supplies;
  681. /* Multiplication factor used for impedance detection */
  682. int zdet_gain_mul_fact;
  683. /* to track the status */
  684. unsigned long status_mask;
  685. struct work_struct tasha_add_child_devices_work;
  686. struct wcd_swr_ctrl_platform_data swr_plat_data;
  687. /* Port values for Rx and Tx codec_dai */
  688. unsigned int rx_port_value[TASHA_RX_MAX];
  689. unsigned int tx_port_value;
  690. unsigned int vi_feed_value;
  691. /* Tasha Interpolator Mode Select for EAR, HPH_L and HPH_R */
  692. u32 hph_mode;
  693. u16 prim_int_users[TASHA_NUM_INTERPOLATORS];
  694. int spl_src_users[SPLINE_SRC_MAX];
  695. struct wcd9xxx_resmgr_v2 *resmgr;
  696. struct delayed_work power_gate_work;
  697. struct mutex power_lock;
  698. struct mutex sido_lock;
  699. /* mbhc module */
  700. struct wcd_mbhc mbhc;
  701. struct blocking_notifier_head notifier;
  702. struct mutex micb_lock;
  703. struct clk *wcd_ext_clk;
  704. struct clk *wcd_native_clk;
  705. struct mutex swr_read_lock;
  706. struct mutex swr_write_lock;
  707. struct mutex swr_clk_lock;
  708. int swr_clk_users;
  709. int native_clk_users;
  710. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high);
  711. struct snd_info_entry *entry;
  712. struct snd_info_entry *version_entry;
  713. int power_active_ref;
  714. struct on_demand_supply on_demand_list[ON_DEMAND_SUPPLIES_MAX];
  715. int (*machine_codec_event_cb)(struct snd_soc_codec *codec,
  716. enum wcd9335_codec_event);
  717. int spkr_gain_offset;
  718. int spkr_mode;
  719. int ear_spkr_gain;
  720. struct hpf_work tx_hpf_work[TASHA_NUM_DECIMATORS];
  721. struct tx_mute_work tx_mute_dwork[TASHA_NUM_DECIMATORS];
  722. struct spk_anc_work spk_anc_dwork;
  723. struct mutex codec_mutex;
  724. int hph_l_gain;
  725. int hph_r_gain;
  726. int rx_7_count;
  727. int rx_8_count;
  728. bool clk_mode;
  729. bool clk_internal;
  730. /* Lock to prevent multiple functions voting at same time */
  731. struct mutex sb_clk_gear_lock;
  732. /* Count for functions voting or un-voting */
  733. u32 ref_count;
  734. /* Lock to protect mclk enablement */
  735. struct mutex mclk_lock;
  736. struct platform_device *pdev_child_devices
  737. [WCD9335_CHILD_DEVICES_MAX];
  738. int child_count;
  739. };
  740. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  741. bool vote);
  742. static const struct tasha_reg_mask_val tasha_spkr_default[] = {
  743. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  744. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  745. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  746. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  747. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x58},
  748. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x58},
  749. };
  750. static const struct tasha_reg_mask_val tasha_spkr_mode1[] = {
  751. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x00},
  752. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x00},
  753. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x00},
  754. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x00},
  755. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x44},
  756. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x44},
  757. };
  758. /**
  759. * tasha_set_spkr_gain_offset - offset the speaker path
  760. * gain with the given offset value.
  761. *
  762. * @codec: codec instance
  763. * @offset: Indicates speaker path gain offset value.
  764. *
  765. * Returns 0 on success or -EINVAL on error.
  766. */
  767. int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
  768. {
  769. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  770. if (!priv)
  771. return -EINVAL;
  772. priv->spkr_gain_offset = offset;
  773. return 0;
  774. }
  775. EXPORT_SYMBOL(tasha_set_spkr_gain_offset);
  776. /**
  777. * tasha_set_spkr_mode - Configures speaker compander and smartboost
  778. * settings based on speaker mode.
  779. *
  780. * @codec: codec instance
  781. * @mode: Indicates speaker configuration mode.
  782. *
  783. * Returns 0 on success or -EINVAL on error.
  784. */
  785. int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode)
  786. {
  787. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  788. int i;
  789. const struct tasha_reg_mask_val *regs;
  790. int size;
  791. if (!priv)
  792. return -EINVAL;
  793. switch (mode) {
  794. case SPKR_MODE_1:
  795. regs = tasha_spkr_mode1;
  796. size = ARRAY_SIZE(tasha_spkr_mode1);
  797. break;
  798. default:
  799. regs = tasha_spkr_default;
  800. size = ARRAY_SIZE(tasha_spkr_default);
  801. break;
  802. }
  803. priv->spkr_mode = mode;
  804. for (i = 0; i < size; i++)
  805. snd_soc_update_bits(codec, regs[i].reg,
  806. regs[i].mask, regs[i].val);
  807. return 0;
  808. }
  809. EXPORT_SYMBOL(tasha_set_spkr_mode);
  810. static void tasha_enable_sido_buck(struct snd_soc_codec *codec)
  811. {
  812. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  813. snd_soc_update_bits(codec, WCD9335_ANA_RCO, 0x80, 0x80);
  814. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x02, 0x02);
  815. /* 100us sleep needed after IREF settings */
  816. usleep_range(100, 110);
  817. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x04, 0x04);
  818. /* 100us sleep needed after VREF settings */
  819. usleep_range(100, 110);
  820. tasha->resmgr->sido_input_src = SIDO_SOURCE_RCO_BG;
  821. }
  822. static void tasha_cdc_sido_ccl_enable(struct tasha_priv *tasha, bool ccl_flag)
  823. {
  824. struct snd_soc_codec *codec = tasha->codec;
  825. if (!codec)
  826. return;
  827. if (!TASHA_IS_2_0(tasha->wcd9xxx)) {
  828. dev_dbg(codec->dev, "%s: tasha version < 2p0, return\n",
  829. __func__);
  830. return;
  831. }
  832. dev_dbg(codec->dev, "%s: sido_ccl_cnt=%d, ccl_flag:%d\n",
  833. __func__, tasha->sido_ccl_cnt, ccl_flag);
  834. if (ccl_flag) {
  835. if (++tasha->sido_ccl_cnt == 1)
  836. snd_soc_update_bits(codec,
  837. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x6E);
  838. } else {
  839. if (tasha->sido_ccl_cnt == 0) {
  840. dev_dbg(codec->dev, "%s: sido_ccl already disabled\n",
  841. __func__);
  842. return;
  843. }
  844. if (--tasha->sido_ccl_cnt == 0)
  845. snd_soc_update_bits(codec,
  846. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x02);
  847. }
  848. }
  849. static bool tasha_cdc_is_svs_enabled(struct tasha_priv *tasha)
  850. {
  851. if (TASHA_IS_2_0(tasha->wcd9xxx) &&
  852. svs_scaling_enabled)
  853. return true;
  854. return false;
  855. }
  856. static int tasha_cdc_req_mclk_enable(struct tasha_priv *tasha,
  857. bool enable)
  858. {
  859. int ret = 0;
  860. mutex_lock(&tasha->mclk_lock);
  861. if (enable) {
  862. tasha_cdc_sido_ccl_enable(tasha, true);
  863. ret = clk_prepare_enable(tasha->wcd_ext_clk);
  864. if (ret) {
  865. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  866. __func__);
  867. goto unlock_mutex;
  868. }
  869. /* get BG */
  870. wcd_resmgr_enable_master_bias(tasha->resmgr);
  871. /* get MCLK */
  872. wcd_resmgr_enable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  873. } else {
  874. /* put MCLK */
  875. wcd_resmgr_disable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  876. /* put BG */
  877. wcd_resmgr_disable_master_bias(tasha->resmgr);
  878. clk_disable_unprepare(tasha->wcd_ext_clk);
  879. tasha_cdc_sido_ccl_enable(tasha, false);
  880. }
  881. unlock_mutex:
  882. mutex_unlock(&tasha->mclk_lock);
  883. return ret;
  884. }
  885. static int tasha_cdc_check_sido_value(enum tasha_sido_voltage req_mv)
  886. {
  887. if ((req_mv != SIDO_VOLTAGE_SVS_MV) &&
  888. (req_mv != SIDO_VOLTAGE_NOMINAL_MV))
  889. return -EINVAL;
  890. return 0;
  891. }
  892. static void tasha_codec_apply_sido_voltage(
  893. struct tasha_priv *tasha,
  894. enum tasha_sido_voltage req_mv)
  895. {
  896. u32 vout_d_val;
  897. struct snd_soc_codec *codec = tasha->codec;
  898. int ret;
  899. if (!codec)
  900. return;
  901. if (!tasha_cdc_is_svs_enabled(tasha))
  902. return;
  903. if ((sido_buck_svs_voltage != SIDO_VOLTAGE_SVS_MV) &&
  904. (sido_buck_svs_voltage != SIDO_VOLTAGE_NOMINAL_MV))
  905. sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  906. ret = tasha_cdc_check_sido_value(req_mv);
  907. if (ret < 0) {
  908. dev_dbg(codec->dev, "%s: requested mv=%d not in range\n",
  909. __func__, req_mv);
  910. return;
  911. }
  912. if (req_mv == tasha->sido_voltage) {
  913. dev_dbg(codec->dev, "%s: Already at requested mv=%d\n",
  914. __func__, req_mv);
  915. return;
  916. }
  917. if (req_mv == sido_buck_svs_voltage) {
  918. if (test_bit(AUDIO_NOMINAL, &tasha->status_mask) ||
  919. test_bit(CPE_NOMINAL, &tasha->status_mask)) {
  920. dev_dbg(codec->dev,
  921. "%s: nominal client running, status_mask=%lu\n",
  922. __func__, tasha->status_mask);
  923. return;
  924. }
  925. }
  926. /* compute the vout_d step value */
  927. vout_d_val = CALCULATE_VOUT_D(req_mv);
  928. snd_soc_write(codec, WCD9335_ANA_BUCK_VOUT_D, vout_d_val & 0xFF);
  929. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x80, 0x80);
  930. /* 1 msec sleep required after SIDO Vout_D voltage change */
  931. usleep_range(1000, 1100);
  932. tasha->sido_voltage = req_mv;
  933. dev_dbg(codec->dev,
  934. "%s: updated SIDO buck Vout_D to %d, vout_d step = %u\n",
  935. __func__, tasha->sido_voltage, vout_d_val);
  936. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL,
  937. 0x80, 0x00);
  938. }
  939. static int tasha_codec_update_sido_voltage(
  940. struct tasha_priv *tasha,
  941. enum tasha_sido_voltage req_mv)
  942. {
  943. int ret = 0;
  944. if (!tasha_cdc_is_svs_enabled(tasha))
  945. return ret;
  946. mutex_lock(&tasha->sido_lock);
  947. /* enable mclk before setting SIDO voltage */
  948. ret = tasha_cdc_req_mclk_enable(tasha, true);
  949. if (ret) {
  950. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  951. __func__);
  952. goto err;
  953. }
  954. tasha_codec_apply_sido_voltage(tasha, req_mv);
  955. tasha_cdc_req_mclk_enable(tasha, false);
  956. err:
  957. mutex_unlock(&tasha->sido_lock);
  958. return ret;
  959. }
  960. int tasha_enable_efuse_sensing(struct snd_soc_codec *codec)
  961. {
  962. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  963. tasha_cdc_mclk_enable(codec, true, false);
  964. if (!TASHA_IS_2_0(priv->wcd9xxx))
  965. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  966. 0x1E, 0x02);
  967. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  968. 0x01, 0x01);
  969. /*
  970. * 5ms sleep required after enabling efuse control
  971. * before checking the status.
  972. */
  973. usleep_range(5000, 5500);
  974. if (!(snd_soc_read(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01))
  975. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  976. if (TASHA_IS_2_0(priv->wcd9xxx)) {
  977. if (!(snd_soc_read(codec,
  978. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0) & 0x40))
  979. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST,
  980. 0x04, 0x00);
  981. tasha_enable_sido_buck(codec);
  982. }
  983. tasha_cdc_mclk_enable(codec, false, false);
  984. return 0;
  985. }
  986. EXPORT_SYMBOL(tasha_enable_efuse_sensing);
  987. void *tasha_get_afe_config(struct snd_soc_codec *codec,
  988. enum afe_config_type config_type)
  989. {
  990. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  991. switch (config_type) {
  992. case AFE_SLIMBUS_SLAVE_CONFIG:
  993. return &priv->slimbus_slave_cfg;
  994. case AFE_CDC_REGISTERS_CONFIG:
  995. return &tasha_audio_reg_cfg;
  996. case AFE_SLIMBUS_SLAVE_PORT_CONFIG:
  997. return &tasha_slimbus_slave_port_cfg;
  998. case AFE_AANC_VERSION:
  999. return &tasha_cdc_aanc_version;
  1000. case AFE_CLIP_BANK_SEL:
  1001. return NULL;
  1002. case AFE_CDC_CLIP_REGISTERS_CONFIG:
  1003. return NULL;
  1004. case AFE_CDC_REGISTER_PAGE_CONFIG:
  1005. return &tasha_cdc_reg_page_cfg;
  1006. default:
  1007. dev_err(codec->dev, "%s: Unknown config_type 0x%x\n",
  1008. __func__, config_type);
  1009. return NULL;
  1010. }
  1011. }
  1012. EXPORT_SYMBOL(tasha_get_afe_config);
  1013. /*
  1014. * tasha_event_register: Registers a machine driver callback
  1015. * function with codec private data for post ADSP sub-system
  1016. * restart (SSR). This callback function will be called from
  1017. * codec driver once codec comes out of reset after ADSP SSR.
  1018. *
  1019. * @machine_event_cb: callback function from machine driver
  1020. * @codec: Codec instance
  1021. *
  1022. * Return: none
  1023. */
  1024. void tasha_event_register(
  1025. int (*machine_event_cb)(struct snd_soc_codec *codec,
  1026. enum wcd9335_codec_event),
  1027. struct snd_soc_codec *codec)
  1028. {
  1029. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1030. if (tasha)
  1031. tasha->machine_codec_event_cb = machine_event_cb;
  1032. else
  1033. dev_dbg(codec->dev, "%s: Invalid tasha_priv data\n", __func__);
  1034. }
  1035. EXPORT_SYMBOL(tasha_event_register);
  1036. static int tasha_mbhc_request_irq(struct snd_soc_codec *codec,
  1037. int irq, irq_handler_t handler,
  1038. const char *name, void *data)
  1039. {
  1040. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1041. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1042. struct wcd9xxx_core_resource *core_res =
  1043. &wcd9xxx->core_res;
  1044. return wcd9xxx_request_irq(core_res, irq, handler, name, data);
  1045. }
  1046. static void tasha_mbhc_irq_control(struct snd_soc_codec *codec,
  1047. int irq, bool enable)
  1048. {
  1049. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1050. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1051. struct wcd9xxx_core_resource *core_res =
  1052. &wcd9xxx->core_res;
  1053. if (enable)
  1054. wcd9xxx_enable_irq(core_res, irq);
  1055. else
  1056. wcd9xxx_disable_irq(core_res, irq);
  1057. }
  1058. static int tasha_mbhc_free_irq(struct snd_soc_codec *codec,
  1059. int irq, void *data)
  1060. {
  1061. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1062. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1063. struct wcd9xxx_core_resource *core_res =
  1064. &wcd9xxx->core_res;
  1065. wcd9xxx_free_irq(core_res, irq, data);
  1066. return 0;
  1067. }
  1068. static void tasha_mbhc_clk_setup(struct snd_soc_codec *codec,
  1069. bool enable)
  1070. {
  1071. if (enable)
  1072. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1073. 0x80, 0x80);
  1074. else
  1075. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1076. 0x80, 0x00);
  1077. }
  1078. static int tasha_mbhc_btn_to_num(struct snd_soc_codec *codec)
  1079. {
  1080. return snd_soc_read(codec, WCD9335_ANA_MBHC_RESULT_3) & 0x7;
  1081. }
  1082. static void tasha_mbhc_mbhc_bias_control(struct snd_soc_codec *codec,
  1083. bool enable)
  1084. {
  1085. if (enable)
  1086. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1087. 0x01, 0x01);
  1088. else
  1089. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1090. 0x01, 0x00);
  1091. }
  1092. static void tasha_mbhc_program_btn_thr(struct snd_soc_codec *codec,
  1093. s16 *btn_low, s16 *btn_high,
  1094. int num_btn, bool is_micbias)
  1095. {
  1096. int i;
  1097. int vth;
  1098. if (num_btn > WCD_MBHC_DEF_BUTTONS) {
  1099. dev_err(codec->dev, "%s: invalid number of buttons: %d\n",
  1100. __func__, num_btn);
  1101. return;
  1102. }
  1103. /*
  1104. * Tasha just needs one set of thresholds for button detection
  1105. * due to micbias voltage ramp to pullup upon button press. So
  1106. * btn_low and is_micbias are ignored and always program button
  1107. * thresholds using btn_high.
  1108. */
  1109. for (i = 0; i < num_btn; i++) {
  1110. vth = ((btn_high[i] * 2) / 25) & 0x3F;
  1111. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN0 + i,
  1112. 0xFC, vth << 2);
  1113. dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
  1114. __func__, i, btn_high[i], vth);
  1115. }
  1116. }
  1117. static bool tasha_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
  1118. {
  1119. struct snd_soc_codec *codec = mbhc->codec;
  1120. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1121. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1122. struct wcd9xxx_core_resource *core_res =
  1123. &wcd9xxx->core_res;
  1124. if (lock)
  1125. return wcd9xxx_lock_sleep(core_res);
  1126. else {
  1127. wcd9xxx_unlock_sleep(core_res);
  1128. return 0;
  1129. }
  1130. }
  1131. static int tasha_mbhc_register_notifier(struct wcd_mbhc *mbhc,
  1132. struct notifier_block *nblock,
  1133. bool enable)
  1134. {
  1135. struct snd_soc_codec *codec = mbhc->codec;
  1136. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1137. if (enable)
  1138. return blocking_notifier_chain_register(&tasha->notifier,
  1139. nblock);
  1140. else
  1141. return blocking_notifier_chain_unregister(&tasha->notifier,
  1142. nblock);
  1143. }
  1144. static bool tasha_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
  1145. {
  1146. u8 val;
  1147. if (micb_num == MIC_BIAS_2) {
  1148. val = (snd_soc_read(mbhc->codec, WCD9335_ANA_MICB2) >> 6);
  1149. if (val == 0x01)
  1150. return true;
  1151. }
  1152. return false;
  1153. }
  1154. static bool tasha_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
  1155. {
  1156. return (snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0) ? true : false;
  1157. }
  1158. static void tasha_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec,
  1159. enum mbhc_hs_pullup_iref pull_up_cur)
  1160. {
  1161. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1162. if (!tasha)
  1163. return;
  1164. /* Default pull up current to 2uA */
  1165. if (pull_up_cur < I_OFF || pull_up_cur > I_3P0_UA ||
  1166. pull_up_cur == I_DEFAULT)
  1167. pull_up_cur = I_2P0_UA;
  1168. dev_dbg(codec->dev, "%s: HS pull up current:%d\n",
  1169. __func__, pull_up_cur);
  1170. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1171. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1172. 0xC0, pull_up_cur << 6);
  1173. else
  1174. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1175. 0xC0, 0x40);
  1176. }
  1177. static int tasha_enable_ext_mb_source(struct wcd_mbhc *mbhc,
  1178. bool turn_on)
  1179. {
  1180. struct snd_soc_codec *codec = mbhc->codec;
  1181. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1182. int ret = 0;
  1183. struct on_demand_supply *supply;
  1184. if (!tasha)
  1185. return -EINVAL;
  1186. supply = &tasha->on_demand_list[ON_DEMAND_MICBIAS];
  1187. if (!supply->supply) {
  1188. dev_dbg(codec->dev, "%s: warning supply not present ond for %s\n",
  1189. __func__, "onDemand Micbias");
  1190. return ret;
  1191. }
  1192. dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
  1193. supply->ondemand_supply_count);
  1194. if (turn_on) {
  1195. if (!(supply->ondemand_supply_count)) {
  1196. ret = snd_soc_dapm_force_enable_pin(
  1197. snd_soc_codec_get_dapm(codec),
  1198. "MICBIAS_REGULATOR");
  1199. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1200. }
  1201. supply->ondemand_supply_count++;
  1202. } else {
  1203. if (supply->ondemand_supply_count > 0)
  1204. supply->ondemand_supply_count--;
  1205. if (!(supply->ondemand_supply_count)) {
  1206. ret = snd_soc_dapm_disable_pin(
  1207. snd_soc_codec_get_dapm(codec),
  1208. "MICBIAS_REGULATOR");
  1209. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1210. }
  1211. }
  1212. if (ret)
  1213. dev_err(codec->dev, "%s: Failed to %s external micbias source\n",
  1214. __func__, turn_on ? "enable" : "disabled");
  1215. else
  1216. dev_dbg(codec->dev, "%s: %s external micbias source\n",
  1217. __func__, turn_on ? "Enabled" : "Disabled");
  1218. return ret;
  1219. }
  1220. static int tasha_micbias_control(struct snd_soc_codec *codec,
  1221. int micb_num,
  1222. int req, bool is_dapm)
  1223. {
  1224. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1225. int micb_index = micb_num - 1;
  1226. u16 micb_reg;
  1227. int pre_off_event = 0, post_off_event = 0;
  1228. int post_on_event = 0, post_dapm_off = 0;
  1229. int post_dapm_on = 0;
  1230. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  1231. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  1232. __func__, micb_index);
  1233. return -EINVAL;
  1234. }
  1235. switch (micb_num) {
  1236. case MIC_BIAS_1:
  1237. micb_reg = WCD9335_ANA_MICB1;
  1238. break;
  1239. case MIC_BIAS_2:
  1240. micb_reg = WCD9335_ANA_MICB2;
  1241. pre_off_event = WCD_EVENT_PRE_MICBIAS_2_OFF;
  1242. post_off_event = WCD_EVENT_POST_MICBIAS_2_OFF;
  1243. post_on_event = WCD_EVENT_POST_MICBIAS_2_ON;
  1244. post_dapm_on = WCD_EVENT_POST_DAPM_MICBIAS_2_ON;
  1245. post_dapm_off = WCD_EVENT_POST_DAPM_MICBIAS_2_OFF;
  1246. break;
  1247. case MIC_BIAS_3:
  1248. micb_reg = WCD9335_ANA_MICB3;
  1249. break;
  1250. case MIC_BIAS_4:
  1251. micb_reg = WCD9335_ANA_MICB4;
  1252. break;
  1253. default:
  1254. dev_err(codec->dev, "%s: Invalid micbias number: %d\n",
  1255. __func__, micb_num);
  1256. return -EINVAL;
  1257. }
  1258. mutex_lock(&tasha->micb_lock);
  1259. switch (req) {
  1260. case MICB_PULLUP_ENABLE:
  1261. tasha->pullup_ref[micb_index]++;
  1262. if ((tasha->pullup_ref[micb_index] == 1) &&
  1263. (tasha->micb_ref[micb_index] == 0))
  1264. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1265. break;
  1266. case MICB_PULLUP_DISABLE:
  1267. if (tasha->pullup_ref[micb_index] > 0)
  1268. tasha->pullup_ref[micb_index]--;
  1269. if ((tasha->pullup_ref[micb_index] == 0) &&
  1270. (tasha->micb_ref[micb_index] == 0))
  1271. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1272. break;
  1273. case MICB_ENABLE:
  1274. tasha->micb_ref[micb_index]++;
  1275. if (tasha->micb_ref[micb_index] == 1) {
  1276. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1277. if (post_on_event)
  1278. blocking_notifier_call_chain(&tasha->notifier,
  1279. post_on_event, &tasha->mbhc);
  1280. }
  1281. if (is_dapm && post_dapm_on)
  1282. blocking_notifier_call_chain(&tasha->notifier,
  1283. post_dapm_on, &tasha->mbhc);
  1284. break;
  1285. case MICB_DISABLE:
  1286. if (tasha->micb_ref[micb_index] > 0)
  1287. tasha->micb_ref[micb_index]--;
  1288. if ((tasha->micb_ref[micb_index] == 0) &&
  1289. (tasha->pullup_ref[micb_index] > 0))
  1290. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1291. else if ((tasha->micb_ref[micb_index] == 0) &&
  1292. (tasha->pullup_ref[micb_index] == 0)) {
  1293. if (pre_off_event)
  1294. blocking_notifier_call_chain(&tasha->notifier,
  1295. pre_off_event, &tasha->mbhc);
  1296. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1297. if (post_off_event)
  1298. blocking_notifier_call_chain(&tasha->notifier,
  1299. post_off_event, &tasha->mbhc);
  1300. }
  1301. if (is_dapm && post_dapm_off)
  1302. blocking_notifier_call_chain(&tasha->notifier,
  1303. post_dapm_off, &tasha->mbhc);
  1304. break;
  1305. };
  1306. dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n",
  1307. __func__, micb_num, tasha->micb_ref[micb_index],
  1308. tasha->pullup_ref[micb_index]);
  1309. mutex_unlock(&tasha->micb_lock);
  1310. return 0;
  1311. }
  1312. static int tasha_mbhc_request_micbias(struct snd_soc_codec *codec,
  1313. int micb_num, int req)
  1314. {
  1315. int ret;
  1316. /*
  1317. * If micbias is requested, make sure that there
  1318. * is vote to enable mclk
  1319. */
  1320. if (req == MICB_ENABLE)
  1321. tasha_cdc_mclk_enable(codec, true, false);
  1322. ret = tasha_micbias_control(codec, micb_num, req, false);
  1323. /*
  1324. * Release vote for mclk while requesting for
  1325. * micbias disable
  1326. */
  1327. if (req == MICB_DISABLE)
  1328. tasha_cdc_mclk_enable(codec, false, false);
  1329. return ret;
  1330. }
  1331. static void tasha_mbhc_micb_ramp_control(struct snd_soc_codec *codec,
  1332. bool enable)
  1333. {
  1334. if (enable) {
  1335. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1336. 0x1C, 0x0C);
  1337. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1338. 0x80, 0x80);
  1339. } else {
  1340. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1341. 0x80, 0x00);
  1342. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1343. 0x1C, 0x00);
  1344. }
  1345. }
  1346. static struct firmware_cal *tasha_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
  1347. enum wcd_cal_type type)
  1348. {
  1349. struct tasha_priv *tasha;
  1350. struct firmware_cal *hwdep_cal;
  1351. struct snd_soc_codec *codec = mbhc->codec;
  1352. if (!codec) {
  1353. pr_err("%s: NULL codec pointer\n", __func__);
  1354. return NULL;
  1355. }
  1356. tasha = snd_soc_codec_get_drvdata(codec);
  1357. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, type);
  1358. if (!hwdep_cal)
  1359. dev_err(codec->dev, "%s: cal not sent by %d\n",
  1360. __func__, type);
  1361. return hwdep_cal;
  1362. }
  1363. static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
  1364. int req_volt,
  1365. int micb_num)
  1366. {
  1367. int cur_vout_ctl, req_vout_ctl;
  1368. int micb_reg, micb_val, micb_en;
  1369. switch (micb_num) {
  1370. case MIC_BIAS_1:
  1371. micb_reg = WCD9335_ANA_MICB1;
  1372. break;
  1373. case MIC_BIAS_2:
  1374. micb_reg = WCD9335_ANA_MICB2;
  1375. break;
  1376. case MIC_BIAS_3:
  1377. micb_reg = WCD9335_ANA_MICB3;
  1378. break;
  1379. case MIC_BIAS_4:
  1380. micb_reg = WCD9335_ANA_MICB4;
  1381. break;
  1382. default:
  1383. return -EINVAL;
  1384. }
  1385. /*
  1386. * If requested micbias voltage is same as current micbias
  1387. * voltage, then just return. Otherwise, adjust voltage as
  1388. * per requested value. If micbias is already enabled, then
  1389. * to avoid slow micbias ramp-up or down enable pull-up
  1390. * momentarily, change the micbias value and then re-enable
  1391. * micbias.
  1392. */
  1393. micb_val = snd_soc_read(codec, micb_reg);
  1394. micb_en = (micb_val & 0xC0) >> 6;
  1395. cur_vout_ctl = micb_val & 0x3F;
  1396. req_vout_ctl = wcd9335_get_micb_vout_ctl_val(req_volt);
  1397. if (req_vout_ctl < 0)
  1398. return -EINVAL;
  1399. if (cur_vout_ctl == req_vout_ctl)
  1400. return 0;
  1401. dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n",
  1402. __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl),
  1403. req_volt, micb_en);
  1404. if (micb_en == 0x1)
  1405. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1406. snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl);
  1407. if (micb_en == 0x1) {
  1408. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1409. /*
  1410. * Add 2ms delay as per HW requirement after enabling
  1411. * micbias
  1412. */
  1413. usleep_range(2000, 2100);
  1414. }
  1415. return 0;
  1416. }
  1417. static int tasha_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
  1418. int micb_num, bool req_en)
  1419. {
  1420. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1421. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  1422. int rc, micb_mv;
  1423. if (micb_num != MIC_BIAS_2)
  1424. return -EINVAL;
  1425. /*
  1426. * If device tree micbias level is already above the minimum
  1427. * voltage needed to detect threshold microphone, then do
  1428. * not change the micbias, just return.
  1429. */
  1430. if (pdata->micbias.micb2_mv >= WCD_MBHC_THR_HS_MICB_MV)
  1431. return 0;
  1432. micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv;
  1433. mutex_lock(&tasha->micb_lock);
  1434. rc = tasha_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2);
  1435. mutex_unlock(&tasha->micb_lock);
  1436. return rc;
  1437. }
  1438. static inline void tasha_mbhc_get_result_params(struct wcd9xxx *wcd9xxx,
  1439. s16 *d1_a, u16 noff,
  1440. int32_t *zdet)
  1441. {
  1442. int i;
  1443. int val, val1;
  1444. s16 c1;
  1445. s32 x1, d1;
  1446. int32_t denom;
  1447. int minCode_param[] = {
  1448. 3277, 1639, 820, 410, 205, 103, 52, 26
  1449. };
  1450. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x20);
  1451. for (i = 0; i < TASHA_ZDET_NUM_MEASUREMENTS; i++) {
  1452. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_2, &val);
  1453. if (val & 0x80)
  1454. break;
  1455. }
  1456. val = val << 0x8;
  1457. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_1, &val1);
  1458. val |= val1;
  1459. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x00);
  1460. x1 = TASHA_MBHC_GET_X1(val);
  1461. c1 = TASHA_MBHC_GET_C1(val);
  1462. /* If ramp is not complete, give additional 5ms */
  1463. if ((c1 < 2) && x1)
  1464. usleep_range(5000, 5050);
  1465. if (!c1 || !x1) {
  1466. dev_dbg(wcd9xxx->dev,
  1467. "%s: Impedance detect ramp error, c1=%d, x1=0x%x\n",
  1468. __func__, c1, x1);
  1469. goto ramp_down;
  1470. }
  1471. d1 = d1_a[c1];
  1472. denom = (x1 * d1) - (1 << (14 - noff));
  1473. if (denom > 0)
  1474. *zdet = (TASHA_MBHC_ZDET_CONST * 1000) / denom;
  1475. else if (x1 < minCode_param[noff])
  1476. *zdet = TASHA_ZDET_FLOATING_IMPEDANCE;
  1477. dev_dbg(wcd9xxx->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
  1478. __func__, d1, c1, x1, *zdet);
  1479. ramp_down:
  1480. i = 0;
  1481. while (x1) {
  1482. regmap_bulk_read(wcd9xxx->regmap,
  1483. WCD9335_ANA_MBHC_RESULT_1, (u8 *)&val, 2);
  1484. x1 = TASHA_MBHC_GET_X1(val);
  1485. i++;
  1486. if (i == TASHA_ZDET_NUM_MEASUREMENTS)
  1487. break;
  1488. }
  1489. }
  1490. /*
  1491. * tasha_mbhc_zdet_gpio_ctrl: Register callback function for
  1492. * controlling the switch on hifi amps. Default switch state
  1493. * will put a 51ohm load in parallel to the hph load. So,
  1494. * impedance detection function will pull the gpio high
  1495. * to make the switch open.
  1496. *
  1497. * @zdet_gpio_cb: callback function from machine driver
  1498. * @codec: Codec instance
  1499. *
  1500. * Return: none
  1501. */
  1502. void tasha_mbhc_zdet_gpio_ctrl(
  1503. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
  1504. struct snd_soc_codec *codec)
  1505. {
  1506. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1507. tasha->zdet_gpio_cb = zdet_gpio_cb;
  1508. }
  1509. EXPORT_SYMBOL(tasha_mbhc_zdet_gpio_ctrl);
  1510. static void tasha_mbhc_zdet_ramp(struct snd_soc_codec *codec,
  1511. struct tasha_mbhc_zdet_param *zdet_param,
  1512. int32_t *zl, int32_t *zr, s16 *d1_a)
  1513. {
  1514. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  1515. int32_t zdet = 0;
  1516. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x70,
  1517. zdet_param->ldo_ctl << 4);
  1518. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN5, 0xFC,
  1519. zdet_param->btn5);
  1520. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN6, 0xFC,
  1521. zdet_param->btn6);
  1522. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN7, 0xFC,
  1523. zdet_param->btn7);
  1524. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x0F,
  1525. zdet_param->noff);
  1526. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x0F,
  1527. zdet_param->nshift);
  1528. if (!zl)
  1529. goto z_right;
  1530. /* Start impedance measurement for HPH_L */
  1531. regmap_update_bits(wcd9xxx->regmap,
  1532. WCD9335_ANA_MBHC_ZDET, 0x80, 0x80);
  1533. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_L, noff = %d\n",
  1534. __func__, zdet_param->noff);
  1535. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1536. regmap_update_bits(wcd9xxx->regmap,
  1537. WCD9335_ANA_MBHC_ZDET, 0x80, 0x00);
  1538. *zl = zdet;
  1539. z_right:
  1540. if (!zr)
  1541. return;
  1542. /* Start impedance measurement for HPH_R */
  1543. regmap_update_bits(wcd9xxx->regmap,
  1544. WCD9335_ANA_MBHC_ZDET, 0x40, 0x40);
  1545. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_R, noff = %d\n",
  1546. __func__, zdet_param->noff);
  1547. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1548. regmap_update_bits(wcd9xxx->regmap,
  1549. WCD9335_ANA_MBHC_ZDET, 0x40, 0x00);
  1550. *zr = zdet;
  1551. }
  1552. static inline void tasha_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
  1553. int32_t *z_val, int flag_l_r)
  1554. {
  1555. s16 q1;
  1556. int q1_cal;
  1557. if (*z_val < (TASHA_ZDET_VAL_400/1000))
  1558. q1 = snd_soc_read(codec,
  1559. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r));
  1560. else
  1561. q1 = snd_soc_read(codec,
  1562. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r));
  1563. if (q1 & 0x80)
  1564. q1_cal = (10000 - ((q1 & 0x7F) * 25));
  1565. else
  1566. q1_cal = (10000 + (q1 * 25));
  1567. if (q1_cal > 0)
  1568. *z_val = ((*z_val) * 10000) / q1_cal;
  1569. }
  1570. static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
  1571. uint32_t *zr)
  1572. {
  1573. struct snd_soc_codec *codec = mbhc->codec;
  1574. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1575. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1576. s16 reg0, reg1, reg2, reg3, reg4;
  1577. int32_t z1L, z1R, z1Ls;
  1578. int zMono, z_diff1, z_diff2;
  1579. bool is_fsm_disable = false;
  1580. bool is_change = false;
  1581. struct tasha_mbhc_zdet_param zdet_param[] = {
  1582. {4, 0, 4, 0x08, 0x14, 0x18}, /* < 32ohm */
  1583. {2, 0, 3, 0x18, 0x7C, 0x90}, /* 32ohm < Z < 400ohm */
  1584. {1, 4, 5, 0x18, 0x7C, 0x90}, /* 400ohm < Z < 1200ohm */
  1585. {1, 6, 7, 0x18, 0x7C, 0x90}, /* >1200ohm */
  1586. };
  1587. struct tasha_mbhc_zdet_param *zdet_param_ptr = NULL;
  1588. s16 d1_a[][4] = {
  1589. {0, 30, 90, 30},
  1590. {0, 30, 30, 5},
  1591. {0, 30, 30, 5},
  1592. {0, 30, 30, 5},
  1593. };
  1594. s16 *d1 = NULL;
  1595. if (!TASHA_IS_2_0(wcd9xxx)) {
  1596. dev_dbg(codec->dev, "%s: Z-det is not supported for this codec version\n",
  1597. __func__);
  1598. *zl = 0;
  1599. *zr = 0;
  1600. return;
  1601. }
  1602. WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
  1603. if (tasha->zdet_gpio_cb)
  1604. is_change = tasha->zdet_gpio_cb(codec, true);
  1605. reg0 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN5);
  1606. reg1 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN6);
  1607. reg2 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN7);
  1608. reg3 = snd_soc_read(codec, WCD9335_MBHC_CTL_1);
  1609. reg4 = snd_soc_read(codec, WCD9335_MBHC_ZDET_ANA_CTL);
  1610. if (snd_soc_read(codec, WCD9335_ANA_MBHC_ELECT) & 0x80) {
  1611. is_fsm_disable = true;
  1612. regmap_update_bits(wcd9xxx->regmap,
  1613. WCD9335_ANA_MBHC_ELECT, 0x80, 0x00);
  1614. }
  1615. /* For NO-jack, disable L_DET_EN before Z-det measurements */
  1616. if (mbhc->hphl_swh)
  1617. regmap_update_bits(wcd9xxx->regmap,
  1618. WCD9335_ANA_MBHC_MECH, 0x80, 0x00);
  1619. /* Enable AZ */
  1620. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1, 0x0C, 0x04);
  1621. /* Turn off 100k pull down on HPHL */
  1622. regmap_update_bits(wcd9xxx->regmap,
  1623. WCD9335_ANA_MBHC_MECH, 0x01, 0x00);
  1624. /* First get impedance on Left */
  1625. d1 = d1_a[1];
  1626. zdet_param_ptr = &zdet_param[1];
  1627. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1628. if (!TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
  1629. goto left_ch_impedance;
  1630. /* second ramp for left ch */
  1631. if (z1L < TASHA_ZDET_VAL_32) {
  1632. zdet_param_ptr = &zdet_param[0];
  1633. d1 = d1_a[0];
  1634. } else if ((z1L > TASHA_ZDET_VAL_400) && (z1L <= TASHA_ZDET_VAL_1200)) {
  1635. zdet_param_ptr = &zdet_param[2];
  1636. d1 = d1_a[2];
  1637. } else if (z1L > TASHA_ZDET_VAL_1200) {
  1638. zdet_param_ptr = &zdet_param[3];
  1639. d1 = d1_a[3];
  1640. }
  1641. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1642. left_ch_impedance:
  1643. if ((z1L == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1644. (z1L > TASHA_ZDET_VAL_100K)) {
  1645. *zl = TASHA_ZDET_FLOATING_IMPEDANCE;
  1646. zdet_param_ptr = &zdet_param[1];
  1647. d1 = d1_a[1];
  1648. } else {
  1649. *zl = z1L/1000;
  1650. tasha_wcd_mbhc_qfuse_cal(codec, zl, 0);
  1651. }
  1652. dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n",
  1653. __func__, *zl);
  1654. /* start of right impedance ramp and calculation */
  1655. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1656. if (TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
  1657. if (((z1R > TASHA_ZDET_VAL_1200) &&
  1658. (zdet_param_ptr->noff == 0x6)) ||
  1659. ((*zl) != TASHA_ZDET_FLOATING_IMPEDANCE))
  1660. goto right_ch_impedance;
  1661. /* second ramp for right ch */
  1662. if (z1R < TASHA_ZDET_VAL_32) {
  1663. zdet_param_ptr = &zdet_param[0];
  1664. d1 = d1_a[0];
  1665. } else if ((z1R > TASHA_ZDET_VAL_400) &&
  1666. (z1R <= TASHA_ZDET_VAL_1200)) {
  1667. zdet_param_ptr = &zdet_param[2];
  1668. d1 = d1_a[2];
  1669. } else if (z1R > TASHA_ZDET_VAL_1200) {
  1670. zdet_param_ptr = &zdet_param[3];
  1671. d1 = d1_a[3];
  1672. }
  1673. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1674. }
  1675. right_ch_impedance:
  1676. if ((z1R == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1677. (z1R > TASHA_ZDET_VAL_100K)) {
  1678. *zr = TASHA_ZDET_FLOATING_IMPEDANCE;
  1679. } else {
  1680. *zr = z1R/1000;
  1681. tasha_wcd_mbhc_qfuse_cal(codec, zr, 1);
  1682. }
  1683. dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n",
  1684. __func__, *zr);
  1685. /* mono/stereo detection */
  1686. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) &&
  1687. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE)) {
  1688. dev_dbg(codec->dev,
  1689. "%s: plug type is invalid or extension cable\n",
  1690. __func__);
  1691. goto zdet_complete;
  1692. }
  1693. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1694. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1695. ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
  1696. ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
  1697. dev_dbg(codec->dev,
  1698. "%s: Mono plug type with one ch floating or shorted to GND\n",
  1699. __func__);
  1700. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1701. goto zdet_complete;
  1702. }
  1703. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x02);
  1704. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x01);
  1705. if (*zl < (TASHA_ZDET_VAL_32/1000))
  1706. tasha_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1);
  1707. else
  1708. tasha_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1);
  1709. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x00);
  1710. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x00);
  1711. z1Ls /= 1000;
  1712. tasha_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0);
  1713. /* parallel of left Z and 9 ohm pull down resistor */
  1714. zMono = ((*zl) * 9) / ((*zl) + 9);
  1715. z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
  1716. z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
  1717. if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
  1718. dev_dbg(codec->dev, "%s: stereo plug type detected\n",
  1719. __func__);
  1720. mbhc->hph_type = WCD_MBHC_HPH_STEREO;
  1721. } else {
  1722. dev_dbg(codec->dev, "%s: MONO plug type detected\n",
  1723. __func__);
  1724. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1725. }
  1726. zdet_complete:
  1727. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN5, reg0);
  1728. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN6, reg1);
  1729. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN7, reg2);
  1730. /* Turn on 100k pull down on HPHL */
  1731. regmap_update_bits(wcd9xxx->regmap,
  1732. WCD9335_ANA_MBHC_MECH, 0x01, 0x01);
  1733. /* For NO-jack, re-enable L_DET_EN after Z-det measurements */
  1734. if (mbhc->hphl_swh)
  1735. regmap_update_bits(wcd9xxx->regmap,
  1736. WCD9335_ANA_MBHC_MECH, 0x80, 0x80);
  1737. snd_soc_write(codec, WCD9335_MBHC_ZDET_ANA_CTL, reg4);
  1738. snd_soc_write(codec, WCD9335_MBHC_CTL_1, reg3);
  1739. if (is_fsm_disable)
  1740. regmap_update_bits(wcd9xxx->regmap,
  1741. WCD9335_ANA_MBHC_ELECT, 0x80, 0x80);
  1742. if (tasha->zdet_gpio_cb && is_change)
  1743. tasha->zdet_gpio_cb(codec, false);
  1744. }
  1745. static void tasha_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable)
  1746. {
  1747. if (enable) {
  1748. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1749. 0x02, 0x02);
  1750. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1751. 0x40, 0x40);
  1752. } else {
  1753. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1754. 0x40, 0x00);
  1755. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1756. 0x02, 0x00);
  1757. }
  1758. }
  1759. static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec,
  1760. bool enable)
  1761. {
  1762. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1763. if (enable) {
  1764. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1765. 0x40, 0x40);
  1766. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1767. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1768. 0x10, 0x10);
  1769. } else {
  1770. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1771. 0x40, 0x00);
  1772. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1773. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1774. 0x10, 0x00);
  1775. }
  1776. }
  1777. static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc)
  1778. {
  1779. struct snd_soc_codec *codec = mbhc->codec;
  1780. if (mbhc->moist_vref == V_OFF)
  1781. return;
  1782. /* Donot enable moisture detection if jack type is NC */
  1783. if (!mbhc->hphl_swh) {
  1784. dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
  1785. __func__);
  1786. return;
  1787. }
  1788. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2,
  1789. 0x0C, mbhc->moist_vref << 2);
  1790. tasha_mbhc_hph_l_pull_up_control(codec, mbhc->moist_iref);
  1791. }
  1792. static void tasha_update_anc_state(struct snd_soc_codec *codec, bool enable,
  1793. int anc_num)
  1794. {
  1795. if (enable)
  1796. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1797. (20 * anc_num), 0x10, 0x10);
  1798. else
  1799. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1800. (20 * anc_num), 0x10, 0x00);
  1801. }
  1802. static bool tasha_is_anc_on(struct wcd_mbhc *mbhc)
  1803. {
  1804. bool anc_on = false;
  1805. u16 ancl, ancr;
  1806. ancl =
  1807. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX1_RX_PATH_CFG0)) & 0x10;
  1808. ancr =
  1809. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX2_RX_PATH_CFG0)) & 0x10;
  1810. anc_on = !!(ancl | ancr);
  1811. return anc_on;
  1812. }
  1813. static const struct wcd_mbhc_cb mbhc_cb = {
  1814. .request_irq = tasha_mbhc_request_irq,
  1815. .irq_control = tasha_mbhc_irq_control,
  1816. .free_irq = tasha_mbhc_free_irq,
  1817. .clk_setup = tasha_mbhc_clk_setup,
  1818. .map_btn_code_to_num = tasha_mbhc_btn_to_num,
  1819. .enable_mb_source = tasha_enable_ext_mb_source,
  1820. .mbhc_bias = tasha_mbhc_mbhc_bias_control,
  1821. .set_btn_thr = tasha_mbhc_program_btn_thr,
  1822. .lock_sleep = tasha_mbhc_lock_sleep,
  1823. .register_notifier = tasha_mbhc_register_notifier,
  1824. .micbias_enable_status = tasha_mbhc_micb_en_status,
  1825. .hph_pa_on_status = tasha_mbhc_hph_pa_on_status,
  1826. .hph_pull_up_control = tasha_mbhc_hph_l_pull_up_control,
  1827. .mbhc_micbias_control = tasha_mbhc_request_micbias,
  1828. .mbhc_micb_ramp_control = tasha_mbhc_micb_ramp_control,
  1829. .get_hwdep_fw_cal = tasha_get_hwdep_fw_cal,
  1830. .mbhc_micb_ctrl_thr_mic = tasha_mbhc_micb_ctrl_threshold_mic,
  1831. .compute_impedance = tasha_wcd_mbhc_calc_impedance,
  1832. .mbhc_gnd_det_ctrl = tasha_mbhc_gnd_det_ctrl,
  1833. .hph_pull_down_ctrl = tasha_mbhc_hph_pull_down_ctrl,
  1834. .mbhc_moisture_config = tasha_mbhc_moisture_config,
  1835. .update_anc_state = tasha_update_anc_state,
  1836. .is_anc_on = tasha_is_anc_on,
  1837. };
  1838. static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol,
  1839. struct snd_ctl_elem_value *ucontrol)
  1840. {
  1841. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1842. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1843. ucontrol->value.integer.value[0] = tasha->anc_slot;
  1844. return 0;
  1845. }
  1846. static int tasha_put_anc_slot(struct snd_kcontrol *kcontrol,
  1847. struct snd_ctl_elem_value *ucontrol)
  1848. {
  1849. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1850. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1851. tasha->anc_slot = ucontrol->value.integer.value[0];
  1852. return 0;
  1853. }
  1854. static int tasha_get_anc_func(struct snd_kcontrol *kcontrol,
  1855. struct snd_ctl_elem_value *ucontrol)
  1856. {
  1857. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1858. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1859. ucontrol->value.integer.value[0] = (tasha->anc_func == true ? 1 : 0);
  1860. return 0;
  1861. }
  1862. static int tasha_put_anc_func(struct snd_kcontrol *kcontrol,
  1863. struct snd_ctl_elem_value *ucontrol)
  1864. {
  1865. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1866. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1867. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  1868. mutex_lock(&tasha->codec_mutex);
  1869. tasha->anc_func = (!ucontrol->value.integer.value[0] ? false : true);
  1870. dev_dbg(codec->dev, "%s: anc_func %x", __func__, tasha->anc_func);
  1871. if (tasha->anc_func == true) {
  1872. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2 PA");
  1873. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2");
  1874. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1 PA");
  1875. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1");
  1876. snd_soc_dapm_enable_pin(dapm, "ANC HPHR PA");
  1877. snd_soc_dapm_enable_pin(dapm, "ANC HPHR");
  1878. snd_soc_dapm_enable_pin(dapm, "ANC HPHL PA");
  1879. snd_soc_dapm_enable_pin(dapm, "ANC HPHL");
  1880. snd_soc_dapm_enable_pin(dapm, "ANC EAR PA");
  1881. snd_soc_dapm_enable_pin(dapm, "ANC EAR");
  1882. snd_soc_dapm_enable_pin(dapm, "ANC SPK1 PA");
  1883. snd_soc_dapm_disable_pin(dapm, "LINEOUT2");
  1884. snd_soc_dapm_disable_pin(dapm, "LINEOUT2 PA");
  1885. snd_soc_dapm_disable_pin(dapm, "LINEOUT1");
  1886. snd_soc_dapm_disable_pin(dapm, "LINEOUT1 PA");
  1887. snd_soc_dapm_disable_pin(dapm, "HPHR");
  1888. snd_soc_dapm_disable_pin(dapm, "HPHL");
  1889. snd_soc_dapm_disable_pin(dapm, "HPHR PA");
  1890. snd_soc_dapm_disable_pin(dapm, "HPHL PA");
  1891. snd_soc_dapm_disable_pin(dapm, "EAR PA");
  1892. snd_soc_dapm_disable_pin(dapm, "EAR");
  1893. } else {
  1894. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  1895. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  1896. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  1897. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  1898. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  1899. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  1900. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  1901. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  1902. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  1903. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  1904. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  1905. snd_soc_dapm_enable_pin(dapm, "LINEOUT2");
  1906. snd_soc_dapm_enable_pin(dapm, "LINEOUT2 PA");
  1907. snd_soc_dapm_enable_pin(dapm, "LINEOUT1");
  1908. snd_soc_dapm_enable_pin(dapm, "LINEOUT1 PA");
  1909. snd_soc_dapm_enable_pin(dapm, "HPHR");
  1910. snd_soc_dapm_enable_pin(dapm, "HPHL");
  1911. snd_soc_dapm_enable_pin(dapm, "HPHR PA");
  1912. snd_soc_dapm_enable_pin(dapm, "HPHL PA");
  1913. snd_soc_dapm_enable_pin(dapm, "EAR PA");
  1914. snd_soc_dapm_enable_pin(dapm, "EAR");
  1915. }
  1916. mutex_unlock(&tasha->codec_mutex);
  1917. snd_soc_dapm_sync(dapm);
  1918. return 0;
  1919. }
  1920. static int tasha_get_clkmode(struct snd_kcontrol *kcontrol,
  1921. struct snd_ctl_elem_value *ucontrol)
  1922. {
  1923. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1924. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1925. ucontrol->value.enumerated.item[0] = tasha->clk_mode;
  1926. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1927. return 0;
  1928. }
  1929. static int tasha_put_clkmode(struct snd_kcontrol *kcontrol,
  1930. struct snd_ctl_elem_value *ucontrol)
  1931. {
  1932. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1933. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1934. tasha->clk_mode = ucontrol->value.enumerated.item[0];
  1935. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1936. return 0;
  1937. }
  1938. static int tasha_get_iir_enable_audio_mixer(
  1939. struct snd_kcontrol *kcontrol,
  1940. struct snd_ctl_elem_value *ucontrol)
  1941. {
  1942. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1943. int iir_idx = ((struct soc_multi_mixer_control *)
  1944. kcontrol->private_value)->reg;
  1945. int band_idx = ((struct soc_multi_mixer_control *)
  1946. kcontrol->private_value)->shift;
  1947. /* IIR filter band registers are at integer multiples of 16 */
  1948. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  1949. ucontrol->value.integer.value[0] = (snd_soc_read(codec, iir_reg) &
  1950. (1 << band_idx)) != 0;
  1951. dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
  1952. iir_idx, band_idx,
  1953. (uint32_t)ucontrol->value.integer.value[0]);
  1954. return 0;
  1955. }
  1956. static int tasha_hph_impedance_get(struct snd_kcontrol *kcontrol,
  1957. struct snd_ctl_elem_value *ucontrol)
  1958. {
  1959. uint32_t zl, zr;
  1960. bool hphr;
  1961. struct soc_multi_mixer_control *mc;
  1962. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1963. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1964. mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
  1965. hphr = mc->shift;
  1966. wcd_mbhc_get_impedance(&priv->mbhc, &zl, &zr);
  1967. dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
  1968. ucontrol->value.integer.value[0] = hphr ? zr : zl;
  1969. return 0;
  1970. }
  1971. static const struct snd_kcontrol_new impedance_detect_controls[] = {
  1972. SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
  1973. tasha_hph_impedance_get, NULL),
  1974. SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
  1975. tasha_hph_impedance_get, NULL),
  1976. };
  1977. static int tasha_get_hph_type(struct snd_kcontrol *kcontrol,
  1978. struct snd_ctl_elem_value *ucontrol)
  1979. {
  1980. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1981. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1982. struct wcd_mbhc *mbhc;
  1983. if (!priv) {
  1984. dev_dbg(codec->dev, "%s: wcd9335 private data is NULL\n",
  1985. __func__);
  1986. return 0;
  1987. }
  1988. mbhc = &priv->mbhc;
  1989. if (!mbhc) {
  1990. dev_dbg(codec->dev, "%s: mbhc not initialized\n", __func__);
  1991. return 0;
  1992. }
  1993. ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
  1994. dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
  1995. return 0;
  1996. }
  1997. static const struct snd_kcontrol_new hph_type_detect_controls[] = {
  1998. SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
  1999. tasha_get_hph_type, NULL),
  2000. };
  2001. static int tasha_vi_feed_mixer_get(struct snd_kcontrol *kcontrol,
  2002. struct snd_ctl_elem_value *ucontrol)
  2003. {
  2004. struct snd_soc_dapm_widget *widget =
  2005. snd_soc_dapm_kcontrol_widget(kcontrol);
  2006. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2007. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2008. ucontrol->value.integer.value[0] = tasha_p->vi_feed_value;
  2009. return 0;
  2010. }
  2011. static int tasha_vi_feed_mixer_put(struct snd_kcontrol *kcontrol,
  2012. struct snd_ctl_elem_value *ucontrol)
  2013. {
  2014. struct snd_soc_dapm_widget *widget =
  2015. snd_soc_dapm_kcontrol_widget(kcontrol);
  2016. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2017. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2018. struct wcd9xxx *core = tasha_p->wcd9xxx;
  2019. struct soc_multi_mixer_control *mixer =
  2020. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2021. u32 dai_id = widget->shift;
  2022. u32 port_id = mixer->shift;
  2023. u32 enable = ucontrol->value.integer.value[0];
  2024. dev_dbg(codec->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n",
  2025. __func__, enable, port_id, dai_id);
  2026. tasha_p->vi_feed_value = ucontrol->value.integer.value[0];
  2027. mutex_lock(&tasha_p->codec_mutex);
  2028. if (enable) {
  2029. if (port_id == TASHA_TX14 && !test_bit(VI_SENSE_1,
  2030. &tasha_p->status_mask)) {
  2031. list_add_tail(&core->tx_chs[TASHA_TX14].list,
  2032. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2033. set_bit(VI_SENSE_1, &tasha_p->status_mask);
  2034. }
  2035. if (port_id == TASHA_TX15 && !test_bit(VI_SENSE_2,
  2036. &tasha_p->status_mask)) {
  2037. list_add_tail(&core->tx_chs[TASHA_TX15].list,
  2038. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2039. set_bit(VI_SENSE_2, &tasha_p->status_mask);
  2040. }
  2041. } else {
  2042. if (port_id == TASHA_TX14 && test_bit(VI_SENSE_1,
  2043. &tasha_p->status_mask)) {
  2044. list_del_init(&core->tx_chs[TASHA_TX14].list);
  2045. clear_bit(VI_SENSE_1, &tasha_p->status_mask);
  2046. }
  2047. if (port_id == TASHA_TX15 && test_bit(VI_SENSE_2,
  2048. &tasha_p->status_mask)) {
  2049. list_del_init(&core->tx_chs[TASHA_TX15].list);
  2050. clear_bit(VI_SENSE_2, &tasha_p->status_mask);
  2051. }
  2052. }
  2053. mutex_unlock(&tasha_p->codec_mutex);
  2054. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL);
  2055. return 0;
  2056. }
  2057. /* virtual port entries */
  2058. static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol,
  2059. struct snd_ctl_elem_value *ucontrol)
  2060. {
  2061. struct snd_soc_dapm_widget *widget =
  2062. snd_soc_dapm_kcontrol_widget(kcontrol);
  2063. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2064. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2065. ucontrol->value.integer.value[0] = tasha_p->tx_port_value;
  2066. return 0;
  2067. }
  2068. static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol,
  2069. struct snd_ctl_elem_value *ucontrol)
  2070. {
  2071. struct snd_soc_dapm_widget *widget =
  2072. snd_soc_dapm_kcontrol_widget(kcontrol);
  2073. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2074. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2075. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2076. struct snd_soc_dapm_update *update = NULL;
  2077. struct soc_multi_mixer_control *mixer =
  2078. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2079. u32 dai_id = widget->shift;
  2080. u32 port_id = mixer->shift;
  2081. u32 enable = ucontrol->value.integer.value[0];
  2082. u32 vtable;
  2083. dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n",
  2084. __func__,
  2085. widget->name, ucontrol->id.name, tasha_p->tx_port_value,
  2086. widget->shift, ucontrol->value.integer.value[0]);
  2087. mutex_lock(&tasha_p->codec_mutex);
  2088. if (tasha_p->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2089. if (dai_id >= ARRAY_SIZE(vport_slim_check_table)) {
  2090. dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n",
  2091. __func__, dai_id);
  2092. mutex_unlock(&tasha_p->codec_mutex);
  2093. return -EINVAL;
  2094. }
  2095. vtable = vport_slim_check_table[dai_id];
  2096. } else {
  2097. if (dai_id >= ARRAY_SIZE(vport_i2s_check_table)) {
  2098. dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n",
  2099. __func__, dai_id);
  2100. return -EINVAL;
  2101. }
  2102. vtable = vport_i2s_check_table[dai_id];
  2103. }
  2104. switch (dai_id) {
  2105. case AIF1_CAP:
  2106. case AIF2_CAP:
  2107. case AIF3_CAP:
  2108. /* only add to the list if value not set */
  2109. if (enable && !(tasha_p->tx_port_value & 1 << port_id)) {
  2110. if (wcd9xxx_tx_vport_validation(vtable, port_id,
  2111. tasha_p->dai, NUM_CODEC_DAIS)) {
  2112. dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n",
  2113. __func__, port_id);
  2114. mutex_unlock(&tasha_p->codec_mutex);
  2115. return 0;
  2116. }
  2117. tasha_p->tx_port_value |= 1 << port_id;
  2118. list_add_tail(&core->tx_chs[port_id].list,
  2119. &tasha_p->dai[dai_id].wcd9xxx_ch_list
  2120. );
  2121. } else if (!enable && (tasha_p->tx_port_value &
  2122. 1 << port_id)) {
  2123. tasha_p->tx_port_value &= ~(1 << port_id);
  2124. list_del_init(&core->tx_chs[port_id].list);
  2125. } else {
  2126. if (enable)
  2127. dev_dbg(codec->dev, "%s: TX%u port is used by\n"
  2128. "this virtual port\n",
  2129. __func__, port_id);
  2130. else
  2131. dev_dbg(codec->dev, "%s: TX%u port is not used by\n"
  2132. "this virtual port\n",
  2133. __func__, port_id);
  2134. /* avoid update power function */
  2135. mutex_unlock(&tasha_p->codec_mutex);
  2136. return 0;
  2137. }
  2138. break;
  2139. case AIF4_MAD_TX:
  2140. case AIF5_CPE_TX:
  2141. break;
  2142. default:
  2143. pr_err("Unknown AIF %d\n", dai_id);
  2144. mutex_unlock(&tasha_p->codec_mutex);
  2145. return -EINVAL;
  2146. }
  2147. pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__,
  2148. widget->name, widget->sname, tasha_p->tx_port_value,
  2149. widget->shift);
  2150. mutex_unlock(&tasha_p->codec_mutex);
  2151. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
  2152. return 0;
  2153. }
  2154. static int slim_rx_mux_get(struct snd_kcontrol *kcontrol,
  2155. struct snd_ctl_elem_value *ucontrol)
  2156. {
  2157. struct snd_soc_dapm_widget *widget =
  2158. snd_soc_dapm_kcontrol_widget(kcontrol);
  2159. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2160. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2161. ucontrol->value.enumerated.item[0] =
  2162. tasha_p->rx_port_value[widget->shift];
  2163. return 0;
  2164. }
  2165. static const char *const slim_rx_mux_text[] = {
  2166. "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB", "AIF_MIX1_PB"
  2167. };
  2168. static int slim_rx_mux_put(struct snd_kcontrol *kcontrol,
  2169. struct snd_ctl_elem_value *ucontrol)
  2170. {
  2171. struct snd_soc_dapm_widget *widget =
  2172. snd_soc_dapm_kcontrol_widget(kcontrol);
  2173. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2174. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2175. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2176. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  2177. struct snd_soc_dapm_update *update = NULL;
  2178. unsigned int rx_port_value;
  2179. u32 port_id = widget->shift;
  2180. tasha_p->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
  2181. rx_port_value = tasha_p->rx_port_value[port_id];
  2182. pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__,
  2183. widget->name, ucontrol->id.name, rx_port_value,
  2184. widget->shift, ucontrol->value.integer.value[0]);
  2185. mutex_lock(&tasha_p->codec_mutex);
  2186. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2187. if (rx_port_value > 2) {
  2188. dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
  2189. __func__);
  2190. goto err;
  2191. }
  2192. }
  2193. /* value need to match the Virtual port and AIF number */
  2194. switch (rx_port_value) {
  2195. case 0:
  2196. list_del_init(&core->rx_chs[port_id].list);
  2197. break;
  2198. case 1:
  2199. if (wcd9xxx_rx_vport_validation(port_id +
  2200. TASHA_RX_PORT_START_NUMBER,
  2201. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list)) {
  2202. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2203. __func__, port_id);
  2204. goto rtn;
  2205. }
  2206. list_add_tail(&core->rx_chs[port_id].list,
  2207. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list);
  2208. break;
  2209. case 2:
  2210. if (wcd9xxx_rx_vport_validation(port_id +
  2211. TASHA_RX_PORT_START_NUMBER,
  2212. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list)) {
  2213. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2214. __func__, port_id);
  2215. goto rtn;
  2216. }
  2217. list_add_tail(&core->rx_chs[port_id].list,
  2218. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list);
  2219. break;
  2220. case 3:
  2221. if (wcd9xxx_rx_vport_validation(port_id +
  2222. TASHA_RX_PORT_START_NUMBER,
  2223. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list)) {
  2224. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2225. __func__, port_id);
  2226. goto rtn;
  2227. }
  2228. list_add_tail(&core->rx_chs[port_id].list,
  2229. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list);
  2230. break;
  2231. case 4:
  2232. if (wcd9xxx_rx_vport_validation(port_id +
  2233. TASHA_RX_PORT_START_NUMBER,
  2234. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list)) {
  2235. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2236. __func__, port_id);
  2237. goto rtn;
  2238. }
  2239. list_add_tail(&core->rx_chs[port_id].list,
  2240. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list);
  2241. break;
  2242. case 5:
  2243. if (wcd9xxx_rx_vport_validation(port_id +
  2244. TASHA_RX_PORT_START_NUMBER,
  2245. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list)) {
  2246. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2247. __func__, port_id);
  2248. goto rtn;
  2249. }
  2250. list_add_tail(&core->rx_chs[port_id].list,
  2251. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list);
  2252. break;
  2253. default:
  2254. pr_err("Unknown AIF %d\n", rx_port_value);
  2255. goto err;
  2256. }
  2257. rtn:
  2258. mutex_unlock(&tasha_p->codec_mutex);
  2259. snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
  2260. rx_port_value, e, update);
  2261. return 0;
  2262. err:
  2263. mutex_unlock(&tasha_p->codec_mutex);
  2264. return -EINVAL;
  2265. }
  2266. static const struct soc_enum slim_rx_mux_enum =
  2267. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text);
  2268. static const struct snd_kcontrol_new slim_rx_mux[TASHA_RX_MAX] = {
  2269. SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum,
  2270. slim_rx_mux_get, slim_rx_mux_put),
  2271. SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
  2272. slim_rx_mux_get, slim_rx_mux_put),
  2273. SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
  2274. slim_rx_mux_get, slim_rx_mux_put),
  2275. SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
  2276. slim_rx_mux_get, slim_rx_mux_put),
  2277. SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
  2278. slim_rx_mux_get, slim_rx_mux_put),
  2279. SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
  2280. slim_rx_mux_get, slim_rx_mux_put),
  2281. SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
  2282. slim_rx_mux_get, slim_rx_mux_put),
  2283. SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
  2284. slim_rx_mux_get, slim_rx_mux_put),
  2285. };
  2286. static const struct snd_kcontrol_new aif4_vi_mixer[] = {
  2287. SOC_SINGLE_EXT("SPKR_VI_1", SND_SOC_NOPM, TASHA_TX14, 1, 0,
  2288. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2289. SOC_SINGLE_EXT("SPKR_VI_2", SND_SOC_NOPM, TASHA_TX15, 1, 0,
  2290. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2291. };
  2292. static const struct snd_kcontrol_new aif1_cap_mixer[] = {
  2293. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2294. slim_tx_mixer_get, slim_tx_mixer_put),
  2295. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2296. slim_tx_mixer_get, slim_tx_mixer_put),
  2297. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2298. slim_tx_mixer_get, slim_tx_mixer_put),
  2299. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2300. slim_tx_mixer_get, slim_tx_mixer_put),
  2301. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2302. slim_tx_mixer_get, slim_tx_mixer_put),
  2303. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2304. slim_tx_mixer_get, slim_tx_mixer_put),
  2305. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2306. slim_tx_mixer_get, slim_tx_mixer_put),
  2307. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2308. slim_tx_mixer_get, slim_tx_mixer_put),
  2309. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2310. slim_tx_mixer_get, slim_tx_mixer_put),
  2311. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2312. slim_tx_mixer_get, slim_tx_mixer_put),
  2313. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2314. slim_tx_mixer_get, slim_tx_mixer_put),
  2315. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2316. slim_tx_mixer_get, slim_tx_mixer_put),
  2317. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2318. slim_tx_mixer_get, slim_tx_mixer_put),
  2319. };
  2320. static const struct snd_kcontrol_new aif2_cap_mixer[] = {
  2321. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2322. slim_tx_mixer_get, slim_tx_mixer_put),
  2323. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2324. slim_tx_mixer_get, slim_tx_mixer_put),
  2325. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2326. slim_tx_mixer_get, slim_tx_mixer_put),
  2327. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2328. slim_tx_mixer_get, slim_tx_mixer_put),
  2329. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2330. slim_tx_mixer_get, slim_tx_mixer_put),
  2331. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2332. slim_tx_mixer_get, slim_tx_mixer_put),
  2333. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2334. slim_tx_mixer_get, slim_tx_mixer_put),
  2335. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2336. slim_tx_mixer_get, slim_tx_mixer_put),
  2337. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2338. slim_tx_mixer_get, slim_tx_mixer_put),
  2339. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2340. slim_tx_mixer_get, slim_tx_mixer_put),
  2341. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2342. slim_tx_mixer_get, slim_tx_mixer_put),
  2343. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2344. slim_tx_mixer_get, slim_tx_mixer_put),
  2345. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2346. slim_tx_mixer_get, slim_tx_mixer_put),
  2347. };
  2348. static const struct snd_kcontrol_new aif3_cap_mixer[] = {
  2349. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2350. slim_tx_mixer_get, slim_tx_mixer_put),
  2351. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2352. slim_tx_mixer_get, slim_tx_mixer_put),
  2353. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2354. slim_tx_mixer_get, slim_tx_mixer_put),
  2355. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2356. slim_tx_mixer_get, slim_tx_mixer_put),
  2357. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2358. slim_tx_mixer_get, slim_tx_mixer_put),
  2359. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2360. slim_tx_mixer_get, slim_tx_mixer_put),
  2361. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2362. slim_tx_mixer_get, slim_tx_mixer_put),
  2363. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2364. slim_tx_mixer_get, slim_tx_mixer_put),
  2365. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2366. slim_tx_mixer_get, slim_tx_mixer_put),
  2367. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2368. slim_tx_mixer_get, slim_tx_mixer_put),
  2369. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2370. slim_tx_mixer_get, slim_tx_mixer_put),
  2371. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2372. slim_tx_mixer_get, slim_tx_mixer_put),
  2373. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2374. slim_tx_mixer_get, slim_tx_mixer_put),
  2375. };
  2376. static const struct snd_kcontrol_new aif4_mad_mixer[] = {
  2377. SOC_SINGLE_EXT("SLIM TX12", SND_SOC_NOPM, TASHA_TX12, 1, 0,
  2378. slim_tx_mixer_get, slim_tx_mixer_put),
  2379. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2380. slim_tx_mixer_get, slim_tx_mixer_put),
  2381. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, 0, 1, 0,
  2382. slim_tx_mixer_get, slim_tx_mixer_put),
  2383. };
  2384. static const struct snd_kcontrol_new rx_int1_spline_mix_switch[] = {
  2385. SOC_DAPM_SINGLE("HPHL Switch", SND_SOC_NOPM, 0, 1, 0)
  2386. };
  2387. static const struct snd_kcontrol_new rx_int2_spline_mix_switch[] = {
  2388. SOC_DAPM_SINGLE("HPHR Switch", SND_SOC_NOPM, 0, 1, 0)
  2389. };
  2390. static const struct snd_kcontrol_new rx_int3_spline_mix_switch[] = {
  2391. SOC_DAPM_SINGLE("LO1 Switch", SND_SOC_NOPM, 0, 1, 0)
  2392. };
  2393. static const struct snd_kcontrol_new rx_int4_spline_mix_switch[] = {
  2394. SOC_DAPM_SINGLE("LO2 Switch", SND_SOC_NOPM, 0, 1, 0)
  2395. };
  2396. static const struct snd_kcontrol_new rx_int5_spline_mix_switch[] = {
  2397. SOC_DAPM_SINGLE("LO3 Switch", SND_SOC_NOPM, 0, 1, 0)
  2398. };
  2399. static const struct snd_kcontrol_new rx_int6_spline_mix_switch[] = {
  2400. SOC_DAPM_SINGLE("LO4 Switch", SND_SOC_NOPM, 0, 1, 0)
  2401. };
  2402. static const struct snd_kcontrol_new rx_int7_spline_mix_switch[] = {
  2403. SOC_DAPM_SINGLE("SPKRL Switch", SND_SOC_NOPM, 0, 1, 0)
  2404. };
  2405. static const struct snd_kcontrol_new rx_int8_spline_mix_switch[] = {
  2406. SOC_DAPM_SINGLE("SPKRR Switch", SND_SOC_NOPM, 0, 1, 0)
  2407. };
  2408. static const struct snd_kcontrol_new rx_int5_vbat_mix_switch[] = {
  2409. SOC_DAPM_SINGLE("LO3 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2410. };
  2411. static const struct snd_kcontrol_new rx_int6_vbat_mix_switch[] = {
  2412. SOC_DAPM_SINGLE("LO4 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2413. };
  2414. static const struct snd_kcontrol_new rx_int7_vbat_mix_switch[] = {
  2415. SOC_DAPM_SINGLE("SPKRL VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2416. };
  2417. static const struct snd_kcontrol_new rx_int8_vbat_mix_switch[] = {
  2418. SOC_DAPM_SINGLE("SPKRR VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2419. };
  2420. static const struct snd_kcontrol_new cpe_in_mix_switch[] = {
  2421. SOC_DAPM_SINGLE("MAD_BYPASS", SND_SOC_NOPM, 0, 1, 0)
  2422. };
  2423. static int tasha_put_iir_enable_audio_mixer(
  2424. struct snd_kcontrol *kcontrol,
  2425. struct snd_ctl_elem_value *ucontrol)
  2426. {
  2427. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2428. int iir_idx = ((struct soc_multi_mixer_control *)
  2429. kcontrol->private_value)->reg;
  2430. int band_idx = ((struct soc_multi_mixer_control *)
  2431. kcontrol->private_value)->shift;
  2432. bool iir_band_en_status;
  2433. int value = ucontrol->value.integer.value[0];
  2434. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  2435. /* Mask first 5 bits, 6-8 are reserved */
  2436. snd_soc_update_bits(codec, iir_reg, (1 << band_idx),
  2437. (value << band_idx));
  2438. iir_band_en_status = ((snd_soc_read(codec, iir_reg) &
  2439. (1 << band_idx)) != 0);
  2440. pr_debug("%s: IIR #%d band #%d enable %d\n", __func__,
  2441. iir_idx, band_idx, iir_band_en_status);
  2442. return 0;
  2443. }
  2444. static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec,
  2445. int iir_idx, int band_idx,
  2446. int coeff_idx)
  2447. {
  2448. uint32_t value = 0;
  2449. /* Address does not automatically update if reading */
  2450. snd_soc_write(codec,
  2451. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2452. ((band_idx * BAND_MAX + coeff_idx)
  2453. * sizeof(uint32_t)) & 0x7F);
  2454. value |= snd_soc_read(codec,
  2455. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx));
  2456. snd_soc_write(codec,
  2457. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2458. ((band_idx * BAND_MAX + coeff_idx)
  2459. * sizeof(uint32_t) + 1) & 0x7F);
  2460. value |= (snd_soc_read(codec,
  2461. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2462. 16 * iir_idx)) << 8);
  2463. snd_soc_write(codec,
  2464. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2465. ((band_idx * BAND_MAX + coeff_idx)
  2466. * sizeof(uint32_t) + 2) & 0x7F);
  2467. value |= (snd_soc_read(codec,
  2468. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2469. 16 * iir_idx)) << 16);
  2470. snd_soc_write(codec,
  2471. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2472. ((band_idx * BAND_MAX + coeff_idx)
  2473. * sizeof(uint32_t) + 3) & 0x7F);
  2474. /* Mask bits top 2 bits since they are reserved */
  2475. value |= ((snd_soc_read(codec,
  2476. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2477. 16 * iir_idx)) & 0x3F) << 24);
  2478. return value;
  2479. }
  2480. static int tasha_get_iir_band_audio_mixer(
  2481. struct snd_kcontrol *kcontrol,
  2482. struct snd_ctl_elem_value *ucontrol)
  2483. {
  2484. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2485. int iir_idx = ((struct soc_multi_mixer_control *)
  2486. kcontrol->private_value)->reg;
  2487. int band_idx = ((struct soc_multi_mixer_control *)
  2488. kcontrol->private_value)->shift;
  2489. ucontrol->value.integer.value[0] =
  2490. get_iir_band_coeff(codec, iir_idx, band_idx, 0);
  2491. ucontrol->value.integer.value[1] =
  2492. get_iir_band_coeff(codec, iir_idx, band_idx, 1);
  2493. ucontrol->value.integer.value[2] =
  2494. get_iir_band_coeff(codec, iir_idx, band_idx, 2);
  2495. ucontrol->value.integer.value[3] =
  2496. get_iir_band_coeff(codec, iir_idx, band_idx, 3);
  2497. ucontrol->value.integer.value[4] =
  2498. get_iir_band_coeff(codec, iir_idx, band_idx, 4);
  2499. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  2500. "%s: IIR #%d band #%d b1 = 0x%x\n"
  2501. "%s: IIR #%d band #%d b2 = 0x%x\n"
  2502. "%s: IIR #%d band #%d a1 = 0x%x\n"
  2503. "%s: IIR #%d band #%d a2 = 0x%x\n",
  2504. __func__, iir_idx, band_idx,
  2505. (uint32_t)ucontrol->value.integer.value[0],
  2506. __func__, iir_idx, band_idx,
  2507. (uint32_t)ucontrol->value.integer.value[1],
  2508. __func__, iir_idx, band_idx,
  2509. (uint32_t)ucontrol->value.integer.value[2],
  2510. __func__, iir_idx, band_idx,
  2511. (uint32_t)ucontrol->value.integer.value[3],
  2512. __func__, iir_idx, band_idx,
  2513. (uint32_t)ucontrol->value.integer.value[4]);
  2514. return 0;
  2515. }
  2516. static void set_iir_band_coeff(struct snd_soc_codec *codec,
  2517. int iir_idx, int band_idx,
  2518. uint32_t value)
  2519. {
  2520. snd_soc_write(codec,
  2521. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2522. (value & 0xFF));
  2523. snd_soc_write(codec,
  2524. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2525. (value >> 8) & 0xFF);
  2526. snd_soc_write(codec,
  2527. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2528. (value >> 16) & 0xFF);
  2529. /* Mask top 2 bits, 7-8 are reserved */
  2530. snd_soc_write(codec,
  2531. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2532. (value >> 24) & 0x3F);
  2533. }
  2534. static void tasha_codec_enable_int_port(struct wcd9xxx_codec_dai_data *dai,
  2535. struct snd_soc_codec *codec)
  2536. {
  2537. struct wcd9xxx_ch *ch;
  2538. int port_num = 0;
  2539. unsigned short reg = 0;
  2540. u8 val = 0;
  2541. struct tasha_priv *tasha_p;
  2542. if (!dai || !codec) {
  2543. pr_err("%s: Invalid params\n", __func__);
  2544. return;
  2545. }
  2546. tasha_p = snd_soc_codec_get_drvdata(codec);
  2547. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2548. if (ch->port >= TASHA_RX_PORT_START_NUMBER) {
  2549. port_num = ch->port - TASHA_RX_PORT_START_NUMBER;
  2550. reg = TASHA_SLIM_PGD_PORT_INT_EN0 + (port_num / 8);
  2551. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2552. reg);
  2553. if (!(val & BYTE_BIT_MASK(port_num))) {
  2554. val |= BYTE_BIT_MASK(port_num);
  2555. wcd9xxx_interface_reg_write(
  2556. tasha_p->wcd9xxx, reg, val);
  2557. val = wcd9xxx_interface_reg_read(
  2558. tasha_p->wcd9xxx, reg);
  2559. }
  2560. } else {
  2561. port_num = ch->port;
  2562. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 + (port_num / 8);
  2563. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2564. reg);
  2565. if (!(val & BYTE_BIT_MASK(port_num))) {
  2566. val |= BYTE_BIT_MASK(port_num);
  2567. wcd9xxx_interface_reg_write(tasha_p->wcd9xxx,
  2568. reg, val);
  2569. val = wcd9xxx_interface_reg_read(
  2570. tasha_p->wcd9xxx, reg);
  2571. }
  2572. }
  2573. }
  2574. }
  2575. static int tasha_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai,
  2576. bool up)
  2577. {
  2578. int ret = 0;
  2579. struct wcd9xxx_ch *ch;
  2580. if (up) {
  2581. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2582. ret = wcd9xxx_get_slave_port(ch->ch_num);
  2583. if (ret < 0) {
  2584. pr_err("%s: Invalid slave port ID: %d\n",
  2585. __func__, ret);
  2586. ret = -EINVAL;
  2587. } else {
  2588. set_bit(ret, &dai->ch_mask);
  2589. }
  2590. }
  2591. } else {
  2592. ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0),
  2593. msecs_to_jiffies(
  2594. TASHA_SLIM_CLOSE_TIMEOUT));
  2595. if (!ret) {
  2596. pr_err("%s: Slim close tx/rx wait timeout, ch_mask:0x%lx\n",
  2597. __func__, dai->ch_mask);
  2598. ret = -ETIMEDOUT;
  2599. } else {
  2600. ret = 0;
  2601. }
  2602. }
  2603. return ret;
  2604. }
  2605. static int tasha_codec_enable_slimrx(struct snd_soc_dapm_widget *w,
  2606. struct snd_kcontrol *kcontrol,
  2607. int event)
  2608. {
  2609. struct wcd9xxx *core;
  2610. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2611. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2612. int ret = 0;
  2613. struct wcd9xxx_codec_dai_data *dai;
  2614. core = dev_get_drvdata(codec->dev->parent);
  2615. dev_dbg(codec->dev, "%s: event called! codec name %s num_dai %d\n"
  2616. "stream name %s event %d\n",
  2617. __func__, codec->component.name,
  2618. codec->component.num_dai, w->sname, event);
  2619. /* Execute the callback only if interface type is slimbus */
  2620. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2621. return 0;
  2622. dai = &tasha_p->dai[w->shift];
  2623. dev_dbg(codec->dev, "%s: w->name %s w->shift %d event %d\n",
  2624. __func__, w->name, w->shift, event);
  2625. switch (event) {
  2626. case SND_SOC_DAPM_POST_PMU:
  2627. dai->bus_down_in_recovery = false;
  2628. tasha_codec_enable_int_port(dai, codec);
  2629. (void) tasha_codec_enable_slim_chmask(dai, true);
  2630. ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2631. dai->rate, dai->bit_width,
  2632. &dai->grph);
  2633. break;
  2634. case SND_SOC_DAPM_PRE_PMD:
  2635. tasha_codec_vote_max_bw(codec, true);
  2636. break;
  2637. case SND_SOC_DAPM_POST_PMD:
  2638. ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list,
  2639. dai->grph);
  2640. dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n",
  2641. __func__, ret);
  2642. if (!dai->bus_down_in_recovery)
  2643. ret = tasha_codec_enable_slim_chmask(dai, false);
  2644. else
  2645. dev_dbg(codec->dev,
  2646. "%s: bus in recovery skip enable slim_chmask",
  2647. __func__);
  2648. ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2649. dai->grph);
  2650. break;
  2651. }
  2652. return ret;
  2653. }
  2654. static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w,
  2655. struct snd_kcontrol *kcontrol,
  2656. int event)
  2657. {
  2658. struct wcd9xxx *core = NULL;
  2659. struct snd_soc_codec *codec = NULL;
  2660. struct tasha_priv *tasha_p = NULL;
  2661. int ret = 0;
  2662. struct wcd9xxx_codec_dai_data *dai = NULL;
  2663. if (!w) {
  2664. pr_err("%s invalid params\n", __func__);
  2665. return -EINVAL;
  2666. }
  2667. codec = snd_soc_dapm_to_codec(w->dapm);
  2668. tasha_p = snd_soc_codec_get_drvdata(codec);
  2669. core = tasha_p->wcd9xxx;
  2670. dev_dbg(codec->dev, "%s: num_dai %d stream name %s\n",
  2671. __func__, codec->component.num_dai, w->sname);
  2672. /* Execute the callback only if interface type is slimbus */
  2673. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2674. dev_err(codec->dev, "%s Interface is not correct", __func__);
  2675. return 0;
  2676. }
  2677. dev_dbg(codec->dev, "%s(): w->name %s event %d w->shift %d\n",
  2678. __func__, w->name, event, w->shift);
  2679. if (w->shift != AIF4_VIFEED) {
  2680. pr_err("%s Error in enabling the tx path\n", __func__);
  2681. ret = -EINVAL;
  2682. goto out_vi;
  2683. }
  2684. dai = &tasha_p->dai[w->shift];
  2685. switch (event) {
  2686. case SND_SOC_DAPM_POST_PMU:
  2687. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2688. dev_dbg(codec->dev, "%s: spkr1 enabled\n", __func__);
  2689. /* Enable V&I sensing */
  2690. snd_soc_update_bits(codec,
  2691. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2692. snd_soc_update_bits(codec,
  2693. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2694. 0x20);
  2695. snd_soc_update_bits(codec,
  2696. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x00);
  2697. snd_soc_update_bits(codec,
  2698. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x0F,
  2699. 0x00);
  2700. snd_soc_update_bits(codec,
  2701. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10);
  2702. snd_soc_update_bits(codec,
  2703. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2704. 0x10);
  2705. snd_soc_update_bits(codec,
  2706. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00);
  2707. snd_soc_update_bits(codec,
  2708. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2709. 0x00);
  2710. }
  2711. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2712. pr_debug("%s: spkr2 enabled\n", __func__);
  2713. /* Enable V&I sensing */
  2714. snd_soc_update_bits(codec,
  2715. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2716. 0x20);
  2717. snd_soc_update_bits(codec,
  2718. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2719. 0x20);
  2720. snd_soc_update_bits(codec,
  2721. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x0F,
  2722. 0x00);
  2723. snd_soc_update_bits(codec,
  2724. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x0F,
  2725. 0x00);
  2726. snd_soc_update_bits(codec,
  2727. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2728. 0x10);
  2729. snd_soc_update_bits(codec,
  2730. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2731. 0x10);
  2732. snd_soc_update_bits(codec,
  2733. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2734. 0x00);
  2735. snd_soc_update_bits(codec,
  2736. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2737. 0x00);
  2738. }
  2739. dai->bus_down_in_recovery = false;
  2740. tasha_codec_enable_int_port(dai, codec);
  2741. (void) tasha_codec_enable_slim_chmask(dai, true);
  2742. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2743. dai->rate, dai->bit_width,
  2744. &dai->grph);
  2745. break;
  2746. case SND_SOC_DAPM_POST_PMD:
  2747. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2748. dai->grph);
  2749. if (ret)
  2750. dev_err(codec->dev, "%s error in close_slim_sch_tx %d\n",
  2751. __func__, ret);
  2752. if (!dai->bus_down_in_recovery)
  2753. ret = tasha_codec_enable_slim_chmask(dai, false);
  2754. if (ret < 0) {
  2755. ret = wcd9xxx_disconnect_port(core,
  2756. &dai->wcd9xxx_ch_list,
  2757. dai->grph);
  2758. dev_dbg(codec->dev, "%s: Disconnect TX port, ret = %d\n",
  2759. __func__, ret);
  2760. }
  2761. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2762. /* Disable V&I sensing */
  2763. dev_dbg(codec->dev, "%s: spkr1 disabled\n", __func__);
  2764. snd_soc_update_bits(codec,
  2765. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2766. snd_soc_update_bits(codec,
  2767. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2768. 0x20);
  2769. snd_soc_update_bits(codec,
  2770. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00);
  2771. snd_soc_update_bits(codec,
  2772. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2773. 0x00);
  2774. }
  2775. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2776. /* Disable V&I sensing */
  2777. dev_dbg(codec->dev, "%s: spkr2 disabled\n", __func__);
  2778. snd_soc_update_bits(codec,
  2779. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2780. 0x20);
  2781. snd_soc_update_bits(codec,
  2782. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2783. 0x20);
  2784. snd_soc_update_bits(codec,
  2785. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2786. 0x00);
  2787. snd_soc_update_bits(codec,
  2788. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2789. 0x00);
  2790. }
  2791. break;
  2792. }
  2793. out_vi:
  2794. return ret;
  2795. }
  2796. /*
  2797. * __tasha_codec_enable_slimtx: Enable the slimbus slave port
  2798. * for TX path
  2799. * @codec: Handle to the codec for which the slave port is to be
  2800. * enabled.
  2801. * @dai_data: The dai specific data for dai which is enabled.
  2802. */
  2803. static int __tasha_codec_enable_slimtx(struct snd_soc_codec *codec,
  2804. int event, struct wcd9xxx_codec_dai_data *dai)
  2805. {
  2806. struct wcd9xxx *core;
  2807. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2808. int ret = 0;
  2809. /* Execute the callback only if interface type is slimbus */
  2810. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2811. return 0;
  2812. dev_dbg(codec->dev,
  2813. "%s: event = %d\n", __func__, event);
  2814. core = dev_get_drvdata(codec->dev->parent);
  2815. switch (event) {
  2816. case SND_SOC_DAPM_POST_PMU:
  2817. dai->bus_down_in_recovery = false;
  2818. tasha_codec_enable_int_port(dai, codec);
  2819. (void) tasha_codec_enable_slim_chmask(dai, true);
  2820. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2821. dai->rate, dai->bit_width,
  2822. &dai->grph);
  2823. break;
  2824. case SND_SOC_DAPM_POST_PMD:
  2825. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2826. dai->grph);
  2827. if (!dai->bus_down_in_recovery)
  2828. ret = tasha_codec_enable_slim_chmask(dai, false);
  2829. if (ret < 0) {
  2830. ret = wcd9xxx_disconnect_port(core,
  2831. &dai->wcd9xxx_ch_list,
  2832. dai->grph);
  2833. pr_debug("%s: Disconnect TX port, ret = %d\n",
  2834. __func__, ret);
  2835. }
  2836. break;
  2837. }
  2838. return ret;
  2839. }
  2840. static int tasha_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
  2841. struct snd_kcontrol *kcontrol,
  2842. int event)
  2843. {
  2844. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2845. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2846. struct wcd9xxx_codec_dai_data *dai;
  2847. dev_dbg(codec->dev,
  2848. "%s: w->name %s, w->shift = %d, num_dai %d stream name %s\n",
  2849. __func__, w->name, w->shift,
  2850. codec->component.num_dai, w->sname);
  2851. dai = &tasha_p->dai[w->shift];
  2852. return __tasha_codec_enable_slimtx(codec, event, dai);
  2853. }
  2854. static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_codec *codec, int event)
  2855. {
  2856. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2857. struct wcd9xxx_codec_dai_data *dai;
  2858. u8 bit_width, rate, buf_period;
  2859. dai = &tasha_p->dai[AIF4_MAD_TX];
  2860. switch (event) {
  2861. case SND_SOC_DAPM_POST_PMU:
  2862. switch (dai->bit_width) {
  2863. case 32:
  2864. bit_width = 0xF;
  2865. break;
  2866. case 24:
  2867. bit_width = 0xE;
  2868. break;
  2869. case 20:
  2870. bit_width = 0xD;
  2871. break;
  2872. case 16:
  2873. default:
  2874. bit_width = 0x0;
  2875. break;
  2876. }
  2877. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x0F,
  2878. bit_width);
  2879. switch (dai->rate) {
  2880. case 384000:
  2881. rate = 0x30;
  2882. break;
  2883. case 192000:
  2884. rate = 0x20;
  2885. break;
  2886. case 48000:
  2887. rate = 0x10;
  2888. break;
  2889. case 16000:
  2890. default:
  2891. rate = 0x00;
  2892. break;
  2893. }
  2894. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x70,
  2895. rate);
  2896. buf_period = (dai->rate * (dai->bit_width/8)) / (16*1000);
  2897. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD,
  2898. 0xFF, buf_period);
  2899. dev_dbg(codec->dev, "%s: PP buffer period= 0x%x\n",
  2900. __func__, buf_period);
  2901. break;
  2902. case SND_SOC_DAPM_POST_PMD:
  2903. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x3C);
  2904. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD, 0x60);
  2905. break;
  2906. default:
  2907. break;
  2908. }
  2909. }
  2910. /*
  2911. * tasha_codec_get_mad_port_id: Callback function that will be invoked
  2912. * to get the port ID for MAD.
  2913. * @codec: Handle to the codec
  2914. * @port_id: cpe port_id needs to enable
  2915. */
  2916. static int tasha_codec_get_mad_port_id(struct snd_soc_codec *codec,
  2917. u16 *port_id)
  2918. {
  2919. struct tasha_priv *tasha_p;
  2920. struct wcd9xxx_codec_dai_data *dai;
  2921. struct wcd9xxx_ch *ch;
  2922. if (!port_id || !codec)
  2923. return -EINVAL;
  2924. tasha_p = snd_soc_codec_get_drvdata(codec);
  2925. if (!tasha_p)
  2926. return -EINVAL;
  2927. dai = &tasha_p->dai[AIF4_MAD_TX];
  2928. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2929. if (ch->port == TASHA_TX12)
  2930. *port_id = WCD_CPE_AFE_OUT_PORT_2;
  2931. else if (ch->port == TASHA_TX13)
  2932. *port_id = WCD_CPE_AFE_OUT_PORT_4;
  2933. else {
  2934. dev_err(codec->dev, "%s: invalid mad_port = %d\n",
  2935. __func__, ch->port);
  2936. return -EINVAL;
  2937. }
  2938. }
  2939. dev_dbg(codec->dev, "%s: port_id = %d\n", __func__, *port_id);
  2940. return 0;
  2941. }
  2942. /*
  2943. * tasha_codec_enable_slimtx_mad: Callback function that will be invoked
  2944. * to setup the slave port for MAD.
  2945. * @codec: Handle to the codec
  2946. * @event: Indicates whether to enable or disable the slave port
  2947. */
  2948. static int tasha_codec_enable_slimtx_mad(struct snd_soc_codec *codec,
  2949. u8 event)
  2950. {
  2951. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2952. struct wcd9xxx_codec_dai_data *dai;
  2953. struct wcd9xxx_ch *ch;
  2954. int dapm_event = SND_SOC_DAPM_POST_PMU;
  2955. u16 port = 0;
  2956. int ret = 0;
  2957. dai = &tasha_p->dai[AIF4_MAD_TX];
  2958. if (event == 0)
  2959. dapm_event = SND_SOC_DAPM_POST_PMD;
  2960. dev_dbg(codec->dev,
  2961. "%s: mad_channel, event = 0x%x\n",
  2962. __func__, event);
  2963. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2964. dev_dbg(codec->dev, "%s: mad_port = %d, event = 0x%x\n",
  2965. __func__, ch->port, event);
  2966. if (ch->port == TASHA_TX13) {
  2967. tasha_codec_cpe_pp_set_cfg(codec, dapm_event);
  2968. port = TASHA_TX13;
  2969. break;
  2970. }
  2971. }
  2972. ret = __tasha_codec_enable_slimtx(codec, dapm_event, dai);
  2973. if (port == TASHA_TX13) {
  2974. switch (dapm_event) {
  2975. case SND_SOC_DAPM_POST_PMU:
  2976. snd_soc_update_bits(codec,
  2977. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2978. 0x20, 0x00);
  2979. snd_soc_update_bits(codec,
  2980. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2981. 0x03, 0x02);
  2982. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2983. 0x80, 0x80);
  2984. break;
  2985. case SND_SOC_DAPM_POST_PMD:
  2986. snd_soc_update_bits(codec,
  2987. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2988. 0x20, 0x20);
  2989. snd_soc_update_bits(codec,
  2990. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2991. 0x03, 0x00);
  2992. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2993. 0x80, 0x00);
  2994. break;
  2995. }
  2996. }
  2997. return ret;
  2998. }
  2999. static int tasha_put_iir_band_audio_mixer(
  3000. struct snd_kcontrol *kcontrol,
  3001. struct snd_ctl_elem_value *ucontrol)
  3002. {
  3003. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3004. int iir_idx = ((struct soc_multi_mixer_control *)
  3005. kcontrol->private_value)->reg;
  3006. int band_idx = ((struct soc_multi_mixer_control *)
  3007. kcontrol->private_value)->shift;
  3008. /*
  3009. * Mask top bit it is reserved
  3010. * Updates addr automatically for each B2 write
  3011. */
  3012. snd_soc_write(codec,
  3013. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  3014. (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
  3015. set_iir_band_coeff(codec, iir_idx, band_idx,
  3016. ucontrol->value.integer.value[0]);
  3017. set_iir_band_coeff(codec, iir_idx, band_idx,
  3018. ucontrol->value.integer.value[1]);
  3019. set_iir_band_coeff(codec, iir_idx, band_idx,
  3020. ucontrol->value.integer.value[2]);
  3021. set_iir_band_coeff(codec, iir_idx, band_idx,
  3022. ucontrol->value.integer.value[3]);
  3023. set_iir_band_coeff(codec, iir_idx, band_idx,
  3024. ucontrol->value.integer.value[4]);
  3025. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  3026. "%s: IIR #%d band #%d b1 = 0x%x\n"
  3027. "%s: IIR #%d band #%d b2 = 0x%x\n"
  3028. "%s: IIR #%d band #%d a1 = 0x%x\n"
  3029. "%s: IIR #%d band #%d a2 = 0x%x\n",
  3030. __func__, iir_idx, band_idx,
  3031. get_iir_band_coeff(codec, iir_idx, band_idx, 0),
  3032. __func__, iir_idx, band_idx,
  3033. get_iir_band_coeff(codec, iir_idx, band_idx, 1),
  3034. __func__, iir_idx, band_idx,
  3035. get_iir_band_coeff(codec, iir_idx, band_idx, 2),
  3036. __func__, iir_idx, band_idx,
  3037. get_iir_band_coeff(codec, iir_idx, band_idx, 3),
  3038. __func__, iir_idx, band_idx,
  3039. get_iir_band_coeff(codec, iir_idx, band_idx, 4));
  3040. return 0;
  3041. }
  3042. static int tasha_get_compander(struct snd_kcontrol *kcontrol,
  3043. struct snd_ctl_elem_value *ucontrol)
  3044. {
  3045. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3046. int comp = ((struct soc_multi_mixer_control *)
  3047. kcontrol->private_value)->shift;
  3048. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3049. ucontrol->value.integer.value[0] = tasha->comp_enabled[comp];
  3050. return 0;
  3051. }
  3052. static int tasha_set_compander(struct snd_kcontrol *kcontrol,
  3053. struct snd_ctl_elem_value *ucontrol)
  3054. {
  3055. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3056. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3057. int comp = ((struct soc_multi_mixer_control *)
  3058. kcontrol->private_value)->shift;
  3059. int value = ucontrol->value.integer.value[0];
  3060. pr_debug("%s: Compander %d enable current %d, new %d\n",
  3061. __func__, comp + 1, tasha->comp_enabled[comp], value);
  3062. tasha->comp_enabled[comp] = value;
  3063. /* Any specific register configuration for compander */
  3064. switch (comp) {
  3065. case COMPANDER_1:
  3066. /* Set Gain Source Select based on compander enable/disable */
  3067. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0x20,
  3068. (value ? 0x00:0x20));
  3069. break;
  3070. case COMPANDER_2:
  3071. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0x20,
  3072. (value ? 0x00:0x20));
  3073. break;
  3074. case COMPANDER_3:
  3075. break;
  3076. case COMPANDER_4:
  3077. break;
  3078. case COMPANDER_5:
  3079. snd_soc_update_bits(codec, WCD9335_SE_LO_LO3_GAIN, 0x20,
  3080. (value ? 0x00:0x20));
  3081. break;
  3082. case COMPANDER_6:
  3083. snd_soc_update_bits(codec, WCD9335_SE_LO_LO4_GAIN, 0x20,
  3084. (value ? 0x00:0x20));
  3085. break;
  3086. case COMPANDER_7:
  3087. break;
  3088. case COMPANDER_8:
  3089. break;
  3090. default:
  3091. /*
  3092. * if compander is not enabled for any interpolator,
  3093. * it does not cause any audio failure, so do not
  3094. * return error in this case, but just print a log
  3095. */
  3096. dev_warn(codec->dev, "%s: unknown compander: %d\n",
  3097. __func__, comp);
  3098. };
  3099. return 0;
  3100. }
  3101. static void tasha_codec_init_flyback(struct snd_soc_codec *codec)
  3102. {
  3103. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x00);
  3104. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x00);
  3105. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0x0F, 0x00);
  3106. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0xF0, 0x00);
  3107. }
  3108. static int tasha_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
  3109. struct snd_kcontrol *kcontrol, int event)
  3110. {
  3111. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3112. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3113. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3114. switch (event) {
  3115. case SND_SOC_DAPM_PRE_PMU:
  3116. tasha->rx_bias_count++;
  3117. if (tasha->rx_bias_count == 1) {
  3118. if (TASHA_IS_2_0(tasha->wcd9xxx))
  3119. tasha_codec_init_flyback(codec);
  3120. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3121. 0x01, 0x01);
  3122. }
  3123. break;
  3124. case SND_SOC_DAPM_POST_PMD:
  3125. tasha->rx_bias_count--;
  3126. if (!tasha->rx_bias_count)
  3127. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3128. 0x01, 0x00);
  3129. break;
  3130. };
  3131. dev_dbg(codec->dev, "%s: Current RX BIAS user count: %d\n", __func__,
  3132. tasha->rx_bias_count);
  3133. return 0;
  3134. }
  3135. static void tasha_realign_anc_coeff(struct snd_soc_codec *codec,
  3136. u16 reg1, u16 reg2)
  3137. {
  3138. u8 val1, val2, tmpval1, tmpval2;
  3139. snd_soc_write(codec, reg1, 0x00);
  3140. tmpval1 = snd_soc_read(codec, reg2);
  3141. tmpval2 = snd_soc_read(codec, reg2);
  3142. snd_soc_write(codec, reg1, 0x00);
  3143. snd_soc_write(codec, reg2, 0xFF);
  3144. snd_soc_write(codec, reg1, 0x01);
  3145. snd_soc_write(codec, reg2, 0xFF);
  3146. snd_soc_write(codec, reg1, 0x00);
  3147. val1 = snd_soc_read(codec, reg2);
  3148. val2 = snd_soc_read(codec, reg2);
  3149. if (val1 == 0x0F && val2 == 0xFF) {
  3150. dev_dbg(codec->dev, "%s: ANC0 co-eff index re-aligned\n",
  3151. __func__);
  3152. snd_soc_read(codec, reg2);
  3153. snd_soc_write(codec, reg1, 0x00);
  3154. snd_soc_write(codec, reg2, tmpval2);
  3155. snd_soc_write(codec, reg1, 0x01);
  3156. snd_soc_write(codec, reg2, tmpval1);
  3157. } else if (val1 == 0xFF && val2 == 0x0F) {
  3158. dev_dbg(codec->dev, "%s: ANC1 co-eff index already aligned\n",
  3159. __func__);
  3160. snd_soc_write(codec, reg1, 0x00);
  3161. snd_soc_write(codec, reg2, tmpval1);
  3162. snd_soc_write(codec, reg1, 0x01);
  3163. snd_soc_write(codec, reg2, tmpval2);
  3164. } else {
  3165. dev_err(codec->dev, "%s: ANC0 co-eff index not aligned\n",
  3166. __func__);
  3167. }
  3168. }
  3169. static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w,
  3170. struct snd_kcontrol *kcontrol, int event)
  3171. {
  3172. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3173. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3174. const char *filename;
  3175. const struct firmware *fw;
  3176. int i;
  3177. int ret = 0;
  3178. int num_anc_slots;
  3179. struct wcd9xxx_anc_header *anc_head;
  3180. struct firmware_cal *hwdep_cal = NULL;
  3181. u32 anc_writes_size = 0;
  3182. u32 anc_cal_size = 0;
  3183. int anc_size_remaining;
  3184. u32 *anc_ptr;
  3185. u16 reg;
  3186. u8 mask, val;
  3187. size_t cal_size;
  3188. const void *data;
  3189. if (!tasha->anc_func)
  3190. return 0;
  3191. switch (event) {
  3192. case SND_SOC_DAPM_PRE_PMU:
  3193. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_ANC_CAL);
  3194. if (hwdep_cal) {
  3195. data = hwdep_cal->data;
  3196. cal_size = hwdep_cal->size;
  3197. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  3198. __func__);
  3199. } else {
  3200. filename = "wcd9335/wcd9335_anc.bin";
  3201. ret = request_firmware(&fw, filename, codec->dev);
  3202. if (ret != 0) {
  3203. dev_err(codec->dev,
  3204. "Failed to acquire ANC data: %d\n", ret);
  3205. return -ENODEV;
  3206. }
  3207. if (!fw) {
  3208. dev_err(codec->dev, "failed to get anc fw");
  3209. return -ENODEV;
  3210. }
  3211. data = fw->data;
  3212. cal_size = fw->size;
  3213. dev_dbg(codec->dev,
  3214. "%s: using request_firmware calibration\n", __func__);
  3215. }
  3216. if (cal_size < sizeof(struct wcd9xxx_anc_header)) {
  3217. dev_err(codec->dev, "Not enough data\n");
  3218. ret = -ENOMEM;
  3219. goto err;
  3220. }
  3221. /* First number is the number of register writes */
  3222. anc_head = (struct wcd9xxx_anc_header *)(data);
  3223. anc_ptr = (u32 *)(data +
  3224. sizeof(struct wcd9xxx_anc_header));
  3225. anc_size_remaining = cal_size -
  3226. sizeof(struct wcd9xxx_anc_header);
  3227. num_anc_slots = anc_head->num_anc_slots;
  3228. if (tasha->anc_slot >= num_anc_slots) {
  3229. dev_err(codec->dev, "Invalid ANC slot selected\n");
  3230. ret = -EINVAL;
  3231. goto err;
  3232. }
  3233. for (i = 0; i < num_anc_slots; i++) {
  3234. if (anc_size_remaining < TASHA_PACKED_REG_SIZE) {
  3235. dev_err(codec->dev,
  3236. "Invalid register format\n");
  3237. ret = -EINVAL;
  3238. goto err;
  3239. }
  3240. anc_writes_size = (u32)(*anc_ptr);
  3241. anc_size_remaining -= sizeof(u32);
  3242. anc_ptr += 1;
  3243. if (anc_writes_size * TASHA_PACKED_REG_SIZE
  3244. > anc_size_remaining) {
  3245. dev_err(codec->dev,
  3246. "Invalid register format\n");
  3247. ret = -EINVAL;
  3248. goto err;
  3249. }
  3250. if (tasha->anc_slot == i)
  3251. break;
  3252. anc_size_remaining -= (anc_writes_size *
  3253. TASHA_PACKED_REG_SIZE);
  3254. anc_ptr += anc_writes_size;
  3255. }
  3256. if (i == num_anc_slots) {
  3257. dev_err(codec->dev, "Selected ANC slot not present\n");
  3258. ret = -EINVAL;
  3259. goto err;
  3260. }
  3261. i = 0;
  3262. anc_cal_size = anc_writes_size;
  3263. if (!strcmp(w->name, "RX INT0 DAC") ||
  3264. !strcmp(w->name, "ANC SPK1 PA"))
  3265. tasha_realign_anc_coeff(codec,
  3266. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3267. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3268. if (!strcmp(w->name, "RX INT1 DAC") ||
  3269. !strcmp(w->name, "RX INT3 DAC")) {
  3270. tasha_realign_anc_coeff(codec,
  3271. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3272. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3273. anc_writes_size = anc_cal_size / 2;
  3274. snd_soc_update_bits(codec,
  3275. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x39, 0x39);
  3276. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3277. !strcmp(w->name, "RX INT4 DAC")) {
  3278. tasha_realign_anc_coeff(codec,
  3279. WCD9335_CDC_ANC1_IIR_COEFF_1_CTL,
  3280. WCD9335_CDC_ANC1_IIR_COEFF_2_CTL);
  3281. i = anc_cal_size / 2;
  3282. snd_soc_update_bits(codec,
  3283. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x39, 0x39);
  3284. }
  3285. for (; i < anc_writes_size; i++) {
  3286. TASHA_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val);
  3287. snd_soc_write(codec, reg, (val & mask));
  3288. }
  3289. if (!strcmp(w->name, "RX INT1 DAC") ||
  3290. !strcmp(w->name, "RX INT3 DAC")) {
  3291. snd_soc_update_bits(codec,
  3292. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08);
  3293. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3294. !strcmp(w->name, "RX INT4 DAC")) {
  3295. snd_soc_update_bits(codec,
  3296. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08);
  3297. }
  3298. if (!hwdep_cal)
  3299. release_firmware(fw);
  3300. break;
  3301. case SND_SOC_DAPM_POST_PMU:
  3302. /* Remove ANC Rx from reset */
  3303. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_CLK_RESET_CTL,
  3304. 0x08, 0x00);
  3305. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_CLK_RESET_CTL,
  3306. 0x08, 0x00);
  3307. break;
  3308. case SND_SOC_DAPM_POST_PMD:
  3309. if (!strcmp(w->name, "ANC HPHL PA") ||
  3310. !strcmp(w->name, "ANC EAR PA") ||
  3311. !strcmp(w->name, "ANC SPK1 PA") ||
  3312. !strcmp(w->name, "ANC LINEOUT1 PA")) {
  3313. snd_soc_update_bits(codec,
  3314. WCD9335_CDC_ANC0_MODE_1_CTL, 0x30, 0x00);
  3315. msleep(50);
  3316. snd_soc_update_bits(codec,
  3317. WCD9335_CDC_ANC0_MODE_1_CTL, 0x01, 0x00);
  3318. snd_soc_update_bits(codec,
  3319. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x38);
  3320. snd_soc_update_bits(codec,
  3321. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x07, 0x00);
  3322. snd_soc_update_bits(codec,
  3323. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x00);
  3324. } else if (!strcmp(w->name, "ANC HPHR PA") ||
  3325. !strcmp(w->name, "ANC LINEOUT2 PA")) {
  3326. snd_soc_update_bits(codec,
  3327. WCD9335_CDC_ANC1_MODE_1_CTL, 0x30, 0x00);
  3328. msleep(50);
  3329. snd_soc_update_bits(codec,
  3330. WCD9335_CDC_ANC1_MODE_1_CTL, 0x01, 0x00);
  3331. snd_soc_update_bits(codec,
  3332. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x38);
  3333. snd_soc_update_bits(codec,
  3334. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x07, 0x00);
  3335. snd_soc_update_bits(codec,
  3336. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x00);
  3337. }
  3338. break;
  3339. }
  3340. return 0;
  3341. err:
  3342. if (!hwdep_cal)
  3343. release_firmware(fw);
  3344. return ret;
  3345. }
  3346. static void tasha_codec_clear_anc_tx_hold(struct tasha_priv *tasha)
  3347. {
  3348. if (test_and_clear_bit(ANC_MIC_AMIC1, &tasha->status_mask))
  3349. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC1, false);
  3350. if (test_and_clear_bit(ANC_MIC_AMIC2, &tasha->status_mask))
  3351. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC2, false);
  3352. if (test_and_clear_bit(ANC_MIC_AMIC3, &tasha->status_mask))
  3353. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC3, false);
  3354. if (test_and_clear_bit(ANC_MIC_AMIC4, &tasha->status_mask))
  3355. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC4, false);
  3356. if (test_and_clear_bit(ANC_MIC_AMIC5, &tasha->status_mask))
  3357. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC5, false);
  3358. if (test_and_clear_bit(ANC_MIC_AMIC6, &tasha->status_mask))
  3359. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC6, false);
  3360. }
  3361. static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha,
  3362. int mode, int event)
  3363. {
  3364. u8 scale_val = 0;
  3365. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3366. return;
  3367. switch (event) {
  3368. case SND_SOC_DAPM_POST_PMU:
  3369. switch (mode) {
  3370. case CLS_H_HIFI:
  3371. scale_val = 0x3;
  3372. break;
  3373. case CLS_H_LOHIFI:
  3374. scale_val = 0x1;
  3375. break;
  3376. }
  3377. if (tasha->anc_func) {
  3378. /* Clear Tx FE HOLD if both PAs are enabled */
  3379. if ((snd_soc_read(tasha->codec, WCD9335_ANA_HPH) &
  3380. 0xC0) == 0xC0) {
  3381. tasha_codec_clear_anc_tx_hold(tasha);
  3382. }
  3383. }
  3384. break;
  3385. case SND_SOC_DAPM_PRE_PMD:
  3386. scale_val = 0x6;
  3387. break;
  3388. }
  3389. if (scale_val)
  3390. snd_soc_update_bits(tasha->codec, WCD9335_HPH_PA_CTL1, 0x0E,
  3391. scale_val << 1);
  3392. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3393. if (tasha->comp_enabled[COMPANDER_1] ||
  3394. tasha->comp_enabled[COMPANDER_2]) {
  3395. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN,
  3396. 0x20, 0x00);
  3397. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN,
  3398. 0x20, 0x00);
  3399. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP,
  3400. 0x20, 0x20);
  3401. }
  3402. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN, 0x1F,
  3403. tasha->hph_l_gain);
  3404. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN, 0x1F,
  3405. tasha->hph_r_gain);
  3406. }
  3407. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3408. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP, 0x20,
  3409. 0x00);
  3410. }
  3411. }
  3412. static void tasha_codec_override(struct snd_soc_codec *codec,
  3413. int mode,
  3414. int event)
  3415. {
  3416. if (mode == CLS_AB) {
  3417. switch (event) {
  3418. case SND_SOC_DAPM_POST_PMU:
  3419. if (!(snd_soc_read(codec,
  3420. WCD9335_CDC_RX2_RX_PATH_CTL) & 0x10) &&
  3421. (!(snd_soc_read(codec,
  3422. WCD9335_CDC_RX1_RX_PATH_CTL) & 0x10)))
  3423. snd_soc_update_bits(codec,
  3424. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x02);
  3425. break;
  3426. case SND_SOC_DAPM_POST_PMD:
  3427. snd_soc_update_bits(codec,
  3428. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00);
  3429. break;
  3430. }
  3431. }
  3432. }
  3433. static int tasha_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
  3434. struct snd_kcontrol *kcontrol,
  3435. int event)
  3436. {
  3437. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3438. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3439. int hph_mode = tasha->hph_mode;
  3440. int ret = 0;
  3441. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3442. switch (event) {
  3443. case SND_SOC_DAPM_PRE_PMU:
  3444. if ((!(strcmp(w->name, "ANC HPHR PA"))) &&
  3445. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3446. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3447. }
  3448. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3449. if (!(strcmp(w->name, "HPHR PA")))
  3450. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x40);
  3451. break;
  3452. case SND_SOC_DAPM_POST_PMU:
  3453. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3454. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3455. != 0xC0)
  3456. /*
  3457. * If PA_EN is not set (potentially in ANC case)
  3458. * then do nothing for POST_PMU and let left
  3459. * channel handle everything.
  3460. */
  3461. break;
  3462. }
  3463. /*
  3464. * 7ms sleep is required after PA is enabled as per
  3465. * HW requirement
  3466. */
  3467. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3468. usleep_range(7000, 7100);
  3469. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3470. }
  3471. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3472. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3473. 0x10, 0x00);
  3474. /* Remove mix path mute if it is enabled */
  3475. if ((snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3476. 0x10)
  3477. snd_soc_update_bits(codec,
  3478. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3479. 0x10, 0x00);
  3480. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3481. /* Do everything needed for left channel */
  3482. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3483. 0x10, 0x00);
  3484. /* Remove mix path mute if it is enabled */
  3485. if ((snd_soc_read(codec,
  3486. WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3487. 0x10)
  3488. snd_soc_update_bits(codec,
  3489. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3490. 0x10, 0x00);
  3491. /* Remove ANC Rx from reset */
  3492. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3493. }
  3494. tasha_codec_override(codec, hph_mode, event);
  3495. break;
  3496. case SND_SOC_DAPM_PRE_PMD:
  3497. blocking_notifier_call_chain(&tasha->notifier,
  3498. WCD_EVENT_PRE_HPHR_PA_OFF,
  3499. &tasha->mbhc);
  3500. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3501. if (!(strcmp(w->name, "ANC HPHR PA")) ||
  3502. !(strcmp(w->name, "HPHR PA")))
  3503. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x00);
  3504. break;
  3505. case SND_SOC_DAPM_POST_PMD:
  3506. /* 5ms sleep is required after PA is disabled as per
  3507. * HW requirement
  3508. */
  3509. usleep_range(5000, 5500);
  3510. tasha_codec_override(codec, hph_mode, event);
  3511. blocking_notifier_call_chain(&tasha->notifier,
  3512. WCD_EVENT_POST_HPHR_PA_OFF,
  3513. &tasha->mbhc);
  3514. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3515. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3516. snd_soc_update_bits(codec,
  3517. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x00);
  3518. }
  3519. break;
  3520. };
  3521. return ret;
  3522. }
  3523. static int tasha_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
  3524. struct snd_kcontrol *kcontrol,
  3525. int event)
  3526. {
  3527. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3528. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3529. int hph_mode = tasha->hph_mode;
  3530. int ret = 0;
  3531. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3532. switch (event) {
  3533. case SND_SOC_DAPM_PRE_PMU:
  3534. if ((!(strcmp(w->name, "ANC HPHL PA"))) &&
  3535. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3536. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3537. }
  3538. if (!(strcmp(w->name, "HPHL PA")))
  3539. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x80);
  3540. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3541. break;
  3542. case SND_SOC_DAPM_POST_PMU:
  3543. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3544. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3545. != 0xC0)
  3546. /*
  3547. * If PA_EN is not set (potentially in ANC case)
  3548. * then do nothing for POST_PMU and let right
  3549. * channel handle everything.
  3550. */
  3551. break;
  3552. }
  3553. /*
  3554. * 7ms sleep is required after PA is enabled as per
  3555. * HW requirement
  3556. */
  3557. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3558. usleep_range(7000, 7100);
  3559. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3560. }
  3561. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3562. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3563. 0x10, 0x00);
  3564. /* Remove mix path mute if it is enabled */
  3565. if ((snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3566. 0x10)
  3567. snd_soc_update_bits(codec,
  3568. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3569. 0x10, 0x00);
  3570. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3571. /* Do everything needed for right channel */
  3572. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3573. 0x10, 0x00);
  3574. /* Remove mix path mute if it is enabled */
  3575. if ((snd_soc_read(codec,
  3576. WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3577. 0x10)
  3578. snd_soc_update_bits(codec,
  3579. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3580. 0x10, 0x00);
  3581. /* Remove ANC Rx from reset */
  3582. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3583. }
  3584. tasha_codec_override(codec, hph_mode, event);
  3585. break;
  3586. case SND_SOC_DAPM_PRE_PMD:
  3587. blocking_notifier_call_chain(&tasha->notifier,
  3588. WCD_EVENT_PRE_HPHL_PA_OFF,
  3589. &tasha->mbhc);
  3590. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3591. if (!(strcmp(w->name, "ANC HPHL PA")) ||
  3592. !(strcmp(w->name, "HPHL PA")))
  3593. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x00);
  3594. break;
  3595. case SND_SOC_DAPM_POST_PMD:
  3596. /* 5ms sleep is required after PA is disabled as per
  3597. * HW requirement
  3598. */
  3599. usleep_range(5000, 5500);
  3600. tasha_codec_override(codec, hph_mode, event);
  3601. blocking_notifier_call_chain(&tasha->notifier,
  3602. WCD_EVENT_POST_HPHL_PA_OFF,
  3603. &tasha->mbhc);
  3604. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3605. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3606. snd_soc_update_bits(codec,
  3607. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00);
  3608. }
  3609. break;
  3610. };
  3611. return ret;
  3612. }
  3613. static int tasha_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w,
  3614. struct snd_kcontrol *kcontrol,
  3615. int event)
  3616. {
  3617. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3618. u16 lineout_vol_reg = 0, lineout_mix_vol_reg = 0;
  3619. int ret = 0;
  3620. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3621. if (w->reg == WCD9335_ANA_LO_1_2) {
  3622. if (w->shift == 7) {
  3623. lineout_vol_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  3624. lineout_mix_vol_reg = WCD9335_CDC_RX3_RX_PATH_MIX_CTL;
  3625. } else if (w->shift == 6) {
  3626. lineout_vol_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  3627. lineout_mix_vol_reg = WCD9335_CDC_RX4_RX_PATH_MIX_CTL;
  3628. }
  3629. } else if (w->reg == WCD9335_ANA_LO_3_4) {
  3630. if (w->shift == 7) {
  3631. lineout_vol_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  3632. lineout_mix_vol_reg = WCD9335_CDC_RX5_RX_PATH_MIX_CTL;
  3633. } else if (w->shift == 6) {
  3634. lineout_vol_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  3635. lineout_mix_vol_reg = WCD9335_CDC_RX6_RX_PATH_MIX_CTL;
  3636. }
  3637. } else {
  3638. dev_err(codec->dev, "%s: Error enabling lineout PA\n",
  3639. __func__);
  3640. return -EINVAL;
  3641. }
  3642. switch (event) {
  3643. case SND_SOC_DAPM_POST_PMU:
  3644. /* 5ms sleep is required after PA is enabled as per
  3645. * HW requirement
  3646. */
  3647. usleep_range(5000, 5500);
  3648. snd_soc_update_bits(codec, lineout_vol_reg,
  3649. 0x10, 0x00);
  3650. /* Remove mix path mute if it is enabled */
  3651. if ((snd_soc_read(codec, lineout_mix_vol_reg)) & 0x10)
  3652. snd_soc_update_bits(codec,
  3653. lineout_mix_vol_reg,
  3654. 0x10, 0x00);
  3655. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3656. !(strcmp(w->name, "ANC LINEOUT2 PA")))
  3657. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3658. tasha_codec_override(codec, CLS_AB, event);
  3659. break;
  3660. case SND_SOC_DAPM_POST_PMD:
  3661. /* 5ms sleep is required after PA is disabled as per
  3662. * HW requirement
  3663. */
  3664. usleep_range(5000, 5500);
  3665. tasha_codec_override(codec, CLS_AB, event);
  3666. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3667. !(strcmp(w->name, "ANC LINEOUT2 PA"))) {
  3668. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3669. if (!(strcmp(w->name, "ANC LINEOUT1 PA")))
  3670. snd_soc_update_bits(codec,
  3671. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  3672. else
  3673. snd_soc_update_bits(codec,
  3674. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  3675. }
  3676. break;
  3677. };
  3678. return ret;
  3679. }
  3680. static void tasha_spk_anc_update_callback(struct work_struct *work)
  3681. {
  3682. struct spk_anc_work *spk_anc_dwork;
  3683. struct tasha_priv *tasha;
  3684. struct delayed_work *delayed_work;
  3685. struct snd_soc_codec *codec;
  3686. delayed_work = to_delayed_work(work);
  3687. spk_anc_dwork = container_of(delayed_work, struct spk_anc_work, dwork);
  3688. tasha = spk_anc_dwork->tasha;
  3689. codec = tasha->codec;
  3690. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0, 0x10, 0x10);
  3691. }
  3692. static int tasha_codec_enable_spk_anc(struct snd_soc_dapm_widget *w,
  3693. struct snd_kcontrol *kcontrol,
  3694. int event)
  3695. {
  3696. int ret = 0;
  3697. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3698. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3699. dev_dbg(codec->dev, "%s %s %d %d\n", __func__, w->name, event,
  3700. tasha->anc_func);
  3701. if (!tasha->anc_func)
  3702. return 0;
  3703. switch (event) {
  3704. case SND_SOC_DAPM_PRE_PMU:
  3705. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3706. schedule_delayed_work(&tasha->spk_anc_dwork.dwork,
  3707. msecs_to_jiffies(spk_anc_en_delay));
  3708. break;
  3709. case SND_SOC_DAPM_POST_PMD:
  3710. cancel_delayed_work_sync(&tasha->spk_anc_dwork.dwork);
  3711. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0,
  3712. 0x10, 0x00);
  3713. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3714. break;
  3715. }
  3716. return ret;
  3717. }
  3718. static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
  3719. struct snd_kcontrol *kcontrol,
  3720. int event)
  3721. {
  3722. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3723. int ret = 0;
  3724. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3725. switch (event) {
  3726. case SND_SOC_DAPM_POST_PMU:
  3727. /* 5ms sleep is required after PA is enabled as per
  3728. * HW requirement
  3729. */
  3730. usleep_range(5000, 5500);
  3731. snd_soc_update_bits(codec, WCD9335_CDC_RX0_RX_PATH_CTL,
  3732. 0x10, 0x00);
  3733. /* Remove mix path mute if it is enabled */
  3734. if ((snd_soc_read(codec, WCD9335_CDC_RX0_RX_PATH_MIX_CTL)) &
  3735. 0x10)
  3736. snd_soc_update_bits(codec,
  3737. WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  3738. 0x10, 0x00);
  3739. break;
  3740. case SND_SOC_DAPM_POST_PMD:
  3741. /* 5ms sleep is required after PA is disabled as per
  3742. * HW requirement
  3743. */
  3744. usleep_range(5000, 5500);
  3745. if (!(strcmp(w->name, "ANC EAR PA"))) {
  3746. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3747. snd_soc_update_bits(codec,
  3748. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x00);
  3749. }
  3750. break;
  3751. };
  3752. return ret;
  3753. }
  3754. static void tasha_codec_hph_mode_gain_opt(struct snd_soc_codec *codec,
  3755. u8 gain)
  3756. {
  3757. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3758. u8 hph_l_en, hph_r_en;
  3759. u8 l_val, r_val;
  3760. u8 hph_pa_status;
  3761. bool is_hphl_pa, is_hphr_pa;
  3762. hph_pa_status = snd_soc_read(codec, WCD9335_ANA_HPH);
  3763. is_hphl_pa = hph_pa_status >> 7;
  3764. is_hphr_pa = (hph_pa_status & 0x40) >> 6;
  3765. hph_l_en = snd_soc_read(codec, WCD9335_HPH_L_EN);
  3766. hph_r_en = snd_soc_read(codec, WCD9335_HPH_R_EN);
  3767. l_val = (hph_l_en & 0xC0) | 0x20 | gain;
  3768. r_val = (hph_r_en & 0xC0) | 0x20 | gain;
  3769. /*
  3770. * Set HPH_L & HPH_R gain source selection to REGISTER
  3771. * for better click and pop only if corresponding PAs are
  3772. * not enabled. Also cache the values of the HPHL/R
  3773. * PA gains to be applied after PAs are enabled
  3774. */
  3775. if ((l_val != hph_l_en) && !is_hphl_pa) {
  3776. snd_soc_write(codec, WCD9335_HPH_L_EN, l_val);
  3777. tasha->hph_l_gain = hph_l_en & 0x1F;
  3778. }
  3779. if ((r_val != hph_r_en) && !is_hphr_pa) {
  3780. snd_soc_write(codec, WCD9335_HPH_R_EN, r_val);
  3781. tasha->hph_r_gain = hph_r_en & 0x1F;
  3782. }
  3783. }
  3784. static void tasha_codec_hph_lohifi_config(struct snd_soc_codec *codec,
  3785. int event)
  3786. {
  3787. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3788. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x06);
  3789. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2,
  3790. 0xF0, 0x40);
  3791. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3792. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3793. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3794. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3795. }
  3796. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3797. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3798. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3799. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A);
  3800. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x0A);
  3801. }
  3802. }
  3803. static void tasha_codec_hph_lp_config(struct snd_soc_codec *codec,
  3804. int event)
  3805. {
  3806. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3807. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3808. tasha_codec_hph_mode_gain_opt(codec, 0x10);
  3809. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3810. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3811. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x04);
  3812. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x20);
  3813. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x07,
  3814. 0x01);
  3815. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x70,
  3816. 0x10);
  3817. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3818. 0x0F, 0x01);
  3819. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3820. 0xF0, 0x10);
  3821. }
  3822. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3823. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x88);
  3824. snd_soc_write(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x33);
  3825. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x00);
  3826. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x00);
  3827. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3828. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3829. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x80);
  3830. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x80);
  3831. }
  3832. }
  3833. static void tasha_codec_hph_hifi_config(struct snd_soc_codec *codec,
  3834. int event)
  3835. {
  3836. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3837. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3838. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3839. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3840. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3841. }
  3842. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3843. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3844. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3845. }
  3846. }
  3847. static void tasha_codec_hph_mode_config(struct snd_soc_codec *codec,
  3848. int event, int mode)
  3849. {
  3850. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3851. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3852. return;
  3853. switch (mode) {
  3854. case CLS_H_LP:
  3855. tasha_codec_hph_lp_config(codec, event);
  3856. break;
  3857. case CLS_H_LOHIFI:
  3858. tasha_codec_hph_lohifi_config(codec, event);
  3859. break;
  3860. case CLS_H_HIFI:
  3861. tasha_codec_hph_hifi_config(codec, event);
  3862. break;
  3863. }
  3864. }
  3865. static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
  3866. struct snd_kcontrol *kcontrol,
  3867. int event)
  3868. {
  3869. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3870. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3871. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3872. int hph_mode = tasha->hph_mode;
  3873. u8 dem_inp;
  3874. int ret = 0;
  3875. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3876. w->name, event, hph_mode);
  3877. switch (event) {
  3878. case SND_SOC_DAPM_PRE_PMU:
  3879. if (tasha->anc_func) {
  3880. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3881. /* 40 msec delay is needed to avoid click and pop */
  3882. msleep(40);
  3883. }
  3884. /* Read DEM INP Select */
  3885. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_SEC0) &
  3886. 0x03;
  3887. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3888. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3889. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3890. __func__, hph_mode);
  3891. return -EINVAL;
  3892. }
  3893. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3894. WCD_CLSH_EVENT_PRE_DAC,
  3895. WCD_CLSH_STATE_HPHR,
  3896. ((hph_mode == CLS_H_LOHIFI) ?
  3897. CLS_H_HIFI : hph_mode));
  3898. if (!(strcmp(w->name, "RX INT2 DAC")))
  3899. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x10, 0x10);
  3900. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3901. if (tasha->anc_func)
  3902. snd_soc_update_bits(codec,
  3903. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x10);
  3904. break;
  3905. case SND_SOC_DAPM_POST_PMU:
  3906. /* 1000us required as per HW requirement */
  3907. usleep_range(1000, 1100);
  3908. if ((hph_mode == CLS_H_LP) &&
  3909. (TASHA_IS_1_1(wcd9xxx))) {
  3910. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3911. 0x03, 0x03);
  3912. }
  3913. break;
  3914. case SND_SOC_DAPM_PRE_PMD:
  3915. if ((hph_mode == CLS_H_LP) &&
  3916. (TASHA_IS_1_1(wcd9xxx))) {
  3917. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3918. 0x03, 0x00);
  3919. }
  3920. if (!(strcmp(w->name, "RX INT2 DAC")))
  3921. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x10, 0x00);
  3922. break;
  3923. case SND_SOC_DAPM_POST_PMD:
  3924. /* 1000us required as per HW requirement */
  3925. usleep_range(1000, 1100);
  3926. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  3927. WCD_CLSH_STATE_HPHL))
  3928. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3929. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3930. WCD_CLSH_EVENT_POST_PA,
  3931. WCD_CLSH_STATE_HPHR,
  3932. ((hph_mode == CLS_H_LOHIFI) ?
  3933. CLS_H_HIFI : hph_mode));
  3934. break;
  3935. };
  3936. return ret;
  3937. }
  3938. static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
  3939. struct snd_kcontrol *kcontrol,
  3940. int event)
  3941. {
  3942. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3943. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3944. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3945. int hph_mode = tasha->hph_mode;
  3946. u8 dem_inp;
  3947. int ret = 0;
  3948. uint32_t impedl = 0, impedr = 0;
  3949. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3950. w->name, event, hph_mode);
  3951. switch (event) {
  3952. case SND_SOC_DAPM_PRE_PMU:
  3953. if (tasha->anc_func) {
  3954. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3955. /* 40 msec delay is needed to avoid click and pop */
  3956. msleep(40);
  3957. }
  3958. /* Read DEM INP Select */
  3959. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_SEC0) &
  3960. 0x03;
  3961. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3962. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3963. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3964. __func__, hph_mode);
  3965. return -EINVAL;
  3966. }
  3967. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3968. WCD_CLSH_EVENT_PRE_DAC,
  3969. WCD_CLSH_STATE_HPHL,
  3970. ((hph_mode == CLS_H_LOHIFI) ?
  3971. CLS_H_HIFI : hph_mode));
  3972. if (!(strcmp(w->name, "RX INT1 DAC")))
  3973. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x20, 0x20);
  3974. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3975. if (tasha->anc_func)
  3976. snd_soc_update_bits(codec,
  3977. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x10);
  3978. ret = wcd_mbhc_get_impedance(&tasha->mbhc,
  3979. &impedl, &impedr);
  3980. if (!ret) {
  3981. wcd_clsh_imped_config(codec, impedl, false);
  3982. set_bit(CLASSH_CONFIG, &tasha->status_mask);
  3983. } else {
  3984. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  3985. __func__, ret);
  3986. ret = 0;
  3987. }
  3988. break;
  3989. case SND_SOC_DAPM_POST_PMU:
  3990. /* 1000us required as per HW requirement */
  3991. usleep_range(1000, 1100);
  3992. if ((hph_mode == CLS_H_LP) &&
  3993. (TASHA_IS_1_1(wcd9xxx))) {
  3994. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3995. 0x03, 0x03);
  3996. }
  3997. break;
  3998. case SND_SOC_DAPM_PRE_PMD:
  3999. if (!(strcmp(w->name, "RX INT1 DAC")))
  4000. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x20, 0x00);
  4001. if ((hph_mode == CLS_H_LP) &&
  4002. (TASHA_IS_1_1(wcd9xxx))) {
  4003. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  4004. 0x03, 0x00);
  4005. }
  4006. break;
  4007. case SND_SOC_DAPM_POST_PMD:
  4008. /* 1000us required as per HW requirement */
  4009. usleep_range(1000, 1100);
  4010. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  4011. WCD_CLSH_STATE_HPHR))
  4012. tasha_codec_hph_mode_config(codec, event, hph_mode);
  4013. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4014. WCD_CLSH_EVENT_POST_PA,
  4015. WCD_CLSH_STATE_HPHL,
  4016. ((hph_mode == CLS_H_LOHIFI) ?
  4017. CLS_H_HIFI : hph_mode));
  4018. if (test_bit(CLASSH_CONFIG, &tasha->status_mask)) {
  4019. wcd_clsh_imped_config(codec, impedl, true);
  4020. clear_bit(CLASSH_CONFIG, &tasha->status_mask);
  4021. } else
  4022. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  4023. __func__, ret);
  4024. break;
  4025. };
  4026. return ret;
  4027. }
  4028. static int tasha_codec_lineout_dac_event(struct snd_soc_dapm_widget *w,
  4029. struct snd_kcontrol *kcontrol,
  4030. int event)
  4031. {
  4032. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4033. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4034. int ret = 0;
  4035. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4036. switch (event) {
  4037. case SND_SOC_DAPM_PRE_PMU:
  4038. if (tasha->anc_func &&
  4039. (!strcmp(w->name, "RX INT3 DAC") ||
  4040. !strcmp(w->name, "RX INT4 DAC")))
  4041. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4042. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4043. WCD_CLSH_EVENT_PRE_DAC,
  4044. WCD_CLSH_STATE_LO,
  4045. CLS_AB);
  4046. if (tasha->anc_func) {
  4047. if (!strcmp(w->name, "RX INT3 DAC"))
  4048. snd_soc_update_bits(codec,
  4049. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  4050. else if (!strcmp(w->name, "RX INT4 DAC"))
  4051. snd_soc_update_bits(codec,
  4052. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  4053. }
  4054. break;
  4055. case SND_SOC_DAPM_POST_PMD:
  4056. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4057. WCD_CLSH_EVENT_POST_PA,
  4058. WCD_CLSH_STATE_LO,
  4059. CLS_AB);
  4060. break;
  4061. }
  4062. return 0;
  4063. }
  4064. static const struct snd_soc_dapm_widget tasha_dapm_i2s_widgets[] = {
  4065. SND_SOC_DAPM_SUPPLY("RX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  4066. 0, 0, NULL, 0),
  4067. SND_SOC_DAPM_SUPPLY("TX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  4068. 0, 0, NULL, 0),
  4069. };
  4070. static int tasha_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
  4071. struct snd_kcontrol *kcontrol,
  4072. int event)
  4073. {
  4074. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4075. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4076. int ret = 0;
  4077. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4078. switch (event) {
  4079. case SND_SOC_DAPM_PRE_PMU:
  4080. if (tasha->anc_func)
  4081. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4082. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4083. WCD_CLSH_EVENT_PRE_DAC,
  4084. WCD_CLSH_STATE_EAR,
  4085. CLS_H_NORMAL);
  4086. if (tasha->anc_func)
  4087. snd_soc_update_bits(codec,
  4088. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x10);
  4089. break;
  4090. case SND_SOC_DAPM_POST_PMU:
  4091. break;
  4092. case SND_SOC_DAPM_PRE_PMD:
  4093. break;
  4094. case SND_SOC_DAPM_POST_PMD:
  4095. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4096. WCD_CLSH_EVENT_POST_PA,
  4097. WCD_CLSH_STATE_EAR,
  4098. CLS_H_NORMAL);
  4099. break;
  4100. };
  4101. return ret;
  4102. }
  4103. static int tasha_codec_spk_boost_event(struct snd_soc_dapm_widget *w,
  4104. struct snd_kcontrol *kcontrol,
  4105. int event)
  4106. {
  4107. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4108. u16 boost_path_ctl, boost_path_cfg1;
  4109. u16 reg, reg_mix;
  4110. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4111. if (!strcmp(w->name, "RX INT7 CHAIN")) {
  4112. boost_path_ctl = WCD9335_CDC_BOOST0_BOOST_PATH_CTL;
  4113. boost_path_cfg1 = WCD9335_CDC_RX7_RX_PATH_CFG1;
  4114. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4115. reg_mix = WCD9335_CDC_RX7_RX_PATH_MIX_CTL;
  4116. } else if (!strcmp(w->name, "RX INT8 CHAIN")) {
  4117. boost_path_ctl = WCD9335_CDC_BOOST1_BOOST_PATH_CTL;
  4118. boost_path_cfg1 = WCD9335_CDC_RX8_RX_PATH_CFG1;
  4119. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4120. reg_mix = WCD9335_CDC_RX8_RX_PATH_MIX_CTL;
  4121. } else {
  4122. dev_err(codec->dev, "%s: unknown widget: %s\n",
  4123. __func__, w->name);
  4124. return -EINVAL;
  4125. }
  4126. switch (event) {
  4127. case SND_SOC_DAPM_PRE_PMU:
  4128. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10);
  4129. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01);
  4130. snd_soc_update_bits(codec, reg, 0x10, 0x00);
  4131. if ((snd_soc_read(codec, reg_mix)) & 0x10)
  4132. snd_soc_update_bits(codec, reg_mix, 0x10, 0x00);
  4133. break;
  4134. case SND_SOC_DAPM_POST_PMD:
  4135. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00);
  4136. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00);
  4137. break;
  4138. };
  4139. return 0;
  4140. }
  4141. static u16 tasha_interp_get_primary_reg(u16 reg, u16 *ind)
  4142. {
  4143. u16 prim_int_reg = 0;
  4144. switch (reg) {
  4145. case WCD9335_CDC_RX0_RX_PATH_CTL:
  4146. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4147. prim_int_reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4148. *ind = 0;
  4149. break;
  4150. case WCD9335_CDC_RX1_RX_PATH_CTL:
  4151. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4152. prim_int_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4153. *ind = 1;
  4154. break;
  4155. case WCD9335_CDC_RX2_RX_PATH_CTL:
  4156. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4157. prim_int_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4158. *ind = 2;
  4159. break;
  4160. case WCD9335_CDC_RX3_RX_PATH_CTL:
  4161. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4162. prim_int_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4163. *ind = 3;
  4164. break;
  4165. case WCD9335_CDC_RX4_RX_PATH_CTL:
  4166. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4167. prim_int_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4168. *ind = 4;
  4169. break;
  4170. case WCD9335_CDC_RX5_RX_PATH_CTL:
  4171. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4172. prim_int_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4173. *ind = 5;
  4174. break;
  4175. case WCD9335_CDC_RX6_RX_PATH_CTL:
  4176. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4177. prim_int_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4178. *ind = 6;
  4179. break;
  4180. case WCD9335_CDC_RX7_RX_PATH_CTL:
  4181. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4182. prim_int_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4183. *ind = 7;
  4184. break;
  4185. case WCD9335_CDC_RX8_RX_PATH_CTL:
  4186. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4187. prim_int_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4188. *ind = 8;
  4189. break;
  4190. };
  4191. return prim_int_reg;
  4192. }
  4193. static void tasha_codec_hd2_control(struct snd_soc_codec *codec,
  4194. u16 prim_int_reg, int event)
  4195. {
  4196. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4197. u16 hd2_scale_reg;
  4198. u16 hd2_enable_reg = 0;
  4199. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  4200. return;
  4201. if (prim_int_reg == WCD9335_CDC_RX1_RX_PATH_CTL) {
  4202. hd2_scale_reg = WCD9335_CDC_RX1_RX_PATH_SEC3;
  4203. hd2_enable_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4204. }
  4205. if (prim_int_reg == WCD9335_CDC_RX2_RX_PATH_CTL) {
  4206. hd2_scale_reg = WCD9335_CDC_RX2_RX_PATH_SEC3;
  4207. hd2_enable_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4208. }
  4209. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) {
  4210. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x10);
  4211. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x01);
  4212. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04);
  4213. }
  4214. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
  4215. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00);
  4216. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x00);
  4217. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00);
  4218. }
  4219. }
  4220. static int tasha_codec_enable_prim_interpolator(
  4221. struct snd_soc_codec *codec,
  4222. u16 reg, int event)
  4223. {
  4224. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4225. u16 prim_int_reg;
  4226. u16 ind = 0;
  4227. prim_int_reg = tasha_interp_get_primary_reg(reg, &ind);
  4228. switch (event) {
  4229. case SND_SOC_DAPM_PRE_PMU:
  4230. tasha->prim_int_users[ind]++;
  4231. if (tasha->prim_int_users[ind] == 1) {
  4232. snd_soc_update_bits(codec, prim_int_reg,
  4233. 0x10, 0x10);
  4234. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4235. snd_soc_update_bits(codec, prim_int_reg,
  4236. 1 << 0x5, 1 << 0x5);
  4237. }
  4238. if ((reg != prim_int_reg) &&
  4239. ((snd_soc_read(codec, prim_int_reg)) & 0x10))
  4240. snd_soc_update_bits(codec, reg, 0x10, 0x10);
  4241. break;
  4242. case SND_SOC_DAPM_POST_PMD:
  4243. tasha->prim_int_users[ind]--;
  4244. if (tasha->prim_int_users[ind] == 0) {
  4245. snd_soc_update_bits(codec, prim_int_reg,
  4246. 1 << 0x5, 0 << 0x5);
  4247. snd_soc_update_bits(codec, prim_int_reg,
  4248. 0x40, 0x40);
  4249. snd_soc_update_bits(codec, prim_int_reg,
  4250. 0x40, 0x00);
  4251. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4252. }
  4253. break;
  4254. };
  4255. dev_dbg(codec->dev, "%s: primary interpolator: INT%d, users: %d\n",
  4256. __func__, ind, tasha->prim_int_users[ind]);
  4257. return 0;
  4258. }
  4259. static int tasha_codec_enable_spline_src(struct snd_soc_codec *codec,
  4260. int src_num,
  4261. int event)
  4262. {
  4263. u16 src_paired_reg = 0;
  4264. struct tasha_priv *tasha;
  4265. u16 rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4266. u16 rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4267. int *src_users, count, spl_src = SPLINE_SRC0;
  4268. u16 src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4269. tasha = snd_soc_codec_get_drvdata(codec);
  4270. switch (src_num) {
  4271. case SRC_IN_HPHL:
  4272. rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4273. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4274. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4275. rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4276. spl_src = SPLINE_SRC0;
  4277. break;
  4278. case SRC_IN_LO1:
  4279. rx_path_cfg_reg = WCD9335_CDC_RX3_RX_PATH_CFG0;
  4280. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4281. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4282. rx_path_ctl_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4283. spl_src = SPLINE_SRC0;
  4284. break;
  4285. case SRC_IN_HPHR:
  4286. rx_path_cfg_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4287. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4288. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4289. rx_path_ctl_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4290. spl_src = SPLINE_SRC1;
  4291. break;
  4292. case SRC_IN_LO2:
  4293. rx_path_cfg_reg = WCD9335_CDC_RX4_RX_PATH_CFG0;
  4294. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4295. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4296. rx_path_ctl_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4297. spl_src = SPLINE_SRC1;
  4298. break;
  4299. case SRC_IN_SPKRL:
  4300. rx_path_cfg_reg = WCD9335_CDC_RX7_RX_PATH_CFG0;
  4301. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4302. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4303. rx_path_ctl_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4304. spl_src = SPLINE_SRC2;
  4305. break;
  4306. case SRC_IN_LO3:
  4307. rx_path_cfg_reg = WCD9335_CDC_RX5_RX_PATH_CFG0;
  4308. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4309. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4310. rx_path_ctl_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4311. spl_src = SPLINE_SRC2;
  4312. break;
  4313. case SRC_IN_SPKRR:
  4314. rx_path_cfg_reg = WCD9335_CDC_RX8_RX_PATH_CFG0;
  4315. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4316. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4317. rx_path_ctl_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4318. spl_src = SPLINE_SRC3;
  4319. break;
  4320. case SRC_IN_LO4:
  4321. rx_path_cfg_reg = WCD9335_CDC_RX6_RX_PATH_CFG0;
  4322. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4323. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4324. rx_path_ctl_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4325. spl_src = SPLINE_SRC3;
  4326. break;
  4327. };
  4328. src_users = &tasha->spl_src_users[spl_src];
  4329. switch (event) {
  4330. case SND_SOC_DAPM_PRE_PMU:
  4331. count = *src_users;
  4332. count++;
  4333. if (count == 1) {
  4334. if ((snd_soc_read(codec, src_clk_reg) & 0x02) ||
  4335. (snd_soc_read(codec, src_paired_reg) & 0x02)) {
  4336. snd_soc_update_bits(codec, src_clk_reg, 0x02,
  4337. 0x00);
  4338. snd_soc_update_bits(codec, src_paired_reg,
  4339. 0x02, 0x00);
  4340. }
  4341. snd_soc_update_bits(codec, src_clk_reg, 0x01, 0x01);
  4342. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4343. 0x80);
  4344. }
  4345. *src_users = count;
  4346. break;
  4347. case SND_SOC_DAPM_POST_PMD:
  4348. count = *src_users;
  4349. count--;
  4350. if (count == 0) {
  4351. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4352. 0x00);
  4353. snd_soc_update_bits(codec, src_clk_reg, 0x03, 0x02);
  4354. /* default sample rate */
  4355. snd_soc_update_bits(codec, rx_path_ctl_reg, 0x0f,
  4356. 0x04);
  4357. }
  4358. *src_users = count;
  4359. break;
  4360. };
  4361. dev_dbg(codec->dev, "%s: Spline SRC%d, users: %d\n",
  4362. __func__, spl_src, *src_users);
  4363. return 0;
  4364. }
  4365. static int tasha_codec_enable_spline_resampler(struct snd_soc_dapm_widget *w,
  4366. struct snd_kcontrol *kcontrol,
  4367. int event)
  4368. {
  4369. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4370. int ret = 0;
  4371. u8 src_in;
  4372. src_in = snd_soc_read(codec, WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0);
  4373. if (!(src_in & 0xFF)) {
  4374. dev_err(codec->dev, "%s: Spline SRC%u input not selected\n",
  4375. __func__, w->shift);
  4376. return -EINVAL;
  4377. }
  4378. switch (w->shift) {
  4379. case SPLINE_SRC0:
  4380. ret = tasha_codec_enable_spline_src(codec,
  4381. ((src_in & 0x03) == 1) ? SRC_IN_HPHL : SRC_IN_LO1,
  4382. event);
  4383. break;
  4384. case SPLINE_SRC1:
  4385. ret = tasha_codec_enable_spline_src(codec,
  4386. ((src_in & 0x0C) == 4) ? SRC_IN_HPHR : SRC_IN_LO2,
  4387. event);
  4388. break;
  4389. case SPLINE_SRC2:
  4390. ret = tasha_codec_enable_spline_src(codec,
  4391. ((src_in & 0x30) == 0x10) ? SRC_IN_LO3 : SRC_IN_SPKRL,
  4392. event);
  4393. break;
  4394. case SPLINE_SRC3:
  4395. ret = tasha_codec_enable_spline_src(codec,
  4396. ((src_in & 0xC0) == 0x40) ? SRC_IN_LO4 : SRC_IN_SPKRR,
  4397. event);
  4398. break;
  4399. default:
  4400. dev_err(codec->dev, "%s: Invalid spline src:%u\n", __func__,
  4401. w->shift);
  4402. ret = -EINVAL;
  4403. };
  4404. return ret;
  4405. }
  4406. static int tasha_codec_enable_swr(struct snd_soc_dapm_widget *w,
  4407. struct snd_kcontrol *kcontrol, int event)
  4408. {
  4409. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4410. struct tasha_priv *tasha;
  4411. int i, ch_cnt;
  4412. tasha = snd_soc_codec_get_drvdata(codec);
  4413. if (!tasha->nr)
  4414. return 0;
  4415. switch (event) {
  4416. case SND_SOC_DAPM_PRE_PMU:
  4417. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4418. !tasha->rx_7_count)
  4419. tasha->rx_7_count++;
  4420. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4421. !tasha->rx_8_count)
  4422. tasha->rx_8_count++;
  4423. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4424. for (i = 0; i < tasha->nr; i++) {
  4425. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4426. SWR_DEVICE_UP, NULL);
  4427. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4428. SWR_SET_NUM_RX_CH, &ch_cnt);
  4429. }
  4430. break;
  4431. case SND_SOC_DAPM_POST_PMD:
  4432. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4433. tasha->rx_7_count)
  4434. tasha->rx_7_count--;
  4435. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4436. tasha->rx_8_count)
  4437. tasha->rx_8_count--;
  4438. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4439. for (i = 0; i < tasha->nr; i++)
  4440. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4441. SWR_SET_NUM_RX_CH, &ch_cnt);
  4442. break;
  4443. }
  4444. dev_dbg(tasha->dev, "%s: current swr ch cnt: %d\n",
  4445. __func__, tasha->rx_7_count + tasha->rx_8_count);
  4446. return 0;
  4447. }
  4448. static int tasha_codec_config_ear_spkr_gain(struct snd_soc_codec *codec,
  4449. int event, int gain_reg)
  4450. {
  4451. int comp_gain_offset, val;
  4452. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4453. switch (tasha->spkr_mode) {
  4454. /* Compander gain in SPKR_MODE1 case is 12 dB */
  4455. case SPKR_MODE_1:
  4456. comp_gain_offset = -12;
  4457. break;
  4458. /* Default case compander gain is 15 dB */
  4459. default:
  4460. comp_gain_offset = -15;
  4461. break;
  4462. }
  4463. switch (event) {
  4464. case SND_SOC_DAPM_POST_PMU:
  4465. /* Apply ear spkr gain only if compander is enabled */
  4466. if (tasha->comp_enabled[COMPANDER_7] &&
  4467. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4468. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4469. (tasha->ear_spkr_gain != 0)) {
  4470. /* For example, val is -8(-12+5-1) for 4dB of gain */
  4471. val = comp_gain_offset + tasha->ear_spkr_gain - 1;
  4472. snd_soc_write(codec, gain_reg, val);
  4473. dev_dbg(codec->dev, "%s: RX7 Volume %d dB\n",
  4474. __func__, val);
  4475. }
  4476. break;
  4477. case SND_SOC_DAPM_POST_PMD:
  4478. /*
  4479. * Reset RX7 volume to 0 dB if compander is enabled and
  4480. * ear_spkr_gain is non-zero.
  4481. */
  4482. if (tasha->comp_enabled[COMPANDER_7] &&
  4483. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4484. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4485. (tasha->ear_spkr_gain != 0)) {
  4486. snd_soc_write(codec, gain_reg, 0x0);
  4487. dev_dbg(codec->dev, "%s: Reset RX7 Volume to 0 dB\n",
  4488. __func__);
  4489. }
  4490. break;
  4491. }
  4492. return 0;
  4493. }
  4494. static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w,
  4495. struct snd_kcontrol *kcontrol, int event)
  4496. {
  4497. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4498. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4499. u16 gain_reg;
  4500. int offset_val = 0;
  4501. int val = 0;
  4502. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4503. switch (w->reg) {
  4504. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4505. gain_reg = WCD9335_CDC_RX0_RX_VOL_MIX_CTL;
  4506. break;
  4507. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4508. gain_reg = WCD9335_CDC_RX1_RX_VOL_MIX_CTL;
  4509. break;
  4510. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4511. gain_reg = WCD9335_CDC_RX2_RX_VOL_MIX_CTL;
  4512. break;
  4513. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4514. gain_reg = WCD9335_CDC_RX3_RX_VOL_MIX_CTL;
  4515. break;
  4516. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4517. gain_reg = WCD9335_CDC_RX4_RX_VOL_MIX_CTL;
  4518. break;
  4519. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4520. gain_reg = WCD9335_CDC_RX5_RX_VOL_MIX_CTL;
  4521. break;
  4522. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4523. gain_reg = WCD9335_CDC_RX6_RX_VOL_MIX_CTL;
  4524. break;
  4525. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4526. gain_reg = WCD9335_CDC_RX7_RX_VOL_MIX_CTL;
  4527. break;
  4528. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4529. gain_reg = WCD9335_CDC_RX8_RX_VOL_MIX_CTL;
  4530. break;
  4531. default:
  4532. dev_err(codec->dev, "%s: No gain register avail for %s\n",
  4533. __func__, w->name);
  4534. return 0;
  4535. };
  4536. switch (event) {
  4537. case SND_SOC_DAPM_POST_PMU:
  4538. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4539. (tasha->comp_enabled[COMPANDER_7] ||
  4540. tasha->comp_enabled[COMPANDER_8]) &&
  4541. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4542. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4543. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4544. 0x01, 0x01);
  4545. snd_soc_update_bits(codec,
  4546. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4547. 0x01, 0x01);
  4548. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4549. 0x01, 0x01);
  4550. snd_soc_update_bits(codec,
  4551. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4552. 0x01, 0x01);
  4553. offset_val = -2;
  4554. }
  4555. val = snd_soc_read(codec, gain_reg);
  4556. val += offset_val;
  4557. snd_soc_write(codec, gain_reg, val);
  4558. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4559. break;
  4560. case SND_SOC_DAPM_POST_PMD:
  4561. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4562. (tasha->comp_enabled[COMPANDER_7] ||
  4563. tasha->comp_enabled[COMPANDER_8]) &&
  4564. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4565. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4566. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4567. 0x01, 0x00);
  4568. snd_soc_update_bits(codec,
  4569. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4570. 0x01, 0x00);
  4571. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4572. 0x01, 0x00);
  4573. snd_soc_update_bits(codec,
  4574. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4575. 0x01, 0x00);
  4576. offset_val = 2;
  4577. val = snd_soc_read(codec, gain_reg);
  4578. val += offset_val;
  4579. snd_soc_write(codec, gain_reg, val);
  4580. }
  4581. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4582. break;
  4583. };
  4584. return 0;
  4585. }
  4586. static int __tasha_cdc_native_clk_enable(struct tasha_priv *tasha,
  4587. bool enable)
  4588. {
  4589. int ret = 0;
  4590. struct snd_soc_codec *codec = tasha->codec;
  4591. if (!tasha->wcd_native_clk) {
  4592. dev_err(tasha->dev, "%s: wcd native clock is NULL\n", __func__);
  4593. return -EINVAL;
  4594. }
  4595. dev_dbg(tasha->dev, "%s: native_clk_enable = %u\n", __func__, enable);
  4596. if (enable) {
  4597. ret = clk_prepare_enable(tasha->wcd_native_clk);
  4598. if (ret) {
  4599. dev_err(tasha->dev, "%s: native clk enable failed\n",
  4600. __func__);
  4601. goto err;
  4602. }
  4603. if (++tasha->native_clk_users == 1) {
  4604. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4605. 0x10, 0x10);
  4606. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4607. 0x80, 0x80);
  4608. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4609. 0x04, 0x00);
  4610. snd_soc_update_bits(codec,
  4611. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4612. 0x02, 0x02);
  4613. }
  4614. } else {
  4615. if (tasha->native_clk_users &&
  4616. (--tasha->native_clk_users == 0)) {
  4617. snd_soc_update_bits(codec,
  4618. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4619. 0x02, 0x00);
  4620. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4621. 0x04, 0x04);
  4622. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4623. 0x80, 0x00);
  4624. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4625. 0x10, 0x00);
  4626. }
  4627. clk_disable_unprepare(tasha->wcd_native_clk);
  4628. }
  4629. dev_dbg(codec->dev, "%s: native_clk_users: %d\n", __func__,
  4630. tasha->native_clk_users);
  4631. err:
  4632. return ret;
  4633. }
  4634. static int tasha_codec_get_native_fifo_sync_mask(struct snd_soc_codec *codec,
  4635. int interp_n)
  4636. {
  4637. int mask = 0;
  4638. u16 reg;
  4639. u8 val1, val2, inp0 = 0;
  4640. u8 inp1 = 0, inp2 = 0;
  4641. reg = WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0 + (2 * interp_n) - 2;
  4642. val1 = snd_soc_read(codec, reg);
  4643. val2 = snd_soc_read(codec, reg + 1);
  4644. inp0 = val1 & 0x0F;
  4645. inp1 = (val1 >> 4) & 0x0F;
  4646. inp2 = (val2 >> 4) & 0x0F;
  4647. if (IS_VALID_NATIVE_FIFO_PORT(inp0))
  4648. mask |= (1 << (inp0 - 5));
  4649. if (IS_VALID_NATIVE_FIFO_PORT(inp1))
  4650. mask |= (1 << (inp1 - 5));
  4651. if (IS_VALID_NATIVE_FIFO_PORT(inp2))
  4652. mask |= (1 << (inp2 - 5));
  4653. dev_dbg(codec->dev, "%s: native fifo mask: 0x%x\n", __func__, mask);
  4654. if (!mask)
  4655. dev_err(codec->dev, "native fifo err,int:%d,inp0:%d,inp1:%d,inp2:%d\n",
  4656. interp_n, inp0, inp1, inp2);
  4657. return mask;
  4658. }
  4659. static int tasha_enable_native_supply(struct snd_soc_dapm_widget *w,
  4660. struct snd_kcontrol *kcontrol, int event)
  4661. {
  4662. int mask;
  4663. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4664. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4665. u16 interp_reg;
  4666. dev_dbg(codec->dev, "%s: event: %d, shift:%d\n", __func__, event,
  4667. w->shift);
  4668. if (w->shift < INTERP_HPHL || w->shift > INTERP_LO2)
  4669. return -EINVAL;
  4670. interp_reg = WCD9335_CDC_RX1_RX_PATH_CTL + 20 * (w->shift - 1);
  4671. mask = tasha_codec_get_native_fifo_sync_mask(codec, w->shift);
  4672. if (!mask)
  4673. return -EINVAL;
  4674. switch (event) {
  4675. case SND_SOC_DAPM_PRE_PMU:
  4676. /* Adjust interpolator rate to 44P1_NATIVE */
  4677. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x09);
  4678. __tasha_cdc_native_clk_enable(tasha, true);
  4679. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4680. mask, mask);
  4681. break;
  4682. case SND_SOC_DAPM_PRE_PMD:
  4683. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4684. mask, 0x0);
  4685. __tasha_cdc_native_clk_enable(tasha, false);
  4686. /* Adjust interpolator rate to default */
  4687. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x04);
  4688. break;
  4689. }
  4690. return 0;
  4691. }
  4692. static int tasha_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
  4693. struct snd_kcontrol *kcontrol, int event)
  4694. {
  4695. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4696. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4697. u16 gain_reg;
  4698. u16 reg;
  4699. int val;
  4700. int offset_val = 0;
  4701. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4702. if (!(strcmp(w->name, "RX INT0 INTERP"))) {
  4703. reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4704. gain_reg = WCD9335_CDC_RX0_RX_VOL_CTL;
  4705. } else if (!(strcmp(w->name, "RX INT1 INTERP"))) {
  4706. reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4707. gain_reg = WCD9335_CDC_RX1_RX_VOL_CTL;
  4708. } else if (!(strcmp(w->name, "RX INT2 INTERP"))) {
  4709. reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4710. gain_reg = WCD9335_CDC_RX2_RX_VOL_CTL;
  4711. } else if (!(strcmp(w->name, "RX INT3 INTERP"))) {
  4712. reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4713. gain_reg = WCD9335_CDC_RX3_RX_VOL_CTL;
  4714. } else if (!(strcmp(w->name, "RX INT4 INTERP"))) {
  4715. reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4716. gain_reg = WCD9335_CDC_RX4_RX_VOL_CTL;
  4717. } else if (!(strcmp(w->name, "RX INT5 INTERP"))) {
  4718. reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4719. gain_reg = WCD9335_CDC_RX5_RX_VOL_CTL;
  4720. } else if (!(strcmp(w->name, "RX INT6 INTERP"))) {
  4721. reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4722. gain_reg = WCD9335_CDC_RX6_RX_VOL_CTL;
  4723. } else if (!(strcmp(w->name, "RX INT7 INTERP"))) {
  4724. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4725. gain_reg = WCD9335_CDC_RX7_RX_VOL_CTL;
  4726. } else if (!(strcmp(w->name, "RX INT8 INTERP"))) {
  4727. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4728. gain_reg = WCD9335_CDC_RX8_RX_VOL_CTL;
  4729. } else {
  4730. dev_err(codec->dev, "%s: Interpolator reg not found\n",
  4731. __func__);
  4732. return -EINVAL;
  4733. }
  4734. switch (event) {
  4735. case SND_SOC_DAPM_PRE_PMU:
  4736. tasha_codec_vote_max_bw(codec, true);
  4737. /* Reset if needed */
  4738. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4739. break;
  4740. case SND_SOC_DAPM_POST_PMU:
  4741. tasha_config_compander(codec, w->shift, event);
  4742. /* apply gain after int clk is enabled */
  4743. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4744. (tasha->comp_enabled[COMPANDER_7] ||
  4745. tasha->comp_enabled[COMPANDER_8]) &&
  4746. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4747. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4748. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4749. 0x01, 0x01);
  4750. snd_soc_update_bits(codec,
  4751. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4752. 0x01, 0x01);
  4753. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4754. 0x01, 0x01);
  4755. snd_soc_update_bits(codec,
  4756. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4757. 0x01, 0x01);
  4758. offset_val = -2;
  4759. }
  4760. val = snd_soc_read(codec, gain_reg);
  4761. val += offset_val;
  4762. snd_soc_write(codec, gain_reg, val);
  4763. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4764. break;
  4765. case SND_SOC_DAPM_POST_PMD:
  4766. tasha_config_compander(codec, w->shift, event);
  4767. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4768. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4769. (tasha->comp_enabled[COMPANDER_7] ||
  4770. tasha->comp_enabled[COMPANDER_8]) &&
  4771. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4772. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4773. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4774. 0x01, 0x00);
  4775. snd_soc_update_bits(codec,
  4776. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4777. 0x01, 0x00);
  4778. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4779. 0x01, 0x00);
  4780. snd_soc_update_bits(codec,
  4781. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4782. 0x01, 0x00);
  4783. offset_val = 2;
  4784. val = snd_soc_read(codec, gain_reg);
  4785. val += offset_val;
  4786. snd_soc_write(codec, gain_reg, val);
  4787. }
  4788. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4789. break;
  4790. };
  4791. return 0;
  4792. }
  4793. static int tasha_codec_set_iir_gain(struct snd_soc_dapm_widget *w,
  4794. struct snd_kcontrol *kcontrol, int event)
  4795. {
  4796. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4797. dev_dbg(codec->dev, "%s: event = %d\n", __func__, event);
  4798. switch (event) {
  4799. case SND_SOC_DAPM_POST_PMU: /* fall through */
  4800. case SND_SOC_DAPM_PRE_PMD:
  4801. if (strnstr(w->name, "IIR0", sizeof("IIR0"))) {
  4802. snd_soc_write(codec,
  4803. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL,
  4804. snd_soc_read(codec,
  4805. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL));
  4806. snd_soc_write(codec,
  4807. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL,
  4808. snd_soc_read(codec,
  4809. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL));
  4810. snd_soc_write(codec,
  4811. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL,
  4812. snd_soc_read(codec,
  4813. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL));
  4814. snd_soc_write(codec,
  4815. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL,
  4816. snd_soc_read(codec,
  4817. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL));
  4818. } else {
  4819. snd_soc_write(codec,
  4820. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL,
  4821. snd_soc_read(codec,
  4822. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL));
  4823. snd_soc_write(codec,
  4824. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL,
  4825. snd_soc_read(codec,
  4826. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL));
  4827. snd_soc_write(codec,
  4828. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL,
  4829. snd_soc_read(codec,
  4830. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL));
  4831. }
  4832. break;
  4833. }
  4834. return 0;
  4835. }
  4836. static int tasha_codec_enable_on_demand_supply(
  4837. struct snd_soc_dapm_widget *w,
  4838. struct snd_kcontrol *kcontrol, int event)
  4839. {
  4840. int ret = 0;
  4841. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4842. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4843. struct on_demand_supply *supply;
  4844. if (w->shift >= ON_DEMAND_SUPPLIES_MAX) {
  4845. dev_err(codec->dev, "%s: error index > MAX Demand supplies",
  4846. __func__);
  4847. ret = -EINVAL;
  4848. goto out;
  4849. }
  4850. dev_dbg(codec->dev, "%s: supply: %s event: %d\n",
  4851. __func__, on_demand_supply_name[w->shift], event);
  4852. supply = &tasha->on_demand_list[w->shift];
  4853. WARN_ONCE(!supply->supply, "%s isn't defined\n",
  4854. on_demand_supply_name[w->shift]);
  4855. if (!supply->supply) {
  4856. dev_err(codec->dev, "%s: err supply not present ond for %d",
  4857. __func__, w->shift);
  4858. goto out;
  4859. }
  4860. switch (event) {
  4861. case SND_SOC_DAPM_PRE_PMU:
  4862. ret = regulator_enable(supply->supply);
  4863. if (ret)
  4864. dev_err(codec->dev, "%s: Failed to enable %s\n",
  4865. __func__,
  4866. on_demand_supply_name[w->shift]);
  4867. break;
  4868. case SND_SOC_DAPM_POST_PMD:
  4869. ret = regulator_disable(supply->supply);
  4870. if (ret)
  4871. dev_err(codec->dev, "%s: Failed to disable %s\n",
  4872. __func__,
  4873. on_demand_supply_name[w->shift]);
  4874. break;
  4875. default:
  4876. break;
  4877. };
  4878. out:
  4879. return ret;
  4880. }
  4881. static int tasha_codec_find_amic_input(struct snd_soc_codec *codec,
  4882. int adc_mux_n)
  4883. {
  4884. u16 mask, shift, adc_mux_in_reg;
  4885. u16 amic_mux_sel_reg;
  4886. bool is_amic;
  4887. if (adc_mux_n < 0 || adc_mux_n > WCD9335_MAX_VALID_ADC_MUX ||
  4888. adc_mux_n == WCD9335_INVALID_ADC_MUX)
  4889. return 0;
  4890. /* Check whether adc mux input is AMIC or DMIC */
  4891. if (adc_mux_n < 4) {
  4892. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
  4893. 2 * adc_mux_n;
  4894. amic_mux_sel_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  4895. 2 * adc_mux_n;
  4896. mask = 0x03;
  4897. shift = 0;
  4898. } else {
  4899. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  4900. adc_mux_n - 4;
  4901. amic_mux_sel_reg = adc_mux_in_reg;
  4902. mask = 0xC0;
  4903. shift = 6;
  4904. }
  4905. is_amic = (((snd_soc_read(codec, adc_mux_in_reg) & mask) >> shift)
  4906. == 1);
  4907. if (!is_amic)
  4908. return 0;
  4909. return snd_soc_read(codec, amic_mux_sel_reg) & 0x07;
  4910. }
  4911. static void tasha_codec_set_tx_hold(struct snd_soc_codec *codec,
  4912. u16 amic_reg, bool set)
  4913. {
  4914. u8 mask = 0x20;
  4915. u8 val;
  4916. if (amic_reg == WCD9335_ANA_AMIC1 ||
  4917. amic_reg == WCD9335_ANA_AMIC3 ||
  4918. amic_reg == WCD9335_ANA_AMIC5)
  4919. mask = 0x40;
  4920. val = set ? mask : 0x00;
  4921. switch (amic_reg) {
  4922. case WCD9335_ANA_AMIC1:
  4923. case WCD9335_ANA_AMIC2:
  4924. snd_soc_update_bits(codec, WCD9335_ANA_AMIC2, mask, val);
  4925. break;
  4926. case WCD9335_ANA_AMIC3:
  4927. case WCD9335_ANA_AMIC4:
  4928. snd_soc_update_bits(codec, WCD9335_ANA_AMIC4, mask, val);
  4929. break;
  4930. case WCD9335_ANA_AMIC5:
  4931. case WCD9335_ANA_AMIC6:
  4932. snd_soc_update_bits(codec, WCD9335_ANA_AMIC6, mask, val);
  4933. break;
  4934. default:
  4935. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4936. __func__, amic_reg);
  4937. break;
  4938. }
  4939. }
  4940. static int tasha_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w,
  4941. struct snd_kcontrol *kcontrol, int event)
  4942. {
  4943. int adc_mux_n = w->shift;
  4944. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4945. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4946. int amic_n;
  4947. dev_dbg(codec->dev, "%s: event: %d\n", __func__, event);
  4948. switch (event) {
  4949. case SND_SOC_DAPM_POST_PMU:
  4950. amic_n = tasha_codec_find_amic_input(codec, adc_mux_n);
  4951. if (amic_n) {
  4952. /*
  4953. * Prevent ANC Rx pop by leaving Tx FE in HOLD
  4954. * state until PA is up. Track AMIC being used
  4955. * so we can release the HOLD later.
  4956. */
  4957. set_bit(ANC_MIC_AMIC1 + amic_n - 1,
  4958. &tasha->status_mask);
  4959. }
  4960. break;
  4961. default:
  4962. break;
  4963. }
  4964. return 0;
  4965. }
  4966. static u16 tasha_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic)
  4967. {
  4968. u16 pwr_level_reg = 0;
  4969. switch (amic) {
  4970. case 1:
  4971. case 2:
  4972. pwr_level_reg = WCD9335_ANA_AMIC1;
  4973. break;
  4974. case 3:
  4975. case 4:
  4976. pwr_level_reg = WCD9335_ANA_AMIC3;
  4977. break;
  4978. case 5:
  4979. case 6:
  4980. pwr_level_reg = WCD9335_ANA_AMIC5;
  4981. break;
  4982. default:
  4983. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4984. __func__, amic);
  4985. break;
  4986. }
  4987. return pwr_level_reg;
  4988. }
  4989. #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
  4990. #define CF_MIN_3DB_4HZ 0x0
  4991. #define CF_MIN_3DB_75HZ 0x1
  4992. #define CF_MIN_3DB_150HZ 0x2
  4993. static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work)
  4994. {
  4995. struct delayed_work *hpf_delayed_work;
  4996. struct hpf_work *hpf_work;
  4997. struct tasha_priv *tasha;
  4998. struct snd_soc_codec *codec;
  4999. u16 dec_cfg_reg, amic_reg;
  5000. u8 hpf_cut_off_freq;
  5001. int amic_n;
  5002. hpf_delayed_work = to_delayed_work(work);
  5003. hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
  5004. tasha = hpf_work->tasha;
  5005. codec = tasha->codec;
  5006. hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
  5007. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator;
  5008. dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
  5009. __func__, hpf_work->decimator, hpf_cut_off_freq);
  5010. amic_n = tasha_codec_find_amic_input(codec, hpf_work->decimator);
  5011. if (amic_n) {
  5012. amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1;
  5013. tasha_codec_set_tx_hold(codec, amic_reg, false);
  5014. }
  5015. tasha_codec_vote_max_bw(codec, true);
  5016. snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  5017. hpf_cut_off_freq << 5);
  5018. tasha_codec_vote_max_bw(codec, false);
  5019. }
  5020. static void tasha_tx_mute_update_callback(struct work_struct *work)
  5021. {
  5022. struct tx_mute_work *tx_mute_dwork;
  5023. struct tasha_priv *tasha;
  5024. struct delayed_work *delayed_work;
  5025. struct snd_soc_codec *codec;
  5026. u16 tx_vol_ctl_reg, hpf_gate_reg;
  5027. delayed_work = to_delayed_work(work);
  5028. tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
  5029. tasha = tx_mute_dwork->tasha;
  5030. codec = tasha->codec;
  5031. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  5032. 16 * tx_mute_dwork->decimator;
  5033. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 +
  5034. 16 * tx_mute_dwork->decimator;
  5035. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x01);
  5036. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5037. }
  5038. static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w,
  5039. struct snd_kcontrol *kcontrol, int event)
  5040. {
  5041. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5042. unsigned int decimator;
  5043. char *dec_adc_mux_name = NULL;
  5044. char *widget_name = NULL;
  5045. char *wname;
  5046. int ret = 0, amic_n;
  5047. u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
  5048. u16 tx_gain_ctl_reg;
  5049. char *dec;
  5050. u8 hpf_cut_off_freq;
  5051. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5052. dev_dbg(codec->dev, "%s %d\n", __func__, event);
  5053. widget_name = kstrndup(w->name, 15, GFP_KERNEL);
  5054. if (!widget_name)
  5055. return -ENOMEM;
  5056. wname = widget_name;
  5057. dec_adc_mux_name = strsep(&widget_name, " ");
  5058. if (!dec_adc_mux_name) {
  5059. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5060. __func__, w->name);
  5061. ret = -EINVAL;
  5062. goto out;
  5063. }
  5064. dec_adc_mux_name = widget_name;
  5065. dec = strpbrk(dec_adc_mux_name, "012345678");
  5066. if (!dec) {
  5067. dev_err(codec->dev, "%s: decimator index not found\n",
  5068. __func__);
  5069. ret = -EINVAL;
  5070. goto out;
  5071. }
  5072. ret = kstrtouint(dec, 10, &decimator);
  5073. if (ret < 0) {
  5074. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5075. __func__, wname);
  5076. ret = -EINVAL;
  5077. goto out;
  5078. }
  5079. dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__,
  5080. w->name, decimator);
  5081. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator;
  5082. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 + 16 * decimator;
  5083. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * decimator;
  5084. tx_gain_ctl_reg = WCD9335_CDC_TX0_TX_VOL_CTL + 16 * decimator;
  5085. switch (event) {
  5086. case SND_SOC_DAPM_PRE_PMU:
  5087. amic_n = tasha_codec_find_amic_input(codec, decimator);
  5088. if (amic_n)
  5089. pwr_level_reg = tasha_codec_get_amic_pwlvl_reg(codec,
  5090. amic_n);
  5091. if (pwr_level_reg) {
  5092. switch ((snd_soc_read(codec, pwr_level_reg) &
  5093. WCD9335_AMIC_PWR_LVL_MASK) >>
  5094. WCD9335_AMIC_PWR_LVL_SHIFT) {
  5095. case WCD9335_AMIC_PWR_LEVEL_LP:
  5096. snd_soc_update_bits(codec, dec_cfg_reg,
  5097. WCD9335_DEC_PWR_LVL_MASK,
  5098. WCD9335_DEC_PWR_LVL_LP);
  5099. break;
  5100. case WCD9335_AMIC_PWR_LEVEL_HP:
  5101. snd_soc_update_bits(codec, dec_cfg_reg,
  5102. WCD9335_DEC_PWR_LVL_MASK,
  5103. WCD9335_DEC_PWR_LVL_HP);
  5104. break;
  5105. case WCD9335_AMIC_PWR_LEVEL_DEFAULT:
  5106. default:
  5107. snd_soc_update_bits(codec, dec_cfg_reg,
  5108. WCD9335_DEC_PWR_LVL_MASK,
  5109. WCD9335_DEC_PWR_LVL_DF);
  5110. break;
  5111. }
  5112. }
  5113. hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) &
  5114. TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
  5115. tasha->tx_hpf_work[decimator].hpf_cut_off_freq =
  5116. hpf_cut_off_freq;
  5117. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
  5118. snd_soc_update_bits(codec, dec_cfg_reg,
  5119. TX_HPF_CUT_OFF_FREQ_MASK,
  5120. CF_MIN_3DB_150HZ << 5);
  5121. /* Enable TX PGA Mute */
  5122. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5123. break;
  5124. case SND_SOC_DAPM_POST_PMU:
  5125. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00);
  5126. if (decimator == 0) {
  5127. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5128. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0xA3);
  5129. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5130. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x03);
  5131. }
  5132. /* schedule work queue to Remove Mute */
  5133. schedule_delayed_work(&tasha->tx_mute_dwork[decimator].dwork,
  5134. msecs_to_jiffies(tx_unmute_delay));
  5135. if (tasha->tx_hpf_work[decimator].hpf_cut_off_freq !=
  5136. CF_MIN_3DB_150HZ)
  5137. schedule_delayed_work(
  5138. &tasha->tx_hpf_work[decimator].dwork,
  5139. msecs_to_jiffies(300));
  5140. /* apply gain after decimator is enabled */
  5141. snd_soc_write(codec, tx_gain_ctl_reg,
  5142. snd_soc_read(codec, tx_gain_ctl_reg));
  5143. break;
  5144. case SND_SOC_DAPM_PRE_PMD:
  5145. hpf_cut_off_freq =
  5146. tasha->tx_hpf_work[decimator].hpf_cut_off_freq;
  5147. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5148. if (cancel_delayed_work_sync(
  5149. &tasha->tx_hpf_work[decimator].dwork)) {
  5150. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  5151. tasha_codec_vote_max_bw(codec, true);
  5152. snd_soc_update_bits(codec, dec_cfg_reg,
  5153. TX_HPF_CUT_OFF_FREQ_MASK,
  5154. hpf_cut_off_freq << 5);
  5155. tasha_codec_vote_max_bw(codec, false);
  5156. }
  5157. }
  5158. cancel_delayed_work_sync(
  5159. &tasha->tx_mute_dwork[decimator].dwork);
  5160. break;
  5161. case SND_SOC_DAPM_POST_PMD:
  5162. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5163. break;
  5164. };
  5165. out:
  5166. kfree(wname);
  5167. return ret;
  5168. }
  5169. static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec,
  5170. unsigned int dmic, struct wcd9xxx_pdata *pdata)
  5171. {
  5172. u8 tx_stream_fs;
  5173. u8 adc_mux_index = 0, adc_mux_sel = 0;
  5174. bool dec_found = false;
  5175. u16 adc_mux_ctl_reg, tx_fs_reg;
  5176. u32 dmic_fs;
  5177. while (dec_found == 0 && adc_mux_index < WCD9335_MAX_VALID_ADC_MUX) {
  5178. if (adc_mux_index < 4) {
  5179. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  5180. (adc_mux_index * 2);
  5181. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5182. 0x78) >> 3) - 1;
  5183. } else if (adc_mux_index < 9) {
  5184. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  5185. ((adc_mux_index - 4) * 1);
  5186. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5187. 0x38) >> 3) - 1;
  5188. } else if (adc_mux_index == 9) {
  5189. ++adc_mux_index;
  5190. continue;
  5191. }
  5192. if (adc_mux_sel == dmic)
  5193. dec_found = true;
  5194. else
  5195. ++adc_mux_index;
  5196. }
  5197. if (dec_found == true && adc_mux_index <= 8) {
  5198. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index);
  5199. tx_stream_fs = snd_soc_read(codec, tx_fs_reg) & 0x0F;
  5200. dmic_fs = tx_stream_fs <= 4 ? WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ :
  5201. WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  5202. /*
  5203. * Check for ECPP path selection and DEC1 not connected to
  5204. * any other audio path to apply ECPP DMIC sample rate
  5205. */
  5206. if ((adc_mux_index == 1) &&
  5207. ((snd_soc_read(codec, WCD9335_CPE_SS_US_EC_MUX_CFG)
  5208. & 0x0F) == 0x0A) &&
  5209. ((snd_soc_read(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0)
  5210. & 0x0C) == 0x00)) {
  5211. dmic_fs = pdata->ecpp_dmic_sample_rate;
  5212. }
  5213. } else {
  5214. dmic_fs = pdata->dmic_sample_rate;
  5215. }
  5216. return dmic_fs;
  5217. }
  5218. static u8 tasha_get_dmic_clk_val(struct snd_soc_codec *codec,
  5219. u32 mclk_rate, u32 dmic_clk_rate)
  5220. {
  5221. u32 div_factor;
  5222. u8 dmic_ctl_val;
  5223. dev_dbg(codec->dev,
  5224. "%s: mclk_rate = %d, dmic_sample_rate = %d\n",
  5225. __func__, mclk_rate, dmic_clk_rate);
  5226. /* Default value to return in case of error */
  5227. if (mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  5228. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5229. else
  5230. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5231. if (dmic_clk_rate == 0) {
  5232. dev_err(codec->dev,
  5233. "%s: dmic_sample_rate cannot be 0\n",
  5234. __func__);
  5235. goto done;
  5236. }
  5237. div_factor = mclk_rate / dmic_clk_rate;
  5238. switch (div_factor) {
  5239. case 2:
  5240. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5241. break;
  5242. case 3:
  5243. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5244. break;
  5245. case 4:
  5246. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_4;
  5247. break;
  5248. case 6:
  5249. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_6;
  5250. break;
  5251. case 8:
  5252. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_8;
  5253. break;
  5254. case 16:
  5255. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_16;
  5256. break;
  5257. default:
  5258. dev_err(codec->dev,
  5259. "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n",
  5260. __func__, div_factor, mclk_rate, dmic_clk_rate);
  5261. break;
  5262. }
  5263. done:
  5264. return dmic_ctl_val;
  5265. }
  5266. static int tasha_codec_enable_adc(struct snd_soc_dapm_widget *w,
  5267. struct snd_kcontrol *kcontrol, int event)
  5268. {
  5269. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5270. dev_dbg(codec->dev, "%s: event:%d\n", __func__, event);
  5271. switch (event) {
  5272. case SND_SOC_DAPM_PRE_PMU:
  5273. tasha_codec_set_tx_hold(codec, w->reg, true);
  5274. break;
  5275. default:
  5276. break;
  5277. }
  5278. return 0;
  5279. }
  5280. static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w,
  5281. struct snd_kcontrol *kcontrol, int event)
  5282. {
  5283. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5284. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5285. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  5286. u8 dmic_clk_en = 0x01;
  5287. u16 dmic_clk_reg;
  5288. s32 *dmic_clk_cnt;
  5289. u8 dmic_rate_val, dmic_rate_shift = 1;
  5290. unsigned int dmic;
  5291. u32 dmic_sample_rate;
  5292. int ret;
  5293. char *wname;
  5294. wname = strpbrk(w->name, "012345");
  5295. if (!wname) {
  5296. dev_err(codec->dev, "%s: widget not found\n", __func__);
  5297. return -EINVAL;
  5298. }
  5299. ret = kstrtouint(wname, 10, &dmic);
  5300. if (ret < 0) {
  5301. dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n",
  5302. __func__);
  5303. return -EINVAL;
  5304. }
  5305. switch (dmic) {
  5306. case 0:
  5307. case 1:
  5308. dmic_clk_cnt = &(tasha->dmic_0_1_clk_cnt);
  5309. dmic_clk_reg = WCD9335_CPE_SS_DMIC0_CTL;
  5310. break;
  5311. case 2:
  5312. case 3:
  5313. dmic_clk_cnt = &(tasha->dmic_2_3_clk_cnt);
  5314. dmic_clk_reg = WCD9335_CPE_SS_DMIC1_CTL;
  5315. break;
  5316. case 4:
  5317. case 5:
  5318. dmic_clk_cnt = &(tasha->dmic_4_5_clk_cnt);
  5319. dmic_clk_reg = WCD9335_CPE_SS_DMIC2_CTL;
  5320. break;
  5321. default:
  5322. dev_err(codec->dev, "%s: Invalid DMIC Selection\n",
  5323. __func__);
  5324. return -EINVAL;
  5325. };
  5326. dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
  5327. __func__, event, dmic, *dmic_clk_cnt);
  5328. switch (event) {
  5329. case SND_SOC_DAPM_PRE_PMU:
  5330. dmic_sample_rate = tasha_get_dmic_sample_rate(codec, dmic,
  5331. pdata);
  5332. dmic_rate_val =
  5333. tasha_get_dmic_clk_val(codec,
  5334. pdata->mclk_rate,
  5335. dmic_sample_rate);
  5336. (*dmic_clk_cnt)++;
  5337. if (*dmic_clk_cnt == 1) {
  5338. snd_soc_update_bits(codec, dmic_clk_reg,
  5339. 0x07 << dmic_rate_shift,
  5340. dmic_rate_val << dmic_rate_shift);
  5341. snd_soc_update_bits(codec, dmic_clk_reg,
  5342. dmic_clk_en, dmic_clk_en);
  5343. }
  5344. break;
  5345. case SND_SOC_DAPM_POST_PMD:
  5346. dmic_rate_val =
  5347. tasha_get_dmic_clk_val(codec,
  5348. pdata->mclk_rate,
  5349. pdata->mad_dmic_sample_rate);
  5350. (*dmic_clk_cnt)--;
  5351. if (*dmic_clk_cnt == 0) {
  5352. snd_soc_update_bits(codec, dmic_clk_reg,
  5353. dmic_clk_en, 0);
  5354. snd_soc_update_bits(codec, dmic_clk_reg,
  5355. 0x07 << dmic_rate_shift,
  5356. dmic_rate_val << dmic_rate_shift);
  5357. }
  5358. break;
  5359. };
  5360. return 0;
  5361. }
  5362. static int __tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5363. int event)
  5364. {
  5365. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5366. int micb_num;
  5367. dev_dbg(codec->dev, "%s: wname: %s, event: %d\n",
  5368. __func__, w->name, event);
  5369. if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1")))
  5370. micb_num = MIC_BIAS_1;
  5371. else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2")))
  5372. micb_num = MIC_BIAS_2;
  5373. else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3")))
  5374. micb_num = MIC_BIAS_3;
  5375. else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4")))
  5376. micb_num = MIC_BIAS_4;
  5377. else
  5378. return -EINVAL;
  5379. switch (event) {
  5380. case SND_SOC_DAPM_PRE_PMU:
  5381. /*
  5382. * MIC BIAS can also be requested by MBHC,
  5383. * so use ref count to handle micbias pullup
  5384. * and enable requests
  5385. */
  5386. tasha_micbias_control(codec, micb_num, MICB_ENABLE, true);
  5387. break;
  5388. case SND_SOC_DAPM_POST_PMU:
  5389. /* wait for cnp time */
  5390. usleep_range(1000, 1100);
  5391. break;
  5392. case SND_SOC_DAPM_POST_PMD:
  5393. tasha_micbias_control(codec, micb_num, MICB_DISABLE, true);
  5394. break;
  5395. };
  5396. return 0;
  5397. }
  5398. static int tasha_codec_ldo_h_control(struct snd_soc_dapm_widget *w,
  5399. int event)
  5400. {
  5401. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5402. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5403. if (SND_SOC_DAPM_EVENT_ON(event)) {
  5404. tasha->ldo_h_users++;
  5405. if (tasha->ldo_h_users == 1)
  5406. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5407. 0x80, 0x80);
  5408. }
  5409. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  5410. tasha->ldo_h_users--;
  5411. if (tasha->ldo_h_users < 0)
  5412. tasha->ldo_h_users = 0;
  5413. if (tasha->ldo_h_users == 0)
  5414. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5415. 0x80, 0x00);
  5416. }
  5417. return 0;
  5418. }
  5419. static int tasha_codec_force_enable_ldo_h(struct snd_soc_dapm_widget *w,
  5420. struct snd_kcontrol *kcontrol,
  5421. int event)
  5422. {
  5423. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5424. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5425. switch (event) {
  5426. case SND_SOC_DAPM_PRE_PMU:
  5427. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5428. tasha_codec_ldo_h_control(w, event);
  5429. break;
  5430. case SND_SOC_DAPM_POST_PMD:
  5431. tasha_codec_ldo_h_control(w, event);
  5432. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5433. break;
  5434. }
  5435. return 0;
  5436. }
  5437. static int tasha_codec_force_enable_micbias(struct snd_soc_dapm_widget *w,
  5438. struct snd_kcontrol *kcontrol,
  5439. int event)
  5440. {
  5441. int ret = 0;
  5442. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5443. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5444. switch (event) {
  5445. case SND_SOC_DAPM_PRE_PMU:
  5446. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5447. tasha_cdc_mclk_enable(codec, true, true);
  5448. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_PRE_PMU);
  5449. /* Wait for 1ms for better cnp */
  5450. usleep_range(1000, 1100);
  5451. tasha_cdc_mclk_enable(codec, false, true);
  5452. break;
  5453. case SND_SOC_DAPM_POST_PMD:
  5454. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_POST_PMD);
  5455. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5456. break;
  5457. }
  5458. return ret;
  5459. }
  5460. static int tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5461. struct snd_kcontrol *kcontrol, int event)
  5462. {
  5463. return __tasha_codec_enable_micbias(w, event);
  5464. }
  5465. static int tasha_codec_enable_standalone_ldo_h(struct snd_soc_codec *codec,
  5466. bool enable)
  5467. {
  5468. int rc;
  5469. if (enable)
  5470. rc = snd_soc_dapm_force_enable_pin(
  5471. snd_soc_codec_get_dapm(codec),
  5472. DAPM_LDO_H_STANDALONE);
  5473. else
  5474. rc = snd_soc_dapm_disable_pin(
  5475. snd_soc_codec_get_dapm(codec),
  5476. DAPM_LDO_H_STANDALONE);
  5477. if (!rc)
  5478. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5479. else
  5480. dev_err(codec->dev, "%s: ldo_h force %s pin failed\n",
  5481. __func__, (enable ? "enable" : "disable"));
  5482. return rc;
  5483. }
  5484. /*
  5485. * tasha_codec_enable_standalone_micbias - enable micbias standalone
  5486. * @codec: pointer to codec instance
  5487. * @micb_num: number of micbias to be enabled
  5488. * @enable: true to enable micbias or false to disable
  5489. *
  5490. * This function is used to enable micbias (1, 2, 3 or 4) during
  5491. * standalone independent of whether TX use-case is running or not
  5492. *
  5493. * Return: error code in case of failure or 0 for success
  5494. */
  5495. int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
  5496. int micb_num,
  5497. bool enable)
  5498. {
  5499. const char * const micb_names[] = {
  5500. DAPM_MICBIAS1_STANDALONE, DAPM_MICBIAS2_STANDALONE,
  5501. DAPM_MICBIAS3_STANDALONE, DAPM_MICBIAS4_STANDALONE
  5502. };
  5503. int micb_index = micb_num - 1;
  5504. int rc;
  5505. if (!codec) {
  5506. pr_err("%s: Codec memory is NULL\n", __func__);
  5507. return -EINVAL;
  5508. }
  5509. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  5510. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  5511. __func__, micb_index);
  5512. return -EINVAL;
  5513. }
  5514. if (enable)
  5515. rc = snd_soc_dapm_force_enable_pin(
  5516. snd_soc_codec_get_dapm(codec),
  5517. micb_names[micb_index]);
  5518. else
  5519. rc = snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec),
  5520. micb_names[micb_index]);
  5521. if (!rc)
  5522. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5523. else
  5524. dev_err(codec->dev, "%s: micbias%d force %s pin failed\n",
  5525. __func__, micb_num, (enable ? "enable" : "disable"));
  5526. return rc;
  5527. }
  5528. EXPORT_SYMBOL(tasha_codec_enable_standalone_micbias);
  5529. static const char *const tasha_anc_func_text[] = {"OFF", "ON"};
  5530. static const struct soc_enum tasha_anc_func_enum =
  5531. SOC_ENUM_SINGLE_EXT(2, tasha_anc_func_text);
  5532. static const char *const tasha_clkmode_text[] = {"EXTERNAL", "INTERNAL"};
  5533. static SOC_ENUM_SINGLE_EXT_DECL(tasha_clkmode_enum, tasha_clkmode_text);
  5534. /* Cutoff frequency for high pass filter */
  5535. static const char * const cf_text[] = {
  5536. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
  5537. };
  5538. static const char * const rx_cf_text[] = {
  5539. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ",
  5540. "CF_NEG_3DB_0P48HZ"
  5541. };
  5542. static const struct soc_enum cf_dec0_enum =
  5543. SOC_ENUM_SINGLE(WCD9335_CDC_TX0_TX_PATH_CFG0, 5, 3, cf_text);
  5544. static const struct soc_enum cf_dec1_enum =
  5545. SOC_ENUM_SINGLE(WCD9335_CDC_TX1_TX_PATH_CFG0, 5, 3, cf_text);
  5546. static const struct soc_enum cf_dec2_enum =
  5547. SOC_ENUM_SINGLE(WCD9335_CDC_TX2_TX_PATH_CFG0, 5, 3, cf_text);
  5548. static const struct soc_enum cf_dec3_enum =
  5549. SOC_ENUM_SINGLE(WCD9335_CDC_TX3_TX_PATH_CFG0, 5, 3, cf_text);
  5550. static const struct soc_enum cf_dec4_enum =
  5551. SOC_ENUM_SINGLE(WCD9335_CDC_TX4_TX_PATH_CFG0, 5, 3, cf_text);
  5552. static const struct soc_enum cf_dec5_enum =
  5553. SOC_ENUM_SINGLE(WCD9335_CDC_TX5_TX_PATH_CFG0, 5, 3, cf_text);
  5554. static const struct soc_enum cf_dec6_enum =
  5555. SOC_ENUM_SINGLE(WCD9335_CDC_TX6_TX_PATH_CFG0, 5, 3, cf_text);
  5556. static const struct soc_enum cf_dec7_enum =
  5557. SOC_ENUM_SINGLE(WCD9335_CDC_TX7_TX_PATH_CFG0, 5, 3, cf_text);
  5558. static const struct soc_enum cf_dec8_enum =
  5559. SOC_ENUM_SINGLE(WCD9335_CDC_TX8_TX_PATH_CFG0, 5, 3, cf_text);
  5560. static const struct soc_enum cf_int0_1_enum =
  5561. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5562. static SOC_ENUM_SINGLE_DECL(cf_int0_2_enum, WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 2,
  5563. rx_cf_text);
  5564. static const struct soc_enum cf_int1_1_enum =
  5565. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5566. static SOC_ENUM_SINGLE_DECL(cf_int1_2_enum, WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 2,
  5567. rx_cf_text);
  5568. static const struct soc_enum cf_int2_1_enum =
  5569. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5570. static SOC_ENUM_SINGLE_DECL(cf_int2_2_enum, WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 2,
  5571. rx_cf_text);
  5572. static const struct soc_enum cf_int3_1_enum =
  5573. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5574. static SOC_ENUM_SINGLE_DECL(cf_int3_2_enum, WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 2,
  5575. rx_cf_text);
  5576. static const struct soc_enum cf_int4_1_enum =
  5577. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5578. static SOC_ENUM_SINGLE_DECL(cf_int4_2_enum, WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 2,
  5579. rx_cf_text);
  5580. static const struct soc_enum cf_int5_1_enum =
  5581. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5582. static SOC_ENUM_SINGLE_DECL(cf_int5_2_enum, WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 2,
  5583. rx_cf_text);
  5584. static const struct soc_enum cf_int6_1_enum =
  5585. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5586. static SOC_ENUM_SINGLE_DECL(cf_int6_2_enum, WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 2,
  5587. rx_cf_text);
  5588. static const struct soc_enum cf_int7_1_enum =
  5589. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5590. static SOC_ENUM_SINGLE_DECL(cf_int7_2_enum, WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 2,
  5591. rx_cf_text);
  5592. static const struct soc_enum cf_int8_1_enum =
  5593. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5594. static SOC_ENUM_SINGLE_DECL(cf_int8_2_enum, WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 2,
  5595. rx_cf_text);
  5596. static const struct snd_soc_dapm_route audio_i2s_map[] = {
  5597. {"SLIM RX0 MUX", NULL, "RX_I2S_CTL"},
  5598. {"SLIM RX1 MUX", NULL, "RX_I2S_CTL"},
  5599. {"SLIM RX2 MUX", NULL, "RX_I2S_CTL"},
  5600. {"SLIM RX3 MUX", NULL, "RX_I2S_CTL"},
  5601. {"SLIM TX6 MUX", NULL, "TX_I2S_CTL"},
  5602. {"SLIM TX7 MUX", NULL, "TX_I2S_CTL"},
  5603. {"SLIM TX8 MUX", NULL, "TX_I2S_CTL"},
  5604. {"SLIM TX11 MUX", NULL, "TX_I2S_CTL"},
  5605. };
  5606. static const struct snd_soc_dapm_route audio_map[] = {
  5607. /* MAD */
  5608. {"MAD_SEL MUX", "SPE", "MAD_CPE_INPUT"},
  5609. {"MAD_SEL MUX", "MSM", "MADINPUT"},
  5610. {"MADONOFF", "Switch", "MAD_SEL MUX"},
  5611. {"MAD_BROADCAST", "Switch", "MAD_SEL MUX"},
  5612. {"TX13 INP MUX", "CPE_TX_PP", "MADONOFF"},
  5613. /* CPE HW MAD bypass */
  5614. {"CPE IN Mixer", "MAD_BYPASS", "SLIM TX1 MUX"},
  5615. {"AIF4_MAD Mixer", "SLIM TX1", "CPE IN Mixer"},
  5616. {"AIF4_MAD Mixer", "SLIM TX12", "MADONOFF"},
  5617. {"AIF4_MAD Mixer", "SLIM TX13", "TX13 INP MUX"},
  5618. {"AIF4 MAD", NULL, "AIF4_MAD Mixer"},
  5619. {"AIF4 MAD", NULL, "AIF4"},
  5620. {"EC BUF MUX INP", "DEC1", "ADC MUX1"},
  5621. {"AIF5 CPE", NULL, "EC BUF MUX INP"},
  5622. /* SLIMBUS Connections */
  5623. {"AIF1 CAP", NULL, "AIF1_CAP Mixer"},
  5624. {"AIF2 CAP", NULL, "AIF2_CAP Mixer"},
  5625. {"AIF3 CAP", NULL, "AIF3_CAP Mixer"},
  5626. /* VI Feedback */
  5627. {"AIF4_VI Mixer", "SPKR_VI_1", "VIINPUT"},
  5628. {"AIF4_VI Mixer", "SPKR_VI_2", "VIINPUT"},
  5629. {"AIF4 VI", NULL, "AIF4_VI Mixer"},
  5630. /* SLIM_MIXER("AIF1_CAP Mixer"),*/
  5631. {"AIF1_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5632. {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5633. {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5634. {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5635. {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5636. {"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5637. {"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5638. {"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5639. {"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5640. {"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5641. {"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5642. {"AIF1_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5643. {"AIF1_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5644. /* SLIM_MIXER("AIF2_CAP Mixer"),*/
  5645. {"AIF2_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5646. {"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5647. {"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5648. {"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5649. {"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5650. {"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5651. {"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5652. {"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5653. {"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5654. {"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5655. {"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5656. {"AIF2_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5657. {"AIF2_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5658. /* SLIM_MIXER("AIF3_CAP Mixer"),*/
  5659. {"AIF3_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5660. {"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5661. {"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5662. {"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5663. {"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5664. {"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5665. {"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5666. {"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5667. {"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5668. {"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5669. {"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5670. {"AIF3_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5671. {"AIF3_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5672. {"SLIM TX0 MUX", "DEC0", "ADC MUX0"},
  5673. {"SLIM TX0 MUX", "RX_MIX_TX0", "RX MIX TX0 MUX"},
  5674. {"SLIM TX0 MUX", "DEC0_192", "ADC US MUX0"},
  5675. {"SLIM TX1 MUX", "DEC1", "ADC MUX1"},
  5676. {"SLIM TX1 MUX", "RX_MIX_TX1", "RX MIX TX1 MUX"},
  5677. {"SLIM TX1 MUX", "DEC1_192", "ADC US MUX1"},
  5678. {"SLIM TX2 MUX", "DEC2", "ADC MUX2"},
  5679. {"SLIM TX2 MUX", "RX_MIX_TX2", "RX MIX TX2 MUX"},
  5680. {"SLIM TX2 MUX", "DEC2_192", "ADC US MUX2"},
  5681. {"SLIM TX3 MUX", "DEC3", "ADC MUX3"},
  5682. {"SLIM TX3 MUX", "RX_MIX_TX3", "RX MIX TX3 MUX"},
  5683. {"SLIM TX3 MUX", "DEC3_192", "ADC US MUX3"},
  5684. {"SLIM TX4 MUX", "DEC4", "ADC MUX4"},
  5685. {"SLIM TX4 MUX", "RX_MIX_TX4", "RX MIX TX4 MUX"},
  5686. {"SLIM TX4 MUX", "DEC4_192", "ADC US MUX4"},
  5687. {"SLIM TX5 MUX", "DEC5", "ADC MUX5"},
  5688. {"SLIM TX5 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5689. {"SLIM TX5 MUX", "DEC5_192", "ADC US MUX5"},
  5690. {"SLIM TX6 MUX", "DEC6", "ADC MUX6"},
  5691. {"SLIM TX6 MUX", "RX_MIX_TX6", "RX MIX TX6 MUX"},
  5692. {"SLIM TX6 MUX", "DEC6_192", "ADC US MUX6"},
  5693. {"SLIM TX7 MUX", "DEC7", "ADC MUX7"},
  5694. {"SLIM TX7 MUX", "RX_MIX_TX7", "RX MIX TX7 MUX"},
  5695. {"SLIM TX7 MUX", "DEC7_192", "ADC US MUX7"},
  5696. {"SLIM TX8 MUX", "DEC8", "ADC MUX8"},
  5697. {"SLIM TX8 MUX", "RX_MIX_TX8", "RX MIX TX8 MUX"},
  5698. {"SLIM TX8 MUX", "DEC8_192", "ADC US MUX8"},
  5699. {"SLIM TX9 MUX", "DEC7", "ADC MUX7"},
  5700. {"SLIM TX9 MUX", "DEC7_192", "ADC US MUX7"},
  5701. {"SLIM TX10 MUX", "DEC6", "ADC MUX6"},
  5702. {"SLIM TX10 MUX", "DEC6_192", "ADC US MUX6"},
  5703. {"SLIM TX11 MUX", "DEC_0_5", "SLIM TX11 INP1 MUX"},
  5704. {"SLIM TX11 MUX", "DEC_9_12", "SLIM TX11 INP1 MUX"},
  5705. {"SLIM TX11 INP1 MUX", "DEC0", "ADC MUX0"},
  5706. {"SLIM TX11 INP1 MUX", "DEC1", "ADC MUX1"},
  5707. {"SLIM TX11 INP1 MUX", "DEC2", "ADC MUX2"},
  5708. {"SLIM TX11 INP1 MUX", "DEC3", "ADC MUX3"},
  5709. {"SLIM TX11 INP1 MUX", "DEC4", "ADC MUX4"},
  5710. {"SLIM TX11 INP1 MUX", "DEC5", "ADC MUX5"},
  5711. {"SLIM TX11 INP1 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5712. {"TX13 INP MUX", "MAD_BRDCST", "MAD_BROADCAST"},
  5713. {"TX13 INP MUX", "CDC_DEC_5", "SLIM TX13 MUX"},
  5714. {"SLIM TX13 MUX", "DEC5", "ADC MUX5"},
  5715. {"RX MIX TX0 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5716. {"RX MIX TX0 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5717. {"RX MIX TX0 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5718. {"RX MIX TX0 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5719. {"RX MIX TX0 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5720. {"RX MIX TX0 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5721. {"RX MIX TX0 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5722. {"RX MIX TX0 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5723. {"RX MIX TX0 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5724. {"RX MIX TX0 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5725. {"RX MIX TX0 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5726. {"RX MIX TX0 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5727. {"RX MIX TX0 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5728. {"RX MIX TX1 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5729. {"RX MIX TX1 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5730. {"RX MIX TX1 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5731. {"RX MIX TX1 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5732. {"RX MIX TX1 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5733. {"RX MIX TX1 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5734. {"RX MIX TX1 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5735. {"RX MIX TX1 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5736. {"RX MIX TX1 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5737. {"RX MIX TX1 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5738. {"RX MIX TX1 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5739. {"RX MIX TX1 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5740. {"RX MIX TX1 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5741. {"RX MIX TX2 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5742. {"RX MIX TX2 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5743. {"RX MIX TX2 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5744. {"RX MIX TX2 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5745. {"RX MIX TX2 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5746. {"RX MIX TX2 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5747. {"RX MIX TX2 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5748. {"RX MIX TX2 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5749. {"RX MIX TX2 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5750. {"RX MIX TX2 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5751. {"RX MIX TX2 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5752. {"RX MIX TX2 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5753. {"RX MIX TX2 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5754. {"RX MIX TX3 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5755. {"RX MIX TX3 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5756. {"RX MIX TX3 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5757. {"RX MIX TX3 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5758. {"RX MIX TX3 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5759. {"RX MIX TX3 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5760. {"RX MIX TX3 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5761. {"RX MIX TX3 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5762. {"RX MIX TX3 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5763. {"RX MIX TX3 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5764. {"RX MIX TX3 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5765. {"RX MIX TX3 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5766. {"RX MIX TX3 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5767. {"RX MIX TX4 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5768. {"RX MIX TX4 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5769. {"RX MIX TX4 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5770. {"RX MIX TX4 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5771. {"RX MIX TX4 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5772. {"RX MIX TX4 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5773. {"RX MIX TX4 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5774. {"RX MIX TX4 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5775. {"RX MIX TX4 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5776. {"RX MIX TX4 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5777. {"RX MIX TX4 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5778. {"RX MIX TX4 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5779. {"RX MIX TX4 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5780. {"RX MIX TX5 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5781. {"RX MIX TX5 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5782. {"RX MIX TX5 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5783. {"RX MIX TX5 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5784. {"RX MIX TX5 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5785. {"RX MIX TX5 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5786. {"RX MIX TX5 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5787. {"RX MIX TX5 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5788. {"RX MIX TX5 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5789. {"RX MIX TX5 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5790. {"RX MIX TX5 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5791. {"RX MIX TX5 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5792. {"RX MIX TX5 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5793. {"RX MIX TX6 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5794. {"RX MIX TX6 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5795. {"RX MIX TX6 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5796. {"RX MIX TX6 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5797. {"RX MIX TX6 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5798. {"RX MIX TX6 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5799. {"RX MIX TX6 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5800. {"RX MIX TX6 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5801. {"RX MIX TX6 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5802. {"RX MIX TX6 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5803. {"RX MIX TX6 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5804. {"RX MIX TX6 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5805. {"RX MIX TX6 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5806. {"RX MIX TX7 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5807. {"RX MIX TX7 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5808. {"RX MIX TX7 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5809. {"RX MIX TX7 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5810. {"RX MIX TX7 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5811. {"RX MIX TX7 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5812. {"RX MIX TX7 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5813. {"RX MIX TX7 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5814. {"RX MIX TX7 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5815. {"RX MIX TX7 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5816. {"RX MIX TX7 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5817. {"RX MIX TX7 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5818. {"RX MIX TX7 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5819. {"RX MIX TX8 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5820. {"RX MIX TX8 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5821. {"RX MIX TX8 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5822. {"RX MIX TX8 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5823. {"RX MIX TX8 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5824. {"RX MIX TX8 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5825. {"RX MIX TX8 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5826. {"RX MIX TX8 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5827. {"RX MIX TX8 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5828. {"RX MIX TX8 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5829. {"RX MIX TX8 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5830. {"RX MIX TX8 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5831. {"RX MIX TX8 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5832. {"ADC US MUX0", "US_Switch", "ADC MUX0"},
  5833. {"ADC US MUX1", "US_Switch", "ADC MUX1"},
  5834. {"ADC US MUX2", "US_Switch", "ADC MUX2"},
  5835. {"ADC US MUX3", "US_Switch", "ADC MUX3"},
  5836. {"ADC US MUX4", "US_Switch", "ADC MUX4"},
  5837. {"ADC US MUX5", "US_Switch", "ADC MUX5"},
  5838. {"ADC US MUX6", "US_Switch", "ADC MUX6"},
  5839. {"ADC US MUX7", "US_Switch", "ADC MUX7"},
  5840. {"ADC US MUX8", "US_Switch", "ADC MUX8"},
  5841. {"ADC MUX0", "DMIC", "DMIC MUX0"},
  5842. {"ADC MUX0", "AMIC", "AMIC MUX0"},
  5843. {"ADC MUX1", "DMIC", "DMIC MUX1"},
  5844. {"ADC MUX1", "AMIC", "AMIC MUX1"},
  5845. {"ADC MUX2", "DMIC", "DMIC MUX2"},
  5846. {"ADC MUX2", "AMIC", "AMIC MUX2"},
  5847. {"ADC MUX3", "DMIC", "DMIC MUX3"},
  5848. {"ADC MUX3", "AMIC", "AMIC MUX3"},
  5849. {"ADC MUX4", "DMIC", "DMIC MUX4"},
  5850. {"ADC MUX4", "AMIC", "AMIC MUX4"},
  5851. {"ADC MUX5", "DMIC", "DMIC MUX5"},
  5852. {"ADC MUX5", "AMIC", "AMIC MUX5"},
  5853. {"ADC MUX6", "DMIC", "DMIC MUX6"},
  5854. {"ADC MUX6", "AMIC", "AMIC MUX6"},
  5855. {"ADC MUX7", "DMIC", "DMIC MUX7"},
  5856. {"ADC MUX7", "AMIC", "AMIC MUX7"},
  5857. {"ADC MUX8", "DMIC", "DMIC MUX8"},
  5858. {"ADC MUX8", "AMIC", "AMIC MUX8"},
  5859. {"ADC MUX10", "DMIC", "DMIC MUX10"},
  5860. {"ADC MUX10", "AMIC", "AMIC MUX10"},
  5861. {"ADC MUX11", "DMIC", "DMIC MUX11"},
  5862. {"ADC MUX11", "AMIC", "AMIC MUX11"},
  5863. {"ADC MUX12", "DMIC", "DMIC MUX12"},
  5864. {"ADC MUX12", "AMIC", "AMIC MUX12"},
  5865. {"ADC MUX13", "DMIC", "DMIC MUX13"},
  5866. {"ADC MUX13", "AMIC", "AMIC MUX13"},
  5867. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX10"},
  5868. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX11"},
  5869. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX12"},
  5870. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX13"},
  5871. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX10"},
  5872. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX11"},
  5873. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX12"},
  5874. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX13"},
  5875. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX10"},
  5876. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX11"},
  5877. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX12"},
  5878. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX13"},
  5879. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX10"},
  5880. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX11"},
  5881. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX12"},
  5882. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX13"},
  5883. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX10"},
  5884. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX11"},
  5885. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX12"},
  5886. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX13"},
  5887. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX10"},
  5888. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX11"},
  5889. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX12"},
  5890. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX13"},
  5891. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX10"},
  5892. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX11"},
  5893. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX12"},
  5894. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX13"},
  5895. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX10"},
  5896. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX11"},
  5897. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX12"},
  5898. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX13"},
  5899. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX10"},
  5900. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX11"},
  5901. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX12"},
  5902. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX13"},
  5903. {"DMIC MUX0", "DMIC0", "DMIC0"},
  5904. {"DMIC MUX0", "DMIC1", "DMIC1"},
  5905. {"DMIC MUX0", "DMIC2", "DMIC2"},
  5906. {"DMIC MUX0", "DMIC3", "DMIC3"},
  5907. {"DMIC MUX0", "DMIC4", "DMIC4"},
  5908. {"DMIC MUX0", "DMIC5", "DMIC5"},
  5909. {"AMIC MUX0", "ADC1", "ADC1"},
  5910. {"AMIC MUX0", "ADC2", "ADC2"},
  5911. {"AMIC MUX0", "ADC3", "ADC3"},
  5912. {"AMIC MUX0", "ADC4", "ADC4"},
  5913. {"AMIC MUX0", "ADC5", "ADC5"},
  5914. {"AMIC MUX0", "ADC6", "ADC6"},
  5915. {"DMIC MUX1", "DMIC0", "DMIC0"},
  5916. {"DMIC MUX1", "DMIC1", "DMIC1"},
  5917. {"DMIC MUX1", "DMIC2", "DMIC2"},
  5918. {"DMIC MUX1", "DMIC3", "DMIC3"},
  5919. {"DMIC MUX1", "DMIC4", "DMIC4"},
  5920. {"DMIC MUX1", "DMIC5", "DMIC5"},
  5921. {"AMIC MUX1", "ADC1", "ADC1"},
  5922. {"AMIC MUX1", "ADC2", "ADC2"},
  5923. {"AMIC MUX1", "ADC3", "ADC3"},
  5924. {"AMIC MUX1", "ADC4", "ADC4"},
  5925. {"AMIC MUX1", "ADC5", "ADC5"},
  5926. {"AMIC MUX1", "ADC6", "ADC6"},
  5927. {"DMIC MUX2", "DMIC0", "DMIC0"},
  5928. {"DMIC MUX2", "DMIC1", "DMIC1"},
  5929. {"DMIC MUX2", "DMIC2", "DMIC2"},
  5930. {"DMIC MUX2", "DMIC3", "DMIC3"},
  5931. {"DMIC MUX2", "DMIC4", "DMIC4"},
  5932. {"DMIC MUX2", "DMIC5", "DMIC5"},
  5933. {"AMIC MUX2", "ADC1", "ADC1"},
  5934. {"AMIC MUX2", "ADC2", "ADC2"},
  5935. {"AMIC MUX2", "ADC3", "ADC3"},
  5936. {"AMIC MUX2", "ADC4", "ADC4"},
  5937. {"AMIC MUX2", "ADC5", "ADC5"},
  5938. {"AMIC MUX2", "ADC6", "ADC6"},
  5939. {"DMIC MUX3", "DMIC0", "DMIC0"},
  5940. {"DMIC MUX3", "DMIC1", "DMIC1"},
  5941. {"DMIC MUX3", "DMIC2", "DMIC2"},
  5942. {"DMIC MUX3", "DMIC3", "DMIC3"},
  5943. {"DMIC MUX3", "DMIC4", "DMIC4"},
  5944. {"DMIC MUX3", "DMIC5", "DMIC5"},
  5945. {"AMIC MUX3", "ADC1", "ADC1"},
  5946. {"AMIC MUX3", "ADC2", "ADC2"},
  5947. {"AMIC MUX3", "ADC3", "ADC3"},
  5948. {"AMIC MUX3", "ADC4", "ADC4"},
  5949. {"AMIC MUX3", "ADC5", "ADC5"},
  5950. {"AMIC MUX3", "ADC6", "ADC6"},
  5951. {"DMIC MUX4", "DMIC0", "DMIC0"},
  5952. {"DMIC MUX4", "DMIC1", "DMIC1"},
  5953. {"DMIC MUX4", "DMIC2", "DMIC2"},
  5954. {"DMIC MUX4", "DMIC3", "DMIC3"},
  5955. {"DMIC MUX4", "DMIC4", "DMIC4"},
  5956. {"DMIC MUX4", "DMIC5", "DMIC5"},
  5957. {"AMIC MUX4", "ADC1", "ADC1"},
  5958. {"AMIC MUX4", "ADC2", "ADC2"},
  5959. {"AMIC MUX4", "ADC3", "ADC3"},
  5960. {"AMIC MUX4", "ADC4", "ADC4"},
  5961. {"AMIC MUX4", "ADC5", "ADC5"},
  5962. {"AMIC MUX4", "ADC6", "ADC6"},
  5963. {"DMIC MUX5", "DMIC0", "DMIC0"},
  5964. {"DMIC MUX5", "DMIC1", "DMIC1"},
  5965. {"DMIC MUX5", "DMIC2", "DMIC2"},
  5966. {"DMIC MUX5", "DMIC3", "DMIC3"},
  5967. {"DMIC MUX5", "DMIC4", "DMIC4"},
  5968. {"DMIC MUX5", "DMIC5", "DMIC5"},
  5969. {"AMIC MUX5", "ADC1", "ADC1"},
  5970. {"AMIC MUX5", "ADC2", "ADC2"},
  5971. {"AMIC MUX5", "ADC3", "ADC3"},
  5972. {"AMIC MUX5", "ADC4", "ADC4"},
  5973. {"AMIC MUX5", "ADC5", "ADC5"},
  5974. {"AMIC MUX5", "ADC6", "ADC6"},
  5975. {"DMIC MUX6", "DMIC0", "DMIC0"},
  5976. {"DMIC MUX6", "DMIC1", "DMIC1"},
  5977. {"DMIC MUX6", "DMIC2", "DMIC2"},
  5978. {"DMIC MUX6", "DMIC3", "DMIC3"},
  5979. {"DMIC MUX6", "DMIC4", "DMIC4"},
  5980. {"DMIC MUX6", "DMIC5", "DMIC5"},
  5981. {"AMIC MUX6", "ADC1", "ADC1"},
  5982. {"AMIC MUX6", "ADC2", "ADC2"},
  5983. {"AMIC MUX6", "ADC3", "ADC3"},
  5984. {"AMIC MUX6", "ADC4", "ADC4"},
  5985. {"AMIC MUX6", "ADC5", "ADC5"},
  5986. {"AMIC MUX6", "ADC6", "ADC6"},
  5987. {"DMIC MUX7", "DMIC0", "DMIC0"},
  5988. {"DMIC MUX7", "DMIC1", "DMIC1"},
  5989. {"DMIC MUX7", "DMIC2", "DMIC2"},
  5990. {"DMIC MUX7", "DMIC3", "DMIC3"},
  5991. {"DMIC MUX7", "DMIC4", "DMIC4"},
  5992. {"DMIC MUX7", "DMIC5", "DMIC5"},
  5993. {"AMIC MUX7", "ADC1", "ADC1"},
  5994. {"AMIC MUX7", "ADC2", "ADC2"},
  5995. {"AMIC MUX7", "ADC3", "ADC3"},
  5996. {"AMIC MUX7", "ADC4", "ADC4"},
  5997. {"AMIC MUX7", "ADC5", "ADC5"},
  5998. {"AMIC MUX7", "ADC6", "ADC6"},
  5999. {"DMIC MUX8", "DMIC0", "DMIC0"},
  6000. {"DMIC MUX8", "DMIC1", "DMIC1"},
  6001. {"DMIC MUX8", "DMIC2", "DMIC2"},
  6002. {"DMIC MUX8", "DMIC3", "DMIC3"},
  6003. {"DMIC MUX8", "DMIC4", "DMIC4"},
  6004. {"DMIC MUX8", "DMIC5", "DMIC5"},
  6005. {"AMIC MUX8", "ADC1", "ADC1"},
  6006. {"AMIC MUX8", "ADC2", "ADC2"},
  6007. {"AMIC MUX8", "ADC3", "ADC3"},
  6008. {"AMIC MUX8", "ADC4", "ADC4"},
  6009. {"AMIC MUX8", "ADC5", "ADC5"},
  6010. {"AMIC MUX8", "ADC6", "ADC6"},
  6011. {"DMIC MUX10", "DMIC0", "DMIC0"},
  6012. {"DMIC MUX10", "DMIC1", "DMIC1"},
  6013. {"DMIC MUX10", "DMIC2", "DMIC2"},
  6014. {"DMIC MUX10", "DMIC3", "DMIC3"},
  6015. {"DMIC MUX10", "DMIC4", "DMIC4"},
  6016. {"DMIC MUX10", "DMIC5", "DMIC5"},
  6017. {"AMIC MUX10", "ADC1", "ADC1"},
  6018. {"AMIC MUX10", "ADC2", "ADC2"},
  6019. {"AMIC MUX10", "ADC3", "ADC3"},
  6020. {"AMIC MUX10", "ADC4", "ADC4"},
  6021. {"AMIC MUX10", "ADC5", "ADC5"},
  6022. {"AMIC MUX10", "ADC6", "ADC6"},
  6023. {"DMIC MUX11", "DMIC0", "DMIC0"},
  6024. {"DMIC MUX11", "DMIC1", "DMIC1"},
  6025. {"DMIC MUX11", "DMIC2", "DMIC2"},
  6026. {"DMIC MUX11", "DMIC3", "DMIC3"},
  6027. {"DMIC MUX11", "DMIC4", "DMIC4"},
  6028. {"DMIC MUX11", "DMIC5", "DMIC5"},
  6029. {"AMIC MUX11", "ADC1", "ADC1"},
  6030. {"AMIC MUX11", "ADC2", "ADC2"},
  6031. {"AMIC MUX11", "ADC3", "ADC3"},
  6032. {"AMIC MUX11", "ADC4", "ADC4"},
  6033. {"AMIC MUX11", "ADC5", "ADC5"},
  6034. {"AMIC MUX11", "ADC6", "ADC6"},
  6035. {"DMIC MUX12", "DMIC0", "DMIC0"},
  6036. {"DMIC MUX12", "DMIC1", "DMIC1"},
  6037. {"DMIC MUX12", "DMIC2", "DMIC2"},
  6038. {"DMIC MUX12", "DMIC3", "DMIC3"},
  6039. {"DMIC MUX12", "DMIC4", "DMIC4"},
  6040. {"DMIC MUX12", "DMIC5", "DMIC5"},
  6041. {"AMIC MUX12", "ADC1", "ADC1"},
  6042. {"AMIC MUX12", "ADC2", "ADC2"},
  6043. {"AMIC MUX12", "ADC3", "ADC3"},
  6044. {"AMIC MUX12", "ADC4", "ADC4"},
  6045. {"AMIC MUX12", "ADC5", "ADC5"},
  6046. {"AMIC MUX12", "ADC6", "ADC6"},
  6047. {"DMIC MUX13", "DMIC0", "DMIC0"},
  6048. {"DMIC MUX13", "DMIC1", "DMIC1"},
  6049. {"DMIC MUX13", "DMIC2", "DMIC2"},
  6050. {"DMIC MUX13", "DMIC3", "DMIC3"},
  6051. {"DMIC MUX13", "DMIC4", "DMIC4"},
  6052. {"DMIC MUX13", "DMIC5", "DMIC5"},
  6053. {"AMIC MUX13", "ADC1", "ADC1"},
  6054. {"AMIC MUX13", "ADC2", "ADC2"},
  6055. {"AMIC MUX13", "ADC3", "ADC3"},
  6056. {"AMIC MUX13", "ADC4", "ADC4"},
  6057. {"AMIC MUX13", "ADC5", "ADC5"},
  6058. {"AMIC MUX13", "ADC6", "ADC6"},
  6059. /* ADC Connections */
  6060. {"ADC1", NULL, "AMIC1"},
  6061. {"ADC2", NULL, "AMIC2"},
  6062. {"ADC3", NULL, "AMIC3"},
  6063. {"ADC4", NULL, "AMIC4"},
  6064. {"ADC5", NULL, "AMIC5"},
  6065. {"ADC6", NULL, "AMIC6"},
  6066. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP0"},
  6067. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP1"},
  6068. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP2"},
  6069. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP0"},
  6070. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP1"},
  6071. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP2"},
  6072. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP0"},
  6073. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP1"},
  6074. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP2"},
  6075. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP0"},
  6076. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP1"},
  6077. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP2"},
  6078. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP0"},
  6079. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP1"},
  6080. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP2"},
  6081. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP0"},
  6082. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP1"},
  6083. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP2"},
  6084. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP0"},
  6085. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP1"},
  6086. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP2"},
  6087. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP0"},
  6088. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP1"},
  6089. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP2"},
  6090. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP0"},
  6091. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP1"},
  6092. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP2"},
  6093. {"RX INT0 SEC MIX", NULL, "RX INT0_1 MIX1"},
  6094. {"RX INT0 MIX2", NULL, "RX INT0 SEC MIX"},
  6095. {"RX INT0 MIX2", NULL, "RX INT0 MIX2 INP"},
  6096. {"RX INT0 INTERP", NULL, "RX INT0 MIX2"},
  6097. {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 INTERP"},
  6098. {"RX INT0 DAC", NULL, "RX INT0 DEM MUX"},
  6099. {"RX INT0 DAC", NULL, "RX_BIAS"},
  6100. {"EAR PA", NULL, "RX INT0 DAC"},
  6101. {"EAR", NULL, "EAR PA"},
  6102. {"SPL SRC0 MUX", "SRC_IN_HPHL", "RX INT1_1 MIX1"},
  6103. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 MIX1"},
  6104. {"RX INT1 SPLINE MIX", "HPHL Switch", "SPL SRC0 MUX"},
  6105. {"RX INT1_1 NATIVE MUX", "ON", "RX INT1_1 MIX1"},
  6106. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 NATIVE MUX"},
  6107. {"RX INT1_1 NATIVE MUX", NULL, "RX INT1 NATIVE SUPPLY"},
  6108. {"RX INT1 SEC MIX", NULL, "RX INT1 SPLINE MIX"},
  6109. {"RX INT1 MIX2", NULL, "RX INT1 SEC MIX"},
  6110. {"RX INT1 MIX2", NULL, "RX INT1 MIX2 INP"},
  6111. {"RX INT1 INTERP", NULL, "RX INT1 MIX2"},
  6112. {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 INTERP"},
  6113. {"RX INT1 DAC", NULL, "RX INT1 DEM MUX"},
  6114. {"RX INT1 DAC", NULL, "RX_BIAS"},
  6115. {"HPHL PA", NULL, "RX INT1 DAC"},
  6116. {"HPHL", NULL, "HPHL PA"},
  6117. {"SPL SRC1 MUX", "SRC_IN_HPHR", "RX INT2_1 MIX1"},
  6118. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 MIX1"},
  6119. {"RX INT2 SPLINE MIX", "HPHR Switch", "SPL SRC1 MUX"},
  6120. {"RX INT2_1 NATIVE MUX", "ON", "RX INT2_1 MIX1"},
  6121. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 NATIVE MUX"},
  6122. {"RX INT2_1 NATIVE MUX", NULL, "RX INT2 NATIVE SUPPLY"},
  6123. {"RX INT2 SEC MIX", NULL, "RX INT2 SPLINE MIX"},
  6124. {"RX INT2 MIX2", NULL, "RX INT2 SEC MIX"},
  6125. {"RX INT2 MIX2", NULL, "RX INT2 MIX2 INP"},
  6126. {"RX INT2 INTERP", NULL, "RX INT2 MIX2"},
  6127. {"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 INTERP"},
  6128. {"RX INT2 DAC", NULL, "RX INT2 DEM MUX"},
  6129. {"RX INT2 DAC", NULL, "RX_BIAS"},
  6130. {"HPHR PA", NULL, "RX INT2 DAC"},
  6131. {"HPHR", NULL, "HPHR PA"},
  6132. {"SPL SRC0 MUX", "SRC_IN_LO1", "RX INT3_1 MIX1"},
  6133. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 MIX1"},
  6134. {"RX INT3 SPLINE MIX", "LO1 Switch", "SPL SRC0 MUX"},
  6135. {"RX INT3_1 NATIVE MUX", "ON", "RX INT3_1 MIX1"},
  6136. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 NATIVE MUX"},
  6137. {"RX INT3_1 NATIVE MUX", NULL, "RX INT3 NATIVE SUPPLY"},
  6138. {"RX INT3 SEC MIX", NULL, "RX INT3 SPLINE MIX"},
  6139. {"RX INT3 MIX2", NULL, "RX INT3 SEC MIX"},
  6140. {"RX INT3 MIX2", NULL, "RX INT3 MIX2 INP"},
  6141. {"RX INT3 INTERP", NULL, "RX INT3 MIX2"},
  6142. {"RX INT3 DAC", NULL, "RX INT3 INTERP"},
  6143. {"RX INT3 DAC", NULL, "RX_BIAS"},
  6144. {"LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6145. {"LINEOUT1", NULL, "LINEOUT1 PA"},
  6146. {"SPL SRC1 MUX", "SRC_IN_LO2", "RX INT4_1 MIX1"},
  6147. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 MIX1"},
  6148. {"RX INT4 SPLINE MIX", "LO2 Switch", "SPL SRC1 MUX"},
  6149. {"RX INT4_1 NATIVE MUX", "ON", "RX INT4_1 MIX1"},
  6150. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 NATIVE MUX"},
  6151. {"RX INT4_1 NATIVE MUX", NULL, "RX INT4 NATIVE SUPPLY"},
  6152. {"RX INT4 SEC MIX", NULL, "RX INT4 SPLINE MIX"},
  6153. {"RX INT4 MIX2", NULL, "RX INT4 SEC MIX"},
  6154. {"RX INT4 MIX2", NULL, "RX INT4 MIX2 INP"},
  6155. {"RX INT4 INTERP", NULL, "RX INT4 MIX2"},
  6156. {"RX INT4 DAC", NULL, "RX INT4 INTERP"},
  6157. {"RX INT4 DAC", NULL, "RX_BIAS"},
  6158. {"LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6159. {"LINEOUT2", NULL, "LINEOUT2 PA"},
  6160. {"SPL SRC2 MUX", "SRC_IN_LO3", "RX INT5_1 MIX1"},
  6161. {"RX INT5 SPLINE MIX", NULL, "RX INT5_1 MIX1"},
  6162. {"RX INT5 SPLINE MIX", "LO3 Switch", "SPL SRC2 MUX"},
  6163. {"RX INT5 SEC MIX", NULL, "RX INT5 SPLINE MIX"},
  6164. {"RX INT5 MIX2", NULL, "RX INT5 SEC MIX"},
  6165. {"RX INT5 INTERP", NULL, "RX INT5 MIX2"},
  6166. {"RX INT5 VBAT", "LO3 VBAT Enable", "RX INT5 INTERP"},
  6167. {"RX INT5 DAC", NULL, "RX INT5 VBAT"},
  6168. {"RX INT5 DAC", NULL, "RX INT5 INTERP"},
  6169. {"RX INT5 DAC", NULL, "RX_BIAS"},
  6170. {"LINEOUT3 PA", NULL, "RX INT5 DAC"},
  6171. {"LINEOUT3", NULL, "LINEOUT3 PA"},
  6172. {"SPL SRC3 MUX", "SRC_IN_LO4", "RX INT6_1 MIX1"},
  6173. {"RX INT6 SPLINE MIX", NULL, "RX INT6_1 MIX1"},
  6174. {"RX INT6 SPLINE MIX", "LO4 Switch", "SPL SRC3 MUX"},
  6175. {"RX INT6 SEC MIX", NULL, "RX INT6 SPLINE MIX"},
  6176. {"RX INT6 MIX2", NULL, "RX INT6 SEC MIX"},
  6177. {"RX INT6 INTERP", NULL, "RX INT6 MIX2"},
  6178. {"RX INT6 VBAT", "LO4 VBAT Enable", "RX INT6 INTERP"},
  6179. {"RX INT6 DAC", NULL, "RX INT6 VBAT"},
  6180. {"RX INT6 DAC", NULL, "RX INT6 INTERP"},
  6181. {"RX INT6 DAC", NULL, "RX_BIAS"},
  6182. {"LINEOUT4 PA", NULL, "RX INT6 DAC"},
  6183. {"LINEOUT4", NULL, "LINEOUT4 PA"},
  6184. {"SPL SRC2 MUX", "SRC_IN_SPKRL", "RX INT7_1 MIX1"},
  6185. {"RX INT7 SPLINE MIX", NULL, "RX INT7_1 MIX1"},
  6186. {"RX INT7 SPLINE MIX", "SPKRL Switch", "SPL SRC2 MUX"},
  6187. {"RX INT7 SEC MIX", NULL, "RX INT7 SPLINE MIX"},
  6188. {"RX INT7 MIX2", NULL, "RX INT7 SEC MIX"},
  6189. {"RX INT7 MIX2", NULL, "RX INT7 MIX2 INP"},
  6190. {"RX INT7 INTERP", NULL, "RX INT7 MIX2"},
  6191. {"RX INT7 VBAT", "SPKRL VBAT Enable", "RX INT7 INTERP"},
  6192. {"RX INT7 CHAIN", NULL, "RX INT7 VBAT"},
  6193. {"RX INT7 CHAIN", NULL, "RX INT7 INTERP"},
  6194. {"RX INT7 CHAIN", NULL, "RX_BIAS"},
  6195. {"SPK1 OUT", NULL, "RX INT7 CHAIN"},
  6196. {"ANC SPKR PA Enable", "Switch", "RX INT7 CHAIN"},
  6197. {"ANC SPK1 PA", NULL, "ANC SPKR PA Enable"},
  6198. {"SPK1 OUT", NULL, "ANC SPK1 PA"},
  6199. {"SPL SRC3 MUX", "SRC_IN_SPKRR", "RX INT8_1 MIX1"},
  6200. {"RX INT8 SPLINE MIX", NULL, "RX INT8_1 MIX1"},
  6201. {"RX INT8 SPLINE MIX", "SPKRR Switch", "SPL SRC3 MUX"},
  6202. {"RX INT8 SEC MIX", NULL, "RX INT8 SPLINE MIX"},
  6203. {"RX INT8 INTERP", NULL, "RX INT8 SEC MIX"},
  6204. {"RX INT8 VBAT", "SPKRR VBAT Enable", "RX INT8 INTERP"},
  6205. {"RX INT8 CHAIN", NULL, "RX INT8 VBAT"},
  6206. {"RX INT8 CHAIN", NULL, "RX INT8 INTERP"},
  6207. {"RX INT8 CHAIN", NULL, "RX_BIAS"},
  6208. {"SPK2 OUT", NULL, "RX INT8 CHAIN"},
  6209. {"ANC0 FB MUX", "ANC_IN_EAR", "RX INT0 MIX2"},
  6210. {"ANC0 FB MUX", "ANC_IN_HPHL", "RX INT1 MIX2"},
  6211. {"ANC0 FB MUX", "ANC_IN_LO1", "RX INT3 MIX2"},
  6212. {"ANC0 FB MUX", "ANC_IN_EAR_SPKR", "RX INT7 MIX2"},
  6213. {"ANC1 FB MUX", "ANC_IN_HPHR", "RX INT2 MIX2"},
  6214. {"ANC1 FB MUX", "ANC_IN_LO2", "RX INT4 MIX2"},
  6215. {"ANC HPHL Enable", "Switch", "ADC MUX10"},
  6216. {"ANC HPHL Enable", "Switch", "ADC MUX11"},
  6217. {"RX INT1 MIX2", NULL, "ANC HPHL Enable"},
  6218. {"ANC HPHR Enable", "Switch", "ADC MUX12"},
  6219. {"ANC HPHR Enable", "Switch", "ADC MUX13"},
  6220. {"RX INT2 MIX2", NULL, "ANC HPHR Enable"},
  6221. {"ANC EAR Enable", "Switch", "ADC MUX10"},
  6222. {"ANC EAR Enable", "Switch", "ADC MUX11"},
  6223. {"RX INT0 MIX2", NULL, "ANC EAR Enable"},
  6224. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX10"},
  6225. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX11"},
  6226. {"RX INT7 MIX2", NULL, "ANC OUT EAR SPKR Enable"},
  6227. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX10"},
  6228. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX11"},
  6229. {"RX INT3 MIX2", NULL, "ANC LINEOUT1 Enable"},
  6230. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX12"},
  6231. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX13"},
  6232. {"RX INT4 MIX2", NULL, "ANC LINEOUT2 Enable"},
  6233. {"ANC EAR PA", NULL, "RX INT0 DAC"},
  6234. {"ANC EAR", NULL, "ANC EAR PA"},
  6235. {"ANC HPHL PA", NULL, "RX INT1 DAC"},
  6236. {"ANC HPHL", NULL, "ANC HPHL PA"},
  6237. {"ANC HPHR PA", NULL, "RX INT2 DAC"},
  6238. {"ANC HPHR", NULL, "ANC HPHR PA"},
  6239. {"ANC LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6240. {"ANC LINEOUT1", NULL, "ANC LINEOUT1 PA"},
  6241. {"ANC LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6242. {"ANC LINEOUT2", NULL, "ANC LINEOUT2 PA"},
  6243. /* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/
  6244. {"SLIM RX0 MUX", "AIF1_PB", "AIF1 PB"},
  6245. {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
  6246. {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
  6247. {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
  6248. {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
  6249. {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
  6250. {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
  6251. {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
  6252. /* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/
  6253. {"SLIM RX0 MUX", "AIF2_PB", "AIF2 PB"},
  6254. {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
  6255. {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
  6256. {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
  6257. {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
  6258. {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
  6259. {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
  6260. {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
  6261. /* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/
  6262. {"SLIM RX0 MUX", "AIF3_PB", "AIF3 PB"},
  6263. {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
  6264. {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
  6265. {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
  6266. {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
  6267. {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
  6268. {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
  6269. {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
  6270. /* SLIM_MUX("AIF4_PB", "AIF4 PB"),*/
  6271. {"SLIM RX0 MUX", "AIF4_PB", "AIF4 PB"},
  6272. {"SLIM RX1 MUX", "AIF4_PB", "AIF4 PB"},
  6273. {"SLIM RX2 MUX", "AIF4_PB", "AIF4 PB"},
  6274. {"SLIM RX3 MUX", "AIF4_PB", "AIF4 PB"},
  6275. {"SLIM RX4 MUX", "AIF4_PB", "AIF4 PB"},
  6276. {"SLIM RX5 MUX", "AIF4_PB", "AIF4 PB"},
  6277. {"SLIM RX6 MUX", "AIF4_PB", "AIF4 PB"},
  6278. {"SLIM RX7 MUX", "AIF4_PB", "AIF4 PB"},
  6279. /* SLIM_MUX("AIF_MIX1_PB", "AIF MIX1 PB"),*/
  6280. {"SLIM RX0 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6281. {"SLIM RX1 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6282. {"SLIM RX2 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6283. {"SLIM RX3 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6284. {"SLIM RX4 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6285. {"SLIM RX5 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6286. {"SLIM RX6 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6287. {"SLIM RX7 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6288. {"SLIM RX0", NULL, "SLIM RX0 MUX"},
  6289. {"SLIM RX1", NULL, "SLIM RX1 MUX"},
  6290. {"SLIM RX2", NULL, "SLIM RX2 MUX"},
  6291. {"SLIM RX3", NULL, "SLIM RX3 MUX"},
  6292. {"SLIM RX4", NULL, "SLIM RX4 MUX"},
  6293. {"SLIM RX5", NULL, "SLIM RX5 MUX"},
  6294. {"SLIM RX6", NULL, "SLIM RX6 MUX"},
  6295. {"SLIM RX7", NULL, "SLIM RX7 MUX"},
  6296. {"RX INT0_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6297. {"RX INT0_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6298. {"RX INT0_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6299. {"RX INT0_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6300. {"RX INT0_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6301. {"RX INT0_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6302. {"RX INT0_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6303. {"RX INT0_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6304. {"RX INT0_1 MIX1 INP0", "IIR0", "IIR0"},
  6305. {"RX INT0_1 MIX1 INP0", "IIR1", "IIR1"},
  6306. {"RX INT0_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6307. {"RX INT0_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6308. {"RX INT0_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6309. {"RX INT0_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6310. {"RX INT0_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6311. {"RX INT0_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6312. {"RX INT0_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6313. {"RX INT0_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6314. {"RX INT0_1 MIX1 INP1", "IIR0", "IIR0"},
  6315. {"RX INT0_1 MIX1 INP1", "IIR1", "IIR1"},
  6316. {"RX INT0_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6317. {"RX INT0_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6318. {"RX INT0_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6319. {"RX INT0_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6320. {"RX INT0_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6321. {"RX INT0_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6322. {"RX INT0_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6323. {"RX INT0_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6324. {"RX INT0_1 MIX1 INP2", "IIR0", "IIR0"},
  6325. {"RX INT0_1 MIX1 INP2", "IIR1", "IIR1"},
  6326. /* MIXing path INT0 */
  6327. {"RX INT0_2 MUX", "RX0", "SLIM RX0"},
  6328. {"RX INT0_2 MUX", "RX1", "SLIM RX1"},
  6329. {"RX INT0_2 MUX", "RX2", "SLIM RX2"},
  6330. {"RX INT0_2 MUX", "RX3", "SLIM RX3"},
  6331. {"RX INT0_2 MUX", "RX4", "SLIM RX4"},
  6332. {"RX INT0_2 MUX", "RX5", "SLIM RX5"},
  6333. {"RX INT0_2 MUX", "RX6", "SLIM RX6"},
  6334. {"RX INT0_2 MUX", "RX7", "SLIM RX7"},
  6335. {"RX INT0 SEC MIX", NULL, "RX INT0_2 MUX"},
  6336. /* MIXing path INT1 */
  6337. {"RX INT1_2 MUX", "RX0", "SLIM RX0"},
  6338. {"RX INT1_2 MUX", "RX1", "SLIM RX1"},
  6339. {"RX INT1_2 MUX", "RX2", "SLIM RX2"},
  6340. {"RX INT1_2 MUX", "RX3", "SLIM RX3"},
  6341. {"RX INT1_2 MUX", "RX4", "SLIM RX4"},
  6342. {"RX INT1_2 MUX", "RX5", "SLIM RX5"},
  6343. {"RX INT1_2 MUX", "RX6", "SLIM RX6"},
  6344. {"RX INT1_2 MUX", "RX7", "SLIM RX7"},
  6345. {"RX INT1 SEC MIX", NULL, "RX INT1_2 MUX"},
  6346. /* MIXing path INT2 */
  6347. {"RX INT2_2 MUX", "RX0", "SLIM RX0"},
  6348. {"RX INT2_2 MUX", "RX1", "SLIM RX1"},
  6349. {"RX INT2_2 MUX", "RX2", "SLIM RX2"},
  6350. {"RX INT2_2 MUX", "RX3", "SLIM RX3"},
  6351. {"RX INT2_2 MUX", "RX4", "SLIM RX4"},
  6352. {"RX INT2_2 MUX", "RX5", "SLIM RX5"},
  6353. {"RX INT2_2 MUX", "RX6", "SLIM RX6"},
  6354. {"RX INT2_2 MUX", "RX7", "SLIM RX7"},
  6355. {"RX INT2 SEC MIX", NULL, "RX INT2_2 MUX"},
  6356. /* MIXing path INT3 */
  6357. {"RX INT3_2 MUX", "RX0", "SLIM RX0"},
  6358. {"RX INT3_2 MUX", "RX1", "SLIM RX1"},
  6359. {"RX INT3_2 MUX", "RX2", "SLIM RX2"},
  6360. {"RX INT3_2 MUX", "RX3", "SLIM RX3"},
  6361. {"RX INT3_2 MUX", "RX4", "SLIM RX4"},
  6362. {"RX INT3_2 MUX", "RX5", "SLIM RX5"},
  6363. {"RX INT3_2 MUX", "RX6", "SLIM RX6"},
  6364. {"RX INT3_2 MUX", "RX7", "SLIM RX7"},
  6365. {"RX INT3 SEC MIX", NULL, "RX INT3_2 MUX"},
  6366. /* MIXing path INT4 */
  6367. {"RX INT4_2 MUX", "RX0", "SLIM RX0"},
  6368. {"RX INT4_2 MUX", "RX1", "SLIM RX1"},
  6369. {"RX INT4_2 MUX", "RX2", "SLIM RX2"},
  6370. {"RX INT4_2 MUX", "RX3", "SLIM RX3"},
  6371. {"RX INT4_2 MUX", "RX4", "SLIM RX4"},
  6372. {"RX INT4_2 MUX", "RX5", "SLIM RX5"},
  6373. {"RX INT4_2 MUX", "RX6", "SLIM RX6"},
  6374. {"RX INT4_2 MUX", "RX7", "SLIM RX7"},
  6375. {"RX INT4 SEC MIX", NULL, "RX INT4_2 MUX"},
  6376. /* MIXing path INT5 */
  6377. {"RX INT5_2 MUX", "RX0", "SLIM RX0"},
  6378. {"RX INT5_2 MUX", "RX1", "SLIM RX1"},
  6379. {"RX INT5_2 MUX", "RX2", "SLIM RX2"},
  6380. {"RX INT5_2 MUX", "RX3", "SLIM RX3"},
  6381. {"RX INT5_2 MUX", "RX4", "SLIM RX4"},
  6382. {"RX INT5_2 MUX", "RX5", "SLIM RX5"},
  6383. {"RX INT5_2 MUX", "RX6", "SLIM RX6"},
  6384. {"RX INT5_2 MUX", "RX7", "SLIM RX7"},
  6385. {"RX INT5 SEC MIX", NULL, "RX INT5_2 MUX"},
  6386. /* MIXing path INT6 */
  6387. {"RX INT6_2 MUX", "RX0", "SLIM RX0"},
  6388. {"RX INT6_2 MUX", "RX1", "SLIM RX1"},
  6389. {"RX INT6_2 MUX", "RX2", "SLIM RX2"},
  6390. {"RX INT6_2 MUX", "RX3", "SLIM RX3"},
  6391. {"RX INT6_2 MUX", "RX4", "SLIM RX4"},
  6392. {"RX INT6_2 MUX", "RX5", "SLIM RX5"},
  6393. {"RX INT6_2 MUX", "RX6", "SLIM RX6"},
  6394. {"RX INT6_2 MUX", "RX7", "SLIM RX7"},
  6395. {"RX INT6 SEC MIX", NULL, "RX INT6_2 MUX"},
  6396. /* MIXing path INT7 */
  6397. {"RX INT7_2 MUX", "RX0", "SLIM RX0"},
  6398. {"RX INT7_2 MUX", "RX1", "SLIM RX1"},
  6399. {"RX INT7_2 MUX", "RX2", "SLIM RX2"},
  6400. {"RX INT7_2 MUX", "RX3", "SLIM RX3"},
  6401. {"RX INT7_2 MUX", "RX4", "SLIM RX4"},
  6402. {"RX INT7_2 MUX", "RX5", "SLIM RX5"},
  6403. {"RX INT7_2 MUX", "RX6", "SLIM RX6"},
  6404. {"RX INT7_2 MUX", "RX7", "SLIM RX7"},
  6405. {"RX INT7 SEC MIX", NULL, "RX INT7_2 MUX"},
  6406. /* MIXing path INT8 */
  6407. {"RX INT8_2 MUX", "RX0", "SLIM RX0"},
  6408. {"RX INT8_2 MUX", "RX1", "SLIM RX1"},
  6409. {"RX INT8_2 MUX", "RX2", "SLIM RX2"},
  6410. {"RX INT8_2 MUX", "RX3", "SLIM RX3"},
  6411. {"RX INT8_2 MUX", "RX4", "SLIM RX4"},
  6412. {"RX INT8_2 MUX", "RX5", "SLIM RX5"},
  6413. {"RX INT8_2 MUX", "RX6", "SLIM RX6"},
  6414. {"RX INT8_2 MUX", "RX7", "SLIM RX7"},
  6415. {"RX INT8 SEC MIX", NULL, "RX INT8_2 MUX"},
  6416. {"RX INT1_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6417. {"RX INT1_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6418. {"RX INT1_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6419. {"RX INT1_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6420. {"RX INT1_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6421. {"RX INT1_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6422. {"RX INT1_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6423. {"RX INT1_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6424. {"RX INT1_1 MIX1 INP0", "IIR0", "IIR0"},
  6425. {"RX INT1_1 MIX1 INP0", "IIR1", "IIR1"},
  6426. {"RX INT1_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6427. {"RX INT1_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6428. {"RX INT1_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6429. {"RX INT1_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6430. {"RX INT1_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6431. {"RX INT1_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6432. {"RX INT1_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6433. {"RX INT1_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6434. {"RX INT1_1 MIX1 INP1", "IIR0", "IIR0"},
  6435. {"RX INT1_1 MIX1 INP1", "IIR1", "IIR1"},
  6436. {"RX INT1_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6437. {"RX INT1_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6438. {"RX INT1_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6439. {"RX INT1_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6440. {"RX INT1_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6441. {"RX INT1_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6442. {"RX INT1_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6443. {"RX INT1_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6444. {"RX INT1_1 MIX1 INP2", "IIR0", "IIR0"},
  6445. {"RX INT1_1 MIX1 INP2", "IIR1", "IIR1"},
  6446. {"RX INT2_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6447. {"RX INT2_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6448. {"RX INT2_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6449. {"RX INT2_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6450. {"RX INT2_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6451. {"RX INT2_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6452. {"RX INT2_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6453. {"RX INT2_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6454. {"RX INT2_1 MIX1 INP0", "IIR0", "IIR0"},
  6455. {"RX INT2_1 MIX1 INP0", "IIR1", "IIR1"},
  6456. {"RX INT2_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6457. {"RX INT2_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6458. {"RX INT2_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6459. {"RX INT2_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6460. {"RX INT2_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6461. {"RX INT2_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6462. {"RX INT2_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6463. {"RX INT2_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6464. {"RX INT2_1 MIX1 INP1", "IIR0", "IIR0"},
  6465. {"RX INT2_1 MIX1 INP1", "IIR1", "IIR1"},
  6466. {"RX INT2_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6467. {"RX INT2_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6468. {"RX INT2_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6469. {"RX INT2_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6470. {"RX INT2_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6471. {"RX INT2_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6472. {"RX INT2_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6473. {"RX INT2_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6474. {"RX INT2_1 MIX1 INP2", "IIR0", "IIR0"},
  6475. {"RX INT2_1 MIX1 INP2", "IIR1", "IIR1"},
  6476. {"RX INT3_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6477. {"RX INT3_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6478. {"RX INT3_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6479. {"RX INT3_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6480. {"RX INT3_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6481. {"RX INT3_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6482. {"RX INT3_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6483. {"RX INT3_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6484. {"RX INT3_1 MIX1 INP0", "IIR0", "IIR0"},
  6485. {"RX INT3_1 MIX1 INP0", "IIR1", "IIR1"},
  6486. {"RX INT3_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6487. {"RX INT3_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6488. {"RX INT3_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6489. {"RX INT3_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6490. {"RX INT3_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6491. {"RX INT3_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6492. {"RX INT3_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6493. {"RX INT3_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6494. {"RX INT3_1 MIX1 INP1", "IIR0", "IIR0"},
  6495. {"RX INT3_1 MIX1 INP1", "IIR1", "IIR1"},
  6496. {"RX INT3_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6497. {"RX INT3_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6498. {"RX INT3_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6499. {"RX INT3_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6500. {"RX INT3_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6501. {"RX INT3_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6502. {"RX INT3_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6503. {"RX INT3_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6504. {"RX INT3_1 MIX1 INP2", "IIR0", "IIR0"},
  6505. {"RX INT3_1 MIX1 INP2", "IIR1", "IIR1"},
  6506. {"RX INT4_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6507. {"RX INT4_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6508. {"RX INT4_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6509. {"RX INT4_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6510. {"RX INT4_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6511. {"RX INT4_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6512. {"RX INT4_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6513. {"RX INT4_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6514. {"RX INT4_1 MIX1 INP0", "IIR0", "IIR0"},
  6515. {"RX INT4_1 MIX1 INP0", "IIR1", "IIR1"},
  6516. {"RX INT4_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6517. {"RX INT4_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6518. {"RX INT4_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6519. {"RX INT4_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6520. {"RX INT4_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6521. {"RX INT4_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6522. {"RX INT4_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6523. {"RX INT4_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6524. {"RX INT4_1 MIX1 INP1", "IIR0", "IIR0"},
  6525. {"RX INT4_1 MIX1 INP1", "IIR1", "IIR1"},
  6526. {"RX INT4_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6527. {"RX INT4_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6528. {"RX INT4_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6529. {"RX INT4_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6530. {"RX INT4_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6531. {"RX INT4_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6532. {"RX INT4_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6533. {"RX INT4_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6534. {"RX INT4_1 MIX1 INP2", "IIR0", "IIR0"},
  6535. {"RX INT4_1 MIX1 INP2", "IIR1", "IIR1"},
  6536. {"RX INT5_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6537. {"RX INT5_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6538. {"RX INT5_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6539. {"RX INT5_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6540. {"RX INT5_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6541. {"RX INT5_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6542. {"RX INT5_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6543. {"RX INT5_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6544. {"RX INT5_1 MIX1 INP0", "IIR0", "IIR0"},
  6545. {"RX INT5_1 MIX1 INP0", "IIR1", "IIR1"},
  6546. {"RX INT5_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6547. {"RX INT5_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6548. {"RX INT5_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6549. {"RX INT5_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6550. {"RX INT5_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6551. {"RX INT5_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6552. {"RX INT5_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6553. {"RX INT5_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6554. {"RX INT5_1 MIX1 INP1", "IIR0", "IIR0"},
  6555. {"RX INT5_1 MIX1 INP1", "IIR1", "IIR1"},
  6556. {"RX INT5_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6557. {"RX INT5_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6558. {"RX INT5_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6559. {"RX INT5_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6560. {"RX INT5_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6561. {"RX INT5_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6562. {"RX INT5_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6563. {"RX INT5_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6564. {"RX INT5_1 MIX1 INP2", "IIR0", "IIR0"},
  6565. {"RX INT5_1 MIX1 INP2", "IIR1", "IIR1"},
  6566. {"RX INT6_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6567. {"RX INT6_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6568. {"RX INT6_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6569. {"RX INT6_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6570. {"RX INT6_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6571. {"RX INT6_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6572. {"RX INT6_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6573. {"RX INT6_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6574. {"RX INT6_1 MIX1 INP0", "IIR0", "IIR0"},
  6575. {"RX INT6_1 MIX1 INP0", "IIR1", "IIR1"},
  6576. {"RX INT6_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6577. {"RX INT6_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6578. {"RX INT6_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6579. {"RX INT6_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6580. {"RX INT6_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6581. {"RX INT6_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6582. {"RX INT6_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6583. {"RX INT6_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6584. {"RX INT6_1 MIX1 INP1", "IIR0", "IIR0"},
  6585. {"RX INT6_1 MIX1 INP1", "IIR1", "IIR1"},
  6586. {"RX INT6_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6587. {"RX INT6_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6588. {"RX INT6_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6589. {"RX INT6_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6590. {"RX INT6_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6591. {"RX INT6_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6592. {"RX INT6_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6593. {"RX INT6_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6594. {"RX INT6_1 MIX1 INP2", "IIR0", "IIR0"},
  6595. {"RX INT6_1 MIX1 INP2", "IIR1", "IIR1"},
  6596. {"RX INT7_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6597. {"RX INT7_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6598. {"RX INT7_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6599. {"RX INT7_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6600. {"RX INT7_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6601. {"RX INT7_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6602. {"RX INT7_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6603. {"RX INT7_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6604. {"RX INT7_1 MIX1 INP0", "IIR0", "IIR0"},
  6605. {"RX INT7_1 MIX1 INP0", "IIR1", "IIR1"},
  6606. {"RX INT7_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6607. {"RX INT7_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6608. {"RX INT7_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6609. {"RX INT7_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6610. {"RX INT7_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6611. {"RX INT7_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6612. {"RX INT7_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6613. {"RX INT7_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6614. {"RX INT7_1 MIX1 INP1", "IIR0", "IIR0"},
  6615. {"RX INT7_1 MIX1 INP1", "IIR1", "IIR1"},
  6616. {"RX INT7_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6617. {"RX INT7_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6618. {"RX INT7_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6619. {"RX INT7_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6620. {"RX INT7_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6621. {"RX INT7_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6622. {"RX INT7_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6623. {"RX INT7_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6624. {"RX INT7_1 MIX1 INP2", "IIR0", "IIR0"},
  6625. {"RX INT7_1 MIX1 INP2", "IIR1", "IIR1"},
  6626. {"RX INT8_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6627. {"RX INT8_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6628. {"RX INT8_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6629. {"RX INT8_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6630. {"RX INT8_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6631. {"RX INT8_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6632. {"RX INT8_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6633. {"RX INT8_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6634. {"RX INT8_1 MIX1 INP0", "IIR0", "IIR0"},
  6635. {"RX INT8_1 MIX1 INP0", "IIR1", "IIR1"},
  6636. {"RX INT8_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6637. {"RX INT8_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6638. {"RX INT8_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6639. {"RX INT8_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6640. {"RX INT8_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6641. {"RX INT8_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6642. {"RX INT8_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6643. {"RX INT8_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6644. {"RX INT8_1 MIX1 INP1", "IIR0", "IIR0"},
  6645. {"RX INT8_1 MIX1 INP1", "IIR1", "IIR1"},
  6646. {"RX INT8_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6647. {"RX INT8_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6648. {"RX INT8_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6649. {"RX INT8_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6650. {"RX INT8_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6651. {"RX INT8_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6652. {"RX INT8_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6653. {"RX INT8_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6654. {"RX INT8_1 MIX1 INP2", "IIR0", "IIR0"},
  6655. {"RX INT8_1 MIX1 INP2", "IIR1", "IIR1"},
  6656. /* SRC0, SRC1 inputs to Sidetone RX Mixer
  6657. * on RX0, RX1, RX2, RX3, RX4 and RX7 chains
  6658. */
  6659. {"IIR0", NULL, "IIR0 INP0 MUX"},
  6660. {"IIR0 INP0 MUX", "DEC0", "ADC MUX0"},
  6661. {"IIR0 INP0 MUX", "DEC1", "ADC MUX1"},
  6662. {"IIR0 INP0 MUX", "DEC2", "ADC MUX2"},
  6663. {"IIR0 INP0 MUX", "DEC3", "ADC MUX3"},
  6664. {"IIR0 INP0 MUX", "DEC4", "ADC MUX4"},
  6665. {"IIR0 INP0 MUX", "DEC5", "ADC MUX5"},
  6666. {"IIR0 INP0 MUX", "DEC6", "ADC MUX6"},
  6667. {"IIR0 INP0 MUX", "DEC7", "ADC MUX7"},
  6668. {"IIR0 INP0 MUX", "DEC8", "ADC MUX8"},
  6669. {"IIR0 INP0 MUX", "RX0", "SLIM RX0"},
  6670. {"IIR0 INP0 MUX", "RX1", "SLIM RX1"},
  6671. {"IIR0 INP0 MUX", "RX2", "SLIM RX2"},
  6672. {"IIR0 INP0 MUX", "RX3", "SLIM RX3"},
  6673. {"IIR0 INP0 MUX", "RX4", "SLIM RX4"},
  6674. {"IIR0 INP0 MUX", "RX5", "SLIM RX5"},
  6675. {"IIR0 INP0 MUX", "RX6", "SLIM RX6"},
  6676. {"IIR0 INP0 MUX", "RX7", "SLIM RX7"},
  6677. {"IIR0", NULL, "IIR0 INP1 MUX"},
  6678. {"IIR0 INP1 MUX", "DEC0", "ADC MUX0"},
  6679. {"IIR0 INP1 MUX", "DEC1", "ADC MUX1"},
  6680. {"IIR0 INP1 MUX", "DEC2", "ADC MUX2"},
  6681. {"IIR0 INP1 MUX", "DEC3", "ADC MUX3"},
  6682. {"IIR0 INP1 MUX", "DEC4", "ADC MUX4"},
  6683. {"IIR0 INP1 MUX", "DEC5", "ADC MUX5"},
  6684. {"IIR0 INP1 MUX", "DEC6", "ADC MUX6"},
  6685. {"IIR0 INP1 MUX", "DEC7", "ADC MUX7"},
  6686. {"IIR0 INP1 MUX", "DEC8", "ADC MUX8"},
  6687. {"IIR0 INP1 MUX", "RX0", "SLIM RX0"},
  6688. {"IIR0 INP1 MUX", "RX1", "SLIM RX1"},
  6689. {"IIR0 INP1 MUX", "RX2", "SLIM RX2"},
  6690. {"IIR0 INP1 MUX", "RX3", "SLIM RX3"},
  6691. {"IIR0 INP1 MUX", "RX4", "SLIM RX4"},
  6692. {"IIR0 INP1 MUX", "RX5", "SLIM RX5"},
  6693. {"IIR0 INP1 MUX", "RX6", "SLIM RX6"},
  6694. {"IIR0 INP1 MUX", "RX7", "SLIM RX7"},
  6695. {"IIR0", NULL, "IIR0 INP2 MUX"},
  6696. {"IIR0 INP2 MUX", "DEC0", "ADC MUX0"},
  6697. {"IIR0 INP2 MUX", "DEC1", "ADC MUX1"},
  6698. {"IIR0 INP2 MUX", "DEC2", "ADC MUX2"},
  6699. {"IIR0 INP2 MUX", "DEC3", "ADC MUX3"},
  6700. {"IIR0 INP2 MUX", "DEC4", "ADC MUX4"},
  6701. {"IIR0 INP2 MUX", "DEC5", "ADC MUX5"},
  6702. {"IIR0 INP2 MUX", "DEC6", "ADC MUX6"},
  6703. {"IIR0 INP2 MUX", "DEC7", "ADC MUX7"},
  6704. {"IIR0 INP2 MUX", "DEC8", "ADC MUX8"},
  6705. {"IIR0 INP2 MUX", "RX0", "SLIM RX0"},
  6706. {"IIR0 INP2 MUX", "RX1", "SLIM RX1"},
  6707. {"IIR0 INP2 MUX", "RX2", "SLIM RX2"},
  6708. {"IIR0 INP2 MUX", "RX3", "SLIM RX3"},
  6709. {"IIR0 INP2 MUX", "RX4", "SLIM RX4"},
  6710. {"IIR0 INP2 MUX", "RX5", "SLIM RX5"},
  6711. {"IIR0 INP2 MUX", "RX6", "SLIM RX6"},
  6712. {"IIR0 INP2 MUX", "RX7", "SLIM RX7"},
  6713. {"IIR0", NULL, "IIR0 INP3 MUX"},
  6714. {"IIR0 INP3 MUX", "DEC0", "ADC MUX0"},
  6715. {"IIR0 INP3 MUX", "DEC1", "ADC MUX1"},
  6716. {"IIR0 INP3 MUX", "DEC2", "ADC MUX2"},
  6717. {"IIR0 INP3 MUX", "DEC3", "ADC MUX3"},
  6718. {"IIR0 INP3 MUX", "DEC4", "ADC MUX4"},
  6719. {"IIR0 INP3 MUX", "DEC5", "ADC MUX5"},
  6720. {"IIR0 INP3 MUX", "DEC6", "ADC MUX6"},
  6721. {"IIR0 INP3 MUX", "DEC7", "ADC MUX7"},
  6722. {"IIR0 INP3 MUX", "DEC8", "ADC MUX8"},
  6723. {"IIR0 INP3 MUX", "RX0", "SLIM RX0"},
  6724. {"IIR0 INP3 MUX", "RX1", "SLIM RX1"},
  6725. {"IIR0 INP3 MUX", "RX2", "SLIM RX2"},
  6726. {"IIR0 INP3 MUX", "RX3", "SLIM RX3"},
  6727. {"IIR0 INP3 MUX", "RX4", "SLIM RX4"},
  6728. {"IIR0 INP3 MUX", "RX5", "SLIM RX5"},
  6729. {"IIR0 INP3 MUX", "RX6", "SLIM RX6"},
  6730. {"IIR0 INP3 MUX", "RX7", "SLIM RX7"},
  6731. {"IIR1", NULL, "IIR1 INP0 MUX"},
  6732. {"IIR1 INP0 MUX", "DEC0", "ADC MUX0"},
  6733. {"IIR1 INP0 MUX", "DEC1", "ADC MUX1"},
  6734. {"IIR1 INP0 MUX", "DEC2", "ADC MUX2"},
  6735. {"IIR1 INP0 MUX", "DEC3", "ADC MUX3"},
  6736. {"IIR1 INP0 MUX", "DEC4", "ADC MUX4"},
  6737. {"IIR1 INP0 MUX", "DEC5", "ADC MUX5"},
  6738. {"IIR1 INP0 MUX", "DEC6", "ADC MUX6"},
  6739. {"IIR1 INP0 MUX", "DEC7", "ADC MUX7"},
  6740. {"IIR1 INP0 MUX", "DEC8", "ADC MUX8"},
  6741. {"IIR1 INP0 MUX", "RX0", "SLIM RX0"},
  6742. {"IIR1 INP0 MUX", "RX1", "SLIM RX1"},
  6743. {"IIR1 INP0 MUX", "RX2", "SLIM RX2"},
  6744. {"IIR1 INP0 MUX", "RX3", "SLIM RX3"},
  6745. {"IIR1 INP0 MUX", "RX4", "SLIM RX4"},
  6746. {"IIR1 INP0 MUX", "RX5", "SLIM RX5"},
  6747. {"IIR1 INP0 MUX", "RX6", "SLIM RX6"},
  6748. {"IIR1 INP0 MUX", "RX7", "SLIM RX7"},
  6749. {"IIR1", NULL, "IIR1 INP1 MUX"},
  6750. {"IIR1 INP1 MUX", "DEC0", "ADC MUX0"},
  6751. {"IIR1 INP1 MUX", "DEC1", "ADC MUX1"},
  6752. {"IIR1 INP1 MUX", "DEC2", "ADC MUX2"},
  6753. {"IIR1 INP1 MUX", "DEC3", "ADC MUX3"},
  6754. {"IIR1 INP1 MUX", "DEC4", "ADC MUX4"},
  6755. {"IIR1 INP1 MUX", "DEC5", "ADC MUX5"},
  6756. {"IIR1 INP1 MUX", "DEC6", "ADC MUX6"},
  6757. {"IIR1 INP1 MUX", "DEC7", "ADC MUX7"},
  6758. {"IIR1 INP1 MUX", "DEC8", "ADC MUX8"},
  6759. {"IIR1 INP1 MUX", "RX0", "SLIM RX0"},
  6760. {"IIR1 INP1 MUX", "RX1", "SLIM RX1"},
  6761. {"IIR1 INP1 MUX", "RX2", "SLIM RX2"},
  6762. {"IIR1 INP1 MUX", "RX3", "SLIM RX3"},
  6763. {"IIR1 INP1 MUX", "RX4", "SLIM RX4"},
  6764. {"IIR1 INP1 MUX", "RX5", "SLIM RX5"},
  6765. {"IIR1 INP1 MUX", "RX6", "SLIM RX6"},
  6766. {"IIR1 INP1 MUX", "RX7", "SLIM RX7"},
  6767. {"IIR1", NULL, "IIR1 INP2 MUX"},
  6768. {"IIR1 INP2 MUX", "DEC0", "ADC MUX0"},
  6769. {"IIR1 INP2 MUX", "DEC1", "ADC MUX1"},
  6770. {"IIR1 INP2 MUX", "DEC2", "ADC MUX2"},
  6771. {"IIR1 INP2 MUX", "DEC3", "ADC MUX3"},
  6772. {"IIR1 INP2 MUX", "DEC4", "ADC MUX4"},
  6773. {"IIR1 INP2 MUX", "DEC5", "ADC MUX5"},
  6774. {"IIR1 INP2 MUX", "DEC6", "ADC MUX6"},
  6775. {"IIR1 INP2 MUX", "DEC7", "ADC MUX7"},
  6776. {"IIR1 INP2 MUX", "DEC8", "ADC MUX8"},
  6777. {"IIR1 INP2 MUX", "RX0", "SLIM RX0"},
  6778. {"IIR1 INP2 MUX", "RX1", "SLIM RX1"},
  6779. {"IIR1 INP2 MUX", "RX2", "SLIM RX2"},
  6780. {"IIR1 INP2 MUX", "RX3", "SLIM RX3"},
  6781. {"IIR1 INP2 MUX", "RX4", "SLIM RX4"},
  6782. {"IIR1 INP2 MUX", "RX5", "SLIM RX5"},
  6783. {"IIR1 INP2 MUX", "RX6", "SLIM RX6"},
  6784. {"IIR1 INP2 MUX", "RX7", "SLIM RX7"},
  6785. {"IIR1", NULL, "IIR1 INP3 MUX"},
  6786. {"IIR1 INP3 MUX", "DEC0", "ADC MUX0"},
  6787. {"IIR1 INP3 MUX", "DEC1", "ADC MUX1"},
  6788. {"IIR1 INP3 MUX", "DEC2", "ADC MUX2"},
  6789. {"IIR1 INP3 MUX", "DEC3", "ADC MUX3"},
  6790. {"IIR1 INP3 MUX", "DEC4", "ADC MUX4"},
  6791. {"IIR1 INP3 MUX", "DEC5", "ADC MUX5"},
  6792. {"IIR1 INP3 MUX", "DEC6", "ADC MUX6"},
  6793. {"IIR1 INP3 MUX", "DEC7", "ADC MUX7"},
  6794. {"IIR1 INP3 MUX", "DEC8", "ADC MUX8"},
  6795. {"IIR1 INP3 MUX", "RX0", "SLIM RX0"},
  6796. {"IIR1 INP3 MUX", "RX1", "SLIM RX1"},
  6797. {"IIR1 INP3 MUX", "RX2", "SLIM RX2"},
  6798. {"IIR1 INP3 MUX", "RX3", "SLIM RX3"},
  6799. {"IIR1 INP3 MUX", "RX4", "SLIM RX4"},
  6800. {"IIR1 INP3 MUX", "RX5", "SLIM RX5"},
  6801. {"IIR1 INP3 MUX", "RX6", "SLIM RX6"},
  6802. {"IIR1 INP3 MUX", "RX7", "SLIM RX7"},
  6803. {"SRC0", NULL, "IIR0"},
  6804. {"SRC1", NULL, "IIR1"},
  6805. {"RX INT0 MIX2 INP", "SRC0", "SRC0"},
  6806. {"RX INT0 MIX2 INP", "SRC1", "SRC1"},
  6807. {"RX INT1 MIX2 INP", "SRC0", "SRC0"},
  6808. {"RX INT1 MIX2 INP", "SRC1", "SRC1"},
  6809. {"RX INT2 MIX2 INP", "SRC0", "SRC0"},
  6810. {"RX INT2 MIX2 INP", "SRC1", "SRC1"},
  6811. {"RX INT3 MIX2 INP", "SRC0", "SRC0"},
  6812. {"RX INT3 MIX2 INP", "SRC1", "SRC1"},
  6813. {"RX INT4 MIX2 INP", "SRC0", "SRC0"},
  6814. {"RX INT4 MIX2 INP", "SRC1", "SRC1"},
  6815. {"RX INT7 MIX2 INP", "SRC0", "SRC0"},
  6816. {"RX INT7 MIX2 INP", "SRC1", "SRC1"},
  6817. };
  6818. static int tasha_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol,
  6819. struct snd_ctl_elem_value *ucontrol)
  6820. {
  6821. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6822. u16 amic_reg;
  6823. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6824. amic_reg = WCD9335_ANA_AMIC1;
  6825. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6826. amic_reg = WCD9335_ANA_AMIC3;
  6827. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6828. amic_reg = WCD9335_ANA_AMIC5;
  6829. ucontrol->value.integer.value[0] =
  6830. (snd_soc_read(codec, amic_reg) & WCD9335_AMIC_PWR_LVL_MASK) >>
  6831. WCD9335_AMIC_PWR_LVL_SHIFT;
  6832. return 0;
  6833. }
  6834. static int tasha_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol,
  6835. struct snd_ctl_elem_value *ucontrol)
  6836. {
  6837. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6838. u32 mode_val;
  6839. u16 amic_reg;
  6840. mode_val = ucontrol->value.enumerated.item[0];
  6841. dev_dbg(codec->dev, "%s: mode: %d\n",
  6842. __func__, mode_val);
  6843. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6844. amic_reg = WCD9335_ANA_AMIC1;
  6845. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6846. amic_reg = WCD9335_ANA_AMIC3;
  6847. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6848. amic_reg = WCD9335_ANA_AMIC5;
  6849. snd_soc_update_bits(codec, amic_reg, WCD9335_AMIC_PWR_LVL_MASK,
  6850. mode_val << WCD9335_AMIC_PWR_LVL_SHIFT);
  6851. return 0;
  6852. }
  6853. static int tasha_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
  6854. struct snd_ctl_elem_value *ucontrol)
  6855. {
  6856. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6857. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6858. ucontrol->value.integer.value[0] = tasha->hph_mode;
  6859. return 0;
  6860. }
  6861. static int tasha_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
  6862. struct snd_ctl_elem_value *ucontrol)
  6863. {
  6864. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6865. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6866. u32 mode_val;
  6867. mode_val = ucontrol->value.enumerated.item[0];
  6868. dev_dbg(codec->dev, "%s: mode: %d\n",
  6869. __func__, mode_val);
  6870. if (mode_val == 0) {
  6871. dev_warn(codec->dev, "%s:Invalid HPH Mode, default to Cls-H HiFi\n",
  6872. __func__);
  6873. mode_val = CLS_H_HIFI;
  6874. }
  6875. tasha->hph_mode = mode_val;
  6876. return 0;
  6877. }
  6878. static const char *const tasha_conn_mad_text[] = {
  6879. "NOTUSED1", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6",
  6880. "NOTUSED2", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4",
  6881. "DMIC5", "NOTUSED3", "NOTUSED4"
  6882. };
  6883. static const struct soc_enum tasha_conn_mad_enum =
  6884. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_conn_mad_text),
  6885. tasha_conn_mad_text);
  6886. static int tasha_enable_ldo_h_get(struct snd_kcontrol *kcontrol,
  6887. struct snd_ctl_elem_value *ucontrol)
  6888. {
  6889. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6890. u8 val = 0;
  6891. if (codec)
  6892. val = snd_soc_read(codec, WCD9335_LDOH_MODE) & 0x80;
  6893. ucontrol->value.integer.value[0] = !!val;
  6894. return 0;
  6895. }
  6896. static int tasha_enable_ldo_h_put(struct snd_kcontrol *kcontrol,
  6897. struct snd_ctl_elem_value *ucontrol)
  6898. {
  6899. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6900. int value = ucontrol->value.integer.value[0];
  6901. bool enable;
  6902. enable = !!value;
  6903. if (codec)
  6904. tasha_codec_enable_standalone_ldo_h(codec, enable);
  6905. return 0;
  6906. }
  6907. static int tasha_mad_input_get(struct snd_kcontrol *kcontrol,
  6908. struct snd_ctl_elem_value *ucontrol)
  6909. {
  6910. u8 tasha_mad_input;
  6911. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6912. tasha_mad_input = snd_soc_read(codec,
  6913. WCD9335_SOC_MAD_INP_SEL) & 0x0F;
  6914. ucontrol->value.integer.value[0] = tasha_mad_input;
  6915. dev_dbg(codec->dev,
  6916. "%s: tasha_mad_input = %s\n", __func__,
  6917. tasha_conn_mad_text[tasha_mad_input]);
  6918. return 0;
  6919. }
  6920. static int tasha_mad_input_put(struct snd_kcontrol *kcontrol,
  6921. struct snd_ctl_elem_value *ucontrol)
  6922. {
  6923. u8 tasha_mad_input;
  6924. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6925. struct snd_soc_card *card = codec->component.card;
  6926. char mad_amic_input_widget[6];
  6927. const char *mad_input_widget;
  6928. const char *source_widget = NULL;
  6929. u32 adc, i, mic_bias_found = 0;
  6930. int ret = 0;
  6931. char *mad_input;
  6932. tasha_mad_input = ucontrol->value.integer.value[0];
  6933. if (tasha_mad_input >= ARRAY_SIZE(tasha_conn_mad_text)) {
  6934. dev_err(codec->dev,
  6935. "%s: tasha_mad_input = %d out of bounds\n",
  6936. __func__, tasha_mad_input);
  6937. return -EINVAL;
  6938. }
  6939. if (!strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED1") ||
  6940. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED2") ||
  6941. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED3") ||
  6942. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED4")) {
  6943. dev_err(codec->dev,
  6944. "%s: Unsupported tasha_mad_input = %s\n",
  6945. __func__, tasha_conn_mad_text[tasha_mad_input]);
  6946. return -EINVAL;
  6947. }
  6948. if (strnstr(tasha_conn_mad_text[tasha_mad_input],
  6949. "ADC", sizeof("ADC"))) {
  6950. mad_input = strpbrk(tasha_conn_mad_text[tasha_mad_input],
  6951. "123456");
  6952. if (!mad_input) {
  6953. dev_err(codec->dev, "%s: Invalid MAD input %s\n",
  6954. __func__,
  6955. tasha_conn_mad_text[tasha_mad_input]);
  6956. return -EINVAL;
  6957. }
  6958. ret = kstrtouint(mad_input, 10, &adc);
  6959. if ((ret < 0) || (adc > 6)) {
  6960. dev_err(codec->dev,
  6961. "%s: Invalid ADC = %s\n", __func__,
  6962. tasha_conn_mad_text[tasha_mad_input]);
  6963. ret = -EINVAL;
  6964. }
  6965. snprintf(mad_amic_input_widget, 6, "%s%u", "AMIC", adc);
  6966. mad_input_widget = mad_amic_input_widget;
  6967. } else {
  6968. /* DMIC type input widget*/
  6969. mad_input_widget = tasha_conn_mad_text[tasha_mad_input];
  6970. }
  6971. dev_dbg(codec->dev,
  6972. "%s: tasha input widget = %s\n", __func__,
  6973. mad_input_widget);
  6974. for (i = 0; i < card->num_of_dapm_routes; i++) {
  6975. if (!strcmp(card->of_dapm_routes[i].sink, mad_input_widget)) {
  6976. source_widget = card->of_dapm_routes[i].source;
  6977. if (!source_widget) {
  6978. dev_err(codec->dev,
  6979. "%s: invalid source widget\n",
  6980. __func__);
  6981. return -EINVAL;
  6982. }
  6983. if (strnstr(source_widget,
  6984. "MIC BIAS1", sizeof("MIC BIAS1"))) {
  6985. mic_bias_found = 1;
  6986. break;
  6987. } else if (strnstr(source_widget,
  6988. "MIC BIAS2", sizeof("MIC BIAS2"))) {
  6989. mic_bias_found = 2;
  6990. break;
  6991. } else if (strnstr(source_widget,
  6992. "MIC BIAS3", sizeof("MIC BIAS3"))) {
  6993. mic_bias_found = 3;
  6994. break;
  6995. } else if (strnstr(source_widget,
  6996. "MIC BIAS4", sizeof("MIC BIAS4"))) {
  6997. mic_bias_found = 4;
  6998. break;
  6999. }
  7000. }
  7001. }
  7002. if (!mic_bias_found) {
  7003. dev_err(codec->dev,
  7004. "%s: mic bias source not found for input = %s\n",
  7005. __func__, mad_input_widget);
  7006. return -EINVAL;
  7007. }
  7008. dev_dbg(codec->dev,
  7009. "%s: mic_bias found = %d\n", __func__,
  7010. mic_bias_found);
  7011. snd_soc_update_bits(codec, WCD9335_SOC_MAD_INP_SEL,
  7012. 0x0F, tasha_mad_input);
  7013. snd_soc_update_bits(codec, WCD9335_ANA_MAD_SETUP,
  7014. 0x07, mic_bias_found);
  7015. return 0;
  7016. }
  7017. static int tasha_pinctl_mode_get(struct snd_kcontrol *kcontrol,
  7018. struct snd_ctl_elem_value *ucontrol)
  7019. {
  7020. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7021. u16 ctl_reg;
  7022. u8 reg_val, pinctl_position;
  7023. pinctl_position = ((struct soc_multi_mixer_control *)
  7024. kcontrol->private_value)->shift;
  7025. switch (pinctl_position >> 3) {
  7026. case 0:
  7027. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7028. break;
  7029. case 1:
  7030. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7031. break;
  7032. case 2:
  7033. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7034. break;
  7035. case 3:
  7036. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7037. break;
  7038. default:
  7039. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7040. __func__, pinctl_position);
  7041. return -EINVAL;
  7042. }
  7043. reg_val = snd_soc_read(codec, ctl_reg);
  7044. reg_val = (reg_val >> (pinctl_position & 0x07)) & 0x1;
  7045. ucontrol->value.integer.value[0] = reg_val;
  7046. return 0;
  7047. }
  7048. static int tasha_pinctl_mode_put(struct snd_kcontrol *kcontrol,
  7049. struct snd_ctl_elem_value *ucontrol)
  7050. {
  7051. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7052. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7053. u16 ctl_reg, cfg_reg;
  7054. u8 ctl_val, cfg_val, pinctl_position, pinctl_mode, mask;
  7055. /* 1- high or low; 0- high Z */
  7056. pinctl_mode = ucontrol->value.integer.value[0];
  7057. pinctl_position = ((struct soc_multi_mixer_control *)
  7058. kcontrol->private_value)->shift;
  7059. switch (pinctl_position >> 3) {
  7060. case 0:
  7061. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7062. break;
  7063. case 1:
  7064. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7065. break;
  7066. case 2:
  7067. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7068. break;
  7069. case 3:
  7070. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7071. break;
  7072. default:
  7073. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7074. __func__, pinctl_position);
  7075. return -EINVAL;
  7076. }
  7077. ctl_val = pinctl_mode << (pinctl_position & 0x07);
  7078. mask = 1 << (pinctl_position & 0x07);
  7079. snd_soc_update_bits(codec, ctl_reg, mask, ctl_val);
  7080. cfg_reg = WCD9335_TLMM_BIST_MODE_PINCFG + pinctl_position;
  7081. if (!pinctl_mode) {
  7082. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  7083. cfg_val = 0x4;
  7084. else
  7085. cfg_val = 0xC;
  7086. } else {
  7087. cfg_val = 0;
  7088. }
  7089. snd_soc_update_bits(codec, cfg_reg, 0x07, cfg_val);
  7090. dev_dbg(codec->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n",
  7091. __func__, ctl_reg, mask, ctl_val, cfg_reg, cfg_val);
  7092. return 0;
  7093. }
  7094. static void wcd_vbat_adc_out_config_2_0(struct wcd_vbat *vbat,
  7095. struct snd_soc_codec *codec)
  7096. {
  7097. u8 val1, val2;
  7098. /*
  7099. * Measure dcp1 by using "ALT" branch of band gap
  7100. * voltage(Vbg) and use it in FAST mode
  7101. */
  7102. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x82, 0x82);
  7103. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7104. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x01);
  7105. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x80);
  7106. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x00);
  7107. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x20);
  7108. /* Wait 100 usec after calibration select as Vbg */
  7109. usleep_range(100, 110);
  7110. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7111. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7112. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7113. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7114. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7115. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x40, 0x40);
  7116. /* Wait 100 usec after selecting Vbg as 1.05V */
  7117. usleep_range(100, 110);
  7118. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7119. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7120. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7121. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7122. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7123. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7124. __func__, vbat->dcp1, vbat->dcp2);
  7125. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7126. /* Wait 100 usec after selecting Vbg as 0.85V */
  7127. usleep_range(100, 110);
  7128. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x00);
  7129. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x20);
  7130. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x00);
  7131. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x00);
  7132. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x00);
  7133. }
  7134. static void wcd_vbat_adc_out_config_1_x(struct wcd_vbat *vbat,
  7135. struct snd_soc_codec *codec)
  7136. {
  7137. u8 val1, val2;
  7138. /*
  7139. * Measure dcp1 by applying band gap voltage(Vbg)
  7140. * of 0.85V
  7141. */
  7142. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x20);
  7143. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7144. snd_soc_write(codec, WCD9335_BIAS_VBG_FINE_ADJ, 0x05);
  7145. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7146. /* Wait 2 sec after enabling band gap bias */
  7147. usleep_range(2000000, 2000100);
  7148. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x82);
  7149. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x87);
  7150. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7151. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0D);
  7152. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01);
  7153. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7154. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xDE);
  7155. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x3C);
  7156. /* Wait 1 msec after calibration select as Vbg */
  7157. usleep_range(1000, 1100);
  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->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7163. /*
  7164. * Measure dcp2 by applying band gap voltage(Vbg)
  7165. * of 1.05V
  7166. */
  7167. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7168. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7169. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x68);
  7170. /* Wait 2 msec after selecting Vbg as 1.05V */
  7171. usleep_range(2000, 2100);
  7172. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7173. /* Wait 1 sec after enabling band gap bias */
  7174. usleep_range(1000000, 1000100);
  7175. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
  7176. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7177. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7178. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7179. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7180. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7181. __func__, vbat->dcp1, vbat->dcp2);
  7182. /* Reset the Vbat ADC configuration */
  7183. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7184. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7185. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7186. /* Wait 2 msec after selecting Vbg as 0.85V */
  7187. usleep_range(2000, 2100);
  7188. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7189. /* Wait 1 sec after enabling band gap bias */
  7190. usleep_range(1000000, 1000100);
  7191. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x1C);
  7192. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xFE);
  7193. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7194. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7195. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x00);
  7196. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x00);
  7197. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0A);
  7198. }
  7199. static void wcd_vbat_adc_out_config(struct wcd_vbat *vbat,
  7200. struct snd_soc_codec *codec)
  7201. {
  7202. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  7203. if (!vbat->adc_config) {
  7204. tasha_cdc_mclk_enable(codec, true, false);
  7205. if (TASHA_IS_2_0(wcd9xxx))
  7206. wcd_vbat_adc_out_config_2_0(vbat, codec);
  7207. else
  7208. wcd_vbat_adc_out_config_1_x(vbat, codec);
  7209. tasha_cdc_mclk_enable(codec, false, false);
  7210. vbat->adc_config = true;
  7211. }
  7212. }
  7213. static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec)
  7214. {
  7215. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7216. struct firmware_cal *hwdep_cal = NULL;
  7217. struct vbat_monitor_reg *vbat_reg_ptr = NULL;
  7218. const void *data;
  7219. size_t cal_size, vbat_size_remaining;
  7220. int ret = 0, i;
  7221. u32 vbat_writes_size = 0;
  7222. u16 reg;
  7223. u8 mask, val, old_val;
  7224. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_VBAT_CAL);
  7225. if (hwdep_cal) {
  7226. data = hwdep_cal->data;
  7227. cal_size = hwdep_cal->size;
  7228. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7229. __func__);
  7230. } else {
  7231. dev_err(codec->dev, "%s: Vbat cal not received\n",
  7232. __func__);
  7233. ret = -EINVAL;
  7234. goto done;
  7235. }
  7236. if (cal_size < sizeof(*vbat_reg_ptr)) {
  7237. dev_err(codec->dev,
  7238. "%s: Incorrect size %zd for Vbat Cal, expected %zd\n",
  7239. __func__, cal_size, sizeof(*vbat_reg_ptr));
  7240. ret = -EINVAL;
  7241. goto done;
  7242. }
  7243. vbat_reg_ptr = (struct vbat_monitor_reg *) (data);
  7244. if (!vbat_reg_ptr) {
  7245. dev_err(codec->dev,
  7246. "%s: Invalid calibration data for Vbat\n",
  7247. __func__);
  7248. ret = -EINVAL;
  7249. goto done;
  7250. }
  7251. vbat_writes_size = vbat_reg_ptr->size;
  7252. vbat_size_remaining = cal_size - sizeof(u32);
  7253. dev_dbg(codec->dev, "%s: vbat_writes_sz: %d, vbat_sz_remaining: %zd\n",
  7254. __func__, vbat_writes_size, vbat_size_remaining);
  7255. if ((vbat_writes_size * TASHA_PACKED_REG_SIZE)
  7256. > vbat_size_remaining) {
  7257. pr_err("%s: Incorrect Vbat calibration data\n", __func__);
  7258. ret = -EINVAL;
  7259. goto done;
  7260. }
  7261. for (i = 0 ; i < vbat_writes_size; i++) {
  7262. TASHA_CODEC_UNPACK_ENTRY(vbat_reg_ptr->writes[i],
  7263. reg, mask, val);
  7264. old_val = snd_soc_read(codec, reg);
  7265. snd_soc_write(codec, reg, (old_val & ~mask) | (val & mask));
  7266. }
  7267. done:
  7268. return ret;
  7269. }
  7270. static int tasha_vbat_adc_data_get(struct snd_kcontrol *kcontrol,
  7271. struct snd_ctl_elem_value *ucontrol)
  7272. {
  7273. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7274. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7275. wcd_vbat_adc_out_config(&tasha->vbat, codec);
  7276. ucontrol->value.integer.value[0] = tasha->vbat.dcp1;
  7277. ucontrol->value.integer.value[1] = tasha->vbat.dcp2;
  7278. dev_dbg(codec->dev,
  7279. "%s: Vbat ADC output values, Dcp1 : %lu, Dcp2: %lu\n",
  7280. __func__, ucontrol->value.integer.value[0],
  7281. ucontrol->value.integer.value[1]);
  7282. return 0;
  7283. }
  7284. static const char * const tasha_vbat_gsm_mode_text[] = {
  7285. "OFF", "ON"};
  7286. static const struct soc_enum tasha_vbat_gsm_mode_enum =
  7287. SOC_ENUM_SINGLE_EXT(2, tasha_vbat_gsm_mode_text);
  7288. static int tasha_vbat_gsm_mode_func_get(struct snd_kcontrol *kcontrol,
  7289. struct snd_ctl_elem_value *ucontrol)
  7290. {
  7291. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7292. ucontrol->value.integer.value[0] =
  7293. ((snd_soc_read(codec, WCD9335_CDC_VBAT_VBAT_CFG) & 0x04) ?
  7294. 1 : 0);
  7295. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7296. ucontrol->value.integer.value[0]);
  7297. return 0;
  7298. }
  7299. static int tasha_vbat_gsm_mode_func_put(struct snd_kcontrol *kcontrol,
  7300. struct snd_ctl_elem_value *ucontrol)
  7301. {
  7302. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7303. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7304. ucontrol->value.integer.value[0]);
  7305. /* Set Vbat register configuration for GSM mode bit based on value */
  7306. if (ucontrol->value.integer.value[0])
  7307. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7308. 0x04, 0x04);
  7309. else
  7310. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7311. 0x04, 0x00);
  7312. return 0;
  7313. }
  7314. static int tasha_codec_vbat_enable_event(struct snd_soc_dapm_widget *w,
  7315. struct snd_kcontrol *kcontrol,
  7316. int event)
  7317. {
  7318. int ret = 0;
  7319. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7320. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7321. u16 vbat_path_ctl, vbat_cfg, vbat_path_cfg;
  7322. vbat_path_ctl = WCD9335_CDC_VBAT_VBAT_PATH_CTL;
  7323. vbat_cfg = WCD9335_CDC_VBAT_VBAT_CFG;
  7324. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7325. if (!strcmp(w->name, "RX INT8 VBAT"))
  7326. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7327. else if (!strcmp(w->name, "RX INT7 VBAT"))
  7328. vbat_path_cfg = WCD9335_CDC_RX7_RX_PATH_CFG1;
  7329. else if (!strcmp(w->name, "RX INT6 VBAT"))
  7330. vbat_path_cfg = WCD9335_CDC_RX6_RX_PATH_CFG1;
  7331. else if (!strcmp(w->name, "RX INT5 VBAT"))
  7332. vbat_path_cfg = WCD9335_CDC_RX5_RX_PATH_CFG1;
  7333. switch (event) {
  7334. case SND_SOC_DAPM_PRE_PMU:
  7335. ret = tasha_update_vbat_reg_config(codec);
  7336. if (ret) {
  7337. dev_dbg(codec->dev,
  7338. "%s : VBAT isn't calibrated, So not enabling it\n",
  7339. __func__);
  7340. return 0;
  7341. }
  7342. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7343. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x02);
  7344. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x10);
  7345. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x01);
  7346. tasha->vbat.is_enabled = true;
  7347. break;
  7348. case SND_SOC_DAPM_POST_PMD:
  7349. if (tasha->vbat.is_enabled) {
  7350. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x00);
  7351. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x00);
  7352. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x00);
  7353. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7354. tasha->vbat.is_enabled = false;
  7355. }
  7356. break;
  7357. };
  7358. return ret;
  7359. }
  7360. static const char * const rx_hph_mode_mux_text[] = {
  7361. "CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI"
  7362. };
  7363. static const struct soc_enum rx_hph_mode_mux_enum =
  7364. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text),
  7365. rx_hph_mode_mux_text);
  7366. static const char * const amic_pwr_lvl_text[] = {
  7367. "LOW_PWR", "DEFAULT", "HIGH_PERF"
  7368. };
  7369. static const struct soc_enum amic_pwr_lvl_enum =
  7370. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amic_pwr_lvl_text),
  7371. amic_pwr_lvl_text);
  7372. static const struct snd_kcontrol_new tasha_snd_controls[] = {
  7373. SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
  7374. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7375. SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
  7376. 0, -84, 40, digital_gain),
  7377. SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
  7378. 0, -84, 40, digital_gain),
  7379. SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
  7380. 0, -84, 40, digital_gain),
  7381. SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
  7382. 0, -84, 40, digital_gain),
  7383. SOC_SINGLE_SX_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
  7384. 0, -84, 40, digital_gain),
  7385. SOC_SINGLE_SX_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
  7386. 0, -84, 40, digital_gain),
  7387. SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
  7388. 0, -84, 40, digital_gain),
  7389. SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
  7390. 0, -84, 40, digital_gain),
  7391. SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
  7392. WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
  7393. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7394. SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
  7395. WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
  7396. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7397. SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
  7398. WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
  7399. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7400. SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
  7401. WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
  7402. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7403. SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
  7404. WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
  7405. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7406. SOC_SINGLE_SX_TLV("RX5 Mix Digital Volume",
  7407. WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
  7408. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7409. SOC_SINGLE_SX_TLV("RX6 Mix Digital Volume",
  7410. WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
  7411. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7412. SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
  7413. WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
  7414. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7415. SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
  7416. WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
  7417. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7418. SOC_SINGLE_SX_TLV("DEC0 Volume", WCD9335_CDC_TX0_TX_VOL_CTL, 0,
  7419. -84, 40, digital_gain),
  7420. SOC_SINGLE_SX_TLV("DEC1 Volume", WCD9335_CDC_TX1_TX_VOL_CTL, 0,
  7421. -84, 40, digital_gain),
  7422. SOC_SINGLE_SX_TLV("DEC2 Volume", WCD9335_CDC_TX2_TX_VOL_CTL, 0,
  7423. -84, 40, digital_gain),
  7424. SOC_SINGLE_SX_TLV("DEC3 Volume", WCD9335_CDC_TX3_TX_VOL_CTL, 0,
  7425. -84, 40, digital_gain),
  7426. SOC_SINGLE_SX_TLV("DEC4 Volume", WCD9335_CDC_TX4_TX_VOL_CTL, 0,
  7427. -84, 40, digital_gain),
  7428. SOC_SINGLE_SX_TLV("DEC5 Volume", WCD9335_CDC_TX5_TX_VOL_CTL, 0,
  7429. -84, 40, digital_gain),
  7430. SOC_SINGLE_SX_TLV("DEC6 Volume", WCD9335_CDC_TX6_TX_VOL_CTL, 0,
  7431. -84, 40, digital_gain),
  7432. SOC_SINGLE_SX_TLV("DEC7 Volume", WCD9335_CDC_TX7_TX_VOL_CTL, 0,
  7433. -84, 40, digital_gain),
  7434. SOC_SINGLE_SX_TLV("DEC8 Volume", WCD9335_CDC_TX8_TX_VOL_CTL, 0,
  7435. -84, 40, digital_gain),
  7436. SOC_SINGLE_SX_TLV("IIR0 INP0 Volume",
  7437. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, -84,
  7438. 40, digital_gain),
  7439. SOC_SINGLE_SX_TLV("IIR0 INP1 Volume",
  7440. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, -84,
  7441. 40, digital_gain),
  7442. SOC_SINGLE_SX_TLV("IIR0 INP2 Volume",
  7443. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, -84,
  7444. 40, digital_gain),
  7445. SOC_SINGLE_SX_TLV("IIR0 INP3 Volume",
  7446. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, -84,
  7447. 40, digital_gain),
  7448. SOC_SINGLE_SX_TLV("IIR1 INP0 Volume",
  7449. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, -84,
  7450. 40, digital_gain),
  7451. SOC_SINGLE_SX_TLV("IIR1 INP1 Volume",
  7452. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, -84,
  7453. 40, digital_gain),
  7454. SOC_SINGLE_SX_TLV("IIR1 INP2 Volume",
  7455. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, -84,
  7456. 40, digital_gain),
  7457. SOC_SINGLE_SX_TLV("IIR1 INP3 Volume",
  7458. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, -84,
  7459. 40, digital_gain),
  7460. SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 100, 0, tasha_get_anc_slot,
  7461. tasha_put_anc_slot),
  7462. SOC_ENUM_EXT("ANC Function", tasha_anc_func_enum, tasha_get_anc_func,
  7463. tasha_put_anc_func),
  7464. SOC_ENUM_EXT("CLK MODE", tasha_clkmode_enum, tasha_get_clkmode,
  7465. tasha_put_clkmode),
  7466. SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
  7467. SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
  7468. SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
  7469. SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
  7470. SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
  7471. SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
  7472. SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
  7473. SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
  7474. SOC_ENUM("TX8 HPF cut off", cf_dec8_enum),
  7475. SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
  7476. SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
  7477. SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
  7478. SOC_ENUM("RX INT1_2 HPF cut off", cf_int1_2_enum),
  7479. SOC_ENUM("RX INT2_1 HPF cut off", cf_int2_1_enum),
  7480. SOC_ENUM("RX INT2_2 HPF cut off", cf_int2_2_enum),
  7481. SOC_ENUM("RX INT3_1 HPF cut off", cf_int3_1_enum),
  7482. SOC_ENUM("RX INT3_2 HPF cut off", cf_int3_2_enum),
  7483. SOC_ENUM("RX INT4_1 HPF cut off", cf_int4_1_enum),
  7484. SOC_ENUM("RX INT4_2 HPF cut off", cf_int4_2_enum),
  7485. SOC_ENUM("RX INT5_1 HPF cut off", cf_int5_1_enum),
  7486. SOC_ENUM("RX INT5_2 HPF cut off", cf_int5_2_enum),
  7487. SOC_ENUM("RX INT6_1 HPF cut off", cf_int6_1_enum),
  7488. SOC_ENUM("RX INT6_2 HPF cut off", cf_int6_2_enum),
  7489. SOC_ENUM("RX INT7_1 HPF cut off", cf_int7_1_enum),
  7490. SOC_ENUM("RX INT7_2 HPF cut off", cf_int7_2_enum),
  7491. SOC_ENUM("RX INT8_1 HPF cut off", cf_int8_1_enum),
  7492. SOC_ENUM("RX INT8_2 HPF cut off", cf_int8_2_enum),
  7493. SOC_SINGLE_EXT("IIR0 Enable Band1", IIR0, BAND1, 1, 0,
  7494. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7495. SOC_SINGLE_EXT("IIR0 Enable Band2", IIR0, BAND2, 1, 0,
  7496. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7497. SOC_SINGLE_EXT("IIR0 Enable Band3", IIR0, BAND3, 1, 0,
  7498. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7499. SOC_SINGLE_EXT("IIR0 Enable Band4", IIR0, BAND4, 1, 0,
  7500. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7501. SOC_SINGLE_EXT("IIR0 Enable Band5", IIR0, BAND5, 1, 0,
  7502. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7503. SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0,
  7504. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7505. SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
  7506. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7507. SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
  7508. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7509. SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
  7510. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7511. SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
  7512. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7513. SOC_SINGLE_MULTI_EXT("IIR0 Band1", IIR0, BAND1, 255, 0, 5,
  7514. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7515. SOC_SINGLE_MULTI_EXT("IIR0 Band2", IIR0, BAND2, 255, 0, 5,
  7516. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7517. SOC_SINGLE_MULTI_EXT("IIR0 Band3", IIR0, BAND3, 255, 0, 5,
  7518. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7519. SOC_SINGLE_MULTI_EXT("IIR0 Band4", IIR0, BAND4, 255, 0, 5,
  7520. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7521. SOC_SINGLE_MULTI_EXT("IIR0 Band5", IIR0, BAND5, 255, 0, 5,
  7522. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7523. SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
  7524. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7525. SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
  7526. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7527. SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
  7528. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7529. SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
  7530. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7531. SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
  7532. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7533. SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0,
  7534. tasha_get_compander, tasha_set_compander),
  7535. SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0,
  7536. tasha_get_compander, tasha_set_compander),
  7537. SOC_SINGLE_EXT("COMP3 Switch", SND_SOC_NOPM, COMPANDER_3, 1, 0,
  7538. tasha_get_compander, tasha_set_compander),
  7539. SOC_SINGLE_EXT("COMP4 Switch", SND_SOC_NOPM, COMPANDER_4, 1, 0,
  7540. tasha_get_compander, tasha_set_compander),
  7541. SOC_SINGLE_EXT("COMP5 Switch", SND_SOC_NOPM, COMPANDER_5, 1, 0,
  7542. tasha_get_compander, tasha_set_compander),
  7543. SOC_SINGLE_EXT("COMP6 Switch", SND_SOC_NOPM, COMPANDER_6, 1, 0,
  7544. tasha_get_compander, tasha_set_compander),
  7545. SOC_SINGLE_EXT("COMP7 Switch", SND_SOC_NOPM, COMPANDER_7, 1, 0,
  7546. tasha_get_compander, tasha_set_compander),
  7547. SOC_SINGLE_EXT("COMP8 Switch", SND_SOC_NOPM, COMPANDER_8, 1, 0,
  7548. tasha_get_compander, tasha_set_compander),
  7549. SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum,
  7550. tasha_rx_hph_mode_get, tasha_rx_hph_mode_put),
  7551. SOC_ENUM_EXT("MAD Input", tasha_conn_mad_enum,
  7552. tasha_mad_input_get, tasha_mad_input_put),
  7553. SOC_SINGLE_EXT("LDO_H Enable", SND_SOC_NOPM, 0, 1, 0,
  7554. tasha_enable_ldo_h_get, tasha_enable_ldo_h_put),
  7555. SOC_SINGLE_EXT("DMIC1_CLK_PIN_MODE", SND_SOC_NOPM, 17, 1, 0,
  7556. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7557. SOC_SINGLE_EXT("DMIC1_DATA_PIN_MODE", SND_SOC_NOPM, 18, 1, 0,
  7558. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7559. SOC_SINGLE_EXT("DMIC2_CLK_PIN_MODE", SND_SOC_NOPM, 19, 1, 0,
  7560. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7561. SOC_SINGLE_EXT("DMIC2_DATA_PIN_MODE", SND_SOC_NOPM, 20, 1, 0,
  7562. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7563. SOC_SINGLE_EXT("DMIC3_CLK_PIN_MODE", SND_SOC_NOPM, 21, 1, 0,
  7564. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7565. SOC_SINGLE_EXT("DMIC3_DATA_PIN_MODE", SND_SOC_NOPM, 22, 1, 0,
  7566. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7567. SOC_ENUM_EXT("AMIC_1_2 PWR MODE", amic_pwr_lvl_enum,
  7568. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7569. SOC_ENUM_EXT("AMIC_3_4 PWR MODE", amic_pwr_lvl_enum,
  7570. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7571. SOC_ENUM_EXT("AMIC_5_6 PWR MODE", amic_pwr_lvl_enum,
  7572. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7573. SOC_SINGLE_MULTI_EXT("Vbat ADC data", SND_SOC_NOPM, 0, 0xFFFF, 0, 2,
  7574. tasha_vbat_adc_data_get, NULL),
  7575. SOC_ENUM_EXT("GSM mode Enable", tasha_vbat_gsm_mode_enum,
  7576. tasha_vbat_gsm_mode_func_get,
  7577. tasha_vbat_gsm_mode_func_put),
  7578. };
  7579. static int tasha_put_dec_enum(struct snd_kcontrol *kcontrol,
  7580. struct snd_ctl_elem_value *ucontrol)
  7581. {
  7582. struct snd_soc_dapm_widget *widget =
  7583. snd_soc_dapm_kcontrol_widget(kcontrol);
  7584. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7585. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7586. unsigned int val;
  7587. u16 mic_sel_reg;
  7588. u8 mic_sel;
  7589. val = ucontrol->value.enumerated.item[0];
  7590. if (val > e->items - 1)
  7591. return -EINVAL;
  7592. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7593. widget->name, val);
  7594. switch (e->reg) {
  7595. case WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1:
  7596. mic_sel_reg = WCD9335_CDC_TX0_TX_PATH_CFG0;
  7597. break;
  7598. case WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1:
  7599. mic_sel_reg = WCD9335_CDC_TX1_TX_PATH_CFG0;
  7600. break;
  7601. case WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1:
  7602. mic_sel_reg = WCD9335_CDC_TX2_TX_PATH_CFG0;
  7603. break;
  7604. case WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1:
  7605. mic_sel_reg = WCD9335_CDC_TX3_TX_PATH_CFG0;
  7606. break;
  7607. case WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0:
  7608. mic_sel_reg = WCD9335_CDC_TX4_TX_PATH_CFG0;
  7609. break;
  7610. case WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0:
  7611. mic_sel_reg = WCD9335_CDC_TX5_TX_PATH_CFG0;
  7612. break;
  7613. case WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0:
  7614. mic_sel_reg = WCD9335_CDC_TX6_TX_PATH_CFG0;
  7615. break;
  7616. case WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0:
  7617. mic_sel_reg = WCD9335_CDC_TX7_TX_PATH_CFG0;
  7618. break;
  7619. case WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0:
  7620. mic_sel_reg = WCD9335_CDC_TX8_TX_PATH_CFG0;
  7621. break;
  7622. default:
  7623. dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n",
  7624. __func__, e->reg);
  7625. return -EINVAL;
  7626. }
  7627. /* ADC: 0, DMIC: 1 */
  7628. mic_sel = val ? 0x0 : 0x1;
  7629. snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, mic_sel << 7);
  7630. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7631. }
  7632. static int tasha_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol,
  7633. struct snd_ctl_elem_value *ucontrol)
  7634. {
  7635. struct snd_soc_dapm_widget *widget =
  7636. snd_soc_dapm_kcontrol_widget(kcontrol);
  7637. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7638. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7639. unsigned int val;
  7640. unsigned short look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7641. val = ucontrol->value.enumerated.item[0];
  7642. if (val >= e->items)
  7643. return -EINVAL;
  7644. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7645. widget->name, val);
  7646. if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0)
  7647. look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7648. else if (e->reg == WCD9335_CDC_RX1_RX_PATH_SEC0)
  7649. look_ahead_dly_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  7650. else if (e->reg == WCD9335_CDC_RX2_RX_PATH_SEC0)
  7651. look_ahead_dly_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  7652. /* Set Look Ahead Delay */
  7653. snd_soc_update_bits(codec, look_ahead_dly_reg,
  7654. 0x08, (val ? 0x08 : 0x00));
  7655. /* Set DEM INP Select */
  7656. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7657. }
  7658. static int tasha_ear_pa_gain_get(struct snd_kcontrol *kcontrol,
  7659. struct snd_ctl_elem_value *ucontrol)
  7660. {
  7661. u8 ear_pa_gain;
  7662. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7663. ear_pa_gain = snd_soc_read(codec, WCD9335_ANA_EAR);
  7664. ear_pa_gain = (ear_pa_gain & 0x70) >> 4;
  7665. ucontrol->value.integer.value[0] = ear_pa_gain;
  7666. dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__,
  7667. ear_pa_gain);
  7668. return 0;
  7669. }
  7670. static int tasha_ear_pa_gain_put(struct snd_kcontrol *kcontrol,
  7671. struct snd_ctl_elem_value *ucontrol)
  7672. {
  7673. u8 ear_pa_gain;
  7674. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7675. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7676. __func__, ucontrol->value.integer.value[0]);
  7677. ear_pa_gain = ucontrol->value.integer.value[0] << 4;
  7678. snd_soc_update_bits(codec, WCD9335_ANA_EAR, 0x70, ear_pa_gain);
  7679. return 0;
  7680. }
  7681. static int tasha_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
  7682. struct snd_ctl_elem_value *ucontrol)
  7683. {
  7684. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7685. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7686. ucontrol->value.integer.value[0] = tasha->ear_spkr_gain;
  7687. dev_dbg(codec->dev, "%s: ear_spkr_gain = %ld\n", __func__,
  7688. ucontrol->value.integer.value[0]);
  7689. return 0;
  7690. }
  7691. static int tasha_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
  7692. struct snd_ctl_elem_value *ucontrol)
  7693. {
  7694. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7695. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7696. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7697. __func__, ucontrol->value.integer.value[0]);
  7698. tasha->ear_spkr_gain = ucontrol->value.integer.value[0];
  7699. return 0;
  7700. }
  7701. static int tasha_spkr_left_boost_stage_get(struct snd_kcontrol *kcontrol,
  7702. struct snd_ctl_elem_value *ucontrol)
  7703. {
  7704. u8 bst_state_max = 0;
  7705. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7706. bst_state_max = snd_soc_read(codec, WCD9335_CDC_BOOST0_BOOST_CTL);
  7707. bst_state_max = (bst_state_max & 0x0c) >> 2;
  7708. ucontrol->value.integer.value[0] = bst_state_max;
  7709. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7710. __func__, ucontrol->value.integer.value[0]);
  7711. return 0;
  7712. }
  7713. static int tasha_spkr_left_boost_stage_put(struct snd_kcontrol *kcontrol,
  7714. struct snd_ctl_elem_value *ucontrol)
  7715. {
  7716. u8 bst_state_max;
  7717. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7718. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7719. __func__, ucontrol->value.integer.value[0]);
  7720. bst_state_max = ucontrol->value.integer.value[0] << 2;
  7721. snd_soc_update_bits(codec, WCD9335_CDC_BOOST0_BOOST_CTL,
  7722. 0x0c, bst_state_max);
  7723. return 0;
  7724. }
  7725. static int tasha_spkr_right_boost_stage_get(struct snd_kcontrol *kcontrol,
  7726. struct snd_ctl_elem_value *ucontrol)
  7727. {
  7728. u8 bst_state_max = 0;
  7729. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7730. bst_state_max = snd_soc_read(codec, WCD9335_CDC_BOOST1_BOOST_CTL);
  7731. bst_state_max = (bst_state_max & 0x0c) >> 2;
  7732. ucontrol->value.integer.value[0] = bst_state_max;
  7733. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7734. __func__, ucontrol->value.integer.value[0]);
  7735. return 0;
  7736. }
  7737. static int tasha_spkr_right_boost_stage_put(struct snd_kcontrol *kcontrol,
  7738. struct snd_ctl_elem_value *ucontrol)
  7739. {
  7740. u8 bst_state_max;
  7741. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7742. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7743. __func__, ucontrol->value.integer.value[0]);
  7744. bst_state_max = ucontrol->value.integer.value[0] << 2;
  7745. snd_soc_update_bits(codec, WCD9335_CDC_BOOST1_BOOST_CTL,
  7746. 0x0c, bst_state_max);
  7747. return 0;
  7748. }
  7749. static int tasha_config_compander(struct snd_soc_codec *codec, int interp_n,
  7750. int event)
  7751. {
  7752. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7753. int comp;
  7754. u16 comp_ctl0_reg, rx_path_cfg0_reg;
  7755. /* EAR does not have compander */
  7756. if (!interp_n)
  7757. return 0;
  7758. comp = interp_n - 1;
  7759. dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n",
  7760. __func__, event, comp + 1, tasha->comp_enabled[comp]);
  7761. if (!tasha->comp_enabled[comp])
  7762. return 0;
  7763. comp_ctl0_reg = WCD9335_CDC_COMPANDER1_CTL0 + (comp * 8);
  7764. rx_path_cfg0_reg = WCD9335_CDC_RX1_RX_PATH_CFG0 + (comp * 20);
  7765. if (SND_SOC_DAPM_EVENT_ON(event)) {
  7766. /* Enable Compander Clock */
  7767. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01);
  7768. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7769. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7770. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02);
  7771. }
  7772. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  7773. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04);
  7774. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00);
  7775. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7776. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7777. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00);
  7778. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00);
  7779. }
  7780. return 0;
  7781. }
  7782. static int tasha_codec_config_mad(struct snd_soc_codec *codec)
  7783. {
  7784. int ret = 0;
  7785. int idx;
  7786. const struct firmware *fw;
  7787. struct firmware_cal *hwdep_cal = NULL;
  7788. struct wcd_mad_audio_cal *mad_cal = NULL;
  7789. const void *data;
  7790. const char *filename = TASHA_MAD_AUDIO_FIRMWARE_PATH;
  7791. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7792. size_t cal_size;
  7793. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_MAD_CAL);
  7794. if (hwdep_cal) {
  7795. data = hwdep_cal->data;
  7796. cal_size = hwdep_cal->size;
  7797. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7798. __func__);
  7799. } else {
  7800. ret = request_firmware(&fw, filename, codec->dev);
  7801. if (ret || !fw) {
  7802. dev_err(codec->dev,
  7803. "%s: MAD firmware acquire failed, err = %d\n",
  7804. __func__, ret);
  7805. return -ENODEV;
  7806. }
  7807. data = fw->data;
  7808. cal_size = fw->size;
  7809. dev_dbg(codec->dev, "%s: using request_firmware calibration\n",
  7810. __func__);
  7811. }
  7812. if (cal_size < sizeof(*mad_cal)) {
  7813. dev_err(codec->dev,
  7814. "%s: Incorrect size %zd for MAD Cal, expected %zd\n",
  7815. __func__, cal_size, sizeof(*mad_cal));
  7816. ret = -ENOMEM;
  7817. goto done;
  7818. }
  7819. mad_cal = (struct wcd_mad_audio_cal *) (data);
  7820. if (!mad_cal) {
  7821. dev_err(codec->dev,
  7822. "%s: Invalid calibration data\n",
  7823. __func__);
  7824. ret = -EINVAL;
  7825. goto done;
  7826. }
  7827. snd_soc_write(codec, WCD9335_SOC_MAD_MAIN_CTL_2,
  7828. mad_cal->microphone_info.cycle_time);
  7829. snd_soc_update_bits(codec, WCD9335_SOC_MAD_MAIN_CTL_1, 0xFF << 3,
  7830. ((uint16_t)mad_cal->microphone_info.settle_time)
  7831. << 3);
  7832. /* Audio */
  7833. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_8,
  7834. mad_cal->audio_info.rms_omit_samples);
  7835. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_1,
  7836. 0x07 << 4, mad_cal->audio_info.rms_comp_time << 4);
  7837. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03 << 2,
  7838. mad_cal->audio_info.detection_mechanism << 2);
  7839. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_7,
  7840. mad_cal->audio_info.rms_diff_threshold & 0x3F);
  7841. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_5,
  7842. mad_cal->audio_info.rms_threshold_lsb);
  7843. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_6,
  7844. mad_cal->audio_info.rms_threshold_msb);
  7845. for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients);
  7846. idx++) {
  7847. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR,
  7848. 0x3F, idx);
  7849. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL,
  7850. mad_cal->audio_info.iir_coefficients[idx]);
  7851. dev_dbg(codec->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x",
  7852. __func__, idx,
  7853. mad_cal->audio_info.iir_coefficients[idx]);
  7854. }
  7855. /* Beacon */
  7856. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_8,
  7857. mad_cal->beacon_info.rms_omit_samples);
  7858. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_1,
  7859. 0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4);
  7860. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_2, 0x03 << 2,
  7861. mad_cal->beacon_info.detection_mechanism << 2);
  7862. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_7,
  7863. mad_cal->beacon_info.rms_diff_threshold & 0x1F);
  7864. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_5,
  7865. mad_cal->beacon_info.rms_threshold_lsb);
  7866. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_6,
  7867. mad_cal->beacon_info.rms_threshold_msb);
  7868. for (idx = 0; idx < ARRAY_SIZE(mad_cal->beacon_info.iir_coefficients);
  7869. idx++) {
  7870. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR,
  7871. 0x3F, idx);
  7872. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL,
  7873. mad_cal->beacon_info.iir_coefficients[idx]);
  7874. dev_dbg(codec->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x",
  7875. __func__, idx,
  7876. mad_cal->beacon_info.iir_coefficients[idx]);
  7877. }
  7878. /* Ultrasound */
  7879. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_1,
  7880. 0x07 << 4,
  7881. mad_cal->ultrasound_info.rms_comp_time << 4);
  7882. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_2, 0x03 << 2,
  7883. mad_cal->ultrasound_info.detection_mechanism << 2);
  7884. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_7,
  7885. mad_cal->ultrasound_info.rms_diff_threshold & 0x1F);
  7886. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_5,
  7887. mad_cal->ultrasound_info.rms_threshold_lsb);
  7888. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_6,
  7889. mad_cal->ultrasound_info.rms_threshold_msb);
  7890. done:
  7891. if (!hwdep_cal)
  7892. release_firmware(fw);
  7893. return ret;
  7894. }
  7895. static int tasha_codec_enable_mad(struct snd_soc_dapm_widget *w,
  7896. struct snd_kcontrol *kcontrol, int event)
  7897. {
  7898. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7899. int ret = 0;
  7900. dev_dbg(codec->dev,
  7901. "%s: event = %d\n", __func__, event);
  7902. /* Return if CPE INPUT is DEC1 */
  7903. if (snd_soc_read(codec, WCD9335_CPE_SS_SVA_CFG) & 0x01)
  7904. return ret;
  7905. switch (event) {
  7906. case SND_SOC_DAPM_PRE_PMU:
  7907. /* Turn on MAD clk */
  7908. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7909. 0x01, 0x01);
  7910. /* Undo reset for MAD */
  7911. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7912. 0x02, 0x00);
  7913. ret = tasha_codec_config_mad(codec);
  7914. if (ret)
  7915. dev_err(codec->dev,
  7916. "%s: Failed to config MAD, err = %d\n",
  7917. __func__, ret);
  7918. break;
  7919. case SND_SOC_DAPM_POST_PMD:
  7920. /* Reset the MAD block */
  7921. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7922. 0x02, 0x02);
  7923. /* Turn off MAD clk */
  7924. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7925. 0x01, 0x00);
  7926. break;
  7927. }
  7928. return ret;
  7929. }
  7930. static int tasha_codec_configure_cpe_input(struct snd_soc_dapm_widget *w,
  7931. struct snd_kcontrol *kcontrol, int event)
  7932. {
  7933. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7934. dev_dbg(codec->dev,
  7935. "%s: event = %d\n", __func__, event);
  7936. switch (event) {
  7937. case SND_SOC_DAPM_PRE_PMU:
  7938. /* Configure CPE input as DEC1 */
  7939. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7940. 0x01, 0x01);
  7941. /* Configure DEC1 Tx out with sample rate as 16K */
  7942. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7943. 0x0F, 0x01);
  7944. break;
  7945. case SND_SOC_DAPM_POST_PMD:
  7946. /* Reset DEC1 Tx out sample rate */
  7947. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7948. 0x0F, 0x04);
  7949. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7950. 0x01, 0x00);
  7951. break;
  7952. }
  7953. return 0;
  7954. }
  7955. static int tasha_codec_aif4_mixer_switch_get(struct snd_kcontrol *kcontrol,
  7956. struct snd_ctl_elem_value *ucontrol)
  7957. {
  7958. struct snd_soc_dapm_widget *widget =
  7959. snd_soc_dapm_kcontrol_widget(kcontrol);
  7960. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7961. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7962. if (test_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask))
  7963. ucontrol->value.integer.value[0] = 1;
  7964. else
  7965. ucontrol->value.integer.value[0] = 0;
  7966. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7967. __func__, ucontrol->value.integer.value[0]);
  7968. return 0;
  7969. }
  7970. static int tasha_codec_aif4_mixer_switch_put(struct snd_kcontrol *kcontrol,
  7971. struct snd_ctl_elem_value *ucontrol)
  7972. {
  7973. struct snd_soc_dapm_widget *widget =
  7974. snd_soc_dapm_kcontrol_widget(kcontrol);
  7975. struct snd_soc_dapm_update *update = NULL;
  7976. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7977. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7978. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7979. __func__, ucontrol->value.integer.value[0]);
  7980. if (ucontrol->value.integer.value[0]) {
  7981. snd_soc_dapm_mixer_update_power(widget->dapm,
  7982. kcontrol, 1, update);
  7983. set_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7984. } else {
  7985. snd_soc_dapm_mixer_update_power(widget->dapm,
  7986. kcontrol, 0, update);
  7987. clear_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7988. }
  7989. return 1;
  7990. }
  7991. static const char * const tasha_ear_pa_gain_text[] = {
  7992. "G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB",
  7993. "G_0_DB", "G_M2P5_DB", "UNDEFINED", "G_M12_DB"
  7994. };
  7995. static const char * const tasha_ear_spkr_pa_gain_text[] = {
  7996. "G_DEFAULT", "G_0_DB", "G_1_DB", "G_2_DB", "G_3_DB", "G_4_DB",
  7997. "G_5_DB", "G_6_DB"
  7998. };
  7999. static const char * const tasha_speaker_boost_stage_text[] = {
  8000. "NO_MAX_STATE", "MAX_STATE_1", "MAX_STATE_2"
  8001. };
  8002. static const struct soc_enum tasha_ear_pa_gain_enum =
  8003. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_pa_gain_text),
  8004. tasha_ear_pa_gain_text);
  8005. static const struct soc_enum tasha_ear_spkr_pa_gain_enum =
  8006. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_spkr_pa_gain_text),
  8007. tasha_ear_spkr_pa_gain_text);
  8008. static const struct soc_enum tasha_spkr_boost_stage_enum =
  8009. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_speaker_boost_stage_text),
  8010. tasha_speaker_boost_stage_text);
  8011. static const struct snd_kcontrol_new tasha_analog_gain_controls[] = {
  8012. SOC_ENUM_EXT("EAR PA Gain", tasha_ear_pa_gain_enum,
  8013. tasha_ear_pa_gain_get, tasha_ear_pa_gain_put),
  8014. SOC_SINGLE_TLV("HPHL Volume", WCD9335_HPH_L_EN, 0, 20, 1,
  8015. line_gain),
  8016. SOC_SINGLE_TLV("HPHR Volume", WCD9335_HPH_R_EN, 0, 20, 1,
  8017. line_gain),
  8018. SOC_SINGLE_TLV("LINEOUT1 Volume", WCD9335_DIFF_LO_LO1_COMPANDER,
  8019. 3, 16, 1, line_gain),
  8020. SOC_SINGLE_TLV("LINEOUT2 Volume", WCD9335_DIFF_LO_LO2_COMPANDER,
  8021. 3, 16, 1, line_gain),
  8022. SOC_SINGLE_TLV("LINEOUT3 Volume", WCD9335_SE_LO_LO3_GAIN, 0, 20, 1,
  8023. line_gain),
  8024. SOC_SINGLE_TLV("LINEOUT4 Volume", WCD9335_SE_LO_LO4_GAIN, 0, 20, 1,
  8025. line_gain),
  8026. SOC_SINGLE_TLV("ADC1 Volume", WCD9335_ANA_AMIC1, 0, 20, 0,
  8027. analog_gain),
  8028. SOC_SINGLE_TLV("ADC2 Volume", WCD9335_ANA_AMIC2, 0, 20, 0,
  8029. analog_gain),
  8030. SOC_SINGLE_TLV("ADC3 Volume", WCD9335_ANA_AMIC3, 0, 20, 0,
  8031. analog_gain),
  8032. SOC_SINGLE_TLV("ADC4 Volume", WCD9335_ANA_AMIC4, 0, 20, 0,
  8033. analog_gain),
  8034. SOC_SINGLE_TLV("ADC5 Volume", WCD9335_ANA_AMIC5, 0, 20, 0,
  8035. analog_gain),
  8036. SOC_SINGLE_TLV("ADC6 Volume", WCD9335_ANA_AMIC6, 0, 20, 0,
  8037. analog_gain),
  8038. };
  8039. static const struct snd_kcontrol_new tasha_spkr_wsa_controls[] = {
  8040. SOC_ENUM_EXT("EAR SPKR PA Gain", tasha_ear_spkr_pa_gain_enum,
  8041. tasha_ear_spkr_pa_gain_get, tasha_ear_spkr_pa_gain_put),
  8042. SOC_ENUM_EXT("SPKR Left Boost Max State", tasha_spkr_boost_stage_enum,
  8043. tasha_spkr_left_boost_stage_get,
  8044. tasha_spkr_left_boost_stage_put),
  8045. SOC_ENUM_EXT("SPKR Right Boost Max State", tasha_spkr_boost_stage_enum,
  8046. tasha_spkr_right_boost_stage_get,
  8047. tasha_spkr_right_boost_stage_put),
  8048. };
  8049. static const char * const spl_src0_mux_text[] = {
  8050. "ZERO", "SRC_IN_HPHL", "SRC_IN_LO1",
  8051. };
  8052. static const char * const spl_src1_mux_text[] = {
  8053. "ZERO", "SRC_IN_HPHR", "SRC_IN_LO2",
  8054. };
  8055. static const char * const spl_src2_mux_text[] = {
  8056. "ZERO", "SRC_IN_LO3", "SRC_IN_SPKRL",
  8057. };
  8058. static const char * const spl_src3_mux_text[] = {
  8059. "ZERO", "SRC_IN_LO4", "SRC_IN_SPKRR",
  8060. };
  8061. static const char * const rx_int0_7_mix_mux_text[] = {
  8062. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  8063. "RX6", "RX7", "PROXIMITY"
  8064. };
  8065. static const char * const rx_int_mix_mux_text[] = {
  8066. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  8067. "RX6", "RX7"
  8068. };
  8069. static const char * const rx_prim_mix_text[] = {
  8070. "ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2",
  8071. "RX3", "RX4", "RX5", "RX6", "RX7"
  8072. };
  8073. static const char * const rx_sidetone_mix_text[] = {
  8074. "ZERO", "SRC0", "SRC1", "SRC_SUM"
  8075. };
  8076. static const char * const sb_tx0_mux_text[] = {
  8077. "ZERO", "RX_MIX_TX0", "DEC0", "DEC0_192"
  8078. };
  8079. static const char * const sb_tx1_mux_text[] = {
  8080. "ZERO", "RX_MIX_TX1", "DEC1", "DEC1_192"
  8081. };
  8082. static const char * const sb_tx2_mux_text[] = {
  8083. "ZERO", "RX_MIX_TX2", "DEC2", "DEC2_192"
  8084. };
  8085. static const char * const sb_tx3_mux_text[] = {
  8086. "ZERO", "RX_MIX_TX3", "DEC3", "DEC3_192"
  8087. };
  8088. static const char * const sb_tx4_mux_text[] = {
  8089. "ZERO", "RX_MIX_TX4", "DEC4", "DEC4_192"
  8090. };
  8091. static const char * const sb_tx5_mux_text[] = {
  8092. "ZERO", "RX_MIX_TX5", "DEC5", "DEC5_192"
  8093. };
  8094. static const char * const sb_tx6_mux_text[] = {
  8095. "ZERO", "RX_MIX_TX6", "DEC6", "DEC6_192"
  8096. };
  8097. static const char * const sb_tx7_mux_text[] = {
  8098. "ZERO", "RX_MIX_TX7", "DEC7", "DEC7_192"
  8099. };
  8100. static const char * const sb_tx8_mux_text[] = {
  8101. "ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192"
  8102. };
  8103. static const char * const sb_tx9_mux_text[] = {
  8104. "ZERO", "DEC7", "DEC7_192"
  8105. };
  8106. static const char * const sb_tx10_mux_text[] = {
  8107. "ZERO", "DEC6", "DEC6_192"
  8108. };
  8109. static const char * const sb_tx11_mux_text[] = {
  8110. "DEC_0_5", "DEC_9_12", "MAD_AUDIO", "MAD_BRDCST"
  8111. };
  8112. static const char * const sb_tx11_inp1_mux_text[] = {
  8113. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4",
  8114. "DEC5", "RX_MIX_TX5", "DEC9_10", "DEC11_12"
  8115. };
  8116. static const char * const sb_tx13_mux_text[] = {
  8117. "ZERO", "DEC5", "DEC5_192"
  8118. };
  8119. static const char * const tx13_inp_mux_text[] = {
  8120. "CDC_DEC_5", "MAD_BRDCST", "CPE_TX_PP"
  8121. };
  8122. static const char * const iir_inp_mux_text[] = {
  8123. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6",
  8124. "DEC7", "DEC8", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7"
  8125. };
  8126. static const char * const rx_int_dem_inp_mux_text[] = {
  8127. "NORMAL_DSM_OUT", "CLSH_DSM_OUT",
  8128. };
  8129. static const char * const rx_int0_interp_mux_text[] = {
  8130. "ZERO", "RX INT0 MIX2",
  8131. };
  8132. static const char * const rx_int1_interp_mux_text[] = {
  8133. "ZERO", "RX INT1 MIX2",
  8134. };
  8135. static const char * const rx_int2_interp_mux_text[] = {
  8136. "ZERO", "RX INT2 MIX2",
  8137. };
  8138. static const char * const rx_int3_interp_mux_text[] = {
  8139. "ZERO", "RX INT3 MIX2",
  8140. };
  8141. static const char * const rx_int4_interp_mux_text[] = {
  8142. "ZERO", "RX INT4 MIX2",
  8143. };
  8144. static const char * const rx_int5_interp_mux_text[] = {
  8145. "ZERO", "RX INT5 MIX2",
  8146. };
  8147. static const char * const rx_int6_interp_mux_text[] = {
  8148. "ZERO", "RX INT6 MIX2",
  8149. };
  8150. static const char * const rx_int7_interp_mux_text[] = {
  8151. "ZERO", "RX INT7 MIX2",
  8152. };
  8153. static const char * const rx_int8_interp_mux_text[] = {
  8154. "ZERO", "RX INT8 SEC MIX"
  8155. };
  8156. static const char * const mad_sel_text[] = {
  8157. "SPE", "MSM"
  8158. };
  8159. static const char * const adc_mux_text[] = {
  8160. "DMIC", "AMIC", "ANC_FB_TUNE1", "ANC_FB_TUNE2"
  8161. };
  8162. static const char * const dmic_mux_text[] = {
  8163. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8164. "SMIC0", "SMIC1", "SMIC2", "SMIC3"
  8165. };
  8166. static const char * const dmic_mux_alt_text[] = {
  8167. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8168. };
  8169. static const char * const amic_mux_text[] = {
  8170. "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6"
  8171. };
  8172. static const char * const rx_echo_mux_text[] = {
  8173. "ZERO", "RX_MIX0", "RX_MIX1", "RX_MIX2", "RX_MIX3", "RX_MIX4",
  8174. "RX_MIX5", "RX_MIX6", "RX_MIX7", "RX_MIX8", "RX_MIX_VBAT5",
  8175. "RX_MIX_VBAT6", "RX_MIX_VBAT7", "RX_MIX_VBAT8"
  8176. };
  8177. static const char * const anc0_fb_mux_text[] = {
  8178. "ZERO", "ANC_IN_HPHL", "ANC_IN_EAR", "ANC_IN_EAR_SPKR",
  8179. "ANC_IN_LO1"
  8180. };
  8181. static const char * const anc1_fb_mux_text[] = {
  8182. "ZERO", "ANC_IN_HPHR", "ANC_IN_LO2"
  8183. };
  8184. static const char * const native_mux_text[] = {
  8185. "OFF", "ON",
  8186. };
  8187. static const struct soc_enum spl_src0_mux_chain_enum =
  8188. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 0, 3,
  8189. spl_src0_mux_text);
  8190. static const struct soc_enum spl_src1_mux_chain_enum =
  8191. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 2, 3,
  8192. spl_src1_mux_text);
  8193. static const struct soc_enum spl_src2_mux_chain_enum =
  8194. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 4, 3,
  8195. spl_src2_mux_text);
  8196. static const struct soc_enum spl_src3_mux_chain_enum =
  8197. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 6, 3,
  8198. spl_src3_mux_text);
  8199. static const struct soc_enum rx_int0_2_mux_chain_enum =
  8200. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 0, 10,
  8201. rx_int0_7_mix_mux_text);
  8202. static const struct soc_enum rx_int1_2_mux_chain_enum =
  8203. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 0, 9,
  8204. rx_int_mix_mux_text);
  8205. static const struct soc_enum rx_int2_2_mux_chain_enum =
  8206. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 0, 9,
  8207. rx_int_mix_mux_text);
  8208. static const struct soc_enum rx_int3_2_mux_chain_enum =
  8209. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 0, 9,
  8210. rx_int_mix_mux_text);
  8211. static const struct soc_enum rx_int4_2_mux_chain_enum =
  8212. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 0, 9,
  8213. rx_int_mix_mux_text);
  8214. static const struct soc_enum rx_int5_2_mux_chain_enum =
  8215. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 0, 9,
  8216. rx_int_mix_mux_text);
  8217. static const struct soc_enum rx_int6_2_mux_chain_enum =
  8218. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 0, 9,
  8219. rx_int_mix_mux_text);
  8220. static const struct soc_enum rx_int7_2_mux_chain_enum =
  8221. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 0, 10,
  8222. rx_int0_7_mix_mux_text);
  8223. static const struct soc_enum rx_int8_2_mux_chain_enum =
  8224. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 0, 9,
  8225. rx_int_mix_mux_text);
  8226. static const struct soc_enum int1_1_native_enum =
  8227. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8228. native_mux_text);
  8229. static const struct soc_enum int2_1_native_enum =
  8230. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8231. native_mux_text);
  8232. static const struct soc_enum int3_1_native_enum =
  8233. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8234. native_mux_text);
  8235. static const struct soc_enum int4_1_native_enum =
  8236. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8237. native_mux_text);
  8238. static const struct soc_enum rx_int0_1_mix_inp0_chain_enum =
  8239. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 0, 13,
  8240. rx_prim_mix_text);
  8241. static const struct soc_enum rx_int0_1_mix_inp1_chain_enum =
  8242. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 4, 13,
  8243. rx_prim_mix_text);
  8244. static const struct soc_enum rx_int0_1_mix_inp2_chain_enum =
  8245. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 4, 13,
  8246. rx_prim_mix_text);
  8247. static const struct soc_enum rx_int1_1_mix_inp0_chain_enum =
  8248. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 0, 13,
  8249. rx_prim_mix_text);
  8250. static const struct soc_enum rx_int1_1_mix_inp1_chain_enum =
  8251. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 4, 13,
  8252. rx_prim_mix_text);
  8253. static const struct soc_enum rx_int1_1_mix_inp2_chain_enum =
  8254. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 4, 13,
  8255. rx_prim_mix_text);
  8256. static const struct soc_enum rx_int2_1_mix_inp0_chain_enum =
  8257. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 0, 13,
  8258. rx_prim_mix_text);
  8259. static const struct soc_enum rx_int2_1_mix_inp1_chain_enum =
  8260. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 4, 13,
  8261. rx_prim_mix_text);
  8262. static const struct soc_enum rx_int2_1_mix_inp2_chain_enum =
  8263. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 4, 13,
  8264. rx_prim_mix_text);
  8265. static const struct soc_enum rx_int3_1_mix_inp0_chain_enum =
  8266. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 0, 13,
  8267. rx_prim_mix_text);
  8268. static const struct soc_enum rx_int3_1_mix_inp1_chain_enum =
  8269. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 4, 13,
  8270. rx_prim_mix_text);
  8271. static const struct soc_enum rx_int3_1_mix_inp2_chain_enum =
  8272. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 4, 13,
  8273. rx_prim_mix_text);
  8274. static const struct soc_enum rx_int4_1_mix_inp0_chain_enum =
  8275. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 0, 13,
  8276. rx_prim_mix_text);
  8277. static const struct soc_enum rx_int4_1_mix_inp1_chain_enum =
  8278. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 4, 13,
  8279. rx_prim_mix_text);
  8280. static const struct soc_enum rx_int4_1_mix_inp2_chain_enum =
  8281. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 4, 13,
  8282. rx_prim_mix_text);
  8283. static const struct soc_enum rx_int5_1_mix_inp0_chain_enum =
  8284. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 0, 13,
  8285. rx_prim_mix_text);
  8286. static const struct soc_enum rx_int5_1_mix_inp1_chain_enum =
  8287. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 4, 13,
  8288. rx_prim_mix_text);
  8289. static const struct soc_enum rx_int5_1_mix_inp2_chain_enum =
  8290. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 4, 13,
  8291. rx_prim_mix_text);
  8292. static const struct soc_enum rx_int6_1_mix_inp0_chain_enum =
  8293. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 0, 13,
  8294. rx_prim_mix_text);
  8295. static const struct soc_enum rx_int6_1_mix_inp1_chain_enum =
  8296. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 4, 13,
  8297. rx_prim_mix_text);
  8298. static const struct soc_enum rx_int6_1_mix_inp2_chain_enum =
  8299. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 4, 13,
  8300. rx_prim_mix_text);
  8301. static const struct soc_enum rx_int7_1_mix_inp0_chain_enum =
  8302. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 0, 13,
  8303. rx_prim_mix_text);
  8304. static const struct soc_enum rx_int7_1_mix_inp1_chain_enum =
  8305. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 4, 13,
  8306. rx_prim_mix_text);
  8307. static const struct soc_enum rx_int7_1_mix_inp2_chain_enum =
  8308. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 4, 13,
  8309. rx_prim_mix_text);
  8310. static const struct soc_enum rx_int8_1_mix_inp0_chain_enum =
  8311. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 0, 13,
  8312. rx_prim_mix_text);
  8313. static const struct soc_enum rx_int8_1_mix_inp1_chain_enum =
  8314. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 4, 13,
  8315. rx_prim_mix_text);
  8316. static const struct soc_enum rx_int8_1_mix_inp2_chain_enum =
  8317. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 4, 13,
  8318. rx_prim_mix_text);
  8319. static const struct soc_enum rx_int0_sidetone_mix_chain_enum =
  8320. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0, 4,
  8321. rx_sidetone_mix_text);
  8322. static const struct soc_enum rx_int1_sidetone_mix_chain_enum =
  8323. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2, 4,
  8324. rx_sidetone_mix_text);
  8325. static const struct soc_enum rx_int2_sidetone_mix_chain_enum =
  8326. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4, 4,
  8327. rx_sidetone_mix_text);
  8328. static const struct soc_enum rx_int3_sidetone_mix_chain_enum =
  8329. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6, 4,
  8330. rx_sidetone_mix_text);
  8331. static const struct soc_enum rx_int4_sidetone_mix_chain_enum =
  8332. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 0, 4,
  8333. rx_sidetone_mix_text);
  8334. static const struct soc_enum rx_int7_sidetone_mix_chain_enum =
  8335. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 2, 4,
  8336. rx_sidetone_mix_text);
  8337. static const struct soc_enum tx_adc_mux0_chain_enum =
  8338. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 0, 4,
  8339. adc_mux_text);
  8340. static const struct soc_enum tx_adc_mux1_chain_enum =
  8341. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 0, 4,
  8342. adc_mux_text);
  8343. static const struct soc_enum tx_adc_mux2_chain_enum =
  8344. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 0, 4,
  8345. adc_mux_text);
  8346. static const struct soc_enum tx_adc_mux3_chain_enum =
  8347. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 0, 4,
  8348. adc_mux_text);
  8349. static const struct soc_enum tx_adc_mux4_chain_enum =
  8350. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 6, 4,
  8351. adc_mux_text);
  8352. static const struct soc_enum tx_adc_mux5_chain_enum =
  8353. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 6, 4,
  8354. adc_mux_text);
  8355. static const struct soc_enum tx_adc_mux6_chain_enum =
  8356. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 6, 4,
  8357. adc_mux_text);
  8358. static const struct soc_enum tx_adc_mux7_chain_enum =
  8359. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 6, 4,
  8360. adc_mux_text);
  8361. static const struct soc_enum tx_adc_mux8_chain_enum =
  8362. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 6, 4,
  8363. adc_mux_text);
  8364. static const struct soc_enum tx_adc_mux10_chain_enum =
  8365. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 6, 4,
  8366. adc_mux_text);
  8367. static const struct soc_enum tx_adc_mux11_chain_enum =
  8368. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 6, 4,
  8369. adc_mux_text);
  8370. static const struct soc_enum tx_adc_mux12_chain_enum =
  8371. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 6, 4,
  8372. adc_mux_text);
  8373. static const struct soc_enum tx_adc_mux13_chain_enum =
  8374. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 6, 4,
  8375. adc_mux_text);
  8376. static const struct soc_enum tx_dmic_mux0_enum =
  8377. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 3, 11,
  8378. dmic_mux_text);
  8379. static const struct soc_enum tx_dmic_mux1_enum =
  8380. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 3, 11,
  8381. dmic_mux_text);
  8382. static const struct soc_enum tx_dmic_mux2_enum =
  8383. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 3, 11,
  8384. dmic_mux_text);
  8385. static const struct soc_enum tx_dmic_mux3_enum =
  8386. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 3, 11,
  8387. dmic_mux_text);
  8388. static const struct soc_enum tx_dmic_mux4_enum =
  8389. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 3, 7,
  8390. dmic_mux_alt_text);
  8391. static const struct soc_enum tx_dmic_mux5_enum =
  8392. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 3, 7,
  8393. dmic_mux_alt_text);
  8394. static const struct soc_enum tx_dmic_mux6_enum =
  8395. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 3, 7,
  8396. dmic_mux_alt_text);
  8397. static const struct soc_enum tx_dmic_mux7_enum =
  8398. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 3, 7,
  8399. dmic_mux_alt_text);
  8400. static const struct soc_enum tx_dmic_mux8_enum =
  8401. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 3, 7,
  8402. dmic_mux_alt_text);
  8403. static const struct soc_enum tx_dmic_mux10_enum =
  8404. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 3, 7,
  8405. dmic_mux_alt_text);
  8406. static const struct soc_enum tx_dmic_mux11_enum =
  8407. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 3, 7,
  8408. dmic_mux_alt_text);
  8409. static const struct soc_enum tx_dmic_mux12_enum =
  8410. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 3, 7,
  8411. dmic_mux_alt_text);
  8412. static const struct soc_enum tx_dmic_mux13_enum =
  8413. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 3, 7,
  8414. dmic_mux_alt_text);
  8415. static const struct soc_enum tx_amic_mux0_enum =
  8416. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 0, 7,
  8417. amic_mux_text);
  8418. static const struct soc_enum tx_amic_mux1_enum =
  8419. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 0, 7,
  8420. amic_mux_text);
  8421. static const struct soc_enum tx_amic_mux2_enum =
  8422. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 0, 7,
  8423. amic_mux_text);
  8424. static const struct soc_enum tx_amic_mux3_enum =
  8425. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 0, 7,
  8426. amic_mux_text);
  8427. static const struct soc_enum tx_amic_mux4_enum =
  8428. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 0, 7,
  8429. amic_mux_text);
  8430. static const struct soc_enum tx_amic_mux5_enum =
  8431. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 0, 7,
  8432. amic_mux_text);
  8433. static const struct soc_enum tx_amic_mux6_enum =
  8434. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 0, 7,
  8435. amic_mux_text);
  8436. static const struct soc_enum tx_amic_mux7_enum =
  8437. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 0, 7,
  8438. amic_mux_text);
  8439. static const struct soc_enum tx_amic_mux8_enum =
  8440. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 0, 7,
  8441. amic_mux_text);
  8442. static const struct soc_enum tx_amic_mux10_enum =
  8443. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 0, 7,
  8444. amic_mux_text);
  8445. static const struct soc_enum tx_amic_mux11_enum =
  8446. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 0, 7,
  8447. amic_mux_text);
  8448. static const struct soc_enum tx_amic_mux12_enum =
  8449. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 0, 7,
  8450. amic_mux_text);
  8451. static const struct soc_enum tx_amic_mux13_enum =
  8452. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 0, 7,
  8453. amic_mux_text);
  8454. static const struct soc_enum sb_tx0_mux_enum =
  8455. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 0, 4,
  8456. sb_tx0_mux_text);
  8457. static const struct soc_enum sb_tx1_mux_enum =
  8458. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 2, 4,
  8459. sb_tx1_mux_text);
  8460. static const struct soc_enum sb_tx2_mux_enum =
  8461. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 4, 4,
  8462. sb_tx2_mux_text);
  8463. static const struct soc_enum sb_tx3_mux_enum =
  8464. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 6, 4,
  8465. sb_tx3_mux_text);
  8466. static const struct soc_enum sb_tx4_mux_enum =
  8467. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 0, 4,
  8468. sb_tx4_mux_text);
  8469. static const struct soc_enum sb_tx5_mux_enum =
  8470. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 2, 4,
  8471. sb_tx5_mux_text);
  8472. static const struct soc_enum sb_tx6_mux_enum =
  8473. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 4, 4,
  8474. sb_tx6_mux_text);
  8475. static const struct soc_enum sb_tx7_mux_enum =
  8476. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 6, 4,
  8477. sb_tx7_mux_text);
  8478. static const struct soc_enum sb_tx8_mux_enum =
  8479. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 0, 4,
  8480. sb_tx8_mux_text);
  8481. static const struct soc_enum sb_tx9_mux_enum =
  8482. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 2, 3,
  8483. sb_tx9_mux_text);
  8484. static const struct soc_enum sb_tx10_mux_enum =
  8485. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 4, 3,
  8486. sb_tx10_mux_text);
  8487. static const struct soc_enum sb_tx11_mux_enum =
  8488. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX11_INP_CFG, 0, 4,
  8489. sb_tx11_mux_text);
  8490. static const struct soc_enum sb_tx11_inp1_mux_enum =
  8491. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 0, 10,
  8492. sb_tx11_inp1_mux_text);
  8493. static const struct soc_enum sb_tx13_mux_enum =
  8494. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 4, 3,
  8495. sb_tx13_mux_text);
  8496. static const struct soc_enum tx13_inp_mux_enum =
  8497. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG, 0, 3,
  8498. tx13_inp_mux_text);
  8499. static const struct soc_enum rx_mix_tx0_mux_enum =
  8500. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 0, 14,
  8501. rx_echo_mux_text);
  8502. static const struct soc_enum rx_mix_tx1_mux_enum =
  8503. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 4, 14,
  8504. rx_echo_mux_text);
  8505. static const struct soc_enum rx_mix_tx2_mux_enum =
  8506. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 0, 14,
  8507. rx_echo_mux_text);
  8508. static const struct soc_enum rx_mix_tx3_mux_enum =
  8509. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 4, 14,
  8510. rx_echo_mux_text);
  8511. static const struct soc_enum rx_mix_tx4_mux_enum =
  8512. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 0, 14,
  8513. rx_echo_mux_text);
  8514. static const struct soc_enum rx_mix_tx5_mux_enum =
  8515. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 4, 14,
  8516. rx_echo_mux_text);
  8517. static const struct soc_enum rx_mix_tx6_mux_enum =
  8518. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 0, 14,
  8519. rx_echo_mux_text);
  8520. static const struct soc_enum rx_mix_tx7_mux_enum =
  8521. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 4, 14,
  8522. rx_echo_mux_text);
  8523. static const struct soc_enum rx_mix_tx8_mux_enum =
  8524. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG4, 0, 14,
  8525. rx_echo_mux_text);
  8526. static const struct soc_enum iir0_inp0_mux_enum =
  8527. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0, 0, 18,
  8528. iir_inp_mux_text);
  8529. static const struct soc_enum iir0_inp1_mux_enum =
  8530. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1, 0, 18,
  8531. iir_inp_mux_text);
  8532. static const struct soc_enum iir0_inp2_mux_enum =
  8533. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2, 0, 18,
  8534. iir_inp_mux_text);
  8535. static const struct soc_enum iir0_inp3_mux_enum =
  8536. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3, 0, 18,
  8537. iir_inp_mux_text);
  8538. static const struct soc_enum iir1_inp0_mux_enum =
  8539. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0, 0, 18,
  8540. iir_inp_mux_text);
  8541. static const struct soc_enum iir1_inp1_mux_enum =
  8542. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1, 0, 18,
  8543. iir_inp_mux_text);
  8544. static const struct soc_enum iir1_inp2_mux_enum =
  8545. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2, 0, 18,
  8546. iir_inp_mux_text);
  8547. static const struct soc_enum iir1_inp3_mux_enum =
  8548. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3, 0, 18,
  8549. iir_inp_mux_text);
  8550. static const struct soc_enum rx_int0_dem_inp_mux_enum =
  8551. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_SEC0, 0,
  8552. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8553. rx_int_dem_inp_mux_text);
  8554. static const struct soc_enum rx_int1_dem_inp_mux_enum =
  8555. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_SEC0, 0,
  8556. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8557. rx_int_dem_inp_mux_text);
  8558. static const struct soc_enum rx_int2_dem_inp_mux_enum =
  8559. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_SEC0, 0,
  8560. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8561. rx_int_dem_inp_mux_text);
  8562. static const struct soc_enum rx_int0_interp_mux_enum =
  8563. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CTL, 5, 2,
  8564. rx_int0_interp_mux_text);
  8565. static const struct soc_enum rx_int1_interp_mux_enum =
  8566. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CTL, 5, 2,
  8567. rx_int1_interp_mux_text);
  8568. static const struct soc_enum rx_int2_interp_mux_enum =
  8569. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CTL, 5, 2,
  8570. rx_int2_interp_mux_text);
  8571. static const struct soc_enum rx_int3_interp_mux_enum =
  8572. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CTL, 5, 2,
  8573. rx_int3_interp_mux_text);
  8574. static const struct soc_enum rx_int4_interp_mux_enum =
  8575. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CTL, 5, 2,
  8576. rx_int4_interp_mux_text);
  8577. static const struct soc_enum rx_int5_interp_mux_enum =
  8578. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CTL, 5, 2,
  8579. rx_int5_interp_mux_text);
  8580. static const struct soc_enum rx_int6_interp_mux_enum =
  8581. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CTL, 5, 2,
  8582. rx_int6_interp_mux_text);
  8583. static const struct soc_enum rx_int7_interp_mux_enum =
  8584. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CTL, 5, 2,
  8585. rx_int7_interp_mux_text);
  8586. static const struct soc_enum rx_int8_interp_mux_enum =
  8587. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CTL, 5, 2,
  8588. rx_int8_interp_mux_text);
  8589. static const struct soc_enum mad_sel_enum =
  8590. SOC_ENUM_SINGLE(WCD9335_CPE_SS_CFG, 0, 2, mad_sel_text);
  8591. static const struct soc_enum anc0_fb_mux_enum =
  8592. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 0, 5,
  8593. anc0_fb_mux_text);
  8594. static const struct soc_enum anc1_fb_mux_enum =
  8595. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 3, 3,
  8596. anc1_fb_mux_text);
  8597. static const struct snd_kcontrol_new rx_int0_dem_inp_mux =
  8598. SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum,
  8599. snd_soc_dapm_get_enum_double,
  8600. tasha_int_dem_inp_mux_put);
  8601. static const struct snd_kcontrol_new rx_int1_dem_inp_mux =
  8602. SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum,
  8603. snd_soc_dapm_get_enum_double,
  8604. tasha_int_dem_inp_mux_put);
  8605. static const struct snd_kcontrol_new rx_int2_dem_inp_mux =
  8606. SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum,
  8607. snd_soc_dapm_get_enum_double,
  8608. tasha_int_dem_inp_mux_put);
  8609. static const struct snd_kcontrol_new spl_src0_mux =
  8610. SOC_DAPM_ENUM("SPL SRC0 MUX Mux", spl_src0_mux_chain_enum);
  8611. static const struct snd_kcontrol_new spl_src1_mux =
  8612. SOC_DAPM_ENUM("SPL SRC1 MUX Mux", spl_src1_mux_chain_enum);
  8613. static const struct snd_kcontrol_new spl_src2_mux =
  8614. SOC_DAPM_ENUM("SPL SRC2 MUX Mux", spl_src2_mux_chain_enum);
  8615. static const struct snd_kcontrol_new spl_src3_mux =
  8616. SOC_DAPM_ENUM("SPL SRC3 MUX Mux", spl_src3_mux_chain_enum);
  8617. static const struct snd_kcontrol_new rx_int0_2_mux =
  8618. SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum);
  8619. static const struct snd_kcontrol_new rx_int1_2_mux =
  8620. SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum);
  8621. static const struct snd_kcontrol_new rx_int2_2_mux =
  8622. SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum);
  8623. static const struct snd_kcontrol_new rx_int3_2_mux =
  8624. SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum);
  8625. static const struct snd_kcontrol_new rx_int4_2_mux =
  8626. SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum);
  8627. static const struct snd_kcontrol_new rx_int5_2_mux =
  8628. SOC_DAPM_ENUM("RX INT5_2 MUX Mux", rx_int5_2_mux_chain_enum);
  8629. static const struct snd_kcontrol_new rx_int6_2_mux =
  8630. SOC_DAPM_ENUM("RX INT6_2 MUX Mux", rx_int6_2_mux_chain_enum);
  8631. static const struct snd_kcontrol_new rx_int7_2_mux =
  8632. SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum);
  8633. static const struct snd_kcontrol_new rx_int8_2_mux =
  8634. SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum);
  8635. static const struct snd_kcontrol_new int1_1_native_mux =
  8636. SOC_DAPM_ENUM("RX INT1_1 NATIVE MUX Mux", int1_1_native_enum);
  8637. static const struct snd_kcontrol_new int2_1_native_mux =
  8638. SOC_DAPM_ENUM("RX INT2_1 NATIVE MUX Mux", int2_1_native_enum);
  8639. static const struct snd_kcontrol_new int3_1_native_mux =
  8640. SOC_DAPM_ENUM("RX INT3_1 NATIVE MUX Mux", int3_1_native_enum);
  8641. static const struct snd_kcontrol_new int4_1_native_mux =
  8642. SOC_DAPM_ENUM("RX INT4_1 NATIVE MUX Mux", int4_1_native_enum);
  8643. static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux =
  8644. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum);
  8645. static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux =
  8646. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum);
  8647. static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux =
  8648. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum);
  8649. static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux =
  8650. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum);
  8651. static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux =
  8652. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum);
  8653. static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux =
  8654. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum);
  8655. static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux =
  8656. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum);
  8657. static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux =
  8658. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum);
  8659. static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux =
  8660. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum);
  8661. static const struct snd_kcontrol_new rx_int3_1_mix_inp0_mux =
  8662. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum);
  8663. static const struct snd_kcontrol_new rx_int3_1_mix_inp1_mux =
  8664. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum);
  8665. static const struct snd_kcontrol_new rx_int3_1_mix_inp2_mux =
  8666. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum);
  8667. static const struct snd_kcontrol_new rx_int4_1_mix_inp0_mux =
  8668. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum);
  8669. static const struct snd_kcontrol_new rx_int4_1_mix_inp1_mux =
  8670. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum);
  8671. static const struct snd_kcontrol_new rx_int4_1_mix_inp2_mux =
  8672. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum);
  8673. static const struct snd_kcontrol_new rx_int5_1_mix_inp0_mux =
  8674. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP0 Mux", rx_int5_1_mix_inp0_chain_enum);
  8675. static const struct snd_kcontrol_new rx_int5_1_mix_inp1_mux =
  8676. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP1 Mux", rx_int5_1_mix_inp1_chain_enum);
  8677. static const struct snd_kcontrol_new rx_int5_1_mix_inp2_mux =
  8678. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP2 Mux", rx_int5_1_mix_inp2_chain_enum);
  8679. static const struct snd_kcontrol_new rx_int6_1_mix_inp0_mux =
  8680. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP0 Mux", rx_int6_1_mix_inp0_chain_enum);
  8681. static const struct snd_kcontrol_new rx_int6_1_mix_inp1_mux =
  8682. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP1 Mux", rx_int6_1_mix_inp1_chain_enum);
  8683. static const struct snd_kcontrol_new rx_int6_1_mix_inp2_mux =
  8684. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP2 Mux", rx_int6_1_mix_inp2_chain_enum);
  8685. static const struct snd_kcontrol_new rx_int7_1_mix_inp0_mux =
  8686. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum);
  8687. static const struct snd_kcontrol_new rx_int7_1_mix_inp1_mux =
  8688. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum);
  8689. static const struct snd_kcontrol_new rx_int7_1_mix_inp2_mux =
  8690. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum);
  8691. static const struct snd_kcontrol_new rx_int8_1_mix_inp0_mux =
  8692. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum);
  8693. static const struct snd_kcontrol_new rx_int8_1_mix_inp1_mux =
  8694. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum);
  8695. static const struct snd_kcontrol_new rx_int8_1_mix_inp2_mux =
  8696. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum);
  8697. static const struct snd_kcontrol_new rx_int0_mix2_inp_mux =
  8698. SOC_DAPM_ENUM("RX INT0 MIX2 INP Mux", rx_int0_sidetone_mix_chain_enum);
  8699. static const struct snd_kcontrol_new rx_int1_mix2_inp_mux =
  8700. SOC_DAPM_ENUM("RX INT1 MIX2 INP Mux", rx_int1_sidetone_mix_chain_enum);
  8701. static const struct snd_kcontrol_new rx_int2_mix2_inp_mux =
  8702. SOC_DAPM_ENUM("RX INT2 MIX2 INP Mux", rx_int2_sidetone_mix_chain_enum);
  8703. static const struct snd_kcontrol_new rx_int3_mix2_inp_mux =
  8704. SOC_DAPM_ENUM("RX INT3 MIX2 INP Mux", rx_int3_sidetone_mix_chain_enum);
  8705. static const struct snd_kcontrol_new rx_int4_mix2_inp_mux =
  8706. SOC_DAPM_ENUM("RX INT4 MIX2 INP Mux", rx_int4_sidetone_mix_chain_enum);
  8707. static const struct snd_kcontrol_new rx_int7_mix2_inp_mux =
  8708. SOC_DAPM_ENUM("RX INT7 MIX2 INP Mux", rx_int7_sidetone_mix_chain_enum);
  8709. static const struct snd_kcontrol_new tx_adc_mux0 =
  8710. SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_chain_enum,
  8711. snd_soc_dapm_get_enum_double,
  8712. tasha_put_dec_enum);
  8713. static const struct snd_kcontrol_new tx_adc_mux1 =
  8714. SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_chain_enum,
  8715. snd_soc_dapm_get_enum_double,
  8716. tasha_put_dec_enum);
  8717. static const struct snd_kcontrol_new tx_adc_mux2 =
  8718. SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_chain_enum,
  8719. snd_soc_dapm_get_enum_double,
  8720. tasha_put_dec_enum);
  8721. static const struct snd_kcontrol_new tx_adc_mux3 =
  8722. SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_chain_enum,
  8723. snd_soc_dapm_get_enum_double,
  8724. tasha_put_dec_enum);
  8725. static const struct snd_kcontrol_new tx_adc_mux4 =
  8726. SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_chain_enum,
  8727. snd_soc_dapm_get_enum_double,
  8728. tasha_put_dec_enum);
  8729. static const struct snd_kcontrol_new tx_adc_mux5 =
  8730. SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_chain_enum,
  8731. snd_soc_dapm_get_enum_double,
  8732. tasha_put_dec_enum);
  8733. static const struct snd_kcontrol_new tx_adc_mux6 =
  8734. SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_chain_enum,
  8735. snd_soc_dapm_get_enum_double,
  8736. tasha_put_dec_enum);
  8737. static const struct snd_kcontrol_new tx_adc_mux7 =
  8738. SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_chain_enum,
  8739. snd_soc_dapm_get_enum_double,
  8740. tasha_put_dec_enum);
  8741. static const struct snd_kcontrol_new tx_adc_mux8 =
  8742. SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_chain_enum,
  8743. snd_soc_dapm_get_enum_double,
  8744. tasha_put_dec_enum);
  8745. static const struct snd_kcontrol_new tx_adc_mux10 =
  8746. SOC_DAPM_ENUM("ADC MUX10 Mux", tx_adc_mux10_chain_enum);
  8747. static const struct snd_kcontrol_new tx_adc_mux11 =
  8748. SOC_DAPM_ENUM("ADC MUX11 Mux", tx_adc_mux11_chain_enum);
  8749. static const struct snd_kcontrol_new tx_adc_mux12 =
  8750. SOC_DAPM_ENUM("ADC MUX12 Mux", tx_adc_mux12_chain_enum);
  8751. static const struct snd_kcontrol_new tx_adc_mux13 =
  8752. SOC_DAPM_ENUM("ADC MUX13 Mux", tx_adc_mux13_chain_enum);
  8753. static const struct snd_kcontrol_new tx_dmic_mux0 =
  8754. SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum);
  8755. static const struct snd_kcontrol_new tx_dmic_mux1 =
  8756. SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum);
  8757. static const struct snd_kcontrol_new tx_dmic_mux2 =
  8758. SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum);
  8759. static const struct snd_kcontrol_new tx_dmic_mux3 =
  8760. SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum);
  8761. static const struct snd_kcontrol_new tx_dmic_mux4 =
  8762. SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum);
  8763. static const struct snd_kcontrol_new tx_dmic_mux5 =
  8764. SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum);
  8765. static const struct snd_kcontrol_new tx_dmic_mux6 =
  8766. SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum);
  8767. static const struct snd_kcontrol_new tx_dmic_mux7 =
  8768. SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum);
  8769. static const struct snd_kcontrol_new tx_dmic_mux8 =
  8770. SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum);
  8771. static const struct snd_kcontrol_new tx_dmic_mux10 =
  8772. SOC_DAPM_ENUM("DMIC MUX10 Mux", tx_dmic_mux10_enum);
  8773. static const struct snd_kcontrol_new tx_dmic_mux11 =
  8774. SOC_DAPM_ENUM("DMIC MUX11 Mux", tx_dmic_mux11_enum);
  8775. static const struct snd_kcontrol_new tx_dmic_mux12 =
  8776. SOC_DAPM_ENUM("DMIC MUX12 Mux", tx_dmic_mux12_enum);
  8777. static const struct snd_kcontrol_new tx_dmic_mux13 =
  8778. SOC_DAPM_ENUM("DMIC MUX13 Mux", tx_dmic_mux13_enum);
  8779. static const struct snd_kcontrol_new tx_amic_mux0 =
  8780. SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum);
  8781. static const struct snd_kcontrol_new tx_amic_mux1 =
  8782. SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum);
  8783. static const struct snd_kcontrol_new tx_amic_mux2 =
  8784. SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum);
  8785. static const struct snd_kcontrol_new tx_amic_mux3 =
  8786. SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum);
  8787. static const struct snd_kcontrol_new tx_amic_mux4 =
  8788. SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum);
  8789. static const struct snd_kcontrol_new tx_amic_mux5 =
  8790. SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum);
  8791. static const struct snd_kcontrol_new tx_amic_mux6 =
  8792. SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum);
  8793. static const struct snd_kcontrol_new tx_amic_mux7 =
  8794. SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum);
  8795. static const struct snd_kcontrol_new tx_amic_mux8 =
  8796. SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum);
  8797. static const struct snd_kcontrol_new tx_amic_mux10 =
  8798. SOC_DAPM_ENUM("AMIC MUX10 Mux", tx_amic_mux10_enum);
  8799. static const struct snd_kcontrol_new tx_amic_mux11 =
  8800. SOC_DAPM_ENUM("AMIC MUX11 Mux", tx_amic_mux11_enum);
  8801. static const struct snd_kcontrol_new tx_amic_mux12 =
  8802. SOC_DAPM_ENUM("AMIC MUX12 Mux", tx_amic_mux12_enum);
  8803. static const struct snd_kcontrol_new tx_amic_mux13 =
  8804. SOC_DAPM_ENUM("AMIC MUX13 Mux", tx_amic_mux13_enum);
  8805. static const struct snd_kcontrol_new sb_tx0_mux =
  8806. SOC_DAPM_ENUM("SLIM TX0 MUX Mux", sb_tx0_mux_enum);
  8807. static const struct snd_kcontrol_new sb_tx1_mux =
  8808. SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum);
  8809. static const struct snd_kcontrol_new sb_tx2_mux =
  8810. SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum);
  8811. static const struct snd_kcontrol_new sb_tx3_mux =
  8812. SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum);
  8813. static const struct snd_kcontrol_new sb_tx4_mux =
  8814. SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum);
  8815. static const struct snd_kcontrol_new sb_tx5_mux =
  8816. SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum);
  8817. static const struct snd_kcontrol_new sb_tx6_mux =
  8818. SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum);
  8819. static const struct snd_kcontrol_new sb_tx7_mux =
  8820. SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum);
  8821. static const struct snd_kcontrol_new sb_tx8_mux =
  8822. SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum);
  8823. static const struct snd_kcontrol_new sb_tx9_mux =
  8824. SOC_DAPM_ENUM("SLIM TX9 MUX Mux", sb_tx9_mux_enum);
  8825. static const struct snd_kcontrol_new sb_tx10_mux =
  8826. SOC_DAPM_ENUM("SLIM TX10 MUX Mux", sb_tx10_mux_enum);
  8827. static const struct snd_kcontrol_new sb_tx11_mux =
  8828. SOC_DAPM_ENUM("SLIM TX11 MUX Mux", sb_tx11_mux_enum);
  8829. static const struct snd_kcontrol_new sb_tx11_inp1_mux =
  8830. SOC_DAPM_ENUM("SLIM TX11 INP1 MUX Mux", sb_tx11_inp1_mux_enum);
  8831. static const struct snd_kcontrol_new sb_tx13_mux =
  8832. SOC_DAPM_ENUM("SLIM TX13 MUX Mux", sb_tx13_mux_enum);
  8833. static const struct snd_kcontrol_new tx13_inp_mux =
  8834. SOC_DAPM_ENUM("TX13 INP MUX Mux", tx13_inp_mux_enum);
  8835. static const struct snd_kcontrol_new rx_mix_tx0_mux =
  8836. SOC_DAPM_ENUM("RX MIX TX0 MUX Mux", rx_mix_tx0_mux_enum);
  8837. static const struct snd_kcontrol_new rx_mix_tx1_mux =
  8838. SOC_DAPM_ENUM("RX MIX TX1 MUX Mux", rx_mix_tx1_mux_enum);
  8839. static const struct snd_kcontrol_new rx_mix_tx2_mux =
  8840. SOC_DAPM_ENUM("RX MIX TX2 MUX Mux", rx_mix_tx2_mux_enum);
  8841. static const struct snd_kcontrol_new rx_mix_tx3_mux =
  8842. SOC_DAPM_ENUM("RX MIX TX3 MUX Mux", rx_mix_tx3_mux_enum);
  8843. static const struct snd_kcontrol_new rx_mix_tx4_mux =
  8844. SOC_DAPM_ENUM("RX MIX TX4 MUX Mux", rx_mix_tx4_mux_enum);
  8845. static const struct snd_kcontrol_new rx_mix_tx5_mux =
  8846. SOC_DAPM_ENUM("RX MIX TX5 MUX Mux", rx_mix_tx5_mux_enum);
  8847. static const struct snd_kcontrol_new rx_mix_tx6_mux =
  8848. SOC_DAPM_ENUM("RX MIX TX6 MUX Mux", rx_mix_tx6_mux_enum);
  8849. static const struct snd_kcontrol_new rx_mix_tx7_mux =
  8850. SOC_DAPM_ENUM("RX MIX TX7 MUX Mux", rx_mix_tx7_mux_enum);
  8851. static const struct snd_kcontrol_new rx_mix_tx8_mux =
  8852. SOC_DAPM_ENUM("RX MIX TX8 MUX Mux", rx_mix_tx8_mux_enum);
  8853. static const struct snd_kcontrol_new iir0_inp0_mux =
  8854. SOC_DAPM_ENUM("IIR0 INP0 Mux", iir0_inp0_mux_enum);
  8855. static const struct snd_kcontrol_new iir0_inp1_mux =
  8856. SOC_DAPM_ENUM("IIR0 INP1 Mux", iir0_inp1_mux_enum);
  8857. static const struct snd_kcontrol_new iir0_inp2_mux =
  8858. SOC_DAPM_ENUM("IIR0 INP2 Mux", iir0_inp2_mux_enum);
  8859. static const struct snd_kcontrol_new iir0_inp3_mux =
  8860. SOC_DAPM_ENUM("IIR0 INP3 Mux", iir0_inp3_mux_enum);
  8861. static const struct snd_kcontrol_new iir1_inp0_mux =
  8862. SOC_DAPM_ENUM("IIR1 INP0 Mux", iir1_inp0_mux_enum);
  8863. static const struct snd_kcontrol_new iir1_inp1_mux =
  8864. SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum);
  8865. static const struct snd_kcontrol_new iir1_inp2_mux =
  8866. SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum);
  8867. static const struct snd_kcontrol_new iir1_inp3_mux =
  8868. SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum);
  8869. static const struct snd_kcontrol_new rx_int0_interp_mux =
  8870. SOC_DAPM_ENUM("RX INT0 INTERP Mux", rx_int0_interp_mux_enum);
  8871. static const struct snd_kcontrol_new rx_int1_interp_mux =
  8872. SOC_DAPM_ENUM("RX INT1 INTERP Mux", rx_int1_interp_mux_enum);
  8873. static const struct snd_kcontrol_new rx_int2_interp_mux =
  8874. SOC_DAPM_ENUM("RX INT2 INTERP Mux", rx_int2_interp_mux_enum);
  8875. static const struct snd_kcontrol_new rx_int3_interp_mux =
  8876. SOC_DAPM_ENUM("RX INT3 INTERP Mux", rx_int3_interp_mux_enum);
  8877. static const struct snd_kcontrol_new rx_int4_interp_mux =
  8878. SOC_DAPM_ENUM("RX INT4 INTERP Mux", rx_int4_interp_mux_enum);
  8879. static const struct snd_kcontrol_new rx_int5_interp_mux =
  8880. SOC_DAPM_ENUM("RX INT5 INTERP Mux", rx_int5_interp_mux_enum);
  8881. static const struct snd_kcontrol_new rx_int6_interp_mux =
  8882. SOC_DAPM_ENUM("RX INT6 INTERP Mux", rx_int6_interp_mux_enum);
  8883. static const struct snd_kcontrol_new rx_int7_interp_mux =
  8884. SOC_DAPM_ENUM("RX INT7 INTERP Mux", rx_int7_interp_mux_enum);
  8885. static const struct snd_kcontrol_new rx_int8_interp_mux =
  8886. SOC_DAPM_ENUM("RX INT8 INTERP Mux", rx_int8_interp_mux_enum);
  8887. static const struct snd_kcontrol_new mad_sel_mux =
  8888. SOC_DAPM_ENUM("MAD_SEL MUX Mux", mad_sel_enum);
  8889. static const struct snd_kcontrol_new aif4_mad_switch =
  8890. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 5, 1, 0);
  8891. static const struct snd_kcontrol_new mad_brdcst_switch =
  8892. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 6, 1, 0);
  8893. static const struct snd_kcontrol_new aif4_switch_mixer_controls =
  8894. SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
  8895. 0, 1, 0, tasha_codec_aif4_mixer_switch_get,
  8896. tasha_codec_aif4_mixer_switch_put);
  8897. static const struct snd_kcontrol_new anc_hphl_switch =
  8898. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8899. static const struct snd_kcontrol_new anc_hphr_switch =
  8900. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8901. static const struct snd_kcontrol_new anc_ear_switch =
  8902. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8903. static const struct snd_kcontrol_new anc_ear_spkr_switch =
  8904. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8905. static const struct snd_kcontrol_new anc_lineout1_switch =
  8906. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8907. static const struct snd_kcontrol_new anc_lineout2_switch =
  8908. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8909. static const struct snd_kcontrol_new anc_spkr_pa_switch =
  8910. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8911. static const struct snd_kcontrol_new adc_us_mux0_switch =
  8912. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8913. static const struct snd_kcontrol_new adc_us_mux1_switch =
  8914. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8915. static const struct snd_kcontrol_new adc_us_mux2_switch =
  8916. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8917. static const struct snd_kcontrol_new adc_us_mux3_switch =
  8918. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8919. static const struct snd_kcontrol_new adc_us_mux4_switch =
  8920. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8921. static const struct snd_kcontrol_new adc_us_mux5_switch =
  8922. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8923. static const struct snd_kcontrol_new adc_us_mux6_switch =
  8924. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8925. static const struct snd_kcontrol_new adc_us_mux7_switch =
  8926. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8927. static const struct snd_kcontrol_new adc_us_mux8_switch =
  8928. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8929. static const struct snd_kcontrol_new anc0_fb_mux =
  8930. SOC_DAPM_ENUM("ANC0 FB MUX Mux", anc0_fb_mux_enum);
  8931. static const struct snd_kcontrol_new anc1_fb_mux =
  8932. SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum);
  8933. static int tasha_codec_ec_buf_mux_enable(struct snd_soc_dapm_widget *w,
  8934. struct snd_kcontrol *kcontrol,
  8935. int event)
  8936. {
  8937. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  8938. dev_dbg(codec->dev, "%s: event = %d name = %s\n",
  8939. __func__, event, w->name);
  8940. switch (event) {
  8941. case SND_SOC_DAPM_POST_PMU:
  8942. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x3B);
  8943. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x08);
  8944. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8945. 0x08, 0x08);
  8946. break;
  8947. case SND_SOC_DAPM_POST_PMD:
  8948. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8949. 0x08, 0x00);
  8950. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x00);
  8951. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x00);
  8952. break;
  8953. }
  8954. return 0;
  8955. };
  8956. static const char * const ec_buf_mux_text[] = {
  8957. "ZERO", "RXMIXEC", "SB_RX0", "SB_RX1", "SB_RX2", "SB_RX3",
  8958. "I2S_RX_SD0_L", "I2S_RX_SD0_R", "I2S_RX_SD1_L", "I2S_RX_SD1_R",
  8959. "DEC1"
  8960. };
  8961. static SOC_ENUM_SINGLE_DECL(ec_buf_mux_enum, WCD9335_CPE_SS_US_EC_MUX_CFG,
  8962. 0, ec_buf_mux_text);
  8963. static const struct snd_kcontrol_new ec_buf_mux =
  8964. SOC_DAPM_ENUM("EC BUF Mux", ec_buf_mux_enum);
  8965. static const struct snd_soc_dapm_widget tasha_dapm_widgets[] = {
  8966. SND_SOC_DAPM_OUTPUT("EAR"),
  8967. SND_SOC_DAPM_OUTPUT("ANC EAR"),
  8968. SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM,
  8969. AIF1_PB, 0, tasha_codec_enable_slimrx,
  8970. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8971. SND_SOC_DAPM_POST_PMD),
  8972. SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM,
  8973. AIF2_PB, 0, tasha_codec_enable_slimrx,
  8974. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8975. SND_SOC_DAPM_POST_PMD),
  8976. SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM,
  8977. AIF3_PB, 0, tasha_codec_enable_slimrx,
  8978. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8979. SND_SOC_DAPM_POST_PMD),
  8980. SND_SOC_DAPM_AIF_IN_E("AIF4 PB", "AIF4 Playback", 0, SND_SOC_NOPM,
  8981. AIF4_PB, 0, tasha_codec_enable_slimrx,
  8982. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8983. SND_SOC_DAPM_POST_PMD),
  8984. SND_SOC_DAPM_AIF_IN_E("AIF MIX1 PB", "AIF Mix Playback", 0,
  8985. SND_SOC_NOPM, AIF_MIX1_PB, 0,
  8986. tasha_codec_enable_slimrx,
  8987. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8988. SND_SOC_DAPM_POST_PMD),
  8989. SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM, TASHA_RX0, 0,
  8990. &slim_rx_mux[TASHA_RX0]),
  8991. SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TASHA_RX1, 0,
  8992. &slim_rx_mux[TASHA_RX1]),
  8993. SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TASHA_RX2, 0,
  8994. &slim_rx_mux[TASHA_RX2]),
  8995. SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TASHA_RX3, 0,
  8996. &slim_rx_mux[TASHA_RX3]),
  8997. SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TASHA_RX4, 0,
  8998. &slim_rx_mux[TASHA_RX4]),
  8999. SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TASHA_RX5, 0,
  9000. &slim_rx_mux[TASHA_RX5]),
  9001. SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, TASHA_RX6, 0,
  9002. &slim_rx_mux[TASHA_RX6]),
  9003. SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, TASHA_RX7, 0,
  9004. &slim_rx_mux[TASHA_RX7]),
  9005. SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
  9006. SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9007. SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9008. SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
  9009. SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
  9010. SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0),
  9011. SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0),
  9012. SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0),
  9013. SND_SOC_DAPM_MUX_E("SPL SRC0 MUX", SND_SOC_NOPM, SPLINE_SRC0, 0,
  9014. &spl_src0_mux, tasha_codec_enable_spline_resampler,
  9015. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9016. SND_SOC_DAPM_MUX_E("SPL SRC1 MUX", SND_SOC_NOPM, SPLINE_SRC1, 0,
  9017. &spl_src1_mux, tasha_codec_enable_spline_resampler,
  9018. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9019. SND_SOC_DAPM_MUX_E("SPL SRC2 MUX", SND_SOC_NOPM, SPLINE_SRC2, 0,
  9020. &spl_src2_mux, tasha_codec_enable_spline_resampler,
  9021. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9022. SND_SOC_DAPM_MUX_E("SPL SRC3 MUX", SND_SOC_NOPM, SPLINE_SRC3, 0,
  9023. &spl_src3_mux, tasha_codec_enable_spline_resampler,
  9024. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9025. SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  9026. 5, 0, &rx_int0_2_mux, tasha_codec_enable_mix_path,
  9027. SND_SOC_DAPM_POST_PMU),
  9028. SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  9029. 5, 0, &rx_int1_2_mux, tasha_codec_enable_mix_path,
  9030. SND_SOC_DAPM_POST_PMU),
  9031. SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  9032. 5, 0, &rx_int2_2_mux, tasha_codec_enable_mix_path,
  9033. SND_SOC_DAPM_POST_PMU),
  9034. SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", WCD9335_CDC_RX3_RX_PATH_MIX_CTL,
  9035. 5, 0, &rx_int3_2_mux, tasha_codec_enable_mix_path,
  9036. SND_SOC_DAPM_POST_PMU),
  9037. SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", WCD9335_CDC_RX4_RX_PATH_MIX_CTL,
  9038. 5, 0, &rx_int4_2_mux, tasha_codec_enable_mix_path,
  9039. SND_SOC_DAPM_POST_PMU),
  9040. SND_SOC_DAPM_MUX_E("RX INT5_2 MUX", WCD9335_CDC_RX5_RX_PATH_MIX_CTL,
  9041. 5, 0, &rx_int5_2_mux, tasha_codec_enable_mix_path,
  9042. SND_SOC_DAPM_POST_PMU),
  9043. SND_SOC_DAPM_MUX_E("RX INT6_2 MUX", WCD9335_CDC_RX6_RX_PATH_MIX_CTL,
  9044. 5, 0, &rx_int6_2_mux, tasha_codec_enable_mix_path,
  9045. SND_SOC_DAPM_POST_PMU),
  9046. SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", WCD9335_CDC_RX7_RX_PATH_MIX_CTL,
  9047. 5, 0, &rx_int7_2_mux, tasha_codec_enable_mix_path,
  9048. SND_SOC_DAPM_POST_PMU),
  9049. SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", WCD9335_CDC_RX8_RX_PATH_MIX_CTL,
  9050. 5, 0, &rx_int8_2_mux, tasha_codec_enable_mix_path,
  9051. SND_SOC_DAPM_POST_PMU),
  9052. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9053. &rx_int0_1_mix_inp0_mux),
  9054. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9055. &rx_int0_1_mix_inp1_mux),
  9056. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9057. &rx_int0_1_mix_inp2_mux),
  9058. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9059. &rx_int1_1_mix_inp0_mux),
  9060. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9061. &rx_int1_1_mix_inp1_mux),
  9062. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9063. &rx_int1_1_mix_inp2_mux),
  9064. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9065. &rx_int2_1_mix_inp0_mux),
  9066. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9067. &rx_int2_1_mix_inp1_mux),
  9068. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9069. &rx_int2_1_mix_inp2_mux),
  9070. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9071. &rx_int3_1_mix_inp0_mux),
  9072. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9073. &rx_int3_1_mix_inp1_mux),
  9074. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9075. &rx_int3_1_mix_inp2_mux),
  9076. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9077. &rx_int4_1_mix_inp0_mux),
  9078. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9079. &rx_int4_1_mix_inp1_mux),
  9080. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9081. &rx_int4_1_mix_inp2_mux),
  9082. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9083. &rx_int5_1_mix_inp0_mux),
  9084. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9085. &rx_int5_1_mix_inp1_mux),
  9086. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9087. &rx_int5_1_mix_inp2_mux),
  9088. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9089. &rx_int6_1_mix_inp0_mux),
  9090. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9091. &rx_int6_1_mix_inp1_mux),
  9092. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9093. &rx_int6_1_mix_inp2_mux),
  9094. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9095. &rx_int7_1_mix_inp0_mux, tasha_codec_enable_swr,
  9096. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9097. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9098. &rx_int7_1_mix_inp1_mux, tasha_codec_enable_swr,
  9099. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9100. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9101. &rx_int7_1_mix_inp2_mux, tasha_codec_enable_swr,
  9102. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9103. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9104. &rx_int8_1_mix_inp0_mux, tasha_codec_enable_swr,
  9105. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9106. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9107. &rx_int8_1_mix_inp1_mux, tasha_codec_enable_swr,
  9108. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9109. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9110. &rx_int8_1_mix_inp2_mux, tasha_codec_enable_swr,
  9111. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9112. SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9113. SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9114. SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9115. SND_SOC_DAPM_MIXER("RX INT1 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9116. rx_int1_spline_mix_switch,
  9117. ARRAY_SIZE(rx_int1_spline_mix_switch)),
  9118. SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9119. SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9120. SND_SOC_DAPM_MIXER("RX INT2 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9121. rx_int2_spline_mix_switch,
  9122. ARRAY_SIZE(rx_int2_spline_mix_switch)),
  9123. SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9124. SND_SOC_DAPM_MIXER("RX INT3_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9125. SND_SOC_DAPM_MIXER("RX INT3 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9126. rx_int3_spline_mix_switch,
  9127. ARRAY_SIZE(rx_int3_spline_mix_switch)),
  9128. SND_SOC_DAPM_MIXER("RX INT3 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9129. SND_SOC_DAPM_MIXER("RX INT4_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9130. SND_SOC_DAPM_MIXER("RX INT4 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9131. rx_int4_spline_mix_switch,
  9132. ARRAY_SIZE(rx_int4_spline_mix_switch)),
  9133. SND_SOC_DAPM_MIXER("RX INT4 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9134. SND_SOC_DAPM_MIXER("RX INT5_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9135. SND_SOC_DAPM_MIXER("RX INT5 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9136. rx_int5_spline_mix_switch,
  9137. ARRAY_SIZE(rx_int5_spline_mix_switch)),
  9138. SND_SOC_DAPM_MIXER("RX INT5 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9139. SND_SOC_DAPM_MIXER("RX INT6_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9140. SND_SOC_DAPM_MIXER("RX INT6 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9141. rx_int6_spline_mix_switch,
  9142. ARRAY_SIZE(rx_int6_spline_mix_switch)),
  9143. SND_SOC_DAPM_MIXER("RX INT6 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9144. SND_SOC_DAPM_MIXER("RX INT7_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9145. SND_SOC_DAPM_MIXER("RX INT7 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9146. SND_SOC_DAPM_MIXER("RX INT7 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9147. rx_int7_spline_mix_switch,
  9148. ARRAY_SIZE(rx_int7_spline_mix_switch)),
  9149. SND_SOC_DAPM_MIXER("RX INT8_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9150. SND_SOC_DAPM_MIXER("RX INT8 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9151. SND_SOC_DAPM_MIXER("RX INT8 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9152. rx_int8_spline_mix_switch,
  9153. ARRAY_SIZE(rx_int8_spline_mix_switch)),
  9154. SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9155. SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9156. SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9157. SND_SOC_DAPM_MIXER("RX INT3 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9158. SND_SOC_DAPM_MIXER("RX INT4 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9159. SND_SOC_DAPM_MIXER("RX INT5 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9160. SND_SOC_DAPM_MIXER("RX INT6 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9161. SND_SOC_DAPM_MIXER("RX INT7 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9162. SND_SOC_DAPM_MIXER_E("RX INT7 CHAIN", SND_SOC_NOPM, 0, 0,
  9163. NULL, 0, tasha_codec_spk_boost_event,
  9164. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9165. SND_SOC_DAPM_MIXER_E("RX INT8 CHAIN", SND_SOC_NOPM, 0, 0,
  9166. NULL, 0, tasha_codec_spk_boost_event,
  9167. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9168. SND_SOC_DAPM_MIXER_E("RX INT5 VBAT", SND_SOC_NOPM, 0, 0,
  9169. rx_int5_vbat_mix_switch,
  9170. ARRAY_SIZE(rx_int5_vbat_mix_switch),
  9171. tasha_codec_vbat_enable_event,
  9172. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9173. SND_SOC_DAPM_MIXER_E("RX INT6 VBAT", SND_SOC_NOPM, 0, 0,
  9174. rx_int6_vbat_mix_switch,
  9175. ARRAY_SIZE(rx_int6_vbat_mix_switch),
  9176. tasha_codec_vbat_enable_event,
  9177. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9178. SND_SOC_DAPM_MIXER_E("RX INT7 VBAT", SND_SOC_NOPM, 0, 0,
  9179. rx_int7_vbat_mix_switch,
  9180. ARRAY_SIZE(rx_int7_vbat_mix_switch),
  9181. tasha_codec_vbat_enable_event,
  9182. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9183. SND_SOC_DAPM_MIXER_E("RX INT8 VBAT", SND_SOC_NOPM, 0, 0,
  9184. rx_int8_vbat_mix_switch,
  9185. ARRAY_SIZE(rx_int8_vbat_mix_switch),
  9186. tasha_codec_vbat_enable_event,
  9187. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9188. SND_SOC_DAPM_MUX("RX INT0 MIX2 INP", WCD9335_CDC_RX0_RX_PATH_CFG1, 4,
  9189. 0, &rx_int0_mix2_inp_mux),
  9190. SND_SOC_DAPM_MUX("RX INT1 MIX2 INP", WCD9335_CDC_RX1_RX_PATH_CFG1, 4,
  9191. 0, &rx_int1_mix2_inp_mux),
  9192. SND_SOC_DAPM_MUX("RX INT2 MIX2 INP", WCD9335_CDC_RX2_RX_PATH_CFG1, 4,
  9193. 0, &rx_int2_mix2_inp_mux),
  9194. SND_SOC_DAPM_MUX("RX INT3 MIX2 INP", WCD9335_CDC_RX3_RX_PATH_CFG1, 4,
  9195. 0, &rx_int3_mix2_inp_mux),
  9196. SND_SOC_DAPM_MUX("RX INT4 MIX2 INP", WCD9335_CDC_RX4_RX_PATH_CFG1, 4,
  9197. 0, &rx_int4_mix2_inp_mux),
  9198. SND_SOC_DAPM_MUX("RX INT7 MIX2 INP", WCD9335_CDC_RX7_RX_PATH_CFG1, 4,
  9199. 0, &rx_int7_mix2_inp_mux),
  9200. SND_SOC_DAPM_MUX("SLIM TX0 MUX", SND_SOC_NOPM, TASHA_TX0, 0,
  9201. &sb_tx0_mux),
  9202. SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TASHA_TX1, 0,
  9203. &sb_tx1_mux),
  9204. SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TASHA_TX2, 0,
  9205. &sb_tx2_mux),
  9206. SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TASHA_TX3, 0,
  9207. &sb_tx3_mux),
  9208. SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TASHA_TX4, 0,
  9209. &sb_tx4_mux),
  9210. SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TASHA_TX5, 0,
  9211. &sb_tx5_mux),
  9212. SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, TASHA_TX6, 0,
  9213. &sb_tx6_mux),
  9214. SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, TASHA_TX7, 0,
  9215. &sb_tx7_mux),
  9216. SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, TASHA_TX8, 0,
  9217. &sb_tx8_mux),
  9218. SND_SOC_DAPM_MUX("SLIM TX9 MUX", SND_SOC_NOPM, TASHA_TX9, 0,
  9219. &sb_tx9_mux),
  9220. SND_SOC_DAPM_MUX("SLIM TX10 MUX", SND_SOC_NOPM, TASHA_TX10, 0,
  9221. &sb_tx10_mux),
  9222. SND_SOC_DAPM_MUX("SLIM TX11 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9223. &sb_tx11_mux),
  9224. SND_SOC_DAPM_MUX("SLIM TX11 INP1 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9225. &sb_tx11_inp1_mux),
  9226. SND_SOC_DAPM_MUX("SLIM TX13 MUX", SND_SOC_NOPM, TASHA_TX13, 0,
  9227. &sb_tx13_mux),
  9228. SND_SOC_DAPM_MUX("TX13 INP MUX", SND_SOC_NOPM, 0, 0,
  9229. &tx13_inp_mux),
  9230. SND_SOC_DAPM_MUX_E("ADC MUX0", WCD9335_CDC_TX0_TX_PATH_CTL, 5, 0,
  9231. &tx_adc_mux0, tasha_codec_enable_dec,
  9232. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9233. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9234. SND_SOC_DAPM_MUX_E("ADC MUX1", WCD9335_CDC_TX1_TX_PATH_CTL, 5, 0,
  9235. &tx_adc_mux1, tasha_codec_enable_dec,
  9236. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9237. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9238. SND_SOC_DAPM_MUX_E("ADC MUX2", WCD9335_CDC_TX2_TX_PATH_CTL, 5, 0,
  9239. &tx_adc_mux2, tasha_codec_enable_dec,
  9240. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9241. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9242. SND_SOC_DAPM_MUX_E("ADC MUX3", WCD9335_CDC_TX3_TX_PATH_CTL, 5, 0,
  9243. &tx_adc_mux3, tasha_codec_enable_dec,
  9244. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9245. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9246. SND_SOC_DAPM_MUX_E("ADC MUX4", WCD9335_CDC_TX4_TX_PATH_CTL, 5, 0,
  9247. &tx_adc_mux4, tasha_codec_enable_dec,
  9248. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9249. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9250. SND_SOC_DAPM_MUX_E("ADC MUX5", WCD9335_CDC_TX5_TX_PATH_CTL, 5, 0,
  9251. &tx_adc_mux5, tasha_codec_enable_dec,
  9252. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9253. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9254. SND_SOC_DAPM_MUX_E("ADC MUX6", WCD9335_CDC_TX6_TX_PATH_CTL, 5, 0,
  9255. &tx_adc_mux6, tasha_codec_enable_dec,
  9256. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9257. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9258. SND_SOC_DAPM_MUX_E("ADC MUX7", WCD9335_CDC_TX7_TX_PATH_CTL, 5, 0,
  9259. &tx_adc_mux7, tasha_codec_enable_dec,
  9260. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9261. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9262. SND_SOC_DAPM_MUX_E("ADC MUX8", WCD9335_CDC_TX8_TX_PATH_CTL, 5, 0,
  9263. &tx_adc_mux8, tasha_codec_enable_dec,
  9264. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9265. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9266. SND_SOC_DAPM_MUX_E("ADC MUX10", SND_SOC_NOPM, 10, 0,
  9267. &tx_adc_mux10, tasha_codec_tx_adc_cfg,
  9268. SND_SOC_DAPM_POST_PMU),
  9269. SND_SOC_DAPM_MUX_E("ADC MUX11", SND_SOC_NOPM, 11, 0,
  9270. &tx_adc_mux11, tasha_codec_tx_adc_cfg,
  9271. SND_SOC_DAPM_POST_PMU),
  9272. SND_SOC_DAPM_MUX_E("ADC MUX12", SND_SOC_NOPM, 12, 0,
  9273. &tx_adc_mux12, tasha_codec_tx_adc_cfg,
  9274. SND_SOC_DAPM_POST_PMU),
  9275. SND_SOC_DAPM_MUX_E("ADC MUX13", SND_SOC_NOPM, 13, 0,
  9276. &tx_adc_mux13, tasha_codec_tx_adc_cfg,
  9277. SND_SOC_DAPM_POST_PMU),
  9278. SND_SOC_DAPM_MUX("DMIC MUX0", SND_SOC_NOPM, 0, 0,
  9279. &tx_dmic_mux0),
  9280. SND_SOC_DAPM_MUX("DMIC MUX1", SND_SOC_NOPM, 0, 0,
  9281. &tx_dmic_mux1),
  9282. SND_SOC_DAPM_MUX("DMIC MUX2", SND_SOC_NOPM, 0, 0,
  9283. &tx_dmic_mux2),
  9284. SND_SOC_DAPM_MUX("DMIC MUX3", SND_SOC_NOPM, 0, 0,
  9285. &tx_dmic_mux3),
  9286. SND_SOC_DAPM_MUX("DMIC MUX4", SND_SOC_NOPM, 0, 0,
  9287. &tx_dmic_mux4),
  9288. SND_SOC_DAPM_MUX("DMIC MUX5", SND_SOC_NOPM, 0, 0,
  9289. &tx_dmic_mux5),
  9290. SND_SOC_DAPM_MUX("DMIC MUX6", SND_SOC_NOPM, 0, 0,
  9291. &tx_dmic_mux6),
  9292. SND_SOC_DAPM_MUX("DMIC MUX7", SND_SOC_NOPM, 0, 0,
  9293. &tx_dmic_mux7),
  9294. SND_SOC_DAPM_MUX("DMIC MUX8", SND_SOC_NOPM, 0, 0,
  9295. &tx_dmic_mux8),
  9296. SND_SOC_DAPM_MUX("DMIC MUX10", SND_SOC_NOPM, 0, 0,
  9297. &tx_dmic_mux10),
  9298. SND_SOC_DAPM_MUX("DMIC MUX11", SND_SOC_NOPM, 0, 0,
  9299. &tx_dmic_mux11),
  9300. SND_SOC_DAPM_MUX("DMIC MUX12", SND_SOC_NOPM, 0, 0,
  9301. &tx_dmic_mux12),
  9302. SND_SOC_DAPM_MUX("DMIC MUX13", SND_SOC_NOPM, 0, 0,
  9303. &tx_dmic_mux13),
  9304. SND_SOC_DAPM_MUX("AMIC MUX0", SND_SOC_NOPM, 0, 0,
  9305. &tx_amic_mux0),
  9306. SND_SOC_DAPM_MUX("AMIC MUX1", SND_SOC_NOPM, 0, 0,
  9307. &tx_amic_mux1),
  9308. SND_SOC_DAPM_MUX("AMIC MUX2", SND_SOC_NOPM, 0, 0,
  9309. &tx_amic_mux2),
  9310. SND_SOC_DAPM_MUX("AMIC MUX3", SND_SOC_NOPM, 0, 0,
  9311. &tx_amic_mux3),
  9312. SND_SOC_DAPM_MUX("AMIC MUX4", SND_SOC_NOPM, 0, 0,
  9313. &tx_amic_mux4),
  9314. SND_SOC_DAPM_MUX("AMIC MUX5", SND_SOC_NOPM, 0, 0,
  9315. &tx_amic_mux5),
  9316. SND_SOC_DAPM_MUX("AMIC MUX6", SND_SOC_NOPM, 0, 0,
  9317. &tx_amic_mux6),
  9318. SND_SOC_DAPM_MUX("AMIC MUX7", SND_SOC_NOPM, 0, 0,
  9319. &tx_amic_mux7),
  9320. SND_SOC_DAPM_MUX("AMIC MUX8", SND_SOC_NOPM, 0, 0,
  9321. &tx_amic_mux8),
  9322. SND_SOC_DAPM_MUX("AMIC MUX10", SND_SOC_NOPM, 0, 0,
  9323. &tx_amic_mux10),
  9324. SND_SOC_DAPM_MUX("AMIC MUX11", SND_SOC_NOPM, 0, 0,
  9325. &tx_amic_mux11),
  9326. SND_SOC_DAPM_MUX("AMIC MUX12", SND_SOC_NOPM, 0, 0,
  9327. &tx_amic_mux12),
  9328. SND_SOC_DAPM_MUX("AMIC MUX13", SND_SOC_NOPM, 0, 0,
  9329. &tx_amic_mux13),
  9330. SND_SOC_DAPM_ADC_E("ADC1", NULL, WCD9335_ANA_AMIC1, 7, 0,
  9331. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9332. SND_SOC_DAPM_ADC_E("ADC2", NULL, WCD9335_ANA_AMIC2, 7, 0,
  9333. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9334. SND_SOC_DAPM_ADC_E("ADC3", NULL, WCD9335_ANA_AMIC3, 7, 0,
  9335. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9336. SND_SOC_DAPM_ADC_E("ADC4", NULL, WCD9335_ANA_AMIC4, 7, 0,
  9337. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9338. SND_SOC_DAPM_ADC_E("ADC5", NULL, WCD9335_ANA_AMIC5, 7, 0,
  9339. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9340. SND_SOC_DAPM_ADC_E("ADC6", NULL, WCD9335_ANA_AMIC6, 7, 0,
  9341. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9342. SND_SOC_DAPM_SUPPLY("RX INT1 NATIVE SUPPLY", SND_SOC_NOPM,
  9343. INTERP_HPHL, 0, tasha_enable_native_supply,
  9344. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9345. SND_SOC_DAPM_SUPPLY("RX INT2 NATIVE SUPPLY", SND_SOC_NOPM,
  9346. INTERP_HPHR, 0, tasha_enable_native_supply,
  9347. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9348. SND_SOC_DAPM_SUPPLY("RX INT3 NATIVE SUPPLY", SND_SOC_NOPM,
  9349. INTERP_LO1, 0, tasha_enable_native_supply,
  9350. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9351. SND_SOC_DAPM_SUPPLY("RX INT4 NATIVE SUPPLY", SND_SOC_NOPM,
  9352. INTERP_LO2, 0, tasha_enable_native_supply,
  9353. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9354. SND_SOC_DAPM_INPUT("AMIC1"),
  9355. SND_SOC_DAPM_MICBIAS_E("MIC BIAS1", SND_SOC_NOPM, 0, 0,
  9356. tasha_codec_enable_micbias,
  9357. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9358. SND_SOC_DAPM_POST_PMD),
  9359. SND_SOC_DAPM_MICBIAS_E("MIC BIAS2", SND_SOC_NOPM, 0, 0,
  9360. tasha_codec_enable_micbias,
  9361. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9362. SND_SOC_DAPM_POST_PMD),
  9363. SND_SOC_DAPM_MICBIAS_E("MIC BIAS3", SND_SOC_NOPM, 0, 0,
  9364. tasha_codec_enable_micbias,
  9365. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9366. SND_SOC_DAPM_POST_PMD),
  9367. SND_SOC_DAPM_MICBIAS_E("MIC BIAS4", SND_SOC_NOPM, 0, 0,
  9368. tasha_codec_enable_micbias,
  9369. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9370. SND_SOC_DAPM_POST_PMD),
  9371. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS1_STANDALONE, SND_SOC_NOPM, 0, 0,
  9372. tasha_codec_force_enable_micbias,
  9373. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9374. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS2_STANDALONE, SND_SOC_NOPM, 0, 0,
  9375. tasha_codec_force_enable_micbias,
  9376. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9377. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS3_STANDALONE, SND_SOC_NOPM, 0, 0,
  9378. tasha_codec_force_enable_micbias,
  9379. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9380. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS4_STANDALONE, SND_SOC_NOPM, 0, 0,
  9381. tasha_codec_force_enable_micbias,
  9382. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9383. SND_SOC_DAPM_SUPPLY(DAPM_LDO_H_STANDALONE, SND_SOC_NOPM, 0, 0,
  9384. tasha_codec_force_enable_ldo_h,
  9385. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9386. SND_SOC_DAPM_MUX("ANC0 FB MUX", SND_SOC_NOPM, 0, 0, &anc0_fb_mux),
  9387. SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux),
  9388. SND_SOC_DAPM_INPUT("AMIC2"),
  9389. SND_SOC_DAPM_INPUT("AMIC3"),
  9390. SND_SOC_DAPM_INPUT("AMIC4"),
  9391. SND_SOC_DAPM_INPUT("AMIC5"),
  9392. SND_SOC_DAPM_INPUT("AMIC6"),
  9393. SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM,
  9394. AIF1_CAP, 0, tasha_codec_enable_slimtx,
  9395. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9396. SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM,
  9397. AIF2_CAP, 0, tasha_codec_enable_slimtx,
  9398. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9399. SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM,
  9400. AIF3_CAP, 0, tasha_codec_enable_slimtx,
  9401. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9402. SND_SOC_DAPM_AIF_OUT_E("AIF4 VI", "VIfeed", 0, SND_SOC_NOPM,
  9403. AIF4_VIFEED, 0, tasha_codec_enable_slimvi_feedback,
  9404. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9405. SND_SOC_DAPM_MIXER("AIF4_VI Mixer", SND_SOC_NOPM, AIF4_VIFEED, 0,
  9406. aif4_vi_mixer, ARRAY_SIZE(aif4_vi_mixer)),
  9407. SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0,
  9408. aif1_cap_mixer, ARRAY_SIZE(aif1_cap_mixer)),
  9409. SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0,
  9410. aif2_cap_mixer, ARRAY_SIZE(aif2_cap_mixer)),
  9411. SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0,
  9412. aif3_cap_mixer, ARRAY_SIZE(aif3_cap_mixer)),
  9413. SND_SOC_DAPM_MIXER("AIF4_MAD Mixer", SND_SOC_NOPM, AIF4_MAD_TX, 0,
  9414. aif4_mad_mixer, ARRAY_SIZE(aif4_mad_mixer)),
  9415. SND_SOC_DAPM_INPUT("VIINPUT"),
  9416. SND_SOC_DAPM_AIF_OUT("AIF5 CPE", "AIF5 CPE TX", 0, SND_SOC_NOPM,
  9417. AIF5_CPE_TX, 0),
  9418. SND_SOC_DAPM_MUX_E("EC BUF MUX INP", SND_SOC_NOPM, 0, 0, &ec_buf_mux,
  9419. tasha_codec_ec_buf_mux_enable,
  9420. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9421. /* Digital Mic Inputs */
  9422. SND_SOC_DAPM_ADC_E("DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  9423. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9424. SND_SOC_DAPM_POST_PMD),
  9425. SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  9426. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9427. SND_SOC_DAPM_POST_PMD),
  9428. SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  9429. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9430. SND_SOC_DAPM_POST_PMD),
  9431. SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  9432. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9433. SND_SOC_DAPM_POST_PMD),
  9434. SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  9435. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9436. SND_SOC_DAPM_POST_PMD),
  9437. SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  9438. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9439. SND_SOC_DAPM_POST_PMD),
  9440. SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux),
  9441. SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux),
  9442. SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux),
  9443. SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux),
  9444. SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux),
  9445. SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
  9446. SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux),
  9447. SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux),
  9448. SND_SOC_DAPM_MIXER_E("IIR0", WCD9335_CDC_SIDETONE_IIR0_IIR_PATH_CTL,
  9449. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9450. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9451. SND_SOC_DAPM_MIXER_E("IIR1", WCD9335_CDC_SIDETONE_IIR1_IIR_PATH_CTL,
  9452. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9453. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9454. SND_SOC_DAPM_MIXER("SRC0", WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL,
  9455. 4, 0, NULL, 0),
  9456. SND_SOC_DAPM_MIXER("SRC1", WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL,
  9457. 4, 0, NULL, 0),
  9458. SND_SOC_DAPM_MIXER_E("CPE IN Mixer", SND_SOC_NOPM, 0, 0,
  9459. cpe_in_mix_switch,
  9460. ARRAY_SIZE(cpe_in_mix_switch),
  9461. tasha_codec_configure_cpe_input,
  9462. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9463. SND_SOC_DAPM_MUX("RX INT1_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9464. &int1_1_native_mux),
  9465. SND_SOC_DAPM_MUX("RX INT2_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9466. &int2_1_native_mux),
  9467. SND_SOC_DAPM_MUX("RX INT3_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9468. &int3_1_native_mux),
  9469. SND_SOC_DAPM_MUX("RX INT4_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9470. &int4_1_native_mux),
  9471. SND_SOC_DAPM_MUX("RX MIX TX0 MUX", SND_SOC_NOPM, 0, 0,
  9472. &rx_mix_tx0_mux),
  9473. SND_SOC_DAPM_MUX("RX MIX TX1 MUX", SND_SOC_NOPM, 0, 0,
  9474. &rx_mix_tx1_mux),
  9475. SND_SOC_DAPM_MUX("RX MIX TX2 MUX", SND_SOC_NOPM, 0, 0,
  9476. &rx_mix_tx2_mux),
  9477. SND_SOC_DAPM_MUX("RX MIX TX3 MUX", SND_SOC_NOPM, 0, 0,
  9478. &rx_mix_tx3_mux),
  9479. SND_SOC_DAPM_MUX("RX MIX TX4 MUX", SND_SOC_NOPM, 0, 0,
  9480. &rx_mix_tx4_mux),
  9481. SND_SOC_DAPM_MUX("RX MIX TX5 MUX", SND_SOC_NOPM, 0, 0,
  9482. &rx_mix_tx5_mux),
  9483. SND_SOC_DAPM_MUX("RX MIX TX6 MUX", SND_SOC_NOPM, 0, 0,
  9484. &rx_mix_tx6_mux),
  9485. SND_SOC_DAPM_MUX("RX MIX TX7 MUX", SND_SOC_NOPM, 0, 0,
  9486. &rx_mix_tx7_mux),
  9487. SND_SOC_DAPM_MUX("RX MIX TX8 MUX", SND_SOC_NOPM, 0, 0,
  9488. &rx_mix_tx8_mux),
  9489. SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0,
  9490. &rx_int0_dem_inp_mux),
  9491. SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0,
  9492. &rx_int1_dem_inp_mux),
  9493. SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM, 0, 0,
  9494. &rx_int2_dem_inp_mux),
  9495. SND_SOC_DAPM_MUX_E("RX INT0 INTERP", SND_SOC_NOPM,
  9496. INTERP_EAR, 0, &rx_int0_interp_mux,
  9497. tasha_codec_enable_interpolator,
  9498. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9499. SND_SOC_DAPM_POST_PMD),
  9500. SND_SOC_DAPM_MUX_E("RX INT1 INTERP", SND_SOC_NOPM,
  9501. INTERP_HPHL, 0, &rx_int1_interp_mux,
  9502. tasha_codec_enable_interpolator,
  9503. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9504. SND_SOC_DAPM_POST_PMD),
  9505. SND_SOC_DAPM_MUX_E("RX INT2 INTERP", SND_SOC_NOPM,
  9506. INTERP_HPHR, 0, &rx_int2_interp_mux,
  9507. tasha_codec_enable_interpolator,
  9508. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9509. SND_SOC_DAPM_POST_PMD),
  9510. SND_SOC_DAPM_MUX_E("RX INT3 INTERP", SND_SOC_NOPM,
  9511. INTERP_LO1, 0, &rx_int3_interp_mux,
  9512. tasha_codec_enable_interpolator,
  9513. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9514. SND_SOC_DAPM_POST_PMD),
  9515. SND_SOC_DAPM_MUX_E("RX INT4 INTERP", SND_SOC_NOPM,
  9516. INTERP_LO2, 0, &rx_int4_interp_mux,
  9517. tasha_codec_enable_interpolator,
  9518. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9519. SND_SOC_DAPM_POST_PMD),
  9520. SND_SOC_DAPM_MUX_E("RX INT5 INTERP", SND_SOC_NOPM,
  9521. INTERP_LO3, 0, &rx_int5_interp_mux,
  9522. tasha_codec_enable_interpolator,
  9523. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9524. SND_SOC_DAPM_POST_PMD),
  9525. SND_SOC_DAPM_MUX_E("RX INT6 INTERP", SND_SOC_NOPM,
  9526. INTERP_LO4, 0, &rx_int6_interp_mux,
  9527. tasha_codec_enable_interpolator,
  9528. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9529. SND_SOC_DAPM_POST_PMD),
  9530. SND_SOC_DAPM_MUX_E("RX INT7 INTERP", SND_SOC_NOPM,
  9531. INTERP_SPKR1, 0, &rx_int7_interp_mux,
  9532. tasha_codec_enable_interpolator,
  9533. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9534. SND_SOC_DAPM_POST_PMD),
  9535. SND_SOC_DAPM_MUX_E("RX INT8 INTERP", SND_SOC_NOPM,
  9536. INTERP_SPKR2, 0, &rx_int8_interp_mux,
  9537. tasha_codec_enable_interpolator,
  9538. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9539. SND_SOC_DAPM_POST_PMD),
  9540. SND_SOC_DAPM_DAC_E("RX INT0 DAC", NULL, SND_SOC_NOPM,
  9541. 0, 0, tasha_codec_ear_dac_event,
  9542. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9543. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9544. SND_SOC_DAPM_DAC_E("RX INT1 DAC", NULL, SND_SOC_NOPM,
  9545. 0, 0, tasha_codec_hphl_dac_event,
  9546. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9547. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9548. SND_SOC_DAPM_DAC_E("RX INT2 DAC", NULL, SND_SOC_NOPM,
  9549. 0, 0, tasha_codec_hphr_dac_event,
  9550. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9551. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9552. SND_SOC_DAPM_DAC_E("RX INT3 DAC", NULL, SND_SOC_NOPM,
  9553. 0, 0, tasha_codec_lineout_dac_event,
  9554. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9555. SND_SOC_DAPM_DAC_E("RX INT4 DAC", NULL, SND_SOC_NOPM,
  9556. 0, 0, tasha_codec_lineout_dac_event,
  9557. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9558. SND_SOC_DAPM_DAC_E("RX INT5 DAC", NULL, SND_SOC_NOPM,
  9559. 0, 0, tasha_codec_lineout_dac_event,
  9560. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9561. SND_SOC_DAPM_DAC_E("RX INT6 DAC", NULL, SND_SOC_NOPM,
  9562. 0, 0, tasha_codec_lineout_dac_event,
  9563. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9564. SND_SOC_DAPM_PGA_E("HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9565. tasha_codec_enable_hphl_pa,
  9566. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9567. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9568. SND_SOC_DAPM_PGA_E("HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9569. tasha_codec_enable_hphr_pa,
  9570. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9571. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9572. SND_SOC_DAPM_PGA_E("EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9573. tasha_codec_enable_ear_pa,
  9574. SND_SOC_DAPM_POST_PMU |
  9575. SND_SOC_DAPM_POST_PMD),
  9576. SND_SOC_DAPM_PGA_E("LINEOUT1 PA", WCD9335_ANA_LO_1_2, 7, 0, NULL, 0,
  9577. tasha_codec_enable_lineout_pa,
  9578. SND_SOC_DAPM_POST_PMU |
  9579. SND_SOC_DAPM_POST_PMD),
  9580. SND_SOC_DAPM_PGA_E("LINEOUT2 PA", WCD9335_ANA_LO_1_2, 6, 0, NULL, 0,
  9581. tasha_codec_enable_lineout_pa,
  9582. SND_SOC_DAPM_POST_PMU |
  9583. SND_SOC_DAPM_POST_PMD),
  9584. SND_SOC_DAPM_PGA_E("LINEOUT3 PA", WCD9335_ANA_LO_3_4, 7, 0, NULL, 0,
  9585. tasha_codec_enable_lineout_pa,
  9586. SND_SOC_DAPM_POST_PMU |
  9587. SND_SOC_DAPM_POST_PMD),
  9588. SND_SOC_DAPM_PGA_E("LINEOUT4 PA", WCD9335_ANA_LO_3_4, 6, 0, NULL, 0,
  9589. tasha_codec_enable_lineout_pa,
  9590. SND_SOC_DAPM_POST_PMU |
  9591. SND_SOC_DAPM_POST_PMD),
  9592. SND_SOC_DAPM_PGA_E("ANC EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9593. tasha_codec_enable_ear_pa,
  9594. SND_SOC_DAPM_POST_PMU |
  9595. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9596. SND_SOC_DAPM_PGA_E("ANC HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9597. tasha_codec_enable_hphl_pa,
  9598. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9599. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9600. SND_SOC_DAPM_PGA_E("ANC HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9601. tasha_codec_enable_hphr_pa,
  9602. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9603. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9604. SND_SOC_DAPM_PGA_E("ANC LINEOUT1 PA", WCD9335_ANA_LO_1_2,
  9605. 7, 0, NULL, 0,
  9606. tasha_codec_enable_lineout_pa,
  9607. SND_SOC_DAPM_POST_PMU |
  9608. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9609. SND_SOC_DAPM_PGA_E("ANC LINEOUT2 PA", WCD9335_ANA_LO_1_2,
  9610. 6, 0, NULL, 0,
  9611. tasha_codec_enable_lineout_pa,
  9612. SND_SOC_DAPM_POST_PMU |
  9613. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9614. SND_SOC_DAPM_PGA_E("ANC SPK1 PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9615. tasha_codec_enable_spk_anc,
  9616. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9617. SND_SOC_DAPM_OUTPUT("HPHL"),
  9618. SND_SOC_DAPM_OUTPUT("HPHR"),
  9619. SND_SOC_DAPM_OUTPUT("ANC HPHL"),
  9620. SND_SOC_DAPM_OUTPUT("ANC HPHR"),
  9621. SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0,
  9622. tasha_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU |
  9623. SND_SOC_DAPM_POST_PMD),
  9624. SND_SOC_DAPM_OUTPUT("SPK1 OUT"),
  9625. SND_SOC_DAPM_OUTPUT("SPK2 OUT"),
  9626. SND_SOC_DAPM_OUTPUT("LINEOUT1"),
  9627. SND_SOC_DAPM_OUTPUT("LINEOUT2"),
  9628. SND_SOC_DAPM_OUTPUT("LINEOUT3"),
  9629. SND_SOC_DAPM_OUTPUT("LINEOUT4"),
  9630. SND_SOC_DAPM_OUTPUT("ANC LINEOUT1"),
  9631. SND_SOC_DAPM_OUTPUT("ANC LINEOUT2"),
  9632. SND_SOC_DAPM_SUPPLY("MICBIAS_REGULATOR", SND_SOC_NOPM,
  9633. ON_DEMAND_MICBIAS, 0,
  9634. tasha_codec_enable_on_demand_supply,
  9635. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9636. SND_SOC_DAPM_SWITCH("ADC US MUX0", WCD9335_CDC_TX0_TX_PATH_192_CTL, 0,
  9637. 0, &adc_us_mux0_switch),
  9638. SND_SOC_DAPM_SWITCH("ADC US MUX1", WCD9335_CDC_TX1_TX_PATH_192_CTL, 0,
  9639. 0, &adc_us_mux1_switch),
  9640. SND_SOC_DAPM_SWITCH("ADC US MUX2", WCD9335_CDC_TX2_TX_PATH_192_CTL, 0,
  9641. 0, &adc_us_mux2_switch),
  9642. SND_SOC_DAPM_SWITCH("ADC US MUX3", WCD9335_CDC_TX3_TX_PATH_192_CTL, 0,
  9643. 0, &adc_us_mux3_switch),
  9644. SND_SOC_DAPM_SWITCH("ADC US MUX4", WCD9335_CDC_TX4_TX_PATH_192_CTL, 0,
  9645. 0, &adc_us_mux4_switch),
  9646. SND_SOC_DAPM_SWITCH("ADC US MUX5", WCD9335_CDC_TX5_TX_PATH_192_CTL, 0,
  9647. 0, &adc_us_mux5_switch),
  9648. SND_SOC_DAPM_SWITCH("ADC US MUX6", WCD9335_CDC_TX6_TX_PATH_192_CTL, 0,
  9649. 0, &adc_us_mux6_switch),
  9650. SND_SOC_DAPM_SWITCH("ADC US MUX7", WCD9335_CDC_TX7_TX_PATH_192_CTL, 0,
  9651. 0, &adc_us_mux7_switch),
  9652. SND_SOC_DAPM_SWITCH("ADC US MUX8", WCD9335_CDC_TX8_TX_PATH_192_CTL, 0,
  9653. 0, &adc_us_mux8_switch),
  9654. /* MAD related widgets */
  9655. SND_SOC_DAPM_AIF_OUT_E("AIF4 MAD", "AIF4 MAD TX", 0,
  9656. SND_SOC_NOPM, 0, 0,
  9657. tasha_codec_enable_mad,
  9658. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9659. SND_SOC_DAPM_MUX("MAD_SEL MUX", SND_SOC_NOPM, 0, 0,
  9660. &mad_sel_mux),
  9661. SND_SOC_DAPM_INPUT("MAD_CPE_INPUT"),
  9662. SND_SOC_DAPM_INPUT("MADINPUT"),
  9663. SND_SOC_DAPM_SWITCH("MADONOFF", SND_SOC_NOPM, 0, 0,
  9664. &aif4_mad_switch),
  9665. SND_SOC_DAPM_SWITCH("MAD_BROADCAST", SND_SOC_NOPM, 0, 0,
  9666. &mad_brdcst_switch),
  9667. SND_SOC_DAPM_SWITCH("AIF4", SND_SOC_NOPM, 0, 0,
  9668. &aif4_switch_mixer_controls),
  9669. SND_SOC_DAPM_SWITCH("ANC HPHL Enable", SND_SOC_NOPM, 0, 0,
  9670. &anc_hphl_switch),
  9671. SND_SOC_DAPM_SWITCH("ANC HPHR Enable", SND_SOC_NOPM, 0, 0,
  9672. &anc_hphr_switch),
  9673. SND_SOC_DAPM_SWITCH("ANC EAR Enable", SND_SOC_NOPM, 0, 0,
  9674. &anc_ear_switch),
  9675. SND_SOC_DAPM_SWITCH("ANC OUT EAR SPKR Enable", SND_SOC_NOPM, 0, 0,
  9676. &anc_ear_spkr_switch),
  9677. SND_SOC_DAPM_SWITCH("ANC LINEOUT1 Enable", SND_SOC_NOPM, 0, 0,
  9678. &anc_lineout1_switch),
  9679. SND_SOC_DAPM_SWITCH("ANC LINEOUT2 Enable", SND_SOC_NOPM, 0, 0,
  9680. &anc_lineout2_switch),
  9681. SND_SOC_DAPM_SWITCH("ANC SPKR PA Enable", SND_SOC_NOPM, 0, 0,
  9682. &anc_spkr_pa_switch),
  9683. };
  9684. static int tasha_get_channel_map(struct snd_soc_dai *dai,
  9685. unsigned int *tx_num, unsigned int *tx_slot,
  9686. unsigned int *rx_num, unsigned int *rx_slot)
  9687. {
  9688. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(dai->codec);
  9689. u32 i = 0;
  9690. struct wcd9xxx_ch *ch;
  9691. switch (dai->id) {
  9692. case AIF1_PB:
  9693. case AIF2_PB:
  9694. case AIF3_PB:
  9695. case AIF4_PB:
  9696. case AIF_MIX1_PB:
  9697. if (!rx_slot || !rx_num) {
  9698. pr_err("%s: Invalid rx_slot %pK or rx_num %pK\n",
  9699. __func__, rx_slot, rx_num);
  9700. return -EINVAL;
  9701. }
  9702. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9703. list) {
  9704. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9705. __func__, i, ch->ch_num);
  9706. rx_slot[i++] = ch->ch_num;
  9707. }
  9708. pr_debug("%s: rx_num %d\n", __func__, i);
  9709. *rx_num = i;
  9710. break;
  9711. case AIF1_CAP:
  9712. case AIF2_CAP:
  9713. case AIF3_CAP:
  9714. case AIF4_MAD_TX:
  9715. case AIF4_VIFEED:
  9716. if (!tx_slot || !tx_num) {
  9717. pr_err("%s: Invalid tx_slot %pK or tx_num %pK\n",
  9718. __func__, tx_slot, tx_num);
  9719. return -EINVAL;
  9720. }
  9721. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9722. list) {
  9723. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9724. __func__, i, ch->ch_num);
  9725. tx_slot[i++] = ch->ch_num;
  9726. }
  9727. pr_debug("%s: tx_num %d\n", __func__, i);
  9728. *tx_num = i;
  9729. break;
  9730. default:
  9731. pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id);
  9732. break;
  9733. }
  9734. return 0;
  9735. }
  9736. static int tasha_set_channel_map(struct snd_soc_dai *dai,
  9737. unsigned int tx_num, unsigned int *tx_slot,
  9738. unsigned int rx_num, unsigned int *rx_slot)
  9739. {
  9740. struct tasha_priv *tasha;
  9741. struct wcd9xxx *core;
  9742. struct wcd9xxx_codec_dai_data *dai_data = NULL;
  9743. if (!dai) {
  9744. pr_err("%s: dai is empty\n", __func__);
  9745. return -EINVAL;
  9746. }
  9747. tasha = snd_soc_codec_get_drvdata(dai->codec);
  9748. core = dev_get_drvdata(dai->codec->dev->parent);
  9749. if (!tx_slot || !rx_slot) {
  9750. pr_err("%s: Invalid tx_slot=%pK, rx_slot=%pK\n",
  9751. __func__, tx_slot, rx_slot);
  9752. return -EINVAL;
  9753. }
  9754. pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n"
  9755. "tasha->intf_type %d\n",
  9756. __func__, dai->name, dai->id, tx_num, rx_num,
  9757. tasha->intf_type);
  9758. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  9759. wcd9xxx_init_slimslave(core, core->slim->laddr,
  9760. tx_num, tx_slot, rx_num, rx_slot);
  9761. /* Reserve TX12/TX13 for MAD data channel */
  9762. dai_data = &tasha->dai[AIF4_MAD_TX];
  9763. if (dai_data) {
  9764. if (TASHA_IS_2_0(tasha->wcd9xxx))
  9765. list_add_tail(&core->tx_chs[TASHA_TX13].list,
  9766. &dai_data->wcd9xxx_ch_list);
  9767. else
  9768. list_add_tail(&core->tx_chs[TASHA_TX12].list,
  9769. &dai_data->wcd9xxx_ch_list);
  9770. }
  9771. }
  9772. return 0;
  9773. }
  9774. static int tasha_startup(struct snd_pcm_substream *substream,
  9775. struct snd_soc_dai *dai)
  9776. {
  9777. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9778. substream->name, substream->stream);
  9779. return 0;
  9780. }
  9781. static void tasha_shutdown(struct snd_pcm_substream *substream,
  9782. struct snd_soc_dai *dai)
  9783. {
  9784. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  9785. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9786. substream->name, substream->stream);
  9787. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  9788. return;
  9789. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  9790. tasha_codec_vote_max_bw(dai->codec, false);
  9791. }
  9792. static int tasha_set_decimator_rate(struct snd_soc_dai *dai,
  9793. u8 tx_fs_rate_reg_val, u32 sample_rate)
  9794. {
  9795. struct snd_soc_codec *codec = dai->codec;
  9796. struct wcd9xxx_ch *ch;
  9797. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9798. u32 tx_port = 0;
  9799. u8 shift = 0, shift_val = 0, tx_mux_sel = 0;
  9800. int decimator = -1;
  9801. u16 tx_port_reg = 0, tx_fs_reg = 0;
  9802. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9803. tx_port = ch->port;
  9804. dev_dbg(codec->dev, "%s: dai->id = %d, tx_port = %d",
  9805. __func__, dai->id, tx_port);
  9806. if ((tx_port < 0) || (tx_port == 12) || (tx_port >= 14)) {
  9807. dev_err(codec->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n",
  9808. __func__, tx_port, dai->id);
  9809. return -EINVAL;
  9810. }
  9811. /* Find the SB TX MUX input - which decimator is connected */
  9812. if (tx_port < 4) {
  9813. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0;
  9814. shift = (tx_port << 1);
  9815. shift_val = 0x03;
  9816. } else if ((tx_port >= 4) && (tx_port < 8)) {
  9817. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1;
  9818. shift = ((tx_port - 4) << 1);
  9819. shift_val = 0x03;
  9820. } else if ((tx_port >= 8) && (tx_port < 11)) {
  9821. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2;
  9822. shift = ((tx_port - 8) << 1);
  9823. shift_val = 0x03;
  9824. } else if (tx_port == 11) {
  9825. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9826. shift = 0;
  9827. shift_val = 0x0F;
  9828. } else if (tx_port == 13) {
  9829. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9830. shift = 4;
  9831. shift_val = 0x03;
  9832. }
  9833. tx_mux_sel = snd_soc_read(codec, tx_port_reg) &
  9834. (shift_val << shift);
  9835. tx_mux_sel = tx_mux_sel >> shift;
  9836. if (tx_port <= 8) {
  9837. if ((tx_mux_sel == 0x2) || (tx_mux_sel == 0x3))
  9838. decimator = tx_port;
  9839. } else if (tx_port <= 10) {
  9840. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9841. decimator = ((tx_port == 9) ? 7 : 6);
  9842. } else if (tx_port == 11) {
  9843. if ((tx_mux_sel >= 1) && (tx_mux_sel < 7))
  9844. decimator = tx_mux_sel - 1;
  9845. } else if (tx_port == 13) {
  9846. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9847. decimator = 5;
  9848. }
  9849. if (decimator >= 0) {
  9850. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  9851. 16 * decimator;
  9852. dev_dbg(codec->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n",
  9853. __func__, decimator, tx_port, sample_rate);
  9854. snd_soc_update_bits(codec, tx_fs_reg, 0x0F,
  9855. tx_fs_rate_reg_val);
  9856. } else if ((tx_port <= 8) && (tx_mux_sel == 0x01)) {
  9857. /* Check if the TX Mux input is RX MIX TXn */
  9858. dev_dbg(codec->dev, "%s: RX_MIX_TX%u going to SLIM TX%u\n",
  9859. __func__, tx_port, tx_port);
  9860. } else {
  9861. dev_err(codec->dev, "%s: ERROR: Invalid decimator: %d\n",
  9862. __func__, decimator);
  9863. return -EINVAL;
  9864. }
  9865. }
  9866. return 0;
  9867. }
  9868. static int tasha_set_mix_interpolator_rate(struct snd_soc_dai *dai,
  9869. u8 int_mix_fs_rate_reg_val,
  9870. u32 sample_rate)
  9871. {
  9872. u8 int_2_inp;
  9873. u32 j;
  9874. u16 int_mux_cfg1, int_fs_reg;
  9875. u8 int_mux_cfg1_val;
  9876. struct snd_soc_codec *codec = dai->codec;
  9877. struct wcd9xxx_ch *ch;
  9878. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9879. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9880. int_2_inp = ch->port + INTn_2_INP_SEL_RX0 -
  9881. TASHA_RX_PORT_START_NUMBER;
  9882. if ((int_2_inp < INTn_2_INP_SEL_RX0) ||
  9883. (int_2_inp > INTn_2_INP_SEL_RX7)) {
  9884. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9885. __func__,
  9886. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9887. dai->id);
  9888. return -EINVAL;
  9889. }
  9890. int_mux_cfg1 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1;
  9891. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9892. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) &
  9893. 0x0F;
  9894. if (int_mux_cfg1_val == int_2_inp) {
  9895. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_MIX_CTL +
  9896. 20 * j;
  9897. pr_debug("%s: AIF_MIX_PB DAI(%d) connected to INT%u_2\n",
  9898. __func__, dai->id, j);
  9899. pr_debug("%s: set INT%u_2 sample rate to %u\n",
  9900. __func__, j, sample_rate);
  9901. snd_soc_update_bits(codec, int_fs_reg,
  9902. 0x0F, int_mix_fs_rate_reg_val);
  9903. }
  9904. int_mux_cfg1 += 2;
  9905. }
  9906. }
  9907. return 0;
  9908. }
  9909. static int tasha_set_prim_interpolator_rate(struct snd_soc_dai *dai,
  9910. u8 int_prim_fs_rate_reg_val,
  9911. u32 sample_rate)
  9912. {
  9913. u8 int_1_mix1_inp;
  9914. u32 j;
  9915. u16 int_mux_cfg0, int_mux_cfg1;
  9916. u16 int_fs_reg;
  9917. u8 int_mux_cfg0_val, int_mux_cfg1_val;
  9918. u8 inp0_sel, inp1_sel, inp2_sel;
  9919. struct snd_soc_codec *codec = dai->codec;
  9920. struct wcd9xxx_ch *ch;
  9921. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9922. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9923. int_1_mix1_inp = ch->port + INTn_1_MIX_INP_SEL_RX0 -
  9924. TASHA_RX_PORT_START_NUMBER;
  9925. if ((int_1_mix1_inp < INTn_1_MIX_INP_SEL_RX0) ||
  9926. (int_1_mix1_inp > INTn_1_MIX_INP_SEL_RX7)) {
  9927. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9928. __func__,
  9929. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9930. dai->id);
  9931. return -EINVAL;
  9932. }
  9933. int_mux_cfg0 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0;
  9934. /*
  9935. * Loop through all interpolator MUX inputs and find out
  9936. * to which interpolator input, the slim rx port
  9937. * is connected
  9938. */
  9939. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9940. int_mux_cfg1 = int_mux_cfg0 + 1;
  9941. int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0);
  9942. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1);
  9943. inp0_sel = int_mux_cfg0_val & 0x0F;
  9944. inp1_sel = (int_mux_cfg0_val >> 4) & 0x0F;
  9945. inp2_sel = (int_mux_cfg1_val >> 4) & 0x0F;
  9946. if ((inp0_sel == int_1_mix1_inp) ||
  9947. (inp1_sel == int_1_mix1_inp) ||
  9948. (inp2_sel == int_1_mix1_inp)) {
  9949. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_CTL +
  9950. 20 * j;
  9951. pr_debug("%s: AIF_PB DAI(%d) connected to INT%u_1\n",
  9952. __func__, dai->id, j);
  9953. pr_debug("%s: set INT%u_1 sample rate to %u\n",
  9954. __func__, j, sample_rate);
  9955. /* sample_rate is in Hz */
  9956. if ((j == 0) && (sample_rate == 44100)) {
  9957. pr_info("%s: Cannot set 44.1KHz on INT0\n",
  9958. __func__);
  9959. } else
  9960. snd_soc_update_bits(codec, int_fs_reg,
  9961. 0x0F, int_prim_fs_rate_reg_val);
  9962. }
  9963. int_mux_cfg0 += 2;
  9964. }
  9965. }
  9966. return 0;
  9967. }
  9968. static int tasha_set_interpolator_rate(struct snd_soc_dai *dai,
  9969. u32 sample_rate)
  9970. {
  9971. int rate_val = 0;
  9972. int i, ret;
  9973. /* set mixing path rate */
  9974. for (i = 0; i < ARRAY_SIZE(int_mix_sample_rate_val); i++) {
  9975. if (sample_rate ==
  9976. int_mix_sample_rate_val[i].sample_rate) {
  9977. rate_val =
  9978. int_mix_sample_rate_val[i].rate_val;
  9979. break;
  9980. }
  9981. }
  9982. if ((i == ARRAY_SIZE(int_mix_sample_rate_val)) ||
  9983. (rate_val < 0))
  9984. goto prim_rate;
  9985. ret = tasha_set_mix_interpolator_rate(dai,
  9986. (u8) rate_val, sample_rate);
  9987. prim_rate:
  9988. /* set primary path sample rate */
  9989. for (i = 0; i < ARRAY_SIZE(int_prim_sample_rate_val); i++) {
  9990. if (sample_rate ==
  9991. int_prim_sample_rate_val[i].sample_rate) {
  9992. rate_val =
  9993. int_prim_sample_rate_val[i].rate_val;
  9994. break;
  9995. }
  9996. }
  9997. if ((i == ARRAY_SIZE(int_prim_sample_rate_val)) ||
  9998. (rate_val < 0))
  9999. return -EINVAL;
  10000. ret = tasha_set_prim_interpolator_rate(dai,
  10001. (u8) rate_val, sample_rate);
  10002. return ret;
  10003. }
  10004. static int tasha_prepare(struct snd_pcm_substream *substream,
  10005. struct snd_soc_dai *dai)
  10006. {
  10007. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  10008. substream->name, substream->stream);
  10009. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  10010. tasha_codec_vote_max_bw(dai->codec, false);
  10011. return 0;
  10012. }
  10013. static int tasha_hw_params(struct snd_pcm_substream *substream,
  10014. struct snd_pcm_hw_params *params,
  10015. struct snd_soc_dai *dai)
  10016. {
  10017. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  10018. int ret;
  10019. int tx_fs_rate = -EINVAL;
  10020. int rx_fs_rate = -EINVAL;
  10021. int i2s_bit_mode;
  10022. struct snd_soc_codec *codec = dai->codec;
  10023. pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
  10024. dai->name, dai->id, params_rate(params),
  10025. params_channels(params));
  10026. switch (substream->stream) {
  10027. case SNDRV_PCM_STREAM_PLAYBACK:
  10028. ret = tasha_set_interpolator_rate(dai, params_rate(params));
  10029. if (ret) {
  10030. pr_err("%s: cannot set sample rate: %u\n",
  10031. __func__, params_rate(params));
  10032. return ret;
  10033. }
  10034. switch (params_width(params)) {
  10035. case 16:
  10036. tasha->dai[dai->id].bit_width = 16;
  10037. i2s_bit_mode = 0x01;
  10038. break;
  10039. case 24:
  10040. tasha->dai[dai->id].bit_width = 24;
  10041. i2s_bit_mode = 0x00;
  10042. break;
  10043. default:
  10044. return -EINVAL;
  10045. }
  10046. tasha->dai[dai->id].rate = params_rate(params);
  10047. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10048. switch (params_rate(params)) {
  10049. case 8000:
  10050. rx_fs_rate = 0;
  10051. break;
  10052. case 16000:
  10053. rx_fs_rate = 1;
  10054. break;
  10055. case 32000:
  10056. rx_fs_rate = 2;
  10057. break;
  10058. case 48000:
  10059. rx_fs_rate = 3;
  10060. break;
  10061. case 96000:
  10062. rx_fs_rate = 4;
  10063. break;
  10064. case 192000:
  10065. rx_fs_rate = 5;
  10066. break;
  10067. default:
  10068. dev_err(tasha->dev,
  10069. "%s: Invalid RX sample rate: %d\n",
  10070. __func__, params_rate(params));
  10071. return -EINVAL;
  10072. };
  10073. snd_soc_update_bits(codec,
  10074. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10075. 0x20, i2s_bit_mode << 5);
  10076. snd_soc_update_bits(codec,
  10077. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10078. 0x1c, (rx_fs_rate << 2));
  10079. }
  10080. break;
  10081. case SNDRV_PCM_STREAM_CAPTURE:
  10082. switch (params_rate(params)) {
  10083. case 8000:
  10084. tx_fs_rate = 0;
  10085. break;
  10086. case 16000:
  10087. tx_fs_rate = 1;
  10088. break;
  10089. case 32000:
  10090. tx_fs_rate = 3;
  10091. break;
  10092. case 48000:
  10093. tx_fs_rate = 4;
  10094. break;
  10095. case 96000:
  10096. tx_fs_rate = 5;
  10097. break;
  10098. case 192000:
  10099. tx_fs_rate = 6;
  10100. break;
  10101. case 384000:
  10102. tx_fs_rate = 7;
  10103. break;
  10104. default:
  10105. dev_err(tasha->dev, "%s: Invalid TX sample rate: %d\n",
  10106. __func__, params_rate(params));
  10107. return -EINVAL;
  10108. };
  10109. if (dai->id != AIF4_VIFEED &&
  10110. dai->id != AIF4_MAD_TX) {
  10111. ret = tasha_set_decimator_rate(dai, tx_fs_rate,
  10112. params_rate(params));
  10113. if (ret < 0) {
  10114. dev_err(tasha->dev, "%s: cannot set TX Decimator rate: %d\n",
  10115. __func__, tx_fs_rate);
  10116. return ret;
  10117. }
  10118. }
  10119. tasha->dai[dai->id].rate = params_rate(params);
  10120. switch (params_width(params)) {
  10121. case 16:
  10122. tasha->dai[dai->id].bit_width = 16;
  10123. i2s_bit_mode = 0x01;
  10124. break;
  10125. case 24:
  10126. tasha->dai[dai->id].bit_width = 24;
  10127. i2s_bit_mode = 0x00;
  10128. break;
  10129. case 32:
  10130. tasha->dai[dai->id].bit_width = 32;
  10131. i2s_bit_mode = 0x00;
  10132. break;
  10133. default:
  10134. dev_err(tasha->dev, "%s: Invalid format 0x%x\n",
  10135. __func__, params_width(params));
  10136. return -EINVAL;
  10137. };
  10138. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10139. snd_soc_update_bits(codec,
  10140. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10141. 0x20, i2s_bit_mode << 5);
  10142. if (tx_fs_rate > 1)
  10143. tx_fs_rate--;
  10144. snd_soc_update_bits(codec,
  10145. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10146. 0x1c, tx_fs_rate << 2);
  10147. snd_soc_update_bits(codec,
  10148. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG,
  10149. 0x05, 0x05);
  10150. snd_soc_update_bits(codec,
  10151. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG,
  10152. 0x05, 0x05);
  10153. snd_soc_update_bits(codec,
  10154. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG,
  10155. 0x05, 0x05);
  10156. snd_soc_update_bits(codec,
  10157. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG,
  10158. 0x05, 0x05);
  10159. }
  10160. break;
  10161. default:
  10162. pr_err("%s: Invalid stream type %d\n", __func__,
  10163. substream->stream);
  10164. return -EINVAL;
  10165. };
  10166. if (dai->id == AIF4_VIFEED)
  10167. tasha->dai[dai->id].bit_width = 32;
  10168. return 0;
  10169. }
  10170. static int tasha_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  10171. {
  10172. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  10173. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  10174. case SND_SOC_DAIFMT_CBS_CFS:
  10175. /* CPU is master */
  10176. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10177. if (dai->id == AIF1_CAP)
  10178. snd_soc_update_bits(dai->codec,
  10179. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10180. 0x2, 0);
  10181. else if (dai->id == AIF1_PB)
  10182. snd_soc_update_bits(dai->codec,
  10183. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10184. 0x2, 0);
  10185. }
  10186. break;
  10187. case SND_SOC_DAIFMT_CBM_CFM:
  10188. /* CPU is slave */
  10189. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10190. if (dai->id == AIF1_CAP)
  10191. snd_soc_update_bits(dai->codec,
  10192. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10193. 0x2, 0x2);
  10194. else if (dai->id == AIF1_PB)
  10195. snd_soc_update_bits(dai->codec,
  10196. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10197. 0x2, 0x2);
  10198. }
  10199. break;
  10200. default:
  10201. return -EINVAL;
  10202. }
  10203. return 0;
  10204. }
  10205. static int tasha_set_dai_sysclk(struct snd_soc_dai *dai,
  10206. int clk_id, unsigned int freq, int dir)
  10207. {
  10208. pr_debug("%s\n", __func__);
  10209. return 0;
  10210. }
  10211. static struct snd_soc_dai_ops tasha_dai_ops = {
  10212. .startup = tasha_startup,
  10213. .shutdown = tasha_shutdown,
  10214. .hw_params = tasha_hw_params,
  10215. .prepare = tasha_prepare,
  10216. .set_sysclk = tasha_set_dai_sysclk,
  10217. .set_fmt = tasha_set_dai_fmt,
  10218. .set_channel_map = tasha_set_channel_map,
  10219. .get_channel_map = tasha_get_channel_map,
  10220. };
  10221. static struct snd_soc_dai_driver tasha_dai[] = {
  10222. {
  10223. .name = "tasha_rx1",
  10224. .id = AIF1_PB,
  10225. .playback = {
  10226. .stream_name = "AIF1 Playback",
  10227. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10228. .formats = TASHA_FORMATS_S16_S24_LE,
  10229. .rate_max = 192000,
  10230. .rate_min = 8000,
  10231. .channels_min = 1,
  10232. .channels_max = 2,
  10233. },
  10234. .ops = &tasha_dai_ops,
  10235. },
  10236. {
  10237. .name = "tasha_tx1",
  10238. .id = AIF1_CAP,
  10239. .capture = {
  10240. .stream_name = "AIF1 Capture",
  10241. .rates = WCD9335_RATES_MASK,
  10242. .formats = TASHA_FORMATS_S16_S24_LE,
  10243. .rate_max = 192000,
  10244. .rate_min = 8000,
  10245. .channels_min = 1,
  10246. .channels_max = 4,
  10247. },
  10248. .ops = &tasha_dai_ops,
  10249. },
  10250. {
  10251. .name = "tasha_rx2",
  10252. .id = AIF2_PB,
  10253. .playback = {
  10254. .stream_name = "AIF2 Playback",
  10255. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10256. .formats = TASHA_FORMATS_S16_S24_LE,
  10257. .rate_min = 8000,
  10258. .rate_max = 192000,
  10259. .channels_min = 1,
  10260. .channels_max = 2,
  10261. },
  10262. .ops = &tasha_dai_ops,
  10263. },
  10264. {
  10265. .name = "tasha_tx2",
  10266. .id = AIF2_CAP,
  10267. .capture = {
  10268. .stream_name = "AIF2 Capture",
  10269. .rates = WCD9335_RATES_MASK,
  10270. .formats = TASHA_FORMATS_S16_S24_LE,
  10271. .rate_max = 192000,
  10272. .rate_min = 8000,
  10273. .channels_min = 1,
  10274. .channels_max = 8,
  10275. },
  10276. .ops = &tasha_dai_ops,
  10277. },
  10278. {
  10279. .name = "tasha_rx3",
  10280. .id = AIF3_PB,
  10281. .playback = {
  10282. .stream_name = "AIF3 Playback",
  10283. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10284. .formats = TASHA_FORMATS_S16_S24_LE,
  10285. .rate_min = 8000,
  10286. .rate_max = 192000,
  10287. .channels_min = 1,
  10288. .channels_max = 2,
  10289. },
  10290. .ops = &tasha_dai_ops,
  10291. },
  10292. {
  10293. .name = "tasha_tx3",
  10294. .id = AIF3_CAP,
  10295. .capture = {
  10296. .stream_name = "AIF3 Capture",
  10297. .rates = WCD9335_RATES_MASK,
  10298. .formats = TASHA_FORMATS_S16_S24_LE,
  10299. .rate_max = 48000,
  10300. .rate_min = 8000,
  10301. .channels_min = 1,
  10302. .channels_max = 2,
  10303. },
  10304. .ops = &tasha_dai_ops,
  10305. },
  10306. {
  10307. .name = "tasha_rx4",
  10308. .id = AIF4_PB,
  10309. .playback = {
  10310. .stream_name = "AIF4 Playback",
  10311. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10312. .formats = TASHA_FORMATS_S16_S24_LE,
  10313. .rate_min = 8000,
  10314. .rate_max = 192000,
  10315. .channels_min = 1,
  10316. .channels_max = 2,
  10317. },
  10318. .ops = &tasha_dai_ops,
  10319. },
  10320. {
  10321. .name = "tasha_mix_rx1",
  10322. .id = AIF_MIX1_PB,
  10323. .playback = {
  10324. .stream_name = "AIF Mix Playback",
  10325. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10326. .formats = TASHA_FORMATS_S16_S24_LE,
  10327. .rate_min = 8000,
  10328. .rate_max = 192000,
  10329. .channels_min = 1,
  10330. .channels_max = 8,
  10331. },
  10332. .ops = &tasha_dai_ops,
  10333. },
  10334. {
  10335. .name = "tasha_mad1",
  10336. .id = AIF4_MAD_TX,
  10337. .capture = {
  10338. .stream_name = "AIF4 MAD TX",
  10339. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10340. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_384000,
  10341. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10342. .rate_min = 16000,
  10343. .rate_max = 384000,
  10344. .channels_min = 1,
  10345. .channels_max = 1,
  10346. },
  10347. .ops = &tasha_dai_ops,
  10348. },
  10349. {
  10350. .name = "tasha_vifeedback",
  10351. .id = AIF4_VIFEED,
  10352. .capture = {
  10353. .stream_name = "VIfeed",
  10354. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
  10355. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10356. .rate_max = 48000,
  10357. .rate_min = 8000,
  10358. .channels_min = 1,
  10359. .channels_max = 4,
  10360. },
  10361. .ops = &tasha_dai_ops,
  10362. },
  10363. {
  10364. .name = "tasha_cpe",
  10365. .id = AIF5_CPE_TX,
  10366. .capture = {
  10367. .stream_name = "AIF5 CPE TX",
  10368. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000,
  10369. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10370. .rate_min = 16000,
  10371. .rate_max = 48000,
  10372. .channels_min = 1,
  10373. .channels_max = 1,
  10374. },
  10375. },
  10376. };
  10377. static struct snd_soc_dai_driver tasha_i2s_dai[] = {
  10378. {
  10379. .name = "tasha_i2s_rx1",
  10380. .id = AIF1_PB,
  10381. .playback = {
  10382. .stream_name = "AIF1 Playback",
  10383. .rates = WCD9335_RATES_MASK,
  10384. .formats = TASHA_FORMATS_S16_S24_LE,
  10385. .rate_max = 192000,
  10386. .rate_min = 8000,
  10387. .channels_min = 1,
  10388. .channels_max = 2,
  10389. },
  10390. .ops = &tasha_dai_ops,
  10391. },
  10392. {
  10393. .name = "tasha_i2s_tx1",
  10394. .id = AIF1_CAP,
  10395. .capture = {
  10396. .stream_name = "AIF1 Capture",
  10397. .rates = WCD9335_RATES_MASK,
  10398. .formats = TASHA_FORMATS_S16_S24_LE,
  10399. .rate_max = 192000,
  10400. .rate_min = 8000,
  10401. .channels_min = 1,
  10402. .channels_max = 4,
  10403. },
  10404. .ops = &tasha_dai_ops,
  10405. },
  10406. {
  10407. .name = "tasha_i2s_rx2",
  10408. .id = AIF2_PB,
  10409. .playback = {
  10410. .stream_name = "AIF2 Playback",
  10411. .rates = WCD9335_RATES_MASK,
  10412. .formats = TASHA_FORMATS_S16_S24_LE,
  10413. .rate_max = 192000,
  10414. .rate_min = 8000,
  10415. .channels_min = 1,
  10416. .channels_max = 2,
  10417. },
  10418. .ops = &tasha_dai_ops,
  10419. },
  10420. {
  10421. .name = "tasha_i2s_tx2",
  10422. .id = AIF2_CAP,
  10423. .capture = {
  10424. .stream_name = "AIF2 Capture",
  10425. .rates = WCD9335_RATES_MASK,
  10426. .formats = TASHA_FORMATS_S16_S24_LE,
  10427. .rate_max = 192000,
  10428. .rate_min = 8000,
  10429. .channels_min = 1,
  10430. .channels_max = 4,
  10431. },
  10432. .ops = &tasha_dai_ops,
  10433. },
  10434. {
  10435. .name = "tasha_mad1",
  10436. .id = AIF4_MAD_TX,
  10437. .capture = {
  10438. .stream_name = "AIF4 MAD TX",
  10439. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10440. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_384000,
  10441. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10442. .rate_min = 16000,
  10443. .rate_max = 384000,
  10444. .channels_min = 1,
  10445. .channels_max = 1,
  10446. },
  10447. .ops = &tasha_dai_ops,
  10448. },
  10449. };
  10450. static void tasha_codec_power_gate_digital_core(struct tasha_priv *tasha)
  10451. {
  10452. struct snd_soc_codec *codec = tasha->codec;
  10453. if (!codec)
  10454. return;
  10455. mutex_lock(&tasha->power_lock);
  10456. dev_dbg(codec->dev, "%s: Entering power gating function, %d\n",
  10457. __func__, tasha->power_active_ref);
  10458. if (tasha->power_active_ref > 0)
  10459. goto exit;
  10460. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10461. WCD_REGION_POWER_COLLAPSE_BEGIN,
  10462. WCD9XXX_DIG_CORE_REGION_1);
  10463. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10464. 0x04, 0x04);
  10465. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10466. 0x01, 0x00);
  10467. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10468. 0x02, 0x00);
  10469. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10470. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  10471. wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_DOWN,
  10472. WCD9XXX_DIG_CORE_REGION_1);
  10473. exit:
  10474. dev_dbg(codec->dev, "%s: Exiting power gating function, %d\n",
  10475. __func__, tasha->power_active_ref);
  10476. mutex_unlock(&tasha->power_lock);
  10477. }
  10478. static void tasha_codec_power_gate_work(struct work_struct *work)
  10479. {
  10480. struct tasha_priv *tasha;
  10481. struct delayed_work *dwork;
  10482. struct snd_soc_codec *codec;
  10483. dwork = to_delayed_work(work);
  10484. tasha = container_of(dwork, struct tasha_priv, power_gate_work);
  10485. codec = tasha->codec;
  10486. if (!codec)
  10487. return;
  10488. tasha_codec_power_gate_digital_core(tasha);
  10489. }
  10490. /* called under power_lock acquisition */
  10491. static int tasha_dig_core_remove_power_collapse(struct snd_soc_codec *codec)
  10492. {
  10493. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10494. tasha_codec_vote_max_bw(codec, true);
  10495. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5);
  10496. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7);
  10497. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3);
  10498. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x00);
  10499. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x02);
  10500. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10501. WCD_REGION_POWER_COLLAPSE_REMOVE,
  10502. WCD9XXX_DIG_CORE_REGION_1);
  10503. regcache_mark_dirty(codec->component.regmap);
  10504. regcache_sync_region(codec->component.regmap,
  10505. TASHA_DIG_CORE_REG_MIN, TASHA_DIG_CORE_REG_MAX);
  10506. tasha_codec_vote_max_bw(codec, false);
  10507. return 0;
  10508. }
  10509. static int tasha_dig_core_power_collapse(struct tasha_priv *tasha,
  10510. int req_state)
  10511. {
  10512. struct snd_soc_codec *codec;
  10513. int cur_state;
  10514. /* Exit if feature is disabled */
  10515. if (!dig_core_collapse_enable)
  10516. return 0;
  10517. mutex_lock(&tasha->power_lock);
  10518. if (req_state == POWER_COLLAPSE)
  10519. tasha->power_active_ref--;
  10520. else if (req_state == POWER_RESUME)
  10521. tasha->power_active_ref++;
  10522. else
  10523. goto unlock_mutex;
  10524. if (tasha->power_active_ref < 0) {
  10525. dev_dbg(tasha->dev, "%s: power_active_ref is negative\n",
  10526. __func__);
  10527. goto unlock_mutex;
  10528. }
  10529. codec = tasha->codec;
  10530. if (!codec)
  10531. goto unlock_mutex;
  10532. if (req_state == POWER_COLLAPSE) {
  10533. if (tasha->power_active_ref == 0) {
  10534. schedule_delayed_work(&tasha->power_gate_work,
  10535. msecs_to_jiffies(dig_core_collapse_timer * 1000));
  10536. }
  10537. } else if (req_state == POWER_RESUME) {
  10538. if (tasha->power_active_ref == 1) {
  10539. /*
  10540. * At this point, there can be two cases:
  10541. * 1. Core already in power collapse state
  10542. * 2. Timer kicked in and still did not expire or
  10543. * waiting for the power_lock
  10544. */
  10545. cur_state = wcd9xxx_get_current_power_state(
  10546. tasha->wcd9xxx,
  10547. WCD9XXX_DIG_CORE_REGION_1);
  10548. if (cur_state == WCD_REGION_POWER_DOWN)
  10549. tasha_dig_core_remove_power_collapse(codec);
  10550. else {
  10551. mutex_unlock(&tasha->power_lock);
  10552. cancel_delayed_work_sync(
  10553. &tasha->power_gate_work);
  10554. mutex_lock(&tasha->power_lock);
  10555. }
  10556. }
  10557. }
  10558. unlock_mutex:
  10559. mutex_unlock(&tasha->power_lock);
  10560. return 0;
  10561. }
  10562. static int __tasha_cdc_mclk_enable_locked(struct tasha_priv *tasha,
  10563. bool enable)
  10564. {
  10565. int ret = 0;
  10566. if (!tasha->wcd_ext_clk) {
  10567. dev_err(tasha->dev, "%s: wcd ext clock is NULL\n", __func__);
  10568. return -EINVAL;
  10569. }
  10570. dev_dbg(tasha->dev, "%s: mclk_enable = %u\n", __func__, enable);
  10571. if (enable) {
  10572. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10573. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10574. if (ret)
  10575. goto err;
  10576. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10577. tasha_codec_apply_sido_voltage(tasha,
  10578. SIDO_VOLTAGE_NOMINAL_MV);
  10579. } else {
  10580. if (!dig_core_collapse_enable) {
  10581. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10582. tasha_codec_update_sido_voltage(tasha,
  10583. sido_buck_svs_voltage);
  10584. }
  10585. tasha_cdc_req_mclk_enable(tasha, false);
  10586. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10587. }
  10588. err:
  10589. return ret;
  10590. }
  10591. static int __tasha_cdc_mclk_enable(struct tasha_priv *tasha,
  10592. bool enable)
  10593. {
  10594. int ret;
  10595. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10596. ret = __tasha_cdc_mclk_enable_locked(tasha, enable);
  10597. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10598. return ret;
  10599. }
  10600. int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10601. {
  10602. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10603. return __tasha_cdc_mclk_enable(tasha, enable);
  10604. }
  10605. EXPORT_SYMBOL(tasha_cdc_mclk_enable);
  10606. int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10607. {
  10608. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10609. int ret = 0;
  10610. dev_dbg(tasha->dev, "%s: clk_mode: %d, enable: %d, clk_internal: %d\n",
  10611. __func__, tasha->clk_mode, enable, tasha->clk_internal);
  10612. if (tasha->clk_mode || tasha->clk_internal) {
  10613. if (enable) {
  10614. tasha_cdc_sido_ccl_enable(tasha, true);
  10615. wcd_resmgr_enable_master_bias(tasha->resmgr);
  10616. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10617. snd_soc_update_bits(codec,
  10618. WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
  10619. 0x01, 0x01);
  10620. snd_soc_update_bits(codec,
  10621. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  10622. 0x01, 0x01);
  10623. set_bit(CPE_NOMINAL, &tasha->status_mask);
  10624. tasha_codec_update_sido_voltage(tasha,
  10625. SIDO_VOLTAGE_NOMINAL_MV);
  10626. tasha->clk_internal = true;
  10627. } else {
  10628. tasha->clk_internal = false;
  10629. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  10630. tasha_codec_update_sido_voltage(tasha,
  10631. sido_buck_svs_voltage);
  10632. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10633. wcd_resmgr_disable_master_bias(tasha->resmgr);
  10634. tasha_cdc_sido_ccl_enable(tasha, false);
  10635. }
  10636. } else {
  10637. ret = __tasha_cdc_mclk_enable(tasha, enable);
  10638. }
  10639. return ret;
  10640. }
  10641. EXPORT_SYMBOL(tasha_cdc_mclk_tx_enable);
  10642. static ssize_t tasha_codec_version_read(struct snd_info_entry *entry,
  10643. void *file_private_data, struct file *file,
  10644. char __user *buf, size_t count, loff_t pos)
  10645. {
  10646. struct tasha_priv *tasha;
  10647. struct wcd9xxx *wcd9xxx;
  10648. char buffer[TASHA_VERSION_ENTRY_SIZE];
  10649. int len = 0;
  10650. tasha = (struct tasha_priv *) entry->private_data;
  10651. if (!tasha) {
  10652. pr_err("%s: tasha priv is null\n", __func__);
  10653. return -EINVAL;
  10654. }
  10655. wcd9xxx = tasha->wcd9xxx;
  10656. if (wcd9xxx->codec_type->id_major == TASHA_MAJOR) {
  10657. if (TASHA_IS_1_0(wcd9xxx))
  10658. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_0\n");
  10659. else if (TASHA_IS_1_1(wcd9xxx))
  10660. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_1\n");
  10661. else
  10662. snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10663. } else if (wcd9xxx->codec_type->id_major == TASHA2P0_MAJOR) {
  10664. len = snprintf(buffer, sizeof(buffer), "WCD9335_2_0\n");
  10665. } else
  10666. len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10667. return simple_read_from_buffer(buf, count, &pos, buffer, len);
  10668. }
  10669. static struct snd_info_entry_ops tasha_codec_info_ops = {
  10670. .read = tasha_codec_version_read,
  10671. };
  10672. /*
  10673. * tasha_codec_info_create_codec_entry - creates wcd9335 module
  10674. * @codec_root: The parent directory
  10675. * @codec: Codec instance
  10676. *
  10677. * Creates wcd9335 module and version entry under the given
  10678. * parent directory.
  10679. *
  10680. * Return: 0 on success or negative error code on failure.
  10681. */
  10682. int tasha_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
  10683. struct snd_soc_codec *codec)
  10684. {
  10685. struct snd_info_entry *version_entry;
  10686. struct tasha_priv *tasha;
  10687. struct snd_soc_card *card;
  10688. if (!codec_root || !codec)
  10689. return -EINVAL;
  10690. tasha = snd_soc_codec_get_drvdata(codec);
  10691. card = codec->component.card;
  10692. tasha->entry = snd_info_create_subdir(codec_root->module,
  10693. "tasha", codec_root);
  10694. if (!tasha->entry) {
  10695. dev_dbg(codec->dev, "%s: failed to create wcd9335 entry\n",
  10696. __func__);
  10697. return -ENOMEM;
  10698. }
  10699. version_entry = snd_info_create_card_entry(card->snd_card,
  10700. "version",
  10701. tasha->entry);
  10702. if (!version_entry) {
  10703. dev_dbg(codec->dev, "%s: failed to create wcd9335 version entry\n",
  10704. __func__);
  10705. return -ENOMEM;
  10706. }
  10707. version_entry->private_data = tasha;
  10708. version_entry->size = TASHA_VERSION_ENTRY_SIZE;
  10709. version_entry->content = SNDRV_INFO_CONTENT_DATA;
  10710. version_entry->c.ops = &tasha_codec_info_ops;
  10711. if (snd_info_register(version_entry) < 0) {
  10712. snd_info_free_entry(version_entry);
  10713. return -ENOMEM;
  10714. }
  10715. tasha->version_entry = version_entry;
  10716. return 0;
  10717. }
  10718. EXPORT_SYMBOL(tasha_codec_info_create_codec_entry);
  10719. static int __tasha_codec_internal_rco_ctrl(
  10720. struct snd_soc_codec *codec, bool enable)
  10721. {
  10722. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10723. int ret = 0;
  10724. if (enable) {
  10725. tasha_cdc_sido_ccl_enable(tasha, true);
  10726. if (wcd_resmgr_get_clk_type(tasha->resmgr) ==
  10727. WCD_CLK_RCO) {
  10728. ret = wcd_resmgr_enable_clk_block(tasha->resmgr,
  10729. WCD_CLK_RCO);
  10730. } else {
  10731. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10732. ret |= wcd_resmgr_enable_clk_block(tasha->resmgr,
  10733. WCD_CLK_RCO);
  10734. ret |= tasha_cdc_req_mclk_enable(tasha, false);
  10735. }
  10736. } else {
  10737. ret = wcd_resmgr_disable_clk_block(tasha->resmgr,
  10738. WCD_CLK_RCO);
  10739. tasha_cdc_sido_ccl_enable(tasha, false);
  10740. }
  10741. if (ret) {
  10742. dev_err(codec->dev, "%s: Error in %s RCO\n",
  10743. __func__, (enable ? "enabling" : "disabling"));
  10744. ret = -EINVAL;
  10745. }
  10746. return ret;
  10747. }
  10748. /*
  10749. * tasha_codec_internal_rco_ctrl()
  10750. * Make sure that the caller does not acquire
  10751. * BG_CLK_LOCK.
  10752. */
  10753. static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
  10754. bool enable)
  10755. {
  10756. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10757. int ret = 0;
  10758. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10759. ret = __tasha_codec_internal_rco_ctrl(codec, enable);
  10760. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10761. return ret;
  10762. }
  10763. /*
  10764. * tasha_mbhc_hs_detect: starts mbhc insertion/removal functionality
  10765. * @codec: handle to snd_soc_codec *
  10766. * @mbhc_cfg: handle to mbhc configuration structure
  10767. * return 0 if mbhc_start is success or error code in case of failure
  10768. */
  10769. int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
  10770. struct wcd_mbhc_config *mbhc_cfg)
  10771. {
  10772. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10773. return wcd_mbhc_start(&tasha->mbhc, mbhc_cfg);
  10774. }
  10775. EXPORT_SYMBOL(tasha_mbhc_hs_detect);
  10776. /*
  10777. * tasha_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
  10778. * @codec: handle to snd_soc_codec *
  10779. */
  10780. void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
  10781. {
  10782. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10783. wcd_mbhc_stop(&tasha->mbhc);
  10784. }
  10785. EXPORT_SYMBOL(tasha_mbhc_hs_detect_exit);
  10786. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv)
  10787. {
  10788. /* min micbias voltage is 1V and maximum is 2.85V */
  10789. if (micb_mv < 1000 || micb_mv > 2850) {
  10790. pr_err("%s: unsupported micbias voltage\n", __func__);
  10791. return -EINVAL;
  10792. }
  10793. return (micb_mv - 1000) / 50;
  10794. }
  10795. static const struct tasha_reg_mask_val tasha_reg_update_reset_val_1_1[] = {
  10796. {WCD9335_RCO_CTRL_2, 0xFF, 0x47},
  10797. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10798. };
  10799. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_1[] = {
  10800. {WCD9335_FLYBACK_VNEG_DAC_CTRL_1, 0xFF, 0x65},
  10801. {WCD9335_FLYBACK_VNEG_DAC_CTRL_2, 0xFF, 0x52},
  10802. {WCD9335_FLYBACK_VNEG_DAC_CTRL_3, 0xFF, 0xAF},
  10803. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10804. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0xF4},
  10805. {WCD9335_FLYBACK_VNEG_CTRL_9, 0xFF, 0x40},
  10806. {WCD9335_FLYBACK_VNEG_CTRL_2, 0xFF, 0x4F},
  10807. {WCD9335_FLYBACK_EN, 0xFF, 0x6E},
  10808. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xF8, 0xF8},
  10809. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xF8, 0xF8},
  10810. };
  10811. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_0[] = {
  10812. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0x54},
  10813. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xFC, 0xFC},
  10814. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xFC, 0xFC},
  10815. };
  10816. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_2_0[] = {
  10817. {WCD9335_RCO_CTRL_2, 0x0F, 0x08},
  10818. {WCD9335_RX_BIAS_FLYB_MID_RST, 0xF0, 0x10},
  10819. {WCD9335_FLYBACK_CTRL_1, 0x20, 0x20},
  10820. {WCD9335_HPH_OCP_CTL, 0xFF, 0x7A},
  10821. {WCD9335_HPH_L_TEST, 0x01, 0x01},
  10822. {WCD9335_HPH_R_TEST, 0x01, 0x01},
  10823. {WCD9335_CDC_BOOST0_BOOST_CFG1, 0x3F, 0x12},
  10824. {WCD9335_CDC_BOOST0_BOOST_CFG2, 0x1C, 0x08},
  10825. {WCD9335_CDC_COMPANDER7_CTL7, 0x1E, 0x18},
  10826. {WCD9335_CDC_BOOST1_BOOST_CFG1, 0x3F, 0x12},
  10827. {WCD9335_CDC_BOOST1_BOOST_CFG2, 0x1C, 0x08},
  10828. {WCD9335_CDC_COMPANDER8_CTL7, 0x1E, 0x18},
  10829. {WCD9335_CDC_TX0_TX_PATH_SEC7, 0xFF, 0x45},
  10830. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xFC, 0xF4},
  10831. {WCD9335_HPH_REFBUFF_LP_CTL, 0x08, 0x08},
  10832. {WCD9335_HPH_REFBUFF_LP_CTL, 0x06, 0x02},
  10833. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xA0},
  10834. {WCD9335_SE_LO_COM1, 0xFF, 0xC0},
  10835. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xFC, 0xF4},
  10836. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xFC, 0xF4},
  10837. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xFC, 0xF8},
  10838. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xFC, 0xF8},
  10839. };
  10840. static const struct tasha_reg_mask_val tasha_codec_reg_defaults[] = {
  10841. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x00},
  10842. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x01},
  10843. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x04, 0x04},
  10844. };
  10845. static const struct tasha_reg_mask_val tasha_codec_reg_i2c_defaults[] = {
  10846. {WCD9335_ANA_CLK_TOP, 0x20, 0x20},
  10847. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x01},
  10848. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x00},
  10849. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x05, 0x05},
  10850. {WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG, 0x01, 0x01},
  10851. {WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG, 0x01, 0x01},
  10852. {WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG, 0x01, 0x01},
  10853. {WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG, 0x01, 0x01},
  10854. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG, 0x05, 0x05},
  10855. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG, 0x05, 0x05},
  10856. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG, 0x05, 0x05},
  10857. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG, 0x05, 0x05},
  10858. };
  10859. static const struct tasha_reg_mask_val tasha_codec_reg_init_common_val[] = {
  10860. /* Rbuckfly/R_EAR(32) */
  10861. {WCD9335_CDC_CLSH_K2_MSB, 0x0F, 0x00},
  10862. {WCD9335_CDC_CLSH_K2_LSB, 0xFF, 0x60},
  10863. {WCD9335_CPE_SS_DMIC_CFG, 0x80, 0x00},
  10864. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x58},
  10865. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x58},
  10866. {WCD9335_CDC_RX7_RX_PATH_CFG1, 0x08, 0x08},
  10867. {WCD9335_CDC_RX8_RX_PATH_CFG1, 0x08, 0x08},
  10868. {WCD9335_ANA_LO_1_2, 0x3C, 0X3C},
  10869. {WCD9335_DIFF_LO_COM_SWCAP_REFBUF_FREQ, 0x70, 0x00},
  10870. {WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03, 0x03},
  10871. {WCD9335_CDC_TOP_TOP_CFG1, 0x02, 0x02},
  10872. {WCD9335_CDC_TOP_TOP_CFG1, 0x01, 0x01},
  10873. {WCD9335_EAR_CMBUFF, 0x08, 0x00},
  10874. {WCD9335_CDC_TX9_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10875. {WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10876. {WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10877. {WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10878. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  10879. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  10880. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  10881. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  10882. {WCD9335_CDC_RX0_RX_PATH_CFG0, 0x01, 0x01},
  10883. {WCD9335_CDC_RX1_RX_PATH_CFG0, 0x01, 0x01},
  10884. {WCD9335_CDC_RX2_RX_PATH_CFG0, 0x01, 0x01},
  10885. {WCD9335_CDC_RX3_RX_PATH_CFG0, 0x01, 0x01},
  10886. {WCD9335_CDC_RX4_RX_PATH_CFG0, 0x01, 0x01},
  10887. {WCD9335_CDC_RX5_RX_PATH_CFG0, 0x01, 0x01},
  10888. {WCD9335_CDC_RX6_RX_PATH_CFG0, 0x01, 0x01},
  10889. {WCD9335_CDC_RX7_RX_PATH_CFG0, 0x01, 0x01},
  10890. {WCD9335_CDC_RX8_RX_PATH_CFG0, 0x01, 0x01},
  10891. {WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 0x01, 0x01},
  10892. {WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 0x01, 0x01},
  10893. {WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 0x01, 0x01},
  10894. {WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 0x01, 0x01},
  10895. {WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 0x01, 0x01},
  10896. {WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 0x01, 0x01},
  10897. {WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 0x01, 0x01},
  10898. {WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 0x01, 0x01},
  10899. {WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 0x01, 0x01},
  10900. {WCD9335_VBADC_IBIAS_FE, 0x0C, 0x08},
  10901. };
  10902. static const struct tasha_reg_mask_val tasha_codec_reg_init_1_x_val[] = {
  10903. /* Enable TX HPF Filter & Linear Phase */
  10904. {WCD9335_CDC_TX0_TX_PATH_CFG0, 0x11, 0x11},
  10905. {WCD9335_CDC_TX1_TX_PATH_CFG0, 0x11, 0x11},
  10906. {WCD9335_CDC_TX2_TX_PATH_CFG0, 0x11, 0x11},
  10907. {WCD9335_CDC_TX3_TX_PATH_CFG0, 0x11, 0x11},
  10908. {WCD9335_CDC_TX4_TX_PATH_CFG0, 0x11, 0x11},
  10909. {WCD9335_CDC_TX5_TX_PATH_CFG0, 0x11, 0x11},
  10910. {WCD9335_CDC_TX6_TX_PATH_CFG0, 0x11, 0x11},
  10911. {WCD9335_CDC_TX7_TX_PATH_CFG0, 0x11, 0x11},
  10912. {WCD9335_CDC_TX8_TX_PATH_CFG0, 0x11, 0x11},
  10913. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xF8, 0xF8},
  10914. {WCD9335_CDC_RX0_RX_PATH_SEC1, 0x08, 0x08},
  10915. {WCD9335_CDC_RX1_RX_PATH_SEC1, 0x08, 0x08},
  10916. {WCD9335_CDC_RX2_RX_PATH_SEC1, 0x08, 0x08},
  10917. {WCD9335_CDC_RX3_RX_PATH_SEC1, 0x08, 0x08},
  10918. {WCD9335_CDC_RX4_RX_PATH_SEC1, 0x08, 0x08},
  10919. {WCD9335_CDC_RX5_RX_PATH_SEC1, 0x08, 0x08},
  10920. {WCD9335_CDC_RX6_RX_PATH_SEC1, 0x08, 0x08},
  10921. {WCD9335_CDC_RX7_RX_PATH_SEC1, 0x08, 0x08},
  10922. {WCD9335_CDC_RX8_RX_PATH_SEC1, 0x08, 0x08},
  10923. {WCD9335_CDC_RX0_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10924. {WCD9335_CDC_RX1_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10925. {WCD9335_CDC_RX2_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10926. {WCD9335_CDC_RX3_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10927. {WCD9335_CDC_RX4_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10928. {WCD9335_CDC_RX5_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10929. {WCD9335_CDC_RX6_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10930. {WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10931. {WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10932. {WCD9335_CDC_TX0_TX_PATH_SEC2, 0x01, 0x01},
  10933. {WCD9335_CDC_TX1_TX_PATH_SEC2, 0x01, 0x01},
  10934. {WCD9335_CDC_TX2_TX_PATH_SEC2, 0x01, 0x01},
  10935. {WCD9335_CDC_TX3_TX_PATH_SEC2, 0x01, 0x01},
  10936. {WCD9335_CDC_TX4_TX_PATH_SEC2, 0x01, 0x01},
  10937. {WCD9335_CDC_TX5_TX_PATH_SEC2, 0x01, 0x01},
  10938. {WCD9335_CDC_TX6_TX_PATH_SEC2, 0x01, 0x01},
  10939. {WCD9335_CDC_TX7_TX_PATH_SEC2, 0x01, 0x01},
  10940. {WCD9335_CDC_TX8_TX_PATH_SEC2, 0x01, 0x01},
  10941. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xF8, 0xF0},
  10942. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xF8, 0xF0},
  10943. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xF8, 0xF8},
  10944. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xF8, 0xF8},
  10945. {WCD9335_RX_OCP_COUNT, 0xFF, 0xFF},
  10946. {WCD9335_HPH_OCP_CTL, 0xF0, 0x70},
  10947. {WCD9335_CPE_SS_CPAR_CFG, 0xFF, 0x00},
  10948. {WCD9335_FLYBACK_VNEG_CTRL_1, 0xFF, 0x63},
  10949. {WCD9335_FLYBACK_VNEG_CTRL_4, 0xFF, 0x7F},
  10950. {WCD9335_CLASSH_CTRL_VCL_1, 0xFF, 0x60},
  10951. {WCD9335_CLASSH_CTRL_CCL_5, 0xFF, 0x40},
  10952. {WCD9335_RX_TIMER_DIV, 0xFF, 0x32},
  10953. {WCD9335_SE_LO_COM2, 0xFF, 0x01},
  10954. {WCD9335_MBHC_ZDET_ANA_CTL, 0x0F, 0x07},
  10955. {WCD9335_RX_BIAS_HPH_PA, 0xF0, 0x60},
  10956. {WCD9335_HPH_RDAC_LDO_CTL, 0x88, 0x88},
  10957. {WCD9335_HPH_L_EN, 0x20, 0x20},
  10958. {WCD9335_HPH_R_EN, 0x20, 0x20},
  10959. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xD8},
  10960. {WCD9335_CDC_RX5_RX_PATH_SEC3, 0xBD, 0xBD},
  10961. {WCD9335_CDC_RX6_RX_PATH_SEC3, 0xBD, 0xBD},
  10962. {WCD9335_DIFF_LO_COM_PA_FREQ, 0x70, 0x40},
  10963. };
  10964. static void tasha_update_reg_reset_values(struct snd_soc_codec *codec)
  10965. {
  10966. u32 i;
  10967. struct wcd9xxx *tasha_core = dev_get_drvdata(codec->dev->parent);
  10968. if (TASHA_IS_1_1(tasha_core)) {
  10969. for (i = 0; i < ARRAY_SIZE(tasha_reg_update_reset_val_1_1);
  10970. i++)
  10971. snd_soc_write(codec,
  10972. tasha_reg_update_reset_val_1_1[i].reg,
  10973. tasha_reg_update_reset_val_1_1[i].val);
  10974. }
  10975. }
  10976. static void tasha_codec_init_reg(struct snd_soc_codec *codec)
  10977. {
  10978. u32 i;
  10979. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  10980. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_common_val); i++)
  10981. snd_soc_update_bits(codec,
  10982. tasha_codec_reg_init_common_val[i].reg,
  10983. tasha_codec_reg_init_common_val[i].mask,
  10984. tasha_codec_reg_init_common_val[i].val);
  10985. if (TASHA_IS_1_1(wcd9xxx) ||
  10986. TASHA_IS_1_0(wcd9xxx))
  10987. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_1_x_val); i++)
  10988. snd_soc_update_bits(codec,
  10989. tasha_codec_reg_init_1_x_val[i].reg,
  10990. tasha_codec_reg_init_1_x_val[i].mask,
  10991. tasha_codec_reg_init_1_x_val[i].val);
  10992. if (TASHA_IS_1_1(wcd9xxx)) {
  10993. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_1); i++)
  10994. snd_soc_update_bits(codec,
  10995. tasha_codec_reg_init_val_1_1[i].reg,
  10996. tasha_codec_reg_init_val_1_1[i].mask,
  10997. tasha_codec_reg_init_val_1_1[i].val);
  10998. } else if (TASHA_IS_1_0(wcd9xxx)) {
  10999. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_0); i++)
  11000. snd_soc_update_bits(codec,
  11001. tasha_codec_reg_init_val_1_0[i].reg,
  11002. tasha_codec_reg_init_val_1_0[i].mask,
  11003. tasha_codec_reg_init_val_1_0[i].val);
  11004. } else if (TASHA_IS_2_0(wcd9xxx)) {
  11005. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_2_0); i++)
  11006. snd_soc_update_bits(codec,
  11007. tasha_codec_reg_init_val_2_0[i].reg,
  11008. tasha_codec_reg_init_val_2_0[i].mask,
  11009. tasha_codec_reg_init_val_2_0[i].val);
  11010. }
  11011. }
  11012. static void tasha_update_reg_defaults(struct tasha_priv *tasha)
  11013. {
  11014. u32 i;
  11015. struct wcd9xxx *wcd9xxx;
  11016. wcd9xxx = tasha->wcd9xxx;
  11017. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_defaults); i++)
  11018. regmap_update_bits(wcd9xxx->regmap,
  11019. tasha_codec_reg_defaults[i].reg,
  11020. tasha_codec_reg_defaults[i].mask,
  11021. tasha_codec_reg_defaults[i].val);
  11022. tasha->intf_type = wcd9xxx_get_intf_type();
  11023. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  11024. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_i2c_defaults); i++)
  11025. regmap_update_bits(wcd9xxx->regmap,
  11026. tasha_codec_reg_i2c_defaults[i].reg,
  11027. tasha_codec_reg_i2c_defaults[i].mask,
  11028. tasha_codec_reg_i2c_defaults[i].val);
  11029. }
  11030. static void tasha_slim_interface_init_reg(struct snd_soc_codec *codec)
  11031. {
  11032. int i;
  11033. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11034. for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++)
  11035. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11036. TASHA_SLIM_PGD_PORT_INT_EN0 + i,
  11037. 0xFF);
  11038. }
  11039. static irqreturn_t tasha_slimbus_irq(int irq, void *data)
  11040. {
  11041. struct tasha_priv *priv = data;
  11042. unsigned long status = 0;
  11043. int i, j, port_id, k;
  11044. u32 bit;
  11045. u8 val, int_val = 0;
  11046. bool tx, cleared;
  11047. unsigned short reg = 0;
  11048. for (i = TASHA_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
  11049. i <= TASHA_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
  11050. val = wcd9xxx_interface_reg_read(priv->wcd9xxx, i);
  11051. status |= ((u32)val << (8 * j));
  11052. }
  11053. for_each_set_bit(j, &status, 32) {
  11054. tx = (j >= 16 ? true : false);
  11055. port_id = (tx ? j - 16 : j);
  11056. val = wcd9xxx_interface_reg_read(priv->wcd9xxx,
  11057. TASHA_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
  11058. if (val) {
  11059. if (!tx)
  11060. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  11061. (port_id / 8);
  11062. else
  11063. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  11064. (port_id / 8);
  11065. int_val = wcd9xxx_interface_reg_read(
  11066. priv->wcd9xxx, reg);
  11067. /*
  11068. * Ignore interrupts for ports for which the
  11069. * interrupts are not specifically enabled.
  11070. */
  11071. if (!(int_val & (1 << (port_id % 8))))
  11072. continue;
  11073. }
  11074. if (val & TASHA_SLIM_IRQ_OVERFLOW)
  11075. pr_err_ratelimited(
  11076. "%s: overflow error on %s port %d, value %x\n",
  11077. __func__, (tx ? "TX" : "RX"), port_id, val);
  11078. if (val & TASHA_SLIM_IRQ_UNDERFLOW)
  11079. pr_err_ratelimited(
  11080. "%s: underflow error on %s port %d, value %x\n",
  11081. __func__, (tx ? "TX" : "RX"), port_id, val);
  11082. if ((val & TASHA_SLIM_IRQ_OVERFLOW) ||
  11083. (val & TASHA_SLIM_IRQ_UNDERFLOW)) {
  11084. if (!tx)
  11085. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  11086. (port_id / 8);
  11087. else
  11088. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  11089. (port_id / 8);
  11090. int_val = wcd9xxx_interface_reg_read(
  11091. priv->wcd9xxx, reg);
  11092. if (int_val & (1 << (port_id % 8))) {
  11093. int_val = int_val ^ (1 << (port_id % 8));
  11094. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11095. reg, int_val);
  11096. }
  11097. }
  11098. if (val & TASHA_SLIM_IRQ_PORT_CLOSED) {
  11099. /*
  11100. * INT SOURCE register starts from RX to TX
  11101. * but port number in the ch_mask is in opposite way
  11102. */
  11103. bit = (tx ? j - 16 : j + 16);
  11104. pr_debug("%s: %s port %d closed value %x, bit %u\n",
  11105. __func__, (tx ? "TX" : "RX"), port_id, val,
  11106. bit);
  11107. for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) {
  11108. pr_debug("%s: priv->dai[%d].ch_mask = 0x%lx\n",
  11109. __func__, k, priv->dai[k].ch_mask);
  11110. if (test_and_clear_bit(bit,
  11111. &priv->dai[k].ch_mask)) {
  11112. cleared = true;
  11113. if (!priv->dai[k].ch_mask)
  11114. wake_up(&priv->dai[k].dai_wait);
  11115. /*
  11116. * There are cases when multiple DAIs
  11117. * might be using the same slimbus
  11118. * channel. Hence don't break here.
  11119. */
  11120. }
  11121. }
  11122. WARN(!cleared,
  11123. "Couldn't find slimbus %s port %d for closing\n",
  11124. (tx ? "TX" : "RX"), port_id);
  11125. }
  11126. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11127. TASHA_SLIM_PGD_PORT_INT_CLR_RX_0 +
  11128. (j / 8),
  11129. 1 << (j % 8));
  11130. }
  11131. return IRQ_HANDLED;
  11132. }
  11133. static int tasha_setup_irqs(struct tasha_priv *tasha)
  11134. {
  11135. int ret = 0;
  11136. struct snd_soc_codec *codec = tasha->codec;
  11137. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11138. struct wcd9xxx_core_resource *core_res =
  11139. &wcd9xxx->core_res;
  11140. ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS,
  11141. tasha_slimbus_irq, "SLIMBUS Slave", tasha);
  11142. if (ret)
  11143. pr_err("%s: Failed to request irq %d\n", __func__,
  11144. WCD9XXX_IRQ_SLIMBUS);
  11145. else
  11146. tasha_slim_interface_init_reg(codec);
  11147. return ret;
  11148. }
  11149. static void tasha_init_slim_slave_cfg(struct snd_soc_codec *codec)
  11150. {
  11151. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11152. struct afe_param_cdc_slimbus_slave_cfg *cfg;
  11153. struct wcd9xxx *wcd9xxx = priv->wcd9xxx;
  11154. uint64_t eaddr = 0;
  11155. cfg = &priv->slimbus_slave_cfg;
  11156. cfg->minor_version = 1;
  11157. cfg->tx_slave_port_offset = 0;
  11158. cfg->rx_slave_port_offset = 16;
  11159. memcpy(&eaddr, &wcd9xxx->slim->e_addr, sizeof(wcd9xxx->slim->e_addr));
  11160. WARN_ON(sizeof(wcd9xxx->slim->e_addr) != 6);
  11161. cfg->device_enum_addr_lsw = eaddr & 0xFFFFFFFF;
  11162. cfg->device_enum_addr_msw = eaddr >> 32;
  11163. dev_dbg(codec->dev, "%s: slimbus logical address 0x%llx\n",
  11164. __func__, eaddr);
  11165. }
  11166. static void tasha_cleanup_irqs(struct tasha_priv *tasha)
  11167. {
  11168. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11169. struct wcd9xxx_core_resource *core_res =
  11170. &wcd9xxx->core_res;
  11171. wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tasha);
  11172. }
  11173. static int tasha_handle_pdata(struct tasha_priv *tasha,
  11174. struct wcd9xxx_pdata *pdata)
  11175. {
  11176. struct snd_soc_codec *codec = tasha->codec;
  11177. u8 dmic_ctl_val, mad_dmic_ctl_val;
  11178. u8 anc_ctl_value;
  11179. u32 def_dmic_rate, dmic_clk_drv;
  11180. int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4;
  11181. int rc = 0;
  11182. if (!pdata) {
  11183. dev_err(codec->dev, "%s: NULL pdata\n", __func__);
  11184. return -ENODEV;
  11185. }
  11186. /* set micbias voltage */
  11187. vout_ctl_1 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb1_mv);
  11188. vout_ctl_2 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb2_mv);
  11189. vout_ctl_3 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb3_mv);
  11190. vout_ctl_4 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb4_mv);
  11191. if (vout_ctl_1 < 0 || vout_ctl_2 < 0 ||
  11192. vout_ctl_3 < 0 || vout_ctl_4 < 0) {
  11193. rc = -EINVAL;
  11194. goto done;
  11195. }
  11196. snd_soc_update_bits(codec, WCD9335_ANA_MICB1, 0x3F, vout_ctl_1);
  11197. snd_soc_update_bits(codec, WCD9335_ANA_MICB2, 0x3F, vout_ctl_2);
  11198. snd_soc_update_bits(codec, WCD9335_ANA_MICB3, 0x3F, vout_ctl_3);
  11199. snd_soc_update_bits(codec, WCD9335_ANA_MICB4, 0x3F, vout_ctl_4);
  11200. /* Set the DMIC sample rate */
  11201. switch (pdata->mclk_rate) {
  11202. case TASHA_MCLK_CLK_9P6MHZ:
  11203. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  11204. break;
  11205. case TASHA_MCLK_CLK_12P288MHZ:
  11206. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ;
  11207. break;
  11208. default:
  11209. /* should never happen */
  11210. dev_err(codec->dev, "%s: Invalid mclk_rate %d\n",
  11211. __func__, pdata->mclk_rate);
  11212. rc = -EINVAL;
  11213. goto done;
  11214. };
  11215. if (pdata->dmic_sample_rate ==
  11216. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11217. dev_info(codec->dev, "%s: dmic_rate invalid default = %d\n",
  11218. __func__, def_dmic_rate);
  11219. pdata->dmic_sample_rate = def_dmic_rate;
  11220. }
  11221. if (pdata->mad_dmic_sample_rate ==
  11222. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11223. dev_info(codec->dev, "%s: mad_dmic_rate invalid default = %d\n",
  11224. __func__, def_dmic_rate);
  11225. /*
  11226. * use dmic_sample_rate as the default for MAD
  11227. * if mad dmic sample rate is undefined
  11228. */
  11229. pdata->mad_dmic_sample_rate = pdata->dmic_sample_rate;
  11230. }
  11231. if (pdata->ecpp_dmic_sample_rate ==
  11232. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11233. dev_info(codec->dev,
  11234. "%s: ecpp_dmic_rate invalid default = %d\n",
  11235. __func__, def_dmic_rate);
  11236. /*
  11237. * use dmic_sample_rate as the default for ECPP DMIC
  11238. * if ecpp dmic sample rate is undefined
  11239. */
  11240. pdata->ecpp_dmic_sample_rate = pdata->dmic_sample_rate;
  11241. }
  11242. if (pdata->dmic_clk_drv ==
  11243. WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED) {
  11244. pdata->dmic_clk_drv = WCD9335_DMIC_CLK_DRIVE_DEFAULT;
  11245. dev_info(codec->dev,
  11246. "%s: dmic_clk_strength invalid, default = %d\n",
  11247. __func__, pdata->dmic_clk_drv);
  11248. }
  11249. switch (pdata->dmic_clk_drv) {
  11250. case 2:
  11251. dmic_clk_drv = 0;
  11252. break;
  11253. case 4:
  11254. dmic_clk_drv = 1;
  11255. break;
  11256. case 8:
  11257. dmic_clk_drv = 2;
  11258. break;
  11259. case 16:
  11260. dmic_clk_drv = 3;
  11261. break;
  11262. default:
  11263. dev_err(codec->dev,
  11264. "%s: invalid dmic_clk_drv %d, using default\n",
  11265. __func__, pdata->dmic_clk_drv);
  11266. dmic_clk_drv = 0;
  11267. break;
  11268. }
  11269. snd_soc_update_bits(codec, WCD9335_TEST_DEBUG_PAD_DRVCTL,
  11270. 0x0C, dmic_clk_drv << 2);
  11271. /*
  11272. * Default the DMIC clk rates to mad_dmic_sample_rate,
  11273. * whereas, the anc/txfe dmic rates to dmic_sample_rate
  11274. * since the anc/txfe are independent of mad block.
  11275. */
  11276. mad_dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11277. pdata->mclk_rate,
  11278. pdata->mad_dmic_sample_rate);
  11279. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC0_CTL,
  11280. 0x0E, mad_dmic_ctl_val << 1);
  11281. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC1_CTL,
  11282. 0x0E, mad_dmic_ctl_val << 1);
  11283. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC2_CTL,
  11284. 0x0E, mad_dmic_ctl_val << 1);
  11285. dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11286. pdata->mclk_rate,
  11287. pdata->dmic_sample_rate);
  11288. if (dmic_ctl_val == WCD9335_DMIC_CLK_DIV_2)
  11289. anc_ctl_value = WCD9335_ANC_DMIC_X2_FULL_RATE;
  11290. else
  11291. anc_ctl_value = WCD9335_ANC_DMIC_X2_HALF_RATE;
  11292. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11293. 0x40, anc_ctl_value << 6);
  11294. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11295. 0x20, anc_ctl_value << 5);
  11296. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11297. 0x40, anc_ctl_value << 6);
  11298. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11299. 0x20, anc_ctl_value << 5);
  11300. done:
  11301. return rc;
  11302. }
  11303. static struct wcd_cpe_core *tasha_codec_get_cpe_core(
  11304. struct snd_soc_codec *codec)
  11305. {
  11306. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11307. return priv->cpe_core;
  11308. }
  11309. static int tasha_codec_cpe_fll_update_divider(
  11310. struct snd_soc_codec *codec, u32 cpe_fll_rate)
  11311. {
  11312. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11313. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11314. u32 div_val = 0, l_val = 0;
  11315. u32 computed_cpe_fll;
  11316. if (cpe_fll_rate != CPE_FLL_CLK_75MHZ &&
  11317. cpe_fll_rate != CPE_FLL_CLK_150MHZ) {
  11318. dev_err(codec->dev,
  11319. "%s: Invalid CPE fll rate request %u\n",
  11320. __func__, cpe_fll_rate);
  11321. return -EINVAL;
  11322. }
  11323. if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_12P288MHZ) {
  11324. /* update divider to 10 and enable 5x divider */
  11325. snd_soc_write(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11326. 0x55);
  11327. div_val = 10;
  11328. } else if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_9P6MHZ) {
  11329. /* update divider to 8 and enable 2x divider */
  11330. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11331. 0x7C, 0x70);
  11332. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11333. 0xE0, 0x20);
  11334. div_val = 8;
  11335. } else {
  11336. dev_err(codec->dev,
  11337. "%s: Invalid MCLK rate %u\n",
  11338. __func__, wcd9xxx->mclk_rate);
  11339. return -EINVAL;
  11340. }
  11341. l_val = ((cpe_fll_rate / 1000) * div_val) /
  11342. (wcd9xxx->mclk_rate / 1000);
  11343. /* If l_val was integer truncated, increment l_val once */
  11344. computed_cpe_fll = (wcd9xxx->mclk_rate / div_val) * l_val;
  11345. if (computed_cpe_fll < cpe_fll_rate)
  11346. l_val++;
  11347. /* update L value LSB and MSB */
  11348. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_0,
  11349. (l_val & 0xFF));
  11350. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_1,
  11351. ((l_val >> 8) & 0xFF));
  11352. tasha->current_cpe_clk_freq = cpe_fll_rate;
  11353. dev_dbg(codec->dev,
  11354. "%s: updated l_val to %u for cpe_clk %u and mclk %u\n",
  11355. __func__, l_val, cpe_fll_rate, wcd9xxx->mclk_rate);
  11356. return 0;
  11357. }
  11358. static int __tasha_cdc_change_cpe_clk(struct snd_soc_codec *codec,
  11359. u32 clk_freq)
  11360. {
  11361. int ret = 0;
  11362. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11363. if (!tasha_cdc_is_svs_enabled(tasha)) {
  11364. dev_dbg(codec->dev,
  11365. "%s: SVS not enabled or tasha is not 2p0, return\n",
  11366. __func__);
  11367. return 0;
  11368. }
  11369. dev_dbg(codec->dev, "%s: clk_freq = %u\n", __func__, clk_freq);
  11370. if (clk_freq == CPE_FLL_CLK_75MHZ) {
  11371. /* Change to SVS */
  11372. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11373. 0x08, 0x08);
  11374. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11375. ret = -EINVAL;
  11376. goto done;
  11377. }
  11378. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11379. 0x10, 0x10);
  11380. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  11381. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  11382. } else if (clk_freq == CPE_FLL_CLK_150MHZ) {
  11383. /* change to nominal */
  11384. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11385. 0x08, 0x08);
  11386. set_bit(CPE_NOMINAL, &tasha->status_mask);
  11387. tasha_codec_update_sido_voltage(tasha, SIDO_VOLTAGE_NOMINAL_MV);
  11388. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11389. ret = -EINVAL;
  11390. goto done;
  11391. }
  11392. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11393. 0x10, 0x10);
  11394. } else {
  11395. dev_err(codec->dev,
  11396. "%s: Invalid clk_freq request %d for CPE FLL\n",
  11397. __func__, clk_freq);
  11398. ret = -EINVAL;
  11399. }
  11400. done:
  11401. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11402. 0x10, 0x00);
  11403. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11404. 0x08, 0x00);
  11405. return ret;
  11406. }
  11407. static int tasha_codec_cpe_fll_enable(struct snd_soc_codec *codec,
  11408. bool enable)
  11409. {
  11410. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11411. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11412. u8 clk_sel_reg_val = 0x00;
  11413. dev_dbg(codec->dev, "%s: enable = %s\n",
  11414. __func__, enable ? "true" : "false");
  11415. if (enable) {
  11416. if (tasha_cdc_is_svs_enabled(tasha)) {
  11417. /* FLL enable is always at SVS */
  11418. if (__tasha_cdc_change_cpe_clk(codec,
  11419. CPE_FLL_CLK_75MHZ)) {
  11420. dev_err(codec->dev,
  11421. "%s: clk change to %d failed\n",
  11422. __func__, CPE_FLL_CLK_75MHZ);
  11423. return -EINVAL;
  11424. }
  11425. } else {
  11426. if (tasha_codec_cpe_fll_update_divider(codec,
  11427. CPE_FLL_CLK_75MHZ)) {
  11428. dev_err(codec->dev,
  11429. "%s: clk change to %d failed\n",
  11430. __func__, CPE_FLL_CLK_75MHZ);
  11431. return -EINVAL;
  11432. }
  11433. }
  11434. if (TASHA_IS_1_0(wcd9xxx)) {
  11435. tasha_cdc_mclk_enable(codec, true, false);
  11436. clk_sel_reg_val = 0x02;
  11437. }
  11438. /* Setup CPE reference clk */
  11439. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11440. 0x02, clk_sel_reg_val);
  11441. /* enable CPE FLL reference clk */
  11442. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11443. 0x01, 0x01);
  11444. /* program the PLL */
  11445. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11446. 0x01, 0x01);
  11447. /* TEST clk setting */
  11448. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11449. 0x80, 0x80);
  11450. /* set FLL mode to HW controlled */
  11451. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11452. 0x60, 0x00);
  11453. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x80);
  11454. } else {
  11455. /* disable CPE FLL reference clk */
  11456. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11457. 0x01, 0x00);
  11458. /* undo TEST clk setting */
  11459. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11460. 0x80, 0x00);
  11461. /* undo FLL mode to HW control */
  11462. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x00);
  11463. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11464. 0x60, 0x20);
  11465. /* undo the PLL */
  11466. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11467. 0x01, 0x00);
  11468. if (TASHA_IS_1_0(wcd9xxx))
  11469. tasha_cdc_mclk_enable(codec, false, false);
  11470. /*
  11471. * FLL could get disabled while at nominal,
  11472. * scale it back to SVS
  11473. */
  11474. if (tasha_cdc_is_svs_enabled(tasha))
  11475. __tasha_cdc_change_cpe_clk(codec,
  11476. CPE_FLL_CLK_75MHZ);
  11477. }
  11478. return 0;
  11479. }
  11480. static void tasha_cdc_query_cpe_clk_plan(void *data,
  11481. struct cpe_svc_cfg_clk_plan *clk_freq)
  11482. {
  11483. struct snd_soc_codec *codec = data;
  11484. struct tasha_priv *tasha;
  11485. u32 cpe_clk_khz;
  11486. if (!codec) {
  11487. pr_err("%s: Invalid codec handle\n",
  11488. __func__);
  11489. return;
  11490. }
  11491. tasha = snd_soc_codec_get_drvdata(codec);
  11492. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11493. dev_dbg(codec->dev,
  11494. "%s: current_clk_freq = %u\n",
  11495. __func__, tasha->current_cpe_clk_freq);
  11496. clk_freq->current_clk_feq = cpe_clk_khz;
  11497. clk_freq->num_clk_freqs = 2;
  11498. if (tasha_cdc_is_svs_enabled(tasha)) {
  11499. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ / 1000;
  11500. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ / 1000;
  11501. } else {
  11502. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ;
  11503. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ;
  11504. }
  11505. }
  11506. static void tasha_cdc_change_cpe_clk(void *data,
  11507. u32 clk_freq)
  11508. {
  11509. struct snd_soc_codec *codec = data;
  11510. struct tasha_priv *tasha;
  11511. u32 cpe_clk_khz, req_freq = 0;
  11512. if (!codec) {
  11513. pr_err("%s: Invalid codec handle\n",
  11514. __func__);
  11515. return;
  11516. }
  11517. tasha = snd_soc_codec_get_drvdata(codec);
  11518. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11519. if (tasha_cdc_is_svs_enabled(tasha)) {
  11520. if ((clk_freq * 1000) <= CPE_FLL_CLK_75MHZ)
  11521. req_freq = CPE_FLL_CLK_75MHZ;
  11522. else
  11523. req_freq = CPE_FLL_CLK_150MHZ;
  11524. }
  11525. dev_dbg(codec->dev,
  11526. "%s: requested clk_freq = %u, current clk_freq = %u\n",
  11527. __func__, clk_freq * 1000,
  11528. tasha->current_cpe_clk_freq);
  11529. if (tasha_cdc_is_svs_enabled(tasha)) {
  11530. if (__tasha_cdc_change_cpe_clk(codec, req_freq))
  11531. dev_err(codec->dev,
  11532. "%s: clock/voltage scaling failed\n",
  11533. __func__);
  11534. }
  11535. }
  11536. static int tasha_codec_slim_reserve_bw(struct snd_soc_codec *codec,
  11537. u32 bw_ops, bool commit)
  11538. {
  11539. struct wcd9xxx *wcd9xxx;
  11540. if (!codec) {
  11541. pr_err("%s: Invalid handle to codec\n",
  11542. __func__);
  11543. return -EINVAL;
  11544. }
  11545. wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11546. if (!wcd9xxx) {
  11547. dev_err(codec->dev, "%s: Invalid parent drv_data\n",
  11548. __func__);
  11549. return -EINVAL;
  11550. }
  11551. return wcd9xxx_slim_reserve_bw(wcd9xxx, bw_ops, commit);
  11552. }
  11553. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  11554. bool vote)
  11555. {
  11556. u32 bw_ops;
  11557. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11558. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  11559. return 0;
  11560. mutex_lock(&tasha->sb_clk_gear_lock);
  11561. if (vote) {
  11562. tasha->ref_count++;
  11563. if (tasha->ref_count == 1) {
  11564. bw_ops = SLIM_BW_CLK_GEAR_9;
  11565. tasha_codec_slim_reserve_bw(codec,
  11566. bw_ops, true);
  11567. }
  11568. } else if (!vote && tasha->ref_count > 0) {
  11569. tasha->ref_count--;
  11570. if (tasha->ref_count == 0) {
  11571. bw_ops = SLIM_BW_UNVOTE;
  11572. tasha_codec_slim_reserve_bw(codec,
  11573. bw_ops, true);
  11574. }
  11575. };
  11576. dev_dbg(codec->dev, "%s Value of counter after vote or un-vote is %d\n",
  11577. __func__, tasha->ref_count);
  11578. mutex_unlock(&tasha->sb_clk_gear_lock);
  11579. return 0;
  11580. }
  11581. static int tasha_cpe_err_irq_control(struct snd_soc_codec *codec,
  11582. enum cpe_err_irq_cntl_type cntl_type, u8 *status)
  11583. {
  11584. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11585. u8 irq_bits;
  11586. if (TASHA_IS_2_0(tasha->wcd9xxx))
  11587. irq_bits = 0xFF;
  11588. else
  11589. irq_bits = 0x3F;
  11590. if (status)
  11591. irq_bits = (*status) & irq_bits;
  11592. switch (cntl_type) {
  11593. case CPE_ERR_IRQ_MASK:
  11594. snd_soc_update_bits(codec,
  11595. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11596. irq_bits, irq_bits);
  11597. break;
  11598. case CPE_ERR_IRQ_UNMASK:
  11599. snd_soc_update_bits(codec,
  11600. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11601. irq_bits, 0x00);
  11602. break;
  11603. case CPE_ERR_IRQ_CLEAR:
  11604. snd_soc_write(codec, WCD9335_CPE_SS_SS_ERROR_INT_CLEAR,
  11605. irq_bits);
  11606. break;
  11607. case CPE_ERR_IRQ_STATUS:
  11608. if (!status)
  11609. return -EINVAL;
  11610. *status = snd_soc_read(codec,
  11611. WCD9335_CPE_SS_SS_ERROR_INT_STATUS);
  11612. break;
  11613. }
  11614. return 0;
  11615. }
  11616. static const struct wcd_cpe_cdc_cb cpe_cb = {
  11617. .cdc_clk_en = tasha_codec_internal_rco_ctrl,
  11618. .cpe_clk_en = tasha_codec_cpe_fll_enable,
  11619. .get_afe_out_port_id = tasha_codec_get_mad_port_id,
  11620. .lab_cdc_ch_ctl = tasha_codec_enable_slimtx_mad,
  11621. .cdc_ext_clk = tasha_cdc_mclk_enable,
  11622. .bus_vote_bw = tasha_codec_vote_max_bw,
  11623. .cpe_err_irq_control = tasha_cpe_err_irq_control,
  11624. };
  11625. static struct cpe_svc_init_param cpe_svc_params = {
  11626. .version = CPE_SVC_INIT_PARAM_V1,
  11627. .query_freq_plans_cb = tasha_cdc_query_cpe_clk_plan,
  11628. .change_freq_plan_cb = tasha_cdc_change_cpe_clk,
  11629. };
  11630. static int tasha_cpe_initialize(struct snd_soc_codec *codec)
  11631. {
  11632. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11633. struct wcd_cpe_params cpe_params;
  11634. memset(&cpe_params, 0,
  11635. sizeof(struct wcd_cpe_params));
  11636. cpe_params.codec = codec;
  11637. cpe_params.get_cpe_core = tasha_codec_get_cpe_core;
  11638. cpe_params.cdc_cb = &cpe_cb;
  11639. cpe_params.dbg_mode = cpe_debug_mode;
  11640. cpe_params.cdc_major_ver = CPE_SVC_CODEC_WCD9335;
  11641. cpe_params.cdc_minor_ver = CPE_SVC_CODEC_V1P0;
  11642. cpe_params.cdc_id = CPE_SVC_CODEC_WCD9335;
  11643. cpe_params.cdc_irq_info.cpe_engine_irq =
  11644. WCD9335_IRQ_SVA_OUTBOX1;
  11645. cpe_params.cdc_irq_info.cpe_err_irq =
  11646. WCD9335_IRQ_SVA_ERROR;
  11647. cpe_params.cdc_irq_info.cpe_fatal_irqs =
  11648. TASHA_CPE_FATAL_IRQS;
  11649. cpe_svc_params.context = codec;
  11650. cpe_params.cpe_svc_params = &cpe_svc_params;
  11651. tasha->cpe_core = wcd_cpe_init("cpe_9335", codec,
  11652. &cpe_params);
  11653. if (IS_ERR_OR_NULL(tasha->cpe_core)) {
  11654. dev_err(codec->dev,
  11655. "%s: Failed to enable CPE\n",
  11656. __func__);
  11657. return -EINVAL;
  11658. }
  11659. return 0;
  11660. }
  11661. static const struct wcd_resmgr_cb tasha_resmgr_cb = {
  11662. .cdc_rco_ctrl = __tasha_codec_internal_rco_ctrl,
  11663. };
  11664. static int tasha_device_down(struct wcd9xxx *wcd9xxx)
  11665. {
  11666. struct snd_soc_codec *codec;
  11667. struct tasha_priv *priv;
  11668. int count;
  11669. int i = 0;
  11670. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11671. priv = snd_soc_codec_get_drvdata(codec);
  11672. wcd_cpe_ssr_event(priv->cpe_core, WCD_CPE_BUS_DOWN_EVENT);
  11673. for (i = 0; i < priv->nr; i++)
  11674. swrm_wcd_notify(priv->swr_ctrl_data[i].swr_pdev,
  11675. SWR_DEVICE_DOWN, NULL);
  11676. snd_soc_card_change_online_state(codec->component.card, 0);
  11677. for (count = 0; count < NUM_CODEC_DAIS; count++)
  11678. priv->dai[count].bus_down_in_recovery = true;
  11679. priv->resmgr->sido_input_src = SIDO_SOURCE_INTERNAL;
  11680. return 0;
  11681. }
  11682. static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx)
  11683. {
  11684. int i, ret = 0;
  11685. struct wcd9xxx *control;
  11686. struct snd_soc_codec *codec;
  11687. struct tasha_priv *tasha;
  11688. struct wcd9xxx_pdata *pdata;
  11689. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11690. tasha = snd_soc_codec_get_drvdata(codec);
  11691. control = dev_get_drvdata(codec->dev->parent);
  11692. wcd9xxx_set_power_state(tasha->wcd9xxx,
  11693. WCD_REGION_POWER_COLLAPSE_REMOVE,
  11694. WCD9XXX_DIG_CORE_REGION_1);
  11695. mutex_lock(&tasha->codec_mutex);
  11696. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11697. control->slim_slave->laddr;
  11698. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11699. control->slim->laddr;
  11700. tasha_init_slim_slave_cfg(codec);
  11701. if (tasha->machine_codec_event_cb)
  11702. tasha->machine_codec_event_cb(codec,
  11703. WCD9335_CODEC_EVENT_CODEC_UP);
  11704. snd_soc_card_change_online_state(codec->component.card, 1);
  11705. /* Class-H Init*/
  11706. wcd_clsh_init(&tasha->clsh_d);
  11707. for (i = 0; i < TASHA_MAX_MICBIAS; i++)
  11708. tasha->micb_ref[i] = 0;
  11709. tasha_update_reg_defaults(tasha);
  11710. tasha->codec = codec;
  11711. dev_dbg(codec->dev, "%s: MCLK Rate = %x\n",
  11712. __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. wcd_resmgr_post_ssr_v2(tasha->resmgr);
  11721. tasha_enable_efuse_sensing(codec);
  11722. regcache_mark_dirty(codec->component.regmap);
  11723. regcache_sync(codec->component.regmap);
  11724. pdata = dev_get_platdata(codec->dev->parent);
  11725. ret = tasha_handle_pdata(tasha, pdata);
  11726. if (ret < 0)
  11727. dev_err(codec->dev, "%s: invalid pdata\n", __func__);
  11728. /* Reset reference counter for voting for max bw */
  11729. tasha->ref_count = 0;
  11730. /* MBHC Init */
  11731. wcd_mbhc_deinit(&tasha->mbhc);
  11732. tasha->mbhc_started = false;
  11733. /* Initialize MBHC module */
  11734. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11735. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11736. if (ret)
  11737. dev_err(codec->dev, "%s: mbhc initialization failed\n",
  11738. __func__);
  11739. else
  11740. tasha_mbhc_hs_detect(codec, tasha->mbhc.mbhc_cfg);
  11741. tasha_cleanup_irqs(tasha);
  11742. ret = tasha_setup_irqs(tasha);
  11743. if (ret) {
  11744. dev_err(codec->dev, "%s: tasha irq setup failed %d\n",
  11745. __func__, ret);
  11746. goto err;
  11747. }
  11748. tasha_set_spkr_mode(codec, tasha->spkr_mode);
  11749. wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT);
  11750. err:
  11751. mutex_unlock(&tasha->codec_mutex);
  11752. return ret;
  11753. }
  11754. static struct regulator *tasha_codec_find_ondemand_regulator(
  11755. struct snd_soc_codec *codec, const char *name)
  11756. {
  11757. int i;
  11758. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11759. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11760. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  11761. for (i = 0; i < wcd9xxx->num_of_supplies; ++i) {
  11762. if (pdata->regulator[i].ondemand &&
  11763. wcd9xxx->supplies[i].supply &&
  11764. !strcmp(wcd9xxx->supplies[i].supply, name))
  11765. return wcd9xxx->supplies[i].consumer;
  11766. }
  11767. dev_dbg(tasha->dev, "Warning: regulator not found:%s\n",
  11768. name);
  11769. return NULL;
  11770. }
  11771. static int tasha_codec_probe(struct snd_soc_codec *codec)
  11772. {
  11773. struct wcd9xxx *control;
  11774. struct tasha_priv *tasha;
  11775. struct wcd9xxx_pdata *pdata;
  11776. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  11777. int i, ret;
  11778. void *ptr = NULL;
  11779. struct regulator *supply;
  11780. control = dev_get_drvdata(codec->dev->parent);
  11781. dev_info(codec->dev, "%s()\n", __func__);
  11782. tasha = snd_soc_codec_get_drvdata(codec);
  11783. tasha->intf_type = wcd9xxx_get_intf_type();
  11784. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11785. control->dev_down = tasha_device_down;
  11786. control->post_reset = tasha_post_reset_cb;
  11787. control->ssr_priv = (void *)codec;
  11788. }
  11789. /* Resource Manager post Init */
  11790. ret = wcd_resmgr_post_init(tasha->resmgr, &tasha_resmgr_cb, codec);
  11791. if (ret) {
  11792. dev_err(codec->dev, "%s: wcd resmgr post init failed\n",
  11793. __func__);
  11794. goto err;
  11795. }
  11796. /* Class-H Init*/
  11797. wcd_clsh_init(&tasha->clsh_d);
  11798. /* Default HPH Mode to Class-H HiFi */
  11799. tasha->hph_mode = CLS_H_HIFI;
  11800. tasha->codec = codec;
  11801. for (i = 0; i < COMPANDER_MAX; i++)
  11802. tasha->comp_enabled[i] = 0;
  11803. tasha->spkr_gain_offset = RX_GAIN_OFFSET_0_DB;
  11804. tasha->intf_type = wcd9xxx_get_intf_type();
  11805. tasha_update_reg_reset_values(codec);
  11806. pr_debug("%s: MCLK Rate = %x\n", __func__, control->mclk_rate);
  11807. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  11808. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11809. 0x03, 0x00);
  11810. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  11811. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11812. 0x03, 0x01);
  11813. tasha_codec_init_reg(codec);
  11814. tasha_enable_efuse_sensing(codec);
  11815. pdata = dev_get_platdata(codec->dev->parent);
  11816. ret = tasha_handle_pdata(tasha, pdata);
  11817. if (ret < 0) {
  11818. pr_err("%s: bad pdata\n", __func__);
  11819. goto err;
  11820. }
  11821. supply = tasha_codec_find_ondemand_regulator(codec,
  11822. on_demand_supply_name[ON_DEMAND_MICBIAS]);
  11823. if (supply) {
  11824. tasha->on_demand_list[ON_DEMAND_MICBIAS].supply = supply;
  11825. tasha->on_demand_list[ON_DEMAND_MICBIAS].ondemand_supply_count =
  11826. 0;
  11827. }
  11828. tasha->fw_data = devm_kzalloc(codec->dev,
  11829. sizeof(*(tasha->fw_data)), GFP_KERNEL);
  11830. if (!tasha->fw_data)
  11831. goto err;
  11832. set_bit(WCD9XXX_ANC_CAL, tasha->fw_data->cal_bit);
  11833. set_bit(WCD9XXX_MBHC_CAL, tasha->fw_data->cal_bit);
  11834. set_bit(WCD9XXX_MAD_CAL, tasha->fw_data->cal_bit);
  11835. set_bit(WCD9XXX_VBAT_CAL, tasha->fw_data->cal_bit);
  11836. ret = wcd_cal_create_hwdep(tasha->fw_data,
  11837. WCD9XXX_CODEC_HWDEP_NODE, codec);
  11838. if (ret < 0) {
  11839. dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret);
  11840. goto err_hwdep;
  11841. }
  11842. /* Initialize MBHC module */
  11843. if (TASHA_IS_2_0(tasha->wcd9xxx)) {
  11844. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].reg =
  11845. WCD9335_MBHC_FSM_STATUS;
  11846. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].mask = 0x01;
  11847. }
  11848. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11849. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11850. if (ret) {
  11851. pr_err("%s: mbhc initialization failed\n", __func__);
  11852. goto err_hwdep;
  11853. }
  11854. ptr = devm_kzalloc(codec->dev, (sizeof(tasha_rx_chs) +
  11855. sizeof(tasha_tx_chs)), GFP_KERNEL);
  11856. if (!ptr) {
  11857. ret = -ENOMEM;
  11858. goto err_hwdep;
  11859. }
  11860. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  11861. snd_soc_dapm_new_controls(dapm, tasha_dapm_i2s_widgets,
  11862. ARRAY_SIZE(tasha_dapm_i2s_widgets));
  11863. snd_soc_dapm_add_routes(dapm, audio_i2s_map,
  11864. ARRAY_SIZE(audio_i2s_map));
  11865. for (i = 0; i < ARRAY_SIZE(tasha_i2s_dai); i++) {
  11866. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11867. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11868. }
  11869. } else if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11870. for (i = 0; i < NUM_CODEC_DAIS; i++) {
  11871. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11872. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11873. }
  11874. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11875. control->slim_slave->laddr;
  11876. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11877. control->slim->laddr;
  11878. tasha_slimbus_slave_port_cfg.slave_port_mapping[0] =
  11879. TASHA_TX13;
  11880. tasha_init_slim_slave_cfg(codec);
  11881. }
  11882. snd_soc_add_codec_controls(codec, impedance_detect_controls,
  11883. ARRAY_SIZE(impedance_detect_controls));
  11884. snd_soc_add_codec_controls(codec, hph_type_detect_controls,
  11885. ARRAY_SIZE(hph_type_detect_controls));
  11886. snd_soc_add_codec_controls(codec,
  11887. tasha_analog_gain_controls,
  11888. ARRAY_SIZE(tasha_analog_gain_controls));
  11889. if (tasha->is_wsa_attach)
  11890. snd_soc_add_codec_controls(codec,
  11891. tasha_spkr_wsa_controls,
  11892. ARRAY_SIZE(tasha_spkr_wsa_controls));
  11893. control->num_rx_port = TASHA_RX_MAX;
  11894. control->rx_chs = ptr;
  11895. memcpy(control->rx_chs, tasha_rx_chs, sizeof(tasha_rx_chs));
  11896. control->num_tx_port = TASHA_TX_MAX;
  11897. control->tx_chs = ptr + sizeof(tasha_rx_chs);
  11898. memcpy(control->tx_chs, tasha_tx_chs, sizeof(tasha_tx_chs));
  11899. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Playback");
  11900. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Capture");
  11901. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Playback");
  11902. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Capture");
  11903. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11904. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Playback");
  11905. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Capture");
  11906. snd_soc_dapm_ignore_suspend(dapm, "AIF4 Playback");
  11907. snd_soc_dapm_ignore_suspend(dapm, "AIF Mix Playback");
  11908. snd_soc_dapm_ignore_suspend(dapm, "AIF4 MAD TX");
  11909. snd_soc_dapm_ignore_suspend(dapm, "VIfeed");
  11910. snd_soc_dapm_ignore_suspend(dapm, "AIF5 CPE TX");
  11911. }
  11912. snd_soc_dapm_sync(dapm);
  11913. ret = tasha_setup_irqs(tasha);
  11914. if (ret) {
  11915. pr_err("%s: tasha irq setup failed %d\n", __func__, ret);
  11916. goto err_pdata;
  11917. }
  11918. ret = tasha_cpe_initialize(codec);
  11919. if (ret) {
  11920. dev_err(codec->dev,
  11921. "%s: cpe initialization failed, err = %d\n",
  11922. __func__, ret);
  11923. /* Do not fail probe if CPE failed */
  11924. ret = 0;
  11925. }
  11926. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11927. tasha->tx_hpf_work[i].tasha = tasha;
  11928. tasha->tx_hpf_work[i].decimator = i;
  11929. INIT_DELAYED_WORK(&tasha->tx_hpf_work[i].dwork,
  11930. tasha_tx_hpf_corner_freq_callback);
  11931. }
  11932. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11933. tasha->tx_mute_dwork[i].tasha = tasha;
  11934. tasha->tx_mute_dwork[i].decimator = i;
  11935. INIT_DELAYED_WORK(&tasha->tx_mute_dwork[i].dwork,
  11936. tasha_tx_mute_update_callback);
  11937. }
  11938. tasha->spk_anc_dwork.tasha = tasha;
  11939. INIT_DELAYED_WORK(&tasha->spk_anc_dwork.dwork,
  11940. tasha_spk_anc_update_callback);
  11941. mutex_lock(&tasha->codec_mutex);
  11942. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  11943. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  11944. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  11945. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  11946. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  11947. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  11948. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  11949. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  11950. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  11951. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  11952. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  11953. mutex_unlock(&tasha->codec_mutex);
  11954. snd_soc_dapm_sync(dapm);
  11955. return ret;
  11956. err_pdata:
  11957. devm_kfree(codec->dev, ptr);
  11958. control->rx_chs = NULL;
  11959. control->tx_chs = NULL;
  11960. err_hwdep:
  11961. devm_kfree(codec->dev, tasha->fw_data);
  11962. tasha->fw_data = NULL;
  11963. err:
  11964. return ret;
  11965. }
  11966. static int tasha_codec_remove(struct snd_soc_codec *codec)
  11967. {
  11968. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11969. struct wcd9xxx *control;
  11970. control = dev_get_drvdata(codec->dev->parent);
  11971. control->num_rx_port = 0;
  11972. control->num_tx_port = 0;
  11973. control->rx_chs = NULL;
  11974. control->tx_chs = NULL;
  11975. tasha_cleanup_irqs(tasha);
  11976. /* Cleanup MBHC */
  11977. wcd_mbhc_deinit(&tasha->mbhc);
  11978. /* Cleanup resmgr */
  11979. return 0;
  11980. }
  11981. static struct regmap *tasha_get_regmap(struct device *dev)
  11982. {
  11983. struct wcd9xxx *control = dev_get_drvdata(dev->parent);
  11984. return control->regmap;
  11985. }
  11986. static struct snd_soc_codec_driver soc_codec_dev_tasha = {
  11987. .probe = tasha_codec_probe,
  11988. .remove = tasha_codec_remove,
  11989. .get_regmap = tasha_get_regmap,
  11990. .component_driver = {
  11991. .controls = tasha_snd_controls,
  11992. .num_controls = ARRAY_SIZE(tasha_snd_controls),
  11993. .dapm_widgets = tasha_dapm_widgets,
  11994. .num_dapm_widgets = ARRAY_SIZE(tasha_dapm_widgets),
  11995. .dapm_routes = audio_map,
  11996. .num_dapm_routes = ARRAY_SIZE(audio_map),
  11997. },
  11998. };
  11999. #ifdef CONFIG_PM
  12000. static int tasha_suspend(struct device *dev)
  12001. {
  12002. struct platform_device *pdev = to_platform_device(dev);
  12003. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  12004. dev_dbg(dev, "%s: system suspend\n", __func__);
  12005. if (cancel_delayed_work_sync(&tasha->power_gate_work))
  12006. tasha_codec_power_gate_digital_core(tasha);
  12007. return 0;
  12008. }
  12009. static int tasha_resume(struct device *dev)
  12010. {
  12011. struct platform_device *pdev = to_platform_device(dev);
  12012. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  12013. if (!tasha) {
  12014. dev_err(dev, "%s: tasha private data is NULL\n", __func__);
  12015. return -EINVAL;
  12016. }
  12017. dev_dbg(dev, "%s: system resume\n", __func__);
  12018. return 0;
  12019. }
  12020. static const struct dev_pm_ops tasha_pm_ops = {
  12021. .suspend = tasha_suspend,
  12022. .resume = tasha_resume,
  12023. };
  12024. #endif
  12025. static int tasha_swrm_read(void *handle, int reg)
  12026. {
  12027. struct tasha_priv *tasha;
  12028. struct wcd9xxx *wcd9xxx;
  12029. unsigned short swr_rd_addr_base;
  12030. unsigned short swr_rd_data_base;
  12031. int val, ret;
  12032. if (!handle) {
  12033. pr_err("%s: NULL handle\n", __func__);
  12034. return -EINVAL;
  12035. }
  12036. tasha = (struct tasha_priv *)handle;
  12037. wcd9xxx = tasha->wcd9xxx;
  12038. dev_dbg(tasha->dev, "%s: Reading soundwire register, 0x%x\n",
  12039. __func__, reg);
  12040. swr_rd_addr_base = WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0;
  12041. swr_rd_data_base = WCD9335_SWR_AHB_BRIDGE_RD_DATA_0;
  12042. /* read_lock */
  12043. mutex_lock(&tasha->swr_read_lock);
  12044. ret = regmap_bulk_write(wcd9xxx->regmap, swr_rd_addr_base,
  12045. (u8 *)&reg, 4);
  12046. if (ret < 0) {
  12047. pr_err("%s: RD Addr Failure\n", __func__);
  12048. goto err;
  12049. }
  12050. /* Check for RD status */
  12051. ret = regmap_bulk_read(wcd9xxx->regmap, swr_rd_data_base,
  12052. (u8 *)&val, 4);
  12053. if (ret < 0) {
  12054. pr_err("%s: RD Data Failure\n", __func__);
  12055. goto err;
  12056. }
  12057. ret = val;
  12058. err:
  12059. /* read_unlock */
  12060. mutex_unlock(&tasha->swr_read_lock);
  12061. return ret;
  12062. }
  12063. static int tasha_swrm_i2s_bulk_write(struct wcd9xxx *wcd9xxx,
  12064. struct wcd9xxx_reg_val *bulk_reg,
  12065. size_t len)
  12066. {
  12067. int i, ret = 0;
  12068. unsigned short swr_wr_addr_base;
  12069. unsigned short swr_wr_data_base;
  12070. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12071. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12072. for (i = 0; i < (len * 2); i += 2) {
  12073. /* First Write the Data to register */
  12074. ret = regmap_bulk_write(wcd9xxx->regmap,
  12075. swr_wr_data_base, bulk_reg[i].buf, 4);
  12076. if (ret < 0) {
  12077. dev_err(wcd9xxx->dev, "%s: WR Data Failure\n",
  12078. __func__);
  12079. break;
  12080. }
  12081. /* Next Write Address */
  12082. ret = regmap_bulk_write(wcd9xxx->regmap,
  12083. swr_wr_addr_base, bulk_reg[i+1].buf, 4);
  12084. if (ret < 0) {
  12085. dev_err(wcd9xxx->dev, "%s: WR Addr Failure\n",
  12086. __func__);
  12087. break;
  12088. }
  12089. }
  12090. return ret;
  12091. }
  12092. static int tasha_swrm_bulk_write(void *handle, u32 *reg, u32 *val, size_t len)
  12093. {
  12094. struct tasha_priv *tasha;
  12095. struct wcd9xxx *wcd9xxx;
  12096. struct wcd9xxx_reg_val *bulk_reg;
  12097. unsigned short swr_wr_addr_base;
  12098. unsigned short swr_wr_data_base;
  12099. int i, j, ret;
  12100. if (!handle) {
  12101. pr_err("%s: NULL handle\n", __func__);
  12102. return -EINVAL;
  12103. }
  12104. if (len <= 0) {
  12105. pr_err("%s: Invalid size: %zu\n", __func__, len);
  12106. return -EINVAL;
  12107. }
  12108. tasha = (struct tasha_priv *)handle;
  12109. wcd9xxx = tasha->wcd9xxx;
  12110. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12111. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12112. bulk_reg = kzalloc((2 * len * sizeof(struct wcd9xxx_reg_val)),
  12113. GFP_KERNEL);
  12114. if (!bulk_reg)
  12115. return -ENOMEM;
  12116. for (i = 0, j = 0; i < (len * 2); i += 2, j++) {
  12117. bulk_reg[i].reg = swr_wr_data_base;
  12118. bulk_reg[i].buf = (u8 *)(&val[j]);
  12119. bulk_reg[i].bytes = 4;
  12120. bulk_reg[i+1].reg = swr_wr_addr_base;
  12121. bulk_reg[i+1].buf = (u8 *)(&reg[j]);
  12122. bulk_reg[i+1].bytes = 4;
  12123. }
  12124. mutex_lock(&tasha->swr_write_lock);
  12125. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12126. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, len);
  12127. if (ret) {
  12128. dev_err(tasha->dev, "%s: i2s bulk write failed, ret: %d\n",
  12129. __func__, ret);
  12130. }
  12131. } else {
  12132. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg,
  12133. (len * 2), false);
  12134. if (ret) {
  12135. dev_err(tasha->dev, "%s: swrm bulk write failed, ret: %d\n",
  12136. __func__, ret);
  12137. }
  12138. }
  12139. mutex_unlock(&tasha->swr_write_lock);
  12140. kfree(bulk_reg);
  12141. return ret;
  12142. }
  12143. static int tasha_swrm_write(void *handle, int reg, int val)
  12144. {
  12145. struct tasha_priv *tasha;
  12146. struct wcd9xxx *wcd9xxx;
  12147. unsigned short swr_wr_addr_base;
  12148. unsigned short swr_wr_data_base;
  12149. struct wcd9xxx_reg_val bulk_reg[2];
  12150. int ret;
  12151. if (!handle) {
  12152. pr_err("%s: NULL handle\n", __func__);
  12153. return -EINVAL;
  12154. }
  12155. tasha = (struct tasha_priv *)handle;
  12156. wcd9xxx = tasha->wcd9xxx;
  12157. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12158. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12159. /* First Write the Data to register */
  12160. bulk_reg[0].reg = swr_wr_data_base;
  12161. bulk_reg[0].buf = (u8 *)(&val);
  12162. bulk_reg[0].bytes = 4;
  12163. bulk_reg[1].reg = swr_wr_addr_base;
  12164. bulk_reg[1].buf = (u8 *)(&reg);
  12165. bulk_reg[1].bytes = 4;
  12166. mutex_lock(&tasha->swr_write_lock);
  12167. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12168. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, 1);
  12169. if (ret) {
  12170. dev_err(tasha->dev, "%s: i2s swrm write failed, ret: %d\n",
  12171. __func__, ret);
  12172. }
  12173. } else {
  12174. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2, false);
  12175. if (ret < 0)
  12176. pr_err("%s: WR Data Failure\n", __func__);
  12177. }
  12178. mutex_unlock(&tasha->swr_write_lock);
  12179. return ret;
  12180. }
  12181. static int tasha_swrm_clock(void *handle, bool enable)
  12182. {
  12183. struct tasha_priv *tasha = (struct tasha_priv *) handle;
  12184. mutex_lock(&tasha->swr_clk_lock);
  12185. dev_dbg(tasha->dev, "%s: swrm clock %s\n",
  12186. __func__, (enable?"enable" : "disable"));
  12187. if (enable) {
  12188. tasha->swr_clk_users++;
  12189. if (tasha->swr_clk_users == 1) {
  12190. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12191. regmap_update_bits(
  12192. tasha->wcd9xxx->regmap,
  12193. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12194. 0x10, 0x00);
  12195. __tasha_cdc_mclk_enable(tasha, true);
  12196. regmap_update_bits(tasha->wcd9xxx->regmap,
  12197. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12198. 0x01, 0x01);
  12199. }
  12200. } else {
  12201. tasha->swr_clk_users--;
  12202. if (tasha->swr_clk_users == 0) {
  12203. regmap_update_bits(tasha->wcd9xxx->regmap,
  12204. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12205. 0x01, 0x00);
  12206. __tasha_cdc_mclk_enable(tasha, false);
  12207. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12208. regmap_update_bits(
  12209. tasha->wcd9xxx->regmap,
  12210. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12211. 0x10, 0x10);
  12212. }
  12213. }
  12214. dev_dbg(tasha->dev, "%s: swrm clock users %d\n",
  12215. __func__, tasha->swr_clk_users);
  12216. mutex_unlock(&tasha->swr_clk_lock);
  12217. return 0;
  12218. }
  12219. static int tasha_swrm_handle_irq(void *handle,
  12220. irqreturn_t (*swrm_irq_handler)(int irq,
  12221. void *data),
  12222. void *swrm_handle,
  12223. int action)
  12224. {
  12225. struct tasha_priv *tasha;
  12226. int ret = 0;
  12227. struct wcd9xxx *wcd9xxx;
  12228. if (!handle) {
  12229. pr_err("%s: null handle received\n", __func__);
  12230. return -EINVAL;
  12231. }
  12232. tasha = (struct tasha_priv *) handle;
  12233. wcd9xxx = tasha->wcd9xxx;
  12234. if (action) {
  12235. ret = wcd9xxx_request_irq(&wcd9xxx->core_res,
  12236. WCD9335_IRQ_SOUNDWIRE,
  12237. swrm_irq_handler,
  12238. "Tasha SWR Master", swrm_handle);
  12239. if (ret)
  12240. dev_err(tasha->dev, "%s: Failed to request irq %d\n",
  12241. __func__, WCD9335_IRQ_SOUNDWIRE);
  12242. } else
  12243. wcd9xxx_free_irq(&wcd9xxx->core_res, WCD9335_IRQ_SOUNDWIRE,
  12244. swrm_handle);
  12245. return ret;
  12246. }
  12247. static void tasha_add_child_devices(struct work_struct *work)
  12248. {
  12249. struct tasha_priv *tasha;
  12250. struct platform_device *pdev;
  12251. struct device_node *node;
  12252. struct wcd9xxx *wcd9xxx;
  12253. struct tasha_swr_ctrl_data *swr_ctrl_data = NULL, *temp;
  12254. int ret, ctrl_num = 0;
  12255. struct wcd_swr_ctrl_platform_data *platdata;
  12256. char plat_dev_name[WCD9335_STRING_LEN];
  12257. tasha = container_of(work, struct tasha_priv,
  12258. tasha_add_child_devices_work);
  12259. if (!tasha) {
  12260. pr_err("%s: Memory for WCD9335 does not exist\n",
  12261. __func__);
  12262. return;
  12263. }
  12264. wcd9xxx = tasha->wcd9xxx;
  12265. if (!wcd9xxx) {
  12266. pr_err("%s: Memory for WCD9XXX does not exist\n",
  12267. __func__);
  12268. return;
  12269. }
  12270. if (!wcd9xxx->dev->of_node) {
  12271. pr_err("%s: DT node for wcd9xxx does not exist\n",
  12272. __func__);
  12273. return;
  12274. }
  12275. platdata = &tasha->swr_plat_data;
  12276. tasha->child_count = 0;
  12277. for_each_child_of_node(wcd9xxx->dev->of_node, node) {
  12278. if (!strcmp(node->name, "swr_master"))
  12279. strlcpy(plat_dev_name, "tasha_swr_ctrl",
  12280. (WCD9335_STRING_LEN - 1));
  12281. else if (strnstr(node->name, "msm_cdc_pinctrl",
  12282. strlen("msm_cdc_pinctrl")) != NULL)
  12283. strlcpy(plat_dev_name, node->name,
  12284. (WCD9335_STRING_LEN - 1));
  12285. else
  12286. continue;
  12287. pdev = platform_device_alloc(plat_dev_name, -1);
  12288. if (!pdev) {
  12289. dev_err(wcd9xxx->dev, "%s: pdev memory alloc failed\n",
  12290. __func__);
  12291. ret = -ENOMEM;
  12292. goto err;
  12293. }
  12294. pdev->dev.parent = tasha->dev;
  12295. pdev->dev.of_node = node;
  12296. if (!strcmp(node->name, "swr_master")) {
  12297. ret = platform_device_add_data(pdev, platdata,
  12298. sizeof(*platdata));
  12299. if (ret) {
  12300. dev_err(&pdev->dev,
  12301. "%s: cannot add plat data ctrl:%d\n",
  12302. __func__, ctrl_num);
  12303. goto fail_pdev_add;
  12304. }
  12305. tasha->is_wsa_attach = true;
  12306. }
  12307. ret = platform_device_add(pdev);
  12308. if (ret) {
  12309. dev_err(&pdev->dev,
  12310. "%s: Cannot add platform device\n",
  12311. __func__);
  12312. goto fail_pdev_add;
  12313. }
  12314. if (!strcmp(node->name, "swr_master")) {
  12315. temp = krealloc(swr_ctrl_data,
  12316. (ctrl_num + 1) * sizeof(
  12317. struct tasha_swr_ctrl_data),
  12318. GFP_KERNEL);
  12319. if (!temp) {
  12320. dev_err(wcd9xxx->dev, "out of memory\n");
  12321. ret = -ENOMEM;
  12322. goto err;
  12323. }
  12324. swr_ctrl_data = temp;
  12325. swr_ctrl_data[ctrl_num].swr_pdev = pdev;
  12326. ctrl_num++;
  12327. dev_dbg(&pdev->dev,
  12328. "%s: Added soundwire ctrl device(s)\n",
  12329. __func__);
  12330. tasha->nr = ctrl_num;
  12331. tasha->swr_ctrl_data = swr_ctrl_data;
  12332. }
  12333. if (tasha->child_count < WCD9335_CHILD_DEVICES_MAX)
  12334. tasha->pdev_child_devices[tasha->child_count++] = pdev;
  12335. else
  12336. goto err;
  12337. }
  12338. return;
  12339. fail_pdev_add:
  12340. platform_device_put(pdev);
  12341. err:
  12342. return;
  12343. }
  12344. /*
  12345. * tasha_codec_ver: to get tasha codec version
  12346. * @codec: handle to snd_soc_codec *
  12347. * return enum codec_variant - version
  12348. */
  12349. enum codec_variant tasha_codec_ver(void)
  12350. {
  12351. return codec_ver;
  12352. }
  12353. EXPORT_SYMBOL(tasha_codec_ver);
  12354. static int __tasha_enable_efuse_sensing(struct tasha_priv *tasha)
  12355. {
  12356. int val, rc;
  12357. __tasha_cdc_mclk_enable(tasha, true);
  12358. regmap_update_bits(tasha->wcd9xxx->regmap,
  12359. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x1E, 0x20);
  12360. regmap_update_bits(tasha->wcd9xxx->regmap,
  12361. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x01, 0x01);
  12362. /*
  12363. * 5ms sleep required after enabling efuse control
  12364. * before checking the status.
  12365. */
  12366. usleep_range(5000, 5500);
  12367. rc = regmap_read(tasha->wcd9xxx->regmap,
  12368. WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS, &val);
  12369. if (rc || (!(val & 0x01)))
  12370. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  12371. __tasha_cdc_mclk_enable(tasha, false);
  12372. return rc;
  12373. }
  12374. void tasha_get_codec_ver(struct tasha_priv *tasha)
  12375. {
  12376. int i;
  12377. int val;
  12378. struct tasha_reg_mask_val codec_reg[] = {
  12379. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10, 0xFF, 0xFF},
  12380. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11, 0xFF, 0x83},
  12381. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12, 0xFF, 0x0A},
  12382. };
  12383. __tasha_enable_efuse_sensing(tasha);
  12384. for (i = 0; i < ARRAY_SIZE(codec_reg); i++) {
  12385. regmap_read(tasha->wcd9xxx->regmap, codec_reg[i].reg, &val);
  12386. if (!(val && codec_reg[i].val)) {
  12387. codec_ver = WCD9335;
  12388. goto ret;
  12389. }
  12390. }
  12391. codec_ver = WCD9326;
  12392. ret:
  12393. pr_debug("%s: codec is %d\n", __func__, codec_ver);
  12394. }
  12395. EXPORT_SYMBOL(tasha_get_codec_ver);
  12396. static int tasha_probe(struct platform_device *pdev)
  12397. {
  12398. int ret = 0;
  12399. struct tasha_priv *tasha;
  12400. struct clk *wcd_ext_clk, *wcd_native_clk;
  12401. struct wcd9xxx_resmgr_v2 *resmgr;
  12402. struct wcd9xxx_power_region *cdc_pwr;
  12403. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12404. if (apr_get_subsys_state() == APR_SUBSYS_DOWN) {
  12405. dev_err(&pdev->dev, "%s: dsp down\n", __func__);
  12406. return -EPROBE_DEFER;
  12407. }
  12408. }
  12409. tasha = devm_kzalloc(&pdev->dev, sizeof(struct tasha_priv),
  12410. GFP_KERNEL);
  12411. if (!tasha)
  12412. return -ENOMEM;
  12413. platform_set_drvdata(pdev, tasha);
  12414. tasha->wcd9xxx = dev_get_drvdata(pdev->dev.parent);
  12415. tasha->dev = &pdev->dev;
  12416. INIT_DELAYED_WORK(&tasha->power_gate_work, tasha_codec_power_gate_work);
  12417. mutex_init(&tasha->power_lock);
  12418. mutex_init(&tasha->sido_lock);
  12419. INIT_WORK(&tasha->tasha_add_child_devices_work,
  12420. tasha_add_child_devices);
  12421. BLOCKING_INIT_NOTIFIER_HEAD(&tasha->notifier);
  12422. mutex_init(&tasha->micb_lock);
  12423. mutex_init(&tasha->swr_read_lock);
  12424. mutex_init(&tasha->swr_write_lock);
  12425. mutex_init(&tasha->swr_clk_lock);
  12426. mutex_init(&tasha->sb_clk_gear_lock);
  12427. mutex_init(&tasha->mclk_lock);
  12428. cdc_pwr = devm_kzalloc(&pdev->dev, sizeof(struct wcd9xxx_power_region),
  12429. GFP_KERNEL);
  12430. if (!cdc_pwr) {
  12431. ret = -ENOMEM;
  12432. goto err_cdc_pwr;
  12433. }
  12434. tasha->wcd9xxx->wcd9xxx_pwr[WCD9XXX_DIG_CORE_REGION_1] = cdc_pwr;
  12435. cdc_pwr->pwr_collapse_reg_min = TASHA_DIG_CORE_REG_MIN;
  12436. cdc_pwr->pwr_collapse_reg_max = TASHA_DIG_CORE_REG_MAX;
  12437. wcd9xxx_set_power_state(tasha->wcd9xxx,
  12438. WCD_REGION_POWER_COLLAPSE_REMOVE,
  12439. WCD9XXX_DIG_CORE_REGION_1);
  12440. mutex_init(&tasha->codec_mutex);
  12441. /*
  12442. * Init resource manager so that if child nodes such as SoundWire
  12443. * requests for clock, resource manager can honor the request
  12444. */
  12445. resmgr = wcd_resmgr_init(&tasha->wcd9xxx->core_res, NULL);
  12446. if (IS_ERR(resmgr)) {
  12447. ret = PTR_ERR(resmgr);
  12448. dev_err(&pdev->dev, "%s: Failed to initialize wcd resmgr\n",
  12449. __func__);
  12450. goto err_resmgr;
  12451. }
  12452. tasha->resmgr = resmgr;
  12453. tasha->swr_plat_data.handle = (void *) tasha;
  12454. tasha->swr_plat_data.read = tasha_swrm_read;
  12455. tasha->swr_plat_data.write = tasha_swrm_write;
  12456. tasha->swr_plat_data.bulk_write = tasha_swrm_bulk_write;
  12457. tasha->swr_plat_data.clk = tasha_swrm_clock;
  12458. tasha->swr_plat_data.handle_irq = tasha_swrm_handle_irq;
  12459. /* Register for Clock */
  12460. wcd_ext_clk = clk_get(tasha->wcd9xxx->dev, "wcd_clk");
  12461. if (IS_ERR(wcd_ext_clk)) {
  12462. dev_err(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12463. __func__, "wcd_ext_clk");
  12464. goto err_clk;
  12465. }
  12466. tasha->wcd_ext_clk = wcd_ext_clk;
  12467. tasha->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV;
  12468. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  12469. tasha->sido_ccl_cnt = 0;
  12470. /* Register native clk for 44.1 playback */
  12471. wcd_native_clk = clk_get(tasha->wcd9xxx->dev, "wcd_native_clk");
  12472. if (IS_ERR(wcd_native_clk))
  12473. dev_dbg(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12474. __func__, "wcd_native_clk");
  12475. else
  12476. tasha->wcd_native_clk = wcd_native_clk;
  12477. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  12478. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12479. tasha_dai, ARRAY_SIZE(tasha_dai));
  12480. else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
  12481. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12482. tasha_i2s_dai,
  12483. ARRAY_SIZE(tasha_i2s_dai));
  12484. else
  12485. ret = -EINVAL;
  12486. if (ret) {
  12487. dev_err(&pdev->dev, "%s: Codec registration failed, ret = %d\n",
  12488. __func__, ret);
  12489. goto err_cdc_reg;
  12490. }
  12491. /* Update codec register default values */
  12492. tasha_update_reg_defaults(tasha);
  12493. schedule_work(&tasha->tasha_add_child_devices_work);
  12494. tasha_get_codec_ver(tasha);
  12495. dev_info(&pdev->dev, "%s: Tasha driver probe done\n", __func__);
  12496. return ret;
  12497. err_cdc_reg:
  12498. clk_put(tasha->wcd_ext_clk);
  12499. if (tasha->wcd_native_clk)
  12500. clk_put(tasha->wcd_native_clk);
  12501. err_clk:
  12502. wcd_resmgr_remove(tasha->resmgr);
  12503. err_resmgr:
  12504. devm_kfree(&pdev->dev, cdc_pwr);
  12505. err_cdc_pwr:
  12506. mutex_destroy(&tasha->mclk_lock);
  12507. devm_kfree(&pdev->dev, tasha);
  12508. return ret;
  12509. }
  12510. static int tasha_remove(struct platform_device *pdev)
  12511. {
  12512. struct tasha_priv *tasha;
  12513. int count = 0;
  12514. tasha = platform_get_drvdata(pdev);
  12515. if (!tasha)
  12516. return -EINVAL;
  12517. for (count = 0; count < tasha->child_count &&
  12518. count < WCD9335_CHILD_DEVICES_MAX; count++)
  12519. platform_device_unregister(tasha->pdev_child_devices[count]);
  12520. mutex_destroy(&tasha->codec_mutex);
  12521. clk_put(tasha->wcd_ext_clk);
  12522. if (tasha->wcd_native_clk)
  12523. clk_put(tasha->wcd_native_clk);
  12524. mutex_destroy(&tasha->mclk_lock);
  12525. mutex_destroy(&tasha->sb_clk_gear_lock);
  12526. snd_soc_unregister_codec(&pdev->dev);
  12527. devm_kfree(&pdev->dev, tasha);
  12528. return 0;
  12529. }
  12530. static struct platform_driver tasha_codec_driver = {
  12531. .probe = tasha_probe,
  12532. .remove = tasha_remove,
  12533. .driver = {
  12534. .name = "tasha_codec",
  12535. .owner = THIS_MODULE,
  12536. #ifdef CONFIG_PM
  12537. .pm = &tasha_pm_ops,
  12538. #endif
  12539. },
  12540. };
  12541. module_platform_driver(tasha_codec_driver);
  12542. MODULE_DESCRIPTION("Tasha Codec driver");
  12543. MODULE_LICENSE("GPL v2");