All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support
@ 2020-11-10  0:37 Utkarsh Patel
  2020-11-10  0:37 ` [PATCH 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support Utkarsh Patel
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Utkarsh Patel @ 2020-11-10  0:37 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

This patch series adds the support for Thunderbolt3/USB4 rounded and
non-rounded frequencies cables and fixes the active cable plug link
training support.

Utkarsh Patel (8):
  usb: typec: Correct the bit values for the Thunderbolt
    rounded/non-rounded cable support
  platform/chrome: cros_ec_typec: Correct the Thunderbolt
    rounded/non-rounded cable support
  usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits
  usb: typec: Remove one bit support for the Thunderbolt
    rounded/non-rounded cable
  usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB
    message
  platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode
    VDO in USB4 mode
  usb: typec: intel_pmc_mux: Configure active cable properties for USB4
  usb: typec: Remove active_link_training variable from Enter_USB
    message

 drivers/platform/chrome/cros_ec_typec.c | 17 +++++++++++++----
 drivers/usb/typec/mux/intel_pmc_mux.c   | 21 ++++++++++++++++++---
 include/linux/usb/typec.h               |  8 ++------
 include/linux/usb/typec_tbt.h           |  6 +++++-
 4 files changed, 38 insertions(+), 14 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support
  2020-11-10  0:37 [PATCH 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
@ 2020-11-10  0:37 ` Utkarsh Patel
  2020-11-10 12:18   ` Heikki Krogerus
  2020-11-10  0:37 ` [PATCH 2/8] platform/chrome: cros_ec_typec: Correct " Utkarsh Patel
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Utkarsh Patel @ 2020-11-10  0:37 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

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(+)

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)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/8] platform/chrome: cros_ec_typec: Correct the Thunderbolt rounded/non-rounded cable support
  2020-11-10  0:37 [PATCH 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
  2020-11-10  0:37 ` [PATCH 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support Utkarsh Patel
@ 2020-11-10  0:37 ` Utkarsh Patel
  2020-11-10 12:18   ` Heikki Krogerus
  2020-11-10  0:37 ` [PATCH 3/8] usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits Utkarsh Patel
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Utkarsh Patel @ 2020-11-10  0:37 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

Thunderbolt rounded/non-rounded cable support is two bits value. Correcting
it as per the Thunderbolt 3 cable discover mode VDO changes done in the
Thunderbolt 3 alternate mode header.

Fixes: 5b30bd35aab4 ("platform/chrome: cros_ec_typec: Add TBT compat support")
Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
---
 drivers/platform/chrome/cros_ec_typec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 31be31161350..8111ed1fc574 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -438,8 +438,7 @@ static int cros_typec_enable_tbt(struct cros_typec_data *typec,
 	if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
 		data.cable_mode |= TBT_CABLE_LINK_TRAINING;
 
-	if (pd_ctrl->cable_gen)
-		data.cable_mode |= TBT_CABLE_ROUNDED;
+	data.cable_mode |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
 
 	/* Enter Mode VDO */
 	data.enter_vdo = TBT_SET_CABLE_SPEED(pd_ctrl->cable_speed);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/8] usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits
  2020-11-10  0:37 [PATCH 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
  2020-11-10  0:37 ` [PATCH 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support Utkarsh Patel
  2020-11-10  0:37 ` [PATCH 2/8] platform/chrome: cros_ec_typec: Correct " Utkarsh Patel
@ 2020-11-10  0:37 ` Utkarsh Patel
  2020-11-10  0:37 ` [PATCH 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable Utkarsh Patel
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Utkarsh Patel @ 2020-11-10  0:37 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

Thunderbolt cable generation bits received as a part of Thunderbolt 3 cable
discover mode VDO needs to be configured for Thunderbolt rounded and
non-rounded cable support in the Thunderbolt alternate mode.

Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
---
 drivers/usb/typec/mux/intel_pmc_mux.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index d7f63b74c6b1..aa3211f1c4c3 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -256,6 +256,7 @@ static int
 pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)
 {
 	struct typec_thunderbolt_data *data = state->data;
+	u8 cable_rounded = TBT_CABLE_ROUNDED_SUPPORT(data->cable_mode);
 	u8 cable_speed = TBT_CABLE_SPEED(data->cable_mode);
 	struct altmode_req req = { };
 
@@ -284,6 +285,8 @@ pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)
 
 	req.mode_data |= PMC_USB_ALTMODE_CABLE_SPD(cable_speed);
 
+	req.mode_data |= PMC_USB_ALTMODE_TBT_GEN(cable_rounded);
+
 	return pmc_usb_command(port, (void *)&req, sizeof(req));
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable
  2020-11-10  0:37 [PATCH 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
                   ` (2 preceding siblings ...)
  2020-11-10  0:37 ` [PATCH 3/8] usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits Utkarsh Patel
@ 2020-11-10  0:37 ` Utkarsh Patel
  2020-11-10 12:19   ` Heikki Krogerus
  2020-11-10  0:37 ` [PATCH 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message Utkarsh Patel
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Utkarsh Patel @ 2020-11-10  0:37 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

Two bits support for the Thunderbolt rounded/non-rounded cable has been
added to the header file.
Hence, removing unused TBT_CABLE_ROUNDED definition from the header file.

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 | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
index aad648d14bb3..63dd44b72e0c 100644
--- a/include/linux/usb/typec_tbt.h
+++ b/include/linux/usb/typec_tbt.h
@@ -39,7 +39,6 @@ struct typec_thunderbolt_data {
 #define   TBT_CABLE_USB3_GEN1		1
 #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
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message
  2020-11-10  0:37 [PATCH 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
                   ` (3 preceding siblings ...)
  2020-11-10  0:37 ` [PATCH 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable Utkarsh Patel
@ 2020-11-10  0:37 ` Utkarsh Patel
  2020-11-10  0:37 ` [PATCH 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode Utkarsh Patel
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Utkarsh Patel @ 2020-11-10  0:37 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

USB4 also uses same cable properties as Thunderbolt 3 so use Thunderbolt 3
cable discover mode VDO to fill details such as active cable plug link
training and cable rounded support.

Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
---
 include/linux/usb/typec.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index 6be558045942..d91e09d9d91c 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -75,6 +75,7 @@ enum typec_orientation {
 /*
  * struct enter_usb_data - Enter_USB Message details
  * @eudo: Enter_USB Data Object
+ * @tbt_cable_vdo: TBT3 Cable Discover Mode Response
  * @active_link_training: Active Cable Plug Link Training
  *
  * @active_link_training is a flag that should be set with uni-directional SBRX
@@ -83,6 +84,7 @@ enum typec_orientation {
  */
 struct enter_usb_data {
 	u32			eudo;
+	u32			tbt_cable_vdo;
 	unsigned char		active_link_training:1;
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode
  2020-11-10  0:37 [PATCH 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
                   ` (4 preceding siblings ...)
  2020-11-10  0:37 ` [PATCH 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message Utkarsh Patel
@ 2020-11-10  0:37 ` Utkarsh Patel
  2020-11-10  0:37 ` [PATCH 7/8] usb: typec: intel_pmc_mux: Configure active cable properties for USB4 Utkarsh Patel
  2020-11-10  0:37 ` [PATCH 8/8] usb: typec: Remove active_link_training variable from Enter_USB message Utkarsh Patel
  7 siblings, 0 replies; 15+ messages in thread
From: Utkarsh Patel @ 2020-11-10  0:37 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

Configure Thunderbolt3/USB4 cable generation value by filing Thunderbolt 3
cable discover mode VDO to support rounded and non-rounded Thunderbolt3/
USB4 cables.
While we are here use Thunderbolt 3 cable discover mode VDO to fill active
cable plug link training value.

Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
---
 drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 8111ed1fc574..b7416e82c3b3 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -514,8 +514,18 @@ static int cros_typec_enable_usb4(struct cros_typec_data *typec,
 	else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
 		data.eudo |= EUDO_CABLE_TYPE_RE_TIMER << EUDO_CABLE_TYPE_SHIFT;
 
-	data.active_link_training = !!(pd_ctrl->control_flags &
-				       USB_PD_CTRL_ACTIVE_LINK_UNIDIR);
+	/*
+	 * This driver does not have access to the identity information or
+	 * capabilities of the cable, so we don't know is it a real USB4 or
+	 * TBT3 cable. Therefore pretending that it's always TBT3 cable by
+	 * filling the TBT3 Cable VDO.
+	 */
+	data.tbt_cable_vdo = TBT_MODE;
+
+	if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
+		data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;
+
+	data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
 
 	port->state.alt = NULL;
 	port->state.data = &data;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 7/8] usb: typec: intel_pmc_mux: Configure active cable properties for USB4
  2020-11-10  0:37 [PATCH 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
                   ` (5 preceding siblings ...)
  2020-11-10  0:37 ` [PATCH 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode Utkarsh Patel
@ 2020-11-10  0:37 ` Utkarsh Patel
  2020-11-10  0:37 ` [PATCH 8/8] usb: typec: Remove active_link_training variable from Enter_USB message Utkarsh Patel
  7 siblings, 0 replies; 15+ messages in thread
From: Utkarsh Patel @ 2020-11-10  0:37 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

Value received as a part of Thunderbolt 3 cable discover mode VDO needs
to be configured in the USB4 mode for the Thunderbolt rounded support and
active cable plug link training.

Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
---
 drivers/usb/typec/mux/intel_pmc_mux.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index aa3211f1c4c3..61feb358aad3 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -295,6 +295,7 @@ pmc_usb_mux_usb4(struct pmc_usb_port *port, struct typec_mux_state *state)
 {
 	struct enter_usb_data *data = state->data;
 	struct altmode_req req = { };
+	u8 cable_rounded;
 	u8 cable_speed;
 
 	if (IOM_PORT_ACTIVITY_IS(port->iom_status, TBT) ||
@@ -308,9 +309,6 @@ pmc_usb_mux_usb4(struct pmc_usb_port *port, struct typec_mux_state *state)
 	/* USB4 Mode */
 	req.mode_data = PMC_USB_ALTMODE_FORCE_LSR;
 
-	if (data->active_link_training)
-		req.mode_data |= PMC_USB_ALTMODE_ACTIVE_LINK;
-
 	req.mode_data |= (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT;
 	req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT;
 
@@ -322,6 +320,20 @@ pmc_usb_mux_usb4(struct pmc_usb_port *port, struct typec_mux_state *state)
 		fallthrough;
 	default:
 		req.mode_data |= PMC_USB_ALTMODE_ACTIVE_CABLE;
+
+		if (data->tbt_cable_vdo) {
+			/* Active Thunderbolt 3 cable */
+			if (data->tbt_cable_vdo & TBT_CABLE_LINK_TRAINING)
+				req.mode_data |= PMC_USB_ALTMODE_ACTIVE_LINK;
+
+			cable_rounded =
+				TBT_CABLE_ROUNDED_SUPPORT(data->tbt_cable_vdo);
+			req.mode_data |= PMC_USB_ALTMODE_TBT_GEN(cable_rounded);
+		} else {
+			/* Active USB4 cable */
+			req.mode_data |= PMC_USB_ALTMODE_ACTIVE_LINK |
+				PMC_USB_ALTMODE_TBT_GEN(1);
+		}
 		break;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 8/8] usb: typec: Remove active_link_training variable from Enter_USB message
  2020-11-10  0:37 [PATCH 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
                   ` (6 preceding siblings ...)
  2020-11-10  0:37 ` [PATCH 7/8] usb: typec: intel_pmc_mux: Configure active cable properties for USB4 Utkarsh Patel
@ 2020-11-10  0:37 ` Utkarsh Patel
  7 siblings, 0 replies; 15+ messages in thread
From: Utkarsh Patel @ 2020-11-10  0:37 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

Thunderbolt 3 cable discover mode VDO support has been added as part of
Enter_USB message to fill details of active cable plug link training.
Hence, removing unused variable active_link_training from Enter_USB
message data structure.

Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
---
 include/linux/usb/typec.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index d91e09d9d91c..4a9608a15ac1 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -76,16 +76,10 @@ enum typec_orientation {
  * struct enter_usb_data - Enter_USB Message details
  * @eudo: Enter_USB Data Object
  * @tbt_cable_vdo: TBT3 Cable Discover Mode Response
- * @active_link_training: Active Cable Plug Link Training
- *
- * @active_link_training is a flag that should be set with uni-directional SBRX
- * communication, and left 0 with passive cables and with bi-directional SBRX
- * communication.
  */
 struct enter_usb_data {
 	u32			eudo;
 	u32			tbt_cable_vdo;
-	unsigned char		active_link_training:1;
 };
 
 /*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support
  2020-11-10  0:37 ` [PATCH 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support Utkarsh Patel
@ 2020-11-10 12:18   ` Heikki Krogerus
  2020-11-11  1:38     ` Patel, Utkarsh H
  0 siblings, 1 reply; 15+ messages in thread
From: Heikki Krogerus @ 2020-11-10 12:18 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh

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,

-- 
heikki

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/8] platform/chrome: cros_ec_typec: Correct the Thunderbolt rounded/non-rounded cable support
  2020-11-10  0:37 ` [PATCH 2/8] platform/chrome: cros_ec_typec: Correct " Utkarsh Patel
@ 2020-11-10 12:18   ` Heikki Krogerus
  2020-11-11  1:38     ` Patel, Utkarsh H
  0 siblings, 1 reply; 15+ messages in thread
From: Heikki Krogerus @ 2020-11-10 12:18 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh

On Mon, Nov 09, 2020 at 04:37:10PM -0800, Utkarsh Patel wrote:
> Thunderbolt rounded/non-rounded cable support is two bits value. Correcting
> it as per the Thunderbolt 3 cable discover mode VDO changes done in the
> Thunderbolt 3 alternate mode header.
> 
> Fixes: 5b30bd35aab4 ("platform/chrome: cros_ec_typec: Add TBT compat support")

Again the fix tag?

> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> ---
>  drivers/platform/chrome/cros_ec_typec.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 31be31161350..8111ed1fc574 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -438,8 +438,7 @@ static int cros_typec_enable_tbt(struct cros_typec_data *typec,
>  	if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
>  		data.cable_mode |= TBT_CABLE_LINK_TRAINING;
>  
> -	if (pd_ctrl->cable_gen)
> -		data.cable_mode |= TBT_CABLE_ROUNDED;
> +	data.cable_mode |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
>  
>  	/* Enter Mode VDO */
>  	data.enter_vdo = TBT_SET_CABLE_SPEED(pd_ctrl->cable_speed);
> -- 
> 2.17.1

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable
  2020-11-10  0:37 ` [PATCH 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable Utkarsh Patel
@ 2020-11-10 12:19   ` Heikki Krogerus
  2020-11-11  1:38     ` Patel, Utkarsh H
  0 siblings, 1 reply; 15+ messages in thread
From: Heikki Krogerus @ 2020-11-10 12:19 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh

On Mon, Nov 09, 2020 at 04:37:12PM -0800, Utkarsh Patel wrote:
> Two bits support for the Thunderbolt rounded/non-rounded cable has been
> added to the header file.
> Hence, removing unused TBT_CABLE_ROUNDED definition from the header file.
> 
> Fixes: ca469c292edc ("usb: typec: Add definitions for Thunderbolt 3 Alternate Mode")

And again?

> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> ---
>  include/linux/usb/typec_tbt.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
> index aad648d14bb3..63dd44b72e0c 100644
> --- a/include/linux/usb/typec_tbt.h
> +++ b/include/linux/usb/typec_tbt.h
> @@ -39,7 +39,6 @@ struct typec_thunderbolt_data {
>  #define   TBT_CABLE_USB3_GEN1		1
>  #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

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: [PATCH 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support
  2020-11-10 12:18   ` Heikki Krogerus
@ 2020-11-11  1:38     ` Patel, Utkarsh H
  0 siblings, 0 replies; 15+ messages in thread
From: Patel, Utkarsh H @ 2020-11-11  1:38 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, Mani, Rajmohan,
	Shaikh, Azhar

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.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: [PATCH 2/8] platform/chrome: cros_ec_typec: Correct the Thunderbolt rounded/non-rounded cable support
  2020-11-10 12:18   ` Heikki Krogerus
@ 2020-11-11  1:38     ` Patel, Utkarsh H
  0 siblings, 0 replies; 15+ messages in thread
From: Patel, Utkarsh H @ 2020-11-11  1:38 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, Mani, Rajmohan,
	Shaikh, Azhar

Hi Heikki,

> -----Original Message-----
> From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Sent: Tuesday, November 10, 2020 4:19 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 2/8] platform/chrome: cros_ec_typec: Correct the
> Thunderbolt rounded/non-rounded cable support
> 
> On Mon, Nov 09, 2020 at 04:37:10PM -0800, Utkarsh Patel wrote:
> > Thunderbolt rounded/non-rounded cable support is two bits value.
> > Correcting it as per the Thunderbolt 3 cable discover mode VDO changes
> > done in the Thunderbolt 3 alternate mode header.
> >
> > Fixes: 5b30bd35aab4 ("platform/chrome: cros_ec_typec: Add TBT compat
> > support")
> 
> Again the fix tag?

Ack. I will remove the fix tag in v2.

> 
> > Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> > ---
> >  drivers/platform/chrome/cros_ec_typec.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/platform/chrome/cros_ec_typec.c
> > b/drivers/platform/chrome/cros_ec_typec.c
> > index 31be31161350..8111ed1fc574 100644
> > --- a/drivers/platform/chrome/cros_ec_typec.c
> > +++ b/drivers/platform/chrome/cros_ec_typec.c
> > @@ -438,8 +438,7 @@ static int cros_typec_enable_tbt(struct
> cros_typec_data *typec,
> >  	if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
> >  		data.cable_mode |= TBT_CABLE_LINK_TRAINING;
> >
> > -	if (pd_ctrl->cable_gen)
> > -		data.cable_mode |= TBT_CABLE_ROUNDED;
> > +	data.cable_mode |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
> >
> >  	/* Enter Mode VDO */
> >  	data.enter_vdo = TBT_SET_CABLE_SPEED(pd_ctrl->cable_speed);
> > --
> > 2.17.1
> 
> thanks,
> 
> --
> Heikki

Sincerely,
Utkarsh Patel.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: [PATCH 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable
  2020-11-10 12:19   ` Heikki Krogerus
@ 2020-11-11  1:38     ` Patel, Utkarsh H
  0 siblings, 0 replies; 15+ messages in thread
From: Patel, Utkarsh H @ 2020-11-11  1:38 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, Mani, Rajmohan,
	Shaikh, Azhar

Hi Heikki,

> -----Original Message-----
> From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Sent: Tuesday, November 10, 2020 4:20 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 4/8] usb: typec: Remove one bit support for the
> Thunderbolt rounded/non-rounded cable
> 
> On Mon, Nov 09, 2020 at 04:37:12PM -0800, Utkarsh Patel wrote:
> > Two bits support for the Thunderbolt rounded/non-rounded cable has
> > been added to the header file.
> > Hence, removing unused TBT_CABLE_ROUNDED definition from the header
> file.
> >
> > Fixes: ca469c292edc ("usb: typec: Add definitions for Thunderbolt 3
> > Alternate Mode")
> 
> And again?

Ack. I will remove the fix tag in v2.

> 
> > Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> > ---
> >  include/linux/usb/typec_tbt.h | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/include/linux/usb/typec_tbt.h
> > b/include/linux/usb/typec_tbt.h index aad648d14bb3..63dd44b72e0c
> > 100644
> > --- a/include/linux/usb/typec_tbt.h
> > +++ b/include/linux/usb/typec_tbt.h
> > @@ -39,7 +39,6 @@ struct typec_thunderbolt_data {
> >  #define   TBT_CABLE_USB3_GEN1		1
> >  #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
> 
> thanks,
> 
> --
> Heikki

Sincerely,
Utkarsh Patel.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-11-11  1:38 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10  0:37 [PATCH 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
2020-11-10  0:37 ` [PATCH 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support Utkarsh Patel
2020-11-10 12:18   ` Heikki Krogerus
2020-11-11  1:38     ` Patel, Utkarsh H
2020-11-10  0:37 ` [PATCH 2/8] platform/chrome: cros_ec_typec: Correct " Utkarsh Patel
2020-11-10 12:18   ` Heikki Krogerus
2020-11-11  1:38     ` Patel, Utkarsh H
2020-11-10  0:37 ` [PATCH 3/8] usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits Utkarsh Patel
2020-11-10  0:37 ` [PATCH 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable Utkarsh Patel
2020-11-10 12:19   ` Heikki Krogerus
2020-11-11  1:38     ` Patel, Utkarsh H
2020-11-10  0:37 ` [PATCH 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message Utkarsh Patel
2020-11-10  0:37 ` [PATCH 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode Utkarsh Patel
2020-11-10  0:37 ` [PATCH 7/8] usb: typec: intel_pmc_mux: Configure active cable properties for USB4 Utkarsh Patel
2020-11-10  0:37 ` [PATCH 8/8] usb: typec: Remove active_link_training variable from Enter_USB message Utkarsh Patel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.