summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2013-11-13 12:17:13 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-11-14 17:27:33 +0000
commit48b1be818ac26fe48482905395f6ff4257f989ed (patch)
treed525ef8bf220b7a097f6468885a3f8d1d34e90c0
parent25ff5e7ece90b34e44531a6ce7b945781298d049 (diff)
downloadchrome-ec-48b1be818ac26fe48482905395f6ff4257f989ed.tar.gz
spring: keep the charger in idle mode when VBUS has glitched on Spring brick
When the Spring charger voltage is drooping, it's probably not overcurrent, so we keep the current limit to 0A until 2 minutes are expired and the user unplugs and replugs the power supply. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=spring BUG=none TEST=On Spring, observe EC serial traces after various VBUS events. Change-Id: If9946c72da99851ad61f02c78b90ab04313cab31 Reviewed-on: https://chromium-review.googlesource.com/176724 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/spring/usb_charging.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c
index a0445efc1a..69e7caed4f 100644
--- a/board/spring/usb_charging.c
+++ b/board/spring/usb_charging.c
@@ -81,7 +81,11 @@
#define BATTERY_KEY_DELAY (PWM_CTRL_OC_DETECT_TIME + 400 * MSEC)
/* Delay to read again ID pin when VBUS went off */
-#define ID_REDETECTION_DELAY 200000
+#define ID_REDETECTION_DELAY (200 * MSEC)
+/* Threshold for glitch detection on the Spring charger */
+#define SPRING_GLITCH_THR (250 * MSEC)
+/* Minimum delay before allowing the charger to go off idle mode */
+#define CHARGER_IDLE_MINIMUM_PERIOD (2 * MINUTE)
/* Delay for signals to settle */
#define DELAY_POWER_MS 20
@@ -108,6 +112,7 @@ static int pending_dev_type_update;
static int pending_video_power_off;
static int restore_id_mux;
static int charger_idle; /* Spring brick in idle mode */
+static timestamp_t charger_idle_time; /* last entry time in idle mode */
static int board_rev = 1; /* Assume new boards unless told otherwise */
@@ -650,6 +655,7 @@ static void check_spring_brick_deferred(void)
*/
CPRINTF("[%T Spring brick went to IDLE\n");
charger_idle = 1;
+ charger_idle_time = get_time();
}
}
@@ -684,6 +690,18 @@ static void usb_detect_overcurrent(int dev_type)
} else if (dev_type & TSU6721_TYPE_VBUS_DEBOUNCED) {
int idx = !(dev_type == TSU6721_TYPE_VBUS_DEBOUNCED);
timestamp_t now = get_time();
+ if ((power_removed_type[1] & TSU6721_TYPE_CHG12) &&
+ ((now.val - power_removed_time[1].val) <
+ SPRING_GLITCH_THR)) {
+ /*
+ * the spring brick should not glitch,
+ * put it in idle.
+ */
+ CPRINTF("[%T Spring brick GLITCH]\n");
+ charger_idle = 1;
+ charger_idle_time = get_time();
+ return;
+ }
now.val -= power_removed_time[idx].val;
if (now.val >= PWM_CTRL_OC_DETECT_TIME) {
oc_detect_retry[idx] = PWM_CTRL_OC_RETRY;
@@ -739,7 +757,9 @@ static void usb_update_ilim(int dev_type)
* let charger in idle mode until it has been unplugged
* and re-detected.
*/
- if (dev_type == TSU6721_TYPE_VBUS_DEBOUNCED) {
+ if ((dev_type == TSU6721_TYPE_VBUS_DEBOUNCED) &&
+ ((get_time().val - charger_idle_time.val) >
+ CHARGER_IDLE_MINIMUM_PERIOD)) {
charger_idle = 0;
CPRINTF("[%T RESET charger idle]\n");
} else {