misc: SRAM: Add option to map SRAM to allow code execution
authorRuss Dill <Russ.Dill@ti.com>
Tue, 17 Sep 2013 09:34:58 +0000 (02:34 -0700)
committer黄涛 <huangtao@rock-chips.com>
Thu, 21 Nov 2013 05:39:20 +0000 (13:39 +0800)
This is necessary for platforms that use SRAM to execute suspend/resume stubs.

Signed-off-by: Russ Dill <Russ.Dill@ti.com>
Documentation/devicetree/bindings/misc/sram.txt
drivers/misc/sram.c
include/linux/platform_data/sram.h [new file with mode: 0644]

index 4d0a00e453a82bcaab289888ad7391178bf1e041..4fa9af31a06176f5c5f450c7027f0b67850c6033 100644 (file)
@@ -8,6 +8,10 @@ Required properties:
 
 - reg : SRAM iomem address range
 
+Optional properties:
+
+- map-exec: Map range to allow code execution
+
 Example:
 
 sram: sram@5c000000 {
index d87cc91bc016568032c7416619c007d1995a6d54..baa50080ac460a288fa1696cea04a6074bdefe3b 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/genalloc.h>
+#include <linux/platform_data/sram.h>
 
 #define SRAM_GRANULARITY       32
 
@@ -38,14 +39,24 @@ struct sram_dev {
 
 static int sram_probe(struct platform_device *pdev)
 {
+       struct sram_platform_data *pdata = pdev->dev.platform_data;
        void __iomem *virt_base;
        struct sram_dev *sram;
        struct resource *res;
        unsigned long size;
+       bool map_exec = false;
        int ret;
 
+       if (of_get_property(pdev->dev.of_node, "map-exec", NULL))
+               map_exec = true;
+       if (pdata && pdata->map_exec)
+               map_exec |= true;
+
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       virt_base = devm_ioremap_resource(&pdev->dev, res);
+       if (map_exec)
+               virt_base = devm_ioremap_exec_resource(&pdev->dev, res);
+       else
+               virt_base = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(virt_base))
                return PTR_ERR(virt_base);
 
diff --git a/include/linux/platform_data/sram.h b/include/linux/platform_data/sram.h
new file mode 100644 (file)
index 0000000..8f5c4ba
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef _LINUX_SRAM_H
+#define _LINUX_SRAM_H
+
+struct sram_platform_data {
+       bool map_exec;
+};
+
+#endif