diff options
-rw-r--r-- | baseboard/volteer/baseboard.c | 113 | ||||
-rw-r--r-- | baseboard/volteer/baseboard.h | 13 | ||||
-rw-r--r-- | baseboard/volteer/cbi_ec_fw_config.c | 7 | ||||
-rw-r--r-- | board/volteer/board.c | 144 | ||||
-rw-r--r-- | board/volteer/board.h | 2 |
5 files changed, 140 insertions, 139 deletions
diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c index 78d720eedc..d51e99a921 100644 --- a/baseboard/volteer/baseboard.c +++ b/baseboard/volteer/baseboard.c @@ -267,37 +267,6 @@ struct tcpc_config_t tcpc_config[] = { BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT); BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT); -/* USBC TCPC configuration for port 1 on USB3 board */ -static const struct tcpc_config_t tcpc_config_p1_usb3 = { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1, - .addr_flags = PS8751_I2C_ADDR1_FLAGS, - }, - .flags = TCPC_FLAGS_TCPCI_REV2_0 | TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V, - .drv = &ps8xxx_tcpm_drv, - .usb23 = USBC_PORT_1_USB2_NUM | (USBC_PORT_1_USB3_NUM << 4), -}; - -/* - * USB3 DB mux configuration - the top level mux still needs to be set to the - * virutal_usb_mux_driver so the AP gets notified of mux changes and updates - * the TCSS configuration on state changes. - */ -static const struct usb_mux usbc1_usb3_db_retimer = { - .usb_port = USBC_PORT_C1, - .driver = &tcpci_tcpm_usb_mux_driver, - .hpd_update = &ps8xxx_tcpc_update_hpd_status, - .next_mux = NULL, -}; - -static const struct usb_mux mux_config_p1_usb3 = { - .usb_port = USBC_PORT_C1, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, - .next_mux = &usbc1_usb3_db_retimer, -}; - /******************************************************************************/ /* USBC PPC configuration */ struct ppc_config_t ppc_chips[] = { @@ -388,50 +357,6 @@ void ppc_interrupt(enum gpio_signal signal) /******************************************************************************/ /* TCPC support routines */ -enum gpio_signal ps8xxx_rst_odl = GPIO_USB_C1_RT_RST_ODL; - -static void ps8815_reset(void) -{ - int val; - - gpio_set_level(ps8xxx_rst_odl, 0); - msleep(GENERIC_MAX(PS8XXX_RESET_DELAY_MS, - PS8815_PWR_H_RST_H_DELAY_MS)); - gpio_set_level(ps8xxx_rst_odl, 1); - msleep(PS8815_FW_INIT_DELAY_MS); - - /* - * b/144397088 - * ps8815 firmware 0x01 needs special configuration - */ - - CPRINTS("%s: patching ps8815 registers", __func__); - - if (i2c_read8(I2C_PORT_USB_C1, - PS8751_I2C_ADDR1_P2_FLAGS, 0x0f, &val) == EC_SUCCESS) - CPRINTS("ps8815: reg 0x0f was %02x", val); - - if (i2c_write8(I2C_PORT_USB_C1, - PS8751_I2C_ADDR1_P2_FLAGS, 0x0f, 0x31) == EC_SUCCESS) - CPRINTS("ps8815: reg 0x0f set to 0x31"); - - if (i2c_read8(I2C_PORT_USB_C1, - PS8751_I2C_ADDR1_P2_FLAGS, 0x0f, &val) == EC_SUCCESS) - CPRINTS("ps8815: reg 0x0f now %02x", val); -} - -void board_reset_pd_mcu(void) -{ - enum ec_cfg_usb_db_type usb_db = ec_cfg_usb_db_type(); - - /* No reset available for TCPC on port 0 */ - /* Daughterboard specific reset for port 1 */ - if (usb_db == DB_USB3_ACTIVE) { - ps8815_reset(); - usb_mux_hpd_update(USBC_PORT_C1, 0, 0); - } -} - uint16_t tcpc_get_alert_status(void) { uint16_t status = 0; @@ -573,18 +498,6 @@ static void baseboard_init(void) } DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_DEFAULT); -/* - * Set up support for the USB3 daughterboard: - * Parade PS8815 TCPC (integrated retimer) - * Diodes PI3USB9201 BC 1.2 chip (same as USB4 board) - * Silergy SYV682A PPC (same as USB4 board) - */ -static void config_db_usb3(void) -{ - tcpc_config[USBC_PORT_C1] = tcpc_config_p1_usb3; - usb_muxes[USBC_PORT_C1] = mux_config_p1_usb3; -} - static uint8_t board_id; uint8_t get_board_id(void) @@ -592,11 +505,10 @@ uint8_t get_board_id(void) return board_id; } -__overridable void config_volteer_gpios(void) +__overridable void board_cbi_init(void) { } -static const char *db_type_prefix = "USB DB type: "; /* * Read CBI from i2c eeprom and initialize variables for board variants * @@ -606,7 +518,6 @@ static const char *db_type_prefix = "USB DB type: "; static void cbi_init(void) { uint32_t cbi_val; - enum ec_cfg_usb_db_type usb_db; /* Board ID */ if (cbi_get_board_version(&cbi_val) != EC_SUCCESS || @@ -617,28 +528,10 @@ static void cbi_init(void) CPRINTS("Board ID: %d", board_id); - config_volteer_gpios(); - /* FW config */ init_fw_config(); - usb_db = ec_cfg_usb_db_type(); - switch (usb_db) { - case DB_USB_ABSENT: - CPRINTS("%sNone", db_type_prefix); - break; - case DB_USB4_GEN2: - CPRINTS("%sUSB4 Gen1/2", db_type_prefix); - break; - case DB_USB4_GEN3: - CPRINTS("%sUSB4 Gen3", db_type_prefix); - break; - case DB_USB3_ACTIVE: - config_db_usb3(); - CPRINTS("%sUSB3 Active", db_type_prefix); - break; - default: - CPRINTS("%sID %d not supported", db_type_prefix, usb_db); - } + /* Allow the board project to make runtime changes based on CBI data */ + board_cbi_init(); } DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_FIRST); diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h index a134c9ced8..7ad485fbe8 100644 --- a/baseboard/volteer/baseboard.h +++ b/baseboard/volteer/baseboard.h @@ -266,10 +266,6 @@ enum usbc_port { USBC_PORT_COUNT }; -extern enum gpio_signal ps8xxx_rst_odl; - -void board_reset_pd_mcu(void); - /* Common definition for the USB PD interrupt handlers. */ void ppc_interrupt(enum gpio_signal signal); void tcpc_alert_event(enum gpio_signal signal); @@ -278,11 +274,12 @@ void bc12_interrupt(enum gpio_signal signal); unsigned char get_board_id(void); /** - * Configure GPIOs based on the CBI board version. Boards in the Volteer - * family can optionally implement this function to change GPIO definitions for - * different board build phases. + * Configure run-time data structures and operation based on CBI data. This + * typically includes customization for changes in the BOARD_VERSION and + * FW_CONFIG fields in CBI. This routine is called from the baseboard after + * the CBI data has been initialized. */ -__override_proto void config_volteer_gpios(void); +__override_proto void board_cbi_init(void); #endif /* !__ASSEMBLER__ */ diff --git a/baseboard/volteer/cbi_ec_fw_config.c b/baseboard/volteer/cbi_ec_fw_config.c index 145115e930..788f152b92 100644 --- a/baseboard/volteer/cbi_ec_fw_config.c +++ b/baseboard/volteer/cbi_ec_fw_config.c @@ -13,13 +13,6 @@ static union volteer_cbi_fw_config fw_config; BUILD_ASSERT(sizeof(fw_config) == sizeof(uint32_t)); -/* - * TODO in separate CL. Update FW_CONFIG default for all Volteer projects - */ -union volteer_cbi_fw_config fw_config_defaults = { - .usb_db = DB_USB4_GEN2, -}; - /**************************************************************************** * Volteer FW_CONFIG access */ diff --git a/board/volteer/board.c b/board/volteer/board.c index ad1c6006b4..eb83f3ee26 100644 --- a/board/volteer/board.c +++ b/board/volteer/board.c @@ -14,6 +14,8 @@ #include "driver/als_tcs3400.h" #include "driver/retimer/bb_retimer.h" #include "driver/sync.h" +#include "driver/tcpm/ps8xxx.h" +#include "driver/tcpm/tcpci.h" #include "extpower.h" #include "fan.h" #include "fan_chip.h" @@ -38,21 +40,11 @@ #define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args) /* - * Reconfigure Volteer GPIOs based on the board ID + * FW_CONFIG defaults for Volteer if the CBI data is not initialized. */ -__override void config_volteer_gpios(void) -{ - /* Legacy support for the first board build */ - if (get_board_id() == 0) { - CPRINTS("Configuring GPIOs for board ID 0"); - CPRINTS("VOLUME_UP button disabled"); - - /* Reassign USB_C1_RT_RST_ODL */ - bb_controls[USBC_PORT_C1].retimer_rst_gpio = - GPIO_USB_C1_RT_RST_ODL_BOARDID_0; - ps8xxx_rst_odl = GPIO_USB_C1_RT_RST_ODL_BOARDID_0; - } -} +union volteer_cbi_fw_config fw_config_defaults = { + .usb_db = DB_USB4_GEN2, +}; static void board_init(void) { @@ -240,10 +232,134 @@ const struct pwm_t pwm_channels[] = { BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); /******************************************************************************/ +/* Volteer specific USB daughter-board configuration */ + +/* USBC TCPC configuration for USB3 daughter board */ +static const struct tcpc_config_t tcpc_config_p1_usb3 = { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C1, + .addr_flags = PS8751_I2C_ADDR1_FLAGS, + }, + .flags = TCPC_FLAGS_TCPCI_REV2_0 | TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V, + .drv = &ps8xxx_tcpm_drv, + .usb23 = USBC_PORT_1_USB2_NUM | (USBC_PORT_1_USB3_NUM << 4), +}; + +/* + * USB3 DB mux configuration - the top level mux still needs to be set to the + * virtual_usb_mux_driver so the AP gets notified of mux changes and updates + * the TCSS configuration on state changes. + */ +static const struct usb_mux usbc1_usb3_db_retimer = { + .usb_port = USBC_PORT_C1, + .driver = &tcpci_tcpm_usb_mux_driver, + .hpd_update = &ps8xxx_tcpc_update_hpd_status, + .next_mux = NULL, +}; + +static const struct usb_mux mux_config_p1_usb3 = { + .usb_port = USBC_PORT_C1, + .driver = &virtual_usb_mux_driver, + .hpd_update = &virtual_hpd_update, + .next_mux = &usbc1_usb3_db_retimer, +}; + +/******************************************************************************/ /* USB-A charging control */ const int usb_port_enable[USB_PORT_COUNT] = { GPIO_EN_PP5000_USBA, }; +static enum gpio_signal ps8xxx_rst_odl = GPIO_USB_C1_RT_RST_ODL; + +static void ps8815_reset(void) +{ + int val; + + gpio_set_level(ps8xxx_rst_odl, 0); + msleep(GENERIC_MAX(PS8XXX_RESET_DELAY_MS, + PS8815_PWR_H_RST_H_DELAY_MS)); + gpio_set_level(ps8xxx_rst_odl, 1); + msleep(PS8815_FW_INIT_DELAY_MS); + + /* + * b/144397088 + * ps8815 firmware 0x01 needs special configuration + */ + + CPRINTS("%s: patching ps8815 registers", __func__); + + if (i2c_read8(I2C_PORT_USB_C1, + PS8751_I2C_ADDR1_P2_FLAGS, 0x0f, &val) == EC_SUCCESS) + CPRINTS("ps8815: reg 0x0f was %02x", val); + + if (i2c_write8(I2C_PORT_USB_C1, + PS8751_I2C_ADDR1_P2_FLAGS, 0x0f, 0x31) == EC_SUCCESS) + CPRINTS("ps8815: reg 0x0f set to 0x31"); + + if (i2c_read8(I2C_PORT_USB_C1, + PS8751_I2C_ADDR1_P2_FLAGS, 0x0f, &val) == EC_SUCCESS) + CPRINTS("ps8815: reg 0x0f now %02x", val); +} + +void board_reset_pd_mcu(void) +{ + enum ec_cfg_usb_db_type usb_db = ec_cfg_usb_db_type(); + + /* No reset available for TCPC on port 0 */ + /* Daughterboard specific reset for port 1 */ + if (usb_db == DB_USB3_ACTIVE) { + ps8815_reset(); + usb_mux_hpd_update(USBC_PORT_C1, 0, 0); + } +} + +/* + * Set up support for the USB3 daughterboard: + * Parade PS8815 TCPC (integrated retimer) + * Diodes PI3USB9201 BC 1.2 chip (same as USB4 board) + * Silergy SYV682A PPC (same as USB4 board) + */ +static void config_db_usb3(void) +{ + tcpc_config[USBC_PORT_C1] = tcpc_config_p1_usb3; + usb_muxes[USBC_PORT_C1] = mux_config_p1_usb3; +} + +static const char *db_type_prefix = "USB DB type: "; +__override void board_cbi_init(void) +{ + enum ec_cfg_usb_db_type usb_db = ec_cfg_usb_db_type(); + + /* Reconfigure Volteer GPIOs based on the board ID */ + if (get_board_id() == 0) { + CPRINTS("Configuring GPIOs for board ID 0"); + CPRINTS("VOLUME_UP button disabled"); + + /* Reassign USB_C1_RT_RST_ODL */ + bb_controls[USBC_PORT_C1].retimer_rst_gpio = + GPIO_USB_C1_RT_RST_ODL_BOARDID_0; + ps8xxx_rst_odl = GPIO_USB_C1_RT_RST_ODL_BOARDID_0; + } + + switch (usb_db) { + case DB_USB_ABSENT: + CPRINTS("%sNone", db_type_prefix); + break; + case DB_USB4_GEN2: + CPRINTS("%sUSB4 Gen1/2", db_type_prefix); + break; + case DB_USB4_GEN3: + CPRINTS("%sUSB4 Gen3", db_type_prefix); + break; + case DB_USB3_ACTIVE: + config_db_usb3(); + CPRINTS("%sUSB3 Active", db_type_prefix); + break; + default: + CPRINTS("%sID %d not supported", db_type_prefix, usb_db); + } +} diff --git a/board/volteer/board.h b/board/volteer/board.h index 5df2ce1a26..6edb5deae4 100644 --- a/board/volteer/board.h +++ b/board/volteer/board.h @@ -169,6 +169,8 @@ enum sensor_id { SENSOR_COUNT, }; +void board_reset_pd_mcu(void); + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ |