From: Andrei Kuchynski <akuchynski@chromium.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
Benson Leung <bleung@chromium.org>,
Jameson Thies <jthies@google.com>,
Tzung-Bi Shih <tzungbi@kernel.org>,
linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev
Cc: Guenter Roeck <groeck@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
"Christian A. Ehrhardt" <lk@c--e.de>,
Abel Vesa <abel.vesa@linaro.org>,
Pooja Katiyar <pooja.katiyar@intel.com>,
Pavan Holla <pholla@chromium.org>, Madhu M <madhu.m@intel.com>,
Venkat Jayaraman <venkat.jayaraman@intel.com>,
linux-kernel@vger.kernel.org,
Andrei Kuchynski <akuchynski@chromium.org>
Subject: [PATCH RFC 6/8] usb: typec: ucsi: Implement enter_usb_mode operation
Date: Mon, 1 Dec 2025 12:26:02 +0000 [thread overview]
Message-ID: <20251201122604.1268071-7-akuchynski@chromium.org> (raw)
In-Reply-To: <20251201122604.1268071-1-akuchynski@chromium.org>
`enter_usb_mode` uses the SET_USB UCSI command to manage USB modes such as
USB3, and USB4 for current and future connections.
It allows port drivers and user-space applications (via the "usb_mode"
partner attribute) to enable and disable USB modes on a connector.
Signed-off-by: Andrei Kuchynski <akuchynski@chromium.org>
---
drivers/usb/typec/ucsi/ucsi.c | 22 ++++++++++++++++++++++
drivers/usb/typec/ucsi/ucsi.h | 3 +++
2 files changed, 25 insertions(+)
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index ee96c42e9e27..3d4c277bcd49 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -1624,7 +1624,29 @@ static int ucsi_pr_swap(struct typec_port *port, enum typec_role role)
return ret;
}
+static int ucsi_enter_usb_mode(struct typec_port *port, enum usb_mode mode)
+{
+ struct ucsi_connector *con = typec_get_drvdata(port);
+ u64 command;
+ int ret;
+
+ command = UCSI_SET_USB | UCSI_CONNECTOR_NUMBER(con->num);
+ if (mode == USB_MODE_USB3)
+ command |= UCSI_USB3_ENABLE;
+ else if (mode == USB_MODE_USB4)
+ command |= UCSI_USB4_ENABLE;
+
+ if (!ucsi_con_mutex_lock(con))
+ return -ENOTCONN;
+ con->ucsi->message_in_size = 0;
+ ret = ucsi_send_command(con->ucsi, command);
+ ucsi_con_mutex_unlock(con);
+
+ return ret;
+}
+
static const struct typec_operations ucsi_ops = {
+ .enter_usb_mode = ucsi_enter_usb_mode,
.dr_set = ucsi_dr_swap,
.pr_set = ucsi_pr_swap
};
diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
index 6e77bdbdaeae..a5ef35d9dce5 100644
--- a/drivers/usb/typec/ucsi/ucsi.h
+++ b/drivers/usb/typec/ucsi/ucsi.h
@@ -219,6 +219,9 @@ void ucsi_connector_change(struct ucsi *ucsi, u8 num);
#define UCSI_GET_PD_MESSAGE_TYPE_IDENTITY 4
#define UCSI_GET_PD_MESSAGE_TYPE_REVISION 5
+/* SET_USB command bits */
+#define UCSI_USB3_ENABLE ((u64)1 << 23)
+#define UCSI_USB4_ENABLE ((u64)1 << 24)
/* -------------------------------------------------------------------------- */
/* Error information returned by PPM in response to GET_ERROR_STATUS command. */
--
2.52.0.158.g65b55ccf14-goog
next prev parent reply other threads:[~2025-12-01 12:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 12:25 [PATCH RFC 0/8] USB Type-C alternate mode selection Andrei Kuchynski
2025-12-01 12:25 ` [PATCH RFC 1/8] usb: typec: Implement " Andrei Kuchynski
2025-12-01 12:25 ` [PATCH RFC 2/8] usb: typec: Integrate USB4 into the mode selection process Andrei Kuchynski
2025-12-01 12:25 ` [PATCH RFC 3/8] usb: typec: Introduce mode_selection bit Andrei Kuchynski
2025-12-01 12:26 ` [PATCH RFC 4/8] usb: typec: ucsi: Support mode selection to activate altmodes Andrei Kuchynski
2025-12-01 12:26 ` [PATCH RFC 5/8] usb: typec: ucsi: Enforce mode selection for cros_ec_ucsi Andrei Kuchynski
2025-12-01 12:26 ` Andrei Kuchynski [this message]
2025-12-01 12:26 ` [PATCH RFC 7/8] usb: typec: ucsi: Support for Thunderbolt alt mode Andrei Kuchynski
2025-12-01 12:26 ` [PATCH RFC 8/8] platform/chrome: cros_ec_typec: Enforce priority-based mode selection Andrei Kuchynski
2025-12-11 13:40 ` [PATCH RFC 0/8] USB Type-C alternate " Heikki Krogerus
2025-12-11 14:22 ` Heikki Krogerus
2025-12-16 14:57 ` Andrei Kuchynski
2025-12-23 11:16 ` Heikki Krogerus
2026-01-07 9:02 ` Andrei Kuchynski
2026-01-09 13:16 ` Heikki Krogerus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251201122604.1268071-7-akuchynski@chromium.org \
--to=akuchynski@chromium.org \
--cc=abel.vesa@linaro.org \
--cc=abhishekpandit@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jthies@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lk@c--e.de \
--cc=madhu.m@intel.com \
--cc=pholla@chromium.org \
--cc=pooja.katiyar@intel.com \
--cc=tzungbi@kernel.org \
--cc=venkat.jayaraman@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®