summaryrefslogtreecommitdiff
path: root/power/common.c
diff options
context:
space:
mode:
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) */