From 3edac78ac13b471244e6053c85088916b1d9ee0b Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Wed, 21 May 2014 19:39:35 +0530 Subject: [PATCH] gpio: tegra: call pinctrl dirctions apis on direction input/output Set the pins in different direction based on client request from gpio. This will help to non-tristate the pin on gpio output mode or enable input on gpio input mode without any explicit condition. Bug 200033491 Change-Id: I074451e344bfd8465aceb39c1091809da4f58f58 Signed-off-by: Laxman Dewangan (cherry picked from commit c520a6048a942b5870f560979045c74659c8fe76) Reviewed-on: http://git-master/r/#/c/415991/ Reviewed-on: http://git-master/r/498326 Reviewed-by: Winnie Hsu Tested-by: Winnie Hsu Reviewed-by: Matthew Pedro --- drivers/gpio/gpio-tegra.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index 88524fe6bfd..707e1a5a04b 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c @@ -154,12 +154,12 @@ void tegra_gpio_init_configure(unsigned gpio, bool is_input, int value) static int tegra_gpio_request(struct gpio_chip *chip, unsigned offset) { - return pinctrl_request_gpio(offset); + return pinctrl_request_gpio(chip->base + offset); } static void tegra_gpio_free(struct gpio_chip *chip, unsigned offset) { - pinctrl_free_gpio(offset); + pinctrl_free_gpio(chip->base + offset); tegra_gpio_disable(offset); } @@ -180,17 +180,33 @@ static int tegra_gpio_get(struct gpio_chip *chip, unsigned offset) static int tegra_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { + int ret; + tegra_gpio_mask_write(GPIO_MSK_OE(offset), offset, 0); tegra_gpio_enable(offset); + + ret = pinctrl_gpio_direction_input(chip->base + offset); + if (ret < 0) + dev_err(chip->dev, + "Tegra gpio input: pinctrl input failed: %d\n", ret); + return 0; } static int tegra_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { + int ret; + tegra_gpio_set(chip, offset, value); tegra_gpio_mask_write(GPIO_MSK_OE(offset), offset, 1); tegra_gpio_enable(offset); + + ret = pinctrl_gpio_direction_output(chip->base + offset); + if (ret < 0) + dev_err(chip->dev, + "Tegra gpio output: pinctrl output failed: %d\n", ret); + return 0; } -- 2.39.2