public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Cc: tzungbi@kernel.org, linux-usb@vger.kernel.org,
	chrome-platform@lists.linux.dev, dmitry.baryshkov@linaro.org,
	jthies@google.com, akuchynski@google.com, pmalani@chromium.org,
	Benson Leung <bleung@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Guenter Roeck <groeck@chromium.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/7] usb: typec: Add driver for Thunderbolt 3 Alternate Mode
Date: Thu, 31 Oct 2024 16:11:50 +0200	[thread overview]
Message-ID: <ZyOQJmF-PcFHgmeq@kuha.fi.intel.com> (raw)
In-Reply-To: <20241030142833.v2.1.I3080b036e8de0b9957c57c1c3059db7149c5e549@changeid>

Hi Abhishek,

On Wed, Oct 30, 2024 at 02:28:32PM -0700, Abhishek Pandit-Subedi wrote:
> From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> 
> Thunderbolt 3 Alternate Mode entry flow is described in
> USB Type-C Specification Release 2.0.
> 
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Co-developed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> ---
> 
> Changes:
> * Delay cable + plug checks so that the module doesn't fail to probe
>   if cable + plug information isn't available by the time the partner
>   altmode is registered.
> * Remove unncessary brace after if (IS_ERR(plug))
> 
> The rest of this patch should be the same as Heikki's original RFC.
> 
> 
> Changes in v2:
> - Use <linux/usb/typec_tbt.h> and add missing TBT_CABLE_ROUNDED
> - Pass struct typec_thunderbolt_data to typec_altmode_notify
> - Rename TYPEC_TBT_MODE to USB_TYPEC_TBT_MODE
> - Use USB_TYPEC_TBT_SID and USB_TYPEC_TBT_MODE for device id
> - Change module license to GPL due to checkpatch warning
> 
>  drivers/platform/chrome/cros_ec_typec.c  |   2 +-
>  drivers/usb/typec/altmodes/Kconfig       |   9 +
>  drivers/usb/typec/altmodes/Makefile      |   2 +
>  drivers/usb/typec/altmodes/thunderbolt.c | 308 +++++++++++++++++++++++
>  include/linux/usb/typec_tbt.h            |   3 +-
>  5 files changed, 322 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/usb/typec/altmodes/thunderbolt.c
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index c7781aea0b88..53d93baa36a8 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -499,7 +499,7 @@ static int cros_typec_enable_tbt(struct cros_typec_data *typec,
>  	}
>  
>  	port->state.data = &data;
> -	port->state.mode = TYPEC_TBT_MODE;
> +	port->state.mode = USB_TYPEC_TBT_MODE;
>  
>  	return typec_mux_set(port->mux, &port->state);
>  }

The definition should be changed in a separate patch.

> +static const struct typec_device_id tbt_typec_id[] = {
> +	{ USB_TYPEC_TBT_SID, USB_TYPEC_TBT_MODE },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(typec, tbt_typec_id);

Now the mode would be the same thing as connector state, which is not
true. The connector state is supposed to reflect the pin assignment,
and the mode is the mode index used with the actual VDMs. For example,
DP alt mode has several different states, but only one mode.

The TBT3 altmode driver will not work with this patch alone, it will
never bind to the partner TBT3 alt mode because the mode does not
match.

Can you reorganise this series so that the patch 2/7 comes before this
one? Then I think you can just use the SVID unless I'm mistaken:

        static const struct typec_device_id tbt_typec_id[] = {
		{ USB_TYPEC_TBT_SID },
		{ }
        };
        MODULE_DEVICE_TABLE(typec, tbt_typec_id);

Alternatively, just leave it to TYPEC_ANY_MODE for now.

> +static struct typec_altmode_driver tbt_altmode_driver = {
> +	.id_table = tbt_typec_id,
> +	.probe = tbt_altmode_probe,
> +	.remove = tbt_altmode_remove,
> +	.driver = {
> +		.name = "typec-thunderbolt",
> +		.owner = THIS_MODULE,
> +	}
> +};
> +module_typec_altmode_driver(tbt_altmode_driver);
> +
> +MODULE_AUTHOR("Heikki Krogerus <heikki.krogerus@linux.intel.com>");
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("Thunderbolt3 USB Type-C Alternate Mode");
> diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
> index fa97d7e00f5c..3ff82641f6a0 100644
> --- a/include/linux/usb/typec_tbt.h
> +++ b/include/linux/usb/typec_tbt.h
> @@ -10,7 +10,7 @@
>  #define USB_TYPEC_TBT_SID		USB_TYPEC_VENDOR_INTEL
>  
>  /* Connector state for Thunderbolt3 */
> -#define TYPEC_TBT_MODE			TYPEC_STATE_MODAL
> +#define USB_TYPEC_TBT_MODE		TYPEC_STATE_MODAL

I think USB_TYPEC_STATE_TBT would be better. But please change this in
a separate patch in any case.

thanks,

-- 
heikki

  parent reply	other threads:[~2024-10-31 14:11 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-30 21:28 [PATCH v2 0/7] Thunderbolt and DP altmode support for cros-ec-typec Abhishek Pandit-Subedi
2024-10-30 21:28 ` [PATCH v2 1/7] usb: typec: Add driver for Thunderbolt 3 Alternate Mode Abhishek Pandit-Subedi
2024-10-31  5:09   ` kernel test robot
2024-10-31 14:11   ` Heikki Krogerus [this message]
2024-10-31 23:02     ` Abhishek Pandit-Subedi
2024-11-01 13:16       ` Heikki Krogerus
2024-11-01 18:48         ` Abhishek Pandit-Subedi
2024-11-04 14:32           ` Heikki Krogerus
2024-11-07 19:21             ` Abhishek Pandit-Subedi
2024-10-30 21:28 ` [PATCH v2 2/7] usb: typec: Only use SVID for matching altmodes Abhishek Pandit-Subedi
2024-10-31 14:13   ` Heikki Krogerus
2024-10-30 21:28 ` [PATCH v2 3/7] usb: typec: Auto enter control for alternate modes Abhishek Pandit-Subedi
2024-10-31 14:33   ` Heikki Krogerus
2024-10-31 22:48     ` Abhishek Pandit-Subedi
2024-11-01 13:59       ` Heikki Krogerus
2024-11-01 16:53         ` Abhishek Pandit-Subedi
2024-11-04 14:14           ` Heikki Krogerus
2024-10-30 21:28 ` [PATCH v2 4/7] platform/chrome: cros_ec_typec: Update partner altmode active Abhishek Pandit-Subedi
2024-10-30 21:28 ` [PATCH v2 5/7] platform/chrome: cros_ec_typec: Displayport support Abhishek Pandit-Subedi
2024-10-31 17:48   ` kernel test robot
2024-10-31 18:54   ` Dmitry Baryshkov
2024-10-31 22:34     ` Abhishek Pandit-Subedi
2024-10-31 19:43   ` kernel test robot
2024-10-30 21:28 ` [PATCH v2 6/7] platform/chrome: cros_ec_typec: Thunderbolt support Abhishek Pandit-Subedi
2024-10-31 17:07   ` kernel test robot
2024-10-31 18:51   ` Dmitry Baryshkov
2024-10-31 22:23     ` Abhishek Pandit-Subedi
2024-10-30 21:28 ` [PATCH v2 7/7] platform/chrome: cros_ec_typec: Disable tbt auto_enter Abhishek Pandit-Subedi

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=ZyOQJmF-PcFHgmeq@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=abhishekpandit@chromium.org \
    --cc=akuchynski@google.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=groeck@chromium.org \
    --cc=jthies@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pmalani@chromium.org \
    --cc=tzungbi@kernel.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