From f21d9520fb51508d24c2128c1bc4065b30fc7a0f Mon Sep 17 00:00:00 2001 From: David Huang Date: Tue, 24 Mar 2020 15:00:06 +0800 Subject: Ezkinil: Add redriver TUSB544 and PS8743 for Ezkinil Setup usb_muxes for TUSB544 and PS8743. BUG=None BRANCH=ezkinil TEST=verify USB is working. Signed-off-by: David Huang Change-Id: I606a571960bc0ff2634dd432573683e8d5631c6e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2115904 Reviewed-by: Denis Brockus --- board/ezkinil/board.c | 33 ++++++++++++++++++++++++++++++--- board/ezkinil/board.h | 8 ++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) (limited to 'board/ezkinil') diff --git a/board/ezkinil/board.c b/board/ezkinil/board.c index b710c60700..f881272da7 100644 --- a/board/ezkinil/board.c +++ b/board/ezkinil/board.c @@ -9,6 +9,9 @@ #include "driver/accelgyro_bmi160.h" #include "driver/accel_kionix.h" #include "driver/accel_kx022.h" +#include "driver/retimer/tusb544.h" +#include "driver/usb_mux/amd_fp5.h" +#include "driver/usb_mux/ps874x.h" #include "extpower.h" #include "fan.h" #include "fan_chip.h" @@ -169,13 +172,37 @@ BUILD_ASSERT(ARRAY_SIZE(mft_channels) == MFT_CH_COUNT); * USB-C MUX/Retimer dynamic configuration */ -/* TODO: Fill in with real mux table updates */ static void setup_mux(void) { - if (ec_config_has_usbc1_retimer_tusb544()) + if (ec_config_has_usbc1_retimer_tusb544()) { ccprints("C1 TUSB544 detected"); - else if (ec_config_has_usbc1_retimer_ps8743()) + /* + * Main MUX is FP5, secondary MUX is TUSB544 + * + * Replace usb_muxes[USBC_PORT_C1] with the AMD FP5 + * table entry. + */ + memcpy(&usb_muxes[USBC_PORT_C1], + &usbc1_amd_fp5_usb_mux, + sizeof(struct usb_mux)); + /* 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 PS8743, secondary MUX is modified FP5 + * + * Replace usb_muxes[USBC_PORT_C1] with the PS8743 + * table entry. + */ + memcpy(&usb_muxes[USBC_PORT_C1], + &usbc1_ps8743, + 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; + } } DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_DEFAULT); diff --git a/board/ezkinil/board.h b/board/ezkinil/board.h index 00acf228dc..baf97a4d30 100644 --- a/board/ezkinil/board.h +++ b/board/ezkinil/board.h @@ -36,6 +36,10 @@ #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 + /* GPIO mapping from board specific name to EC common name. */ #define CONFIG_BATTERY_PRESENT_GPIO GPIO_EC_BATT_PRES_ODL #define GPIO_AC_PRESENT GPIO_ACOK_OD @@ -167,6 +171,10 @@ static inline bool ec_config_has_usbc1_retimer_tusb544(void) ? GPIO_DP1_HPD \ : GPIO_DP2_HPD) +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__ */ #endif /* __CROS_EC_BOARD_H */ -- cgit v1.2.1