bcm53xx: use backported versions of bcma USB patches
authorRafał Miłecki <zajec5@gmail.com>
Sun, 8 May 2016 21:09:12 +0000 (21:09 +0000)
committerRafał Miłecki <zajec5@gmail.com>
Sun, 8 May 2016 21:09:12 +0000 (21:09 +0000)
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
SVN-Revision: 49297

21 files changed:
target/linux/bcm53xx/patches-3.18/082-01-USB-bcma-remove-chip-id-check.patch [new file with mode: 0644]
target/linux/bcm53xx/patches-3.18/082-02-USB-bcma-replace-numbers-with-constants.patch [new file with mode: 0644]
target/linux/bcm53xx/patches-3.18/082-03-USB-bcma-use-devm_kzalloc.patch [new file with mode: 0644]
target/linux/bcm53xx/patches-3.18/082-04-USB-bcma-fix-error-handling-in-bcma_hcd_create_pdev.patch [new file with mode: 0644]
target/linux/bcm53xx/patches-3.18/082-05-USB-bcma-add-bcm53xx-support.patch [new file with mode: 0644]
target/linux/bcm53xx/patches-3.18/082-06-USB-bcma-add-support-for-controlling-bus-power-throu.patch [new file with mode: 0644]
target/linux/bcm53xx/patches-3.18/083-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch [new file with mode: 0644]
target/linux/bcm53xx/patches-3.18/084-01-USB-bcma-make-helper-creating-platform-dev-more-gene.patch [new file with mode: 0644]
target/linux/bcm53xx/patches-3.18/084-02-USB-bcma-separate-code-initializing-USB-2.0-core.patch [new file with mode: 0644]
target/linux/bcm53xx/patches-3.18/085-USB-bcma-use-simpler-devm-helper-for-getting-vcc-GPI.patch [new file with mode: 0644]
target/linux/bcm53xx/patches-3.18/180-USB-bcma-remove-chip-id-check.patch [deleted file]
target/linux/bcm53xx/patches-3.18/181-USB-bcma-replace-numbers-with-constants.patch [deleted file]
target/linux/bcm53xx/patches-3.18/182-USB-bcma-use-devm_kzalloc.patch [deleted file]
target/linux/bcm53xx/patches-3.18/183-USB-bcma-fix-error-handling-in-bcma_hcd_create_pdev.patch [deleted file]
target/linux/bcm53xx/patches-3.18/184-USB-bcma-add-bcm53xx-support.patch [deleted file]
target/linux/bcm53xx/patches-3.18/185-USB-bcma-add-support-for-controlling-bus-power-throu.patch [deleted file]
target/linux/bcm53xx/patches-3.18/186-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch [deleted file]
target/linux/bcm53xx/patches-3.18/810-USB-bcma-make-helper-creating-platform-dev-more-gene.patch [deleted file]
target/linux/bcm53xx/patches-3.18/811-USB-bcma-use-separated-function-for-USB-2.0-initiali.patch [deleted file]
target/linux/bcm53xx/patches-3.18/812-USB-bcma-add-USB-3.0-support.patch
target/linux/bcm53xx/patches-3.18/813-USB-bcma-use-simpler-devm_gpiod_get.patch [deleted file]

diff --git a/target/linux/bcm53xx/patches-3.18/082-01-USB-bcma-remove-chip-id-check.patch b/target/linux/bcm53xx/patches-3.18/082-01-USB-bcma-remove-chip-id-check.patch
new file mode 100644 (file)
index 0000000..9a05a2d
--- /dev/null
@@ -0,0 +1,35 @@
+From 7e4a4da67255d92620ba59b461b5bc295db28dae Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Thu, 11 Jun 2015 22:57:35 +0200
+Subject: [PATCH] USB: bcma: remove chip id check
+
+I have never seen any bcma device with an USB host core which was not a
+SoC, the bcma devices have an USB device core with a different core id.
+Some SoC have IDs with 47XX and 53XX in decimal form which would be
+rejected by this check. Instead of fixing this check just remove it.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/host/bcma-hcd.c | 5 -----
+ 1 file changed, 5 deletions(-)
+
+--- a/drivers/usb/host/bcma-hcd.c
++++ b/drivers/usb/host/bcma-hcd.c
+@@ -214,16 +214,11 @@ err_alloc:
+ static int bcma_hcd_probe(struct bcma_device *dev)
+ {
+       int err;
+-      u16 chipid_top;
+       u32 ohci_addr;
+       struct bcma_hcd_device *usb_dev;
+       struct bcma_chipinfo *chipinfo;
+       chipinfo = &dev->bus->chipinfo;
+-      /* USBcores are only connected on embedded devices. */
+-      chipid_top = (chipinfo->id & 0xFF00);
+-      if (chipid_top != 0x4700 && chipid_top != 0x5300)
+-              return -ENODEV;
+       /* TODO: Probably need checks here; is the core connected? */
diff --git a/target/linux/bcm53xx/patches-3.18/082-02-USB-bcma-replace-numbers-with-constants.patch b/target/linux/bcm53xx/patches-3.18/082-02-USB-bcma-replace-numbers-with-constants.patch
new file mode 100644 (file)
index 0000000..9b2920a
--- /dev/null
@@ -0,0 +1,25 @@
+From 98e13e05a1bab82c3bec1d867159bc8384acbe5b Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Thu, 11 Jun 2015 22:57:36 +0200
+Subject: [PATCH] USB: bcma: replace numbers with constants
+
+The constants for these numbers were added long time ago, use them.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/host/bcma-hcd.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/usb/host/bcma-hcd.c
++++ b/drivers/usb/host/bcma-hcd.c
+@@ -233,7 +233,8 @@ static int bcma_hcd_probe(struct bcma_de
+       /* In AI chips EHCI is addrspace 0, OHCI is 1 */
+       ohci_addr = dev->addr_s[0];
+-      if ((chipinfo->id == 0x5357 || chipinfo->id == 0x4749)
++      if ((chipinfo->id == BCMA_CHIP_ID_BCM5357 ||
++           chipinfo->id == BCMA_CHIP_ID_BCM4749)
+           && chipinfo->rev == 0)
+               ohci_addr = 0x18009000;
diff --git a/target/linux/bcm53xx/patches-3.18/082-03-USB-bcma-use-devm_kzalloc.patch b/target/linux/bcm53xx/patches-3.18/082-03-USB-bcma-use-devm_kzalloc.patch
new file mode 100644 (file)
index 0000000..007af3e
--- /dev/null
@@ -0,0 +1,48 @@
+From c27da2b22b558390acc515e71e47b1b307f85d5a Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Thu, 11 Jun 2015 22:57:37 +0200
+Subject: [PATCH] USB: bcma: use devm_kzalloc
+
+Instead of manually handling the frees use devm. There was also a free
+missing in the unregister call which is not needed with devm.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/host/bcma-hcd.c | 11 ++++-------
+ 1 file changed, 4 insertions(+), 7 deletions(-)
+
+--- a/drivers/usb/host/bcma-hcd.c
++++ b/drivers/usb/host/bcma-hcd.c
+@@ -225,7 +225,8 @@ static int bcma_hcd_probe(struct bcma_de
+       if (dma_set_mask_and_coherent(dev->dma_dev, DMA_BIT_MASK(32)))
+               return -EOPNOTSUPP;
+-      usb_dev = kzalloc(sizeof(struct bcma_hcd_device), GFP_KERNEL);
++      usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
++                             GFP_KERNEL);
+       if (!usb_dev)
+               return -ENOMEM;
+@@ -239,10 +240,8 @@ static int bcma_hcd_probe(struct bcma_de
+               ohci_addr = 0x18009000;
+       usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, true, ohci_addr);
+-      if (IS_ERR(usb_dev->ohci_dev)) {
+-              err = PTR_ERR(usb_dev->ohci_dev);
+-              goto err_free_usb_dev;
+-      }
++      if (IS_ERR(usb_dev->ohci_dev))
++              return PTR_ERR(usb_dev->ohci_dev);
+       usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, false, dev->addr);
+       if (IS_ERR(usb_dev->ehci_dev)) {
+@@ -255,8 +254,6 @@ static int bcma_hcd_probe(struct bcma_de
+ err_unregister_ohci_dev:
+       platform_device_unregister(usb_dev->ohci_dev);
+-err_free_usb_dev:
+-      kfree(usb_dev);
+       return err;
+ }
diff --git a/target/linux/bcm53xx/patches-3.18/082-04-USB-bcma-fix-error-handling-in-bcma_hcd_create_pdev.patch b/target/linux/bcm53xx/patches-3.18/082-04-USB-bcma-fix-error-handling-in-bcma_hcd_create_pdev.patch
new file mode 100644 (file)
index 0000000..8b4203e
--- /dev/null
@@ -0,0 +1,34 @@
+From ab2de5793080dfb9f191ca71068b9f476a55a0f4 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Thu, 11 Jun 2015 22:57:38 +0200
+Subject: [PATCH] USB: bcma: fix error handling in bcma_hcd_create_pdev()
+
+This patch makes bcma_hcd_create_pdev() not return NULL, but a prober
+error code in case of an error.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/host/bcma-hcd.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/usb/host/bcma-hcd.c
++++ b/drivers/usb/host/bcma-hcd.c
+@@ -169,7 +169,7 @@ static struct platform_device *bcma_hcd_
+ {
+       struct platform_device *hci_dev;
+       struct resource hci_res[2];
+-      int ret = -ENOMEM;
++      int ret;
+       memset(hci_res, 0, sizeof(hci_res));
+@@ -183,7 +183,7 @@ static struct platform_device *bcma_hcd_
+       hci_dev = platform_device_alloc(ohci ? "ohci-platform" :
+                                       "ehci-platform" , 0);
+       if (!hci_dev)
+-              return NULL;
++              return ERR_PTR(-ENOMEM);
+       hci_dev->dev.parent = &dev->dev;
+       hci_dev->dev.dma_mask = &hci_dev->dev.coherent_dma_mask;
diff --git a/target/linux/bcm53xx/patches-3.18/082-05-USB-bcma-add-bcm53xx-support.patch b/target/linux/bcm53xx/patches-3.18/082-05-USB-bcma-add-bcm53xx-support.patch
new file mode 100644 (file)
index 0000000..25a8910
--- /dev/null
@@ -0,0 +1,134 @@
+From 10bc04b744c69f253dfe47bc143325349ce8becc Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Thu, 11 Jun 2015 22:57:39 +0200
+Subject: [PATCH] USB: bcma: add bcm53xx support
+
+The Broadcom ARM SoCs with this usb core need a different
+initialization and they have a different core id. This patch adds
+support for these USB 2.0 core.
+
+Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/host/bcma-hcd.c | 81 +++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 78 insertions(+), 3 deletions(-)
+
+--- a/drivers/usb/host/bcma-hcd.c
++++ b/drivers/usb/host/bcma-hcd.c
+@@ -2,7 +2,8 @@
+  * Broadcom specific Advanced Microcontroller Bus
+  * Broadcom USB-core driver (BCMA bus glue)
+  *
+- * Copyright 2011-2012 Hauke Mehrtens <hauke@hauke-m.de>
++ * Copyright 2011-2015 Hauke Mehrtens <hauke@hauke-m.de>
++ * Copyright 2015 Felix Fietkau <nbd@openwrt.org>
+  *
+  * Based on ssb-ohci driver
+  * Copyright 2007 Michael Buesch <m@bues.ch>
+@@ -88,7 +89,7 @@ static void bcma_hcd_4716wa(struct bcma_
+ }
+ /* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */
+-static void bcma_hcd_init_chip(struct bcma_device *dev)
++static void bcma_hcd_init_chip_mips(struct bcma_device *dev)
+ {
+       u32 tmp;
+@@ -159,6 +160,70 @@ static void bcma_hcd_init_chip(struct bc
+       }
+ }
++static void bcma_hcd_init_chip_arm_phy(struct bcma_device *dev)
++{
++      struct bcma_device *arm_core;
++      void __iomem *dmu;
++
++      arm_core = bcma_find_core(dev->bus, BCMA_CORE_ARMCA9);
++      if (!arm_core) {
++              dev_err(&dev->dev, "can not find ARM Cortex A9 ihost core\n");
++              return;
++      }
++
++      dmu = ioremap_nocache(arm_core->addr_s[0], 0x1000);
++      if (!dmu) {
++              dev_err(&dev->dev, "can not map ARM Cortex A9 ihost core\n");
++              return;
++      }
++
++      /* Unlock DMU PLL settings */
++      iowrite32(0x0000ea68, dmu + 0x180);
++
++      /* Write USB 2.0 PLL control setting */
++      iowrite32(0x00dd10c3, dmu + 0x164);
++
++      /* Lock DMU PLL settings */
++      iowrite32(0x00000000, dmu + 0x180);
++
++      iounmap(dmu);
++}
++
++static void bcma_hcd_init_chip_arm_hc(struct bcma_device *dev)
++{
++      u32 val;
++
++      /*
++       * Delay after PHY initialized to ensure HC is ready to be configured
++       */
++      usleep_range(1000, 2000);
++
++      /* Set packet buffer OUT threshold */
++      val = bcma_read32(dev, 0x94);
++      val &= 0xffff;
++      val |= 0x80 << 16;
++      bcma_write32(dev, 0x94, val);
++
++      /* Enable break memory transfer */
++      val = bcma_read32(dev, 0x9c);
++      val |= 1;
++      bcma_write32(dev, 0x9c, val);
++}
++
++static void bcma_hcd_init_chip_arm(struct bcma_device *dev)
++{
++      bcma_core_enable(dev, 0);
++
++      if (dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM4707 ||
++          dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM53018) {
++              if (dev->bus->chipinfo.pkg == BCMA_PKG_ID_BCM4707 ||
++                  dev->bus->chipinfo.pkg == BCMA_PKG_ID_BCM4708)
++                      bcma_hcd_init_chip_arm_phy(dev);
++
++              bcma_hcd_init_chip_arm_hc(dev);
++      }
++}
++
+ static const struct usb_ehci_pdata ehci_pdata = {
+ };
+@@ -230,7 +295,16 @@ static int bcma_hcd_probe(struct bcma_de
+       if (!usb_dev)
+               return -ENOMEM;
+-      bcma_hcd_init_chip(dev);
++      switch (dev->id.id) {
++      case BCMA_CORE_NS_USB20:
++              bcma_hcd_init_chip_arm(dev);
++              break;
++      case BCMA_CORE_USB20_HOST:
++              bcma_hcd_init_chip_mips(dev);
++              break;
++      default:
++              return -ENODEV;
++      }
+       /* In AI chips EHCI is addrspace 0, OHCI is 1 */
+       ohci_addr = dev->addr_s[0];
+@@ -299,6 +373,7 @@ static int bcma_hcd_resume(struct bcma_d
+ static const struct bcma_device_id bcma_hcd_table[] = {
+       BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, BCMA_ANY_CLASS),
++      BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_USB20, BCMA_ANY_REV, BCMA_ANY_CLASS),
+       BCMA_CORETABLE_END
+ };
+ MODULE_DEVICE_TABLE(bcma, bcma_hcd_table);
diff --git a/target/linux/bcm53xx/patches-3.18/082-06-USB-bcma-add-support-for-controlling-bus-power-throu.patch b/target/linux/bcm53xx/patches-3.18/082-06-USB-bcma-add-support-for-controlling-bus-power-throu.patch
new file mode 100644 (file)
index 0000000..dd347d7
--- /dev/null
@@ -0,0 +1,83 @@
+From eb4861c3cef7f745df0d2a26b0f4287da0190424 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Thu, 11 Jun 2015 22:57:40 +0200
+Subject: [PATCH] USB: bcma: add support for controlling bus power through GPIO
+
+On some boards a GPIO is needed to activate USB controller. Make it
+possible to specify such a GPIO in device tree.
+
+Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/host/bcma-hcd.c | 24 ++++++++++++++++++++++++
+ 1 file changed, 24 insertions(+)
+
+--- a/drivers/usb/host/bcma-hcd.c
++++ b/drivers/usb/host/bcma-hcd.c
+@@ -24,6 +24,8 @@
+ #include <linux/platform_device.h>
+ #include <linux/module.h>
+ #include <linux/slab.h>
++#include <linux/of.h>
++#include <linux/of_gpio.h>
+ #include <linux/usb/ehci_pdriver.h>
+ #include <linux/usb/ohci_pdriver.h>
+@@ -224,6 +226,23 @@ static void bcma_hcd_init_chip_arm(struc
+       }
+ }
++static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
++{
++      int gpio;
++
++      gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
++      if (!gpio_is_valid(gpio))
++              return;
++
++      if (val) {
++              gpio_request(gpio, "bcma-hcd-gpio");
++              gpio_set_value(gpio, 1);
++      } else {
++              gpio_set_value(gpio, 0);
++              gpio_free(gpio);
++      }
++}
++
+ static const struct usb_ehci_pdata ehci_pdata = {
+ };
+@@ -295,6 +314,8 @@ static int bcma_hcd_probe(struct bcma_de
+       if (!usb_dev)
+               return -ENOMEM;
++      bcma_hci_platform_power_gpio(dev, true);
++
+       switch (dev->id.id) {
+       case BCMA_CORE_NS_USB20:
+               bcma_hcd_init_chip_arm(dev);
+@@ -347,6 +368,7 @@ static void bcma_hcd_remove(struct bcma_
+ static void bcma_hcd_shutdown(struct bcma_device *dev)
+ {
++      bcma_hci_platform_power_gpio(dev, false);
+       bcma_core_disable(dev, 0);
+ }
+@@ -354,6 +376,7 @@ static void bcma_hcd_shutdown(struct bcm
+ static int bcma_hcd_suspend(struct bcma_device *dev)
+ {
++      bcma_hci_platform_power_gpio(dev, false);
+       bcma_core_disable(dev, 0);
+       return 0;
+@@ -361,6 +384,7 @@ static int bcma_hcd_suspend(struct bcma_
+ static int bcma_hcd_resume(struct bcma_device *dev)
+ {
++      bcma_hci_platform_power_gpio(dev, true);
+       bcma_core_enable(dev, 0);
+       return 0;
diff --git a/target/linux/bcm53xx/patches-3.18/083-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch b/target/linux/bcm53xx/patches-3.18/083-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch
new file mode 100644 (file)
index 0000000..bc735a2
--- /dev/null
@@ -0,0 +1,75 @@
+From 9faae5a37b266afca6914163316856c5ed4ec366 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+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 <zajec5@gmail.com>
+Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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:
diff --git a/target/linux/bcm53xx/patches-3.18/084-01-USB-bcma-make-helper-creating-platform-dev-more-gene.patch b/target/linux/bcm53xx/patches-3.18/084-01-USB-bcma-make-helper-creating-platform-dev-more-gene.patch
new file mode 100644 (file)
index 0000000..320b6dd
--- /dev/null
@@ -0,0 +1,77 @@
+From 352d9e2ee85b43170388599a17cd7b219f270163 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Date: Sat, 5 Dec 2015 13:15:06 +0100
+Subject: [PATCH] USB: bcma: make helper creating platform dev more generic
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Having "bool ohci" argument in bcma_hcd_create_pdev function limited it
+to support two cases only (OHCI and EHCI) and put too much logic in it.
+Lets make caller pass all required data. This adds few extra arguments
+to the function call but will allow us to reuse this code and handle
+more cases in the future (e.g. add XHCI support).
+
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/host/bcma-hcd.c | 24 +++++++++++++-----------
+ 1 file changed, 13 insertions(+), 11 deletions(-)
+
+--- a/drivers/usb/host/bcma-hcd.c
++++ b/drivers/usb/host/bcma-hcd.c
+@@ -244,7 +244,10 @@ static const struct usb_ehci_pdata ehci_
+ static const struct usb_ohci_pdata ohci_pdata = {
+ };
+-static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev, bool ohci, u32 addr)
++static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev,
++                                                  const char *name, u32 addr,
++                                                  const void *data,
++                                                  size_t size)
+ {
+       struct platform_device *hci_dev;
+       struct resource hci_res[2];
+@@ -259,8 +262,7 @@ static struct platform_device *bcma_hcd_
+       hci_res[1].start = dev->irq;
+       hci_res[1].flags = IORESOURCE_IRQ;
+-      hci_dev = platform_device_alloc(ohci ? "ohci-platform" :
+-                                      "ehci-platform" , 0);
++      hci_dev = platform_device_alloc(name, 0);
+       if (!hci_dev)
+               return ERR_PTR(-ENOMEM);
+@@ -271,12 +273,8 @@ static struct platform_device *bcma_hcd_
+                                           ARRAY_SIZE(hci_res));
+       if (ret)
+               goto err_alloc;
+-      if (ohci)
+-              ret = platform_device_add_data(hci_dev, &ohci_pdata,
+-                                             sizeof(ohci_pdata));
+-      else
+-              ret = platform_device_add_data(hci_dev, &ehci_pdata,
+-                                             sizeof(ehci_pdata));
++      if (data)
++              ret = platform_device_add_data(hci_dev, data, size);
+       if (ret)
+               goto err_alloc;
+       ret = platform_device_add(hci_dev);
+@@ -333,11 +331,15 @@ static int bcma_hcd_probe(struct bcma_de
+           && chipinfo->rev == 0)
+               ohci_addr = 0x18009000;
+-      usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, true, ohci_addr);
++      usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, "ohci-platform",
++                                               ohci_addr, &ohci_pdata,
++                                               sizeof(ohci_pdata));
+       if (IS_ERR(usb_dev->ohci_dev))
+               return PTR_ERR(usb_dev->ohci_dev);
+-      usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, false, dev->addr);
++      usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, "ehci-platform",
++                                               dev->addr, &ehci_pdata,
++                                               sizeof(ehci_pdata));
+       if (IS_ERR(usb_dev->ehci_dev)) {
+               err = PTR_ERR(usb_dev->ehci_dev);
+               goto err_unregister_ohci_dev;
diff --git a/target/linux/bcm53xx/patches-3.18/084-02-USB-bcma-separate-code-initializing-USB-2.0-core.patch b/target/linux/bcm53xx/patches-3.18/084-02-USB-bcma-separate-code-initializing-USB-2.0-core.patch
new file mode 100644 (file)
index 0000000..36ce273
--- /dev/null
@@ -0,0 +1,116 @@
+From adbff3a4f93d8501e8ae11906268e21b086d57ed Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Date: Sat, 5 Dec 2015 13:15:07 +0100
+Subject: [PATCH] USB: bcma: separate code initializing USB 2.0 core
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This splits one big probing function into two smaller ones. The main one
+is now responsible for the generic stuff: allocating memory & enabling
+power using GPIO. The new one contains code that is specific to the USB
+2.0 bcma core.
+This will allow adding support for the USB 3.0 bcma core (handling XHCI)
+in the future.
+
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/host/bcma-hcd.c | 59 ++++++++++++++++++++++++++++++---------------
+ 1 file changed, 39 insertions(+), 20 deletions(-)
+
+--- a/drivers/usb/host/bcma-hcd.c
++++ b/drivers/usb/host/bcma-hcd.c
+@@ -35,6 +35,7 @@ MODULE_DESCRIPTION("Common USB driver fo
+ MODULE_LICENSE("GPL");
+ struct bcma_hcd_device {
++      struct bcma_device *core;
+       struct platform_device *ehci_dev;
+       struct platform_device *ohci_dev;
+       struct gpio_desc *gpio_desc;
+@@ -288,31 +289,16 @@ err_alloc:
+       return ERR_PTR(ret);
+ }
+-static int bcma_hcd_probe(struct bcma_device *dev)
++static int bcma_hcd_usb20_init(struct bcma_hcd_device *usb_dev)
+ {
+-      int err;
++      struct bcma_device *dev = usb_dev->core;
++      struct bcma_chipinfo *chipinfo = &dev->bus->chipinfo;
+       u32 ohci_addr;
+-      struct bcma_hcd_device *usb_dev;
+-      struct bcma_chipinfo *chipinfo;
+-
+-      chipinfo = &dev->bus->chipinfo;
+-
+-      /* TODO: Probably need checks here; is the core connected? */
++      int err;
+       if (dma_set_mask_and_coherent(dev->dma_dev, DMA_BIT_MASK(32)))
+               return -EOPNOTSUPP;
+-      usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
+-                             GFP_KERNEL);
+-      if (!usb_dev)
+-              return -ENOMEM;
+-
+-      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:
+               bcma_hcd_init_chip_arm(dev);
+@@ -345,7 +331,6 @@ static int bcma_hcd_probe(struct bcma_de
+               goto err_unregister_ohci_dev;
+       }
+-      bcma_set_drvdata(dev, usb_dev);
+       return 0;
+ err_unregister_ohci_dev:
+@@ -353,6 +338,40 @@ err_unregister_ohci_dev:
+       return err;
+ }
++static int bcma_hcd_probe(struct bcma_device *core)
++{
++      int err;
++      struct bcma_hcd_device *usb_dev;
++
++      /* TODO: Probably need checks here; is the core connected? */
++
++      usb_dev = devm_kzalloc(&core->dev, sizeof(struct bcma_hcd_device),
++                             GFP_KERNEL);
++      if (!usb_dev)
++              return -ENOMEM;
++      usb_dev->core = core;
++
++      if (core->dev.of_node)
++              usb_dev->gpio_desc = devm_get_gpiod_from_child(&core->dev, "vcc",
++                                                             &core->dev.of_node->fwnode);
++      if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
++              gpiod_direction_output(usb_dev->gpio_desc, 1);
++
++      switch (core->id.id) {
++      case BCMA_CORE_USB20_HOST:
++      case BCMA_CORE_NS_USB20:
++              err = bcma_hcd_usb20_init(usb_dev);
++              if (err)
++                      return err;
++              break;
++      default:
++              return -ENODEV;
++      }
++
++      bcma_set_drvdata(core, usb_dev);
++      return 0;
++}
++
+ static void bcma_hcd_remove(struct bcma_device *dev)
+ {
+       struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);
diff --git a/target/linux/bcm53xx/patches-3.18/085-USB-bcma-use-simpler-devm-helper-for-getting-vcc-GPI.patch b/target/linux/bcm53xx/patches-3.18/085-USB-bcma-use-simpler-devm-helper-for-getting-vcc-GPI.patch
new file mode 100644 (file)
index 0000000..840669c
--- /dev/null
@@ -0,0 +1,34 @@
+From 1507372b97a098fd51b92c4dbdbbcd65cba26939 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Date: Wed, 23 Mar 2016 12:37:11 +0100
+Subject: [PATCH] USB: bcma: use simpler devm helper for getting vcc GPIO
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Thanks to switching to devm_gpiod_get:
+1) We don't have to pass fwnode pointer
+2) We can request initial GPIO value at getting call
+This was successfully tested on Netgear R6250 (BCM4708).
+
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/host/bcma-hcd.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+--- a/drivers/usb/host/bcma-hcd.c
++++ b/drivers/usb/host/bcma-hcd.c
+@@ -352,10 +352,8 @@ static int bcma_hcd_probe(struct bcma_de
+       usb_dev->core = core;
+       if (core->dev.of_node)
+-              usb_dev->gpio_desc = devm_get_gpiod_from_child(&core->dev, "vcc",
+-                                                             &core->dev.of_node->fwnode);
+-      if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
+-              gpiod_direction_output(usb_dev->gpio_desc, 1);
++              usb_dev->gpio_desc = devm_gpiod_get(&core->dev, "vcc",
++                                                  GPIOD_OUT_HIGH);
+       switch (core->id.id) {
+       case BCMA_CORE_USB20_HOST:
diff --git a/target/linux/bcm53xx/patches-3.18/180-USB-bcma-remove-chip-id-check.patch b/target/linux/bcm53xx/patches-3.18/180-USB-bcma-remove-chip-id-check.patch
deleted file mode 100644 (file)
index e5e3010..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-From baf3d128e5bdf9d322539609133a15b493b0c2ef Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Thu, 11 Jun 2015 22:57:35 +0200
-Subject: [PATCH] USB: bcma: remove chip id check
-
-I have never seen any bcma device with an USB host core which was not a
-SoC, the bcma devices have an USB device core with a different core id.
-Some SoC have IDs with 47XX and 53XX in decimal form which would be
-rejected by this check. Instead of fixing this check just remove it.
-
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
----
- drivers/usb/host/bcma-hcd.c | 5 -----
- 1 file changed, 5 deletions(-)
-
---- a/drivers/usb/host/bcma-hcd.c
-+++ b/drivers/usb/host/bcma-hcd.c
-@@ -214,16 +214,11 @@ err_alloc:
- static int bcma_hcd_probe(struct bcma_device *dev)
- {
-       int err;
--      u16 chipid_top;
-       u32 ohci_addr;
-       struct bcma_hcd_device *usb_dev;
-       struct bcma_chipinfo *chipinfo;
-       chipinfo = &dev->bus->chipinfo;
--      /* USBcores are only connected on embedded devices. */
--      chipid_top = (chipinfo->id & 0xFF00);
--      if (chipid_top != 0x4700 && chipid_top != 0x5300)
--              return -ENODEV;
-       /* TODO: Probably need checks here; is the core connected? */
diff --git a/target/linux/bcm53xx/patches-3.18/181-USB-bcma-replace-numbers-with-constants.patch b/target/linux/bcm53xx/patches-3.18/181-USB-bcma-replace-numbers-with-constants.patch
deleted file mode 100644 (file)
index 5ae4e0d..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-From f5bc834917a8b1b9487749bdfe8eda52a01967b4 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Thu, 11 Jun 2015 22:57:36 +0200
-Subject: [PATCH] USB: bcma: replace numbers with constants
-
-The constants for these numbers were added long time ago, use them.
-
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
----
- drivers/usb/host/bcma-hcd.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
---- a/drivers/usb/host/bcma-hcd.c
-+++ b/drivers/usb/host/bcma-hcd.c
-@@ -233,7 +233,8 @@ static int bcma_hcd_probe(struct bcma_de
-       /* In AI chips EHCI is addrspace 0, OHCI is 1 */
-       ohci_addr = dev->addr_s[0];
--      if ((chipinfo->id == 0x5357 || chipinfo->id == 0x4749)
-+      if ((chipinfo->id == BCMA_CHIP_ID_BCM5357 ||
-+           chipinfo->id == BCMA_CHIP_ID_BCM4749)
-           && chipinfo->rev == 0)
-               ohci_addr = 0x18009000;
diff --git a/target/linux/bcm53xx/patches-3.18/182-USB-bcma-use-devm_kzalloc.patch b/target/linux/bcm53xx/patches-3.18/182-USB-bcma-use-devm_kzalloc.patch
deleted file mode 100644 (file)
index 700d354..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-From 93724affb195149df6f7630901d878f6e273fa02 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Thu, 11 Jun 2015 22:57:37 +0200
-Subject: [PATCH] USB: bcma: use devm_kzalloc
-
-Instead of manually handling the frees use devm. There was also a free
-missing in the unregister call which is not needed with devm.
-
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
----
- drivers/usb/host/bcma-hcd.c | 11 ++++-------
- 1 file changed, 4 insertions(+), 7 deletions(-)
-
---- a/drivers/usb/host/bcma-hcd.c
-+++ b/drivers/usb/host/bcma-hcd.c
-@@ -225,7 +225,8 @@ static int bcma_hcd_probe(struct bcma_de
-       if (dma_set_mask_and_coherent(dev->dma_dev, DMA_BIT_MASK(32)))
-               return -EOPNOTSUPP;
--      usb_dev = kzalloc(sizeof(struct bcma_hcd_device), GFP_KERNEL);
-+      usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
-+                             GFP_KERNEL);
-       if (!usb_dev)
-               return -ENOMEM;
-@@ -239,10 +240,8 @@ static int bcma_hcd_probe(struct bcma_de
-               ohci_addr = 0x18009000;
-       usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, true, ohci_addr);
--      if (IS_ERR(usb_dev->ohci_dev)) {
--              err = PTR_ERR(usb_dev->ohci_dev);
--              goto err_free_usb_dev;
--      }
-+      if (IS_ERR(usb_dev->ohci_dev))
-+              return PTR_ERR(usb_dev->ohci_dev);
-       usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, false, dev->addr);
-       if (IS_ERR(usb_dev->ehci_dev)) {
-@@ -255,8 +254,6 @@ static int bcma_hcd_probe(struct bcma_de
- err_unregister_ohci_dev:
-       platform_device_unregister(usb_dev->ohci_dev);
--err_free_usb_dev:
--      kfree(usb_dev);
-       return err;
- }
diff --git a/target/linux/bcm53xx/patches-3.18/183-USB-bcma-fix-error-handling-in-bcma_hcd_create_pdev.patch b/target/linux/bcm53xx/patches-3.18/183-USB-bcma-fix-error-handling-in-bcma_hcd_create_pdev.patch
deleted file mode 100644 (file)
index 91cd0fa..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-From 232996d1ba3002e7e80b18075e2838fc86f21412 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Thu, 11 Jun 2015 22:57:38 +0200
-Subject: [PATCH] USB: bcma: fix error handling in bcma_hcd_create_pdev()
-
-This patch makes bcma_hcd_create_pdev() not return NULL, but a prober
-error code in case of an error.
-
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
----
- drivers/usb/host/bcma-hcd.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/drivers/usb/host/bcma-hcd.c
-+++ b/drivers/usb/host/bcma-hcd.c
-@@ -169,7 +169,7 @@ static struct platform_device *bcma_hcd_
- {
-       struct platform_device *hci_dev;
-       struct resource hci_res[2];
--      int ret = -ENOMEM;
-+      int ret;
-       memset(hci_res, 0, sizeof(hci_res));
-@@ -183,7 +183,7 @@ static struct platform_device *bcma_hcd_
-       hci_dev = platform_device_alloc(ohci ? "ohci-platform" :
-                                       "ehci-platform" , 0);
-       if (!hci_dev)
--              return NULL;
-+              return ERR_PTR(-ENOMEM);
-       hci_dev->dev.parent = &dev->dev;
-       hci_dev->dev.dma_mask = &hci_dev->dev.coherent_dma_mask;
diff --git a/target/linux/bcm53xx/patches-3.18/184-USB-bcma-add-bcm53xx-support.patch b/target/linux/bcm53xx/patches-3.18/184-USB-bcma-add-bcm53xx-support.patch
deleted file mode 100644 (file)
index 920efdc..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-From b65851f41c22b8c69b8fe9ca7782d19ed2155efc Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Thu, 11 Jun 2015 22:57:39 +0200
-Subject: [PATCH] USB: bcma: add bcm53xx support
-
-The Broadcom ARM SoCs with this usb core need a different
-initialization and they have a different core id. This patch adds
-support for these USB 2.0 core.
-
-Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
----
- drivers/usb/host/bcma-hcd.c | 81 +++++++++++++++++++++++++++++++++++++++++++--
- 1 file changed, 78 insertions(+), 3 deletions(-)
-
---- a/drivers/usb/host/bcma-hcd.c
-+++ b/drivers/usb/host/bcma-hcd.c
-@@ -2,7 +2,8 @@
-  * Broadcom specific Advanced Microcontroller Bus
-  * Broadcom USB-core driver (BCMA bus glue)
-  *
-- * Copyright 2011-2012 Hauke Mehrtens <hauke@hauke-m.de>
-+ * Copyright 2011-2015 Hauke Mehrtens <hauke@hauke-m.de>
-+ * Copyright 2015 Felix Fietkau <nbd@openwrt.org>
-  *
-  * Based on ssb-ohci driver
-  * Copyright 2007 Michael Buesch <m@bues.ch>
-@@ -88,7 +89,7 @@ static void bcma_hcd_4716wa(struct bcma_
- }
- /* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */
--static void bcma_hcd_init_chip(struct bcma_device *dev)
-+static void bcma_hcd_init_chip_mips(struct bcma_device *dev)
- {
-       u32 tmp;
-@@ -159,6 +160,70 @@ static void bcma_hcd_init_chip(struct bc
-       }
- }
-+static void bcma_hcd_init_chip_arm_phy(struct bcma_device *dev)
-+{
-+      struct bcma_device *arm_core;
-+      void __iomem *dmu;
-+
-+      arm_core = bcma_find_core(dev->bus, BCMA_CORE_ARMCA9);
-+      if (!arm_core) {
-+              dev_err(&dev->dev, "can not find ARM Cortex A9 ihost core\n");
-+              return;
-+      }
-+
-+      dmu = ioremap_nocache(arm_core->addr_s[0], 0x1000);
-+      if (!dmu) {
-+              dev_err(&dev->dev, "can not map ARM Cortex A9 ihost core\n");
-+              return;
-+      }
-+
-+      /* Unlock DMU PLL settings */
-+      iowrite32(0x0000ea68, dmu + 0x180);
-+
-+      /* Write USB 2.0 PLL control setting */
-+      iowrite32(0x00dd10c3, dmu + 0x164);
-+
-+      /* Lock DMU PLL settings */
-+      iowrite32(0x00000000, dmu + 0x180);
-+
-+      iounmap(dmu);
-+}
-+
-+static void bcma_hcd_init_chip_arm_hc(struct bcma_device *dev)
-+{
-+      u32 val;
-+
-+      /*
-+       * Delay after PHY initialized to ensure HC is ready to be configured
-+       */
-+      usleep_range(1000, 2000);
-+
-+      /* Set packet buffer OUT threshold */
-+      val = bcma_read32(dev, 0x94);
-+      val &= 0xffff;
-+      val |= 0x80 << 16;
-+      bcma_write32(dev, 0x94, val);
-+
-+      /* Enable break memory transfer */
-+      val = bcma_read32(dev, 0x9c);
-+      val |= 1;
-+      bcma_write32(dev, 0x9c, val);
-+}
-+
-+static void bcma_hcd_init_chip_arm(struct bcma_device *dev)
-+{
-+      bcma_core_enable(dev, 0);
-+
-+      if (dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM4707 ||
-+          dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM53018) {
-+              if (dev->bus->chipinfo.pkg == BCMA_PKG_ID_BCM4707 ||
-+                  dev->bus->chipinfo.pkg == BCMA_PKG_ID_BCM4708)
-+                      bcma_hcd_init_chip_arm_phy(dev);
-+
-+              bcma_hcd_init_chip_arm_hc(dev);
-+      }
-+}
-+
- static const struct usb_ehci_pdata ehci_pdata = {
- };
-@@ -230,7 +295,16 @@ static int bcma_hcd_probe(struct bcma_de
-       if (!usb_dev)
-               return -ENOMEM;
--      bcma_hcd_init_chip(dev);
-+      switch (dev->id.id) {
-+      case BCMA_CORE_NS_USB20:
-+              bcma_hcd_init_chip_arm(dev);
-+              break;
-+      case BCMA_CORE_USB20_HOST:
-+              bcma_hcd_init_chip_mips(dev);
-+              break;
-+      default:
-+              return -ENODEV;
-+      }
-       /* In AI chips EHCI is addrspace 0, OHCI is 1 */
-       ohci_addr = dev->addr_s[0];
-@@ -299,6 +373,7 @@ static int bcma_hcd_resume(struct bcma_d
- static const struct bcma_device_id bcma_hcd_table[] = {
-       BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, BCMA_ANY_CLASS),
-+      BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_USB20, BCMA_ANY_REV, BCMA_ANY_CLASS),
-       BCMA_CORETABLE_END
- };
- MODULE_DEVICE_TABLE(bcma, bcma_hcd_table);
diff --git a/target/linux/bcm53xx/patches-3.18/185-USB-bcma-add-support-for-controlling-bus-power-throu.patch b/target/linux/bcm53xx/patches-3.18/185-USB-bcma-add-support-for-controlling-bus-power-throu.patch
deleted file mode 100644 (file)
index d9a8a1e..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-From f3cf44a313b3687efd55ba091558e20a4d218c31 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Thu, 11 Jun 2015 22:57:40 +0200
-Subject: [PATCH] USB: bcma: add support for controlling bus power through GPIO
-
-On some boards a GPIO is needed to activate USB controller. Make it
-possible to specify such a GPIO in device tree.
-
-Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
----
- drivers/usb/host/bcma-hcd.c | 24 ++++++++++++++++++++++++
- 1 file changed, 24 insertions(+)
-
---- a/drivers/usb/host/bcma-hcd.c
-+++ b/drivers/usb/host/bcma-hcd.c
-@@ -24,6 +24,8 @@
- #include <linux/platform_device.h>
- #include <linux/module.h>
- #include <linux/slab.h>
-+#include <linux/of.h>
-+#include <linux/of_gpio.h>
- #include <linux/usb/ehci_pdriver.h>
- #include <linux/usb/ohci_pdriver.h>
-@@ -224,6 +226,23 @@ static void bcma_hcd_init_chip_arm(struc
-       }
- }
-+static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
-+{
-+      int gpio;
-+
-+      gpio = of_get_named_gpio(dev->dev.of_node, "vcc-gpio", 0);
-+      if (!gpio_is_valid(gpio))
-+              return;
-+
-+      if (val) {
-+              gpio_request(gpio, "bcma-hcd-gpio");
-+              gpio_set_value(gpio, 1);
-+      } else {
-+              gpio_set_value(gpio, 0);
-+              gpio_free(gpio);
-+      }
-+}
-+
- static const struct usb_ehci_pdata ehci_pdata = {
- };
-@@ -295,6 +314,8 @@ static int bcma_hcd_probe(struct bcma_de
-       if (!usb_dev)
-               return -ENOMEM;
-+      bcma_hci_platform_power_gpio(dev, true);
-+
-       switch (dev->id.id) {
-       case BCMA_CORE_NS_USB20:
-               bcma_hcd_init_chip_arm(dev);
-@@ -347,6 +368,7 @@ static void bcma_hcd_remove(struct bcma_
- static void bcma_hcd_shutdown(struct bcma_device *dev)
- {
-+      bcma_hci_platform_power_gpio(dev, false);
-       bcma_core_disable(dev, 0);
- }
-@@ -354,6 +376,7 @@ static void bcma_hcd_shutdown(struct bcm
- static int bcma_hcd_suspend(struct bcma_device *dev)
- {
-+      bcma_hci_platform_power_gpio(dev, false);
-       bcma_core_disable(dev, 0);
-       return 0;
-@@ -361,6 +384,7 @@ static int bcma_hcd_suspend(struct bcma_
- static int bcma_hcd_resume(struct bcma_device *dev)
- {
-+      bcma_hci_platform_power_gpio(dev, true);
-       bcma_core_enable(dev, 0);
-       return 0;
diff --git a/target/linux/bcm53xx/patches-3.18/186-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch b/target/linux/bcm53xx/patches-3.18/186-USB-bcma-switch-to-GPIO-descriptor-for-power-control.patch
deleted file mode 100644 (file)
index f1995d1..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-From 0cb136f9882e4649ad6160bb7b48955ff728888c Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
-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 <zajec5@gmail.com>
----
- 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:
diff --git a/target/linux/bcm53xx/patches-3.18/810-USB-bcma-make-helper-creating-platform-dev-more-gene.patch b/target/linux/bcm53xx/patches-3.18/810-USB-bcma-make-helper-creating-platform-dev-more-gene.patch
deleted file mode 100644 (file)
index e664435..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-From 5b4fed9fc917cc2bfc5297eeab03aeba5d340618 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
-Date: Tue, 16 Jun 2015 12:33:46 +0200
-Subject: [PATCH] USB: bcma: make helper creating platform dev more generic
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Having "bool ohci" argument bounded us to two cases only and didn't
-allow re-using this code for XHCI.
-
-Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
----
- drivers/usb/host/bcma-hcd.c | 24 +++++++++++++-----------
- 1 file changed, 13 insertions(+), 11 deletions(-)
-
---- a/drivers/usb/host/bcma-hcd.c
-+++ b/drivers/usb/host/bcma-hcd.c
-@@ -244,7 +244,10 @@ static const struct usb_ehci_pdata ehci_
- static const struct usb_ohci_pdata ohci_pdata = {
- };
--static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev, bool ohci, u32 addr)
-+static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev,
-+                                                  const char *name, u32 addr,
-+                                                  const void *data,
-+                                                  size_t size)
- {
-       struct platform_device *hci_dev;
-       struct resource hci_res[2];
-@@ -259,8 +262,7 @@ static struct platform_device *bcma_hcd_
-       hci_res[1].start = dev->irq;
-       hci_res[1].flags = IORESOURCE_IRQ;
--      hci_dev = platform_device_alloc(ohci ? "ohci-platform" :
--                                      "ehci-platform" , 0);
-+      hci_dev = platform_device_alloc(name, 0);
-       if (!hci_dev)
-               return ERR_PTR(-ENOMEM);
-@@ -271,12 +273,8 @@ static struct platform_device *bcma_hcd_
-                                           ARRAY_SIZE(hci_res));
-       if (ret)
-               goto err_alloc;
--      if (ohci)
--              ret = platform_device_add_data(hci_dev, &ohci_pdata,
--                                             sizeof(ohci_pdata));
--      else
--              ret = platform_device_add_data(hci_dev, &ehci_pdata,
--                                             sizeof(ehci_pdata));
-+      if (data)
-+              ret = platform_device_add_data(hci_dev, data, size);
-       if (ret)
-               goto err_alloc;
-       ret = platform_device_add(hci_dev);
-@@ -333,11 +331,15 @@ static int bcma_hcd_probe(struct bcma_de
-           && chipinfo->rev == 0)
-               ohci_addr = 0x18009000;
--      usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, true, ohci_addr);
-+      usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, "ohci-platform",
-+                                               ohci_addr, &ohci_pdata,
-+                                               sizeof(ohci_pdata));
-       if (IS_ERR(usb_dev->ohci_dev))
-               return PTR_ERR(usb_dev->ohci_dev);
--      usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, false, dev->addr);
-+      usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, "ehci-platform",
-+                                               dev->addr, &ehci_pdata,
-+                                               sizeof(ehci_pdata));
-       if (IS_ERR(usb_dev->ehci_dev)) {
-               err = PTR_ERR(usb_dev->ehci_dev);
-               goto err_unregister_ohci_dev;
diff --git a/target/linux/bcm53xx/patches-3.18/811-USB-bcma-use-separated-function-for-USB-2.0-initiali.patch b/target/linux/bcm53xx/patches-3.18/811-USB-bcma-use-separated-function-for-USB-2.0-initiali.patch
deleted file mode 100644 (file)
index 4c30442..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-From 4aed231f49954114d5ae23e97789e9aa540a0b70 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
-Date: Tue, 16 Jun 2015 12:52:07 +0200
-Subject: [PATCH] USB: bcma: use separated function for USB 2.0 initialization
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This will allow adding USB 3.0 (XHCI) support cleanly.
-
-Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
----
- drivers/usb/host/bcma-hcd.c | 51 +++++++++++++++++++++++++++++++--------------
- 1 file changed, 35 insertions(+), 16 deletions(-)
-
---- a/drivers/usb/host/bcma-hcd.c
-+++ b/drivers/usb/host/bcma-hcd.c
-@@ -35,6 +35,7 @@ MODULE_DESCRIPTION("Common USB driver fo
- MODULE_LICENSE("GPL");
- struct bcma_hcd_device {
-+      struct bcma_device *core;
-       struct platform_device *ehci_dev;
-       struct platform_device *ohci_dev;
-       struct gpio_desc *gpio_desc;
-@@ -288,31 +289,16 @@ err_alloc:
-       return ERR_PTR(ret);
- }
--static int bcma_hcd_probe(struct bcma_device *dev)
-+static int bcma_hcd_usb20_init(struct bcma_hcd_device *usb_dev)
- {
--      int err;
-+      struct bcma_device *dev = usb_dev->core;
-+      struct bcma_chipinfo *chipinfo = &dev->bus->chipinfo;
-       u32 ohci_addr;
--      struct bcma_hcd_device *usb_dev;
--      struct bcma_chipinfo *chipinfo;
--
--      chipinfo = &dev->bus->chipinfo;
--
--      /* TODO: Probably need checks here; is the core connected? */
-+      int err;
-       if (dma_set_mask_and_coherent(dev->dma_dev, DMA_BIT_MASK(32)))
-               return -EOPNOTSUPP;
--      usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
--                             GFP_KERNEL);
--      if (!usb_dev)
--              return -ENOMEM;
--
--      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:
-               bcma_hcd_init_chip_arm(dev);
-@@ -345,7 +331,6 @@ static int bcma_hcd_probe(struct bcma_de
-               goto err_unregister_ohci_dev;
-       }
--      bcma_set_drvdata(dev, usb_dev);
-       return 0;
- err_unregister_ohci_dev:
-@@ -353,6 +338,40 @@ err_unregister_ohci_dev:
-       return err;
- }
-+static int bcma_hcd_probe(struct bcma_device *dev)
-+{
-+      int err;
-+      struct bcma_hcd_device *usb_dev;
-+
-+      /* TODO: Probably need checks here; is the core connected? */
-+
-+      usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
-+                             GFP_KERNEL);
-+      if (!usb_dev)
-+              return -ENOMEM;
-+      usb_dev->core = dev;
-+
-+      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_USB20_HOST:
-+      case BCMA_CORE_NS_USB20:
-+              err = bcma_hcd_usb20_init(usb_dev);
-+              if (err)
-+                      return err;
-+              break;
-+      default:
-+              return -ENODEV;
-+      }
-+
-+      bcma_set_drvdata(dev, usb_dev);
-+      return 0;
-+}
-+
- static void bcma_hcd_remove(struct bcma_device *dev)
- {
-       struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);
index 52d423164950d8dc71646c0c7e2f38506458b7c0..08876f5b62001f28238ac6d3cb62b38977eae680 100644 (file)
@@ -185,10 +185,10 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
 +      return 0;
 +}
 +
- static int bcma_hcd_probe(struct bcma_device *dev)
+ static int bcma_hcd_probe(struct bcma_device *core)
  {
        int err;
-@@ -364,6 +525,11 @@ static int bcma_hcd_probe(struct bcma_de
+@@ -362,6 +523,11 @@ static int bcma_hcd_probe(struct bcma_de
                if (err)
                        return err;
                break;
@@ -200,7 +200,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
        default:
                return -ENODEV;
        }
-@@ -377,11 +543,14 @@ static void bcma_hcd_remove(struct bcma_
+@@ -375,11 +541,14 @@ static void bcma_hcd_remove(struct bcma_
        struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);
        struct platform_device *ohci_dev = usb_dev->ohci_dev;
        struct platform_device *ehci_dev = usb_dev->ehci_dev;
@@ -215,7 +215,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  
        bcma_core_disable(dev, 0);
  }
-@@ -418,6 +587,7 @@ static int bcma_hcd_resume(struct bcma_d
+@@ -416,6 +585,7 @@ static int bcma_hcd_resume(struct bcma_d
  static const struct bcma_device_id bcma_hcd_table[] = {
        BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, BCMA_ANY_CLASS),
        BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_USB20, BCMA_ANY_REV, BCMA_ANY_CLASS),
diff --git a/target/linux/bcm53xx/patches-3.18/813-USB-bcma-use-simpler-devm_gpiod_get.patch b/target/linux/bcm53xx/patches-3.18/813-USB-bcma-use-simpler-devm_gpiod_get.patch
deleted file mode 100644 (file)
index 84355ac..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
-Date: Sat, 2 Jan 2016 11:26:28 +0100
-Subject: [PATCH] USB: bcma: use simpler devm_gpiod_get
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
----
- drivers/usb/host/bcma-hcd.c | 3 +--
- 1 file changed, 1 insertion(+), 2 deletions(-)
-
---- a/drivers/usb/host/bcma-hcd.c
-+++ b/drivers/usb/host/bcma-hcd.c
-@@ -513,8 +513,7 @@ static int bcma_hcd_probe(struct bcma_de
-       usb_dev->core = dev;
-       if (dev->dev.of_node)
--              usb_dev->gpio_desc = devm_get_gpiod_from_child(&dev->dev, "vcc",
--                                                             &dev->dev.of_node->fwnode);
-+              usb_dev->gpio_desc = devm_gpiod_get(&dev->dev, "vcc");
-       if (!IS_ERR_OR_NULL(usb_dev->gpio_desc))
-               gpiod_direction_output(usb_dev->gpio_desc, 1);