diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2018-06-27 10:47:28 +0200 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2018-07-02 16:00:49 +0200 |
commit | f9e03b0ef10ce5040714783a09cf12df26bcb3d7 (patch) | |
tree | 12256ec748c0b9e8d6a7af063fc32b453768f1e9 /drivers/gpio/gpio-sch311x.c | |
parent | 30467c19e456ac3503164248131ec0ea57852abf (diff) |
gpio: sch311x: Implement .get_direction()
It's pretty simple to implement the .get_direction() for this
chip, so let's just do it.
Cc: Bruno Randolf <br1@einfach.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-sch311x.c')
-rw-r--r-- | drivers/gpio/gpio-sch311x.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c index 8bc2bf45e5da..ed64f7fa23b1 100644 --- a/drivers/gpio/gpio-sch311x.c +++ b/drivers/gpio/gpio-sch311x.c @@ -221,6 +221,18 @@ static int sch311x_gpio_direction_out(struct gpio_chip *chip, unsigned offset, return 0; } +static int sch311x_gpio_get_direction(struct gpio_chip *chip, unsigned offset) +{ + struct sch311x_gpio_block *block = gpiochip_get_data(chip); + unsigned char data; + + spin_lock(&block->lock); + data = inb(block->runtime_reg + block->config_regs[offset]); + spin_unlock(&block->lock); + + return !!(data & SCH311X_GPIO_CONF_IN); +} + static int sch311x_gpio_probe(struct platform_device *pdev) { struct sch311x_pdev_data *pdata = dev_get_platdata(&pdev->dev); @@ -253,6 +265,7 @@ static int sch311x_gpio_probe(struct platform_device *pdev) block->chip.free = sch311x_gpio_free; block->chip.direction_input = sch311x_gpio_direction_in; block->chip.direction_output = sch311x_gpio_direction_out; + block->chip.get_direction = sch311x_gpio_get_direction; block->chip.get = sch311x_gpio_get; block->chip.set = sch311x_gpio_set; block->chip.ngpio = 8; |