082-06-USB-bcma-add-support-for-controlling-bus-power-throu.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From eb4861c3cef7f745df0d2a26b0f4287da0190424 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@openwrt.org>
  8. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  9. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  10. ---
  11. drivers/usb/host/bcma-hcd.c | 24 ++++++++++++++++++++++++
  12. 1 file changed, 24 insertions(+)
  13. --- a/drivers/usb/host/bcma-hcd.c
  14. +++ b/drivers/usb/host/bcma-hcd.c
  15. @@ -24,6 +24,8 @@
  16. #include <linux/platform_device.h>
  17. #include <linux/module.h>
  18. #include <linux/slab.h>
  19. +#include <linux/of.h>
  20. +#include <linux/of_gpio.h>
  21. #include <linux/usb/ehci_pdriver.h>
  22. #include <linux/usb/ohci_pdriver.h>
  23. @@ -224,6 +226,23 @@ static void bcma_hcd_init_chip_arm(struc
  24. }
  25. }
  26. +static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
  27. +{
  28. + int gpio;
  29. +
  30. + gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
  31. + if (!gpio_is_valid(gpio))
  32. + return;
  33. +
  34. + if (val) {
  35. + gpio_request(gpio, "bcma-hcd-gpio");
  36. + gpio_set_value(gpio, 1);
  37. + } else {
  38. + gpio_set_value(gpio, 0);
  39. + gpio_free(gpio);
  40. + }
  41. +}
  42. +
  43. static const struct usb_ehci_pdata ehci_pdata = {
  44. };
  45. @@ -295,6 +314,8 @@ static int bcma_hcd_probe(struct bcma_de
  46. if (!usb_dev)
  47. return -ENOMEM;
  48. + bcma_hci_platform_power_gpio(dev, true);
  49. +
  50. switch (dev->id.id) {
  51. case BCMA_CORE_NS_USB20:
  52. bcma_hcd_init_chip_arm(dev);
  53. @@ -347,6 +368,7 @@ static void bcma_hcd_remove(struct bcma_
  54. static void bcma_hcd_shutdown(struct bcma_device *dev)
  55. {
  56. + bcma_hci_platform_power_gpio(dev, false);
  57. bcma_core_disable(dev, 0);
  58. }
  59. @@ -354,6 +376,7 @@ static void bcma_hcd_shutdown(struct bcm
  60. static int bcma_hcd_suspend(struct bcma_device *dev)
  61. {
  62. + bcma_hci_platform_power_gpio(dev, false);
  63. bcma_core_disable(dev, 0);
  64. return 0;
  65. @@ -361,6 +384,7 @@ static int bcma_hcd_suspend(struct bcma_
  66. static int bcma_hcd_resume(struct bcma_device *dev)
  67. {
  68. + bcma_hci_platform_power_gpio(dev, true);
  69. bcma_core_enable(dev, 0);
  70. return 0;