summaryrefslogtreecommitdiff
path: root/board/metaknight
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-12-22 15:29:10 -0800
committerCommit Bot <commit-bot@chromium.org>2021-01-06 02:46:02 +0000
commit7be1639f1584b6c3bc2a2bfa6c57504fb1ce765b (patch)
treeedaa51878a38bc6959bd8a617d91413b53971dff /board/metaknight
parentdb469dbbb7cac8cd6d6e43623185402a44f68c8e (diff)
downloadchrome-ec-7be1639f1584b6c3bc2a2bfa6c57504fb1ce765b.tar.gz
metaknight: Rerun USB-C interrupts if still set
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=metaknight` Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: If6d05594887590ded83aa65146674912da8004d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2601172 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>
Diffstat (limited to 'board/metaknight')
-rw-r--r--board/metaknight/board.c75
1 files changed, 63 insertions, 12 deletions
diff --git a/board/metaknight/board.c b/board/metaknight/board.c
index 790b8a05e2..4925b6e9e8 100644
--- a/board/metaknight/board.c
+++ b/board/metaknight/board.c
@@ -45,6 +45,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)
@@ -56,33 +58,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;
+/* C0 interrupt line shared by BC 1.2 and charger */
+static void check_c0_line(void);
+DECLARE_DEFERRED(check_c0_line);
- schedule_deferred_pd_interrupt(port);
-}
-
-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_C1_INT_EN_RAILS_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);
+
+}
+
static void sub_hdmi_hpd_interrupt(enum gpio_signal s)
{
int hdmi_hpd_odl = gpio_get_level(GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL);
@@ -152,6 +201,7 @@ void board_init(void)
int on;
gpio_enable_interrupt(GPIO_USB_C0_INT_ODL);
+ check_c0_line();
if (get_cbi_fw_config_db() == DB_1A_HDMI) {
/* Disable i2c on HDMI pins */
@@ -178,6 +228,7 @@ void board_init(void)
/* Enable C1 interrupts */
gpio_enable_interrupt(GPIO_SUB_C1_INT_EN_RAILS_ODL);
+ check_c1_line();
}
/* Enable gpio interrupt for base accelgyro sensor */
gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);