summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib-of.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2020-04-15 21:24:48 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-04-16 15:31:43 +0200
commit6e24826d2c51a0e005ecf3ed74ea48688fca0306 (patch)
tree7f2dcab387726f0d129284b53519ac33a9d98e9f /drivers/gpio/gpiolib-of.c
parentusb: cdns3: change dev_info to dev_dbg for debug message (diff)
downloadlinux-6e24826d2c51a0e005ecf3ed74ea48688fca0306.tar.xz
linux-6e24826d2c51a0e005ecf3ed74ea48688fca0306.zip
usb: fusb302: Convert to use GPIO descriptors
This converts the FUSB302 driver to use GPIO descriptors. The conversion to descriptors per se is pretty straight-forward. In the process I discovered that: 1. The driver uses a completely undocumented device tree binding for the interrupt GPIO line, "fcs,int_n". Ooops. 2. The undocumented binding, presumably since it has not seen review, is just "fcs,int_n", lacking the compulsory "-gpios" suffix and also something that is not a good name because the "_n" implies the line is inverted which is something we handle with flags in the device tree. Ooops. 3. Possibly the driver should not be requesting the line as a GPIO and request the corresponding interrupt line by open coding, the GPIO chip is very likely doubleing as an IRQ controller and can probably provide an interrupt directly for this line with interrupts-extended = <&gpio0 ...>; 4. Possibly the IRQ should just be tagged on the I2C client node in the device tree like apparently ACPI does, as it overrides this IRQ with client->irq if that exists. But now it is too late to do much about that and as I can see this is used like this in the Pinebook which is a shipping product so let'a just contain the mess and move on. The property currently appears in: arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts Create a quirk in the GPIO OF library to allow this property specifically to be specified without the "-gpios" suffix, we have other such bindings already. Cc: Tobias Schramm <t.schramm@manjaro.org> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Cc: Yueyao Zhu <yueyao@google.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: devicetree@vger.kernel.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20200415192448.305257-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/gpio/gpiolib-of.c')
-rw-r--r--drivers/gpio/gpiolib-of.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index ccc449df3792..20c2c428168e 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -460,6 +460,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)
{
@@ -504,6 +522,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;