aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/gpio.c
diff options
context:
space:
mode:
authorRichard Genoud <richard.genoud@gmail.com>2014-05-13 14:20:42 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-28 15:44:32 -0400
commitfa3909320c00286c6b9d6ade16bc6d44f940379c (patch)
tree0135d87214615392a1c3bf9dcba76011e96cb47f /arch/arm/mach-at91/gpio.c
parent7f40605a2661d17275a1aa245498f4a12ad9ca9a (diff)
ARM: at91: gpio: implement get_direction
This is needed for gpiod_get_direction(). Otherwise, it returns -EINVAL. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/arm/mach-at91/gpio.c')
-rw-r--r--arch/arm/mach-at91/gpio.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index a5afcf76550e..afbe34027e62 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -49,6 +49,7 @@ static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset);
49static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip); 49static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip);
50static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val); 50static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val);
51static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset); 51static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset);
52static int at91_gpiolib_get_direction(struct gpio_chip *chip, unsigned offset);
52static int at91_gpiolib_direction_output(struct gpio_chip *chip, 53static int at91_gpiolib_direction_output(struct gpio_chip *chip,
53 unsigned offset, int val); 54 unsigned offset, int val);
54static int at91_gpiolib_direction_input(struct gpio_chip *chip, 55static int at91_gpiolib_direction_input(struct gpio_chip *chip,
@@ -60,6 +61,7 @@ static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset);
60 .chip = { \ 61 .chip = { \
61 .label = name, \ 62 .label = name, \
62 .request = at91_gpiolib_request, \ 63 .request = at91_gpiolib_request, \
64 .get_direction = at91_gpiolib_get_direction, \
63 .direction_input = at91_gpiolib_direction_input, \ 65 .direction_input = at91_gpiolib_direction_input, \
64 .direction_output = at91_gpiolib_direction_output, \ 66 .direction_output = at91_gpiolib_direction_output, \
65 .get = at91_gpiolib_get, \ 67 .get = at91_gpiolib_get, \
@@ -799,6 +801,17 @@ static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset)
799 return 0; 801 return 0;
800} 802}
801 803
804static int at91_gpiolib_get_direction(struct gpio_chip *chip, unsigned offset)
805{
806 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
807 void __iomem *pio = at91_gpio->regbase;
808 unsigned mask = 1 << offset;
809 u32 osr;
810
811 osr = __raw_readl(pio + PIO_OSR);
812 return !(osr & mask);
813}
814
802static int at91_gpiolib_direction_input(struct gpio_chip *chip, 815static int at91_gpiolib_direction_input(struct gpio_chip *chip,
803 unsigned offset) 816 unsigned offset)
804{ 817{