[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260119131824.2529334-1-akuchynski@chromium.org>
Date: Mon, 19 Jan 2026 13:18:17 +0000
From: Andrei Kuchynski <akuchynski@...omium.org>
To: Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Abhishek Pandit-Subedi <abhishekpandit@...omium.org>,
Benson Leung <bleung@...omium.org>,
Jameson Thies <jthies@...gle.com>,
linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org,
chrome-platform@...ts.linux.dev
Cc: Tzung-Bi Shih <tzungbi@...nel.org>,
Guenter Roeck <groeck@...omium.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>,
Ćukasz Bartosik <ukaszb@...omium.org>,
Pooja Katiyar <pooja.katiyar@...el.com>,
Johan Hovold <johan@...nel.org>,
Hsin-Te Yuan <yuanhsinte@...omium.org>,
Madhu M <madhu.m@...el.com>,
Venkat Jayaraman <venkat.jayaraman@...el.com>,
Andrei Kuchynski <akuchynski@...omium.org>
Subject: [PATCH v5 0/7] USB Type-C mode selection
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.
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.19.0-rc4,
PDC: TI TPS6699, Realtek RTS5453.
Changes in V5:
- Use the no_mode_control field instead of
con->ucsi->cap.features & UCSI_CAP_ALT_MODE_OVERRIDE
- Squash previous V4 patches 3/8 and 7/8 into a single patch
- Adopt guard(mutex)(&sel->lock) in mode_selection_work_fn()
- Use dev_err instead of dev_dbg, remove the error message when exiting
the mode
- Update typec_altmode_state_update() to only reschedule the
mode_selection_work_fn task if it was successfully cancelled
- Clean up code style and alignment issues
Andrei Kuchynski (7):
usb: typec: Add mode_control field to port property
platform/chrome: cros_ec_typec: Set no_mode_control flag
usb: typec: Expose alternate mode priority via sysfs
usb: typec: Implement mode selection
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
Documentation/ABI/testing/sysfs-class-typec | 11 +
drivers/platform/chrome/cros_ec_typec.c | 1 +
drivers/usb/typec/Makefile | 2 +-
drivers/usb/typec/altmodes/displayport.c | 6 +-
drivers/usb/typec/altmodes/thunderbolt.c | 2 +-
drivers/usb/typec/class.c | 100 ++++++-
drivers/usb/typec/class.h | 3 +
drivers/usb/typec/mode_selection.c | 283 ++++++++++++++++++++
drivers/usb/typec/ucsi/cros_ec_ucsi.c | 22 ++
drivers/usb/typec/ucsi/ucsi.c | 12 +
drivers/usb/typec/ucsi/ucsi.h | 4 +
include/linux/usb/typec.h | 3 +
include/linux/usb/typec_altmode.h | 42 +++
13 files changed, 483 insertions(+), 8 deletions(-)
create mode 100644 drivers/usb/typec/mode_selection.c
--
2.52.0.457.g6b5491de43-goog
Powered by blists - more mailing lists