From f6c7abb503f04bd16071534aae7af541ea328d27 Mon Sep 17 00:00:00 2001 From: Mary Ruthven Date: Wed, 13 Jul 2016 15:01:50 -0700 Subject: [PATCH] g: fix rdd to enable sleep When the debug cable is disconnected the a USB suspend interrupt is triggered and puts the chip to sleep before rdd can detect a change on the cc lines and disconnect from CCD. This prevents the DEBUG_STATE_MAP from being reset to detect the debug connect and is left detecting the disconnect. Since the debug accessory is already disconnected the RDD interrupt will wake up the chip right after it goes to sleep. The UTMI and PIN wake source still cause the chip to wake up before the RDD interrupt, so disable those to test this change. BUG=chrome-os-partner:54796 BRANCH=none TEST=Disable wake pin and utmi wake sources. Put cr50 to sleep. Attach a reworked suzy q and make sure cr50 wakes up. Detach it and check that it goes back to sleep. Do that a couple of times. Check CCD is still enabled when the debug accessory is detected and disabled on disconnect. Change-Id: I58a012895bc874dcdd512aa84de9a917469f3139 Signed-off-by: Mary Ruthven Reviewed-on: https://chromium-review.googlesource.com/360234 Reviewed-by: Aseda Aboagye --- chip/g/rdd.c | 9 +++++++-- include/system.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/chip/g/rdd.c b/chip/g/rdd.c index f6c11f69d2..a3c9758e54 100644 --- a/chip/g/rdd.c +++ b/chip/g/rdd.c @@ -8,9 +8,12 @@ #include "hooks.h" #include "rdd.h" #include "registers.h" +#include "system.h" #include "task.h" #include "usb_api.h" +#define CPRINTS(format, args...) cprints(CC_USB, format, ## args) + static uint16_t debug_detect; int debug_cable_is_attached(void) @@ -24,15 +27,17 @@ int debug_cable_is_attached(void) void rdd_interrupt(void) { if (debug_cable_is_attached()) { - ccprintf("Debug Accessory connected\n"); + CPRINTS("Debug Accessory connected"); + disable_sleep(SLEEP_MASK_RDD); /* Detect when debug cable is disconnected */ GWRITE(RDD, PROG_DEBUG_STATE_MAP, ~debug_detect); rdd_attached(); } else { - ccprintf("Debug Accessory disconnected\n"); + CPRINTS("Debug Accessory disconnected"); /* Detect when debug cable is connected */ GWRITE(RDD, PROG_DEBUG_STATE_MAP, debug_detect); rdd_detached(); + enable_sleep(SLEEP_MASK_RDD); } /* Clear interrupt */ diff --git a/include/system.h b/include/system.h index 0d2eebdf1e..4362097345 100644 --- a/include/system.h +++ b/include/system.h @@ -317,6 +317,7 @@ enum { SLEEP_MASK_I2C_SLAVE = (1 << 7), /* I2C slave communication ongoing */ SLEEP_MASK_FAN = (1 << 8), /* Fan control loop ongoing */ SLEEP_MASK_USB_DEVICE = (1 << 9), /* Generic USB device in use */ + SLEEP_MASK_RDD = (1 << 10),/* RDD ongoing */ SLEEP_MASK_FORCE_NO_DSLEEP = (1 << 15), /* Force disable. */