summaryrefslogtreecommitdiff
path: root/common/charge_ramp.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2017-03-27 15:39:36 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-03-30 17:35:44 -0700
commit1cf94fd052c64ed6aabeed44ea90ee035a77b222 (patch)
treed7d796ac336590de9a967d99ab8470882fede4ea /common/charge_ramp.c
parent333043bc8f2a04c058af10200948076611a6dfb0 (diff)
downloadchrome-ec-1cf94fd052c64ed6aabeed44ea90ee035a77b222.tar.gz
chg_ramp: Don't change ICL until vals are init'd.
When the charge ramp task starts, it starts up in the DISCONNECTED state. From this state, it's possible to set the input current limit to 0 mA. However, upon task start, we shouldn't take any action until we have valid values from a new charge supplier or a supplier leaving. This commit changes the charge ramp task to not touch the input current limit until the charge ramp state changes or the desired input current changes at least once. BUG=b:36468002 BRANCH=gru,master TEST=Flash kevin EC RW or build AP FW that contains the fix that will by sync'd by EC SW sync. Make sure WP is asserted to prevent PD communications in RO. Unplug battery. Plug in AC, verify that system can boot up to UI on AC alone. TEST=make -j buildall Change-Id: I351917bce7902c49d1bb842a0cc83dd161d75b6f Reviewed-on: https://chromium-review.googlesource.com/461382 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/463927 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/charge_ramp.c')
-rw-r--r--common/charge_ramp.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/common/charge_ramp.c b/common/charge_ramp.c
index 1c9dfecc33..a5928983fc 100644
--- a/common/charge_ramp.c
+++ b/common/charge_ramp.c
@@ -159,6 +159,7 @@ void chg_ramp_task(void)
static enum chg_ramp_state ramp_st_prev = CHG_RAMP_DISCONNECTED,
ramp_st_new = CHG_RAMP_DISCONNECTED;
int active_icl_new;
+ static uint8_t values_have_changed_at_least_once;
/* Clear last OCP supplier to guarantee we ramp on first connect */
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++)
@@ -322,19 +323,28 @@ void chg_ramp_task(void)
task_wait_time = STABLE_VBUS_MONITOR_INTERVAL;
break;
}
- if (ramp_st != ramp_st_new || active_icl != active_icl_new)
+ if (ramp_st != ramp_st_new || active_icl != active_icl_new) {
CPRINTS("Ramp p%d st%d %dmA %dmA",
active_port, ramp_st_new, min_icl,
active_icl_new);
+ values_have_changed_at_least_once = 1;
+ }
ramp_st_prev = ramp_st;
ramp_st = ramp_st_new;
active_icl = active_icl_new;
- /* Set the input current limit */
- lim = chg_ramp_get_current_limit();
- board_set_charge_limit(active_port, active_sup, lim,
- lim, active_vtg);
+ /*
+ * Don't perform any action unless something has changed.
+ * Otherwise, when the task starts, we may try and set a current
+ * limit that's invalid/uninitialized.
+ */
+ if (values_have_changed_at_least_once) {
+ /* Set the input current limit */
+ lim = chg_ramp_get_current_limit();
+ board_set_charge_limit(active_port, active_sup, lim,
+ lim, active_vtg);
+ }
if (ramp_st == CHG_RAMP_STABILIZE)
/*