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
BRANCH=None

(cherry picked from commit d2ac89d58c34d7cc0a2a3fb591fcdcddbe2e9feb)
Change-Id: Ib72e20faf7c7f302a4e39d43b23176247e5176fa
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/312950
Commit-Ready: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
This commit is contained in:
Wonjoon Lee
2015-11-12 18:24:48 +09:00
committed by chrome-bot
parent ea3b0a97c8
commit d0cf3227ce

View File

@@ -44,6 +44,7 @@
static const struct battery_info *batt_info;
static struct charge_state_data curr;
static int prev_ac, prev_charge, prev_full;
static enum battery_present 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 */
@@ -560,6 +561,15 @@ void charger_init(void)
}
DECLARE_HOOK(HOOK_INIT, charger_init, HOOK_PRIO_DEFAULT);
int get_desired_input_current(enum battery_present batt_present,
const struct charger_info * const info)
{
if (batt_present == BP_YES || system_is_locked())
return CONFIG_CHARGER_INPUT_CURRENT;
else
return info->input_current_max;
}
/* Main loop */
void charger_task(void)
{
@@ -581,10 +591,8 @@ void charger_task(void)
* 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;
prev_bp = curr.batt.is_present;
curr.desired_input_current = get_desired_input_current(prev_bp, info);
while (1) {
@@ -629,6 +637,13 @@ void charger_task(void)
charger_get_params(&curr.chg);
battery_get_params(&curr.batt);
if (prev_bp != curr.batt.is_present) {
prev_bp = curr.batt.is_present;
curr.desired_input_current =
get_desired_input_current(prev_bp, info);
charger_set_input_current(curr.desired_input_current);
}
curr.chg.flags |= CHG_FLAG_INITIALIZED;
/*