bcm53xx: update USB 3.0 driver with version submitted upstream
[openwrt.git] / target / linux / bcm53xx / patches-4.1 / 198-USB-bcma-fix-setting-VCC-GPIO-value.patch
1 From 7572673e06393b117f87b20b82be0518634d7042 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Sun, 21 Jun 2015 12:09:57 +0200
4 Subject: [PATCH v3 6/6] usb: bcma: fix setting VCC GPIO value
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 It wasn't working (on most of devices?) without setting GPIO direction
10 and wasn't respecting ACTIVE_LOW flag.
11
12 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
13 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
14 ---
15  drivers/usb/host/bcma-hcd.c | 14 ++++++++++----
16  1 file changed, 10 insertions(+), 4 deletions(-)
17
18 --- a/drivers/usb/host/bcma-hcd.c
19 +++ b/drivers/usb/host/bcma-hcd.c
20 @@ -26,6 +26,7 @@
21  #include <linux/slab.h>
22  #include <linux/of.h>
23  #include <linux/of_gpio.h>
24 +#include <linux/gpio/consumer.h>
25  #include <linux/usb/ehci_pdriver.h>
26  #include <linux/usb/ohci_pdriver.h>
27  #include <linux/usb/xhci_pdriver.h>
28 @@ -231,17 +232,22 @@ static void bcma_hcd_init_chip_arm(struc
29  
30  static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
31  {
32 +       enum of_gpio_flags of_flags;
33         int gpio;
34  
35 -       gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
36 +       gpio = of_get_named_gpio_flags(dev->dev.of_node, "vcc-gpio", 0, &of_flags);
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 +               unsigned long flags = 0;
44 +               bool active_low = !!(of_flags & OF_GPIO_ACTIVE_LOW);
45 +
46 +               flags |= active_low ? GPIOF_ACTIVE_LOW : 0;
47 +               flags |= active_low ? GPIOF_INIT_LOW : GPIOF_INIT_HIGH;
48 +               gpio_request_one(gpio, flags, "bcma-hcd-gpio");
49         } else {
50 -               gpio_set_value(gpio, 0);
51 +               gpiod_set_value(gpio_to_desc(gpio), 0);
52                 gpio_free(gpio);
53         }
54  }