wcd9335.c 439 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326
  1. /*
  2. * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/init.h>
  15. #include <linux/firmware.h>
  16. #include <linux/slab.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/device.h>
  19. #include <linux/printk.h>
  20. #include <linux/ratelimit.h>
  21. #include <linux/debugfs.h>
  22. #include <linux/wait.h>
  23. #include <linux/bitops.h>
  24. #include <linux/regmap.h>
  25. #include <linux/regulator/consumer.h>
  26. #include <linux/clk.h>
  27. #include <linux/delay.h>
  28. #include <linux/pm_runtime.h>
  29. #include <linux/kernel.h>
  30. #include <linux/gpio.h>
  31. #include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
  32. #include <soc/swr-wcd.h>
  33. #include <sound/pcm.h>
  34. #include <sound/pcm_params.h>
  35. #include <sound/soc.h>
  36. #include <sound/soc-dapm.h>
  37. #include <sound/tlv.h>
  38. #include <sound/info.h>
  39. #include "core.h"
  40. #include "pdata.h"
  41. #include "wcd9335.h"
  42. #include "wcd-mbhc-v2.h"
  43. #include "wcd9xxx-common-v2.h"
  44. #include "wcd9xxx-resmgr-v2.h"
  45. #include "wcd9xxx-irq.h"
  46. #include "wcd9335_registers.h"
  47. #include "wcd9335_irq.h"
  48. #include "wcd_cpe_core.h"
  49. #include "wcdcal-hwdep.h"
  50. #include "wcd-mbhc-v2-api.h"
  51. #define TASHA_RX_PORT_START_NUMBER 16
  52. #define WCD9335_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
  53. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
  54. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  55. /* Fractional Rates */
  56. #define WCD9335_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100)
  57. #define WCD9335_MIX_RATES_MASK (SNDRV_PCM_RATE_48000 |\
  58. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  59. #define TASHA_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  60. SNDRV_PCM_FMTBIT_S24_LE | \
  61. SNDRV_PCM_FMTBIT_S24_3LE)
  62. #define TASHA_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  63. SNDRV_PCM_FMTBIT_S24_LE | \
  64. SNDRV_PCM_FMTBIT_S24_3LE | \
  65. SNDRV_PCM_FMTBIT_S32_LE)
  66. #define TASHA_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
  67. /*
  68. * Timeout in milli seconds and it is the wait time for
  69. * slim channel removal interrupt to receive.
  70. */
  71. #define TASHA_SLIM_CLOSE_TIMEOUT 1000
  72. #define TASHA_SLIM_IRQ_OVERFLOW (1 << 0)
  73. #define TASHA_SLIM_IRQ_UNDERFLOW (1 << 1)
  74. #define TASHA_SLIM_IRQ_PORT_CLOSED (1 << 2)
  75. #define TASHA_MCLK_CLK_12P288MHZ 12288000
  76. #define TASHA_MCLK_CLK_9P6MHZ 9600000
  77. #define TASHA_SLIM_PGD_PORT_INT_TX_EN0 (TASHA_SLIM_PGD_PORT_INT_EN0 + 2)
  78. #define TASHA_NUM_INTERPOLATORS 9
  79. #define TASHA_NUM_DECIMATORS 9
  80. #define WCD9335_CHILD_DEVICES_MAX 6
  81. #define BYTE_BIT_MASK(nr) (1 << ((nr) % BITS_PER_BYTE))
  82. #define TASHA_MAD_AUDIO_FIRMWARE_PATH "wcd9335/wcd9335_mad_audio.bin"
  83. #define TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS (1 << 0)
  84. #define TASHA_CPE_SS_ERR_STATUS_WDOG_BITE (1 << 1)
  85. #define TASHA_CPE_FATAL_IRQS \
  86. (TASHA_CPE_SS_ERR_STATUS_WDOG_BITE | \
  87. TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS)
  88. #define SLIM_BW_CLK_GEAR_9 6200000
  89. #define SLIM_BW_UNVOTE 0
  90. #define CPE_FLL_CLK_75MHZ 75000000
  91. #define CPE_FLL_CLK_150MHZ 150000000
  92. #define WCD9335_REG_BITS 8
  93. #define WCD9335_MAX_VALID_ADC_MUX 13
  94. #define WCD9335_INVALID_ADC_MUX 9
  95. #define TASHA_DIG_CORE_REG_MIN WCD9335_CDC_ANC0_CLK_RESET_CTL
  96. #define TASHA_DIG_CORE_REG_MAX 0xDFF
  97. /* Convert from vout ctl to micbias voltage in mV */
  98. #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
  99. #define TASHA_ZDET_NUM_MEASUREMENTS 900
  100. #define TASHA_MBHC_GET_C1(c) ((c & 0xC000) >> 14)
  101. #define TASHA_MBHC_GET_X1(x) (x & 0x3FFF)
  102. /* z value compared in milliOhm */
  103. #define TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000))
  104. #define TASHA_MBHC_ZDET_CONST (86 * 16384)
  105. #define TASHA_MBHC_MOISTURE_VREF V_45_MV
  106. #define TASHA_MBHC_MOISTURE_IREF I_3P0_UA
  107. #define TASHA_VERSION_ENTRY_SIZE 17
  108. #define WCD9335_AMIC_PWR_LEVEL_LP 0
  109. #define WCD9335_AMIC_PWR_LEVEL_DEFAULT 1
  110. #define WCD9335_AMIC_PWR_LEVEL_HP 2
  111. #define WCD9335_AMIC_PWR_LVL_MASK 0x60
  112. #define WCD9335_AMIC_PWR_LVL_SHIFT 0x5
  113. #define WCD9335_DEC_PWR_LVL_MASK 0x06
  114. #define WCD9335_DEC_PWR_LVL_LP 0x02
  115. #define WCD9335_DEC_PWR_LVL_HP 0x04
  116. #define WCD9335_DEC_PWR_LVL_DF 0x00
  117. #define WCD9335_STRING_LEN 100
  118. #define CALCULATE_VOUT_D(req_mv) (((req_mv - 650) * 10) / 25)
  119. static int cpe_debug_mode;
  120. #define TASHA_MAX_MICBIAS 4
  121. #define DAPM_MICBIAS1_STANDALONE "MIC BIAS1 Standalone"
  122. #define DAPM_MICBIAS2_STANDALONE "MIC BIAS2 Standalone"
  123. #define DAPM_MICBIAS3_STANDALONE "MIC BIAS3 Standalone"
  124. #define DAPM_MICBIAS4_STANDALONE "MIC BIAS4 Standalone"
  125. #define DAPM_LDO_H_STANDALONE "LDO_H"
  126. module_param(cpe_debug_mode, int, 0664);
  127. MODULE_PARM_DESC(cpe_debug_mode, "boot cpe in debug mode");
  128. #define TASHA_DIG_CORE_COLLAPSE_TIMER_MS (5 * 1000)
  129. #define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH 64
  130. static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = {
  131. "cdc-vdd-mic-bias",
  132. };
  133. enum {
  134. POWER_COLLAPSE,
  135. POWER_RESUME,
  136. };
  137. enum tasha_sido_voltage {
  138. SIDO_VOLTAGE_SVS_MV = 950,
  139. SIDO_VOLTAGE_NOMINAL_MV = 1100,
  140. };
  141. static enum codec_variant codec_ver;
  142. static int dig_core_collapse_enable = 1;
  143. module_param(dig_core_collapse_enable, int, 0664);
  144. MODULE_PARM_DESC(dig_core_collapse_enable, "enable/disable power gating");
  145. /* dig_core_collapse timer in seconds */
  146. static int dig_core_collapse_timer = (TASHA_DIG_CORE_COLLAPSE_TIMER_MS/1000);
  147. module_param(dig_core_collapse_timer, int, 0664);
  148. MODULE_PARM_DESC(dig_core_collapse_timer, "timer for power gating");
  149. /* SVS Scaling enable/disable */
  150. static int svs_scaling_enabled = 1;
  151. module_param(svs_scaling_enabled, int, 0664);
  152. MODULE_PARM_DESC(svs_scaling_enabled, "enable/disable svs scaling");
  153. /* SVS buck setting */
  154. static int sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  155. module_param(sido_buck_svs_voltage, int, 0664);
  156. MODULE_PARM_DESC(sido_buck_svs_voltage,
  157. "setting for SVS voltage for SIDO BUCK");
  158. #define TASHA_TX_UNMUTE_DELAY_MS 40
  159. static int tx_unmute_delay = TASHA_TX_UNMUTE_DELAY_MS;
  160. module_param(tx_unmute_delay, int, 0664);
  161. MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path");
  162. static struct afe_param_slimbus_slave_port_cfg tasha_slimbus_slave_port_cfg = {
  163. .minor_version = 1,
  164. .slimbus_dev_id = AFE_SLIMBUS_DEVICE_1,
  165. .slave_dev_pgd_la = 0,
  166. .slave_dev_intfdev_la = 0,
  167. .bit_width = 16,
  168. .data_format = 0,
  169. .num_channels = 1
  170. };
  171. struct tasha_mbhc_zdet_param {
  172. u16 ldo_ctl;
  173. u16 noff;
  174. u16 nshift;
  175. u16 btn5;
  176. u16 btn6;
  177. u16 btn7;
  178. };
  179. static struct afe_param_cdc_reg_page_cfg tasha_cdc_reg_page_cfg = {
  180. .minor_version = AFE_API_VERSION_CDC_REG_PAGE_CFG,
  181. .enable = 1,
  182. .proc_id = AFE_CDC_REG_PAGE_ASSIGN_PROC_ID_1,
  183. };
  184. static struct afe_param_cdc_reg_cfg audio_reg_cfg[] = {
  185. {
  186. 1,
  187. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_MAIN_CTL_1),
  188. HW_MAD_AUDIO_ENABLE, 0x1, WCD9335_REG_BITS, 0
  189. },
  190. {
  191. 1,
  192. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_3),
  193. HW_MAD_AUDIO_SLEEP_TIME, 0xF, WCD9335_REG_BITS, 0
  194. },
  195. {
  196. 1,
  197. (TASHA_REGISTER_START_OFFSET + WCD9335_SOC_MAD_AUDIO_CTL_4),
  198. HW_MAD_TX_AUDIO_SWITCH_OFF, 0x1, WCD9335_REG_BITS, 0
  199. },
  200. {
  201. 1,
  202. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  203. MAD_AUDIO_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  204. },
  205. {
  206. 1,
  207. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  208. MAD_AUDIO_INT_MASK_REG, 0x1, WCD9335_REG_BITS, 0
  209. },
  210. {
  211. 1,
  212. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  213. MAD_AUDIO_INT_STATUS_REG, 0x1, WCD9335_REG_BITS, 0
  214. },
  215. {
  216. 1,
  217. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  218. MAD_AUDIO_INT_CLEAR_REG, 0x1, WCD9335_REG_BITS, 0
  219. },
  220. {
  221. 1,
  222. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  223. VBAT_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  224. },
  225. {
  226. 1,
  227. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  228. VBAT_INT_MASK_REG, 0x08, WCD9335_REG_BITS, 0
  229. },
  230. {
  231. 1,
  232. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  233. VBAT_INT_STATUS_REG, 0x08, WCD9335_REG_BITS, 0
  234. },
  235. {
  236. 1,
  237. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  238. VBAT_INT_CLEAR_REG, 0x08, WCD9335_REG_BITS, 0
  239. },
  240. {
  241. 1,
  242. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_CFG),
  243. VBAT_RELEASE_INT_DEST_SELECT_REG, 0x2, WCD9335_REG_BITS, 0
  244. },
  245. {
  246. 1,
  247. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_MASK3),
  248. VBAT_RELEASE_INT_MASK_REG, 0x10, WCD9335_REG_BITS, 0
  249. },
  250. {
  251. 1,
  252. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_STATUS3),
  253. VBAT_RELEASE_INT_STATUS_REG, 0x10, WCD9335_REG_BITS, 0
  254. },
  255. {
  256. 1,
  257. (TASHA_REGISTER_START_OFFSET + WCD9335_INTR_PIN2_CLEAR3),
  258. VBAT_RELEASE_INT_CLEAR_REG, 0x10, WCD9335_REG_BITS, 0
  259. },
  260. {
  261. 1,
  262. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  263. SB_PGD_PORT_TX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  264. },
  265. {
  266. 1,
  267. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_TX_BASE),
  268. SB_PGD_PORT_TX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  269. },
  270. {
  271. 1,
  272. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  273. SB_PGD_PORT_RX_WATERMARK_N, 0x1E, WCD9335_REG_BITS, 0x1
  274. },
  275. {
  276. 1,
  277. (TASHA_REGISTER_START_OFFSET + TASHA_SB_PGD_PORT_RX_BASE),
  278. SB_PGD_PORT_RX_ENABLE_N, 0x1, WCD9335_REG_BITS, 0x1
  279. },
  280. { 1,
  281. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  282. AANC_FF_GAIN_ADAPTIVE, 0x4, WCD9335_REG_BITS, 0
  283. },
  284. { 1,
  285. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_IIR_ADAPT_CTL),
  286. AANC_FFGAIN_ADAPTIVE_EN, 0x8, WCD9335_REG_BITS, 0
  287. },
  288. {
  289. 1,
  290. (TASHA_REGISTER_START_OFFSET + WCD9335_CDC_ANC0_FF_A_GAIN_CTL),
  291. AANC_GAIN_CONTROL, 0xFF, WCD9335_REG_BITS, 0
  292. },
  293. };
  294. static struct afe_param_cdc_reg_cfg_data tasha_audio_reg_cfg = {
  295. .num_registers = ARRAY_SIZE(audio_reg_cfg),
  296. .reg_data = audio_reg_cfg,
  297. };
  298. static struct afe_param_id_cdc_aanc_version tasha_cdc_aanc_version = {
  299. .cdc_aanc_minor_version = AFE_API_VERSION_CDC_AANC_VERSION,
  300. .aanc_hw_version = AANC_HW_BLOCK_VERSION_2,
  301. };
  302. enum {
  303. VI_SENSE_1,
  304. VI_SENSE_2,
  305. AIF4_SWITCH_VALUE,
  306. AUDIO_NOMINAL,
  307. CPE_NOMINAL,
  308. HPH_PA_DELAY,
  309. ANC_MIC_AMIC1,
  310. ANC_MIC_AMIC2,
  311. ANC_MIC_AMIC3,
  312. ANC_MIC_AMIC4,
  313. ANC_MIC_AMIC5,
  314. ANC_MIC_AMIC6,
  315. CLASSH_CONFIG,
  316. };
  317. enum {
  318. AIF1_PB = 0,
  319. AIF1_CAP,
  320. AIF2_PB,
  321. AIF2_CAP,
  322. AIF3_PB,
  323. AIF3_CAP,
  324. AIF4_PB,
  325. AIF_MIX1_PB,
  326. AIF4_MAD_TX,
  327. AIF4_VIFEED,
  328. AIF5_CPE_TX,
  329. NUM_CODEC_DAIS,
  330. };
  331. enum {
  332. INTn_1_MIX_INP_SEL_ZERO = 0,
  333. INTn_1_MIX_INP_SEL_DEC0,
  334. INTn_1_MIX_INP_SEL_DEC1,
  335. INTn_1_MIX_INP_SEL_IIR0,
  336. INTn_1_MIX_INP_SEL_IIR1,
  337. INTn_1_MIX_INP_SEL_RX0,
  338. INTn_1_MIX_INP_SEL_RX1,
  339. INTn_1_MIX_INP_SEL_RX2,
  340. INTn_1_MIX_INP_SEL_RX3,
  341. INTn_1_MIX_INP_SEL_RX4,
  342. INTn_1_MIX_INP_SEL_RX5,
  343. INTn_1_MIX_INP_SEL_RX6,
  344. INTn_1_MIX_INP_SEL_RX7,
  345. };
  346. #define IS_VALID_NATIVE_FIFO_PORT(inp) \
  347. ((inp >= INTn_1_MIX_INP_SEL_RX0) && \
  348. (inp <= INTn_1_MIX_INP_SEL_RX3))
  349. enum {
  350. INTn_2_INP_SEL_ZERO = 0,
  351. INTn_2_INP_SEL_RX0,
  352. INTn_2_INP_SEL_RX1,
  353. INTn_2_INP_SEL_RX2,
  354. INTn_2_INP_SEL_RX3,
  355. INTn_2_INP_SEL_RX4,
  356. INTn_2_INP_SEL_RX5,
  357. INTn_2_INP_SEL_RX6,
  358. INTn_2_INP_SEL_RX7,
  359. INTn_2_INP_SEL_PROXIMITY,
  360. };
  361. enum {
  362. INTERP_EAR = 0,
  363. INTERP_HPHL,
  364. INTERP_HPHR,
  365. INTERP_LO1,
  366. INTERP_LO2,
  367. INTERP_LO3,
  368. INTERP_LO4,
  369. INTERP_SPKR1,
  370. INTERP_SPKR2,
  371. };
  372. struct interp_sample_rate {
  373. int sample_rate;
  374. int rate_val;
  375. };
  376. static struct interp_sample_rate int_prim_sample_rate_val[] = {
  377. {8000, 0x0}, /* 8K */
  378. {16000, 0x1}, /* 16K */
  379. {24000, -EINVAL},/* 24K */
  380. {32000, 0x3}, /* 32K */
  381. {48000, 0x4}, /* 48K */
  382. {96000, 0x5}, /* 96K */
  383. {192000, 0x6}, /* 192K */
  384. {384000, 0x7}, /* 384K */
  385. {44100, 0x8}, /* 44.1K */
  386. };
  387. static struct interp_sample_rate int_mix_sample_rate_val[] = {
  388. {48000, 0x4}, /* 48K */
  389. {96000, 0x5}, /* 96K */
  390. {192000, 0x6}, /* 192K */
  391. };
  392. static const struct wcd9xxx_ch tasha_rx_chs[TASHA_RX_MAX] = {
  393. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER, 0),
  394. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 1, 1),
  395. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 2, 2),
  396. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 3, 3),
  397. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 4, 4),
  398. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 5, 5),
  399. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 6, 6),
  400. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 7, 7),
  401. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 8, 8),
  402. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 9, 9),
  403. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 10, 10),
  404. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 11, 11),
  405. WCD9XXX_CH(TASHA_RX_PORT_START_NUMBER + 12, 12),
  406. };
  407. static const struct wcd9xxx_ch tasha_tx_chs[TASHA_TX_MAX] = {
  408. WCD9XXX_CH(0, 0),
  409. WCD9XXX_CH(1, 1),
  410. WCD9XXX_CH(2, 2),
  411. WCD9XXX_CH(3, 3),
  412. WCD9XXX_CH(4, 4),
  413. WCD9XXX_CH(5, 5),
  414. WCD9XXX_CH(6, 6),
  415. WCD9XXX_CH(7, 7),
  416. WCD9XXX_CH(8, 8),
  417. WCD9XXX_CH(9, 9),
  418. WCD9XXX_CH(10, 10),
  419. WCD9XXX_CH(11, 11),
  420. WCD9XXX_CH(12, 12),
  421. WCD9XXX_CH(13, 13),
  422. WCD9XXX_CH(14, 14),
  423. WCD9XXX_CH(15, 15),
  424. };
  425. static const u32 vport_slim_check_table[NUM_CODEC_DAIS] = {
  426. /* Needs to define in the same order of DAI enum definitions */
  427. 0,
  428. BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  429. 0,
  430. BIT(AIF1_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  431. 0,
  432. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF4_MAD_TX) | BIT(AIF5_CPE_TX),
  433. 0,
  434. 0,
  435. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF5_CPE_TX),
  436. 0,
  437. BIT(AIF1_CAP) | BIT(AIF2_CAP) | BIT(AIF3_CAP) | BIT(AIF4_MAD_TX),
  438. };
  439. static const u32 vport_i2s_check_table[NUM_CODEC_DAIS] = {
  440. 0, /* AIF1_PB */
  441. BIT(AIF2_CAP), /* AIF1_CAP */
  442. 0, /* AIF2_PB */
  443. BIT(AIF1_CAP), /* AIF2_CAP */
  444. };
  445. /* Codec supports 2 IIR filters */
  446. enum {
  447. IIR0 = 0,
  448. IIR1,
  449. IIR_MAX,
  450. };
  451. /* Each IIR has 5 Filter Stages */
  452. enum {
  453. BAND1 = 0,
  454. BAND2,
  455. BAND3,
  456. BAND4,
  457. BAND5,
  458. BAND_MAX,
  459. };
  460. enum {
  461. COMPANDER_1, /* HPH_L */
  462. COMPANDER_2, /* HPH_R */
  463. COMPANDER_3, /* LO1_DIFF */
  464. COMPANDER_4, /* LO2_DIFF */
  465. COMPANDER_5, /* LO3_SE */
  466. COMPANDER_6, /* LO4_SE */
  467. COMPANDER_7, /* SWR SPK CH1 */
  468. COMPANDER_8, /* SWR SPK CH2 */
  469. COMPANDER_MAX,
  470. };
  471. enum {
  472. SRC_IN_HPHL,
  473. SRC_IN_LO1,
  474. SRC_IN_HPHR,
  475. SRC_IN_LO2,
  476. SRC_IN_SPKRL,
  477. SRC_IN_LO3,
  478. SRC_IN_SPKRR,
  479. SRC_IN_LO4,
  480. };
  481. enum {
  482. SPLINE_SRC0,
  483. SPLINE_SRC1,
  484. SPLINE_SRC2,
  485. SPLINE_SRC3,
  486. SPLINE_SRC_MAX,
  487. };
  488. static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
  489. static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
  490. static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
  491. static struct snd_soc_dai_driver tasha_dai[];
  492. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv);
  493. static int tasha_config_compander(struct snd_soc_codec *, int, int);
  494. static void tasha_codec_set_tx_hold(struct snd_soc_codec *, u16, bool);
  495. static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
  496. bool enable);
  497. /* Hold instance to soundwire platform device */
  498. struct tasha_swr_ctrl_data {
  499. struct platform_device *swr_pdev;
  500. struct ida swr_ida;
  501. };
  502. struct wcd_swr_ctrl_platform_data {
  503. void *handle; /* holds codec private data */
  504. int (*read)(void *handle, int reg);
  505. int (*write)(void *handle, int reg, int val);
  506. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  507. int (*clk)(void *handle, bool enable);
  508. int (*handle_irq)(void *handle,
  509. irqreturn_t (*swrm_irq_handler)(int irq,
  510. void *data),
  511. void *swrm_handle,
  512. int action);
  513. };
  514. static struct wcd_mbhc_register
  515. wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = {
  516. WCD_MBHC_REGISTER("WCD_MBHC_L_DET_EN",
  517. WCD9335_ANA_MBHC_MECH, 0x80, 7, 0),
  518. WCD_MBHC_REGISTER("WCD_MBHC_GND_DET_EN",
  519. WCD9335_ANA_MBHC_MECH, 0x40, 6, 0),
  520. WCD_MBHC_REGISTER("WCD_MBHC_MECH_DETECTION_TYPE",
  521. WCD9335_ANA_MBHC_MECH, 0x20, 5, 0),
  522. WCD_MBHC_REGISTER("WCD_MBHC_MIC_CLAMP_CTL",
  523. WCD9335_MBHC_PLUG_DETECT_CTL, 0x30, 4, 0),
  524. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_DETECTION_TYPE",
  525. WCD9335_ANA_MBHC_ELECT, 0x08, 3, 0),
  526. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_CTRL",
  527. WCD9335_MBHC_PLUG_DETECT_CTL, 0xC0, 6, 0),
  528. WCD_MBHC_REGISTER("WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL",
  529. WCD9335_ANA_MBHC_MECH, 0x04, 2, 0),
  530. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PLUG_TYPE",
  531. WCD9335_ANA_MBHC_MECH, 0x10, 4, 0),
  532. WCD_MBHC_REGISTER("WCD_MBHC_GND_PLUG_TYPE",
  533. WCD9335_ANA_MBHC_MECH, 0x08, 3, 0),
  534. WCD_MBHC_REGISTER("WCD_MBHC_SW_HPH_LP_100K_TO_GND",
  535. WCD9335_ANA_MBHC_MECH, 0x01, 0, 0),
  536. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_SCHMT_ISRC",
  537. WCD9335_ANA_MBHC_ELECT, 0x06, 1, 0),
  538. WCD_MBHC_REGISTER("WCD_MBHC_FSM_EN",
  539. WCD9335_ANA_MBHC_ELECT, 0x80, 7, 0),
  540. WCD_MBHC_REGISTER("WCD_MBHC_INSREM_DBNC",
  541. WCD9335_MBHC_PLUG_DETECT_CTL, 0x0F, 0, 0),
  542. WCD_MBHC_REGISTER("WCD_MBHC_BTN_DBNC",
  543. WCD9335_MBHC_CTL_1, 0x03, 0, 0),
  544. WCD_MBHC_REGISTER("WCD_MBHC_HS_VREF",
  545. WCD9335_MBHC_CTL_2, 0x03, 0, 0),
  546. WCD_MBHC_REGISTER("WCD_MBHC_HS_COMP_RESULT",
  547. WCD9335_ANA_MBHC_RESULT_3, 0x08, 3, 0),
  548. WCD_MBHC_REGISTER("WCD_MBHC_MIC_SCHMT_RESULT",
  549. WCD9335_ANA_MBHC_RESULT_3, 0x20, 5, 0),
  550. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_SCHMT_RESULT",
  551. WCD9335_ANA_MBHC_RESULT_3, 0x80, 7, 0),
  552. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_SCHMT_RESULT",
  553. WCD9335_ANA_MBHC_RESULT_3, 0x40, 6, 0),
  554. WCD_MBHC_REGISTER("WCD_MBHC_OCP_FSM_EN",
  555. WCD9335_HPH_OCP_CTL, 0x10, 4, 0),
  556. WCD_MBHC_REGISTER("WCD_MBHC_BTN_RESULT",
  557. WCD9335_ANA_MBHC_RESULT_3, 0x07, 0, 0),
  558. WCD_MBHC_REGISTER("WCD_MBHC_BTN_ISRC_CTL",
  559. WCD9335_ANA_MBHC_ELECT, 0x70, 4, 0),
  560. WCD_MBHC_REGISTER("WCD_MBHC_ELECT_RESULT",
  561. WCD9335_ANA_MBHC_RESULT_3, 0xFF, 0, 0),
  562. WCD_MBHC_REGISTER("WCD_MBHC_MICB_CTRL",
  563. WCD9335_ANA_MICB2, 0xC0, 6, 0),
  564. WCD_MBHC_REGISTER("WCD_MBHC_HPH_CNP_WG_TIME",
  565. WCD9335_HPH_CNP_WG_TIME, 0xFF, 0, 0),
  566. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_PA_EN",
  567. WCD9335_ANA_HPH, 0x40, 6, 0),
  568. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_PA_EN",
  569. WCD9335_ANA_HPH, 0x80, 7, 0),
  570. WCD_MBHC_REGISTER("WCD_MBHC_HPH_PA_EN",
  571. WCD9335_ANA_HPH, 0xC0, 6, 0),
  572. WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE",
  573. WCD9335_ANA_MBHC_RESULT_3, 0x10, 4, 0),
  574. WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL",
  575. 0, 0, 0, 0),
  576. WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN",
  577. WCD9335_ANA_MBHC_ZDET, 0x01, 0, 0),
  578. /*
  579. * MBHC FSM status register is only available in Tasha 2.0.
  580. * So, init with 0 later once the version is known, then values
  581. * will be updated.
  582. */
  583. WCD_MBHC_REGISTER("WCD_MBHC_FSM_STATUS",
  584. 0, 0, 0, 0),
  585. WCD_MBHC_REGISTER("WCD_MBHC_MUX_CTL",
  586. WCD9335_MBHC_CTL_2, 0x70, 4, 0),
  587. WCD_MBHC_REGISTER("WCD_MBHC_MOISTURE_STATUS",
  588. WCD9335_MBHC_FSM_STATUS, 0X20, 5, 0),
  589. WCD_MBHC_REGISTER("WCD_MBHC_HPHR_GND",
  590. WCD9335_HPH_PA_CTL2, 0x40, 6, 0),
  591. WCD_MBHC_REGISTER("WCD_MBHC_HPHL_GND",
  592. WCD9335_HPH_PA_CTL2, 0x10, 4, 0),
  593. };
  594. static const struct wcd_mbhc_intr intr_ids = {
  595. .mbhc_sw_intr = WCD9335_IRQ_MBHC_SW_DET,
  596. .mbhc_btn_press_intr = WCD9335_IRQ_MBHC_BUTTON_PRESS_DET,
  597. .mbhc_btn_release_intr = WCD9335_IRQ_MBHC_BUTTON_RELEASE_DET,
  598. .mbhc_hs_ins_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_LEG_DET,
  599. .mbhc_hs_rem_intr = WCD9335_IRQ_MBHC_ELECT_INS_REM_DET,
  600. .hph_left_ocp = WCD9335_IRQ_HPH_PA_OCPL_FAULT,
  601. .hph_right_ocp = WCD9335_IRQ_HPH_PA_OCPR_FAULT,
  602. };
  603. struct wcd_vbat {
  604. bool is_enabled;
  605. bool adc_config;
  606. /* Variables to cache Vbat ADC output values */
  607. u16 dcp1;
  608. u16 dcp2;
  609. };
  610. struct hpf_work {
  611. struct tasha_priv *tasha;
  612. u8 decimator;
  613. u8 hpf_cut_off_freq;
  614. struct delayed_work dwork;
  615. };
  616. #define WCD9335_SPK_ANC_EN_DELAY_MS 350
  617. static int spk_anc_en_delay = WCD9335_SPK_ANC_EN_DELAY_MS;
  618. module_param(spk_anc_en_delay, int, 0664);
  619. MODULE_PARM_DESC(spk_anc_en_delay, "delay to enable anc in speaker path");
  620. struct spk_anc_work {
  621. struct tasha_priv *tasha;
  622. struct delayed_work dwork;
  623. };
  624. struct tx_mute_work {
  625. struct tasha_priv *tasha;
  626. u8 decimator;
  627. struct delayed_work dwork;
  628. };
  629. struct tasha_priv {
  630. struct device *dev;
  631. struct wcd9xxx *wcd9xxx;
  632. struct snd_soc_codec *codec;
  633. u32 adc_count;
  634. u32 rx_bias_count;
  635. s32 dmic_0_1_clk_cnt;
  636. s32 dmic_2_3_clk_cnt;
  637. s32 dmic_4_5_clk_cnt;
  638. s32 ldo_h_users;
  639. s32 micb_ref[TASHA_MAX_MICBIAS];
  640. s32 pullup_ref[TASHA_MAX_MICBIAS];
  641. u32 anc_slot;
  642. bool anc_func;
  643. /* Vbat module */
  644. struct wcd_vbat vbat;
  645. /* cal info for codec */
  646. struct fw_info *fw_data;
  647. /*track tasha interface type*/
  648. u8 intf_type;
  649. /* num of slim ports required */
  650. struct wcd9xxx_codec_dai_data dai[NUM_CODEC_DAIS];
  651. /* SoundWire data structure */
  652. struct tasha_swr_ctrl_data *swr_ctrl_data;
  653. int nr;
  654. /*compander*/
  655. int comp_enabled[COMPANDER_MAX];
  656. /* Maintain the status of AUX PGA */
  657. int aux_pga_cnt;
  658. u8 aux_l_gain;
  659. u8 aux_r_gain;
  660. bool spkr_pa_widget_on;
  661. struct regulator *spkdrv_reg;
  662. struct regulator *spkdrv2_reg;
  663. bool mbhc_started;
  664. /* class h specific data */
  665. struct wcd_clsh_cdc_data clsh_d;
  666. struct afe_param_cdc_slimbus_slave_cfg slimbus_slave_cfg;
  667. /*
  668. * list used to save/restore registers at start and
  669. * end of impedance measurement
  670. */
  671. struct list_head reg_save_restore;
  672. /* handle to cpe core */
  673. struct wcd_cpe_core *cpe_core;
  674. u32 current_cpe_clk_freq;
  675. enum tasha_sido_voltage sido_voltage;
  676. int sido_ccl_cnt;
  677. u32 ana_rx_supplies;
  678. /* Multiplication factor used for impedance detection */
  679. int zdet_gain_mul_fact;
  680. /* to track the status */
  681. unsigned long status_mask;
  682. struct work_struct tasha_add_child_devices_work;
  683. struct wcd_swr_ctrl_platform_data swr_plat_data;
  684. /* Port values for Rx and Tx codec_dai */
  685. unsigned int rx_port_value[TASHA_RX_MAX];
  686. unsigned int tx_port_value;
  687. unsigned int vi_feed_value;
  688. /* Tasha Interpolator Mode Select for EAR, HPH_L and HPH_R */
  689. u32 hph_mode;
  690. u16 prim_int_users[TASHA_NUM_INTERPOLATORS];
  691. int spl_src_users[SPLINE_SRC_MAX];
  692. struct wcd9xxx_resmgr_v2 *resmgr;
  693. struct delayed_work power_gate_work;
  694. struct mutex power_lock;
  695. struct mutex sido_lock;
  696. /* mbhc module */
  697. struct wcd_mbhc mbhc;
  698. struct blocking_notifier_head notifier;
  699. struct mutex micb_lock;
  700. struct clk *wcd_ext_clk;
  701. struct clk *wcd_native_clk;
  702. struct mutex swr_read_lock;
  703. struct mutex swr_write_lock;
  704. struct mutex swr_clk_lock;
  705. int swr_clk_users;
  706. int native_clk_users;
  707. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high);
  708. struct snd_info_entry *entry;
  709. struct snd_info_entry *version_entry;
  710. int power_active_ref;
  711. struct on_demand_supply on_demand_list[ON_DEMAND_SUPPLIES_MAX];
  712. int (*machine_codec_event_cb)(struct snd_soc_codec *codec,
  713. enum wcd9335_codec_event);
  714. int spkr_gain_offset;
  715. int spkr_mode;
  716. int ear_spkr_gain;
  717. struct hpf_work tx_hpf_work[TASHA_NUM_DECIMATORS];
  718. struct tx_mute_work tx_mute_dwork[TASHA_NUM_DECIMATORS];
  719. struct spk_anc_work spk_anc_dwork;
  720. struct mutex codec_mutex;
  721. int hph_l_gain;
  722. int hph_r_gain;
  723. int rx_7_count;
  724. int rx_8_count;
  725. bool clk_mode;
  726. bool clk_internal;
  727. /* Lock to prevent multiple functions voting at same time */
  728. struct mutex sb_clk_gear_lock;
  729. /* Count for functions voting or un-voting */
  730. u32 ref_count;
  731. /* Lock to protect mclk enablement */
  732. struct mutex mclk_lock;
  733. struct platform_device *pdev_child_devices
  734. [WCD9335_CHILD_DEVICES_MAX];
  735. int child_count;
  736. };
  737. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  738. bool vote);
  739. static const struct tasha_reg_mask_val tasha_spkr_default[] = {
  740. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  741. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  742. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  743. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  744. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x50},
  745. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x50},
  746. };
  747. static const struct tasha_reg_mask_val tasha_spkr_mode1[] = {
  748. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x00},
  749. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x00},
  750. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x00},
  751. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x00},
  752. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x44},
  753. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x44},
  754. };
  755. /**
  756. * tasha_set_spkr_gain_offset - offset the speaker path
  757. * gain with the given offset value.
  758. *
  759. * @codec: codec instance
  760. * @offset: Indicates speaker path gain offset value.
  761. *
  762. * Returns 0 on success or -EINVAL on error.
  763. */
  764. int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
  765. {
  766. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  767. if (!priv)
  768. return -EINVAL;
  769. priv->spkr_gain_offset = offset;
  770. return 0;
  771. }
  772. EXPORT_SYMBOL(tasha_set_spkr_gain_offset);
  773. /**
  774. * tasha_set_spkr_mode - Configures speaker compander and smartboost
  775. * settings based on speaker mode.
  776. *
  777. * @codec: codec instance
  778. * @mode: Indicates speaker configuration mode.
  779. *
  780. * Returns 0 on success or -EINVAL on error.
  781. */
  782. int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode)
  783. {
  784. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  785. int i;
  786. const struct tasha_reg_mask_val *regs;
  787. int size;
  788. if (!priv)
  789. return -EINVAL;
  790. switch (mode) {
  791. case SPKR_MODE_1:
  792. regs = tasha_spkr_mode1;
  793. size = ARRAY_SIZE(tasha_spkr_mode1);
  794. break;
  795. default:
  796. regs = tasha_spkr_default;
  797. size = ARRAY_SIZE(tasha_spkr_default);
  798. break;
  799. }
  800. priv->spkr_mode = mode;
  801. for (i = 0; i < size; i++)
  802. snd_soc_update_bits(codec, regs[i].reg,
  803. regs[i].mask, regs[i].val);
  804. return 0;
  805. }
  806. EXPORT_SYMBOL(tasha_set_spkr_mode);
  807. static void tasha_enable_sido_buck(struct snd_soc_codec *codec)
  808. {
  809. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  810. snd_soc_update_bits(codec, WCD9335_ANA_RCO, 0x80, 0x80);
  811. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x02, 0x02);
  812. /* 100us sleep needed after IREF settings */
  813. usleep_range(100, 110);
  814. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x04, 0x04);
  815. /* 100us sleep needed after VREF settings */
  816. usleep_range(100, 110);
  817. tasha->resmgr->sido_input_src = SIDO_SOURCE_RCO_BG;
  818. }
  819. static void tasha_cdc_sido_ccl_enable(struct tasha_priv *tasha, bool ccl_flag)
  820. {
  821. struct snd_soc_codec *codec = tasha->codec;
  822. if (!codec)
  823. return;
  824. if (!TASHA_IS_2_0(tasha->wcd9xxx)) {
  825. dev_dbg(codec->dev, "%s: tasha version < 2p0, return\n",
  826. __func__);
  827. return;
  828. }
  829. dev_dbg(codec->dev, "%s: sido_ccl_cnt=%d, ccl_flag:%d\n",
  830. __func__, tasha->sido_ccl_cnt, ccl_flag);
  831. if (ccl_flag) {
  832. if (++tasha->sido_ccl_cnt == 1)
  833. snd_soc_update_bits(codec,
  834. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x6E);
  835. } else {
  836. if (tasha->sido_ccl_cnt == 0) {
  837. dev_dbg(codec->dev, "%s: sido_ccl already disabled\n",
  838. __func__);
  839. return;
  840. }
  841. if (--tasha->sido_ccl_cnt == 0)
  842. snd_soc_update_bits(codec,
  843. WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x02);
  844. }
  845. }
  846. static bool tasha_cdc_is_svs_enabled(struct tasha_priv *tasha)
  847. {
  848. if (TASHA_IS_2_0(tasha->wcd9xxx) &&
  849. svs_scaling_enabled)
  850. return true;
  851. return false;
  852. }
  853. static int tasha_cdc_req_mclk_enable(struct tasha_priv *tasha,
  854. bool enable)
  855. {
  856. int ret = 0;
  857. mutex_lock(&tasha->mclk_lock);
  858. if (enable) {
  859. tasha_cdc_sido_ccl_enable(tasha, true);
  860. ret = clk_prepare_enable(tasha->wcd_ext_clk);
  861. if (ret) {
  862. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  863. __func__);
  864. goto unlock_mutex;
  865. }
  866. /* get BG */
  867. wcd_resmgr_enable_master_bias(tasha->resmgr);
  868. /* get MCLK */
  869. wcd_resmgr_enable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  870. } else {
  871. /* put MCLK */
  872. wcd_resmgr_disable_clk_block(tasha->resmgr, WCD_CLK_MCLK);
  873. /* put BG */
  874. wcd_resmgr_disable_master_bias(tasha->resmgr);
  875. clk_disable_unprepare(tasha->wcd_ext_clk);
  876. tasha_cdc_sido_ccl_enable(tasha, false);
  877. }
  878. unlock_mutex:
  879. mutex_unlock(&tasha->mclk_lock);
  880. return ret;
  881. }
  882. static int tasha_cdc_check_sido_value(enum tasha_sido_voltage req_mv)
  883. {
  884. if ((req_mv != SIDO_VOLTAGE_SVS_MV) &&
  885. (req_mv != SIDO_VOLTAGE_NOMINAL_MV))
  886. return -EINVAL;
  887. return 0;
  888. }
  889. static void tasha_codec_apply_sido_voltage(
  890. struct tasha_priv *tasha,
  891. enum tasha_sido_voltage req_mv)
  892. {
  893. u32 vout_d_val;
  894. struct snd_soc_codec *codec = tasha->codec;
  895. int ret;
  896. if (!codec)
  897. return;
  898. if (!tasha_cdc_is_svs_enabled(tasha))
  899. return;
  900. if ((sido_buck_svs_voltage != SIDO_VOLTAGE_SVS_MV) &&
  901. (sido_buck_svs_voltage != SIDO_VOLTAGE_NOMINAL_MV))
  902. sido_buck_svs_voltage = SIDO_VOLTAGE_SVS_MV;
  903. ret = tasha_cdc_check_sido_value(req_mv);
  904. if (ret < 0) {
  905. dev_dbg(codec->dev, "%s: requested mv=%d not in range\n",
  906. __func__, req_mv);
  907. return;
  908. }
  909. if (req_mv == tasha->sido_voltage) {
  910. dev_dbg(codec->dev, "%s: Already at requested mv=%d\n",
  911. __func__, req_mv);
  912. return;
  913. }
  914. if (req_mv == sido_buck_svs_voltage) {
  915. if (test_bit(AUDIO_NOMINAL, &tasha->status_mask) ||
  916. test_bit(CPE_NOMINAL, &tasha->status_mask)) {
  917. dev_dbg(codec->dev,
  918. "%s: nominal client running, status_mask=%lu\n",
  919. __func__, tasha->status_mask);
  920. return;
  921. }
  922. }
  923. /* compute the vout_d step value */
  924. vout_d_val = CALCULATE_VOUT_D(req_mv);
  925. snd_soc_write(codec, WCD9335_ANA_BUCK_VOUT_D, vout_d_val & 0xFF);
  926. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x80, 0x80);
  927. /* 1 msec sleep required after SIDO Vout_D voltage change */
  928. usleep_range(1000, 1100);
  929. tasha->sido_voltage = req_mv;
  930. dev_dbg(codec->dev,
  931. "%s: updated SIDO buck Vout_D to %d, vout_d step = %u\n",
  932. __func__, tasha->sido_voltage, vout_d_val);
  933. snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL,
  934. 0x80, 0x00);
  935. }
  936. static int tasha_codec_update_sido_voltage(
  937. struct tasha_priv *tasha,
  938. enum tasha_sido_voltage req_mv)
  939. {
  940. int ret = 0;
  941. if (!tasha_cdc_is_svs_enabled(tasha))
  942. return ret;
  943. mutex_lock(&tasha->sido_lock);
  944. /* enable mclk before setting SIDO voltage */
  945. ret = tasha_cdc_req_mclk_enable(tasha, true);
  946. if (ret) {
  947. dev_err(tasha->dev, "%s: ext clk enable failed\n",
  948. __func__);
  949. goto err;
  950. }
  951. tasha_codec_apply_sido_voltage(tasha, req_mv);
  952. tasha_cdc_req_mclk_enable(tasha, false);
  953. err:
  954. mutex_unlock(&tasha->sido_lock);
  955. return ret;
  956. }
  957. int tasha_enable_efuse_sensing(struct snd_soc_codec *codec)
  958. {
  959. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  960. tasha_cdc_mclk_enable(codec, true, false);
  961. if (!TASHA_IS_2_0(priv->wcd9xxx))
  962. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  963. 0x1E, 0x02);
  964. snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL,
  965. 0x01, 0x01);
  966. /*
  967. * 5ms sleep required after enabling efuse control
  968. * before checking the status.
  969. */
  970. usleep_range(5000, 5500);
  971. if (!(snd_soc_read(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01))
  972. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  973. if (TASHA_IS_2_0(priv->wcd9xxx)) {
  974. if (!(snd_soc_read(codec,
  975. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0) & 0x40))
  976. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST,
  977. 0x04, 0x00);
  978. tasha_enable_sido_buck(codec);
  979. }
  980. tasha_cdc_mclk_enable(codec, false, false);
  981. return 0;
  982. }
  983. EXPORT_SYMBOL(tasha_enable_efuse_sensing);
  984. void *tasha_get_afe_config(struct snd_soc_codec *codec,
  985. enum afe_config_type config_type)
  986. {
  987. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  988. switch (config_type) {
  989. case AFE_SLIMBUS_SLAVE_CONFIG:
  990. return &priv->slimbus_slave_cfg;
  991. case AFE_CDC_REGISTERS_CONFIG:
  992. return &tasha_audio_reg_cfg;
  993. case AFE_SLIMBUS_SLAVE_PORT_CONFIG:
  994. return &tasha_slimbus_slave_port_cfg;
  995. case AFE_AANC_VERSION:
  996. return &tasha_cdc_aanc_version;
  997. case AFE_CLIP_BANK_SEL:
  998. return NULL;
  999. case AFE_CDC_CLIP_REGISTERS_CONFIG:
  1000. return NULL;
  1001. case AFE_CDC_REGISTER_PAGE_CONFIG:
  1002. return &tasha_cdc_reg_page_cfg;
  1003. default:
  1004. dev_err(codec->dev, "%s: Unknown config_type 0x%x\n",
  1005. __func__, config_type);
  1006. return NULL;
  1007. }
  1008. }
  1009. EXPORT_SYMBOL(tasha_get_afe_config);
  1010. /*
  1011. * tasha_event_register: Registers a machine driver callback
  1012. * function with codec private data for post ADSP sub-system
  1013. * restart (SSR). This callback function will be called from
  1014. * codec driver once codec comes out of reset after ADSP SSR.
  1015. *
  1016. * @machine_event_cb: callback function from machine driver
  1017. * @codec: Codec instance
  1018. *
  1019. * Return: none
  1020. */
  1021. void tasha_event_register(
  1022. int (*machine_event_cb)(struct snd_soc_codec *codec,
  1023. enum wcd9335_codec_event),
  1024. struct snd_soc_codec *codec)
  1025. {
  1026. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1027. if (tasha)
  1028. tasha->machine_codec_event_cb = machine_event_cb;
  1029. else
  1030. dev_dbg(codec->dev, "%s: Invalid tasha_priv data\n", __func__);
  1031. }
  1032. EXPORT_SYMBOL(tasha_event_register);
  1033. static int tasha_mbhc_request_irq(struct snd_soc_codec *codec,
  1034. int irq, irq_handler_t handler,
  1035. const char *name, void *data)
  1036. {
  1037. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1038. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1039. struct wcd9xxx_core_resource *core_res =
  1040. &wcd9xxx->core_res;
  1041. return wcd9xxx_request_irq(core_res, irq, handler, name, data);
  1042. }
  1043. static void tasha_mbhc_irq_control(struct snd_soc_codec *codec,
  1044. int irq, bool enable)
  1045. {
  1046. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1047. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1048. struct wcd9xxx_core_resource *core_res =
  1049. &wcd9xxx->core_res;
  1050. if (enable)
  1051. wcd9xxx_enable_irq(core_res, irq);
  1052. else
  1053. wcd9xxx_disable_irq(core_res, irq);
  1054. }
  1055. static int tasha_mbhc_free_irq(struct snd_soc_codec *codec,
  1056. int irq, void *data)
  1057. {
  1058. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1059. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1060. struct wcd9xxx_core_resource *core_res =
  1061. &wcd9xxx->core_res;
  1062. wcd9xxx_free_irq(core_res, irq, data);
  1063. return 0;
  1064. }
  1065. static void tasha_mbhc_clk_setup(struct snd_soc_codec *codec,
  1066. bool enable)
  1067. {
  1068. if (enable)
  1069. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1070. 0x80, 0x80);
  1071. else
  1072. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1,
  1073. 0x80, 0x00);
  1074. }
  1075. static int tasha_mbhc_btn_to_num(struct snd_soc_codec *codec)
  1076. {
  1077. return snd_soc_read(codec, WCD9335_ANA_MBHC_RESULT_3) & 0x7;
  1078. }
  1079. static void tasha_mbhc_mbhc_bias_control(struct snd_soc_codec *codec,
  1080. bool enable)
  1081. {
  1082. if (enable)
  1083. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1084. 0x01, 0x01);
  1085. else
  1086. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT,
  1087. 0x01, 0x00);
  1088. }
  1089. static void tasha_mbhc_program_btn_thr(struct snd_soc_codec *codec,
  1090. s16 *btn_low, s16 *btn_high,
  1091. int num_btn, bool is_micbias)
  1092. {
  1093. int i;
  1094. int vth;
  1095. if (num_btn > WCD_MBHC_DEF_BUTTONS) {
  1096. dev_err(codec->dev, "%s: invalid number of buttons: %d\n",
  1097. __func__, num_btn);
  1098. return;
  1099. }
  1100. /*
  1101. * Tasha just needs one set of thresholds for button detection
  1102. * due to micbias voltage ramp to pullup upon button press. So
  1103. * btn_low and is_micbias are ignored and always program button
  1104. * thresholds using btn_high.
  1105. */
  1106. for (i = 0; i < num_btn; i++) {
  1107. vth = ((btn_high[i] * 2) / 25) & 0x3F;
  1108. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN0 + i,
  1109. 0xFC, vth << 2);
  1110. dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
  1111. __func__, i, btn_high[i], vth);
  1112. }
  1113. }
  1114. static bool tasha_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
  1115. {
  1116. struct snd_soc_codec *codec = mbhc->codec;
  1117. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1118. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1119. struct wcd9xxx_core_resource *core_res =
  1120. &wcd9xxx->core_res;
  1121. if (lock)
  1122. return wcd9xxx_lock_sleep(core_res);
  1123. else {
  1124. wcd9xxx_unlock_sleep(core_res);
  1125. return 0;
  1126. }
  1127. }
  1128. static int tasha_mbhc_register_notifier(struct wcd_mbhc *mbhc,
  1129. struct notifier_block *nblock,
  1130. bool enable)
  1131. {
  1132. struct snd_soc_codec *codec = mbhc->codec;
  1133. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1134. if (enable)
  1135. return blocking_notifier_chain_register(&tasha->notifier,
  1136. nblock);
  1137. else
  1138. return blocking_notifier_chain_unregister(&tasha->notifier,
  1139. nblock);
  1140. }
  1141. static bool tasha_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
  1142. {
  1143. u8 val;
  1144. if (micb_num == MIC_BIAS_2) {
  1145. val = (snd_soc_read(mbhc->codec, WCD9335_ANA_MICB2) >> 6);
  1146. if (val == 0x01)
  1147. return true;
  1148. }
  1149. return false;
  1150. }
  1151. static bool tasha_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
  1152. {
  1153. return (snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0) ? true : false;
  1154. }
  1155. static void tasha_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec,
  1156. enum mbhc_hs_pullup_iref pull_up_cur)
  1157. {
  1158. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1159. if (!tasha)
  1160. return;
  1161. /* Default pull up current to 2uA */
  1162. if (pull_up_cur < I_OFF || pull_up_cur > I_3P0_UA ||
  1163. pull_up_cur == I_DEFAULT)
  1164. pull_up_cur = I_2P0_UA;
  1165. dev_dbg(codec->dev, "%s: HS pull up current:%d\n",
  1166. __func__, pull_up_cur);
  1167. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1168. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1169. 0xC0, pull_up_cur << 6);
  1170. else
  1171. snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL,
  1172. 0xC0, 0x40);
  1173. }
  1174. static int tasha_enable_ext_mb_source(struct wcd_mbhc *mbhc,
  1175. bool turn_on)
  1176. {
  1177. struct snd_soc_codec *codec = mbhc->codec;
  1178. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1179. int ret = 0;
  1180. struct on_demand_supply *supply;
  1181. if (!tasha)
  1182. return -EINVAL;
  1183. supply = &tasha->on_demand_list[ON_DEMAND_MICBIAS];
  1184. if (!supply->supply) {
  1185. dev_dbg(codec->dev, "%s: warning supply not present ond for %s\n",
  1186. __func__, "onDemand Micbias");
  1187. return ret;
  1188. }
  1189. dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
  1190. supply->ondemand_supply_count);
  1191. if (turn_on) {
  1192. if (!(supply->ondemand_supply_count)) {
  1193. ret = snd_soc_dapm_force_enable_pin(
  1194. snd_soc_codec_get_dapm(codec),
  1195. "MICBIAS_REGULATOR");
  1196. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1197. }
  1198. supply->ondemand_supply_count++;
  1199. } else {
  1200. if (supply->ondemand_supply_count > 0)
  1201. supply->ondemand_supply_count--;
  1202. if (!(supply->ondemand_supply_count)) {
  1203. ret = snd_soc_dapm_disable_pin(
  1204. snd_soc_codec_get_dapm(codec),
  1205. "MICBIAS_REGULATOR");
  1206. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  1207. }
  1208. }
  1209. if (ret)
  1210. dev_err(codec->dev, "%s: Failed to %s external micbias source\n",
  1211. __func__, turn_on ? "enable" : "disabled");
  1212. else
  1213. dev_dbg(codec->dev, "%s: %s external micbias source\n",
  1214. __func__, turn_on ? "Enabled" : "Disabled");
  1215. return ret;
  1216. }
  1217. static int tasha_micbias_control(struct snd_soc_codec *codec,
  1218. int micb_num,
  1219. int req, bool is_dapm)
  1220. {
  1221. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1222. int micb_index = micb_num - 1;
  1223. u16 micb_reg;
  1224. int pre_off_event = 0, post_off_event = 0;
  1225. int post_on_event = 0, post_dapm_off = 0;
  1226. int post_dapm_on = 0;
  1227. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  1228. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  1229. __func__, micb_index);
  1230. return -EINVAL;
  1231. }
  1232. switch (micb_num) {
  1233. case MIC_BIAS_1:
  1234. micb_reg = WCD9335_ANA_MICB1;
  1235. break;
  1236. case MIC_BIAS_2:
  1237. micb_reg = WCD9335_ANA_MICB2;
  1238. pre_off_event = WCD_EVENT_PRE_MICBIAS_2_OFF;
  1239. post_off_event = WCD_EVENT_POST_MICBIAS_2_OFF;
  1240. post_on_event = WCD_EVENT_POST_MICBIAS_2_ON;
  1241. post_dapm_on = WCD_EVENT_POST_DAPM_MICBIAS_2_ON;
  1242. post_dapm_off = WCD_EVENT_POST_DAPM_MICBIAS_2_OFF;
  1243. break;
  1244. case MIC_BIAS_3:
  1245. micb_reg = WCD9335_ANA_MICB3;
  1246. break;
  1247. case MIC_BIAS_4:
  1248. micb_reg = WCD9335_ANA_MICB4;
  1249. break;
  1250. default:
  1251. dev_err(codec->dev, "%s: Invalid micbias number: %d\n",
  1252. __func__, micb_num);
  1253. return -EINVAL;
  1254. }
  1255. mutex_lock(&tasha->micb_lock);
  1256. switch (req) {
  1257. case MICB_PULLUP_ENABLE:
  1258. tasha->pullup_ref[micb_index]++;
  1259. if ((tasha->pullup_ref[micb_index] == 1) &&
  1260. (tasha->micb_ref[micb_index] == 0))
  1261. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1262. break;
  1263. case MICB_PULLUP_DISABLE:
  1264. if (tasha->pullup_ref[micb_index] > 0)
  1265. tasha->pullup_ref[micb_index]--;
  1266. if ((tasha->pullup_ref[micb_index] == 0) &&
  1267. (tasha->micb_ref[micb_index] == 0))
  1268. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1269. break;
  1270. case MICB_ENABLE:
  1271. tasha->micb_ref[micb_index]++;
  1272. if (tasha->micb_ref[micb_index] == 1) {
  1273. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1274. if (post_on_event)
  1275. blocking_notifier_call_chain(&tasha->notifier,
  1276. post_on_event, &tasha->mbhc);
  1277. }
  1278. if (is_dapm && post_dapm_on)
  1279. blocking_notifier_call_chain(&tasha->notifier,
  1280. post_dapm_on, &tasha->mbhc);
  1281. break;
  1282. case MICB_DISABLE:
  1283. if (tasha->micb_ref[micb_index] > 0)
  1284. tasha->micb_ref[micb_index]--;
  1285. if ((tasha->micb_ref[micb_index] == 0) &&
  1286. (tasha->pullup_ref[micb_index] > 0))
  1287. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1288. else if ((tasha->micb_ref[micb_index] == 0) &&
  1289. (tasha->pullup_ref[micb_index] == 0)) {
  1290. if (pre_off_event)
  1291. blocking_notifier_call_chain(&tasha->notifier,
  1292. pre_off_event, &tasha->mbhc);
  1293. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1294. if (post_off_event)
  1295. blocking_notifier_call_chain(&tasha->notifier,
  1296. post_off_event, &tasha->mbhc);
  1297. }
  1298. if (is_dapm && post_dapm_off)
  1299. blocking_notifier_call_chain(&tasha->notifier,
  1300. post_dapm_off, &tasha->mbhc);
  1301. break;
  1302. };
  1303. dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n",
  1304. __func__, micb_num, tasha->micb_ref[micb_index],
  1305. tasha->pullup_ref[micb_index]);
  1306. mutex_unlock(&tasha->micb_lock);
  1307. return 0;
  1308. }
  1309. static int tasha_mbhc_request_micbias(struct snd_soc_codec *codec,
  1310. int micb_num, int req)
  1311. {
  1312. int ret;
  1313. /*
  1314. * If micbias is requested, make sure that there
  1315. * is vote to enable mclk
  1316. */
  1317. if (req == MICB_ENABLE)
  1318. tasha_cdc_mclk_enable(codec, true, false);
  1319. ret = tasha_micbias_control(codec, micb_num, req, false);
  1320. /*
  1321. * Release vote for mclk while requesting for
  1322. * micbias disable
  1323. */
  1324. if (req == MICB_DISABLE)
  1325. tasha_cdc_mclk_enable(codec, false, false);
  1326. return ret;
  1327. }
  1328. static void tasha_mbhc_micb_ramp_control(struct snd_soc_codec *codec,
  1329. bool enable)
  1330. {
  1331. if (enable) {
  1332. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1333. 0x1C, 0x0C);
  1334. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1335. 0x80, 0x80);
  1336. } else {
  1337. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1338. 0x80, 0x00);
  1339. snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP,
  1340. 0x1C, 0x00);
  1341. }
  1342. }
  1343. static struct firmware_cal *tasha_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
  1344. enum wcd_cal_type type)
  1345. {
  1346. struct tasha_priv *tasha;
  1347. struct firmware_cal *hwdep_cal;
  1348. struct snd_soc_codec *codec = mbhc->codec;
  1349. if (!codec) {
  1350. pr_err("%s: NULL codec pointer\n", __func__);
  1351. return NULL;
  1352. }
  1353. tasha = snd_soc_codec_get_drvdata(codec);
  1354. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, type);
  1355. if (!hwdep_cal)
  1356. dev_err(codec->dev, "%s: cal not sent by %d\n",
  1357. __func__, type);
  1358. return hwdep_cal;
  1359. }
  1360. static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
  1361. int req_volt,
  1362. int micb_num)
  1363. {
  1364. int cur_vout_ctl, req_vout_ctl;
  1365. int micb_reg, micb_val, micb_en;
  1366. switch (micb_num) {
  1367. case MIC_BIAS_1:
  1368. micb_reg = WCD9335_ANA_MICB1;
  1369. break;
  1370. case MIC_BIAS_2:
  1371. micb_reg = WCD9335_ANA_MICB2;
  1372. break;
  1373. case MIC_BIAS_3:
  1374. micb_reg = WCD9335_ANA_MICB3;
  1375. break;
  1376. case MIC_BIAS_4:
  1377. micb_reg = WCD9335_ANA_MICB4;
  1378. break;
  1379. default:
  1380. return -EINVAL;
  1381. }
  1382. /*
  1383. * If requested micbias voltage is same as current micbias
  1384. * voltage, then just return. Otherwise, adjust voltage as
  1385. * per requested value. If micbias is already enabled, then
  1386. * to avoid slow micbias ramp-up or down enable pull-up
  1387. * momentarily, change the micbias value and then re-enable
  1388. * micbias.
  1389. */
  1390. micb_val = snd_soc_read(codec, micb_reg);
  1391. micb_en = (micb_val & 0xC0) >> 6;
  1392. cur_vout_ctl = micb_val & 0x3F;
  1393. req_vout_ctl = wcd9335_get_micb_vout_ctl_val(req_volt);
  1394. if (req_vout_ctl < 0)
  1395. return -EINVAL;
  1396. if (cur_vout_ctl == req_vout_ctl)
  1397. return 0;
  1398. dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n",
  1399. __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl),
  1400. req_volt, micb_en);
  1401. if (micb_en == 0x1)
  1402. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1403. snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl);
  1404. if (micb_en == 0x1) {
  1405. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1406. /*
  1407. * Add 2ms delay as per HW requirement after enabling
  1408. * micbias
  1409. */
  1410. usleep_range(2000, 2100);
  1411. }
  1412. return 0;
  1413. }
  1414. static int tasha_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
  1415. int micb_num, bool req_en)
  1416. {
  1417. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1418. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  1419. int rc, micb_mv;
  1420. if (micb_num != MIC_BIAS_2)
  1421. return -EINVAL;
  1422. /*
  1423. * If device tree micbias level is already above the minimum
  1424. * voltage needed to detect threshold microphone, then do
  1425. * not change the micbias, just return.
  1426. */
  1427. if (pdata->micbias.micb2_mv >= WCD_MBHC_THR_HS_MICB_MV)
  1428. return 0;
  1429. micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv;
  1430. mutex_lock(&tasha->micb_lock);
  1431. rc = tasha_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2);
  1432. mutex_unlock(&tasha->micb_lock);
  1433. return rc;
  1434. }
  1435. static inline void tasha_mbhc_get_result_params(struct wcd9xxx *wcd9xxx,
  1436. s16 *d1_a, u16 noff,
  1437. int32_t *zdet)
  1438. {
  1439. int i;
  1440. int val, val1;
  1441. s16 c1;
  1442. s32 x1, d1;
  1443. int32_t denom;
  1444. int minCode_param[] = {
  1445. 3277, 1639, 820, 410, 205, 103, 52, 26
  1446. };
  1447. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x20);
  1448. for (i = 0; i < TASHA_ZDET_NUM_MEASUREMENTS; i++) {
  1449. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_2, &val);
  1450. if (val & 0x80)
  1451. break;
  1452. }
  1453. val = val << 0x8;
  1454. regmap_read(wcd9xxx->regmap, WCD9335_ANA_MBHC_RESULT_1, &val1);
  1455. val |= val1;
  1456. regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ZDET, 0x20, 0x00);
  1457. x1 = TASHA_MBHC_GET_X1(val);
  1458. c1 = TASHA_MBHC_GET_C1(val);
  1459. /* If ramp is not complete, give additional 5ms */
  1460. if ((c1 < 2) && x1)
  1461. usleep_range(5000, 5050);
  1462. if (!c1 || !x1) {
  1463. dev_dbg(wcd9xxx->dev,
  1464. "%s: Impedance detect ramp error, c1=%d, x1=0x%x\n",
  1465. __func__, c1, x1);
  1466. goto ramp_down;
  1467. }
  1468. d1 = d1_a[c1];
  1469. denom = (x1 * d1) - (1 << (14 - noff));
  1470. if (denom > 0)
  1471. *zdet = (TASHA_MBHC_ZDET_CONST * 1000) / denom;
  1472. else if (x1 < minCode_param[noff])
  1473. *zdet = TASHA_ZDET_FLOATING_IMPEDANCE;
  1474. dev_dbg(wcd9xxx->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%d(milliOhm)\n",
  1475. __func__, d1, c1, x1, *zdet);
  1476. ramp_down:
  1477. i = 0;
  1478. while (x1) {
  1479. regmap_bulk_read(wcd9xxx->regmap,
  1480. WCD9335_ANA_MBHC_RESULT_1, (u8 *)&val, 2);
  1481. x1 = TASHA_MBHC_GET_X1(val);
  1482. i++;
  1483. if (i == TASHA_ZDET_NUM_MEASUREMENTS)
  1484. break;
  1485. }
  1486. }
  1487. /*
  1488. * tasha_mbhc_zdet_gpio_ctrl: Register callback function for
  1489. * controlling the switch on hifi amps. Default switch state
  1490. * will put a 51ohm load in parallel to the hph load. So,
  1491. * impedance detection function will pull the gpio high
  1492. * to make the switch open.
  1493. *
  1494. * @zdet_gpio_cb: callback function from machine driver
  1495. * @codec: Codec instance
  1496. *
  1497. * Return: none
  1498. */
  1499. void tasha_mbhc_zdet_gpio_ctrl(
  1500. int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
  1501. struct snd_soc_codec *codec)
  1502. {
  1503. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1504. tasha->zdet_gpio_cb = zdet_gpio_cb;
  1505. }
  1506. EXPORT_SYMBOL(tasha_mbhc_zdet_gpio_ctrl);
  1507. static void tasha_mbhc_zdet_ramp(struct snd_soc_codec *codec,
  1508. struct tasha_mbhc_zdet_param *zdet_param,
  1509. int32_t *zl, int32_t *zr, s16 *d1_a)
  1510. {
  1511. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  1512. int32_t zdet = 0;
  1513. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x70,
  1514. zdet_param->ldo_ctl << 4);
  1515. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN5, 0xFC,
  1516. zdet_param->btn5);
  1517. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN6, 0xFC,
  1518. zdet_param->btn6);
  1519. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN7, 0xFC,
  1520. zdet_param->btn7);
  1521. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x0F,
  1522. zdet_param->noff);
  1523. snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x0F,
  1524. zdet_param->nshift);
  1525. if (!zl)
  1526. goto z_right;
  1527. /* Start impedance measurement for HPH_L */
  1528. regmap_update_bits(wcd9xxx->regmap,
  1529. WCD9335_ANA_MBHC_ZDET, 0x80, 0x80);
  1530. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_L, noff = %d\n",
  1531. __func__, zdet_param->noff);
  1532. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1533. regmap_update_bits(wcd9xxx->regmap,
  1534. WCD9335_ANA_MBHC_ZDET, 0x80, 0x00);
  1535. *zl = zdet;
  1536. z_right:
  1537. if (!zr)
  1538. return;
  1539. /* Start impedance measurement for HPH_R */
  1540. regmap_update_bits(wcd9xxx->regmap,
  1541. WCD9335_ANA_MBHC_ZDET, 0x40, 0x40);
  1542. dev_dbg(wcd9xxx->dev, "%s: ramp for HPH_R, noff = %d\n",
  1543. __func__, zdet_param->noff);
  1544. tasha_mbhc_get_result_params(wcd9xxx, d1_a, zdet_param->noff, &zdet);
  1545. regmap_update_bits(wcd9xxx->regmap,
  1546. WCD9335_ANA_MBHC_ZDET, 0x40, 0x00);
  1547. *zr = zdet;
  1548. }
  1549. static inline void tasha_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
  1550. int32_t *z_val, int flag_l_r)
  1551. {
  1552. s16 q1;
  1553. int q1_cal;
  1554. if (*z_val < (TASHA_ZDET_VAL_400/1000))
  1555. q1 = snd_soc_read(codec,
  1556. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r));
  1557. else
  1558. q1 = snd_soc_read(codec,
  1559. WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r));
  1560. if (q1 & 0x80)
  1561. q1_cal = (10000 - ((q1 & 0x7F) * 25));
  1562. else
  1563. q1_cal = (10000 + (q1 * 25));
  1564. if (q1_cal > 0)
  1565. *z_val = ((*z_val) * 10000) / q1_cal;
  1566. }
  1567. static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
  1568. uint32_t *zr)
  1569. {
  1570. struct snd_soc_codec *codec = mbhc->codec;
  1571. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1572. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  1573. s16 reg0, reg1, reg2, reg3, reg4;
  1574. int32_t z1L, z1R, z1Ls;
  1575. int zMono, z_diff1, z_diff2;
  1576. bool is_fsm_disable = false;
  1577. bool is_change = false;
  1578. struct tasha_mbhc_zdet_param zdet_param[] = {
  1579. {4, 0, 4, 0x08, 0x14, 0x18}, /* < 32ohm */
  1580. {2, 0, 3, 0x18, 0x7C, 0x90}, /* 32ohm < Z < 400ohm */
  1581. {1, 4, 5, 0x18, 0x7C, 0x90}, /* 400ohm < Z < 1200ohm */
  1582. {1, 6, 7, 0x18, 0x7C, 0x90}, /* >1200ohm */
  1583. };
  1584. struct tasha_mbhc_zdet_param *zdet_param_ptr = NULL;
  1585. s16 d1_a[][4] = {
  1586. {0, 30, 90, 30},
  1587. {0, 30, 30, 5},
  1588. {0, 30, 30, 5},
  1589. {0, 30, 30, 5},
  1590. };
  1591. s16 *d1 = NULL;
  1592. if (!TASHA_IS_2_0(wcd9xxx)) {
  1593. dev_dbg(codec->dev, "%s: Z-det is not supported for this codec version\n",
  1594. __func__);
  1595. *zl = 0;
  1596. *zr = 0;
  1597. return;
  1598. }
  1599. WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
  1600. if (tasha->zdet_gpio_cb)
  1601. is_change = tasha->zdet_gpio_cb(codec, true);
  1602. reg0 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN5);
  1603. reg1 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN6);
  1604. reg2 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN7);
  1605. reg3 = snd_soc_read(codec, WCD9335_MBHC_CTL_1);
  1606. reg4 = snd_soc_read(codec, WCD9335_MBHC_ZDET_ANA_CTL);
  1607. if (snd_soc_read(codec, WCD9335_ANA_MBHC_ELECT) & 0x80) {
  1608. is_fsm_disable = true;
  1609. regmap_update_bits(wcd9xxx->regmap,
  1610. WCD9335_ANA_MBHC_ELECT, 0x80, 0x00);
  1611. }
  1612. /* For NO-jack, disable L_DET_EN before Z-det measurements */
  1613. if (mbhc->hphl_swh)
  1614. regmap_update_bits(wcd9xxx->regmap,
  1615. WCD9335_ANA_MBHC_MECH, 0x80, 0x00);
  1616. /* Enable AZ */
  1617. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1, 0x0C, 0x04);
  1618. /* Turn off 100k pull down on HPHL */
  1619. regmap_update_bits(wcd9xxx->regmap,
  1620. WCD9335_ANA_MBHC_MECH, 0x01, 0x00);
  1621. /* First get impedance on Left */
  1622. d1 = d1_a[1];
  1623. zdet_param_ptr = &zdet_param[1];
  1624. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1625. if (!TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
  1626. goto left_ch_impedance;
  1627. /* second ramp for left ch */
  1628. if (z1L < TASHA_ZDET_VAL_32) {
  1629. zdet_param_ptr = &zdet_param[0];
  1630. d1 = d1_a[0];
  1631. } else if ((z1L > TASHA_ZDET_VAL_400) && (z1L <= TASHA_ZDET_VAL_1200)) {
  1632. zdet_param_ptr = &zdet_param[2];
  1633. d1 = d1_a[2];
  1634. } else if (z1L > TASHA_ZDET_VAL_1200) {
  1635. zdet_param_ptr = &zdet_param[3];
  1636. d1 = d1_a[3];
  1637. }
  1638. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
  1639. left_ch_impedance:
  1640. if ((z1L == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1641. (z1L > TASHA_ZDET_VAL_100K)) {
  1642. *zl = TASHA_ZDET_FLOATING_IMPEDANCE;
  1643. zdet_param_ptr = &zdet_param[1];
  1644. d1 = d1_a[1];
  1645. } else {
  1646. *zl = z1L/1000;
  1647. tasha_wcd_mbhc_qfuse_cal(codec, zl, 0);
  1648. }
  1649. dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n",
  1650. __func__, *zl);
  1651. /* start of right impedance ramp and calculation */
  1652. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1653. if (TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
  1654. if (((z1R > TASHA_ZDET_VAL_1200) &&
  1655. (zdet_param_ptr->noff == 0x6)) ||
  1656. ((*zl) != TASHA_ZDET_FLOATING_IMPEDANCE))
  1657. goto right_ch_impedance;
  1658. /* second ramp for right ch */
  1659. if (z1R < TASHA_ZDET_VAL_32) {
  1660. zdet_param_ptr = &zdet_param[0];
  1661. d1 = d1_a[0];
  1662. } else if ((z1R > TASHA_ZDET_VAL_400) &&
  1663. (z1R <= TASHA_ZDET_VAL_1200)) {
  1664. zdet_param_ptr = &zdet_param[2];
  1665. d1 = d1_a[2];
  1666. } else if (z1R > TASHA_ZDET_VAL_1200) {
  1667. zdet_param_ptr = &zdet_param[3];
  1668. d1 = d1_a[3];
  1669. }
  1670. tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
  1671. }
  1672. right_ch_impedance:
  1673. if ((z1R == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1674. (z1R > TASHA_ZDET_VAL_100K)) {
  1675. *zr = TASHA_ZDET_FLOATING_IMPEDANCE;
  1676. } else {
  1677. *zr = z1R/1000;
  1678. tasha_wcd_mbhc_qfuse_cal(codec, zr, 1);
  1679. }
  1680. dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n",
  1681. __func__, *zr);
  1682. /* mono/stereo detection */
  1683. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) &&
  1684. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE)) {
  1685. dev_dbg(codec->dev,
  1686. "%s: plug type is invalid or extension cable\n",
  1687. __func__);
  1688. goto zdet_complete;
  1689. }
  1690. if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1691. (*zr == TASHA_ZDET_FLOATING_IMPEDANCE) ||
  1692. ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
  1693. ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
  1694. dev_dbg(codec->dev,
  1695. "%s: Mono plug type with one ch floating or shorted to GND\n",
  1696. __func__);
  1697. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1698. goto zdet_complete;
  1699. }
  1700. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x02);
  1701. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x01);
  1702. if (*zl < (TASHA_ZDET_VAL_32/1000))
  1703. tasha_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1);
  1704. else
  1705. tasha_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1);
  1706. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x00);
  1707. snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x00);
  1708. z1Ls /= 1000;
  1709. tasha_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0);
  1710. /* parallel of left Z and 9 ohm pull down resistor */
  1711. zMono = ((*zl) * 9) / ((*zl) + 9);
  1712. z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
  1713. z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
  1714. if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
  1715. dev_dbg(codec->dev, "%s: stereo plug type detected\n",
  1716. __func__);
  1717. mbhc->hph_type = WCD_MBHC_HPH_STEREO;
  1718. } else {
  1719. dev_dbg(codec->dev, "%s: MONO plug type detected\n",
  1720. __func__);
  1721. mbhc->hph_type = WCD_MBHC_HPH_MONO;
  1722. }
  1723. zdet_complete:
  1724. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN5, reg0);
  1725. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN6, reg1);
  1726. snd_soc_write(codec, WCD9335_ANA_MBHC_BTN7, reg2);
  1727. /* Turn on 100k pull down on HPHL */
  1728. regmap_update_bits(wcd9xxx->regmap,
  1729. WCD9335_ANA_MBHC_MECH, 0x01, 0x01);
  1730. /* For NO-jack, re-enable L_DET_EN after Z-det measurements */
  1731. if (mbhc->hphl_swh)
  1732. regmap_update_bits(wcd9xxx->regmap,
  1733. WCD9335_ANA_MBHC_MECH, 0x80, 0x80);
  1734. snd_soc_write(codec, WCD9335_MBHC_ZDET_ANA_CTL, reg4);
  1735. snd_soc_write(codec, WCD9335_MBHC_CTL_1, reg3);
  1736. if (is_fsm_disable)
  1737. regmap_update_bits(wcd9xxx->regmap,
  1738. WCD9335_ANA_MBHC_ELECT, 0x80, 0x80);
  1739. if (tasha->zdet_gpio_cb && is_change)
  1740. tasha->zdet_gpio_cb(codec, false);
  1741. }
  1742. static void tasha_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable)
  1743. {
  1744. if (enable) {
  1745. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1746. 0x02, 0x02);
  1747. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1748. 0x40, 0x40);
  1749. } else {
  1750. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1751. 0x40, 0x00);
  1752. snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH,
  1753. 0x02, 0x00);
  1754. }
  1755. }
  1756. static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec,
  1757. bool enable)
  1758. {
  1759. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1760. if (enable) {
  1761. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1762. 0x40, 0x40);
  1763. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1764. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1765. 0x10, 0x10);
  1766. } else {
  1767. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1768. 0x40, 0x00);
  1769. if (TASHA_IS_2_0(tasha->wcd9xxx))
  1770. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2,
  1771. 0x10, 0x00);
  1772. }
  1773. }
  1774. static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc)
  1775. {
  1776. struct snd_soc_codec *codec = mbhc->codec;
  1777. if (mbhc->moist_vref == V_OFF)
  1778. return;
  1779. /* Donot enable moisture detection if jack type is NC */
  1780. if (!mbhc->hphl_swh) {
  1781. dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
  1782. __func__);
  1783. return;
  1784. }
  1785. snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2,
  1786. 0x0C, mbhc->moist_vref << 2);
  1787. tasha_mbhc_hph_l_pull_up_control(codec, mbhc->moist_iref);
  1788. }
  1789. static void tasha_update_anc_state(struct snd_soc_codec *codec, bool enable,
  1790. int anc_num)
  1791. {
  1792. if (enable)
  1793. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1794. (20 * anc_num), 0x10, 0x10);
  1795. else
  1796. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 +
  1797. (20 * anc_num), 0x10, 0x00);
  1798. }
  1799. static bool tasha_is_anc_on(struct wcd_mbhc *mbhc)
  1800. {
  1801. bool anc_on = false;
  1802. u16 ancl, ancr;
  1803. ancl =
  1804. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX1_RX_PATH_CFG0)) & 0x10;
  1805. ancr =
  1806. (snd_soc_read(mbhc->codec, WCD9335_CDC_RX2_RX_PATH_CFG0)) & 0x10;
  1807. anc_on = !!(ancl | ancr);
  1808. return anc_on;
  1809. }
  1810. static const struct wcd_mbhc_cb mbhc_cb = {
  1811. .request_irq = tasha_mbhc_request_irq,
  1812. .irq_control = tasha_mbhc_irq_control,
  1813. .free_irq = tasha_mbhc_free_irq,
  1814. .clk_setup = tasha_mbhc_clk_setup,
  1815. .map_btn_code_to_num = tasha_mbhc_btn_to_num,
  1816. .enable_mb_source = tasha_enable_ext_mb_source,
  1817. .mbhc_bias = tasha_mbhc_mbhc_bias_control,
  1818. .set_btn_thr = tasha_mbhc_program_btn_thr,
  1819. .lock_sleep = tasha_mbhc_lock_sleep,
  1820. .register_notifier = tasha_mbhc_register_notifier,
  1821. .micbias_enable_status = tasha_mbhc_micb_en_status,
  1822. .hph_pa_on_status = tasha_mbhc_hph_pa_on_status,
  1823. .hph_pull_up_control = tasha_mbhc_hph_l_pull_up_control,
  1824. .mbhc_micbias_control = tasha_mbhc_request_micbias,
  1825. .mbhc_micb_ramp_control = tasha_mbhc_micb_ramp_control,
  1826. .get_hwdep_fw_cal = tasha_get_hwdep_fw_cal,
  1827. .mbhc_micb_ctrl_thr_mic = tasha_mbhc_micb_ctrl_threshold_mic,
  1828. .compute_impedance = tasha_wcd_mbhc_calc_impedance,
  1829. .mbhc_gnd_det_ctrl = tasha_mbhc_gnd_det_ctrl,
  1830. .hph_pull_down_ctrl = tasha_mbhc_hph_pull_down_ctrl,
  1831. .mbhc_moisture_config = tasha_mbhc_moisture_config,
  1832. .update_anc_state = tasha_update_anc_state,
  1833. .is_anc_on = tasha_is_anc_on,
  1834. };
  1835. static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol,
  1836. struct snd_ctl_elem_value *ucontrol)
  1837. {
  1838. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1839. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1840. ucontrol->value.integer.value[0] = tasha->anc_slot;
  1841. return 0;
  1842. }
  1843. static int tasha_put_anc_slot(struct snd_kcontrol *kcontrol,
  1844. struct snd_ctl_elem_value *ucontrol)
  1845. {
  1846. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1847. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1848. tasha->anc_slot = ucontrol->value.integer.value[0];
  1849. return 0;
  1850. }
  1851. static int tasha_get_anc_func(struct snd_kcontrol *kcontrol,
  1852. struct snd_ctl_elem_value *ucontrol)
  1853. {
  1854. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1855. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1856. ucontrol->value.integer.value[0] = (tasha->anc_func == true ? 1 : 0);
  1857. return 0;
  1858. }
  1859. static int tasha_put_anc_func(struct snd_kcontrol *kcontrol,
  1860. struct snd_ctl_elem_value *ucontrol)
  1861. {
  1862. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1863. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1864. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  1865. mutex_lock(&tasha->codec_mutex);
  1866. tasha->anc_func = (!ucontrol->value.integer.value[0] ? false : true);
  1867. dev_dbg(codec->dev, "%s: anc_func %x", __func__, tasha->anc_func);
  1868. if (tasha->anc_func == true) {
  1869. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2 PA");
  1870. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2");
  1871. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1 PA");
  1872. snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT1");
  1873. snd_soc_dapm_enable_pin(dapm, "ANC HPHR PA");
  1874. snd_soc_dapm_enable_pin(dapm, "ANC HPHR");
  1875. snd_soc_dapm_enable_pin(dapm, "ANC HPHL PA");
  1876. snd_soc_dapm_enable_pin(dapm, "ANC HPHL");
  1877. snd_soc_dapm_enable_pin(dapm, "ANC EAR PA");
  1878. snd_soc_dapm_enable_pin(dapm, "ANC EAR");
  1879. snd_soc_dapm_enable_pin(dapm, "ANC SPK1 PA");
  1880. snd_soc_dapm_disable_pin(dapm, "LINEOUT2");
  1881. snd_soc_dapm_disable_pin(dapm, "LINEOUT2 PA");
  1882. snd_soc_dapm_disable_pin(dapm, "LINEOUT1");
  1883. snd_soc_dapm_disable_pin(dapm, "LINEOUT1 PA");
  1884. snd_soc_dapm_disable_pin(dapm, "HPHR");
  1885. snd_soc_dapm_disable_pin(dapm, "HPHL");
  1886. snd_soc_dapm_disable_pin(dapm, "HPHR PA");
  1887. snd_soc_dapm_disable_pin(dapm, "HPHL PA");
  1888. snd_soc_dapm_disable_pin(dapm, "EAR PA");
  1889. snd_soc_dapm_disable_pin(dapm, "EAR");
  1890. } else {
  1891. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  1892. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  1893. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  1894. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  1895. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  1896. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  1897. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  1898. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  1899. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  1900. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  1901. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  1902. snd_soc_dapm_enable_pin(dapm, "LINEOUT2");
  1903. snd_soc_dapm_enable_pin(dapm, "LINEOUT2 PA");
  1904. snd_soc_dapm_enable_pin(dapm, "LINEOUT1");
  1905. snd_soc_dapm_enable_pin(dapm, "LINEOUT1 PA");
  1906. snd_soc_dapm_enable_pin(dapm, "HPHR");
  1907. snd_soc_dapm_enable_pin(dapm, "HPHL");
  1908. snd_soc_dapm_enable_pin(dapm, "HPHR PA");
  1909. snd_soc_dapm_enable_pin(dapm, "HPHL PA");
  1910. snd_soc_dapm_enable_pin(dapm, "EAR PA");
  1911. snd_soc_dapm_enable_pin(dapm, "EAR");
  1912. }
  1913. mutex_unlock(&tasha->codec_mutex);
  1914. snd_soc_dapm_sync(dapm);
  1915. return 0;
  1916. }
  1917. static int tasha_get_clkmode(struct snd_kcontrol *kcontrol,
  1918. struct snd_ctl_elem_value *ucontrol)
  1919. {
  1920. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1921. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1922. ucontrol->value.enumerated.item[0] = tasha->clk_mode;
  1923. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1924. return 0;
  1925. }
  1926. static int tasha_put_clkmode(struct snd_kcontrol *kcontrol,
  1927. struct snd_ctl_elem_value *ucontrol)
  1928. {
  1929. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1930. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  1931. tasha->clk_mode = ucontrol->value.enumerated.item[0];
  1932. dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode);
  1933. return 0;
  1934. }
  1935. static int tasha_get_iir_enable_audio_mixer(
  1936. struct snd_kcontrol *kcontrol,
  1937. struct snd_ctl_elem_value *ucontrol)
  1938. {
  1939. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1940. int iir_idx = ((struct soc_multi_mixer_control *)
  1941. kcontrol->private_value)->reg;
  1942. int band_idx = ((struct soc_multi_mixer_control *)
  1943. kcontrol->private_value)->shift;
  1944. /* IIR filter band registers are at integer multiples of 16 */
  1945. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  1946. ucontrol->value.integer.value[0] = (snd_soc_read(codec, iir_reg) &
  1947. (1 << band_idx)) != 0;
  1948. dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__,
  1949. iir_idx, band_idx,
  1950. (uint32_t)ucontrol->value.integer.value[0]);
  1951. return 0;
  1952. }
  1953. static int tasha_hph_impedance_get(struct snd_kcontrol *kcontrol,
  1954. struct snd_ctl_elem_value *ucontrol)
  1955. {
  1956. uint32_t zl, zr;
  1957. bool hphr;
  1958. struct soc_multi_mixer_control *mc;
  1959. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1960. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1961. mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
  1962. hphr = mc->shift;
  1963. wcd_mbhc_get_impedance(&priv->mbhc, &zl, &zr);
  1964. dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
  1965. ucontrol->value.integer.value[0] = hphr ? zr : zl;
  1966. return 0;
  1967. }
  1968. static const struct snd_kcontrol_new impedance_detect_controls[] = {
  1969. SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
  1970. tasha_hph_impedance_get, NULL),
  1971. SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
  1972. tasha_hph_impedance_get, NULL),
  1973. };
  1974. static int tasha_get_hph_type(struct snd_kcontrol *kcontrol,
  1975. struct snd_ctl_elem_value *ucontrol)
  1976. {
  1977. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1978. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  1979. struct wcd_mbhc *mbhc;
  1980. if (!priv) {
  1981. dev_dbg(codec->dev, "%s: wcd9335 private data is NULL\n",
  1982. __func__);
  1983. return 0;
  1984. }
  1985. mbhc = &priv->mbhc;
  1986. if (!mbhc) {
  1987. dev_dbg(codec->dev, "%s: mbhc not initialized\n", __func__);
  1988. return 0;
  1989. }
  1990. ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
  1991. dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
  1992. return 0;
  1993. }
  1994. static const struct snd_kcontrol_new hph_type_detect_controls[] = {
  1995. SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
  1996. tasha_get_hph_type, NULL),
  1997. };
  1998. static int tasha_vi_feed_mixer_get(struct snd_kcontrol *kcontrol,
  1999. struct snd_ctl_elem_value *ucontrol)
  2000. {
  2001. struct snd_soc_dapm_widget *widget =
  2002. snd_soc_dapm_kcontrol_widget(kcontrol);
  2003. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2004. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2005. ucontrol->value.integer.value[0] = tasha_p->vi_feed_value;
  2006. return 0;
  2007. }
  2008. static int tasha_vi_feed_mixer_put(struct snd_kcontrol *kcontrol,
  2009. struct snd_ctl_elem_value *ucontrol)
  2010. {
  2011. struct snd_soc_dapm_widget *widget =
  2012. snd_soc_dapm_kcontrol_widget(kcontrol);
  2013. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2014. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2015. struct wcd9xxx *core = tasha_p->wcd9xxx;
  2016. struct soc_multi_mixer_control *mixer =
  2017. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2018. u32 dai_id = widget->shift;
  2019. u32 port_id = mixer->shift;
  2020. u32 enable = ucontrol->value.integer.value[0];
  2021. dev_dbg(codec->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n",
  2022. __func__, enable, port_id, dai_id);
  2023. tasha_p->vi_feed_value = ucontrol->value.integer.value[0];
  2024. mutex_lock(&tasha_p->codec_mutex);
  2025. if (enable) {
  2026. if (port_id == TASHA_TX14 && !test_bit(VI_SENSE_1,
  2027. &tasha_p->status_mask)) {
  2028. list_add_tail(&core->tx_chs[TASHA_TX14].list,
  2029. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2030. set_bit(VI_SENSE_1, &tasha_p->status_mask);
  2031. }
  2032. if (port_id == TASHA_TX15 && !test_bit(VI_SENSE_2,
  2033. &tasha_p->status_mask)) {
  2034. list_add_tail(&core->tx_chs[TASHA_TX15].list,
  2035. &tasha_p->dai[dai_id].wcd9xxx_ch_list);
  2036. set_bit(VI_SENSE_2, &tasha_p->status_mask);
  2037. }
  2038. } else {
  2039. if (port_id == TASHA_TX14 && test_bit(VI_SENSE_1,
  2040. &tasha_p->status_mask)) {
  2041. list_del_init(&core->tx_chs[TASHA_TX14].list);
  2042. clear_bit(VI_SENSE_1, &tasha_p->status_mask);
  2043. }
  2044. if (port_id == TASHA_TX15 && test_bit(VI_SENSE_2,
  2045. &tasha_p->status_mask)) {
  2046. list_del_init(&core->tx_chs[TASHA_TX15].list);
  2047. clear_bit(VI_SENSE_2, &tasha_p->status_mask);
  2048. }
  2049. }
  2050. mutex_unlock(&tasha_p->codec_mutex);
  2051. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL);
  2052. return 0;
  2053. }
  2054. /* virtual port entries */
  2055. static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol,
  2056. struct snd_ctl_elem_value *ucontrol)
  2057. {
  2058. struct snd_soc_dapm_widget *widget =
  2059. snd_soc_dapm_kcontrol_widget(kcontrol);
  2060. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2061. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2062. ucontrol->value.integer.value[0] = tasha_p->tx_port_value;
  2063. return 0;
  2064. }
  2065. static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol,
  2066. struct snd_ctl_elem_value *ucontrol)
  2067. {
  2068. struct snd_soc_dapm_widget *widget =
  2069. snd_soc_dapm_kcontrol_widget(kcontrol);
  2070. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2071. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2072. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2073. struct snd_soc_dapm_update *update = NULL;
  2074. struct soc_multi_mixer_control *mixer =
  2075. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  2076. u32 dai_id = widget->shift;
  2077. u32 port_id = mixer->shift;
  2078. u32 enable = ucontrol->value.integer.value[0];
  2079. u32 vtable;
  2080. dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n",
  2081. __func__,
  2082. widget->name, ucontrol->id.name, tasha_p->tx_port_value,
  2083. widget->shift, ucontrol->value.integer.value[0]);
  2084. mutex_lock(&tasha_p->codec_mutex);
  2085. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2086. if (dai_id != AIF1_CAP) {
  2087. dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
  2088. __func__);
  2089. mutex_unlock(&tasha_p->codec_mutex);
  2090. return -EINVAL;
  2091. }
  2092. vtable = vport_slim_check_table[dai_id];
  2093. } else {
  2094. if (dai_id >= ARRAY_SIZE(vport_i2s_check_table)) {
  2095. dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n",
  2096. __func__, dai_id);
  2097. return -EINVAL;
  2098. }
  2099. vtable = vport_i2s_check_table[dai_id];
  2100. }
  2101. switch (dai_id) {
  2102. case AIF1_CAP:
  2103. case AIF2_CAP:
  2104. case AIF3_CAP:
  2105. /* only add to the list if value not set */
  2106. if (enable && !(tasha_p->tx_port_value & 1 << port_id)) {
  2107. if (wcd9xxx_tx_vport_validation(vtable, port_id,
  2108. tasha_p->dai, NUM_CODEC_DAIS)) {
  2109. dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n",
  2110. __func__, port_id);
  2111. mutex_unlock(&tasha_p->codec_mutex);
  2112. return 0;
  2113. }
  2114. tasha_p->tx_port_value |= 1 << port_id;
  2115. list_add_tail(&core->tx_chs[port_id].list,
  2116. &tasha_p->dai[dai_id].wcd9xxx_ch_list
  2117. );
  2118. } else if (!enable && (tasha_p->tx_port_value &
  2119. 1 << port_id)) {
  2120. tasha_p->tx_port_value &= ~(1 << port_id);
  2121. list_del_init(&core->tx_chs[port_id].list);
  2122. } else {
  2123. if (enable)
  2124. dev_dbg(codec->dev, "%s: TX%u port is used by\n"
  2125. "this virtual port\n",
  2126. __func__, port_id);
  2127. else
  2128. dev_dbg(codec->dev, "%s: TX%u port is not used by\n"
  2129. "this virtual port\n",
  2130. __func__, port_id);
  2131. /* avoid update power function */
  2132. mutex_unlock(&tasha_p->codec_mutex);
  2133. return 0;
  2134. }
  2135. break;
  2136. case AIF4_MAD_TX:
  2137. case AIF5_CPE_TX:
  2138. break;
  2139. default:
  2140. pr_err("Unknown AIF %d\n", dai_id);
  2141. mutex_unlock(&tasha_p->codec_mutex);
  2142. return -EINVAL;
  2143. }
  2144. pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__,
  2145. widget->name, widget->sname, tasha_p->tx_port_value,
  2146. widget->shift);
  2147. mutex_unlock(&tasha_p->codec_mutex);
  2148. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
  2149. return 0;
  2150. }
  2151. static int slim_rx_mux_get(struct snd_kcontrol *kcontrol,
  2152. struct snd_ctl_elem_value *ucontrol)
  2153. {
  2154. struct snd_soc_dapm_widget *widget =
  2155. snd_soc_dapm_kcontrol_widget(kcontrol);
  2156. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2157. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2158. ucontrol->value.enumerated.item[0] =
  2159. tasha_p->rx_port_value[widget->shift];
  2160. return 0;
  2161. }
  2162. static const char *const slim_rx_mux_text[] = {
  2163. "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB", "AIF_MIX1_PB"
  2164. };
  2165. static int slim_rx_mux_put(struct snd_kcontrol *kcontrol,
  2166. struct snd_ctl_elem_value *ucontrol)
  2167. {
  2168. struct snd_soc_dapm_widget *widget =
  2169. snd_soc_dapm_kcontrol_widget(kcontrol);
  2170. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  2171. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2172. struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
  2173. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  2174. struct snd_soc_dapm_update *update = NULL;
  2175. unsigned int rx_port_value;
  2176. u32 port_id = widget->shift;
  2177. tasha_p->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
  2178. rx_port_value = tasha_p->rx_port_value[port_id];
  2179. pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__,
  2180. widget->name, ucontrol->id.name, rx_port_value,
  2181. widget->shift, ucontrol->value.integer.value[0]);
  2182. mutex_lock(&tasha_p->codec_mutex);
  2183. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2184. if (rx_port_value > 2) {
  2185. dev_err(codec->dev, "%s: invalid AIF for I2C mode\n",
  2186. __func__);
  2187. goto err;
  2188. }
  2189. }
  2190. /* value need to match the Virtual port and AIF number */
  2191. switch (rx_port_value) {
  2192. case 0:
  2193. list_del_init(&core->rx_chs[port_id].list);
  2194. break;
  2195. case 1:
  2196. if (wcd9xxx_rx_vport_validation(port_id +
  2197. TASHA_RX_PORT_START_NUMBER,
  2198. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list)) {
  2199. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2200. __func__, port_id);
  2201. goto rtn;
  2202. }
  2203. list_add_tail(&core->rx_chs[port_id].list,
  2204. &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list);
  2205. break;
  2206. case 2:
  2207. if (wcd9xxx_rx_vport_validation(port_id +
  2208. TASHA_RX_PORT_START_NUMBER,
  2209. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list)) {
  2210. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2211. __func__, port_id);
  2212. goto rtn;
  2213. }
  2214. list_add_tail(&core->rx_chs[port_id].list,
  2215. &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list);
  2216. break;
  2217. case 3:
  2218. if (wcd9xxx_rx_vport_validation(port_id +
  2219. TASHA_RX_PORT_START_NUMBER,
  2220. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list)) {
  2221. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2222. __func__, port_id);
  2223. goto rtn;
  2224. }
  2225. list_add_tail(&core->rx_chs[port_id].list,
  2226. &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list);
  2227. break;
  2228. case 4:
  2229. if (wcd9xxx_rx_vport_validation(port_id +
  2230. TASHA_RX_PORT_START_NUMBER,
  2231. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list)) {
  2232. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2233. __func__, port_id);
  2234. goto rtn;
  2235. }
  2236. list_add_tail(&core->rx_chs[port_id].list,
  2237. &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list);
  2238. break;
  2239. case 5:
  2240. if (wcd9xxx_rx_vport_validation(port_id +
  2241. TASHA_RX_PORT_START_NUMBER,
  2242. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list)) {
  2243. dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n",
  2244. __func__, port_id);
  2245. goto rtn;
  2246. }
  2247. list_add_tail(&core->rx_chs[port_id].list,
  2248. &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list);
  2249. break;
  2250. default:
  2251. pr_err("Unknown AIF %d\n", rx_port_value);
  2252. goto err;
  2253. }
  2254. rtn:
  2255. mutex_unlock(&tasha_p->codec_mutex);
  2256. snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
  2257. rx_port_value, e, update);
  2258. return 0;
  2259. err:
  2260. mutex_unlock(&tasha_p->codec_mutex);
  2261. return -EINVAL;
  2262. }
  2263. static const struct soc_enum slim_rx_mux_enum =
  2264. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text);
  2265. static const struct snd_kcontrol_new slim_rx_mux[TASHA_RX_MAX] = {
  2266. SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum,
  2267. slim_rx_mux_get, slim_rx_mux_put),
  2268. SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
  2269. slim_rx_mux_get, slim_rx_mux_put),
  2270. SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
  2271. slim_rx_mux_get, slim_rx_mux_put),
  2272. SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
  2273. slim_rx_mux_get, slim_rx_mux_put),
  2274. SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
  2275. slim_rx_mux_get, slim_rx_mux_put),
  2276. SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
  2277. slim_rx_mux_get, slim_rx_mux_put),
  2278. SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
  2279. slim_rx_mux_get, slim_rx_mux_put),
  2280. SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
  2281. slim_rx_mux_get, slim_rx_mux_put),
  2282. };
  2283. static const struct snd_kcontrol_new aif4_vi_mixer[] = {
  2284. SOC_SINGLE_EXT("SPKR_VI_1", SND_SOC_NOPM, TASHA_TX14, 1, 0,
  2285. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2286. SOC_SINGLE_EXT("SPKR_VI_2", SND_SOC_NOPM, TASHA_TX15, 1, 0,
  2287. tasha_vi_feed_mixer_get, tasha_vi_feed_mixer_put),
  2288. };
  2289. static const struct snd_kcontrol_new aif1_cap_mixer[] = {
  2290. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2291. slim_tx_mixer_get, slim_tx_mixer_put),
  2292. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2293. slim_tx_mixer_get, slim_tx_mixer_put),
  2294. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2295. slim_tx_mixer_get, slim_tx_mixer_put),
  2296. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2297. slim_tx_mixer_get, slim_tx_mixer_put),
  2298. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2299. slim_tx_mixer_get, slim_tx_mixer_put),
  2300. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2301. slim_tx_mixer_get, slim_tx_mixer_put),
  2302. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2303. slim_tx_mixer_get, slim_tx_mixer_put),
  2304. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2305. slim_tx_mixer_get, slim_tx_mixer_put),
  2306. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2307. slim_tx_mixer_get, slim_tx_mixer_put),
  2308. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2309. slim_tx_mixer_get, slim_tx_mixer_put),
  2310. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2311. slim_tx_mixer_get, slim_tx_mixer_put),
  2312. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2313. slim_tx_mixer_get, slim_tx_mixer_put),
  2314. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2315. slim_tx_mixer_get, slim_tx_mixer_put),
  2316. };
  2317. static const struct snd_kcontrol_new aif2_cap_mixer[] = {
  2318. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2319. slim_tx_mixer_get, slim_tx_mixer_put),
  2320. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2321. slim_tx_mixer_get, slim_tx_mixer_put),
  2322. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2323. slim_tx_mixer_get, slim_tx_mixer_put),
  2324. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2325. slim_tx_mixer_get, slim_tx_mixer_put),
  2326. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2327. slim_tx_mixer_get, slim_tx_mixer_put),
  2328. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2329. slim_tx_mixer_get, slim_tx_mixer_put),
  2330. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2331. slim_tx_mixer_get, slim_tx_mixer_put),
  2332. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2333. slim_tx_mixer_get, slim_tx_mixer_put),
  2334. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2335. slim_tx_mixer_get, slim_tx_mixer_put),
  2336. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2337. slim_tx_mixer_get, slim_tx_mixer_put),
  2338. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2339. slim_tx_mixer_get, slim_tx_mixer_put),
  2340. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2341. slim_tx_mixer_get, slim_tx_mixer_put),
  2342. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2343. slim_tx_mixer_get, slim_tx_mixer_put),
  2344. };
  2345. static const struct snd_kcontrol_new aif3_cap_mixer[] = {
  2346. SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, TASHA_TX0, 1, 0,
  2347. slim_tx_mixer_get, slim_tx_mixer_put),
  2348. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TASHA_TX1, 1, 0,
  2349. slim_tx_mixer_get, slim_tx_mixer_put),
  2350. SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TASHA_TX2, 1, 0,
  2351. slim_tx_mixer_get, slim_tx_mixer_put),
  2352. SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TASHA_TX3, 1, 0,
  2353. slim_tx_mixer_get, slim_tx_mixer_put),
  2354. SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TASHA_TX4, 1, 0,
  2355. slim_tx_mixer_get, slim_tx_mixer_put),
  2356. SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TASHA_TX5, 1, 0,
  2357. slim_tx_mixer_get, slim_tx_mixer_put),
  2358. SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TASHA_TX6, 1, 0,
  2359. slim_tx_mixer_get, slim_tx_mixer_put),
  2360. SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TASHA_TX7, 1, 0,
  2361. slim_tx_mixer_get, slim_tx_mixer_put),
  2362. SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TASHA_TX8, 1, 0,
  2363. slim_tx_mixer_get, slim_tx_mixer_put),
  2364. SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TASHA_TX9, 1, 0,
  2365. slim_tx_mixer_get, slim_tx_mixer_put),
  2366. SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TASHA_TX10, 1, 0,
  2367. slim_tx_mixer_get, slim_tx_mixer_put),
  2368. SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, TASHA_TX11, 1, 0,
  2369. slim_tx_mixer_get, slim_tx_mixer_put),
  2370. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2371. slim_tx_mixer_get, slim_tx_mixer_put),
  2372. };
  2373. static const struct snd_kcontrol_new aif4_mad_mixer[] = {
  2374. SOC_SINGLE_EXT("SLIM TX12", SND_SOC_NOPM, TASHA_TX12, 1, 0,
  2375. slim_tx_mixer_get, slim_tx_mixer_put),
  2376. SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, TASHA_TX13, 1, 0,
  2377. slim_tx_mixer_get, slim_tx_mixer_put),
  2378. SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, 0, 1, 0,
  2379. slim_tx_mixer_get, slim_tx_mixer_put),
  2380. };
  2381. static const struct snd_kcontrol_new rx_int1_spline_mix_switch[] = {
  2382. SOC_DAPM_SINGLE("HPHL Switch", SND_SOC_NOPM, 0, 1, 0)
  2383. };
  2384. static const struct snd_kcontrol_new rx_int2_spline_mix_switch[] = {
  2385. SOC_DAPM_SINGLE("HPHR Switch", SND_SOC_NOPM, 0, 1, 0)
  2386. };
  2387. static const struct snd_kcontrol_new rx_int3_spline_mix_switch[] = {
  2388. SOC_DAPM_SINGLE("LO1 Switch", SND_SOC_NOPM, 0, 1, 0)
  2389. };
  2390. static const struct snd_kcontrol_new rx_int4_spline_mix_switch[] = {
  2391. SOC_DAPM_SINGLE("LO2 Switch", SND_SOC_NOPM, 0, 1, 0)
  2392. };
  2393. static const struct snd_kcontrol_new rx_int5_spline_mix_switch[] = {
  2394. SOC_DAPM_SINGLE("LO3 Switch", SND_SOC_NOPM, 0, 1, 0)
  2395. };
  2396. static const struct snd_kcontrol_new rx_int6_spline_mix_switch[] = {
  2397. SOC_DAPM_SINGLE("LO4 Switch", SND_SOC_NOPM, 0, 1, 0)
  2398. };
  2399. static const struct snd_kcontrol_new rx_int7_spline_mix_switch[] = {
  2400. SOC_DAPM_SINGLE("SPKRL Switch", SND_SOC_NOPM, 0, 1, 0)
  2401. };
  2402. static const struct snd_kcontrol_new rx_int8_spline_mix_switch[] = {
  2403. SOC_DAPM_SINGLE("SPKRR Switch", SND_SOC_NOPM, 0, 1, 0)
  2404. };
  2405. static const struct snd_kcontrol_new rx_int5_vbat_mix_switch[] = {
  2406. SOC_DAPM_SINGLE("LO3 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2407. };
  2408. static const struct snd_kcontrol_new rx_int6_vbat_mix_switch[] = {
  2409. SOC_DAPM_SINGLE("LO4 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2410. };
  2411. static const struct snd_kcontrol_new rx_int7_vbat_mix_switch[] = {
  2412. SOC_DAPM_SINGLE("SPKRL VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2413. };
  2414. static const struct snd_kcontrol_new rx_int8_vbat_mix_switch[] = {
  2415. SOC_DAPM_SINGLE("SPKRR VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
  2416. };
  2417. static const struct snd_kcontrol_new cpe_in_mix_switch[] = {
  2418. SOC_DAPM_SINGLE("MAD_BYPASS", SND_SOC_NOPM, 0, 1, 0)
  2419. };
  2420. static int tasha_put_iir_enable_audio_mixer(
  2421. struct snd_kcontrol *kcontrol,
  2422. struct snd_ctl_elem_value *ucontrol)
  2423. {
  2424. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2425. int iir_idx = ((struct soc_multi_mixer_control *)
  2426. kcontrol->private_value)->reg;
  2427. int band_idx = ((struct soc_multi_mixer_control *)
  2428. kcontrol->private_value)->shift;
  2429. bool iir_band_en_status;
  2430. int value = ucontrol->value.integer.value[0];
  2431. u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx;
  2432. /* Mask first 5 bits, 6-8 are reserved */
  2433. snd_soc_update_bits(codec, iir_reg, (1 << band_idx),
  2434. (value << band_idx));
  2435. iir_band_en_status = ((snd_soc_read(codec, iir_reg) &
  2436. (1 << band_idx)) != 0);
  2437. pr_debug("%s: IIR #%d band #%d enable %d\n", __func__,
  2438. iir_idx, band_idx, iir_band_en_status);
  2439. return 0;
  2440. }
  2441. static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec,
  2442. int iir_idx, int band_idx,
  2443. int coeff_idx)
  2444. {
  2445. uint32_t value = 0;
  2446. /* Address does not automatically update if reading */
  2447. snd_soc_write(codec,
  2448. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2449. ((band_idx * BAND_MAX + coeff_idx)
  2450. * sizeof(uint32_t)) & 0x7F);
  2451. value |= snd_soc_read(codec,
  2452. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx));
  2453. snd_soc_write(codec,
  2454. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2455. ((band_idx * BAND_MAX + coeff_idx)
  2456. * sizeof(uint32_t) + 1) & 0x7F);
  2457. value |= (snd_soc_read(codec,
  2458. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2459. 16 * iir_idx)) << 8);
  2460. snd_soc_write(codec,
  2461. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2462. ((band_idx * BAND_MAX + coeff_idx)
  2463. * sizeof(uint32_t) + 2) & 0x7F);
  2464. value |= (snd_soc_read(codec,
  2465. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2466. 16 * iir_idx)) << 16);
  2467. snd_soc_write(codec,
  2468. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  2469. ((band_idx * BAND_MAX + coeff_idx)
  2470. * sizeof(uint32_t) + 3) & 0x7F);
  2471. /* Mask bits top 2 bits since they are reserved */
  2472. value |= ((snd_soc_read(codec,
  2473. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL +
  2474. 16 * iir_idx)) & 0x3F) << 24);
  2475. return value;
  2476. }
  2477. static int tasha_get_iir_band_audio_mixer(
  2478. struct snd_kcontrol *kcontrol,
  2479. struct snd_ctl_elem_value *ucontrol)
  2480. {
  2481. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2482. int iir_idx = ((struct soc_multi_mixer_control *)
  2483. kcontrol->private_value)->reg;
  2484. int band_idx = ((struct soc_multi_mixer_control *)
  2485. kcontrol->private_value)->shift;
  2486. ucontrol->value.integer.value[0] =
  2487. get_iir_band_coeff(codec, iir_idx, band_idx, 0);
  2488. ucontrol->value.integer.value[1] =
  2489. get_iir_band_coeff(codec, iir_idx, band_idx, 1);
  2490. ucontrol->value.integer.value[2] =
  2491. get_iir_band_coeff(codec, iir_idx, band_idx, 2);
  2492. ucontrol->value.integer.value[3] =
  2493. get_iir_band_coeff(codec, iir_idx, band_idx, 3);
  2494. ucontrol->value.integer.value[4] =
  2495. get_iir_band_coeff(codec, iir_idx, band_idx, 4);
  2496. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  2497. "%s: IIR #%d band #%d b1 = 0x%x\n"
  2498. "%s: IIR #%d band #%d b2 = 0x%x\n"
  2499. "%s: IIR #%d band #%d a1 = 0x%x\n"
  2500. "%s: IIR #%d band #%d a2 = 0x%x\n",
  2501. __func__, iir_idx, band_idx,
  2502. (uint32_t)ucontrol->value.integer.value[0],
  2503. __func__, iir_idx, band_idx,
  2504. (uint32_t)ucontrol->value.integer.value[1],
  2505. __func__, iir_idx, band_idx,
  2506. (uint32_t)ucontrol->value.integer.value[2],
  2507. __func__, iir_idx, band_idx,
  2508. (uint32_t)ucontrol->value.integer.value[3],
  2509. __func__, iir_idx, band_idx,
  2510. (uint32_t)ucontrol->value.integer.value[4]);
  2511. return 0;
  2512. }
  2513. static void set_iir_band_coeff(struct snd_soc_codec *codec,
  2514. int iir_idx, int band_idx,
  2515. uint32_t value)
  2516. {
  2517. snd_soc_write(codec,
  2518. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2519. (value & 0xFF));
  2520. snd_soc_write(codec,
  2521. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2522. (value >> 8) & 0xFF);
  2523. snd_soc_write(codec,
  2524. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2525. (value >> 16) & 0xFF);
  2526. /* Mask top 2 bits, 7-8 are reserved */
  2527. snd_soc_write(codec,
  2528. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx),
  2529. (value >> 24) & 0x3F);
  2530. }
  2531. static void tasha_codec_enable_int_port(struct wcd9xxx_codec_dai_data *dai,
  2532. struct snd_soc_codec *codec)
  2533. {
  2534. struct wcd9xxx_ch *ch;
  2535. int port_num = 0;
  2536. unsigned short reg = 0;
  2537. u8 val = 0;
  2538. struct tasha_priv *tasha_p;
  2539. if (!dai || !codec) {
  2540. pr_err("%s: Invalid params\n", __func__);
  2541. return;
  2542. }
  2543. tasha_p = snd_soc_codec_get_drvdata(codec);
  2544. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2545. if (ch->port >= TASHA_RX_PORT_START_NUMBER) {
  2546. port_num = ch->port - TASHA_RX_PORT_START_NUMBER;
  2547. reg = TASHA_SLIM_PGD_PORT_INT_EN0 + (port_num / 8);
  2548. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2549. reg);
  2550. if (!(val & BYTE_BIT_MASK(port_num))) {
  2551. val |= BYTE_BIT_MASK(port_num);
  2552. wcd9xxx_interface_reg_write(
  2553. tasha_p->wcd9xxx, reg, val);
  2554. val = wcd9xxx_interface_reg_read(
  2555. tasha_p->wcd9xxx, reg);
  2556. }
  2557. } else {
  2558. port_num = ch->port;
  2559. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 + (port_num / 8);
  2560. val = wcd9xxx_interface_reg_read(tasha_p->wcd9xxx,
  2561. reg);
  2562. if (!(val & BYTE_BIT_MASK(port_num))) {
  2563. val |= BYTE_BIT_MASK(port_num);
  2564. wcd9xxx_interface_reg_write(tasha_p->wcd9xxx,
  2565. reg, val);
  2566. val = wcd9xxx_interface_reg_read(
  2567. tasha_p->wcd9xxx, reg);
  2568. }
  2569. }
  2570. }
  2571. }
  2572. static int tasha_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai,
  2573. bool up)
  2574. {
  2575. int ret = 0;
  2576. struct wcd9xxx_ch *ch;
  2577. if (up) {
  2578. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2579. ret = wcd9xxx_get_slave_port(ch->ch_num);
  2580. if (ret < 0) {
  2581. pr_err("%s: Invalid slave port ID: %d\n",
  2582. __func__, ret);
  2583. ret = -EINVAL;
  2584. } else {
  2585. set_bit(ret, &dai->ch_mask);
  2586. }
  2587. }
  2588. } else {
  2589. ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0),
  2590. msecs_to_jiffies(
  2591. TASHA_SLIM_CLOSE_TIMEOUT));
  2592. if (!ret) {
  2593. pr_err("%s: Slim close tx/rx wait timeout, ch_mask:0x%lx\n",
  2594. __func__, dai->ch_mask);
  2595. ret = -ETIMEDOUT;
  2596. } else {
  2597. ret = 0;
  2598. }
  2599. }
  2600. return ret;
  2601. }
  2602. static int tasha_codec_enable_slimrx(struct snd_soc_dapm_widget *w,
  2603. struct snd_kcontrol *kcontrol,
  2604. int event)
  2605. {
  2606. struct wcd9xxx *core;
  2607. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2608. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2609. int ret = 0;
  2610. struct wcd9xxx_codec_dai_data *dai;
  2611. core = dev_get_drvdata(codec->dev->parent);
  2612. dev_dbg(codec->dev, "%s: event called! codec name %s num_dai %d\n"
  2613. "stream name %s event %d\n",
  2614. __func__, codec->component.name,
  2615. codec->component.num_dai, w->sname, event);
  2616. /* Execute the callback only if interface type is slimbus */
  2617. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2618. return 0;
  2619. dai = &tasha_p->dai[w->shift];
  2620. dev_dbg(codec->dev, "%s: w->name %s w->shift %d event %d\n",
  2621. __func__, w->name, w->shift, event);
  2622. switch (event) {
  2623. case SND_SOC_DAPM_POST_PMU:
  2624. dai->bus_down_in_recovery = false;
  2625. tasha_codec_enable_int_port(dai, codec);
  2626. (void) tasha_codec_enable_slim_chmask(dai, true);
  2627. ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2628. dai->rate, dai->bit_width,
  2629. &dai->grph);
  2630. break;
  2631. case SND_SOC_DAPM_PRE_PMD:
  2632. tasha_codec_vote_max_bw(codec, true);
  2633. break;
  2634. case SND_SOC_DAPM_POST_PMD:
  2635. ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list,
  2636. dai->grph);
  2637. dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n",
  2638. __func__, ret);
  2639. if (!dai->bus_down_in_recovery)
  2640. ret = tasha_codec_enable_slim_chmask(dai, false);
  2641. else
  2642. dev_dbg(codec->dev,
  2643. "%s: bus in recovery skip enable slim_chmask",
  2644. __func__);
  2645. ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
  2646. dai->grph);
  2647. break;
  2648. }
  2649. return ret;
  2650. }
  2651. static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w,
  2652. struct snd_kcontrol *kcontrol,
  2653. int event)
  2654. {
  2655. struct wcd9xxx *core = NULL;
  2656. struct snd_soc_codec *codec = NULL;
  2657. struct tasha_priv *tasha_p = NULL;
  2658. int ret = 0;
  2659. struct wcd9xxx_codec_dai_data *dai = NULL;
  2660. if (!w) {
  2661. pr_err("%s invalid params\n", __func__);
  2662. return -EINVAL;
  2663. }
  2664. codec = snd_soc_dapm_to_codec(w->dapm);
  2665. tasha_p = snd_soc_codec_get_drvdata(codec);
  2666. core = tasha_p->wcd9xxx;
  2667. dev_dbg(codec->dev, "%s: num_dai %d stream name %s\n",
  2668. __func__, codec->component.num_dai, w->sname);
  2669. /* Execute the callback only if interface type is slimbus */
  2670. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  2671. dev_err(codec->dev, "%s Interface is not correct", __func__);
  2672. return 0;
  2673. }
  2674. dev_dbg(codec->dev, "%s(): w->name %s event %d w->shift %d\n",
  2675. __func__, w->name, event, w->shift);
  2676. if (w->shift != AIF4_VIFEED) {
  2677. pr_err("%s Error in enabling the tx path\n", __func__);
  2678. ret = -EINVAL;
  2679. goto out_vi;
  2680. }
  2681. dai = &tasha_p->dai[w->shift];
  2682. switch (event) {
  2683. case SND_SOC_DAPM_POST_PMU:
  2684. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2685. dev_dbg(codec->dev, "%s: spkr1 enabled\n", __func__);
  2686. /* Enable V&I sensing */
  2687. snd_soc_update_bits(codec,
  2688. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2689. snd_soc_update_bits(codec,
  2690. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2691. 0x20);
  2692. snd_soc_update_bits(codec,
  2693. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x00);
  2694. snd_soc_update_bits(codec,
  2695. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x0F,
  2696. 0x00);
  2697. snd_soc_update_bits(codec,
  2698. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10);
  2699. snd_soc_update_bits(codec,
  2700. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2701. 0x10);
  2702. snd_soc_update_bits(codec,
  2703. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00);
  2704. snd_soc_update_bits(codec,
  2705. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2706. 0x00);
  2707. }
  2708. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2709. pr_debug("%s: spkr2 enabled\n", __func__);
  2710. /* Enable V&I sensing */
  2711. snd_soc_update_bits(codec,
  2712. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2713. 0x20);
  2714. snd_soc_update_bits(codec,
  2715. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2716. 0x20);
  2717. snd_soc_update_bits(codec,
  2718. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x0F,
  2719. 0x00);
  2720. snd_soc_update_bits(codec,
  2721. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x0F,
  2722. 0x00);
  2723. snd_soc_update_bits(codec,
  2724. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2725. 0x10);
  2726. snd_soc_update_bits(codec,
  2727. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2728. 0x10);
  2729. snd_soc_update_bits(codec,
  2730. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2731. 0x00);
  2732. snd_soc_update_bits(codec,
  2733. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2734. 0x00);
  2735. }
  2736. dai->bus_down_in_recovery = false;
  2737. tasha_codec_enable_int_port(dai, codec);
  2738. (void) tasha_codec_enable_slim_chmask(dai, true);
  2739. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2740. dai->rate, dai->bit_width,
  2741. &dai->grph);
  2742. break;
  2743. case SND_SOC_DAPM_POST_PMD:
  2744. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2745. dai->grph);
  2746. if (ret)
  2747. dev_err(codec->dev, "%s error in close_slim_sch_tx %d\n",
  2748. __func__, ret);
  2749. if (!dai->bus_down_in_recovery)
  2750. ret = tasha_codec_enable_slim_chmask(dai, false);
  2751. if (ret < 0) {
  2752. ret = wcd9xxx_disconnect_port(core,
  2753. &dai->wcd9xxx_ch_list,
  2754. dai->grph);
  2755. dev_dbg(codec->dev, "%s: Disconnect TX port, ret = %d\n",
  2756. __func__, ret);
  2757. }
  2758. if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) {
  2759. /* Disable V&I sensing */
  2760. dev_dbg(codec->dev, "%s: spkr1 disabled\n", __func__);
  2761. snd_soc_update_bits(codec,
  2762. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20);
  2763. snd_soc_update_bits(codec,
  2764. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20,
  2765. 0x20);
  2766. snd_soc_update_bits(codec,
  2767. WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00);
  2768. snd_soc_update_bits(codec,
  2769. WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10,
  2770. 0x00);
  2771. }
  2772. if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) {
  2773. /* Disable V&I sensing */
  2774. dev_dbg(codec->dev, "%s: spkr2 disabled\n", __func__);
  2775. snd_soc_update_bits(codec,
  2776. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20,
  2777. 0x20);
  2778. snd_soc_update_bits(codec,
  2779. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20,
  2780. 0x20);
  2781. snd_soc_update_bits(codec,
  2782. WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10,
  2783. 0x00);
  2784. snd_soc_update_bits(codec,
  2785. WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10,
  2786. 0x00);
  2787. }
  2788. break;
  2789. }
  2790. out_vi:
  2791. return ret;
  2792. }
  2793. /*
  2794. * __tasha_codec_enable_slimtx: Enable the slimbus slave port
  2795. * for TX path
  2796. * @codec: Handle to the codec for which the slave port is to be
  2797. * enabled.
  2798. * @dai_data: The dai specific data for dai which is enabled.
  2799. */
  2800. static int __tasha_codec_enable_slimtx(struct snd_soc_codec *codec,
  2801. int event, struct wcd9xxx_codec_dai_data *dai)
  2802. {
  2803. struct wcd9xxx *core;
  2804. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2805. int ret = 0;
  2806. /* Execute the callback only if interface type is slimbus */
  2807. if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  2808. return 0;
  2809. dev_dbg(codec->dev,
  2810. "%s: event = %d\n", __func__, event);
  2811. core = dev_get_drvdata(codec->dev->parent);
  2812. switch (event) {
  2813. case SND_SOC_DAPM_POST_PMU:
  2814. dai->bus_down_in_recovery = false;
  2815. tasha_codec_enable_int_port(dai, codec);
  2816. (void) tasha_codec_enable_slim_chmask(dai, true);
  2817. ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2818. dai->rate, dai->bit_width,
  2819. &dai->grph);
  2820. break;
  2821. case SND_SOC_DAPM_POST_PMD:
  2822. ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
  2823. dai->grph);
  2824. if (!dai->bus_down_in_recovery)
  2825. ret = tasha_codec_enable_slim_chmask(dai, false);
  2826. if (ret < 0) {
  2827. ret = wcd9xxx_disconnect_port(core,
  2828. &dai->wcd9xxx_ch_list,
  2829. dai->grph);
  2830. pr_debug("%s: Disconnect TX port, ret = %d\n",
  2831. __func__, ret);
  2832. }
  2833. break;
  2834. }
  2835. return ret;
  2836. }
  2837. static int tasha_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
  2838. struct snd_kcontrol *kcontrol,
  2839. int event)
  2840. {
  2841. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2842. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2843. struct wcd9xxx_codec_dai_data *dai;
  2844. dev_dbg(codec->dev,
  2845. "%s: w->name %s, w->shift = %d, num_dai %d stream name %s\n",
  2846. __func__, w->name, w->shift,
  2847. codec->component.num_dai, w->sname);
  2848. dai = &tasha_p->dai[w->shift];
  2849. return __tasha_codec_enable_slimtx(codec, event, dai);
  2850. }
  2851. static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_codec *codec, int event)
  2852. {
  2853. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2854. struct wcd9xxx_codec_dai_data *dai;
  2855. u8 bit_width, rate, buf_period;
  2856. dai = &tasha_p->dai[AIF4_MAD_TX];
  2857. switch (event) {
  2858. case SND_SOC_DAPM_POST_PMU:
  2859. switch (dai->bit_width) {
  2860. case 32:
  2861. bit_width = 0xF;
  2862. break;
  2863. case 24:
  2864. bit_width = 0xE;
  2865. break;
  2866. case 20:
  2867. bit_width = 0xD;
  2868. break;
  2869. case 16:
  2870. default:
  2871. bit_width = 0x0;
  2872. break;
  2873. }
  2874. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x0F,
  2875. bit_width);
  2876. switch (dai->rate) {
  2877. case 384000:
  2878. rate = 0x30;
  2879. break;
  2880. case 192000:
  2881. rate = 0x20;
  2882. break;
  2883. case 48000:
  2884. rate = 0x10;
  2885. break;
  2886. case 16000:
  2887. default:
  2888. rate = 0x00;
  2889. break;
  2890. }
  2891. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x70,
  2892. rate);
  2893. buf_period = (dai->rate * (dai->bit_width/8)) / (16*1000);
  2894. snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD,
  2895. 0xFF, buf_period);
  2896. dev_dbg(codec->dev, "%s: PP buffer period= 0x%x\n",
  2897. __func__, buf_period);
  2898. break;
  2899. case SND_SOC_DAPM_POST_PMD:
  2900. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x3C);
  2901. snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD, 0x60);
  2902. break;
  2903. default:
  2904. break;
  2905. }
  2906. }
  2907. /*
  2908. * tasha_codec_get_mad_port_id: Callback function that will be invoked
  2909. * to get the port ID for MAD.
  2910. * @codec: Handle to the codec
  2911. * @port_id: cpe port_id needs to enable
  2912. */
  2913. static int tasha_codec_get_mad_port_id(struct snd_soc_codec *codec,
  2914. u16 *port_id)
  2915. {
  2916. struct tasha_priv *tasha_p;
  2917. struct wcd9xxx_codec_dai_data *dai;
  2918. struct wcd9xxx_ch *ch;
  2919. if (!port_id || !codec)
  2920. return -EINVAL;
  2921. tasha_p = snd_soc_codec_get_drvdata(codec);
  2922. if (!tasha_p)
  2923. return -EINVAL;
  2924. dai = &tasha_p->dai[AIF4_MAD_TX];
  2925. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2926. if (ch->port == TASHA_TX12)
  2927. *port_id = WCD_CPE_AFE_OUT_PORT_2;
  2928. else if (ch->port == TASHA_TX13)
  2929. *port_id = WCD_CPE_AFE_OUT_PORT_4;
  2930. else {
  2931. dev_err(codec->dev, "%s: invalid mad_port = %d\n",
  2932. __func__, ch->port);
  2933. return -EINVAL;
  2934. }
  2935. }
  2936. dev_dbg(codec->dev, "%s: port_id = %d\n", __func__, *port_id);
  2937. return 0;
  2938. }
  2939. /*
  2940. * tasha_codec_enable_slimtx_mad: Callback function that will be invoked
  2941. * to setup the slave port for MAD.
  2942. * @codec: Handle to the codec
  2943. * @event: Indicates whether to enable or disable the slave port
  2944. */
  2945. static int tasha_codec_enable_slimtx_mad(struct snd_soc_codec *codec,
  2946. u8 event)
  2947. {
  2948. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  2949. struct wcd9xxx_codec_dai_data *dai;
  2950. struct wcd9xxx_ch *ch;
  2951. int dapm_event = SND_SOC_DAPM_POST_PMU;
  2952. u16 port = 0;
  2953. int ret = 0;
  2954. dai = &tasha_p->dai[AIF4_MAD_TX];
  2955. if (event == 0)
  2956. dapm_event = SND_SOC_DAPM_POST_PMD;
  2957. dev_dbg(codec->dev,
  2958. "%s: mad_channel, event = 0x%x\n",
  2959. __func__, event);
  2960. list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
  2961. dev_dbg(codec->dev, "%s: mad_port = %d, event = 0x%x\n",
  2962. __func__, ch->port, event);
  2963. if (ch->port == TASHA_TX13) {
  2964. tasha_codec_cpe_pp_set_cfg(codec, dapm_event);
  2965. port = TASHA_TX13;
  2966. break;
  2967. }
  2968. }
  2969. ret = __tasha_codec_enable_slimtx(codec, dapm_event, dai);
  2970. if (port == TASHA_TX13) {
  2971. switch (dapm_event) {
  2972. case SND_SOC_DAPM_POST_PMU:
  2973. snd_soc_update_bits(codec,
  2974. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2975. 0x20, 0x00);
  2976. snd_soc_update_bits(codec,
  2977. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2978. 0x03, 0x02);
  2979. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2980. 0x80, 0x80);
  2981. break;
  2982. case SND_SOC_DAPM_POST_PMD:
  2983. snd_soc_update_bits(codec,
  2984. WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN,
  2985. 0x20, 0x20);
  2986. snd_soc_update_bits(codec,
  2987. WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG,
  2988. 0x03, 0x00);
  2989. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG,
  2990. 0x80, 0x00);
  2991. break;
  2992. }
  2993. }
  2994. return ret;
  2995. }
  2996. static int tasha_put_iir_band_audio_mixer(
  2997. struct snd_kcontrol *kcontrol,
  2998. struct snd_ctl_elem_value *ucontrol)
  2999. {
  3000. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3001. int iir_idx = ((struct soc_multi_mixer_control *)
  3002. kcontrol->private_value)->reg;
  3003. int band_idx = ((struct soc_multi_mixer_control *)
  3004. kcontrol->private_value)->shift;
  3005. /*
  3006. * Mask top bit it is reserved
  3007. * Updates addr automatically for each B2 write
  3008. */
  3009. snd_soc_write(codec,
  3010. (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
  3011. (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
  3012. set_iir_band_coeff(codec, iir_idx, band_idx,
  3013. ucontrol->value.integer.value[0]);
  3014. set_iir_band_coeff(codec, iir_idx, band_idx,
  3015. ucontrol->value.integer.value[1]);
  3016. set_iir_band_coeff(codec, iir_idx, band_idx,
  3017. ucontrol->value.integer.value[2]);
  3018. set_iir_band_coeff(codec, iir_idx, band_idx,
  3019. ucontrol->value.integer.value[3]);
  3020. set_iir_band_coeff(codec, iir_idx, band_idx,
  3021. ucontrol->value.integer.value[4]);
  3022. pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n"
  3023. "%s: IIR #%d band #%d b1 = 0x%x\n"
  3024. "%s: IIR #%d band #%d b2 = 0x%x\n"
  3025. "%s: IIR #%d band #%d a1 = 0x%x\n"
  3026. "%s: IIR #%d band #%d a2 = 0x%x\n",
  3027. __func__, iir_idx, band_idx,
  3028. get_iir_band_coeff(codec, iir_idx, band_idx, 0),
  3029. __func__, iir_idx, band_idx,
  3030. get_iir_band_coeff(codec, iir_idx, band_idx, 1),
  3031. __func__, iir_idx, band_idx,
  3032. get_iir_band_coeff(codec, iir_idx, band_idx, 2),
  3033. __func__, iir_idx, band_idx,
  3034. get_iir_band_coeff(codec, iir_idx, band_idx, 3),
  3035. __func__, iir_idx, band_idx,
  3036. get_iir_band_coeff(codec, iir_idx, band_idx, 4));
  3037. return 0;
  3038. }
  3039. static int tasha_get_compander(struct snd_kcontrol *kcontrol,
  3040. struct snd_ctl_elem_value *ucontrol)
  3041. {
  3042. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3043. int comp = ((struct soc_multi_mixer_control *)
  3044. kcontrol->private_value)->shift;
  3045. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3046. ucontrol->value.integer.value[0] = tasha->comp_enabled[comp];
  3047. return 0;
  3048. }
  3049. static int tasha_set_compander(struct snd_kcontrol *kcontrol,
  3050. struct snd_ctl_elem_value *ucontrol)
  3051. {
  3052. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  3053. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3054. int comp = ((struct soc_multi_mixer_control *)
  3055. kcontrol->private_value)->shift;
  3056. int value = ucontrol->value.integer.value[0];
  3057. pr_debug("%s: Compander %d enable current %d, new %d\n",
  3058. __func__, comp + 1, tasha->comp_enabled[comp], value);
  3059. tasha->comp_enabled[comp] = value;
  3060. /* Any specific register configuration for compander */
  3061. switch (comp) {
  3062. case COMPANDER_1:
  3063. /* Set Gain Source Select based on compander enable/disable */
  3064. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0x20,
  3065. (value ? 0x00:0x20));
  3066. break;
  3067. case COMPANDER_2:
  3068. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0x20,
  3069. (value ? 0x00:0x20));
  3070. break;
  3071. case COMPANDER_3:
  3072. break;
  3073. case COMPANDER_4:
  3074. break;
  3075. case COMPANDER_5:
  3076. snd_soc_update_bits(codec, WCD9335_SE_LO_LO3_GAIN, 0x20,
  3077. (value ? 0x00:0x20));
  3078. break;
  3079. case COMPANDER_6:
  3080. snd_soc_update_bits(codec, WCD9335_SE_LO_LO4_GAIN, 0x20,
  3081. (value ? 0x00:0x20));
  3082. break;
  3083. case COMPANDER_7:
  3084. break;
  3085. case COMPANDER_8:
  3086. break;
  3087. default:
  3088. /*
  3089. * if compander is not enabled for any interpolator,
  3090. * it does not cause any audio failure, so do not
  3091. * return error in this case, but just print a log
  3092. */
  3093. dev_warn(codec->dev, "%s: unknown compander: %d\n",
  3094. __func__, comp);
  3095. };
  3096. return 0;
  3097. }
  3098. static void tasha_codec_init_flyback(struct snd_soc_codec *codec)
  3099. {
  3100. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x00);
  3101. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x00);
  3102. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0x0F, 0x00);
  3103. snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0xF0, 0x00);
  3104. }
  3105. static int tasha_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
  3106. struct snd_kcontrol *kcontrol, int event)
  3107. {
  3108. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3109. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3110. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3111. switch (event) {
  3112. case SND_SOC_DAPM_PRE_PMU:
  3113. tasha->rx_bias_count++;
  3114. if (tasha->rx_bias_count == 1) {
  3115. if (TASHA_IS_2_0(tasha->wcd9xxx))
  3116. tasha_codec_init_flyback(codec);
  3117. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3118. 0x01, 0x01);
  3119. }
  3120. break;
  3121. case SND_SOC_DAPM_POST_PMD:
  3122. tasha->rx_bias_count--;
  3123. if (!tasha->rx_bias_count)
  3124. snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES,
  3125. 0x01, 0x00);
  3126. break;
  3127. };
  3128. dev_dbg(codec->dev, "%s: Current RX BIAS user count: %d\n", __func__,
  3129. tasha->rx_bias_count);
  3130. return 0;
  3131. }
  3132. static void tasha_realign_anc_coeff(struct snd_soc_codec *codec,
  3133. u16 reg1, u16 reg2)
  3134. {
  3135. u8 val1, val2, tmpval1, tmpval2;
  3136. snd_soc_write(codec, reg1, 0x00);
  3137. tmpval1 = snd_soc_read(codec, reg2);
  3138. tmpval2 = snd_soc_read(codec, reg2);
  3139. snd_soc_write(codec, reg1, 0x00);
  3140. snd_soc_write(codec, reg2, 0xFF);
  3141. snd_soc_write(codec, reg1, 0x01);
  3142. snd_soc_write(codec, reg2, 0xFF);
  3143. snd_soc_write(codec, reg1, 0x00);
  3144. val1 = snd_soc_read(codec, reg2);
  3145. val2 = snd_soc_read(codec, reg2);
  3146. if (val1 == 0x0F && val2 == 0xFF) {
  3147. dev_dbg(codec->dev, "%s: ANC0 co-eff index re-aligned\n",
  3148. __func__);
  3149. snd_soc_read(codec, reg2);
  3150. snd_soc_write(codec, reg1, 0x00);
  3151. snd_soc_write(codec, reg2, tmpval2);
  3152. snd_soc_write(codec, reg1, 0x01);
  3153. snd_soc_write(codec, reg2, tmpval1);
  3154. } else if (val1 == 0xFF && val2 == 0x0F) {
  3155. dev_dbg(codec->dev, "%s: ANC1 co-eff index already aligned\n",
  3156. __func__);
  3157. snd_soc_write(codec, reg1, 0x00);
  3158. snd_soc_write(codec, reg2, tmpval1);
  3159. snd_soc_write(codec, reg1, 0x01);
  3160. snd_soc_write(codec, reg2, tmpval2);
  3161. } else {
  3162. dev_err(codec->dev, "%s: ANC0 co-eff index not aligned\n",
  3163. __func__);
  3164. }
  3165. }
  3166. static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w,
  3167. struct snd_kcontrol *kcontrol, int event)
  3168. {
  3169. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3170. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3171. const char *filename;
  3172. const struct firmware *fw;
  3173. int i;
  3174. int ret = 0;
  3175. int num_anc_slots;
  3176. struct wcd9xxx_anc_header *anc_head;
  3177. struct firmware_cal *hwdep_cal = NULL;
  3178. u32 anc_writes_size = 0;
  3179. u32 anc_cal_size = 0;
  3180. int anc_size_remaining;
  3181. u32 *anc_ptr;
  3182. u16 reg;
  3183. u8 mask, val;
  3184. size_t cal_size;
  3185. const void *data;
  3186. if (!tasha->anc_func)
  3187. return 0;
  3188. switch (event) {
  3189. case SND_SOC_DAPM_PRE_PMU:
  3190. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_ANC_CAL);
  3191. if (hwdep_cal) {
  3192. data = hwdep_cal->data;
  3193. cal_size = hwdep_cal->size;
  3194. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  3195. __func__);
  3196. } else {
  3197. filename = "wcd9335/wcd9335_anc.bin";
  3198. ret = request_firmware(&fw, filename, codec->dev);
  3199. if (ret != 0) {
  3200. dev_err(codec->dev,
  3201. "Failed to acquire ANC data: %d\n", ret);
  3202. return -ENODEV;
  3203. }
  3204. if (!fw) {
  3205. dev_err(codec->dev, "failed to get anc fw");
  3206. return -ENODEV;
  3207. }
  3208. data = fw->data;
  3209. cal_size = fw->size;
  3210. dev_dbg(codec->dev,
  3211. "%s: using request_firmware calibration\n", __func__);
  3212. }
  3213. if (cal_size < sizeof(struct wcd9xxx_anc_header)) {
  3214. dev_err(codec->dev, "Not enough data\n");
  3215. ret = -ENOMEM;
  3216. goto err;
  3217. }
  3218. /* First number is the number of register writes */
  3219. anc_head = (struct wcd9xxx_anc_header *)(data);
  3220. anc_ptr = (u32 *)(data +
  3221. sizeof(struct wcd9xxx_anc_header));
  3222. anc_size_remaining = cal_size -
  3223. sizeof(struct wcd9xxx_anc_header);
  3224. num_anc_slots = anc_head->num_anc_slots;
  3225. if (tasha->anc_slot >= num_anc_slots) {
  3226. dev_err(codec->dev, "Invalid ANC slot selected\n");
  3227. ret = -EINVAL;
  3228. goto err;
  3229. }
  3230. for (i = 0; i < num_anc_slots; i++) {
  3231. if (anc_size_remaining < TASHA_PACKED_REG_SIZE) {
  3232. dev_err(codec->dev,
  3233. "Invalid register format\n");
  3234. ret = -EINVAL;
  3235. goto err;
  3236. }
  3237. anc_writes_size = (u32)(*anc_ptr);
  3238. anc_size_remaining -= sizeof(u32);
  3239. anc_ptr += 1;
  3240. if (anc_writes_size * TASHA_PACKED_REG_SIZE
  3241. > anc_size_remaining) {
  3242. dev_err(codec->dev,
  3243. "Invalid register format\n");
  3244. ret = -EINVAL;
  3245. goto err;
  3246. }
  3247. if (tasha->anc_slot == i)
  3248. break;
  3249. anc_size_remaining -= (anc_writes_size *
  3250. TASHA_PACKED_REG_SIZE);
  3251. anc_ptr += anc_writes_size;
  3252. }
  3253. if (i == num_anc_slots) {
  3254. dev_err(codec->dev, "Selected ANC slot not present\n");
  3255. ret = -EINVAL;
  3256. goto err;
  3257. }
  3258. i = 0;
  3259. anc_cal_size = anc_writes_size;
  3260. if (!strcmp(w->name, "RX INT0 DAC") ||
  3261. !strcmp(w->name, "ANC SPK1 PA"))
  3262. tasha_realign_anc_coeff(codec,
  3263. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3264. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3265. if (!strcmp(w->name, "RX INT1 DAC") ||
  3266. !strcmp(w->name, "RX INT3 DAC")) {
  3267. tasha_realign_anc_coeff(codec,
  3268. WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
  3269. WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
  3270. anc_writes_size = anc_cal_size / 2;
  3271. snd_soc_update_bits(codec,
  3272. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x39, 0x39);
  3273. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3274. !strcmp(w->name, "RX INT4 DAC")) {
  3275. tasha_realign_anc_coeff(codec,
  3276. WCD9335_CDC_ANC1_IIR_COEFF_1_CTL,
  3277. WCD9335_CDC_ANC1_IIR_COEFF_2_CTL);
  3278. i = anc_cal_size / 2;
  3279. snd_soc_update_bits(codec,
  3280. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x39, 0x39);
  3281. }
  3282. for (; i < anc_writes_size; i++) {
  3283. TASHA_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val);
  3284. snd_soc_write(codec, reg, (val & mask));
  3285. }
  3286. if (!strcmp(w->name, "RX INT1 DAC") ||
  3287. !strcmp(w->name, "RX INT3 DAC")) {
  3288. snd_soc_update_bits(codec,
  3289. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08);
  3290. } else if (!strcmp(w->name, "RX INT2 DAC") ||
  3291. !strcmp(w->name, "RX INT4 DAC")) {
  3292. snd_soc_update_bits(codec,
  3293. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08);
  3294. }
  3295. if (!hwdep_cal)
  3296. release_firmware(fw);
  3297. break;
  3298. case SND_SOC_DAPM_POST_PMU:
  3299. /* Remove ANC Rx from reset */
  3300. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_CLK_RESET_CTL,
  3301. 0x08, 0x00);
  3302. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_CLK_RESET_CTL,
  3303. 0x08, 0x00);
  3304. break;
  3305. case SND_SOC_DAPM_POST_PMD:
  3306. if (!strcmp(w->name, "ANC HPHL PA") ||
  3307. !strcmp(w->name, "ANC EAR PA") ||
  3308. !strcmp(w->name, "ANC SPK1 PA") ||
  3309. !strcmp(w->name, "ANC LINEOUT1 PA")) {
  3310. snd_soc_update_bits(codec,
  3311. WCD9335_CDC_ANC0_MODE_1_CTL, 0x30, 0x00);
  3312. msleep(50);
  3313. snd_soc_update_bits(codec,
  3314. WCD9335_CDC_ANC0_MODE_1_CTL, 0x01, 0x00);
  3315. snd_soc_update_bits(codec,
  3316. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x38);
  3317. snd_soc_update_bits(codec,
  3318. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x07, 0x00);
  3319. snd_soc_update_bits(codec,
  3320. WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x00);
  3321. } else if (!strcmp(w->name, "ANC HPHR PA") ||
  3322. !strcmp(w->name, "ANC LINEOUT2 PA")) {
  3323. snd_soc_update_bits(codec,
  3324. WCD9335_CDC_ANC1_MODE_1_CTL, 0x30, 0x00);
  3325. msleep(50);
  3326. snd_soc_update_bits(codec,
  3327. WCD9335_CDC_ANC1_MODE_1_CTL, 0x01, 0x00);
  3328. snd_soc_update_bits(codec,
  3329. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x38);
  3330. snd_soc_update_bits(codec,
  3331. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x07, 0x00);
  3332. snd_soc_update_bits(codec,
  3333. WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x00);
  3334. }
  3335. break;
  3336. }
  3337. return 0;
  3338. err:
  3339. if (!hwdep_cal)
  3340. release_firmware(fw);
  3341. return ret;
  3342. }
  3343. static void tasha_codec_clear_anc_tx_hold(struct tasha_priv *tasha)
  3344. {
  3345. if (test_and_clear_bit(ANC_MIC_AMIC1, &tasha->status_mask))
  3346. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC1, false);
  3347. if (test_and_clear_bit(ANC_MIC_AMIC2, &tasha->status_mask))
  3348. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC2, false);
  3349. if (test_and_clear_bit(ANC_MIC_AMIC3, &tasha->status_mask))
  3350. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC3, false);
  3351. if (test_and_clear_bit(ANC_MIC_AMIC4, &tasha->status_mask))
  3352. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC4, false);
  3353. if (test_and_clear_bit(ANC_MIC_AMIC5, &tasha->status_mask))
  3354. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC5, false);
  3355. if (test_and_clear_bit(ANC_MIC_AMIC6, &tasha->status_mask))
  3356. tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC6, false);
  3357. }
  3358. static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha,
  3359. int mode, int event)
  3360. {
  3361. u8 scale_val = 0;
  3362. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3363. return;
  3364. switch (event) {
  3365. case SND_SOC_DAPM_POST_PMU:
  3366. switch (mode) {
  3367. case CLS_H_HIFI:
  3368. scale_val = 0x3;
  3369. break;
  3370. case CLS_H_LOHIFI:
  3371. scale_val = 0x1;
  3372. break;
  3373. }
  3374. if (tasha->anc_func) {
  3375. /* Clear Tx FE HOLD if both PAs are enabled */
  3376. if ((snd_soc_read(tasha->codec, WCD9335_ANA_HPH) &
  3377. 0xC0) == 0xC0) {
  3378. tasha_codec_clear_anc_tx_hold(tasha);
  3379. }
  3380. }
  3381. break;
  3382. case SND_SOC_DAPM_PRE_PMD:
  3383. scale_val = 0x6;
  3384. break;
  3385. }
  3386. if (scale_val)
  3387. snd_soc_update_bits(tasha->codec, WCD9335_HPH_PA_CTL1, 0x0E,
  3388. scale_val << 1);
  3389. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3390. if (tasha->comp_enabled[COMPANDER_1] ||
  3391. tasha->comp_enabled[COMPANDER_2]) {
  3392. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN,
  3393. 0x20, 0x00);
  3394. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN,
  3395. 0x20, 0x00);
  3396. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP,
  3397. 0x20, 0x20);
  3398. }
  3399. snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN, 0x1F,
  3400. tasha->hph_l_gain);
  3401. snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN, 0x1F,
  3402. tasha->hph_r_gain);
  3403. }
  3404. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3405. snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP, 0x20,
  3406. 0x00);
  3407. }
  3408. }
  3409. static void tasha_codec_override(struct snd_soc_codec *codec,
  3410. int mode,
  3411. int event)
  3412. {
  3413. if (mode == CLS_AB) {
  3414. switch (event) {
  3415. case SND_SOC_DAPM_POST_PMU:
  3416. if (!(snd_soc_read(codec,
  3417. WCD9335_CDC_RX2_RX_PATH_CTL) & 0x10) &&
  3418. (!(snd_soc_read(codec,
  3419. WCD9335_CDC_RX1_RX_PATH_CTL) & 0x10)))
  3420. snd_soc_update_bits(codec,
  3421. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x02);
  3422. break;
  3423. case SND_SOC_DAPM_POST_PMD:
  3424. snd_soc_update_bits(codec,
  3425. WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00);
  3426. break;
  3427. }
  3428. }
  3429. }
  3430. static int tasha_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
  3431. struct snd_kcontrol *kcontrol,
  3432. int event)
  3433. {
  3434. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3435. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3436. int hph_mode = tasha->hph_mode;
  3437. int ret = 0;
  3438. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3439. switch (event) {
  3440. case SND_SOC_DAPM_PRE_PMU:
  3441. if ((!(strcmp(w->name, "ANC HPHR PA"))) &&
  3442. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3443. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3444. }
  3445. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3446. if (!(strcmp(w->name, "HPHR PA")))
  3447. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x40);
  3448. break;
  3449. case SND_SOC_DAPM_POST_PMU:
  3450. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3451. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3452. != 0xC0)
  3453. /*
  3454. * If PA_EN is not set (potentially in ANC case)
  3455. * then do nothing for POST_PMU and let left
  3456. * channel handle everything.
  3457. */
  3458. break;
  3459. }
  3460. /*
  3461. * 7ms sleep is required after PA is enabled as per
  3462. * HW requirement
  3463. */
  3464. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3465. usleep_range(7000, 7100);
  3466. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3467. }
  3468. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3469. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3470. 0x10, 0x00);
  3471. /* Remove mix path mute if it is enabled */
  3472. if ((snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3473. 0x10)
  3474. snd_soc_update_bits(codec,
  3475. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3476. 0x10, 0x00);
  3477. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3478. /* Do everything needed for left channel */
  3479. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3480. 0x10, 0x00);
  3481. /* Remove mix path mute if it is enabled */
  3482. if ((snd_soc_read(codec,
  3483. WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3484. 0x10)
  3485. snd_soc_update_bits(codec,
  3486. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3487. 0x10, 0x00);
  3488. /* Remove ANC Rx from reset */
  3489. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3490. }
  3491. tasha_codec_override(codec, hph_mode, event);
  3492. break;
  3493. case SND_SOC_DAPM_PRE_PMD:
  3494. blocking_notifier_call_chain(&tasha->notifier,
  3495. WCD_EVENT_PRE_HPHR_PA_OFF,
  3496. &tasha->mbhc);
  3497. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3498. if (!(strcmp(w->name, "ANC HPHR PA")) ||
  3499. !(strcmp(w->name, "HPHR PA")))
  3500. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x00);
  3501. break;
  3502. case SND_SOC_DAPM_POST_PMD:
  3503. /* 5ms sleep is required after PA is disabled as per
  3504. * HW requirement
  3505. */
  3506. usleep_range(5000, 5500);
  3507. tasha_codec_override(codec, hph_mode, event);
  3508. blocking_notifier_call_chain(&tasha->notifier,
  3509. WCD_EVENT_POST_HPHR_PA_OFF,
  3510. &tasha->mbhc);
  3511. if (!(strcmp(w->name, "ANC HPHR PA"))) {
  3512. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3513. snd_soc_update_bits(codec,
  3514. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x00);
  3515. }
  3516. break;
  3517. };
  3518. return ret;
  3519. }
  3520. static int tasha_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
  3521. struct snd_kcontrol *kcontrol,
  3522. int event)
  3523. {
  3524. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3525. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3526. int hph_mode = tasha->hph_mode;
  3527. int ret = 0;
  3528. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3529. switch (event) {
  3530. case SND_SOC_DAPM_PRE_PMU:
  3531. if ((!(strcmp(w->name, "ANC HPHL PA"))) &&
  3532. (test_bit(HPH_PA_DELAY, &tasha->status_mask))) {
  3533. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0);
  3534. }
  3535. if (!(strcmp(w->name, "HPHL PA")))
  3536. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x80);
  3537. set_bit(HPH_PA_DELAY, &tasha->status_mask);
  3538. break;
  3539. case SND_SOC_DAPM_POST_PMU:
  3540. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3541. if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0)
  3542. != 0xC0)
  3543. /*
  3544. * If PA_EN is not set (potentially in ANC case)
  3545. * then do nothing for POST_PMU and let right
  3546. * channel handle everything.
  3547. */
  3548. break;
  3549. }
  3550. /*
  3551. * 7ms sleep is required after PA is enabled as per
  3552. * HW requirement
  3553. */
  3554. if (test_bit(HPH_PA_DELAY, &tasha->status_mask)) {
  3555. usleep_range(7000, 7100);
  3556. clear_bit(HPH_PA_DELAY, &tasha->status_mask);
  3557. }
  3558. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3559. snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL,
  3560. 0x10, 0x00);
  3561. /* Remove mix path mute if it is enabled */
  3562. if ((snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) &
  3563. 0x10)
  3564. snd_soc_update_bits(codec,
  3565. WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  3566. 0x10, 0x00);
  3567. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3568. /* Do everything needed for right channel */
  3569. snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL,
  3570. 0x10, 0x00);
  3571. /* Remove mix path mute if it is enabled */
  3572. if ((snd_soc_read(codec,
  3573. WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) &
  3574. 0x10)
  3575. snd_soc_update_bits(codec,
  3576. WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  3577. 0x10, 0x00);
  3578. /* Remove ANC Rx from reset */
  3579. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3580. }
  3581. tasha_codec_override(codec, hph_mode, event);
  3582. break;
  3583. case SND_SOC_DAPM_PRE_PMD:
  3584. blocking_notifier_call_chain(&tasha->notifier,
  3585. WCD_EVENT_PRE_HPHL_PA_OFF,
  3586. &tasha->mbhc);
  3587. tasha_codec_hph_post_pa_config(tasha, hph_mode, event);
  3588. if (!(strcmp(w->name, "ANC HPHL PA")) ||
  3589. !(strcmp(w->name, "HPHL PA")))
  3590. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x00);
  3591. break;
  3592. case SND_SOC_DAPM_POST_PMD:
  3593. /* 5ms sleep is required after PA is disabled as per
  3594. * HW requirement
  3595. */
  3596. usleep_range(5000, 5500);
  3597. tasha_codec_override(codec, hph_mode, event);
  3598. blocking_notifier_call_chain(&tasha->notifier,
  3599. WCD_EVENT_POST_HPHL_PA_OFF,
  3600. &tasha->mbhc);
  3601. if (!(strcmp(w->name, "ANC HPHL PA"))) {
  3602. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3603. snd_soc_update_bits(codec,
  3604. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00);
  3605. }
  3606. break;
  3607. };
  3608. return ret;
  3609. }
  3610. static int tasha_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w,
  3611. struct snd_kcontrol *kcontrol,
  3612. int event)
  3613. {
  3614. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3615. u16 lineout_vol_reg = 0, lineout_mix_vol_reg = 0;
  3616. int ret = 0;
  3617. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3618. if (w->reg == WCD9335_ANA_LO_1_2) {
  3619. if (w->shift == 7) {
  3620. lineout_vol_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  3621. lineout_mix_vol_reg = WCD9335_CDC_RX3_RX_PATH_MIX_CTL;
  3622. } else if (w->shift == 6) {
  3623. lineout_vol_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  3624. lineout_mix_vol_reg = WCD9335_CDC_RX4_RX_PATH_MIX_CTL;
  3625. }
  3626. } else if (w->reg == WCD9335_ANA_LO_3_4) {
  3627. if (w->shift == 7) {
  3628. lineout_vol_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  3629. lineout_mix_vol_reg = WCD9335_CDC_RX5_RX_PATH_MIX_CTL;
  3630. } else if (w->shift == 6) {
  3631. lineout_vol_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  3632. lineout_mix_vol_reg = WCD9335_CDC_RX6_RX_PATH_MIX_CTL;
  3633. }
  3634. } else {
  3635. dev_err(codec->dev, "%s: Error enabling lineout PA\n",
  3636. __func__);
  3637. return -EINVAL;
  3638. }
  3639. switch (event) {
  3640. case SND_SOC_DAPM_POST_PMU:
  3641. /* 5ms sleep is required after PA is enabled as per
  3642. * HW requirement
  3643. */
  3644. usleep_range(5000, 5500);
  3645. snd_soc_update_bits(codec, lineout_vol_reg,
  3646. 0x10, 0x00);
  3647. /* Remove mix path mute if it is enabled */
  3648. if ((snd_soc_read(codec, lineout_mix_vol_reg)) & 0x10)
  3649. snd_soc_update_bits(codec,
  3650. lineout_mix_vol_reg,
  3651. 0x10, 0x00);
  3652. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3653. !(strcmp(w->name, "ANC LINEOUT2 PA")))
  3654. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3655. tasha_codec_override(codec, CLS_AB, event);
  3656. break;
  3657. case SND_SOC_DAPM_POST_PMD:
  3658. /* 5ms sleep is required after PA is disabled as per
  3659. * HW requirement
  3660. */
  3661. usleep_range(5000, 5500);
  3662. tasha_codec_override(codec, CLS_AB, event);
  3663. if (!(strcmp(w->name, "ANC LINEOUT1 PA")) ||
  3664. !(strcmp(w->name, "ANC LINEOUT2 PA"))) {
  3665. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3666. if (!(strcmp(w->name, "ANC LINEOUT1 PA")))
  3667. snd_soc_update_bits(codec,
  3668. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  3669. else
  3670. snd_soc_update_bits(codec,
  3671. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  3672. }
  3673. break;
  3674. };
  3675. return ret;
  3676. }
  3677. static void tasha_spk_anc_update_callback(struct work_struct *work)
  3678. {
  3679. struct spk_anc_work *spk_anc_dwork;
  3680. struct tasha_priv *tasha;
  3681. struct delayed_work *delayed_work;
  3682. struct snd_soc_codec *codec;
  3683. delayed_work = to_delayed_work(work);
  3684. spk_anc_dwork = container_of(delayed_work, struct spk_anc_work, dwork);
  3685. tasha = spk_anc_dwork->tasha;
  3686. codec = tasha->codec;
  3687. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0, 0x10, 0x10);
  3688. }
  3689. static int tasha_codec_enable_spk_anc(struct snd_soc_dapm_widget *w,
  3690. struct snd_kcontrol *kcontrol,
  3691. int event)
  3692. {
  3693. int ret = 0;
  3694. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3695. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3696. dev_dbg(codec->dev, "%s %s %d %d\n", __func__, w->name, event,
  3697. tasha->anc_func);
  3698. if (!tasha->anc_func)
  3699. return 0;
  3700. switch (event) {
  3701. case SND_SOC_DAPM_PRE_PMU:
  3702. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3703. schedule_delayed_work(&tasha->spk_anc_dwork.dwork,
  3704. msecs_to_jiffies(spk_anc_en_delay));
  3705. break;
  3706. case SND_SOC_DAPM_POST_PMD:
  3707. cancel_delayed_work_sync(&tasha->spk_anc_dwork.dwork);
  3708. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0,
  3709. 0x10, 0x00);
  3710. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3711. break;
  3712. }
  3713. return ret;
  3714. }
  3715. static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
  3716. struct snd_kcontrol *kcontrol,
  3717. int event)
  3718. {
  3719. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3720. int ret = 0;
  3721. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  3722. switch (event) {
  3723. case SND_SOC_DAPM_POST_PMU:
  3724. /* 5ms sleep is required after PA is enabled as per
  3725. * HW requirement
  3726. */
  3727. usleep_range(5000, 5500);
  3728. snd_soc_update_bits(codec, WCD9335_CDC_RX0_RX_PATH_CTL,
  3729. 0x10, 0x00);
  3730. /* Remove mix path mute if it is enabled */
  3731. if ((snd_soc_read(codec, WCD9335_CDC_RX0_RX_PATH_MIX_CTL)) &
  3732. 0x10)
  3733. snd_soc_update_bits(codec,
  3734. WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  3735. 0x10, 0x00);
  3736. break;
  3737. case SND_SOC_DAPM_POST_PMD:
  3738. /* 5ms sleep is required after PA is disabled as per
  3739. * HW requirement
  3740. */
  3741. usleep_range(5000, 5500);
  3742. if (!(strcmp(w->name, "ANC EAR PA"))) {
  3743. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3744. snd_soc_update_bits(codec,
  3745. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x00);
  3746. }
  3747. break;
  3748. };
  3749. return ret;
  3750. }
  3751. static void tasha_codec_hph_mode_gain_opt(struct snd_soc_codec *codec,
  3752. u8 gain)
  3753. {
  3754. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3755. u8 hph_l_en, hph_r_en;
  3756. u8 l_val, r_val;
  3757. u8 hph_pa_status;
  3758. bool is_hphl_pa, is_hphr_pa;
  3759. hph_pa_status = snd_soc_read(codec, WCD9335_ANA_HPH);
  3760. is_hphl_pa = hph_pa_status >> 7;
  3761. is_hphr_pa = (hph_pa_status & 0x40) >> 6;
  3762. hph_l_en = snd_soc_read(codec, WCD9335_HPH_L_EN);
  3763. hph_r_en = snd_soc_read(codec, WCD9335_HPH_R_EN);
  3764. l_val = (hph_l_en & 0xC0) | 0x20 | gain;
  3765. r_val = (hph_r_en & 0xC0) | 0x20 | gain;
  3766. /*
  3767. * Set HPH_L & HPH_R gain source selection to REGISTER
  3768. * for better click and pop only if corresponding PAs are
  3769. * not enabled. Also cache the values of the HPHL/R
  3770. * PA gains to be applied after PAs are enabled
  3771. */
  3772. if ((l_val != hph_l_en) && !is_hphl_pa) {
  3773. snd_soc_write(codec, WCD9335_HPH_L_EN, l_val);
  3774. tasha->hph_l_gain = hph_l_en & 0x1F;
  3775. }
  3776. if ((r_val != hph_r_en) && !is_hphr_pa) {
  3777. snd_soc_write(codec, WCD9335_HPH_R_EN, r_val);
  3778. tasha->hph_r_gain = hph_r_en & 0x1F;
  3779. }
  3780. }
  3781. static void tasha_codec_hph_lohifi_config(struct snd_soc_codec *codec,
  3782. int event)
  3783. {
  3784. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3785. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x06);
  3786. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2,
  3787. 0xF0, 0x40);
  3788. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3789. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3790. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3791. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3792. }
  3793. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3794. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3795. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3796. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A);
  3797. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x0A);
  3798. }
  3799. }
  3800. static void tasha_codec_hph_lp_config(struct snd_soc_codec *codec,
  3801. int event)
  3802. {
  3803. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3804. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3805. tasha_codec_hph_mode_gain_opt(codec, 0x10);
  3806. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3807. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3808. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x04);
  3809. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x20);
  3810. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x07,
  3811. 0x01);
  3812. snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x70,
  3813. 0x10);
  3814. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3815. 0x0F, 0x01);
  3816. snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO,
  3817. 0xF0, 0x10);
  3818. }
  3819. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3820. snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x88);
  3821. snd_soc_write(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x33);
  3822. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x00);
  3823. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x00);
  3824. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3825. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3826. snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x80);
  3827. snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x80);
  3828. }
  3829. }
  3830. static void tasha_codec_hph_hifi_config(struct snd_soc_codec *codec,
  3831. int event)
  3832. {
  3833. if (SND_SOC_DAPM_EVENT_ON(event)) {
  3834. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03);
  3835. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08);
  3836. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C);
  3837. tasha_codec_hph_mode_gain_opt(codec, 0x11);
  3838. }
  3839. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  3840. snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00);
  3841. snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02);
  3842. }
  3843. }
  3844. static void tasha_codec_hph_mode_config(struct snd_soc_codec *codec,
  3845. int event, int mode)
  3846. {
  3847. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3848. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  3849. return;
  3850. switch (mode) {
  3851. case CLS_H_LP:
  3852. tasha_codec_hph_lp_config(codec, event);
  3853. break;
  3854. case CLS_H_LOHIFI:
  3855. tasha_codec_hph_lohifi_config(codec, event);
  3856. break;
  3857. case CLS_H_HIFI:
  3858. tasha_codec_hph_hifi_config(codec, event);
  3859. break;
  3860. }
  3861. }
  3862. static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
  3863. struct snd_kcontrol *kcontrol,
  3864. int event)
  3865. {
  3866. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3867. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3868. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3869. int hph_mode = tasha->hph_mode;
  3870. u8 dem_inp;
  3871. int ret = 0;
  3872. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3873. w->name, event, hph_mode);
  3874. switch (event) {
  3875. case SND_SOC_DAPM_PRE_PMU:
  3876. if (tasha->anc_func) {
  3877. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3878. /* 40 msec delay is needed to avoid click and pop */
  3879. msleep(40);
  3880. }
  3881. /* Read DEM INP Select */
  3882. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_SEC0) &
  3883. 0x03;
  3884. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3885. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3886. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3887. __func__, hph_mode);
  3888. return -EINVAL;
  3889. }
  3890. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3891. WCD_CLSH_EVENT_PRE_DAC,
  3892. WCD_CLSH_STATE_HPHR,
  3893. ((hph_mode == CLS_H_LOHIFI) ?
  3894. CLS_H_HIFI : hph_mode));
  3895. if (!(strcmp(w->name, "RX INT2 DAC")))
  3896. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x10, 0x10);
  3897. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3898. if (tasha->anc_func)
  3899. snd_soc_update_bits(codec,
  3900. WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x10);
  3901. break;
  3902. case SND_SOC_DAPM_POST_PMU:
  3903. /* 1000us required as per HW requirement */
  3904. usleep_range(1000, 1100);
  3905. if ((hph_mode == CLS_H_LP) &&
  3906. (TASHA_IS_1_1(wcd9xxx))) {
  3907. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3908. 0x03, 0x03);
  3909. }
  3910. break;
  3911. case SND_SOC_DAPM_PRE_PMD:
  3912. if ((hph_mode == CLS_H_LP) &&
  3913. (TASHA_IS_1_1(wcd9xxx))) {
  3914. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3915. 0x03, 0x00);
  3916. }
  3917. if (!(strcmp(w->name, "RX INT2 DAC")))
  3918. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x10, 0x00);
  3919. break;
  3920. case SND_SOC_DAPM_POST_PMD:
  3921. /* 1000us required as per HW requirement */
  3922. usleep_range(1000, 1100);
  3923. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  3924. WCD_CLSH_STATE_HPHL))
  3925. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3926. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3927. WCD_CLSH_EVENT_POST_PA,
  3928. WCD_CLSH_STATE_HPHR,
  3929. ((hph_mode == CLS_H_LOHIFI) ?
  3930. CLS_H_HIFI : hph_mode));
  3931. break;
  3932. };
  3933. return ret;
  3934. }
  3935. static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
  3936. struct snd_kcontrol *kcontrol,
  3937. int event)
  3938. {
  3939. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  3940. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  3941. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  3942. int hph_mode = tasha->hph_mode;
  3943. u8 dem_inp;
  3944. int ret = 0;
  3945. uint32_t impedl = 0, impedr = 0;
  3946. dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__,
  3947. w->name, event, hph_mode);
  3948. switch (event) {
  3949. case SND_SOC_DAPM_PRE_PMU:
  3950. if (tasha->anc_func) {
  3951. ret = tasha_codec_enable_anc(w, kcontrol, event);
  3952. /* 40 msec delay is needed to avoid click and pop */
  3953. msleep(40);
  3954. }
  3955. /* Read DEM INP Select */
  3956. dem_inp = snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_SEC0) &
  3957. 0x03;
  3958. if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) ||
  3959. (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) {
  3960. dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n",
  3961. __func__, hph_mode);
  3962. return -EINVAL;
  3963. }
  3964. wcd_clsh_fsm(codec, &tasha->clsh_d,
  3965. WCD_CLSH_EVENT_PRE_DAC,
  3966. WCD_CLSH_STATE_HPHL,
  3967. ((hph_mode == CLS_H_LOHIFI) ?
  3968. CLS_H_HIFI : hph_mode));
  3969. if (!(strcmp(w->name, "RX INT1 DAC")))
  3970. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x20, 0x20);
  3971. tasha_codec_hph_mode_config(codec, event, hph_mode);
  3972. if (tasha->anc_func)
  3973. snd_soc_update_bits(codec,
  3974. WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x10);
  3975. ret = wcd_mbhc_get_impedance(&tasha->mbhc,
  3976. &impedl, &impedr);
  3977. if (!ret) {
  3978. wcd_clsh_imped_config(codec, impedl, false);
  3979. set_bit(CLASSH_CONFIG, &tasha->status_mask);
  3980. } else {
  3981. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  3982. __func__, ret);
  3983. ret = 0;
  3984. }
  3985. break;
  3986. case SND_SOC_DAPM_POST_PMU:
  3987. /* 1000us required as per HW requirement */
  3988. usleep_range(1000, 1100);
  3989. if ((hph_mode == CLS_H_LP) &&
  3990. (TASHA_IS_1_1(wcd9xxx))) {
  3991. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  3992. 0x03, 0x03);
  3993. }
  3994. break;
  3995. case SND_SOC_DAPM_PRE_PMD:
  3996. if (!(strcmp(w->name, "RX INT1 DAC")))
  3997. snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x20, 0x00);
  3998. if ((hph_mode == CLS_H_LP) &&
  3999. (TASHA_IS_1_1(wcd9xxx))) {
  4000. snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL,
  4001. 0x03, 0x00);
  4002. }
  4003. break;
  4004. case SND_SOC_DAPM_POST_PMD:
  4005. /* 1000us required as per HW requirement */
  4006. usleep_range(1000, 1100);
  4007. if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) &
  4008. WCD_CLSH_STATE_HPHR))
  4009. tasha_codec_hph_mode_config(codec, event, hph_mode);
  4010. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4011. WCD_CLSH_EVENT_POST_PA,
  4012. WCD_CLSH_STATE_HPHL,
  4013. ((hph_mode == CLS_H_LOHIFI) ?
  4014. CLS_H_HIFI : hph_mode));
  4015. if (test_bit(CLASSH_CONFIG, &tasha->status_mask)) {
  4016. wcd_clsh_imped_config(codec, impedl, true);
  4017. clear_bit(CLASSH_CONFIG, &tasha->status_mask);
  4018. } else
  4019. dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n",
  4020. __func__, ret);
  4021. break;
  4022. };
  4023. return ret;
  4024. }
  4025. static int tasha_codec_lineout_dac_event(struct snd_soc_dapm_widget *w,
  4026. struct snd_kcontrol *kcontrol,
  4027. int event)
  4028. {
  4029. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4030. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4031. int ret = 0;
  4032. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4033. switch (event) {
  4034. case SND_SOC_DAPM_PRE_PMU:
  4035. if (tasha->anc_func &&
  4036. (!strcmp(w->name, "RX INT3 DAC") ||
  4037. !strcmp(w->name, "RX INT4 DAC")))
  4038. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4039. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4040. WCD_CLSH_EVENT_PRE_DAC,
  4041. WCD_CLSH_STATE_LO,
  4042. CLS_AB);
  4043. if (tasha->anc_func) {
  4044. if (!strcmp(w->name, "RX INT3 DAC"))
  4045. snd_soc_update_bits(codec,
  4046. WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10);
  4047. else if (!strcmp(w->name, "RX INT4 DAC"))
  4048. snd_soc_update_bits(codec,
  4049. WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10);
  4050. }
  4051. break;
  4052. case SND_SOC_DAPM_POST_PMD:
  4053. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4054. WCD_CLSH_EVENT_POST_PA,
  4055. WCD_CLSH_STATE_LO,
  4056. CLS_AB);
  4057. break;
  4058. }
  4059. return 0;
  4060. }
  4061. static const struct snd_soc_dapm_widget tasha_dapm_i2s_widgets[] = {
  4062. SND_SOC_DAPM_SUPPLY("RX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  4063. 0, 0, NULL, 0),
  4064. SND_SOC_DAPM_SUPPLY("TX_I2S_CTL", WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  4065. 0, 0, NULL, 0),
  4066. };
  4067. static int tasha_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
  4068. struct snd_kcontrol *kcontrol,
  4069. int event)
  4070. {
  4071. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4072. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4073. int ret = 0;
  4074. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4075. switch (event) {
  4076. case SND_SOC_DAPM_PRE_PMU:
  4077. if (tasha->anc_func)
  4078. ret = tasha_codec_enable_anc(w, kcontrol, event);
  4079. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4080. WCD_CLSH_EVENT_PRE_DAC,
  4081. WCD_CLSH_STATE_EAR,
  4082. CLS_H_NORMAL);
  4083. if (tasha->anc_func)
  4084. snd_soc_update_bits(codec,
  4085. WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x10);
  4086. break;
  4087. case SND_SOC_DAPM_POST_PMU:
  4088. break;
  4089. case SND_SOC_DAPM_PRE_PMD:
  4090. break;
  4091. case SND_SOC_DAPM_POST_PMD:
  4092. wcd_clsh_fsm(codec, &tasha->clsh_d,
  4093. WCD_CLSH_EVENT_POST_PA,
  4094. WCD_CLSH_STATE_EAR,
  4095. CLS_H_NORMAL);
  4096. break;
  4097. };
  4098. return ret;
  4099. }
  4100. static int tasha_codec_spk_boost_event(struct snd_soc_dapm_widget *w,
  4101. struct snd_kcontrol *kcontrol,
  4102. int event)
  4103. {
  4104. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4105. u16 boost_path_ctl, boost_path_cfg1;
  4106. u16 reg, reg_mix;
  4107. dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
  4108. if (!strcmp(w->name, "RX INT7 CHAIN")) {
  4109. boost_path_ctl = WCD9335_CDC_BOOST0_BOOST_PATH_CTL;
  4110. boost_path_cfg1 = WCD9335_CDC_RX7_RX_PATH_CFG1;
  4111. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4112. reg_mix = WCD9335_CDC_RX7_RX_PATH_MIX_CTL;
  4113. } else if (!strcmp(w->name, "RX INT8 CHAIN")) {
  4114. boost_path_ctl = WCD9335_CDC_BOOST1_BOOST_PATH_CTL;
  4115. boost_path_cfg1 = WCD9335_CDC_RX8_RX_PATH_CFG1;
  4116. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4117. reg_mix = WCD9335_CDC_RX8_RX_PATH_MIX_CTL;
  4118. } else {
  4119. dev_err(codec->dev, "%s: unknown widget: %s\n",
  4120. __func__, w->name);
  4121. return -EINVAL;
  4122. }
  4123. switch (event) {
  4124. case SND_SOC_DAPM_PRE_PMU:
  4125. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10);
  4126. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01);
  4127. snd_soc_update_bits(codec, reg, 0x10, 0x00);
  4128. if ((snd_soc_read(codec, reg_mix)) & 0x10)
  4129. snd_soc_update_bits(codec, reg_mix, 0x10, 0x00);
  4130. break;
  4131. case SND_SOC_DAPM_POST_PMD:
  4132. snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00);
  4133. snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00);
  4134. break;
  4135. };
  4136. return 0;
  4137. }
  4138. static u16 tasha_interp_get_primary_reg(u16 reg, u16 *ind)
  4139. {
  4140. u16 prim_int_reg = 0;
  4141. switch (reg) {
  4142. case WCD9335_CDC_RX0_RX_PATH_CTL:
  4143. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4144. prim_int_reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4145. *ind = 0;
  4146. break;
  4147. case WCD9335_CDC_RX1_RX_PATH_CTL:
  4148. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4149. prim_int_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4150. *ind = 1;
  4151. break;
  4152. case WCD9335_CDC_RX2_RX_PATH_CTL:
  4153. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4154. prim_int_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4155. *ind = 2;
  4156. break;
  4157. case WCD9335_CDC_RX3_RX_PATH_CTL:
  4158. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4159. prim_int_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4160. *ind = 3;
  4161. break;
  4162. case WCD9335_CDC_RX4_RX_PATH_CTL:
  4163. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4164. prim_int_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4165. *ind = 4;
  4166. break;
  4167. case WCD9335_CDC_RX5_RX_PATH_CTL:
  4168. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4169. prim_int_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4170. *ind = 5;
  4171. break;
  4172. case WCD9335_CDC_RX6_RX_PATH_CTL:
  4173. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4174. prim_int_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4175. *ind = 6;
  4176. break;
  4177. case WCD9335_CDC_RX7_RX_PATH_CTL:
  4178. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4179. prim_int_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4180. *ind = 7;
  4181. break;
  4182. case WCD9335_CDC_RX8_RX_PATH_CTL:
  4183. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4184. prim_int_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4185. *ind = 8;
  4186. break;
  4187. };
  4188. return prim_int_reg;
  4189. }
  4190. static void tasha_codec_hd2_control(struct snd_soc_codec *codec,
  4191. u16 prim_int_reg, int event)
  4192. {
  4193. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4194. u16 hd2_scale_reg;
  4195. u16 hd2_enable_reg = 0;
  4196. if (!TASHA_IS_2_0(tasha->wcd9xxx))
  4197. return;
  4198. if (prim_int_reg == WCD9335_CDC_RX1_RX_PATH_CTL) {
  4199. hd2_scale_reg = WCD9335_CDC_RX1_RX_PATH_SEC3;
  4200. hd2_enable_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4201. }
  4202. if (prim_int_reg == WCD9335_CDC_RX2_RX_PATH_CTL) {
  4203. hd2_scale_reg = WCD9335_CDC_RX2_RX_PATH_SEC3;
  4204. hd2_enable_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4205. }
  4206. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) {
  4207. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x10);
  4208. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x01);
  4209. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04);
  4210. }
  4211. if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
  4212. snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00);
  4213. snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x00);
  4214. snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00);
  4215. }
  4216. }
  4217. static int tasha_codec_enable_prim_interpolator(
  4218. struct snd_soc_codec *codec,
  4219. u16 reg, int event)
  4220. {
  4221. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4222. u16 prim_int_reg;
  4223. u16 ind = 0;
  4224. prim_int_reg = tasha_interp_get_primary_reg(reg, &ind);
  4225. switch (event) {
  4226. case SND_SOC_DAPM_PRE_PMU:
  4227. tasha->prim_int_users[ind]++;
  4228. if (tasha->prim_int_users[ind] == 1) {
  4229. snd_soc_update_bits(codec, prim_int_reg,
  4230. 0x10, 0x10);
  4231. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4232. snd_soc_update_bits(codec, prim_int_reg,
  4233. 1 << 0x5, 1 << 0x5);
  4234. }
  4235. if ((reg != prim_int_reg) &&
  4236. ((snd_soc_read(codec, prim_int_reg)) & 0x10))
  4237. snd_soc_update_bits(codec, reg, 0x10, 0x10);
  4238. break;
  4239. case SND_SOC_DAPM_POST_PMD:
  4240. tasha->prim_int_users[ind]--;
  4241. if (tasha->prim_int_users[ind] == 0) {
  4242. snd_soc_update_bits(codec, prim_int_reg,
  4243. 1 << 0x5, 0 << 0x5);
  4244. snd_soc_update_bits(codec, prim_int_reg,
  4245. 0x40, 0x40);
  4246. snd_soc_update_bits(codec, prim_int_reg,
  4247. 0x40, 0x00);
  4248. tasha_codec_hd2_control(codec, prim_int_reg, event);
  4249. }
  4250. break;
  4251. };
  4252. dev_dbg(codec->dev, "%s: primary interpolator: INT%d, users: %d\n",
  4253. __func__, ind, tasha->prim_int_users[ind]);
  4254. return 0;
  4255. }
  4256. static int tasha_codec_enable_spline_src(struct snd_soc_codec *codec,
  4257. int src_num,
  4258. int event)
  4259. {
  4260. u16 src_paired_reg = 0;
  4261. struct tasha_priv *tasha;
  4262. u16 rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4263. u16 rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4264. int *src_users, count, spl_src = SPLINE_SRC0;
  4265. u16 src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4266. tasha = snd_soc_codec_get_drvdata(codec);
  4267. switch (src_num) {
  4268. case SRC_IN_HPHL:
  4269. rx_path_cfg_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  4270. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4271. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4272. rx_path_ctl_reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4273. spl_src = SPLINE_SRC0;
  4274. break;
  4275. case SRC_IN_LO1:
  4276. rx_path_cfg_reg = WCD9335_CDC_RX3_RX_PATH_CFG0;
  4277. src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4278. src_paired_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4279. rx_path_ctl_reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4280. spl_src = SPLINE_SRC0;
  4281. break;
  4282. case SRC_IN_HPHR:
  4283. rx_path_cfg_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  4284. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4285. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4286. rx_path_ctl_reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4287. spl_src = SPLINE_SRC1;
  4288. break;
  4289. case SRC_IN_LO2:
  4290. rx_path_cfg_reg = WCD9335_CDC_RX4_RX_PATH_CFG0;
  4291. src_clk_reg = WCD9335_SPLINE_SRC1_CLK_RST_CTL_0;
  4292. src_paired_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0;
  4293. rx_path_ctl_reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4294. spl_src = SPLINE_SRC1;
  4295. break;
  4296. case SRC_IN_SPKRL:
  4297. rx_path_cfg_reg = WCD9335_CDC_RX7_RX_PATH_CFG0;
  4298. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4299. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4300. rx_path_ctl_reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4301. spl_src = SPLINE_SRC2;
  4302. break;
  4303. case SRC_IN_LO3:
  4304. rx_path_cfg_reg = WCD9335_CDC_RX5_RX_PATH_CFG0;
  4305. src_clk_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4306. src_paired_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4307. rx_path_ctl_reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4308. spl_src = SPLINE_SRC2;
  4309. break;
  4310. case SRC_IN_SPKRR:
  4311. rx_path_cfg_reg = WCD9335_CDC_RX8_RX_PATH_CFG0;
  4312. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4313. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4314. rx_path_ctl_reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4315. spl_src = SPLINE_SRC3;
  4316. break;
  4317. case SRC_IN_LO4:
  4318. rx_path_cfg_reg = WCD9335_CDC_RX6_RX_PATH_CFG0;
  4319. src_clk_reg = WCD9335_SPLINE_SRC3_CLK_RST_CTL_0;
  4320. src_paired_reg = WCD9335_SPLINE_SRC2_CLK_RST_CTL_0;
  4321. rx_path_ctl_reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4322. spl_src = SPLINE_SRC3;
  4323. break;
  4324. };
  4325. src_users = &tasha->spl_src_users[spl_src];
  4326. switch (event) {
  4327. case SND_SOC_DAPM_PRE_PMU:
  4328. count = *src_users;
  4329. count++;
  4330. if (count == 1) {
  4331. if ((snd_soc_read(codec, src_clk_reg) & 0x02) ||
  4332. (snd_soc_read(codec, src_paired_reg) & 0x02)) {
  4333. snd_soc_update_bits(codec, src_clk_reg, 0x02,
  4334. 0x00);
  4335. snd_soc_update_bits(codec, src_paired_reg,
  4336. 0x02, 0x00);
  4337. }
  4338. snd_soc_update_bits(codec, src_clk_reg, 0x01, 0x01);
  4339. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4340. 0x80);
  4341. }
  4342. *src_users = count;
  4343. break;
  4344. case SND_SOC_DAPM_POST_PMD:
  4345. count = *src_users;
  4346. count--;
  4347. if (count == 0) {
  4348. snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80,
  4349. 0x00);
  4350. snd_soc_update_bits(codec, src_clk_reg, 0x03, 0x02);
  4351. /* default sample rate */
  4352. snd_soc_update_bits(codec, rx_path_ctl_reg, 0x0f,
  4353. 0x04);
  4354. }
  4355. *src_users = count;
  4356. break;
  4357. };
  4358. dev_dbg(codec->dev, "%s: Spline SRC%d, users: %d\n",
  4359. __func__, spl_src, *src_users);
  4360. return 0;
  4361. }
  4362. static int tasha_codec_enable_spline_resampler(struct snd_soc_dapm_widget *w,
  4363. struct snd_kcontrol *kcontrol,
  4364. int event)
  4365. {
  4366. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4367. int ret = 0;
  4368. u8 src_in;
  4369. src_in = snd_soc_read(codec, WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0);
  4370. if (!(src_in & 0xFF)) {
  4371. dev_err(codec->dev, "%s: Spline SRC%u input not selected\n",
  4372. __func__, w->shift);
  4373. return -EINVAL;
  4374. }
  4375. switch (w->shift) {
  4376. case SPLINE_SRC0:
  4377. ret = tasha_codec_enable_spline_src(codec,
  4378. ((src_in & 0x03) == 1) ? SRC_IN_HPHL : SRC_IN_LO1,
  4379. event);
  4380. break;
  4381. case SPLINE_SRC1:
  4382. ret = tasha_codec_enable_spline_src(codec,
  4383. ((src_in & 0x0C) == 4) ? SRC_IN_HPHR : SRC_IN_LO2,
  4384. event);
  4385. break;
  4386. case SPLINE_SRC2:
  4387. ret = tasha_codec_enable_spline_src(codec,
  4388. ((src_in & 0x30) == 0x10) ? SRC_IN_LO3 : SRC_IN_SPKRL,
  4389. event);
  4390. break;
  4391. case SPLINE_SRC3:
  4392. ret = tasha_codec_enable_spline_src(codec,
  4393. ((src_in & 0xC0) == 0x40) ? SRC_IN_LO4 : SRC_IN_SPKRR,
  4394. event);
  4395. break;
  4396. default:
  4397. dev_err(codec->dev, "%s: Invalid spline src:%u\n", __func__,
  4398. w->shift);
  4399. ret = -EINVAL;
  4400. };
  4401. return ret;
  4402. }
  4403. static int tasha_codec_enable_swr(struct snd_soc_dapm_widget *w,
  4404. struct snd_kcontrol *kcontrol, int event)
  4405. {
  4406. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4407. struct tasha_priv *tasha;
  4408. int i, ch_cnt;
  4409. tasha = snd_soc_codec_get_drvdata(codec);
  4410. if (!tasha->nr)
  4411. return 0;
  4412. switch (event) {
  4413. case SND_SOC_DAPM_PRE_PMU:
  4414. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4415. !tasha->rx_7_count)
  4416. tasha->rx_7_count++;
  4417. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4418. !tasha->rx_8_count)
  4419. tasha->rx_8_count++;
  4420. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4421. for (i = 0; i < tasha->nr; i++) {
  4422. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4423. SWR_DEVICE_UP, NULL);
  4424. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4425. SWR_SET_NUM_RX_CH, &ch_cnt);
  4426. }
  4427. break;
  4428. case SND_SOC_DAPM_POST_PMD:
  4429. if ((strnstr(w->name, "INT7_", sizeof("RX INT7_"))) &&
  4430. tasha->rx_7_count)
  4431. tasha->rx_7_count--;
  4432. if ((strnstr(w->name, "INT8_", sizeof("RX INT8_"))) &&
  4433. tasha->rx_8_count)
  4434. tasha->rx_8_count--;
  4435. ch_cnt = tasha->rx_7_count + tasha->rx_8_count;
  4436. for (i = 0; i < tasha->nr; i++)
  4437. swrm_wcd_notify(tasha->swr_ctrl_data[i].swr_pdev,
  4438. SWR_SET_NUM_RX_CH, &ch_cnt);
  4439. break;
  4440. }
  4441. dev_dbg(tasha->dev, "%s: current swr ch cnt: %d\n",
  4442. __func__, tasha->rx_7_count + tasha->rx_8_count);
  4443. return 0;
  4444. }
  4445. static int tasha_codec_config_ear_spkr_gain(struct snd_soc_codec *codec,
  4446. int event, int gain_reg)
  4447. {
  4448. int comp_gain_offset, val;
  4449. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4450. switch (tasha->spkr_mode) {
  4451. /* Compander gain in SPKR_MODE1 case is 12 dB */
  4452. case SPKR_MODE_1:
  4453. comp_gain_offset = -12;
  4454. break;
  4455. /* Default case compander gain is 15 dB */
  4456. default:
  4457. comp_gain_offset = -15;
  4458. break;
  4459. }
  4460. switch (event) {
  4461. case SND_SOC_DAPM_POST_PMU:
  4462. /* Apply ear spkr gain only if compander is enabled */
  4463. if (tasha->comp_enabled[COMPANDER_7] &&
  4464. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4465. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4466. (tasha->ear_spkr_gain != 0)) {
  4467. /* For example, val is -8(-12+5-1) for 4dB of gain */
  4468. val = comp_gain_offset + tasha->ear_spkr_gain - 1;
  4469. snd_soc_write(codec, gain_reg, val);
  4470. dev_dbg(codec->dev, "%s: RX7 Volume %d dB\n",
  4471. __func__, val);
  4472. }
  4473. break;
  4474. case SND_SOC_DAPM_POST_PMD:
  4475. /*
  4476. * Reset RX7 volume to 0 dB if compander is enabled and
  4477. * ear_spkr_gain is non-zero.
  4478. */
  4479. if (tasha->comp_enabled[COMPANDER_7] &&
  4480. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4481. gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) &&
  4482. (tasha->ear_spkr_gain != 0)) {
  4483. snd_soc_write(codec, gain_reg, 0x0);
  4484. dev_dbg(codec->dev, "%s: Reset RX7 Volume to 0 dB\n",
  4485. __func__);
  4486. }
  4487. break;
  4488. }
  4489. return 0;
  4490. }
  4491. static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w,
  4492. struct snd_kcontrol *kcontrol, int event)
  4493. {
  4494. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4495. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4496. u16 gain_reg;
  4497. int offset_val = 0;
  4498. int val = 0;
  4499. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4500. switch (w->reg) {
  4501. case WCD9335_CDC_RX0_RX_PATH_MIX_CTL:
  4502. gain_reg = WCD9335_CDC_RX0_RX_VOL_MIX_CTL;
  4503. break;
  4504. case WCD9335_CDC_RX1_RX_PATH_MIX_CTL:
  4505. gain_reg = WCD9335_CDC_RX1_RX_VOL_MIX_CTL;
  4506. break;
  4507. case WCD9335_CDC_RX2_RX_PATH_MIX_CTL:
  4508. gain_reg = WCD9335_CDC_RX2_RX_VOL_MIX_CTL;
  4509. break;
  4510. case WCD9335_CDC_RX3_RX_PATH_MIX_CTL:
  4511. gain_reg = WCD9335_CDC_RX3_RX_VOL_MIX_CTL;
  4512. break;
  4513. case WCD9335_CDC_RX4_RX_PATH_MIX_CTL:
  4514. gain_reg = WCD9335_CDC_RX4_RX_VOL_MIX_CTL;
  4515. break;
  4516. case WCD9335_CDC_RX5_RX_PATH_MIX_CTL:
  4517. gain_reg = WCD9335_CDC_RX5_RX_VOL_MIX_CTL;
  4518. break;
  4519. case WCD9335_CDC_RX6_RX_PATH_MIX_CTL:
  4520. gain_reg = WCD9335_CDC_RX6_RX_VOL_MIX_CTL;
  4521. break;
  4522. case WCD9335_CDC_RX7_RX_PATH_MIX_CTL:
  4523. gain_reg = WCD9335_CDC_RX7_RX_VOL_MIX_CTL;
  4524. break;
  4525. case WCD9335_CDC_RX8_RX_PATH_MIX_CTL:
  4526. gain_reg = WCD9335_CDC_RX8_RX_VOL_MIX_CTL;
  4527. break;
  4528. default:
  4529. dev_err(codec->dev, "%s: No gain register avail for %s\n",
  4530. __func__, w->name);
  4531. return 0;
  4532. };
  4533. switch (event) {
  4534. case SND_SOC_DAPM_POST_PMU:
  4535. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4536. (tasha->comp_enabled[COMPANDER_7] ||
  4537. tasha->comp_enabled[COMPANDER_8]) &&
  4538. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4539. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4540. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4541. 0x01, 0x01);
  4542. snd_soc_update_bits(codec,
  4543. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4544. 0x01, 0x01);
  4545. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4546. 0x01, 0x01);
  4547. snd_soc_update_bits(codec,
  4548. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4549. 0x01, 0x01);
  4550. offset_val = -2;
  4551. }
  4552. val = snd_soc_read(codec, gain_reg);
  4553. val += offset_val;
  4554. snd_soc_write(codec, gain_reg, val);
  4555. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4556. break;
  4557. case SND_SOC_DAPM_POST_PMD:
  4558. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4559. (tasha->comp_enabled[COMPANDER_7] ||
  4560. tasha->comp_enabled[COMPANDER_8]) &&
  4561. (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL ||
  4562. gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) {
  4563. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4564. 0x01, 0x00);
  4565. snd_soc_update_bits(codec,
  4566. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4567. 0x01, 0x00);
  4568. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4569. 0x01, 0x00);
  4570. snd_soc_update_bits(codec,
  4571. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4572. 0x01, 0x00);
  4573. offset_val = 2;
  4574. val = snd_soc_read(codec, gain_reg);
  4575. val += offset_val;
  4576. snd_soc_write(codec, gain_reg, val);
  4577. }
  4578. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4579. break;
  4580. };
  4581. return 0;
  4582. }
  4583. static int __tasha_cdc_native_clk_enable(struct tasha_priv *tasha,
  4584. bool enable)
  4585. {
  4586. int ret = 0;
  4587. struct snd_soc_codec *codec = tasha->codec;
  4588. if (!tasha->wcd_native_clk) {
  4589. dev_err(tasha->dev, "%s: wcd native clock is NULL\n", __func__);
  4590. return -EINVAL;
  4591. }
  4592. dev_dbg(tasha->dev, "%s: native_clk_enable = %u\n", __func__, enable);
  4593. if (enable) {
  4594. ret = clk_prepare_enable(tasha->wcd_native_clk);
  4595. if (ret) {
  4596. dev_err(tasha->dev, "%s: native clk enable failed\n",
  4597. __func__);
  4598. goto err;
  4599. }
  4600. if (++tasha->native_clk_users == 1) {
  4601. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4602. 0x10, 0x10);
  4603. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4604. 0x80, 0x80);
  4605. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4606. 0x04, 0x00);
  4607. snd_soc_update_bits(codec,
  4608. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4609. 0x02, 0x02);
  4610. }
  4611. } else {
  4612. if (tasha->native_clk_users &&
  4613. (--tasha->native_clk_users == 0)) {
  4614. snd_soc_update_bits(codec,
  4615. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  4616. 0x02, 0x00);
  4617. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE,
  4618. 0x04, 0x04);
  4619. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4620. 0x80, 0x00);
  4621. snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL,
  4622. 0x10, 0x00);
  4623. }
  4624. clk_disable_unprepare(tasha->wcd_native_clk);
  4625. }
  4626. dev_dbg(codec->dev, "%s: native_clk_users: %d\n", __func__,
  4627. tasha->native_clk_users);
  4628. err:
  4629. return ret;
  4630. }
  4631. static int tasha_codec_get_native_fifo_sync_mask(struct snd_soc_codec *codec,
  4632. int interp_n)
  4633. {
  4634. int mask = 0;
  4635. u16 reg;
  4636. u8 val1, val2, inp0 = 0;
  4637. u8 inp1 = 0, inp2 = 0;
  4638. reg = WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0 + (2 * interp_n) - 2;
  4639. val1 = snd_soc_read(codec, reg);
  4640. val2 = snd_soc_read(codec, reg + 1);
  4641. inp0 = val1 & 0x0F;
  4642. inp1 = (val1 >> 4) & 0x0F;
  4643. inp2 = (val2 >> 4) & 0x0F;
  4644. if (IS_VALID_NATIVE_FIFO_PORT(inp0))
  4645. mask |= (1 << (inp0 - 5));
  4646. if (IS_VALID_NATIVE_FIFO_PORT(inp1))
  4647. mask |= (1 << (inp1 - 5));
  4648. if (IS_VALID_NATIVE_FIFO_PORT(inp2))
  4649. mask |= (1 << (inp2 - 5));
  4650. dev_dbg(codec->dev, "%s: native fifo mask: 0x%x\n", __func__, mask);
  4651. if (!mask)
  4652. dev_err(codec->dev, "native fifo err,int:%d,inp0:%d,inp1:%d,inp2:%d\n",
  4653. interp_n, inp0, inp1, inp2);
  4654. return mask;
  4655. }
  4656. static int tasha_enable_native_supply(struct snd_soc_dapm_widget *w,
  4657. struct snd_kcontrol *kcontrol, int event)
  4658. {
  4659. int mask;
  4660. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4661. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4662. u16 interp_reg;
  4663. dev_dbg(codec->dev, "%s: event: %d, shift:%d\n", __func__, event,
  4664. w->shift);
  4665. if (w->shift < INTERP_HPHL || w->shift > INTERP_LO2)
  4666. return -EINVAL;
  4667. interp_reg = WCD9335_CDC_RX1_RX_PATH_CTL + 20 * (w->shift - 1);
  4668. mask = tasha_codec_get_native_fifo_sync_mask(codec, w->shift);
  4669. if (!mask)
  4670. return -EINVAL;
  4671. switch (event) {
  4672. case SND_SOC_DAPM_PRE_PMU:
  4673. /* Adjust interpolator rate to 44P1_NATIVE */
  4674. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x09);
  4675. __tasha_cdc_native_clk_enable(tasha, true);
  4676. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4677. mask, mask);
  4678. break;
  4679. case SND_SOC_DAPM_PRE_PMD:
  4680. snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC,
  4681. mask, 0x0);
  4682. __tasha_cdc_native_clk_enable(tasha, false);
  4683. /* Adjust interpolator rate to default */
  4684. snd_soc_update_bits(codec, interp_reg, 0x0F, 0x04);
  4685. break;
  4686. }
  4687. return 0;
  4688. }
  4689. static int tasha_codec_enable_interpolator(struct snd_soc_dapm_widget *w,
  4690. struct snd_kcontrol *kcontrol, int event)
  4691. {
  4692. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4693. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4694. u16 gain_reg;
  4695. u16 reg;
  4696. int val;
  4697. int offset_val = 0;
  4698. dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name);
  4699. if (!(strcmp(w->name, "RX INT0 INTERP"))) {
  4700. reg = WCD9335_CDC_RX0_RX_PATH_CTL;
  4701. gain_reg = WCD9335_CDC_RX0_RX_VOL_CTL;
  4702. } else if (!(strcmp(w->name, "RX INT1 INTERP"))) {
  4703. reg = WCD9335_CDC_RX1_RX_PATH_CTL;
  4704. gain_reg = WCD9335_CDC_RX1_RX_VOL_CTL;
  4705. } else if (!(strcmp(w->name, "RX INT2 INTERP"))) {
  4706. reg = WCD9335_CDC_RX2_RX_PATH_CTL;
  4707. gain_reg = WCD9335_CDC_RX2_RX_VOL_CTL;
  4708. } else if (!(strcmp(w->name, "RX INT3 INTERP"))) {
  4709. reg = WCD9335_CDC_RX3_RX_PATH_CTL;
  4710. gain_reg = WCD9335_CDC_RX3_RX_VOL_CTL;
  4711. } else if (!(strcmp(w->name, "RX INT4 INTERP"))) {
  4712. reg = WCD9335_CDC_RX4_RX_PATH_CTL;
  4713. gain_reg = WCD9335_CDC_RX4_RX_VOL_CTL;
  4714. } else if (!(strcmp(w->name, "RX INT5 INTERP"))) {
  4715. reg = WCD9335_CDC_RX5_RX_PATH_CTL;
  4716. gain_reg = WCD9335_CDC_RX5_RX_VOL_CTL;
  4717. } else if (!(strcmp(w->name, "RX INT6 INTERP"))) {
  4718. reg = WCD9335_CDC_RX6_RX_PATH_CTL;
  4719. gain_reg = WCD9335_CDC_RX6_RX_VOL_CTL;
  4720. } else if (!(strcmp(w->name, "RX INT7 INTERP"))) {
  4721. reg = WCD9335_CDC_RX7_RX_PATH_CTL;
  4722. gain_reg = WCD9335_CDC_RX7_RX_VOL_CTL;
  4723. } else if (!(strcmp(w->name, "RX INT8 INTERP"))) {
  4724. reg = WCD9335_CDC_RX8_RX_PATH_CTL;
  4725. gain_reg = WCD9335_CDC_RX8_RX_VOL_CTL;
  4726. } else {
  4727. dev_err(codec->dev, "%s: Interpolator reg not found\n",
  4728. __func__);
  4729. return -EINVAL;
  4730. }
  4731. switch (event) {
  4732. case SND_SOC_DAPM_PRE_PMU:
  4733. tasha_codec_vote_max_bw(codec, true);
  4734. /* Reset if needed */
  4735. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4736. break;
  4737. case SND_SOC_DAPM_POST_PMU:
  4738. tasha_config_compander(codec, w->shift, event);
  4739. /* apply gain after int clk is enabled */
  4740. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4741. (tasha->comp_enabled[COMPANDER_7] ||
  4742. tasha->comp_enabled[COMPANDER_8]) &&
  4743. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4744. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4745. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4746. 0x01, 0x01);
  4747. snd_soc_update_bits(codec,
  4748. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4749. 0x01, 0x01);
  4750. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4751. 0x01, 0x01);
  4752. snd_soc_update_bits(codec,
  4753. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4754. 0x01, 0x01);
  4755. offset_val = -2;
  4756. }
  4757. val = snd_soc_read(codec, gain_reg);
  4758. val += offset_val;
  4759. snd_soc_write(codec, gain_reg, val);
  4760. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4761. break;
  4762. case SND_SOC_DAPM_POST_PMD:
  4763. tasha_config_compander(codec, w->shift, event);
  4764. tasha_codec_enable_prim_interpolator(codec, reg, event);
  4765. if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
  4766. (tasha->comp_enabled[COMPANDER_7] ||
  4767. tasha->comp_enabled[COMPANDER_8]) &&
  4768. (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL ||
  4769. gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) {
  4770. snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1,
  4771. 0x01, 0x00);
  4772. snd_soc_update_bits(codec,
  4773. WCD9335_CDC_RX7_RX_PATH_MIX_SEC0,
  4774. 0x01, 0x00);
  4775. snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1,
  4776. 0x01, 0x00);
  4777. snd_soc_update_bits(codec,
  4778. WCD9335_CDC_RX8_RX_PATH_MIX_SEC0,
  4779. 0x01, 0x00);
  4780. offset_val = 2;
  4781. val = snd_soc_read(codec, gain_reg);
  4782. val += offset_val;
  4783. snd_soc_write(codec, gain_reg, val);
  4784. }
  4785. tasha_codec_config_ear_spkr_gain(codec, event, gain_reg);
  4786. break;
  4787. };
  4788. return 0;
  4789. }
  4790. static int tasha_codec_set_iir_gain(struct snd_soc_dapm_widget *w,
  4791. struct snd_kcontrol *kcontrol, int event)
  4792. {
  4793. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4794. dev_dbg(codec->dev, "%s: event = %d\n", __func__, event);
  4795. switch (event) {
  4796. case SND_SOC_DAPM_POST_PMU: /* fall through */
  4797. case SND_SOC_DAPM_PRE_PMD:
  4798. if (strnstr(w->name, "IIR0", sizeof("IIR0"))) {
  4799. snd_soc_write(codec,
  4800. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL,
  4801. snd_soc_read(codec,
  4802. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL));
  4803. snd_soc_write(codec,
  4804. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL,
  4805. snd_soc_read(codec,
  4806. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL));
  4807. snd_soc_write(codec,
  4808. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL,
  4809. snd_soc_read(codec,
  4810. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL));
  4811. snd_soc_write(codec,
  4812. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL,
  4813. snd_soc_read(codec,
  4814. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL));
  4815. } else {
  4816. snd_soc_write(codec,
  4817. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL,
  4818. snd_soc_read(codec,
  4819. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL));
  4820. snd_soc_write(codec,
  4821. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL,
  4822. snd_soc_read(codec,
  4823. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL));
  4824. snd_soc_write(codec,
  4825. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL,
  4826. snd_soc_read(codec,
  4827. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL));
  4828. }
  4829. break;
  4830. }
  4831. return 0;
  4832. }
  4833. static int tasha_codec_enable_on_demand_supply(
  4834. struct snd_soc_dapm_widget *w,
  4835. struct snd_kcontrol *kcontrol, int event)
  4836. {
  4837. int ret = 0;
  4838. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4839. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4840. struct on_demand_supply *supply;
  4841. if (w->shift >= ON_DEMAND_SUPPLIES_MAX) {
  4842. dev_err(codec->dev, "%s: error index > MAX Demand supplies",
  4843. __func__);
  4844. ret = -EINVAL;
  4845. goto out;
  4846. }
  4847. dev_dbg(codec->dev, "%s: supply: %s event: %d\n",
  4848. __func__, on_demand_supply_name[w->shift], event);
  4849. supply = &tasha->on_demand_list[w->shift];
  4850. WARN_ONCE(!supply->supply, "%s isn't defined\n",
  4851. on_demand_supply_name[w->shift]);
  4852. if (!supply->supply) {
  4853. dev_err(codec->dev, "%s: err supply not present ond for %d",
  4854. __func__, w->shift);
  4855. goto out;
  4856. }
  4857. switch (event) {
  4858. case SND_SOC_DAPM_PRE_PMU:
  4859. ret = regulator_enable(supply->supply);
  4860. if (ret)
  4861. dev_err(codec->dev, "%s: Failed to enable %s\n",
  4862. __func__,
  4863. on_demand_supply_name[w->shift]);
  4864. break;
  4865. case SND_SOC_DAPM_POST_PMD:
  4866. ret = regulator_disable(supply->supply);
  4867. if (ret)
  4868. dev_err(codec->dev, "%s: Failed to disable %s\n",
  4869. __func__,
  4870. on_demand_supply_name[w->shift]);
  4871. break;
  4872. default:
  4873. break;
  4874. };
  4875. out:
  4876. return ret;
  4877. }
  4878. static int tasha_codec_find_amic_input(struct snd_soc_codec *codec,
  4879. int adc_mux_n)
  4880. {
  4881. u16 mask, shift, adc_mux_in_reg;
  4882. u16 amic_mux_sel_reg;
  4883. bool is_amic;
  4884. if (adc_mux_n < 0 || adc_mux_n > WCD9335_MAX_VALID_ADC_MUX ||
  4885. adc_mux_n == WCD9335_INVALID_ADC_MUX)
  4886. return 0;
  4887. /* Check whether adc mux input is AMIC or DMIC */
  4888. if (adc_mux_n < 4) {
  4889. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
  4890. 2 * adc_mux_n;
  4891. amic_mux_sel_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  4892. 2 * adc_mux_n;
  4893. mask = 0x03;
  4894. shift = 0;
  4895. } else {
  4896. adc_mux_in_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  4897. adc_mux_n - 4;
  4898. amic_mux_sel_reg = adc_mux_in_reg;
  4899. mask = 0xC0;
  4900. shift = 6;
  4901. }
  4902. is_amic = (((snd_soc_read(codec, adc_mux_in_reg) & mask) >> shift)
  4903. == 1);
  4904. if (!is_amic)
  4905. return 0;
  4906. return snd_soc_read(codec, amic_mux_sel_reg) & 0x07;
  4907. }
  4908. static void tasha_codec_set_tx_hold(struct snd_soc_codec *codec,
  4909. u16 amic_reg, bool set)
  4910. {
  4911. u8 mask = 0x20;
  4912. u8 val;
  4913. if (amic_reg == WCD9335_ANA_AMIC1 ||
  4914. amic_reg == WCD9335_ANA_AMIC3 ||
  4915. amic_reg == WCD9335_ANA_AMIC5)
  4916. mask = 0x40;
  4917. val = set ? mask : 0x00;
  4918. switch (amic_reg) {
  4919. case WCD9335_ANA_AMIC1:
  4920. case WCD9335_ANA_AMIC2:
  4921. snd_soc_update_bits(codec, WCD9335_ANA_AMIC2, mask, val);
  4922. break;
  4923. case WCD9335_ANA_AMIC3:
  4924. case WCD9335_ANA_AMIC4:
  4925. snd_soc_update_bits(codec, WCD9335_ANA_AMIC4, mask, val);
  4926. break;
  4927. case WCD9335_ANA_AMIC5:
  4928. case WCD9335_ANA_AMIC6:
  4929. snd_soc_update_bits(codec, WCD9335_ANA_AMIC6, mask, val);
  4930. break;
  4931. default:
  4932. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4933. __func__, amic_reg);
  4934. break;
  4935. }
  4936. }
  4937. static int tasha_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w,
  4938. struct snd_kcontrol *kcontrol, int event)
  4939. {
  4940. int adc_mux_n = w->shift;
  4941. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  4942. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  4943. int amic_n;
  4944. dev_dbg(codec->dev, "%s: event: %d\n", __func__, event);
  4945. switch (event) {
  4946. case SND_SOC_DAPM_POST_PMU:
  4947. amic_n = tasha_codec_find_amic_input(codec, adc_mux_n);
  4948. if (amic_n) {
  4949. /*
  4950. * Prevent ANC Rx pop by leaving Tx FE in HOLD
  4951. * state until PA is up. Track AMIC being used
  4952. * so we can release the HOLD later.
  4953. */
  4954. set_bit(ANC_MIC_AMIC1 + amic_n - 1,
  4955. &tasha->status_mask);
  4956. }
  4957. break;
  4958. default:
  4959. break;
  4960. }
  4961. return 0;
  4962. }
  4963. static u16 tasha_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic)
  4964. {
  4965. u16 pwr_level_reg = 0;
  4966. switch (amic) {
  4967. case 1:
  4968. case 2:
  4969. pwr_level_reg = WCD9335_ANA_AMIC1;
  4970. break;
  4971. case 3:
  4972. case 4:
  4973. pwr_level_reg = WCD9335_ANA_AMIC3;
  4974. break;
  4975. case 5:
  4976. case 6:
  4977. pwr_level_reg = WCD9335_ANA_AMIC5;
  4978. break;
  4979. default:
  4980. dev_dbg(codec->dev, "%s: invalid amic: %d\n",
  4981. __func__, amic);
  4982. break;
  4983. }
  4984. return pwr_level_reg;
  4985. }
  4986. #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
  4987. #define CF_MIN_3DB_4HZ 0x0
  4988. #define CF_MIN_3DB_75HZ 0x1
  4989. #define CF_MIN_3DB_150HZ 0x2
  4990. static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work)
  4991. {
  4992. struct delayed_work *hpf_delayed_work;
  4993. struct hpf_work *hpf_work;
  4994. struct tasha_priv *tasha;
  4995. struct snd_soc_codec *codec;
  4996. u16 dec_cfg_reg, amic_reg;
  4997. u8 hpf_cut_off_freq;
  4998. int amic_n;
  4999. hpf_delayed_work = to_delayed_work(work);
  5000. hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
  5001. tasha = hpf_work->tasha;
  5002. codec = tasha->codec;
  5003. hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
  5004. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator;
  5005. dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
  5006. __func__, hpf_work->decimator, hpf_cut_off_freq);
  5007. amic_n = tasha_codec_find_amic_input(codec, hpf_work->decimator);
  5008. if (amic_n) {
  5009. amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1;
  5010. tasha_codec_set_tx_hold(codec, amic_reg, false);
  5011. }
  5012. tasha_codec_vote_max_bw(codec, true);
  5013. snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  5014. hpf_cut_off_freq << 5);
  5015. tasha_codec_vote_max_bw(codec, false);
  5016. }
  5017. static void tasha_tx_mute_update_callback(struct work_struct *work)
  5018. {
  5019. struct tx_mute_work *tx_mute_dwork;
  5020. struct tasha_priv *tasha;
  5021. struct delayed_work *delayed_work;
  5022. struct snd_soc_codec *codec;
  5023. u16 tx_vol_ctl_reg, hpf_gate_reg;
  5024. delayed_work = to_delayed_work(work);
  5025. tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
  5026. tasha = tx_mute_dwork->tasha;
  5027. codec = tasha->codec;
  5028. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  5029. 16 * tx_mute_dwork->decimator;
  5030. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 +
  5031. 16 * tx_mute_dwork->decimator;
  5032. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x01);
  5033. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5034. }
  5035. static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w,
  5036. struct snd_kcontrol *kcontrol, int event)
  5037. {
  5038. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5039. unsigned int decimator;
  5040. char *dec_adc_mux_name = NULL;
  5041. char *widget_name = NULL;
  5042. char *wname;
  5043. int ret = 0, amic_n;
  5044. u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg;
  5045. u16 tx_gain_ctl_reg;
  5046. char *dec;
  5047. u8 hpf_cut_off_freq;
  5048. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5049. dev_dbg(codec->dev, "%s %d\n", __func__, event);
  5050. widget_name = kstrndup(w->name, 15, GFP_KERNEL);
  5051. if (!widget_name)
  5052. return -ENOMEM;
  5053. wname = widget_name;
  5054. dec_adc_mux_name = strsep(&widget_name, " ");
  5055. if (!dec_adc_mux_name) {
  5056. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5057. __func__, w->name);
  5058. ret = -EINVAL;
  5059. goto out;
  5060. }
  5061. dec_adc_mux_name = widget_name;
  5062. dec = strpbrk(dec_adc_mux_name, "012345678");
  5063. if (!dec) {
  5064. dev_err(codec->dev, "%s: decimator index not found\n",
  5065. __func__);
  5066. ret = -EINVAL;
  5067. goto out;
  5068. }
  5069. ret = kstrtouint(dec, 10, &decimator);
  5070. if (ret < 0) {
  5071. dev_err(codec->dev, "%s: Invalid decimator = %s\n",
  5072. __func__, wname);
  5073. ret = -EINVAL;
  5074. goto out;
  5075. }
  5076. dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__,
  5077. w->name, decimator);
  5078. tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator;
  5079. hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 + 16 * decimator;
  5080. dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * decimator;
  5081. tx_gain_ctl_reg = WCD9335_CDC_TX0_TX_VOL_CTL + 16 * decimator;
  5082. switch (event) {
  5083. case SND_SOC_DAPM_PRE_PMU:
  5084. amic_n = tasha_codec_find_amic_input(codec, decimator);
  5085. if (amic_n)
  5086. pwr_level_reg = tasha_codec_get_amic_pwlvl_reg(codec,
  5087. amic_n);
  5088. if (pwr_level_reg) {
  5089. switch ((snd_soc_read(codec, pwr_level_reg) &
  5090. WCD9335_AMIC_PWR_LVL_MASK) >>
  5091. WCD9335_AMIC_PWR_LVL_SHIFT) {
  5092. case WCD9335_AMIC_PWR_LEVEL_LP:
  5093. snd_soc_update_bits(codec, dec_cfg_reg,
  5094. WCD9335_DEC_PWR_LVL_MASK,
  5095. WCD9335_DEC_PWR_LVL_LP);
  5096. break;
  5097. case WCD9335_AMIC_PWR_LEVEL_HP:
  5098. snd_soc_update_bits(codec, dec_cfg_reg,
  5099. WCD9335_DEC_PWR_LVL_MASK,
  5100. WCD9335_DEC_PWR_LVL_HP);
  5101. break;
  5102. case WCD9335_AMIC_PWR_LEVEL_DEFAULT:
  5103. default:
  5104. snd_soc_update_bits(codec, dec_cfg_reg,
  5105. WCD9335_DEC_PWR_LVL_MASK,
  5106. WCD9335_DEC_PWR_LVL_DF);
  5107. break;
  5108. }
  5109. }
  5110. hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) &
  5111. TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
  5112. tasha->tx_hpf_work[decimator].hpf_cut_off_freq =
  5113. hpf_cut_off_freq;
  5114. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
  5115. snd_soc_update_bits(codec, dec_cfg_reg,
  5116. TX_HPF_CUT_OFF_FREQ_MASK,
  5117. CF_MIN_3DB_150HZ << 5);
  5118. /* Enable TX PGA Mute */
  5119. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5120. break;
  5121. case SND_SOC_DAPM_POST_PMU:
  5122. snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00);
  5123. if (decimator == 0) {
  5124. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5125. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0xA3);
  5126. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83);
  5127. snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x03);
  5128. }
  5129. /* schedule work queue to Remove Mute */
  5130. schedule_delayed_work(&tasha->tx_mute_dwork[decimator].dwork,
  5131. msecs_to_jiffies(tx_unmute_delay));
  5132. if (tasha->tx_hpf_work[decimator].hpf_cut_off_freq !=
  5133. CF_MIN_3DB_150HZ)
  5134. schedule_delayed_work(
  5135. &tasha->tx_hpf_work[decimator].dwork,
  5136. msecs_to_jiffies(300));
  5137. /* apply gain after decimator is enabled */
  5138. snd_soc_write(codec, tx_gain_ctl_reg,
  5139. snd_soc_read(codec, tx_gain_ctl_reg));
  5140. break;
  5141. case SND_SOC_DAPM_PRE_PMD:
  5142. hpf_cut_off_freq =
  5143. tasha->tx_hpf_work[decimator].hpf_cut_off_freq;
  5144. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
  5145. if (cancel_delayed_work_sync(
  5146. &tasha->tx_hpf_work[decimator].dwork)) {
  5147. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  5148. tasha_codec_vote_max_bw(codec, true);
  5149. snd_soc_update_bits(codec, dec_cfg_reg,
  5150. TX_HPF_CUT_OFF_FREQ_MASK,
  5151. hpf_cut_off_freq << 5);
  5152. tasha_codec_vote_max_bw(codec, false);
  5153. }
  5154. }
  5155. cancel_delayed_work_sync(
  5156. &tasha->tx_mute_dwork[decimator].dwork);
  5157. break;
  5158. case SND_SOC_DAPM_POST_PMD:
  5159. snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
  5160. break;
  5161. };
  5162. out:
  5163. kfree(wname);
  5164. return ret;
  5165. }
  5166. static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec,
  5167. unsigned int dmic, struct wcd9xxx_pdata *pdata)
  5168. {
  5169. u8 tx_stream_fs;
  5170. u8 adc_mux_index = 0, adc_mux_sel = 0;
  5171. bool dec_found = false;
  5172. u16 adc_mux_ctl_reg, tx_fs_reg;
  5173. u32 dmic_fs;
  5174. while (dec_found == 0 && adc_mux_index < WCD9335_MAX_VALID_ADC_MUX) {
  5175. if (adc_mux_index < 4) {
  5176. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  5177. (adc_mux_index * 2);
  5178. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5179. 0x78) >> 3) - 1;
  5180. } else if (adc_mux_index < 9) {
  5181. adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 +
  5182. ((adc_mux_index - 4) * 1);
  5183. adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) &
  5184. 0x38) >> 3) - 1;
  5185. } else if (adc_mux_index == 9) {
  5186. ++adc_mux_index;
  5187. continue;
  5188. }
  5189. if (adc_mux_sel == dmic)
  5190. dec_found = true;
  5191. else
  5192. ++adc_mux_index;
  5193. }
  5194. if (dec_found == true && adc_mux_index <= 8) {
  5195. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index);
  5196. tx_stream_fs = snd_soc_read(codec, tx_fs_reg) & 0x0F;
  5197. dmic_fs = tx_stream_fs <= 4 ? WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ :
  5198. WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  5199. /*
  5200. * Check for ECPP path selection and DEC1 not connected to
  5201. * any other audio path to apply ECPP DMIC sample rate
  5202. */
  5203. if ((adc_mux_index == 1) &&
  5204. ((snd_soc_read(codec, WCD9335_CPE_SS_US_EC_MUX_CFG)
  5205. & 0x0F) == 0x0A) &&
  5206. ((snd_soc_read(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0)
  5207. & 0x0C) == 0x00)) {
  5208. dmic_fs = pdata->ecpp_dmic_sample_rate;
  5209. }
  5210. } else {
  5211. dmic_fs = pdata->dmic_sample_rate;
  5212. }
  5213. return dmic_fs;
  5214. }
  5215. static u8 tasha_get_dmic_clk_val(struct snd_soc_codec *codec,
  5216. u32 mclk_rate, u32 dmic_clk_rate)
  5217. {
  5218. u32 div_factor;
  5219. u8 dmic_ctl_val;
  5220. dev_dbg(codec->dev,
  5221. "%s: mclk_rate = %d, dmic_sample_rate = %d\n",
  5222. __func__, mclk_rate, dmic_clk_rate);
  5223. /* Default value to return in case of error */
  5224. if (mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  5225. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5226. else
  5227. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5228. if (dmic_clk_rate == 0) {
  5229. dev_err(codec->dev,
  5230. "%s: dmic_sample_rate cannot be 0\n",
  5231. __func__);
  5232. goto done;
  5233. }
  5234. div_factor = mclk_rate / dmic_clk_rate;
  5235. switch (div_factor) {
  5236. case 2:
  5237. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_2;
  5238. break;
  5239. case 3:
  5240. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3;
  5241. break;
  5242. case 4:
  5243. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_4;
  5244. break;
  5245. case 6:
  5246. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_6;
  5247. break;
  5248. case 8:
  5249. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_8;
  5250. break;
  5251. case 16:
  5252. dmic_ctl_val = WCD9335_DMIC_CLK_DIV_16;
  5253. break;
  5254. default:
  5255. dev_err(codec->dev,
  5256. "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n",
  5257. __func__, div_factor, mclk_rate, dmic_clk_rate);
  5258. break;
  5259. }
  5260. done:
  5261. return dmic_ctl_val;
  5262. }
  5263. static int tasha_codec_enable_adc(struct snd_soc_dapm_widget *w,
  5264. struct snd_kcontrol *kcontrol, int event)
  5265. {
  5266. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5267. dev_dbg(codec->dev, "%s: event:%d\n", __func__, event);
  5268. switch (event) {
  5269. case SND_SOC_DAPM_PRE_PMU:
  5270. tasha_codec_set_tx_hold(codec, w->reg, true);
  5271. break;
  5272. default:
  5273. break;
  5274. }
  5275. return 0;
  5276. }
  5277. static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w,
  5278. struct snd_kcontrol *kcontrol, int event)
  5279. {
  5280. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5281. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5282. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  5283. u8 dmic_clk_en = 0x01;
  5284. u16 dmic_clk_reg;
  5285. s32 *dmic_clk_cnt;
  5286. u8 dmic_rate_val, dmic_rate_shift = 1;
  5287. unsigned int dmic;
  5288. u32 dmic_sample_rate;
  5289. int ret;
  5290. char *wname;
  5291. wname = strpbrk(w->name, "012345");
  5292. if (!wname) {
  5293. dev_err(codec->dev, "%s: widget not found\n", __func__);
  5294. return -EINVAL;
  5295. }
  5296. ret = kstrtouint(wname, 10, &dmic);
  5297. if (ret < 0) {
  5298. dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n",
  5299. __func__);
  5300. return -EINVAL;
  5301. }
  5302. switch (dmic) {
  5303. case 0:
  5304. case 1:
  5305. dmic_clk_cnt = &(tasha->dmic_0_1_clk_cnt);
  5306. dmic_clk_reg = WCD9335_CPE_SS_DMIC0_CTL;
  5307. break;
  5308. case 2:
  5309. case 3:
  5310. dmic_clk_cnt = &(tasha->dmic_2_3_clk_cnt);
  5311. dmic_clk_reg = WCD9335_CPE_SS_DMIC1_CTL;
  5312. break;
  5313. case 4:
  5314. case 5:
  5315. dmic_clk_cnt = &(tasha->dmic_4_5_clk_cnt);
  5316. dmic_clk_reg = WCD9335_CPE_SS_DMIC2_CTL;
  5317. break;
  5318. default:
  5319. dev_err(codec->dev, "%s: Invalid DMIC Selection\n",
  5320. __func__);
  5321. return -EINVAL;
  5322. };
  5323. dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
  5324. __func__, event, dmic, *dmic_clk_cnt);
  5325. switch (event) {
  5326. case SND_SOC_DAPM_PRE_PMU:
  5327. dmic_sample_rate = tasha_get_dmic_sample_rate(codec, dmic,
  5328. pdata);
  5329. dmic_rate_val =
  5330. tasha_get_dmic_clk_val(codec,
  5331. pdata->mclk_rate,
  5332. dmic_sample_rate);
  5333. (*dmic_clk_cnt)++;
  5334. if (*dmic_clk_cnt == 1) {
  5335. snd_soc_update_bits(codec, dmic_clk_reg,
  5336. 0x07 << dmic_rate_shift,
  5337. dmic_rate_val << dmic_rate_shift);
  5338. snd_soc_update_bits(codec, dmic_clk_reg,
  5339. dmic_clk_en, dmic_clk_en);
  5340. }
  5341. break;
  5342. case SND_SOC_DAPM_POST_PMD:
  5343. dmic_rate_val =
  5344. tasha_get_dmic_clk_val(codec,
  5345. pdata->mclk_rate,
  5346. pdata->mad_dmic_sample_rate);
  5347. (*dmic_clk_cnt)--;
  5348. if (*dmic_clk_cnt == 0) {
  5349. snd_soc_update_bits(codec, dmic_clk_reg,
  5350. dmic_clk_en, 0);
  5351. snd_soc_update_bits(codec, dmic_clk_reg,
  5352. 0x07 << dmic_rate_shift,
  5353. dmic_rate_val << dmic_rate_shift);
  5354. }
  5355. break;
  5356. };
  5357. return 0;
  5358. }
  5359. static int __tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5360. int event)
  5361. {
  5362. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5363. int micb_num;
  5364. dev_dbg(codec->dev, "%s: wname: %s, event: %d\n",
  5365. __func__, w->name, event);
  5366. if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1")))
  5367. micb_num = MIC_BIAS_1;
  5368. else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2")))
  5369. micb_num = MIC_BIAS_2;
  5370. else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3")))
  5371. micb_num = MIC_BIAS_3;
  5372. else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4")))
  5373. micb_num = MIC_BIAS_4;
  5374. else
  5375. return -EINVAL;
  5376. switch (event) {
  5377. case SND_SOC_DAPM_PRE_PMU:
  5378. /*
  5379. * MIC BIAS can also be requested by MBHC,
  5380. * so use ref count to handle micbias pullup
  5381. * and enable requests
  5382. */
  5383. tasha_micbias_control(codec, micb_num, MICB_ENABLE, true);
  5384. break;
  5385. case SND_SOC_DAPM_POST_PMU:
  5386. /* wait for cnp time */
  5387. usleep_range(1000, 1100);
  5388. break;
  5389. case SND_SOC_DAPM_POST_PMD:
  5390. tasha_micbias_control(codec, micb_num, MICB_DISABLE, true);
  5391. break;
  5392. };
  5393. return 0;
  5394. }
  5395. static int tasha_codec_ldo_h_control(struct snd_soc_dapm_widget *w,
  5396. int event)
  5397. {
  5398. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5399. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5400. if (SND_SOC_DAPM_EVENT_ON(event)) {
  5401. tasha->ldo_h_users++;
  5402. if (tasha->ldo_h_users == 1)
  5403. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5404. 0x80, 0x80);
  5405. }
  5406. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  5407. tasha->ldo_h_users--;
  5408. if (tasha->ldo_h_users < 0)
  5409. tasha->ldo_h_users = 0;
  5410. if (tasha->ldo_h_users == 0)
  5411. snd_soc_update_bits(codec, WCD9335_LDOH_MODE,
  5412. 0x80, 0x00);
  5413. }
  5414. return 0;
  5415. }
  5416. static int tasha_codec_force_enable_ldo_h(struct snd_soc_dapm_widget *w,
  5417. struct snd_kcontrol *kcontrol,
  5418. int event)
  5419. {
  5420. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5421. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5422. switch (event) {
  5423. case SND_SOC_DAPM_PRE_PMU:
  5424. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5425. tasha_codec_ldo_h_control(w, event);
  5426. break;
  5427. case SND_SOC_DAPM_POST_PMD:
  5428. tasha_codec_ldo_h_control(w, event);
  5429. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5430. break;
  5431. }
  5432. return 0;
  5433. }
  5434. static int tasha_codec_force_enable_micbias(struct snd_soc_dapm_widget *w,
  5435. struct snd_kcontrol *kcontrol,
  5436. int event)
  5437. {
  5438. int ret = 0;
  5439. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  5440. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  5441. switch (event) {
  5442. case SND_SOC_DAPM_PRE_PMU:
  5443. wcd_resmgr_enable_master_bias(tasha->resmgr);
  5444. tasha_cdc_mclk_enable(codec, true, true);
  5445. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_PRE_PMU);
  5446. /* Wait for 1ms for better cnp */
  5447. usleep_range(1000, 1100);
  5448. tasha_cdc_mclk_enable(codec, false, true);
  5449. break;
  5450. case SND_SOC_DAPM_POST_PMD:
  5451. ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_POST_PMD);
  5452. wcd_resmgr_disable_master_bias(tasha->resmgr);
  5453. break;
  5454. }
  5455. return ret;
  5456. }
  5457. static int tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  5458. struct snd_kcontrol *kcontrol, int event)
  5459. {
  5460. return __tasha_codec_enable_micbias(w, event);
  5461. }
  5462. static int tasha_codec_enable_standalone_ldo_h(struct snd_soc_codec *codec,
  5463. bool enable)
  5464. {
  5465. int rc;
  5466. if (enable)
  5467. rc = snd_soc_dapm_force_enable_pin(
  5468. snd_soc_codec_get_dapm(codec),
  5469. DAPM_LDO_H_STANDALONE);
  5470. else
  5471. rc = snd_soc_dapm_disable_pin(
  5472. snd_soc_codec_get_dapm(codec),
  5473. DAPM_LDO_H_STANDALONE);
  5474. if (!rc)
  5475. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5476. else
  5477. dev_err(codec->dev, "%s: ldo_h force %s pin failed\n",
  5478. __func__, (enable ? "enable" : "disable"));
  5479. return rc;
  5480. }
  5481. /*
  5482. * tasha_codec_enable_standalone_micbias - enable micbias standalone
  5483. * @codec: pointer to codec instance
  5484. * @micb_num: number of micbias to be enabled
  5485. * @enable: true to enable micbias or false to disable
  5486. *
  5487. * This function is used to enable micbias (1, 2, 3 or 4) during
  5488. * standalone independent of whether TX use-case is running or not
  5489. *
  5490. * Return: error code in case of failure or 0 for success
  5491. */
  5492. int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
  5493. int micb_num,
  5494. bool enable)
  5495. {
  5496. const char * const micb_names[] = {
  5497. DAPM_MICBIAS1_STANDALONE, DAPM_MICBIAS2_STANDALONE,
  5498. DAPM_MICBIAS3_STANDALONE, DAPM_MICBIAS4_STANDALONE
  5499. };
  5500. int micb_index = micb_num - 1;
  5501. int rc;
  5502. if (!codec) {
  5503. pr_err("%s: Codec memory is NULL\n", __func__);
  5504. return -EINVAL;
  5505. }
  5506. if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) {
  5507. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  5508. __func__, micb_index);
  5509. return -EINVAL;
  5510. }
  5511. if (enable)
  5512. rc = snd_soc_dapm_force_enable_pin(
  5513. snd_soc_codec_get_dapm(codec),
  5514. micb_names[micb_index]);
  5515. else
  5516. rc = snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec),
  5517. micb_names[micb_index]);
  5518. if (!rc)
  5519. snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
  5520. else
  5521. dev_err(codec->dev, "%s: micbias%d force %s pin failed\n",
  5522. __func__, micb_num, (enable ? "enable" : "disable"));
  5523. return rc;
  5524. }
  5525. EXPORT_SYMBOL(tasha_codec_enable_standalone_micbias);
  5526. static const char *const tasha_anc_func_text[] = {"OFF", "ON"};
  5527. static const struct soc_enum tasha_anc_func_enum =
  5528. SOC_ENUM_SINGLE_EXT(2, tasha_anc_func_text);
  5529. static const char *const tasha_clkmode_text[] = {"EXTERNAL", "INTERNAL"};
  5530. static SOC_ENUM_SINGLE_EXT_DECL(tasha_clkmode_enum, tasha_clkmode_text);
  5531. /* Cutoff frequency for high pass filter */
  5532. static const char * const cf_text[] = {
  5533. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
  5534. };
  5535. static const char * const rx_cf_text[] = {
  5536. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ",
  5537. "CF_NEG_3DB_0P48HZ"
  5538. };
  5539. static const struct soc_enum cf_dec0_enum =
  5540. SOC_ENUM_SINGLE(WCD9335_CDC_TX0_TX_PATH_CFG0, 5, 3, cf_text);
  5541. static const struct soc_enum cf_dec1_enum =
  5542. SOC_ENUM_SINGLE(WCD9335_CDC_TX1_TX_PATH_CFG0, 5, 3, cf_text);
  5543. static const struct soc_enum cf_dec2_enum =
  5544. SOC_ENUM_SINGLE(WCD9335_CDC_TX2_TX_PATH_CFG0, 5, 3, cf_text);
  5545. static const struct soc_enum cf_dec3_enum =
  5546. SOC_ENUM_SINGLE(WCD9335_CDC_TX3_TX_PATH_CFG0, 5, 3, cf_text);
  5547. static const struct soc_enum cf_dec4_enum =
  5548. SOC_ENUM_SINGLE(WCD9335_CDC_TX4_TX_PATH_CFG0, 5, 3, cf_text);
  5549. static const struct soc_enum cf_dec5_enum =
  5550. SOC_ENUM_SINGLE(WCD9335_CDC_TX5_TX_PATH_CFG0, 5, 3, cf_text);
  5551. static const struct soc_enum cf_dec6_enum =
  5552. SOC_ENUM_SINGLE(WCD9335_CDC_TX6_TX_PATH_CFG0, 5, 3, cf_text);
  5553. static const struct soc_enum cf_dec7_enum =
  5554. SOC_ENUM_SINGLE(WCD9335_CDC_TX7_TX_PATH_CFG0, 5, 3, cf_text);
  5555. static const struct soc_enum cf_dec8_enum =
  5556. SOC_ENUM_SINGLE(WCD9335_CDC_TX8_TX_PATH_CFG0, 5, 3, cf_text);
  5557. static const struct soc_enum cf_int0_1_enum =
  5558. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5559. static SOC_ENUM_SINGLE_DECL(cf_int0_2_enum, WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 2,
  5560. rx_cf_text);
  5561. static const struct soc_enum cf_int1_1_enum =
  5562. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5563. static SOC_ENUM_SINGLE_DECL(cf_int1_2_enum, WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 2,
  5564. rx_cf_text);
  5565. static const struct soc_enum cf_int2_1_enum =
  5566. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5567. static SOC_ENUM_SINGLE_DECL(cf_int2_2_enum, WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 2,
  5568. rx_cf_text);
  5569. static const struct soc_enum cf_int3_1_enum =
  5570. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5571. static SOC_ENUM_SINGLE_DECL(cf_int3_2_enum, WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 2,
  5572. rx_cf_text);
  5573. static const struct soc_enum cf_int4_1_enum =
  5574. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5575. static SOC_ENUM_SINGLE_DECL(cf_int4_2_enum, WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 2,
  5576. rx_cf_text);
  5577. static const struct soc_enum cf_int5_1_enum =
  5578. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5579. static SOC_ENUM_SINGLE_DECL(cf_int5_2_enum, WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 2,
  5580. rx_cf_text);
  5581. static const struct soc_enum cf_int6_1_enum =
  5582. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5583. static SOC_ENUM_SINGLE_DECL(cf_int6_2_enum, WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 2,
  5584. rx_cf_text);
  5585. static const struct soc_enum cf_int7_1_enum =
  5586. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5587. static SOC_ENUM_SINGLE_DECL(cf_int7_2_enum, WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 2,
  5588. rx_cf_text);
  5589. static const struct soc_enum cf_int8_1_enum =
  5590. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CFG2, 0, 4, rx_cf_text);
  5591. static SOC_ENUM_SINGLE_DECL(cf_int8_2_enum, WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 2,
  5592. rx_cf_text);
  5593. static const struct snd_soc_dapm_route audio_i2s_map[] = {
  5594. {"SLIM RX0 MUX", NULL, "RX_I2S_CTL"},
  5595. {"SLIM RX1 MUX", NULL, "RX_I2S_CTL"},
  5596. {"SLIM RX2 MUX", NULL, "RX_I2S_CTL"},
  5597. {"SLIM RX3 MUX", NULL, "RX_I2S_CTL"},
  5598. {"SLIM TX6 MUX", NULL, "TX_I2S_CTL"},
  5599. {"SLIM TX7 MUX", NULL, "TX_I2S_CTL"},
  5600. {"SLIM TX8 MUX", NULL, "TX_I2S_CTL"},
  5601. {"SLIM TX11 MUX", NULL, "TX_I2S_CTL"},
  5602. };
  5603. static const struct snd_soc_dapm_route audio_map[] = {
  5604. /* MAD */
  5605. {"MAD_SEL MUX", "SPE", "MAD_CPE_INPUT"},
  5606. {"MAD_SEL MUX", "MSM", "MADINPUT"},
  5607. {"MADONOFF", "Switch", "MAD_SEL MUX"},
  5608. {"MAD_BROADCAST", "Switch", "MAD_SEL MUX"},
  5609. {"TX13 INP MUX", "CPE_TX_PP", "MADONOFF"},
  5610. /* CPE HW MAD bypass */
  5611. {"CPE IN Mixer", "MAD_BYPASS", "SLIM TX1 MUX"},
  5612. {"AIF4_MAD Mixer", "SLIM TX1", "CPE IN Mixer"},
  5613. {"AIF4_MAD Mixer", "SLIM TX12", "MADONOFF"},
  5614. {"AIF4_MAD Mixer", "SLIM TX13", "TX13 INP MUX"},
  5615. {"AIF4 MAD", NULL, "AIF4_MAD Mixer"},
  5616. {"AIF4 MAD", NULL, "AIF4"},
  5617. {"EC BUF MUX INP", "DEC1", "ADC MUX1"},
  5618. {"AIF5 CPE", NULL, "EC BUF MUX INP"},
  5619. /* SLIMBUS Connections */
  5620. {"AIF1 CAP", NULL, "AIF1_CAP Mixer"},
  5621. {"AIF2 CAP", NULL, "AIF2_CAP Mixer"},
  5622. {"AIF3 CAP", NULL, "AIF3_CAP Mixer"},
  5623. /* VI Feedback */
  5624. {"AIF4_VI Mixer", "SPKR_VI_1", "VIINPUT"},
  5625. {"AIF4_VI Mixer", "SPKR_VI_2", "VIINPUT"},
  5626. {"AIF4 VI", NULL, "AIF4_VI Mixer"},
  5627. /* SLIM_MIXER("AIF1_CAP Mixer"),*/
  5628. {"AIF1_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5629. {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5630. {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5631. {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5632. {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5633. {"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5634. {"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5635. {"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5636. {"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5637. {"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5638. {"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5639. {"AIF1_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5640. {"AIF1_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5641. /* SLIM_MIXER("AIF2_CAP Mixer"),*/
  5642. {"AIF2_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5643. {"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5644. {"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5645. {"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5646. {"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5647. {"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5648. {"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5649. {"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5650. {"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5651. {"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5652. {"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5653. {"AIF2_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5654. {"AIF2_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5655. /* SLIM_MIXER("AIF3_CAP Mixer"),*/
  5656. {"AIF3_CAP Mixer", "SLIM TX0", "SLIM TX0 MUX"},
  5657. {"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"},
  5658. {"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"},
  5659. {"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"},
  5660. {"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"},
  5661. {"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"},
  5662. {"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"},
  5663. {"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"},
  5664. {"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"},
  5665. {"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"},
  5666. {"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"},
  5667. {"AIF3_CAP Mixer", "SLIM TX11", "SLIM TX11 MUX"},
  5668. {"AIF3_CAP Mixer", "SLIM TX13", "TX13 INP MUX"},
  5669. {"SLIM TX0 MUX", "DEC0", "ADC MUX0"},
  5670. {"SLIM TX0 MUX", "RX_MIX_TX0", "RX MIX TX0 MUX"},
  5671. {"SLIM TX0 MUX", "DEC0_192", "ADC US MUX0"},
  5672. {"SLIM TX1 MUX", "DEC1", "ADC MUX1"},
  5673. {"SLIM TX1 MUX", "RX_MIX_TX1", "RX MIX TX1 MUX"},
  5674. {"SLIM TX1 MUX", "DEC1_192", "ADC US MUX1"},
  5675. {"SLIM TX2 MUX", "DEC2", "ADC MUX2"},
  5676. {"SLIM TX2 MUX", "RX_MIX_TX2", "RX MIX TX2 MUX"},
  5677. {"SLIM TX2 MUX", "DEC2_192", "ADC US MUX2"},
  5678. {"SLIM TX3 MUX", "DEC3", "ADC MUX3"},
  5679. {"SLIM TX3 MUX", "RX_MIX_TX3", "RX MIX TX3 MUX"},
  5680. {"SLIM TX3 MUX", "DEC3_192", "ADC US MUX3"},
  5681. {"SLIM TX4 MUX", "DEC4", "ADC MUX4"},
  5682. {"SLIM TX4 MUX", "RX_MIX_TX4", "RX MIX TX4 MUX"},
  5683. {"SLIM TX4 MUX", "DEC4_192", "ADC US MUX4"},
  5684. {"SLIM TX5 MUX", "DEC5", "ADC MUX5"},
  5685. {"SLIM TX5 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5686. {"SLIM TX5 MUX", "DEC5_192", "ADC US MUX5"},
  5687. {"SLIM TX6 MUX", "DEC6", "ADC MUX6"},
  5688. {"SLIM TX6 MUX", "RX_MIX_TX6", "RX MIX TX6 MUX"},
  5689. {"SLIM TX6 MUX", "DEC6_192", "ADC US MUX6"},
  5690. {"SLIM TX7 MUX", "DEC7", "ADC MUX7"},
  5691. {"SLIM TX7 MUX", "RX_MIX_TX7", "RX MIX TX7 MUX"},
  5692. {"SLIM TX7 MUX", "DEC7_192", "ADC US MUX7"},
  5693. {"SLIM TX8 MUX", "DEC8", "ADC MUX8"},
  5694. {"SLIM TX8 MUX", "RX_MIX_TX8", "RX MIX TX8 MUX"},
  5695. {"SLIM TX8 MUX", "DEC8_192", "ADC US MUX8"},
  5696. {"SLIM TX9 MUX", "DEC7", "ADC MUX7"},
  5697. {"SLIM TX9 MUX", "DEC7_192", "ADC US MUX7"},
  5698. {"SLIM TX10 MUX", "DEC6", "ADC MUX6"},
  5699. {"SLIM TX10 MUX", "DEC6_192", "ADC US MUX6"},
  5700. {"SLIM TX11 MUX", "DEC_0_5", "SLIM TX11 INP1 MUX"},
  5701. {"SLIM TX11 MUX", "DEC_9_12", "SLIM TX11 INP1 MUX"},
  5702. {"SLIM TX11 INP1 MUX", "DEC0", "ADC MUX0"},
  5703. {"SLIM TX11 INP1 MUX", "DEC1", "ADC MUX1"},
  5704. {"SLIM TX11 INP1 MUX", "DEC2", "ADC MUX2"},
  5705. {"SLIM TX11 INP1 MUX", "DEC3", "ADC MUX3"},
  5706. {"SLIM TX11 INP1 MUX", "DEC4", "ADC MUX4"},
  5707. {"SLIM TX11 INP1 MUX", "DEC5", "ADC MUX5"},
  5708. {"SLIM TX11 INP1 MUX", "RX_MIX_TX5", "RX MIX TX5 MUX"},
  5709. {"TX13 INP MUX", "MAD_BRDCST", "MAD_BROADCAST"},
  5710. {"TX13 INP MUX", "CDC_DEC_5", "SLIM TX13 MUX"},
  5711. {"SLIM TX13 MUX", "DEC5", "ADC MUX5"},
  5712. {"RX MIX TX0 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5713. {"RX MIX TX0 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5714. {"RX MIX TX0 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5715. {"RX MIX TX0 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5716. {"RX MIX TX0 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5717. {"RX MIX TX0 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5718. {"RX MIX TX0 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5719. {"RX MIX TX0 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5720. {"RX MIX TX0 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5721. {"RX MIX TX0 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5722. {"RX MIX TX0 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5723. {"RX MIX TX0 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5724. {"RX MIX TX0 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5725. {"RX MIX TX1 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5726. {"RX MIX TX1 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5727. {"RX MIX TX1 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5728. {"RX MIX TX1 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5729. {"RX MIX TX1 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5730. {"RX MIX TX1 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5731. {"RX MIX TX1 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5732. {"RX MIX TX1 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5733. {"RX MIX TX1 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5734. {"RX MIX TX1 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5735. {"RX MIX TX1 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5736. {"RX MIX TX1 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5737. {"RX MIX TX1 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5738. {"RX MIX TX2 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5739. {"RX MIX TX2 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5740. {"RX MIX TX2 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5741. {"RX MIX TX2 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5742. {"RX MIX TX2 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5743. {"RX MIX TX2 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5744. {"RX MIX TX2 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5745. {"RX MIX TX2 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5746. {"RX MIX TX2 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5747. {"RX MIX TX2 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5748. {"RX MIX TX2 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5749. {"RX MIX TX2 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5750. {"RX MIX TX2 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5751. {"RX MIX TX3 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5752. {"RX MIX TX3 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5753. {"RX MIX TX3 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5754. {"RX MIX TX3 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5755. {"RX MIX TX3 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5756. {"RX MIX TX3 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5757. {"RX MIX TX3 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5758. {"RX MIX TX3 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5759. {"RX MIX TX3 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5760. {"RX MIX TX3 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5761. {"RX MIX TX3 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5762. {"RX MIX TX3 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5763. {"RX MIX TX3 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5764. {"RX MIX TX4 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5765. {"RX MIX TX4 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5766. {"RX MIX TX4 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5767. {"RX MIX TX4 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5768. {"RX MIX TX4 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5769. {"RX MIX TX4 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5770. {"RX MIX TX4 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5771. {"RX MIX TX4 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5772. {"RX MIX TX4 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5773. {"RX MIX TX4 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5774. {"RX MIX TX4 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5775. {"RX MIX TX4 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5776. {"RX MIX TX4 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5777. {"RX MIX TX5 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5778. {"RX MIX TX5 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5779. {"RX MIX TX5 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5780. {"RX MIX TX5 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5781. {"RX MIX TX5 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5782. {"RX MIX TX5 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5783. {"RX MIX TX5 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5784. {"RX MIX TX5 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5785. {"RX MIX TX5 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5786. {"RX MIX TX5 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5787. {"RX MIX TX5 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5788. {"RX MIX TX5 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5789. {"RX MIX TX5 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5790. {"RX MIX TX6 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5791. {"RX MIX TX6 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5792. {"RX MIX TX6 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5793. {"RX MIX TX6 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5794. {"RX MIX TX6 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5795. {"RX MIX TX6 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5796. {"RX MIX TX6 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5797. {"RX MIX TX6 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5798. {"RX MIX TX6 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5799. {"RX MIX TX6 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5800. {"RX MIX TX6 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5801. {"RX MIX TX6 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5802. {"RX MIX TX6 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5803. {"RX MIX TX7 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5804. {"RX MIX TX7 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5805. {"RX MIX TX7 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5806. {"RX MIX TX7 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5807. {"RX MIX TX7 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5808. {"RX MIX TX7 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5809. {"RX MIX TX7 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5810. {"RX MIX TX7 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5811. {"RX MIX TX7 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5812. {"RX MIX TX7 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5813. {"RX MIX TX7 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5814. {"RX MIX TX7 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5815. {"RX MIX TX7 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5816. {"RX MIX TX8 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
  5817. {"RX MIX TX8 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
  5818. {"RX MIX TX8 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
  5819. {"RX MIX TX8 MUX", "RX_MIX3", "RX INT3 SEC MIX"},
  5820. {"RX MIX TX8 MUX", "RX_MIX4", "RX INT4 SEC MIX"},
  5821. {"RX MIX TX8 MUX", "RX_MIX5", "RX INT5 SEC MIX"},
  5822. {"RX MIX TX8 MUX", "RX_MIX6", "RX INT6 SEC MIX"},
  5823. {"RX MIX TX8 MUX", "RX_MIX7", "RX INT7 SEC MIX"},
  5824. {"RX MIX TX8 MUX", "RX_MIX8", "RX INT8 SEC MIX"},
  5825. {"RX MIX TX8 MUX", "RX_MIX_VBAT5", "RX INT5 VBAT"},
  5826. {"RX MIX TX8 MUX", "RX_MIX_VBAT6", "RX INT6 VBAT"},
  5827. {"RX MIX TX8 MUX", "RX_MIX_VBAT7", "RX INT7 VBAT"},
  5828. {"RX MIX TX8 MUX", "RX_MIX_VBAT8", "RX INT8 VBAT"},
  5829. {"ADC US MUX0", "US_Switch", "ADC MUX0"},
  5830. {"ADC US MUX1", "US_Switch", "ADC MUX1"},
  5831. {"ADC US MUX2", "US_Switch", "ADC MUX2"},
  5832. {"ADC US MUX3", "US_Switch", "ADC MUX3"},
  5833. {"ADC US MUX4", "US_Switch", "ADC MUX4"},
  5834. {"ADC US MUX5", "US_Switch", "ADC MUX5"},
  5835. {"ADC US MUX6", "US_Switch", "ADC MUX6"},
  5836. {"ADC US MUX7", "US_Switch", "ADC MUX7"},
  5837. {"ADC US MUX8", "US_Switch", "ADC MUX8"},
  5838. {"ADC MUX0", "DMIC", "DMIC MUX0"},
  5839. {"ADC MUX0", "AMIC", "AMIC MUX0"},
  5840. {"ADC MUX1", "DMIC", "DMIC MUX1"},
  5841. {"ADC MUX1", "AMIC", "AMIC MUX1"},
  5842. {"ADC MUX2", "DMIC", "DMIC MUX2"},
  5843. {"ADC MUX2", "AMIC", "AMIC MUX2"},
  5844. {"ADC MUX3", "DMIC", "DMIC MUX3"},
  5845. {"ADC MUX3", "AMIC", "AMIC MUX3"},
  5846. {"ADC MUX4", "DMIC", "DMIC MUX4"},
  5847. {"ADC MUX4", "AMIC", "AMIC MUX4"},
  5848. {"ADC MUX5", "DMIC", "DMIC MUX5"},
  5849. {"ADC MUX5", "AMIC", "AMIC MUX5"},
  5850. {"ADC MUX6", "DMIC", "DMIC MUX6"},
  5851. {"ADC MUX6", "AMIC", "AMIC MUX6"},
  5852. {"ADC MUX7", "DMIC", "DMIC MUX7"},
  5853. {"ADC MUX7", "AMIC", "AMIC MUX7"},
  5854. {"ADC MUX8", "DMIC", "DMIC MUX8"},
  5855. {"ADC MUX8", "AMIC", "AMIC MUX8"},
  5856. {"ADC MUX10", "DMIC", "DMIC MUX10"},
  5857. {"ADC MUX10", "AMIC", "AMIC MUX10"},
  5858. {"ADC MUX11", "DMIC", "DMIC MUX11"},
  5859. {"ADC MUX11", "AMIC", "AMIC MUX11"},
  5860. {"ADC MUX12", "DMIC", "DMIC MUX12"},
  5861. {"ADC MUX12", "AMIC", "AMIC MUX12"},
  5862. {"ADC MUX13", "DMIC", "DMIC MUX13"},
  5863. {"ADC MUX13", "AMIC", "AMIC MUX13"},
  5864. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX10"},
  5865. {"ADC MUX0", "ANC_FB_TUNE1", "ADC MUX11"},
  5866. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX12"},
  5867. {"ADC MUX0", "ANC_FB_TUNE2", "ADC MUX13"},
  5868. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX10"},
  5869. {"ADC MUX1", "ANC_FB_TUNE1", "ADC MUX11"},
  5870. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX12"},
  5871. {"ADC MUX1", "ANC_FB_TUNE2", "ADC MUX13"},
  5872. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX10"},
  5873. {"ADC MUX2", "ANC_FB_TUNE1", "ADC MUX11"},
  5874. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX12"},
  5875. {"ADC MUX2", "ANC_FB_TUNE2", "ADC MUX13"},
  5876. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX10"},
  5877. {"ADC MUX3", "ANC_FB_TUNE1", "ADC MUX11"},
  5878. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX12"},
  5879. {"ADC MUX3", "ANC_FB_TUNE2", "ADC MUX13"},
  5880. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX10"},
  5881. {"ADC MUX4", "ANC_FB_TUNE1", "ADC MUX11"},
  5882. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX12"},
  5883. {"ADC MUX4", "ANC_FB_TUNE2", "ADC MUX13"},
  5884. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX10"},
  5885. {"ADC MUX5", "ANC_FB_TUNE1", "ADC MUX11"},
  5886. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX12"},
  5887. {"ADC MUX5", "ANC_FB_TUNE2", "ADC MUX13"},
  5888. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX10"},
  5889. {"ADC MUX6", "ANC_FB_TUNE1", "ADC MUX11"},
  5890. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX12"},
  5891. {"ADC MUX6", "ANC_FB_TUNE2", "ADC MUX13"},
  5892. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX10"},
  5893. {"ADC MUX7", "ANC_FB_TUNE1", "ADC MUX11"},
  5894. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX12"},
  5895. {"ADC MUX7", "ANC_FB_TUNE2", "ADC MUX13"},
  5896. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX10"},
  5897. {"ADC MUX8", "ANC_FB_TUNE1", "ADC MUX11"},
  5898. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX12"},
  5899. {"ADC MUX8", "ANC_FB_TUNE2", "ADC MUX13"},
  5900. {"DMIC MUX0", "DMIC0", "DMIC0"},
  5901. {"DMIC MUX0", "DMIC1", "DMIC1"},
  5902. {"DMIC MUX0", "DMIC2", "DMIC2"},
  5903. {"DMIC MUX0", "DMIC3", "DMIC3"},
  5904. {"DMIC MUX0", "DMIC4", "DMIC4"},
  5905. {"DMIC MUX0", "DMIC5", "DMIC5"},
  5906. {"AMIC MUX0", "ADC1", "ADC1"},
  5907. {"AMIC MUX0", "ADC2", "ADC2"},
  5908. {"AMIC MUX0", "ADC3", "ADC3"},
  5909. {"AMIC MUX0", "ADC4", "ADC4"},
  5910. {"AMIC MUX0", "ADC5", "ADC5"},
  5911. {"AMIC MUX0", "ADC6", "ADC6"},
  5912. {"DMIC MUX1", "DMIC0", "DMIC0"},
  5913. {"DMIC MUX1", "DMIC1", "DMIC1"},
  5914. {"DMIC MUX1", "DMIC2", "DMIC2"},
  5915. {"DMIC MUX1", "DMIC3", "DMIC3"},
  5916. {"DMIC MUX1", "DMIC4", "DMIC4"},
  5917. {"DMIC MUX1", "DMIC5", "DMIC5"},
  5918. {"AMIC MUX1", "ADC1", "ADC1"},
  5919. {"AMIC MUX1", "ADC2", "ADC2"},
  5920. {"AMIC MUX1", "ADC3", "ADC3"},
  5921. {"AMIC MUX1", "ADC4", "ADC4"},
  5922. {"AMIC MUX1", "ADC5", "ADC5"},
  5923. {"AMIC MUX1", "ADC6", "ADC6"},
  5924. {"DMIC MUX2", "DMIC0", "DMIC0"},
  5925. {"DMIC MUX2", "DMIC1", "DMIC1"},
  5926. {"DMIC MUX2", "DMIC2", "DMIC2"},
  5927. {"DMIC MUX2", "DMIC3", "DMIC3"},
  5928. {"DMIC MUX2", "DMIC4", "DMIC4"},
  5929. {"DMIC MUX2", "DMIC5", "DMIC5"},
  5930. {"AMIC MUX2", "ADC1", "ADC1"},
  5931. {"AMIC MUX2", "ADC2", "ADC2"},
  5932. {"AMIC MUX2", "ADC3", "ADC3"},
  5933. {"AMIC MUX2", "ADC4", "ADC4"},
  5934. {"AMIC MUX2", "ADC5", "ADC5"},
  5935. {"AMIC MUX2", "ADC6", "ADC6"},
  5936. {"DMIC MUX3", "DMIC0", "DMIC0"},
  5937. {"DMIC MUX3", "DMIC1", "DMIC1"},
  5938. {"DMIC MUX3", "DMIC2", "DMIC2"},
  5939. {"DMIC MUX3", "DMIC3", "DMIC3"},
  5940. {"DMIC MUX3", "DMIC4", "DMIC4"},
  5941. {"DMIC MUX3", "DMIC5", "DMIC5"},
  5942. {"AMIC MUX3", "ADC1", "ADC1"},
  5943. {"AMIC MUX3", "ADC2", "ADC2"},
  5944. {"AMIC MUX3", "ADC3", "ADC3"},
  5945. {"AMIC MUX3", "ADC4", "ADC4"},
  5946. {"AMIC MUX3", "ADC5", "ADC5"},
  5947. {"AMIC MUX3", "ADC6", "ADC6"},
  5948. {"DMIC MUX4", "DMIC0", "DMIC0"},
  5949. {"DMIC MUX4", "DMIC1", "DMIC1"},
  5950. {"DMIC MUX4", "DMIC2", "DMIC2"},
  5951. {"DMIC MUX4", "DMIC3", "DMIC3"},
  5952. {"DMIC MUX4", "DMIC4", "DMIC4"},
  5953. {"DMIC MUX4", "DMIC5", "DMIC5"},
  5954. {"AMIC MUX4", "ADC1", "ADC1"},
  5955. {"AMIC MUX4", "ADC2", "ADC2"},
  5956. {"AMIC MUX4", "ADC3", "ADC3"},
  5957. {"AMIC MUX4", "ADC4", "ADC4"},
  5958. {"AMIC MUX4", "ADC5", "ADC5"},
  5959. {"AMIC MUX4", "ADC6", "ADC6"},
  5960. {"DMIC MUX5", "DMIC0", "DMIC0"},
  5961. {"DMIC MUX5", "DMIC1", "DMIC1"},
  5962. {"DMIC MUX5", "DMIC2", "DMIC2"},
  5963. {"DMIC MUX5", "DMIC3", "DMIC3"},
  5964. {"DMIC MUX5", "DMIC4", "DMIC4"},
  5965. {"DMIC MUX5", "DMIC5", "DMIC5"},
  5966. {"AMIC MUX5", "ADC1", "ADC1"},
  5967. {"AMIC MUX5", "ADC2", "ADC2"},
  5968. {"AMIC MUX5", "ADC3", "ADC3"},
  5969. {"AMIC MUX5", "ADC4", "ADC4"},
  5970. {"AMIC MUX5", "ADC5", "ADC5"},
  5971. {"AMIC MUX5", "ADC6", "ADC6"},
  5972. {"DMIC MUX6", "DMIC0", "DMIC0"},
  5973. {"DMIC MUX6", "DMIC1", "DMIC1"},
  5974. {"DMIC MUX6", "DMIC2", "DMIC2"},
  5975. {"DMIC MUX6", "DMIC3", "DMIC3"},
  5976. {"DMIC MUX6", "DMIC4", "DMIC4"},
  5977. {"DMIC MUX6", "DMIC5", "DMIC5"},
  5978. {"AMIC MUX6", "ADC1", "ADC1"},
  5979. {"AMIC MUX6", "ADC2", "ADC2"},
  5980. {"AMIC MUX6", "ADC3", "ADC3"},
  5981. {"AMIC MUX6", "ADC4", "ADC4"},
  5982. {"AMIC MUX6", "ADC5", "ADC5"},
  5983. {"AMIC MUX6", "ADC6", "ADC6"},
  5984. {"DMIC MUX7", "DMIC0", "DMIC0"},
  5985. {"DMIC MUX7", "DMIC1", "DMIC1"},
  5986. {"DMIC MUX7", "DMIC2", "DMIC2"},
  5987. {"DMIC MUX7", "DMIC3", "DMIC3"},
  5988. {"DMIC MUX7", "DMIC4", "DMIC4"},
  5989. {"DMIC MUX7", "DMIC5", "DMIC5"},
  5990. {"AMIC MUX7", "ADC1", "ADC1"},
  5991. {"AMIC MUX7", "ADC2", "ADC2"},
  5992. {"AMIC MUX7", "ADC3", "ADC3"},
  5993. {"AMIC MUX7", "ADC4", "ADC4"},
  5994. {"AMIC MUX7", "ADC5", "ADC5"},
  5995. {"AMIC MUX7", "ADC6", "ADC6"},
  5996. {"DMIC MUX8", "DMIC0", "DMIC0"},
  5997. {"DMIC MUX8", "DMIC1", "DMIC1"},
  5998. {"DMIC MUX8", "DMIC2", "DMIC2"},
  5999. {"DMIC MUX8", "DMIC3", "DMIC3"},
  6000. {"DMIC MUX8", "DMIC4", "DMIC4"},
  6001. {"DMIC MUX8", "DMIC5", "DMIC5"},
  6002. {"AMIC MUX8", "ADC1", "ADC1"},
  6003. {"AMIC MUX8", "ADC2", "ADC2"},
  6004. {"AMIC MUX8", "ADC3", "ADC3"},
  6005. {"AMIC MUX8", "ADC4", "ADC4"},
  6006. {"AMIC MUX8", "ADC5", "ADC5"},
  6007. {"AMIC MUX8", "ADC6", "ADC6"},
  6008. {"DMIC MUX10", "DMIC0", "DMIC0"},
  6009. {"DMIC MUX10", "DMIC1", "DMIC1"},
  6010. {"DMIC MUX10", "DMIC2", "DMIC2"},
  6011. {"DMIC MUX10", "DMIC3", "DMIC3"},
  6012. {"DMIC MUX10", "DMIC4", "DMIC4"},
  6013. {"DMIC MUX10", "DMIC5", "DMIC5"},
  6014. {"AMIC MUX10", "ADC1", "ADC1"},
  6015. {"AMIC MUX10", "ADC2", "ADC2"},
  6016. {"AMIC MUX10", "ADC3", "ADC3"},
  6017. {"AMIC MUX10", "ADC4", "ADC4"},
  6018. {"AMIC MUX10", "ADC5", "ADC5"},
  6019. {"AMIC MUX10", "ADC6", "ADC6"},
  6020. {"DMIC MUX11", "DMIC0", "DMIC0"},
  6021. {"DMIC MUX11", "DMIC1", "DMIC1"},
  6022. {"DMIC MUX11", "DMIC2", "DMIC2"},
  6023. {"DMIC MUX11", "DMIC3", "DMIC3"},
  6024. {"DMIC MUX11", "DMIC4", "DMIC4"},
  6025. {"DMIC MUX11", "DMIC5", "DMIC5"},
  6026. {"AMIC MUX11", "ADC1", "ADC1"},
  6027. {"AMIC MUX11", "ADC2", "ADC2"},
  6028. {"AMIC MUX11", "ADC3", "ADC3"},
  6029. {"AMIC MUX11", "ADC4", "ADC4"},
  6030. {"AMIC MUX11", "ADC5", "ADC5"},
  6031. {"AMIC MUX11", "ADC6", "ADC6"},
  6032. {"DMIC MUX12", "DMIC0", "DMIC0"},
  6033. {"DMIC MUX12", "DMIC1", "DMIC1"},
  6034. {"DMIC MUX12", "DMIC2", "DMIC2"},
  6035. {"DMIC MUX12", "DMIC3", "DMIC3"},
  6036. {"DMIC MUX12", "DMIC4", "DMIC4"},
  6037. {"DMIC MUX12", "DMIC5", "DMIC5"},
  6038. {"AMIC MUX12", "ADC1", "ADC1"},
  6039. {"AMIC MUX12", "ADC2", "ADC2"},
  6040. {"AMIC MUX12", "ADC3", "ADC3"},
  6041. {"AMIC MUX12", "ADC4", "ADC4"},
  6042. {"AMIC MUX12", "ADC5", "ADC5"},
  6043. {"AMIC MUX12", "ADC6", "ADC6"},
  6044. {"DMIC MUX13", "DMIC0", "DMIC0"},
  6045. {"DMIC MUX13", "DMIC1", "DMIC1"},
  6046. {"DMIC MUX13", "DMIC2", "DMIC2"},
  6047. {"DMIC MUX13", "DMIC3", "DMIC3"},
  6048. {"DMIC MUX13", "DMIC4", "DMIC4"},
  6049. {"DMIC MUX13", "DMIC5", "DMIC5"},
  6050. {"AMIC MUX13", "ADC1", "ADC1"},
  6051. {"AMIC MUX13", "ADC2", "ADC2"},
  6052. {"AMIC MUX13", "ADC3", "ADC3"},
  6053. {"AMIC MUX13", "ADC4", "ADC4"},
  6054. {"AMIC MUX13", "ADC5", "ADC5"},
  6055. {"AMIC MUX13", "ADC6", "ADC6"},
  6056. /* ADC Connections */
  6057. {"ADC1", NULL, "AMIC1"},
  6058. {"ADC2", NULL, "AMIC2"},
  6059. {"ADC3", NULL, "AMIC3"},
  6060. {"ADC4", NULL, "AMIC4"},
  6061. {"ADC5", NULL, "AMIC5"},
  6062. {"ADC6", NULL, "AMIC6"},
  6063. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP0"},
  6064. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP1"},
  6065. {"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP2"},
  6066. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP0"},
  6067. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP1"},
  6068. {"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP2"},
  6069. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP0"},
  6070. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP1"},
  6071. {"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP2"},
  6072. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP0"},
  6073. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP1"},
  6074. {"RX INT3_1 MIX1", NULL, "RX INT3_1 MIX1 INP2"},
  6075. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP0"},
  6076. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP1"},
  6077. {"RX INT4_1 MIX1", NULL, "RX INT4_1 MIX1 INP2"},
  6078. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP0"},
  6079. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP1"},
  6080. {"RX INT5_1 MIX1", NULL, "RX INT5_1 MIX1 INP2"},
  6081. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP0"},
  6082. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP1"},
  6083. {"RX INT6_1 MIX1", NULL, "RX INT6_1 MIX1 INP2"},
  6084. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP0"},
  6085. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP1"},
  6086. {"RX INT7_1 MIX1", NULL, "RX INT7_1 MIX1 INP2"},
  6087. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP0"},
  6088. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP1"},
  6089. {"RX INT8_1 MIX1", NULL, "RX INT8_1 MIX1 INP2"},
  6090. {"RX INT0 SEC MIX", NULL, "RX INT0_1 MIX1"},
  6091. {"RX INT0 MIX2", NULL, "RX INT0 SEC MIX"},
  6092. {"RX INT0 MIX2", NULL, "RX INT0 MIX2 INP"},
  6093. {"RX INT0 INTERP", NULL, "RX INT0 MIX2"},
  6094. {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 INTERP"},
  6095. {"RX INT0 DAC", NULL, "RX INT0 DEM MUX"},
  6096. {"RX INT0 DAC", NULL, "RX_BIAS"},
  6097. {"EAR PA", NULL, "RX INT0 DAC"},
  6098. {"EAR", NULL, "EAR PA"},
  6099. {"SPL SRC0 MUX", "SRC_IN_HPHL", "RX INT1_1 MIX1"},
  6100. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 MIX1"},
  6101. {"RX INT1 SPLINE MIX", "HPHL Switch", "SPL SRC0 MUX"},
  6102. {"RX INT1_1 NATIVE MUX", "ON", "RX INT1_1 MIX1"},
  6103. {"RX INT1 SPLINE MIX", NULL, "RX INT1_1 NATIVE MUX"},
  6104. {"RX INT1_1 NATIVE MUX", NULL, "RX INT1 NATIVE SUPPLY"},
  6105. {"RX INT1 SEC MIX", NULL, "RX INT1 SPLINE MIX"},
  6106. {"RX INT1 MIX2", NULL, "RX INT1 SEC MIX"},
  6107. {"RX INT1 MIX2", NULL, "RX INT1 MIX2 INP"},
  6108. {"RX INT1 INTERP", NULL, "RX INT1 MIX2"},
  6109. {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 INTERP"},
  6110. {"RX INT1 DAC", NULL, "RX INT1 DEM MUX"},
  6111. {"RX INT1 DAC", NULL, "RX_BIAS"},
  6112. {"HPHL PA", NULL, "RX INT1 DAC"},
  6113. {"HPHL", NULL, "HPHL PA"},
  6114. {"SPL SRC1 MUX", "SRC_IN_HPHR", "RX INT2_1 MIX1"},
  6115. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 MIX1"},
  6116. {"RX INT2 SPLINE MIX", "HPHR Switch", "SPL SRC1 MUX"},
  6117. {"RX INT2_1 NATIVE MUX", "ON", "RX INT2_1 MIX1"},
  6118. {"RX INT2 SPLINE MIX", NULL, "RX INT2_1 NATIVE MUX"},
  6119. {"RX INT2_1 NATIVE MUX", NULL, "RX INT2 NATIVE SUPPLY"},
  6120. {"RX INT2 SEC MIX", NULL, "RX INT2 SPLINE MIX"},
  6121. {"RX INT2 MIX2", NULL, "RX INT2 SEC MIX"},
  6122. {"RX INT2 MIX2", NULL, "RX INT2 MIX2 INP"},
  6123. {"RX INT2 INTERP", NULL, "RX INT2 MIX2"},
  6124. {"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 INTERP"},
  6125. {"RX INT2 DAC", NULL, "RX INT2 DEM MUX"},
  6126. {"RX INT2 DAC", NULL, "RX_BIAS"},
  6127. {"HPHR PA", NULL, "RX INT2 DAC"},
  6128. {"HPHR", NULL, "HPHR PA"},
  6129. {"SPL SRC0 MUX", "SRC_IN_LO1", "RX INT3_1 MIX1"},
  6130. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 MIX1"},
  6131. {"RX INT3 SPLINE MIX", "LO1 Switch", "SPL SRC0 MUX"},
  6132. {"RX INT3_1 NATIVE MUX", "ON", "RX INT3_1 MIX1"},
  6133. {"RX INT3 SPLINE MIX", NULL, "RX INT3_1 NATIVE MUX"},
  6134. {"RX INT3_1 NATIVE MUX", NULL, "RX INT3 NATIVE SUPPLY"},
  6135. {"RX INT3 SEC MIX", NULL, "RX INT3 SPLINE MIX"},
  6136. {"RX INT3 MIX2", NULL, "RX INT3 SEC MIX"},
  6137. {"RX INT3 MIX2", NULL, "RX INT3 MIX2 INP"},
  6138. {"RX INT3 INTERP", NULL, "RX INT3 MIX2"},
  6139. {"RX INT3 DAC", NULL, "RX INT3 INTERP"},
  6140. {"RX INT3 DAC", NULL, "RX_BIAS"},
  6141. {"LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6142. {"LINEOUT1", NULL, "LINEOUT1 PA"},
  6143. {"SPL SRC1 MUX", "SRC_IN_LO2", "RX INT4_1 MIX1"},
  6144. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 MIX1"},
  6145. {"RX INT4 SPLINE MIX", "LO2 Switch", "SPL SRC1 MUX"},
  6146. {"RX INT4_1 NATIVE MUX", "ON", "RX INT4_1 MIX1"},
  6147. {"RX INT4 SPLINE MIX", NULL, "RX INT4_1 NATIVE MUX"},
  6148. {"RX INT4_1 NATIVE MUX", NULL, "RX INT4 NATIVE SUPPLY"},
  6149. {"RX INT4 SEC MIX", NULL, "RX INT4 SPLINE MIX"},
  6150. {"RX INT4 MIX2", NULL, "RX INT4 SEC MIX"},
  6151. {"RX INT4 MIX2", NULL, "RX INT4 MIX2 INP"},
  6152. {"RX INT4 INTERP", NULL, "RX INT4 MIX2"},
  6153. {"RX INT4 DAC", NULL, "RX INT4 INTERP"},
  6154. {"RX INT4 DAC", NULL, "RX_BIAS"},
  6155. {"LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6156. {"LINEOUT2", NULL, "LINEOUT2 PA"},
  6157. {"SPL SRC2 MUX", "SRC_IN_LO3", "RX INT5_1 MIX1"},
  6158. {"RX INT5 SPLINE MIX", NULL, "RX INT5_1 MIX1"},
  6159. {"RX INT5 SPLINE MIX", "LO3 Switch", "SPL SRC2 MUX"},
  6160. {"RX INT5 SEC MIX", NULL, "RX INT5 SPLINE MIX"},
  6161. {"RX INT5 MIX2", NULL, "RX INT5 SEC MIX"},
  6162. {"RX INT5 INTERP", NULL, "RX INT5 MIX2"},
  6163. {"RX INT5 VBAT", "LO3 VBAT Enable", "RX INT5 INTERP"},
  6164. {"RX INT5 DAC", NULL, "RX INT5 VBAT"},
  6165. {"RX INT5 DAC", NULL, "RX INT5 INTERP"},
  6166. {"RX INT5 DAC", NULL, "RX_BIAS"},
  6167. {"LINEOUT3 PA", NULL, "RX INT5 DAC"},
  6168. {"LINEOUT3", NULL, "LINEOUT3 PA"},
  6169. {"SPL SRC3 MUX", "SRC_IN_LO4", "RX INT6_1 MIX1"},
  6170. {"RX INT6 SPLINE MIX", NULL, "RX INT6_1 MIX1"},
  6171. {"RX INT6 SPLINE MIX", "LO4 Switch", "SPL SRC3 MUX"},
  6172. {"RX INT6 SEC MIX", NULL, "RX INT6 SPLINE MIX"},
  6173. {"RX INT6 MIX2", NULL, "RX INT6 SEC MIX"},
  6174. {"RX INT6 INTERP", NULL, "RX INT6 MIX2"},
  6175. {"RX INT6 VBAT", "LO4 VBAT Enable", "RX INT6 INTERP"},
  6176. {"RX INT6 DAC", NULL, "RX INT6 VBAT"},
  6177. {"RX INT6 DAC", NULL, "RX INT6 INTERP"},
  6178. {"RX INT6 DAC", NULL, "RX_BIAS"},
  6179. {"LINEOUT4 PA", NULL, "RX INT6 DAC"},
  6180. {"LINEOUT4", NULL, "LINEOUT4 PA"},
  6181. {"SPL SRC2 MUX", "SRC_IN_SPKRL", "RX INT7_1 MIX1"},
  6182. {"RX INT7 SPLINE MIX", NULL, "RX INT7_1 MIX1"},
  6183. {"RX INT7 SPLINE MIX", "SPKRL Switch", "SPL SRC2 MUX"},
  6184. {"RX INT7 SEC MIX", NULL, "RX INT7 SPLINE MIX"},
  6185. {"RX INT7 MIX2", NULL, "RX INT7 SEC MIX"},
  6186. {"RX INT7 MIX2", NULL, "RX INT7 MIX2 INP"},
  6187. {"RX INT7 INTERP", NULL, "RX INT7 MIX2"},
  6188. {"RX INT7 VBAT", "SPKRL VBAT Enable", "RX INT7 INTERP"},
  6189. {"RX INT7 CHAIN", NULL, "RX INT7 VBAT"},
  6190. {"RX INT7 CHAIN", NULL, "RX INT7 INTERP"},
  6191. {"RX INT7 CHAIN", NULL, "RX_BIAS"},
  6192. {"SPK1 OUT", NULL, "RX INT7 CHAIN"},
  6193. {"ANC SPKR PA Enable", "Switch", "RX INT7 CHAIN"},
  6194. {"ANC SPK1 PA", NULL, "ANC SPKR PA Enable"},
  6195. {"SPK1 OUT", NULL, "ANC SPK1 PA"},
  6196. {"SPL SRC3 MUX", "SRC_IN_SPKRR", "RX INT8_1 MIX1"},
  6197. {"RX INT8 SPLINE MIX", NULL, "RX INT8_1 MIX1"},
  6198. {"RX INT8 SPLINE MIX", "SPKRR Switch", "SPL SRC3 MUX"},
  6199. {"RX INT8 SEC MIX", NULL, "RX INT8 SPLINE MIX"},
  6200. {"RX INT8 INTERP", NULL, "RX INT8 SEC MIX"},
  6201. {"RX INT8 VBAT", "SPKRR VBAT Enable", "RX INT8 INTERP"},
  6202. {"RX INT8 CHAIN", NULL, "RX INT8 VBAT"},
  6203. {"RX INT8 CHAIN", NULL, "RX INT8 INTERP"},
  6204. {"RX INT8 CHAIN", NULL, "RX_BIAS"},
  6205. {"SPK2 OUT", NULL, "RX INT8 CHAIN"},
  6206. {"ANC0 FB MUX", "ANC_IN_EAR", "RX INT0 MIX2"},
  6207. {"ANC0 FB MUX", "ANC_IN_HPHL", "RX INT1 MIX2"},
  6208. {"ANC0 FB MUX", "ANC_IN_LO1", "RX INT3 MIX2"},
  6209. {"ANC0 FB MUX", "ANC_IN_EAR_SPKR", "RX INT7 MIX2"},
  6210. {"ANC1 FB MUX", "ANC_IN_HPHR", "RX INT2 MIX2"},
  6211. {"ANC1 FB MUX", "ANC_IN_LO2", "RX INT4 MIX2"},
  6212. {"ANC HPHL Enable", "Switch", "ADC MUX10"},
  6213. {"ANC HPHL Enable", "Switch", "ADC MUX11"},
  6214. {"RX INT1 MIX2", NULL, "ANC HPHL Enable"},
  6215. {"ANC HPHR Enable", "Switch", "ADC MUX12"},
  6216. {"ANC HPHR Enable", "Switch", "ADC MUX13"},
  6217. {"RX INT2 MIX2", NULL, "ANC HPHR Enable"},
  6218. {"ANC EAR Enable", "Switch", "ADC MUX10"},
  6219. {"ANC EAR Enable", "Switch", "ADC MUX11"},
  6220. {"RX INT0 MIX2", NULL, "ANC EAR Enable"},
  6221. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX10"},
  6222. {"ANC OUT EAR SPKR Enable", "Switch", "ADC MUX11"},
  6223. {"RX INT7 MIX2", NULL, "ANC OUT EAR SPKR Enable"},
  6224. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX10"},
  6225. {"ANC LINEOUT1 Enable", "Switch", "ADC MUX11"},
  6226. {"RX INT3 MIX2", NULL, "ANC LINEOUT1 Enable"},
  6227. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX12"},
  6228. {"ANC LINEOUT2 Enable", "Switch", "ADC MUX13"},
  6229. {"RX INT4 MIX2", NULL, "ANC LINEOUT2 Enable"},
  6230. {"ANC EAR PA", NULL, "RX INT0 DAC"},
  6231. {"ANC EAR", NULL, "ANC EAR PA"},
  6232. {"ANC HPHL PA", NULL, "RX INT1 DAC"},
  6233. {"ANC HPHL", NULL, "ANC HPHL PA"},
  6234. {"ANC HPHR PA", NULL, "RX INT2 DAC"},
  6235. {"ANC HPHR", NULL, "ANC HPHR PA"},
  6236. {"ANC LINEOUT1 PA", NULL, "RX INT3 DAC"},
  6237. {"ANC LINEOUT1", NULL, "ANC LINEOUT1 PA"},
  6238. {"ANC LINEOUT2 PA", NULL, "RX INT4 DAC"},
  6239. {"ANC LINEOUT2", NULL, "ANC LINEOUT2 PA"},
  6240. /* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/
  6241. {"SLIM RX0 MUX", "AIF1_PB", "AIF1 PB"},
  6242. {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
  6243. {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
  6244. {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
  6245. {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
  6246. {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
  6247. {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
  6248. {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
  6249. /* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/
  6250. {"SLIM RX0 MUX", "AIF2_PB", "AIF2 PB"},
  6251. {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
  6252. {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
  6253. {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
  6254. {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
  6255. {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
  6256. {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
  6257. {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
  6258. /* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/
  6259. {"SLIM RX0 MUX", "AIF3_PB", "AIF3 PB"},
  6260. {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
  6261. {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
  6262. {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
  6263. {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
  6264. {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
  6265. {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
  6266. {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
  6267. /* SLIM_MUX("AIF4_PB", "AIF4 PB"),*/
  6268. {"SLIM RX0 MUX", "AIF4_PB", "AIF4 PB"},
  6269. {"SLIM RX1 MUX", "AIF4_PB", "AIF4 PB"},
  6270. {"SLIM RX2 MUX", "AIF4_PB", "AIF4 PB"},
  6271. {"SLIM RX3 MUX", "AIF4_PB", "AIF4 PB"},
  6272. {"SLIM RX4 MUX", "AIF4_PB", "AIF4 PB"},
  6273. {"SLIM RX5 MUX", "AIF4_PB", "AIF4 PB"},
  6274. {"SLIM RX6 MUX", "AIF4_PB", "AIF4 PB"},
  6275. {"SLIM RX7 MUX", "AIF4_PB", "AIF4 PB"},
  6276. /* SLIM_MUX("AIF_MIX1_PB", "AIF MIX1 PB"),*/
  6277. {"SLIM RX0 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6278. {"SLIM RX1 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6279. {"SLIM RX2 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6280. {"SLIM RX3 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6281. {"SLIM RX4 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6282. {"SLIM RX5 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6283. {"SLIM RX6 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6284. {"SLIM RX7 MUX", "AIF_MIX1_PB", "AIF MIX1 PB"},
  6285. {"SLIM RX0", NULL, "SLIM RX0 MUX"},
  6286. {"SLIM RX1", NULL, "SLIM RX1 MUX"},
  6287. {"SLIM RX2", NULL, "SLIM RX2 MUX"},
  6288. {"SLIM RX3", NULL, "SLIM RX3 MUX"},
  6289. {"SLIM RX4", NULL, "SLIM RX4 MUX"},
  6290. {"SLIM RX5", NULL, "SLIM RX5 MUX"},
  6291. {"SLIM RX6", NULL, "SLIM RX6 MUX"},
  6292. {"SLIM RX7", NULL, "SLIM RX7 MUX"},
  6293. {"RX INT0_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6294. {"RX INT0_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6295. {"RX INT0_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6296. {"RX INT0_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6297. {"RX INT0_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6298. {"RX INT0_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6299. {"RX INT0_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6300. {"RX INT0_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6301. {"RX INT0_1 MIX1 INP0", "IIR0", "IIR0"},
  6302. {"RX INT0_1 MIX1 INP0", "IIR1", "IIR1"},
  6303. {"RX INT0_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6304. {"RX INT0_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6305. {"RX INT0_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6306. {"RX INT0_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6307. {"RX INT0_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6308. {"RX INT0_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6309. {"RX INT0_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6310. {"RX INT0_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6311. {"RX INT0_1 MIX1 INP1", "IIR0", "IIR0"},
  6312. {"RX INT0_1 MIX1 INP1", "IIR1", "IIR1"},
  6313. {"RX INT0_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6314. {"RX INT0_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6315. {"RX INT0_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6316. {"RX INT0_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6317. {"RX INT0_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6318. {"RX INT0_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6319. {"RX INT0_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6320. {"RX INT0_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6321. {"RX INT0_1 MIX1 INP2", "IIR0", "IIR0"},
  6322. {"RX INT0_1 MIX1 INP2", "IIR1", "IIR1"},
  6323. /* MIXing path INT0 */
  6324. {"RX INT0_2 MUX", "RX0", "SLIM RX0"},
  6325. {"RX INT0_2 MUX", "RX1", "SLIM RX1"},
  6326. {"RX INT0_2 MUX", "RX2", "SLIM RX2"},
  6327. {"RX INT0_2 MUX", "RX3", "SLIM RX3"},
  6328. {"RX INT0_2 MUX", "RX4", "SLIM RX4"},
  6329. {"RX INT0_2 MUX", "RX5", "SLIM RX5"},
  6330. {"RX INT0_2 MUX", "RX6", "SLIM RX6"},
  6331. {"RX INT0_2 MUX", "RX7", "SLIM RX7"},
  6332. {"RX INT0 SEC MIX", NULL, "RX INT0_2 MUX"},
  6333. /* MIXing path INT1 */
  6334. {"RX INT1_2 MUX", "RX0", "SLIM RX0"},
  6335. {"RX INT1_2 MUX", "RX1", "SLIM RX1"},
  6336. {"RX INT1_2 MUX", "RX2", "SLIM RX2"},
  6337. {"RX INT1_2 MUX", "RX3", "SLIM RX3"},
  6338. {"RX INT1_2 MUX", "RX4", "SLIM RX4"},
  6339. {"RX INT1_2 MUX", "RX5", "SLIM RX5"},
  6340. {"RX INT1_2 MUX", "RX6", "SLIM RX6"},
  6341. {"RX INT1_2 MUX", "RX7", "SLIM RX7"},
  6342. {"RX INT1 SEC MIX", NULL, "RX INT1_2 MUX"},
  6343. /* MIXing path INT2 */
  6344. {"RX INT2_2 MUX", "RX0", "SLIM RX0"},
  6345. {"RX INT2_2 MUX", "RX1", "SLIM RX1"},
  6346. {"RX INT2_2 MUX", "RX2", "SLIM RX2"},
  6347. {"RX INT2_2 MUX", "RX3", "SLIM RX3"},
  6348. {"RX INT2_2 MUX", "RX4", "SLIM RX4"},
  6349. {"RX INT2_2 MUX", "RX5", "SLIM RX5"},
  6350. {"RX INT2_2 MUX", "RX6", "SLIM RX6"},
  6351. {"RX INT2_2 MUX", "RX7", "SLIM RX7"},
  6352. {"RX INT2 SEC MIX", NULL, "RX INT2_2 MUX"},
  6353. /* MIXing path INT3 */
  6354. {"RX INT3_2 MUX", "RX0", "SLIM RX0"},
  6355. {"RX INT3_2 MUX", "RX1", "SLIM RX1"},
  6356. {"RX INT3_2 MUX", "RX2", "SLIM RX2"},
  6357. {"RX INT3_2 MUX", "RX3", "SLIM RX3"},
  6358. {"RX INT3_2 MUX", "RX4", "SLIM RX4"},
  6359. {"RX INT3_2 MUX", "RX5", "SLIM RX5"},
  6360. {"RX INT3_2 MUX", "RX6", "SLIM RX6"},
  6361. {"RX INT3_2 MUX", "RX7", "SLIM RX7"},
  6362. {"RX INT3 SEC MIX", NULL, "RX INT3_2 MUX"},
  6363. /* MIXing path INT4 */
  6364. {"RX INT4_2 MUX", "RX0", "SLIM RX0"},
  6365. {"RX INT4_2 MUX", "RX1", "SLIM RX1"},
  6366. {"RX INT4_2 MUX", "RX2", "SLIM RX2"},
  6367. {"RX INT4_2 MUX", "RX3", "SLIM RX3"},
  6368. {"RX INT4_2 MUX", "RX4", "SLIM RX4"},
  6369. {"RX INT4_2 MUX", "RX5", "SLIM RX5"},
  6370. {"RX INT4_2 MUX", "RX6", "SLIM RX6"},
  6371. {"RX INT4_2 MUX", "RX7", "SLIM RX7"},
  6372. {"RX INT4 SEC MIX", NULL, "RX INT4_2 MUX"},
  6373. /* MIXing path INT5 */
  6374. {"RX INT5_2 MUX", "RX0", "SLIM RX0"},
  6375. {"RX INT5_2 MUX", "RX1", "SLIM RX1"},
  6376. {"RX INT5_2 MUX", "RX2", "SLIM RX2"},
  6377. {"RX INT5_2 MUX", "RX3", "SLIM RX3"},
  6378. {"RX INT5_2 MUX", "RX4", "SLIM RX4"},
  6379. {"RX INT5_2 MUX", "RX5", "SLIM RX5"},
  6380. {"RX INT5_2 MUX", "RX6", "SLIM RX6"},
  6381. {"RX INT5_2 MUX", "RX7", "SLIM RX7"},
  6382. {"RX INT5 SEC MIX", NULL, "RX INT5_2 MUX"},
  6383. /* MIXing path INT6 */
  6384. {"RX INT6_2 MUX", "RX0", "SLIM RX0"},
  6385. {"RX INT6_2 MUX", "RX1", "SLIM RX1"},
  6386. {"RX INT6_2 MUX", "RX2", "SLIM RX2"},
  6387. {"RX INT6_2 MUX", "RX3", "SLIM RX3"},
  6388. {"RX INT6_2 MUX", "RX4", "SLIM RX4"},
  6389. {"RX INT6_2 MUX", "RX5", "SLIM RX5"},
  6390. {"RX INT6_2 MUX", "RX6", "SLIM RX6"},
  6391. {"RX INT6_2 MUX", "RX7", "SLIM RX7"},
  6392. {"RX INT6 SEC MIX", NULL, "RX INT6_2 MUX"},
  6393. /* MIXing path INT7 */
  6394. {"RX INT7_2 MUX", "RX0", "SLIM RX0"},
  6395. {"RX INT7_2 MUX", "RX1", "SLIM RX1"},
  6396. {"RX INT7_2 MUX", "RX2", "SLIM RX2"},
  6397. {"RX INT7_2 MUX", "RX3", "SLIM RX3"},
  6398. {"RX INT7_2 MUX", "RX4", "SLIM RX4"},
  6399. {"RX INT7_2 MUX", "RX5", "SLIM RX5"},
  6400. {"RX INT7_2 MUX", "RX6", "SLIM RX6"},
  6401. {"RX INT7_2 MUX", "RX7", "SLIM RX7"},
  6402. {"RX INT7 SEC MIX", NULL, "RX INT7_2 MUX"},
  6403. /* MIXing path INT8 */
  6404. {"RX INT8_2 MUX", "RX0", "SLIM RX0"},
  6405. {"RX INT8_2 MUX", "RX1", "SLIM RX1"},
  6406. {"RX INT8_2 MUX", "RX2", "SLIM RX2"},
  6407. {"RX INT8_2 MUX", "RX3", "SLIM RX3"},
  6408. {"RX INT8_2 MUX", "RX4", "SLIM RX4"},
  6409. {"RX INT8_2 MUX", "RX5", "SLIM RX5"},
  6410. {"RX INT8_2 MUX", "RX6", "SLIM RX6"},
  6411. {"RX INT8_2 MUX", "RX7", "SLIM RX7"},
  6412. {"RX INT8 SEC MIX", NULL, "RX INT8_2 MUX"},
  6413. {"RX INT1_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6414. {"RX INT1_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6415. {"RX INT1_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6416. {"RX INT1_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6417. {"RX INT1_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6418. {"RX INT1_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6419. {"RX INT1_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6420. {"RX INT1_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6421. {"RX INT1_1 MIX1 INP0", "IIR0", "IIR0"},
  6422. {"RX INT1_1 MIX1 INP0", "IIR1", "IIR1"},
  6423. {"RX INT1_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6424. {"RX INT1_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6425. {"RX INT1_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6426. {"RX INT1_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6427. {"RX INT1_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6428. {"RX INT1_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6429. {"RX INT1_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6430. {"RX INT1_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6431. {"RX INT1_1 MIX1 INP1", "IIR0", "IIR0"},
  6432. {"RX INT1_1 MIX1 INP1", "IIR1", "IIR1"},
  6433. {"RX INT1_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6434. {"RX INT1_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6435. {"RX INT1_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6436. {"RX INT1_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6437. {"RX INT1_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6438. {"RX INT1_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6439. {"RX INT1_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6440. {"RX INT1_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6441. {"RX INT1_1 MIX1 INP2", "IIR0", "IIR0"},
  6442. {"RX INT1_1 MIX1 INP2", "IIR1", "IIR1"},
  6443. {"RX INT2_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6444. {"RX INT2_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6445. {"RX INT2_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6446. {"RX INT2_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6447. {"RX INT2_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6448. {"RX INT2_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6449. {"RX INT2_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6450. {"RX INT2_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6451. {"RX INT2_1 MIX1 INP0", "IIR0", "IIR0"},
  6452. {"RX INT2_1 MIX1 INP0", "IIR1", "IIR1"},
  6453. {"RX INT2_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6454. {"RX INT2_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6455. {"RX INT2_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6456. {"RX INT2_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6457. {"RX INT2_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6458. {"RX INT2_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6459. {"RX INT2_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6460. {"RX INT2_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6461. {"RX INT2_1 MIX1 INP1", "IIR0", "IIR0"},
  6462. {"RX INT2_1 MIX1 INP1", "IIR1", "IIR1"},
  6463. {"RX INT2_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6464. {"RX INT2_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6465. {"RX INT2_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6466. {"RX INT2_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6467. {"RX INT2_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6468. {"RX INT2_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6469. {"RX INT2_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6470. {"RX INT2_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6471. {"RX INT2_1 MIX1 INP2", "IIR0", "IIR0"},
  6472. {"RX INT2_1 MIX1 INP2", "IIR1", "IIR1"},
  6473. {"RX INT3_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6474. {"RX INT3_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6475. {"RX INT3_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6476. {"RX INT3_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6477. {"RX INT3_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6478. {"RX INT3_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6479. {"RX INT3_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6480. {"RX INT3_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6481. {"RX INT3_1 MIX1 INP0", "IIR0", "IIR0"},
  6482. {"RX INT3_1 MIX1 INP0", "IIR1", "IIR1"},
  6483. {"RX INT3_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6484. {"RX INT3_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6485. {"RX INT3_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6486. {"RX INT3_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6487. {"RX INT3_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6488. {"RX INT3_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6489. {"RX INT3_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6490. {"RX INT3_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6491. {"RX INT3_1 MIX1 INP1", "IIR0", "IIR0"},
  6492. {"RX INT3_1 MIX1 INP1", "IIR1", "IIR1"},
  6493. {"RX INT3_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6494. {"RX INT3_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6495. {"RX INT3_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6496. {"RX INT3_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6497. {"RX INT3_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6498. {"RX INT3_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6499. {"RX INT3_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6500. {"RX INT3_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6501. {"RX INT3_1 MIX1 INP2", "IIR0", "IIR0"},
  6502. {"RX INT3_1 MIX1 INP2", "IIR1", "IIR1"},
  6503. {"RX INT4_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6504. {"RX INT4_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6505. {"RX INT4_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6506. {"RX INT4_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6507. {"RX INT4_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6508. {"RX INT4_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6509. {"RX INT4_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6510. {"RX INT4_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6511. {"RX INT4_1 MIX1 INP0", "IIR0", "IIR0"},
  6512. {"RX INT4_1 MIX1 INP0", "IIR1", "IIR1"},
  6513. {"RX INT4_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6514. {"RX INT4_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6515. {"RX INT4_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6516. {"RX INT4_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6517. {"RX INT4_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6518. {"RX INT4_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6519. {"RX INT4_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6520. {"RX INT4_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6521. {"RX INT4_1 MIX1 INP1", "IIR0", "IIR0"},
  6522. {"RX INT4_1 MIX1 INP1", "IIR1", "IIR1"},
  6523. {"RX INT4_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6524. {"RX INT4_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6525. {"RX INT4_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6526. {"RX INT4_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6527. {"RX INT4_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6528. {"RX INT4_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6529. {"RX INT4_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6530. {"RX INT4_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6531. {"RX INT4_1 MIX1 INP2", "IIR0", "IIR0"},
  6532. {"RX INT4_1 MIX1 INP2", "IIR1", "IIR1"},
  6533. {"RX INT5_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6534. {"RX INT5_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6535. {"RX INT5_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6536. {"RX INT5_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6537. {"RX INT5_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6538. {"RX INT5_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6539. {"RX INT5_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6540. {"RX INT5_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6541. {"RX INT5_1 MIX1 INP0", "IIR0", "IIR0"},
  6542. {"RX INT5_1 MIX1 INP0", "IIR1", "IIR1"},
  6543. {"RX INT5_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6544. {"RX INT5_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6545. {"RX INT5_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6546. {"RX INT5_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6547. {"RX INT5_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6548. {"RX INT5_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6549. {"RX INT5_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6550. {"RX INT5_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6551. {"RX INT5_1 MIX1 INP1", "IIR0", "IIR0"},
  6552. {"RX INT5_1 MIX1 INP1", "IIR1", "IIR1"},
  6553. {"RX INT5_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6554. {"RX INT5_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6555. {"RX INT5_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6556. {"RX INT5_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6557. {"RX INT5_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6558. {"RX INT5_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6559. {"RX INT5_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6560. {"RX INT5_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6561. {"RX INT5_1 MIX1 INP2", "IIR0", "IIR0"},
  6562. {"RX INT5_1 MIX1 INP2", "IIR1", "IIR1"},
  6563. {"RX INT6_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6564. {"RX INT6_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6565. {"RX INT6_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6566. {"RX INT6_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6567. {"RX INT6_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6568. {"RX INT6_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6569. {"RX INT6_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6570. {"RX INT6_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6571. {"RX INT6_1 MIX1 INP0", "IIR0", "IIR0"},
  6572. {"RX INT6_1 MIX1 INP0", "IIR1", "IIR1"},
  6573. {"RX INT6_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6574. {"RX INT6_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6575. {"RX INT6_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6576. {"RX INT6_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6577. {"RX INT6_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6578. {"RX INT6_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6579. {"RX INT6_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6580. {"RX INT6_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6581. {"RX INT6_1 MIX1 INP1", "IIR0", "IIR0"},
  6582. {"RX INT6_1 MIX1 INP1", "IIR1", "IIR1"},
  6583. {"RX INT6_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6584. {"RX INT6_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6585. {"RX INT6_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6586. {"RX INT6_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6587. {"RX INT6_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6588. {"RX INT6_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6589. {"RX INT6_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6590. {"RX INT6_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6591. {"RX INT6_1 MIX1 INP2", "IIR0", "IIR0"},
  6592. {"RX INT6_1 MIX1 INP2", "IIR1", "IIR1"},
  6593. {"RX INT7_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6594. {"RX INT7_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6595. {"RX INT7_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6596. {"RX INT7_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6597. {"RX INT7_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6598. {"RX INT7_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6599. {"RX INT7_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6600. {"RX INT7_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6601. {"RX INT7_1 MIX1 INP0", "IIR0", "IIR0"},
  6602. {"RX INT7_1 MIX1 INP0", "IIR1", "IIR1"},
  6603. {"RX INT7_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6604. {"RX INT7_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6605. {"RX INT7_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6606. {"RX INT7_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6607. {"RX INT7_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6608. {"RX INT7_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6609. {"RX INT7_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6610. {"RX INT7_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6611. {"RX INT7_1 MIX1 INP1", "IIR0", "IIR0"},
  6612. {"RX INT7_1 MIX1 INP1", "IIR1", "IIR1"},
  6613. {"RX INT7_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6614. {"RX INT7_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6615. {"RX INT7_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6616. {"RX INT7_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6617. {"RX INT7_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6618. {"RX INT7_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6619. {"RX INT7_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6620. {"RX INT7_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6621. {"RX INT7_1 MIX1 INP2", "IIR0", "IIR0"},
  6622. {"RX INT7_1 MIX1 INP2", "IIR1", "IIR1"},
  6623. {"RX INT8_1 MIX1 INP0", "RX0", "SLIM RX0"},
  6624. {"RX INT8_1 MIX1 INP0", "RX1", "SLIM RX1"},
  6625. {"RX INT8_1 MIX1 INP0", "RX2", "SLIM RX2"},
  6626. {"RX INT8_1 MIX1 INP0", "RX3", "SLIM RX3"},
  6627. {"RX INT8_1 MIX1 INP0", "RX4", "SLIM RX4"},
  6628. {"RX INT8_1 MIX1 INP0", "RX5", "SLIM RX5"},
  6629. {"RX INT8_1 MIX1 INP0", "RX6", "SLIM RX6"},
  6630. {"RX INT8_1 MIX1 INP0", "RX7", "SLIM RX7"},
  6631. {"RX INT8_1 MIX1 INP0", "IIR0", "IIR0"},
  6632. {"RX INT8_1 MIX1 INP0", "IIR1", "IIR1"},
  6633. {"RX INT8_1 MIX1 INP1", "RX0", "SLIM RX0"},
  6634. {"RX INT8_1 MIX1 INP1", "RX1", "SLIM RX1"},
  6635. {"RX INT8_1 MIX1 INP1", "RX2", "SLIM RX2"},
  6636. {"RX INT8_1 MIX1 INP1", "RX3", "SLIM RX3"},
  6637. {"RX INT8_1 MIX1 INP1", "RX4", "SLIM RX4"},
  6638. {"RX INT8_1 MIX1 INP1", "RX5", "SLIM RX5"},
  6639. {"RX INT8_1 MIX1 INP1", "RX6", "SLIM RX6"},
  6640. {"RX INT8_1 MIX1 INP1", "RX7", "SLIM RX7"},
  6641. {"RX INT8_1 MIX1 INP1", "IIR0", "IIR0"},
  6642. {"RX INT8_1 MIX1 INP1", "IIR1", "IIR1"},
  6643. {"RX INT8_1 MIX1 INP2", "RX0", "SLIM RX0"},
  6644. {"RX INT8_1 MIX1 INP2", "RX1", "SLIM RX1"},
  6645. {"RX INT8_1 MIX1 INP2", "RX2", "SLIM RX2"},
  6646. {"RX INT8_1 MIX1 INP2", "RX3", "SLIM RX3"},
  6647. {"RX INT8_1 MIX1 INP2", "RX4", "SLIM RX4"},
  6648. {"RX INT8_1 MIX1 INP2", "RX5", "SLIM RX5"},
  6649. {"RX INT8_1 MIX1 INP2", "RX6", "SLIM RX6"},
  6650. {"RX INT8_1 MIX1 INP2", "RX7", "SLIM RX7"},
  6651. {"RX INT8_1 MIX1 INP2", "IIR0", "IIR0"},
  6652. {"RX INT8_1 MIX1 INP2", "IIR1", "IIR1"},
  6653. /* SRC0, SRC1 inputs to Sidetone RX Mixer
  6654. * on RX0, RX1, RX2, RX3, RX4 and RX7 chains
  6655. */
  6656. {"IIR0", NULL, "IIR0 INP0 MUX"},
  6657. {"IIR0 INP0 MUX", "DEC0", "ADC MUX0"},
  6658. {"IIR0 INP0 MUX", "DEC1", "ADC MUX1"},
  6659. {"IIR0 INP0 MUX", "DEC2", "ADC MUX2"},
  6660. {"IIR0 INP0 MUX", "DEC3", "ADC MUX3"},
  6661. {"IIR0 INP0 MUX", "DEC4", "ADC MUX4"},
  6662. {"IIR0 INP0 MUX", "DEC5", "ADC MUX5"},
  6663. {"IIR0 INP0 MUX", "DEC6", "ADC MUX6"},
  6664. {"IIR0 INP0 MUX", "DEC7", "ADC MUX7"},
  6665. {"IIR0 INP0 MUX", "DEC8", "ADC MUX8"},
  6666. {"IIR0 INP0 MUX", "RX0", "SLIM RX0"},
  6667. {"IIR0 INP0 MUX", "RX1", "SLIM RX1"},
  6668. {"IIR0 INP0 MUX", "RX2", "SLIM RX2"},
  6669. {"IIR0 INP0 MUX", "RX3", "SLIM RX3"},
  6670. {"IIR0 INP0 MUX", "RX4", "SLIM RX4"},
  6671. {"IIR0 INP0 MUX", "RX5", "SLIM RX5"},
  6672. {"IIR0 INP0 MUX", "RX6", "SLIM RX6"},
  6673. {"IIR0 INP0 MUX", "RX7", "SLIM RX7"},
  6674. {"IIR0", NULL, "IIR0 INP1 MUX"},
  6675. {"IIR0 INP1 MUX", "DEC0", "ADC MUX0"},
  6676. {"IIR0 INP1 MUX", "DEC1", "ADC MUX1"},
  6677. {"IIR0 INP1 MUX", "DEC2", "ADC MUX2"},
  6678. {"IIR0 INP1 MUX", "DEC3", "ADC MUX3"},
  6679. {"IIR0 INP1 MUX", "DEC4", "ADC MUX4"},
  6680. {"IIR0 INP1 MUX", "DEC5", "ADC MUX5"},
  6681. {"IIR0 INP1 MUX", "DEC6", "ADC MUX6"},
  6682. {"IIR0 INP1 MUX", "DEC7", "ADC MUX7"},
  6683. {"IIR0 INP1 MUX", "DEC8", "ADC MUX8"},
  6684. {"IIR0 INP1 MUX", "RX0", "SLIM RX0"},
  6685. {"IIR0 INP1 MUX", "RX1", "SLIM RX1"},
  6686. {"IIR0 INP1 MUX", "RX2", "SLIM RX2"},
  6687. {"IIR0 INP1 MUX", "RX3", "SLIM RX3"},
  6688. {"IIR0 INP1 MUX", "RX4", "SLIM RX4"},
  6689. {"IIR0 INP1 MUX", "RX5", "SLIM RX5"},
  6690. {"IIR0 INP1 MUX", "RX6", "SLIM RX6"},
  6691. {"IIR0 INP1 MUX", "RX7", "SLIM RX7"},
  6692. {"IIR0", NULL, "IIR0 INP2 MUX"},
  6693. {"IIR0 INP2 MUX", "DEC0", "ADC MUX0"},
  6694. {"IIR0 INP2 MUX", "DEC1", "ADC MUX1"},
  6695. {"IIR0 INP2 MUX", "DEC2", "ADC MUX2"},
  6696. {"IIR0 INP2 MUX", "DEC3", "ADC MUX3"},
  6697. {"IIR0 INP2 MUX", "DEC4", "ADC MUX4"},
  6698. {"IIR0 INP2 MUX", "DEC5", "ADC MUX5"},
  6699. {"IIR0 INP2 MUX", "DEC6", "ADC MUX6"},
  6700. {"IIR0 INP2 MUX", "DEC7", "ADC MUX7"},
  6701. {"IIR0 INP2 MUX", "DEC8", "ADC MUX8"},
  6702. {"IIR0 INP2 MUX", "RX0", "SLIM RX0"},
  6703. {"IIR0 INP2 MUX", "RX1", "SLIM RX1"},
  6704. {"IIR0 INP2 MUX", "RX2", "SLIM RX2"},
  6705. {"IIR0 INP2 MUX", "RX3", "SLIM RX3"},
  6706. {"IIR0 INP2 MUX", "RX4", "SLIM RX4"},
  6707. {"IIR0 INP2 MUX", "RX5", "SLIM RX5"},
  6708. {"IIR0 INP2 MUX", "RX6", "SLIM RX6"},
  6709. {"IIR0 INP2 MUX", "RX7", "SLIM RX7"},
  6710. {"IIR0", NULL, "IIR0 INP3 MUX"},
  6711. {"IIR0 INP3 MUX", "DEC0", "ADC MUX0"},
  6712. {"IIR0 INP3 MUX", "DEC1", "ADC MUX1"},
  6713. {"IIR0 INP3 MUX", "DEC2", "ADC MUX2"},
  6714. {"IIR0 INP3 MUX", "DEC3", "ADC MUX3"},
  6715. {"IIR0 INP3 MUX", "DEC4", "ADC MUX4"},
  6716. {"IIR0 INP3 MUX", "DEC5", "ADC MUX5"},
  6717. {"IIR0 INP3 MUX", "DEC6", "ADC MUX6"},
  6718. {"IIR0 INP3 MUX", "DEC7", "ADC MUX7"},
  6719. {"IIR0 INP3 MUX", "DEC8", "ADC MUX8"},
  6720. {"IIR0 INP3 MUX", "RX0", "SLIM RX0"},
  6721. {"IIR0 INP3 MUX", "RX1", "SLIM RX1"},
  6722. {"IIR0 INP3 MUX", "RX2", "SLIM RX2"},
  6723. {"IIR0 INP3 MUX", "RX3", "SLIM RX3"},
  6724. {"IIR0 INP3 MUX", "RX4", "SLIM RX4"},
  6725. {"IIR0 INP3 MUX", "RX5", "SLIM RX5"},
  6726. {"IIR0 INP3 MUX", "RX6", "SLIM RX6"},
  6727. {"IIR0 INP3 MUX", "RX7", "SLIM RX7"},
  6728. {"IIR1", NULL, "IIR1 INP0 MUX"},
  6729. {"IIR1 INP0 MUX", "DEC0", "ADC MUX0"},
  6730. {"IIR1 INP0 MUX", "DEC1", "ADC MUX1"},
  6731. {"IIR1 INP0 MUX", "DEC2", "ADC MUX2"},
  6732. {"IIR1 INP0 MUX", "DEC3", "ADC MUX3"},
  6733. {"IIR1 INP0 MUX", "DEC4", "ADC MUX4"},
  6734. {"IIR1 INP0 MUX", "DEC5", "ADC MUX5"},
  6735. {"IIR1 INP0 MUX", "DEC6", "ADC MUX6"},
  6736. {"IIR1 INP0 MUX", "DEC7", "ADC MUX7"},
  6737. {"IIR1 INP0 MUX", "DEC8", "ADC MUX8"},
  6738. {"IIR1 INP0 MUX", "RX0", "SLIM RX0"},
  6739. {"IIR1 INP0 MUX", "RX1", "SLIM RX1"},
  6740. {"IIR1 INP0 MUX", "RX2", "SLIM RX2"},
  6741. {"IIR1 INP0 MUX", "RX3", "SLIM RX3"},
  6742. {"IIR1 INP0 MUX", "RX4", "SLIM RX4"},
  6743. {"IIR1 INP0 MUX", "RX5", "SLIM RX5"},
  6744. {"IIR1 INP0 MUX", "RX6", "SLIM RX6"},
  6745. {"IIR1 INP0 MUX", "RX7", "SLIM RX7"},
  6746. {"IIR1", NULL, "IIR1 INP1 MUX"},
  6747. {"IIR1 INP1 MUX", "DEC0", "ADC MUX0"},
  6748. {"IIR1 INP1 MUX", "DEC1", "ADC MUX1"},
  6749. {"IIR1 INP1 MUX", "DEC2", "ADC MUX2"},
  6750. {"IIR1 INP1 MUX", "DEC3", "ADC MUX3"},
  6751. {"IIR1 INP1 MUX", "DEC4", "ADC MUX4"},
  6752. {"IIR1 INP1 MUX", "DEC5", "ADC MUX5"},
  6753. {"IIR1 INP1 MUX", "DEC6", "ADC MUX6"},
  6754. {"IIR1 INP1 MUX", "DEC7", "ADC MUX7"},
  6755. {"IIR1 INP1 MUX", "DEC8", "ADC MUX8"},
  6756. {"IIR1 INP1 MUX", "RX0", "SLIM RX0"},
  6757. {"IIR1 INP1 MUX", "RX1", "SLIM RX1"},
  6758. {"IIR1 INP1 MUX", "RX2", "SLIM RX2"},
  6759. {"IIR1 INP1 MUX", "RX3", "SLIM RX3"},
  6760. {"IIR1 INP1 MUX", "RX4", "SLIM RX4"},
  6761. {"IIR1 INP1 MUX", "RX5", "SLIM RX5"},
  6762. {"IIR1 INP1 MUX", "RX6", "SLIM RX6"},
  6763. {"IIR1 INP1 MUX", "RX7", "SLIM RX7"},
  6764. {"IIR1", NULL, "IIR1 INP2 MUX"},
  6765. {"IIR1 INP2 MUX", "DEC0", "ADC MUX0"},
  6766. {"IIR1 INP2 MUX", "DEC1", "ADC MUX1"},
  6767. {"IIR1 INP2 MUX", "DEC2", "ADC MUX2"},
  6768. {"IIR1 INP2 MUX", "DEC3", "ADC MUX3"},
  6769. {"IIR1 INP2 MUX", "DEC4", "ADC MUX4"},
  6770. {"IIR1 INP2 MUX", "DEC5", "ADC MUX5"},
  6771. {"IIR1 INP2 MUX", "DEC6", "ADC MUX6"},
  6772. {"IIR1 INP2 MUX", "DEC7", "ADC MUX7"},
  6773. {"IIR1 INP2 MUX", "DEC8", "ADC MUX8"},
  6774. {"IIR1 INP2 MUX", "RX0", "SLIM RX0"},
  6775. {"IIR1 INP2 MUX", "RX1", "SLIM RX1"},
  6776. {"IIR1 INP2 MUX", "RX2", "SLIM RX2"},
  6777. {"IIR1 INP2 MUX", "RX3", "SLIM RX3"},
  6778. {"IIR1 INP2 MUX", "RX4", "SLIM RX4"},
  6779. {"IIR1 INP2 MUX", "RX5", "SLIM RX5"},
  6780. {"IIR1 INP2 MUX", "RX6", "SLIM RX6"},
  6781. {"IIR1 INP2 MUX", "RX7", "SLIM RX7"},
  6782. {"IIR1", NULL, "IIR1 INP3 MUX"},
  6783. {"IIR1 INP3 MUX", "DEC0", "ADC MUX0"},
  6784. {"IIR1 INP3 MUX", "DEC1", "ADC MUX1"},
  6785. {"IIR1 INP3 MUX", "DEC2", "ADC MUX2"},
  6786. {"IIR1 INP3 MUX", "DEC3", "ADC MUX3"},
  6787. {"IIR1 INP3 MUX", "DEC4", "ADC MUX4"},
  6788. {"IIR1 INP3 MUX", "DEC5", "ADC MUX5"},
  6789. {"IIR1 INP3 MUX", "DEC6", "ADC MUX6"},
  6790. {"IIR1 INP3 MUX", "DEC7", "ADC MUX7"},
  6791. {"IIR1 INP3 MUX", "DEC8", "ADC MUX8"},
  6792. {"IIR1 INP3 MUX", "RX0", "SLIM RX0"},
  6793. {"IIR1 INP3 MUX", "RX1", "SLIM RX1"},
  6794. {"IIR1 INP3 MUX", "RX2", "SLIM RX2"},
  6795. {"IIR1 INP3 MUX", "RX3", "SLIM RX3"},
  6796. {"IIR1 INP3 MUX", "RX4", "SLIM RX4"},
  6797. {"IIR1 INP3 MUX", "RX5", "SLIM RX5"},
  6798. {"IIR1 INP3 MUX", "RX6", "SLIM RX6"},
  6799. {"IIR1 INP3 MUX", "RX7", "SLIM RX7"},
  6800. {"SRC0", NULL, "IIR0"},
  6801. {"SRC1", NULL, "IIR1"},
  6802. {"RX INT0 MIX2 INP", "SRC0", "SRC0"},
  6803. {"RX INT0 MIX2 INP", "SRC1", "SRC1"},
  6804. {"RX INT1 MIX2 INP", "SRC0", "SRC0"},
  6805. {"RX INT1 MIX2 INP", "SRC1", "SRC1"},
  6806. {"RX INT2 MIX2 INP", "SRC0", "SRC0"},
  6807. {"RX INT2 MIX2 INP", "SRC1", "SRC1"},
  6808. {"RX INT3 MIX2 INP", "SRC0", "SRC0"},
  6809. {"RX INT3 MIX2 INP", "SRC1", "SRC1"},
  6810. {"RX INT4 MIX2 INP", "SRC0", "SRC0"},
  6811. {"RX INT4 MIX2 INP", "SRC1", "SRC1"},
  6812. {"RX INT7 MIX2 INP", "SRC0", "SRC0"},
  6813. {"RX INT7 MIX2 INP", "SRC1", "SRC1"},
  6814. };
  6815. static int tasha_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol,
  6816. struct snd_ctl_elem_value *ucontrol)
  6817. {
  6818. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6819. u16 amic_reg;
  6820. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6821. amic_reg = WCD9335_ANA_AMIC1;
  6822. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6823. amic_reg = WCD9335_ANA_AMIC3;
  6824. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6825. amic_reg = WCD9335_ANA_AMIC5;
  6826. ucontrol->value.integer.value[0] =
  6827. (snd_soc_read(codec, amic_reg) & WCD9335_AMIC_PWR_LVL_MASK) >>
  6828. WCD9335_AMIC_PWR_LVL_SHIFT;
  6829. return 0;
  6830. }
  6831. static int tasha_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol,
  6832. struct snd_ctl_elem_value *ucontrol)
  6833. {
  6834. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6835. u32 mode_val;
  6836. u16 amic_reg;
  6837. mode_val = ucontrol->value.enumerated.item[0];
  6838. dev_dbg(codec->dev, "%s: mode: %d\n",
  6839. __func__, mode_val);
  6840. if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE"))
  6841. amic_reg = WCD9335_ANA_AMIC1;
  6842. if (!strcmp(kcontrol->id.name, "AMIC_3_4 PWR MODE"))
  6843. amic_reg = WCD9335_ANA_AMIC3;
  6844. if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE"))
  6845. amic_reg = WCD9335_ANA_AMIC5;
  6846. snd_soc_update_bits(codec, amic_reg, WCD9335_AMIC_PWR_LVL_MASK,
  6847. mode_val << WCD9335_AMIC_PWR_LVL_SHIFT);
  6848. return 0;
  6849. }
  6850. static int tasha_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
  6851. struct snd_ctl_elem_value *ucontrol)
  6852. {
  6853. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6854. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6855. ucontrol->value.integer.value[0] = tasha->hph_mode;
  6856. return 0;
  6857. }
  6858. static int tasha_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
  6859. struct snd_ctl_elem_value *ucontrol)
  6860. {
  6861. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6862. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  6863. u32 mode_val;
  6864. mode_val = ucontrol->value.enumerated.item[0];
  6865. dev_dbg(codec->dev, "%s: mode: %d\n",
  6866. __func__, mode_val);
  6867. if (mode_val == 0) {
  6868. dev_warn(codec->dev, "%s:Invalid HPH Mode, default to Cls-H HiFi\n",
  6869. __func__);
  6870. mode_val = CLS_H_HIFI;
  6871. }
  6872. tasha->hph_mode = mode_val;
  6873. return 0;
  6874. }
  6875. static const char *const tasha_conn_mad_text[] = {
  6876. "NOTUSED1", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6",
  6877. "NOTUSED2", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4",
  6878. "DMIC5", "NOTUSED3", "NOTUSED4"
  6879. };
  6880. static const struct soc_enum tasha_conn_mad_enum =
  6881. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_conn_mad_text),
  6882. tasha_conn_mad_text);
  6883. static int tasha_enable_ldo_h_get(struct snd_kcontrol *kcontrol,
  6884. struct snd_ctl_elem_value *ucontrol)
  6885. {
  6886. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6887. u8 val = 0;
  6888. if (codec)
  6889. val = snd_soc_read(codec, WCD9335_LDOH_MODE) & 0x80;
  6890. ucontrol->value.integer.value[0] = !!val;
  6891. return 0;
  6892. }
  6893. static int tasha_enable_ldo_h_put(struct snd_kcontrol *kcontrol,
  6894. struct snd_ctl_elem_value *ucontrol)
  6895. {
  6896. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6897. int value = ucontrol->value.integer.value[0];
  6898. bool enable;
  6899. enable = !!value;
  6900. if (codec)
  6901. tasha_codec_enable_standalone_ldo_h(codec, enable);
  6902. return 0;
  6903. }
  6904. static int tasha_mad_input_get(struct snd_kcontrol *kcontrol,
  6905. struct snd_ctl_elem_value *ucontrol)
  6906. {
  6907. u8 tasha_mad_input;
  6908. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6909. tasha_mad_input = snd_soc_read(codec,
  6910. WCD9335_SOC_MAD_INP_SEL) & 0x0F;
  6911. ucontrol->value.integer.value[0] = tasha_mad_input;
  6912. dev_dbg(codec->dev,
  6913. "%s: tasha_mad_input = %s\n", __func__,
  6914. tasha_conn_mad_text[tasha_mad_input]);
  6915. return 0;
  6916. }
  6917. static int tasha_mad_input_put(struct snd_kcontrol *kcontrol,
  6918. struct snd_ctl_elem_value *ucontrol)
  6919. {
  6920. u8 tasha_mad_input;
  6921. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  6922. struct snd_soc_card *card = codec->component.card;
  6923. char mad_amic_input_widget[6];
  6924. const char *mad_input_widget;
  6925. const char *source_widget = NULL;
  6926. u32 adc, i, mic_bias_found = 0;
  6927. int ret = 0;
  6928. char *mad_input;
  6929. tasha_mad_input = ucontrol->value.integer.value[0];
  6930. if (tasha_mad_input >= ARRAY_SIZE(tasha_conn_mad_text)) {
  6931. dev_err(codec->dev,
  6932. "%s: tasha_mad_input = %d out of bounds\n",
  6933. __func__, tasha_mad_input);
  6934. return -EINVAL;
  6935. }
  6936. if (!strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED1") ||
  6937. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED2") ||
  6938. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED3") ||
  6939. !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED4")) {
  6940. dev_err(codec->dev,
  6941. "%s: Unsupported tasha_mad_input = %s\n",
  6942. __func__, tasha_conn_mad_text[tasha_mad_input]);
  6943. return -EINVAL;
  6944. }
  6945. if (strnstr(tasha_conn_mad_text[tasha_mad_input],
  6946. "ADC", sizeof("ADC"))) {
  6947. mad_input = strpbrk(tasha_conn_mad_text[tasha_mad_input],
  6948. "123456");
  6949. if (!mad_input) {
  6950. dev_err(codec->dev, "%s: Invalid MAD input %s\n",
  6951. __func__,
  6952. tasha_conn_mad_text[tasha_mad_input]);
  6953. return -EINVAL;
  6954. }
  6955. ret = kstrtouint(mad_input, 10, &adc);
  6956. if ((ret < 0) || (adc > 6)) {
  6957. dev_err(codec->dev,
  6958. "%s: Invalid ADC = %s\n", __func__,
  6959. tasha_conn_mad_text[tasha_mad_input]);
  6960. ret = -EINVAL;
  6961. }
  6962. snprintf(mad_amic_input_widget, 6, "%s%u", "AMIC", adc);
  6963. mad_input_widget = mad_amic_input_widget;
  6964. } else {
  6965. /* DMIC type input widget*/
  6966. mad_input_widget = tasha_conn_mad_text[tasha_mad_input];
  6967. }
  6968. dev_dbg(codec->dev,
  6969. "%s: tasha input widget = %s\n", __func__,
  6970. mad_input_widget);
  6971. for (i = 0; i < card->num_of_dapm_routes; i++) {
  6972. if (!strcmp(card->of_dapm_routes[i].sink, mad_input_widget)) {
  6973. source_widget = card->of_dapm_routes[i].source;
  6974. if (!source_widget) {
  6975. dev_err(codec->dev,
  6976. "%s: invalid source widget\n",
  6977. __func__);
  6978. return -EINVAL;
  6979. }
  6980. if (strnstr(source_widget,
  6981. "MIC BIAS1", sizeof("MIC BIAS1"))) {
  6982. mic_bias_found = 1;
  6983. break;
  6984. } else if (strnstr(source_widget,
  6985. "MIC BIAS2", sizeof("MIC BIAS2"))) {
  6986. mic_bias_found = 2;
  6987. break;
  6988. } else if (strnstr(source_widget,
  6989. "MIC BIAS3", sizeof("MIC BIAS3"))) {
  6990. mic_bias_found = 3;
  6991. break;
  6992. } else if (strnstr(source_widget,
  6993. "MIC BIAS4", sizeof("MIC BIAS4"))) {
  6994. mic_bias_found = 4;
  6995. break;
  6996. }
  6997. }
  6998. }
  6999. if (!mic_bias_found) {
  7000. dev_err(codec->dev,
  7001. "%s: mic bias source not found for input = %s\n",
  7002. __func__, mad_input_widget);
  7003. return -EINVAL;
  7004. }
  7005. dev_dbg(codec->dev,
  7006. "%s: mic_bias found = %d\n", __func__,
  7007. mic_bias_found);
  7008. snd_soc_update_bits(codec, WCD9335_SOC_MAD_INP_SEL,
  7009. 0x0F, tasha_mad_input);
  7010. snd_soc_update_bits(codec, WCD9335_ANA_MAD_SETUP,
  7011. 0x07, mic_bias_found);
  7012. return 0;
  7013. }
  7014. static int tasha_pinctl_mode_get(struct snd_kcontrol *kcontrol,
  7015. struct snd_ctl_elem_value *ucontrol)
  7016. {
  7017. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7018. u16 ctl_reg;
  7019. u8 reg_val, pinctl_position;
  7020. pinctl_position = ((struct soc_multi_mixer_control *)
  7021. kcontrol->private_value)->shift;
  7022. switch (pinctl_position >> 3) {
  7023. case 0:
  7024. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7025. break;
  7026. case 1:
  7027. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7028. break;
  7029. case 2:
  7030. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7031. break;
  7032. case 3:
  7033. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7034. break;
  7035. default:
  7036. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7037. __func__, pinctl_position);
  7038. return -EINVAL;
  7039. }
  7040. reg_val = snd_soc_read(codec, ctl_reg);
  7041. reg_val = (reg_val >> (pinctl_position & 0x07)) & 0x1;
  7042. ucontrol->value.integer.value[0] = reg_val;
  7043. return 0;
  7044. }
  7045. static int tasha_pinctl_mode_put(struct snd_kcontrol *kcontrol,
  7046. struct snd_ctl_elem_value *ucontrol)
  7047. {
  7048. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7049. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7050. u16 ctl_reg, cfg_reg;
  7051. u8 ctl_val, cfg_val, pinctl_position, pinctl_mode, mask;
  7052. /* 1- high or low; 0- high Z */
  7053. pinctl_mode = ucontrol->value.integer.value[0];
  7054. pinctl_position = ((struct soc_multi_mixer_control *)
  7055. kcontrol->private_value)->shift;
  7056. switch (pinctl_position >> 3) {
  7057. case 0:
  7058. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_0;
  7059. break;
  7060. case 1:
  7061. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_1;
  7062. break;
  7063. case 2:
  7064. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_2;
  7065. break;
  7066. case 3:
  7067. ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3;
  7068. break;
  7069. default:
  7070. dev_err(codec->dev, "%s: Invalid pinctl position = %d\n",
  7071. __func__, pinctl_position);
  7072. return -EINVAL;
  7073. }
  7074. ctl_val = pinctl_mode << (pinctl_position & 0x07);
  7075. mask = 1 << (pinctl_position & 0x07);
  7076. snd_soc_update_bits(codec, ctl_reg, mask, ctl_val);
  7077. cfg_reg = WCD9335_TLMM_BIST_MODE_PINCFG + pinctl_position;
  7078. if (!pinctl_mode) {
  7079. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  7080. cfg_val = 0x4;
  7081. else
  7082. cfg_val = 0xC;
  7083. } else {
  7084. cfg_val = 0;
  7085. }
  7086. snd_soc_update_bits(codec, cfg_reg, 0x07, cfg_val);
  7087. dev_dbg(codec->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n",
  7088. __func__, ctl_reg, mask, ctl_val, cfg_reg, cfg_val);
  7089. return 0;
  7090. }
  7091. static void wcd_vbat_adc_out_config_2_0(struct wcd_vbat *vbat,
  7092. struct snd_soc_codec *codec)
  7093. {
  7094. u8 val1, val2;
  7095. /*
  7096. * Measure dcp1 by using "ALT" branch of band gap
  7097. * voltage(Vbg) and use it in FAST mode
  7098. */
  7099. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x82, 0x82);
  7100. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7101. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x01);
  7102. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x80);
  7103. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x00);
  7104. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x20);
  7105. /* Wait 100 usec after calibration select as Vbg */
  7106. usleep_range(100, 110);
  7107. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7108. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7109. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7110. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7111. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7112. snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x40, 0x40);
  7113. /* Wait 100 usec after selecting Vbg as 1.05V */
  7114. usleep_range(100, 110);
  7115. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40);
  7116. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7117. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7118. snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00);
  7119. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7120. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7121. __func__, vbat->dcp1, vbat->dcp2);
  7122. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7123. /* Wait 100 usec after selecting Vbg as 0.85V */
  7124. usleep_range(100, 110);
  7125. snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x00);
  7126. snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x20);
  7127. snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x00);
  7128. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x00);
  7129. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x00);
  7130. }
  7131. static void wcd_vbat_adc_out_config_1_x(struct wcd_vbat *vbat,
  7132. struct snd_soc_codec *codec)
  7133. {
  7134. u8 val1, val2;
  7135. /*
  7136. * Measure dcp1 by applying band gap voltage(Vbg)
  7137. * of 0.85V
  7138. */
  7139. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x20);
  7140. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7141. snd_soc_write(codec, WCD9335_BIAS_VBG_FINE_ADJ, 0x05);
  7142. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7143. /* Wait 2 sec after enabling band gap bias */
  7144. usleep_range(2000000, 2000100);
  7145. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x82);
  7146. snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x87);
  7147. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10);
  7148. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0D);
  7149. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01);
  7150. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7151. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xDE);
  7152. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x3C);
  7153. /* Wait 1 msec after calibration select as Vbg */
  7154. usleep_range(1000, 1100);
  7155. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
  7156. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7157. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7158. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7159. vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7160. /*
  7161. * Measure dcp2 by applying band gap voltage(Vbg)
  7162. * of 1.05V
  7163. */
  7164. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7165. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7166. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x68);
  7167. /* Wait 2 msec after selecting Vbg as 1.05V */
  7168. usleep_range(2000, 2100);
  7169. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7170. /* Wait 1 sec after enabling band gap bias */
  7171. usleep_range(1000000, 1000100);
  7172. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0);
  7173. val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB);
  7174. val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB);
  7175. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7176. vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07));
  7177. dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n",
  7178. __func__, vbat->dcp1, vbat->dcp2);
  7179. /* Reset the Vbat ADC configuration */
  7180. snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80);
  7181. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0);
  7182. snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28);
  7183. /* Wait 2 msec after selecting Vbg as 0.85V */
  7184. usleep_range(2000, 2100);
  7185. snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0);
  7186. /* Wait 1 sec after enabling band gap bias */
  7187. usleep_range(1000000, 1000100);
  7188. snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x1C);
  7189. snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xFE);
  7190. snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80);
  7191. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7192. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x00);
  7193. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x00);
  7194. snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0A);
  7195. }
  7196. static void wcd_vbat_adc_out_config(struct wcd_vbat *vbat,
  7197. struct snd_soc_codec *codec)
  7198. {
  7199. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  7200. if (!vbat->adc_config) {
  7201. tasha_cdc_mclk_enable(codec, true, false);
  7202. if (TASHA_IS_2_0(wcd9xxx))
  7203. wcd_vbat_adc_out_config_2_0(vbat, codec);
  7204. else
  7205. wcd_vbat_adc_out_config_1_x(vbat, codec);
  7206. tasha_cdc_mclk_enable(codec, false, false);
  7207. vbat->adc_config = true;
  7208. }
  7209. }
  7210. static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec)
  7211. {
  7212. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7213. struct firmware_cal *hwdep_cal = NULL;
  7214. struct vbat_monitor_reg *vbat_reg_ptr = NULL;
  7215. const void *data;
  7216. size_t cal_size, vbat_size_remaining;
  7217. int ret = 0, i;
  7218. u32 vbat_writes_size = 0;
  7219. u16 reg;
  7220. u8 mask, val, old_val;
  7221. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_VBAT_CAL);
  7222. if (hwdep_cal) {
  7223. data = hwdep_cal->data;
  7224. cal_size = hwdep_cal->size;
  7225. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7226. __func__);
  7227. } else {
  7228. dev_err(codec->dev, "%s: Vbat cal not received\n",
  7229. __func__);
  7230. ret = -EINVAL;
  7231. goto done;
  7232. }
  7233. if (cal_size < sizeof(*vbat_reg_ptr)) {
  7234. dev_err(codec->dev,
  7235. "%s: Incorrect size %zd for Vbat Cal, expected %zd\n",
  7236. __func__, cal_size, sizeof(*vbat_reg_ptr));
  7237. ret = -EINVAL;
  7238. goto done;
  7239. }
  7240. vbat_reg_ptr = (struct vbat_monitor_reg *) (data);
  7241. if (!vbat_reg_ptr) {
  7242. dev_err(codec->dev,
  7243. "%s: Invalid calibration data for Vbat\n",
  7244. __func__);
  7245. ret = -EINVAL;
  7246. goto done;
  7247. }
  7248. vbat_writes_size = vbat_reg_ptr->size;
  7249. vbat_size_remaining = cal_size - sizeof(u32);
  7250. dev_dbg(codec->dev, "%s: vbat_writes_sz: %d, vbat_sz_remaining: %zd\n",
  7251. __func__, vbat_writes_size, vbat_size_remaining);
  7252. if ((vbat_writes_size * TASHA_PACKED_REG_SIZE)
  7253. > vbat_size_remaining) {
  7254. pr_err("%s: Incorrect Vbat calibration data\n", __func__);
  7255. ret = -EINVAL;
  7256. goto done;
  7257. }
  7258. for (i = 0 ; i < vbat_writes_size; i++) {
  7259. TASHA_CODEC_UNPACK_ENTRY(vbat_reg_ptr->writes[i],
  7260. reg, mask, val);
  7261. old_val = snd_soc_read(codec, reg);
  7262. snd_soc_write(codec, reg, (old_val & ~mask) | (val & mask));
  7263. }
  7264. done:
  7265. return ret;
  7266. }
  7267. static int tasha_vbat_adc_data_get(struct snd_kcontrol *kcontrol,
  7268. struct snd_ctl_elem_value *ucontrol)
  7269. {
  7270. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7271. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7272. wcd_vbat_adc_out_config(&tasha->vbat, codec);
  7273. ucontrol->value.integer.value[0] = tasha->vbat.dcp1;
  7274. ucontrol->value.integer.value[1] = tasha->vbat.dcp2;
  7275. dev_dbg(codec->dev,
  7276. "%s: Vbat ADC output values, Dcp1 : %lu, Dcp2: %lu\n",
  7277. __func__, ucontrol->value.integer.value[0],
  7278. ucontrol->value.integer.value[1]);
  7279. return 0;
  7280. }
  7281. static const char * const tasha_vbat_gsm_mode_text[] = {
  7282. "OFF", "ON"};
  7283. static const struct soc_enum tasha_vbat_gsm_mode_enum =
  7284. SOC_ENUM_SINGLE_EXT(2, tasha_vbat_gsm_mode_text);
  7285. static int tasha_vbat_gsm_mode_func_get(struct snd_kcontrol *kcontrol,
  7286. struct snd_ctl_elem_value *ucontrol)
  7287. {
  7288. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7289. ucontrol->value.integer.value[0] =
  7290. ((snd_soc_read(codec, WCD9335_CDC_VBAT_VBAT_CFG) & 0x04) ?
  7291. 1 : 0);
  7292. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7293. ucontrol->value.integer.value[0]);
  7294. return 0;
  7295. }
  7296. static int tasha_vbat_gsm_mode_func_put(struct snd_kcontrol *kcontrol,
  7297. struct snd_ctl_elem_value *ucontrol)
  7298. {
  7299. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7300. dev_dbg(codec->dev, "%s: value: %lu\n", __func__,
  7301. ucontrol->value.integer.value[0]);
  7302. /* Set Vbat register configuration for GSM mode bit based on value */
  7303. if (ucontrol->value.integer.value[0])
  7304. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7305. 0x04, 0x04);
  7306. else
  7307. snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG,
  7308. 0x04, 0x00);
  7309. return 0;
  7310. }
  7311. static int tasha_codec_vbat_enable_event(struct snd_soc_dapm_widget *w,
  7312. struct snd_kcontrol *kcontrol,
  7313. int event)
  7314. {
  7315. int ret = 0;
  7316. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7317. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7318. u16 vbat_path_ctl, vbat_cfg, vbat_path_cfg;
  7319. vbat_path_ctl = WCD9335_CDC_VBAT_VBAT_PATH_CTL;
  7320. vbat_cfg = WCD9335_CDC_VBAT_VBAT_CFG;
  7321. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7322. if (!strcmp(w->name, "RX INT8 VBAT"))
  7323. vbat_path_cfg = WCD9335_CDC_RX8_RX_PATH_CFG1;
  7324. else if (!strcmp(w->name, "RX INT7 VBAT"))
  7325. vbat_path_cfg = WCD9335_CDC_RX7_RX_PATH_CFG1;
  7326. else if (!strcmp(w->name, "RX INT6 VBAT"))
  7327. vbat_path_cfg = WCD9335_CDC_RX6_RX_PATH_CFG1;
  7328. else if (!strcmp(w->name, "RX INT5 VBAT"))
  7329. vbat_path_cfg = WCD9335_CDC_RX5_RX_PATH_CFG1;
  7330. switch (event) {
  7331. case SND_SOC_DAPM_PRE_PMU:
  7332. ret = tasha_update_vbat_reg_config(codec);
  7333. if (ret) {
  7334. dev_dbg(codec->dev,
  7335. "%s : VBAT isn't calibrated, So not enabling it\n",
  7336. __func__);
  7337. return 0;
  7338. }
  7339. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80);
  7340. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x02);
  7341. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x10);
  7342. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x01);
  7343. tasha->vbat.is_enabled = true;
  7344. break;
  7345. case SND_SOC_DAPM_POST_PMD:
  7346. if (tasha->vbat.is_enabled) {
  7347. snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x00);
  7348. snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x00);
  7349. snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x00);
  7350. snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00);
  7351. tasha->vbat.is_enabled = false;
  7352. }
  7353. break;
  7354. };
  7355. return ret;
  7356. }
  7357. static const char * const rx_hph_mode_mux_text[] = {
  7358. "CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI"
  7359. };
  7360. static const struct soc_enum rx_hph_mode_mux_enum =
  7361. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text),
  7362. rx_hph_mode_mux_text);
  7363. static const char * const amic_pwr_lvl_text[] = {
  7364. "LOW_PWR", "DEFAULT", "HIGH_PERF"
  7365. };
  7366. static const struct soc_enum amic_pwr_lvl_enum =
  7367. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amic_pwr_lvl_text),
  7368. amic_pwr_lvl_text);
  7369. static const struct snd_kcontrol_new tasha_snd_controls[] = {
  7370. SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
  7371. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7372. SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
  7373. 0, -84, 40, digital_gain),
  7374. SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
  7375. 0, -84, 40, digital_gain),
  7376. SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
  7377. 0, -84, 40, digital_gain),
  7378. SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
  7379. 0, -84, 40, digital_gain),
  7380. SOC_SINGLE_SX_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
  7381. 0, -84, 40, digital_gain),
  7382. SOC_SINGLE_SX_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
  7383. 0, -84, 40, digital_gain),
  7384. SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
  7385. 0, -84, 40, digital_gain),
  7386. SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
  7387. 0, -84, 40, digital_gain),
  7388. SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
  7389. WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
  7390. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7391. SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
  7392. WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
  7393. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7394. SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
  7395. WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
  7396. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7397. SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
  7398. WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
  7399. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7400. SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
  7401. WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
  7402. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7403. SOC_SINGLE_SX_TLV("RX5 Mix Digital Volume",
  7404. WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
  7405. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7406. SOC_SINGLE_SX_TLV("RX6 Mix Digital Volume",
  7407. WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
  7408. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7409. SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
  7410. WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
  7411. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7412. SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
  7413. WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
  7414. 0, -84, 40, digital_gain), /* -84dB min - 40dB max */
  7415. SOC_SINGLE_SX_TLV("DEC0 Volume", WCD9335_CDC_TX0_TX_VOL_CTL, 0,
  7416. -84, 40, digital_gain),
  7417. SOC_SINGLE_SX_TLV("DEC1 Volume", WCD9335_CDC_TX1_TX_VOL_CTL, 0,
  7418. -84, 40, digital_gain),
  7419. SOC_SINGLE_SX_TLV("DEC2 Volume", WCD9335_CDC_TX2_TX_VOL_CTL, 0,
  7420. -84, 40, digital_gain),
  7421. SOC_SINGLE_SX_TLV("DEC3 Volume", WCD9335_CDC_TX3_TX_VOL_CTL, 0,
  7422. -84, 40, digital_gain),
  7423. SOC_SINGLE_SX_TLV("DEC4 Volume", WCD9335_CDC_TX4_TX_VOL_CTL, 0,
  7424. -84, 40, digital_gain),
  7425. SOC_SINGLE_SX_TLV("DEC5 Volume", WCD9335_CDC_TX5_TX_VOL_CTL, 0,
  7426. -84, 40, digital_gain),
  7427. SOC_SINGLE_SX_TLV("DEC6 Volume", WCD9335_CDC_TX6_TX_VOL_CTL, 0,
  7428. -84, 40, digital_gain),
  7429. SOC_SINGLE_SX_TLV("DEC7 Volume", WCD9335_CDC_TX7_TX_VOL_CTL, 0,
  7430. -84, 40, digital_gain),
  7431. SOC_SINGLE_SX_TLV("DEC8 Volume", WCD9335_CDC_TX8_TX_VOL_CTL, 0,
  7432. -84, 40, digital_gain),
  7433. SOC_SINGLE_SX_TLV("IIR0 INP0 Volume",
  7434. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, -84,
  7435. 40, digital_gain),
  7436. SOC_SINGLE_SX_TLV("IIR0 INP1 Volume",
  7437. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, -84,
  7438. 40, digital_gain),
  7439. SOC_SINGLE_SX_TLV("IIR0 INP2 Volume",
  7440. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, -84,
  7441. 40, digital_gain),
  7442. SOC_SINGLE_SX_TLV("IIR0 INP3 Volume",
  7443. WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, -84,
  7444. 40, digital_gain),
  7445. SOC_SINGLE_SX_TLV("IIR1 INP0 Volume",
  7446. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, -84,
  7447. 40, digital_gain),
  7448. SOC_SINGLE_SX_TLV("IIR1 INP1 Volume",
  7449. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, -84,
  7450. 40, digital_gain),
  7451. SOC_SINGLE_SX_TLV("IIR1 INP2 Volume",
  7452. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, -84,
  7453. 40, digital_gain),
  7454. SOC_SINGLE_SX_TLV("IIR1 INP3 Volume",
  7455. WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, -84,
  7456. 40, digital_gain),
  7457. SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 100, 0, tasha_get_anc_slot,
  7458. tasha_put_anc_slot),
  7459. SOC_ENUM_EXT("ANC Function", tasha_anc_func_enum, tasha_get_anc_func,
  7460. tasha_put_anc_func),
  7461. SOC_ENUM_EXT("CLK MODE", tasha_clkmode_enum, tasha_get_clkmode,
  7462. tasha_put_clkmode),
  7463. SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
  7464. SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
  7465. SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
  7466. SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
  7467. SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
  7468. SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
  7469. SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
  7470. SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
  7471. SOC_ENUM("TX8 HPF cut off", cf_dec8_enum),
  7472. SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
  7473. SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
  7474. SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
  7475. SOC_ENUM("RX INT1_2 HPF cut off", cf_int1_2_enum),
  7476. SOC_ENUM("RX INT2_1 HPF cut off", cf_int2_1_enum),
  7477. SOC_ENUM("RX INT2_2 HPF cut off", cf_int2_2_enum),
  7478. SOC_ENUM("RX INT3_1 HPF cut off", cf_int3_1_enum),
  7479. SOC_ENUM("RX INT3_2 HPF cut off", cf_int3_2_enum),
  7480. SOC_ENUM("RX INT4_1 HPF cut off", cf_int4_1_enum),
  7481. SOC_ENUM("RX INT4_2 HPF cut off", cf_int4_2_enum),
  7482. SOC_ENUM("RX INT5_1 HPF cut off", cf_int5_1_enum),
  7483. SOC_ENUM("RX INT5_2 HPF cut off", cf_int5_2_enum),
  7484. SOC_ENUM("RX INT6_1 HPF cut off", cf_int6_1_enum),
  7485. SOC_ENUM("RX INT6_2 HPF cut off", cf_int6_2_enum),
  7486. SOC_ENUM("RX INT7_1 HPF cut off", cf_int7_1_enum),
  7487. SOC_ENUM("RX INT7_2 HPF cut off", cf_int7_2_enum),
  7488. SOC_ENUM("RX INT8_1 HPF cut off", cf_int8_1_enum),
  7489. SOC_ENUM("RX INT8_2 HPF cut off", cf_int8_2_enum),
  7490. SOC_SINGLE_EXT("IIR0 Enable Band1", IIR0, BAND1, 1, 0,
  7491. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7492. SOC_SINGLE_EXT("IIR0 Enable Band2", IIR0, BAND2, 1, 0,
  7493. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7494. SOC_SINGLE_EXT("IIR0 Enable Band3", IIR0, BAND3, 1, 0,
  7495. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7496. SOC_SINGLE_EXT("IIR0 Enable Band4", IIR0, BAND4, 1, 0,
  7497. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7498. SOC_SINGLE_EXT("IIR0 Enable Band5", IIR0, BAND5, 1, 0,
  7499. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7500. SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0,
  7501. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7502. SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
  7503. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7504. SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
  7505. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7506. SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
  7507. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7508. SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
  7509. tasha_get_iir_enable_audio_mixer, tasha_put_iir_enable_audio_mixer),
  7510. SOC_SINGLE_MULTI_EXT("IIR0 Band1", IIR0, BAND1, 255, 0, 5,
  7511. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7512. SOC_SINGLE_MULTI_EXT("IIR0 Band2", IIR0, BAND2, 255, 0, 5,
  7513. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7514. SOC_SINGLE_MULTI_EXT("IIR0 Band3", IIR0, BAND3, 255, 0, 5,
  7515. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7516. SOC_SINGLE_MULTI_EXT("IIR0 Band4", IIR0, BAND4, 255, 0, 5,
  7517. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7518. SOC_SINGLE_MULTI_EXT("IIR0 Band5", IIR0, BAND5, 255, 0, 5,
  7519. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7520. SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
  7521. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7522. SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
  7523. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7524. SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
  7525. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7526. SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
  7527. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7528. SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
  7529. tasha_get_iir_band_audio_mixer, tasha_put_iir_band_audio_mixer),
  7530. SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0,
  7531. tasha_get_compander, tasha_set_compander),
  7532. SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0,
  7533. tasha_get_compander, tasha_set_compander),
  7534. SOC_SINGLE_EXT("COMP3 Switch", SND_SOC_NOPM, COMPANDER_3, 1, 0,
  7535. tasha_get_compander, tasha_set_compander),
  7536. SOC_SINGLE_EXT("COMP4 Switch", SND_SOC_NOPM, COMPANDER_4, 1, 0,
  7537. tasha_get_compander, tasha_set_compander),
  7538. SOC_SINGLE_EXT("COMP5 Switch", SND_SOC_NOPM, COMPANDER_5, 1, 0,
  7539. tasha_get_compander, tasha_set_compander),
  7540. SOC_SINGLE_EXT("COMP6 Switch", SND_SOC_NOPM, COMPANDER_6, 1, 0,
  7541. tasha_get_compander, tasha_set_compander),
  7542. SOC_SINGLE_EXT("COMP7 Switch", SND_SOC_NOPM, COMPANDER_7, 1, 0,
  7543. tasha_get_compander, tasha_set_compander),
  7544. SOC_SINGLE_EXT("COMP8 Switch", SND_SOC_NOPM, COMPANDER_8, 1, 0,
  7545. tasha_get_compander, tasha_set_compander),
  7546. SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum,
  7547. tasha_rx_hph_mode_get, tasha_rx_hph_mode_put),
  7548. SOC_ENUM_EXT("MAD Input", tasha_conn_mad_enum,
  7549. tasha_mad_input_get, tasha_mad_input_put),
  7550. SOC_SINGLE_EXT("LDO_H Enable", SND_SOC_NOPM, 0, 1, 0,
  7551. tasha_enable_ldo_h_get, tasha_enable_ldo_h_put),
  7552. SOC_SINGLE_EXT("DMIC1_CLK_PIN_MODE", SND_SOC_NOPM, 17, 1, 0,
  7553. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7554. SOC_SINGLE_EXT("DMIC1_DATA_PIN_MODE", SND_SOC_NOPM, 18, 1, 0,
  7555. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7556. SOC_SINGLE_EXT("DMIC2_CLK_PIN_MODE", SND_SOC_NOPM, 19, 1, 0,
  7557. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7558. SOC_SINGLE_EXT("DMIC2_DATA_PIN_MODE", SND_SOC_NOPM, 20, 1, 0,
  7559. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7560. SOC_SINGLE_EXT("DMIC3_CLK_PIN_MODE", SND_SOC_NOPM, 21, 1, 0,
  7561. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7562. SOC_SINGLE_EXT("DMIC3_DATA_PIN_MODE", SND_SOC_NOPM, 22, 1, 0,
  7563. tasha_pinctl_mode_get, tasha_pinctl_mode_put),
  7564. SOC_ENUM_EXT("AMIC_1_2 PWR MODE", amic_pwr_lvl_enum,
  7565. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7566. SOC_ENUM_EXT("AMIC_3_4 PWR MODE", amic_pwr_lvl_enum,
  7567. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7568. SOC_ENUM_EXT("AMIC_5_6 PWR MODE", amic_pwr_lvl_enum,
  7569. tasha_amic_pwr_lvl_get, tasha_amic_pwr_lvl_put),
  7570. SOC_SINGLE_MULTI_EXT("Vbat ADC data", SND_SOC_NOPM, 0, 0xFFFF, 0, 2,
  7571. tasha_vbat_adc_data_get, NULL),
  7572. SOC_ENUM_EXT("GSM mode Enable", tasha_vbat_gsm_mode_enum,
  7573. tasha_vbat_gsm_mode_func_get,
  7574. tasha_vbat_gsm_mode_func_put),
  7575. };
  7576. static int tasha_put_dec_enum(struct snd_kcontrol *kcontrol,
  7577. struct snd_ctl_elem_value *ucontrol)
  7578. {
  7579. struct snd_soc_dapm_widget *widget =
  7580. snd_soc_dapm_kcontrol_widget(kcontrol);
  7581. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7582. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7583. unsigned int val;
  7584. u16 mic_sel_reg;
  7585. u8 mic_sel;
  7586. val = ucontrol->value.enumerated.item[0];
  7587. if (val > e->items - 1)
  7588. return -EINVAL;
  7589. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7590. widget->name, val);
  7591. switch (e->reg) {
  7592. case WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1:
  7593. mic_sel_reg = WCD9335_CDC_TX0_TX_PATH_CFG0;
  7594. break;
  7595. case WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1:
  7596. mic_sel_reg = WCD9335_CDC_TX1_TX_PATH_CFG0;
  7597. break;
  7598. case WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1:
  7599. mic_sel_reg = WCD9335_CDC_TX2_TX_PATH_CFG0;
  7600. break;
  7601. case WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1:
  7602. mic_sel_reg = WCD9335_CDC_TX3_TX_PATH_CFG0;
  7603. break;
  7604. case WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0:
  7605. mic_sel_reg = WCD9335_CDC_TX4_TX_PATH_CFG0;
  7606. break;
  7607. case WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0:
  7608. mic_sel_reg = WCD9335_CDC_TX5_TX_PATH_CFG0;
  7609. break;
  7610. case WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0:
  7611. mic_sel_reg = WCD9335_CDC_TX6_TX_PATH_CFG0;
  7612. break;
  7613. case WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0:
  7614. mic_sel_reg = WCD9335_CDC_TX7_TX_PATH_CFG0;
  7615. break;
  7616. case WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0:
  7617. mic_sel_reg = WCD9335_CDC_TX8_TX_PATH_CFG0;
  7618. break;
  7619. default:
  7620. dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n",
  7621. __func__, e->reg);
  7622. return -EINVAL;
  7623. }
  7624. /* ADC: 0, DMIC: 1 */
  7625. mic_sel = val ? 0x0 : 0x1;
  7626. snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, mic_sel << 7);
  7627. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7628. }
  7629. static int tasha_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol,
  7630. struct snd_ctl_elem_value *ucontrol)
  7631. {
  7632. struct snd_soc_dapm_widget *widget =
  7633. snd_soc_dapm_kcontrol_widget(kcontrol);
  7634. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7635. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  7636. unsigned int val;
  7637. unsigned short look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7638. val = ucontrol->value.enumerated.item[0];
  7639. if (val >= e->items)
  7640. return -EINVAL;
  7641. dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  7642. widget->name, val);
  7643. if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0)
  7644. look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0;
  7645. else if (e->reg == WCD9335_CDC_RX1_RX_PATH_SEC0)
  7646. look_ahead_dly_reg = WCD9335_CDC_RX1_RX_PATH_CFG0;
  7647. else if (e->reg == WCD9335_CDC_RX2_RX_PATH_SEC0)
  7648. look_ahead_dly_reg = WCD9335_CDC_RX2_RX_PATH_CFG0;
  7649. /* Set Look Ahead Delay */
  7650. snd_soc_update_bits(codec, look_ahead_dly_reg,
  7651. 0x08, (val ? 0x08 : 0x00));
  7652. /* Set DEM INP Select */
  7653. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  7654. }
  7655. static int tasha_ear_pa_gain_get(struct snd_kcontrol *kcontrol,
  7656. struct snd_ctl_elem_value *ucontrol)
  7657. {
  7658. u8 ear_pa_gain;
  7659. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7660. ear_pa_gain = snd_soc_read(codec, WCD9335_ANA_EAR);
  7661. ear_pa_gain = (ear_pa_gain & 0x70) >> 4;
  7662. ucontrol->value.integer.value[0] = ear_pa_gain;
  7663. dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__,
  7664. ear_pa_gain);
  7665. return 0;
  7666. }
  7667. static int tasha_ear_pa_gain_put(struct snd_kcontrol *kcontrol,
  7668. struct snd_ctl_elem_value *ucontrol)
  7669. {
  7670. u8 ear_pa_gain;
  7671. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7672. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7673. __func__, ucontrol->value.integer.value[0]);
  7674. ear_pa_gain = ucontrol->value.integer.value[0] << 4;
  7675. snd_soc_update_bits(codec, WCD9335_ANA_EAR, 0x70, ear_pa_gain);
  7676. return 0;
  7677. }
  7678. static int tasha_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
  7679. struct snd_ctl_elem_value *ucontrol)
  7680. {
  7681. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7682. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7683. ucontrol->value.integer.value[0] = tasha->ear_spkr_gain;
  7684. dev_dbg(codec->dev, "%s: ear_spkr_gain = %ld\n", __func__,
  7685. ucontrol->value.integer.value[0]);
  7686. return 0;
  7687. }
  7688. static int tasha_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
  7689. struct snd_ctl_elem_value *ucontrol)
  7690. {
  7691. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7692. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7693. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7694. __func__, ucontrol->value.integer.value[0]);
  7695. tasha->ear_spkr_gain = ucontrol->value.integer.value[0];
  7696. return 0;
  7697. }
  7698. static int tasha_spkr_left_boost_stage_get(struct snd_kcontrol *kcontrol,
  7699. struct snd_ctl_elem_value *ucontrol)
  7700. {
  7701. u8 bst_state_max = 0;
  7702. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7703. bst_state_max = snd_soc_read(codec, WCD9335_CDC_BOOST0_BOOST_CTL);
  7704. bst_state_max = (bst_state_max & 0x0c) >> 2;
  7705. ucontrol->value.integer.value[0] = bst_state_max;
  7706. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7707. __func__, ucontrol->value.integer.value[0]);
  7708. return 0;
  7709. }
  7710. static int tasha_spkr_left_boost_stage_put(struct snd_kcontrol *kcontrol,
  7711. struct snd_ctl_elem_value *ucontrol)
  7712. {
  7713. u8 bst_state_max;
  7714. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7715. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7716. __func__, ucontrol->value.integer.value[0]);
  7717. bst_state_max = ucontrol->value.integer.value[0] << 2;
  7718. snd_soc_update_bits(codec, WCD9335_CDC_BOOST0_BOOST_CTL,
  7719. 0x0c, bst_state_max);
  7720. return 0;
  7721. }
  7722. static int tasha_spkr_right_boost_stage_get(struct snd_kcontrol *kcontrol,
  7723. struct snd_ctl_elem_value *ucontrol)
  7724. {
  7725. u8 bst_state_max = 0;
  7726. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7727. bst_state_max = snd_soc_read(codec, WCD9335_CDC_BOOST1_BOOST_CTL);
  7728. bst_state_max = (bst_state_max & 0x0c) >> 2;
  7729. ucontrol->value.integer.value[0] = bst_state_max;
  7730. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7731. __func__, ucontrol->value.integer.value[0]);
  7732. return 0;
  7733. }
  7734. static int tasha_spkr_right_boost_stage_put(struct snd_kcontrol *kcontrol,
  7735. struct snd_ctl_elem_value *ucontrol)
  7736. {
  7737. u8 bst_state_max;
  7738. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  7739. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  7740. __func__, ucontrol->value.integer.value[0]);
  7741. bst_state_max = ucontrol->value.integer.value[0] << 2;
  7742. snd_soc_update_bits(codec, WCD9335_CDC_BOOST1_BOOST_CTL,
  7743. 0x0c, bst_state_max);
  7744. return 0;
  7745. }
  7746. static int tasha_config_compander(struct snd_soc_codec *codec, int interp_n,
  7747. int event)
  7748. {
  7749. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7750. int comp;
  7751. u16 comp_ctl0_reg, rx_path_cfg0_reg;
  7752. /* EAR does not have compander */
  7753. if (!interp_n)
  7754. return 0;
  7755. comp = interp_n - 1;
  7756. dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n",
  7757. __func__, event, comp + 1, tasha->comp_enabled[comp]);
  7758. if (!tasha->comp_enabled[comp])
  7759. return 0;
  7760. comp_ctl0_reg = WCD9335_CDC_COMPANDER1_CTL0 + (comp * 8);
  7761. rx_path_cfg0_reg = WCD9335_CDC_RX1_RX_PATH_CFG0 + (comp * 20);
  7762. if (SND_SOC_DAPM_EVENT_ON(event)) {
  7763. /* Enable Compander Clock */
  7764. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01);
  7765. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7766. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7767. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02);
  7768. }
  7769. if (SND_SOC_DAPM_EVENT_OFF(event)) {
  7770. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04);
  7771. snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00);
  7772. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02);
  7773. snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00);
  7774. snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00);
  7775. snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00);
  7776. }
  7777. return 0;
  7778. }
  7779. static int tasha_codec_config_mad(struct snd_soc_codec *codec)
  7780. {
  7781. int ret = 0;
  7782. int idx;
  7783. const struct firmware *fw;
  7784. struct firmware_cal *hwdep_cal = NULL;
  7785. struct wcd_mad_audio_cal *mad_cal = NULL;
  7786. const void *data;
  7787. const char *filename = TASHA_MAD_AUDIO_FIRMWARE_PATH;
  7788. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  7789. size_t cal_size;
  7790. hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_MAD_CAL);
  7791. if (hwdep_cal) {
  7792. data = hwdep_cal->data;
  7793. cal_size = hwdep_cal->size;
  7794. dev_dbg(codec->dev, "%s: using hwdep calibration\n",
  7795. __func__);
  7796. } else {
  7797. ret = request_firmware(&fw, filename, codec->dev);
  7798. if (ret || !fw) {
  7799. dev_err(codec->dev,
  7800. "%s: MAD firmware acquire failed, err = %d\n",
  7801. __func__, ret);
  7802. return -ENODEV;
  7803. }
  7804. data = fw->data;
  7805. cal_size = fw->size;
  7806. dev_dbg(codec->dev, "%s: using request_firmware calibration\n",
  7807. __func__);
  7808. }
  7809. if (cal_size < sizeof(*mad_cal)) {
  7810. dev_err(codec->dev,
  7811. "%s: Incorrect size %zd for MAD Cal, expected %zd\n",
  7812. __func__, cal_size, sizeof(*mad_cal));
  7813. ret = -ENOMEM;
  7814. goto done;
  7815. }
  7816. mad_cal = (struct wcd_mad_audio_cal *) (data);
  7817. if (!mad_cal) {
  7818. dev_err(codec->dev,
  7819. "%s: Invalid calibration data\n",
  7820. __func__);
  7821. ret = -EINVAL;
  7822. goto done;
  7823. }
  7824. snd_soc_write(codec, WCD9335_SOC_MAD_MAIN_CTL_2,
  7825. mad_cal->microphone_info.cycle_time);
  7826. snd_soc_update_bits(codec, WCD9335_SOC_MAD_MAIN_CTL_1, 0xFF << 3,
  7827. ((uint16_t)mad_cal->microphone_info.settle_time)
  7828. << 3);
  7829. /* Audio */
  7830. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_8,
  7831. mad_cal->audio_info.rms_omit_samples);
  7832. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_1,
  7833. 0x07 << 4, mad_cal->audio_info.rms_comp_time << 4);
  7834. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03 << 2,
  7835. mad_cal->audio_info.detection_mechanism << 2);
  7836. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_7,
  7837. mad_cal->audio_info.rms_diff_threshold & 0x3F);
  7838. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_5,
  7839. mad_cal->audio_info.rms_threshold_lsb);
  7840. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_6,
  7841. mad_cal->audio_info.rms_threshold_msb);
  7842. for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients);
  7843. idx++) {
  7844. snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR,
  7845. 0x3F, idx);
  7846. snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL,
  7847. mad_cal->audio_info.iir_coefficients[idx]);
  7848. dev_dbg(codec->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x",
  7849. __func__, idx,
  7850. mad_cal->audio_info.iir_coefficients[idx]);
  7851. }
  7852. /* Beacon */
  7853. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_8,
  7854. mad_cal->beacon_info.rms_omit_samples);
  7855. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_1,
  7856. 0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4);
  7857. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_2, 0x03 << 2,
  7858. mad_cal->beacon_info.detection_mechanism << 2);
  7859. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_7,
  7860. mad_cal->beacon_info.rms_diff_threshold & 0x1F);
  7861. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_5,
  7862. mad_cal->beacon_info.rms_threshold_lsb);
  7863. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_6,
  7864. mad_cal->beacon_info.rms_threshold_msb);
  7865. for (idx = 0; idx < ARRAY_SIZE(mad_cal->beacon_info.iir_coefficients);
  7866. idx++) {
  7867. snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR,
  7868. 0x3F, idx);
  7869. snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL,
  7870. mad_cal->beacon_info.iir_coefficients[idx]);
  7871. dev_dbg(codec->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x",
  7872. __func__, idx,
  7873. mad_cal->beacon_info.iir_coefficients[idx]);
  7874. }
  7875. /* Ultrasound */
  7876. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_1,
  7877. 0x07 << 4,
  7878. mad_cal->ultrasound_info.rms_comp_time << 4);
  7879. snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_2, 0x03 << 2,
  7880. mad_cal->ultrasound_info.detection_mechanism << 2);
  7881. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_7,
  7882. mad_cal->ultrasound_info.rms_diff_threshold & 0x1F);
  7883. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_5,
  7884. mad_cal->ultrasound_info.rms_threshold_lsb);
  7885. snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_6,
  7886. mad_cal->ultrasound_info.rms_threshold_msb);
  7887. done:
  7888. if (!hwdep_cal)
  7889. release_firmware(fw);
  7890. return ret;
  7891. }
  7892. static int tasha_codec_enable_mad(struct snd_soc_dapm_widget *w,
  7893. struct snd_kcontrol *kcontrol, int event)
  7894. {
  7895. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7896. int ret = 0;
  7897. dev_dbg(codec->dev,
  7898. "%s: event = %d\n", __func__, event);
  7899. /* Return if CPE INPUT is DEC1 */
  7900. if (snd_soc_read(codec, WCD9335_CPE_SS_SVA_CFG) & 0x01)
  7901. return ret;
  7902. switch (event) {
  7903. case SND_SOC_DAPM_PRE_PMU:
  7904. /* Turn on MAD clk */
  7905. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7906. 0x01, 0x01);
  7907. /* Undo reset for MAD */
  7908. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7909. 0x02, 0x00);
  7910. ret = tasha_codec_config_mad(codec);
  7911. if (ret)
  7912. dev_err(codec->dev,
  7913. "%s: Failed to config MAD, err = %d\n",
  7914. __func__, ret);
  7915. break;
  7916. case SND_SOC_DAPM_POST_PMD:
  7917. /* Reset the MAD block */
  7918. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7919. 0x02, 0x02);
  7920. /* Turn off MAD clk */
  7921. snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL,
  7922. 0x01, 0x00);
  7923. break;
  7924. }
  7925. return ret;
  7926. }
  7927. static int tasha_codec_configure_cpe_input(struct snd_soc_dapm_widget *w,
  7928. struct snd_kcontrol *kcontrol, int event)
  7929. {
  7930. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  7931. dev_dbg(codec->dev,
  7932. "%s: event = %d\n", __func__, event);
  7933. switch (event) {
  7934. case SND_SOC_DAPM_PRE_PMU:
  7935. /* Configure CPE input as DEC1 */
  7936. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7937. 0x01, 0x01);
  7938. /* Configure DEC1 Tx out with sample rate as 16K */
  7939. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7940. 0x0F, 0x01);
  7941. break;
  7942. case SND_SOC_DAPM_POST_PMD:
  7943. /* Reset DEC1 Tx out sample rate */
  7944. snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL,
  7945. 0x0F, 0x04);
  7946. snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG,
  7947. 0x01, 0x00);
  7948. break;
  7949. }
  7950. return 0;
  7951. }
  7952. static int tasha_codec_aif4_mixer_switch_get(struct snd_kcontrol *kcontrol,
  7953. struct snd_ctl_elem_value *ucontrol)
  7954. {
  7955. struct snd_soc_dapm_widget *widget =
  7956. snd_soc_dapm_kcontrol_widget(kcontrol);
  7957. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7958. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7959. if (test_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask))
  7960. ucontrol->value.integer.value[0] = 1;
  7961. else
  7962. ucontrol->value.integer.value[0] = 0;
  7963. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7964. __func__, ucontrol->value.integer.value[0]);
  7965. return 0;
  7966. }
  7967. static int tasha_codec_aif4_mixer_switch_put(struct snd_kcontrol *kcontrol,
  7968. struct snd_ctl_elem_value *ucontrol)
  7969. {
  7970. struct snd_soc_dapm_widget *widget =
  7971. snd_soc_dapm_kcontrol_widget(kcontrol);
  7972. struct snd_soc_dapm_update *update = NULL;
  7973. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
  7974. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec);
  7975. dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n",
  7976. __func__, ucontrol->value.integer.value[0]);
  7977. if (ucontrol->value.integer.value[0]) {
  7978. snd_soc_dapm_mixer_update_power(widget->dapm,
  7979. kcontrol, 1, update);
  7980. set_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7981. } else {
  7982. snd_soc_dapm_mixer_update_power(widget->dapm,
  7983. kcontrol, 0, update);
  7984. clear_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask);
  7985. }
  7986. return 1;
  7987. }
  7988. static const char * const tasha_ear_pa_gain_text[] = {
  7989. "G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB",
  7990. "G_0_DB", "G_M2P5_DB", "UNDEFINED", "G_M12_DB"
  7991. };
  7992. static const char * const tasha_ear_spkr_pa_gain_text[] = {
  7993. "G_DEFAULT", "G_0_DB", "G_1_DB", "G_2_DB", "G_3_DB", "G_4_DB",
  7994. "G_5_DB", "G_6_DB"
  7995. };
  7996. static const char * const tasha_speaker_boost_stage_text[] = {
  7997. "NO_MAX_STATE", "MAX_STATE_1", "MAX_STATE_2"
  7998. };
  7999. static const struct soc_enum tasha_ear_pa_gain_enum =
  8000. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_pa_gain_text),
  8001. tasha_ear_pa_gain_text);
  8002. static const struct soc_enum tasha_ear_spkr_pa_gain_enum =
  8003. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_ear_spkr_pa_gain_text),
  8004. tasha_ear_spkr_pa_gain_text);
  8005. static const struct soc_enum tasha_spkr_boost_stage_enum =
  8006. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tasha_speaker_boost_stage_text),
  8007. tasha_speaker_boost_stage_text);
  8008. static const struct snd_kcontrol_new tasha_analog_gain_controls[] = {
  8009. SOC_ENUM_EXT("EAR PA Gain", tasha_ear_pa_gain_enum,
  8010. tasha_ear_pa_gain_get, tasha_ear_pa_gain_put),
  8011. SOC_ENUM_EXT("EAR SPKR PA Gain", tasha_ear_spkr_pa_gain_enum,
  8012. tasha_ear_spkr_pa_gain_get, tasha_ear_spkr_pa_gain_put),
  8013. SOC_ENUM_EXT("SPKR Left Boost Max State", tasha_spkr_boost_stage_enum,
  8014. tasha_spkr_left_boost_stage_get,
  8015. tasha_spkr_left_boost_stage_put),
  8016. SOC_ENUM_EXT("SPKR Right Boost Max State", tasha_spkr_boost_stage_enum,
  8017. tasha_spkr_right_boost_stage_get,
  8018. tasha_spkr_right_boost_stage_put),
  8019. SOC_SINGLE_TLV("HPHL Volume", WCD9335_HPH_L_EN, 0, 20, 1,
  8020. line_gain),
  8021. SOC_SINGLE_TLV("HPHR Volume", WCD9335_HPH_R_EN, 0, 20, 1,
  8022. line_gain),
  8023. SOC_SINGLE_TLV("LINEOUT1 Volume", WCD9335_DIFF_LO_LO1_COMPANDER,
  8024. 3, 16, 1, line_gain),
  8025. SOC_SINGLE_TLV("LINEOUT2 Volume", WCD9335_DIFF_LO_LO2_COMPANDER,
  8026. 3, 16, 1, line_gain),
  8027. SOC_SINGLE_TLV("LINEOUT3 Volume", WCD9335_SE_LO_LO3_GAIN, 0, 20, 1,
  8028. line_gain),
  8029. SOC_SINGLE_TLV("LINEOUT4 Volume", WCD9335_SE_LO_LO4_GAIN, 0, 20, 1,
  8030. line_gain),
  8031. SOC_SINGLE_TLV("ADC1 Volume", WCD9335_ANA_AMIC1, 0, 20, 0,
  8032. analog_gain),
  8033. SOC_SINGLE_TLV("ADC2 Volume", WCD9335_ANA_AMIC2, 0, 20, 0,
  8034. analog_gain),
  8035. SOC_SINGLE_TLV("ADC3 Volume", WCD9335_ANA_AMIC3, 0, 20, 0,
  8036. analog_gain),
  8037. SOC_SINGLE_TLV("ADC4 Volume", WCD9335_ANA_AMIC4, 0, 20, 0,
  8038. analog_gain),
  8039. SOC_SINGLE_TLV("ADC5 Volume", WCD9335_ANA_AMIC5, 0, 20, 0,
  8040. analog_gain),
  8041. SOC_SINGLE_TLV("ADC6 Volume", WCD9335_ANA_AMIC6, 0, 20, 0,
  8042. analog_gain),
  8043. };
  8044. static const char * const spl_src0_mux_text[] = {
  8045. "ZERO", "SRC_IN_HPHL", "SRC_IN_LO1",
  8046. };
  8047. static const char * const spl_src1_mux_text[] = {
  8048. "ZERO", "SRC_IN_HPHR", "SRC_IN_LO2",
  8049. };
  8050. static const char * const spl_src2_mux_text[] = {
  8051. "ZERO", "SRC_IN_LO3", "SRC_IN_SPKRL",
  8052. };
  8053. static const char * const spl_src3_mux_text[] = {
  8054. "ZERO", "SRC_IN_LO4", "SRC_IN_SPKRR",
  8055. };
  8056. static const char * const rx_int0_7_mix_mux_text[] = {
  8057. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  8058. "RX6", "RX7", "PROXIMITY"
  8059. };
  8060. static const char * const rx_int_mix_mux_text[] = {
  8061. "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5",
  8062. "RX6", "RX7"
  8063. };
  8064. static const char * const rx_prim_mix_text[] = {
  8065. "ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2",
  8066. "RX3", "RX4", "RX5", "RX6", "RX7"
  8067. };
  8068. static const char * const rx_sidetone_mix_text[] = {
  8069. "ZERO", "SRC0", "SRC1", "SRC_SUM"
  8070. };
  8071. static const char * const sb_tx0_mux_text[] = {
  8072. "ZERO", "RX_MIX_TX0", "DEC0", "DEC0_192"
  8073. };
  8074. static const char * const sb_tx1_mux_text[] = {
  8075. "ZERO", "RX_MIX_TX1", "DEC1", "DEC1_192"
  8076. };
  8077. static const char * const sb_tx2_mux_text[] = {
  8078. "ZERO", "RX_MIX_TX2", "DEC2", "DEC2_192"
  8079. };
  8080. static const char * const sb_tx3_mux_text[] = {
  8081. "ZERO", "RX_MIX_TX3", "DEC3", "DEC3_192"
  8082. };
  8083. static const char * const sb_tx4_mux_text[] = {
  8084. "ZERO", "RX_MIX_TX4", "DEC4", "DEC4_192"
  8085. };
  8086. static const char * const sb_tx5_mux_text[] = {
  8087. "ZERO", "RX_MIX_TX5", "DEC5", "DEC5_192"
  8088. };
  8089. static const char * const sb_tx6_mux_text[] = {
  8090. "ZERO", "RX_MIX_TX6", "DEC6", "DEC6_192"
  8091. };
  8092. static const char * const sb_tx7_mux_text[] = {
  8093. "ZERO", "RX_MIX_TX7", "DEC7", "DEC7_192"
  8094. };
  8095. static const char * const sb_tx8_mux_text[] = {
  8096. "ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192"
  8097. };
  8098. static const char * const sb_tx9_mux_text[] = {
  8099. "ZERO", "DEC7", "DEC7_192"
  8100. };
  8101. static const char * const sb_tx10_mux_text[] = {
  8102. "ZERO", "DEC6", "DEC6_192"
  8103. };
  8104. static const char * const sb_tx11_mux_text[] = {
  8105. "DEC_0_5", "DEC_9_12", "MAD_AUDIO", "MAD_BRDCST"
  8106. };
  8107. static const char * const sb_tx11_inp1_mux_text[] = {
  8108. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4",
  8109. "DEC5", "RX_MIX_TX5", "DEC9_10", "DEC11_12"
  8110. };
  8111. static const char * const sb_tx13_mux_text[] = {
  8112. "ZERO", "DEC5", "DEC5_192"
  8113. };
  8114. static const char * const tx13_inp_mux_text[] = {
  8115. "CDC_DEC_5", "MAD_BRDCST", "CPE_TX_PP"
  8116. };
  8117. static const char * const iir_inp_mux_text[] = {
  8118. "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6",
  8119. "DEC7", "DEC8", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7"
  8120. };
  8121. static const char * const rx_int_dem_inp_mux_text[] = {
  8122. "NORMAL_DSM_OUT", "CLSH_DSM_OUT",
  8123. };
  8124. static const char * const rx_int0_interp_mux_text[] = {
  8125. "ZERO", "RX INT0 MIX2",
  8126. };
  8127. static const char * const rx_int1_interp_mux_text[] = {
  8128. "ZERO", "RX INT1 MIX2",
  8129. };
  8130. static const char * const rx_int2_interp_mux_text[] = {
  8131. "ZERO", "RX INT2 MIX2",
  8132. };
  8133. static const char * const rx_int3_interp_mux_text[] = {
  8134. "ZERO", "RX INT3 MIX2",
  8135. };
  8136. static const char * const rx_int4_interp_mux_text[] = {
  8137. "ZERO", "RX INT4 MIX2",
  8138. };
  8139. static const char * const rx_int5_interp_mux_text[] = {
  8140. "ZERO", "RX INT5 MIX2",
  8141. };
  8142. static const char * const rx_int6_interp_mux_text[] = {
  8143. "ZERO", "RX INT6 MIX2",
  8144. };
  8145. static const char * const rx_int7_interp_mux_text[] = {
  8146. "ZERO", "RX INT7 MIX2",
  8147. };
  8148. static const char * const rx_int8_interp_mux_text[] = {
  8149. "ZERO", "RX INT8 SEC MIX"
  8150. };
  8151. static const char * const mad_sel_text[] = {
  8152. "SPE", "MSM"
  8153. };
  8154. static const char * const adc_mux_text[] = {
  8155. "DMIC", "AMIC", "ANC_FB_TUNE1", "ANC_FB_TUNE2"
  8156. };
  8157. static const char * const dmic_mux_text[] = {
  8158. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8159. "SMIC0", "SMIC1", "SMIC2", "SMIC3"
  8160. };
  8161. static const char * const dmic_mux_alt_text[] = {
  8162. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5",
  8163. };
  8164. static const char * const amic_mux_text[] = {
  8165. "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6"
  8166. };
  8167. static const char * const rx_echo_mux_text[] = {
  8168. "ZERO", "RX_MIX0", "RX_MIX1", "RX_MIX2", "RX_MIX3", "RX_MIX4",
  8169. "RX_MIX5", "RX_MIX6", "RX_MIX7", "RX_MIX8", "RX_MIX_VBAT5",
  8170. "RX_MIX_VBAT6", "RX_MIX_VBAT7", "RX_MIX_VBAT8"
  8171. };
  8172. static const char * const anc0_fb_mux_text[] = {
  8173. "ZERO", "ANC_IN_HPHL", "ANC_IN_EAR", "ANC_IN_EAR_SPKR",
  8174. "ANC_IN_LO1"
  8175. };
  8176. static const char * const anc1_fb_mux_text[] = {
  8177. "ZERO", "ANC_IN_HPHR", "ANC_IN_LO2"
  8178. };
  8179. static const char * const native_mux_text[] = {
  8180. "OFF", "ON",
  8181. };
  8182. static const struct soc_enum spl_src0_mux_chain_enum =
  8183. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 0, 3,
  8184. spl_src0_mux_text);
  8185. static const struct soc_enum spl_src1_mux_chain_enum =
  8186. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 2, 3,
  8187. spl_src1_mux_text);
  8188. static const struct soc_enum spl_src2_mux_chain_enum =
  8189. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 4, 3,
  8190. spl_src2_mux_text);
  8191. static const struct soc_enum spl_src3_mux_chain_enum =
  8192. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0, 6, 3,
  8193. spl_src3_mux_text);
  8194. static const struct soc_enum rx_int0_2_mux_chain_enum =
  8195. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 0, 10,
  8196. rx_int0_7_mix_mux_text);
  8197. static const struct soc_enum rx_int1_2_mux_chain_enum =
  8198. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 0, 9,
  8199. rx_int_mix_mux_text);
  8200. static const struct soc_enum rx_int2_2_mux_chain_enum =
  8201. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 0, 9,
  8202. rx_int_mix_mux_text);
  8203. static const struct soc_enum rx_int3_2_mux_chain_enum =
  8204. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 0, 9,
  8205. rx_int_mix_mux_text);
  8206. static const struct soc_enum rx_int4_2_mux_chain_enum =
  8207. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 0, 9,
  8208. rx_int_mix_mux_text);
  8209. static const struct soc_enum rx_int5_2_mux_chain_enum =
  8210. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 0, 9,
  8211. rx_int_mix_mux_text);
  8212. static const struct soc_enum rx_int6_2_mux_chain_enum =
  8213. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 0, 9,
  8214. rx_int_mix_mux_text);
  8215. static const struct soc_enum rx_int7_2_mux_chain_enum =
  8216. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 0, 10,
  8217. rx_int0_7_mix_mux_text);
  8218. static const struct soc_enum rx_int8_2_mux_chain_enum =
  8219. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 0, 9,
  8220. rx_int_mix_mux_text);
  8221. static const struct soc_enum int1_1_native_enum =
  8222. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8223. native_mux_text);
  8224. static const struct soc_enum int2_1_native_enum =
  8225. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8226. native_mux_text);
  8227. static const struct soc_enum int3_1_native_enum =
  8228. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8229. native_mux_text);
  8230. static const struct soc_enum int4_1_native_enum =
  8231. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(native_mux_text),
  8232. native_mux_text);
  8233. static const struct soc_enum rx_int0_1_mix_inp0_chain_enum =
  8234. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 0, 13,
  8235. rx_prim_mix_text);
  8236. static const struct soc_enum rx_int0_1_mix_inp1_chain_enum =
  8237. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0, 4, 13,
  8238. rx_prim_mix_text);
  8239. static const struct soc_enum rx_int0_1_mix_inp2_chain_enum =
  8240. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1, 4, 13,
  8241. rx_prim_mix_text);
  8242. static const struct soc_enum rx_int1_1_mix_inp0_chain_enum =
  8243. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 0, 13,
  8244. rx_prim_mix_text);
  8245. static const struct soc_enum rx_int1_1_mix_inp1_chain_enum =
  8246. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0, 4, 13,
  8247. rx_prim_mix_text);
  8248. static const struct soc_enum rx_int1_1_mix_inp2_chain_enum =
  8249. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG1, 4, 13,
  8250. rx_prim_mix_text);
  8251. static const struct soc_enum rx_int2_1_mix_inp0_chain_enum =
  8252. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 0, 13,
  8253. rx_prim_mix_text);
  8254. static const struct soc_enum rx_int2_1_mix_inp1_chain_enum =
  8255. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG0, 4, 13,
  8256. rx_prim_mix_text);
  8257. static const struct soc_enum rx_int2_1_mix_inp2_chain_enum =
  8258. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT2_CFG1, 4, 13,
  8259. rx_prim_mix_text);
  8260. static const struct soc_enum rx_int3_1_mix_inp0_chain_enum =
  8261. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 0, 13,
  8262. rx_prim_mix_text);
  8263. static const struct soc_enum rx_int3_1_mix_inp1_chain_enum =
  8264. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG0, 4, 13,
  8265. rx_prim_mix_text);
  8266. static const struct soc_enum rx_int3_1_mix_inp2_chain_enum =
  8267. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT3_CFG1, 4, 13,
  8268. rx_prim_mix_text);
  8269. static const struct soc_enum rx_int4_1_mix_inp0_chain_enum =
  8270. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 0, 13,
  8271. rx_prim_mix_text);
  8272. static const struct soc_enum rx_int4_1_mix_inp1_chain_enum =
  8273. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG0, 4, 13,
  8274. rx_prim_mix_text);
  8275. static const struct soc_enum rx_int4_1_mix_inp2_chain_enum =
  8276. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT4_CFG1, 4, 13,
  8277. rx_prim_mix_text);
  8278. static const struct soc_enum rx_int5_1_mix_inp0_chain_enum =
  8279. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 0, 13,
  8280. rx_prim_mix_text);
  8281. static const struct soc_enum rx_int5_1_mix_inp1_chain_enum =
  8282. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG0, 4, 13,
  8283. rx_prim_mix_text);
  8284. static const struct soc_enum rx_int5_1_mix_inp2_chain_enum =
  8285. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT5_CFG1, 4, 13,
  8286. rx_prim_mix_text);
  8287. static const struct soc_enum rx_int6_1_mix_inp0_chain_enum =
  8288. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 0, 13,
  8289. rx_prim_mix_text);
  8290. static const struct soc_enum rx_int6_1_mix_inp1_chain_enum =
  8291. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG0, 4, 13,
  8292. rx_prim_mix_text);
  8293. static const struct soc_enum rx_int6_1_mix_inp2_chain_enum =
  8294. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT6_CFG1, 4, 13,
  8295. rx_prim_mix_text);
  8296. static const struct soc_enum rx_int7_1_mix_inp0_chain_enum =
  8297. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 0, 13,
  8298. rx_prim_mix_text);
  8299. static const struct soc_enum rx_int7_1_mix_inp1_chain_enum =
  8300. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG0, 4, 13,
  8301. rx_prim_mix_text);
  8302. static const struct soc_enum rx_int7_1_mix_inp2_chain_enum =
  8303. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT7_CFG1, 4, 13,
  8304. rx_prim_mix_text);
  8305. static const struct soc_enum rx_int8_1_mix_inp0_chain_enum =
  8306. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 0, 13,
  8307. rx_prim_mix_text);
  8308. static const struct soc_enum rx_int8_1_mix_inp1_chain_enum =
  8309. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG0, 4, 13,
  8310. rx_prim_mix_text);
  8311. static const struct soc_enum rx_int8_1_mix_inp2_chain_enum =
  8312. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_INT8_CFG1, 4, 13,
  8313. rx_prim_mix_text);
  8314. static const struct soc_enum rx_int0_sidetone_mix_chain_enum =
  8315. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0, 4,
  8316. rx_sidetone_mix_text);
  8317. static const struct soc_enum rx_int1_sidetone_mix_chain_enum =
  8318. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2, 4,
  8319. rx_sidetone_mix_text);
  8320. static const struct soc_enum rx_int2_sidetone_mix_chain_enum =
  8321. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4, 4,
  8322. rx_sidetone_mix_text);
  8323. static const struct soc_enum rx_int3_sidetone_mix_chain_enum =
  8324. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6, 4,
  8325. rx_sidetone_mix_text);
  8326. static const struct soc_enum rx_int4_sidetone_mix_chain_enum =
  8327. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 0, 4,
  8328. rx_sidetone_mix_text);
  8329. static const struct soc_enum rx_int7_sidetone_mix_chain_enum =
  8330. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 2, 4,
  8331. rx_sidetone_mix_text);
  8332. static const struct soc_enum tx_adc_mux0_chain_enum =
  8333. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 0, 4,
  8334. adc_mux_text);
  8335. static const struct soc_enum tx_adc_mux1_chain_enum =
  8336. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 0, 4,
  8337. adc_mux_text);
  8338. static const struct soc_enum tx_adc_mux2_chain_enum =
  8339. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 0, 4,
  8340. adc_mux_text);
  8341. static const struct soc_enum tx_adc_mux3_chain_enum =
  8342. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 0, 4,
  8343. adc_mux_text);
  8344. static const struct soc_enum tx_adc_mux4_chain_enum =
  8345. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 6, 4,
  8346. adc_mux_text);
  8347. static const struct soc_enum tx_adc_mux5_chain_enum =
  8348. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 6, 4,
  8349. adc_mux_text);
  8350. static const struct soc_enum tx_adc_mux6_chain_enum =
  8351. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 6, 4,
  8352. adc_mux_text);
  8353. static const struct soc_enum tx_adc_mux7_chain_enum =
  8354. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 6, 4,
  8355. adc_mux_text);
  8356. static const struct soc_enum tx_adc_mux8_chain_enum =
  8357. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 6, 4,
  8358. adc_mux_text);
  8359. static const struct soc_enum tx_adc_mux10_chain_enum =
  8360. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 6, 4,
  8361. adc_mux_text);
  8362. static const struct soc_enum tx_adc_mux11_chain_enum =
  8363. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 6, 4,
  8364. adc_mux_text);
  8365. static const struct soc_enum tx_adc_mux12_chain_enum =
  8366. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 6, 4,
  8367. adc_mux_text);
  8368. static const struct soc_enum tx_adc_mux13_chain_enum =
  8369. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 6, 4,
  8370. adc_mux_text);
  8371. static const struct soc_enum tx_dmic_mux0_enum =
  8372. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 3, 11,
  8373. dmic_mux_text);
  8374. static const struct soc_enum tx_dmic_mux1_enum =
  8375. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 3, 11,
  8376. dmic_mux_text);
  8377. static const struct soc_enum tx_dmic_mux2_enum =
  8378. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 3, 11,
  8379. dmic_mux_text);
  8380. static const struct soc_enum tx_dmic_mux3_enum =
  8381. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 3, 11,
  8382. dmic_mux_text);
  8383. static const struct soc_enum tx_dmic_mux4_enum =
  8384. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 3, 7,
  8385. dmic_mux_alt_text);
  8386. static const struct soc_enum tx_dmic_mux5_enum =
  8387. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 3, 7,
  8388. dmic_mux_alt_text);
  8389. static const struct soc_enum tx_dmic_mux6_enum =
  8390. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 3, 7,
  8391. dmic_mux_alt_text);
  8392. static const struct soc_enum tx_dmic_mux7_enum =
  8393. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 3, 7,
  8394. dmic_mux_alt_text);
  8395. static const struct soc_enum tx_dmic_mux8_enum =
  8396. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 3, 7,
  8397. dmic_mux_alt_text);
  8398. static const struct soc_enum tx_dmic_mux10_enum =
  8399. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 3, 7,
  8400. dmic_mux_alt_text);
  8401. static const struct soc_enum tx_dmic_mux11_enum =
  8402. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 3, 7,
  8403. dmic_mux_alt_text);
  8404. static const struct soc_enum tx_dmic_mux12_enum =
  8405. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 3, 7,
  8406. dmic_mux_alt_text);
  8407. static const struct soc_enum tx_dmic_mux13_enum =
  8408. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 3, 7,
  8409. dmic_mux_alt_text);
  8410. static const struct soc_enum tx_amic_mux0_enum =
  8411. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 0, 7,
  8412. amic_mux_text);
  8413. static const struct soc_enum tx_amic_mux1_enum =
  8414. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 0, 7,
  8415. amic_mux_text);
  8416. static const struct soc_enum tx_amic_mux2_enum =
  8417. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 0, 7,
  8418. amic_mux_text);
  8419. static const struct soc_enum tx_amic_mux3_enum =
  8420. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 0, 7,
  8421. amic_mux_text);
  8422. static const struct soc_enum tx_amic_mux4_enum =
  8423. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 0, 7,
  8424. amic_mux_text);
  8425. static const struct soc_enum tx_amic_mux5_enum =
  8426. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 0, 7,
  8427. amic_mux_text);
  8428. static const struct soc_enum tx_amic_mux6_enum =
  8429. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 0, 7,
  8430. amic_mux_text);
  8431. static const struct soc_enum tx_amic_mux7_enum =
  8432. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 0, 7,
  8433. amic_mux_text);
  8434. static const struct soc_enum tx_amic_mux8_enum =
  8435. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 0, 7,
  8436. amic_mux_text);
  8437. static const struct soc_enum tx_amic_mux10_enum =
  8438. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX10_CFG0, 0, 7,
  8439. amic_mux_text);
  8440. static const struct soc_enum tx_amic_mux11_enum =
  8441. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX11_CFG0, 0, 7,
  8442. amic_mux_text);
  8443. static const struct soc_enum tx_amic_mux12_enum =
  8444. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX12_CFG0, 0, 7,
  8445. amic_mux_text);
  8446. static const struct soc_enum tx_amic_mux13_enum =
  8447. SOC_ENUM_SINGLE(WCD9335_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 0, 7,
  8448. amic_mux_text);
  8449. static const struct soc_enum sb_tx0_mux_enum =
  8450. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 0, 4,
  8451. sb_tx0_mux_text);
  8452. static const struct soc_enum sb_tx1_mux_enum =
  8453. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 2, 4,
  8454. sb_tx1_mux_text);
  8455. static const struct soc_enum sb_tx2_mux_enum =
  8456. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 4, 4,
  8457. sb_tx2_mux_text);
  8458. static const struct soc_enum sb_tx3_mux_enum =
  8459. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 6, 4,
  8460. sb_tx3_mux_text);
  8461. static const struct soc_enum sb_tx4_mux_enum =
  8462. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 0, 4,
  8463. sb_tx4_mux_text);
  8464. static const struct soc_enum sb_tx5_mux_enum =
  8465. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 2, 4,
  8466. sb_tx5_mux_text);
  8467. static const struct soc_enum sb_tx6_mux_enum =
  8468. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 4, 4,
  8469. sb_tx6_mux_text);
  8470. static const struct soc_enum sb_tx7_mux_enum =
  8471. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1, 6, 4,
  8472. sb_tx7_mux_text);
  8473. static const struct soc_enum sb_tx8_mux_enum =
  8474. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 0, 4,
  8475. sb_tx8_mux_text);
  8476. static const struct soc_enum sb_tx9_mux_enum =
  8477. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 2, 3,
  8478. sb_tx9_mux_text);
  8479. static const struct soc_enum sb_tx10_mux_enum =
  8480. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2, 4, 3,
  8481. sb_tx10_mux_text);
  8482. static const struct soc_enum sb_tx11_mux_enum =
  8483. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX11_INP_CFG, 0, 4,
  8484. sb_tx11_mux_text);
  8485. static const struct soc_enum sb_tx11_inp1_mux_enum =
  8486. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 0, 10,
  8487. sb_tx11_inp1_mux_text);
  8488. static const struct soc_enum sb_tx13_mux_enum =
  8489. SOC_ENUM_SINGLE(WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3, 4, 3,
  8490. sb_tx13_mux_text);
  8491. static const struct soc_enum tx13_inp_mux_enum =
  8492. SOC_ENUM_SINGLE(WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG, 0, 3,
  8493. tx13_inp_mux_text);
  8494. static const struct soc_enum rx_mix_tx0_mux_enum =
  8495. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 0, 14,
  8496. rx_echo_mux_text);
  8497. static const struct soc_enum rx_mix_tx1_mux_enum =
  8498. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG0, 4, 14,
  8499. rx_echo_mux_text);
  8500. static const struct soc_enum rx_mix_tx2_mux_enum =
  8501. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 0, 14,
  8502. rx_echo_mux_text);
  8503. static const struct soc_enum rx_mix_tx3_mux_enum =
  8504. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG1, 4, 14,
  8505. rx_echo_mux_text);
  8506. static const struct soc_enum rx_mix_tx4_mux_enum =
  8507. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 0, 14,
  8508. rx_echo_mux_text);
  8509. static const struct soc_enum rx_mix_tx5_mux_enum =
  8510. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG2, 4, 14,
  8511. rx_echo_mux_text);
  8512. static const struct soc_enum rx_mix_tx6_mux_enum =
  8513. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 0, 14,
  8514. rx_echo_mux_text);
  8515. static const struct soc_enum rx_mix_tx7_mux_enum =
  8516. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG3, 4, 14,
  8517. rx_echo_mux_text);
  8518. static const struct soc_enum rx_mix_tx8_mux_enum =
  8519. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_RX_MIX_CFG4, 0, 14,
  8520. rx_echo_mux_text);
  8521. static const struct soc_enum iir0_inp0_mux_enum =
  8522. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0, 0, 18,
  8523. iir_inp_mux_text);
  8524. static const struct soc_enum iir0_inp1_mux_enum =
  8525. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1, 0, 18,
  8526. iir_inp_mux_text);
  8527. static const struct soc_enum iir0_inp2_mux_enum =
  8528. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2, 0, 18,
  8529. iir_inp_mux_text);
  8530. static const struct soc_enum iir0_inp3_mux_enum =
  8531. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3, 0, 18,
  8532. iir_inp_mux_text);
  8533. static const struct soc_enum iir1_inp0_mux_enum =
  8534. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0, 0, 18,
  8535. iir_inp_mux_text);
  8536. static const struct soc_enum iir1_inp1_mux_enum =
  8537. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1, 0, 18,
  8538. iir_inp_mux_text);
  8539. static const struct soc_enum iir1_inp2_mux_enum =
  8540. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2, 0, 18,
  8541. iir_inp_mux_text);
  8542. static const struct soc_enum iir1_inp3_mux_enum =
  8543. SOC_ENUM_SINGLE(WCD9335_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3, 0, 18,
  8544. iir_inp_mux_text);
  8545. static const struct soc_enum rx_int0_dem_inp_mux_enum =
  8546. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_SEC0, 0,
  8547. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8548. rx_int_dem_inp_mux_text);
  8549. static const struct soc_enum rx_int1_dem_inp_mux_enum =
  8550. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_SEC0, 0,
  8551. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8552. rx_int_dem_inp_mux_text);
  8553. static const struct soc_enum rx_int2_dem_inp_mux_enum =
  8554. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_SEC0, 0,
  8555. ARRAY_SIZE(rx_int_dem_inp_mux_text),
  8556. rx_int_dem_inp_mux_text);
  8557. static const struct soc_enum rx_int0_interp_mux_enum =
  8558. SOC_ENUM_SINGLE(WCD9335_CDC_RX0_RX_PATH_CTL, 5, 2,
  8559. rx_int0_interp_mux_text);
  8560. static const struct soc_enum rx_int1_interp_mux_enum =
  8561. SOC_ENUM_SINGLE(WCD9335_CDC_RX1_RX_PATH_CTL, 5, 2,
  8562. rx_int1_interp_mux_text);
  8563. static const struct soc_enum rx_int2_interp_mux_enum =
  8564. SOC_ENUM_SINGLE(WCD9335_CDC_RX2_RX_PATH_CTL, 5, 2,
  8565. rx_int2_interp_mux_text);
  8566. static const struct soc_enum rx_int3_interp_mux_enum =
  8567. SOC_ENUM_SINGLE(WCD9335_CDC_RX3_RX_PATH_CTL, 5, 2,
  8568. rx_int3_interp_mux_text);
  8569. static const struct soc_enum rx_int4_interp_mux_enum =
  8570. SOC_ENUM_SINGLE(WCD9335_CDC_RX4_RX_PATH_CTL, 5, 2,
  8571. rx_int4_interp_mux_text);
  8572. static const struct soc_enum rx_int5_interp_mux_enum =
  8573. SOC_ENUM_SINGLE(WCD9335_CDC_RX5_RX_PATH_CTL, 5, 2,
  8574. rx_int5_interp_mux_text);
  8575. static const struct soc_enum rx_int6_interp_mux_enum =
  8576. SOC_ENUM_SINGLE(WCD9335_CDC_RX6_RX_PATH_CTL, 5, 2,
  8577. rx_int6_interp_mux_text);
  8578. static const struct soc_enum rx_int7_interp_mux_enum =
  8579. SOC_ENUM_SINGLE(WCD9335_CDC_RX7_RX_PATH_CTL, 5, 2,
  8580. rx_int7_interp_mux_text);
  8581. static const struct soc_enum rx_int8_interp_mux_enum =
  8582. SOC_ENUM_SINGLE(WCD9335_CDC_RX8_RX_PATH_CTL, 5, 2,
  8583. rx_int8_interp_mux_text);
  8584. static const struct soc_enum mad_sel_enum =
  8585. SOC_ENUM_SINGLE(WCD9335_CPE_SS_CFG, 0, 2, mad_sel_text);
  8586. static const struct soc_enum anc0_fb_mux_enum =
  8587. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 0, 5,
  8588. anc0_fb_mux_text);
  8589. static const struct soc_enum anc1_fb_mux_enum =
  8590. SOC_ENUM_SINGLE(WCD9335_CDC_RX_INP_MUX_ANC_CFG0, 3, 3,
  8591. anc1_fb_mux_text);
  8592. static const struct snd_kcontrol_new rx_int0_dem_inp_mux =
  8593. SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum,
  8594. snd_soc_dapm_get_enum_double,
  8595. tasha_int_dem_inp_mux_put);
  8596. static const struct snd_kcontrol_new rx_int1_dem_inp_mux =
  8597. SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum,
  8598. snd_soc_dapm_get_enum_double,
  8599. tasha_int_dem_inp_mux_put);
  8600. static const struct snd_kcontrol_new rx_int2_dem_inp_mux =
  8601. SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum,
  8602. snd_soc_dapm_get_enum_double,
  8603. tasha_int_dem_inp_mux_put);
  8604. static const struct snd_kcontrol_new spl_src0_mux =
  8605. SOC_DAPM_ENUM("SPL SRC0 MUX Mux", spl_src0_mux_chain_enum);
  8606. static const struct snd_kcontrol_new spl_src1_mux =
  8607. SOC_DAPM_ENUM("SPL SRC1 MUX Mux", spl_src1_mux_chain_enum);
  8608. static const struct snd_kcontrol_new spl_src2_mux =
  8609. SOC_DAPM_ENUM("SPL SRC2 MUX Mux", spl_src2_mux_chain_enum);
  8610. static const struct snd_kcontrol_new spl_src3_mux =
  8611. SOC_DAPM_ENUM("SPL SRC3 MUX Mux", spl_src3_mux_chain_enum);
  8612. static const struct snd_kcontrol_new rx_int0_2_mux =
  8613. SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum);
  8614. static const struct snd_kcontrol_new rx_int1_2_mux =
  8615. SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum);
  8616. static const struct snd_kcontrol_new rx_int2_2_mux =
  8617. SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum);
  8618. static const struct snd_kcontrol_new rx_int3_2_mux =
  8619. SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum);
  8620. static const struct snd_kcontrol_new rx_int4_2_mux =
  8621. SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum);
  8622. static const struct snd_kcontrol_new rx_int5_2_mux =
  8623. SOC_DAPM_ENUM("RX INT5_2 MUX Mux", rx_int5_2_mux_chain_enum);
  8624. static const struct snd_kcontrol_new rx_int6_2_mux =
  8625. SOC_DAPM_ENUM("RX INT6_2 MUX Mux", rx_int6_2_mux_chain_enum);
  8626. static const struct snd_kcontrol_new rx_int7_2_mux =
  8627. SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum);
  8628. static const struct snd_kcontrol_new rx_int8_2_mux =
  8629. SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum);
  8630. static const struct snd_kcontrol_new int1_1_native_mux =
  8631. SOC_DAPM_ENUM("RX INT1_1 NATIVE MUX Mux", int1_1_native_enum);
  8632. static const struct snd_kcontrol_new int2_1_native_mux =
  8633. SOC_DAPM_ENUM("RX INT2_1 NATIVE MUX Mux", int2_1_native_enum);
  8634. static const struct snd_kcontrol_new int3_1_native_mux =
  8635. SOC_DAPM_ENUM("RX INT3_1 NATIVE MUX Mux", int3_1_native_enum);
  8636. static const struct snd_kcontrol_new int4_1_native_mux =
  8637. SOC_DAPM_ENUM("RX INT4_1 NATIVE MUX Mux", int4_1_native_enum);
  8638. static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux =
  8639. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum);
  8640. static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux =
  8641. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum);
  8642. static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux =
  8643. SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum);
  8644. static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux =
  8645. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum);
  8646. static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux =
  8647. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum);
  8648. static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux =
  8649. SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum);
  8650. static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux =
  8651. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum);
  8652. static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux =
  8653. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum);
  8654. static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux =
  8655. SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum);
  8656. static const struct snd_kcontrol_new rx_int3_1_mix_inp0_mux =
  8657. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum);
  8658. static const struct snd_kcontrol_new rx_int3_1_mix_inp1_mux =
  8659. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum);
  8660. static const struct snd_kcontrol_new rx_int3_1_mix_inp2_mux =
  8661. SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum);
  8662. static const struct snd_kcontrol_new rx_int4_1_mix_inp0_mux =
  8663. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum);
  8664. static const struct snd_kcontrol_new rx_int4_1_mix_inp1_mux =
  8665. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum);
  8666. static const struct snd_kcontrol_new rx_int4_1_mix_inp2_mux =
  8667. SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum);
  8668. static const struct snd_kcontrol_new rx_int5_1_mix_inp0_mux =
  8669. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP0 Mux", rx_int5_1_mix_inp0_chain_enum);
  8670. static const struct snd_kcontrol_new rx_int5_1_mix_inp1_mux =
  8671. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP1 Mux", rx_int5_1_mix_inp1_chain_enum);
  8672. static const struct snd_kcontrol_new rx_int5_1_mix_inp2_mux =
  8673. SOC_DAPM_ENUM("RX INT5_1 MIX1 INP2 Mux", rx_int5_1_mix_inp2_chain_enum);
  8674. static const struct snd_kcontrol_new rx_int6_1_mix_inp0_mux =
  8675. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP0 Mux", rx_int6_1_mix_inp0_chain_enum);
  8676. static const struct snd_kcontrol_new rx_int6_1_mix_inp1_mux =
  8677. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP1 Mux", rx_int6_1_mix_inp1_chain_enum);
  8678. static const struct snd_kcontrol_new rx_int6_1_mix_inp2_mux =
  8679. SOC_DAPM_ENUM("RX INT6_1 MIX1 INP2 Mux", rx_int6_1_mix_inp2_chain_enum);
  8680. static const struct snd_kcontrol_new rx_int7_1_mix_inp0_mux =
  8681. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum);
  8682. static const struct snd_kcontrol_new rx_int7_1_mix_inp1_mux =
  8683. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum);
  8684. static const struct snd_kcontrol_new rx_int7_1_mix_inp2_mux =
  8685. SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum);
  8686. static const struct snd_kcontrol_new rx_int8_1_mix_inp0_mux =
  8687. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum);
  8688. static const struct snd_kcontrol_new rx_int8_1_mix_inp1_mux =
  8689. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum);
  8690. static const struct snd_kcontrol_new rx_int8_1_mix_inp2_mux =
  8691. SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum);
  8692. static const struct snd_kcontrol_new rx_int0_mix2_inp_mux =
  8693. SOC_DAPM_ENUM("RX INT0 MIX2 INP Mux", rx_int0_sidetone_mix_chain_enum);
  8694. static const struct snd_kcontrol_new rx_int1_mix2_inp_mux =
  8695. SOC_DAPM_ENUM("RX INT1 MIX2 INP Mux", rx_int1_sidetone_mix_chain_enum);
  8696. static const struct snd_kcontrol_new rx_int2_mix2_inp_mux =
  8697. SOC_DAPM_ENUM("RX INT2 MIX2 INP Mux", rx_int2_sidetone_mix_chain_enum);
  8698. static const struct snd_kcontrol_new rx_int3_mix2_inp_mux =
  8699. SOC_DAPM_ENUM("RX INT3 MIX2 INP Mux", rx_int3_sidetone_mix_chain_enum);
  8700. static const struct snd_kcontrol_new rx_int4_mix2_inp_mux =
  8701. SOC_DAPM_ENUM("RX INT4 MIX2 INP Mux", rx_int4_sidetone_mix_chain_enum);
  8702. static const struct snd_kcontrol_new rx_int7_mix2_inp_mux =
  8703. SOC_DAPM_ENUM("RX INT7 MIX2 INP Mux", rx_int7_sidetone_mix_chain_enum);
  8704. static const struct snd_kcontrol_new tx_adc_mux0 =
  8705. SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_chain_enum,
  8706. snd_soc_dapm_get_enum_double,
  8707. tasha_put_dec_enum);
  8708. static const struct snd_kcontrol_new tx_adc_mux1 =
  8709. SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_chain_enum,
  8710. snd_soc_dapm_get_enum_double,
  8711. tasha_put_dec_enum);
  8712. static const struct snd_kcontrol_new tx_adc_mux2 =
  8713. SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_chain_enum,
  8714. snd_soc_dapm_get_enum_double,
  8715. tasha_put_dec_enum);
  8716. static const struct snd_kcontrol_new tx_adc_mux3 =
  8717. SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_chain_enum,
  8718. snd_soc_dapm_get_enum_double,
  8719. tasha_put_dec_enum);
  8720. static const struct snd_kcontrol_new tx_adc_mux4 =
  8721. SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_chain_enum,
  8722. snd_soc_dapm_get_enum_double,
  8723. tasha_put_dec_enum);
  8724. static const struct snd_kcontrol_new tx_adc_mux5 =
  8725. SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_chain_enum,
  8726. snd_soc_dapm_get_enum_double,
  8727. tasha_put_dec_enum);
  8728. static const struct snd_kcontrol_new tx_adc_mux6 =
  8729. SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_chain_enum,
  8730. snd_soc_dapm_get_enum_double,
  8731. tasha_put_dec_enum);
  8732. static const struct snd_kcontrol_new tx_adc_mux7 =
  8733. SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_chain_enum,
  8734. snd_soc_dapm_get_enum_double,
  8735. tasha_put_dec_enum);
  8736. static const struct snd_kcontrol_new tx_adc_mux8 =
  8737. SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_chain_enum,
  8738. snd_soc_dapm_get_enum_double,
  8739. tasha_put_dec_enum);
  8740. static const struct snd_kcontrol_new tx_adc_mux10 =
  8741. SOC_DAPM_ENUM("ADC MUX10 Mux", tx_adc_mux10_chain_enum);
  8742. static const struct snd_kcontrol_new tx_adc_mux11 =
  8743. SOC_DAPM_ENUM("ADC MUX11 Mux", tx_adc_mux11_chain_enum);
  8744. static const struct snd_kcontrol_new tx_adc_mux12 =
  8745. SOC_DAPM_ENUM("ADC MUX12 Mux", tx_adc_mux12_chain_enum);
  8746. static const struct snd_kcontrol_new tx_adc_mux13 =
  8747. SOC_DAPM_ENUM("ADC MUX13 Mux", tx_adc_mux13_chain_enum);
  8748. static const struct snd_kcontrol_new tx_dmic_mux0 =
  8749. SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum);
  8750. static const struct snd_kcontrol_new tx_dmic_mux1 =
  8751. SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum);
  8752. static const struct snd_kcontrol_new tx_dmic_mux2 =
  8753. SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum);
  8754. static const struct snd_kcontrol_new tx_dmic_mux3 =
  8755. SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum);
  8756. static const struct snd_kcontrol_new tx_dmic_mux4 =
  8757. SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum);
  8758. static const struct snd_kcontrol_new tx_dmic_mux5 =
  8759. SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum);
  8760. static const struct snd_kcontrol_new tx_dmic_mux6 =
  8761. SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum);
  8762. static const struct snd_kcontrol_new tx_dmic_mux7 =
  8763. SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum);
  8764. static const struct snd_kcontrol_new tx_dmic_mux8 =
  8765. SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum);
  8766. static const struct snd_kcontrol_new tx_dmic_mux10 =
  8767. SOC_DAPM_ENUM("DMIC MUX10 Mux", tx_dmic_mux10_enum);
  8768. static const struct snd_kcontrol_new tx_dmic_mux11 =
  8769. SOC_DAPM_ENUM("DMIC MUX11 Mux", tx_dmic_mux11_enum);
  8770. static const struct snd_kcontrol_new tx_dmic_mux12 =
  8771. SOC_DAPM_ENUM("DMIC MUX12 Mux", tx_dmic_mux12_enum);
  8772. static const struct snd_kcontrol_new tx_dmic_mux13 =
  8773. SOC_DAPM_ENUM("DMIC MUX13 Mux", tx_dmic_mux13_enum);
  8774. static const struct snd_kcontrol_new tx_amic_mux0 =
  8775. SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum);
  8776. static const struct snd_kcontrol_new tx_amic_mux1 =
  8777. SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum);
  8778. static const struct snd_kcontrol_new tx_amic_mux2 =
  8779. SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum);
  8780. static const struct snd_kcontrol_new tx_amic_mux3 =
  8781. SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum);
  8782. static const struct snd_kcontrol_new tx_amic_mux4 =
  8783. SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum);
  8784. static const struct snd_kcontrol_new tx_amic_mux5 =
  8785. SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum);
  8786. static const struct snd_kcontrol_new tx_amic_mux6 =
  8787. SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum);
  8788. static const struct snd_kcontrol_new tx_amic_mux7 =
  8789. SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum);
  8790. static const struct snd_kcontrol_new tx_amic_mux8 =
  8791. SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum);
  8792. static const struct snd_kcontrol_new tx_amic_mux10 =
  8793. SOC_DAPM_ENUM("AMIC MUX10 Mux", tx_amic_mux10_enum);
  8794. static const struct snd_kcontrol_new tx_amic_mux11 =
  8795. SOC_DAPM_ENUM("AMIC MUX11 Mux", tx_amic_mux11_enum);
  8796. static const struct snd_kcontrol_new tx_amic_mux12 =
  8797. SOC_DAPM_ENUM("AMIC MUX12 Mux", tx_amic_mux12_enum);
  8798. static const struct snd_kcontrol_new tx_amic_mux13 =
  8799. SOC_DAPM_ENUM("AMIC MUX13 Mux", tx_amic_mux13_enum);
  8800. static const struct snd_kcontrol_new sb_tx0_mux =
  8801. SOC_DAPM_ENUM("SLIM TX0 MUX Mux", sb_tx0_mux_enum);
  8802. static const struct snd_kcontrol_new sb_tx1_mux =
  8803. SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum);
  8804. static const struct snd_kcontrol_new sb_tx2_mux =
  8805. SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum);
  8806. static const struct snd_kcontrol_new sb_tx3_mux =
  8807. SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum);
  8808. static const struct snd_kcontrol_new sb_tx4_mux =
  8809. SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum);
  8810. static const struct snd_kcontrol_new sb_tx5_mux =
  8811. SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum);
  8812. static const struct snd_kcontrol_new sb_tx6_mux =
  8813. SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum);
  8814. static const struct snd_kcontrol_new sb_tx7_mux =
  8815. SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum);
  8816. static const struct snd_kcontrol_new sb_tx8_mux =
  8817. SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum);
  8818. static const struct snd_kcontrol_new sb_tx9_mux =
  8819. SOC_DAPM_ENUM("SLIM TX9 MUX Mux", sb_tx9_mux_enum);
  8820. static const struct snd_kcontrol_new sb_tx10_mux =
  8821. SOC_DAPM_ENUM("SLIM TX10 MUX Mux", sb_tx10_mux_enum);
  8822. static const struct snd_kcontrol_new sb_tx11_mux =
  8823. SOC_DAPM_ENUM("SLIM TX11 MUX Mux", sb_tx11_mux_enum);
  8824. static const struct snd_kcontrol_new sb_tx11_inp1_mux =
  8825. SOC_DAPM_ENUM("SLIM TX11 INP1 MUX Mux", sb_tx11_inp1_mux_enum);
  8826. static const struct snd_kcontrol_new sb_tx13_mux =
  8827. SOC_DAPM_ENUM("SLIM TX13 MUX Mux", sb_tx13_mux_enum);
  8828. static const struct snd_kcontrol_new tx13_inp_mux =
  8829. SOC_DAPM_ENUM("TX13 INP MUX Mux", tx13_inp_mux_enum);
  8830. static const struct snd_kcontrol_new rx_mix_tx0_mux =
  8831. SOC_DAPM_ENUM("RX MIX TX0 MUX Mux", rx_mix_tx0_mux_enum);
  8832. static const struct snd_kcontrol_new rx_mix_tx1_mux =
  8833. SOC_DAPM_ENUM("RX MIX TX1 MUX Mux", rx_mix_tx1_mux_enum);
  8834. static const struct snd_kcontrol_new rx_mix_tx2_mux =
  8835. SOC_DAPM_ENUM("RX MIX TX2 MUX Mux", rx_mix_tx2_mux_enum);
  8836. static const struct snd_kcontrol_new rx_mix_tx3_mux =
  8837. SOC_DAPM_ENUM("RX MIX TX3 MUX Mux", rx_mix_tx3_mux_enum);
  8838. static const struct snd_kcontrol_new rx_mix_tx4_mux =
  8839. SOC_DAPM_ENUM("RX MIX TX4 MUX Mux", rx_mix_tx4_mux_enum);
  8840. static const struct snd_kcontrol_new rx_mix_tx5_mux =
  8841. SOC_DAPM_ENUM("RX MIX TX5 MUX Mux", rx_mix_tx5_mux_enum);
  8842. static const struct snd_kcontrol_new rx_mix_tx6_mux =
  8843. SOC_DAPM_ENUM("RX MIX TX6 MUX Mux", rx_mix_tx6_mux_enum);
  8844. static const struct snd_kcontrol_new rx_mix_tx7_mux =
  8845. SOC_DAPM_ENUM("RX MIX TX7 MUX Mux", rx_mix_tx7_mux_enum);
  8846. static const struct snd_kcontrol_new rx_mix_tx8_mux =
  8847. SOC_DAPM_ENUM("RX MIX TX8 MUX Mux", rx_mix_tx8_mux_enum);
  8848. static const struct snd_kcontrol_new iir0_inp0_mux =
  8849. SOC_DAPM_ENUM("IIR0 INP0 Mux", iir0_inp0_mux_enum);
  8850. static const struct snd_kcontrol_new iir0_inp1_mux =
  8851. SOC_DAPM_ENUM("IIR0 INP1 Mux", iir0_inp1_mux_enum);
  8852. static const struct snd_kcontrol_new iir0_inp2_mux =
  8853. SOC_DAPM_ENUM("IIR0 INP2 Mux", iir0_inp2_mux_enum);
  8854. static const struct snd_kcontrol_new iir0_inp3_mux =
  8855. SOC_DAPM_ENUM("IIR0 INP3 Mux", iir0_inp3_mux_enum);
  8856. static const struct snd_kcontrol_new iir1_inp0_mux =
  8857. SOC_DAPM_ENUM("IIR1 INP0 Mux", iir1_inp0_mux_enum);
  8858. static const struct snd_kcontrol_new iir1_inp1_mux =
  8859. SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum);
  8860. static const struct snd_kcontrol_new iir1_inp2_mux =
  8861. SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum);
  8862. static const struct snd_kcontrol_new iir1_inp3_mux =
  8863. SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum);
  8864. static const struct snd_kcontrol_new rx_int0_interp_mux =
  8865. SOC_DAPM_ENUM("RX INT0 INTERP Mux", rx_int0_interp_mux_enum);
  8866. static const struct snd_kcontrol_new rx_int1_interp_mux =
  8867. SOC_DAPM_ENUM("RX INT1 INTERP Mux", rx_int1_interp_mux_enum);
  8868. static const struct snd_kcontrol_new rx_int2_interp_mux =
  8869. SOC_DAPM_ENUM("RX INT2 INTERP Mux", rx_int2_interp_mux_enum);
  8870. static const struct snd_kcontrol_new rx_int3_interp_mux =
  8871. SOC_DAPM_ENUM("RX INT3 INTERP Mux", rx_int3_interp_mux_enum);
  8872. static const struct snd_kcontrol_new rx_int4_interp_mux =
  8873. SOC_DAPM_ENUM("RX INT4 INTERP Mux", rx_int4_interp_mux_enum);
  8874. static const struct snd_kcontrol_new rx_int5_interp_mux =
  8875. SOC_DAPM_ENUM("RX INT5 INTERP Mux", rx_int5_interp_mux_enum);
  8876. static const struct snd_kcontrol_new rx_int6_interp_mux =
  8877. SOC_DAPM_ENUM("RX INT6 INTERP Mux", rx_int6_interp_mux_enum);
  8878. static const struct snd_kcontrol_new rx_int7_interp_mux =
  8879. SOC_DAPM_ENUM("RX INT7 INTERP Mux", rx_int7_interp_mux_enum);
  8880. static const struct snd_kcontrol_new rx_int8_interp_mux =
  8881. SOC_DAPM_ENUM("RX INT8 INTERP Mux", rx_int8_interp_mux_enum);
  8882. static const struct snd_kcontrol_new mad_sel_mux =
  8883. SOC_DAPM_ENUM("MAD_SEL MUX Mux", mad_sel_enum);
  8884. static const struct snd_kcontrol_new aif4_mad_switch =
  8885. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 5, 1, 0);
  8886. static const struct snd_kcontrol_new mad_brdcst_switch =
  8887. SOC_DAPM_SINGLE("Switch", WCD9335_CPE_SS_CFG, 6, 1, 0);
  8888. static const struct snd_kcontrol_new aif4_switch_mixer_controls =
  8889. SOC_SINGLE_EXT("Switch", SND_SOC_NOPM,
  8890. 0, 1, 0, tasha_codec_aif4_mixer_switch_get,
  8891. tasha_codec_aif4_mixer_switch_put);
  8892. static const struct snd_kcontrol_new anc_hphl_switch =
  8893. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8894. static const struct snd_kcontrol_new anc_hphr_switch =
  8895. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8896. static const struct snd_kcontrol_new anc_ear_switch =
  8897. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8898. static const struct snd_kcontrol_new anc_ear_spkr_switch =
  8899. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8900. static const struct snd_kcontrol_new anc_lineout1_switch =
  8901. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8902. static const struct snd_kcontrol_new anc_lineout2_switch =
  8903. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8904. static const struct snd_kcontrol_new anc_spkr_pa_switch =
  8905. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0);
  8906. static const struct snd_kcontrol_new adc_us_mux0_switch =
  8907. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8908. static const struct snd_kcontrol_new adc_us_mux1_switch =
  8909. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8910. static const struct snd_kcontrol_new adc_us_mux2_switch =
  8911. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8912. static const struct snd_kcontrol_new adc_us_mux3_switch =
  8913. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8914. static const struct snd_kcontrol_new adc_us_mux4_switch =
  8915. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8916. static const struct snd_kcontrol_new adc_us_mux5_switch =
  8917. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8918. static const struct snd_kcontrol_new adc_us_mux6_switch =
  8919. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8920. static const struct snd_kcontrol_new adc_us_mux7_switch =
  8921. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8922. static const struct snd_kcontrol_new adc_us_mux8_switch =
  8923. SOC_DAPM_SINGLE("US_Switch", SND_SOC_NOPM, 0, 1, 0);
  8924. static const struct snd_kcontrol_new anc0_fb_mux =
  8925. SOC_DAPM_ENUM("ANC0 FB MUX Mux", anc0_fb_mux_enum);
  8926. static const struct snd_kcontrol_new anc1_fb_mux =
  8927. SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum);
  8928. static int tasha_codec_ec_buf_mux_enable(struct snd_soc_dapm_widget *w,
  8929. struct snd_kcontrol *kcontrol,
  8930. int event)
  8931. {
  8932. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  8933. dev_dbg(codec->dev, "%s: event = %d name = %s\n",
  8934. __func__, event, w->name);
  8935. switch (event) {
  8936. case SND_SOC_DAPM_POST_PMU:
  8937. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x3B);
  8938. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x08);
  8939. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8940. 0x08, 0x08);
  8941. break;
  8942. case SND_SOC_DAPM_POST_PMD:
  8943. snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0,
  8944. 0x08, 0x00);
  8945. snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x00);
  8946. snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x00);
  8947. break;
  8948. }
  8949. return 0;
  8950. };
  8951. static const char * const ec_buf_mux_text[] = {
  8952. "ZERO", "RXMIXEC", "SB_RX0", "SB_RX1", "SB_RX2", "SB_RX3",
  8953. "I2S_RX_SD0_L", "I2S_RX_SD0_R", "I2S_RX_SD1_L", "I2S_RX_SD1_R",
  8954. "DEC1"
  8955. };
  8956. static SOC_ENUM_SINGLE_DECL(ec_buf_mux_enum, WCD9335_CPE_SS_US_EC_MUX_CFG,
  8957. 0, ec_buf_mux_text);
  8958. static const struct snd_kcontrol_new ec_buf_mux =
  8959. SOC_DAPM_ENUM("EC BUF Mux", ec_buf_mux_enum);
  8960. static const struct snd_soc_dapm_widget tasha_dapm_widgets[] = {
  8961. SND_SOC_DAPM_OUTPUT("EAR"),
  8962. SND_SOC_DAPM_OUTPUT("ANC EAR"),
  8963. SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM,
  8964. AIF1_PB, 0, tasha_codec_enable_slimrx,
  8965. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8966. SND_SOC_DAPM_POST_PMD),
  8967. SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM,
  8968. AIF2_PB, 0, tasha_codec_enable_slimrx,
  8969. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8970. SND_SOC_DAPM_POST_PMD),
  8971. SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM,
  8972. AIF3_PB, 0, tasha_codec_enable_slimrx,
  8973. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8974. SND_SOC_DAPM_POST_PMD),
  8975. SND_SOC_DAPM_AIF_IN_E("AIF4 PB", "AIF4 Playback", 0, SND_SOC_NOPM,
  8976. AIF4_PB, 0, tasha_codec_enable_slimrx,
  8977. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
  8978. SND_SOC_DAPM_POST_PMD),
  8979. SND_SOC_DAPM_AIF_IN_E("AIF MIX1 PB", "AIF Mix Playback", 0,
  8980. SND_SOC_NOPM, AIF_MIX1_PB, 0,
  8981. 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_MUX("SLIM RX0 MUX", SND_SOC_NOPM, TASHA_RX0, 0,
  8985. &slim_rx_mux[TASHA_RX0]),
  8986. SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TASHA_RX1, 0,
  8987. &slim_rx_mux[TASHA_RX1]),
  8988. SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TASHA_RX2, 0,
  8989. &slim_rx_mux[TASHA_RX2]),
  8990. SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TASHA_RX3, 0,
  8991. &slim_rx_mux[TASHA_RX3]),
  8992. SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TASHA_RX4, 0,
  8993. &slim_rx_mux[TASHA_RX4]),
  8994. SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TASHA_RX5, 0,
  8995. &slim_rx_mux[TASHA_RX5]),
  8996. SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, TASHA_RX6, 0,
  8997. &slim_rx_mux[TASHA_RX6]),
  8998. SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, TASHA_RX7, 0,
  8999. &slim_rx_mux[TASHA_RX7]),
  9000. SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
  9001. SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9002. SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9003. SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
  9004. SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
  9005. SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0),
  9006. SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0),
  9007. SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0),
  9008. SND_SOC_DAPM_MUX_E("SPL SRC0 MUX", SND_SOC_NOPM, SPLINE_SRC0, 0,
  9009. &spl_src0_mux, tasha_codec_enable_spline_resampler,
  9010. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9011. SND_SOC_DAPM_MUX_E("SPL SRC1 MUX", SND_SOC_NOPM, SPLINE_SRC1, 0,
  9012. &spl_src1_mux, tasha_codec_enable_spline_resampler,
  9013. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9014. SND_SOC_DAPM_MUX_E("SPL SRC2 MUX", SND_SOC_NOPM, SPLINE_SRC2, 0,
  9015. &spl_src2_mux, tasha_codec_enable_spline_resampler,
  9016. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9017. SND_SOC_DAPM_MUX_E("SPL SRC3 MUX", SND_SOC_NOPM, SPLINE_SRC3, 0,
  9018. &spl_src3_mux, tasha_codec_enable_spline_resampler,
  9019. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9020. SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
  9021. 5, 0, &rx_int0_2_mux, tasha_codec_enable_mix_path,
  9022. SND_SOC_DAPM_POST_PMU),
  9023. SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
  9024. 5, 0, &rx_int1_2_mux, tasha_codec_enable_mix_path,
  9025. SND_SOC_DAPM_POST_PMU),
  9026. SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
  9027. 5, 0, &rx_int2_2_mux, tasha_codec_enable_mix_path,
  9028. SND_SOC_DAPM_POST_PMU),
  9029. SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", WCD9335_CDC_RX3_RX_PATH_MIX_CTL,
  9030. 5, 0, &rx_int3_2_mux, tasha_codec_enable_mix_path,
  9031. SND_SOC_DAPM_POST_PMU),
  9032. SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", WCD9335_CDC_RX4_RX_PATH_MIX_CTL,
  9033. 5, 0, &rx_int4_2_mux, tasha_codec_enable_mix_path,
  9034. SND_SOC_DAPM_POST_PMU),
  9035. SND_SOC_DAPM_MUX_E("RX INT5_2 MUX", WCD9335_CDC_RX5_RX_PATH_MIX_CTL,
  9036. 5, 0, &rx_int5_2_mux, tasha_codec_enable_mix_path,
  9037. SND_SOC_DAPM_POST_PMU),
  9038. SND_SOC_DAPM_MUX_E("RX INT6_2 MUX", WCD9335_CDC_RX6_RX_PATH_MIX_CTL,
  9039. 5, 0, &rx_int6_2_mux, tasha_codec_enable_mix_path,
  9040. SND_SOC_DAPM_POST_PMU),
  9041. SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", WCD9335_CDC_RX7_RX_PATH_MIX_CTL,
  9042. 5, 0, &rx_int7_2_mux, tasha_codec_enable_mix_path,
  9043. SND_SOC_DAPM_POST_PMU),
  9044. SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", WCD9335_CDC_RX8_RX_PATH_MIX_CTL,
  9045. 5, 0, &rx_int8_2_mux, tasha_codec_enable_mix_path,
  9046. SND_SOC_DAPM_POST_PMU),
  9047. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9048. &rx_int0_1_mix_inp0_mux),
  9049. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9050. &rx_int0_1_mix_inp1_mux),
  9051. SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9052. &rx_int0_1_mix_inp2_mux),
  9053. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9054. &rx_int1_1_mix_inp0_mux),
  9055. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9056. &rx_int1_1_mix_inp1_mux),
  9057. SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9058. &rx_int1_1_mix_inp2_mux),
  9059. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9060. &rx_int2_1_mix_inp0_mux),
  9061. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9062. &rx_int2_1_mix_inp1_mux),
  9063. SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9064. &rx_int2_1_mix_inp2_mux),
  9065. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9066. &rx_int3_1_mix_inp0_mux),
  9067. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9068. &rx_int3_1_mix_inp1_mux),
  9069. SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9070. &rx_int3_1_mix_inp2_mux),
  9071. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9072. &rx_int4_1_mix_inp0_mux),
  9073. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9074. &rx_int4_1_mix_inp1_mux),
  9075. SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9076. &rx_int4_1_mix_inp2_mux),
  9077. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9078. &rx_int5_1_mix_inp0_mux),
  9079. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9080. &rx_int5_1_mix_inp1_mux),
  9081. SND_SOC_DAPM_MUX("RX INT5_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9082. &rx_int5_1_mix_inp2_mux),
  9083. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9084. &rx_int6_1_mix_inp0_mux),
  9085. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9086. &rx_int6_1_mix_inp1_mux),
  9087. SND_SOC_DAPM_MUX("RX INT6_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9088. &rx_int6_1_mix_inp2_mux),
  9089. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9090. &rx_int7_1_mix_inp0_mux, tasha_codec_enable_swr,
  9091. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9092. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9093. &rx_int7_1_mix_inp1_mux, tasha_codec_enable_swr,
  9094. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9095. SND_SOC_DAPM_MUX_E("RX INT7_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9096. &rx_int7_1_mix_inp2_mux, tasha_codec_enable_swr,
  9097. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9098. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP0", SND_SOC_NOPM, 0, 0,
  9099. &rx_int8_1_mix_inp0_mux, tasha_codec_enable_swr,
  9100. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9101. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
  9102. &rx_int8_1_mix_inp1_mux, tasha_codec_enable_swr,
  9103. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9104. SND_SOC_DAPM_MUX_E("RX INT8_1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
  9105. &rx_int8_1_mix_inp2_mux, tasha_codec_enable_swr,
  9106. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9107. SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9108. SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9109. SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9110. SND_SOC_DAPM_MIXER("RX INT1 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9111. rx_int1_spline_mix_switch,
  9112. ARRAY_SIZE(rx_int1_spline_mix_switch)),
  9113. SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9114. SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9115. SND_SOC_DAPM_MIXER("RX INT2 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9116. rx_int2_spline_mix_switch,
  9117. ARRAY_SIZE(rx_int2_spline_mix_switch)),
  9118. SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9119. SND_SOC_DAPM_MIXER("RX INT3_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9120. SND_SOC_DAPM_MIXER("RX INT3 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9121. rx_int3_spline_mix_switch,
  9122. ARRAY_SIZE(rx_int3_spline_mix_switch)),
  9123. SND_SOC_DAPM_MIXER("RX INT3 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9124. SND_SOC_DAPM_MIXER("RX INT4_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9125. SND_SOC_DAPM_MIXER("RX INT4 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9126. rx_int4_spline_mix_switch,
  9127. ARRAY_SIZE(rx_int4_spline_mix_switch)),
  9128. SND_SOC_DAPM_MIXER("RX INT4 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9129. SND_SOC_DAPM_MIXER("RX INT5_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9130. SND_SOC_DAPM_MIXER("RX INT5 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9131. rx_int5_spline_mix_switch,
  9132. ARRAY_SIZE(rx_int5_spline_mix_switch)),
  9133. SND_SOC_DAPM_MIXER("RX INT5 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9134. SND_SOC_DAPM_MIXER("RX INT6_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9135. SND_SOC_DAPM_MIXER("RX INT6 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9136. rx_int6_spline_mix_switch,
  9137. ARRAY_SIZE(rx_int6_spline_mix_switch)),
  9138. SND_SOC_DAPM_MIXER("RX INT6 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9139. SND_SOC_DAPM_MIXER("RX INT7_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9140. SND_SOC_DAPM_MIXER("RX INT7 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9141. SND_SOC_DAPM_MIXER("RX INT7 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9142. rx_int7_spline_mix_switch,
  9143. ARRAY_SIZE(rx_int7_spline_mix_switch)),
  9144. SND_SOC_DAPM_MIXER("RX INT8_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
  9145. SND_SOC_DAPM_MIXER("RX INT8 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  9146. SND_SOC_DAPM_MIXER("RX INT8 SPLINE MIX", SND_SOC_NOPM, 0, 0,
  9147. rx_int8_spline_mix_switch,
  9148. ARRAY_SIZE(rx_int8_spline_mix_switch)),
  9149. SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9150. SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9151. SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9152. SND_SOC_DAPM_MIXER("RX INT3 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9153. SND_SOC_DAPM_MIXER("RX INT4 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9154. SND_SOC_DAPM_MIXER("RX INT5 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9155. SND_SOC_DAPM_MIXER("RX INT6 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9156. SND_SOC_DAPM_MIXER("RX INT7 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
  9157. SND_SOC_DAPM_MIXER_E("RX INT7 CHAIN", SND_SOC_NOPM, 0, 0,
  9158. NULL, 0, tasha_codec_spk_boost_event,
  9159. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9160. SND_SOC_DAPM_MIXER_E("RX INT8 CHAIN", SND_SOC_NOPM, 0, 0,
  9161. NULL, 0, tasha_codec_spk_boost_event,
  9162. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9163. SND_SOC_DAPM_MIXER_E("RX INT5 VBAT", SND_SOC_NOPM, 0, 0,
  9164. rx_int5_vbat_mix_switch,
  9165. ARRAY_SIZE(rx_int5_vbat_mix_switch),
  9166. tasha_codec_vbat_enable_event,
  9167. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9168. SND_SOC_DAPM_MIXER_E("RX INT6 VBAT", SND_SOC_NOPM, 0, 0,
  9169. rx_int6_vbat_mix_switch,
  9170. ARRAY_SIZE(rx_int6_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 INT7 VBAT", SND_SOC_NOPM, 0, 0,
  9174. rx_int7_vbat_mix_switch,
  9175. ARRAY_SIZE(rx_int7_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 INT8 VBAT", SND_SOC_NOPM, 0, 0,
  9179. rx_int8_vbat_mix_switch,
  9180. ARRAY_SIZE(rx_int8_vbat_mix_switch),
  9181. tasha_codec_vbat_enable_event,
  9182. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9183. SND_SOC_DAPM_MUX("RX INT0 MIX2 INP", WCD9335_CDC_RX0_RX_PATH_CFG1, 4,
  9184. 0, &rx_int0_mix2_inp_mux),
  9185. SND_SOC_DAPM_MUX("RX INT1 MIX2 INP", WCD9335_CDC_RX1_RX_PATH_CFG1, 4,
  9186. 0, &rx_int1_mix2_inp_mux),
  9187. SND_SOC_DAPM_MUX("RX INT2 MIX2 INP", WCD9335_CDC_RX2_RX_PATH_CFG1, 4,
  9188. 0, &rx_int2_mix2_inp_mux),
  9189. SND_SOC_DAPM_MUX("RX INT3 MIX2 INP", WCD9335_CDC_RX3_RX_PATH_CFG1, 4,
  9190. 0, &rx_int3_mix2_inp_mux),
  9191. SND_SOC_DAPM_MUX("RX INT4 MIX2 INP", WCD9335_CDC_RX4_RX_PATH_CFG1, 4,
  9192. 0, &rx_int4_mix2_inp_mux),
  9193. SND_SOC_DAPM_MUX("RX INT7 MIX2 INP", WCD9335_CDC_RX7_RX_PATH_CFG1, 4,
  9194. 0, &rx_int7_mix2_inp_mux),
  9195. SND_SOC_DAPM_MUX("SLIM TX0 MUX", SND_SOC_NOPM, TASHA_TX0, 0,
  9196. &sb_tx0_mux),
  9197. SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TASHA_TX1, 0,
  9198. &sb_tx1_mux),
  9199. SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TASHA_TX2, 0,
  9200. &sb_tx2_mux),
  9201. SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TASHA_TX3, 0,
  9202. &sb_tx3_mux),
  9203. SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TASHA_TX4, 0,
  9204. &sb_tx4_mux),
  9205. SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TASHA_TX5, 0,
  9206. &sb_tx5_mux),
  9207. SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, TASHA_TX6, 0,
  9208. &sb_tx6_mux),
  9209. SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, TASHA_TX7, 0,
  9210. &sb_tx7_mux),
  9211. SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, TASHA_TX8, 0,
  9212. &sb_tx8_mux),
  9213. SND_SOC_DAPM_MUX("SLIM TX9 MUX", SND_SOC_NOPM, TASHA_TX9, 0,
  9214. &sb_tx9_mux),
  9215. SND_SOC_DAPM_MUX("SLIM TX10 MUX", SND_SOC_NOPM, TASHA_TX10, 0,
  9216. &sb_tx10_mux),
  9217. SND_SOC_DAPM_MUX("SLIM TX11 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9218. &sb_tx11_mux),
  9219. SND_SOC_DAPM_MUX("SLIM TX11 INP1 MUX", SND_SOC_NOPM, TASHA_TX11, 0,
  9220. &sb_tx11_inp1_mux),
  9221. SND_SOC_DAPM_MUX("SLIM TX13 MUX", SND_SOC_NOPM, TASHA_TX13, 0,
  9222. &sb_tx13_mux),
  9223. SND_SOC_DAPM_MUX("TX13 INP MUX", SND_SOC_NOPM, 0, 0,
  9224. &tx13_inp_mux),
  9225. SND_SOC_DAPM_MUX_E("ADC MUX0", WCD9335_CDC_TX0_TX_PATH_CTL, 5, 0,
  9226. &tx_adc_mux0, tasha_codec_enable_dec,
  9227. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9228. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9229. SND_SOC_DAPM_MUX_E("ADC MUX1", WCD9335_CDC_TX1_TX_PATH_CTL, 5, 0,
  9230. &tx_adc_mux1, tasha_codec_enable_dec,
  9231. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9232. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9233. SND_SOC_DAPM_MUX_E("ADC MUX2", WCD9335_CDC_TX2_TX_PATH_CTL, 5, 0,
  9234. &tx_adc_mux2, tasha_codec_enable_dec,
  9235. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9236. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9237. SND_SOC_DAPM_MUX_E("ADC MUX3", WCD9335_CDC_TX3_TX_PATH_CTL, 5, 0,
  9238. &tx_adc_mux3, tasha_codec_enable_dec,
  9239. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9240. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9241. SND_SOC_DAPM_MUX_E("ADC MUX4", WCD9335_CDC_TX4_TX_PATH_CTL, 5, 0,
  9242. &tx_adc_mux4, tasha_codec_enable_dec,
  9243. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9244. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9245. SND_SOC_DAPM_MUX_E("ADC MUX5", WCD9335_CDC_TX5_TX_PATH_CTL, 5, 0,
  9246. &tx_adc_mux5, tasha_codec_enable_dec,
  9247. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9248. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9249. SND_SOC_DAPM_MUX_E("ADC MUX6", WCD9335_CDC_TX6_TX_PATH_CTL, 5, 0,
  9250. &tx_adc_mux6, tasha_codec_enable_dec,
  9251. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9252. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9253. SND_SOC_DAPM_MUX_E("ADC MUX7", WCD9335_CDC_TX7_TX_PATH_CTL, 5, 0,
  9254. &tx_adc_mux7, tasha_codec_enable_dec,
  9255. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9256. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9257. SND_SOC_DAPM_MUX_E("ADC MUX8", WCD9335_CDC_TX8_TX_PATH_CTL, 5, 0,
  9258. &tx_adc_mux8, tasha_codec_enable_dec,
  9259. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9260. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9261. SND_SOC_DAPM_MUX_E("ADC MUX10", SND_SOC_NOPM, 10, 0,
  9262. &tx_adc_mux10, tasha_codec_tx_adc_cfg,
  9263. SND_SOC_DAPM_POST_PMU),
  9264. SND_SOC_DAPM_MUX_E("ADC MUX11", SND_SOC_NOPM, 11, 0,
  9265. &tx_adc_mux11, tasha_codec_tx_adc_cfg,
  9266. SND_SOC_DAPM_POST_PMU),
  9267. SND_SOC_DAPM_MUX_E("ADC MUX12", SND_SOC_NOPM, 12, 0,
  9268. &tx_adc_mux12, tasha_codec_tx_adc_cfg,
  9269. SND_SOC_DAPM_POST_PMU),
  9270. SND_SOC_DAPM_MUX_E("ADC MUX13", SND_SOC_NOPM, 13, 0,
  9271. &tx_adc_mux13, tasha_codec_tx_adc_cfg,
  9272. SND_SOC_DAPM_POST_PMU),
  9273. SND_SOC_DAPM_MUX("DMIC MUX0", SND_SOC_NOPM, 0, 0,
  9274. &tx_dmic_mux0),
  9275. SND_SOC_DAPM_MUX("DMIC MUX1", SND_SOC_NOPM, 0, 0,
  9276. &tx_dmic_mux1),
  9277. SND_SOC_DAPM_MUX("DMIC MUX2", SND_SOC_NOPM, 0, 0,
  9278. &tx_dmic_mux2),
  9279. SND_SOC_DAPM_MUX("DMIC MUX3", SND_SOC_NOPM, 0, 0,
  9280. &tx_dmic_mux3),
  9281. SND_SOC_DAPM_MUX("DMIC MUX4", SND_SOC_NOPM, 0, 0,
  9282. &tx_dmic_mux4),
  9283. SND_SOC_DAPM_MUX("DMIC MUX5", SND_SOC_NOPM, 0, 0,
  9284. &tx_dmic_mux5),
  9285. SND_SOC_DAPM_MUX("DMIC MUX6", SND_SOC_NOPM, 0, 0,
  9286. &tx_dmic_mux6),
  9287. SND_SOC_DAPM_MUX("DMIC MUX7", SND_SOC_NOPM, 0, 0,
  9288. &tx_dmic_mux7),
  9289. SND_SOC_DAPM_MUX("DMIC MUX8", SND_SOC_NOPM, 0, 0,
  9290. &tx_dmic_mux8),
  9291. SND_SOC_DAPM_MUX("DMIC MUX10", SND_SOC_NOPM, 0, 0,
  9292. &tx_dmic_mux10),
  9293. SND_SOC_DAPM_MUX("DMIC MUX11", SND_SOC_NOPM, 0, 0,
  9294. &tx_dmic_mux11),
  9295. SND_SOC_DAPM_MUX("DMIC MUX12", SND_SOC_NOPM, 0, 0,
  9296. &tx_dmic_mux12),
  9297. SND_SOC_DAPM_MUX("DMIC MUX13", SND_SOC_NOPM, 0, 0,
  9298. &tx_dmic_mux13),
  9299. SND_SOC_DAPM_MUX("AMIC MUX0", SND_SOC_NOPM, 0, 0,
  9300. &tx_amic_mux0),
  9301. SND_SOC_DAPM_MUX("AMIC MUX1", SND_SOC_NOPM, 0, 0,
  9302. &tx_amic_mux1),
  9303. SND_SOC_DAPM_MUX("AMIC MUX2", SND_SOC_NOPM, 0, 0,
  9304. &tx_amic_mux2),
  9305. SND_SOC_DAPM_MUX("AMIC MUX3", SND_SOC_NOPM, 0, 0,
  9306. &tx_amic_mux3),
  9307. SND_SOC_DAPM_MUX("AMIC MUX4", SND_SOC_NOPM, 0, 0,
  9308. &tx_amic_mux4),
  9309. SND_SOC_DAPM_MUX("AMIC MUX5", SND_SOC_NOPM, 0, 0,
  9310. &tx_amic_mux5),
  9311. SND_SOC_DAPM_MUX("AMIC MUX6", SND_SOC_NOPM, 0, 0,
  9312. &tx_amic_mux6),
  9313. SND_SOC_DAPM_MUX("AMIC MUX7", SND_SOC_NOPM, 0, 0,
  9314. &tx_amic_mux7),
  9315. SND_SOC_DAPM_MUX("AMIC MUX8", SND_SOC_NOPM, 0, 0,
  9316. &tx_amic_mux8),
  9317. SND_SOC_DAPM_MUX("AMIC MUX10", SND_SOC_NOPM, 0, 0,
  9318. &tx_amic_mux10),
  9319. SND_SOC_DAPM_MUX("AMIC MUX11", SND_SOC_NOPM, 0, 0,
  9320. &tx_amic_mux11),
  9321. SND_SOC_DAPM_MUX("AMIC MUX12", SND_SOC_NOPM, 0, 0,
  9322. &tx_amic_mux12),
  9323. SND_SOC_DAPM_MUX("AMIC MUX13", SND_SOC_NOPM, 0, 0,
  9324. &tx_amic_mux13),
  9325. SND_SOC_DAPM_ADC_E("ADC1", NULL, WCD9335_ANA_AMIC1, 7, 0,
  9326. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9327. SND_SOC_DAPM_ADC_E("ADC2", NULL, WCD9335_ANA_AMIC2, 7, 0,
  9328. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9329. SND_SOC_DAPM_ADC_E("ADC3", NULL, WCD9335_ANA_AMIC3, 7, 0,
  9330. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9331. SND_SOC_DAPM_ADC_E("ADC4", NULL, WCD9335_ANA_AMIC4, 7, 0,
  9332. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9333. SND_SOC_DAPM_ADC_E("ADC5", NULL, WCD9335_ANA_AMIC5, 7, 0,
  9334. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9335. SND_SOC_DAPM_ADC_E("ADC6", NULL, WCD9335_ANA_AMIC6, 7, 0,
  9336. tasha_codec_enable_adc, SND_SOC_DAPM_PRE_PMU),
  9337. SND_SOC_DAPM_SUPPLY("RX INT1 NATIVE SUPPLY", SND_SOC_NOPM,
  9338. INTERP_HPHL, 0, tasha_enable_native_supply,
  9339. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9340. SND_SOC_DAPM_SUPPLY("RX INT2 NATIVE SUPPLY", SND_SOC_NOPM,
  9341. INTERP_HPHR, 0, tasha_enable_native_supply,
  9342. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9343. SND_SOC_DAPM_SUPPLY("RX INT3 NATIVE SUPPLY", SND_SOC_NOPM,
  9344. INTERP_LO1, 0, tasha_enable_native_supply,
  9345. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9346. SND_SOC_DAPM_SUPPLY("RX INT4 NATIVE SUPPLY", SND_SOC_NOPM,
  9347. INTERP_LO2, 0, tasha_enable_native_supply,
  9348. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
  9349. SND_SOC_DAPM_INPUT("AMIC1"),
  9350. SND_SOC_DAPM_MICBIAS_E("MIC BIAS1", SND_SOC_NOPM, 0, 0,
  9351. tasha_codec_enable_micbias,
  9352. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9353. SND_SOC_DAPM_POST_PMD),
  9354. SND_SOC_DAPM_MICBIAS_E("MIC BIAS2", SND_SOC_NOPM, 0, 0,
  9355. tasha_codec_enable_micbias,
  9356. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9357. SND_SOC_DAPM_POST_PMD),
  9358. SND_SOC_DAPM_MICBIAS_E("MIC BIAS3", SND_SOC_NOPM, 0, 0,
  9359. tasha_codec_enable_micbias,
  9360. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9361. SND_SOC_DAPM_POST_PMD),
  9362. SND_SOC_DAPM_MICBIAS_E("MIC BIAS4", SND_SOC_NOPM, 0, 0,
  9363. tasha_codec_enable_micbias,
  9364. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9365. SND_SOC_DAPM_POST_PMD),
  9366. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS1_STANDALONE, SND_SOC_NOPM, 0, 0,
  9367. tasha_codec_force_enable_micbias,
  9368. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9369. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS2_STANDALONE, SND_SOC_NOPM, 0, 0,
  9370. tasha_codec_force_enable_micbias,
  9371. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9372. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS3_STANDALONE, SND_SOC_NOPM, 0, 0,
  9373. tasha_codec_force_enable_micbias,
  9374. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9375. SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS4_STANDALONE, SND_SOC_NOPM, 0, 0,
  9376. tasha_codec_force_enable_micbias,
  9377. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9378. SND_SOC_DAPM_SUPPLY(DAPM_LDO_H_STANDALONE, SND_SOC_NOPM, 0, 0,
  9379. tasha_codec_force_enable_ldo_h,
  9380. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9381. SND_SOC_DAPM_MUX("ANC0 FB MUX", SND_SOC_NOPM, 0, 0, &anc0_fb_mux),
  9382. SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux),
  9383. SND_SOC_DAPM_INPUT("AMIC2"),
  9384. SND_SOC_DAPM_INPUT("AMIC3"),
  9385. SND_SOC_DAPM_INPUT("AMIC4"),
  9386. SND_SOC_DAPM_INPUT("AMIC5"),
  9387. SND_SOC_DAPM_INPUT("AMIC6"),
  9388. SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM,
  9389. AIF1_CAP, 0, tasha_codec_enable_slimtx,
  9390. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9391. SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM,
  9392. AIF2_CAP, 0, tasha_codec_enable_slimtx,
  9393. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9394. SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM,
  9395. AIF3_CAP, 0, tasha_codec_enable_slimtx,
  9396. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9397. SND_SOC_DAPM_AIF_OUT_E("AIF4 VI", "VIfeed", 0, SND_SOC_NOPM,
  9398. AIF4_VIFEED, 0, tasha_codec_enable_slimvi_feedback,
  9399. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9400. SND_SOC_DAPM_MIXER("AIF4_VI Mixer", SND_SOC_NOPM, AIF4_VIFEED, 0,
  9401. aif4_vi_mixer, ARRAY_SIZE(aif4_vi_mixer)),
  9402. SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0,
  9403. aif1_cap_mixer, ARRAY_SIZE(aif1_cap_mixer)),
  9404. SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0,
  9405. aif2_cap_mixer, ARRAY_SIZE(aif2_cap_mixer)),
  9406. SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0,
  9407. aif3_cap_mixer, ARRAY_SIZE(aif3_cap_mixer)),
  9408. SND_SOC_DAPM_MIXER("AIF4_MAD Mixer", SND_SOC_NOPM, AIF4_MAD_TX, 0,
  9409. aif4_mad_mixer, ARRAY_SIZE(aif4_mad_mixer)),
  9410. SND_SOC_DAPM_INPUT("VIINPUT"),
  9411. SND_SOC_DAPM_AIF_OUT("AIF5 CPE", "AIF5 CPE TX", 0, SND_SOC_NOPM,
  9412. AIF5_CPE_TX, 0),
  9413. SND_SOC_DAPM_MUX_E("EC BUF MUX INP", SND_SOC_NOPM, 0, 0, &ec_buf_mux,
  9414. tasha_codec_ec_buf_mux_enable,
  9415. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
  9416. /* Digital Mic Inputs */
  9417. SND_SOC_DAPM_ADC_E("DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  9418. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9419. SND_SOC_DAPM_POST_PMD),
  9420. SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  9421. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9422. SND_SOC_DAPM_POST_PMD),
  9423. SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  9424. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9425. SND_SOC_DAPM_POST_PMD),
  9426. SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  9427. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9428. SND_SOC_DAPM_POST_PMD),
  9429. SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  9430. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9431. SND_SOC_DAPM_POST_PMD),
  9432. SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  9433. tasha_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  9434. SND_SOC_DAPM_POST_PMD),
  9435. SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux),
  9436. SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux),
  9437. SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux),
  9438. SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux),
  9439. SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux),
  9440. SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
  9441. SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux),
  9442. SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux),
  9443. SND_SOC_DAPM_MIXER_E("IIR0", WCD9335_CDC_SIDETONE_IIR0_IIR_PATH_CTL,
  9444. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9445. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9446. SND_SOC_DAPM_MIXER_E("IIR1", WCD9335_CDC_SIDETONE_IIR1_IIR_PATH_CTL,
  9447. 4, 0, NULL, 0, tasha_codec_set_iir_gain,
  9448. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  9449. SND_SOC_DAPM_MIXER("SRC0", WCD9335_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL,
  9450. 4, 0, NULL, 0),
  9451. SND_SOC_DAPM_MIXER("SRC1", WCD9335_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL,
  9452. 4, 0, NULL, 0),
  9453. SND_SOC_DAPM_MIXER_E("CPE IN Mixer", SND_SOC_NOPM, 0, 0,
  9454. cpe_in_mix_switch,
  9455. ARRAY_SIZE(cpe_in_mix_switch),
  9456. tasha_codec_configure_cpe_input,
  9457. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9458. SND_SOC_DAPM_MUX("RX INT1_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9459. &int1_1_native_mux),
  9460. SND_SOC_DAPM_MUX("RX INT2_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9461. &int2_1_native_mux),
  9462. SND_SOC_DAPM_MUX("RX INT3_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9463. &int3_1_native_mux),
  9464. SND_SOC_DAPM_MUX("RX INT4_1 NATIVE MUX", SND_SOC_NOPM, 0, 0,
  9465. &int4_1_native_mux),
  9466. SND_SOC_DAPM_MUX("RX MIX TX0 MUX", SND_SOC_NOPM, 0, 0,
  9467. &rx_mix_tx0_mux),
  9468. SND_SOC_DAPM_MUX("RX MIX TX1 MUX", SND_SOC_NOPM, 0, 0,
  9469. &rx_mix_tx1_mux),
  9470. SND_SOC_DAPM_MUX("RX MIX TX2 MUX", SND_SOC_NOPM, 0, 0,
  9471. &rx_mix_tx2_mux),
  9472. SND_SOC_DAPM_MUX("RX MIX TX3 MUX", SND_SOC_NOPM, 0, 0,
  9473. &rx_mix_tx3_mux),
  9474. SND_SOC_DAPM_MUX("RX MIX TX4 MUX", SND_SOC_NOPM, 0, 0,
  9475. &rx_mix_tx4_mux),
  9476. SND_SOC_DAPM_MUX("RX MIX TX5 MUX", SND_SOC_NOPM, 0, 0,
  9477. &rx_mix_tx5_mux),
  9478. SND_SOC_DAPM_MUX("RX MIX TX6 MUX", SND_SOC_NOPM, 0, 0,
  9479. &rx_mix_tx6_mux),
  9480. SND_SOC_DAPM_MUX("RX MIX TX7 MUX", SND_SOC_NOPM, 0, 0,
  9481. &rx_mix_tx7_mux),
  9482. SND_SOC_DAPM_MUX("RX MIX TX8 MUX", SND_SOC_NOPM, 0, 0,
  9483. &rx_mix_tx8_mux),
  9484. SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0,
  9485. &rx_int0_dem_inp_mux),
  9486. SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0,
  9487. &rx_int1_dem_inp_mux),
  9488. SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM, 0, 0,
  9489. &rx_int2_dem_inp_mux),
  9490. SND_SOC_DAPM_MUX_E("RX INT0 INTERP", SND_SOC_NOPM,
  9491. INTERP_EAR, 0, &rx_int0_interp_mux,
  9492. tasha_codec_enable_interpolator,
  9493. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9494. SND_SOC_DAPM_POST_PMD),
  9495. SND_SOC_DAPM_MUX_E("RX INT1 INTERP", SND_SOC_NOPM,
  9496. INTERP_HPHL, 0, &rx_int1_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 INT2 INTERP", SND_SOC_NOPM,
  9501. INTERP_HPHR, 0, &rx_int2_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 INT3 INTERP", SND_SOC_NOPM,
  9506. INTERP_LO1, 0, &rx_int3_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 INT4 INTERP", SND_SOC_NOPM,
  9511. INTERP_LO2, 0, &rx_int4_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 INT5 INTERP", SND_SOC_NOPM,
  9516. INTERP_LO3, 0, &rx_int5_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 INT6 INTERP", SND_SOC_NOPM,
  9521. INTERP_LO4, 0, &rx_int6_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 INT7 INTERP", SND_SOC_NOPM,
  9526. INTERP_SPKR1, 0, &rx_int7_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 INT8 INTERP", SND_SOC_NOPM,
  9531. INTERP_SPKR2, 0, &rx_int8_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_DAC_E("RX INT0 DAC", NULL, SND_SOC_NOPM,
  9536. 0, 0, tasha_codec_ear_dac_event,
  9537. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9538. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9539. SND_SOC_DAPM_DAC_E("RX INT1 DAC", NULL, SND_SOC_NOPM,
  9540. 0, 0, tasha_codec_hphl_dac_event,
  9541. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9542. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9543. SND_SOC_DAPM_DAC_E("RX INT2 DAC", NULL, SND_SOC_NOPM,
  9544. 0, 0, tasha_codec_hphr_dac_event,
  9545. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9546. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9547. SND_SOC_DAPM_DAC_E("RX INT3 DAC", NULL, SND_SOC_NOPM,
  9548. 0, 0, tasha_codec_lineout_dac_event,
  9549. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9550. SND_SOC_DAPM_DAC_E("RX INT4 DAC", NULL, SND_SOC_NOPM,
  9551. 0, 0, tasha_codec_lineout_dac_event,
  9552. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9553. SND_SOC_DAPM_DAC_E("RX INT5 DAC", NULL, SND_SOC_NOPM,
  9554. 0, 0, tasha_codec_lineout_dac_event,
  9555. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9556. SND_SOC_DAPM_DAC_E("RX INT6 DAC", NULL, SND_SOC_NOPM,
  9557. 0, 0, tasha_codec_lineout_dac_event,
  9558. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9559. SND_SOC_DAPM_PGA_E("HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9560. tasha_codec_enable_hphl_pa,
  9561. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9562. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9563. SND_SOC_DAPM_PGA_E("HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9564. tasha_codec_enable_hphr_pa,
  9565. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9566. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9567. SND_SOC_DAPM_PGA_E("EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9568. tasha_codec_enable_ear_pa,
  9569. SND_SOC_DAPM_POST_PMU |
  9570. SND_SOC_DAPM_POST_PMD),
  9571. SND_SOC_DAPM_PGA_E("LINEOUT1 PA", WCD9335_ANA_LO_1_2, 7, 0, NULL, 0,
  9572. tasha_codec_enable_lineout_pa,
  9573. SND_SOC_DAPM_POST_PMU |
  9574. SND_SOC_DAPM_POST_PMD),
  9575. SND_SOC_DAPM_PGA_E("LINEOUT2 PA", WCD9335_ANA_LO_1_2, 6, 0, NULL, 0,
  9576. tasha_codec_enable_lineout_pa,
  9577. SND_SOC_DAPM_POST_PMU |
  9578. SND_SOC_DAPM_POST_PMD),
  9579. SND_SOC_DAPM_PGA_E("LINEOUT3 PA", WCD9335_ANA_LO_3_4, 7, 0, NULL, 0,
  9580. tasha_codec_enable_lineout_pa,
  9581. SND_SOC_DAPM_POST_PMU |
  9582. SND_SOC_DAPM_POST_PMD),
  9583. SND_SOC_DAPM_PGA_E("LINEOUT4 PA", WCD9335_ANA_LO_3_4, 6, 0, NULL, 0,
  9584. tasha_codec_enable_lineout_pa,
  9585. SND_SOC_DAPM_POST_PMU |
  9586. SND_SOC_DAPM_POST_PMD),
  9587. SND_SOC_DAPM_PGA_E("ANC EAR PA", WCD9335_ANA_EAR, 7, 0, NULL, 0,
  9588. tasha_codec_enable_ear_pa,
  9589. SND_SOC_DAPM_POST_PMU |
  9590. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9591. SND_SOC_DAPM_PGA_E("ANC HPHL PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9592. tasha_codec_enable_hphl_pa,
  9593. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9594. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9595. SND_SOC_DAPM_PGA_E("ANC HPHR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9596. tasha_codec_enable_hphr_pa,
  9597. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  9598. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9599. SND_SOC_DAPM_PGA_E("ANC LINEOUT1 PA", WCD9335_ANA_LO_1_2,
  9600. 7, 0, NULL, 0,
  9601. tasha_codec_enable_lineout_pa,
  9602. SND_SOC_DAPM_POST_PMU |
  9603. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  9604. SND_SOC_DAPM_PGA_E("ANC LINEOUT2 PA", WCD9335_ANA_LO_1_2,
  9605. 6, 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 SPK1 PA", SND_SOC_NOPM, 0, 0, NULL, 0,
  9610. tasha_codec_enable_spk_anc,
  9611. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9612. SND_SOC_DAPM_OUTPUT("HPHL"),
  9613. SND_SOC_DAPM_OUTPUT("HPHR"),
  9614. SND_SOC_DAPM_OUTPUT("ANC HPHL"),
  9615. SND_SOC_DAPM_OUTPUT("ANC HPHR"),
  9616. SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0,
  9617. tasha_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU |
  9618. SND_SOC_DAPM_POST_PMD),
  9619. SND_SOC_DAPM_OUTPUT("SPK1 OUT"),
  9620. SND_SOC_DAPM_OUTPUT("SPK2 OUT"),
  9621. SND_SOC_DAPM_OUTPUT("LINEOUT1"),
  9622. SND_SOC_DAPM_OUTPUT("LINEOUT2"),
  9623. SND_SOC_DAPM_OUTPUT("LINEOUT3"),
  9624. SND_SOC_DAPM_OUTPUT("LINEOUT4"),
  9625. SND_SOC_DAPM_OUTPUT("ANC LINEOUT1"),
  9626. SND_SOC_DAPM_OUTPUT("ANC LINEOUT2"),
  9627. SND_SOC_DAPM_SUPPLY("MICBIAS_REGULATOR", SND_SOC_NOPM,
  9628. ON_DEMAND_MICBIAS, 0,
  9629. tasha_codec_enable_on_demand_supply,
  9630. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9631. SND_SOC_DAPM_SWITCH("ADC US MUX0", WCD9335_CDC_TX0_TX_PATH_192_CTL, 0,
  9632. 0, &adc_us_mux0_switch),
  9633. SND_SOC_DAPM_SWITCH("ADC US MUX1", WCD9335_CDC_TX1_TX_PATH_192_CTL, 0,
  9634. 0, &adc_us_mux1_switch),
  9635. SND_SOC_DAPM_SWITCH("ADC US MUX2", WCD9335_CDC_TX2_TX_PATH_192_CTL, 0,
  9636. 0, &adc_us_mux2_switch),
  9637. SND_SOC_DAPM_SWITCH("ADC US MUX3", WCD9335_CDC_TX3_TX_PATH_192_CTL, 0,
  9638. 0, &adc_us_mux3_switch),
  9639. SND_SOC_DAPM_SWITCH("ADC US MUX4", WCD9335_CDC_TX4_TX_PATH_192_CTL, 0,
  9640. 0, &adc_us_mux4_switch),
  9641. SND_SOC_DAPM_SWITCH("ADC US MUX5", WCD9335_CDC_TX5_TX_PATH_192_CTL, 0,
  9642. 0, &adc_us_mux5_switch),
  9643. SND_SOC_DAPM_SWITCH("ADC US MUX6", WCD9335_CDC_TX6_TX_PATH_192_CTL, 0,
  9644. 0, &adc_us_mux6_switch),
  9645. SND_SOC_DAPM_SWITCH("ADC US MUX7", WCD9335_CDC_TX7_TX_PATH_192_CTL, 0,
  9646. 0, &adc_us_mux7_switch),
  9647. SND_SOC_DAPM_SWITCH("ADC US MUX8", WCD9335_CDC_TX8_TX_PATH_192_CTL, 0,
  9648. 0, &adc_us_mux8_switch),
  9649. /* MAD related widgets */
  9650. SND_SOC_DAPM_AIF_OUT_E("AIF4 MAD", "AIF4 MAD TX", 0,
  9651. SND_SOC_NOPM, 0, 0,
  9652. tasha_codec_enable_mad,
  9653. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  9654. SND_SOC_DAPM_MUX("MAD_SEL MUX", SND_SOC_NOPM, 0, 0,
  9655. &mad_sel_mux),
  9656. SND_SOC_DAPM_INPUT("MAD_CPE_INPUT"),
  9657. SND_SOC_DAPM_INPUT("MADINPUT"),
  9658. SND_SOC_DAPM_SWITCH("MADONOFF", SND_SOC_NOPM, 0, 0,
  9659. &aif4_mad_switch),
  9660. SND_SOC_DAPM_SWITCH("MAD_BROADCAST", SND_SOC_NOPM, 0, 0,
  9661. &mad_brdcst_switch),
  9662. SND_SOC_DAPM_SWITCH("AIF4", SND_SOC_NOPM, 0, 0,
  9663. &aif4_switch_mixer_controls),
  9664. SND_SOC_DAPM_SWITCH("ANC HPHL Enable", SND_SOC_NOPM, 0, 0,
  9665. &anc_hphl_switch),
  9666. SND_SOC_DAPM_SWITCH("ANC HPHR Enable", SND_SOC_NOPM, 0, 0,
  9667. &anc_hphr_switch),
  9668. SND_SOC_DAPM_SWITCH("ANC EAR Enable", SND_SOC_NOPM, 0, 0,
  9669. &anc_ear_switch),
  9670. SND_SOC_DAPM_SWITCH("ANC OUT EAR SPKR Enable", SND_SOC_NOPM, 0, 0,
  9671. &anc_ear_spkr_switch),
  9672. SND_SOC_DAPM_SWITCH("ANC LINEOUT1 Enable", SND_SOC_NOPM, 0, 0,
  9673. &anc_lineout1_switch),
  9674. SND_SOC_DAPM_SWITCH("ANC LINEOUT2 Enable", SND_SOC_NOPM, 0, 0,
  9675. &anc_lineout2_switch),
  9676. SND_SOC_DAPM_SWITCH("ANC SPKR PA Enable", SND_SOC_NOPM, 0, 0,
  9677. &anc_spkr_pa_switch),
  9678. };
  9679. static int tasha_get_channel_map(struct snd_soc_dai *dai,
  9680. unsigned int *tx_num, unsigned int *tx_slot,
  9681. unsigned int *rx_num, unsigned int *rx_slot)
  9682. {
  9683. struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(dai->codec);
  9684. u32 i = 0;
  9685. struct wcd9xxx_ch *ch;
  9686. switch (dai->id) {
  9687. case AIF1_PB:
  9688. case AIF2_PB:
  9689. case AIF3_PB:
  9690. case AIF4_PB:
  9691. case AIF_MIX1_PB:
  9692. if (!rx_slot || !rx_num) {
  9693. pr_err("%s: Invalid rx_slot %pK or rx_num %pK\n",
  9694. __func__, rx_slot, rx_num);
  9695. return -EINVAL;
  9696. }
  9697. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9698. list) {
  9699. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9700. __func__, i, ch->ch_num);
  9701. rx_slot[i++] = ch->ch_num;
  9702. }
  9703. pr_debug("%s: rx_num %d\n", __func__, i);
  9704. *rx_num = i;
  9705. break;
  9706. case AIF1_CAP:
  9707. case AIF2_CAP:
  9708. case AIF3_CAP:
  9709. case AIF4_MAD_TX:
  9710. case AIF4_VIFEED:
  9711. if (!tx_slot || !tx_num) {
  9712. pr_err("%s: Invalid tx_slot %pK or tx_num %pK\n",
  9713. __func__, tx_slot, tx_num);
  9714. return -EINVAL;
  9715. }
  9716. list_for_each_entry(ch, &tasha_p->dai[dai->id].wcd9xxx_ch_list,
  9717. list) {
  9718. pr_debug("%s: slot_num %u ch->ch_num %d\n",
  9719. __func__, i, ch->ch_num);
  9720. tx_slot[i++] = ch->ch_num;
  9721. }
  9722. pr_debug("%s: tx_num %d\n", __func__, i);
  9723. *tx_num = i;
  9724. break;
  9725. default:
  9726. pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id);
  9727. break;
  9728. }
  9729. return 0;
  9730. }
  9731. static int tasha_set_channel_map(struct snd_soc_dai *dai,
  9732. unsigned int tx_num, unsigned int *tx_slot,
  9733. unsigned int rx_num, unsigned int *rx_slot)
  9734. {
  9735. struct tasha_priv *tasha;
  9736. struct wcd9xxx *core;
  9737. struct wcd9xxx_codec_dai_data *dai_data = NULL;
  9738. if (!dai) {
  9739. pr_err("%s: dai is empty\n", __func__);
  9740. return -EINVAL;
  9741. }
  9742. tasha = snd_soc_codec_get_drvdata(dai->codec);
  9743. core = dev_get_drvdata(dai->codec->dev->parent);
  9744. if (!tx_slot || !rx_slot) {
  9745. pr_err("%s: Invalid tx_slot=%pK, rx_slot=%pK\n",
  9746. __func__, tx_slot, rx_slot);
  9747. return -EINVAL;
  9748. }
  9749. pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n"
  9750. "tasha->intf_type %d\n",
  9751. __func__, dai->name, dai->id, tx_num, rx_num,
  9752. tasha->intf_type);
  9753. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  9754. wcd9xxx_init_slimslave(core, core->slim->laddr,
  9755. tx_num, tx_slot, rx_num, rx_slot);
  9756. /* Reserve TX12/TX13 for MAD data channel */
  9757. dai_data = &tasha->dai[AIF4_MAD_TX];
  9758. if (dai_data) {
  9759. if (TASHA_IS_2_0(tasha->wcd9xxx))
  9760. list_add_tail(&core->tx_chs[TASHA_TX13].list,
  9761. &dai_data->wcd9xxx_ch_list);
  9762. else
  9763. list_add_tail(&core->tx_chs[TASHA_TX12].list,
  9764. &dai_data->wcd9xxx_ch_list);
  9765. }
  9766. }
  9767. return 0;
  9768. }
  9769. static int tasha_startup(struct snd_pcm_substream *substream,
  9770. struct snd_soc_dai *dai)
  9771. {
  9772. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9773. substream->name, substream->stream);
  9774. return 0;
  9775. }
  9776. static void tasha_shutdown(struct snd_pcm_substream *substream,
  9777. struct snd_soc_dai *dai)
  9778. {
  9779. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  9780. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  9781. substream->name, substream->stream);
  9782. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  9783. return;
  9784. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  9785. tasha_codec_vote_max_bw(dai->codec, false);
  9786. }
  9787. static int tasha_set_decimator_rate(struct snd_soc_dai *dai,
  9788. u8 tx_fs_rate_reg_val, u32 sample_rate)
  9789. {
  9790. struct snd_soc_codec *codec = dai->codec;
  9791. struct wcd9xxx_ch *ch;
  9792. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9793. u32 tx_port = 0;
  9794. u8 shift = 0, shift_val = 0, tx_mux_sel = 0;
  9795. int decimator = -1;
  9796. u16 tx_port_reg = 0, tx_fs_reg = 0;
  9797. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9798. tx_port = ch->port;
  9799. dev_dbg(codec->dev, "%s: dai->id = %d, tx_port = %d",
  9800. __func__, dai->id, tx_port);
  9801. if ((tx_port < 0) || (tx_port == 12) || (tx_port >= 14)) {
  9802. dev_err(codec->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n",
  9803. __func__, tx_port, dai->id);
  9804. return -EINVAL;
  9805. }
  9806. /* Find the SB TX MUX input - which decimator is connected */
  9807. if (tx_port < 4) {
  9808. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0;
  9809. shift = (tx_port << 1);
  9810. shift_val = 0x03;
  9811. } else if ((tx_port >= 4) && (tx_port < 8)) {
  9812. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG1;
  9813. shift = ((tx_port - 4) << 1);
  9814. shift_val = 0x03;
  9815. } else if ((tx_port >= 8) && (tx_port < 11)) {
  9816. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG2;
  9817. shift = ((tx_port - 8) << 1);
  9818. shift_val = 0x03;
  9819. } else if (tx_port == 11) {
  9820. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9821. shift = 0;
  9822. shift_val = 0x0F;
  9823. } else if (tx_port == 13) {
  9824. tx_port_reg = WCD9335_CDC_IF_ROUTER_TX_MUX_CFG3;
  9825. shift = 4;
  9826. shift_val = 0x03;
  9827. }
  9828. tx_mux_sel = snd_soc_read(codec, tx_port_reg) &
  9829. (shift_val << shift);
  9830. tx_mux_sel = tx_mux_sel >> shift;
  9831. if (tx_port <= 8) {
  9832. if ((tx_mux_sel == 0x2) || (tx_mux_sel == 0x3))
  9833. decimator = tx_port;
  9834. } else if (tx_port <= 10) {
  9835. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9836. decimator = ((tx_port == 9) ? 7 : 6);
  9837. } else if (tx_port == 11) {
  9838. if ((tx_mux_sel >= 1) && (tx_mux_sel < 7))
  9839. decimator = tx_mux_sel - 1;
  9840. } else if (tx_port == 13) {
  9841. if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2))
  9842. decimator = 5;
  9843. }
  9844. if (decimator >= 0) {
  9845. tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL +
  9846. 16 * decimator;
  9847. dev_dbg(codec->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n",
  9848. __func__, decimator, tx_port, sample_rate);
  9849. snd_soc_update_bits(codec, tx_fs_reg, 0x0F,
  9850. tx_fs_rate_reg_val);
  9851. } else if ((tx_port <= 8) && (tx_mux_sel == 0x01)) {
  9852. /* Check if the TX Mux input is RX MIX TXn */
  9853. dev_dbg(codec->dev, "%s: RX_MIX_TX%u going to SLIM TX%u\n",
  9854. __func__, tx_port, tx_port);
  9855. } else {
  9856. dev_err(codec->dev, "%s: ERROR: Invalid decimator: %d\n",
  9857. __func__, decimator);
  9858. return -EINVAL;
  9859. }
  9860. }
  9861. return 0;
  9862. }
  9863. static int tasha_set_mix_interpolator_rate(struct snd_soc_dai *dai,
  9864. u8 int_mix_fs_rate_reg_val,
  9865. u32 sample_rate)
  9866. {
  9867. u8 int_2_inp;
  9868. u32 j;
  9869. u16 int_mux_cfg1, int_fs_reg;
  9870. u8 int_mux_cfg1_val;
  9871. struct snd_soc_codec *codec = dai->codec;
  9872. struct wcd9xxx_ch *ch;
  9873. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9874. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9875. int_2_inp = ch->port + INTn_2_INP_SEL_RX0 -
  9876. TASHA_RX_PORT_START_NUMBER;
  9877. if ((int_2_inp < INTn_2_INP_SEL_RX0) ||
  9878. (int_2_inp > INTn_2_INP_SEL_RX7)) {
  9879. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9880. __func__,
  9881. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9882. dai->id);
  9883. return -EINVAL;
  9884. }
  9885. int_mux_cfg1 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1;
  9886. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9887. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) &
  9888. 0x0F;
  9889. if (int_mux_cfg1_val == int_2_inp) {
  9890. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_MIX_CTL +
  9891. 20 * j;
  9892. pr_debug("%s: AIF_MIX_PB DAI(%d) connected to INT%u_2\n",
  9893. __func__, dai->id, j);
  9894. pr_debug("%s: set INT%u_2 sample rate to %u\n",
  9895. __func__, j, sample_rate);
  9896. snd_soc_update_bits(codec, int_fs_reg,
  9897. 0x0F, int_mix_fs_rate_reg_val);
  9898. }
  9899. int_mux_cfg1 += 2;
  9900. }
  9901. }
  9902. return 0;
  9903. }
  9904. static int tasha_set_prim_interpolator_rate(struct snd_soc_dai *dai,
  9905. u8 int_prim_fs_rate_reg_val,
  9906. u32 sample_rate)
  9907. {
  9908. u8 int_1_mix1_inp;
  9909. u32 j;
  9910. u16 int_mux_cfg0, int_mux_cfg1;
  9911. u16 int_fs_reg;
  9912. u8 int_mux_cfg0_val, int_mux_cfg1_val;
  9913. u8 inp0_sel, inp1_sel, inp2_sel;
  9914. struct snd_soc_codec *codec = dai->codec;
  9915. struct wcd9xxx_ch *ch;
  9916. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  9917. list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) {
  9918. int_1_mix1_inp = ch->port + INTn_1_MIX_INP_SEL_RX0 -
  9919. TASHA_RX_PORT_START_NUMBER;
  9920. if ((int_1_mix1_inp < INTn_1_MIX_INP_SEL_RX0) ||
  9921. (int_1_mix1_inp > INTn_1_MIX_INP_SEL_RX7)) {
  9922. pr_err("%s: Invalid RX%u port, Dai ID is %d\n",
  9923. __func__,
  9924. (ch->port - TASHA_RX_PORT_START_NUMBER),
  9925. dai->id);
  9926. return -EINVAL;
  9927. }
  9928. int_mux_cfg0 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG0;
  9929. /*
  9930. * Loop through all interpolator MUX inputs and find out
  9931. * to which interpolator input, the slim rx port
  9932. * is connected
  9933. */
  9934. for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) {
  9935. int_mux_cfg1 = int_mux_cfg0 + 1;
  9936. int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0);
  9937. int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1);
  9938. inp0_sel = int_mux_cfg0_val & 0x0F;
  9939. inp1_sel = (int_mux_cfg0_val >> 4) & 0x0F;
  9940. inp2_sel = (int_mux_cfg1_val >> 4) & 0x0F;
  9941. if ((inp0_sel == int_1_mix1_inp) ||
  9942. (inp1_sel == int_1_mix1_inp) ||
  9943. (inp2_sel == int_1_mix1_inp)) {
  9944. int_fs_reg = WCD9335_CDC_RX0_RX_PATH_CTL +
  9945. 20 * j;
  9946. pr_debug("%s: AIF_PB DAI(%d) connected to INT%u_1\n",
  9947. __func__, dai->id, j);
  9948. pr_debug("%s: set INT%u_1 sample rate to %u\n",
  9949. __func__, j, sample_rate);
  9950. /* sample_rate is in Hz */
  9951. if ((j == 0) && (sample_rate == 44100)) {
  9952. pr_info("%s: Cannot set 44.1KHz on INT0\n",
  9953. __func__);
  9954. } else
  9955. snd_soc_update_bits(codec, int_fs_reg,
  9956. 0x0F, int_prim_fs_rate_reg_val);
  9957. }
  9958. int_mux_cfg0 += 2;
  9959. }
  9960. }
  9961. return 0;
  9962. }
  9963. static int tasha_set_interpolator_rate(struct snd_soc_dai *dai,
  9964. u32 sample_rate)
  9965. {
  9966. int rate_val = 0;
  9967. int i, ret;
  9968. /* set mixing path rate */
  9969. for (i = 0; i < ARRAY_SIZE(int_mix_sample_rate_val); i++) {
  9970. if (sample_rate ==
  9971. int_mix_sample_rate_val[i].sample_rate) {
  9972. rate_val =
  9973. int_mix_sample_rate_val[i].rate_val;
  9974. break;
  9975. }
  9976. }
  9977. if ((i == ARRAY_SIZE(int_mix_sample_rate_val)) ||
  9978. (rate_val < 0))
  9979. goto prim_rate;
  9980. ret = tasha_set_mix_interpolator_rate(dai,
  9981. (u8) rate_val, sample_rate);
  9982. prim_rate:
  9983. /* set primary path sample rate */
  9984. for (i = 0; i < ARRAY_SIZE(int_prim_sample_rate_val); i++) {
  9985. if (sample_rate ==
  9986. int_prim_sample_rate_val[i].sample_rate) {
  9987. rate_val =
  9988. int_prim_sample_rate_val[i].rate_val;
  9989. break;
  9990. }
  9991. }
  9992. if ((i == ARRAY_SIZE(int_prim_sample_rate_val)) ||
  9993. (rate_val < 0))
  9994. return -EINVAL;
  9995. ret = tasha_set_prim_interpolator_rate(dai,
  9996. (u8) rate_val, sample_rate);
  9997. return ret;
  9998. }
  9999. static int tasha_prepare(struct snd_pcm_substream *substream,
  10000. struct snd_soc_dai *dai)
  10001. {
  10002. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  10003. substream->name, substream->stream);
  10004. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  10005. tasha_codec_vote_max_bw(dai->codec, false);
  10006. return 0;
  10007. }
  10008. static int tasha_hw_params(struct snd_pcm_substream *substream,
  10009. struct snd_pcm_hw_params *params,
  10010. struct snd_soc_dai *dai)
  10011. {
  10012. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  10013. int ret;
  10014. int tx_fs_rate = -EINVAL;
  10015. int rx_fs_rate = -EINVAL;
  10016. int i2s_bit_mode;
  10017. struct snd_soc_codec *codec = dai->codec;
  10018. pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
  10019. dai->name, dai->id, params_rate(params),
  10020. params_channels(params));
  10021. switch (substream->stream) {
  10022. case SNDRV_PCM_STREAM_PLAYBACK:
  10023. ret = tasha_set_interpolator_rate(dai, params_rate(params));
  10024. if (ret) {
  10025. pr_err("%s: cannot set sample rate: %u\n",
  10026. __func__, params_rate(params));
  10027. return ret;
  10028. }
  10029. switch (params_width(params)) {
  10030. case 16:
  10031. tasha->dai[dai->id].bit_width = 16;
  10032. i2s_bit_mode = 0x01;
  10033. break;
  10034. case 24:
  10035. tasha->dai[dai->id].bit_width = 24;
  10036. i2s_bit_mode = 0x00;
  10037. break;
  10038. default:
  10039. return -EINVAL;
  10040. }
  10041. tasha->dai[dai->id].rate = params_rate(params);
  10042. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10043. switch (params_rate(params)) {
  10044. case 8000:
  10045. rx_fs_rate = 0;
  10046. break;
  10047. case 16000:
  10048. rx_fs_rate = 1;
  10049. break;
  10050. case 32000:
  10051. rx_fs_rate = 2;
  10052. break;
  10053. case 48000:
  10054. rx_fs_rate = 3;
  10055. break;
  10056. case 96000:
  10057. rx_fs_rate = 4;
  10058. break;
  10059. case 192000:
  10060. rx_fs_rate = 5;
  10061. break;
  10062. default:
  10063. dev_err(tasha->dev,
  10064. "%s: Invalid RX sample rate: %d\n",
  10065. __func__, params_rate(params));
  10066. return -EINVAL;
  10067. };
  10068. snd_soc_update_bits(codec,
  10069. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10070. 0x20, i2s_bit_mode << 5);
  10071. snd_soc_update_bits(codec,
  10072. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10073. 0x1c, (rx_fs_rate << 2));
  10074. }
  10075. break;
  10076. case SNDRV_PCM_STREAM_CAPTURE:
  10077. switch (params_rate(params)) {
  10078. case 8000:
  10079. tx_fs_rate = 0;
  10080. break;
  10081. case 16000:
  10082. tx_fs_rate = 1;
  10083. break;
  10084. case 32000:
  10085. tx_fs_rate = 3;
  10086. break;
  10087. case 48000:
  10088. tx_fs_rate = 4;
  10089. break;
  10090. case 96000:
  10091. tx_fs_rate = 5;
  10092. break;
  10093. case 192000:
  10094. tx_fs_rate = 6;
  10095. break;
  10096. case 384000:
  10097. tx_fs_rate = 7;
  10098. break;
  10099. default:
  10100. dev_err(tasha->dev, "%s: Invalid TX sample rate: %d\n",
  10101. __func__, params_rate(params));
  10102. return -EINVAL;
  10103. };
  10104. if (dai->id != AIF4_VIFEED &&
  10105. dai->id != AIF4_MAD_TX) {
  10106. ret = tasha_set_decimator_rate(dai, tx_fs_rate,
  10107. params_rate(params));
  10108. if (ret < 0) {
  10109. dev_err(tasha->dev, "%s: cannot set TX Decimator rate: %d\n",
  10110. __func__, tx_fs_rate);
  10111. return ret;
  10112. }
  10113. }
  10114. tasha->dai[dai->id].rate = params_rate(params);
  10115. switch (params_width(params)) {
  10116. case 16:
  10117. tasha->dai[dai->id].bit_width = 16;
  10118. i2s_bit_mode = 0x01;
  10119. break;
  10120. case 24:
  10121. tasha->dai[dai->id].bit_width = 24;
  10122. i2s_bit_mode = 0x00;
  10123. break;
  10124. case 32:
  10125. tasha->dai[dai->id].bit_width = 32;
  10126. i2s_bit_mode = 0x00;
  10127. break;
  10128. default:
  10129. dev_err(tasha->dev, "%s: Invalid format 0x%x\n",
  10130. __func__, params_width(params));
  10131. return -EINVAL;
  10132. };
  10133. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10134. snd_soc_update_bits(codec,
  10135. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10136. 0x20, i2s_bit_mode << 5);
  10137. if (tx_fs_rate > 1)
  10138. tx_fs_rate--;
  10139. snd_soc_update_bits(codec,
  10140. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10141. 0x1c, tx_fs_rate << 2);
  10142. snd_soc_update_bits(codec,
  10143. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG,
  10144. 0x05, 0x05);
  10145. snd_soc_update_bits(codec,
  10146. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG,
  10147. 0x05, 0x05);
  10148. snd_soc_update_bits(codec,
  10149. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG,
  10150. 0x05, 0x05);
  10151. snd_soc_update_bits(codec,
  10152. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG,
  10153. 0x05, 0x05);
  10154. }
  10155. break;
  10156. default:
  10157. pr_err("%s: Invalid stream type %d\n", __func__,
  10158. substream->stream);
  10159. return -EINVAL;
  10160. };
  10161. if (dai->id == AIF4_VIFEED)
  10162. tasha->dai[dai->id].bit_width = 32;
  10163. return 0;
  10164. }
  10165. static int tasha_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  10166. {
  10167. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec);
  10168. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  10169. case SND_SOC_DAIFMT_CBS_CFS:
  10170. /* CPU is master */
  10171. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10172. if (dai->id == AIF1_CAP)
  10173. snd_soc_update_bits(dai->codec,
  10174. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10175. 0x2, 0);
  10176. else if (dai->id == AIF1_PB)
  10177. snd_soc_update_bits(dai->codec,
  10178. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10179. 0x2, 0);
  10180. }
  10181. break;
  10182. case SND_SOC_DAIFMT_CBM_CFM:
  10183. /* CPU is slave */
  10184. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  10185. if (dai->id == AIF1_CAP)
  10186. snd_soc_update_bits(dai->codec,
  10187. WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL,
  10188. 0x2, 0x2);
  10189. else if (dai->id == AIF1_PB)
  10190. snd_soc_update_bits(dai->codec,
  10191. WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL,
  10192. 0x2, 0x2);
  10193. }
  10194. break;
  10195. default:
  10196. return -EINVAL;
  10197. }
  10198. return 0;
  10199. }
  10200. static int tasha_set_dai_sysclk(struct snd_soc_dai *dai,
  10201. int clk_id, unsigned int freq, int dir)
  10202. {
  10203. pr_debug("%s\n", __func__);
  10204. return 0;
  10205. }
  10206. static struct snd_soc_dai_ops tasha_dai_ops = {
  10207. .startup = tasha_startup,
  10208. .shutdown = tasha_shutdown,
  10209. .hw_params = tasha_hw_params,
  10210. .prepare = tasha_prepare,
  10211. .set_sysclk = tasha_set_dai_sysclk,
  10212. .set_fmt = tasha_set_dai_fmt,
  10213. .set_channel_map = tasha_set_channel_map,
  10214. .get_channel_map = tasha_get_channel_map,
  10215. };
  10216. static struct snd_soc_dai_driver tasha_dai[] = {
  10217. {
  10218. .name = "tasha_rx1",
  10219. .id = AIF1_PB,
  10220. .playback = {
  10221. .stream_name = "AIF1 Playback",
  10222. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10223. .formats = TASHA_FORMATS_S16_S24_LE,
  10224. .rate_max = 192000,
  10225. .rate_min = 8000,
  10226. .channels_min = 1,
  10227. .channels_max = 2,
  10228. },
  10229. .ops = &tasha_dai_ops,
  10230. },
  10231. {
  10232. .name = "tasha_tx1",
  10233. .id = AIF1_CAP,
  10234. .capture = {
  10235. .stream_name = "AIF1 Capture",
  10236. .rates = WCD9335_RATES_MASK,
  10237. .formats = TASHA_FORMATS_S16_S24_LE,
  10238. .rate_max = 192000,
  10239. .rate_min = 8000,
  10240. .channels_min = 1,
  10241. .channels_max = 4,
  10242. },
  10243. .ops = &tasha_dai_ops,
  10244. },
  10245. {
  10246. .name = "tasha_rx2",
  10247. .id = AIF2_PB,
  10248. .playback = {
  10249. .stream_name = "AIF2 Playback",
  10250. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10251. .formats = TASHA_FORMATS_S16_S24_LE,
  10252. .rate_min = 8000,
  10253. .rate_max = 192000,
  10254. .channels_min = 1,
  10255. .channels_max = 2,
  10256. },
  10257. .ops = &tasha_dai_ops,
  10258. },
  10259. {
  10260. .name = "tasha_tx2",
  10261. .id = AIF2_CAP,
  10262. .capture = {
  10263. .stream_name = "AIF2 Capture",
  10264. .rates = WCD9335_RATES_MASK,
  10265. .formats = TASHA_FORMATS_S16_S24_LE,
  10266. .rate_max = 192000,
  10267. .rate_min = 8000,
  10268. .channels_min = 1,
  10269. .channels_max = 8,
  10270. },
  10271. .ops = &tasha_dai_ops,
  10272. },
  10273. {
  10274. .name = "tasha_rx3",
  10275. .id = AIF3_PB,
  10276. .playback = {
  10277. .stream_name = "AIF3 Playback",
  10278. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10279. .formats = TASHA_FORMATS_S16_S24_LE,
  10280. .rate_min = 8000,
  10281. .rate_max = 192000,
  10282. .channels_min = 1,
  10283. .channels_max = 2,
  10284. },
  10285. .ops = &tasha_dai_ops,
  10286. },
  10287. {
  10288. .name = "tasha_tx3",
  10289. .id = AIF3_CAP,
  10290. .capture = {
  10291. .stream_name = "AIF3 Capture",
  10292. .rates = WCD9335_RATES_MASK,
  10293. .formats = TASHA_FORMATS_S16_S24_LE,
  10294. .rate_max = 48000,
  10295. .rate_min = 8000,
  10296. .channels_min = 1,
  10297. .channels_max = 2,
  10298. },
  10299. .ops = &tasha_dai_ops,
  10300. },
  10301. {
  10302. .name = "tasha_rx4",
  10303. .id = AIF4_PB,
  10304. .playback = {
  10305. .stream_name = "AIF4 Playback",
  10306. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10307. .formats = TASHA_FORMATS_S16_S24_LE,
  10308. .rate_min = 8000,
  10309. .rate_max = 192000,
  10310. .channels_min = 1,
  10311. .channels_max = 2,
  10312. },
  10313. .ops = &tasha_dai_ops,
  10314. },
  10315. {
  10316. .name = "tasha_mix_rx1",
  10317. .id = AIF_MIX1_PB,
  10318. .playback = {
  10319. .stream_name = "AIF Mix Playback",
  10320. .rates = WCD9335_RATES_MASK | WCD9335_FRAC_RATES_MASK,
  10321. .formats = TASHA_FORMATS_S16_S24_LE,
  10322. .rate_min = 8000,
  10323. .rate_max = 192000,
  10324. .channels_min = 1,
  10325. .channels_max = 8,
  10326. },
  10327. .ops = &tasha_dai_ops,
  10328. },
  10329. {
  10330. .name = "tasha_mad1",
  10331. .id = AIF4_MAD_TX,
  10332. .capture = {
  10333. .stream_name = "AIF4 MAD TX",
  10334. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10335. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_384000,
  10336. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10337. .rate_min = 16000,
  10338. .rate_max = 384000,
  10339. .channels_min = 1,
  10340. .channels_max = 1,
  10341. },
  10342. .ops = &tasha_dai_ops,
  10343. },
  10344. {
  10345. .name = "tasha_vifeedback",
  10346. .id = AIF4_VIFEED,
  10347. .capture = {
  10348. .stream_name = "VIfeed",
  10349. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_48000,
  10350. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10351. .rate_max = 48000,
  10352. .rate_min = 8000,
  10353. .channels_min = 1,
  10354. .channels_max = 4,
  10355. },
  10356. .ops = &tasha_dai_ops,
  10357. },
  10358. {
  10359. .name = "tasha_cpe",
  10360. .id = AIF5_CPE_TX,
  10361. .capture = {
  10362. .stream_name = "AIF5 CPE TX",
  10363. .rates = SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000,
  10364. .formats = TASHA_FORMATS_S16_S24_S32_LE,
  10365. .rate_min = 16000,
  10366. .rate_max = 48000,
  10367. .channels_min = 1,
  10368. .channels_max = 1,
  10369. },
  10370. },
  10371. };
  10372. static struct snd_soc_dai_driver tasha_i2s_dai[] = {
  10373. {
  10374. .name = "tasha_i2s_rx1",
  10375. .id = AIF1_PB,
  10376. .playback = {
  10377. .stream_name = "AIF1 Playback",
  10378. .rates = WCD9335_RATES_MASK,
  10379. .formats = TASHA_FORMATS_S16_S24_LE,
  10380. .rate_max = 192000,
  10381. .rate_min = 8000,
  10382. .channels_min = 1,
  10383. .channels_max = 2,
  10384. },
  10385. .ops = &tasha_dai_ops,
  10386. },
  10387. {
  10388. .name = "tasha_i2s_tx1",
  10389. .id = AIF1_CAP,
  10390. .capture = {
  10391. .stream_name = "AIF1 Capture",
  10392. .rates = WCD9335_RATES_MASK,
  10393. .formats = TASHA_FORMATS_S16_S24_LE,
  10394. .rate_max = 192000,
  10395. .rate_min = 8000,
  10396. .channels_min = 1,
  10397. .channels_max = 4,
  10398. },
  10399. .ops = &tasha_dai_ops,
  10400. },
  10401. {
  10402. .name = "tasha_i2s_rx2",
  10403. .id = AIF2_PB,
  10404. .playback = {
  10405. .stream_name = "AIF2 Playback",
  10406. .rates = WCD9335_RATES_MASK,
  10407. .formats = TASHA_FORMATS_S16_S24_LE,
  10408. .rate_max = 192000,
  10409. .rate_min = 8000,
  10410. .channels_min = 1,
  10411. .channels_max = 2,
  10412. },
  10413. .ops = &tasha_dai_ops,
  10414. },
  10415. {
  10416. .name = "tasha_i2s_tx2",
  10417. .id = AIF2_CAP,
  10418. .capture = {
  10419. .stream_name = "AIF2 Capture",
  10420. .rates = WCD9335_RATES_MASK,
  10421. .formats = TASHA_FORMATS_S16_S24_LE,
  10422. .rate_max = 192000,
  10423. .rate_min = 8000,
  10424. .channels_min = 1,
  10425. .channels_max = 4,
  10426. },
  10427. .ops = &tasha_dai_ops,
  10428. },
  10429. };
  10430. static void tasha_codec_power_gate_digital_core(struct tasha_priv *tasha)
  10431. {
  10432. struct snd_soc_codec *codec = tasha->codec;
  10433. if (!codec)
  10434. return;
  10435. mutex_lock(&tasha->power_lock);
  10436. dev_dbg(codec->dev, "%s: Entering power gating function, %d\n",
  10437. __func__, tasha->power_active_ref);
  10438. if (tasha->power_active_ref > 0)
  10439. goto exit;
  10440. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10441. WCD_REGION_POWER_COLLAPSE_BEGIN,
  10442. WCD9XXX_DIG_CORE_REGION_1);
  10443. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10444. 0x04, 0x04);
  10445. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10446. 0x01, 0x00);
  10447. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL,
  10448. 0x02, 0x00);
  10449. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10450. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  10451. wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_DOWN,
  10452. WCD9XXX_DIG_CORE_REGION_1);
  10453. exit:
  10454. dev_dbg(codec->dev, "%s: Exiting power gating function, %d\n",
  10455. __func__, tasha->power_active_ref);
  10456. mutex_unlock(&tasha->power_lock);
  10457. }
  10458. static void tasha_codec_power_gate_work(struct work_struct *work)
  10459. {
  10460. struct tasha_priv *tasha;
  10461. struct delayed_work *dwork;
  10462. struct snd_soc_codec *codec;
  10463. dwork = to_delayed_work(work);
  10464. tasha = container_of(dwork, struct tasha_priv, power_gate_work);
  10465. codec = tasha->codec;
  10466. if (!codec)
  10467. return;
  10468. tasha_codec_power_gate_digital_core(tasha);
  10469. }
  10470. /* called under power_lock acquisition */
  10471. static int tasha_dig_core_remove_power_collapse(struct snd_soc_codec *codec)
  10472. {
  10473. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10474. tasha_codec_vote_max_bw(codec, true);
  10475. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5);
  10476. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7);
  10477. snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3);
  10478. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x00);
  10479. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x02);
  10480. wcd9xxx_set_power_state(tasha->wcd9xxx,
  10481. WCD_REGION_POWER_COLLAPSE_REMOVE,
  10482. WCD9XXX_DIG_CORE_REGION_1);
  10483. regcache_mark_dirty(codec->component.regmap);
  10484. regcache_sync_region(codec->component.regmap,
  10485. TASHA_DIG_CORE_REG_MIN, TASHA_DIG_CORE_REG_MAX);
  10486. tasha_codec_vote_max_bw(codec, false);
  10487. return 0;
  10488. }
  10489. static int tasha_dig_core_power_collapse(struct tasha_priv *tasha,
  10490. int req_state)
  10491. {
  10492. struct snd_soc_codec *codec;
  10493. int cur_state;
  10494. /* Exit if feature is disabled */
  10495. if (!dig_core_collapse_enable)
  10496. return 0;
  10497. mutex_lock(&tasha->power_lock);
  10498. if (req_state == POWER_COLLAPSE)
  10499. tasha->power_active_ref--;
  10500. else if (req_state == POWER_RESUME)
  10501. tasha->power_active_ref++;
  10502. else
  10503. goto unlock_mutex;
  10504. if (tasha->power_active_ref < 0) {
  10505. dev_dbg(tasha->dev, "%s: power_active_ref is negative\n",
  10506. __func__);
  10507. goto unlock_mutex;
  10508. }
  10509. codec = tasha->codec;
  10510. if (!codec)
  10511. goto unlock_mutex;
  10512. if (req_state == POWER_COLLAPSE) {
  10513. if (tasha->power_active_ref == 0) {
  10514. schedule_delayed_work(&tasha->power_gate_work,
  10515. msecs_to_jiffies(dig_core_collapse_timer * 1000));
  10516. }
  10517. } else if (req_state == POWER_RESUME) {
  10518. if (tasha->power_active_ref == 1) {
  10519. /*
  10520. * At this point, there can be two cases:
  10521. * 1. Core already in power collapse state
  10522. * 2. Timer kicked in and still did not expire or
  10523. * waiting for the power_lock
  10524. */
  10525. cur_state = wcd9xxx_get_current_power_state(
  10526. tasha->wcd9xxx,
  10527. WCD9XXX_DIG_CORE_REGION_1);
  10528. if (cur_state == WCD_REGION_POWER_DOWN)
  10529. tasha_dig_core_remove_power_collapse(codec);
  10530. else {
  10531. mutex_unlock(&tasha->power_lock);
  10532. cancel_delayed_work_sync(
  10533. &tasha->power_gate_work);
  10534. mutex_lock(&tasha->power_lock);
  10535. }
  10536. }
  10537. }
  10538. unlock_mutex:
  10539. mutex_unlock(&tasha->power_lock);
  10540. return 0;
  10541. }
  10542. static int __tasha_cdc_mclk_enable_locked(struct tasha_priv *tasha,
  10543. bool enable)
  10544. {
  10545. int ret = 0;
  10546. if (!tasha->wcd_ext_clk) {
  10547. dev_err(tasha->dev, "%s: wcd ext clock is NULL\n", __func__);
  10548. return -EINVAL;
  10549. }
  10550. dev_dbg(tasha->dev, "%s: mclk_enable = %u\n", __func__, enable);
  10551. if (enable) {
  10552. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10553. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10554. if (ret)
  10555. goto err;
  10556. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10557. tasha_codec_apply_sido_voltage(tasha,
  10558. SIDO_VOLTAGE_NOMINAL_MV);
  10559. } else {
  10560. if (!dig_core_collapse_enable) {
  10561. clear_bit(AUDIO_NOMINAL, &tasha->status_mask);
  10562. tasha_codec_update_sido_voltage(tasha,
  10563. sido_buck_svs_voltage);
  10564. }
  10565. tasha_cdc_req_mclk_enable(tasha, false);
  10566. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10567. }
  10568. err:
  10569. return ret;
  10570. }
  10571. static int __tasha_cdc_mclk_enable(struct tasha_priv *tasha,
  10572. bool enable)
  10573. {
  10574. int ret;
  10575. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10576. ret = __tasha_cdc_mclk_enable_locked(tasha, enable);
  10577. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10578. return ret;
  10579. }
  10580. int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10581. {
  10582. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10583. return __tasha_cdc_mclk_enable(tasha, enable);
  10584. }
  10585. EXPORT_SYMBOL(tasha_cdc_mclk_enable);
  10586. int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable, bool dapm)
  10587. {
  10588. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10589. int ret = 0;
  10590. dev_dbg(tasha->dev, "%s: clk_mode: %d, enable: %d, clk_internal: %d\n",
  10591. __func__, tasha->clk_mode, enable, tasha->clk_internal);
  10592. if (tasha->clk_mode || tasha->clk_internal) {
  10593. if (enable) {
  10594. tasha_cdc_sido_ccl_enable(tasha, true);
  10595. wcd_resmgr_enable_master_bias(tasha->resmgr);
  10596. tasha_dig_core_power_collapse(tasha, POWER_RESUME);
  10597. snd_soc_update_bits(codec,
  10598. WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
  10599. 0x01, 0x01);
  10600. snd_soc_update_bits(codec,
  10601. WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL,
  10602. 0x01, 0x01);
  10603. set_bit(CPE_NOMINAL, &tasha->status_mask);
  10604. tasha_codec_update_sido_voltage(tasha,
  10605. SIDO_VOLTAGE_NOMINAL_MV);
  10606. tasha->clk_internal = true;
  10607. } else {
  10608. tasha->clk_internal = false;
  10609. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  10610. tasha_codec_update_sido_voltage(tasha,
  10611. sido_buck_svs_voltage);
  10612. tasha_dig_core_power_collapse(tasha, POWER_COLLAPSE);
  10613. wcd_resmgr_disable_master_bias(tasha->resmgr);
  10614. tasha_cdc_sido_ccl_enable(tasha, false);
  10615. }
  10616. } else {
  10617. ret = __tasha_cdc_mclk_enable(tasha, enable);
  10618. }
  10619. return ret;
  10620. }
  10621. EXPORT_SYMBOL(tasha_cdc_mclk_tx_enable);
  10622. static ssize_t tasha_codec_version_read(struct snd_info_entry *entry,
  10623. void *file_private_data, struct file *file,
  10624. char __user *buf, size_t count, loff_t pos)
  10625. {
  10626. struct tasha_priv *tasha;
  10627. struct wcd9xxx *wcd9xxx;
  10628. char buffer[TASHA_VERSION_ENTRY_SIZE];
  10629. int len = 0;
  10630. tasha = (struct tasha_priv *) entry->private_data;
  10631. if (!tasha) {
  10632. pr_err("%s: tasha priv is null\n", __func__);
  10633. return -EINVAL;
  10634. }
  10635. wcd9xxx = tasha->wcd9xxx;
  10636. if (wcd9xxx->codec_type->id_major == TASHA_MAJOR) {
  10637. if (TASHA_IS_1_0(wcd9xxx))
  10638. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_0\n");
  10639. else if (TASHA_IS_1_1(wcd9xxx))
  10640. len = snprintf(buffer, sizeof(buffer), "WCD9335_1_1\n");
  10641. else
  10642. snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10643. } else if (wcd9xxx->codec_type->id_major == TASHA2P0_MAJOR) {
  10644. len = snprintf(buffer, sizeof(buffer), "WCD9335_2_0\n");
  10645. } else
  10646. len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  10647. return simple_read_from_buffer(buf, count, &pos, buffer, len);
  10648. }
  10649. static struct snd_info_entry_ops tasha_codec_info_ops = {
  10650. .read = tasha_codec_version_read,
  10651. };
  10652. /*
  10653. * tasha_codec_info_create_codec_entry - creates wcd9335 module
  10654. * @codec_root: The parent directory
  10655. * @codec: Codec instance
  10656. *
  10657. * Creates wcd9335 module and version entry under the given
  10658. * parent directory.
  10659. *
  10660. * Return: 0 on success or negative error code on failure.
  10661. */
  10662. int tasha_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
  10663. struct snd_soc_codec *codec)
  10664. {
  10665. struct snd_info_entry *version_entry;
  10666. struct tasha_priv *tasha;
  10667. struct snd_soc_card *card;
  10668. if (!codec_root || !codec)
  10669. return -EINVAL;
  10670. tasha = snd_soc_codec_get_drvdata(codec);
  10671. card = codec->component.card;
  10672. tasha->entry = snd_info_create_subdir(codec_root->module,
  10673. "tasha", codec_root);
  10674. if (!tasha->entry) {
  10675. dev_dbg(codec->dev, "%s: failed to create wcd9335 entry\n",
  10676. __func__);
  10677. return -ENOMEM;
  10678. }
  10679. version_entry = snd_info_create_card_entry(card->snd_card,
  10680. "version",
  10681. tasha->entry);
  10682. if (!version_entry) {
  10683. dev_dbg(codec->dev, "%s: failed to create wcd9335 version entry\n",
  10684. __func__);
  10685. return -ENOMEM;
  10686. }
  10687. version_entry->private_data = tasha;
  10688. version_entry->size = TASHA_VERSION_ENTRY_SIZE;
  10689. version_entry->content = SNDRV_INFO_CONTENT_DATA;
  10690. version_entry->c.ops = &tasha_codec_info_ops;
  10691. if (snd_info_register(version_entry) < 0) {
  10692. snd_info_free_entry(version_entry);
  10693. return -ENOMEM;
  10694. }
  10695. tasha->version_entry = version_entry;
  10696. return 0;
  10697. }
  10698. EXPORT_SYMBOL(tasha_codec_info_create_codec_entry);
  10699. static int __tasha_codec_internal_rco_ctrl(
  10700. struct snd_soc_codec *codec, bool enable)
  10701. {
  10702. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10703. int ret = 0;
  10704. if (enable) {
  10705. tasha_cdc_sido_ccl_enable(tasha, true);
  10706. if (wcd_resmgr_get_clk_type(tasha->resmgr) ==
  10707. WCD_CLK_RCO) {
  10708. ret = wcd_resmgr_enable_clk_block(tasha->resmgr,
  10709. WCD_CLK_RCO);
  10710. } else {
  10711. ret = tasha_cdc_req_mclk_enable(tasha, true);
  10712. ret |= wcd_resmgr_enable_clk_block(tasha->resmgr,
  10713. WCD_CLK_RCO);
  10714. ret |= tasha_cdc_req_mclk_enable(tasha, false);
  10715. }
  10716. } else {
  10717. ret = wcd_resmgr_disable_clk_block(tasha->resmgr,
  10718. WCD_CLK_RCO);
  10719. tasha_cdc_sido_ccl_enable(tasha, false);
  10720. }
  10721. if (ret) {
  10722. dev_err(codec->dev, "%s: Error in %s RCO\n",
  10723. __func__, (enable ? "enabling" : "disabling"));
  10724. ret = -EINVAL;
  10725. }
  10726. return ret;
  10727. }
  10728. /*
  10729. * tasha_codec_internal_rco_ctrl()
  10730. * Make sure that the caller does not acquire
  10731. * BG_CLK_LOCK.
  10732. */
  10733. static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec,
  10734. bool enable)
  10735. {
  10736. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10737. int ret = 0;
  10738. WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr);
  10739. ret = __tasha_codec_internal_rco_ctrl(codec, enable);
  10740. WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr);
  10741. return ret;
  10742. }
  10743. /*
  10744. * tasha_mbhc_hs_detect: starts mbhc insertion/removal functionality
  10745. * @codec: handle to snd_soc_codec *
  10746. * @mbhc_cfg: handle to mbhc configuration structure
  10747. * return 0 if mbhc_start is success or error code in case of failure
  10748. */
  10749. int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
  10750. struct wcd_mbhc_config *mbhc_cfg)
  10751. {
  10752. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10753. return wcd_mbhc_start(&tasha->mbhc, mbhc_cfg);
  10754. }
  10755. EXPORT_SYMBOL(tasha_mbhc_hs_detect);
  10756. /*
  10757. * tasha_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
  10758. * @codec: handle to snd_soc_codec *
  10759. */
  10760. void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
  10761. {
  10762. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  10763. wcd_mbhc_stop(&tasha->mbhc);
  10764. }
  10765. EXPORT_SYMBOL(tasha_mbhc_hs_detect_exit);
  10766. static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv)
  10767. {
  10768. /* min micbias voltage is 1V and maximum is 2.85V */
  10769. if (micb_mv < 1000 || micb_mv > 2850) {
  10770. pr_err("%s: unsupported micbias voltage\n", __func__);
  10771. return -EINVAL;
  10772. }
  10773. return (micb_mv - 1000) / 50;
  10774. }
  10775. static const struct tasha_reg_mask_val tasha_reg_update_reset_val_1_1[] = {
  10776. {WCD9335_RCO_CTRL_2, 0xFF, 0x47},
  10777. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10778. };
  10779. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_1[] = {
  10780. {WCD9335_FLYBACK_VNEG_DAC_CTRL_1, 0xFF, 0x65},
  10781. {WCD9335_FLYBACK_VNEG_DAC_CTRL_2, 0xFF, 0x52},
  10782. {WCD9335_FLYBACK_VNEG_DAC_CTRL_3, 0xFF, 0xAF},
  10783. {WCD9335_FLYBACK_VNEG_DAC_CTRL_4, 0xFF, 0x60},
  10784. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0xF4},
  10785. {WCD9335_FLYBACK_VNEG_CTRL_9, 0xFF, 0x40},
  10786. {WCD9335_FLYBACK_VNEG_CTRL_2, 0xFF, 0x4F},
  10787. {WCD9335_FLYBACK_EN, 0xFF, 0x6E},
  10788. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xF8, 0xF8},
  10789. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xF8, 0xF8},
  10790. };
  10791. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_1_0[] = {
  10792. {WCD9335_FLYBACK_VNEG_CTRL_3, 0xFF, 0x54},
  10793. {WCD9335_CDC_RX2_RX_PATH_SEC0, 0xFC, 0xFC},
  10794. {WCD9335_CDC_RX1_RX_PATH_SEC0, 0xFC, 0xFC},
  10795. };
  10796. static const struct tasha_reg_mask_val tasha_codec_reg_init_val_2_0[] = {
  10797. {WCD9335_RCO_CTRL_2, 0x0F, 0x08},
  10798. {WCD9335_RX_BIAS_FLYB_MID_RST, 0xF0, 0x10},
  10799. {WCD9335_FLYBACK_CTRL_1, 0x20, 0x20},
  10800. {WCD9335_HPH_OCP_CTL, 0xFF, 0x7A},
  10801. {WCD9335_HPH_L_TEST, 0x01, 0x01},
  10802. {WCD9335_HPH_R_TEST, 0x01, 0x01},
  10803. {WCD9335_CDC_BOOST0_BOOST_CFG1, 0x3F, 0x12},
  10804. {WCD9335_CDC_BOOST0_BOOST_CFG2, 0x1C, 0x08},
  10805. {WCD9335_CDC_COMPANDER7_CTL7, 0x1E, 0x18},
  10806. {WCD9335_CDC_BOOST1_BOOST_CFG1, 0x3F, 0x12},
  10807. {WCD9335_CDC_BOOST1_BOOST_CFG2, 0x1C, 0x08},
  10808. {WCD9335_CDC_COMPANDER8_CTL7, 0x1E, 0x18},
  10809. {WCD9335_CDC_TX0_TX_PATH_SEC7, 0xFF, 0x45},
  10810. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xFC, 0xF4},
  10811. {WCD9335_HPH_REFBUFF_LP_CTL, 0x08, 0x08},
  10812. {WCD9335_HPH_REFBUFF_LP_CTL, 0x06, 0x02},
  10813. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xA0},
  10814. {WCD9335_SE_LO_COM1, 0xFF, 0xC0},
  10815. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xFC, 0xF4},
  10816. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xFC, 0xF4},
  10817. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xFC, 0xF8},
  10818. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xFC, 0xF8},
  10819. };
  10820. static const struct tasha_reg_mask_val tasha_codec_reg_defaults[] = {
  10821. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x00},
  10822. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x01},
  10823. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x04, 0x04},
  10824. };
  10825. static const struct tasha_reg_mask_val tasha_codec_reg_i2c_defaults[] = {
  10826. {WCD9335_ANA_CLK_TOP, 0x20, 0x20},
  10827. {WCD9335_CODEC_RPM_CLK_GATE, 0x03, 0x01},
  10828. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x03, 0x00},
  10829. {WCD9335_CODEC_RPM_CLK_MCLK_CFG, 0x05, 0x05},
  10830. {WCD9335_DATA_HUB_DATA_HUB_RX0_INP_CFG, 0x01, 0x01},
  10831. {WCD9335_DATA_HUB_DATA_HUB_RX1_INP_CFG, 0x01, 0x01},
  10832. {WCD9335_DATA_HUB_DATA_HUB_RX2_INP_CFG, 0x01, 0x01},
  10833. {WCD9335_DATA_HUB_DATA_HUB_RX3_INP_CFG, 0x01, 0x01},
  10834. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG, 0x05, 0x05},
  10835. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG, 0x05, 0x05},
  10836. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG, 0x05, 0x05},
  10837. {WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG, 0x05, 0x05},
  10838. };
  10839. static const struct tasha_reg_mask_val tasha_codec_reg_init_common_val[] = {
  10840. /* Rbuckfly/R_EAR(32) */
  10841. {WCD9335_CDC_CLSH_K2_MSB, 0x0F, 0x00},
  10842. {WCD9335_CDC_CLSH_K2_LSB, 0xFF, 0x60},
  10843. {WCD9335_CPE_SS_DMIC_CFG, 0x80, 0x00},
  10844. {WCD9335_CDC_BOOST0_BOOST_CTL, 0x70, 0x50},
  10845. {WCD9335_CDC_BOOST1_BOOST_CTL, 0x70, 0x50},
  10846. {WCD9335_CDC_RX7_RX_PATH_CFG1, 0x08, 0x08},
  10847. {WCD9335_CDC_RX8_RX_PATH_CFG1, 0x08, 0x08},
  10848. {WCD9335_ANA_LO_1_2, 0x3C, 0X3C},
  10849. {WCD9335_DIFF_LO_COM_SWCAP_REFBUF_FREQ, 0x70, 0x00},
  10850. {WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03, 0x03},
  10851. {WCD9335_CDC_TOP_TOP_CFG1, 0x02, 0x02},
  10852. {WCD9335_CDC_TOP_TOP_CFG1, 0x01, 0x01},
  10853. {WCD9335_EAR_CMBUFF, 0x08, 0x00},
  10854. {WCD9335_CDC_TX9_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10855. {WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10856. {WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10857. {WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
  10858. {WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
  10859. {WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
  10860. {WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
  10861. {WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
  10862. {WCD9335_CDC_RX0_RX_PATH_CFG0, 0x01, 0x01},
  10863. {WCD9335_CDC_RX1_RX_PATH_CFG0, 0x01, 0x01},
  10864. {WCD9335_CDC_RX2_RX_PATH_CFG0, 0x01, 0x01},
  10865. {WCD9335_CDC_RX3_RX_PATH_CFG0, 0x01, 0x01},
  10866. {WCD9335_CDC_RX4_RX_PATH_CFG0, 0x01, 0x01},
  10867. {WCD9335_CDC_RX5_RX_PATH_CFG0, 0x01, 0x01},
  10868. {WCD9335_CDC_RX6_RX_PATH_CFG0, 0x01, 0x01},
  10869. {WCD9335_CDC_RX7_RX_PATH_CFG0, 0x01, 0x01},
  10870. {WCD9335_CDC_RX8_RX_PATH_CFG0, 0x01, 0x01},
  10871. {WCD9335_CDC_RX0_RX_PATH_MIX_CFG, 0x01, 0x01},
  10872. {WCD9335_CDC_RX1_RX_PATH_MIX_CFG, 0x01, 0x01},
  10873. {WCD9335_CDC_RX2_RX_PATH_MIX_CFG, 0x01, 0x01},
  10874. {WCD9335_CDC_RX3_RX_PATH_MIX_CFG, 0x01, 0x01},
  10875. {WCD9335_CDC_RX4_RX_PATH_MIX_CFG, 0x01, 0x01},
  10876. {WCD9335_CDC_RX5_RX_PATH_MIX_CFG, 0x01, 0x01},
  10877. {WCD9335_CDC_RX6_RX_PATH_MIX_CFG, 0x01, 0x01},
  10878. {WCD9335_CDC_RX7_RX_PATH_MIX_CFG, 0x01, 0x01},
  10879. {WCD9335_CDC_RX8_RX_PATH_MIX_CFG, 0x01, 0x01},
  10880. {WCD9335_VBADC_IBIAS_FE, 0x0C, 0x08},
  10881. };
  10882. static const struct tasha_reg_mask_val tasha_codec_reg_init_1_x_val[] = {
  10883. /* Enable TX HPF Filter & Linear Phase */
  10884. {WCD9335_CDC_TX0_TX_PATH_CFG0, 0x11, 0x11},
  10885. {WCD9335_CDC_TX1_TX_PATH_CFG0, 0x11, 0x11},
  10886. {WCD9335_CDC_TX2_TX_PATH_CFG0, 0x11, 0x11},
  10887. {WCD9335_CDC_TX3_TX_PATH_CFG0, 0x11, 0x11},
  10888. {WCD9335_CDC_TX4_TX_PATH_CFG0, 0x11, 0x11},
  10889. {WCD9335_CDC_TX5_TX_PATH_CFG0, 0x11, 0x11},
  10890. {WCD9335_CDC_TX6_TX_PATH_CFG0, 0x11, 0x11},
  10891. {WCD9335_CDC_TX7_TX_PATH_CFG0, 0x11, 0x11},
  10892. {WCD9335_CDC_TX8_TX_PATH_CFG0, 0x11, 0x11},
  10893. {WCD9335_CDC_RX0_RX_PATH_SEC0, 0xF8, 0xF8},
  10894. {WCD9335_CDC_RX0_RX_PATH_SEC1, 0x08, 0x08},
  10895. {WCD9335_CDC_RX1_RX_PATH_SEC1, 0x08, 0x08},
  10896. {WCD9335_CDC_RX2_RX_PATH_SEC1, 0x08, 0x08},
  10897. {WCD9335_CDC_RX3_RX_PATH_SEC1, 0x08, 0x08},
  10898. {WCD9335_CDC_RX4_RX_PATH_SEC1, 0x08, 0x08},
  10899. {WCD9335_CDC_RX5_RX_PATH_SEC1, 0x08, 0x08},
  10900. {WCD9335_CDC_RX6_RX_PATH_SEC1, 0x08, 0x08},
  10901. {WCD9335_CDC_RX7_RX_PATH_SEC1, 0x08, 0x08},
  10902. {WCD9335_CDC_RX8_RX_PATH_SEC1, 0x08, 0x08},
  10903. {WCD9335_CDC_RX0_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10904. {WCD9335_CDC_RX1_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10905. {WCD9335_CDC_RX2_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10906. {WCD9335_CDC_RX3_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10907. {WCD9335_CDC_RX4_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10908. {WCD9335_CDC_RX5_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10909. {WCD9335_CDC_RX6_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10910. {WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10911. {WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, 0x08, 0x08},
  10912. {WCD9335_CDC_TX0_TX_PATH_SEC2, 0x01, 0x01},
  10913. {WCD9335_CDC_TX1_TX_PATH_SEC2, 0x01, 0x01},
  10914. {WCD9335_CDC_TX2_TX_PATH_SEC2, 0x01, 0x01},
  10915. {WCD9335_CDC_TX3_TX_PATH_SEC2, 0x01, 0x01},
  10916. {WCD9335_CDC_TX4_TX_PATH_SEC2, 0x01, 0x01},
  10917. {WCD9335_CDC_TX5_TX_PATH_SEC2, 0x01, 0x01},
  10918. {WCD9335_CDC_TX6_TX_PATH_SEC2, 0x01, 0x01},
  10919. {WCD9335_CDC_TX7_TX_PATH_SEC2, 0x01, 0x01},
  10920. {WCD9335_CDC_TX8_TX_PATH_SEC2, 0x01, 0x01},
  10921. {WCD9335_CDC_RX3_RX_PATH_SEC0, 0xF8, 0xF0},
  10922. {WCD9335_CDC_RX4_RX_PATH_SEC0, 0xF8, 0xF0},
  10923. {WCD9335_CDC_RX5_RX_PATH_SEC0, 0xF8, 0xF8},
  10924. {WCD9335_CDC_RX6_RX_PATH_SEC0, 0xF8, 0xF8},
  10925. {WCD9335_RX_OCP_COUNT, 0xFF, 0xFF},
  10926. {WCD9335_HPH_OCP_CTL, 0xF0, 0x70},
  10927. {WCD9335_CPE_SS_CPAR_CFG, 0xFF, 0x00},
  10928. {WCD9335_FLYBACK_VNEG_CTRL_1, 0xFF, 0x63},
  10929. {WCD9335_FLYBACK_VNEG_CTRL_4, 0xFF, 0x7F},
  10930. {WCD9335_CLASSH_CTRL_VCL_1, 0xFF, 0x60},
  10931. {WCD9335_CLASSH_CTRL_CCL_5, 0xFF, 0x40},
  10932. {WCD9335_RX_TIMER_DIV, 0xFF, 0x32},
  10933. {WCD9335_SE_LO_COM2, 0xFF, 0x01},
  10934. {WCD9335_MBHC_ZDET_ANA_CTL, 0x0F, 0x07},
  10935. {WCD9335_RX_BIAS_HPH_PA, 0xF0, 0x60},
  10936. {WCD9335_HPH_RDAC_LDO_CTL, 0x88, 0x88},
  10937. {WCD9335_HPH_L_EN, 0x20, 0x20},
  10938. {WCD9335_HPH_R_EN, 0x20, 0x20},
  10939. {WCD9335_DIFF_LO_CORE_OUT_PROG, 0xFC, 0xD8},
  10940. {WCD9335_CDC_RX5_RX_PATH_SEC3, 0xBD, 0xBD},
  10941. {WCD9335_CDC_RX6_RX_PATH_SEC3, 0xBD, 0xBD},
  10942. {WCD9335_DIFF_LO_COM_PA_FREQ, 0x70, 0x40},
  10943. };
  10944. static void tasha_update_reg_reset_values(struct snd_soc_codec *codec)
  10945. {
  10946. u32 i;
  10947. struct wcd9xxx *tasha_core = dev_get_drvdata(codec->dev->parent);
  10948. if (TASHA_IS_1_1(tasha_core)) {
  10949. for (i = 0; i < ARRAY_SIZE(tasha_reg_update_reset_val_1_1);
  10950. i++)
  10951. snd_soc_write(codec,
  10952. tasha_reg_update_reset_val_1_1[i].reg,
  10953. tasha_reg_update_reset_val_1_1[i].val);
  10954. }
  10955. }
  10956. static void tasha_codec_init_reg(struct snd_soc_codec *codec)
  10957. {
  10958. u32 i;
  10959. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  10960. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_common_val); i++)
  10961. snd_soc_update_bits(codec,
  10962. tasha_codec_reg_init_common_val[i].reg,
  10963. tasha_codec_reg_init_common_val[i].mask,
  10964. tasha_codec_reg_init_common_val[i].val);
  10965. if (TASHA_IS_1_1(wcd9xxx) ||
  10966. TASHA_IS_1_0(wcd9xxx))
  10967. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_1_x_val); i++)
  10968. snd_soc_update_bits(codec,
  10969. tasha_codec_reg_init_1_x_val[i].reg,
  10970. tasha_codec_reg_init_1_x_val[i].mask,
  10971. tasha_codec_reg_init_1_x_val[i].val);
  10972. if (TASHA_IS_1_1(wcd9xxx)) {
  10973. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_1); i++)
  10974. snd_soc_update_bits(codec,
  10975. tasha_codec_reg_init_val_1_1[i].reg,
  10976. tasha_codec_reg_init_val_1_1[i].mask,
  10977. tasha_codec_reg_init_val_1_1[i].val);
  10978. } else if (TASHA_IS_1_0(wcd9xxx)) {
  10979. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_0); i++)
  10980. snd_soc_update_bits(codec,
  10981. tasha_codec_reg_init_val_1_0[i].reg,
  10982. tasha_codec_reg_init_val_1_0[i].mask,
  10983. tasha_codec_reg_init_val_1_0[i].val);
  10984. } else if (TASHA_IS_2_0(wcd9xxx)) {
  10985. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_2_0); i++)
  10986. snd_soc_update_bits(codec,
  10987. tasha_codec_reg_init_val_2_0[i].reg,
  10988. tasha_codec_reg_init_val_2_0[i].mask,
  10989. tasha_codec_reg_init_val_2_0[i].val);
  10990. }
  10991. }
  10992. static void tasha_update_reg_defaults(struct tasha_priv *tasha)
  10993. {
  10994. u32 i;
  10995. struct wcd9xxx *wcd9xxx;
  10996. wcd9xxx = tasha->wcd9xxx;
  10997. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_defaults); i++)
  10998. regmap_update_bits(wcd9xxx->regmap,
  10999. tasha_codec_reg_defaults[i].reg,
  11000. tasha_codec_reg_defaults[i].mask,
  11001. tasha_codec_reg_defaults[i].val);
  11002. tasha->intf_type = wcd9xxx_get_intf_type();
  11003. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  11004. for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_i2c_defaults); i++)
  11005. regmap_update_bits(wcd9xxx->regmap,
  11006. tasha_codec_reg_i2c_defaults[i].reg,
  11007. tasha_codec_reg_i2c_defaults[i].mask,
  11008. tasha_codec_reg_i2c_defaults[i].val);
  11009. }
  11010. static void tasha_slim_interface_init_reg(struct snd_soc_codec *codec)
  11011. {
  11012. int i;
  11013. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11014. for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++)
  11015. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11016. TASHA_SLIM_PGD_PORT_INT_EN0 + i,
  11017. 0xFF);
  11018. }
  11019. static irqreturn_t tasha_slimbus_irq(int irq, void *data)
  11020. {
  11021. struct tasha_priv *priv = data;
  11022. unsigned long status = 0;
  11023. int i, j, port_id, k;
  11024. u32 bit;
  11025. u8 val, int_val = 0;
  11026. bool tx, cleared;
  11027. unsigned short reg = 0;
  11028. for (i = TASHA_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
  11029. i <= TASHA_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
  11030. val = wcd9xxx_interface_reg_read(priv->wcd9xxx, i);
  11031. status |= ((u32)val << (8 * j));
  11032. }
  11033. for_each_set_bit(j, &status, 32) {
  11034. tx = (j >= 16 ? true : false);
  11035. port_id = (tx ? j - 16 : j);
  11036. val = wcd9xxx_interface_reg_read(priv->wcd9xxx,
  11037. TASHA_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
  11038. if (val) {
  11039. if (!tx)
  11040. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  11041. (port_id / 8);
  11042. else
  11043. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  11044. (port_id / 8);
  11045. int_val = wcd9xxx_interface_reg_read(
  11046. priv->wcd9xxx, reg);
  11047. /*
  11048. * Ignore interrupts for ports for which the
  11049. * interrupts are not specifically enabled.
  11050. */
  11051. if (!(int_val & (1 << (port_id % 8))))
  11052. continue;
  11053. }
  11054. if (val & TASHA_SLIM_IRQ_OVERFLOW)
  11055. pr_err_ratelimited(
  11056. "%s: overflow error on %s port %d, value %x\n",
  11057. __func__, (tx ? "TX" : "RX"), port_id, val);
  11058. if (val & TASHA_SLIM_IRQ_UNDERFLOW)
  11059. pr_err_ratelimited(
  11060. "%s: underflow error on %s port %d, value %x\n",
  11061. __func__, (tx ? "TX" : "RX"), port_id, val);
  11062. if ((val & TASHA_SLIM_IRQ_OVERFLOW) ||
  11063. (val & TASHA_SLIM_IRQ_UNDERFLOW)) {
  11064. if (!tx)
  11065. reg = TASHA_SLIM_PGD_PORT_INT_EN0 +
  11066. (port_id / 8);
  11067. else
  11068. reg = TASHA_SLIM_PGD_PORT_INT_TX_EN0 +
  11069. (port_id / 8);
  11070. int_val = wcd9xxx_interface_reg_read(
  11071. priv->wcd9xxx, reg);
  11072. if (int_val & (1 << (port_id % 8))) {
  11073. int_val = int_val ^ (1 << (port_id % 8));
  11074. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11075. reg, int_val);
  11076. }
  11077. }
  11078. if (val & TASHA_SLIM_IRQ_PORT_CLOSED) {
  11079. /*
  11080. * INT SOURCE register starts from RX to TX
  11081. * but port number in the ch_mask is in opposite way
  11082. */
  11083. bit = (tx ? j - 16 : j + 16);
  11084. pr_debug("%s: %s port %d closed value %x, bit %u\n",
  11085. __func__, (tx ? "TX" : "RX"), port_id, val,
  11086. bit);
  11087. for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) {
  11088. pr_debug("%s: priv->dai[%d].ch_mask = 0x%lx\n",
  11089. __func__, k, priv->dai[k].ch_mask);
  11090. if (test_and_clear_bit(bit,
  11091. &priv->dai[k].ch_mask)) {
  11092. cleared = true;
  11093. if (!priv->dai[k].ch_mask)
  11094. wake_up(&priv->dai[k].dai_wait);
  11095. /*
  11096. * There are cases when multiple DAIs
  11097. * might be using the same slimbus
  11098. * channel. Hence don't break here.
  11099. */
  11100. }
  11101. }
  11102. WARN(!cleared,
  11103. "Couldn't find slimbus %s port %d for closing\n",
  11104. (tx ? "TX" : "RX"), port_id);
  11105. }
  11106. wcd9xxx_interface_reg_write(priv->wcd9xxx,
  11107. TASHA_SLIM_PGD_PORT_INT_CLR_RX_0 +
  11108. (j / 8),
  11109. 1 << (j % 8));
  11110. }
  11111. return IRQ_HANDLED;
  11112. }
  11113. static int tasha_setup_irqs(struct tasha_priv *tasha)
  11114. {
  11115. int ret = 0;
  11116. struct snd_soc_codec *codec = tasha->codec;
  11117. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11118. struct wcd9xxx_core_resource *core_res =
  11119. &wcd9xxx->core_res;
  11120. ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS,
  11121. tasha_slimbus_irq, "SLIMBUS Slave", tasha);
  11122. if (ret)
  11123. pr_err("%s: Failed to request irq %d\n", __func__,
  11124. WCD9XXX_IRQ_SLIMBUS);
  11125. else
  11126. tasha_slim_interface_init_reg(codec);
  11127. return ret;
  11128. }
  11129. static void tasha_init_slim_slave_cfg(struct snd_soc_codec *codec)
  11130. {
  11131. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11132. struct afe_param_cdc_slimbus_slave_cfg *cfg;
  11133. struct wcd9xxx *wcd9xxx = priv->wcd9xxx;
  11134. uint64_t eaddr = 0;
  11135. cfg = &priv->slimbus_slave_cfg;
  11136. cfg->minor_version = 1;
  11137. cfg->tx_slave_port_offset = 0;
  11138. cfg->rx_slave_port_offset = 16;
  11139. memcpy(&eaddr, &wcd9xxx->slim->e_addr, sizeof(wcd9xxx->slim->e_addr));
  11140. WARN_ON(sizeof(wcd9xxx->slim->e_addr) != 6);
  11141. cfg->device_enum_addr_lsw = eaddr & 0xFFFFFFFF;
  11142. cfg->device_enum_addr_msw = eaddr >> 32;
  11143. dev_dbg(codec->dev, "%s: slimbus logical address 0x%llx\n",
  11144. __func__, eaddr);
  11145. }
  11146. static void tasha_cleanup_irqs(struct tasha_priv *tasha)
  11147. {
  11148. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11149. struct wcd9xxx_core_resource *core_res =
  11150. &wcd9xxx->core_res;
  11151. wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tasha);
  11152. }
  11153. static int tasha_handle_pdata(struct tasha_priv *tasha,
  11154. struct wcd9xxx_pdata *pdata)
  11155. {
  11156. struct snd_soc_codec *codec = tasha->codec;
  11157. u8 dmic_ctl_val, mad_dmic_ctl_val;
  11158. u8 anc_ctl_value;
  11159. u32 def_dmic_rate, dmic_clk_drv;
  11160. int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4;
  11161. int rc = 0;
  11162. if (!pdata) {
  11163. dev_err(codec->dev, "%s: NULL pdata\n", __func__);
  11164. return -ENODEV;
  11165. }
  11166. /* set micbias voltage */
  11167. vout_ctl_1 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb1_mv);
  11168. vout_ctl_2 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb2_mv);
  11169. vout_ctl_3 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb3_mv);
  11170. vout_ctl_4 = wcd9335_get_micb_vout_ctl_val(pdata->micbias.micb4_mv);
  11171. if (vout_ctl_1 < 0 || vout_ctl_2 < 0 ||
  11172. vout_ctl_3 < 0 || vout_ctl_4 < 0) {
  11173. rc = -EINVAL;
  11174. goto done;
  11175. }
  11176. snd_soc_update_bits(codec, WCD9335_ANA_MICB1, 0x3F, vout_ctl_1);
  11177. snd_soc_update_bits(codec, WCD9335_ANA_MICB2, 0x3F, vout_ctl_2);
  11178. snd_soc_update_bits(codec, WCD9335_ANA_MICB3, 0x3F, vout_ctl_3);
  11179. snd_soc_update_bits(codec, WCD9335_ANA_MICB4, 0x3F, vout_ctl_4);
  11180. /* Set the DMIC sample rate */
  11181. switch (pdata->mclk_rate) {
  11182. case TASHA_MCLK_CLK_9P6MHZ:
  11183. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ;
  11184. break;
  11185. case TASHA_MCLK_CLK_12P288MHZ:
  11186. def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ;
  11187. break;
  11188. default:
  11189. /* should never happen */
  11190. dev_err(codec->dev, "%s: Invalid mclk_rate %d\n",
  11191. __func__, pdata->mclk_rate);
  11192. rc = -EINVAL;
  11193. goto done;
  11194. };
  11195. if (pdata->dmic_sample_rate ==
  11196. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11197. dev_info(codec->dev, "%s: dmic_rate invalid default = %d\n",
  11198. __func__, def_dmic_rate);
  11199. pdata->dmic_sample_rate = def_dmic_rate;
  11200. }
  11201. if (pdata->mad_dmic_sample_rate ==
  11202. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11203. dev_info(codec->dev, "%s: mad_dmic_rate invalid default = %d\n",
  11204. __func__, def_dmic_rate);
  11205. /*
  11206. * use dmic_sample_rate as the default for MAD
  11207. * if mad dmic sample rate is undefined
  11208. */
  11209. pdata->mad_dmic_sample_rate = pdata->dmic_sample_rate;
  11210. }
  11211. if (pdata->ecpp_dmic_sample_rate ==
  11212. WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) {
  11213. dev_info(codec->dev,
  11214. "%s: ecpp_dmic_rate invalid default = %d\n",
  11215. __func__, def_dmic_rate);
  11216. /*
  11217. * use dmic_sample_rate as the default for ECPP DMIC
  11218. * if ecpp dmic sample rate is undefined
  11219. */
  11220. pdata->ecpp_dmic_sample_rate = pdata->dmic_sample_rate;
  11221. }
  11222. if (pdata->dmic_clk_drv ==
  11223. WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED) {
  11224. pdata->dmic_clk_drv = WCD9335_DMIC_CLK_DRIVE_DEFAULT;
  11225. dev_info(codec->dev,
  11226. "%s: dmic_clk_strength invalid, default = %d\n",
  11227. __func__, pdata->dmic_clk_drv);
  11228. }
  11229. switch (pdata->dmic_clk_drv) {
  11230. case 2:
  11231. dmic_clk_drv = 0;
  11232. break;
  11233. case 4:
  11234. dmic_clk_drv = 1;
  11235. break;
  11236. case 8:
  11237. dmic_clk_drv = 2;
  11238. break;
  11239. case 16:
  11240. dmic_clk_drv = 3;
  11241. break;
  11242. default:
  11243. dev_err(codec->dev,
  11244. "%s: invalid dmic_clk_drv %d, using default\n",
  11245. __func__, pdata->dmic_clk_drv);
  11246. dmic_clk_drv = 0;
  11247. break;
  11248. }
  11249. snd_soc_update_bits(codec, WCD9335_TEST_DEBUG_PAD_DRVCTL,
  11250. 0x0C, dmic_clk_drv << 2);
  11251. /*
  11252. * Default the DMIC clk rates to mad_dmic_sample_rate,
  11253. * whereas, the anc/txfe dmic rates to dmic_sample_rate
  11254. * since the anc/txfe are independent of mad block.
  11255. */
  11256. mad_dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11257. pdata->mclk_rate,
  11258. pdata->mad_dmic_sample_rate);
  11259. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC0_CTL,
  11260. 0x0E, mad_dmic_ctl_val << 1);
  11261. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC1_CTL,
  11262. 0x0E, mad_dmic_ctl_val << 1);
  11263. snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC2_CTL,
  11264. 0x0E, mad_dmic_ctl_val << 1);
  11265. dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec,
  11266. pdata->mclk_rate,
  11267. pdata->dmic_sample_rate);
  11268. if (dmic_ctl_val == WCD9335_DMIC_CLK_DIV_2)
  11269. anc_ctl_value = WCD9335_ANC_DMIC_X2_FULL_RATE;
  11270. else
  11271. anc_ctl_value = WCD9335_ANC_DMIC_X2_HALF_RATE;
  11272. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11273. 0x40, anc_ctl_value << 6);
  11274. snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL,
  11275. 0x20, anc_ctl_value << 5);
  11276. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11277. 0x40, anc_ctl_value << 6);
  11278. snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL,
  11279. 0x20, anc_ctl_value << 5);
  11280. done:
  11281. return rc;
  11282. }
  11283. static struct wcd_cpe_core *tasha_codec_get_cpe_core(
  11284. struct snd_soc_codec *codec)
  11285. {
  11286. struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
  11287. return priv->cpe_core;
  11288. }
  11289. static int tasha_codec_cpe_fll_update_divider(
  11290. struct snd_soc_codec *codec, u32 cpe_fll_rate)
  11291. {
  11292. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11293. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11294. u32 div_val = 0, l_val = 0;
  11295. u32 computed_cpe_fll;
  11296. if (cpe_fll_rate != CPE_FLL_CLK_75MHZ &&
  11297. cpe_fll_rate != CPE_FLL_CLK_150MHZ) {
  11298. dev_err(codec->dev,
  11299. "%s: Invalid CPE fll rate request %u\n",
  11300. __func__, cpe_fll_rate);
  11301. return -EINVAL;
  11302. }
  11303. if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_12P288MHZ) {
  11304. /* update divider to 10 and enable 5x divider */
  11305. snd_soc_write(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11306. 0x55);
  11307. div_val = 10;
  11308. } else if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_9P6MHZ) {
  11309. /* update divider to 8 and enable 2x divider */
  11310. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11311. 0x7C, 0x70);
  11312. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_1,
  11313. 0xE0, 0x20);
  11314. div_val = 8;
  11315. } else {
  11316. dev_err(codec->dev,
  11317. "%s: Invalid MCLK rate %u\n",
  11318. __func__, wcd9xxx->mclk_rate);
  11319. return -EINVAL;
  11320. }
  11321. l_val = ((cpe_fll_rate / 1000) * div_val) /
  11322. (wcd9xxx->mclk_rate / 1000);
  11323. /* If l_val was integer truncated, increment l_val once */
  11324. computed_cpe_fll = (wcd9xxx->mclk_rate / div_val) * l_val;
  11325. if (computed_cpe_fll < cpe_fll_rate)
  11326. l_val++;
  11327. /* update L value LSB and MSB */
  11328. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_0,
  11329. (l_val & 0xFF));
  11330. snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_1,
  11331. ((l_val >> 8) & 0xFF));
  11332. tasha->current_cpe_clk_freq = cpe_fll_rate;
  11333. dev_dbg(codec->dev,
  11334. "%s: updated l_val to %u for cpe_clk %u and mclk %u\n",
  11335. __func__, l_val, cpe_fll_rate, wcd9xxx->mclk_rate);
  11336. return 0;
  11337. }
  11338. static int __tasha_cdc_change_cpe_clk(struct snd_soc_codec *codec,
  11339. u32 clk_freq)
  11340. {
  11341. int ret = 0;
  11342. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11343. if (!tasha_cdc_is_svs_enabled(tasha)) {
  11344. dev_dbg(codec->dev,
  11345. "%s: SVS not enabled or tasha is not 2p0, return\n",
  11346. __func__);
  11347. return 0;
  11348. }
  11349. dev_dbg(codec->dev, "%s: clk_freq = %u\n", __func__, clk_freq);
  11350. if (clk_freq == CPE_FLL_CLK_75MHZ) {
  11351. /* Change to SVS */
  11352. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11353. 0x08, 0x08);
  11354. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11355. ret = -EINVAL;
  11356. goto done;
  11357. }
  11358. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11359. 0x10, 0x10);
  11360. clear_bit(CPE_NOMINAL, &tasha->status_mask);
  11361. tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage);
  11362. } else if (clk_freq == CPE_FLL_CLK_150MHZ) {
  11363. /* change to nominal */
  11364. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11365. 0x08, 0x08);
  11366. set_bit(CPE_NOMINAL, &tasha->status_mask);
  11367. tasha_codec_update_sido_voltage(tasha, SIDO_VOLTAGE_NOMINAL_MV);
  11368. if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) {
  11369. ret = -EINVAL;
  11370. goto done;
  11371. }
  11372. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11373. 0x10, 0x10);
  11374. } else {
  11375. dev_err(codec->dev,
  11376. "%s: Invalid clk_freq request %d for CPE FLL\n",
  11377. __func__, clk_freq);
  11378. ret = -EINVAL;
  11379. }
  11380. done:
  11381. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11382. 0x10, 0x00);
  11383. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11384. 0x08, 0x00);
  11385. return ret;
  11386. }
  11387. static int tasha_codec_cpe_fll_enable(struct snd_soc_codec *codec,
  11388. bool enable)
  11389. {
  11390. struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11391. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11392. u8 clk_sel_reg_val = 0x00;
  11393. dev_dbg(codec->dev, "%s: enable = %s\n",
  11394. __func__, enable ? "true" : "false");
  11395. if (enable) {
  11396. if (tasha_cdc_is_svs_enabled(tasha)) {
  11397. /* FLL enable is always at SVS */
  11398. if (__tasha_cdc_change_cpe_clk(codec,
  11399. CPE_FLL_CLK_75MHZ)) {
  11400. dev_err(codec->dev,
  11401. "%s: clk change to %d failed\n",
  11402. __func__, CPE_FLL_CLK_75MHZ);
  11403. return -EINVAL;
  11404. }
  11405. } else {
  11406. if (tasha_codec_cpe_fll_update_divider(codec,
  11407. CPE_FLL_CLK_75MHZ)) {
  11408. dev_err(codec->dev,
  11409. "%s: clk change to %d failed\n",
  11410. __func__, CPE_FLL_CLK_75MHZ);
  11411. return -EINVAL;
  11412. }
  11413. }
  11414. if (TASHA_IS_1_0(wcd9xxx)) {
  11415. tasha_cdc_mclk_enable(codec, true, false);
  11416. clk_sel_reg_val = 0x02;
  11417. }
  11418. /* Setup CPE reference clk */
  11419. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11420. 0x02, clk_sel_reg_val);
  11421. /* enable CPE FLL reference clk */
  11422. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11423. 0x01, 0x01);
  11424. /* program the PLL */
  11425. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11426. 0x01, 0x01);
  11427. /* TEST clk setting */
  11428. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11429. 0x80, 0x80);
  11430. /* set FLL mode to HW controlled */
  11431. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11432. 0x60, 0x00);
  11433. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x80);
  11434. } else {
  11435. /* disable CPE FLL reference clk */
  11436. snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP,
  11437. 0x01, 0x00);
  11438. /* undo TEST clk setting */
  11439. snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0,
  11440. 0x80, 0x00);
  11441. /* undo FLL mode to HW control */
  11442. snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x00);
  11443. snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE,
  11444. 0x60, 0x20);
  11445. /* undo the PLL */
  11446. snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0,
  11447. 0x01, 0x00);
  11448. if (TASHA_IS_1_0(wcd9xxx))
  11449. tasha_cdc_mclk_enable(codec, false, false);
  11450. /*
  11451. * FLL could get disabled while at nominal,
  11452. * scale it back to SVS
  11453. */
  11454. if (tasha_cdc_is_svs_enabled(tasha))
  11455. __tasha_cdc_change_cpe_clk(codec,
  11456. CPE_FLL_CLK_75MHZ);
  11457. }
  11458. return 0;
  11459. }
  11460. static void tasha_cdc_query_cpe_clk_plan(void *data,
  11461. struct cpe_svc_cfg_clk_plan *clk_freq)
  11462. {
  11463. struct snd_soc_codec *codec = data;
  11464. struct tasha_priv *tasha;
  11465. u32 cpe_clk_khz;
  11466. if (!codec) {
  11467. pr_err("%s: Invalid codec handle\n",
  11468. __func__);
  11469. return;
  11470. }
  11471. tasha = snd_soc_codec_get_drvdata(codec);
  11472. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11473. dev_dbg(codec->dev,
  11474. "%s: current_clk_freq = %u\n",
  11475. __func__, tasha->current_cpe_clk_freq);
  11476. clk_freq->current_clk_feq = cpe_clk_khz;
  11477. clk_freq->num_clk_freqs = 2;
  11478. if (tasha_cdc_is_svs_enabled(tasha)) {
  11479. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ / 1000;
  11480. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ / 1000;
  11481. } else {
  11482. clk_freq->clk_freqs[0] = CPE_FLL_CLK_75MHZ;
  11483. clk_freq->clk_freqs[1] = CPE_FLL_CLK_150MHZ;
  11484. }
  11485. }
  11486. static void tasha_cdc_change_cpe_clk(void *data,
  11487. u32 clk_freq)
  11488. {
  11489. struct snd_soc_codec *codec = data;
  11490. struct tasha_priv *tasha;
  11491. u32 cpe_clk_khz, req_freq = 0;
  11492. if (!codec) {
  11493. pr_err("%s: Invalid codec handle\n",
  11494. __func__);
  11495. return;
  11496. }
  11497. tasha = snd_soc_codec_get_drvdata(codec);
  11498. cpe_clk_khz = tasha->current_cpe_clk_freq / 1000;
  11499. if (tasha_cdc_is_svs_enabled(tasha)) {
  11500. if ((clk_freq * 1000) <= CPE_FLL_CLK_75MHZ)
  11501. req_freq = CPE_FLL_CLK_75MHZ;
  11502. else
  11503. req_freq = CPE_FLL_CLK_150MHZ;
  11504. }
  11505. dev_dbg(codec->dev,
  11506. "%s: requested clk_freq = %u, current clk_freq = %u\n",
  11507. __func__, clk_freq * 1000,
  11508. tasha->current_cpe_clk_freq);
  11509. if (tasha_cdc_is_svs_enabled(tasha)) {
  11510. if (__tasha_cdc_change_cpe_clk(codec, req_freq))
  11511. dev_err(codec->dev,
  11512. "%s: clock/voltage scaling failed\n",
  11513. __func__);
  11514. }
  11515. }
  11516. static int tasha_codec_slim_reserve_bw(struct snd_soc_codec *codec,
  11517. u32 bw_ops, bool commit)
  11518. {
  11519. struct wcd9xxx *wcd9xxx;
  11520. if (!codec) {
  11521. pr_err("%s: Invalid handle to codec\n",
  11522. __func__);
  11523. return -EINVAL;
  11524. }
  11525. wcd9xxx = dev_get_drvdata(codec->dev->parent);
  11526. if (!wcd9xxx) {
  11527. dev_err(codec->dev, "%s: Invalid parent drv_data\n",
  11528. __func__);
  11529. return -EINVAL;
  11530. }
  11531. return wcd9xxx_slim_reserve_bw(wcd9xxx, bw_ops, commit);
  11532. }
  11533. static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
  11534. bool vote)
  11535. {
  11536. u32 bw_ops;
  11537. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11538. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C)
  11539. return 0;
  11540. mutex_lock(&tasha->sb_clk_gear_lock);
  11541. if (vote) {
  11542. tasha->ref_count++;
  11543. if (tasha->ref_count == 1) {
  11544. bw_ops = SLIM_BW_CLK_GEAR_9;
  11545. tasha_codec_slim_reserve_bw(codec,
  11546. bw_ops, true);
  11547. }
  11548. } else if (!vote && tasha->ref_count > 0) {
  11549. tasha->ref_count--;
  11550. if (tasha->ref_count == 0) {
  11551. bw_ops = SLIM_BW_UNVOTE;
  11552. tasha_codec_slim_reserve_bw(codec,
  11553. bw_ops, true);
  11554. }
  11555. };
  11556. dev_dbg(codec->dev, "%s Value of counter after vote or un-vote is %d\n",
  11557. __func__, tasha->ref_count);
  11558. mutex_unlock(&tasha->sb_clk_gear_lock);
  11559. return 0;
  11560. }
  11561. static int tasha_cpe_err_irq_control(struct snd_soc_codec *codec,
  11562. enum cpe_err_irq_cntl_type cntl_type, u8 *status)
  11563. {
  11564. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11565. u8 irq_bits;
  11566. if (TASHA_IS_2_0(tasha->wcd9xxx))
  11567. irq_bits = 0xFF;
  11568. else
  11569. irq_bits = 0x3F;
  11570. if (status)
  11571. irq_bits = (*status) & irq_bits;
  11572. switch (cntl_type) {
  11573. case CPE_ERR_IRQ_MASK:
  11574. snd_soc_update_bits(codec,
  11575. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11576. irq_bits, irq_bits);
  11577. break;
  11578. case CPE_ERR_IRQ_UNMASK:
  11579. snd_soc_update_bits(codec,
  11580. WCD9335_CPE_SS_SS_ERROR_INT_MASK,
  11581. irq_bits, 0x00);
  11582. break;
  11583. case CPE_ERR_IRQ_CLEAR:
  11584. snd_soc_write(codec, WCD9335_CPE_SS_SS_ERROR_INT_CLEAR,
  11585. irq_bits);
  11586. break;
  11587. case CPE_ERR_IRQ_STATUS:
  11588. if (!status)
  11589. return -EINVAL;
  11590. *status = snd_soc_read(codec,
  11591. WCD9335_CPE_SS_SS_ERROR_INT_STATUS);
  11592. break;
  11593. }
  11594. return 0;
  11595. }
  11596. static const struct wcd_cpe_cdc_cb cpe_cb = {
  11597. .cdc_clk_en = tasha_codec_internal_rco_ctrl,
  11598. .cpe_clk_en = tasha_codec_cpe_fll_enable,
  11599. .get_afe_out_port_id = tasha_codec_get_mad_port_id,
  11600. .lab_cdc_ch_ctl = tasha_codec_enable_slimtx_mad,
  11601. .cdc_ext_clk = tasha_cdc_mclk_enable,
  11602. .bus_vote_bw = tasha_codec_vote_max_bw,
  11603. .cpe_err_irq_control = tasha_cpe_err_irq_control,
  11604. };
  11605. static struct cpe_svc_init_param cpe_svc_params = {
  11606. .version = CPE_SVC_INIT_PARAM_V1,
  11607. .query_freq_plans_cb = tasha_cdc_query_cpe_clk_plan,
  11608. .change_freq_plan_cb = tasha_cdc_change_cpe_clk,
  11609. };
  11610. static int tasha_cpe_initialize(struct snd_soc_codec *codec)
  11611. {
  11612. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11613. struct wcd_cpe_params cpe_params;
  11614. memset(&cpe_params, 0,
  11615. sizeof(struct wcd_cpe_params));
  11616. cpe_params.codec = codec;
  11617. cpe_params.get_cpe_core = tasha_codec_get_cpe_core;
  11618. cpe_params.cdc_cb = &cpe_cb;
  11619. cpe_params.dbg_mode = cpe_debug_mode;
  11620. cpe_params.cdc_major_ver = CPE_SVC_CODEC_WCD9335;
  11621. cpe_params.cdc_minor_ver = CPE_SVC_CODEC_V1P0;
  11622. cpe_params.cdc_id = CPE_SVC_CODEC_WCD9335;
  11623. cpe_params.cdc_irq_info.cpe_engine_irq =
  11624. WCD9335_IRQ_SVA_OUTBOX1;
  11625. cpe_params.cdc_irq_info.cpe_err_irq =
  11626. WCD9335_IRQ_SVA_ERROR;
  11627. cpe_params.cdc_irq_info.cpe_fatal_irqs =
  11628. TASHA_CPE_FATAL_IRQS;
  11629. cpe_svc_params.context = codec;
  11630. cpe_params.cpe_svc_params = &cpe_svc_params;
  11631. tasha->cpe_core = wcd_cpe_init("cpe_9335", codec,
  11632. &cpe_params);
  11633. if (IS_ERR_OR_NULL(tasha->cpe_core)) {
  11634. dev_err(codec->dev,
  11635. "%s: Failed to enable CPE\n",
  11636. __func__);
  11637. return -EINVAL;
  11638. }
  11639. return 0;
  11640. }
  11641. static const struct wcd_resmgr_cb tasha_resmgr_cb = {
  11642. .cdc_rco_ctrl = __tasha_codec_internal_rco_ctrl,
  11643. };
  11644. static int tasha_device_down(struct wcd9xxx *wcd9xxx)
  11645. {
  11646. struct snd_soc_codec *codec;
  11647. struct tasha_priv *priv;
  11648. int count;
  11649. int i = 0;
  11650. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11651. priv = snd_soc_codec_get_drvdata(codec);
  11652. wcd_cpe_ssr_event(priv->cpe_core, WCD_CPE_BUS_DOWN_EVENT);
  11653. for (i = 0; i < priv->nr; i++)
  11654. swrm_wcd_notify(priv->swr_ctrl_data[i].swr_pdev,
  11655. SWR_DEVICE_DOWN, NULL);
  11656. snd_soc_card_change_online_state(codec->component.card, 0);
  11657. for (count = 0; count < NUM_CODEC_DAIS; count++)
  11658. priv->dai[count].bus_down_in_recovery = true;
  11659. priv->resmgr->sido_input_src = SIDO_SOURCE_INTERNAL;
  11660. return 0;
  11661. }
  11662. static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx)
  11663. {
  11664. int i, ret = 0;
  11665. struct wcd9xxx *control;
  11666. struct snd_soc_codec *codec;
  11667. struct tasha_priv *tasha;
  11668. struct wcd9xxx_pdata *pdata;
  11669. codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
  11670. tasha = snd_soc_codec_get_drvdata(codec);
  11671. control = dev_get_drvdata(codec->dev->parent);
  11672. wcd9xxx_set_power_state(tasha->wcd9xxx,
  11673. WCD_REGION_POWER_COLLAPSE_REMOVE,
  11674. WCD9XXX_DIG_CORE_REGION_1);
  11675. mutex_lock(&tasha->codec_mutex);
  11676. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11677. control->slim_slave->laddr;
  11678. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11679. control->slim->laddr;
  11680. tasha_init_slim_slave_cfg(codec);
  11681. if (tasha->machine_codec_event_cb)
  11682. tasha->machine_codec_event_cb(codec,
  11683. WCD9335_CODEC_EVENT_CODEC_UP);
  11684. snd_soc_card_change_online_state(codec->component.card, 1);
  11685. /* Class-H Init*/
  11686. wcd_clsh_init(&tasha->clsh_d);
  11687. for (i = 0; i < TASHA_MAX_MICBIAS; i++)
  11688. tasha->micb_ref[i] = 0;
  11689. tasha_update_reg_defaults(tasha);
  11690. tasha->codec = codec;
  11691. dev_dbg(codec->dev, "%s: MCLK Rate = %x\n",
  11692. __func__, control->mclk_rate);
  11693. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  11694. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11695. 0x03, 0x00);
  11696. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  11697. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11698. 0x03, 0x01);
  11699. tasha_codec_init_reg(codec);
  11700. wcd_resmgr_post_ssr_v2(tasha->resmgr);
  11701. tasha_enable_efuse_sensing(codec);
  11702. regcache_mark_dirty(codec->component.regmap);
  11703. regcache_sync(codec->component.regmap);
  11704. pdata = dev_get_platdata(codec->dev->parent);
  11705. ret = tasha_handle_pdata(tasha, pdata);
  11706. if (ret < 0)
  11707. dev_err(codec->dev, "%s: invalid pdata\n", __func__);
  11708. /* Reset reference counter for voting for max bw */
  11709. tasha->ref_count = 0;
  11710. /* MBHC Init */
  11711. wcd_mbhc_deinit(&tasha->mbhc);
  11712. tasha->mbhc_started = false;
  11713. /* Initialize MBHC module */
  11714. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11715. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11716. if (ret)
  11717. dev_err(codec->dev, "%s: mbhc initialization failed\n",
  11718. __func__);
  11719. else
  11720. tasha_mbhc_hs_detect(codec, tasha->mbhc.mbhc_cfg);
  11721. tasha_cleanup_irqs(tasha);
  11722. ret = tasha_setup_irqs(tasha);
  11723. if (ret) {
  11724. dev_err(codec->dev, "%s: tasha irq setup failed %d\n",
  11725. __func__, ret);
  11726. goto err;
  11727. }
  11728. tasha_set_spkr_mode(codec, tasha->spkr_mode);
  11729. wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT);
  11730. err:
  11731. mutex_unlock(&tasha->codec_mutex);
  11732. return ret;
  11733. }
  11734. static struct regulator *tasha_codec_find_ondemand_regulator(
  11735. struct snd_soc_codec *codec, const char *name)
  11736. {
  11737. int i;
  11738. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11739. struct wcd9xxx *wcd9xxx = tasha->wcd9xxx;
  11740. struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
  11741. for (i = 0; i < wcd9xxx->num_of_supplies; ++i) {
  11742. if (pdata->regulator[i].ondemand &&
  11743. wcd9xxx->supplies[i].supply &&
  11744. !strcmp(wcd9xxx->supplies[i].supply, name))
  11745. return wcd9xxx->supplies[i].consumer;
  11746. }
  11747. dev_dbg(tasha->dev, "Warning: regulator not found:%s\n",
  11748. name);
  11749. return NULL;
  11750. }
  11751. static int tasha_codec_probe(struct snd_soc_codec *codec)
  11752. {
  11753. struct wcd9xxx *control;
  11754. struct tasha_priv *tasha;
  11755. struct wcd9xxx_pdata *pdata;
  11756. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  11757. int i, ret;
  11758. void *ptr = NULL;
  11759. struct regulator *supply;
  11760. control = dev_get_drvdata(codec->dev->parent);
  11761. dev_info(codec->dev, "%s()\n", __func__);
  11762. tasha = snd_soc_codec_get_drvdata(codec);
  11763. tasha->intf_type = wcd9xxx_get_intf_type();
  11764. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11765. control->dev_down = tasha_device_down;
  11766. control->post_reset = tasha_post_reset_cb;
  11767. control->ssr_priv = (void *)codec;
  11768. }
  11769. /* Resource Manager post Init */
  11770. ret = wcd_resmgr_post_init(tasha->resmgr, &tasha_resmgr_cb, codec);
  11771. if (ret) {
  11772. dev_err(codec->dev, "%s: wcd resmgr post init failed\n",
  11773. __func__);
  11774. goto err;
  11775. }
  11776. /* Class-H Init*/
  11777. wcd_clsh_init(&tasha->clsh_d);
  11778. /* Default HPH Mode to Class-H HiFi */
  11779. tasha->hph_mode = CLS_H_HIFI;
  11780. tasha->codec = codec;
  11781. for (i = 0; i < COMPANDER_MAX; i++)
  11782. tasha->comp_enabled[i] = 0;
  11783. tasha->spkr_gain_offset = RX_GAIN_OFFSET_0_DB;
  11784. tasha->intf_type = wcd9xxx_get_intf_type();
  11785. tasha_update_reg_reset_values(codec);
  11786. pr_debug("%s: MCLK Rate = %x\n", __func__, control->mclk_rate);
  11787. if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ)
  11788. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11789. 0x03, 0x00);
  11790. else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ)
  11791. snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG,
  11792. 0x03, 0x01);
  11793. tasha_codec_init_reg(codec);
  11794. tasha_enable_efuse_sensing(codec);
  11795. pdata = dev_get_platdata(codec->dev->parent);
  11796. ret = tasha_handle_pdata(tasha, pdata);
  11797. if (ret < 0) {
  11798. pr_err("%s: bad pdata\n", __func__);
  11799. goto err;
  11800. }
  11801. supply = tasha_codec_find_ondemand_regulator(codec,
  11802. on_demand_supply_name[ON_DEMAND_MICBIAS]);
  11803. if (supply) {
  11804. tasha->on_demand_list[ON_DEMAND_MICBIAS].supply = supply;
  11805. tasha->on_demand_list[ON_DEMAND_MICBIAS].ondemand_supply_count =
  11806. 0;
  11807. }
  11808. tasha->fw_data = devm_kzalloc(codec->dev,
  11809. sizeof(*(tasha->fw_data)), GFP_KERNEL);
  11810. if (!tasha->fw_data)
  11811. goto err;
  11812. set_bit(WCD9XXX_ANC_CAL, tasha->fw_data->cal_bit);
  11813. set_bit(WCD9XXX_MBHC_CAL, tasha->fw_data->cal_bit);
  11814. set_bit(WCD9XXX_MAD_CAL, tasha->fw_data->cal_bit);
  11815. set_bit(WCD9XXX_VBAT_CAL, tasha->fw_data->cal_bit);
  11816. ret = wcd_cal_create_hwdep(tasha->fw_data,
  11817. WCD9XXX_CODEC_HWDEP_NODE, codec);
  11818. if (ret < 0) {
  11819. dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret);
  11820. goto err_hwdep;
  11821. }
  11822. /* Initialize MBHC module */
  11823. if (TASHA_IS_2_0(tasha->wcd9xxx)) {
  11824. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].reg =
  11825. WCD9335_MBHC_FSM_STATUS;
  11826. wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].mask = 0x01;
  11827. }
  11828. ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids,
  11829. wcd_mbhc_registers, TASHA_ZDET_SUPPORTED);
  11830. if (ret) {
  11831. pr_err("%s: mbhc initialization failed\n", __func__);
  11832. goto err_hwdep;
  11833. }
  11834. ptr = devm_kzalloc(codec->dev, (sizeof(tasha_rx_chs) +
  11835. sizeof(tasha_tx_chs)), GFP_KERNEL);
  11836. if (!ptr) {
  11837. ret = -ENOMEM;
  11838. goto err_hwdep;
  11839. }
  11840. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
  11841. snd_soc_dapm_new_controls(dapm, tasha_dapm_i2s_widgets,
  11842. ARRAY_SIZE(tasha_dapm_i2s_widgets));
  11843. snd_soc_dapm_add_routes(dapm, audio_i2s_map,
  11844. ARRAY_SIZE(audio_i2s_map));
  11845. for (i = 0; i < ARRAY_SIZE(tasha_i2s_dai); i++) {
  11846. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11847. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11848. }
  11849. } else if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11850. for (i = 0; i < NUM_CODEC_DAIS; i++) {
  11851. INIT_LIST_HEAD(&tasha->dai[i].wcd9xxx_ch_list);
  11852. init_waitqueue_head(&tasha->dai[i].dai_wait);
  11853. }
  11854. tasha_slimbus_slave_port_cfg.slave_dev_intfdev_la =
  11855. control->slim_slave->laddr;
  11856. tasha_slimbus_slave_port_cfg.slave_dev_pgd_la =
  11857. control->slim->laddr;
  11858. tasha_slimbus_slave_port_cfg.slave_port_mapping[0] =
  11859. TASHA_TX13;
  11860. tasha_init_slim_slave_cfg(codec);
  11861. }
  11862. snd_soc_add_codec_controls(codec, impedance_detect_controls,
  11863. ARRAY_SIZE(impedance_detect_controls));
  11864. snd_soc_add_codec_controls(codec, hph_type_detect_controls,
  11865. ARRAY_SIZE(hph_type_detect_controls));
  11866. snd_soc_add_codec_controls(codec,
  11867. tasha_analog_gain_controls,
  11868. ARRAY_SIZE(tasha_analog_gain_controls));
  11869. control->num_rx_port = TASHA_RX_MAX;
  11870. control->rx_chs = ptr;
  11871. memcpy(control->rx_chs, tasha_rx_chs, sizeof(tasha_rx_chs));
  11872. control->num_tx_port = TASHA_TX_MAX;
  11873. control->tx_chs = ptr + sizeof(tasha_rx_chs);
  11874. memcpy(control->tx_chs, tasha_tx_chs, sizeof(tasha_tx_chs));
  11875. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Playback");
  11876. snd_soc_dapm_ignore_suspend(dapm, "AIF1 Capture");
  11877. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Playback");
  11878. snd_soc_dapm_ignore_suspend(dapm, "AIF2 Capture");
  11879. if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
  11880. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Playback");
  11881. snd_soc_dapm_ignore_suspend(dapm, "AIF3 Capture");
  11882. snd_soc_dapm_ignore_suspend(dapm, "AIF4 Playback");
  11883. snd_soc_dapm_ignore_suspend(dapm, "AIF Mix Playback");
  11884. snd_soc_dapm_ignore_suspend(dapm, "AIF4 MAD TX");
  11885. snd_soc_dapm_ignore_suspend(dapm, "VIfeed");
  11886. snd_soc_dapm_ignore_suspend(dapm, "AIF5 CPE TX");
  11887. }
  11888. snd_soc_dapm_sync(dapm);
  11889. ret = tasha_setup_irqs(tasha);
  11890. if (ret) {
  11891. pr_err("%s: tasha irq setup failed %d\n", __func__, ret);
  11892. goto err_pdata;
  11893. }
  11894. ret = tasha_cpe_initialize(codec);
  11895. if (ret) {
  11896. dev_err(codec->dev,
  11897. "%s: cpe initialization failed, err = %d\n",
  11898. __func__, ret);
  11899. /* Do not fail probe if CPE failed */
  11900. ret = 0;
  11901. }
  11902. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11903. tasha->tx_hpf_work[i].tasha = tasha;
  11904. tasha->tx_hpf_work[i].decimator = i;
  11905. INIT_DELAYED_WORK(&tasha->tx_hpf_work[i].dwork,
  11906. tasha_tx_hpf_corner_freq_callback);
  11907. }
  11908. for (i = 0; i < TASHA_NUM_DECIMATORS; i++) {
  11909. tasha->tx_mute_dwork[i].tasha = tasha;
  11910. tasha->tx_mute_dwork[i].decimator = i;
  11911. INIT_DELAYED_WORK(&tasha->tx_mute_dwork[i].dwork,
  11912. tasha_tx_mute_update_callback);
  11913. }
  11914. tasha->spk_anc_dwork.tasha = tasha;
  11915. INIT_DELAYED_WORK(&tasha->spk_anc_dwork.dwork,
  11916. tasha_spk_anc_update_callback);
  11917. mutex_lock(&tasha->codec_mutex);
  11918. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1");
  11919. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2");
  11920. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1 PA");
  11921. snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2 PA");
  11922. snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
  11923. snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
  11924. snd_soc_dapm_disable_pin(dapm, "ANC HPHL PA");
  11925. snd_soc_dapm_disable_pin(dapm, "ANC HPHR PA");
  11926. snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
  11927. snd_soc_dapm_disable_pin(dapm, "ANC EAR");
  11928. snd_soc_dapm_disable_pin(dapm, "ANC SPK1 PA");
  11929. mutex_unlock(&tasha->codec_mutex);
  11930. snd_soc_dapm_sync(dapm);
  11931. return ret;
  11932. err_pdata:
  11933. devm_kfree(codec->dev, ptr);
  11934. control->rx_chs = NULL;
  11935. control->tx_chs = NULL;
  11936. err_hwdep:
  11937. devm_kfree(codec->dev, tasha->fw_data);
  11938. tasha->fw_data = NULL;
  11939. err:
  11940. return ret;
  11941. }
  11942. static int tasha_codec_remove(struct snd_soc_codec *codec)
  11943. {
  11944. struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec);
  11945. struct wcd9xxx *control;
  11946. control = dev_get_drvdata(codec->dev->parent);
  11947. control->num_rx_port = 0;
  11948. control->num_tx_port = 0;
  11949. control->rx_chs = NULL;
  11950. control->tx_chs = NULL;
  11951. tasha_cleanup_irqs(tasha);
  11952. /* Cleanup MBHC */
  11953. wcd_mbhc_deinit(&tasha->mbhc);
  11954. /* Cleanup resmgr */
  11955. return 0;
  11956. }
  11957. static struct regmap *tasha_get_regmap(struct device *dev)
  11958. {
  11959. struct wcd9xxx *control = dev_get_drvdata(dev->parent);
  11960. return control->regmap;
  11961. }
  11962. static struct snd_soc_codec_driver soc_codec_dev_tasha = {
  11963. .probe = tasha_codec_probe,
  11964. .remove = tasha_codec_remove,
  11965. .get_regmap = tasha_get_regmap,
  11966. .component_driver = {
  11967. .controls = tasha_snd_controls,
  11968. .num_controls = ARRAY_SIZE(tasha_snd_controls),
  11969. .dapm_widgets = tasha_dapm_widgets,
  11970. .num_dapm_widgets = ARRAY_SIZE(tasha_dapm_widgets),
  11971. .dapm_routes = audio_map,
  11972. .num_dapm_routes = ARRAY_SIZE(audio_map),
  11973. },
  11974. };
  11975. #ifdef CONFIG_PM
  11976. static int tasha_suspend(struct device *dev)
  11977. {
  11978. struct platform_device *pdev = to_platform_device(dev);
  11979. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  11980. dev_dbg(dev, "%s: system suspend\n", __func__);
  11981. if (cancel_delayed_work_sync(&tasha->power_gate_work))
  11982. tasha_codec_power_gate_digital_core(tasha);
  11983. return 0;
  11984. }
  11985. static int tasha_resume(struct device *dev)
  11986. {
  11987. struct platform_device *pdev = to_platform_device(dev);
  11988. struct tasha_priv *tasha = platform_get_drvdata(pdev);
  11989. if (!tasha) {
  11990. dev_err(dev, "%s: tasha private data is NULL\n", __func__);
  11991. return -EINVAL;
  11992. }
  11993. dev_dbg(dev, "%s: system resume\n", __func__);
  11994. return 0;
  11995. }
  11996. static const struct dev_pm_ops tasha_pm_ops = {
  11997. .suspend = tasha_suspend,
  11998. .resume = tasha_resume,
  11999. };
  12000. #endif
  12001. static int tasha_swrm_read(void *handle, int reg)
  12002. {
  12003. struct tasha_priv *tasha;
  12004. struct wcd9xxx *wcd9xxx;
  12005. unsigned short swr_rd_addr_base;
  12006. unsigned short swr_rd_data_base;
  12007. int val, ret;
  12008. if (!handle) {
  12009. pr_err("%s: NULL handle\n", __func__);
  12010. return -EINVAL;
  12011. }
  12012. tasha = (struct tasha_priv *)handle;
  12013. wcd9xxx = tasha->wcd9xxx;
  12014. dev_dbg(tasha->dev, "%s: Reading soundwire register, 0x%x\n",
  12015. __func__, reg);
  12016. swr_rd_addr_base = WCD9335_SWR_AHB_BRIDGE_RD_ADDR_0;
  12017. swr_rd_data_base = WCD9335_SWR_AHB_BRIDGE_RD_DATA_0;
  12018. /* read_lock */
  12019. mutex_lock(&tasha->swr_read_lock);
  12020. ret = regmap_bulk_write(wcd9xxx->regmap, swr_rd_addr_base,
  12021. (u8 *)&reg, 4);
  12022. if (ret < 0) {
  12023. pr_err("%s: RD Addr Failure\n", __func__);
  12024. goto err;
  12025. }
  12026. /* Check for RD status */
  12027. ret = regmap_bulk_read(wcd9xxx->regmap, swr_rd_data_base,
  12028. (u8 *)&val, 4);
  12029. if (ret < 0) {
  12030. pr_err("%s: RD Data Failure\n", __func__);
  12031. goto err;
  12032. }
  12033. ret = val;
  12034. err:
  12035. /* read_unlock */
  12036. mutex_unlock(&tasha->swr_read_lock);
  12037. return ret;
  12038. }
  12039. static int tasha_swrm_i2s_bulk_write(struct wcd9xxx *wcd9xxx,
  12040. struct wcd9xxx_reg_val *bulk_reg,
  12041. size_t len)
  12042. {
  12043. int i, ret = 0;
  12044. unsigned short swr_wr_addr_base;
  12045. unsigned short swr_wr_data_base;
  12046. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12047. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12048. for (i = 0; i < (len * 2); i += 2) {
  12049. /* First Write the Data to register */
  12050. ret = regmap_bulk_write(wcd9xxx->regmap,
  12051. swr_wr_data_base, bulk_reg[i].buf, 4);
  12052. if (ret < 0) {
  12053. dev_err(wcd9xxx->dev, "%s: WR Data Failure\n",
  12054. __func__);
  12055. break;
  12056. }
  12057. /* Next Write Address */
  12058. ret = regmap_bulk_write(wcd9xxx->regmap,
  12059. swr_wr_addr_base, bulk_reg[i+1].buf, 4);
  12060. if (ret < 0) {
  12061. dev_err(wcd9xxx->dev, "%s: WR Addr Failure\n",
  12062. __func__);
  12063. break;
  12064. }
  12065. }
  12066. return ret;
  12067. }
  12068. static int tasha_swrm_bulk_write(void *handle, u32 *reg, u32 *val, size_t len)
  12069. {
  12070. struct tasha_priv *tasha;
  12071. struct wcd9xxx *wcd9xxx;
  12072. struct wcd9xxx_reg_val *bulk_reg;
  12073. unsigned short swr_wr_addr_base;
  12074. unsigned short swr_wr_data_base;
  12075. int i, j, ret;
  12076. if (!handle) {
  12077. pr_err("%s: NULL handle\n", __func__);
  12078. return -EINVAL;
  12079. }
  12080. if (len <= 0) {
  12081. pr_err("%s: Invalid size: %zu\n", __func__, len);
  12082. return -EINVAL;
  12083. }
  12084. tasha = (struct tasha_priv *)handle;
  12085. wcd9xxx = tasha->wcd9xxx;
  12086. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12087. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12088. bulk_reg = kzalloc((2 * len * sizeof(struct wcd9xxx_reg_val)),
  12089. GFP_KERNEL);
  12090. if (!bulk_reg)
  12091. return -ENOMEM;
  12092. for (i = 0, j = 0; i < (len * 2); i += 2, j++) {
  12093. bulk_reg[i].reg = swr_wr_data_base;
  12094. bulk_reg[i].buf = (u8 *)(&val[j]);
  12095. bulk_reg[i].bytes = 4;
  12096. bulk_reg[i+1].reg = swr_wr_addr_base;
  12097. bulk_reg[i+1].buf = (u8 *)(&reg[j]);
  12098. bulk_reg[i+1].bytes = 4;
  12099. }
  12100. mutex_lock(&tasha->swr_write_lock);
  12101. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12102. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, len);
  12103. if (ret) {
  12104. dev_err(tasha->dev, "%s: i2s bulk write failed, ret: %d\n",
  12105. __func__, ret);
  12106. }
  12107. } else {
  12108. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg,
  12109. (len * 2), false);
  12110. if (ret) {
  12111. dev_err(tasha->dev, "%s: swrm bulk write failed, ret: %d\n",
  12112. __func__, ret);
  12113. }
  12114. }
  12115. mutex_unlock(&tasha->swr_write_lock);
  12116. kfree(bulk_reg);
  12117. return ret;
  12118. }
  12119. static int tasha_swrm_write(void *handle, int reg, int val)
  12120. {
  12121. struct tasha_priv *tasha;
  12122. struct wcd9xxx *wcd9xxx;
  12123. unsigned short swr_wr_addr_base;
  12124. unsigned short swr_wr_data_base;
  12125. struct wcd9xxx_reg_val bulk_reg[2];
  12126. int ret;
  12127. if (!handle) {
  12128. pr_err("%s: NULL handle\n", __func__);
  12129. return -EINVAL;
  12130. }
  12131. tasha = (struct tasha_priv *)handle;
  12132. wcd9xxx = tasha->wcd9xxx;
  12133. swr_wr_addr_base = WCD9335_SWR_AHB_BRIDGE_WR_ADDR_0;
  12134. swr_wr_data_base = WCD9335_SWR_AHB_BRIDGE_WR_DATA_0;
  12135. /* First Write the Data to register */
  12136. bulk_reg[0].reg = swr_wr_data_base;
  12137. bulk_reg[0].buf = (u8 *)(&val);
  12138. bulk_reg[0].bytes = 4;
  12139. bulk_reg[1].reg = swr_wr_addr_base;
  12140. bulk_reg[1].buf = (u8 *)(&reg);
  12141. bulk_reg[1].bytes = 4;
  12142. mutex_lock(&tasha->swr_write_lock);
  12143. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12144. ret = tasha_swrm_i2s_bulk_write(wcd9xxx, bulk_reg, 1);
  12145. if (ret) {
  12146. dev_err(tasha->dev, "%s: i2s swrm write failed, ret: %d\n",
  12147. __func__, ret);
  12148. }
  12149. } else {
  12150. ret = wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2, false);
  12151. if (ret < 0)
  12152. pr_err("%s: WR Data Failure\n", __func__);
  12153. }
  12154. mutex_unlock(&tasha->swr_write_lock);
  12155. return ret;
  12156. }
  12157. static int tasha_swrm_clock(void *handle, bool enable)
  12158. {
  12159. struct tasha_priv *tasha = (struct tasha_priv *) handle;
  12160. mutex_lock(&tasha->swr_clk_lock);
  12161. dev_dbg(tasha->dev, "%s: swrm clock %s\n",
  12162. __func__, (enable?"enable" : "disable"));
  12163. if (enable) {
  12164. tasha->swr_clk_users++;
  12165. if (tasha->swr_clk_users == 1) {
  12166. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12167. regmap_update_bits(
  12168. tasha->wcd9xxx->regmap,
  12169. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12170. 0x10, 0x00);
  12171. __tasha_cdc_mclk_enable(tasha, true);
  12172. regmap_update_bits(tasha->wcd9xxx->regmap,
  12173. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12174. 0x01, 0x01);
  12175. }
  12176. } else {
  12177. tasha->swr_clk_users--;
  12178. if (tasha->swr_clk_users == 0) {
  12179. regmap_update_bits(tasha->wcd9xxx->regmap,
  12180. WCD9335_CDC_CLK_RST_CTRL_SWR_CONTROL,
  12181. 0x01, 0x00);
  12182. __tasha_cdc_mclk_enable(tasha, false);
  12183. if (TASHA_IS_2_0(tasha->wcd9xxx))
  12184. regmap_update_bits(
  12185. tasha->wcd9xxx->regmap,
  12186. WCD9335_TEST_DEBUG_NPL_DLY_TEST_1,
  12187. 0x10, 0x10);
  12188. }
  12189. }
  12190. dev_dbg(tasha->dev, "%s: swrm clock users %d\n",
  12191. __func__, tasha->swr_clk_users);
  12192. mutex_unlock(&tasha->swr_clk_lock);
  12193. return 0;
  12194. }
  12195. static int tasha_swrm_handle_irq(void *handle,
  12196. irqreturn_t (*swrm_irq_handler)(int irq,
  12197. void *data),
  12198. void *swrm_handle,
  12199. int action)
  12200. {
  12201. struct tasha_priv *tasha;
  12202. int ret = 0;
  12203. struct wcd9xxx *wcd9xxx;
  12204. if (!handle) {
  12205. pr_err("%s: null handle received\n", __func__);
  12206. return -EINVAL;
  12207. }
  12208. tasha = (struct tasha_priv *) handle;
  12209. wcd9xxx = tasha->wcd9xxx;
  12210. if (action) {
  12211. ret = wcd9xxx_request_irq(&wcd9xxx->core_res,
  12212. WCD9335_IRQ_SOUNDWIRE,
  12213. swrm_irq_handler,
  12214. "Tasha SWR Master", swrm_handle);
  12215. if (ret)
  12216. dev_err(tasha->dev, "%s: Failed to request irq %d\n",
  12217. __func__, WCD9335_IRQ_SOUNDWIRE);
  12218. } else
  12219. wcd9xxx_free_irq(&wcd9xxx->core_res, WCD9335_IRQ_SOUNDWIRE,
  12220. swrm_handle);
  12221. return ret;
  12222. }
  12223. static void tasha_add_child_devices(struct work_struct *work)
  12224. {
  12225. struct tasha_priv *tasha;
  12226. struct platform_device *pdev;
  12227. struct device_node *node;
  12228. struct wcd9xxx *wcd9xxx;
  12229. struct tasha_swr_ctrl_data *swr_ctrl_data = NULL, *temp;
  12230. int ret, ctrl_num = 0;
  12231. struct wcd_swr_ctrl_platform_data *platdata;
  12232. char plat_dev_name[WCD9335_STRING_LEN];
  12233. tasha = container_of(work, struct tasha_priv,
  12234. tasha_add_child_devices_work);
  12235. if (!tasha) {
  12236. pr_err("%s: Memory for WCD9335 does not exist\n",
  12237. __func__);
  12238. return;
  12239. }
  12240. wcd9xxx = tasha->wcd9xxx;
  12241. if (!wcd9xxx) {
  12242. pr_err("%s: Memory for WCD9XXX does not exist\n",
  12243. __func__);
  12244. return;
  12245. }
  12246. if (!wcd9xxx->dev->of_node) {
  12247. pr_err("%s: DT node for wcd9xxx does not exist\n",
  12248. __func__);
  12249. return;
  12250. }
  12251. platdata = &tasha->swr_plat_data;
  12252. tasha->child_count = 0;
  12253. for_each_child_of_node(wcd9xxx->dev->of_node, node) {
  12254. if (!strcmp(node->name, "swr_master"))
  12255. strlcpy(plat_dev_name, "tasha_swr_ctrl",
  12256. (WCD9335_STRING_LEN - 1));
  12257. else if (strnstr(node->name, "msm_cdc_pinctrl",
  12258. strlen("msm_cdc_pinctrl")) != NULL)
  12259. strlcpy(plat_dev_name, node->name,
  12260. (WCD9335_STRING_LEN - 1));
  12261. else
  12262. continue;
  12263. pdev = platform_device_alloc(plat_dev_name, -1);
  12264. if (!pdev) {
  12265. dev_err(wcd9xxx->dev, "%s: pdev memory alloc failed\n",
  12266. __func__);
  12267. ret = -ENOMEM;
  12268. goto err;
  12269. }
  12270. pdev->dev.parent = tasha->dev;
  12271. pdev->dev.of_node = node;
  12272. if (!strcmp(node->name, "swr_master")) {
  12273. ret = platform_device_add_data(pdev, platdata,
  12274. sizeof(*platdata));
  12275. if (ret) {
  12276. dev_err(&pdev->dev,
  12277. "%s: cannot add plat data ctrl:%d\n",
  12278. __func__, ctrl_num);
  12279. goto fail_pdev_add;
  12280. }
  12281. }
  12282. ret = platform_device_add(pdev);
  12283. if (ret) {
  12284. dev_err(&pdev->dev,
  12285. "%s: Cannot add platform device\n",
  12286. __func__);
  12287. goto fail_pdev_add;
  12288. }
  12289. if (!strcmp(node->name, "swr_master")) {
  12290. temp = krealloc(swr_ctrl_data,
  12291. (ctrl_num + 1) * sizeof(
  12292. struct tasha_swr_ctrl_data),
  12293. GFP_KERNEL);
  12294. if (!temp) {
  12295. dev_err(wcd9xxx->dev, "out of memory\n");
  12296. ret = -ENOMEM;
  12297. goto err;
  12298. }
  12299. swr_ctrl_data = temp;
  12300. swr_ctrl_data[ctrl_num].swr_pdev = pdev;
  12301. ctrl_num++;
  12302. dev_dbg(&pdev->dev,
  12303. "%s: Added soundwire ctrl device(s)\n",
  12304. __func__);
  12305. tasha->nr = ctrl_num;
  12306. tasha->swr_ctrl_data = swr_ctrl_data;
  12307. }
  12308. if (tasha->child_count < WCD9335_CHILD_DEVICES_MAX)
  12309. tasha->pdev_child_devices[tasha->child_count++] = pdev;
  12310. else
  12311. goto err;
  12312. }
  12313. return;
  12314. fail_pdev_add:
  12315. platform_device_put(pdev);
  12316. err:
  12317. return;
  12318. }
  12319. /*
  12320. * tasha_codec_ver: to get tasha codec version
  12321. * @codec: handle to snd_soc_codec *
  12322. * return enum codec_variant - version
  12323. */
  12324. enum codec_variant tasha_codec_ver(void)
  12325. {
  12326. return codec_ver;
  12327. }
  12328. EXPORT_SYMBOL(tasha_codec_ver);
  12329. static int __tasha_enable_efuse_sensing(struct tasha_priv *tasha)
  12330. {
  12331. int val, rc;
  12332. __tasha_cdc_mclk_enable(tasha, true);
  12333. regmap_update_bits(tasha->wcd9xxx->regmap,
  12334. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x1E, 0x20);
  12335. regmap_update_bits(tasha->wcd9xxx->regmap,
  12336. WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x01, 0x01);
  12337. /*
  12338. * 5ms sleep required after enabling efuse control
  12339. * before checking the status.
  12340. */
  12341. usleep_range(5000, 5500);
  12342. rc = regmap_read(tasha->wcd9xxx->regmap,
  12343. WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS, &val);
  12344. if (rc || (!(val & 0x01)))
  12345. WARN(1, "%s: Efuse sense is not complete\n", __func__);
  12346. __tasha_cdc_mclk_enable(tasha, false);
  12347. return rc;
  12348. }
  12349. void tasha_get_codec_ver(struct tasha_priv *tasha)
  12350. {
  12351. int i;
  12352. int val;
  12353. struct tasha_reg_mask_val codec_reg[] = {
  12354. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10, 0xFF, 0xFF},
  12355. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11, 0xFF, 0x83},
  12356. {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12, 0xFF, 0x0A},
  12357. };
  12358. __tasha_enable_efuse_sensing(tasha);
  12359. for (i = 0; i < ARRAY_SIZE(codec_reg); i++) {
  12360. regmap_read(tasha->wcd9xxx->regmap, codec_reg[i].reg, &val);
  12361. if (!(val && codec_reg[i].val)) {
  12362. codec_ver = WCD9335;
  12363. goto ret;
  12364. }
  12365. }
  12366. codec_ver = WCD9326;
  12367. ret:
  12368. pr_debug("%s: codec is %d\n", __func__, codec_ver);
  12369. }
  12370. EXPORT_SYMBOL(tasha_get_codec_ver);
  12371. static int tasha_probe(struct platform_device *pdev)
  12372. {
  12373. int ret = 0;
  12374. struct tasha_priv *tasha;
  12375. struct clk *wcd_ext_clk, *wcd_native_clk;
  12376. struct wcd9xxx_resmgr_v2 *resmgr;
  12377. struct wcd9xxx_power_region *cdc_pwr;
  12378. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) {
  12379. if (apr_get_subsys_state() == APR_SUBSYS_DOWN) {
  12380. dev_err(&pdev->dev, "%s: dsp down\n", __func__);
  12381. return -EPROBE_DEFER;
  12382. }
  12383. }
  12384. tasha = devm_kzalloc(&pdev->dev, sizeof(struct tasha_priv),
  12385. GFP_KERNEL);
  12386. if (!tasha)
  12387. return -ENOMEM;
  12388. platform_set_drvdata(pdev, tasha);
  12389. tasha->wcd9xxx = dev_get_drvdata(pdev->dev.parent);
  12390. tasha->dev = &pdev->dev;
  12391. INIT_DELAYED_WORK(&tasha->power_gate_work, tasha_codec_power_gate_work);
  12392. mutex_init(&tasha->power_lock);
  12393. mutex_init(&tasha->sido_lock);
  12394. INIT_WORK(&tasha->tasha_add_child_devices_work,
  12395. tasha_add_child_devices);
  12396. BLOCKING_INIT_NOTIFIER_HEAD(&tasha->notifier);
  12397. mutex_init(&tasha->micb_lock);
  12398. mutex_init(&tasha->swr_read_lock);
  12399. mutex_init(&tasha->swr_write_lock);
  12400. mutex_init(&tasha->swr_clk_lock);
  12401. mutex_init(&tasha->sb_clk_gear_lock);
  12402. mutex_init(&tasha->mclk_lock);
  12403. cdc_pwr = devm_kzalloc(&pdev->dev, sizeof(struct wcd9xxx_power_region),
  12404. GFP_KERNEL);
  12405. if (!cdc_pwr) {
  12406. ret = -ENOMEM;
  12407. goto err_cdc_pwr;
  12408. }
  12409. tasha->wcd9xxx->wcd9xxx_pwr[WCD9XXX_DIG_CORE_REGION_1] = cdc_pwr;
  12410. cdc_pwr->pwr_collapse_reg_min = TASHA_DIG_CORE_REG_MIN;
  12411. cdc_pwr->pwr_collapse_reg_max = TASHA_DIG_CORE_REG_MAX;
  12412. wcd9xxx_set_power_state(tasha->wcd9xxx,
  12413. WCD_REGION_POWER_COLLAPSE_REMOVE,
  12414. WCD9XXX_DIG_CORE_REGION_1);
  12415. mutex_init(&tasha->codec_mutex);
  12416. /*
  12417. * Init resource manager so that if child nodes such as SoundWire
  12418. * requests for clock, resource manager can honor the request
  12419. */
  12420. resmgr = wcd_resmgr_init(&tasha->wcd9xxx->core_res, NULL);
  12421. if (IS_ERR(resmgr)) {
  12422. ret = PTR_ERR(resmgr);
  12423. dev_err(&pdev->dev, "%s: Failed to initialize wcd resmgr\n",
  12424. __func__);
  12425. goto err_resmgr;
  12426. }
  12427. tasha->resmgr = resmgr;
  12428. tasha->swr_plat_data.handle = (void *) tasha;
  12429. tasha->swr_plat_data.read = tasha_swrm_read;
  12430. tasha->swr_plat_data.write = tasha_swrm_write;
  12431. tasha->swr_plat_data.bulk_write = tasha_swrm_bulk_write;
  12432. tasha->swr_plat_data.clk = tasha_swrm_clock;
  12433. tasha->swr_plat_data.handle_irq = tasha_swrm_handle_irq;
  12434. /* Register for Clock */
  12435. wcd_ext_clk = clk_get(tasha->wcd9xxx->dev, "wcd_clk");
  12436. if (IS_ERR(wcd_ext_clk)) {
  12437. dev_err(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12438. __func__, "wcd_ext_clk");
  12439. goto err_clk;
  12440. }
  12441. tasha->wcd_ext_clk = wcd_ext_clk;
  12442. tasha->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV;
  12443. set_bit(AUDIO_NOMINAL, &tasha->status_mask);
  12444. tasha->sido_ccl_cnt = 0;
  12445. /* Register native clk for 44.1 playback */
  12446. wcd_native_clk = clk_get(tasha->wcd9xxx->dev, "wcd_native_clk");
  12447. if (IS_ERR(wcd_native_clk))
  12448. dev_dbg(tasha->wcd9xxx->dev, "%s: clk get %s failed\n",
  12449. __func__, "wcd_native_clk");
  12450. else
  12451. tasha->wcd_native_clk = wcd_native_clk;
  12452. if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
  12453. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12454. tasha_dai, ARRAY_SIZE(tasha_dai));
  12455. else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
  12456. ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha,
  12457. tasha_i2s_dai,
  12458. ARRAY_SIZE(tasha_i2s_dai));
  12459. else
  12460. ret = -EINVAL;
  12461. if (ret) {
  12462. dev_err(&pdev->dev, "%s: Codec registration failed, ret = %d\n",
  12463. __func__, ret);
  12464. goto err_cdc_reg;
  12465. }
  12466. /* Update codec register default values */
  12467. tasha_update_reg_defaults(tasha);
  12468. schedule_work(&tasha->tasha_add_child_devices_work);
  12469. tasha_get_codec_ver(tasha);
  12470. dev_info(&pdev->dev, "%s: Tasha driver probe done\n", __func__);
  12471. return ret;
  12472. err_cdc_reg:
  12473. clk_put(tasha->wcd_ext_clk);
  12474. if (tasha->wcd_native_clk)
  12475. clk_put(tasha->wcd_native_clk);
  12476. err_clk:
  12477. wcd_resmgr_remove(tasha->resmgr);
  12478. err_resmgr:
  12479. devm_kfree(&pdev->dev, cdc_pwr);
  12480. err_cdc_pwr:
  12481. mutex_destroy(&tasha->mclk_lock);
  12482. devm_kfree(&pdev->dev, tasha);
  12483. return ret;
  12484. }
  12485. static int tasha_remove(struct platform_device *pdev)
  12486. {
  12487. struct tasha_priv *tasha;
  12488. int count = 0;
  12489. tasha = platform_get_drvdata(pdev);
  12490. if (!tasha)
  12491. return -EINVAL;
  12492. for (count = 0; count < tasha->child_count &&
  12493. count < WCD9335_CHILD_DEVICES_MAX; count++)
  12494. platform_device_unregister(tasha->pdev_child_devices[count]);
  12495. mutex_destroy(&tasha->codec_mutex);
  12496. clk_put(tasha->wcd_ext_clk);
  12497. if (tasha->wcd_native_clk)
  12498. clk_put(tasha->wcd_native_clk);
  12499. mutex_destroy(&tasha->mclk_lock);
  12500. mutex_destroy(&tasha->sb_clk_gear_lock);
  12501. snd_soc_unregister_codec(&pdev->dev);
  12502. devm_kfree(&pdev->dev, tasha);
  12503. return 0;
  12504. }
  12505. static struct platform_driver tasha_codec_driver = {
  12506. .probe = tasha_probe,
  12507. .remove = tasha_remove,
  12508. .driver = {
  12509. .name = "tasha_codec",
  12510. .owner = THIS_MODULE,
  12511. #ifdef CONFIG_PM
  12512. .pm = &tasha_pm_ops,
  12513. #endif
  12514. },
  12515. };
  12516. module_platform_driver(tasha_codec_driver);
  12517. MODULE_DESCRIPTION("Tasha Codec driver");
  12518. MODULE_LICENSE("GPL v2");