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
);
101 static int wm831x_reg_locked(struct wm831x
*wm831x
, unsigned short reg
)
107 case WM831X_WATCHDOG
:
108 case WM831X_DC4_CONTROL
:
109 case WM831X_ON_PIN_CONTROL
:
110 case WM831X_BACKUP_CHARGER_CONTROL
:
111 case WM831X_CHARGER_CONTROL_1
:
112 case WM831X_CHARGER_CONTROL_2
:
121 * wm831x_reg_unlock: Unlock user keyed registers
123 * The WM831x has a user key preventing writes to particularly
124 * critical registers. This function locks those registers,
125 * allowing writes to them.
127 void wm831x_reg_lock(struct wm831x
*wm831x
)
131 ret
= wm831x_reg_write(wm831x
, WM831X_SECURITY_KEY
, 0);
133 dev_vdbg(wm831x
->dev
, "Registers locked\n");
135 mutex_lock(&wm831x
->io_lock
);
136 WARN_ON(wm831x
->locked
);
138 mutex_unlock(&wm831x
->io_lock
);
140 dev_err(wm831x
->dev
, "Failed to lock registers: %d\n", ret
);
144 EXPORT_SYMBOL_GPL(wm831x_reg_lock
);
147 * wm831x_reg_unlock: Unlock user keyed registers
149 * The WM831x has a user key preventing writes to particularly
150 * critical registers. This function locks those registers,
151 * preventing spurious writes.
153 int wm831x_reg_unlock(struct wm831x
*wm831x
)
157 /* 0x9716 is the value required to unlock the registers */
158 ret
= wm831x_reg_write(wm831x
, WM831X_SECURITY_KEY
, 0x9716);
160 dev_vdbg(wm831x
->dev
, "Registers unlocked\n");
162 mutex_lock(&wm831x
->io_lock
);
163 WARN_ON(!wm831x
->locked
);
165 mutex_unlock(&wm831x
->io_lock
);
170 EXPORT_SYMBOL_GPL(wm831x_reg_unlock
);
172 static int wm831x_read(struct wm831x
*wm831x
, unsigned short reg
,
173 int bytes
, void *dest
)
181 ret
= wm831x
->read_dev(wm831x
, reg
, bytes
, dest
);
185 for (i
= 0; i
< bytes
/ 2; i
++) {
186 buf
[i
] = be16_to_cpu(buf
[i
]);
188 dev_vdbg(wm831x
->dev
, "Read %04x from R%d(0x%x)\n",
189 buf
[i
], reg
+ i
, reg
+ i
);
196 * wm831x_reg_read: Read a single WM831x register.
198 * @wm831x: Device to read from.
199 * @reg: Register to read.
201 int wm831x_reg_read(struct wm831x
*wm831x
, unsigned short reg
)
206 mutex_lock(&wm831x
->io_lock
);
208 ret
= wm831x_read(wm831x
, reg
, 2, &val
);
210 mutex_unlock(&wm831x
->io_lock
);
217 EXPORT_SYMBOL_GPL(wm831x_reg_read
);
220 * wm831x_bulk_read: Read multiple WM831x registers
222 * @wm831x: Device to read from
223 * @reg: First register
224 * @count: Number of registers
225 * @buf: Buffer to fill.
227 int wm831x_bulk_read(struct wm831x
*wm831x
, unsigned short reg
,
232 mutex_lock(&wm831x
->io_lock
);
234 ret
= wm831x_read(wm831x
, reg
, count
* 2, buf
);
236 mutex_unlock(&wm831x
->io_lock
);
240 EXPORT_SYMBOL_GPL(wm831x_bulk_read
);
242 static int wm831x_write(struct wm831x
*wm831x
, unsigned short reg
,
243 int bytes
, void *src
)
251 for (i
= 0; i
< bytes
/ 2; i
++) {
252 if (wm831x_reg_locked(wm831x
, reg
))
255 dev_vdbg(wm831x
->dev
, "Write %04x to R%d(0x%x)\n",
256 buf
[i
], reg
+ i
, reg
+ i
);
258 buf
[i
] = cpu_to_be16(buf
[i
]);
261 return wm831x
->write_dev(wm831x
, reg
, bytes
, src
);
265 * wm831x_reg_write: Write a single WM831x register.
267 * @wm831x: Device to write to.
268 * @reg: Register to write to.
269 * @val: Value to write.
271 int wm831x_reg_write(struct wm831x
*wm831x
, unsigned short reg
,
276 mutex_lock(&wm831x
->io_lock
);
278 ret
= wm831x_write(wm831x
, reg
, 2, &val
);
280 mutex_unlock(&wm831x
->io_lock
);
284 EXPORT_SYMBOL_GPL(wm831x_reg_write
);
287 * wm831x_set_bits: Set the value of a bitfield in a WM831x register
289 * @wm831x: Device to write to.
290 * @reg: Register to write to.
291 * @mask: Mask of bits to set.
292 * @val: Value to set (unshifted)
294 int wm831x_set_bits(struct wm831x
*wm831x
, unsigned short reg
,
295 unsigned short mask
, unsigned short val
)
300 mutex_lock(&wm831x
->io_lock
);
302 ret
= wm831x_read(wm831x
, reg
, 2, &r
);
309 ret
= wm831x_write(wm831x
, reg
, 2, &r
);
312 mutex_unlock(&wm831x
->io_lock
);
316 EXPORT_SYMBOL_GPL(wm831x_set_bits
);
319 * wm831x_auxadc_read: Read a value from the WM831x AUXADC
321 * @wm831x: Device to read from.
322 * @input: AUXADC input to read.
324 int wm831x_auxadc_read(struct wm831x
*wm831x
, enum wm831x_auxadc input
)
326 int ret
, src
, irq_masked
, timeout
;
328 /* Are we using the interrupt? */
329 irq_masked
= wm831x_reg_read(wm831x
, WM831X_INTERRUPT_STATUS_1_MASK
);
330 irq_masked
&= WM831X_AUXADC_DATA_EINT
;
332 mutex_lock(&wm831x
->auxadc_lock
);
334 ret
= wm831x_set_bits(wm831x
, WM831X_AUXADC_CONTROL
,
335 WM831X_AUX_ENA
, WM831X_AUX_ENA
);
337 dev_err(wm831x
->dev
, "Failed to enable AUXADC: %d\n", ret
);
341 /* We force a single source at present */
343 ret
= wm831x_reg_write(wm831x
, WM831X_AUXADC_SOURCE
,
346 dev_err(wm831x
->dev
, "Failed to set AUXADC source: %d\n", ret
);
350 /* Clear any notification from a very late arriving interrupt */
351 try_wait_for_completion(&wm831x
->auxadc_done
);
353 ret
= wm831x_set_bits(wm831x
, WM831X_AUXADC_CONTROL
,
354 WM831X_AUX_CVT_ENA
, WM831X_AUX_CVT_ENA
);
356 dev_err(wm831x
->dev
, "Failed to start AUXADC: %d\n", ret
);
361 /* If we're not using interrupts then poll the
362 * interrupt status register */
367 ret
= wm831x_reg_read(wm831x
,
368 WM831X_INTERRUPT_STATUS_1
);
371 "ISR 1 read failed: %d\n", ret
);
375 /* Did it complete? */
376 if (ret
& WM831X_AUXADC_DATA_EINT
) {
377 wm831x_reg_write(wm831x
,
378 WM831X_INTERRUPT_STATUS_1
,
379 WM831X_AUXADC_DATA_EINT
);
383 "AUXADC conversion timeout\n");
389 /* If we are using interrupts then wait for the
390 * interrupt to complete. Use an extremely long
391 * timeout to handle situations with heavy load where
392 * the notification of the interrupt may be delayed by
393 * threaded IRQ handling. */
394 if (!wait_for_completion_timeout(&wm831x
->auxadc_done
,
395 msecs_to_jiffies(500))) {
396 dev_err(wm831x
->dev
, "Timed out waiting for AUXADC\n");
402 ret
= wm831x_reg_read(wm831x
, WM831X_AUXADC_DATA
);
404 dev_err(wm831x
->dev
, "Failed to read AUXADC data: %d\n", ret
);
406 src
= ((ret
& WM831X_AUX_DATA_SRC_MASK
)
407 >> WM831X_AUX_DATA_SRC_SHIFT
) - 1;
410 src
= WM831X_AUX_CAL
;
413 dev_err(wm831x
->dev
, "Data from source %d not %d\n",
417 ret
&= WM831X_AUX_DATA_MASK
;
422 wm831x_set_bits(wm831x
, WM831X_AUXADC_CONTROL
, WM831X_AUX_ENA
, 0);
424 mutex_unlock(&wm831x
->auxadc_lock
);
427 EXPORT_SYMBOL_GPL(wm831x_auxadc_read
);
429 static irqreturn_t
wm831x_auxadc_irq(int irq
, void *irq_data
)
431 struct wm831x
*wm831x
= irq_data
;
433 complete(&wm831x
->auxadc_done
);
439 * wm831x_auxadc_read_uv: Read a voltage from the WM831x AUXADC
441 * @wm831x: Device to read from.
442 * @input: AUXADC input to read.
444 int wm831x_auxadc_read_uv(struct wm831x
*wm831x
, enum wm831x_auxadc input
)
448 ret
= wm831x_auxadc_read(wm831x
, input
);
456 EXPORT_SYMBOL_GPL(wm831x_auxadc_read_uv
);
458 static struct resource wm831x_dcdc1_resources
[] = {
460 .start
= WM831X_DC1_CONTROL_1
,
461 .end
= WM831X_DC1_DVS_CONTROL
,
462 .flags
= IORESOURCE_IO
,
466 .start
= WM831X_IRQ_UV_DC1
,
467 .end
= WM831X_IRQ_UV_DC1
,
468 .flags
= IORESOURCE_IRQ
,
472 .start
= WM831X_IRQ_HC_DC1
,
473 .end
= WM831X_IRQ_HC_DC1
,
474 .flags
= IORESOURCE_IRQ
,
479 static struct resource wm831x_dcdc2_resources
[] = {
481 .start
= WM831X_DC2_CONTROL_1
,
482 .end
= WM831X_DC2_DVS_CONTROL
,
483 .flags
= IORESOURCE_IO
,
487 .start
= WM831X_IRQ_UV_DC2
,
488 .end
= WM831X_IRQ_UV_DC2
,
489 .flags
= IORESOURCE_IRQ
,
493 .start
= WM831X_IRQ_HC_DC2
,
494 .end
= WM831X_IRQ_HC_DC2
,
495 .flags
= IORESOURCE_IRQ
,
499 static struct resource wm831x_dcdc3_resources
[] = {
501 .start
= WM831X_DC3_CONTROL_1
,
502 .end
= WM831X_DC3_SLEEP_CONTROL
,
503 .flags
= IORESOURCE_IO
,
507 .start
= WM831X_IRQ_UV_DC3
,
508 .end
= WM831X_IRQ_UV_DC3
,
509 .flags
= IORESOURCE_IRQ
,
513 static struct resource wm831x_dcdc4_resources
[] = {
515 .start
= WM831X_DC4_CONTROL
,
516 .end
= WM831X_DC4_SLEEP_CONTROL
,
517 .flags
= IORESOURCE_IO
,
521 .start
= WM831X_IRQ_UV_DC4
,
522 .end
= WM831X_IRQ_UV_DC4
,
523 .flags
= IORESOURCE_IRQ
,
527 static struct resource wm8320_dcdc4_buck_resources
[] = {
529 .start
= WM831X_DC4_CONTROL
,
530 .end
= WM832X_DC4_SLEEP_CONTROL
,
531 .flags
= IORESOURCE_IO
,
535 .start
= WM831X_IRQ_UV_DC4
,
536 .end
= WM831X_IRQ_UV_DC4
,
537 .flags
= IORESOURCE_IRQ
,
541 static struct resource wm831x_gpio_resources
[] = {
543 .start
= WM831X_IRQ_GPIO_1
,
544 .end
= WM831X_IRQ_GPIO_16
,
545 .flags
= IORESOURCE_IRQ
,
549 static struct resource wm831x_isink1_resources
[] = {
551 .start
= WM831X_CURRENT_SINK_1
,
552 .end
= WM831X_CURRENT_SINK_1
,
553 .flags
= IORESOURCE_IO
,
556 .start
= WM831X_IRQ_CS1
,
557 .end
= WM831X_IRQ_CS1
,
558 .flags
= IORESOURCE_IRQ
,
562 static struct resource wm831x_isink2_resources
[] = {
564 .start
= WM831X_CURRENT_SINK_2
,
565 .end
= WM831X_CURRENT_SINK_2
,
566 .flags
= IORESOURCE_IO
,
569 .start
= WM831X_IRQ_CS2
,
570 .end
= WM831X_IRQ_CS2
,
571 .flags
= IORESOURCE_IRQ
,
575 static struct resource wm831x_ldo1_resources
[] = {
577 .start
= WM831X_LDO1_CONTROL
,
578 .end
= WM831X_LDO1_SLEEP_CONTROL
,
579 .flags
= IORESOURCE_IO
,
583 .start
= WM831X_IRQ_UV_LDO1
,
584 .end
= WM831X_IRQ_UV_LDO1
,
585 .flags
= IORESOURCE_IRQ
,
589 static struct resource wm831x_ldo2_resources
[] = {
591 .start
= WM831X_LDO2_CONTROL
,
592 .end
= WM831X_LDO2_SLEEP_CONTROL
,
593 .flags
= IORESOURCE_IO
,
597 .start
= WM831X_IRQ_UV_LDO2
,
598 .end
= WM831X_IRQ_UV_LDO2
,
599 .flags
= IORESOURCE_IRQ
,
603 static struct resource wm831x_ldo3_resources
[] = {
605 .start
= WM831X_LDO3_CONTROL
,
606 .end
= WM831X_LDO3_SLEEP_CONTROL
,
607 .flags
= IORESOURCE_IO
,
611 .start
= WM831X_IRQ_UV_LDO3
,
612 .end
= WM831X_IRQ_UV_LDO3
,
613 .flags
= IORESOURCE_IRQ
,
617 static struct resource wm831x_ldo4_resources
[] = {
619 .start
= WM831X_LDO4_CONTROL
,
620 .end
= WM831X_LDO4_SLEEP_CONTROL
,
621 .flags
= IORESOURCE_IO
,
625 .start
= WM831X_IRQ_UV_LDO4
,
626 .end
= WM831X_IRQ_UV_LDO4
,
627 .flags
= IORESOURCE_IRQ
,
631 static struct resource wm831x_ldo5_resources
[] = {
633 .start
= WM831X_LDO5_CONTROL
,
634 .end
= WM831X_LDO5_SLEEP_CONTROL
,
635 .flags
= IORESOURCE_IO
,
639 .start
= WM831X_IRQ_UV_LDO5
,
640 .end
= WM831X_IRQ_UV_LDO5
,
641 .flags
= IORESOURCE_IRQ
,
645 static struct resource wm831x_ldo6_resources
[] = {
647 .start
= WM831X_LDO6_CONTROL
,
648 .end
= WM831X_LDO6_SLEEP_CONTROL
,
649 .flags
= IORESOURCE_IO
,
653 .start
= WM831X_IRQ_UV_LDO6
,
654 .end
= WM831X_IRQ_UV_LDO6
,
655 .flags
= IORESOURCE_IRQ
,
659 static struct resource wm831x_ldo7_resources
[] = {
661 .start
= WM831X_LDO7_CONTROL
,
662 .end
= WM831X_LDO7_SLEEP_CONTROL
,
663 .flags
= IORESOURCE_IO
,
667 .start
= WM831X_IRQ_UV_LDO7
,
668 .end
= WM831X_IRQ_UV_LDO7
,
669 .flags
= IORESOURCE_IRQ
,
673 static struct resource wm831x_ldo8_resources
[] = {
675 .start
= WM831X_LDO8_CONTROL
,
676 .end
= WM831X_LDO8_SLEEP_CONTROL
,
677 .flags
= IORESOURCE_IO
,
681 .start
= WM831X_IRQ_UV_LDO8
,
682 .end
= WM831X_IRQ_UV_LDO8
,
683 .flags
= IORESOURCE_IRQ
,
687 static struct resource wm831x_ldo9_resources
[] = {
689 .start
= WM831X_LDO9_CONTROL
,
690 .end
= WM831X_LDO9_SLEEP_CONTROL
,
691 .flags
= IORESOURCE_IO
,
695 .start
= WM831X_IRQ_UV_LDO9
,
696 .end
= WM831X_IRQ_UV_LDO9
,
697 .flags
= IORESOURCE_IRQ
,
701 static struct resource wm831x_ldo10_resources
[] = {
703 .start
= WM831X_LDO10_CONTROL
,
704 .end
= WM831X_LDO10_SLEEP_CONTROL
,
705 .flags
= IORESOURCE_IO
,
709 .start
= WM831X_IRQ_UV_LDO10
,
710 .end
= WM831X_IRQ_UV_LDO10
,
711 .flags
= IORESOURCE_IRQ
,
715 static struct resource wm831x_ldo11_resources
[] = {
717 .start
= WM831X_LDO11_ON_CONTROL
,
718 .end
= WM831X_LDO11_SLEEP_CONTROL
,
719 .flags
= IORESOURCE_IO
,
723 static struct resource wm831x_on_resources
[] = {
725 .start
= WM831X_IRQ_ON
,
726 .end
= WM831X_IRQ_ON
,
727 .flags
= IORESOURCE_IRQ
,
732 static struct resource wm831x_power_resources
[] = {
735 .start
= WM831X_IRQ_PPM_SYSLO
,
736 .end
= WM831X_IRQ_PPM_SYSLO
,
737 .flags
= IORESOURCE_IRQ
,
741 .start
= WM831X_IRQ_PPM_PWR_SRC
,
742 .end
= WM831X_IRQ_PPM_PWR_SRC
,
743 .flags
= IORESOURCE_IRQ
,
747 .start
= WM831X_IRQ_PPM_USB_CURR
,
748 .end
= WM831X_IRQ_PPM_USB_CURR
,
749 .flags
= IORESOURCE_IRQ
,
753 .start
= WM831X_IRQ_CHG_BATT_HOT
,
754 .end
= WM831X_IRQ_CHG_BATT_HOT
,
755 .flags
= IORESOURCE_IRQ
,
759 .start
= WM831X_IRQ_CHG_BATT_COLD
,
760 .end
= WM831X_IRQ_CHG_BATT_COLD
,
761 .flags
= IORESOURCE_IRQ
,
765 .start
= WM831X_IRQ_CHG_BATT_FAIL
,
766 .end
= WM831X_IRQ_CHG_BATT_FAIL
,
767 .flags
= IORESOURCE_IRQ
,
771 .start
= WM831X_IRQ_CHG_OV
,
772 .end
= WM831X_IRQ_CHG_OV
,
773 .flags
= IORESOURCE_IRQ
,
777 .start
= WM831X_IRQ_CHG_END
,
778 .end
= WM831X_IRQ_CHG_END
,
779 .flags
= IORESOURCE_IRQ
,
783 .start
= WM831X_IRQ_CHG_TO
,
784 .end
= WM831X_IRQ_CHG_TO
,
785 .flags
= IORESOURCE_IRQ
,
789 .start
= WM831X_IRQ_CHG_MODE
,
790 .end
= WM831X_IRQ_CHG_MODE
,
791 .flags
= IORESOURCE_IRQ
,
795 .start
= WM831X_IRQ_CHG_START
,
796 .end
= WM831X_IRQ_CHG_START
,
797 .flags
= IORESOURCE_IRQ
,
801 static struct resource wm831x_rtc_resources
[] = {
804 .start
= WM831X_IRQ_RTC_PER
,
805 .end
= WM831X_IRQ_RTC_PER
,
806 .flags
= IORESOURCE_IRQ
,
810 .start
= WM831X_IRQ_RTC_ALM
,
811 .end
= WM831X_IRQ_RTC_ALM
,
812 .flags
= IORESOURCE_IRQ
,
816 static struct resource wm831x_status1_resources
[] = {
818 .start
= WM831X_STATUS_LED_1
,
819 .end
= WM831X_STATUS_LED_1
,
820 .flags
= IORESOURCE_IO
,
824 static struct resource wm831x_status2_resources
[] = {
826 .start
= WM831X_STATUS_LED_2
,
827 .end
= WM831X_STATUS_LED_2
,
828 .flags
= IORESOURCE_IO
,
832 static struct resource wm831x_touch_resources
[] = {
835 .start
= WM831X_IRQ_TCHPD
,
836 .end
= WM831X_IRQ_TCHPD
,
837 .flags
= IORESOURCE_IRQ
,
841 .start
= WM831X_IRQ_TCHDATA
,
842 .end
= WM831X_IRQ_TCHDATA
,
843 .flags
= IORESOURCE_IRQ
,
847 static struct resource wm831x_wdt_resources
[] = {
849 .start
= WM831X_IRQ_WDOG_TO
,
850 .end
= WM831X_IRQ_WDOG_TO
,
851 .flags
= IORESOURCE_IRQ
,
855 static struct mfd_cell wm8310_devs
[] = {
857 .name
= "wm831x-backup",
860 .name
= "wm831x-buckv",
862 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
863 .resources
= wm831x_dcdc1_resources
,
866 .name
= "wm831x-buckv",
868 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
869 .resources
= wm831x_dcdc2_resources
,
872 .name
= "wm831x-buckp",
874 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
875 .resources
= wm831x_dcdc3_resources
,
878 .name
= "wm831x-boostp",
880 .num_resources
= ARRAY_SIZE(wm831x_dcdc4_resources
),
881 .resources
= wm831x_dcdc4_resources
,
884 .name
= "wm831x-epe",
888 .name
= "wm831x-epe",
892 .name
= "wm831x-gpio",
893 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
894 .resources
= wm831x_gpio_resources
,
897 .name
= "wm831x-hwmon",
900 .name
= "wm831x-isink",
902 .num_resources
= ARRAY_SIZE(wm831x_isink1_resources
),
903 .resources
= wm831x_isink1_resources
,
906 .name
= "wm831x-isink",
908 .num_resources
= ARRAY_SIZE(wm831x_isink2_resources
),
909 .resources
= wm831x_isink2_resources
,
912 .name
= "wm831x-ldo",
914 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
915 .resources
= wm831x_ldo1_resources
,
918 .name
= "wm831x-ldo",
920 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
921 .resources
= wm831x_ldo2_resources
,
924 .name
= "wm831x-ldo",
926 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
927 .resources
= wm831x_ldo3_resources
,
930 .name
= "wm831x-ldo",
932 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
933 .resources
= wm831x_ldo4_resources
,
936 .name
= "wm831x-ldo",
938 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
939 .resources
= wm831x_ldo5_resources
,
942 .name
= "wm831x-ldo",
944 .num_resources
= ARRAY_SIZE(wm831x_ldo6_resources
),
945 .resources
= wm831x_ldo6_resources
,
948 .name
= "wm831x-aldo",
950 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
951 .resources
= wm831x_ldo7_resources
,
954 .name
= "wm831x-aldo",
956 .num_resources
= ARRAY_SIZE(wm831x_ldo8_resources
),
957 .resources
= wm831x_ldo8_resources
,
960 .name
= "wm831x-aldo",
962 .num_resources
= ARRAY_SIZE(wm831x_ldo9_resources
),
963 .resources
= wm831x_ldo9_resources
,
966 .name
= "wm831x-aldo",
968 .num_resources
= ARRAY_SIZE(wm831x_ldo10_resources
),
969 .resources
= wm831x_ldo10_resources
,
972 .name
= "wm831x-alive-ldo",
974 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
975 .resources
= wm831x_ldo11_resources
,
979 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
980 .resources
= wm831x_on_resources
,
983 .name
= "wm831x-power",
984 .num_resources
= ARRAY_SIZE(wm831x_power_resources
),
985 .resources
= wm831x_power_resources
,
988 .name
= "wm831x-rtc",
989 .num_resources
= ARRAY_SIZE(wm831x_rtc_resources
),
990 .resources
= wm831x_rtc_resources
,
993 .name
= "wm831x-status",
995 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
996 .resources
= wm831x_status1_resources
,
999 .name
= "wm831x-status",
1001 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1002 .resources
= wm831x_status2_resources
,
1005 .name
= "wm831x-watchdog",
1006 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1007 .resources
= wm831x_wdt_resources
,
1011 static struct mfd_cell wm8311_devs
[] = {
1013 .name
= "wm831x-backup",
1016 .name
= "wm831x-buckv",
1018 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
1019 .resources
= wm831x_dcdc1_resources
,
1022 .name
= "wm831x-buckv",
1024 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
1025 .resources
= wm831x_dcdc2_resources
,
1028 .name
= "wm831x-buckp",
1030 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
1031 .resources
= wm831x_dcdc3_resources
,
1034 .name
= "wm831x-boostp",
1036 .num_resources
= ARRAY_SIZE(wm831x_dcdc4_resources
),
1037 .resources
= wm831x_dcdc4_resources
,
1040 .name
= "wm831x-epe",
1044 .name
= "wm831x-epe",
1048 .name
= "wm831x-gpio",
1049 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
1050 .resources
= wm831x_gpio_resources
,
1053 .name
= "wm831x-hwmon",
1056 .name
= "wm831x-isink",
1058 .num_resources
= ARRAY_SIZE(wm831x_isink1_resources
),
1059 .resources
= wm831x_isink1_resources
,
1062 .name
= "wm831x-isink",
1064 .num_resources
= ARRAY_SIZE(wm831x_isink2_resources
),
1065 .resources
= wm831x_isink2_resources
,
1068 .name
= "wm831x-ldo",
1070 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
1071 .resources
= wm831x_ldo1_resources
,
1074 .name
= "wm831x-ldo",
1076 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
1077 .resources
= wm831x_ldo2_resources
,
1080 .name
= "wm831x-ldo",
1082 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
1083 .resources
= wm831x_ldo3_resources
,
1086 .name
= "wm831x-ldo",
1088 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
1089 .resources
= wm831x_ldo4_resources
,
1092 .name
= "wm831x-ldo",
1094 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
1095 .resources
= wm831x_ldo5_resources
,
1098 .name
= "wm831x-aldo",
1100 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
1101 .resources
= wm831x_ldo7_resources
,
1104 .name
= "wm831x-alive-ldo",
1106 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
1107 .resources
= wm831x_ldo11_resources
,
1110 .name
= "wm831x-on",
1111 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
1112 .resources
= wm831x_on_resources
,
1115 .name
= "wm831x-power",
1116 .num_resources
= ARRAY_SIZE(wm831x_power_resources
),
1117 .resources
= wm831x_power_resources
,
1120 .name
= "wm831x-rtc",
1121 .num_resources
= ARRAY_SIZE(wm831x_rtc_resources
),
1122 .resources
= wm831x_rtc_resources
,
1125 .name
= "wm831x-status",
1127 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
1128 .resources
= wm831x_status1_resources
,
1131 .name
= "wm831x-status",
1133 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1134 .resources
= wm831x_status2_resources
,
1137 .name
= "wm831x-touch",
1138 .num_resources
= ARRAY_SIZE(wm831x_touch_resources
),
1139 .resources
= wm831x_touch_resources
,
1142 .name
= "wm831x-watchdog",
1143 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1144 .resources
= wm831x_wdt_resources
,
1148 static struct mfd_cell wm8312_devs
[] = {
1150 .name
= "wm831x-backup",
1153 .name
= "wm831x-buckv",
1155 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
1156 .resources
= wm831x_dcdc1_resources
,
1159 .name
= "wm831x-buckv",
1161 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
1162 .resources
= wm831x_dcdc2_resources
,
1165 .name
= "wm831x-buckp",
1167 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
1168 .resources
= wm831x_dcdc3_resources
,
1171 .name
= "wm831x-boostp",
1173 .num_resources
= ARRAY_SIZE(wm831x_dcdc4_resources
),
1174 .resources
= wm831x_dcdc4_resources
,
1177 .name
= "wm831x-epe",
1181 .name
= "wm831x-epe",
1185 .name
= "wm831x-gpio",
1186 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
1187 .resources
= wm831x_gpio_resources
,
1190 .name
= "wm831x-hwmon",
1193 .name
= "wm831x-isink",
1195 .num_resources
= ARRAY_SIZE(wm831x_isink1_resources
),
1196 .resources
= wm831x_isink1_resources
,
1199 .name
= "wm831x-isink",
1201 .num_resources
= ARRAY_SIZE(wm831x_isink2_resources
),
1202 .resources
= wm831x_isink2_resources
,
1205 .name
= "wm831x-ldo",
1207 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
1208 .resources
= wm831x_ldo1_resources
,
1211 .name
= "wm831x-ldo",
1213 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
1214 .resources
= wm831x_ldo2_resources
,
1217 .name
= "wm831x-ldo",
1219 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
1220 .resources
= wm831x_ldo3_resources
,
1223 .name
= "wm831x-ldo",
1225 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
1226 .resources
= wm831x_ldo4_resources
,
1229 .name
= "wm831x-ldo",
1231 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
1232 .resources
= wm831x_ldo5_resources
,
1235 .name
= "wm831x-ldo",
1237 .num_resources
= ARRAY_SIZE(wm831x_ldo6_resources
),
1238 .resources
= wm831x_ldo6_resources
,
1241 .name
= "wm831x-aldo",
1243 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
1244 .resources
= wm831x_ldo7_resources
,
1247 .name
= "wm831x-aldo",
1249 .num_resources
= ARRAY_SIZE(wm831x_ldo8_resources
),
1250 .resources
= wm831x_ldo8_resources
,
1253 .name
= "wm831x-aldo",
1255 .num_resources
= ARRAY_SIZE(wm831x_ldo9_resources
),
1256 .resources
= wm831x_ldo9_resources
,
1259 .name
= "wm831x-aldo",
1261 .num_resources
= ARRAY_SIZE(wm831x_ldo10_resources
),
1262 .resources
= wm831x_ldo10_resources
,
1265 .name
= "wm831x-alive-ldo",
1267 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
1268 .resources
= wm831x_ldo11_resources
,
1271 .name
= "wm831x-on",
1272 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
1273 .resources
= wm831x_on_resources
,
1276 .name
= "wm831x-power",
1277 .num_resources
= ARRAY_SIZE(wm831x_power_resources
),
1278 .resources
= wm831x_power_resources
,
1281 .name
= "wm831x-rtc",
1282 .num_resources
= ARRAY_SIZE(wm831x_rtc_resources
),
1283 .resources
= wm831x_rtc_resources
,
1286 .name
= "wm831x-status",
1288 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
1289 .resources
= wm831x_status1_resources
,
1292 .name
= "wm831x-status",
1294 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1295 .resources
= wm831x_status2_resources
,
1298 .name
= "wm831x-touch",
1299 .num_resources
= ARRAY_SIZE(wm831x_touch_resources
),
1300 .resources
= wm831x_touch_resources
,
1303 .name
= "wm831x-watchdog",
1304 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1305 .resources
= wm831x_wdt_resources
,
1309 static struct mfd_cell wm8320_devs
[] = {
1311 .name
= "wm831x-backup",
1314 .name
= "wm831x-buckv",
1316 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
1317 .resources
= wm831x_dcdc1_resources
,
1320 .name
= "wm831x-buckv",
1322 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
1323 .resources
= wm831x_dcdc2_resources
,
1326 .name
= "wm831x-buckp",
1328 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
1329 .resources
= wm831x_dcdc3_resources
,
1332 .name
= "wm831x-buckp",
1334 .num_resources
= ARRAY_SIZE(wm8320_dcdc4_buck_resources
),
1335 .resources
= wm8320_dcdc4_buck_resources
,
1338 .name
= "wm831x-gpio",
1339 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
1340 .resources
= wm831x_gpio_resources
,
1343 .name
= "wm831x-hwmon",
1346 .name
= "wm831x-ldo",
1348 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
1349 .resources
= wm831x_ldo1_resources
,
1352 .name
= "wm831x-ldo",
1354 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
1355 .resources
= wm831x_ldo2_resources
,
1358 .name
= "wm831x-ldo",
1360 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
1361 .resources
= wm831x_ldo3_resources
,
1364 .name
= "wm831x-ldo",
1366 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
1367 .resources
= wm831x_ldo4_resources
,
1370 .name
= "wm831x-ldo",
1372 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
1373 .resources
= wm831x_ldo5_resources
,
1376 .name
= "wm831x-ldo",
1378 .num_resources
= ARRAY_SIZE(wm831x_ldo6_resources
),
1379 .resources
= wm831x_ldo6_resources
,
1382 .name
= "wm831x-aldo",
1384 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
1385 .resources
= wm831x_ldo7_resources
,
1388 .name
= "wm831x-aldo",
1390 .num_resources
= ARRAY_SIZE(wm831x_ldo8_resources
),
1391 .resources
= wm831x_ldo8_resources
,
1394 .name
= "wm831x-aldo",
1396 .num_resources
= ARRAY_SIZE(wm831x_ldo9_resources
),
1397 .resources
= wm831x_ldo9_resources
,
1400 .name
= "wm831x-aldo",
1402 .num_resources
= ARRAY_SIZE(wm831x_ldo10_resources
),
1403 .resources
= wm831x_ldo10_resources
,
1406 .name
= "wm831x-alive-ldo",
1408 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
1409 .resources
= wm831x_ldo11_resources
,
1412 .name
= "wm831x-on",
1413 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
1414 .resources
= wm831x_on_resources
,
1417 .name
= "wm831x-rtc",
1418 .num_resources
= ARRAY_SIZE(wm831x_rtc_resources
),
1419 .resources
= wm831x_rtc_resources
,
1422 .name
= "wm831x-status",
1424 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
1425 .resources
= wm831x_status1_resources
,
1428 .name
= "wm831x-status",
1430 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1431 .resources
= wm831x_status2_resources
,
1434 .name
= "wm831x-watchdog",
1435 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1436 .resources
= wm831x_wdt_resources
,
1440 static struct mfd_cell backlight_devs
[] = {
1442 .name
= "wm831x-backlight",
1447 * Instantiate the generic non-control parts of the device.
1449 static int wm831x_device_init(struct wm831x
*wm831x
, unsigned long id
, int irq
)
1451 struct wm831x_pdata
*pdata
= wm831x
->dev
->platform_data
;
1453 enum wm831x_parent parent
;
1456 mutex_init(&wm831x
->io_lock
);
1457 mutex_init(&wm831x
->key_lock
);
1458 mutex_init(&wm831x
->auxadc_lock
);
1459 init_completion(&wm831x
->auxadc_done
);
1460 dev_set_drvdata(wm831x
->dev
, wm831x
);
1462 ret
= wm831x_reg_read(wm831x
, WM831X_PARENT_ID
);
1464 dev_err(wm831x
->dev
, "Failed to read parent ID: %d\n", ret
);
1467 if (ret
!= 0x6204) {
1468 dev_err(wm831x
->dev
, "Device is not a WM831x: ID %x\n", ret
);
1473 ret
= wm831x_reg_read(wm831x
, WM831X_REVISION
);
1475 dev_err(wm831x
->dev
, "Failed to read revision: %d\n", ret
);
1478 rev
= (ret
& WM831X_PARENT_REV_MASK
) >> WM831X_PARENT_REV_SHIFT
;
1480 ret
= wm831x_reg_read(wm831x
, WM831X_RESET_ID
);
1482 dev_err(wm831x
->dev
, "Failed to read device ID: %d\n", ret
);
1486 /* Some engineering samples do not have the ID set, rely on
1487 * the device being registered correctly.
1490 dev_info(wm831x
->dev
, "Device is an engineering sample\n");
1497 wm831x
->num_gpio
= 16;
1498 wm831x
->charger_irq_wake
= 1;
1500 wm831x
->has_gpio_ena
= 1;
1501 wm831x
->has_cs_sts
= 1;
1504 dev_info(wm831x
->dev
, "WM8310 revision %c\n", 'A' + rev
);
1509 wm831x
->num_gpio
= 16;
1510 wm831x
->charger_irq_wake
= 1;
1512 wm831x
->has_gpio_ena
= 1;
1513 wm831x
->has_cs_sts
= 1;
1516 dev_info(wm831x
->dev
, "WM8311 revision %c\n", 'A' + rev
);
1521 wm831x
->num_gpio
= 16;
1522 wm831x
->charger_irq_wake
= 1;
1524 wm831x
->has_gpio_ena
= 1;
1525 wm831x
->has_cs_sts
= 1;
1528 dev_info(wm831x
->dev
, "WM8312 revision %c\n", 'A' + rev
);
1533 wm831x
->num_gpio
= 12;
1534 dev_info(wm831x
->dev
, "WM8320 revision %c\n", 'A' + rev
);
1539 wm831x
->num_gpio
= 12;
1540 dev_info(wm831x
->dev
, "WM8321 revision %c\n", 'A' + rev
);
1544 dev_err(wm831x
->dev
, "Unknown WM831x device %04x\n", ret
);
1549 /* This will need revisiting in future but is OK for all
1553 dev_warn(wm831x
->dev
, "Device was registered as a WM%lx\n",
1556 /* Bootstrap the user key */
1557 ret
= wm831x_reg_read(wm831x
, WM831X_SECURITY_KEY
);
1559 dev_err(wm831x
->dev
, "Failed to read security key: %d\n", ret
);
1563 dev_warn(wm831x
->dev
, "Security key had non-zero value %x\n",
1565 wm831x_reg_write(wm831x
, WM831X_SECURITY_KEY
, 0);
1569 if (pdata
&& pdata
->pre_init
) {
1570 ret
= pdata
->pre_init(wm831x
);
1572 dev_err(wm831x
->dev
, "pre_init() failed: %d\n", ret
);
1577 ret
= wm831x_irq_init(wm831x
, irq
);
1581 if (wm831x
->irq_base
) {
1582 ret
= request_threaded_irq(wm831x
->irq_base
+
1583 WM831X_IRQ_AUXADC_DATA
,
1584 NULL
, wm831x_auxadc_irq
, 0,
1587 dev_err(wm831x
->dev
, "AUXADC IRQ request failed: %d\n",
1591 /* The core device is up, instantiate the subdevices. */
1594 ret
= mfd_add_devices(wm831x
->dev
, -1,
1595 wm8310_devs
, ARRAY_SIZE(wm8310_devs
),
1596 NULL
, wm831x
->irq_base
);
1600 ret
= mfd_add_devices(wm831x
->dev
, -1,
1601 wm8311_devs
, ARRAY_SIZE(wm8311_devs
),
1602 NULL
, wm831x
->irq_base
);
1606 ret
= mfd_add_devices(wm831x
->dev
, -1,
1607 wm8312_devs
, ARRAY_SIZE(wm8312_devs
),
1608 NULL
, wm831x
->irq_base
);
1612 ret
= mfd_add_devices(wm831x
->dev
, -1,
1613 wm8320_devs
, ARRAY_SIZE(wm8320_devs
),
1618 ret
= mfd_add_devices(wm831x
->dev
, -1,
1619 wm8320_devs
, ARRAY_SIZE(wm8320_devs
),
1624 /* If this happens the bus probe function is buggy */
1629 dev_err(wm831x
->dev
, "Failed to add children\n");
1633 if (pdata
&& pdata
->backlight
) {
1634 /* Treat errors as non-critical */
1635 ret
= mfd_add_devices(wm831x
->dev
, -1, backlight_devs
,
1636 ARRAY_SIZE(backlight_devs
), NULL
,
1639 dev_err(wm831x
->dev
, "Failed to add backlight: %d\n",
1643 wm831x_otp_init(wm831x
);
1645 if (pdata
&& pdata
->post_init
) {
1646 ret
= pdata
->post_init(wm831x
);
1648 dev_err(wm831x
->dev
, "post_init() failed: %d\n", ret
);
1656 wm831x_irq_exit(wm831x
);
1658 mfd_remove_devices(wm831x
->dev
);
1663 static void wm831x_device_exit(struct wm831x
*wm831x
)
1665 wm831x_otp_exit(wm831x
);
1666 mfd_remove_devices(wm831x
->dev
);
1667 if (wm831x
->irq_base
)
1668 free_irq(wm831x
->irq_base
+ WM831X_IRQ_AUXADC_DATA
, wm831x
);
1669 wm831x_irq_exit(wm831x
);
1673 static int wm831x_device_suspend(struct wm831x
*wm831x
)
1677 /* If the charger IRQs are a wake source then make sure we ack
1678 * them even if they're not actively being used (eg, no power
1679 * driver or no IRQ line wired up) then acknowledge the
1680 * interrupts otherwise suspend won't last very long.
1682 if (wm831x
->charger_irq_wake
) {
1683 reg
= wm831x_reg_read(wm831x
, WM831X_INTERRUPT_STATUS_2_MASK
);
1685 mask
= WM831X_CHG_BATT_HOT_EINT
|
1686 WM831X_CHG_BATT_COLD_EINT
|
1687 WM831X_CHG_BATT_FAIL_EINT
|
1688 WM831X_CHG_OV_EINT
| WM831X_CHG_END_EINT
|
1689 WM831X_CHG_TO_EINT
| WM831X_CHG_MODE_EINT
|
1690 WM831X_CHG_START_EINT
;
1692 /* If any of the interrupts are masked read the statuses */
1694 reg
= wm831x_reg_read(wm831x
,
1695 WM831X_INTERRUPT_STATUS_2
);
1698 dev_info(wm831x
->dev
,
1699 "Acknowledging masked charger IRQs: %x\n",
1701 wm831x_reg_write(wm831x
, WM831X_INTERRUPT_STATUS_2
,
1709 static int wm831x_i2c_read_device(struct wm831x
*wm831x
, unsigned short reg
,
1710 int bytes
, void *dest
)
1712 struct i2c_client
*i2c
= wm831x
->control_data
;
1714 u16 r
= cpu_to_be16(reg
);
1716 ret
= i2c_master_send(i2c
, (unsigned char *)&r
, 2);
1722 ret
= i2c_master_recv(i2c
, dest
, bytes
);
1730 /* Currently we allocate the write buffer on the stack; this is OK for
1731 * small writes - if we need to do large writes this will need to be
1734 static int wm831x_i2c_write_device(struct wm831x
*wm831x
, unsigned short reg
,
1735 int bytes
, void *src
)
1737 struct i2c_client
*i2c
= wm831x
->control_data
;
1738 unsigned char msg
[bytes
+ 2];
1741 reg
= cpu_to_be16(reg
);
1742 memcpy(&msg
[0], ®
, 2);
1743 memcpy(&msg
[2], src
, bytes
);
1745 ret
= i2c_master_send(i2c
, msg
, bytes
+ 2);
1748 if (ret
< bytes
+ 2)
1754 static int wm831x_i2c_probe(struct i2c_client
*i2c
,
1755 const struct i2c_device_id
*id
)
1757 struct wm831x
*wm831x
;
1759 wm831x
= kzalloc(sizeof(struct wm831x
), GFP_KERNEL
);
1763 i2c_set_clientdata(i2c
, wm831x
);
1764 wm831x
->dev
= &i2c
->dev
;
1765 wm831x
->control_data
= i2c
;
1766 wm831x
->read_dev
= wm831x_i2c_read_device
;
1767 wm831x
->write_dev
= wm831x_i2c_write_device
;
1769 return wm831x_device_init(wm831x
, id
->driver_data
, i2c
->irq
);
1772 static int wm831x_i2c_remove(struct i2c_client
*i2c
)
1774 struct wm831x
*wm831x
= i2c_get_clientdata(i2c
);
1776 wm831x_device_exit(wm831x
);
1781 static int wm831x_i2c_suspend(struct i2c_client
*i2c
, pm_message_t mesg
)
1783 struct wm831x
*wm831x
= i2c_get_clientdata(i2c
);
1785 return wm831x_device_suspend(wm831x
);
1788 static const struct i2c_device_id wm831x_i2c_id
[] = {
1789 { "wm8310", WM8310
},
1790 { "wm8311", WM8311
},
1791 { "wm8312", WM8312
},
1792 { "wm8320", WM8320
},
1793 { "wm8321", WM8321
},
1796 MODULE_DEVICE_TABLE(i2c
, wm831x_i2c_id
);
1799 static struct i2c_driver wm831x_i2c_driver
= {
1802 .owner
= THIS_MODULE
,
1804 .probe
= wm831x_i2c_probe
,
1805 .remove
= wm831x_i2c_remove
,
1806 .suspend
= wm831x_i2c_suspend
,
1807 .id_table
= wm831x_i2c_id
,
1810 static int __init
wm831x_i2c_init(void)
1814 ret
= i2c_add_driver(&wm831x_i2c_driver
);
1816 pr_err("Failed to register wm831x I2C driver: %d\n", ret
);
1820 subsys_initcall(wm831x_i2c_init
);
1822 static void __exit
wm831x_i2c_exit(void)
1824 i2c_del_driver(&wm831x_i2c_driver
);
1826 module_exit(wm831x_i2c_exit
);
1828 MODULE_DESCRIPTION("I2C support for the WM831X AudioPlus PMIC");
1829 MODULE_LICENSE("GPL");
1830 MODULE_AUTHOR("Mark Brown");