[PATCH 0/2] usb: typec: hd3ss3220: Add sysfs interface for role state
From: Venkata Swamy Kassa
Date: Fri Feb 27 2026 - 13:50:40 EST
This patch series adds a sysfs interface to the HD3SS3220 Type-C controller
driver, allowing userspace to query the current USB role state.
Background
==========
The HD3SS3220 is a Type-C DRP (Dual Role Port) controller that detects cable
attachment and determines the port role based on CC pin logic. The driver
correctly propagates role changes to the USB controller via usb_role_switch,
but there is no mechanism for userspace to query the current state.
Problem
=======
When implementing udev rules to automatically start/stop USB gadget functions
based on cable connection:
1. In older kernels (5.15.x), the UDC subsystem emitted distinct "add" and
"remove" events that could be used to distinguish connect vs disconnect.
2. In newer kernels (6.6.x), only "change" events are emitted on the usb_role
subsystem, with no way to distinguish the actual role from the event itself.
Userspace needs to read the current role to determine the appropriate action
(start gadget for "device" role, stop gadget for "none" or "host" role).
Solution
========
Patch 1: Add a 'usb_role' sysfs attribute that exposes the current role as
a string. Also call sysfs_notify() and kobject_uevent() on role
changes to enable poll() and udev notifications.
Patch 2: Document the new sysfs attribute in Documentation/ABI/testing/.
Testing
=======
Tested on Variscite VAR-SOM-MX8M-PLUS with TI HD3SS3220 Type-C controller.
Cable connect/disconnect events correctly update the sysfs attribute and
trigger udev rules.
Venkata Swamy Kassa (2):
usb: typec: hd3ss3220: Add sysfs attribute for USB role state
Documentation: ABI: Add usb_role sysfs for hd3ss3220
Documentation/ABI/testing/sysfs-driver-hd3ss3220 | 14 ++++++++
drivers/usb/typec/hd3ss3220.c | 32 +++++++++++++++++
2 files changed, 46 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-driver-hd3ss3220
--
2.34.1