diff options
author | Edward Hill <ecgh@chromium.org> | 2019-12-23 04:04:30 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-26 16:51:10 +0000 |
commit | d158e276531acc1627bbf9b6872f391e54690ef4 (patch) | |
tree | b8460ee20c5c73cd8ce500114c9168e804cb6903 /baseboard | |
parent | bfff18207694893690b2fcdec8f3907dd254d716 (diff) | |
download | chrome-ec-d158e276531acc1627bbf9b6872f391e54690ef4.tar.gz |
zork: Detect PS8802 or PS8818 retimer for USB-C1
To support both OPT1 DB with PS8818 retimer, and OPT3 DB with
PS8802 retimer, try both, and remember the first one that succeeds.
BUG=b:138682132, b:143147353
BRANCH=none
TEST=USB3 device enumerates as 5G on Trembyle OPT1 and OPT3 USB-C1
Change-Id: I9a78801dc35c19f97fc015b739b105541c41e1d5
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1980392
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Tested-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'baseboard')
-rw-r--r-- | baseboard/zork/baseboard.c | 60 | ||||
-rw-r--r-- | baseboard/zork/baseboard.h | 1 |
2 files changed, 59 insertions, 2 deletions
diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c index 8647c518c9..ac89f9d4a5 100644 --- a/baseboard/zork/baseboard.c +++ b/baseboard/zork/baseboard.c @@ -22,6 +22,7 @@ #include "driver/ppc/aoz1380.h" #include "driver/ppc/nx20p348x.h" #include "driver/retimer/pi3dpx1207.h" +#include "driver/retimer/ps8802.h" #include "driver/retimer/ps8818.h" #include "driver/tcpm/ps8xxx.h" #include "driver/tcpm/nct38xx.h" @@ -468,6 +469,62 @@ struct usb_mux usb_muxes[] = { }; BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT); +enum zork_c1_retimer { + C1_RETIMER_UNKNOWN, + C1_RETIMER_PS8802, + C1_RETIMER_PS8818, +}; + +static enum zork_c1_retimer zork_c1_retimer = C1_RETIMER_UNKNOWN; + +/* + * To support both OPT1 DB with PS8818 retimer, and OPT3 DB with PS8802 retimer, + * try both, and remember the first one that succeeds. + */ +static int zork_c1_set_mux(int port, mux_state_t mux_state) +{ + int rv = EC_ERROR_UNKNOWN; + + /* + * Retimers are not powered in G3 so return success if setting mux to + * none and error otherwise. + */ + if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) + return (mux_state == TYPEC_MUX_NONE) + ? EC_SUCCESS + : EC_ERROR_NOT_POWERED; + + /* + * Identifying a PS8818 is faster than the PS8802, + * so do it first. + */ + if (zork_c1_retimer != C1_RETIMER_PS8802) { + usb_retimers[USBC_PORT_C1].i2c_addr_flags + = PS8818_I2C_ADDR_FLAGS; + rv = ps8818_usb_retimer.set(port, mux_state); + if (rv == EC_SUCCESS && zork_c1_retimer != C1_RETIMER_PS8818) { + zork_c1_retimer = C1_RETIMER_PS8818; + ccprints("C1 PS8818 detected"); + } + } + + if (zork_c1_retimer != C1_RETIMER_PS8818) { + usb_retimers[USBC_PORT_C1].i2c_addr_flags + = PS8802_I2C_ADDR_FLAGS; + rv = ps8802_usb_retimer.set(port, mux_state); + if (rv == EC_SUCCESS && zork_c1_retimer != C1_RETIMER_PS8802) { + zork_c1_retimer = C1_RETIMER_PS8802; + ccprints("C1 PS8802 detected"); + } + } + + return rv; +} + +const struct usb_retimer_driver zork_c1_usb_retimer = { + .set = zork_c1_set_mux, +}; + struct usb_retimer usb_retimers[USBC_PORT_COUNT] = { [USBC_PORT_C0] = { .driver = &pi3dpx1207_usb_retimer, @@ -477,9 +534,8 @@ struct usb_retimer usb_retimers[USBC_PORT_COUNT] = { .gpio_dp_enable = GPIO_USB_C0_IN_HPD, }, [USBC_PORT_C1] = { - .driver = &ps8818_usb_retimer, + .driver = &zork_c1_usb_retimer, .i2c_port = I2C_PORT_TCPC1, - .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS, }, }; diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h index 3f62d6ec59..1ed4bee22b 100644 --- a/baseboard/zork/baseboard.h +++ b/baseboard/zork/baseboard.h @@ -146,6 +146,7 @@ #define CONFIG_USBC_PPC_AOZ1380 #define CONFIG_USBC_PPC_NX20P3483 #define CONFIG_USBC_RETIMER_PI3DPX1207 +#define CONFIG_USBC_RETIMER_PS8802 #define CONFIG_USBC_RETIMER_PS8818 #define CONFIG_USBC_SS_MUX #define CONFIG_USBC_SS_MUX_DFP_ONLY |