From 56385a05672ebee2e7ec17e37a18f90b0e92e9f3 Mon Sep 17 00:00:00 2001 From: Jagadish Krishnamoorthy Date: Tue, 8 Dec 2015 18:31:00 -0800 Subject: [PATCH] ALS: wake up ALS task when switched to RW mode Enabling of ALS is done during resume hook. During EC sw sync, resume hook is not called and hence ALS task wont run. Adding init hook to wake up the ALS task. BUG=chrome-os-partner:48418 BRANCH=none TEST= On Kunimitsu board, ensure sw sync is enabled. In OS, cat /sys/bus/iio/devices/iio:devicesx/in_illuminace_input should output valid value and not zero. Change-Id: Iba1a3ab2cf7bfc2d8aa36cf9bb9b762f398882c3 Signed-off-by: Jagadish Krishnamoorthy Reviewed-on: https://chromium-review.googlesource.com/317030 Commit-Ready: Freddy Paul Reviewed-by: Freddy Paul Reviewed-by: Shawn N --- common/als.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/common/als.c b/common/als.c index 06bd734ef0..96a1550570 100644 --- a/common/als.c +++ b/common/als.c @@ -8,10 +8,12 @@ */ #include "als.h" +#include "chipset.h" #include "common.h" #include "console.h" #include "hooks.h" #include "host_command.h" +#include "system.h" #include "task.h" #include "timer.h" #include "util.h" @@ -77,8 +79,20 @@ static void als_task_disable(void) task_timeout = -1; } +static void als_task_init(void) +{ + /* + * Enable ALS task in S0 only and may need to re-enable + * when sysjumped. + */ + if (system_jumped_to_this_image() && + chipset_in_state(CHIPSET_STATE_ON)) + als_task_enable(); +} + DECLARE_HOOK(HOOK_CHIPSET_RESUME, als_task_enable, HOOK_PRIO_ALS_INIT); DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, als_task_disable, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_INIT, als_task_init, HOOK_PRIO_ALS_INIT); /*****************************************************************************/ /* Console commands */