From: t-kristo@ti.com (Tero Kristo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv3 07/20] ARM: OMAP4: secure: add support for device off
Date: Tue, 12 Jun 2012 18:31:22 +0300 [thread overview]
Message-ID: <1339515095-9908-8-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1339515095-9908-1-git-send-email-t-kristo@ti.com>
If omap4 chip enters device off, complete secure context must be saved.
This requires a separate secure HAL call. As device off mode is overloaded
on top of functional core_pwrdm state, the code checks if core_pwrdm is
entering off mode, and does the complete context save in that case.
Otherwise the GIC save context is enough.
Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
arch/arm/mach-omap2/omap-secure.c | 48 +++++++++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-omap2/omap-secure.c b/arch/arm/mach-omap2/omap-secure.c
index 44905a5..340b11a 100644
--- a/arch/arm/mach-omap2/omap-secure.c
+++ b/arch/arm/mach-omap2/omap-secure.c
@@ -21,6 +21,7 @@
#include <plat/omap-secure.h>
#include <mach/omap-secure.h>
+#include <plat/omap_hwmod.h>
#include "common.h"
@@ -28,6 +29,8 @@
static phys_addr_t omap_secure_memblock_base;
static struct clockdomain *l4_secure_clkdm;
+static struct powerdomain *core_pd;
+static struct omap_hwmod *l3_main_3_oh;
/**
* omap_sec_dispatcher: Routine to dispatch low power secure
@@ -97,6 +100,29 @@ static void save_secure_gic(void)
pr_err("GIC and Wakeupgen secure context save failed\n");
}
+static void save_secure_all(void)
+{
+ u32 ret;
+
+ /*
+ * l3_main_3 must be enabled before calling SAVEALL API,
+ * as it is accessing firewall registers which require this
+ * clock to be enabled. Otherwise secure ROM code will crash.
+ */
+ omap_hwmod_enable(l3_main_3_oh);
+
+ ret = omap_secure_dispatcher(OMAP4_HAL_SAVEALL_INDEX,
+ FLAG_START_CRITICAL,
+ 1, omap_secure_ram_mempool_base(),
+ 0, 0, 0);
+
+ /* Disable after save, not needed anymore */
+ omap_hwmod_idle(l3_main_3_oh);
+
+ if (ret != API_HAL_RET_VALUE_OK)
+ pr_err("Secure all context save failed\n");
+}
+
static int secure_notifier(struct notifier_block *self, unsigned long cmd,
void *v)
{
@@ -113,7 +139,16 @@ static int secure_notifier(struct notifier_block *self, unsigned long cmd,
0, 0, 0, 0, 0);
break;
case CPU_CLUSTER_PM_ENTER:
- save_secure_gic();
+ /*
+ * If device is entering off-mode (core_pd next functional
+ * pwrst = OFF), we must save complete secure mode context.
+ * Otherwise just saving GIC / wakeupgen context is enough.
+ */
+ if (pwrdm_read_next_func_pwrst(core_pd) ==
+ PWRDM_FUNC_PWRST_OFF)
+ save_secure_all();
+ else
+ save_secure_gic();
break;
}
return NOTIFY_OK;
@@ -125,8 +160,17 @@ static struct notifier_block secure_notifier_block = {
static int __init secure_pm_init(void)
{
- if (omap_type() != OMAP2_DEVICE_TYPE_GP)
+ if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
cpu_pm_register_notifier(&secure_notifier_block);
+
+ l3_main_3_oh = omap_hwmod_lookup("l3_main_3");
+ if (!l3_main_3_oh)
+ pr_err("%s: failed to get l3_main_3_oh\n", __func__);
+
+ core_pd = pwrdm_lookup("core_pwrdm");
+ if (!core_pd)
+ pr_err("%s: failed to get core_pwrdm\n", __func__);
+ }
return 0;
}
early_initcall(secure_pm_init);
--
1.7.4.1
next prev parent reply other threads:[~2012-06-12 15:31 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-12 15:31 [PATCHv3 00/20] ARM: OMAP4: device off support Tero Kristo
2012-06-12 15:31 ` [PATCHv3 01/20] ARM: OMAP4: PM: powerdomain: Add HWSAR flag to L3INIT Tero Kristo
2012-06-12 15:31 ` [PATCHv3 02/20] ARM: OMAP4: powerdomain: update mpu / core off counters during device off Tero Kristo
2012-06-12 15:31 ` [PATCHv3 03/20] ARM: OMAP4: PM: add support for " Tero Kristo
2012-06-13 15:21 ` Jean Pihet
2012-06-14 9:18 ` Tero Kristo
2012-06-14 13:53 ` Tero Kristo
2012-06-12 15:31 ` [PATCHv3 04/20] ARM: OMAP4: PM: update ROM return address for OSWR and OFF Tero Kristo
2012-06-12 15:31 ` [PATCHv3 05/20] OMAP4: PM: clockdomain: workaround for l4_secure_clkdm HWSUP Tero Kristo
2012-06-12 15:31 ` [PATCHv3 06/20] ARM: OMAP4: secure: move GIC / wakeupgen save restore to secure CPU PM notifier Tero Kristo
2012-06-12 15:31 ` Tero Kristo [this message]
2012-06-12 15:31 ` [PATCHv3 08/20] ARM: OMAP4: PM: add MPUSS power domain device off support Tero Kristo
2012-06-12 15:31 ` [PATCHv3 09/20] ARM: OMAP4: PM: save/restore all DPLL settings in OFF mode Tero Kristo
2012-06-12 15:31 ` [PATCHv3 10/20] ARM: OMAP4: PM: save/restore all CM1/2 " Tero Kristo
2012-06-12 15:31 ` [PATCHv3 11/20] ARM: OMAP4: PM: Add SAR backup support towards device OFF Tero Kristo
2012-06-12 15:31 ` [PATCHv3 12/20] ARM: OMAP4: PM: Work-around for ROM code BUG of IVAHD/TESLA Tero Kristo
2012-06-12 15:31 ` [PATCHv3 13/20] ARM: OMAP4: PM: save/restore CM L3INSTR registers when MPU hits OSWR/OFF mode Tero Kristo
2012-06-12 15:31 ` [PATCHv3 14/20] ARM: OMAP4: PM: Mark the PPI and SPI interrupts as non-secure for GP Tero Kristo
2012-06-12 15:31 ` [PATCHv3 15/20] ARM: OMAP4430: PM: workaround for DDR corruption on second CS Tero Kristo
2012-06-12 15:31 ` [PATCHv3 16/20] TEMP: ARM: OMAP4: prevent voltage transitions Tero Kristo
2012-06-12 15:31 ` [PATCHv3 17/20] ARM: OMAP4: put cpu1 back to sleep if no wake request Tero Kristo
2012-06-12 15:31 ` [PATCHv3 18/20] ARM: OMAP4460: wakeupgen: set GIC_CPU0 backup status flag always Tero Kristo
2012-06-12 15:31 ` [PATCHv3 19/20] ARM: OMAP4: PM: enable off mode by default Tero Kristo
2012-06-12 15:41 ` [PATCHv3 20/20] ARM: OMAP4430: PM: errata i625, WUGEN lost for GP devices after OFF mode Tero Kristo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1339515095-9908-8-git-send-email-t-kristo@ti.com \
--to=t-kristo@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).