wm8994-core.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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/of.h>
  22. #include <linux/of_device.h>
  23. #include <linux/of_gpio.h>
  24. #include <linux/pm_runtime.h>
  25. #include <linux/regmap.h>
  26. #include <linux/regulator/consumer.h>
  27. #include <linux/regulator/machine.h>
  28. #include <linux/mfd/wm8994/core.h>
  29. #include <linux/mfd/wm8994/pdata.h>
  30. #include <linux/mfd/wm8994/registers.h>
  31. #include "wm8994.h"
  32. static const struct mfd_cell wm8994_regulator_devs[] = {
  33. {
  34. .name = "wm8994-ldo",
  35. .id = 0,
  36. .pm_runtime_no_callbacks = true,
  37. },
  38. {
  39. .name = "wm8994-ldo",
  40. .id = 1,
  41. .pm_runtime_no_callbacks = true,
  42. },
  43. };
  44. static struct resource wm8994_codec_resources[] = {
  45. {
  46. .start = WM8994_IRQ_TEMP_SHUT,
  47. .end = WM8994_IRQ_TEMP_WARN,
  48. .flags = IORESOURCE_IRQ,
  49. },
  50. };
  51. static struct resource wm8994_gpio_resources[] = {
  52. {
  53. .start = WM8994_IRQ_GPIO(1),
  54. .end = WM8994_IRQ_GPIO(11),
  55. .flags = IORESOURCE_IRQ,
  56. },
  57. };
  58. static const struct mfd_cell wm8994_devs[] = {
  59. {
  60. .name = "wm8994-codec",
  61. .num_resources = ARRAY_SIZE(wm8994_codec_resources),
  62. .resources = wm8994_codec_resources,
  63. },
  64. {
  65. .name = "wm8994-gpio",
  66. .num_resources = ARRAY_SIZE(wm8994_gpio_resources),
  67. .resources = wm8994_gpio_resources,
  68. .pm_runtime_no_callbacks = true,
  69. },
  70. };
  71. /*
  72. * Supplies for the main bulk of CODEC; the LDO supplies are ignored
  73. * and should be handled via the standard regulator API supply
  74. * management.
  75. */
  76. static const char *wm1811_main_supplies[] = {
  77. "DBVDD1",
  78. "DBVDD2",
  79. "DBVDD3",
  80. "DCVDD",
  81. "AVDD1",
  82. "AVDD2",
  83. "CPVDD",
  84. "SPKVDD1",
  85. "SPKVDD2",
  86. };
  87. static const char *wm8994_main_supplies[] = {
  88. "DBVDD",
  89. "DCVDD",
  90. "AVDD1",
  91. "AVDD2",
  92. "CPVDD",
  93. "SPKVDD1",
  94. "SPKVDD2",
  95. };
  96. static const char *wm8958_main_supplies[] = {
  97. "DBVDD1",
  98. "DBVDD2",
  99. "DBVDD3",
  100. "DCVDD",
  101. "AVDD1",
  102. "AVDD2",
  103. "CPVDD",
  104. "SPKVDD1",
  105. "SPKVDD2",
  106. };
  107. #ifdef CONFIG_PM
  108. static int wm8994_suspend(struct device *dev)
  109. {
  110. struct wm8994 *wm8994 = dev_get_drvdata(dev);
  111. int ret;
  112. /* Don't actually go through with the suspend if the CODEC is
  113. * still active for accessory detect. */
  114. switch (wm8994->type) {
  115. case WM8958:
  116. case WM1811:
  117. ret = wm8994_reg_read(wm8994, WM8958_MIC_DETECT_1);
  118. if (ret < 0) {
  119. dev_err(dev, "Failed to read power status: %d\n", ret);
  120. } else if (ret & WM8958_MICD_ENA) {
  121. dev_dbg(dev, "CODEC still active, ignoring suspend\n");
  122. return 0;
  123. }
  124. break;
  125. default:
  126. break;
  127. }
  128. /* Disable LDO pulldowns while the device is suspended if we
  129. * don't know that something will be driving them. */
  130. if (!wm8994->ldo_ena_always_driven)
  131. wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2,
  132. WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD,
  133. WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD);
  134. /* Explicitly put the device into reset in case regulators
  135. * don't get disabled in order to ensure consistent restart.
  136. */
  137. wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET,
  138. wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET));
  139. regcache_mark_dirty(wm8994->regmap);
  140. /* Restore GPIO registers to prevent problems with mismatched
  141. * pin configurations.
  142. */
  143. ret = regcache_sync_region(wm8994->regmap, WM8994_GPIO_1,
  144. WM8994_GPIO_11);
  145. if (ret != 0)
  146. dev_err(dev, "Failed to restore GPIO registers: %d\n", ret);
  147. /* In case one of the GPIOs is used as a wake input. */
  148. ret = regcache_sync_region(wm8994->regmap,
  149. WM8994_INTERRUPT_STATUS_1_MASK,
  150. WM8994_INTERRUPT_STATUS_1_MASK);
  151. if (ret != 0)
  152. dev_err(dev, "Failed to restore interrupt mask: %d\n", ret);
  153. regcache_cache_only(wm8994->regmap, true);
  154. wm8994->suspended = true;
  155. ret = regulator_bulk_disable(wm8994->num_supplies,
  156. wm8994->supplies);
  157. if (ret != 0) {
  158. dev_err(dev, "Failed to disable supplies: %d\n", ret);
  159. return ret;
  160. }
  161. return 0;
  162. }
  163. static int wm8994_resume(struct device *dev)
  164. {
  165. struct wm8994 *wm8994 = dev_get_drvdata(dev);
  166. int ret;
  167. /* We may have lied to the PM core about suspending */
  168. if (!wm8994->suspended)
  169. return 0;
  170. ret = regulator_bulk_enable(wm8994->num_supplies,
  171. wm8994->supplies);
  172. if (ret != 0) {
  173. dev_err(dev, "Failed to enable supplies: %d\n", ret);
  174. return ret;
  175. }
  176. regcache_cache_only(wm8994->regmap, false);
  177. ret = regcache_sync(wm8994->regmap);
  178. if (ret != 0) {
  179. dev_err(dev, "Failed to restore register map: %d\n", ret);
  180. goto err_enable;
  181. }
  182. /* Disable LDO pulldowns while the device is active */
  183. wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2,
  184. WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD,
  185. 0);
  186. wm8994->suspended = false;
  187. return 0;
  188. err_enable:
  189. regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies);
  190. return ret;
  191. }
  192. #endif
  193. #ifdef CONFIG_REGULATOR
  194. static int wm8994_ldo_in_use(struct wm8994_pdata *pdata, int ldo)
  195. {
  196. struct wm8994_ldo_pdata *ldo_pdata;
  197. if (!pdata)
  198. return 0;
  199. ldo_pdata = &pdata->ldo[ldo];
  200. if (!ldo_pdata->init_data)
  201. return 0;
  202. return ldo_pdata->init_data->num_consumer_supplies != 0;
  203. }
  204. #else
  205. static int wm8994_ldo_in_use(struct wm8994_pdata *pdata, int ldo)
  206. {
  207. return 0;
  208. }
  209. #endif
  210. static const struct reg_sequence wm8994_revc_patch[] = {
  211. { 0x102, 0x3 },
  212. { 0x56, 0x3 },
  213. { 0x817, 0x0 },
  214. { 0x102, 0x0 },
  215. };
  216. static const struct reg_sequence wm8958_reva_patch[] = {
  217. { 0x102, 0x3 },
  218. { 0xcb, 0x81 },
  219. { 0x817, 0x0 },
  220. { 0x102, 0x0 },
  221. };
  222. static const struct reg_sequence wm1811_reva_patch[] = {
  223. { 0x102, 0x3 },
  224. { 0x56, 0xc07 },
  225. { 0x5d, 0x7e },
  226. { 0x5e, 0x0 },
  227. { 0x102, 0x0 },
  228. };
  229. #ifdef CONFIG_OF
  230. static int wm8994_set_pdata_from_of(struct wm8994 *wm8994)
  231. {
  232. struct device_node *np = wm8994->dev->of_node;
  233. struct wm8994_pdata *pdata = &wm8994->pdata;
  234. int i;
  235. if (!np)
  236. return 0;
  237. if (of_property_read_u32_array(np, "wlf,gpio-cfg", pdata->gpio_defaults,
  238. ARRAY_SIZE(pdata->gpio_defaults)) >= 0) {
  239. for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
  240. if (wm8994->pdata.gpio_defaults[i] == 0)
  241. pdata->gpio_defaults[i]
  242. = WM8994_CONFIGURE_GPIO;
  243. }
  244. }
  245. of_property_read_u32_array(np, "wlf,micbias-cfg", pdata->micbias,
  246. ARRAY_SIZE(pdata->micbias));
  247. pdata->lineout1_diff = true;
  248. pdata->lineout2_diff = true;
  249. if (of_find_property(np, "wlf,lineout1-se", NULL))
  250. pdata->lineout1_diff = false;
  251. if (of_find_property(np, "wlf,lineout2-se", NULL))
  252. pdata->lineout2_diff = false;
  253. if (of_find_property(np, "wlf,lineout1-feedback", NULL))
  254. pdata->lineout1fb = true;
  255. if (of_find_property(np, "wlf,lineout2-feedback", NULL))
  256. pdata->lineout2fb = true;
  257. if (of_find_property(np, "wlf,ldoena-always-driven", NULL))
  258. pdata->lineout2fb = true;
  259. pdata->ldo[0].enable = of_get_named_gpio(np, "wlf,ldo1ena", 0);
  260. if (pdata->ldo[0].enable < 0)
  261. pdata->ldo[0].enable = 0;
  262. pdata->ldo[1].enable = of_get_named_gpio(np, "wlf,ldo2ena", 0);
  263. if (pdata->ldo[1].enable < 0)
  264. pdata->ldo[1].enable = 0;
  265. return 0;
  266. }
  267. #else
  268. static int wm8994_set_pdata_from_of(struct wm8994 *wm8994)
  269. {
  270. return 0;
  271. }
  272. #endif
  273. /*
  274. * Instantiate the generic non-control parts of the device.
  275. */
  276. static int wm8994_device_init(struct wm8994 *wm8994, int irq)
  277. {
  278. struct wm8994_pdata *pdata;
  279. struct regmap_config *regmap_config;
  280. const struct reg_sequence *regmap_patch = NULL;
  281. const char *devname;
  282. int ret, i, patch_regs = 0;
  283. int pulls = 0;
  284. if (dev_get_platdata(wm8994->dev)) {
  285. pdata = dev_get_platdata(wm8994->dev);
  286. wm8994->pdata = *pdata;
  287. }
  288. pdata = &wm8994->pdata;
  289. ret = wm8994_set_pdata_from_of(wm8994);
  290. if (ret != 0)
  291. return ret;
  292. dev_set_drvdata(wm8994->dev, wm8994);
  293. /* Add the on-chip regulators first for bootstrapping */
  294. ret = mfd_add_devices(wm8994->dev, 0,
  295. wm8994_regulator_devs,
  296. ARRAY_SIZE(wm8994_regulator_devs),
  297. NULL, 0, NULL);
  298. if (ret != 0) {
  299. dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
  300. goto err;
  301. }
  302. switch (wm8994->type) {
  303. case WM1811:
  304. wm8994->num_supplies = ARRAY_SIZE(wm1811_main_supplies);
  305. break;
  306. case WM8994:
  307. wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies);
  308. break;
  309. case WM8958:
  310. wm8994->num_supplies = ARRAY_SIZE(wm8958_main_supplies);
  311. break;
  312. default:
  313. BUG();
  314. goto err;
  315. }
  316. wm8994->supplies = devm_kzalloc(wm8994->dev,
  317. sizeof(struct regulator_bulk_data) *
  318. wm8994->num_supplies, GFP_KERNEL);
  319. if (!wm8994->supplies) {
  320. ret = -ENOMEM;
  321. goto err;
  322. }
  323. switch (wm8994->type) {
  324. case WM1811:
  325. for (i = 0; i < ARRAY_SIZE(wm1811_main_supplies); i++)
  326. wm8994->supplies[i].supply = wm1811_main_supplies[i];
  327. break;
  328. case WM8994:
  329. for (i = 0; i < ARRAY_SIZE(wm8994_main_supplies); i++)
  330. wm8994->supplies[i].supply = wm8994_main_supplies[i];
  331. break;
  332. case WM8958:
  333. for (i = 0; i < ARRAY_SIZE(wm8958_main_supplies); i++)
  334. wm8994->supplies[i].supply = wm8958_main_supplies[i];
  335. break;
  336. default:
  337. BUG();
  338. goto err;
  339. }
  340. ret = devm_regulator_bulk_get(wm8994->dev, wm8994->num_supplies,
  341. wm8994->supplies);
  342. if (ret != 0) {
  343. dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret);
  344. goto err;
  345. }
  346. ret = regulator_bulk_enable(wm8994->num_supplies,
  347. wm8994->supplies);
  348. if (ret != 0) {
  349. dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret);
  350. goto err;
  351. }
  352. ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET);
  353. if (ret < 0) {
  354. dev_err(wm8994->dev, "Failed to read ID register\n");
  355. goto err_enable;
  356. }
  357. switch (ret) {
  358. case 0x1811:
  359. devname = "WM1811";
  360. if (wm8994->type != WM1811)
  361. dev_warn(wm8994->dev, "Device registered as type %d\n",
  362. wm8994->type);
  363. wm8994->type = WM1811;
  364. break;
  365. case 0x8994:
  366. devname = "WM8994";
  367. if (wm8994->type != WM8994)
  368. dev_warn(wm8994->dev, "Device registered as type %d\n",
  369. wm8994->type);
  370. wm8994->type = WM8994;
  371. break;
  372. case 0x8958:
  373. devname = "WM8958";
  374. if (wm8994->type != WM8958)
  375. dev_warn(wm8994->dev, "Device registered as type %d\n",
  376. wm8994->type);
  377. wm8994->type = WM8958;
  378. break;
  379. default:
  380. dev_err(wm8994->dev, "Device is not a WM8994, ID is %x\n",
  381. ret);
  382. ret = -EINVAL;
  383. goto err_enable;
  384. }
  385. ret = wm8994_reg_read(wm8994, WM8994_CHIP_REVISION);
  386. if (ret < 0) {
  387. dev_err(wm8994->dev, "Failed to read revision register: %d\n",
  388. ret);
  389. goto err_enable;
  390. }
  391. wm8994->revision = ret & WM8994_CHIP_REV_MASK;
  392. wm8994->cust_id = (ret & WM8994_CUST_ID_MASK) >> WM8994_CUST_ID_SHIFT;
  393. switch (wm8994->type) {
  394. case WM8994:
  395. switch (wm8994->revision) {
  396. case 0:
  397. case 1:
  398. dev_warn(wm8994->dev,
  399. "revision %c not fully supported\n",
  400. 'A' + wm8994->revision);
  401. break;
  402. case 2:
  403. case 3:
  404. default:
  405. regmap_patch = wm8994_revc_patch;
  406. patch_regs = ARRAY_SIZE(wm8994_revc_patch);
  407. break;
  408. }
  409. break;
  410. case WM8958:
  411. switch (wm8994->revision) {
  412. case 0:
  413. regmap_patch = wm8958_reva_patch;
  414. patch_regs = ARRAY_SIZE(wm8958_reva_patch);
  415. break;
  416. default:
  417. break;
  418. }
  419. break;
  420. case WM1811:
  421. /* Revision C did not change the relevant layer */
  422. if (wm8994->revision > 1)
  423. wm8994->revision++;
  424. regmap_patch = wm1811_reva_patch;
  425. patch_regs = ARRAY_SIZE(wm1811_reva_patch);
  426. break;
  427. default:
  428. break;
  429. }
  430. dev_info(wm8994->dev, "%s revision %c CUST_ID %02x\n", devname,
  431. 'A' + wm8994->revision, wm8994->cust_id);
  432. switch (wm8994->type) {
  433. case WM1811:
  434. regmap_config = &wm1811_regmap_config;
  435. break;
  436. case WM8994:
  437. regmap_config = &wm8994_regmap_config;
  438. break;
  439. case WM8958:
  440. regmap_config = &wm8958_regmap_config;
  441. break;
  442. default:
  443. dev_err(wm8994->dev, "Unknown device type %d\n", wm8994->type);
  444. return -EINVAL;
  445. }
  446. ret = regmap_reinit_cache(wm8994->regmap, regmap_config);
  447. if (ret != 0) {
  448. dev_err(wm8994->dev, "Failed to reinit register cache: %d\n",
  449. ret);
  450. return ret;
  451. }
  452. /* Explicitly put the device into reset in case regulators
  453. * don't get disabled in order to ensure we know the device
  454. * state.
  455. */
  456. ret = wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET,
  457. wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET));
  458. if (ret != 0) {
  459. dev_err(wm8994->dev, "Failed to reset device: %d\n", ret);
  460. return ret;
  461. }
  462. if (regmap_patch) {
  463. ret = regmap_register_patch(wm8994->regmap, regmap_patch,
  464. patch_regs);
  465. if (ret != 0) {
  466. dev_err(wm8994->dev, "Failed to register patch: %d\n",
  467. ret);
  468. goto err;
  469. }
  470. }
  471. wm8994->irq_base = pdata->irq_base;
  472. wm8994->gpio_base = pdata->gpio_base;
  473. /* GPIO configuration is only applied if it's non-zero */
  474. for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
  475. if (pdata->gpio_defaults[i]) {
  476. wm8994_set_bits(wm8994, WM8994_GPIO_1 + i,
  477. 0xffff, pdata->gpio_defaults[i]);
  478. }
  479. }
  480. wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven;
  481. if (pdata->spkmode_pu)
  482. pulls |= WM8994_SPKMODE_PU;
  483. /* Disable unneeded pulls */
  484. wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2,
  485. WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD |
  486. WM8994_SPKMODE_PU | WM8994_CSNADDR_PD,
  487. pulls);
  488. /* In some system designs where the regulators are not in use,
  489. * we can achieve a small reduction in leakage currents by
  490. * floating LDO outputs. This bit makes no difference if the
  491. * LDOs are enabled, it only affects cases where the LDOs were
  492. * in operation and are then disabled.
  493. */
  494. for (i = 0; i < WM8994_NUM_LDO_REGS; i++) {
  495. if (wm8994_ldo_in_use(pdata, i))
  496. wm8994_set_bits(wm8994, WM8994_LDO_1 + i,
  497. WM8994_LDO1_DISCH, WM8994_LDO1_DISCH);
  498. else
  499. wm8994_set_bits(wm8994, WM8994_LDO_1 + i,
  500. WM8994_LDO1_DISCH, 0);
  501. }
  502. wm8994_irq_init(wm8994);
  503. ret = mfd_add_devices(wm8994->dev, -1,
  504. wm8994_devs, ARRAY_SIZE(wm8994_devs),
  505. NULL, 0, NULL);
  506. if (ret != 0) {
  507. dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
  508. goto err_irq;
  509. }
  510. pm_runtime_enable(wm8994->dev);
  511. pm_runtime_idle(wm8994->dev);
  512. return 0;
  513. err_irq:
  514. wm8994_irq_exit(wm8994);
  515. err_enable:
  516. regulator_bulk_disable(wm8994->num_supplies,
  517. wm8994->supplies);
  518. err:
  519. mfd_remove_devices(wm8994->dev);
  520. return ret;
  521. }
  522. static void wm8994_device_exit(struct wm8994 *wm8994)
  523. {
  524. pm_runtime_disable(wm8994->dev);
  525. mfd_remove_devices(wm8994->dev);
  526. wm8994_irq_exit(wm8994);
  527. regulator_bulk_disable(wm8994->num_supplies,
  528. wm8994->supplies);
  529. }
  530. static const struct of_device_id wm8994_of_match[] = {
  531. { .compatible = "wlf,wm1811", .data = (void *)WM1811 },
  532. { .compatible = "wlf,wm8994", .data = (void *)WM8994 },
  533. { .compatible = "wlf,wm8958", .data = (void *)WM8958 },
  534. { }
  535. };
  536. MODULE_DEVICE_TABLE(of, wm8994_of_match);
  537. static int wm8994_i2c_probe(struct i2c_client *i2c,
  538. const struct i2c_device_id *id)
  539. {
  540. const struct of_device_id *of_id;
  541. struct wm8994 *wm8994;
  542. int ret;
  543. wm8994 = devm_kzalloc(&i2c->dev, sizeof(struct wm8994), GFP_KERNEL);
  544. if (wm8994 == NULL)
  545. return -ENOMEM;
  546. i2c_set_clientdata(i2c, wm8994);
  547. wm8994->dev = &i2c->dev;
  548. wm8994->irq = i2c->irq;
  549. if (i2c->dev.of_node) {
  550. of_id = of_match_device(wm8994_of_match, &i2c->dev);
  551. if (of_id)
  552. wm8994->type = (enum wm8994_type)of_id->data;
  553. } else {
  554. wm8994->type = id->driver_data;
  555. }
  556. wm8994->regmap = devm_regmap_init_i2c(i2c, &wm8994_base_regmap_config);
  557. if (IS_ERR(wm8994->regmap)) {
  558. ret = PTR_ERR(wm8994->regmap);
  559. dev_err(wm8994->dev, "Failed to allocate register map: %d\n",
  560. ret);
  561. return ret;
  562. }
  563. return wm8994_device_init(wm8994, i2c->irq);
  564. }
  565. static int wm8994_i2c_remove(struct i2c_client *i2c)
  566. {
  567. struct wm8994 *wm8994 = i2c_get_clientdata(i2c);
  568. wm8994_device_exit(wm8994);
  569. return 0;
  570. }
  571. static const struct i2c_device_id wm8994_i2c_id[] = {
  572. { "wm1811", WM1811 },
  573. { "wm1811a", WM1811 },
  574. { "wm8994", WM8994 },
  575. { "wm8958", WM8958 },
  576. { }
  577. };
  578. MODULE_DEVICE_TABLE(i2c, wm8994_i2c_id);
  579. static const struct dev_pm_ops wm8994_pm_ops = {
  580. SET_RUNTIME_PM_OPS(wm8994_suspend, wm8994_resume, NULL)
  581. };
  582. static struct i2c_driver wm8994_i2c_driver = {
  583. .driver = {
  584. .name = "wm8994",
  585. .pm = &wm8994_pm_ops,
  586. .of_match_table = of_match_ptr(wm8994_of_match),
  587. },
  588. .probe = wm8994_i2c_probe,
  589. .remove = wm8994_i2c_remove,
  590. .id_table = wm8994_i2c_id,
  591. };
  592. module_i2c_driver(wm8994_i2c_driver);
  593. MODULE_DESCRIPTION("Core support for the WM8994 audio CODEC");
  594. MODULE_LICENSE("GPL");
  595. MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");