Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186925
b: refs/heads/master
c: f92e8f8
h: refs/heads/master
i:
  186923: 3877c86
v: v3
  • Loading branch information
Mark Brown authored and Samuel Ortiz committed Mar 7, 2010
1 parent 38959a7 commit 78c9411
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6b8274fafeec9b112cee5b6ced5f9189957c889f
refs/heads/master: f92e8f8144243a3651b2e350b706ea2d04931f8c
21 changes: 16 additions & 5 deletions trunk/drivers/gpio/wm831x-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ static int wm831x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
{
struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
struct wm831x *wm831x = wm831x_gpio->wm831x;
int val = WM831X_GPN_DIR;

if (wm831x->has_gpio_ena)
val |= WM831X_GPN_TRI;

return wm831x_set_bits(wm831x, WM831X_GPIO1_CONTROL + offset,
WM831X_GPN_DIR | WM831X_GPN_TRI,
WM831X_GPN_DIR);
WM831X_GPN_DIR | WM831X_GPN_TRI, val);
}

static int wm831x_gpio_get(struct gpio_chip *chip, unsigned offset)
Expand Down Expand Up @@ -74,10 +77,14 @@ static int wm831x_gpio_direction_out(struct gpio_chip *chip,
{
struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
struct wm831x *wm831x = wm831x_gpio->wm831x;
int val = 0;
int ret;

if (wm831x->has_gpio_ena)
val |= WM831X_GPN_TRI;

ret = wm831x_set_bits(wm831x, WM831X_GPIO1_CONTROL + offset,
WM831X_GPN_DIR | WM831X_GPN_TRI, 0);
WM831X_GPN_DIR | WM831X_GPN_TRI, val);
if (ret < 0)
return ret;

Expand All @@ -103,7 +110,7 @@ static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
{
struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
struct wm831x *wm831x = wm831x_gpio->wm831x;
int i;
int i, tristated;

for (i = 0; i < chip->ngpio; i++) {
int gpio = i + chip->base;
Expand Down Expand Up @@ -170,6 +177,10 @@ static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
break;
}

tristated = reg & WM831X_GPN_TRI;
if (wm831x->has_gpio_ena)
tristated = !tristated;

seq_printf(s, " %s %s %s %s%s\n"
" %s%s (0x%4x)\n",
reg & WM831X_GPN_DIR ? "in" : "out",
Expand All @@ -178,7 +189,7 @@ static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
powerdomain,
reg & WM831X_GPN_POL ? "" : " inverted",
reg & WM831X_GPN_OD ? "open-drain" : "CMOS",
reg & WM831X_GPN_TRI ? " tristated" : "",
tristated ? " tristated" : "",
reg);
}
}
Expand Down
15 changes: 15 additions & 0 deletions trunk/drivers/mfd/wm831x-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1449,18 +1449,33 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
case WM8310:
parent = WM8310;
wm831x->num_gpio = 16;
if (rev > 0) {
wm831x->has_gpio_ena = 1;
wm831x->has_cs_sts = 1;
}

dev_info(wm831x->dev, "WM8310 revision %c\n", 'A' + rev);
break;

case WM8311:
parent = WM8311;
wm831x->num_gpio = 16;
if (rev > 0) {
wm831x->has_gpio_ena = 1;
wm831x->has_cs_sts = 1;
}

dev_info(wm831x->dev, "WM8311 revision %c\n", 'A' + rev);
break;

case WM8312:
parent = WM8312;
wm831x->num_gpio = 16;
if (rev > 0) {
wm831x->has_gpio_ena = 1;
wm831x->has_cs_sts = 1;
}

dev_info(wm831x->dev, "WM8312 revision %c\n", 'A' + rev);
break;

Expand Down
4 changes: 4 additions & 0 deletions trunk/include/linux/mfd/wm831x/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ struct wm831x {
int irq_masks_cur[WM831X_NUM_IRQ_REGS]; /* Currently active value */
int irq_masks_cache[WM831X_NUM_IRQ_REGS]; /* Cached hardware value */

/* Chip revision based flags */
unsigned has_gpio_ena:1; /* Has GPIO enable bit */
unsigned has_cs_sts:1; /* Has current sink status bit */

int num_gpio;

struct mutex auxadc_lock;
Expand Down
4 changes: 4 additions & 0 deletions trunk/include/linux/mfd/wm831x/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#define WM831X_GPN_OD_MASK 0x0200 /* GPN_OD */
#define WM831X_GPN_OD_SHIFT 9 /* GPN_OD */
#define WM831X_GPN_OD_WIDTH 1 /* GPN_OD */
#define WM831X_GPN_ENA 0x0080 /* GPN_ENA */
#define WM831X_GPN_ENA_MASK 0x0080 /* GPN_ENA */
#define WM831X_GPN_ENA_SHIFT 7 /* GPN_ENA */
#define WM831X_GPN_ENA_WIDTH 1 /* GPN_ENA */
#define WM831X_GPN_TRI 0x0080 /* GPN_TRI */
#define WM831X_GPN_TRI_MASK 0x0080 /* GPN_TRI */
#define WM831X_GPN_TRI_SHIFT 7 /* GPN_TRI */
Expand Down

0 comments on commit 78c9411

Please sign in to comment.