wm8711.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /*
  2. * wm8711.c -- WM8711 ALSA SoC Audio driver
  3. *
  4. * Copyright 2006 Wolfson Microelectronics
  5. *
  6. * Author: Mike Arthur <linux@wolfsonmicro.com>
  7. *
  8. * Based on wm8731.c by Richard Purdie
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/moduleparam.h>
  16. #include <linux/init.h>
  17. #include <linux/delay.h>
  18. #include <linux/pm.h>
  19. #include <linux/i2c.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/spi/spi.h>
  22. #include <sound/core.h>
  23. #include <sound/pcm.h>
  24. #include <sound/pcm_params.h>
  25. #include <sound/soc.h>
  26. #include <sound/soc-dapm.h>
  27. #include <sound/tlv.h>
  28. #include <sound/initval.h>
  29. #include "wm8711.h"
  30. static struct snd_soc_codec *wm8711_codec;
  31. /* codec private data */
  32. struct wm8711_priv {
  33. struct snd_soc_codec codec;
  34. u16 reg_cache[WM8711_CACHEREGNUM];
  35. unsigned int sysclk;
  36. };
  37. /*
  38. * wm8711 register cache
  39. * We can't read the WM8711 register space when we are
  40. * using 2 wire for device control, so we cache them instead.
  41. * There is no point in caching the reset register
  42. */
  43. static const u16 wm8711_reg[WM8711_CACHEREGNUM] = {
  44. 0x0079, 0x0079, 0x000a, 0x0008,
  45. 0x009f, 0x000a, 0x0000, 0x0000
  46. };
  47. #define wm8711_reset(c) snd_soc_write(c, WM8711_RESET, 0)
  48. static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
  49. static const struct snd_kcontrol_new wm8711_snd_controls[] = {
  50. SOC_DOUBLE_R_TLV("Master Playback Volume", WM8711_LOUT1V, WM8711_ROUT1V,
  51. 0, 127, 0, out_tlv),
  52. SOC_DOUBLE_R("Master Playback ZC Switch", WM8711_LOUT1V, WM8711_ROUT1V,
  53. 7, 1, 0),
  54. };
  55. /* Output Mixer */
  56. static const struct snd_kcontrol_new wm8711_output_mixer_controls[] = {
  57. SOC_DAPM_SINGLE("Line Bypass Switch", WM8711_APANA, 3, 1, 0),
  58. SOC_DAPM_SINGLE("HiFi Playback Switch", WM8711_APANA, 4, 1, 0),
  59. };
  60. static const struct snd_soc_dapm_widget wm8711_dapm_widgets[] = {
  61. SND_SOC_DAPM_MIXER("Output Mixer", WM8711_PWR, 4, 1,
  62. &wm8711_output_mixer_controls[0],
  63. ARRAY_SIZE(wm8711_output_mixer_controls)),
  64. SND_SOC_DAPM_DAC("DAC", "HiFi Playback", WM8711_PWR, 3, 1),
  65. SND_SOC_DAPM_OUTPUT("LOUT"),
  66. SND_SOC_DAPM_OUTPUT("LHPOUT"),
  67. SND_SOC_DAPM_OUTPUT("ROUT"),
  68. SND_SOC_DAPM_OUTPUT("RHPOUT"),
  69. };
  70. static const struct snd_soc_dapm_route intercon[] = {
  71. /* output mixer */
  72. {"Output Mixer", "Line Bypass Switch", "Line Input"},
  73. {"Output Mixer", "HiFi Playback Switch", "DAC"},
  74. /* outputs */
  75. {"RHPOUT", NULL, "Output Mixer"},
  76. {"ROUT", NULL, "Output Mixer"},
  77. {"LHPOUT", NULL, "Output Mixer"},
  78. {"LOUT", NULL, "Output Mixer"},
  79. };
  80. static int wm8711_add_widgets(struct snd_soc_codec *codec)
  81. {
  82. snd_soc_dapm_new_controls(codec, wm8711_dapm_widgets,
  83. ARRAY_SIZE(wm8711_dapm_widgets));
  84. snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon));
  85. snd_soc_dapm_new_widgets(codec);
  86. return 0;
  87. }
  88. struct _coeff_div {
  89. u32 mclk;
  90. u32 rate;
  91. u16 fs;
  92. u8 sr:4;
  93. u8 bosr:1;
  94. u8 usb:1;
  95. };
  96. /* codec mclk clock divider coefficients */
  97. static const struct _coeff_div coeff_div[] = {
  98. /* 48k */
  99. {12288000, 48000, 256, 0x0, 0x0, 0x0},
  100. {18432000, 48000, 384, 0x0, 0x1, 0x0},
  101. {12000000, 48000, 250, 0x0, 0x0, 0x1},
  102. /* 32k */
  103. {12288000, 32000, 384, 0x6, 0x0, 0x0},
  104. {18432000, 32000, 576, 0x6, 0x1, 0x0},
  105. {12000000, 32000, 375, 0x6, 0x0, 0x1},
  106. /* 8k */
  107. {12288000, 8000, 1536, 0x3, 0x0, 0x0},
  108. {18432000, 8000, 2304, 0x3, 0x1, 0x0},
  109. {11289600, 8000, 1408, 0xb, 0x0, 0x0},
  110. {16934400, 8000, 2112, 0xb, 0x1, 0x0},
  111. {12000000, 8000, 1500, 0x3, 0x0, 0x1},
  112. /* 96k */
  113. {12288000, 96000, 128, 0x7, 0x0, 0x0},
  114. {18432000, 96000, 192, 0x7, 0x1, 0x0},
  115. {12000000, 96000, 125, 0x7, 0x0, 0x1},
  116. /* 44.1k */
  117. {11289600, 44100, 256, 0x8, 0x0, 0x0},
  118. {16934400, 44100, 384, 0x8, 0x1, 0x0},
  119. {12000000, 44100, 272, 0x8, 0x1, 0x1},
  120. /* 88.2k */
  121. {11289600, 88200, 128, 0xf, 0x0, 0x0},
  122. {16934400, 88200, 192, 0xf, 0x1, 0x0},
  123. {12000000, 88200, 136, 0xf, 0x1, 0x1},
  124. };
  125. static inline int get_coeff(int mclk, int rate)
  126. {
  127. int i;
  128. for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
  129. if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
  130. return i;
  131. }
  132. return 0;
  133. }
  134. static int wm8711_hw_params(struct snd_pcm_substream *substream,
  135. struct snd_pcm_hw_params *params,
  136. struct snd_soc_dai *dai)
  137. {
  138. struct snd_soc_codec *codec = dai->codec;
  139. struct wm8711_priv *wm8711 = codec->private_data;
  140. u16 iface = snd_soc_read(codec, WM8711_IFACE) & 0xfffc;
  141. int i = get_coeff(wm8711->sysclk, params_rate(params));
  142. u16 srate = (coeff_div[i].sr << 2) |
  143. (coeff_div[i].bosr << 1) | coeff_div[i].usb;
  144. snd_soc_write(codec, WM8711_SRATE, srate);
  145. /* bit size */
  146. switch (params_format(params)) {
  147. case SNDRV_PCM_FORMAT_S16_LE:
  148. break;
  149. case SNDRV_PCM_FORMAT_S20_3LE:
  150. iface |= 0x0004;
  151. break;
  152. case SNDRV_PCM_FORMAT_S24_LE:
  153. iface |= 0x0008;
  154. break;
  155. }
  156. snd_soc_write(codec, WM8711_IFACE, iface);
  157. return 0;
  158. }
  159. static int wm8711_pcm_prepare(struct snd_pcm_substream *substream,
  160. struct snd_soc_dai *dai)
  161. {
  162. struct snd_soc_codec *codec = dai->codec;
  163. /* set active */
  164. snd_soc_write(codec, WM8711_ACTIVE, 0x0001);
  165. return 0;
  166. }
  167. static void wm8711_shutdown(struct snd_pcm_substream *substream,
  168. struct snd_soc_dai *dai)
  169. {
  170. struct snd_soc_codec *codec = dai->codec;
  171. /* deactivate */
  172. if (!codec->active) {
  173. udelay(50);
  174. snd_soc_write(codec, WM8711_ACTIVE, 0x0);
  175. }
  176. }
  177. static int wm8711_mute(struct snd_soc_dai *dai, int mute)
  178. {
  179. struct snd_soc_codec *codec = dai->codec;
  180. u16 mute_reg = snd_soc_read(codec, WM8711_APDIGI) & 0xfff7;
  181. if (mute)
  182. snd_soc_write(codec, WM8711_APDIGI, mute_reg | 0x8);
  183. else
  184. snd_soc_write(codec, WM8711_APDIGI, mute_reg);
  185. return 0;
  186. }
  187. static int wm8711_set_dai_sysclk(struct snd_soc_dai *codec_dai,
  188. int clk_id, unsigned int freq, int dir)
  189. {
  190. struct snd_soc_codec *codec = codec_dai->codec;
  191. struct wm8711_priv *wm8711 = codec->private_data;
  192. switch (freq) {
  193. case 11289600:
  194. case 12000000:
  195. case 12288000:
  196. case 16934400:
  197. case 18432000:
  198. wm8711->sysclk = freq;
  199. return 0;
  200. }
  201. return -EINVAL;
  202. }
  203. static int wm8711_set_dai_fmt(struct snd_soc_dai *codec_dai,
  204. unsigned int fmt)
  205. {
  206. struct snd_soc_codec *codec = codec_dai->codec;
  207. u16 iface = 0;
  208. /* set master/slave audio interface */
  209. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  210. case SND_SOC_DAIFMT_CBM_CFM:
  211. iface |= 0x0040;
  212. break;
  213. case SND_SOC_DAIFMT_CBS_CFS:
  214. break;
  215. default:
  216. return -EINVAL;
  217. }
  218. /* interface format */
  219. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  220. case SND_SOC_DAIFMT_I2S:
  221. iface |= 0x0002;
  222. break;
  223. case SND_SOC_DAIFMT_RIGHT_J:
  224. break;
  225. case SND_SOC_DAIFMT_LEFT_J:
  226. iface |= 0x0001;
  227. break;
  228. case SND_SOC_DAIFMT_DSP_A:
  229. iface |= 0x0003;
  230. break;
  231. case SND_SOC_DAIFMT_DSP_B:
  232. iface |= 0x0013;
  233. break;
  234. default:
  235. return -EINVAL;
  236. }
  237. /* clock inversion */
  238. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  239. case SND_SOC_DAIFMT_NB_NF:
  240. break;
  241. case SND_SOC_DAIFMT_IB_IF:
  242. iface |= 0x0090;
  243. break;
  244. case SND_SOC_DAIFMT_IB_NF:
  245. iface |= 0x0080;
  246. break;
  247. case SND_SOC_DAIFMT_NB_IF:
  248. iface |= 0x0010;
  249. break;
  250. default:
  251. return -EINVAL;
  252. }
  253. /* set iface */
  254. snd_soc_write(codec, WM8711_IFACE, iface);
  255. return 0;
  256. }
  257. static int wm8711_set_bias_level(struct snd_soc_codec *codec,
  258. enum snd_soc_bias_level level)
  259. {
  260. u16 reg = snd_soc_read(codec, WM8711_PWR) & 0xff7f;
  261. switch (level) {
  262. case SND_SOC_BIAS_ON:
  263. snd_soc_write(codec, WM8711_PWR, reg);
  264. break;
  265. case SND_SOC_BIAS_PREPARE:
  266. break;
  267. case SND_SOC_BIAS_STANDBY:
  268. snd_soc_write(codec, WM8711_PWR, reg | 0x0040);
  269. break;
  270. case SND_SOC_BIAS_OFF:
  271. snd_soc_write(codec, WM8711_ACTIVE, 0x0);
  272. snd_soc_write(codec, WM8711_PWR, 0xffff);
  273. break;
  274. }
  275. codec->bias_level = level;
  276. return 0;
  277. }
  278. #define WM8711_RATES SNDRV_PCM_RATE_8000_96000
  279. #define WM8711_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
  280. SNDRV_PCM_FMTBIT_S24_LE)
  281. static struct snd_soc_dai_ops wm8711_ops = {
  282. .prepare = wm8711_pcm_prepare,
  283. .hw_params = wm8711_hw_params,
  284. .shutdown = wm8711_shutdown,
  285. .digital_mute = wm8711_mute,
  286. .set_sysclk = wm8711_set_dai_sysclk,
  287. .set_fmt = wm8711_set_dai_fmt,
  288. };
  289. struct snd_soc_dai wm8711_dai = {
  290. .name = "WM8711",
  291. .playback = {
  292. .stream_name = "Playback",
  293. .channels_min = 1,
  294. .channels_max = 2,
  295. .rates = WM8711_RATES,
  296. .formats = WM8711_FORMATS,
  297. },
  298. .ops = &wm8711_ops,
  299. };
  300. EXPORT_SYMBOL_GPL(wm8711_dai);
  301. static int wm8711_suspend(struct platform_device *pdev, pm_message_t state)
  302. {
  303. struct snd_soc_device *socdev = platform_get_drvdata(pdev);
  304. struct snd_soc_codec *codec = socdev->card->codec;
  305. snd_soc_write(codec, WM8711_ACTIVE, 0x0);
  306. wm8711_set_bias_level(codec, SND_SOC_BIAS_OFF);
  307. return 0;
  308. }
  309. static int wm8711_resume(struct platform_device *pdev)
  310. {
  311. struct snd_soc_device *socdev = platform_get_drvdata(pdev);
  312. struct snd_soc_codec *codec = socdev->card->codec;
  313. int i;
  314. u8 data[2];
  315. u16 *cache = codec->reg_cache;
  316. /* Sync reg_cache with the hardware */
  317. for (i = 0; i < ARRAY_SIZE(wm8711_reg); i++) {
  318. data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001);
  319. data[1] = cache[i] & 0x00ff;
  320. codec->hw_write(codec->control_data, data, 2);
  321. }
  322. wm8711_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
  323. wm8711_set_bias_level(codec, codec->suspend_bias_level);
  324. return 0;
  325. }
  326. static int wm8711_probe(struct platform_device *pdev)
  327. {
  328. struct snd_soc_device *socdev = platform_get_drvdata(pdev);
  329. struct snd_soc_codec *codec;
  330. int ret = 0;
  331. if (wm8711_codec == NULL) {
  332. dev_err(&pdev->dev, "Codec device not registered\n");
  333. return -ENODEV;
  334. }
  335. socdev->card->codec = wm8711_codec;
  336. codec = wm8711_codec;
  337. /* register pcms */
  338. ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
  339. if (ret < 0) {
  340. dev_err(codec->dev, "failed to create pcms: %d\n", ret);
  341. goto pcm_err;
  342. }
  343. snd_soc_add_controls(codec, wm8711_snd_controls,
  344. ARRAY_SIZE(wm8711_snd_controls));
  345. wm8711_add_widgets(codec);
  346. ret = snd_soc_init_card(socdev);
  347. if (ret < 0) {
  348. dev_err(codec->dev, "failed to register card: %d\n", ret);
  349. goto card_err;
  350. }
  351. return ret;
  352. card_err:
  353. snd_soc_free_pcms(socdev);
  354. snd_soc_dapm_free(socdev);
  355. pcm_err:
  356. return ret;
  357. }
  358. /* power down chip */
  359. static int wm8711_remove(struct platform_device *pdev)
  360. {
  361. struct snd_soc_device *socdev = platform_get_drvdata(pdev);
  362. snd_soc_free_pcms(socdev);
  363. snd_soc_dapm_free(socdev);
  364. return 0;
  365. }
  366. struct snd_soc_codec_device soc_codec_dev_wm8711 = {
  367. .probe = wm8711_probe,
  368. .remove = wm8711_remove,
  369. .suspend = wm8711_suspend,
  370. .resume = wm8711_resume,
  371. };
  372. EXPORT_SYMBOL_GPL(soc_codec_dev_wm8711);
  373. static int wm8711_register(struct wm8711_priv *wm8711,
  374. enum snd_soc_control_type control)
  375. {
  376. int ret;
  377. struct snd_soc_codec *codec = &wm8711->codec;
  378. u16 reg;
  379. if (wm8711_codec) {
  380. dev_err(codec->dev, "Another WM8711 is registered\n");
  381. return -EINVAL;
  382. }
  383. mutex_init(&codec->mutex);
  384. INIT_LIST_HEAD(&codec->dapm_widgets);
  385. INIT_LIST_HEAD(&codec->dapm_paths);
  386. codec->private_data = wm8711;
  387. codec->name = "WM8711";
  388. codec->owner = THIS_MODULE;
  389. codec->bias_level = SND_SOC_BIAS_OFF;
  390. codec->set_bias_level = wm8711_set_bias_level;
  391. codec->dai = &wm8711_dai;
  392. codec->num_dai = 1;
  393. codec->reg_cache_size = WM8711_CACHEREGNUM;
  394. codec->reg_cache = &wm8711->reg_cache;
  395. memcpy(codec->reg_cache, wm8711_reg, sizeof(wm8711_reg));
  396. ret = snd_soc_codec_set_cache_io(codec, 7, 9, control);
  397. if (ret < 0) {
  398. dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
  399. goto err;
  400. }
  401. ret = wm8711_reset(codec);
  402. if (ret < 0) {
  403. dev_err(codec->dev, "Failed to issue reset\n");
  404. goto err;
  405. }
  406. wm8711_dai.dev = codec->dev;
  407. wm8711_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
  408. /* Latch the update bits */
  409. reg = snd_soc_read(codec, WM8711_LOUT1V);
  410. snd_soc_write(codec, WM8711_LOUT1V, reg | 0x0100);
  411. reg = snd_soc_read(codec, WM8711_ROUT1V);
  412. snd_soc_write(codec, WM8711_ROUT1V, reg | 0x0100);
  413. wm8711_codec = codec;
  414. ret = snd_soc_register_codec(codec);
  415. if (ret != 0) {
  416. dev_err(codec->dev, "Failed to register codec: %d\n", ret);
  417. goto err;
  418. }
  419. ret = snd_soc_register_dai(&wm8711_dai);
  420. if (ret != 0) {
  421. dev_err(codec->dev, "Failed to register DAI: %d\n", ret);
  422. goto err_codec;
  423. }
  424. return 0;
  425. err_codec:
  426. snd_soc_unregister_codec(codec);
  427. err:
  428. kfree(wm8711);
  429. return ret;
  430. }
  431. static void wm8711_unregister(struct wm8711_priv *wm8711)
  432. {
  433. wm8711_set_bias_level(&wm8711->codec, SND_SOC_BIAS_OFF);
  434. snd_soc_unregister_dai(&wm8711_dai);
  435. snd_soc_unregister_codec(&wm8711->codec);
  436. kfree(wm8711);
  437. wm8711_codec = NULL;
  438. }
  439. #if defined(CONFIG_SPI_MASTER)
  440. static int __devinit wm8711_spi_probe(struct spi_device *spi)
  441. {
  442. struct snd_soc_codec *codec;
  443. struct wm8711_priv *wm8711;
  444. wm8711 = kzalloc(sizeof(struct wm8711_priv), GFP_KERNEL);
  445. if (wm8711 == NULL)
  446. return -ENOMEM;
  447. codec = &wm8711->codec;
  448. codec->control_data = spi;
  449. codec->dev = &spi->dev;
  450. dev_set_drvdata(&spi->dev, wm8711);
  451. return wm8711_register(wm8711, SND_SOC_SPI);
  452. }
  453. static int __devexit wm8711_spi_remove(struct spi_device *spi)
  454. {
  455. struct wm8711_priv *wm8711 = dev_get_drvdata(&spi->dev);
  456. wm8711_unregister(wm8711);
  457. return 0;
  458. }
  459. static struct spi_driver wm8711_spi_driver = {
  460. .driver = {
  461. .name = "wm8711",
  462. .bus = &spi_bus_type,
  463. .owner = THIS_MODULE,
  464. },
  465. .probe = wm8711_spi_probe,
  466. .remove = __devexit_p(wm8711_spi_remove),
  467. };
  468. #endif /* CONFIG_SPI_MASTER */
  469. #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
  470. static __devinit int wm8711_i2c_probe(struct i2c_client *i2c,
  471. const struct i2c_device_id *id)
  472. {
  473. struct wm8711_priv *wm8711;
  474. struct snd_soc_codec *codec;
  475. wm8711 = kzalloc(sizeof(struct wm8711_priv), GFP_KERNEL);
  476. if (wm8711 == NULL)
  477. return -ENOMEM;
  478. codec = &wm8711->codec;
  479. codec->hw_write = (hw_write_t)i2c_master_send;
  480. i2c_set_clientdata(i2c, wm8711);
  481. codec->control_data = i2c;
  482. codec->dev = &i2c->dev;
  483. return wm8711_register(wm8711, SND_SOC_I2C);
  484. }
  485. static __devexit int wm8711_i2c_remove(struct i2c_client *client)
  486. {
  487. struct wm8711_priv *wm8711 = i2c_get_clientdata(client);
  488. wm8711_unregister(wm8711);
  489. return 0;
  490. }
  491. static const struct i2c_device_id wm8711_i2c_id[] = {
  492. { "wm8711", 0 },
  493. { }
  494. };
  495. MODULE_DEVICE_TABLE(i2c, wm8711_i2c_id);
  496. static struct i2c_driver wm8711_i2c_driver = {
  497. .driver = {
  498. .name = "WM8711 I2C Codec",
  499. .owner = THIS_MODULE,
  500. },
  501. .probe = wm8711_i2c_probe,
  502. .remove = __devexit_p(wm8711_i2c_remove),
  503. .id_table = wm8711_i2c_id,
  504. };
  505. #endif
  506. static int __init wm8711_modinit(void)
  507. {
  508. int ret;
  509. #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
  510. ret = i2c_add_driver(&wm8711_i2c_driver);
  511. if (ret != 0) {
  512. printk(KERN_ERR "Failed to register WM8711 I2C driver: %d\n",
  513. ret);
  514. }
  515. #endif
  516. #if defined(CONFIG_SPI_MASTER)
  517. ret = spi_register_driver(&wm8711_spi_driver);
  518. if (ret != 0) {
  519. printk(KERN_ERR "Failed to register WM8711 SPI driver: %d\n",
  520. ret);
  521. }
  522. #endif
  523. return 0;
  524. }
  525. module_init(wm8711_modinit);
  526. static void __exit wm8711_exit(void)
  527. {
  528. #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
  529. i2c_del_driver(&wm8711_i2c_driver);
  530. #endif
  531. #if defined(CONFIG_SPI_MASTER)
  532. spi_unregister_driver(&wm8711_spi_driver);
  533. #endif
  534. }
  535. module_exit(wm8711_exit);
  536. MODULE_DESCRIPTION("ASoC WM8711 driver");
  537. MODULE_AUTHOR("Mike Arthur");
  538. MODULE_LICENSE("GPL");