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

gpio: mvebu: implement get_direction

struct gpio_chip documentation recommends to always implement this
callback function.

A more concrete motivation is to be able (in combination with
GPIOD_ASIS) to detect whether the bootloader has changed the state of a
GPIO signal.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Baruch Siach and committed by
Linus Walleij
e8dacf59 bfeffd15

+11
+11
drivers/gpio/gpio-mvebu.c
··· 376 376 return 0; 377 377 } 378 378 379 + static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin) 380 + { 381 + struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); 382 + u32 u; 383 + 384 + regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u); 385 + 386 + return !!(u & BIT(pin)); 387 + } 388 + 379 389 static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin) 380 390 { 381 391 struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); ··· 1140 1130 mvchip->chip.parent = &pdev->dev; 1141 1131 mvchip->chip.request = gpiochip_generic_request; 1142 1132 mvchip->chip.free = gpiochip_generic_free; 1133 + mvchip->chip.get_direction = mvebu_gpio_get_direction; 1143 1134 mvchip->chip.direction_input = mvebu_gpio_direction_input; 1144 1135 mvchip->chip.get = mvebu_gpio_get; 1145 1136 mvchip->chip.direction_output = mvebu_gpio_direction_output;