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>;
				};
			};
		};
	};
};

Signed-off-by: Li Jun <jun.li@nxp.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/1679991784-25500-1-git-send-email-jun.li@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Li Jun 2023-03-28 16:23:04 +08:00 committed by Greg Kroah-Hartman
parent 8000540218
commit d56de8c9a1

View File

@ -6577,6 +6577,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;