summaryrefslogtreecommitdiff
path: root/common/charge_state_v2.c
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-09-06 22:37:15 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-09-17 01:24:25 +0000
commiteff864775f25f16480955ebde7234219c6e03948 (patch)
treed4abaf804d6778885004c0423cbda45856569c55 /common/charge_state_v2.c
parentf0274df3db491c207413db35319eb72b35874b21 (diff)
downloadchrome-ec-eff864775f25f16480955ebde7234219c6e03948.tar.gz
samus: exchange status with PD MCU on boot
On boot, the EC should send host command to exchange status with PD MCU. This allows EC to get the correct input current limit when EC reboots and PD does not. Also had to move some of the charger state machine initialization to run with HOOK_INIT so that it runs before the tasks run. BUG=none BRANCH=none TEST=tested on EVT samus. Without this change, if you reboot EC, and run charger command, the charger input current limit is 512mA. with this change, when the EC reboots, it sends host command to PD MCU to get current limit and sets it appropriately. Change-Id: I5426f0fc3a62b6cd7a73f55cb11b895902a54903 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/216879 Reviewed-by: Todd Broch <tbroch@chromium.org>
Diffstat (limited to 'common/charge_state_v2.c')
-rw-r--r--common/charge_state_v2.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index c37e8189f1..1b796c9c27 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -457,6 +457,15 @@ const struct batt_params *charger_current_battery_params(void)
return &curr.batt;
}
+void charger_init(void)
+{
+ /* Initialize current state */
+ memset(&curr, 0, sizeof(curr));
+ curr.batt.is_present = BP_NOT_SURE;
+ curr.desired_input_current = CONFIG_CHARGER_INPUT_CURRENT;
+}
+DECLARE_HOOK(HOOK_INIT, charger_init, HOOK_PRIO_DEFAULT);
+
/* Main loop */
void charger_task(void)
{
@@ -466,10 +475,6 @@ void charger_task(void)
/* Get the battery-specific values */
batt_info = battery_get_info();
- /* Initialize all the state */
- memset(&curr, 0, sizeof(curr));
- curr.batt.is_present = BP_NOT_SURE;
- curr.desired_input_current = CONFIG_CHARGER_INPUT_CURRENT;
prev_ac = prev_charge = -1;
state_machine_force_idle = 0;
shutdown_warning_time.val = 0UL;