summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hill <ecgh@chromium.org>2020-04-15 16:31:48 -0600
committerCommit Bot <commit-bot@chromium.org>2020-04-16 06:14:10 +0000
commit57d7b7d45390d9bac51cadcc7d5349c830eaedb6 (patch)
treeafe2e0353658793a15215f3476c7a6c37832da5a
parent66272422f71c94bb7c5b31830a43e2ce1684a37c (diff)
downloadchrome-ec-57d7b7d45390d9bac51cadcc7d5349c830eaedb6.tar.gz
PS874x: Split PS8740 and PS8743
Split ps874x.[ch] into ps8740.[ch] and ps8743.[ch] since we need to support both at runtime for Dalboz. I left PS8742 in ps8740.[ch] since it is not very different. BUG=b:153454399 BRANCH=none TEST=make -j buildall Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I92b02e08f377d1781c130a0bbe1482a936ad7a4d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2151647 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
-rw-r--r--baseboard/zork/baseboard.h1
-rw-r--r--baseboard/zork/variant_dalboz.c5
-rw-r--r--baseboard/zork/variant_trembyle.c5
-rw-r--r--board/chell/board.c18
-rw-r--r--board/ezkinil/board.c2
-rw-r--r--board/glados/board.c2
-rw-r--r--board/glkrvp/chg_usb_pd.c4
-rw-r--r--board/glkrvp_ite/chg_usb_pd.c4
-rw-r--r--board/mchpevb1/board.c2
-rw-r--r--board/oak/board.c2
-rw-r--r--board/reef_it8320/board.c2
-rw-r--r--driver/build.mk6
-rw-r--r--driver/usb_mux/ps8740.c124
-rw-r--r--driver/usb_mux/ps8740.h91
-rw-r--r--driver/usb_mux/ps8743.c126
-rw-r--r--driver/usb_mux/ps8743.h80
-rw-r--r--driver/usb_mux/ps874x.c134
-rw-r--r--driver/usb_mux/ps874x.h135
-rw-r--r--include/usb_mux.h3
19 files changed, 450 insertions, 296 deletions
diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h
index be0040e518..9d75896d10 100644
--- a/baseboard/zork/baseboard.h
+++ b/baseboard/zork/baseboard.h
@@ -234,7 +234,6 @@
#endif
#define I2C_ADDR_EEPROM_FLAGS 0x50
-#define PS8743_I2C_ADDR_FLAGS 0x11
/* Sensors */
#define CONFIG_MKBP_EVENT
diff --git a/baseboard/zork/variant_dalboz.c b/baseboard/zork/variant_dalboz.c
index 41307d6da4..4e14beb3c9 100644
--- a/baseboard/zork/variant_dalboz.c
+++ b/baseboard/zork/variant_dalboz.c
@@ -8,6 +8,7 @@
#include "driver/ioexpander/pcal6408.h"
#include "driver/tcpm/nct38xx.h"
#include "driver/usb_mux/amd_fp5.h"
+#include "driver/usb_mux/ps8740.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
@@ -199,8 +200,8 @@ const struct usb_mux usb_muxes[] = {
[USBC_PORT_C1] = {
.usb_port = USBC_PORT_C1,
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr_flags = 0x10,
- .driver = &ps874x_usb_mux_driver,
+ .i2c_addr_flags = PS8740_I2C_ADDR0_FLAG,
+ .driver = &ps8740_usb_mux_driver,
.next_mux = &usbc1_amd_fp5_usb_mux,
}
};
diff --git a/baseboard/zork/variant_trembyle.c b/baseboard/zork/variant_trembyle.c
index 0d131db677..c81a79802e 100644
--- a/baseboard/zork/variant_trembyle.c
+++ b/baseboard/zork/variant_trembyle.c
@@ -11,6 +11,7 @@
#include "driver/retimer/tusb544.h"
#include "driver/tcpm/nct38xx.h"
#include "driver/usb_mux/amd_fp5.h"
+#include "driver/usb_mux/ps8743.h"
#include "fan.h"
#include "fan_chip.h"
#include "gpio.h"
@@ -306,8 +307,8 @@ const struct usb_mux usbc1_tusb544 = {
const struct usb_mux usbc1_ps8743 = {
.usb_port = USBC_PORT_C1,
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr_flags = PS8743_I2C_ADDR_FLAGS,
- .driver = &ps874x_usb_mux_driver,
+ .i2c_addr_flags = PS8743_I2C_ADDR1_FLAG,
+ .driver = &ps8743_usb_mux_driver,
};
struct usb_mux usbc1_amd_fp5_usb_mux = {
.usb_port = USBC_PORT_C1,
diff --git a/board/chell/board.c b/board/chell/board.c
index 1472d7e5e9..1315235f8d 100644
--- a/board/chell/board.c
+++ b/board/chell/board.c
@@ -34,7 +34,7 @@
#include "uart.h"
#include "usb_charge.h"
#include "usb_mux.h"
-#include "usb_mux/ps874x.h"
+#include "usb_mux/ps8740.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#include "util.h"
@@ -171,12 +171,12 @@ struct pi3usb9281_config pi3usb9281_chips[] = {
BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT);
-static int ps874x_tune_mux(int port)
+static int ps8740_tune_mux(int port)
{
/* Apply same USB EQ settings to both Type-C mux */
- ps874x_tune_usb_eq(port,
- PS874X_USB_EQ_TX_6_5_DB,
- PS874X_USB_EQ_RX_14_3_DB);
+ ps8740_tune_usb_eq(port,
+ PS8740_USB_EQ_TX_6_5_DB,
+ PS8740_USB_EQ_RX_14_3_DB);
return EC_SUCCESS;
}
@@ -186,15 +186,15 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
.usb_port = 0,
.i2c_port = I2C_PORT_USB_MUX,
.i2c_addr_flags = 0x1A,
- .driver = &ps874x_usb_mux_driver,
- .board_init = &ps874x_tune_mux,
+ .driver = &ps8740_usb_mux_driver,
+ .board_init = &ps8740_tune_mux,
},
{
.usb_port = 1,
.i2c_port = I2C_PORT_USB_MUX,
.i2c_addr_flags = 0x10,
- .driver = &ps874x_usb_mux_driver,
- .board_init = &ps874x_tune_mux,
+ .driver = &ps8740_usb_mux_driver,
+ .board_init = &ps8740_tune_mux,
}
};
diff --git a/board/ezkinil/board.c b/board/ezkinil/board.c
index 1c88037340..cf84888f8b 100644
--- a/board/ezkinil/board.c
+++ b/board/ezkinil/board.c
@@ -11,7 +11,7 @@
#include "driver/accel_kx022.h"
#include "driver/retimer/tusb544.h"
#include "driver/usb_mux/amd_fp5.h"
-#include "driver/usb_mux/ps874x.h"
+#include "driver/usb_mux/ps8743.h"
#include "extpower.h"
#include "fan.h"
#include "fan_chip.h"
diff --git a/board/glados/board.c b/board/glados/board.c
index f973e4f74b..73b8e3ed86 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -175,7 +175,7 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
.usb_port = 1,
.i2c_port = I2C_PORT_USB_MUX,
.i2c_addr_flags = 0x10,
- .driver = &ps874x_usb_mux_driver,
+ .driver = &ps8740_usb_mux_driver,
}
};
diff --git a/board/glkrvp/chg_usb_pd.c b/board/glkrvp/chg_usb_pd.c
index 634da73a1c..f396177d81 100644
--- a/board/glkrvp/chg_usb_pd.c
+++ b/board/glkrvp/chg_usb_pd.c
@@ -55,13 +55,13 @@ const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
.usb_port = 0,
.i2c_port = I2C_PORT_USB_MUX,
.i2c_addr_flags = 0x10,
- .driver = &ps874x_usb_mux_driver,
+ .driver = &ps8743_usb_mux_driver,
},
{
.usb_port = 1,
.i2c_port = I2C_PORT_USB_MUX,
.i2c_addr_flags = 0x11,
- .driver = &ps874x_usb_mux_driver,
+ .driver = &ps8743_usb_mux_driver,
},
};
diff --git a/board/glkrvp_ite/chg_usb_pd.c b/board/glkrvp_ite/chg_usb_pd.c
index 87ff5bf6d9..0f425ecf7b 100644
--- a/board/glkrvp_ite/chg_usb_pd.c
+++ b/board/glkrvp_ite/chg_usb_pd.c
@@ -55,13 +55,13 @@ const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
.usb_port = 0,
.i2c_port = I2C_PORT_USB_MUX,
.i2c_addr_flags = 0x10,
- .driver = &ps874x_usb_mux_driver,
+ .driver = &ps8743_usb_mux_driver,
},
{
.usb_port = 1,
.i2c_port = I2C_PORT_USB_MUX,
.i2c_addr_flags = 0x11,
- .driver = &ps874x_usb_mux_driver,
+ .driver = &ps8743_usb_mux_driver,
},
};
diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c
index d6e8da3a02..519107a929 100644
--- a/board/mchpevb1/board.c
+++ b/board/mchpevb1/board.c
@@ -398,7 +398,7 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
.usb_port = 1,
.i2c_port = I2C_PORT_USB_MUX,
.i2c_addr_flags = 0x10,
- .driver = &ps874x_usb_mux_driver,
+ .driver = &ps8740_usb_mux_driver,
}
};
#endif
diff --git a/board/oak/board.c b/board/oak/board.c
index e79dc31460..fcde44a0cd 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -210,7 +210,7 @@ const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
.driver = &pi3usb3x532_usb_mux_driver,
#else
.i2c_addr_flags = 0x10,
- .driver = &ps874x_usb_mux_driver,
+ .driver = &ps8740_usb_mux_driver,
#endif
},
};
diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c
index 5c5796bb9e..a9af42a492 100644
--- a/board/reef_it8320/board.c
+++ b/board/reef_it8320/board.c
@@ -175,7 +175,7 @@ const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
.usb_port = 1,
.i2c_port = I2C_PORT_USB_MUX,
.i2c_addr_flags = 0x10,
- .driver = &ps874x_usb_mux_driver,
+ .driver = &ps8740_usb_mux_driver,
.hpd_update = &it83xx_tcpc_update_hpd_status,
},
};
diff --git a/driver/build.mk b/driver/build.mk
index 82ad5920f4..d8acfc2d01 100644
--- a/driver/build.mk
+++ b/driver/build.mk
@@ -158,9 +158,9 @@ driver-$(CONFIG_USB_MUX_ANX7440)+=usb_mux/anx7440.o
driver-$(CONFIG_USB_MUX_IT5205)+=usb_mux/it5205.o
driver-$(CONFIG_USB_MUX_PI3USB30532)+=usb_mux/pi3usb3x532.o
driver-$(CONFIG_USB_MUX_PI3USB31532)+=usb_mux/pi3usb3x532.o
-driver-$(CONFIG_USB_MUX_PS8740)+=usb_mux/ps874x.o
-driver-$(CONFIG_USB_MUX_PS8742)+=usb_mux/ps874x.o
-driver-$(CONFIG_USB_MUX_PS8743)+=usb_mux/ps874x.o
+driver-$(CONFIG_USB_MUX_PS8740)+=usb_mux/ps8740.o
+driver-$(CONFIG_USB_MUX_PS8742)+=usb_mux/ps8740.o
+driver-$(CONFIG_USB_MUX_PS8743)+=usb_mux/ps8743.o
driver-$(CONFIG_USB_MUX_VIRTUAL)+=usb_mux/virtual.o
# Type-C Power Path Controllers (PPC)
diff --git a/driver/usb_mux/ps8740.c b/driver/usb_mux/ps8740.c
new file mode 100644
index 0000000000..b99c107610
--- /dev/null
+++ b/driver/usb_mux/ps8740.c
@@ -0,0 +1,124 @@
+/* Copyright 2020 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 (and PS8742)
+ * USB Type-C Redriving Switch for USB Host / DisplayPort.
+ */
+
+#include "common.h"
+#include "i2c.h"
+#include "ps8740.h"
+#include "usb_mux.h"
+#include "util.h"
+
+int ps8740_read(const struct usb_mux *me, uint8_t reg, int *val)
+{
+ return i2c_read8(me->i2c_port, me->i2c_addr_flags,
+ reg, val);
+}
+
+int ps8740_write(const struct usb_mux *me, uint8_t reg, uint8_t val)
+{
+ return i2c_write8(me->i2c_port, me->i2c_addr_flags,
+ reg, val);
+}
+
+static int ps8740_init(const struct usb_mux *me)
+{
+ int id1;
+ int id2;
+ int res;
+
+ /* Reset chip back to power-on state */
+ res = ps8740_write(me, PS8740_REG_MODE, PS8740_MODE_POWER_DOWN);
+ if (res)
+ return res;
+
+ /*
+ * Verify chip ID registers.
+ */
+ res = ps8740_read(me, PS8740_REG_CHIP_ID1, &id1);
+ if (res)
+ return res;
+
+ res = ps8740_read(me, PS8740_REG_CHIP_ID2, &id2);
+ if (res)
+ return res;
+
+ if (id1 != PS8740_CHIP_ID1 || id2 != PS8740_CHIP_ID2)
+ return EC_ERROR_UNKNOWN;
+
+ /*
+ * Verify revision ID registers.
+ */
+ res = ps8740_read(me, PS8740_REG_REVISION_ID1, &id1);
+ if (res)
+ return res;
+
+ res = ps8740_read(me, PS8740_REG_REVISION_ID2, &id2);
+ if (res)
+ return res;
+
+ if (id1 != PS8740_REVISION_ID1)
+ return EC_ERROR_UNKNOWN;
+ /* PS8740 may have REVISION_ID2 as 0xa or 0xb */
+ if (id2 != PS8740_REVISION_ID2_0 && id2 != PS8740_REVISION_ID2_1)
+ return EC_ERROR_UNKNOWN;
+
+ return EC_SUCCESS;
+}
+
+/* Writes control register to set switch mode */
+static int ps8740_set_mux(const struct usb_mux *me, mux_state_t mux_state)
+{
+ uint8_t reg = 0;
+
+ if (mux_state & USB_PD_MUX_USB_ENABLED)
+ reg |= PS8740_MODE_USB_ENABLED;
+ if (mux_state & USB_PD_MUX_DP_ENABLED)
+ reg |= PS8740_MODE_DP_ENABLED;
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ reg |= PS8740_MODE_POLARITY_INVERTED;
+
+ return ps8740_write(me, PS8740_REG_MODE, reg);
+}
+
+/* Reads control register and updates mux_state accordingly */
+static int ps8740_get_mux(const struct usb_mux *me, mux_state_t *mux_state)
+{
+ int reg;
+ int res;
+
+ res = ps8740_read(me, PS8740_REG_STATUS, &reg);
+ if (res)
+ return res;
+
+ *mux_state = 0;
+ if (reg & PS8740_STATUS_USB_ENABLED)
+ *mux_state |= USB_PD_MUX_USB_ENABLED;
+ if (reg & PS8740_STATUS_DP_ENABLED)
+ *mux_state |= USB_PD_MUX_DP_ENABLED;
+ if (reg & PS8740_STATUS_POLARITY_INVERTED)
+ *mux_state |= USB_PD_MUX_POLARITY_INVERTED;
+
+ return EC_SUCCESS;
+}
+
+/* Tune USB Tx/Rx Equalization */
+int ps8740_tune_usb_eq(int port, uint8_t tx, uint8_t rx)
+{
+ int ret;
+ const struct usb_mux *me = &usb_muxes[port];
+
+ ret = ps8740_write(me, PS8740_REG_USB_EQ_TX, tx);
+ ret |= ps8740_write(me, 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/ps8740.h b/driver/usb_mux/ps8740.h
new file mode 100644
index 0000000000..084719d03e
--- /dev/null
+++ b/driver/usb_mux/ps8740.h
@@ -0,0 +1,91 @@
+/* Copyright 2020 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 (and PS8742)
+ * USB Type-C Redriving Switch for USB Host / DisplayPort.
+ */
+
+#ifndef __CROS_EC_PS8740_H
+#define __CROS_EC_PS8740_H
+
+#include "usb_mux.h"
+
+#define PS8740_I2C_ADDR0_FLAG 0x10
+#define PS8740_I2C_ADDR1_FLAG 0x11
+#define PS8740_I2C_ADDR2_FLAG 0x19
+#define PS8740_I2C_ADDR3_FLAG 0x1a
+
+/* Mode register for setting mux */
+#define PS8740_REG_MODE 0x00
+#define PS8740_MODE_POLARITY_INVERTED BIT(4)
+#define PS8740_MODE_USB_ENABLED BIT(5)
+#define PS8740_MODE_DP_ENABLED BIT(6)
+#ifdef CONFIG_USB_MUX_PS8740
+ #define PS8740_MODE_POWER_DOWN BIT(7)
+#elif defined(CONFIG_USB_MUX_PS8742)
+ #define PS8740_MODE_CE_DP_ENABLED BIT(7)
+ /* To reset the state machine to default */
+ #define PS8740_MODE_POWER_DOWN 0
+#endif
+
+/* Status register for checking mux state */
+#define PS8740_REG_STATUS 0x09
+#define PS8740_STATUS_POLARITY_INVERTED BIT(2)
+#define PS8740_STATUS_USB_ENABLED BIT(3)
+#define PS8740_STATUS_DP_ENABLED BIT(4)
+#define PS8740_STATUS_HPD_ASSERTED BIT(7)
+
+/* Chip ID / revision registers and expected fused values */
+#define PS8740_REG_REVISION_ID1 0xf0
+#define PS8740_REG_REVISION_ID2 0xf1
+#define PS8740_REG_CHIP_ID1 0xf2
+#define PS8740_REG_CHIP_ID2 0xf3
+#ifdef CONFIG_USB_MUX_PS8740
+ #define PS8740_REVISION_ID1 0x00
+ #define PS8740_REVISION_ID2_0 0x0a
+ #define PS8740_REVISION_ID2_1 0x0b
+ #define PS8740_CHIP_ID1 0x40
+#elif defined(CONFIG_USB_MUX_PS8742)
+ #define PS8740_REVISION_ID1 0x01
+ #define PS8740_REVISION_ID2_0 0x0a
+ #define PS8740_REVISION_ID2_1 0x0a
+ #define PS8740_CHIP_ID1 0x42
+#endif
+#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 BIT(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);
+int ps8740_write(const struct usb_mux *me, uint8_t reg, uint8_t val);
+int ps8740_read(const struct usb_mux *me, uint8_t reg, int *val);
+
+#endif /* __CROS_EC_PS8740_H */
diff --git a/driver/usb_mux/ps8743.c b/driver/usb_mux/ps8743.c
new file mode 100644
index 0000000000..c44a2f9c89
--- /dev/null
+++ b/driver/usb_mux/ps8743.c
@@ -0,0 +1,126 @@
+/* Copyright 2020 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.
+ */
+
+#include "common.h"
+#include "i2c.h"
+#include "ps8743.h"
+#include "usb_mux.h"
+#include "util.h"
+
+int ps8743_read(const struct usb_mux *me, uint8_t reg, int *val)
+{
+ return i2c_read8(me->i2c_port, me->i2c_addr_flags,
+ reg, val);
+}
+
+int ps8743_write(const struct usb_mux *me, uint8_t reg, uint8_t val)
+{
+ return i2c_write8(me->i2c_port, me->i2c_addr_flags,
+ reg, val);
+}
+
+static int ps8743_init(const struct usb_mux *me)
+{
+ int id1;
+ int id2;
+ int res;
+
+ /* Reset chip back to power-on state */
+ res = ps8743_write(me, PS8743_REG_MODE, PS8743_MODE_POWER_DOWN);
+ if (res)
+ return res;
+
+ /*
+ * Verify chip ID registers.
+ */
+ res = ps8743_read(me, PS8743_REG_CHIP_ID1, &id1);
+ if (res)
+ return res;
+
+ res = ps8743_read(me, PS8743_REG_CHIP_ID2, &id2);
+ if (res)
+ return res;
+
+ if (id1 != PS8743_CHIP_ID1 || id2 != PS8743_CHIP_ID2)
+ return EC_ERROR_UNKNOWN;
+
+ /*
+ * Verify revision ID registers.
+ */
+ res = ps8743_read(me, PS8743_REG_REVISION_ID1, &id1);
+ if (res)
+ return res;
+
+ res = ps8743_read(me, PS8743_REG_REVISION_ID2, &id2);
+ if (res)
+ return res;
+
+ /*
+ * From Parade: PS8743 may have REVISION_ID1 as 0 or 1
+ * Rev 1 is derived from Rev 0 and have same functionality.
+ */
+ if (id1 != PS8743_REVISION_ID1_0 && id1 != PS8743_REVISION_ID1_1)
+ return EC_ERROR_UNKNOWN;
+ if (id2 != PS8743_REVISION_ID2)
+ return EC_ERROR_UNKNOWN;
+
+ return EC_SUCCESS;
+}
+
+/* Writes control register to set switch mode */
+static int ps8743_set_mux(const struct usb_mux *me, mux_state_t mux_state)
+{
+ uint8_t reg = 0;
+
+ if (mux_state & USB_PD_MUX_USB_ENABLED)
+ reg |= PS8743_MODE_USB_ENABLED;
+ if (mux_state & USB_PD_MUX_DP_ENABLED)
+ reg |= PS8743_MODE_DP_ENABLED;
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ reg |= PS8743_MODE_POLARITY_INVERTED;
+
+ return ps8743_write(me, PS8743_REG_MODE, reg);
+}
+
+/* Reads control register and updates mux_state accordingly */
+static int ps8743_get_mux(const struct usb_mux *me, mux_state_t *mux_state)
+{
+ int reg;
+ int res;
+
+ res = ps8743_read(me, PS8743_REG_STATUS, &reg);
+ if (res)
+ return res;
+
+ *mux_state = 0;
+ if (reg & PS8743_STATUS_USB_ENABLED)
+ *mux_state |= USB_PD_MUX_USB_ENABLED;
+ if (reg & PS8743_STATUS_DP_ENABLED)
+ *mux_state |= USB_PD_MUX_DP_ENABLED;
+ if (reg & PS8743_STATUS_POLARITY_INVERTED)
+ *mux_state |= USB_PD_MUX_POLARITY_INVERTED;
+
+ return EC_SUCCESS;
+}
+
+/* Tune USB Tx/Rx Equalization */
+int ps8743_tune_usb_eq(int port, uint8_t tx, uint8_t rx)
+{
+ int ret;
+ const struct usb_mux *me = &usb_muxes[port];
+
+ ret = ps8743_write(me, PS8743_REG_USB_EQ_TX, tx);
+ ret |= ps8743_write(me, PS8743_REG_USB_EQ_RX, rx);
+
+ return ret;
+}
+
+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/ps8743.h b/driver/usb_mux/ps8743.h
new file mode 100644
index 0000000000..b728e49523
--- /dev/null
+++ b/driver/usb_mux/ps8743.h
@@ -0,0 +1,80 @@
+/* Copyright 2020 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
+
+#include "usb_mux.h"
+
+#define PS8743_I2C_ADDR0_FLAG 0x10
+#define PS8743_I2C_ADDR1_FLAG 0x11
+#define PS8743_I2C_ADDR2_FLAG 0x19
+#define PS8743_I2C_ADDR3_FLAG 0x1a
+
+/* Mode register for setting mux */
+#define PS8743_REG_MODE 0x00
+#define PS8743_MODE_POLARITY_INVERTED BIT(2)
+#define PS8743_MODE_FLIP_PIN_ENABLED BIT(3)
+#define PS8743_MODE_USB_ENABLED BIT(4)
+#define PS8743_MODE_CE_USB_ENABLED BIT(5)
+#define PS8743_MODE_DP_ENABLED BIT(6)
+#define PS8743_MODE_CE_DP_ENABLED BIT(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 BIT(2)
+#define PS8743_STATUS_USB_ENABLED BIT(3)
+#define PS8743_STATUS_DP_ENABLED BIT(4)
+#define PS8743_STATUS_HPD_ASSERTED BIT(7)
+
+/* Chip ID / revision registers and expected fused values */
+#define PS8743_REG_REVISION_ID1 0xf0
+#define PS8743_REG_REVISION_ID2 0xf1
+#define PS8743_REG_CHIP_ID1 0xf2
+#define PS8743_REG_CHIP_ID2 0xf3
+#define PS8743_REVISION_ID1_0 0x00
+#define PS8743_REVISION_ID1_1 0x01
+#define PS8743_REVISION_ID2 0x0b
+#define PS8743_CHIP_ID1 0x41
+#define PS8743_CHIP_ID2 0x87
+
+/* USB equalization settings for Host to Mux */
+#define PS8743_REG_USB_EQ_TX 0x32
+#define PS8743_USB_EQ_TX_12_8_DB 0x00
+#define PS8743_USB_EQ_TX_17_DB 0x20
+#define PS8743_USB_EQ_TX_7_7_DB 0x40
+#define PS8743_USB_EQ_TX_3_6_DB 0x60
+#define PS8743_USB_EQ_TX_15_DB 0x80
+#define PS8743_USB_EQ_TX_10_9_DB 0xc0
+#define PS8743_USB_EQ_TX_4_5_DB 0xe0
+
+/* USB equalization settings for Connector to Mux */
+#define PS8743_REG_USB_EQ_RX 0x3b
+#define PS8743_USB_EQ_RX_2_4_DB 0x00
+#define PS8743_USB_EQ_RX_5_DB 0x10
+#define PS8743_USB_EQ_RX_6_5_DB 0x20
+#define PS8743_USB_EQ_RX_7_4_DB 0x30
+#define PS8743_USB_EQ_RX_8_7_DB 0x40
+#define PS8743_USB_EQ_RX_10_9_DB 0x50
+#define PS8743_USB_EQ_RX_12_8_DB 0x60
+#define PS8743_USB_EQ_RX_13_8_DB 0x70
+#define PS8743_USB_EQ_RX_14_8_DB 0x80
+#define PS8743_USB_EQ_RX_15_4_DB 0x90
+#define PS8743_USB_EQ_RX_16_0_DB 0xa0
+#define PS8743_USB_EQ_RX_16_7_DB 0xb0
+#define PS8743_USB_EQ_RX_18_8_DB 0xc0
+#define PS8743_USB_EQ_RX_21_3_DB 0xd0
+#define PS8743_USB_EQ_RX_22_2_DB 0xe0
+
+int ps8743_tune_usb_eq(int i2c_addr, uint8_t tx, uint8_t rx);
+int ps8743_write(const struct usb_mux *me, uint8_t reg, uint8_t val);
+int ps8743_read(const struct usb_mux *me, uint8_t reg, int *val);
+
+#endif /* __CROS_EC_PS8743_H */
diff --git a/driver/usb_mux/ps874x.c b/driver/usb_mux/ps874x.c
deleted file mode 100644
index 838fb8a7d3..0000000000
--- a/driver/usb_mux/ps874x.c
+++ /dev/null
@@ -1,134 +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 PS874X USB Type-C Redriving Switch for USB Host / DisplayPort.
- */
-
-#include "common.h"
-#include "i2c.h"
-#include "ps874x.h"
-#include "usb_mux.h"
-#include "util.h"
-
-int ps874x_read(const struct usb_mux *me, uint8_t reg, int *val)
-{
- return i2c_read8(me->i2c_port, me->i2c_addr_flags,
- reg, val);
-}
-
-int ps874x_write(const struct usb_mux *me, uint8_t reg, uint8_t val)
-{
- return i2c_write8(me->i2c_port, me->i2c_addr_flags,
- reg, val);
-}
-
-static int ps874x_init(const struct usb_mux *me)
-{
- int id1;
- int id2;
- int res;
-
- /* Reset chip back to power-on state */
- res = ps874x_write(me, PS874X_REG_MODE, PS874X_MODE_POWER_DOWN);
- if (res)
- return res;
-
- /*
- * Verify chip ID registers.
- */
- res = ps874x_read(me, PS874X_REG_CHIP_ID1, &id1);
- if (res)
- return res;
-
- res = ps874x_read(me, PS874X_REG_CHIP_ID2, &id2);
- if (res)
- return res;
-
- if (id1 != PS874X_CHIP_ID1 || id2 != PS874X_CHIP_ID2)
- return EC_ERROR_UNKNOWN;
-
- /*
- * Verify revision ID registers.
- */
- res = ps874x_read(me, PS874X_REG_REVISION_ID1, &id1);
- if (res)
- return res;
-
- res = ps874x_read(me, PS874X_REG_REVISION_ID2, &id2);
- if (res)
- return res;
-
-#ifdef CONFIG_USB_MUX_PS8740
- if (id1 != PS874X_REVISION_ID1)
- return EC_ERROR_UNKNOWN;
- /* PS8740 may have REVISION_ID2 as 0xa or 0xb */
- if (id2 != PS874X_REVISION_ID2_0 && id2 != PS874X_REVISION_ID2_1)
- return EC_ERROR_UNKNOWN;
-#else
- /*
- * From Parade: PS8743 may have REVISION_ID1 as 0 or 1
- * Rev 1 is derived from Rev 0 and have same functionality.
- */
- if (id1 != PS874X_REVISION_ID1_0 && id1 != PS874X_REVISION_ID1_1)
- return EC_ERROR_UNKNOWN;
- if (id2 != PS874X_REVISION_ID2)
- return EC_ERROR_UNKNOWN;
-#endif
-
- return EC_SUCCESS;
-}
-
-/* Writes control register to set switch mode */
-static int ps874x_set_mux(const struct usb_mux *me, mux_state_t mux_state)
-{
- uint8_t reg = 0;
-
- if (mux_state & USB_PD_MUX_USB_ENABLED)
- reg |= PS874X_MODE_USB_ENABLED;
- if (mux_state & USB_PD_MUX_DP_ENABLED)
- reg |= PS874X_MODE_DP_ENABLED;
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- reg |= PS874X_MODE_POLARITY_INVERTED;
-
- return ps874x_write(me, PS874X_REG_MODE, reg);
-}
-
-/* Reads control register and updates mux_state accordingly */
-static int ps874x_get_mux(const struct usb_mux *me, mux_state_t *mux_state)
-{
- int reg;
- int res;
-
- res = ps874x_read(me, PS874X_REG_STATUS, &reg);
- if (res)
- return res;
-
- *mux_state = 0;
- if (reg & PS874X_STATUS_USB_ENABLED)
- *mux_state |= USB_PD_MUX_USB_ENABLED;
- if (reg & PS874X_STATUS_DP_ENABLED)
- *mux_state |= USB_PD_MUX_DP_ENABLED;
- if (reg & PS874X_STATUS_POLARITY_INVERTED)
- *mux_state |= USB_PD_MUX_POLARITY_INVERTED;
-
- return EC_SUCCESS;
-}
-
-/* Tune USB Tx/Rx Equalization */
-int ps874x_tune_usb_eq(int port, uint8_t tx, uint8_t rx)
-{
- int ret;
- const struct usb_mux *me = &usb_muxes[port];
-
- ret = ps874x_write(me, PS874X_REG_USB_EQ_TX, tx);
- ret |= ps874x_write(me, 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
deleted file mode 100644
index 12b5191ddd..0000000000
--- a/driver/usb_mux/ps874x.h
+++ /dev/null
@@ -1,135 +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 PS874X USB Type-C Redriving Switch for USB Host / DisplayPort.
- */
-
-#ifndef __CROS_EC_PS874X_H
-#define __CROS_EC_PS874X_H
-
-#include "usb_mux.h"
-
-#define PS874X_I2C_ADDR0_FLAG 0x10
-#define PS874X_I2C_ADDR1_FLAG 0x11
-#define PS874X_I2C_ADDR2_FLAG 0x19
-#define PS874X_I2C_ADDR3_FLAG 0x1a
-
-/* Mode register for setting mux */
-#define PS874X_REG_MODE 0x00
-#ifdef CONFIG_USB_MUX_PS8740
- #define PS874X_MODE_POLARITY_INVERTED BIT(4)
- #define PS874X_MODE_USB_ENABLED BIT(5)
- #define PS874X_MODE_DP_ENABLED BIT(6)
- #define PS874X_MODE_POWER_DOWN BIT(7)
-#elif defined(CONFIG_USB_MUX_PS8742)
- #define PS874X_MODE_POLARITY_INVERTED BIT(4)
- #define PS874X_MODE_USB_ENABLED BIT(5)
- #define PS874X_MODE_DP_ENABLED BIT(6)
- #define PS874X_MODE_CE_DP_ENABLED BIT(7)
- /* To reset the state machine to default */
- #define PS874X_MODE_POWER_DOWN 0
-#elif defined(CONFIG_USB_MUX_PS8743)
- #define PS874X_MODE_POLARITY_INVERTED BIT(2)
- #define PS874X_MODE_FLIP_PIN_ENABLED BIT(3)
- #define PS874X_MODE_USB_ENABLED BIT(4)
- #define PS874X_MODE_CE_USB_ENABLED BIT(5)
- #define PS874X_MODE_DP_ENABLED BIT(6)
- #define PS874X_MODE_CE_DP_ENABLED BIT(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 BIT(2)
-#define PS874X_STATUS_USB_ENABLED BIT(3)
-#define PS874X_STATUS_DP_ENABLED BIT(4)
-#define PS874X_STATUS_HPD_ASSERTED BIT(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_0 0x0a
- #define PS874X_REVISION_ID2_1 0x0b
- #define PS874X_CHIP_ID1 0x40
-#elif defined(CONFIG_USB_MUX_PS8742)
- #define PS874X_REVISION_ID1 0x01
- #define PS874X_REVISION_ID2 0x0a
- #define PS874X_CHIP_ID1 0x42
-#elif defined(CONFIG_USB_MUX_PS8743)
- #define PS874X_REVISION_ID1_0 0x00
- #define PS874X_REVISION_ID1_1 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
-#if defined(CONFIG_USB_MUX_PS8740) || defined(CONFIG_USB_MUX_PS8742)
- #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 BIT(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
-#if defined(CONFIG_USB_MUX_PS8740) || defined(CONFIG_USB_MUX_PS8742)
- #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);
-int ps874x_write(const struct usb_mux *me, uint8_t reg, uint8_t val);
-int ps874x_read(const struct usb_mux *me, uint8_t reg, int *val);
-
-#endif /* __CROS_EC_PS874X_H */
diff --git a/include/usb_mux.h b/include/usb_mux.h
index b606656b61..9b24114f39 100644
--- a/include/usb_mux.h
+++ b/include/usb_mux.h
@@ -134,7 +134,8 @@ extern const struct usb_mux_driver amd_fp5_usb_mux_driver;
extern const struct usb_mux_driver anx7440_usb_mux_driver;
extern const struct usb_mux_driver it5205_usb_mux_driver;
extern const struct usb_mux_driver pi3usb3x532_usb_mux_driver;
-extern const struct usb_mux_driver ps874x_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 tcpm_usb_mux_driver;
extern const struct usb_mux_driver virtual_usb_mux_driver;