Commit 20b3d2a7 authored by Stefan Wahren's avatar Stefan Wahren Committed by Linus Walleij

pinctrl: bcm2835: Implement get_direction callback

Implement gpio_chip's get_direction() callback, that lets other
drivers get particular GPIOs direction using gpiod_get_direction().
Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: default avatarEric Anholt <eric@anholt.net>
Reviewed-by: default avatarStephen Warren <swarren@wwwdotorg.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 42a44402
...@@ -342,6 +342,18 @@ static int bcm2835_gpio_get(struct gpio_chip *chip, unsigned offset) ...@@ -342,6 +342,18 @@ static int bcm2835_gpio_get(struct gpio_chip *chip, unsigned offset)
return bcm2835_gpio_get_bit(pc, GPLEV0, offset); return bcm2835_gpio_get_bit(pc, GPLEV0, offset);
} }
static int bcm2835_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
{
struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset);
/* Alternative function doesn't clearly provide a direction */
if (fsel > BCM2835_FSEL_GPIO_OUT)
return -EINVAL;
return (fsel == BCM2835_FSEL_GPIO_IN);
}
static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{ {
struct bcm2835_pinctrl *pc = gpiochip_get_data(chip); struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
...@@ -370,6 +382,7 @@ static struct gpio_chip bcm2835_gpio_chip = { ...@@ -370,6 +382,7 @@ static struct gpio_chip bcm2835_gpio_chip = {
.free = gpiochip_generic_free, .free = gpiochip_generic_free,
.direction_input = bcm2835_gpio_direction_input, .direction_input = bcm2835_gpio_direction_input,
.direction_output = bcm2835_gpio_direction_output, .direction_output = bcm2835_gpio_direction_output,
.get_direction = bcm2835_gpio_get_direction,
.get = bcm2835_gpio_get, .get = bcm2835_gpio_get,
.set = bcm2835_gpio_set, .set = bcm2835_gpio_set,
.to_irq = bcm2835_gpio_to_irq, .to_irq = bcm2835_gpio_to_irq,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment