wm8960.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. /*
  2. * wm8960.c -- WM8960 ALSA SoC Audio driver
  3. *
  4. * Author: Liam Girdwood
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/moduleparam.h>
  12. #include <linux/init.h>
  13. #include <linux/delay.h>
  14. #include <linux/pm.h>
  15. #include <linux/i2c.h>
  16. #include <linux/slab.h>
  17. #include <sound/core.h>
  18. #include <sound/pcm.h>
  19. #include <sound/pcm_params.h>
  20. #include <sound/soc.h>
  21. #include <sound/initval.h>
  22. #include <sound/tlv.h>
  23. #include <sound/wm8960.h>
  24. #include "wm8960.h"
  25. /* R25 - Power 1 */
  26. #define WM8960_VMID_MASK 0x180
  27. #define WM8960_VREF 0x40
  28. /* R26 - Power 2 */
  29. #define WM8960_PWR2_LOUT1 0x40
  30. #define WM8960_PWR2_ROUT1 0x20
  31. #define WM8960_PWR2_OUT3 0x02
  32. /* R28 - Anti-pop 1 */
  33. #define WM8960_POBCTRL 0x80
  34. #define WM8960_BUFDCOPEN 0x10
  35. #define WM8960_BUFIOEN 0x08
  36. #define WM8960_SOFT_ST 0x04
  37. #define WM8960_HPSTBY 0x01
  38. /* R29 - Anti-pop 2 */
  39. #define WM8960_DISOP 0x40
  40. #define WM8960_DRES_MASK 0x30
  41. /*
  42. * wm8960 register cache
  43. * We can't read the WM8960 register space when we are
  44. * using 2 wire for device control, so we cache them instead.
  45. */
  46. static const u16 wm8960_reg[WM8960_CACHEREGNUM] = {
  47. 0x0097, 0x0097, 0x0000, 0x0000,
  48. 0x0000, 0x0008, 0x0000, 0x000a,
  49. 0x01c0, 0x0000, 0x00ff, 0x00ff,
  50. 0x0000, 0x0000, 0x0000, 0x0000,
  51. 0x0000, 0x007b, 0x0100, 0x0032,
  52. 0x0000, 0x00c3, 0x00c3, 0x01c0,
  53. 0x0000, 0x0000, 0x0000, 0x0000,
  54. 0x0000, 0x0000, 0x0000, 0x0000,
  55. 0x0100, 0x0100, 0x0050, 0x0050,
  56. 0x0050, 0x0050, 0x0000, 0x0000,
  57. 0x0000, 0x0000, 0x0040, 0x0000,
  58. 0x0000, 0x0050, 0x0050, 0x0000,
  59. 0x0002, 0x0037, 0x004d, 0x0080,
  60. 0x0008, 0x0031, 0x0026, 0x00e9,
  61. };
  62. struct wm8960_priv {
  63. enum snd_soc_control_type control_type;
  64. int (*set_bias_level)(struct snd_soc_codec *,
  65. enum snd_soc_bias_level level);
  66. struct snd_soc_dapm_widget *lout1;
  67. struct snd_soc_dapm_widget *rout1;
  68. struct snd_soc_dapm_widget *out3;
  69. bool deemph;
  70. int playback_fs;
  71. };
  72. #define wm8960_reset(c) snd_soc_write(c, WM8960_RESET, 0)
  73. /* enumerated controls */
  74. static const char *wm8960_polarity[] = {"No Inversion", "Left Inverted",
  75. "Right Inverted", "Stereo Inversion"};
  76. static const char *wm8960_3d_upper_cutoff[] = {"High", "Low"};
  77. static const char *wm8960_3d_lower_cutoff[] = {"Low", "High"};
  78. static const char *wm8960_alcfunc[] = {"Off", "Right", "Left", "Stereo"};
  79. static const char *wm8960_alcmode[] = {"ALC", "Limiter"};
  80. static const struct soc_enum wm8960_enum[] = {
  81. SOC_ENUM_SINGLE(WM8960_DACCTL1, 5, 4, wm8960_polarity),
  82. SOC_ENUM_SINGLE(WM8960_DACCTL2, 5, 4, wm8960_polarity),
  83. SOC_ENUM_SINGLE(WM8960_3D, 6, 2, wm8960_3d_upper_cutoff),
  84. SOC_ENUM_SINGLE(WM8960_3D, 5, 2, wm8960_3d_lower_cutoff),
  85. SOC_ENUM_SINGLE(WM8960_ALC1, 7, 4, wm8960_alcfunc),
  86. SOC_ENUM_SINGLE(WM8960_ALC3, 8, 2, wm8960_alcmode),
  87. };
  88. static const int deemph_settings[] = { 0, 32000, 44100, 48000 };
  89. static int wm8960_set_deemph(struct snd_soc_codec *codec)
  90. {
  91. struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
  92. int val, i, best;
  93. /* If we're using deemphasis select the nearest available sample
  94. * rate.
  95. */
  96. if (wm8960->deemph) {
  97. best = 1;
  98. for (i = 2; i < ARRAY_SIZE(deemph_settings); i++) {
  99. if (abs(deemph_settings[i] - wm8960->playback_fs) <
  100. abs(deemph_settings[best] - wm8960->playback_fs))
  101. best = i;
  102. }
  103. val = best << 1;
  104. } else {
  105. val = 0;
  106. }
  107. dev_dbg(codec->dev, "Set deemphasis %d\n", val);
  108. return snd_soc_update_bits(codec, WM8960_DACCTL1,
  109. 0x6, val);
  110. }
  111. static int wm8960_get_deemph(struct snd_kcontrol *kcontrol,
  112. struct snd_ctl_elem_value *ucontrol)
  113. {
  114. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  115. struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
  116. ucontrol->value.enumerated.item[0] = wm8960->deemph;
  117. return 0;
  118. }
  119. static int wm8960_put_deemph(struct snd_kcontrol *kcontrol,
  120. struct snd_ctl_elem_value *ucontrol)
  121. {
  122. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  123. struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
  124. int deemph = ucontrol->value.enumerated.item[0];
  125. if (deemph > 1)
  126. return -EINVAL;
  127. wm8960->deemph = deemph;
  128. return wm8960_set_deemph(codec);
  129. }
  130. static const DECLARE_TLV_DB_SCALE(adc_tlv, -9700, 50, 0);
  131. static const DECLARE_TLV_DB_SCALE(dac_tlv, -12700, 50, 1);
  132. static const DECLARE_TLV_DB_SCALE(bypass_tlv, -2100, 300, 0);
  133. static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
  134. static const struct snd_kcontrol_new wm8960_snd_controls[] = {
  135. SOC_DOUBLE_R_TLV("Capture Volume", WM8960_LINVOL, WM8960_RINVOL,
  136. 0, 63, 0, adc_tlv),
  137. SOC_DOUBLE_R("Capture Volume ZC Switch", WM8960_LINVOL, WM8960_RINVOL,
  138. 6, 1, 0),
  139. SOC_DOUBLE_R("Capture Switch", WM8960_LINVOL, WM8960_RINVOL,
  140. 7, 1, 0),
  141. SOC_DOUBLE_R_TLV("Playback Volume", WM8960_LDAC, WM8960_RDAC,
  142. 0, 255, 0, dac_tlv),
  143. SOC_DOUBLE_R_TLV("Headphone Playback Volume", WM8960_LOUT1, WM8960_ROUT1,
  144. 0, 127, 0, out_tlv),
  145. SOC_DOUBLE_R("Headphone Playback ZC Switch", WM8960_LOUT1, WM8960_ROUT1,
  146. 7, 1, 0),
  147. SOC_DOUBLE_R_TLV("Speaker Playback Volume", WM8960_LOUT2, WM8960_ROUT2,
  148. 0, 127, 0, out_tlv),
  149. SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8960_LOUT2, WM8960_ROUT2,
  150. 7, 1, 0),
  151. SOC_SINGLE("Speaker DC Volume", WM8960_CLASSD3, 3, 5, 0),
  152. SOC_SINGLE("Speaker AC Volume", WM8960_CLASSD3, 0, 5, 0),
  153. SOC_SINGLE("PCM Playback -6dB Switch", WM8960_DACCTL1, 7, 1, 0),
  154. SOC_ENUM("ADC Polarity", wm8960_enum[0]),
  155. SOC_SINGLE("ADC High Pass Filter Switch", WM8960_DACCTL1, 0, 1, 0),
  156. SOC_ENUM("DAC Polarity", wm8960_enum[2]),
  157. SOC_SINGLE_BOOL_EXT("DAC Deemphasis Switch", 0,
  158. wm8960_get_deemph, wm8960_put_deemph),
  159. SOC_ENUM("3D Filter Upper Cut-Off", wm8960_enum[2]),
  160. SOC_ENUM("3D Filter Lower Cut-Off", wm8960_enum[3]),
  161. SOC_SINGLE("3D Volume", WM8960_3D, 1, 15, 0),
  162. SOC_SINGLE("3D Switch", WM8960_3D, 0, 1, 0),
  163. SOC_ENUM("ALC Function", wm8960_enum[4]),
  164. SOC_SINGLE("ALC Max Gain", WM8960_ALC1, 4, 7, 0),
  165. SOC_SINGLE("ALC Target", WM8960_ALC1, 0, 15, 1),
  166. SOC_SINGLE("ALC Min Gain", WM8960_ALC2, 4, 7, 0),
  167. SOC_SINGLE("ALC Hold Time", WM8960_ALC2, 0, 15, 0),
  168. SOC_ENUM("ALC Mode", wm8960_enum[5]),
  169. SOC_SINGLE("ALC Decay", WM8960_ALC3, 4, 15, 0),
  170. SOC_SINGLE("ALC Attack", WM8960_ALC3, 0, 15, 0),
  171. SOC_SINGLE("Noise Gate Threshold", WM8960_NOISEG, 3, 31, 0),
  172. SOC_SINGLE("Noise Gate Switch", WM8960_NOISEG, 0, 1, 0),
  173. SOC_DOUBLE_R("ADC PCM Capture Volume", WM8960_LINPATH, WM8960_RINPATH,
  174. 0, 127, 0),
  175. SOC_SINGLE_TLV("Left Output Mixer Boost Bypass Volume",
  176. WM8960_BYPASS1, 4, 7, 1, bypass_tlv),
  177. SOC_SINGLE_TLV("Left Output Mixer LINPUT3 Volume",
  178. WM8960_LOUTMIX, 4, 7, 1, bypass_tlv),
  179. SOC_SINGLE_TLV("Right Output Mixer Boost Bypass Volume",
  180. WM8960_BYPASS2, 4, 7, 1, bypass_tlv),
  181. SOC_SINGLE_TLV("Right Output Mixer RINPUT3 Volume",
  182. WM8960_ROUTMIX, 4, 7, 1, bypass_tlv),
  183. };
  184. static const struct snd_kcontrol_new wm8960_lin_boost[] = {
  185. SOC_DAPM_SINGLE("LINPUT2 Switch", WM8960_LINPATH, 6, 1, 0),
  186. SOC_DAPM_SINGLE("LINPUT3 Switch", WM8960_LINPATH, 7, 1, 0),
  187. SOC_DAPM_SINGLE("LINPUT1 Switch", WM8960_LINPATH, 8, 1, 0),
  188. };
  189. static const struct snd_kcontrol_new wm8960_lin[] = {
  190. SOC_DAPM_SINGLE("Boost Switch", WM8960_LINPATH, 3, 1, 0),
  191. };
  192. static const struct snd_kcontrol_new wm8960_rin_boost[] = {
  193. SOC_DAPM_SINGLE("RINPUT2 Switch", WM8960_RINPATH, 6, 1, 0),
  194. SOC_DAPM_SINGLE("RINPUT3 Switch", WM8960_RINPATH, 7, 1, 0),
  195. SOC_DAPM_SINGLE("RINPUT1 Switch", WM8960_RINPATH, 8, 1, 0),
  196. };
  197. static const struct snd_kcontrol_new wm8960_rin[] = {
  198. SOC_DAPM_SINGLE("Boost Switch", WM8960_RINPATH, 3, 1, 0),
  199. };
  200. static const struct snd_kcontrol_new wm8960_loutput_mixer[] = {
  201. SOC_DAPM_SINGLE("PCM Playback Switch", WM8960_LOUTMIX, 8, 1, 0),
  202. SOC_DAPM_SINGLE("LINPUT3 Switch", WM8960_LOUTMIX, 7, 1, 0),
  203. SOC_DAPM_SINGLE("Boost Bypass Switch", WM8960_BYPASS1, 7, 1, 0),
  204. };
  205. static const struct snd_kcontrol_new wm8960_routput_mixer[] = {
  206. SOC_DAPM_SINGLE("PCM Playback Switch", WM8960_ROUTMIX, 8, 1, 0),
  207. SOC_DAPM_SINGLE("RINPUT3 Switch", WM8960_ROUTMIX, 7, 1, 0),
  208. SOC_DAPM_SINGLE("Boost Bypass Switch", WM8960_BYPASS2, 7, 1, 0),
  209. };
  210. static const struct snd_kcontrol_new wm8960_mono_out[] = {
  211. SOC_DAPM_SINGLE("Left Switch", WM8960_MONOMIX1, 7, 1, 0),
  212. SOC_DAPM_SINGLE("Right Switch", WM8960_MONOMIX2, 7, 1, 0),
  213. };
  214. static const struct snd_soc_dapm_widget wm8960_dapm_widgets[] = {
  215. SND_SOC_DAPM_INPUT("LINPUT1"),
  216. SND_SOC_DAPM_INPUT("RINPUT1"),
  217. SND_SOC_DAPM_INPUT("LINPUT2"),
  218. SND_SOC_DAPM_INPUT("RINPUT2"),
  219. SND_SOC_DAPM_INPUT("LINPUT3"),
  220. SND_SOC_DAPM_INPUT("RINPUT3"),
  221. SND_SOC_DAPM_SUPPLY("MICB", WM8960_POWER1, 1, 0, NULL, 0),
  222. SND_SOC_DAPM_MIXER("Left Boost Mixer", WM8960_POWER1, 5, 0,
  223. wm8960_lin_boost, ARRAY_SIZE(wm8960_lin_boost)),
  224. SND_SOC_DAPM_MIXER("Right Boost Mixer", WM8960_POWER1, 4, 0,
  225. wm8960_rin_boost, ARRAY_SIZE(wm8960_rin_boost)),
  226. SND_SOC_DAPM_MIXER("Left Input Mixer", WM8960_POWER3, 5, 0,
  227. wm8960_lin, ARRAY_SIZE(wm8960_lin)),
  228. SND_SOC_DAPM_MIXER("Right Input Mixer", WM8960_POWER3, 4, 0,
  229. wm8960_rin, ARRAY_SIZE(wm8960_rin)),
  230. SND_SOC_DAPM_ADC("Left ADC", "Capture", WM8960_POWER2, 3, 0),
  231. SND_SOC_DAPM_ADC("Right ADC", "Capture", WM8960_POWER2, 2, 0),
  232. SND_SOC_DAPM_DAC("Left DAC", "Playback", WM8960_POWER2, 8, 0),
  233. SND_SOC_DAPM_DAC("Right DAC", "Playback", WM8960_POWER2, 7, 0),
  234. SND_SOC_DAPM_MIXER("Left Output Mixer", WM8960_POWER3, 3, 0,
  235. &wm8960_loutput_mixer[0],
  236. ARRAY_SIZE(wm8960_loutput_mixer)),
  237. SND_SOC_DAPM_MIXER("Right Output Mixer", WM8960_POWER3, 2, 0,
  238. &wm8960_routput_mixer[0],
  239. ARRAY_SIZE(wm8960_routput_mixer)),
  240. SND_SOC_DAPM_PGA("LOUT1 PGA", WM8960_POWER2, 6, 0, NULL, 0),
  241. SND_SOC_DAPM_PGA("ROUT1 PGA", WM8960_POWER2, 5, 0, NULL, 0),
  242. SND_SOC_DAPM_PGA("Left Speaker PGA", WM8960_POWER2, 4, 0, NULL, 0),
  243. SND_SOC_DAPM_PGA("Right Speaker PGA", WM8960_POWER2, 3, 0, NULL, 0),
  244. SND_SOC_DAPM_PGA("Right Speaker Output", WM8960_CLASSD1, 7, 0, NULL, 0),
  245. SND_SOC_DAPM_PGA("Left Speaker Output", WM8960_CLASSD1, 6, 0, NULL, 0),
  246. SND_SOC_DAPM_OUTPUT("SPK_LP"),
  247. SND_SOC_DAPM_OUTPUT("SPK_LN"),
  248. SND_SOC_DAPM_OUTPUT("HP_L"),
  249. SND_SOC_DAPM_OUTPUT("HP_R"),
  250. SND_SOC_DAPM_OUTPUT("SPK_RP"),
  251. SND_SOC_DAPM_OUTPUT("SPK_RN"),
  252. SND_SOC_DAPM_OUTPUT("OUT3"),
  253. };
  254. static const struct snd_soc_dapm_widget wm8960_dapm_widgets_out3[] = {
  255. SND_SOC_DAPM_MIXER("Mono Output Mixer", WM8960_POWER2, 1, 0,
  256. &wm8960_mono_out[0],
  257. ARRAY_SIZE(wm8960_mono_out)),
  258. };
  259. /* Represent OUT3 as a PGA so that it gets turned on with LOUT1/ROUT1 */
  260. static const struct snd_soc_dapm_widget wm8960_dapm_widgets_capless[] = {
  261. SND_SOC_DAPM_PGA("OUT3 VMID", WM8960_POWER2, 1, 0, NULL, 0),
  262. };
  263. static const struct snd_soc_dapm_route audio_paths[] = {
  264. { "Left Boost Mixer", "LINPUT1 Switch", "LINPUT1" },
  265. { "Left Boost Mixer", "LINPUT2 Switch", "LINPUT2" },
  266. { "Left Boost Mixer", "LINPUT3 Switch", "LINPUT3" },
  267. { "Left Input Mixer", "Boost Switch", "Left Boost Mixer", },
  268. { "Left Input Mixer", NULL, "LINPUT1", }, /* Really Boost Switch */
  269. { "Left Input Mixer", NULL, "LINPUT2" },
  270. { "Left Input Mixer", NULL, "LINPUT3" },
  271. { "Right Boost Mixer", "RINPUT1 Switch", "RINPUT1" },
  272. { "Right Boost Mixer", "RINPUT2 Switch", "RINPUT2" },
  273. { "Right Boost Mixer", "RINPUT3 Switch", "RINPUT3" },
  274. { "Right Input Mixer", "Boost Switch", "Right Boost Mixer", },
  275. { "Right Input Mixer", NULL, "RINPUT1", }, /* Really Boost Switch */
  276. { "Right Input Mixer", NULL, "RINPUT2" },
  277. { "Right Input Mixer", NULL, "LINPUT3" },
  278. { "Left ADC", NULL, "Left Input Mixer" },
  279. { "Right ADC", NULL, "Right Input Mixer" },
  280. { "Left Output Mixer", "LINPUT3 Switch", "LINPUT3" },
  281. { "Left Output Mixer", "Boost Bypass Switch", "Left Boost Mixer"} ,
  282. { "Left Output Mixer", "PCM Playback Switch", "Left DAC" },
  283. { "Right Output Mixer", "RINPUT3 Switch", "RINPUT3" },
  284. { "Right Output Mixer", "Boost Bypass Switch", "Right Boost Mixer" } ,
  285. { "Right Output Mixer", "PCM Playback Switch", "Right DAC" },
  286. { "LOUT1 PGA", NULL, "Left Output Mixer" },
  287. { "ROUT1 PGA", NULL, "Right Output Mixer" },
  288. { "HP_L", NULL, "LOUT1 PGA" },
  289. { "HP_R", NULL, "ROUT1 PGA" },
  290. { "Left Speaker PGA", NULL, "Left Output Mixer" },
  291. { "Right Speaker PGA", NULL, "Right Output Mixer" },
  292. { "Left Speaker Output", NULL, "Left Speaker PGA" },
  293. { "Right Speaker Output", NULL, "Right Speaker PGA" },
  294. { "SPK_LN", NULL, "Left Speaker Output" },
  295. { "SPK_LP", NULL, "Left Speaker Output" },
  296. { "SPK_RN", NULL, "Right Speaker Output" },
  297. { "SPK_RP", NULL, "Right Speaker Output" },
  298. };
  299. static const struct snd_soc_dapm_route audio_paths_out3[] = {
  300. { "Mono Output Mixer", "Left Switch", "Left Output Mixer" },
  301. { "Mono Output Mixer", "Right Switch", "Right Output Mixer" },
  302. { "OUT3", NULL, "Mono Output Mixer", }
  303. };
  304. static const struct snd_soc_dapm_route audio_paths_capless[] = {
  305. { "HP_L", NULL, "OUT3 VMID" },
  306. { "HP_R", NULL, "OUT3 VMID" },
  307. { "OUT3 VMID", NULL, "Left Output Mixer" },
  308. { "OUT3 VMID", NULL, "Right Output Mixer" },
  309. };
  310. static int wm8960_add_widgets(struct snd_soc_codec *codec)
  311. {
  312. struct wm8960_data *pdata = codec->dev->platform_data;
  313. struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
  314. struct snd_soc_dapm_context *dapm = &codec->dapm;
  315. struct snd_soc_dapm_widget *w;
  316. snd_soc_dapm_new_controls(dapm, wm8960_dapm_widgets,
  317. ARRAY_SIZE(wm8960_dapm_widgets));
  318. snd_soc_dapm_add_routes(dapm, audio_paths, ARRAY_SIZE(audio_paths));
  319. /* In capless mode OUT3 is used to provide VMID for the
  320. * headphone outputs, otherwise it is used as a mono mixer.
  321. */
  322. if (pdata && pdata->capless) {
  323. snd_soc_dapm_new_controls(dapm, wm8960_dapm_widgets_capless,
  324. ARRAY_SIZE(wm8960_dapm_widgets_capless));
  325. snd_soc_dapm_add_routes(dapm, audio_paths_capless,
  326. ARRAY_SIZE(audio_paths_capless));
  327. } else {
  328. snd_soc_dapm_new_controls(dapm, wm8960_dapm_widgets_out3,
  329. ARRAY_SIZE(wm8960_dapm_widgets_out3));
  330. snd_soc_dapm_add_routes(dapm, audio_paths_out3,
  331. ARRAY_SIZE(audio_paths_out3));
  332. }
  333. /* We need to power up the headphone output stage out of
  334. * sequence for capless mode. To save scanning the widget
  335. * list each time to find the desired power state do so now
  336. * and save the result.
  337. */
  338. list_for_each_entry(w, &codec->card->widgets, list) {
  339. if (w->dapm != &codec->dapm)
  340. continue;
  341. if (strcmp(w->name, "LOUT1 PGA") == 0)
  342. wm8960->lout1 = w;
  343. if (strcmp(w->name, "ROUT1 PGA") == 0)
  344. wm8960->rout1 = w;
  345. if (strcmp(w->name, "OUT3 VMID") == 0)
  346. wm8960->out3 = w;
  347. }
  348. return 0;
  349. }
  350. static int wm8960_set_dai_fmt(struct snd_soc_dai *codec_dai,
  351. unsigned int fmt)
  352. {
  353. struct snd_soc_codec *codec = codec_dai->codec;
  354. u16 iface = 0;
  355. /* set master/slave audio interface */
  356. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  357. case SND_SOC_DAIFMT_CBM_CFM:
  358. iface |= 0x0040;
  359. break;
  360. case SND_SOC_DAIFMT_CBS_CFS:
  361. break;
  362. default:
  363. return -EINVAL;
  364. }
  365. /* interface format */
  366. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  367. case SND_SOC_DAIFMT_I2S:
  368. iface |= 0x0002;
  369. break;
  370. case SND_SOC_DAIFMT_RIGHT_J:
  371. break;
  372. case SND_SOC_DAIFMT_LEFT_J:
  373. iface |= 0x0001;
  374. break;
  375. case SND_SOC_DAIFMT_DSP_A:
  376. iface |= 0x0003;
  377. break;
  378. case SND_SOC_DAIFMT_DSP_B:
  379. iface |= 0x0013;
  380. break;
  381. default:
  382. return -EINVAL;
  383. }
  384. /* clock inversion */
  385. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  386. case SND_SOC_DAIFMT_NB_NF:
  387. break;
  388. case SND_SOC_DAIFMT_IB_IF:
  389. iface |= 0x0090;
  390. break;
  391. case SND_SOC_DAIFMT_IB_NF:
  392. iface |= 0x0080;
  393. break;
  394. case SND_SOC_DAIFMT_NB_IF:
  395. iface |= 0x0010;
  396. break;
  397. default:
  398. return -EINVAL;
  399. }
  400. /* set iface */
  401. snd_soc_write(codec, WM8960_IFACE1, iface);
  402. return 0;
  403. }
  404. static struct {
  405. int rate;
  406. unsigned int val;
  407. } alc_rates[] = {
  408. { 48000, 0 },
  409. { 44100, 0 },
  410. { 32000, 1 },
  411. { 22050, 2 },
  412. { 24000, 2 },
  413. { 16000, 3 },
  414. { 11250, 4 },
  415. { 12000, 4 },
  416. { 8000, 5 },
  417. };
  418. static int wm8960_hw_params(struct snd_pcm_substream *substream,
  419. struct snd_pcm_hw_params *params,
  420. struct snd_soc_dai *dai)
  421. {
  422. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  423. struct snd_soc_codec *codec = rtd->codec;
  424. struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
  425. u16 iface = snd_soc_read(codec, WM8960_IFACE1) & 0xfff3;
  426. int i;
  427. /* bit size */
  428. switch (params_format(params)) {
  429. case SNDRV_PCM_FORMAT_S16_LE:
  430. break;
  431. case SNDRV_PCM_FORMAT_S20_3LE:
  432. iface |= 0x0004;
  433. break;
  434. case SNDRV_PCM_FORMAT_S24_LE:
  435. iface |= 0x0008;
  436. break;
  437. }
  438. /* Update filters for the new rate */
  439. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  440. wm8960->playback_fs = params_rate(params);
  441. wm8960_set_deemph(codec);
  442. } else {
  443. for (i = 0; i < ARRAY_SIZE(alc_rates); i++)
  444. if (alc_rates[i].rate == params_rate(params))
  445. snd_soc_update_bits(codec,
  446. WM8960_ADDCTL3, 0x7,
  447. alc_rates[i].val);
  448. }
  449. /* set iface */
  450. snd_soc_write(codec, WM8960_IFACE1, iface);
  451. return 0;
  452. }
  453. static int wm8960_mute(struct snd_soc_dai *dai, int mute)
  454. {
  455. struct snd_soc_codec *codec = dai->codec;
  456. u16 mute_reg = snd_soc_read(codec, WM8960_DACCTL1) & 0xfff7;
  457. if (mute)
  458. snd_soc_write(codec, WM8960_DACCTL1, mute_reg | 0x8);
  459. else
  460. snd_soc_write(codec, WM8960_DACCTL1, mute_reg);
  461. return 0;
  462. }
  463. static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec,
  464. enum snd_soc_bias_level level)
  465. {
  466. u16 reg;
  467. switch (level) {
  468. case SND_SOC_BIAS_ON:
  469. break;
  470. case SND_SOC_BIAS_PREPARE:
  471. /* Set VMID to 2x50k */
  472. reg = snd_soc_read(codec, WM8960_POWER1);
  473. reg &= ~0x180;
  474. reg |= 0x80;
  475. snd_soc_write(codec, WM8960_POWER1, reg);
  476. break;
  477. case SND_SOC_BIAS_STANDBY:
  478. if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
  479. snd_soc_cache_sync(codec);
  480. /* Enable anti-pop features */
  481. snd_soc_write(codec, WM8960_APOP1,
  482. WM8960_POBCTRL | WM8960_SOFT_ST |
  483. WM8960_BUFDCOPEN | WM8960_BUFIOEN);
  484. /* Enable & ramp VMID at 2x50k */
  485. reg = snd_soc_read(codec, WM8960_POWER1);
  486. reg |= 0x80;
  487. snd_soc_write(codec, WM8960_POWER1, reg);
  488. msleep(100);
  489. /* Enable VREF */
  490. snd_soc_write(codec, WM8960_POWER1, reg | WM8960_VREF);
  491. /* Disable anti-pop features */
  492. snd_soc_write(codec, WM8960_APOP1, WM8960_BUFIOEN);
  493. }
  494. /* Set VMID to 2x250k */
  495. reg = snd_soc_read(codec, WM8960_POWER1);
  496. reg &= ~0x180;
  497. reg |= 0x100;
  498. snd_soc_write(codec, WM8960_POWER1, reg);
  499. break;
  500. case SND_SOC_BIAS_OFF:
  501. /* Enable anti-pop features */
  502. snd_soc_write(codec, WM8960_APOP1,
  503. WM8960_POBCTRL | WM8960_SOFT_ST |
  504. WM8960_BUFDCOPEN | WM8960_BUFIOEN);
  505. /* Disable VMID and VREF, let them discharge */
  506. snd_soc_write(codec, WM8960_POWER1, 0);
  507. msleep(600);
  508. break;
  509. }
  510. codec->dapm.bias_level = level;
  511. return 0;
  512. }
  513. static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec,
  514. enum snd_soc_bias_level level)
  515. {
  516. struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
  517. int reg;
  518. switch (level) {
  519. case SND_SOC_BIAS_ON:
  520. break;
  521. case SND_SOC_BIAS_PREPARE:
  522. switch (codec->dapm.bias_level) {
  523. case SND_SOC_BIAS_STANDBY:
  524. /* Enable anti pop mode */
  525. snd_soc_update_bits(codec, WM8960_APOP1,
  526. WM8960_POBCTRL | WM8960_SOFT_ST |
  527. WM8960_BUFDCOPEN,
  528. WM8960_POBCTRL | WM8960_SOFT_ST |
  529. WM8960_BUFDCOPEN);
  530. /* Enable LOUT1, ROUT1 and OUT3 if they're enabled */
  531. reg = 0;
  532. if (wm8960->lout1 && wm8960->lout1->power)
  533. reg |= WM8960_PWR2_LOUT1;
  534. if (wm8960->rout1 && wm8960->rout1->power)
  535. reg |= WM8960_PWR2_ROUT1;
  536. if (wm8960->out3 && wm8960->out3->power)
  537. reg |= WM8960_PWR2_OUT3;
  538. snd_soc_update_bits(codec, WM8960_POWER2,
  539. WM8960_PWR2_LOUT1 |
  540. WM8960_PWR2_ROUT1 |
  541. WM8960_PWR2_OUT3, reg);
  542. /* Enable VMID at 2*50k */
  543. snd_soc_update_bits(codec, WM8960_POWER1,
  544. WM8960_VMID_MASK, 0x80);
  545. /* Ramp */
  546. msleep(100);
  547. /* Enable VREF */
  548. snd_soc_update_bits(codec, WM8960_POWER1,
  549. WM8960_VREF, WM8960_VREF);
  550. msleep(100);
  551. break;
  552. case SND_SOC_BIAS_ON:
  553. /* Enable anti-pop mode */
  554. snd_soc_update_bits(codec, WM8960_APOP1,
  555. WM8960_POBCTRL | WM8960_SOFT_ST |
  556. WM8960_BUFDCOPEN,
  557. WM8960_POBCTRL | WM8960_SOFT_ST |
  558. WM8960_BUFDCOPEN);
  559. /* Disable VMID and VREF */
  560. snd_soc_update_bits(codec, WM8960_POWER1,
  561. WM8960_VREF | WM8960_VMID_MASK, 0);
  562. break;
  563. case SND_SOC_BIAS_OFF:
  564. snd_soc_cache_sync(codec);
  565. break;
  566. default:
  567. break;
  568. }
  569. break;
  570. case SND_SOC_BIAS_STANDBY:
  571. switch (codec->dapm.bias_level) {
  572. case SND_SOC_BIAS_PREPARE:
  573. /* Disable HP discharge */
  574. snd_soc_update_bits(codec, WM8960_APOP2,
  575. WM8960_DISOP | WM8960_DRES_MASK,
  576. 0);
  577. /* Disable anti-pop features */
  578. snd_soc_update_bits(codec, WM8960_APOP1,
  579. WM8960_POBCTRL | WM8960_SOFT_ST |
  580. WM8960_BUFDCOPEN,
  581. WM8960_POBCTRL | WM8960_SOFT_ST |
  582. WM8960_BUFDCOPEN);
  583. break;
  584. default:
  585. break;
  586. }
  587. break;
  588. case SND_SOC_BIAS_OFF:
  589. break;
  590. }
  591. codec->dapm.bias_level = level;
  592. return 0;
  593. }
  594. /* PLL divisors */
  595. struct _pll_div {
  596. u32 pre_div:1;
  597. u32 n:4;
  598. u32 k:24;
  599. };
  600. /* The size in bits of the pll divide multiplied by 10
  601. * to allow rounding later */
  602. #define FIXED_PLL_SIZE ((1 << 24) * 10)
  603. static int pll_factors(unsigned int source, unsigned int target,
  604. struct _pll_div *pll_div)
  605. {
  606. unsigned long long Kpart;
  607. unsigned int K, Ndiv, Nmod;
  608. pr_debug("WM8960 PLL: setting %dHz->%dHz\n", source, target);
  609. /* Scale up target to PLL operating frequency */
  610. target *= 4;
  611. Ndiv = target / source;
  612. if (Ndiv < 6) {
  613. source >>= 1;
  614. pll_div->pre_div = 1;
  615. Ndiv = target / source;
  616. } else
  617. pll_div->pre_div = 0;
  618. if ((Ndiv < 6) || (Ndiv > 12)) {
  619. pr_err("WM8960 PLL: Unsupported N=%d\n", Ndiv);
  620. return -EINVAL;
  621. }
  622. pll_div->n = Ndiv;
  623. Nmod = target % source;
  624. Kpart = FIXED_PLL_SIZE * (long long)Nmod;
  625. do_div(Kpart, source);
  626. K = Kpart & 0xFFFFFFFF;
  627. /* Check if we need to round */
  628. if ((K % 10) >= 5)
  629. K += 5;
  630. /* Move down to proper range now rounding is done */
  631. K /= 10;
  632. pll_div->k = K;
  633. pr_debug("WM8960 PLL: N=%x K=%x pre_div=%d\n",
  634. pll_div->n, pll_div->k, pll_div->pre_div);
  635. return 0;
  636. }
  637. static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
  638. int source, unsigned int freq_in, unsigned int freq_out)
  639. {
  640. struct snd_soc_codec *codec = codec_dai->codec;
  641. u16 reg;
  642. static struct _pll_div pll_div;
  643. int ret;
  644. if (freq_in && freq_out) {
  645. ret = pll_factors(freq_in, freq_out, &pll_div);
  646. if (ret != 0)
  647. return ret;
  648. }
  649. /* Disable the PLL: even if we are changing the frequency the
  650. * PLL needs to be disabled while we do so. */
  651. snd_soc_write(codec, WM8960_CLOCK1,
  652. snd_soc_read(codec, WM8960_CLOCK1) & ~1);
  653. snd_soc_write(codec, WM8960_POWER2,
  654. snd_soc_read(codec, WM8960_POWER2) & ~1);
  655. if (!freq_in || !freq_out)
  656. return 0;
  657. reg = snd_soc_read(codec, WM8960_PLL1) & ~0x3f;
  658. reg |= pll_div.pre_div << 4;
  659. reg |= pll_div.n;
  660. if (pll_div.k) {
  661. reg |= 0x20;
  662. snd_soc_write(codec, WM8960_PLL2, (pll_div.k >> 18) & 0x3f);
  663. snd_soc_write(codec, WM8960_PLL3, (pll_div.k >> 9) & 0x1ff);
  664. snd_soc_write(codec, WM8960_PLL4, pll_div.k & 0x1ff);
  665. }
  666. snd_soc_write(codec, WM8960_PLL1, reg);
  667. /* Turn it on */
  668. snd_soc_write(codec, WM8960_POWER2,
  669. snd_soc_read(codec, WM8960_POWER2) | 1);
  670. msleep(250);
  671. snd_soc_write(codec, WM8960_CLOCK1,
  672. snd_soc_read(codec, WM8960_CLOCK1) | 1);
  673. return 0;
  674. }
  675. static int wm8960_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
  676. int div_id, int div)
  677. {
  678. struct snd_soc_codec *codec = codec_dai->codec;
  679. u16 reg;
  680. switch (div_id) {
  681. case WM8960_SYSCLKDIV:
  682. reg = snd_soc_read(codec, WM8960_CLOCK1) & 0x1f9;
  683. snd_soc_write(codec, WM8960_CLOCK1, reg | div);
  684. break;
  685. case WM8960_DACDIV:
  686. reg = snd_soc_read(codec, WM8960_CLOCK1) & 0x1c7;
  687. snd_soc_write(codec, WM8960_CLOCK1, reg | div);
  688. break;
  689. case WM8960_OPCLKDIV:
  690. reg = snd_soc_read(codec, WM8960_PLL1) & 0x03f;
  691. snd_soc_write(codec, WM8960_PLL1, reg | div);
  692. break;
  693. case WM8960_DCLKDIV:
  694. reg = snd_soc_read(codec, WM8960_CLOCK2) & 0x03f;
  695. snd_soc_write(codec, WM8960_CLOCK2, reg | div);
  696. break;
  697. case WM8960_TOCLKSEL:
  698. reg = snd_soc_read(codec, WM8960_ADDCTL1) & 0x1fd;
  699. snd_soc_write(codec, WM8960_ADDCTL1, reg | div);
  700. break;
  701. default:
  702. return -EINVAL;
  703. }
  704. return 0;
  705. }
  706. static int wm8960_set_bias_level(struct snd_soc_codec *codec,
  707. enum snd_soc_bias_level level)
  708. {
  709. struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
  710. return wm8960->set_bias_level(codec, level);
  711. }
  712. #define WM8960_RATES SNDRV_PCM_RATE_8000_48000
  713. #define WM8960_FORMATS \
  714. (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
  715. SNDRV_PCM_FMTBIT_S24_LE)
  716. static const struct snd_soc_dai_ops wm8960_dai_ops = {
  717. .hw_params = wm8960_hw_params,
  718. .digital_mute = wm8960_mute,
  719. .set_fmt = wm8960_set_dai_fmt,
  720. .set_clkdiv = wm8960_set_dai_clkdiv,
  721. .set_pll = wm8960_set_dai_pll,
  722. };
  723. static struct snd_soc_dai_driver wm8960_dai = {
  724. .name = "wm8960-hifi",
  725. .playback = {
  726. .stream_name = "Playback",
  727. .channels_min = 1,
  728. .channels_max = 2,
  729. .rates = WM8960_RATES,
  730. .formats = WM8960_FORMATS,},
  731. .capture = {
  732. .stream_name = "Capture",
  733. .channels_min = 1,
  734. .channels_max = 2,
  735. .rates = WM8960_RATES,
  736. .formats = WM8960_FORMATS,},
  737. .ops = &wm8960_dai_ops,
  738. .symmetric_rates = 1,
  739. };
  740. static int wm8960_suspend(struct snd_soc_codec *codec)
  741. {
  742. struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
  743. wm8960->set_bias_level(codec, SND_SOC_BIAS_OFF);
  744. return 0;
  745. }
  746. static int wm8960_resume(struct snd_soc_codec *codec)
  747. {
  748. struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
  749. wm8960->set_bias_level(codec, SND_SOC_BIAS_STANDBY);
  750. return 0;
  751. }
  752. static int wm8960_probe(struct snd_soc_codec *codec)
  753. {
  754. struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
  755. struct wm8960_data *pdata = dev_get_platdata(codec->dev);
  756. int ret;
  757. u16 reg;
  758. wm8960->set_bias_level = wm8960_set_bias_level_out3;
  759. if (!pdata) {
  760. dev_warn(codec->dev, "No platform data supplied\n");
  761. } else {
  762. if (pdata->dres > WM8960_DRES_MAX) {
  763. dev_err(codec->dev, "Invalid DRES: %d\n", pdata->dres);
  764. pdata->dres = 0;
  765. }
  766. if (pdata->capless)
  767. wm8960->set_bias_level = wm8960_set_bias_level_capless;
  768. }
  769. ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8960->control_type);
  770. if (ret < 0) {
  771. dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
  772. return ret;
  773. }
  774. ret = wm8960_reset(codec);
  775. if (ret < 0) {
  776. dev_err(codec->dev, "Failed to issue reset\n");
  777. return ret;
  778. }
  779. wm8960->set_bias_level(codec, SND_SOC_BIAS_STANDBY);
  780. /* Latch the update bits */
  781. reg = snd_soc_read(codec, WM8960_LINVOL);
  782. snd_soc_write(codec, WM8960_LINVOL, reg | 0x100);
  783. reg = snd_soc_read(codec, WM8960_RINVOL);
  784. snd_soc_write(codec, WM8960_RINVOL, reg | 0x100);
  785. reg = snd_soc_read(codec, WM8960_LADC);
  786. snd_soc_write(codec, WM8960_LADC, reg | 0x100);
  787. reg = snd_soc_read(codec, WM8960_RADC);
  788. snd_soc_write(codec, WM8960_RADC, reg | 0x100);
  789. reg = snd_soc_read(codec, WM8960_LDAC);
  790. snd_soc_write(codec, WM8960_LDAC, reg | 0x100);
  791. reg = snd_soc_read(codec, WM8960_RDAC);
  792. snd_soc_write(codec, WM8960_RDAC, reg | 0x100);
  793. reg = snd_soc_read(codec, WM8960_LOUT1);
  794. snd_soc_write(codec, WM8960_LOUT1, reg | 0x100);
  795. reg = snd_soc_read(codec, WM8960_ROUT1);
  796. snd_soc_write(codec, WM8960_ROUT1, reg | 0x100);
  797. reg = snd_soc_read(codec, WM8960_LOUT2);
  798. snd_soc_write(codec, WM8960_LOUT2, reg | 0x100);
  799. reg = snd_soc_read(codec, WM8960_ROUT2);
  800. snd_soc_write(codec, WM8960_ROUT2, reg | 0x100);
  801. snd_soc_add_controls(codec, wm8960_snd_controls,
  802. ARRAY_SIZE(wm8960_snd_controls));
  803. wm8960_add_widgets(codec);
  804. return 0;
  805. }
  806. /* power down chip */
  807. static int wm8960_remove(struct snd_soc_codec *codec)
  808. {
  809. struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
  810. wm8960->set_bias_level(codec, SND_SOC_BIAS_OFF);
  811. return 0;
  812. }
  813. static struct snd_soc_codec_driver soc_codec_dev_wm8960 = {
  814. .probe = wm8960_probe,
  815. .remove = wm8960_remove,
  816. .suspend = wm8960_suspend,
  817. .resume = wm8960_resume,
  818. .set_bias_level = wm8960_set_bias_level,
  819. .reg_cache_size = ARRAY_SIZE(wm8960_reg),
  820. .reg_word_size = sizeof(u16),
  821. .reg_cache_default = wm8960_reg,
  822. };
  823. static __devinit int wm8960_i2c_probe(struct i2c_client *i2c,
  824. const struct i2c_device_id *id)
  825. {
  826. struct wm8960_priv *wm8960;
  827. int ret;
  828. wm8960 = kzalloc(sizeof(struct wm8960_priv), GFP_KERNEL);
  829. if (wm8960 == NULL)
  830. return -ENOMEM;
  831. i2c_set_clientdata(i2c, wm8960);
  832. wm8960->control_type = SND_SOC_I2C;
  833. ret = snd_soc_register_codec(&i2c->dev,
  834. &soc_codec_dev_wm8960, &wm8960_dai, 1);
  835. if (ret < 0)
  836. kfree(wm8960);
  837. return ret;
  838. }
  839. static __devexit int wm8960_i2c_remove(struct i2c_client *client)
  840. {
  841. snd_soc_unregister_codec(&client->dev);
  842. kfree(i2c_get_clientdata(client));
  843. return 0;
  844. }
  845. static const struct i2c_device_id wm8960_i2c_id[] = {
  846. { "wm8960", 0 },
  847. { }
  848. };
  849. MODULE_DEVICE_TABLE(i2c, wm8960_i2c_id);
  850. static struct i2c_driver wm8960_i2c_driver = {
  851. .driver = {
  852. .name = "wm8960",
  853. .owner = THIS_MODULE,
  854. },
  855. .probe = wm8960_i2c_probe,
  856. .remove = __devexit_p(wm8960_i2c_remove),
  857. .id_table = wm8960_i2c_id,
  858. };
  859. static int __init wm8960_modinit(void)
  860. {
  861. int ret = 0;
  862. ret = i2c_add_driver(&wm8960_i2c_driver);
  863. if (ret != 0) {
  864. printk(KERN_ERR "Failed to register WM8960 I2C driver: %d\n",
  865. ret);
  866. }
  867. return ret;
  868. }
  869. module_init(wm8960_modinit);
  870. static void __exit wm8960_exit(void)
  871. {
  872. i2c_del_driver(&wm8960_i2c_driver);
  873. }
  874. module_exit(wm8960_exit);
  875. MODULE_DESCRIPTION("ASoC WM8960 driver");
  876. MODULE_AUTHOR("Liam Girdwood");
  877. MODULE_LICENSE("GPL");