wm8962.c 121 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * wm8962.c -- WM8962 ALSA SoC Audio driver
  4. *
  5. * Copyright 2010-2 Wolfson Microelectronics plc
  6. *
  7. * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
  8. */
  9. #include <linux/module.h>
  10. #include <linux/moduleparam.h>
  11. #include <linux/init.h>
  12. #include <linux/clk.h>
  13. #include <linux/delay.h>
  14. #include <linux/pm.h>
  15. #include <linux/gcd.h>
  16. #include <linux/gpio/driver.h>
  17. #include <linux/i2c.h>
  18. #include <linux/input.h>
  19. #include <linux/pm_runtime.h>
  20. #include <linux/regmap.h>
  21. #include <linux/regulator/consumer.h>
  22. #include <linux/slab.h>
  23. #include <linux/workqueue.h>
  24. #include <linux/mutex.h>
  25. #include <sound/core.h>
  26. #include <sound/jack.h>
  27. #include <sound/pcm.h>
  28. #include <sound/pcm_params.h>
  29. #include <sound/soc.h>
  30. #include <sound/initval.h>
  31. #include <sound/tlv.h>
  32. #include <sound/wm8962.h>
  33. #include <trace/events/asoc.h>
  34. #include "wm8962.h"
  35. #define WM8962_NUM_SUPPLIES 8
  36. static const char *wm8962_supply_names[WM8962_NUM_SUPPLIES] = {
  37. "DCVDD",
  38. "DBVDD",
  39. "AVDD",
  40. "CPVDD",
  41. "MICVDD",
  42. "PLLVDD",
  43. "SPKVDD1",
  44. "SPKVDD2",
  45. };
  46. /* codec private data */
  47. struct wm8962_priv {
  48. struct wm8962_pdata pdata;
  49. struct regmap *regmap;
  50. struct snd_soc_component *component;
  51. int sysclk;
  52. int sysclk_rate;
  53. int bclk; /* Desired BCLK */
  54. int lrclk;
  55. struct completion fll_lock;
  56. int fll_src;
  57. int fll_fref;
  58. int fll_fout;
  59. struct mutex dsp2_ena_lock;
  60. u16 dsp2_ena;
  61. struct delayed_work mic_work;
  62. struct snd_soc_jack *jack;
  63. struct regulator_bulk_data supplies[WM8962_NUM_SUPPLIES];
  64. struct notifier_block disable_nb[WM8962_NUM_SUPPLIES];
  65. struct input_dev *beep;
  66. struct work_struct beep_work;
  67. int beep_rate;
  68. #ifdef CONFIG_GPIOLIB
  69. struct gpio_chip gpio_chip;
  70. #endif
  71. int irq;
  72. };
  73. /* We can't use the same notifier block for more than one supply and
  74. * there's no way I can see to get from a callback to the caller
  75. * except container_of().
  76. */
  77. #define WM8962_REGULATOR_EVENT(n) \
  78. static int wm8962_regulator_event_##n(struct notifier_block *nb, \
  79. unsigned long event, void *data) \
  80. { \
  81. struct wm8962_priv *wm8962 = container_of(nb, struct wm8962_priv, \
  82. disable_nb[n]); \
  83. if (event & REGULATOR_EVENT_DISABLE) { \
  84. regcache_mark_dirty(wm8962->regmap); \
  85. } \
  86. return 0; \
  87. }
  88. WM8962_REGULATOR_EVENT(0)
  89. WM8962_REGULATOR_EVENT(1)
  90. WM8962_REGULATOR_EVENT(2)
  91. WM8962_REGULATOR_EVENT(3)
  92. WM8962_REGULATOR_EVENT(4)
  93. WM8962_REGULATOR_EVENT(5)
  94. WM8962_REGULATOR_EVENT(6)
  95. WM8962_REGULATOR_EVENT(7)
  96. static const struct reg_default wm8962_reg[] = {
  97. { 0, 0x009F }, /* R0 - Left Input volume */
  98. { 1, 0x049F }, /* R1 - Right Input volume */
  99. { 2, 0x0000 }, /* R2 - HPOUTL volume */
  100. { 3, 0x0000 }, /* R3 - HPOUTR volume */
  101. { 5, 0x0018 }, /* R5 - ADC & DAC Control 1 */
  102. { 6, 0x2008 }, /* R6 - ADC & DAC Control 2 */
  103. { 7, 0x000A }, /* R7 - Audio Interface 0 */
  104. { 8, 0x01E4 }, /* R8 - Clocking2 */
  105. { 9, 0x0300 }, /* R9 - Audio Interface 1 */
  106. { 10, 0x00C0 }, /* R10 - Left DAC volume */
  107. { 11, 0x00C0 }, /* R11 - Right DAC volume */
  108. { 14, 0x0040 }, /* R14 - Audio Interface 2 */
  109. { 15, 0x6243 }, /* R15 - Software Reset */
  110. { 17, 0x007B }, /* R17 - ALC1 */
  111. { 18, 0x0000 }, /* R18 - ALC2 */
  112. { 19, 0x1C32 }, /* R19 - ALC3 */
  113. { 20, 0x3200 }, /* R20 - Noise Gate */
  114. { 21, 0x00C0 }, /* R21 - Left ADC volume */
  115. { 22, 0x00C0 }, /* R22 - Right ADC volume */
  116. { 23, 0x0160 }, /* R23 - Additional control(1) */
  117. { 24, 0x0000 }, /* R24 - Additional control(2) */
  118. { 25, 0x0000 }, /* R25 - Pwr Mgmt (1) */
  119. { 26, 0x0000 }, /* R26 - Pwr Mgmt (2) */
  120. { 27, 0x0010 }, /* R27 - Additional Control (3) */
  121. { 28, 0x0000 }, /* R28 - Anti-pop */
  122. { 30, 0x005E }, /* R30 - Clocking 3 */
  123. { 31, 0x0000 }, /* R31 - Input mixer control (1) */
  124. { 32, 0x0145 }, /* R32 - Left input mixer volume */
  125. { 33, 0x0145 }, /* R33 - Right input mixer volume */
  126. { 34, 0x0009 }, /* R34 - Input mixer control (2) */
  127. { 35, 0x0003 }, /* R35 - Input bias control */
  128. { 37, 0x0008 }, /* R37 - Left input PGA control */
  129. { 38, 0x0008 }, /* R38 - Right input PGA control */
  130. { 40, 0x0000 }, /* R40 - SPKOUTL volume */
  131. { 41, 0x0000 }, /* R41 - SPKOUTR volume */
  132. { 49, 0x0010 }, /* R49 - Class D Control 1 */
  133. { 51, 0x0003 }, /* R51 - Class D Control 2 */
  134. { 56, 0x0506 }, /* R56 - Clocking 4 */
  135. { 57, 0x0000 }, /* R57 - DAC DSP Mixing (1) */
  136. { 58, 0x0000 }, /* R58 - DAC DSP Mixing (2) */
  137. { 60, 0x0300 }, /* R60 - DC Servo 0 */
  138. { 61, 0x0300 }, /* R61 - DC Servo 1 */
  139. { 64, 0x0810 }, /* R64 - DC Servo 4 */
  140. { 68, 0x001B }, /* R68 - Analogue PGA Bias */
  141. { 69, 0x0000 }, /* R69 - Analogue HP 0 */
  142. { 71, 0x01FB }, /* R71 - Analogue HP 2 */
  143. { 72, 0x0000 }, /* R72 - Charge Pump 1 */
  144. { 82, 0x0004 }, /* R82 - Charge Pump B */
  145. { 87, 0x0000 }, /* R87 - Write Sequencer Control 1 */
  146. { 90, 0x0000 }, /* R90 - Write Sequencer Control 2 */
  147. { 93, 0x0000 }, /* R93 - Write Sequencer Control 3 */
  148. { 94, 0x0000 }, /* R94 - Control Interface */
  149. { 99, 0x0000 }, /* R99 - Mixer Enables */
  150. { 100, 0x0000 }, /* R100 - Headphone Mixer (1) */
  151. { 101, 0x0000 }, /* R101 - Headphone Mixer (2) */
  152. { 102, 0x013F }, /* R102 - Headphone Mixer (3) */
  153. { 103, 0x013F }, /* R103 - Headphone Mixer (4) */
  154. { 105, 0x0000 }, /* R105 - Speaker Mixer (1) */
  155. { 106, 0x0000 }, /* R106 - Speaker Mixer (2) */
  156. { 107, 0x013F }, /* R107 - Speaker Mixer (3) */
  157. { 108, 0x013F }, /* R108 - Speaker Mixer (4) */
  158. { 109, 0x0003 }, /* R109 - Speaker Mixer (5) */
  159. { 110, 0x0002 }, /* R110 - Beep Generator (1) */
  160. { 115, 0x0006 }, /* R115 - Oscillator Trim (3) */
  161. { 116, 0x0026 }, /* R116 - Oscillator Trim (4) */
  162. { 119, 0x0000 }, /* R119 - Oscillator Trim (7) */
  163. { 124, 0x0011 }, /* R124 - Analogue Clocking1 */
  164. { 125, 0x004B }, /* R125 - Analogue Clocking2 */
  165. { 126, 0x000D }, /* R126 - Analogue Clocking3 */
  166. { 127, 0x0000 }, /* R127 - PLL Software Reset */
  167. { 131, 0x0000 }, /* R131 - PLL 4 */
  168. { 136, 0x0067 }, /* R136 - PLL 9 */
  169. { 137, 0x001C }, /* R137 - PLL 10 */
  170. { 138, 0x0071 }, /* R138 - PLL 11 */
  171. { 139, 0x00C7 }, /* R139 - PLL 12 */
  172. { 140, 0x0067 }, /* R140 - PLL 13 */
  173. { 141, 0x0048 }, /* R141 - PLL 14 */
  174. { 142, 0x0022 }, /* R142 - PLL 15 */
  175. { 143, 0x0097 }, /* R143 - PLL 16 */
  176. { 155, 0x000C }, /* R155 - FLL Control (1) */
  177. { 156, 0x0039 }, /* R156 - FLL Control (2) */
  178. { 157, 0x0180 }, /* R157 - FLL Control (3) */
  179. { 159, 0x0032 }, /* R159 - FLL Control (5) */
  180. { 160, 0x0018 }, /* R160 - FLL Control (6) */
  181. { 161, 0x007D }, /* R161 - FLL Control (7) */
  182. { 162, 0x0008 }, /* R162 - FLL Control (8) */
  183. { 252, 0x0005 }, /* R252 - General test 1 */
  184. { 256, 0x0000 }, /* R256 - DF1 */
  185. { 257, 0x0000 }, /* R257 - DF2 */
  186. { 258, 0x0000 }, /* R258 - DF3 */
  187. { 259, 0x0000 }, /* R259 - DF4 */
  188. { 260, 0x0000 }, /* R260 - DF5 */
  189. { 261, 0x0000 }, /* R261 - DF6 */
  190. { 262, 0x0000 }, /* R262 - DF7 */
  191. { 264, 0x0000 }, /* R264 - LHPF1 */
  192. { 265, 0x0000 }, /* R265 - LHPF2 */
  193. { 268, 0x0000 }, /* R268 - THREED1 */
  194. { 269, 0x0000 }, /* R269 - THREED2 */
  195. { 270, 0x0000 }, /* R270 - THREED3 */
  196. { 271, 0x0000 }, /* R271 - THREED4 */
  197. { 276, 0x000C }, /* R276 - DRC 1 */
  198. { 277, 0x0925 }, /* R277 - DRC 2 */
  199. { 278, 0x0000 }, /* R278 - DRC 3 */
  200. { 279, 0x0000 }, /* R279 - DRC 4 */
  201. { 280, 0x0000 }, /* R280 - DRC 5 */
  202. { 285, 0x0000 }, /* R285 - Tloopback */
  203. { 335, 0x0004 }, /* R335 - EQ1 */
  204. { 336, 0x6318 }, /* R336 - EQ2 */
  205. { 337, 0x6300 }, /* R337 - EQ3 */
  206. { 338, 0x0FCA }, /* R338 - EQ4 */
  207. { 339, 0x0400 }, /* R339 - EQ5 */
  208. { 340, 0x00D8 }, /* R340 - EQ6 */
  209. { 341, 0x1EB5 }, /* R341 - EQ7 */
  210. { 342, 0xF145 }, /* R342 - EQ8 */
  211. { 343, 0x0B75 }, /* R343 - EQ9 */
  212. { 344, 0x01C5 }, /* R344 - EQ10 */
  213. { 345, 0x1C58 }, /* R345 - EQ11 */
  214. { 346, 0xF373 }, /* R346 - EQ12 */
  215. { 347, 0x0A54 }, /* R347 - EQ13 */
  216. { 348, 0x0558 }, /* R348 - EQ14 */
  217. { 349, 0x168E }, /* R349 - EQ15 */
  218. { 350, 0xF829 }, /* R350 - EQ16 */
  219. { 351, 0x07AD }, /* R351 - EQ17 */
  220. { 352, 0x1103 }, /* R352 - EQ18 */
  221. { 353, 0x0564 }, /* R353 - EQ19 */
  222. { 354, 0x0559 }, /* R354 - EQ20 */
  223. { 355, 0x4000 }, /* R355 - EQ21 */
  224. { 356, 0x6318 }, /* R356 - EQ22 */
  225. { 357, 0x6300 }, /* R357 - EQ23 */
  226. { 358, 0x0FCA }, /* R358 - EQ24 */
  227. { 359, 0x0400 }, /* R359 - EQ25 */
  228. { 360, 0x00D8 }, /* R360 - EQ26 */
  229. { 361, 0x1EB5 }, /* R361 - EQ27 */
  230. { 362, 0xF145 }, /* R362 - EQ28 */
  231. { 363, 0x0B75 }, /* R363 - EQ29 */
  232. { 364, 0x01C5 }, /* R364 - EQ30 */
  233. { 365, 0x1C58 }, /* R365 - EQ31 */
  234. { 366, 0xF373 }, /* R366 - EQ32 */
  235. { 367, 0x0A54 }, /* R367 - EQ33 */
  236. { 368, 0x0558 }, /* R368 - EQ34 */
  237. { 369, 0x168E }, /* R369 - EQ35 */
  238. { 370, 0xF829 }, /* R370 - EQ36 */
  239. { 371, 0x07AD }, /* R371 - EQ37 */
  240. { 372, 0x1103 }, /* R372 - EQ38 */
  241. { 373, 0x0564 }, /* R373 - EQ39 */
  242. { 374, 0x0559 }, /* R374 - EQ40 */
  243. { 375, 0x4000 }, /* R375 - EQ41 */
  244. { 513, 0x0000 }, /* R513 - GPIO 2 */
  245. { 514, 0x0000 }, /* R514 - GPIO 3 */
  246. { 516, 0x8100 }, /* R516 - GPIO 5 */
  247. { 517, 0x8100 }, /* R517 - GPIO 6 */
  248. { 568, 0x0030 }, /* R568 - Interrupt Status 1 Mask */
  249. { 569, 0xFFED }, /* R569 - Interrupt Status 2 Mask */
  250. { 576, 0x0000 }, /* R576 - Interrupt Control */
  251. { 584, 0x002D }, /* R584 - IRQ Debounce */
  252. { 586, 0x0000 }, /* R586 - MICINT Source Pol */
  253. { 768, 0x1C00 }, /* R768 - DSP2 Power Management */
  254. { 8192, 0x0000 }, /* R8192 - DSP2 Instruction RAM 0 */
  255. { 9216, 0x0030 }, /* R9216 - DSP2 Address RAM 2 */
  256. { 9217, 0x0000 }, /* R9217 - DSP2 Address RAM 1 */
  257. { 9218, 0x0000 }, /* R9218 - DSP2 Address RAM 0 */
  258. { 12288, 0x0000 }, /* R12288 - DSP2 Data1 RAM 1 */
  259. { 12289, 0x0000 }, /* R12289 - DSP2 Data1 RAM 0 */
  260. { 13312, 0x0000 }, /* R13312 - DSP2 Data2 RAM 1 */
  261. { 13313, 0x0000 }, /* R13313 - DSP2 Data2 RAM 0 */
  262. { 14336, 0x0000 }, /* R14336 - DSP2 Data3 RAM 1 */
  263. { 14337, 0x0000 }, /* R14337 - DSP2 Data3 RAM 0 */
  264. { 15360, 0x000A }, /* R15360 - DSP2 Coeff RAM 0 */
  265. { 16384, 0x0000 }, /* R16384 - RETUNEADC_SHARED_COEFF_1 */
  266. { 16385, 0x0000 }, /* R16385 - RETUNEADC_SHARED_COEFF_0 */
  267. { 16386, 0x0000 }, /* R16386 - RETUNEDAC_SHARED_COEFF_1 */
  268. { 16387, 0x0000 }, /* R16387 - RETUNEDAC_SHARED_COEFF_0 */
  269. { 16388, 0x0000 }, /* R16388 - SOUNDSTAGE_ENABLES_1 */
  270. { 16389, 0x0000 }, /* R16389 - SOUNDSTAGE_ENABLES_0 */
  271. { 16896, 0x0002 }, /* R16896 - HDBASS_AI_1 */
  272. { 16897, 0xBD12 }, /* R16897 - HDBASS_AI_0 */
  273. { 16898, 0x007C }, /* R16898 - HDBASS_AR_1 */
  274. { 16899, 0x586C }, /* R16899 - HDBASS_AR_0 */
  275. { 16900, 0x0053 }, /* R16900 - HDBASS_B_1 */
  276. { 16901, 0x8121 }, /* R16901 - HDBASS_B_0 */
  277. { 16902, 0x003F }, /* R16902 - HDBASS_K_1 */
  278. { 16903, 0x8BD8 }, /* R16903 - HDBASS_K_0 */
  279. { 16904, 0x0032 }, /* R16904 - HDBASS_N1_1 */
  280. { 16905, 0xF52D }, /* R16905 - HDBASS_N1_0 */
  281. { 16906, 0x0065 }, /* R16906 - HDBASS_N2_1 */
  282. { 16907, 0xAC8C }, /* R16907 - HDBASS_N2_0 */
  283. { 16908, 0x006B }, /* R16908 - HDBASS_N3_1 */
  284. { 16909, 0xE087 }, /* R16909 - HDBASS_N3_0 */
  285. { 16910, 0x0072 }, /* R16910 - HDBASS_N4_1 */
  286. { 16911, 0x1483 }, /* R16911 - HDBASS_N4_0 */
  287. { 16912, 0x0072 }, /* R16912 - HDBASS_N5_1 */
  288. { 16913, 0x1483 }, /* R16913 - HDBASS_N5_0 */
  289. { 16914, 0x0043 }, /* R16914 - HDBASS_X1_1 */
  290. { 16915, 0x3525 }, /* R16915 - HDBASS_X1_0 */
  291. { 16916, 0x0006 }, /* R16916 - HDBASS_X2_1 */
  292. { 16917, 0x6A4A }, /* R16917 - HDBASS_X2_0 */
  293. { 16918, 0x0043 }, /* R16918 - HDBASS_X3_1 */
  294. { 16919, 0x6079 }, /* R16919 - HDBASS_X3_0 */
  295. { 16920, 0x0008 }, /* R16920 - HDBASS_ATK_1 */
  296. { 16921, 0x0000 }, /* R16921 - HDBASS_ATK_0 */
  297. { 16922, 0x0001 }, /* R16922 - HDBASS_DCY_1 */
  298. { 16923, 0x0000 }, /* R16923 - HDBASS_DCY_0 */
  299. { 16924, 0x0059 }, /* R16924 - HDBASS_PG_1 */
  300. { 16925, 0x999A }, /* R16925 - HDBASS_PG_0 */
  301. { 17408, 0x0083 }, /* R17408 - HPF_C_1 */
  302. { 17409, 0x98AD }, /* R17409 - HPF_C_0 */
  303. { 17920, 0x007F }, /* R17920 - ADCL_RETUNE_C1_1 */
  304. { 17921, 0xFFFF }, /* R17921 - ADCL_RETUNE_C1_0 */
  305. { 17922, 0x0000 }, /* R17922 - ADCL_RETUNE_C2_1 */
  306. { 17923, 0x0000 }, /* R17923 - ADCL_RETUNE_C2_0 */
  307. { 17924, 0x0000 }, /* R17924 - ADCL_RETUNE_C3_1 */
  308. { 17925, 0x0000 }, /* R17925 - ADCL_RETUNE_C3_0 */
  309. { 17926, 0x0000 }, /* R17926 - ADCL_RETUNE_C4_1 */
  310. { 17927, 0x0000 }, /* R17927 - ADCL_RETUNE_C4_0 */
  311. { 17928, 0x0000 }, /* R17928 - ADCL_RETUNE_C5_1 */
  312. { 17929, 0x0000 }, /* R17929 - ADCL_RETUNE_C5_0 */
  313. { 17930, 0x0000 }, /* R17930 - ADCL_RETUNE_C6_1 */
  314. { 17931, 0x0000 }, /* R17931 - ADCL_RETUNE_C6_0 */
  315. { 17932, 0x0000 }, /* R17932 - ADCL_RETUNE_C7_1 */
  316. { 17933, 0x0000 }, /* R17933 - ADCL_RETUNE_C7_0 */
  317. { 17934, 0x0000 }, /* R17934 - ADCL_RETUNE_C8_1 */
  318. { 17935, 0x0000 }, /* R17935 - ADCL_RETUNE_C8_0 */
  319. { 17936, 0x0000 }, /* R17936 - ADCL_RETUNE_C9_1 */
  320. { 17937, 0x0000 }, /* R17937 - ADCL_RETUNE_C9_0 */
  321. { 17938, 0x0000 }, /* R17938 - ADCL_RETUNE_C10_1 */
  322. { 17939, 0x0000 }, /* R17939 - ADCL_RETUNE_C10_0 */
  323. { 17940, 0x0000 }, /* R17940 - ADCL_RETUNE_C11_1 */
  324. { 17941, 0x0000 }, /* R17941 - ADCL_RETUNE_C11_0 */
  325. { 17942, 0x0000 }, /* R17942 - ADCL_RETUNE_C12_1 */
  326. { 17943, 0x0000 }, /* R17943 - ADCL_RETUNE_C12_0 */
  327. { 17944, 0x0000 }, /* R17944 - ADCL_RETUNE_C13_1 */
  328. { 17945, 0x0000 }, /* R17945 - ADCL_RETUNE_C13_0 */
  329. { 17946, 0x0000 }, /* R17946 - ADCL_RETUNE_C14_1 */
  330. { 17947, 0x0000 }, /* R17947 - ADCL_RETUNE_C14_0 */
  331. { 17948, 0x0000 }, /* R17948 - ADCL_RETUNE_C15_1 */
  332. { 17949, 0x0000 }, /* R17949 - ADCL_RETUNE_C15_0 */
  333. { 17950, 0x0000 }, /* R17950 - ADCL_RETUNE_C16_1 */
  334. { 17951, 0x0000 }, /* R17951 - ADCL_RETUNE_C16_0 */
  335. { 17952, 0x0000 }, /* R17952 - ADCL_RETUNE_C17_1 */
  336. { 17953, 0x0000 }, /* R17953 - ADCL_RETUNE_C17_0 */
  337. { 17954, 0x0000 }, /* R17954 - ADCL_RETUNE_C18_1 */
  338. { 17955, 0x0000 }, /* R17955 - ADCL_RETUNE_C18_0 */
  339. { 17956, 0x0000 }, /* R17956 - ADCL_RETUNE_C19_1 */
  340. { 17957, 0x0000 }, /* R17957 - ADCL_RETUNE_C19_0 */
  341. { 17958, 0x0000 }, /* R17958 - ADCL_RETUNE_C20_1 */
  342. { 17959, 0x0000 }, /* R17959 - ADCL_RETUNE_C20_0 */
  343. { 17960, 0x0000 }, /* R17960 - ADCL_RETUNE_C21_1 */
  344. { 17961, 0x0000 }, /* R17961 - ADCL_RETUNE_C21_0 */
  345. { 17962, 0x0000 }, /* R17962 - ADCL_RETUNE_C22_1 */
  346. { 17963, 0x0000 }, /* R17963 - ADCL_RETUNE_C22_0 */
  347. { 17964, 0x0000 }, /* R17964 - ADCL_RETUNE_C23_1 */
  348. { 17965, 0x0000 }, /* R17965 - ADCL_RETUNE_C23_0 */
  349. { 17966, 0x0000 }, /* R17966 - ADCL_RETUNE_C24_1 */
  350. { 17967, 0x0000 }, /* R17967 - ADCL_RETUNE_C24_0 */
  351. { 17968, 0x0000 }, /* R17968 - ADCL_RETUNE_C25_1 */
  352. { 17969, 0x0000 }, /* R17969 - ADCL_RETUNE_C25_0 */
  353. { 17970, 0x0000 }, /* R17970 - ADCL_RETUNE_C26_1 */
  354. { 17971, 0x0000 }, /* R17971 - ADCL_RETUNE_C26_0 */
  355. { 17972, 0x0000 }, /* R17972 - ADCL_RETUNE_C27_1 */
  356. { 17973, 0x0000 }, /* R17973 - ADCL_RETUNE_C27_0 */
  357. { 17974, 0x0000 }, /* R17974 - ADCL_RETUNE_C28_1 */
  358. { 17975, 0x0000 }, /* R17975 - ADCL_RETUNE_C28_0 */
  359. { 17976, 0x0000 }, /* R17976 - ADCL_RETUNE_C29_1 */
  360. { 17977, 0x0000 }, /* R17977 - ADCL_RETUNE_C29_0 */
  361. { 17978, 0x0000 }, /* R17978 - ADCL_RETUNE_C30_1 */
  362. { 17979, 0x0000 }, /* R17979 - ADCL_RETUNE_C30_0 */
  363. { 17980, 0x0000 }, /* R17980 - ADCL_RETUNE_C31_1 */
  364. { 17981, 0x0000 }, /* R17981 - ADCL_RETUNE_C31_0 */
  365. { 17982, 0x0000 }, /* R17982 - ADCL_RETUNE_C32_1 */
  366. { 17983, 0x0000 }, /* R17983 - ADCL_RETUNE_C32_0 */
  367. { 18432, 0x0020 }, /* R18432 - RETUNEADC_PG2_1 */
  368. { 18433, 0x0000 }, /* R18433 - RETUNEADC_PG2_0 */
  369. { 18434, 0x0040 }, /* R18434 - RETUNEADC_PG_1 */
  370. { 18435, 0x0000 }, /* R18435 - RETUNEADC_PG_0 */
  371. { 18944, 0x007F }, /* R18944 - ADCR_RETUNE_C1_1 */
  372. { 18945, 0xFFFF }, /* R18945 - ADCR_RETUNE_C1_0 */
  373. { 18946, 0x0000 }, /* R18946 - ADCR_RETUNE_C2_1 */
  374. { 18947, 0x0000 }, /* R18947 - ADCR_RETUNE_C2_0 */
  375. { 18948, 0x0000 }, /* R18948 - ADCR_RETUNE_C3_1 */
  376. { 18949, 0x0000 }, /* R18949 - ADCR_RETUNE_C3_0 */
  377. { 18950, 0x0000 }, /* R18950 - ADCR_RETUNE_C4_1 */
  378. { 18951, 0x0000 }, /* R18951 - ADCR_RETUNE_C4_0 */
  379. { 18952, 0x0000 }, /* R18952 - ADCR_RETUNE_C5_1 */
  380. { 18953, 0x0000 }, /* R18953 - ADCR_RETUNE_C5_0 */
  381. { 18954, 0x0000 }, /* R18954 - ADCR_RETUNE_C6_1 */
  382. { 18955, 0x0000 }, /* R18955 - ADCR_RETUNE_C6_0 */
  383. { 18956, 0x0000 }, /* R18956 - ADCR_RETUNE_C7_1 */
  384. { 18957, 0x0000 }, /* R18957 - ADCR_RETUNE_C7_0 */
  385. { 18958, 0x0000 }, /* R18958 - ADCR_RETUNE_C8_1 */
  386. { 18959, 0x0000 }, /* R18959 - ADCR_RETUNE_C8_0 */
  387. { 18960, 0x0000 }, /* R18960 - ADCR_RETUNE_C9_1 */
  388. { 18961, 0x0000 }, /* R18961 - ADCR_RETUNE_C9_0 */
  389. { 18962, 0x0000 }, /* R18962 - ADCR_RETUNE_C10_1 */
  390. { 18963, 0x0000 }, /* R18963 - ADCR_RETUNE_C10_0 */
  391. { 18964, 0x0000 }, /* R18964 - ADCR_RETUNE_C11_1 */
  392. { 18965, 0x0000 }, /* R18965 - ADCR_RETUNE_C11_0 */
  393. { 18966, 0x0000 }, /* R18966 - ADCR_RETUNE_C12_1 */
  394. { 18967, 0x0000 }, /* R18967 - ADCR_RETUNE_C12_0 */
  395. { 18968, 0x0000 }, /* R18968 - ADCR_RETUNE_C13_1 */
  396. { 18969, 0x0000 }, /* R18969 - ADCR_RETUNE_C13_0 */
  397. { 18970, 0x0000 }, /* R18970 - ADCR_RETUNE_C14_1 */
  398. { 18971, 0x0000 }, /* R18971 - ADCR_RETUNE_C14_0 */
  399. { 18972, 0x0000 }, /* R18972 - ADCR_RETUNE_C15_1 */
  400. { 18973, 0x0000 }, /* R18973 - ADCR_RETUNE_C15_0 */
  401. { 18974, 0x0000 }, /* R18974 - ADCR_RETUNE_C16_1 */
  402. { 18975, 0x0000 }, /* R18975 - ADCR_RETUNE_C16_0 */
  403. { 18976, 0x0000 }, /* R18976 - ADCR_RETUNE_C17_1 */
  404. { 18977, 0x0000 }, /* R18977 - ADCR_RETUNE_C17_0 */
  405. { 18978, 0x0000 }, /* R18978 - ADCR_RETUNE_C18_1 */
  406. { 18979, 0x0000 }, /* R18979 - ADCR_RETUNE_C18_0 */
  407. { 18980, 0x0000 }, /* R18980 - ADCR_RETUNE_C19_1 */
  408. { 18981, 0x0000 }, /* R18981 - ADCR_RETUNE_C19_0 */
  409. { 18982, 0x0000 }, /* R18982 - ADCR_RETUNE_C20_1 */
  410. { 18983, 0x0000 }, /* R18983 - ADCR_RETUNE_C20_0 */
  411. { 18984, 0x0000 }, /* R18984 - ADCR_RETUNE_C21_1 */
  412. { 18985, 0x0000 }, /* R18985 - ADCR_RETUNE_C21_0 */
  413. { 18986, 0x0000 }, /* R18986 - ADCR_RETUNE_C22_1 */
  414. { 18987, 0x0000 }, /* R18987 - ADCR_RETUNE_C22_0 */
  415. { 18988, 0x0000 }, /* R18988 - ADCR_RETUNE_C23_1 */
  416. { 18989, 0x0000 }, /* R18989 - ADCR_RETUNE_C23_0 */
  417. { 18990, 0x0000 }, /* R18990 - ADCR_RETUNE_C24_1 */
  418. { 18991, 0x0000 }, /* R18991 - ADCR_RETUNE_C24_0 */
  419. { 18992, 0x0000 }, /* R18992 - ADCR_RETUNE_C25_1 */
  420. { 18993, 0x0000 }, /* R18993 - ADCR_RETUNE_C25_0 */
  421. { 18994, 0x0000 }, /* R18994 - ADCR_RETUNE_C26_1 */
  422. { 18995, 0x0000 }, /* R18995 - ADCR_RETUNE_C26_0 */
  423. { 18996, 0x0000 }, /* R18996 - ADCR_RETUNE_C27_1 */
  424. { 18997, 0x0000 }, /* R18997 - ADCR_RETUNE_C27_0 */
  425. { 18998, 0x0000 }, /* R18998 - ADCR_RETUNE_C28_1 */
  426. { 18999, 0x0000 }, /* R18999 - ADCR_RETUNE_C28_0 */
  427. { 19000, 0x0000 }, /* R19000 - ADCR_RETUNE_C29_1 */
  428. { 19001, 0x0000 }, /* R19001 - ADCR_RETUNE_C29_0 */
  429. { 19002, 0x0000 }, /* R19002 - ADCR_RETUNE_C30_1 */
  430. { 19003, 0x0000 }, /* R19003 - ADCR_RETUNE_C30_0 */
  431. { 19004, 0x0000 }, /* R19004 - ADCR_RETUNE_C31_1 */
  432. { 19005, 0x0000 }, /* R19005 - ADCR_RETUNE_C31_0 */
  433. { 19006, 0x0000 }, /* R19006 - ADCR_RETUNE_C32_1 */
  434. { 19007, 0x0000 }, /* R19007 - ADCR_RETUNE_C32_0 */
  435. { 19456, 0x007F }, /* R19456 - DACL_RETUNE_C1_1 */
  436. { 19457, 0xFFFF }, /* R19457 - DACL_RETUNE_C1_0 */
  437. { 19458, 0x0000 }, /* R19458 - DACL_RETUNE_C2_1 */
  438. { 19459, 0x0000 }, /* R19459 - DACL_RETUNE_C2_0 */
  439. { 19460, 0x0000 }, /* R19460 - DACL_RETUNE_C3_1 */
  440. { 19461, 0x0000 }, /* R19461 - DACL_RETUNE_C3_0 */
  441. { 19462, 0x0000 }, /* R19462 - DACL_RETUNE_C4_1 */
  442. { 19463, 0x0000 }, /* R19463 - DACL_RETUNE_C4_0 */
  443. { 19464, 0x0000 }, /* R19464 - DACL_RETUNE_C5_1 */
  444. { 19465, 0x0000 }, /* R19465 - DACL_RETUNE_C5_0 */
  445. { 19466, 0x0000 }, /* R19466 - DACL_RETUNE_C6_1 */
  446. { 19467, 0x0000 }, /* R19467 - DACL_RETUNE_C6_0 */
  447. { 19468, 0x0000 }, /* R19468 - DACL_RETUNE_C7_1 */
  448. { 19469, 0x0000 }, /* R19469 - DACL_RETUNE_C7_0 */
  449. { 19470, 0x0000 }, /* R19470 - DACL_RETUNE_C8_1 */
  450. { 19471, 0x0000 }, /* R19471 - DACL_RETUNE_C8_0 */
  451. { 19472, 0x0000 }, /* R19472 - DACL_RETUNE_C9_1 */
  452. { 19473, 0x0000 }, /* R19473 - DACL_RETUNE_C9_0 */
  453. { 19474, 0x0000 }, /* R19474 - DACL_RETUNE_C10_1 */
  454. { 19475, 0x0000 }, /* R19475 - DACL_RETUNE_C10_0 */
  455. { 19476, 0x0000 }, /* R19476 - DACL_RETUNE_C11_1 */
  456. { 19477, 0x0000 }, /* R19477 - DACL_RETUNE_C11_0 */
  457. { 19478, 0x0000 }, /* R19478 - DACL_RETUNE_C12_1 */
  458. { 19479, 0x0000 }, /* R19479 - DACL_RETUNE_C12_0 */
  459. { 19480, 0x0000 }, /* R19480 - DACL_RETUNE_C13_1 */
  460. { 19481, 0x0000 }, /* R19481 - DACL_RETUNE_C13_0 */
  461. { 19482, 0x0000 }, /* R19482 - DACL_RETUNE_C14_1 */
  462. { 19483, 0x0000 }, /* R19483 - DACL_RETUNE_C14_0 */
  463. { 19484, 0x0000 }, /* R19484 - DACL_RETUNE_C15_1 */
  464. { 19485, 0x0000 }, /* R19485 - DACL_RETUNE_C15_0 */
  465. { 19486, 0x0000 }, /* R19486 - DACL_RETUNE_C16_1 */
  466. { 19487, 0x0000 }, /* R19487 - DACL_RETUNE_C16_0 */
  467. { 19488, 0x0000 }, /* R19488 - DACL_RETUNE_C17_1 */
  468. { 19489, 0x0000 }, /* R19489 - DACL_RETUNE_C17_0 */
  469. { 19490, 0x0000 }, /* R19490 - DACL_RETUNE_C18_1 */
  470. { 19491, 0x0000 }, /* R19491 - DACL_RETUNE_C18_0 */
  471. { 19492, 0x0000 }, /* R19492 - DACL_RETUNE_C19_1 */
  472. { 19493, 0x0000 }, /* R19493 - DACL_RETUNE_C19_0 */
  473. { 19494, 0x0000 }, /* R19494 - DACL_RETUNE_C20_1 */
  474. { 19495, 0x0000 }, /* R19495 - DACL_RETUNE_C20_0 */
  475. { 19496, 0x0000 }, /* R19496 - DACL_RETUNE_C21_1 */
  476. { 19497, 0x0000 }, /* R19497 - DACL_RETUNE_C21_0 */
  477. { 19498, 0x0000 }, /* R19498 - DACL_RETUNE_C22_1 */
  478. { 19499, 0x0000 }, /* R19499 - DACL_RETUNE_C22_0 */
  479. { 19500, 0x0000 }, /* R19500 - DACL_RETUNE_C23_1 */
  480. { 19501, 0x0000 }, /* R19501 - DACL_RETUNE_C23_0 */
  481. { 19502, 0x0000 }, /* R19502 - DACL_RETUNE_C24_1 */
  482. { 19503, 0x0000 }, /* R19503 - DACL_RETUNE_C24_0 */
  483. { 19504, 0x0000 }, /* R19504 - DACL_RETUNE_C25_1 */
  484. { 19505, 0x0000 }, /* R19505 - DACL_RETUNE_C25_0 */
  485. { 19506, 0x0000 }, /* R19506 - DACL_RETUNE_C26_1 */
  486. { 19507, 0x0000 }, /* R19507 - DACL_RETUNE_C26_0 */
  487. { 19508, 0x0000 }, /* R19508 - DACL_RETUNE_C27_1 */
  488. { 19509, 0x0000 }, /* R19509 - DACL_RETUNE_C27_0 */
  489. { 19510, 0x0000 }, /* R19510 - DACL_RETUNE_C28_1 */
  490. { 19511, 0x0000 }, /* R19511 - DACL_RETUNE_C28_0 */
  491. { 19512, 0x0000 }, /* R19512 - DACL_RETUNE_C29_1 */
  492. { 19513, 0x0000 }, /* R19513 - DACL_RETUNE_C29_0 */
  493. { 19514, 0x0000 }, /* R19514 - DACL_RETUNE_C30_1 */
  494. { 19515, 0x0000 }, /* R19515 - DACL_RETUNE_C30_0 */
  495. { 19516, 0x0000 }, /* R19516 - DACL_RETUNE_C31_1 */
  496. { 19517, 0x0000 }, /* R19517 - DACL_RETUNE_C31_0 */
  497. { 19518, 0x0000 }, /* R19518 - DACL_RETUNE_C32_1 */
  498. { 19519, 0x0000 }, /* R19519 - DACL_RETUNE_C32_0 */
  499. { 19968, 0x0020 }, /* R19968 - RETUNEDAC_PG2_1 */
  500. { 19969, 0x0000 }, /* R19969 - RETUNEDAC_PG2_0 */
  501. { 19970, 0x0040 }, /* R19970 - RETUNEDAC_PG_1 */
  502. { 19971, 0x0000 }, /* R19971 - RETUNEDAC_PG_0 */
  503. { 20480, 0x007F }, /* R20480 - DACR_RETUNE_C1_1 */
  504. { 20481, 0xFFFF }, /* R20481 - DACR_RETUNE_C1_0 */
  505. { 20482, 0x0000 }, /* R20482 - DACR_RETUNE_C2_1 */
  506. { 20483, 0x0000 }, /* R20483 - DACR_RETUNE_C2_0 */
  507. { 20484, 0x0000 }, /* R20484 - DACR_RETUNE_C3_1 */
  508. { 20485, 0x0000 }, /* R20485 - DACR_RETUNE_C3_0 */
  509. { 20486, 0x0000 }, /* R20486 - DACR_RETUNE_C4_1 */
  510. { 20487, 0x0000 }, /* R20487 - DACR_RETUNE_C4_0 */
  511. { 20488, 0x0000 }, /* R20488 - DACR_RETUNE_C5_1 */
  512. { 20489, 0x0000 }, /* R20489 - DACR_RETUNE_C5_0 */
  513. { 20490, 0x0000 }, /* R20490 - DACR_RETUNE_C6_1 */
  514. { 20491, 0x0000 }, /* R20491 - DACR_RETUNE_C6_0 */
  515. { 20492, 0x0000 }, /* R20492 - DACR_RETUNE_C7_1 */
  516. { 20493, 0x0000 }, /* R20493 - DACR_RETUNE_C7_0 */
  517. { 20494, 0x0000 }, /* R20494 - DACR_RETUNE_C8_1 */
  518. { 20495, 0x0000 }, /* R20495 - DACR_RETUNE_C8_0 */
  519. { 20496, 0x0000 }, /* R20496 - DACR_RETUNE_C9_1 */
  520. { 20497, 0x0000 }, /* R20497 - DACR_RETUNE_C9_0 */
  521. { 20498, 0x0000 }, /* R20498 - DACR_RETUNE_C10_1 */
  522. { 20499, 0x0000 }, /* R20499 - DACR_RETUNE_C10_0 */
  523. { 20500, 0x0000 }, /* R20500 - DACR_RETUNE_C11_1 */
  524. { 20501, 0x0000 }, /* R20501 - DACR_RETUNE_C11_0 */
  525. { 20502, 0x0000 }, /* R20502 - DACR_RETUNE_C12_1 */
  526. { 20503, 0x0000 }, /* R20503 - DACR_RETUNE_C12_0 */
  527. { 20504, 0x0000 }, /* R20504 - DACR_RETUNE_C13_1 */
  528. { 20505, 0x0000 }, /* R20505 - DACR_RETUNE_C13_0 */
  529. { 20506, 0x0000 }, /* R20506 - DACR_RETUNE_C14_1 */
  530. { 20507, 0x0000 }, /* R20507 - DACR_RETUNE_C14_0 */
  531. { 20508, 0x0000 }, /* R20508 - DACR_RETUNE_C15_1 */
  532. { 20509, 0x0000 }, /* R20509 - DACR_RETUNE_C15_0 */
  533. { 20510, 0x0000 }, /* R20510 - DACR_RETUNE_C16_1 */
  534. { 20511, 0x0000 }, /* R20511 - DACR_RETUNE_C16_0 */
  535. { 20512, 0x0000 }, /* R20512 - DACR_RETUNE_C17_1 */
  536. { 20513, 0x0000 }, /* R20513 - DACR_RETUNE_C17_0 */
  537. { 20514, 0x0000 }, /* R20514 - DACR_RETUNE_C18_1 */
  538. { 20515, 0x0000 }, /* R20515 - DACR_RETUNE_C18_0 */
  539. { 20516, 0x0000 }, /* R20516 - DACR_RETUNE_C19_1 */
  540. { 20517, 0x0000 }, /* R20517 - DACR_RETUNE_C19_0 */
  541. { 20518, 0x0000 }, /* R20518 - DACR_RETUNE_C20_1 */
  542. { 20519, 0x0000 }, /* R20519 - DACR_RETUNE_C20_0 */
  543. { 20520, 0x0000 }, /* R20520 - DACR_RETUNE_C21_1 */
  544. { 20521, 0x0000 }, /* R20521 - DACR_RETUNE_C21_0 */
  545. { 20522, 0x0000 }, /* R20522 - DACR_RETUNE_C22_1 */
  546. { 20523, 0x0000 }, /* R20523 - DACR_RETUNE_C22_0 */
  547. { 20524, 0x0000 }, /* R20524 - DACR_RETUNE_C23_1 */
  548. { 20525, 0x0000 }, /* R20525 - DACR_RETUNE_C23_0 */
  549. { 20526, 0x0000 }, /* R20526 - DACR_RETUNE_C24_1 */
  550. { 20527, 0x0000 }, /* R20527 - DACR_RETUNE_C24_0 */
  551. { 20528, 0x0000 }, /* R20528 - DACR_RETUNE_C25_1 */
  552. { 20529, 0x0000 }, /* R20529 - DACR_RETUNE_C25_0 */
  553. { 20530, 0x0000 }, /* R20530 - DACR_RETUNE_C26_1 */
  554. { 20531, 0x0000 }, /* R20531 - DACR_RETUNE_C26_0 */
  555. { 20532, 0x0000 }, /* R20532 - DACR_RETUNE_C27_1 */
  556. { 20533, 0x0000 }, /* R20533 - DACR_RETUNE_C27_0 */
  557. { 20534, 0x0000 }, /* R20534 - DACR_RETUNE_C28_1 */
  558. { 20535, 0x0000 }, /* R20535 - DACR_RETUNE_C28_0 */
  559. { 20536, 0x0000 }, /* R20536 - DACR_RETUNE_C29_1 */
  560. { 20537, 0x0000 }, /* R20537 - DACR_RETUNE_C29_0 */
  561. { 20538, 0x0000 }, /* R20538 - DACR_RETUNE_C30_1 */
  562. { 20539, 0x0000 }, /* R20539 - DACR_RETUNE_C30_0 */
  563. { 20540, 0x0000 }, /* R20540 - DACR_RETUNE_C31_1 */
  564. { 20541, 0x0000 }, /* R20541 - DACR_RETUNE_C31_0 */
  565. { 20542, 0x0000 }, /* R20542 - DACR_RETUNE_C32_1 */
  566. { 20543, 0x0000 }, /* R20543 - DACR_RETUNE_C32_0 */
  567. { 20992, 0x008C }, /* R20992 - VSS_XHD2_1 */
  568. { 20993, 0x0200 }, /* R20993 - VSS_XHD2_0 */
  569. { 20994, 0x0035 }, /* R20994 - VSS_XHD3_1 */
  570. { 20995, 0x0700 }, /* R20995 - VSS_XHD3_0 */
  571. { 20996, 0x003A }, /* R20996 - VSS_XHN1_1 */
  572. { 20997, 0x4100 }, /* R20997 - VSS_XHN1_0 */
  573. { 20998, 0x008B }, /* R20998 - VSS_XHN2_1 */
  574. { 20999, 0x7D00 }, /* R20999 - VSS_XHN2_0 */
  575. { 21000, 0x003A }, /* R21000 - VSS_XHN3_1 */
  576. { 21001, 0x4100 }, /* R21001 - VSS_XHN3_0 */
  577. { 21002, 0x008C }, /* R21002 - VSS_XLA_1 */
  578. { 21003, 0xFEE8 }, /* R21003 - VSS_XLA_0 */
  579. { 21004, 0x0078 }, /* R21004 - VSS_XLB_1 */
  580. { 21005, 0x0000 }, /* R21005 - VSS_XLB_0 */
  581. { 21006, 0x003F }, /* R21006 - VSS_XLG_1 */
  582. { 21007, 0xB260 }, /* R21007 - VSS_XLG_0 */
  583. { 21008, 0x002D }, /* R21008 - VSS_PG2_1 */
  584. { 21009, 0x1818 }, /* R21009 - VSS_PG2_0 */
  585. { 21010, 0x0020 }, /* R21010 - VSS_PG_1 */
  586. { 21011, 0x0000 }, /* R21011 - VSS_PG_0 */
  587. { 21012, 0x00F1 }, /* R21012 - VSS_XTD1_1 */
  588. { 21013, 0x8340 }, /* R21013 - VSS_XTD1_0 */
  589. { 21014, 0x00FB }, /* R21014 - VSS_XTD2_1 */
  590. { 21015, 0x8300 }, /* R21015 - VSS_XTD2_0 */
  591. { 21016, 0x00EE }, /* R21016 - VSS_XTD3_1 */
  592. { 21017, 0xAEC0 }, /* R21017 - VSS_XTD3_0 */
  593. { 21018, 0x00FB }, /* R21018 - VSS_XTD4_1 */
  594. { 21019, 0xAC40 }, /* R21019 - VSS_XTD4_0 */
  595. { 21020, 0x00F1 }, /* R21020 - VSS_XTD5_1 */
  596. { 21021, 0x7F80 }, /* R21021 - VSS_XTD5_0 */
  597. { 21022, 0x00F4 }, /* R21022 - VSS_XTD6_1 */
  598. { 21023, 0x3B40 }, /* R21023 - VSS_XTD6_0 */
  599. { 21024, 0x00F5 }, /* R21024 - VSS_XTD7_1 */
  600. { 21025, 0xFB00 }, /* R21025 - VSS_XTD7_0 */
  601. { 21026, 0x00EA }, /* R21026 - VSS_XTD8_1 */
  602. { 21027, 0x10C0 }, /* R21027 - VSS_XTD8_0 */
  603. { 21028, 0x00FC }, /* R21028 - VSS_XTD9_1 */
  604. { 21029, 0xC580 }, /* R21029 - VSS_XTD9_0 */
  605. { 21030, 0x00E2 }, /* R21030 - VSS_XTD10_1 */
  606. { 21031, 0x75C0 }, /* R21031 - VSS_XTD10_0 */
  607. { 21032, 0x0004 }, /* R21032 - VSS_XTD11_1 */
  608. { 21033, 0xB480 }, /* R21033 - VSS_XTD11_0 */
  609. { 21034, 0x00D4 }, /* R21034 - VSS_XTD12_1 */
  610. { 21035, 0xF980 }, /* R21035 - VSS_XTD12_0 */
  611. { 21036, 0x0004 }, /* R21036 - VSS_XTD13_1 */
  612. { 21037, 0x9140 }, /* R21037 - VSS_XTD13_0 */
  613. { 21038, 0x00D8 }, /* R21038 - VSS_XTD14_1 */
  614. { 21039, 0xA480 }, /* R21039 - VSS_XTD14_0 */
  615. { 21040, 0x0002 }, /* R21040 - VSS_XTD15_1 */
  616. { 21041, 0x3DC0 }, /* R21041 - VSS_XTD15_0 */
  617. { 21042, 0x00CF }, /* R21042 - VSS_XTD16_1 */
  618. { 21043, 0x7A80 }, /* R21043 - VSS_XTD16_0 */
  619. { 21044, 0x00DC }, /* R21044 - VSS_XTD17_1 */
  620. { 21045, 0x0600 }, /* R21045 - VSS_XTD17_0 */
  621. { 21046, 0x00F2 }, /* R21046 - VSS_XTD18_1 */
  622. { 21047, 0xDAC0 }, /* R21047 - VSS_XTD18_0 */
  623. { 21048, 0x00BA }, /* R21048 - VSS_XTD19_1 */
  624. { 21049, 0xF340 }, /* R21049 - VSS_XTD19_0 */
  625. { 21050, 0x000A }, /* R21050 - VSS_XTD20_1 */
  626. { 21051, 0x7940 }, /* R21051 - VSS_XTD20_0 */
  627. { 21052, 0x001C }, /* R21052 - VSS_XTD21_1 */
  628. { 21053, 0x0680 }, /* R21053 - VSS_XTD21_0 */
  629. { 21054, 0x00FD }, /* R21054 - VSS_XTD22_1 */
  630. { 21055, 0x2D00 }, /* R21055 - VSS_XTD22_0 */
  631. { 21056, 0x001C }, /* R21056 - VSS_XTD23_1 */
  632. { 21057, 0xE840 }, /* R21057 - VSS_XTD23_0 */
  633. { 21058, 0x000D }, /* R21058 - VSS_XTD24_1 */
  634. { 21059, 0xDC40 }, /* R21059 - VSS_XTD24_0 */
  635. { 21060, 0x00FC }, /* R21060 - VSS_XTD25_1 */
  636. { 21061, 0x9D00 }, /* R21061 - VSS_XTD25_0 */
  637. { 21062, 0x0009 }, /* R21062 - VSS_XTD26_1 */
  638. { 21063, 0x5580 }, /* R21063 - VSS_XTD26_0 */
  639. { 21064, 0x00FE }, /* R21064 - VSS_XTD27_1 */
  640. { 21065, 0x7E80 }, /* R21065 - VSS_XTD27_0 */
  641. { 21066, 0x000E }, /* R21066 - VSS_XTD28_1 */
  642. { 21067, 0xAB40 }, /* R21067 - VSS_XTD28_0 */
  643. { 21068, 0x00F9 }, /* R21068 - VSS_XTD29_1 */
  644. { 21069, 0x9880 }, /* R21069 - VSS_XTD29_0 */
  645. { 21070, 0x0009 }, /* R21070 - VSS_XTD30_1 */
  646. { 21071, 0x87C0 }, /* R21071 - VSS_XTD30_0 */
  647. { 21072, 0x00FD }, /* R21072 - VSS_XTD31_1 */
  648. { 21073, 0x2C40 }, /* R21073 - VSS_XTD31_0 */
  649. { 21074, 0x0009 }, /* R21074 - VSS_XTD32_1 */
  650. { 21075, 0x4800 }, /* R21075 - VSS_XTD32_0 */
  651. { 21076, 0x0003 }, /* R21076 - VSS_XTS1_1 */
  652. { 21077, 0x5F40 }, /* R21077 - VSS_XTS1_0 */
  653. { 21078, 0x0000 }, /* R21078 - VSS_XTS2_1 */
  654. { 21079, 0x8700 }, /* R21079 - VSS_XTS2_0 */
  655. { 21080, 0x00FA }, /* R21080 - VSS_XTS3_1 */
  656. { 21081, 0xE4C0 }, /* R21081 - VSS_XTS3_0 */
  657. { 21082, 0x0000 }, /* R21082 - VSS_XTS4_1 */
  658. { 21083, 0x0B40 }, /* R21083 - VSS_XTS4_0 */
  659. { 21084, 0x0004 }, /* R21084 - VSS_XTS5_1 */
  660. { 21085, 0xE180 }, /* R21085 - VSS_XTS5_0 */
  661. { 21086, 0x0001 }, /* R21086 - VSS_XTS6_1 */
  662. { 21087, 0x1F40 }, /* R21087 - VSS_XTS6_0 */
  663. { 21088, 0x00F8 }, /* R21088 - VSS_XTS7_1 */
  664. { 21089, 0xB000 }, /* R21089 - VSS_XTS7_0 */
  665. { 21090, 0x00FB }, /* R21090 - VSS_XTS8_1 */
  666. { 21091, 0xCBC0 }, /* R21091 - VSS_XTS8_0 */
  667. { 21092, 0x0004 }, /* R21092 - VSS_XTS9_1 */
  668. { 21093, 0xF380 }, /* R21093 - VSS_XTS9_0 */
  669. { 21094, 0x0007 }, /* R21094 - VSS_XTS10_1 */
  670. { 21095, 0xDF40 }, /* R21095 - VSS_XTS10_0 */
  671. { 21096, 0x00FF }, /* R21096 - VSS_XTS11_1 */
  672. { 21097, 0x0700 }, /* R21097 - VSS_XTS11_0 */
  673. { 21098, 0x00EF }, /* R21098 - VSS_XTS12_1 */
  674. { 21099, 0xD700 }, /* R21099 - VSS_XTS12_0 */
  675. { 21100, 0x00FB }, /* R21100 - VSS_XTS13_1 */
  676. { 21101, 0xAF40 }, /* R21101 - VSS_XTS13_0 */
  677. { 21102, 0x0010 }, /* R21102 - VSS_XTS14_1 */
  678. { 21103, 0x8A80 }, /* R21103 - VSS_XTS14_0 */
  679. { 21104, 0x0011 }, /* R21104 - VSS_XTS15_1 */
  680. { 21105, 0x07C0 }, /* R21105 - VSS_XTS15_0 */
  681. { 21106, 0x00E0 }, /* R21106 - VSS_XTS16_1 */
  682. { 21107, 0x0800 }, /* R21107 - VSS_XTS16_0 */
  683. { 21108, 0x00D2 }, /* R21108 - VSS_XTS17_1 */
  684. { 21109, 0x7600 }, /* R21109 - VSS_XTS17_0 */
  685. { 21110, 0x0020 }, /* R21110 - VSS_XTS18_1 */
  686. { 21111, 0xCF40 }, /* R21111 - VSS_XTS18_0 */
  687. { 21112, 0x0030 }, /* R21112 - VSS_XTS19_1 */
  688. { 21113, 0x2340 }, /* R21113 - VSS_XTS19_0 */
  689. { 21114, 0x00FD }, /* R21114 - VSS_XTS20_1 */
  690. { 21115, 0x69C0 }, /* R21115 - VSS_XTS20_0 */
  691. { 21116, 0x0028 }, /* R21116 - VSS_XTS21_1 */
  692. { 21117, 0x3500 }, /* R21117 - VSS_XTS21_0 */
  693. { 21118, 0x0006 }, /* R21118 - VSS_XTS22_1 */
  694. { 21119, 0x3300 }, /* R21119 - VSS_XTS22_0 */
  695. { 21120, 0x00D9 }, /* R21120 - VSS_XTS23_1 */
  696. { 21121, 0xF6C0 }, /* R21121 - VSS_XTS23_0 */
  697. { 21122, 0x00F3 }, /* R21122 - VSS_XTS24_1 */
  698. { 21123, 0x3340 }, /* R21123 - VSS_XTS24_0 */
  699. { 21124, 0x000F }, /* R21124 - VSS_XTS25_1 */
  700. { 21125, 0x4200 }, /* R21125 - VSS_XTS25_0 */
  701. { 21126, 0x0004 }, /* R21126 - VSS_XTS26_1 */
  702. { 21127, 0x0C80 }, /* R21127 - VSS_XTS26_0 */
  703. { 21128, 0x00FB }, /* R21128 - VSS_XTS27_1 */
  704. { 21129, 0x3F80 }, /* R21129 - VSS_XTS27_0 */
  705. { 21130, 0x00F7 }, /* R21130 - VSS_XTS28_1 */
  706. { 21131, 0x57C0 }, /* R21131 - VSS_XTS28_0 */
  707. { 21132, 0x0003 }, /* R21132 - VSS_XTS29_1 */
  708. { 21133, 0x5400 }, /* R21133 - VSS_XTS29_0 */
  709. { 21134, 0x0000 }, /* R21134 - VSS_XTS30_1 */
  710. { 21135, 0xC6C0 }, /* R21135 - VSS_XTS30_0 */
  711. { 21136, 0x0003 }, /* R21136 - VSS_XTS31_1 */
  712. { 21137, 0x12C0 }, /* R21137 - VSS_XTS31_0 */
  713. { 21138, 0x00FD }, /* R21138 - VSS_XTS32_1 */
  714. { 21139, 0x8580 }, /* R21139 - VSS_XTS32_0 */
  715. };
  716. static bool wm8962_volatile_register(struct device *dev, unsigned int reg)
  717. {
  718. switch (reg) {
  719. case WM8962_CLOCKING1:
  720. case WM8962_SOFTWARE_RESET:
  721. case WM8962_THERMAL_SHUTDOWN_STATUS:
  722. case WM8962_ADDITIONAL_CONTROL_4:
  723. case WM8962_DC_SERVO_6:
  724. case WM8962_INTERRUPT_STATUS_1:
  725. case WM8962_INTERRUPT_STATUS_2:
  726. case WM8962_DSP2_EXECCONTROL:
  727. return true;
  728. default:
  729. return false;
  730. }
  731. }
  732. static bool wm8962_readable_register(struct device *dev, unsigned int reg)
  733. {
  734. switch (reg) {
  735. case WM8962_LEFT_INPUT_VOLUME:
  736. case WM8962_RIGHT_INPUT_VOLUME:
  737. case WM8962_HPOUTL_VOLUME:
  738. case WM8962_HPOUTR_VOLUME:
  739. case WM8962_CLOCKING1:
  740. case WM8962_ADC_DAC_CONTROL_1:
  741. case WM8962_ADC_DAC_CONTROL_2:
  742. case WM8962_AUDIO_INTERFACE_0:
  743. case WM8962_CLOCKING2:
  744. case WM8962_AUDIO_INTERFACE_1:
  745. case WM8962_LEFT_DAC_VOLUME:
  746. case WM8962_RIGHT_DAC_VOLUME:
  747. case WM8962_AUDIO_INTERFACE_2:
  748. case WM8962_SOFTWARE_RESET:
  749. case WM8962_ALC1:
  750. case WM8962_ALC2:
  751. case WM8962_ALC3:
  752. case WM8962_NOISE_GATE:
  753. case WM8962_LEFT_ADC_VOLUME:
  754. case WM8962_RIGHT_ADC_VOLUME:
  755. case WM8962_ADDITIONAL_CONTROL_1:
  756. case WM8962_ADDITIONAL_CONTROL_2:
  757. case WM8962_PWR_MGMT_1:
  758. case WM8962_PWR_MGMT_2:
  759. case WM8962_ADDITIONAL_CONTROL_3:
  760. case WM8962_ANTI_POP:
  761. case WM8962_CLOCKING_3:
  762. case WM8962_INPUT_MIXER_CONTROL_1:
  763. case WM8962_LEFT_INPUT_MIXER_VOLUME:
  764. case WM8962_RIGHT_INPUT_MIXER_VOLUME:
  765. case WM8962_INPUT_MIXER_CONTROL_2:
  766. case WM8962_INPUT_BIAS_CONTROL:
  767. case WM8962_LEFT_INPUT_PGA_CONTROL:
  768. case WM8962_RIGHT_INPUT_PGA_CONTROL:
  769. case WM8962_SPKOUTL_VOLUME:
  770. case WM8962_SPKOUTR_VOLUME:
  771. case WM8962_THERMAL_SHUTDOWN_STATUS:
  772. case WM8962_ADDITIONAL_CONTROL_4:
  773. case WM8962_CLASS_D_CONTROL_1:
  774. case WM8962_CLASS_D_CONTROL_2:
  775. case WM8962_CLOCKING_4:
  776. case WM8962_DAC_DSP_MIXING_1:
  777. case WM8962_DAC_DSP_MIXING_2:
  778. case WM8962_DC_SERVO_0:
  779. case WM8962_DC_SERVO_1:
  780. case WM8962_DC_SERVO_4:
  781. case WM8962_DC_SERVO_6:
  782. case WM8962_ANALOGUE_PGA_BIAS:
  783. case WM8962_ANALOGUE_HP_0:
  784. case WM8962_ANALOGUE_HP_2:
  785. case WM8962_CHARGE_PUMP_1:
  786. case WM8962_CHARGE_PUMP_B:
  787. case WM8962_WRITE_SEQUENCER_CONTROL_1:
  788. case WM8962_WRITE_SEQUENCER_CONTROL_2:
  789. case WM8962_WRITE_SEQUENCER_CONTROL_3:
  790. case WM8962_CONTROL_INTERFACE:
  791. case WM8962_MIXER_ENABLES:
  792. case WM8962_HEADPHONE_MIXER_1:
  793. case WM8962_HEADPHONE_MIXER_2:
  794. case WM8962_HEADPHONE_MIXER_3:
  795. case WM8962_HEADPHONE_MIXER_4:
  796. case WM8962_SPEAKER_MIXER_1:
  797. case WM8962_SPEAKER_MIXER_2:
  798. case WM8962_SPEAKER_MIXER_3:
  799. case WM8962_SPEAKER_MIXER_4:
  800. case WM8962_SPEAKER_MIXER_5:
  801. case WM8962_BEEP_GENERATOR_1:
  802. case WM8962_OSCILLATOR_TRIM_3:
  803. case WM8962_OSCILLATOR_TRIM_4:
  804. case WM8962_OSCILLATOR_TRIM_7:
  805. case WM8962_ANALOGUE_CLOCKING1:
  806. case WM8962_ANALOGUE_CLOCKING2:
  807. case WM8962_ANALOGUE_CLOCKING3:
  808. case WM8962_PLL_SOFTWARE_RESET:
  809. case WM8962_PLL2:
  810. case WM8962_PLL_4:
  811. case WM8962_PLL_9:
  812. case WM8962_PLL_10:
  813. case WM8962_PLL_11:
  814. case WM8962_PLL_12:
  815. case WM8962_PLL_13:
  816. case WM8962_PLL_14:
  817. case WM8962_PLL_15:
  818. case WM8962_PLL_16:
  819. case WM8962_FLL_CONTROL_1:
  820. case WM8962_FLL_CONTROL_2:
  821. case WM8962_FLL_CONTROL_3:
  822. case WM8962_FLL_CONTROL_5:
  823. case WM8962_FLL_CONTROL_6:
  824. case WM8962_FLL_CONTROL_7:
  825. case WM8962_FLL_CONTROL_8:
  826. case WM8962_GENERAL_TEST_1:
  827. case WM8962_DF1:
  828. case WM8962_DF2:
  829. case WM8962_DF3:
  830. case WM8962_DF4:
  831. case WM8962_DF5:
  832. case WM8962_DF6:
  833. case WM8962_DF7:
  834. case WM8962_LHPF1:
  835. case WM8962_LHPF2:
  836. case WM8962_THREED1:
  837. case WM8962_THREED2:
  838. case WM8962_THREED3:
  839. case WM8962_THREED4:
  840. case WM8962_DRC_1:
  841. case WM8962_DRC_2:
  842. case WM8962_DRC_3:
  843. case WM8962_DRC_4:
  844. case WM8962_DRC_5:
  845. case WM8962_TLOOPBACK:
  846. case WM8962_EQ1:
  847. case WM8962_EQ2:
  848. case WM8962_EQ3:
  849. case WM8962_EQ4:
  850. case WM8962_EQ5:
  851. case WM8962_EQ6:
  852. case WM8962_EQ7:
  853. case WM8962_EQ8:
  854. case WM8962_EQ9:
  855. case WM8962_EQ10:
  856. case WM8962_EQ11:
  857. case WM8962_EQ12:
  858. case WM8962_EQ13:
  859. case WM8962_EQ14:
  860. case WM8962_EQ15:
  861. case WM8962_EQ16:
  862. case WM8962_EQ17:
  863. case WM8962_EQ18:
  864. case WM8962_EQ19:
  865. case WM8962_EQ20:
  866. case WM8962_EQ21:
  867. case WM8962_EQ22:
  868. case WM8962_EQ23:
  869. case WM8962_EQ24:
  870. case WM8962_EQ25:
  871. case WM8962_EQ26:
  872. case WM8962_EQ27:
  873. case WM8962_EQ28:
  874. case WM8962_EQ29:
  875. case WM8962_EQ30:
  876. case WM8962_EQ31:
  877. case WM8962_EQ32:
  878. case WM8962_EQ33:
  879. case WM8962_EQ34:
  880. case WM8962_EQ35:
  881. case WM8962_EQ36:
  882. case WM8962_EQ37:
  883. case WM8962_EQ38:
  884. case WM8962_EQ39:
  885. case WM8962_EQ40:
  886. case WM8962_EQ41:
  887. case WM8962_GPIO_2:
  888. case WM8962_GPIO_3:
  889. case WM8962_GPIO_5:
  890. case WM8962_GPIO_6:
  891. case WM8962_INTERRUPT_STATUS_1:
  892. case WM8962_INTERRUPT_STATUS_2:
  893. case WM8962_INTERRUPT_STATUS_1_MASK:
  894. case WM8962_INTERRUPT_STATUS_2_MASK:
  895. case WM8962_INTERRUPT_CONTROL:
  896. case WM8962_IRQ_DEBOUNCE:
  897. case WM8962_MICINT_SOURCE_POL:
  898. case WM8962_DSP2_POWER_MANAGEMENT:
  899. case WM8962_DSP2_EXECCONTROL:
  900. case WM8962_DSP2_INSTRUCTION_RAM_0:
  901. case WM8962_DSP2_ADDRESS_RAM_2:
  902. case WM8962_DSP2_ADDRESS_RAM_1:
  903. case WM8962_DSP2_ADDRESS_RAM_0:
  904. case WM8962_DSP2_DATA1_RAM_1:
  905. case WM8962_DSP2_DATA1_RAM_0:
  906. case WM8962_DSP2_DATA2_RAM_1:
  907. case WM8962_DSP2_DATA2_RAM_0:
  908. case WM8962_DSP2_DATA3_RAM_1:
  909. case WM8962_DSP2_DATA3_RAM_0:
  910. case WM8962_DSP2_COEFF_RAM_0:
  911. case WM8962_RETUNEADC_SHARED_COEFF_1:
  912. case WM8962_RETUNEADC_SHARED_COEFF_0:
  913. case WM8962_RETUNEDAC_SHARED_COEFF_1:
  914. case WM8962_RETUNEDAC_SHARED_COEFF_0:
  915. case WM8962_SOUNDSTAGE_ENABLES_1:
  916. case WM8962_SOUNDSTAGE_ENABLES_0:
  917. case WM8962_HDBASS_AI_1:
  918. case WM8962_HDBASS_AI_0:
  919. case WM8962_HDBASS_AR_1:
  920. case WM8962_HDBASS_AR_0:
  921. case WM8962_HDBASS_B_1:
  922. case WM8962_HDBASS_B_0:
  923. case WM8962_HDBASS_K_1:
  924. case WM8962_HDBASS_K_0:
  925. case WM8962_HDBASS_N1_1:
  926. case WM8962_HDBASS_N1_0:
  927. case WM8962_HDBASS_N2_1:
  928. case WM8962_HDBASS_N2_0:
  929. case WM8962_HDBASS_N3_1:
  930. case WM8962_HDBASS_N3_0:
  931. case WM8962_HDBASS_N4_1:
  932. case WM8962_HDBASS_N4_0:
  933. case WM8962_HDBASS_N5_1:
  934. case WM8962_HDBASS_N5_0:
  935. case WM8962_HDBASS_X1_1:
  936. case WM8962_HDBASS_X1_0:
  937. case WM8962_HDBASS_X2_1:
  938. case WM8962_HDBASS_X2_0:
  939. case WM8962_HDBASS_X3_1:
  940. case WM8962_HDBASS_X3_0:
  941. case WM8962_HDBASS_ATK_1:
  942. case WM8962_HDBASS_ATK_0:
  943. case WM8962_HDBASS_DCY_1:
  944. case WM8962_HDBASS_DCY_0:
  945. case WM8962_HDBASS_PG_1:
  946. case WM8962_HDBASS_PG_0:
  947. case WM8962_HPF_C_1:
  948. case WM8962_HPF_C_0:
  949. case WM8962_ADCL_RETUNE_C1_1:
  950. case WM8962_ADCL_RETUNE_C1_0:
  951. case WM8962_ADCL_RETUNE_C2_1:
  952. case WM8962_ADCL_RETUNE_C2_0:
  953. case WM8962_ADCL_RETUNE_C3_1:
  954. case WM8962_ADCL_RETUNE_C3_0:
  955. case WM8962_ADCL_RETUNE_C4_1:
  956. case WM8962_ADCL_RETUNE_C4_0:
  957. case WM8962_ADCL_RETUNE_C5_1:
  958. case WM8962_ADCL_RETUNE_C5_0:
  959. case WM8962_ADCL_RETUNE_C6_1:
  960. case WM8962_ADCL_RETUNE_C6_0:
  961. case WM8962_ADCL_RETUNE_C7_1:
  962. case WM8962_ADCL_RETUNE_C7_0:
  963. case WM8962_ADCL_RETUNE_C8_1:
  964. case WM8962_ADCL_RETUNE_C8_0:
  965. case WM8962_ADCL_RETUNE_C9_1:
  966. case WM8962_ADCL_RETUNE_C9_0:
  967. case WM8962_ADCL_RETUNE_C10_1:
  968. case WM8962_ADCL_RETUNE_C10_0:
  969. case WM8962_ADCL_RETUNE_C11_1:
  970. case WM8962_ADCL_RETUNE_C11_0:
  971. case WM8962_ADCL_RETUNE_C12_1:
  972. case WM8962_ADCL_RETUNE_C12_0:
  973. case WM8962_ADCL_RETUNE_C13_1:
  974. case WM8962_ADCL_RETUNE_C13_0:
  975. case WM8962_ADCL_RETUNE_C14_1:
  976. case WM8962_ADCL_RETUNE_C14_0:
  977. case WM8962_ADCL_RETUNE_C15_1:
  978. case WM8962_ADCL_RETUNE_C15_0:
  979. case WM8962_ADCL_RETUNE_C16_1:
  980. case WM8962_ADCL_RETUNE_C16_0:
  981. case WM8962_ADCL_RETUNE_C17_1:
  982. case WM8962_ADCL_RETUNE_C17_0:
  983. case WM8962_ADCL_RETUNE_C18_1:
  984. case WM8962_ADCL_RETUNE_C18_0:
  985. case WM8962_ADCL_RETUNE_C19_1:
  986. case WM8962_ADCL_RETUNE_C19_0:
  987. case WM8962_ADCL_RETUNE_C20_1:
  988. case WM8962_ADCL_RETUNE_C20_0:
  989. case WM8962_ADCL_RETUNE_C21_1:
  990. case WM8962_ADCL_RETUNE_C21_0:
  991. case WM8962_ADCL_RETUNE_C22_1:
  992. case WM8962_ADCL_RETUNE_C22_0:
  993. case WM8962_ADCL_RETUNE_C23_1:
  994. case WM8962_ADCL_RETUNE_C23_0:
  995. case WM8962_ADCL_RETUNE_C24_1:
  996. case WM8962_ADCL_RETUNE_C24_0:
  997. case WM8962_ADCL_RETUNE_C25_1:
  998. case WM8962_ADCL_RETUNE_C25_0:
  999. case WM8962_ADCL_RETUNE_C26_1:
  1000. case WM8962_ADCL_RETUNE_C26_0:
  1001. case WM8962_ADCL_RETUNE_C27_1:
  1002. case WM8962_ADCL_RETUNE_C27_0:
  1003. case WM8962_ADCL_RETUNE_C28_1:
  1004. case WM8962_ADCL_RETUNE_C28_0:
  1005. case WM8962_ADCL_RETUNE_C29_1:
  1006. case WM8962_ADCL_RETUNE_C29_0:
  1007. case WM8962_ADCL_RETUNE_C30_1:
  1008. case WM8962_ADCL_RETUNE_C30_0:
  1009. case WM8962_ADCL_RETUNE_C31_1:
  1010. case WM8962_ADCL_RETUNE_C31_0:
  1011. case WM8962_ADCL_RETUNE_C32_1:
  1012. case WM8962_ADCL_RETUNE_C32_0:
  1013. case WM8962_RETUNEADC_PG2_1:
  1014. case WM8962_RETUNEADC_PG2_0:
  1015. case WM8962_RETUNEADC_PG_1:
  1016. case WM8962_RETUNEADC_PG_0:
  1017. case WM8962_ADCR_RETUNE_C1_1:
  1018. case WM8962_ADCR_RETUNE_C1_0:
  1019. case WM8962_ADCR_RETUNE_C2_1:
  1020. case WM8962_ADCR_RETUNE_C2_0:
  1021. case WM8962_ADCR_RETUNE_C3_1:
  1022. case WM8962_ADCR_RETUNE_C3_0:
  1023. case WM8962_ADCR_RETUNE_C4_1:
  1024. case WM8962_ADCR_RETUNE_C4_0:
  1025. case WM8962_ADCR_RETUNE_C5_1:
  1026. case WM8962_ADCR_RETUNE_C5_0:
  1027. case WM8962_ADCR_RETUNE_C6_1:
  1028. case WM8962_ADCR_RETUNE_C6_0:
  1029. case WM8962_ADCR_RETUNE_C7_1:
  1030. case WM8962_ADCR_RETUNE_C7_0:
  1031. case WM8962_ADCR_RETUNE_C8_1:
  1032. case WM8962_ADCR_RETUNE_C8_0:
  1033. case WM8962_ADCR_RETUNE_C9_1:
  1034. case WM8962_ADCR_RETUNE_C9_0:
  1035. case WM8962_ADCR_RETUNE_C10_1:
  1036. case WM8962_ADCR_RETUNE_C10_0:
  1037. case WM8962_ADCR_RETUNE_C11_1:
  1038. case WM8962_ADCR_RETUNE_C11_0:
  1039. case WM8962_ADCR_RETUNE_C12_1:
  1040. case WM8962_ADCR_RETUNE_C12_0:
  1041. case WM8962_ADCR_RETUNE_C13_1:
  1042. case WM8962_ADCR_RETUNE_C13_0:
  1043. case WM8962_ADCR_RETUNE_C14_1:
  1044. case WM8962_ADCR_RETUNE_C14_0:
  1045. case WM8962_ADCR_RETUNE_C15_1:
  1046. case WM8962_ADCR_RETUNE_C15_0:
  1047. case WM8962_ADCR_RETUNE_C16_1:
  1048. case WM8962_ADCR_RETUNE_C16_0:
  1049. case WM8962_ADCR_RETUNE_C17_1:
  1050. case WM8962_ADCR_RETUNE_C17_0:
  1051. case WM8962_ADCR_RETUNE_C18_1:
  1052. case WM8962_ADCR_RETUNE_C18_0:
  1053. case WM8962_ADCR_RETUNE_C19_1:
  1054. case WM8962_ADCR_RETUNE_C19_0:
  1055. case WM8962_ADCR_RETUNE_C20_1:
  1056. case WM8962_ADCR_RETUNE_C20_0:
  1057. case WM8962_ADCR_RETUNE_C21_1:
  1058. case WM8962_ADCR_RETUNE_C21_0:
  1059. case WM8962_ADCR_RETUNE_C22_1:
  1060. case WM8962_ADCR_RETUNE_C22_0:
  1061. case WM8962_ADCR_RETUNE_C23_1:
  1062. case WM8962_ADCR_RETUNE_C23_0:
  1063. case WM8962_ADCR_RETUNE_C24_1:
  1064. case WM8962_ADCR_RETUNE_C24_0:
  1065. case WM8962_ADCR_RETUNE_C25_1:
  1066. case WM8962_ADCR_RETUNE_C25_0:
  1067. case WM8962_ADCR_RETUNE_C26_1:
  1068. case WM8962_ADCR_RETUNE_C26_0:
  1069. case WM8962_ADCR_RETUNE_C27_1:
  1070. case WM8962_ADCR_RETUNE_C27_0:
  1071. case WM8962_ADCR_RETUNE_C28_1:
  1072. case WM8962_ADCR_RETUNE_C28_0:
  1073. case WM8962_ADCR_RETUNE_C29_1:
  1074. case WM8962_ADCR_RETUNE_C29_0:
  1075. case WM8962_ADCR_RETUNE_C30_1:
  1076. case WM8962_ADCR_RETUNE_C30_0:
  1077. case WM8962_ADCR_RETUNE_C31_1:
  1078. case WM8962_ADCR_RETUNE_C31_0:
  1079. case WM8962_ADCR_RETUNE_C32_1:
  1080. case WM8962_ADCR_RETUNE_C32_0:
  1081. case WM8962_DACL_RETUNE_C1_1:
  1082. case WM8962_DACL_RETUNE_C1_0:
  1083. case WM8962_DACL_RETUNE_C2_1:
  1084. case WM8962_DACL_RETUNE_C2_0:
  1085. case WM8962_DACL_RETUNE_C3_1:
  1086. case WM8962_DACL_RETUNE_C3_0:
  1087. case WM8962_DACL_RETUNE_C4_1:
  1088. case WM8962_DACL_RETUNE_C4_0:
  1089. case WM8962_DACL_RETUNE_C5_1:
  1090. case WM8962_DACL_RETUNE_C5_0:
  1091. case WM8962_DACL_RETUNE_C6_1:
  1092. case WM8962_DACL_RETUNE_C6_0:
  1093. case WM8962_DACL_RETUNE_C7_1:
  1094. case WM8962_DACL_RETUNE_C7_0:
  1095. case WM8962_DACL_RETUNE_C8_1:
  1096. case WM8962_DACL_RETUNE_C8_0:
  1097. case WM8962_DACL_RETUNE_C9_1:
  1098. case WM8962_DACL_RETUNE_C9_0:
  1099. case WM8962_DACL_RETUNE_C10_1:
  1100. case WM8962_DACL_RETUNE_C10_0:
  1101. case WM8962_DACL_RETUNE_C11_1:
  1102. case WM8962_DACL_RETUNE_C11_0:
  1103. case WM8962_DACL_RETUNE_C12_1:
  1104. case WM8962_DACL_RETUNE_C12_0:
  1105. case WM8962_DACL_RETUNE_C13_1:
  1106. case WM8962_DACL_RETUNE_C13_0:
  1107. case WM8962_DACL_RETUNE_C14_1:
  1108. case WM8962_DACL_RETUNE_C14_0:
  1109. case WM8962_DACL_RETUNE_C15_1:
  1110. case WM8962_DACL_RETUNE_C15_0:
  1111. case WM8962_DACL_RETUNE_C16_1:
  1112. case WM8962_DACL_RETUNE_C16_0:
  1113. case WM8962_DACL_RETUNE_C17_1:
  1114. case WM8962_DACL_RETUNE_C17_0:
  1115. case WM8962_DACL_RETUNE_C18_1:
  1116. case WM8962_DACL_RETUNE_C18_0:
  1117. case WM8962_DACL_RETUNE_C19_1:
  1118. case WM8962_DACL_RETUNE_C19_0:
  1119. case WM8962_DACL_RETUNE_C20_1:
  1120. case WM8962_DACL_RETUNE_C20_0:
  1121. case WM8962_DACL_RETUNE_C21_1:
  1122. case WM8962_DACL_RETUNE_C21_0:
  1123. case WM8962_DACL_RETUNE_C22_1:
  1124. case WM8962_DACL_RETUNE_C22_0:
  1125. case WM8962_DACL_RETUNE_C23_1:
  1126. case WM8962_DACL_RETUNE_C23_0:
  1127. case WM8962_DACL_RETUNE_C24_1:
  1128. case WM8962_DACL_RETUNE_C24_0:
  1129. case WM8962_DACL_RETUNE_C25_1:
  1130. case WM8962_DACL_RETUNE_C25_0:
  1131. case WM8962_DACL_RETUNE_C26_1:
  1132. case WM8962_DACL_RETUNE_C26_0:
  1133. case WM8962_DACL_RETUNE_C27_1:
  1134. case WM8962_DACL_RETUNE_C27_0:
  1135. case WM8962_DACL_RETUNE_C28_1:
  1136. case WM8962_DACL_RETUNE_C28_0:
  1137. case WM8962_DACL_RETUNE_C29_1:
  1138. case WM8962_DACL_RETUNE_C29_0:
  1139. case WM8962_DACL_RETUNE_C30_1:
  1140. case WM8962_DACL_RETUNE_C30_0:
  1141. case WM8962_DACL_RETUNE_C31_1:
  1142. case WM8962_DACL_RETUNE_C31_0:
  1143. case WM8962_DACL_RETUNE_C32_1:
  1144. case WM8962_DACL_RETUNE_C32_0:
  1145. case WM8962_RETUNEDAC_PG2_1:
  1146. case WM8962_RETUNEDAC_PG2_0:
  1147. case WM8962_RETUNEDAC_PG_1:
  1148. case WM8962_RETUNEDAC_PG_0:
  1149. case WM8962_DACR_RETUNE_C1_1:
  1150. case WM8962_DACR_RETUNE_C1_0:
  1151. case WM8962_DACR_RETUNE_C2_1:
  1152. case WM8962_DACR_RETUNE_C2_0:
  1153. case WM8962_DACR_RETUNE_C3_1:
  1154. case WM8962_DACR_RETUNE_C3_0:
  1155. case WM8962_DACR_RETUNE_C4_1:
  1156. case WM8962_DACR_RETUNE_C4_0:
  1157. case WM8962_DACR_RETUNE_C5_1:
  1158. case WM8962_DACR_RETUNE_C5_0:
  1159. case WM8962_DACR_RETUNE_C6_1:
  1160. case WM8962_DACR_RETUNE_C6_0:
  1161. case WM8962_DACR_RETUNE_C7_1:
  1162. case WM8962_DACR_RETUNE_C7_0:
  1163. case WM8962_DACR_RETUNE_C8_1:
  1164. case WM8962_DACR_RETUNE_C8_0:
  1165. case WM8962_DACR_RETUNE_C9_1:
  1166. case WM8962_DACR_RETUNE_C9_0:
  1167. case WM8962_DACR_RETUNE_C10_1:
  1168. case WM8962_DACR_RETUNE_C10_0:
  1169. case WM8962_DACR_RETUNE_C11_1:
  1170. case WM8962_DACR_RETUNE_C11_0:
  1171. case WM8962_DACR_RETUNE_C12_1:
  1172. case WM8962_DACR_RETUNE_C12_0:
  1173. case WM8962_DACR_RETUNE_C13_1:
  1174. case WM8962_DACR_RETUNE_C13_0:
  1175. case WM8962_DACR_RETUNE_C14_1:
  1176. case WM8962_DACR_RETUNE_C14_0:
  1177. case WM8962_DACR_RETUNE_C15_1:
  1178. case WM8962_DACR_RETUNE_C15_0:
  1179. case WM8962_DACR_RETUNE_C16_1:
  1180. case WM8962_DACR_RETUNE_C16_0:
  1181. case WM8962_DACR_RETUNE_C17_1:
  1182. case WM8962_DACR_RETUNE_C17_0:
  1183. case WM8962_DACR_RETUNE_C18_1:
  1184. case WM8962_DACR_RETUNE_C18_0:
  1185. case WM8962_DACR_RETUNE_C19_1:
  1186. case WM8962_DACR_RETUNE_C19_0:
  1187. case WM8962_DACR_RETUNE_C20_1:
  1188. case WM8962_DACR_RETUNE_C20_0:
  1189. case WM8962_DACR_RETUNE_C21_1:
  1190. case WM8962_DACR_RETUNE_C21_0:
  1191. case WM8962_DACR_RETUNE_C22_1:
  1192. case WM8962_DACR_RETUNE_C22_0:
  1193. case WM8962_DACR_RETUNE_C23_1:
  1194. case WM8962_DACR_RETUNE_C23_0:
  1195. case WM8962_DACR_RETUNE_C24_1:
  1196. case WM8962_DACR_RETUNE_C24_0:
  1197. case WM8962_DACR_RETUNE_C25_1:
  1198. case WM8962_DACR_RETUNE_C25_0:
  1199. case WM8962_DACR_RETUNE_C26_1:
  1200. case WM8962_DACR_RETUNE_C26_0:
  1201. case WM8962_DACR_RETUNE_C27_1:
  1202. case WM8962_DACR_RETUNE_C27_0:
  1203. case WM8962_DACR_RETUNE_C28_1:
  1204. case WM8962_DACR_RETUNE_C28_0:
  1205. case WM8962_DACR_RETUNE_C29_1:
  1206. case WM8962_DACR_RETUNE_C29_0:
  1207. case WM8962_DACR_RETUNE_C30_1:
  1208. case WM8962_DACR_RETUNE_C30_0:
  1209. case WM8962_DACR_RETUNE_C31_1:
  1210. case WM8962_DACR_RETUNE_C31_0:
  1211. case WM8962_DACR_RETUNE_C32_1:
  1212. case WM8962_DACR_RETUNE_C32_0:
  1213. case WM8962_VSS_XHD2_1:
  1214. case WM8962_VSS_XHD2_0:
  1215. case WM8962_VSS_XHD3_1:
  1216. case WM8962_VSS_XHD3_0:
  1217. case WM8962_VSS_XHN1_1:
  1218. case WM8962_VSS_XHN1_0:
  1219. case WM8962_VSS_XHN2_1:
  1220. case WM8962_VSS_XHN2_0:
  1221. case WM8962_VSS_XHN3_1:
  1222. case WM8962_VSS_XHN3_0:
  1223. case WM8962_VSS_XLA_1:
  1224. case WM8962_VSS_XLA_0:
  1225. case WM8962_VSS_XLB_1:
  1226. case WM8962_VSS_XLB_0:
  1227. case WM8962_VSS_XLG_1:
  1228. case WM8962_VSS_XLG_0:
  1229. case WM8962_VSS_PG2_1:
  1230. case WM8962_VSS_PG2_0:
  1231. case WM8962_VSS_PG_1:
  1232. case WM8962_VSS_PG_0:
  1233. case WM8962_VSS_XTD1_1:
  1234. case WM8962_VSS_XTD1_0:
  1235. case WM8962_VSS_XTD2_1:
  1236. case WM8962_VSS_XTD2_0:
  1237. case WM8962_VSS_XTD3_1:
  1238. case WM8962_VSS_XTD3_0:
  1239. case WM8962_VSS_XTD4_1:
  1240. case WM8962_VSS_XTD4_0:
  1241. case WM8962_VSS_XTD5_1:
  1242. case WM8962_VSS_XTD5_0:
  1243. case WM8962_VSS_XTD6_1:
  1244. case WM8962_VSS_XTD6_0:
  1245. case WM8962_VSS_XTD7_1:
  1246. case WM8962_VSS_XTD7_0:
  1247. case WM8962_VSS_XTD8_1:
  1248. case WM8962_VSS_XTD8_0:
  1249. case WM8962_VSS_XTD9_1:
  1250. case WM8962_VSS_XTD9_0:
  1251. case WM8962_VSS_XTD10_1:
  1252. case WM8962_VSS_XTD10_0:
  1253. case WM8962_VSS_XTD11_1:
  1254. case WM8962_VSS_XTD11_0:
  1255. case WM8962_VSS_XTD12_1:
  1256. case WM8962_VSS_XTD12_0:
  1257. case WM8962_VSS_XTD13_1:
  1258. case WM8962_VSS_XTD13_0:
  1259. case WM8962_VSS_XTD14_1:
  1260. case WM8962_VSS_XTD14_0:
  1261. case WM8962_VSS_XTD15_1:
  1262. case WM8962_VSS_XTD15_0:
  1263. case WM8962_VSS_XTD16_1:
  1264. case WM8962_VSS_XTD16_0:
  1265. case WM8962_VSS_XTD17_1:
  1266. case WM8962_VSS_XTD17_0:
  1267. case WM8962_VSS_XTD18_1:
  1268. case WM8962_VSS_XTD18_0:
  1269. case WM8962_VSS_XTD19_1:
  1270. case WM8962_VSS_XTD19_0:
  1271. case WM8962_VSS_XTD20_1:
  1272. case WM8962_VSS_XTD20_0:
  1273. case WM8962_VSS_XTD21_1:
  1274. case WM8962_VSS_XTD21_0:
  1275. case WM8962_VSS_XTD22_1:
  1276. case WM8962_VSS_XTD22_0:
  1277. case WM8962_VSS_XTD23_1:
  1278. case WM8962_VSS_XTD23_0:
  1279. case WM8962_VSS_XTD24_1:
  1280. case WM8962_VSS_XTD24_0:
  1281. case WM8962_VSS_XTD25_1:
  1282. case WM8962_VSS_XTD25_0:
  1283. case WM8962_VSS_XTD26_1:
  1284. case WM8962_VSS_XTD26_0:
  1285. case WM8962_VSS_XTD27_1:
  1286. case WM8962_VSS_XTD27_0:
  1287. case WM8962_VSS_XTD28_1:
  1288. case WM8962_VSS_XTD28_0:
  1289. case WM8962_VSS_XTD29_1:
  1290. case WM8962_VSS_XTD29_0:
  1291. case WM8962_VSS_XTD30_1:
  1292. case WM8962_VSS_XTD30_0:
  1293. case WM8962_VSS_XTD31_1:
  1294. case WM8962_VSS_XTD31_0:
  1295. case WM8962_VSS_XTD32_1:
  1296. case WM8962_VSS_XTD32_0:
  1297. case WM8962_VSS_XTS1_1:
  1298. case WM8962_VSS_XTS1_0:
  1299. case WM8962_VSS_XTS2_1:
  1300. case WM8962_VSS_XTS2_0:
  1301. case WM8962_VSS_XTS3_1:
  1302. case WM8962_VSS_XTS3_0:
  1303. case WM8962_VSS_XTS4_1:
  1304. case WM8962_VSS_XTS4_0:
  1305. case WM8962_VSS_XTS5_1:
  1306. case WM8962_VSS_XTS5_0:
  1307. case WM8962_VSS_XTS6_1:
  1308. case WM8962_VSS_XTS6_0:
  1309. case WM8962_VSS_XTS7_1:
  1310. case WM8962_VSS_XTS7_0:
  1311. case WM8962_VSS_XTS8_1:
  1312. case WM8962_VSS_XTS8_0:
  1313. case WM8962_VSS_XTS9_1:
  1314. case WM8962_VSS_XTS9_0:
  1315. case WM8962_VSS_XTS10_1:
  1316. case WM8962_VSS_XTS10_0:
  1317. case WM8962_VSS_XTS11_1:
  1318. case WM8962_VSS_XTS11_0:
  1319. case WM8962_VSS_XTS12_1:
  1320. case WM8962_VSS_XTS12_0:
  1321. case WM8962_VSS_XTS13_1:
  1322. case WM8962_VSS_XTS13_0:
  1323. case WM8962_VSS_XTS14_1:
  1324. case WM8962_VSS_XTS14_0:
  1325. case WM8962_VSS_XTS15_1:
  1326. case WM8962_VSS_XTS15_0:
  1327. case WM8962_VSS_XTS16_1:
  1328. case WM8962_VSS_XTS16_0:
  1329. case WM8962_VSS_XTS17_1:
  1330. case WM8962_VSS_XTS17_0:
  1331. case WM8962_VSS_XTS18_1:
  1332. case WM8962_VSS_XTS18_0:
  1333. case WM8962_VSS_XTS19_1:
  1334. case WM8962_VSS_XTS19_0:
  1335. case WM8962_VSS_XTS20_1:
  1336. case WM8962_VSS_XTS20_0:
  1337. case WM8962_VSS_XTS21_1:
  1338. case WM8962_VSS_XTS21_0:
  1339. case WM8962_VSS_XTS22_1:
  1340. case WM8962_VSS_XTS22_0:
  1341. case WM8962_VSS_XTS23_1:
  1342. case WM8962_VSS_XTS23_0:
  1343. case WM8962_VSS_XTS24_1:
  1344. case WM8962_VSS_XTS24_0:
  1345. case WM8962_VSS_XTS25_1:
  1346. case WM8962_VSS_XTS25_0:
  1347. case WM8962_VSS_XTS26_1:
  1348. case WM8962_VSS_XTS26_0:
  1349. case WM8962_VSS_XTS27_1:
  1350. case WM8962_VSS_XTS27_0:
  1351. case WM8962_VSS_XTS28_1:
  1352. case WM8962_VSS_XTS28_0:
  1353. case WM8962_VSS_XTS29_1:
  1354. case WM8962_VSS_XTS29_0:
  1355. case WM8962_VSS_XTS30_1:
  1356. case WM8962_VSS_XTS30_0:
  1357. case WM8962_VSS_XTS31_1:
  1358. case WM8962_VSS_XTS31_0:
  1359. case WM8962_VSS_XTS32_1:
  1360. case WM8962_VSS_XTS32_0:
  1361. return true;
  1362. default:
  1363. return false;
  1364. }
  1365. }
  1366. static int wm8962_reset(struct wm8962_priv *wm8962)
  1367. {
  1368. int ret;
  1369. ret = regmap_write(wm8962->regmap, WM8962_SOFTWARE_RESET, 0x6243);
  1370. if (ret != 0)
  1371. return ret;
  1372. return regmap_write(wm8962->regmap, WM8962_PLL_SOFTWARE_RESET, 0);
  1373. }
  1374. static const DECLARE_TLV_DB_SCALE(inpga_tlv, -2325, 75, 0);
  1375. static const DECLARE_TLV_DB_SCALE(mixin_tlv, -1500, 300, 0);
  1376. static const DECLARE_TLV_DB_RANGE(mixinpga_tlv,
  1377. 0, 1, TLV_DB_SCALE_ITEM(0, 600, 0),
  1378. 2, 2, TLV_DB_SCALE_ITEM(1300, 1300, 0),
  1379. 3, 4, TLV_DB_SCALE_ITEM(1800, 200, 0),
  1380. 5, 5, TLV_DB_SCALE_ITEM(2400, 0, 0),
  1381. 6, 7, TLV_DB_SCALE_ITEM(2700, 300, 0)
  1382. );
  1383. static const DECLARE_TLV_DB_SCALE(beep_tlv, -9600, 600, 1);
  1384. static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1);
  1385. static const DECLARE_TLV_DB_SCALE(st_tlv, -3600, 300, 0);
  1386. static const DECLARE_TLV_DB_SCALE(inmix_tlv, -600, 600, 0);
  1387. static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0);
  1388. static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
  1389. static const DECLARE_TLV_DB_SCALE(hp_tlv, -700, 100, 0);
  1390. static const DECLARE_TLV_DB_RANGE(classd_tlv,
  1391. 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0),
  1392. 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0)
  1393. );
  1394. static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
  1395. static int wm8962_dsp2_write_config(struct snd_soc_component *component)
  1396. {
  1397. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  1398. return regcache_sync_region(wm8962->regmap,
  1399. WM8962_HDBASS_AI_1, WM8962_MAX_REGISTER);
  1400. }
  1401. static int wm8962_dsp2_set_enable(struct snd_soc_component *component, u16 val)
  1402. {
  1403. u16 adcl = snd_soc_component_read(component, WM8962_LEFT_ADC_VOLUME);
  1404. u16 adcr = snd_soc_component_read(component, WM8962_RIGHT_ADC_VOLUME);
  1405. u16 dac = snd_soc_component_read(component, WM8962_ADC_DAC_CONTROL_1);
  1406. /* Mute the ADCs and DACs */
  1407. snd_soc_component_write(component, WM8962_LEFT_ADC_VOLUME, 0);
  1408. snd_soc_component_write(component, WM8962_RIGHT_ADC_VOLUME, WM8962_ADC_VU);
  1409. snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1,
  1410. WM8962_DAC_MUTE, WM8962_DAC_MUTE);
  1411. snd_soc_component_write(component, WM8962_SOUNDSTAGE_ENABLES_0, val);
  1412. /* Restore the ADCs and DACs */
  1413. snd_soc_component_write(component, WM8962_LEFT_ADC_VOLUME, adcl);
  1414. snd_soc_component_write(component, WM8962_RIGHT_ADC_VOLUME, adcr);
  1415. snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1,
  1416. WM8962_DAC_MUTE, dac);
  1417. return 0;
  1418. }
  1419. static int wm8962_dsp2_start(struct snd_soc_component *component)
  1420. {
  1421. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  1422. wm8962_dsp2_write_config(component);
  1423. snd_soc_component_write(component, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_RUNR);
  1424. wm8962_dsp2_set_enable(component, wm8962->dsp2_ena);
  1425. return 0;
  1426. }
  1427. static int wm8962_dsp2_stop(struct snd_soc_component *component)
  1428. {
  1429. wm8962_dsp2_set_enable(component, 0);
  1430. snd_soc_component_write(component, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_STOP);
  1431. return 0;
  1432. }
  1433. #define WM8962_DSP2_ENABLE(xname, xshift) \
  1434. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  1435. .info = wm8962_dsp2_ena_info, \
  1436. .get = wm8962_dsp2_ena_get, .put = wm8962_dsp2_ena_put, \
  1437. .private_value = xshift }
  1438. static int wm8962_dsp2_ena_info(struct snd_kcontrol *kcontrol,
  1439. struct snd_ctl_elem_info *uinfo)
  1440. {
  1441. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  1442. uinfo->count = 1;
  1443. uinfo->value.integer.min = 0;
  1444. uinfo->value.integer.max = 1;
  1445. return 0;
  1446. }
  1447. static int wm8962_dsp2_ena_get(struct snd_kcontrol *kcontrol,
  1448. struct snd_ctl_elem_value *ucontrol)
  1449. {
  1450. int shift = kcontrol->private_value;
  1451. struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
  1452. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  1453. ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift);
  1454. return 0;
  1455. }
  1456. static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol,
  1457. struct snd_ctl_elem_value *ucontrol)
  1458. {
  1459. int shift = kcontrol->private_value;
  1460. struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
  1461. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  1462. int old = wm8962->dsp2_ena;
  1463. int ret = 0;
  1464. int dsp2_running = snd_soc_component_read(component, WM8962_DSP2_POWER_MANAGEMENT) &
  1465. WM8962_DSP2_ENA;
  1466. mutex_lock(&wm8962->dsp2_ena_lock);
  1467. if (ucontrol->value.integer.value[0])
  1468. wm8962->dsp2_ena |= 1 << shift;
  1469. else
  1470. wm8962->dsp2_ena &= ~(1 << shift);
  1471. if (wm8962->dsp2_ena == old)
  1472. goto out;
  1473. ret = 1;
  1474. if (dsp2_running) {
  1475. if (wm8962->dsp2_ena)
  1476. wm8962_dsp2_set_enable(component, wm8962->dsp2_ena);
  1477. else
  1478. wm8962_dsp2_stop(component);
  1479. }
  1480. out:
  1481. mutex_unlock(&wm8962->dsp2_ena_lock);
  1482. return ret;
  1483. }
  1484. /* The VU bits for the headphones are in a different register to the mute
  1485. * bits and only take effect on the PGA if it is actually powered.
  1486. */
  1487. static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol,
  1488. struct snd_ctl_elem_value *ucontrol)
  1489. {
  1490. struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
  1491. int ret;
  1492. /* Apply the update (if any) */
  1493. ret = snd_soc_put_volsw(kcontrol, ucontrol);
  1494. if (ret == 0)
  1495. return 0;
  1496. /* If the left PGA is enabled hit that VU bit... */
  1497. ret = snd_soc_component_read(component, WM8962_PWR_MGMT_2);
  1498. if (ret & WM8962_HPOUTL_PGA_ENA) {
  1499. snd_soc_component_write(component, WM8962_HPOUTL_VOLUME,
  1500. snd_soc_component_read(component, WM8962_HPOUTL_VOLUME));
  1501. return 1;
  1502. }
  1503. /* ...otherwise the right. The VU is stereo. */
  1504. if (ret & WM8962_HPOUTR_PGA_ENA)
  1505. snd_soc_component_write(component, WM8962_HPOUTR_VOLUME,
  1506. snd_soc_component_read(component, WM8962_HPOUTR_VOLUME));
  1507. return 1;
  1508. }
  1509. /* The VU bits for the speakers are in a different register to the mute
  1510. * bits and only take effect on the PGA if it is actually powered.
  1511. */
  1512. static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol,
  1513. struct snd_ctl_elem_value *ucontrol)
  1514. {
  1515. struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
  1516. int ret;
  1517. /* Apply the update (if any) */
  1518. ret = snd_soc_put_volsw(kcontrol, ucontrol);
  1519. if (ret == 0)
  1520. return 0;
  1521. /* If the left PGA is enabled hit that VU bit... */
  1522. ret = snd_soc_component_read(component, WM8962_PWR_MGMT_2);
  1523. if (ret & WM8962_SPKOUTL_PGA_ENA) {
  1524. snd_soc_component_write(component, WM8962_SPKOUTL_VOLUME,
  1525. snd_soc_component_read(component, WM8962_SPKOUTL_VOLUME));
  1526. return 1;
  1527. }
  1528. /* ...otherwise the right. The VU is stereo. */
  1529. if (ret & WM8962_SPKOUTR_PGA_ENA)
  1530. snd_soc_component_write(component, WM8962_SPKOUTR_VOLUME,
  1531. snd_soc_component_read(component, WM8962_SPKOUTR_VOLUME));
  1532. return 1;
  1533. }
  1534. static const char *cap_hpf_mode_text[] = {
  1535. "Hi-fi", "Application"
  1536. };
  1537. static SOC_ENUM_SINGLE_DECL(cap_hpf_mode,
  1538. WM8962_ADC_DAC_CONTROL_2, 10, cap_hpf_mode_text);
  1539. static const char *cap_lhpf_mode_text[] = {
  1540. "LPF", "HPF"
  1541. };
  1542. static SOC_ENUM_SINGLE_DECL(cap_lhpf_mode,
  1543. WM8962_LHPF1, 1, cap_lhpf_mode_text);
  1544. static const struct snd_kcontrol_new wm8962_snd_controls[] = {
  1545. SOC_DOUBLE("Input Mixer Switch", WM8962_INPUT_MIXER_CONTROL_1, 3, 2, 1, 1),
  1546. SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8962_LEFT_INPUT_MIXER_VOLUME, 6, 7, 0,
  1547. mixin_tlv),
  1548. SOC_SINGLE_TLV("MIXINL PGA Volume", WM8962_LEFT_INPUT_MIXER_VOLUME, 3, 7, 0,
  1549. mixinpga_tlv),
  1550. SOC_SINGLE_TLV("MIXINL IN3L Volume", WM8962_LEFT_INPUT_MIXER_VOLUME, 0, 7, 0,
  1551. mixin_tlv),
  1552. SOC_SINGLE_TLV("MIXINR IN2R Volume", WM8962_RIGHT_INPUT_MIXER_VOLUME, 6, 7, 0,
  1553. mixin_tlv),
  1554. SOC_SINGLE_TLV("MIXINR PGA Volume", WM8962_RIGHT_INPUT_MIXER_VOLUME, 3, 7, 0,
  1555. mixinpga_tlv),
  1556. SOC_SINGLE_TLV("MIXINR IN3R Volume", WM8962_RIGHT_INPUT_MIXER_VOLUME, 0, 7, 0,
  1557. mixin_tlv),
  1558. SOC_DOUBLE_R_TLV("Digital Capture Volume", WM8962_LEFT_ADC_VOLUME,
  1559. WM8962_RIGHT_ADC_VOLUME, 1, 127, 0, digital_tlv),
  1560. SOC_DOUBLE_R_TLV("Capture Volume", WM8962_LEFT_INPUT_VOLUME,
  1561. WM8962_RIGHT_INPUT_VOLUME, 0, 63, 0, inpga_tlv),
  1562. SOC_DOUBLE_R("Capture Switch", WM8962_LEFT_INPUT_VOLUME,
  1563. WM8962_RIGHT_INPUT_VOLUME, 7, 1, 1),
  1564. SOC_DOUBLE_R("Capture ZC Switch", WM8962_LEFT_INPUT_VOLUME,
  1565. WM8962_RIGHT_INPUT_VOLUME, 6, 1, 1),
  1566. SOC_SINGLE("Capture HPF Switch", WM8962_ADC_DAC_CONTROL_1, 0, 1, 1),
  1567. SOC_ENUM("Capture HPF Mode", cap_hpf_mode),
  1568. SOC_SINGLE("Capture HPF Cutoff", WM8962_ADC_DAC_CONTROL_2, 7, 7, 0),
  1569. SOC_SINGLE("Capture LHPF Switch", WM8962_LHPF1, 0, 1, 0),
  1570. SOC_ENUM("Capture LHPF Mode", cap_lhpf_mode),
  1571. SOC_DOUBLE_R_TLV("Sidetone Volume", WM8962_DAC_DSP_MIXING_1,
  1572. WM8962_DAC_DSP_MIXING_2, 4, 12, 0, st_tlv),
  1573. SOC_DOUBLE_R_TLV("Digital Playback Volume", WM8962_LEFT_DAC_VOLUME,
  1574. WM8962_RIGHT_DAC_VOLUME, 1, 127, 0, digital_tlv),
  1575. SOC_SINGLE("DAC High Performance Switch", WM8962_ADC_DAC_CONTROL_2, 0, 1, 0),
  1576. SOC_SINGLE("DAC L/R Swap Switch", WM8962_AUDIO_INTERFACE_0, 5, 1, 0),
  1577. SOC_SINGLE("ADC L/R Swap Switch", WM8962_AUDIO_INTERFACE_0, 8, 1, 0),
  1578. SOC_SINGLE("DAC Monomix Switch", WM8962_DAC_DSP_MIXING_1, WM8962_DAC_MONOMIX_SHIFT, 1, 0),
  1579. SOC_SINGLE("ADC Monomix Switch", WM8962_THREED1, WM8962_ADC_MONOMIX_SHIFT, 1, 0),
  1580. SOC_SINGLE("ADC High Performance Switch", WM8962_ADDITIONAL_CONTROL_1,
  1581. 5, 1, 0),
  1582. SOC_SINGLE_TLV("Beep Volume", WM8962_BEEP_GENERATOR_1, 4, 15, 0, beep_tlv),
  1583. SOC_DOUBLE_R_TLV("Headphone Volume", WM8962_HPOUTL_VOLUME,
  1584. WM8962_HPOUTR_VOLUME, 0, 127, 0, out_tlv),
  1585. SOC_DOUBLE_EXT("Headphone Switch", WM8962_PWR_MGMT_2, 1, 0, 1, 1,
  1586. snd_soc_get_volsw, wm8962_put_hp_sw),
  1587. SOC_DOUBLE_R("Headphone ZC Switch", WM8962_HPOUTL_VOLUME, WM8962_HPOUTR_VOLUME,
  1588. 7, 1, 0),
  1589. SOC_DOUBLE_TLV("Headphone Aux Volume", WM8962_ANALOGUE_HP_2, 3, 6, 7, 0,
  1590. hp_tlv),
  1591. SOC_DOUBLE_R("Headphone Mixer Switch", WM8962_HEADPHONE_MIXER_3,
  1592. WM8962_HEADPHONE_MIXER_4, 8, 1, 1),
  1593. SOC_SINGLE_TLV("HPMIXL IN4L Volume", WM8962_HEADPHONE_MIXER_3,
  1594. 3, 7, 0, bypass_tlv),
  1595. SOC_SINGLE_TLV("HPMIXL IN4R Volume", WM8962_HEADPHONE_MIXER_3,
  1596. 0, 7, 0, bypass_tlv),
  1597. SOC_SINGLE_TLV("HPMIXL MIXINL Volume", WM8962_HEADPHONE_MIXER_3,
  1598. 7, 1, 1, inmix_tlv),
  1599. SOC_SINGLE_TLV("HPMIXL MIXINR Volume", WM8962_HEADPHONE_MIXER_3,
  1600. 6, 1, 1, inmix_tlv),
  1601. SOC_SINGLE_TLV("HPMIXR IN4L Volume", WM8962_HEADPHONE_MIXER_4,
  1602. 3, 7, 0, bypass_tlv),
  1603. SOC_SINGLE_TLV("HPMIXR IN4R Volume", WM8962_HEADPHONE_MIXER_4,
  1604. 0, 7, 0, bypass_tlv),
  1605. SOC_SINGLE_TLV("HPMIXR MIXINL Volume", WM8962_HEADPHONE_MIXER_4,
  1606. 7, 1, 1, inmix_tlv),
  1607. SOC_SINGLE_TLV("HPMIXR MIXINR Volume", WM8962_HEADPHONE_MIXER_4,
  1608. 6, 1, 1, inmix_tlv),
  1609. SOC_SINGLE_TLV("Speaker Boost Volume", WM8962_CLASS_D_CONTROL_2, 0, 7, 0,
  1610. classd_tlv),
  1611. SOC_SINGLE("EQ Switch", WM8962_EQ1, WM8962_EQ_ENA_SHIFT, 1, 0),
  1612. SOC_DOUBLE_R_TLV("EQ1 Volume", WM8962_EQ2, WM8962_EQ22,
  1613. WM8962_EQL_B1_GAIN_SHIFT, 31, 0, eq_tlv),
  1614. SOC_DOUBLE_R_TLV("EQ2 Volume", WM8962_EQ2, WM8962_EQ22,
  1615. WM8962_EQL_B2_GAIN_SHIFT, 31, 0, eq_tlv),
  1616. SOC_DOUBLE_R_TLV("EQ3 Volume", WM8962_EQ2, WM8962_EQ22,
  1617. WM8962_EQL_B3_GAIN_SHIFT, 31, 0, eq_tlv),
  1618. SOC_DOUBLE_R_TLV("EQ4 Volume", WM8962_EQ3, WM8962_EQ23,
  1619. WM8962_EQL_B4_GAIN_SHIFT, 31, 0, eq_tlv),
  1620. SOC_DOUBLE_R_TLV("EQ5 Volume", WM8962_EQ3, WM8962_EQ23,
  1621. WM8962_EQL_B5_GAIN_SHIFT, 31, 0, eq_tlv),
  1622. SND_SOC_BYTES("EQL Coefficients", WM8962_EQ4, 18),
  1623. SND_SOC_BYTES("EQR Coefficients", WM8962_EQ24, 18),
  1624. SOC_SINGLE("3D Switch", WM8962_THREED1, 0, 1, 0),
  1625. SND_SOC_BYTES_MASK("3D Coefficients", WM8962_THREED1, 4, WM8962_THREED_ENA),
  1626. SOC_SINGLE("DF1 Switch", WM8962_DF1, 0, 1, 0),
  1627. SND_SOC_BYTES_MASK("DF1 Coefficients", WM8962_DF1, 7, WM8962_DF1_ENA),
  1628. SOC_SINGLE("DRC Switch", WM8962_DRC_1, 0, 1, 0),
  1629. SND_SOC_BYTES_MASK("DRC Coefficients", WM8962_DRC_1, 5, WM8962_DRC_ENA),
  1630. WM8962_DSP2_ENABLE("VSS Switch", WM8962_VSS_ENA_SHIFT),
  1631. SND_SOC_BYTES("VSS Coefficients", WM8962_VSS_XHD2_1, 148),
  1632. WM8962_DSP2_ENABLE("HPF1 Switch", WM8962_HPF1_ENA_SHIFT),
  1633. WM8962_DSP2_ENABLE("HPF2 Switch", WM8962_HPF2_ENA_SHIFT),
  1634. SND_SOC_BYTES("HPF Coefficients", WM8962_LHPF2, 1),
  1635. WM8962_DSP2_ENABLE("HD Bass Switch", WM8962_HDBASS_ENA_SHIFT),
  1636. SND_SOC_BYTES("HD Bass Coefficients", WM8962_HDBASS_AI_1, 30),
  1637. SOC_DOUBLE("ALC Switch", WM8962_ALC1, WM8962_ALCL_ENA_SHIFT,
  1638. WM8962_ALCR_ENA_SHIFT, 1, 0),
  1639. SND_SOC_BYTES_MASK("ALC Coefficients", WM8962_ALC1, 4,
  1640. WM8962_ALCL_ENA_MASK | WM8962_ALCR_ENA_MASK),
  1641. };
  1642. static const struct snd_kcontrol_new wm8962_spk_mono_controls[] = {
  1643. SOC_SINGLE_TLV("Speaker Volume", WM8962_SPKOUTL_VOLUME, 0, 127, 0, out_tlv),
  1644. SOC_SINGLE_EXT("Speaker Switch", WM8962_CLASS_D_CONTROL_1, 1, 1, 1,
  1645. snd_soc_get_volsw, wm8962_put_spk_sw),
  1646. SOC_SINGLE("Speaker ZC Switch", WM8962_SPKOUTL_VOLUME, 7, 1, 0),
  1647. SOC_SINGLE("Speaker Mixer Switch", WM8962_SPEAKER_MIXER_3, 8, 1, 1),
  1648. SOC_SINGLE_TLV("Speaker Mixer IN4L Volume", WM8962_SPEAKER_MIXER_3,
  1649. 3, 7, 0, bypass_tlv),
  1650. SOC_SINGLE_TLV("Speaker Mixer IN4R Volume", WM8962_SPEAKER_MIXER_3,
  1651. 0, 7, 0, bypass_tlv),
  1652. SOC_SINGLE_TLV("Speaker Mixer MIXINL Volume", WM8962_SPEAKER_MIXER_3,
  1653. 7, 1, 1, inmix_tlv),
  1654. SOC_SINGLE_TLV("Speaker Mixer MIXINR Volume", WM8962_SPEAKER_MIXER_3,
  1655. 6, 1, 1, inmix_tlv),
  1656. SOC_SINGLE_TLV("Speaker Mixer DACL Volume", WM8962_SPEAKER_MIXER_5,
  1657. 7, 1, 0, inmix_tlv),
  1658. SOC_SINGLE_TLV("Speaker Mixer DACR Volume", WM8962_SPEAKER_MIXER_5,
  1659. 6, 1, 0, inmix_tlv),
  1660. };
  1661. static const struct snd_kcontrol_new wm8962_spk_stereo_controls[] = {
  1662. SOC_DOUBLE_R_TLV("Speaker Volume", WM8962_SPKOUTL_VOLUME,
  1663. WM8962_SPKOUTR_VOLUME, 0, 127, 0, out_tlv),
  1664. SOC_DOUBLE_EXT("Speaker Switch", WM8962_CLASS_D_CONTROL_1, 1, 0, 1, 1,
  1665. snd_soc_get_volsw, wm8962_put_spk_sw),
  1666. SOC_DOUBLE_R("Speaker ZC Switch", WM8962_SPKOUTL_VOLUME, WM8962_SPKOUTR_VOLUME,
  1667. 7, 1, 0),
  1668. SOC_DOUBLE_R("Speaker Mixer Switch", WM8962_SPEAKER_MIXER_3,
  1669. WM8962_SPEAKER_MIXER_4, 8, 1, 1),
  1670. SOC_SINGLE_TLV("SPKOUTL Mixer IN4L Volume", WM8962_SPEAKER_MIXER_3,
  1671. 3, 7, 0, bypass_tlv),
  1672. SOC_SINGLE_TLV("SPKOUTL Mixer IN4R Volume", WM8962_SPEAKER_MIXER_3,
  1673. 0, 7, 0, bypass_tlv),
  1674. SOC_SINGLE_TLV("SPKOUTL Mixer MIXINL Volume", WM8962_SPEAKER_MIXER_3,
  1675. 7, 1, 1, inmix_tlv),
  1676. SOC_SINGLE_TLV("SPKOUTL Mixer MIXINR Volume", WM8962_SPEAKER_MIXER_3,
  1677. 6, 1, 1, inmix_tlv),
  1678. SOC_SINGLE_TLV("SPKOUTL Mixer DACL Volume", WM8962_SPEAKER_MIXER_5,
  1679. 7, 1, 0, inmix_tlv),
  1680. SOC_SINGLE_TLV("SPKOUTL Mixer DACR Volume", WM8962_SPEAKER_MIXER_5,
  1681. 6, 1, 0, inmix_tlv),
  1682. SOC_SINGLE_TLV("SPKOUTR Mixer IN4L Volume", WM8962_SPEAKER_MIXER_4,
  1683. 3, 7, 0, bypass_tlv),
  1684. SOC_SINGLE_TLV("SPKOUTR Mixer IN4R Volume", WM8962_SPEAKER_MIXER_4,
  1685. 0, 7, 0, bypass_tlv),
  1686. SOC_SINGLE_TLV("SPKOUTR Mixer MIXINL Volume", WM8962_SPEAKER_MIXER_4,
  1687. 7, 1, 1, inmix_tlv),
  1688. SOC_SINGLE_TLV("SPKOUTR Mixer MIXINR Volume", WM8962_SPEAKER_MIXER_4,
  1689. 6, 1, 1, inmix_tlv),
  1690. SOC_SINGLE_TLV("SPKOUTR Mixer DACL Volume", WM8962_SPEAKER_MIXER_5,
  1691. 5, 1, 0, inmix_tlv),
  1692. SOC_SINGLE_TLV("SPKOUTR Mixer DACR Volume", WM8962_SPEAKER_MIXER_5,
  1693. 4, 1, 0, inmix_tlv),
  1694. };
  1695. static int cp_event(struct snd_soc_dapm_widget *w,
  1696. struct snd_kcontrol *kcontrol, int event)
  1697. {
  1698. switch (event) {
  1699. case SND_SOC_DAPM_POST_PMU:
  1700. msleep(5);
  1701. break;
  1702. default:
  1703. WARN(1, "Invalid event %d\n", event);
  1704. return -EINVAL;
  1705. }
  1706. return 0;
  1707. }
  1708. static int hp_event(struct snd_soc_dapm_widget *w,
  1709. struct snd_kcontrol *kcontrol, int event)
  1710. {
  1711. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  1712. int timeout;
  1713. int reg;
  1714. int expected = (WM8962_DCS_STARTUP_DONE_HP1L |
  1715. WM8962_DCS_STARTUP_DONE_HP1R);
  1716. switch (event) {
  1717. case SND_SOC_DAPM_POST_PMU:
  1718. snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
  1719. WM8962_HP1L_ENA | WM8962_HP1R_ENA,
  1720. WM8962_HP1L_ENA | WM8962_HP1R_ENA);
  1721. udelay(20);
  1722. snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
  1723. WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY,
  1724. WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY);
  1725. /* Start the DC servo */
  1726. snd_soc_component_update_bits(component, WM8962_DC_SERVO_1,
  1727. WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA |
  1728. WM8962_HP1L_DCS_STARTUP |
  1729. WM8962_HP1R_DCS_STARTUP,
  1730. WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA |
  1731. WM8962_HP1L_DCS_STARTUP |
  1732. WM8962_HP1R_DCS_STARTUP);
  1733. /* Wait for it to complete, should be well under 100ms */
  1734. timeout = 0;
  1735. do {
  1736. msleep(1);
  1737. reg = snd_soc_component_read(component, WM8962_DC_SERVO_6);
  1738. if (reg < 0) {
  1739. dev_err(component->dev,
  1740. "Failed to read DCS status: %d\n",
  1741. reg);
  1742. continue;
  1743. }
  1744. dev_dbg(component->dev, "DCS status: %x\n", reg);
  1745. } while (++timeout < 200 && (reg & expected) != expected);
  1746. if ((reg & expected) != expected)
  1747. dev_err(component->dev, "DC servo timed out\n");
  1748. else
  1749. dev_dbg(component->dev, "DC servo complete after %dms\n",
  1750. timeout);
  1751. snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
  1752. WM8962_HP1L_ENA_OUTP |
  1753. WM8962_HP1R_ENA_OUTP,
  1754. WM8962_HP1L_ENA_OUTP |
  1755. WM8962_HP1R_ENA_OUTP);
  1756. udelay(20);
  1757. snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
  1758. WM8962_HP1L_RMV_SHORT |
  1759. WM8962_HP1R_RMV_SHORT,
  1760. WM8962_HP1L_RMV_SHORT |
  1761. WM8962_HP1R_RMV_SHORT);
  1762. break;
  1763. case SND_SOC_DAPM_PRE_PMD:
  1764. snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
  1765. WM8962_HP1L_RMV_SHORT |
  1766. WM8962_HP1R_RMV_SHORT, 0);
  1767. udelay(20);
  1768. snd_soc_component_update_bits(component, WM8962_DC_SERVO_1,
  1769. WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA |
  1770. WM8962_HP1L_DCS_STARTUP |
  1771. WM8962_HP1R_DCS_STARTUP,
  1772. 0);
  1773. snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
  1774. WM8962_HP1L_ENA | WM8962_HP1R_ENA |
  1775. WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY |
  1776. WM8962_HP1L_ENA_OUTP |
  1777. WM8962_HP1R_ENA_OUTP, 0);
  1778. break;
  1779. default:
  1780. WARN(1, "Invalid event %d\n", event);
  1781. return -EINVAL;
  1782. }
  1783. return 0;
  1784. }
  1785. /* VU bits for the output PGAs only take effect while the PGA is powered */
  1786. static int out_pga_event(struct snd_soc_dapm_widget *w,
  1787. struct snd_kcontrol *kcontrol, int event)
  1788. {
  1789. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  1790. int reg;
  1791. switch (w->shift) {
  1792. case WM8962_HPOUTR_PGA_ENA_SHIFT:
  1793. reg = WM8962_HPOUTR_VOLUME;
  1794. break;
  1795. case WM8962_HPOUTL_PGA_ENA_SHIFT:
  1796. reg = WM8962_HPOUTL_VOLUME;
  1797. break;
  1798. case WM8962_SPKOUTR_PGA_ENA_SHIFT:
  1799. reg = WM8962_SPKOUTR_VOLUME;
  1800. break;
  1801. case WM8962_SPKOUTL_PGA_ENA_SHIFT:
  1802. reg = WM8962_SPKOUTL_VOLUME;
  1803. break;
  1804. default:
  1805. WARN(1, "Invalid shift %d\n", w->shift);
  1806. return -EINVAL;
  1807. }
  1808. switch (event) {
  1809. case SND_SOC_DAPM_POST_PMU:
  1810. return snd_soc_component_write(component, reg,
  1811. snd_soc_component_read(component, reg));
  1812. default:
  1813. WARN(1, "Invalid event %d\n", event);
  1814. return -EINVAL;
  1815. }
  1816. }
  1817. static int dsp2_event(struct snd_soc_dapm_widget *w,
  1818. struct snd_kcontrol *kcontrol, int event)
  1819. {
  1820. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  1821. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  1822. switch (event) {
  1823. case SND_SOC_DAPM_POST_PMU:
  1824. if (wm8962->dsp2_ena)
  1825. wm8962_dsp2_start(component);
  1826. break;
  1827. case SND_SOC_DAPM_PRE_PMD:
  1828. if (wm8962->dsp2_ena)
  1829. wm8962_dsp2_stop(component);
  1830. break;
  1831. default:
  1832. WARN(1, "Invalid event %d\n", event);
  1833. return -EINVAL;
  1834. }
  1835. return 0;
  1836. }
  1837. static const char *st_text[] = { "None", "Left", "Right" };
  1838. static SOC_ENUM_SINGLE_DECL(str_enum,
  1839. WM8962_DAC_DSP_MIXING_1, 2, st_text);
  1840. static const struct snd_kcontrol_new str_mux =
  1841. SOC_DAPM_ENUM("Right Sidetone", str_enum);
  1842. static SOC_ENUM_SINGLE_DECL(stl_enum,
  1843. WM8962_DAC_DSP_MIXING_2, 2, st_text);
  1844. static const struct snd_kcontrol_new stl_mux =
  1845. SOC_DAPM_ENUM("Left Sidetone", stl_enum);
  1846. static const char *outmux_text[] = { "DAC", "Mixer" };
  1847. static SOC_ENUM_SINGLE_DECL(spkoutr_enum,
  1848. WM8962_SPEAKER_MIXER_2, 7, outmux_text);
  1849. static const struct snd_kcontrol_new spkoutr_mux =
  1850. SOC_DAPM_ENUM("SPKOUTR Mux", spkoutr_enum);
  1851. static SOC_ENUM_SINGLE_DECL(spkoutl_enum,
  1852. WM8962_SPEAKER_MIXER_1, 7, outmux_text);
  1853. static const struct snd_kcontrol_new spkoutl_mux =
  1854. SOC_DAPM_ENUM("SPKOUTL Mux", spkoutl_enum);
  1855. static SOC_ENUM_SINGLE_DECL(hpoutr_enum,
  1856. WM8962_HEADPHONE_MIXER_2, 7, outmux_text);
  1857. static const struct snd_kcontrol_new hpoutr_mux =
  1858. SOC_DAPM_ENUM("HPOUTR Mux", hpoutr_enum);
  1859. static SOC_ENUM_SINGLE_DECL(hpoutl_enum,
  1860. WM8962_HEADPHONE_MIXER_1, 7, outmux_text);
  1861. static const struct snd_kcontrol_new hpoutl_mux =
  1862. SOC_DAPM_ENUM("HPOUTL Mux", hpoutl_enum);
  1863. static const struct snd_kcontrol_new inpgal[] = {
  1864. SOC_DAPM_SINGLE("IN1L Switch", WM8962_LEFT_INPUT_PGA_CONTROL, 3, 1, 0),
  1865. SOC_DAPM_SINGLE("IN2L Switch", WM8962_LEFT_INPUT_PGA_CONTROL, 2, 1, 0),
  1866. SOC_DAPM_SINGLE("IN3L Switch", WM8962_LEFT_INPUT_PGA_CONTROL, 1, 1, 0),
  1867. SOC_DAPM_SINGLE("IN4L Switch", WM8962_LEFT_INPUT_PGA_CONTROL, 0, 1, 0),
  1868. };
  1869. static const struct snd_kcontrol_new inpgar[] = {
  1870. SOC_DAPM_SINGLE("IN1R Switch", WM8962_RIGHT_INPUT_PGA_CONTROL, 3, 1, 0),
  1871. SOC_DAPM_SINGLE("IN2R Switch", WM8962_RIGHT_INPUT_PGA_CONTROL, 2, 1, 0),
  1872. SOC_DAPM_SINGLE("IN3R Switch", WM8962_RIGHT_INPUT_PGA_CONTROL, 1, 1, 0),
  1873. SOC_DAPM_SINGLE("IN4R Switch", WM8962_RIGHT_INPUT_PGA_CONTROL, 0, 1, 0),
  1874. };
  1875. static const struct snd_kcontrol_new mixinl[] = {
  1876. SOC_DAPM_SINGLE("IN2L Switch", WM8962_INPUT_MIXER_CONTROL_2, 5, 1, 0),
  1877. SOC_DAPM_SINGLE("IN3L Switch", WM8962_INPUT_MIXER_CONTROL_2, 4, 1, 0),
  1878. SOC_DAPM_SINGLE("PGA Switch", WM8962_INPUT_MIXER_CONTROL_2, 3, 1, 0),
  1879. };
  1880. static const struct snd_kcontrol_new mixinr[] = {
  1881. SOC_DAPM_SINGLE("IN2R Switch", WM8962_INPUT_MIXER_CONTROL_2, 2, 1, 0),
  1882. SOC_DAPM_SINGLE("IN3R Switch", WM8962_INPUT_MIXER_CONTROL_2, 1, 1, 0),
  1883. SOC_DAPM_SINGLE("PGA Switch", WM8962_INPUT_MIXER_CONTROL_2, 0, 1, 0),
  1884. };
  1885. static const struct snd_kcontrol_new hpmixl[] = {
  1886. SOC_DAPM_SINGLE("DACL Switch", WM8962_HEADPHONE_MIXER_1, 5, 1, 0),
  1887. SOC_DAPM_SINGLE("DACR Switch", WM8962_HEADPHONE_MIXER_1, 4, 1, 0),
  1888. SOC_DAPM_SINGLE("MIXINL Switch", WM8962_HEADPHONE_MIXER_1, 3, 1, 0),
  1889. SOC_DAPM_SINGLE("MIXINR Switch", WM8962_HEADPHONE_MIXER_1, 2, 1, 0),
  1890. SOC_DAPM_SINGLE("IN4L Switch", WM8962_HEADPHONE_MIXER_1, 1, 1, 0),
  1891. SOC_DAPM_SINGLE("IN4R Switch", WM8962_HEADPHONE_MIXER_1, 0, 1, 0),
  1892. };
  1893. static const struct snd_kcontrol_new hpmixr[] = {
  1894. SOC_DAPM_SINGLE("DACL Switch", WM8962_HEADPHONE_MIXER_2, 5, 1, 0),
  1895. SOC_DAPM_SINGLE("DACR Switch", WM8962_HEADPHONE_MIXER_2, 4, 1, 0),
  1896. SOC_DAPM_SINGLE("MIXINL Switch", WM8962_HEADPHONE_MIXER_2, 3, 1, 0),
  1897. SOC_DAPM_SINGLE("MIXINR Switch", WM8962_HEADPHONE_MIXER_2, 2, 1, 0),
  1898. SOC_DAPM_SINGLE("IN4L Switch", WM8962_HEADPHONE_MIXER_2, 1, 1, 0),
  1899. SOC_DAPM_SINGLE("IN4R Switch", WM8962_HEADPHONE_MIXER_2, 0, 1, 0),
  1900. };
  1901. static const struct snd_kcontrol_new spkmixl[] = {
  1902. SOC_DAPM_SINGLE("DACL Switch", WM8962_SPEAKER_MIXER_1, 5, 1, 0),
  1903. SOC_DAPM_SINGLE("DACR Switch", WM8962_SPEAKER_MIXER_1, 4, 1, 0),
  1904. SOC_DAPM_SINGLE("MIXINL Switch", WM8962_SPEAKER_MIXER_1, 3, 1, 0),
  1905. SOC_DAPM_SINGLE("MIXINR Switch", WM8962_SPEAKER_MIXER_1, 2, 1, 0),
  1906. SOC_DAPM_SINGLE("IN4L Switch", WM8962_SPEAKER_MIXER_1, 1, 1, 0),
  1907. SOC_DAPM_SINGLE("IN4R Switch", WM8962_SPEAKER_MIXER_1, 0, 1, 0),
  1908. };
  1909. static const struct snd_kcontrol_new spkmixr[] = {
  1910. SOC_DAPM_SINGLE("DACL Switch", WM8962_SPEAKER_MIXER_2, 5, 1, 0),
  1911. SOC_DAPM_SINGLE("DACR Switch", WM8962_SPEAKER_MIXER_2, 4, 1, 0),
  1912. SOC_DAPM_SINGLE("MIXINL Switch", WM8962_SPEAKER_MIXER_2, 3, 1, 0),
  1913. SOC_DAPM_SINGLE("MIXINR Switch", WM8962_SPEAKER_MIXER_2, 2, 1, 0),
  1914. SOC_DAPM_SINGLE("IN4L Switch", WM8962_SPEAKER_MIXER_2, 1, 1, 0),
  1915. SOC_DAPM_SINGLE("IN4R Switch", WM8962_SPEAKER_MIXER_2, 0, 1, 0),
  1916. };
  1917. static const struct snd_soc_dapm_widget wm8962_dapm_widgets[] = {
  1918. SND_SOC_DAPM_INPUT("IN1L"),
  1919. SND_SOC_DAPM_INPUT("IN1R"),
  1920. SND_SOC_DAPM_INPUT("IN2L"),
  1921. SND_SOC_DAPM_INPUT("IN2R"),
  1922. SND_SOC_DAPM_INPUT("IN3L"),
  1923. SND_SOC_DAPM_INPUT("IN3R"),
  1924. SND_SOC_DAPM_INPUT("IN4L"),
  1925. SND_SOC_DAPM_INPUT("IN4R"),
  1926. SND_SOC_DAPM_SIGGEN("Beep"),
  1927. SND_SOC_DAPM_INPUT("DMICDAT"),
  1928. SND_SOC_DAPM_SUPPLY("MICBIAS", WM8962_PWR_MGMT_1, 1, 0, NULL, 0),
  1929. SND_SOC_DAPM_SUPPLY("Class G", WM8962_CHARGE_PUMP_B, 0, 1, NULL, 0),
  1930. SND_SOC_DAPM_SUPPLY("SYSCLK", WM8962_CLOCKING2, 5, 0, NULL, 0),
  1931. SND_SOC_DAPM_SUPPLY("Charge Pump", WM8962_CHARGE_PUMP_1, 0, 0, cp_event,
  1932. SND_SOC_DAPM_POST_PMU),
  1933. SND_SOC_DAPM_SUPPLY("TOCLK", WM8962_ADDITIONAL_CONTROL_1, 0, 0, NULL, 0),
  1934. SND_SOC_DAPM_SUPPLY_S("DSP2", 1, WM8962_DSP2_POWER_MANAGEMENT,
  1935. WM8962_DSP2_ENA_SHIFT, 0, dsp2_event,
  1936. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  1937. SND_SOC_DAPM_SUPPLY("TEMP_HP", WM8962_ADDITIONAL_CONTROL_4, 2, 0, NULL, 0),
  1938. SND_SOC_DAPM_SUPPLY("TEMP_SPK", WM8962_ADDITIONAL_CONTROL_4, 1, 0, NULL, 0),
  1939. SND_SOC_DAPM_MIXER("INPGAL", WM8962_LEFT_INPUT_PGA_CONTROL, 4, 0,
  1940. inpgal, ARRAY_SIZE(inpgal)),
  1941. SND_SOC_DAPM_MIXER("INPGAR", WM8962_RIGHT_INPUT_PGA_CONTROL, 4, 0,
  1942. inpgar, ARRAY_SIZE(inpgar)),
  1943. SND_SOC_DAPM_MIXER("MIXINL", WM8962_PWR_MGMT_1, 5, 0,
  1944. mixinl, ARRAY_SIZE(mixinl)),
  1945. SND_SOC_DAPM_MIXER("MIXINR", WM8962_PWR_MGMT_1, 4, 0,
  1946. mixinr, ARRAY_SIZE(mixinr)),
  1947. SND_SOC_DAPM_AIF_IN("DMIC_ENA", NULL, 0, WM8962_PWR_MGMT_1, 10, 0),
  1948. SND_SOC_DAPM_ADC("ADCL", "Capture", WM8962_PWR_MGMT_1, 3, 0),
  1949. SND_SOC_DAPM_ADC("ADCR", "Capture", WM8962_PWR_MGMT_1, 2, 0),
  1950. SND_SOC_DAPM_MUX("STL", SND_SOC_NOPM, 0, 0, &stl_mux),
  1951. SND_SOC_DAPM_MUX("STR", SND_SOC_NOPM, 0, 0, &str_mux),
  1952. SND_SOC_DAPM_DAC("DACL", "Playback", WM8962_PWR_MGMT_2, 8, 0),
  1953. SND_SOC_DAPM_DAC("DACR", "Playback", WM8962_PWR_MGMT_2, 7, 0),
  1954. SND_SOC_DAPM_PGA("Left Bypass", SND_SOC_NOPM, 0, 0, NULL, 0),
  1955. SND_SOC_DAPM_PGA("Right Bypass", SND_SOC_NOPM, 0, 0, NULL, 0),
  1956. SND_SOC_DAPM_MIXER("HPMIXL", WM8962_MIXER_ENABLES, 3, 0,
  1957. hpmixl, ARRAY_SIZE(hpmixl)),
  1958. SND_SOC_DAPM_MIXER("HPMIXR", WM8962_MIXER_ENABLES, 2, 0,
  1959. hpmixr, ARRAY_SIZE(hpmixr)),
  1960. SND_SOC_DAPM_MUX_E("HPOUTL PGA", WM8962_PWR_MGMT_2, 6, 0, &hpoutl_mux,
  1961. out_pga_event, SND_SOC_DAPM_POST_PMU),
  1962. SND_SOC_DAPM_MUX_E("HPOUTR PGA", WM8962_PWR_MGMT_2, 5, 0, &hpoutr_mux,
  1963. out_pga_event, SND_SOC_DAPM_POST_PMU),
  1964. SND_SOC_DAPM_PGA_E("HPOUT", SND_SOC_NOPM, 0, 0, NULL, 0, hp_event,
  1965. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  1966. SND_SOC_DAPM_OUTPUT("HPOUTL"),
  1967. SND_SOC_DAPM_OUTPUT("HPOUTR"),
  1968. };
  1969. static const struct snd_soc_dapm_widget wm8962_dapm_spk_mono_widgets[] = {
  1970. SND_SOC_DAPM_MIXER("Speaker Mixer", WM8962_MIXER_ENABLES, 1, 0,
  1971. spkmixl, ARRAY_SIZE(spkmixl)),
  1972. SND_SOC_DAPM_MUX_E("Speaker PGA", WM8962_PWR_MGMT_2, 4, 0, &spkoutl_mux,
  1973. out_pga_event, SND_SOC_DAPM_POST_PMU),
  1974. SND_SOC_DAPM_PGA("Speaker Output", WM8962_CLASS_D_CONTROL_1, 7, 0, NULL, 0),
  1975. SND_SOC_DAPM_OUTPUT("SPKOUT"),
  1976. };
  1977. static const struct snd_soc_dapm_widget wm8962_dapm_spk_stereo_widgets[] = {
  1978. SND_SOC_DAPM_MIXER("SPKOUTL Mixer", WM8962_MIXER_ENABLES, 1, 0,
  1979. spkmixl, ARRAY_SIZE(spkmixl)),
  1980. SND_SOC_DAPM_MIXER("SPKOUTR Mixer", WM8962_MIXER_ENABLES, 0, 0,
  1981. spkmixr, ARRAY_SIZE(spkmixr)),
  1982. SND_SOC_DAPM_MUX_E("SPKOUTL PGA", WM8962_PWR_MGMT_2, 4, 0, &spkoutl_mux,
  1983. out_pga_event, SND_SOC_DAPM_POST_PMU),
  1984. SND_SOC_DAPM_MUX_E("SPKOUTR PGA", WM8962_PWR_MGMT_2, 3, 0, &spkoutr_mux,
  1985. out_pga_event, SND_SOC_DAPM_POST_PMU),
  1986. SND_SOC_DAPM_PGA("SPKOUTR Output", WM8962_CLASS_D_CONTROL_1, 7, 0, NULL, 0),
  1987. SND_SOC_DAPM_PGA("SPKOUTL Output", WM8962_CLASS_D_CONTROL_1, 6, 0, NULL, 0),
  1988. SND_SOC_DAPM_OUTPUT("SPKOUTL"),
  1989. SND_SOC_DAPM_OUTPUT("SPKOUTR"),
  1990. };
  1991. static const struct snd_soc_dapm_route wm8962_intercon[] = {
  1992. { "INPGAL", "IN1L Switch", "IN1L" },
  1993. { "INPGAL", "IN2L Switch", "IN2L" },
  1994. { "INPGAL", "IN3L Switch", "IN3L" },
  1995. { "INPGAL", "IN4L Switch", "IN4L" },
  1996. { "INPGAR", "IN1R Switch", "IN1R" },
  1997. { "INPGAR", "IN2R Switch", "IN2R" },
  1998. { "INPGAR", "IN3R Switch", "IN3R" },
  1999. { "INPGAR", "IN4R Switch", "IN4R" },
  2000. { "MIXINL", "IN2L Switch", "IN2L" },
  2001. { "MIXINL", "IN3L Switch", "IN3L" },
  2002. { "MIXINL", "PGA Switch", "INPGAL" },
  2003. { "MIXINR", "IN2R Switch", "IN2R" },
  2004. { "MIXINR", "IN3R Switch", "IN3R" },
  2005. { "MIXINR", "PGA Switch", "INPGAR" },
  2006. { "MICBIAS", NULL, "SYSCLK" },
  2007. { "DMIC_ENA", NULL, "DMICDAT" },
  2008. { "ADCL", NULL, "SYSCLK" },
  2009. { "ADCL", NULL, "TOCLK" },
  2010. { "ADCL", NULL, "MIXINL" },
  2011. { "ADCL", NULL, "DMIC_ENA" },
  2012. { "ADCL", NULL, "DSP2" },
  2013. { "ADCR", NULL, "SYSCLK" },
  2014. { "ADCR", NULL, "TOCLK" },
  2015. { "ADCR", NULL, "MIXINR" },
  2016. { "ADCR", NULL, "DMIC_ENA" },
  2017. { "ADCR", NULL, "DSP2" },
  2018. { "STL", "Left", "ADCL" },
  2019. { "STL", "Right", "ADCR" },
  2020. { "STL", NULL, "Class G" },
  2021. { "STR", "Left", "ADCL" },
  2022. { "STR", "Right", "ADCR" },
  2023. { "STR", NULL, "Class G" },
  2024. { "DACL", NULL, "SYSCLK" },
  2025. { "DACL", NULL, "TOCLK" },
  2026. { "DACL", NULL, "Beep" },
  2027. { "DACL", NULL, "STL" },
  2028. { "DACL", NULL, "DSP2" },
  2029. { "DACR", NULL, "SYSCLK" },
  2030. { "DACR", NULL, "TOCLK" },
  2031. { "DACR", NULL, "Beep" },
  2032. { "DACR", NULL, "STR" },
  2033. { "DACR", NULL, "DSP2" },
  2034. { "HPMIXL", "IN4L Switch", "IN4L" },
  2035. { "HPMIXL", "IN4R Switch", "IN4R" },
  2036. { "HPMIXL", "DACL Switch", "DACL" },
  2037. { "HPMIXL", "DACR Switch", "DACR" },
  2038. { "HPMIXL", "MIXINL Switch", "MIXINL" },
  2039. { "HPMIXL", "MIXINR Switch", "MIXINR" },
  2040. { "HPMIXR", "IN4L Switch", "IN4L" },
  2041. { "HPMIXR", "IN4R Switch", "IN4R" },
  2042. { "HPMIXR", "DACL Switch", "DACL" },
  2043. { "HPMIXR", "DACR Switch", "DACR" },
  2044. { "HPMIXR", "MIXINL Switch", "MIXINL" },
  2045. { "HPMIXR", "MIXINR Switch", "MIXINR" },
  2046. { "Left Bypass", NULL, "HPMIXL" },
  2047. { "Left Bypass", NULL, "Class G" },
  2048. { "Right Bypass", NULL, "HPMIXR" },
  2049. { "Right Bypass", NULL, "Class G" },
  2050. { "HPOUTL PGA", "Mixer", "Left Bypass" },
  2051. { "HPOUTL PGA", "DAC", "DACL" },
  2052. { "HPOUTR PGA", "Mixer", "Right Bypass" },
  2053. { "HPOUTR PGA", "DAC", "DACR" },
  2054. { "HPOUT", NULL, "HPOUTL PGA" },
  2055. { "HPOUT", NULL, "HPOUTR PGA" },
  2056. { "HPOUT", NULL, "Charge Pump" },
  2057. { "HPOUT", NULL, "SYSCLK" },
  2058. { "HPOUT", NULL, "TOCLK" },
  2059. { "HPOUTL", NULL, "HPOUT" },
  2060. { "HPOUTR", NULL, "HPOUT" },
  2061. { "HPOUTL", NULL, "TEMP_HP" },
  2062. { "HPOUTR", NULL, "TEMP_HP" },
  2063. };
  2064. static const struct snd_soc_dapm_route wm8962_spk_mono_intercon[] = {
  2065. { "Speaker Mixer", "IN4L Switch", "IN4L" },
  2066. { "Speaker Mixer", "IN4R Switch", "IN4R" },
  2067. { "Speaker Mixer", "DACL Switch", "DACL" },
  2068. { "Speaker Mixer", "DACR Switch", "DACR" },
  2069. { "Speaker Mixer", "MIXINL Switch", "MIXINL" },
  2070. { "Speaker Mixer", "MIXINR Switch", "MIXINR" },
  2071. { "Speaker PGA", "Mixer", "Speaker Mixer" },
  2072. { "Speaker PGA", "DAC", "DACL" },
  2073. { "Speaker Output", NULL, "Speaker PGA" },
  2074. { "Speaker Output", NULL, "SYSCLK" },
  2075. { "Speaker Output", NULL, "TOCLK" },
  2076. { "Speaker Output", NULL, "TEMP_SPK" },
  2077. { "SPKOUT", NULL, "Speaker Output" },
  2078. };
  2079. static const struct snd_soc_dapm_route wm8962_spk_stereo_intercon[] = {
  2080. { "SPKOUTL Mixer", "IN4L Switch", "IN4L" },
  2081. { "SPKOUTL Mixer", "IN4R Switch", "IN4R" },
  2082. { "SPKOUTL Mixer", "DACL Switch", "DACL" },
  2083. { "SPKOUTL Mixer", "DACR Switch", "DACR" },
  2084. { "SPKOUTL Mixer", "MIXINL Switch", "MIXINL" },
  2085. { "SPKOUTL Mixer", "MIXINR Switch", "MIXINR" },
  2086. { "SPKOUTR Mixer", "IN4L Switch", "IN4L" },
  2087. { "SPKOUTR Mixer", "IN4R Switch", "IN4R" },
  2088. { "SPKOUTR Mixer", "DACL Switch", "DACL" },
  2089. { "SPKOUTR Mixer", "DACR Switch", "DACR" },
  2090. { "SPKOUTR Mixer", "MIXINL Switch", "MIXINL" },
  2091. { "SPKOUTR Mixer", "MIXINR Switch", "MIXINR" },
  2092. { "SPKOUTL PGA", "Mixer", "SPKOUTL Mixer" },
  2093. { "SPKOUTL PGA", "DAC", "DACL" },
  2094. { "SPKOUTR PGA", "Mixer", "SPKOUTR Mixer" },
  2095. { "SPKOUTR PGA", "DAC", "DACR" },
  2096. { "SPKOUTL Output", NULL, "SPKOUTL PGA" },
  2097. { "SPKOUTL Output", NULL, "SYSCLK" },
  2098. { "SPKOUTL Output", NULL, "TOCLK" },
  2099. { "SPKOUTL Output", NULL, "TEMP_SPK" },
  2100. { "SPKOUTR Output", NULL, "SPKOUTR PGA" },
  2101. { "SPKOUTR Output", NULL, "SYSCLK" },
  2102. { "SPKOUTR Output", NULL, "TOCLK" },
  2103. { "SPKOUTR Output", NULL, "TEMP_SPK" },
  2104. { "SPKOUTL", NULL, "SPKOUTL Output" },
  2105. { "SPKOUTR", NULL, "SPKOUTR Output" },
  2106. };
  2107. static int wm8962_add_widgets(struct snd_soc_component *component)
  2108. {
  2109. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2110. struct wm8962_pdata *pdata = &wm8962->pdata;
  2111. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  2112. snd_soc_add_component_controls(component, wm8962_snd_controls,
  2113. ARRAY_SIZE(wm8962_snd_controls));
  2114. if (pdata->spk_mono)
  2115. snd_soc_add_component_controls(component, wm8962_spk_mono_controls,
  2116. ARRAY_SIZE(wm8962_spk_mono_controls));
  2117. else
  2118. snd_soc_add_component_controls(component, wm8962_spk_stereo_controls,
  2119. ARRAY_SIZE(wm8962_spk_stereo_controls));
  2120. snd_soc_dapm_new_controls(dapm, wm8962_dapm_widgets,
  2121. ARRAY_SIZE(wm8962_dapm_widgets));
  2122. if (pdata->spk_mono)
  2123. snd_soc_dapm_new_controls(dapm, wm8962_dapm_spk_mono_widgets,
  2124. ARRAY_SIZE(wm8962_dapm_spk_mono_widgets));
  2125. else
  2126. snd_soc_dapm_new_controls(dapm, wm8962_dapm_spk_stereo_widgets,
  2127. ARRAY_SIZE(wm8962_dapm_spk_stereo_widgets));
  2128. snd_soc_dapm_add_routes(dapm, wm8962_intercon,
  2129. ARRAY_SIZE(wm8962_intercon));
  2130. if (pdata->spk_mono)
  2131. snd_soc_dapm_add_routes(dapm, wm8962_spk_mono_intercon,
  2132. ARRAY_SIZE(wm8962_spk_mono_intercon));
  2133. else
  2134. snd_soc_dapm_add_routes(dapm, wm8962_spk_stereo_intercon,
  2135. ARRAY_SIZE(wm8962_spk_stereo_intercon));
  2136. snd_soc_dapm_disable_pin(dapm, "Beep");
  2137. return 0;
  2138. }
  2139. /* -1 for reserved values */
  2140. static const int bclk_divs[] = {
  2141. 1, -1, 2, 3, 4, -1, 6, 8, -1, 12, 16, 24, -1, 32, 32, 32
  2142. };
  2143. static const int sysclk_rates[] = {
  2144. 64, 128, 192, 256, 384, 512, 768, 1024, 1408, 1536, 3072, 6144
  2145. };
  2146. static void wm8962_configure_bclk(struct snd_soc_component *component)
  2147. {
  2148. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2149. int dspclk, i;
  2150. int clocking2 = 0;
  2151. int clocking4 = 0;
  2152. int aif2 = 0;
  2153. if (!wm8962->sysclk_rate) {
  2154. dev_dbg(component->dev, "No SYSCLK configured\n");
  2155. return;
  2156. }
  2157. if (!wm8962->bclk || !wm8962->lrclk) {
  2158. dev_dbg(component->dev, "No audio clocks configured\n");
  2159. return;
  2160. }
  2161. for (i = 0; i < ARRAY_SIZE(sysclk_rates); i++) {
  2162. if (sysclk_rates[i] == wm8962->sysclk_rate / wm8962->lrclk) {
  2163. clocking4 |= i << WM8962_SYSCLK_RATE_SHIFT;
  2164. break;
  2165. }
  2166. }
  2167. if (i == ARRAY_SIZE(sysclk_rates)) {
  2168. dev_err(component->dev, "Unsupported sysclk ratio %d\n",
  2169. wm8962->sysclk_rate / wm8962->lrclk);
  2170. return;
  2171. }
  2172. dev_dbg(component->dev, "Selected sysclk ratio %d\n", sysclk_rates[i]);
  2173. snd_soc_component_update_bits(component, WM8962_CLOCKING_4,
  2174. WM8962_SYSCLK_RATE_MASK, clocking4);
  2175. /* DSPCLK_DIV can be only generated correctly after enabling SYSCLK.
  2176. * So we here provisionally enable it and then disable it afterward
  2177. * if current bias_level hasn't reached SND_SOC_BIAS_ON.
  2178. */
  2179. if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON)
  2180. snd_soc_component_update_bits(component, WM8962_CLOCKING2,
  2181. WM8962_SYSCLK_ENA_MASK, WM8962_SYSCLK_ENA);
  2182. dspclk = snd_soc_component_read(component, WM8962_CLOCKING1);
  2183. if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON)
  2184. snd_soc_component_update_bits(component, WM8962_CLOCKING2,
  2185. WM8962_SYSCLK_ENA_MASK, 0);
  2186. if (dspclk < 0) {
  2187. dev_err(component->dev, "Failed to read DSPCLK: %d\n", dspclk);
  2188. return;
  2189. }
  2190. dspclk = (dspclk & WM8962_DSPCLK_DIV_MASK) >> WM8962_DSPCLK_DIV_SHIFT;
  2191. switch (dspclk) {
  2192. case 0:
  2193. dspclk = wm8962->sysclk_rate;
  2194. break;
  2195. case 1:
  2196. dspclk = wm8962->sysclk_rate / 2;
  2197. break;
  2198. case 2:
  2199. dspclk = wm8962->sysclk_rate / 4;
  2200. break;
  2201. default:
  2202. dev_warn(component->dev, "Unknown DSPCLK divisor read back\n");
  2203. dspclk = wm8962->sysclk_rate;
  2204. }
  2205. dev_dbg(component->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk);
  2206. /* We're expecting an exact match */
  2207. for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) {
  2208. if (bclk_divs[i] < 0)
  2209. continue;
  2210. if (dspclk / bclk_divs[i] == wm8962->bclk) {
  2211. dev_dbg(component->dev, "Selected BCLK_DIV %d for %dHz\n",
  2212. bclk_divs[i], wm8962->bclk);
  2213. clocking2 |= i;
  2214. break;
  2215. }
  2216. }
  2217. if (i == ARRAY_SIZE(bclk_divs)) {
  2218. dev_err(component->dev, "Unsupported BCLK ratio %d\n",
  2219. dspclk / wm8962->bclk);
  2220. return;
  2221. }
  2222. aif2 |= wm8962->bclk / wm8962->lrclk;
  2223. dev_dbg(component->dev, "Selected LRCLK divisor %d for %dHz\n",
  2224. wm8962->bclk / wm8962->lrclk, wm8962->lrclk);
  2225. snd_soc_component_update_bits(component, WM8962_CLOCKING2,
  2226. WM8962_BCLK_DIV_MASK, clocking2);
  2227. snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_2,
  2228. WM8962_AIF_RATE_MASK, aif2);
  2229. }
  2230. static int wm8962_set_bias_level(struct snd_soc_component *component,
  2231. enum snd_soc_bias_level level)
  2232. {
  2233. switch (level) {
  2234. case SND_SOC_BIAS_ON:
  2235. break;
  2236. case SND_SOC_BIAS_PREPARE:
  2237. /* VMID 2*50k */
  2238. snd_soc_component_update_bits(component, WM8962_PWR_MGMT_1,
  2239. WM8962_VMID_SEL_MASK, 0x80);
  2240. wm8962_configure_bclk(component);
  2241. break;
  2242. case SND_SOC_BIAS_STANDBY:
  2243. /* VMID 2*250k */
  2244. snd_soc_component_update_bits(component, WM8962_PWR_MGMT_1,
  2245. WM8962_VMID_SEL_MASK, 0x100);
  2246. if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
  2247. msleep(100);
  2248. break;
  2249. case SND_SOC_BIAS_OFF:
  2250. break;
  2251. }
  2252. return 0;
  2253. }
  2254. static const struct {
  2255. int rate;
  2256. int reg;
  2257. } sr_vals[] = {
  2258. { 48000, 0 },
  2259. { 44100, 0 },
  2260. { 32000, 1 },
  2261. { 22050, 2 },
  2262. { 24000, 2 },
  2263. { 16000, 3 },
  2264. { 11025, 4 },
  2265. { 12000, 4 },
  2266. { 8000, 5 },
  2267. { 88200, 6 },
  2268. { 96000, 6 },
  2269. };
  2270. static int wm8962_hw_params(struct snd_pcm_substream *substream,
  2271. struct snd_pcm_hw_params *params,
  2272. struct snd_soc_dai *dai)
  2273. {
  2274. struct snd_soc_component *component = dai->component;
  2275. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2276. int i;
  2277. int aif0 = 0;
  2278. int adctl3 = 0;
  2279. wm8962->bclk = snd_soc_params_to_bclk(params);
  2280. if (params_channels(params) == 1)
  2281. wm8962->bclk *= 2;
  2282. wm8962->lrclk = params_rate(params);
  2283. for (i = 0; i < ARRAY_SIZE(sr_vals); i++) {
  2284. if (sr_vals[i].rate == wm8962->lrclk) {
  2285. adctl3 |= sr_vals[i].reg;
  2286. break;
  2287. }
  2288. }
  2289. if (i == ARRAY_SIZE(sr_vals)) {
  2290. dev_err(component->dev, "Unsupported rate %dHz\n", wm8962->lrclk);
  2291. return -EINVAL;
  2292. }
  2293. if (wm8962->lrclk % 8000 == 0)
  2294. adctl3 |= WM8962_SAMPLE_RATE_INT_MODE;
  2295. switch (params_width(params)) {
  2296. case 16:
  2297. break;
  2298. case 20:
  2299. aif0 |= 0x4;
  2300. break;
  2301. case 24:
  2302. aif0 |= 0x8;
  2303. break;
  2304. case 32:
  2305. aif0 |= 0xc;
  2306. break;
  2307. default:
  2308. return -EINVAL;
  2309. }
  2310. snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_0,
  2311. WM8962_WL_MASK, aif0);
  2312. snd_soc_component_update_bits(component, WM8962_ADDITIONAL_CONTROL_3,
  2313. WM8962_SAMPLE_RATE_INT_MODE |
  2314. WM8962_SAMPLE_RATE_MASK, adctl3);
  2315. dev_dbg(component->dev, "hw_params set BCLK %dHz LRCLK %dHz\n",
  2316. wm8962->bclk, wm8962->lrclk);
  2317. if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON)
  2318. wm8962_configure_bclk(component);
  2319. return 0;
  2320. }
  2321. static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
  2322. unsigned int freq, int dir)
  2323. {
  2324. struct snd_soc_component *component = dai->component;
  2325. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2326. int src;
  2327. switch (clk_id) {
  2328. case WM8962_SYSCLK_MCLK:
  2329. wm8962->sysclk = WM8962_SYSCLK_MCLK;
  2330. src = 0;
  2331. break;
  2332. case WM8962_SYSCLK_FLL:
  2333. wm8962->sysclk = WM8962_SYSCLK_FLL;
  2334. src = 1 << WM8962_SYSCLK_SRC_SHIFT;
  2335. break;
  2336. default:
  2337. return -EINVAL;
  2338. }
  2339. snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_SYSCLK_SRC_MASK,
  2340. src);
  2341. wm8962->sysclk_rate = freq;
  2342. return 0;
  2343. }
  2344. static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2345. {
  2346. struct snd_soc_component *component = dai->component;
  2347. int aif0 = 0;
  2348. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  2349. case SND_SOC_DAIFMT_DSP_B:
  2350. aif0 |= WM8962_LRCLK_INV | 3;
  2351. fallthrough;
  2352. case SND_SOC_DAIFMT_DSP_A:
  2353. aif0 |= 3;
  2354. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  2355. case SND_SOC_DAIFMT_NB_NF:
  2356. case SND_SOC_DAIFMT_IB_NF:
  2357. break;
  2358. default:
  2359. return -EINVAL;
  2360. }
  2361. break;
  2362. case SND_SOC_DAIFMT_RIGHT_J:
  2363. break;
  2364. case SND_SOC_DAIFMT_LEFT_J:
  2365. aif0 |= 1;
  2366. break;
  2367. case SND_SOC_DAIFMT_I2S:
  2368. aif0 |= 2;
  2369. break;
  2370. default:
  2371. return -EINVAL;
  2372. }
  2373. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  2374. case SND_SOC_DAIFMT_NB_NF:
  2375. break;
  2376. case SND_SOC_DAIFMT_IB_NF:
  2377. aif0 |= WM8962_BCLK_INV;
  2378. break;
  2379. case SND_SOC_DAIFMT_NB_IF:
  2380. aif0 |= WM8962_LRCLK_INV;
  2381. break;
  2382. case SND_SOC_DAIFMT_IB_IF:
  2383. aif0 |= WM8962_BCLK_INV | WM8962_LRCLK_INV;
  2384. break;
  2385. default:
  2386. return -EINVAL;
  2387. }
  2388. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  2389. case SND_SOC_DAIFMT_CBM_CFM:
  2390. aif0 |= WM8962_MSTR;
  2391. break;
  2392. case SND_SOC_DAIFMT_CBS_CFS:
  2393. break;
  2394. default:
  2395. return -EINVAL;
  2396. }
  2397. snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_0,
  2398. WM8962_FMT_MASK | WM8962_BCLK_INV | WM8962_MSTR |
  2399. WM8962_LRCLK_INV, aif0);
  2400. return 0;
  2401. }
  2402. struct _fll_div {
  2403. u16 fll_fratio;
  2404. u16 fll_outdiv;
  2405. u16 fll_refclk_div;
  2406. u16 n;
  2407. u16 theta;
  2408. u16 lambda;
  2409. };
  2410. /* The size in bits of the FLL divide multiplied by 10
  2411. * to allow rounding later */
  2412. #define FIXED_FLL_SIZE ((1 << 16) * 10)
  2413. static struct {
  2414. unsigned int min;
  2415. unsigned int max;
  2416. u16 fll_fratio;
  2417. int ratio;
  2418. } fll_fratios[] = {
  2419. { 0, 64000, 4, 16 },
  2420. { 64000, 128000, 3, 8 },
  2421. { 128000, 256000, 2, 4 },
  2422. { 256000, 1000000, 1, 2 },
  2423. { 1000000, 13500000, 0, 1 },
  2424. };
  2425. static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
  2426. unsigned int Fout)
  2427. {
  2428. unsigned int target;
  2429. unsigned int div;
  2430. unsigned int fratio, gcd_fll;
  2431. int i;
  2432. /* Fref must be <=13.5MHz */
  2433. div = 1;
  2434. fll_div->fll_refclk_div = 0;
  2435. while ((Fref / div) > 13500000) {
  2436. div *= 2;
  2437. fll_div->fll_refclk_div++;
  2438. if (div > 4) {
  2439. pr_err("Can't scale %dMHz input down to <=13.5MHz\n",
  2440. Fref);
  2441. return -EINVAL;
  2442. }
  2443. }
  2444. pr_debug("FLL Fref=%u Fout=%u\n", Fref, Fout);
  2445. /* Apply the division for our remaining calculations */
  2446. Fref /= div;
  2447. /* Fvco should be 90-100MHz; don't check the upper bound */
  2448. div = 2;
  2449. while (Fout * div < 90000000) {
  2450. div++;
  2451. if (div > 64) {
  2452. pr_err("Unable to find FLL_OUTDIV for Fout=%uHz\n",
  2453. Fout);
  2454. return -EINVAL;
  2455. }
  2456. }
  2457. target = Fout * div;
  2458. fll_div->fll_outdiv = div - 1;
  2459. pr_debug("FLL Fvco=%dHz\n", target);
  2460. /* Find an appropriate FLL_FRATIO and factor it out of the target */
  2461. for (i = 0; i < ARRAY_SIZE(fll_fratios); i++) {
  2462. if (fll_fratios[i].min <= Fref && Fref <= fll_fratios[i].max) {
  2463. fll_div->fll_fratio = fll_fratios[i].fll_fratio;
  2464. fratio = fll_fratios[i].ratio;
  2465. break;
  2466. }
  2467. }
  2468. if (i == ARRAY_SIZE(fll_fratios)) {
  2469. pr_err("Unable to find FLL_FRATIO for Fref=%uHz\n", Fref);
  2470. return -EINVAL;
  2471. }
  2472. fll_div->n = target / (fratio * Fref);
  2473. if (target % Fref == 0) {
  2474. fll_div->theta = 0;
  2475. fll_div->lambda = 1;
  2476. } else {
  2477. gcd_fll = gcd(target, fratio * Fref);
  2478. fll_div->theta = (target - (fll_div->n * fratio * Fref))
  2479. / gcd_fll;
  2480. fll_div->lambda = (fratio * Fref) / gcd_fll;
  2481. }
  2482. pr_debug("FLL N=%x THETA=%x LAMBDA=%x\n",
  2483. fll_div->n, fll_div->theta, fll_div->lambda);
  2484. pr_debug("FLL_FRATIO=%x FLL_OUTDIV=%x FLL_REFCLK_DIV=%x\n",
  2485. fll_div->fll_fratio, fll_div->fll_outdiv,
  2486. fll_div->fll_refclk_div);
  2487. return 0;
  2488. }
  2489. static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int source,
  2490. unsigned int Fref, unsigned int Fout)
  2491. {
  2492. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2493. struct _fll_div fll_div;
  2494. unsigned long timeout;
  2495. int ret;
  2496. int fll1 = 0;
  2497. /* Any change? */
  2498. if (source == wm8962->fll_src && Fref == wm8962->fll_fref &&
  2499. Fout == wm8962->fll_fout)
  2500. return 0;
  2501. if (Fout == 0) {
  2502. dev_dbg(component->dev, "FLL disabled\n");
  2503. wm8962->fll_fref = 0;
  2504. wm8962->fll_fout = 0;
  2505. snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1,
  2506. WM8962_FLL_ENA, 0);
  2507. pm_runtime_put(component->dev);
  2508. return 0;
  2509. }
  2510. ret = fll_factors(&fll_div, Fref, Fout);
  2511. if (ret != 0)
  2512. return ret;
  2513. /* Parameters good, disable so we can reprogram */
  2514. snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0);
  2515. switch (fll_id) {
  2516. case WM8962_FLL_MCLK:
  2517. case WM8962_FLL_BCLK:
  2518. case WM8962_FLL_OSC:
  2519. fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
  2520. break;
  2521. case WM8962_FLL_INT:
  2522. snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1,
  2523. WM8962_FLL_OSC_ENA, WM8962_FLL_OSC_ENA);
  2524. snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_5,
  2525. WM8962_FLL_FRC_NCO, WM8962_FLL_FRC_NCO);
  2526. break;
  2527. default:
  2528. dev_err(component->dev, "Unknown FLL source %d\n", ret);
  2529. return -EINVAL;
  2530. }
  2531. if (fll_div.theta)
  2532. fll1 |= WM8962_FLL_FRAC;
  2533. /* Stop the FLL while we reconfigure */
  2534. snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0);
  2535. snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_2,
  2536. WM8962_FLL_OUTDIV_MASK |
  2537. WM8962_FLL_REFCLK_DIV_MASK,
  2538. (fll_div.fll_outdiv << WM8962_FLL_OUTDIV_SHIFT) |
  2539. (fll_div.fll_refclk_div));
  2540. snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_3,
  2541. WM8962_FLL_FRATIO_MASK, fll_div.fll_fratio);
  2542. snd_soc_component_write(component, WM8962_FLL_CONTROL_6, fll_div.theta);
  2543. snd_soc_component_write(component, WM8962_FLL_CONTROL_7, fll_div.lambda);
  2544. snd_soc_component_write(component, WM8962_FLL_CONTROL_8, fll_div.n);
  2545. reinit_completion(&wm8962->fll_lock);
  2546. ret = pm_runtime_get_sync(component->dev);
  2547. if (ret < 0) {
  2548. pm_runtime_put_noidle(component->dev);
  2549. dev_err(component->dev, "Failed to resume device: %d\n", ret);
  2550. return ret;
  2551. }
  2552. snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1,
  2553. WM8962_FLL_FRAC | WM8962_FLL_REFCLK_SRC_MASK |
  2554. WM8962_FLL_ENA, fll1 | WM8962_FLL_ENA);
  2555. dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout);
  2556. /* This should be a massive overestimate but go even
  2557. * higher if we'll error out
  2558. */
  2559. if (wm8962->irq)
  2560. timeout = msecs_to_jiffies(5);
  2561. else
  2562. timeout = msecs_to_jiffies(1);
  2563. timeout = wait_for_completion_timeout(&wm8962->fll_lock,
  2564. timeout);
  2565. if (timeout == 0 && wm8962->irq) {
  2566. dev_err(component->dev, "FLL lock timed out");
  2567. snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1,
  2568. WM8962_FLL_ENA, 0);
  2569. pm_runtime_put(component->dev);
  2570. return -ETIMEDOUT;
  2571. }
  2572. wm8962->fll_fref = Fref;
  2573. wm8962->fll_fout = Fout;
  2574. wm8962->fll_src = source;
  2575. return 0;
  2576. }
  2577. static int wm8962_mute(struct snd_soc_dai *dai, int mute, int direction)
  2578. {
  2579. struct snd_soc_component *component = dai->component;
  2580. int val, ret;
  2581. if (mute)
  2582. val = WM8962_DAC_MUTE | WM8962_DAC_MUTE_ALT;
  2583. else
  2584. val = 0;
  2585. /**
  2586. * The DAC mute bit is mirrored in two registers, update both to keep
  2587. * the register cache consistent.
  2588. */
  2589. ret = snd_soc_component_update_bits(component, WM8962_CLASS_D_CONTROL_1,
  2590. WM8962_DAC_MUTE_ALT, val);
  2591. if (ret < 0)
  2592. return ret;
  2593. return snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1,
  2594. WM8962_DAC_MUTE, val);
  2595. }
  2596. #define WM8962_RATES (SNDRV_PCM_RATE_8000_48000 |\
  2597. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
  2598. #define WM8962_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
  2599. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
  2600. static const struct snd_soc_dai_ops wm8962_dai_ops = {
  2601. .hw_params = wm8962_hw_params,
  2602. .set_sysclk = wm8962_set_dai_sysclk,
  2603. .set_fmt = wm8962_set_dai_fmt,
  2604. .mute_stream = wm8962_mute,
  2605. .no_capture_mute = 1,
  2606. };
  2607. static struct snd_soc_dai_driver wm8962_dai = {
  2608. .name = "wm8962",
  2609. .playback = {
  2610. .stream_name = "Playback",
  2611. .channels_min = 1,
  2612. .channels_max = 2,
  2613. .rates = WM8962_RATES,
  2614. .formats = WM8962_FORMATS,
  2615. },
  2616. .capture = {
  2617. .stream_name = "Capture",
  2618. .channels_min = 1,
  2619. .channels_max = 2,
  2620. .rates = WM8962_RATES,
  2621. .formats = WM8962_FORMATS,
  2622. },
  2623. .ops = &wm8962_dai_ops,
  2624. .symmetric_rates = 1,
  2625. };
  2626. static void wm8962_mic_work(struct work_struct *work)
  2627. {
  2628. struct wm8962_priv *wm8962 = container_of(work,
  2629. struct wm8962_priv,
  2630. mic_work.work);
  2631. struct snd_soc_component *component = wm8962->component;
  2632. int status = 0;
  2633. int irq_pol = 0;
  2634. int reg;
  2635. reg = snd_soc_component_read(component, WM8962_ADDITIONAL_CONTROL_4);
  2636. if (reg & WM8962_MICDET_STS) {
  2637. status |= SND_JACK_MICROPHONE;
  2638. irq_pol |= WM8962_MICD_IRQ_POL;
  2639. }
  2640. if (reg & WM8962_MICSHORT_STS) {
  2641. status |= SND_JACK_BTN_0;
  2642. irq_pol |= WM8962_MICSCD_IRQ_POL;
  2643. }
  2644. snd_soc_jack_report(wm8962->jack, status,
  2645. SND_JACK_MICROPHONE | SND_JACK_BTN_0);
  2646. snd_soc_component_update_bits(component, WM8962_MICINT_SOURCE_POL,
  2647. WM8962_MICSCD_IRQ_POL |
  2648. WM8962_MICD_IRQ_POL, irq_pol);
  2649. }
  2650. static irqreturn_t wm8962_irq(int irq, void *data)
  2651. {
  2652. struct device *dev = data;
  2653. struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
  2654. unsigned int mask;
  2655. unsigned int active;
  2656. int reg, ret;
  2657. ret = pm_runtime_get_sync(dev);
  2658. if (ret < 0) {
  2659. pm_runtime_put_noidle(dev);
  2660. dev_err(dev, "Failed to resume: %d\n", ret);
  2661. return IRQ_NONE;
  2662. }
  2663. ret = regmap_read(wm8962->regmap, WM8962_INTERRUPT_STATUS_2_MASK,
  2664. &mask);
  2665. if (ret != 0) {
  2666. pm_runtime_put(dev);
  2667. dev_err(dev, "Failed to read interrupt mask: %d\n",
  2668. ret);
  2669. return IRQ_NONE;
  2670. }
  2671. ret = regmap_read(wm8962->regmap, WM8962_INTERRUPT_STATUS_2, &active);
  2672. if (ret != 0) {
  2673. pm_runtime_put(dev);
  2674. dev_err(dev, "Failed to read interrupt: %d\n", ret);
  2675. return IRQ_NONE;
  2676. }
  2677. active &= ~mask;
  2678. if (!active) {
  2679. pm_runtime_put(dev);
  2680. return IRQ_NONE;
  2681. }
  2682. /* Acknowledge the interrupts */
  2683. ret = regmap_write(wm8962->regmap, WM8962_INTERRUPT_STATUS_2, active);
  2684. if (ret != 0)
  2685. dev_warn(dev, "Failed to ack interrupt: %d\n", ret);
  2686. if (active & WM8962_FLL_LOCK_EINT) {
  2687. dev_dbg(dev, "FLL locked\n");
  2688. complete(&wm8962->fll_lock);
  2689. }
  2690. if (active & WM8962_FIFOS_ERR_EINT)
  2691. dev_err(dev, "FIFO error\n");
  2692. if (active & WM8962_TEMP_SHUT_EINT) {
  2693. dev_crit(dev, "Thermal shutdown\n");
  2694. ret = regmap_read(wm8962->regmap,
  2695. WM8962_THERMAL_SHUTDOWN_STATUS, &reg);
  2696. if (ret != 0) {
  2697. dev_warn(dev, "Failed to read thermal status: %d\n",
  2698. ret);
  2699. reg = 0;
  2700. }
  2701. if (reg & WM8962_TEMP_ERR_HP)
  2702. dev_crit(dev, "Headphone thermal error\n");
  2703. if (reg & WM8962_TEMP_WARN_HP)
  2704. dev_crit(dev, "Headphone thermal warning\n");
  2705. if (reg & WM8962_TEMP_ERR_SPK)
  2706. dev_crit(dev, "Speaker thermal error\n");
  2707. if (reg & WM8962_TEMP_WARN_SPK)
  2708. dev_crit(dev, "Speaker thermal warning\n");
  2709. }
  2710. if (active & (WM8962_MICSCD_EINT | WM8962_MICD_EINT)) {
  2711. dev_dbg(dev, "Microphone event detected\n");
  2712. #ifndef CONFIG_SND_SOC_WM8962_MODULE
  2713. trace_snd_soc_jack_irq(dev_name(dev));
  2714. #endif
  2715. pm_wakeup_event(dev, 300);
  2716. queue_delayed_work(system_power_efficient_wq,
  2717. &wm8962->mic_work,
  2718. msecs_to_jiffies(250));
  2719. }
  2720. pm_runtime_put(dev);
  2721. return IRQ_HANDLED;
  2722. }
  2723. /**
  2724. * wm8962_mic_detect - Enable microphone detection via the WM8962 IRQ
  2725. *
  2726. * @component: WM8962 component
  2727. * @jack: jack to report detection events on
  2728. *
  2729. * Enable microphone detection via IRQ on the WM8962. If GPIOs are
  2730. * being used to bring out signals to the processor then only platform
  2731. * data configuration is needed for WM8962 and processor GPIOs should
  2732. * be configured using snd_soc_jack_add_gpios() instead.
  2733. *
  2734. * If no jack is supplied detection will be disabled.
  2735. */
  2736. int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack)
  2737. {
  2738. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2739. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  2740. int irq_mask, enable;
  2741. wm8962->jack = jack;
  2742. if (jack) {
  2743. irq_mask = 0;
  2744. enable = WM8962_MICDET_ENA;
  2745. } else {
  2746. irq_mask = WM8962_MICD_EINT | WM8962_MICSCD_EINT;
  2747. enable = 0;
  2748. }
  2749. snd_soc_component_update_bits(component, WM8962_INTERRUPT_STATUS_2_MASK,
  2750. WM8962_MICD_EINT | WM8962_MICSCD_EINT, irq_mask);
  2751. snd_soc_component_update_bits(component, WM8962_ADDITIONAL_CONTROL_4,
  2752. WM8962_MICDET_ENA, enable);
  2753. /* Send an initial empty report */
  2754. snd_soc_jack_report(wm8962->jack, 0,
  2755. SND_JACK_MICROPHONE | SND_JACK_BTN_0);
  2756. snd_soc_dapm_mutex_lock(dapm);
  2757. if (jack) {
  2758. snd_soc_dapm_force_enable_pin_unlocked(dapm, "SYSCLK");
  2759. snd_soc_dapm_force_enable_pin_unlocked(dapm, "MICBIAS");
  2760. } else {
  2761. snd_soc_dapm_disable_pin_unlocked(dapm, "SYSCLK");
  2762. snd_soc_dapm_disable_pin_unlocked(dapm, "MICBIAS");
  2763. }
  2764. snd_soc_dapm_mutex_unlock(dapm);
  2765. return 0;
  2766. }
  2767. EXPORT_SYMBOL_GPL(wm8962_mic_detect);
  2768. static int beep_rates[] = {
  2769. 500, 1000, 2000, 4000,
  2770. };
  2771. static void wm8962_beep_work(struct work_struct *work)
  2772. {
  2773. struct wm8962_priv *wm8962 =
  2774. container_of(work, struct wm8962_priv, beep_work);
  2775. struct snd_soc_component *component = wm8962->component;
  2776. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  2777. int i;
  2778. int reg = 0;
  2779. int best = 0;
  2780. if (wm8962->beep_rate) {
  2781. for (i = 0; i < ARRAY_SIZE(beep_rates); i++) {
  2782. if (abs(wm8962->beep_rate - beep_rates[i]) <
  2783. abs(wm8962->beep_rate - beep_rates[best]))
  2784. best = i;
  2785. }
  2786. dev_dbg(component->dev, "Set beep rate %dHz for requested %dHz\n",
  2787. beep_rates[best], wm8962->beep_rate);
  2788. reg = WM8962_BEEP_ENA | (best << WM8962_BEEP_RATE_SHIFT);
  2789. snd_soc_dapm_enable_pin(dapm, "Beep");
  2790. } else {
  2791. dev_dbg(component->dev, "Disabling beep\n");
  2792. snd_soc_dapm_disable_pin(dapm, "Beep");
  2793. }
  2794. snd_soc_component_update_bits(component, WM8962_BEEP_GENERATOR_1,
  2795. WM8962_BEEP_ENA | WM8962_BEEP_RATE_MASK, reg);
  2796. snd_soc_dapm_sync(dapm);
  2797. }
  2798. /* For usability define a way of injecting beep events for the device -
  2799. * many systems will not have a keyboard.
  2800. */
  2801. static int wm8962_beep_event(struct input_dev *dev, unsigned int type,
  2802. unsigned int code, int hz)
  2803. {
  2804. struct snd_soc_component *component = input_get_drvdata(dev);
  2805. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2806. dev_dbg(component->dev, "Beep event %x %x\n", code, hz);
  2807. switch (code) {
  2808. case SND_BELL:
  2809. if (hz)
  2810. hz = 1000;
  2811. case SND_TONE:
  2812. break;
  2813. default:
  2814. return -1;
  2815. }
  2816. /* Kick the beep from a workqueue */
  2817. wm8962->beep_rate = hz;
  2818. schedule_work(&wm8962->beep_work);
  2819. return 0;
  2820. }
  2821. static ssize_t wm8962_beep_set(struct device *dev,
  2822. struct device_attribute *attr,
  2823. const char *buf, size_t count)
  2824. {
  2825. struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
  2826. long int time;
  2827. int ret;
  2828. ret = kstrtol(buf, 10, &time);
  2829. if (ret != 0)
  2830. return ret;
  2831. input_event(wm8962->beep, EV_SND, SND_TONE, time);
  2832. return count;
  2833. }
  2834. static DEVICE_ATTR(beep, 0200, NULL, wm8962_beep_set);
  2835. static void wm8962_init_beep(struct snd_soc_component *component)
  2836. {
  2837. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2838. int ret;
  2839. wm8962->beep = devm_input_allocate_device(component->dev);
  2840. if (!wm8962->beep) {
  2841. dev_err(component->dev, "Failed to allocate beep device\n");
  2842. return;
  2843. }
  2844. INIT_WORK(&wm8962->beep_work, wm8962_beep_work);
  2845. wm8962->beep_rate = 0;
  2846. wm8962->beep->name = "WM8962 Beep Generator";
  2847. wm8962->beep->phys = dev_name(component->dev);
  2848. wm8962->beep->id.bustype = BUS_I2C;
  2849. wm8962->beep->evbit[0] = BIT_MASK(EV_SND);
  2850. wm8962->beep->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
  2851. wm8962->beep->event = wm8962_beep_event;
  2852. wm8962->beep->dev.parent = component->dev;
  2853. input_set_drvdata(wm8962->beep, component);
  2854. ret = input_register_device(wm8962->beep);
  2855. if (ret != 0) {
  2856. wm8962->beep = NULL;
  2857. dev_err(component->dev, "Failed to register beep device\n");
  2858. }
  2859. ret = device_create_file(component->dev, &dev_attr_beep);
  2860. if (ret != 0) {
  2861. dev_err(component->dev, "Failed to create keyclick file: %d\n",
  2862. ret);
  2863. }
  2864. }
  2865. static void wm8962_free_beep(struct snd_soc_component *component)
  2866. {
  2867. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2868. device_remove_file(component->dev, &dev_attr_beep);
  2869. cancel_work_sync(&wm8962->beep_work);
  2870. wm8962->beep = NULL;
  2871. snd_soc_component_update_bits(component, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA,0);
  2872. }
  2873. static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio)
  2874. {
  2875. int mask = 0;
  2876. int val = 0;
  2877. /* Some of the GPIOs are behind MFP configuration and need to
  2878. * be put into GPIO mode. */
  2879. switch (gpio) {
  2880. case 2:
  2881. mask = WM8962_CLKOUT2_SEL_MASK;
  2882. val = 1 << WM8962_CLKOUT2_SEL_SHIFT;
  2883. break;
  2884. case 3:
  2885. mask = WM8962_CLKOUT3_SEL_MASK;
  2886. val = 1 << WM8962_CLKOUT3_SEL_SHIFT;
  2887. break;
  2888. default:
  2889. break;
  2890. }
  2891. if (mask)
  2892. regmap_update_bits(wm8962->regmap, WM8962_ANALOGUE_CLOCKING1,
  2893. mask, val);
  2894. }
  2895. #ifdef CONFIG_GPIOLIB
  2896. static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
  2897. {
  2898. struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
  2899. /* The WM8962 GPIOs aren't linearly numbered. For simplicity
  2900. * we export linear numbers and error out if the unsupported
  2901. * ones are requsted.
  2902. */
  2903. switch (offset + 1) {
  2904. case 2:
  2905. case 3:
  2906. case 5:
  2907. case 6:
  2908. break;
  2909. default:
  2910. return -EINVAL;
  2911. }
  2912. wm8962_set_gpio_mode(wm8962, offset + 1);
  2913. return 0;
  2914. }
  2915. static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
  2916. {
  2917. struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
  2918. struct snd_soc_component *component = wm8962->component;
  2919. snd_soc_component_update_bits(component, WM8962_GPIO_BASE + offset,
  2920. WM8962_GP2_LVL, !!value << WM8962_GP2_LVL_SHIFT);
  2921. }
  2922. static int wm8962_gpio_direction_out(struct gpio_chip *chip,
  2923. unsigned offset, int value)
  2924. {
  2925. struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
  2926. struct snd_soc_component *component = wm8962->component;
  2927. int ret, val;
  2928. /* Force function 1 (logic output) */
  2929. val = (1 << WM8962_GP2_FN_SHIFT) | (value << WM8962_GP2_LVL_SHIFT);
  2930. ret = snd_soc_component_update_bits(component, WM8962_GPIO_BASE + offset,
  2931. WM8962_GP2_FN_MASK | WM8962_GP2_LVL, val);
  2932. if (ret < 0)
  2933. return ret;
  2934. return 0;
  2935. }
  2936. static const struct gpio_chip wm8962_template_chip = {
  2937. .label = "wm8962",
  2938. .owner = THIS_MODULE,
  2939. .request = wm8962_gpio_request,
  2940. .direction_output = wm8962_gpio_direction_out,
  2941. .set = wm8962_gpio_set,
  2942. .can_sleep = 1,
  2943. };
  2944. static void wm8962_init_gpio(struct snd_soc_component *component)
  2945. {
  2946. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2947. struct wm8962_pdata *pdata = &wm8962->pdata;
  2948. int ret;
  2949. wm8962->gpio_chip = wm8962_template_chip;
  2950. wm8962->gpio_chip.ngpio = WM8962_MAX_GPIO;
  2951. wm8962->gpio_chip.parent = component->dev;
  2952. if (pdata->gpio_base)
  2953. wm8962->gpio_chip.base = pdata->gpio_base;
  2954. else
  2955. wm8962->gpio_chip.base = -1;
  2956. ret = gpiochip_add_data(&wm8962->gpio_chip, wm8962);
  2957. if (ret != 0)
  2958. dev_err(component->dev, "Failed to add GPIOs: %d\n", ret);
  2959. }
  2960. static void wm8962_free_gpio(struct snd_soc_component *component)
  2961. {
  2962. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2963. gpiochip_remove(&wm8962->gpio_chip);
  2964. }
  2965. #else
  2966. static void wm8962_init_gpio(struct snd_soc_component *component)
  2967. {
  2968. }
  2969. static void wm8962_free_gpio(struct snd_soc_component *component)
  2970. {
  2971. }
  2972. #endif
  2973. static int wm8962_probe(struct snd_soc_component *component)
  2974. {
  2975. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  2976. int ret;
  2977. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  2978. int i;
  2979. bool dmicclk, dmicdat;
  2980. wm8962->component = component;
  2981. wm8962->disable_nb[0].notifier_call = wm8962_regulator_event_0;
  2982. wm8962->disable_nb[1].notifier_call = wm8962_regulator_event_1;
  2983. wm8962->disable_nb[2].notifier_call = wm8962_regulator_event_2;
  2984. wm8962->disable_nb[3].notifier_call = wm8962_regulator_event_3;
  2985. wm8962->disable_nb[4].notifier_call = wm8962_regulator_event_4;
  2986. wm8962->disable_nb[5].notifier_call = wm8962_regulator_event_5;
  2987. wm8962->disable_nb[6].notifier_call = wm8962_regulator_event_6;
  2988. wm8962->disable_nb[7].notifier_call = wm8962_regulator_event_7;
  2989. /* This should really be moved into the regulator core */
  2990. for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) {
  2991. ret = devm_regulator_register_notifier(
  2992. wm8962->supplies[i].consumer,
  2993. &wm8962->disable_nb[i]);
  2994. if (ret != 0) {
  2995. dev_err(component->dev,
  2996. "Failed to register regulator notifier: %d\n",
  2997. ret);
  2998. }
  2999. }
  3000. wm8962_add_widgets(component);
  3001. /* Save boards having to disable DMIC when not in use */
  3002. dmicclk = false;
  3003. dmicdat = false;
  3004. for (i = 1; i < WM8962_MAX_GPIO; i++) {
  3005. /*
  3006. * Register 515 (WM8962_GPIO_BASE + 3) does not exist,
  3007. * so skip its access
  3008. */
  3009. if (i == 3)
  3010. continue;
  3011. switch (snd_soc_component_read(component, WM8962_GPIO_BASE + i)
  3012. & WM8962_GP2_FN_MASK) {
  3013. case WM8962_GPIO_FN_DMICCLK:
  3014. dmicclk = true;
  3015. break;
  3016. case WM8962_GPIO_FN_DMICDAT:
  3017. dmicdat = true;
  3018. break;
  3019. default:
  3020. break;
  3021. }
  3022. }
  3023. if (!dmicclk || !dmicdat) {
  3024. dev_dbg(component->dev, "DMIC not in use, disabling\n");
  3025. snd_soc_dapm_nc_pin(dapm, "DMICDAT");
  3026. }
  3027. if (dmicclk != dmicdat)
  3028. dev_warn(component->dev, "DMIC GPIOs partially configured\n");
  3029. wm8962_init_beep(component);
  3030. wm8962_init_gpio(component);
  3031. return 0;
  3032. }
  3033. static void wm8962_remove(struct snd_soc_component *component)
  3034. {
  3035. struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
  3036. cancel_delayed_work_sync(&wm8962->mic_work);
  3037. wm8962_free_gpio(component);
  3038. wm8962_free_beep(component);
  3039. }
  3040. static const struct snd_soc_component_driver soc_component_dev_wm8962 = {
  3041. .probe = wm8962_probe,
  3042. .remove = wm8962_remove,
  3043. .set_bias_level = wm8962_set_bias_level,
  3044. .set_pll = wm8962_set_fll,
  3045. .use_pmdown_time = 1,
  3046. .endianness = 1,
  3047. .non_legacy_dai_naming = 1,
  3048. };
  3049. /* Improve power consumption for IN4 DC measurement mode */
  3050. static const struct reg_sequence wm8962_dc_measure[] = {
  3051. { 0xfd, 0x1 },
  3052. { 0xcc, 0x40 },
  3053. { 0xfd, 0 },
  3054. };
  3055. static const struct regmap_config wm8962_regmap = {
  3056. .reg_bits = 16,
  3057. .val_bits = 16,
  3058. .max_register = WM8962_MAX_REGISTER,
  3059. .reg_defaults = wm8962_reg,
  3060. .num_reg_defaults = ARRAY_SIZE(wm8962_reg),
  3061. .volatile_reg = wm8962_volatile_register,
  3062. .readable_reg = wm8962_readable_register,
  3063. .cache_type = REGCACHE_RBTREE,
  3064. };
  3065. static int wm8962_set_pdata_from_of(struct i2c_client *i2c,
  3066. struct wm8962_pdata *pdata)
  3067. {
  3068. const struct device_node *np = i2c->dev.of_node;
  3069. u32 val32;
  3070. int i;
  3071. if (of_property_read_bool(np, "spk-mono"))
  3072. pdata->spk_mono = true;
  3073. if (of_property_read_u32(np, "mic-cfg", &val32) >= 0)
  3074. pdata->mic_cfg = val32;
  3075. if (of_property_read_u32_array(np, "gpio-cfg", pdata->gpio_init,
  3076. ARRAY_SIZE(pdata->gpio_init)) >= 0)
  3077. for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++) {
  3078. /*
  3079. * The range of GPIO register value is [0x0, 0xffff]
  3080. * While the default value of each register is 0x0
  3081. * Any other value will be regarded as default value
  3082. */
  3083. if (pdata->gpio_init[i] > 0xffff)
  3084. pdata->gpio_init[i] = 0x0;
  3085. }
  3086. pdata->mclk = devm_clk_get(&i2c->dev, NULL);
  3087. return 0;
  3088. }
  3089. static int wm8962_i2c_probe(struct i2c_client *i2c,
  3090. const struct i2c_device_id *id)
  3091. {
  3092. struct wm8962_pdata *pdata = dev_get_platdata(&i2c->dev);
  3093. struct wm8962_priv *wm8962;
  3094. unsigned int reg;
  3095. int ret, i, irq_pol, trigger;
  3096. wm8962 = devm_kzalloc(&i2c->dev, sizeof(*wm8962), GFP_KERNEL);
  3097. if (wm8962 == NULL)
  3098. return -ENOMEM;
  3099. mutex_init(&wm8962->dsp2_ena_lock);
  3100. i2c_set_clientdata(i2c, wm8962);
  3101. INIT_DELAYED_WORK(&wm8962->mic_work, wm8962_mic_work);
  3102. init_completion(&wm8962->fll_lock);
  3103. wm8962->irq = i2c->irq;
  3104. /* If platform data was supplied, update the default data in priv */
  3105. if (pdata) {
  3106. memcpy(&wm8962->pdata, pdata, sizeof(struct wm8962_pdata));
  3107. } else if (i2c->dev.of_node) {
  3108. ret = wm8962_set_pdata_from_of(i2c, &wm8962->pdata);
  3109. if (ret != 0)
  3110. return ret;
  3111. }
  3112. /* Mark the mclk pointer to NULL if no mclk assigned */
  3113. if (IS_ERR(wm8962->pdata.mclk)) {
  3114. /* But do not ignore the request for probe defer */
  3115. if (PTR_ERR(wm8962->pdata.mclk) == -EPROBE_DEFER)
  3116. return -EPROBE_DEFER;
  3117. wm8962->pdata.mclk = NULL;
  3118. }
  3119. for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++)
  3120. wm8962->supplies[i].supply = wm8962_supply_names[i];
  3121. ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8962->supplies),
  3122. wm8962->supplies);
  3123. if (ret != 0) {
  3124. dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
  3125. goto err;
  3126. }
  3127. ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies),
  3128. wm8962->supplies);
  3129. if (ret != 0) {
  3130. dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
  3131. return ret;
  3132. }
  3133. wm8962->regmap = devm_regmap_init_i2c(i2c, &wm8962_regmap);
  3134. if (IS_ERR(wm8962->regmap)) {
  3135. ret = PTR_ERR(wm8962->regmap);
  3136. dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
  3137. goto err_enable;
  3138. }
  3139. /*
  3140. * We haven't marked the chip revision as volatile due to
  3141. * sharing a register with the right input volume; explicitly
  3142. * bypass the cache to read it.
  3143. */
  3144. regcache_cache_bypass(wm8962->regmap, true);
  3145. ret = regmap_read(wm8962->regmap, WM8962_SOFTWARE_RESET, &reg);
  3146. if (ret < 0) {
  3147. dev_err(&i2c->dev, "Failed to read ID register\n");
  3148. goto err_enable;
  3149. }
  3150. if (reg != 0x6243) {
  3151. dev_err(&i2c->dev,
  3152. "Device is not a WM8962, ID %x != 0x6243\n", reg);
  3153. ret = -EINVAL;
  3154. goto err_enable;
  3155. }
  3156. ret = regmap_read(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME, &reg);
  3157. if (ret < 0) {
  3158. dev_err(&i2c->dev, "Failed to read device revision: %d\n",
  3159. ret);
  3160. goto err_enable;
  3161. }
  3162. dev_info(&i2c->dev, "customer id %x revision %c\n",
  3163. (reg & WM8962_CUST_ID_MASK) >> WM8962_CUST_ID_SHIFT,
  3164. ((reg & WM8962_CHIP_REV_MASK) >> WM8962_CHIP_REV_SHIFT)
  3165. + 'A');
  3166. regcache_cache_bypass(wm8962->regmap, false);
  3167. ret = wm8962_reset(wm8962);
  3168. if (ret < 0) {
  3169. dev_err(&i2c->dev, "Failed to issue reset\n");
  3170. goto err_enable;
  3171. }
  3172. /* SYSCLK defaults to on; make sure it is off so we can safely
  3173. * write to registers if the device is declocked.
  3174. */
  3175. regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2,
  3176. WM8962_SYSCLK_ENA, 0);
  3177. /* Ensure we have soft control over all registers */
  3178. regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2,
  3179. WM8962_CLKREG_OVD, WM8962_CLKREG_OVD);
  3180. /* Ensure that the oscillator and PLLs are disabled */
  3181. regmap_update_bits(wm8962->regmap, WM8962_PLL2,
  3182. WM8962_OSC_ENA | WM8962_PLL2_ENA | WM8962_PLL3_ENA,
  3183. 0);
  3184. /* Apply static configuration for GPIOs */
  3185. for (i = 0; i < ARRAY_SIZE(wm8962->pdata.gpio_init); i++)
  3186. if (wm8962->pdata.gpio_init[i]) {
  3187. wm8962_set_gpio_mode(wm8962, i + 1);
  3188. regmap_write(wm8962->regmap, 0x200 + i,
  3189. wm8962->pdata.gpio_init[i] & 0xffff);
  3190. }
  3191. /* Put the speakers into mono mode? */
  3192. if (wm8962->pdata.spk_mono)
  3193. regmap_update_bits(wm8962->regmap, WM8962_CLASS_D_CONTROL_2,
  3194. WM8962_SPK_MONO_MASK, WM8962_SPK_MONO);
  3195. /* Micbias setup, detection enable and detection
  3196. * threasholds. */
  3197. if (wm8962->pdata.mic_cfg)
  3198. regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4,
  3199. WM8962_MICDET_ENA |
  3200. WM8962_MICDET_THR_MASK |
  3201. WM8962_MICSHORT_THR_MASK |
  3202. WM8962_MICBIAS_LVL,
  3203. wm8962->pdata.mic_cfg);
  3204. /* Latch volume update bits */
  3205. regmap_update_bits(wm8962->regmap, WM8962_LEFT_INPUT_VOLUME,
  3206. WM8962_IN_VU, WM8962_IN_VU);
  3207. regmap_update_bits(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME,
  3208. WM8962_IN_VU, WM8962_IN_VU);
  3209. regmap_update_bits(wm8962->regmap, WM8962_LEFT_ADC_VOLUME,
  3210. WM8962_ADC_VU, WM8962_ADC_VU);
  3211. regmap_update_bits(wm8962->regmap, WM8962_RIGHT_ADC_VOLUME,
  3212. WM8962_ADC_VU, WM8962_ADC_VU);
  3213. regmap_update_bits(wm8962->regmap, WM8962_LEFT_DAC_VOLUME,
  3214. WM8962_DAC_VU, WM8962_DAC_VU);
  3215. regmap_update_bits(wm8962->regmap, WM8962_RIGHT_DAC_VOLUME,
  3216. WM8962_DAC_VU, WM8962_DAC_VU);
  3217. regmap_update_bits(wm8962->regmap, WM8962_SPKOUTL_VOLUME,
  3218. WM8962_SPKOUT_VU, WM8962_SPKOUT_VU);
  3219. regmap_update_bits(wm8962->regmap, WM8962_SPKOUTR_VOLUME,
  3220. WM8962_SPKOUT_VU, WM8962_SPKOUT_VU);
  3221. regmap_update_bits(wm8962->regmap, WM8962_HPOUTL_VOLUME,
  3222. WM8962_HPOUT_VU, WM8962_HPOUT_VU);
  3223. regmap_update_bits(wm8962->regmap, WM8962_HPOUTR_VOLUME,
  3224. WM8962_HPOUT_VU, WM8962_HPOUT_VU);
  3225. /* Stereo control for EQ */
  3226. regmap_update_bits(wm8962->regmap, WM8962_EQ1,
  3227. WM8962_EQ_SHARED_COEFF, 0);
  3228. /* Don't debouce interrupts so we don't need SYSCLK */
  3229. regmap_update_bits(wm8962->regmap, WM8962_IRQ_DEBOUNCE,
  3230. WM8962_FLL_LOCK_DB | WM8962_PLL3_LOCK_DB |
  3231. WM8962_PLL2_LOCK_DB | WM8962_TEMP_SHUT_DB,
  3232. 0);
  3233. if (wm8962->pdata.in4_dc_measure) {
  3234. ret = regmap_register_patch(wm8962->regmap,
  3235. wm8962_dc_measure,
  3236. ARRAY_SIZE(wm8962_dc_measure));
  3237. if (ret != 0)
  3238. dev_err(&i2c->dev,
  3239. "Failed to configure for DC measurement: %d\n",
  3240. ret);
  3241. }
  3242. if (wm8962->irq) {
  3243. if (wm8962->pdata.irq_active_low) {
  3244. trigger = IRQF_TRIGGER_LOW;
  3245. irq_pol = WM8962_IRQ_POL;
  3246. } else {
  3247. trigger = IRQF_TRIGGER_HIGH;
  3248. irq_pol = 0;
  3249. }
  3250. regmap_update_bits(wm8962->regmap, WM8962_INTERRUPT_CONTROL,
  3251. WM8962_IRQ_POL, irq_pol);
  3252. ret = devm_request_threaded_irq(&i2c->dev, wm8962->irq, NULL,
  3253. wm8962_irq,
  3254. trigger | IRQF_ONESHOT,
  3255. "wm8962", &i2c->dev);
  3256. if (ret != 0) {
  3257. dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n",
  3258. wm8962->irq, ret);
  3259. wm8962->irq = 0;
  3260. /* Non-fatal */
  3261. } else {
  3262. /* Enable some IRQs by default */
  3263. regmap_update_bits(wm8962->regmap,
  3264. WM8962_INTERRUPT_STATUS_2_MASK,
  3265. WM8962_FLL_LOCK_EINT |
  3266. WM8962_TEMP_SHUT_EINT |
  3267. WM8962_FIFOS_ERR_EINT, 0);
  3268. }
  3269. }
  3270. pm_runtime_enable(&i2c->dev);
  3271. pm_request_idle(&i2c->dev);
  3272. ret = devm_snd_soc_register_component(&i2c->dev,
  3273. &soc_component_dev_wm8962, &wm8962_dai, 1);
  3274. if (ret < 0)
  3275. goto err_pm_runtime;
  3276. regcache_cache_only(wm8962->regmap, true);
  3277. /* The drivers should power up as needed */
  3278. regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
  3279. return 0;
  3280. err_pm_runtime:
  3281. pm_runtime_disable(&i2c->dev);
  3282. err_enable:
  3283. regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
  3284. err:
  3285. return ret;
  3286. }
  3287. static int wm8962_i2c_remove(struct i2c_client *client)
  3288. {
  3289. pm_runtime_disable(&client->dev);
  3290. return 0;
  3291. }
  3292. #ifdef CONFIG_PM
  3293. static int wm8962_runtime_resume(struct device *dev)
  3294. {
  3295. struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
  3296. int ret;
  3297. ret = clk_prepare_enable(wm8962->pdata.mclk);
  3298. if (ret) {
  3299. dev_err(dev, "Failed to enable MCLK: %d\n", ret);
  3300. return ret;
  3301. }
  3302. ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies),
  3303. wm8962->supplies);
  3304. if (ret != 0) {
  3305. dev_err(dev, "Failed to enable supplies: %d\n", ret);
  3306. goto disable_clock;
  3307. }
  3308. regcache_cache_only(wm8962->regmap, false);
  3309. wm8962_reset(wm8962);
  3310. regcache_mark_dirty(wm8962->regmap);
  3311. /* SYSCLK defaults to on; make sure it is off so we can safely
  3312. * write to registers if the device is declocked.
  3313. */
  3314. regmap_write_bits(wm8962->regmap, WM8962_CLOCKING2,
  3315. WM8962_SYSCLK_ENA, 0);
  3316. /* Ensure we have soft control over all registers */
  3317. regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2,
  3318. WM8962_CLKREG_OVD, WM8962_CLKREG_OVD);
  3319. /* Ensure that the oscillator and PLLs are disabled */
  3320. regmap_update_bits(wm8962->regmap, WM8962_PLL2,
  3321. WM8962_OSC_ENA | WM8962_PLL2_ENA | WM8962_PLL3_ENA,
  3322. 0);
  3323. regcache_sync(wm8962->regmap);
  3324. regmap_update_bits(wm8962->regmap, WM8962_ANTI_POP,
  3325. WM8962_STARTUP_BIAS_ENA | WM8962_VMID_BUF_ENA,
  3326. WM8962_STARTUP_BIAS_ENA | WM8962_VMID_BUF_ENA);
  3327. /* Bias enable at 2*5k (fast start-up) */
  3328. regmap_update_bits(wm8962->regmap, WM8962_PWR_MGMT_1,
  3329. WM8962_BIAS_ENA | WM8962_VMID_SEL_MASK,
  3330. WM8962_BIAS_ENA | 0x180);
  3331. msleep(5);
  3332. return 0;
  3333. disable_clock:
  3334. clk_disable_unprepare(wm8962->pdata.mclk);
  3335. return ret;
  3336. }
  3337. static int wm8962_runtime_suspend(struct device *dev)
  3338. {
  3339. struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
  3340. regmap_update_bits(wm8962->regmap, WM8962_PWR_MGMT_1,
  3341. WM8962_VMID_SEL_MASK | WM8962_BIAS_ENA, 0);
  3342. regmap_update_bits(wm8962->regmap, WM8962_ANTI_POP,
  3343. WM8962_STARTUP_BIAS_ENA |
  3344. WM8962_VMID_BUF_ENA, 0);
  3345. regcache_cache_only(wm8962->regmap, true);
  3346. regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies),
  3347. wm8962->supplies);
  3348. clk_disable_unprepare(wm8962->pdata.mclk);
  3349. return 0;
  3350. }
  3351. #endif
  3352. static const struct dev_pm_ops wm8962_pm = {
  3353. SET_RUNTIME_PM_OPS(wm8962_runtime_suspend, wm8962_runtime_resume, NULL)
  3354. };
  3355. static const struct i2c_device_id wm8962_i2c_id[] = {
  3356. { "wm8962", 0 },
  3357. { }
  3358. };
  3359. MODULE_DEVICE_TABLE(i2c, wm8962_i2c_id);
  3360. static const struct of_device_id wm8962_of_match[] = {
  3361. { .compatible = "wlf,wm8962", },
  3362. { }
  3363. };
  3364. MODULE_DEVICE_TABLE(of, wm8962_of_match);
  3365. static struct i2c_driver wm8962_i2c_driver = {
  3366. .driver = {
  3367. .name = "wm8962",
  3368. .of_match_table = wm8962_of_match,
  3369. .pm = &wm8962_pm,
  3370. },
  3371. .probe = wm8962_i2c_probe,
  3372. .remove = wm8962_i2c_remove,
  3373. .id_table = wm8962_i2c_id,
  3374. };
  3375. module_i2c_driver(wm8962_i2c_driver);
  3376. MODULE_DESCRIPTION("ASoC WM8962 driver");
  3377. MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
  3378. MODULE_LICENSE("GPL");