summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-01-17 14:37:05 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-19 22:19:11 +0000
commitcea3f26d5d4e9160c1e628b29abd74d74ca36c04 (patch)
treeeeee1b2f59aaa78224554cde944852f5e4f33495 /common
parent9da3dfb29fb7d2abf718a6f7173a9591c2c72720 (diff)
downloadchrome-ec-cea3f26d5d4e9160c1e628b29abd74d74ca36c04.tar.gz
charge state v2: allow boot without battery when unlocked
Change charge_state_v2 to set the maximum input current limit when there is no battery present AND the system is not locked. This allows us to boot without a battery. Note that using the max input current limit may cause us to overcurrent our charger, but that's no worse than putting a limit on it and having the system brownout. Either way you must have a high enough power charger to boot without a battery. BUG=chrome-os-partner:35570 BRANCH=samus TEST=load on samus, remove battery and plug in zinger. check "charger" has input current limit of 8128mA, and on PD MCU jump back and forth between RO and RW and make sure system doesn't power off. Note that without this CL, if you sysjump on the PD MCU it causes input current limit to reset to 500mA and causes AP to shutoff. Change-Id: Ie13d97a6b5c0937510cff0cf05fb032898c3b131 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/241762 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/charge_state_v2.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 91a41ade34..849ec8dff6 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -522,10 +522,21 @@ 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;
- curr.desired_input_current = CONFIG_CHARGER_INPUT_CURRENT;
+
+ /*
+ * 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);
@@ -931,6 +942,15 @@ int charge_temp_sensor_get_val(int idx, int *temp_ptr)
int charge_set_input_current_limit(int ma)
{
+ /*
+ * If battery is not present and we are not locked, then allow system
+ * to pull as much input current as needed. Yes, we might overcurrent
+ * the charger but this is no worse then browning out due to
+ * insufficient input current.
+ */
+ if (curr.batt.is_present != BP_YES && !system_is_locked())
+ return EC_SUCCESS;
+
curr.desired_input_current = ma;
return charger_set_input_current(ma);
}