[Toybox] Proposal: Add ucsicontrol (USB Type-C UCSI utility) to toybox

M, Madhu madhu.m at intel.com
Sat Aug 29 12:50:15 UTC 2026


Hi Rob,

Thanks for the follow-up. Let me address both points in detail:

1. What is ucsicontrol?
ucsicontrol is a user space command-line tool that talks to the kernel's UCSI (USB Type-C Connector System Software Interface) driver. It lets you query and control USB Type-C / USB Power Delivery (PD) state directly from the OS — without needing external hardware like a PD analyzer, oscilloscope, or Type-C breakout board.
UCSI is defined in its own standalone specification — the "USB Type-C Connector System Software Interface (UCSI) Specification" published by Intel. It defines how the OS communicates with the platform's embedded PPM (Platform Policy Manager) — usually firmware in the EC or a PD controller chip. Each physical Type-C port is exposed as a connector, and each connector's PD controller is the LPM (Local Policy Manager).
The tool operates in user space, communicating through debugfs interfaces with the kernel's OPM (Operating System Policy Manager), which in turn manages communication with the platform's PPM and underlying hardware controllers.

What you can inspect / do:
Capability
Description
Capability
Type-C port capabilities
Connector status
Whether a cable/device is attached, connected partner type
Power role
Source (providing power) vs Sink (consuming)
Data role
DFP (host) vs UFP (device)
Orientation / plug flip
Which CC line is active (CC1/CC2)
PDOs
Advertised source/sink power profiles (voltage/current)
RDO
The negotiated request (which PDO was selected, current level)
Alternate modes
DisplayPort / Thunderbolt alt-mode SVIDs and status
Cable info
Whether it's an e-marked cable, its capabilities
Role swap
Trigger PR_SWAP (power) / DR_SWAP (data) in software
Reset
Issue a connector/PPM reset to recover a stuck port

Typical commands:BASH
ucsicontrol get-capability               # PPM capabilities
ucsicontrol get-connector-capability 1   # Per-connector capability
ucsicontrol get-connector-status 1       # Live status (attach, roles, orientation)
ucsicontrol get-pdos 1                   # Advertised power profiles
ucsicontrol get-alternate-modes 1        # Cable/partner alternate modes
ucsicontrol set-uor 1 ...               # USB Operation Role swap
ucsicontrol set-pdr 1 ...               # Power Direction Role swap
ucsicontrol connector-reset 1           # Reset a stuck connector

2. Power On/Off USB Port — Not Possible with ucsicontrol:
I want to clarify that ucsicontrol cannot power on/off a USB port. It is specifically designed to interface with the UCSI layer, which manages Type-C connector state, USB Power Delivery (PD) negotiation, alternate modes, and connector/PPM resets. Power cycling a USB port (cutting VBUS to a connected device) is a hardware-level operation controlled by the platform's power management or a USB hub controller — not by UCSI. Tools like uhubctl are designed for that purpose on supported hardware.

3. Testing — Short-Term Approach (Real Hardware):
ucsicontrol communicates via the kernel's UCSI debugfs interface, introduced in Linux kernel 6.5 (drivers/usb/typec/ucsi/debugfs.c). It allows direct injection and testing of UCSI commands from userspace.

📝 Note: The latest Ubuntu and Android releases ship with Linux kernel 7.0, which includes full UCSI debugfs support. ucsicontrol has been completely tested and verified on both Ubuntu OS and Android OS, confirming it works reliably on these modern platforms out of the box.
Prerequisites:

  *   Linux kernel ≥ 6.5 (latest Ubuntu and Android ship with kernel 7.0)
  *   Kernel built with CONFIG_DEBUG_FS=y and CONFIG_TYPEC_UCSI=y
  *   A system with a UCSI-capable Type-C controller (most modern Intel platforms with Thunderbolt/USB4 qualify)
Steps to test on real hardware:
BASH
# 1. Check if debugfs is mounted
mount | grep debugfs

# 2. If not mounted, mount it manually
sudo mount -t debugfs none /sys/kernel/debug

# 3. Verify the UCSI debugfs interface is present
ls /sys/kernel/debug/usb/ucsi/
# Expected output: port1/ port2/ (one directory per Type-C connector)

# 4. Run ucsicontrol commands
ucsicontrol get-capability
ucsicontrol get-connector-status 1
ucsicontrol get-pdos 1
The /sys/kernel/debug/usb/ucsi/ path must be present and mounted in the filesystem — it is exposed by the UCSI kernel driver and provides the raw UCSI command/response interface that ucsicontrol reads from and writes to.

4. Long-Term / QEMU Testing:
I'll investigate whether a virtual/dummy UCSI kernel module can be created to simulate a UCSI PPM and expose the same debugfs interface under QEMU — this would be the ideal path for automated regression testing (make test_ucsicontrol). I'll update you once

I have more concrete progress on this.

Please let me know if you have any questions!

Regards, Madhu M





-----Original Message-----
From: Rob Landley <rob at landley.net>
Sent: 29 August 2026 04:10
To: M, Madhu <madhu.m at intel.com>; toybox <toybox at lists.landley.net>
Subject: Re: [Toybox] Proposal: Add ucsicontrol (USB Type-C UCSI utility) to toybox



On 8/26/26 03:24, M, Madhu wrote:

> Hi Rob,

>

> Ucsicontrol is still listed as pending.

> (https://codeberg.org/landley/toybox/src/branch/master/toys/pending/uc

> sicontrol.c) Please let me know what needs to be completed in order to

> move it forward.



I think last time I poked you I asked if there was any way to test it?

(Right now if I make any changes, I can't check for regressions.)



Personally useful to me would be a way to power on/off a usb port or device without physically unplugging and replugging it, but really anything reproducible would be nice. I just need to be able to test.



What would be _ideal_ would be some sort of QEMU or kernel virtual driver that I could use to do automated regression tests without needing a specific physical piece of hardware, but I'm aware that's a big ask.



Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox/attachments/20260829/23abf295/attachment-0001.htm>


More information about the Toybox mailing list