wm8962.c 116 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798
  1. /*
  2. * wm8962.c -- WM8962 ALSA SoC Audio driver
  3. *
  4. * Copyright 2010 Wolfson Microelectronics plc
  5. *
  6. * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/moduleparam.h>
  15. #include <linux/init.h>
  16. #include <linux/delay.h>
  17. #include <linux/pm.h>
  18. #include <linux/gcd.h>
  19. #include <linux/gpio.h>
  20. #include <linux/i2c.h>
  21. #include <linux/input.h>
  22. #include <linux/pm_runtime.h>
  23. #include <linux/regmap.h>
  24. #include <linux/regulator/consumer.h>
  25. #include <linux/slab.h>
  26. #include <linux/workqueue.h>
  27. #include <sound/core.h>
  28. #include <sound/jack.h>
  29. #include <sound/pcm.h>
  30. #include <sound/pcm_params.h>
  31. #include <sound/soc.h>
  32. #include <sound/initval.h>
  33. #include <sound/tlv.h>
  34. #include <sound/wm8962.h>
  35. #include <trace/events/asoc.h>
  36. #include "wm8962.h"
  37. #define WM8962_NUM_SUPPLIES 8
  38. static const char *wm8962_supply_names[WM8962_NUM_SUPPLIES] = {
  39. "DCVDD",
  40. "DBVDD",
  41. "AVDD",
  42. "CPVDD",
  43. "MICVDD",
  44. "PLLVDD",
  45. "SPKVDD1",
  46. "SPKVDD2",
  47. };
  48. /* codec private data */
  49. struct wm8962_priv {
  50. struct regmap *regmap;
  51. struct snd_soc_codec *codec;
  52. int sysclk;
  53. int sysclk_rate;
  54. int bclk; /* Desired BCLK */
  55. int lrclk;
  56. struct completion fll_lock;
  57. int fll_src;
  58. int fll_fref;
  59. int fll_fout;
  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. #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
  66. struct input_dev *beep;
  67. struct work_struct beep_work;
  68. int beep_rate;
  69. #endif
  70. #ifdef CONFIG_GPIOLIB
  71. struct gpio_chip gpio_chip;
  72. #endif
  73. int irq;
  74. };
  75. /* We can't use the same notifier block for more than one supply and
  76. * there's no way I can see to get from a callback to the caller
  77. * except container_of().
  78. */
  79. #define WM8962_REGULATOR_EVENT(n) \
  80. static int wm8962_regulator_event_##n(struct notifier_block *nb, \
  81. unsigned long event, void *data) \
  82. { \
  83. struct wm8962_priv *wm8962 = container_of(nb, struct wm8962_priv, \
  84. disable_nb[n]); \
  85. if (event & REGULATOR_EVENT_DISABLE) { \
  86. regcache_mark_dirty(wm8962->regmap); \
  87. } \
  88. return 0; \
  89. }
  90. WM8962_REGULATOR_EVENT(0)
  91. WM8962_REGULATOR_EVENT(1)
  92. WM8962_REGULATOR_EVENT(2)
  93. WM8962_REGULATOR_EVENT(3)
  94. WM8962_REGULATOR_EVENT(4)
  95. WM8962_REGULATOR_EVENT(5)
  96. WM8962_REGULATOR_EVENT(6)
  97. WM8962_REGULATOR_EVENT(7)
  98. static struct reg_default wm8962_reg[] = {
  99. { 0, 0x009F }, /* R0 - Left Input volume */
  100. { 1, 0x049F }, /* R1 - Right Input volume */
  101. { 2, 0x0000 }, /* R2 - HPOUTL volume */
  102. { 3, 0x0000 }, /* R3 - HPOUTR volume */
  103. { 5, 0x0018 }, /* R5 - ADC & DAC Control 1 */
  104. { 6, 0x2008 }, /* R6 - ADC & DAC Control 2 */
  105. { 7, 0x000A }, /* R7 - Audio Interface 0 */
  106. { 9, 0x0300 }, /* R9 - Audio Interface 1 */
  107. { 10, 0x00C0 }, /* R10 - Left DAC volume */
  108. { 11, 0x00C0 }, /* R11 - Right DAC volume */
  109. { 14, 0x0040 }, /* R14 - Audio Interface 2 */
  110. { 15, 0x6243 }, /* R15 - Software Reset */
  111. { 17, 0x007B }, /* R17 - ALC1 */
  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_CLOCKING2:
  721. case WM8962_SOFTWARE_RESET:
  722. case WM8962_ALC2:
  723. case WM8962_THERMAL_SHUTDOWN_STATUS:
  724. case WM8962_ADDITIONAL_CONTROL_4:
  725. case WM8962_DC_SERVO_6:
  726. case WM8962_INTERRUPT_STATUS_1:
  727. case WM8962_INTERRUPT_STATUS_2:
  728. case WM8962_DSP2_EXECCONTROL:
  729. return true;
  730. default:
  731. return false;
  732. }
  733. }
  734. static bool wm8962_readable_register(struct device *dev, unsigned int reg)
  735. {
  736. switch (reg) {
  737. case WM8962_LEFT_INPUT_VOLUME:
  738. case WM8962_RIGHT_INPUT_VOLUME:
  739. case WM8962_HPOUTL_VOLUME:
  740. case WM8962_HPOUTR_VOLUME:
  741. case WM8962_CLOCKING1:
  742. case WM8962_ADC_DAC_CONTROL_1:
  743. case WM8962_ADC_DAC_CONTROL_2:
  744. case WM8962_AUDIO_INTERFACE_0:
  745. case WM8962_CLOCKING2:
  746. case WM8962_AUDIO_INTERFACE_1:
  747. case WM8962_LEFT_DAC_VOLUME:
  748. case WM8962_RIGHT_DAC_VOLUME:
  749. case WM8962_AUDIO_INTERFACE_2:
  750. case WM8962_SOFTWARE_RESET:
  751. case WM8962_ALC1:
  752. case WM8962_ALC2:
  753. case WM8962_ALC3:
  754. case WM8962_NOISE_GATE:
  755. case WM8962_LEFT_ADC_VOLUME:
  756. case WM8962_RIGHT_ADC_VOLUME:
  757. case WM8962_ADDITIONAL_CONTROL_1:
  758. case WM8962_ADDITIONAL_CONTROL_2:
  759. case WM8962_PWR_MGMT_1:
  760. case WM8962_PWR_MGMT_2:
  761. case WM8962_ADDITIONAL_CONTROL_3:
  762. case WM8962_ANTI_POP:
  763. case WM8962_CLOCKING_3:
  764. case WM8962_INPUT_MIXER_CONTROL_1:
  765. case WM8962_LEFT_INPUT_MIXER_VOLUME:
  766. case WM8962_RIGHT_INPUT_MIXER_VOLUME:
  767. case WM8962_INPUT_MIXER_CONTROL_2:
  768. case WM8962_INPUT_BIAS_CONTROL:
  769. case WM8962_LEFT_INPUT_PGA_CONTROL:
  770. case WM8962_RIGHT_INPUT_PGA_CONTROL:
  771. case WM8962_SPKOUTL_VOLUME:
  772. case WM8962_SPKOUTR_VOLUME:
  773. case WM8962_THERMAL_SHUTDOWN_STATUS:
  774. case WM8962_ADDITIONAL_CONTROL_4:
  775. case WM8962_CLASS_D_CONTROL_1:
  776. case WM8962_CLASS_D_CONTROL_2:
  777. case WM8962_CLOCKING_4:
  778. case WM8962_DAC_DSP_MIXING_1:
  779. case WM8962_DAC_DSP_MIXING_2:
  780. case WM8962_DC_SERVO_0:
  781. case WM8962_DC_SERVO_1:
  782. case WM8962_DC_SERVO_4:
  783. case WM8962_DC_SERVO_6:
  784. case WM8962_ANALOGUE_PGA_BIAS:
  785. case WM8962_ANALOGUE_HP_0:
  786. case WM8962_ANALOGUE_HP_2:
  787. case WM8962_CHARGE_PUMP_1:
  788. case WM8962_CHARGE_PUMP_B:
  789. case WM8962_WRITE_SEQUENCER_CONTROL_1:
  790. case WM8962_WRITE_SEQUENCER_CONTROL_2:
  791. case WM8962_WRITE_SEQUENCER_CONTROL_3:
  792. case WM8962_CONTROL_INTERFACE:
  793. case WM8962_MIXER_ENABLES:
  794. case WM8962_HEADPHONE_MIXER_1:
  795. case WM8962_HEADPHONE_MIXER_2:
  796. case WM8962_HEADPHONE_MIXER_3:
  797. case WM8962_HEADPHONE_MIXER_4:
  798. case WM8962_SPEAKER_MIXER_1:
  799. case WM8962_SPEAKER_MIXER_2:
  800. case WM8962_SPEAKER_MIXER_3:
  801. case WM8962_SPEAKER_MIXER_4:
  802. case WM8962_SPEAKER_MIXER_5:
  803. case WM8962_BEEP_GENERATOR_1:
  804. case WM8962_OSCILLATOR_TRIM_3:
  805. case WM8962_OSCILLATOR_TRIM_4:
  806. case WM8962_OSCILLATOR_TRIM_7:
  807. case WM8962_ANALOGUE_CLOCKING1:
  808. case WM8962_ANALOGUE_CLOCKING2:
  809. case WM8962_ANALOGUE_CLOCKING3:
  810. case WM8962_PLL_SOFTWARE_RESET:
  811. case WM8962_PLL2:
  812. case WM8962_PLL_4:
  813. case WM8962_PLL_9:
  814. case WM8962_PLL_10:
  815. case WM8962_PLL_11:
  816. case WM8962_PLL_12:
  817. case WM8962_PLL_13:
  818. case WM8962_PLL_14:
  819. case WM8962_PLL_15:
  820. case WM8962_PLL_16:
  821. case WM8962_FLL_CONTROL_1:
  822. case WM8962_FLL_CONTROL_2:
  823. case WM8962_FLL_CONTROL_3:
  824. case WM8962_FLL_CONTROL_5:
  825. case WM8962_FLL_CONTROL_6:
  826. case WM8962_FLL_CONTROL_7:
  827. case WM8962_FLL_CONTROL_8:
  828. case WM8962_GENERAL_TEST_1:
  829. case WM8962_DF1:
  830. case WM8962_DF2:
  831. case WM8962_DF3:
  832. case WM8962_DF4:
  833. case WM8962_DF5:
  834. case WM8962_DF6:
  835. case WM8962_DF7:
  836. case WM8962_LHPF1:
  837. case WM8962_LHPF2:
  838. case WM8962_THREED1:
  839. case WM8962_THREED2:
  840. case WM8962_THREED3:
  841. case WM8962_THREED4:
  842. case WM8962_DRC_1:
  843. case WM8962_DRC_2:
  844. case WM8962_DRC_3:
  845. case WM8962_DRC_4:
  846. case WM8962_DRC_5:
  847. case WM8962_TLOOPBACK:
  848. case WM8962_EQ1:
  849. case WM8962_EQ2:
  850. case WM8962_EQ3:
  851. case WM8962_EQ4:
  852. case WM8962_EQ5:
  853. case WM8962_EQ6:
  854. case WM8962_EQ7:
  855. case WM8962_EQ8:
  856. case WM8962_EQ9:
  857. case WM8962_EQ10:
  858. case WM8962_EQ11:
  859. case WM8962_EQ12:
  860. case WM8962_EQ13:
  861. case WM8962_EQ14:
  862. case WM8962_EQ15:
  863. case WM8962_EQ16:
  864. case WM8962_EQ17:
  865. case WM8962_EQ18:
  866. case WM8962_EQ19:
  867. case WM8962_EQ20:
  868. case WM8962_EQ21:
  869. case WM8962_EQ22:
  870. case WM8962_EQ23:
  871. case WM8962_EQ24:
  872. case WM8962_EQ25:
  873. case WM8962_EQ26:
  874. case WM8962_EQ27:
  875. case WM8962_EQ28:
  876. case WM8962_EQ29:
  877. case WM8962_EQ30:
  878. case WM8962_EQ31:
  879. case WM8962_EQ32:
  880. case WM8962_EQ33:
  881. case WM8962_EQ34:
  882. case WM8962_EQ35:
  883. case WM8962_EQ36:
  884. case WM8962_EQ37:
  885. case WM8962_EQ38:
  886. case WM8962_EQ39:
  887. case WM8962_EQ40:
  888. case WM8962_EQ41:
  889. case WM8962_GPIO_BASE:
  890. case WM8962_GPIO_2:
  891. case WM8962_GPIO_3:
  892. case WM8962_GPIO_5:
  893. case WM8962_GPIO_6:
  894. case WM8962_INTERRUPT_STATUS_1:
  895. case WM8962_INTERRUPT_STATUS_2:
  896. case WM8962_INTERRUPT_STATUS_1_MASK:
  897. case WM8962_INTERRUPT_STATUS_2_MASK:
  898. case WM8962_INTERRUPT_CONTROL:
  899. case WM8962_IRQ_DEBOUNCE:
  900. case WM8962_MICINT_SOURCE_POL:
  901. case WM8962_DSP2_POWER_MANAGEMENT:
  902. case WM8962_DSP2_EXECCONTROL:
  903. case WM8962_DSP2_INSTRUCTION_RAM_0:
  904. case WM8962_DSP2_ADDRESS_RAM_2:
  905. case WM8962_DSP2_ADDRESS_RAM_1:
  906. case WM8962_DSP2_ADDRESS_RAM_0:
  907. case WM8962_DSP2_DATA1_RAM_1:
  908. case WM8962_DSP2_DATA1_RAM_0:
  909. case WM8962_DSP2_DATA2_RAM_1:
  910. case WM8962_DSP2_DATA2_RAM_0:
  911. case WM8962_DSP2_DATA3_RAM_1:
  912. case WM8962_DSP2_DATA3_RAM_0:
  913. case WM8962_DSP2_COEFF_RAM_0:
  914. case WM8962_RETUNEADC_SHARED_COEFF_1:
  915. case WM8962_RETUNEADC_SHARED_COEFF_0:
  916. case WM8962_RETUNEDAC_SHARED_COEFF_1:
  917. case WM8962_RETUNEDAC_SHARED_COEFF_0:
  918. case WM8962_SOUNDSTAGE_ENABLES_1:
  919. case WM8962_SOUNDSTAGE_ENABLES_0:
  920. case WM8962_HDBASS_AI_1:
  921. case WM8962_HDBASS_AI_0:
  922. case WM8962_HDBASS_AR_1:
  923. case WM8962_HDBASS_AR_0:
  924. case WM8962_HDBASS_B_1:
  925. case WM8962_HDBASS_B_0:
  926. case WM8962_HDBASS_K_1:
  927. case WM8962_HDBASS_K_0:
  928. case WM8962_HDBASS_N1_1:
  929. case WM8962_HDBASS_N1_0:
  930. case WM8962_HDBASS_N2_1:
  931. case WM8962_HDBASS_N2_0:
  932. case WM8962_HDBASS_N3_1:
  933. case WM8962_HDBASS_N3_0:
  934. case WM8962_HDBASS_N4_1:
  935. case WM8962_HDBASS_N4_0:
  936. case WM8962_HDBASS_N5_1:
  937. case WM8962_HDBASS_N5_0:
  938. case WM8962_HDBASS_X1_1:
  939. case WM8962_HDBASS_X1_0:
  940. case WM8962_HDBASS_X2_1:
  941. case WM8962_HDBASS_X2_0:
  942. case WM8962_HDBASS_X3_1:
  943. case WM8962_HDBASS_X3_0:
  944. case WM8962_HDBASS_ATK_1:
  945. case WM8962_HDBASS_ATK_0:
  946. case WM8962_HDBASS_DCY_1:
  947. case WM8962_HDBASS_DCY_0:
  948. case WM8962_HDBASS_PG_1:
  949. case WM8962_HDBASS_PG_0:
  950. case WM8962_HPF_C_1:
  951. case WM8962_HPF_C_0:
  952. case WM8962_ADCL_RETUNE_C1_1:
  953. case WM8962_ADCL_RETUNE_C1_0:
  954. case WM8962_ADCL_RETUNE_C2_1:
  955. case WM8962_ADCL_RETUNE_C2_0:
  956. case WM8962_ADCL_RETUNE_C3_1:
  957. case WM8962_ADCL_RETUNE_C3_0:
  958. case WM8962_ADCL_RETUNE_C4_1:
  959. case WM8962_ADCL_RETUNE_C4_0:
  960. case WM8962_ADCL_RETUNE_C5_1:
  961. case WM8962_ADCL_RETUNE_C5_0:
  962. case WM8962_ADCL_RETUNE_C6_1:
  963. case WM8962_ADCL_RETUNE_C6_0:
  964. case WM8962_ADCL_RETUNE_C7_1:
  965. case WM8962_ADCL_RETUNE_C7_0:
  966. case WM8962_ADCL_RETUNE_C8_1:
  967. case WM8962_ADCL_RETUNE_C8_0:
  968. case WM8962_ADCL_RETUNE_C9_1:
  969. case WM8962_ADCL_RETUNE_C9_0:
  970. case WM8962_ADCL_RETUNE_C10_1:
  971. case WM8962_ADCL_RETUNE_C10_0:
  972. case WM8962_ADCL_RETUNE_C11_1:
  973. case WM8962_ADCL_RETUNE_C11_0:
  974. case WM8962_ADCL_RETUNE_C12_1:
  975. case WM8962_ADCL_RETUNE_C12_0:
  976. case WM8962_ADCL_RETUNE_C13_1:
  977. case WM8962_ADCL_RETUNE_C13_0:
  978. case WM8962_ADCL_RETUNE_C14_1:
  979. case WM8962_ADCL_RETUNE_C14_0:
  980. case WM8962_ADCL_RETUNE_C15_1:
  981. case WM8962_ADCL_RETUNE_C15_0:
  982. case WM8962_ADCL_RETUNE_C16_1:
  983. case WM8962_ADCL_RETUNE_C16_0:
  984. case WM8962_ADCL_RETUNE_C17_1:
  985. case WM8962_ADCL_RETUNE_C17_0:
  986. case WM8962_ADCL_RETUNE_C18_1:
  987. case WM8962_ADCL_RETUNE_C18_0:
  988. case WM8962_ADCL_RETUNE_C19_1:
  989. case WM8962_ADCL_RETUNE_C19_0:
  990. case WM8962_ADCL_RETUNE_C20_1:
  991. case WM8962_ADCL_RETUNE_C20_0:
  992. case WM8962_ADCL_RETUNE_C21_1:
  993. case WM8962_ADCL_RETUNE_C21_0:
  994. case WM8962_ADCL_RETUNE_C22_1:
  995. case WM8962_ADCL_RETUNE_C22_0:
  996. case WM8962_ADCL_RETUNE_C23_1:
  997. case WM8962_ADCL_RETUNE_C23_0:
  998. case WM8962_ADCL_RETUNE_C24_1:
  999. case WM8962_ADCL_RETUNE_C24_0:
  1000. case WM8962_ADCL_RETUNE_C25_1:
  1001. case WM8962_ADCL_RETUNE_C25_0:
  1002. case WM8962_ADCL_RETUNE_C26_1:
  1003. case WM8962_ADCL_RETUNE_C26_0:
  1004. case WM8962_ADCL_RETUNE_C27_1:
  1005. case WM8962_ADCL_RETUNE_C27_0:
  1006. case WM8962_ADCL_RETUNE_C28_1:
  1007. case WM8962_ADCL_RETUNE_C28_0:
  1008. case WM8962_ADCL_RETUNE_C29_1:
  1009. case WM8962_ADCL_RETUNE_C29_0:
  1010. case WM8962_ADCL_RETUNE_C30_1:
  1011. case WM8962_ADCL_RETUNE_C30_0:
  1012. case WM8962_ADCL_RETUNE_C31_1:
  1013. case WM8962_ADCL_RETUNE_C31_0:
  1014. case WM8962_ADCL_RETUNE_C32_1:
  1015. case WM8962_ADCL_RETUNE_C32_0:
  1016. case WM8962_RETUNEADC_PG2_1:
  1017. case WM8962_RETUNEADC_PG2_0:
  1018. case WM8962_RETUNEADC_PG_1:
  1019. case WM8962_RETUNEADC_PG_0:
  1020. case WM8962_ADCR_RETUNE_C1_1:
  1021. case WM8962_ADCR_RETUNE_C1_0:
  1022. case WM8962_ADCR_RETUNE_C2_1:
  1023. case WM8962_ADCR_RETUNE_C2_0:
  1024. case WM8962_ADCR_RETUNE_C3_1:
  1025. case WM8962_ADCR_RETUNE_C3_0:
  1026. case WM8962_ADCR_RETUNE_C4_1:
  1027. case WM8962_ADCR_RETUNE_C4_0:
  1028. case WM8962_ADCR_RETUNE_C5_1:
  1029. case WM8962_ADCR_RETUNE_C5_0:
  1030. case WM8962_ADCR_RETUNE_C6_1:
  1031. case WM8962_ADCR_RETUNE_C6_0:
  1032. case WM8962_ADCR_RETUNE_C7_1:
  1033. case WM8962_ADCR_RETUNE_C7_0:
  1034. case WM8962_ADCR_RETUNE_C8_1:
  1035. case WM8962_ADCR_RETUNE_C8_0:
  1036. case WM8962_ADCR_RETUNE_C9_1:
  1037. case WM8962_ADCR_RETUNE_C9_0:
  1038. case WM8962_ADCR_RETUNE_C10_1:
  1039. case WM8962_ADCR_RETUNE_C10_0:
  1040. case WM8962_ADCR_RETUNE_C11_1:
  1041. case WM8962_ADCR_RETUNE_C11_0:
  1042. case WM8962_ADCR_RETUNE_C12_1:
  1043. case WM8962_ADCR_RETUNE_C12_0:
  1044. case WM8962_ADCR_RETUNE_C13_1:
  1045. case WM8962_ADCR_RETUNE_C13_0:
  1046. case WM8962_ADCR_RETUNE_C14_1:
  1047. case WM8962_ADCR_RETUNE_C14_0:
  1048. case WM8962_ADCR_RETUNE_C15_1:
  1049. case WM8962_ADCR_RETUNE_C15_0:
  1050. case WM8962_ADCR_RETUNE_C16_1:
  1051. case WM8962_ADCR_RETUNE_C16_0:
  1052. case WM8962_ADCR_RETUNE_C17_1:
  1053. case WM8962_ADCR_RETUNE_C17_0:
  1054. case WM8962_ADCR_RETUNE_C18_1:
  1055. case WM8962_ADCR_RETUNE_C18_0:
  1056. case WM8962_ADCR_RETUNE_C19_1:
  1057. case WM8962_ADCR_RETUNE_C19_0:
  1058. case WM8962_ADCR_RETUNE_C20_1:
  1059. case WM8962_ADCR_RETUNE_C20_0:
  1060. case WM8962_ADCR_RETUNE_C21_1:
  1061. case WM8962_ADCR_RETUNE_C21_0:
  1062. case WM8962_ADCR_RETUNE_C22_1:
  1063. case WM8962_ADCR_RETUNE_C22_0:
  1064. case WM8962_ADCR_RETUNE_C23_1:
  1065. case WM8962_ADCR_RETUNE_C23_0:
  1066. case WM8962_ADCR_RETUNE_C24_1:
  1067. case WM8962_ADCR_RETUNE_C24_0:
  1068. case WM8962_ADCR_RETUNE_C25_1:
  1069. case WM8962_ADCR_RETUNE_C25_0:
  1070. case WM8962_ADCR_RETUNE_C26_1:
  1071. case WM8962_ADCR_RETUNE_C26_0:
  1072. case WM8962_ADCR_RETUNE_C27_1:
  1073. case WM8962_ADCR_RETUNE_C27_0:
  1074. case WM8962_ADCR_RETUNE_C28_1:
  1075. case WM8962_ADCR_RETUNE_C28_0:
  1076. case WM8962_ADCR_RETUNE_C29_1:
  1077. case WM8962_ADCR_RETUNE_C29_0:
  1078. case WM8962_ADCR_RETUNE_C30_1:
  1079. case WM8962_ADCR_RETUNE_C30_0:
  1080. case WM8962_ADCR_RETUNE_C31_1:
  1081. case WM8962_ADCR_RETUNE_C31_0:
  1082. case WM8962_ADCR_RETUNE_C32_1:
  1083. case WM8962_ADCR_RETUNE_C32_0:
  1084. case WM8962_DACL_RETUNE_C1_1:
  1085. case WM8962_DACL_RETUNE_C1_0:
  1086. case WM8962_DACL_RETUNE_C2_1:
  1087. case WM8962_DACL_RETUNE_C2_0:
  1088. case WM8962_DACL_RETUNE_C3_1:
  1089. case WM8962_DACL_RETUNE_C3_0:
  1090. case WM8962_DACL_RETUNE_C4_1:
  1091. case WM8962_DACL_RETUNE_C4_0:
  1092. case WM8962_DACL_RETUNE_C5_1:
  1093. case WM8962_DACL_RETUNE_C5_0:
  1094. case WM8962_DACL_RETUNE_C6_1:
  1095. case WM8962_DACL_RETUNE_C6_0:
  1096. case WM8962_DACL_RETUNE_C7_1:
  1097. case WM8962_DACL_RETUNE_C7_0:
  1098. case WM8962_DACL_RETUNE_C8_1:
  1099. case WM8962_DACL_RETUNE_C8_0:
  1100. case WM8962_DACL_RETUNE_C9_1:
  1101. case WM8962_DACL_RETUNE_C9_0:
  1102. case WM8962_DACL_RETUNE_C10_1:
  1103. case WM8962_DACL_RETUNE_C10_0:
  1104. case WM8962_DACL_RETUNE_C11_1:
  1105. case WM8962_DACL_RETUNE_C11_0:
  1106. case WM8962_DACL_RETUNE_C12_1:
  1107. case WM8962_DACL_RETUNE_C12_0:
  1108. case WM8962_DACL_RETUNE_C13_1:
  1109. case WM8962_DACL_RETUNE_C13_0:
  1110. case WM8962_DACL_RETUNE_C14_1:
  1111. case WM8962_DACL_RETUNE_C14_0:
  1112. case WM8962_DACL_RETUNE_C15_1:
  1113. case WM8962_DACL_RETUNE_C15_0:
  1114. case WM8962_DACL_RETUNE_C16_1:
  1115. case WM8962_DACL_RETUNE_C16_0:
  1116. case WM8962_DACL_RETUNE_C17_1:
  1117. case WM8962_DACL_RETUNE_C17_0:
  1118. case WM8962_DACL_RETUNE_C18_1:
  1119. case WM8962_DACL_RETUNE_C18_0:
  1120. case WM8962_DACL_RETUNE_C19_1:
  1121. case WM8962_DACL_RETUNE_C19_0:
  1122. case WM8962_DACL_RETUNE_C20_1:
  1123. case WM8962_DACL_RETUNE_C20_0:
  1124. case WM8962_DACL_RETUNE_C21_1:
  1125. case WM8962_DACL_RETUNE_C21_0:
  1126. case WM8962_DACL_RETUNE_C22_1:
  1127. case WM8962_DACL_RETUNE_C22_0:
  1128. case WM8962_DACL_RETUNE_C23_1:
  1129. case WM8962_DACL_RETUNE_C23_0:
  1130. case WM8962_DACL_RETUNE_C24_1:
  1131. case WM8962_DACL_RETUNE_C24_0:
  1132. case WM8962_DACL_RETUNE_C25_1:
  1133. case WM8962_DACL_RETUNE_C25_0:
  1134. case WM8962_DACL_RETUNE_C26_1:
  1135. case WM8962_DACL_RETUNE_C26_0:
  1136. case WM8962_DACL_RETUNE_C27_1:
  1137. case WM8962_DACL_RETUNE_C27_0:
  1138. case WM8962_DACL_RETUNE_C28_1:
  1139. case WM8962_DACL_RETUNE_C28_0:
  1140. case WM8962_DACL_RETUNE_C29_1:
  1141. case WM8962_DACL_RETUNE_C29_0:
  1142. case WM8962_DACL_RETUNE_C30_1:
  1143. case WM8962_DACL_RETUNE_C30_0:
  1144. case WM8962_DACL_RETUNE_C31_1:
  1145. case WM8962_DACL_RETUNE_C31_0:
  1146. case WM8962_DACL_RETUNE_C32_1:
  1147. case WM8962_DACL_RETUNE_C32_0:
  1148. case WM8962_RETUNEDAC_PG2_1:
  1149. case WM8962_RETUNEDAC_PG2_0:
  1150. case WM8962_RETUNEDAC_PG_1:
  1151. case WM8962_RETUNEDAC_PG_0:
  1152. case WM8962_DACR_RETUNE_C1_1:
  1153. case WM8962_DACR_RETUNE_C1_0:
  1154. case WM8962_DACR_RETUNE_C2_1:
  1155. case WM8962_DACR_RETUNE_C2_0:
  1156. case WM8962_DACR_RETUNE_C3_1:
  1157. case WM8962_DACR_RETUNE_C3_0:
  1158. case WM8962_DACR_RETUNE_C4_1:
  1159. case WM8962_DACR_RETUNE_C4_0:
  1160. case WM8962_DACR_RETUNE_C5_1:
  1161. case WM8962_DACR_RETUNE_C5_0:
  1162. case WM8962_DACR_RETUNE_C6_1:
  1163. case WM8962_DACR_RETUNE_C6_0:
  1164. case WM8962_DACR_RETUNE_C7_1:
  1165. case WM8962_DACR_RETUNE_C7_0:
  1166. case WM8962_DACR_RETUNE_C8_1:
  1167. case WM8962_DACR_RETUNE_C8_0:
  1168. case WM8962_DACR_RETUNE_C9_1:
  1169. case WM8962_DACR_RETUNE_C9_0:
  1170. case WM8962_DACR_RETUNE_C10_1:
  1171. case WM8962_DACR_RETUNE_C10_0:
  1172. case WM8962_DACR_RETUNE_C11_1:
  1173. case WM8962_DACR_RETUNE_C11_0:
  1174. case WM8962_DACR_RETUNE_C12_1:
  1175. case WM8962_DACR_RETUNE_C12_0:
  1176. case WM8962_DACR_RETUNE_C13_1:
  1177. case WM8962_DACR_RETUNE_C13_0:
  1178. case WM8962_DACR_RETUNE_C14_1:
  1179. case WM8962_DACR_RETUNE_C14_0:
  1180. case WM8962_DACR_RETUNE_C15_1:
  1181. case WM8962_DACR_RETUNE_C15_0:
  1182. case WM8962_DACR_RETUNE_C16_1:
  1183. case WM8962_DACR_RETUNE_C16_0:
  1184. case WM8962_DACR_RETUNE_C17_1:
  1185. case WM8962_DACR_RETUNE_C17_0:
  1186. case WM8962_DACR_RETUNE_C18_1:
  1187. case WM8962_DACR_RETUNE_C18_0:
  1188. case WM8962_DACR_RETUNE_C19_1:
  1189. case WM8962_DACR_RETUNE_C19_0:
  1190. case WM8962_DACR_RETUNE_C20_1:
  1191. case WM8962_DACR_RETUNE_C20_0:
  1192. case WM8962_DACR_RETUNE_C21_1:
  1193. case WM8962_DACR_RETUNE_C21_0:
  1194. case WM8962_DACR_RETUNE_C22_1:
  1195. case WM8962_DACR_RETUNE_C22_0:
  1196. case WM8962_DACR_RETUNE_C23_1:
  1197. case WM8962_DACR_RETUNE_C23_0:
  1198. case WM8962_DACR_RETUNE_C24_1:
  1199. case WM8962_DACR_RETUNE_C24_0:
  1200. case WM8962_DACR_RETUNE_C25_1:
  1201. case WM8962_DACR_RETUNE_C25_0:
  1202. case WM8962_DACR_RETUNE_C26_1:
  1203. case WM8962_DACR_RETUNE_C26_0:
  1204. case WM8962_DACR_RETUNE_C27_1:
  1205. case WM8962_DACR_RETUNE_C27_0:
  1206. case WM8962_DACR_RETUNE_C28_1:
  1207. case WM8962_DACR_RETUNE_C28_0:
  1208. case WM8962_DACR_RETUNE_C29_1:
  1209. case WM8962_DACR_RETUNE_C29_0:
  1210. case WM8962_DACR_RETUNE_C30_1:
  1211. case WM8962_DACR_RETUNE_C30_0:
  1212. case WM8962_DACR_RETUNE_C31_1:
  1213. case WM8962_DACR_RETUNE_C31_0:
  1214. case WM8962_DACR_RETUNE_C32_1:
  1215. case WM8962_DACR_RETUNE_C32_0:
  1216. case WM8962_VSS_XHD2_1:
  1217. case WM8962_VSS_XHD2_0:
  1218. case WM8962_VSS_XHD3_1:
  1219. case WM8962_VSS_XHD3_0:
  1220. case WM8962_VSS_XHN1_1:
  1221. case WM8962_VSS_XHN1_0:
  1222. case WM8962_VSS_XHN2_1:
  1223. case WM8962_VSS_XHN2_0:
  1224. case WM8962_VSS_XHN3_1:
  1225. case WM8962_VSS_XHN3_0:
  1226. case WM8962_VSS_XLA_1:
  1227. case WM8962_VSS_XLA_0:
  1228. case WM8962_VSS_XLB_1:
  1229. case WM8962_VSS_XLB_0:
  1230. case WM8962_VSS_XLG_1:
  1231. case WM8962_VSS_XLG_0:
  1232. case WM8962_VSS_PG2_1:
  1233. case WM8962_VSS_PG2_0:
  1234. case WM8962_VSS_PG_1:
  1235. case WM8962_VSS_PG_0:
  1236. case WM8962_VSS_XTD1_1:
  1237. case WM8962_VSS_XTD1_0:
  1238. case WM8962_VSS_XTD2_1:
  1239. case WM8962_VSS_XTD2_0:
  1240. case WM8962_VSS_XTD3_1:
  1241. case WM8962_VSS_XTD3_0:
  1242. case WM8962_VSS_XTD4_1:
  1243. case WM8962_VSS_XTD4_0:
  1244. case WM8962_VSS_XTD5_1:
  1245. case WM8962_VSS_XTD5_0:
  1246. case WM8962_VSS_XTD6_1:
  1247. case WM8962_VSS_XTD6_0:
  1248. case WM8962_VSS_XTD7_1:
  1249. case WM8962_VSS_XTD7_0:
  1250. case WM8962_VSS_XTD8_1:
  1251. case WM8962_VSS_XTD8_0:
  1252. case WM8962_VSS_XTD9_1:
  1253. case WM8962_VSS_XTD9_0:
  1254. case WM8962_VSS_XTD10_1:
  1255. case WM8962_VSS_XTD10_0:
  1256. case WM8962_VSS_XTD11_1:
  1257. case WM8962_VSS_XTD11_0:
  1258. case WM8962_VSS_XTD12_1:
  1259. case WM8962_VSS_XTD12_0:
  1260. case WM8962_VSS_XTD13_1:
  1261. case WM8962_VSS_XTD13_0:
  1262. case WM8962_VSS_XTD14_1:
  1263. case WM8962_VSS_XTD14_0:
  1264. case WM8962_VSS_XTD15_1:
  1265. case WM8962_VSS_XTD15_0:
  1266. case WM8962_VSS_XTD16_1:
  1267. case WM8962_VSS_XTD16_0:
  1268. case WM8962_VSS_XTD17_1:
  1269. case WM8962_VSS_XTD17_0:
  1270. case WM8962_VSS_XTD18_1:
  1271. case WM8962_VSS_XTD18_0:
  1272. case WM8962_VSS_XTD19_1:
  1273. case WM8962_VSS_XTD19_0:
  1274. case WM8962_VSS_XTD20_1:
  1275. case WM8962_VSS_XTD20_0:
  1276. case WM8962_VSS_XTD21_1:
  1277. case WM8962_VSS_XTD21_0:
  1278. case WM8962_VSS_XTD22_1:
  1279. case WM8962_VSS_XTD22_0:
  1280. case WM8962_VSS_XTD23_1:
  1281. case WM8962_VSS_XTD23_0:
  1282. case WM8962_VSS_XTD24_1:
  1283. case WM8962_VSS_XTD24_0:
  1284. case WM8962_VSS_XTD25_1:
  1285. case WM8962_VSS_XTD25_0:
  1286. case WM8962_VSS_XTD26_1:
  1287. case WM8962_VSS_XTD26_0:
  1288. case WM8962_VSS_XTD27_1:
  1289. case WM8962_VSS_XTD27_0:
  1290. case WM8962_VSS_XTD28_1:
  1291. case WM8962_VSS_XTD28_0:
  1292. case WM8962_VSS_XTD29_1:
  1293. case WM8962_VSS_XTD29_0:
  1294. case WM8962_VSS_XTD30_1:
  1295. case WM8962_VSS_XTD30_0:
  1296. case WM8962_VSS_XTD31_1:
  1297. case WM8962_VSS_XTD31_0:
  1298. case WM8962_VSS_XTD32_1:
  1299. case WM8962_VSS_XTD32_0:
  1300. case WM8962_VSS_XTS1_1:
  1301. case WM8962_VSS_XTS1_0:
  1302. case WM8962_VSS_XTS2_1:
  1303. case WM8962_VSS_XTS2_0:
  1304. case WM8962_VSS_XTS3_1:
  1305. case WM8962_VSS_XTS3_0:
  1306. case WM8962_VSS_XTS4_1:
  1307. case WM8962_VSS_XTS4_0:
  1308. case WM8962_VSS_XTS5_1:
  1309. case WM8962_VSS_XTS5_0:
  1310. case WM8962_VSS_XTS6_1:
  1311. case WM8962_VSS_XTS6_0:
  1312. case WM8962_VSS_XTS7_1:
  1313. case WM8962_VSS_XTS7_0:
  1314. case WM8962_VSS_XTS8_1:
  1315. case WM8962_VSS_XTS8_0:
  1316. case WM8962_VSS_XTS9_1:
  1317. case WM8962_VSS_XTS9_0:
  1318. case WM8962_VSS_XTS10_1:
  1319. case WM8962_VSS_XTS10_0:
  1320. case WM8962_VSS_XTS11_1:
  1321. case WM8962_VSS_XTS11_0:
  1322. case WM8962_VSS_XTS12_1:
  1323. case WM8962_VSS_XTS12_0:
  1324. case WM8962_VSS_XTS13_1:
  1325. case WM8962_VSS_XTS13_0:
  1326. case WM8962_VSS_XTS14_1:
  1327. case WM8962_VSS_XTS14_0:
  1328. case WM8962_VSS_XTS15_1:
  1329. case WM8962_VSS_XTS15_0:
  1330. case WM8962_VSS_XTS16_1:
  1331. case WM8962_VSS_XTS16_0:
  1332. case WM8962_VSS_XTS17_1:
  1333. case WM8962_VSS_XTS17_0:
  1334. case WM8962_VSS_XTS18_1:
  1335. case WM8962_VSS_XTS18_0:
  1336. case WM8962_VSS_XTS19_1:
  1337. case WM8962_VSS_XTS19_0:
  1338. case WM8962_VSS_XTS20_1:
  1339. case WM8962_VSS_XTS20_0:
  1340. case WM8962_VSS_XTS21_1:
  1341. case WM8962_VSS_XTS21_0:
  1342. case WM8962_VSS_XTS22_1:
  1343. case WM8962_VSS_XTS22_0:
  1344. case WM8962_VSS_XTS23_1:
  1345. case WM8962_VSS_XTS23_0:
  1346. case WM8962_VSS_XTS24_1:
  1347. case WM8962_VSS_XTS24_0:
  1348. case WM8962_VSS_XTS25_1:
  1349. case WM8962_VSS_XTS25_0:
  1350. case WM8962_VSS_XTS26_1:
  1351. case WM8962_VSS_XTS26_0:
  1352. case WM8962_VSS_XTS27_1:
  1353. case WM8962_VSS_XTS27_0:
  1354. case WM8962_VSS_XTS28_1:
  1355. case WM8962_VSS_XTS28_0:
  1356. case WM8962_VSS_XTS29_1:
  1357. case WM8962_VSS_XTS29_0:
  1358. case WM8962_VSS_XTS30_1:
  1359. case WM8962_VSS_XTS30_0:
  1360. case WM8962_VSS_XTS31_1:
  1361. case WM8962_VSS_XTS31_0:
  1362. case WM8962_VSS_XTS32_1:
  1363. case WM8962_VSS_XTS32_0:
  1364. return true;
  1365. default:
  1366. return false;
  1367. }
  1368. }
  1369. static int wm8962_reset(struct wm8962_priv *wm8962)
  1370. {
  1371. int ret;
  1372. ret = regmap_write(wm8962->regmap, WM8962_SOFTWARE_RESET, 0x6243);
  1373. if (ret != 0)
  1374. return ret;
  1375. return regmap_write(wm8962->regmap, WM8962_PLL_SOFTWARE_RESET, 0);
  1376. }
  1377. static const DECLARE_TLV_DB_SCALE(inpga_tlv, -2325, 75, 0);
  1378. static const DECLARE_TLV_DB_SCALE(mixin_tlv, -1500, 300, 0);
  1379. static const unsigned int mixinpga_tlv[] = {
  1380. TLV_DB_RANGE_HEAD(5),
  1381. 0, 1, TLV_DB_SCALE_ITEM(0, 600, 0),
  1382. 2, 2, TLV_DB_SCALE_ITEM(1300, 1300, 0),
  1383. 3, 4, TLV_DB_SCALE_ITEM(1800, 200, 0),
  1384. 5, 5, TLV_DB_SCALE_ITEM(2400, 0, 0),
  1385. 6, 7, TLV_DB_SCALE_ITEM(2700, 300, 0),
  1386. };
  1387. static const DECLARE_TLV_DB_SCALE(beep_tlv, -9600, 600, 1);
  1388. static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1);
  1389. static const DECLARE_TLV_DB_SCALE(st_tlv, -3600, 300, 0);
  1390. static const DECLARE_TLV_DB_SCALE(inmix_tlv, -600, 600, 0);
  1391. static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0);
  1392. static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
  1393. static const DECLARE_TLV_DB_SCALE(hp_tlv, -700, 100, 0);
  1394. static const unsigned int classd_tlv[] = {
  1395. TLV_DB_RANGE_HEAD(2),
  1396. 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0),
  1397. 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0),
  1398. };
  1399. static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
  1400. static int wm8962_dsp2_write_config(struct snd_soc_codec *codec)
  1401. {
  1402. return 0;
  1403. }
  1404. static int wm8962_dsp2_set_enable(struct snd_soc_codec *codec, u16 val)
  1405. {
  1406. u16 adcl = snd_soc_read(codec, WM8962_LEFT_ADC_VOLUME);
  1407. u16 adcr = snd_soc_read(codec, WM8962_RIGHT_ADC_VOLUME);
  1408. u16 dac = snd_soc_read(codec, WM8962_ADC_DAC_CONTROL_1);
  1409. /* Mute the ADCs and DACs */
  1410. snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, 0);
  1411. snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, WM8962_ADC_VU);
  1412. snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1,
  1413. WM8962_DAC_MUTE, WM8962_DAC_MUTE);
  1414. snd_soc_write(codec, WM8962_SOUNDSTAGE_ENABLES_0, val);
  1415. /* Restore the ADCs and DACs */
  1416. snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, adcl);
  1417. snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, adcr);
  1418. snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1,
  1419. WM8962_DAC_MUTE, dac);
  1420. return 0;
  1421. }
  1422. static int wm8962_dsp2_start(struct snd_soc_codec *codec)
  1423. {
  1424. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  1425. wm8962_dsp2_write_config(codec);
  1426. snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_RUNR);
  1427. wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena);
  1428. return 0;
  1429. }
  1430. static int wm8962_dsp2_stop(struct snd_soc_codec *codec)
  1431. {
  1432. wm8962_dsp2_set_enable(codec, 0);
  1433. snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_STOP);
  1434. return 0;
  1435. }
  1436. #define WM8962_DSP2_ENABLE(xname, xshift) \
  1437. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  1438. .info = wm8962_dsp2_ena_info, \
  1439. .get = wm8962_dsp2_ena_get, .put = wm8962_dsp2_ena_put, \
  1440. .private_value = xshift }
  1441. static int wm8962_dsp2_ena_info(struct snd_kcontrol *kcontrol,
  1442. struct snd_ctl_elem_info *uinfo)
  1443. {
  1444. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  1445. uinfo->count = 1;
  1446. uinfo->value.integer.min = 0;
  1447. uinfo->value.integer.max = 1;
  1448. return 0;
  1449. }
  1450. static int wm8962_dsp2_ena_get(struct snd_kcontrol *kcontrol,
  1451. struct snd_ctl_elem_value *ucontrol)
  1452. {
  1453. int shift = kcontrol->private_value;
  1454. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  1455. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  1456. ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift);
  1457. return 0;
  1458. }
  1459. static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol,
  1460. struct snd_ctl_elem_value *ucontrol)
  1461. {
  1462. int shift = kcontrol->private_value;
  1463. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  1464. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  1465. int old = wm8962->dsp2_ena;
  1466. int ret = 0;
  1467. int dsp2_running = snd_soc_read(codec, WM8962_DSP2_POWER_MANAGEMENT) &
  1468. WM8962_DSP2_ENA;
  1469. mutex_lock(&codec->mutex);
  1470. if (ucontrol->value.integer.value[0])
  1471. wm8962->dsp2_ena |= 1 << shift;
  1472. else
  1473. wm8962->dsp2_ena &= ~(1 << shift);
  1474. if (wm8962->dsp2_ena == old)
  1475. goto out;
  1476. ret = 1;
  1477. if (dsp2_running) {
  1478. if (wm8962->dsp2_ena)
  1479. wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena);
  1480. else
  1481. wm8962_dsp2_stop(codec);
  1482. }
  1483. out:
  1484. mutex_unlock(&codec->mutex);
  1485. return ret;
  1486. }
  1487. /* The VU bits for the headphones are in a different register to the mute
  1488. * bits and only take effect on the PGA if it is actually powered.
  1489. */
  1490. static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol,
  1491. struct snd_ctl_elem_value *ucontrol)
  1492. {
  1493. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  1494. int ret;
  1495. /* Apply the update (if any) */
  1496. ret = snd_soc_put_volsw(kcontrol, ucontrol);
  1497. if (ret == 0)
  1498. return 0;
  1499. /* If the left PGA is enabled hit that VU bit... */
  1500. ret = snd_soc_read(codec, WM8962_PWR_MGMT_2);
  1501. if (ret & WM8962_HPOUTL_PGA_ENA) {
  1502. snd_soc_write(codec, WM8962_HPOUTL_VOLUME,
  1503. snd_soc_read(codec, WM8962_HPOUTL_VOLUME));
  1504. return 1;
  1505. }
  1506. /* ...otherwise the right. The VU is stereo. */
  1507. if (ret & WM8962_HPOUTR_PGA_ENA)
  1508. snd_soc_write(codec, WM8962_HPOUTR_VOLUME,
  1509. snd_soc_read(codec, WM8962_HPOUTR_VOLUME));
  1510. return 1;
  1511. }
  1512. /* The VU bits for the speakers are in a different register to the mute
  1513. * bits and only take effect on the PGA if it is actually powered.
  1514. */
  1515. static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol,
  1516. struct snd_ctl_elem_value *ucontrol)
  1517. {
  1518. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  1519. int ret;
  1520. /* Apply the update (if any) */
  1521. ret = snd_soc_put_volsw(kcontrol, ucontrol);
  1522. if (ret == 0)
  1523. return 0;
  1524. /* If the left PGA is enabled hit that VU bit... */
  1525. ret = snd_soc_read(codec, WM8962_PWR_MGMT_2);
  1526. if (ret & WM8962_SPKOUTL_PGA_ENA) {
  1527. snd_soc_write(codec, WM8962_SPKOUTL_VOLUME,
  1528. snd_soc_read(codec, WM8962_SPKOUTL_VOLUME));
  1529. return 1;
  1530. }
  1531. /* ...otherwise the right. The VU is stereo. */
  1532. if (ret & WM8962_SPKOUTR_PGA_ENA)
  1533. snd_soc_write(codec, WM8962_SPKOUTR_VOLUME,
  1534. snd_soc_read(codec, WM8962_SPKOUTR_VOLUME));
  1535. return 1;
  1536. }
  1537. static const char *cap_hpf_mode_text[] = {
  1538. "Hi-fi", "Application"
  1539. };
  1540. static const struct soc_enum cap_hpf_mode =
  1541. SOC_ENUM_SINGLE(WM8962_ADC_DAC_CONTROL_2, 10, 2, cap_hpf_mode_text);
  1542. static const char *cap_lhpf_mode_text[] = {
  1543. "LPF", "HPF"
  1544. };
  1545. static const struct soc_enum cap_lhpf_mode =
  1546. SOC_ENUM_SINGLE(WM8962_LHPF1, 1, 2, cap_lhpf_mode_text);
  1547. static const struct snd_kcontrol_new wm8962_snd_controls[] = {
  1548. SOC_DOUBLE("Input Mixer Switch", WM8962_INPUT_MIXER_CONTROL_1, 3, 2, 1, 1),
  1549. SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8962_LEFT_INPUT_MIXER_VOLUME, 6, 7, 0,
  1550. mixin_tlv),
  1551. SOC_SINGLE_TLV("MIXINL PGA Volume", WM8962_LEFT_INPUT_MIXER_VOLUME, 3, 7, 0,
  1552. mixinpga_tlv),
  1553. SOC_SINGLE_TLV("MIXINL IN3L Volume", WM8962_LEFT_INPUT_MIXER_VOLUME, 0, 7, 0,
  1554. mixin_tlv),
  1555. SOC_SINGLE_TLV("MIXINR IN2R Volume", WM8962_RIGHT_INPUT_MIXER_VOLUME, 6, 7, 0,
  1556. mixin_tlv),
  1557. SOC_SINGLE_TLV("MIXINR PGA Volume", WM8962_RIGHT_INPUT_MIXER_VOLUME, 3, 7, 0,
  1558. mixinpga_tlv),
  1559. SOC_SINGLE_TLV("MIXINR IN3R Volume", WM8962_RIGHT_INPUT_MIXER_VOLUME, 0, 7, 0,
  1560. mixin_tlv),
  1561. SOC_DOUBLE_R_TLV("Digital Capture Volume", WM8962_LEFT_ADC_VOLUME,
  1562. WM8962_RIGHT_ADC_VOLUME, 1, 127, 0, digital_tlv),
  1563. SOC_DOUBLE_R_TLV("Capture Volume", WM8962_LEFT_INPUT_VOLUME,
  1564. WM8962_RIGHT_INPUT_VOLUME, 0, 63, 0, inpga_tlv),
  1565. SOC_DOUBLE_R("Capture Switch", WM8962_LEFT_INPUT_VOLUME,
  1566. WM8962_RIGHT_INPUT_VOLUME, 7, 1, 1),
  1567. SOC_DOUBLE_R("Capture ZC Switch", WM8962_LEFT_INPUT_VOLUME,
  1568. WM8962_RIGHT_INPUT_VOLUME, 6, 1, 1),
  1569. SOC_SINGLE("Capture HPF Switch", WM8962_ADC_DAC_CONTROL_1, 0, 1, 1),
  1570. SOC_ENUM("Capture HPF Mode", cap_hpf_mode),
  1571. SOC_SINGLE("Capture HPF Cutoff", WM8962_ADC_DAC_CONTROL_2, 7, 7, 0),
  1572. SOC_SINGLE("Capture LHPF Switch", WM8962_LHPF1, 0, 1, 0),
  1573. SOC_ENUM("Capture LHPF Mode", cap_lhpf_mode),
  1574. SOC_DOUBLE_R_TLV("Sidetone Volume", WM8962_DAC_DSP_MIXING_1,
  1575. WM8962_DAC_DSP_MIXING_2, 4, 12, 0, st_tlv),
  1576. SOC_DOUBLE_R_TLV("Digital Playback Volume", WM8962_LEFT_DAC_VOLUME,
  1577. WM8962_RIGHT_DAC_VOLUME, 1, 127, 0, digital_tlv),
  1578. SOC_SINGLE("DAC High Performance Switch", WM8962_ADC_DAC_CONTROL_2, 0, 1, 0),
  1579. SOC_SINGLE("DAC L/R Swap Switch", WM8962_AUDIO_INTERFACE_0, 5, 1, 0),
  1580. SOC_SINGLE("ADC L/R Swap Switch", WM8962_AUDIO_INTERFACE_0, 8, 1, 0),
  1581. SOC_SINGLE("ADC High Performance Switch", WM8962_ADDITIONAL_CONTROL_1,
  1582. 5, 1, 0),
  1583. SOC_SINGLE_TLV("Beep Volume", WM8962_BEEP_GENERATOR_1, 4, 15, 0, beep_tlv),
  1584. SOC_DOUBLE_R_TLV("Headphone Volume", WM8962_HPOUTL_VOLUME,
  1585. WM8962_HPOUTR_VOLUME, 0, 127, 0, out_tlv),
  1586. SOC_DOUBLE_EXT("Headphone Switch", WM8962_PWR_MGMT_2, 1, 0, 1, 1,
  1587. snd_soc_get_volsw, wm8962_put_hp_sw),
  1588. SOC_DOUBLE_R("Headphone ZC Switch", WM8962_HPOUTL_VOLUME, WM8962_HPOUTR_VOLUME,
  1589. 7, 1, 0),
  1590. SOC_DOUBLE_TLV("Headphone Aux Volume", WM8962_ANALOGUE_HP_2, 3, 6, 7, 0,
  1591. hp_tlv),
  1592. SOC_DOUBLE_R("Headphone Mixer Switch", WM8962_HEADPHONE_MIXER_3,
  1593. WM8962_HEADPHONE_MIXER_4, 8, 1, 1),
  1594. SOC_SINGLE_TLV("HPMIXL IN4L Volume", WM8962_HEADPHONE_MIXER_3,
  1595. 3, 7, 0, bypass_tlv),
  1596. SOC_SINGLE_TLV("HPMIXL IN4R Volume", WM8962_HEADPHONE_MIXER_3,
  1597. 0, 7, 0, bypass_tlv),
  1598. SOC_SINGLE_TLV("HPMIXL MIXINL Volume", WM8962_HEADPHONE_MIXER_3,
  1599. 7, 1, 1, inmix_tlv),
  1600. SOC_SINGLE_TLV("HPMIXL MIXINR Volume", WM8962_HEADPHONE_MIXER_3,
  1601. 6, 1, 1, inmix_tlv),
  1602. SOC_SINGLE_TLV("HPMIXR IN4L Volume", WM8962_HEADPHONE_MIXER_4,
  1603. 3, 7, 0, bypass_tlv),
  1604. SOC_SINGLE_TLV("HPMIXR IN4R Volume", WM8962_HEADPHONE_MIXER_4,
  1605. 0, 7, 0, bypass_tlv),
  1606. SOC_SINGLE_TLV("HPMIXR MIXINL Volume", WM8962_HEADPHONE_MIXER_4,
  1607. 7, 1, 1, inmix_tlv),
  1608. SOC_SINGLE_TLV("HPMIXR MIXINR Volume", WM8962_HEADPHONE_MIXER_4,
  1609. 6, 1, 1, inmix_tlv),
  1610. SOC_SINGLE_TLV("Speaker Boost Volume", WM8962_CLASS_D_CONTROL_2, 0, 7, 0,
  1611. classd_tlv),
  1612. SOC_SINGLE("EQ Switch", WM8962_EQ1, WM8962_EQ_ENA_SHIFT, 1, 0),
  1613. SOC_DOUBLE_R_TLV("EQ1 Volume", WM8962_EQ2, WM8962_EQ22,
  1614. WM8962_EQL_B1_GAIN_SHIFT, 31, 0, eq_tlv),
  1615. SOC_DOUBLE_R_TLV("EQ2 Volume", WM8962_EQ2, WM8962_EQ22,
  1616. WM8962_EQL_B2_GAIN_SHIFT, 31, 0, eq_tlv),
  1617. SOC_DOUBLE_R_TLV("EQ3 Volume", WM8962_EQ2, WM8962_EQ22,
  1618. WM8962_EQL_B3_GAIN_SHIFT, 31, 0, eq_tlv),
  1619. SOC_DOUBLE_R_TLV("EQ4 Volume", WM8962_EQ3, WM8962_EQ23,
  1620. WM8962_EQL_B4_GAIN_SHIFT, 31, 0, eq_tlv),
  1621. SOC_DOUBLE_R_TLV("EQ5 Volume", WM8962_EQ3, WM8962_EQ23,
  1622. WM8962_EQL_B5_GAIN_SHIFT, 31, 0, eq_tlv),
  1623. WM8962_DSP2_ENABLE("VSS Switch", WM8962_VSS_ENA_SHIFT),
  1624. WM8962_DSP2_ENABLE("HPF1 Switch", WM8962_HPF1_ENA_SHIFT),
  1625. WM8962_DSP2_ENABLE("HPF2 Switch", WM8962_HPF2_ENA_SHIFT),
  1626. WM8962_DSP2_ENABLE("HD Bass Switch", WM8962_HDBASS_ENA_SHIFT),
  1627. };
  1628. static const struct snd_kcontrol_new wm8962_spk_mono_controls[] = {
  1629. SOC_SINGLE_TLV("Speaker Volume", WM8962_SPKOUTL_VOLUME, 0, 127, 0, out_tlv),
  1630. SOC_SINGLE_EXT("Speaker Switch", WM8962_CLASS_D_CONTROL_1, 1, 1, 1,
  1631. snd_soc_get_volsw, wm8962_put_spk_sw),
  1632. SOC_SINGLE("Speaker ZC Switch", WM8962_SPKOUTL_VOLUME, 7, 1, 0),
  1633. SOC_SINGLE("Speaker Mixer Switch", WM8962_SPEAKER_MIXER_3, 8, 1, 1),
  1634. SOC_SINGLE_TLV("Speaker Mixer IN4L Volume", WM8962_SPEAKER_MIXER_3,
  1635. 3, 7, 0, bypass_tlv),
  1636. SOC_SINGLE_TLV("Speaker Mixer IN4R Volume", WM8962_SPEAKER_MIXER_3,
  1637. 0, 7, 0, bypass_tlv),
  1638. SOC_SINGLE_TLV("Speaker Mixer MIXINL Volume", WM8962_SPEAKER_MIXER_3,
  1639. 7, 1, 1, inmix_tlv),
  1640. SOC_SINGLE_TLV("Speaker Mixer MIXINR Volume", WM8962_SPEAKER_MIXER_3,
  1641. 6, 1, 1, inmix_tlv),
  1642. SOC_SINGLE_TLV("Speaker Mixer DACL Volume", WM8962_SPEAKER_MIXER_5,
  1643. 7, 1, 0, inmix_tlv),
  1644. SOC_SINGLE_TLV("Speaker Mixer DACR Volume", WM8962_SPEAKER_MIXER_5,
  1645. 6, 1, 0, inmix_tlv),
  1646. };
  1647. static const struct snd_kcontrol_new wm8962_spk_stereo_controls[] = {
  1648. SOC_DOUBLE_R_TLV("Speaker Volume", WM8962_SPKOUTL_VOLUME,
  1649. WM8962_SPKOUTR_VOLUME, 0, 127, 0, out_tlv),
  1650. SOC_DOUBLE_EXT("Speaker Switch", WM8962_CLASS_D_CONTROL_1, 1, 0, 1, 1,
  1651. snd_soc_get_volsw, wm8962_put_spk_sw),
  1652. SOC_DOUBLE_R("Speaker ZC Switch", WM8962_SPKOUTL_VOLUME, WM8962_SPKOUTR_VOLUME,
  1653. 7, 1, 0),
  1654. SOC_DOUBLE_R("Speaker Mixer Switch", WM8962_SPEAKER_MIXER_3,
  1655. WM8962_SPEAKER_MIXER_4, 8, 1, 1),
  1656. SOC_SINGLE_TLV("SPKOUTL Mixer IN4L Volume", WM8962_SPEAKER_MIXER_3,
  1657. 3, 7, 0, bypass_tlv),
  1658. SOC_SINGLE_TLV("SPKOUTL Mixer IN4R Volume", WM8962_SPEAKER_MIXER_3,
  1659. 0, 7, 0, bypass_tlv),
  1660. SOC_SINGLE_TLV("SPKOUTL Mixer MIXINL Volume", WM8962_SPEAKER_MIXER_3,
  1661. 7, 1, 1, inmix_tlv),
  1662. SOC_SINGLE_TLV("SPKOUTL Mixer MIXINR Volume", WM8962_SPEAKER_MIXER_3,
  1663. 6, 1, 1, inmix_tlv),
  1664. SOC_SINGLE_TLV("SPKOUTL Mixer DACL Volume", WM8962_SPEAKER_MIXER_5,
  1665. 7, 1, 0, inmix_tlv),
  1666. SOC_SINGLE_TLV("SPKOUTL Mixer DACR Volume", WM8962_SPEAKER_MIXER_5,
  1667. 6, 1, 0, inmix_tlv),
  1668. SOC_SINGLE_TLV("SPKOUTR Mixer IN4L Volume", WM8962_SPEAKER_MIXER_4,
  1669. 3, 7, 0, bypass_tlv),
  1670. SOC_SINGLE_TLV("SPKOUTR Mixer IN4R Volume", WM8962_SPEAKER_MIXER_4,
  1671. 0, 7, 0, bypass_tlv),
  1672. SOC_SINGLE_TLV("SPKOUTR Mixer MIXINL Volume", WM8962_SPEAKER_MIXER_4,
  1673. 7, 1, 1, inmix_tlv),
  1674. SOC_SINGLE_TLV("SPKOUTR Mixer MIXINR Volume", WM8962_SPEAKER_MIXER_4,
  1675. 6, 1, 1, inmix_tlv),
  1676. SOC_SINGLE_TLV("SPKOUTR Mixer DACL Volume", WM8962_SPEAKER_MIXER_5,
  1677. 5, 1, 0, inmix_tlv),
  1678. SOC_SINGLE_TLV("SPKOUTR Mixer DACR Volume", WM8962_SPEAKER_MIXER_5,
  1679. 4, 1, 0, inmix_tlv),
  1680. };
  1681. static int cp_event(struct snd_soc_dapm_widget *w,
  1682. struct snd_kcontrol *kcontrol, int event)
  1683. {
  1684. switch (event) {
  1685. case SND_SOC_DAPM_POST_PMU:
  1686. msleep(5);
  1687. break;
  1688. default:
  1689. BUG();
  1690. return -EINVAL;
  1691. }
  1692. return 0;
  1693. }
  1694. static int hp_event(struct snd_soc_dapm_widget *w,
  1695. struct snd_kcontrol *kcontrol, int event)
  1696. {
  1697. struct snd_soc_codec *codec = w->codec;
  1698. int timeout;
  1699. int reg;
  1700. int expected = (WM8962_DCS_STARTUP_DONE_HP1L |
  1701. WM8962_DCS_STARTUP_DONE_HP1R);
  1702. switch (event) {
  1703. case SND_SOC_DAPM_POST_PMU:
  1704. snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0,
  1705. WM8962_HP1L_ENA | WM8962_HP1R_ENA,
  1706. WM8962_HP1L_ENA | WM8962_HP1R_ENA);
  1707. udelay(20);
  1708. snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0,
  1709. WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY,
  1710. WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY);
  1711. /* Start the DC servo */
  1712. snd_soc_update_bits(codec, WM8962_DC_SERVO_1,
  1713. WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA |
  1714. WM8962_HP1L_DCS_STARTUP |
  1715. WM8962_HP1R_DCS_STARTUP,
  1716. WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA |
  1717. WM8962_HP1L_DCS_STARTUP |
  1718. WM8962_HP1R_DCS_STARTUP);
  1719. /* Wait for it to complete, should be well under 100ms */
  1720. timeout = 0;
  1721. do {
  1722. msleep(1);
  1723. reg = snd_soc_read(codec, WM8962_DC_SERVO_6);
  1724. if (reg < 0) {
  1725. dev_err(codec->dev,
  1726. "Failed to read DCS status: %d\n",
  1727. reg);
  1728. continue;
  1729. }
  1730. dev_dbg(codec->dev, "DCS status: %x\n", reg);
  1731. } while (++timeout < 200 && (reg & expected) != expected);
  1732. if ((reg & expected) != expected)
  1733. dev_err(codec->dev, "DC servo timed out\n");
  1734. else
  1735. dev_dbg(codec->dev, "DC servo complete after %dms\n",
  1736. timeout);
  1737. snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0,
  1738. WM8962_HP1L_ENA_OUTP |
  1739. WM8962_HP1R_ENA_OUTP,
  1740. WM8962_HP1L_ENA_OUTP |
  1741. WM8962_HP1R_ENA_OUTP);
  1742. udelay(20);
  1743. snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0,
  1744. WM8962_HP1L_RMV_SHORT |
  1745. WM8962_HP1R_RMV_SHORT,
  1746. WM8962_HP1L_RMV_SHORT |
  1747. WM8962_HP1R_RMV_SHORT);
  1748. break;
  1749. case SND_SOC_DAPM_PRE_PMD:
  1750. snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0,
  1751. WM8962_HP1L_RMV_SHORT |
  1752. WM8962_HP1R_RMV_SHORT, 0);
  1753. udelay(20);
  1754. snd_soc_update_bits(codec, WM8962_DC_SERVO_1,
  1755. WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA |
  1756. WM8962_HP1L_DCS_STARTUP |
  1757. WM8962_HP1R_DCS_STARTUP,
  1758. 0);
  1759. snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0,
  1760. WM8962_HP1L_ENA | WM8962_HP1R_ENA |
  1761. WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY |
  1762. WM8962_HP1L_ENA_OUTP |
  1763. WM8962_HP1R_ENA_OUTP, 0);
  1764. break;
  1765. default:
  1766. BUG();
  1767. return -EINVAL;
  1768. }
  1769. return 0;
  1770. }
  1771. /* VU bits for the output PGAs only take effect while the PGA is powered */
  1772. static int out_pga_event(struct snd_soc_dapm_widget *w,
  1773. struct snd_kcontrol *kcontrol, int event)
  1774. {
  1775. struct snd_soc_codec *codec = w->codec;
  1776. int reg;
  1777. switch (w->shift) {
  1778. case WM8962_HPOUTR_PGA_ENA_SHIFT:
  1779. reg = WM8962_HPOUTR_VOLUME;
  1780. break;
  1781. case WM8962_HPOUTL_PGA_ENA_SHIFT:
  1782. reg = WM8962_HPOUTL_VOLUME;
  1783. break;
  1784. case WM8962_SPKOUTR_PGA_ENA_SHIFT:
  1785. reg = WM8962_SPKOUTR_VOLUME;
  1786. break;
  1787. case WM8962_SPKOUTL_PGA_ENA_SHIFT:
  1788. reg = WM8962_SPKOUTL_VOLUME;
  1789. break;
  1790. default:
  1791. BUG();
  1792. return -EINVAL;
  1793. }
  1794. switch (event) {
  1795. case SND_SOC_DAPM_POST_PMU:
  1796. return snd_soc_write(codec, reg, snd_soc_read(codec, reg));
  1797. default:
  1798. BUG();
  1799. return -EINVAL;
  1800. }
  1801. }
  1802. static int dsp2_event(struct snd_soc_dapm_widget *w,
  1803. struct snd_kcontrol *kcontrol, int event)
  1804. {
  1805. struct snd_soc_codec *codec = w->codec;
  1806. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  1807. switch (event) {
  1808. case SND_SOC_DAPM_POST_PMU:
  1809. if (wm8962->dsp2_ena)
  1810. wm8962_dsp2_start(codec);
  1811. break;
  1812. case SND_SOC_DAPM_PRE_PMD:
  1813. if (wm8962->dsp2_ena)
  1814. wm8962_dsp2_stop(codec);
  1815. break;
  1816. default:
  1817. BUG();
  1818. return -EINVAL;
  1819. }
  1820. return 0;
  1821. }
  1822. static const char *st_text[] = { "None", "Left", "Right" };
  1823. static const struct soc_enum str_enum =
  1824. SOC_ENUM_SINGLE(WM8962_DAC_DSP_MIXING_1, 2, 3, st_text);
  1825. static const struct snd_kcontrol_new str_mux =
  1826. SOC_DAPM_ENUM("Right Sidetone", str_enum);
  1827. static const struct soc_enum stl_enum =
  1828. SOC_ENUM_SINGLE(WM8962_DAC_DSP_MIXING_2, 2, 3, st_text);
  1829. static const struct snd_kcontrol_new stl_mux =
  1830. SOC_DAPM_ENUM("Left Sidetone", stl_enum);
  1831. static const char *outmux_text[] = { "DAC", "Mixer" };
  1832. static const struct soc_enum spkoutr_enum =
  1833. SOC_ENUM_SINGLE(WM8962_SPEAKER_MIXER_2, 7, 2, outmux_text);
  1834. static const struct snd_kcontrol_new spkoutr_mux =
  1835. SOC_DAPM_ENUM("SPKOUTR Mux", spkoutr_enum);
  1836. static const struct soc_enum spkoutl_enum =
  1837. SOC_ENUM_SINGLE(WM8962_SPEAKER_MIXER_1, 7, 2, outmux_text);
  1838. static const struct snd_kcontrol_new spkoutl_mux =
  1839. SOC_DAPM_ENUM("SPKOUTL Mux", spkoutl_enum);
  1840. static const struct soc_enum hpoutr_enum =
  1841. SOC_ENUM_SINGLE(WM8962_HEADPHONE_MIXER_2, 7, 2, outmux_text);
  1842. static const struct snd_kcontrol_new hpoutr_mux =
  1843. SOC_DAPM_ENUM("HPOUTR Mux", hpoutr_enum);
  1844. static const struct soc_enum hpoutl_enum =
  1845. SOC_ENUM_SINGLE(WM8962_HEADPHONE_MIXER_1, 7, 2, outmux_text);
  1846. static const struct snd_kcontrol_new hpoutl_mux =
  1847. SOC_DAPM_ENUM("HPOUTL Mux", hpoutl_enum);
  1848. static const struct snd_kcontrol_new inpgal[] = {
  1849. SOC_DAPM_SINGLE("IN1L Switch", WM8962_LEFT_INPUT_PGA_CONTROL, 3, 1, 0),
  1850. SOC_DAPM_SINGLE("IN2L Switch", WM8962_LEFT_INPUT_PGA_CONTROL, 2, 1, 0),
  1851. SOC_DAPM_SINGLE("IN3L Switch", WM8962_LEFT_INPUT_PGA_CONTROL, 1, 1, 0),
  1852. SOC_DAPM_SINGLE("IN4L Switch", WM8962_LEFT_INPUT_PGA_CONTROL, 0, 1, 0),
  1853. };
  1854. static const struct snd_kcontrol_new inpgar[] = {
  1855. SOC_DAPM_SINGLE("IN1R Switch", WM8962_RIGHT_INPUT_PGA_CONTROL, 3, 1, 0),
  1856. SOC_DAPM_SINGLE("IN2R Switch", WM8962_RIGHT_INPUT_PGA_CONTROL, 2, 1, 0),
  1857. SOC_DAPM_SINGLE("IN3R Switch", WM8962_RIGHT_INPUT_PGA_CONTROL, 1, 1, 0),
  1858. SOC_DAPM_SINGLE("IN4R Switch", WM8962_RIGHT_INPUT_PGA_CONTROL, 0, 1, 0),
  1859. };
  1860. static const struct snd_kcontrol_new mixinl[] = {
  1861. SOC_DAPM_SINGLE("IN2L Switch", WM8962_INPUT_MIXER_CONTROL_2, 5, 1, 0),
  1862. SOC_DAPM_SINGLE("IN3L Switch", WM8962_INPUT_MIXER_CONTROL_2, 4, 1, 0),
  1863. SOC_DAPM_SINGLE("PGA Switch", WM8962_INPUT_MIXER_CONTROL_2, 3, 1, 0),
  1864. };
  1865. static const struct snd_kcontrol_new mixinr[] = {
  1866. SOC_DAPM_SINGLE("IN2R Switch", WM8962_INPUT_MIXER_CONTROL_2, 2, 1, 0),
  1867. SOC_DAPM_SINGLE("IN3R Switch", WM8962_INPUT_MIXER_CONTROL_2, 1, 1, 0),
  1868. SOC_DAPM_SINGLE("PGA Switch", WM8962_INPUT_MIXER_CONTROL_2, 0, 1, 0),
  1869. };
  1870. static const struct snd_kcontrol_new hpmixl[] = {
  1871. SOC_DAPM_SINGLE("DACL Switch", WM8962_HEADPHONE_MIXER_1, 5, 1, 0),
  1872. SOC_DAPM_SINGLE("DACR Switch", WM8962_HEADPHONE_MIXER_1, 4, 1, 0),
  1873. SOC_DAPM_SINGLE("MIXINL Switch", WM8962_HEADPHONE_MIXER_1, 3, 1, 0),
  1874. SOC_DAPM_SINGLE("MIXINR Switch", WM8962_HEADPHONE_MIXER_1, 2, 1, 0),
  1875. SOC_DAPM_SINGLE("IN4L Switch", WM8962_HEADPHONE_MIXER_1, 1, 1, 0),
  1876. SOC_DAPM_SINGLE("IN4R Switch", WM8962_HEADPHONE_MIXER_1, 0, 1, 0),
  1877. };
  1878. static const struct snd_kcontrol_new hpmixr[] = {
  1879. SOC_DAPM_SINGLE("DACL Switch", WM8962_HEADPHONE_MIXER_2, 5, 1, 0),
  1880. SOC_DAPM_SINGLE("DACR Switch", WM8962_HEADPHONE_MIXER_2, 4, 1, 0),
  1881. SOC_DAPM_SINGLE("MIXINL Switch", WM8962_HEADPHONE_MIXER_2, 3, 1, 0),
  1882. SOC_DAPM_SINGLE("MIXINR Switch", WM8962_HEADPHONE_MIXER_2, 2, 1, 0),
  1883. SOC_DAPM_SINGLE("IN4L Switch", WM8962_HEADPHONE_MIXER_2, 1, 1, 0),
  1884. SOC_DAPM_SINGLE("IN4R Switch", WM8962_HEADPHONE_MIXER_2, 0, 1, 0),
  1885. };
  1886. static const struct snd_kcontrol_new spkmixl[] = {
  1887. SOC_DAPM_SINGLE("DACL Switch", WM8962_SPEAKER_MIXER_1, 5, 1, 0),
  1888. SOC_DAPM_SINGLE("DACR Switch", WM8962_SPEAKER_MIXER_1, 4, 1, 0),
  1889. SOC_DAPM_SINGLE("MIXINL Switch", WM8962_SPEAKER_MIXER_1, 3, 1, 0),
  1890. SOC_DAPM_SINGLE("MIXINR Switch", WM8962_SPEAKER_MIXER_1, 2, 1, 0),
  1891. SOC_DAPM_SINGLE("IN4L Switch", WM8962_SPEAKER_MIXER_1, 1, 1, 0),
  1892. SOC_DAPM_SINGLE("IN4R Switch", WM8962_SPEAKER_MIXER_1, 0, 1, 0),
  1893. };
  1894. static const struct snd_kcontrol_new spkmixr[] = {
  1895. SOC_DAPM_SINGLE("DACL Switch", WM8962_SPEAKER_MIXER_2, 5, 1, 0),
  1896. SOC_DAPM_SINGLE("DACR Switch", WM8962_SPEAKER_MIXER_2, 4, 1, 0),
  1897. SOC_DAPM_SINGLE("MIXINL Switch", WM8962_SPEAKER_MIXER_2, 3, 1, 0),
  1898. SOC_DAPM_SINGLE("MIXINR Switch", WM8962_SPEAKER_MIXER_2, 2, 1, 0),
  1899. SOC_DAPM_SINGLE("IN4L Switch", WM8962_SPEAKER_MIXER_2, 1, 1, 0),
  1900. SOC_DAPM_SINGLE("IN4R Switch", WM8962_SPEAKER_MIXER_2, 0, 1, 0),
  1901. };
  1902. static const struct snd_soc_dapm_widget wm8962_dapm_widgets[] = {
  1903. SND_SOC_DAPM_INPUT("IN1L"),
  1904. SND_SOC_DAPM_INPUT("IN1R"),
  1905. SND_SOC_DAPM_INPUT("IN2L"),
  1906. SND_SOC_DAPM_INPUT("IN2R"),
  1907. SND_SOC_DAPM_INPUT("IN3L"),
  1908. SND_SOC_DAPM_INPUT("IN3R"),
  1909. SND_SOC_DAPM_INPUT("IN4L"),
  1910. SND_SOC_DAPM_INPUT("IN4R"),
  1911. SND_SOC_DAPM_SIGGEN("Beep"),
  1912. SND_SOC_DAPM_INPUT("DMICDAT"),
  1913. SND_SOC_DAPM_SUPPLY("MICBIAS", WM8962_PWR_MGMT_1, 1, 0, NULL, 0),
  1914. SND_SOC_DAPM_SUPPLY("Class G", WM8962_CHARGE_PUMP_B, 0, 1, NULL, 0),
  1915. SND_SOC_DAPM_SUPPLY("SYSCLK", WM8962_CLOCKING2, 5, 0, NULL, 0),
  1916. SND_SOC_DAPM_SUPPLY("Charge Pump", WM8962_CHARGE_PUMP_1, 0, 0, cp_event,
  1917. SND_SOC_DAPM_POST_PMU),
  1918. SND_SOC_DAPM_SUPPLY("TOCLK", WM8962_ADDITIONAL_CONTROL_1, 0, 0, NULL, 0),
  1919. SND_SOC_DAPM_SUPPLY_S("DSP2", 1, WM8962_DSP2_POWER_MANAGEMENT,
  1920. WM8962_DSP2_ENA_SHIFT, 0, dsp2_event,
  1921. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  1922. SND_SOC_DAPM_SUPPLY("TEMP_HP", WM8962_ADDITIONAL_CONTROL_4, 2, 0, NULL, 0),
  1923. SND_SOC_DAPM_SUPPLY("TEMP_SPK", WM8962_ADDITIONAL_CONTROL_4, 1, 0, NULL, 0),
  1924. SND_SOC_DAPM_MIXER("INPGAL", WM8962_LEFT_INPUT_PGA_CONTROL, 4, 0,
  1925. inpgal, ARRAY_SIZE(inpgal)),
  1926. SND_SOC_DAPM_MIXER("INPGAR", WM8962_RIGHT_INPUT_PGA_CONTROL, 4, 0,
  1927. inpgar, ARRAY_SIZE(inpgar)),
  1928. SND_SOC_DAPM_MIXER("MIXINL", WM8962_PWR_MGMT_1, 5, 0,
  1929. mixinl, ARRAY_SIZE(mixinl)),
  1930. SND_SOC_DAPM_MIXER("MIXINR", WM8962_PWR_MGMT_1, 4, 0,
  1931. mixinr, ARRAY_SIZE(mixinr)),
  1932. SND_SOC_DAPM_AIF_IN("DMIC_ENA", NULL, 0, WM8962_PWR_MGMT_1, 10, 0),
  1933. SND_SOC_DAPM_ADC("ADCL", "Capture", WM8962_PWR_MGMT_1, 3, 0),
  1934. SND_SOC_DAPM_ADC("ADCR", "Capture", WM8962_PWR_MGMT_1, 2, 0),
  1935. SND_SOC_DAPM_MUX("STL", SND_SOC_NOPM, 0, 0, &stl_mux),
  1936. SND_SOC_DAPM_MUX("STR", SND_SOC_NOPM, 0, 0, &str_mux),
  1937. SND_SOC_DAPM_DAC("DACL", "Playback", WM8962_PWR_MGMT_2, 8, 0),
  1938. SND_SOC_DAPM_DAC("DACR", "Playback", WM8962_PWR_MGMT_2, 7, 0),
  1939. SND_SOC_DAPM_PGA("Left Bypass", SND_SOC_NOPM, 0, 0, NULL, 0),
  1940. SND_SOC_DAPM_PGA("Right Bypass", SND_SOC_NOPM, 0, 0, NULL, 0),
  1941. SND_SOC_DAPM_MIXER("HPMIXL", WM8962_MIXER_ENABLES, 3, 0,
  1942. hpmixl, ARRAY_SIZE(hpmixl)),
  1943. SND_SOC_DAPM_MIXER("HPMIXR", WM8962_MIXER_ENABLES, 2, 0,
  1944. hpmixr, ARRAY_SIZE(hpmixr)),
  1945. SND_SOC_DAPM_MUX_E("HPOUTL PGA", WM8962_PWR_MGMT_2, 6, 0, &hpoutl_mux,
  1946. out_pga_event, SND_SOC_DAPM_POST_PMU),
  1947. SND_SOC_DAPM_MUX_E("HPOUTR PGA", WM8962_PWR_MGMT_2, 5, 0, &hpoutr_mux,
  1948. out_pga_event, SND_SOC_DAPM_POST_PMU),
  1949. SND_SOC_DAPM_PGA_E("HPOUT", SND_SOC_NOPM, 0, 0, NULL, 0, hp_event,
  1950. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
  1951. SND_SOC_DAPM_OUTPUT("HPOUTL"),
  1952. SND_SOC_DAPM_OUTPUT("HPOUTR"),
  1953. };
  1954. static const struct snd_soc_dapm_widget wm8962_dapm_spk_mono_widgets[] = {
  1955. SND_SOC_DAPM_MIXER("Speaker Mixer", WM8962_MIXER_ENABLES, 1, 0,
  1956. spkmixl, ARRAY_SIZE(spkmixl)),
  1957. SND_SOC_DAPM_MUX_E("Speaker PGA", WM8962_PWR_MGMT_2, 4, 0, &spkoutl_mux,
  1958. out_pga_event, SND_SOC_DAPM_POST_PMU),
  1959. SND_SOC_DAPM_PGA("Speaker Output", WM8962_CLASS_D_CONTROL_1, 7, 0, NULL, 0),
  1960. SND_SOC_DAPM_OUTPUT("SPKOUT"),
  1961. };
  1962. static const struct snd_soc_dapm_widget wm8962_dapm_spk_stereo_widgets[] = {
  1963. SND_SOC_DAPM_MIXER("SPKOUTL Mixer", WM8962_MIXER_ENABLES, 1, 0,
  1964. spkmixl, ARRAY_SIZE(spkmixl)),
  1965. SND_SOC_DAPM_MIXER("SPKOUTR Mixer", WM8962_MIXER_ENABLES, 0, 0,
  1966. spkmixr, ARRAY_SIZE(spkmixr)),
  1967. SND_SOC_DAPM_MUX_E("SPKOUTL PGA", WM8962_PWR_MGMT_2, 4, 0, &spkoutl_mux,
  1968. out_pga_event, SND_SOC_DAPM_POST_PMU),
  1969. SND_SOC_DAPM_MUX_E("SPKOUTR PGA", WM8962_PWR_MGMT_2, 3, 0, &spkoutr_mux,
  1970. out_pga_event, SND_SOC_DAPM_POST_PMU),
  1971. SND_SOC_DAPM_PGA("SPKOUTR Output", WM8962_CLASS_D_CONTROL_1, 7, 0, NULL, 0),
  1972. SND_SOC_DAPM_PGA("SPKOUTL Output", WM8962_CLASS_D_CONTROL_1, 6, 0, NULL, 0),
  1973. SND_SOC_DAPM_OUTPUT("SPKOUTL"),
  1974. SND_SOC_DAPM_OUTPUT("SPKOUTR"),
  1975. };
  1976. static const struct snd_soc_dapm_route wm8962_intercon[] = {
  1977. { "INPGAL", "IN1L Switch", "IN1L" },
  1978. { "INPGAL", "IN2L Switch", "IN2L" },
  1979. { "INPGAL", "IN3L Switch", "IN3L" },
  1980. { "INPGAL", "IN4L Switch", "IN4L" },
  1981. { "INPGAR", "IN1R Switch", "IN1R" },
  1982. { "INPGAR", "IN2R Switch", "IN2R" },
  1983. { "INPGAR", "IN3R Switch", "IN3R" },
  1984. { "INPGAR", "IN4R Switch", "IN4R" },
  1985. { "MIXINL", "IN2L Switch", "IN2L" },
  1986. { "MIXINL", "IN3L Switch", "IN3L" },
  1987. { "MIXINL", "PGA Switch", "INPGAL" },
  1988. { "MIXINR", "IN2R Switch", "IN2R" },
  1989. { "MIXINR", "IN3R Switch", "IN3R" },
  1990. { "MIXINR", "PGA Switch", "INPGAR" },
  1991. { "MICBIAS", NULL, "SYSCLK" },
  1992. { "DMIC_ENA", NULL, "DMICDAT" },
  1993. { "ADCL", NULL, "SYSCLK" },
  1994. { "ADCL", NULL, "TOCLK" },
  1995. { "ADCL", NULL, "MIXINL" },
  1996. { "ADCL", NULL, "DMIC_ENA" },
  1997. { "ADCL", NULL, "DSP2" },
  1998. { "ADCR", NULL, "SYSCLK" },
  1999. { "ADCR", NULL, "TOCLK" },
  2000. { "ADCR", NULL, "MIXINR" },
  2001. { "ADCR", NULL, "DMIC_ENA" },
  2002. { "ADCR", NULL, "DSP2" },
  2003. { "STL", "Left", "ADCL" },
  2004. { "STL", "Right", "ADCR" },
  2005. { "STL", NULL, "Class G" },
  2006. { "STR", "Left", "ADCL" },
  2007. { "STR", "Right", "ADCR" },
  2008. { "STR", NULL, "Class G" },
  2009. { "DACL", NULL, "SYSCLK" },
  2010. { "DACL", NULL, "TOCLK" },
  2011. { "DACL", NULL, "Beep" },
  2012. { "DACL", NULL, "STL" },
  2013. { "DACL", NULL, "DSP2" },
  2014. { "DACR", NULL, "SYSCLK" },
  2015. { "DACR", NULL, "TOCLK" },
  2016. { "DACR", NULL, "Beep" },
  2017. { "DACR", NULL, "STR" },
  2018. { "DACR", NULL, "DSP2" },
  2019. { "HPMIXL", "IN4L Switch", "IN4L" },
  2020. { "HPMIXL", "IN4R Switch", "IN4R" },
  2021. { "HPMIXL", "DACL Switch", "DACL" },
  2022. { "HPMIXL", "DACR Switch", "DACR" },
  2023. { "HPMIXL", "MIXINL Switch", "MIXINL" },
  2024. { "HPMIXL", "MIXINR Switch", "MIXINR" },
  2025. { "HPMIXR", "IN4L Switch", "IN4L" },
  2026. { "HPMIXR", "IN4R Switch", "IN4R" },
  2027. { "HPMIXR", "DACL Switch", "DACL" },
  2028. { "HPMIXR", "DACR Switch", "DACR" },
  2029. { "HPMIXR", "MIXINL Switch", "MIXINL" },
  2030. { "HPMIXR", "MIXINR Switch", "MIXINR" },
  2031. { "Left Bypass", NULL, "HPMIXL" },
  2032. { "Left Bypass", NULL, "Class G" },
  2033. { "Right Bypass", NULL, "HPMIXR" },
  2034. { "Right Bypass", NULL, "Class G" },
  2035. { "HPOUTL PGA", "Mixer", "Left Bypass" },
  2036. { "HPOUTL PGA", "DAC", "DACL" },
  2037. { "HPOUTR PGA", "Mixer", "Right Bypass" },
  2038. { "HPOUTR PGA", "DAC", "DACR" },
  2039. { "HPOUT", NULL, "HPOUTL PGA" },
  2040. { "HPOUT", NULL, "HPOUTR PGA" },
  2041. { "HPOUT", NULL, "Charge Pump" },
  2042. { "HPOUT", NULL, "SYSCLK" },
  2043. { "HPOUT", NULL, "TOCLK" },
  2044. { "HPOUTL", NULL, "HPOUT" },
  2045. { "HPOUTR", NULL, "HPOUT" },
  2046. { "HPOUTL", NULL, "TEMP_HP" },
  2047. { "HPOUTR", NULL, "TEMP_HP" },
  2048. };
  2049. static const struct snd_soc_dapm_route wm8962_spk_mono_intercon[] = {
  2050. { "Speaker Mixer", "IN4L Switch", "IN4L" },
  2051. { "Speaker Mixer", "IN4R Switch", "IN4R" },
  2052. { "Speaker Mixer", "DACL Switch", "DACL" },
  2053. { "Speaker Mixer", "DACR Switch", "DACR" },
  2054. { "Speaker Mixer", "MIXINL Switch", "MIXINL" },
  2055. { "Speaker Mixer", "MIXINR Switch", "MIXINR" },
  2056. { "Speaker PGA", "Mixer", "Speaker Mixer" },
  2057. { "Speaker PGA", "DAC", "DACL" },
  2058. { "Speaker Output", NULL, "Speaker PGA" },
  2059. { "Speaker Output", NULL, "SYSCLK" },
  2060. { "Speaker Output", NULL, "TOCLK" },
  2061. { "Speaker Output", NULL, "TEMP_SPK" },
  2062. { "SPKOUT", NULL, "Speaker Output" },
  2063. };
  2064. static const struct snd_soc_dapm_route wm8962_spk_stereo_intercon[] = {
  2065. { "SPKOUTL Mixer", "IN4L Switch", "IN4L" },
  2066. { "SPKOUTL Mixer", "IN4R Switch", "IN4R" },
  2067. { "SPKOUTL Mixer", "DACL Switch", "DACL" },
  2068. { "SPKOUTL Mixer", "DACR Switch", "DACR" },
  2069. { "SPKOUTL Mixer", "MIXINL Switch", "MIXINL" },
  2070. { "SPKOUTL Mixer", "MIXINR Switch", "MIXINR" },
  2071. { "SPKOUTR Mixer", "IN4L Switch", "IN4L" },
  2072. { "SPKOUTR Mixer", "IN4R Switch", "IN4R" },
  2073. { "SPKOUTR Mixer", "DACL Switch", "DACL" },
  2074. { "SPKOUTR Mixer", "DACR Switch", "DACR" },
  2075. { "SPKOUTR Mixer", "MIXINL Switch", "MIXINL" },
  2076. { "SPKOUTR Mixer", "MIXINR Switch", "MIXINR" },
  2077. { "SPKOUTL PGA", "Mixer", "SPKOUTL Mixer" },
  2078. { "SPKOUTL PGA", "DAC", "DACL" },
  2079. { "SPKOUTR PGA", "Mixer", "SPKOUTR Mixer" },
  2080. { "SPKOUTR PGA", "DAC", "DACR" },
  2081. { "SPKOUTL Output", NULL, "SPKOUTL PGA" },
  2082. { "SPKOUTL Output", NULL, "SYSCLK" },
  2083. { "SPKOUTL Output", NULL, "TOCLK" },
  2084. { "SPKOUTL Output", NULL, "TEMP_SPK" },
  2085. { "SPKOUTR Output", NULL, "SPKOUTR PGA" },
  2086. { "SPKOUTR Output", NULL, "SYSCLK" },
  2087. { "SPKOUTR Output", NULL, "TOCLK" },
  2088. { "SPKOUTR Output", NULL, "TEMP_SPK" },
  2089. { "SPKOUTL", NULL, "SPKOUTL Output" },
  2090. { "SPKOUTR", NULL, "SPKOUTR Output" },
  2091. };
  2092. static int wm8962_add_widgets(struct snd_soc_codec *codec)
  2093. {
  2094. struct wm8962_pdata *pdata = dev_get_platdata(codec->dev);
  2095. struct snd_soc_dapm_context *dapm = &codec->dapm;
  2096. snd_soc_add_codec_controls(codec, wm8962_snd_controls,
  2097. ARRAY_SIZE(wm8962_snd_controls));
  2098. if (pdata && pdata->spk_mono)
  2099. snd_soc_add_codec_controls(codec, wm8962_spk_mono_controls,
  2100. ARRAY_SIZE(wm8962_spk_mono_controls));
  2101. else
  2102. snd_soc_add_codec_controls(codec, wm8962_spk_stereo_controls,
  2103. ARRAY_SIZE(wm8962_spk_stereo_controls));
  2104. snd_soc_dapm_new_controls(dapm, wm8962_dapm_widgets,
  2105. ARRAY_SIZE(wm8962_dapm_widgets));
  2106. if (pdata && pdata->spk_mono)
  2107. snd_soc_dapm_new_controls(dapm, wm8962_dapm_spk_mono_widgets,
  2108. ARRAY_SIZE(wm8962_dapm_spk_mono_widgets));
  2109. else
  2110. snd_soc_dapm_new_controls(dapm, wm8962_dapm_spk_stereo_widgets,
  2111. ARRAY_SIZE(wm8962_dapm_spk_stereo_widgets));
  2112. snd_soc_dapm_add_routes(dapm, wm8962_intercon,
  2113. ARRAY_SIZE(wm8962_intercon));
  2114. if (pdata && pdata->spk_mono)
  2115. snd_soc_dapm_add_routes(dapm, wm8962_spk_mono_intercon,
  2116. ARRAY_SIZE(wm8962_spk_mono_intercon));
  2117. else
  2118. snd_soc_dapm_add_routes(dapm, wm8962_spk_stereo_intercon,
  2119. ARRAY_SIZE(wm8962_spk_stereo_intercon));
  2120. snd_soc_dapm_disable_pin(dapm, "Beep");
  2121. return 0;
  2122. }
  2123. /* -1 for reserved values */
  2124. static const int bclk_divs[] = {
  2125. 1, -1, 2, 3, 4, -1, 6, 8, -1, 12, 16, 24, -1, 32, 32, 32
  2126. };
  2127. static const int sysclk_rates[] = {
  2128. 64, 128, 192, 256, 384, 512, 768, 1024, 1408, 1536, 3072, 6144
  2129. };
  2130. static void wm8962_configure_bclk(struct snd_soc_codec *codec)
  2131. {
  2132. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  2133. int dspclk, i;
  2134. int clocking2 = 0;
  2135. int clocking4 = 0;
  2136. int aif2 = 0;
  2137. if (!wm8962->sysclk_rate) {
  2138. dev_dbg(codec->dev, "No SYSCLK configured\n");
  2139. return;
  2140. }
  2141. if (!wm8962->bclk || !wm8962->lrclk) {
  2142. dev_dbg(codec->dev, "No audio clocks configured\n");
  2143. return;
  2144. }
  2145. for (i = 0; i < ARRAY_SIZE(sysclk_rates); i++) {
  2146. if (sysclk_rates[i] == wm8962->sysclk_rate / wm8962->lrclk) {
  2147. clocking4 |= i << WM8962_SYSCLK_RATE_SHIFT;
  2148. break;
  2149. }
  2150. }
  2151. if (i == ARRAY_SIZE(sysclk_rates)) {
  2152. dev_err(codec->dev, "Unsupported sysclk ratio %d\n",
  2153. wm8962->sysclk_rate / wm8962->lrclk);
  2154. return;
  2155. }
  2156. dev_dbg(codec->dev, "Selected sysclk ratio %d\n", sysclk_rates[i]);
  2157. snd_soc_update_bits(codec, WM8962_CLOCKING_4,
  2158. WM8962_SYSCLK_RATE_MASK, clocking4);
  2159. dspclk = snd_soc_read(codec, WM8962_CLOCKING1);
  2160. if (dspclk < 0) {
  2161. dev_err(codec->dev, "Failed to read DSPCLK: %d\n", dspclk);
  2162. return;
  2163. }
  2164. dspclk = (dspclk & WM8962_DSPCLK_DIV_MASK) >> WM8962_DSPCLK_DIV_SHIFT;
  2165. switch (dspclk) {
  2166. case 0:
  2167. dspclk = wm8962->sysclk_rate;
  2168. break;
  2169. case 1:
  2170. dspclk = wm8962->sysclk_rate / 2;
  2171. break;
  2172. case 2:
  2173. dspclk = wm8962->sysclk_rate / 4;
  2174. break;
  2175. default:
  2176. dev_warn(codec->dev, "Unknown DSPCLK divisor read back\n");
  2177. dspclk = wm8962->sysclk;
  2178. }
  2179. dev_dbg(codec->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk);
  2180. /* We're expecting an exact match */
  2181. for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) {
  2182. if (bclk_divs[i] < 0)
  2183. continue;
  2184. if (dspclk / bclk_divs[i] == wm8962->bclk) {
  2185. dev_dbg(codec->dev, "Selected BCLK_DIV %d for %dHz\n",
  2186. bclk_divs[i], wm8962->bclk);
  2187. clocking2 |= i;
  2188. break;
  2189. }
  2190. }
  2191. if (i == ARRAY_SIZE(bclk_divs)) {
  2192. dev_err(codec->dev, "Unsupported BCLK ratio %d\n",
  2193. dspclk / wm8962->bclk);
  2194. return;
  2195. }
  2196. aif2 |= wm8962->bclk / wm8962->lrclk;
  2197. dev_dbg(codec->dev, "Selected LRCLK divisor %d for %dHz\n",
  2198. wm8962->bclk / wm8962->lrclk, wm8962->lrclk);
  2199. snd_soc_update_bits(codec, WM8962_CLOCKING2,
  2200. WM8962_BCLK_DIV_MASK, clocking2);
  2201. snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_2,
  2202. WM8962_AIF_RATE_MASK, aif2);
  2203. }
  2204. static int wm8962_set_bias_level(struct snd_soc_codec *codec,
  2205. enum snd_soc_bias_level level)
  2206. {
  2207. if (level == codec->dapm.bias_level)
  2208. return 0;
  2209. switch (level) {
  2210. case SND_SOC_BIAS_ON:
  2211. break;
  2212. case SND_SOC_BIAS_PREPARE:
  2213. /* VMID 2*50k */
  2214. snd_soc_update_bits(codec, WM8962_PWR_MGMT_1,
  2215. WM8962_VMID_SEL_MASK, 0x80);
  2216. wm8962_configure_bclk(codec);
  2217. break;
  2218. case SND_SOC_BIAS_STANDBY:
  2219. /* VMID 2*250k */
  2220. snd_soc_update_bits(codec, WM8962_PWR_MGMT_1,
  2221. WM8962_VMID_SEL_MASK, 0x100);
  2222. if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
  2223. msleep(100);
  2224. break;
  2225. case SND_SOC_BIAS_OFF:
  2226. break;
  2227. }
  2228. codec->dapm.bias_level = level;
  2229. return 0;
  2230. }
  2231. static const struct {
  2232. int rate;
  2233. int reg;
  2234. } sr_vals[] = {
  2235. { 48000, 0 },
  2236. { 44100, 0 },
  2237. { 32000, 1 },
  2238. { 22050, 2 },
  2239. { 24000, 2 },
  2240. { 16000, 3 },
  2241. { 11025, 4 },
  2242. { 12000, 4 },
  2243. { 8000, 5 },
  2244. { 88200, 6 },
  2245. { 96000, 6 },
  2246. };
  2247. static int wm8962_hw_params(struct snd_pcm_substream *substream,
  2248. struct snd_pcm_hw_params *params,
  2249. struct snd_soc_dai *dai)
  2250. {
  2251. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  2252. struct snd_soc_codec *codec = rtd->codec;
  2253. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  2254. int i;
  2255. int aif0 = 0;
  2256. int adctl3 = 0;
  2257. wm8962->bclk = snd_soc_params_to_bclk(params);
  2258. if (params_channels(params) == 1)
  2259. wm8962->bclk *= 2;
  2260. wm8962->lrclk = params_rate(params);
  2261. for (i = 0; i < ARRAY_SIZE(sr_vals); i++) {
  2262. if (sr_vals[i].rate == wm8962->lrclk) {
  2263. adctl3 |= sr_vals[i].reg;
  2264. break;
  2265. }
  2266. }
  2267. if (i == ARRAY_SIZE(sr_vals)) {
  2268. dev_err(codec->dev, "Unsupported rate %dHz\n", wm8962->lrclk);
  2269. return -EINVAL;
  2270. }
  2271. if (wm8962->lrclk % 8000 == 0)
  2272. adctl3 |= WM8962_SAMPLE_RATE_INT_MODE;
  2273. switch (params_format(params)) {
  2274. case SNDRV_PCM_FORMAT_S16_LE:
  2275. break;
  2276. case SNDRV_PCM_FORMAT_S20_3LE:
  2277. aif0 |= 0x4;
  2278. break;
  2279. case SNDRV_PCM_FORMAT_S24_LE:
  2280. aif0 |= 0x8;
  2281. break;
  2282. case SNDRV_PCM_FORMAT_S32_LE:
  2283. aif0 |= 0xc;
  2284. break;
  2285. default:
  2286. return -EINVAL;
  2287. }
  2288. snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0,
  2289. WM8962_WL_MASK, aif0);
  2290. snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_3,
  2291. WM8962_SAMPLE_RATE_INT_MODE |
  2292. WM8962_SAMPLE_RATE_MASK, adctl3);
  2293. if (codec->dapm.bias_level == SND_SOC_BIAS_ON)
  2294. wm8962_configure_bclk(codec);
  2295. return 0;
  2296. }
  2297. static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
  2298. unsigned int freq, int dir)
  2299. {
  2300. struct snd_soc_codec *codec = dai->codec;
  2301. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  2302. int src;
  2303. switch (clk_id) {
  2304. case WM8962_SYSCLK_MCLK:
  2305. wm8962->sysclk = WM8962_SYSCLK_MCLK;
  2306. src = 0;
  2307. break;
  2308. case WM8962_SYSCLK_FLL:
  2309. wm8962->sysclk = WM8962_SYSCLK_FLL;
  2310. src = 1 << WM8962_SYSCLK_SRC_SHIFT;
  2311. break;
  2312. default:
  2313. return -EINVAL;
  2314. }
  2315. snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_SRC_MASK,
  2316. src);
  2317. wm8962->sysclk_rate = freq;
  2318. wm8962_configure_bclk(codec);
  2319. return 0;
  2320. }
  2321. static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2322. {
  2323. struct snd_soc_codec *codec = dai->codec;
  2324. int aif0 = 0;
  2325. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  2326. case SND_SOC_DAIFMT_DSP_B:
  2327. aif0 |= WM8962_LRCLK_INV | 3;
  2328. case SND_SOC_DAIFMT_DSP_A:
  2329. aif0 |= 3;
  2330. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  2331. case SND_SOC_DAIFMT_NB_NF:
  2332. case SND_SOC_DAIFMT_IB_NF:
  2333. break;
  2334. default:
  2335. return -EINVAL;
  2336. }
  2337. break;
  2338. case SND_SOC_DAIFMT_RIGHT_J:
  2339. break;
  2340. case SND_SOC_DAIFMT_LEFT_J:
  2341. aif0 |= 1;
  2342. break;
  2343. case SND_SOC_DAIFMT_I2S:
  2344. aif0 |= 2;
  2345. break;
  2346. default:
  2347. return -EINVAL;
  2348. }
  2349. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  2350. case SND_SOC_DAIFMT_NB_NF:
  2351. break;
  2352. case SND_SOC_DAIFMT_IB_NF:
  2353. aif0 |= WM8962_BCLK_INV;
  2354. break;
  2355. case SND_SOC_DAIFMT_NB_IF:
  2356. aif0 |= WM8962_LRCLK_INV;
  2357. break;
  2358. case SND_SOC_DAIFMT_IB_IF:
  2359. aif0 |= WM8962_BCLK_INV | WM8962_LRCLK_INV;
  2360. break;
  2361. default:
  2362. return -EINVAL;
  2363. }
  2364. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  2365. case SND_SOC_DAIFMT_CBM_CFM:
  2366. aif0 |= WM8962_MSTR;
  2367. break;
  2368. case SND_SOC_DAIFMT_CBS_CFS:
  2369. break;
  2370. default:
  2371. return -EINVAL;
  2372. }
  2373. snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0,
  2374. WM8962_FMT_MASK | WM8962_BCLK_INV | WM8962_MSTR |
  2375. WM8962_LRCLK_INV, aif0);
  2376. return 0;
  2377. }
  2378. struct _fll_div {
  2379. u16 fll_fratio;
  2380. u16 fll_outdiv;
  2381. u16 fll_refclk_div;
  2382. u16 n;
  2383. u16 theta;
  2384. u16 lambda;
  2385. };
  2386. /* The size in bits of the FLL divide multiplied by 10
  2387. * to allow rounding later */
  2388. #define FIXED_FLL_SIZE ((1 << 16) * 10)
  2389. static struct {
  2390. unsigned int min;
  2391. unsigned int max;
  2392. u16 fll_fratio;
  2393. int ratio;
  2394. } fll_fratios[] = {
  2395. { 0, 64000, 4, 16 },
  2396. { 64000, 128000, 3, 8 },
  2397. { 128000, 256000, 2, 4 },
  2398. { 256000, 1000000, 1, 2 },
  2399. { 1000000, 13500000, 0, 1 },
  2400. };
  2401. static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
  2402. unsigned int Fout)
  2403. {
  2404. unsigned int target;
  2405. unsigned int div;
  2406. unsigned int fratio, gcd_fll;
  2407. int i;
  2408. /* Fref must be <=13.5MHz */
  2409. div = 1;
  2410. fll_div->fll_refclk_div = 0;
  2411. while ((Fref / div) > 13500000) {
  2412. div *= 2;
  2413. fll_div->fll_refclk_div++;
  2414. if (div > 4) {
  2415. pr_err("Can't scale %dMHz input down to <=13.5MHz\n",
  2416. Fref);
  2417. return -EINVAL;
  2418. }
  2419. }
  2420. pr_debug("FLL Fref=%u Fout=%u\n", Fref, Fout);
  2421. /* Apply the division for our remaining calculations */
  2422. Fref /= div;
  2423. /* Fvco should be 90-100MHz; don't check the upper bound */
  2424. div = 2;
  2425. while (Fout * div < 90000000) {
  2426. div++;
  2427. if (div > 64) {
  2428. pr_err("Unable to find FLL_OUTDIV for Fout=%uHz\n",
  2429. Fout);
  2430. return -EINVAL;
  2431. }
  2432. }
  2433. target = Fout * div;
  2434. fll_div->fll_outdiv = div - 1;
  2435. pr_debug("FLL Fvco=%dHz\n", target);
  2436. /* Find an appropriate FLL_FRATIO and factor it out of the target */
  2437. for (i = 0; i < ARRAY_SIZE(fll_fratios); i++) {
  2438. if (fll_fratios[i].min <= Fref && Fref <= fll_fratios[i].max) {
  2439. fll_div->fll_fratio = fll_fratios[i].fll_fratio;
  2440. fratio = fll_fratios[i].ratio;
  2441. break;
  2442. }
  2443. }
  2444. if (i == ARRAY_SIZE(fll_fratios)) {
  2445. pr_err("Unable to find FLL_FRATIO for Fref=%uHz\n", Fref);
  2446. return -EINVAL;
  2447. }
  2448. fll_div->n = target / (fratio * Fref);
  2449. if (target % Fref == 0) {
  2450. fll_div->theta = 0;
  2451. fll_div->lambda = 0;
  2452. } else {
  2453. gcd_fll = gcd(target, fratio * Fref);
  2454. fll_div->theta = (target - (fll_div->n * fratio * Fref))
  2455. / gcd_fll;
  2456. fll_div->lambda = (fratio * Fref) / gcd_fll;
  2457. }
  2458. pr_debug("FLL N=%x THETA=%x LAMBDA=%x\n",
  2459. fll_div->n, fll_div->theta, fll_div->lambda);
  2460. pr_debug("FLL_FRATIO=%x FLL_OUTDIV=%x FLL_REFCLK_DIV=%x\n",
  2461. fll_div->fll_fratio, fll_div->fll_outdiv,
  2462. fll_div->fll_refclk_div);
  2463. return 0;
  2464. }
  2465. static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
  2466. unsigned int Fref, unsigned int Fout)
  2467. {
  2468. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  2469. struct _fll_div fll_div;
  2470. unsigned long timeout;
  2471. int ret;
  2472. int fll1 = 0;
  2473. /* Any change? */
  2474. if (source == wm8962->fll_src && Fref == wm8962->fll_fref &&
  2475. Fout == wm8962->fll_fout)
  2476. return 0;
  2477. if (Fout == 0) {
  2478. dev_dbg(codec->dev, "FLL disabled\n");
  2479. wm8962->fll_fref = 0;
  2480. wm8962->fll_fout = 0;
  2481. snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1,
  2482. WM8962_FLL_ENA, 0);
  2483. pm_runtime_put(codec->dev);
  2484. return 0;
  2485. }
  2486. ret = fll_factors(&fll_div, Fref, Fout);
  2487. if (ret != 0)
  2488. return ret;
  2489. /* Parameters good, disable so we can reprogram */
  2490. snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0);
  2491. switch (fll_id) {
  2492. case WM8962_FLL_MCLK:
  2493. case WM8962_FLL_BCLK:
  2494. case WM8962_FLL_OSC:
  2495. fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
  2496. break;
  2497. case WM8962_FLL_INT:
  2498. snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1,
  2499. WM8962_FLL_OSC_ENA, WM8962_FLL_OSC_ENA);
  2500. snd_soc_update_bits(codec, WM8962_FLL_CONTROL_5,
  2501. WM8962_FLL_FRC_NCO, WM8962_FLL_FRC_NCO);
  2502. break;
  2503. default:
  2504. dev_err(codec->dev, "Unknown FLL source %d\n", ret);
  2505. return -EINVAL;
  2506. }
  2507. if (fll_div.theta || fll_div.lambda)
  2508. fll1 |= WM8962_FLL_FRAC;
  2509. /* Stop the FLL while we reconfigure */
  2510. snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0);
  2511. snd_soc_update_bits(codec, WM8962_FLL_CONTROL_2,
  2512. WM8962_FLL_OUTDIV_MASK |
  2513. WM8962_FLL_REFCLK_DIV_MASK,
  2514. (fll_div.fll_outdiv << WM8962_FLL_OUTDIV_SHIFT) |
  2515. (fll_div.fll_refclk_div));
  2516. snd_soc_update_bits(codec, WM8962_FLL_CONTROL_3,
  2517. WM8962_FLL_FRATIO_MASK, fll_div.fll_fratio);
  2518. snd_soc_write(codec, WM8962_FLL_CONTROL_6, fll_div.theta);
  2519. snd_soc_write(codec, WM8962_FLL_CONTROL_7, fll_div.lambda);
  2520. snd_soc_write(codec, WM8962_FLL_CONTROL_8, fll_div.n);
  2521. try_wait_for_completion(&wm8962->fll_lock);
  2522. pm_runtime_get_sync(codec->dev);
  2523. snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1,
  2524. WM8962_FLL_FRAC | WM8962_FLL_REFCLK_SRC_MASK |
  2525. WM8962_FLL_ENA, fll1 | WM8962_FLL_ENA);
  2526. dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout);
  2527. ret = 0;
  2528. if (fll1 & WM8962_FLL_ENA) {
  2529. /* This should be a massive overestimate but go even
  2530. * higher if we'll error out
  2531. */
  2532. if (wm8962->irq)
  2533. timeout = msecs_to_jiffies(5);
  2534. else
  2535. timeout = msecs_to_jiffies(1);
  2536. timeout = wait_for_completion_timeout(&wm8962->fll_lock,
  2537. timeout);
  2538. if (timeout == 0 && wm8962->irq) {
  2539. dev_err(codec->dev, "FLL lock timed out");
  2540. ret = -ETIMEDOUT;
  2541. }
  2542. }
  2543. wm8962->fll_fref = Fref;
  2544. wm8962->fll_fout = Fout;
  2545. wm8962->fll_src = source;
  2546. return ret;
  2547. }
  2548. static int wm8962_mute(struct snd_soc_dai *dai, int mute)
  2549. {
  2550. struct snd_soc_codec *codec = dai->codec;
  2551. int val, ret;
  2552. if (mute)
  2553. val = WM8962_DAC_MUTE | WM8962_DAC_MUTE_ALT;
  2554. else
  2555. val = 0;
  2556. /**
  2557. * The DAC mute bit is mirrored in two registers, update both to keep
  2558. * the register cache consistent.
  2559. */
  2560. ret = snd_soc_update_bits(codec, WM8962_CLASS_D_CONTROL_1,
  2561. WM8962_DAC_MUTE_ALT, val);
  2562. if (ret < 0)
  2563. return ret;
  2564. return snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1,
  2565. WM8962_DAC_MUTE, val);
  2566. }
  2567. #define WM8962_RATES SNDRV_PCM_RATE_8000_96000
  2568. #define WM8962_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
  2569. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
  2570. static const struct snd_soc_dai_ops wm8962_dai_ops = {
  2571. .hw_params = wm8962_hw_params,
  2572. .set_sysclk = wm8962_set_dai_sysclk,
  2573. .set_fmt = wm8962_set_dai_fmt,
  2574. .digital_mute = wm8962_mute,
  2575. };
  2576. static struct snd_soc_dai_driver wm8962_dai = {
  2577. .name = "wm8962",
  2578. .playback = {
  2579. .stream_name = "Playback",
  2580. .channels_min = 1,
  2581. .channels_max = 2,
  2582. .rates = WM8962_RATES,
  2583. .formats = WM8962_FORMATS,
  2584. },
  2585. .capture = {
  2586. .stream_name = "Capture",
  2587. .channels_min = 1,
  2588. .channels_max = 2,
  2589. .rates = WM8962_RATES,
  2590. .formats = WM8962_FORMATS,
  2591. },
  2592. .ops = &wm8962_dai_ops,
  2593. .symmetric_rates = 1,
  2594. };
  2595. static void wm8962_mic_work(struct work_struct *work)
  2596. {
  2597. struct wm8962_priv *wm8962 = container_of(work,
  2598. struct wm8962_priv,
  2599. mic_work.work);
  2600. struct snd_soc_codec *codec = wm8962->codec;
  2601. int status = 0;
  2602. int irq_pol = 0;
  2603. int reg;
  2604. reg = snd_soc_read(codec, WM8962_ADDITIONAL_CONTROL_4);
  2605. if (reg & WM8962_MICDET_STS) {
  2606. status |= SND_JACK_MICROPHONE;
  2607. irq_pol |= WM8962_MICD_IRQ_POL;
  2608. }
  2609. if (reg & WM8962_MICSHORT_STS) {
  2610. status |= SND_JACK_BTN_0;
  2611. irq_pol |= WM8962_MICSCD_IRQ_POL;
  2612. }
  2613. snd_soc_jack_report(wm8962->jack, status,
  2614. SND_JACK_MICROPHONE | SND_JACK_BTN_0);
  2615. snd_soc_update_bits(codec, WM8962_MICINT_SOURCE_POL,
  2616. WM8962_MICSCD_IRQ_POL |
  2617. WM8962_MICD_IRQ_POL, irq_pol);
  2618. }
  2619. static irqreturn_t wm8962_irq(int irq, void *data)
  2620. {
  2621. struct device *dev = data;
  2622. struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
  2623. unsigned int mask;
  2624. unsigned int active;
  2625. int reg, ret;
  2626. ret = regmap_read(wm8962->regmap, WM8962_INTERRUPT_STATUS_2_MASK,
  2627. &mask);
  2628. if (ret != 0) {
  2629. dev_err(dev, "Failed to read interrupt mask: %d\n",
  2630. ret);
  2631. return IRQ_NONE;
  2632. }
  2633. ret = regmap_read(wm8962->regmap, WM8962_INTERRUPT_STATUS_2, &active);
  2634. if (ret != 0) {
  2635. dev_err(dev, "Failed to read interrupt: %d\n", ret);
  2636. return IRQ_NONE;
  2637. }
  2638. active &= ~mask;
  2639. if (!active)
  2640. return IRQ_NONE;
  2641. /* Acknowledge the interrupts */
  2642. ret = regmap_write(wm8962->regmap, WM8962_INTERRUPT_STATUS_2, active);
  2643. if (ret != 0)
  2644. dev_warn(dev, "Failed to ack interrupt: %d\n", ret);
  2645. if (active & WM8962_FLL_LOCK_EINT) {
  2646. dev_dbg(dev, "FLL locked\n");
  2647. complete(&wm8962->fll_lock);
  2648. }
  2649. if (active & WM8962_FIFOS_ERR_EINT)
  2650. dev_err(dev, "FIFO error\n");
  2651. if (active & WM8962_TEMP_SHUT_EINT) {
  2652. dev_crit(dev, "Thermal shutdown\n");
  2653. ret = regmap_read(wm8962->regmap,
  2654. WM8962_THERMAL_SHUTDOWN_STATUS, &reg);
  2655. if (ret != 0) {
  2656. dev_warn(dev, "Failed to read thermal status: %d\n",
  2657. ret);
  2658. reg = 0;
  2659. }
  2660. if (reg & WM8962_TEMP_ERR_HP)
  2661. dev_crit(dev, "Headphone thermal error\n");
  2662. if (reg & WM8962_TEMP_WARN_HP)
  2663. dev_crit(dev, "Headphone thermal warning\n");
  2664. if (reg & WM8962_TEMP_ERR_SPK)
  2665. dev_crit(dev, "Speaker thermal error\n");
  2666. if (reg & WM8962_TEMP_WARN_SPK)
  2667. dev_crit(dev, "Speaker thermal warning\n");
  2668. }
  2669. if (active & (WM8962_MICSCD_EINT | WM8962_MICD_EINT)) {
  2670. dev_dbg(dev, "Microphone event detected\n");
  2671. #ifndef CONFIG_SND_SOC_WM8962_MODULE
  2672. trace_snd_soc_jack_irq(dev_name(dev));
  2673. #endif
  2674. pm_wakeup_event(dev, 300);
  2675. schedule_delayed_work(&wm8962->mic_work,
  2676. msecs_to_jiffies(250));
  2677. }
  2678. return IRQ_HANDLED;
  2679. }
  2680. /**
  2681. * wm8962_mic_detect - Enable microphone detection via the WM8962 IRQ
  2682. *
  2683. * @codec: WM8962 codec
  2684. * @jack: jack to report detection events on
  2685. *
  2686. * Enable microphone detection via IRQ on the WM8962. If GPIOs are
  2687. * being used to bring out signals to the processor then only platform
  2688. * data configuration is needed for WM8962 and processor GPIOs should
  2689. * be configured using snd_soc_jack_add_gpios() instead.
  2690. *
  2691. * If no jack is supplied detection will be disabled.
  2692. */
  2693. int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
  2694. {
  2695. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  2696. int irq_mask, enable;
  2697. wm8962->jack = jack;
  2698. if (jack) {
  2699. irq_mask = 0;
  2700. enable = WM8962_MICDET_ENA;
  2701. } else {
  2702. irq_mask = WM8962_MICD_EINT | WM8962_MICSCD_EINT;
  2703. enable = 0;
  2704. }
  2705. snd_soc_update_bits(codec, WM8962_INTERRUPT_STATUS_2_MASK,
  2706. WM8962_MICD_EINT | WM8962_MICSCD_EINT, irq_mask);
  2707. snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_4,
  2708. WM8962_MICDET_ENA, enable);
  2709. /* Send an initial empty report */
  2710. snd_soc_jack_report(wm8962->jack, 0,
  2711. SND_JACK_MICROPHONE | SND_JACK_BTN_0);
  2712. if (jack) {
  2713. snd_soc_dapm_force_enable_pin(&codec->dapm, "SYSCLK");
  2714. snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS");
  2715. } else {
  2716. snd_soc_dapm_disable_pin(&codec->dapm, "SYSCLK");
  2717. snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
  2718. }
  2719. return 0;
  2720. }
  2721. EXPORT_SYMBOL_GPL(wm8962_mic_detect);
  2722. #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
  2723. static int beep_rates[] = {
  2724. 500, 1000, 2000, 4000,
  2725. };
  2726. static void wm8962_beep_work(struct work_struct *work)
  2727. {
  2728. struct wm8962_priv *wm8962 =
  2729. container_of(work, struct wm8962_priv, beep_work);
  2730. struct snd_soc_codec *codec = wm8962->codec;
  2731. struct snd_soc_dapm_context *dapm = &codec->dapm;
  2732. int i;
  2733. int reg = 0;
  2734. int best = 0;
  2735. if (wm8962->beep_rate) {
  2736. for (i = 0; i < ARRAY_SIZE(beep_rates); i++) {
  2737. if (abs(wm8962->beep_rate - beep_rates[i]) <
  2738. abs(wm8962->beep_rate - beep_rates[best]))
  2739. best = i;
  2740. }
  2741. dev_dbg(codec->dev, "Set beep rate %dHz for requested %dHz\n",
  2742. beep_rates[best], wm8962->beep_rate);
  2743. reg = WM8962_BEEP_ENA | (best << WM8962_BEEP_RATE_SHIFT);
  2744. snd_soc_dapm_enable_pin(dapm, "Beep");
  2745. } else {
  2746. dev_dbg(codec->dev, "Disabling beep\n");
  2747. snd_soc_dapm_disable_pin(dapm, "Beep");
  2748. }
  2749. snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1,
  2750. WM8962_BEEP_ENA | WM8962_BEEP_RATE_MASK, reg);
  2751. snd_soc_dapm_sync(dapm);
  2752. }
  2753. /* For usability define a way of injecting beep events for the device -
  2754. * many systems will not have a keyboard.
  2755. */
  2756. static int wm8962_beep_event(struct input_dev *dev, unsigned int type,
  2757. unsigned int code, int hz)
  2758. {
  2759. struct snd_soc_codec *codec = input_get_drvdata(dev);
  2760. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  2761. dev_dbg(codec->dev, "Beep event %x %x\n", code, hz);
  2762. switch (code) {
  2763. case SND_BELL:
  2764. if (hz)
  2765. hz = 1000;
  2766. case SND_TONE:
  2767. break;
  2768. default:
  2769. return -1;
  2770. }
  2771. /* Kick the beep from a workqueue */
  2772. wm8962->beep_rate = hz;
  2773. schedule_work(&wm8962->beep_work);
  2774. return 0;
  2775. }
  2776. static ssize_t wm8962_beep_set(struct device *dev,
  2777. struct device_attribute *attr,
  2778. const char *buf, size_t count)
  2779. {
  2780. struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
  2781. long int time;
  2782. int ret;
  2783. ret = strict_strtol(buf, 10, &time);
  2784. if (ret != 0)
  2785. return ret;
  2786. input_event(wm8962->beep, EV_SND, SND_TONE, time);
  2787. return count;
  2788. }
  2789. static DEVICE_ATTR(beep, 0200, NULL, wm8962_beep_set);
  2790. static void wm8962_init_beep(struct snd_soc_codec *codec)
  2791. {
  2792. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  2793. int ret;
  2794. wm8962->beep = input_allocate_device();
  2795. if (!wm8962->beep) {
  2796. dev_err(codec->dev, "Failed to allocate beep device\n");
  2797. return;
  2798. }
  2799. INIT_WORK(&wm8962->beep_work, wm8962_beep_work);
  2800. wm8962->beep_rate = 0;
  2801. wm8962->beep->name = "WM8962 Beep Generator";
  2802. wm8962->beep->phys = dev_name(codec->dev);
  2803. wm8962->beep->id.bustype = BUS_I2C;
  2804. wm8962->beep->evbit[0] = BIT_MASK(EV_SND);
  2805. wm8962->beep->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
  2806. wm8962->beep->event = wm8962_beep_event;
  2807. wm8962->beep->dev.parent = codec->dev;
  2808. input_set_drvdata(wm8962->beep, codec);
  2809. ret = input_register_device(wm8962->beep);
  2810. if (ret != 0) {
  2811. input_free_device(wm8962->beep);
  2812. wm8962->beep = NULL;
  2813. dev_err(codec->dev, "Failed to register beep device\n");
  2814. }
  2815. ret = device_create_file(codec->dev, &dev_attr_beep);
  2816. if (ret != 0) {
  2817. dev_err(codec->dev, "Failed to create keyclick file: %d\n",
  2818. ret);
  2819. }
  2820. }
  2821. static void wm8962_free_beep(struct snd_soc_codec *codec)
  2822. {
  2823. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  2824. device_remove_file(codec->dev, &dev_attr_beep);
  2825. input_unregister_device(wm8962->beep);
  2826. cancel_work_sync(&wm8962->beep_work);
  2827. wm8962->beep = NULL;
  2828. snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA,0);
  2829. }
  2830. #else
  2831. static void wm8962_init_beep(struct snd_soc_codec *codec)
  2832. {
  2833. }
  2834. static void wm8962_free_beep(struct snd_soc_codec *codec)
  2835. {
  2836. }
  2837. #endif
  2838. static void wm8962_set_gpio_mode(struct snd_soc_codec *codec, int gpio)
  2839. {
  2840. int mask = 0;
  2841. int val = 0;
  2842. /* Some of the GPIOs are behind MFP configuration and need to
  2843. * be put into GPIO mode. */
  2844. switch (gpio) {
  2845. case 2:
  2846. mask = WM8962_CLKOUT2_SEL_MASK;
  2847. val = 1 << WM8962_CLKOUT2_SEL_SHIFT;
  2848. break;
  2849. case 3:
  2850. mask = WM8962_CLKOUT3_SEL_MASK;
  2851. val = 1 << WM8962_CLKOUT3_SEL_SHIFT;
  2852. break;
  2853. default:
  2854. break;
  2855. }
  2856. if (mask)
  2857. snd_soc_update_bits(codec, WM8962_ANALOGUE_CLOCKING1,
  2858. mask, val);
  2859. }
  2860. #ifdef CONFIG_GPIOLIB
  2861. static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip)
  2862. {
  2863. return container_of(chip, struct wm8962_priv, gpio_chip);
  2864. }
  2865. static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
  2866. {
  2867. struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
  2868. struct snd_soc_codec *codec = wm8962->codec;
  2869. /* The WM8962 GPIOs aren't linearly numbered. For simplicity
  2870. * we export linear numbers and error out if the unsupported
  2871. * ones are requsted.
  2872. */
  2873. switch (offset + 1) {
  2874. case 2:
  2875. case 3:
  2876. case 5:
  2877. case 6:
  2878. break;
  2879. default:
  2880. return -EINVAL;
  2881. }
  2882. wm8962_set_gpio_mode(codec, offset + 1);
  2883. return 0;
  2884. }
  2885. static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
  2886. {
  2887. struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
  2888. struct snd_soc_codec *codec = wm8962->codec;
  2889. snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset,
  2890. WM8962_GP2_LVL, !!value << WM8962_GP2_LVL_SHIFT);
  2891. }
  2892. static int wm8962_gpio_direction_out(struct gpio_chip *chip,
  2893. unsigned offset, int value)
  2894. {
  2895. struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
  2896. struct snd_soc_codec *codec = wm8962->codec;
  2897. int ret, val;
  2898. /* Force function 1 (logic output) */
  2899. val = (1 << WM8962_GP2_FN_SHIFT) | (value << WM8962_GP2_LVL_SHIFT);
  2900. ret = snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset,
  2901. WM8962_GP2_FN_MASK | WM8962_GP2_LVL, val);
  2902. if (ret < 0)
  2903. return ret;
  2904. return 0;
  2905. }
  2906. static struct gpio_chip wm8962_template_chip = {
  2907. .label = "wm8962",
  2908. .owner = THIS_MODULE,
  2909. .request = wm8962_gpio_request,
  2910. .direction_output = wm8962_gpio_direction_out,
  2911. .set = wm8962_gpio_set,
  2912. .can_sleep = 1,
  2913. };
  2914. static void wm8962_init_gpio(struct snd_soc_codec *codec)
  2915. {
  2916. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  2917. struct wm8962_pdata *pdata = dev_get_platdata(codec->dev);
  2918. int ret;
  2919. wm8962->gpio_chip = wm8962_template_chip;
  2920. wm8962->gpio_chip.ngpio = WM8962_MAX_GPIO;
  2921. wm8962->gpio_chip.dev = codec->dev;
  2922. if (pdata && pdata->gpio_base)
  2923. wm8962->gpio_chip.base = pdata->gpio_base;
  2924. else
  2925. wm8962->gpio_chip.base = -1;
  2926. ret = gpiochip_add(&wm8962->gpio_chip);
  2927. if (ret != 0)
  2928. dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret);
  2929. }
  2930. static void wm8962_free_gpio(struct snd_soc_codec *codec)
  2931. {
  2932. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  2933. int ret;
  2934. ret = gpiochip_remove(&wm8962->gpio_chip);
  2935. if (ret != 0)
  2936. dev_err(codec->dev, "Failed to remove GPIOs: %d\n", ret);
  2937. }
  2938. #else
  2939. static void wm8962_init_gpio(struct snd_soc_codec *codec)
  2940. {
  2941. }
  2942. static void wm8962_free_gpio(struct snd_soc_codec *codec)
  2943. {
  2944. }
  2945. #endif
  2946. static int wm8962_probe(struct snd_soc_codec *codec)
  2947. {
  2948. int ret;
  2949. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  2950. struct wm8962_pdata *pdata = dev_get_platdata(codec->dev);
  2951. int i, trigger, irq_pol;
  2952. bool dmicclk, dmicdat;
  2953. wm8962->codec = codec;
  2954. codec->control_data = wm8962->regmap;
  2955. ret = snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP);
  2956. if (ret != 0) {
  2957. dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
  2958. return ret;
  2959. }
  2960. wm8962->disable_nb[0].notifier_call = wm8962_regulator_event_0;
  2961. wm8962->disable_nb[1].notifier_call = wm8962_regulator_event_1;
  2962. wm8962->disable_nb[2].notifier_call = wm8962_regulator_event_2;
  2963. wm8962->disable_nb[3].notifier_call = wm8962_regulator_event_3;
  2964. wm8962->disable_nb[4].notifier_call = wm8962_regulator_event_4;
  2965. wm8962->disable_nb[5].notifier_call = wm8962_regulator_event_5;
  2966. wm8962->disable_nb[6].notifier_call = wm8962_regulator_event_6;
  2967. wm8962->disable_nb[7].notifier_call = wm8962_regulator_event_7;
  2968. /* This should really be moved into the regulator core */
  2969. for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) {
  2970. ret = regulator_register_notifier(wm8962->supplies[i].consumer,
  2971. &wm8962->disable_nb[i]);
  2972. if (ret != 0) {
  2973. dev_err(codec->dev,
  2974. "Failed to register regulator notifier: %d\n",
  2975. ret);
  2976. }
  2977. }
  2978. /* SYSCLK defaults to on; make sure it is off so we can safely
  2979. * write to registers if the device is declocked.
  2980. */
  2981. snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_ENA, 0);
  2982. /* Ensure we have soft control over all registers */
  2983. snd_soc_update_bits(codec, WM8962_CLOCKING2,
  2984. WM8962_CLKREG_OVD, WM8962_CLKREG_OVD);
  2985. /* Ensure that the oscillator and PLLs are disabled */
  2986. snd_soc_update_bits(codec, WM8962_PLL2,
  2987. WM8962_OSC_ENA | WM8962_PLL2_ENA | WM8962_PLL3_ENA,
  2988. 0);
  2989. if (pdata) {
  2990. /* Apply static configuration for GPIOs */
  2991. for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++)
  2992. if (pdata->gpio_init[i]) {
  2993. wm8962_set_gpio_mode(codec, i + 1);
  2994. snd_soc_write(codec, 0x200 + i,
  2995. pdata->gpio_init[i] & 0xffff);
  2996. }
  2997. /* Put the speakers into mono mode? */
  2998. if (pdata->spk_mono)
  2999. snd_soc_update_bits(codec, WM8962_CLASS_D_CONTROL_2,
  3000. WM8962_SPK_MONO_MASK, WM8962_SPK_MONO);
  3001. /* Micbias setup, detection enable and detection
  3002. * threasholds. */
  3003. if (pdata->mic_cfg)
  3004. snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_4,
  3005. WM8962_MICDET_ENA |
  3006. WM8962_MICDET_THR_MASK |
  3007. WM8962_MICSHORT_THR_MASK |
  3008. WM8962_MICBIAS_LVL,
  3009. pdata->mic_cfg);
  3010. }
  3011. /* Latch volume update bits */
  3012. snd_soc_update_bits(codec, WM8962_LEFT_INPUT_VOLUME,
  3013. WM8962_IN_VU, WM8962_IN_VU);
  3014. snd_soc_update_bits(codec, WM8962_RIGHT_INPUT_VOLUME,
  3015. WM8962_IN_VU, WM8962_IN_VU);
  3016. snd_soc_update_bits(codec, WM8962_LEFT_ADC_VOLUME,
  3017. WM8962_ADC_VU, WM8962_ADC_VU);
  3018. snd_soc_update_bits(codec, WM8962_RIGHT_ADC_VOLUME,
  3019. WM8962_ADC_VU, WM8962_ADC_VU);
  3020. snd_soc_update_bits(codec, WM8962_LEFT_DAC_VOLUME,
  3021. WM8962_DAC_VU, WM8962_DAC_VU);
  3022. snd_soc_update_bits(codec, WM8962_RIGHT_DAC_VOLUME,
  3023. WM8962_DAC_VU, WM8962_DAC_VU);
  3024. snd_soc_update_bits(codec, WM8962_SPKOUTL_VOLUME,
  3025. WM8962_SPKOUT_VU, WM8962_SPKOUT_VU);
  3026. snd_soc_update_bits(codec, WM8962_SPKOUTR_VOLUME,
  3027. WM8962_SPKOUT_VU, WM8962_SPKOUT_VU);
  3028. snd_soc_update_bits(codec, WM8962_HPOUTL_VOLUME,
  3029. WM8962_HPOUT_VU, WM8962_HPOUT_VU);
  3030. snd_soc_update_bits(codec, WM8962_HPOUTR_VOLUME,
  3031. WM8962_HPOUT_VU, WM8962_HPOUT_VU);
  3032. /* Stereo control for EQ */
  3033. snd_soc_update_bits(codec, WM8962_EQ1, WM8962_EQ_SHARED_COEFF, 0);
  3034. /* Don't debouce interrupts so we don't need SYSCLK */
  3035. snd_soc_update_bits(codec, WM8962_IRQ_DEBOUNCE,
  3036. WM8962_FLL_LOCK_DB | WM8962_PLL3_LOCK_DB |
  3037. WM8962_PLL2_LOCK_DB | WM8962_TEMP_SHUT_DB,
  3038. 0);
  3039. wm8962_add_widgets(codec);
  3040. /* Save boards having to disable DMIC when not in use */
  3041. dmicclk = false;
  3042. dmicdat = false;
  3043. for (i = 0; i < WM8962_MAX_GPIO; i++) {
  3044. switch (snd_soc_read(codec, WM8962_GPIO_BASE + i)
  3045. & WM8962_GP2_FN_MASK) {
  3046. case WM8962_GPIO_FN_DMICCLK:
  3047. dmicclk = true;
  3048. break;
  3049. case WM8962_GPIO_FN_DMICDAT:
  3050. dmicdat = true;
  3051. break;
  3052. default:
  3053. break;
  3054. }
  3055. }
  3056. if (!dmicclk || !dmicdat) {
  3057. dev_dbg(codec->dev, "DMIC not in use, disabling\n");
  3058. snd_soc_dapm_nc_pin(&codec->dapm, "DMICDAT");
  3059. }
  3060. if (dmicclk != dmicdat)
  3061. dev_warn(codec->dev, "DMIC GPIOs partially configured\n");
  3062. wm8962_init_beep(codec);
  3063. wm8962_init_gpio(codec);
  3064. if (wm8962->irq) {
  3065. if (pdata && pdata->irq_active_low) {
  3066. trigger = IRQF_TRIGGER_LOW;
  3067. irq_pol = WM8962_IRQ_POL;
  3068. } else {
  3069. trigger = IRQF_TRIGGER_HIGH;
  3070. irq_pol = 0;
  3071. }
  3072. snd_soc_update_bits(codec, WM8962_INTERRUPT_CONTROL,
  3073. WM8962_IRQ_POL, irq_pol);
  3074. ret = request_threaded_irq(wm8962->irq, NULL, wm8962_irq,
  3075. trigger | IRQF_ONESHOT,
  3076. "wm8962", codec->dev);
  3077. if (ret != 0) {
  3078. dev_err(codec->dev, "Failed to request IRQ %d: %d\n",
  3079. wm8962->irq, ret);
  3080. wm8962->irq = 0;
  3081. /* Non-fatal */
  3082. } else {
  3083. /* Enable some IRQs by default */
  3084. snd_soc_update_bits(codec,
  3085. WM8962_INTERRUPT_STATUS_2_MASK,
  3086. WM8962_FLL_LOCK_EINT |
  3087. WM8962_TEMP_SHUT_EINT |
  3088. WM8962_FIFOS_ERR_EINT, 0);
  3089. }
  3090. }
  3091. return 0;
  3092. }
  3093. static int wm8962_remove(struct snd_soc_codec *codec)
  3094. {
  3095. struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
  3096. int i;
  3097. if (wm8962->irq)
  3098. free_irq(wm8962->irq, codec);
  3099. cancel_delayed_work_sync(&wm8962->mic_work);
  3100. wm8962_free_gpio(codec);
  3101. wm8962_free_beep(codec);
  3102. for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++)
  3103. regulator_unregister_notifier(wm8962->supplies[i].consumer,
  3104. &wm8962->disable_nb[i]);
  3105. return 0;
  3106. }
  3107. static struct snd_soc_codec_driver soc_codec_dev_wm8962 = {
  3108. .probe = wm8962_probe,
  3109. .remove = wm8962_remove,
  3110. .set_bias_level = wm8962_set_bias_level,
  3111. .set_pll = wm8962_set_fll,
  3112. .idle_bias_off = true,
  3113. };
  3114. /* Improve power consumption for IN4 DC measurement mode */
  3115. static const struct reg_default wm8962_dc_measure[] = {
  3116. { 0xfd, 0x1 },
  3117. { 0xcc, 0x40 },
  3118. { 0xfd, 0 },
  3119. };
  3120. static const struct regmap_config wm8962_regmap = {
  3121. .reg_bits = 16,
  3122. .val_bits = 16,
  3123. .max_register = WM8962_MAX_REGISTER,
  3124. .reg_defaults = wm8962_reg,
  3125. .num_reg_defaults = ARRAY_SIZE(wm8962_reg),
  3126. .volatile_reg = wm8962_volatile_register,
  3127. .readable_reg = wm8962_readable_register,
  3128. .cache_type = REGCACHE_RBTREE,
  3129. };
  3130. static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,
  3131. const struct i2c_device_id *id)
  3132. {
  3133. struct wm8962_pdata *pdata = dev_get_platdata(&i2c->dev);
  3134. struct wm8962_priv *wm8962;
  3135. unsigned int reg;
  3136. int ret, i;
  3137. wm8962 = devm_kzalloc(&i2c->dev, sizeof(struct wm8962_priv),
  3138. GFP_KERNEL);
  3139. if (wm8962 == NULL)
  3140. return -ENOMEM;
  3141. i2c_set_clientdata(i2c, wm8962);
  3142. INIT_DELAYED_WORK(&wm8962->mic_work, wm8962_mic_work);
  3143. init_completion(&wm8962->fll_lock);
  3144. wm8962->irq = i2c->irq;
  3145. for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++)
  3146. wm8962->supplies[i].supply = wm8962_supply_names[i];
  3147. ret = regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8962->supplies),
  3148. wm8962->supplies);
  3149. if (ret != 0) {
  3150. dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
  3151. goto err;
  3152. }
  3153. ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies),
  3154. wm8962->supplies);
  3155. if (ret != 0) {
  3156. dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
  3157. goto err_get;
  3158. }
  3159. wm8962->regmap = regmap_init_i2c(i2c, &wm8962_regmap);
  3160. if (IS_ERR(wm8962->regmap)) {
  3161. ret = PTR_ERR(wm8962->regmap);
  3162. dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
  3163. goto err_enable;
  3164. }
  3165. /*
  3166. * We haven't marked the chip revision as volatile due to
  3167. * sharing a register with the right input volume; explicitly
  3168. * bypass the cache to read it.
  3169. */
  3170. regcache_cache_bypass(wm8962->regmap, true);
  3171. ret = regmap_read(wm8962->regmap, WM8962_SOFTWARE_RESET, &reg);
  3172. if (ret < 0) {
  3173. dev_err(&i2c->dev, "Failed to read ID register\n");
  3174. goto err_regmap;
  3175. }
  3176. if (reg != 0x6243) {
  3177. dev_err(&i2c->dev,
  3178. "Device is not a WM8962, ID %x != 0x6243\n", reg);
  3179. ret = -EINVAL;
  3180. goto err_regmap;
  3181. }
  3182. ret = regmap_read(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME, &reg);
  3183. if (ret < 0) {
  3184. dev_err(&i2c->dev, "Failed to read device revision: %d\n",
  3185. ret);
  3186. goto err_regmap;
  3187. }
  3188. dev_info(&i2c->dev, "customer id %x revision %c\n",
  3189. (reg & WM8962_CUST_ID_MASK) >> WM8962_CUST_ID_SHIFT,
  3190. ((reg & WM8962_CHIP_REV_MASK) >> WM8962_CHIP_REV_SHIFT)
  3191. + 'A');
  3192. regcache_cache_bypass(wm8962->regmap, false);
  3193. ret = wm8962_reset(wm8962);
  3194. if (ret < 0) {
  3195. dev_err(&i2c->dev, "Failed to issue reset\n");
  3196. goto err_regmap;
  3197. }
  3198. if (pdata && pdata->in4_dc_measure) {
  3199. ret = regmap_register_patch(wm8962->regmap,
  3200. wm8962_dc_measure,
  3201. ARRAY_SIZE(wm8962_dc_measure));
  3202. if (ret != 0)
  3203. dev_err(&i2c->dev,
  3204. "Failed to configure for DC mesurement: %d\n",
  3205. ret);
  3206. }
  3207. pm_runtime_enable(&i2c->dev);
  3208. pm_request_idle(&i2c->dev);
  3209. ret = snd_soc_register_codec(&i2c->dev,
  3210. &soc_codec_dev_wm8962, &wm8962_dai, 1);
  3211. if (ret < 0)
  3212. goto err_regmap;
  3213. regcache_cache_only(wm8962->regmap, true);
  3214. /* The drivers should power up as needed */
  3215. regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
  3216. return 0;
  3217. err_regmap:
  3218. regmap_exit(wm8962->regmap);
  3219. err_enable:
  3220. regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
  3221. err_get:
  3222. regulator_bulk_free(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
  3223. err:
  3224. return ret;
  3225. }
  3226. static __devexit int wm8962_i2c_remove(struct i2c_client *client)
  3227. {
  3228. struct wm8962_priv *wm8962 = dev_get_drvdata(&client->dev);
  3229. snd_soc_unregister_codec(&client->dev);
  3230. regmap_exit(wm8962->regmap);
  3231. regulator_bulk_free(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
  3232. return 0;
  3233. }
  3234. #ifdef CONFIG_PM_RUNTIME
  3235. static int wm8962_runtime_resume(struct device *dev)
  3236. {
  3237. struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
  3238. int ret;
  3239. ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies),
  3240. wm8962->supplies);
  3241. if (ret != 0) {
  3242. dev_err(dev,
  3243. "Failed to enable supplies: %d\n", ret);
  3244. return ret;
  3245. }
  3246. regcache_cache_only(wm8962->regmap, false);
  3247. wm8962_reset(wm8962);
  3248. regcache_sync(wm8962->regmap);
  3249. regmap_update_bits(wm8962->regmap, WM8962_ANTI_POP,
  3250. WM8962_STARTUP_BIAS_ENA | WM8962_VMID_BUF_ENA,
  3251. WM8962_STARTUP_BIAS_ENA | WM8962_VMID_BUF_ENA);
  3252. /* Bias enable at 2*50k for ramp */
  3253. regmap_update_bits(wm8962->regmap, WM8962_PWR_MGMT_1,
  3254. WM8962_VMID_SEL_MASK | WM8962_BIAS_ENA,
  3255. WM8962_BIAS_ENA | 0x180);
  3256. msleep(5);
  3257. /* VMID back to 2x250k for standby */
  3258. regmap_update_bits(wm8962->regmap, WM8962_PWR_MGMT_1,
  3259. WM8962_VMID_SEL_MASK, 0x100);
  3260. return 0;
  3261. }
  3262. static int wm8962_runtime_suspend(struct device *dev)
  3263. {
  3264. struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
  3265. regmap_update_bits(wm8962->regmap, WM8962_PWR_MGMT_1,
  3266. WM8962_VMID_SEL_MASK | WM8962_BIAS_ENA, 0);
  3267. regmap_update_bits(wm8962->regmap, WM8962_ANTI_POP,
  3268. WM8962_STARTUP_BIAS_ENA |
  3269. WM8962_VMID_BUF_ENA, 0);
  3270. regcache_cache_only(wm8962->regmap, true);
  3271. regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies),
  3272. wm8962->supplies);
  3273. return 0;
  3274. }
  3275. #endif
  3276. static struct dev_pm_ops wm8962_pm = {
  3277. SET_RUNTIME_PM_OPS(wm8962_runtime_suspend, wm8962_runtime_resume, NULL)
  3278. };
  3279. static const struct i2c_device_id wm8962_i2c_id[] = {
  3280. { "wm8962", 0 },
  3281. { }
  3282. };
  3283. MODULE_DEVICE_TABLE(i2c, wm8962_i2c_id);
  3284. static struct i2c_driver wm8962_i2c_driver = {
  3285. .driver = {
  3286. .name = "wm8962",
  3287. .owner = THIS_MODULE,
  3288. .pm = &wm8962_pm,
  3289. },
  3290. .probe = wm8962_i2c_probe,
  3291. .remove = __devexit_p(wm8962_i2c_remove),
  3292. .id_table = wm8962_i2c_id,
  3293. };
  3294. module_i2c_driver(wm8962_i2c_driver);
  3295. MODULE_DESCRIPTION("ASoC WM8962 driver");
  3296. MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
  3297. MODULE_LICENSE("GPL");