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>
21 #include <linux/slab.h>
23 #include <linux/mfd/wm831x/core.h>
24 #include <linux/mfd/wm831x/pdata.h>
25 #include <linux/mfd/wm831x/irq.h>
26 #include <linux/mfd/wm831x/auxadc.h>
27 #include <linux/mfd/wm831x/otp.h>
28 #include <linux/mfd/wm831x/regulator.h>
30 /* Current settings - values are 2*2^(reg_val/4) microamps. These are
31 * exported since they are used by multiple drivers.
33 int wm831x_isinkv_values
[WM831X_ISINK_MAX_ISEL
+ 1] = {
91 EXPORT_SYMBOL_GPL(wm831x_isinkv_values
);
100 static int wm831x_reg_locked(struct wm831x
*wm831x
, unsigned short reg
)
106 case WM831X_WATCHDOG
:
107 case WM831X_DC4_CONTROL
:
108 case WM831X_ON_PIN_CONTROL
:
109 case WM831X_BACKUP_CHARGER_CONTROL
:
110 case WM831X_CHARGER_CONTROL_1
:
111 case WM831X_CHARGER_CONTROL_2
:
120 * wm831x_reg_unlock: Unlock user keyed registers
122 * The WM831x has a user key preventing writes to particularly
123 * critical registers. This function locks those registers,
124 * allowing writes to them.
126 void wm831x_reg_lock(struct wm831x
*wm831x
)
130 ret
= wm831x_reg_write(wm831x
, WM831X_SECURITY_KEY
, 0);
132 dev_vdbg(wm831x
->dev
, "Registers locked\n");
134 mutex_lock(&wm831x
->io_lock
);
135 WARN_ON(wm831x
->locked
);
137 mutex_unlock(&wm831x
->io_lock
);
139 dev_err(wm831x
->dev
, "Failed to lock registers: %d\n", ret
);
143 EXPORT_SYMBOL_GPL(wm831x_reg_lock
);
146 * wm831x_reg_unlock: Unlock user keyed registers
148 * The WM831x has a user key preventing writes to particularly
149 * critical registers. This function locks those registers,
150 * preventing spurious writes.
152 int wm831x_reg_unlock(struct wm831x
*wm831x
)
156 /* 0x9716 is the value required to unlock the registers */
157 ret
= wm831x_reg_write(wm831x
, WM831X_SECURITY_KEY
, 0x9716);
159 dev_vdbg(wm831x
->dev
, "Registers unlocked\n");
161 mutex_lock(&wm831x
->io_lock
);
162 WARN_ON(!wm831x
->locked
);
164 mutex_unlock(&wm831x
->io_lock
);
169 EXPORT_SYMBOL_GPL(wm831x_reg_unlock
);
171 static int wm831x_read(struct wm831x
*wm831x
, unsigned short reg
,
172 int bytes
, void *dest
)
180 ret
= wm831x
->read_dev(wm831x
, reg
, bytes
, dest
);
184 for (i
= 0; i
< bytes
/ 2; i
++) {
185 buf
[i
] = be16_to_cpu(buf
[i
]);
187 dev_vdbg(wm831x
->dev
, "Read %04x from R%d(0x%x)\n",
188 buf
[i
], reg
+ i
, reg
+ i
);
195 * wm831x_reg_read: Read a single WM831x register.
197 * @wm831x: Device to read from.
198 * @reg: Register to read.
200 int wm831x_reg_read(struct wm831x
*wm831x
, unsigned short reg
)
205 mutex_lock(&wm831x
->io_lock
);
207 ret
= wm831x_read(wm831x
, reg
, 2, &val
);
209 mutex_unlock(&wm831x
->io_lock
);
216 EXPORT_SYMBOL_GPL(wm831x_reg_read
);
219 * wm831x_bulk_read: Read multiple WM831x registers
221 * @wm831x: Device to read from
222 * @reg: First register
223 * @count: Number of registers
224 * @buf: Buffer to fill.
226 int wm831x_bulk_read(struct wm831x
*wm831x
, unsigned short reg
,
231 mutex_lock(&wm831x
->io_lock
);
233 ret
= wm831x_read(wm831x
, reg
, count
* 2, buf
);
235 mutex_unlock(&wm831x
->io_lock
);
239 EXPORT_SYMBOL_GPL(wm831x_bulk_read
);
241 static int wm831x_write(struct wm831x
*wm831x
, unsigned short reg
,
242 int bytes
, void *src
)
250 for (i
= 0; i
< bytes
/ 2; i
++) {
251 if (wm831x_reg_locked(wm831x
, reg
))
254 dev_vdbg(wm831x
->dev
, "Write %04x to R%d(0x%x)\n",
255 buf
[i
], reg
+ i
, reg
+ i
);
257 buf
[i
] = cpu_to_be16(buf
[i
]);
260 return wm831x
->write_dev(wm831x
, reg
, bytes
, src
);
264 * wm831x_reg_write: Write a single WM831x register.
266 * @wm831x: Device to write to.
267 * @reg: Register to write to.
268 * @val: Value to write.
270 int wm831x_reg_write(struct wm831x
*wm831x
, unsigned short reg
,
275 mutex_lock(&wm831x
->io_lock
);
277 ret
= wm831x_write(wm831x
, reg
, 2, &val
);
279 mutex_unlock(&wm831x
->io_lock
);
283 EXPORT_SYMBOL_GPL(wm831x_reg_write
);
286 * wm831x_set_bits: Set the value of a bitfield in a WM831x register
288 * @wm831x: Device to write to.
289 * @reg: Register to write to.
290 * @mask: Mask of bits to set.
291 * @val: Value to set (unshifted)
293 int wm831x_set_bits(struct wm831x
*wm831x
, unsigned short reg
,
294 unsigned short mask
, unsigned short val
)
299 mutex_lock(&wm831x
->io_lock
);
301 ret
= wm831x_read(wm831x
, reg
, 2, &r
);
308 ret
= wm831x_write(wm831x
, reg
, 2, &r
);
311 mutex_unlock(&wm831x
->io_lock
);
315 EXPORT_SYMBOL_GPL(wm831x_set_bits
);
318 * wm831x_auxadc_read: Read a value from the WM831x AUXADC
320 * @wm831x: Device to read from.
321 * @input: AUXADC input to read.
323 int wm831x_auxadc_read(struct wm831x
*wm831x
, enum wm831x_auxadc input
)
325 int ret
, src
, irq_masked
, timeout
;
327 /* Are we using the interrupt? */
328 irq_masked
= wm831x_reg_read(wm831x
, WM831X_INTERRUPT_STATUS_1_MASK
);
329 irq_masked
&= WM831X_AUXADC_DATA_EINT
;
331 mutex_lock(&wm831x
->auxadc_lock
);
333 ret
= wm831x_set_bits(wm831x
, WM831X_AUXADC_CONTROL
,
334 WM831X_AUX_ENA
, WM831X_AUX_ENA
);
336 dev_err(wm831x
->dev
, "Failed to enable AUXADC: %d\n", ret
);
340 /* We force a single source at present */
342 ret
= wm831x_reg_write(wm831x
, WM831X_AUXADC_SOURCE
,
345 dev_err(wm831x
->dev
, "Failed to set AUXADC source: %d\n", ret
);
349 /* Clear any notification from a very late arriving interrupt */
350 try_wait_for_completion(&wm831x
->auxadc_done
);
352 ret
= wm831x_set_bits(wm831x
, WM831X_AUXADC_CONTROL
,
353 WM831X_AUX_CVT_ENA
, WM831X_AUX_CVT_ENA
);
355 dev_err(wm831x
->dev
, "Failed to start AUXADC: %d\n", ret
);
360 /* If we're not using interrupts then poll the
361 * interrupt status register */
366 ret
= wm831x_reg_read(wm831x
,
367 WM831X_INTERRUPT_STATUS_1
);
370 "ISR 1 read failed: %d\n", ret
);
374 /* Did it complete? */
375 if (ret
& WM831X_AUXADC_DATA_EINT
) {
376 wm831x_reg_write(wm831x
,
377 WM831X_INTERRUPT_STATUS_1
,
378 WM831X_AUXADC_DATA_EINT
);
382 "AUXADC conversion timeout\n");
388 /* If we are using interrupts then wait for the
389 * interrupt to complete. Use an extremely long
390 * timeout to handle situations with heavy load where
391 * the notification of the interrupt may be delayed by
392 * threaded IRQ handling. */
393 if (!wait_for_completion_timeout(&wm831x
->auxadc_done
,
394 msecs_to_jiffies(500))) {
395 dev_err(wm831x
->dev
, "Timed out waiting for AUXADC\n");
401 ret
= wm831x_reg_read(wm831x
, WM831X_AUXADC_DATA
);
403 dev_err(wm831x
->dev
, "Failed to read AUXADC data: %d\n", ret
);
405 src
= ((ret
& WM831X_AUX_DATA_SRC_MASK
)
406 >> WM831X_AUX_DATA_SRC_SHIFT
) - 1;
409 src
= WM831X_AUX_CAL
;
412 dev_err(wm831x
->dev
, "Data from source %d not %d\n",
416 ret
&= WM831X_AUX_DATA_MASK
;
421 wm831x_set_bits(wm831x
, WM831X_AUXADC_CONTROL
, WM831X_AUX_ENA
, 0);
423 mutex_unlock(&wm831x
->auxadc_lock
);
426 EXPORT_SYMBOL_GPL(wm831x_auxadc_read
);
428 static irqreturn_t
wm831x_auxadc_irq(int irq
, void *irq_data
)
430 struct wm831x
*wm831x
= irq_data
;
432 complete(&wm831x
->auxadc_done
);
438 * wm831x_auxadc_read_uv: Read a voltage from the WM831x AUXADC
440 * @wm831x: Device to read from.
441 * @input: AUXADC input to read.
443 int wm831x_auxadc_read_uv(struct wm831x
*wm831x
, enum wm831x_auxadc input
)
447 ret
= wm831x_auxadc_read(wm831x
, input
);
455 EXPORT_SYMBOL_GPL(wm831x_auxadc_read_uv
);
457 static struct resource wm831x_dcdc1_resources
[] = {
459 .start
= WM831X_DC1_CONTROL_1
,
460 .end
= WM831X_DC1_DVS_CONTROL
,
461 .flags
= IORESOURCE_IO
,
465 .start
= WM831X_IRQ_UV_DC1
,
466 .end
= WM831X_IRQ_UV_DC1
,
467 .flags
= IORESOURCE_IRQ
,
471 .start
= WM831X_IRQ_HC_DC1
,
472 .end
= WM831X_IRQ_HC_DC1
,
473 .flags
= IORESOURCE_IRQ
,
478 static struct resource wm831x_dcdc2_resources
[] = {
480 .start
= WM831X_DC2_CONTROL_1
,
481 .end
= WM831X_DC2_DVS_CONTROL
,
482 .flags
= IORESOURCE_IO
,
486 .start
= WM831X_IRQ_UV_DC2
,
487 .end
= WM831X_IRQ_UV_DC2
,
488 .flags
= IORESOURCE_IRQ
,
492 .start
= WM831X_IRQ_HC_DC2
,
493 .end
= WM831X_IRQ_HC_DC2
,
494 .flags
= IORESOURCE_IRQ
,
498 static struct resource wm831x_dcdc3_resources
[] = {
500 .start
= WM831X_DC3_CONTROL_1
,
501 .end
= WM831X_DC3_SLEEP_CONTROL
,
502 .flags
= IORESOURCE_IO
,
506 .start
= WM831X_IRQ_UV_DC3
,
507 .end
= WM831X_IRQ_UV_DC3
,
508 .flags
= IORESOURCE_IRQ
,
512 static struct resource wm831x_dcdc4_resources
[] = {
514 .start
= WM831X_DC4_CONTROL
,
515 .end
= WM831X_DC4_SLEEP_CONTROL
,
516 .flags
= IORESOURCE_IO
,
520 .start
= WM831X_IRQ_UV_DC4
,
521 .end
= WM831X_IRQ_UV_DC4
,
522 .flags
= IORESOURCE_IRQ
,
526 static struct resource wm8320_dcdc4_buck_resources
[] = {
528 .start
= WM831X_DC4_CONTROL
,
529 .end
= WM832X_DC4_SLEEP_CONTROL
,
530 .flags
= IORESOURCE_IO
,
534 .start
= WM831X_IRQ_UV_DC4
,
535 .end
= WM831X_IRQ_UV_DC4
,
536 .flags
= IORESOURCE_IRQ
,
540 static struct resource wm831x_gpio_resources
[] = {
542 .start
= WM831X_IRQ_GPIO_1
,
543 .end
= WM831X_IRQ_GPIO_16
,
544 .flags
= IORESOURCE_IRQ
,
548 static struct resource wm831x_isink1_resources
[] = {
550 .start
= WM831X_CURRENT_SINK_1
,
551 .end
= WM831X_CURRENT_SINK_1
,
552 .flags
= IORESOURCE_IO
,
555 .start
= WM831X_IRQ_CS1
,
556 .end
= WM831X_IRQ_CS1
,
557 .flags
= IORESOURCE_IRQ
,
561 static struct resource wm831x_isink2_resources
[] = {
563 .start
= WM831X_CURRENT_SINK_2
,
564 .end
= WM831X_CURRENT_SINK_2
,
565 .flags
= IORESOURCE_IO
,
568 .start
= WM831X_IRQ_CS2
,
569 .end
= WM831X_IRQ_CS2
,
570 .flags
= IORESOURCE_IRQ
,
574 static struct resource wm831x_ldo1_resources
[] = {
576 .start
= WM831X_LDO1_CONTROL
,
577 .end
= WM831X_LDO1_SLEEP_CONTROL
,
578 .flags
= IORESOURCE_IO
,
582 .start
= WM831X_IRQ_UV_LDO1
,
583 .end
= WM831X_IRQ_UV_LDO1
,
584 .flags
= IORESOURCE_IRQ
,
588 static struct resource wm831x_ldo2_resources
[] = {
590 .start
= WM831X_LDO2_CONTROL
,
591 .end
= WM831X_LDO2_SLEEP_CONTROL
,
592 .flags
= IORESOURCE_IO
,
596 .start
= WM831X_IRQ_UV_LDO2
,
597 .end
= WM831X_IRQ_UV_LDO2
,
598 .flags
= IORESOURCE_IRQ
,
602 static struct resource wm831x_ldo3_resources
[] = {
604 .start
= WM831X_LDO3_CONTROL
,
605 .end
= WM831X_LDO3_SLEEP_CONTROL
,
606 .flags
= IORESOURCE_IO
,
610 .start
= WM831X_IRQ_UV_LDO3
,
611 .end
= WM831X_IRQ_UV_LDO3
,
612 .flags
= IORESOURCE_IRQ
,
616 static struct resource wm831x_ldo4_resources
[] = {
618 .start
= WM831X_LDO4_CONTROL
,
619 .end
= WM831X_LDO4_SLEEP_CONTROL
,
620 .flags
= IORESOURCE_IO
,
624 .start
= WM831X_IRQ_UV_LDO4
,
625 .end
= WM831X_IRQ_UV_LDO4
,
626 .flags
= IORESOURCE_IRQ
,
630 static struct resource wm831x_ldo5_resources
[] = {
632 .start
= WM831X_LDO5_CONTROL
,
633 .end
= WM831X_LDO5_SLEEP_CONTROL
,
634 .flags
= IORESOURCE_IO
,
638 .start
= WM831X_IRQ_UV_LDO5
,
639 .end
= WM831X_IRQ_UV_LDO5
,
640 .flags
= IORESOURCE_IRQ
,
644 static struct resource wm831x_ldo6_resources
[] = {
646 .start
= WM831X_LDO6_CONTROL
,
647 .end
= WM831X_LDO6_SLEEP_CONTROL
,
648 .flags
= IORESOURCE_IO
,
652 .start
= WM831X_IRQ_UV_LDO6
,
653 .end
= WM831X_IRQ_UV_LDO6
,
654 .flags
= IORESOURCE_IRQ
,
658 static struct resource wm831x_ldo7_resources
[] = {
660 .start
= WM831X_LDO7_CONTROL
,
661 .end
= WM831X_LDO7_SLEEP_CONTROL
,
662 .flags
= IORESOURCE_IO
,
666 .start
= WM831X_IRQ_UV_LDO7
,
667 .end
= WM831X_IRQ_UV_LDO7
,
668 .flags
= IORESOURCE_IRQ
,
672 static struct resource wm831x_ldo8_resources
[] = {
674 .start
= WM831X_LDO8_CONTROL
,
675 .end
= WM831X_LDO8_SLEEP_CONTROL
,
676 .flags
= IORESOURCE_IO
,
680 .start
= WM831X_IRQ_UV_LDO8
,
681 .end
= WM831X_IRQ_UV_LDO8
,
682 .flags
= IORESOURCE_IRQ
,
686 static struct resource wm831x_ldo9_resources
[] = {
688 .start
= WM831X_LDO9_CONTROL
,
689 .end
= WM831X_LDO9_SLEEP_CONTROL
,
690 .flags
= IORESOURCE_IO
,
694 .start
= WM831X_IRQ_UV_LDO9
,
695 .end
= WM831X_IRQ_UV_LDO9
,
696 .flags
= IORESOURCE_IRQ
,
700 static struct resource wm831x_ldo10_resources
[] = {
702 .start
= WM831X_LDO10_CONTROL
,
703 .end
= WM831X_LDO10_SLEEP_CONTROL
,
704 .flags
= IORESOURCE_IO
,
708 .start
= WM831X_IRQ_UV_LDO10
,
709 .end
= WM831X_IRQ_UV_LDO10
,
710 .flags
= IORESOURCE_IRQ
,
714 static struct resource wm831x_ldo11_resources
[] = {
716 .start
= WM831X_LDO11_ON_CONTROL
,
717 .end
= WM831X_LDO11_SLEEP_CONTROL
,
718 .flags
= IORESOURCE_IO
,
722 static struct resource wm831x_on_resources
[] = {
724 .start
= WM831X_IRQ_ON
,
725 .end
= WM831X_IRQ_ON
,
726 .flags
= IORESOURCE_IRQ
,
731 static struct resource wm831x_power_resources
[] = {
734 .start
= WM831X_IRQ_PPM_SYSLO
,
735 .end
= WM831X_IRQ_PPM_SYSLO
,
736 .flags
= IORESOURCE_IRQ
,
740 .start
= WM831X_IRQ_PPM_PWR_SRC
,
741 .end
= WM831X_IRQ_PPM_PWR_SRC
,
742 .flags
= IORESOURCE_IRQ
,
746 .start
= WM831X_IRQ_PPM_USB_CURR
,
747 .end
= WM831X_IRQ_PPM_USB_CURR
,
748 .flags
= IORESOURCE_IRQ
,
752 .start
= WM831X_IRQ_CHG_BATT_HOT
,
753 .end
= WM831X_IRQ_CHG_BATT_HOT
,
754 .flags
= IORESOURCE_IRQ
,
758 .start
= WM831X_IRQ_CHG_BATT_COLD
,
759 .end
= WM831X_IRQ_CHG_BATT_COLD
,
760 .flags
= IORESOURCE_IRQ
,
764 .start
= WM831X_IRQ_CHG_BATT_FAIL
,
765 .end
= WM831X_IRQ_CHG_BATT_FAIL
,
766 .flags
= IORESOURCE_IRQ
,
770 .start
= WM831X_IRQ_CHG_OV
,
771 .end
= WM831X_IRQ_CHG_OV
,
772 .flags
= IORESOURCE_IRQ
,
776 .start
= WM831X_IRQ_CHG_END
,
777 .end
= WM831X_IRQ_CHG_END
,
778 .flags
= IORESOURCE_IRQ
,
782 .start
= WM831X_IRQ_CHG_TO
,
783 .end
= WM831X_IRQ_CHG_TO
,
784 .flags
= IORESOURCE_IRQ
,
788 .start
= WM831X_IRQ_CHG_MODE
,
789 .end
= WM831X_IRQ_CHG_MODE
,
790 .flags
= IORESOURCE_IRQ
,
794 .start
= WM831X_IRQ_CHG_START
,
795 .end
= WM831X_IRQ_CHG_START
,
796 .flags
= IORESOURCE_IRQ
,
800 static struct resource wm831x_rtc_resources
[] = {
803 .start
= WM831X_IRQ_RTC_PER
,
804 .end
= WM831X_IRQ_RTC_PER
,
805 .flags
= IORESOURCE_IRQ
,
809 .start
= WM831X_IRQ_RTC_ALM
,
810 .end
= WM831X_IRQ_RTC_ALM
,
811 .flags
= IORESOURCE_IRQ
,
815 static struct resource wm831x_status1_resources
[] = {
817 .start
= WM831X_STATUS_LED_1
,
818 .end
= WM831X_STATUS_LED_1
,
819 .flags
= IORESOURCE_IO
,
823 static struct resource wm831x_status2_resources
[] = {
825 .start
= WM831X_STATUS_LED_2
,
826 .end
= WM831X_STATUS_LED_2
,
827 .flags
= IORESOURCE_IO
,
831 static struct resource wm831x_touch_resources
[] = {
834 .start
= WM831X_IRQ_TCHPD
,
835 .end
= WM831X_IRQ_TCHPD
,
836 .flags
= IORESOURCE_IRQ
,
840 .start
= WM831X_IRQ_TCHDATA
,
841 .end
= WM831X_IRQ_TCHDATA
,
842 .flags
= IORESOURCE_IRQ
,
846 static struct resource wm831x_wdt_resources
[] = {
848 .start
= WM831X_IRQ_WDOG_TO
,
849 .end
= WM831X_IRQ_WDOG_TO
,
850 .flags
= IORESOURCE_IRQ
,
854 static struct mfd_cell wm8310_devs
[] = {
856 .name
= "wm831x-backup",
859 .name
= "wm831x-buckv",
861 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
862 .resources
= wm831x_dcdc1_resources
,
865 .name
= "wm831x-buckv",
867 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
868 .resources
= wm831x_dcdc2_resources
,
871 .name
= "wm831x-buckp",
873 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
874 .resources
= wm831x_dcdc3_resources
,
877 .name
= "wm831x-boostp",
879 .num_resources
= ARRAY_SIZE(wm831x_dcdc4_resources
),
880 .resources
= wm831x_dcdc4_resources
,
883 .name
= "wm831x-epe",
887 .name
= "wm831x-epe",
891 .name
= "wm831x-gpio",
892 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
893 .resources
= wm831x_gpio_resources
,
896 .name
= "wm831x-hwmon",
899 .name
= "wm831x-isink",
901 .num_resources
= ARRAY_SIZE(wm831x_isink1_resources
),
902 .resources
= wm831x_isink1_resources
,
905 .name
= "wm831x-isink",
907 .num_resources
= ARRAY_SIZE(wm831x_isink2_resources
),
908 .resources
= wm831x_isink2_resources
,
911 .name
= "wm831x-ldo",
913 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
914 .resources
= wm831x_ldo1_resources
,
917 .name
= "wm831x-ldo",
919 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
920 .resources
= wm831x_ldo2_resources
,
923 .name
= "wm831x-ldo",
925 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
926 .resources
= wm831x_ldo3_resources
,
929 .name
= "wm831x-ldo",
931 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
932 .resources
= wm831x_ldo4_resources
,
935 .name
= "wm831x-ldo",
937 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
938 .resources
= wm831x_ldo5_resources
,
941 .name
= "wm831x-ldo",
943 .num_resources
= ARRAY_SIZE(wm831x_ldo6_resources
),
944 .resources
= wm831x_ldo6_resources
,
947 .name
= "wm831x-aldo",
949 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
950 .resources
= wm831x_ldo7_resources
,
953 .name
= "wm831x-aldo",
955 .num_resources
= ARRAY_SIZE(wm831x_ldo8_resources
),
956 .resources
= wm831x_ldo8_resources
,
959 .name
= "wm831x-aldo",
961 .num_resources
= ARRAY_SIZE(wm831x_ldo9_resources
),
962 .resources
= wm831x_ldo9_resources
,
965 .name
= "wm831x-aldo",
967 .num_resources
= ARRAY_SIZE(wm831x_ldo10_resources
),
968 .resources
= wm831x_ldo10_resources
,
971 .name
= "wm831x-alive-ldo",
973 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
974 .resources
= wm831x_ldo11_resources
,
978 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
979 .resources
= wm831x_on_resources
,
982 .name
= "wm831x-power",
983 .num_resources
= ARRAY_SIZE(wm831x_power_resources
),
984 .resources
= wm831x_power_resources
,
987 .name
= "wm831x-rtc",
988 .num_resources
= ARRAY_SIZE(wm831x_rtc_resources
),
989 .resources
= wm831x_rtc_resources
,
992 .name
= "wm831x-status",
994 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
995 .resources
= wm831x_status1_resources
,
998 .name
= "wm831x-status",
1000 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1001 .resources
= wm831x_status2_resources
,
1004 .name
= "wm831x-watchdog",
1005 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1006 .resources
= wm831x_wdt_resources
,
1010 static struct mfd_cell wm8311_devs
[] = {
1012 .name
= "wm831x-backup",
1015 .name
= "wm831x-buckv",
1017 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
1018 .resources
= wm831x_dcdc1_resources
,
1021 .name
= "wm831x-buckv",
1023 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
1024 .resources
= wm831x_dcdc2_resources
,
1027 .name
= "wm831x-buckp",
1029 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
1030 .resources
= wm831x_dcdc3_resources
,
1033 .name
= "wm831x-boostp",
1035 .num_resources
= ARRAY_SIZE(wm831x_dcdc4_resources
),
1036 .resources
= wm831x_dcdc4_resources
,
1039 .name
= "wm831x-epe",
1043 .name
= "wm831x-epe",
1047 .name
= "wm831x-gpio",
1048 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
1049 .resources
= wm831x_gpio_resources
,
1052 .name
= "wm831x-hwmon",
1055 .name
= "wm831x-isink",
1057 .num_resources
= ARRAY_SIZE(wm831x_isink1_resources
),
1058 .resources
= wm831x_isink1_resources
,
1061 .name
= "wm831x-isink",
1063 .num_resources
= ARRAY_SIZE(wm831x_isink2_resources
),
1064 .resources
= wm831x_isink2_resources
,
1067 .name
= "wm831x-ldo",
1069 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
1070 .resources
= wm831x_ldo1_resources
,
1073 .name
= "wm831x-ldo",
1075 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
1076 .resources
= wm831x_ldo2_resources
,
1079 .name
= "wm831x-ldo",
1081 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
1082 .resources
= wm831x_ldo3_resources
,
1085 .name
= "wm831x-ldo",
1087 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
1088 .resources
= wm831x_ldo4_resources
,
1091 .name
= "wm831x-ldo",
1093 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
1094 .resources
= wm831x_ldo5_resources
,
1097 .name
= "wm831x-aldo",
1099 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
1100 .resources
= wm831x_ldo7_resources
,
1103 .name
= "wm831x-alive-ldo",
1105 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
1106 .resources
= wm831x_ldo11_resources
,
1109 .name
= "wm831x-on",
1110 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
1111 .resources
= wm831x_on_resources
,
1114 .name
= "wm831x-power",
1115 .num_resources
= ARRAY_SIZE(wm831x_power_resources
),
1116 .resources
= wm831x_power_resources
,
1119 .name
= "wm831x-rtc",
1120 .num_resources
= ARRAY_SIZE(wm831x_rtc_resources
),
1121 .resources
= wm831x_rtc_resources
,
1124 .name
= "wm831x-status",
1126 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
1127 .resources
= wm831x_status1_resources
,
1130 .name
= "wm831x-status",
1132 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1133 .resources
= wm831x_status2_resources
,
1136 .name
= "wm831x-touch",
1137 .num_resources
= ARRAY_SIZE(wm831x_touch_resources
),
1138 .resources
= wm831x_touch_resources
,
1141 .name
= "wm831x-watchdog",
1142 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1143 .resources
= wm831x_wdt_resources
,
1147 static struct mfd_cell wm8312_devs
[] = {
1149 .name
= "wm831x-backup",
1152 .name
= "wm831x-buckv",
1154 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
1155 .resources
= wm831x_dcdc1_resources
,
1158 .name
= "wm831x-buckv",
1160 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
1161 .resources
= wm831x_dcdc2_resources
,
1164 .name
= "wm831x-buckp",
1166 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
1167 .resources
= wm831x_dcdc3_resources
,
1170 .name
= "wm831x-boostp",
1172 .num_resources
= ARRAY_SIZE(wm831x_dcdc4_resources
),
1173 .resources
= wm831x_dcdc4_resources
,
1176 .name
= "wm831x-epe",
1180 .name
= "wm831x-epe",
1184 .name
= "wm831x-gpio",
1185 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
1186 .resources
= wm831x_gpio_resources
,
1189 .name
= "wm831x-hwmon",
1192 .name
= "wm831x-isink",
1194 .num_resources
= ARRAY_SIZE(wm831x_isink1_resources
),
1195 .resources
= wm831x_isink1_resources
,
1198 .name
= "wm831x-isink",
1200 .num_resources
= ARRAY_SIZE(wm831x_isink2_resources
),
1201 .resources
= wm831x_isink2_resources
,
1204 .name
= "wm831x-ldo",
1206 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
1207 .resources
= wm831x_ldo1_resources
,
1210 .name
= "wm831x-ldo",
1212 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
1213 .resources
= wm831x_ldo2_resources
,
1216 .name
= "wm831x-ldo",
1218 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
1219 .resources
= wm831x_ldo3_resources
,
1222 .name
= "wm831x-ldo",
1224 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
1225 .resources
= wm831x_ldo4_resources
,
1228 .name
= "wm831x-ldo",
1230 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
1231 .resources
= wm831x_ldo5_resources
,
1234 .name
= "wm831x-ldo",
1236 .num_resources
= ARRAY_SIZE(wm831x_ldo6_resources
),
1237 .resources
= wm831x_ldo6_resources
,
1240 .name
= "wm831x-aldo",
1242 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
1243 .resources
= wm831x_ldo7_resources
,
1246 .name
= "wm831x-aldo",
1248 .num_resources
= ARRAY_SIZE(wm831x_ldo8_resources
),
1249 .resources
= wm831x_ldo8_resources
,
1252 .name
= "wm831x-aldo",
1254 .num_resources
= ARRAY_SIZE(wm831x_ldo9_resources
),
1255 .resources
= wm831x_ldo9_resources
,
1258 .name
= "wm831x-aldo",
1260 .num_resources
= ARRAY_SIZE(wm831x_ldo10_resources
),
1261 .resources
= wm831x_ldo10_resources
,
1264 .name
= "wm831x-alive-ldo",
1266 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
1267 .resources
= wm831x_ldo11_resources
,
1270 .name
= "wm831x-on",
1271 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
1272 .resources
= wm831x_on_resources
,
1275 .name
= "wm831x-power",
1276 .num_resources
= ARRAY_SIZE(wm831x_power_resources
),
1277 .resources
= wm831x_power_resources
,
1280 .name
= "wm831x-rtc",
1281 .num_resources
= ARRAY_SIZE(wm831x_rtc_resources
),
1282 .resources
= wm831x_rtc_resources
,
1285 .name
= "wm831x-status",
1287 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
1288 .resources
= wm831x_status1_resources
,
1291 .name
= "wm831x-status",
1293 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1294 .resources
= wm831x_status2_resources
,
1297 .name
= "wm831x-touch",
1298 .num_resources
= ARRAY_SIZE(wm831x_touch_resources
),
1299 .resources
= wm831x_touch_resources
,
1302 .name
= "wm831x-watchdog",
1303 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1304 .resources
= wm831x_wdt_resources
,
1308 static struct mfd_cell wm8320_devs
[] = {
1310 .name
= "wm831x-backup",
1313 .name
= "wm831x-buckv",
1315 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
1316 .resources
= wm831x_dcdc1_resources
,
1319 .name
= "wm831x-buckv",
1321 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
1322 .resources
= wm831x_dcdc2_resources
,
1325 .name
= "wm831x-buckp",
1327 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
1328 .resources
= wm831x_dcdc3_resources
,
1331 .name
= "wm831x-buckp",
1333 .num_resources
= ARRAY_SIZE(wm8320_dcdc4_buck_resources
),
1334 .resources
= wm8320_dcdc4_buck_resources
,
1337 .name
= "wm831x-gpio",
1338 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
1339 .resources
= wm831x_gpio_resources
,
1342 .name
= "wm831x-hwmon",
1345 .name
= "wm831x-ldo",
1347 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
1348 .resources
= wm831x_ldo1_resources
,
1351 .name
= "wm831x-ldo",
1353 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
1354 .resources
= wm831x_ldo2_resources
,
1357 .name
= "wm831x-ldo",
1359 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
1360 .resources
= wm831x_ldo3_resources
,
1363 .name
= "wm831x-ldo",
1365 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
1366 .resources
= wm831x_ldo4_resources
,
1369 .name
= "wm831x-ldo",
1371 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
1372 .resources
= wm831x_ldo5_resources
,
1375 .name
= "wm831x-ldo",
1377 .num_resources
= ARRAY_SIZE(wm831x_ldo6_resources
),
1378 .resources
= wm831x_ldo6_resources
,
1381 .name
= "wm831x-aldo",
1383 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
1384 .resources
= wm831x_ldo7_resources
,
1387 .name
= "wm831x-aldo",
1389 .num_resources
= ARRAY_SIZE(wm831x_ldo8_resources
),
1390 .resources
= wm831x_ldo8_resources
,
1393 .name
= "wm831x-aldo",
1395 .num_resources
= ARRAY_SIZE(wm831x_ldo9_resources
),
1396 .resources
= wm831x_ldo9_resources
,
1399 .name
= "wm831x-aldo",
1401 .num_resources
= ARRAY_SIZE(wm831x_ldo10_resources
),
1402 .resources
= wm831x_ldo10_resources
,
1405 .name
= "wm831x-alive-ldo",
1407 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
1408 .resources
= wm831x_ldo11_resources
,
1411 .name
= "wm831x-on",
1412 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
1413 .resources
= wm831x_on_resources
,
1416 .name
= "wm831x-rtc",
1417 .num_resources
= ARRAY_SIZE(wm831x_rtc_resources
),
1418 .resources
= wm831x_rtc_resources
,
1421 .name
= "wm831x-status",
1423 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
1424 .resources
= wm831x_status1_resources
,
1427 .name
= "wm831x-status",
1429 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1430 .resources
= wm831x_status2_resources
,
1433 .name
= "wm831x-watchdog",
1434 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1435 .resources
= wm831x_wdt_resources
,
1439 static struct mfd_cell backlight_devs
[] = {
1441 .name
= "wm831x-backlight",
1446 * Instantiate the generic non-control parts of the device.
1448 static int wm831x_device_init(struct wm831x
*wm831x
, unsigned long id
, int irq
)
1450 struct wm831x_pdata
*pdata
= wm831x
->dev
->platform_data
;
1452 enum wm831x_parent parent
;
1455 mutex_init(&wm831x
->io_lock
);
1456 mutex_init(&wm831x
->key_lock
);
1457 mutex_init(&wm831x
->auxadc_lock
);
1458 init_completion(&wm831x
->auxadc_done
);
1459 dev_set_drvdata(wm831x
->dev
, wm831x
);
1461 ret
= wm831x_reg_read(wm831x
, WM831X_PARENT_ID
);
1463 dev_err(wm831x
->dev
, "Failed to read parent ID: %d\n", ret
);
1466 if (ret
!= 0x6204) {
1467 dev_err(wm831x
->dev
, "Device is not a WM831x: ID %x\n", ret
);
1472 ret
= wm831x_reg_read(wm831x
, WM831X_REVISION
);
1474 dev_err(wm831x
->dev
, "Failed to read revision: %d\n", ret
);
1477 rev
= (ret
& WM831X_PARENT_REV_MASK
) >> WM831X_PARENT_REV_SHIFT
;
1479 ret
= wm831x_reg_read(wm831x
, WM831X_RESET_ID
);
1481 dev_err(wm831x
->dev
, "Failed to read device ID: %d\n", ret
);
1485 /* Some engineering samples do not have the ID set, rely on
1486 * the device being registered correctly.
1489 dev_info(wm831x
->dev
, "Device is an engineering sample\n");
1496 wm831x
->num_gpio
= 16;
1497 wm831x
->charger_irq_wake
= 1;
1499 wm831x
->has_gpio_ena
= 1;
1500 wm831x
->has_cs_sts
= 1;
1503 dev_info(wm831x
->dev
, "WM8310 revision %c\n", 'A' + rev
);
1508 wm831x
->num_gpio
= 16;
1509 wm831x
->charger_irq_wake
= 1;
1511 wm831x
->has_gpio_ena
= 1;
1512 wm831x
->has_cs_sts
= 1;
1515 dev_info(wm831x
->dev
, "WM8311 revision %c\n", 'A' + rev
);
1520 wm831x
->num_gpio
= 16;
1521 wm831x
->charger_irq_wake
= 1;
1523 wm831x
->has_gpio_ena
= 1;
1524 wm831x
->has_cs_sts
= 1;
1527 dev_info(wm831x
->dev
, "WM8312 revision %c\n", 'A' + rev
);
1532 wm831x
->num_gpio
= 12;
1533 dev_info(wm831x
->dev
, "WM8320 revision %c\n", 'A' + rev
);
1537 dev_err(wm831x
->dev
, "Unknown WM831x device %04x\n", ret
);
1542 /* This will need revisiting in future but is OK for all
1546 dev_warn(wm831x
->dev
, "Device was registered as a WM%lx\n",
1549 /* Bootstrap the user key */
1550 ret
= wm831x_reg_read(wm831x
, WM831X_SECURITY_KEY
);
1552 dev_err(wm831x
->dev
, "Failed to read security key: %d\n", ret
);
1556 dev_warn(wm831x
->dev
, "Security key had non-zero value %x\n",
1558 wm831x_reg_write(wm831x
, WM831X_SECURITY_KEY
, 0);
1562 if (pdata
&& pdata
->pre_init
) {
1563 ret
= pdata
->pre_init(wm831x
);
1565 dev_err(wm831x
->dev
, "pre_init() failed: %d\n", ret
);
1570 ret
= wm831x_irq_init(wm831x
, irq
);
1574 if (wm831x
->irq_base
) {
1575 ret
= request_threaded_irq(wm831x
->irq_base
+
1576 WM831X_IRQ_AUXADC_DATA
,
1577 NULL
, wm831x_auxadc_irq
, 0,
1580 dev_err(wm831x
->dev
, "AUXADC IRQ request failed: %d\n",
1584 /* The core device is up, instantiate the subdevices. */
1587 ret
= mfd_add_devices(wm831x
->dev
, -1,
1588 wm8310_devs
, ARRAY_SIZE(wm8310_devs
),
1589 NULL
, wm831x
->irq_base
);
1593 ret
= mfd_add_devices(wm831x
->dev
, -1,
1594 wm8311_devs
, ARRAY_SIZE(wm8311_devs
),
1595 NULL
, wm831x
->irq_base
);
1599 ret
= mfd_add_devices(wm831x
->dev
, -1,
1600 wm8312_devs
, ARRAY_SIZE(wm8312_devs
),
1601 NULL
, wm831x
->irq_base
);
1605 ret
= mfd_add_devices(wm831x
->dev
, -1,
1606 wm8320_devs
, ARRAY_SIZE(wm8320_devs
),
1611 /* If this happens the bus probe function is buggy */
1616 dev_err(wm831x
->dev
, "Failed to add children\n");
1620 if (pdata
&& pdata
->backlight
) {
1621 /* Treat errors as non-critical */
1622 ret
= mfd_add_devices(wm831x
->dev
, -1, backlight_devs
,
1623 ARRAY_SIZE(backlight_devs
), NULL
,
1626 dev_err(wm831x
->dev
, "Failed to add backlight: %d\n",
1630 wm831x_otp_init(wm831x
);
1632 if (pdata
&& pdata
->post_init
) {
1633 ret
= pdata
->post_init(wm831x
);
1635 dev_err(wm831x
->dev
, "post_init() failed: %d\n", ret
);
1643 wm831x_irq_exit(wm831x
);
1645 mfd_remove_devices(wm831x
->dev
);
1650 static void wm831x_device_exit(struct wm831x
*wm831x
)
1652 wm831x_otp_exit(wm831x
);
1653 mfd_remove_devices(wm831x
->dev
);
1654 if (wm831x
->irq_base
)
1655 free_irq(wm831x
->irq_base
+ WM831X_IRQ_AUXADC_DATA
, wm831x
);
1656 wm831x_irq_exit(wm831x
);
1660 static int wm831x_device_suspend(struct wm831x
*wm831x
)
1664 /* If the charger IRQs are a wake source then make sure we ack
1665 * them even if they're not actively being used (eg, no power
1666 * driver or no IRQ line wired up) then acknowledge the
1667 * interrupts otherwise suspend won't last very long.
1669 if (wm831x
->charger_irq_wake
) {
1670 reg
= wm831x_reg_read(wm831x
, WM831X_INTERRUPT_STATUS_2_MASK
);
1672 mask
= WM831X_CHG_BATT_HOT_EINT
|
1673 WM831X_CHG_BATT_COLD_EINT
|
1674 WM831X_CHG_BATT_FAIL_EINT
|
1675 WM831X_CHG_OV_EINT
| WM831X_CHG_END_EINT
|
1676 WM831X_CHG_TO_EINT
| WM831X_CHG_MODE_EINT
|
1677 WM831X_CHG_START_EINT
;
1679 /* If any of the interrupts are masked read the statuses */
1681 reg
= wm831x_reg_read(wm831x
,
1682 WM831X_INTERRUPT_STATUS_2
);
1685 dev_info(wm831x
->dev
,
1686 "Acknowledging masked charger IRQs: %x\n",
1688 wm831x_reg_write(wm831x
, WM831X_INTERRUPT_STATUS_2
,
1696 static int wm831x_i2c_read_device(struct wm831x
*wm831x
, unsigned short reg
,
1697 int bytes
, void *dest
)
1699 struct i2c_client
*i2c
= wm831x
->control_data
;
1701 u16 r
= cpu_to_be16(reg
);
1703 ret
= i2c_master_send(i2c
, (unsigned char *)&r
, 2);
1709 ret
= i2c_master_recv(i2c
, dest
, bytes
);
1717 /* Currently we allocate the write buffer on the stack; this is OK for
1718 * small writes - if we need to do large writes this will need to be
1721 static int wm831x_i2c_write_device(struct wm831x
*wm831x
, unsigned short reg
,
1722 int bytes
, void *src
)
1724 struct i2c_client
*i2c
= wm831x
->control_data
;
1725 unsigned char msg
[bytes
+ 2];
1728 reg
= cpu_to_be16(reg
);
1729 memcpy(&msg
[0], ®
, 2);
1730 memcpy(&msg
[2], src
, bytes
);
1732 ret
= i2c_master_send(i2c
, msg
, bytes
+ 2);
1735 if (ret
< bytes
+ 2)
1741 static int wm831x_i2c_probe(struct i2c_client
*i2c
,
1742 const struct i2c_device_id
*id
)
1744 struct wm831x
*wm831x
;
1746 wm831x
= kzalloc(sizeof(struct wm831x
), GFP_KERNEL
);
1747 if (wm831x
== NULL
) {
1752 i2c_set_clientdata(i2c
, wm831x
);
1753 wm831x
->dev
= &i2c
->dev
;
1754 wm831x
->control_data
= i2c
;
1755 wm831x
->read_dev
= wm831x_i2c_read_device
;
1756 wm831x
->write_dev
= wm831x_i2c_write_device
;
1758 return wm831x_device_init(wm831x
, id
->driver_data
, i2c
->irq
);
1761 static int wm831x_i2c_remove(struct i2c_client
*i2c
)
1763 struct wm831x
*wm831x
= i2c_get_clientdata(i2c
);
1765 wm831x_device_exit(wm831x
);
1770 static int wm831x_i2c_suspend(struct i2c_client
*i2c
, pm_message_t mesg
)
1772 struct wm831x
*wm831x
= i2c_get_clientdata(i2c
);
1774 return wm831x_device_suspend(wm831x
);
1777 static const struct i2c_device_id wm831x_i2c_id
[] = {
1778 { "wm8310", WM8310
},
1779 { "wm8311", WM8311
},
1780 { "wm8312", WM8312
},
1781 { "wm8320", WM8320
},
1784 MODULE_DEVICE_TABLE(i2c
, wm831x_i2c_id
);
1787 static struct i2c_driver wm831x_i2c_driver
= {
1790 .owner
= THIS_MODULE
,
1792 .probe
= wm831x_i2c_probe
,
1793 .remove
= wm831x_i2c_remove
,
1794 .suspend
= wm831x_i2c_suspend
,
1795 .id_table
= wm831x_i2c_id
,
1798 static int __init
wm831x_i2c_init(void)
1802 ret
= i2c_add_driver(&wm831x_i2c_driver
);
1804 pr_err("Failed to register wm831x I2C driver: %d\n", ret
);
1808 subsys_initcall(wm831x_i2c_init
);
1810 static void __exit
wm831x_i2c_exit(void)
1812 i2c_del_driver(&wm831x_i2c_driver
);
1814 module_exit(wm831x_i2c_exit
);
1816 MODULE_DESCRIPTION("I2C support for the WM831X AudioPlus PMIC");
1817 MODULE_LICENSE("GPL");
1818 MODULE_AUTHOR("Mark Brown");