Skip to contentSkip to conversation

usb: typec: tcpm: try to get role switch from tcpc fwnode

PATCH In review Li Jun 4 participants 5 messages Mar 28, 2023 – Mar 29, 2023

Subsystems (3)
lore
Share & tools
lore

Li Jun

author
#0 lore raw

PATCH 1/1 usb: typec: tcpm: try to get role switch from tcpc fwnode

Try to get usb role switch from tcpc fwnode if failed to get role switch from port dev, this is for case the port for role switch endpoint is located in connector node, as per connector binding doc, port@0 for HS is required.

ptn5110: tcpc@50 {
	compatible = "nxp,ptn5110";
	...
	status = "okay";

	connector {
		compatible = "usb-c-connector";
		label = "USB-C";
		...

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;

				typec_conn: endpoint {
					remote-endpoint = <&usb2_controller>;
				};
			};
		};
	};
};
---
 drivers/usb/typec/tcpm/tcpm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +2 -0
index a0d943d78580..f0534bdb4462 100644
@@ -6557,6 +6557,8 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	port->port_type = port->typec_caps.type;
 
 	port->role_sw = usb_role_switch_get(port->dev);
+	if (!port->role_sw)
+		port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode);
 	if (IS_ERR(port->role_sw)) {
 		err = PTR_ERR(port->role_sw);
 		goto out_destroy_wq;
Signature · 1 line
2.34.1
maintainer
#1 lore raw

+Bryan

Quoted 40 lines · Li Jun

Try to get usb role switch from tcpc fwnode if failed to get role switch from port dev, this is for case the port for role switch endpoint is located in connector node, as per connector binding doc, port@0 for HS is required.

ptn5110: tcpc@50 {
	compatible = "nxp,ptn5110";
	...
	status = "okay";

	connector {
		compatible = "usb-c-connector";
		label = "USB-C";
		...

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;

				typec_conn: endpoint {
					remote-endpoint = <&usb2_controller>;
				};
			};
		};
	};
};
---
 drivers/usb/typec/tcpm/tcpm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +0 -0
index a0d943d78580..f0534bdb4462 100644

drivers/usb/typec/tcpm/tcpm.c struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) · line 6564

Quoted 8 lines
drivers/usb/typec/tcpm/tcpm.c +2 -0
@@ -6557,6 +6557,8 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	port->port_type = port->typec_caps.type;
 
 	port->role_sw = usb_role_switch_get(port->dev);
+	if (!port->role_sw)
+		port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode);
 	if (IS_ERR(port->role_sw)) {
 		err = PTR_ERR(port->role_sw);
 		goto out_destroy_wq;

This looks like exactly the same as the RFC from Bryan that I just commented. I have not objections if this looks okay to you Brian. I think we should still wait for comments also from Guenter.

thanks,

Signature · 1 line
heikki
#2 lore raw
Quoted 45 lines · Heikki Krogerus

+Bryan

Quoted 42 lines · Li Jun

Try to get usb role switch from tcpc fwnode if failed to get role switch from port dev, this is for case the port for role switch endpoint is located in connector node, as per connector binding doc, port@0 for HS is required.

ptn5110: tcpc@50 {
	compatible = "nxp,ptn5110";
	...
	status = "okay";

	connector {
		compatible = "usb-c-connector";
		label = "USB-C";
		...

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;

				typec_conn: endpoint {
					remote-endpoint = <&usb2_controller>;
				};
			};
		};
	};
};
---
 drivers/usb/typec/tcpm/tcpm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +0 -0
index a0d943d78580..f0534bdb4462 100644
@@ -6557,6 +6557,8 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	port->port_type = port->typec_caps.type;
 
Quoted 11 lines

drivers/usb/typec/tcpm/tcpm.c struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) · line 6564

Quoted 6 lines
drivers/usb/typec/tcpm/tcpm.c +2 -0
 	port->role_sw = usb_role_switch_get(port->dev);
+	if (!port->role_sw)
+		port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode);
 	if (IS_ERR(port->role_sw)) {
 		err = PTR_ERR(port->role_sw);
 		goto out_destroy_wq;

This looks like exactly the same as the RFC from Bryan that I just commented. I have not objections if this looks okay to you Brian. I think we should still wait for comments also from Guenter.

Ok with me.

Guenter

Quoted 4 lines

thanks,

Signature · 1 line
heikki
#3 lore raw
In reply to Heikki Krogerus
Quoted 56 lines · Heikki Krogerus

+Bryan

Quoted 40 lines · Li Jun

Try to get usb role switch from tcpc fwnode if failed to get role switch from port dev, this is for case the port for role switch endpoint is located in connector node, as per connector binding doc, port@0 for HS is required.

ptn5110: tcpc@50 {
	compatible = "nxp,ptn5110";
	...
	status = "okay";

	connector {
		compatible = "usb-c-connector";
		label = "USB-C";
		...

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;

				typec_conn: endpoint {
					remote-endpoint = <&usb2_controller>;
				};
			};
		};
	};
};
---
  drivers/usb/typec/tcpm/tcpm.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +0 -0
index a0d943d78580..f0534bdb4462 100644

drivers/usb/typec/tcpm/tcpm.c struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) · line 6564

Quoted 8 lines
drivers/usb/typec/tcpm/tcpm.c +2 -0
@@ -6557,6 +6557,8 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
  	port->port_type = port->typec_caps.type;
 
  	port->role_sw = usb_role_switch_get(port->dev);
+	if (!port->role_sw)
+		port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode);
  	if (IS_ERR(port->role_sw)) {
  		err = PTR_ERR(port->role_sw);
  		goto out_destroy_wq;

This looks like exactly the same as the RFC from Bryan that I just commented. I have not objections if this looks okay to you Brian. I think we should still wait for comments also from Guenter.

Quoted 2 lines

thanks,

It does look exactly the same. I don't mind letting Li have the commit.

---
bod

maintainer Reviewed-by on v1 1/1
#4 lore raw
In reply to Li Jun
Quoted 30 lines · Li Jun

Try to get usb role switch from tcpc fwnode if failed to get role switch from port dev, this is for case the port for role switch endpoint is located in connector node, as per connector binding doc, port@0 for HS is required.

ptn5110: tcpc@50 {
	compatible = "nxp,ptn5110";
	...
	status = "okay";

	connector {
		compatible = "usb-c-connector";
		label = "USB-C";
		...

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;

				typec_conn: endpoint {
					remote-endpoint = <&usb2_controller>;
				};
			};
		};
	};
};
Quoted 1 line
Quoted 19 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +2 -0
index a0d943d78580..f0534bdb4462 100644
@@ -6557,6 +6557,8 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	port->port_type = port->typec_caps.type;
 
 	port->role_sw = usb_role_switch_get(port->dev);
+	if (!port->role_sw)
+		port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode);
 	if (IS_ERR(port->role_sw)) {
 		err = PTR_ERR(port->role_sw);
 		goto out_destroy_wq;
Signature · 1 line
2.34.1
Signature · 1 line
heikki