Skip to content

Commit 9370084

Browse files
yegorichlinusw
authored andcommitted
gpio: omap: implement get_direction
This patch implements gpio_chip's get_direction() routine, that lets other drivers get particular GPIOs direction using struct gpio_desc. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Acked-by: Javier Martinez Canillas <javier@dowhile0.org> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Tested-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Kevin Hilman <khilman@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 47a95fe commit 9370084

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/gpio/gpio-omap.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/of_device.h>
2727
#include <linux/irqchip/chained_irq.h>
2828
#include <linux/gpio.h>
29+
#include <linux/bitops.h>
2930
#include <linux/platform_data/gpio-omap.h>
3031

3132
#define OFF_MODE 1
@@ -927,6 +928,21 @@ static inline void mpuio_init(struct gpio_bank *bank)
927928

928929
/*---------------------------------------------------------------------*/
929930

931+
static int gpio_get_direction(struct gpio_chip *chip, unsigned offset)
932+
{
933+
struct gpio_bank *bank;
934+
unsigned long flags;
935+
void __iomem *reg;
936+
int dir;
937+
938+
bank = container_of(chip, struct gpio_bank, chip);
939+
reg = bank->base + bank->regs->direction;
940+
spin_lock_irqsave(&bank->lock, flags);
941+
dir = !!(readl_relaxed(reg) & BIT(offset));
942+
spin_unlock_irqrestore(&bank->lock, flags);
943+
return dir;
944+
}
945+
930946
static int gpio_input(struct gpio_chip *chip, unsigned offset)
931947
{
932948
struct gpio_bank *bank;
@@ -1085,6 +1101,7 @@ static int omap_gpio_chip_init(struct gpio_bank *bank)
10851101
*/
10861102
bank->chip.request = omap_gpio_request;
10871103
bank->chip.free = omap_gpio_free;
1104+
bank->chip.get_direction = gpio_get_direction;
10881105
bank->chip.direction_input = gpio_input;
10891106
bank->chip.get = gpio_get;
10901107
bank->chip.direction_output = gpio_output;

0 commit comments

Comments
 (0)