From 869c6c528b670e90f845035553e4eefedde88672 Mon Sep 17 00:00:00 2001 From: "YongBeum.Ha" Date: Wed, 27 Jan 2021 10:05:28 +0900 Subject: sasuke : tune usb_eq and usb_gain on port 1 tune usb_eq and usb_gain on port 1 BUG=b:176862264 BRANCH=None TEST=make -j BOARD=sasuke update ec and check usb eq register Signed-off-by: YongBeum.Ha Change-Id: Ief9bc8d545e94d2e4726ed61d12739e7e872aabc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2649895 Reviewed-by: Diana Z --- board/sasuke/board.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/board/sasuke/board.c b/board/sasuke/board.c index 8e1f9fdb14..962f4a6bab 100644 --- a/board/sasuke/board.c +++ b/board/sasuke/board.c @@ -468,6 +468,8 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { }, }; +static int board_nb7v904m_mux_set(const struct usb_mux *me, + mux_state_t mux_state); const struct usb_mux usbc0_retimer = { .usb_port = 0, .i2c_port = I2C_PORT_USB_C0, @@ -479,7 +481,9 @@ const struct usb_mux usbc1_retimer = { .i2c_port = I2C_PORT_SUB_USB_C1, .i2c_addr_flags = NB7V904M_I2C_ADDR0, .driver = &nb7v904m_usb_redriver_drv, + .board_set = &board_nb7v904m_mux_set, }; + const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .usb_port = 0, @@ -497,6 +501,71 @@ const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { } }; +/* USB Mux */ +static int board_nb7v904m_mux_set(const struct usb_mux *me, + mux_state_t mux_state) +{ + int rv = EC_SUCCESS; + int flipped = !!(mux_state & USB_PD_MUX_POLARITY_INVERTED); + + if (mux_state & USB_PD_MUX_USB_ENABLED) { + /* USB with DP */ + if (mux_state & USB_PD_MUX_DP_ENABLED) { + if (flipped) { + rv |= nb7v904m_tune_usb_set_eq(me, + NB7V904M_CH_A_EQ_10_DB, + NB7V904M_CH_ALL_SKIP_EQ, + NB7V904M_CH_ALL_SKIP_EQ, + NB7V904M_CH_D_EQ_4_DB); + rv |= nb7v904m_tune_usb_flat_gain(me, + NB7V904M_CH_ALL_SKIP_GAIN, + NB7V904M_CH_B_GAIN_3P5_DB, + NB7V904M_CH_C_GAIN_0_DB, + NB7V904M_CH_ALL_SKIP_GAIN); + } + else { + rv |= nb7v904m_tune_usb_set_eq(me, + NB7V904M_CH_A_EQ_4_DB, + NB7V904M_CH_ALL_SKIP_EQ, + NB7V904M_CH_ALL_SKIP_EQ, + NB7V904M_CH_D_EQ_10_DB); + rv |= nb7v904m_tune_usb_flat_gain(me, + NB7V904M_CH_ALL_SKIP_GAIN, + NB7V904M_CH_B_GAIN_0_DB, + NB7V904M_CH_C_GAIN_3P5_DB, + NB7V904M_CH_ALL_SKIP_GAIN); + } + } else { + /* USB only */ + rv |= nb7v904m_tune_usb_set_eq(me, + NB7V904M_CH_A_EQ_10_DB, + NB7V904M_CH_ALL_SKIP_EQ, + NB7V904M_CH_ALL_SKIP_EQ, + NB7V904M_CH_D_EQ_10_DB); + rv |= nb7v904m_tune_usb_flat_gain(me, + NB7V904M_CH_ALL_SKIP_GAIN, + NB7V904M_CH_B_GAIN_3P5_DB, + NB7V904M_CH_C_GAIN_3P5_DB, + NB7V904M_CH_ALL_SKIP_GAIN); + } + + } else if (mux_state & USB_PD_MUX_DP_ENABLED) { + /* 4 lanes DP */ + rv |= nb7v904m_tune_usb_set_eq(me, + NB7V904M_CH_A_EQ_4_DB, + NB7V904M_CH_ALL_SKIP_EQ, + NB7V904M_CH_ALL_SKIP_EQ, + NB7V904M_CH_D_EQ_4_DB); + rv |= nb7v904m_tune_usb_flat_gain(me, + NB7V904M_CH_ALL_SKIP_GAIN, + NB7V904M_CH_B_GAIN_0_DB, + NB7V904M_CH_C_GAIN_0_DB, + NB7V904M_CH_ALL_SKIP_GAIN); + } + + return rv; +} + uint16_t tcpc_get_alert_status(void) { uint16_t status = 0; -- cgit v1.2.1