[S390] clear TIF_SINGLE_STEP for new process.
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / mfd / wm831x-core.c
blob4b2021af1d9646be71d5a257c9adc0ded9b8052d
1 /*
2 * wm831x-core.c -- Device access for Wolfson WM831x PMICs
4 * Copyright 2009 Wolfson Microelectronics PLC.
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
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.
15 #include <linux/kernel.h>
16 #include <linux/module.h>
17 #include <linux/i2c.h>
18 #include <linux/bcd.h>
19 #include <linux/delay.h>
20 #include <linux/mfd/core.h>
22 #include <linux/mfd/wm831x/core.h>
23 #include <linux/mfd/wm831x/pdata.h>
24 #include <linux/mfd/wm831x/irq.h>
25 #include <linux/mfd/wm831x/auxadc.h>
26 #include <linux/mfd/wm831x/otp.h>
27 #include <linux/mfd/wm831x/regulator.h>
29 /* Current settings - values are 2*2^(reg_val/4) microamps. These are
30 * exported since they are used by multiple drivers.
32 int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1] = {
42 10,
43 11,
44 13,
45 16,
46 19,
47 23,
48 27,
49 32,
50 38,
51 45,
52 54,
53 64,
54 76,
55 91,
56 108,
57 128,
58 152,
59 181,
60 215,
61 256,
62 304,
63 362,
64 431,
65 512,
66 609,
67 724,
68 861,
69 1024,
70 1218,
71 1448,
72 1722,
73 2048,
74 2435,
75 2896,
76 3444,
77 4096,
78 4871,
79 5793,
80 6889,
81 8192,
82 9742,
83 11585,
84 13777,
85 16384,
86 19484,
87 23170,
88 27554,
90 EXPORT_SYMBOL_GPL(wm831x_isinkv_values);
92 enum wm831x_parent {
93 WM8310 = 0x8310,
94 WM8311 = 0x8311,
95 WM8312 = 0x8312,
96 WM8320 = 0x8320,
99 static int wm831x_reg_locked(struct wm831x *wm831x, unsigned short reg)
101 if (!wm831x->locked)
102 return 0;
104 switch (reg) {
105 case WM831X_WATCHDOG:
106 case WM831X_DC4_CONTROL:
107 case WM831X_ON_PIN_CONTROL:
108 case WM831X_BACKUP_CHARGER_CONTROL:
109 case WM831X_CHARGER_CONTROL_1:
110 case WM831X_CHARGER_CONTROL_2:
111 return 1;
113 default:
114 return 0;
119 * wm831x_reg_unlock: Unlock user keyed registers
121 * The WM831x has a user key preventing writes to particularly
122 * critical registers. This function locks those registers,
123 * allowing writes to them.
125 void wm831x_reg_lock(struct wm831x *wm831x)
127 int ret;
129 ret = wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0);
130 if (ret == 0) {
131 dev_vdbg(wm831x->dev, "Registers locked\n");
133 mutex_lock(&wm831x->io_lock);
134 WARN_ON(wm831x->locked);
135 wm831x->locked = 1;
136 mutex_unlock(&wm831x->io_lock);
137 } else {
138 dev_err(wm831x->dev, "Failed to lock registers: %d\n", ret);
142 EXPORT_SYMBOL_GPL(wm831x_reg_lock);
145 * wm831x_reg_unlock: Unlock user keyed registers
147 * The WM831x has a user key preventing writes to particularly
148 * critical registers. This function locks those registers,
149 * preventing spurious writes.
151 int wm831x_reg_unlock(struct wm831x *wm831x)
153 int ret;
155 /* 0x9716 is the value required to unlock the registers */
156 ret = wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0x9716);
157 if (ret == 0) {
158 dev_vdbg(wm831x->dev, "Registers unlocked\n");
160 mutex_lock(&wm831x->io_lock);
161 WARN_ON(!wm831x->locked);
162 wm831x->locked = 0;
163 mutex_unlock(&wm831x->io_lock);
166 return ret;
168 EXPORT_SYMBOL_GPL(wm831x_reg_unlock);
170 static int wm831x_read(struct wm831x *wm831x, unsigned short reg,
171 int bytes, void *dest)
173 int ret, i;
174 u16 *buf = dest;
176 BUG_ON(bytes % 2);
177 BUG_ON(bytes <= 0);
179 ret = wm831x->read_dev(wm831x, reg, bytes, dest);
180 if (ret < 0)
181 return ret;
183 for (i = 0; i < bytes / 2; i++) {
184 buf[i] = be16_to_cpu(buf[i]);
186 dev_vdbg(wm831x->dev, "Read %04x from R%d(0x%x)\n",
187 buf[i], reg + i, reg + i);
190 return 0;
194 * wm831x_reg_read: Read a single WM831x register.
196 * @wm831x: Device to read from.
197 * @reg: Register to read.
199 int wm831x_reg_read(struct wm831x *wm831x, unsigned short reg)
201 unsigned short val;
202 int ret;
204 mutex_lock(&wm831x->io_lock);
206 ret = wm831x_read(wm831x, reg, 2, &val);
208 mutex_unlock(&wm831x->io_lock);
210 if (ret < 0)
211 return ret;
212 else
213 return val;
215 EXPORT_SYMBOL_GPL(wm831x_reg_read);
218 * wm831x_bulk_read: Read multiple WM831x registers
220 * @wm831x: Device to read from
221 * @reg: First register
222 * @count: Number of registers
223 * @buf: Buffer to fill.
225 int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg,
226 int count, u16 *buf)
228 int ret;
230 mutex_lock(&wm831x->io_lock);
232 ret = wm831x_read(wm831x, reg, count * 2, buf);
234 mutex_unlock(&wm831x->io_lock);
236 return ret;
238 EXPORT_SYMBOL_GPL(wm831x_bulk_read);
240 static int wm831x_write(struct wm831x *wm831x, unsigned short reg,
241 int bytes, void *src)
243 u16 *buf = src;
244 int i;
246 BUG_ON(bytes % 2);
247 BUG_ON(bytes <= 0);
249 for (i = 0; i < bytes / 2; i++) {
250 if (wm831x_reg_locked(wm831x, reg))
251 return -EPERM;
253 dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n",
254 buf[i], reg + i, reg + i);
256 buf[i] = cpu_to_be16(buf[i]);
259 return wm831x->write_dev(wm831x, reg, bytes, src);
263 * wm831x_reg_write: Write a single WM831x register.
265 * @wm831x: Device to write to.
266 * @reg: Register to write to.
267 * @val: Value to write.
269 int wm831x_reg_write(struct wm831x *wm831x, unsigned short reg,
270 unsigned short val)
272 int ret;
274 mutex_lock(&wm831x->io_lock);
276 ret = wm831x_write(wm831x, reg, 2, &val);
278 mutex_unlock(&wm831x->io_lock);
280 return ret;
282 EXPORT_SYMBOL_GPL(wm831x_reg_write);
285 * wm831x_set_bits: Set the value of a bitfield in a WM831x register
287 * @wm831x: Device to write to.
288 * @reg: Register to write to.
289 * @mask: Mask of bits to set.
290 * @val: Value to set (unshifted)
292 int wm831x_set_bits(struct wm831x *wm831x, unsigned short reg,
293 unsigned short mask, unsigned short val)
295 int ret;
296 u16 r;
298 mutex_lock(&wm831x->io_lock);
300 ret = wm831x_read(wm831x, reg, 2, &r);
301 if (ret < 0)
302 goto out;
304 r &= ~mask;
305 r |= val;
307 ret = wm831x_write(wm831x, reg, 2, &r);
309 out:
310 mutex_unlock(&wm831x->io_lock);
312 return ret;
314 EXPORT_SYMBOL_GPL(wm831x_set_bits);
317 * wm831x_auxadc_read: Read a value from the WM831x AUXADC
319 * @wm831x: Device to read from.
320 * @input: AUXADC input to read.
322 int wm831x_auxadc_read(struct wm831x *wm831x, enum wm831x_auxadc input)
324 int tries = 10;
325 int ret, src;
327 mutex_lock(&wm831x->auxadc_lock);
329 ret = wm831x_set_bits(wm831x, WM831X_AUXADC_CONTROL,
330 WM831X_AUX_ENA, WM831X_AUX_ENA);
331 if (ret < 0) {
332 dev_err(wm831x->dev, "Failed to enable AUXADC: %d\n", ret);
333 goto out;
336 /* We force a single source at present */
337 src = input;
338 ret = wm831x_reg_write(wm831x, WM831X_AUXADC_SOURCE,
339 1 << src);
340 if (ret < 0) {
341 dev_err(wm831x->dev, "Failed to set AUXADC source: %d\n", ret);
342 goto out;
345 ret = wm831x_set_bits(wm831x, WM831X_AUXADC_CONTROL,
346 WM831X_AUX_CVT_ENA, WM831X_AUX_CVT_ENA);
347 if (ret < 0) {
348 dev_err(wm831x->dev, "Failed to start AUXADC: %d\n", ret);
349 goto disable;
352 do {
353 msleep(1);
355 ret = wm831x_reg_read(wm831x, WM831X_AUXADC_CONTROL);
356 if (ret < 0)
357 ret = WM831X_AUX_CVT_ENA;
358 } while ((ret & WM831X_AUX_CVT_ENA) && --tries);
360 if (ret & WM831X_AUX_CVT_ENA) {
361 dev_err(wm831x->dev, "Timed out reading AUXADC\n");
362 ret = -EBUSY;
363 goto disable;
366 ret = wm831x_reg_read(wm831x, WM831X_AUXADC_DATA);
367 if (ret < 0) {
368 dev_err(wm831x->dev, "Failed to read AUXADC data: %d\n", ret);
369 } else {
370 src = ((ret & WM831X_AUX_DATA_SRC_MASK)
371 >> WM831X_AUX_DATA_SRC_SHIFT) - 1;
373 if (src == 14)
374 src = WM831X_AUX_CAL;
376 if (src != input) {
377 dev_err(wm831x->dev, "Data from source %d not %d\n",
378 src, input);
379 ret = -EINVAL;
380 } else {
381 ret &= WM831X_AUX_DATA_MASK;
385 disable:
386 wm831x_set_bits(wm831x, WM831X_AUXADC_CONTROL, WM831X_AUX_ENA, 0);
387 out:
388 mutex_unlock(&wm831x->auxadc_lock);
389 return ret;
391 EXPORT_SYMBOL_GPL(wm831x_auxadc_read);
394 * wm831x_auxadc_read_uv: Read a voltage from the WM831x AUXADC
396 * @wm831x: Device to read from.
397 * @input: AUXADC input to read.
399 int wm831x_auxadc_read_uv(struct wm831x *wm831x, enum wm831x_auxadc input)
401 int ret;
403 ret = wm831x_auxadc_read(wm831x, input);
404 if (ret < 0)
405 return ret;
407 ret *= 1465;
409 return ret;
411 EXPORT_SYMBOL_GPL(wm831x_auxadc_read_uv);
413 static struct resource wm831x_dcdc1_resources[] = {
415 .start = WM831X_DC1_CONTROL_1,
416 .end = WM831X_DC1_DVS_CONTROL,
417 .flags = IORESOURCE_IO,
420 .name = "UV",
421 .start = WM831X_IRQ_UV_DC1,
422 .end = WM831X_IRQ_UV_DC1,
423 .flags = IORESOURCE_IRQ,
426 .name = "HC",
427 .start = WM831X_IRQ_HC_DC1,
428 .end = WM831X_IRQ_HC_DC1,
429 .flags = IORESOURCE_IRQ,
434 static struct resource wm831x_dcdc2_resources[] = {
436 .start = WM831X_DC2_CONTROL_1,
437 .end = WM831X_DC2_DVS_CONTROL,
438 .flags = IORESOURCE_IO,
441 .name = "UV",
442 .start = WM831X_IRQ_UV_DC2,
443 .end = WM831X_IRQ_UV_DC2,
444 .flags = IORESOURCE_IRQ,
447 .name = "HC",
448 .start = WM831X_IRQ_HC_DC2,
449 .end = WM831X_IRQ_HC_DC2,
450 .flags = IORESOURCE_IRQ,
454 static struct resource wm831x_dcdc3_resources[] = {
456 .start = WM831X_DC3_CONTROL_1,
457 .end = WM831X_DC3_SLEEP_CONTROL,
458 .flags = IORESOURCE_IO,
461 .name = "UV",
462 .start = WM831X_IRQ_UV_DC3,
463 .end = WM831X_IRQ_UV_DC3,
464 .flags = IORESOURCE_IRQ,
468 static struct resource wm831x_dcdc4_resources[] = {
470 .start = WM831X_DC4_CONTROL,
471 .end = WM831X_DC4_SLEEP_CONTROL,
472 .flags = IORESOURCE_IO,
475 .name = "UV",
476 .start = WM831X_IRQ_UV_DC4,
477 .end = WM831X_IRQ_UV_DC4,
478 .flags = IORESOURCE_IRQ,
482 static struct resource wm8320_dcdc4_buck_resources[] = {
484 .start = WM831X_DC4_CONTROL,
485 .end = WM832X_DC4_SLEEP_CONTROL,
486 .flags = IORESOURCE_IO,
489 .name = "UV",
490 .start = WM831X_IRQ_UV_DC4,
491 .end = WM831X_IRQ_UV_DC4,
492 .flags = IORESOURCE_IRQ,
496 static struct resource wm831x_gpio_resources[] = {
498 .start = WM831X_IRQ_GPIO_1,
499 .end = WM831X_IRQ_GPIO_16,
500 .flags = IORESOURCE_IRQ,
504 static struct resource wm831x_isink1_resources[] = {
506 .start = WM831X_CURRENT_SINK_1,
507 .end = WM831X_CURRENT_SINK_1,
508 .flags = IORESOURCE_IO,
511 .start = WM831X_IRQ_CS1,
512 .end = WM831X_IRQ_CS1,
513 .flags = IORESOURCE_IRQ,
517 static struct resource wm831x_isink2_resources[] = {
519 .start = WM831X_CURRENT_SINK_2,
520 .end = WM831X_CURRENT_SINK_2,
521 .flags = IORESOURCE_IO,
524 .start = WM831X_IRQ_CS2,
525 .end = WM831X_IRQ_CS2,
526 .flags = IORESOURCE_IRQ,
530 static struct resource wm831x_ldo1_resources[] = {
532 .start = WM831X_LDO1_CONTROL,
533 .end = WM831X_LDO1_SLEEP_CONTROL,
534 .flags = IORESOURCE_IO,
537 .name = "UV",
538 .start = WM831X_IRQ_UV_LDO1,
539 .end = WM831X_IRQ_UV_LDO1,
540 .flags = IORESOURCE_IRQ,
544 static struct resource wm831x_ldo2_resources[] = {
546 .start = WM831X_LDO2_CONTROL,
547 .end = WM831X_LDO2_SLEEP_CONTROL,
548 .flags = IORESOURCE_IO,
551 .name = "UV",
552 .start = WM831X_IRQ_UV_LDO2,
553 .end = WM831X_IRQ_UV_LDO2,
554 .flags = IORESOURCE_IRQ,
558 static struct resource wm831x_ldo3_resources[] = {
560 .start = WM831X_LDO3_CONTROL,
561 .end = WM831X_LDO3_SLEEP_CONTROL,
562 .flags = IORESOURCE_IO,
565 .name = "UV",
566 .start = WM831X_IRQ_UV_LDO3,
567 .end = WM831X_IRQ_UV_LDO3,
568 .flags = IORESOURCE_IRQ,
572 static struct resource wm831x_ldo4_resources[] = {
574 .start = WM831X_LDO4_CONTROL,
575 .end = WM831X_LDO4_SLEEP_CONTROL,
576 .flags = IORESOURCE_IO,
579 .name = "UV",
580 .start = WM831X_IRQ_UV_LDO4,
581 .end = WM831X_IRQ_UV_LDO4,
582 .flags = IORESOURCE_IRQ,
586 static struct resource wm831x_ldo5_resources[] = {
588 .start = WM831X_LDO5_CONTROL,
589 .end = WM831X_LDO5_SLEEP_CONTROL,
590 .flags = IORESOURCE_IO,
593 .name = "UV",
594 .start = WM831X_IRQ_UV_LDO5,
595 .end = WM831X_IRQ_UV_LDO5,
596 .flags = IORESOURCE_IRQ,
600 static struct resource wm831x_ldo6_resources[] = {
602 .start = WM831X_LDO6_CONTROL,
603 .end = WM831X_LDO6_SLEEP_CONTROL,
604 .flags = IORESOURCE_IO,
607 .name = "UV",
608 .start = WM831X_IRQ_UV_LDO6,
609 .end = WM831X_IRQ_UV_LDO6,
610 .flags = IORESOURCE_IRQ,
614 static struct resource wm831x_ldo7_resources[] = {
616 .start = WM831X_LDO7_CONTROL,
617 .end = WM831X_LDO7_SLEEP_CONTROL,
618 .flags = IORESOURCE_IO,
621 .name = "UV",
622 .start = WM831X_IRQ_UV_LDO7,
623 .end = WM831X_IRQ_UV_LDO7,
624 .flags = IORESOURCE_IRQ,
628 static struct resource wm831x_ldo8_resources[] = {
630 .start = WM831X_LDO8_CONTROL,
631 .end = WM831X_LDO8_SLEEP_CONTROL,
632 .flags = IORESOURCE_IO,
635 .name = "UV",
636 .start = WM831X_IRQ_UV_LDO8,
637 .end = WM831X_IRQ_UV_LDO8,
638 .flags = IORESOURCE_IRQ,
642 static struct resource wm831x_ldo9_resources[] = {
644 .start = WM831X_LDO9_CONTROL,
645 .end = WM831X_LDO9_SLEEP_CONTROL,
646 .flags = IORESOURCE_IO,
649 .name = "UV",
650 .start = WM831X_IRQ_UV_LDO9,
651 .end = WM831X_IRQ_UV_LDO9,
652 .flags = IORESOURCE_IRQ,
656 static struct resource wm831x_ldo10_resources[] = {
658 .start = WM831X_LDO10_CONTROL,
659 .end = WM831X_LDO10_SLEEP_CONTROL,
660 .flags = IORESOURCE_IO,
663 .name = "UV",
664 .start = WM831X_IRQ_UV_LDO10,
665 .end = WM831X_IRQ_UV_LDO10,
666 .flags = IORESOURCE_IRQ,
670 static struct resource wm831x_ldo11_resources[] = {
672 .start = WM831X_LDO11_ON_CONTROL,
673 .end = WM831X_LDO11_SLEEP_CONTROL,
674 .flags = IORESOURCE_IO,
678 static struct resource wm831x_on_resources[] = {
680 .start = WM831X_IRQ_ON,
681 .end = WM831X_IRQ_ON,
682 .flags = IORESOURCE_IRQ,
687 static struct resource wm831x_power_resources[] = {
689 .name = "SYSLO",
690 .start = WM831X_IRQ_PPM_SYSLO,
691 .end = WM831X_IRQ_PPM_SYSLO,
692 .flags = IORESOURCE_IRQ,
695 .name = "PWR SRC",
696 .start = WM831X_IRQ_PPM_PWR_SRC,
697 .end = WM831X_IRQ_PPM_PWR_SRC,
698 .flags = IORESOURCE_IRQ,
701 .name = "USB CURR",
702 .start = WM831X_IRQ_PPM_USB_CURR,
703 .end = WM831X_IRQ_PPM_USB_CURR,
704 .flags = IORESOURCE_IRQ,
707 .name = "BATT HOT",
708 .start = WM831X_IRQ_CHG_BATT_HOT,
709 .end = WM831X_IRQ_CHG_BATT_HOT,
710 .flags = IORESOURCE_IRQ,
713 .name = "BATT COLD",
714 .start = WM831X_IRQ_CHG_BATT_COLD,
715 .end = WM831X_IRQ_CHG_BATT_COLD,
716 .flags = IORESOURCE_IRQ,
719 .name = "BATT FAIL",
720 .start = WM831X_IRQ_CHG_BATT_FAIL,
721 .end = WM831X_IRQ_CHG_BATT_FAIL,
722 .flags = IORESOURCE_IRQ,
725 .name = "OV",
726 .start = WM831X_IRQ_CHG_OV,
727 .end = WM831X_IRQ_CHG_OV,
728 .flags = IORESOURCE_IRQ,
731 .name = "END",
732 .start = WM831X_IRQ_CHG_END,
733 .end = WM831X_IRQ_CHG_END,
734 .flags = IORESOURCE_IRQ,
737 .name = "TO",
738 .start = WM831X_IRQ_CHG_TO,
739 .end = WM831X_IRQ_CHG_TO,
740 .flags = IORESOURCE_IRQ,
743 .name = "MODE",
744 .start = WM831X_IRQ_CHG_MODE,
745 .end = WM831X_IRQ_CHG_MODE,
746 .flags = IORESOURCE_IRQ,
749 .name = "START",
750 .start = WM831X_IRQ_CHG_START,
751 .end = WM831X_IRQ_CHG_START,
752 .flags = IORESOURCE_IRQ,
756 static struct resource wm831x_rtc_resources[] = {
758 .name = "PER",
759 .start = WM831X_IRQ_RTC_PER,
760 .end = WM831X_IRQ_RTC_PER,
761 .flags = IORESOURCE_IRQ,
764 .name = "ALM",
765 .start = WM831X_IRQ_RTC_ALM,
766 .end = WM831X_IRQ_RTC_ALM,
767 .flags = IORESOURCE_IRQ,
771 static struct resource wm831x_status1_resources[] = {
773 .start = WM831X_STATUS_LED_1,
774 .end = WM831X_STATUS_LED_1,
775 .flags = IORESOURCE_IO,
779 static struct resource wm831x_status2_resources[] = {
781 .start = WM831X_STATUS_LED_2,
782 .end = WM831X_STATUS_LED_2,
783 .flags = IORESOURCE_IO,
787 static struct resource wm831x_touch_resources[] = {
789 .name = "TCHPD",
790 .start = WM831X_IRQ_TCHPD,
791 .end = WM831X_IRQ_TCHPD,
792 .flags = IORESOURCE_IRQ,
795 .name = "TCHDATA",
796 .start = WM831X_IRQ_TCHDATA,
797 .end = WM831X_IRQ_TCHDATA,
798 .flags = IORESOURCE_IRQ,
802 static struct resource wm831x_wdt_resources[] = {
804 .start = WM831X_IRQ_WDOG_TO,
805 .end = WM831X_IRQ_WDOG_TO,
806 .flags = IORESOURCE_IRQ,
810 static struct mfd_cell wm8310_devs[] = {
812 .name = "wm831x-backup",
815 .name = "wm831x-buckv",
816 .id = 1,
817 .num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
818 .resources = wm831x_dcdc1_resources,
821 .name = "wm831x-buckv",
822 .id = 2,
823 .num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
824 .resources = wm831x_dcdc2_resources,
827 .name = "wm831x-buckp",
828 .id = 3,
829 .num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
830 .resources = wm831x_dcdc3_resources,
833 .name = "wm831x-boostp",
834 .id = 4,
835 .num_resources = ARRAY_SIZE(wm831x_dcdc4_resources),
836 .resources = wm831x_dcdc4_resources,
839 .name = "wm831x-epe",
840 .id = 1,
843 .name = "wm831x-epe",
844 .id = 2,
847 .name = "wm831x-gpio",
848 .num_resources = ARRAY_SIZE(wm831x_gpio_resources),
849 .resources = wm831x_gpio_resources,
852 .name = "wm831x-hwmon",
855 .name = "wm831x-isink",
856 .id = 1,
857 .num_resources = ARRAY_SIZE(wm831x_isink1_resources),
858 .resources = wm831x_isink1_resources,
861 .name = "wm831x-isink",
862 .id = 2,
863 .num_resources = ARRAY_SIZE(wm831x_isink2_resources),
864 .resources = wm831x_isink2_resources,
867 .name = "wm831x-ldo",
868 .id = 1,
869 .num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
870 .resources = wm831x_ldo1_resources,
873 .name = "wm831x-ldo",
874 .id = 2,
875 .num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
876 .resources = wm831x_ldo2_resources,
879 .name = "wm831x-ldo",
880 .id = 3,
881 .num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
882 .resources = wm831x_ldo3_resources,
885 .name = "wm831x-ldo",
886 .id = 4,
887 .num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
888 .resources = wm831x_ldo4_resources,
891 .name = "wm831x-ldo",
892 .id = 5,
893 .num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
894 .resources = wm831x_ldo5_resources,
897 .name = "wm831x-ldo",
898 .id = 6,
899 .num_resources = ARRAY_SIZE(wm831x_ldo6_resources),
900 .resources = wm831x_ldo6_resources,
903 .name = "wm831x-aldo",
904 .id = 7,
905 .num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
906 .resources = wm831x_ldo7_resources,
909 .name = "wm831x-aldo",
910 .id = 8,
911 .num_resources = ARRAY_SIZE(wm831x_ldo8_resources),
912 .resources = wm831x_ldo8_resources,
915 .name = "wm831x-aldo",
916 .id = 9,
917 .num_resources = ARRAY_SIZE(wm831x_ldo9_resources),
918 .resources = wm831x_ldo9_resources,
921 .name = "wm831x-aldo",
922 .id = 10,
923 .num_resources = ARRAY_SIZE(wm831x_ldo10_resources),
924 .resources = wm831x_ldo10_resources,
927 .name = "wm831x-alive-ldo",
928 .id = 11,
929 .num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
930 .resources = wm831x_ldo11_resources,
933 .name = "wm831x-on",
934 .num_resources = ARRAY_SIZE(wm831x_on_resources),
935 .resources = wm831x_on_resources,
938 .name = "wm831x-power",
939 .num_resources = ARRAY_SIZE(wm831x_power_resources),
940 .resources = wm831x_power_resources,
943 .name = "wm831x-rtc",
944 .num_resources = ARRAY_SIZE(wm831x_rtc_resources),
945 .resources = wm831x_rtc_resources,
948 .name = "wm831x-status",
949 .id = 1,
950 .num_resources = ARRAY_SIZE(wm831x_status1_resources),
951 .resources = wm831x_status1_resources,
954 .name = "wm831x-status",
955 .id = 2,
956 .num_resources = ARRAY_SIZE(wm831x_status2_resources),
957 .resources = wm831x_status2_resources,
960 .name = "wm831x-watchdog",
961 .num_resources = ARRAY_SIZE(wm831x_wdt_resources),
962 .resources = wm831x_wdt_resources,
966 static struct mfd_cell wm8311_devs[] = {
968 .name = "wm831x-backup",
971 .name = "wm831x-buckv",
972 .id = 1,
973 .num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
974 .resources = wm831x_dcdc1_resources,
977 .name = "wm831x-buckv",
978 .id = 2,
979 .num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
980 .resources = wm831x_dcdc2_resources,
983 .name = "wm831x-buckp",
984 .id = 3,
985 .num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
986 .resources = wm831x_dcdc3_resources,
989 .name = "wm831x-boostp",
990 .id = 4,
991 .num_resources = ARRAY_SIZE(wm831x_dcdc4_resources),
992 .resources = wm831x_dcdc4_resources,
995 .name = "wm831x-epe",
996 .id = 1,
999 .name = "wm831x-epe",
1000 .id = 2,
1003 .name = "wm831x-gpio",
1004 .num_resources = ARRAY_SIZE(wm831x_gpio_resources),
1005 .resources = wm831x_gpio_resources,
1008 .name = "wm831x-hwmon",
1011 .name = "wm831x-isink",
1012 .id = 1,
1013 .num_resources = ARRAY_SIZE(wm831x_isink1_resources),
1014 .resources = wm831x_isink1_resources,
1017 .name = "wm831x-isink",
1018 .id = 2,
1019 .num_resources = ARRAY_SIZE(wm831x_isink2_resources),
1020 .resources = wm831x_isink2_resources,
1023 .name = "wm831x-ldo",
1024 .id = 1,
1025 .num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
1026 .resources = wm831x_ldo1_resources,
1029 .name = "wm831x-ldo",
1030 .id = 2,
1031 .num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
1032 .resources = wm831x_ldo2_resources,
1035 .name = "wm831x-ldo",
1036 .id = 3,
1037 .num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
1038 .resources = wm831x_ldo3_resources,
1041 .name = "wm831x-ldo",
1042 .id = 4,
1043 .num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
1044 .resources = wm831x_ldo4_resources,
1047 .name = "wm831x-ldo",
1048 .id = 5,
1049 .num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
1050 .resources = wm831x_ldo5_resources,
1053 .name = "wm831x-aldo",
1054 .id = 7,
1055 .num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
1056 .resources = wm831x_ldo7_resources,
1059 .name = "wm831x-alive-ldo",
1060 .id = 11,
1061 .num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
1062 .resources = wm831x_ldo11_resources,
1065 .name = "wm831x-on",
1066 .num_resources = ARRAY_SIZE(wm831x_on_resources),
1067 .resources = wm831x_on_resources,
1070 .name = "wm831x-power",
1071 .num_resources = ARRAY_SIZE(wm831x_power_resources),
1072 .resources = wm831x_power_resources,
1075 .name = "wm831x-rtc",
1076 .num_resources = ARRAY_SIZE(wm831x_rtc_resources),
1077 .resources = wm831x_rtc_resources,
1080 .name = "wm831x-status",
1081 .id = 1,
1082 .num_resources = ARRAY_SIZE(wm831x_status1_resources),
1083 .resources = wm831x_status1_resources,
1086 .name = "wm831x-status",
1087 .id = 2,
1088 .num_resources = ARRAY_SIZE(wm831x_status2_resources),
1089 .resources = wm831x_status2_resources,
1092 .name = "wm831x-touch",
1093 .num_resources = ARRAY_SIZE(wm831x_touch_resources),
1094 .resources = wm831x_touch_resources,
1097 .name = "wm831x-watchdog",
1098 .num_resources = ARRAY_SIZE(wm831x_wdt_resources),
1099 .resources = wm831x_wdt_resources,
1103 static struct mfd_cell wm8312_devs[] = {
1105 .name = "wm831x-backup",
1108 .name = "wm831x-buckv",
1109 .id = 1,
1110 .num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
1111 .resources = wm831x_dcdc1_resources,
1114 .name = "wm831x-buckv",
1115 .id = 2,
1116 .num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
1117 .resources = wm831x_dcdc2_resources,
1120 .name = "wm831x-buckp",
1121 .id = 3,
1122 .num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
1123 .resources = wm831x_dcdc3_resources,
1126 .name = "wm831x-boostp",
1127 .id = 4,
1128 .num_resources = ARRAY_SIZE(wm831x_dcdc4_resources),
1129 .resources = wm831x_dcdc4_resources,
1132 .name = "wm831x-epe",
1133 .id = 1,
1136 .name = "wm831x-epe",
1137 .id = 2,
1140 .name = "wm831x-gpio",
1141 .num_resources = ARRAY_SIZE(wm831x_gpio_resources),
1142 .resources = wm831x_gpio_resources,
1145 .name = "wm831x-hwmon",
1148 .name = "wm831x-isink",
1149 .id = 1,
1150 .num_resources = ARRAY_SIZE(wm831x_isink1_resources),
1151 .resources = wm831x_isink1_resources,
1154 .name = "wm831x-isink",
1155 .id = 2,
1156 .num_resources = ARRAY_SIZE(wm831x_isink2_resources),
1157 .resources = wm831x_isink2_resources,
1160 .name = "wm831x-ldo",
1161 .id = 1,
1162 .num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
1163 .resources = wm831x_ldo1_resources,
1166 .name = "wm831x-ldo",
1167 .id = 2,
1168 .num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
1169 .resources = wm831x_ldo2_resources,
1172 .name = "wm831x-ldo",
1173 .id = 3,
1174 .num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
1175 .resources = wm831x_ldo3_resources,
1178 .name = "wm831x-ldo",
1179 .id = 4,
1180 .num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
1181 .resources = wm831x_ldo4_resources,
1184 .name = "wm831x-ldo",
1185 .id = 5,
1186 .num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
1187 .resources = wm831x_ldo5_resources,
1190 .name = "wm831x-ldo",
1191 .id = 6,
1192 .num_resources = ARRAY_SIZE(wm831x_ldo6_resources),
1193 .resources = wm831x_ldo6_resources,
1196 .name = "wm831x-aldo",
1197 .id = 7,
1198 .num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
1199 .resources = wm831x_ldo7_resources,
1202 .name = "wm831x-aldo",
1203 .id = 8,
1204 .num_resources = ARRAY_SIZE(wm831x_ldo8_resources),
1205 .resources = wm831x_ldo8_resources,
1208 .name = "wm831x-aldo",
1209 .id = 9,
1210 .num_resources = ARRAY_SIZE(wm831x_ldo9_resources),
1211 .resources = wm831x_ldo9_resources,
1214 .name = "wm831x-aldo",
1215 .id = 10,
1216 .num_resources = ARRAY_SIZE(wm831x_ldo10_resources),
1217 .resources = wm831x_ldo10_resources,
1220 .name = "wm831x-alive-ldo",
1221 .id = 11,
1222 .num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
1223 .resources = wm831x_ldo11_resources,
1226 .name = "wm831x-on",
1227 .num_resources = ARRAY_SIZE(wm831x_on_resources),
1228 .resources = wm831x_on_resources,
1231 .name = "wm831x-power",
1232 .num_resources = ARRAY_SIZE(wm831x_power_resources),
1233 .resources = wm831x_power_resources,
1236 .name = "wm831x-rtc",
1237 .num_resources = ARRAY_SIZE(wm831x_rtc_resources),
1238 .resources = wm831x_rtc_resources,
1241 .name = "wm831x-status",
1242 .id = 1,
1243 .num_resources = ARRAY_SIZE(wm831x_status1_resources),
1244 .resources = wm831x_status1_resources,
1247 .name = "wm831x-status",
1248 .id = 2,
1249 .num_resources = ARRAY_SIZE(wm831x_status2_resources),
1250 .resources = wm831x_status2_resources,
1253 .name = "wm831x-touch",
1254 .num_resources = ARRAY_SIZE(wm831x_touch_resources),
1255 .resources = wm831x_touch_resources,
1258 .name = "wm831x-watchdog",
1259 .num_resources = ARRAY_SIZE(wm831x_wdt_resources),
1260 .resources = wm831x_wdt_resources,
1264 static struct mfd_cell wm8320_devs[] = {
1266 .name = "wm831x-backup",
1269 .name = "wm831x-buckv",
1270 .id = 1,
1271 .num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
1272 .resources = wm831x_dcdc1_resources,
1275 .name = "wm831x-buckv",
1276 .id = 2,
1277 .num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
1278 .resources = wm831x_dcdc2_resources,
1281 .name = "wm831x-buckp",
1282 .id = 3,
1283 .num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
1284 .resources = wm831x_dcdc3_resources,
1287 .name = "wm831x-buckp",
1288 .id = 4,
1289 .num_resources = ARRAY_SIZE(wm8320_dcdc4_buck_resources),
1290 .resources = wm8320_dcdc4_buck_resources,
1293 .name = "wm831x-gpio",
1294 .num_resources = ARRAY_SIZE(wm831x_gpio_resources),
1295 .resources = wm831x_gpio_resources,
1298 .name = "wm831x-hwmon",
1301 .name = "wm831x-ldo",
1302 .id = 1,
1303 .num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
1304 .resources = wm831x_ldo1_resources,
1307 .name = "wm831x-ldo",
1308 .id = 2,
1309 .num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
1310 .resources = wm831x_ldo2_resources,
1313 .name = "wm831x-ldo",
1314 .id = 3,
1315 .num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
1316 .resources = wm831x_ldo3_resources,
1319 .name = "wm831x-ldo",
1320 .id = 4,
1321 .num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
1322 .resources = wm831x_ldo4_resources,
1325 .name = "wm831x-ldo",
1326 .id = 5,
1327 .num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
1328 .resources = wm831x_ldo5_resources,
1331 .name = "wm831x-ldo",
1332 .id = 6,
1333 .num_resources = ARRAY_SIZE(wm831x_ldo6_resources),
1334 .resources = wm831x_ldo6_resources,
1337 .name = "wm831x-aldo",
1338 .id = 7,
1339 .num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
1340 .resources = wm831x_ldo7_resources,
1343 .name = "wm831x-aldo",
1344 .id = 8,
1345 .num_resources = ARRAY_SIZE(wm831x_ldo8_resources),
1346 .resources = wm831x_ldo8_resources,
1349 .name = "wm831x-aldo",
1350 .id = 9,
1351 .num_resources = ARRAY_SIZE(wm831x_ldo9_resources),
1352 .resources = wm831x_ldo9_resources,
1355 .name = "wm831x-aldo",
1356 .id = 10,
1357 .num_resources = ARRAY_SIZE(wm831x_ldo10_resources),
1358 .resources = wm831x_ldo10_resources,
1361 .name = "wm831x-alive-ldo",
1362 .id = 11,
1363 .num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
1364 .resources = wm831x_ldo11_resources,
1367 .name = "wm831x-on",
1368 .num_resources = ARRAY_SIZE(wm831x_on_resources),
1369 .resources = wm831x_on_resources,
1372 .name = "wm831x-rtc",
1373 .num_resources = ARRAY_SIZE(wm831x_rtc_resources),
1374 .resources = wm831x_rtc_resources,
1377 .name = "wm831x-status",
1378 .id = 1,
1379 .num_resources = ARRAY_SIZE(wm831x_status1_resources),
1380 .resources = wm831x_status1_resources,
1383 .name = "wm831x-status",
1384 .id = 2,
1385 .num_resources = ARRAY_SIZE(wm831x_status2_resources),
1386 .resources = wm831x_status2_resources,
1389 .name = "wm831x-watchdog",
1390 .num_resources = ARRAY_SIZE(wm831x_wdt_resources),
1391 .resources = wm831x_wdt_resources,
1395 static struct mfd_cell backlight_devs[] = {
1397 .name = "wm831x-backlight",
1402 * Instantiate the generic non-control parts of the device.
1404 static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1406 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
1407 int rev;
1408 enum wm831x_parent parent;
1409 int ret;
1411 mutex_init(&wm831x->io_lock);
1412 mutex_init(&wm831x->key_lock);
1413 mutex_init(&wm831x->auxadc_lock);
1414 dev_set_drvdata(wm831x->dev, wm831x);
1416 ret = wm831x_reg_read(wm831x, WM831X_PARENT_ID);
1417 if (ret < 0) {
1418 dev_err(wm831x->dev, "Failed to read parent ID: %d\n", ret);
1419 goto err;
1421 if (ret != 0x6204) {
1422 dev_err(wm831x->dev, "Device is not a WM831x: ID %x\n", ret);
1423 ret = -EINVAL;
1424 goto err;
1427 ret = wm831x_reg_read(wm831x, WM831X_REVISION);
1428 if (ret < 0) {
1429 dev_err(wm831x->dev, "Failed to read revision: %d\n", ret);
1430 goto err;
1432 rev = (ret & WM831X_PARENT_REV_MASK) >> WM831X_PARENT_REV_SHIFT;
1434 ret = wm831x_reg_read(wm831x, WM831X_RESET_ID);
1435 if (ret < 0) {
1436 dev_err(wm831x->dev, "Failed to read device ID: %d\n", ret);
1437 goto err;
1440 /* Some engineering samples do not have the ID set, rely on
1441 * the device being registered correctly.
1443 if (ret == 0) {
1444 dev_info(wm831x->dev, "Device is an engineering sample\n");
1445 ret = id;
1448 switch (ret) {
1449 case WM8310:
1450 parent = WM8310;
1451 wm831x->num_gpio = 16;
1452 dev_info(wm831x->dev, "WM8310 revision %c\n", 'A' + rev);
1453 break;
1455 case WM8311:
1456 parent = WM8311;
1457 wm831x->num_gpio = 16;
1458 dev_info(wm831x->dev, "WM8311 revision %c\n", 'A' + rev);
1459 break;
1461 case WM8312:
1462 parent = WM8312;
1463 wm831x->num_gpio = 16;
1464 dev_info(wm831x->dev, "WM8312 revision %c\n", 'A' + rev);
1465 break;
1467 case WM8320:
1468 parent = WM8320;
1469 wm831x->num_gpio = 12;
1470 dev_info(wm831x->dev, "WM8320 revision %c\n", 'A' + rev);
1471 break;
1473 default:
1474 dev_err(wm831x->dev, "Unknown WM831x device %04x\n", ret);
1475 ret = -EINVAL;
1476 goto err;
1479 /* This will need revisiting in future but is OK for all
1480 * current parts.
1482 if (parent != id)
1483 dev_warn(wm831x->dev, "Device was registered as a WM%lx\n",
1484 id);
1486 /* Bootstrap the user key */
1487 ret = wm831x_reg_read(wm831x, WM831X_SECURITY_KEY);
1488 if (ret < 0) {
1489 dev_err(wm831x->dev, "Failed to read security key: %d\n", ret);
1490 goto err;
1492 if (ret != 0) {
1493 dev_warn(wm831x->dev, "Security key had non-zero value %x\n",
1494 ret);
1495 wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0);
1497 wm831x->locked = 1;
1499 if (pdata && pdata->pre_init) {
1500 ret = pdata->pre_init(wm831x);
1501 if (ret != 0) {
1502 dev_err(wm831x->dev, "pre_init() failed: %d\n", ret);
1503 goto err;
1507 ret = wm831x_irq_init(wm831x, irq);
1508 if (ret != 0)
1509 goto err;
1511 /* The core device is up, instantiate the subdevices. */
1512 switch (parent) {
1513 case WM8310:
1514 ret = mfd_add_devices(wm831x->dev, -1,
1515 wm8310_devs, ARRAY_SIZE(wm8310_devs),
1516 NULL, wm831x->irq_base);
1517 break;
1519 case WM8311:
1520 ret = mfd_add_devices(wm831x->dev, -1,
1521 wm8311_devs, ARRAY_SIZE(wm8311_devs),
1522 NULL, wm831x->irq_base);
1523 break;
1525 case WM8312:
1526 ret = mfd_add_devices(wm831x->dev, -1,
1527 wm8312_devs, ARRAY_SIZE(wm8312_devs),
1528 NULL, wm831x->irq_base);
1529 break;
1531 case WM8320:
1532 ret = mfd_add_devices(wm831x->dev, -1,
1533 wm8320_devs, ARRAY_SIZE(wm8320_devs),
1534 NULL, 0);
1535 break;
1537 default:
1538 /* If this happens the bus probe function is buggy */
1539 BUG();
1542 if (ret != 0) {
1543 dev_err(wm831x->dev, "Failed to add children\n");
1544 goto err_irq;
1547 if (pdata && pdata->backlight) {
1548 /* Treat errors as non-critical */
1549 ret = mfd_add_devices(wm831x->dev, -1, backlight_devs,
1550 ARRAY_SIZE(backlight_devs), NULL,
1551 wm831x->irq_base);
1552 if (ret < 0)
1553 dev_err(wm831x->dev, "Failed to add backlight: %d\n",
1554 ret);
1557 wm831x_otp_init(wm831x);
1559 if (pdata && pdata->post_init) {
1560 ret = pdata->post_init(wm831x);
1561 if (ret != 0) {
1562 dev_err(wm831x->dev, "post_init() failed: %d\n", ret);
1563 goto err_irq;
1567 return 0;
1569 err_irq:
1570 wm831x_irq_exit(wm831x);
1571 err:
1572 mfd_remove_devices(wm831x->dev);
1573 kfree(wm831x);
1574 return ret;
1577 static void wm831x_device_exit(struct wm831x *wm831x)
1579 wm831x_otp_exit(wm831x);
1580 mfd_remove_devices(wm831x->dev);
1581 wm831x_irq_exit(wm831x);
1582 kfree(wm831x);
1585 static int wm831x_i2c_read_device(struct wm831x *wm831x, unsigned short reg,
1586 int bytes, void *dest)
1588 struct i2c_client *i2c = wm831x->control_data;
1589 int ret;
1590 u16 r = cpu_to_be16(reg);
1592 ret = i2c_master_send(i2c, (unsigned char *)&r, 2);
1593 if (ret < 0)
1594 return ret;
1595 if (ret != 2)
1596 return -EIO;
1598 ret = i2c_master_recv(i2c, dest, bytes);
1599 if (ret < 0)
1600 return ret;
1601 if (ret != bytes)
1602 return -EIO;
1603 return 0;
1606 /* Currently we allocate the write buffer on the stack; this is OK for
1607 * small writes - if we need to do large writes this will need to be
1608 * revised.
1610 static int wm831x_i2c_write_device(struct wm831x *wm831x, unsigned short reg,
1611 int bytes, void *src)
1613 struct i2c_client *i2c = wm831x->control_data;
1614 unsigned char msg[bytes + 2];
1615 int ret;
1617 reg = cpu_to_be16(reg);
1618 memcpy(&msg[0], &reg, 2);
1619 memcpy(&msg[2], src, bytes);
1621 ret = i2c_master_send(i2c, msg, bytes + 2);
1622 if (ret < 0)
1623 return ret;
1624 if (ret < bytes + 2)
1625 return -EIO;
1627 return 0;
1630 static int wm831x_i2c_probe(struct i2c_client *i2c,
1631 const struct i2c_device_id *id)
1633 struct wm831x *wm831x;
1635 wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL);
1636 if (wm831x == NULL) {
1637 kfree(i2c);
1638 return -ENOMEM;
1641 i2c_set_clientdata(i2c, wm831x);
1642 wm831x->dev = &i2c->dev;
1643 wm831x->control_data = i2c;
1644 wm831x->read_dev = wm831x_i2c_read_device;
1645 wm831x->write_dev = wm831x_i2c_write_device;
1647 return wm831x_device_init(wm831x, id->driver_data, i2c->irq);
1650 static int wm831x_i2c_remove(struct i2c_client *i2c)
1652 struct wm831x *wm831x = i2c_get_clientdata(i2c);
1654 wm831x_device_exit(wm831x);
1656 return 0;
1659 static const struct i2c_device_id wm831x_i2c_id[] = {
1660 { "wm8310", WM8310 },
1661 { "wm8311", WM8311 },
1662 { "wm8312", WM8312 },
1663 { "wm8320", WM8320 },
1666 MODULE_DEVICE_TABLE(i2c, wm831x_i2c_id);
1669 static struct i2c_driver wm831x_i2c_driver = {
1670 .driver = {
1671 .name = "wm831x",
1672 .owner = THIS_MODULE,
1674 .probe = wm831x_i2c_probe,
1675 .remove = wm831x_i2c_remove,
1676 .id_table = wm831x_i2c_id,
1679 static int __init wm831x_i2c_init(void)
1681 int ret;
1683 ret = i2c_add_driver(&wm831x_i2c_driver);
1684 if (ret != 0)
1685 pr_err("Failed to register wm831x I2C driver: %d\n", ret);
1687 return ret;
1689 subsys_initcall(wm831x_i2c_init);
1691 static void __exit wm831x_i2c_exit(void)
1693 i2c_del_driver(&wm831x_i2c_driver);
1695 module_exit(wm831x_i2c_exit);
1697 MODULE_DESCRIPTION("I2C support for the WM831X AudioPlus PMIC");
1698 MODULE_LICENSE("GPL");
1699 MODULE_AUTHOR("Mark Brown");