diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2016-04-29 12:25:23 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-04-30 07:15:10 -0400 |
commit | f002d07c56c7b7007328e8fff2adf04db1c81e90 (patch) | |
tree | 3a9b90c61cf73f64934a4eee57d307aed179aebd | |
parent | 72d3200061776264941be1b5a9bb8e926b3b30a5 (diff) |
gpio: tegra: Implement gpio_get_direction callback
Implement gpio_get_direction() callback for Tegra GPIO.
The direction is only valid if the pin is configured as
GPIO. If pin is not configured in GPIO mode then this
function return error.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-tegra.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index b3ddd922290d..ec891a27952f 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c | |||
@@ -191,6 +191,21 @@ static int tegra_gpio_direction_output(struct gpio_chip *chip, unsigned offset, | |||
191 | return 0; | 191 | return 0; |
192 | } | 192 | } |
193 | 193 | ||
194 | static int tegra_gpio_get_direction(struct gpio_chip *chip, unsigned offset) | ||
195 | { | ||
196 | struct tegra_gpio_info *tgi = gpiochip_get_data(chip); | ||
197 | u32 pin_mask = BIT(GPIO_BIT(offset)); | ||
198 | u32 cnf, oe; | ||
199 | |||
200 | cnf = tegra_gpio_readl(tgi, GPIO_CNF(tgi, offset)); | ||
201 | if (!(cnf & pin_mask)) | ||
202 | return -EINVAL; | ||
203 | |||
204 | oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset)); | ||
205 | |||
206 | return (oe & pin_mask) ? GPIOF_DIR_OUT : GPIOF_DIR_IN; | ||
207 | } | ||
208 | |||
194 | static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset, | 209 | static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset, |
195 | unsigned int debounce) | 210 | unsigned int debounce) |
196 | { | 211 | { |
@@ -575,6 +590,7 @@ static int tegra_gpio_probe(struct platform_device *pdev) | |||
575 | tgi->gc.get = tegra_gpio_get; | 590 | tgi->gc.get = tegra_gpio_get; |
576 | tgi->gc.direction_output = tegra_gpio_direction_output; | 591 | tgi->gc.direction_output = tegra_gpio_direction_output; |
577 | tgi->gc.set = tegra_gpio_set; | 592 | tgi->gc.set = tegra_gpio_set; |
593 | tgi->gc.get_direction = tegra_gpio_get_direction; | ||
578 | tgi->gc.to_irq = tegra_gpio_to_irq; | 594 | tgi->gc.to_irq = tegra_gpio_to_irq; |
579 | tgi->gc.base = 0; | 595 | tgi->gc.base = 0; |
580 | tgi->gc.ngpio = tgi->bank_count * 32; | 596 | tgi->gc.ngpio = tgi->bank_count * 32; |