]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
gpio: tegra: call pinctrl dirctions apis on direction input/output
authorLaxman Dewangan <ldewangan@nvidia.com>
Wed, 21 May 2014 14:09:35 +0000 (19:39 +0530)
committerMatthew Pedro <mapedro@nvidia.com>
Mon, 15 Sep 2014 17:24:38 +0000 (10:24 -0700)
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 <ldewangan@nvidia.com>
(cherry picked from commit c520a6048a942b5870f560979045c74659c8fe76)
Reviewed-on: http://git-master/r/#/c/415991/
Reviewed-on: http://git-master/r/498326
Reviewed-by: Winnie Hsu <whsu@nvidia.com>
Tested-by: Winnie Hsu <whsu@nvidia.com>
Reviewed-by: Matthew Pedro <mapedro@nvidia.com>
drivers/gpio/gpio-tegra.c

index 88524fe6bfd78206be2988c539c15293f8a71998..707e1a5a04b958ca9f818d7ee2441e3db5ef15f3 100644 (file)
@@ -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;
 }