public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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>,
	"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 v5 7/7] usb: typec: ucsi: Enforce mode selection for cros_ec_ucsi
Date: Tue, 20 Jan 2026 17:27:39 +0200	[thread overview]
Message-ID: <aW-e6_yEl6ON-5mk@kuha> (raw)
In-Reply-To: <20260119131824.2529334-8-akuchynski@chromium.org>

Mon, Jan 19, 2026 at 01:18:24PM +0000, Andrei Kuchynski kirjoitti:
> The mode selection sequence is initiated by the driver after all partner
> alternate modes have been successfully registered.
> When a partner is disconnected, the driver also stops the mode selection
> process and releases resources via `typec_mode_selection_delete`.
> 
> Signed-off-by: Andrei Kuchynski <akuchynski@chromium.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> Changes in V5:
> - Use the no_mode_control field instead of
>   con->ucsi->cap.features & UCSI_CAP_ALT_MODE_OVERRIDE
> 
>  drivers/usb/typec/ucsi/cros_ec_ucsi.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> index eed2a7d0ebc63..6bca2dce211cd 100644
> --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> @@ -16,6 +16,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  #include <linux/wait.h>
> +#include <linux/usb/typec_altmode.h>
>  
>  #include "ucsi.h"
>  
> @@ -33,6 +34,11 @@
>  /* Number of times to attempt recovery from a write timeout before giving up. */
>  #define WRITE_TMO_CTR_MAX	5
>  
> +/* Delay between mode entry/exit attempts, ms */
> +static const unsigned int mode_selection_delay = 1000;
> +/* Timeout for a mode entry attempt, ms */
> +static const unsigned int mode_selection_timeout = 4000;
> +
>  struct cros_ucsi_data {
>  	struct device *dev;
>  	struct ucsi *ucsi;
> @@ -134,6 +140,20 @@ static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd, u32 *cci,
>  	return ret;
>  }
>  
> +static void cros_ucsi_add_partner_altmodes(struct ucsi_connector *con)
> +{
> +	if (!con->typec_cap.no_mode_control)
> +		typec_mode_selection_start(con->partner,
> +					   mode_selection_delay,
> +					   mode_selection_timeout);
> +}
> +
> +static void cros_ucsi_remove_partner_altmodes(struct ucsi_connector *con)
> +{
> +	if (!con->typec_cap.no_mode_control)
> +		typec_mode_selection_delete(con->partner);
> +}
> +
>  static const struct ucsi_operations cros_ucsi_ops = {
>  	.read_version = cros_ucsi_read_version,
>  	.read_cci = cros_ucsi_read_cci,
> @@ -141,6 +161,8 @@ static const struct ucsi_operations cros_ucsi_ops = {
>  	.read_message_in = cros_ucsi_read_message_in,
>  	.async_control = cros_ucsi_async_control,
>  	.sync_control = cros_ucsi_sync_control,
> +	.add_partner_altmodes = cros_ucsi_add_partner_altmodes,
> +	.remove_partner_altmodes = cros_ucsi_remove_partner_altmodes,
>  };
>  
>  static void cros_ucsi_work(struct work_struct *work)
> -- 
> 2.52.0.457.g6b5491de43-goog

-- 
heikki

      reply	other threads:[~2026-01-20 15:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-19 13:18 [PATCH v5 0/7] USB Type-C mode selection Andrei Kuchynski
2026-01-19 13:18 ` [PATCH v5 1/7] usb: typec: Add mode_control field to port property Andrei Kuchynski
2026-01-19 13:18 ` [PATCH v5 2/7] platform/chrome: cros_ec_typec: Set no_mode_control flag Andrei Kuchynski
2026-01-19 13:18 ` [PATCH v5 3/7] usb: typec: Expose alternate mode priority via sysfs Andrei Kuchynski
2026-01-20 15:20   ` Heikki Krogerus
2026-01-19 13:18 ` [PATCH v5 4/7] usb: typec: Implement mode selection Andrei Kuchynski
2026-01-20 15:24   ` Heikki Krogerus
2026-01-19 13:18 ` [PATCH v5 5/7] usb: typec: Introduce mode_selection bit Andrei Kuchynski
2026-01-20 15:25   ` Heikki Krogerus
2026-01-19 13:18 ` [PATCH v5 6/7] usb: typec: ucsi: Support mode selection to activate altmodes Andrei Kuchynski
2026-01-20 15:26   ` Heikki Krogerus
2026-01-19 13:18 ` [PATCH v5 7/7] usb: typec: ucsi: Enforce mode selection for cros_ec_ucsi Andrei Kuchynski
2026-01-20 15:27   ` Heikki Krogerus [this message]

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=aW-e6_yEl6ON-5mk@kuha \
    --to=heikki.krogerus@linux.intel.com \
    --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