wm8955.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  1. /*
  2. * wm8955.c -- WM8955 ALSA SoC Audio driver
  3. *
  4. * Copyright 2009 Wolfson Microelectronics plc
  5. *
  6. * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/moduleparam.h>
  14. #include <linux/init.h>
  15. #include <linux/delay.h>
  16. #include <linux/pm.h>
  17. #include <linux/i2c.h>
  18. #include <linux/regmap.h>
  19. #include <linux/regulator/consumer.h>
  20. #include <linux/slab.h>
  21. #include <sound/core.h>
  22. #include <sound/pcm.h>
  23. #include <sound/pcm_params.h>
  24. #include <sound/soc.h>
  25. #include <sound/initval.h>
  26. #include <sound/tlv.h>
  27. #include <sound/wm8955.h>
  28. #include "wm8955.h"
  29. #define WM8955_NUM_SUPPLIES 4
  30. static const char *wm8955_supply_names[WM8955_NUM_SUPPLIES] = {
  31. "DCVDD",
  32. "DBVDD",
  33. "HPVDD",
  34. "AVDD",
  35. };
  36. /* codec private data */
  37. struct wm8955_priv {
  38. struct regmap *regmap;
  39. unsigned int mclk_rate;
  40. int deemph;
  41. int fs;
  42. struct regulator_bulk_data supplies[WM8955_NUM_SUPPLIES];
  43. };
  44. static const struct reg_default wm8955_reg_defaults[] = {
  45. { 2, 0x0079 }, /* R2 - LOUT1 volume */
  46. { 3, 0x0079 }, /* R3 - ROUT1 volume */
  47. { 5, 0x0008 }, /* R5 - DAC Control */
  48. { 7, 0x000A }, /* R7 - Audio Interface */
  49. { 8, 0x0000 }, /* R8 - Sample Rate */
  50. { 10, 0x00FF }, /* R10 - Left DAC volume */
  51. { 11, 0x00FF }, /* R11 - Right DAC volume */
  52. { 12, 0x000F }, /* R12 - Bass control */
  53. { 13, 0x000F }, /* R13 - Treble control */
  54. { 23, 0x00C1 }, /* R23 - Additional control (1) */
  55. { 24, 0x0000 }, /* R24 - Additional control (2) */
  56. { 25, 0x0000 }, /* R25 - Power Management (1) */
  57. { 26, 0x0000 }, /* R26 - Power Management (2) */
  58. { 27, 0x0000 }, /* R27 - Additional Control (3) */
  59. { 34, 0x0050 }, /* R34 - Left out Mix (1) */
  60. { 35, 0x0050 }, /* R35 - Left out Mix (2) */
  61. { 36, 0x0050 }, /* R36 - Right out Mix (1) */
  62. { 37, 0x0050 }, /* R37 - Right Out Mix (2) */
  63. { 38, 0x0050 }, /* R38 - Mono out Mix (1) */
  64. { 39, 0x0050 }, /* R39 - Mono out Mix (2) */
  65. { 40, 0x0079 }, /* R40 - LOUT2 volume */
  66. { 41, 0x0079 }, /* R41 - ROUT2 volume */
  67. { 42, 0x0079 }, /* R42 - MONOOUT volume */
  68. { 43, 0x0000 }, /* R43 - Clocking / PLL */
  69. { 44, 0x0103 }, /* R44 - PLL Control 1 */
  70. { 45, 0x0024 }, /* R45 - PLL Control 2 */
  71. { 46, 0x01BA }, /* R46 - PLL Control 3 */
  72. { 59, 0x0000 }, /* R59 - PLL Control 4 */
  73. };
  74. static bool wm8955_writeable(struct device *dev, unsigned int reg)
  75. {
  76. switch (reg) {
  77. case WM8955_LOUT1_VOLUME:
  78. case WM8955_ROUT1_VOLUME:
  79. case WM8955_DAC_CONTROL:
  80. case WM8955_AUDIO_INTERFACE:
  81. case WM8955_SAMPLE_RATE:
  82. case WM8955_LEFT_DAC_VOLUME:
  83. case WM8955_RIGHT_DAC_VOLUME:
  84. case WM8955_BASS_CONTROL:
  85. case WM8955_TREBLE_CONTROL:
  86. case WM8955_RESET:
  87. case WM8955_ADDITIONAL_CONTROL_1:
  88. case WM8955_ADDITIONAL_CONTROL_2:
  89. case WM8955_POWER_MANAGEMENT_1:
  90. case WM8955_POWER_MANAGEMENT_2:
  91. case WM8955_ADDITIONAL_CONTROL_3:
  92. case WM8955_LEFT_OUT_MIX_1:
  93. case WM8955_LEFT_OUT_MIX_2:
  94. case WM8955_RIGHT_OUT_MIX_1:
  95. case WM8955_RIGHT_OUT_MIX_2:
  96. case WM8955_MONO_OUT_MIX_1:
  97. case WM8955_MONO_OUT_MIX_2:
  98. case WM8955_LOUT2_VOLUME:
  99. case WM8955_ROUT2_VOLUME:
  100. case WM8955_MONOOUT_VOLUME:
  101. case WM8955_CLOCKING_PLL:
  102. case WM8955_PLL_CONTROL_1:
  103. case WM8955_PLL_CONTROL_2:
  104. case WM8955_PLL_CONTROL_3:
  105. case WM8955_PLL_CONTROL_4:
  106. return true;
  107. default:
  108. return false;
  109. }
  110. }
  111. static bool wm8955_volatile(struct device *dev, unsigned int reg)
  112. {
  113. switch (reg) {
  114. case WM8955_RESET:
  115. return true;
  116. default:
  117. return false;
  118. }
  119. }
  120. static int wm8955_reset(struct snd_soc_codec *codec)
  121. {
  122. return snd_soc_write(codec, WM8955_RESET, 0);
  123. }
  124. struct pll_factors {
  125. int n;
  126. int k;
  127. int outdiv;
  128. };
  129. /* The size in bits of the FLL divide multiplied by 10
  130. * to allow rounding later */
  131. #define FIXED_FLL_SIZE ((1 << 22) * 10)
  132. static int wm8995_pll_factors(struct device *dev,
  133. int Fref, int Fout, struct pll_factors *pll)
  134. {
  135. u64 Kpart;
  136. unsigned int K, Ndiv, Nmod, target;
  137. dev_dbg(dev, "Fref=%u Fout=%u\n", Fref, Fout);
  138. /* The oscilator should run at should be 90-100MHz, and
  139. * there's a divide by 4 plus an optional divide by 2 in the
  140. * output path to generate the system clock. The clock table
  141. * is sortd so we should always generate a suitable target. */
  142. target = Fout * 4;
  143. if (target < 90000000) {
  144. pll->outdiv = 1;
  145. target *= 2;
  146. } else {
  147. pll->outdiv = 0;
  148. }
  149. WARN_ON(target < 90000000 || target > 100000000);
  150. dev_dbg(dev, "Fvco=%dHz\n", target);
  151. /* Now, calculate N.K */
  152. Ndiv = target / Fref;
  153. pll->n = Ndiv;
  154. Nmod = target % Fref;
  155. dev_dbg(dev, "Nmod=%d\n", Nmod);
  156. /* Calculate fractional part - scale up so we can round. */
  157. Kpart = FIXED_FLL_SIZE * (long long)Nmod;
  158. do_div(Kpart, Fref);
  159. K = Kpart & 0xFFFFFFFF;
  160. if ((K % 10) >= 5)
  161. K += 5;
  162. /* Move down to proper range now rounding is done */
  163. pll->k = K / 10;
  164. dev_dbg(dev, "N=%x K=%x OUTDIV=%x\n", pll->n, pll->k, pll->outdiv);
  165. return 0;
  166. }
  167. /* Lookup table specifying SRATE (table 25 in datasheet); some of the
  168. * output frequencies have been rounded to the standard frequencies
  169. * they are intended to match where the error is slight. */
  170. static struct {
  171. int mclk;
  172. int fs;
  173. int usb;
  174. int sr;
  175. } clock_cfgs[] = {
  176. { 18432000, 8000, 0, 3, },
  177. { 18432000, 12000, 0, 9, },
  178. { 18432000, 16000, 0, 11, },
  179. { 18432000, 24000, 0, 29, },
  180. { 18432000, 32000, 0, 13, },
  181. { 18432000, 48000, 0, 1, },
  182. { 18432000, 96000, 0, 15, },
  183. { 16934400, 8018, 0, 19, },
  184. { 16934400, 11025, 0, 25, },
  185. { 16934400, 22050, 0, 27, },
  186. { 16934400, 44100, 0, 17, },
  187. { 16934400, 88200, 0, 31, },
  188. { 12000000, 8000, 1, 2, },
  189. { 12000000, 11025, 1, 25, },
  190. { 12000000, 12000, 1, 8, },
  191. { 12000000, 16000, 1, 10, },
  192. { 12000000, 22050, 1, 27, },
  193. { 12000000, 24000, 1, 28, },
  194. { 12000000, 32000, 1, 12, },
  195. { 12000000, 44100, 1, 17, },
  196. { 12000000, 48000, 1, 0, },
  197. { 12000000, 88200, 1, 31, },
  198. { 12000000, 96000, 1, 14, },
  199. { 12288000, 8000, 0, 2, },
  200. { 12288000, 12000, 0, 8, },
  201. { 12288000, 16000, 0, 10, },
  202. { 12288000, 24000, 0, 28, },
  203. { 12288000, 32000, 0, 12, },
  204. { 12288000, 48000, 0, 0, },
  205. { 12288000, 96000, 0, 14, },
  206. { 12289600, 8018, 0, 18, },
  207. { 12289600, 11025, 0, 24, },
  208. { 12289600, 22050, 0, 26, },
  209. { 11289600, 44100, 0, 16, },
  210. { 11289600, 88200, 0, 31, },
  211. };
  212. static int wm8955_configure_clocking(struct snd_soc_codec *codec)
  213. {
  214. struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
  215. int i, ret, val;
  216. int clocking = 0;
  217. int srate = 0;
  218. int sr = -1;
  219. struct pll_factors pll;
  220. /* If we're not running a sample rate currently just pick one */
  221. if (wm8955->fs == 0)
  222. wm8955->fs = 8000;
  223. /* Can we generate an exact output? */
  224. for (i = 0; i < ARRAY_SIZE(clock_cfgs); i++) {
  225. if (wm8955->fs != clock_cfgs[i].fs)
  226. continue;
  227. sr = i;
  228. if (wm8955->mclk_rate == clock_cfgs[i].mclk)
  229. break;
  230. }
  231. /* We should never get here with an unsupported sample rate */
  232. if (sr == -1) {
  233. dev_err(codec->dev, "Sample rate %dHz unsupported\n",
  234. wm8955->fs);
  235. WARN_ON(sr == -1);
  236. return -EINVAL;
  237. }
  238. if (i == ARRAY_SIZE(clock_cfgs)) {
  239. /* If we can't generate the right clock from MCLK then
  240. * we should configure the PLL to supply us with an
  241. * appropriate clock.
  242. */
  243. clocking |= WM8955_MCLKSEL;
  244. /* Use the last divider configuration we saw for the
  245. * sample rate. */
  246. ret = wm8995_pll_factors(codec->dev, wm8955->mclk_rate,
  247. clock_cfgs[sr].mclk, &pll);
  248. if (ret != 0) {
  249. dev_err(codec->dev,
  250. "Unable to generate %dHz from %dHz MCLK\n",
  251. wm8955->fs, wm8955->mclk_rate);
  252. return -EINVAL;
  253. }
  254. snd_soc_update_bits(codec, WM8955_PLL_CONTROL_1,
  255. WM8955_N_MASK | WM8955_K_21_18_MASK,
  256. (pll.n << WM8955_N_SHIFT) |
  257. pll.k >> 18);
  258. snd_soc_update_bits(codec, WM8955_PLL_CONTROL_2,
  259. WM8955_K_17_9_MASK,
  260. (pll.k >> 9) & WM8955_K_17_9_MASK);
  261. snd_soc_update_bits(codec, WM8955_PLL_CONTROL_3,
  262. WM8955_K_8_0_MASK,
  263. pll.k & WM8955_K_8_0_MASK);
  264. if (pll.k)
  265. snd_soc_update_bits(codec, WM8955_PLL_CONTROL_4,
  266. WM8955_KEN, WM8955_KEN);
  267. else
  268. snd_soc_update_bits(codec, WM8955_PLL_CONTROL_4,
  269. WM8955_KEN, 0);
  270. if (pll.outdiv)
  271. val = WM8955_PLL_RB | WM8955_PLLOUTDIV2;
  272. else
  273. val = WM8955_PLL_RB;
  274. /* Now start the PLL running */
  275. snd_soc_update_bits(codec, WM8955_CLOCKING_PLL,
  276. WM8955_PLL_RB | WM8955_PLLOUTDIV2, val);
  277. snd_soc_update_bits(codec, WM8955_CLOCKING_PLL,
  278. WM8955_PLLEN, WM8955_PLLEN);
  279. }
  280. srate = clock_cfgs[sr].usb | (clock_cfgs[sr].sr << WM8955_SR_SHIFT);
  281. snd_soc_update_bits(codec, WM8955_SAMPLE_RATE,
  282. WM8955_USB | WM8955_SR_MASK, srate);
  283. snd_soc_update_bits(codec, WM8955_CLOCKING_PLL,
  284. WM8955_MCLKSEL, clocking);
  285. return 0;
  286. }
  287. static int wm8955_sysclk(struct snd_soc_dapm_widget *w,
  288. struct snd_kcontrol *kcontrol, int event)
  289. {
  290. struct snd_soc_codec *codec = w->codec;
  291. int ret = 0;
  292. /* Always disable the clocks - if we're doing reconfiguration this
  293. * avoids misclocking.
  294. */
  295. snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1,
  296. WM8955_DIGENB, 0);
  297. snd_soc_update_bits(codec, WM8955_CLOCKING_PLL,
  298. WM8955_PLL_RB | WM8955_PLLEN, 0);
  299. switch (event) {
  300. case SND_SOC_DAPM_POST_PMD:
  301. break;
  302. case SND_SOC_DAPM_PRE_PMU:
  303. ret = wm8955_configure_clocking(codec);
  304. break;
  305. default:
  306. ret = -EINVAL;
  307. break;
  308. }
  309. return ret;
  310. }
  311. static int deemph_settings[] = { 0, 32000, 44100, 48000 };
  312. static int wm8955_set_deemph(struct snd_soc_codec *codec)
  313. {
  314. struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
  315. int val, i, best;
  316. /* If we're using deemphasis select the nearest available sample
  317. * rate.
  318. */
  319. if (wm8955->deemph) {
  320. best = 1;
  321. for (i = 2; i < ARRAY_SIZE(deemph_settings); i++) {
  322. if (abs(deemph_settings[i] - wm8955->fs) <
  323. abs(deemph_settings[best] - wm8955->fs))
  324. best = i;
  325. }
  326. val = best << WM8955_DEEMPH_SHIFT;
  327. } else {
  328. val = 0;
  329. }
  330. dev_dbg(codec->dev, "Set deemphasis %d\n", val);
  331. return snd_soc_update_bits(codec, WM8955_DAC_CONTROL,
  332. WM8955_DEEMPH_MASK, val);
  333. }
  334. static int wm8955_get_deemph(struct snd_kcontrol *kcontrol,
  335. struct snd_ctl_elem_value *ucontrol)
  336. {
  337. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  338. struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
  339. ucontrol->value.integer.value[0] = wm8955->deemph;
  340. return 0;
  341. }
  342. static int wm8955_put_deemph(struct snd_kcontrol *kcontrol,
  343. struct snd_ctl_elem_value *ucontrol)
  344. {
  345. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  346. struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
  347. int deemph = ucontrol->value.integer.value[0];
  348. if (deemph > 1)
  349. return -EINVAL;
  350. wm8955->deemph = deemph;
  351. return wm8955_set_deemph(codec);
  352. }
  353. static const char *bass_mode_text[] = {
  354. "Linear", "Adaptive",
  355. };
  356. static const struct soc_enum bass_mode =
  357. SOC_ENUM_SINGLE(WM8955_BASS_CONTROL, 7, 2, bass_mode_text);
  358. static const char *bass_cutoff_text[] = {
  359. "Low", "High"
  360. };
  361. static const struct soc_enum bass_cutoff =
  362. SOC_ENUM_SINGLE(WM8955_BASS_CONTROL, 6, 2, bass_cutoff_text);
  363. static const char *treble_cutoff_text[] = {
  364. "High", "Low"
  365. };
  366. static const struct soc_enum treble_cutoff =
  367. SOC_ENUM_SINGLE(WM8955_TREBLE_CONTROL, 6, 2, treble_cutoff_text);
  368. static const DECLARE_TLV_DB_SCALE(digital_tlv, -12750, 50, 1);
  369. static const DECLARE_TLV_DB_SCALE(atten_tlv, -600, 600, 0);
  370. static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0);
  371. static const DECLARE_TLV_DB_SCALE(mono_tlv, -2100, 300, 0);
  372. static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
  373. static const DECLARE_TLV_DB_SCALE(treble_tlv, -1200, 150, 1);
  374. static const struct snd_kcontrol_new wm8955_snd_controls[] = {
  375. SOC_DOUBLE_R_TLV("Digital Playback Volume", WM8955_LEFT_DAC_VOLUME,
  376. WM8955_RIGHT_DAC_VOLUME, 0, 255, 0, digital_tlv),
  377. SOC_SINGLE_TLV("Playback Attenuation Volume", WM8955_DAC_CONTROL, 7, 1, 1,
  378. atten_tlv),
  379. SOC_SINGLE_BOOL_EXT("DAC Deemphasis Switch", 0,
  380. wm8955_get_deemph, wm8955_put_deemph),
  381. SOC_ENUM("Bass Mode", bass_mode),
  382. SOC_ENUM("Bass Cutoff", bass_cutoff),
  383. SOC_SINGLE("Bass Volume", WM8955_BASS_CONTROL, 0, 15, 1),
  384. SOC_ENUM("Treble Cutoff", treble_cutoff),
  385. SOC_SINGLE_TLV("Treble Volume", WM8955_TREBLE_CONTROL, 0, 14, 1, treble_tlv),
  386. SOC_SINGLE_TLV("Left Bypass Volume", WM8955_LEFT_OUT_MIX_1, 4, 7, 1,
  387. bypass_tlv),
  388. SOC_SINGLE_TLV("Left Mono Volume", WM8955_LEFT_OUT_MIX_2, 4, 7, 1,
  389. bypass_tlv),
  390. SOC_SINGLE_TLV("Right Mono Volume", WM8955_RIGHT_OUT_MIX_1, 4, 7, 1,
  391. bypass_tlv),
  392. SOC_SINGLE_TLV("Right Bypass Volume", WM8955_RIGHT_OUT_MIX_2, 4, 7, 1,
  393. bypass_tlv),
  394. /* Not a stereo pair so they line up with the DAPM switches */
  395. SOC_SINGLE_TLV("Mono Left Bypass Volume", WM8955_MONO_OUT_MIX_1, 4, 7, 1,
  396. mono_tlv),
  397. SOC_SINGLE_TLV("Mono Right Bypass Volume", WM8955_MONO_OUT_MIX_2, 4, 7, 1,
  398. mono_tlv),
  399. SOC_DOUBLE_R_TLV("Headphone Volume", WM8955_LOUT1_VOLUME,
  400. WM8955_ROUT1_VOLUME, 0, 127, 0, out_tlv),
  401. SOC_DOUBLE_R("Headphone ZC Switch", WM8955_LOUT1_VOLUME,
  402. WM8955_ROUT1_VOLUME, 7, 1, 0),
  403. SOC_DOUBLE_R_TLV("Speaker Volume", WM8955_LOUT2_VOLUME,
  404. WM8955_ROUT2_VOLUME, 0, 127, 0, out_tlv),
  405. SOC_DOUBLE_R("Speaker ZC Switch", WM8955_LOUT2_VOLUME,
  406. WM8955_ROUT2_VOLUME, 7, 1, 0),
  407. SOC_SINGLE_TLV("Mono Volume", WM8955_MONOOUT_VOLUME, 0, 127, 0, out_tlv),
  408. SOC_SINGLE("Mono ZC Switch", WM8955_MONOOUT_VOLUME, 7, 1, 0),
  409. };
  410. static const struct snd_kcontrol_new lmixer[] = {
  411. SOC_DAPM_SINGLE("Playback Switch", WM8955_LEFT_OUT_MIX_1, 8, 1, 0),
  412. SOC_DAPM_SINGLE("Bypass Switch", WM8955_LEFT_OUT_MIX_1, 7, 1, 0),
  413. SOC_DAPM_SINGLE("Right Playback Switch", WM8955_LEFT_OUT_MIX_2, 8, 1, 0),
  414. SOC_DAPM_SINGLE("Mono Switch", WM8955_LEFT_OUT_MIX_2, 7, 1, 0),
  415. };
  416. static const struct snd_kcontrol_new rmixer[] = {
  417. SOC_DAPM_SINGLE("Left Playback Switch", WM8955_RIGHT_OUT_MIX_1, 8, 1, 0),
  418. SOC_DAPM_SINGLE("Mono Switch", WM8955_RIGHT_OUT_MIX_1, 7, 1, 0),
  419. SOC_DAPM_SINGLE("Playback Switch", WM8955_RIGHT_OUT_MIX_2, 8, 1, 0),
  420. SOC_DAPM_SINGLE("Bypass Switch", WM8955_RIGHT_OUT_MIX_2, 7, 1, 0),
  421. };
  422. static const struct snd_kcontrol_new mmixer[] = {
  423. SOC_DAPM_SINGLE("Left Playback Switch", WM8955_MONO_OUT_MIX_1, 8, 1, 0),
  424. SOC_DAPM_SINGLE("Left Bypass Switch", WM8955_MONO_OUT_MIX_1, 7, 1, 0),
  425. SOC_DAPM_SINGLE("Right Playback Switch", WM8955_MONO_OUT_MIX_2, 8, 1, 0),
  426. SOC_DAPM_SINGLE("Right Bypass Switch", WM8955_MONO_OUT_MIX_2, 7, 1, 0),
  427. };
  428. static const struct snd_soc_dapm_widget wm8955_dapm_widgets[] = {
  429. SND_SOC_DAPM_INPUT("MONOIN-"),
  430. SND_SOC_DAPM_INPUT("MONOIN+"),
  431. SND_SOC_DAPM_INPUT("LINEINR"),
  432. SND_SOC_DAPM_INPUT("LINEINL"),
  433. SND_SOC_DAPM_PGA("Mono Input", SND_SOC_NOPM, 0, 0, NULL, 0),
  434. SND_SOC_DAPM_SUPPLY("SYSCLK", WM8955_POWER_MANAGEMENT_1, 0, 1, wm8955_sysclk,
  435. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  436. SND_SOC_DAPM_SUPPLY("TSDEN", WM8955_ADDITIONAL_CONTROL_1, 8, 0, NULL, 0),
  437. SND_SOC_DAPM_DAC("DACL", "Playback", WM8955_POWER_MANAGEMENT_2, 8, 0),
  438. SND_SOC_DAPM_DAC("DACR", "Playback", WM8955_POWER_MANAGEMENT_2, 7, 0),
  439. SND_SOC_DAPM_PGA("LOUT1 PGA", WM8955_POWER_MANAGEMENT_2, 6, 0, NULL, 0),
  440. SND_SOC_DAPM_PGA("ROUT1 PGA", WM8955_POWER_MANAGEMENT_2, 5, 0, NULL, 0),
  441. SND_SOC_DAPM_PGA("LOUT2 PGA", WM8955_POWER_MANAGEMENT_2, 4, 0, NULL, 0),
  442. SND_SOC_DAPM_PGA("ROUT2 PGA", WM8955_POWER_MANAGEMENT_2, 3, 0, NULL, 0),
  443. SND_SOC_DAPM_PGA("MOUT PGA", WM8955_POWER_MANAGEMENT_2, 2, 0, NULL, 0),
  444. SND_SOC_DAPM_PGA("OUT3 PGA", WM8955_POWER_MANAGEMENT_2, 1, 0, NULL, 0),
  445. /* The names are chosen to make the control names nice */
  446. SND_SOC_DAPM_MIXER("Left", SND_SOC_NOPM, 0, 0,
  447. lmixer, ARRAY_SIZE(lmixer)),
  448. SND_SOC_DAPM_MIXER("Right", SND_SOC_NOPM, 0, 0,
  449. rmixer, ARRAY_SIZE(rmixer)),
  450. SND_SOC_DAPM_MIXER("Mono", SND_SOC_NOPM, 0, 0,
  451. mmixer, ARRAY_SIZE(mmixer)),
  452. SND_SOC_DAPM_OUTPUT("LOUT1"),
  453. SND_SOC_DAPM_OUTPUT("ROUT1"),
  454. SND_SOC_DAPM_OUTPUT("LOUT2"),
  455. SND_SOC_DAPM_OUTPUT("ROUT2"),
  456. SND_SOC_DAPM_OUTPUT("MONOOUT"),
  457. SND_SOC_DAPM_OUTPUT("OUT3"),
  458. };
  459. static const struct snd_soc_dapm_route wm8955_dapm_routes[] = {
  460. { "DACL", NULL, "SYSCLK" },
  461. { "DACR", NULL, "SYSCLK" },
  462. { "Mono Input", NULL, "MONOIN-" },
  463. { "Mono Input", NULL, "MONOIN+" },
  464. { "Left", "Playback Switch", "DACL" },
  465. { "Left", "Right Playback Switch", "DACR" },
  466. { "Left", "Bypass Switch", "LINEINL" },
  467. { "Left", "Mono Switch", "Mono Input" },
  468. { "Right", "Playback Switch", "DACR" },
  469. { "Right", "Left Playback Switch", "DACL" },
  470. { "Right", "Bypass Switch", "LINEINR" },
  471. { "Right", "Mono Switch", "Mono Input" },
  472. { "Mono", "Left Playback Switch", "DACL" },
  473. { "Mono", "Right Playback Switch", "DACR" },
  474. { "Mono", "Left Bypass Switch", "LINEINL" },
  475. { "Mono", "Right Bypass Switch", "LINEINR" },
  476. { "LOUT1 PGA", NULL, "Left" },
  477. { "LOUT1", NULL, "TSDEN" },
  478. { "LOUT1", NULL, "LOUT1 PGA" },
  479. { "ROUT1 PGA", NULL, "Right" },
  480. { "ROUT1", NULL, "TSDEN" },
  481. { "ROUT1", NULL, "ROUT1 PGA" },
  482. { "LOUT2 PGA", NULL, "Left" },
  483. { "LOUT2", NULL, "TSDEN" },
  484. { "LOUT2", NULL, "LOUT2 PGA" },
  485. { "ROUT2 PGA", NULL, "Right" },
  486. { "ROUT2", NULL, "TSDEN" },
  487. { "ROUT2", NULL, "ROUT2 PGA" },
  488. { "MOUT PGA", NULL, "Mono" },
  489. { "MONOOUT", NULL, "MOUT PGA" },
  490. /* OUT3 not currently implemented */
  491. { "OUT3", NULL, "OUT3 PGA" },
  492. };
  493. static int wm8955_hw_params(struct snd_pcm_substream *substream,
  494. struct snd_pcm_hw_params *params,
  495. struct snd_soc_dai *dai)
  496. {
  497. struct snd_soc_codec *codec = dai->codec;
  498. struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
  499. int ret;
  500. int wl;
  501. switch (params_format(params)) {
  502. case SNDRV_PCM_FORMAT_S16_LE:
  503. wl = 0;
  504. break;
  505. case SNDRV_PCM_FORMAT_S20_3LE:
  506. wl = 0x4;
  507. break;
  508. case SNDRV_PCM_FORMAT_S24_LE:
  509. wl = 0x8;
  510. break;
  511. case SNDRV_PCM_FORMAT_S32_LE:
  512. wl = 0xc;
  513. break;
  514. default:
  515. return -EINVAL;
  516. }
  517. snd_soc_update_bits(codec, WM8955_AUDIO_INTERFACE,
  518. WM8955_WL_MASK, wl);
  519. wm8955->fs = params_rate(params);
  520. wm8955_set_deemph(codec);
  521. /* If the chip is clocked then disable the clocks and force a
  522. * reconfiguration, otherwise DAPM will power up the
  523. * clocks for us later. */
  524. ret = snd_soc_read(codec, WM8955_POWER_MANAGEMENT_1);
  525. if (ret < 0)
  526. return ret;
  527. if (ret & WM8955_DIGENB) {
  528. snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1,
  529. WM8955_DIGENB, 0);
  530. snd_soc_update_bits(codec, WM8955_CLOCKING_PLL,
  531. WM8955_PLL_RB | WM8955_PLLEN, 0);
  532. wm8955_configure_clocking(codec);
  533. }
  534. return 0;
  535. }
  536. static int wm8955_set_sysclk(struct snd_soc_dai *dai, int clk_id,
  537. unsigned int freq, int dir)
  538. {
  539. struct snd_soc_codec *codec = dai->codec;
  540. struct wm8955_priv *priv = snd_soc_codec_get_drvdata(codec);
  541. int div;
  542. switch (clk_id) {
  543. case WM8955_CLK_MCLK:
  544. if (freq > 15000000) {
  545. priv->mclk_rate = freq /= 2;
  546. div = WM8955_MCLKDIV2;
  547. } else {
  548. priv->mclk_rate = freq;
  549. div = 0;
  550. }
  551. snd_soc_update_bits(codec, WM8955_SAMPLE_RATE,
  552. WM8955_MCLKDIV2, div);
  553. break;
  554. default:
  555. return -EINVAL;
  556. }
  557. dev_dbg(dai->dev, "Clock source is %d at %uHz\n", clk_id, freq);
  558. return 0;
  559. }
  560. static int wm8955_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  561. {
  562. struct snd_soc_codec *codec = dai->codec;
  563. u16 aif = 0;
  564. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  565. case SND_SOC_DAIFMT_CBS_CFS:
  566. break;
  567. case SND_SOC_DAIFMT_CBM_CFM:
  568. aif |= WM8955_MS;
  569. break;
  570. default:
  571. return -EINVAL;
  572. }
  573. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  574. case SND_SOC_DAIFMT_DSP_B:
  575. aif |= WM8955_LRP;
  576. case SND_SOC_DAIFMT_DSP_A:
  577. aif |= 0x3;
  578. break;
  579. case SND_SOC_DAIFMT_I2S:
  580. aif |= 0x2;
  581. break;
  582. case SND_SOC_DAIFMT_RIGHT_J:
  583. break;
  584. case SND_SOC_DAIFMT_LEFT_J:
  585. aif |= 0x1;
  586. break;
  587. default:
  588. return -EINVAL;
  589. }
  590. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  591. case SND_SOC_DAIFMT_DSP_A:
  592. case SND_SOC_DAIFMT_DSP_B:
  593. /* frame inversion not valid for DSP modes */
  594. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  595. case SND_SOC_DAIFMT_NB_NF:
  596. break;
  597. case SND_SOC_DAIFMT_IB_NF:
  598. aif |= WM8955_BCLKINV;
  599. break;
  600. default:
  601. return -EINVAL;
  602. }
  603. break;
  604. case SND_SOC_DAIFMT_I2S:
  605. case SND_SOC_DAIFMT_RIGHT_J:
  606. case SND_SOC_DAIFMT_LEFT_J:
  607. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  608. case SND_SOC_DAIFMT_NB_NF:
  609. break;
  610. case SND_SOC_DAIFMT_IB_IF:
  611. aif |= WM8955_BCLKINV | WM8955_LRP;
  612. break;
  613. case SND_SOC_DAIFMT_IB_NF:
  614. aif |= WM8955_BCLKINV;
  615. break;
  616. case SND_SOC_DAIFMT_NB_IF:
  617. aif |= WM8955_LRP;
  618. break;
  619. default:
  620. return -EINVAL;
  621. }
  622. break;
  623. default:
  624. return -EINVAL;
  625. }
  626. snd_soc_update_bits(codec, WM8955_AUDIO_INTERFACE,
  627. WM8955_MS | WM8955_FORMAT_MASK | WM8955_BCLKINV |
  628. WM8955_LRP, aif);
  629. return 0;
  630. }
  631. static int wm8955_digital_mute(struct snd_soc_dai *codec_dai, int mute)
  632. {
  633. struct snd_soc_codec *codec = codec_dai->codec;
  634. int val;
  635. if (mute)
  636. val = WM8955_DACMU;
  637. else
  638. val = 0;
  639. snd_soc_update_bits(codec, WM8955_DAC_CONTROL, WM8955_DACMU, val);
  640. return 0;
  641. }
  642. static int wm8955_set_bias_level(struct snd_soc_codec *codec,
  643. enum snd_soc_bias_level level)
  644. {
  645. struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
  646. int ret;
  647. switch (level) {
  648. case SND_SOC_BIAS_ON:
  649. break;
  650. case SND_SOC_BIAS_PREPARE:
  651. /* VMID resistance 2*50k */
  652. snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1,
  653. WM8955_VMIDSEL_MASK,
  654. 0x1 << WM8955_VMIDSEL_SHIFT);
  655. /* Default bias current */
  656. snd_soc_update_bits(codec, WM8955_ADDITIONAL_CONTROL_1,
  657. WM8955_VSEL_MASK,
  658. 0x2 << WM8955_VSEL_SHIFT);
  659. break;
  660. case SND_SOC_BIAS_STANDBY:
  661. if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
  662. ret = regulator_bulk_enable(ARRAY_SIZE(wm8955->supplies),
  663. wm8955->supplies);
  664. if (ret != 0) {
  665. dev_err(codec->dev,
  666. "Failed to enable supplies: %d\n",
  667. ret);
  668. return ret;
  669. }
  670. regcache_sync(wm8955->regmap);
  671. /* Enable VREF and VMID */
  672. snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1,
  673. WM8955_VREF |
  674. WM8955_VMIDSEL_MASK,
  675. WM8955_VREF |
  676. 0x3 << WM8955_VREF_SHIFT);
  677. /* Let VMID ramp */
  678. msleep(500);
  679. /* High resistance VROI to maintain outputs */
  680. snd_soc_update_bits(codec,
  681. WM8955_ADDITIONAL_CONTROL_3,
  682. WM8955_VROI, WM8955_VROI);
  683. }
  684. /* Maintain VMID with 2*250k */
  685. snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1,
  686. WM8955_VMIDSEL_MASK,
  687. 0x2 << WM8955_VMIDSEL_SHIFT);
  688. /* Minimum bias current */
  689. snd_soc_update_bits(codec, WM8955_ADDITIONAL_CONTROL_1,
  690. WM8955_VSEL_MASK, 0);
  691. break;
  692. case SND_SOC_BIAS_OFF:
  693. /* Low resistance VROI to help discharge */
  694. snd_soc_update_bits(codec,
  695. WM8955_ADDITIONAL_CONTROL_3,
  696. WM8955_VROI, 0);
  697. /* Turn off VMID and VREF */
  698. snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1,
  699. WM8955_VREF |
  700. WM8955_VMIDSEL_MASK, 0);
  701. regulator_bulk_disable(ARRAY_SIZE(wm8955->supplies),
  702. wm8955->supplies);
  703. break;
  704. }
  705. codec->dapm.bias_level = level;
  706. return 0;
  707. }
  708. #define WM8955_RATES SNDRV_PCM_RATE_8000_96000
  709. #define WM8955_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
  710. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
  711. static const struct snd_soc_dai_ops wm8955_dai_ops = {
  712. .set_sysclk = wm8955_set_sysclk,
  713. .set_fmt = wm8955_set_fmt,
  714. .hw_params = wm8955_hw_params,
  715. .digital_mute = wm8955_digital_mute,
  716. };
  717. static struct snd_soc_dai_driver wm8955_dai = {
  718. .name = "wm8955-hifi",
  719. .playback = {
  720. .stream_name = "Playback",
  721. .channels_min = 2,
  722. .channels_max = 2,
  723. .rates = WM8955_RATES,
  724. .formats = WM8955_FORMATS,
  725. },
  726. .ops = &wm8955_dai_ops,
  727. };
  728. #ifdef CONFIG_PM
  729. static int wm8955_suspend(struct snd_soc_codec *codec)
  730. {
  731. struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
  732. wm8955_set_bias_level(codec, SND_SOC_BIAS_OFF);
  733. regcache_mark_dirty(wm8955->regmap);
  734. return 0;
  735. }
  736. static int wm8955_resume(struct snd_soc_codec *codec)
  737. {
  738. wm8955_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
  739. return 0;
  740. }
  741. #else
  742. #define wm8955_suspend NULL
  743. #define wm8955_resume NULL
  744. #endif
  745. static int wm8955_probe(struct snd_soc_codec *codec)
  746. {
  747. struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
  748. struct wm8955_pdata *pdata = dev_get_platdata(codec->dev);
  749. int ret, i;
  750. codec->control_data = wm8955->regmap;
  751. ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
  752. if (ret != 0) {
  753. dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
  754. return ret;
  755. }
  756. for (i = 0; i < ARRAY_SIZE(wm8955->supplies); i++)
  757. wm8955->supplies[i].supply = wm8955_supply_names[i];
  758. ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8955->supplies),
  759. wm8955->supplies);
  760. if (ret != 0) {
  761. dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
  762. return ret;
  763. }
  764. ret = regulator_bulk_enable(ARRAY_SIZE(wm8955->supplies),
  765. wm8955->supplies);
  766. if (ret != 0) {
  767. dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
  768. goto err_get;
  769. }
  770. ret = wm8955_reset(codec);
  771. if (ret < 0) {
  772. dev_err(codec->dev, "Failed to issue reset: %d\n", ret);
  773. goto err_enable;
  774. }
  775. /* Change some default settings - latch VU and enable ZC */
  776. snd_soc_update_bits(codec, WM8955_LEFT_DAC_VOLUME,
  777. WM8955_LDVU, WM8955_LDVU);
  778. snd_soc_update_bits(codec, WM8955_RIGHT_DAC_VOLUME,
  779. WM8955_RDVU, WM8955_RDVU);
  780. snd_soc_update_bits(codec, WM8955_LOUT1_VOLUME,
  781. WM8955_LO1VU | WM8955_LO1ZC,
  782. WM8955_LO1VU | WM8955_LO1ZC);
  783. snd_soc_update_bits(codec, WM8955_ROUT1_VOLUME,
  784. WM8955_RO1VU | WM8955_RO1ZC,
  785. WM8955_RO1VU | WM8955_RO1ZC);
  786. snd_soc_update_bits(codec, WM8955_LOUT2_VOLUME,
  787. WM8955_LO2VU | WM8955_LO2ZC,
  788. WM8955_LO2VU | WM8955_LO2ZC);
  789. snd_soc_update_bits(codec, WM8955_ROUT2_VOLUME,
  790. WM8955_RO2VU | WM8955_RO2ZC,
  791. WM8955_RO2VU | WM8955_RO2ZC);
  792. snd_soc_update_bits(codec, WM8955_MONOOUT_VOLUME,
  793. WM8955_MOZC, WM8955_MOZC);
  794. /* Also enable adaptive bass boost by default */
  795. snd_soc_update_bits(codec, WM8955_BASS_CONTROL, WM8955_BB, WM8955_BB);
  796. /* Set platform data values */
  797. if (pdata) {
  798. if (pdata->out2_speaker)
  799. snd_soc_update_bits(codec, WM8955_ADDITIONAL_CONTROL_2,
  800. WM8955_ROUT2INV, WM8955_ROUT2INV);
  801. if (pdata->monoin_diff)
  802. snd_soc_update_bits(codec, WM8955_MONO_OUT_MIX_1,
  803. WM8955_DMEN, WM8955_DMEN);
  804. }
  805. wm8955_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
  806. /* Bias level configuration will have done an extra enable */
  807. regulator_bulk_disable(ARRAY_SIZE(wm8955->supplies), wm8955->supplies);
  808. return 0;
  809. err_enable:
  810. regulator_bulk_disable(ARRAY_SIZE(wm8955->supplies), wm8955->supplies);
  811. err_get:
  812. regulator_bulk_free(ARRAY_SIZE(wm8955->supplies), wm8955->supplies);
  813. return ret;
  814. }
  815. static int wm8955_remove(struct snd_soc_codec *codec)
  816. {
  817. struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
  818. wm8955_set_bias_level(codec, SND_SOC_BIAS_OFF);
  819. regulator_bulk_free(ARRAY_SIZE(wm8955->supplies), wm8955->supplies);
  820. return 0;
  821. }
  822. static struct snd_soc_codec_driver soc_codec_dev_wm8955 = {
  823. .probe = wm8955_probe,
  824. .remove = wm8955_remove,
  825. .suspend = wm8955_suspend,
  826. .resume = wm8955_resume,
  827. .set_bias_level = wm8955_set_bias_level,
  828. .controls = wm8955_snd_controls,
  829. .num_controls = ARRAY_SIZE(wm8955_snd_controls),
  830. .dapm_widgets = wm8955_dapm_widgets,
  831. .num_dapm_widgets = ARRAY_SIZE(wm8955_dapm_widgets),
  832. .dapm_routes = wm8955_dapm_routes,
  833. .num_dapm_routes = ARRAY_SIZE(wm8955_dapm_routes),
  834. };
  835. static const struct regmap_config wm8955_regmap = {
  836. .reg_bits = 7,
  837. .val_bits = 9,
  838. .max_register = WM8955_MAX_REGISTER,
  839. .volatile_reg = wm8955_volatile,
  840. .writeable_reg = wm8955_writeable,
  841. .cache_type = REGCACHE_RBTREE,
  842. .reg_defaults = wm8955_reg_defaults,
  843. .num_reg_defaults = ARRAY_SIZE(wm8955_reg_defaults),
  844. };
  845. static __devinit int wm8955_i2c_probe(struct i2c_client *i2c,
  846. const struct i2c_device_id *id)
  847. {
  848. struct wm8955_priv *wm8955;
  849. int ret;
  850. wm8955 = devm_kzalloc(&i2c->dev, sizeof(struct wm8955_priv),
  851. GFP_KERNEL);
  852. if (wm8955 == NULL)
  853. return -ENOMEM;
  854. wm8955->regmap = regmap_init_i2c(i2c, &wm8955_regmap);
  855. if (IS_ERR(wm8955->regmap)) {
  856. ret = PTR_ERR(wm8955->regmap);
  857. dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
  858. ret);
  859. return ret;
  860. }
  861. i2c_set_clientdata(i2c, wm8955);
  862. ret = snd_soc_register_codec(&i2c->dev,
  863. &soc_codec_dev_wm8955, &wm8955_dai, 1);
  864. if (ret != 0)
  865. goto err;
  866. return ret;
  867. err:
  868. regmap_exit(wm8955->regmap);
  869. return ret;
  870. }
  871. static __devexit int wm8955_i2c_remove(struct i2c_client *client)
  872. {
  873. struct wm8955_priv *wm8955 = i2c_get_clientdata(client);
  874. snd_soc_unregister_codec(&client->dev);
  875. regmap_exit(wm8955->regmap);
  876. return 0;
  877. }
  878. static const struct i2c_device_id wm8955_i2c_id[] = {
  879. { "wm8955", 0 },
  880. { }
  881. };
  882. MODULE_DEVICE_TABLE(i2c, wm8955_i2c_id);
  883. static struct i2c_driver wm8955_i2c_driver = {
  884. .driver = {
  885. .name = "wm8955",
  886. .owner = THIS_MODULE,
  887. },
  888. .probe = wm8955_i2c_probe,
  889. .remove = __devexit_p(wm8955_i2c_remove),
  890. .id_table = wm8955_i2c_id,
  891. };
  892. static int __init wm8955_modinit(void)
  893. {
  894. int ret = 0;
  895. ret = i2c_add_driver(&wm8955_i2c_driver);
  896. if (ret != 0) {
  897. printk(KERN_ERR "Failed to register WM8955 I2C driver: %d\n",
  898. ret);
  899. }
  900. return ret;
  901. }
  902. module_init(wm8955_modinit);
  903. static void __exit wm8955_exit(void)
  904. {
  905. i2c_del_driver(&wm8955_i2c_driver);
  906. }
  907. module_exit(wm8955_exit);
  908. MODULE_DESCRIPTION("ASoC WM8955 driver");
  909. MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
  910. MODULE_LICENSE("GPL");