Skip to content

Commit a79f16e

Browse files
Heikki Krogerusgregkh
authored andcommitted
usb: typec: ucsi: Add support for the partner USB Modes
UCSI does not share the contents of the Enter_USB Message that was used, so the active mode still has to be always determined from the enumerated USB device. However, after UCSI v2.0 it is possible to check separately is USB4 the active mode. So with USB2 and USB3 the mode is always determined from the result of the USB enumeration, and when USB4 USB Mode is active, UCSI driver can assign the mode directly. Signed-off-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ae70c80 commit a79f16e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

drivers/usb/typec/ucsi/ucsi.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,15 @@ static int ucsi_register_partner(struct ucsi_connector *con)
10571057

10581058
con->partner = partner;
10591059

1060+
if ((con->ucsi->version >= UCSI_VERSION_3_0) &&
1061+
(UCSI_CONSTAT_PARTNER_FLAGS(con->status.flags) &
1062+
UCSI_CONSTAT_PARTNER_FLAG_USB4_GEN4))
1063+
typec_partner_set_usb_mode(partner, USB_MODE_USB4);
1064+
else if ((con->ucsi->version >= UCSI_VERSION_2_0) &&
1065+
(UCSI_CONSTAT_PARTNER_FLAGS(con->status.flags) &
1066+
UCSI_CONSTAT_PARTNER_FLAG_USB4_GEN3))
1067+
typec_partner_set_usb_mode(partner, USB_MODE_USB4);
1068+
10601069
return 0;
10611070
}
10621071

drivers/usb/typec/ucsi/ucsi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ struct ucsi_connector_status {
347347
#define UCSI_CONSTAT_PARTNER_FLAGS(_f_) (((_f_) & GENMASK(12, 5)) >> 5)
348348
#define UCSI_CONSTAT_PARTNER_FLAG_USB 1
349349
#define UCSI_CONSTAT_PARTNER_FLAG_ALT_MODE 2
350+
#define UCSI_CONSTAT_PARTNER_FLAG_USB4_GEN3 4
351+
#define UCSI_CONSTAT_PARTNER_FLAG_USB4_GEN4 8
350352
#define UCSI_CONSTAT_PARTNER_TYPE(_f_) (((_f_) & GENMASK(15, 13)) >> 13)
351353
#define UCSI_CONSTAT_PARTNER_TYPE_DFP 1
352354
#define UCSI_CONSTAT_PARTNER_TYPE_UFP 2

0 commit comments

Comments
 (0)