mxs: delete old kernel versions
[openwrt/openwrt.git] / target / linux / bcm53xx / patches-4.1 / 186-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch
1 From 0cb136f9882e4649ad6160bb7b48955ff728888c Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Sun, 1 Nov 2015 08:17:21 +0100
4 Subject: [PATCH V2] USB: bcma: switch to GPIO descriptor for power control
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 So far we were using simple (legacy) GPIO functions & some poor logic to
10 control power. It got many drawbacks: we were ignoring OF flags
11 (GPIO_ACTIVE_LOW), we were not setting direction to output and we were
12 assuming gpio_request success all the time.
13 Fix it by switching to gpiod functions and adding appropriate checks.
14
15 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
16 ---
17 drivers/usb/host/bcma-hcd.c | 21 ++++++++++-----------
18 1 file changed, 10 insertions(+), 11 deletions(-)
19
20 --- a/drivers/usb/host/bcma-hcd.c
21 +++ b/drivers/usb/host/bcma-hcd.c
22 @@ -21,6 +21,7 @@
23 */
24 #include <linux/bcma/bcma.h>
25 #include <linux/delay.h>
26 +#include <linux/gpio/consumer.h>
27 #include <linux/platform_device.h>
28 #include <linux/module.h>
29 #include <linux/slab.h>
30 @@ -36,6 +37,7 @@ MODULE_LICENSE("GPL");
31 struct bcma_hcd_device {
32 struct platform_device *ehci_dev;
33 struct platform_device *ohci_dev;
34 + struct gpio_desc *gpio_desc;
35 };
36
37 /* Wait for bitmask in a register to get set or cleared.
38 @@ -228,19 +230,12 @@ static void bcma_hcd_init_chip_arm(struc
39
40 static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
41 {
42 - int gpio;
43 + struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);
44
45 - gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
46 - if (!gpio_is_valid(gpio))
47 + if (IS_ERR_OR_NULL(usb_dev->gpio_desc))
48 return;
49
50 - if (val) {
51 - gpio_request(gpio, "bcma-hcd-gpio");
52 - gpio_set_value(gpio, 1);
53 - } else {
54 - gpio_set_value(gpio, 0);
55 - gpio_free(gpio);
56 - }
57 + gpiod_set_value(usb_dev->gpio_desc, val);
58 }
59
60 static const struct usb_ehci_pdata ehci_pdata = {
61 @@ -314,7 +309,11 @@ static int bcma_hcd_probe(struct bcma_de
62 if (!usb_dev)
63 return -ENOMEM;
64
65 - bcma_hci_platform_power_gpio(dev, true);
66 + if (dev->dev.of_node)
67 + usb_dev->gpio_desc = devm_get_gpiod_from_child(&dev->dev, "vcc",
68 + &dev->dev.of_node->fwnode);
69 + if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
70 + gpiod_direction_output(usb_dev->gpio_desc, 1);
71
72 switch (dev->id.id) {
73 case BCMA_CORE_NS_USB20: