Skip to contentSkip to conversation

Add Cypress CYPD6129 UCSI support for monza SOM USB0 DRD

PATCH In review Akash Kumar 6 participants 17 messages May 20

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

cover Add Cypress CYPD6129 UCSI support for monza SOM USB0 DRD

Hi all,

This series adds support for the Cypress/Infineon CYPD6129 UCSI controller, used on the monza SOM platform for USB0 dual-role operation.

The series consists of:
1. A dt-binding update to document the CYPD6129 compatible string for the existing CCGx binding.
2. A driver update to bind the UCSI CCG driver to CYPD6129.
3. A board DTS update to enable USB0 DRD mode on monza SOM using the

     CYPD6129 controller over I2C12.

This enables the USB-C controller, connector, interrupt routing, and the USB2/USB3 endpoints required for DRD operation on the platform.

Akash Kumar (3):
dt-bindings: usb: typec: Add Cypress CYPD6129 UCSI controller compatible
usb: ucsi: ccg: Add support for CYPD6129 (CCG6)
arm64: dts: qcom: monaco-monza-som: Enable USB0 DRD mode

 .../bindings/usb/cypress,cypd4226.yaml        | 73 ++++++++++++++-----
 .../arm64/boot/dts/qcom/monaco-monza-som.dtsi | 57 +++++++++++++++
 drivers/usb/typec/ucsi/ucsi_ccg.c             |  1 +
 3 files changed, 113 insertions(+), 18 deletions(-)
Signature · 4 lines
2.43.0

Thanks,
Akash Kumar
#1 lore raw

PATCH 1/3 dt-bindings: usb: typec: Add Cypress CYPD6129 UCSI controller compatible

Document the "cypress,cypd6129" compatible string for the Cypress/Infineon EZ-PD CCGx UCSI controller.

The CYPD6129 is compatible with the existing CCGx binding, so allow it as a valid compatible and permit the existing "cypress,cypd4226" fallback where appropriate.

---
 .../bindings/usb/cypress,cypd4226.yaml        | 73 ++++++++++++++-----
 1 file changed, 55 insertions(+), 18 deletions(-)
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +55 -18
index 0620d82508c1..90769c43ac95 100644
@@ -15,7 +15,13 @@ description:
 
 properties:
   compatible:
-    const: cypress,cypd4226
+    oneOf:
+      - enum:
+          - cypress,cypd6129
+          - cypress,cypd4226
+      - items:
+          - const: cypress,cypd6129
+          - const: cypress,cypd4226
 
   '#address-cells':
     const: 1
@@ -63,10 +69,42 @@ examples:
   - |
     #include <dt-bindings/interrupt-controller/arm-gic.h>
     i2c {
-      #address-cells = <1>;
-      #size-cells = <0>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        #interrupt-cells = <2>;
+
+        typec@8 {
+            compatible = "cypress,cypd6129";
+            reg = <0x08>;
+            interrupt-parent = <&node>;
+            interrupts = <GPIO IRQ_TYPE_LEVEL_LOW>;
+            firmware-name = "ccg_primary.cyacd2";
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            connector@0 {
+                compatible = "usb-c-connector";
+                reg = <0>;
+                label = "USB-C";
+                data-role = "dual";
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
 
-      typec@8 {
+                    port@0 {
+                        reg = <0>;
+                        endpoint {
+                            remote-endpoint = <&usb_role_switch0>;
+                        };
+                    };
+                };
+            };
+        };
+    };
+
+  - |
+    typec@8 {
         compatible = "cypress,cypd4226";
         reg = <0x08>;
         interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
@@ -74,20 +112,19 @@ examples:
         #address-cells = <1>;
         #size-cells = <0>;
         connector@0 {
-          compatible = "usb-c-connector";
-          reg = <0>;
-          label = "USB-C";
-          data-role = "dual";
-          ports {
-            #address-cells = <1>;
-            #size-cells = <0>;
-            port@0 {
-              reg = <0>;
-              endpoint {
-                remote-endpoint = <&usb_role_switch0>;
-              };
+            compatible = "usb-c-connector";
+            reg = <0>;
+            label = "USB-C";
+            data-role = "dual";
+            ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+                port@0 {
+                    reg = <0>;
+                    endpoint {
+                        remote-endpoint = <&usb_role_switch0>;
+                    };
+                };
             };
-          };
         };
-      };
     };
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/3] dt-bindings: usb: typec: Add Cypress CYPD6129 UCSI controller compatible

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Low] The new device tree example assigns an unauthorized value to the 'firmware-name' property, which…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Low] The new device tree example assigns an unauthorized value to the 'firmware-name' property, which violates the schema constraints.
- [Low] The DT example fails to compile due to an undefined macro 'GPIO' and an undefined phandle label '&node'.
- [Low] The second device tree example is missing its parent bus node, resulting in an invalid 'reg' property length and incorrect node context. --

commit 911d8bba6bd4939c0495f237ef6ddd1854af3dd2
Author: Akash Kumar <[email protected]>

dt-bindings: usb: typec: Add Cypress CYPD6129 UCSI controller compatible

This commit documents the "cypress,cypd6129" compatible string for the Cypress/Infineon EZ-PD CCGx UCSI controller. It allows the new compatible and permits the existing "cypress,cypd4226" fallback.

Quoted 3 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +0 -0

[ ... ]

Quoted 5 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +0 -1
@@ -63,10 +69,42 @@ examples:
   - |
     #include <dt-bindings/interrupt-controller/arm-gic.h>
     i2c {
-      #address-cells = <1>;

Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml examples: · line 80

Quoted 10 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +9 -1
-      #size-cells = <0>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        #interrupt-cells = <2>;
+
+        typec@8 {
+            compatible = "cypress,cypd6129";
+            reg = <0x08>;
+            interrupt-parent = <&node>;
+            interrupts = <GPIO IRQ_TYPE_LEVEL_LOW>;

[Severity: Low]
Will this example compile successfully? The label "node" is not defined anywhere in the example, and "GPIO" is not a defined C preprocessor macro. This typically causes the device tree compiler to fail with syntax and undefined reference errors during dt_binding_check.

Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml examples: · line 81

Quoted 1 line
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +1 -0
+            firmware-name = "ccg_primary.cyacd2";

[Severity: Low]
Will this cause dt_binding_check to fail schema validation? The schema restricts the firmware-name property to an enum of specific values like "nvidia,gpu" and "nvidia,jetson-agx-xavier". Using "ccg_primary.cyacd2" appears to violate this constraint.

Quoted 2 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +2 -0
+            #address-cells = <1>;
+            #size-cells = <0>;

[ ... ]

Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml examples: · line 107

Quoted 4 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +4 -0
+    };
+
+  - |
+    typec@8 {

[Severity: Low]
Does this second example lack a valid parent bus wrapper?

The original typec@8 example was wrapped inside an i2c node that provided the required #address-cells and #size-cells context. Without the parent node, the reg = <0x08> property will trigger a missing cells error during dt_binding_check.

Quoted 3 lines
         compatible = "cypress,cypd4226";
         reg = <0x08>;
         interrupts = <2 IRQ_TYPE_LEVEL_LOW>;

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

Re: [PATCH 1/3] dt-bindings: usb: typec: Add Cypress CYPD6129 UCSI controller compatible

In reply to Akash Kumar
Quoted 33 lines · Akash Kumar

Document the "cypress,cypd6129" compatible string for the Cypress/Infineon EZ-PD CCGx UCSI controller.

The CYPD6129 is compatible with the existing CCGx binding, so allow it as a valid compatible and permit the existing "cypress,cypd4226" fallback where appropriate.

---
 .../bindings/usb/cypress,cypd4226.yaml        | 73 ++++++++++++++-----
 1 file changed, 55 insertions(+), 18 deletions(-)
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +7 -1
index 0620d82508c1..90769c43ac95 100644
@@ -15,7 +15,13 @@ description:
 
 properties:
   compatible:
-    const: cypress,cypd4226
+    oneOf:
+      - enum:
+          - cypress,cypd6129
+          - cypress,cypd4226
+      - items:
+          - const: cypress,cypd6129
+          - const: cypress,cypd4226
 
   '#address-cells':
     const: 1
@@ -63,10 +69,42 @@ examples:
   - |

Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml examples: · line 77

Quoted 10 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +6 -2
     #include <dt-bindings/interrupt-controller/arm-gic.h>
     i2c {
-      #address-cells = <1>;
-      #size-cells = <0>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        #interrupt-cells = <2>;
+
+        typec@8 {
+            compatible = "cypress,cypd6129";

What does this example bring here?

Quoted 21 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +19 -1
+            reg = <0x08>;
+            interrupt-parent = <&node>;
+            interrupts = <GPIO IRQ_TYPE_LEVEL_LOW>;
+            firmware-name = "ccg_primary.cyacd2";
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            connector@0 {
+                compatible = "usb-c-connector";
+                reg = <0>;
+                label = "USB-C";
+                data-role = "dual";
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
 
-      typec@8 {
+                    port@0 {
+                        reg = <0>;
+                        endpoint {

Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml examples: · line 107

Quoted 10 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +10 -0
+                            remote-endpoint = <&usb_role_switch0>;
+                        };
+                    };
+                };
+            };
+        };
+    };
+
+  - |
+    typec@8 {

Ugh, definitely not. The default here is #size-cells = <1>, which is not suitable for I2C devices.

Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml examples: · line 77

Quoted 8 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +0 -1
         compatible = "cypress,cypd4226";
         reg = <0x08>;
         interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
@@ -74,20 +112,19 @@ examples:
         #address-cells = <1>;
         #size-cells = <0>;
         connector@0 {
-          compatible = "usb-c-connector";

Don't mix cleanups (whitespace changes) and sensible changes.

Quoted 32 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +13 -13
-          reg = <0>;
-          label = "USB-C";
-          data-role = "dual";
-          ports {
-            #address-cells = <1>;
-            #size-cells = <0>;
-            port@0 {
-              reg = <0>;
-              endpoint {
-                remote-endpoint = <&usb_role_switch0>;
-              };
+            compatible = "usb-c-connector";
+            reg = <0>;
+            label = "USB-C";
+            data-role = "dual";
+            ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+                port@0 {
+                    reg = <0>;
+                    endpoint {
+                        remote-endpoint = <&usb_role_switch0>;
+                    };
+                };
             };
-          };
         };
-      };
     };
Signature · 1 line
2.43.0
Signature · 2 lines
With best wishes
Dmitry
#4 lore raw

Re: [PATCH 1/3] dt-bindings: usb: typec: Add Cypress CYPD6129 UCSI controller compatible

In reply to Akash Kumar
Quoted 18 lines · Akash Kumar

Document the "cypress,cypd6129" compatible string for the Cypress/Infineon EZ-PD CCGx UCSI controller.

The CYPD6129 is compatible with the existing CCGx binding, so allow it as a valid compatible and permit the existing "cypress,cypd4226" fallback where appropriate.

---
 .../bindings/usb/cypress,cypd4226.yaml        | 73 ++++++++++++++-----
 1 file changed, 55 insertions(+), 18 deletions(-)
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +0 -0
index 0620d82508c1..90769c43ac95 100644
@@ -15,7 +15,13 @@ description:
 

Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml description: · line 24

Quoted 10 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +7 -1
 properties:
   compatible:
-    const: cypress,cypd4226
+    oneOf:
+      - enum:
+          - cypress,cypd6129
+          - cypress,cypd4226
+      - items:
+          - const: cypress,cypd6129
+          - const: cypress,cypd4226

Missied it. So, is it a separate value or is it compatible, always having cypress,cypd4226 as a fallback?

Quoted 3 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +0 -0
   '#address-cells':
     const: 1
Signature · 2 lines
With best wishes
Dmitry
#5 lore raw

Re: [PATCH 1/3] dt-bindings: usb: typec: Add Cypress CYPD6129 UCSI controller compatible

In reply to Akash Kumar
Quoted 4 lines · Akash Kumar

Document the "cypress,cypd6129" compatible string for the Cypress/Infineon EZ-PD CCGx UCSI controller.

The CYPD6129 is compatible with the existing CCGx binding, so allow it as a

Device can be compatible with a device, not with a binding.

And explain WHY it is compatible.

Quoted 14 lines

valid compatible and permit the existing "cypress,cypd4226" fallback where appropriate.

---
 .../bindings/usb/cypress,cypd4226.yaml        | 73 ++++++++++++++-----
 1 file changed, 55 insertions(+), 18 deletions(-)
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +0 -0
index 0620d82508c1..90769c43ac95 100644
@@ -15,7 +15,13 @@ description:
 

Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml description: · line 24

Quoted 10 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +7 -1
 properties:
   compatible:
-    const: cypress,cypd4226
+    oneOf:
+      - enum:
+          - cypress,cypd6129
+          - cypress,cypd4226
+      - items:
+          - const: cypress,cypd6129
+          - const: cypress,cypd4226

Hm? This makes no sense.

Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml examples: · line 67

Quoted 9 lines
Documentation/devicetree/bindings/usb/cypress,cypd4226.yaml +0 -2
   '#address-cells':
     const: 1
@@ -63,10 +69,42 @@ examples:
   - |
     #include <dt-bindings/interrupt-controller/arm-gic.h>
     i2c {
-      #address-cells = <1>;
-      #size-cells = <0>;

What is happening here?

You are making random changes to the binding. No, don't.

Best regards,
Krzysztof

#6 lore raw

Re: [PATCH 1/3] dt-bindings: usb: typec: Add Cypress CYPD6129 UCSI controller compatible

In reply to Akash Kumar
Quoted 12 lines · Akash Kumar

Document the "cypress,cypd6129" compatible string for the Cypress/Infineon EZ-PD CCGx UCSI controller.

The CYPD6129 is compatible with the existing CCGx binding, so allow it as a valid compatible and permit the existing "cypress,cypd4226" fallback where appropriate.

---
 .../bindings/usb/cypress,cypd4226.yaml        | 73 ++++++++++++++-----
 1 file changed, 55 insertions(+), 18 deletions(-)

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Lexical error: Documentation/devicetree/bindings/usb/cypress,cypd4226.example.dts:34.31-35 Unexpected 'GPIO' FATAL ERROR: Syntax error parsing input tree
make[2]: *** [scripts/Makefile.dtbs:140: Documentation/devicetree/bindings/usb/cypress,cypd4226.example.dtb] Error 1 make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1644: dt_binding_check] Error 2
make: *** [Makefile:248: __sub-make] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.kernel.org/project/devicetree/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#7 lore raw

PATCH 2/3 arm64: dts: qcom: monaco-monza-som: Enable USB0 DRD mode

In reply to Akash Kumar

Enable USB0 dual-role mode on monza SOM using the Cypress CYPD6129 UCSI controller.

Switch the controller node to I2C12, configure the required pinctrl and interrupt settings, and wire the USB2/USB3 endpoints for the USB-C connector.

---
 .../arm64/boot/dts/qcom/monaco-monza-som.dtsi | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +57 -0
index 9b5ed55939b8..8e3af6018dfc 100644
@@ -194,6 +194,52 @@ &iris {
 	status = "okay";
 };
 
+&i2c12 {
+	pinctrl-0 = <&qup_i2c12_data_clk>, <&usb0_intr_state>;
+	pinctrl-names = "default";
+	status = "okay";
+
+	typec@8 {
+		compatible = "cypress,cypd6129";
+		reg = <0x08>;
+		interrupt-parent = <&tlmm>;
+		interrupts = < 3 IRQ_TYPE_LEVEL_LOW>;
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";
+
+		ccg_typec_con0: connector@0 {
+			compatible = "usb-c-connector";
+			reg = <0>;
+			label = "USB-C";
+			data-role = "dual";
+			power-role = "dual";
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port@0 {
+					reg = <0>;
+
+					ucsi_ccg_hs: endpoint {
+						remote-endpoint = <&usb_1_dwc3_hs>;
+					};
+				};
+
+				port@1 {
+					reg = <1>;
+
+					ucsi_ccg_ss: endpoint {
+						remote-endpoint = <&usb_1_dwc3_ss>;
+					};
+				};
+			};
+		};
+	};
+};
+
 /* PCIe0 Gen4 x2 */
 &pcie0 {
 	iommu-map = <0x0 &pcie_smmu 0x0000 0x1>,
@@ -227,6 +273,11 @@ &pcie1_phy {
 	status = "okay";
 };
 
+&qup_i2c12_data_clk {
+	drive-strength = <2>;
+	bias-pull-up;
+};
+
 &qupv3_id_0 {
 	firmware-name = "qcom/qcs8300/qupv3fw.elf";
 
@@ -295,6 +346,12 @@ dp_hpd: dp-hpd-state {
 		function = "edp0_hot";
 		bias-disable;
 	};
+
+	usb0_intr_state: usb0-intr-state {
+		pins = "gpio3";
+		drive-strength = <2>;
+		bias-pull-up;
+	};
 };
 
 /* USB0 HS + SS */
Signature · 1 line
2.43.0
#8 lore raw

Re: [PATCH 2/3] arm64: dts: qcom: monaco-monza-som: Enable USB0 DRD mode

Quoted 17 lines · Akash Kumar

Enable USB0 dual-role mode on monza SOM using the Cypress CYPD6129 UCSI controller.

Switch the controller node to I2C12, configure the required pinctrl and interrupt settings, and wire the USB2/USB3 endpoints for the USB-C connector.

---
 .../arm64/boot/dts/qcom/monaco-monza-som.dtsi | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +0 -0
index 9b5ed55939b8..8e3af6018dfc 100644

arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi &iris { · line 197

Quoted 4 lines
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +1 -0
@@ -194,6 +194,52 @@ &iris {
 	status = "okay";
 };
 
+&i2c12 {

Wrong place.

arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi &iris { · line 205

Quoted 8 lines
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +8 -0
+	pinctrl-0 = <&qup_i2c12_data_clk>, <&usb0_intr_state>;
+	pinctrl-names = "default";
+	status = "okay";
+
+	typec@8 {
+		compatible = "cypress,cypd6129";
+		reg = <0x08>;
+		interrupt-parent = <&tlmm>;

Is interrupt-parent required?

arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi &iris { · line 206

Quoted 1 line
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +1 -0
+		interrupts = < 3 IRQ_TYPE_LEVEL_LOW>;

Extra whitespace

Quoted 5 lines
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +5 -0
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";
+
Signature · 2 lines
With best wishes
Dmitry
#9 lore raw

Re: [PATCH 2/3] arm64: dts: qcom: monaco-monza-som: Enable USB0 DRD mode

In reply to Akash Kumar
Quoted 17 lines · Akash Kumar

Enable USB0 dual-role mode on monza SOM using the Cypress CYPD6129 UCSI controller.

Switch the controller node to I2C12, configure the required pinctrl and interrupt settings, and wire the USB2/USB3 endpoints for the USB-C connector.

---
 .../arm64/boot/dts/qcom/monaco-monza-som.dtsi | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +0 -0
index 9b5ed55939b8..8e3af6018dfc 100644

arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi &iris { · line 203

Quoted 10 lines
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +7 -0
@@ -194,6 +194,52 @@ &iris {
 	status = "okay";
 };
 
+&i2c12 {
+	pinctrl-0 = <&qup_i2c12_data_clk>, <&usb0_intr_state>;
+	pinctrl-names = "default";
+	status = "okay";
+
+	typec@8 {
+		compatible = "cypress,cypd6129";

Missing fallback compat.

Quoted 4 lines
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +4 -0
+		reg = <0x08>;
+		interrupt-parent = <&tlmm>;
+		interrupts = < 3 IRQ_TYPE_LEVEL_LOW>;
+
Signature · 2 lines
With best wishes
Dmitry
#10 lore raw

Re: [PATCH 2/3] arm64: dts: qcom: monaco-monza-som: Enable USB0 DRD mode

In reply to Akash Kumar
Quoted 17 lines · Akash Kumar

Enable USB0 dual-role mode on monza SOM using the Cypress CYPD6129 UCSI controller.

Switch the controller node to I2C12, configure the required pinctrl and interrupt settings, and wire the USB2/USB3 endpoints for the USB-C connector.

---
 .../arm64/boot/dts/qcom/monaco-monza-som.dtsi | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +0 -0
index 9b5ed55939b8..8e3af6018dfc 100644

arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi &iris { · line 200

Quoted 7 lines
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +4 -0
@@ -194,6 +194,52 @@ &iris {
 	status = "okay";
 };
 
+&i2c12 {
+	pinctrl-0 = <&qup_i2c12_data_clk>, <&usb0_intr_state>;
+	pinctrl-names = "default";
+	status = "okay";

Let's keep a \n before 'status'

arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi &iris { · line 206

Quoted 6 lines
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +6 -0
+
+	typec@8 {
+		compatible = "cypress,cypd6129";
+		reg = <0x08>;
+		interrupt-parent = <&tlmm>;
+		interrupts = < 3 IRQ_TYPE_LEVEL_LOW>;

interrupts-extended = <&tlmm 3 IRQ..>

arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi &iris { · line 210

Quoted 4 lines
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +4 -0
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";

This is unnecessary, nodes are enabled by default

Konrad

#11 lore raw

Re: [PATCH 2/3] arm64: dts: qcom: monaco-monza-som: Enable USB0 DRD mode

In reply to Akash Kumar
Quoted 24 lines · Akash Kumar

Enable USB0 dual-role mode on monza SOM using the Cypress CYPD6129 UCSI controller.

Switch the controller node to I2C12, configure the required pinctrl and interrupt settings, and wire the USB2/USB3 endpoints for the USB-C connector.

---
 .../arm64/boot/dts/qcom/monaco-monza-som.dtsi | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +4 -0
index 9b5ed55939b8..8e3af6018dfc 100644
@@ -194,6 +194,52 @@ &iris {
 	status = "okay";
 };
 
+&i2c12 {
+	pinctrl-0 = <&qup_i2c12_data_clk>, <&usb0_intr_state>;
+	pinctrl-names = "default";
+	status = "okay";

arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi &iris { · line 210

Quoted 10 lines
arch/arm64/boot/dts/qcom/monaco-monza-som.dtsi +10 -0
+
+	typec@8 {
+		compatible = "cypress,cypd6129";
+		reg = <0x08>;
+		interrupt-parent = <&tlmm>;
+		interrupts = < 3 IRQ_TYPE_LEVEL_LOW>;
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";

Why do you need to enable it? Who disabled this node?

Best regards,
Krzysztof

#12 lore raw

PATCH 3/3 usb: ucsi: ccg: Add support for CYPD6129 (CCG6)

In reply to Akash Kumar

Add "cypress,cypd6129" to the UCSI CCG driver match table so the driver can bind to CCG6-based platforms using this controller.

This is required for monza SOM USB-C support.

---
 drivers/usb/typec/ucsi/ucsi_ccg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +1 -0
index 199799b319c2..0695ce348135 100644
@@ -1520,6 +1520,7 @@ static void ucsi_ccg_remove(struct i2c_client *client)
 
 static const struct of_device_id ucsi_ccg_of_match_table[] = {
 		{ .compatible = "cypress,cypd4226", },
+		{ .compatible = "cypress,cypd6129", },
 		{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, ucsi_ccg_of_match_table);
Signature · 1 line
2.43.0
#13 lore raw

Re: [PATCH 3/3] usb: ucsi: ccg: Add support for CYPD6129 (CCG6)

Quoted 15 lines · Akash Kumar

Add "cypress,cypd6129" to the UCSI CCG driver match table so the driver can bind to CCG6-based platforms using this controller.

This is required for monza SOM USB-C support.

---
 drivers/usb/typec/ucsi/ucsi_ccg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +0 -0
index 199799b319c2..0695ce348135 100644

drivers/usb/typec/ucsi/ucsi_ccg.c static void ucsi_ccg_remove(struct i2c_client *client) · line 1523

Quoted 4 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +1 -0
@@ -1520,6 +1520,7 @@ static void ucsi_ccg_remove(struct i2c_client *client)
 
 static const struct of_device_id ucsi_ccg_of_match_table[] = {
 		{ .compatible = "cypress,cypd4226", },
+		{ .compatible = "cypress,cypd6129", },

As you are using cypress,cypd4226 as a fallback compat, driver changes are unnecessary.

Quoted 6 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +0 -0
 		{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, ucsi_ccg_of_match_table);
Signature · 1 line
2.43.0
Signature · 2 lines
With best wishes
Dmitry
#14 lore raw

Re: [PATCH 3/3] usb: ucsi: ccg: Add support for CYPD6129 (CCG6)

In reply to Akash Kumar
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Incorrect teardown order in ucsi_ccg_remove allows the IRQ handler to execute after ucsi_unregister and ucsi_destroy have freed the ucsi instance and its connectors, leading to a use-after-free vulnerability. --

commit d51e27a1b01686843b28a09a37b6e7b3a61e453b
Author: Akash Kumar <[email protected]>

usb: ucsi: ccg: Add support for CYPD6129 (CCG6)

This commit adds "cypress,cypd6129" to the UCSI CCG driver match table. This allows the driver to bind to CCG6-based platforms using this controller.

drivers/usb/typec/ucsi/ucsi_ccg.c static void ucsi_ccg_remove(struct i2c_client *client)

Quoted 5 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +0 -0
index 199799b319c2a..0695ce348135c 100644
@@ -1520,6 +1520,7 @@ static void ucsi_ccg_remove(struct i2c_client *client)

[Severity: High]
This is a pre-existing issue, but does the teardown order in ucsi_ccg_remove() cause a use-after-free of the ucsi instance and its connectors?

Looking at ucsi_ccg_remove():

	ucsi_unregister(uc->ucsi);
	ucsi_destroy(uc->ucsi);
	free_irq(uc->irq, uc);

Because free_irq() is called after ucsi_unregister() and ucsi_destroy(), an interrupt could fire during the teardown process.

If this happens, the IRQ handler would execute and call ucsi_notify_common(), which dereferences the already-freed uc->ucsi pointer and accesses the freed ucsi->connector array.

Should free_irq() be moved before ucsi_unregister() so that any pending IRQ handlers complete and no new ones are scheduled?

Quoted 6 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +1 -0
 static const struct of_device_id ucsi_ccg_of_match_table[] = {
 		{ .compatible = "cypress,cypd4226", },
+		{ .compatible = "cypress,cypd6129", },
 		{ /* sentinel */ }
 };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#15 lore raw

Re: [PATCH 3/3] usb: ucsi: ccg: Add support for CYPD6129 (CCG6)

In reply to Akash Kumar
Quoted 4 lines · Akash Kumar

Add "cypress,cypd6129" to the UCSI CCG driver match table so the driver can bind to CCG6-based platforms using this controller.

This is required for monza SOM USB-C support.

Pointless statement. What is "monza SOM"? Who could guess it in open source community?

Quoted 11 lines
---
 drivers/usb/typec/ucsi/ucsi_ccg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +0 -0
index 199799b319c2..0695ce348135 100644

drivers/usb/typec/ucsi/ucsi_ccg.c static void ucsi_ccg_remove(struct i2c_client *client) · line 1523

Quoted 4 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +1 -0
@@ -1520,6 +1520,7 @@ static void ucsi_ccg_remove(struct i2c_client *client)
 
 static const struct of_device_id ucsi_ccg_of_match_table[] = {
 		{ .compatible = "cypress,cypd4226", },
+		{ .compatible = "cypress,cypd6129", },

NAK. You just said they are compatible!

Best regards,
Krzysztof

#16 lore raw
In reply to Akash Kumar
Quoted 12 lines · Akash Kumar

Hi all,

This series adds support for the Cypress/Infineon CYPD6129 UCSI controller, used on the monza SOM platform for USB0 dual-role operation.

The series consists of:
1. A dt-binding update to document the CYPD6129 compatible string for the existing CCGx binding.
2. A driver update to bind the UCSI CCG driver to CYPD6129.
3. A board DTS update to enable USB0 DRD mode on monza SOM using the

     CYPD6129 controller over I2C12.
Quoted 7 lines

This enables the USB-C controller, connector, interrupt routing, and the USB2/USB3 endpoints required for DRD operation on the platform.

Akash Kumar (3):
dt-bindings: usb: typec: Add Cypress CYPD6129 UCSI controller compatible
usb: ucsi: ccg: Add support for CYPD6129 (CCG6)
arm64: dts: qcom: monaco-monza-som: Enable USB0 DRD mode

Why are you mixing USB with DTS (don't! we asked many times already), and in completely random order (read submitting patches in DT dir).

Best regards,
Krzysztof