Skip to contentSkip to conversation

Add QCOM DWC3 Phy support

PATCH In review Andy Gross 3 participants 10 messages Nov 20, 2015

Subsystems (5)
lore
Share & tools
lore

Andy Gross

author
#0 lore raw

cover Add QCOM DWC3 Phy support

This set of patches adds support for the QCOM DWC3 phys found on various Qualcomm platforms. The PHY portion of this set was originally part of:

https://lkml.org/lkml/2014/9/12/597

The applicable review comments were fixed and additional changes were made to accomodate the TCSR phy mux selection required to get working ports.

Andy Gross (4):
phy: Add Qualcomm DWC3 HS/SS PHY driver
usb: dwc3: qcom: Configure TCSR phy mux register
ARM: dts: qcom: Add DWC3 USB support on IPQ8064
Documentation: usb: dwc3: qcom: Add TCSR mux usage

 .../devicetree/bindings/usb/qcom,dwc3.txt          |  11 +
 arch/arm/boot/dts/qcom-ipq8064-ap148.dts           |  24 +
 arch/arm/boot/dts/qcom-ipq8064.dtsi                |  89 ++++
 drivers/phy/Kconfig                                |  11 +
 drivers/phy/Makefile                               |   1 +
 drivers/phy/phy-qcom-dwc3.c                        | 483 +++++++++++++++++++++
 drivers/usb/dwc3/dwc3-qcom.c                       |  25 ++
 7 files changed, 644 insertions(+)
 create mode 100644 drivers/phy/phy-qcom-dwc3.c
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
author
#1 lore raw

PATCH 1/4 phy: Add Qualcomm DWC3 HS/SS PHY driver

This patch adds a new driver for the Qualcomm USB 3.0 PHY that exists on some Qualcomm platforms. This driver uses the generic PHY framework and will interact with the DWC3 controller.

---
 drivers/phy/Kconfig         |  11 +
 drivers/phy/Makefile        |   1 +
 drivers/phy/phy-qcom-dwc3.c | 483 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 495 insertions(+)
 create mode 100644 drivers/phy/phy-qcom-dwc3.c
drivers/phy/Kconfig +11 -0
index 7eb5859d..f26bfc9 100644
@@ -305,6 +305,17 @@ config PHY_QCOM_APQ8064_SATA
 	depends on OF
 	select GENERIC_PHY
 
+config PHY_QCOM_DWC3
+	tristate "Qualcomm DWC3 USB PHY support"
+	depends on ARCH_QCOM
+	depends on HAS_IOMEM
+	depends on OF
+	select GENERIC_PHY
+	help
+	  This option enables support for the Synopsis PHYs present inside the
+	  Qualcomm USB3.0 DWC3 controller.  This driver supports both HS and SS
+	  PHY controllers.
+
 config PHY_QCOM_IPQ806X_SATA
 	tristate "Qualcomm IPQ806x SATA SerDes/PHY driver"
 	depends on ARCH_QCOM
drivers/phy/Makefile +1 -0
index 075db1a..0610e0d 100644
@@ -48,3 +48,4 @@ obj-$(CONFIG_PHY_TUSB1210)		+= phy-tusb1210.o
 obj-$(CONFIG_PHY_BRCMSTB_SATA)		+= phy-brcmstb-sata.o
 obj-$(CONFIG_PHY_PISTACHIO_USB)		+= phy-pistachio-usb.o
 obj-$(CONFIG_PHY_CYGNUS_PCIE)		+= phy-bcm-cygnus-pcie.o
+obj-$(CONFIG_PHY_QCOM_DWC3)		+= phy-qcom-dwc3.o
drivers/phy/phy-qcom-dwc3.c new file +483 -0

483 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
author
#2 lore raw

PATCH 2/4 usb: dwc3: qcom: Configure TCSR phy mux register

In reply to Andy Gross

This patch adds automatic configuration of the TCSR phy mux register based on the syscon-tcsr devicetree entry. This configuration is optional, as some platforms may not require the mux selection.

---
 drivers/usb/dwc3/dwc3-qcom.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/usb/dwc3/dwc3-qcom.c +25 -0
index 0880260..fcf264c 100644
@@ -17,6 +17,8 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 
 struct dwc3_qcom {
 	struct device		*dev;
@@ -30,6 +32,9 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct dwc3_qcom *qdwc;
+	struct regmap *regmap;
+	u32 mux_offset;
+	u32 mux_bit;
 	int ret;
 
 	qdwc = devm_kzalloc(&pdev->dev, sizeof(*qdwc), GFP_KERNEL);
@@ -58,6 +63,26 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 		qdwc->sleep_clk = NULL;
 	}
 
+	/* look for tcsr and if present, provision it */
+	regmap = syscon_regmap_lookup_by_phandle(node, "syscon-tcsr");
+	if (!IS_ERR(regmap)) {
+		if (of_property_read_u32_index(node, "syscon-tcsr", 1,
+					       &mux_offset)) {
+			dev_err(qdwc->dev, "missing USB TCSR mux offset\n");
+			return -EINVAL;
+		}
+		if (of_property_read_u32_index(node, "syscon-tcsr", 2,
+					       &mux_bit)) {
+			dev_err(qdwc->dev, "missing USB TCSR mux bit\n");
+			return -EINVAL;
+		}
+
+		regmap_update_bits(regmap, mux_offset, BIT(mux_bit),
+				   BIT(mux_bit));
+	} else {
+		dev_info(qdwc->dev, "missing syscon tcsr entry\n");
+	}
+
 	ret = clk_prepare_enable(qdwc->core_clk);
 	if (ret) {
 		dev_err(qdwc->dev, "failed to enable core clock\n");
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#3 lore raw

Re: [PATCH 2/4] usb: dwc3: qcom: Configure TCSR phy mux register

Hi,

Quoted 5 lines · Andy Gross

This patch adds automatic configuration of the TCSR phy mux register based on the syscon-tcsr devicetree entry. This configuration is optional, as some platforms may not require the mux selection.

just when I find a way to make a generic dwc3-of-simple.c glue layer :-p

I can, certainly drop my patches but I need more details on the syscon usage below.

Quoted 37 lines
---
 drivers/usb/dwc3/dwc3-qcom.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/usb/dwc3/dwc3-qcom.c +11 -0
index 0880260..fcf264c 100644
@@ -17,6 +17,8 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 
 struct dwc3_qcom {
 	struct device		*dev;
@@ -30,6 +32,9 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct dwc3_qcom *qdwc;
+	struct regmap *regmap;
+	u32 mux_offset;
+	u32 mux_bit;
 	int ret;
 
 	qdwc = devm_kzalloc(&pdev->dev, sizeof(*qdwc), GFP_KERNEL);
@@ -58,6 +63,26 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 		qdwc->sleep_clk = NULL;
 	}
 
+	/* look for tcsr and if present, provision it */
+	regmap = syscon_regmap_lookup_by_phandle(node, "syscon-tcsr");
+	if (!IS_ERR(regmap)) {
+		if (of_property_read_u32_index(node, "syscon-tcsr", 1,
+					       &mux_offset)) {
+			dev_err(qdwc->dev, "missing USB TCSR mux offset\n");

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_probe(struct platform_device *pdev) · line 81

Quoted 10 lines
drivers/usb/dwc3/dwc3-qcom.c +10 -0
+			return -EINVAL;
+		}
+		if (of_property_read_u32_index(node, "syscon-tcsr", 2,
+					       &mux_bit)) {
+			dev_err(qdwc->dev, "missing USB TCSR mux bit\n");
+			return -EINVAL;
+		}
+
+		regmap_update_bits(regmap, mux_offset, BIT(mux_bit),
+				   BIT(mux_bit));

what is tcsr and what does it ? It also seems to be optional, why's that ?

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151120/4c34a46e/attachment-0001.sig>
author
#4 lore raw

Re: [PATCH 2/4] usb: dwc3: qcom: Configure TCSR phy mux register

Quoted 56 lines · Felipe Balbi

Hi,

Quoted 5 lines · Andy Gross

This patch adds automatic configuration of the TCSR phy mux register based on the syscon-tcsr devicetree entry. This configuration is optional, as some platforms may not require the mux selection.

just when I find a way to make a generic dwc3-of-simple.c glue layer :-p

I can, certainly drop my patches but I need more details on the syscon usage below.

Quoted 41 lines
---
 drivers/usb/dwc3/dwc3-qcom.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/usb/dwc3/dwc3-qcom.c +15 -0
index 0880260..fcf264c 100644
@@ -17,6 +17,8 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 
 struct dwc3_qcom {
 	struct device		*dev;
@@ -30,6 +32,9 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct dwc3_qcom *qdwc;
+	struct regmap *regmap;
+	u32 mux_offset;
+	u32 mux_bit;
 	int ret;
 
 	qdwc = devm_kzalloc(&pdev->dev, sizeof(*qdwc), GFP_KERNEL);
@@ -58,6 +63,26 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 		qdwc->sleep_clk = NULL;
 	}
 
+	/* look for tcsr and if present, provision it */
+	regmap = syscon_regmap_lookup_by_phandle(node, "syscon-tcsr");
+	if (!IS_ERR(regmap)) {
+		if (of_property_read_u32_index(node, "syscon-tcsr", 1,
+					       &mux_offset)) {
+			dev_err(qdwc->dev, "missing USB TCSR mux offset\n");
+			return -EINVAL;
+		}
+		if (of_property_read_u32_index(node, "syscon-tcsr", 2,
+					       &mux_bit)) {
Quoted 11 lines

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_probe(struct platform_device *pdev) · line 81

Quoted 6 lines
drivers/usb/dwc3/dwc3-qcom.c +6 -0
+			dev_err(qdwc->dev, "missing USB TCSR mux bit\n");
+			return -EINVAL;
+		}
+
+		regmap_update_bits(regmap, mux_offset, BIT(mux_bit),
+				   BIT(mux_bit));

what is tcsr and what does it ? It also seems to be optional, why's that ?

Signature · 1 line
balbi

The syscon is to set the mux selection for the phys. Our hardware has a steering mux between hsic and dwc3 and setting this to 1 steers the phys to the right controller.

It is optional because not all platforms appear to have this stupidity.

Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#5 lore raw

PATCH 3/4 ARM: dts: qcom: Add DWC3 USB support on IPQ8064

In reply to Andy Gross

This patch adds Qualcomm DWC3 USB nodes to device tree to enable support for the DWC3 controller found on IPQ8064/AP148 platforms.

---
 arch/arm/boot/dts/qcom-ipq8064-ap148.dts | 24 +++++++++
 arch/arm/boot/dts/qcom-ipq8064.dtsi      | 89 ++++++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+)
arch/arm/boot/dts/qcom-ipq8064-ap148.dts +24 -0
index d501382..bf1638c 100644
@@ -97,5 +97,29 @@
 		sata at 29000000 {
 			status = "ok";
 		};
+
+		phy at 100f8800 {
+			status = "ok";
+		};
+
+		phy at 100f8830 {
+			status = "ok";
+		};
+
+		usb30 at 0 {
+			status = "ok";
+		};
+
+		phy at 110f8800 {
+			status = "ok";
+		};
+
+		phy at 110f8830 {
+			status = "ok";
+		};
+
+		usb30 at 1 {
+			status = "ok";
+		};
 	};
 };
arch/arm/boot/dts/qcom-ipq8064.dtsi +89 -0

94 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
author
#6 lore raw

PATCH 4/4 Documentation: usb: dwc3: qcom: Add TCSR mux usage

In reply to Andy Gross

This patch adds documentation for the optional syscon-tcsr property in the Qualcomm DWC3 node. The syscon-tcsr specifies the register and bit used to configure the TCSR USB phy mux register.

---
 Documentation/devicetree/bindings/usb/qcom,dwc3.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/usb/qcom,dwc3.txt +11 -0
index ca164e7..dfa222d 100644
@@ -8,6 +8,10 @@ Required properties:
   "core"		Master/Core clock, have to be >= 125 MHz for SS
 				operation and >= 60MHz for HS operation
 
+Optional properties:
+- syscon-tcsr	Specifies TCSR handle, register offset, and bit position for
+			configuring the phy mux setting.
+
 Optional clocks:
   "iface"		System bus AXI clock.  Not present on all platforms
   "sleep"		Sleep clock, used when USB3 core goes into low
@@ -22,6 +26,11 @@ Documentation/devicetree/bindings/phy/qcom,dwc3-usb-phy.txt
 
 Example device nodes:
 
+		tcsr: syscon at 1a400000 {
+			compatible = "qcom,tcsr-ipq8064", "syscon";
+			reg = <0x1a400000 0x100>;
+		};
+
 		hs_phy: phy at 100f8800 {
 			compatible = "qcom,dwc3-hs-usb-phy";
 			reg = <0x100f8800 0x30>;
@@ -51,6 +60,8 @@ Example device nodes:
 
 			ranges;
 
+			syscon-tcsr = <&tcsr 0xb0 0x1>;
+
 			status = "ok";
 
 			dwc3 at 10000000 {
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
maintainer Acked-by on v1 4/4
#7 lore raw

Re: [PATCH 4/4] Documentation: usb: dwc3: qcom: Add TCSR mux usage

Quoted 5 lines · Andy Gross

This patch adds documentation for the optional syscon-tcsr property in the Qualcomm DWC3 node. The syscon-tcsr specifies the register and bit used to configure the TCSR USB phy mux register.

Quoted 48 lines
---
 Documentation/devicetree/bindings/usb/qcom,dwc3.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/usb/qcom,dwc3.txt +11 -0
index ca164e7..dfa222d 100644
@@ -8,6 +8,10 @@ Required properties:
   "core"		Master/Core clock, have to be >= 125 MHz for SS
 				operation and >= 60MHz for HS operation
 
+Optional properties:
+- syscon-tcsr	Specifies TCSR handle, register offset, and bit position for
+			configuring the phy mux setting.
+
 Optional clocks:
   "iface"		System bus AXI clock.  Not present on all platforms
   "sleep"		Sleep clock, used when USB3 core goes into low
@@ -22,6 +26,11 @@ Documentation/devicetree/bindings/phy/qcom,dwc3-usb-phy.txt
 
 Example device nodes:
 
+		tcsr: syscon at 1a400000 {
+			compatible = "qcom,tcsr-ipq8064", "syscon";
+			reg = <0x1a400000 0x100>;
+		};
+
 		hs_phy: phy at 100f8800 {
 			compatible = "qcom,dwc3-hs-usb-phy";
 			reg = <0x100f8800 0x30>;
@@ -51,6 +60,8 @@ Example device nodes:
 
 			ranges;
 
+			syscon-tcsr = <&tcsr 0xb0 0x1>;
+
 			status = "ok";
 
 			dwc3 at 10000000 {
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

Re: [PATCH 4/4] Documentation: usb: dwc3: qcom: Add TCSR mux usage

In reply to Andy Gross

Hi,

Quoted 14 lines · Andy Gross

This patch adds documentation for the optional syscon-tcsr property in the Qualcomm DWC3 node. The syscon-tcsr specifies the register and bit used to configure the TCSR USB phy mux register.

---
 Documentation/devicetree/bindings/usb/qcom,dwc3.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/usb/qcom,dwc3.txt +0 -0
index ca164e7..dfa222d 100644

Documentation/devicetree/bindings/usb/qcom,dwc3.txt Required properties: · line 13

Quoted 6 lines
Documentation/devicetree/bindings/usb/qcom,dwc3.txt +3 -0
@@ -8,6 +8,10 @@ Required properties:
   "core"		Master/Core clock, have to be >= 125 MHz for SS
 				operation and >= 60MHz for HS operation
 
+Optional properties:
+- syscon-tcsr	Specifies TCSR handle, register offset, and bit position for
+			configuring the phy mux setting.

oh, it's a PHY mux ? I don't think it should be part of any dwc3-* glue layer then. By the time we reach dwc3, the mux should be properly configured.

Kishon, any ideas ?

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151120/b8e081a7/attachment.sig>
author
#9 lore raw

Re: [PATCH 4/4] Documentation: usb: dwc3: qcom: Add TCSR mux usage

Quoted 29 lines · Felipe Balbi

Hi,

Quoted 14 lines · Andy Gross

This patch adds documentation for the optional syscon-tcsr property in the Qualcomm DWC3 node. The syscon-tcsr specifies the register and bit used to configure the TCSR USB phy mux register.

---
 Documentation/devicetree/bindings/usb/qcom,dwc3.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/usb/qcom,dwc3.txt +0 -0
index ca164e7..dfa222d 100644

Documentation/devicetree/bindings/usb/qcom,dwc3.txt Required properties: · line 13

Quoted 6 lines
Documentation/devicetree/bindings/usb/qcom,dwc3.txt +3 -0
@@ -8,6 +8,10 @@ Required properties:
   "core"		Master/Core clock, have to be >= 125 MHz for SS
 				operation and >= 60MHz for HS operation
 
+Optional properties:
+- syscon-tcsr	Specifies TCSR handle, register offset, and bit position for
+			configuring the phy mux setting.

oh, it's a PHY mux ? I don't think it should be part of any dwc3-* glue layer then. By the time we reach dwc3, the mux should be properly configured.

Quoted 4 lines

Kishon, any ideas ?

Signature · 1 line
balbi

The only issue with putting it at the phy layer is that i'd have redundant syscon entries for each pair of phys, unless i group them somehow in dt. The only other issue I can think of is that in the downstream kernels, they do this before messing with the configuration of the dwc3. So long as the phys do their thing before the dwc3 (phys latched before config), we're ok.

Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project