Charge State: Update memory-mapped AC status in the hook handler

Update the AC status immediately in the AC_CHANGE_HOOK handler
so the memmory-mapped value shared with the host is correct
prior to the host receiving an "AC changed" ACPI notification.

BUG=chromium:349681
BRANCH=ToT
TEST=Plug/unplug AC power. Verify that the host 'ACEX' bit is
set prior to it receiving ACPI event 4 (or cleared before
ACPI event 5). See crbug.com/349681#c12

Change-Id: I5c84e05b6886c5da9e8504cb803c80c3ec7c23fb
Original-Change-Id: I1496efe1cfac9995e88bf9d84414ee903886d9ed
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/190345
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/192136
This commit is contained in:
ChromeOS Developer
2014-03-17 12:02:46 -07:00
committed by chrome-internal-fetch
parent 9381c1a1a1
commit 82e873da24

View File

@@ -874,18 +874,40 @@ void charger_task(void)
/* Hooks */
/**
* Charge notification hook.
* Chipset notification hook.
*
* This is triggered when the AC state changes or the system boots, so that
* we can update our charging state.
* This is triggered when the system boots or resumes, so that we can update
* our charging state.
*/
static void charge_hook(void)
static void chipset_hook(void)
{
/* Wake up the task now */
task_wake(TASK_ID_CHARGER);
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, charge_hook, HOOK_PRIO_DEFAULT);
DECLARE_HOOK(HOOK_AC_CHANGE, charge_hook, HOOK_PRIO_DEFAULT);
DECLARE_HOOK(HOOK_CHIPSET_RESUME, chipset_hook, HOOK_PRIO_DEFAULT);
/**
* AC change notification hook.
*
* This is triggered when the AC state changes, so that we can update the
* memory-mapped AC status and our charging state.
*/
static void ac_change_hook(void)
{
/**
* Update the memory-mapped AC_PRESENT flag immediately so the
* state is correct prior to the host being notified of the AC
* change event.
*/
if (extpower_is_present())
*task_ctx.memmap_batt_flags |= EC_BATT_FLAG_AC_PRESENT;
else
*task_ctx.memmap_batt_flags &= ~EC_BATT_FLAG_AC_PRESENT;
/* Wake up the task now */
task_wake(TASK_ID_CHARGER);
}
DECLARE_HOOK(HOOK_AC_CHANGE, ac_change_hook, HOOK_PRIO_DEFAULT);
static void charge_init(void)
{