diff options
author | Zick Wei <zick.wei@quanta.corp-partner.google.com> | 2020-05-06 09:26:08 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-21 23:48:36 +0000 |
commit | 6c655b318a5960fe9082b312dd3e6368efb4cbb6 (patch) | |
tree | 52ce36f508abdd36bb9a35b904523ed330948e4c /board | |
parent | 8e6ab39b174272d6114b90cdc11adc9c0723eb9f (diff) | |
download | chrome-ec-6c655b318a5960fe9082b312dd3e6368efb4cbb6.tar.gz |
berknip: add redriver TUSB544 and PS8743
berknip use TUSB544 on opt1 DB
and PS8743 on opt3 DB.
BUG=b:148757952
BRANCH=none
TEST=verify on berknip opt1 and opt3 USB C1 port can work.
Change-Id: Ic065c7bd9c575cd42e24512ff02548e8e07b1011
Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2183575
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Commit-Queue: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/berknip/board.c | 195 | ||||
-rw-r--r-- | board/berknip/board.h | 66 |
2 files changed, 104 insertions, 157 deletions
diff --git a/board/berknip/board.c b/board/berknip/board.c index e22b61dcef..c7a99339cb 100644 --- a/board/berknip/board.c +++ b/board/berknip/board.c @@ -10,9 +10,9 @@ #include "driver/accelgyro_bmi_common.h" #include "driver/accel_kionix.h" #include "driver/accel_kx022.h" -#include "driver/retimer/pi3dpx1207.h" -#include "driver/retimer/ps8811.h" +#include "driver/retimer/tusb544.h" #include "driver/usb_mux/amd_fp5.h" +#include "driver/usb_mux/ps8743.h" #include "extpower.h" #include "fan.h" #include "fan_chip.h" @@ -149,140 +149,40 @@ const struct mft_t mft_channels[] = { BUILD_ASSERT(ARRAY_SIZE(mft_channels) == MFT_CH_COUNT); /***************************************************************************** - * USB-A Retimer tuning - */ -#define PS8811_ACCESS_RETRIES 2 - -/* PS8811 gain tuning */ -static void ps8811_tuning_init(void) -{ - int rv; - int retry; - - /* Turn on the retimers */ - ioex_set_level(IOEX_USB_A0_RETIMER_EN, 1); - ioex_set_level(IOEX_USB_A1_RETIMER_EN, 1); - - /* USB-A0 can run with default settings */ - for (retry = 0; retry < PS8811_ACCESS_RETRIES; ++retry) { - int val; - - rv = i2c_read8(I2C_PORT_USBA0, - PS8811_I2C_ADDR_FLAGS + PS8811_REG_PAGE1, - PS8811_REG1_USB_BEQ_LEVEL, &val); - if (!rv) - break; - } - if (rv) { - ioex_set_level(IOEX_USB_A0_RETIMER_EN, 0); - CPRINTSUSB("C0: PS8811 not detected"); - } - - /* USB-A1 needs to increase gain to get over MB/DB connector */ - for (retry = 0; retry < PS8811_ACCESS_RETRIES; ++retry) { - rv = i2c_write8(I2C_PORT_USBA1, - PS8811_I2C_ADDR_FLAGS + PS8811_REG_PAGE1, - PS8811_REG1_USB_BEQ_LEVEL, - PS8811_BEQ_I2C_LEVEL_UP_13DB | - PS8811_BEQ_PIN_LEVEL_UP_18DB); - if (!rv) - break; - } - if (rv) { - ioex_set_level(IOEX_USB_A1_RETIMER_EN, 0); - CPRINTSUSB("C1: PS8811 not detected"); - } -} -DECLARE_HOOK(HOOK_CHIPSET_STARTUP, ps8811_tuning_init, HOOK_PRIO_DEFAULT); - -static void ps8811_retimer_off(void) -{ - /* Turn on the retimers */ - ioex_set_level(IOEX_USB_A0_RETIMER_EN, 0); - ioex_set_level(IOEX_USB_A1_RETIMER_EN, 0); -} -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, ps8811_retimer_off, HOOK_PRIO_DEFAULT); - -/***************************************************************************** * USB-C MUX/Retimer dynamic configuration */ static void setup_mux(void) { - if (ec_config_has_usbc1_retimer_ps8802()) { - ccprints("C1 PS8802 detected"); - + if (ec_config_has_usbc1_retimer_tusb544()) { + ccprints("C1 TUSB544 detected"); /* - * Main MUX is PS8802, secondary MUX is modified FP5 + * Main MUX is FP5, secondary MUX is TUSB544 * - * Replace usb_muxes[USBC_PORT_C1] with the PS8802 + * Replace usb_muxes[USBC_PORT_C1] with the AMD FP5 * table entry. */ memcpy(&usb_muxes[USBC_PORT_C1], - &usbc1_ps8802, + &usbc1_amd_fp5_usb_mux, sizeof(struct usb_mux)); - - /* Set the AMD FP5 as the secondary MUX */ - usb_muxes[USBC_PORT_C1].next_mux = &usbc1_amd_fp5_usb_mux; - - /* Don't have the AMD FP5 flip */ - usbc1_amd_fp5_usb_mux.flags = USB_MUX_FLAG_SET_WITHOUT_FLIP; - - } else if (ec_config_has_usbc1_retimer_ps8818()) { - ccprints("C1 PS8818 detected"); - + /* Set the TUSB544 as the secondary MUX */ + usb_muxes[USBC_PORT_C1].next_mux = &usbc1_tusb544; + } else if (ec_config_has_usbc1_retimer_ps8743()) { + ccprints("C1 PS8743 detected"); /* - * Main MUX is FP5, secondary MUX is PS8818 + * Main MUX is PS8743, secondary MUX is modified FP5 * - * Replace usb_muxes[USBC_PORT_C1] with the AMD FP5 + * Replace usb_muxes[USBC_PORT_C1] with the PS8743 * table entry. */ memcpy(&usb_muxes[USBC_PORT_C1], - &usbc1_amd_fp5_usb_mux, + &usbc1_ps8743, sizeof(struct usb_mux)); - - /* Set the PS8818 as the secondary MUX */ - usb_muxes[USBC_PORT_C1].next_mux = &usbc1_ps8818; - } -} - -/* TODO(b:151232257) Remove probe code when hardware supports CBI */ -#include "driver/retimer/ps8802.h" -#include "driver/retimer/ps8818.h" -static void probe_setup_mux_backup(void) -{ - if (usb_muxes[USBC_PORT_C1].driver != NULL) - return; - - /* - * Identifying a PS8818 is faster than the PS8802, - * so do it first. - */ - if (ps8818_detect(&usbc1_ps8818) == EC_SUCCESS) { - set_cbi_fw_config(0x00004000); - setup_mux(); - } else if (ps8802_detect(&usbc1_ps8802) == EC_SUCCESS) { - set_cbi_fw_config(0x00004001); - setup_mux(); + /* Set the AMD FP5 as the secondary MUX */ + usb_muxes[USBC_PORT_C1].next_mux = &usbc1_amd_fp5_usb_mux; + /* Don't have the AMD FP5 flip */ + usbc1_amd_fp5_usb_mux.flags = USB_MUX_FLAG_SET_WITHOUT_FLIP; } } -DECLARE_HOOK(HOOK_CHIPSET_STARTUP, probe_setup_mux_backup, HOOK_PRIO_DEFAULT); - -const struct pi3dpx1207_usb_control pi3dpx1207_controls[] = { - [USBC_PORT_C0] = { - .enable_gpio = IOEX_USB_C0_DATA_EN, - .dp_enable_gpio = GPIO_USB_C0_IN_HPD, - }, - [USBC_PORT_C1] = { - }, -}; -BUILD_ASSERT(ARRAY_SIZE(pi3dpx1207_controls) == USBC_PORT_COUNT); - -const struct usb_mux usbc0_pi3dpx1207_usb_retimer = { - .usb_port = USBC_PORT_C0, - .i2c_port = I2C_PORT_TCPC0, - .i2c_addr_flags = PI3DPX1207_I2C_ADDR_FLAGS, - .driver = &pi3dpx1207_usb_retimer, -}; struct usb_mux usb_muxes[] = { [USBC_PORT_C0] = { @@ -290,7 +190,6 @@ struct usb_mux usb_muxes[] = { .i2c_port = I2C_PORT_USB_AP_MUX, .i2c_addr_flags = AMD_FP5_MUX_I2C_ADDR_FLAGS, .driver = &amd_fp5_usb_mux_driver, - .next_mux = &usbc0_pi3dpx1207_usb_retimer, }, [USBC_PORT_C1] = { /* Filled in dynamically at startup */ @@ -298,6 +197,64 @@ struct usb_mux usb_muxes[] = { }; BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT); +static int board_tusb544_mux_set(const struct usb_mux *me, + mux_state_t mux_state) +{ + if (mux_state & USB_PD_MUX_DP_ENABLED) { + /* Enable IN_HPD on the DB */ + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + } else { + /* Disable IN_HPD on the DB */ + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + } + return EC_SUCCESS; +} + +static int board_ps8743_mux_set(const struct usb_mux *me, + mux_state_t mux_state) +{ + int rv = EC_SUCCESS; + int reg = 0; + + rv = ps8743_read(me, PS8743_REG_MODE, ®); + if (rv) + return rv; + + /* Disable FLIP pin, enable I2C control. */ + reg |= PS8743_MODE_FLIP_REG_CONTROL; + /* Disable CE_DP pin, enable I2C control. */ + reg |= PS8743_MODE_DP_REG_CONTROL; + + /* DP specific config */ + if (mux_state & USB_PD_MUX_DP_ENABLED) { + /* Enable IN_HPD on the DB */ + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + /* Disable USB mode on DB */ + ioex_set_level(IOEX_USB_C1_DATA_EN, 0); + } else { + /* Disable IN_HPD on the DB */ + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + /* Enable USB mode on DB */ + ioex_set_level(IOEX_USB_C1_DATA_EN, 1); + } + return ps8743_write(me, PS8743_REG_MODE, reg); +} + +const struct usb_mux usbc1_tusb544 = { + .usb_port = USBC_PORT_C1, + .i2c_port = I2C_PORT_TCPC1, + .i2c_addr_flags = TUSB544_I2C_ADDR_FLAGS1, + .driver = &tusb544_drv, + .board_set = &board_tusb544_mux_set, +}; +const struct usb_mux usbc1_ps8743 = { + .usb_port = USBC_PORT_C1, + .i2c_port = I2C_PORT_TCPC1, + .i2c_addr_flags = PS8743_I2C_ADDR1_FLAG, + .driver = &ps8743_usb_mux_driver, + .board_set = &board_ps8743_mux_set, +}; + /***************************************************************************** * Use FW_CONFIG to set correct configuration. */ diff --git a/board/berknip/board.h b/board/berknip/board.h index ae1321dda6..df2fec3810 100644 --- a/board/berknip/board.h +++ b/board/berknip/board.h @@ -20,7 +20,6 @@ #define CONFIG_SYSTEM_UNLOCKED #define CONFIG_I2C_DEBUG -#define CONFIG_USBC_RETIMER_PI3DPX1207 #define CONFIG_MKBP_USE_GPIO /* Motion sensing drivers */ @@ -37,6 +36,11 @@ #define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL #define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL +/* Type C mux/retimer */ +#define CONFIG_USB_MUX_PS8743 +#define CONFIG_USBC_RETIMER_TUSB544 +#define TUSB544_I2C_ADDR_FLAGS1 0x0F + /* GPIO mapping from board specific name to EC common name. */ #define CONFIG_BATTERY_PRESENT_GPIO GPIO_EC_BATT_PRES_ODL #define CONFIG_SCI_GPIO GPIO_EC_FCH_SCI_ODL @@ -88,10 +92,10 @@ enum pwm_channel { /** * BERKNIP_MB_USBAC - * USB-A0 Speed: 10 Gbps - * Retimer: PS8811 - * USB-C0 Speed: 10 Gbps - * Retimer: PI3DPX1207 + * USB-A0 Speed: 5 Gbps + * Retimer: none + * USB-C0 Speed: 5 Gbps + * Retimer: none * TCPC: NCT3807 * PPC: AOZ1380 * IOEX: TCPC @@ -102,10 +106,10 @@ enum ec_cfg_usb_mb_type { /** * BERKNIP_DB_T_OPT1_USBAC_HMDI - * USB-A1 Speed: 10 Gbps - * Retimer: PS8811 - * USB-C1 Speed: 10 Gbps - * Retimer: PS8818 + * USB-A1 Speed: 5 Gbps + * Retimer: PS8719 + * USB-C1 Speed: 5 Gbps + * Retimer: TUSB544 * TCPC: NCT3807 * PPC: NX20P3483 * IOEX: TCPC @@ -113,23 +117,12 @@ enum ec_cfg_usb_mb_type { * Retimer: PI3HDX1204 * MST Hub: none * - * BERKNIP_DB_T_OPT2_USBAC - * USB-A1 Speed: 10 Gbps - * Retimer: PS8811 - * USB-C1 Speed: 10 Gbps - * Retimer: PS8802 - * TCPC: NCT3807 - * PPC: NX20P3483 - * IOEX: TCPC - * HDMI Exists: no - * Retimer: none - * MST Hub: none * * BERKNIP_DB_T_OPT3_USBAC_HDMI_MSTHUB - * USB-A1 Speed: 10 Gbps - * Retimer: PS8811 - * USB-C1 Speed: 10 Gbps - * Retimer: PS8802 + * USB-A1 Speed: 5 Gbps + * Retimer: PS8719 + * USB-C1 Speed: 5 Gbps + * Retimer: PS8743 * TCPC: NCT3807 * PPC: NX20P3483 * IOEX: TCPC @@ -139,28 +132,26 @@ enum ec_cfg_usb_mb_type { */ enum ec_cfg_usb_db_type { BERKNIP_DB_T_OPT1_USBAC_HMDI = 0, - BERKNIP_DB_T_OPT2_USBAC = 1, - BERKNIP_DB_T_OPT3_USBAC_HDMI_MSTHUB = 2, + BERKNIP_DB_T_OPT3_USBAC_HDMI_MSTHUB = 1, }; -#define HAS_USBC1_RETIMER_PS8802 \ - (BIT(BERKNIP_DB_T_OPT2_USBAC) | \ - BIT(BERKNIP_DB_T_OPT3_USBAC_HDMI_MSTHUB)) +#define HAS_USBC1_RETIMER_PS8743 \ + (BIT(BERKNIP_DB_T_OPT3_USBAC_HDMI_MSTHUB)) -static inline bool ec_config_has_usbc1_retimer_ps8802(void) +static inline bool ec_config_has_usbc1_retimer_ps8743(void) { return !!(BIT(ec_config_get_usb_db()) & - HAS_USBC1_RETIMER_PS8802); + HAS_USBC1_RETIMER_PS8743); } -#define HAS_USBC1_RETIMER_PS8818 \ +#define HAS_USBC1_RETIMER_TUSB544 \ (BIT(BERKNIP_DB_T_OPT1_USBAC_HMDI)) -static inline bool ec_config_has_usbc1_retimer_ps8818(void) +static inline bool ec_config_has_usbc1_retimer_tusb544(void) { return !!(BIT(ec_config_get_usb_db()) & - HAS_USBC1_RETIMER_PS8818); + HAS_USBC1_RETIMER_TUSB544); } #define HAS_HDMI_RETIMER_PI3HDX1204 \ @@ -192,13 +183,12 @@ static inline bool ec_config_has_hdmi_conn_hpd(void) #define PORT_TO_HPD(port) ((port == 0) \ ? GPIO_USB_C0_HPD \ - : (ec_config_has_usbc1_retimer_ps8802()) \ + : (ec_config_has_usbc1_retimer_ps8743()) \ ? GPIO_DP1_HPD \ : GPIO_DP2_HPD) -extern const struct usb_mux usbc0_pi3dpx1207_usb_retimer; -extern const struct usb_mux usbc1_ps8802; -extern const struct usb_mux usbc1_ps8818; +extern const struct usb_mux usbc1_tusb544; +extern const struct usb_mux usbc1_ps8743; extern struct usb_mux usbc1_amd_fp5_usb_mux; #endif /* !__ASSEMBLER__ */ |