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
6 On some boards a GPIO is needed to activate USB controller. Make it
7 possible to specify such a GPIO in device tree.
9 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
12 drivers/usb/host/bcma-hcd.c | 24 ++++++++++++++++++++++++
13 1 file changed, 24 insertions(+)
15 diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
16 index 983bc67..a01c6ce 100644
17 --- a/drivers/usb/host/bcma-hcd.c
18 +++ b/drivers/usb/host/bcma-hcd.c
20 #include <linux/platform_device.h>
21 #include <linux/module.h>
22 #include <linux/slab.h>
23 +#include <linux/of.h>
24 +#include <linux/of_gpio.h>
25 #include <linux/usb/ehci_pdriver.h>
26 #include <linux/usb/ohci_pdriver.h>
28 @@ -224,6 +226,23 @@ static void bcma_hcd_init_chip_arm(struct bcma_device *dev)
32 +static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
36 + gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
37 + if (!gpio_is_valid(gpio))
41 + gpio_request(gpio, "bcma-hcd-gpio");
42 + gpio_set_value(gpio, 1);
44 + gpio_set_value(gpio, 0);
49 static const struct usb_ehci_pdata ehci_pdata = {
52 @@ -295,6 +314,8 @@ static int bcma_hcd_probe(struct bcma_device *dev)
56 + bcma_hci_platform_power_gpio(dev, true);
59 case BCMA_CORE_NS_USB20:
60 bcma_hcd_init_chip_arm(dev);
61 @@ -347,6 +368,7 @@ static void bcma_hcd_remove(struct bcma_device *dev)
63 static void bcma_hcd_shutdown(struct bcma_device *dev)
65 + bcma_hci_platform_power_gpio(dev, false);
66 bcma_core_disable(dev, 0);
69 @@ -354,6 +376,7 @@ static void bcma_hcd_shutdown(struct bcma_device *dev)
71 static int bcma_hcd_suspend(struct bcma_device *dev)
73 + bcma_hci_platform_power_gpio(dev, false);
74 bcma_core_disable(dev, 0);
77 @@ -361,6 +384,7 @@ static int bcma_hcd_suspend(struct bcma_device *dev)
79 static int bcma_hcd_resume(struct bcma_device *dev)
81 + bcma_hci_platform_power_gpio(dev, true);
82 bcma_core_enable(dev, 0);