public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] usb: typec: hd3ss3220: Add sysfs interface for role state
@ 2026-02-27 18:50 Venkata Swamy Kassa
  2026-02-27 18:50 ` [PATCH 1/2] kcsan: test: Adjust "expect" allocation type for kmalloc_obj Venkata Swamy Kassa
  2026-02-27 18:50 ` [PATCH 2/2] usb-typec-hd3ss3220-Add-sysfs-attribute-for-USB-role Venkata Swamy Kassa
  0 siblings, 2 replies; 5+ messages in thread
From: Venkata Swamy Kassa @ 2026-02-27 18:50 UTC (permalink / raw)
  To: heikki.krogerus, gregkh; +Cc: linux-usb, linux-kernel

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


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

end of thread, other threads:[~2026-02-27 20:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27 18:50 [PATCH 0/2] usb: typec: hd3ss3220: Add sysfs interface for role state Venkata Swamy Kassa
2026-02-27 18:50 ` [PATCH 1/2] kcsan: test: Adjust "expect" allocation type for kmalloc_obj Venkata Swamy Kassa
2026-02-27 20:27   ` Greg KH
2026-02-27 18:50 ` [PATCH 2/2] usb-typec-hd3ss3220-Add-sysfs-attribute-for-USB-role Venkata Swamy Kassa
2026-02-27 20:26   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox