mxs: delete old kernel versions
[openwrt/openwrt.git] / target / linux / bcm53xx / patches-4.1 / 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 --- a/drivers/usb/host/bcma-hcd.c
16 +++ b/drivers/usb/host/bcma-hcd.c
17 @@ -24,6 +24,8 @@
18 #include <linux/platform_device.h>
19 #include <linux/module.h>
20 #include <linux/slab.h>
21 +#include <linux/of.h>
22 +#include <linux/of_gpio.h>
23 #include <linux/usb/ehci_pdriver.h>
24 #include <linux/usb/ohci_pdriver.h>
25
26 @@ -224,6 +226,23 @@ static void bcma_hcd_init_chip_arm(struc
27 }
28 }
29
30 +static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
31 +{
32 + int gpio;
33 +
34 + gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
35 + if (!gpio_is_valid(gpio))
36 + return;
37 +
38 + if (val) {
39 + gpio_request(gpio, "bcma-hcd-gpio");
40 + gpio_set_value(gpio, 1);
41 + } else {
42 + gpio_set_value(gpio, 0);
43 + gpio_free(gpio);
44 + }
45 +}
46 +
47 static const struct usb_ehci_pdata ehci_pdata = {
48 };
49
50 @@ -295,6 +314,8 @@ static int bcma_hcd_probe(struct bcma_de
51 if (!usb_dev)
52 return -ENOMEM;
53
54 + bcma_hci_platform_power_gpio(dev, true);
55 +
56 switch (dev->id.id) {
57 case BCMA_CORE_NS_USB20:
58 bcma_hcd_init_chip_arm(dev);
59 @@ -347,6 +368,7 @@ static void bcma_hcd_remove(struct bcma_
60
61 static void bcma_hcd_shutdown(struct bcma_device *dev)
62 {
63 + bcma_hci_platform_power_gpio(dev, false);
64 bcma_core_disable(dev, 0);
65 }
66
67 @@ -354,6 +376,7 @@ static void bcma_hcd_shutdown(struct bcm
68
69 static int bcma_hcd_suspend(struct bcma_device *dev)
70 {
71 + bcma_hci_platform_power_gpio(dev, false);
72 bcma_core_disable(dev, 0);
73
74 return 0;
75 @@ -361,6 +384,7 @@ static int bcma_hcd_suspend(struct bcma_
76
77 static int bcma_hcd_resume(struct bcma_device *dev)
78 {
79 + bcma_hci_platform_power_gpio(dev, true);
80 bcma_core_enable(dev, 0);
81
82 return 0;