Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Laxman Dewangan and committed by
Linus Walleij
f002d07c 72d32000

+16
+16
drivers/gpio/gpio-tegra.c
··· 191 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 209 static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset, 195 210 unsigned int debounce) 196 211 { ··· 590 575 tgi->gc.get = tegra_gpio_get; 591 576 tgi->gc.direction_output = tegra_gpio_direction_output; 592 577 tgi->gc.set = tegra_gpio_set; 578 + tgi->gc.get_direction = tegra_gpio_get_direction; 593 579 tgi->gc.to_irq = tegra_gpio_to_irq; 594 580 tgi->gc.base = 0; 595 581 tgi->gc.ngpio = tgi->bank_count * 32;