71777816dacccda0d6f6d9b0711caa3fb217d2e3
[15.05/openwrt.git] / target / linux / bcm53xx / patches-3.18 / 813-USB-bcma-fix-setting-VCC-GPIO-value.patch
1 From bdc3b01d94b22f8b5f9621a1c37336e78f4f1bce 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] 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 ---
14  drivers/usb/host/bcma-hcd.c | 13 +++++++++----
15  1 file changed, 9 insertions(+), 4 deletions(-)
16
17 diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
18 index 8853ef7..d18ffdc 100644
19 --- a/drivers/usb/host/bcma-hcd.c
20 +++ b/drivers/usb/host/bcma-hcd.c
21 @@ -230,17 +230,22 @@ static void bcma_hcd_init_chip_arm(struct bcma_device *dev)
22  
23  static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
24  {
25 +       enum of_gpio_flags of_flags;
26         int gpio;
27  
28 -       gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
29 +       gpio = of_get_named_gpio_flags(dev->dev.of_node, "vcc-gpio", 0, &of_flags);
30         if (!gpio_is_valid(gpio))
31                 return;
32  
33         if (val) {
34 -               gpio_request(gpio, "bcma-hcd-gpio");
35 -               gpio_set_value(gpio, 1);
36 +               unsigned long flags = 0;
37 +               bool active_low = !!(of_flags & OF_GPIO_ACTIVE_LOW);
38 +
39 +               flags |= active_low ? GPIOF_ACTIVE_LOW : 0;
40 +               flags |= active_low ? GPIOF_INIT_LOW : GPIOF_INIT_HIGH;
41 +               gpio_request_one(gpio, flags, "bcma-hcd-gpio");
42         } else {
43 -               gpio_set_value(gpio, 0);
44 +               gpiod_set_value(gpio_to_desc(gpio), 0);
45                 gpio_free(gpio);
46         }
47  }
48 -- 
49 1.8.4.5
50