summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjerry2.huang <jerry2.huang@lcfc.corp-partner.google.com>2020-12-18 17:20:29 +0800
committerCommit Bot <commit-bot@chromium.org>2020-12-21 21:27:27 +0000
commit623ab3b91352fa93209bd8015b7769bfda7f8d2f (patch)
tree51557a2314b329e162ff4dcfbcbfbf6d10e19362
parentb8aa849de779ea14ba7713d7cc1379a62b835115 (diff)
downloadchrome-ec-623ab3b91352fa93209bd8015b7769bfda7f8d2f.tar.gz
Boten: Share interrupt lines more gracefully
1.Set up checking for interrupt line wedging, which may occur when interrupts from the charger/TCPC occur with similar timing to the BC 1.2 interrupts. 2.Enable TCPC dump BUG=b:175526824 BRANCH=firmware-dedede-13606.B-master TEST=make buildall, test multiple DUT-DUT connections and ensure neither system wedges its interrupt line low Signed-off-by: jerry2.huang <jerry2.huang@lcfc.corp-partner.google.com> Change-Id: I98ca5a347b47bf6fcbbd6ed27a203a3f0a33ca35 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2598299 Reviewed-by: Henry Sun <henrysun@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--board/boten/board.c41
-rw-r--r--board/boten/board.h3
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