diff options
author | Scott Collyer <scollyer@google.com> | 2021-02-16 13:42:35 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-24 23:33:11 +0000 |
commit | d63ddef4a7c63066704c80f7e98d12911829a3c2 (patch) | |
tree | 40780a668242abccaf41fdce08e619b800f58feb /board/gingerbread | |
parent | 2cee0e2eb293cea2ccc1ae782de85480dc04d808 (diff) | |
download | chrome-ec-d63ddef4a7c63066704c80f7e98d12911829a3c2.tar.gz |
honeybuns: Add USB-PD for port C1 (user facing ALT-DP)
This CL adds support for honeybuns C1, which is the user facing usbc
port that also support ALT-DP mode. This CL adds support for both
gingergread and quiche.
Note that gingerbread is being checked in with a TODO for specifying
the PPC driver for C1. This is necessary to allow gingerbread to still
build while the solution for asymmetric port hardware is finalized.
BUG=b:183289386
BRANCH=None
TEST=Verified port C1 attaches to display adapters, usbpd hubs, and
type-c monitors
Signed-off-by: Scott Collyer <scollyer@google.com>
Change-Id: Iafbd5a38917601fc5055857662dd0e893d503948
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2699456
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'board/gingerbread')
-rw-r--r-- | board/gingerbread/board.c | 75 | ||||
-rw-r--r-- | board/gingerbread/board.h | 12 | ||||
-rw-r--r-- | board/gingerbread/ec.tasklist | 2 | ||||
-rw-r--r-- | board/gingerbread/gpio.inc | 4 |
4 files changed, 85 insertions, 8 deletions
diff --git a/board/gingerbread/board.c b/board/gingerbread/board.c index 82f02da6d3..d20b09b067 100644 --- a/board/gingerbread/board.c +++ b/board/gingerbread/board.c @@ -44,6 +44,7 @@ #ifdef SECTION_IS_RW static int pd_dual_role_init[CONFIG_USB_PD_PORT_MAX_COUNT] = { PD_DRP_TOGGLE_ON, + PD_DRP_FORCE_SOURCE, }; static void ppc_interrupt(enum gpio_signal signal) @@ -58,6 +59,21 @@ static void ppc_interrupt(enum gpio_signal signal) } } +static void tcpc_alert_event(enum gpio_signal s) +{ + int port = -1; + + switch (s) { + case GPIO_USBC_DP_MUX_ALERT_ODL: + port = USB_PD_PORT_DP; + break; + default: + return; + } + + schedule_deferred_pd_interrupt(port); +} + void hpd_interrupt(enum gpio_signal signal) { usb_pd_hpd_edge_event(signal); @@ -123,11 +139,24 @@ struct ppc_config_t ppc_chips[] = { #endif #ifdef SECTION_IS_RW +/* + * TCPCs: 2 USBC/PD ports + * port 0 -> host port -> STM32G4 UCPD + * port 1 -> user data/display port -> PS8805 + */ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_EMBEDDED, .drv = &stm32gx_tcpm_drv, }, + { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_I2C3, + .addr_flags = PS8751_I2C_ADDR2_FLAGS, + }, + .drv = &ps8xxx_tcpm_drv, + }, }; const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { @@ -137,15 +166,30 @@ const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { .i2c_addr_flags = TUSB1064_I2C_ADDR0_FLAGS, .driver = &tusb1064_usb_mux_driver, }, + [USB_PD_PORT_DP] = { + .usb_port = USB_PD_PORT_DP, + .i2c_port = I2C_PORT_I2C3, + .i2c_addr_flags = PS8751_I2C_ADDR2_FLAGS, + .driver = &tcpci_tcpm_usb_mux_driver, + .hpd_update = &ps8xxx_tcpc_update_hpd_status, + }, }; /* USB-C PPC Configuration */ struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_HOST] = { - .i2c_port = 2, + .i2c_port = I2C_PORT_I2C3, .i2c_addr_flags = SN5S330_ADDR0_FLAGS, .drv = &sn5s330_drv }, + /* + * TODO(b/159330563): The stub driver has not yet landed (and may not + * land) in TOT. Need to comment this out for now, until the correct + * solution for asymmetrical port hardware exists. + */ + [USB_PD_PORT_DP] = { + /* .drv = &ppc_stub_drv */ + }, }; unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); @@ -156,7 +200,20 @@ const struct hpd_to_pd_config_t hpd_config = { void board_reset_pd_mcu(void) { - + cprints(CC_SYSTEM, "Resetting TCPCs..."); + cflush(); + /* + * Reset all TCPCs. + * C0 -> ucpd (on chip TCPC) + * C1 -> PS8805 TCPC -> USBC_DP_PD_RST_L + * C2 -> PS8803 TCPC -> USBC_UF_RESET_L + */ + gpio_set_level(GPIO_USBC_DP_PD_RST_L, 0); + gpio_set_level(GPIO_USBC_UF_RESET_L, 0); + msleep(PS8805_FW_INIT_DELAY_MS); + gpio_set_level(GPIO_USBC_DP_PD_RST_L, 1); + gpio_set_level(GPIO_USBC_UF_RESET_L, 1); + msleep(PS8805_FW_INIT_DELAY_MS); } @@ -168,6 +225,9 @@ void board_tcpc_init(void) /* Enable PPC interrupts. */ gpio_enable_interrupt(GPIO_HOST_USBC_PPC_INT_ODL); + /* Enable TCPC interrupts. */ + gpio_enable_interrupt(GPIO_USBC_DP_MUX_ALERT_ODL); + /* Enable HPD interrupt */ gpio_enable_interrupt(GPIO_DDI_MST_IN_HPD); @@ -187,6 +247,17 @@ int ppc_get_alert_status(int port) return 0; } +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + + if (!gpio_get_level(GPIO_USBC_DP_MUX_ALERT_ODL) && + gpio_get_level(GPIO_USBC_DP_PD_RST_L)) + status |= PD_STATUS_TCPC_ALERT_1; + + return status; +} + void board_overcurrent_event(int port, int is_overcurrented) { /* TODO: b/ - check correct operation for honeybuns */ diff --git a/board/gingerbread/board.h b/board/gingerbread/board.h index 1c5983cf68..21883367d0 100644 --- a/board/gingerbread/board.h +++ b/board/gingerbread/board.h @@ -14,15 +14,21 @@ /* Optional features */ #define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands while in dev. */ -#undef CONFIG_UART_TX_BUF_SIZE -#define CONFIG_UART_TX_BUF_SIZE 4096 +#define CONFIG_WP_ACTIVE_HIGH + +/* Console */ +#define CONFIG_UART_CONSOLE 3 +#define CONFIG_UART_TX_DMA_CH STM32_DMAC_USART3_TX +#define CONFIG_UART_TX_DMA_PH DMAMUX_REQ_USART3_TX /* USB Type C and USB PD defines */ #define USB_PD_PORT_HOST 0 #define USB_PD_PORT_DP 1 -#define CONFIG_USB_PD_PORT_MAX_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_MUX_TUSB1064 +#define CONFIG_USBC_PPC_STUB +#define CONFIG_USB_PD_VBUS_ALERT_TCPC #define CONFIG_USB_PID 0x5049 #define CONFIG_USB_BCD_DEV 0x0001 /* v 0.01 */ diff --git a/board/gingerbread/ec.tasklist b/board/gingerbread/ec.tasklist index f884f8df16..a7c0eb9b2c 100644 --- a/board/gingerbread/ec.tasklist +++ b/board/gingerbread/ec.tasklist @@ -12,4 +12,6 @@ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS_RW(PD_C0, pd_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS_RW(PD_C1, pd_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS_RW(PD_INT_C1, pd_interrupt_handler_task, 1, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS_RW(UCPD, ucpd_task, 0, LARGER_TASK_STACK_SIZE) diff --git a/board/gingerbread/gpio.inc b/board/gingerbread/gpio.inc index 532903a98b..0c54a9800d 100644 --- a/board/gingerbread/gpio.inc +++ b/board/gingerbread/gpio.inc @@ -10,9 +10,7 @@ #ifdef SECTION_IS_RW GPIO_INT(HOST_USBC_PPC_INT_ODL, PIN(C, 1), GPIO_INT_FALLING | GPIO_PULL_UP, ppc_interrupt) -/* TODO (b/183289386): These singals are required for C1 operation. - * GPIO_INT(USBC_DP_MUX_ALERT_ODL, PIN(C, 12), GPIO_INT_FALLING | GPIO_PULL_UP, tcpc_alert_event) - */ +GPIO_INT(USBC_DP_MUX_ALERT_ODL, PIN(C, 12), GPIO_INT_FALLING | GPIO_PULL_UP, tcpc_alert_event) GPIO_INT(DDI_MST_IN_HPD, PIN(C, 14), GPIO_INT_BOTH, hpd_interrupt) #endif |