summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chip/g/rdd.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/chip/g/rdd.c b/chip/g/rdd.c
index d02ec362f7..bd0d2360d8 100644
--- a/chip/g/rdd.c
+++ b/chip/g/rdd.c
@@ -31,30 +31,38 @@ int debug_cable_is_attached(void)
return (cc1 == cc2 && (cc1 == 3 || cc1 == 1));
}
-void rdd_interrupt(void)
+static void rdd_disconnected(void)
{
- int is_debug;
+ CPRINTS("Debug Accessory disconnected");
+
+ rdd_detached();
+}
+DECLARE_DEFERRED(rdd_disconnected);
+void rdd_interrupt(void)
+{
delay_sleep_by(1 * SECOND);
- is_debug = debug_cable_is_attached();
+ if (debug_cable_is_attached()) {
+ /* cancel pending rdd disconnect */
+ hook_call_deferred(&rdd_disconnected_data, -1);
- if (is_debug) {
CPRINTS("Debug Accessory connected");
/* Detect when debug cable is disconnected */
GWRITE(RDD, PROG_DEBUG_STATE_MAP, DETECT_DISCONNECT);
rdd_attached();
- } else if (!is_debug) {
- CPRINTS("Debug Accessory disconnected");
-
+ } else {
/* Detect when debug cable is connected */
GWRITE(RDD, PROG_DEBUG_STATE_MAP, DETECT_DEBUG);
- rdd_detached();
-
- cflush();
+ /*
+ * Debounce the RDD disconnect for 2 seconds so rdd events
+ * won't be triggered by any PD negotiation the EC does during
+ * reset or sysjump.
+ */
+ hook_call_deferred(&rdd_disconnected_data, 2 * SECOND);
}
/* Clear interrupt */