Commit 0b14c22e authored by Mark Brown's avatar Mark Brown Committed by Samuel Ortiz

mfd: Provide platform data for WM831x GPIO configuration

Allow the GPIO mode of WM831x devices to be configured using platform data.
Users may provide a table of GPIO register values in gpio_defaults[]. In
order to allow 0 to be set explicitly out of range values are accepted and
masked off, with a WM831X_GPIO_CONFIGURE define provided to set an out of
range value.

This can be used to configure higher numbered GPIOs or override values set
in OTP for GPIOs configured using OTP.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 8997619a
...@@ -1442,7 +1442,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) ...@@ -1442,7 +1442,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
struct wm831x_pdata *pdata = wm831x->dev->platform_data; struct wm831x_pdata *pdata = wm831x->dev->platform_data;
int rev; int rev;
enum wm831x_parent parent; enum wm831x_parent parent;
int ret; int ret, i;
mutex_init(&wm831x->io_lock); mutex_init(&wm831x->io_lock);
mutex_init(&wm831x->key_lock); mutex_init(&wm831x->key_lock);
...@@ -1581,6 +1581,17 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) ...@@ -1581,6 +1581,17 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
} }
} }
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);
}
}
ret = wm831x_irq_init(wm831x, irq); ret = wm831x_irq_init(wm831x, irq);
if (ret != 0) if (ret != 0)
goto err; goto err;
......
...@@ -105,6 +105,9 @@ struct wm831x_watchdog_pdata { ...@@ -105,6 +105,9 @@ struct wm831x_watchdog_pdata {
#define WM831X_MAX_LDO 11 #define WM831X_MAX_LDO 11
#define WM831X_MAX_ISINK 2 #define WM831X_MAX_ISINK 2
#define WM831X_GPIO_CONFIGURE 0x10000
#define WM831X_GPIO_NUM 16
struct wm831x_pdata { struct wm831x_pdata {
/** Used to distinguish multiple WM831x chips */ /** Used to distinguish multiple WM831x chips */
int wm831x_num; int wm831x_num;
...@@ -119,6 +122,7 @@ struct wm831x_pdata { ...@@ -119,6 +122,7 @@ struct wm831x_pdata {
int irq_base; int irq_base;
int gpio_base; int gpio_base;
int gpio_defaults[WM831X_GPIO_NUM];
struct wm831x_backlight_pdata *backlight; struct wm831x_backlight_pdata *backlight;
struct wm831x_backup_pdata *backup; struct wm831x_backup_pdata *backup;
struct wm831x_battery_pdata *battery; struct wm831x_battery_pdata *battery;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment