lantiq: Configure gpio power output pin when initializing dwc2 usb
[openwrt/svn-archive/archive.git] / target / linux / lantiq / patches-3.18 / 0040-USB-DWC2-enable-usb-power-gpio.patch
1 --- a/drivers/usb/dwc2/platform.c 2015-02-06 16:53:48.000000000 +0200
2 +++ b/drivers/usb/dwc2/platform.c 2015-02-09 19:22:41.974089626 +0200
3 @@ -40,6 +40,7 @@
4 #include <linux/device.h>
5 #include <linux/dma-mapping.h>
6 #include <linux/of_device.h>
7 +#include <linux/of_gpio.h>
8 #include <linux/platform_device.h>
9
10 #include <linux/usb/of.h>
11 @@ -154,6 +155,7 @@
12 struct resource *res;
13 int retval;
14 int irq;
15 + int gpio_count;
16
17 if (usb_disabled())
18 return -ENODEV;
19 @@ -173,6 +175,16 @@
20 defparams.dma_desc_enable = 0;
21 }
22
23 + gpio_count = of_gpio_count(dev->dev.of_node);
24 + while (gpio_count > 0) {
25 + enum of_gpio_flags flags;
26 + int gpio = of_get_gpio_flags(dev->dev.of_node, --gpio_count, &flags);
27 + if (gpio_request(gpio, "usb"))
28 + continue;
29 + dev_info(&dev->dev, "requested GPIO %d\n", gpio);
30 + gpio_direction_output(gpio, (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
31 + }
32 +
33 hsotg = devm_kzalloc(&dev->dev, sizeof(*hsotg), GFP_KERNEL);
34 if (!hsotg)
35 return -ENOMEM;