diff options
Diffstat (limited to 'board/cheza')
-rw-r--r-- | board/cheza/board.c | 22 | ||||
-rw-r--r-- | board/cheza/gpio.inc | 2 |
2 files changed, 20 insertions, 4 deletions
diff --git a/board/cheza/board.c b/board/cheza/board.c index d533f296c3..fffdedf707 100644 --- a/board/cheza/board.c +++ b/board/cheza/board.c @@ -48,6 +48,7 @@ static void usb0_evt(enum gpio_signal signal); static void usb1_evt(enum gpio_signal signal); static void ppc_interrupt(enum gpio_signal signal); static void anx74xx_cable_det_interrupt(enum gpio_signal signal); +static void usb1_oc_evt(enum gpio_signal signal); #include "gpio_list.h" @@ -125,6 +126,19 @@ static void ppc_interrupt(enum gpio_signal signal) sn5s330_interrupt(0); } +static void usb1_oc_evt_deferred(void) +{ + /* Only port-1 has overcurrent GPIO interrupt */ + board_overcurrent_event(0); +} +DECLARE_DEFERRED(usb1_oc_evt_deferred); + +static void usb1_oc_evt(enum gpio_signal signal) +{ + /* Switch the context to handle the event */ + hook_call_deferred(&usb1_oc_evt_deferred_data, 0); +} + /* Wake-up pins for hibernate */ const enum gpio_signal hibernate_wake_pins[] = { GPIO_LID_OPEN, @@ -417,7 +431,8 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT); /* Called on AP S5 -> S3 transition */ static void board_chipset_startup(void) { - gpio_set_flags(GPIO_USB_C1_OC_ODL, GPIO_INPUT | GPIO_PULL_UP); + gpio_set_flags(GPIO_USB_C1_OC_ODL, GPIO_INT_FALLING | GPIO_PULL_UP); + gpio_enable_interrupt(GPIO_USB_C1_OC_ODL); } DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); @@ -425,7 +440,8 @@ DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); static void board_chipset_shutdown(void) { /* 5V is off in S5. Disable pull-up to prevent current leak. */ - gpio_set_flags(GPIO_USB_C1_OC_ODL, GPIO_INPUT); + gpio_disable_interrupt(GPIO_USB_C1_OC_ODL); + gpio_set_flags(GPIO_USB_C1_OC_ODL, GPIO_INT_FALLING); } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); @@ -495,7 +511,7 @@ int board_is_sourcing_vbus(int port) void board_overcurrent_event(int port) { - /* TODO(waihong): Notify AP? */ + /* TODO(b/120231371): Notify AP */ CPRINTS("p%d: overcurrent!", port); } diff --git a/board/cheza/gpio.inc b/board/cheza/gpio.inc index 64d1d89319..bc9d12ad79 100644 --- a/board/cheza/gpio.inc +++ b/board/cheza/gpio.inc @@ -17,6 +17,7 @@ GPIO_INT(USB_C1_BC12_INT_L, PIN(8, 2), GPIO_INT_FALLING, usb1_evt) /* Interr GPIO_INT(USB_C0_VBUS_DET_L, PIN(6, 2), GPIO_INT_BOTH | GPIO_PULL_UP, vbus0_evt) /* BC1.2 VBUS detection on port-0 */ GPIO_INT(USB_C1_VBUS_DET_L, PIN(8, 3), GPIO_INT_BOTH | GPIO_PULL_UP, vbus1_evt) /* BC1.2 VBUS detection on port-1 */ GPIO_INT(USB_C0_CABLE_DET, PIN(3, 7), GPIO_INT_RISING, anx74xx_cable_det_interrupt) /* Cable detection from port-0 TCPC */ +GPIO_INT(USB_C1_OC_ODL, PIN(7, 2), GPIO_INT_FALLING, usb1_oc_evt) /* Port-1 power switch over-current */ GPIO_INT(ACCEL_GYRO_INT_L, PIN(D, 3), GPIO_INT_FALLING | GPIO_SEL_1P8V, bmi160_interrupt) /* Accelerometer/gyro interrupt */ /* System interrupts */ @@ -122,7 +123,6 @@ GPIO(USBC_MUX_CONF1, PIN(5, 1), GPIO_OUT_HIGH) /* Port-1 enable DP switc /* USB-C port-1 interrupts */ GPIO(USB_C1_DP_HPD, PIN(9, 6), GPIO_INPUT) /* DP HPD from port-1 TCPC */ -GPIO(USB_C1_OC_ODL, PIN(7, 2), GPIO_INPUT) /* Port-1 power switch over-current */ /* I2C */ GPIO(I2C0_SCL, PIN(B, 5), GPIO_INPUT) /* EC_I2C_POWER_SCL */ |