Re: [PATCH] platform/chrome: cros_ec_typec: Add support for setting USB mode via sysfs

From: Tzung-Bi Shih
Date: Tue Feb 18 2025 - 09:28:51 EST


On Mon, Feb 10, 2025 at 01:04:19PM +0000, Andrei Kuchynski wrote:
> +static int cros_typec_enter_usb_mode(struct typec_port *tc_port, enum usb_mode mode)
> +{
> + struct cros_typec_port *port = typec_get_drvdata(tc_port);
> + struct ec_params_typec_control req = {
> + .port = port->port_num,
> + .command = (mode == USB_MODE_USB4) ?
> + TYPEC_CONTROL_COMMAND_ENTER_MODE : TYPEC_CONTROL_COMMAND_EXIT_MODES,
> + .mode_to_enter = CROS_EC_ALTMODE_USB4

The symbol `CROS_EC_ALTMODE_USB4` doesn't exist. On a related note, wouldn't
it always enter CROS_EC_ALTMODE_USB4 if the value is hard-coded here?

> @@ -84,6 +102,13 @@ static int cros_typec_parse_port_props(struct typec_capability *cap,
> cap->prefer_role = ret;
> }
>
> + if (fwnode_property_present(fwnode, "usb2-port"))
> + cap->usb_capability |= USB_CAPABILITY_USB2;
> + if (fwnode_property_present(fwnode, "usb3-port"))
> + cap->usb_capability |= USB_CAPABILITY_USB3;
> + if (fwnode_property_present(fwnode, "usb4-port"))
> + cap->usb_capability |= USB_CAPABILITY_USB4;

Are these defined somewhere? E.g. the bindings?