[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250630141239.3174390-1-akuchynski@chromium.org>
Date: Mon, 30 Jun 2025 14:12:29 +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>,
Tzung-Bi Shih <tzungbi@...nel.org>,
linux-usb@...r.kernel.org,
chrome-platform@...ts.linux.dev
Cc: Guenter Roeck <groeck@...omium.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Dmitry Baryshkov <lumag@...nel.org>,
"Christian A. Ehrhardt" <lk@...e.de>,
linux-kernel@...r.kernel.org,
Andrei Kuchynski <akuchynski@...omium.org>
Subject: [PATCH v2 00/10] USB Type-C mode selection
This patch series introduces a flexible mechanism for USB Type-C mode
selection, enabling into USB4 mode, Thunderbolt alternate mode, or
DisplayPort alternate mode.
Two new sysfs attributes are exposed to provide user control over mode
selection:
`mode_priorities`: Allows users to define their preferred order for
attempting mode entry.
`mode_selection`: Initiates an automatic mode entry process based on the
configured priorities and reports the outcome.
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.15.
Changes in v2:
- The `altmode_priorities` attribute has been renamed to `mode_priorities`.
Consequently, USB4 is no longer referred to as an alternate mode in the
code, comments, or documentation.
- Mode priorities are now set as a mode sequence, eliminating the need for
explicit numeric values, which simplifies configuration.
- The `mode_priorities` attribute no longer supports disabling modes.
Instead, this is now handled by using the `active` attribute of the port's
alt-mode and the `usb_capability` attribute.
- Changed `typec_mode_selection_reset` behavior. The function returns
EINPROGRESS if the entry process cannot be terminated immediately.
- Patch 6 from v1, which addressed a deadlock, has been removed as the fix
was already merged separately -
https://lore.kernel.org/r/20250624133246.3936737-1-akuchynski@chromium.org.
- `typec_svid_to_altmode` macro has been replaced with an inline function.
- Attempts to enter a specific mode are now limited when the operation
consistently returns an EBUSY error.
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 | 33 ++
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 | 94 +++-
drivers/usb/typec/class.h | 16 +
drivers/usb/typec/mode_selection.c | 529 +++++++++++++++++++
drivers/usb/typec/mode_selection.h | 49 ++
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, 820 insertions(+), 15 deletions(-)
create mode 100644 drivers/usb/typec/mode_selection.c
create mode 100644 drivers/usb/typec/mode_selection.h
--
2.50.0.727.gbf7dc18ff4-goog
Powered by blists - more mailing lists