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>
This commit is contained in:
parent
bfeffd1552
commit
e8dacf5957
|
@ -376,6 +376,16 @@ static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned int pin,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
|
||||
{
|
||||
struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip);
|
||||
u32 u;
|
||||
|
||||
regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
|
||||
|
||||
return !!(u & BIT(pin));
|
||||
}
|
||||
|
||||
static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
|
||||
{
|
||||
struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip);
|
||||
|
@ -1130,6 +1140,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
|
|||
mvchip->chip.parent = &pdev->dev;
|
||||
mvchip->chip.request = gpiochip_generic_request;
|
||||
mvchip->chip.free = gpiochip_generic_free;
|
||||
mvchip->chip.get_direction = mvebu_gpio_get_direction;
|
||||
mvchip->chip.direction_input = mvebu_gpio_direction_input;
|
||||
mvchip->chip.get = mvebu_gpio_get;
|
||||
mvchip->chip.direction_output = mvebu_gpio_direction_output;
|
||||
|
|
Loading…
Reference in New Issue