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>
This commit is contained in:
parent
7f40605a26
commit
fa3909320c
1 changed files with 13 additions and 0 deletions
|
@ -49,6 +49,7 @@ static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset);
|
||||||
static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip);
|
static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip);
|
||||||
static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val);
|
static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val);
|
||||||
static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset);
|
static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset);
|
||||||
|
static int at91_gpiolib_get_direction(struct gpio_chip *chip, unsigned offset);
|
||||||
static int at91_gpiolib_direction_output(struct gpio_chip *chip,
|
static int at91_gpiolib_direction_output(struct gpio_chip *chip,
|
||||||
unsigned offset, int val);
|
unsigned offset, int val);
|
||||||
static int at91_gpiolib_direction_input(struct gpio_chip *chip,
|
static 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);
|
||||||
.chip = { \
|
.chip = { \
|
||||||
.label = name, \
|
.label = name, \
|
||||||
.request = at91_gpiolib_request, \
|
.request = at91_gpiolib_request, \
|
||||||
|
.get_direction = at91_gpiolib_get_direction, \
|
||||||
.direction_input = at91_gpiolib_direction_input, \
|
.direction_input = at91_gpiolib_direction_input, \
|
||||||
.direction_output = at91_gpiolib_direction_output, \
|
.direction_output = at91_gpiolib_direction_output, \
|
||||||
.get = at91_gpiolib_get, \
|
.get = at91_gpiolib_get, \
|
||||||
|
@ -799,6 +801,17 @@ static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int at91_gpiolib_get_direction(struct gpio_chip *chip, unsigned offset)
|
||||||
|
{
|
||||||
|
struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
|
||||||
|
void __iomem *pio = at91_gpio->regbase;
|
||||||
|
unsigned mask = 1 << offset;
|
||||||
|
u32 osr;
|
||||||
|
|
||||||
|
osr = __raw_readl(pio + PIO_OSR);
|
||||||
|
return !(osr & mask);
|
||||||
|
}
|
||||||
|
|
||||||
static int at91_gpiolib_direction_input(struct gpio_chip *chip,
|
static int at91_gpiolib_direction_input(struct gpio_chip *chip,
|
||||||
unsigned offset)
|
unsigned offset)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue