Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: at91: implement get_direction

This is needed for gpiod_get_direction().
Otherwise, it returns -EINVAL.

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Richard Genoud and committed by
Linus Walleij
8af584b8 0c002ef8

+12
+12
drivers/pinctrl/pinctrl-at91.c
··· 1137 1137 pinctrl_free_gpio(gpio); 1138 1138 } 1139 1139 1140 + static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset) 1141 + { 1142 + struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); 1143 + void __iomem *pio = at91_gpio->regbase; 1144 + unsigned mask = 1 << offset; 1145 + u32 osr; 1146 + 1147 + osr = readl_relaxed(pio + PIO_OSR); 1148 + return !(osr & mask); 1149 + } 1150 + 1140 1151 static int at91_gpio_direction_input(struct gpio_chip *chip, unsigned offset) 1141 1152 { 1142 1153 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); ··· 1581 1570 static struct gpio_chip at91_gpio_template = { 1582 1571 .request = at91_gpio_request, 1583 1572 .free = at91_gpio_free, 1573 + .get_direction = at91_gpio_get_direction, 1584 1574 .direction_input = at91_gpio_direction_input, 1585 1575 .get = at91_gpio_get, 1586 1576 .direction_output = at91_gpio_direction_output,