* [PATCH 1/6] Documentation: sram: ti: Add TI SRAM bindings
2016-05-09 21:49 [PATCH 0/6] ARM: OMAP3: Convert OMAP3 PM code to use generic sram driver Dave Gerlach
@ 2016-05-09 21:49 ` Dave Gerlach
2016-05-09 21:49 ` [PATCH 2/6] ARM: dts: omap3: Add ocmcram node Dave Gerlach
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Dave Gerlach @ 2016-05-09 21:49 UTC (permalink / raw)
To: linux-arm-kernel
Add binding document for TI use of mmio-sram driver for purposes like
mapping the region as executable or reserving space needed by secure
silicon.
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---
Documentation/devicetree/bindings/sram/ti-sram.txt | 47 ++++++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 Documentation/devicetree/bindings/sram/ti-sram.txt
diff --git a/Documentation/devicetree/bindings/sram/ti-sram.txt b/Documentation/devicetree/bindings/sram/ti-sram.txt
new file mode 100644
index 000000000000..68c4b733c78c
--- /dev/null
+++ b/Documentation/devicetree/bindings/sram/ti-sram.txt
@@ -0,0 +1,47 @@
+TI SRAM Node:
+-------------
+
+Many TI SoC's rely on SRAM for running low-level PM code as part of the
+suspend or cpuidle path. Because of this, regions in sram must be mapped
+as "memory-exec" or "memory-exec-nocache" in order for the region to be
+executable.
+
+Optional sub-node
+-----------------
+Some TI SoCs have secure variants that require a certain portion of
+the SRAM to be reserved for use by secure software. This can be
+marked in the parent SRAM node with a subnode as described in
+Documentation/devicetree/bindings/sram/sram.txt. This node can be
+added in two ways:
+
+- From board dts files for secure platforms to avoid adding it
+ for all SoC variants with a fixed size defined.
+- As a dummy node in the .dtsi sram node with any size that will be
+ modified by a bootloader to the correct size needed.
+
+Sub-node properties:
+- compatible : should be "ti,secure-sram"
+
+The rest of the properties should follow the generic mmio-sram discription
+found in Documentation/devicetree/bindings/sram/sram.txt
+
+Example:
+ /* In parent SoC .dtsi */
+ ocmcram: ocmcram at 40200000 {
+ compatible = "mmio-sram";
+ reg = <0x40200000 0x10000>; /* 64k */
+ memory-exec-nocache;
+ ranges = <0x0 0x40200000 0x10000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ };
+
+ /* In board .dts where secure silicon is present */
+ &ocmcram {
+ sram-hs at 0 {
+ compatible = "ti,secure-ram";
+ reg = <0x0 0xC000>;
+ };
+ };
--
2.7.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/6] ARM: dts: omap3: Add ocmcram node
2016-05-09 21:49 [PATCH 0/6] ARM: OMAP3: Convert OMAP3 PM code to use generic sram driver Dave Gerlach
2016-05-09 21:49 ` [PATCH 1/6] Documentation: sram: ti: Add TI SRAM bindings Dave Gerlach
@ 2016-05-09 21:49 ` Dave Gerlach
2016-05-09 21:49 ` [PATCH 3/6] ARM: dts: omap3-n900: Add secure reserved region to " Dave Gerlach
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Dave Gerlach @ 2016-05-09 21:49 UTC (permalink / raw)
To: linux-arm-kernel
Add an ocmcram node to omap3 dtsi using the mmio-sram driver to
represent the 64kb of SRAM available on omap3 and it's derivatives.
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---
arch/arm/boot/dts/omap3.dtsi | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index b41d07e8e765..a267616c3c68 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -59,6 +59,7 @@
mpu {
compatible = "ti,omap3-mpu";
ti,hwmods = "mpu";
+ sram = <&ocmcram>;
};
iva: iva {
@@ -153,6 +154,16 @@
};
};
+ ocmcram: ocmcram at 40200000 {
+ compatible = "mmio-sram";
+ reg = <0x40200000 0x10000>; /* 64k */
+ memory-exec-nocache;
+ ranges = <0x0 0x40200000 0x10000>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ };
+
aes: aes at 480c5000 {
compatible = "ti,omap3-aes";
ti,hwmods = "aes";
--
2.7.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] ARM: dts: omap3-n900: Add secure reserved region to ocmcram node
2016-05-09 21:49 [PATCH 0/6] ARM: OMAP3: Convert OMAP3 PM code to use generic sram driver Dave Gerlach
2016-05-09 21:49 ` [PATCH 1/6] Documentation: sram: ti: Add TI SRAM bindings Dave Gerlach
2016-05-09 21:49 ` [PATCH 2/6] ARM: dts: omap3: Add ocmcram node Dave Gerlach
@ 2016-05-09 21:49 ` Dave Gerlach
2016-05-09 21:49 ` [PATCH 4/6] ARM: OMAP2+: pm34xx: Convert to use generic sram driver for idle code Dave Gerlach
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Dave Gerlach @ 2016-05-09 21:49 UTC (permalink / raw)
To: linux-arm-kernel
Platforms with secure silicon, like omap3-n900, need to mark off a
section of the ocmcram as reserved because it is used by secure
software.
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---
arch/arm/boot/dts/omap3-n900.dts | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index b3c26a96a726..448452a76c23 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -1004,3 +1004,10 @@
&ssi_port2 {
status = "disabled";
};
+
+&ocmcram {
+ sram-hs at 0 {
+ compatible = "ti,secure-ram";
+ reg = <0x0 0xC000>;
+ };
+};
--
2.7.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] ARM: OMAP2+: pm34xx: Convert to use generic sram driver for idle code
2016-05-09 21:49 [PATCH 0/6] ARM: OMAP3: Convert OMAP3 PM code to use generic sram driver Dave Gerlach
` (2 preceding siblings ...)
2016-05-09 21:49 ` [PATCH 3/6] ARM: dts: omap3-n900: Add secure reserved region to " Dave Gerlach
@ 2016-05-09 21:49 ` Dave Gerlach
2016-05-09 21:49 ` [PATCH 5/6] ARM: OMAP2+: Remove legacy sram init code for omap3 platforms Dave Gerlach
2016-05-09 21:49 ` [PATCH 6/6] ARM: OMAP2+: sram: remove legacy OMAP3 code Dave Gerlach
5 siblings, 0 replies; 7+ messages in thread
From: Dave Gerlach @ 2016-05-09 21:49 UTC (permalink / raw)
To: linux-arm-kernel
Change to use the generic SRAM driver and genalloc framework to allocate
SRAM space for low-level ASM PM code instead of omap specific SRAM
allocator.
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---
arch/arm/mach-omap2/pm34xx.c | 82 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 81 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index d44e0e2f1106..5ebbf5c30c6e 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -24,17 +24,21 @@
#include <linux/module.h>
#include <linux/list.h>
#include <linux/err.h>
+#include <linux/genalloc.h>
#include <linux/gpio.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/slab.h>
+#include <linux/of.h>
#include <linux/omap-dma.h>
#include <linux/omap-gpmc.h>
#include <linux/platform_data/gpio-omap.h>
+#include <linux/sizes.h>
#include <trace/events/power.h>
#include <asm/fncpy.h>
+#include <asm/proc-fns.h>
#include <asm/suspend.h>
#include <asm/system_misc.h>
@@ -68,6 +72,9 @@ static LIST_HEAD(pwrst_list);
static int (*_omap_save_secure_sram)(u32 *addr);
void (*omap3_do_wfi_sram)(void);
+static struct gen_pool *sram_pool;
+static phys_addr_t ocmcram_location;
+static phys_addr_t secure_ocmcram_location;
static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
static struct powerdomain *core_pwrdm, *per_pwrdm;
@@ -179,6 +186,71 @@ static void omap34xx_save_context(u32 *save)
*save++ = val;
}
+/*
+ * Push functions to SRAM
+ *
+ * The minimum set of functions is pushed to SRAM for execution:
+ * - omap3_do_wfi for erratum i581 WA,
+ * - save_secure_ram_context for security extensions.
+ */
+static int omap3_prepare_push_sram_idle(void)
+{
+ struct device_node *np;
+
+ np = of_find_compatible_node(NULL, NULL, "ti,omap3-mpu");
+ if (!np) {
+ pr_warn("PM: %s: Unable to find device node for mpu\n",
+ __func__);
+ return -ENODEV;
+ }
+
+ sram_pool = of_gen_pool_get(np, "sram", 0);
+
+ if (!sram_pool) {
+ pr_warn("PM: %s: Unable to get sram pool for ocmcram\n",
+ __func__);
+ return -ENODEV;
+ }
+
+ ocmcram_location = gen_pool_alloc(sram_pool, omap3_do_wfi_sz);
+ if (!ocmcram_location) {
+ pr_warn("PM: %s: Unable to allocate memory from ocmcram for omap3_do_wfi_sz.\n",
+ __func__);
+ return -EINVAL;
+ }
+
+ if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
+ secure_ocmcram_location =
+ gen_pool_alloc(sram_pool,
+ save_secure_ram_context_sz);
+ if (!secure_ocmcram_location) {
+ pr_warn("PM: %s: Unable to allocate memory from ocmcram for save_secure_ram_context.\n",
+ __func__);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+static int omap3_push_sram_idle(void)
+{
+ omap3_do_wfi_sram = fncpy((void *)ocmcram_location,
+ &omap3_do_wfi,
+ omap3_do_wfi_sz);
+
+ return 0;
+}
+
+static int omap3_push_sram_secure_idle(void)
+{
+ if (omap_type() != OMAP2_DEVICE_TYPE_GP)
+ _omap_save_secure_sram = fncpy((void *)secure_ocmcram_location,
+ &save_secure_ram_context,
+ save_secure_ram_context_sz);
+ return 0;
+}
+
static int omap34xx_do_sram_idle(unsigned long save_state)
{
omap34xx_cpu_suspend(save_state);
@@ -281,7 +353,8 @@ void omap_sram_idle(void)
pwrdm_read_prev_pwrst(core_pwrdm) == PWRDM_POWER_OFF) {
omap3_core_restore_context();
omap3_cm_restore_context();
- omap3_sram_restore_context();
+ omap3_push_sram_idle();
+ omap3_push_sram_secure_idle();
omap2_sms_restore_context();
} else {
/*
@@ -517,6 +590,13 @@ int __init omap3_pm_init(void)
per_clkdm = clkdm_lookup("per_clkdm");
wkup_clkdm = clkdm_lookup("wkup_clkdm");
+ ret = omap3_prepare_push_sram_idle();
+ if (ret)
+ goto err3;
+
+ omap3_push_sram_idle();
+ omap3_push_sram_secure_idle();
+
omap_common_suspend_init(omap3_pm_suspend);
arm_pm_idle = omap3_pm_idle;
--
2.7.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] ARM: OMAP2+: Remove legacy sram init code for omap3 platforms
2016-05-09 21:49 [PATCH 0/6] ARM: OMAP3: Convert OMAP3 PM code to use generic sram driver Dave Gerlach
` (3 preceding siblings ...)
2016-05-09 21:49 ` [PATCH 4/6] ARM: OMAP2+: pm34xx: Convert to use generic sram driver for idle code Dave Gerlach
@ 2016-05-09 21:49 ` Dave Gerlach
2016-05-09 21:49 ` [PATCH 6/6] ARM: OMAP2+: sram: remove legacy OMAP3 code Dave Gerlach
5 siblings, 0 replies; 7+ messages in thread
From: Dave Gerlach @ 2016-05-09 21:49 UTC (permalink / raw)
To: linux-arm-kernel
Remove omap3 platforms from using legacy sram init code in mach-omap2 as
the platforms will now use the generic mmio-sram driver like other omap
platforms already do.
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---
arch/arm/mach-omap2/pdata-quirks.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index a935d28443da..1a5b8afdb2e3 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -579,8 +579,7 @@ void __init pdata_quirks_init(const struct of_device_id *omap_dt_match_table)
* We still need this for omap2420 and omap3 PM to work, others are
* using drivers/misc/sram.c already.
*/
- if (of_machine_is_compatible("ti,omap2420") ||
- of_machine_is_compatible("ti,omap3"))
+ if (of_machine_is_compatible("ti,omap2420"))
omap_sdrc_init(NULL, NULL);
pdata_quirks_check(auxdata_quirks);
--
2.7.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] ARM: OMAP2+: sram: remove legacy OMAP3 code
2016-05-09 21:49 [PATCH 0/6] ARM: OMAP3: Convert OMAP3 PM code to use generic sram driver Dave Gerlach
` (4 preceding siblings ...)
2016-05-09 21:49 ` [PATCH 5/6] ARM: OMAP2+: Remove legacy sram init code for omap3 platforms Dave Gerlach
@ 2016-05-09 21:49 ` Dave Gerlach
5 siblings, 0 replies; 7+ messages in thread
From: Dave Gerlach @ 2016-05-09 21:49 UTC (permalink / raw)
To: linux-arm-kernel
Now that we have converted OMAP3 PM code to use generic sram driver we
no longer need to provide OMAP3 specific SRAM code for the omap SRAM
API.
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---
arch/arm/mach-omap2/pm34xx.c | 16 ----------------
arch/arm/mach-omap2/sram.c | 23 -----------------------
2 files changed, 39 deletions(-)
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 5ebbf5c30c6e..22d4c8742f99 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -502,22 +502,6 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
return omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
}
-/*
- * Push functions to SRAM
- *
- * The minimum set of functions is pushed to SRAM for execution:
- * - omap3_do_wfi for erratum i581 WA,
- * - save_secure_ram_context for security extensions.
- */
-void omap_push_sram_idle(void)
-{
- omap3_do_wfi_sram = omap_sram_push(omap3_do_wfi, omap3_do_wfi_sz);
-
- if (omap_type() != OMAP2_DEVICE_TYPE_GP)
- _omap_save_secure_sram = omap_sram_push(save_secure_ram_context,
- save_secure_ram_context_sz);
-}
-
static void __init pm_errata_configure(void)
{
if (cpu_is_omap3630()) {
diff --git a/arch/arm/mach-omap2/sram.c b/arch/arm/mach-omap2/sram.c
index 83d0e61f49e6..7881304b5205 100644
--- a/arch/arm/mach-omap2/sram.c
+++ b/arch/arm/mach-omap2/sram.c
@@ -209,27 +209,6 @@ static inline int omap243x_sram_init(void)
}
#endif
-#ifdef CONFIG_ARCH_OMAP3
-
-void omap3_sram_restore_context(void)
-{
- omap_sram_reset();
-
- omap_push_sram_idle();
-}
-
-static inline int omap34xx_sram_init(void)
-{
- omap3_sram_restore_context();
- return 0;
-}
-#else
-static inline int omap34xx_sram_init(void)
-{
- return 0;
-}
-#endif /* CONFIG_ARCH_OMAP3 */
-
int __init omap_sram_init(void)
{
omap_detect_sram();
@@ -239,8 +218,6 @@ int __init omap_sram_init(void)
omap242x_sram_init();
else if (cpu_is_omap2430())
omap243x_sram_init();
- else if (cpu_is_omap34xx())
- omap34xx_sram_init();
return 0;
}
--
2.7.3
^ permalink raw reply related [flat|nested] 7+ messages in thread