summaryrefslogtreecommitdiff
path: root/lib/power_management/suspend/tftf_suspend.c
diff options
context:
space:
mode:
authorSoby Mathew <soby.mathew@arm.com>2015-08-17 12:12:58 +0100
committerSoby Mathew <soby.mathew@arm.com>2015-10-27 15:16:39 +0000
commitc48ed44aaf48e2c5130ae5d32d9d451dcc9f1b38 (patch)
treeb49e40a8cd7442b0cdd007345df2c8d80de16146 /lib/power_management/suspend/tftf_suspend.c
parent09cc32a5e2b1e8ecb18b5c478afe815b15903495 (diff)
Rework the CPU suspend framework to support system suspend
This patch adds support for suspending and restoring the system context to the existing TFTF suspend helpers. The suspend test cases are also modified to use the new helpers. Change-Id: I1816ae5280476e8fbe7fddc7790dc53d14581470
Diffstat (limited to 'lib/power_management/suspend/tftf_suspend.c')
-rw-r--r--lib/power_management/suspend/tftf_suspend.c67
1 files changed, 51 insertions, 16 deletions
diff --git a/lib/power_management/suspend/tftf_suspend.c b/lib/power_management/suspend/tftf_suspend.c
index 46abeea..0bd81d3 100644
--- a/lib/power_management/suspend/tftf_suspend.c
+++ b/lib/power_management/suspend/tftf_suspend.c
@@ -23,17 +23,30 @@
#include <tftf_lib.h>
#include "suspend_private.h"
-int32_t tftf_enter_suspend(uint32_t power_state,
- tftf_cpu_suspend_ctx_t *ctx)
+int32_t tftf_enter_suspend(const suspend_info_t *info,
+ tftf_suspend_ctx_t *ctx)
{
- smc64_args args = {
- SMC_PSCI_CPU_SUSPEND_AARCH64,
- power_state,
- (uint64_t)__tftf_cpu_resume_ep,
- (uint64_t)ctx
- };
+ smc64_args cpu_suspend_args = {
+ info->psci_api,
+ info->power_state,
+ (uint64_t)__tftf_cpu_resume_ep,
+ (uint64_t)ctx
+ };
+
+ smc64_args system_suspend_args = {
+ info->psci_api,
+ (uint64_t)__tftf_cpu_resume_ep,
+ (uint64_t)ctx
+ };
+
smc64_ret_values rc;
+ if (info->save_system_context) {
+ ctx->save_system_context = 1;
+ tftf_save_system_ctx(ctx);
+ } else
+ ctx->save_system_context = 0;
+
/*
* Save the CPU context. It will be restored in resume path in
* __tftf_cpu_resume_ep().
@@ -45,7 +58,10 @@ int32_t tftf_enter_suspend(uint32_t power_state,
*/
flush_dcache_range((uint64_t)ctx, sizeof(*ctx));
- rc = tftf_smc64(&args);
+ if (info->psci_api == SMC_PSCI_CPU_SUSPEND_AARCH64)
+ rc = tftf_smc64(&cpu_suspend_args);
+ else
+ rc = tftf_smc64(&system_suspend_args);
/*
* If execution reaches this point, The above SMC call was an invalid
@@ -55,7 +71,24 @@ int32_t tftf_enter_suspend(uint32_t power_state,
return rc.ret0;
}
-int32_t tftf_cpu_suspend(uint32_t power_state)
+void tftf_restore_system_ctx(tftf_suspend_ctx_t *ctx)
+{
+ assert(ctx != NULL);
+ assert(ctx->save_system_context);
+
+ INFO("Restoring system context\n");
+}
+
+void tftf_save_system_ctx(tftf_suspend_ctx_t *ctx)
+{
+ assert(ctx != NULL);
+ assert(ctx->save_system_context);
+
+ /* Nothing to do here currently */
+ INFO("Saving system context\n");
+}
+
+int tftf_suspend(const suspend_info_t *info)
{
int32_t rc;
uint64_t flags;
@@ -64,13 +97,15 @@ int32_t tftf_cpu_suspend(uint32_t power_state)
INFO("Going into suspend state\n");
- rc = __tftf_cpu_suspend(power_state);
+ rc = __tftf_suspend(info);
- /*
- * HACK: ARM TF is disabling Group 1 interrupts while entering suspend
- * but does not restore it
- */
- arm_gic_cpuif_setup();
+ if (!info->save_system_context) {
+ /*
+ * HACK: ARM TF is disabling Group 1 interrupts while
+ * entering suspend but does not restore it
+ */
+ arm_gic_cpuif_setup();
+ }
/*
* DAIF flags should be restored last because it could be an issue