mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 01:21:49 +00:00
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>
This commit is contained in:
committed by
chrome-internal-fetch
parent
45b4eda877
commit
bacd096372
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user