summaryrefslogtreecommitdiff
path: root/power/common.c
diff options
context:
space:
mode:
authorJustin TerAvest <teravest@chromium.org>2018-04-19 12:29:53 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-04-19 19:29:07 -0700
commit60f45d28774d938c77c0f406c273dd54d180265b (patch)
tree18b846dce51efac86041c9c7d3271e250b525b73 /power/common.c
parent2d5331b9a2a32b855ea4e667bfa9d1b7c3801013 (diff)
downloadchrome-ec-60f45d28774d938c77c0f406c273dd54d180265b.tar.gz
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 <teravest@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1020066 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'power/common.c')
-rw-r--r--power/common.c25
1 files changed, 25 insertions, 0 deletions
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) */