Author: rmilecki Date: 2015-12-03 11:51:32 +0100 (Thu, 03 Dec 2015) New Revision: 47709
Added: trunk/target/linux/bcm53xx/patches-4.4/080-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch Removed: trunk/target/linux/bcm53xx/patches-4.4/186-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch Log: bcm53xx: move & update accepted USB patch for GPIO control Signed-off-by: Rafa?\197?\130 Mi?\197?\130ecki <[email protected]> Copied: trunk/target/linux/bcm53xx/patches-4.4/080-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch (from rev 47708, trunk/target/linux/bcm53xx/patches-4.4/186-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch) =================================================================== --- trunk/target/linux/bcm53xx/patches-4.4/080-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch (rev 0) +++ trunk/target/linux/bcm53xx/patches-4.4/080-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch 2015-12-03 10:51:32 UTC (rev 47709) @@ -0,0 +1,75 @@ +From 9faae5a37b266afca6914163316856c5ed4ec366 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]> +Date: Sun, 1 Nov 2015 10:04:41 +0100 +Subject: [PATCH] USB: bcma: switch to GPIO descriptor for power control +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +So far we were using simple (legacy) GPIO functions & some poor logic to +control power. It got many drawbacks: we were ignoring OF flags +(GPIO_ACTIVE_LOW), we were not setting direction to output and we were +assuming gpio_request success all the time. +Fix it by switching to gpiod functions and adding appropriate checks. + +Signed-off-by: Rafał Miłecki <[email protected]> +Acked-by: Hauke Mehrtens <[email protected]> +Signed-off-by: Greg Kroah-Hartman <[email protected]> +--- + drivers/usb/host/bcma-hcd.c | 21 ++++++++++----------- + 1 file changed, 10 insertions(+), 11 deletions(-) + +--- a/drivers/usb/host/bcma-hcd.c ++++ b/drivers/usb/host/bcma-hcd.c +@@ -21,6 +21,7 @@ + */ + #include <linux/bcma/bcma.h> + #include <linux/delay.h> ++#include <linux/gpio/consumer.h> + #include <linux/platform_device.h> + #include <linux/module.h> + #include <linux/slab.h> +@@ -36,6 +37,7 @@ MODULE_LICENSE("GPL"); + struct bcma_hcd_device { + struct platform_device *ehci_dev; + struct platform_device *ohci_dev; ++ struct gpio_desc *gpio_desc; + }; + + /* Wait for bitmask in a register to get set or cleared. +@@ -228,19 +230,12 @@ static void bcma_hcd_init_chip_arm(struct bcma_device *dev) + + static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val) + { +- int gpio; ++ struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev); + +- gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0); +- if (!gpio_is_valid(gpio)) ++ if (IS_ERR_OR_NULL(usb_dev->gpio_desc)) + return; + +- if (val) { +- gpio_request(gpio, "bcma-hcd-gpio"); +- gpio_set_value(gpio, 1); +- } else { +- gpio_set_value(gpio, 0); +- gpio_free(gpio); +- } ++ gpiod_set_value(usb_dev->gpio_desc, val); + } + + static const struct usb_ehci_pdata ehci_pdata = { +@@ -314,7 +309,11 @@ static int bcma_hcd_probe(struct bcma_device *dev) + if (!usb_dev) + return -ENOMEM; + +- bcma_hci_platform_power_gpio(dev, true); ++ if (dev->dev.of_node) ++ usb_dev->gpio_desc = devm_get_gpiod_from_child(&dev->dev, "vcc", ++ &dev->dev.of_node->fwnode); ++ if (!IS_ERR_OR_NULL(usb_dev->gpio_desc)) ++ gpiod_direction_output(usb_dev->gpio_desc, 1); + + switch (dev->id.id) { + case BCMA_CORE_NS_USB20: Deleted: trunk/target/linux/bcm53xx/patches-4.4/186-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch =================================================================== --- trunk/target/linux/bcm53xx/patches-4.4/186-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch 2015-12-03 10:19:16 UTC (rev 47708) +++ trunk/target/linux/bcm53xx/patches-4.4/186-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch 2015-12-03 10:51:32 UTC (rev 47709) @@ -1,73 +0,0 @@ -From 0cb136f9882e4649ad6160bb7b48955ff728888c Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]> -Date: Sun, 1 Nov 2015 08:17:21 +0100 -Subject: [PATCH V2] USB: bcma: switch to GPIO descriptor for power control -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -So far we were using simple (legacy) GPIO functions & some poor logic to -control power. It got many drawbacks: we were ignoring OF flags -(GPIO_ACTIVE_LOW), we were not setting direction to output and we were -assuming gpio_request success all the time. -Fix it by switching to gpiod functions and adding appropriate checks. - -Signed-off-by: Rafał Miłecki <[email protected]> ---- - drivers/usb/host/bcma-hcd.c | 21 ++++++++++----------- - 1 file changed, 10 insertions(+), 11 deletions(-) - ---- a/drivers/usb/host/bcma-hcd.c -+++ b/drivers/usb/host/bcma-hcd.c -@@ -21,6 +21,7 @@ - */ - #include <linux/bcma/bcma.h> - #include <linux/delay.h> -+#include <linux/gpio/consumer.h> - #include <linux/platform_device.h> - #include <linux/module.h> - #include <linux/slab.h> -@@ -36,6 +37,7 @@ MODULE_LICENSE("GPL"); - struct bcma_hcd_device { - struct platform_device *ehci_dev; - struct platform_device *ohci_dev; -+ struct gpio_desc *gpio_desc; - }; - - /* Wait for bitmask in a register to get set or cleared. -@@ -228,19 +230,12 @@ static void bcma_hcd_init_chip_arm(struc - - static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val) - { -- int gpio; -+ struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev); - -- gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0); -- if (!gpio_is_valid(gpio)) -+ if (IS_ERR_OR_NULL(usb_dev->gpio_desc)) - return; - -- if (val) { -- gpio_request(gpio, "bcma-hcd-gpio"); -- gpio_set_value(gpio, 1); -- } else { -- gpio_set_value(gpio, 0); -- gpio_free(gpio); -- } -+ gpiod_set_value(usb_dev->gpio_desc, val); - } - - static const struct usb_ehci_pdata ehci_pdata = { -@@ -314,7 +309,11 @@ static int bcma_hcd_probe(struct bcma_de - if (!usb_dev) - return -ENOMEM; - -- bcma_hci_platform_power_gpio(dev, true); -+ if (dev->dev.of_node) -+ usb_dev->gpio_desc = devm_get_gpiod_from_child(&dev->dev, "vcc", -+ &dev->dev.of_node->fwnode); -+ if (!IS_ERR_OR_NULL(usb_dev->gpio_desc)) -+ gpiod_direction_output(usb_dev->gpio_desc, 1); - - switch (dev->id.id) { - case BCMA_CORE_NS_USB20: _______________________________________________ openwrt-commits mailing list [email protected] https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits
