Commit 0b14c22ea1e0226d894df76176971d06e8886aa7

Authored by Mark Brown
Committed by Samuel Ortiz
1 parent 8997619a04

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: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

Showing 2 changed files with 16 additions and 1 deletions Side-by-side Diff

drivers/mfd/wm831x-core.c
... ... @@ -1442,7 +1442,7 @@
1442 1442 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
1443 1443 int rev;
1444 1444 enum wm831x_parent parent;
1445   - int ret;
  1445 + int ret, i;
1446 1446  
1447 1447 mutex_init(&wm831x->io_lock);
1448 1448 mutex_init(&wm831x->key_lock);
... ... @@ -1578,6 +1578,17 @@
1578 1578 if (ret != 0) {
1579 1579 dev_err(wm831x->dev, "pre_init() failed: %d\n", ret);
1580 1580 goto err;
  1581 + }
  1582 + }
  1583 +
  1584 + if (pdata) {
  1585 + for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
  1586 + if (!pdata->gpio_defaults[i])
  1587 + continue;
  1588 +
  1589 + wm831x_reg_write(wm831x,
  1590 + WM831X_GPIO1_CONTROL + i,
  1591 + pdata->gpio_defaults[i] & 0xffff);
1581 1592 }
1582 1593 }
1583 1594  
include/linux/mfd/wm831x/pdata.h
... ... @@ -105,6 +105,9 @@
105 105 #define WM831X_MAX_LDO 11
106 106 #define WM831X_MAX_ISINK 2
107 107  
  108 +#define WM831X_GPIO_CONFIGURE 0x10000
  109 +#define WM831X_GPIO_NUM 16
  110 +
108 111 struct wm831x_pdata {
109 112 /** Used to distinguish multiple WM831x chips */
110 113 int wm831x_num;
... ... @@ -119,6 +122,7 @@
119 122  
120 123 int irq_base;
121 124 int gpio_base;
  125 + int gpio_defaults[WM831X_GPIO_NUM];
122 126 struct wm831x_backlight_pdata *backlight;
123 127 struct wm831x_backup_pdata *backup;
124 128 struct wm831x_battery_pdata *battery;