wm8962.c 116 KB

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