summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@google.com>2015-02-10 21:24:01 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-20 19:37:16 +0000
commit9de97e87547dd929e377b80b95ee279d0087feba (patch)
treed80ae9763d85524920765e6685f90a13e922380b
parent79dbd9280208b6b4252b9f483c8844be347e4392 (diff)
downloadchrome-ec-9de97e87547dd929e377b80b95ee279d0087feba.tar.gz
charge_state_v2: Do not draw max input current if battery is present
Currently we set the input current limit to its maximum when the system is unlocked, so that we can boot the system with a powerful charger when the battery is absent. However, with a low power charger, we risk browning out the charger. If the battery is present, reduce the input current limit so that low power chargers work in this case. BRANCH=None BUG=None TEST=On Ryu, reboot EC when the a low power charger is used. Without this change, the charger browns out right after the reboot. With this fix, the problem doesn't happen anymore. Change-Id: I9d491cbe45e77f864198c97a47624918e6c272db Signed-off-by: Vic Yang <victoryang@google.com> Reviewed-on: https://chromium-review.googlesource.com/248442 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
-rw-r--r--common/charge_state_v2.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 445819fc4e..9ee92396c0 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -522,21 +522,9 @@ const struct batt_params *charger_current_battery_params(void)
void charger_init(void)
{
- const struct charger_info * const info = charger_get_info();
-
/* Initialize current state */
memset(&curr, 0, sizeof(curr));
curr.batt.is_present = BP_NOT_SURE;
-
- /*
- * If system is not locked, then use max input current limit so
- * that if there is no battery present, we can pull as much power
- * as needed. If battery is present, then input current will be
- * immediately lowered to the real desired value.
- */
- curr.desired_input_current = system_is_locked() ?
- CONFIG_CHARGER_INPUT_CURRENT :
- info->input_current_max;
}
DECLARE_HOOK(HOOK_INIT, charger_init, HOOK_PRIO_DEFAULT);
@@ -555,6 +543,17 @@ void charger_task(void)
shutdown_warning_time.val = 0UL;
battery_seems_to_be_dead = 0;
+ /*
+ * If system is not locked and we don't have a battery to live on,
+ * then use max input current limit so that we can pull as much power
+ * as needed.
+ */
+ battery_get_params(&curr.batt);
+ if (curr.batt.is_present == BP_YES || system_is_locked())
+ curr.desired_input_current = CONFIG_CHARGER_INPUT_CURRENT;
+ else
+ curr.desired_input_current = info->input_current_max;
+
while (1) {
#ifdef CONFIG_SB_FIRMWARE_UPDATE