diff options
-rw-r--r-- | board/boten/board.c | 41 | ||||
-rw-r--r-- | board/boten/board.h | 3 |
2 files changed, 42 insertions, 2 deletions
diff --git a/board/boten/board.c b/board/boten/board.c index 4bdc26745f..61df80eaf6 100644 --- a/board/boten/board.c +++ b/board/boten/board.c @@ -40,22 +40,52 @@ #include "usb_pd_tcpm.h" #define CPRINTUSB(format, args...) cprints(CC_USBCHARGE, format, ## args) +#define INT_RECHECK_US 5000 + +/* C0 interrupt line shared by BC 1.2 and charger */ +static void check_c0_line(void); +DECLARE_DEFERRED(check_c0_line); static void hdmi_hpd_interrupt(enum gpio_signal s) { gpio_set_level(GPIO_USB_C1_DP_HPD, !gpio_get_level(s)); } -static void usb_c0_interrupt(enum gpio_signal s) +static void notify_c0_chips(void) { /* * The interrupt line is shared between the TCPC and BC 1.2 detection - * chip. + * chip. Therefore we'll need to check both ICs. */ schedule_deferred_pd_interrupt(0); task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12); } +static void check_c0_line(void) +{ + /* + * If line is still being held low, see if there's more to process from + * one of the chips + */ + if (!gpio_get_level(GPIO_USB_C0_INT_ODL)) { + notify_c0_chips(); + hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); + } +} + +static void usb_c0_interrupt(enum gpio_signal s) +{ + /* Cancel any previous calls to check the interrupt line */ + hook_call_deferred(&check_c0_line_data, -1); + + /* Notify all chips using this line that an interrupt came in */ + notify_c0_chips(); + + /* Check the line again in 5ms */ + hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); + +} + static void c0_ccsbu_ovp_interrupt(enum gpio_signal s) { cprints(CC_USBPD, "C0: CC OVP, SBU OVP, or thermal event"); @@ -162,6 +192,13 @@ void board_init(void) pwm_set_duty(PWM_CH_LED_RED, 70); pwm_set_duty(PWM_CH_LED_GREEN, 70); pwm_set_duty(PWM_CH_LED_WHITE, 70); + + /* + * If interrupt lines are already low, schedule them to be processed + * after inits are completed. + */ + if (!gpio_get_level(GPIO_USB_C0_INT_ODL)) + hook_call_deferred(&check_c0_line_data, 0); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); diff --git a/board/boten/board.h b/board/boten/board.h index f74be69f3b..d22c176ba4 100644 --- a/board/boten/board.h +++ b/board/boten/board.h @@ -72,6 +72,9 @@ #define CONFIG_USB_PD_DISCHARGE_TCPC #define CONFIG_USB_PD_TCPC_LOW_POWER +/* EC console commands */ +#define CONFIG_CMD_TCPC_DUMP + /* Variant references the TCPCs to determine Vbus sourcing */ #define CONFIG_USB_PD_5V_EN_CUSTOM |