Skip to content

Commit c65d1fd

Browse files
Russell Kinglinusw
authored andcommitted
gpio: sa1100: implement get_direction method
Allow gpiolib to read back the current IO direction configuration by implementing the .get_direction callback. This, in part, allows debugfs to report the complete true hardware state rather than the software state. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 07242b2 commit c65d1fd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/gpio/gpio-sa1100.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
5252
writel_relaxed(BIT(offset), sa1100_gpio_chip(chip)->membase + reg);
5353
}
5454

55+
static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset)
56+
{
57+
void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR;
58+
59+
return !(readl_relaxed(gpdr) & BIT(offset));
60+
}
61+
5562
static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
5663
{
5764
void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR;
@@ -85,6 +92,7 @@ static int sa1100_to_irq(struct gpio_chip *chip, unsigned offset)
8592
static struct sa1100_gpio_chip sa1100_gpio_chip = {
8693
.chip = {
8794
.label = "gpio",
95+
.get_direction = sa1100_get_direction,
8896
.direction_input = sa1100_direction_input,
8997
.direction_output = sa1100_direction_output,
9098
.set = sa1100_gpio_set,

0 commit comments

Comments
 (0)