diff options
author | Ayushee <ayushee.shah@intel.com> | 2020-08-28 14:21:18 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-07 19:16:10 +0000 |
commit | f22925531a49127dca6b43b738e4c006fa33ff11 (patch) | |
tree | e35639ac48e59aad7ddde3e6c62d5f22d71d8e80 /driver | |
parent | 840d7258423fced9538af206c2f13f8cd5600b59 (diff) | |
download | chrome-ec-f22925531a49127dca6b43b738e4c006fa33ff11.tar.gz |
BB retimer: Set UFP mode of BB retimer
This CL enables getting the enter mode information received from DFP
and sets the following BB retimer bits accordingly.
Bit 2: RE_TIMER_DRIVER
Bit 18: CABLE_TYPE
Bit 19: VPRO_DOCK_DETECTED
Bit 20: TBT_ACTIVE_LINK_TRAINING
Bit 22: ACTIVE/PASSIVE
Bits 27-25: TBT Cable speed
Bits 29-28: TBT_GEN_SUPPORT
BUG=b:157163664
BRANCH=None
TEST=Tested with volteer as UFP, able to set the retimer bits
Signed-off-by: Ayushee <ayushee.shah@intel.com>
Change-Id: I661aa4630b42fbaa136ff3855c4f70e3dee61546
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2382634
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/retimer/bb_retimer.c | 132 |
1 files changed, 88 insertions, 44 deletions
diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c index d6200d521c..0b203c0175 100644 --- a/driver/retimer/bb_retimer.c +++ b/driver/retimer/bb_retimer.c @@ -260,59 +260,103 @@ static void retimer_set_state_dfp(int port, mux_state_t mux_state, } } -static void retimer_set_state_ufp(mux_state_t mux_state, +static void retimer_set_state_ufp(int port, mux_state_t mux_state, uint32_t *set_retimer_con) { - if (mux_state & USB_PD_MUX_USB_ENABLED) { + /* + * Bit 7: USB_DATA_ROLE for the Burnside Bridge side of + * connection. + * 0 - DFP + * 1 - UFP + */ + *set_retimer_con |= BB_RETIMER_USB_DATA_ROLE; + + if (!IS_ENABLED(CONFIG_USB_PD_ALT_MODE_UFP)) + return; + + /* TODO:b/168890624: Set USB4 retimer config for UFP */ + if (mux_state & USB_PD_MUX_TBT_COMPAT_ENABLED) { + union tbt_dev_mode_enter_cmd ufp_tbt_enter_mode = { + .raw_value = pd_ufp_get_enter_mode(port)}; /* - * Bit 4: USB2_CONNECTION (ignored if BIT5=0). - * 0 - No USB2 Connection - * 1 - USB2 connection + * Bit 2: RE_TIMER_DRIVER + * 0 - Re-driver + * 1 - Re-timer * - * Don't care + * Set according to TBT3 Enter Mode bit 22. */ + if (ufp_tbt_enter_mode.retimer_type == USB_RETIMER) + *set_retimer_con |= BB_RETIMER_RE_TIMER_DRIVER; /* - * Bit 7: USB_DATA_ROLE for the Burnside Bridge side of - * connection (ignored if BIT5=0). - * 0 - DFP - * 1 - UFP + * Bit 18: CABLE_TYPE + * 0 - Electrical cable + * 1 - Optical cable + * + * Set according to TBT3 Enter Mode bit 21. */ - *set_retimer_con |= BB_RETIMER_USB_DATA_ROLE; - } + if (ufp_tbt_enter_mode.tbt_cable == TBT_CABLE_OPTICAL) + *set_retimer_con |= BB_RETIMER_TBT_CABLE_TYPE; - /* - * Bit 17: TBT_TYPE - * 0 - Type-C to Type-C Cable - * 1 - Type-C Legacy TBT Adapter - * For UFP, TBT_TYPE = 0 - */ + /* + * Bit 19: VPO_DOCK_DETECTED_OR_DP_OVERDRIVE + * 0 - No vPro Dock.No DP Overdrive + * detected + * 1 - vPro Dock or DP Overdrive + * detected + * + * Set according to TBT3 Enter Mode bit 26 or bit 31 + */ + if (ufp_tbt_enter_mode.intel_spec_b0 == + VENDOR_SPECIFIC_SUPPORTED || + ufp_tbt_enter_mode.vendor_spec_b1 == + VENDOR_SPECIFIC_SUPPORTED) + *set_retimer_con |= BB_RETIMER_VPRO_DOCK_DP_OVERDRIVE; - /* - * TODO: b/157163664: Add the following bits: - * - * Bit 2: RE_TIMER_DRIVER: - * Set according to b20:19 of enter USB. - * - * Bit 16: TBT_CONNECTION: - * Set according to b14 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. - * - * Bits 29-28: TBT_GEN_SUPPORT - * For Thunderbolt-compat mode, set according to bits 20:19 of enter - * mode. - */ + /* + * Bit 20: TBT_ACTIVE_LINK_TRAINING + * 0 - Active with bi-directional LSRX communication + * 1 - Active with uni-directional LSRX communication + * + * Set according to TBT3 Enter Mode bit 23 + */ + if (ufp_tbt_enter_mode.lsrx_comm == UNIDIR_LSRX_COMM) + *set_retimer_con |= BB_RETIMER_TBT_ACTIVE_LINK_TRAINING; + + /* + * Bit 22: ACTIVE/PASSIVE + * 0 - Passive cable + * 1 - Active cable + * + * Set according to TBT3 Enter Mode bit 24 + */ + if (ufp_tbt_enter_mode.cable == TBT_ENTER_ACTIVE_CABLE) + *set_retimer_con |= BB_RETIMER_ACTIVE_PASSIVE; + + /* + * Bit 27-25: TBT Cable speed + * 000b - No functionality + * 001b - USB3.1 Gen1 Cable + * 010b - 10Gb/s + * 011b - 10Gb/s and 20Gb/s + * 10..11b - Reserved + * + * Set according to TBT3 Enter Mode bit 18:16 + */ + *set_retimer_con |= BB_RETIMER_USB4_TBT_CABLE_SPEED_SUPPORT( + ufp_tbt_enter_mode.tbt_cable_speed); + /* + * 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 according to TBT3 Enter Mode bit 20:19 + */ + *set_retimer_con |= BB_RETIMER_TBT_CABLE_GENERATION( + ufp_tbt_enter_mode.tbt_rounded); + } } /** @@ -412,7 +456,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); else - retimer_set_state_ufp(mux_state, &set_retimer_con); + retimer_set_state_ufp(port, mux_state, &set_retimer_con); /* Writing the register4 */ return bb_retimer_write(me, BB_RETIMER_REG_CONNECTION_STATE, |