wm8994-core.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  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/delay.h>
  19. #include <linux/mfd/core.h>
  20. #include <linux/pm_runtime.h>
  21. #include <linux/regulator/consumer.h>
  22. #include <linux/regulator/machine.h>
  23. #include <linux/mfd/wm8994/core.h>
  24. #include <linux/mfd/wm8994/pdata.h>
  25. #include <linux/mfd/wm8994/registers.h>
  26. static int wm8994_read(struct wm8994 *wm8994, unsigned short reg,
  27. int bytes, void *dest)
  28. {
  29. int ret, i;
  30. u16 *buf = dest;
  31. BUG_ON(bytes % 2);
  32. BUG_ON(bytes <= 0);
  33. ret = wm8994->read_dev(wm8994, reg, bytes, dest);
  34. if (ret < 0)
  35. return ret;
  36. for (i = 0; i < bytes / 2; i++) {
  37. dev_vdbg(wm8994->dev, "Read %04x from R%d(0x%x)\n",
  38. be16_to_cpu(buf[i]), reg + i, reg + i);
  39. }
  40. return 0;
  41. }
  42. /**
  43. * wm8994_reg_read: Read a single WM8994 register.
  44. *
  45. * @wm8994: Device to read from.
  46. * @reg: Register to read.
  47. */
  48. int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg)
  49. {
  50. unsigned short val;
  51. int ret;
  52. mutex_lock(&wm8994->io_lock);
  53. ret = wm8994_read(wm8994, reg, 2, &val);
  54. mutex_unlock(&wm8994->io_lock);
  55. if (ret < 0)
  56. return ret;
  57. else
  58. return be16_to_cpu(val);
  59. }
  60. EXPORT_SYMBOL_GPL(wm8994_reg_read);
  61. /**
  62. * wm8994_bulk_read: Read multiple WM8994 registers
  63. *
  64. * @wm8994: Device to read from
  65. * @reg: First register
  66. * @count: Number of registers
  67. * @buf: Buffer to fill. The data will be returned big endian.
  68. */
  69. int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
  70. int count, u16 *buf)
  71. {
  72. int ret;
  73. mutex_lock(&wm8994->io_lock);
  74. ret = wm8994_read(wm8994, reg, count * 2, buf);
  75. mutex_unlock(&wm8994->io_lock);
  76. return ret;
  77. }
  78. EXPORT_SYMBOL_GPL(wm8994_bulk_read);
  79. static int wm8994_write(struct wm8994 *wm8994, unsigned short reg,
  80. int bytes, const void *src)
  81. {
  82. const u16 *buf = src;
  83. int i;
  84. BUG_ON(bytes % 2);
  85. BUG_ON(bytes <= 0);
  86. for (i = 0; i < bytes / 2; i++) {
  87. dev_vdbg(wm8994->dev, "Write %04x to R%d(0x%x)\n",
  88. be16_to_cpu(buf[i]), reg + i, reg + i);
  89. }
  90. return wm8994->write_dev(wm8994, reg, bytes, src);
  91. }
  92. /**
  93. * wm8994_reg_write: Write a single WM8994 register.
  94. *
  95. * @wm8994: Device to write to.
  96. * @reg: Register to write to.
  97. * @val: Value to write.
  98. */
  99. int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg,
  100. unsigned short val)
  101. {
  102. int ret;
  103. val = cpu_to_be16(val);
  104. mutex_lock(&wm8994->io_lock);
  105. ret = wm8994_write(wm8994, reg, 2, &val);
  106. mutex_unlock(&wm8994->io_lock);
  107. return ret;
  108. }
  109. EXPORT_SYMBOL_GPL(wm8994_reg_write);
  110. /**
  111. * wm8994_bulk_write: Write multiple WM8994 registers
  112. *
  113. * @wm8994: Device to write to
  114. * @reg: First register
  115. * @count: Number of registers
  116. * @buf: Buffer to write from. Data must be big-endian formatted.
  117. */
  118. int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg,
  119. int count, const u16 *buf)
  120. {
  121. int ret;
  122. mutex_lock(&wm8994->io_lock);
  123. ret = wm8994_write(wm8994, reg, count * 2, buf);
  124. mutex_unlock(&wm8994->io_lock);
  125. return ret;
  126. }
  127. EXPORT_SYMBOL_GPL(wm8994_bulk_write);
  128. /**
  129. * wm8994_set_bits: Set the value of a bitfield in a WM8994 register
  130. *
  131. * @wm8994: Device to write to.
  132. * @reg: Register to write to.
  133. * @mask: Mask of bits to set.
  134. * @val: Value to set (unshifted)
  135. */
  136. int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
  137. unsigned short mask, unsigned short val)
  138. {
  139. int ret;
  140. u16 r;
  141. mutex_lock(&wm8994->io_lock);
  142. ret = wm8994_read(wm8994, reg, 2, &r);
  143. if (ret < 0)
  144. goto out;
  145. r = be16_to_cpu(r);
  146. r &= ~mask;
  147. r |= val;
  148. r = cpu_to_be16(r);
  149. ret = wm8994_write(wm8994, reg, 2, &r);
  150. out:
  151. mutex_unlock(&wm8994->io_lock);
  152. return ret;
  153. }
  154. EXPORT_SYMBOL_GPL(wm8994_set_bits);
  155. static struct mfd_cell wm8994_regulator_devs[] = {
  156. {
  157. .name = "wm8994-ldo",
  158. .id = 1,
  159. .pm_runtime_no_callbacks = true,
  160. },
  161. {
  162. .name = "wm8994-ldo",
  163. .id = 2,
  164. .pm_runtime_no_callbacks = true,
  165. },
  166. };
  167. static struct resource wm8994_codec_resources[] = {
  168. {
  169. .start = WM8994_IRQ_TEMP_SHUT,
  170. .end = WM8994_IRQ_TEMP_WARN,
  171. .flags = IORESOURCE_IRQ,
  172. },
  173. };
  174. static struct resource wm8994_gpio_resources[] = {
  175. {
  176. .start = WM8994_IRQ_GPIO(1),
  177. .end = WM8994_IRQ_GPIO(11),
  178. .flags = IORESOURCE_IRQ,
  179. },
  180. };
  181. static struct mfd_cell wm8994_devs[] = {
  182. {
  183. .name = "wm8994-codec",
  184. .num_resources = ARRAY_SIZE(wm8994_codec_resources),
  185. .resources = wm8994_codec_resources,
  186. },
  187. {
  188. .name = "wm8994-gpio",
  189. .num_resources = ARRAY_SIZE(wm8994_gpio_resources),
  190. .resources = wm8994_gpio_resources,
  191. .pm_runtime_no_callbacks = true,
  192. },
  193. };
  194. /*
  195. * Supplies for the main bulk of CODEC; the LDO supplies are ignored
  196. * and should be handled via the standard regulator API supply
  197. * management.
  198. */
  199. static const char *wm1811_main_supplies[] = {
  200. "DBVDD1",
  201. "DBVDD2",
  202. "DBVDD3",
  203. "DCVDD",
  204. "AVDD1",
  205. "AVDD2",
  206. "CPVDD",
  207. "SPKVDD1",
  208. "SPKVDD2",
  209. };
  210. static const char *wm8994_main_supplies[] = {
  211. "DBVDD",
  212. "DCVDD",
  213. "AVDD1",
  214. "AVDD2",
  215. "CPVDD",
  216. "SPKVDD1",
  217. "SPKVDD2",
  218. };
  219. static const char *wm8958_main_supplies[] = {
  220. "DBVDD1",
  221. "DBVDD2",
  222. "DBVDD3",
  223. "DCVDD",
  224. "AVDD1",
  225. "AVDD2",
  226. "CPVDD",
  227. "SPKVDD1",
  228. "SPKVDD2",
  229. };
  230. #ifdef CONFIG_PM
  231. static int wm8994_suspend(struct device *dev)
  232. {
  233. struct wm8994 *wm8994 = dev_get_drvdata(dev);
  234. int ret;
  235. /* Don't actually go through with the suspend if the CODEC is
  236. * still active (eg, for audio passthrough from CP. */
  237. ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_1);
  238. if (ret < 0) {
  239. dev_err(dev, "Failed to read power status: %d\n", ret);
  240. } else if (ret & WM8994_VMID_SEL_MASK) {
  241. dev_dbg(dev, "CODEC still active, ignoring suspend\n");
  242. return 0;
  243. }
  244. /* GPIO configuration state is saved here since we may be configuring
  245. * the GPIO alternate functions even if we're not using the gpiolib
  246. * driver for them.
  247. */
  248. ret = wm8994_read(wm8994, WM8994_GPIO_1, WM8994_NUM_GPIO_REGS * 2,
  249. &wm8994->gpio_regs);
  250. if (ret < 0)
  251. dev_err(dev, "Failed to save GPIO registers: %d\n", ret);
  252. /* For similar reasons we also stash the regulator states */
  253. ret = wm8994_read(wm8994, WM8994_LDO_1, WM8994_NUM_LDO_REGS * 2,
  254. &wm8994->ldo_regs);
  255. if (ret < 0)
  256. dev_err(dev, "Failed to save LDO registers: %d\n", ret);
  257. /* Explicitly put the device into reset in case regulators
  258. * don't get disabled in order to ensure consistent restart.
  259. */
  260. wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET, 0x8994);
  261. wm8994->suspended = true;
  262. ret = regulator_bulk_disable(wm8994->num_supplies,
  263. wm8994->supplies);
  264. if (ret != 0) {
  265. dev_err(dev, "Failed to disable supplies: %d\n", ret);
  266. return ret;
  267. }
  268. return 0;
  269. }
  270. static int wm8994_resume(struct device *dev)
  271. {
  272. struct wm8994 *wm8994 = dev_get_drvdata(dev);
  273. int ret, i;
  274. /* We may have lied to the PM core about suspending */
  275. if (!wm8994->suspended)
  276. return 0;
  277. ret = regulator_bulk_enable(wm8994->num_supplies,
  278. wm8994->supplies);
  279. if (ret != 0) {
  280. dev_err(dev, "Failed to enable supplies: %d\n", ret);
  281. return ret;
  282. }
  283. /* Write register at a time as we use the cache on the CPU so store
  284. * it in native endian.
  285. */
  286. for (i = 0; i < ARRAY_SIZE(wm8994->irq_masks_cur); i++) {
  287. ret = wm8994_reg_write(wm8994, WM8994_INTERRUPT_STATUS_1_MASK
  288. + i, wm8994->irq_masks_cur[i]);
  289. if (ret < 0)
  290. dev_err(dev, "Failed to restore interrupt masks: %d\n",
  291. ret);
  292. }
  293. ret = wm8994_write(wm8994, WM8994_LDO_1, WM8994_NUM_LDO_REGS * 2,
  294. &wm8994->ldo_regs);
  295. if (ret < 0)
  296. dev_err(dev, "Failed to restore LDO registers: %d\n", ret);
  297. ret = wm8994_write(wm8994, WM8994_GPIO_1, WM8994_NUM_GPIO_REGS * 2,
  298. &wm8994->gpio_regs);
  299. if (ret < 0)
  300. dev_err(dev, "Failed to restore GPIO registers: %d\n", ret);
  301. wm8994->suspended = false;
  302. return 0;
  303. }
  304. #endif
  305. #ifdef CONFIG_REGULATOR
  306. static int wm8994_ldo_in_use(struct wm8994_pdata *pdata, int ldo)
  307. {
  308. struct wm8994_ldo_pdata *ldo_pdata;
  309. if (!pdata)
  310. return 0;
  311. ldo_pdata = &pdata->ldo[ldo];
  312. if (!ldo_pdata->init_data)
  313. return 0;
  314. return ldo_pdata->init_data->num_consumer_supplies != 0;
  315. }
  316. #else
  317. static int wm8994_ldo_in_use(struct wm8994_pdata *pdata, int ldo)
  318. {
  319. return 0;
  320. }
  321. #endif
  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. mutex_init(&wm8994->io_lock);
  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;
  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;
  354. }
  355. wm8994->supplies = kzalloc(sizeof(struct regulator_bulk_data) *
  356. wm8994->num_supplies,
  357. GFP_KERNEL);
  358. if (!wm8994->supplies) {
  359. ret = -ENOMEM;
  360. goto err;
  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;
  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_supplies;
  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. }
  459. /* In some system designs where the regulators are not in use,
  460. * we can achieve a small reduction in leakage currents by
  461. * floating LDO outputs. This bit makes no difference if the
  462. * LDOs are enabled, it only affects cases where the LDOs were
  463. * in operation and are then disabled.
  464. */
  465. for (i = 0; i < WM8994_NUM_LDO_REGS; i++) {
  466. if (wm8994_ldo_in_use(pdata, i))
  467. wm8994_set_bits(wm8994, WM8994_LDO_1 + i,
  468. WM8994_LDO1_DISCH, WM8994_LDO1_DISCH);
  469. else
  470. wm8994_set_bits(wm8994, WM8994_LDO_1 + i,
  471. WM8994_LDO1_DISCH, 0);
  472. }
  473. wm8994_irq_init(wm8994);
  474. ret = mfd_add_devices(wm8994->dev, -1,
  475. wm8994_devs, ARRAY_SIZE(wm8994_devs),
  476. NULL, 0);
  477. if (ret != 0) {
  478. dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
  479. goto err_irq;
  480. }
  481. pm_runtime_enable(wm8994->dev);
  482. pm_runtime_resume(wm8994->dev);
  483. return 0;
  484. err_irq:
  485. wm8994_irq_exit(wm8994);
  486. err_enable:
  487. regulator_bulk_disable(wm8994->num_supplies,
  488. wm8994->supplies);
  489. err_get:
  490. regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
  491. err_supplies:
  492. kfree(wm8994->supplies);
  493. err:
  494. mfd_remove_devices(wm8994->dev);
  495. kfree(wm8994);
  496. return ret;
  497. }
  498. static void wm8994_device_exit(struct wm8994 *wm8994)
  499. {
  500. pm_runtime_disable(wm8994->dev);
  501. mfd_remove_devices(wm8994->dev);
  502. wm8994_irq_exit(wm8994);
  503. regulator_bulk_disable(wm8994->num_supplies,
  504. wm8994->supplies);
  505. regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
  506. kfree(wm8994->supplies);
  507. kfree(wm8994);
  508. }
  509. static int wm8994_i2c_read_device(struct wm8994 *wm8994, unsigned short reg,
  510. int bytes, void *dest)
  511. {
  512. struct i2c_client *i2c = wm8994->control_data;
  513. int ret;
  514. u16 r = cpu_to_be16(reg);
  515. ret = i2c_master_send(i2c, (unsigned char *)&r, 2);
  516. if (ret < 0)
  517. return ret;
  518. if (ret != 2)
  519. return -EIO;
  520. ret = i2c_master_recv(i2c, dest, bytes);
  521. if (ret < 0)
  522. return ret;
  523. if (ret != bytes)
  524. return -EIO;
  525. return 0;
  526. }
  527. static int wm8994_i2c_write_device(struct wm8994 *wm8994, unsigned short reg,
  528. int bytes, const void *src)
  529. {
  530. struct i2c_client *i2c = wm8994->control_data;
  531. struct i2c_msg xfer[2];
  532. int ret;
  533. reg = cpu_to_be16(reg);
  534. xfer[0].addr = i2c->addr;
  535. xfer[0].flags = 0;
  536. xfer[0].len = 2;
  537. xfer[0].buf = (char *)&reg;
  538. xfer[1].addr = i2c->addr;
  539. xfer[1].flags = I2C_M_NOSTART;
  540. xfer[1].len = bytes;
  541. xfer[1].buf = (char *)src;
  542. ret = i2c_transfer(i2c->adapter, xfer, 2);
  543. if (ret < 0)
  544. return ret;
  545. if (ret != 2)
  546. return -EIO;
  547. return 0;
  548. }
  549. static int wm8994_i2c_probe(struct i2c_client *i2c,
  550. const struct i2c_device_id *id)
  551. {
  552. struct wm8994 *wm8994;
  553. wm8994 = kzalloc(sizeof(struct wm8994), GFP_KERNEL);
  554. if (wm8994 == NULL)
  555. return -ENOMEM;
  556. i2c_set_clientdata(i2c, wm8994);
  557. wm8994->dev = &i2c->dev;
  558. wm8994->control_data = i2c;
  559. wm8994->read_dev = wm8994_i2c_read_device;
  560. wm8994->write_dev = wm8994_i2c_write_device;
  561. wm8994->irq = i2c->irq;
  562. wm8994->type = id->driver_data;
  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. { "wm8994", WM8994 },
  574. { "wm8958", WM8958 },
  575. { }
  576. };
  577. MODULE_DEVICE_TABLE(i2c, wm8994_i2c_id);
  578. static UNIVERSAL_DEV_PM_OPS(wm8994_pm_ops, wm8994_suspend, wm8994_resume,
  579. NULL);
  580. static struct i2c_driver wm8994_i2c_driver = {
  581. .driver = {
  582. .name = "wm8994",
  583. .owner = THIS_MODULE,
  584. .pm = &wm8994_pm_ops,
  585. },
  586. .probe = wm8994_i2c_probe,
  587. .remove = wm8994_i2c_remove,
  588. .id_table = wm8994_i2c_id,
  589. };
  590. static int __init wm8994_i2c_init(void)
  591. {
  592. int ret;
  593. ret = i2c_add_driver(&wm8994_i2c_driver);
  594. if (ret != 0)
  595. pr_err("Failed to register wm8994 I2C driver: %d\n", ret);
  596. return ret;
  597. }
  598. module_init(wm8994_i2c_init);
  599. static void __exit wm8994_i2c_exit(void)
  600. {
  601. i2c_del_driver(&wm8994_i2c_driver);
  602. }
  603. module_exit(wm8994_i2c_exit);
  604. MODULE_DESCRIPTION("Core support for the WM8994 audio CODEC");
  605. MODULE_LICENSE("GPL");
  606. MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");