0040-USB-DWC2-enable-usb-power-gpio.patch 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. --- a/drivers/usb/dwc2/platform.c
  2. +++ b/drivers/usb/dwc2/platform.c
  3. @@ -42,6 +42,7 @@
  4. #include <linux/dma-mapping.h>
  5. #include <linux/of_device.h>
  6. #include <linux/mutex.h>
  7. +#include <linux/of_gpio.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/phy/phy.h>
  10. #include <linux/platform_data/s3c-hsotg.h>
  11. @@ -336,6 +337,7 @@ static int dwc2_driver_probe(struct plat
  12. struct resource *res;
  13. int retval;
  14. int irq;
  15. + int gpio_count;
  16. match = of_match_device(dwc2_of_match_table, &dev->dev);
  17. if (match && match->data) {
  18. @@ -352,6 +354,16 @@ static int dwc2_driver_probe(struct plat
  19. defparams.dma_desc_enable = 0;
  20. }
  21. + gpio_count = of_gpio_count(dev->dev.of_node);
  22. + while (gpio_count > 0) {
  23. + enum of_gpio_flags flags;
  24. + int gpio = of_get_gpio_flags(dev->dev.of_node, --gpio_count, &flags);
  25. + if (gpio_request(gpio, "usb"))
  26. + continue;
  27. + dev_info(&dev->dev, "requested GPIO %d\n", gpio);
  28. + gpio_direction_output(gpio, (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
  29. + }
  30. +
  31. hsotg = devm_kzalloc(&dev->dev, sizeof(*hsotg), GFP_KERNEL);
  32. if (!hsotg)
  33. return -ENOMEM;