0040-USB-DWC2-enable-usb-power-gpio.patch 995 B

1234567891011121314151617181920212223242526272829303132333435
  1. --- a/drivers/usb/dwc2/platform.c
  2. +++ b/drivers/usb/dwc2/platform.c
  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. #include <linux/usb/of.h>
  10. @@ -154,6 +155,7 @@ static int dwc2_driver_probe(struct plat
  11. struct resource *res;
  12. int retval;
  13. int irq;
  14. + int gpio_count;
  15. if (usb_disabled())
  16. return -ENODEV;
  17. @@ -173,6 +175,16 @@ static int dwc2_driver_probe(struct plat
  18. defparams.dma_desc_enable = 0;
  19. }
  20. + gpio_count = of_gpio_count(dev->dev.of_node);
  21. + while (gpio_count > 0) {
  22. + enum of_gpio_flags flags;
  23. + int gpio = of_get_gpio_flags(dev->dev.of_node, --gpio_count, &flags);
  24. + if (gpio_request(gpio, "usb"))
  25. + continue;
  26. + dev_info(&dev->dev, "requested GPIO %d\n", gpio);
  27. + gpio_direction_output(gpio, (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
  28. + }
  29. +
  30. hsotg = devm_kzalloc(&dev->dev, sizeof(*hsotg), GFP_KERNEL);
  31. if (!hsotg)
  32. return -ENOMEM;