summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-12-22 15:23:07 -0800
committerCommit Bot <commit-bot@chromium.org>2021-01-06 02:46:00 +0000
commitdb469dbbb7cac8cd6d6e43623185402a44f68c8e (patch)
tree0cfd73504c6fba40d6b250ea63b2ec63fef5c3f5
parentfb33efdf2828f2fa9743e6f8eb2a5a55110a3156 (diff)
downloadchrome-ec-db469dbbb7cac8cd6d6e43623185402a44f68c8e.tar.gz
magolor: Rerun USB-C interrupts if still asserted
This commit revises the USB-C interrupt handlers. Sometimes the interrupt line can remain asserted once we've finished handling the interrupt. This commit leverages the work that was done for the other dedede boards to check if the interrupt is still asserted and rerun the interrupt handlers if needed. BUG=b:143166332 BRANCH=dedede TEST=`make -j BOARD=magolor` Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I643e5a94baf38f421d58dc8ab6fc0a409915cdf6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2601171 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--board/magolor/board.c74
1 files changed, 63 insertions, 11 deletions
diff --git a/board/magolor/board.c b/board/magolor/board.c
index 18b6a77968..b256796d89 100644
--- a/board/magolor/board.c
+++ b/board/magolor/board.c
@@ -46,6 +46,8 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+#define INT_RECHECK_US 5000
+
#define ADC_VOL_UP_MASK BIT(0)
#define ADC_VOL_DOWN_MASK BIT(1)
@@ -61,33 +63,80 @@ const int usb_port_enable[USB_PORT_COUNT] = {
GPIO_EN_USB_A1_VBUS,
};
-static void tcpc_alert_event(enum gpio_signal s)
-{
- int port = (s == GPIO_USB_C0_INT_ODL) ? 0 : 1;
- schedule_deferred_pd_interrupt(port);
-}
+/* C0 interrupt line shared by BC 1.2 and charger */
+static void check_c0_line(void);
+DECLARE_DEFERRED(check_c0_line);
-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. Therefore we'll need to check both ICs.
*/
- tcpc_alert_event(s);
+ schedule_deferred_pd_interrupt(0);
task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12);
}
-static void sub_usb_c1_interrupt(enum gpio_signal s)
+static void check_c0_line(void)
{
/*
- * The interrupt line is shared between the TCPC and BC 1.2 detection
- * chip. Therefore we'll need to check both ICs.
+ * If line is still being held low, see if there's more to process from
+ * one of the chips
*/
- tcpc_alert_event(s);
+ 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);
+
+}
+
+/* C1 interrupt line shared by BC 1.2, TCPC, and charger */
+static void check_c1_line(void);
+DECLARE_DEFERRED(check_c1_line);
+
+static void notify_c1_chips(void)
+{
+ schedule_deferred_pd_interrupt(1);
task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12);
}
+static void check_c1_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_SUB_USB_C1_INT_ODL)) {
+ notify_c1_chips();
+ hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
+ }
+}
+
+static void sub_usb_c1_interrupt(enum gpio_signal s)
+{
+ /* Cancel any previous calls to check the interrupt line */
+ hook_call_deferred(&check_c1_line_data, -1);
+
+ /* Notify all chips using this line that an interrupt came in */
+ notify_c1_chips();
+
+ /* Check the line again in 5ms */
+ hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
+}
+
#include "gpio_list.h"
/* ADC channels */
@@ -164,6 +213,9 @@ void board_init(void)
gpio_enable_interrupt(GPIO_USB_C0_INT_ODL);
gpio_enable_interrupt(GPIO_SUB_USB_C1_INT_ODL);
+ check_c0_line();
+ check_c1_line();
+
/* Enable gpio interrupt for base accelgyro sensor */
gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);