Merge tag 'usb-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
[platform/kernel/linux-rpi.git] / drivers / gpio / gpiolib-of.c
index 2c5dd13..219eb00 100644 (file)
@@ -466,6 +466,24 @@ static struct gpio_desc *of_find_arizona_gpio(struct device *dev,
        return of_get_named_gpiod_flags(dev->of_node, con_id, 0, of_flags);
 }
 
+static struct gpio_desc *of_find_usb_gpio(struct device *dev,
+                                         const char *con_id,
+                                         enum of_gpio_flags *of_flags)
+{
+       /*
+        * Currently this USB quirk is only for the Fairchild FUSB302 host which is using
+        * an undocumented DT GPIO line named "fcs,int_n" without the compulsory "-gpios"
+        * suffix.
+        */
+       if (!IS_ENABLED(CONFIG_TYPEC_FUSB302))
+               return ERR_PTR(-ENOENT);
+
+       if (!con_id || strcmp(con_id, "fcs,int_n"))
+               return ERR_PTR(-ENOENT);
+
+       return of_get_named_gpiod_flags(dev->of_node, con_id, 0, of_flags);
+}
+
 struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
                               unsigned int idx, unsigned long *flags)
 {
@@ -510,6 +528,9 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
        if (PTR_ERR(desc) == -ENOENT)
                desc = of_find_arizona_gpio(dev, con_id, &of_flags);
 
+       if (PTR_ERR(desc) == -ENOENT)
+               desc = of_find_usb_gpio(dev, con_id, &of_flags);
+
        if (IS_ERR(desc))
                return desc;