2009-07-27 21:45:52 +08:00
|
|
|
/*
|
|
|
|
* wm831x-core.c -- Device access for Wolfson WM831x PMICs
|
|
|
|
*
|
|
|
|
* Copyright 2009 Wolfson Microelectronics PLC.
|
|
|
|
*
|
|
|
|
* Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
2009-07-27 21:45:54 +08:00
|
|
|
#include <linux/bcd.h>
|
|
|
|
#include <linux/delay.h>
|
2009-07-27 21:45:52 +08:00
|
|
|
#include <linux/mfd/core.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2009-07-27 21:45:52 +08:00
|
|
|
|
|
|
|
#include <linux/mfd/wm831x/core.h>
|
|
|
|
#include <linux/mfd/wm831x/pdata.h>
|
2009-07-27 21:45:53 +08:00
|
|
|
#include <linux/mfd/wm831x/irq.h>
|
2009-07-27 21:45:54 +08:00
|
|
|
#include <linux/mfd/wm831x/auxadc.h>
|
2009-07-27 21:45:56 +08:00
|
|
|
#include <linux/mfd/wm831x/otp.h>
|
2009-07-27 21:45:57 +08:00
|
|
|
#include <linux/mfd/wm831x/regulator.h>
|
|
|
|
|
|
|
|
/* Current settings - values are 2*2^(reg_val/4) microamps. These are
|
|
|
|
* exported since they are used by multiple drivers.
|
|
|
|
*/
|
2009-11-30 21:24:18 +08:00
|
|
|
int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1] = {
|
2009-07-27 21:45:57 +08:00
|
|
|
2,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
6,
|
|
|
|
7,
|
|
|
|
8,
|
|
|
|
10,
|
|
|
|
11,
|
|
|
|
13,
|
|
|
|
16,
|
|
|
|
19,
|
|
|
|
23,
|
|
|
|
27,
|
|
|
|
32,
|
|
|
|
38,
|
|
|
|
45,
|
|
|
|
54,
|
|
|
|
64,
|
|
|
|
76,
|
|
|
|
91,
|
|
|
|
108,
|
|
|
|
128,
|
|
|
|
152,
|
|
|
|
181,
|
|
|
|
215,
|
|
|
|
256,
|
|
|
|
304,
|
|
|
|
362,
|
|
|
|
431,
|
|
|
|
512,
|
|
|
|
609,
|
|
|
|
724,
|
|
|
|
861,
|
|
|
|
1024,
|
|
|
|
1218,
|
|
|
|
1448,
|
|
|
|
1722,
|
|
|
|
2048,
|
|
|
|
2435,
|
|
|
|
2896,
|
|
|
|
3444,
|
|
|
|
4096,
|
|
|
|
4871,
|
|
|
|
5793,
|
|
|
|
6889,
|
|
|
|
8192,
|
|
|
|
9742,
|
|
|
|
11585,
|
|
|
|
13777,
|
|
|
|
16384,
|
|
|
|
19484,
|
|
|
|
23170,
|
|
|
|
27554,
|
|
|
|
};
|
|
|
|
EXPORT_SYMBOL_GPL(wm831x_isinkv_values);
|
2009-07-27 21:45:52 +08:00
|
|
|
|
|
|
|
static int wm831x_reg_locked(struct wm831x *wm831x, unsigned short reg)
|
|
|
|
{
|
|
|
|
if (!wm831x->locked)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch (reg) {
|
|
|
|
case WM831X_WATCHDOG:
|
|
|
|
case WM831X_DC4_CONTROL:
|
|
|
|
case WM831X_ON_PIN_CONTROL:
|
|
|
|
case WM831X_BACKUP_CHARGER_CONTROL:
|
|
|
|
case WM831X_CHARGER_CONTROL_1:
|
|
|
|
case WM831X_CHARGER_CONTROL_2:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wm831x_reg_unlock: Unlock user keyed registers
|
|
|
|
*
|
|
|
|
* The WM831x has a user key preventing writes to particularly
|
|
|
|
* critical registers. This function locks those registers,
|
|
|
|
* allowing writes to them.
|
|
|
|
*/
|
|
|
|
void wm831x_reg_lock(struct wm831x *wm831x)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0);
|
|
|
|
if (ret == 0) {
|
|
|
|
dev_vdbg(wm831x->dev, "Registers locked\n");
|
|
|
|
|
|
|
|
mutex_lock(&wm831x->io_lock);
|
|
|
|
WARN_ON(wm831x->locked);
|
|
|
|
wm831x->locked = 1;
|
|
|
|
mutex_unlock(&wm831x->io_lock);
|
|
|
|
} else {
|
|
|
|
dev_err(wm831x->dev, "Failed to lock registers: %d\n", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wm831x_reg_lock);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wm831x_reg_unlock: Unlock user keyed registers
|
|
|
|
*
|
|
|
|
* The WM831x has a user key preventing writes to particularly
|
|
|
|
* critical registers. This function locks those registers,
|
|
|
|
* preventing spurious writes.
|
|
|
|
*/
|
|
|
|
int wm831x_reg_unlock(struct wm831x *wm831x)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* 0x9716 is the value required to unlock the registers */
|
|
|
|
ret = wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0x9716);
|
|
|
|
if (ret == 0) {
|
|
|
|
dev_vdbg(wm831x->dev, "Registers unlocked\n");
|
|
|
|
|
|
|
|
mutex_lock(&wm831x->io_lock);
|
|
|
|
WARN_ON(!wm831x->locked);
|
|
|
|
wm831x->locked = 0;
|
|
|
|
mutex_unlock(&wm831x->io_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wm831x_reg_unlock);
|
|
|
|
|
|
|
|
static int wm831x_read(struct wm831x *wm831x, unsigned short reg,
|
|
|
|
int bytes, void *dest)
|
|
|
|
{
|
|
|
|
int ret, i;
|
|
|
|
u16 *buf = dest;
|
|
|
|
|
|
|
|
BUG_ON(bytes % 2);
|
|
|
|
BUG_ON(bytes <= 0);
|
|
|
|
|
|
|
|
ret = wm831x->read_dev(wm831x, reg, bytes, dest);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
for (i = 0; i < bytes / 2; i++) {
|
|
|
|
buf[i] = be16_to_cpu(buf[i]);
|
|
|
|
|
|
|
|
dev_vdbg(wm831x->dev, "Read %04x from R%d(0x%x)\n",
|
|
|
|
buf[i], reg + i, reg + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wm831x_reg_read: Read a single WM831x register.
|
|
|
|
*
|
|
|
|
* @wm831x: Device to read from.
|
|
|
|
* @reg: Register to read.
|
|
|
|
*/
|
|
|
|
int wm831x_reg_read(struct wm831x *wm831x, unsigned short reg)
|
|
|
|
{
|
|
|
|
unsigned short val;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&wm831x->io_lock);
|
|
|
|
|
|
|
|
ret = wm831x_read(wm831x, reg, 2, &val);
|
|
|
|
|
|
|
|
mutex_unlock(&wm831x->io_lock);
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
else
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wm831x_reg_read);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wm831x_bulk_read: Read multiple WM831x registers
|
|
|
|
*
|
|
|
|
* @wm831x: Device to read from
|
|
|
|
* @reg: First register
|
|
|
|
* @count: Number of registers
|
|
|
|
* @buf: Buffer to fill.
|
|
|
|
*/
|
|
|
|
int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg,
|
|
|
|
int count, u16 *buf)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&wm831x->io_lock);
|
|
|
|
|
|
|
|
ret = wm831x_read(wm831x, reg, count * 2, buf);
|
|
|
|
|
|
|
|
mutex_unlock(&wm831x->io_lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wm831x_bulk_read);
|
|
|
|
|
|
|
|
static int wm831x_write(struct wm831x *wm831x, unsigned short reg,
|
|
|
|
int bytes, void *src)
|
|
|
|
{
|
|
|
|
u16 *buf = src;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
BUG_ON(bytes % 2);
|
|
|
|
BUG_ON(bytes <= 0);
|
|
|
|
|
|
|
|
for (i = 0; i < bytes / 2; i++) {
|
|
|
|
if (wm831x_reg_locked(wm831x, reg))
|
|
|
|
return -EPERM;
|
|
|
|
|
|
|
|
dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n",
|
|
|
|
buf[i], reg + i, reg + i);
|
|
|
|
|
|
|
|
buf[i] = cpu_to_be16(buf[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return wm831x->write_dev(wm831x, reg, bytes, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wm831x_reg_write: Write a single WM831x register.
|
|
|
|
*
|
|
|
|
* @wm831x: Device to write to.
|
|
|
|
* @reg: Register to write to.
|
|
|
|
* @val: Value to write.
|
|
|
|
*/
|
|
|
|
int wm831x_reg_write(struct wm831x *wm831x, unsigned short reg,
|
|
|
|
unsigned short val)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&wm831x->io_lock);
|
|
|
|
|
|
|
|
ret = wm831x_write(wm831x, reg, 2, &val);
|
|
|
|
|
|
|
|
mutex_unlock(&wm831x->io_lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wm831x_reg_write);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wm831x_set_bits: Set the value of a bitfield in a WM831x register
|
|
|
|
*
|
|
|
|
* @wm831x: Device to write to.
|
|
|
|
* @reg: Register to write to.
|
|
|
|
* @mask: Mask of bits to set.
|
|
|
|
* @val: Value to set (unshifted)
|
|
|
|
*/
|
|
|
|
int wm831x_set_bits(struct wm831x *wm831x, unsigned short reg,
|
|
|
|
unsigned short mask, unsigned short val)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
u16 r;
|
|
|
|
|
|
|
|
mutex_lock(&wm831x->io_lock);
|
|
|
|
|
|
|
|
ret = wm831x_read(wm831x, reg, 2, &r);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
r &= ~mask;
|
|
|
|
r |= val;
|
|
|
|
|
|
|
|
ret = wm831x_write(wm831x, reg, 2, &r);
|
|
|
|
|
|
|
|
out:
|
|
|
|
mutex_unlock(&wm831x->io_lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wm831x_set_bits);
|
|
|
|
|
|
|
|
static struct resource wm831x_dcdc1_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_DC1_CONTROL_1,
|
|
|
|
.end = WM831X_DC1_DVS_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_DC1,
|
|
|
|
.end = WM831X_IRQ_UV_DC1,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "HC",
|
|
|
|
.start = WM831X_IRQ_HC_DC1,
|
|
|
|
.end = WM831X_IRQ_HC_DC1,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static struct resource wm831x_dcdc2_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_DC2_CONTROL_1,
|
|
|
|
.end = WM831X_DC2_DVS_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_DC2,
|
|
|
|
.end = WM831X_IRQ_UV_DC2,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "HC",
|
|
|
|
.start = WM831X_IRQ_HC_DC2,
|
|
|
|
.end = WM831X_IRQ_HC_DC2,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_dcdc3_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_DC3_CONTROL_1,
|
|
|
|
.end = WM831X_DC3_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_DC3,
|
|
|
|
.end = WM831X_IRQ_UV_DC3,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_dcdc4_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_DC4_CONTROL,
|
|
|
|
.end = WM831X_DC4_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_DC4,
|
|
|
|
.end = WM831X_IRQ_UV_DC4,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2009-10-01 22:41:07 +08:00
|
|
|
static struct resource wm8320_dcdc4_buck_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_DC4_CONTROL,
|
|
|
|
.end = WM832X_DC4_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_DC4,
|
|
|
|
.end = WM831X_IRQ_UV_DC4,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2009-07-27 21:45:52 +08:00
|
|
|
static struct resource wm831x_gpio_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_IRQ_GPIO_1,
|
|
|
|
.end = WM831X_IRQ_GPIO_16,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_isink1_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_CURRENT_SINK_1,
|
|
|
|
.end = WM831X_CURRENT_SINK_1,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.start = WM831X_IRQ_CS1,
|
|
|
|
.end = WM831X_IRQ_CS1,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_isink2_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_CURRENT_SINK_2,
|
|
|
|
.end = WM831X_CURRENT_SINK_2,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.start = WM831X_IRQ_CS2,
|
|
|
|
.end = WM831X_IRQ_CS2,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_ldo1_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_LDO1_CONTROL,
|
|
|
|
.end = WM831X_LDO1_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_LDO1,
|
|
|
|
.end = WM831X_IRQ_UV_LDO1,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_ldo2_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_LDO2_CONTROL,
|
|
|
|
.end = WM831X_LDO2_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_LDO2,
|
|
|
|
.end = WM831X_IRQ_UV_LDO2,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_ldo3_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_LDO3_CONTROL,
|
|
|
|
.end = WM831X_LDO3_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_LDO3,
|
|
|
|
.end = WM831X_IRQ_UV_LDO3,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_ldo4_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_LDO4_CONTROL,
|
|
|
|
.end = WM831X_LDO4_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_LDO4,
|
|
|
|
.end = WM831X_IRQ_UV_LDO4,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_ldo5_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_LDO5_CONTROL,
|
|
|
|
.end = WM831X_LDO5_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_LDO5,
|
|
|
|
.end = WM831X_IRQ_UV_LDO5,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_ldo6_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_LDO6_CONTROL,
|
|
|
|
.end = WM831X_LDO6_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_LDO6,
|
|
|
|
.end = WM831X_IRQ_UV_LDO6,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_ldo7_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_LDO7_CONTROL,
|
|
|
|
.end = WM831X_LDO7_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_LDO7,
|
|
|
|
.end = WM831X_IRQ_UV_LDO7,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_ldo8_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_LDO8_CONTROL,
|
|
|
|
.end = WM831X_LDO8_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_LDO8,
|
|
|
|
.end = WM831X_IRQ_UV_LDO8,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_ldo9_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_LDO9_CONTROL,
|
|
|
|
.end = WM831X_LDO9_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_LDO9,
|
|
|
|
.end = WM831X_IRQ_UV_LDO9,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_ldo10_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_LDO10_CONTROL,
|
|
|
|
.end = WM831X_LDO10_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "UV",
|
|
|
|
.start = WM831X_IRQ_UV_LDO10,
|
|
|
|
.end = WM831X_IRQ_UV_LDO10,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_ldo11_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_LDO11_ON_CONTROL,
|
|
|
|
.end = WM831X_LDO11_SLEEP_CONTROL,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_on_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_IRQ_ON,
|
|
|
|
.end = WM831X_IRQ_ON,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static struct resource wm831x_power_resources[] = {
|
|
|
|
{
|
|
|
|
.name = "SYSLO",
|
|
|
|
.start = WM831X_IRQ_PPM_SYSLO,
|
|
|
|
.end = WM831X_IRQ_PPM_SYSLO,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "PWR SRC",
|
|
|
|
.start = WM831X_IRQ_PPM_PWR_SRC,
|
|
|
|
.end = WM831X_IRQ_PPM_PWR_SRC,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "USB CURR",
|
|
|
|
.start = WM831X_IRQ_PPM_USB_CURR,
|
|
|
|
.end = WM831X_IRQ_PPM_USB_CURR,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "BATT HOT",
|
|
|
|
.start = WM831X_IRQ_CHG_BATT_HOT,
|
|
|
|
.end = WM831X_IRQ_CHG_BATT_HOT,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "BATT COLD",
|
|
|
|
.start = WM831X_IRQ_CHG_BATT_COLD,
|
|
|
|
.end = WM831X_IRQ_CHG_BATT_COLD,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "BATT FAIL",
|
|
|
|
.start = WM831X_IRQ_CHG_BATT_FAIL,
|
|
|
|
.end = WM831X_IRQ_CHG_BATT_FAIL,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "OV",
|
|
|
|
.start = WM831X_IRQ_CHG_OV,
|
|
|
|
.end = WM831X_IRQ_CHG_OV,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "END",
|
|
|
|
.start = WM831X_IRQ_CHG_END,
|
|
|
|
.end = WM831X_IRQ_CHG_END,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "TO",
|
|
|
|
.start = WM831X_IRQ_CHG_TO,
|
|
|
|
.end = WM831X_IRQ_CHG_TO,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "MODE",
|
|
|
|
.start = WM831X_IRQ_CHG_MODE,
|
|
|
|
.end = WM831X_IRQ_CHG_MODE,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "START",
|
|
|
|
.start = WM831X_IRQ_CHG_START,
|
|
|
|
.end = WM831X_IRQ_CHG_START,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_rtc_resources[] = {
|
|
|
|
{
|
|
|
|
.name = "PER",
|
|
|
|
.start = WM831X_IRQ_RTC_PER,
|
|
|
|
.end = WM831X_IRQ_RTC_PER,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "ALM",
|
|
|
|
.start = WM831X_IRQ_RTC_ALM,
|
|
|
|
.end = WM831X_IRQ_RTC_ALM,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_status1_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_STATUS_LED_1,
|
|
|
|
.end = WM831X_STATUS_LED_1,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_status2_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_STATUS_LED_2,
|
|
|
|
.end = WM831X_STATUS_LED_2,
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_touch_resources[] = {
|
|
|
|
{
|
|
|
|
.name = "TCHPD",
|
|
|
|
.start = WM831X_IRQ_TCHPD,
|
|
|
|
.end = WM831X_IRQ_TCHPD,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "TCHDATA",
|
|
|
|
.start = WM831X_IRQ_TCHDATA,
|
|
|
|
.end = WM831X_IRQ_TCHDATA,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource wm831x_wdt_resources[] = {
|
|
|
|
{
|
|
|
|
.start = WM831X_IRQ_WDOG_TO,
|
|
|
|
.end = WM831X_IRQ_WDOG_TO,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct mfd_cell wm8310_devs[] = {
|
2009-10-01 22:41:06 +08:00
|
|
|
{
|
|
|
|
.name = "wm831x-backup",
|
|
|
|
},
|
2009-07-27 21:45:52 +08:00
|
|
|
{
|
|
|
|
.name = "wm831x-buckv",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
|
|
|
|
.resources = wm831x_dcdc1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-buckv",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
|
|
|
|
.resources = wm831x_dcdc2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-buckp",
|
|
|
|
.id = 3,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
|
|
|
|
.resources = wm831x_dcdc3_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-boostp",
|
|
|
|
.id = 4,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc4_resources),
|
|
|
|
.resources = wm831x_dcdc4_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-epe",
|
|
|
|
.id = 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-epe",
|
|
|
|
.id = 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-gpio",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_gpio_resources),
|
|
|
|
.resources = wm831x_gpio_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-hwmon",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-isink",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_isink1_resources),
|
|
|
|
.resources = wm831x_isink1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-isink",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_isink2_resources),
|
|
|
|
.resources = wm831x_isink2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
|
|
|
|
.resources = wm831x_ldo1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
|
|
|
|
.resources = wm831x_ldo2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 3,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
|
|
|
|
.resources = wm831x_ldo3_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 4,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
|
|
|
|
.resources = wm831x_ldo4_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 5,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
|
|
|
|
.resources = wm831x_ldo5_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 6,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo6_resources),
|
|
|
|
.resources = wm831x_ldo6_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 7,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
|
|
|
|
.resources = wm831x_ldo7_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 8,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo8_resources),
|
|
|
|
.resources = wm831x_ldo8_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 9,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo9_resources),
|
|
|
|
.resources = wm831x_ldo9_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 10,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo10_resources),
|
|
|
|
.resources = wm831x_ldo10_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-alive-ldo",
|
|
|
|
.id = 11,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
|
|
|
|
.resources = wm831x_ldo11_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-on",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_on_resources),
|
|
|
|
.resources = wm831x_on_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-power",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_power_resources),
|
|
|
|
.resources = wm831x_power_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-status",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_status1_resources),
|
|
|
|
.resources = wm831x_status1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-status",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_status2_resources),
|
|
|
|
.resources = wm831x_status2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-watchdog",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_wdt_resources),
|
|
|
|
.resources = wm831x_wdt_resources,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct mfd_cell wm8311_devs[] = {
|
2009-10-01 22:41:06 +08:00
|
|
|
{
|
|
|
|
.name = "wm831x-backup",
|
|
|
|
},
|
2009-07-27 21:45:52 +08:00
|
|
|
{
|
|
|
|
.name = "wm831x-buckv",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
|
|
|
|
.resources = wm831x_dcdc1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-buckv",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
|
|
|
|
.resources = wm831x_dcdc2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-buckp",
|
|
|
|
.id = 3,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
|
|
|
|
.resources = wm831x_dcdc3_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-boostp",
|
|
|
|
.id = 4,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc4_resources),
|
|
|
|
.resources = wm831x_dcdc4_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-epe",
|
|
|
|
.id = 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-epe",
|
|
|
|
.id = 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-gpio",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_gpio_resources),
|
|
|
|
.resources = wm831x_gpio_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-hwmon",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-isink",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_isink1_resources),
|
|
|
|
.resources = wm831x_isink1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-isink",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_isink2_resources),
|
|
|
|
.resources = wm831x_isink2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
|
|
|
|
.resources = wm831x_ldo1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
|
|
|
|
.resources = wm831x_ldo2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 3,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
|
|
|
|
.resources = wm831x_ldo3_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 4,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
|
|
|
|
.resources = wm831x_ldo4_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 5,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
|
|
|
|
.resources = wm831x_ldo5_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 7,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
|
|
|
|
.resources = wm831x_ldo7_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-alive-ldo",
|
|
|
|
.id = 11,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
|
|
|
|
.resources = wm831x_ldo11_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-on",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_on_resources),
|
|
|
|
.resources = wm831x_on_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-power",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_power_resources),
|
|
|
|
.resources = wm831x_power_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-status",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_status1_resources),
|
|
|
|
.resources = wm831x_status1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-status",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_status2_resources),
|
|
|
|
.resources = wm831x_status2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-watchdog",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_wdt_resources),
|
|
|
|
.resources = wm831x_wdt_resources,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct mfd_cell wm8312_devs[] = {
|
2009-10-01 22:41:06 +08:00
|
|
|
{
|
|
|
|
.name = "wm831x-backup",
|
|
|
|
},
|
2009-07-27 21:45:52 +08:00
|
|
|
{
|
|
|
|
.name = "wm831x-buckv",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
|
|
|
|
.resources = wm831x_dcdc1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-buckv",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
|
|
|
|
.resources = wm831x_dcdc2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-buckp",
|
|
|
|
.id = 3,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
|
|
|
|
.resources = wm831x_dcdc3_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-boostp",
|
|
|
|
.id = 4,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc4_resources),
|
|
|
|
.resources = wm831x_dcdc4_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-epe",
|
|
|
|
.id = 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-epe",
|
|
|
|
.id = 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-gpio",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_gpio_resources),
|
|
|
|
.resources = wm831x_gpio_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-hwmon",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-isink",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_isink1_resources),
|
|
|
|
.resources = wm831x_isink1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-isink",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_isink2_resources),
|
|
|
|
.resources = wm831x_isink2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
|
|
|
|
.resources = wm831x_ldo1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
|
|
|
|
.resources = wm831x_ldo2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 3,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
|
|
|
|
.resources = wm831x_ldo3_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 4,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
|
|
|
|
.resources = wm831x_ldo4_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 5,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
|
|
|
|
.resources = wm831x_ldo5_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 6,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo6_resources),
|
|
|
|
.resources = wm831x_ldo6_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 7,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
|
|
|
|
.resources = wm831x_ldo7_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 8,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo8_resources),
|
|
|
|
.resources = wm831x_ldo8_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 9,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo9_resources),
|
|
|
|
.resources = wm831x_ldo9_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 10,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo10_resources),
|
|
|
|
.resources = wm831x_ldo10_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-alive-ldo",
|
|
|
|
.id = 11,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
|
|
|
|
.resources = wm831x_ldo11_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-on",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_on_resources),
|
|
|
|
.resources = wm831x_on_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-power",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_power_resources),
|
|
|
|
.resources = wm831x_power_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-status",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_status1_resources),
|
|
|
|
.resources = wm831x_status1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-status",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_status2_resources),
|
|
|
|
.resources = wm831x_status2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-watchdog",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_wdt_resources),
|
|
|
|
.resources = wm831x_wdt_resources,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2009-10-01 22:41:07 +08:00
|
|
|
static struct mfd_cell wm8320_devs[] = {
|
|
|
|
{
|
|
|
|
.name = "wm831x-backup",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-buckv",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
|
|
|
|
.resources = wm831x_dcdc1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-buckv",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
|
|
|
|
.resources = wm831x_dcdc2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-buckp",
|
|
|
|
.id = 3,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
|
|
|
|
.resources = wm831x_dcdc3_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-buckp",
|
|
|
|
.id = 4,
|
|
|
|
.num_resources = ARRAY_SIZE(wm8320_dcdc4_buck_resources),
|
|
|
|
.resources = wm8320_dcdc4_buck_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-gpio",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_gpio_resources),
|
|
|
|
.resources = wm831x_gpio_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-hwmon",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
|
|
|
|
.resources = wm831x_ldo1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
|
|
|
|
.resources = wm831x_ldo2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 3,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
|
|
|
|
.resources = wm831x_ldo3_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 4,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
|
|
|
|
.resources = wm831x_ldo4_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 5,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
|
|
|
|
.resources = wm831x_ldo5_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-ldo",
|
|
|
|
.id = 6,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo6_resources),
|
|
|
|
.resources = wm831x_ldo6_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 7,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
|
|
|
|
.resources = wm831x_ldo7_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 8,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo8_resources),
|
|
|
|
.resources = wm831x_ldo8_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 9,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo9_resources),
|
|
|
|
.resources = wm831x_ldo9_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-aldo",
|
|
|
|
.id = 10,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo10_resources),
|
|
|
|
.resources = wm831x_ldo10_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-alive-ldo",
|
|
|
|
.id = 11,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
|
|
|
|
.resources = wm831x_ldo11_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-on",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_on_resources),
|
|
|
|
.resources = wm831x_on_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-status",
|
|
|
|
.id = 1,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_status1_resources),
|
|
|
|
.resources = wm831x_status1_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-status",
|
|
|
|
.id = 2,
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_status2_resources),
|
|
|
|
.resources = wm831x_status2_resources,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wm831x-watchdog",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_wdt_resources),
|
|
|
|
.resources = wm831x_wdt_resources,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2011-06-03 02:18:49 +08:00
|
|
|
static struct mfd_cell touch_devs[] = {
|
|
|
|
{
|
|
|
|
.name = "wm831x-touch",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_touch_resources),
|
|
|
|
.resources = wm831x_touch_resources,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2011-06-03 02:18:50 +08:00
|
|
|
static struct mfd_cell rtc_devs[] = {
|
|
|
|
{
|
|
|
|
.name = "wm831x-rtc",
|
|
|
|
.num_resources = ARRAY_SIZE(wm831x_rtc_resources),
|
|
|
|
.resources = wm831x_rtc_resources,
|
|
|
|
},
|
|
|
|
};
|
2011-06-03 02:18:49 +08:00
|
|
|
|
2009-07-27 21:45:55 +08:00
|
|
|
static struct mfd_cell backlight_devs[] = {
|
|
|
|
{
|
|
|
|
.name = "wm831x-backlight",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2009-07-27 21:45:52 +08:00
|
|
|
/*
|
|
|
|
* Instantiate the generic non-control parts of the device.
|
|
|
|
*/
|
2010-10-20 05:57:56 +08:00
|
|
|
int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
|
2009-07-27 21:45:52 +08:00
|
|
|
{
|
|
|
|
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
|
2011-06-03 02:18:48 +08:00
|
|
|
int rev, wm831x_num;
|
2009-07-27 21:45:52 +08:00
|
|
|
enum wm831x_parent parent;
|
2011-04-04 10:04:42 +08:00
|
|
|
int ret, i;
|
2009-07-27 21:45:52 +08:00
|
|
|
|
|
|
|
mutex_init(&wm831x->io_lock);
|
|
|
|
mutex_init(&wm831x->key_lock);
|
|
|
|
dev_set_drvdata(wm831x->dev, wm831x);
|
|
|
|
|
|
|
|
ret = wm831x_reg_read(wm831x, WM831X_PARENT_ID);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(wm831x->dev, "Failed to read parent ID: %d\n", ret);
|
|
|
|
goto err;
|
|
|
|
}
|
2010-12-03 00:25:43 +08:00
|
|
|
switch (ret) {
|
|
|
|
case 0x6204:
|
|
|
|
case 0x6246:
|
|
|
|
break;
|
|
|
|
default:
|
2009-07-27 21:45:52 +08:00
|
|
|
dev_err(wm831x->dev, "Device is not a WM831x: ID %x\n", ret);
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = wm831x_reg_read(wm831x, WM831X_REVISION);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(wm831x->dev, "Failed to read revision: %d\n", ret);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
rev = (ret & WM831X_PARENT_REV_MASK) >> WM831X_PARENT_REV_SHIFT;
|
|
|
|
|
|
|
|
ret = wm831x_reg_read(wm831x, WM831X_RESET_ID);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(wm831x->dev, "Failed to read device ID: %d\n", ret);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2009-10-01 22:41:04 +08:00
|
|
|
/* Some engineering samples do not have the ID set, rely on
|
|
|
|
* the device being registered correctly.
|
|
|
|
*/
|
|
|
|
if (ret == 0) {
|
|
|
|
dev_info(wm831x->dev, "Device is an engineering sample\n");
|
|
|
|
ret = id;
|
|
|
|
}
|
|
|
|
|
2009-07-27 21:45:52 +08:00
|
|
|
switch (ret) {
|
2009-10-01 22:41:04 +08:00
|
|
|
case WM8310:
|
2009-07-27 21:45:52 +08:00
|
|
|
parent = WM8310;
|
2009-10-01 22:41:05 +08:00
|
|
|
wm831x->num_gpio = 16;
|
2010-04-08 16:02:39 +08:00
|
|
|
wm831x->charger_irq_wake = 1;
|
2010-02-18 02:45:25 +08:00
|
|
|
if (rev > 0) {
|
|
|
|
wm831x->has_gpio_ena = 1;
|
|
|
|
wm831x->has_cs_sts = 1;
|
|
|
|
}
|
|
|
|
|
2009-10-01 22:41:04 +08:00
|
|
|
dev_info(wm831x->dev, "WM8310 revision %c\n", 'A' + rev);
|
2009-07-27 21:45:52 +08:00
|
|
|
break;
|
|
|
|
|
2009-10-01 22:41:04 +08:00
|
|
|
case WM8311:
|
2009-07-27 21:45:52 +08:00
|
|
|
parent = WM8311;
|
2009-10-01 22:41:05 +08:00
|
|
|
wm831x->num_gpio = 16;
|
2010-04-08 16:02:39 +08:00
|
|
|
wm831x->charger_irq_wake = 1;
|
2010-02-18 02:45:25 +08:00
|
|
|
if (rev > 0) {
|
|
|
|
wm831x->has_gpio_ena = 1;
|
|
|
|
wm831x->has_cs_sts = 1;
|
|
|
|
}
|
|
|
|
|
2009-10-01 22:41:04 +08:00
|
|
|
dev_info(wm831x->dev, "WM8311 revision %c\n", 'A' + rev);
|
2009-07-27 21:45:52 +08:00
|
|
|
break;
|
|
|
|
|
2009-10-01 22:41:04 +08:00
|
|
|
case WM8312:
|
2009-07-27 21:45:52 +08:00
|
|
|
parent = WM8312;
|
2009-10-01 22:41:05 +08:00
|
|
|
wm831x->num_gpio = 16;
|
2010-04-08 16:02:39 +08:00
|
|
|
wm831x->charger_irq_wake = 1;
|
2010-02-18 02:45:25 +08:00
|
|
|
if (rev > 0) {
|
|
|
|
wm831x->has_gpio_ena = 1;
|
|
|
|
wm831x->has_cs_sts = 1;
|
|
|
|
}
|
|
|
|
|
2009-10-01 22:41:04 +08:00
|
|
|
dev_info(wm831x->dev, "WM8312 revision %c\n", 'A' + rev);
|
2009-07-27 21:45:52 +08:00
|
|
|
break;
|
|
|
|
|
2009-10-01 22:41:07 +08:00
|
|
|
case WM8320:
|
|
|
|
parent = WM8320;
|
|
|
|
wm831x->num_gpio = 12;
|
|
|
|
dev_info(wm831x->dev, "WM8320 revision %c\n", 'A' + rev);
|
|
|
|
break;
|
|
|
|
|
2010-07-21 21:23:37 +08:00
|
|
|
case WM8321:
|
|
|
|
parent = WM8321;
|
|
|
|
wm831x->num_gpio = 12;
|
|
|
|
dev_info(wm831x->dev, "WM8321 revision %c\n", 'A' + rev);
|
|
|
|
break;
|
|
|
|
|
2010-09-29 00:13:39 +08:00
|
|
|
case WM8325:
|
|
|
|
parent = WM8325;
|
|
|
|
wm831x->num_gpio = 12;
|
|
|
|
dev_info(wm831x->dev, "WM8325 revision %c\n", 'A' + rev);
|
|
|
|
break;
|
|
|
|
|
2010-11-25 02:01:41 +08:00
|
|
|
case WM8326:
|
|
|
|
parent = WM8326;
|
|
|
|
wm831x->num_gpio = 12;
|
|
|
|
dev_info(wm831x->dev, "WM8326 revision %c\n", 'A' + rev);
|
|
|
|
break;
|
|
|
|
|
2009-07-27 21:45:52 +08:00
|
|
|
default:
|
|
|
|
dev_err(wm831x->dev, "Unknown WM831x device %04x\n", ret);
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This will need revisiting in future but is OK for all
|
|
|
|
* current parts.
|
|
|
|
*/
|
|
|
|
if (parent != id)
|
2009-10-01 22:41:04 +08:00
|
|
|
dev_warn(wm831x->dev, "Device was registered as a WM%lx\n",
|
2009-07-27 21:45:52 +08:00
|
|
|
id);
|
|
|
|
|
|
|
|
/* Bootstrap the user key */
|
|
|
|
ret = wm831x_reg_read(wm831x, WM831X_SECURITY_KEY);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(wm831x->dev, "Failed to read security key: %d\n", ret);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
if (ret != 0) {
|
|
|
|
dev_warn(wm831x->dev, "Security key had non-zero value %x\n",
|
|
|
|
ret);
|
|
|
|
wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0);
|
|
|
|
}
|
|
|
|
wm831x->locked = 1;
|
|
|
|
|
|
|
|
if (pdata && pdata->pre_init) {
|
|
|
|
ret = pdata->pre_init(wm831x);
|
|
|
|
if (ret != 0) {
|
|
|
|
dev_err(wm831x->dev, "pre_init() failed: %d\n", ret);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-04 10:04:42 +08:00
|
|
|
if (pdata) {
|
|
|
|
for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
|
|
|
|
if (!pdata->gpio_defaults[i])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wm831x_reg_write(wm831x,
|
|
|
|
WM831X_GPIO1_CONTROL + i,
|
|
|
|
pdata->gpio_defaults[i] & 0xffff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-03 02:18:48 +08:00
|
|
|
/* Multiply by 10 as we have many subdevices of the same type */
|
|
|
|
if (pdata && pdata->wm831x_num)
|
|
|
|
wm831x_num = pdata->wm831x_num * 10;
|
|
|
|
else
|
|
|
|
wm831x_num = -1;
|
|
|
|
|
2009-07-27 21:45:53 +08:00
|
|
|
ret = wm831x_irq_init(wm831x, irq);
|
|
|
|
if (ret != 0)
|
|
|
|
goto err;
|
|
|
|
|
2011-06-03 02:18:53 +08:00
|
|
|
wm831x_auxadc_init(wm831x);
|
2010-02-23 19:08:06 +08:00
|
|
|
|
2009-07-27 21:45:52 +08:00
|
|
|
/* The core device is up, instantiate the subdevices. */
|
|
|
|
switch (parent) {
|
|
|
|
case WM8310:
|
2011-06-03 02:18:48 +08:00
|
|
|
ret = mfd_add_devices(wm831x->dev, wm831x_num,
|
2009-07-27 21:45:52 +08:00
|
|
|
wm8310_devs, ARRAY_SIZE(wm8310_devs),
|
2009-11-12 00:10:22 +08:00
|
|
|
NULL, wm831x->irq_base);
|
2009-07-27 21:45:52 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM8311:
|
2011-06-03 02:18:48 +08:00
|
|
|
ret = mfd_add_devices(wm831x->dev, wm831x_num,
|
2009-07-27 21:45:52 +08:00
|
|
|
wm8311_devs, ARRAY_SIZE(wm8311_devs),
|
2009-11-12 00:10:22 +08:00
|
|
|
NULL, wm831x->irq_base);
|
2011-06-03 02:18:49 +08:00
|
|
|
if (!pdata || !pdata->disable_touch)
|
|
|
|
mfd_add_devices(wm831x->dev, wm831x_num,
|
|
|
|
touch_devs, ARRAY_SIZE(touch_devs),
|
|
|
|
NULL, wm831x->irq_base);
|
2009-07-27 21:45:52 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM8312:
|
2011-06-03 02:18:48 +08:00
|
|
|
ret = mfd_add_devices(wm831x->dev, wm831x_num,
|
2009-07-27 21:45:52 +08:00
|
|
|
wm8312_devs, ARRAY_SIZE(wm8312_devs),
|
2009-11-12 00:10:22 +08:00
|
|
|
NULL, wm831x->irq_base);
|
2011-06-03 02:18:49 +08:00
|
|
|
if (!pdata || !pdata->disable_touch)
|
|
|
|
mfd_add_devices(wm831x->dev, wm831x_num,
|
|
|
|
touch_devs, ARRAY_SIZE(touch_devs),
|
|
|
|
NULL, wm831x->irq_base);
|
2009-07-27 21:45:52 +08:00
|
|
|
break;
|
|
|
|
|
2009-10-01 22:41:07 +08:00
|
|
|
case WM8320:
|
2010-07-21 21:23:37 +08:00
|
|
|
case WM8321:
|
2010-09-29 00:13:39 +08:00
|
|
|
case WM8325:
|
2010-11-25 02:01:41 +08:00
|
|
|
case WM8326:
|
2011-06-03 02:18:48 +08:00
|
|
|
ret = mfd_add_devices(wm831x->dev, wm831x_num,
|
2010-09-29 00:13:39 +08:00
|
|
|
wm8320_devs, ARRAY_SIZE(wm8320_devs),
|
2010-11-25 02:01:39 +08:00
|
|
|
NULL, wm831x->irq_base);
|
2010-09-29 00:13:39 +08:00
|
|
|
break;
|
|
|
|
|
2009-07-27 21:45:52 +08:00
|
|
|
default:
|
|
|
|
/* If this happens the bus probe function is buggy */
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret != 0) {
|
|
|
|
dev_err(wm831x->dev, "Failed to add children\n");
|
2009-07-27 21:45:53 +08:00
|
|
|
goto err_irq;
|
2009-07-27 21:45:52 +08:00
|
|
|
}
|
|
|
|
|
2011-06-03 02:18:50 +08:00
|
|
|
/* The RTC can only be used if the 32.768kHz crystal is
|
|
|
|
* enabled; this can't be controlled by software at runtime.
|
|
|
|
*/
|
|
|
|
ret = wm831x_reg_read(wm831x, WM831X_CLOCK_CONTROL_2);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(wm831x->dev, "Failed to read clock status: %d\n", ret);
|
|
|
|
goto err_irq;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret & WM831X_XTAL_ENA) {
|
|
|
|
ret = mfd_add_devices(wm831x->dev, wm831x_num,
|
|
|
|
rtc_devs, ARRAY_SIZE(rtc_devs),
|
|
|
|
NULL, wm831x->irq_base);
|
|
|
|
if (ret != 0) {
|
|
|
|
dev_err(wm831x->dev, "Failed to add RTC: %d\n", ret);
|
|
|
|
goto err_irq;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dev_info(wm831x->dev, "32.768kHz clock disabled, no RTC\n");
|
|
|
|
}
|
|
|
|
|
2009-07-27 21:45:55 +08:00
|
|
|
if (pdata && pdata->backlight) {
|
|
|
|
/* Treat errors as non-critical */
|
2011-06-03 02:18:48 +08:00
|
|
|
ret = mfd_add_devices(wm831x->dev, wm831x_num, backlight_devs,
|
2009-11-12 00:10:22 +08:00
|
|
|
ARRAY_SIZE(backlight_devs), NULL,
|
|
|
|
wm831x->irq_base);
|
2009-07-27 21:45:55 +08:00
|
|
|
if (ret < 0)
|
|
|
|
dev_err(wm831x->dev, "Failed to add backlight: %d\n",
|
|
|
|
ret);
|
|
|
|
}
|
|
|
|
|
2009-07-27 21:45:56 +08:00
|
|
|
wm831x_otp_init(wm831x);
|
|
|
|
|
2009-07-27 21:45:52 +08:00
|
|
|
if (pdata && pdata->post_init) {
|
|
|
|
ret = pdata->post_init(wm831x);
|
|
|
|
if (ret != 0) {
|
|
|
|
dev_err(wm831x->dev, "post_init() failed: %d\n", ret);
|
2009-07-27 21:45:53 +08:00
|
|
|
goto err_irq;
|
2009-07-27 21:45:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2009-07-27 21:45:53 +08:00
|
|
|
err_irq:
|
|
|
|
wm831x_irq_exit(wm831x);
|
2009-07-27 21:45:52 +08:00
|
|
|
err:
|
|
|
|
mfd_remove_devices(wm831x->dev);
|
|
|
|
kfree(wm831x);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-10-20 05:57:56 +08:00
|
|
|
void wm831x_device_exit(struct wm831x *wm831x)
|
2009-07-27 21:45:52 +08:00
|
|
|
{
|
2009-07-27 21:45:56 +08:00
|
|
|
wm831x_otp_exit(wm831x);
|
2009-07-27 21:45:52 +08:00
|
|
|
mfd_remove_devices(wm831x->dev);
|
2010-02-23 19:08:06 +08:00
|
|
|
if (wm831x->irq_base)
|
|
|
|
free_irq(wm831x->irq_base + WM831X_IRQ_AUXADC_DATA, wm831x);
|
2009-07-27 21:45:53 +08:00
|
|
|
wm831x_irq_exit(wm831x);
|
2009-07-27 21:45:52 +08:00
|
|
|
kfree(wm831x);
|
|
|
|
}
|
|
|
|
|
2010-10-20 05:57:56 +08:00
|
|
|
int wm831x_device_suspend(struct wm831x *wm831x)
|
2010-04-08 16:02:39 +08:00
|
|
|
{
|
|
|
|
int reg, mask;
|
|
|
|
|
|
|
|
/* If the charger IRQs are a wake source then make sure we ack
|
|
|
|
* them even if they're not actively being used (eg, no power
|
|
|
|
* driver or no IRQ line wired up) then acknowledge the
|
|
|
|
* interrupts otherwise suspend won't last very long.
|
|
|
|
*/
|
|
|
|
if (wm831x->charger_irq_wake) {
|
|
|
|
reg = wm831x_reg_read(wm831x, WM831X_INTERRUPT_STATUS_2_MASK);
|
|
|
|
|
|
|
|
mask = WM831X_CHG_BATT_HOT_EINT |
|
|
|
|
WM831X_CHG_BATT_COLD_EINT |
|
|
|
|
WM831X_CHG_BATT_FAIL_EINT |
|
|
|
|
WM831X_CHG_OV_EINT | WM831X_CHG_END_EINT |
|
|
|
|
WM831X_CHG_TO_EINT | WM831X_CHG_MODE_EINT |
|
|
|
|
WM831X_CHG_START_EINT;
|
|
|
|
|
|
|
|
/* If any of the interrupts are masked read the statuses */
|
|
|
|
if (reg & mask)
|
|
|
|
reg = wm831x_reg_read(wm831x,
|
|
|
|
WM831X_INTERRUPT_STATUS_2);
|
|
|
|
|
|
|
|
if (reg & mask) {
|
|
|
|
dev_info(wm831x->dev,
|
|
|
|
"Acknowledging masked charger IRQs: %x\n",
|
|
|
|
reg & mask);
|
|
|
|
wm831x_reg_write(wm831x, WM831X_INTERRUPT_STATUS_2,
|
|
|
|
reg & mask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-20 05:57:56 +08:00
|
|
|
MODULE_DESCRIPTION("Core support for the WM831X AudioPlus PMIC");
|
2009-07-27 21:45:52 +08:00
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Mark Brown");
|