linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/10] USB Type-C mode selection
@ 2025-06-30 14:12 Andrei Kuchynski
  2025-06-30 14:12 ` [PATCH v2 01/10] usb: typec: Add alt_mode_override field to port property Andrei Kuchynski
                   ` (9 more replies)
  0 siblings, 10 replies; 18+ messages in thread
From: Andrei Kuchynski @ 2025-06-30 14:12 UTC (permalink / raw)
  To: Heikki Krogerus, Abhishek Pandit-Subedi, Benson Leung,
	Jameson Thies, Tzung-Bi Shih, linux-usb, chrome-platform
  Cc: Guenter Roeck, Greg Kroah-Hartman, Dmitry Baryshkov,
	Christian A. Ehrhardt, linux-kernel, Andrei Kuchynski

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


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2025-07-31 16:09 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30 14:12 [PATCH v2 00/10] USB Type-C mode selection Andrei Kuchynski
2025-06-30 14:12 ` [PATCH v2 01/10] usb: typec: Add alt_mode_override field to port property Andrei Kuchynski
2025-06-30 14:12 ` [PATCH v2 02/10] platform/chrome: cros_ec_typec: Set alt_mode_override flag Andrei Kuchynski
2025-06-30 14:12 ` [PATCH v2 03/10] usb: typec: ucsi: " Andrei Kuchynski
2025-06-30 14:12 ` [PATCH v2 04/10] usb: typec: Expose mode priorities via sysfs Andrei Kuchynski
2025-07-01  8:32   ` Greg Kroah-Hartman
2025-07-22 15:07     ` Andrei Kuchynski
2025-06-30 14:12 ` [PATCH v2 05/10] usb: typec: Implement automated mode selection Andrei Kuchynski
2025-07-01  3:59   ` kernel test robot
2025-07-01  8:40   ` Greg Kroah-Hartman
2025-07-22 15:08     ` Andrei Kuchynski
2025-07-24  8:39       ` Andrei Kuchynski
2025-07-31 16:09         ` Andrei Kuchynski
2025-06-30 14:12 ` [PATCH v2 06/10] usb: typec: Report altmode entry status via callback Andrei Kuchynski
2025-06-30 14:12 ` [PATCH v2 07/10] usb: typec: ucsi: displayport: Propagate DP altmode entry result Andrei Kuchynski
2025-06-30 14:12 ` [PATCH v2 08/10] platform/chrome: cros_ec_typec: Propagate " Andrei Kuchynski
2025-06-30 14:12 ` [PATCH v2 09/10] platform/chrome: cros_ec_typec: Report USB4 entry status via callback Andrei Kuchynski
2025-06-30 14:12 ` [PATCH v2 10/10] platform/chrome: cros_ec_typec: Add default_usb_mode_set support Andrei Kuchynski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).