bcm53xx: add profiling support
[openwrt/svn-archive/archive.git] / target / linux / bcm53xx / patches-3.18 / 191-bcma_hcd_add_gpio_power_control.patch
1 Subject: [PATCH] bcma-hcd: add support for controlling bus power through GPIO
2
3 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
4 ---
5 --- a/drivers/usb/host/bcma-hcd.c
6 +++ b/drivers/usb/host/bcma-hcd.c
7 @@ -23,6 +23,8 @@
8 #include <linux/platform_device.h>
9 #include <linux/module.h>
10 #include <linux/slab.h>
11 +#include <linux/of.h>
12 +#include <linux/of_gpio.h>
13 #include <linux/usb/ehci_pdriver.h>
14 #include <linux/usb/ohci_pdriver.h>
15
16 @@ -205,7 +207,38 @@ static void bcma_hcd_init_chip_arm(struc
17 iounmap(dmu);
18 }
19
20 +static void bcma_hci_platform_power_gpio(struct platform_device *dev, bool val)
21 +{
22 + int gpio;
23 +
24 + gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
25 + if (!gpio_is_valid(gpio))
26 + return;
27 +
28 + if (val) {
29 + gpio_request(gpio, "bcma-hcd-gpio");
30 + gpio_set_value(gpio, 1);
31 + } else {
32 + gpio_set_value(gpio, 0);
33 + gpio_free(gpio);
34 + }
35 +}
36 +
37 +static int bcma_hci_platform_power_on(struct platform_device *dev)
38 +{
39 + bcma_hci_platform_power_gpio(dev, true);
40 + return 0;
41 +}
42 +
43 +static void bcma_hci_platform_power_off(struct platform_device *dev)
44 +{
45 + bcma_hci_platform_power_gpio(dev, false);
46 +}
47 +
48 static const struct usb_ehci_pdata ehci_pdata = {
49 + .power_on = bcma_hci_platform_power_on,
50 + .power_suspend = bcma_hci_platform_power_off,
51 + .power_off = bcma_hci_platform_power_off,
52 };
53
54 static const struct usb_ohci_pdata ohci_pdata = {
55 @@ -233,6 +266,7 @@ static struct platform_device *bcma_hcd_
56
57 hci_dev->dev.parent = &dev->dev;
58 hci_dev->dev.dma_mask = &hci_dev->dev.coherent_dma_mask;
59 + hci_dev->dev.of_node = dev->dev.of_node;
60
61 ret = platform_device_add_resources(hci_dev, hci_res,
62 ARRAY_SIZE(hci_res));