diff options
author | Raymond Chung <raymondchung@ami.corp-partner.google.com> | 2022-11-28 11:40:34 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-02 04:52:53 +0000 |
commit | 25b49cfcb6368a9ee1811f73d1be0c5f63dbd208 (patch) | |
tree | c3b084d401dc6ffef002c8607ca8a9afadd829c3 | |
parent | 72ae3419d58a781bb2f01f3e24f095989f193719 (diff) | |
download | chrome-ec-25b49cfcb6368a9ee1811f73d1be0c5f63dbd208.tar.gz |
gaelin: Add USB-A retimer support
Initialize PS8811 retimer for USB-A0 and USB-A1. Print an error if
retimer does not respond to i2c read.
BUG=b:237517617
BRANCH=None
TEST=PS8811 is detected on the console.
Change-Id: I7f7bf9f6cb030141bc5de6018353b8ffb6d11686
Signed-off-by: Raymond Chung <raymondchung@ami.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4060626
Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r-- | board/gaelin/board.c | 44 | ||||
-rw-r--r-- | board/gaelin/board.h | 5 | ||||
-rw-r--r-- | board/gaelin/gpio.inc | 2 | ||||
-rw-r--r-- | board/gaelin/i2c.c | 8 |
4 files changed, 59 insertions, 0 deletions
diff --git a/board/gaelin/board.c b/board/gaelin/board.c index 7544085c9c..dba0eaf99a 100644 --- a/board/gaelin/board.c +++ b/board/gaelin/board.c @@ -11,6 +11,7 @@ #include "compile_time_macros.h" #include "console.h" #include "cros_board_info.h" +#include "driver/retimer/ps8811.h" #include "driver/tcpm/tcpci.h" #include "fw_config.h" #include "gpio.h" @@ -41,6 +42,49 @@ const int usb_port_enable[USB_PORT_COUNT] = { BUILD_ASSERT(ARRAY_SIZE(usb_port_enable) == USB_PORT_COUNT); /******************************************************************************/ +/* USB-A retimer control */ + +const struct usb_mux usba_ps8811[] = { + [USBA_PORT_A0] = { + .usb_port = USBA_PORT_A0, + .i2c_port = I2C_PORT_USB_A0_A1_MIX, + .i2c_addr_flags = PS8811_I2C_ADDR_FLAGS0, + }, + [USBA_PORT_A1] = { + .usb_port = USBA_PORT_A1, + .i2c_port = I2C_PORT_USB_A0_A1_MIX, + .i2c_addr_flags = PS8811_I2C_ADDR_FLAGS2, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(usba_ps8811) == USBA_PORT_COUNT); + +static int usba_retimer_init(int port) +{ + int rv, val; + const struct usb_mux *me = &usba_ps8811[port]; + + rv = ps8811_i2c_read(me, PS8811_REG_PAGE1, PS8811_REG1_USB_BEQ_LEVEL, + &val); + + if (rv) { + CPRINTS("A%d: PS8811 retimer not detected!", port); + } else { + CPRINTS("A%d: PS8811 retimer detected", port); + } + + return rv; +} + +void board_chipset_startup(void) +{ + int i; + + for (i = 0; i < USBA_PORT_COUNT; i++) + usba_retimer_init(i); +} +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); + +/******************************************************************************/ int board_set_active_charge_port(int port) { diff --git a/board/gaelin/board.h b/board/gaelin/board.h index 166f0f1432..25b424b782 100644 --- a/board/gaelin/board.h +++ b/board/gaelin/board.h @@ -27,6 +27,7 @@ /* USB Type A Features */ #define USB_PORT_COUNT 4 #define CONFIG_USB_PORT_POWER_DUMB +#define CONFIG_USBC_RETIMER_PS8811 /* USB Type C and USB PD defines */ #define CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY @@ -93,6 +94,8 @@ #define I2C_PORT_USB_C0_BC12 NPCX_I2C_PORT2_0 #define I2C_PORT_USB_C1_BC12 NPCX_I2C_PORT3_0 +#define I2C_PORT_USB_A0_A1_MIX NPCX_I2C_PORT6_1 + #define I2C_PORT_EEPROM NPCX_I2C_PORT7_0 #define I2C_PORT_MP2964 NPCX_I2C_PORT7_0 @@ -161,6 +164,8 @@ enum fan_channel { FAN_CH_0 = 0, FAN_CH_COUNT }; enum mft_channel { MFT_CH_0 = 0, MFT_CH_COUNT }; +enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_A1, USBA_PORT_COUNT }; + extern void adp_connect_interrupt(enum gpio_signal signal); #endif /* !__ASSEMBLER__ */ diff --git a/board/gaelin/gpio.inc b/board/gaelin/gpio.inc index 6de7003743..3e84f2e692 100644 --- a/board/gaelin/gpio.inc +++ b/board/gaelin/gpio.inc @@ -106,6 +106,8 @@ GPIO(EC_I2C_USB_C0_TCPC_SCL, PIN(9, 0), GPIO_INPUT) GPIO(EC_I2C_USB_C0_TCPC_SDA, PIN(8, 7), GPIO_INPUT) GPIO(EC_I2C_USB_C1_TCPC_SCL, PIN(F, 3), GPIO_INPUT) GPIO(EC_I2C_USB_C1_TCPC_SDA, PIN(F, 2), GPIO_INPUT) +GPIO(EC_I2C_USB_A0_A1_MIX_SCL, PIN(E, 4), GPIO_INPUT) +GPIO(EC_I2C_USB_A0_A1_MIX_SDA, PIN(E, 3), GPIO_INPUT) /* USBA */ GPIO(EN_PP5000_USBA, PIN(D, 7), GPIO_OUT_LOW) diff --git a/board/gaelin/i2c.c b/board/gaelin/i2c.c index ef7e1ca09f..ce285d16b4 100644 --- a/board/gaelin/i2c.c +++ b/board/gaelin/i2c.c @@ -50,6 +50,14 @@ const struct i2c_port_t i2c_ports[] = { .sda = GPIO_SMSCALER_DATA, }, { + /* I2C6 */ + .name = "usba0_retimer,usba1_retimer", + .port = I2C_PORT_USB_A0_A1_MIX, + .kbps = 1000, + .scl = GPIO_EC_I2C_USB_A0_A1_MIX_SCL, + .sda = GPIO_EC_I2C_USB_A0_A1_MIX_SDA, + }, + { /* I2C7 */ .name = "eeprom", .port = I2C_PORT_EEPROM, |