diff options
author | Wonjoon Lee <woojoo.lee@samsung.com> | 2015-11-12 18:24:48 +0900 |
---|---|---|
committer | ChromeOS bot <3su6n15k.default@developer.gserviceaccount.com> | 2015-11-13 01:08:33 +0000 |
commit | 466d2bd7873a012ae213289816bbe66b2d085e51 (patch) | |
tree | 30d8a196775f6388b28db687c5c5e8bacac64976 | |
parent | 7dcab905e0648ff77995d4a2e65864094cc4fe24 (diff) | |
download | chrome-ec-466d2bd7873a012ae213289816bbe66b2d085e51.tar.gz |
charge_state_v2: Set charger input current in the task
When task creating, input_current will be set as condition.
But there is no more handling for this value. so it will remain
even if condition is changed.
This will put input current decision int the loop so that we can
proper input current as battery existence.
BUG=chrome-os-partner:47546
TEST=make buildall, command 'charger' with/without battery.
and see it is changed dynamically
Change-Id: Ib72e20faf7c7f302a4e39d43b23176247e5176fa
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/312209
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | common/charge_state_v2.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index e4085aed04..642d157a18 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -39,7 +39,7 @@ */ static const struct battery_info *batt_info; static struct charge_state_data curr; -static int prev_ac, prev_charge, prev_full; +static int prev_ac, prev_charge, prev_full, prev_bp; static int is_full; /* battery not accepting current */ static int state_machine_force_idle; static int manual_mode; /* volt/curr are no longer maintained by charger */ @@ -553,22 +553,11 @@ void charger_task(void) /* Get the battery-specific values */ batt_info = battery_get_info(); - prev_ac = prev_charge = -1; + prev_ac = prev_charge = prev_bp = -1; state_machine_force_idle = 0; 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 @@ -578,6 +567,21 @@ void charger_task(void) } #endif + /* + * 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 (prev_bp != curr.batt.is_present) { + 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; + charger_set_input_current(curr.desired_input_current); + prev_bp = curr.batt.is_present; + } + /* Let's see what's going on... */ curr.ts = get_time(); sleep_usec = 0; @@ -610,7 +614,6 @@ void charger_task(void) } } charger_get_params(&curr.chg); - battery_get_params(&curr.batt); /* Fake state of charge if necessary */ if (fake_state_of_charge >= 0) { |