From 60f45d28774d938c77c0f406c273dd54d180265b Mon Sep 17 00:00:00 2001 From: Justin TerAvest Date: Thu, 19 Apr 2018 12:29:53 -0600 Subject: power/common: Preserve 5v enable across sysjump The value of pwr_5v_en_req needs to be preserved when the EC performs a sysjump, otherwise any task calling power_5v_enable(tid, 0) will drop the 5v rail for the entire system. I've scheduled this at HOOK_PRIO_FIRST for restoring the value to ensure that no other init hooks read a stale value, but I'm not sure if that's necessary. BUG=b:78275296 BRANCH=none TEST=Booted yorp with power only connected to USB-C port 0 Change-Id: I3a9ed24a5fde02b60163ad2c5e3252759f8c1c5b Signed-off-by: Justin TerAvest Reviewed-on: https://chromium-review.googlesource.com/1020066 Reviewed-by: Aseda Aboagye Reviewed-by: Aaron Durbin Reviewed-by: Furquan Shaikh Reviewed-by: Jett Rink --- power/common.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'power/common.c') diff --git a/power/common.c b/power/common.c index 162ed39254..d4fc0aecee 100644 --- a/power/common.c +++ b/power/common.c @@ -856,4 +856,29 @@ void __attribute__((weak)) power_5v_enable(task_id_t tid, int enable) mutex_unlock(&pwr_5v_ctl_mtx); } + +#define P5_SYSJUMP_TAG 0x5005 /* "P5" */ +static void restore_enable_5v_state(void) +{ + const uint32_t *state; + int size; + + state = (const uint32_t *) system_get_jump_tag(P5_SYSJUMP_TAG, 0, + &size); + if (state && size == sizeof(pwr_5v_en_req)) { + mutex_lock(&pwr_5v_ctl_mtx); + pwr_5v_en_req |= *state; + mutex_unlock(&pwr_5v_ctl_mtx); + } +} +DECLARE_HOOK(HOOK_INIT, restore_enable_5v_state, HOOK_PRIO_FIRST); + +static void preserve_enable_5v_state(void) +{ + mutex_lock(&pwr_5v_ctl_mtx); + system_add_jump_tag(P5_SYSJUMP_TAG, 0, sizeof(pwr_5v_en_req), + &pwr_5v_en_req); + mutex_unlock(&pwr_5v_ctl_mtx); +} +DECLARE_HOOK(HOOK_SYSJUMP, preserve_enable_5v_state, HOOK_PRIO_DEFAULT); #endif /* defined(CONFIG_POWER_PP5000_CONTROL) */ -- cgit v1.2.1