From: Rafał Miłecki <zaj...@gmail.com>

It wasn't working (on most of devices?) without setting GPIO direction
and wasn't respecting ACTIVE_LOW flag.

Signed-off-by: Rafał Miłecki <zaj...@gmail.com>
Signed-off-by: Hauke Mehrtens <ha...@hauke-m.de>
---
 drivers/usb/host/bcma-hcd.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
index 32815e6..7041028 100644
--- a/drivers/usb/host/bcma-hcd.c
+++ b/drivers/usb/host/bcma-hcd.c
@@ -231,17 +231,22 @@ static void bcma_hcd_init_chip_arm(struct bcma_device 
*dev)
 
 static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
 {
+       enum of_gpio_flags of_flags;
        int gpio;
 
-       gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
+       gpio = of_get_named_gpio_flags(dev->dev.of_node, "vcc-gpio", 0, 
&of_flags);
        if (!gpio_is_valid(gpio))
                return;
 
        if (val) {
-               gpio_request(gpio, "bcma-hcd-gpio");
-               gpio_set_value(gpio, 1);
+               unsigned long flags = 0;
+               bool active_low = !!(of_flags & OF_GPIO_ACTIVE_LOW);
+
+               flags |= active_low ? GPIOF_ACTIVE_LOW : 0;
+               flags |= active_low ? GPIOF_INIT_LOW : GPIOF_INIT_HIGH;
+               gpio_request_one(gpio, flags, "bcma-hcd-gpio");
        } else {
-               gpio_set_value(gpio, 0);
+               gpiod_set_value(gpio_to_desc(gpio), 0);
                gpio_free(gpio);
        }
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to