diff options
-rw-r--r-- | board/eve/board.c | 15 | ||||
-rw-r--r-- | board/eve/board.h | 2 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 5 | ||||
-rw-r--r-- | include/config.h | 3 |
4 files changed, 23 insertions, 2 deletions
diff --git a/board/eve/board.c b/board/eve/board.c index 5e9e3e700e..c95eec9c57 100644 --- a/board/eve/board.c +++ b/board/eve/board.c @@ -300,6 +300,18 @@ void board_reset_pd_mcu(void) void board_tcpc_init(void) { + int count = 0; + int port; + + /* Wait for disconnected battery to wake up */ + while (battery_hw_present() == BP_YES && + battery_is_present() == BP_NO) { + usleep(100 * MSEC); + /* Give up waiting after 2 seconds */ + if (++count > 20) + break; + } + /* Only reset TCPC if not sysjump */ if (!system_jumped_late()) board_reset_pd_mcu(); @@ -318,10 +330,9 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) usb_mux_hpd_update(port, 0, 0); } -DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1); uint16_t tcpc_get_alert_status(void) { diff --git a/board/eve/board.h b/board/eve/board.h index 086ada0de7..8a9a9f2faa 100644 --- a/board/eve/board.h +++ b/board/eve/board.h @@ -163,6 +163,7 @@ #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 #define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_VBUS_DETECT_CHARGER +#define CONFIG_USB_PD_TCPC_BOARD_INIT #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_MUX #define CONFIG_USB_PD_TCPM_ANX3429 @@ -286,6 +287,7 @@ enum adc_channel { int board_get_version(void); void board_reset_pd_mcu(void); void board_set_tcpc_power_mode(int port, int mode); +void board_tcpc_init(void); void led_register_double_tap(void); void board_update_ac_status(void); diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 71343f1334..63c300b9ca 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -2955,6 +2955,11 @@ void pd_task(void *u) set_vconn(port, 0); #endif +#ifdef CONFIG_USB_PD_TCPC_BOARD_INIT + /* Board specific TCPC init */ + board_tcpc_init(); +#endif + /* Initialize TCPM driver and wait for TCPC to be ready */ res = reset_device_and_notify(port); invalidate_last_message_id(port); diff --git a/include/config.h b/include/config.h index 1a6f1767a9..ea17b81bb7 100644 --- a/include/config.h +++ b/include/config.h @@ -3978,6 +3978,9 @@ /* Use TCPC module (type-C port controller) */ #undef CONFIG_USB_PD_TCPC +/* Board provides specific TCPC init function */ +#undef CONFIG_USB_PD_TCPC_BOARD_INIT + /* Enable TCPC to enter low power mode */ #undef CONFIG_USB_PD_TCPC_LOW_POWER |