diff options
author | Bill Richardson <wfrichar@chromium.org> | 2013-09-13 09:26:06 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-09-13 17:14:46 +0000 |
commit | 1bcdd0eb6ff353a7215efe0b24630148ea7a9f28 (patch) | |
tree | c85e18291ec7c7849dc6f37eb8a1743b563d52bf | |
parent | 6412d099521e30025f6f91931f323e2fe057d9f0 (diff) | |
download | chrome-ec-1bcdd0eb6ff353a7215efe0b24630148ea7a9f28.tar.gz |
Falco: Always update charger's input current limit.
I was just updating the input current limit when turbo mode was enabled and
disabled. However, it turns out that the charger can decide to change the
setting all by itself if the inrush current is too high. This happens pretty
much every time that the AC is applied.
We didn't notice this while the AP was on, but when the AP was off we were
exiting the watch_adapter_closely() function too soon and so we missed the
transition. This CL fixes that.
But just to be safe, instead of only updating when we think we need to,
we're going to just update the value every time we check on the adapter.
That way if we happen to miss a change due to a race condition or transient,
we'll catch it the next time through the loop.
BUG=chrome-os-partner:20739
BRANCH=Falco,ToT
TEST=manual
Before this CL, you can run "sbc 0x3f" on the EC console while plugging and
unplugging the AC adapter. When the AP is off and AC is reapplied, you'd see
the reported value mysteriously change.
After this CL, it doesn't.
Change-Id: I5661c548cccd4eb24ba4d8a0b8cd070acc2e49ef
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169322
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | common/extpower_falco.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/common/extpower_falco.c b/common/extpower_falco.c index 947c4c2eac..65933e1353 100644 --- a/common/extpower_falco.c +++ b/common/extpower_falco.c @@ -164,10 +164,8 @@ static void set_turbo(int on) { int tmp, r; - if (ac_turbo == on) - return; - - CPRINTF("[%T turbo mode => %d]\n", on); + if (ac_turbo != on) + CPRINTF("[%T turbo mode => %d]\n", on); /* Set/clear turbo mode in charger */ r = charger_get_option(&tmp); @@ -183,7 +181,9 @@ static void set_turbo(int on) if (r != EC_SUCCESS) goto bad; - /* Set allowed Io based on adapter */ + /* Set allowed Io based on adapter. The charger will sometimes change + * this setting all by itself due to inrush current limiting, so we + * can't assume it stays where we put it. */ r = charger_set_input_current(ad_input_current[ac_adapter][on]); if (r != EC_SUCCESS) goto bad; @@ -286,6 +286,11 @@ void watch_adapter_closely(struct power_state_context *ctx) } else if (ctx->curr.batt.state_of_charge > 15) { set_turbo(1); } + } else { + /* If we're not on AC, we can't monitor the current, + * so watch for its return. + */ + ac_turbo = -1; } /* If the AP is off, we won't need to throttle it. */ @@ -293,12 +298,6 @@ void watch_adapter_closely(struct power_state_context *ctx) CHIPSET_STATE_SUSPEND)) return; - /* And if we're not on AC, we can't monitor the current. */ - if (!extpower_is_present()) { - ac_turbo = -1; /* watch for its return */ - return; - } - /* Check all the thresholds. */ current = adc_read_channel(ADC_CH_CHARGER_CURRENT); for (i = 0; i < NUM_AC_THRESHOLDS; i++) |