public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] usb: typec: ucsi: Set usb mode on partner change
@ 2026-04-02 18:24 Jameson Thies
  2026-04-02 19:50 ` Benson Leung
  2026-04-07 12:21 ` Heikki Krogerus
  0 siblings, 2 replies; 3+ messages in thread
From: Jameson Thies @ 2026-04-02 18:24 UTC (permalink / raw)
  To: heikki.krogerus, linux-usb, linux-kernel
  Cc: dmitry.baryshkov, bleung, gregkh, akuchynski, abhishekpandit,
	Jameson Thies

Currently the partner usb_mode is only set in ucsi_register_partner().
If the partner enters USB4 operation after it is registered, this is not
reported to the typec class. The UCSI spec states that the Connector
Partner Changed bit can represent a Connector Partner Flags change. When
handling a UCSI partner change, check the partner flags for USB4
operation.

Signed-off-by: Jameson Thies <jthies@google.com>
---
 drivers/usb/typec/ucsi/ucsi.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index fe1fb8a68a1d..e6fd2e2eba94 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -1182,6 +1182,12 @@ static void ucsi_partner_change(struct ucsi_connector *con)
 			if (UCSI_CONSTAT(con, PARTNER_FLAG_USB))
 				typec_set_mode(con->port, TYPEC_STATE_USB);
 		}
+
+		if (((con->ucsi->version >= UCSI_VERSION_3_0 &&
+		    UCSI_CONSTAT(con, PARTNER_FLAG_USB4_GEN4)) ||
+		    (con->ucsi->version >= UCSI_VERSION_2_0 &&
+		    UCSI_CONSTAT(con, PARTNER_FLAG_USB4_GEN3))) && con->partner)
+			typec_partner_set_usb_mode(con->partner, USB_MODE_USB4);
 	}
 
 	if ((!UCSI_CONSTAT(con, PARTNER_FLAG_USB)) &&

base-commit: 81ebd43cc0d6d106ce7b6ccbf7b5e40ca7f5503d
-- 
2.53.0.1213.gd9a14994de-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] usb: typec: ucsi: Set usb mode on partner change
  2026-04-02 18:24 [PATCH v1] usb: typec: ucsi: Set usb mode on partner change Jameson Thies
@ 2026-04-02 19:50 ` Benson Leung
  2026-04-07 12:21 ` Heikki Krogerus
  1 sibling, 0 replies; 3+ messages in thread
From: Benson Leung @ 2026-04-02 19:50 UTC (permalink / raw)
  To: Jameson Thies
  Cc: heikki.krogerus, linux-usb, linux-kernel, dmitry.baryshkov,
	bleung, gregkh, akuchynski, abhishekpandit

[-- Attachment #1: Type: text/plain, Size: 1525 bytes --]

Hi Jameson,

On Thu, Apr 02, 2026 at 06:24:38PM +0000, Jameson Thies wrote:
> Currently the partner usb_mode is only set in ucsi_register_partner().
> If the partner enters USB4 operation after it is registered, this is not
> reported to the typec class. The UCSI spec states that the Connector
> Partner Changed bit can represent a Connector Partner Flags change. When
> handling a UCSI partner change, check the partner flags for USB4
> operation.
> 
> Signed-off-by: Jameson Thies <jthies@google.com>

Reviewed-by: Benson Leung <bleung@chromium.org>


> ---
>  drivers/usb/typec/ucsi/ucsi.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index fe1fb8a68a1d..e6fd2e2eba94 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1182,6 +1182,12 @@ static void ucsi_partner_change(struct ucsi_connector *con)
>  			if (UCSI_CONSTAT(con, PARTNER_FLAG_USB))
>  				typec_set_mode(con->port, TYPEC_STATE_USB);
>  		}
> +
> +		if (((con->ucsi->version >= UCSI_VERSION_3_0 &&
> +		    UCSI_CONSTAT(con, PARTNER_FLAG_USB4_GEN4)) ||
> +		    (con->ucsi->version >= UCSI_VERSION_2_0 &&
> +		    UCSI_CONSTAT(con, PARTNER_FLAG_USB4_GEN3))) && con->partner)
> +			typec_partner_set_usb_mode(con->partner, USB_MODE_USB4);
>  	}
>  
>  	if ((!UCSI_CONSTAT(con, PARTNER_FLAG_USB)) &&
> 
> base-commit: 81ebd43cc0d6d106ce7b6ccbf7b5e40ca7f5503d
> -- 
> 2.53.0.1213.gd9a14994de-goog
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] usb: typec: ucsi: Set usb mode on partner change
  2026-04-02 18:24 [PATCH v1] usb: typec: ucsi: Set usb mode on partner change Jameson Thies
  2026-04-02 19:50 ` Benson Leung
@ 2026-04-07 12:21 ` Heikki Krogerus
  1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2026-04-07 12:21 UTC (permalink / raw)
  To: Jameson Thies
  Cc: linux-usb, linux-kernel, dmitry.baryshkov, bleung, gregkh,
	akuchynski, abhishekpandit

Thu, Apr 02, 2026 at 06:24:38PM +0000, Jameson Thies kirjoitti:
> Currently the partner usb_mode is only set in ucsi_register_partner().
> If the partner enters USB4 operation after it is registered, this is not
> reported to the typec class. The UCSI spec states that the Connector
> Partner Changed bit can represent a Connector Partner Flags change. When
> handling a UCSI partner change, check the partner flags for USB4
> operation.
> 
> Signed-off-by: Jameson Thies <jthies@google.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/ucsi/ucsi.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index fe1fb8a68a1d..e6fd2e2eba94 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1182,6 +1182,12 @@ static void ucsi_partner_change(struct ucsi_connector *con)
>  			if (UCSI_CONSTAT(con, PARTNER_FLAG_USB))
>  				typec_set_mode(con->port, TYPEC_STATE_USB);
>  		}
> +
> +		if (((con->ucsi->version >= UCSI_VERSION_3_0 &&
> +		    UCSI_CONSTAT(con, PARTNER_FLAG_USB4_GEN4)) ||
> +		    (con->ucsi->version >= UCSI_VERSION_2_0 &&
> +		    UCSI_CONSTAT(con, PARTNER_FLAG_USB4_GEN3))) && con->partner)
> +			typec_partner_set_usb_mode(con->partner, USB_MODE_USB4);
>  	}
>  
>  	if ((!UCSI_CONSTAT(con, PARTNER_FLAG_USB)) &&

-- 
heikki

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-07 12:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 18:24 [PATCH v1] usb: typec: ucsi: Set usb mode on partner change Jameson Thies
2026-04-02 19:50 ` Benson Leung
2026-04-07 12:21 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox