diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2014-11-17 17:10:50 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-11-18 09:10:47 +0000 |
commit | bacd096372e22d87d7b98d9afc9ae9db91d4e0b9 (patch) | |
tree | f478abe95f31835e5429f821d09f78235865164f /board | |
parent | 45b4eda8771ad03777a03326207075dce57f13e3 (diff) | |
download | chrome-ec-bacd096372e22d87d7b98d9afc9ae9db91d4e0b9.tar.gz |
zinger: optimize idle current
Force enabling STOP mode when we have a power contract etablished but
the sink is consuming a low current (<500mA).
As a side effect, when the STOP mode is on, the fast OCP is no longer
reacting fast because the analog watchdog ADC conversion will only
happen on the next wake-up (dozens of milliseconds).
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=samus
BUG=none
TEST=run on Zinger with the UART RX used as debug GPIO to record STOP
mode entry/exit.
Change-Id: If78b2651862782cee45cfcdb22425b94f1eee678
Reviewed-on: https://chromium-review.googlesource.com/230341
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/zinger/usb_pd_policy.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/board/zinger/usb_pd_policy.c b/board/zinger/usb_pd_policy.c index 0f6bcdfccd..2c609eca2b 100644 --- a/board/zinger/usb_pd_policy.c +++ b/board/zinger/usb_pd_policy.c @@ -9,6 +9,7 @@ #include "debug.h" #include "hooks.h" #include "registers.h" +#include "system.h" #include "task.h" #include "timer.h" #include "util.h" @@ -101,6 +102,9 @@ static timestamp_t fault_deadline; /* reset over-current after 1 second */ #define OCP_TIMEOUT SECOND +/* Threshold below which we stop fast OCP to save power */ +#define SINK_IDLE_CURRENT VBUS_MA(500 /* mA */) + /* Under-voltage limit is 0.8x Vnom */ #define UVP_MV(mv) VBUS_MV((mv) * 8 / 10) /* Over-voltage limit is 1.2x Vnom */ @@ -141,6 +145,7 @@ static void discharge_voltage(int target_volt) discharge_deadline.val = get_time().val + DISCHARGE_TIMEOUT; /* Monitor VBUS voltage */ target_volt -= DISCHARGE_OVERSHOOT_MV; + disable_sleep(SLEEP_MASK_USB_PD); adc_enable_watchdog(ADC_CH_V_SENSE, 0xFFF, target_volt); } @@ -325,6 +330,17 @@ int pd_board_checks(void) return EC_ERROR_INVAL; } } + /* + * Optimize power consumption when the sink is idle : + * Enable STOP mode while we are connected, + * this kills fast OCP as the actual ADC conversion for the analog + * watchdog will happen on the next wake-up (x0 ms latency). + */ + if (vbus_amp < SINK_IDLE_CURRENT && !discharge_is_enabled()) + /* override the PD state machine sleep mask */ + enable_sleep(SLEEP_MASK_USB_PD); + else if (vbus_amp > SINK_IDLE_CURRENT) + disable_sleep(SLEEP_MASK_USB_PD); /* * Set the voltage index to use for checking OVP. During a down step |