wm8994-core.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /*
  2. * wm8994-core.c -- Device access for Wolfson WM8994
  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 it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/slab.h>
  17. #include <linux/i2c.h>
  18. #include <linux/err.h>
  19. #include <linux/delay.h>
  20. #include <linux/mfd/core.h>
  21. #include <linux/pm_runtime.h>
  22. #include <linux/regmap.h>
  23. #include <linux/regulator/consumer.h>
  24. #include <linux/regulator/machine.h>
  25. #include <linux/mfd/wm8994/core.h>
  26. #include <linux/mfd/wm8994/pdata.h>
  27. #include <linux/mfd/wm8994/registers.h>
  28. static int wm8994_read(struct wm8994 *wm8994, unsigned short reg,
  29. int bytes, void *dest)
  30. {
  31. return regmap_raw_read(wm8994->regmap, reg, dest, bytes);
  32. }
  33. /**
  34. * wm8994_reg_read: Read a single WM8994 register.
  35. *
  36. * @wm8994: Device to read from.
  37. * @reg: Register to read.
  38. */
  39. int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg)
  40. {
  41. unsigned int val;
  42. int ret;
  43. ret = regmap_read(wm8994->regmap, reg, &val);
  44. if (ret < 0)
  45. return ret;
  46. else
  47. return val;
  48. }
  49. EXPORT_SYMBOL_GPL(wm8994_reg_read);
  50. /**
  51. * wm8994_bulk_read: Read multiple WM8994 registers
  52. *
  53. * @wm8994: Device to read from
  54. * @reg: First register
  55. * @count: Number of registers
  56. * @buf: Buffer to fill. The data will be returned big endian.
  57. */
  58. int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
  59. int count, u16 *buf)
  60. {
  61. return regmap_bulk_read(wm8994->regmap, reg, buf, count);
  62. }
  63. static int wm8994_write(struct wm8994 *wm8994, unsigned short reg,
  64. int bytes, const void *src)
  65. {
  66. return regmap_raw_write(wm8994->regmap, reg, src, bytes);
  67. }
  68. /**
  69. * wm8994_reg_write: Write a single WM8994 register.
  70. *
  71. * @wm8994: Device to write to.
  72. * @reg: Register to write to.
  73. * @val: Value to write.
  74. */
  75. int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg,
  76. unsigned short val)
  77. {
  78. return regmap_write(wm8994->regmap, reg, val);
  79. }
  80. EXPORT_SYMBOL_GPL(wm8994_reg_write);
  81. /**
  82. * wm8994_bulk_write: Write multiple WM8994 registers
  83. *
  84. * @wm8994: Device to write to
  85. * @reg: First register
  86. * @count: Number of registers
  87. * @buf: Buffer to write from. Data must be big-endian formatted.
  88. */
  89. int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg,
  90. int count, const u16 *buf)
  91. {
  92. return regmap_raw_write(wm8994->regmap, reg, buf, count * sizeof(u16));
  93. }
  94. EXPORT_SYMBOL_GPL(wm8994_bulk_write);
  95. /**
  96. * wm8994_set_bits: Set the value of a bitfield in a WM8994 register
  97. *
  98. * @wm8994: Device to write to.
  99. * @reg: Register to write to.
  100. * @mask: Mask of bits to set.
  101. * @val: Value to set (unshifted)
  102. */
  103. int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
  104. unsigned short mask, unsigned short val)
  105. {
  106. return regmap_update_bits(wm8994->regmap, reg, mask, val);
  107. }
  108. EXPORT_SYMBOL_GPL(wm8994_set_bits);
  109. static struct mfd_cell wm8994_regulator_devs[] = {
  110. {
  111. .name = "wm8994-ldo",
  112. .id = 1,
  113. .pm_runtime_no_callbacks = true,
  114. },
  115. {
  116. .name = "wm8994-ldo",
  117. .id = 2,
  118. .pm_runtime_no_callbacks = true,
  119. },
  120. };
  121. static struct resource wm8994_codec_resources[] = {
  122. {
  123. .start = WM8994_IRQ_TEMP_SHUT,
  124. .end = WM8994_IRQ_TEMP_WARN,
  125. .flags = IORESOURCE_IRQ,
  126. },
  127. };
  128. static struct resource wm8994_gpio_resources[] = {
  129. {
  130. .start = WM8994_IRQ_GPIO(1),
  131. .end = WM8994_IRQ_GPIO(11),
  132. .flags = IORESOURCE_IRQ,
  133. },
  134. };
  135. static struct mfd_cell wm8994_devs[] = {
  136. {
  137. .name = "wm8994-codec",
  138. .num_resources = ARRAY_SIZE(wm8994_codec_resources),
  139. .resources = wm8994_codec_resources,
  140. },
  141. {
  142. .name = "wm8994-gpio",
  143. .num_resources = ARRAY_SIZE(wm8994_gpio_resources),
  144. .resources = wm8994_gpio_resources,
  145. .pm_runtime_no_callbacks = true,
  146. },
  147. };
  148. /*
  149. * Supplies for the main bulk of CODEC; the LDO supplies are ignored
  150. * and should be handled via the standard regulator API supply
  151. * management.
  152. */
  153. static const char *wm1811_main_supplies[] = {
  154. "DBVDD1",
  155. "DBVDD2",
  156. "DBVDD3",
  157. "DCVDD",
  158. "AVDD1",
  159. "AVDD2",
  160. "CPVDD",
  161. "SPKVDD1",
  162. "SPKVDD2",
  163. };
  164. static const char *wm8994_main_supplies[] = {
  165. "DBVDD",
  166. "DCVDD",
  167. "AVDD1",
  168. "AVDD2",
  169. "CPVDD",
  170. "SPKVDD1",
  171. "SPKVDD2",
  172. };
  173. static const char *wm8958_main_supplies[] = {
  174. "DBVDD1",
  175. "DBVDD2",
  176. "DBVDD3",
  177. "DCVDD",
  178. "AVDD1",
  179. "AVDD2",
  180. "CPVDD",
  181. "SPKVDD1",
  182. "SPKVDD2",
  183. };
  184. #ifdef CONFIG_PM
  185. static int wm8994_suspend(struct device *dev)
  186. {
  187. struct wm8994 *wm8994 = dev_get_drvdata(dev);
  188. int ret;
  189. /* Don't actually go through with the suspend if the CODEC is
  190. * still active (eg, for audio passthrough from CP. */
  191. ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_1);
  192. if (ret < 0) {
  193. dev_err(dev, "Failed to read power status: %d\n", ret);
  194. } else if (ret & WM8994_VMID_SEL_MASK) {
  195. dev_dbg(dev, "CODEC still active, ignoring suspend\n");
  196. return 0;
  197. }
  198. ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_4);
  199. if (ret < 0) {
  200. dev_err(dev, "Failed to read power status: %d\n", ret);
  201. } else if (ret & (WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA |
  202. WM8994_AIF1ADC2L_ENA | WM8994_AIF1ADC2R_ENA |
  203. WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC1R_ENA)) {
  204. dev_dbg(dev, "CODEC still active, ignoring suspend\n");
  205. return 0;
  206. }
  207. ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_5);
  208. if (ret < 0) {
  209. dev_err(dev, "Failed to read power status: %d\n", ret);
  210. } else if (ret & (WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA |
  211. WM8994_AIF1DAC2L_ENA | WM8994_AIF1DAC2R_ENA |
  212. WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA)) {
  213. dev_dbg(dev, "CODEC still active, ignoring suspend\n");
  214. return 0;
  215. }
  216. switch (wm8994->type) {
  217. case WM8958:
  218. case WM1811:
  219. ret = wm8994_reg_read(wm8994, WM8958_MIC_DETECT_1);
  220. if (ret < 0) {
  221. dev_err(dev, "Failed to read power status: %d\n", ret);
  222. } else if (ret & WM8958_MICD_ENA) {
  223. dev_dbg(dev, "CODEC still active, ignoring suspend\n");
  224. return 0;
  225. }
  226. break;
  227. default:
  228. break;
  229. }
  230. /* Disable LDO pulldowns while the device is suspended if we
  231. * don't know that something will be driving them. */
  232. if (!wm8994->ldo_ena_always_driven)
  233. wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2,
  234. WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD,
  235. WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD);
  236. /* GPIO configuration state is saved here since we may be configuring
  237. * the GPIO alternate functions even if we're not using the gpiolib
  238. * driver for them.
  239. */
  240. ret = wm8994_read(wm8994, WM8994_GPIO_1, WM8994_NUM_GPIO_REGS * 2,
  241. &wm8994->gpio_regs);
  242. if (ret < 0)
  243. dev_err(dev, "Failed to save GPIO registers: %d\n", ret);
  244. /* For similar reasons we also stash the regulator states */
  245. ret = wm8994_read(wm8994, WM8994_LDO_1, WM8994_NUM_LDO_REGS * 2,
  246. &wm8994->ldo_regs);
  247. if (ret < 0)
  248. dev_err(dev, "Failed to save LDO registers: %d\n", ret);
  249. /* Explicitly put the device into reset in case regulators
  250. * don't get disabled in order to ensure consistent restart.
  251. */
  252. wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET, 0x8994);
  253. wm8994->suspended = true;
  254. ret = regulator_bulk_disable(wm8994->num_supplies,
  255. wm8994->supplies);
  256. if (ret != 0) {
  257. dev_err(dev, "Failed to disable supplies: %d\n", ret);
  258. return ret;
  259. }
  260. return 0;
  261. }
  262. static int wm8994_resume(struct device *dev)
  263. {
  264. struct wm8994 *wm8994 = dev_get_drvdata(dev);
  265. int ret, i;
  266. /* We may have lied to the PM core about suspending */
  267. if (!wm8994->suspended)
  268. return 0;
  269. ret = regulator_bulk_enable(wm8994->num_supplies,
  270. wm8994->supplies);
  271. if (ret != 0) {
  272. dev_err(dev, "Failed to enable supplies: %d\n", ret);
  273. return ret;
  274. }
  275. /* Write register at a time as we use the cache on the CPU so store
  276. * it in native endian.
  277. */
  278. for (i = 0; i < ARRAY_SIZE(wm8994->irq_masks_cur); i++) {
  279. ret = wm8994_reg_write(wm8994, WM8994_INTERRUPT_STATUS_1_MASK
  280. + i, wm8994->irq_masks_cur[i]);
  281. if (ret < 0)
  282. dev_err(dev, "Failed to restore interrupt masks: %d\n",
  283. ret);
  284. }
  285. ret = wm8994_write(wm8994, WM8994_LDO_1, WM8994_NUM_LDO_REGS * 2,
  286. &wm8994->ldo_regs);
  287. if (ret < 0)
  288. dev_err(dev, "Failed to restore LDO registers: %d\n", ret);
  289. ret = wm8994_write(wm8994, WM8994_GPIO_1, WM8994_NUM_GPIO_REGS * 2,
  290. &wm8994->gpio_regs);
  291. if (ret < 0)
  292. dev_err(dev, "Failed to restore GPIO registers: %d\n", ret);
  293. /* Disable LDO pulldowns while the device is active */
  294. wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2,
  295. WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD,
  296. 0);
  297. wm8994->suspended = false;
  298. return 0;
  299. }
  300. #endif
  301. #ifdef CONFIG_REGULATOR
  302. static int wm8994_ldo_in_use(struct wm8994_pdata *pdata, int ldo)
  303. {
  304. struct wm8994_ldo_pdata *ldo_pdata;
  305. if (!pdata)
  306. return 0;
  307. ldo_pdata = &pdata->ldo[ldo];
  308. if (!ldo_pdata->init_data)
  309. return 0;
  310. return ldo_pdata->init_data->num_consumer_supplies != 0;
  311. }
  312. #else
  313. static int wm8994_ldo_in_use(struct wm8994_pdata *pdata, int ldo)
  314. {
  315. return 0;
  316. }
  317. #endif
  318. static struct regmap_config wm8994_regmap_config = {
  319. .reg_bits = 16,
  320. .val_bits = 16,
  321. };
  322. /*
  323. * Instantiate the generic non-control parts of the device.
  324. */
  325. static int wm8994_device_init(struct wm8994 *wm8994, int irq)
  326. {
  327. struct wm8994_pdata *pdata = wm8994->dev->platform_data;
  328. const char *devname;
  329. int ret, i;
  330. int pulls = 0;
  331. dev_set_drvdata(wm8994->dev, wm8994);
  332. /* Add the on-chip regulators first for bootstrapping */
  333. ret = mfd_add_devices(wm8994->dev, -1,
  334. wm8994_regulator_devs,
  335. ARRAY_SIZE(wm8994_regulator_devs),
  336. NULL, 0);
  337. if (ret != 0) {
  338. dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
  339. goto err_regmap;
  340. }
  341. switch (wm8994->type) {
  342. case WM1811:
  343. wm8994->num_supplies = ARRAY_SIZE(wm1811_main_supplies);
  344. break;
  345. case WM8994:
  346. wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies);
  347. break;
  348. case WM8958:
  349. wm8994->num_supplies = ARRAY_SIZE(wm8958_main_supplies);
  350. break;
  351. default:
  352. BUG();
  353. goto err_regmap;
  354. }
  355. wm8994->supplies = devm_kzalloc(wm8994->dev,
  356. sizeof(struct regulator_bulk_data) *
  357. wm8994->num_supplies, GFP_KERNEL);
  358. if (!wm8994->supplies) {
  359. ret = -ENOMEM;
  360. goto err_regmap;
  361. }
  362. switch (wm8994->type) {
  363. case WM1811:
  364. for (i = 0; i < ARRAY_SIZE(wm1811_main_supplies); i++)
  365. wm8994->supplies[i].supply = wm1811_main_supplies[i];
  366. break;
  367. case WM8994:
  368. for (i = 0; i < ARRAY_SIZE(wm8994_main_supplies); i++)
  369. wm8994->supplies[i].supply = wm8994_main_supplies[i];
  370. break;
  371. case WM8958:
  372. for (i = 0; i < ARRAY_SIZE(wm8958_main_supplies); i++)
  373. wm8994->supplies[i].supply = wm8958_main_supplies[i];
  374. break;
  375. default:
  376. BUG();
  377. goto err_regmap;
  378. }
  379. ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies,
  380. wm8994->supplies);
  381. if (ret != 0) {
  382. dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret);
  383. goto err_regmap;
  384. }
  385. ret = regulator_bulk_enable(wm8994->num_supplies,
  386. wm8994->supplies);
  387. if (ret != 0) {
  388. dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret);
  389. goto err_get;
  390. }
  391. ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET);
  392. if (ret < 0) {
  393. dev_err(wm8994->dev, "Failed to read ID register\n");
  394. goto err_enable;
  395. }
  396. switch (ret) {
  397. case 0x1811:
  398. devname = "WM1811";
  399. if (wm8994->type != WM1811)
  400. dev_warn(wm8994->dev, "Device registered as type %d\n",
  401. wm8994->type);
  402. wm8994->type = WM1811;
  403. break;
  404. case 0x8994:
  405. devname = "WM8994";
  406. if (wm8994->type != WM8994)
  407. dev_warn(wm8994->dev, "Device registered as type %d\n",
  408. wm8994->type);
  409. wm8994->type = WM8994;
  410. break;
  411. case 0x8958:
  412. devname = "WM8958";
  413. if (wm8994->type != WM8958)
  414. dev_warn(wm8994->dev, "Device registered as type %d\n",
  415. wm8994->type);
  416. wm8994->type = WM8958;
  417. break;
  418. default:
  419. dev_err(wm8994->dev, "Device is not a WM8994, ID is %x\n",
  420. ret);
  421. ret = -EINVAL;
  422. goto err_enable;
  423. }
  424. ret = wm8994_reg_read(wm8994, WM8994_CHIP_REVISION);
  425. if (ret < 0) {
  426. dev_err(wm8994->dev, "Failed to read revision register: %d\n",
  427. ret);
  428. goto err_enable;
  429. }
  430. switch (wm8994->type) {
  431. case WM8994:
  432. switch (ret) {
  433. case 0:
  434. case 1:
  435. dev_warn(wm8994->dev,
  436. "revision %c not fully supported\n",
  437. 'A' + ret);
  438. break;
  439. default:
  440. break;
  441. }
  442. break;
  443. default:
  444. break;
  445. }
  446. dev_info(wm8994->dev, "%s revision %c\n", devname, 'A' + ret);
  447. if (pdata) {
  448. wm8994->irq_base = pdata->irq_base;
  449. wm8994->gpio_base = pdata->gpio_base;
  450. /* GPIO configuration is only applied if it's non-zero */
  451. for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
  452. if (pdata->gpio_defaults[i]) {
  453. wm8994_set_bits(wm8994, WM8994_GPIO_1 + i,
  454. 0xffff,
  455. pdata->gpio_defaults[i]);
  456. }
  457. }
  458. wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven;
  459. if (pdata->spkmode_pu)
  460. pulls |= WM8994_SPKMODE_PU;
  461. }
  462. /* Disable unneeded pulls */
  463. wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2,
  464. WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD |
  465. WM8994_SPKMODE_PU | WM8994_CSNADDR_PD,
  466. pulls);
  467. /* In some system designs where the regulators are not in use,
  468. * we can achieve a small reduction in leakage currents by
  469. * floating LDO outputs. This bit makes no difference if the
  470. * LDOs are enabled, it only affects cases where the LDOs were
  471. * in operation and are then disabled.
  472. */
  473. for (i = 0; i < WM8994_NUM_LDO_REGS; i++) {
  474. if (wm8994_ldo_in_use(pdata, i))
  475. wm8994_set_bits(wm8994, WM8994_LDO_1 + i,
  476. WM8994_LDO1_DISCH, WM8994_LDO1_DISCH);
  477. else
  478. wm8994_set_bits(wm8994, WM8994_LDO_1 + i,
  479. WM8994_LDO1_DISCH, 0);
  480. }
  481. wm8994_irq_init(wm8994);
  482. ret = mfd_add_devices(wm8994->dev, -1,
  483. wm8994_devs, ARRAY_SIZE(wm8994_devs),
  484. NULL, 0);
  485. if (ret != 0) {
  486. dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
  487. goto err_irq;
  488. }
  489. pm_runtime_enable(wm8994->dev);
  490. pm_runtime_resume(wm8994->dev);
  491. return 0;
  492. err_irq:
  493. wm8994_irq_exit(wm8994);
  494. err_enable:
  495. regulator_bulk_disable(wm8994->num_supplies,
  496. wm8994->supplies);
  497. err_get:
  498. regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
  499. err_regmap:
  500. regmap_exit(wm8994->regmap);
  501. mfd_remove_devices(wm8994->dev);
  502. return ret;
  503. }
  504. static void wm8994_device_exit(struct wm8994 *wm8994)
  505. {
  506. pm_runtime_disable(wm8994->dev);
  507. mfd_remove_devices(wm8994->dev);
  508. wm8994_irq_exit(wm8994);
  509. regulator_bulk_disable(wm8994->num_supplies,
  510. wm8994->supplies);
  511. regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
  512. regmap_exit(wm8994->regmap);
  513. }
  514. static const struct of_device_id wm8994_of_match[] = {
  515. { .compatible = "wlf,wm1811", },
  516. { .compatible = "wlf,wm8994", },
  517. { .compatible = "wlf,wm8958", },
  518. { }
  519. };
  520. MODULE_DEVICE_TABLE(of, wm8994_of_match);
  521. static int wm8994_i2c_probe(struct i2c_client *i2c,
  522. const struct i2c_device_id *id)
  523. {
  524. struct wm8994 *wm8994;
  525. int ret;
  526. wm8994 = devm_kzalloc(&i2c->dev, sizeof(struct wm8994), GFP_KERNEL);
  527. if (wm8994 == NULL)
  528. return -ENOMEM;
  529. i2c_set_clientdata(i2c, wm8994);
  530. wm8994->dev = &i2c->dev;
  531. wm8994->irq = i2c->irq;
  532. wm8994->type = id->driver_data;
  533. wm8994->regmap = regmap_init_i2c(i2c, &wm8994_regmap_config);
  534. if (IS_ERR(wm8994->regmap)) {
  535. ret = PTR_ERR(wm8994->regmap);
  536. dev_err(wm8994->dev, "Failed to allocate register map: %d\n",
  537. ret);
  538. return ret;
  539. }
  540. return wm8994_device_init(wm8994, i2c->irq);
  541. }
  542. static int wm8994_i2c_remove(struct i2c_client *i2c)
  543. {
  544. struct wm8994 *wm8994 = i2c_get_clientdata(i2c);
  545. wm8994_device_exit(wm8994);
  546. return 0;
  547. }
  548. static const struct i2c_device_id wm8994_i2c_id[] = {
  549. { "wm1811", WM1811 },
  550. { "wm1811a", WM1811 },
  551. { "wm8994", WM8994 },
  552. { "wm8958", WM8958 },
  553. { }
  554. };
  555. MODULE_DEVICE_TABLE(i2c, wm8994_i2c_id);
  556. static UNIVERSAL_DEV_PM_OPS(wm8994_pm_ops, wm8994_suspend, wm8994_resume,
  557. NULL);
  558. static struct i2c_driver wm8994_i2c_driver = {
  559. .driver = {
  560. .name = "wm8994",
  561. .owner = THIS_MODULE,
  562. .pm = &wm8994_pm_ops,
  563. .of_match_table = wm8994_of_match,
  564. },
  565. .probe = wm8994_i2c_probe,
  566. .remove = wm8994_i2c_remove,
  567. .id_table = wm8994_i2c_id,
  568. };
  569. static int __init wm8994_i2c_init(void)
  570. {
  571. int ret;
  572. ret = i2c_add_driver(&wm8994_i2c_driver);
  573. if (ret != 0)
  574. pr_err("Failed to register wm8994 I2C driver: %d\n", ret);
  575. return ret;
  576. }
  577. module_init(wm8994_i2c_init);
  578. static void __exit wm8994_i2c_exit(void)
  579. {
  580. i2c_del_driver(&wm8994_i2c_driver);
  581. }
  582. module_exit(wm8994_i2c_exit);
  583. MODULE_DESCRIPTION("Core support for the WM8994 audio CODEC");
  584. MODULE_LICENSE("GPL");
  585. MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");