]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
gpio: of: Add support for making pin in non-GPIO mode from DT
authorLaxman Dewangan <ldewangan@nvidia.com>
Thu, 9 Mar 2017 13:04:21 +0000 (18:34 +0530)
committermobile promotions <svcmobile_promotions@nvidia.com>
Wed, 31 May 2017 04:16:41 +0000 (21:16 -0700)
Add support to make the pin to make as non-GPIO mode from DT.
This will help to make the pin in function mode if bootloader
made it to GPIO mode.

Bug 200305703

Change-Id: I8cfc31b551bb16d1eac7c1f8d280655a1f028cb1
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/1317924
(cherry picked from commit 6ce5123fd9cfbbb8cac92ec8f8b13cbc206af3c5)
Signed-off-by: Shreshtha SAHU <ssahu@nvidia.com>
Reviewed-on: http://git-master/r/1491906

drivers/gpio/gpiolib-of.c

index 9e47a681c9b359b37ccdcdc0c82af78daf1bd246..3d1c4df66401aa913fd6d740f10d56c1f8067d6a 100644 (file)
@@ -198,6 +198,8 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
                *dflags |= GPIOD_OUT_LOW;
        else if (of_property_read_bool(np, "output-high"))
                *dflags |= GPIOD_OUT_HIGH;
+       else if (of_property_read_bool(np, "function"))
+               *dflags = 0;
        else {
                pr_warn("GPIO line %d (%s): no hogging state specified, bailing out\n",
                        desc_to_gpio(gg_data.out_gpio), np->name);
@@ -259,6 +261,16 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
                        if (IS_ERR(desc))
                                continue;
 
+                       /* dflags is 0 for making pin in non-gpio mode */
+                       if (!dflags) {
+                               ret = chip->request(chip,
+                                                   gpio_chip_hwgpio(desc));
+                               if (!ret)
+                                       chip->free(chip,
+                                                  gpio_chip_hwgpio(desc));
+                               continue;
+                       }
+
                        ret = gpiod_hog(desc, name, lflags, dflags);
                        if (ret < 0)
                                return ret;