From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Andrei Kuchynski <akuchynski@chromium.org>
Cc: "Abhishek Pandit-Subedi" <abhishekpandit@chromium.org>,
"Benson Leung" <bleung@chromium.org>,
"Jameson Thies" <jthies@google.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
chrome-platform@lists.linux.dev,
"Tzung-Bi Shih" <tzungbi@kernel.org>,
"Guenter Roeck" <groeck@chromium.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>,
"Łukasz Bartosik" <ukaszb@chromium.org>,
"Abel Vesa" <abel.vesa@linaro.org>,
"Pooja Katiyar" <pooja.katiyar@intel.com>,
"Johan Hovold" <johan@kernel.org>,
"Hsin-Te Yuan" <yuanhsinte@chromium.org>,
"Madhu M" <madhu.m@intel.com>,
"Venkat Jayaraman" <venkat.jayaraman@intel.com>
Subject: Re: [PATCH v4 7/8] usb: typec: ucsi: Support mode selection to activate altmodes
Date: Thu, 15 Jan 2026 16:59:19 +0200 [thread overview]
Message-ID: <aWkAx-QjfwQGJ6Eb@kuha> (raw)
In-Reply-To: <20260113130536.3068311-8-akuchynski@chromium.org>
Tue, Jan 13, 2026 at 01:05:35PM +0000, Andrei Kuchynski kirjoitti:
> If the ucsi port driver supports modes selection, it should implement
> `add_partner_altmodes` and `remove_partner_altmodes` ucsi operations. With
> these operations the driver can manage the mode selection process.
> Once partner altmodes are registered, `add_partner_altmodes` is called to
> start the mode selection. When the partner is unregistered,
> `remove_partner_altmodes` is supposed to stop any ongoing processes and
> clean up the resources.
>
> `typec_altmode_state_update` informes mode selection about the current mode
> of the Type-C connector.
>
> Signed-off-by: Andrei Kuchynski <akuchynski@chromium.org>
> ---
> drivers/usb/typec/ucsi/ucsi.c | 11 +++++++++++
> drivers/usb/typec/ucsi/ucsi.h | 4 ++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index deb210c066cb5..4a6e23b55b10c 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -314,6 +314,7 @@ void ucsi_altmode_update_active(struct ucsi_connector *con)
> {
> const struct typec_altmode *altmode = NULL;
> u64 command;
> + u16 svid = 0;
> int ret;
> u8 cur;
> int i;
> @@ -335,6 +336,10 @@ void ucsi_altmode_update_active(struct ucsi_connector *con)
> for (i = 0; con->partner_altmode[i]; i++)
> typec_altmode_update_active(con->partner_altmode[i],
> con->partner_altmode[i] == altmode);
> +
> + if (altmode)
> + svid = altmode->svid;
> + typec_altmode_state_update(con->partner, svid, 0);
> }
>
> static int ucsi_altmode_next_mode(struct typec_altmode **alt, u16 svid)
> @@ -609,6 +614,8 @@ static int ucsi_register_altmodes(struct ucsi_connector *con, u8 recipient)
> desc.vdo = alt[j].mid;
> desc.svid = alt[j].svid;
> desc.roles = TYPEC_PORT_DRD;
> + desc.mode_selection = con->ucsi->ops->add_partner_altmodes &&
> + con->ucsi->cap.features & UCSI_CAP_ALT_MODE_OVERRIDE;
Can't you just use that con->typec_cap.no_mode_control flag here?
Maybe also consider squashing that patch 3/8 into this one while at it.
> ret = ucsi_register_altmode(con, &desc, recipient);
> if (ret)
> @@ -831,6 +838,8 @@ static int ucsi_check_altmodes(struct ucsi_connector *con)
> if (con->partner_altmode[0]) {
> num_partner_am = ucsi_get_num_altmode(con->partner_altmode);
> typec_partner_set_num_altmodes(con->partner, num_partner_am);
> + if (con->ucsi->ops->add_partner_altmodes)
> + con->ucsi->ops->add_partner_altmodes(con);
> ucsi_altmode_update_active(con);
> return 0;
> } else {
> @@ -1119,6 +1128,8 @@ static void ucsi_unregister_partner(struct ucsi_connector *con)
> return;
>
> typec_set_mode(con->port, TYPEC_STATE_SAFE);
> + if (con->ucsi->ops->remove_partner_altmodes)
> + con->ucsi->ops->remove_partner_altmodes(con);
>
> typec_partner_set_usb_power_delivery(con->partner, NULL);
> ucsi_unregister_partner_pdos(con);
thanks,
--
heikki
next prev parent reply other threads:[~2026-01-15 14:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-13 13:05 [PATCH v4 0/8] USB Type-C mode selection Andrei Kuchynski
2026-01-13 13:05 ` [PATCH v4 1/8] usb: typec: Add mode_control field to port property Andrei Kuchynski
2026-01-13 13:05 ` [PATCH v4 2/8] platform/chrome: cros_ec_typec: Set no_mode_control flag Andrei Kuchynski
2026-01-13 13:05 ` [PATCH v4 3/8] usb: typec: ucsi: " Andrei Kuchynski
2026-01-13 13:05 ` [PATCH v4 4/8] usb: typec: Expose alternate mode priority via sysfs Andrei Kuchynski
2026-01-15 14:33 ` Heikki Krogerus
2026-01-16 11:21 ` Greg Kroah-Hartman
2026-01-17 19:25 ` Andrei Kuchynski
2026-01-13 13:05 ` [PATCH v4 5/8] usb: typec: Implement mode selection Andrei Kuchynski
2026-01-15 14:52 ` Heikki Krogerus
2026-01-17 19:28 ` Andrei Kuchynski
2026-01-13 13:05 ` [PATCH v4 6/8] usb: typec: Introduce mode_selection bit Andrei Kuchynski
2026-01-13 13:05 ` [PATCH v4 7/8] usb: typec: ucsi: Support mode selection to activate altmodes Andrei Kuchynski
2026-01-15 14:59 ` Heikki Krogerus [this message]
2026-01-17 19:34 ` Andrei Kuchynski
2026-01-13 13:05 ` [PATCH v4 8/8] usb: typec: ucsi: Enforce mode selection for cros_ec_ucsi Andrei Kuchynski
2026-01-14 14:52 ` [PATCH v4 0/8] USB Type-C mode selection Greg Kroah-Hartman
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=aWkAx-QjfwQGJ6Eb@kuha \
--to=heikki.krogerus@linux.intel.com \
--cc=abel.vesa@linaro.org \
--cc=abhishekpandit@chromium.org \
--cc=akuchynski@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=johan@kernel.org \
--cc=jthies@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=madhu.m@intel.com \
--cc=pooja.katiyar@intel.com \
--cc=tzungbi@kernel.org \
--cc=ukaszb@chromium.org \
--cc=venkat.jayaraman@intel.com \
--cc=yuanhsinte@chromium.org \
/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