[PATCH RFC 0/8] USB Type-C alternate mode selection

Andrei Kuchynski posted 8 patches 2 months, 1 week ago
drivers/platform/chrome/cros_ec_typec.c      |  47 ++-
drivers/platform/chrome/cros_typec_altmode.c |   8 +-
drivers/usb/typec/Makefile                   |   2 +-
drivers/usb/typec/altmodes/displayport.c     |   6 +-
drivers/usb/typec/altmodes/thunderbolt.c     |   2 +-
drivers/usb/typec/class.c                    |   1 +
drivers/usb/typec/class.h                    |   2 +
drivers/usb/typec/mode_selection.c           | 308 +++++++++++++++++++
drivers/usb/typec/ucsi/Makefile              |   4 +
drivers/usb/typec/ucsi/cros_ec_ucsi.c        |  44 +++
drivers/usb/typec/ucsi/thunderbolt.c         | 199 ++++++++++++
drivers/usb/typec/ucsi/ucsi.c                |  56 +++-
drivers/usb/typec/ucsi/ucsi.h                |  27 ++
include/linux/usb/typec.h                    |   1 +
include/linux/usb/typec_altmode.h            |  43 +++
15 files changed, 728 insertions(+), 22 deletions(-)
create mode 100644 drivers/usb/typec/mode_selection.c
create mode 100644 drivers/usb/typec/ucsi/thunderbolt.c
[PATCH RFC 0/8] USB Type-C alternate mode selection
Posted by Andrei Kuchynski 2 months, 1 week ago
This patch series introduces functionality to the USB Type-C Alternate Mode
negotiation process by implementing a priority-based selection mechanism.

Currently, DisplayPort and Thunderbolt drivers initiate a mode entry
separately within their respective probe functions. The Power Delivery
Controller (PDC) retains the ability to activate either USB4 mode or
Alternate Modes based on its internal policy.
The mode selection mechanism disables Alternate Modes to be entered by
their respective drivers and the PDC. Instead, a priority-ordered approach
is used to activate the most desirable mode.

A new `priority` field is added to the `typec_altmode` structure to store
a numerical priority value, with all priorities being unique.
If the port driver supports the mode selection feature, it must set the
`mode_selection` boolean field within the `typec_altmode` structure. This
indicates to the alternate mode drivers that they are not to activate the
altmode separately.

The mode selection process is managed by three API functions:
- `typec_mode_selection_start`
- `typec_altmode_state_update`
- `typec_mode_selection_delete`

When a partner device is connected, the `typec_mode_selection_start`
function executes the following steps:
- It compiles a priority-ordered list of Alternate Modes that are mutually
supported by both the port and the partner.
- A dedicated mode selection task is subsequently initiated on the Work
Queue.
- This task attempts to activate a mode by starting with the
highest-priority altmode on the list. Alternate modes are identified with
their SVIDs. Activation/Deactivation performed via `activate` typec_altmode
operation. The process stops as soon as a mode is successfully entered.
Otherwise, after a timeout or if an error occurs, the next alternative mode
will be activated.

The `typec_altmode_state_update` function is invoked by the port driver to
communicate the current mode of the Type-C connector.

The `typec_mode_selection_delete` function is responsible for stopping the
currently running mode selection process and releasing all associated
system resources.

USB4 activation can be handled in two distinct ways:
- Treated like an Alternate Mode, using associated sysfs attributes -
`activate` port attribute to enable/disable the mode, `activate` partner
attribute to activate/deactivate the mode, `priority` to keep modes
priority.
- Like a separate USB mode representing in sysfs via `usb_capabily` ports
attribute to enable the mode on the port and `usb_mode` partner attribute
to activate the mode. In this scenario, USB4 is the highest-priority mode,
without the need for a separate priority field. It is put on the top of the
preferred list if it is supported by the partner (partner->usb_capability
has USB_CAPABILITY_USB4 bit set) and is supported and enabled on the port
(port->usb_mode is USB_MODE_USB4).

This patch series implements the second approach. It identifies the USB4
mode via its SVID 0xFF00. Instead of using the typec_altmode_ops activate()
function, activation is handled via the typec_operations enter_usb_mode()
function.
Mode selection is initiated only once during partner registration, and only
if the port driver provides support for this feature. Subsequent
mode-switching activities can be managed via existing sysfs entries. Any
modifications to altmode priorities are relevant only to future
connections.

This series was tested on an Android OS device with kernel 6.17, PDC:
TI TPS6699, Realtek RTS5453.
This series depends on the 'USB Type-C alternate mode priorities' series:
https://lore.kernel.org/all/20251124124639.1101335-1-akuchynski@chromium.org/ 

Andrei Kuchynski (8):
  usb: typec: Implement mode selection
  usb: typec: Integrate USB4 into the mode selection process
  usb: typec: Introduce mode_selection bit
  usb: typec: ucsi: Support mode selection to activate altmodes
  usb: typec: ucsi: Enforce mode selection for cros_ec_ucsi
  usb: typec: ucsi: Implement enter_usb_mode operation
  usb: typec: ucsi: Support for Thunderbolt alt mode
  platform/chrome: cros_ec_typec: Enforce priority-based mode selection

 drivers/platform/chrome/cros_ec_typec.c      |  47 ++-
 drivers/platform/chrome/cros_typec_altmode.c |   8 +-
 drivers/usb/typec/Makefile                   |   2 +-
 drivers/usb/typec/altmodes/displayport.c     |   6 +-
 drivers/usb/typec/altmodes/thunderbolt.c     |   2 +-
 drivers/usb/typec/class.c                    |   1 +
 drivers/usb/typec/class.h                    |   2 +
 drivers/usb/typec/mode_selection.c           | 308 +++++++++++++++++++
 drivers/usb/typec/ucsi/Makefile              |   4 +
 drivers/usb/typec/ucsi/cros_ec_ucsi.c        |  44 +++
 drivers/usb/typec/ucsi/thunderbolt.c         | 199 ++++++++++++
 drivers/usb/typec/ucsi/ucsi.c                |  56 +++-
 drivers/usb/typec/ucsi/ucsi.h                |  27 ++
 include/linux/usb/typec.h                    |   1 +
 include/linux/usb/typec_altmode.h            |  43 +++
 15 files changed, 728 insertions(+), 22 deletions(-)
 create mode 100644 drivers/usb/typec/mode_selection.c
 create mode 100644 drivers/usb/typec/ucsi/thunderbolt.c

-- 
2.52.0.158.g65b55ccf14-goog
Re: [PATCH RFC 0/8] USB Type-C alternate mode selection
Posted by Heikki Krogerus 1 month, 4 weeks ago
Mon, Dec 01, 2025 at 12:25:56PM +0000, Andrei Kuchynski kirjoitti:
> This patch series introduces functionality to the USB Type-C Alternate Mode
> negotiation process by implementing a priority-based selection mechanism.
> 
> Currently, DisplayPort and Thunderbolt drivers initiate a mode entry
> separately within their respective probe functions. The Power Delivery
> Controller (PDC) retains the ability to activate either USB4 mode or
> Alternate Modes based on its internal policy.
> The mode selection mechanism disables Alternate Modes to be entered by
> their respective drivers and the PDC. Instead, a priority-ordered approach
> is used to activate the most desirable mode.
> 
> A new `priority` field is added to the `typec_altmode` structure to store
> a numerical priority value, with all priorities being unique.
> If the port driver supports the mode selection feature, it must set the
> `mode_selection` boolean field within the `typec_altmode` structure. This
> indicates to the alternate mode drivers that they are not to activate the
> altmode separately.
> 
> The mode selection process is managed by three API functions:
> - `typec_mode_selection_start`
> - `typec_altmode_state_update`
> - `typec_mode_selection_delete`
> 
> When a partner device is connected, the `typec_mode_selection_start`
> function executes the following steps:
> - It compiles a priority-ordered list of Alternate Modes that are mutually
> supported by both the port and the partner.
> - A dedicated mode selection task is subsequently initiated on the Work
> Queue.
> - This task attempts to activate a mode by starting with the
> highest-priority altmode on the list. Alternate modes are identified with
> their SVIDs. Activation/Deactivation performed via `activate` typec_altmode
> operation. The process stops as soon as a mode is successfully entered.
> Otherwise, after a timeout or if an error occurs, the next alternative mode
> will be activated.
> 
> The `typec_altmode_state_update` function is invoked by the port driver to
> communicate the current mode of the Type-C connector.
> 
> The `typec_mode_selection_delete` function is responsible for stopping the
> currently running mode selection process and releasing all associated
> system resources.
> 
> USB4 activation can be handled in two distinct ways:
> - Treated like an Alternate Mode, using associated sysfs attributes -
> `activate` port attribute to enable/disable the mode, `activate` partner
> attribute to activate/deactivate the mode, `priority` to keep modes
> priority.
> - Like a separate USB mode representing in sysfs via `usb_capabily` ports
> attribute to enable the mode on the port and `usb_mode` partner attribute
> to activate the mode. In this scenario, USB4 is the highest-priority mode,
> without the need for a separate priority field. It is put on the top of the
> preferred list if it is supported by the partner (partner->usb_capability
> has USB_CAPABILITY_USB4 bit set) and is supported and enabled on the port
> (port->usb_mode is USB_MODE_USB4).
> 
> This patch series implements the second approach. It identifies the USB4
> mode via its SVID 0xFF00. Instead of using the typec_altmode_ops activate()
> function, activation is handled via the typec_operations enter_usb_mode()
> function.
> Mode selection is initiated only once during partner registration, and only
> if the port driver provides support for this feature. Subsequent
> mode-switching activities can be managed via existing sysfs entries. Any
> modifications to altmode priorities are relevant only to future
> connections.
> 
> This series was tested on an Android OS device with kernel 6.17, PDC:
> TI TPS6699, Realtek RTS5453.
> This series depends on the 'USB Type-C alternate mode priorities' series:
> https://lore.kernel.org/all/20251124124639.1101335-1-akuchynski@chromium.org/ 

Without going into the code review yet, I'm okay with this in general,
except with the artificial SID for the USB4. I still don't understand
why do you guys think we should use that instead of an USB4 specific
device type?

I think somebody said earlier that the user space can't see the device
type of the alt modes? If that's really the case, then I think there
is some bigger issue here. Are you really sure that if you check the
device type of an alternate mode for example with udevadm, it does not
say DEVTYPE=typec_alternate_mode ?

        % udevadm info -q property --property=DEVTYPE /sys/bus/typec/devices/port0-partner.0
        DEVTYPE=typec_alternate_mode

Br,

> Andrei Kuchynski (8):
>   usb: typec: Implement mode selection
>   usb: typec: Integrate USB4 into the mode selection process
>   usb: typec: Introduce mode_selection bit
>   usb: typec: ucsi: Support mode selection to activate altmodes
>   usb: typec: ucsi: Enforce mode selection for cros_ec_ucsi
>   usb: typec: ucsi: Implement enter_usb_mode operation
>   usb: typec: ucsi: Support for Thunderbolt alt mode
>   platform/chrome: cros_ec_typec: Enforce priority-based mode selection
> 
>  drivers/platform/chrome/cros_ec_typec.c      |  47 ++-
>  drivers/platform/chrome/cros_typec_altmode.c |   8 +-
>  drivers/usb/typec/Makefile                   |   2 +-
>  drivers/usb/typec/altmodes/displayport.c     |   6 +-
>  drivers/usb/typec/altmodes/thunderbolt.c     |   2 +-
>  drivers/usb/typec/class.c                    |   1 +
>  drivers/usb/typec/class.h                    |   2 +
>  drivers/usb/typec/mode_selection.c           | 308 +++++++++++++++++++
>  drivers/usb/typec/ucsi/Makefile              |   4 +
>  drivers/usb/typec/ucsi/cros_ec_ucsi.c        |  44 +++
>  drivers/usb/typec/ucsi/thunderbolt.c         | 199 ++++++++++++
>  drivers/usb/typec/ucsi/ucsi.c                |  56 +++-
>  drivers/usb/typec/ucsi/ucsi.h                |  27 ++
>  include/linux/usb/typec.h                    |   1 +
>  include/linux/usb/typec_altmode.h            |  43 +++
>  15 files changed, 728 insertions(+), 22 deletions(-)
>  create mode 100644 drivers/usb/typec/mode_selection.c
>  create mode 100644 drivers/usb/typec/ucsi/thunderbolt.c
> 
> -- 
> 2.52.0.158.g65b55ccf14-goog

-- 
heikki
Re: [PATCH RFC 0/8] USB Type-C alternate mode selection
Posted by Heikki Krogerus 1 month, 4 weeks ago
Thu, Dec 11, 2025 at 03:40:24PM +0200, Heikki Krogerus kirjoitti:
> Without going into the code review yet, I'm okay with this in general,
> except with the artificial SID for the USB4. I still don't understand
> why do you guys think we should use that instead of an USB4 specific
> device type?
> 
> I think somebody said earlier that the user space can't see the device
> type of the alt modes? If that's really the case, then I think there
> is some bigger issue here. Are you really sure that if you check the
> device type of an alternate mode for example with udevadm, it does not
> say DEVTYPE=typec_alternate_mode ?
> 
>         % udevadm info -q property --property=DEVTYPE /sys/bus/typec/devices/port0-partner.0
>         DEVTYPE=typec_alternate_mode

Or just use grep :)

        % grep DEVTYPE /sys/bus/typec/devices/port0-partner.0/uevent
        DEVTYPE=typec_alternate_mode

So, if that really does not work, then there is a bug somewhere that
we obviously need to fix.

Please note that the port altmodes are now also part of the bus.

Br,

-- 
heikki
Re: [PATCH RFC 0/8] USB Type-C alternate mode selection
Posted by Andrei Kuchynski 1 month, 3 weeks ago
On Thu, Dec 11, 2025 at 3:23 PM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> Thu, Dec 11, 2025 at 03:40:24PM +0200, Heikki Krogerus kirjoitti:
> > Without going into the code review yet, I'm okay with this in general,
> > except with the artificial SID for the USB4. I still don't understand
> > why do you guys think we should use that instead of an USB4 specific
> > device type?
> >
> > I think somebody said earlier that the user space can't see the device
> > type of the alt modes? If that's really the case, then I think there
> > is some bigger issue here. Are you really sure that if you check the
> > device type of an alternate mode for example with udevadm, it does not
> > say DEVTYPE=typec_alternate_mode ?
> >
> >         % udevadm info -q property --property=DEVTYPE /sys/bus/typec/devices/port0-partner.0
> >         DEVTYPE=typec_alternate_mode
>
> Or just use grep :)
>
>         % grep DEVTYPE /sys/bus/typec/devices/port0-partner.0/uevent
>         DEVTYPE=typec_alternate_mode
>
> So, if that really does not work, then there is a bug somewhere that
> we obviously need to fix.
>
> Please note that the port altmodes are now also part of the bus.
>
> Br,
>
> --
> heikki

Thank you for the review, Heikki.

The USB4 SID is utilized for distinguishing between USB4 and alternate
modes internally and is not exposed to user-space. This represents internal
implementation detail, for example the boolean variable `is_alternate`
could serve the same purpose as the SID.
This patch series introduces no new sysfs entries; the only new attribute,
`priority`, was introduced in the mode priority series, available at
https://lore.kernel.org/all/20251124124639.1101335-1-akuchynski@chromium.org/

It is possible to use already existing `usb_capabily` and `usb_mode`
attributes to manage USB4 mode, allowing verification of USB4 support on
both the port and the partner. The activation of USB4 is accomplished
through the implementation of the `enter_usb_mode` typec operation.

I would like your opinion on whether using a USB4 device type would be a
better approach.

Please note that patches 6 and 7 are not part of the mode selection series.
They are not yet complete and are provided only to demonstrate how the
entire feature should work.

I confirm there is no issue with the DEVTYPE. Thank you.

Thanks,
Andrei
Re: [PATCH RFC 0/8] USB Type-C alternate mode selection
Posted by Heikki Krogerus 1 month, 2 weeks ago
Hi,

Tue, Dec 16, 2025 at 03:57:40PM +0100, Andrei Kuchynski kirjoitti:
> On Thu, Dec 11, 2025 at 3:23 PM Heikki Krogerus
> <heikki.krogerus@linux.intel.com> wrote:
> >
> > Thu, Dec 11, 2025 at 03:40:24PM +0200, Heikki Krogerus kirjoitti:
> > > Without going into the code review yet, I'm okay with this in general,
> > > except with the artificial SID for the USB4. I still don't understand
> > > why do you guys think we should use that instead of an USB4 specific
> > > device type?
> > >
> > > I think somebody said earlier that the user space can't see the device
> > > type of the alt modes? If that's really the case, then I think there
> > > is some bigger issue here. Are you really sure that if you check the
> > > device type of an alternate mode for example with udevadm, it does not
> > > say DEVTYPE=typec_alternate_mode ?
> > >
> > >         % udevadm info -q property --property=DEVTYPE /sys/bus/typec/devices/port0-partner.0
> > >         DEVTYPE=typec_alternate_mode
> >
> > Or just use grep :)
> >
> >         % grep DEVTYPE /sys/bus/typec/devices/port0-partner.0/uevent
> >         DEVTYPE=typec_alternate_mode
> >
> > So, if that really does not work, then there is a bug somewhere that
> > we obviously need to fix.
> >
> > Please note that the port altmodes are now also part of the bus.
> >
> > Br,
> >
> > --
> > heikki
> 
> Thank you for the review, Heikki.
> 
> The USB4 SID is utilized for distinguishing between USB4 and alternate
> modes internally and is not exposed to user-space. This represents internal
> implementation detail, for example the boolean variable `is_alternate`
> could serve the same purpose as the SID.
> This patch series introduces no new sysfs entries; the only new attribute,
> `priority`, was introduced in the mode priority series, available at
> https://lore.kernel.org/all/20251124124639.1101335-1-akuchynski@chromium.org/
> 
> It is possible to use already existing `usb_capabily` and `usb_mode`
> attributes to manage USB4 mode, allowing verification of USB4 support on
> both the port and the partner. The activation of USB4 is accomplished
> through the implementation of the `enter_usb_mode` typec operation.
> 
> I would like your opinion on whether using a USB4 device type would be a
> better approach.

The device for the USB4 mode will need to have its own device type in
any case, but I'm indeed mainly concerned about how we expose the USB4
mode device to the user space.

As a kernel internal implementation detail the custom SID is probable
fine for now, although I was actually hoping that we could improve the
API a bit. So something like typec_register_mode() type of API. You
probable could introduce something like this for that API:

        struct typec_mode {
                /* enum typec_accessory         accessory; */
                enum usb_mode                   usb;      /* or just USB4 flag */
                struct typec_altmode_desc       *altmode; /* NULL with USB4 */
        };

> Please note that patches 6 and 7 are not part of the mode selection series.
> They are not yet complete and are provided only to demonstrate how the
> entire feature should work.

Got it.

> I confirm there is no issue with the DEVTYPE. Thank you.

Okay, good. So there are no bugs at least :)

Br,

-- 
heikki
Re: [PATCH RFC 0/8] USB Type-C alternate mode selection
Posted by Andrei Kuchynski 1 month ago
On Tue, Dec 23, 2025 at 12:17 PM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> Hi,
>
> Tue, Dec 16, 2025 at 03:57:40PM +0100, Andrei Kuchynski kirjoitti:
> > On Thu, Dec 11, 2025 at 3:23 PM Heikki Krogerus
> > <heikki.krogerus@linux.intel.com> wrote:
> > >
> > > Thu, Dec 11, 2025 at 03:40:24PM +0200, Heikki Krogerus kirjoitti:
> > > > Without going into the code review yet, I'm okay with this in general,
> > > > except with the artificial SID for the USB4. I still don't understand
> > > > why do you guys think we should use that instead of an USB4 specific
> > > > device type?
> > > >
> > > > I think somebody said earlier that the user space can't see the device
> > > > type of the alt modes? If that's really the case, then I think there
> > > > is some bigger issue here. Are you really sure that if you check the
> > > > device type of an alternate mode for example with udevadm, it does not
> > > > say DEVTYPE=typec_alternate_mode ?
> > > >
> > > >         % udevadm info -q property --property=DEVTYPE /sys/bus/typec/devices/port0-partner.0
> > > >         DEVTYPE=typec_alternate_mode
> > >
> > > Or just use grep :)
> > >
> > >         % grep DEVTYPE /sys/bus/typec/devices/port0-partner.0/uevent
> > >         DEVTYPE=typec_alternate_mode
> > >
> > > So, if that really does not work, then there is a bug somewhere that
> > > we obviously need to fix.
> > >
> > > Please note that the port altmodes are now also part of the bus.
> > >
> > > Br,
> > >
> > > --
> > > heikki
> >
> > Thank you for the review, Heikki.
> >
> > The USB4 SID is utilized for distinguishing between USB4 and alternate
> > modes internally and is not exposed to user-space. This represents internal
> > implementation detail, for example the boolean variable `is_alternate`
> > could serve the same purpose as the SID.
> > This patch series introduces no new sysfs entries; the only new attribute,
> > `priority`, was introduced in the mode priority series, available at
> > https://lore.kernel.org/all/20251124124639.1101335-1-akuchynski@chromium.org/
> >
> > It is possible to use already existing `usb_capabily` and `usb_mode`
> > attributes to manage USB4 mode, allowing verification of USB4 support on
> > both the port and the partner. The activation of USB4 is accomplished
> > through the implementation of the `enter_usb_mode` typec operation.
> >
> > I would like your opinion on whether using a USB4 device type would be a
> > better approach.
>
> The device for the USB4 mode will need to have its own device type in
> any case, but I'm indeed mainly concerned about how we expose the USB4
> mode device to the user space.
>
> As a kernel internal implementation detail the custom SID is probable
> fine for now, although I was actually hoping that we could improve the
> API a bit. So something like typec_register_mode() type of API. You
> probable could introduce something like this for that API:
>
>         struct typec_mode {
>                 /* enum typec_accessory         accessory; */
>                 enum usb_mode                   usb;      /* or just USB4 flag */
>                 struct typec_altmode_desc       *altmode; /* NULL with USB4 */
>         };

Got it.
If you don’t have objections regarding the mode selection, I will proceed
with sending the current patch series, omitting the USB4 support.
The support for USB4 mode will be in a subsequent series.

Thanks,
Andrei
Re: [PATCH RFC 0/8] USB Type-C alternate mode selection
Posted by Heikki Krogerus 4 weeks, 1 day ago
Wed, Jan 07, 2026 at 10:02:45AM +0100, Andrei Kuchynski kirjoitti:
> On Tue, Dec 23, 2025 at 12:17 PM Heikki Krogerus
> <heikki.krogerus@linux.intel.com> wrote:
> >
> > Hi,
> >
> > Tue, Dec 16, 2025 at 03:57:40PM +0100, Andrei Kuchynski kirjoitti:
> > > On Thu, Dec 11, 2025 at 3:23 PM Heikki Krogerus
> > > <heikki.krogerus@linux.intel.com> wrote:
> > > >
> > > > Thu, Dec 11, 2025 at 03:40:24PM +0200, Heikki Krogerus kirjoitti:
> > > > > Without going into the code review yet, I'm okay with this in general,
> > > > > except with the artificial SID for the USB4. I still don't understand
> > > > > why do you guys think we should use that instead of an USB4 specific
> > > > > device type?
> > > > >
> > > > > I think somebody said earlier that the user space can't see the device
> > > > > type of the alt modes? If that's really the case, then I think there
> > > > > is some bigger issue here. Are you really sure that if you check the
> > > > > device type of an alternate mode for example with udevadm, it does not
> > > > > say DEVTYPE=typec_alternate_mode ?
> > > > >
> > > > >         % udevadm info -q property --property=DEVTYPE /sys/bus/typec/devices/port0-partner.0
> > > > >         DEVTYPE=typec_alternate_mode
> > > >
> > > > Or just use grep :)
> > > >
> > > >         % grep DEVTYPE /sys/bus/typec/devices/port0-partner.0/uevent
> > > >         DEVTYPE=typec_alternate_mode
> > > >
> > > > So, if that really does not work, then there is a bug somewhere that
> > > > we obviously need to fix.
> > > >
> > > > Please note that the port altmodes are now also part of the bus.
> > > >
> > > > Br,
> > > >
> > > > --
> > > > heikki
> > >
> > > Thank you for the review, Heikki.
> > >
> > > The USB4 SID is utilized for distinguishing between USB4 and alternate
> > > modes internally and is not exposed to user-space. This represents internal
> > > implementation detail, for example the boolean variable `is_alternate`
> > > could serve the same purpose as the SID.
> > > This patch series introduces no new sysfs entries; the only new attribute,
> > > `priority`, was introduced in the mode priority series, available at
> > > https://lore.kernel.org/all/20251124124639.1101335-1-akuchynski@chromium.org/
> > >
> > > It is possible to use already existing `usb_capabily` and `usb_mode`
> > > attributes to manage USB4 mode, allowing verification of USB4 support on
> > > both the port and the partner. The activation of USB4 is accomplished
> > > through the implementation of the `enter_usb_mode` typec operation.
> > >
> > > I would like your opinion on whether using a USB4 device type would be a
> > > better approach.
> >
> > The device for the USB4 mode will need to have its own device type in
> > any case, but I'm indeed mainly concerned about how we expose the USB4
> > mode device to the user space.
> >
> > As a kernel internal implementation detail the custom SID is probable
> > fine for now, although I was actually hoping that we could improve the
> > API a bit. So something like typec_register_mode() type of API. You
> > probable could introduce something like this for that API:
> >
> >         struct typec_mode {
> >                 /* enum typec_accessory         accessory; */
> >                 enum usb_mode                   usb;      /* or just USB4 flag */
> >                 struct typec_altmode_desc       *altmode; /* NULL with USB4 */
> >         };
> 
> Got it.
> If you don’t have objections regarding the mode selection, I will proceed
> with sending the current patch series, omitting the USB4 support.
> The support for USB4 mode will be in a subsequent series.

No objections :)


-- 
heikki