[PATCH v2 0/5] USB Type-C alternate mode priorities

Andrei Kuchynski posted 5 patches 1 month, 1 week ago
There is a newer version of this series
Documentation/ABI/testing/sysfs-class-typec | 11 ++++++
drivers/platform/chrome/cros_ec_typec.c     |  1 +
drivers/usb/typec/Makefile                  |  2 +-
drivers/usb/typec/class.c                   | 41 +++++++++++++++++++--
drivers/usb/typec/class.h                   |  2 +
drivers/usb/typec/mode_selection.c          | 38 +++++++++++++++++++
drivers/usb/typec/mode_selection.h          |  6 +++
drivers/usb/typec/ucsi/ucsi.c               |  2 +
include/linux/usb/typec.h                   |  1 +
include/linux/usb/typec_altmode.h           |  1 +
10 files changed, 100 insertions(+), 5 deletions(-)
create mode 100644 drivers/usb/typec/mode_selection.c
create mode 100644 drivers/usb/typec/mode_selection.h
[PATCH v2 0/5] USB Type-C alternate mode priorities
Posted by Andrei Kuchynski 1 month, 1 week ago
This patch series introduces a mechanism for setting USB Type-C alternate
mode priorities. It allows the user to specify their preferred order for
mode selection, such as USB4, Thunderbolt, or DisplayPort.

A new sysfs attribute named 'priority' is exposed to provide user-space
control over the mode selection process.

This series was tested on a Android OS device running kernel 6.16.

Changes in v2:
- The priority variable is now a member of the typec_altmode struct
- typec_altmode2port is used to obtain the typec_port struct pointer
- Default priorities are now set based on the order of registration
- The mode_control capability is enabled by default
- The mode_selection_state struct will be introduced in a separate series
- svid will be used instead of the typec_mode_type enum

Andrei Kuchynski (5):
  usb: typec: Add alt_mode_override field to port property
  platform/chrome: cros_ec_typec: Set alt_mode_override flag
  usb: typec: ucsi: Set alt_mode_override flag
  usb: typec: Implement alternate mode priority handling
  usb: typec: Expose alternate mode priority via sysfs

 Documentation/ABI/testing/sysfs-class-typec | 11 ++++++
 drivers/platform/chrome/cros_ec_typec.c     |  1 +
 drivers/usb/typec/Makefile                  |  2 +-
 drivers/usb/typec/class.c                   | 41 +++++++++++++++++++--
 drivers/usb/typec/class.h                   |  2 +
 drivers/usb/typec/mode_selection.c          | 38 +++++++++++++++++++
 drivers/usb/typec/mode_selection.h          |  6 +++
 drivers/usb/typec/ucsi/ucsi.c               |  2 +
 include/linux/usb/typec.h                   |  1 +
 include/linux/usb/typec_altmode.h           |  1 +
 10 files changed, 100 insertions(+), 5 deletions(-)
 create mode 100644 drivers/usb/typec/mode_selection.c
 create mode 100644 drivers/usb/typec/mode_selection.h

-- 
2.51.0.rc2.233.g662b1ed5c5-goog
Re: [PATCH v2 0/5] USB Type-C alternate mode priorities
Posted by Heikki Krogerus 4 weeks ago
Hi Andrei,

On Mon, Aug 25, 2025 at 02:57:45PM +0000, Andrei Kuchynski wrote:
> This patch series introduces a mechanism for setting USB Type-C alternate
> mode priorities. It allows the user to specify their preferred order for
> mode selection, such as USB4, Thunderbolt, or DisplayPort.
> 
> A new sysfs attribute named 'priority' is exposed to provide user-space
> control over the mode selection process.
> 
> This series was tested on a Android OS device running kernel 6.16.
> 
> Changes in v2:
> - The priority variable is now a member of the typec_altmode struct
> - typec_altmode2port is used to obtain the typec_port struct pointer
> - Default priorities are now set based on the order of registration
> - The mode_control capability is enabled by default
> - The mode_selection_state struct will be introduced in a separate series
> - svid will be used instead of the typec_mode_type enum
> 
> Andrei Kuchynski (5):
>   usb: typec: Add alt_mode_override field to port property
>   platform/chrome: cros_ec_typec: Set alt_mode_override flag
>   usb: typec: ucsi: Set alt_mode_override flag
>   usb: typec: Implement alternate mode priority handling
>   usb: typec: Expose alternate mode priority via sysfs

I'm sorry for keeping you waiting. I think these are okay - although,
I had to put a few nitpicks :) but they are minor - but can you
include a patch where you use the priority member in a driver (maybe
cros_ec_typec.c)?

thanks,

-- 
heikki
Re: [PATCH v2 0/5] USB Type-C alternate mode priorities
Posted by Andrei Kuchynski 4 weeks ago
On Fri, Sep 5, 2025 at 1:57 PM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> Hi Andrei,
>
> On Mon, Aug 25, 2025 at 02:57:45PM +0000, Andrei Kuchynski wrote:
> > This patch series introduces a mechanism for setting USB Type-C alternate
> > mode priorities. It allows the user to specify their preferred order for
> > mode selection, such as USB4, Thunderbolt, or DisplayPort.
> >
> > A new sysfs attribute named 'priority' is exposed to provide user-space
> > control over the mode selection process.
> >
> > This series was tested on a Android OS device running kernel 6.16.
> >
> > Changes in v2:
> > - The priority variable is now a member of the typec_altmode struct
> > - typec_altmode2port is used to obtain the typec_port struct pointer
> > - Default priorities are now set based on the order of registration
> > - The mode_control capability is enabled by default
> > - The mode_selection_state struct will be introduced in a separate series
> > - svid will be used instead of the typec_mode_type enum
> >
> > Andrei Kuchynski (5):
> >   usb: typec: Add alt_mode_override field to port property
> >   platform/chrome: cros_ec_typec: Set alt_mode_override flag
> >   usb: typec: ucsi: Set alt_mode_override flag
> >   usb: typec: Implement alternate mode priority handling
> >   usb: typec: Expose alternate mode priority via sysfs
>
> I'm sorry for keeping you waiting. I think these are okay - although,
> I had to put a few nitpicks :) but they are minor - but can you
> include a patch where you use the priority member in a driver (maybe
> cros_ec_typec.c)?
>
> thanks,
>
> --
> heikki

Thank you for your review and feedback! I appreciate you taking the time to
provide these notes.

The patch using the priority member is part of a subsequent series that I
have ready. I will send it shortly. This functionality is implemented in
mode_selection.c to determine the mode order, and we plan to use it for
both the cros_ec_typec and UCSI implementations.

I will send a new v3 patch set shortly with the minor changes you suggested.

Thanks!
Andrei