From 288d2854d983fda307f1971067136fb00cce150b Mon Sep 17 00:00:00 2001 From: "M, Madhu" Date: Fri, 4 Sep 2026 09:08:50 +0000 Subject: [PATCH] ucsicontrol changes - Replaced the unavailable Intel UCSI PDF reference with the USB-IF UCSI specification page: https://www.usb.org/document-library/usb-type-cr-connector-system-software-interface-ucsi-specification - Updated UCSI diagnostics and the parser comment to use the argument names from the command help: ``, `

`, ``, ``, ``, ``, ``, ``, and ``. - Added an `Arguments` section to the command help defining each placeholder and its accepted values. - Added definitions for every placeholder directly to the argument-related `error_exit()` messages. - Standardized all argument-validation diagnostics on `requires` wording. - Reverted the alternate-mode completion output to its original message format. - Clarified the `get_lpm_ppm_info` help text as LPM/PPM vendor, product, and firmware information. --- toys/other/ucsicontrol.c | 51 ++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/toys/other/ucsicontrol.c b/toys/other/ucsicontrol.c index bba4b9d7..8e5702bc 100644 --- a/toys/other/ucsicontrol.c +++ b/toys/other/ucsicontrol.c @@ -2,7 +2,7 @@ * * Copyright 2026 Madhu M * - * See https://www.intel.com/content/dam/www/public/us/en/documents/technical-specs/usb-type-c-connector-system-software-interface-spec.pdf + * See https://www.usb.org/document-library/usb-type-cr-connector-system-software-interface-ucsi-specification * * Talks directly to the kernel UCSI debugfs interface exposed under * /sys/kernel/debug/usb/ucsi/.../{command,response}. @@ -33,7 +33,7 @@ config UCSICONTROL get_pdos

Get advertised power profiles (voltage/ current) where P=partner, O=offset, S=src/sink, T=type - get_lpm_ppm_info Get PPM vendor/product/firmware info + get_lpm_ppm_info Get LPM/PPM vendor/product/firmware info get_error_status Get connector error status set_uor Trigger USB data role swap (DFP|UFP|Accept) set_pdr Trigger power role swap (SRC|SNK|Accept) @@ -41,8 +41,19 @@ config UCSICONTROL set_new_cam Set alternate mode; S=am_specific, E=enter|exit connector_reset Reset stuck Type-C connector - is the connector number (0-based). Use get_capability to list available - connectors on your system. + Arguments: + N Connector number (0-based) + R Alternate-mode recipient: conn, sop, sopprime, or sopprimeprime + P PDO partner: 0=partner, 1=cable plug + O PDO offset + S PDO source/sink selector, or CAM-specific data for set_new_cam + T PDO type + Role Data role: DFP, UFP, or Accept; power role: SRC, SNK, or Accept + Mode CC mode: Rd, Rp, or DRP + CAM Alternate-mode number + E CAM action: enter or exit + + Use get_capability to list available connectors on your system. */ #define FOR_ucsicontrol @@ -454,10 +465,10 @@ static int role_code(char *s, char *a, char *b, char *c, int va, int vb, int vc) error_exit("Invalid type: %s", s); } -// Common parser for single-connector commands. +// Common parser for single-connector commands. static int required_conn(char **args, char *op) { - if (!args[1]) error_exit("%s requires a connector number (0-based)", op); + if (!args[1]) error_exit("%s requires (connector number, 0-based)", op); return get_conn(args[1]); } @@ -506,15 +517,15 @@ void ucsicontrol_main(void) unsigned char prev[256]; if (!args[1] || !args[2]) - error_exit("Usage: get_alternate_modes " - "[conn|sop|sopprime|sopprimeprime]"); + error_exit("get_alternate_modes requires " + "(N=connector number, R=conn|sop|sopprime|sopprimeprime)"); conn = get_conn(args[1]); if (!strcmp(args[2], "conn")) recipient = 0; else if (!strcmp(args[2], "sop")) recipient = 1; else if (!strcmp(args[2], "sopprime")) recipient = 2; else if (!strcmp(args[2], "sopprimeprime")) recipient = 3; - else error_exit("Usage: get_alternate_modes " - ""); + else error_exit("get_alternate_modes requires " + "(N=connector number, R=conn|sop|sopprime|sopprimeprime)"); for (;;) { // GET_ALTERNATE_MODES (0x0C): Recipient[16], ConnNum[24], // AltModeOffset[32], NumAltModes[40]=1 -> up to 2 modes per call. @@ -563,8 +574,8 @@ void ucsicontrol_main(void) unsigned ppdo = 0, pdo; if (!args[1] || !args[2] || !args[3] || !args[4] || !args[5]) - error_exit("get_pdos needs " - ""); + error_exit("get_pdos requires

" + "(N=connector, P=partner, O=offset, S=source/sink, T=type)"); conn = get_conn(args[1]); partner = atolx(args[2]); offset = atolx(args[3]); @@ -603,7 +614,8 @@ void ucsicontrol_main(void) int rst; if (!args[1] || !args[2]) - error_exit("connector_reset needs "); + error_exit("connector_reset requires " + "(N=connector number)"); conn = get_conn(args[1]); rst = role_code(args[2], "soft", "hard", "", 0, 1, -1); n = ucsi_cmd(UCSI_CMD_CONNECTOR_RESET | UCSI_CMD_CONNECTOR(conn) @@ -614,7 +626,8 @@ void ucsicontrol_main(void) int uor; if (!args[1] || !args[2]) - error_exit("set_uor needs "); + error_exit("set_uor requires " + "(N=connector, Role=DFP|UFP|Accept)"); conn = get_conn(args[1]); uor = role_code(args[2], "DFP", "UFP", "Accept", 1, 2, 4); n = ucsi_cmd(UCSI_CMD_SET_UOR | UCSI_CMD_CONNECTOR(conn) @@ -625,7 +638,8 @@ void ucsicontrol_main(void) int pdr; if (!args[1] || !args[2]) - error_exit("set_pdr needs "); + error_exit("set_pdr requires " + "(N=connector, Role=SRC|SNK|Accept)"); conn = get_conn(args[1]); pdr = role_code(args[2], "SRC", "SNK", "Accept", 1, 2, 4); n = ucsi_cmd(UCSI_CMD_SET_PDR | UCSI_CMD_CONNECTOR(conn) | (pdr<<23), @@ -636,7 +650,8 @@ void ucsicontrol_main(void) int ccom; if (!args[1] || !args[2]) - error_exit("set_ccom needs "); + error_exit("set_ccom requires " + "(N=connector, Mode=Rd|Rp|DRP)"); conn = get_conn(args[1]); ccom = role_code(args[2], "Rd", "Rp", "DRP", 1, 2, 4); n = ucsi_cmd(UCSI_CMD_SET_CCOM | UCSI_CMD_CONNECTOR(conn) | (ccom<<23), @@ -648,8 +663,8 @@ void ucsicontrol_main(void) unsigned amspec; if (!args[1] || !args[2] || !args[3] || !args[4]) - error_exit("set_new_cam needs " - ""); + error_exit("set_new_cam requires " + "(N=connector, CAM=alternate mode, S=am_specific, E=enter|exit)"); conn = get_conn(args[1]); newcam = atolx(args[2]); amspec = atolx(args[3]); -- 2.39.5