185-USB-bcma-add-support-for-controlling-bus-power-throu.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. From f3cf44a313b3687efd55ba091558e20a4d218c31 Mon Sep 17 00:00:00 2001
  2. From: Hauke Mehrtens <hauke@hauke-m.de>
  3. Date: Thu, 11 Jun 2015 22:57:40 +0200
  4. Subject: [PATCH] USB: bcma: add support for controlling bus power through GPIO
  5. On some boards a GPIO is needed to activate USB controller. Make it
  6. possible to specify such a GPIO in device tree.
  7. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  8. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  9. ---
  10. drivers/usb/host/bcma-hcd.c | 24 ++++++++++++++++++++++++
  11. 1 file changed, 24 insertions(+)
  12. --- a/drivers/usb/host/bcma-hcd.c
  13. +++ b/drivers/usb/host/bcma-hcd.c
  14. @@ -24,6 +24,8 @@
  15. #include <linux/platform_device.h>
  16. #include <linux/module.h>
  17. #include <linux/slab.h>
  18. +#include <linux/of.h>
  19. +#include <linux/of_gpio.h>
  20. #include <linux/usb/ehci_pdriver.h>
  21. #include <linux/usb/ohci_pdriver.h>
  22. @@ -224,6 +226,23 @@ static void bcma_hcd_init_chip_arm(struc
  23. }
  24. }
  25. +static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
  26. +{
  27. + int gpio;
  28. +
  29. + gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
  30. + if (!gpio_is_valid(gpio))
  31. + return;
  32. +
  33. + if (val) {
  34. + gpio_request(gpio, "bcma-hcd-gpio");
  35. + gpio_set_value(gpio, 1);
  36. + } else {
  37. + gpio_set_value(gpio, 0);
  38. + gpio_free(gpio);
  39. + }
  40. +}
  41. +
  42. static const struct usb_ehci_pdata ehci_pdata = {
  43. };
  44. @@ -295,6 +314,8 @@ static int bcma_hcd_probe(struct bcma_de
  45. if (!usb_dev)
  46. return -ENOMEM;
  47. + bcma_hci_platform_power_gpio(dev, true);
  48. +
  49. switch (dev->id.id) {
  50. case BCMA_CORE_NS_USB20:
  51. bcma_hcd_init_chip_arm(dev);
  52. @@ -347,6 +368,7 @@ static void bcma_hcd_remove(struct bcma_
  53. static void bcma_hcd_shutdown(struct bcma_device *dev)
  54. {
  55. + bcma_hci_platform_power_gpio(dev, false);
  56. bcma_core_disable(dev, 0);
  57. }
  58. @@ -354,6 +376,7 @@ static void bcma_hcd_shutdown(struct bcm
  59. static int bcma_hcd_suspend(struct bcma_device *dev)
  60. {
  61. + bcma_hci_platform_power_gpio(dev, false);
  62. bcma_core_disable(dev, 0);
  63. return 0;
  64. @@ -361,6 +384,7 @@ static int bcma_hcd_suspend(struct bcma_
  65. static int bcma_hcd_resume(struct bcma_device *dev)
  66. {
  67. + bcma_hci_platform_power_gpio(dev, true);
  68. bcma_core_enable(dev, 0);
  69. return 0;