diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2016-04-28 15:00:18 +0200 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-06-07 09:35:15 +0200 |
commit | 8e293fb057d0f2d353bca11848b6526c56b0af09 (patch) | |
tree | f69bcc458d2c6ddeb0da2726fe625b34e2b2144b /drivers/gpio | |
parent | 353661dfe19512fa54c4662d4624dd946a2c8751 (diff) | |
download | linux-8e293fb057d0f2d353bca11848b6526c56b0af09.tar.bz2 |
gpio: stmpe: implement .get_direction()
This implements the .get_direction() callback for the STMPE
expander GPIO.
Cc: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-stmpe.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c index 6f7af28b8966..8480bd72661f 100644 --- a/drivers/gpio/gpio-stmpe.c +++ b/drivers/gpio/gpio-stmpe.c @@ -68,6 +68,22 @@ static void stmpe_gpio_set(struct gpio_chip *chip, unsigned offset, int val) stmpe_reg_write(stmpe, reg, mask); } +static int stmpe_gpio_get_direction(struct gpio_chip *chip, + unsigned offset) +{ + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); + struct stmpe *stmpe = stmpe_gpio->stmpe; + u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); + u8 mask = 1 << (offset % 8); + int ret; + + ret = stmpe_reg_read(stmpe, reg); + if (ret < 0) + return ret; + + return !(ret & mask); +} + static int stmpe_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { @@ -106,6 +122,7 @@ static int stmpe_gpio_request(struct gpio_chip *chip, unsigned offset) static struct gpio_chip template_chip = { .label = "stmpe", .owner = THIS_MODULE, + .get_direction = stmpe_gpio_get_direction, .direction_input = stmpe_gpio_direction_input, .get = stmpe_gpio_get, .direction_output = stmpe_gpio_direction_output, |