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 | |
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>
-rw-r--r-- | baseboard/volteer/baseboard.h | 1 | ||||
-rw-r--r-- | baseboard/volteer/usb_pd_policy.c | 11 | ||||
-rw-r--r-- | common/build.mk | 1 | ||||
-rw-r--r-- | common/usb_pd_alt_mode_ufp.c | 22 | ||||
-rw-r--r-- | driver/retimer/bb_retimer.c | 132 | ||||
-rw-r--r-- | include/config.h | 12 | ||||
-rw-r--r-- | include/usb_pd.h | 17 |
7 files changed, 142 insertions, 54 deletions
diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h index 772b34e694..132ed7375b 100644 --- a/baseboard/volteer/baseboard.h +++ b/baseboard/volteer/baseboard.h @@ -158,6 +158,7 @@ #define CONFIG_USB_POWER_DELIVERY #define CONFIG_USB_PD_ALT_MODE #define CONFIG_USB_PD_ALT_MODE_DFP +#define CONFIG_USB_PD_ALT_MODE_UFP #define CONFIG_USB_PD_DISCHARGE_PPC #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_TCPC_RUNTIME_CONFIG diff --git a/baseboard/volteer/usb_pd_policy.c b/baseboard/volteer/usb_pd_policy.c index 2b4cd162aa..670654198f 100644 --- a/baseboard/volteer/usb_pd_policy.c +++ b/baseboard/volteer/usb_pd_policy.c @@ -76,8 +76,6 @@ int board_vbus_source_enabled(int port) /* Responses specifically for the enablement of TBT mode in the role of UFP */ #define OPOS_TBT 1 -static union tbt_dev_mode_enter_cmd - ufp_enter_mode[CONFIG_USB_PD_PORT_MAX_COUNT]; static const union tbt_mode_resp_device vdo_tbt_modes[1] = { { @@ -181,14 +179,7 @@ static int svdm_tbt_compat_response_enter_mode( */ if ((mux_state & USB_PD_MUX_USB_ENABLED) || (mux_state & USB_PD_MUX_SAFE_MODE)) { - - /* - * TODO(b:157163664): set retimer config for UFP - * Save TBT3 SOP VDO from request so retimer can use it - */ - ufp_enter_mode[port] = - (union tbt_dev_mode_enter_cmd)payload[1]; - + pd_ufp_set_enter_mode(port, payload); set_tbt_compat_mode_ready(port); CPRINTS("UFP Enter TBT mode"); return 1; /* ACK */ diff --git a/common/build.mk b/common/build.mk index 9b20fc1369..1acc35347b 100644 --- a/common/build.mk +++ b/common/build.mk @@ -162,6 +162,7 @@ common-$(CONFIG_USB_PD_HOST_CMD)+=usb_pd_host_cmd.o common-$(CONFIG_USB_PD_CONSOLE_CMD)+=usb_pd_console_cmd.o endif common-$(CONFIG_USB_PD_ALT_MODE_DFP)+=usb_pd_alt_mode_dfp.o +common-$(CONFIG_USB_PD_ALT_MODE_UFP)+=usb_pd_alt_mode_ufp.o common-$(CONFIG_USB_PD_LOGGING)+=event_log.o pd_log.o common-$(CONFIG_USB_PD_TCPC)+=usb_pd_tcpc.o common-$(CONFIG_USB_UPDATE)+=usb_update.o update_fw.o diff --git a/common/usb_pd_alt_mode_ufp.c b/common/usb_pd_alt_mode_ufp.c new file mode 100644 index 0000000000..3db60166d2 --- /dev/null +++ b/common/usb_pd_alt_mode_ufp.c @@ -0,0 +1,22 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Alternate Mode Upstream Facing Port (UFP) USB-PD module. + */ +#include "usb_pd.h" +#include "usb_tbt_alt_mode.h" + +static uint32_t ufp_enter_mode[CONFIG_USB_PD_PORT_MAX_COUNT]; + +/* Save port partner's enter mode message */ +void pd_ufp_set_enter_mode(int port, uint32_t *payload) +{ + ufp_enter_mode[port] = payload[1]; +} + +/* Return port partner's enter mode message */ +uint32_t pd_ufp_get_enter_mode(int port) +{ + return ufp_enter_mode[port]; +} 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, diff --git a/include/config.h b/include/config.h index 6d9d0d46dc..56e64c1672 100644 --- a/include/config.h +++ b/include/config.h @@ -3977,6 +3977,9 @@ */ #undef CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY +/* Support for USB PD alternate mode of Upward Facing Port */ +#undef CONFIG_USB_PD_ALT_MODE_UFP + /* HPD is sent to the GPU from the EC via a GPIO */ #undef CONFIG_USB_PD_DP_HPD_GPIO @@ -5043,6 +5046,15 @@ /******************************************************************************/ /* + * If CONFIG_USBC_SS_MUX_DFP_ONLY is enabled, make sure + * CONFIG_USB_PD_ALT_MODE_UFP is not enabled + */ +#if defined(CONFIG_USBC_SS_MUX_DFP_ONLY) && defined(CONFIG_USB_PD_ALT_MODE_UFP) +#error port cannot be UFP when CONFIG_USBC_SS_MUX_DFP_ONLY is enabled +#endif + +/******************************************************************************/ +/* * Automatically define CONFIG_USB_PD_FRS if FRS is enabled in the TCPC or PPC */ #if defined(CONFIG_USB_PD_FRS_PPC) || defined(CONFIG_USB_PD_FRS_TCPC) diff --git a/include/usb_pd.h b/include/usb_pd.h index bcde9fabef..e0f0ac0e28 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -1707,6 +1707,23 @@ uint32_t pd_dfp_enter_mode(int port, enum tcpm_transmit_type type, uint16_t svid, int opos); /** + * Save the Enter mode command data received from the port partner for setting + * the retimer + * + * @param port USB-C port number + * @param payload payload data. + */ +void pd_ufp_set_enter_mode(int port, uint32_t *payload); + +/** + * Return Enter mode command data received from the port partner + * + * @param port USB-C port number + * @return enter mode raw value requested to the UFP + */ +uint32_t pd_ufp_get_enter_mode(int port); + +/** * Get DisplayPort pin mode for DFP to request from UFP's capabilities. * * @param port USB-C port number. |