diff options
Diffstat (limited to 'board/gingerbread')
-rw-r--r-- | board/gingerbread/board.c | 48 | ||||
-rw-r--r-- | board/gingerbread/board.h | 6 | ||||
-rw-r--r-- | board/gingerbread/ec.tasklist | 1 | ||||
-rw-r--r-- | board/gingerbread/gpio.inc | 4 |
4 files changed, 52 insertions, 7 deletions
diff --git a/board/gingerbread/board.c b/board/gingerbread/board.c index 03d70a69d3..82f02da6d3 100644 --- a/board/gingerbread/board.c +++ b/board/gingerbread/board.c @@ -7,24 +7,34 @@ #include "common.h" #include "driver/ppc/sn5s330.h" +#include "driver/tcpm/ps8xxx.h" #include "driver/tcpm/stm32gx.h" #include "driver/tcpm/tcpci.h" +#include "driver/usb_mux/tusb1064.h" #include "ec_version.h" #include "gpio.h" #include "hooks.h" +#include "mp4245.h" #include "switch.h" #include "system.h" #include "task.h" +#include "timer.h" #include "uart.h" #include "usb_descriptor.h" #include "usb_pd.h" #include "usbc_ppc.h" +#include "usb_descriptor.h" +#include "usb_pd_dp_ufp.h" +#include "usb_pe_sm.h" +#include "usb_prl_sm.h" +#include "usb_tc_sm.h" #include "util.h" - #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args) #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args) +#define QUICHE_PD_DEBUG_LVL 1 + #ifdef SECTION_IS_RW #define CROS_EC_SECTION "RW" #else @@ -32,6 +42,10 @@ #endif #ifdef SECTION_IS_RW +static int pd_dual_role_init[CONFIG_USB_PD_PORT_MAX_COUNT] = { + PD_DRP_TOGGLE_ON, +}; + static void ppc_interrupt(enum gpio_signal signal) { switch (signal) { @@ -44,6 +58,10 @@ static void ppc_interrupt(enum gpio_signal signal) } } +void hpd_interrupt(enum gpio_signal signal) +{ + usb_pd_hpd_edge_event(signal); +} #endif /* SECTION_IS_RW */ #include "gpio_list.h" /* Must come after other header files. */ @@ -115,8 +133,9 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_HOST] = { .usb_port = USB_PD_PORT_HOST, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, + .i2c_port = I2C_PORT_I2C1, + .i2c_addr_flags = TUSB1064_I2C_ADDR0_FLAGS, + .driver = &tusb1064_usb_mux_driver, }, }; @@ -130,14 +149,35 @@ struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = { }; unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); +const struct hpd_to_pd_config_t hpd_config = { + .port = USB_PD_PORT_HOST, + .signal = GPIO_DDI_MST_IN_HPD, +}; + +void board_reset_pd_mcu(void) +{ + +} + + /* Power Delivery and charging functions */ void board_tcpc_init(void) { + board_reset_pd_mcu(); + /* Enable PPC interrupts. */ gpio_enable_interrupt(GPIO_HOST_USBC_PPC_INT_ODL); + + /* Enable HPD interrupt */ + gpio_enable_interrupt(GPIO_DDI_MST_IN_HPD); + } -DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1); +DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 2); +enum pd_dual_role_states board_tc_get_initial_drp_mode(int port) +{ + return pd_dual_role_init[port]; +} int ppc_get_alert_status(int port) { diff --git a/board/gingerbread/board.h b/board/gingerbread/board.h index 75780a3fb2..1c5983cf68 100644 --- a/board/gingerbread/board.h +++ b/board/gingerbread/board.h @@ -20,7 +20,9 @@ /* 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_MUX_TUSB1064 #define CONFIG_USB_PID 0x5049 #define CONFIG_USB_BCD_DEV 0x0001 /* v 0.01 */ @@ -34,7 +36,7 @@ /* Required symbolic I2C port names */ #define I2C_PORT_MP4245 I2C_PORT_I2C3 #define I2C_PORT_EEPROM I2C_PORT_I2C1 -#define MP4245_SLAVE_ADDR MP4245_I2C_ADDR_0_FLAGS +#define MP4245_I2C_ADDR_FLAGS MP4245_I2C_ADDR_0_FLAGS /* * Macros for GPIO signals used in common code that don't match the @@ -50,6 +52,8 @@ #include "registers.h" +#define GPIO_DP_HPD GPIO_DDI_MST_IN_HPD + #define GPIO_TRIGGER_1 GPIO_EC_HUB1_RESET_L #define GPIO_TRIGGER_2 GPIO_EC_HUB2_RESET_L diff --git a/board/gingerbread/ec.tasklist b/board/gingerbread/ec.tasklist index 1f79cd8fbd..f884f8df16 100644 --- a/board/gingerbread/ec.tasklist +++ b/board/gingerbread/ec.tasklist @@ -11,4 +11,5 @@ TASK_ALWAYS_RO(RWSIG, rwsig_task, NULL, 1280) \ 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(UCPD, ucpd_task, 0, LARGER_TASK_STACK_SIZE) diff --git a/board/gingerbread/gpio.inc b/board/gingerbread/gpio.inc index e3bb4e2ad4..532903a98b 100644 --- a/board/gingerbread/gpio.inc +++ b/board/gingerbread/gpio.inc @@ -10,10 +10,10 @@ #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 C0 and C1 operation. +/* 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(DDI_MST_IN_HPD, PIN(C, 14), GPIO_INT_BOTH, hpd_interrupt) */ +GPIO_INT(DDI_MST_IN_HPD, PIN(C, 14), GPIO_INT_BOTH, hpd_interrupt) #endif /* Power sequencing signals */ |