rt5677.c 170 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314
  1. /*
  2. * rt5677.c -- RT5677 ALSA SoC audio codec driver
  3. *
  4. * Copyright 2013 Realtek Semiconductor Corp.
  5. * Author: Oder Chiou <oder_chiou@realtek.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/acpi.h>
  12. #include <linux/fs.h>
  13. #include <linux/module.h>
  14. #include <linux/moduleparam.h>
  15. #include <linux/init.h>
  16. #include <linux/delay.h>
  17. #include <linux/pm.h>
  18. #include <linux/regmap.h>
  19. #include <linux/i2c.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/spi/spi.h>
  22. #include <linux/firmware.h>
  23. #include <linux/property.h>
  24. #include <sound/core.h>
  25. #include <sound/pcm.h>
  26. #include <sound/pcm_params.h>
  27. #include <sound/soc.h>
  28. #include <sound/soc-dapm.h>
  29. #include <sound/initval.h>
  30. #include <sound/tlv.h>
  31. #include "rl6231.h"
  32. #include "rt5677.h"
  33. #include "rt5677-spi.h"
  34. #define RT5677_DEVICE_ID 0x6327
  35. #define RT5677_PR_RANGE_BASE (0xff + 1)
  36. #define RT5677_PR_SPACING 0x100
  37. #define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING))
  38. /* GPIO indexes defined by ACPI */
  39. enum {
  40. RT5677_GPIO_PLUG_DET = 0,
  41. RT5677_GPIO_MIC_PRESENT_L = 1,
  42. RT5677_GPIO_HOTWORD_DET_L = 2,
  43. RT5677_GPIO_DSP_INT = 3,
  44. RT5677_GPIO_HP_AMP_SHDN_L = 4,
  45. };
  46. static const struct regmap_range_cfg rt5677_ranges[] = {
  47. {
  48. .name = "PR",
  49. .range_min = RT5677_PR_BASE,
  50. .range_max = RT5677_PR_BASE + 0xfd,
  51. .selector_reg = RT5677_PRIV_INDEX,
  52. .selector_mask = 0xff,
  53. .selector_shift = 0x0,
  54. .window_start = RT5677_PRIV_DATA,
  55. .window_len = 0x1,
  56. },
  57. };
  58. static const struct reg_sequence init_list[] = {
  59. {RT5677_ASRC_12, 0x0018},
  60. {RT5677_PR_BASE + 0x3d, 0x364d},
  61. {RT5677_PR_BASE + 0x17, 0x4fc0},
  62. {RT5677_PR_BASE + 0x13, 0x0312},
  63. {RT5677_PR_BASE + 0x1e, 0x0000},
  64. {RT5677_PR_BASE + 0x12, 0x0eaa},
  65. {RT5677_PR_BASE + 0x14, 0x018a},
  66. {RT5677_PR_BASE + 0x15, 0x0490},
  67. {RT5677_PR_BASE + 0x38, 0x0f71},
  68. {RT5677_PR_BASE + 0x39, 0x0f71},
  69. };
  70. #define RT5677_INIT_REG_LEN ARRAY_SIZE(init_list)
  71. static const struct reg_default rt5677_reg[] = {
  72. {RT5677_RESET , 0x0000},
  73. {RT5677_LOUT1 , 0xa800},
  74. {RT5677_IN1 , 0x0000},
  75. {RT5677_MICBIAS , 0x0000},
  76. {RT5677_SLIMBUS_PARAM , 0x0000},
  77. {RT5677_SLIMBUS_RX , 0x0000},
  78. {RT5677_SLIMBUS_CTRL , 0x0000},
  79. {RT5677_SIDETONE_CTRL , 0x000b},
  80. {RT5677_ANA_DAC1_2_3_SRC , 0x0000},
  81. {RT5677_IF_DSP_DAC3_4_MIXER , 0x1111},
  82. {RT5677_DAC4_DIG_VOL , 0xafaf},
  83. {RT5677_DAC3_DIG_VOL , 0xafaf},
  84. {RT5677_DAC1_DIG_VOL , 0xafaf},
  85. {RT5677_DAC2_DIG_VOL , 0xafaf},
  86. {RT5677_IF_DSP_DAC2_MIXER , 0x0011},
  87. {RT5677_STO1_ADC_DIG_VOL , 0x2f2f},
  88. {RT5677_MONO_ADC_DIG_VOL , 0x2f2f},
  89. {RT5677_STO1_2_ADC_BST , 0x0000},
  90. {RT5677_STO2_ADC_DIG_VOL , 0x2f2f},
  91. {RT5677_ADC_BST_CTRL2 , 0x0000},
  92. {RT5677_STO3_4_ADC_BST , 0x0000},
  93. {RT5677_STO3_ADC_DIG_VOL , 0x2f2f},
  94. {RT5677_STO4_ADC_DIG_VOL , 0x2f2f},
  95. {RT5677_STO4_ADC_MIXER , 0xd4c0},
  96. {RT5677_STO3_ADC_MIXER , 0xd4c0},
  97. {RT5677_STO2_ADC_MIXER , 0xd4c0},
  98. {RT5677_STO1_ADC_MIXER , 0xd4c0},
  99. {RT5677_MONO_ADC_MIXER , 0xd4d1},
  100. {RT5677_ADC_IF_DSP_DAC1_MIXER , 0x8080},
  101. {RT5677_STO1_DAC_MIXER , 0xaaaa},
  102. {RT5677_MONO_DAC_MIXER , 0xaaaa},
  103. {RT5677_DD1_MIXER , 0xaaaa},
  104. {RT5677_DD2_MIXER , 0xaaaa},
  105. {RT5677_IF3_DATA , 0x0000},
  106. {RT5677_IF4_DATA , 0x0000},
  107. {RT5677_PDM_OUT_CTRL , 0x8888},
  108. {RT5677_PDM_DATA_CTRL1 , 0x0000},
  109. {RT5677_PDM_DATA_CTRL2 , 0x0000},
  110. {RT5677_PDM1_DATA_CTRL2 , 0x0000},
  111. {RT5677_PDM1_DATA_CTRL3 , 0x0000},
  112. {RT5677_PDM1_DATA_CTRL4 , 0x0000},
  113. {RT5677_PDM2_DATA_CTRL2 , 0x0000},
  114. {RT5677_PDM2_DATA_CTRL3 , 0x0000},
  115. {RT5677_PDM2_DATA_CTRL4 , 0x0000},
  116. {RT5677_TDM1_CTRL1 , 0x0300},
  117. {RT5677_TDM1_CTRL2 , 0x0000},
  118. {RT5677_TDM1_CTRL3 , 0x4000},
  119. {RT5677_TDM1_CTRL4 , 0x0123},
  120. {RT5677_TDM1_CTRL5 , 0x4567},
  121. {RT5677_TDM2_CTRL1 , 0x0300},
  122. {RT5677_TDM2_CTRL2 , 0x0000},
  123. {RT5677_TDM2_CTRL3 , 0x4000},
  124. {RT5677_TDM2_CTRL4 , 0x0123},
  125. {RT5677_TDM2_CTRL5 , 0x4567},
  126. {RT5677_I2C_MASTER_CTRL1 , 0x0001},
  127. {RT5677_I2C_MASTER_CTRL2 , 0x0000},
  128. {RT5677_I2C_MASTER_CTRL3 , 0x0000},
  129. {RT5677_I2C_MASTER_CTRL4 , 0x0000},
  130. {RT5677_I2C_MASTER_CTRL5 , 0x0000},
  131. {RT5677_I2C_MASTER_CTRL6 , 0x0000},
  132. {RT5677_I2C_MASTER_CTRL7 , 0x0000},
  133. {RT5677_I2C_MASTER_CTRL8 , 0x0000},
  134. {RT5677_DMIC_CTRL1 , 0x1505},
  135. {RT5677_DMIC_CTRL2 , 0x0055},
  136. {RT5677_HAP_GENE_CTRL1 , 0x0111},
  137. {RT5677_HAP_GENE_CTRL2 , 0x0064},
  138. {RT5677_HAP_GENE_CTRL3 , 0xef0e},
  139. {RT5677_HAP_GENE_CTRL4 , 0xf0f0},
  140. {RT5677_HAP_GENE_CTRL5 , 0xef0e},
  141. {RT5677_HAP_GENE_CTRL6 , 0xf0f0},
  142. {RT5677_HAP_GENE_CTRL7 , 0xef0e},
  143. {RT5677_HAP_GENE_CTRL8 , 0xf0f0},
  144. {RT5677_HAP_GENE_CTRL9 , 0xf000},
  145. {RT5677_HAP_GENE_CTRL10 , 0x0000},
  146. {RT5677_PWR_DIG1 , 0x0000},
  147. {RT5677_PWR_DIG2 , 0x0000},
  148. {RT5677_PWR_ANLG1 , 0x0055},
  149. {RT5677_PWR_ANLG2 , 0x0000},
  150. {RT5677_PWR_DSP1 , 0x0001},
  151. {RT5677_PWR_DSP_ST , 0x0000},
  152. {RT5677_PWR_DSP2 , 0x0000},
  153. {RT5677_ADC_DAC_HPF_CTRL1 , 0x0e00},
  154. {RT5677_PRIV_INDEX , 0x0000},
  155. {RT5677_PRIV_DATA , 0x0000},
  156. {RT5677_I2S4_SDP , 0x8000},
  157. {RT5677_I2S1_SDP , 0x8000},
  158. {RT5677_I2S2_SDP , 0x8000},
  159. {RT5677_I2S3_SDP , 0x8000},
  160. {RT5677_CLK_TREE_CTRL1 , 0x1111},
  161. {RT5677_CLK_TREE_CTRL2 , 0x1111},
  162. {RT5677_CLK_TREE_CTRL3 , 0x0000},
  163. {RT5677_PLL1_CTRL1 , 0x0000},
  164. {RT5677_PLL1_CTRL2 , 0x0000},
  165. {RT5677_PLL2_CTRL1 , 0x0c60},
  166. {RT5677_PLL2_CTRL2 , 0x2000},
  167. {RT5677_GLB_CLK1 , 0x0000},
  168. {RT5677_GLB_CLK2 , 0x0000},
  169. {RT5677_ASRC_1 , 0x0000},
  170. {RT5677_ASRC_2 , 0x0000},
  171. {RT5677_ASRC_3 , 0x0000},
  172. {RT5677_ASRC_4 , 0x0000},
  173. {RT5677_ASRC_5 , 0x0000},
  174. {RT5677_ASRC_6 , 0x0000},
  175. {RT5677_ASRC_7 , 0x0000},
  176. {RT5677_ASRC_8 , 0x0000},
  177. {RT5677_ASRC_9 , 0x0000},
  178. {RT5677_ASRC_10 , 0x0000},
  179. {RT5677_ASRC_11 , 0x0000},
  180. {RT5677_ASRC_12 , 0x0018},
  181. {RT5677_ASRC_13 , 0x0000},
  182. {RT5677_ASRC_14 , 0x0000},
  183. {RT5677_ASRC_15 , 0x0000},
  184. {RT5677_ASRC_16 , 0x0000},
  185. {RT5677_ASRC_17 , 0x0000},
  186. {RT5677_ASRC_18 , 0x0000},
  187. {RT5677_ASRC_19 , 0x0000},
  188. {RT5677_ASRC_20 , 0x0000},
  189. {RT5677_ASRC_21 , 0x000c},
  190. {RT5677_ASRC_22 , 0x0000},
  191. {RT5677_ASRC_23 , 0x0000},
  192. {RT5677_VAD_CTRL1 , 0x2184},
  193. {RT5677_VAD_CTRL2 , 0x010a},
  194. {RT5677_VAD_CTRL3 , 0x0aea},
  195. {RT5677_VAD_CTRL4 , 0x000c},
  196. {RT5677_VAD_CTRL5 , 0x0000},
  197. {RT5677_DSP_INB_CTRL1 , 0x0000},
  198. {RT5677_DSP_INB_CTRL2 , 0x0000},
  199. {RT5677_DSP_IN_OUTB_CTRL , 0x0000},
  200. {RT5677_DSP_OUTB0_1_DIG_VOL , 0x2f2f},
  201. {RT5677_DSP_OUTB2_3_DIG_VOL , 0x2f2f},
  202. {RT5677_DSP_OUTB4_5_DIG_VOL , 0x2f2f},
  203. {RT5677_DSP_OUTB6_7_DIG_VOL , 0x2f2f},
  204. {RT5677_ADC_EQ_CTRL1 , 0x6000},
  205. {RT5677_ADC_EQ_CTRL2 , 0x0000},
  206. {RT5677_EQ_CTRL1 , 0xc000},
  207. {RT5677_EQ_CTRL2 , 0x0000},
  208. {RT5677_EQ_CTRL3 , 0x0000},
  209. {RT5677_SOFT_VOL_ZERO_CROSS1 , 0x0009},
  210. {RT5677_JD_CTRL1 , 0x0000},
  211. {RT5677_JD_CTRL2 , 0x0000},
  212. {RT5677_JD_CTRL3 , 0x0000},
  213. {RT5677_IRQ_CTRL1 , 0x0000},
  214. {RT5677_IRQ_CTRL2 , 0x0000},
  215. {RT5677_GPIO_ST , 0x0000},
  216. {RT5677_GPIO_CTRL1 , 0x0000},
  217. {RT5677_GPIO_CTRL2 , 0x0000},
  218. {RT5677_GPIO_CTRL3 , 0x0000},
  219. {RT5677_STO1_ADC_HI_FILTER1 , 0xb320},
  220. {RT5677_STO1_ADC_HI_FILTER2 , 0x0000},
  221. {RT5677_MONO_ADC_HI_FILTER1 , 0xb300},
  222. {RT5677_MONO_ADC_HI_FILTER2 , 0x0000},
  223. {RT5677_STO2_ADC_HI_FILTER1 , 0xb300},
  224. {RT5677_STO2_ADC_HI_FILTER2 , 0x0000},
  225. {RT5677_STO3_ADC_HI_FILTER1 , 0xb300},
  226. {RT5677_STO3_ADC_HI_FILTER2 , 0x0000},
  227. {RT5677_STO4_ADC_HI_FILTER1 , 0xb300},
  228. {RT5677_STO4_ADC_HI_FILTER2 , 0x0000},
  229. {RT5677_MB_DRC_CTRL1 , 0x0f20},
  230. {RT5677_DRC1_CTRL1 , 0x001f},
  231. {RT5677_DRC1_CTRL2 , 0x020c},
  232. {RT5677_DRC1_CTRL3 , 0x1f00},
  233. {RT5677_DRC1_CTRL4 , 0x0000},
  234. {RT5677_DRC1_CTRL5 , 0x0000},
  235. {RT5677_DRC1_CTRL6 , 0x0029},
  236. {RT5677_DRC2_CTRL1 , 0x001f},
  237. {RT5677_DRC2_CTRL2 , 0x020c},
  238. {RT5677_DRC2_CTRL3 , 0x1f00},
  239. {RT5677_DRC2_CTRL4 , 0x0000},
  240. {RT5677_DRC2_CTRL5 , 0x0000},
  241. {RT5677_DRC2_CTRL6 , 0x0029},
  242. {RT5677_DRC1_HL_CTRL1 , 0x8000},
  243. {RT5677_DRC1_HL_CTRL2 , 0x0200},
  244. {RT5677_DRC2_HL_CTRL1 , 0x8000},
  245. {RT5677_DRC2_HL_CTRL2 , 0x0200},
  246. {RT5677_DSP_INB1_SRC_CTRL1 , 0x5800},
  247. {RT5677_DSP_INB1_SRC_CTRL2 , 0x0000},
  248. {RT5677_DSP_INB1_SRC_CTRL3 , 0x0000},
  249. {RT5677_DSP_INB1_SRC_CTRL4 , 0x0800},
  250. {RT5677_DSP_INB2_SRC_CTRL1 , 0x5800},
  251. {RT5677_DSP_INB2_SRC_CTRL2 , 0x0000},
  252. {RT5677_DSP_INB2_SRC_CTRL3 , 0x0000},
  253. {RT5677_DSP_INB2_SRC_CTRL4 , 0x0800},
  254. {RT5677_DSP_INB3_SRC_CTRL1 , 0x5800},
  255. {RT5677_DSP_INB3_SRC_CTRL2 , 0x0000},
  256. {RT5677_DSP_INB3_SRC_CTRL3 , 0x0000},
  257. {RT5677_DSP_INB3_SRC_CTRL4 , 0x0800},
  258. {RT5677_DSP_OUTB1_SRC_CTRL1 , 0x5800},
  259. {RT5677_DSP_OUTB1_SRC_CTRL2 , 0x0000},
  260. {RT5677_DSP_OUTB1_SRC_CTRL3 , 0x0000},
  261. {RT5677_DSP_OUTB1_SRC_CTRL4 , 0x0800},
  262. {RT5677_DSP_OUTB2_SRC_CTRL1 , 0x5800},
  263. {RT5677_DSP_OUTB2_SRC_CTRL2 , 0x0000},
  264. {RT5677_DSP_OUTB2_SRC_CTRL3 , 0x0000},
  265. {RT5677_DSP_OUTB2_SRC_CTRL4 , 0x0800},
  266. {RT5677_DSP_OUTB_0123_MIXER_CTRL, 0xfefe},
  267. {RT5677_DSP_OUTB_45_MIXER_CTRL , 0xfefe},
  268. {RT5677_DSP_OUTB_67_MIXER_CTRL , 0xfefe},
  269. {RT5677_DIG_MISC , 0x0000},
  270. {RT5677_GEN_CTRL1 , 0x0000},
  271. {RT5677_GEN_CTRL2 , 0x0000},
  272. {RT5677_VENDOR_ID , 0x0000},
  273. {RT5677_VENDOR_ID1 , 0x10ec},
  274. {RT5677_VENDOR_ID2 , 0x6327},
  275. };
  276. static bool rt5677_volatile_register(struct device *dev, unsigned int reg)
  277. {
  278. int i;
  279. for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) {
  280. if (reg >= rt5677_ranges[i].range_min &&
  281. reg <= rt5677_ranges[i].range_max) {
  282. return true;
  283. }
  284. }
  285. switch (reg) {
  286. case RT5677_RESET:
  287. case RT5677_SLIMBUS_PARAM:
  288. case RT5677_PDM_DATA_CTRL1:
  289. case RT5677_PDM_DATA_CTRL2:
  290. case RT5677_PDM1_DATA_CTRL4:
  291. case RT5677_PDM2_DATA_CTRL4:
  292. case RT5677_I2C_MASTER_CTRL1:
  293. case RT5677_I2C_MASTER_CTRL7:
  294. case RT5677_I2C_MASTER_CTRL8:
  295. case RT5677_HAP_GENE_CTRL2:
  296. case RT5677_PWR_DSP_ST:
  297. case RT5677_PRIV_DATA:
  298. case RT5677_ASRC_22:
  299. case RT5677_ASRC_23:
  300. case RT5677_VAD_CTRL5:
  301. case RT5677_ADC_EQ_CTRL1:
  302. case RT5677_EQ_CTRL1:
  303. case RT5677_IRQ_CTRL1:
  304. case RT5677_IRQ_CTRL2:
  305. case RT5677_GPIO_ST:
  306. case RT5677_DSP_INB1_SRC_CTRL4:
  307. case RT5677_DSP_INB2_SRC_CTRL4:
  308. case RT5677_DSP_INB3_SRC_CTRL4:
  309. case RT5677_DSP_OUTB1_SRC_CTRL4:
  310. case RT5677_DSP_OUTB2_SRC_CTRL4:
  311. case RT5677_VENDOR_ID:
  312. case RT5677_VENDOR_ID1:
  313. case RT5677_VENDOR_ID2:
  314. return true;
  315. default:
  316. return false;
  317. }
  318. }
  319. static bool rt5677_readable_register(struct device *dev, unsigned int reg)
  320. {
  321. int i;
  322. for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) {
  323. if (reg >= rt5677_ranges[i].range_min &&
  324. reg <= rt5677_ranges[i].range_max) {
  325. return true;
  326. }
  327. }
  328. switch (reg) {
  329. case RT5677_RESET:
  330. case RT5677_LOUT1:
  331. case RT5677_IN1:
  332. case RT5677_MICBIAS:
  333. case RT5677_SLIMBUS_PARAM:
  334. case RT5677_SLIMBUS_RX:
  335. case RT5677_SLIMBUS_CTRL:
  336. case RT5677_SIDETONE_CTRL:
  337. case RT5677_ANA_DAC1_2_3_SRC:
  338. case RT5677_IF_DSP_DAC3_4_MIXER:
  339. case RT5677_DAC4_DIG_VOL:
  340. case RT5677_DAC3_DIG_VOL:
  341. case RT5677_DAC1_DIG_VOL:
  342. case RT5677_DAC2_DIG_VOL:
  343. case RT5677_IF_DSP_DAC2_MIXER:
  344. case RT5677_STO1_ADC_DIG_VOL:
  345. case RT5677_MONO_ADC_DIG_VOL:
  346. case RT5677_STO1_2_ADC_BST:
  347. case RT5677_STO2_ADC_DIG_VOL:
  348. case RT5677_ADC_BST_CTRL2:
  349. case RT5677_STO3_4_ADC_BST:
  350. case RT5677_STO3_ADC_DIG_VOL:
  351. case RT5677_STO4_ADC_DIG_VOL:
  352. case RT5677_STO4_ADC_MIXER:
  353. case RT5677_STO3_ADC_MIXER:
  354. case RT5677_STO2_ADC_MIXER:
  355. case RT5677_STO1_ADC_MIXER:
  356. case RT5677_MONO_ADC_MIXER:
  357. case RT5677_ADC_IF_DSP_DAC1_MIXER:
  358. case RT5677_STO1_DAC_MIXER:
  359. case RT5677_MONO_DAC_MIXER:
  360. case RT5677_DD1_MIXER:
  361. case RT5677_DD2_MIXER:
  362. case RT5677_IF3_DATA:
  363. case RT5677_IF4_DATA:
  364. case RT5677_PDM_OUT_CTRL:
  365. case RT5677_PDM_DATA_CTRL1:
  366. case RT5677_PDM_DATA_CTRL2:
  367. case RT5677_PDM1_DATA_CTRL2:
  368. case RT5677_PDM1_DATA_CTRL3:
  369. case RT5677_PDM1_DATA_CTRL4:
  370. case RT5677_PDM2_DATA_CTRL2:
  371. case RT5677_PDM2_DATA_CTRL3:
  372. case RT5677_PDM2_DATA_CTRL4:
  373. case RT5677_TDM1_CTRL1:
  374. case RT5677_TDM1_CTRL2:
  375. case RT5677_TDM1_CTRL3:
  376. case RT5677_TDM1_CTRL4:
  377. case RT5677_TDM1_CTRL5:
  378. case RT5677_TDM2_CTRL1:
  379. case RT5677_TDM2_CTRL2:
  380. case RT5677_TDM2_CTRL3:
  381. case RT5677_TDM2_CTRL4:
  382. case RT5677_TDM2_CTRL5:
  383. case RT5677_I2C_MASTER_CTRL1:
  384. case RT5677_I2C_MASTER_CTRL2:
  385. case RT5677_I2C_MASTER_CTRL3:
  386. case RT5677_I2C_MASTER_CTRL4:
  387. case RT5677_I2C_MASTER_CTRL5:
  388. case RT5677_I2C_MASTER_CTRL6:
  389. case RT5677_I2C_MASTER_CTRL7:
  390. case RT5677_I2C_MASTER_CTRL8:
  391. case RT5677_DMIC_CTRL1:
  392. case RT5677_DMIC_CTRL2:
  393. case RT5677_HAP_GENE_CTRL1:
  394. case RT5677_HAP_GENE_CTRL2:
  395. case RT5677_HAP_GENE_CTRL3:
  396. case RT5677_HAP_GENE_CTRL4:
  397. case RT5677_HAP_GENE_CTRL5:
  398. case RT5677_HAP_GENE_CTRL6:
  399. case RT5677_HAP_GENE_CTRL7:
  400. case RT5677_HAP_GENE_CTRL8:
  401. case RT5677_HAP_GENE_CTRL9:
  402. case RT5677_HAP_GENE_CTRL10:
  403. case RT5677_PWR_DIG1:
  404. case RT5677_PWR_DIG2:
  405. case RT5677_PWR_ANLG1:
  406. case RT5677_PWR_ANLG2:
  407. case RT5677_PWR_DSP1:
  408. case RT5677_PWR_DSP_ST:
  409. case RT5677_PWR_DSP2:
  410. case RT5677_ADC_DAC_HPF_CTRL1:
  411. case RT5677_PRIV_INDEX:
  412. case RT5677_PRIV_DATA:
  413. case RT5677_I2S4_SDP:
  414. case RT5677_I2S1_SDP:
  415. case RT5677_I2S2_SDP:
  416. case RT5677_I2S3_SDP:
  417. case RT5677_CLK_TREE_CTRL1:
  418. case RT5677_CLK_TREE_CTRL2:
  419. case RT5677_CLK_TREE_CTRL3:
  420. case RT5677_PLL1_CTRL1:
  421. case RT5677_PLL1_CTRL2:
  422. case RT5677_PLL2_CTRL1:
  423. case RT5677_PLL2_CTRL2:
  424. case RT5677_GLB_CLK1:
  425. case RT5677_GLB_CLK2:
  426. case RT5677_ASRC_1:
  427. case RT5677_ASRC_2:
  428. case RT5677_ASRC_3:
  429. case RT5677_ASRC_4:
  430. case RT5677_ASRC_5:
  431. case RT5677_ASRC_6:
  432. case RT5677_ASRC_7:
  433. case RT5677_ASRC_8:
  434. case RT5677_ASRC_9:
  435. case RT5677_ASRC_10:
  436. case RT5677_ASRC_11:
  437. case RT5677_ASRC_12:
  438. case RT5677_ASRC_13:
  439. case RT5677_ASRC_14:
  440. case RT5677_ASRC_15:
  441. case RT5677_ASRC_16:
  442. case RT5677_ASRC_17:
  443. case RT5677_ASRC_18:
  444. case RT5677_ASRC_19:
  445. case RT5677_ASRC_20:
  446. case RT5677_ASRC_21:
  447. case RT5677_ASRC_22:
  448. case RT5677_ASRC_23:
  449. case RT5677_VAD_CTRL1:
  450. case RT5677_VAD_CTRL2:
  451. case RT5677_VAD_CTRL3:
  452. case RT5677_VAD_CTRL4:
  453. case RT5677_VAD_CTRL5:
  454. case RT5677_DSP_INB_CTRL1:
  455. case RT5677_DSP_INB_CTRL2:
  456. case RT5677_DSP_IN_OUTB_CTRL:
  457. case RT5677_DSP_OUTB0_1_DIG_VOL:
  458. case RT5677_DSP_OUTB2_3_DIG_VOL:
  459. case RT5677_DSP_OUTB4_5_DIG_VOL:
  460. case RT5677_DSP_OUTB6_7_DIG_VOL:
  461. case RT5677_ADC_EQ_CTRL1:
  462. case RT5677_ADC_EQ_CTRL2:
  463. case RT5677_EQ_CTRL1:
  464. case RT5677_EQ_CTRL2:
  465. case RT5677_EQ_CTRL3:
  466. case RT5677_SOFT_VOL_ZERO_CROSS1:
  467. case RT5677_JD_CTRL1:
  468. case RT5677_JD_CTRL2:
  469. case RT5677_JD_CTRL3:
  470. case RT5677_IRQ_CTRL1:
  471. case RT5677_IRQ_CTRL2:
  472. case RT5677_GPIO_ST:
  473. case RT5677_GPIO_CTRL1:
  474. case RT5677_GPIO_CTRL2:
  475. case RT5677_GPIO_CTRL3:
  476. case RT5677_STO1_ADC_HI_FILTER1:
  477. case RT5677_STO1_ADC_HI_FILTER2:
  478. case RT5677_MONO_ADC_HI_FILTER1:
  479. case RT5677_MONO_ADC_HI_FILTER2:
  480. case RT5677_STO2_ADC_HI_FILTER1:
  481. case RT5677_STO2_ADC_HI_FILTER2:
  482. case RT5677_STO3_ADC_HI_FILTER1:
  483. case RT5677_STO3_ADC_HI_FILTER2:
  484. case RT5677_STO4_ADC_HI_FILTER1:
  485. case RT5677_STO4_ADC_HI_FILTER2:
  486. case RT5677_MB_DRC_CTRL1:
  487. case RT5677_DRC1_CTRL1:
  488. case RT5677_DRC1_CTRL2:
  489. case RT5677_DRC1_CTRL3:
  490. case RT5677_DRC1_CTRL4:
  491. case RT5677_DRC1_CTRL5:
  492. case RT5677_DRC1_CTRL6:
  493. case RT5677_DRC2_CTRL1:
  494. case RT5677_DRC2_CTRL2:
  495. case RT5677_DRC2_CTRL3:
  496. case RT5677_DRC2_CTRL4:
  497. case RT5677_DRC2_CTRL5:
  498. case RT5677_DRC2_CTRL6:
  499. case RT5677_DRC1_HL_CTRL1:
  500. case RT5677_DRC1_HL_CTRL2:
  501. case RT5677_DRC2_HL_CTRL1:
  502. case RT5677_DRC2_HL_CTRL2:
  503. case RT5677_DSP_INB1_SRC_CTRL1:
  504. case RT5677_DSP_INB1_SRC_CTRL2:
  505. case RT5677_DSP_INB1_SRC_CTRL3:
  506. case RT5677_DSP_INB1_SRC_CTRL4:
  507. case RT5677_DSP_INB2_SRC_CTRL1:
  508. case RT5677_DSP_INB2_SRC_CTRL2:
  509. case RT5677_DSP_INB2_SRC_CTRL3:
  510. case RT5677_DSP_INB2_SRC_CTRL4:
  511. case RT5677_DSP_INB3_SRC_CTRL1:
  512. case RT5677_DSP_INB3_SRC_CTRL2:
  513. case RT5677_DSP_INB3_SRC_CTRL3:
  514. case RT5677_DSP_INB3_SRC_CTRL4:
  515. case RT5677_DSP_OUTB1_SRC_CTRL1:
  516. case RT5677_DSP_OUTB1_SRC_CTRL2:
  517. case RT5677_DSP_OUTB1_SRC_CTRL3:
  518. case RT5677_DSP_OUTB1_SRC_CTRL4:
  519. case RT5677_DSP_OUTB2_SRC_CTRL1:
  520. case RT5677_DSP_OUTB2_SRC_CTRL2:
  521. case RT5677_DSP_OUTB2_SRC_CTRL3:
  522. case RT5677_DSP_OUTB2_SRC_CTRL4:
  523. case RT5677_DSP_OUTB_0123_MIXER_CTRL:
  524. case RT5677_DSP_OUTB_45_MIXER_CTRL:
  525. case RT5677_DSP_OUTB_67_MIXER_CTRL:
  526. case RT5677_DIG_MISC:
  527. case RT5677_GEN_CTRL1:
  528. case RT5677_GEN_CTRL2:
  529. case RT5677_VENDOR_ID:
  530. case RT5677_VENDOR_ID1:
  531. case RT5677_VENDOR_ID2:
  532. return true;
  533. default:
  534. return false;
  535. }
  536. }
  537. /**
  538. * rt5677_dsp_mode_i2c_write_addr - Write value to address on DSP mode.
  539. * @rt5677: Private Data.
  540. * @addr: Address index.
  541. * @value: Address data.
  542. *
  543. *
  544. * Returns 0 for success or negative error code.
  545. */
  546. static int rt5677_dsp_mode_i2c_write_addr(struct rt5677_priv *rt5677,
  547. unsigned int addr, unsigned int value, unsigned int opcode)
  548. {
  549. struct snd_soc_codec *codec = rt5677->codec;
  550. int ret;
  551. mutex_lock(&rt5677->dsp_cmd_lock);
  552. ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
  553. addr >> 16);
  554. if (ret < 0) {
  555. dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret);
  556. goto err;
  557. }
  558. ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
  559. addr & 0xffff);
  560. if (ret < 0) {
  561. dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret);
  562. goto err;
  563. }
  564. ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB,
  565. value >> 16);
  566. if (ret < 0) {
  567. dev_err(codec->dev, "Failed to set data msb value: %d\n", ret);
  568. goto err;
  569. }
  570. ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB,
  571. value & 0xffff);
  572. if (ret < 0) {
  573. dev_err(codec->dev, "Failed to set data lsb value: %d\n", ret);
  574. goto err;
  575. }
  576. ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
  577. opcode);
  578. if (ret < 0) {
  579. dev_err(codec->dev, "Failed to set op code value: %d\n", ret);
  580. goto err;
  581. }
  582. err:
  583. mutex_unlock(&rt5677->dsp_cmd_lock);
  584. return ret;
  585. }
  586. /**
  587. * rt5677_dsp_mode_i2c_read_addr - Read value from address on DSP mode.
  588. * rt5677: Private Data.
  589. * @addr: Address index.
  590. * @value: Address data.
  591. *
  592. *
  593. * Returns 0 for success or negative error code.
  594. */
  595. static int rt5677_dsp_mode_i2c_read_addr(
  596. struct rt5677_priv *rt5677, unsigned int addr, unsigned int *value)
  597. {
  598. struct snd_soc_codec *codec = rt5677->codec;
  599. int ret;
  600. unsigned int msb, lsb;
  601. mutex_lock(&rt5677->dsp_cmd_lock);
  602. ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
  603. addr >> 16);
  604. if (ret < 0) {
  605. dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret);
  606. goto err;
  607. }
  608. ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
  609. addr & 0xffff);
  610. if (ret < 0) {
  611. dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret);
  612. goto err;
  613. }
  614. ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
  615. 0x0002);
  616. if (ret < 0) {
  617. dev_err(codec->dev, "Failed to set op code value: %d\n", ret);
  618. goto err;
  619. }
  620. regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB, &msb);
  621. regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB, &lsb);
  622. *value = (msb << 16) | lsb;
  623. err:
  624. mutex_unlock(&rt5677->dsp_cmd_lock);
  625. return ret;
  626. }
  627. /**
  628. * rt5677_dsp_mode_i2c_write - Write register on DSP mode.
  629. * rt5677: Private Data.
  630. * @reg: Register index.
  631. * @value: Register data.
  632. *
  633. *
  634. * Returns 0 for success or negative error code.
  635. */
  636. static int rt5677_dsp_mode_i2c_write(struct rt5677_priv *rt5677,
  637. unsigned int reg, unsigned int value)
  638. {
  639. return rt5677_dsp_mode_i2c_write_addr(rt5677, 0x18020000 + reg * 2,
  640. value, 0x0001);
  641. }
  642. /**
  643. * rt5677_dsp_mode_i2c_read - Read register on DSP mode.
  644. * @codec: SoC audio codec device.
  645. * @reg: Register index.
  646. * @value: Register data.
  647. *
  648. *
  649. * Returns 0 for success or negative error code.
  650. */
  651. static int rt5677_dsp_mode_i2c_read(
  652. struct rt5677_priv *rt5677, unsigned int reg, unsigned int *value)
  653. {
  654. int ret = rt5677_dsp_mode_i2c_read_addr(rt5677, 0x18020000 + reg * 2,
  655. value);
  656. *value &= 0xffff;
  657. return ret;
  658. }
  659. static void rt5677_set_dsp_mode(struct snd_soc_codec *codec, bool on)
  660. {
  661. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  662. if (on) {
  663. regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x2);
  664. rt5677->is_dsp_mode = true;
  665. } else {
  666. regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x0);
  667. rt5677->is_dsp_mode = false;
  668. }
  669. }
  670. static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on)
  671. {
  672. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  673. static bool activity;
  674. int ret;
  675. if (!IS_ENABLED(CONFIG_SND_SOC_RT5677_SPI))
  676. return -ENXIO;
  677. if (on && !activity) {
  678. activity = true;
  679. regcache_cache_only(rt5677->regmap, false);
  680. regcache_cache_bypass(rt5677->regmap, true);
  681. regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x1);
  682. regmap_update_bits(rt5677->regmap,
  683. RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0f00);
  684. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
  685. RT5677_LDO1_SEL_MASK, 0x0);
  686. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
  687. RT5677_PWR_LDO1, RT5677_PWR_LDO1);
  688. switch (rt5677->type) {
  689. case RT5677:
  690. regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
  691. RT5677_MCLK_SRC_MASK, RT5677_MCLK2_SRC);
  692. regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2,
  693. RT5677_PLL2_PR_SRC_MASK |
  694. RT5677_DSP_CLK_SRC_MASK,
  695. RT5677_PLL2_PR_SRC_MCLK2 |
  696. RT5677_DSP_CLK_SRC_BYPASS);
  697. break;
  698. case RT5676:
  699. regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2,
  700. RT5677_DSP_CLK_SRC_MASK,
  701. RT5677_DSP_CLK_SRC_BYPASS);
  702. break;
  703. default:
  704. break;
  705. }
  706. regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x07ff);
  707. regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x07fd);
  708. rt5677_set_dsp_mode(codec, true);
  709. ret = reject_firmware(&rt5677->fw1, RT5677_FIRMWARE1,
  710. codec->dev);
  711. if (ret == 0) {
  712. rt5677_spi_write_firmware(0x50000000, rt5677->fw1);
  713. release_firmware(rt5677->fw1);
  714. }
  715. ret = reject_firmware(&rt5677->fw2, RT5677_FIRMWARE2,
  716. codec->dev);
  717. if (ret == 0) {
  718. rt5677_spi_write_firmware(0x60000000, rt5677->fw2);
  719. release_firmware(rt5677->fw2);
  720. }
  721. regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x0);
  722. regcache_cache_bypass(rt5677->regmap, false);
  723. regcache_cache_only(rt5677->regmap, true);
  724. } else if (!on && activity) {
  725. activity = false;
  726. regcache_cache_only(rt5677->regmap, false);
  727. regcache_cache_bypass(rt5677->regmap, true);
  728. regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x1);
  729. rt5677_set_dsp_mode(codec, false);
  730. regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x0001);
  731. regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
  732. regcache_cache_bypass(rt5677->regmap, false);
  733. regcache_mark_dirty(rt5677->regmap);
  734. regcache_sync(rt5677->regmap);
  735. }
  736. return 0;
  737. }
  738. static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
  739. static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0);
  740. static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
  741. static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0);
  742. static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
  743. static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0);
  744. /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
  745. static const DECLARE_TLV_DB_RANGE(bst_tlv,
  746. 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
  747. 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
  748. 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
  749. 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
  750. 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
  751. 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
  752. 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0)
  753. );
  754. static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
  755. struct snd_ctl_elem_value *ucontrol)
  756. {
  757. struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
  758. struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
  759. ucontrol->value.integer.value[0] = rt5677->dsp_vad_en;
  760. return 0;
  761. }
  762. static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol,
  763. struct snd_ctl_elem_value *ucontrol)
  764. {
  765. struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
  766. struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
  767. struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
  768. rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0];
  769. if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
  770. rt5677_set_dsp_vad(codec, rt5677->dsp_vad_en);
  771. return 0;
  772. }
  773. static const struct snd_kcontrol_new rt5677_snd_controls[] = {
  774. /* OUTPUT Control */
  775. SOC_SINGLE("OUT1 Playback Switch", RT5677_LOUT1,
  776. RT5677_LOUT1_L_MUTE_SFT, 1, 1),
  777. SOC_SINGLE("OUT2 Playback Switch", RT5677_LOUT1,
  778. RT5677_LOUT2_L_MUTE_SFT, 1, 1),
  779. SOC_SINGLE("OUT3 Playback Switch", RT5677_LOUT1,
  780. RT5677_LOUT3_L_MUTE_SFT, 1, 1),
  781. /* DAC Digital Volume */
  782. SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5677_DAC1_DIG_VOL,
  783. RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
  784. SOC_DOUBLE_TLV("DAC2 Playback Volume", RT5677_DAC2_DIG_VOL,
  785. RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
  786. SOC_DOUBLE_TLV("DAC3 Playback Volume", RT5677_DAC3_DIG_VOL,
  787. RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
  788. SOC_DOUBLE_TLV("DAC4 Playback Volume", RT5677_DAC4_DIG_VOL,
  789. RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 87, 0, dac_vol_tlv),
  790. /* IN1/IN2 Control */
  791. SOC_SINGLE_TLV("IN1 Boost", RT5677_IN1, RT5677_BST_SFT1, 8, 0, bst_tlv),
  792. SOC_SINGLE_TLV("IN2 Boost", RT5677_IN1, RT5677_BST_SFT2, 8, 0, bst_tlv),
  793. /* ADC Digital Volume Control */
  794. SOC_DOUBLE("ADC1 Capture Switch", RT5677_STO1_ADC_DIG_VOL,
  795. RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
  796. SOC_DOUBLE("ADC2 Capture Switch", RT5677_STO2_ADC_DIG_VOL,
  797. RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
  798. SOC_DOUBLE("ADC3 Capture Switch", RT5677_STO3_ADC_DIG_VOL,
  799. RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
  800. SOC_DOUBLE("ADC4 Capture Switch", RT5677_STO4_ADC_DIG_VOL,
  801. RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
  802. SOC_DOUBLE("Mono ADC Capture Switch", RT5677_MONO_ADC_DIG_VOL,
  803. RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1),
  804. SOC_DOUBLE_TLV("ADC1 Capture Volume", RT5677_STO1_ADC_DIG_VOL,
  805. RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
  806. adc_vol_tlv),
  807. SOC_DOUBLE_TLV("ADC2 Capture Volume", RT5677_STO2_ADC_DIG_VOL,
  808. RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
  809. adc_vol_tlv),
  810. SOC_DOUBLE_TLV("ADC3 Capture Volume", RT5677_STO3_ADC_DIG_VOL,
  811. RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
  812. adc_vol_tlv),
  813. SOC_DOUBLE_TLV("ADC4 Capture Volume", RT5677_STO4_ADC_DIG_VOL,
  814. RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 63, 0,
  815. adc_vol_tlv),
  816. SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5677_MONO_ADC_DIG_VOL,
  817. RT5677_MONO_ADC_L_VOL_SFT, RT5677_MONO_ADC_R_VOL_SFT, 63, 0,
  818. adc_vol_tlv),
  819. /* Sidetone Control */
  820. SOC_SINGLE_TLV("Sidetone Volume", RT5677_SIDETONE_CTRL,
  821. RT5677_ST_VOL_SFT, 31, 0, st_vol_tlv),
  822. /* ADC Boost Volume Control */
  823. SOC_DOUBLE_TLV("STO1 ADC Boost Volume", RT5677_STO1_2_ADC_BST,
  824. RT5677_STO1_ADC_L_BST_SFT, RT5677_STO1_ADC_R_BST_SFT, 3, 0,
  825. adc_bst_tlv),
  826. SOC_DOUBLE_TLV("STO2 ADC Boost Volume", RT5677_STO1_2_ADC_BST,
  827. RT5677_STO2_ADC_L_BST_SFT, RT5677_STO2_ADC_R_BST_SFT, 3, 0,
  828. adc_bst_tlv),
  829. SOC_DOUBLE_TLV("STO3 ADC Boost Volume", RT5677_STO3_4_ADC_BST,
  830. RT5677_STO3_ADC_L_BST_SFT, RT5677_STO3_ADC_R_BST_SFT, 3, 0,
  831. adc_bst_tlv),
  832. SOC_DOUBLE_TLV("STO4 ADC Boost Volume", RT5677_STO3_4_ADC_BST,
  833. RT5677_STO4_ADC_L_BST_SFT, RT5677_STO4_ADC_R_BST_SFT, 3, 0,
  834. adc_bst_tlv),
  835. SOC_DOUBLE_TLV("Mono ADC Boost Volume", RT5677_ADC_BST_CTRL2,
  836. RT5677_MONO_ADC_L_BST_SFT, RT5677_MONO_ADC_R_BST_SFT, 3, 0,
  837. adc_bst_tlv),
  838. SOC_SINGLE_EXT("DSP VAD Switch", SND_SOC_NOPM, 0, 1, 0,
  839. rt5677_dsp_vad_get, rt5677_dsp_vad_put),
  840. };
  841. /**
  842. * set_dmic_clk - Set parameter of dmic.
  843. *
  844. * @w: DAPM widget.
  845. * @kcontrol: The kcontrol of this widget.
  846. * @event: Event id.
  847. *
  848. * Choose dmic clock between 1MHz and 3MHz.
  849. * It is better for clock to approximate 3MHz.
  850. */
  851. static int set_dmic_clk(struct snd_soc_dapm_widget *w,
  852. struct snd_kcontrol *kcontrol, int event)
  853. {
  854. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  855. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  856. int idx, rate;
  857. rate = rt5677->sysclk / rl6231_get_pre_div(rt5677->regmap,
  858. RT5677_CLK_TREE_CTRL1, RT5677_I2S_PD1_SFT);
  859. idx = rl6231_calc_dmic_clk(rate);
  860. if (idx < 0)
  861. dev_err(codec->dev, "Failed to set DMIC clock\n");
  862. else
  863. regmap_update_bits(rt5677->regmap, RT5677_DMIC_CTRL1,
  864. RT5677_DMIC_CLK_MASK, idx << RT5677_DMIC_CLK_SFT);
  865. return idx;
  866. }
  867. static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
  868. struct snd_soc_dapm_widget *sink)
  869. {
  870. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
  871. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  872. unsigned int val;
  873. regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val);
  874. val &= RT5677_SCLK_SRC_MASK;
  875. if (val == RT5677_SCLK_SRC_PLL1)
  876. return 1;
  877. else
  878. return 0;
  879. }
  880. static int is_using_asrc(struct snd_soc_dapm_widget *source,
  881. struct snd_soc_dapm_widget *sink)
  882. {
  883. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
  884. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  885. unsigned int reg, shift, val;
  886. if (source->reg == RT5677_ASRC_1) {
  887. switch (source->shift) {
  888. case 12:
  889. reg = RT5677_ASRC_4;
  890. shift = 0;
  891. break;
  892. case 13:
  893. reg = RT5677_ASRC_4;
  894. shift = 4;
  895. break;
  896. case 14:
  897. reg = RT5677_ASRC_4;
  898. shift = 8;
  899. break;
  900. case 15:
  901. reg = RT5677_ASRC_4;
  902. shift = 12;
  903. break;
  904. default:
  905. return 0;
  906. }
  907. } else {
  908. switch (source->shift) {
  909. case 0:
  910. reg = RT5677_ASRC_6;
  911. shift = 8;
  912. break;
  913. case 1:
  914. reg = RT5677_ASRC_6;
  915. shift = 12;
  916. break;
  917. case 2:
  918. reg = RT5677_ASRC_5;
  919. shift = 0;
  920. break;
  921. case 3:
  922. reg = RT5677_ASRC_5;
  923. shift = 4;
  924. break;
  925. case 4:
  926. reg = RT5677_ASRC_5;
  927. shift = 8;
  928. break;
  929. case 5:
  930. reg = RT5677_ASRC_5;
  931. shift = 12;
  932. break;
  933. case 12:
  934. reg = RT5677_ASRC_3;
  935. shift = 0;
  936. break;
  937. case 13:
  938. reg = RT5677_ASRC_3;
  939. shift = 4;
  940. break;
  941. case 14:
  942. reg = RT5677_ASRC_3;
  943. shift = 12;
  944. break;
  945. default:
  946. return 0;
  947. }
  948. }
  949. regmap_read(rt5677->regmap, reg, &val);
  950. val = (val >> shift) & 0xf;
  951. switch (val) {
  952. case 1 ... 6:
  953. return 1;
  954. default:
  955. return 0;
  956. }
  957. }
  958. static int can_use_asrc(struct snd_soc_dapm_widget *source,
  959. struct snd_soc_dapm_widget *sink)
  960. {
  961. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
  962. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  963. if (rt5677->sysclk > rt5677->lrck[RT5677_AIF1] * 384)
  964. return 1;
  965. return 0;
  966. }
  967. /**
  968. * rt5677_sel_asrc_clk_src - select ASRC clock source for a set of filters
  969. * @codec: SoC audio codec device.
  970. * @filter_mask: mask of filters.
  971. * @clk_src: clock source
  972. *
  973. * The ASRC function is for asynchronous MCLK and LRCK. Also, since RT5677 can
  974. * only support standard 32fs or 64fs i2s format, ASRC should be enabled to
  975. * support special i2s clock format such as Intel's 100fs(100 * sampling rate).
  976. * ASRC function will track i2s clock and generate a corresponding system clock
  977. * for codec. This function provides an API to select the clock source for a
  978. * set of filters specified by the mask. And the codec driver will turn on ASRC
  979. * for these filters if ASRC is selected as their clock source.
  980. */
  981. int rt5677_sel_asrc_clk_src(struct snd_soc_codec *codec,
  982. unsigned int filter_mask, unsigned int clk_src)
  983. {
  984. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  985. unsigned int asrc3_mask = 0, asrc3_value = 0;
  986. unsigned int asrc4_mask = 0, asrc4_value = 0;
  987. unsigned int asrc5_mask = 0, asrc5_value = 0;
  988. unsigned int asrc6_mask = 0, asrc6_value = 0;
  989. unsigned int asrc7_mask = 0, asrc7_value = 0;
  990. unsigned int asrc8_mask = 0, asrc8_value = 0;
  991. switch (clk_src) {
  992. case RT5677_CLK_SEL_SYS:
  993. case RT5677_CLK_SEL_I2S1_ASRC:
  994. case RT5677_CLK_SEL_I2S2_ASRC:
  995. case RT5677_CLK_SEL_I2S3_ASRC:
  996. case RT5677_CLK_SEL_I2S4_ASRC:
  997. case RT5677_CLK_SEL_I2S5_ASRC:
  998. case RT5677_CLK_SEL_I2S6_ASRC:
  999. case RT5677_CLK_SEL_SYS2:
  1000. case RT5677_CLK_SEL_SYS3:
  1001. case RT5677_CLK_SEL_SYS4:
  1002. case RT5677_CLK_SEL_SYS5:
  1003. case RT5677_CLK_SEL_SYS6:
  1004. case RT5677_CLK_SEL_SYS7:
  1005. break;
  1006. default:
  1007. return -EINVAL;
  1008. }
  1009. /* ASRC 3 */
  1010. if (filter_mask & RT5677_DA_STEREO_FILTER) {
  1011. asrc3_mask |= RT5677_DA_STO_CLK_SEL_MASK;
  1012. asrc3_value = (asrc3_value & ~RT5677_DA_STO_CLK_SEL_MASK)
  1013. | (clk_src << RT5677_DA_STO_CLK_SEL_SFT);
  1014. }
  1015. if (filter_mask & RT5677_DA_MONO2_L_FILTER) {
  1016. asrc3_mask |= RT5677_DA_MONO2L_CLK_SEL_MASK;
  1017. asrc3_value = (asrc3_value & ~RT5677_DA_MONO2L_CLK_SEL_MASK)
  1018. | (clk_src << RT5677_DA_MONO2L_CLK_SEL_SFT);
  1019. }
  1020. if (filter_mask & RT5677_DA_MONO2_R_FILTER) {
  1021. asrc3_mask |= RT5677_DA_MONO2R_CLK_SEL_MASK;
  1022. asrc3_value = (asrc3_value & ~RT5677_DA_MONO2R_CLK_SEL_MASK)
  1023. | (clk_src << RT5677_DA_MONO2R_CLK_SEL_SFT);
  1024. }
  1025. if (asrc3_mask)
  1026. regmap_update_bits(rt5677->regmap, RT5677_ASRC_3, asrc3_mask,
  1027. asrc3_value);
  1028. /* ASRC 4 */
  1029. if (filter_mask & RT5677_DA_MONO3_L_FILTER) {
  1030. asrc4_mask |= RT5677_DA_MONO3L_CLK_SEL_MASK;
  1031. asrc4_value = (asrc4_value & ~RT5677_DA_MONO3L_CLK_SEL_MASK)
  1032. | (clk_src << RT5677_DA_MONO3L_CLK_SEL_SFT);
  1033. }
  1034. if (filter_mask & RT5677_DA_MONO3_R_FILTER) {
  1035. asrc4_mask |= RT5677_DA_MONO3R_CLK_SEL_MASK;
  1036. asrc4_value = (asrc4_value & ~RT5677_DA_MONO3R_CLK_SEL_MASK)
  1037. | (clk_src << RT5677_DA_MONO3R_CLK_SEL_SFT);
  1038. }
  1039. if (filter_mask & RT5677_DA_MONO4_L_FILTER) {
  1040. asrc4_mask |= RT5677_DA_MONO4L_CLK_SEL_MASK;
  1041. asrc4_value = (asrc4_value & ~RT5677_DA_MONO4L_CLK_SEL_MASK)
  1042. | (clk_src << RT5677_DA_MONO4L_CLK_SEL_SFT);
  1043. }
  1044. if (filter_mask & RT5677_DA_MONO4_R_FILTER) {
  1045. asrc4_mask |= RT5677_DA_MONO4R_CLK_SEL_MASK;
  1046. asrc4_value = (asrc4_value & ~RT5677_DA_MONO4R_CLK_SEL_MASK)
  1047. | (clk_src << RT5677_DA_MONO4R_CLK_SEL_SFT);
  1048. }
  1049. if (asrc4_mask)
  1050. regmap_update_bits(rt5677->regmap, RT5677_ASRC_4, asrc4_mask,
  1051. asrc4_value);
  1052. /* ASRC 5 */
  1053. if (filter_mask & RT5677_AD_STEREO1_FILTER) {
  1054. asrc5_mask |= RT5677_AD_STO1_CLK_SEL_MASK;
  1055. asrc5_value = (asrc5_value & ~RT5677_AD_STO1_CLK_SEL_MASK)
  1056. | (clk_src << RT5677_AD_STO1_CLK_SEL_SFT);
  1057. }
  1058. if (filter_mask & RT5677_AD_STEREO2_FILTER) {
  1059. asrc5_mask |= RT5677_AD_STO2_CLK_SEL_MASK;
  1060. asrc5_value = (asrc5_value & ~RT5677_AD_STO2_CLK_SEL_MASK)
  1061. | (clk_src << RT5677_AD_STO2_CLK_SEL_SFT);
  1062. }
  1063. if (filter_mask & RT5677_AD_STEREO3_FILTER) {
  1064. asrc5_mask |= RT5677_AD_STO3_CLK_SEL_MASK;
  1065. asrc5_value = (asrc5_value & ~RT5677_AD_STO3_CLK_SEL_MASK)
  1066. | (clk_src << RT5677_AD_STO3_CLK_SEL_SFT);
  1067. }
  1068. if (filter_mask & RT5677_AD_STEREO4_FILTER) {
  1069. asrc5_mask |= RT5677_AD_STO4_CLK_SEL_MASK;
  1070. asrc5_value = (asrc5_value & ~RT5677_AD_STO4_CLK_SEL_MASK)
  1071. | (clk_src << RT5677_AD_STO4_CLK_SEL_SFT);
  1072. }
  1073. if (asrc5_mask)
  1074. regmap_update_bits(rt5677->regmap, RT5677_ASRC_5, asrc5_mask,
  1075. asrc5_value);
  1076. /* ASRC 6 */
  1077. if (filter_mask & RT5677_AD_MONO_L_FILTER) {
  1078. asrc6_mask |= RT5677_AD_MONOL_CLK_SEL_MASK;
  1079. asrc6_value = (asrc6_value & ~RT5677_AD_MONOL_CLK_SEL_MASK)
  1080. | (clk_src << RT5677_AD_MONOL_CLK_SEL_SFT);
  1081. }
  1082. if (filter_mask & RT5677_AD_MONO_R_FILTER) {
  1083. asrc6_mask |= RT5677_AD_MONOR_CLK_SEL_MASK;
  1084. asrc6_value = (asrc6_value & ~RT5677_AD_MONOR_CLK_SEL_MASK)
  1085. | (clk_src << RT5677_AD_MONOR_CLK_SEL_SFT);
  1086. }
  1087. if (asrc6_mask)
  1088. regmap_update_bits(rt5677->regmap, RT5677_ASRC_6, asrc6_mask,
  1089. asrc6_value);
  1090. /* ASRC 7 */
  1091. if (filter_mask & RT5677_DSP_OB_0_3_FILTER) {
  1092. asrc7_mask |= RT5677_DSP_OB_0_3_CLK_SEL_MASK;
  1093. asrc7_value = (asrc7_value & ~RT5677_DSP_OB_0_3_CLK_SEL_MASK)
  1094. | (clk_src << RT5677_DSP_OB_0_3_CLK_SEL_SFT);
  1095. }
  1096. if (filter_mask & RT5677_DSP_OB_4_7_FILTER) {
  1097. asrc7_mask |= RT5677_DSP_OB_4_7_CLK_SEL_MASK;
  1098. asrc7_value = (asrc7_value & ~RT5677_DSP_OB_4_7_CLK_SEL_MASK)
  1099. | (clk_src << RT5677_DSP_OB_4_7_CLK_SEL_SFT);
  1100. }
  1101. if (asrc7_mask)
  1102. regmap_update_bits(rt5677->regmap, RT5677_ASRC_7, asrc7_mask,
  1103. asrc7_value);
  1104. /* ASRC 8 */
  1105. if (filter_mask & RT5677_I2S1_SOURCE) {
  1106. asrc8_mask |= RT5677_I2S1_CLK_SEL_MASK;
  1107. asrc8_value = (asrc8_value & ~RT5677_I2S1_CLK_SEL_MASK)
  1108. | ((clk_src - 1) << RT5677_I2S1_CLK_SEL_SFT);
  1109. }
  1110. if (filter_mask & RT5677_I2S2_SOURCE) {
  1111. asrc8_mask |= RT5677_I2S2_CLK_SEL_MASK;
  1112. asrc8_value = (asrc8_value & ~RT5677_I2S2_CLK_SEL_MASK)
  1113. | ((clk_src - 1) << RT5677_I2S2_CLK_SEL_SFT);
  1114. }
  1115. if (filter_mask & RT5677_I2S3_SOURCE) {
  1116. asrc8_mask |= RT5677_I2S3_CLK_SEL_MASK;
  1117. asrc8_value = (asrc8_value & ~RT5677_I2S3_CLK_SEL_MASK)
  1118. | ((clk_src - 1) << RT5677_I2S3_CLK_SEL_SFT);
  1119. }
  1120. if (filter_mask & RT5677_I2S4_SOURCE) {
  1121. asrc8_mask |= RT5677_I2S4_CLK_SEL_MASK;
  1122. asrc8_value = (asrc8_value & ~RT5677_I2S4_CLK_SEL_MASK)
  1123. | ((clk_src - 1) << RT5677_I2S4_CLK_SEL_SFT);
  1124. }
  1125. if (asrc8_mask)
  1126. regmap_update_bits(rt5677->regmap, RT5677_ASRC_8, asrc8_mask,
  1127. asrc8_value);
  1128. return 0;
  1129. }
  1130. EXPORT_SYMBOL_GPL(rt5677_sel_asrc_clk_src);
  1131. static int rt5677_dmic_use_asrc(struct snd_soc_dapm_widget *source,
  1132. struct snd_soc_dapm_widget *sink)
  1133. {
  1134. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
  1135. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  1136. unsigned int asrc_setting;
  1137. switch (source->shift) {
  1138. case 11:
  1139. regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
  1140. asrc_setting = (asrc_setting & RT5677_AD_STO1_CLK_SEL_MASK) >>
  1141. RT5677_AD_STO1_CLK_SEL_SFT;
  1142. break;
  1143. case 10:
  1144. regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
  1145. asrc_setting = (asrc_setting & RT5677_AD_STO2_CLK_SEL_MASK) >>
  1146. RT5677_AD_STO2_CLK_SEL_SFT;
  1147. break;
  1148. case 9:
  1149. regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
  1150. asrc_setting = (asrc_setting & RT5677_AD_STO3_CLK_SEL_MASK) >>
  1151. RT5677_AD_STO3_CLK_SEL_SFT;
  1152. break;
  1153. case 8:
  1154. regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
  1155. asrc_setting = (asrc_setting & RT5677_AD_STO4_CLK_SEL_MASK) >>
  1156. RT5677_AD_STO4_CLK_SEL_SFT;
  1157. break;
  1158. case 7:
  1159. regmap_read(rt5677->regmap, RT5677_ASRC_6, &asrc_setting);
  1160. asrc_setting = (asrc_setting & RT5677_AD_MONOL_CLK_SEL_MASK) >>
  1161. RT5677_AD_MONOL_CLK_SEL_SFT;
  1162. break;
  1163. case 6:
  1164. regmap_read(rt5677->regmap, RT5677_ASRC_6, &asrc_setting);
  1165. asrc_setting = (asrc_setting & RT5677_AD_MONOR_CLK_SEL_MASK) >>
  1166. RT5677_AD_MONOR_CLK_SEL_SFT;
  1167. break;
  1168. default:
  1169. return 0;
  1170. }
  1171. if (asrc_setting >= RT5677_CLK_SEL_I2S1_ASRC &&
  1172. asrc_setting <= RT5677_CLK_SEL_I2S6_ASRC)
  1173. return 1;
  1174. return 0;
  1175. }
  1176. /* Digital Mixer */
  1177. static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = {
  1178. SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
  1179. RT5677_M_STO1_ADC_L1_SFT, 1, 1),
  1180. SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER,
  1181. RT5677_M_STO1_ADC_L2_SFT, 1, 1),
  1182. };
  1183. static const struct snd_kcontrol_new rt5677_sto1_adc_r_mix[] = {
  1184. SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER,
  1185. RT5677_M_STO1_ADC_R1_SFT, 1, 1),
  1186. SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER,
  1187. RT5677_M_STO1_ADC_R2_SFT, 1, 1),
  1188. };
  1189. static const struct snd_kcontrol_new rt5677_sto2_adc_l_mix[] = {
  1190. SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER,
  1191. RT5677_M_STO2_ADC_L1_SFT, 1, 1),
  1192. SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER,
  1193. RT5677_M_STO2_ADC_L2_SFT, 1, 1),
  1194. };
  1195. static const struct snd_kcontrol_new rt5677_sto2_adc_r_mix[] = {
  1196. SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER,
  1197. RT5677_M_STO2_ADC_R1_SFT, 1, 1),
  1198. SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER,
  1199. RT5677_M_STO2_ADC_R2_SFT, 1, 1),
  1200. };
  1201. static const struct snd_kcontrol_new rt5677_sto3_adc_l_mix[] = {
  1202. SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER,
  1203. RT5677_M_STO3_ADC_L1_SFT, 1, 1),
  1204. SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER,
  1205. RT5677_M_STO3_ADC_L2_SFT, 1, 1),
  1206. };
  1207. static const struct snd_kcontrol_new rt5677_sto3_adc_r_mix[] = {
  1208. SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER,
  1209. RT5677_M_STO3_ADC_R1_SFT, 1, 1),
  1210. SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER,
  1211. RT5677_M_STO3_ADC_R2_SFT, 1, 1),
  1212. };
  1213. static const struct snd_kcontrol_new rt5677_sto4_adc_l_mix[] = {
  1214. SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER,
  1215. RT5677_M_STO4_ADC_L1_SFT, 1, 1),
  1216. SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER,
  1217. RT5677_M_STO4_ADC_L2_SFT, 1, 1),
  1218. };
  1219. static const struct snd_kcontrol_new rt5677_sto4_adc_r_mix[] = {
  1220. SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER,
  1221. RT5677_M_STO4_ADC_R1_SFT, 1, 1),
  1222. SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER,
  1223. RT5677_M_STO4_ADC_R2_SFT, 1, 1),
  1224. };
  1225. static const struct snd_kcontrol_new rt5677_mono_adc_l_mix[] = {
  1226. SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER,
  1227. RT5677_M_MONO_ADC_L1_SFT, 1, 1),
  1228. SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER,
  1229. RT5677_M_MONO_ADC_L2_SFT, 1, 1),
  1230. };
  1231. static const struct snd_kcontrol_new rt5677_mono_adc_r_mix[] = {
  1232. SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER,
  1233. RT5677_M_MONO_ADC_R1_SFT, 1, 1),
  1234. SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER,
  1235. RT5677_M_MONO_ADC_R2_SFT, 1, 1),
  1236. };
  1237. static const struct snd_kcontrol_new rt5677_dac_l_mix[] = {
  1238. SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
  1239. RT5677_M_ADDA_MIXER1_L_SFT, 1, 1),
  1240. SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
  1241. RT5677_M_DAC1_L_SFT, 1, 1),
  1242. };
  1243. static const struct snd_kcontrol_new rt5677_dac_r_mix[] = {
  1244. SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
  1245. RT5677_M_ADDA_MIXER1_R_SFT, 1, 1),
  1246. SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER,
  1247. RT5677_M_DAC1_R_SFT, 1, 1),
  1248. };
  1249. static const struct snd_kcontrol_new rt5677_sto1_dac_l_mix[] = {
  1250. SOC_DAPM_SINGLE_AUTODISABLE("ST L Switch", RT5677_STO1_DAC_MIXER,
  1251. RT5677_M_ST_DAC1_L_SFT, 1, 1),
  1252. SOC_DAPM_SINGLE_AUTODISABLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER,
  1253. RT5677_M_DAC1_L_STO_L_SFT, 1, 1),
  1254. SOC_DAPM_SINGLE_AUTODISABLE("DAC2 L Switch", RT5677_STO1_DAC_MIXER,
  1255. RT5677_M_DAC2_L_STO_L_SFT, 1, 1),
  1256. SOC_DAPM_SINGLE_AUTODISABLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER,
  1257. RT5677_M_DAC1_R_STO_L_SFT, 1, 1),
  1258. };
  1259. static const struct snd_kcontrol_new rt5677_sto1_dac_r_mix[] = {
  1260. SOC_DAPM_SINGLE_AUTODISABLE("ST R Switch", RT5677_STO1_DAC_MIXER,
  1261. RT5677_M_ST_DAC1_R_SFT, 1, 1),
  1262. SOC_DAPM_SINGLE_AUTODISABLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER,
  1263. RT5677_M_DAC1_R_STO_R_SFT, 1, 1),
  1264. SOC_DAPM_SINGLE_AUTODISABLE("DAC2 R Switch", RT5677_STO1_DAC_MIXER,
  1265. RT5677_M_DAC2_R_STO_R_SFT, 1, 1),
  1266. SOC_DAPM_SINGLE_AUTODISABLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER,
  1267. RT5677_M_DAC1_L_STO_R_SFT, 1, 1),
  1268. };
  1269. static const struct snd_kcontrol_new rt5677_mono_dac_l_mix[] = {
  1270. SOC_DAPM_SINGLE_AUTODISABLE("ST L Switch", RT5677_MONO_DAC_MIXER,
  1271. RT5677_M_ST_DAC2_L_SFT, 1, 1),
  1272. SOC_DAPM_SINGLE_AUTODISABLE("DAC1 L Switch", RT5677_MONO_DAC_MIXER,
  1273. RT5677_M_DAC1_L_MONO_L_SFT, 1, 1),
  1274. SOC_DAPM_SINGLE_AUTODISABLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER,
  1275. RT5677_M_DAC2_L_MONO_L_SFT, 1, 1),
  1276. SOC_DAPM_SINGLE_AUTODISABLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER,
  1277. RT5677_M_DAC2_R_MONO_L_SFT, 1, 1),
  1278. };
  1279. static const struct snd_kcontrol_new rt5677_mono_dac_r_mix[] = {
  1280. SOC_DAPM_SINGLE_AUTODISABLE("ST R Switch", RT5677_MONO_DAC_MIXER,
  1281. RT5677_M_ST_DAC2_R_SFT, 1, 1),
  1282. SOC_DAPM_SINGLE_AUTODISABLE("DAC1 R Switch", RT5677_MONO_DAC_MIXER,
  1283. RT5677_M_DAC1_R_MONO_R_SFT, 1, 1),
  1284. SOC_DAPM_SINGLE_AUTODISABLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER,
  1285. RT5677_M_DAC2_R_MONO_R_SFT, 1, 1),
  1286. SOC_DAPM_SINGLE_AUTODISABLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER,
  1287. RT5677_M_DAC2_L_MONO_R_SFT, 1, 1),
  1288. };
  1289. static const struct snd_kcontrol_new rt5677_dd1_l_mix[] = {
  1290. SOC_DAPM_SINGLE_AUTODISABLE("Sto DAC Mix L Switch", RT5677_DD1_MIXER,
  1291. RT5677_M_STO_L_DD1_L_SFT, 1, 1),
  1292. SOC_DAPM_SINGLE_AUTODISABLE("Mono DAC Mix L Switch", RT5677_DD1_MIXER,
  1293. RT5677_M_MONO_L_DD1_L_SFT, 1, 1),
  1294. SOC_DAPM_SINGLE_AUTODISABLE("DAC3 L Switch", RT5677_DD1_MIXER,
  1295. RT5677_M_DAC3_L_DD1_L_SFT, 1, 1),
  1296. SOC_DAPM_SINGLE_AUTODISABLE("DAC3 R Switch", RT5677_DD1_MIXER,
  1297. RT5677_M_DAC3_R_DD1_L_SFT, 1, 1),
  1298. };
  1299. static const struct snd_kcontrol_new rt5677_dd1_r_mix[] = {
  1300. SOC_DAPM_SINGLE_AUTODISABLE("Sto DAC Mix R Switch", RT5677_DD1_MIXER,
  1301. RT5677_M_STO_R_DD1_R_SFT, 1, 1),
  1302. SOC_DAPM_SINGLE_AUTODISABLE("Mono DAC Mix R Switch", RT5677_DD1_MIXER,
  1303. RT5677_M_MONO_R_DD1_R_SFT, 1, 1),
  1304. SOC_DAPM_SINGLE_AUTODISABLE("DAC3 R Switch", RT5677_DD1_MIXER,
  1305. RT5677_M_DAC3_R_DD1_R_SFT, 1, 1),
  1306. SOC_DAPM_SINGLE_AUTODISABLE("DAC3 L Switch", RT5677_DD1_MIXER,
  1307. RT5677_M_DAC3_L_DD1_R_SFT, 1, 1),
  1308. };
  1309. static const struct snd_kcontrol_new rt5677_dd2_l_mix[] = {
  1310. SOC_DAPM_SINGLE_AUTODISABLE("Sto DAC Mix L Switch", RT5677_DD2_MIXER,
  1311. RT5677_M_STO_L_DD2_L_SFT, 1, 1),
  1312. SOC_DAPM_SINGLE_AUTODISABLE("Mono DAC Mix L Switch", RT5677_DD2_MIXER,
  1313. RT5677_M_MONO_L_DD2_L_SFT, 1, 1),
  1314. SOC_DAPM_SINGLE_AUTODISABLE("DAC4 L Switch", RT5677_DD2_MIXER,
  1315. RT5677_M_DAC4_L_DD2_L_SFT, 1, 1),
  1316. SOC_DAPM_SINGLE_AUTODISABLE("DAC4 R Switch", RT5677_DD2_MIXER,
  1317. RT5677_M_DAC4_R_DD2_L_SFT, 1, 1),
  1318. };
  1319. static const struct snd_kcontrol_new rt5677_dd2_r_mix[] = {
  1320. SOC_DAPM_SINGLE_AUTODISABLE("Sto DAC Mix R Switch", RT5677_DD2_MIXER,
  1321. RT5677_M_STO_R_DD2_R_SFT, 1, 1),
  1322. SOC_DAPM_SINGLE_AUTODISABLE("Mono DAC Mix R Switch", RT5677_DD2_MIXER,
  1323. RT5677_M_MONO_R_DD2_R_SFT, 1, 1),
  1324. SOC_DAPM_SINGLE_AUTODISABLE("DAC4 R Switch", RT5677_DD2_MIXER,
  1325. RT5677_M_DAC4_R_DD2_R_SFT, 1, 1),
  1326. SOC_DAPM_SINGLE_AUTODISABLE("DAC4 L Switch", RT5677_DD2_MIXER,
  1327. RT5677_M_DAC4_L_DD2_R_SFT, 1, 1),
  1328. };
  1329. static const struct snd_kcontrol_new rt5677_ob_01_mix[] = {
  1330. SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1331. RT5677_DSP_IB_01_H_SFT, 1, 1),
  1332. SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1333. RT5677_DSP_IB_23_H_SFT, 1, 1),
  1334. SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1335. RT5677_DSP_IB_45_H_SFT, 1, 1),
  1336. SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1337. RT5677_DSP_IB_6_H_SFT, 1, 1),
  1338. SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1339. RT5677_DSP_IB_7_H_SFT, 1, 1),
  1340. SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1341. RT5677_DSP_IB_8_H_SFT, 1, 1),
  1342. SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1343. RT5677_DSP_IB_9_H_SFT, 1, 1),
  1344. };
  1345. static const struct snd_kcontrol_new rt5677_ob_23_mix[] = {
  1346. SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1347. RT5677_DSP_IB_01_L_SFT, 1, 1),
  1348. SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1349. RT5677_DSP_IB_23_L_SFT, 1, 1),
  1350. SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1351. RT5677_DSP_IB_45_L_SFT, 1, 1),
  1352. SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1353. RT5677_DSP_IB_6_L_SFT, 1, 1),
  1354. SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1355. RT5677_DSP_IB_7_L_SFT, 1, 1),
  1356. SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1357. RT5677_DSP_IB_8_L_SFT, 1, 1),
  1358. SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL,
  1359. RT5677_DSP_IB_9_L_SFT, 1, 1),
  1360. };
  1361. static const struct snd_kcontrol_new rt5677_ob_4_mix[] = {
  1362. SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1363. RT5677_DSP_IB_01_H_SFT, 1, 1),
  1364. SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1365. RT5677_DSP_IB_23_H_SFT, 1, 1),
  1366. SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1367. RT5677_DSP_IB_45_H_SFT, 1, 1),
  1368. SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1369. RT5677_DSP_IB_6_H_SFT, 1, 1),
  1370. SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1371. RT5677_DSP_IB_7_H_SFT, 1, 1),
  1372. SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1373. RT5677_DSP_IB_8_H_SFT, 1, 1),
  1374. SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1375. RT5677_DSP_IB_9_H_SFT, 1, 1),
  1376. };
  1377. static const struct snd_kcontrol_new rt5677_ob_5_mix[] = {
  1378. SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1379. RT5677_DSP_IB_01_L_SFT, 1, 1),
  1380. SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1381. RT5677_DSP_IB_23_L_SFT, 1, 1),
  1382. SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1383. RT5677_DSP_IB_45_L_SFT, 1, 1),
  1384. SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1385. RT5677_DSP_IB_6_L_SFT, 1, 1),
  1386. SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1387. RT5677_DSP_IB_7_L_SFT, 1, 1),
  1388. SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1389. RT5677_DSP_IB_8_L_SFT, 1, 1),
  1390. SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL,
  1391. RT5677_DSP_IB_9_L_SFT, 1, 1),
  1392. };
  1393. static const struct snd_kcontrol_new rt5677_ob_6_mix[] = {
  1394. SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1395. RT5677_DSP_IB_01_H_SFT, 1, 1),
  1396. SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1397. RT5677_DSP_IB_23_H_SFT, 1, 1),
  1398. SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1399. RT5677_DSP_IB_45_H_SFT, 1, 1),
  1400. SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1401. RT5677_DSP_IB_6_H_SFT, 1, 1),
  1402. SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1403. RT5677_DSP_IB_7_H_SFT, 1, 1),
  1404. SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1405. RT5677_DSP_IB_8_H_SFT, 1, 1),
  1406. SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1407. RT5677_DSP_IB_9_H_SFT, 1, 1),
  1408. };
  1409. static const struct snd_kcontrol_new rt5677_ob_7_mix[] = {
  1410. SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1411. RT5677_DSP_IB_01_L_SFT, 1, 1),
  1412. SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1413. RT5677_DSP_IB_23_L_SFT, 1, 1),
  1414. SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1415. RT5677_DSP_IB_45_L_SFT, 1, 1),
  1416. SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1417. RT5677_DSP_IB_6_L_SFT, 1, 1),
  1418. SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1419. RT5677_DSP_IB_7_L_SFT, 1, 1),
  1420. SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1421. RT5677_DSP_IB_8_L_SFT, 1, 1),
  1422. SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL,
  1423. RT5677_DSP_IB_9_L_SFT, 1, 1),
  1424. };
  1425. /* Mux */
  1426. /* DAC1 L/R Source */ /* MX-29 [10:8] */
  1427. static const char * const rt5677_dac1_src[] = {
  1428. "IF1 DAC 01", "IF2 DAC 01", "IF3 DAC LR", "IF4 DAC LR", "SLB DAC 01",
  1429. "OB 01"
  1430. };
  1431. static SOC_ENUM_SINGLE_DECL(
  1432. rt5677_dac1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER,
  1433. RT5677_DAC1_L_SEL_SFT, rt5677_dac1_src);
  1434. static const struct snd_kcontrol_new rt5677_dac1_mux =
  1435. SOC_DAPM_ENUM("DAC1 Source", rt5677_dac1_enum);
  1436. /* ADDA1 L/R Source */ /* MX-29 [1:0] */
  1437. static const char * const rt5677_adda1_src[] = {
  1438. "STO1 ADC MIX", "STO2 ADC MIX", "OB 67",
  1439. };
  1440. static SOC_ENUM_SINGLE_DECL(
  1441. rt5677_adda1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER,
  1442. RT5677_ADDA1_SEL_SFT, rt5677_adda1_src);
  1443. static const struct snd_kcontrol_new rt5677_adda1_mux =
  1444. SOC_DAPM_ENUM("ADDA1 Source", rt5677_adda1_enum);
  1445. /*DAC2 L/R Source*/ /* MX-1B [6:4] [2:0] */
  1446. static const char * const rt5677_dac2l_src[] = {
  1447. "IF1 DAC 2", "IF2 DAC 2", "IF3 DAC L", "IF4 DAC L", "SLB DAC 2",
  1448. "OB 2",
  1449. };
  1450. static SOC_ENUM_SINGLE_DECL(
  1451. rt5677_dac2l_enum, RT5677_IF_DSP_DAC2_MIXER,
  1452. RT5677_SEL_DAC2_L_SRC_SFT, rt5677_dac2l_src);
  1453. static const struct snd_kcontrol_new rt5677_dac2_l_mux =
  1454. SOC_DAPM_ENUM("DAC2 L Source", rt5677_dac2l_enum);
  1455. static const char * const rt5677_dac2r_src[] = {
  1456. "IF1 DAC 3", "IF2 DAC 3", "IF3 DAC R", "IF4 DAC R", "SLB DAC 3",
  1457. "OB 3", "Haptic Generator", "VAD ADC"
  1458. };
  1459. static SOC_ENUM_SINGLE_DECL(
  1460. rt5677_dac2r_enum, RT5677_IF_DSP_DAC2_MIXER,
  1461. RT5677_SEL_DAC2_R_SRC_SFT, rt5677_dac2r_src);
  1462. static const struct snd_kcontrol_new rt5677_dac2_r_mux =
  1463. SOC_DAPM_ENUM("DAC2 R Source", rt5677_dac2r_enum);
  1464. /*DAC3 L/R Source*/ /* MX-16 [6:4] [2:0] */
  1465. static const char * const rt5677_dac3l_src[] = {
  1466. "IF1 DAC 4", "IF2 DAC 4", "IF3 DAC L", "IF4 DAC L",
  1467. "SLB DAC 4", "OB 4"
  1468. };
  1469. static SOC_ENUM_SINGLE_DECL(
  1470. rt5677_dac3l_enum, RT5677_IF_DSP_DAC3_4_MIXER,
  1471. RT5677_SEL_DAC3_L_SRC_SFT, rt5677_dac3l_src);
  1472. static const struct snd_kcontrol_new rt5677_dac3_l_mux =
  1473. SOC_DAPM_ENUM("DAC3 L Source", rt5677_dac3l_enum);
  1474. static const char * const rt5677_dac3r_src[] = {
  1475. "IF1 DAC 5", "IF2 DAC 5", "IF3 DAC R", "IF4 DAC R",
  1476. "SLB DAC 5", "OB 5"
  1477. };
  1478. static SOC_ENUM_SINGLE_DECL(
  1479. rt5677_dac3r_enum, RT5677_IF_DSP_DAC3_4_MIXER,
  1480. RT5677_SEL_DAC3_R_SRC_SFT, rt5677_dac3r_src);
  1481. static const struct snd_kcontrol_new rt5677_dac3_r_mux =
  1482. SOC_DAPM_ENUM("DAC3 R Source", rt5677_dac3r_enum);
  1483. /*DAC4 L/R Source*/ /* MX-16 [14:12] [10:8] */
  1484. static const char * const rt5677_dac4l_src[] = {
  1485. "IF1 DAC 6", "IF2 DAC 6", "IF3 DAC L", "IF4 DAC L",
  1486. "SLB DAC 6", "OB 6"
  1487. };
  1488. static SOC_ENUM_SINGLE_DECL(
  1489. rt5677_dac4l_enum, RT5677_IF_DSP_DAC3_4_MIXER,
  1490. RT5677_SEL_DAC4_L_SRC_SFT, rt5677_dac4l_src);
  1491. static const struct snd_kcontrol_new rt5677_dac4_l_mux =
  1492. SOC_DAPM_ENUM("DAC4 L Source", rt5677_dac4l_enum);
  1493. static const char * const rt5677_dac4r_src[] = {
  1494. "IF1 DAC 7", "IF2 DAC 7", "IF3 DAC R", "IF4 DAC R",
  1495. "SLB DAC 7", "OB 7"
  1496. };
  1497. static SOC_ENUM_SINGLE_DECL(
  1498. rt5677_dac4r_enum, RT5677_IF_DSP_DAC3_4_MIXER,
  1499. RT5677_SEL_DAC4_R_SRC_SFT, rt5677_dac4r_src);
  1500. static const struct snd_kcontrol_new rt5677_dac4_r_mux =
  1501. SOC_DAPM_ENUM("DAC4 R Source", rt5677_dac4r_enum);
  1502. /* In/OutBound Source Pass SRC */ /* MX-A5 [3] [4] [0] [1] [2] */
  1503. static const char * const rt5677_iob_bypass_src[] = {
  1504. "Bypass", "Pass SRC"
  1505. };
  1506. static SOC_ENUM_SINGLE_DECL(
  1507. rt5677_ob01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
  1508. RT5677_SEL_SRC_OB01_SFT, rt5677_iob_bypass_src);
  1509. static const struct snd_kcontrol_new rt5677_ob01_bypass_src_mux =
  1510. SOC_DAPM_ENUM("OB01 Bypass Source", rt5677_ob01_bypass_src_enum);
  1511. static SOC_ENUM_SINGLE_DECL(
  1512. rt5677_ob23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
  1513. RT5677_SEL_SRC_OB23_SFT, rt5677_iob_bypass_src);
  1514. static const struct snd_kcontrol_new rt5677_ob23_bypass_src_mux =
  1515. SOC_DAPM_ENUM("OB23 Bypass Source", rt5677_ob23_bypass_src_enum);
  1516. static SOC_ENUM_SINGLE_DECL(
  1517. rt5677_ib01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
  1518. RT5677_SEL_SRC_IB01_SFT, rt5677_iob_bypass_src);
  1519. static const struct snd_kcontrol_new rt5677_ib01_bypass_src_mux =
  1520. SOC_DAPM_ENUM("IB01 Bypass Source", rt5677_ib01_bypass_src_enum);
  1521. static SOC_ENUM_SINGLE_DECL(
  1522. rt5677_ib23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
  1523. RT5677_SEL_SRC_IB23_SFT, rt5677_iob_bypass_src);
  1524. static const struct snd_kcontrol_new rt5677_ib23_bypass_src_mux =
  1525. SOC_DAPM_ENUM("IB23 Bypass Source", rt5677_ib23_bypass_src_enum);
  1526. static SOC_ENUM_SINGLE_DECL(
  1527. rt5677_ib45_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL,
  1528. RT5677_SEL_SRC_IB45_SFT, rt5677_iob_bypass_src);
  1529. static const struct snd_kcontrol_new rt5677_ib45_bypass_src_mux =
  1530. SOC_DAPM_ENUM("IB45 Bypass Source", rt5677_ib45_bypass_src_enum);
  1531. /* Stereo ADC Source 2 */ /* MX-27 MX26 MX25 [11:10] */
  1532. static const char * const rt5677_stereo_adc2_src[] = {
  1533. "DD MIX1", "DMIC", "Stereo DAC MIX"
  1534. };
  1535. static SOC_ENUM_SINGLE_DECL(
  1536. rt5677_stereo1_adc2_enum, RT5677_STO1_ADC_MIXER,
  1537. RT5677_SEL_STO1_ADC2_SFT, rt5677_stereo_adc2_src);
  1538. static const struct snd_kcontrol_new rt5677_sto1_adc2_mux =
  1539. SOC_DAPM_ENUM("Stereo1 ADC2 Source", rt5677_stereo1_adc2_enum);
  1540. static SOC_ENUM_SINGLE_DECL(
  1541. rt5677_stereo2_adc2_enum, RT5677_STO2_ADC_MIXER,
  1542. RT5677_SEL_STO2_ADC2_SFT, rt5677_stereo_adc2_src);
  1543. static const struct snd_kcontrol_new rt5677_sto2_adc2_mux =
  1544. SOC_DAPM_ENUM("Stereo2 ADC2 Source", rt5677_stereo2_adc2_enum);
  1545. static SOC_ENUM_SINGLE_DECL(
  1546. rt5677_stereo3_adc2_enum, RT5677_STO3_ADC_MIXER,
  1547. RT5677_SEL_STO3_ADC2_SFT, rt5677_stereo_adc2_src);
  1548. static const struct snd_kcontrol_new rt5677_sto3_adc2_mux =
  1549. SOC_DAPM_ENUM("Stereo3 ADC2 Source", rt5677_stereo3_adc2_enum);
  1550. /* DMIC Source */ /* MX-28 [9:8][1:0] MX-27 MX-26 MX-25 MX-24 [9:8] */
  1551. static const char * const rt5677_dmic_src[] = {
  1552. "DMIC1", "DMIC2", "DMIC3", "DMIC4"
  1553. };
  1554. static SOC_ENUM_SINGLE_DECL(
  1555. rt5677_mono_dmic_l_enum, RT5677_MONO_ADC_MIXER,
  1556. RT5677_SEL_MONO_DMIC_L_SFT, rt5677_dmic_src);
  1557. static const struct snd_kcontrol_new rt5677_mono_dmic_l_mux =
  1558. SOC_DAPM_ENUM("Mono DMIC L Source", rt5677_mono_dmic_l_enum);
  1559. static SOC_ENUM_SINGLE_DECL(
  1560. rt5677_mono_dmic_r_enum, RT5677_MONO_ADC_MIXER,
  1561. RT5677_SEL_MONO_DMIC_R_SFT, rt5677_dmic_src);
  1562. static const struct snd_kcontrol_new rt5677_mono_dmic_r_mux =
  1563. SOC_DAPM_ENUM("Mono DMIC R Source", rt5677_mono_dmic_r_enum);
  1564. static SOC_ENUM_SINGLE_DECL(
  1565. rt5677_stereo1_dmic_enum, RT5677_STO1_ADC_MIXER,
  1566. RT5677_SEL_STO1_DMIC_SFT, rt5677_dmic_src);
  1567. static const struct snd_kcontrol_new rt5677_sto1_dmic_mux =
  1568. SOC_DAPM_ENUM("Stereo1 DMIC Source", rt5677_stereo1_dmic_enum);
  1569. static SOC_ENUM_SINGLE_DECL(
  1570. rt5677_stereo2_dmic_enum, RT5677_STO2_ADC_MIXER,
  1571. RT5677_SEL_STO2_DMIC_SFT, rt5677_dmic_src);
  1572. static const struct snd_kcontrol_new rt5677_sto2_dmic_mux =
  1573. SOC_DAPM_ENUM("Stereo2 DMIC Source", rt5677_stereo2_dmic_enum);
  1574. static SOC_ENUM_SINGLE_DECL(
  1575. rt5677_stereo3_dmic_enum, RT5677_STO3_ADC_MIXER,
  1576. RT5677_SEL_STO3_DMIC_SFT, rt5677_dmic_src);
  1577. static const struct snd_kcontrol_new rt5677_sto3_dmic_mux =
  1578. SOC_DAPM_ENUM("Stereo3 DMIC Source", rt5677_stereo3_dmic_enum);
  1579. static SOC_ENUM_SINGLE_DECL(
  1580. rt5677_stereo4_dmic_enum, RT5677_STO4_ADC_MIXER,
  1581. RT5677_SEL_STO4_DMIC_SFT, rt5677_dmic_src);
  1582. static const struct snd_kcontrol_new rt5677_sto4_dmic_mux =
  1583. SOC_DAPM_ENUM("Stereo4 DMIC Source", rt5677_stereo4_dmic_enum);
  1584. /* Stereo2 ADC Source */ /* MX-26 [0] */
  1585. static const char * const rt5677_stereo2_adc_lr_src[] = {
  1586. "L", "LR"
  1587. };
  1588. static SOC_ENUM_SINGLE_DECL(
  1589. rt5677_stereo2_adc_lr_enum, RT5677_STO2_ADC_MIXER,
  1590. RT5677_SEL_STO2_LR_MIX_SFT, rt5677_stereo2_adc_lr_src);
  1591. static const struct snd_kcontrol_new rt5677_sto2_adc_lr_mux =
  1592. SOC_DAPM_ENUM("Stereo2 ADC LR Source", rt5677_stereo2_adc_lr_enum);
  1593. /* Stereo1 ADC Source 1 */ /* MX-27 MX26 MX25 [13:12] */
  1594. static const char * const rt5677_stereo_adc1_src[] = {
  1595. "DD MIX1", "ADC1/2", "Stereo DAC MIX"
  1596. };
  1597. static SOC_ENUM_SINGLE_DECL(
  1598. rt5677_stereo1_adc1_enum, RT5677_STO1_ADC_MIXER,
  1599. RT5677_SEL_STO1_ADC1_SFT, rt5677_stereo_adc1_src);
  1600. static const struct snd_kcontrol_new rt5677_sto1_adc1_mux =
  1601. SOC_DAPM_ENUM("Stereo1 ADC1 Source", rt5677_stereo1_adc1_enum);
  1602. static SOC_ENUM_SINGLE_DECL(
  1603. rt5677_stereo2_adc1_enum, RT5677_STO2_ADC_MIXER,
  1604. RT5677_SEL_STO2_ADC1_SFT, rt5677_stereo_adc1_src);
  1605. static const struct snd_kcontrol_new rt5677_sto2_adc1_mux =
  1606. SOC_DAPM_ENUM("Stereo2 ADC1 Source", rt5677_stereo2_adc1_enum);
  1607. static SOC_ENUM_SINGLE_DECL(
  1608. rt5677_stereo3_adc1_enum, RT5677_STO3_ADC_MIXER,
  1609. RT5677_SEL_STO3_ADC1_SFT, rt5677_stereo_adc1_src);
  1610. static const struct snd_kcontrol_new rt5677_sto3_adc1_mux =
  1611. SOC_DAPM_ENUM("Stereo3 ADC1 Source", rt5677_stereo3_adc1_enum);
  1612. /* Mono ADC Left Source 2 */ /* MX-28 [11:10] */
  1613. static const char * const rt5677_mono_adc2_l_src[] = {
  1614. "DD MIX1L", "DMIC", "MONO DAC MIXL"
  1615. };
  1616. static SOC_ENUM_SINGLE_DECL(
  1617. rt5677_mono_adc2_l_enum, RT5677_MONO_ADC_MIXER,
  1618. RT5677_SEL_MONO_ADC_L2_SFT, rt5677_mono_adc2_l_src);
  1619. static const struct snd_kcontrol_new rt5677_mono_adc2_l_mux =
  1620. SOC_DAPM_ENUM("Mono ADC2 L Source", rt5677_mono_adc2_l_enum);
  1621. /* Mono ADC Left Source 1 */ /* MX-28 [13:12] */
  1622. static const char * const rt5677_mono_adc1_l_src[] = {
  1623. "DD MIX1L", "ADC1", "MONO DAC MIXL"
  1624. };
  1625. static SOC_ENUM_SINGLE_DECL(
  1626. rt5677_mono_adc1_l_enum, RT5677_MONO_ADC_MIXER,
  1627. RT5677_SEL_MONO_ADC_L1_SFT, rt5677_mono_adc1_l_src);
  1628. static const struct snd_kcontrol_new rt5677_mono_adc1_l_mux =
  1629. SOC_DAPM_ENUM("Mono ADC1 L Source", rt5677_mono_adc1_l_enum);
  1630. /* Mono ADC Right Source 2 */ /* MX-28 [3:2] */
  1631. static const char * const rt5677_mono_adc2_r_src[] = {
  1632. "DD MIX1R", "DMIC", "MONO DAC MIXR"
  1633. };
  1634. static SOC_ENUM_SINGLE_DECL(
  1635. rt5677_mono_adc2_r_enum, RT5677_MONO_ADC_MIXER,
  1636. RT5677_SEL_MONO_ADC_R2_SFT, rt5677_mono_adc2_r_src);
  1637. static const struct snd_kcontrol_new rt5677_mono_adc2_r_mux =
  1638. SOC_DAPM_ENUM("Mono ADC2 R Source", rt5677_mono_adc2_r_enum);
  1639. /* Mono ADC Right Source 1 */ /* MX-28 [5:4] */
  1640. static const char * const rt5677_mono_adc1_r_src[] = {
  1641. "DD MIX1R", "ADC2", "MONO DAC MIXR"
  1642. };
  1643. static SOC_ENUM_SINGLE_DECL(
  1644. rt5677_mono_adc1_r_enum, RT5677_MONO_ADC_MIXER,
  1645. RT5677_SEL_MONO_ADC_R1_SFT, rt5677_mono_adc1_r_src);
  1646. static const struct snd_kcontrol_new rt5677_mono_adc1_r_mux =
  1647. SOC_DAPM_ENUM("Mono ADC1 R Source", rt5677_mono_adc1_r_enum);
  1648. /* Stereo4 ADC Source 2 */ /* MX-24 [11:10] */
  1649. static const char * const rt5677_stereo4_adc2_src[] = {
  1650. "DD MIX1", "DMIC", "DD MIX2"
  1651. };
  1652. static SOC_ENUM_SINGLE_DECL(
  1653. rt5677_stereo4_adc2_enum, RT5677_STO4_ADC_MIXER,
  1654. RT5677_SEL_STO4_ADC2_SFT, rt5677_stereo4_adc2_src);
  1655. static const struct snd_kcontrol_new rt5677_sto4_adc2_mux =
  1656. SOC_DAPM_ENUM("Stereo4 ADC2 Source", rt5677_stereo4_adc2_enum);
  1657. /* Stereo4 ADC Source 1 */ /* MX-24 [13:12] */
  1658. static const char * const rt5677_stereo4_adc1_src[] = {
  1659. "DD MIX1", "ADC1/2", "DD MIX2"
  1660. };
  1661. static SOC_ENUM_SINGLE_DECL(
  1662. rt5677_stereo4_adc1_enum, RT5677_STO4_ADC_MIXER,
  1663. RT5677_SEL_STO4_ADC1_SFT, rt5677_stereo4_adc1_src);
  1664. static const struct snd_kcontrol_new rt5677_sto4_adc1_mux =
  1665. SOC_DAPM_ENUM("Stereo4 ADC1 Source", rt5677_stereo4_adc1_enum);
  1666. /* InBound0/1 Source */ /* MX-A3 [14:12] */
  1667. static const char * const rt5677_inbound01_src[] = {
  1668. "IF1 DAC 01", "IF2 DAC 01", "SLB DAC 01", "STO1 ADC MIX",
  1669. "VAD ADC/DAC1 FS"
  1670. };
  1671. static SOC_ENUM_SINGLE_DECL(
  1672. rt5677_inbound01_enum, RT5677_DSP_INB_CTRL1,
  1673. RT5677_IB01_SRC_SFT, rt5677_inbound01_src);
  1674. static const struct snd_kcontrol_new rt5677_ib01_src_mux =
  1675. SOC_DAPM_ENUM("InBound0/1 Source", rt5677_inbound01_enum);
  1676. /* InBound2/3 Source */ /* MX-A3 [10:8] */
  1677. static const char * const rt5677_inbound23_src[] = {
  1678. "IF1 DAC 23", "IF2 DAC 23", "SLB DAC 23", "STO2 ADC MIX",
  1679. "DAC1 FS", "IF4 DAC"
  1680. };
  1681. static SOC_ENUM_SINGLE_DECL(
  1682. rt5677_inbound23_enum, RT5677_DSP_INB_CTRL1,
  1683. RT5677_IB23_SRC_SFT, rt5677_inbound23_src);
  1684. static const struct snd_kcontrol_new rt5677_ib23_src_mux =
  1685. SOC_DAPM_ENUM("InBound2/3 Source", rt5677_inbound23_enum);
  1686. /* InBound4/5 Source */ /* MX-A3 [6:4] */
  1687. static const char * const rt5677_inbound45_src[] = {
  1688. "IF1 DAC 45", "IF2 DAC 45", "SLB DAC 45", "STO3 ADC MIX",
  1689. "IF3 DAC"
  1690. };
  1691. static SOC_ENUM_SINGLE_DECL(
  1692. rt5677_inbound45_enum, RT5677_DSP_INB_CTRL1,
  1693. RT5677_IB45_SRC_SFT, rt5677_inbound45_src);
  1694. static const struct snd_kcontrol_new rt5677_ib45_src_mux =
  1695. SOC_DAPM_ENUM("InBound4/5 Source", rt5677_inbound45_enum);
  1696. /* InBound6 Source */ /* MX-A3 [2:0] */
  1697. static const char * const rt5677_inbound6_src[] = {
  1698. "IF1 DAC 6", "IF2 DAC 6", "SLB DAC 6", "STO4 ADC MIX L",
  1699. "IF4 DAC L", "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L"
  1700. };
  1701. static SOC_ENUM_SINGLE_DECL(
  1702. rt5677_inbound6_enum, RT5677_DSP_INB_CTRL1,
  1703. RT5677_IB6_SRC_SFT, rt5677_inbound6_src);
  1704. static const struct snd_kcontrol_new rt5677_ib6_src_mux =
  1705. SOC_DAPM_ENUM("InBound6 Source", rt5677_inbound6_enum);
  1706. /* InBound7 Source */ /* MX-A4 [14:12] */
  1707. static const char * const rt5677_inbound7_src[] = {
  1708. "IF1 DAC 7", "IF2 DAC 7", "SLB DAC 7", "STO4 ADC MIX R",
  1709. "IF4 DAC R", "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R"
  1710. };
  1711. static SOC_ENUM_SINGLE_DECL(
  1712. rt5677_inbound7_enum, RT5677_DSP_INB_CTRL2,
  1713. RT5677_IB7_SRC_SFT, rt5677_inbound7_src);
  1714. static const struct snd_kcontrol_new rt5677_ib7_src_mux =
  1715. SOC_DAPM_ENUM("InBound7 Source", rt5677_inbound7_enum);
  1716. /* InBound8 Source */ /* MX-A4 [10:8] */
  1717. static const char * const rt5677_inbound8_src[] = {
  1718. "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L", "STO4 ADC MIX L",
  1719. "MONO ADC MIX L", "DACL1 FS"
  1720. };
  1721. static SOC_ENUM_SINGLE_DECL(
  1722. rt5677_inbound8_enum, RT5677_DSP_INB_CTRL2,
  1723. RT5677_IB8_SRC_SFT, rt5677_inbound8_src);
  1724. static const struct snd_kcontrol_new rt5677_ib8_src_mux =
  1725. SOC_DAPM_ENUM("InBound8 Source", rt5677_inbound8_enum);
  1726. /* InBound9 Source */ /* MX-A4 [6:4] */
  1727. static const char * const rt5677_inbound9_src[] = {
  1728. "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R", "STO4 ADC MIX R",
  1729. "MONO ADC MIX R", "DACR1 FS", "DAC1 FS"
  1730. };
  1731. static SOC_ENUM_SINGLE_DECL(
  1732. rt5677_inbound9_enum, RT5677_DSP_INB_CTRL2,
  1733. RT5677_IB9_SRC_SFT, rt5677_inbound9_src);
  1734. static const struct snd_kcontrol_new rt5677_ib9_src_mux =
  1735. SOC_DAPM_ENUM("InBound9 Source", rt5677_inbound9_enum);
  1736. /* VAD Source */ /* MX-9F [6:4] */
  1737. static const char * const rt5677_vad_src[] = {
  1738. "STO1 ADC MIX L", "MONO ADC MIX L", "MONO ADC MIX R", "STO2 ADC MIX L",
  1739. "STO3 ADC MIX L"
  1740. };
  1741. static SOC_ENUM_SINGLE_DECL(
  1742. rt5677_vad_enum, RT5677_VAD_CTRL4,
  1743. RT5677_VAD_SRC_SFT, rt5677_vad_src);
  1744. static const struct snd_kcontrol_new rt5677_vad_src_mux =
  1745. SOC_DAPM_ENUM("VAD Source", rt5677_vad_enum);
  1746. /* Sidetone Source */ /* MX-13 [11:9] */
  1747. static const char * const rt5677_sidetone_src[] = {
  1748. "DMIC1 L", "DMIC2 L", "DMIC3 L", "DMIC4 L", "ADC1", "ADC2"
  1749. };
  1750. static SOC_ENUM_SINGLE_DECL(
  1751. rt5677_sidetone_enum, RT5677_SIDETONE_CTRL,
  1752. RT5677_ST_SEL_SFT, rt5677_sidetone_src);
  1753. static const struct snd_kcontrol_new rt5677_sidetone_mux =
  1754. SOC_DAPM_ENUM("Sidetone Source", rt5677_sidetone_enum);
  1755. /* DAC1/2 Source */ /* MX-15 [1:0] */
  1756. static const char * const rt5677_dac12_src[] = {
  1757. "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2"
  1758. };
  1759. static SOC_ENUM_SINGLE_DECL(
  1760. rt5677_dac12_enum, RT5677_ANA_DAC1_2_3_SRC,
  1761. RT5677_ANA_DAC1_2_SRC_SEL_SFT, rt5677_dac12_src);
  1762. static const struct snd_kcontrol_new rt5677_dac12_mux =
  1763. SOC_DAPM_ENUM("Analog DAC1/2 Source", rt5677_dac12_enum);
  1764. /* DAC3 Source */ /* MX-15 [5:4] */
  1765. static const char * const rt5677_dac3_src[] = {
  1766. "MONO DAC MIXL", "MONO DAC MIXR", "DD MIX1L", "DD MIX2L"
  1767. };
  1768. static SOC_ENUM_SINGLE_DECL(
  1769. rt5677_dac3_enum, RT5677_ANA_DAC1_2_3_SRC,
  1770. RT5677_ANA_DAC3_SRC_SEL_SFT, rt5677_dac3_src);
  1771. static const struct snd_kcontrol_new rt5677_dac3_mux =
  1772. SOC_DAPM_ENUM("Analog DAC3 Source", rt5677_dac3_enum);
  1773. /* PDM channel Source */ /* MX-31 [13:12][9:8][5:4][1:0] */
  1774. static const char * const rt5677_pdm_src[] = {
  1775. "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2"
  1776. };
  1777. static SOC_ENUM_SINGLE_DECL(
  1778. rt5677_pdm1_l_enum, RT5677_PDM_OUT_CTRL,
  1779. RT5677_SEL_PDM1_L_SFT, rt5677_pdm_src);
  1780. static const struct snd_kcontrol_new rt5677_pdm1_l_mux =
  1781. SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_l_enum);
  1782. static SOC_ENUM_SINGLE_DECL(
  1783. rt5677_pdm2_l_enum, RT5677_PDM_OUT_CTRL,
  1784. RT5677_SEL_PDM2_L_SFT, rt5677_pdm_src);
  1785. static const struct snd_kcontrol_new rt5677_pdm2_l_mux =
  1786. SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_l_enum);
  1787. static SOC_ENUM_SINGLE_DECL(
  1788. rt5677_pdm1_r_enum, RT5677_PDM_OUT_CTRL,
  1789. RT5677_SEL_PDM1_R_SFT, rt5677_pdm_src);
  1790. static const struct snd_kcontrol_new rt5677_pdm1_r_mux =
  1791. SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_r_enum);
  1792. static SOC_ENUM_SINGLE_DECL(
  1793. rt5677_pdm2_r_enum, RT5677_PDM_OUT_CTRL,
  1794. RT5677_SEL_PDM2_R_SFT, rt5677_pdm_src);
  1795. static const struct snd_kcontrol_new rt5677_pdm2_r_mux =
  1796. SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_r_enum);
  1797. /* TDM IF1/2 SLB ADC1 Data Selection */ /* MX-3C MX-41 [5:4] MX-08 [1:0] */
  1798. static const char * const rt5677_if12_adc1_src[] = {
  1799. "STO1 ADC MIX", "OB01", "VAD ADC"
  1800. };
  1801. static SOC_ENUM_SINGLE_DECL(
  1802. rt5677_if1_adc1_enum, RT5677_TDM1_CTRL2,
  1803. RT5677_IF1_ADC1_SFT, rt5677_if12_adc1_src);
  1804. static const struct snd_kcontrol_new rt5677_if1_adc1_mux =
  1805. SOC_DAPM_ENUM("IF1 ADC1 Source", rt5677_if1_adc1_enum);
  1806. static SOC_ENUM_SINGLE_DECL(
  1807. rt5677_if2_adc1_enum, RT5677_TDM2_CTRL2,
  1808. RT5677_IF2_ADC1_SFT, rt5677_if12_adc1_src);
  1809. static const struct snd_kcontrol_new rt5677_if2_adc1_mux =
  1810. SOC_DAPM_ENUM("IF2 ADC1 Source", rt5677_if2_adc1_enum);
  1811. static SOC_ENUM_SINGLE_DECL(
  1812. rt5677_slb_adc1_enum, RT5677_SLIMBUS_RX,
  1813. RT5677_SLB_ADC1_SFT, rt5677_if12_adc1_src);
  1814. static const struct snd_kcontrol_new rt5677_slb_adc1_mux =
  1815. SOC_DAPM_ENUM("SLB ADC1 Source", rt5677_slb_adc1_enum);
  1816. /* TDM IF1/2 SLB ADC2 Data Selection */ /* MX-3C MX-41 [7:6] MX-08 [3:2] */
  1817. static const char * const rt5677_if12_adc2_src[] = {
  1818. "STO2 ADC MIX", "OB23"
  1819. };
  1820. static SOC_ENUM_SINGLE_DECL(
  1821. rt5677_if1_adc2_enum, RT5677_TDM1_CTRL2,
  1822. RT5677_IF1_ADC2_SFT, rt5677_if12_adc2_src);
  1823. static const struct snd_kcontrol_new rt5677_if1_adc2_mux =
  1824. SOC_DAPM_ENUM("IF1 ADC2 Source", rt5677_if1_adc2_enum);
  1825. static SOC_ENUM_SINGLE_DECL(
  1826. rt5677_if2_adc2_enum, RT5677_TDM2_CTRL2,
  1827. RT5677_IF2_ADC2_SFT, rt5677_if12_adc2_src);
  1828. static const struct snd_kcontrol_new rt5677_if2_adc2_mux =
  1829. SOC_DAPM_ENUM("IF2 ADC2 Source", rt5677_if2_adc2_enum);
  1830. static SOC_ENUM_SINGLE_DECL(
  1831. rt5677_slb_adc2_enum, RT5677_SLIMBUS_RX,
  1832. RT5677_SLB_ADC2_SFT, rt5677_if12_adc2_src);
  1833. static const struct snd_kcontrol_new rt5677_slb_adc2_mux =
  1834. SOC_DAPM_ENUM("SLB ADC2 Source", rt5677_slb_adc2_enum);
  1835. /* TDM IF1/2 SLB ADC3 Data Selection */ /* MX-3C MX-41 [9:8] MX-08 [5:4] */
  1836. static const char * const rt5677_if12_adc3_src[] = {
  1837. "STO3 ADC MIX", "MONO ADC MIX", "OB45"
  1838. };
  1839. static SOC_ENUM_SINGLE_DECL(
  1840. rt5677_if1_adc3_enum, RT5677_TDM1_CTRL2,
  1841. RT5677_IF1_ADC3_SFT, rt5677_if12_adc3_src);
  1842. static const struct snd_kcontrol_new rt5677_if1_adc3_mux =
  1843. SOC_DAPM_ENUM("IF1 ADC3 Source", rt5677_if1_adc3_enum);
  1844. static SOC_ENUM_SINGLE_DECL(
  1845. rt5677_if2_adc3_enum, RT5677_TDM2_CTRL2,
  1846. RT5677_IF2_ADC3_SFT, rt5677_if12_adc3_src);
  1847. static const struct snd_kcontrol_new rt5677_if2_adc3_mux =
  1848. SOC_DAPM_ENUM("IF2 ADC3 Source", rt5677_if2_adc3_enum);
  1849. static SOC_ENUM_SINGLE_DECL(
  1850. rt5677_slb_adc3_enum, RT5677_SLIMBUS_RX,
  1851. RT5677_SLB_ADC3_SFT, rt5677_if12_adc3_src);
  1852. static const struct snd_kcontrol_new rt5677_slb_adc3_mux =
  1853. SOC_DAPM_ENUM("SLB ADC3 Source", rt5677_slb_adc3_enum);
  1854. /* TDM IF1/2 SLB ADC4 Data Selection */ /* MX-3C MX-41 [11:10] MX-08 [7:6] */
  1855. static const char * const rt5677_if12_adc4_src[] = {
  1856. "STO4 ADC MIX", "OB67", "OB01"
  1857. };
  1858. static SOC_ENUM_SINGLE_DECL(
  1859. rt5677_if1_adc4_enum, RT5677_TDM1_CTRL2,
  1860. RT5677_IF1_ADC4_SFT, rt5677_if12_adc4_src);
  1861. static const struct snd_kcontrol_new rt5677_if1_adc4_mux =
  1862. SOC_DAPM_ENUM("IF1 ADC4 Source", rt5677_if1_adc4_enum);
  1863. static SOC_ENUM_SINGLE_DECL(
  1864. rt5677_if2_adc4_enum, RT5677_TDM2_CTRL2,
  1865. RT5677_IF2_ADC4_SFT, rt5677_if12_adc4_src);
  1866. static const struct snd_kcontrol_new rt5677_if2_adc4_mux =
  1867. SOC_DAPM_ENUM("IF2 ADC4 Source", rt5677_if2_adc4_enum);
  1868. static SOC_ENUM_SINGLE_DECL(
  1869. rt5677_slb_adc4_enum, RT5677_SLIMBUS_RX,
  1870. RT5677_SLB_ADC4_SFT, rt5677_if12_adc4_src);
  1871. static const struct snd_kcontrol_new rt5677_slb_adc4_mux =
  1872. SOC_DAPM_ENUM("SLB ADC4 Source", rt5677_slb_adc4_enum);
  1873. /* Interface3/4 ADC Data Input */ /* MX-2F [3:0] MX-30 [7:4] */
  1874. static const char * const rt5677_if34_adc_src[] = {
  1875. "STO1 ADC MIX", "STO2 ADC MIX", "STO3 ADC MIX", "STO4 ADC MIX",
  1876. "MONO ADC MIX", "OB01", "OB23", "VAD ADC"
  1877. };
  1878. static SOC_ENUM_SINGLE_DECL(
  1879. rt5677_if3_adc_enum, RT5677_IF3_DATA,
  1880. RT5677_IF3_ADC_IN_SFT, rt5677_if34_adc_src);
  1881. static const struct snd_kcontrol_new rt5677_if3_adc_mux =
  1882. SOC_DAPM_ENUM("IF3 ADC Source", rt5677_if3_adc_enum);
  1883. static SOC_ENUM_SINGLE_DECL(
  1884. rt5677_if4_adc_enum, RT5677_IF4_DATA,
  1885. RT5677_IF4_ADC_IN_SFT, rt5677_if34_adc_src);
  1886. static const struct snd_kcontrol_new rt5677_if4_adc_mux =
  1887. SOC_DAPM_ENUM("IF4 ADC Source", rt5677_if4_adc_enum);
  1888. /* TDM IF1/2 ADC Data Selection */ /* MX-3B MX-40 [7:6][5:4][3:2][1:0] */
  1889. static const char * const rt5677_if12_adc_swap_src[] = {
  1890. "L/R", "R/L", "L/L", "R/R"
  1891. };
  1892. static SOC_ENUM_SINGLE_DECL(
  1893. rt5677_if1_adc1_swap_enum, RT5677_TDM1_CTRL1,
  1894. RT5677_IF1_ADC1_SWAP_SFT, rt5677_if12_adc_swap_src);
  1895. static const struct snd_kcontrol_new rt5677_if1_adc1_swap_mux =
  1896. SOC_DAPM_ENUM("IF1 ADC1 Swap Source", rt5677_if1_adc1_swap_enum);
  1897. static SOC_ENUM_SINGLE_DECL(
  1898. rt5677_if1_adc2_swap_enum, RT5677_TDM1_CTRL1,
  1899. RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
  1900. static const struct snd_kcontrol_new rt5677_if1_adc2_swap_mux =
  1901. SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if1_adc2_swap_enum);
  1902. static SOC_ENUM_SINGLE_DECL(
  1903. rt5677_if1_adc3_swap_enum, RT5677_TDM1_CTRL1,
  1904. RT5677_IF1_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src);
  1905. static const struct snd_kcontrol_new rt5677_if1_adc3_swap_mux =
  1906. SOC_DAPM_ENUM("IF1 ADC3 Swap Source", rt5677_if1_adc3_swap_enum);
  1907. static SOC_ENUM_SINGLE_DECL(
  1908. rt5677_if1_adc4_swap_enum, RT5677_TDM1_CTRL1,
  1909. RT5677_IF1_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src);
  1910. static const struct snd_kcontrol_new rt5677_if1_adc4_swap_mux =
  1911. SOC_DAPM_ENUM("IF1 ADC4 Swap Source", rt5677_if1_adc4_swap_enum);
  1912. static SOC_ENUM_SINGLE_DECL(
  1913. rt5677_if2_adc1_swap_enum, RT5677_TDM2_CTRL1,
  1914. RT5677_IF1_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
  1915. static const struct snd_kcontrol_new rt5677_if2_adc1_swap_mux =
  1916. SOC_DAPM_ENUM("IF1 ADC2 Swap Source", rt5677_if2_adc1_swap_enum);
  1917. static SOC_ENUM_SINGLE_DECL(
  1918. rt5677_if2_adc2_swap_enum, RT5677_TDM2_CTRL1,
  1919. RT5677_IF2_ADC2_SWAP_SFT, rt5677_if12_adc_swap_src);
  1920. static const struct snd_kcontrol_new rt5677_if2_adc2_swap_mux =
  1921. SOC_DAPM_ENUM("IF2 ADC2 Swap Source", rt5677_if2_adc2_swap_enum);
  1922. static SOC_ENUM_SINGLE_DECL(
  1923. rt5677_if2_adc3_swap_enum, RT5677_TDM2_CTRL1,
  1924. RT5677_IF2_ADC3_SWAP_SFT, rt5677_if12_adc_swap_src);
  1925. static const struct snd_kcontrol_new rt5677_if2_adc3_swap_mux =
  1926. SOC_DAPM_ENUM("IF2 ADC3 Swap Source", rt5677_if2_adc3_swap_enum);
  1927. static SOC_ENUM_SINGLE_DECL(
  1928. rt5677_if2_adc4_swap_enum, RT5677_TDM2_CTRL1,
  1929. RT5677_IF2_ADC4_SWAP_SFT, rt5677_if12_adc_swap_src);
  1930. static const struct snd_kcontrol_new rt5677_if2_adc4_swap_mux =
  1931. SOC_DAPM_ENUM("IF2 ADC4 Swap Source", rt5677_if2_adc4_swap_enum);
  1932. /* TDM IF1 ADC Data Selection */ /* MX-3C [2:0] */
  1933. static const char * const rt5677_if1_adc_tdm_swap_src[] = {
  1934. "1/2/3/4", "2/1/3/4", "2/3/1/4", "4/1/2/3", "1/3/2/4", "1/4/2/3",
  1935. "3/1/2/4", "3/4/1/2"
  1936. };
  1937. static SOC_ENUM_SINGLE_DECL(
  1938. rt5677_if1_adc_tdm_swap_enum, RT5677_TDM1_CTRL2,
  1939. RT5677_IF1_ADC_CTRL_SFT, rt5677_if1_adc_tdm_swap_src);
  1940. static const struct snd_kcontrol_new rt5677_if1_adc_tdm_swap_mux =
  1941. SOC_DAPM_ENUM("IF1 ADC TDM Swap Source", rt5677_if1_adc_tdm_swap_enum);
  1942. /* TDM IF2 ADC Data Selection */ /* MX-41[2:0] */
  1943. static const char * const rt5677_if2_adc_tdm_swap_src[] = {
  1944. "1/2/3/4", "2/1/3/4", "3/1/2/4", "4/1/2/3", "1/3/2/4", "1/4/2/3",
  1945. "2/3/1/4", "3/4/1/2"
  1946. };
  1947. static SOC_ENUM_SINGLE_DECL(
  1948. rt5677_if2_adc_tdm_swap_enum, RT5677_TDM2_CTRL2,
  1949. RT5677_IF2_ADC_CTRL_SFT, rt5677_if2_adc_tdm_swap_src);
  1950. static const struct snd_kcontrol_new rt5677_if2_adc_tdm_swap_mux =
  1951. SOC_DAPM_ENUM("IF2 ADC TDM Swap Source", rt5677_if2_adc_tdm_swap_enum);
  1952. /* TDM IF1/2 DAC Data Selection */ /* MX-3E[14:12][10:8][6:4][2:0]
  1953. MX-3F[14:12][10:8][6:4][2:0]
  1954. MX-43[14:12][10:8][6:4][2:0]
  1955. MX-44[14:12][10:8][6:4][2:0] */
  1956. static const char * const rt5677_if12_dac_tdm_sel_src[] = {
  1957. "Slot0", "Slot1", "Slot2", "Slot3", "Slot4", "Slot5", "Slot6", "Slot7"
  1958. };
  1959. static SOC_ENUM_SINGLE_DECL(
  1960. rt5677_if1_dac0_tdm_sel_enum, RT5677_TDM1_CTRL4,
  1961. RT5677_IF1_DAC0_SFT, rt5677_if12_dac_tdm_sel_src);
  1962. static const struct snd_kcontrol_new rt5677_if1_dac0_tdm_sel_mux =
  1963. SOC_DAPM_ENUM("IF1 DAC0 TDM Source", rt5677_if1_dac0_tdm_sel_enum);
  1964. static SOC_ENUM_SINGLE_DECL(
  1965. rt5677_if1_dac1_tdm_sel_enum, RT5677_TDM1_CTRL4,
  1966. RT5677_IF1_DAC1_SFT, rt5677_if12_dac_tdm_sel_src);
  1967. static const struct snd_kcontrol_new rt5677_if1_dac1_tdm_sel_mux =
  1968. SOC_DAPM_ENUM("IF1 DAC1 TDM Source", rt5677_if1_dac1_tdm_sel_enum);
  1969. static SOC_ENUM_SINGLE_DECL(
  1970. rt5677_if1_dac2_tdm_sel_enum, RT5677_TDM1_CTRL4,
  1971. RT5677_IF1_DAC2_SFT, rt5677_if12_dac_tdm_sel_src);
  1972. static const struct snd_kcontrol_new rt5677_if1_dac2_tdm_sel_mux =
  1973. SOC_DAPM_ENUM("IF1 DAC2 TDM Source", rt5677_if1_dac2_tdm_sel_enum);
  1974. static SOC_ENUM_SINGLE_DECL(
  1975. rt5677_if1_dac3_tdm_sel_enum, RT5677_TDM1_CTRL4,
  1976. RT5677_IF1_DAC3_SFT, rt5677_if12_dac_tdm_sel_src);
  1977. static const struct snd_kcontrol_new rt5677_if1_dac3_tdm_sel_mux =
  1978. SOC_DAPM_ENUM("IF1 DAC3 TDM Source", rt5677_if1_dac3_tdm_sel_enum);
  1979. static SOC_ENUM_SINGLE_DECL(
  1980. rt5677_if1_dac4_tdm_sel_enum, RT5677_TDM1_CTRL5,
  1981. RT5677_IF1_DAC4_SFT, rt5677_if12_dac_tdm_sel_src);
  1982. static const struct snd_kcontrol_new rt5677_if1_dac4_tdm_sel_mux =
  1983. SOC_DAPM_ENUM("IF1 DAC4 TDM Source", rt5677_if1_dac4_tdm_sel_enum);
  1984. static SOC_ENUM_SINGLE_DECL(
  1985. rt5677_if1_dac5_tdm_sel_enum, RT5677_TDM1_CTRL5,
  1986. RT5677_IF1_DAC5_SFT, rt5677_if12_dac_tdm_sel_src);
  1987. static const struct snd_kcontrol_new rt5677_if1_dac5_tdm_sel_mux =
  1988. SOC_DAPM_ENUM("IF1 DAC5 TDM Source", rt5677_if1_dac5_tdm_sel_enum);
  1989. static SOC_ENUM_SINGLE_DECL(
  1990. rt5677_if1_dac6_tdm_sel_enum, RT5677_TDM1_CTRL5,
  1991. RT5677_IF1_DAC6_SFT, rt5677_if12_dac_tdm_sel_src);
  1992. static const struct snd_kcontrol_new rt5677_if1_dac6_tdm_sel_mux =
  1993. SOC_DAPM_ENUM("IF1 DAC6 TDM Source", rt5677_if1_dac6_tdm_sel_enum);
  1994. static SOC_ENUM_SINGLE_DECL(
  1995. rt5677_if1_dac7_tdm_sel_enum, RT5677_TDM1_CTRL5,
  1996. RT5677_IF1_DAC7_SFT, rt5677_if12_dac_tdm_sel_src);
  1997. static const struct snd_kcontrol_new rt5677_if1_dac7_tdm_sel_mux =
  1998. SOC_DAPM_ENUM("IF1 DAC7 TDM Source", rt5677_if1_dac7_tdm_sel_enum);
  1999. static SOC_ENUM_SINGLE_DECL(
  2000. rt5677_if2_dac0_tdm_sel_enum, RT5677_TDM2_CTRL4,
  2001. RT5677_IF2_DAC0_SFT, rt5677_if12_dac_tdm_sel_src);
  2002. static const struct snd_kcontrol_new rt5677_if2_dac0_tdm_sel_mux =
  2003. SOC_DAPM_ENUM("IF2 DAC0 TDM Source", rt5677_if2_dac0_tdm_sel_enum);
  2004. static SOC_ENUM_SINGLE_DECL(
  2005. rt5677_if2_dac1_tdm_sel_enum, RT5677_TDM2_CTRL4,
  2006. RT5677_IF2_DAC1_SFT, rt5677_if12_dac_tdm_sel_src);
  2007. static const struct snd_kcontrol_new rt5677_if2_dac1_tdm_sel_mux =
  2008. SOC_DAPM_ENUM("IF2 DAC1 TDM Source", rt5677_if2_dac1_tdm_sel_enum);
  2009. static SOC_ENUM_SINGLE_DECL(
  2010. rt5677_if2_dac2_tdm_sel_enum, RT5677_TDM2_CTRL4,
  2011. RT5677_IF2_DAC2_SFT, rt5677_if12_dac_tdm_sel_src);
  2012. static const struct snd_kcontrol_new rt5677_if2_dac2_tdm_sel_mux =
  2013. SOC_DAPM_ENUM("IF2 DAC2 TDM Source", rt5677_if2_dac2_tdm_sel_enum);
  2014. static SOC_ENUM_SINGLE_DECL(
  2015. rt5677_if2_dac3_tdm_sel_enum, RT5677_TDM2_CTRL4,
  2016. RT5677_IF2_DAC3_SFT, rt5677_if12_dac_tdm_sel_src);
  2017. static const struct snd_kcontrol_new rt5677_if2_dac3_tdm_sel_mux =
  2018. SOC_DAPM_ENUM("IF2 DAC3 TDM Source", rt5677_if2_dac3_tdm_sel_enum);
  2019. static SOC_ENUM_SINGLE_DECL(
  2020. rt5677_if2_dac4_tdm_sel_enum, RT5677_TDM2_CTRL5,
  2021. RT5677_IF2_DAC4_SFT, rt5677_if12_dac_tdm_sel_src);
  2022. static const struct snd_kcontrol_new rt5677_if2_dac4_tdm_sel_mux =
  2023. SOC_DAPM_ENUM("IF2 DAC4 TDM Source", rt5677_if2_dac4_tdm_sel_enum);
  2024. static SOC_ENUM_SINGLE_DECL(
  2025. rt5677_if2_dac5_tdm_sel_enum, RT5677_TDM2_CTRL5,
  2026. RT5677_IF2_DAC5_SFT, rt5677_if12_dac_tdm_sel_src);
  2027. static const struct snd_kcontrol_new rt5677_if2_dac5_tdm_sel_mux =
  2028. SOC_DAPM_ENUM("IF2 DAC5 TDM Source", rt5677_if2_dac5_tdm_sel_enum);
  2029. static SOC_ENUM_SINGLE_DECL(
  2030. rt5677_if2_dac6_tdm_sel_enum, RT5677_TDM2_CTRL5,
  2031. RT5677_IF2_DAC6_SFT, rt5677_if12_dac_tdm_sel_src);
  2032. static const struct snd_kcontrol_new rt5677_if2_dac6_tdm_sel_mux =
  2033. SOC_DAPM_ENUM("IF2 DAC6 TDM Source", rt5677_if2_dac6_tdm_sel_enum);
  2034. static SOC_ENUM_SINGLE_DECL(
  2035. rt5677_if2_dac7_tdm_sel_enum, RT5677_TDM2_CTRL5,
  2036. RT5677_IF2_DAC7_SFT, rt5677_if12_dac_tdm_sel_src);
  2037. static const struct snd_kcontrol_new rt5677_if2_dac7_tdm_sel_mux =
  2038. SOC_DAPM_ENUM("IF2 DAC7 TDM Source", rt5677_if2_dac7_tdm_sel_enum);
  2039. static int rt5677_bst1_event(struct snd_soc_dapm_widget *w,
  2040. struct snd_kcontrol *kcontrol, int event)
  2041. {
  2042. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2043. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  2044. switch (event) {
  2045. case SND_SOC_DAPM_POST_PMU:
  2046. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
  2047. RT5677_PWR_BST1_P, RT5677_PWR_BST1_P);
  2048. break;
  2049. case SND_SOC_DAPM_PRE_PMD:
  2050. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
  2051. RT5677_PWR_BST1_P, 0);
  2052. break;
  2053. default:
  2054. return 0;
  2055. }
  2056. return 0;
  2057. }
  2058. static int rt5677_bst2_event(struct snd_soc_dapm_widget *w,
  2059. struct snd_kcontrol *kcontrol, int event)
  2060. {
  2061. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2062. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  2063. switch (event) {
  2064. case SND_SOC_DAPM_POST_PMU:
  2065. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
  2066. RT5677_PWR_BST2_P, RT5677_PWR_BST2_P);
  2067. break;
  2068. case SND_SOC_DAPM_PRE_PMD:
  2069. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
  2070. RT5677_PWR_BST2_P, 0);
  2071. break;
  2072. default:
  2073. return 0;
  2074. }
  2075. return 0;
  2076. }
  2077. static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w,
  2078. struct snd_kcontrol *kcontrol, int event)
  2079. {
  2080. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2081. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  2082. switch (event) {
  2083. case SND_SOC_DAPM_PRE_PMU:
  2084. regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2);
  2085. break;
  2086. case SND_SOC_DAPM_POST_PMU:
  2087. regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0);
  2088. break;
  2089. default:
  2090. return 0;
  2091. }
  2092. return 0;
  2093. }
  2094. static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w,
  2095. struct snd_kcontrol *kcontrol, int event)
  2096. {
  2097. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2098. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  2099. switch (event) {
  2100. case SND_SOC_DAPM_PRE_PMU:
  2101. regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2);
  2102. break;
  2103. case SND_SOC_DAPM_POST_PMU:
  2104. regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0);
  2105. break;
  2106. default:
  2107. return 0;
  2108. }
  2109. return 0;
  2110. }
  2111. static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w,
  2112. struct snd_kcontrol *kcontrol, int event)
  2113. {
  2114. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2115. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  2116. switch (event) {
  2117. case SND_SOC_DAPM_POST_PMU:
  2118. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
  2119. RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 |
  2120. RT5677_PWR_CLK_MB, RT5677_PWR_CLK_MB1 |
  2121. RT5677_PWR_PP_MB1 | RT5677_PWR_CLK_MB);
  2122. break;
  2123. case SND_SOC_DAPM_PRE_PMD:
  2124. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
  2125. RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 |
  2126. RT5677_PWR_CLK_MB, 0);
  2127. break;
  2128. default:
  2129. return 0;
  2130. }
  2131. return 0;
  2132. }
  2133. static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w,
  2134. struct snd_kcontrol *kcontrol, int event)
  2135. {
  2136. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2137. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  2138. unsigned int value;
  2139. switch (event) {
  2140. case SND_SOC_DAPM_PRE_PMU:
  2141. regmap_read(rt5677->regmap, RT5677_TDM1_CTRL2, &value);
  2142. if (value & RT5677_IF1_ADC_CTRL_MASK)
  2143. regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1,
  2144. RT5677_IF1_ADC_MODE_MASK,
  2145. RT5677_IF1_ADC_MODE_TDM);
  2146. break;
  2147. default:
  2148. return 0;
  2149. }
  2150. return 0;
  2151. }
  2152. static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w,
  2153. struct snd_kcontrol *kcontrol, int event)
  2154. {
  2155. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2156. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  2157. unsigned int value;
  2158. switch (event) {
  2159. case SND_SOC_DAPM_PRE_PMU:
  2160. regmap_read(rt5677->regmap, RT5677_TDM2_CTRL2, &value);
  2161. if (value & RT5677_IF2_ADC_CTRL_MASK)
  2162. regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1,
  2163. RT5677_IF2_ADC_MODE_MASK,
  2164. RT5677_IF2_ADC_MODE_TDM);
  2165. break;
  2166. default:
  2167. return 0;
  2168. }
  2169. return 0;
  2170. }
  2171. static int rt5677_vref_event(struct snd_soc_dapm_widget *w,
  2172. struct snd_kcontrol *kcontrol, int event)
  2173. {
  2174. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2175. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  2176. switch (event) {
  2177. case SND_SOC_DAPM_POST_PMU:
  2178. if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_ON &&
  2179. !rt5677->is_vref_slow) {
  2180. mdelay(20);
  2181. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
  2182. RT5677_PWR_FV1 | RT5677_PWR_FV2,
  2183. RT5677_PWR_FV1 | RT5677_PWR_FV2);
  2184. rt5677->is_vref_slow = true;
  2185. }
  2186. break;
  2187. default:
  2188. return 0;
  2189. }
  2190. return 0;
  2191. }
  2192. static int rt5677_filter_power_event(struct snd_soc_dapm_widget *w,
  2193. struct snd_kcontrol *kcontrol, int event)
  2194. {
  2195. switch (event) {
  2196. case SND_SOC_DAPM_POST_PMU:
  2197. msleep(50);
  2198. break;
  2199. default:
  2200. return 0;
  2201. }
  2202. return 0;
  2203. }
  2204. static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = {
  2205. SND_SOC_DAPM_SUPPLY("PLL1", RT5677_PWR_ANLG2, RT5677_PWR_PLL1_BIT,
  2206. 0, rt5677_set_pll1_event, SND_SOC_DAPM_PRE_PMU |
  2207. SND_SOC_DAPM_POST_PMU),
  2208. SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT,
  2209. 0, rt5677_set_pll2_event, SND_SOC_DAPM_PRE_PMU |
  2210. SND_SOC_DAPM_POST_PMU),
  2211. /* ASRC */
  2212. SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5677_ASRC_1, 0, 0, NULL, 0),
  2213. SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5677_ASRC_1, 1, 0, NULL, 0),
  2214. SND_SOC_DAPM_SUPPLY_S("I2S3 ASRC", 1, RT5677_ASRC_1, 2, 0, NULL, 0),
  2215. SND_SOC_DAPM_SUPPLY_S("I2S4 ASRC", 1, RT5677_ASRC_1, 3, 0, NULL, 0),
  2216. SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5677_ASRC_2, 14, 0, NULL, 0),
  2217. SND_SOC_DAPM_SUPPLY_S("DAC MONO2 L ASRC", 1, RT5677_ASRC_2, 13, 0, NULL,
  2218. 0),
  2219. SND_SOC_DAPM_SUPPLY_S("DAC MONO2 R ASRC", 1, RT5677_ASRC_2, 12, 0, NULL,
  2220. 0),
  2221. SND_SOC_DAPM_SUPPLY_S("DAC MONO3 L ASRC", 1, RT5677_ASRC_1, 15, 0, NULL,
  2222. 0),
  2223. SND_SOC_DAPM_SUPPLY_S("DAC MONO3 R ASRC", 1, RT5677_ASRC_1, 14, 0, NULL,
  2224. 0),
  2225. SND_SOC_DAPM_SUPPLY_S("DAC MONO4 L ASRC", 1, RT5677_ASRC_1, 13, 0, NULL,
  2226. 0),
  2227. SND_SOC_DAPM_SUPPLY_S("DAC MONO4 R ASRC", 1, RT5677_ASRC_1, 12, 0, NULL,
  2228. 0),
  2229. SND_SOC_DAPM_SUPPLY_S("DMIC STO1 ASRC", 1, RT5677_ASRC_2, 11, 0, NULL,
  2230. 0),
  2231. SND_SOC_DAPM_SUPPLY_S("DMIC STO2 ASRC", 1, RT5677_ASRC_2, 10, 0, NULL,
  2232. 0),
  2233. SND_SOC_DAPM_SUPPLY_S("DMIC STO3 ASRC", 1, RT5677_ASRC_2, 9, 0, NULL,
  2234. 0),
  2235. SND_SOC_DAPM_SUPPLY_S("DMIC STO4 ASRC", 1, RT5677_ASRC_2, 8, 0, NULL,
  2236. 0),
  2237. SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5677_ASRC_2, 7, 0, NULL,
  2238. 0),
  2239. SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5677_ASRC_2, 6, 0, NULL,
  2240. 0),
  2241. SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5677_ASRC_2, 5, 0, NULL, 0),
  2242. SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5677_ASRC_2, 4, 0, NULL, 0),
  2243. SND_SOC_DAPM_SUPPLY_S("ADC STO3 ASRC", 1, RT5677_ASRC_2, 3, 0, NULL, 0),
  2244. SND_SOC_DAPM_SUPPLY_S("ADC STO4 ASRC", 1, RT5677_ASRC_2, 2, 0, NULL, 0),
  2245. SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5677_ASRC_2, 1, 0, NULL,
  2246. 0),
  2247. SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5677_ASRC_2, 0, 0, NULL,
  2248. 0),
  2249. /* Input Side */
  2250. /* micbias */
  2251. SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5677_PWR_ANLG2, RT5677_PWR_MB1_BIT,
  2252. 0, rt5677_set_micbias1_event, SND_SOC_DAPM_PRE_PMD |
  2253. SND_SOC_DAPM_POST_PMU),
  2254. /* Input Lines */
  2255. SND_SOC_DAPM_INPUT("DMIC L1"),
  2256. SND_SOC_DAPM_INPUT("DMIC R1"),
  2257. SND_SOC_DAPM_INPUT("DMIC L2"),
  2258. SND_SOC_DAPM_INPUT("DMIC R2"),
  2259. SND_SOC_DAPM_INPUT("DMIC L3"),
  2260. SND_SOC_DAPM_INPUT("DMIC R3"),
  2261. SND_SOC_DAPM_INPUT("DMIC L4"),
  2262. SND_SOC_DAPM_INPUT("DMIC R4"),
  2263. SND_SOC_DAPM_INPUT("IN1P"),
  2264. SND_SOC_DAPM_INPUT("IN1N"),
  2265. SND_SOC_DAPM_INPUT("IN2P"),
  2266. SND_SOC_DAPM_INPUT("IN2N"),
  2267. SND_SOC_DAPM_INPUT("Haptic Generator"),
  2268. SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0),
  2269. SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM, 0, 0, NULL, 0),
  2270. SND_SOC_DAPM_PGA("DMIC3", SND_SOC_NOPM, 0, 0, NULL, 0),
  2271. SND_SOC_DAPM_PGA("DMIC4", SND_SOC_NOPM, 0, 0, NULL, 0),
  2272. SND_SOC_DAPM_SUPPLY("DMIC1 power", RT5677_DMIC_CTRL1,
  2273. RT5677_DMIC_1_EN_SFT, 0, NULL, 0),
  2274. SND_SOC_DAPM_SUPPLY("DMIC2 power", RT5677_DMIC_CTRL1,
  2275. RT5677_DMIC_2_EN_SFT, 0, NULL, 0),
  2276. SND_SOC_DAPM_SUPPLY("DMIC3 power", RT5677_DMIC_CTRL1,
  2277. RT5677_DMIC_3_EN_SFT, 0, NULL, 0),
  2278. SND_SOC_DAPM_SUPPLY("DMIC4 power", RT5677_DMIC_CTRL2,
  2279. RT5677_DMIC_4_EN_SFT, 0, NULL, 0),
  2280. SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0,
  2281. set_dmic_clk, SND_SOC_DAPM_PRE_PMU),
  2282. /* Boost */
  2283. SND_SOC_DAPM_PGA_E("BST1", RT5677_PWR_ANLG2,
  2284. RT5677_PWR_BST1_BIT, 0, NULL, 0, rt5677_bst1_event,
  2285. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
  2286. SND_SOC_DAPM_PGA_E("BST2", RT5677_PWR_ANLG2,
  2287. RT5677_PWR_BST2_BIT, 0, NULL, 0, rt5677_bst2_event,
  2288. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
  2289. /* ADCs */
  2290. SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM,
  2291. 0, 0),
  2292. SND_SOC_DAPM_ADC("ADC 2", NULL, SND_SOC_NOPM,
  2293. 0, 0),
  2294. SND_SOC_DAPM_PGA("ADC 1_2", SND_SOC_NOPM, 0, 0, NULL, 0),
  2295. SND_SOC_DAPM_SUPPLY("ADC 1 power", RT5677_PWR_DIG1,
  2296. RT5677_PWR_ADC_L_BIT, 0, NULL, 0),
  2297. SND_SOC_DAPM_SUPPLY("ADC 2 power", RT5677_PWR_DIG1,
  2298. RT5677_PWR_ADC_R_BIT, 0, NULL, 0),
  2299. SND_SOC_DAPM_SUPPLY("ADC1 clock", RT5677_PWR_DIG1,
  2300. RT5677_PWR_ADCFED1_BIT, 0, NULL, 0),
  2301. SND_SOC_DAPM_SUPPLY("ADC2 clock", RT5677_PWR_DIG1,
  2302. RT5677_PWR_ADCFED2_BIT, 0, NULL, 0),
  2303. /* ADC Mux */
  2304. SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0,
  2305. &rt5677_sto1_dmic_mux),
  2306. SND_SOC_DAPM_MUX("Stereo1 ADC1 Mux", SND_SOC_NOPM, 0, 0,
  2307. &rt5677_sto1_adc1_mux),
  2308. SND_SOC_DAPM_MUX("Stereo1 ADC2 Mux", SND_SOC_NOPM, 0, 0,
  2309. &rt5677_sto1_adc2_mux),
  2310. SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM, 0, 0,
  2311. &rt5677_sto2_dmic_mux),
  2312. SND_SOC_DAPM_MUX("Stereo2 ADC1 Mux", SND_SOC_NOPM, 0, 0,
  2313. &rt5677_sto2_adc1_mux),
  2314. SND_SOC_DAPM_MUX("Stereo2 ADC2 Mux", SND_SOC_NOPM, 0, 0,
  2315. &rt5677_sto2_adc2_mux),
  2316. SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM, 0, 0,
  2317. &rt5677_sto2_adc_lr_mux),
  2318. SND_SOC_DAPM_MUX("Stereo3 DMIC Mux", SND_SOC_NOPM, 0, 0,
  2319. &rt5677_sto3_dmic_mux),
  2320. SND_SOC_DAPM_MUX("Stereo3 ADC1 Mux", SND_SOC_NOPM, 0, 0,
  2321. &rt5677_sto3_adc1_mux),
  2322. SND_SOC_DAPM_MUX("Stereo3 ADC2 Mux", SND_SOC_NOPM, 0, 0,
  2323. &rt5677_sto3_adc2_mux),
  2324. SND_SOC_DAPM_MUX("Stereo4 DMIC Mux", SND_SOC_NOPM, 0, 0,
  2325. &rt5677_sto4_dmic_mux),
  2326. SND_SOC_DAPM_MUX("Stereo4 ADC1 Mux", SND_SOC_NOPM, 0, 0,
  2327. &rt5677_sto4_adc1_mux),
  2328. SND_SOC_DAPM_MUX("Stereo4 ADC2 Mux", SND_SOC_NOPM, 0, 0,
  2329. &rt5677_sto4_adc2_mux),
  2330. SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0,
  2331. &rt5677_mono_dmic_l_mux),
  2332. SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0,
  2333. &rt5677_mono_dmic_r_mux),
  2334. SND_SOC_DAPM_MUX("Mono ADC2 L Mux", SND_SOC_NOPM, 0, 0,
  2335. &rt5677_mono_adc2_l_mux),
  2336. SND_SOC_DAPM_MUX("Mono ADC1 L Mux", SND_SOC_NOPM, 0, 0,
  2337. &rt5677_mono_adc1_l_mux),
  2338. SND_SOC_DAPM_MUX("Mono ADC1 R Mux", SND_SOC_NOPM, 0, 0,
  2339. &rt5677_mono_adc1_r_mux),
  2340. SND_SOC_DAPM_MUX("Mono ADC2 R Mux", SND_SOC_NOPM, 0, 0,
  2341. &rt5677_mono_adc2_r_mux),
  2342. /* ADC Mixer */
  2343. SND_SOC_DAPM_SUPPLY("adc stereo1 filter", RT5677_PWR_DIG2,
  2344. RT5677_PWR_ADC_S1F_BIT, 0, NULL, 0),
  2345. SND_SOC_DAPM_SUPPLY("adc stereo2 filter", RT5677_PWR_DIG2,
  2346. RT5677_PWR_ADC_S2F_BIT, 0, NULL, 0),
  2347. SND_SOC_DAPM_SUPPLY("adc stereo3 filter", RT5677_PWR_DIG2,
  2348. RT5677_PWR_ADC_S3F_BIT, 0, NULL, 0),
  2349. SND_SOC_DAPM_SUPPLY("adc stereo4 filter", RT5677_PWR_DIG2,
  2350. RT5677_PWR_ADC_S4F_BIT, 0, NULL, 0),
  2351. SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0,
  2352. rt5677_sto1_adc_l_mix, ARRAY_SIZE(rt5677_sto1_adc_l_mix)),
  2353. SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", SND_SOC_NOPM, 0, 0,
  2354. rt5677_sto1_adc_r_mix, ARRAY_SIZE(rt5677_sto1_adc_r_mix)),
  2355. SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM, 0, 0,
  2356. rt5677_sto2_adc_l_mix, ARRAY_SIZE(rt5677_sto2_adc_l_mix)),
  2357. SND_SOC_DAPM_MIXER("Sto2 ADC MIXR", SND_SOC_NOPM, 0, 0,
  2358. rt5677_sto2_adc_r_mix, ARRAY_SIZE(rt5677_sto2_adc_r_mix)),
  2359. SND_SOC_DAPM_MIXER("Sto3 ADC MIXL", SND_SOC_NOPM, 0, 0,
  2360. rt5677_sto3_adc_l_mix, ARRAY_SIZE(rt5677_sto3_adc_l_mix)),
  2361. SND_SOC_DAPM_MIXER("Sto3 ADC MIXR", SND_SOC_NOPM, 0, 0,
  2362. rt5677_sto3_adc_r_mix, ARRAY_SIZE(rt5677_sto3_adc_r_mix)),
  2363. SND_SOC_DAPM_MIXER("Sto4 ADC MIXL", SND_SOC_NOPM, 0, 0,
  2364. rt5677_sto4_adc_l_mix, ARRAY_SIZE(rt5677_sto4_adc_l_mix)),
  2365. SND_SOC_DAPM_MIXER("Sto4 ADC MIXR", SND_SOC_NOPM, 0, 0,
  2366. rt5677_sto4_adc_r_mix, ARRAY_SIZE(rt5677_sto4_adc_r_mix)),
  2367. SND_SOC_DAPM_SUPPLY("adc mono left filter", RT5677_PWR_DIG2,
  2368. RT5677_PWR_ADC_MF_L_BIT, 0, NULL, 0),
  2369. SND_SOC_DAPM_MIXER("Mono ADC MIXL", SND_SOC_NOPM, 0, 0,
  2370. rt5677_mono_adc_l_mix, ARRAY_SIZE(rt5677_mono_adc_l_mix)),
  2371. SND_SOC_DAPM_SUPPLY("adc mono right filter", RT5677_PWR_DIG2,
  2372. RT5677_PWR_ADC_MF_R_BIT, 0, NULL, 0),
  2373. SND_SOC_DAPM_MIXER("Mono ADC MIXR", SND_SOC_NOPM, 0, 0,
  2374. rt5677_mono_adc_r_mix, ARRAY_SIZE(rt5677_mono_adc_r_mix)),
  2375. /* ADC PGA */
  2376. SND_SOC_DAPM_PGA("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
  2377. SND_SOC_DAPM_PGA("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
  2378. SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  2379. SND_SOC_DAPM_PGA("Stereo2 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
  2380. SND_SOC_DAPM_PGA("Stereo2 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
  2381. SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  2382. SND_SOC_DAPM_PGA("Stereo3 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
  2383. SND_SOC_DAPM_PGA("Stereo3 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
  2384. SND_SOC_DAPM_PGA("Stereo3 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  2385. SND_SOC_DAPM_PGA("Stereo4 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
  2386. SND_SOC_DAPM_PGA("Stereo4 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
  2387. SND_SOC_DAPM_PGA("Stereo4 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  2388. SND_SOC_DAPM_PGA("Sto2 ADC LR MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  2389. SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  2390. SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
  2391. SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
  2392. /* DSP */
  2393. SND_SOC_DAPM_MUX("IB9 Mux", SND_SOC_NOPM, 0, 0,
  2394. &rt5677_ib9_src_mux),
  2395. SND_SOC_DAPM_MUX("IB8 Mux", SND_SOC_NOPM, 0, 0,
  2396. &rt5677_ib8_src_mux),
  2397. SND_SOC_DAPM_MUX("IB7 Mux", SND_SOC_NOPM, 0, 0,
  2398. &rt5677_ib7_src_mux),
  2399. SND_SOC_DAPM_MUX("IB6 Mux", SND_SOC_NOPM, 0, 0,
  2400. &rt5677_ib6_src_mux),
  2401. SND_SOC_DAPM_MUX("IB45 Mux", SND_SOC_NOPM, 0, 0,
  2402. &rt5677_ib45_src_mux),
  2403. SND_SOC_DAPM_MUX("IB23 Mux", SND_SOC_NOPM, 0, 0,
  2404. &rt5677_ib23_src_mux),
  2405. SND_SOC_DAPM_MUX("IB01 Mux", SND_SOC_NOPM, 0, 0,
  2406. &rt5677_ib01_src_mux),
  2407. SND_SOC_DAPM_MUX("IB45 Bypass Mux", SND_SOC_NOPM, 0, 0,
  2408. &rt5677_ib45_bypass_src_mux),
  2409. SND_SOC_DAPM_MUX("IB23 Bypass Mux", SND_SOC_NOPM, 0, 0,
  2410. &rt5677_ib23_bypass_src_mux),
  2411. SND_SOC_DAPM_MUX("IB01 Bypass Mux", SND_SOC_NOPM, 0, 0,
  2412. &rt5677_ib01_bypass_src_mux),
  2413. SND_SOC_DAPM_MUX("OB23 Bypass Mux", SND_SOC_NOPM, 0, 0,
  2414. &rt5677_ob23_bypass_src_mux),
  2415. SND_SOC_DAPM_MUX("OB01 Bypass Mux", SND_SOC_NOPM, 0, 0,
  2416. &rt5677_ob01_bypass_src_mux),
  2417. SND_SOC_DAPM_PGA("OB45", SND_SOC_NOPM, 0, 0, NULL, 0),
  2418. SND_SOC_DAPM_PGA("OB67", SND_SOC_NOPM, 0, 0, NULL, 0),
  2419. SND_SOC_DAPM_PGA("OutBound2", SND_SOC_NOPM, 0, 0, NULL, 0),
  2420. SND_SOC_DAPM_PGA("OutBound3", SND_SOC_NOPM, 0, 0, NULL, 0),
  2421. SND_SOC_DAPM_PGA("OutBound4", SND_SOC_NOPM, 0, 0, NULL, 0),
  2422. SND_SOC_DAPM_PGA("OutBound5", SND_SOC_NOPM, 0, 0, NULL, 0),
  2423. SND_SOC_DAPM_PGA("OutBound6", SND_SOC_NOPM, 0, 0, NULL, 0),
  2424. SND_SOC_DAPM_PGA("OutBound7", SND_SOC_NOPM, 0, 0, NULL, 0),
  2425. /* Digital Interface */
  2426. SND_SOC_DAPM_SUPPLY("I2S1", RT5677_PWR_DIG1,
  2427. RT5677_PWR_I2S1_BIT, 0, NULL, 0),
  2428. SND_SOC_DAPM_PGA("IF1 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
  2429. SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
  2430. SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
  2431. SND_SOC_DAPM_PGA("IF1 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
  2432. SND_SOC_DAPM_PGA("IF1 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
  2433. SND_SOC_DAPM_PGA("IF1 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
  2434. SND_SOC_DAPM_PGA("IF1 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
  2435. SND_SOC_DAPM_PGA("IF1 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
  2436. SND_SOC_DAPM_PGA("IF1 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
  2437. SND_SOC_DAPM_PGA("IF1 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
  2438. SND_SOC_DAPM_PGA("IF1 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
  2439. SND_SOC_DAPM_PGA("IF1 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
  2440. SND_SOC_DAPM_PGA("IF1 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
  2441. SND_SOC_DAPM_PGA("IF1 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
  2442. SND_SOC_DAPM_PGA("IF1 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
  2443. SND_SOC_DAPM_PGA("IF1 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
  2444. SND_SOC_DAPM_SUPPLY("I2S2", RT5677_PWR_DIG1,
  2445. RT5677_PWR_I2S2_BIT, 0, NULL, 0),
  2446. SND_SOC_DAPM_PGA("IF2 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
  2447. SND_SOC_DAPM_PGA("IF2 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
  2448. SND_SOC_DAPM_PGA("IF2 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
  2449. SND_SOC_DAPM_PGA("IF2 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
  2450. SND_SOC_DAPM_PGA("IF2 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
  2451. SND_SOC_DAPM_PGA("IF2 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
  2452. SND_SOC_DAPM_PGA("IF2 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
  2453. SND_SOC_DAPM_PGA("IF2 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
  2454. SND_SOC_DAPM_PGA("IF2 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
  2455. SND_SOC_DAPM_PGA("IF2 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
  2456. SND_SOC_DAPM_PGA("IF2 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
  2457. SND_SOC_DAPM_PGA("IF2 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
  2458. SND_SOC_DAPM_PGA("IF2 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
  2459. SND_SOC_DAPM_PGA("IF2 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
  2460. SND_SOC_DAPM_PGA("IF2 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
  2461. SND_SOC_DAPM_PGA("IF2 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
  2462. SND_SOC_DAPM_SUPPLY("I2S3", RT5677_PWR_DIG1,
  2463. RT5677_PWR_I2S3_BIT, 0, NULL, 0),
  2464. SND_SOC_DAPM_PGA("IF3 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
  2465. SND_SOC_DAPM_PGA("IF3 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
  2466. SND_SOC_DAPM_PGA("IF3 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
  2467. SND_SOC_DAPM_PGA("IF3 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
  2468. SND_SOC_DAPM_PGA("IF3 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
  2469. SND_SOC_DAPM_PGA("IF3 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
  2470. SND_SOC_DAPM_SUPPLY("I2S4", RT5677_PWR_DIG1,
  2471. RT5677_PWR_I2S4_BIT, 0, NULL, 0),
  2472. SND_SOC_DAPM_PGA("IF4 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
  2473. SND_SOC_DAPM_PGA("IF4 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0),
  2474. SND_SOC_DAPM_PGA("IF4 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0),
  2475. SND_SOC_DAPM_PGA("IF4 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
  2476. SND_SOC_DAPM_PGA("IF4 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
  2477. SND_SOC_DAPM_PGA("IF4 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
  2478. SND_SOC_DAPM_SUPPLY("SLB", RT5677_PWR_DIG1,
  2479. RT5677_PWR_SLB_BIT, 0, NULL, 0),
  2480. SND_SOC_DAPM_PGA("SLB DAC0", SND_SOC_NOPM, 0, 0, NULL, 0),
  2481. SND_SOC_DAPM_PGA("SLB DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
  2482. SND_SOC_DAPM_PGA("SLB DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
  2483. SND_SOC_DAPM_PGA("SLB DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
  2484. SND_SOC_DAPM_PGA("SLB DAC4", SND_SOC_NOPM, 0, 0, NULL, 0),
  2485. SND_SOC_DAPM_PGA("SLB DAC5", SND_SOC_NOPM, 0, 0, NULL, 0),
  2486. SND_SOC_DAPM_PGA("SLB DAC6", SND_SOC_NOPM, 0, 0, NULL, 0),
  2487. SND_SOC_DAPM_PGA("SLB DAC7", SND_SOC_NOPM, 0, 0, NULL, 0),
  2488. SND_SOC_DAPM_PGA("SLB DAC01", SND_SOC_NOPM, 0, 0, NULL, 0),
  2489. SND_SOC_DAPM_PGA("SLB DAC23", SND_SOC_NOPM, 0, 0, NULL, 0),
  2490. SND_SOC_DAPM_PGA("SLB DAC45", SND_SOC_NOPM, 0, 0, NULL, 0),
  2491. SND_SOC_DAPM_PGA("SLB DAC67", SND_SOC_NOPM, 0, 0, NULL, 0),
  2492. SND_SOC_DAPM_PGA("SLB ADC1", SND_SOC_NOPM, 0, 0, NULL, 0),
  2493. SND_SOC_DAPM_PGA("SLB ADC2", SND_SOC_NOPM, 0, 0, NULL, 0),
  2494. SND_SOC_DAPM_PGA("SLB ADC3", SND_SOC_NOPM, 0, 0, NULL, 0),
  2495. SND_SOC_DAPM_PGA("SLB ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
  2496. /* Digital Interface Select */
  2497. SND_SOC_DAPM_MUX("IF1 ADC1 Mux", SND_SOC_NOPM, 0, 0,
  2498. &rt5677_if1_adc1_mux),
  2499. SND_SOC_DAPM_MUX("IF1 ADC2 Mux", SND_SOC_NOPM, 0, 0,
  2500. &rt5677_if1_adc2_mux),
  2501. SND_SOC_DAPM_MUX("IF1 ADC3 Mux", SND_SOC_NOPM, 0, 0,
  2502. &rt5677_if1_adc3_mux),
  2503. SND_SOC_DAPM_MUX("IF1 ADC4 Mux", SND_SOC_NOPM, 0, 0,
  2504. &rt5677_if1_adc4_mux),
  2505. SND_SOC_DAPM_MUX("IF1 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0,
  2506. &rt5677_if1_adc1_swap_mux),
  2507. SND_SOC_DAPM_MUX("IF1 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0,
  2508. &rt5677_if1_adc2_swap_mux),
  2509. SND_SOC_DAPM_MUX("IF1 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0,
  2510. &rt5677_if1_adc3_swap_mux),
  2511. SND_SOC_DAPM_MUX("IF1 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0,
  2512. &rt5677_if1_adc4_swap_mux),
  2513. SND_SOC_DAPM_MUX_E("IF1 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0,
  2514. &rt5677_if1_adc_tdm_swap_mux, rt5677_if1_adc_tdm_event,
  2515. SND_SOC_DAPM_PRE_PMU),
  2516. SND_SOC_DAPM_MUX("IF2 ADC1 Mux", SND_SOC_NOPM, 0, 0,
  2517. &rt5677_if2_adc1_mux),
  2518. SND_SOC_DAPM_MUX("IF2 ADC2 Mux", SND_SOC_NOPM, 0, 0,
  2519. &rt5677_if2_adc2_mux),
  2520. SND_SOC_DAPM_MUX("IF2 ADC3 Mux", SND_SOC_NOPM, 0, 0,
  2521. &rt5677_if2_adc3_mux),
  2522. SND_SOC_DAPM_MUX("IF2 ADC4 Mux", SND_SOC_NOPM, 0, 0,
  2523. &rt5677_if2_adc4_mux),
  2524. SND_SOC_DAPM_MUX("IF2 ADC1 Swap Mux", SND_SOC_NOPM, 0, 0,
  2525. &rt5677_if2_adc1_swap_mux),
  2526. SND_SOC_DAPM_MUX("IF2 ADC2 Swap Mux", SND_SOC_NOPM, 0, 0,
  2527. &rt5677_if2_adc2_swap_mux),
  2528. SND_SOC_DAPM_MUX("IF2 ADC3 Swap Mux", SND_SOC_NOPM, 0, 0,
  2529. &rt5677_if2_adc3_swap_mux),
  2530. SND_SOC_DAPM_MUX("IF2 ADC4 Swap Mux", SND_SOC_NOPM, 0, 0,
  2531. &rt5677_if2_adc4_swap_mux),
  2532. SND_SOC_DAPM_MUX_E("IF2 ADC TDM Swap Mux", SND_SOC_NOPM, 0, 0,
  2533. &rt5677_if2_adc_tdm_swap_mux, rt5677_if2_adc_tdm_event,
  2534. SND_SOC_DAPM_PRE_PMU),
  2535. SND_SOC_DAPM_MUX("IF3 ADC Mux", SND_SOC_NOPM, 0, 0,
  2536. &rt5677_if3_adc_mux),
  2537. SND_SOC_DAPM_MUX("IF4 ADC Mux", SND_SOC_NOPM, 0, 0,
  2538. &rt5677_if4_adc_mux),
  2539. SND_SOC_DAPM_MUX("SLB ADC1 Mux", SND_SOC_NOPM, 0, 0,
  2540. &rt5677_slb_adc1_mux),
  2541. SND_SOC_DAPM_MUX("SLB ADC2 Mux", SND_SOC_NOPM, 0, 0,
  2542. &rt5677_slb_adc2_mux),
  2543. SND_SOC_DAPM_MUX("SLB ADC3 Mux", SND_SOC_NOPM, 0, 0,
  2544. &rt5677_slb_adc3_mux),
  2545. SND_SOC_DAPM_MUX("SLB ADC4 Mux", SND_SOC_NOPM, 0, 0,
  2546. &rt5677_slb_adc4_mux),
  2547. SND_SOC_DAPM_MUX("IF1 DAC0 Mux", SND_SOC_NOPM, 0, 0,
  2548. &rt5677_if1_dac0_tdm_sel_mux),
  2549. SND_SOC_DAPM_MUX("IF1 DAC1 Mux", SND_SOC_NOPM, 0, 0,
  2550. &rt5677_if1_dac1_tdm_sel_mux),
  2551. SND_SOC_DAPM_MUX("IF1 DAC2 Mux", SND_SOC_NOPM, 0, 0,
  2552. &rt5677_if1_dac2_tdm_sel_mux),
  2553. SND_SOC_DAPM_MUX("IF1 DAC3 Mux", SND_SOC_NOPM, 0, 0,
  2554. &rt5677_if1_dac3_tdm_sel_mux),
  2555. SND_SOC_DAPM_MUX("IF1 DAC4 Mux", SND_SOC_NOPM, 0, 0,
  2556. &rt5677_if1_dac4_tdm_sel_mux),
  2557. SND_SOC_DAPM_MUX("IF1 DAC5 Mux", SND_SOC_NOPM, 0, 0,
  2558. &rt5677_if1_dac5_tdm_sel_mux),
  2559. SND_SOC_DAPM_MUX("IF1 DAC6 Mux", SND_SOC_NOPM, 0, 0,
  2560. &rt5677_if1_dac6_tdm_sel_mux),
  2561. SND_SOC_DAPM_MUX("IF1 DAC7 Mux", SND_SOC_NOPM, 0, 0,
  2562. &rt5677_if1_dac7_tdm_sel_mux),
  2563. SND_SOC_DAPM_MUX("IF2 DAC0 Mux", SND_SOC_NOPM, 0, 0,
  2564. &rt5677_if2_dac0_tdm_sel_mux),
  2565. SND_SOC_DAPM_MUX("IF2 DAC1 Mux", SND_SOC_NOPM, 0, 0,
  2566. &rt5677_if2_dac1_tdm_sel_mux),
  2567. SND_SOC_DAPM_MUX("IF2 DAC2 Mux", SND_SOC_NOPM, 0, 0,
  2568. &rt5677_if2_dac2_tdm_sel_mux),
  2569. SND_SOC_DAPM_MUX("IF2 DAC3 Mux", SND_SOC_NOPM, 0, 0,
  2570. &rt5677_if2_dac3_tdm_sel_mux),
  2571. SND_SOC_DAPM_MUX("IF2 DAC4 Mux", SND_SOC_NOPM, 0, 0,
  2572. &rt5677_if2_dac4_tdm_sel_mux),
  2573. SND_SOC_DAPM_MUX("IF2 DAC5 Mux", SND_SOC_NOPM, 0, 0,
  2574. &rt5677_if2_dac5_tdm_sel_mux),
  2575. SND_SOC_DAPM_MUX("IF2 DAC6 Mux", SND_SOC_NOPM, 0, 0,
  2576. &rt5677_if2_dac6_tdm_sel_mux),
  2577. SND_SOC_DAPM_MUX("IF2 DAC7 Mux", SND_SOC_NOPM, 0, 0,
  2578. &rt5677_if2_dac7_tdm_sel_mux),
  2579. /* Audio Interface */
  2580. SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
  2581. SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
  2582. SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
  2583. SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
  2584. SND_SOC_DAPM_AIF_IN("AIF3RX", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0),
  2585. SND_SOC_DAPM_AIF_OUT("AIF3TX", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0),
  2586. SND_SOC_DAPM_AIF_IN("AIF4RX", "AIF4 Playback", 0, SND_SOC_NOPM, 0, 0),
  2587. SND_SOC_DAPM_AIF_OUT("AIF4TX", "AIF4 Capture", 0, SND_SOC_NOPM, 0, 0),
  2588. SND_SOC_DAPM_AIF_IN("SLBRX", "SLIMBus Playback", 0, SND_SOC_NOPM, 0, 0),
  2589. SND_SOC_DAPM_AIF_OUT("SLBTX", "SLIMBus Capture", 0, SND_SOC_NOPM, 0, 0),
  2590. /* Sidetone Mux */
  2591. SND_SOC_DAPM_MUX("Sidetone Mux", SND_SOC_NOPM, 0, 0,
  2592. &rt5677_sidetone_mux),
  2593. SND_SOC_DAPM_SUPPLY("Sidetone Power", RT5677_SIDETONE_CTRL,
  2594. RT5677_ST_EN_SFT, 0, NULL, 0),
  2595. /* VAD Mux*/
  2596. SND_SOC_DAPM_MUX("VAD ADC Mux", SND_SOC_NOPM, 0, 0,
  2597. &rt5677_vad_src_mux),
  2598. /* Tensilica DSP */
  2599. SND_SOC_DAPM_PGA("Tensilica DSP", SND_SOC_NOPM, 0, 0, NULL, 0),
  2600. SND_SOC_DAPM_MIXER("OB01 MIX", SND_SOC_NOPM, 0, 0,
  2601. rt5677_ob_01_mix, ARRAY_SIZE(rt5677_ob_01_mix)),
  2602. SND_SOC_DAPM_MIXER("OB23 MIX", SND_SOC_NOPM, 0, 0,
  2603. rt5677_ob_23_mix, ARRAY_SIZE(rt5677_ob_23_mix)),
  2604. SND_SOC_DAPM_MIXER("OB4 MIX", SND_SOC_NOPM, 0, 0,
  2605. rt5677_ob_4_mix, ARRAY_SIZE(rt5677_ob_4_mix)),
  2606. SND_SOC_DAPM_MIXER("OB5 MIX", SND_SOC_NOPM, 0, 0,
  2607. rt5677_ob_5_mix, ARRAY_SIZE(rt5677_ob_5_mix)),
  2608. SND_SOC_DAPM_MIXER("OB6 MIX", SND_SOC_NOPM, 0, 0,
  2609. rt5677_ob_6_mix, ARRAY_SIZE(rt5677_ob_6_mix)),
  2610. SND_SOC_DAPM_MIXER("OB7 MIX", SND_SOC_NOPM, 0, 0,
  2611. rt5677_ob_7_mix, ARRAY_SIZE(rt5677_ob_7_mix)),
  2612. /* Output Side */
  2613. /* DAC mixer before sound effect */
  2614. SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM, 0, 0,
  2615. rt5677_dac_l_mix, ARRAY_SIZE(rt5677_dac_l_mix)),
  2616. SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM, 0, 0,
  2617. rt5677_dac_r_mix, ARRAY_SIZE(rt5677_dac_r_mix)),
  2618. SND_SOC_DAPM_PGA("DAC1 FS", SND_SOC_NOPM, 0, 0, NULL, 0),
  2619. /* DAC Mux */
  2620. SND_SOC_DAPM_MUX("DAC1 Mux", SND_SOC_NOPM, 0, 0,
  2621. &rt5677_dac1_mux),
  2622. SND_SOC_DAPM_MUX("ADDA1 Mux", SND_SOC_NOPM, 0, 0,
  2623. &rt5677_adda1_mux),
  2624. SND_SOC_DAPM_MUX("DAC12 SRC Mux", SND_SOC_NOPM, 0, 0,
  2625. &rt5677_dac12_mux),
  2626. SND_SOC_DAPM_MUX("DAC3 SRC Mux", SND_SOC_NOPM, 0, 0,
  2627. &rt5677_dac3_mux),
  2628. /* DAC2 channel Mux */
  2629. SND_SOC_DAPM_MUX("DAC2 L Mux", SND_SOC_NOPM, 0, 0,
  2630. &rt5677_dac2_l_mux),
  2631. SND_SOC_DAPM_MUX("DAC2 R Mux", SND_SOC_NOPM, 0, 0,
  2632. &rt5677_dac2_r_mux),
  2633. /* DAC3 channel Mux */
  2634. SND_SOC_DAPM_MUX("DAC3 L Mux", SND_SOC_NOPM, 0, 0,
  2635. &rt5677_dac3_l_mux),
  2636. SND_SOC_DAPM_MUX("DAC3 R Mux", SND_SOC_NOPM, 0, 0,
  2637. &rt5677_dac3_r_mux),
  2638. /* DAC4 channel Mux */
  2639. SND_SOC_DAPM_MUX("DAC4 L Mux", SND_SOC_NOPM, 0, 0,
  2640. &rt5677_dac4_l_mux),
  2641. SND_SOC_DAPM_MUX("DAC4 R Mux", SND_SOC_NOPM, 0, 0,
  2642. &rt5677_dac4_r_mux),
  2643. /* DAC Mixer */
  2644. SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2,
  2645. RT5677_PWR_DAC_S1F_BIT, 0, rt5677_filter_power_event,
  2646. SND_SOC_DAPM_POST_PMU),
  2647. SND_SOC_DAPM_SUPPLY("dac mono2 left filter", RT5677_PWR_DIG2,
  2648. RT5677_PWR_DAC_M2F_L_BIT, 0, rt5677_filter_power_event,
  2649. SND_SOC_DAPM_POST_PMU),
  2650. SND_SOC_DAPM_SUPPLY("dac mono2 right filter", RT5677_PWR_DIG2,
  2651. RT5677_PWR_DAC_M2F_R_BIT, 0, rt5677_filter_power_event,
  2652. SND_SOC_DAPM_POST_PMU),
  2653. SND_SOC_DAPM_SUPPLY("dac mono3 left filter", RT5677_PWR_DIG2,
  2654. RT5677_PWR_DAC_M3F_L_BIT, 0, rt5677_filter_power_event,
  2655. SND_SOC_DAPM_POST_PMU),
  2656. SND_SOC_DAPM_SUPPLY("dac mono3 right filter", RT5677_PWR_DIG2,
  2657. RT5677_PWR_DAC_M3F_R_BIT, 0, rt5677_filter_power_event,
  2658. SND_SOC_DAPM_POST_PMU),
  2659. SND_SOC_DAPM_SUPPLY("dac mono4 left filter", RT5677_PWR_DIG2,
  2660. RT5677_PWR_DAC_M4F_L_BIT, 0, rt5677_filter_power_event,
  2661. SND_SOC_DAPM_POST_PMU),
  2662. SND_SOC_DAPM_SUPPLY("dac mono4 right filter", RT5677_PWR_DIG2,
  2663. RT5677_PWR_DAC_M4F_R_BIT, 0, rt5677_filter_power_event,
  2664. SND_SOC_DAPM_POST_PMU),
  2665. SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0,
  2666. rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)),
  2667. SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0,
  2668. rt5677_sto1_dac_r_mix, ARRAY_SIZE(rt5677_sto1_dac_r_mix)),
  2669. SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0,
  2670. rt5677_mono_dac_l_mix, ARRAY_SIZE(rt5677_mono_dac_l_mix)),
  2671. SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0,
  2672. rt5677_mono_dac_r_mix, ARRAY_SIZE(rt5677_mono_dac_r_mix)),
  2673. SND_SOC_DAPM_MIXER("DD1 MIXL", SND_SOC_NOPM, 0, 0,
  2674. rt5677_dd1_l_mix, ARRAY_SIZE(rt5677_dd1_l_mix)),
  2675. SND_SOC_DAPM_MIXER("DD1 MIXR", SND_SOC_NOPM, 0, 0,
  2676. rt5677_dd1_r_mix, ARRAY_SIZE(rt5677_dd1_r_mix)),
  2677. SND_SOC_DAPM_MIXER("DD2 MIXL", SND_SOC_NOPM, 0, 0,
  2678. rt5677_dd2_l_mix, ARRAY_SIZE(rt5677_dd2_l_mix)),
  2679. SND_SOC_DAPM_MIXER("DD2 MIXR", SND_SOC_NOPM, 0, 0,
  2680. rt5677_dd2_r_mix, ARRAY_SIZE(rt5677_dd2_r_mix)),
  2681. SND_SOC_DAPM_PGA("Stereo DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  2682. SND_SOC_DAPM_PGA("Mono DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  2683. SND_SOC_DAPM_PGA("DD1 MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  2684. SND_SOC_DAPM_PGA("DD2 MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
  2685. /* DACs */
  2686. SND_SOC_DAPM_DAC("DAC 1", NULL, RT5677_PWR_DIG1,
  2687. RT5677_PWR_DAC1_BIT, 0),
  2688. SND_SOC_DAPM_DAC("DAC 2", NULL, RT5677_PWR_DIG1,
  2689. RT5677_PWR_DAC2_BIT, 0),
  2690. SND_SOC_DAPM_DAC("DAC 3", NULL, RT5677_PWR_DIG1,
  2691. RT5677_PWR_DAC3_BIT, 0),
  2692. /* PDM */
  2693. SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5677_PWR_DIG2,
  2694. RT5677_PWR_PDM1_BIT, 0, NULL, 0),
  2695. SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5677_PWR_DIG2,
  2696. RT5677_PWR_PDM2_BIT, 0, NULL, 0),
  2697. SND_SOC_DAPM_MUX("PDM1 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_L_SFT,
  2698. 1, &rt5677_pdm1_l_mux),
  2699. SND_SOC_DAPM_MUX("PDM1 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_R_SFT,
  2700. 1, &rt5677_pdm1_r_mux),
  2701. SND_SOC_DAPM_MUX("PDM2 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_L_SFT,
  2702. 1, &rt5677_pdm2_l_mux),
  2703. SND_SOC_DAPM_MUX("PDM2 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_R_SFT,
  2704. 1, &rt5677_pdm2_r_mux),
  2705. SND_SOC_DAPM_PGA_S("LOUT1 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO1_BIT,
  2706. 0, NULL, 0),
  2707. SND_SOC_DAPM_PGA_S("LOUT2 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO2_BIT,
  2708. 0, NULL, 0),
  2709. SND_SOC_DAPM_PGA_S("LOUT3 amp", 0, RT5677_PWR_ANLG1, RT5677_PWR_LO3_BIT,
  2710. 0, NULL, 0),
  2711. SND_SOC_DAPM_PGA_S("LOUT1 vref", 1, SND_SOC_NOPM, 0, 0,
  2712. rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
  2713. SND_SOC_DAPM_PGA_S("LOUT2 vref", 1, SND_SOC_NOPM, 0, 0,
  2714. rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
  2715. SND_SOC_DAPM_PGA_S("LOUT3 vref", 1, SND_SOC_NOPM, 0, 0,
  2716. rt5677_vref_event, SND_SOC_DAPM_POST_PMU),
  2717. /* Output Lines */
  2718. SND_SOC_DAPM_OUTPUT("LOUT1"),
  2719. SND_SOC_DAPM_OUTPUT("LOUT2"),
  2720. SND_SOC_DAPM_OUTPUT("LOUT3"),
  2721. SND_SOC_DAPM_OUTPUT("PDM1L"),
  2722. SND_SOC_DAPM_OUTPUT("PDM1R"),
  2723. SND_SOC_DAPM_OUTPUT("PDM2L"),
  2724. SND_SOC_DAPM_OUTPUT("PDM2R"),
  2725. SND_SOC_DAPM_POST("vref", rt5677_vref_event),
  2726. };
  2727. static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
  2728. { "Stereo1 DMIC Mux", NULL, "DMIC STO1 ASRC", rt5677_dmic_use_asrc },
  2729. { "Stereo2 DMIC Mux", NULL, "DMIC STO2 ASRC", rt5677_dmic_use_asrc },
  2730. { "Stereo3 DMIC Mux", NULL, "DMIC STO3 ASRC", rt5677_dmic_use_asrc },
  2731. { "Stereo4 DMIC Mux", NULL, "DMIC STO4 ASRC", rt5677_dmic_use_asrc },
  2732. { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", rt5677_dmic_use_asrc },
  2733. { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", rt5677_dmic_use_asrc },
  2734. { "I2S1", NULL, "I2S1 ASRC", can_use_asrc},
  2735. { "I2S2", NULL, "I2S2 ASRC", can_use_asrc},
  2736. { "I2S3", NULL, "I2S3 ASRC", can_use_asrc},
  2737. { "I2S4", NULL, "I2S4 ASRC", can_use_asrc},
  2738. { "dac stereo1 filter", NULL, "DAC STO ASRC", is_using_asrc },
  2739. { "dac mono2 left filter", NULL, "DAC MONO2 L ASRC", is_using_asrc },
  2740. { "dac mono2 right filter", NULL, "DAC MONO2 R ASRC", is_using_asrc },
  2741. { "dac mono3 left filter", NULL, "DAC MONO3 L ASRC", is_using_asrc },
  2742. { "dac mono3 right filter", NULL, "DAC MONO3 R ASRC", is_using_asrc },
  2743. { "dac mono4 left filter", NULL, "DAC MONO4 L ASRC", is_using_asrc },
  2744. { "dac mono4 right filter", NULL, "DAC MONO4 R ASRC", is_using_asrc },
  2745. { "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc },
  2746. { "adc stereo2 filter", NULL, "ADC STO2 ASRC", is_using_asrc },
  2747. { "adc stereo3 filter", NULL, "ADC STO3 ASRC", is_using_asrc },
  2748. { "adc stereo4 filter", NULL, "ADC STO4 ASRC", is_using_asrc },
  2749. { "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc },
  2750. { "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc },
  2751. { "DMIC1", NULL, "DMIC L1" },
  2752. { "DMIC1", NULL, "DMIC R1" },
  2753. { "DMIC2", NULL, "DMIC L2" },
  2754. { "DMIC2", NULL, "DMIC R2" },
  2755. { "DMIC3", NULL, "DMIC L3" },
  2756. { "DMIC3", NULL, "DMIC R3" },
  2757. { "DMIC4", NULL, "DMIC L4" },
  2758. { "DMIC4", NULL, "DMIC R4" },
  2759. { "DMIC L1", NULL, "DMIC CLK" },
  2760. { "DMIC R1", NULL, "DMIC CLK" },
  2761. { "DMIC L2", NULL, "DMIC CLK" },
  2762. { "DMIC R2", NULL, "DMIC CLK" },
  2763. { "DMIC L3", NULL, "DMIC CLK" },
  2764. { "DMIC R3", NULL, "DMIC CLK" },
  2765. { "DMIC L4", NULL, "DMIC CLK" },
  2766. { "DMIC R4", NULL, "DMIC CLK" },
  2767. { "DMIC L1", NULL, "DMIC1 power" },
  2768. { "DMIC R1", NULL, "DMIC1 power" },
  2769. { "DMIC L3", NULL, "DMIC3 power" },
  2770. { "DMIC R3", NULL, "DMIC3 power" },
  2771. { "DMIC L4", NULL, "DMIC4 power" },
  2772. { "DMIC R4", NULL, "DMIC4 power" },
  2773. { "BST1", NULL, "IN1P" },
  2774. { "BST1", NULL, "IN1N" },
  2775. { "BST2", NULL, "IN2P" },
  2776. { "BST2", NULL, "IN2N" },
  2777. { "IN1P", NULL, "MICBIAS1" },
  2778. { "IN1N", NULL, "MICBIAS1" },
  2779. { "IN2P", NULL, "MICBIAS1" },
  2780. { "IN2N", NULL, "MICBIAS1" },
  2781. { "ADC 1", NULL, "BST1" },
  2782. { "ADC 1", NULL, "ADC 1 power" },
  2783. { "ADC 1", NULL, "ADC1 clock" },
  2784. { "ADC 2", NULL, "BST2" },
  2785. { "ADC 2", NULL, "ADC 2 power" },
  2786. { "ADC 2", NULL, "ADC2 clock" },
  2787. { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" },
  2788. { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" },
  2789. { "Stereo1 DMIC Mux", "DMIC3", "DMIC3" },
  2790. { "Stereo1 DMIC Mux", "DMIC4", "DMIC4" },
  2791. { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" },
  2792. { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" },
  2793. { "Stereo2 DMIC Mux", "DMIC3", "DMIC3" },
  2794. { "Stereo2 DMIC Mux", "DMIC4", "DMIC4" },
  2795. { "Stereo3 DMIC Mux", "DMIC1", "DMIC1" },
  2796. { "Stereo3 DMIC Mux", "DMIC2", "DMIC2" },
  2797. { "Stereo3 DMIC Mux", "DMIC3", "DMIC3" },
  2798. { "Stereo3 DMIC Mux", "DMIC4", "DMIC4" },
  2799. { "Stereo4 DMIC Mux", "DMIC1", "DMIC1" },
  2800. { "Stereo4 DMIC Mux", "DMIC2", "DMIC2" },
  2801. { "Stereo4 DMIC Mux", "DMIC3", "DMIC3" },
  2802. { "Stereo4 DMIC Mux", "DMIC4", "DMIC4" },
  2803. { "Mono DMIC L Mux", "DMIC1", "DMIC1" },
  2804. { "Mono DMIC L Mux", "DMIC2", "DMIC2" },
  2805. { "Mono DMIC L Mux", "DMIC3", "DMIC3" },
  2806. { "Mono DMIC L Mux", "DMIC4", "DMIC4" },
  2807. { "Mono DMIC R Mux", "DMIC1", "DMIC1" },
  2808. { "Mono DMIC R Mux", "DMIC2", "DMIC2" },
  2809. { "Mono DMIC R Mux", "DMIC3", "DMIC3" },
  2810. { "Mono DMIC R Mux", "DMIC4", "DMIC4" },
  2811. { "ADC 1_2", NULL, "ADC 1" },
  2812. { "ADC 1_2", NULL, "ADC 2" },
  2813. { "Stereo1 ADC1 Mux", "DD MIX1", "DD1 MIX" },
  2814. { "Stereo1 ADC1 Mux", "ADC1/2", "ADC 1_2" },
  2815. { "Stereo1 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
  2816. { "Stereo1 ADC2 Mux", "DD MIX1", "DD1 MIX" },
  2817. { "Stereo1 ADC2 Mux", "DMIC", "Stereo1 DMIC Mux" },
  2818. { "Stereo1 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
  2819. { "Stereo2 ADC1 Mux", "DD MIX1", "DD1 MIX" },
  2820. { "Stereo2 ADC1 Mux", "ADC1/2", "ADC 1_2" },
  2821. { "Stereo2 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
  2822. { "Stereo2 ADC2 Mux", "DD MIX1", "DD1 MIX" },
  2823. { "Stereo2 ADC2 Mux", "DMIC", "Stereo2 DMIC Mux" },
  2824. { "Stereo2 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
  2825. { "Stereo3 ADC1 Mux", "DD MIX1", "DD1 MIX" },
  2826. { "Stereo3 ADC1 Mux", "ADC1/2", "ADC 1_2" },
  2827. { "Stereo3 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
  2828. { "Stereo3 ADC2 Mux", "DD MIX1", "DD1 MIX" },
  2829. { "Stereo3 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" },
  2830. { "Stereo3 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" },
  2831. { "Stereo4 ADC1 Mux", "DD MIX1", "DD1 MIX" },
  2832. { "Stereo4 ADC1 Mux", "ADC1/2", "ADC 1_2" },
  2833. { "Stereo4 ADC1 Mux", "DD MIX2", "DD2 MIX" },
  2834. { "Stereo4 ADC2 Mux", "DD MIX1", "DD1 MIX" },
  2835. { "Stereo4 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" },
  2836. { "Stereo4 ADC2 Mux", "DD MIX2", "DD2 MIX" },
  2837. { "Mono ADC2 L Mux", "DD MIX1L", "DD1 MIXL" },
  2838. { "Mono ADC2 L Mux", "DMIC", "Mono DMIC L Mux" },
  2839. { "Mono ADC2 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
  2840. { "Mono ADC1 L Mux", "DD MIX1L", "DD1 MIXL" },
  2841. { "Mono ADC1 L Mux", "ADC1", "ADC 1" },
  2842. { "Mono ADC1 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
  2843. { "Mono ADC1 R Mux", "DD MIX1R", "DD1 MIXR" },
  2844. { "Mono ADC1 R Mux", "ADC2", "ADC 2" },
  2845. { "Mono ADC1 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
  2846. { "Mono ADC2 R Mux", "DD MIX1R", "DD1 MIXR" },
  2847. { "Mono ADC2 R Mux", "DMIC", "Mono DMIC R Mux" },
  2848. { "Mono ADC2 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
  2849. { "Sto1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC1 Mux" },
  2850. { "Sto1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC2 Mux" },
  2851. { "Sto1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC1 Mux" },
  2852. { "Sto1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC2 Mux" },
  2853. { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" },
  2854. { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" },
  2855. { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" },
  2856. { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" },
  2857. { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
  2858. { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXL" },
  2859. { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR" },
  2860. { "Sto2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC1 Mux" },
  2861. { "Sto2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC2 Mux" },
  2862. { "Sto2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC1 Mux" },
  2863. { "Sto2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC2 Mux" },
  2864. { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXL" },
  2865. { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXR" },
  2866. { "Stereo2 ADC LR Mux", "L", "Sto2 ADC MIXL" },
  2867. { "Stereo2 ADC LR Mux", "LR", "Sto2 ADC LR MIX" },
  2868. { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" },
  2869. { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" },
  2870. { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" },
  2871. { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" },
  2872. { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll },
  2873. { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXL" },
  2874. { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXR" },
  2875. { "Sto3 ADC MIXL", "ADC1 Switch", "Stereo3 ADC1 Mux" },
  2876. { "Sto3 ADC MIXL", "ADC2 Switch", "Stereo3 ADC2 Mux" },
  2877. { "Sto3 ADC MIXR", "ADC1 Switch", "Stereo3 ADC1 Mux" },
  2878. { "Sto3 ADC MIXR", "ADC2 Switch", "Stereo3 ADC2 Mux" },
  2879. { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" },
  2880. { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" },
  2881. { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" },
  2882. { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" },
  2883. { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll },
  2884. { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXL" },
  2885. { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXR" },
  2886. { "Sto4 ADC MIXL", "ADC1 Switch", "Stereo4 ADC1 Mux" },
  2887. { "Sto4 ADC MIXL", "ADC2 Switch", "Stereo4 ADC2 Mux" },
  2888. { "Sto4 ADC MIXR", "ADC1 Switch", "Stereo4 ADC1 Mux" },
  2889. { "Sto4 ADC MIXR", "ADC2 Switch", "Stereo4 ADC2 Mux" },
  2890. { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" },
  2891. { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" },
  2892. { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" },
  2893. { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" },
  2894. { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll },
  2895. { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXL" },
  2896. { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXR" },
  2897. { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC1 L Mux" },
  2898. { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC2 L Mux" },
  2899. { "Mono ADC MIXL", NULL, "adc mono left filter" },
  2900. { "adc mono left filter", NULL, "PLL1", is_sys_clk_from_pll },
  2901. { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC1 R Mux" },
  2902. { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC2 R Mux" },
  2903. { "Mono ADC MIXR", NULL, "adc mono right filter" },
  2904. { "adc mono right filter", NULL, "PLL1", is_sys_clk_from_pll },
  2905. { "Mono ADC MIX", NULL, "Mono ADC MIXL" },
  2906. { "Mono ADC MIX", NULL, "Mono ADC MIXR" },
  2907. { "VAD ADC Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
  2908. { "VAD ADC Mux", "MONO ADC MIX L", "Mono ADC MIXL" },
  2909. { "VAD ADC Mux", "MONO ADC MIX R", "Mono ADC MIXR" },
  2910. { "VAD ADC Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
  2911. { "VAD ADC Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
  2912. { "IF1 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
  2913. { "IF1 ADC1 Mux", "OB01", "OB01 Bypass Mux" },
  2914. { "IF1 ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
  2915. { "IF1 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
  2916. { "IF1 ADC2 Mux", "OB23", "OB23 Bypass Mux" },
  2917. { "IF1 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
  2918. { "IF1 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
  2919. { "IF1 ADC3 Mux", "OB45", "OB45" },
  2920. { "IF1 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
  2921. { "IF1 ADC4 Mux", "OB67", "OB67" },
  2922. { "IF1 ADC4 Mux", "OB01", "OB01 Bypass Mux" },
  2923. { "IF1 ADC1 Swap Mux", "L/R", "IF1 ADC1 Mux" },
  2924. { "IF1 ADC1 Swap Mux", "R/L", "IF1 ADC1 Mux" },
  2925. { "IF1 ADC1 Swap Mux", "L/L", "IF1 ADC1 Mux" },
  2926. { "IF1 ADC1 Swap Mux", "R/R", "IF1 ADC1 Mux" },
  2927. { "IF1 ADC2 Swap Mux", "L/R", "IF1 ADC2 Mux" },
  2928. { "IF1 ADC2 Swap Mux", "R/L", "IF1 ADC2 Mux" },
  2929. { "IF1 ADC2 Swap Mux", "L/L", "IF1 ADC2 Mux" },
  2930. { "IF1 ADC2 Swap Mux", "R/R", "IF1 ADC2 Mux" },
  2931. { "IF1 ADC3 Swap Mux", "L/R", "IF1 ADC3 Mux" },
  2932. { "IF1 ADC3 Swap Mux", "R/L", "IF1 ADC3 Mux" },
  2933. { "IF1 ADC3 Swap Mux", "L/L", "IF1 ADC3 Mux" },
  2934. { "IF1 ADC3 Swap Mux", "R/R", "IF1 ADC3 Mux" },
  2935. { "IF1 ADC4 Swap Mux", "L/R", "IF1 ADC4 Mux" },
  2936. { "IF1 ADC4 Swap Mux", "R/L", "IF1 ADC4 Mux" },
  2937. { "IF1 ADC4 Swap Mux", "L/L", "IF1 ADC4 Mux" },
  2938. { "IF1 ADC4 Swap Mux", "R/R", "IF1 ADC4 Mux" },
  2939. { "IF1 ADC", NULL, "IF1 ADC1 Swap Mux" },
  2940. { "IF1 ADC", NULL, "IF1 ADC2 Swap Mux" },
  2941. { "IF1 ADC", NULL, "IF1 ADC3 Swap Mux" },
  2942. { "IF1 ADC", NULL, "IF1 ADC4 Swap Mux" },
  2943. { "IF1 ADC TDM Swap Mux", "1/2/3/4", "IF1 ADC" },
  2944. { "IF1 ADC TDM Swap Mux", "2/1/3/4", "IF1 ADC" },
  2945. { "IF1 ADC TDM Swap Mux", "2/3/1/4", "IF1 ADC" },
  2946. { "IF1 ADC TDM Swap Mux", "4/1/2/3", "IF1 ADC" },
  2947. { "IF1 ADC TDM Swap Mux", "1/3/2/4", "IF1 ADC" },
  2948. { "IF1 ADC TDM Swap Mux", "1/4/2/3", "IF1 ADC" },
  2949. { "IF1 ADC TDM Swap Mux", "3/1/2/4", "IF1 ADC" },
  2950. { "IF1 ADC TDM Swap Mux", "3/4/1/2", "IF1 ADC" },
  2951. { "AIF1TX", NULL, "I2S1" },
  2952. { "AIF1TX", NULL, "IF1 ADC TDM Swap Mux" },
  2953. { "IF2 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
  2954. { "IF2 ADC1 Mux", "OB01", "OB01 Bypass Mux" },
  2955. { "IF2 ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
  2956. { "IF2 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
  2957. { "IF2 ADC2 Mux", "OB23", "OB23 Bypass Mux" },
  2958. { "IF2 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
  2959. { "IF2 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
  2960. { "IF2 ADC3 Mux", "OB45", "OB45" },
  2961. { "IF2 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
  2962. { "IF2 ADC4 Mux", "OB67", "OB67" },
  2963. { "IF2 ADC4 Mux", "OB01", "OB01 Bypass Mux" },
  2964. { "IF2 ADC1 Swap Mux", "L/R", "IF2 ADC1 Mux" },
  2965. { "IF2 ADC1 Swap Mux", "R/L", "IF2 ADC1 Mux" },
  2966. { "IF2 ADC1 Swap Mux", "L/L", "IF2 ADC1 Mux" },
  2967. { "IF2 ADC1 Swap Mux", "R/R", "IF2 ADC1 Mux" },
  2968. { "IF2 ADC2 Swap Mux", "L/R", "IF2 ADC2 Mux" },
  2969. { "IF2 ADC2 Swap Mux", "R/L", "IF2 ADC2 Mux" },
  2970. { "IF2 ADC2 Swap Mux", "L/L", "IF2 ADC2 Mux" },
  2971. { "IF2 ADC2 Swap Mux", "R/R", "IF2 ADC2 Mux" },
  2972. { "IF2 ADC3 Swap Mux", "L/R", "IF2 ADC3 Mux" },
  2973. { "IF2 ADC3 Swap Mux", "R/L", "IF2 ADC3 Mux" },
  2974. { "IF2 ADC3 Swap Mux", "L/L", "IF2 ADC3 Mux" },
  2975. { "IF2 ADC3 Swap Mux", "R/R", "IF2 ADC3 Mux" },
  2976. { "IF2 ADC4 Swap Mux", "L/R", "IF2 ADC4 Mux" },
  2977. { "IF2 ADC4 Swap Mux", "R/L", "IF2 ADC4 Mux" },
  2978. { "IF2 ADC4 Swap Mux", "L/L", "IF2 ADC4 Mux" },
  2979. { "IF2 ADC4 Swap Mux", "R/R", "IF2 ADC4 Mux" },
  2980. { "IF2 ADC", NULL, "IF2 ADC1 Swap Mux" },
  2981. { "IF2 ADC", NULL, "IF2 ADC2 Swap Mux" },
  2982. { "IF2 ADC", NULL, "IF2 ADC3 Swap Mux" },
  2983. { "IF2 ADC", NULL, "IF2 ADC4 Swap Mux" },
  2984. { "IF2 ADC TDM Swap Mux", "1/2/3/4", "IF2 ADC" },
  2985. { "IF2 ADC TDM Swap Mux", "2/1/3/4", "IF2 ADC" },
  2986. { "IF2 ADC TDM Swap Mux", "3/1/2/4", "IF2 ADC" },
  2987. { "IF2 ADC TDM Swap Mux", "4/1/2/3", "IF2 ADC" },
  2988. { "IF2 ADC TDM Swap Mux", "1/3/2/4", "IF2 ADC" },
  2989. { "IF2 ADC TDM Swap Mux", "1/4/2/3", "IF2 ADC" },
  2990. { "IF2 ADC TDM Swap Mux", "2/3/1/4", "IF2 ADC" },
  2991. { "IF2 ADC TDM Swap Mux", "3/4/1/2", "IF2 ADC" },
  2992. { "AIF2TX", NULL, "I2S2" },
  2993. { "AIF2TX", NULL, "IF2 ADC TDM Swap Mux" },
  2994. { "IF3 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
  2995. { "IF3 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
  2996. { "IF3 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
  2997. { "IF3 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
  2998. { "IF3 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" },
  2999. { "IF3 ADC Mux", "OB01", "OB01 Bypass Mux" },
  3000. { "IF3 ADC Mux", "OB23", "OB23 Bypass Mux" },
  3001. { "IF3 ADC Mux", "VAD ADC", "VAD ADC Mux" },
  3002. { "AIF3TX", NULL, "I2S3" },
  3003. { "AIF3TX", NULL, "IF3 ADC Mux" },
  3004. { "IF4 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
  3005. { "IF4 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
  3006. { "IF4 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
  3007. { "IF4 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
  3008. { "IF4 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" },
  3009. { "IF4 ADC Mux", "OB01", "OB01 Bypass Mux" },
  3010. { "IF4 ADC Mux", "OB23", "OB23 Bypass Mux" },
  3011. { "IF4 ADC Mux", "VAD ADC", "VAD ADC Mux" },
  3012. { "AIF4TX", NULL, "I2S4" },
  3013. { "AIF4TX", NULL, "IF4 ADC Mux" },
  3014. { "SLB ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
  3015. { "SLB ADC1 Mux", "OB01", "OB01 Bypass Mux" },
  3016. { "SLB ADC1 Mux", "VAD ADC", "VAD ADC Mux" },
  3017. { "SLB ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
  3018. { "SLB ADC2 Mux", "OB23", "OB23 Bypass Mux" },
  3019. { "SLB ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
  3020. { "SLB ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" },
  3021. { "SLB ADC3 Mux", "OB45", "OB45" },
  3022. { "SLB ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" },
  3023. { "SLB ADC4 Mux", "OB67", "OB67" },
  3024. { "SLB ADC4 Mux", "OB01", "OB01 Bypass Mux" },
  3025. { "SLBTX", NULL, "SLB" },
  3026. { "SLBTX", NULL, "SLB ADC1 Mux" },
  3027. { "SLBTX", NULL, "SLB ADC2 Mux" },
  3028. { "SLBTX", NULL, "SLB ADC3 Mux" },
  3029. { "SLBTX", NULL, "SLB ADC4 Mux" },
  3030. { "IB01 Mux", "IF1 DAC 01", "IF1 DAC01" },
  3031. { "IB01 Mux", "IF2 DAC 01", "IF2 DAC01" },
  3032. { "IB01 Mux", "SLB DAC 01", "SLB DAC01" },
  3033. { "IB01 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
  3034. { "IB01 Mux", "VAD ADC/DAC1 FS", "DAC1 FS" },
  3035. { "IB01 Bypass Mux", "Bypass", "IB01 Mux" },
  3036. { "IB01 Bypass Mux", "Pass SRC", "IB01 Mux" },
  3037. { "IB23 Mux", "IF1 DAC 23", "IF1 DAC23" },
  3038. { "IB23 Mux", "IF2 DAC 23", "IF2 DAC23" },
  3039. { "IB23 Mux", "SLB DAC 23", "SLB DAC23" },
  3040. { "IB23 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
  3041. { "IB23 Mux", "DAC1 FS", "DAC1 FS" },
  3042. { "IB23 Mux", "IF4 DAC", "IF4 DAC" },
  3043. { "IB23 Bypass Mux", "Bypass", "IB23 Mux" },
  3044. { "IB23 Bypass Mux", "Pass SRC", "IB23 Mux" },
  3045. { "IB45 Mux", "IF1 DAC 45", "IF1 DAC45" },
  3046. { "IB45 Mux", "IF2 DAC 45", "IF2 DAC45" },
  3047. { "IB45 Mux", "SLB DAC 45", "SLB DAC45" },
  3048. { "IB45 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" },
  3049. { "IB45 Mux", "IF3 DAC", "IF3 DAC" },
  3050. { "IB45 Bypass Mux", "Bypass", "IB45 Mux" },
  3051. { "IB45 Bypass Mux", "Pass SRC", "IB45 Mux" },
  3052. { "IB6 Mux", "IF1 DAC 6", "IF1 DAC6 Mux" },
  3053. { "IB6 Mux", "IF2 DAC 6", "IF2 DAC6 Mux" },
  3054. { "IB6 Mux", "SLB DAC 6", "SLB DAC6" },
  3055. { "IB6 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" },
  3056. { "IB6 Mux", "IF4 DAC L", "IF4 DAC L" },
  3057. { "IB6 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
  3058. { "IB6 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
  3059. { "IB6 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
  3060. { "IB7 Mux", "IF1 DAC 7", "IF1 DAC7 Mux" },
  3061. { "IB7 Mux", "IF2 DAC 7", "IF2 DAC7 Mux" },
  3062. { "IB7 Mux", "SLB DAC 7", "SLB DAC7" },
  3063. { "IB7 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" },
  3064. { "IB7 Mux", "IF4 DAC R", "IF4 DAC R" },
  3065. { "IB7 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" },
  3066. { "IB7 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" },
  3067. { "IB7 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" },
  3068. { "IB8 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" },
  3069. { "IB8 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
  3070. { "IB8 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
  3071. { "IB8 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" },
  3072. { "IB8 Mux", "MONO ADC MIX L", "Mono ADC MIXL" },
  3073. { "IB8 Mux", "DACL1 FS", "DAC1 MIXL" },
  3074. { "IB9 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" },
  3075. { "IB9 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" },
  3076. { "IB9 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" },
  3077. { "IB9 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" },
  3078. { "IB9 Mux", "MONO ADC MIX R", "Mono ADC MIXR" },
  3079. { "IB9 Mux", "DACR1 FS", "DAC1 MIXR" },
  3080. { "IB9 Mux", "DAC1 FS", "DAC1 FS" },
  3081. { "OB01 MIX", "IB01 Switch", "IB01 Bypass Mux" },
  3082. { "OB01 MIX", "IB23 Switch", "IB23 Bypass Mux" },
  3083. { "OB01 MIX", "IB45 Switch", "IB45 Bypass Mux" },
  3084. { "OB01 MIX", "IB6 Switch", "IB6 Mux" },
  3085. { "OB01 MIX", "IB7 Switch", "IB7 Mux" },
  3086. { "OB01 MIX", "IB8 Switch", "IB8 Mux" },
  3087. { "OB01 MIX", "IB9 Switch", "IB9 Mux" },
  3088. { "OB23 MIX", "IB01 Switch", "IB01 Bypass Mux" },
  3089. { "OB23 MIX", "IB23 Switch", "IB23 Bypass Mux" },
  3090. { "OB23 MIX", "IB45 Switch", "IB45 Bypass Mux" },
  3091. { "OB23 MIX", "IB6 Switch", "IB6 Mux" },
  3092. { "OB23 MIX", "IB7 Switch", "IB7 Mux" },
  3093. { "OB23 MIX", "IB8 Switch", "IB8 Mux" },
  3094. { "OB23 MIX", "IB9 Switch", "IB9 Mux" },
  3095. { "OB4 MIX", "IB01 Switch", "IB01 Bypass Mux" },
  3096. { "OB4 MIX", "IB23 Switch", "IB23 Bypass Mux" },
  3097. { "OB4 MIX", "IB45 Switch", "IB45 Bypass Mux" },
  3098. { "OB4 MIX", "IB6 Switch", "IB6 Mux" },
  3099. { "OB4 MIX", "IB7 Switch", "IB7 Mux" },
  3100. { "OB4 MIX", "IB8 Switch", "IB8 Mux" },
  3101. { "OB4 MIX", "IB9 Switch", "IB9 Mux" },
  3102. { "OB5 MIX", "IB01 Switch", "IB01 Bypass Mux" },
  3103. { "OB5 MIX", "IB23 Switch", "IB23 Bypass Mux" },
  3104. { "OB5 MIX", "IB45 Switch", "IB45 Bypass Mux" },
  3105. { "OB5 MIX", "IB6 Switch", "IB6 Mux" },
  3106. { "OB5 MIX", "IB7 Switch", "IB7 Mux" },
  3107. { "OB5 MIX", "IB8 Switch", "IB8 Mux" },
  3108. { "OB5 MIX", "IB9 Switch", "IB9 Mux" },
  3109. { "OB6 MIX", "IB01 Switch", "IB01 Bypass Mux" },
  3110. { "OB6 MIX", "IB23 Switch", "IB23 Bypass Mux" },
  3111. { "OB6 MIX", "IB45 Switch", "IB45 Bypass Mux" },
  3112. { "OB6 MIX", "IB6 Switch", "IB6 Mux" },
  3113. { "OB6 MIX", "IB7 Switch", "IB7 Mux" },
  3114. { "OB6 MIX", "IB8 Switch", "IB8 Mux" },
  3115. { "OB6 MIX", "IB9 Switch", "IB9 Mux" },
  3116. { "OB7 MIX", "IB01 Switch", "IB01 Bypass Mux" },
  3117. { "OB7 MIX", "IB23 Switch", "IB23 Bypass Mux" },
  3118. { "OB7 MIX", "IB45 Switch", "IB45 Bypass Mux" },
  3119. { "OB7 MIX", "IB6 Switch", "IB6 Mux" },
  3120. { "OB7 MIX", "IB7 Switch", "IB7 Mux" },
  3121. { "OB7 MIX", "IB8 Switch", "IB8 Mux" },
  3122. { "OB7 MIX", "IB9 Switch", "IB9 Mux" },
  3123. { "OB01 Bypass Mux", "Bypass", "OB01 MIX" },
  3124. { "OB01 Bypass Mux", "Pass SRC", "OB01 MIX" },
  3125. { "OB23 Bypass Mux", "Bypass", "OB23 MIX" },
  3126. { "OB23 Bypass Mux", "Pass SRC", "OB23 MIX" },
  3127. { "OutBound2", NULL, "OB23 Bypass Mux" },
  3128. { "OutBound3", NULL, "OB23 Bypass Mux" },
  3129. { "OutBound4", NULL, "OB4 MIX" },
  3130. { "OutBound5", NULL, "OB5 MIX" },
  3131. { "OutBound6", NULL, "OB6 MIX" },
  3132. { "OutBound7", NULL, "OB7 MIX" },
  3133. { "OB45", NULL, "OutBound4" },
  3134. { "OB45", NULL, "OutBound5" },
  3135. { "OB67", NULL, "OutBound6" },
  3136. { "OB67", NULL, "OutBound7" },
  3137. { "IF1 DAC0", NULL, "AIF1RX" },
  3138. { "IF1 DAC1", NULL, "AIF1RX" },
  3139. { "IF1 DAC2", NULL, "AIF1RX" },
  3140. { "IF1 DAC3", NULL, "AIF1RX" },
  3141. { "IF1 DAC4", NULL, "AIF1RX" },
  3142. { "IF1 DAC5", NULL, "AIF1RX" },
  3143. { "IF1 DAC6", NULL, "AIF1RX" },
  3144. { "IF1 DAC7", NULL, "AIF1RX" },
  3145. { "IF1 DAC0", NULL, "I2S1" },
  3146. { "IF1 DAC1", NULL, "I2S1" },
  3147. { "IF1 DAC2", NULL, "I2S1" },
  3148. { "IF1 DAC3", NULL, "I2S1" },
  3149. { "IF1 DAC4", NULL, "I2S1" },
  3150. { "IF1 DAC5", NULL, "I2S1" },
  3151. { "IF1 DAC6", NULL, "I2S1" },
  3152. { "IF1 DAC7", NULL, "I2S1" },
  3153. { "IF1 DAC0 Mux", "Slot0", "IF1 DAC0" },
  3154. { "IF1 DAC0 Mux", "Slot1", "IF1 DAC1" },
  3155. { "IF1 DAC0 Mux", "Slot2", "IF1 DAC2" },
  3156. { "IF1 DAC0 Mux", "Slot3", "IF1 DAC3" },
  3157. { "IF1 DAC0 Mux", "Slot4", "IF1 DAC4" },
  3158. { "IF1 DAC0 Mux", "Slot5", "IF1 DAC5" },
  3159. { "IF1 DAC0 Mux", "Slot6", "IF1 DAC6" },
  3160. { "IF1 DAC0 Mux", "Slot7", "IF1 DAC7" },
  3161. { "IF1 DAC1 Mux", "Slot0", "IF1 DAC0" },
  3162. { "IF1 DAC1 Mux", "Slot1", "IF1 DAC1" },
  3163. { "IF1 DAC1 Mux", "Slot2", "IF1 DAC2" },
  3164. { "IF1 DAC1 Mux", "Slot3", "IF1 DAC3" },
  3165. { "IF1 DAC1 Mux", "Slot4", "IF1 DAC4" },
  3166. { "IF1 DAC1 Mux", "Slot5", "IF1 DAC5" },
  3167. { "IF1 DAC1 Mux", "Slot6", "IF1 DAC6" },
  3168. { "IF1 DAC1 Mux", "Slot7", "IF1 DAC7" },
  3169. { "IF1 DAC2 Mux", "Slot0", "IF1 DAC0" },
  3170. { "IF1 DAC2 Mux", "Slot1", "IF1 DAC1" },
  3171. { "IF1 DAC2 Mux", "Slot2", "IF1 DAC2" },
  3172. { "IF1 DAC2 Mux", "Slot3", "IF1 DAC3" },
  3173. { "IF1 DAC2 Mux", "Slot4", "IF1 DAC4" },
  3174. { "IF1 DAC2 Mux", "Slot5", "IF1 DAC5" },
  3175. { "IF1 DAC2 Mux", "Slot6", "IF1 DAC6" },
  3176. { "IF1 DAC2 Mux", "Slot7", "IF1 DAC7" },
  3177. { "IF1 DAC3 Mux", "Slot0", "IF1 DAC0" },
  3178. { "IF1 DAC3 Mux", "Slot1", "IF1 DAC1" },
  3179. { "IF1 DAC3 Mux", "Slot2", "IF1 DAC2" },
  3180. { "IF1 DAC3 Mux", "Slot3", "IF1 DAC3" },
  3181. { "IF1 DAC3 Mux", "Slot4", "IF1 DAC4" },
  3182. { "IF1 DAC3 Mux", "Slot5", "IF1 DAC5" },
  3183. { "IF1 DAC3 Mux", "Slot6", "IF1 DAC6" },
  3184. { "IF1 DAC3 Mux", "Slot7", "IF1 DAC7" },
  3185. { "IF1 DAC4 Mux", "Slot0", "IF1 DAC0" },
  3186. { "IF1 DAC4 Mux", "Slot1", "IF1 DAC1" },
  3187. { "IF1 DAC4 Mux", "Slot2", "IF1 DAC2" },
  3188. { "IF1 DAC4 Mux", "Slot3", "IF1 DAC3" },
  3189. { "IF1 DAC4 Mux", "Slot4", "IF1 DAC4" },
  3190. { "IF1 DAC4 Mux", "Slot5", "IF1 DAC5" },
  3191. { "IF1 DAC4 Mux", "Slot6", "IF1 DAC6" },
  3192. { "IF1 DAC4 Mux", "Slot7", "IF1 DAC7" },
  3193. { "IF1 DAC5 Mux", "Slot0", "IF1 DAC0" },
  3194. { "IF1 DAC5 Mux", "Slot1", "IF1 DAC1" },
  3195. { "IF1 DAC5 Mux", "Slot2", "IF1 DAC2" },
  3196. { "IF1 DAC5 Mux", "Slot3", "IF1 DAC3" },
  3197. { "IF1 DAC5 Mux", "Slot4", "IF1 DAC4" },
  3198. { "IF1 DAC5 Mux", "Slot5", "IF1 DAC5" },
  3199. { "IF1 DAC5 Mux", "Slot6", "IF1 DAC6" },
  3200. { "IF1 DAC5 Mux", "Slot7", "IF1 DAC7" },
  3201. { "IF1 DAC6 Mux", "Slot0", "IF1 DAC0" },
  3202. { "IF1 DAC6 Mux", "Slot1", "IF1 DAC1" },
  3203. { "IF1 DAC6 Mux", "Slot2", "IF1 DAC2" },
  3204. { "IF1 DAC6 Mux", "Slot3", "IF1 DAC3" },
  3205. { "IF1 DAC6 Mux", "Slot4", "IF1 DAC4" },
  3206. { "IF1 DAC6 Mux", "Slot5", "IF1 DAC5" },
  3207. { "IF1 DAC6 Mux", "Slot6", "IF1 DAC6" },
  3208. { "IF1 DAC6 Mux", "Slot7", "IF1 DAC7" },
  3209. { "IF1 DAC7 Mux", "Slot0", "IF1 DAC0" },
  3210. { "IF1 DAC7 Mux", "Slot1", "IF1 DAC1" },
  3211. { "IF1 DAC7 Mux", "Slot2", "IF1 DAC2" },
  3212. { "IF1 DAC7 Mux", "Slot3", "IF1 DAC3" },
  3213. { "IF1 DAC7 Mux", "Slot4", "IF1 DAC4" },
  3214. { "IF1 DAC7 Mux", "Slot5", "IF1 DAC5" },
  3215. { "IF1 DAC7 Mux", "Slot6", "IF1 DAC6" },
  3216. { "IF1 DAC7 Mux", "Slot7", "IF1 DAC7" },
  3217. { "IF1 DAC01", NULL, "IF1 DAC0 Mux" },
  3218. { "IF1 DAC01", NULL, "IF1 DAC1 Mux" },
  3219. { "IF1 DAC23", NULL, "IF1 DAC2 Mux" },
  3220. { "IF1 DAC23", NULL, "IF1 DAC3 Mux" },
  3221. { "IF1 DAC45", NULL, "IF1 DAC4 Mux" },
  3222. { "IF1 DAC45", NULL, "IF1 DAC5 Mux" },
  3223. { "IF1 DAC67", NULL, "IF1 DAC6 Mux" },
  3224. { "IF1 DAC67", NULL, "IF1 DAC7 Mux" },
  3225. { "IF2 DAC0", NULL, "AIF2RX" },
  3226. { "IF2 DAC1", NULL, "AIF2RX" },
  3227. { "IF2 DAC2", NULL, "AIF2RX" },
  3228. { "IF2 DAC3", NULL, "AIF2RX" },
  3229. { "IF2 DAC4", NULL, "AIF2RX" },
  3230. { "IF2 DAC5", NULL, "AIF2RX" },
  3231. { "IF2 DAC6", NULL, "AIF2RX" },
  3232. { "IF2 DAC7", NULL, "AIF2RX" },
  3233. { "IF2 DAC0", NULL, "I2S2" },
  3234. { "IF2 DAC1", NULL, "I2S2" },
  3235. { "IF2 DAC2", NULL, "I2S2" },
  3236. { "IF2 DAC3", NULL, "I2S2" },
  3237. { "IF2 DAC4", NULL, "I2S2" },
  3238. { "IF2 DAC5", NULL, "I2S2" },
  3239. { "IF2 DAC6", NULL, "I2S2" },
  3240. { "IF2 DAC7", NULL, "I2S2" },
  3241. { "IF2 DAC0 Mux", "Slot0", "IF2 DAC0" },
  3242. { "IF2 DAC0 Mux", "Slot1", "IF2 DAC1" },
  3243. { "IF2 DAC0 Mux", "Slot2", "IF2 DAC2" },
  3244. { "IF2 DAC0 Mux", "Slot3", "IF2 DAC3" },
  3245. { "IF2 DAC0 Mux", "Slot4", "IF2 DAC4" },
  3246. { "IF2 DAC0 Mux", "Slot5", "IF2 DAC5" },
  3247. { "IF2 DAC0 Mux", "Slot6", "IF2 DAC6" },
  3248. { "IF2 DAC0 Mux", "Slot7", "IF2 DAC7" },
  3249. { "IF2 DAC1 Mux", "Slot0", "IF2 DAC0" },
  3250. { "IF2 DAC1 Mux", "Slot1", "IF2 DAC1" },
  3251. { "IF2 DAC1 Mux", "Slot2", "IF2 DAC2" },
  3252. { "IF2 DAC1 Mux", "Slot3", "IF2 DAC3" },
  3253. { "IF2 DAC1 Mux", "Slot4", "IF2 DAC4" },
  3254. { "IF2 DAC1 Mux", "Slot5", "IF2 DAC5" },
  3255. { "IF2 DAC1 Mux", "Slot6", "IF2 DAC6" },
  3256. { "IF2 DAC1 Mux", "Slot7", "IF2 DAC7" },
  3257. { "IF2 DAC2 Mux", "Slot0", "IF2 DAC0" },
  3258. { "IF2 DAC2 Mux", "Slot1", "IF2 DAC1" },
  3259. { "IF2 DAC2 Mux", "Slot2", "IF2 DAC2" },
  3260. { "IF2 DAC2 Mux", "Slot3", "IF2 DAC3" },
  3261. { "IF2 DAC2 Mux", "Slot4", "IF2 DAC4" },
  3262. { "IF2 DAC2 Mux", "Slot5", "IF2 DAC5" },
  3263. { "IF2 DAC2 Mux", "Slot6", "IF2 DAC6" },
  3264. { "IF2 DAC2 Mux", "Slot7", "IF2 DAC7" },
  3265. { "IF2 DAC3 Mux", "Slot0", "IF2 DAC0" },
  3266. { "IF2 DAC3 Mux", "Slot1", "IF2 DAC1" },
  3267. { "IF2 DAC3 Mux", "Slot2", "IF2 DAC2" },
  3268. { "IF2 DAC3 Mux", "Slot3", "IF2 DAC3" },
  3269. { "IF2 DAC3 Mux", "Slot4", "IF2 DAC4" },
  3270. { "IF2 DAC3 Mux", "Slot5", "IF2 DAC5" },
  3271. { "IF2 DAC3 Mux", "Slot6", "IF2 DAC6" },
  3272. { "IF2 DAC3 Mux", "Slot7", "IF2 DAC7" },
  3273. { "IF2 DAC4 Mux", "Slot0", "IF2 DAC0" },
  3274. { "IF2 DAC4 Mux", "Slot1", "IF2 DAC1" },
  3275. { "IF2 DAC4 Mux", "Slot2", "IF2 DAC2" },
  3276. { "IF2 DAC4 Mux", "Slot3", "IF2 DAC3" },
  3277. { "IF2 DAC4 Mux", "Slot4", "IF2 DAC4" },
  3278. { "IF2 DAC4 Mux", "Slot5", "IF2 DAC5" },
  3279. { "IF2 DAC4 Mux", "Slot6", "IF2 DAC6" },
  3280. { "IF2 DAC4 Mux", "Slot7", "IF2 DAC7" },
  3281. { "IF2 DAC5 Mux", "Slot0", "IF2 DAC0" },
  3282. { "IF2 DAC5 Mux", "Slot1", "IF2 DAC1" },
  3283. { "IF2 DAC5 Mux", "Slot2", "IF2 DAC2" },
  3284. { "IF2 DAC5 Mux", "Slot3", "IF2 DAC3" },
  3285. { "IF2 DAC5 Mux", "Slot4", "IF2 DAC4" },
  3286. { "IF2 DAC5 Mux", "Slot5", "IF2 DAC5" },
  3287. { "IF2 DAC5 Mux", "Slot6", "IF2 DAC6" },
  3288. { "IF2 DAC5 Mux", "Slot7", "IF2 DAC7" },
  3289. { "IF2 DAC6 Mux", "Slot0", "IF2 DAC0" },
  3290. { "IF2 DAC6 Mux", "Slot1", "IF2 DAC1" },
  3291. { "IF2 DAC6 Mux", "Slot2", "IF2 DAC2" },
  3292. { "IF2 DAC6 Mux", "Slot3", "IF2 DAC3" },
  3293. { "IF2 DAC6 Mux", "Slot4", "IF2 DAC4" },
  3294. { "IF2 DAC6 Mux", "Slot5", "IF2 DAC5" },
  3295. { "IF2 DAC6 Mux", "Slot6", "IF2 DAC6" },
  3296. { "IF2 DAC6 Mux", "Slot7", "IF2 DAC7" },
  3297. { "IF2 DAC7 Mux", "Slot0", "IF2 DAC0" },
  3298. { "IF2 DAC7 Mux", "Slot1", "IF2 DAC1" },
  3299. { "IF2 DAC7 Mux", "Slot2", "IF2 DAC2" },
  3300. { "IF2 DAC7 Mux", "Slot3", "IF2 DAC3" },
  3301. { "IF2 DAC7 Mux", "Slot4", "IF2 DAC4" },
  3302. { "IF2 DAC7 Mux", "Slot5", "IF2 DAC5" },
  3303. { "IF2 DAC7 Mux", "Slot6", "IF2 DAC6" },
  3304. { "IF2 DAC7 Mux", "Slot7", "IF2 DAC7" },
  3305. { "IF2 DAC01", NULL, "IF2 DAC0 Mux" },
  3306. { "IF2 DAC01", NULL, "IF2 DAC1 Mux" },
  3307. { "IF2 DAC23", NULL, "IF2 DAC2 Mux" },
  3308. { "IF2 DAC23", NULL, "IF2 DAC3 Mux" },
  3309. { "IF2 DAC45", NULL, "IF2 DAC4 Mux" },
  3310. { "IF2 DAC45", NULL, "IF2 DAC5 Mux" },
  3311. { "IF2 DAC67", NULL, "IF2 DAC6 Mux" },
  3312. { "IF2 DAC67", NULL, "IF2 DAC7 Mux" },
  3313. { "IF3 DAC", NULL, "AIF3RX" },
  3314. { "IF3 DAC", NULL, "I2S3" },
  3315. { "IF4 DAC", NULL, "AIF4RX" },
  3316. { "IF4 DAC", NULL, "I2S4" },
  3317. { "IF3 DAC L", NULL, "IF3 DAC" },
  3318. { "IF3 DAC R", NULL, "IF3 DAC" },
  3319. { "IF4 DAC L", NULL, "IF4 DAC" },
  3320. { "IF4 DAC R", NULL, "IF4 DAC" },
  3321. { "SLB DAC0", NULL, "SLBRX" },
  3322. { "SLB DAC1", NULL, "SLBRX" },
  3323. { "SLB DAC2", NULL, "SLBRX" },
  3324. { "SLB DAC3", NULL, "SLBRX" },
  3325. { "SLB DAC4", NULL, "SLBRX" },
  3326. { "SLB DAC5", NULL, "SLBRX" },
  3327. { "SLB DAC6", NULL, "SLBRX" },
  3328. { "SLB DAC7", NULL, "SLBRX" },
  3329. { "SLB DAC0", NULL, "SLB" },
  3330. { "SLB DAC1", NULL, "SLB" },
  3331. { "SLB DAC2", NULL, "SLB" },
  3332. { "SLB DAC3", NULL, "SLB" },
  3333. { "SLB DAC4", NULL, "SLB" },
  3334. { "SLB DAC5", NULL, "SLB" },
  3335. { "SLB DAC6", NULL, "SLB" },
  3336. { "SLB DAC7", NULL, "SLB" },
  3337. { "SLB DAC01", NULL, "SLB DAC0" },
  3338. { "SLB DAC01", NULL, "SLB DAC1" },
  3339. { "SLB DAC23", NULL, "SLB DAC2" },
  3340. { "SLB DAC23", NULL, "SLB DAC3" },
  3341. { "SLB DAC45", NULL, "SLB DAC4" },
  3342. { "SLB DAC45", NULL, "SLB DAC5" },
  3343. { "SLB DAC67", NULL, "SLB DAC6" },
  3344. { "SLB DAC67", NULL, "SLB DAC7" },
  3345. { "ADDA1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" },
  3346. { "ADDA1 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" },
  3347. { "ADDA1 Mux", "OB 67", "OB67" },
  3348. { "DAC1 Mux", "IF1 DAC 01", "IF1 DAC01" },
  3349. { "DAC1 Mux", "IF2 DAC 01", "IF2 DAC01" },
  3350. { "DAC1 Mux", "IF3 DAC LR", "IF3 DAC" },
  3351. { "DAC1 Mux", "IF4 DAC LR", "IF4 DAC" },
  3352. { "DAC1 Mux", "SLB DAC 01", "SLB DAC01" },
  3353. { "DAC1 Mux", "OB 01", "OB01 Bypass Mux" },
  3354. { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" },
  3355. { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" },
  3356. { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" },
  3357. { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" },
  3358. { "DAC1 FS", NULL, "DAC1 MIXL" },
  3359. { "DAC1 FS", NULL, "DAC1 MIXR" },
  3360. { "DAC2 L Mux", "IF1 DAC 2", "IF1 DAC2 Mux" },
  3361. { "DAC2 L Mux", "IF2 DAC 2", "IF2 DAC2 Mux" },
  3362. { "DAC2 L Mux", "IF3 DAC L", "IF3 DAC L" },
  3363. { "DAC2 L Mux", "IF4 DAC L", "IF4 DAC L" },
  3364. { "DAC2 L Mux", "SLB DAC 2", "SLB DAC2" },
  3365. { "DAC2 L Mux", "OB 2", "OutBound2" },
  3366. { "DAC2 R Mux", "IF1 DAC 3", "IF1 DAC3 Mux" },
  3367. { "DAC2 R Mux", "IF2 DAC 3", "IF2 DAC3 Mux" },
  3368. { "DAC2 R Mux", "IF3 DAC R", "IF3 DAC R" },
  3369. { "DAC2 R Mux", "IF4 DAC R", "IF4 DAC R" },
  3370. { "DAC2 R Mux", "SLB DAC 3", "SLB DAC3" },
  3371. { "DAC2 R Mux", "OB 3", "OutBound3" },
  3372. { "DAC2 R Mux", "Haptic Generator", "Haptic Generator" },
  3373. { "DAC2 R Mux", "VAD ADC", "VAD ADC Mux" },
  3374. { "DAC3 L Mux", "IF1 DAC 4", "IF1 DAC4 Mux" },
  3375. { "DAC3 L Mux", "IF2 DAC 4", "IF2 DAC4 Mux" },
  3376. { "DAC3 L Mux", "IF3 DAC L", "IF3 DAC L" },
  3377. { "DAC3 L Mux", "IF4 DAC L", "IF4 DAC L" },
  3378. { "DAC3 L Mux", "SLB DAC 4", "SLB DAC4" },
  3379. { "DAC3 L Mux", "OB 4", "OutBound4" },
  3380. { "DAC3 R Mux", "IF1 DAC 5", "IF1 DAC5 Mux" },
  3381. { "DAC3 R Mux", "IF2 DAC 5", "IF2 DAC5 Mux" },
  3382. { "DAC3 R Mux", "IF3 DAC R", "IF3 DAC R" },
  3383. { "DAC3 R Mux", "IF4 DAC R", "IF4 DAC R" },
  3384. { "DAC3 R Mux", "SLB DAC 5", "SLB DAC5" },
  3385. { "DAC3 R Mux", "OB 5", "OutBound5" },
  3386. { "DAC4 L Mux", "IF1 DAC 6", "IF1 DAC6 Mux" },
  3387. { "DAC4 L Mux", "IF2 DAC 6", "IF2 DAC6 Mux" },
  3388. { "DAC4 L Mux", "IF3 DAC L", "IF3 DAC L" },
  3389. { "DAC4 L Mux", "IF4 DAC L", "IF4 DAC L" },
  3390. { "DAC4 L Mux", "SLB DAC 6", "SLB DAC6" },
  3391. { "DAC4 L Mux", "OB 6", "OutBound6" },
  3392. { "DAC4 R Mux", "IF1 DAC 7", "IF1 DAC7 Mux" },
  3393. { "DAC4 R Mux", "IF2 DAC 7", "IF2 DAC7 Mux" },
  3394. { "DAC4 R Mux", "IF3 DAC R", "IF3 DAC R" },
  3395. { "DAC4 R Mux", "IF4 DAC R", "IF4 DAC R" },
  3396. { "DAC4 R Mux", "SLB DAC 7", "SLB DAC7" },
  3397. { "DAC4 R Mux", "OB 7", "OutBound7" },
  3398. { "Sidetone Mux", "DMIC1 L", "DMIC L1" },
  3399. { "Sidetone Mux", "DMIC2 L", "DMIC L2" },
  3400. { "Sidetone Mux", "DMIC3 L", "DMIC L3" },
  3401. { "Sidetone Mux", "DMIC4 L", "DMIC L4" },
  3402. { "Sidetone Mux", "ADC1", "ADC 1" },
  3403. { "Sidetone Mux", "ADC2", "ADC 2" },
  3404. { "Sidetone Mux", NULL, "Sidetone Power" },
  3405. { "Stereo DAC MIXL", "ST L Switch", "Sidetone Mux" },
  3406. { "Stereo DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
  3407. { "Stereo DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
  3408. { "Stereo DAC MIXL", "DAC1 R Switch", "DAC1 MIXR" },
  3409. { "Stereo DAC MIXL", NULL, "dac stereo1 filter" },
  3410. { "Stereo DAC MIXR", "ST R Switch", "Sidetone Mux" },
  3411. { "Stereo DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
  3412. { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
  3413. { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" },
  3414. { "Stereo DAC MIXR", NULL, "dac stereo1 filter" },
  3415. { "dac stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll },
  3416. { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" },
  3417. { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" },
  3418. { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" },
  3419. { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" },
  3420. { "Mono DAC MIXL", NULL, "dac mono2 left filter" },
  3421. { "dac mono2 left filter", NULL, "PLL1", is_sys_clk_from_pll },
  3422. { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" },
  3423. { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" },
  3424. { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" },
  3425. { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" },
  3426. { "Mono DAC MIXR", NULL, "dac mono2 right filter" },
  3427. { "dac mono2 right filter", NULL, "PLL1", is_sys_clk_from_pll },
  3428. { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
  3429. { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
  3430. { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" },
  3431. { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" },
  3432. { "DD1 MIXL", NULL, "dac mono3 left filter" },
  3433. { "dac mono3 left filter", NULL, "PLL1", is_sys_clk_from_pll },
  3434. { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
  3435. { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
  3436. { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" },
  3437. { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" },
  3438. { "DD1 MIXR", NULL, "dac mono3 right filter" },
  3439. { "dac mono3 right filter", NULL, "PLL1", is_sys_clk_from_pll },
  3440. { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
  3441. { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" },
  3442. { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" },
  3443. { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" },
  3444. { "DD2 MIXL", NULL, "dac mono4 left filter" },
  3445. { "dac mono4 left filter", NULL, "PLL1", is_sys_clk_from_pll },
  3446. { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
  3447. { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" },
  3448. { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" },
  3449. { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" },
  3450. { "DD2 MIXR", NULL, "dac mono4 right filter" },
  3451. { "dac mono4 right filter", NULL, "PLL1", is_sys_clk_from_pll },
  3452. { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" },
  3453. { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" },
  3454. { "Mono DAC MIX", NULL, "Mono DAC MIXL" },
  3455. { "Mono DAC MIX", NULL, "Mono DAC MIXR" },
  3456. { "DD1 MIX", NULL, "DD1 MIXL" },
  3457. { "DD1 MIX", NULL, "DD1 MIXR" },
  3458. { "DD2 MIX", NULL, "DD2 MIXL" },
  3459. { "DD2 MIX", NULL, "DD2 MIXR" },
  3460. { "DAC12 SRC Mux", "STO1 DAC MIX", "Stereo DAC MIX" },
  3461. { "DAC12 SRC Mux", "MONO DAC MIX", "Mono DAC MIX" },
  3462. { "DAC12 SRC Mux", "DD MIX1", "DD1 MIX" },
  3463. { "DAC12 SRC Mux", "DD MIX2", "DD2 MIX" },
  3464. { "DAC3 SRC Mux", "MONO DAC MIXL", "Mono DAC MIXL" },
  3465. { "DAC3 SRC Mux", "MONO DAC MIXR", "Mono DAC MIXR" },
  3466. { "DAC3 SRC Mux", "DD MIX1L", "DD1 MIXL" },
  3467. { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" },
  3468. { "DAC 1", NULL, "DAC12 SRC Mux" },
  3469. { "DAC 2", NULL, "DAC12 SRC Mux" },
  3470. { "DAC 3", NULL, "DAC3 SRC Mux" },
  3471. { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
  3472. { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
  3473. { "PDM1 L Mux", "DD MIX1", "DD1 MIXL" },
  3474. { "PDM1 L Mux", "DD MIX2", "DD2 MIXL" },
  3475. { "PDM1 L Mux", NULL, "PDM1 Power" },
  3476. { "PDM1 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" },
  3477. { "PDM1 R Mux", "MONO DAC MIX", "Mono DAC MIXR" },
  3478. { "PDM1 R Mux", "DD MIX1", "DD1 MIXR" },
  3479. { "PDM1 R Mux", "DD MIX2", "DD2 MIXR" },
  3480. { "PDM1 R Mux", NULL, "PDM1 Power" },
  3481. { "PDM2 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" },
  3482. { "PDM2 L Mux", "MONO DAC MIX", "Mono DAC MIXL" },
  3483. { "PDM2 L Mux", "DD MIX1", "DD1 MIXL" },
  3484. { "PDM2 L Mux", "DD MIX2", "DD2 MIXL" },
  3485. { "PDM2 L Mux", NULL, "PDM2 Power" },
  3486. { "PDM2 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" },
  3487. { "PDM2 R Mux", "MONO DAC MIX", "Mono DAC MIXR" },
  3488. { "PDM2 R Mux", "DD MIX1", "DD1 MIXR" },
  3489. { "PDM2 R Mux", "DD MIX1", "DD2 MIXR" },
  3490. { "PDM2 R Mux", NULL, "PDM2 Power" },
  3491. { "LOUT1 amp", NULL, "DAC 1" },
  3492. { "LOUT2 amp", NULL, "DAC 2" },
  3493. { "LOUT3 amp", NULL, "DAC 3" },
  3494. { "LOUT1 vref", NULL, "LOUT1 amp" },
  3495. { "LOUT2 vref", NULL, "LOUT2 amp" },
  3496. { "LOUT3 vref", NULL, "LOUT3 amp" },
  3497. { "LOUT1", NULL, "LOUT1 vref" },
  3498. { "LOUT2", NULL, "LOUT2 vref" },
  3499. { "LOUT3", NULL, "LOUT3 vref" },
  3500. { "PDM1L", NULL, "PDM1 L Mux" },
  3501. { "PDM1R", NULL, "PDM1 R Mux" },
  3502. { "PDM2L", NULL, "PDM2 L Mux" },
  3503. { "PDM2R", NULL, "PDM2 R Mux" },
  3504. };
  3505. static const struct snd_soc_dapm_route rt5677_dmic2_clk_1[] = {
  3506. { "DMIC L2", NULL, "DMIC1 power" },
  3507. { "DMIC R2", NULL, "DMIC1 power" },
  3508. };
  3509. static const struct snd_soc_dapm_route rt5677_dmic2_clk_2[] = {
  3510. { "DMIC L2", NULL, "DMIC2 power" },
  3511. { "DMIC R2", NULL, "DMIC2 power" },
  3512. };
  3513. static int rt5677_hw_params(struct snd_pcm_substream *substream,
  3514. struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
  3515. {
  3516. struct snd_soc_codec *codec = dai->codec;
  3517. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  3518. unsigned int val_len = 0, val_clk, mask_clk;
  3519. int pre_div, bclk_ms, frame_size;
  3520. rt5677->lrck[dai->id] = params_rate(params);
  3521. pre_div = rl6231_get_clk_info(rt5677->sysclk, rt5677->lrck[dai->id]);
  3522. if (pre_div < 0) {
  3523. dev_err(codec->dev, "Unsupported clock setting: sysclk=%dHz lrck=%dHz\n",
  3524. rt5677->sysclk, rt5677->lrck[dai->id]);
  3525. return -EINVAL;
  3526. }
  3527. frame_size = snd_soc_params_to_frame_size(params);
  3528. if (frame_size < 0) {
  3529. dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size);
  3530. return -EINVAL;
  3531. }
  3532. bclk_ms = frame_size > 32;
  3533. rt5677->bclk[dai->id] = rt5677->lrck[dai->id] * (32 << bclk_ms);
  3534. dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n",
  3535. rt5677->bclk[dai->id], rt5677->lrck[dai->id]);
  3536. dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n",
  3537. bclk_ms, pre_div, dai->id);
  3538. switch (params_width(params)) {
  3539. case 16:
  3540. break;
  3541. case 20:
  3542. val_len |= RT5677_I2S_DL_20;
  3543. break;
  3544. case 24:
  3545. val_len |= RT5677_I2S_DL_24;
  3546. break;
  3547. case 8:
  3548. val_len |= RT5677_I2S_DL_8;
  3549. break;
  3550. default:
  3551. return -EINVAL;
  3552. }
  3553. switch (dai->id) {
  3554. case RT5677_AIF1:
  3555. mask_clk = RT5677_I2S_PD1_MASK;
  3556. val_clk = pre_div << RT5677_I2S_PD1_SFT;
  3557. regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP,
  3558. RT5677_I2S_DL_MASK, val_len);
  3559. regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
  3560. mask_clk, val_clk);
  3561. break;
  3562. case RT5677_AIF2:
  3563. mask_clk = RT5677_I2S_PD2_MASK;
  3564. val_clk = pre_div << RT5677_I2S_PD2_SFT;
  3565. regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP,
  3566. RT5677_I2S_DL_MASK, val_len);
  3567. regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
  3568. mask_clk, val_clk);
  3569. break;
  3570. case RT5677_AIF3:
  3571. mask_clk = RT5677_I2S_BCLK_MS3_MASK | RT5677_I2S_PD3_MASK;
  3572. val_clk = bclk_ms << RT5677_I2S_BCLK_MS3_SFT |
  3573. pre_div << RT5677_I2S_PD3_SFT;
  3574. regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP,
  3575. RT5677_I2S_DL_MASK, val_len);
  3576. regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
  3577. mask_clk, val_clk);
  3578. break;
  3579. case RT5677_AIF4:
  3580. mask_clk = RT5677_I2S_BCLK_MS4_MASK | RT5677_I2S_PD4_MASK;
  3581. val_clk = bclk_ms << RT5677_I2S_BCLK_MS4_SFT |
  3582. pre_div << RT5677_I2S_PD4_SFT;
  3583. regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP,
  3584. RT5677_I2S_DL_MASK, val_len);
  3585. regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1,
  3586. mask_clk, val_clk);
  3587. break;
  3588. default:
  3589. break;
  3590. }
  3591. return 0;
  3592. }
  3593. static int rt5677_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  3594. {
  3595. struct snd_soc_codec *codec = dai->codec;
  3596. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  3597. unsigned int reg_val = 0;
  3598. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  3599. case SND_SOC_DAIFMT_CBM_CFM:
  3600. rt5677->master[dai->id] = 1;
  3601. break;
  3602. case SND_SOC_DAIFMT_CBS_CFS:
  3603. reg_val |= RT5677_I2S_MS_S;
  3604. rt5677->master[dai->id] = 0;
  3605. break;
  3606. default:
  3607. return -EINVAL;
  3608. }
  3609. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  3610. case SND_SOC_DAIFMT_NB_NF:
  3611. break;
  3612. case SND_SOC_DAIFMT_IB_NF:
  3613. reg_val |= RT5677_I2S_BP_INV;
  3614. break;
  3615. default:
  3616. return -EINVAL;
  3617. }
  3618. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  3619. case SND_SOC_DAIFMT_I2S:
  3620. break;
  3621. case SND_SOC_DAIFMT_LEFT_J:
  3622. reg_val |= RT5677_I2S_DF_LEFT;
  3623. break;
  3624. case SND_SOC_DAIFMT_DSP_A:
  3625. reg_val |= RT5677_I2S_DF_PCM_A;
  3626. break;
  3627. case SND_SOC_DAIFMT_DSP_B:
  3628. reg_val |= RT5677_I2S_DF_PCM_B;
  3629. break;
  3630. default:
  3631. return -EINVAL;
  3632. }
  3633. switch (dai->id) {
  3634. case RT5677_AIF1:
  3635. regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP,
  3636. RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
  3637. RT5677_I2S_DF_MASK, reg_val);
  3638. break;
  3639. case RT5677_AIF2:
  3640. regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP,
  3641. RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
  3642. RT5677_I2S_DF_MASK, reg_val);
  3643. break;
  3644. case RT5677_AIF3:
  3645. regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP,
  3646. RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
  3647. RT5677_I2S_DF_MASK, reg_val);
  3648. break;
  3649. case RT5677_AIF4:
  3650. regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP,
  3651. RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK |
  3652. RT5677_I2S_DF_MASK, reg_val);
  3653. break;
  3654. default:
  3655. break;
  3656. }
  3657. return 0;
  3658. }
  3659. static int rt5677_set_dai_sysclk(struct snd_soc_dai *dai,
  3660. int clk_id, unsigned int freq, int dir)
  3661. {
  3662. struct snd_soc_codec *codec = dai->codec;
  3663. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  3664. unsigned int reg_val = 0;
  3665. if (freq == rt5677->sysclk && clk_id == rt5677->sysclk_src)
  3666. return 0;
  3667. switch (clk_id) {
  3668. case RT5677_SCLK_S_MCLK:
  3669. reg_val |= RT5677_SCLK_SRC_MCLK;
  3670. break;
  3671. case RT5677_SCLK_S_PLL1:
  3672. reg_val |= RT5677_SCLK_SRC_PLL1;
  3673. break;
  3674. case RT5677_SCLK_S_RCCLK:
  3675. reg_val |= RT5677_SCLK_SRC_RCCLK;
  3676. break;
  3677. default:
  3678. dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id);
  3679. return -EINVAL;
  3680. }
  3681. regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
  3682. RT5677_SCLK_SRC_MASK, reg_val);
  3683. rt5677->sysclk = freq;
  3684. rt5677->sysclk_src = clk_id;
  3685. dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id);
  3686. return 0;
  3687. }
  3688. /**
  3689. * rt5677_pll_calc - Calcualte PLL M/N/K code.
  3690. * @freq_in: external clock provided to codec.
  3691. * @freq_out: target clock which codec works on.
  3692. * @pll_code: Pointer to structure with M, N, K, bypass K and bypass M flag.
  3693. *
  3694. * Calcualte M/N/K code and bypass K/M flag to configure PLL for codec.
  3695. *
  3696. * Returns 0 for success or negative error code.
  3697. */
  3698. static int rt5677_pll_calc(const unsigned int freq_in,
  3699. const unsigned int freq_out, struct rl6231_pll_code *pll_code)
  3700. {
  3701. if (RT5677_PLL_INP_MIN > freq_in)
  3702. return -EINVAL;
  3703. return rl6231_pll_calc(freq_in, freq_out, pll_code);
  3704. }
  3705. static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
  3706. unsigned int freq_in, unsigned int freq_out)
  3707. {
  3708. struct snd_soc_codec *codec = dai->codec;
  3709. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  3710. struct rl6231_pll_code pll_code;
  3711. int ret;
  3712. if (source == rt5677->pll_src && freq_in == rt5677->pll_in &&
  3713. freq_out == rt5677->pll_out)
  3714. return 0;
  3715. if (!freq_in || !freq_out) {
  3716. dev_dbg(codec->dev, "PLL disabled\n");
  3717. rt5677->pll_in = 0;
  3718. rt5677->pll_out = 0;
  3719. regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
  3720. RT5677_SCLK_SRC_MASK, RT5677_SCLK_SRC_MCLK);
  3721. return 0;
  3722. }
  3723. switch (source) {
  3724. case RT5677_PLL1_S_MCLK:
  3725. regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
  3726. RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_MCLK);
  3727. break;
  3728. case RT5677_PLL1_S_BCLK1:
  3729. case RT5677_PLL1_S_BCLK2:
  3730. case RT5677_PLL1_S_BCLK3:
  3731. case RT5677_PLL1_S_BCLK4:
  3732. switch (dai->id) {
  3733. case RT5677_AIF1:
  3734. regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
  3735. RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK1);
  3736. break;
  3737. case RT5677_AIF2:
  3738. regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
  3739. RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK2);
  3740. break;
  3741. case RT5677_AIF3:
  3742. regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
  3743. RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK3);
  3744. break;
  3745. case RT5677_AIF4:
  3746. regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
  3747. RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK4);
  3748. break;
  3749. default:
  3750. break;
  3751. }
  3752. break;
  3753. default:
  3754. dev_err(codec->dev, "Unknown PLL source %d\n", source);
  3755. return -EINVAL;
  3756. }
  3757. ret = rt5677_pll_calc(freq_in, freq_out, &pll_code);
  3758. if (ret < 0) {
  3759. dev_err(codec->dev, "Unsupport input clock %d\n", freq_in);
  3760. return ret;
  3761. }
  3762. dev_dbg(codec->dev, "m_bypass=%d m=%d n=%d k=%d\n",
  3763. pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code),
  3764. pll_code.n_code, pll_code.k_code);
  3765. regmap_write(rt5677->regmap, RT5677_PLL1_CTRL1,
  3766. pll_code.n_code << RT5677_PLL_N_SFT | pll_code.k_code);
  3767. regmap_write(rt5677->regmap, RT5677_PLL1_CTRL2,
  3768. (pll_code.m_bp ? 0 : pll_code.m_code) << RT5677_PLL_M_SFT |
  3769. pll_code.m_bp << RT5677_PLL_M_BP_SFT);
  3770. rt5677->pll_in = freq_in;
  3771. rt5677->pll_out = freq_out;
  3772. rt5677->pll_src = source;
  3773. return 0;
  3774. }
  3775. static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
  3776. unsigned int rx_mask, int slots, int slot_width)
  3777. {
  3778. struct snd_soc_codec *codec = dai->codec;
  3779. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  3780. unsigned int val = 0, slot_width_25 = 0;
  3781. if (rx_mask || tx_mask)
  3782. val |= (1 << 12);
  3783. switch (slots) {
  3784. case 4:
  3785. val |= (1 << 10);
  3786. break;
  3787. case 6:
  3788. val |= (2 << 10);
  3789. break;
  3790. case 8:
  3791. val |= (3 << 10);
  3792. break;
  3793. case 2:
  3794. default:
  3795. break;
  3796. }
  3797. switch (slot_width) {
  3798. case 20:
  3799. val |= (1 << 8);
  3800. break;
  3801. case 25:
  3802. slot_width_25 = 0x8080;
  3803. case 24:
  3804. val |= (2 << 8);
  3805. break;
  3806. case 32:
  3807. val |= (3 << 8);
  3808. break;
  3809. case 16:
  3810. default:
  3811. break;
  3812. }
  3813. switch (dai->id) {
  3814. case RT5677_AIF1:
  3815. regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1, 0x1f00,
  3816. val);
  3817. regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x8000,
  3818. slot_width_25);
  3819. break;
  3820. case RT5677_AIF2:
  3821. regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1, 0x1f00,
  3822. val);
  3823. regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x80,
  3824. slot_width_25);
  3825. break;
  3826. default:
  3827. break;
  3828. }
  3829. return 0;
  3830. }
  3831. static int rt5677_set_bias_level(struct snd_soc_codec *codec,
  3832. enum snd_soc_bias_level level)
  3833. {
  3834. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  3835. switch (level) {
  3836. case SND_SOC_BIAS_ON:
  3837. break;
  3838. case SND_SOC_BIAS_PREPARE:
  3839. if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) {
  3840. rt5677_set_dsp_vad(codec, false);
  3841. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
  3842. RT5677_LDO1_SEL_MASK | RT5677_LDO2_SEL_MASK,
  3843. 0x0055);
  3844. regmap_update_bits(rt5677->regmap,
  3845. RT5677_PR_BASE + RT5677_BIAS_CUR4,
  3846. 0x0f00, 0x0f00);
  3847. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1,
  3848. RT5677_PWR_FV1 | RT5677_PWR_FV2 |
  3849. RT5677_PWR_VREF1 | RT5677_PWR_MB |
  3850. RT5677_PWR_BG | RT5677_PWR_VREF2,
  3851. RT5677_PWR_VREF1 | RT5677_PWR_MB |
  3852. RT5677_PWR_BG | RT5677_PWR_VREF2);
  3853. rt5677->is_vref_slow = false;
  3854. regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
  3855. RT5677_PWR_CORE, RT5677_PWR_CORE);
  3856. regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC,
  3857. 0x1, 0x1);
  3858. }
  3859. break;
  3860. case SND_SOC_BIAS_STANDBY:
  3861. break;
  3862. case SND_SOC_BIAS_OFF:
  3863. regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x0);
  3864. regmap_write(rt5677->regmap, RT5677_PWR_DIG1, 0x0000);
  3865. regmap_write(rt5677->regmap, RT5677_PWR_DIG2, 0x0000);
  3866. regmap_write(rt5677->regmap, RT5677_PWR_ANLG1, 0x0022);
  3867. regmap_write(rt5677->regmap, RT5677_PWR_ANLG2, 0x0000);
  3868. regmap_update_bits(rt5677->regmap,
  3869. RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0000);
  3870. if (rt5677->dsp_vad_en)
  3871. rt5677_set_dsp_vad(codec, true);
  3872. break;
  3873. default:
  3874. break;
  3875. }
  3876. return 0;
  3877. }
  3878. #ifdef CONFIG_GPIOLIB
  3879. static void rt5677_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
  3880. {
  3881. struct rt5677_priv *rt5677 = gpiochip_get_data(chip);
  3882. switch (offset) {
  3883. case RT5677_GPIO1 ... RT5677_GPIO5:
  3884. regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
  3885. 0x1 << (offset * 3 + 1), !!value << (offset * 3 + 1));
  3886. break;
  3887. case RT5677_GPIO6:
  3888. regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
  3889. RT5677_GPIO6_OUT_MASK, !!value << RT5677_GPIO6_OUT_SFT);
  3890. break;
  3891. default:
  3892. break;
  3893. }
  3894. }
  3895. static int rt5677_gpio_direction_out(struct gpio_chip *chip,
  3896. unsigned offset, int value)
  3897. {
  3898. struct rt5677_priv *rt5677 = gpiochip_get_data(chip);
  3899. switch (offset) {
  3900. case RT5677_GPIO1 ... RT5677_GPIO5:
  3901. regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
  3902. 0x3 << (offset * 3 + 1),
  3903. (0x2 | !!value) << (offset * 3 + 1));
  3904. break;
  3905. case RT5677_GPIO6:
  3906. regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
  3907. RT5677_GPIO6_DIR_MASK | RT5677_GPIO6_OUT_MASK,
  3908. RT5677_GPIO6_DIR_OUT | !!value << RT5677_GPIO6_OUT_SFT);
  3909. break;
  3910. default:
  3911. break;
  3912. }
  3913. return 0;
  3914. }
  3915. static int rt5677_gpio_get(struct gpio_chip *chip, unsigned offset)
  3916. {
  3917. struct rt5677_priv *rt5677 = gpiochip_get_data(chip);
  3918. int value, ret;
  3919. ret = regmap_read(rt5677->regmap, RT5677_GPIO_ST, &value);
  3920. if (ret < 0)
  3921. return ret;
  3922. return (value & (0x1 << offset)) >> offset;
  3923. }
  3924. static int rt5677_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
  3925. {
  3926. struct rt5677_priv *rt5677 = gpiochip_get_data(chip);
  3927. switch (offset) {
  3928. case RT5677_GPIO1 ... RT5677_GPIO5:
  3929. regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
  3930. 0x1 << (offset * 3 + 2), 0x0);
  3931. break;
  3932. case RT5677_GPIO6:
  3933. regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3,
  3934. RT5677_GPIO6_DIR_MASK, RT5677_GPIO6_DIR_IN);
  3935. break;
  3936. default:
  3937. break;
  3938. }
  3939. return 0;
  3940. }
  3941. /** Configures the gpio as
  3942. * 0 - floating
  3943. * 1 - pull down
  3944. * 2 - pull up
  3945. */
  3946. static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset,
  3947. int value)
  3948. {
  3949. int shift;
  3950. switch (offset) {
  3951. case RT5677_GPIO1 ... RT5677_GPIO2:
  3952. shift = 2 * (1 - offset);
  3953. regmap_update_bits(rt5677->regmap,
  3954. RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL2,
  3955. 0x3 << shift,
  3956. (value & 0x3) << shift);
  3957. break;
  3958. case RT5677_GPIO3 ... RT5677_GPIO6:
  3959. shift = 2 * (9 - offset);
  3960. regmap_update_bits(rt5677->regmap,
  3961. RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL3,
  3962. 0x3 << shift,
  3963. (value & 0x3) << shift);
  3964. break;
  3965. default:
  3966. break;
  3967. }
  3968. }
  3969. static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset)
  3970. {
  3971. struct rt5677_priv *rt5677 = gpiochip_get_data(chip);
  3972. struct regmap_irq_chip_data *data = rt5677->irq_data;
  3973. int irq;
  3974. if (offset >= RT5677_GPIO1 && offset <= RT5677_GPIO3) {
  3975. if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) ||
  3976. (rt5677->pdata.jd1_gpio == 2 &&
  3977. offset == RT5677_GPIO2) ||
  3978. (rt5677->pdata.jd1_gpio == 3 &&
  3979. offset == RT5677_GPIO3)) {
  3980. irq = RT5677_IRQ_JD1;
  3981. } else {
  3982. return -ENXIO;
  3983. }
  3984. }
  3985. if (offset >= RT5677_GPIO4 && offset <= RT5677_GPIO6) {
  3986. if ((rt5677->pdata.jd2_gpio == 1 && offset == RT5677_GPIO4) ||
  3987. (rt5677->pdata.jd2_gpio == 2 &&
  3988. offset == RT5677_GPIO5) ||
  3989. (rt5677->pdata.jd2_gpio == 3 &&
  3990. offset == RT5677_GPIO6)) {
  3991. irq = RT5677_IRQ_JD2;
  3992. } else if ((rt5677->pdata.jd3_gpio == 1 &&
  3993. offset == RT5677_GPIO4) ||
  3994. (rt5677->pdata.jd3_gpio == 2 &&
  3995. offset == RT5677_GPIO5) ||
  3996. (rt5677->pdata.jd3_gpio == 3 &&
  3997. offset == RT5677_GPIO6)) {
  3998. irq = RT5677_IRQ_JD3;
  3999. } else {
  4000. return -ENXIO;
  4001. }
  4002. }
  4003. return regmap_irq_get_virq(data, irq);
  4004. }
  4005. static const struct gpio_chip rt5677_template_chip = {
  4006. .label = "rt5677",
  4007. .owner = THIS_MODULE,
  4008. .direction_output = rt5677_gpio_direction_out,
  4009. .set = rt5677_gpio_set,
  4010. .direction_input = rt5677_gpio_direction_in,
  4011. .get = rt5677_gpio_get,
  4012. .to_irq = rt5677_to_irq,
  4013. .can_sleep = 1,
  4014. };
  4015. static void rt5677_init_gpio(struct i2c_client *i2c)
  4016. {
  4017. struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
  4018. int ret;
  4019. rt5677->gpio_chip = rt5677_template_chip;
  4020. rt5677->gpio_chip.ngpio = RT5677_GPIO_NUM;
  4021. rt5677->gpio_chip.parent = &i2c->dev;
  4022. rt5677->gpio_chip.base = -1;
  4023. ret = gpiochip_add_data(&rt5677->gpio_chip, rt5677);
  4024. if (ret != 0)
  4025. dev_err(&i2c->dev, "Failed to add GPIOs: %d\n", ret);
  4026. }
  4027. static void rt5677_free_gpio(struct i2c_client *i2c)
  4028. {
  4029. struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
  4030. gpiochip_remove(&rt5677->gpio_chip);
  4031. }
  4032. #else
  4033. static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset,
  4034. int value)
  4035. {
  4036. }
  4037. static void rt5677_init_gpio(struct i2c_client *i2c)
  4038. {
  4039. }
  4040. static void rt5677_free_gpio(struct i2c_client *i2c)
  4041. {
  4042. }
  4043. #endif
  4044. static int rt5677_probe(struct snd_soc_codec *codec)
  4045. {
  4046. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  4047. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  4048. int i;
  4049. rt5677->codec = codec;
  4050. if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) {
  4051. snd_soc_dapm_add_routes(dapm,
  4052. rt5677_dmic2_clk_2,
  4053. ARRAY_SIZE(rt5677_dmic2_clk_2));
  4054. } else { /*use dmic1 clock by default*/
  4055. snd_soc_dapm_add_routes(dapm,
  4056. rt5677_dmic2_clk_1,
  4057. ARRAY_SIZE(rt5677_dmic2_clk_1));
  4058. }
  4059. snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF);
  4060. regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020);
  4061. regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00);
  4062. for (i = 0; i < RT5677_GPIO_NUM; i++)
  4063. rt5677_gpio_config(rt5677, i, rt5677->pdata.gpio_config[i]);
  4064. if (rt5677->irq_data) {
  4065. regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1, 0x8000,
  4066. 0x8000);
  4067. regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x0018,
  4068. 0x0008);
  4069. if (rt5677->pdata.jd1_gpio)
  4070. regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
  4071. RT5677_SEL_GPIO_JD1_MASK,
  4072. rt5677->pdata.jd1_gpio <<
  4073. RT5677_SEL_GPIO_JD1_SFT);
  4074. if (rt5677->pdata.jd2_gpio)
  4075. regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
  4076. RT5677_SEL_GPIO_JD2_MASK,
  4077. rt5677->pdata.jd2_gpio <<
  4078. RT5677_SEL_GPIO_JD2_SFT);
  4079. if (rt5677->pdata.jd3_gpio)
  4080. regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1,
  4081. RT5677_SEL_GPIO_JD3_MASK,
  4082. rt5677->pdata.jd3_gpio <<
  4083. RT5677_SEL_GPIO_JD3_SFT);
  4084. }
  4085. mutex_init(&rt5677->dsp_cmd_lock);
  4086. mutex_init(&rt5677->dsp_pri_lock);
  4087. return 0;
  4088. }
  4089. static int rt5677_remove(struct snd_soc_codec *codec)
  4090. {
  4091. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  4092. regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
  4093. gpiod_set_value_cansleep(rt5677->pow_ldo2, 0);
  4094. gpiod_set_value_cansleep(rt5677->reset_pin, 1);
  4095. return 0;
  4096. }
  4097. #ifdef CONFIG_PM
  4098. static int rt5677_suspend(struct snd_soc_codec *codec)
  4099. {
  4100. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  4101. if (!rt5677->dsp_vad_en) {
  4102. regcache_cache_only(rt5677->regmap, true);
  4103. regcache_mark_dirty(rt5677->regmap);
  4104. gpiod_set_value_cansleep(rt5677->pow_ldo2, 0);
  4105. gpiod_set_value_cansleep(rt5677->reset_pin, 1);
  4106. }
  4107. return 0;
  4108. }
  4109. static int rt5677_resume(struct snd_soc_codec *codec)
  4110. {
  4111. struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
  4112. if (!rt5677->dsp_vad_en) {
  4113. rt5677->pll_src = 0;
  4114. rt5677->pll_in = 0;
  4115. rt5677->pll_out = 0;
  4116. gpiod_set_value_cansleep(rt5677->pow_ldo2, 1);
  4117. gpiod_set_value_cansleep(rt5677->reset_pin, 0);
  4118. if (rt5677->pow_ldo2 || rt5677->reset_pin)
  4119. msleep(10);
  4120. regcache_cache_only(rt5677->regmap, false);
  4121. regcache_sync(rt5677->regmap);
  4122. }
  4123. return 0;
  4124. }
  4125. #else
  4126. #define rt5677_suspend NULL
  4127. #define rt5677_resume NULL
  4128. #endif
  4129. static int rt5677_read(void *context, unsigned int reg, unsigned int *val)
  4130. {
  4131. struct i2c_client *client = context;
  4132. struct rt5677_priv *rt5677 = i2c_get_clientdata(client);
  4133. if (rt5677->is_dsp_mode) {
  4134. if (reg > 0xff) {
  4135. mutex_lock(&rt5677->dsp_pri_lock);
  4136. rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
  4137. reg & 0xff);
  4138. rt5677_dsp_mode_i2c_read(rt5677, RT5677_PRIV_DATA, val);
  4139. mutex_unlock(&rt5677->dsp_pri_lock);
  4140. } else {
  4141. rt5677_dsp_mode_i2c_read(rt5677, reg, val);
  4142. }
  4143. } else {
  4144. regmap_read(rt5677->regmap_physical, reg, val);
  4145. }
  4146. return 0;
  4147. }
  4148. static int rt5677_write(void *context, unsigned int reg, unsigned int val)
  4149. {
  4150. struct i2c_client *client = context;
  4151. struct rt5677_priv *rt5677 = i2c_get_clientdata(client);
  4152. if (rt5677->is_dsp_mode) {
  4153. if (reg > 0xff) {
  4154. mutex_lock(&rt5677->dsp_pri_lock);
  4155. rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
  4156. reg & 0xff);
  4157. rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_DATA,
  4158. val);
  4159. mutex_unlock(&rt5677->dsp_pri_lock);
  4160. } else {
  4161. rt5677_dsp_mode_i2c_write(rt5677, reg, val);
  4162. }
  4163. } else {
  4164. regmap_write(rt5677->regmap_physical, reg, val);
  4165. }
  4166. return 0;
  4167. }
  4168. #define RT5677_STEREO_RATES SNDRV_PCM_RATE_8000_96000
  4169. #define RT5677_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
  4170. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
  4171. static const struct snd_soc_dai_ops rt5677_aif_dai_ops = {
  4172. .hw_params = rt5677_hw_params,
  4173. .set_fmt = rt5677_set_dai_fmt,
  4174. .set_sysclk = rt5677_set_dai_sysclk,
  4175. .set_pll = rt5677_set_dai_pll,
  4176. .set_tdm_slot = rt5677_set_tdm_slot,
  4177. };
  4178. static struct snd_soc_dai_driver rt5677_dai[] = {
  4179. {
  4180. .name = "rt5677-aif1",
  4181. .id = RT5677_AIF1,
  4182. .playback = {
  4183. .stream_name = "AIF1 Playback",
  4184. .channels_min = 1,
  4185. .channels_max = 2,
  4186. .rates = RT5677_STEREO_RATES,
  4187. .formats = RT5677_FORMATS,
  4188. },
  4189. .capture = {
  4190. .stream_name = "AIF1 Capture",
  4191. .channels_min = 1,
  4192. .channels_max = 2,
  4193. .rates = RT5677_STEREO_RATES,
  4194. .formats = RT5677_FORMATS,
  4195. },
  4196. .ops = &rt5677_aif_dai_ops,
  4197. },
  4198. {
  4199. .name = "rt5677-aif2",
  4200. .id = RT5677_AIF2,
  4201. .playback = {
  4202. .stream_name = "AIF2 Playback",
  4203. .channels_min = 1,
  4204. .channels_max = 2,
  4205. .rates = RT5677_STEREO_RATES,
  4206. .formats = RT5677_FORMATS,
  4207. },
  4208. .capture = {
  4209. .stream_name = "AIF2 Capture",
  4210. .channels_min = 1,
  4211. .channels_max = 2,
  4212. .rates = RT5677_STEREO_RATES,
  4213. .formats = RT5677_FORMATS,
  4214. },
  4215. .ops = &rt5677_aif_dai_ops,
  4216. },
  4217. {
  4218. .name = "rt5677-aif3",
  4219. .id = RT5677_AIF3,
  4220. .playback = {
  4221. .stream_name = "AIF3 Playback",
  4222. .channels_min = 1,
  4223. .channels_max = 2,
  4224. .rates = RT5677_STEREO_RATES,
  4225. .formats = RT5677_FORMATS,
  4226. },
  4227. .capture = {
  4228. .stream_name = "AIF3 Capture",
  4229. .channels_min = 1,
  4230. .channels_max = 2,
  4231. .rates = RT5677_STEREO_RATES,
  4232. .formats = RT5677_FORMATS,
  4233. },
  4234. .ops = &rt5677_aif_dai_ops,
  4235. },
  4236. {
  4237. .name = "rt5677-aif4",
  4238. .id = RT5677_AIF4,
  4239. .playback = {
  4240. .stream_name = "AIF4 Playback",
  4241. .channels_min = 1,
  4242. .channels_max = 2,
  4243. .rates = RT5677_STEREO_RATES,
  4244. .formats = RT5677_FORMATS,
  4245. },
  4246. .capture = {
  4247. .stream_name = "AIF4 Capture",
  4248. .channels_min = 1,
  4249. .channels_max = 2,
  4250. .rates = RT5677_STEREO_RATES,
  4251. .formats = RT5677_FORMATS,
  4252. },
  4253. .ops = &rt5677_aif_dai_ops,
  4254. },
  4255. {
  4256. .name = "rt5677-slimbus",
  4257. .id = RT5677_AIF5,
  4258. .playback = {
  4259. .stream_name = "SLIMBus Playback",
  4260. .channels_min = 1,
  4261. .channels_max = 2,
  4262. .rates = RT5677_STEREO_RATES,
  4263. .formats = RT5677_FORMATS,
  4264. },
  4265. .capture = {
  4266. .stream_name = "SLIMBus Capture",
  4267. .channels_min = 1,
  4268. .channels_max = 2,
  4269. .rates = RT5677_STEREO_RATES,
  4270. .formats = RT5677_FORMATS,
  4271. },
  4272. .ops = &rt5677_aif_dai_ops,
  4273. },
  4274. };
  4275. static struct snd_soc_codec_driver soc_codec_dev_rt5677 = {
  4276. .probe = rt5677_probe,
  4277. .remove = rt5677_remove,
  4278. .suspend = rt5677_suspend,
  4279. .resume = rt5677_resume,
  4280. .set_bias_level = rt5677_set_bias_level,
  4281. .idle_bias_off = true,
  4282. .component_driver = {
  4283. .controls = rt5677_snd_controls,
  4284. .num_controls = ARRAY_SIZE(rt5677_snd_controls),
  4285. .dapm_widgets = rt5677_dapm_widgets,
  4286. .num_dapm_widgets = ARRAY_SIZE(rt5677_dapm_widgets),
  4287. .dapm_routes = rt5677_dapm_routes,
  4288. .num_dapm_routes = ARRAY_SIZE(rt5677_dapm_routes),
  4289. },
  4290. };
  4291. static const struct regmap_config rt5677_regmap_physical = {
  4292. .name = "physical",
  4293. .reg_bits = 8,
  4294. .val_bits = 16,
  4295. .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) *
  4296. RT5677_PR_SPACING),
  4297. .readable_reg = rt5677_readable_register,
  4298. .cache_type = REGCACHE_NONE,
  4299. .ranges = rt5677_ranges,
  4300. .num_ranges = ARRAY_SIZE(rt5677_ranges),
  4301. };
  4302. static const struct regmap_config rt5677_regmap = {
  4303. .reg_bits = 8,
  4304. .val_bits = 16,
  4305. .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) *
  4306. RT5677_PR_SPACING),
  4307. .volatile_reg = rt5677_volatile_register,
  4308. .readable_reg = rt5677_readable_register,
  4309. .reg_read = rt5677_read,
  4310. .reg_write = rt5677_write,
  4311. .cache_type = REGCACHE_RBTREE,
  4312. .reg_defaults = rt5677_reg,
  4313. .num_reg_defaults = ARRAY_SIZE(rt5677_reg),
  4314. .ranges = rt5677_ranges,
  4315. .num_ranges = ARRAY_SIZE(rt5677_ranges),
  4316. };
  4317. static const struct i2c_device_id rt5677_i2c_id[] = {
  4318. { "rt5677", RT5677 },
  4319. { "rt5676", RT5676 },
  4320. { "RT5677CE:00", RT5677 },
  4321. { }
  4322. };
  4323. MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
  4324. static const struct of_device_id rt5677_of_match[] = {
  4325. { .compatible = "realtek,rt5677", },
  4326. { }
  4327. };
  4328. MODULE_DEVICE_TABLE(of, rt5677_of_match);
  4329. static const struct acpi_gpio_params plug_det_gpio = { RT5677_GPIO_PLUG_DET, 0, false };
  4330. static const struct acpi_gpio_params mic_present_gpio = { RT5677_GPIO_MIC_PRESENT_L, 0, false };
  4331. static const struct acpi_gpio_params headphone_enable_gpio = { RT5677_GPIO_HP_AMP_SHDN_L, 0, false };
  4332. static const struct acpi_gpio_mapping bdw_rt5677_gpios[] = {
  4333. { "plug-det-gpios", &plug_det_gpio, 1 },
  4334. { "mic-present-gpios", &mic_present_gpio, 1 },
  4335. { "headphone-enable-gpios", &headphone_enable_gpio, 1 },
  4336. { NULL },
  4337. };
  4338. static void rt5677_read_acpi_properties(struct rt5677_priv *rt5677,
  4339. struct device *dev)
  4340. {
  4341. int ret;
  4342. u32 val;
  4343. ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
  4344. bdw_rt5677_gpios);
  4345. if (ret)
  4346. dev_warn(dev, "Failed to add driver gpios\n");
  4347. if (!device_property_read_u32(dev, "DCLK", &val))
  4348. rt5677->pdata.dmic2_clk_pin = val;
  4349. rt5677->pdata.in1_diff = device_property_read_bool(dev, "IN1");
  4350. rt5677->pdata.in2_diff = device_property_read_bool(dev, "IN2");
  4351. rt5677->pdata.lout1_diff = device_property_read_bool(dev, "OUT1");
  4352. rt5677->pdata.lout2_diff = device_property_read_bool(dev, "OUT2");
  4353. rt5677->pdata.lout3_diff = device_property_read_bool(dev, "OUT3");
  4354. device_property_read_u32(dev, "JD1", &rt5677->pdata.jd1_gpio);
  4355. device_property_read_u32(dev, "JD2", &rt5677->pdata.jd2_gpio);
  4356. device_property_read_u32(dev, "JD3", &rt5677->pdata.jd3_gpio);
  4357. }
  4358. static void rt5677_read_device_properties(struct rt5677_priv *rt5677,
  4359. struct device *dev)
  4360. {
  4361. rt5677->pdata.in1_diff = device_property_read_bool(dev,
  4362. "realtek,in1-differential");
  4363. rt5677->pdata.in2_diff = device_property_read_bool(dev,
  4364. "realtek,in2-differential");
  4365. rt5677->pdata.lout1_diff = device_property_read_bool(dev,
  4366. "realtek,lout1-differential");
  4367. rt5677->pdata.lout2_diff = device_property_read_bool(dev,
  4368. "realtek,lout2-differential");
  4369. rt5677->pdata.lout3_diff = device_property_read_bool(dev,
  4370. "realtek,lout3-differential");
  4371. device_property_read_u8_array(dev, "realtek,gpio-config",
  4372. rt5677->pdata.gpio_config, RT5677_GPIO_NUM);
  4373. device_property_read_u32(dev, "realtek,jd1-gpio",
  4374. &rt5677->pdata.jd1_gpio);
  4375. device_property_read_u32(dev, "realtek,jd2-gpio",
  4376. &rt5677->pdata.jd2_gpio);
  4377. device_property_read_u32(dev, "realtek,jd3-gpio",
  4378. &rt5677->pdata.jd3_gpio);
  4379. }
  4380. static struct regmap_irq rt5677_irqs[] = {
  4381. [RT5677_IRQ_JD1] = {
  4382. .reg_offset = 0,
  4383. .mask = RT5677_EN_IRQ_GPIO_JD1,
  4384. },
  4385. [RT5677_IRQ_JD2] = {
  4386. .reg_offset = 0,
  4387. .mask = RT5677_EN_IRQ_GPIO_JD2,
  4388. },
  4389. [RT5677_IRQ_JD3] = {
  4390. .reg_offset = 0,
  4391. .mask = RT5677_EN_IRQ_GPIO_JD3,
  4392. },
  4393. };
  4394. static struct regmap_irq_chip rt5677_irq_chip = {
  4395. .name = "rt5677",
  4396. .irqs = rt5677_irqs,
  4397. .num_irqs = ARRAY_SIZE(rt5677_irqs),
  4398. .num_regs = 1,
  4399. .status_base = RT5677_IRQ_CTRL1,
  4400. .mask_base = RT5677_IRQ_CTRL1,
  4401. .mask_invert = 1,
  4402. };
  4403. static int rt5677_init_irq(struct i2c_client *i2c)
  4404. {
  4405. int ret;
  4406. struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
  4407. if (!rt5677->pdata.jd1_gpio &&
  4408. !rt5677->pdata.jd2_gpio &&
  4409. !rt5677->pdata.jd3_gpio)
  4410. return 0;
  4411. if (!i2c->irq) {
  4412. dev_err(&i2c->dev, "No interrupt specified\n");
  4413. return -EINVAL;
  4414. }
  4415. ret = regmap_add_irq_chip(rt5677->regmap, i2c->irq,
  4416. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0,
  4417. &rt5677_irq_chip, &rt5677->irq_data);
  4418. if (ret != 0) {
  4419. dev_err(&i2c->dev, "Failed to register IRQ chip: %d\n", ret);
  4420. return ret;
  4421. }
  4422. return 0;
  4423. }
  4424. static void rt5677_free_irq(struct i2c_client *i2c)
  4425. {
  4426. struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c);
  4427. if (rt5677->irq_data)
  4428. regmap_del_irq_chip(i2c->irq, rt5677->irq_data);
  4429. }
  4430. static int rt5677_i2c_probe(struct i2c_client *i2c,
  4431. const struct i2c_device_id *id)
  4432. {
  4433. struct rt5677_platform_data *pdata = dev_get_platdata(&i2c->dev);
  4434. struct rt5677_priv *rt5677;
  4435. int ret;
  4436. unsigned int val;
  4437. rt5677 = devm_kzalloc(&i2c->dev, sizeof(struct rt5677_priv),
  4438. GFP_KERNEL);
  4439. if (rt5677 == NULL)
  4440. return -ENOMEM;
  4441. i2c_set_clientdata(i2c, rt5677);
  4442. rt5677->type = id->driver_data;
  4443. if (pdata)
  4444. rt5677->pdata = *pdata;
  4445. else if (i2c->dev.of_node)
  4446. rt5677_read_device_properties(rt5677, &i2c->dev);
  4447. else if (ACPI_HANDLE(&i2c->dev))
  4448. rt5677_read_acpi_properties(rt5677, &i2c->dev);
  4449. else
  4450. return -EINVAL;
  4451. /* pow-ldo2 and reset are optional. The codec pins may be statically
  4452. * connected on the board without gpios. If the gpio device property
  4453. * isn't specified, devm_gpiod_get_optional returns NULL.
  4454. */
  4455. rt5677->pow_ldo2 = devm_gpiod_get_optional(&i2c->dev,
  4456. "realtek,pow-ldo2", GPIOD_OUT_HIGH);
  4457. if (IS_ERR(rt5677->pow_ldo2)) {
  4458. ret = PTR_ERR(rt5677->pow_ldo2);
  4459. dev_err(&i2c->dev, "Failed to request POW_LDO2: %d\n", ret);
  4460. return ret;
  4461. }
  4462. rt5677->reset_pin = devm_gpiod_get_optional(&i2c->dev,
  4463. "realtek,reset", GPIOD_OUT_LOW);
  4464. if (IS_ERR(rt5677->reset_pin)) {
  4465. ret = PTR_ERR(rt5677->reset_pin);
  4466. dev_err(&i2c->dev, "Failed to request RESET: %d\n", ret);
  4467. return ret;
  4468. }
  4469. if (rt5677->pow_ldo2 || rt5677->reset_pin) {
  4470. /* Wait a while until I2C bus becomes available. The datasheet
  4471. * does not specify the exact we should wait but startup
  4472. * sequence mentiones at least a few milliseconds.
  4473. */
  4474. msleep(10);
  4475. }
  4476. rt5677->regmap_physical = devm_regmap_init_i2c(i2c,
  4477. &rt5677_regmap_physical);
  4478. if (IS_ERR(rt5677->regmap_physical)) {
  4479. ret = PTR_ERR(rt5677->regmap_physical);
  4480. dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
  4481. ret);
  4482. return ret;
  4483. }
  4484. rt5677->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt5677_regmap);
  4485. if (IS_ERR(rt5677->regmap)) {
  4486. ret = PTR_ERR(rt5677->regmap);
  4487. dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
  4488. ret);
  4489. return ret;
  4490. }
  4491. regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val);
  4492. if (val != RT5677_DEVICE_ID) {
  4493. dev_err(&i2c->dev,
  4494. "Device with ID register %#x is not rt5677\n", val);
  4495. return -ENODEV;
  4496. }
  4497. regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
  4498. ret = regmap_register_patch(rt5677->regmap, init_list,
  4499. ARRAY_SIZE(init_list));
  4500. if (ret != 0)
  4501. dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
  4502. if (rt5677->pdata.in1_diff)
  4503. regmap_update_bits(rt5677->regmap, RT5677_IN1,
  4504. RT5677_IN_DF1, RT5677_IN_DF1);
  4505. if (rt5677->pdata.in2_diff)
  4506. regmap_update_bits(rt5677->regmap, RT5677_IN1,
  4507. RT5677_IN_DF2, RT5677_IN_DF2);
  4508. if (rt5677->pdata.lout1_diff)
  4509. regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
  4510. RT5677_LOUT1_L_DF, RT5677_LOUT1_L_DF);
  4511. if (rt5677->pdata.lout2_diff)
  4512. regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
  4513. RT5677_LOUT2_L_DF, RT5677_LOUT2_L_DF);
  4514. if (rt5677->pdata.lout3_diff)
  4515. regmap_update_bits(rt5677->regmap, RT5677_LOUT1,
  4516. RT5677_LOUT3_L_DF, RT5677_LOUT3_L_DF);
  4517. if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) {
  4518. regmap_update_bits(rt5677->regmap, RT5677_GEN_CTRL2,
  4519. RT5677_GPIO5_FUNC_MASK,
  4520. RT5677_GPIO5_FUNC_DMIC);
  4521. regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2,
  4522. RT5677_GPIO5_DIR_MASK,
  4523. RT5677_GPIO5_DIR_OUT);
  4524. }
  4525. if (rt5677->pdata.micbias1_vdd_3v3)
  4526. regmap_update_bits(rt5677->regmap, RT5677_MICBIAS,
  4527. RT5677_MICBIAS1_CTRL_VDD_MASK,
  4528. RT5677_MICBIAS1_CTRL_VDD_3_3V);
  4529. rt5677_init_gpio(i2c);
  4530. rt5677_init_irq(i2c);
  4531. return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5677,
  4532. rt5677_dai, ARRAY_SIZE(rt5677_dai));
  4533. }
  4534. static int rt5677_i2c_remove(struct i2c_client *i2c)
  4535. {
  4536. snd_soc_unregister_codec(&i2c->dev);
  4537. rt5677_free_irq(i2c);
  4538. rt5677_free_gpio(i2c);
  4539. return 0;
  4540. }
  4541. static struct i2c_driver rt5677_i2c_driver = {
  4542. .driver = {
  4543. .name = "rt5677",
  4544. .of_match_table = rt5677_of_match,
  4545. },
  4546. .probe = rt5677_i2c_probe,
  4547. .remove = rt5677_i2c_remove,
  4548. .id_table = rt5677_i2c_id,
  4549. };
  4550. module_i2c_driver(rt5677_i2c_driver);
  4551. MODULE_DESCRIPTION("ASoC RT5677 driver");
  4552. MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>");
  4553. MODULE_LICENSE("GPL v2");