Skip to contentSkip to conversation

usb: dwc3: keystone: Convert binding to YAML

PATCH In review Roger Quadros 4 participants 11 messages May 13, 2020 – Jun 2, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover usb: dwc3: keystone: Convert binding to YAML

Hi Felipe,

This series converts keystone-usb.txt to YAML and prepares for Super-Speed support for AM654 SoC.

cheers,
-roger

Roger Quadros (3):
dt-bindings: usb: convert keystone-usb.txt to YAML
dt-bindings: usb: ti,keystone-dwc3.yaml: Add USB3.0 PHY property
usb: dwc3: keystone: Turn on USB3 PHY before controller

 .../devicetree/bindings/usb/keystone-usb.txt  | 56 ------------
 .../bindings/usb/ti,keystone-dwc3.yaml        | 88 +++++++++++++++++++
 drivers/usb/dwc3/dwc3-keystone.c              | 47 +++++++++-
 3 files changed, 134 insertions(+), 57 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/usb/keystone-usb.txt
 create mode 100644 Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#1 lore raw

PATCH 1/3 dt-bindings: usb: convert keystone-usb.txt to YAML

Convert keystone-usb documentation to YAML format.

---
 .../devicetree/bindings/usb/keystone-usb.txt  | 56 ----------------
 .../bindings/usb/ti,keystone-dwc3.yaml        | 67 +++++++++++++++++++
 2 files changed, 67 insertions(+), 56 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/usb/keystone-usb.txt
 create mode 100644 Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml
Documentation/devicetree/bindings/usb/keystone-usb.txt deleted +0 -56
deleted file mode 100644
index 77df82e36138..000000000000
@@ -1,56 +0,0 @@
-TI Keystone Soc USB Controller
-
-DWC3 GLUE
-
-Required properties:
- - compatible: should be
-		"ti,keystone-dwc3" for Keystone 2 SoCs
-		"ti,am654-dwc3" for AM654 SoC
- - #address-cells, #size-cells : should be '1' if the device has sub-nodes
-   with 'reg' property.
- - reg : Address and length of the register set for the USB subsystem on
-   the SOC.
- - interrupts : The irq number of this device that is used to interrupt the
-   MPU.
- - ranges: allows valid 1:1 translation between child's address space and
-   parent's address space.
-
-SoC-specific Required Properties:
-The following are mandatory properties for Keystone 2 66AK2HK, 66AK2L and 66AK2E
-SoCs only:
-
-- clocks:		Clock ID for USB functional clock.
-- clock-names:		Must be "usb".
-
-
-The following are mandatory properties for 66AK2G and AM654:
-
-- power-domains:	Should contain a phandle to a PM domain provider node
-			and an args specifier containing the USB device id
-			value. This property is as per the binding,
-			Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt
-
-Sub-nodes:
-The dwc3 core should be added as subnode to Keystone DWC3 glue.
-- dwc3 :
-   The binding details of dwc3 can be found in:
-   Documentation/devicetree/bindings/usb/dwc3.txt
-
-Example:
-	usb: usb@2680000 {
-		compatible = "ti,keystone-dwc3";
-		#address-cells = <1>;
-		#size-cells = <1>;
-		reg = <0x2680000 0x10000>;
-		clocks = <&clkusb>;
-		clock-names = "usb";
-		interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
-		ranges;
-
-		dwc3@2690000 {
-			compatible = "synopsys,dwc3";
-			reg = <0x2690000 0x70000>;
-			interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
-			usb-phy = <&usb_phy>, <&usb_phy>;
-		};
-	};
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +67 -0

67 lines not on this page · raw message

Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
maintainer
#2 lore raw

Re: [PATCH 1/3] dt-bindings: usb: convert keystone-usb.txt to YAML

Quoted 84 lines · Roger Quadros

Convert keystone-usb documentation to YAML format.

---
 .../devicetree/bindings/usb/keystone-usb.txt  | 56 ----------------
 .../bindings/usb/ti,keystone-dwc3.yaml        | 67 +++++++++++++++++++
 2 files changed, 67 insertions(+), 56 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/usb/keystone-usb.txt
 create mode 100644 Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml
Documentation/devicetree/bindings/usb/keystone-usb.txt deleted +0 -56
deleted file mode 100644
index 77df82e36138..000000000000
@@ -1,56 +0,0 @@
-TI Keystone Soc USB Controller
-
-DWC3 GLUE
-
-Required properties:
- - compatible: should be
-		"ti,keystone-dwc3" for Keystone 2 SoCs
-		"ti,am654-dwc3" for AM654 SoC
- - #address-cells, #size-cells : should be '1' if the device has sub-nodes
-   with 'reg' property.
- - reg : Address and length of the register set for the USB subsystem on
-   the SOC.
- - interrupts : The irq number of this device that is used to interrupt the
-   MPU.
- - ranges: allows valid 1:1 translation between child's address space and
-   parent's address space.
-
-SoC-specific Required Properties:
-The following are mandatory properties for Keystone 2 66AK2HK, 66AK2L and 66AK2E
-SoCs only:
-
-- clocks:		Clock ID for USB functional clock.
-- clock-names:		Must be "usb".
-
-
-The following are mandatory properties for 66AK2G and AM654:
-
-- power-domains:	Should contain a phandle to a PM domain provider node
-			and an args specifier containing the USB device id
-			value. This property is as per the binding,
-			Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt
-
-Sub-nodes:
-The dwc3 core should be added as subnode to Keystone DWC3 glue.
-- dwc3 :
-   The binding details of dwc3 can be found in:
-   Documentation/devicetree/bindings/usb/dwc3.txt
-
-Example:
-	usb: usb@2680000 {
-		compatible = "ti,keystone-dwc3";
-		#address-cells = <1>;
-		#size-cells = <1>;
-		reg = <0x2680000 0x10000>;
-		clocks = <&clkusb>;
-		clock-names = "usb";
-		interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
-		ranges;
-
-		dwc3@2690000 {
-			compatible = "synopsys,dwc3";
-			reg = <0x2690000 0x70000>;
-			interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
-			usb-phy = <&usb_phy>, <&usb_phy>;
-		};
-	};
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +6 -0
new file mode 100644
index 000000000000..14d2fe329b93
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/ti,keystone-dwc3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 16

Quoted 10 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +10 -0
+title: TI Keystone Soc USB Controller
+
+maintainers:
+  - Roger Quadros <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - const: "ti,keystone-dwc3"
+      - const: "ti,am654-dwc3"

Use enum rather than oneOf+const.

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 25

Quoted 9 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +9 -0
+
+  reg:
+    maxItems: 1
+    description: Address and length of the register set for the USB subsystem on
+      the SOC.
+
+  interrupts:
+    maxItems: 1
+    description: The irq number of this device that is used to interrupt the MPU.

No need for genericish descriptions when a single item.

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 29

Quoted 4 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +4 -0
+
+
+  clocks:
+    description: Clock ID for USB functional clock.

How many?

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 35

Quoted 6 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +6 -0
+
+  power-domains:
+    description: Should contain a phandle to a PM domain provider node
+      and an args specifier containing the USB device id
+      value. This property is as per the binding,
+      Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt

How many?

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 37

Quoted 2 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +2 -0
+
+  dwc3:

This doesn't work because there's a unit address. You need a pattern.

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 39

Quoted 2 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +2 -0
+    description: This is the node representing the DWC3 controller instance
+      Documentation/devicetree/bindings/usb/dwc3.txt

type: object

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 45

Quoted 6 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +6 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks

additionalProperties: false

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 54

Quoted 9 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +9 -0
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    usb: usb@2680000 {
+      compatible = "ti,keystone-dwc3";
+      #address-cells = <1>;
+      #size-cells = <1>;

These have to be documented.

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 59

Quoted 5 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +5 -0
+      reg = <0x2680000 0x10000>;
+      clocks = <&clkusb>;
+      clock-names = "usb";
+      interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
+      ranges;

This too.

Quoted 12 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +8 -0
+
+      dwc3@2690000 {
+        compatible = "synopsys,dwc3";
+        reg = <0x2690000 0x70000>;
+        interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
+        usb-phy = <&usb_phy>, <&usb_phy>;
+      };
+    };
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#3 lore raw

Re: [PATCH 1/3] dt-bindings: usb: convert keystone-usb.txt to YAML

Rob,

Thanks for the review. Since this patch was already picked up I will address the issues in a follow up patch.

cheers,
-roger

Quoted 177 lines · Rob Herring
Quoted 84 lines · Roger Quadros

Convert keystone-usb documentation to YAML format.

---
  .../devicetree/bindings/usb/keystone-usb.txt  | 56 ----------------
  .../bindings/usb/ti,keystone-dwc3.yaml        | 67 +++++++++++++++++++
  2 files changed, 67 insertions(+), 56 deletions(-)

delete mode 100644 Documentation/devicetree/bindings/usb/keystone-usb.txt create mode 100644 Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml

Documentation/devicetree/bindings/usb/keystone-usb.txt deleted +0 -56
deleted file mode 100644
index 77df82e36138..000000000000
@@ -1,56 +0,0 @@
-TI Keystone Soc USB Controller
-
-DWC3 GLUE
-
-Required properties:
- - compatible: should be
-		"ti,keystone-dwc3" for Keystone 2 SoCs
-		"ti,am654-dwc3" for AM654 SoC
- - #address-cells, #size-cells : should be '1' if the device has sub-nodes
-   with 'reg' property.
- - reg : Address and length of the register set for the USB subsystem on
-   the SOC.
- - interrupts : The irq number of this device that is used to interrupt the
-   MPU.
- - ranges: allows valid 1:1 translation between child's address space and
-   parent's address space.
-
-SoC-specific Required Properties:
-The following are mandatory properties for Keystone 2 66AK2HK, 66AK2L and 66AK2E
-SoCs only:
-
-- clocks:		Clock ID for USB functional clock.
-- clock-names:		Must be "usb".
-
-
-The following are mandatory properties for 66AK2G and AM654:
-
-- power-domains:	Should contain a phandle to a PM domain provider node
-			and an args specifier containing the USB device id
-			value. This property is as per the binding,
-			Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt
-
-Sub-nodes:
-The dwc3 core should be added as subnode to Keystone DWC3 glue.
-- dwc3 :
-   The binding details of dwc3 can be found in:
-   Documentation/devicetree/bindings/usb/dwc3.txt
-
-Example:
-	usb: usb@2680000 {
-		compatible = "ti,keystone-dwc3";
-		#address-cells = <1>;
-		#size-cells = <1>;
-		reg = <0x2680000 0x10000>;
-		clocks = <&clkusb>;
-		clock-names = "usb";
-		interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
-		ranges;
-
-		dwc3@2690000 {
-			compatible = "synopsys,dwc3";
-			reg = <0x2690000 0x70000>;
-			interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
-			usb-phy = <&usb_phy>, <&usb_phy>;
-		};
-	};
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +6 -0
new file mode 100644
index 000000000000..14d2fe329b93
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/ti,keystone-dwc3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 16

Quoted 10 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +10 -0
+title: TI Keystone Soc USB Controller
+
+maintainers:
+  - Roger Quadros <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - const: "ti,keystone-dwc3"
+      - const: "ti,am654-dwc3"

Use enum rather than oneOf+const.

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 25

Quoted 9 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +9 -0
+
+  reg:
+    maxItems: 1
+    description: Address and length of the register set for the USB subsystem on
+      the SOC.
+
+  interrupts:
+    maxItems: 1
+    description: The irq number of this device that is used to interrupt the MPU.

No need for genericish descriptions when a single item.

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 29

Quoted 4 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +4 -0
+
+
+  clocks:
+    description: Clock ID for USB functional clock.

How many?

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 35

Quoted 6 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +6 -0
+
+  power-domains:
+    description: Should contain a phandle to a PM domain provider node
+      and an args specifier containing the USB device id
+      value. This property is as per the binding,
+      Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt

How many?

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 37

Quoted 2 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +2 -0
+
+  dwc3:

This doesn't work because there's a unit address. You need a pattern.

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 39

Quoted 2 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +2 -0
+    description: This is the node representing the DWC3 controller instance
+      Documentation/devicetree/bindings/usb/dwc3.txt

type: object

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 45

Quoted 6 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +6 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks

additionalProperties: false

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 54

Quoted 9 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +9 -0
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    usb: usb@2680000 {
+      compatible = "ti,keystone-dwc3";
+      #address-cells = <1>;
+      #size-cells = <1>;

These have to be documented.

Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml line 59

Quoted 5 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +5 -0
+      reg = <0x2680000 0x10000>;
+      clocks = <&clkusb>;
+      clock-names = "usb";
+      interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
+      ranges;

This too.

Quoted 12 lines
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml new file +8 -0
+
+      dwc3@2690000 {
+        compatible = "synopsys,dwc3";
+        reg = <0x2690000 0x70000>;
+        interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
+        usb-phy = <&usb_phy>, <&usb_phy>;
+      };
+    };
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#4 lore raw

PATCH 2/3 dt-bindings: usb: ti,keystone-dwc3.yaml: Add USB3.0 PHY property

In reply to Roger Quadros

AM654 SoC requires USB3.0 PHY to be turned on before the USB controller. For this SoC, the 'phys' property is used to provide the USB3.0 reference.

---
 .../bindings/usb/ti,keystone-dwc3.yaml        | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
Documentation/devicetree/bindings/usb/ti,keystone-dwc3.yaml +21 -0
index 14d2fe329b93..51c0ab01b0bc 100644
@@ -34,6 +34,16 @@ properties:
       value. This property is as per the binding,
       Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt
 
+  phys:
+    description:
+      PHY specifier for the USB3.0 PHY. Some SoCs need the USB3.0 PHY
+      to be turned on before the controller.
+      Documentation/devicetree/bindings/phy/phy-bindings.txt
+
+  phy-names:
+    items:
+      - const: "usb3-phy"
+
   dwc3:
     description: This is the node representing the DWC3 controller instance
       Documentation/devicetree/bindings/usb/dwc3.txt
@@ -44,6 +54,17 @@ required:
   - interrupts
   - clocks
 
+if:
+  properties:
+    compatible:
+      contains:
+        const: "ti,am654-dwc3"
+
+then:
+  required:
+    - phys
+    - phy-names
+
 examples:
   - |
     #include <dt-bindings/interrupt-controller/arm-gic.h>
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#5 lore raw

PATCH 3/3 usb: dwc3: keystone: Turn on USB3 PHY before controller

In reply to Roger Quadros

The Local Power Sleep Controller (LPSC) dependency on AM65 requires SERDES0 to be powered on before USB.

We need to power up SERDES0 power domain and hold it on throughout the reset, init, power on sequence.

---
 drivers/usb/dwc3/dwc3-keystone.c | 47 +++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-keystone.c +46 -1
index 1e14a6f4884b..46d46f3507fc 100644
@@ -14,6 +14,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
 #include <linux/of_platform.h>
+#include <linux/phy/phy.h>
 #include <linux/pm_runtime.h>
 
 /* USBSS register offsets */
@@ -34,6 +35,7 @@
 struct dwc3_keystone {
 	struct device			*dev;
 	void __iomem			*usbss;
+	struct phy			*usb3_phy;
 };
 
 static inline u32 kdwc3_readl(void __iomem *base, u32 offset)
@@ -95,8 +97,44 @@ static int kdwc3_probe(struct platform_device *pdev)
 	if (IS_ERR(kdwc->usbss))
 		return PTR_ERR(kdwc->usbss);
 
-	pm_runtime_enable(kdwc->dev);
+	/* PSC dependency on AM65 needs SERDES0 to be powered before USB0 */
+	kdwc->usb3_phy = devm_phy_get(dev, "usb3-phy");
+	if (IS_ERR(kdwc->usb3_phy)) {
+		error = PTR_ERR(kdwc->usb3_phy);
+		if (error == -ENOSYS || error == -ENODEV) {
+			kdwc->usb3_phy = NULL;
+		} else {
+			if (error != -EPROBE_DEFER) {
+				dev_err(dev, "couldn't get usb3 phy: %d\n",
+					error);
+			}
+
+			return error;
+		}
+	}
+
+	phy_pm_runtime_get_sync(kdwc->usb3_phy);
+
+	error = phy_reset(kdwc->usb3_phy);
+	if (error < 0) {
+		dev_err(dev, "usb3 phy reset failed: %d\n", error);
+		return error;
+	}
+
+	error = phy_init(kdwc->usb3_phy);
+	if (error < 0) {
+		dev_err(dev, "usb3 phy init failed: %d\n", error);
+		return error;
+	}
 
+	error = phy_power_on(kdwc->usb3_phy);
+	if (error < 0) {
+		dev_err(dev, "usb3 phy power on failed: %d\n", error);
+		phy_exit(kdwc->usb3_phy);
+		return error;
+	}
+
+	pm_runtime_enable(kdwc->dev);
 	error = pm_runtime_get_sync(kdwc->dev);
 	if (error < 0) {
 		dev_err(kdwc->dev, "pm_runtime_get_sync failed, error %d\n",
@@ -138,6 +176,9 @@ static int kdwc3_probe(struct platform_device *pdev)
 err_irq:
 	pm_runtime_put_sync(kdwc->dev);
 	pm_runtime_disable(kdwc->dev);
+	phy_power_off(kdwc->usb3_phy);
+	phy_exit(kdwc->usb3_phy);
+	phy_pm_runtime_put_sync(kdwc->usb3_phy);
 
 	return error;
 }
@@ -163,6 +204,10 @@ static int kdwc3_remove(struct platform_device *pdev)
 	pm_runtime_put_sync(kdwc->dev);
 	pm_runtime_disable(kdwc->dev);
 
+	phy_power_off(kdwc->usb3_phy);
+	phy_exit(kdwc->usb3_phy);
+	phy_pm_runtime_put_sync(kdwc->usb3_phy);
+
 	platform_set_drvdata(pdev, NULL);
 
 	return 0;
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#6 lore raw

Re: [PATCH 3/3] usb: dwc3: keystone: Turn on USB3 PHY before controller

Quoted 32 lines · Roger Quadros

The Local Power Sleep Controller (LPSC) dependency on AM65 requires SERDES0 to be powered on before USB.

We need to power up SERDES0 power domain and hold it on throughout the reset, init, power on sequence.

---
 drivers/usb/dwc3/dwc3-keystone.c | 47 +++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-keystone.c +2 -0
index 1e14a6f4884b..46d46f3507fc 100644
@@ -14,6 +14,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
 #include <linux/of_platform.h>
+#include <linux/phy/phy.h>
 #include <linux/pm_runtime.h>
 
 /* USBSS register offsets */
@@ -34,6 +35,7 @@
 struct dwc3_keystone {
 	struct device			*dev;
 	void __iomem			*usbss;
+	struct phy			*usb3_phy;
 };
 
 static inline u32 kdwc3_readl(void __iomem *base, u32 offset)

drivers/usb/dwc3/dwc3-keystone.c static int kdwc3_probe(struct platform_device *pdev) · line 101

Quoted 6 lines
drivers/usb/dwc3/dwc3-keystone.c +2 -1
@@ -95,8 +97,44 @@ static int kdwc3_probe(struct platform_device *pdev)
 	if (IS_ERR(kdwc->usbss))
 		return PTR_ERR(kdwc->usbss);
 
-	pm_runtime_enable(kdwc->dev);
+	/* PSC dependency on AM65 needs SERDES0 to be powered before USB0 */
+	kdwc->usb3_phy = devm_phy_get(dev, "usb3-phy");

Use devm_phy_optional_get() instead?

Quoted 60 lines
drivers/usb/dwc3/dwc3-keystone.c +42 -0
+	if (IS_ERR(kdwc->usb3_phy)) {
+		error = PTR_ERR(kdwc->usb3_phy);
+		if (error == -ENOSYS || error == -ENODEV) {
+			kdwc->usb3_phy = NULL;
+		} else {
+			if (error != -EPROBE_DEFER) {
+				dev_err(dev, "couldn't get usb3 phy: %d\n",
+					error);
+			}
+
+			return error;
+		}
+	}
+
+	phy_pm_runtime_get_sync(kdwc->usb3_phy);
+
+	error = phy_reset(kdwc->usb3_phy);
+	if (error < 0) {
+		dev_err(dev, "usb3 phy reset failed: %d\n", error);
+		return error;
+	}
+
+	error = phy_init(kdwc->usb3_phy);
+	if (error < 0) {
+		dev_err(dev, "usb3 phy init failed: %d\n", error);
+		return error;
+	}
 
+	error = phy_power_on(kdwc->usb3_phy);
+	if (error < 0) {
+		dev_err(dev, "usb3 phy power on failed: %d\n", error);
+		phy_exit(kdwc->usb3_phy);
+		return error;
+	}
+
+	pm_runtime_enable(kdwc->dev);
 	error = pm_runtime_get_sync(kdwc->dev);
 	if (error < 0) {
 		dev_err(kdwc->dev, "pm_runtime_get_sync failed, error %d\n",
@@ -138,6 +176,9 @@ static int kdwc3_probe(struct platform_device *pdev)
 err_irq:
 	pm_runtime_put_sync(kdwc->dev);
 	pm_runtime_disable(kdwc->dev);
+	phy_power_off(kdwc->usb3_phy);
+	phy_exit(kdwc->usb3_phy);
+	phy_pm_runtime_put_sync(kdwc->usb3_phy);
 
 	return error;
 }
@@ -163,6 +204,10 @@ static int kdwc3_remove(struct platform_device *pdev)
 	pm_runtime_put_sync(kdwc->dev);
 	pm_runtime_disable(kdwc->dev);
 
+	phy_power_off(kdwc->usb3_phy);
+	phy_exit(kdwc->usb3_phy);
+	phy_pm_runtime_put_sync(kdwc->usb3_phy);
+
 	platform_set_drvdata(pdev, NULL);
 
 	return 0;
#7 lore raw

Re: [PATCH 3/3] usb: dwc3: keystone: Turn on USB3 PHY before controller

Quoted 36 lines · Chunfeng Yun
Quoted 35 lines · Roger Quadros

The Local Power Sleep Controller (LPSC) dependency on AM65 requires SERDES0 to be powered on before USB.

We need to power up SERDES0 power domain and hold it on throughout the reset, init, power on sequence.

---
  drivers/usb/dwc3/dwc3-keystone.c | 47 +++++++++++++++++++++++++++++++-
  1 file changed, 46 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-keystone.c +2 -0
index 1e14a6f4884b..46d46f3507fc 100644
@@ -14,6 +14,7 @@
  #include <linux/dma-mapping.h>
  #include <linux/io.h>
  #include <linux/of_platform.h>
+#include <linux/phy/phy.h>
  #include <linux/pm_runtime.h>
 
  /* USBSS register offsets */
@@ -34,6 +35,7 @@
  struct dwc3_keystone {
  	struct device			*dev;
  	void __iomem			*usbss;
+	struct phy			*usb3_phy;
  };
 
  static inline u32 kdwc3_readl(void __iomem *base, u32 offset)
@@ -95,8 +97,44 @@ static int kdwc3_probe(struct platform_device *pdev)
  	if (IS_ERR(kdwc->usbss))
  		return PTR_ERR(kdwc->usbss);
 
Quoted 4 lines

drivers/usb/dwc3/dwc3-keystone.c static int kdwc3_probe(struct platform_device *pdev) · line 101

Quoted 3 lines
drivers/usb/dwc3/dwc3-keystone.c +2 -1
-	pm_runtime_enable(kdwc->dev);
+	/* PSC dependency on AM65 needs SERDES0 to be powered before USB0 */
+	kdwc->usb3_phy = devm_phy_get(dev, "usb3-phy");

Use devm_phy_optional_get() instead?

Indeed, it seems better suited.

cheers,
-roger

Quoted 62 lines
Quoted 61 lines
drivers/usb/dwc3/dwc3-keystone.c +42 -0
+	if (IS_ERR(kdwc->usb3_phy)) {
+		error = PTR_ERR(kdwc->usb3_phy);
+		if (error == -ENOSYS || error == -ENODEV) {
+			kdwc->usb3_phy = NULL;
+		} else {
+			if (error != -EPROBE_DEFER) {
+				dev_err(dev, "couldn't get usb3 phy: %d\n",
+					error);
+			}
+
+			return error;
+		}
+	}
+
+	phy_pm_runtime_get_sync(kdwc->usb3_phy);
+
+	error = phy_reset(kdwc->usb3_phy);
+	if (error < 0) {
+		dev_err(dev, "usb3 phy reset failed: %d\n", error);
+		return error;
+	}
+
+	error = phy_init(kdwc->usb3_phy);
+	if (error < 0) {
+		dev_err(dev, "usb3 phy init failed: %d\n", error);
+		return error;
+	}
 
+	error = phy_power_on(kdwc->usb3_phy);
+	if (error < 0) {
+		dev_err(dev, "usb3 phy power on failed: %d\n", error);
+		phy_exit(kdwc->usb3_phy);
+		return error;
+	}
+
+	pm_runtime_enable(kdwc->dev);
  	error = pm_runtime_get_sync(kdwc->dev);
  	if (error < 0) {
  		dev_err(kdwc->dev, "pm_runtime_get_sync failed, error %d\n",
@@ -138,6 +176,9 @@ static int kdwc3_probe(struct platform_device *pdev)
  err_irq:
  	pm_runtime_put_sync(kdwc->dev);
  	pm_runtime_disable(kdwc->dev);
+	phy_power_off(kdwc->usb3_phy);
+	phy_exit(kdwc->usb3_phy);
+	phy_pm_runtime_put_sync(kdwc->usb3_phy);
 
  	return error;
  }
@@ -163,6 +204,10 @@ static int kdwc3_remove(struct platform_device *pdev)
  	pm_runtime_put_sync(kdwc->dev);
  	pm_runtime_disable(kdwc->dev);
 
+	phy_power_off(kdwc->usb3_phy);
+	phy_exit(kdwc->usb3_phy);
+	phy_pm_runtime_put_sync(kdwc->usb3_phy);
+
  	platform_set_drvdata(pdev, NULL);
 
  	return 0;
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#8 lore raw

Re: [PATCH 3/3] usb: dwc3: keystone: Turn on USB3 PHY before controller

Quoted 37 lines · Roger Quadros
Quoted 36 lines · Chunfeng Yun
Quoted 35 lines · Roger Quadros

The Local Power Sleep Controller (LPSC) dependency on AM65 requires SERDES0 to be powered on before USB.

We need to power up SERDES0 power domain and hold it on throughout the reset, init, power on sequence.

---
  drivers/usb/dwc3/dwc3-keystone.c | 47 +++++++++++++++++++++++++++++++-
  1 file changed, 46 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-keystone.c +2 -0
index 1e14a6f4884b..46d46f3507fc 100644
@@ -14,6 +14,7 @@
  #include <linux/dma-mapping.h>
  #include <linux/io.h>
  #include <linux/of_platform.h>
+#include <linux/phy/phy.h>
  #include <linux/pm_runtime.h>
 
  /* USBSS register offsets */
@@ -34,6 +35,7 @@
  struct dwc3_keystone {
  	struct device			*dev;
  	void __iomem			*usbss;
+	struct phy			*usb3_phy;
  };
 
  static inline u32 kdwc3_readl(void __iomem *base, u32 offset)
@@ -95,8 +97,44 @@ static int kdwc3_probe(struct platform_device *pdev)
  	if (IS_ERR(kdwc->usbss))
  		return PTR_ERR(kdwc->usbss);
 
Quoted 6 lines
Quoted 4 lines

drivers/usb/dwc3/dwc3-keystone.c static int kdwc3_probe(struct platform_device *pdev) · line 101

Quoted 3 lines
drivers/usb/dwc3/dwc3-keystone.c +2 -1
-	pm_runtime_enable(kdwc->dev);
+	/* PSC dependency on AM65 needs SERDES0 to be powered before USB0 */
+	kdwc->usb3_phy = devm_phy_get(dev, "usb3-phy");

Use devm_phy_optional_get() instead?

Indeed, it seems better suited.

patches 1 and 2 are in testing/next

Signature · 1 line
balbi
#9 lore raw

Re: [PATCH 3/3] usb: dwc3: keystone: Turn on USB3 PHY before controller

Felipe,

Quoted 39 lines · Felipe Balbi
Quoted 37 lines · Roger Quadros
Quoted 36 lines · Chunfeng Yun
Quoted 35 lines · Roger Quadros

The Local Power Sleep Controller (LPSC) dependency on AM65 requires SERDES0 to be powered on before USB.

We need to power up SERDES0 power domain and hold it on throughout the reset, init, power on sequence.

---
   drivers/usb/dwc3/dwc3-keystone.c | 47 +++++++++++++++++++++++++++++++-
   1 file changed, 46 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-keystone.c +2 -0
index 1e14a6f4884b..46d46f3507fc 100644
@@ -14,6 +14,7 @@
   #include <linux/dma-mapping.h>
   #include <linux/io.h>
   #include <linux/of_platform.h>
+#include <linux/phy/phy.h>
   #include <linux/pm_runtime.h>
 
   /* USBSS register offsets */
@@ -34,6 +35,7 @@
   struct dwc3_keystone {
   	struct device			*dev;
   	void __iomem			*usbss;
+	struct phy			*usb3_phy;
   };
 
   static inline u32 kdwc3_readl(void __iomem *base, u32 offset)
@@ -95,8 +97,44 @@ static int kdwc3_probe(struct platform_device *pdev)
   	if (IS_ERR(kdwc->usbss))
   		return PTR_ERR(kdwc->usbss);
 
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

drivers/usb/dwc3/dwc3-keystone.c static int kdwc3_probe(struct platform_device *pdev) · line 101

Quoted 3 lines
drivers/usb/dwc3/dwc3-keystone.c +2 -1
-	pm_runtime_enable(kdwc->dev);
+	/* PSC dependency on AM65 needs SERDES0 to be powered before USB0 */
+	kdwc->usb3_phy = devm_phy_get(dev, "usb3-phy");

Use devm_phy_optional_get() instead?

Indeed, it seems better suited.

patches 1 and 2 are in testing/next

Could you please drop them as I need to make changes to make the PHY optional. I will send v2 of entire series.

cheers,
-roger

Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#10 lore raw

Re: [PATCH 3/3] usb: dwc3: keystone: Turn on USB3 PHY before controller

Quoted 44 lines · Roger Quadros

Felipe,

Quoted 41 lines · Felipe Balbi
Quoted 39 lines · Roger Quadros
Quoted 37 lines · Chunfeng Yun
Quoted 30 lines · Roger Quadros

The Local Power Sleep Controller (LPSC) dependency on AM65 requires SERDES0 to be powered on before USB.

We need to power up SERDES0 power domain and hold it on throughout the reset, init, power on sequence.

---
   drivers/usb/dwc3/dwc3-keystone.c | 47 +++++++++++++++++++++++++++++++-

   1 file changed, 46 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-keystone.c +2 -0
index 1e14a6f4884b..46d46f3507fc 100644
@@ -14,6 +14,7 @@
    #include <linux/dma-mapping.h>
    #include <linux/io.h>
    #include <linux/of_platform.h>
+#include <linux/phy/phy.h>
    #include <linux/pm_runtime.h>
    /* USBSS register offsets */
@@ -34,6 +35,7 @@
    struct dwc3_keystone {
        struct device            *dev;
        void __iomem            *usbss;
+    struct phy            *usb3_phy;
    };
    static inline u32 kdwc3_readl(void __iomem *base, u32 offset)

drivers/usb/dwc3/dwc3-keystone.c static int kdwc3_probe(struct platform_device *pdev) · line 100

Quoted 5 lines
drivers/usb/dwc3/dwc3-keystone.c +2 -1
@@ -95,8 +97,44 @@ static int kdwc3_probe(struct platform_device *pdev)
        if (IS_ERR(kdwc->usbss))
            return PTR_ERR(kdwc->usbss);
-    pm_runtime_enable(kdwc->dev);
+    /* PSC dependency on AM65 needs SERDES0 to be powered before USB0 */
+    kdwc->usb3_phy = devm_phy_get(dev, "usb3-phy");

Use devm_phy_optional_get() instead?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Indeed, it seems better suited.

patches 1 and 2 are in testing/next

Could you please drop them as I need to make changes to make the PHY optional. I will send v2 of entire series.

Actually only patch 2 and 3 need to be revised. Patch 1 is fine.

cheers,
-roger

Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki