8a00141b8fad224d13e878cad8c37f4ea46e0102
[openwrt/svn-archive/archive.git] / target / linux / bcm53xx / patches-3.18 / 185-USB-bcma-add-support-for-controlling-bus-power-throu.patch
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
6 On some boards a GPIO is needed to activate USB controller. Make it
7 possible to specify such a GPIO in device tree.
8
9 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
11 ---
12 drivers/usb/host/bcma-hcd.c | 24 ++++++++++++++++++++++++
13 1 file changed, 24 insertions(+)
14
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
19 @@ -24,6 +24,8 @@
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>
27
28 @@ -224,6 +226,23 @@ static void bcma_hcd_init_chip_arm(struct bcma_device *dev)
29 }
30 }
31
32 +static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
33 +{
34 + int gpio;
35 +
36 + gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
37 + if (!gpio_is_valid(gpio))
38 + return;
39 +
40 + if (val) {
41 + gpio_request(gpio, "bcma-hcd-gpio");
42 + gpio_set_value(gpio, 1);
43 + } else {
44 + gpio_set_value(gpio, 0);
45 + gpio_free(gpio);
46 + }
47 +}
48 +
49 static const struct usb_ehci_pdata ehci_pdata = {
50 };
51
52 @@ -295,6 +314,8 @@ static int bcma_hcd_probe(struct bcma_device *dev)
53 if (!usb_dev)
54 return -ENOMEM;
55
56 + bcma_hci_platform_power_gpio(dev, true);
57 +
58 switch (dev->id.id) {
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)
62
63 static void bcma_hcd_shutdown(struct bcma_device *dev)
64 {
65 + bcma_hci_platform_power_gpio(dev, false);
66 bcma_core_disable(dev, 0);
67 }
68
69 @@ -354,6 +376,7 @@ static void bcma_hcd_shutdown(struct bcma_device *dev)
70
71 static int bcma_hcd_suspend(struct bcma_device *dev)
72 {
73 + bcma_hci_platform_power_gpio(dev, false);
74 bcma_core_disable(dev, 0);
75
76 return 0;
77 @@ -361,6 +384,7 @@ static int bcma_hcd_suspend(struct bcma_device *dev)
78
79 static int bcma_hcd_resume(struct bcma_device *dev)
80 {
81 + bcma_hci_platform_power_gpio(dev, true);
82 bcma_core_enable(dev, 0);
83
84 return 0;
85 --
86 1.8.4.5
87