Re: [PATCH v4 2/4] usb: typec: ucsi: Register cables based on GET_CABLE_PROPERTY

From: Bjorn Andersson
Date: Tue Mar 26 2024 - 18:09:46 EST


On Mon, Mar 11, 2024 at 06:28:41PM +0100, neil.armstrong@xxxxxxxxxx wrote:
> On 05/03/2024 03:58, Jameson Thies wrote:
[..]
> With:
> =================><====================================
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index cf52cb34d285..eec64a4c8cdd 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1189,8 +1189,10 @@ static void ucsi_handle_connector_change(struct work_struct *work)
> ucsi_register_partner(con);
> ucsi_partner_task(con, ucsi_check_connection, 1, HZ);
> ucsi_partner_task(con, ucsi_check_connector_capability, 1, HZ);
> - ucsi_partner_task(con, ucsi_get_partner_identity, 1, HZ);
> - ucsi_partner_task(con, ucsi_check_cable, 1, HZ);
> + if (con->ucsi->cap.features & UCSI_CAP_GET_PD_MESSAGE)
> + ucsi_partner_task(con, ucsi_get_partner_identity, 1, HZ);
> + if (con->ucsi->cap.features & UCSI_CAP_CABLE_DETAILS)
> + ucsi_partner_task(con, ucsi_check_cable, 1, HZ);
>
> if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) ==
> UCSI_CONSTAT_PWR_OPMODE_PD)
> @@ -1589,8 +1591,10 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con)
> ucsi_register_partner(con);
> ucsi_pwr_opmode_change(con);
> ucsi_port_psy_changed(con);
> - ucsi_get_partner_identity(con);
> - ucsi_check_cable(con);
> + if (con->ucsi->cap.features & UCSI_CAP_GET_PD_MESSAGE)
> + ucsi_get_partner_identity(con);
> + if (con->ucsi->cap.features & UCSI_CAP_CABLE_DETAILS)
> + ucsi_check_cable(con);
> }
>
> /* Only notify USB controller if partner supports USB data */
> diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
> index 32daf5f58650..2e9c35a3af27 100644
> --- a/drivers/usb/typec/ucsi/ucsi.h
> +++ b/drivers/usb/typec/ucsi/ucsi.h
> @@ -215,6 +215,7 @@ struct ucsi_capability {
> #define UCSI_CAP_CABLE_DETAILS BIT(5)
> #define UCSI_CAP_EXT_SUPPLY_NOTIFICATIONS BIT(6)
> #define UCSI_CAP_PD_RESET BIT(7)
> +#define UCSI_CAP_GET_PD_MESSAGE BIT(8)
> u16 reserved_1;
> u8 num_alt_modes;
> u8 reserved_2;
> =================><====================================
> it works fine again.
>

The series broke role switching on qcs6490-rb3gen2 (next-20240326 is
broken). You're proposed addition brings it back, thank you.

Was this posted somewhere?

Regards,
Bjorn