aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpio/wm831x-gpio.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/gpio/wm831x-gpio.c b/drivers/gpio/wm831x-gpio.c
index b4468b616890..c5a00f7a7bf0 100644
--- a/drivers/gpio/wm831x-gpio.c
+++ b/drivers/gpio/wm831x-gpio.c
@@ -60,23 +60,31 @@ static int wm831x_gpio_get(struct gpio_chip *chip, unsigned offset)
60 return 0; 60 return 0;
61} 61}
62 62
63static int wm831x_gpio_direction_out(struct gpio_chip *chip, 63static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
64 unsigned offset, int value)
65{ 64{
66 struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); 65 struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
67 struct wm831x *wm831x = wm831x_gpio->wm831x; 66 struct wm831x *wm831x = wm831x_gpio->wm831x;
68 67
69 return wm831x_set_bits(wm831x, WM831X_GPIO1_CONTROL + offset, 68 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, 1 << offset,
70 WM831X_GPN_DIR | WM831X_GPN_TRI, 0); 69 value << offset);
71} 70}
72 71
73static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 72static int wm831x_gpio_direction_out(struct gpio_chip *chip,
73 unsigned offset, int value)
74{ 74{
75 struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); 75 struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
76 struct wm831x *wm831x = wm831x_gpio->wm831x; 76 struct wm831x *wm831x = wm831x_gpio->wm831x;
77 int ret;
77 78
78 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, 1 << offset, 79 ret = wm831x_set_bits(wm831x, WM831X_GPIO1_CONTROL + offset,
79 value << offset); 80 WM831X_GPN_DIR | WM831X_GPN_TRI, 0);
81 if (ret < 0)
82 return ret;
83
84 /* Can only set GPIO state once it's in output mode */
85 wm831x_gpio_set(chip, offset, value);
86
87 return 0;
80} 88}
81 89
82static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) 90static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset)