Skip to contentSkip to conversation

usb: cdns,usb3: Convert DT binding to YAML

PATCH In review Roger Quadros 3 participants 7 messages Sep 15, 2020 – Sep 24, 2020

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

v3 cover usb: cdns,usb3: Convert DT binding to YAML

Hi Felipe,

This series converts DT binding to YAML schema. Then adds a new property to enable workaround for USB2.0 PHY Rx compliance issues.

cheers,
-roger

Changelog:
v3:
- removed oneOf from compatible. Added items in phy-names.

v2:
- updated commit log to better describe why DT property is required for the quirk.

Pawel Laszczak (1):
usb: cdns3: Enable workaround for USB2.0 PHY Rx compliance test PHY
lockup

Roger Quadros (2):
dt-bindings: usb: Convert cdns-usb3.txt to YAML schema
dt-bindings: usb: cdns,usb3: Add cdns,phyrst-a-enable property

 .../devicetree/bindings/usb/cdns,usb3.yaml    | 96 +++++++++++++++++++
 .../devicetree/bindings/usb/cdns-usb3.txt     | 45 ---------
 drivers/usb/cdns3/core.c                      |  2 +
 drivers/usb/cdns3/core.h                      |  1 +
 drivers/usb/cdns3/drd.c                       | 12 +++
 drivers/usb/cdns3/drd.h                       |  5 +-
 6 files changed, 115 insertions(+), 46 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/cdns,usb3.yaml
 delete mode 100644 Documentation/devicetree/bindings/usb/cdns-usb3.txt
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#1 lore raw

PATCH v3 1/3 dt-bindings: usb: Convert cdns-usb3.txt to YAML schema

Converts cdns-usb3.txt to YAML schema cdns,usb3.yaml

---
 .../devicetree/bindings/usb/cdns,usb3.yaml    | 92 +++++++++++++++++++
 .../devicetree/bindings/usb/cdns-usb3.txt     | 45 ---------
 2 files changed, 92 insertions(+), 45 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/cdns,usb3.yaml
 delete mode 100644 Documentation/devicetree/bindings/usb/cdns-usb3.txt
Documentation/devicetree/bindings/usb/cdns,usb3.yaml new file +92 -0
new file mode 100644
index 000000000000..9b14c8443d39
@@ -0,0 +1,92 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/cdns,usb3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cadence USBSS-DRD controller bindings
+
+maintainers:
+  - Pawel Laszczak <[email protected]>
+
+properties:
+  compatible:
+    const: cdns,usb3
+
+  reg:
+    items:
+      - description: OTG controller registers
+      - description: XHCI Host controller registers
+      - description: DEVICE controller registers
+
+  reg-names:
+    items:
+      - const: otg
+      - const: xhci
+      - const: dev
+
+  interrupts:
+    items:
+      - description: OTG/DRD controller interrupt
+      - description: XHCI host controller interrupt
+      - description: Device controller interrupt
+
+  interrupt-names:
+    items:
+      - const: host
+      - const: peripheral
+      - const: otg
+
+  dr_mode:
+    enum: [host, otg, peripheral]
+
+  maximum-speed:
+    enum: [super-speed, high-speed, full-speed]
+
+  phys:
+   minItems: 1
+   maxItems: 2
+
+  phy-names:
+    minItems: 1
+    maxItems: 2
+    items:
+      anyOf:
+        - const: cdns3,usb2-phy
+        - const: cdns3,usb3-phy
+
+  cdns,on-chip-buff-size:
+    description:
+      size of memory intended as internal memory for endpoints
+      buffers expressed in KB
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    bus {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        usb@6000000 {
+            compatible = "cdns,usb3";
+            reg = <0x00 0x6000000 0x00 0x10000>,
+                  <0x00 0x6010000 0x00 0x10000>,
+                  <0x00 0x6020000 0x00 0x10000>;
+            reg-names = "otg", "xhci", "dev";
+            interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>,
+                         <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>,
+                         <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
+            interrupt-names = "host", "peripheral", "otg";
+            maximum-speed = "super-speed";
+            dr_mode = "otg";
+        };
+    };
Documentation/devicetree/bindings/usb/cdns-usb3.txt deleted +0 -45

45 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 Reviewed-by on v3 1/3
#2 lore raw

Re: [PATCH v3 1/3] dt-bindings: usb: Convert cdns-usb3.txt to YAML schema

Quoted 10 lines · Roger Quadros

Converts cdns-usb3.txt to YAML schema cdns,usb3.yaml

---
 .../devicetree/bindings/usb/cdns,usb3.yaml    | 92 +++++++++++++++++++
 .../devicetree/bindings/usb/cdns-usb3.txt     | 45 ---------
 2 files changed, 92 insertions(+), 45 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/cdns,usb3.yaml
 delete mode 100644 Documentation/devicetree/bindings/usb/cdns-usb3.txt
#3 lore raw

PATCH v3 2/3 dt-bindings: usb: cdns,usb3: Add cdns,phyrst-a-enable property

In reply to Roger Quadros

Controller version 0x0002450D has USB2 PHY RX sensitivity issues that needs to be worked around by enabling phyrst-a-enable bit in PHYRST_CFG register.

There is no way to know controller version before device controller is started and the workaround needs to be applied for both host and device modes, so we add this DT property.

---
 Documentation/devicetree/bindings/usb/cdns,usb3.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/usb/cdns,usb3.yaml +4 -0
index 9b14c8443d39..ac20b98e9910 100644
@@ -61,6 +61,10 @@ properties:
       buffers expressed in KB
     $ref: /schemas/types.yaml#/definitions/uint32
 
+  cdns,phyrst-a-enable:
+    description: Enable resetting of PHY if Rx fail is detected
+    type: boolean
+
 required:
   - compatible
   - reg
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#4 lore raw

Re: [PATCH v3 2/3] dt-bindings: usb: cdns,usb3: Add cdns,phyrst-a-enable property

Hello!

Quoted 19 lines · Roger Quadros

Controller version 0x0002450D has USB2 PHY RX sensitivity issues that needs to be worked around by enabling phyrst-a-enable bit in PHYRST_CFG register.

There is no way to know controller version before device controller is started and the workaround needs to be applied for both host and device modes, so we add this DT property.

---
 Documentation/devicetree/bindings/usb/cdns,usb3.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/usb/cdns,usb3.yaml +0 -0
index 9b14c8443d39..ac20b98e9910 100644

Documentation/devicetree/bindings/usb/cdns,usb3.yaml properties: · line 65

Quoted 5 lines
Documentation/devicetree/bindings/usb/cdns,usb3.yaml +2 -0
@@ -61,6 +61,10 @@ properties:
       buffers expressed in KB
     $ref: /schemas/types.yaml#/definitions/uint32
 
+  cdns,phyrst-a-enable:
+    description: Enable resetting of PHY if Rx fail is detected

Failure?

[...]

MBR, Sergei

#5 lore raw

Re: [PATCH v3 2/3] dt-bindings: usb: cdns,usb3: Add cdns,phyrst-a-enable property

Hi Sergei,

Quoted 26 lines · Sergei Shtylyov

Hello!

Quoted 22 lines · Roger Quadros

Controller version 0x0002450D has USB2 PHY RX sensitivity issues that needs to be worked around by enabling phyrst-a-enable bit in PHYRST_CFG register.

There is no way to know controller version before device controller is started and the workaround needs to be applied for both host and device modes, so we add this DT property.

---
  Documentation/devicetree/bindings/usb/cdns,usb3.yaml | 4 ++++
  1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/usb/cdns,usb3.yaml +0 -0
index 9b14c8443d39..ac20b98e9910 100644
@@ -61,6 +61,10 @@ properties:
        buffers expressed in KB
      $ref: /schemas/types.yaml#/definitions/uint32
 
Quoted 4 lines

Documentation/devicetree/bindings/usb/cdns,usb3.yaml properties: · line 65

Quoted 2 lines
Documentation/devicetree/bindings/usb/cdns,usb3.yaml +2 -0
+  cdns,phyrst-a-enable:
+    description: Enable resetting of PHY if Rx fail is detected

Failure?

Actually the IP manual says "Reset PHY if Rx fail is detected".

So let's leave it like that.

Quoted 5 lines

[...]

MBR, Sergei

cheers,
-roger

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

PATCH v3 3/3 usb: cdns3: Enable workaround for USB2.0 PHY Rx compliance test PHY lockup

In reply to Roger Quadros

From: Pawel Laszczak <[email protected]>

USB2.0 PHY hangs in Rx Compliance test when the incoming packet amplitude is varied below and above the Squelch Level of Receiver during the active packet multiple times.

Version 1 of the controller allows PHY to be reset when RX fail condition is detected to work around the above issue. This feature is disabled by default and needs to be enabled using a bit from the newly added PHYRST_CFG register. This patch enables the workaround.

There is no way to know controller version before device controller is started and the workaround needs to be applied for both host and device modes, so we rely on a DT property do decide when to apply the workaround.

---
 drivers/usb/cdns3/core.c |  2 ++
 drivers/usb/cdns3/core.h |  1 +
 drivers/usb/cdns3/drd.c  | 12 ++++++++++++
 drivers/usb/cdns3/drd.h  |  5 ++++-
 4 files changed, 19 insertions(+), 1 deletion(-)
drivers/usb/cdns3/core.c +2 -0
index 5c1586ec7824..34b36487682b 100644
@@ -443,6 +443,8 @@ static int cdns3_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
+	cdns->phyrst_a_enable = device_property_read_bool(dev, "cdns,phyrst-a-enable");
+
 	cdns->otg_res = *res;
 
 	mutex_init(&cdns->mutex);
drivers/usb/cdns3/core.h +1 -0
index 1ad1f1fe61e9..24cf0f1b5726 100644
@@ -76,6 +76,7 @@ struct cdns3 {
 #define CDNS3_CONTROLLER_V0	0
 #define CDNS3_CONTROLLER_V1	1
 	u32				version;
+	bool				phyrst_a_enable;
 
 	int				otg_irq;
 	int				dev_irq;
drivers/usb/cdns3/drd.c +12 -0
index 6234bcd6158a..b74803e9703d 100644
@@ -42,6 +42,18 @@ int cdns3_set_mode(struct cdns3 *cdns, enum usb_dr_mode mode)
 			reg = readl(&cdns->otg_v1_regs->override);
 			reg |= OVERRIDE_IDPULLUP;
 			writel(reg, &cdns->otg_v1_regs->override);
+
+			/*
+			 * Enable work around feature built into the
+			 * controller to address issue with RX Sensitivity
+			 * est (EL_17) for USB2 PHY. The issue only occures
+			 * for 0x0002450D controller version.
+			 */
+			if (cdns->phyrst_a_enable) {
+				reg = readl(&cdns->otg_v1_regs->phyrst_cfg);
+				reg |= PHYRST_CFG_PHYRST_A_ENABLE;
+				writel(reg, &cdns->otg_v1_regs->phyrst_cfg);
+			}
 		} else {
 			reg = readl(&cdns->otg_v0_regs->ctrl1);
 			reg |= OVERRIDE_IDPULLUP_V0;
drivers/usb/cdns3/drd.h +4 -1
index 7e7cf7fa2dd3..f1ccae285a16 100644
@@ -31,7 +31,7 @@ struct cdns3_otg_regs {
 	__le32 simulate;
 	__le32 override;
 	__le32 susp_ctrl;
-	__le32 reserved4;
+	__le32 phyrst_cfg;
 	__le32 anasts;
 	__le32 adp_ramp_time;
 	__le32 ctrl1;
@@ -153,6 +153,9 @@ struct cdns3_otg_common_regs {
 /* Only for CDNS3_CONTROLLER_V0 version */
 #define OVERRIDE_IDPULLUP_V0		BIT(24)
 
+/* PHYRST_CFG - bitmasks */
+#define PHYRST_CFG_PHYRST_A_ENABLE     BIT(0)
+
 #define CDNS3_ID_PERIPHERAL		1
 #define CDNS3_ID_HOST			0
 
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki