diff options
author | plr.vincent@gmail.com <plr.vincent@gmail.com> | 2016-06-06 00:56:08 +0000 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-06-14 09:10:18 +0200 |
commit | 107cdd2d69d10a3338cb0f863364b44985eaaf64 (patch) | |
tree | b5abebfb800805ae5c233ac1a03fc012246575e3 /drivers/gpio/gpio-f7188x.c | |
parent | 6b891a2647337554f4b5cdff98d843f5e25b70af (diff) | |
download | op-kernel-dev-107cdd2d69d10a3338cb0f863364b44985eaaf64.zip op-kernel-dev-107cdd2d69d10a3338cb0f863364b44985eaaf64.tar.gz |
gpio: f7188x: Implement get_direction.
Avoids gpiolib assumptions on initial pin direction, allowing user to observe
power-on settings.
Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-f7188x.c')
-rw-r--r-- | drivers/gpio/gpio-f7188x.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c index 05aa538..600be84 100644 --- a/drivers/gpio/gpio-f7188x.c +++ b/drivers/gpio/gpio-f7188x.c @@ -125,6 +125,7 @@ static inline void superio_exit(int base) * GPIO chip. */ +static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset); static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset); static int f7188x_gpio_get(struct gpio_chip *chip, unsigned offset); static int f7188x_gpio_direction_out(struct gpio_chip *chip, @@ -139,6 +140,7 @@ static int f7188x_gpio_set_single_ended(struct gpio_chip *gc, .chip = { \ .label = DRVNAME, \ .owner = THIS_MODULE, \ + .get_direction = f7188x_gpio_get_direction, \ .direction_input = f7188x_gpio_direction_in, \ .get = f7188x_gpio_get, \ .direction_output = f7188x_gpio_direction_out, \ @@ -209,6 +211,26 @@ static struct f7188x_gpio_bank f81866_gpio_bank[] = { F7188X_GPIO_BANK(80, 8, 0x88), }; +static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset) +{ + int err; + struct f7188x_gpio_bank *bank = + container_of(chip, struct f7188x_gpio_bank, chip); + struct f7188x_sio *sio = bank->data->sio; + u8 dir; + + err = superio_enter(sio->addr); + if (err) + return err; + superio_select(sio->addr, SIO_LD_GPIO); + + dir = superio_inb(sio->addr, gpio_dir(bank->regbase)); + + superio_exit(sio->addr); + + return !(dir & 1 << offset); +} + static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { int err; |