Skip to contentSkip to conversation

dt-bindings: connector: usb: provide bindings for altmodes

PATCH New Dmitry Baryshkov 1 participant 4 messages Dec 4, 2023

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

v4 cover dt-bindings: connector: usb: provide bindings for altmodes

In some cases we need a way to specify USB-C AltModes that can be supportd on the particular USB-C connector. For example, x86 INT33FE driver does this by populating fwnode properties internally. For the Qualcomm Robotics RB5 platform (and several similar devices which use Qualcomm PMIC TCPM) we have to put this information to the DT.

Provide the DT bindings for this kind of information and while we are at it, change svid property to be 16-bit unsigned integer instead of a simple u32.

NOTE: usage of u16 is not compatible with the recenty extended qcom/qrb5165-rb5.dts DT file, but it is more logical since SVID is 16 bits wide.

Changes since v3:
- Added enum to constraint atmode SVID (Rob)
- Moved additionaPropperties to come beore the property definitions (Rob)

Changes since v2:
- Inlined altmode definitions instead of having them under $defs (Rob)
- Explicity list permitted AltMode names (currenty only displayport is allowed) (Rob)

Changes since v1:
- Added type:object and fixed 'description' string in the altmodes-list definition.

Dmitry Baryshkov (3):
dt-bindings: connector: usb: add altmodes description
usb: typec: change altmode SVID to u16 entry
arm64: dts: qcom: qrb5165-rb5: use u16 for DP altmode svid

 .../bindings/connector/usb-connector.yaml     | 33 +++++++++++++++++++
 arch/arm64/boot/dts/qcom/qrb5165-rb5.dts      |  2 +-
 drivers/platform/x86/intel/chtwc_int33fe.c    |  2 +-
 drivers/usb/typec/class.c                     |  5 +--
 4 files changed, 38 insertions(+), 4 deletions(-)
Signature · 1 line
2.42.0
#1 lore raw

PATCH v4 1/3 dt-bindings: connector: usb: add altmodes description

Add description of the USB-C AltModes supported on the particular USB-C connector. This is required for devices like Qualcomm Robotics RB5, which have no other way to express alternative modes supported by the hardware platform.

---
 .../bindings/connector/usb-connector.yaml     | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)
Documentation/devicetree/bindings/connector/usb-connector.yaml +33 -0
index 7c8a3e8430d3..28660b931d0c 100644
@@ -171,6 +171,32 @@ properties:
       offer the power, Capability Mismatch is set. Required for power sink and
       power dual role.
 
+  altmodes:
+    type: object
+    description: List of Alternative Modes supported by the schematics on the
+      particular device. This is only necessary if there are no other means to
+      discover supported alternative modes (e.g. through the UCSI firmware
+      interface).
+
+    additionalProperties: false
+
+    patternProperties:
+      "^(displayport)$":
+        type: object
+        description:
+          A single USB-C Alternative Mode as supported by the USB-C connector logic.
+
+        additionalProperties: false
+
+        properties:
+          svid:
+            $ref: /schemas/types.yaml#/definitions/uint16
+            description: Unique value assigned by USB-IF to the Vendor / AltMode.
+            enum: [ 0xff01 ]
+          vdo:
+            $ref: /schemas/types.yaml#/definitions/uint32
+            description: VDO returned by Discover Modes USB PD command.
+
   port:
     $ref: /schemas/graph.yaml#/properties/port
     description: OF graph bindings modeling a data bus to the connector, e.g.
@@ -289,6 +315,13 @@ examples:
             compatible = "usb-c-connector";
             label = "USB-C";
 
+            altmodes {
+                displayport {
+                    svid = /bits/ 16 <0xff01>;
+                    vdo = <0x00001c46>;
+                };
+            };
+
             ports {
                 #address-cells = <1>;
                 #size-cells = <0>;
Signature · 1 line
2.42.0
#2 lore raw

PATCH v4 2/3 usb: typec: change altmode SVID to u16 entry

In reply to Dmitry Baryshkov

As stated in the changelog for the commit 7b458a4c5d73 ("usb: typec: Add typec_port_register_altmodes()"), the code should be adjusted according to the AltMode bindings. As the SVID is 16 bits wide (according to the USB PD Spec), use fwnode_property_read_u16() to read it.

---
 drivers/platform/x86/intel/chtwc_int33fe.c | 2 +-
 drivers/usb/typec/class.c                  | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/platform/x86/intel/chtwc_int33fe.c +1 -1
index 848baecc1bb0..93f75ba1dafd 100644
@@ -136,7 +136,7 @@ static const struct software_node altmodes_node = {
 };
 
 static const struct property_entry dp_altmode_properties[] = {
-	PROPERTY_ENTRY_U32("svid", 0xff01),
+	PROPERTY_ENTRY_U16("svid", 0xff01),
 	PROPERTY_ENTRY_U32("vdo", 0x0c0086),
 	{ }
 };
drivers/usb/typec/class.c +3 -2
index 2e0451bd336e..a959dcc3374a 100644
@@ -2230,7 +2230,8 @@ void typec_port_register_altmodes(struct typec_port *port,
 	struct typec_altmode_desc desc;
 	struct typec_altmode *alt;
 	size_t index = 0;
-	u32 svid, vdo;
+	u16 svid;
+	u32 vdo;
 	int ret;
 
 	altmodes_node = device_get_named_child_node(&port->dev, "altmodes");
@@ -2238,7 +2239,7 @@ void typec_port_register_altmodes(struct typec_port *port,
 		return; /* No altmodes specified */
 
 	fwnode_for_each_child_node(altmodes_node, child) {
-		ret = fwnode_property_read_u32(child, "svid", &svid);
+		ret = fwnode_property_read_u16(child, "svid", &svid);
 		if (ret) {
 			dev_err(&port->dev, "Error reading svid for altmode %s\n",
 				fwnode_get_name(child));
Signature · 1 line
2.42.0
#3 lore raw

PATCH v4 3/3 arm64: dts: qcom: qrb5165-rb5: use u16 for DP altmode svid

In reply to Dmitry Baryshkov

Follow the bindings and use 16-bit value for AltMode SVID instead of using the full u32.

Fixes b3dea914127e ("arm64: dts: qcom: qrb5165-rb5: enable DP altmode")
---
 arch/arm64/boot/dts/qcom/qrb5165-rb5.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/qrb5165-rb5.dts +1 -1
index c8cd40a462a3..88b37ceb13ed 100644
@@ -1425,7 +1425,7 @@ PDO_FIXED_USB_COMM |
 
 		altmodes {
 			displayport {
-				svid = <0xff01>;
+				svid = /bits/ 16 <0xff01>;
 				vdo = <0x00001c46>;
 			};
 		};
Signature · 1 line
2.42.0