diff options
-rw-r--r-- | board/chell/board.c | 18 | ||||
-rw-r--r-- | board/glados/board.c | 2 | ||||
-rw-r--r-- | board/oak/board.c | 2 | ||||
-rw-r--r-- | board/reef_it8320/board.c | 2 | ||||
-rw-r--r-- | board/wheatley/board.c | 2 | ||||
-rw-r--r-- | driver/build.mk | 4 | ||||
-rw-r--r-- | driver/ps8740.h | 67 | ||||
-rw-r--r-- | driver/ps8743.h | 40 | ||||
-rw-r--r-- | driver/usb_mux_ps8740.c | 125 | ||||
-rw-r--r-- | driver/usb_mux_ps8743.c | 108 | ||||
-rw-r--r-- | driver/usb_mux_ps874x.c | 118 | ||||
-rw-r--r-- | driver/usb_mux_ps874x.h | 113 | ||||
-rw-r--r-- | include/usb_mux.h | 3 |
13 files changed, 247 insertions, 357 deletions
diff --git a/board/chell/board.c b/board/chell/board.c index e8c013353c..6637e56543 100644 --- a/board/chell/board.c +++ b/board/chell/board.c @@ -20,7 +20,6 @@ #include "keyboard_scan.h" #include "lid_switch.h" #include "pi3usb9281.h" -#include "ps8740.h" #include "power.h" #include "power_button.h" #include "pwm.h" @@ -35,6 +34,7 @@ #include "uart.h" #include "usb_charge.h" #include "usb_mux.h" +#include "usb_mux_ps874x.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" #include "util.h" @@ -169,12 +169,12 @@ struct pi3usb9281_config pi3usb9281_chips[] = { BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) == CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT); -static int ps8740_tune_mux(const struct usb_mux *mux) +static int ps874x_tune_mux(const struct usb_mux *mux) { /* Apply same USB EQ settings to both Type-C mux */ - ps8740_tune_usb_eq(mux->port_addr, - PS8740_USB_EQ_TX_6_5_DB, - PS8740_USB_EQ_RX_14_3_DB); + ps874x_tune_usb_eq(mux->port_addr, + PS874X_USB_EQ_TX_6_5_DB, + PS874X_USB_EQ_RX_14_3_DB); return EC_SUCCESS; } @@ -182,13 +182,13 @@ static int ps8740_tune_mux(const struct usb_mux *mux) struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { { .port_addr = 0x34, - .driver = &ps8740_usb_mux_driver, - .board_init = &ps8740_tune_mux, + .driver = &ps874x_usb_mux_driver, + .board_init = &ps874x_tune_mux, }, { .port_addr = 0x20, - .driver = &ps8740_usb_mux_driver, - .board_init = &ps8740_tune_mux, + .driver = &ps874x_usb_mux_driver, + .board_init = &ps874x_tune_mux, } }; diff --git a/board/glados/board.c b/board/glados/board.c index 930a7f8a7d..893d3c32db 100644 --- a/board/glados/board.c +++ b/board/glados/board.c @@ -167,7 +167,7 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { }, { .port_addr = 0x20, - .driver = &ps8740_usb_mux_driver, + .driver = &ps874x_usb_mux_driver, } }; diff --git a/board/oak/board.c b/board/oak/board.c index 0c8af7b2ba..704c287c11 100644 --- a/board/oak/board.c +++ b/board/oak/board.c @@ -173,7 +173,7 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { #else { .port_addr = 0x20, - .driver = &ps8740_usb_mux_driver, + .driver = &ps874x_usb_mux_driver, }, #endif }; diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c index e2abb87957..101deb2baf 100644 --- a/board/reef_it8320/board.c +++ b/board/reef_it8320/board.c @@ -177,7 +177,7 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { }, { .port_addr = 0x20, - .driver = &ps8740_usb_mux_driver, + .driver = &ps874x_usb_mux_driver, .hpd_update = &it83xx_tcpc_update_hpd_status, }, }; diff --git a/board/wheatley/board.c b/board/wheatley/board.c index 79903a505a..88f39d2bc7 100644 --- a/board/wheatley/board.c +++ b/board/wheatley/board.c @@ -167,7 +167,7 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { }, { .port_addr = 0x20, - .driver = &ps8740_usb_mux_driver, + .driver = &ps874x_usb_mux_driver, } }; diff --git a/driver/build.mk b/driver/build.mk index b4d2638a57..82a8f7a41d 100644 --- a/driver/build.mk +++ b/driver/build.mk @@ -101,8 +101,8 @@ driver-$(CONFIG_USBC_SS_MUX)+=usb_mux.o # USB muxes driver-$(CONFIG_USB_MUX_PI3USB30532)+=usb_mux_pi3usb30532.o -driver-$(CONFIG_USB_MUX_PS8740)+=usb_mux_ps8740.o -driver-$(CONFIG_USB_MUX_PS8743)+=usb_mux_ps8743.o +driver-$(CONFIG_USB_MUX_PS8740)+=usb_mux_ps874x.o +driver-$(CONFIG_USB_MUX_PS8743)+=usb_mux_ps874x.o driver-$(CONFIG_USB_MUX_VIRTUAL)+=usb_mux_virtual.o # Firmware Update diff --git a/driver/ps8740.h b/driver/ps8740.h deleted file mode 100644 index 94076e7921..0000000000 --- a/driver/ps8740.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright 2015 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Parade PS8740 USB port switch driver. - */ - -#ifndef __CROS_EC_PS8740_H -#define __CROS_EC_PS8740_H - -/* Mode register for setting mux */ -#define PS8740_REG_MODE 0x00 -#define PS8740_MODE_POLARITY_INVERTED (1 << 4) -#define PS8740_MODE_USB_ENABLED (1 << 5) -#define PS8740_MODE_DP_ENABLED (1 << 6) -#define PS8740_MODE_POWER_DOWN (1 << 7) - -/* Status register for checking mux state */ -#define PS8740_REG_STATUS 0x09 -#define PS8740_STATUS_POLARITY_INVERTED (1 << 2) -#define PS8740_STATUS_USB_ENABLED (1 << 3) -#define PS8740_STATUS_DP_ENABLED (1 << 4) -#define PS8740_STATUS_HPD_ASSERTED (1 << 7) - -/* Chip ID / revision registers and expected fused values */ -#define PS8740_REG_REVISION_ID1 0xf0 -#define PS8740_REVISION_ID1 0x00 -#define PS8740_REG_REVISION_ID2 0xf1 -#define PS8740_REVISION_ID2 0x0a -#define PS8740_REG_CHIP_ID1 0xf2 -#define PS8740_CHIP_ID1 0x40 -#define PS8740_REG_CHIP_ID2 0xf3 -#define PS8740_CHIP_ID2 0x87 - -/* USB equalization settings for Host to Mux */ -#define PS8740_REG_USB_EQ_TX 0x32 -#define PS8740_USB_EQ_TX_10_1_DB 0x00 -#define PS8740_USB_EQ_TX_14_3_DB 0x20 -#define PS8740_USB_EQ_TX_8_5_DB 0x40 -#define PS8740_USB_EQ_TX_6_5_DB 0x60 -#define PS8740_USB_EQ_TX_11_5_DB 0x80 -#define PS8740_USB_EQ_TX_9_5_DB 0xc0 -#define PS8740_USB_EQ_TX_7_5_DB 0xe0 -#define PS8740_USB_EQ_TERM_100_OHM (0 << 2) -#define PS8740_USB_EQ_TERM_85_OHM (1 << 2) - -/* USB equalization settings for Connector to Mux */ -#define PS8740_REG_USB_EQ_RX 0x3b -#define PS8740_USB_EQ_RX_4_4_DB 0x00 -#define PS8740_USB_EQ_RX_7_0_DB 0x10 -#define PS8740_USB_EQ_RX_8_2_DB 0x20 -#define PS8740_USB_EQ_RX_9_4_DB 0x30 -#define PS8740_USB_EQ_RX_10_2_DB 0x40 -#define PS8740_USB_EQ_RX_11_4_DB 0x50 -#define PS8740_USB_EQ_RX_14_3_DB 0x60 -#define PS8740_USB_EQ_RX_14_8_DB 0x70 -#define PS8740_USB_EQ_RX_15_2_DB 0x80 -#define PS8740_USB_EQ_RX_15_5_DB 0x90 -#define PS8740_USB_EQ_RX_16_2_DB 0xa0 -#define PS8740_USB_EQ_RX_17_3_DB 0xb0 -#define PS8740_USB_EQ_RX_18_4_DB 0xc0 -#define PS8740_USB_EQ_RX_20_1_DB 0xd0 -#define PS8740_USB_EQ_RX_21_3_DB 0xe0 - -int ps8740_tune_usb_eq(int i2c_addr, uint8_t tx, uint8_t rx); - -#endif /* __CROS_EC_PS8740_H */ diff --git a/driver/ps8743.h b/driver/ps8743.h deleted file mode 100644 index 1ab516bba4..0000000000 --- a/driver/ps8743.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Parade PS8743 USB Type-C Redriving Switch for USB Host / DisplayPort. - */ - -#ifndef __CROS_EC_PS8743_H -#define __CROS_EC_PS8743_H - -/* Mode register for setting mux */ -#define PS8743_REG_MODE 0x00 -#define PS8743_MODE_POLARITY_INVERTED (1 << 2) -#define PS8743_MODE_FLIP_PIN_ENABLED (1 << 3) -#define PS8743_MODE_USB_ENABLED (1 << 4) -#define PS8743_MODE_CE_USB_ENABLED (1 << 5) -#define PS8743_MODE_DP_ENABLED (1 << 6) -#define PS8743_MODE_CE_DP_ENABLED (1 << 7) -/* To reset the state machine to default */ -#define PS8743_MODE_POWER_DOWN (PS8743_MODE_CE_USB_ENABLED | \ - PS8743_MODE_CE_DP_ENABLED) - -/* Status register for checking mux state */ -#define PS8743_REG_STATUS 0x09 -#define PS8743_STATUS_POLARITY_INVERTED (1 << 2) -#define PS8743_STATUS_USB_ENABLED (1 << 3) -#define PS8743_STATUS_DP_ENABLED (1 << 4) -#define PS8743_STATUS_HPD_ASSERTED (1 << 7) - -/* Chip ID / revision registers and expected fused values */ -#define PS8743_REG_REVISION_ID1 0xf0 -#define PS8743_REVISION_ID1 0x01 -#define PS8743_REG_REVISION_ID2 0xf1 -#define PS8743_REVISION_ID2 0x0b -#define PS8743_REG_CHIP_ID1 0xf2 -#define PS8743_CHIP_ID1 0x41 -#define PS8743_REG_CHIP_ID2 0xf3 -#define PS8743_CHIP_ID2 0x87 - -#endif /* __CROS_EC_PS8743_H */ diff --git a/driver/usb_mux_ps8740.c b/driver/usb_mux_ps8740.c deleted file mode 100644 index dada5368f6..0000000000 --- a/driver/usb_mux_ps8740.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright 2015 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Parade PS8740 USB port switch driver. - */ - -#include "common.h" -#include "i2c.h" -#include "ps8740.h" -#include "usb_mux.h" -#include "util.h" - -static int ps8740_read(int i2c_addr, uint8_t reg, uint8_t *val) -{ - int read, res; - - res = i2c_read8(I2C_PORT_USB_MUX, i2c_addr, reg, &read); - if (res) - return res; - - *val = read; - return EC_SUCCESS; -} - -static int ps8740_write(int i2c_addr, uint8_t reg, uint8_t val) -{ - return i2c_write8(I2C_PORT_USB_MUX, i2c_addr, reg, val); -} - -static int ps8740_reset(int i2c_addr) -{ - return ps8740_write(i2c_addr, PS8740_REG_MODE, PS8740_MODE_POWER_DOWN); -} - -static int ps8740_init(int i2c_addr) -{ - uint8_t val; - int res; - - /* Reset chip back to power-on state */ - res = ps8740_reset(i2c_addr); - if (res) - return res; - - /* Verify revision / chip ID registers */ - res = ps8740_read(i2c_addr, PS8740_REG_REVISION_ID1, &val); - if (res) - return res; - if (val != PS8740_REVISION_ID1) - return EC_ERROR_UNKNOWN; - - res = ps8740_read(i2c_addr, PS8740_REG_REVISION_ID2, &val); - if (res) - return res; - if (val < PS8740_REVISION_ID2) - return EC_ERROR_UNKNOWN; - - res = ps8740_read(i2c_addr, PS8740_REG_CHIP_ID1, &val); - if (res) - return res; - if (val != PS8740_CHIP_ID1) - return EC_ERROR_UNKNOWN; - - res = ps8740_read(i2c_addr, PS8740_REG_CHIP_ID2, &val); - if (res) - return res; - if (val != PS8740_CHIP_ID2) - return EC_ERROR_UNKNOWN; - - return EC_SUCCESS; -} - -/* Writes control register to set switch mode */ -static int ps8740_set_mux(int i2c_addr, mux_state_t mux_state) -{ - uint8_t reg = 0; - - if (mux_state & MUX_USB_ENABLED) - reg |= PS8740_MODE_USB_ENABLED; - if (mux_state & MUX_DP_ENABLED) - reg |= PS8740_MODE_DP_ENABLED; - if (mux_state & MUX_POLARITY_INVERTED) - reg |= PS8740_MODE_POLARITY_INVERTED; - - return ps8740_write(i2c_addr, PS8740_REG_MODE, reg); -} - -/* Reads control register and updates mux_state accordingly */ -static int ps8740_get_mux(int i2c_addr, mux_state_t *mux_state) -{ - uint8_t reg; - int res; - - *mux_state = 0; - res = ps8740_read(i2c_addr, PS8740_REG_STATUS, ®); - if (res) - return res; - - if (reg & PS8740_STATUS_USB_ENABLED) - *mux_state |= MUX_USB_ENABLED; - if (reg & PS8740_STATUS_DP_ENABLED) - *mux_state |= MUX_DP_ENABLED; - if (reg & PS8740_STATUS_POLARITY_INVERTED) - *mux_state |= MUX_POLARITY_INVERTED; - - return EC_SUCCESS; -} - -/* Tune USB Tx/Rx Equalization */ -int ps8740_tune_usb_eq(int i2c_addr, uint8_t tx, uint8_t rx) -{ - int ret = 0; - - ret |= ps8740_write(i2c_addr, PS8740_REG_USB_EQ_TX, tx); - ret |= ps8740_write(i2c_addr, PS8740_REG_USB_EQ_RX, rx); - - return ret; -} - -const struct usb_mux_driver ps8740_usb_mux_driver = { - .init = ps8740_init, - .set = ps8740_set_mux, - .get = ps8740_get_mux, -}; diff --git a/driver/usb_mux_ps8743.c b/driver/usb_mux_ps8743.c deleted file mode 100644 index 112bda40ee..0000000000 --- a/driver/usb_mux_ps8743.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Parade PS8743 USB Type-C Redriving Switch for USB Host / DisplayPort. - * - * TODO: Merge PS8743 & PS8740 as PS874X as both the drivers are almost same. - */ - -#include "common.h" -#include "i2c.h" -#include "ps8743.h" -#include "usb_mux.h" -#include "util.h" - -static inline int ps8743_read(int i2c_addr, uint8_t reg, int *val) -{ - return i2c_read8(I2C_PORT_USB_MUX, i2c_addr, reg, val); -} - -static inline int ps8743_write(int i2c_addr, uint8_t reg, uint8_t val) -{ - return i2c_write8(I2C_PORT_USB_MUX, i2c_addr, reg, val); -} - -static int ps8743_init(int i2c_addr) -{ - int val; - int res; - - /* Reset chip back to power-on state */ - res = ps8743_write(i2c_addr, PS8743_REG_MODE, PS8743_MODE_POWER_DOWN); - if (res) - return res; - - /* - * Verify revision / chip ID registers. - * From Parade: PS8743 may have REVISION_ID1 as 0 or 1, - * 1 is derived from 0 and have same functionality. - */ - res = ps8743_read(i2c_addr, PS8743_REG_REVISION_ID1, &val); - if (res) - return res; - if (val <= PS8743_REVISION_ID1) - return EC_ERROR_UNKNOWN; - - res = ps8743_read(i2c_addr, PS8743_REG_REVISION_ID2, &val); - if (res) - return res; - if (val != PS8743_REVISION_ID2) - return EC_ERROR_UNKNOWN; - - res = ps8743_read(i2c_addr, PS8743_REG_CHIP_ID1, &val); - if (res) - return res; - if (val != PS8743_CHIP_ID1) - return EC_ERROR_UNKNOWN; - - res = ps8743_read(i2c_addr, PS8743_REG_CHIP_ID2, &val); - if (res) - return res; - if (val != PS8743_CHIP_ID2) - return EC_ERROR_UNKNOWN; - - return EC_SUCCESS; -} - -/* Writes control register to set switch mode */ -static int ps8743_set_mux(int i2c_addr, mux_state_t mux_state) -{ - uint8_t reg = 0; - - if (mux_state & MUX_USB_ENABLED) - reg |= PS8743_MODE_USB_ENABLED; - if (mux_state & MUX_DP_ENABLED) - reg |= PS8743_MODE_DP_ENABLED; - if (mux_state & MUX_POLARITY_INVERTED) - reg |= PS8743_MODE_POLARITY_INVERTED; - - return ps8743_write(i2c_addr, PS8743_REG_MODE, reg); -} - -/* Reads control register and updates mux_state accordingly */ -static int ps8743_get_mux(int i2c_addr, mux_state_t *mux_state) -{ - int reg; - int res; - - res = ps8743_read(i2c_addr, PS8743_REG_STATUS, ®); - if (res) - return res; - - *mux_state = 0; - if (reg & PS8743_STATUS_USB_ENABLED) - *mux_state |= MUX_USB_ENABLED; - if (reg & PS8743_STATUS_DP_ENABLED) - *mux_state |= MUX_DP_ENABLED; - if (reg & PS8743_STATUS_POLARITY_INVERTED) - *mux_state |= MUX_POLARITY_INVERTED; - - return EC_SUCCESS; -} - -const struct usb_mux_driver ps8743_usb_mux_driver = { - .init = ps8743_init, - .set = ps8743_set_mux, - .get = ps8743_get_mux, -}; diff --git a/driver/usb_mux_ps874x.c b/driver/usb_mux_ps874x.c new file mode 100644 index 0000000000..76b7eb26c3 --- /dev/null +++ b/driver/usb_mux_ps874x.c @@ -0,0 +1,118 @@ +/* Copyright 2017 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Parade PS874X USB Type-C Redriving Switch for USB Host / DisplayPort. + */ + +#include "common.h" +#include "i2c.h" +#include "usb_mux_ps874x.h" +#include "usb_mux.h" +#include "util.h" + +static inline int ps874x_read(int i2c_addr, uint8_t reg, int *val) +{ + return i2c_read8(I2C_PORT_USB_MUX, i2c_addr, reg, val); +} + +static inline int ps874x_write(int i2c_addr, uint8_t reg, uint8_t val) +{ + return i2c_write8(I2C_PORT_USB_MUX, i2c_addr, reg, val); +} + +static int ps874x_init(int i2c_addr) +{ + int val; + int res; + + /* Reset chip back to power-on state */ + res = ps874x_write(i2c_addr, PS874X_REG_MODE, PS874X_MODE_POWER_DOWN); + if (res) + return res; + + /* + * Verify revision / chip ID registers. + * From Parade: PS8743 may have REVISION_ID1 as 0 or 1, + * PS8740 may have REVISION_ID2 as 0 or 1, + * 1 is derived from 0 and have same functionality. + */ + res = ps874x_read(i2c_addr, PS874X_REG_REVISION_ID1, &val); + if (res) + return res; + if (val < PS874X_REVISION_ID1) + return EC_ERROR_UNKNOWN; + + res = ps874x_read(i2c_addr, PS874X_REG_REVISION_ID2, &val); + if (res) + return res; + if (val < PS874X_REVISION_ID2) + return EC_ERROR_UNKNOWN; + + res = ps874x_read(i2c_addr, PS874X_REG_CHIP_ID1, &val); + if (res) + return res; + if (val != PS874X_CHIP_ID1) + return EC_ERROR_UNKNOWN; + + res = ps874x_read(i2c_addr, PS874X_REG_CHIP_ID2, &val); + if (res) + return res; + if (val != PS874X_CHIP_ID2) + return EC_ERROR_UNKNOWN; + + return EC_SUCCESS; +} + +/* Writes control register to set switch mode */ +static int ps874x_set_mux(int i2c_addr, mux_state_t mux_state) +{ + uint8_t reg = 0; + + if (mux_state & MUX_USB_ENABLED) + reg |= PS874X_MODE_USB_ENABLED; + if (mux_state & MUX_DP_ENABLED) + reg |= PS874X_MODE_DP_ENABLED; + if (mux_state & MUX_POLARITY_INVERTED) + reg |= PS874X_MODE_POLARITY_INVERTED; + + return ps874x_write(i2c_addr, PS874X_REG_MODE, reg); +} + +/* Reads control register and updates mux_state accordingly */ +static int ps874x_get_mux(int i2c_addr, mux_state_t *mux_state) +{ + int reg; + int res; + + res = ps874x_read(i2c_addr, PS874X_REG_STATUS, ®); + if (res) + return res; + + *mux_state = 0; + if (reg & PS874X_STATUS_USB_ENABLED) + *mux_state |= MUX_USB_ENABLED; + if (reg & PS874X_STATUS_DP_ENABLED) + *mux_state |= MUX_DP_ENABLED; + if (reg & PS874X_STATUS_POLARITY_INVERTED) + *mux_state |= MUX_POLARITY_INVERTED; + + return EC_SUCCESS; +} + +/* Tune USB Tx/Rx Equalization */ +int ps874x_tune_usb_eq(int i2c_addr, uint8_t tx, uint8_t rx) +{ + int ret; + + ret = ps874x_write(i2c_addr, PS874X_REG_USB_EQ_TX, tx); + ret |= ps874x_write(i2c_addr, PS874X_REG_USB_EQ_RX, rx); + + return ret; +} + +const struct usb_mux_driver ps874x_usb_mux_driver = { + .init = ps874x_init, + .set = ps874x_set_mux, + .get = ps874x_get_mux, +}; diff --git a/driver/usb_mux_ps874x.h b/driver/usb_mux_ps874x.h new file mode 100644 index 0000000000..8092e448bb --- /dev/null +++ b/driver/usb_mux_ps874x.h @@ -0,0 +1,113 @@ +/* Copyright 2017 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Parade PS874X USB Type-C Redriving Switch for USB Host / DisplayPort. + */ + +#ifndef __CROS_EC_USB_MUX_PS874X_H +#define __CROS_EC_USB_MUX_PS874X_H + +/* Mode register for setting mux */ +#define PS874X_REG_MODE 0x00 +#ifdef CONFIG_USB_MUX_PS8740 + #define PS874X_MODE_POLARITY_INVERTED (1 << 4) + #define PS874X_MODE_USB_ENABLED (1 << 5) + #define PS874X_MODE_DP_ENABLED (1 << 6) + #define PS874X_MODE_POWER_DOWN (1 << 7) +#elif defined(CONFIG_USB_MUX_PS8743) + #define PS874X_MODE_POLARITY_INVERTED (1 << 2) + #define PS874X_MODE_FLIP_PIN_ENABLED (1 << 3) + #define PS874X_MODE_USB_ENABLED (1 << 4) + #define PS874X_MODE_CE_USB_ENABLED (1 << 5) + #define PS874X_MODE_DP_ENABLED (1 << 6) + #define PS874X_MODE_CE_DP_ENABLED (1 << 7) + /* To reset the state machine to default */ + #define PS874X_MODE_POWER_DOWN (PS874X_MODE_CE_USB_ENABLED | \ + PS874X_MODE_CE_DP_ENABLED) +#endif + +/* Status register for checking mux state */ +#define PS874X_REG_STATUS 0x09 +#define PS874X_STATUS_POLARITY_INVERTED (1 << 2) +#define PS874X_STATUS_USB_ENABLED (1 << 3) +#define PS874X_STATUS_DP_ENABLED (1 << 4) +#define PS874X_STATUS_HPD_ASSERTED (1 << 7) + +/* Chip ID / revision registers and expected fused values */ +#define PS874X_REG_REVISION_ID1 0xf0 +#define PS874X_REG_REVISION_ID2 0xf1 +#define PS874X_REG_CHIP_ID1 0xf2 +#define PS874X_REG_CHIP_ID2 0xf3 +#ifdef CONFIG_USB_MUX_PS8740 + #define PS874X_REVISION_ID1 0x00 + #define PS874X_REVISION_ID2 0x0a + #define PS874X_CHIP_ID1 0x40 +#elif defined(CONFIG_USB_MUX_PS8743) + #define PS874X_REVISION_ID1 0x01 + #define PS874X_REVISION_ID2 0x0b + #define PS874X_CHIP_ID1 0x41 +#endif +#define PS874X_CHIP_ID2 0x87 + +/* USB equalization settings for Host to Mux */ +#define PS874X_REG_USB_EQ_TX 0x32 +#ifdef CONFIG_USB_MUX_PS8740 + #define PS874X_USB_EQ_TX_10_1_DB 0x00 + #define PS874X_USB_EQ_TX_14_3_DB 0x20 + #define PS874X_USB_EQ_TX_8_5_DB 0x40 + #define PS874X_USB_EQ_TX_6_5_DB 0x60 + #define PS874X_USB_EQ_TX_11_5_DB 0x80 + #define PS874X_USB_EQ_TX_9_5_DB 0xc0 + #define PS874X_USB_EQ_TX_7_5_DB 0xe0 + #define PS874X_USB_EQ_TERM_100_OHM (0 << 2) + #define PS874X_USB_EQ_TERM_85_OHM (1 << 2) +#elif defined(CONFIG_USB_MUX_PS8743) + #define PS874X_USB_EQ_TX_12_8_DB 0x00 + #define PS874X_USB_EQ_TX_17_DB 0x20 + #define PS874X_USB_EQ_TX_7_7_DB 0x40 + #define PS874X_USB_EQ_TX_3_6_DB 0x60 + #define PS874X_USB_EQ_TX_15_DB 0x80 + #define PS874X_USB_EQ_TX_10_9_DB 0xc0 + #define PS874X_USB_EQ_TX_4_5_DB 0xe0 +#endif + +/* USB equalization settings for Connector to Mux */ +#define PS874X_REG_USB_EQ_RX 0x3b +#ifdef CONFIG_USB_MUX_PS8740 + #define PS874X_USB_EQ_RX_4_4_DB 0x00 + #define PS874X_USB_EQ_RX_7_0_DB 0x10 + #define PS874X_USB_EQ_RX_8_2_DB 0x20 + #define PS874X_USB_EQ_RX_9_4_DB 0x30 + #define PS874X_USB_EQ_RX_10_2_DB 0x40 + #define PS874X_USB_EQ_RX_11_4_DB 0x50 + #define PS874X_USB_EQ_RX_14_3_DB 0x60 + #define PS874X_USB_EQ_RX_14_8_DB 0x70 + #define PS874X_USB_EQ_RX_15_2_DB 0x80 + #define PS874X_USB_EQ_RX_15_5_DB 0x90 + #define PS874X_USB_EQ_RX_16_2_DB 0xa0 + #define PS874X_USB_EQ_RX_17_3_DB 0xb0 + #define PS874X_USB_EQ_RX_18_4_DB 0xc0 + #define PS874X_USB_EQ_RX_20_1_DB 0xd0 + #define PS874X_USB_EQ_RX_21_3_DB 0xe0 +#elif defined(CONFIG_USB_MUX_PS8743) + #define PS874X_USB_EQ_RX_2_4_DB 0x00 + #define PS874X_USB_EQ_RX_5_DB 0x10 + #define PS874X_USB_EQ_RX_6_5_DB 0x20 + #define PS874X_USB_EQ_RX_7_4_DB 0x30 + #define PS874X_USB_EQ_RX_8_7_DB 0x40 + #define PS874X_USB_EQ_RX_10_9_DB 0x50 + #define PS874X_USB_EQ_RX_12_8_DB 0x60 + #define PS874X_USB_EQ_RX_13_8_DB 0x70 + #define PS874X_USB_EQ_RX_14_8_DB 0x80 + #define PS874X_USB_EQ_RX_15_4_DB 0x90 + #define PS874X_USB_EQ_RX_16_0_DB 0xa0 + #define PS874X_USB_EQ_RX_16_7_DB 0xb0 + #define PS874X_USB_EQ_RX_18_8_DB 0xc0 + #define PS874X_USB_EQ_RX_21_3_DB 0xd0 + #define PS874X_USB_EQ_RX_22_2_DB 0xe0 +#endif + +int ps874x_tune_usb_eq(int i2c_addr, uint8_t tx, uint8_t rx); + +#endif /* __CROS_EC_USB_MUX_PS874X_H */ diff --git a/include/usb_mux.h b/include/usb_mux.h index 712ed3d437..8df27af44b 100644 --- a/include/usb_mux.h +++ b/include/usb_mux.h @@ -89,8 +89,7 @@ struct usb_mux { /* Supported USB mux drivers */ extern const struct usb_mux_driver pi3usb30532_usb_mux_driver; -extern const struct usb_mux_driver ps8740_usb_mux_driver; -extern const struct usb_mux_driver ps8743_usb_mux_driver; +extern const struct usb_mux_driver ps874x_usb_mux_driver; extern const struct usb_mux_driver tcpm_usb_mux_driver; extern const struct usb_mux_driver virtual_usb_mux_driver; |