summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZick Wei <zick.wei@quanta.corp-partner.google.com>2022-01-22 10:28:16 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-06-16 07:09:42 +0000
commita3af20f62beaad35e6dc708db76b76ef941ad91e (patch)
treed9739d351c1d0a9354d707a6844451c035ef22a0
parent32ab8778773f5fb09ff455a08d224917c7148b4e (diff)
downloadchrome-ec-a3af20f62beaad35e6dc708db76b76ef941ad91e.tar.gz
agah: support USBC retimer
This patch apply support of USBC retimer ps8818 on USBC2, will upload another CL after EQ setting confirmed. BUG=b:218400524, b:233552228 BRANCH=none TEST=make BOARD=agah Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Change-Id: I3f6490dd8809b37cf974f2663374a472399c5861 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3406469 Commit-Queue: Kenny Pan <kennypan@google.com> Reviewed-by: Kenny Pan <kennypan@google.com> Reviewed-by: caveh jalali <caveh@chromium.org>
-rw-r--r--board/agah/board.h1
-rw-r--r--board/agah/usbc_config.c77
-rw-r--r--board/agah/usbc_config.h6
3 files changed, 74 insertions, 10 deletions
diff --git a/board/agah/board.h b/board/agah/board.h
index ed8b43ffd9..7655f9a4fe 100644
--- a/board/agah/board.h
+++ b/board/agah/board.h
@@ -51,6 +51,7 @@
/* USB Type C and USB PD defines */
#define CONFIG_USB_PD_TCPM_RT1715
#undef CONFIG_USB_PD_TCPM_NCT38XX
+#define CONFIG_USBC_RETIMER_PS8818
/* I2C speed console command */
#define CONFIG_CMD_I2C_SPEED
diff --git a/board/agah/usbc_config.c b/board/agah/usbc_config.c
index d3d20c96c5..0902f2f799 100644
--- a/board/agah/usbc_config.c
+++ b/board/agah/usbc_config.c
@@ -14,6 +14,7 @@
#include "console.h"
#include "driver/bc12/pi3usb9201_public.h"
#include "driver/ppc/syv682x_public.h"
+#include "driver/retimer/ps8818.h"
#include "driver/tcpm/rt1715.h"
#include "driver/tcpm/tcpci.h"
#include "ec_commands.h"
@@ -85,30 +86,86 @@ struct ppc_config_t ppc_chips[] = {
unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
-/* USBC mux configuration - Alder Lake includes internal mux */
-static const struct usb_mux usbc0_tcss_usb_mux = {
- .usb_port = USBC_PORT_C0,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
+const static struct ps8818_reg_val equalizer_default_table[] = {
+ {
+ .reg = PS8818_REG1_APTX1EQ_10G_LEVEL,
+ .mask = PS8818_EQ_LEVEL_UP_MASK,
+ .val = PS8818_EQ_LEVEL_UP_19DB,
+ },
+ {
+ .reg = PS8818_REG1_APTX2EQ_10G_LEVEL,
+ .mask = PS8818_EQ_LEVEL_UP_MASK,
+ .val = PS8818_EQ_LEVEL_UP_19DB,
+ },
+ {
+ .reg = PS8818_REG1_APTX1EQ_5G_LEVEL,
+ .mask = PS8818_EQ_LEVEL_UP_MASK,
+ .val = PS8818_EQ_LEVEL_UP_19DB,
+ },
+ {
+ .reg = PS8818_REG1_APTX2EQ_5G_LEVEL,
+ .mask = PS8818_EQ_LEVEL_UP_MASK,
+ .val = PS8818_EQ_LEVEL_UP_19DB,
+ },
+ {
+ .reg = PS8818_REG1_RX_PHY,
+ .mask = PS8818_RX_INPUT_TERM_MASK,
+ .val = PS8818_RX_INPUT_TERM_112_OHM,
+ },
};
-static const struct usb_mux usbc2_tcss_usb_mux = {
+
+#define NUM_EQ_DEFAULT_ARRAY ARRAY_SIZE(equalizer_default_table)
+
+int board_ps8818_mux_set(const struct usb_mux *me,
+ mux_state_t mux_state)
+{
+ int rv = EC_SUCCESS;
+ int i;
+
+ /* USB specific config */
+ if (mux_state & USB_PD_MUX_USB_ENABLED) {
+
+ /* Boost the USB gain */
+ for (i = 0; i < NUM_EQ_DEFAULT_ARRAY; i++)
+ rv |= ps8818_i2c_field_update8(me, PS8818_REG_PAGE1,
+ equalizer_default_table[i].reg,
+ equalizer_default_table[i].mask,
+ equalizer_default_table[i].val);
+ }
+
+ /* DP specific config */
+ if (mux_state & USB_PD_MUX_DP_ENABLED) {
+ /* Boost the DP gain */
+ rv |= ps8818_i2c_field_update8(me,
+ PS8818_REG_PAGE1,
+ PS8818_REG1_DPEQ_LEVEL,
+ PS8818_DPEQ_LEVEL_UP_MASK,
+ PS8818_DPEQ_LEVEL_UP_19DB);
+ }
+
+ return rv;
+}
+
+const static struct usb_mux usbc2_ps8818 = {
.usb_port = USBC_PORT_C2,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
+ .i2c_port = I2C_PORT_USB_C2_TCPC,
+ .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS,
+ .driver = &ps8818_usb_retimer_driver,
+ .board_set = &board_ps8818_mux_set,
};
+/* USBC mux configuration - Alder Lake includes internal mux */
const struct usb_mux usb_muxes[] = {
[USBC_PORT_C0] = {
.usb_port = USBC_PORT_C0,
.driver = &virtual_usb_mux_driver,
.hpd_update = &virtual_hpd_update,
- .next_mux = &usbc0_tcss_usb_mux,
},
[USBC_PORT_C2] = {
.usb_port = USBC_PORT_C2,
.driver = &virtual_usb_mux_driver,
.hpd_update = &virtual_hpd_update,
- .next_mux = &usbc2_tcss_usb_mux,
+ .next_mux = &usbc2_ps8818,
},
};
BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
diff --git a/board/agah/usbc_config.h b/board/agah/usbc_config.h
index b9f2c2ffff..e5b7576d72 100644
--- a/board/agah/usbc_config.h
+++ b/board/agah/usbc_config.h
@@ -16,4 +16,10 @@ enum usbc_port {
USBC_PORT_COUNT
};
+struct ps8818_reg_val {
+ uint8_t reg;
+ uint8_t mask;
+ uint16_t val;
+};
+
#endif /* __CROS_EC_USBC_CONFIG_H */