[PATCH] mmc: Allow sdhci platform drivers to set quirks2 from platform data

2013-07-18 Thread Al Cooper
Signed-off-by: Al Cooper 
---
 drivers/mmc/host/sdhci-pltfm.c |4 +++-
 drivers/mmc/host/sdhci-pltfm.h |1 +
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index 3145a78..e605509 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -149,8 +149,10 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device 
*pdev,
host->ops = pdata->ops;
else
host->ops = &sdhci_pltfm_ops;
-   if (pdata)
+   if (pdata) {
host->quirks = pdata->quirks;
+   host->quirks2 = pdata->quirks2;
+   }
host->irq = platform_get_irq(pdev, 0);
 
if (!request_mem_region(iomem->start, resource_size(iomem),
diff --git a/drivers/mmc/host/sdhci-pltfm.h b/drivers/mmc/host/sdhci-pltfm.h
index 153b6c5..2940ee3 100644
--- a/drivers/mmc/host/sdhci-pltfm.h
+++ b/drivers/mmc/host/sdhci-pltfm.h
@@ -18,6 +18,7 @@
 struct sdhci_pltfm_data {
struct sdhci_ops *ops;
unsigned int quirks;
+   unsigned int quirks2;
 };
 
 struct sdhci_pltfm_host {
-- 
1.7.6


--
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


[PATCH] usb: Add Device Tree support to XHCI Platform driver

2013-07-18 Thread Al Cooper
Add Device Tree match table. Setup dma_mask and coherent_dma_mask
if they're not already set.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/xhci-plat.c |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 51e22bf..60b3ff4 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -14,6 +14,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "xhci.h"
 
@@ -91,6 +93,16 @@ static int xhci_plat_probe(struct platform_device *pdev)
int ret;
int irq;
 
+   /*
+* Right now device-tree probed devices don't get dma_mask set.
+* Since shared usb code relies on it, set it here for now.
+* Once we have dma capability bindings this can go away.
+*/
+   if (!pdev->dev.dma_mask)
+   pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
+   if (!pdev->dev.coherent_dma_mask)
+   pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+
if (usb_disabled())
return -ENODEV;
 
@@ -186,11 +198,17 @@ static int xhci_plat_remove(struct platform_device *dev)
return 0;
 }
 
+static const struct of_device_id usb_xhci_of_match[] = {
+   { .compatible = "xhci-hcd" },
+   {},
+};
+
 static struct platform_driver usb_xhci_driver = {
.probe  = xhci_plat_probe,
.remove = xhci_plat_remove,
.driver = {
.name = "xhci-hcd",
+   .of_match_table = of_match_ptr(usb_xhci_of_match),
},
 };
 MODULE_ALIAS("platform:xhci-hcd");
-- 
1.7.6


--
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


[PATCH V2] usb: Add Device Tree support to XHCI Platform driver

2013-07-22 Thread Al Cooper
Add Device Tree match table to xhci-plat.c. Add DT bindings document.

Signed-off-by: Al Cooper 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |   14 ++
 drivers/usb/host/xhci-plat.c   |7 +++
 2 files changed, 21 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usb-xhci.txt

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
new file mode 100644
index 000..654cf3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -0,0 +1,14 @@
+USB XHCI controllers
+
+Required properties:
+  - compatible: should be "usb-xhci".
+  - reg: should contain address and length of the standard XHCI
+register set for the device.
+  - interrupts: one XHCI interrupt should be described here.
+
+Example:
+   xhci@f0931000 {
+   compatible = "usb-xhci";
+   reg = <0xf0931000 0x8c8>;
+   interrupts = <0x0 0x4e 0x0>;
+   };
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index d718134..4c4823a 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "xhci.h"
 
@@ -212,11 +213,17 @@ static int xhci_plat_remove(struct platform_device *dev)
return 0;
 }
 
+static const struct of_device_id usb_xhci_of_match[] = {
+   { .compatible = "usb-xhci" },
+   {},
+};
+
 static struct platform_driver usb_xhci_driver = {
.probe  = xhci_plat_probe,
.remove = xhci_plat_remove,
.driver = {
.name = "xhci-hcd",
+   .of_match_table = of_match_ptr(usb_xhci_of_match),
},
 };
 MODULE_ALIAS("platform:xhci-hcd");
-- 
1.7.6


--
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


[PATCH V3] usb: Add Device Tree support to XHCI Platform driver

2013-07-23 Thread Al Cooper
Add Device Tree match table to xhci-plat.c. Add DT bindings document.

Signed-off-by: Al Cooper 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt | 14 ++
 drivers/usb/host/xhci-plat.c   |  9 +
 2 files changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/usb-xhci.txt

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
new file mode 100644
index 000..654cf3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -0,0 +1,14 @@
+USB XHCI controllers
+
+Required properties:
+  - compatible: should be "usb-xhci".
+  - reg: should contain address and length of the standard XHCI
+register set for the device.
+  - interrupts: one XHCI interrupt should be described here.
+
+Example:
+   xhci@f0931000 {
+   compatible = "usb-xhci";
+   reg = <0xf0931000 0x8c8>;
+   interrupts = <0x0 0x4e 0x0>;
+   };
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index d718134..d70f607 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "xhci.h"
 
@@ -212,11 +213,19 @@ static int xhci_plat_remove(struct platform_device *dev)
return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id usb_xhci_of_match[] = {
+   { .compatible = "usb-xhci" },
+   {},
+};
+#endif
+
 static struct platform_driver usb_xhci_driver = {
.probe  = xhci_plat_probe,
.remove = xhci_plat_remove,
.driver = {
.name = "xhci-hcd",
+   .of_match_table = of_match_ptr(usb_xhci_of_match),
},
 };
 MODULE_ALIAS("platform:xhci-hcd");
-- 
1.8.1.3


--
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


[PATCH V4] usb: Add Device Tree support to XHCI Platform driver

2013-07-23 Thread Al Cooper
Add Device Tree match table to xhci-plat.c. Add DT bindings document.

Signed-off-by: Al Cooper 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt | 14 ++
 drivers/usb/host/xhci-plat.c   | 10 ++
 2 files changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/usb-xhci.txt

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
new file mode 100644
index 000..b88aee7
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -0,0 +1,14 @@
+USB XHCI controllers
+
+Required properties:
+  - compatible: should be "xhci-platform".
+  - reg: should contain address and length of the standard XHCI
+register set for the device.
+  - interrupts: one XHCI interrupt should be described here.
+
+Example:
+   xhci@f0931000 {
+   compatible = "xhci-platform";
+   reg = <0xf0931000 0x8c8>;
+   interrupts = <0x0 0x4e 0x0>;
+   };
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index d718134..d547f24 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "xhci.h"
 
@@ -212,11 +213,20 @@ static int xhci_plat_remove(struct platform_device *dev)
return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id usb_xhci_of_match[] = {
+   { .compatible = "xhci-platform" },
+   {},
+};
+MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
+#endif
+
 static struct platform_driver usb_xhci_driver = {
.probe  = xhci_plat_probe,
.remove = xhci_plat_remove,
.driver = {
.name = "xhci-hcd",
+   .of_match_table = of_match_ptr(usb_xhci_of_match),
},
 };
 MODULE_ALIAS("platform:xhci-hcd");
-- 
1.8.1.3


--
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


[PATCH V5] usb: Add Device Tree support to XHCI Platform driver

2013-07-25 Thread Al Cooper
Add Device Tree match table to xhci-plat.c. Add DT bindings document.

Signed-off-by: Al Cooper 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |   14 ++
 drivers/usb/host/xhci-plat.c   |   10 ++
 2 files changed, 24 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usb-xhci.txt

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
new file mode 100644
index 000..5752df0
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -0,0 +1,14 @@
+USB xHCI controllers
+
+Required properties:
+  - compatible: should be "xhci-platform".
+  - reg: should contain address and length of the standard XHCI
+register set for the device.
+  - interrupts: one XHCI interrupt should be described here.
+
+Example:
+   usb@f0931000 {
+   compatible = "xhci-platform";
+   reg = <0xf0931000 0x8c8>;
+   interrupts = <0x0 0x4e 0x0>;
+   };
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index d718134..fbc11dc 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "xhci.h"
 
@@ -212,11 +213,20 @@ static int xhci_plat_remove(struct platform_device *dev)
return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id usb_xhci_of_match[] = {
+   { .compatible = "xhci-platform" },
+   { },
+};
+MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
+#endif
+
 static struct platform_driver usb_xhci_driver = {
.probe  = xhci_plat_probe,
.remove = xhci_plat_remove,
.driver = {
.name = "xhci-hcd",
+   .of_match_table = of_match_ptr(usb_xhci_of_match),
},
 };
 MODULE_ALIAS("platform:xhci-hcd");
-- 
1.7.6


--
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


[PATCH 0/2] Add Broadcom USB PHY driver for Broadcom STB SoCs

2016-05-27 Thread Al Cooper
Add Broadcom USB PHY driver for Broadcom STB SoCs. This driver in
combination with the generic ohci, ehci and xhci platform drivers
will enable USB1.1, USB2.0 and USB3.0 support.

NOTE: An unrelated patch is in the pipline to move the file
drivers/soc/brcmstb/common.c to drivers/soc/bcm/brcmstb/common.c

Al Cooper (2):
  soc: brcmstb: Add Product ID and Family ID helper functions
  usb: phy: phy-brcm-usb: Add Broadcom STB USB Phy driver

 .../devicetree/bindings/phy/brcm,usb-phy.txt   |  39 +
 MAINTAINERS|   7 +
 drivers/phy/Kconfig|  10 +
 drivers/phy/Makefile   |   2 +
 drivers/phy/phy-brcm-usb-init.c| 792 +
 drivers/phy/phy-brcm-usb-init.h|  49 ++
 drivers/phy/phy-brcm-usb.c | 206 ++
 drivers/soc/brcmstb/common.c   |  12 +
 include/linux/soc/brcmstb/brcmstb.h|  10 +
 9 files changed, 1127 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,usb-phy.txt
 create mode 100644 drivers/phy/phy-brcm-usb-init.c
 create mode 100644 drivers/phy/phy-brcm-usb-init.h
 create mode 100644 drivers/phy/phy-brcm-usb.c

-- 
1.9.0.138.g2de3478

--
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


[PATCH 1/2] soc: brcmstb: Add Product ID and Family ID helper functions

2016-05-27 Thread Al Cooper
Signed-off-by: Al Cooper 
---
 drivers/soc/brcmstb/common.c| 12 
 include/linux/soc/brcmstb/brcmstb.h | 10 ++
 2 files changed, 22 insertions(+)

diff --git a/drivers/soc/brcmstb/common.c b/drivers/soc/brcmstb/common.c
index 94e7335..454f4c2 100644
--- a/drivers/soc/brcmstb/common.c
+++ b/drivers/soc/brcmstb/common.c
@@ -40,6 +40,18 @@ bool soc_is_brcmstb(void)
return of_match_node(brcmstb_machine_match, root) != NULL;
 }
 
+u32 brcmstb_get_family_id(void)
+{
+   return family_id;
+}
+EXPORT_SYMBOL(brcmstb_get_family_id);
+
+u32 brcmstb_get_product_id(void)
+{
+   return product_id;
+}
+EXPORT_SYMBOL(brcmstb_get_product_id);
+
 static const struct of_device_id sun_top_ctrl_match[] = {
{ .compatible = "brcm,brcmstb-sun-top-ctrl", },
{ }
diff --git a/include/linux/soc/brcmstb/brcmstb.h 
b/include/linux/soc/brcmstb/brcmstb.h
index 337ce41..4bf5edd 100644
--- a/include/linux/soc/brcmstb/brcmstb.h
+++ b/include/linux/soc/brcmstb/brcmstb.h
@@ -1,10 +1,20 @@
 #ifndef __BRCMSTB_SOC_H
 #define __BRCMSTB_SOC_H
 
+#define BRCM_ID(reg)   ((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)
+#define BRCM_REV(reg)  ((u32)reg & 0xff)
+
 /*
  * Bus Interface Unit control register setup, must happen early during boot,
  * before SMP is brought up, called by machine entry point.
  */
 void brcmstb_biuctrl_init(void);
 
+/*
+* Helper functions for getting family or product id from the
+* SoC driver.
+*/
+u32 brcmstb_get_family_id(void);
+u32 brcmstb_get_product_id(void);
+
 #endif /* __BRCMSTB_SOC_H */
-- 
1.9.0.138.g2de3478

--
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


[PATCH 2/2] usb: phy: phy-brcm-usb: Add Broadcom STB USB Phy driver

2016-05-27 Thread Al Cooper
Add a new USB Phy driver for Broadcom STB SoCs. This driver
supports all Broadcom STB ARM SoCs. This driver in combination
with the generic ohci, ehci and xhci platform drivers will enable
USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports
the Broadcom UDC gadget driver.

Signed-off-by: Al Cooper 
---
 .../devicetree/bindings/phy/brcm,usb-phy.txt   |  39 +
 MAINTAINERS|   7 +
 drivers/phy/Kconfig|  10 +
 drivers/phy/Makefile   |   2 +
 drivers/phy/phy-brcm-usb-init.c| 792 +
 drivers/phy/phy-brcm-usb-init.h|  49 ++
 drivers/phy/phy-brcm-usb.c | 206 ++
 7 files changed, 1105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,usb-phy.txt
 create mode 100644 drivers/phy/phy-brcm-usb-init.c
 create mode 100644 drivers/phy/phy-brcm-usb-init.h
 create mode 100644 drivers/phy/phy-brcm-usb.c

diff --git a/Documentation/devicetree/bindings/phy/brcm,usb-phy.txt 
b/Documentation/devicetree/bindings/phy/brcm,usb-phy.txt
new file mode 100644
index 000..6652966
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,usb-phy.txt
@@ -0,0 +1,39 @@
+Broadcom STB USB PHY
+
+Required properties:
+ - compatible: brcm,usb-phy
+ - reg: two offset and length pairs. The second pair specifies the
+USB 3.0 related registers and is only required for PHYs
+that support USB 3.0
+ - #phy-cells: Shall be 1 as it expects one argument for setting
+  the type of the PHY. Possible values are 0 (1.1 and 2.0),
+  1 (3.0)
+
+
+Optional Properties:
+- clocks : phandle + clock specifier for the phy clocks
+- clock-names: string, clock name
+- ipp: Invert Port Power
+- ioc: Invert Over Current detection
+- has_xhci: Contains an optional 3.0 PHY
+- device: PHY Device mode. Possible values are: 0 (Host), 1 (Device)
+  or 2 (DRD)
+
+
+
+Example:
+
+usbphy_0: usb-phy@f0470200 {
+   reg = <0xf0470200 0xb8>,
+   <0xf0471940 0x6c0>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "brcm,usb-phy";
+   ioc = <1>;
+   ipp = <1>;
+   #phy-cells = <1>;
+   ranges;
+   has_xhci;
+   clocks = <&sw_usb20>;
+   clock-names = "sw_usb";
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index ed1229e..4d529e7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2631,6 +2631,13 @@ S:   Maintained
 F: drivers/bcma/
 F: include/linux/bcma/
 
+BROADCOM STB USB PHY DRIVER
+M: Al Cooper 
+L: linux-usb@vger.kernel.org
+L: bcm-kernel-feedback-l...@broadcom.com
+S: Supported
+F: drivers/phy/phy-brcm-usb*
+
 BROADCOM SYSTEMPORT ETHERNET DRIVER
 M: Florian Fainelli 
 L: net...@vger.kernel.org
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index b869b98..61a0244 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -432,6 +432,16 @@ config PHY_CYGNUS_PCIE
  Enable this to support the Broadcom Cygnus PCIe PHY.
  If unsure, say N.
 
+config BRCM_USB_PHY
+   tristate "Broadcom USB PHY driver"
+   depends on OF && USB && ARCH_BRCMSTB
+   select GENERIC_PHY
+   default y
+   help
+ Enable this to support the Broadcom USB PHY on
+ Broadcom STB SoCs.
+ If unsure, say Y.
+
 source "drivers/phy/tegra/Kconfig"
 
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9c3e73c..babb0c7 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -9,6 +9,8 @@ obj-$(CONFIG_PHY_BERLIN_SATA)   += phy-berlin-sata.o
 obj-$(CONFIG_PHY_DM816X_USB)   += phy-dm816x-usb.o
 obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
+obj-$(CONFIG_BRCM_USB_PHY) += phy-brcm-usb.o
+obj-$(CONFIG_BRCM_USB_PHY) += phy-brcm-usb-init.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
 obj-$(CONFIG_PHY_LPC18XX_USB_OTG)  += phy-lpc18xx-usb-otg.o
diff --git a/drivers/phy/phy-brcm-usb-init.c b/drivers/phy/phy-brcm-usb-init.c
new file mode 100644
index 000..f5d8c32
--- /dev/null
+++ b/drivers/phy/phy-brcm-usb-init.c
@@ -0,0 +1,792 @@
+/*
+ * Copyright (C) 2014-2016 Broadcom
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documen

[PATCH V2 2/2] usb: phy: phy-brcm-usb: Add Broadcom STB USB Phy driver

2016-05-27 Thread Al Cooper
Add a new USB Phy driver for Broadcom STB SoCs. This driver
supports all Broadcom STB ARM SoCs. This driver in combination
with the generic ohci, ehci and xhci platform drivers will enable
USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports
the Broadcom UDC gadget driver.

Signed-off-by: Al Cooper 
---
 .../bindings/phy/brcm,brcmstb-usb-phy.txt  |  39 +
 MAINTAINERS|   7 +
 drivers/phy/Kconfig|  10 +
 drivers/phy/Makefile   |   2 +
 drivers/phy/phy-brcm-usb-init.c| 792 +
 drivers/phy/phy-brcm-usb-init.h|  49 ++
 drivers/phy/phy-brcm-usb.c | 206 ++
 7 files changed, 1105 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
 create mode 100644 drivers/phy/phy-brcm-usb-init.c
 create mode 100644 drivers/phy/phy-brcm-usb-init.h
 create mode 100644 drivers/phy/phy-brcm-usb.c

diff --git a/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt 
b/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
new file mode 100644
index 000..34fa9dd
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
@@ -0,0 +1,39 @@
+Broadcom STB USB PHY
+
+Required properties:
+ - compatible: brcm,brcmstb-usb-phy
+ - reg: two offset and length pairs. The second pair specifies the
+USB 3.0 related registers and is only required for PHYs
+that support USB 3.0
+ - #phy-cells: Shall be 1 as it expects one argument for setting
+  the type of the PHY. Possible values are 0 (1.1 and 2.0),
+  1 (3.0)
+
+
+Optional Properties:
+- clocks : phandle + clock specifier for the phy clocks
+- clock-names: string, clock name
+- ipp: Invert Port Power
+- ioc: Invert Over Current detection
+- has_xhci: Contains an optional 3.0 PHY
+- device: PHY Device mode. Possible values are: 0 (Host), 1 (Device)
+  or 2 (DRD)
+
+
+
+Example:
+
+usbphy_0: usb-phy@f0470200 {
+   reg = <0xf0470200 0xb8>,
+   <0xf0471940 0x6c0>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "brcm,brcmstb-usb-phy";
+   ioc = <1>;
+   ipp = <1>;
+   #phy-cells = <1>;
+   ranges;
+   has_xhci;
+   clocks = <&sw_usb20>;
+   clock-names = "sw_usb";
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index ed1229e..4d529e7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2631,6 +2631,13 @@ S:   Maintained
 F: drivers/bcma/
 F: include/linux/bcma/
 
+BROADCOM STB USB PHY DRIVER
+M: Al Cooper 
+L: linux-usb@vger.kernel.org
+L: bcm-kernel-feedback-l...@broadcom.com
+S: Supported
+F: drivers/phy/phy-brcm-usb*
+
 BROADCOM SYSTEMPORT ETHERNET DRIVER
 M: Florian Fainelli 
 L: net...@vger.kernel.org
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index b869b98..61a0244 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -432,6 +432,16 @@ config PHY_CYGNUS_PCIE
  Enable this to support the Broadcom Cygnus PCIe PHY.
  If unsure, say N.
 
+config BRCM_USB_PHY
+   tristate "Broadcom USB PHY driver"
+   depends on OF && USB && ARCH_BRCMSTB
+   select GENERIC_PHY
+   default y
+   help
+ Enable this to support the Broadcom USB PHY on
+ Broadcom STB SoCs.
+ If unsure, say Y.
+
 source "drivers/phy/tegra/Kconfig"
 
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9c3e73c..babb0c7 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -9,6 +9,8 @@ obj-$(CONFIG_PHY_BERLIN_SATA)   += phy-berlin-sata.o
 obj-$(CONFIG_PHY_DM816X_USB)   += phy-dm816x-usb.o
 obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
+obj-$(CONFIG_BRCM_USB_PHY) += phy-brcm-usb.o
+obj-$(CONFIG_BRCM_USB_PHY) += phy-brcm-usb-init.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
 obj-$(CONFIG_PHY_LPC18XX_USB_OTG)  += phy-lpc18xx-usb-otg.o
diff --git a/drivers/phy/phy-brcm-usb-init.c b/drivers/phy/phy-brcm-usb-init.c
new file mode 100644
index 000..f5d8c32
--- /dev/null
+++ b/drivers/phy/phy-brcm-usb-init.c
@@ -0,0 +1,792 @@
+/*
+ * Copyright (C) 2014-2016 Broadcom
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions an

[PATCH V2 0/2] Add Broadcom USB PHY driver for Broadcom STB SoCs

2016-05-27 Thread Al Cooper
Add Broadcom USB PHY driver for Broadcom STB SoCs. This driver in
combination with the generic ohci, ehci and xhci platform drivers
will enable USB1.1, USB2.0 and USB3.0 support.

NOTE: An unrelated patch is in the pipline to move the file
drivers/soc/brcmstb/common.c to drivers/soc/bcm/brcmstb/common.c

V2 - Change compatible name from "brcm,usb-phy" to
 "brcm,brcmstb-usb-phy"

Al Cooper (2):
  soc: brcmstb: Add Product ID and Family ID helper functions
  usb: phy: phy-brcm-usb: Add Broadcom STB USB Phy driver

 .../bindings/phy/brcm,brcmstb-usb-phy.txt  |  39 +
 MAINTAINERS|   7 +
 drivers/phy/Kconfig|  10 +
 drivers/phy/Makefile   |   2 +
 drivers/phy/phy-brcm-usb-init.c| 792 +
 drivers/phy/phy-brcm-usb-init.h|  49 ++
 drivers/phy/phy-brcm-usb.c | 206 ++
 drivers/soc/brcmstb/common.c   |  12 +
 include/linux/soc/brcmstb/brcmstb.h|  10 +
 9 files changed, 1127 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
 create mode 100644 drivers/phy/phy-brcm-usb-init.c
 create mode 100644 drivers/phy/phy-brcm-usb-init.h
 create mode 100644 drivers/phy/phy-brcm-usb.c

-- 
1.9.0.138.g2de3478

--
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


[PATCH V2 1/2] soc: brcmstb: Add Product ID and Family ID helper functions

2016-05-27 Thread Al Cooper
Signed-off-by: Al Cooper 
---
 drivers/soc/brcmstb/common.c| 12 
 include/linux/soc/brcmstb/brcmstb.h | 10 ++
 2 files changed, 22 insertions(+)

diff --git a/drivers/soc/brcmstb/common.c b/drivers/soc/brcmstb/common.c
index 94e7335..454f4c2 100644
--- a/drivers/soc/brcmstb/common.c
+++ b/drivers/soc/brcmstb/common.c
@@ -40,6 +40,18 @@ bool soc_is_brcmstb(void)
return of_match_node(brcmstb_machine_match, root) != NULL;
 }
 
+u32 brcmstb_get_family_id(void)
+{
+   return family_id;
+}
+EXPORT_SYMBOL(brcmstb_get_family_id);
+
+u32 brcmstb_get_product_id(void)
+{
+   return product_id;
+}
+EXPORT_SYMBOL(brcmstb_get_product_id);
+
 static const struct of_device_id sun_top_ctrl_match[] = {
{ .compatible = "brcm,brcmstb-sun-top-ctrl", },
{ }
diff --git a/include/linux/soc/brcmstb/brcmstb.h 
b/include/linux/soc/brcmstb/brcmstb.h
index 337ce41..4bf5edd 100644
--- a/include/linux/soc/brcmstb/brcmstb.h
+++ b/include/linux/soc/brcmstb/brcmstb.h
@@ -1,10 +1,20 @@
 #ifndef __BRCMSTB_SOC_H
 #define __BRCMSTB_SOC_H
 
+#define BRCM_ID(reg)   ((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)
+#define BRCM_REV(reg)  ((u32)reg & 0xff)
+
 /*
  * Bus Interface Unit control register setup, must happen early during boot,
  * before SMP is brought up, called by machine entry point.
  */
 void brcmstb_biuctrl_init(void);
 
+/*
+* Helper functions for getting family or product id from the
+* SoC driver.
+*/
+u32 brcmstb_get_family_id(void);
+u32 brcmstb_get_product_id(void);
+
 #endif /* __BRCMSTB_SOC_H */
-- 
1.9.0.138.g2de3478

--
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


[RESEND PATCH V2 2/2] usb: phy: phy-brcm-usb: Add Broadcom STB USB phy driver

2016-06-08 Thread Al Cooper
Add a new USB Phy driver for Broadcom STB SoCs. This driver
supports all Broadcom STB ARM SoCs. This driver in combination
with the generic ohci, ehci and xhci platform drivers will enable
USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports
the Broadcom UDC gadget driver.

Signed-off-by: Al Cooper 
---
 .../bindings/phy/brcm,brcmstb-usb-phy.txt  |  39 +
 MAINTAINERS|   7 +
 drivers/phy/Kconfig|  10 +
 drivers/phy/Makefile   |   2 +
 drivers/phy/phy-brcm-usb-init.c| 792 +
 drivers/phy/phy-brcm-usb-init.h|  49 ++
 drivers/phy/phy-brcm-usb.c | 206 ++
 7 files changed, 1105 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
 create mode 100644 drivers/phy/phy-brcm-usb-init.c
 create mode 100644 drivers/phy/phy-brcm-usb-init.h
 create mode 100644 drivers/phy/phy-brcm-usb.c

diff --git a/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt 
b/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
new file mode 100644
index 000..34fa9dd
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
@@ -0,0 +1,39 @@
+Broadcom STB USB PHY
+
+Required properties:
+ - compatible: brcm,brcmstb-usb-phy
+ - reg: two offset and length pairs. The second pair specifies the
+USB 3.0 related registers and is only required for PHYs
+that support USB 3.0
+ - #phy-cells: Shall be 1 as it expects one argument for setting
+  the type of the PHY. Possible values are 0 (1.1 and 2.0),
+  1 (3.0)
+
+
+Optional Properties:
+- clocks : phandle + clock specifier for the phy clocks
+- clock-names: string, clock name
+- ipp: Invert Port Power
+- ioc: Invert Over Current detection
+- has_xhci: Contains an optional 3.0 PHY
+- device: PHY Device mode. Possible values are: 0 (Host), 1 (Device)
+  or 2 (DRD)
+
+
+
+Example:
+
+usbphy_0: usb-phy@f0470200 {
+   reg = <0xf0470200 0xb8>,
+   <0xf0471940 0x6c0>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "brcm,brcmstb-usb-phy";
+   ioc = <1>;
+   ipp = <1>;
+   #phy-cells = <1>;
+   ranges;
+   has_xhci;
+   clocks = <&sw_usb20>;
+   clock-names = "sw_usb";
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index ed1229e..4d529e7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2631,6 +2631,13 @@ S:   Maintained
 F: drivers/bcma/
 F: include/linux/bcma/
 
+BROADCOM STB USB PHY DRIVER
+M: Al Cooper 
+L: linux-usb@vger.kernel.org
+L: bcm-kernel-feedback-l...@broadcom.com
+S: Supported
+F: drivers/phy/phy-brcm-usb*
+
 BROADCOM SYSTEMPORT ETHERNET DRIVER
 M: Florian Fainelli 
 L: net...@vger.kernel.org
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index b869b98..61a0244 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -432,6 +432,16 @@ config PHY_CYGNUS_PCIE
  Enable this to support the Broadcom Cygnus PCIe PHY.
  If unsure, say N.
 
+config BRCM_USB_PHY
+   tristate "Broadcom USB PHY driver"
+   depends on OF && USB && ARCH_BRCMSTB
+   select GENERIC_PHY
+   default y
+   help
+ Enable this to support the Broadcom USB PHY on
+ Broadcom STB SoCs.
+ If unsure, say Y.
+
 source "drivers/phy/tegra/Kconfig"
 
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9c3e73c..babb0c7 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -9,6 +9,8 @@ obj-$(CONFIG_PHY_BERLIN_SATA)   += phy-berlin-sata.o
 obj-$(CONFIG_PHY_DM816X_USB)   += phy-dm816x-usb.o
 obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
+obj-$(CONFIG_BRCM_USB_PHY) += phy-brcm-usb.o
+obj-$(CONFIG_BRCM_USB_PHY) += phy-brcm-usb-init.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
 obj-$(CONFIG_PHY_LPC18XX_USB_OTG)  += phy-lpc18xx-usb-otg.o
diff --git a/drivers/phy/phy-brcm-usb-init.c b/drivers/phy/phy-brcm-usb-init.c
new file mode 100644
index 000..f5d8c32
--- /dev/null
+++ b/drivers/phy/phy-brcm-usb-init.c
@@ -0,0 +1,792 @@
+/*
+ * Copyright (C) 2014-2016 Broadcom
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions an

[RESEND PATCH V2 0/2] Add Broadcom USB PHY driver for Broadcom STB SoCs

2016-06-08 Thread Al Cooper
Add Broadcom USB PHY driver for Broadcom STB SoCs. This driver in
combination with the generic ohci, ehci and xhci platform drivers
will enable USB1.1, USB2.0 and USB3.0 support.

NOTE: An unrelated patch is in the pipline to move the file
drivers/soc/brcmstb/common.c to drivers/soc/bcm/brcmstb/common.c

V2 - Change compatible name from "brcm,usb-phy" to
 "brcm,brcmstb-usb-phy"

Al Cooper (2):
  soc: brcmstb: Add Product ID and Family ID helper functions
  usb: phy: phy-brcm-usb: Add Broadcom STB USB Phy driver

 .../bindings/phy/brcm,brcmstb-usb-phy.txt  |  39 +
 MAINTAINERS|   7 +
 drivers/phy/Kconfig|  10 +
 drivers/phy/Makefile   |   2 +
 drivers/phy/phy-brcm-usb-init.c| 792 +
 drivers/phy/phy-brcm-usb-init.h|  49 ++
 drivers/phy/phy-brcm-usb.c | 206 ++
 drivers/soc/brcmstb/common.c   |  12 +
 include/linux/soc/brcmstb/brcmstb.h|  10 +
 9 files changed, 1127 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
 create mode 100644 drivers/phy/phy-brcm-usb-init.c
 create mode 100644 drivers/phy/phy-brcm-usb-init.h
 create mode 100644 drivers/phy/phy-brcm-usb.c

-- 
1.9.0.138.g2de3478

--
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


[RESEND PATCH V2 1/2] soc: brcmstb: Add Product ID and Family ID helper functions

2016-06-08 Thread Al Cooper
Signed-off-by: Al Cooper 
---
 drivers/soc/brcmstb/common.c| 12 
 include/linux/soc/brcmstb/brcmstb.h | 10 ++
 2 files changed, 22 insertions(+)

diff --git a/drivers/soc/brcmstb/common.c b/drivers/soc/brcmstb/common.c
index 94e7335..454f4c2 100644
--- a/drivers/soc/brcmstb/common.c
+++ b/drivers/soc/brcmstb/common.c
@@ -40,6 +40,18 @@ bool soc_is_brcmstb(void)
return of_match_node(brcmstb_machine_match, root) != NULL;
 }
 
+u32 brcmstb_get_family_id(void)
+{
+   return family_id;
+}
+EXPORT_SYMBOL(brcmstb_get_family_id);
+
+u32 brcmstb_get_product_id(void)
+{
+   return product_id;
+}
+EXPORT_SYMBOL(brcmstb_get_product_id);
+
 static const struct of_device_id sun_top_ctrl_match[] = {
{ .compatible = "brcm,brcmstb-sun-top-ctrl", },
{ }
diff --git a/include/linux/soc/brcmstb/brcmstb.h 
b/include/linux/soc/brcmstb/brcmstb.h
index 337ce41..4bf5edd 100644
--- a/include/linux/soc/brcmstb/brcmstb.h
+++ b/include/linux/soc/brcmstb/brcmstb.h
@@ -1,10 +1,20 @@
 #ifndef __BRCMSTB_SOC_H
 #define __BRCMSTB_SOC_H
 
+#define BRCM_ID(reg)   ((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)
+#define BRCM_REV(reg)  ((u32)reg & 0xff)
+
 /*
  * Bus Interface Unit control register setup, must happen early during boot,
  * before SMP is brought up, called by machine entry point.
  */
 void brcmstb_biuctrl_init(void);
 
+/*
+* Helper functions for getting family or product id from the
+* SoC driver.
+*/
+u32 brcmstb_get_family_id(void);
+u32 brcmstb_get_product_id(void);
+
 #endif /* __BRCMSTB_SOC_H */
-- 
1.9.0.138.g2de3478

--
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


[PATCH 3/8] usb: bdc: Add clock enable for new chips with a separate BDC clock

2017-06-27 Thread Al Cooper
Newer SoC's have added a BDC clock to the Device Tree, so get
and enable it.

Signed-off-by: Al Cooper 
Signed-off-by: Florian Fainelli 
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index ccb9c21..3bd82d2 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "bdc.h"
 #include "bdc_dbg.h"
@@ -452,8 +453,22 @@ static int bdc_probe(struct platform_device *pdev)
int irq;
u32 temp;
struct device *dev = &pdev->dev;
+   struct clk *clk;
 
dev_dbg(dev, "%s()\n", __func__);
+
+   clk = devm_clk_get(dev, "sw_usbd");
+   if (IS_ERR(clk)) {
+   dev_info(dev, "Clock not found in Device Tree\n");
+   clk = NULL;
+   }
+
+   ret = clk_prepare_enable(clk);
+   if (ret) {
+   dev_err(dev, "could not enable clock\n");
+   return ret;
+   }
+
bdc = devm_kzalloc(dev, sizeof(*bdc), GFP_KERNEL);
if (!bdc)
return -ENOMEM;
-- 
1.9.0.138.g2de3478

--
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


[PATCH 4/8] usb: bdc: Small code cleanup

2017-06-27 Thread Al Cooper
Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 3bd82d2..621328f 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -488,28 +488,29 @@ static int bdc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, bdc);
bdc->irq = irq;
bdc->dev = dev;
-   dev_dbg(bdc->dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
+   dev_dbg(dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
 
temp = bdc_readl(bdc->regs, BDC_BDCSC);
if ((temp & BDC_P64) &&
!dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
-   dev_dbg(bdc->dev, "Using 64-bit address\n");
+   dev_dbg(dev, "Using 64-bit address\n");
} else {
-   ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+   ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
if (ret) {
-   dev_err(bdc->dev, "No suitable DMA config available, 
abort\n");
+   dev_err(dev,
+   "No suitable DMA config available, abort\n");
return -ENOTSUPP;
}
-   dev_dbg(bdc->dev, "Using 32-bit address\n");
+   dev_dbg(dev, "Using 32-bit address\n");
}
ret = bdc_hw_init(bdc);
if (ret) {
-   dev_err(bdc->dev, "BDC init failure:%d\n", ret);
+   dev_err(dev, "BDC init failure:%d\n", ret);
return ret;
}
ret = bdc_udc_init(bdc);
if (ret) {
-   dev_err(bdc->dev, "BDC Gadget init failure:%d\n", ret);
+   dev_err(dev, "BDC Gadget init failure:%d\n", ret);
goto cleanup;
}
return 0;
-- 
1.9.0.138.g2de3478

--
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


[PATCH 8/8] usb: bdc: Enable in Kconfig for ARCH_BRCMSTB systems

2017-06-27 Thread Al Cooper
Many ARM based Broadcom STB SoC's have a USB BDC controller so
enable this driver for these systems.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/udc/bdc/Kconfig 
b/drivers/usb/gadget/udc/bdc/Kconfig
index eb8b553..c74ac25 100644
--- a/drivers/usb/gadget/udc/bdc/Kconfig
+++ b/drivers/usb/gadget/udc/bdc/Kconfig
@@ -1,6 +1,7 @@
 config USB_BDC_UDC
tristate "Broadcom USB3.0 device controller IP driver(BDC)"
depends on USB_GADGET && HAS_DMA
+   default ARCH_BRCMSTB
 
help
BDC is Broadcom's USB3.0 device controller IP. If your SOC has a BDC IP
-- 
1.9.0.138.g2de3478

--
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


[PATCH 7/8] usb: bdc: fix "xsf for ep not enabled" errror

2017-06-27 Thread Al Cooper
This patch essentially clears the port status change bits at the
correct times. It is necessary because the driver was not handling
the change bits correctly for events during device
connection/disconnection and bus enumeration. So, one of them (PCC)
was left stuck sometimes causing the "xsf for ep not enabled"
error we get on first connection. This was found by the Android team.
This was debugged and fixed by Sasi Kumar.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc_udc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_udc.c 
b/drivers/usb/gadget/udc/bdc/bdc_udc.c
index aae7458..c843461 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_udc.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_udc.c
@@ -249,6 +249,7 @@ void bdc_sr_uspc(struct bdc *bdc, struct bdc_sr *sreport)
disconn = true;
else if ((uspc & BDC_PCS) && !BDC_PST(uspc))
connected = true;
+   clear_flags |= BDC_PCC;
}
 
/* Change in VBus and VBus is present */
@@ -259,16 +260,16 @@ void bdc_sr_uspc(struct bdc *bdc, struct bdc_sr *sreport)
bdc_softconn(bdc);
usb_gadget_set_state(&bdc->gadget, USB_STATE_POWERED);
}
-   clear_flags = BDC_VBC;
+   clear_flags |= BDC_VBC;
} else if ((uspc & BDC_PRS) || (uspc & BDC_PRC) || disconn) {
/* Hot reset, warm reset, 2.0 bus reset or disconn */
dev_dbg(bdc->dev, "Port reset or disconn\n");
bdc_uspc_disconnected(bdc, disconn);
-   clear_flags = BDC_PCC|BDC_PCS|BDC_PRS|BDC_PRC;
+   clear_flags |= BDC_PRC;
} else if ((uspc & BDC_PSC) && (uspc & BDC_PCS)) {
/* Change in Link state */
handle_link_state_change(bdc, uspc);
-   clear_flags = BDC_PSC|BDC_PCS;
+   clear_flags |= BDC_PSC;
}
 
/*
-- 
1.9.0.138.g2de3478

--
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


[PATCH 6/8] usb: bdc: Add support for suspend/resume

2017-06-27 Thread Al Cooper
Based on a previous commit by Danesh Petigara 
that added resume to solve the following problem:
"The BDC driver will fail after resuming from S3 suspend and this
will cause any upper layer gadget driver to fail."
This commit also adds support for suspend and manages the clock during
suspend/resume.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h  |  1 +
 drivers/usb/gadget/udc/bdc/bdc_core.c | 36 +++
 2 files changed, 37 insertions(+)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index 3664808..f838647 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -454,6 +454,7 @@ struct bdc {
 * Func Wake packet every 2.5 secs. Refer to USB3 spec section 8.5.6.4
 */
struct delayed_work func_wake_notify;
+   struct clk  *clk;
 };
 
 static inline u32 bdc_readl(void __iomem *base, u32 offset)
diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 1714bd3..021c0e7 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -473,6 +473,8 @@ static int bdc_probe(struct platform_device *pdev)
if (!bdc)
return -ENOMEM;
 
+   bdc->clk = clk;
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
bdc->regs = devm_ioremap_resource(dev, res);
if (IS_ERR(bdc->regs)) {
@@ -529,10 +531,43 @@ static int bdc_remove(struct platform_device *pdev)
dev_dbg(bdc->dev, "%s ()\n", __func__);
bdc_udc_exit(bdc);
bdc_hw_exit(bdc);
+   clk_disable_unprepare(bdc->clk);
+   return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int bdc_suspend(struct device *dev)
+{
+   struct bdc *bdc = dev_get_drvdata(dev);
+
+   clk_disable_unprepare(bdc->clk);
+   return 0;
+}
+
+static int bdc_resume(struct device *dev)
+{
+   struct bdc *bdc = dev_get_drvdata(dev);
+   int ret;
+
+   ret = clk_prepare_enable(bdc->clk);
+   if (ret) {
+   dev_err(bdc->dev, "err enabling the clock\n");
+   return ret;
+   }
+   ret = bdc_reinit(bdc);
+   if (ret) {
+   dev_err(bdc->dev, "err in bdc reinit\n");
+   return ret;
+   }
 
return 0;
 }
 
+#endif /* CONFIG_PM_SLEEP */
+
+static SIMPLE_DEV_PM_OPS(bdc_pm_ops, bdc_suspend,
+   bdc_resume);
+
 static const struct of_device_id bdc_of_match[] = {
{ .compatible = "brcm,bdc-udc-v0.16" },
{ .compatible = "brcm,bdc-udc" },
@@ -543,6 +578,7 @@ static int bdc_remove(struct platform_device *pdev)
.driver = {
.name   = BRCM_BDC_NAME,
.owner  = THIS_MODULE,
+   .pm = &bdc_pm_ops,
.of_match_table = bdc_of_match,
},
.probe  = bdc_probe,
-- 
1.9.0.138.g2de3478

--
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


[PATCH 5/8] usb: gadget: bdc: hook a quick Device Tree compatible string

2017-06-27 Thread Al Cooper
From: Florian Fainelli 

Allows Device Tree probing

Signed-off-by: Florian Fainelli 
Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 621328f..1714bd3 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -533,9 +533,17 @@ static int bdc_remove(struct platform_device *pdev)
return 0;
 }
 
+static const struct of_device_id bdc_of_match[] = {
+   { .compatible = "brcm,bdc-udc-v0.16" },
+   { .compatible = "brcm,bdc-udc" },
+   { /* sentinel */ }
+};
+
 static struct platform_driver bdc_driver = {
.driver = {
.name   = BRCM_BDC_NAME,
+   .owner  = THIS_MODULE,
+   .of_match_table = bdc_of_match,
},
.probe  = bdc_probe,
.remove = bdc_remove,
-- 
1.9.0.138.g2de3478

--
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


[PATCH 1/8] usb: gadget: bdc: Fix misleading register names

2017-06-27 Thread Al Cooper
The BDC endpoint status registers 0-7 were originally each going
to be an array of regsiters. This was later changed to being a
single register. The register definitions are being changed from:
"#define BDC_EPSTS0(n)  (0x60 + (n * 0x10))"
to
"#define BDC_EPSTS0 0x60"
to reflect this change and to avoid future coding mistakes.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h | 16 
 drivers/usb/gadget/udc/bdc/bdc_dbg.c | 16 
 drivers/usb/gadget/udc/bdc/bdc_ep.c  |  4 ++--
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index 916d471..3664808 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -83,14 +83,14 @@
 
 #define BDC_DVCSA  0x50
 #define BDC_DVCSB  0x54
-#define BDC_EPSTS0(n)  (0x60 + (n * 0x10))
-#define BDC_EPSTS1(n)  (0x64 + (n * 0x10))
-#define BDC_EPSTS2(n)  (0x68 + (n * 0x10))
-#define BDC_EPSTS3(n)  (0x6c + (n * 0x10))
-#define BDC_EPSTS4(n)  (0x70 + (n * 0x10))
-#define BDC_EPSTS5(n)  (0x74 + (n * 0x10))
-#define BDC_EPSTS6(n)  (0x78 + (n * 0x10))
-#define BDC_EPSTS7(n)  (0x7c + (n * 0x10))
+#define BDC_EPSTS0 0x60
+#define BDC_EPSTS1 0x64
+#define BDC_EPSTS2 0x68
+#define BDC_EPSTS3 0x6c
+#define BDC_EPSTS4 0x70
+#define BDC_EPSTS5 0x74
+#define BDC_EPSTS6 0x78
+#define BDC_EPSTS7 0x7c
 #define BDC_SRRBAL(n)  (0x200 + (n * 0x10))
 #define BDC_SRRBAH(n)  (0x204 + (n * 0x10))
 #define BDC_SRRINT(n)  (0x208 + (n * 0x10))
diff --git a/drivers/usb/gadget/udc/bdc/bdc_dbg.c 
b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
index 5945dbc..ac98f6f 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_dbg.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
@@ -40,28 +40,28 @@ void bdc_dump_epsts(struct bdc *bdc)
 {
u32 temp;
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS0(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS0);
dev_vdbg(bdc->dev, "BDC_EPSTS0:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS1(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS1);
dev_vdbg(bdc->dev, "BDC_EPSTS1:0x%x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS2(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS2);
dev_vdbg(bdc->dev, "BDC_EPSTS2:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS3(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS3);
dev_vdbg(bdc->dev, "BDC_EPSTS3:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS4(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS4);
dev_vdbg(bdc->dev, "BDC_EPSTS4:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS5(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS5);
dev_vdbg(bdc->dev, "BDC_EPSTS5:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS6(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS6);
dev_vdbg(bdc->dev, "BDC_EPSTS6:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS7(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS7);
dev_vdbg(bdc->dev, "BDC_EPSTS7:0x%08x\n", temp);
 }
 
diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c 
b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index ff1ef24..bfd8f7a 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -777,9 +777,9 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req 
*req)
 */
 
/* The current hw dequeue pointer */
-   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(0));
+   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0);
deq_ptr_64 = tmp_32;
-   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS1(0));
+   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS1);
deq_ptr_64 |= ((u64)tmp_32 << 32);
 
/* we have the dma addr of next bd that will be fetched by hardware */
-- 
1.9.0.138.g2de3478

--
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


[PATCH 2/8] usb: bdc: Add Device Tree binding document for Broadcom BDC driver

2017-06-27 Thread Al Cooper
Add Device Tree binding document for Broadcom USB Device
Controller (BDC).

Signed-off-by: Al Cooper 
---
 .../devicetree/bindings/usb/brcm,bdc-udc.txt   | 28 ++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bdc-udc.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,bdc-udc.txt 
b/Documentation/devicetree/bindings/usb/brcm,bdc-udc.txt
new file mode 100644
index 000..4eeaddb
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,bdc-udc.txt
@@ -0,0 +1,28 @@
+Broadcom USB Device Controller (BDC)
+
+
+Required properties:
+
+- compatible: must be one of:
+"brcm,bdc-udc-v0.16"
+"brcm,bdc-udc"
+- reg: the base register address and length
+- interrupts: ther interrupt line for this controller
+
+Optional properties:
+
+On Broadcom STB platforms, these properties are required:
+
+- phys: phandle to the USB PHY blocks
+- clocks: phandle to the functional clock of this block
+
+Example:
+
+udc@f0b02000 {
+status = "disabled";
+compatible = "brcm,bdc-udc-v0.16";
+reg = <0xf0b02000 0xfc4>;
+interrupts = <0x0 0x60 0x0>;
+phys = <&usbphy_0 0x0>;
+clocks = <&sw_usbd>;
+};
-- 
1.9.0.138.g2de3478

--
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


[PATCH 0/8] Bugs fixes and improvements to Broadcom BDC driver

2017-06-27 Thread Al Cooper
Bug fixes and improvements to the USB Broadcom Device
Controller (BDC) driver.

Al Cooper (7):
  usb: gadget: bdc: Fix misleading register names
  usb: bdc: Add Device Tree binding document for Broadcom BDC driver
  usb: bdc: Add clock enable for new chips with a separate BDC clock
  usb: bdc: Small code cleanup
  usb: bdc: Add support for suspend/resume
  usb: bdc: fix "xsf for ep not enabled" errror
  usb: bdc: Enable in Kconfig for ARCH_BRCMSTB systems

Florian Fainelli (1):
  usb: gadget: bdc: hook a quick Device Tree compatible string

 .../devicetree/bindings/usb/brcm,bdc-udc.txt   | 28 
 drivers/usb/gadget/udc/bdc/Kconfig |  1 +
 drivers/usb/gadget/udc/bdc/bdc.h   | 17 ++---
 drivers/usb/gadget/udc/bdc/bdc_core.c  | 74 --
 drivers/usb/gadget/udc/bdc/bdc_dbg.c   | 16 ++---
 drivers/usb/gadget/udc/bdc/bdc_ep.c|  4 +-
 drivers/usb/gadget/udc/bdc/bdc_udc.c   |  7 +-
 7 files changed, 119 insertions(+), 28 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bdc-udc.txt

-- 
1.9.0.138.g2de3478

--
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


Re: [PATCH 4/8] usb: bdc: Small code cleanup

2017-06-28 Thread Al Cooper
On Wed, Jun 28, 2017 at 4:47 AM, David Laight  wrote:
>>
>>   temp = bdc_readl(bdc->regs, BDC_BDCSC);
>>   if ((temp & BDC_P64) &&
>>   !dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
>> - dev_dbg(bdc->dev, "Using 64-bit address\n");
>> + dev_dbg(dev, "Using 64-bit address\n");
>>   } else {
>> - ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
>> + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
>
> That just wrong...
> Or was wrong before.

Why is this wrong?

Al
--
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


[PATCH V2 8/9] usb: bdc: Enable in Kconfig for ARCH_BRCMSTB systems

2017-07-19 Thread Al Cooper
Many ARM based Broadcom STB SoC's have a USB BDC controller so
enable this driver for these systems.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/udc/bdc/Kconfig 
b/drivers/usb/gadget/udc/bdc/Kconfig
index eb8b553..c74ac25 100644
--- a/drivers/usb/gadget/udc/bdc/Kconfig
+++ b/drivers/usb/gadget/udc/bdc/Kconfig
@@ -1,6 +1,7 @@
 config USB_BDC_UDC
tristate "Broadcom USB3.0 device controller IP driver(BDC)"
depends on USB_GADGET && HAS_DMA
+   default ARCH_BRCMSTB
 
help
BDC is Broadcom's USB3.0 device controller IP. If your SOC has a BDC IP
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2 6/9] usb: bdc: Add support for suspend/resume

2017-07-19 Thread Al Cooper
Based on a previous commit by Danesh Petigara 
that added resume to solve the following problem:
"The BDC driver will fail after resuming from S3 suspend and this
will cause any upper layer gadget driver to fail."
This commit also adds support for suspend and manages the clock during
suspend/resume.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h  |  1 +
 drivers/usb/gadget/udc/bdc/bdc_core.c | 36 +++
 2 files changed, 37 insertions(+)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index f657a4e..67c5f23 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -454,6 +454,7 @@ struct bdc {
 * Func Wake packet every 2.5 secs. Refer to USB3 spec section 8.5.6.4
 */
struct delayed_work func_wake_notify;
+   struct clk  *clk;
 };
 
 static inline u32 bdc_readl(void __iomem *base, u32 offset)
diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index bc0729b..2690b6f 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -473,6 +473,8 @@ static int bdc_probe(struct platform_device *pdev)
if (!bdc)
return -ENOMEM;
 
+   bdc->clk = clk;
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
bdc->regs = devm_ioremap_resource(dev, res);
if (IS_ERR(bdc->regs)) {
@@ -529,10 +531,43 @@ static int bdc_remove(struct platform_device *pdev)
dev_dbg(bdc->dev, "%s ()\n", __func__);
bdc_udc_exit(bdc);
bdc_hw_exit(bdc);
+   clk_disable_unprepare(bdc->clk);
+   return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int bdc_suspend(struct device *dev)
+{
+   struct bdc *bdc = dev_get_drvdata(dev);
+
+   clk_disable_unprepare(bdc->clk);
+   return 0;
+}
+
+static int bdc_resume(struct device *dev)
+{
+   struct bdc *bdc = dev_get_drvdata(dev);
+   int ret;
+
+   ret = clk_prepare_enable(bdc->clk);
+   if (ret) {
+   dev_err(bdc->dev, "err enabling the clock\n");
+   return ret;
+   }
+   ret = bdc_reinit(bdc);
+   if (ret) {
+   dev_err(bdc->dev, "err in bdc reinit\n");
+   return ret;
+   }
 
return 0;
 }
 
+#endif /* CONFIG_PM_SLEEP */
+
+static SIMPLE_DEV_PM_OPS(bdc_pm_ops, bdc_suspend,
+   bdc_resume);
+
 static const struct of_device_id bdc_of_match[] = {
{ .compatible = "brcm,bdc-v0.16" },
{ .compatible = "brcm,bdc" },
@@ -543,6 +578,7 @@ static int bdc_remove(struct platform_device *pdev)
.driver = {
.name   = BRCM_BDC_NAME,
.owner  = THIS_MODULE,
+   .pm = &bdc_pm_ops,
.of_match_table = bdc_of_match,
},
.probe  = bdc_probe,
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2 9/9] usb: bdc: Add support for USB phy

2017-07-19 Thread Al Cooper
If a phy is specified in the device tree node, get it and use it.
This was based on a patch by:
"Srinath Mannam "

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h  |  3 ++
 drivers/usb/gadget/udc/bdc/bdc_core.c | 74 ++-
 2 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index 67c5f23..6df0352 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -413,6 +413,9 @@ struct bdc {
/* device lock */
spinlock_t  lock;
 
+   /* generic phy */
+   struct phy  **phys;
+   int num_phys;
/* num of endpoints for a particular instantiation of IP */
unsigned int num_eps;
/*
diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 2690b6f..7a8af4b 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -445,6 +446,43 @@ static int bdc_hw_init(struct bdc *bdc)
return 0;
 }
 
+static int bdc_phy_init(struct bdc *bdc)
+{
+   int phy_num;
+   int ret;
+
+   for (phy_num = 0; phy_num < bdc->num_phys; phy_num++) {
+   ret = phy_init(bdc->phys[phy_num]);
+   if (ret)
+   goto err_exit_phy;
+   ret = phy_power_on(bdc->phys[phy_num]);
+   if (ret) {
+   phy_exit(bdc->phys[phy_num]);
+   goto err_exit_phy;
+   }
+   }
+
+   return 0;
+
+err_exit_phy:
+   while (--phy_num >= 0) {
+   phy_power_off(bdc->phys[phy_num]);
+   phy_exit(bdc->phys[phy_num]);
+   }
+
+   return ret;
+}
+
+static void bdc_phy_exit(struct bdc *bdc)
+{
+   int phy_num;
+
+   for (phy_num = 0; phy_num < bdc->num_phys; phy_num++) {
+   phy_power_off(bdc->phys[phy_num]);
+   phy_exit(bdc->phys[phy_num]);
+   }
+}
+
 static int bdc_probe(struct platform_device *pdev)
 {
struct bdc *bdc;
@@ -454,6 +492,7 @@ static int bdc_probe(struct platform_device *pdev)
u32 temp;
struct device *dev = &pdev->dev;
struct clk *clk;
+   int phy_num;
 
dev_dbg(dev, "%s()\n", __func__);
 
@@ -492,6 +531,35 @@ static int bdc_probe(struct platform_device *pdev)
bdc->dev = dev;
dev_dbg(dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
 
+   bdc->num_phys = of_count_phandle_with_args(dev->of_node,
+   "phys", "#phy-cells");
+   if (bdc->num_phys > 0) {
+   bdc->phys = devm_kcalloc(dev, bdc->num_phys,
+   sizeof(struct phy *), GFP_KERNEL);
+   if (!bdc->phys)
+   return -ENOMEM;
+   } else {
+   bdc->num_phys = 0;
+   }
+   dev_info(dev, "Using %d phy(s)\n", bdc->num_phys);
+
+   for (phy_num = 0; phy_num < bdc->num_phys; phy_num++) {
+   bdc->phys[phy_num] = devm_of_phy_get_by_index(
+   dev, dev->of_node, phy_num);
+   if (IS_ERR(bdc->phys[phy_num])) {
+   ret = PTR_ERR(bdc->phys[phy_num]);
+   dev_err(bdc->dev,
+   "BDC phy specified but not found:%d\n", ret);
+   return ret;
+   }
+   }
+
+   ret = bdc_phy_init(bdc);
+   if (ret) {
+   dev_err(bdc->dev, "BDC phy init failure:%d\n", ret);
+   return ret;
+   }
+
temp = bdc_readl(bdc->regs, BDC_BDCCAP1);
if ((temp & BDC_P64) &&
!dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
@@ -508,7 +576,7 @@ static int bdc_probe(struct platform_device *pdev)
ret = bdc_hw_init(bdc);
if (ret) {
dev_err(dev, "BDC init failure:%d\n", ret);
-   return ret;
+   goto phycleanup;
}
ret = bdc_udc_init(bdc);
if (ret) {
@@ -519,7 +587,8 @@ static int bdc_probe(struct platform_device *pdev)
 
 cleanup:
bdc_hw_exit(bdc);
-
+phycleanup:
+   bdc_phy_exit(bdc);
return ret;
 }
 
@@ -531,6 +600,7 @@ static int bdc_remove(struct platform_device *pdev)
dev_dbg(bdc->dev, "%s ()\n", __func__);
bdc_udc_exit(bdc);
bdc_hw_exit(bdc);
+   bdc_phy_exit(bdc);
clk_disable_unprepare(bdc->clk);
return 0;
 }
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2 7/9] usb: bdc: fix "xsf for ep not enabled" errror

2017-07-19 Thread Al Cooper
This patch essentially clears the port status change bits at the
correct times. It is necessary because the driver was not handling
the change bits correctly for events during device
connection/disconnection and bus enumeration. So, one of them (PCC)
was left stuck sometimes causing the "xsf for ep not enabled"
error we get on first connection. This was found by the Android team.
This was debugged and fixed by Sasi Kumar.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc_udc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_udc.c 
b/drivers/usb/gadget/udc/bdc/bdc_udc.c
index aae7458..c843461 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_udc.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_udc.c
@@ -249,6 +249,7 @@ void bdc_sr_uspc(struct bdc *bdc, struct bdc_sr *sreport)
disconn = true;
else if ((uspc & BDC_PCS) && !BDC_PST(uspc))
connected = true;
+   clear_flags |= BDC_PCC;
}
 
/* Change in VBus and VBus is present */
@@ -259,16 +260,16 @@ void bdc_sr_uspc(struct bdc *bdc, struct bdc_sr *sreport)
bdc_softconn(bdc);
usb_gadget_set_state(&bdc->gadget, USB_STATE_POWERED);
}
-   clear_flags = BDC_VBC;
+   clear_flags |= BDC_VBC;
} else if ((uspc & BDC_PRS) || (uspc & BDC_PRC) || disconn) {
/* Hot reset, warm reset, 2.0 bus reset or disconn */
dev_dbg(bdc->dev, "Port reset or disconn\n");
bdc_uspc_disconnected(bdc, disconn);
-   clear_flags = BDC_PCC|BDC_PCS|BDC_PRS|BDC_PRC;
+   clear_flags |= BDC_PRC;
} else if ((uspc & BDC_PSC) && (uspc & BDC_PCS)) {
/* Change in Link state */
handle_link_state_change(bdc, uspc);
-   clear_flags = BDC_PSC|BDC_PCS;
+   clear_flags |= BDC_PSC;
}
 
/*
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2 5/9] usb: bdc: hook a quick Device Tree compatible string

2017-07-19 Thread Al Cooper
From: Florian Fainelli 

Allows Device Tree probing

Signed-off-by: Florian Fainelli 
Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h  | 4 ++--
 drivers/usb/gadget/udc/bdc/bdc_core.c | 8 
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index 3664808..f657a4e 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -27,8 +27,8 @@
 #include 
 #include 
 
-#define BRCM_BDC_NAME "bdc_usb3"
-#define BRCM_BDC_DESC "BDC device controller driver"
+#define BRCM_BDC_NAME "bdc"
+#define BRCM_BDC_DESC "Broadcom USB Device Controller driver"
 
 #define DMA_ADDR_INVALID(~(dma_addr_t)0)
 
diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index c2bfae2..bc0729b 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -533,9 +533,17 @@ static int bdc_remove(struct platform_device *pdev)
return 0;
 }
 
+static const struct of_device_id bdc_of_match[] = {
+   { .compatible = "brcm,bdc-v0.16" },
+   { .compatible = "brcm,bdc" },
+   { /* sentinel */ }
+};
+
 static struct platform_driver bdc_driver = {
.driver = {
.name   = BRCM_BDC_NAME,
+   .owner  = THIS_MODULE,
+   .of_match_table = bdc_of_match,
},
.probe  = bdc_probe,
.remove = bdc_remove,
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2 3/9] usb: bdc: Add clock enable for new chips with a separate BDC clock

2017-07-19 Thread Al Cooper
Newer SoC's have added a BDC clock to the Device Tree, so get
and enable it.

Signed-off-by: Al Cooper 
Signed-off-by: Florian Fainelli 
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index e9bd8d4..dda7b43 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "bdc.h"
 #include "bdc_dbg.h"
@@ -452,8 +453,22 @@ static int bdc_probe(struct platform_device *pdev)
int irq;
u32 temp;
struct device *dev = &pdev->dev;
+   struct clk *clk;
 
dev_dbg(dev, "%s()\n", __func__);
+
+   clk = devm_clk_get(dev, "sw_usbd");
+   if (IS_ERR(clk)) {
+   dev_info(dev, "Clock not found in Device Tree\n");
+   clk = NULL;
+   }
+
+   ret = clk_prepare_enable(clk);
+   if (ret) {
+   dev_err(dev, "could not enable clock\n");
+   return ret;
+   }
+
bdc = devm_kzalloc(dev, sizeof(*bdc), GFP_KERNEL);
if (!bdc)
return -ENOMEM;
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2 4/9] usb: bdc: Small code cleanup

2017-07-19 Thread Al Cooper
Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index dda7b43..c2bfae2 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -488,28 +488,29 @@ static int bdc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, bdc);
bdc->irq = irq;
bdc->dev = dev;
-   dev_dbg(bdc->dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
+   dev_dbg(dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
 
temp = bdc_readl(bdc->regs, BDC_BDCCAP1);
if ((temp & BDC_P64) &&
!dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
-   dev_dbg(bdc->dev, "Using 64-bit address\n");
+   dev_dbg(dev, "Using 64-bit address\n");
} else {
-   ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+   ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
if (ret) {
-   dev_err(bdc->dev, "No suitable DMA config available, 
abort\n");
+   dev_err(dev,
+   "No suitable DMA config available, abort\n");
return -ENOTSUPP;
}
-   dev_dbg(bdc->dev, "Using 32-bit address\n");
+   dev_dbg(dev, "Using 32-bit address\n");
}
ret = bdc_hw_init(bdc);
if (ret) {
-   dev_err(bdc->dev, "BDC init failure:%d\n", ret);
+   dev_err(dev, "BDC init failure:%d\n", ret);
return ret;
}
ret = bdc_udc_init(bdc);
if (ret) {
-   dev_err(bdc->dev, "BDC Gadget init failure:%d\n", ret);
+   dev_err(dev, "BDC Gadget init failure:%d\n", ret);
goto cleanup;
}
return 0;
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2 1/9] usb: bdc: Fix misleading register names

2017-07-19 Thread Al Cooper
The BDC endpoint status registers 0-7 were originally each going
to be an array of regsiters. This was later changed to being a
single register. The register definitions are being changed from:
"#define BDC_EPSTS0(n)  (0x60 + (n * 0x10))"
to
"#define BDC_EPSTS0 0x60"
to reflect this change and to avoid future coding mistakes.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h | 16 
 drivers/usb/gadget/udc/bdc/bdc_dbg.c | 16 
 drivers/usb/gadget/udc/bdc/bdc_ep.c  |  4 ++--
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index 916d471..3664808 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -83,14 +83,14 @@
 
 #define BDC_DVCSA  0x50
 #define BDC_DVCSB  0x54
-#define BDC_EPSTS0(n)  (0x60 + (n * 0x10))
-#define BDC_EPSTS1(n)  (0x64 + (n * 0x10))
-#define BDC_EPSTS2(n)  (0x68 + (n * 0x10))
-#define BDC_EPSTS3(n)  (0x6c + (n * 0x10))
-#define BDC_EPSTS4(n)  (0x70 + (n * 0x10))
-#define BDC_EPSTS5(n)  (0x74 + (n * 0x10))
-#define BDC_EPSTS6(n)  (0x78 + (n * 0x10))
-#define BDC_EPSTS7(n)  (0x7c + (n * 0x10))
+#define BDC_EPSTS0 0x60
+#define BDC_EPSTS1 0x64
+#define BDC_EPSTS2 0x68
+#define BDC_EPSTS3 0x6c
+#define BDC_EPSTS4 0x70
+#define BDC_EPSTS5 0x74
+#define BDC_EPSTS6 0x78
+#define BDC_EPSTS7 0x7c
 #define BDC_SRRBAL(n)  (0x200 + (n * 0x10))
 #define BDC_SRRBAH(n)  (0x204 + (n * 0x10))
 #define BDC_SRRINT(n)  (0x208 + (n * 0x10))
diff --git a/drivers/usb/gadget/udc/bdc/bdc_dbg.c 
b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
index 5945dbc..ac98f6f 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_dbg.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
@@ -40,28 +40,28 @@ void bdc_dump_epsts(struct bdc *bdc)
 {
u32 temp;
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS0(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS0);
dev_vdbg(bdc->dev, "BDC_EPSTS0:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS1(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS1);
dev_vdbg(bdc->dev, "BDC_EPSTS1:0x%x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS2(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS2);
dev_vdbg(bdc->dev, "BDC_EPSTS2:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS3(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS3);
dev_vdbg(bdc->dev, "BDC_EPSTS3:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS4(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS4);
dev_vdbg(bdc->dev, "BDC_EPSTS4:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS5(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS5);
dev_vdbg(bdc->dev, "BDC_EPSTS5:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS6(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS6);
dev_vdbg(bdc->dev, "BDC_EPSTS6:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS7(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS7);
dev_vdbg(bdc->dev, "BDC_EPSTS7:0x%08x\n", temp);
 }
 
diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c 
b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index ff1ef24..bfd8f7a 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -777,9 +777,9 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req 
*req)
 */
 
/* The current hw dequeue pointer */
-   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(0));
+   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0);
deq_ptr_64 = tmp_32;
-   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS1(0));
+   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS1);
deq_ptr_64 |= ((u64)tmp_32 << 32);
 
/* we have the dma addr of next bd that will be fetched by hardware */
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2 0/9] Bug fixes and improvements to Broadcom BDC driver

2017-07-19 Thread Al Cooper
V2 Changes:
- Add support for USB phys. We need to handle systems with either
  a single phy or systems with both a USB2.0 and USB3.0 phy
- Fixes to the dt-bindings document based on feedback from 
  Rob Herring. Changes include changing the compatible base
  name to "brcm,bdc" because "brcm,bdc-udc" seemed redundant
- Add proper suspend/resume support with clock control
- Split out code cleanup into separate patch

Bug fixes and improvements to the Broadcom USB STB BDC driver.

Al Cooper (8):
  usb: bdc: Fix misleading register names
  dt-bindings: usb: bdc: Add Device Tree binding for Broadcom UDC driver
  usb: bdc: Add clock enable for new chips with a separate BDC clock
  usb: bdc: Small code cleanup
  usb: bdc: Add support for suspend/resume
  usb: bdc: fix "xsf for ep not enabled" errror
  usb: bdc: Enable in Kconfig for ARCH_BRCMSTB systems
  usb: bdc: Add support for USB phy

Florian Fainelli (1):
  usb: bdc: hook a quick Device Tree compatible string

 Documentation/devicetree/bindings/usb/brcm,bdc.txt |  29 
 drivers/usb/gadget/udc/bdc/Kconfig |   1 +
 drivers/usb/gadget/udc/bdc/bdc.h   |  24 ++--
 drivers/usb/gadget/udc/bdc/bdc_core.c  | 148 +++--
 drivers/usb/gadget/udc/bdc/bdc_dbg.c   |  16 +--
 drivers/usb/gadget/udc/bdc/bdc_ep.c|   4 +-
 drivers/usb/gadget/udc/bdc/bdc_udc.c   |   7 +-
 7 files changed, 197 insertions(+), 32 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bdc.txt

-- 
1.9.0.138.g2de3478

--
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


[PATCH V2 2/9] dt-bindings: usb: bdc: Add Device Tree binding for Broadcom UDC driver

2017-07-19 Thread Al Cooper
Add Device Tree binding document for Broadcom USB Device
Controller (BDC).

Signed-off-by: Al Cooper 
---
 Documentation/devicetree/bindings/usb/brcm,bdc.txt | 29 ++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bdc.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,bdc.txt 
b/Documentation/devicetree/bindings/usb/brcm,bdc.txt
new file mode 100644
index 000..63e63af
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,bdc.txt
@@ -0,0 +1,29 @@
+Broadcom USB Device Controller (BDC)
+
+
+Required properties:
+
+- compatible: must be one of:
+"brcm,bdc-v0.16"
+"brcm,bdc"
+- reg: the base register address and length
+- interrupts: the interrupt line for this controller
+
+Optional properties:
+
+On Broadcom STB platforms, these properties are required:
+
+- phys: phandle to one or two USB PHY blocks
+NOTE: Some SoC's have a single phy and some have
+USB 2.0 and USB 3.0 phys
+- clocks: phandle to the functional clock of this block
+
+Example:
+
+bdc@f0b02000 {
+compatible = "brcm,bdc-v0.16";
+reg = <0xf0b02000 0xfc4>;
+interrupts = <0x0 0x60 0x0>;
+phys = <&usbphy_0 0x0>;
+clocks = <&sw_usbd>;
+};
-- 
1.9.0.138.g2de3478

--
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


[PATCH V3 2/2] usb: phy: phy-brcm-usb: Add Broadcom STB USB Phy driver

2016-08-30 Thread Al Cooper
Add a new USB Phy driver for Broadcom STB SoCs. This driver
supports all Broadcom STB ARM SoCs. This driver in combination
with the generic ohci, ehci and xhci platform drivers will enable
USB1.1, USB2.0 and USB3.0 support. This Phy driver also supports
the Broadcom UDC gadget driver.

Signed-off-by: Al Cooper 
---
 .../bindings/phy/brcm,brcmstb-usb-phy.txt  |  39 +
 MAINTAINERS|   7 +
 drivers/phy/Kconfig|  10 +
 drivers/phy/Makefile   |   2 +
 drivers/phy/phy-brcm-usb-init.c| 792 +
 drivers/phy/phy-brcm-usb-init.h|  49 ++
 drivers/phy/phy-brcm-usb.c | 206 ++
 7 files changed, 1105 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
 create mode 100644 drivers/phy/phy-brcm-usb-init.c
 create mode 100644 drivers/phy/phy-brcm-usb-init.h
 create mode 100644 drivers/phy/phy-brcm-usb.c

diff --git a/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt 
b/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
new file mode 100644
index 000..34fa9dd
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
@@ -0,0 +1,39 @@
+Broadcom STB USB PHY
+
+Required properties:
+ - compatible: brcm,brcmstb-usb-phy
+ - reg: two offset and length pairs. The second pair specifies the
+USB 3.0 related registers and is only required for PHYs
+that support USB 3.0
+ - #phy-cells: Shall be 1 as it expects one argument for setting
+  the type of the PHY. Possible values are 0 (1.1 and 2.0),
+  1 (3.0)
+
+
+Optional Properties:
+- clocks : phandle + clock specifier for the phy clocks
+- clock-names: string, clock name
+- ipp: Invert Port Power
+- ioc: Invert Over Current detection
+- has_xhci: Contains an optional 3.0 PHY
+- device: PHY Device mode. Possible values are: 0 (Host), 1 (Device)
+  or 2 (DRD)
+
+
+
+Example:
+
+usbphy_0: usb-phy@f0470200 {
+   reg = <0xf0470200 0xb8>,
+   <0xf0471940 0x6c0>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "brcm,brcmstb-usb-phy";
+   ioc = <1>;
+   ipp = <1>;
+   #phy-cells = <1>;
+   ranges;
+   has_xhci;
+   clocks = <&sw_usb20>;
+   clock-names = "sw_usb";
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index 0bbe4b1..d58b124 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2697,6 +2697,13 @@ S:   Maintained
 F: drivers/bcma/
 F: include/linux/bcma/
 
+BROADCOM STB USB PHY DRIVER
+M: Al Cooper 
+L: linux-usb@vger.kernel.org
+L: bcm-kernel-feedback-l...@broadcom.com
+S: Supported
+F: drivers/phy/phy-brcm-usb*
+
 BROADCOM SYSTEMPORT ETHERNET DRIVER
 M: Florian Fainelli 
 L: net...@vger.kernel.org
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 19bff3a..5ff5e47 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -443,6 +443,16 @@ config PHY_CYGNUS_PCIE
  Enable this to support the Broadcom Cygnus PCIe PHY.
  If unsure, say N.
 
+config BRCM_USB_PHY
+   tristate "Broadcom USB PHY driver"
+   depends on OF && USB && ARCH_BRCMSTB
+   select GENERIC_PHY
+   default y
+   help
+ Enable this to support the Broadcom USB PHY on
+ Broadcom STB SoCs.
+ If unsure, say Y.
+
 source "drivers/phy/tegra/Kconfig"
 
 config PHY_NS2_PCIE
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 90ae198..f4ff6c7 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -10,6 +10,8 @@ obj-$(CONFIG_PHY_DA8XX_USB)   += phy-da8xx-usb.o
 obj-$(CONFIG_PHY_DM816X_USB)   += phy-dm816x-usb.o
 obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
+obj-$(CONFIG_BRCM_USB_PHY) += phy-brcm-usb.o
+obj-$(CONFIG_BRCM_USB_PHY) += phy-brcm-usb-init.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
 obj-$(CONFIG_PHY_LPC18XX_USB_OTG)  += phy-lpc18xx-usb-otg.o
diff --git a/drivers/phy/phy-brcm-usb-init.c b/drivers/phy/phy-brcm-usb-init.c
new file mode 100644
index 000..f5d8c32
--- /dev/null
+++ b/drivers/phy/phy-brcm-usb-init.c
@@ -0,0 +1,792 @@
+/*
+ * Copyright (C) 2014-2016 Broadcom
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of 

[PATCH V3 1/2] soc: brcmstb: Add Product ID and Family ID helper functions

2016-08-30 Thread Al Cooper
Signed-off-by: Al Cooper 
---
 drivers/soc/bcm/brcmstb/common.c| 12 
 include/linux/soc/brcmstb/brcmstb.h | 10 ++
 2 files changed, 22 insertions(+)

diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c
index 94e7335..454f4c2 100644
--- a/drivers/soc/bcm/brcmstb/common.c
+++ b/drivers/soc/bcm/brcmstb/common.c
@@ -40,6 +40,18 @@ bool soc_is_brcmstb(void)
return of_match_node(brcmstb_machine_match, root) != NULL;
 }
 
+u32 brcmstb_get_family_id(void)
+{
+   return family_id;
+}
+EXPORT_SYMBOL(brcmstb_get_family_id);
+
+u32 brcmstb_get_product_id(void)
+{
+   return product_id;
+}
+EXPORT_SYMBOL(brcmstb_get_product_id);
+
 static const struct of_device_id sun_top_ctrl_match[] = {
{ .compatible = "brcm,brcmstb-sun-top-ctrl", },
{ }
diff --git a/include/linux/soc/brcmstb/brcmstb.h 
b/include/linux/soc/brcmstb/brcmstb.h
index 337ce41..4bf5edd 100644
--- a/include/linux/soc/brcmstb/brcmstb.h
+++ b/include/linux/soc/brcmstb/brcmstb.h
@@ -1,10 +1,20 @@
 #ifndef __BRCMSTB_SOC_H
 #define __BRCMSTB_SOC_H
 
+#define BRCM_ID(reg)   ((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)
+#define BRCM_REV(reg)  ((u32)reg & 0xff)
+
 /*
  * Bus Interface Unit control register setup, must happen early during boot,
  * before SMP is brought up, called by machine entry point.
  */
 void brcmstb_biuctrl_init(void);
 
+/*
+* Helper functions for getting family or product id from the
+* SoC driver.
+*/
+u32 brcmstb_get_family_id(void);
+u32 brcmstb_get_product_id(void);
+
 #endif /* __BRCMSTB_SOC_H */
-- 
1.9.0.138.g2de3478

--
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


[PATCH V3 0/2] Add Broadcom USB PHY driver for Broadcom STB SoCs

2016-08-30 Thread Al Cooper
Add Broadcom USB PHY driver for Broadcom STB SoCs. This driver in
combination with the generic ohci, ehci and xhci platform drivers
will enable USB1.1, USB2.0 and USB3.0 support.

V3 - Rebase to latest
V2 - Change compatible name from "brcm,usb-phy" to
 "brcm,brcmstb-usb-phy"

Al Cooper (2):
  soc: brcmstb: Add Product ID and Family ID helper functions
  usb: phy: phy-brcm-usb: Add Broadcom STB USB Phy driver

 .../bindings/phy/brcm,brcmstb-usb-phy.txt  |  39 +
 MAINTAINERS|   7 +
 drivers/phy/Kconfig|  10 +
 drivers/phy/Makefile   |   2 +
 drivers/phy/phy-brcm-usb-init.c| 792 +
 drivers/phy/phy-brcm-usb-init.h|  49 ++
 drivers/phy/phy-brcm-usb.c | 206 ++
 drivers/soc/bcm/brcmstb/common.c   |  12 +
 include/linux/soc/brcmstb/brcmstb.h|  10 +
 9 files changed, 1127 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
 create mode 100644 drivers/phy/phy-brcm-usb-init.c
 create mode 100644 drivers/phy/phy-brcm-usb-init.h
 create mode 100644 drivers/phy/phy-brcm-usb.c

-- 
1.9.0.138.g2de3478

--
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


[PATCH] usb: xhci_suspend is not stopping the root hub timer for the shared HCD

2014-07-29 Thread Al Cooper
xhci_suspend() will stop the primary HCD's root hub timer, but leaves
the shared HCD's timer running. This change adds stopping of the
shared HCD timer.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/xhci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 7436d5f..7a1b8fd 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -871,6 +871,7 @@ int xhci_suspend(struct xhci_hcd *xhci)
xhci_dbg(xhci, "%s: stopping port polling.\n", __func__);
clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
del_timer_sync(&hcd->rh_timer);
+   del_timer_sync(&hcd->shared_hcd->rh_timer);
 
spin_lock_irq(&xhci->lock);
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2] usb: xhci_suspend is not stopping the root hub timer for the shared HCD

2014-07-30 Thread Al Cooper
V2 - Restart polling (which will restart the timer) for the shared
HCD in xhci_resume().

xhci_suspend() will stop the primary HCD's root hub timer, but leaves
the shared HCD's timer running. This change adds stopping of the
shared HCD timer.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/xhci.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 7436d5f..300dd25 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -871,6 +871,8 @@ int xhci_suspend(struct xhci_hcd *xhci)
xhci_dbg(xhci, "%s: stopping port polling.\n", __func__);
clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
del_timer_sync(&hcd->rh_timer);
+   clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
+   del_timer_sync(&xhci->shared_hcd->rh_timer);
 
spin_lock_irq(&xhci->lock);
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
@@ -1075,6 +1077,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
xhci_dbg(xhci, "%s: starting port polling.\n", __func__);
set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
usb_hcd_poll_rh_status(hcd);
+   set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
+   usb_hcd_poll_rh_status(xhci->shared_hcd);
 
return retval;
 }
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2] usb: xhci_suspend is not stopping the root hub timer for the shared HCD

2014-08-06 Thread Al Cooper
V2 - Restart polling (which will restart the timer) for the shared
HCD in xhci_resume().

xhci_suspend() will stop the primary HCD's root hub timer, but leaves
the shared HCD's timer running. This change adds stopping of the
shared HCD timer.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/xhci.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index b6f2117..1557d4f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -871,6 +871,8 @@ int xhci_suspend(struct xhci_hcd *xhci)
xhci_dbg(xhci, "%s: stopping port polling.\n", __func__);
clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
del_timer_sync(&hcd->rh_timer);
+   clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
+   del_timer_sync(&xhci->shared_hcd->rh_timer);
 
spin_lock_irq(&xhci->lock);
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
@@ -1075,6 +1077,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
xhci_dbg(xhci, "%s: starting port polling.\n", __func__);
set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
usb_hcd_poll_rh_status(hcd);
+   set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
+   usb_hcd_poll_rh_status(xhci->shared_hcd);
 
return retval;
 }
-- 
1.9.0.138.g2de3478

--
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


[PATCH 4/4] MAINTAINERS: Add entry for BDC UDC driver

2015-07-16 Thread Al Cooper
Signed-off-by: Al Cooper 
---
 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 246d9d8..88b443d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2301,6 +2301,12 @@ L:   net...@vger.kernel.org
 S: Supported
 F: drivers/net/ethernet/broadcom/bcmsysport.*
 
+BROADCOM BDC UDC DRIVER
+M: Al Cooper 
+L: linux-usb@vger.kernel.org
+S: Supported
+F: drivers/usb/gadget/udc/bdc/*
+
 BROCADE BFA FC SCSI DRIVER
 M: Anil Gurumurthy 
 M: Sudarsana Kalluru 
-- 
1.9.0.138.g2de3478

--
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


[PATCH 2/4] usb: gadget: udc: bdc: Add a Device Tree compatible string

2015-07-16 Thread Al Cooper
Allows Device Tree probing

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 5c8f4ef..0f963d5 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -518,9 +518,17 @@ static int bdc_remove(struct platform_device *pdev)
return 0;
 }
 
+static const struct of_device_id bdc_of_match[] = {
+   { .compatible = "brcm,bdc-udc-v0.16" },
+   { .compatible = "brcm,bdc-udc" },
+   { /* sentinel */ }
+};
+
 static struct platform_driver bdc_driver = {
.driver = {
.name   = BRCM_BDC_NAME,
+   .owner  = THIS_MODULE,
+   .of_match_table = bdc_of_match,
},
.probe  = bdc_probe,
.remove = bdc_remove,
-- 
1.9.0.138.g2de3478

--
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


[PATCH 3/4] usb: gadget: bdc: Add device-tree binding document for BDC driver

2015-07-16 Thread Al Cooper
Signed-off-by: Al Cooper 
---
 Documentation/devicetree/bindings/usb/bdc-udc.txt | 16 
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/bdc-udc.txt

diff --git a/Documentation/devicetree/bindings/usb/bdc-udc.txt 
b/Documentation/devicetree/bindings/usb/bdc-udc.txt
new file mode 100644
index 000..18fb948
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/bdc-udc.txt
@@ -0,0 +1,16 @@
+USB Device Controller (UDC) for Broadcom Device Controller (BDC)
+
+Required properties:
+
+- compatible: Must be "brcm,bdc-udc-v0.16" or "brcm,bdc-udc"
+
+- reg: Address and length of the register set for the device
+
+- interrupts: Interrupt number for this device
+
+Example:
+   bdc@f0472000 {
+   compatible = "brcm,bdc-udc-v0.16", "brcm,bdc-udc";
+   reg = <0xf0472000 0xfc4>;
+   interrupts = <0x0 0x76 0x0>;
+   };
-- 
1.9.0.138.g2de3478

--
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


[PATCH 1/4] usb: gadget: udc: bdc: Fix a driver crash on disconnect

2015-07-16 Thread Al Cooper
ep_dequeue() in bdc_ep.c was capturing the hw dequeue pointer
incorrectly by reading the wrong register for the upper 32 bits.
The header file defining the registers was incorrect.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h | 16 
 drivers/usb/gadget/udc/bdc/bdc_dbg.c | 16 
 drivers/usb/gadget/udc/bdc/bdc_ep.c  |  4 ++--
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index dc18a20..56c059f 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -83,14 +83,14 @@
 
 #define BDC_DVCSA  0x50
 #define BDC_DVCSB  0x54
-#define BDC_EPSTS0(n)  (0x60 + (n * 0x10))
-#define BDC_EPSTS1(n)  (0x64 + (n * 0x10))
-#define BDC_EPSTS2(n)  (0x68 + (n * 0x10))
-#define BDC_EPSTS3(n)  (0x6c + (n * 0x10))
-#define BDC_EPSTS4(n)  (0x70 + (n * 0x10))
-#define BDC_EPSTS5(n)  (0x74 + (n * 0x10))
-#define BDC_EPSTS6(n)  (0x78 + (n * 0x10))
-#define BDC_EPSTS7(n)  (0x7c + (n * 0x10))
+#define BDC_EPSTS0 0x60
+#define BDC_EPSTS1 0x64
+#define BDC_EPSTS2 0x68
+#define BDC_EPSTS3 0x6c
+#define BDC_EPSTS4 0x70
+#define BDC_EPSTS5 0x74
+#define BDC_EPSTS6 0x78
+#define BDC_EPSTS7 0x7c
 #define BDC_SRRBAL(n)  (0x200 + (n * 0x10))
 #define BDC_SRRBAH(n)  (0x204 + (n * 0x10))
 #define BDC_SRRINT(n)  (0x208 + (n * 0x10))
diff --git a/drivers/usb/gadget/udc/bdc/bdc_dbg.c 
b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
index 5945dbc..8445bf9 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_dbg.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
@@ -40,28 +40,28 @@ void bdc_dump_epsts(struct bdc *bdc)
 {
u32 temp;
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS0(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS0);
dev_vdbg(bdc->dev, "BDC_EPSTS0:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS1(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS1);
dev_vdbg(bdc->dev, "BDC_EPSTS1:0x%x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS2(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS2);
dev_vdbg(bdc->dev, "BDC_EPSTS2:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS3(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS3);
dev_vdbg(bdc->dev, "BDC_EPSTS3:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS4(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS4);
dev_vdbg(bdc->dev, "BDC_EPSTS4:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS5(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS5);
dev_vdbg(bdc->dev, "BDC_EPSTS5:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS6(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS6);
dev_vdbg(bdc->dev, "BDC_EPSTS6:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS7(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS7));
dev_vdbg(bdc->dev, "BDC_EPSTS7:0x%08x\n", temp);
 }
 
diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c 
b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index b04980c..e56ccbe 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -777,9 +777,9 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req 
*req)
 */
 
/* The current hw dequeue pointer */
-   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(0));
+   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0);
deq_ptr_64 = tmp_32;
-   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(1));
+   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS1);
deq_ptr_64 |= ((u64)tmp_32 << 32);
 
/* we have the dma addr of next bd that will be fetched by hardware */
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2 1/4] usb: gadget: udc: bdc: Fix a driver crash on disconnect

2015-07-22 Thread Al Cooper
V2 - Fix a compiler bug that happend when the config options
CONFIG_USB_GADGET_DEBUG and CONFIG_USB_GADGET_VERBOSE
were enabled.

ep_dequeue() in bdc_ep.c was capturing the hw dequeue pointer
incorrectly by reading the wrong register for the upper 32 bits.
The header file defining the registers was incorrect.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h | 16 
 drivers/usb/gadget/udc/bdc/bdc_dbg.c | 16 
 drivers/usb/gadget/udc/bdc/bdc_ep.c  |  4 ++--
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index dc18a20..56c059f 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -83,14 +83,14 @@
 
 #define BDC_DVCSA  0x50
 #define BDC_DVCSB  0x54
-#define BDC_EPSTS0(n)  (0x60 + (n * 0x10))
-#define BDC_EPSTS1(n)  (0x64 + (n * 0x10))
-#define BDC_EPSTS2(n)  (0x68 + (n * 0x10))
-#define BDC_EPSTS3(n)  (0x6c + (n * 0x10))
-#define BDC_EPSTS4(n)  (0x70 + (n * 0x10))
-#define BDC_EPSTS5(n)  (0x74 + (n * 0x10))
-#define BDC_EPSTS6(n)  (0x78 + (n * 0x10))
-#define BDC_EPSTS7(n)  (0x7c + (n * 0x10))
+#define BDC_EPSTS0 0x60
+#define BDC_EPSTS1 0x64
+#define BDC_EPSTS2 0x68
+#define BDC_EPSTS3 0x6c
+#define BDC_EPSTS4 0x70
+#define BDC_EPSTS5 0x74
+#define BDC_EPSTS6 0x78
+#define BDC_EPSTS7 0x7c
 #define BDC_SRRBAL(n)  (0x200 + (n * 0x10))
 #define BDC_SRRBAH(n)  (0x204 + (n * 0x10))
 #define BDC_SRRINT(n)  (0x208 + (n * 0x10))
diff --git a/drivers/usb/gadget/udc/bdc/bdc_dbg.c 
b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
index 5945dbc..ac98f6f 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_dbg.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
@@ -40,28 +40,28 @@ void bdc_dump_epsts(struct bdc *bdc)
 {
u32 temp;
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS0(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS0);
dev_vdbg(bdc->dev, "BDC_EPSTS0:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS1(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS1);
dev_vdbg(bdc->dev, "BDC_EPSTS1:0x%x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS2(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS2);
dev_vdbg(bdc->dev, "BDC_EPSTS2:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS3(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS3);
dev_vdbg(bdc->dev, "BDC_EPSTS3:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS4(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS4);
dev_vdbg(bdc->dev, "BDC_EPSTS4:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS5(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS5);
dev_vdbg(bdc->dev, "BDC_EPSTS5:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS6(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS6);
dev_vdbg(bdc->dev, "BDC_EPSTS6:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS7(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS7);
dev_vdbg(bdc->dev, "BDC_EPSTS7:0x%08x\n", temp);
 }
 
diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c 
b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index b04980c..e56ccbe 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -777,9 +777,9 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req 
*req)
 */
 
/* The current hw dequeue pointer */
-   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(0));
+   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0);
deq_ptr_64 = tmp_32;
-   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(1));
+   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS1);
deq_ptr_64 |= ((u64)tmp_32 << 32);
 
/* we have the dma addr of next bd that will be fetched by hardware */
-- 
1.9.0.138.g2de3478

--
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


[PATCH] usb: gadget: udc: bdc: Minimal fix for a driver crash on disconnect

2015-07-24 Thread Al Cooper
ep_dequeue() in bdc_ep.c was capturing the hw dequeue pointer
incorrectly by reading the wrong register for the upper 32 bits.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc_ep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c 
b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index b04980c..1efa612 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -779,7 +779,7 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req 
*req)
/* The current hw dequeue pointer */
tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(0));
deq_ptr_64 = tmp_32;
-   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(1));
+   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS1(0));
deq_ptr_64 |= ((u64)tmp_32 << 32);
 
/* we have the dma addr of next bd that will be fetched by hardware */
-- 
1.9.0.138.g2de3478

--
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


[PATCH] usb: xhci: Fix OOPS in xhci error handling code

2014-08-26 Thread Al Cooper
The xhci driver will OOPS on resume from S2/S3 if dma_alloc_coherent()
is out of memory. This is a result of two things:
1. xhci_mem_cleanup() in xhci-mem.c free's xhci->lpm_command if
it's not NULL, but doesn't set it to NULL after the free.
2. xhci_mem_cleanup() is called twice on resume, once for normal
restart and once from xhci_mem_init() if dma_alloc_coherent() fails,
resulting in a free of xhci->lpm_command that has already been freed.
The fix is to set xhci->lpm_command to NULL after freeing it.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/xhci-mem.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 8056d90..efb2e7c 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1812,6 +1812,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
 
if (xhci->lpm_command)
xhci_free_command(xhci, xhci->lpm_command);
+   xhci->lpm_command = NULL;
if (xhci->cmd_ring)
xhci_ring_free(xhci, xhci->cmd_ring);
xhci->cmd_ring = NULL;
-- 
1.9.0.138.g2de3478

--
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


[PATCH] usb: Add connected retry on resume for non SS devices

2015-12-02 Thread Al Cooper
Currently usb_port_resume waits for up to 2 seconds for CONNECT
status for SS devices only. This change will do the same thing for
non-SS devices even though the reason is a little different. This
will fix an issue where VBUS is turned off during system wide
"suspend to ram" and some 2.0 devices take greater than the current
max of 100ms to show connected after VBUS is enabled. This is most
commonly seen on hard drive based devices and USB3.0 devices plugged
into a 2.0 only port.

Signed-off-by: Al Cooper 
---
 drivers/usb/core/hub.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index bdeadc1..d32824b 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3322,7 +3322,7 @@ static int finish_port_resume(struct usb_device *udev)
  * This routine should only be called when persist is enabled for a SS
  * device.
  */
-static int wait_for_ss_port_enable(struct usb_device *udev,
+static int wait_for_connected(struct usb_device *udev,
struct usb_hub *hub, int *port1,
u16 *portchange, u16 *portstatus)
 {
@@ -3434,8 +3434,8 @@ int usb_port_resume(struct usb_device *udev, pm_message_t 
msg)
}
}
 
-   if (udev->persist_enabled && hub_is_superspeed(hub->hdev))
-   status = wait_for_ss_port_enable(udev, hub, &port1, &portchange,
+   if (udev->persist_enabled)
+   status = wait_for_connected(udev, hub, &port1, &portchange,
&portstatus);
 
status = check_port_resume_type(udev,
-- 
1.9.0.138.g2de3478

--
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


[PATCH V2] usb: Add connected retry on resume for non SS devices

2015-12-02 Thread Al Cooper
Currently usb_port_resume waits for up to 2 seconds for CONNECT
status for SS devices only. This change will do the same thing for
non-SS devices even though the reason is a little different. This
will fix an issue where VBUS is turned off during system wide
"suspend to ram" and some 2.0 devices take greater than the current
max of 100ms to show connected after VBUS is enabled. This is most
commonly seen on hard drive based devices and USB3.0 devices plugged
into a 2.0 only port.

Signed-off-by: Al Cooper 
---

V2 - Change comment to reflect change to wait_for_connect()
   - Add dev_dbg message that shows the actual wait time

 drivers/usb/core/hub.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index bdeadc1..00a0554 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3304,7 +3304,7 @@ static int finish_port_resume(struct usb_device *udev)
 /*
  * There are some SS USB devices which take longer time for link training.
  * XHCI specs 4.19.4 says that when Link training is successful, port
- * sets CSC bit to 1. So if SW reads port status before successful link
+ * sets CCS bit to 1. So if SW reads port status before successful link
  * training, then it will not find device to be present.
  * USB Analyzer log with such buggy devices show that in some cases
  * device switch on the RX termination after long delay of host enabling
@@ -3315,14 +3315,17 @@ static int finish_port_resume(struct usb_device *udev)
  * routine implements a 2000 ms timeout for link training. If in a case
  * link trains before timeout, loop will exit earlier.
  *
+ * There are also some 2.0 hard drive based devices and 3.0 thumb
+ * drives that, when plugged into a 2.0 only port, take a long
+ * time to set CCS after VBUS enable.
+ *
  * FIXME: If a device was connected before suspend, but was removed
  * while system was asleep, then the loop in the following routine will
  * only exit at timeout.
  *
- * This routine should only be called when persist is enabled for a SS
- * device.
+ * This routine should only be called when persist is enabled.
  */
-static int wait_for_ss_port_enable(struct usb_device *udev,
+static int wait_for_connected(struct usb_device *udev,
struct usb_hub *hub, int *port1,
u16 *portchange, u16 *portstatus)
 {
@@ -3335,6 +3338,7 @@ static int wait_for_ss_port_enable(struct usb_device 
*udev,
delay_ms += 20;
status = hub_port_status(hub, *port1, portstatus, portchange);
}
+   dev_dbg(&udev->dev, "Waited %dms for CONNECT\n", delay_ms);
return status;
 }
 
@@ -3434,8 +3438,8 @@ int usb_port_resume(struct usb_device *udev, pm_message_t 
msg)
}
}
 
-   if (udev->persist_enabled && hub_is_superspeed(hub->hdev))
-   status = wait_for_ss_port_enable(udev, hub, &port1, &portchange,
+   if (udev->persist_enabled)
+   status = wait_for_connected(udev, hub, &port1, &portchange,
&portstatus);
 
status = check_port_resume_type(udev,
-- 
1.9.0.138.g2de3478

--
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


[PATCH 2/5] usb: host: Add OHCI driver for Broadcom STB SoCs

2018-09-26 Thread Al Cooper
This driver enables USB OHCI on Broadcom ARM and MIPS STB SoCs.
The drivers depend on a matching "brcm,brcmstb-usb-phy"
Broadcom STB USB Phy driver.

The standard platform driver can't be used because of differences
in PHY and Clock handling. The standard PHY handling in hcd.c will
do a phy_exit/phy_init on suspend/resume and this will end up
shutting down the PHYs to the point that the host controller
registers are no longer accessible and will cause suspend to crash.
The clocks specified in device tree for these drivers are not
available in mainline so instead of returning EPROBE_DEFER when
the specified clock is not found and eventually failing probe,
the clock pointer is set to NULL which disables all clock handling.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/ohci-brcm.c | 204 +++
 1 file changed, 204 insertions(+)
 create mode 100644 drivers/usb/host/ohci-brcm.c

diff --git a/drivers/usb/host/ohci-brcm.c b/drivers/usb/host/ohci-brcm.c
new file mode 100644
index ..d4de59a56e2c
--- /dev/null
+++ b/drivers/usb/host/ohci-brcm.c
@@ -0,0 +1,204 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, Broadcom */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ohci.h"
+
+#define BRCM_DRIVER_DESC "OHCI Broadcom STB driver"
+
+static const char hcd_name[] = "ohci-brcm";
+
+#define hcd_to_ohci_priv(h) ((struct brcm_priv *)hcd_to_ohci(h)->priv)
+
+struct brcm_priv {
+   struct clk *clk;
+   struct phy *phy;
+};
+
+static struct hc_driver __read_mostly ohci_brcm_hc_driver;
+
+static const struct ohci_driver_overrides brcm_overrides __initconst = {
+   .product_desc = "Broadcom STB OHCI controller",
+   .extra_priv_size = sizeof(struct brcm_priv),
+};
+
+static int ohci_brcm_probe(struct platform_device *dev)
+{
+   struct usb_hcd *hcd;
+   struct brcm_priv *priv;
+   struct resource *res_mem;
+   int irq;
+   int err;
+
+   if (usb_disabled())
+   return -ENODEV;
+
+   err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32));
+   if (err)
+   return err;
+
+   irq = platform_get_irq(dev, 0);
+   if (irq < 0) {
+   dev_err(&dev->dev, "no irq provided");
+   return irq;
+   }
+
+   /* initialize hcd */
+   hcd = usb_create_hcd(&ohci_brcm_hc_driver,
+   &dev->dev, dev_name(&dev->dev));
+   if (!hcd)
+   return -ENOMEM;
+
+   platform_set_drvdata(dev, hcd);
+   priv = hcd_to_ohci_priv(hcd);
+
+   priv->clk = devm_clk_get(&dev->dev, NULL);
+   if (IS_ERR(priv->clk)) {
+   dev_err(&dev->dev, "Clock not found in Device Tree\n");
+   priv->clk = NULL;
+   }
+   err = clk_prepare_enable(priv->clk);
+   if (err)
+   goto err_hcd;
+
+   priv->phy = devm_of_phy_get_by_index(&dev->dev, dev->dev.of_node, 0);
+   if (IS_ERR(priv->phy)) {
+   dev_err(&dev->dev, "USB Phy not found.\n");
+   err = PTR_ERR(priv->phy);
+   goto err_clk;
+   }
+   phy_init(priv->phy);
+
+   pm_runtime_set_active(&dev->dev);
+   pm_runtime_enable(&dev->dev);
+
+   res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
+   hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
+   if (IS_ERR(hcd->regs)) {
+   err = PTR_ERR(hcd->regs);
+   goto err_phy;
+   }
+   hcd->rsrc_start = res_mem->start;
+   hcd->rsrc_len = resource_size(res_mem);
+   hcd->skip_phy_initialization = 1;
+   err = usb_add_hcd(hcd, irq, IRQF_SHARED);
+   if (err)
+   goto err_phy;
+
+   device_wakeup_enable(hcd->self.controller);
+
+   platform_set_drvdata(dev, hcd);
+
+   return err;
+
+err_phy:
+   pm_runtime_disable(&dev->dev);
+   phy_exit(priv->phy);
+err_clk:
+   clk_disable_unprepare(priv->clk);
+err_hcd:
+   usb_put_hcd(hcd);
+
+   return err;
+
+}
+
+static int ohci_brcm_remove(struct platform_device *dev)
+{
+   struct usb_hcd *hcd = platform_get_drvdata(dev);
+   struct brcm_priv *priv = hcd_to_ohci_priv(hcd);
+
+   pm_runtime_get_sync(&dev->dev);
+   usb_remove_hcd(hcd);
+   phy_exit(priv->phy);
+   clk_disable_unprepare(priv->clk);
+   usb_put_hcd(hcd);
+   pm_runtime_put_sync(&dev->dev);
+   pm_runtime_disable(&dev->dev);
+   return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+
+static int ohci_brcm_suspend(struct device *dev)
+{
+   int ret;
+   struct usb_hcd *hcd = dev_get_drvdata(dev);
+   struct brcm_priv *priv = hcd_to_ohci_priv(hcd);

[PATCH 4/5] usb: host: Add XHCI driver for Broadcom STB SoCs

2018-09-26 Thread Al Cooper
This driver enables USB XHCI on Broadcom ARM STB SoCs.
The drivers depend on a matching "brcm,brcmstb-usb-phy"
Broadcom STB USB Phy driver.

The standard platform driver can't be used because of differences
in PHY and Clock handling. The standard PHY handling in hcd.c will
do a phy_exit/phy_init on suspend/resume and this will end up
shutting down the PHYs to the point that the host controller
registers are no longer accessible and will cause suspend to crash.
The clocks specified in device tree for these drivers are not
available in mainline so instead of returning EPROBE_DEFER when
the specified clock is not found and eventually failing probe,
the clock pointer is set to NULL which disables all clock handling.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/xhci-brcm.c | 294 +++
 1 file changed, 294 insertions(+)
 create mode 100644 drivers/usb/host/xhci-brcm.c

diff --git a/drivers/usb/host/xhci-brcm.c b/drivers/usb/host/xhci-brcm.c
new file mode 100644
index ..1a7578b8ef6a
--- /dev/null
+++ b/drivers/usb/host/xhci-brcm.c
@@ -0,0 +1,294 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, Broadcom */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "xhci.h"
+
+static struct hc_driver __read_mostly xhci_brcm_hc_driver;
+
+#define BRCM_DRIVER_DESC "xHCI Broadcom STB driver"
+#define BRCM_DRIVER_NAME "xhci-brcm"
+
+#define hcd_to_xhci_priv(h) ((struct brcm_priv *)hcd_to_xhci(h)->priv)
+
+struct brcm_priv {
+   struct phy *phy;
+};
+
+static void xhci_brcm_quirks(struct device *dev, struct xhci_hcd *xhci)
+{
+   /*
+* As of now platform drivers don't provide MSI support so we ensure
+* here that the generic code does not try to make a pci_dev from our
+* dev struct in order to setup MSI
+*/
+   xhci->quirks |= XHCI_PLAT;
+
+   /*
+* The Broadcom XHCI core does not support save/restore state
+* so we need to reset on resume.
+*/
+   xhci->quirks |= XHCI_RESET_ON_RESUME;
+}
+
+/* called during probe() after chip reset completes */
+static int xhci_brcm_setup(struct usb_hcd *hcd)
+{
+   return xhci_gen_setup(hcd, xhci_brcm_quirks);
+}
+
+static const struct xhci_driver_overrides brcm_overrides __initconst = {
+
+   .extra_priv_size = sizeof(struct brcm_priv),
+   .reset = xhci_brcm_setup,
+};
+
+static int xhci_brcm_probe(struct platform_device *pdev)
+{
+   const struct hc_driver  *driver;
+   struct brcm_priv*priv;
+   struct xhci_hcd *xhci;
+   struct resource *res;
+   struct usb_hcd  *hcd;
+   int ret;
+   int irq;
+
+   if (usb_disabled())
+   return -ENODEV;
+
+   driver = &xhci_brcm_hc_driver;
+
+   irq = platform_get_irq(pdev, 0);
+   if (irq < 0)
+   return -ENODEV;
+
+   /* Try to set 64-bit DMA first */
+   if (WARN_ON(!pdev->dev.dma_mask))
+   /* Platform did not initialize dma_mask */
+   ret = dma_coerce_mask_and_coherent(&pdev->dev,
+  DMA_BIT_MASK(64));
+   else
+   ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+
+   /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
+   if (ret) {
+   ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
+
+   pm_runtime_set_active(&pdev->dev);
+   pm_runtime_enable(&pdev->dev);
+   pm_runtime_get_noresume(&pdev->dev);
+
+   hcd = __usb_create_hcd(driver, &pdev->dev, &pdev->dev,
+  dev_name(&pdev->dev), NULL);
+   if (!hcd) {
+   return -ENOMEM;
+   goto disable_runtime;
+   }
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+   if (IS_ERR(hcd->regs)) {
+   ret = PTR_ERR(hcd->regs);
+   goto put_hcd;
+   }
+
+   hcd->rsrc_start = res->start;
+   hcd->rsrc_len = resource_size(res);
+
+   /*
+* Not all platforms have a clk so it is not an error if the
+* clock does not exists.
+*/
+   xhci = hcd_to_xhci(hcd);
+   xhci->clk = devm_clk_get(&pdev->dev, NULL);
+   if (IS_ERR(xhci->clk)) {
+   dev_err(&pdev->dev, "Clock not found in Device Tree\n");
+   xhci->clk = NULL;
+   }
+   device_wakeup_enable(hcd->self.controller);
+
+   xhci->main_hcd = hcd;
+   xhci->shared_hcd = __usb_create_hcd(driver, &pdev->dev, &pdev->dev,
+   

[PATCH 5/5] usb: host: Enable building of new Broadcom STB USB drivers

2018-09-26 Thread Al Cooper
Changes to Makefile and Kconfig to enable building of the new
Broadcom STB OHCI, EHCI and XHCI drivers. Also update MAINTAINERS.

Signed-off-by: Al Cooper 
---
 MAINTAINERS   |  9 +
 drivers/usb/host/Kconfig  | 27 +++
 drivers/usb/host/Makefile |  7 +++
 3 files changed, 43 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 02a39617ec82..9b8e7caad2ba 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3007,6 +3007,15 @@ S:   Supported
 F: drivers/gpio/gpio-brcmstb.c
 F: Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt
 
+BROADCOM BRCMSTB USB XHCI, EHCI and OHCI DRIVERS
+M: Al Cooper 
+L: linux-usb@vger.kernel.org
+L: bcm-kernel-feedback-l...@broadcom.com
+S: Maintained
+F: drivers/usb/host/xhci-brcm.c
+F: drivers/usb/host/ehci-brcm.c
+F: drivers/usb/host/ohci-brcm.c
+
 BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER
 M: Al Cooper 
 L: linux-ker...@vger.kernel.org
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 1a4ea98cac2a..1693a5076980 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -798,3 +798,30 @@ config USB_HCD_TEST_MODE
  This option is of interest only to developers who need to validate
  their USB hardware designs.  It is not needed for normal use.  If
  unsure, say N.
+
+config USB_OHCI_BRCM
+   tristate
+
+config USB_EHCI_BRCM
+   tristate
+
+config USB_XHCI_BRCM
+   tristate
+
+config BRCM_USB_PHY
+   tristate
+
+config USB_BRCM
+   tristate "Broadcom STB USB support"
+   depends on ARCH_BRCMSTB
+   select USB_OHCI_BRCM if USB_OHCI_HCD
+   select USB_EHCI_BRCM if USB_EHCI_HCD
+   select USB_XHCI_BRCM if USB_XHCI_HCD
+   select BRCM_USB_PHY if USB_OHCI_HCD || USB_EHCI_HCD || USB_XHCI_HCD
+   select GENERIC_PHY if BRCM_USB_PHY
+   default ARCH_BRCMSTB
+   help
+ Say Y to enable the drivers for the onchip USB controllers.
+
+ If your chipset supports power management, disabling this driver
+ will keep the device permanently powered down.
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index e6235269c151..13e4f45a3a1d 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -91,3 +91,10 @@ obj-$(CONFIG_USB_HCD_BCMA)   += bcma-hcd.o
 obj-$(CONFIG_USB_HCD_SSB)  += ssb-hcd.o
 obj-$(CONFIG_USB_FOTG210_HCD)  += fotg210-hcd.o
 obj-$(CONFIG_USB_MAX3421_HCD)  += max3421-hcd.o
+
+# The order is important here because it controls the order that
+# the drivers will be initialized and we always need to init
+# the drivers in the order XHCI, EHCI and OHCI.
+obj-$(CONFIG_USB_XHCI_BRCM)+= xhci-brcm.o
+obj-$(CONFIG_USB_EHCI_BRCM)+= ehci-brcm.o
+obj-$(CONFIG_USB_OHCI_BRCM)+= ohci-brcm.o
-- 
1.9.0.138.g2de3478



[PATCH 1/5] dt-bindings: Add Broadcom STB OHCI, EHCI and XHCI binding document

2018-09-26 Thread Al Cooper
Add DT bindings document for Broadcom STB USB OHCI, EHCI and
XHCI drivers.

Signed-off-by: Al Cooper 
---
 .../devicetree/bindings/usb/brcm,ehci-brcm.txt | 22 +
 .../devicetree/bindings/usb/brcm,ohci-brcm.txt | 22 +
 .../devicetree/bindings/usb/brcm,xhci-brcm.txt | 23 ++
 3 files changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,ehci-brcm.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,ohci-brcm.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,xhci-brcm.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,ehci-brcm.txt 
b/Documentation/devicetree/bindings/usb/brcm,ehci-brcm.txt
new file mode 100644
index ..020b5ec40f5b
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,ehci-brcm.txt
@@ -0,0 +1,22 @@
+Broadcom STB USB EHCI controller
+
+Required properties:
+- compatible: should be "brcm,ehci-brcm-v2"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+- phys: phandle + phy specifier pair
+  The specifier should be 0 for the OHCI/EHCI PHY and 1 for the XHCI PHY
+
+Optional properties:
+- clocks: A list of phandles for the clocks
+
+Example:
+
+ehci@f0b00300 {
+   compatible = "brcm,ehci-brcm-v2";
+   reg = <0xf0b00300 0xa8>;
+   interrupts = <0x0 0x5a 0x0>;
+   interrupt-names = "usb0_ehci_0";
+   phys = <&usbphy_0 0x0>;
+   clocks = <&usb20>
+};
diff --git a/Documentation/devicetree/bindings/usb/brcm,ohci-brcm.txt 
b/Documentation/devicetree/bindings/usb/brcm,ohci-brcm.txt
new file mode 100644
index ..c7bb56f30540
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,ohci-brcm.txt
@@ -0,0 +1,22 @@
+Broadcom STB USB OHCI controller
+
+Required properties:
+- compatible: should be "brcm,ohci-brcm-v2"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+- phys: phandle + phy specifier pair
+  The specifier should be 0 for the OHCI/EHCI PHY and 1 for the XHCI PHY
+
+Optional properties:
+- clocks: A list of phandles for the clocks
+
+Example:
+
+ohci@f0b00400 {
+   compatible = "brcm,ohci-brcm-v2";
+   reg = <0xf0b00400 0x58>;
+   interrupts = <0x0 0x5b 0x0>;
+   interrupt-names = "usb0_ohci_0";
+   phys = <&usbphy_0 0x0>;
+   clocks = <&usb20>;
+};
diff --git a/Documentation/devicetree/bindings/usb/brcm,xhci-brcm.txt 
b/Documentation/devicetree/bindings/usb/brcm,xhci-brcm.txt
new file mode 100644
index ..7ca5f126c2f6
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,xhci-brcm.txt
@@ -0,0 +1,23 @@
+Broadcom STB USB XHCI controller
+
+Required properties:
+- compatible: should be "brcm,xhci-brcm-v2"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+- phys: phandle + phy specifier pair
+  The specifier should be 0 for the OHCI/EHCI PHY and 1 for the XHCI PHY
+
+Optional properties:
+- clocks: A list of phandles for the clocks
+- usb3-lpm-capable: determines if platform is USB3 LPM capable
+
+Example:
+
+xhci_0_0: xhci@f0b01000 {
+   compatible = "brcm,xhci-brcm-v2";
+   reg = <0xf0b01000 0x1000>;
+   interrupts = <0x0 0x5c 0x0>;
+   interrupt-names = "usb0_xhci_0";
+   phys = <&usbphy_0 0x1>;
+   clocks = <&usb30>;
+};
-- 
1.9.0.138.g2de3478



[PATCH 3/5] usb: host: Add EHCI driver for Broadcom STB SoCs

2018-09-26 Thread Al Cooper
This driver enables USB EHCI on Broadcom ARM and MIPS STB SoCs.
The drivers depend on a matching "brcm,brcmstb-usb-phy"
Broadcom STB USB Phy driver.

The standard platform driver can't be used because of differences
in PHY and Clock handling. The standard PHY handling in hcd.c will
do a phy_exit/phy_init on suspend/resume and this will end up
shutting down the PHYs to the point that the host controller
registers are no longer accessible and will cause suspend to crash.
The clocks specified in device tree for these drivers are not
available in mainline so instead of returning EPROBE_DEFER when
the specified clock is not found and eventually failing probe,
the clock pointer is set to NULL which disables all clock handling.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/ehci-brcm.c | 304 +++
 1 file changed, 304 insertions(+)
 create mode 100644 drivers/usb/host/ehci-brcm.c

diff --git a/drivers/usb/host/ehci-brcm.c b/drivers/usb/host/ehci-brcm.c
new file mode 100644
index ..6bee4e0e2cbb
--- /dev/null
+++ b/drivers/usb/host/ehci-brcm.c
@@ -0,0 +1,304 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, Broadcom */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ehci.h"
+
+#define BRCM_DRIVER_DESC "EHCI Broadcom STB driver"
+
+#define hcd_to_ehci_priv(h) ((struct brcm_priv *)hcd_to_ehci(h)->priv)
+
+struct brcm_priv {
+   struct clk *clk;
+   struct phy *phy;
+};
+
+static const char brcm_hcd_name[] = "ehci-brcm";
+
+static int (*org_hub_control)(struct usb_hcd *hcd,
+   u16 typeReq, u16 wValue, u16 wIndex,
+   char *buf, u16 wLength);
+
+/* ehci_brcm_wait_for_sof
+ * Wait for start of next microframe, then wait extra delay microseconds
+ */
+static inline void ehci_brcm_wait_for_sof(struct ehci_hcd *ehci, u32 delay)
+{
+   int frame_idx = ehci_readl(ehci, &ehci->regs->frame_index);
+
+   while (frame_idx == ehci_readl(ehci, &ehci->regs->frame_index))
+   ;
+   udelay(delay);
+}
+
+/*
+ * ehci_brcm_hub_control
+ * Intercept echi-hcd request to complete RESUME and align it to the start
+ * of the next microframe.
+ * If RESUME is complete too late in the microframe, host controller
+ * detects babble on suspended port and resets the port afterwards.
+ * This s/w workaround allows to avoid this problem.
+ * See SWLINUX-1909 for more details
+ */
+static int ehci_brcm_hub_control(
+   struct usb_hcd  *hcd,
+   u16 typeReq,
+   u16 wValue,
+   u16 wIndex,
+   char*buf,
+   u16 wLength)
+{
+   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+   int ports = HCS_N_PORTS(ehci->hcs_params);
+   u32 __iomem *status_reg = &ehci->regs->port_status[
+   (wIndex & 0xff) - 1];
+   unsigned long flags;
+   int retval, irq_disabled = 0;
+
+   /*
+* RESUME is cleared when GetPortStatus() is called 20ms after start
+* of RESUME
+*/
+   if ((typeReq == GetPortStatus) &&
+   (wIndex && wIndex <= ports) &&
+   ehci->reset_done[wIndex-1] &&
+   time_after_eq(jiffies, ehci->reset_done[wIndex-1]) &&
+   (ehci_readl(ehci, status_reg) & PORT_RESUME)) {
+
+   /*
+* to make sure we are not interrupted until RESUME bit
+* is cleared, disable interrupts on current CPU
+*/
+   ehci_dbg(ehci, "SOF alignment workaround\n");
+   irq_disabled = 1;
+   local_irq_save(flags);
+   ehci_brcm_wait_for_sof(ehci, 5);
+   }
+   retval = (*org_hub_control)(hcd, typeReq, wValue, wIndex, buf, wLength);
+   if (irq_disabled)
+   local_irq_restore(flags);
+   return retval;
+}
+
+static int ehci_brcm_reset(struct usb_hcd *hcd)
+{
+   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+
+   ehci->big_endian_mmio = 1;
+
+   ehci->caps = (struct ehci_caps *) hcd->regs;
+   ehci->regs = (struct ehci_regs *) (hcd->regs +
+   HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)));
+
+   /* This fixes the lockup during reboot due to prior interrupts */
+   ehci_writel(ehci, CMD_RESET, &ehci->regs->command);
+   mdelay(10);
+
+   /*
+* SWLINUX-1705: Avoid OUT packet underflows during high memory
+*   bus usage
+* port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x90
+*/
+   ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]);
+   ehci_writel(ehci, 0x0001, &ehci->regs->port_sta

[PATCH 0/5] Add XHCI, EHCI and OHCI drivers for Broadcom STB SoCs

2018-09-26 Thread Al Cooper
Add XHCI, EHCI and OHCI drivers for Broadcom STB SoCs. These drivers
depend on getting access to the new Broadcom STB USB PHY driver
through a device-tree phandle and will fail if the driver is not
available.

Al Cooper (5):
  dt-bindings: Add Broadcom STB OHCI, EHCI and XHCI binding document
  usb: host: Add OHCI driver for Broadcom STB SoCs
  usb: host: Add EHCI driver for Broadcom STB SoCs
  usb: host: Add XHCI driver for Broadcom STB SoCs
  usb: host: Enable building of new Broadcom STB USB drivers

 .../devicetree/bindings/usb/brcm,ehci-brcm.txt |  22 ++
 .../devicetree/bindings/usb/brcm,ohci-brcm.txt |  22 ++
 .../devicetree/bindings/usb/brcm,xhci-brcm.txt |  23 ++
 MAINTAINERS|   9 +
 drivers/usb/host/Kconfig   |  27 ++
 drivers/usb/host/Makefile  |   7 +
 drivers/usb/host/ehci-brcm.c   | 304 +
 drivers/usb/host/ohci-brcm.c   | 204 ++
 drivers/usb/host/xhci-brcm.c   | 294 
 9 files changed, 912 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,ehci-brcm.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,ohci-brcm.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,xhci-brcm.txt
 create mode 100644 drivers/usb/host/ehci-brcm.c
 create mode 100644 drivers/usb/host/ohci-brcm.c
 create mode 100644 drivers/usb/host/xhci-brcm.c

-- 
1.9.0.138.g2de3478



[PATCH V2 0/6] Add XHCI, EHCI and OHCI support for Broadcom STB SoS's

2018-10-17 Thread Al Cooper
V2 - Based on feedback, the functionality for XHCI and OHCI was
 moved from Broadcom platform drivers into the standard XHCI
 and OHCI platform drivers. The EHCI functionality still uses
 a Broadcom EHCI driver because of the workarounds needed for
 bugs in the EHCI controller.

This adds support for the XHCI, EHCI and OHCI host controllers found
in Broadcom STB SoC's. These drivers depend on getting access to the
new Broadcom STB USB PHY driver through a device-tree phandle and
will fail if the driver is not available.

Al Cooper (6):
  dt-bindings: Add Broadcom STB OHCI, EHCI and XHCI binding document
  usb: core: Add ability to skip phy exit on suspend and init on resume
  usb: xhci: xhci-plat: Add support for Broadcom STB SoC's
  usb: ohci-platform: Add support for Broadcom STB SoC's
  usb: ehci: Add new EHCI driver for Broadcom STB SoC's
  usb: host: Add ability to build new Broadcom STB USB drivers

 .../devicetree/bindings/usb/brcm,bcm7445-ehci.txt  |  22 ++
 .../devicetree/bindings/usb/brcm,bcm7445-ohci.txt  |  22 ++
 .../devicetree/bindings/usb/brcm,bcm7445-xhci.txt  |  23 ++
 MAINTAINERS|   9 +
 drivers/usb/core/hcd.c |   8 +-
 drivers/usb/core/phy.c |  18 +-
 drivers/usb/core/phy.h |   9 +-
 drivers/usb/host/Kconfig   |  29 ++
 drivers/usb/host/Makefile  |  18 +-
 drivers/usb/host/ehci-brcm.c   | 291 +
 drivers/usb/host/ohci-platform.c   |  35 ++-
 drivers/usb/host/xhci-brcm.c   |  17 ++
 drivers/usb/host/xhci-brcm.h   |  16 ++
 drivers/usb/host/xhci-plat.c   |   8 +
 include/linux/usb/hcd.h|   3 +
 include/linux/usb/ohci_pdriver.h   |   1 +
 16 files changed, 504 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ohci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-xhci.txt
 create mode 100644 drivers/usb/host/ehci-brcm.c
 create mode 100644 drivers/usb/host/xhci-brcm.c
 create mode 100644 drivers/usb/host/xhci-brcm.h

-- 
1.9.0.138.g2de3478



[PATCH V2 3/6] usb: xhci: xhci-plat: Add support for Broadcom STB SoC's

2018-10-17 Thread Al Cooper
Add support for Broadcom STB SoC's to the xhci platform driver

Signed-off-by: Al Cooper 
---
 drivers/usb/host/xhci-brcm.c | 17 +
 drivers/usb/host/xhci-brcm.h | 16 
 drivers/usb/host/xhci-plat.c |  8 
 3 files changed, 41 insertions(+)
 create mode 100644 drivers/usb/host/xhci-brcm.c
 create mode 100644 drivers/usb/host/xhci-brcm.h

diff --git a/drivers/usb/host/xhci-brcm.c b/drivers/usb/host/xhci-brcm.c
new file mode 100644
index ..a7220126f6af
--- /dev/null
+++ b/drivers/usb/host/xhci-brcm.c
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, Broadcom */
+
+#include 
+#include 
+
+#include "xhci.h"
+
+int xhci_plat_brcm_init_quirk(struct usb_hcd *hcd)
+{
+   struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+   xhci->quirks |= XHCI_RESET_ON_RESUME;
+   hcd->suspend_without_phy_exit = 1;
+   return 0;
+}
+
diff --git a/drivers/usb/host/xhci-brcm.h b/drivers/usb/host/xhci-brcm.h
new file mode 100644
index ..a39d1b807a4c
--- /dev/null
+++ b/drivers/usb/host/xhci-brcm.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2018, Broadcom */
+
+#ifndef _XHCI_BRCM_H
+#define _XHCI_BRCM_H
+
+#if IS_ENABLED(CONFIG_USB_XHCI_BRCM)
+int xhci_plat_brcm_init_quirk(struct usb_hcd *hcd);
+#else
+static inline int xhci_brcm_init_quirk(struct usb_hcd *hcd)
+{
+   return 0;
+}
+#endif
+#endif /* _XHCI_BRCM_H */
+
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 94e939249b2b..1de22928e862 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -23,6 +23,7 @@
 #include "xhci-plat.h"
 #include "xhci-mvebu.h"
 #include "xhci-rcar.h"
+#include "xhci-brcm.h"
 
 static struct hc_driver __read_mostly xhci_plat_hc_driver;
 
@@ -111,6 +112,10 @@ static int xhci_plat_start(struct usb_hcd *hcd)
.resume_quirk = xhci_rcar_resume_quirk,
 };
 
+static const struct xhci_plat_priv xhci_plat_brcm = {
+   .init_quirk = xhci_plat_brcm_init_quirk
+};
+
 static const struct of_device_id usb_xhci_of_match[] = {
{
.compatible = "generic-xhci",
@@ -143,6 +148,9 @@ static int xhci_plat_start(struct usb_hcd *hcd)
}, {
.compatible = "renesas,rcar-gen3-xhci",
.data = &xhci_plat_renesas_rcar_gen3,
+   }, {
+   .compatible = "brcm,bcm7445-xhci",
+   .data = &xhci_plat_brcm,
},
{},
 };
-- 
1.9.0.138.g2de3478



[PATCH V2 4/6] usb: ohci-platform: Add support for Broadcom STB SoC's

2018-10-17 Thread Al Cooper
Add support for Broadcom STB SoC's to the ohci platform driver.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/ohci-platform.c | 35 +--
 include/linux/usb/ohci_pdriver.h |  1 +
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index 65a1c3fdc88c..363d6fa676a5 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -99,12 +100,24 @@ static int ohci_platform_probe(struct platform_device *dev)
if (usb_disabled())
return -ENODEV;
 
-   /*
-* Use reasonable defaults so platforms don't have to provide these
-* with DT probing on ARM.
-*/
-   if (!pdata)
-   pdata = &ohci_platform_defaults;
+   if (!pdata) {
+   const struct usb_ohci_pdata *match_pdata;
+
+   match_pdata = of_device_get_match_data(&dev->dev);
+   if (match_pdata) {
+   pdata = devm_kzalloc(&dev->dev, sizeof(*pdata),
+GFP_KERNEL);
+   if (!pdata)
+   return -ENOMEM;
+   *pdata = *match_pdata;
+   } else {
+   /*
+* Use reasonable defaults so platforms don't have
+* to provide these with DT probing on ARM.
+*/
+   pdata = &ohci_platform_defaults;
+   }
+   }
 
err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32));
if (err)
@@ -177,6 +190,8 @@ static int ohci_platform_probe(struct platform_device *dev)
ohci->flags |= OHCI_QUIRK_FRAME_NO;
if (pdata->num_ports)
ohci->num_ports = pdata->num_ports;
+   if (pdata->suspend_without_phy_exit)
+   hcd->suspend_without_phy_exit = 1;
 
 #ifndef CONFIG_USB_OHCI_BIG_ENDIAN_MMIO
if (ohci->flags & OHCI_QUIRK_BE_MMIO) {
@@ -305,10 +320,18 @@ static int ohci_platform_resume(struct device *dev)
 }
 #endif /* CONFIG_PM_SLEEP */
 
+static const struct usb_ohci_pdata ohci_plat_brcm_bcm7445_ohci = {
+   .power_on = ohci_platform_power_on,
+   .power_suspend =ohci_platform_power_off,
+   .power_off =ohci_platform_power_off,
+   .suspend_without_phy_exit = 1,
+};
+
 static const struct of_device_id ohci_platform_ids[] = {
{ .compatible = "generic-ohci", },
{ .compatible = "cavium,octeon-6335-ohci", },
{ .compatible = "ti,ohci-omap3", },
+   { .compatible = "brcm,bcm7445-ohci", &ohci_plat_brcm_bcm7445_ohci},
{ }
 };
 MODULE_DEVICE_TABLE(of, ohci_platform_ids);
diff --git a/include/linux/usb/ohci_pdriver.h b/include/linux/usb/ohci_pdriver.h
index 7eb16cf587ee..16b24ea1e3bb 100644
--- a/include/linux/usb/ohci_pdriver.h
+++ b/include/linux/usb/ohci_pdriver.h
@@ -35,6 +35,7 @@ struct usb_ohci_pdata {
unsignedbig_endian_desc:1;
unsignedbig_endian_mmio:1;
unsignedno_big_frame_no:1;
+   unsignedsuspend_without_phy_exit:1;
unsigned intnum_ports;
 
/* Turn on all power and clocks */
-- 
1.9.0.138.g2de3478



[PATCH V2 2/6] usb: core: Add ability to skip phy exit on suspend and init on resume

2018-10-17 Thread Al Cooper
Add the ability to skip calling the PHY's exit routine on suspend
and the PHY's init routine on resume. This is to handle a USB PHY
that should have it's power_off function called on suspend but cannot
have it's exit function called because on exit it will disable the
PHY to the point where register accesses to the Host Controllers
using the PHY will be disabled and the host drivers will crash.

This is enabled with the HCD flag "suspend_without_phy_exit" which
can be set from any HCD driver.

Signed-off-by: Al Cooper 
---
 drivers/usb/core/hcd.c  |  8 
 drivers/usb/core/phy.c  | 18 --
 drivers/usb/core/phy.h  |  9 ++---
 include/linux/usb/hcd.h |  3 +++
 4 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 1c21955fe7c0..e67e4d6b3d21 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2263,7 +2263,7 @@ int hcd_bus_suspend(struct usb_device *rhdev, 
pm_message_t msg)
hcd->state = HC_STATE_SUSPENDED;
 
if (!PMSG_IS_AUTO(msg))
-   usb_phy_roothub_suspend(hcd->self.sysdev,
+   usb_phy_roothub_suspend(hcd,
hcd->phy_roothub);
 
/* Did we race with a root-hub wakeup event? */
@@ -2304,7 +2304,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t 
msg)
}
 
if (!PMSG_IS_AUTO(msg)) {
-   status = usb_phy_roothub_resume(hcd->self.sysdev,
+   status = usb_phy_roothub_resume(hcd,
hcd->phy_roothub);
if (status)
return status;
@@ -2347,7 +2347,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t 
msg)
}
} else {
hcd->state = old_state;
-   usb_phy_roothub_suspend(hcd->self.sysdev, hcd->phy_roothub);
+   usb_phy_roothub_suspend(hcd, hcd->phy_roothub);
dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
"resume", status);
if (status != -ESHUTDOWN)
@@ -2744,7 +2744,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
struct usb_device *rhdev;
 
if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) {
-   hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev);
+   hcd->phy_roothub = usb_phy_roothub_alloc(hcd);
if (IS_ERR(hcd->phy_roothub))
return PTR_ERR(hcd->phy_roothub);
 
diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c
index 9879767452a2..b54db39eee4c 100644
--- a/drivers/usb/core/phy.c
+++ b/drivers/usb/core/phy.c
@@ -45,10 +45,11 @@ static int usb_phy_roothub_add_phy(struct device *dev, int 
index,
return 0;
 }
 
-struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev)
+struct usb_phy_roothub *usb_phy_roothub_alloc(struct usb_hcd *hcd)
 {
struct usb_phy_roothub *phy_roothub;
int i, num_phys, err;
+   struct device *dev = hcd->self.sysdev;
 
if (!IS_ENABLED(CONFIG_GENERIC_PHY))
return NULL;
@@ -161,26 +162,30 @@ void usb_phy_roothub_power_off(struct usb_phy_roothub 
*phy_roothub)
 }
 EXPORT_SYMBOL_GPL(usb_phy_roothub_power_off);
 
-int usb_phy_roothub_suspend(struct device *controller_dev,
+int usb_phy_roothub_suspend(struct usb_hcd *hcd,
struct usb_phy_roothub *phy_roothub)
 {
+   struct device *controller_dev = hcd->self.sysdev;
+
usb_phy_roothub_power_off(phy_roothub);
 
/* keep the PHYs initialized so the device can wake up the system */
-   if (device_may_wakeup(controller_dev))
+   if (device_may_wakeup(controller_dev) || hcd->suspend_without_phy_exit)
return 0;
 
return usb_phy_roothub_exit(phy_roothub);
 }
 EXPORT_SYMBOL_GPL(usb_phy_roothub_suspend);
 
-int usb_phy_roothub_resume(struct device *controller_dev,
+int usb_phy_roothub_resume(struct usb_hcd *hcd,
   struct usb_phy_roothub *phy_roothub)
 {
+   struct device *controller_dev = hcd->self.sysdev;
int err;
 
/* if the device can't wake up the system _exit was called */
-   if (!device_may_wakeup(controller_dev)) {
+   if (!device_may_wakeup(controller_dev) &&
+   !hcd->suspend_without_phy_exit) {
err = usb_phy_roothub_init(phy_roothub);
if (err)
return err;
@@ -189,7 +194,8 @@ int usb_phy_roothub_resume(struct device *controller_dev,
err = usb_phy_roothub_power_on(phy_roothub);
 
/* undo _init if _power_on failed */
-   if (err && !device_may_wakeup(controller_dev))
+   if (err && !device_may_wakeup(controller_dev)
+  

[PATCH V2 5/6] usb: ehci: Add new EHCI driver for Broadcom STB SoC's

2018-10-17 Thread Al Cooper
Add a new EHCI driver for Broadcom STB SoC's. A new EHCI driver
was created instead of adding support to the existing ehci platform
driver because of the code required to workaround bugs in the EHCI
controller.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/ehci-brcm.c | 291 +++
 1 file changed, 291 insertions(+)
 create mode 100644 drivers/usb/host/ehci-brcm.c

diff --git a/drivers/usb/host/ehci-brcm.c b/drivers/usb/host/ehci-brcm.c
new file mode 100644
index ..b2a100698bf5
--- /dev/null
+++ b/drivers/usb/host/ehci-brcm.c
@@ -0,0 +1,291 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, Broadcom */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ehci.h"
+
+#define BRCM_DRIVER_DESC "EHCI Broadcom STB driver"
+
+#define hcd_to_ehci_priv(h) ((struct brcm_priv *)hcd_to_ehci(h)->priv)
+
+struct brcm_priv {
+   struct clk *clk;
+};
+
+static const char brcm_hcd_name[] = "ehci-brcm";
+
+static int (*org_hub_control)(struct usb_hcd *hcd,
+   u16 typeReq, u16 wValue, u16 wIndex,
+   char *buf, u16 wLength);
+
+/* ehci_brcm_wait_for_sof
+ * Wait for start of next microframe, then wait extra delay microseconds
+ */
+static inline void ehci_brcm_wait_for_sof(struct ehci_hcd *ehci, u32 delay)
+{
+   int frame_idx = ehci_readl(ehci, &ehci->regs->frame_index);
+
+   while (frame_idx == ehci_readl(ehci, &ehci->regs->frame_index))
+   ;
+   udelay(delay);
+}
+
+/*
+ * ehci_brcm_hub_control
+ * Intercept echi-hcd request to complete RESUME and align it to the start
+ * of the next microframe.
+ * If RESUME is complete too late in the microframe, host controller
+ * detects babble on suspended port and resets the port afterwards.
+ * This s/w workaround allows to avoid this problem.
+ * See SWLINUX-1909 for more details
+ */
+static int ehci_brcm_hub_control(
+   struct usb_hcd  *hcd,
+   u16 typeReq,
+   u16 wValue,
+   u16 wIndex,
+   char*buf,
+   u16 wLength)
+{
+   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+   int ports = HCS_N_PORTS(ehci->hcs_params);
+   u32 __iomem *status_reg = &ehci->regs->port_status[
+   (wIndex & 0xff) - 1];
+   unsigned long flags;
+   int retval, irq_disabled = 0;
+
+   /*
+* RESUME is cleared when GetPortStatus() is called 20ms after start
+* of RESUME
+*/
+   if ((typeReq == GetPortStatus) &&
+   (wIndex && wIndex <= ports) &&
+   ehci->reset_done[wIndex-1] &&
+   time_after_eq(jiffies, ehci->reset_done[wIndex-1]) &&
+   (ehci_readl(ehci, status_reg) & PORT_RESUME)) {
+
+   /*
+* to make sure we are not interrupted until RESUME bit
+* is cleared, disable interrupts on current CPU
+*/
+   ehci_dbg(ehci, "SOF alignment workaround\n");
+   irq_disabled = 1;
+   local_irq_save(flags);
+   ehci_brcm_wait_for_sof(ehci, 5);
+   }
+   retval = (*org_hub_control)(hcd, typeReq, wValue, wIndex, buf, wLength);
+   if (irq_disabled)
+   local_irq_restore(flags);
+   return retval;
+}
+
+static int ehci_brcm_reset(struct usb_hcd *hcd)
+{
+   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+
+   ehci->big_endian_mmio = 1;
+   hcd->suspend_without_phy_exit = 1;
+
+   ehci->caps = (struct ehci_caps *) hcd->regs;
+   ehci->regs = (struct ehci_regs *) (hcd->regs +
+   HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)));
+
+   /* This fixes the lockup during reboot due to prior interrupts */
+   ehci_writel(ehci, CMD_RESET, &ehci->regs->command);
+   mdelay(10);
+
+   /*
+* SWLINUX-1705: Avoid OUT packet underflows during high memory
+*   bus usage
+* port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x90
+*/
+   ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]);
+   ehci_writel(ehci, 0x0001, &ehci->regs->port_status[0x12]);
+
+   return ehci_setup(hcd);
+}
+
+static struct hc_driver __read_mostly ehci_brcm_hc_driver;
+
+static const struct ehci_driver_overrides brcm_overrides __initconst = {
+
+   .reset =ehci_brcm_reset,
+   .extra_priv_size = sizeof(struct brcm_priv),
+};
+
+static int ehci_brcm_probe(struct platform_device *pdev)
+{
+   struct usb_hcd *hcd;
+   struct resource *res_mem;
+   struct brcm_priv *priv;
+   int irq;
+   int err;
+
+   if (usb_disabled())
+   ret

[PATCH V2 6/6] usb: host: Add ability to build new Broadcom STB USB drivers

2018-10-17 Thread Al Cooper
Add the build system changes needed to get the Broadcom STB XHCI,
EHCI and OHCI functionality working. The link order for XHCI was
changed in the Makefile because of the way STB XHCI, EHCI and OHCI
controllers share a port which requires that the XHCI driver be
initialized first. Also update MAINTAINERS.

Signed-off-by: Al Cooper 
---
 MAINTAINERS   |  9 +
 drivers/usb/host/Kconfig  | 29 +
 drivers/usb/host/Makefile | 18 --
 3 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6ac000cc006d..7e062dcbe173 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3006,6 +3006,15 @@ S:   Supported
 F: drivers/gpio/gpio-brcmstb.c
 F: Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt
 
+BROADCOM BRCMSTB USB XHCI, EHCI and OHCI DRIVERS
+M: Al Cooper 
+L: linux-usb@vger.kernel.org
+L: bcm-kernel-feedback-l...@broadcom.com
+S: Maintained
+F: drivers/usb/host/xhci-brcm.*
+F: drivers/usb/host/ohci-brcm.c
+F: Documentation/devicetree/bindings/usb/brcm,bcm7445-*.txt
+
 BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER
 M: Al Cooper 
 L: linux-ker...@vger.kernel.org
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 1a4ea98cac2a..112de3334389 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -94,6 +94,35 @@ config USB_XHCI_TEGRA
  Say 'Y' to enable the support for the xHCI host controller
  found in NVIDIA Tegra124 and later SoCs.
 
+config USB_OHCI_BRCM
+   tristate
+
+config USB_EHCI_BRCM
+   tristate
+
+config USB_XHCI_BRCM
+   tristate
+
+config BRCM_USB_PHY
+   tristate
+
+config USB_BRCM
+   tristate "Broadcom STB USB support"
+   depends on ARCH_BRCMSTB
+   select USB_OHCI_HCD_PLATFORM if USB_OHCI_HCD
+   select USB_EHCI_BRCM if USB_EHCI_HCD
+   select USB_XHCI_BRCM if USB_XHCI_HCD
+   select USB_XHCI_PLATFORM if USB_XHCI_HCD
+   select BRCM_USB_PHY if USB_OHCI_HCD || USB_EHCI_HCD || USB_XHCI_HCD
+   select GENERIC_PHY if BRCM_USB_PHY
+   default ARCH_BRCMSTB
+   help
+ Say Y to enable support for XHCI, EHCI and OHCI host controllers
+ found in Broadcom STB SoC's.
+
+ Disabling this will keep the controllers and corresponding
+ PHYs powered down.
+
 endif # USB_XHCI_HCD
 
 config USB_EHCI_HCD
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index e6235269c151..2a16226f0916 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -31,6 +31,10 @@ ifneq ($(CONFIG_USB_XHCI_RCAR), )
xhci-plat-hcd-y += xhci-rcar.o
 endif
 
+ifneq ($(CONFIG_USB_XHCI_BRCM), )
+   xhci-plat-hcd-y += xhci-brcm.o
+endif
+
 ifneq ($(CONFIG_DEBUG_FS),)
xhci-hcd-y  += xhci-debugfs.o
 endif
@@ -39,6 +43,13 @@ obj-$(CONFIG_USB_WHCI_HCD)   += whci/
 
 obj-$(CONFIG_USB_PCI)  += pci-quirks.o
 
+obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o
+obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o
+obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o
+obj-$(CONFIG_USB_XHCI_HISTB)   += xhci-histb.o
+obj-$(CONFIG_USB_XHCI_MTK) += xhci-mtk.o
+obj-$(CONFIG_USB_XHCI_TEGRA)   += xhci-tegra.o
+
 obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
 obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
 obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)+= ehci-platform.o
@@ -52,6 +63,7 @@ obj-$(CONFIG_USB_EHCI_EXYNOS) += ehci-exynos.o
 obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += ehci-tegra.o
 obj-$(CONFIG_USB_W90X900_EHCI) += ehci-w90x900.o
+obj-$(CONFIG_USB_EHCI_BRCM)+= ehci-brcm.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
@@ -72,12 +84,6 @@ obj-$(CONFIG_USB_OHCI_HCD_DAVINCI)   += ohci-da8xx.o
 
 obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
 obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
-obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o
-obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o
-obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o
-obj-$(CONFIG_USB_XHCI_HISTB)   += xhci-histb.o
-obj-$(CONFIG_USB_XHCI_MTK) += xhci-mtk.o
-obj-$(CONFIG_USB_XHCI_TEGRA)   += xhci-tegra.o
 obj-$(CONFIG_USB_SL811_HCD)+= sl811-hcd.o
 obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o
 obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o
-- 
1.9.0.138.g2de3478



[PATCH V2 1/6] dt-bindings: Add Broadcom STB OHCI, EHCI and XHCI binding document

2018-10-17 Thread Al Cooper
Add DT bindings document for Broadcom STB USB OHCI, EHCI and
XHCI drivers.

Signed-off-by: Al Cooper 
---
 .../devicetree/bindings/usb/brcm,bcm7445-ehci.txt  | 22 +
 .../devicetree/bindings/usb/brcm,bcm7445-ohci.txt  | 22 +
 .../devicetree/bindings/usb/brcm,bcm7445-xhci.txt  | 23 ++
 3 files changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ohci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-xhci.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt 
b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt
new file mode 100644
index ..824f4bf5d07c
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt
@@ -0,0 +1,22 @@
+Broadcom STB USB EHCI controller
+
+Required properties:
+- compatible: should be "brcm,bcm7445-ehci"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+- phys: phandle + phy specifier pair
+  The specifier should be 0 for the OHCI/EHCI PHY
+
+Optional properties:
+- clocks: A phandle for the EHCI clock
+
+Example:
+
+ehci@f0b00300 {
+   compatible = "brcm,bcm7445-ehci";
+   reg = <0xf0b00300 0xa8>;
+   interrupts = <0x0 0x5a 0x0>;
+   interrupt-names = "usb0_ehci_0";
+   phys = <&usbphy_0 0x0>;
+   clocks = <&usb20>
+};
diff --git a/Documentation/devicetree/bindings/usb/brcm,bcm7445-ohci.txt 
b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ohci.txt
new file mode 100644
index ..de5a22b3d138
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ohci.txt
@@ -0,0 +1,22 @@
+Broadcom STB USB OHCI controller
+
+Required properties:
+- compatible: should be "brcm,bcm7445-ohci"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+- phys: phandle + phy specifier pair
+  The specifier should be 0 for the OHCI/EHCI PHY
+
+Optional properties:
+- clocks: A phandle for the OHCI clock
+
+Example:
+
+ohci@f0b00400 {
+   compatible = "brcm,bcm7445-ohci";
+   reg = <0xf0b00400 0x58>;
+   interrupts = <0x0 0x5b 0x0>;
+   interrupt-names = "usb0_ohci_0";
+   phys = <&usbphy_0 0x0>;
+   clocks = <&usb20>;
+};
diff --git a/Documentation/devicetree/bindings/usb/brcm,bcm7445-xhci.txt 
b/Documentation/devicetree/bindings/usb/brcm,bcm7445-xhci.txt
new file mode 100644
index ..c41f3f8d836d
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,bcm7445-xhci.txt
@@ -0,0 +1,23 @@
+Broadcom STB USB XHCI controller
+
+Required properties:
+- compatible: should be "brcm,bcm7445-xhci"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+- phys: phandle + phy specifier pair
+  The specifier should be 1 for the XHCI PHY
+
+Optional properties:
+- clocks: A phandle for the XHCI clock
+- usb3-lpm-capable: determines if platform is USB3 LPM capable
+
+Example:
+
+xhci_0_0: xhci@f0b01000 {
+   compatible = "brcm,bcm7445-xhci";
+   reg = <0xf0b01000 0x1000>;
+   interrupts = <0x0 0x5c 0x0>;
+   interrupt-names = "usb0_xhci_0";
+   phys = <&usbphy_0 0x1>;
+   clocks = <&usb30>;
+};
-- 
1.9.0.138.g2de3478



[PATCH V3 6/6] usb: host: Add ability to build new Broadcom STB USB drivers

2018-11-05 Thread Al Cooper
Add the build system changes needed to get the Broadcom STB XHCI,
EHCI and OHCI functionality working. The link order for XHCI was
changed in the Makefile because of the way STB XHCI, EHCI and OHCI
controllers share a port which requires that the XHCI driver be
initialized first. Also update MAINTAINERS.

Signed-off-by: Al Cooper 
---
 MAINTAINERS   |  9 +
 drivers/usb/host/Kconfig  | 29 +
 drivers/usb/host/Makefile | 18 --
 3 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index e8e1d86bd505..c4e7bcb7f992 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2991,6 +2991,15 @@ S:   Supported
 F: drivers/i2c/busses/i2c-brcmstb.c
 F: Documentation/devicetree/bindings/i2c/i2c-brcmstb.txt
 
+BROADCOM BRCMSTB USB XHCI, EHCI and OHCI DRIVERS
+M: Al Cooper 
+L: linux-usb@vger.kernel.org
+L: bcm-kernel-feedback-l...@broadcom.com
+S: Maintained
+F: drivers/usb/host/xhci-brcm.*
+F: drivers/usb/host/ohci-brcm.c
+F: Documentation/devicetree/bindings/usb/brcm,bcm7445-*.txt
+
 BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER
 M: Al Cooper 
 L: linux-ker...@vger.kernel.org
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 16758b12a5e9..ec6b4582ab12 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -94,6 +94,35 @@ config USB_XHCI_TEGRA
  Say 'Y' to enable the support for the xHCI host controller
  found in NVIDIA Tegra124 and later SoCs.
 
+config USB_OHCI_BRCM
+   tristate
+
+config USB_EHCI_BRCM
+   tristate
+
+config USB_XHCI_BRCM
+   tristate
+
+config BRCM_USB_PHY
+   tristate
+
+config USB_BRCM
+   tristate "Broadcom STB USB support"
+   depends on ARCH_BRCMSTB
+   select USB_OHCI_HCD_PLATFORM if USB_OHCI_HCD
+   select USB_EHCI_BRCM if USB_EHCI_HCD
+   select USB_XHCI_BRCM if USB_XHCI_HCD
+   select USB_XHCI_PLATFORM if USB_XHCI_HCD
+   select BRCM_USB_PHY if USB_OHCI_HCD || USB_EHCI_HCD || USB_XHCI_HCD
+   select GENERIC_PHY if BRCM_USB_PHY
+   default ARCH_BRCMSTB
+   help
+ Say Y to enable support for XHCI, EHCI and OHCI host controllers
+ found in Broadcom STB SoC's.
+
+ Disabling this will keep the controllers and corresponding
+ PHYs powered down.
+
 endif # USB_XHCI_HCD
 
 config USB_EHCI_HCD
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 84514f71ae44..9bdd64b710ee 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -31,6 +31,10 @@ ifneq ($(CONFIG_USB_XHCI_RCAR), )
xhci-plat-hcd-y += xhci-rcar.o
 endif
 
+ifneq ($(CONFIG_USB_XHCI_BRCM), )
+   xhci-plat-hcd-y += xhci-brcm.o
+endif
+
 ifneq ($(CONFIG_DEBUG_FS),)
xhci-hcd-y  += xhci-debugfs.o
 endif
@@ -39,6 +43,13 @@ obj-$(CONFIG_USB_WHCI_HCD)   += whci/
 
 obj-$(CONFIG_USB_PCI)  += pci-quirks.o
 
+obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o
+obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o
+obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o
+obj-$(CONFIG_USB_XHCI_HISTB)   += xhci-histb.o
+obj-$(CONFIG_USB_XHCI_MTK) += xhci-mtk.o
+obj-$(CONFIG_USB_XHCI_TEGRA)   += xhci-tegra.o
+
 obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
 obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
 obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)+= ehci-platform.o
@@ -52,6 +63,7 @@ obj-$(CONFIG_USB_EHCI_EXYNOS) += ehci-exynos.o
 obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += ehci-tegra.o
 obj-$(CONFIG_USB_W90X900_EHCI) += ehci-w90x900.o
+obj-$(CONFIG_USB_EHCI_BRCM)+= ehci-brcm.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
@@ -72,12 +84,6 @@ obj-$(CONFIG_USB_OHCI_HCD_DAVINCI)   += ohci-da8xx.o
 
 obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
 obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
-obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o
-obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o
-obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o
-obj-$(CONFIG_USB_XHCI_HISTB)   += xhci-histb.o
-obj-$(CONFIG_USB_XHCI_MTK) += xhci-mtk.o
-obj-$(CONFIG_USB_XHCI_TEGRA)   += xhci-tegra.o
 obj-$(CONFIG_USB_SL811_HCD)+= sl811-hcd.o
 obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o
 obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o
-- 
1.9.0.138.g2de3478



[PATCH V3 4/6] usb: ohci-platform: Add support for Broadcom STB SoC's

2018-11-05 Thread Al Cooper
Add support for Broadcom STB SoC's to the ohci platform driver.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/ohci-platform.c | 34 --
 include/linux/usb/ohci_pdriver.h |  1 +
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index 65a1c3fdc88c..f425168238e6 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -99,12 +100,23 @@ static int ohci_platform_probe(struct platform_device *dev)
if (usb_disabled())
return -ENODEV;
 
-   /*
-* Use reasonable defaults so platforms don't have to provide these
-* with DT probing on ARM.
-*/
-   if (!pdata)
-   pdata = &ohci_platform_defaults;
+   if (!pdata) {
+   const struct usb_ohci_pdata *match_pdata;
+
+   match_pdata = of_device_get_match_data(&dev->dev);
+   if (match_pdata) {
+   pdata = devm_kmemdup(&dev->dev, match_pdata,
+sizeof(*pdata), GFP_KERNEL);
+   if (!pdata)
+   return -ENOMEM;
+   } else {
+   /*
+* Use reasonable defaults so platforms don't have
+* to provide these with DT probing on ARM.
+*/
+   pdata = &ohci_platform_defaults;
+   }
+   }
 
err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32));
if (err)
@@ -177,6 +189,8 @@ static int ohci_platform_probe(struct platform_device *dev)
ohci->flags |= OHCI_QUIRK_FRAME_NO;
if (pdata->num_ports)
ohci->num_ports = pdata->num_ports;
+   if (pdata->suspend_without_phy_exit)
+   hcd->suspend_without_phy_exit = 1;
 
 #ifndef CONFIG_USB_OHCI_BIG_ENDIAN_MMIO
if (ohci->flags & OHCI_QUIRK_BE_MMIO) {
@@ -305,10 +319,18 @@ static int ohci_platform_resume(struct device *dev)
 }
 #endif /* CONFIG_PM_SLEEP */
 
+static const struct usb_ohci_pdata ohci_plat_brcm_bcm7445_ohci = {
+   .power_on = ohci_platform_power_on,
+   .power_suspend =ohci_platform_power_off,
+   .power_off =ohci_platform_power_off,
+   .suspend_without_phy_exit = 1,
+};
+
 static const struct of_device_id ohci_platform_ids[] = {
{ .compatible = "generic-ohci", },
{ .compatible = "cavium,octeon-6335-ohci", },
{ .compatible = "ti,ohci-omap3", },
+   { .compatible = "brcm,bcm7445-ohci", &ohci_plat_brcm_bcm7445_ohci},
{ }
 };
 MODULE_DEVICE_TABLE(of, ohci_platform_ids);
diff --git a/include/linux/usb/ohci_pdriver.h b/include/linux/usb/ohci_pdriver.h
index 7eb16cf587ee..16b24ea1e3bb 100644
--- a/include/linux/usb/ohci_pdriver.h
+++ b/include/linux/usb/ohci_pdriver.h
@@ -35,6 +35,7 @@ struct usb_ohci_pdata {
unsignedbig_endian_desc:1;
unsignedbig_endian_mmio:1;
unsignedno_big_frame_no:1;
+   unsignedsuspend_without_phy_exit:1;
unsigned intnum_ports;
 
/* Turn on all power and clocks */
-- 
1.9.0.138.g2de3478



[PATCH V3 5/6] usb: ehci: Add new EHCI driver for Broadcom STB SoC's

2018-11-05 Thread Al Cooper
Add a new EHCI driver for Broadcom STB SoC's. A new EHCI driver
was created instead of adding support to the existing ehci platform
driver because of the code required to workaround bugs in the EHCI
controller.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/ehci-brcm.c | 287 +++
 1 file changed, 287 insertions(+)
 create mode 100644 drivers/usb/host/ehci-brcm.c

diff --git a/drivers/usb/host/ehci-brcm.c b/drivers/usb/host/ehci-brcm.c
new file mode 100644
index ..f36ce240538b
--- /dev/null
+++ b/drivers/usb/host/ehci-brcm.c
@@ -0,0 +1,287 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, Broadcom */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ehci.h"
+
+#define BRCM_DRIVER_DESC "EHCI Broadcom STB driver"
+
+#define hcd_to_ehci_priv(h) ((struct brcm_priv *)hcd_to_ehci(h)->priv)
+
+struct brcm_priv {
+   struct clk *clk;
+};
+
+static const char brcm_hcd_name[] = "ehci-brcm";
+
+static int (*org_hub_control)(struct usb_hcd *hcd,
+   u16 typeReq, u16 wValue, u16 wIndex,
+   char *buf, u16 wLength);
+
+/* ehci_brcm_wait_for_sof
+ * Wait for start of next microframe, then wait extra delay microseconds
+ */
+static inline void ehci_brcm_wait_for_sof(struct ehci_hcd *ehci, u32 delay)
+{
+   int frame_idx = ehci_readl(ehci, &ehci->regs->frame_index);
+
+   while (frame_idx == ehci_readl(ehci, &ehci->regs->frame_index))
+   ;
+   udelay(delay);
+}
+
+/*
+ * ehci_brcm_hub_control
+ * Intercept echi-hcd request to complete RESUME and align it to the start
+ * of the next microframe.
+ * If RESUME is complete too late in the microframe, host controller
+ * detects babble on suspended port and resets the port afterwards.
+ * This s/w workaround allows to avoid this problem.
+ * See SWLINUX-1909 for more details
+ */
+static int ehci_brcm_hub_control(
+   struct usb_hcd  *hcd,
+   u16 typeReq,
+   u16 wValue,
+   u16 wIndex,
+   char*buf,
+   u16 wLength)
+{
+   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+   int ports = HCS_N_PORTS(ehci->hcs_params);
+   u32 __iomem *status_reg = &ehci->regs->port_status[
+   (wIndex & 0xff) - 1];
+   unsigned long flags;
+   int retval, irq_disabled = 0;
+
+   /*
+* RESUME is cleared when GetPortStatus() is called 20ms after start
+* of RESUME
+*/
+   if ((typeReq == GetPortStatus) &&
+   (wIndex && wIndex <= ports) &&
+   ehci->reset_done[wIndex-1] &&
+   time_after_eq(jiffies, ehci->reset_done[wIndex-1]) &&
+   (ehci_readl(ehci, status_reg) & PORT_RESUME)) {
+
+   /*
+* to make sure we are not interrupted until RESUME bit
+* is cleared, disable interrupts on current CPU
+*/
+   ehci_dbg(ehci, "SOF alignment workaround\n");
+   irq_disabled = 1;
+   local_irq_save(flags);
+   ehci_brcm_wait_for_sof(ehci, 5);
+   }
+   retval = (*org_hub_control)(hcd, typeReq, wValue, wIndex, buf, wLength);
+   if (irq_disabled)
+   local_irq_restore(flags);
+   return retval;
+}
+
+static int ehci_brcm_reset(struct usb_hcd *hcd)
+{
+   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+
+   ehci->big_endian_mmio = 1;
+   hcd->suspend_without_phy_exit = 1;
+
+   ehci->caps = (struct ehci_caps *) hcd->regs;
+   ehci->regs = (struct ehci_regs *) (hcd->regs +
+   HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)));
+
+   /* This fixes the lockup during reboot due to prior interrupts */
+   ehci_writel(ehci, CMD_RESET, &ehci->regs->command);
+   mdelay(10);
+
+   /*
+* SWLINUX-1705: Avoid OUT packet underflows during high memory
+*   bus usage
+* port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x90
+*/
+   ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]);
+   ehci_writel(ehci, 0x0001, &ehci->regs->port_status[0x12]);
+
+   return ehci_setup(hcd);
+}
+
+static struct hc_driver __read_mostly ehci_brcm_hc_driver;
+
+static const struct ehci_driver_overrides brcm_overrides __initconst = {
+
+   .reset =ehci_brcm_reset,
+   .extra_priv_size = sizeof(struct brcm_priv),
+};
+
+static int ehci_brcm_probe(struct platform_device *pdev)
+{
+   struct usb_hcd *hcd;
+   struct resource *res_mem;
+   struct brcm_priv *priv;
+   int irq;
+   int err;
+
+   if (usb_disabled())
+   

[PATCH V3 0/6] Add XHCI, EHCI and OHCI support for Broadcom STB SoS's

2018-11-05 Thread Al Cooper
V3 - Based on feedback
   - Patch 3/6
 In xhci-brcm.h, fixed incorrect function name when
 CONFIG_USB_XHCI_BRCM is not defined. Found by kbuild test robot.
   - Patch 4/6
 In ohci-platform.c, use devm_kmemdup() instead of demv_kzalloc().
   - Patch 5/6
 In ehci-platform.c, use dma_coerce_mask_and_coherent()
 instead of dma_coerce_mask_and_coherent(). Remove unneeded
 #ifdef CONFIG_OF.

V2 - Based on feedback, the functionality for XHCI and OHCI was
 moved from Broadcom platform drivers into the standard XHCI
 and OHCI platform drivers. The EHCI functionality still uses
 a Broadcom EHCI driver because of the workarounds needed for
 bugs in the EHCI controller.

This adds support for the XHCI, EHCI and OHCI host controllers found
in Broadcom STB SoC's. These drivers depend on getting access to the
new Broadcom STB USB PHY driver through a device-tree phandle and
will fail if the driver is not available.

Al Cooper (6):
  dt-bindings: Add Broadcom STB OHCI, EHCI and XHCI binding document
  usb: core: Add ability to skip phy exit on suspend and init on resume
  usb: xhci: xhci-plat: Add support for Broadcom STB SoC's
  usb: ohci-platform: Add support for Broadcom STB SoC's
  usb: ehci: Add new EHCI driver for Broadcom STB SoC's
  usb: host: Add ability to build new Broadcom STB USB drivers

 .../devicetree/bindings/usb/brcm,bcm7445-ehci.txt  |  22 ++
 .../devicetree/bindings/usb/brcm,bcm7445-ohci.txt  |  22 ++
 .../devicetree/bindings/usb/brcm,bcm7445-xhci.txt  |  23 ++
 MAINTAINERS|   9 +
 drivers/usb/core/hcd.c |   8 +-
 drivers/usb/core/phy.c |  18 +-
 drivers/usb/core/phy.h |   9 +-
 drivers/usb/host/Kconfig   |  29 +++
 drivers/usb/host/Makefile  |  18 +-
 drivers/usb/host/ehci-brcm.c   | 287 +
 drivers/usb/host/ohci-platform.c   |  34 ++-
 drivers/usb/host/xhci-brcm.c   |  17 ++
 drivers/usb/host/xhci-brcm.h   |  16 ++
 drivers/usb/host/xhci-plat.c   |   8 +
 include/linux/usb/hcd.h|   3 +
 include/linux/usb/ohci_pdriver.h   |   1 +
 16 files changed, 499 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ohci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-xhci.txt
 create mode 100644 drivers/usb/host/ehci-brcm.c
 create mode 100644 drivers/usb/host/xhci-brcm.c
 create mode 100644 drivers/usb/host/xhci-brcm.h

-- 
1.9.0.138.g2de3478



[PATCH V3 3/6] usb: xhci: xhci-plat: Add support for Broadcom STB SoC's

2018-11-05 Thread Al Cooper
Add support for Broadcom STB SoC's to the xhci platform driver

Signed-off-by: Al Cooper 
---
 drivers/usb/host/xhci-brcm.c | 17 +
 drivers/usb/host/xhci-brcm.h | 16 
 drivers/usb/host/xhci-plat.c |  8 
 3 files changed, 41 insertions(+)
 create mode 100644 drivers/usb/host/xhci-brcm.c
 create mode 100644 drivers/usb/host/xhci-brcm.h

diff --git a/drivers/usb/host/xhci-brcm.c b/drivers/usb/host/xhci-brcm.c
new file mode 100644
index ..a7220126f6af
--- /dev/null
+++ b/drivers/usb/host/xhci-brcm.c
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, Broadcom */
+
+#include 
+#include 
+
+#include "xhci.h"
+
+int xhci_plat_brcm_init_quirk(struct usb_hcd *hcd)
+{
+   struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+   xhci->quirks |= XHCI_RESET_ON_RESUME;
+   hcd->suspend_without_phy_exit = 1;
+   return 0;
+}
+
diff --git a/drivers/usb/host/xhci-brcm.h b/drivers/usb/host/xhci-brcm.h
new file mode 100644
index ..e64800fae4d5
--- /dev/null
+++ b/drivers/usb/host/xhci-brcm.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2018, Broadcom */
+
+#ifndef _XHCI_BRCM_H
+#define _XHCI_BRCM_H
+
+#if IS_ENABLED(CONFIG_USB_XHCI_BRCM)
+int xhci_plat_brcm_init_quirk(struct usb_hcd *hcd);
+#else
+static inline int xhci_plat_brcm_init_quirk(struct usb_hcd *hcd)
+{
+   return 0;
+}
+#endif
+#endif /* _XHCI_BRCM_H */
+
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 32b5574ad5c5..5372d4040be6 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -24,6 +24,7 @@
 #include "xhci-plat.h"
 #include "xhci-mvebu.h"
 #include "xhci-rcar.h"
+#include "xhci-brcm.h"
 
 static struct hc_driver __read_mostly xhci_plat_hc_driver;
 
@@ -112,6 +113,10 @@ static int xhci_plat_start(struct usb_hcd *hcd)
.resume_quirk = xhci_rcar_resume_quirk,
 };
 
+static const struct xhci_plat_priv xhci_plat_brcm = {
+   .init_quirk = xhci_plat_brcm_init_quirk
+};
+
 static const struct of_device_id usb_xhci_of_match[] = {
{
.compatible = "generic-xhci",
@@ -144,6 +149,9 @@ static int xhci_plat_start(struct usb_hcd *hcd)
}, {
.compatible = "renesas,rcar-gen3-xhci",
.data = &xhci_plat_renesas_rcar_gen3,
+   }, {
+   .compatible = "brcm,bcm7445-xhci",
+   .data = &xhci_plat_brcm,
},
{},
 };
-- 
1.9.0.138.g2de3478



[PATCH V3 2/6] usb: core: Add ability to skip phy exit on suspend and init on resume

2018-11-05 Thread Al Cooper
Add the ability to skip calling the PHY's exit routine on suspend
and the PHY's init routine on resume. This is to handle a USB PHY
that should have it's power_off function called on suspend but cannot
have it's exit function called because on exit it will disable the
PHY to the point where register accesses to the Host Controllers
using the PHY will be disabled and the host drivers will crash.

This is enabled with the HCD flag "suspend_without_phy_exit" which
can be set from any HCD driver.

Signed-off-by: Al Cooper 
---
 drivers/usb/core/hcd.c  |  8 
 drivers/usb/core/phy.c  | 18 --
 drivers/usb/core/phy.h  |  9 ++---
 include/linux/usb/hcd.h |  3 +++
 4 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 487025d31d44..5ebc82a69403 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2249,7 +2249,7 @@ int hcd_bus_suspend(struct usb_device *rhdev, 
pm_message_t msg)
hcd->state = HC_STATE_SUSPENDED;
 
if (!PMSG_IS_AUTO(msg))
-   usb_phy_roothub_suspend(hcd->self.sysdev,
+   usb_phy_roothub_suspend(hcd,
hcd->phy_roothub);
 
/* Did we race with a root-hub wakeup event? */
@@ -2290,7 +2290,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t 
msg)
}
 
if (!PMSG_IS_AUTO(msg)) {
-   status = usb_phy_roothub_resume(hcd->self.sysdev,
+   status = usb_phy_roothub_resume(hcd,
hcd->phy_roothub);
if (status)
return status;
@@ -2333,7 +2333,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t 
msg)
}
} else {
hcd->state = old_state;
-   usb_phy_roothub_suspend(hcd->self.sysdev, hcd->phy_roothub);
+   usb_phy_roothub_suspend(hcd, hcd->phy_roothub);
dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
"resume", status);
if (status != -ESHUTDOWN)
@@ -2730,7 +2730,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
struct usb_device *rhdev;
 
if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) {
-   hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev);
+   hcd->phy_roothub = usb_phy_roothub_alloc(hcd);
if (IS_ERR(hcd->phy_roothub))
return PTR_ERR(hcd->phy_roothub);
 
diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c
index 38b2c776c4b4..308d716304da 100644
--- a/drivers/usb/core/phy.c
+++ b/drivers/usb/core/phy.c
@@ -46,10 +46,11 @@ static int usb_phy_roothub_add_phy(struct device *dev, int 
index,
return 0;
 }
 
-struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev)
+struct usb_phy_roothub *usb_phy_roothub_alloc(struct usb_hcd *hcd)
 {
struct usb_phy_roothub *phy_roothub;
int i, num_phys, err;
+   struct device *dev = hcd->self.sysdev;
 
if (!IS_ENABLED(CONFIG_GENERIC_PHY))
return NULL;
@@ -162,26 +163,30 @@ void usb_phy_roothub_power_off(struct usb_phy_roothub 
*phy_roothub)
 }
 EXPORT_SYMBOL_GPL(usb_phy_roothub_power_off);
 
-int usb_phy_roothub_suspend(struct device *controller_dev,
+int usb_phy_roothub_suspend(struct usb_hcd *hcd,
struct usb_phy_roothub *phy_roothub)
 {
+   struct device *controller_dev = hcd->self.sysdev;
+
usb_phy_roothub_power_off(phy_roothub);
 
/* keep the PHYs initialized so the device can wake up the system */
-   if (device_may_wakeup(controller_dev))
+   if (device_may_wakeup(controller_dev) || hcd->suspend_without_phy_exit)
return 0;
 
return usb_phy_roothub_exit(phy_roothub);
 }
 EXPORT_SYMBOL_GPL(usb_phy_roothub_suspend);
 
-int usb_phy_roothub_resume(struct device *controller_dev,
+int usb_phy_roothub_resume(struct usb_hcd *hcd,
   struct usb_phy_roothub *phy_roothub)
 {
+   struct device *controller_dev = hcd->self.sysdev;
int err;
 
/* if the device can't wake up the system _exit was called */
-   if (!device_may_wakeup(controller_dev)) {
+   if (!device_may_wakeup(controller_dev) &&
+   !hcd->suspend_without_phy_exit) {
err = usb_phy_roothub_init(phy_roothub);
if (err)
return err;
@@ -190,7 +195,8 @@ int usb_phy_roothub_resume(struct device *controller_dev,
err = usb_phy_roothub_power_on(phy_roothub);
 
/* undo _init if _power_on failed */
-   if (err && !device_may_wakeup(controller_dev))
+   if (err && !device_may_wakeup(controller_dev)
+  

[PATCH V3 1/6] dt-bindings: Add Broadcom STB OHCI, EHCI and XHCI binding document

2018-11-05 Thread Al Cooper
Add DT bindings document for Broadcom STB USB OHCI, EHCI and
XHCI drivers.

Signed-off-by: Al Cooper 
---
 .../devicetree/bindings/usb/brcm,bcm7445-ehci.txt  | 22 +
 .../devicetree/bindings/usb/brcm,bcm7445-ohci.txt  | 22 +
 .../devicetree/bindings/usb/brcm,bcm7445-xhci.txt  | 23 ++
 3 files changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ohci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-xhci.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt 
b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt
new file mode 100644
index ..824f4bf5d07c
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt
@@ -0,0 +1,22 @@
+Broadcom STB USB EHCI controller
+
+Required properties:
+- compatible: should be "brcm,bcm7445-ehci"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+- phys: phandle + phy specifier pair
+  The specifier should be 0 for the OHCI/EHCI PHY
+
+Optional properties:
+- clocks: A phandle for the EHCI clock
+
+Example:
+
+ehci@f0b00300 {
+   compatible = "brcm,bcm7445-ehci";
+   reg = <0xf0b00300 0xa8>;
+   interrupts = <0x0 0x5a 0x0>;
+   interrupt-names = "usb0_ehci_0";
+   phys = <&usbphy_0 0x0>;
+   clocks = <&usb20>
+};
diff --git a/Documentation/devicetree/bindings/usb/brcm,bcm7445-ohci.txt 
b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ohci.txt
new file mode 100644
index ..de5a22b3d138
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ohci.txt
@@ -0,0 +1,22 @@
+Broadcom STB USB OHCI controller
+
+Required properties:
+- compatible: should be "brcm,bcm7445-ohci"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+- phys: phandle + phy specifier pair
+  The specifier should be 0 for the OHCI/EHCI PHY
+
+Optional properties:
+- clocks: A phandle for the OHCI clock
+
+Example:
+
+ohci@f0b00400 {
+   compatible = "brcm,bcm7445-ohci";
+   reg = <0xf0b00400 0x58>;
+   interrupts = <0x0 0x5b 0x0>;
+   interrupt-names = "usb0_ohci_0";
+   phys = <&usbphy_0 0x0>;
+   clocks = <&usb20>;
+};
diff --git a/Documentation/devicetree/bindings/usb/brcm,bcm7445-xhci.txt 
b/Documentation/devicetree/bindings/usb/brcm,bcm7445-xhci.txt
new file mode 100644
index ..c41f3f8d836d
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,bcm7445-xhci.txt
@@ -0,0 +1,23 @@
+Broadcom STB USB XHCI controller
+
+Required properties:
+- compatible: should be "brcm,bcm7445-xhci"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+- phys: phandle + phy specifier pair
+  The specifier should be 1 for the XHCI PHY
+
+Optional properties:
+- clocks: A phandle for the XHCI clock
+- usb3-lpm-capable: determines if platform is USB3 LPM capable
+
+Example:
+
+xhci_0_0: xhci@f0b01000 {
+   compatible = "brcm,bcm7445-xhci";
+   reg = <0xf0b01000 0x1000>;
+   interrupts = <0x0 0x5c 0x0>;
+   interrupt-names = "usb0_xhci_0";
+   phys = <&usbphy_0 0x1>;
+   clocks = <&usb30>;
+};
-- 
1.9.0.138.g2de3478



Re: [PATCH V3 4/6] usb: ohci-platform: Add support for Broadcom STB SoC's

2018-11-06 Thread Al Cooper

On 11/6/18 11:08 AM, Alan Stern wrote:

On Mon, 5 Nov 2018, Al Cooper wrote:


Add support for Broadcom STB SoC's to the ohci platform driver.

Signed-off-by: Al Cooper 
---



@@ -177,6 +189,8 @@ static int ohci_platform_probe(struct platform_device *dev)
ohci->flags |= OHCI_QUIRK_FRAME_NO;
if (pdata->num_ports)
ohci->num_ports = pdata->num_ports;
+   if (pdata->suspend_without_phy_exit)
+   hcd->suspend_without_phy_exit = 1;


Sorry if I missed this in the earlier discussions...  Is there any
possibility of adding a DT binding that could express this requirement,
instead of putting it in the platform data?

Alan Stern



Alan,

That was my original approach but internal review suggested that I use 
pdata instead. Below is my original patch for:
[PATCH V3 2/6] usb: core: Add ability to skip phy exit on suspend and 
init on resume
With this patch I can then use ohci_platform.c without any 
modifications. Could you let me know what you think?


Thanks
Al

Add the ability to skip calling the PHY's exit routine on suspend
and the PHY's init routine on resume. This is to handle a USB PHY
that should have it's power_off function called on suspend but cannot
have it's exit function called because on exit it will disable the
PHY to the point where register accesses to the Host Controllers
using the PHY will be disabled and the host drivers will crash.

This is enabled with the HCD flag "suspend_without_phy_exit" which
can be set from any HCD driver or from the device-tree property
"suspend-without-phy-exit".

Signed-off-by: Al Cooper 
---
 drivers/usb/core/hcd.c  |  8 
 drivers/usb/core/phy.c  | 21 +++--
 drivers/usb/core/phy.h  |  9 ++---
 include/linux/usb/hcd.h |  3 +++
 4 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 1c21955fe7c0..e67e4d6b3d21 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2263,7 +2263,7 @@ int hcd_bus_suspend(struct usb_device *rhdev, 
pm_message_t msg)

hcd->state = HC_STATE_SUSPENDED;

if (!PMSG_IS_AUTO(msg))
-   usb_phy_roothub_suspend(hcd->self.sysdev,
+   usb_phy_roothub_suspend(hcd,
hcd->phy_roothub);

/* Did we race with a root-hub wakeup event? */
@@ -2304,7 +2304,7 @@ int hcd_bus_resume(struct usb_device *rhdev, 
pm_message_t msg)

}

if (!PMSG_IS_AUTO(msg)) {
-   status = usb_phy_roothub_resume(hcd->self.sysdev,
+   status = usb_phy_roothub_resume(hcd,
hcd->phy_roothub);
if (status)
return status;
@@ -2347,7 +2347,7 @@ int hcd_bus_resume(struct usb_device *rhdev, 
pm_message_t msg)

}
} else {
hcd->state = old_state;
-   usb_phy_roothub_suspend(hcd->self.sysdev, hcd->phy_roothub);
+   usb_phy_roothub_suspend(hcd, hcd->phy_roothub);
dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
"resume", status);
if (status != -ESHUTDOWN)
@@ -2744,7 +2744,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
struct usb_device *rhdev;

if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) {
-   hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev);
+   hcd->phy_roothub = usb_phy_roothub_alloc(hcd);
if (IS_ERR(hcd->phy_roothub))
return PTR_ERR(hcd->phy_roothub);

diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c
index 9879767452a2..0eb12566f1c3 100644
--- a/drivers/usb/core/phy.c
+++ b/drivers/usb/core/phy.c
@@ -45,10 +45,11 @@ static int usb_phy_roothub_add_phy(struct device 
*dev, int index,

return 0;
 }

-struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev)
+struct usb_phy_roothub *usb_phy_roothub_alloc(struct usb_hcd *hcd)
 {
struct usb_phy_roothub *phy_roothub;
int i, num_phys, err;
+   struct device *dev = hcd->self.sysdev;

if (!IS_ENABLED(CONFIG_GENERIC_PHY))
return NULL;
@@ -58,6 +59,9 @@ struct usb_phy_roothub *usb_phy_roothub_alloc(struct 
device *dev)

if (num_phys <= 0)
return NULL;

+   if (device_property_read_bool(dev, "suspend-without-phy-exit"))
+   hcd->suspend_without_phy_exit = 1;
+
phy_roothub = devm_kzalloc(dev, sizeof(*phy_roothub), GFP_KERNEL);
if (!phy_roothub)
return ERR_PTR(-ENOMEM);
@@ -161,26 +165,30 @@ void usb_phy_roothub_power_off(struct 
usb_phy_roothub *phy_roothub)

 }
 EXPORT_SYMBOL_GPL(usb_phy_roothub_power_off);

Re: [PATCH V3 4/6] usb: ohci-platform: Add support for Broadcom STB SoC's

2018-11-07 Thread Al Cooper

On 11/7/18 10:23 AM, Alan Stern wrote:

On Tue, 6 Nov 2018, Florian Fainelli wrote:


On 11/6/18 1:40 PM, Al Cooper wrote:

On 11/6/18 11:08 AM, Alan Stern wrote:

On Mon, 5 Nov 2018, Al Cooper wrote:


Add support for Broadcom STB SoC's to the ohci platform driver.

Signed-off-by: Al Cooper 
---



@@ -177,6 +189,8 @@ static int ohci_platform_probe(struct
platform_device *dev)
   ohci->flags |= OHCI_QUIRK_FRAME_NO;
   if (pdata->num_ports)
   ohci->num_ports = pdata->num_ports;
+    if (pdata->suspend_without_phy_exit)
+    hcd->suspend_without_phy_exit = 1;


Sorry if I missed this in the earlier discussions...  Is there any
possibility of adding a DT binding that could express this requirement,
instead of putting it in the platform data?

Alan Stern



Alan,

That was my original approach but internal review suggested that I use
pdata instead. Below is my original patch for:


And the reason for that suggestion was really because it was percevied
as encoding a driver behavior as a Device Tree property as opposed to
describing something that was inherently and strictly a hardware
behavior (therefore suitable for Device Tree).


Right.  The best way to approach this problem is to identify and
characterize the hardware behavior which makes this override necessary.
Then _that_ can be added to DT, since it will be a property of the
hardware rather than of the driver.


Add the ability to skip calling the PHY's exit routine on suspend
and the PHY's init routine on resume. This is to handle a USB PHY
that should have it's power_off function called on suspend but cannot
have it's exit function called because on exit it will disable the
PHY to the point where register accesses to the Host Controllers
using the PHY will be disabled and the host drivers will crash.


What's special about this PHY?  Why does the exit function mess the PHY
up?  Or to put it another way, why doesn't the exit function mess up
other PHYs in the same way?

For that matter, can we change the code so that suspend doesn't call
the exit function for _any_ PHY?  Will just calling the power_off
function be good enough?  If not, then why not?

Alan Stern



In our USB hardware the USB PHY supplies a clock for the EHCI/OHCI and 
XHCI host controllers and if the PHY is totally shut down the EHCI, OHCI 
and XHCI registers will cause an exception if accessed and cause the 
EHCI, OHCI and XHCI drivers to crash. There is always talk of fixing 
this in the hardware by adding an aux clock that will takeover when the 
PHY clock is shut down, but this hasn't happened yet. It seems like 
"exit on suspend" still makes sense on systems that don't have this 
problem (additional power savings?) so removing the exit on suspend for 
all systems is not a good idea.


Al


Re: [PATCH V3 4/6] usb: ohci-platform: Add support for Broadcom STB SoC's

2018-11-07 Thread Al Cooper

On 11/7/18 12:29 PM, Florian Fainelli wrote:

On 11/7/18 8:27 AM, Alan Stern wrote:

On Wed, 7 Nov 2018, Al Cooper wrote:


On 11/7/18 10:23 AM, Alan Stern wrote:

On Tue, 6 Nov 2018, Florian Fainelli wrote:


On 11/6/18 1:40 PM, Al Cooper wrote:

On 11/6/18 11:08 AM, Alan Stern wrote:

On Mon, 5 Nov 2018, Al Cooper wrote:


Add support for Broadcom STB SoC's to the ohci platform driver.

Signed-off-by: Al Cooper 
---



@@ -177,6 +189,8 @@ static int ohci_platform_probe(struct
platform_device *dev)
    ohci->flags |= OHCI_QUIRK_FRAME_NO;
    if (pdata->num_ports)
    ohci->num_ports = pdata->num_ports;
+    if (pdata->suspend_without_phy_exit)
+    hcd->suspend_without_phy_exit = 1;


Sorry if I missed this in the earlier discussions...  Is there any
possibility of adding a DT binding that could express this requirement,
instead of putting it in the platform data?

Alan Stern



Alan,

That was my original approach but internal review suggested that I use
pdata instead. Below is my original patch for:


And the reason for that suggestion was really because it was percevied
as encoding a driver behavior as a Device Tree property as opposed to
describing something that was inherently and strictly a hardware
behavior (therefore suitable for Device Tree).


Right.  The best way to approach this problem is to identify and
characterize the hardware behavior which makes this override necessary.
Then _that_ can be added to DT, since it will be a property of the
hardware rather than of the driver.


Add the ability to skip calling the PHY's exit routine on suspend
and the PHY's init routine on resume. This is to handle a USB PHY
that should have it's power_off function called on suspend but cannot
have it's exit function called because on exit it will disable the
PHY to the point where register accesses to the Host Controllers
using the PHY will be disabled and the host drivers will crash.


What's special about this PHY?  Why does the exit function mess the PHY
up?  Or to put it another way, why doesn't the exit function mess up
other PHYs in the same way?

For that matter, can we change the code so that suspend doesn't call
the exit function for _any_ PHY?  Will just calling the power_off
function be good enough?  If not, then why not?

Alan Stern



In our USB hardware the USB PHY supplies a clock for the EHCI/OHCI and
XHCI host controllers and if the PHY is totally shut down the EHCI, OHCI
and XHCI registers will cause an exception if accessed and cause the
EHCI, OHCI and XHCI drivers to crash. There is always talk of fixing
this in the hardware by adding an aux clock that will takeover when the
PHY clock is shut down, but this hasn't happened yet. It seems like
"exit on suspend" still makes sense on systems that don't have this
problem (additional power savings?) so removing the exit on suspend for
all systems is not a good idea.


Then in theory you should be able to add a Device Tree property which
says that the PHY provides a clock for the USB host controller.  That
is strictly a property of the hardware; it has nothing to do with the
driver.  Therefore it is appropriate for DT.


The very compatible string that is being allocated/defined for this
controller carries that information already, that is, if you probe a
"brcm,bcm7445-ohci" compatible then that means the controller has a
dependency on the PHY to supply its clock.

Adding a property vs. keying on the compatible string makes sense if you
know there is at least a second consumer of that property (unless we
make it a broadcom specific property, in which case, it really is
redundant with the compatible string).

Anyway, my grudge with that property was the name chosen initially,
which included an action to be performed by an implementation as opposed
to something purely descriptive. E.g: 'phy-supplies-clock' might be okay.



Wouldn't this solve your issue?


It would not change much except that there is no need to much with
ohci-platform.c anymore, but ultimately that property needs to be read
by ohci-hcd.c and acted on, which would likely lead to the same amount
of changes as those present in patch #2 currently.

We also need this functionality in the EHCI and XHCI drivers and it's 
not the ohci-hcd.c module that needs to know, it's the core/phy.c module 
called from core/hcd.c.


Al


[PATCH V4 2/5] usb: core: Add ability to skip phy exit on suspend and init on resume

2018-11-09 Thread Al Cooper
Add the ability to skip calling the PHY's exit routine on suspend
and the PHY's init routine on resume. This is to handle a USB PHY
that should have it's power_off function called on suspend but cannot
have it's exit function called because on exit it will disable the
PHY to the point where all USB clocks are stopped and register
accesses to the Host Controllers using the PHY will be disabled
and the host drivers will crash.

This is enabled with the HCD flag "phy_supplies_usb_clock" which
can be set from any HCD driver or with the device tree property
"phy-supplies-usb-clock".

Signed-off-by: Al Cooper 
---
 drivers/usb/core/hcd.c  |  8 
 drivers/usb/core/phy.c  | 28 
 drivers/usb/core/phy.h  |  9 ++---
 include/linux/usb/hcd.h |  6 ++
 4 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 487025d31d44..5ebc82a69403 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2249,7 +2249,7 @@ int hcd_bus_suspend(struct usb_device *rhdev, 
pm_message_t msg)
hcd->state = HC_STATE_SUSPENDED;
 
if (!PMSG_IS_AUTO(msg))
-   usb_phy_roothub_suspend(hcd->self.sysdev,
+   usb_phy_roothub_suspend(hcd,
hcd->phy_roothub);
 
/* Did we race with a root-hub wakeup event? */
@@ -2290,7 +2290,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t 
msg)
}
 
if (!PMSG_IS_AUTO(msg)) {
-   status = usb_phy_roothub_resume(hcd->self.sysdev,
+   status = usb_phy_roothub_resume(hcd,
hcd->phy_roothub);
if (status)
return status;
@@ -2333,7 +2333,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t 
msg)
}
} else {
hcd->state = old_state;
-   usb_phy_roothub_suspend(hcd->self.sysdev, hcd->phy_roothub);
+   usb_phy_roothub_suspend(hcd, hcd->phy_roothub);
dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
"resume", status);
if (status != -ESHUTDOWN)
@@ -2730,7 +2730,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
struct usb_device *rhdev;
 
if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) {
-   hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev);
+   hcd->phy_roothub = usb_phy_roothub_alloc(hcd);
if (IS_ERR(hcd->phy_roothub))
return PTR_ERR(hcd->phy_roothub);
 
diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c
index 38b2c776c4b4..8bfbacb52a7b 100644
--- a/drivers/usb/core/phy.c
+++ b/drivers/usb/core/phy.c
@@ -46,10 +46,11 @@ static int usb_phy_roothub_add_phy(struct device *dev, int 
index,
return 0;
 }
 
-struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev)
+struct usb_phy_roothub *usb_phy_roothub_alloc(struct usb_hcd *hcd)
 {
struct usb_phy_roothub *phy_roothub;
int i, num_phys, err;
+   struct device *dev = hcd->self.sysdev;
 
if (!IS_ENABLED(CONFIG_GENERIC_PHY))
return NULL;
@@ -59,6 +60,9 @@ struct usb_phy_roothub *usb_phy_roothub_alloc(struct device 
*dev)
if (num_phys <= 0)
return NULL;
 
+   if (device_property_read_bool(dev, "phy-supplies-usb-clock"))
+   hcd->phy_supplies_usb_clock = 1;
+
phy_roothub = devm_kzalloc(dev, sizeof(*phy_roothub), GFP_KERNEL);
if (!phy_roothub)
return ERR_PTR(-ENOMEM);
@@ -162,26 +166,33 @@ void usb_phy_roothub_power_off(struct usb_phy_roothub 
*phy_roothub)
 }
 EXPORT_SYMBOL_GPL(usb_phy_roothub_power_off);
 
-int usb_phy_roothub_suspend(struct device *controller_dev,
+int usb_phy_roothub_suspend(struct usb_hcd *hcd,
struct usb_phy_roothub *phy_roothub)
 {
+   struct device *controller_dev = hcd->self.sysdev;
+
usb_phy_roothub_power_off(phy_roothub);
 
-   /* keep the PHYs initialized so the device can wake up the system */
-   if (device_may_wakeup(controller_dev))
+   /*
+* keep the PHYs initialized so the device can wake up the system
+* or if needed to keep the USB clocks enabled.
+*/
+   if (device_may_wakeup(controller_dev) || hcd->phy_supplies_usb_clock)
return 0;
 
return usb_phy_roothub_exit(phy_roothub);
 }
 EXPORT_SYMBOL_GPL(usb_phy_roothub_suspend);
 
-int usb_phy_roothub_resume(struct device *controller_dev,
+int usb_phy_roothub_resume(struct usb_hcd *hcd,
   struct usb_phy_roothub *phy_roothub)
 {
+   struct device *controller_dev = hcd->

[PATCH V4 4/5] usb: ehci: Add new EHCI driver for Broadcom STB SoC's

2018-11-09 Thread Al Cooper
Add a new EHCI driver for Broadcom STB SoC's. A new EHCI driver
was created instead of adding support to the existing ehci platform
driver because of the code required to workaround bugs in the EHCI
controller.

Signed-off-by: Al Cooper 
---
 drivers/usb/host/ehci-brcm.c | 286 +++
 1 file changed, 286 insertions(+)
 create mode 100644 drivers/usb/host/ehci-brcm.c

diff --git a/drivers/usb/host/ehci-brcm.c b/drivers/usb/host/ehci-brcm.c
new file mode 100644
index ..eb0ea030a4c8
--- /dev/null
+++ b/drivers/usb/host/ehci-brcm.c
@@ -0,0 +1,286 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, Broadcom */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ehci.h"
+
+#define BRCM_DRIVER_DESC "EHCI Broadcom STB driver"
+
+#define hcd_to_ehci_priv(h) ((struct brcm_priv *)hcd_to_ehci(h)->priv)
+
+struct brcm_priv {
+   struct clk *clk;
+};
+
+static const char brcm_hcd_name[] = "ehci-brcm";
+
+static int (*org_hub_control)(struct usb_hcd *hcd,
+   u16 typeReq, u16 wValue, u16 wIndex,
+   char *buf, u16 wLength);
+
+/* ehci_brcm_wait_for_sof
+ * Wait for start of next microframe, then wait extra delay microseconds
+ */
+static inline void ehci_brcm_wait_for_sof(struct ehci_hcd *ehci, u32 delay)
+{
+   int frame_idx = ehci_readl(ehci, &ehci->regs->frame_index);
+
+   while (frame_idx == ehci_readl(ehci, &ehci->regs->frame_index))
+   ;
+   udelay(delay);
+}
+
+/*
+ * ehci_brcm_hub_control
+ * Intercept echi-hcd request to complete RESUME and align it to the start
+ * of the next microframe.
+ * If RESUME is complete too late in the microframe, host controller
+ * detects babble on suspended port and resets the port afterwards.
+ * This s/w workaround allows to avoid this problem.
+ * See SWLINUX-1909 for more details
+ */
+static int ehci_brcm_hub_control(
+   struct usb_hcd  *hcd,
+   u16 typeReq,
+   u16 wValue,
+   u16 wIndex,
+   char*buf,
+   u16 wLength)
+{
+   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+   int ports = HCS_N_PORTS(ehci->hcs_params);
+   u32 __iomem *status_reg = &ehci->regs->port_status[
+   (wIndex & 0xff) - 1];
+   unsigned long flags;
+   int retval, irq_disabled = 0;
+
+   /*
+* RESUME is cleared when GetPortStatus() is called 20ms after start
+* of RESUME
+*/
+   if ((typeReq == GetPortStatus) &&
+   (wIndex && wIndex <= ports) &&
+   ehci->reset_done[wIndex-1] &&
+   time_after_eq(jiffies, ehci->reset_done[wIndex-1]) &&
+   (ehci_readl(ehci, status_reg) & PORT_RESUME)) {
+
+   /*
+* to make sure we are not interrupted until RESUME bit
+* is cleared, disable interrupts on current CPU
+*/
+   ehci_dbg(ehci, "SOF alignment workaround\n");
+   irq_disabled = 1;
+   local_irq_save(flags);
+   ehci_brcm_wait_for_sof(ehci, 5);
+   }
+   retval = (*org_hub_control)(hcd, typeReq, wValue, wIndex, buf, wLength);
+   if (irq_disabled)
+   local_irq_restore(flags);
+   return retval;
+}
+
+static int ehci_brcm_reset(struct usb_hcd *hcd)
+{
+   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+
+   ehci->big_endian_mmio = 1;
+
+   ehci->caps = (struct ehci_caps *) hcd->regs;
+   ehci->regs = (struct ehci_regs *) (hcd->regs +
+   HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)));
+
+   /* This fixes the lockup during reboot due to prior interrupts */
+   ehci_writel(ehci, CMD_RESET, &ehci->regs->command);
+   mdelay(10);
+
+   /*
+* SWLINUX-1705: Avoid OUT packet underflows during high memory
+*   bus usage
+* port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x90
+*/
+   ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]);
+   ehci_writel(ehci, 0x0001, &ehci->regs->port_status[0x12]);
+
+   return ehci_setup(hcd);
+}
+
+static struct hc_driver __read_mostly ehci_brcm_hc_driver;
+
+static const struct ehci_driver_overrides brcm_overrides __initconst = {
+
+   .reset =ehci_brcm_reset,
+   .extra_priv_size = sizeof(struct brcm_priv),
+};
+
+static int ehci_brcm_probe(struct platform_device *pdev)
+{
+   struct usb_hcd *hcd;
+   struct resource *res_mem;
+   struct brcm_priv *priv;
+   int irq;
+   int err;
+
+   if (usb_disabled())
+   return -ENODEV;
+
+   err = dma_set_mask_and_coherent(&

[PATCH V4 5/5] usb: host: Add ability to build new Broadcom STB USB drivers

2018-11-09 Thread Al Cooper
Add the build system changes needed to get the Broadcom STB XHCI,
EHCI and OHCI functionality working. The link order for XHCI was
changed in the Makefile because of the way STB XHCI, EHCI and OHCI
controllers share a port which requires that the XHCI driver be
initialized first. Also update MAINTAINERS.

Signed-off-by: Al Cooper 
---
 MAINTAINERS |  9 +
 arch/arm/configs/multi_v7_defconfig |  1 +
 arch/arm64/configs/defconfig|  1 +
 drivers/usb/host/Kconfig| 26 ++
 drivers/usb/host/Makefile   | 18 --
 5 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2f3eba4484aa..932fcc6f8ff5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2998,6 +2998,15 @@ S:   Supported
 F: drivers/i2c/busses/i2c-brcmstb.c
 F: Documentation/devicetree/bindings/i2c/i2c-brcmstb.txt
 
+BROADCOM BRCMSTB USB XHCI, EHCI and OHCI DRIVERS
+M: Al Cooper 
+L: linux-usb@vger.kernel.org
+L: bcm-kernel-feedback-l...@broadcom.com
+S: Maintained
+F: drivers/usb/host/ehci-brcm.*
+F: drivers/usb/host/xhci-brcm.*
+F: Documentation/devicetree/bindings/usb/brcm,bcm7445-*.txt
+
 BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER
 M: Al Cooper 
 L: linux-ker...@vger.kernel.org
diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index 63af6234c1b6..64ca0edb43ed 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -726,6 +726,7 @@ CONFIG_USB_CHIPIDEA_UDC=y
 CONFIG_USB_CHIPIDEA_HOST=y
 CONFIG_USB_ISP1760=y
 CONFIG_USB_HSIC_USB3503=y
+CONFIG_USB_BRCM=y
 CONFIG_AB8500_USB=y
 CONFIG_KEYSTONE_USB_PHY=m
 CONFIG_NOP_USB_XCEIV=m
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index c9a57d11330b..89637256e7bf 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -520,6 +520,7 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_RENESAS_USBHS_UDC=m
 CONFIG_USB_RENESAS_USB3=m
 CONFIG_USB_ULPI_BUS=y
+CONFIG_USB_BRCM=y
 CONFIG_MMC=y
 CONFIG_MMC_BLOCK_MINORS=32
 CONFIG_MMC_ARMMMCI=y
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 16758b12a5e9..2d0b3060ad05 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -96,6 +96,32 @@ config USB_XHCI_TEGRA
 
 endif # USB_XHCI_HCD
 
+config USB_OHCI_BRCM
+   tristate
+
+config USB_EHCI_BRCM
+   tristate
+
+config USB_XHCI_BRCM
+   tristate
+
+config BRCM_USB_PHY
+   tristate
+
+config USB_BRCM
+   tristate "Broadcom STB USB support"
+   depends on ARCH_BRCMSTB || COMPILE_TEST
+   select USB_OHCI_HCD_PLATFORM if USB_OHCI_HCD
+   select USB_EHCI_BRCM if USB_EHCI_HCD
+   select USB_XHCI_BRCM if USB_XHCI_HCD
+   select USB_XHCI_PLATFORM if USB_XHCI_HCD
+   help
+ Say Y to enable support for XHCI, EHCI and OHCI host controllers
+ found in Broadcom STB SoC's.
+
+ Disabling this will keep the controllers and corresponding
+ PHYs powered down.
+
 config USB_EHCI_HCD
tristate "EHCI HCD (USB 2.0) support"
depends on HAS_DMA && HAS_IOMEM
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 84514f71ae44..9bdd64b710ee 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -31,6 +31,10 @@ ifneq ($(CONFIG_USB_XHCI_RCAR), )
xhci-plat-hcd-y += xhci-rcar.o
 endif
 
+ifneq ($(CONFIG_USB_XHCI_BRCM), )
+   xhci-plat-hcd-y += xhci-brcm.o
+endif
+
 ifneq ($(CONFIG_DEBUG_FS),)
xhci-hcd-y  += xhci-debugfs.o
 endif
@@ -39,6 +43,13 @@ obj-$(CONFIG_USB_WHCI_HCD)   += whci/
 
 obj-$(CONFIG_USB_PCI)  += pci-quirks.o
 
+obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o
+obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o
+obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o
+obj-$(CONFIG_USB_XHCI_HISTB)   += xhci-histb.o
+obj-$(CONFIG_USB_XHCI_MTK) += xhci-mtk.o
+obj-$(CONFIG_USB_XHCI_TEGRA)   += xhci-tegra.o
+
 obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
 obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
 obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)+= ehci-platform.o
@@ -52,6 +63,7 @@ obj-$(CONFIG_USB_EHCI_EXYNOS) += ehci-exynos.o
 obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += ehci-tegra.o
 obj-$(CONFIG_USB_W90X900_EHCI) += ehci-w90x900.o
+obj-$(CONFIG_USB_EHCI_BRCM)+= ehci-brcm.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
@@ -72,12 +84,6 @@ obj-$(CONFIG_USB_OHCI_HCD_DAVINCI)   += ohci-da8xx.o
 
 obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
 obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
-obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o
-obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o
-obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o
-obj-$(CONFIG_USB_XHCI_HISTB)   += xhci-histb.o
-obj-$(CONFIG_USB_XHCI_MTK) += xhci-mtk.o
-obj-$(CONFIG_USB_X

[PATCH V4 1/5] dt-bindings: Add Broadcom STB USB support

2018-11-09 Thread Al Cooper
Add DT bindings for Broadcom STB USB EHCI and XHCI drivers.
Add "phy-supplies-usb-clock" property description to usb-hcd.txt

NOTE: The OHCI driver is not included because it uses the generic
  platform driver.

Signed-off-by: Al Cooper 
---
 .../devicetree/bindings/usb/brcm,bcm7445-ehci.txt  | 24 ++
 Documentation/devicetree/bindings/usb/usb-hcd.txt  |  3 +++
 Documentation/devicetree/bindings/usb/usb-xhci.txt |  1 +
 3 files changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt 
b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt
new file mode 100644
index ..4dea956f2705
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt
@@ -0,0 +1,24 @@
+Broadcom STB USB EHCI controller
+
+Required properties:
+- compatible: should be "brcm,bcm7445-ehci"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+- phys: phandle + phy specifier pair
+  The specifier should be 0 for the OHCI/EHCI PHY
+- phy-supplies-usb-clock: See usb-hcd.txt for details.
+
+Optional properties:
+- clocks: A phandle for the EHCI clock
+
+Example:
+
+ehci@f0b00300 {
+   compatible = "brcm,bcm7445-ehci";
+   reg = <0xf0b00300 0xa8>;
+   interrupts = <0x0 0x5a 0x0>;
+   interrupt-names = "usb0_ehci_0";
+   phys = <&usbphy_0 0x0>;
+   clocks = <&usb20>;
+   phy-supplies-usb-clock;
+};
diff --git a/Documentation/devicetree/bindings/usb/usb-hcd.txt 
b/Documentation/devicetree/bindings/usb/usb-hcd.txt
index 50529b838c9c..6b4755924b15 100644
--- a/Documentation/devicetree/bindings/usb/usb-hcd.txt
+++ b/Documentation/devicetree/bindings/usb/usb-hcd.txt
@@ -2,6 +2,9 @@ Generic USB HCD (Host Controller Device) Properties
 
 Optional properties:
 - phys: a list of all USB PHYs on this HCD
+- phy-supplies-usb-clock: boolean, used for SoCs where the PHY supplies
+  the usb controller clock. This will prevent the PHY exit from being
+  called on suspend.
 
 Example:
&usb1 {
diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index fea8b1545751..f58e617ee54c 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -21,6 +21,7 @@ Required properties:
   device
 - "renesas,rcar-gen3-xhci" for a generic R-Car Gen3 or RZ/G2 compatible
   device
+- "brcm,bcm7445-xhci" for Broadcom STB SoCs
 - "xhci-platform" (deprecated)
 
 When compatible with the generic version, nodes must list the
-- 
1.9.0.138.g2de3478



[PATCH V4 0/5] Add XHCI, EHCI and OHCI support for Broadcom STB SoS's

2018-11-09 Thread Al Cooper
V4 - Rename hcd phy flag "suspend_without_phy_exit" to
 "phy_supplies_usb_clock" to more closely reflect
 the actaual hardware. Add the device tree property
 "suspend-without-phy-exit" to set the flag. Remove the code
 that sets the flag in the OHCI, EHCI and XHCI drivers which
 means that the ohci_platform.c driver can be used without
 any modifications.
   
V3 - Based on feedback
   - Patch 3/6
 In xhci-brcm.h, fixed incorrect function name when
 CONFIG_USB_XHCI_BRCM is not defined. Found by kbuild test robot.
   - Patch 4/6
 In ohci-platform.c, use devm_kmemdup() instead of demv_kzalloc().
   - Patch 5/6
 In ehci-platform.c, use dma_coerce_mask_and_coherent()
 instead of dma_coerce_mask_and_coherent(). Remove unneeded
 #ifdef CONFIG_OF.

V2 - Based on feedback, the functionality for XHCI and OHCI was
 moved from Broadcom platform drivers into the standard XHCI
 and OHCI platform drivers. The EHCI functionality still uses
 a Broadcom EHCI driver because of the workarounds needed for
 bugs in the EHCI controller.

This adds support for the XHCI, EHCI and OHCI host controllers found
in Broadcom STB SoC's. These drivers depend on getting access to the
new Broadcom STB USB PHY driver through a device-tree phandle and
will fail if the driver is not available.

Al Cooper (5):
  dt-bindings: Add Broadcom STB USB support
  usb: core: Add ability to skip phy exit on suspend and init on resume
  usb: xhci: xhci-plat: Add support for Broadcom STB SoC's
  usb: ehci: Add new EHCI driver for Broadcom STB SoC's
  usb: host: Add ability to build new Broadcom STB USB drivers

 .../devicetree/bindings/usb/brcm,bcm7445-ehci.txt  |  24 ++
 Documentation/devicetree/bindings/usb/usb-hcd.txt  |   3 +
 Documentation/devicetree/bindings/usb/usb-xhci.txt |   1 +
 MAINTAINERS|   9 +
 arch/arm/configs/multi_v7_defconfig|   1 +
 arch/arm64/configs/defconfig   |   1 +
 drivers/usb/core/hcd.c |   8 +-
 drivers/usb/core/phy.c |  28 +-
 drivers/usb/core/phy.h |   9 +-
 drivers/usb/host/Kconfig   |  26 ++
 drivers/usb/host/Makefile  |  18 +-
 drivers/usb/host/ehci-brcm.c   | 286 +
 drivers/usb/host/xhci-brcm.c   |  16 ++
 drivers/usb/host/xhci-brcm.h   |  16 ++
 drivers/usb/host/xhci-plat.c   |   8 +
 include/linux/usb/hcd.h|   6 +
 16 files changed, 439 insertions(+), 21 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bcm7445-ehci.txt
 create mode 100644 drivers/usb/host/ehci-brcm.c
 create mode 100644 drivers/usb/host/xhci-brcm.c
 create mode 100644 drivers/usb/host/xhci-brcm.h

-- 
1.9.0.138.g2de3478



[PATCH V4 3/5] usb: xhci: xhci-plat: Add support for Broadcom STB SoC's

2018-11-09 Thread Al Cooper
Add support for Broadcom STB SoC's to the xhci platform driver

Signed-off-by: Al Cooper 
---
 drivers/usb/host/xhci-brcm.c | 16 
 drivers/usb/host/xhci-brcm.h | 16 
 drivers/usb/host/xhci-plat.c |  8 
 3 files changed, 40 insertions(+)
 create mode 100644 drivers/usb/host/xhci-brcm.c
 create mode 100644 drivers/usb/host/xhci-brcm.h

diff --git a/drivers/usb/host/xhci-brcm.c b/drivers/usb/host/xhci-brcm.c
new file mode 100644
index ..bf8c0bfd1780
--- /dev/null
+++ b/drivers/usb/host/xhci-brcm.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, Broadcom */
+
+#include 
+#include 
+
+#include "xhci.h"
+
+int xhci_plat_brcm_init_quirk(struct usb_hcd *hcd)
+{
+   struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+   xhci->quirks |= XHCI_RESET_ON_RESUME;
+   return 0;
+}
+
diff --git a/drivers/usb/host/xhci-brcm.h b/drivers/usb/host/xhci-brcm.h
new file mode 100644
index ..e64800fae4d5
--- /dev/null
+++ b/drivers/usb/host/xhci-brcm.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2018, Broadcom */
+
+#ifndef _XHCI_BRCM_H
+#define _XHCI_BRCM_H
+
+#if IS_ENABLED(CONFIG_USB_XHCI_BRCM)
+int xhci_plat_brcm_init_quirk(struct usb_hcd *hcd);
+#else
+static inline int xhci_plat_brcm_init_quirk(struct usb_hcd *hcd)
+{
+   return 0;
+}
+#endif
+#endif /* _XHCI_BRCM_H */
+
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 32b5574ad5c5..5372d4040be6 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -24,6 +24,7 @@
 #include "xhci-plat.h"
 #include "xhci-mvebu.h"
 #include "xhci-rcar.h"
+#include "xhci-brcm.h"
 
 static struct hc_driver __read_mostly xhci_plat_hc_driver;
 
@@ -112,6 +113,10 @@ static int xhci_plat_start(struct usb_hcd *hcd)
.resume_quirk = xhci_rcar_resume_quirk,
 };
 
+static const struct xhci_plat_priv xhci_plat_brcm = {
+   .init_quirk = xhci_plat_brcm_init_quirk
+};
+
 static const struct of_device_id usb_xhci_of_match[] = {
{
.compatible = "generic-xhci",
@@ -144,6 +149,9 @@ static int xhci_plat_start(struct usb_hcd *hcd)
}, {
.compatible = "renesas,rcar-gen3-xhci",
.data = &xhci_plat_renesas_rcar_gen3,
+   }, {
+   .compatible = "brcm,bcm7445-xhci",
+   .data = &xhci_plat_brcm,
},
{},
 };
-- 
1.9.0.138.g2de3478