summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChromeOS Developer <dparker@chromium.org>2014-03-17 12:02:46 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-03-29 02:14:22 +0000
commit82e873da24f741b3199ca5a8dd08bf9aee17bcf1 (patch)
tree0aed92de367a598fa45f19993db986759deda1b6
parent9381c1a1a13064cc437e7d8a5ac35cb528a6d3c3 (diff)
downloadchrome-ec-82e873da24f741b3199ca5a8dd08bf9aee17bcf1.tar.gz
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
-rw-r--r--common/charge_state_v1.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/common/charge_state_v1.c b/common/charge_state_v1.c
index bb2c681ef9..d08aa2430b 100644
--- a/common/charge_state_v1.c
+++ b/common/charge_state_v1.c
@@ -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)
{