[PATCH v3 00/10] USB Type-C mode selection

Andrei Kuchynski posted 10 patches 2 months ago
Documentation/ABI/testing/sysfs-class-typec  |  72 +++
drivers/platform/chrome/cros_ec_typec.c      |  17 +
drivers/platform/chrome/cros_typec_altmode.c |  32 +-
drivers/platform/chrome/cros_typec_altmode.h |   6 +
drivers/usb/typec/Makefile                   |   2 +-
drivers/usb/typec/altmodes/displayport.c     |  17 +-
drivers/usb/typec/altmodes/thunderbolt.c     |   8 +
drivers/usb/typec/class.c                    | 212 ++++++-
drivers/usb/typec/class.h                    |  15 +
drivers/usb/typec/mode_selection.c           | 575 +++++++++++++++++++
drivers/usb/typec/mode_selection.h           |  54 ++
drivers/usb/typec/ucsi/displayport.c         |  10 +-
drivers/usb/typec/ucsi/ucsi.c                |   2 +
include/linux/usb/pd_vdo.h                   |   2 +
include/linux/usb/typec.h                    |   1 +
include/linux/usb/typec_altmode.h            |  12 +
include/linux/usb/typec_dp.h                 |   2 +
include/linux/usb/typec_tbt.h                |   3 +
18 files changed, 1024 insertions(+), 18 deletions(-)
create mode 100644 drivers/usb/typec/mode_selection.c
create mode 100644 drivers/usb/typec/mode_selection.h
[PATCH v3 00/10] USB Type-C mode selection
Posted by Andrei Kuchynski 2 months ago
This patch series introduces a flexible mechanism for USB Type-C mode
selection, enabling into USB4 mode, Thunderbolt alternate mode, or
DisplayPort alternate mode.

New sysfs attributes are exposed to provide user control over mode
selection:
`priority`, `usb4_priority`: Allows users to define their preferred order
for attempting mode entry.
`mode_priorities`: Lists the modes supported by the port, ordered by
priority.
`mode_selection`: Lists modes supported by the partner and triggers an
automatic mode negotiation.
`entry_result`, `usb4_entry_result`: Reports the status of the last mode
selection attempt.

The mode selection logic attempts to enter prioritized modes sequentially.
A mode is considered successfully negotiated only when its alternate mode
driver explicitly reports a positive status. Alternate mode drivers are
required to report their mode entry status (either successful or failed).
If the driver does not report its status within a defined timeout period,
the system automatically proceeds to attempt entry into the next preferred
mode.

This series was tested on a ChromeOS Brya device running kernel 6.6, and on
an Android OS device with kernel 6.16.

Changes in v3:
- The mode_priorities sysfs attribute has been made read-only.
- The mode_selection attribute now exclusively lists partner-supported
modes, with mode entry results reported via separate attributes.
- The driver returns mode entry results instead of error codes.
- Constant values are used in place of module parameters.

Andrei Kuchynski (10):
  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: Expose mode priorities via sysfs
  usb: typec: Implement automated mode selection
  usb: typec: Report altmode entry status via callback
  usb: typec: ucsi: displayport: Propagate DP altmode entry result
  platform/chrome: cros_ec_typec: Propagate altmode entry result
  platform/chrome: cros_ec_typec: Report USB4 entry status via callback
  platform/chrome: cros_ec_typec: Add default_usb_mode_set support

 Documentation/ABI/testing/sysfs-class-typec  |  72 +++
 drivers/platform/chrome/cros_ec_typec.c      |  17 +
 drivers/platform/chrome/cros_typec_altmode.c |  32 +-
 drivers/platform/chrome/cros_typec_altmode.h |   6 +
 drivers/usb/typec/Makefile                   |   2 +-
 drivers/usb/typec/altmodes/displayport.c     |  17 +-
 drivers/usb/typec/altmodes/thunderbolt.c     |   8 +
 drivers/usb/typec/class.c                    | 212 ++++++-
 drivers/usb/typec/class.h                    |  15 +
 drivers/usb/typec/mode_selection.c           | 575 +++++++++++++++++++
 drivers/usb/typec/mode_selection.h           |  54 ++
 drivers/usb/typec/ucsi/displayport.c         |  10 +-
 drivers/usb/typec/ucsi/ucsi.c                |   2 +
 include/linux/usb/pd_vdo.h                   |   2 +
 include/linux/usb/typec.h                    |   1 +
 include/linux/usb/typec_altmode.h            |  12 +
 include/linux/usb/typec_dp.h                 |   2 +
 include/linux/usb/typec_tbt.h                |   3 +
 18 files changed, 1024 insertions(+), 18 deletions(-)
 create mode 100644 drivers/usb/typec/mode_selection.c
 create mode 100644 drivers/usb/typec/mode_selection.h

-- 
2.50.1.565.gc32cd1483b-goog