diff options
-rw-r--r-- | board/woomax/board.c | 52 | ||||
-rw-r--r-- | driver/retimer/ps8802.h | 16 |
2 files changed, 68 insertions, 0 deletions
diff --git a/board/woomax/board.c b/board/woomax/board.c index 6460083e77..eeae681ae7 100644 --- a/board/woomax/board.c +++ b/board/woomax/board.c @@ -15,6 +15,7 @@ #include "driver/accel_kx022.h" #include "driver/retimer/pi3dpx1207.h" #include "driver/retimer/pi3hdx1204.h" +#include "driver/retimer/ps8802.h" #include "driver/retimer/ps8811.h" #include "driver/retimer/ps8818.h" #include "driver/temp_sensor/sb_tsi.h" @@ -343,6 +344,56 @@ static int woomax_ps8818_mux_set(const struct usb_mux *me, return rv; } +static int woomax_ps8802_mux_set(const struct usb_mux *me, + mux_state_t mux_state) +{ + int rv = EC_SUCCESS; + + /* Make sure the PS8802 is awake */ + rv = ps8802_i2c_wake(me); + if (rv) + return rv; + + /* USB specific config */ + if (mux_state & USB_PD_MUX_USB_ENABLED) { + /* Boost the USB gain */ + rv = ps8802_i2c_field_update16(me, + PS8802_REG_PAGE2, + PS8802_REG2_USB_SSEQ_LEVEL, + PS8802_USBEQ_LEVEL_UP_MASK, + PS8802_USBEQ_LEVEL_UP_19DB); + if (rv) + return rv; + } + + /* DP specific config */ + if (mux_state & USB_PD_MUX_DP_ENABLED) { + /*Boost the DP gain */ + rv = ps8802_i2c_field_update16(me, + PS8802_REG_PAGE2, + PS8802_REG2_DPEQ_LEVEL, + PS8802_DPEQ_LEVEL_UP_MASK, + PS8802_DPEQ_LEVEL_UP_19DB); + if (rv) + return rv; + + /* Enable IN_HPD on the DB */ + gpio_or_ioex_set_level(board_usbc1_retimer_inhpd, 1); + } else { + /* Disable IN_HPD on the DB */ + gpio_or_ioex_set_level(board_usbc1_retimer_inhpd, 0); + } + + /* Set extra swing level tuning at 800mV/P0 */ + rv = ps8802_i2c_field_update8(me, + PS8802_REG_PAGE1, + PS8802_800MV_LEVEL_TUNING, + PS8802_EXTRA_SWING_LEVEL_P0_MASK, + PS8802_EXTRA_SWING_LEVEL_P0_UP_1); + + return rv; +} + const struct usb_mux usbc1_woomax_ps8818 = { .usb_port = USBC_PORT_C1, .i2c_port = I2C_PORT_TCPC1, @@ -368,6 +419,7 @@ static void setup_mux(void) /* Set the AMD FP5 as the secondary MUX */ usb_muxes[USBC_PORT_C1].next_mux = &usbc1_amd_fp5_usb_mux; + usb_muxes[USBC_PORT_C1].board_set = &woomax_ps8802_mux_set; /* Don't have the AMD FP5 flip */ usbc1_amd_fp5_usb_mux.flags = USB_MUX_FLAG_SET_WITHOUT_FLIP; diff --git a/driver/retimer/ps8802.h b/driver/retimer/ps8802.h index 4429db92ad..97edb656e9 100644 --- a/driver/retimer/ps8802.h +++ b/driver/retimer/ps8802.h @@ -32,6 +32,22 @@ #define PS8802_STATUS_10_GBPS BIT(5) /* + * PAGE 1 Register Definitions + */ +#define PS8802_REG_PAGE1 0x01 + +#define PS8802_800MV_LEVEL_TUNING 0x8A +#define PS8802_EXTRA_SWING_LEVEL_P0_DEFAULT 0X00 +#define PS8802_EXTRA_SWING_LEVEL_P0_DOWN_1 0X01 +#define PS8802_EXTRA_SWING_LEVEL_P0_DOWN_2 0X02 +#define PS8802_EXTRA_SWING_LEVEL_P0_DOWN_3 0X03 +#define PS8802_EXTRA_SWING_LEVEL_P0_DOWN_4 0X04 +#define PS8802_EXTRA_SWING_LEVEL_P0_UP_1 0X05 +#define PS8802_EXTRA_SWING_LEVEL_P0_UP_2 0X06 +#define PS8802_EXTRA_SWING_LEVEL_P0_UP_3 0X07 +#define PS8802_EXTRA_SWING_LEVEL_P0_MASK 0X07 + +/* * PAGE 2 Register Definitions */ #define PS8802_REG_PAGE2 0x02 |