summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorAyushee <ayushee.shah@intel.com>2020-04-06 14:21:19 -0700
committerCommit Bot <commit-bot@chromium.org>2020-05-27 02:04:40 +0000
commit3b7744e274ab7cbaf9e8ce05c542a6da7bd0cfc0 (patch)
treeffa921da482ea51bc6d8b93ffb0835bc3543b70d /driver
parent5e251579f921b6a3704d5c5218de22701340614f (diff)
downloadchrome-ec-3b7744e274ab7cbaf9e8ce05c542a6da7bd0cfc0.tar.gz
BB retimer: Refactor TBT retimer bits
For DFP, the following bits depend on the Discover Mode SOP and SOP' response. Bit 2: RE_TIMER_DRIVER Bit 17: TBT_TYPE, Bit 18: CABLE_TYPE, Bit 20: TBT_ACTIVE_LINK_TRAINING Bits 29-28: TBT_GEN_SUPPORT Hence setting these bits accordingly in "retimer_set_state_dfp()" function. Ref: Burnside Bridge spec Table 13: Connection state register BUG=b:152544514 BRANCH=None TEST=Able to see Thunderbolt getting enumerated on the CPU console Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I0172cd9c74ba37c0f3e87db55cbd58ebaeef5ebe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2139281 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/retimer/bb_retimer.c137
1 files changed, 84 insertions, 53 deletions
diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c
index 1314a4a0a8..45cbc8bf2a 100644
--- a/driver/retimer/bb_retimer.c
+++ b/driver/retimer/bb_retimer.c
@@ -114,9 +114,12 @@ static void bb_retimer_power_handle(const struct usb_mux *me, int on_off)
}
static void retimer_set_state_dfp(int port, mux_state_t mux_state,
- uint32_t *set_retimer_con,
- enum idh_ptype cable_type)
+ uint32_t *set_retimer_con)
{
+ union tbt_mode_resp_cable cable_resp;
+ union tbt_mode_resp_device dev_resp;
+ enum idh_ptype cable_type = get_usb_pd_cable_type(port);
+
if (mux_state & USB_PD_MUX_USB_ENABLED) {
/*
* Bit 4: USB2_CONNECTION (ignored if BIT5=0).
@@ -143,6 +146,60 @@ static void retimer_set_state_dfp(int port, mux_state_t mux_state,
(cable_type == IDH_PTYPE_ACABLE))
*set_retimer_con |= BB_RETIMER_ACTIVE_PASSIVE;
+ /* TODO: Bit 2: RE_TIMER_DRIVER for USB/DP/USB4 */
+
+ if (mux_state & USB_PD_MUX_TBT_COMPAT_ENABLED) {
+ cable_resp = get_cable_tbt_vdo(port);
+ dev_resp = get_dev_tbt_vdo(port);
+
+ /*
+ * Bit 2: RE_TIMER_DRIVER
+ * 0 - Re-driver
+ * 1 - Re-timer
+ *
+ * If Alternate mode is Thunderbolt-Compat, RE_TIMER_DRIVER is
+ * set according to Discover Mode SOP' response,
+ * Bit 22: Retimer Type.
+ */
+ if (cable_resp.retimer_type == USB_RETIMER)
+ *set_retimer_con |= BB_RETIMER_RE_TIMER_DRIVER;
+
+ /*
+ * Bit 17: TBT_TYPE
+ * 0 - Type-C to Type-C Cable
+ * 1 - Type-C Legacy TBT Adapter
+ */
+ if (dev_resp.tbt_adapter == TBT_ADAPTER_TBT2_LEGACY)
+ *set_retimer_con |= BB_RETIMER_TBT_TYPE;
+
+ /*
+ * Bit 18: CABLE_TYPE
+ * 0 - Electrical cable
+ * 1 - Optical cable
+ */
+ if (cable_resp.tbt_cable == TBT_CABLE_OPTICAL)
+ *set_retimer_con |= BB_RETIMER_TBT_CABLE_TYPE;
+
+ /*
+ * Bit 20: TBT_ACTIVE_LINK_TRAINING
+ * 0 - Active with bi-directional LSRX communication
+ * 1 - Active with uni-directional LSRX communication
+ * Set to "0" when passive cable plug
+ */
+ if (cable_type == IDH_PTYPE_ACABLE &&
+ cable_resp.lsrx_comm == UNIDIR_LSRX_COMM)
+ *set_retimer_con |= BB_RETIMER_TBT_ACTIVE_LINK_TRAINING;
+
+ /*
+ * Bits 29-28: TBT_GEN_SUPPORT
+ * 00b - 3rd generation TBT (10.3125 and 20.625Gb/s)
+ * 01b - 4th generation TBT (10.00005Gb/s, 10.3125Gb/s,
+ * 20.0625Gb/s, 20.000Gb/s)
+ * 10..11b - Reserved
+ */
+ *set_retimer_con |= BB_RETIMER_TBT_CABLE_GENERATION(
+ cable_resp.tbt_rounded);
+ }
}
static void retimer_set_state_ufp(mux_state_t mux_state,
@@ -165,13 +222,36 @@ static void retimer_set_state_ufp(mux_state_t mux_state,
*/
*set_retimer_con |= BB_RETIMER_USB_DATA_ROLE;
}
+
+ /*
+ * Bit 17: TBT_TYPE
+ * 0 - Type-C to Type-C Cable
+ * 1 - Type-C Legacy TBT Adapter
+ * For UFP, TBT_TYPE = 0
+ */
+
/*
* TODO: b/157163664: Add the following bits:
*
+ * Bit 2: RE_TIMER_DRIVER:
+ * Set according to b20:19 of enter USB.
+ *
+ * Bit 18: CABLE_TYPE:
+ * For Thunderbolt-compat mode, set according to bit 21 of enter mode.
+ * For USB/DP/USB4, set according to bits 20:19 of enter mode.
+ *
+ * Bit 20: TBT_ACTIVE_LINK_TRAINING:
+ * For Thunderbolt-compat mode, set according to bit 23 of enter mode.
+ * For USB, set to 0.
+ *
* Bit 22: ACTIVE/PASSIVE
* For USB4, set according to bits 20:19 of enter USB SOP.
* For thubderbolt-compat mode, set according to bit 24 of enter mode
* sop.
+ *
+ * Bits 29-28: TBT_GEN_SUPPORT
+ * For Thunderbolt-compat mode, set according to bits 20:19 of enter
+ * mode.
*/
}
@@ -184,8 +264,6 @@ static int retimer_set_state(const struct usb_mux *me, mux_state_t mux_state)
uint8_t dp_pin_mode;
int port = me->usb_port;
union tbt_mode_resp_cable cable_resp;
- union tbt_mode_resp_device dev_resp;
- enum idh_ptype cable_type = get_usb_pd_cable_type(port);
/*
* Bit 0: DATA_CONNECTION_PRESENT
@@ -258,61 +336,15 @@ static int retimer_set_state(const struct usb_mux *me, mux_state_t mux_state)
if (mux_state & (USB_PD_MUX_TBT_COMPAT_ENABLED |
USB_PD_MUX_USB4_ENABLED)) {
cable_resp = get_cable_tbt_vdo(port);
- dev_resp = get_dev_tbt_vdo(port);
-
- /*
- * Bit 2: RE_TIMER_DRIVER
- * 0 - Re-driver
- * 1 - Re-timer
- */
- if (cable_resp.retimer_type == USB_RETIMER)
- set_retimer_con |= BB_RETIMER_RE_TIMER_DRIVER;
/*
* Bit 16: TBT_CONNECTION
* 0 - TBT not configured
* 1 - TBT configured
*/
- if (mux_state & USB_PD_MUX_TBT_COMPAT_ENABLED) {
+ if (mux_state & USB_PD_MUX_TBT_COMPAT_ENABLED)
set_retimer_con |= BB_RETIMER_TBT_CONNECTION;
- /*
- * Bit 17: TBT_TYPE
- * 0 - Type-C to Type-C Cable
- * 1 - Type-C Legacy TBT Adapter
- */
- if (dev_resp.tbt_adapter == TBT_ADAPTER_TBT2_LEGACY)
- set_retimer_con |= BB_RETIMER_TBT_TYPE;
-
- /*
- * Bits 29-28: TBT_GEN_SUPPORT
- * 00b - 3rd generation TBT (10.3125 and 20.625Gb/s)
- * 01b - 4th generation TBT (10.00005Gb/s, 10.3125Gb/s,
- * 20.0625Gb/s, 20.000Gb/s)
- * 10..11b - Reserved
- */
- set_retimer_con |= BB_RETIMER_TBT_CABLE_GENERATION(
- cable_resp.tbt_rounded);
- }
-
- /*
- * Bit 18: CABLE_TYPE
- * 0 - Electrical cable
- * 1 - Optical cable
- */
- if (cable_resp.tbt_cable == TBT_CABLE_OPTICAL)
- set_retimer_con |= BB_RETIMER_TBT_CABLE_TYPE;
-
- /*
- * Bit 20: TBT_ACTIVE_LINK_TRAINING
- * 0 - Active with bi-directional LSRX communication
- * 1 - Active with uni-directional LSRX communication
- * Set to "0" when passive cable plug
- */
- if (cable_type == IDH_PTYPE_ACABLE &&
- cable_resp.lsrx_comm == UNIDIR_LSRX_COMM)
- set_retimer_con |= BB_RETIMER_TBT_ACTIVE_LINK_TRAINING;
-
/*
* Bit 23: USB4 Connection
* 0 - USB4 not configured
@@ -334,8 +366,7 @@ static int retimer_set_state(const struct usb_mux *me, mux_state_t mux_state)
}
if (pd_get_data_role(port) == PD_ROLE_DFP)
- retimer_set_state_dfp(port, mux_state, &set_retimer_con,
- cable_type);
+ retimer_set_state_dfp(port, mux_state, &set_retimer_con);
else
retimer_set_state_ufp(mux_state, &set_retimer_con);