pd: Fix multiple reboot for battery cut-off

In case of boot after battery is cut-off without this
change the battery is assumed to be present even though it
is not initialized and ready to provide power in try source
enable function. With this assumption charger is disconnected
momentarily which causes reboot.
Also make sure that try source enable is updated after battery
is ready by notifying hook call HOOK_BATTERY_SOC_CHANGE.

BUG=chrome-os-partner:51753
BRANCH=firmware-glados-7820.B
TEST=Enter battery cutoff command from EC console to enter into ship
     mode and plug-in AC, verified no reboots happen.

Change-Id: I6f7656125717f85851f5ad4e37dfd953a52799c6
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/335913
Reviewed-by: Shawn N <shawnn@chromium.org>
(cherry picked from commit 10040ac6284efe88b74193bdbb0c05ec92b563b4)
Reviewed-on: https://chromium-review.googlesource.com/336697
Commit-Ready: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Tested-by: Divya Jyothi <divya.jyothi@intel.com>
This commit is contained in:
Divya Sasidharan
2016-03-29 16:46:38 -07:00
committed by chrome-bot
parent 013a47740d
commit e353ab0363
2 changed files with 10 additions and 0 deletions

View File

@@ -657,6 +657,7 @@ void charger_task(void)
curr.desired_input_current =
get_desired_input_current(prev_bp, info);
charger_set_input_current(curr.desired_input_current);
hook_notify(HOOK_BATTERY_SOC_CHANGE);
}
/*

View File

@@ -1214,6 +1214,15 @@ static void pd_update_try_source(void)
*/
pd_try_src_enable = drp_state == PD_DRP_TOGGLE_ON &&
batt_soc >= CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC;
#if defined(CONFIG_BATTERY_PRESENT_CUSTOM) || \
defined(CONFIG_BATTERY_PRESENT_GPIO)
/*
* When battery is cutoff in ship mode it may not be reliable to
* check if battery is present with its state of charge.
* Also check if battery is initialized and ready to provide power.
*/
pd_try_src_enable &= (battery_is_present() == BP_YES);
#endif
/*
* Clear this flag to cover case where a TrySrc