diff mbox series

[1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support

Message ID 20201110003716.5164-2-utkarsh.h.patel@intel.com (mailing list archive)
State Superseded
Headers show
Series Thunderbolt3/USB4 cable rounded and active cable plug link training support | expand

Commit Message

Patel, Utkarsh H Nov. 10, 2020, 12:37 a.m. UTC
Rounded and non-rounded Thunderbolt cables are represented by two bits as
per USB Type-C Connector specification v2.0 section F.2.6.
Corrected that in the Thunderbolt 3 cable discover mode VDO.

Fixes: ca469c292edc ("usb: typec: Add definitions for Thunderbolt 3 Alternate Mode")
Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
---
 include/linux/usb/typec_tbt.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Heikki Krogerus Nov. 10, 2020, 12:18 p.m. UTC | #1
On Mon, Nov 09, 2020 at 04:37:09PM -0800, Utkarsh Patel wrote:
> Rounded and non-rounded Thunderbolt cables are represented by two bits as
> per USB Type-C Connector specification v2.0 section F.2.6.
> Corrected that in the Thunderbolt 3 cable discover mode VDO.
> 
> Fixes: ca469c292edc ("usb: typec: Add definitions for Thunderbolt 3 Alternate Mode")

Hold on... Why is this tagged as a fix? What is it fixing?

Why do we even need this change? The field may have two bits, but
only one is used: "10b...11b = Reserved".

> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> ---
>  include/linux/usb/typec_tbt.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
> index 47c2d501ddce..aad648d14bb3 100644
> --- a/include/linux/usb/typec_tbt.h
> +++ b/include/linux/usb/typec_tbt.h
> @@ -40,11 +40,16 @@ struct typec_thunderbolt_data {
>  #define   TBT_CABLE_USB3_PASSIVE	2
>  #define   TBT_CABLE_10_AND_20GBPS	3
>  #define TBT_CABLE_ROUNDED		BIT(19)
> +#define TBT_CABLE_ROUNDED_SUPPORT(_vdo_) \
> +					(((_vdo_) & GENMASK(20, 19)) >> 19)
> +#define   TBT_GEN3_NON_ROUNDED                 0
> +#define   TBT_GEN3_GEN4_ROUNDED_NON_ROUNDED    1
>  #define TBT_CABLE_OPTICAL		BIT(21)
>  #define TBT_CABLE_RETIMER		BIT(22)
>  #define TBT_CABLE_LINK_TRAINING		BIT(23)
>  
>  #define TBT_SET_CABLE_SPEED(_s_)	(((_s_) & GENMASK(2, 0)) << 16)
> +#define TBT_SET_CABLE_ROUNDED(_g_)	(((_g_) & GENMASK(1, 0)) << 19)
>  
>  /* TBT3 Device Enter Mode VDO bits */
>  #define TBT_ENTER_MODE_CABLE_SPEED(s)	TBT_SET_CABLE_SPEED(s)

thanks,
Patel, Utkarsh H Nov. 11, 2020, 1:38 a.m. UTC | #2
Hi Heikki,

Thank you for the review.

> -----Original Message-----
> From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Sent: Tuesday, November 10, 2020 4:18 AM
> To: Patel, Utkarsh H <utkarsh.h.patel@intel.com>
> Cc: linux-kernel@vger.kernel.org; linux-usb@vger.kernel.org;
> pmalani@chromium.org; enric.balletbo@collabora.com; Mani, Rajmohan
> <rajmohan.mani@intel.com>; Shaikh, Azhar <azhar.shaikh@intel.com>
> Subject: Re: [PATCH 1/8] usb: typec: Correct the bit values for the Thunderbolt
> rounded/non-rounded cable support
> 
> On Mon, Nov 09, 2020 at 04:37:09PM -0800, Utkarsh Patel wrote:
> > Rounded and non-rounded Thunderbolt cables are represented by two bits
> > as per USB Type-C Connector specification v2.0 section F.2.6.
> > Corrected that in the Thunderbolt 3 cable discover mode VDO.
> >
> > Fixes: ca469c292edc ("usb: typec: Add definitions for Thunderbolt 3
> > Alternate Mode")
> 
> Hold on... Why is this tagged as a fix? What is it fixing?

Ack. I will remove the fix tag in v2. 

> 
> Why do we even need this change? The field may have two bits, but only one
> is used: "10b...11b = Reserved".

Today, only one bit is being used but as per the spec cable rounded support needs to be two bits field. 
There is no functional implication but since I am adding changes for rounded cable support hence trying to follow the spec. 

> 
> > Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> > ---
> >  include/linux/usb/typec_tbt.h | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/include/linux/usb/typec_tbt.h
> > b/include/linux/usb/typec_tbt.h index 47c2d501ddce..aad648d14bb3
> > 100644
> > --- a/include/linux/usb/typec_tbt.h
> > +++ b/include/linux/usb/typec_tbt.h
> > @@ -40,11 +40,16 @@ struct typec_thunderbolt_data {
> >  #define   TBT_CABLE_USB3_PASSIVE	2
> >  #define   TBT_CABLE_10_AND_20GBPS	3
> >  #define TBT_CABLE_ROUNDED		BIT(19)
> > +#define TBT_CABLE_ROUNDED_SUPPORT(_vdo_) \
> > +					(((_vdo_) & GENMASK(20, 19)) >> 19)
> > +#define   TBT_GEN3_NON_ROUNDED                 0
> > +#define   TBT_GEN3_GEN4_ROUNDED_NON_ROUNDED    1
> >  #define TBT_CABLE_OPTICAL		BIT(21)
> >  #define TBT_CABLE_RETIMER		BIT(22)
> >  #define TBT_CABLE_LINK_TRAINING		BIT(23)
> >
> >  #define TBT_SET_CABLE_SPEED(_s_)	(((_s_) & GENMASK(2, 0)) << 16)
> > +#define TBT_SET_CABLE_ROUNDED(_g_)	(((_g_) & GENMASK(1, 0)) <<
> 19)
> >
> >  /* TBT3 Device Enter Mode VDO bits */
> >  #define TBT_ENTER_MODE_CABLE_SPEED(s)	TBT_SET_CABLE_SPEED(s)
> 
> thanks,
> 
> --
> Heikki

Sincerely,
Utkarsh Patel.
diff mbox series

Patch

diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
index 47c2d501ddce..aad648d14bb3 100644
--- a/include/linux/usb/typec_tbt.h
+++ b/include/linux/usb/typec_tbt.h
@@ -40,11 +40,16 @@  struct typec_thunderbolt_data {
 #define   TBT_CABLE_USB3_PASSIVE	2
 #define   TBT_CABLE_10_AND_20GBPS	3
 #define TBT_CABLE_ROUNDED		BIT(19)
+#define TBT_CABLE_ROUNDED_SUPPORT(_vdo_) \
+					(((_vdo_) & GENMASK(20, 19)) >> 19)
+#define   TBT_GEN3_NON_ROUNDED                 0
+#define   TBT_GEN3_GEN4_ROUNDED_NON_ROUNDED    1
 #define TBT_CABLE_OPTICAL		BIT(21)
 #define TBT_CABLE_RETIMER		BIT(22)
 #define TBT_CABLE_LINK_TRAINING		BIT(23)
 
 #define TBT_SET_CABLE_SPEED(_s_)	(((_s_) & GENMASK(2, 0)) << 16)
+#define TBT_SET_CABLE_ROUNDED(_g_)	(((_g_) & GENMASK(1, 0)) << 19)
 
 /* TBT3 Device Enter Mode VDO bits */
 #define TBT_ENTER_MODE_CABLE_SPEED(s)	TBT_SET_CABLE_SPEED(s)