ARM: MM: Add DT binding for Feroceon L2 cache
authorAndrew Lunn <andrew@lunn.ch>
Sat, 22 Feb 2014 19:14:52 +0000 (20:14 +0100)
committerJason Cooper <jason@lakedaemon.net>
Sat, 22 Feb 2014 20:43:49 +0000 (20:43 +0000)
Instantiate the L2 cache from DT. Indicate in DT where the cache
control register is so that it is possible to enable/disable write
through on the CPU.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Documentation/devicetree/bindings/arm/mrvl/feroceon.txt [new file with mode: 0644]
arch/arm/include/asm/hardware/cache-feroceon-l2.h
arch/arm/mach-kirkwood/board-dt.c
arch/arm/mm/cache-feroceon-l2.c

diff --git a/Documentation/devicetree/bindings/arm/mrvl/feroceon.txt b/Documentation/devicetree/bindings/arm/mrvl/feroceon.txt
new file mode 100644 (file)
index 0000000..0d244b9
--- /dev/null
@@ -0,0 +1,16 @@
+* Marvell Feroceon Cache
+
+Required properties:
+- compatible : Should be either "marvell,feroceon-cache" or
+              "marvell,kirkwood-cache".
+
+Optional properties:
+- reg        : Address of the L2 cache control register. Mandatory for
+              "marvell,kirkwood-cache", not used by "marvell,feroceon-cache"
+
+
+Example:
+               l2: l2-cache@20128 {
+                       compatible = "marvell,kirkwood-cache";
+                       reg = <0x20128 0x4>;
+               };
index 8edd330aabf6c1336d875266e75fe486942bd3a3..12e1588dc4f139b78a823f7152f2f08d0c37da28 100644 (file)
@@ -9,3 +9,5 @@
  */
 
 extern void __init feroceon_l2_init(int l2_wt_override);
+extern int __init feroceon_of_init(void);
+
index 29c246858d5a0dc1eb15bb0d1495e378efef52ec..ec0702c02d6c9e802cb7104110588863353912ac 100644 (file)
@@ -42,19 +42,6 @@ static void __init kirkwood_map_io(void)
        iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
 }
 
-static void __init kirkwood_l2_init(void)
-{
-#ifdef CONFIG_CACHE_FEROCEON_L2
-#ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
-       writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
-       feroceon_l2_init(1);
-#else
-       writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
-       feroceon_l2_init(0);
-#endif
-#endif
-}
-
 static struct resource kirkwood_cpufreq_resources[] = {
        [0] = {
                .start  = CPU_CONTROL_PHYS,
@@ -211,8 +198,9 @@ static void __init kirkwood_dt_init(void)
 
        BUG_ON(mvebu_mbus_dt_init());
 
-       kirkwood_l2_init();
-
+#ifdef CONFIG_CACHE_FEROCEON_L2
+       feroceon_of_init();
+#endif
        kirkwood_cpufreq_init();
        kirkwood_cpuidle_init();
 
index 898362e7972bdc260519f704cf5f4ad832fefd03..8dc1a2b5a8ed5148880a7ec8edd46e3c2ece8fe9 100644 (file)
  */
 
 #include <linux/init.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/highmem.h>
+#include <linux/io.h>
 #include <asm/cacheflush.h>
 #include <asm/cp15.h>
 #include <asm/hardware/cache-feroceon-l2.h>
 
+#define L2_WRITETHROUGH_KIRKWOOD       BIT(4)
+
 /*
  * Low-level cache maintenance operations.
  *
@@ -350,3 +355,41 @@ void __init feroceon_l2_init(int __l2_wt_override)
        printk(KERN_INFO "Feroceon L2: Cache support initialised%s.\n",
                         l2_wt_override ? ", in WT override mode" : "");
 }
+#ifdef CONFIG_OF
+static const struct of_device_id feroceon_ids[] __initconst = {
+       { .compatible = "marvell,kirkwood-cache"},
+       { .compatible = "marvell,feroceon-cache"},
+       {}
+};
+
+int __init feroceon_of_init(void)
+{
+       struct device_node *node;
+       void __iomem *base;
+       bool l2_wt_override = false;
+       struct resource res;
+
+#if defined(CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH)
+       l2_wt_override = true;
+#endif
+
+       node = of_find_matching_node(NULL, feroceon_ids);
+       if (node && of_device_is_compatible(node, "marvell,kirkwood-cache")) {
+               if (of_address_to_resource(node, 0, &res))
+                       return -ENODEV;
+
+               base = ioremap(res.start, resource_size(&res));
+               if (!base)
+                       return -ENOMEM;
+
+               if (l2_wt_override)
+                       writel(readl(base) | L2_WRITETHROUGH_KIRKWOOD, base);
+               else
+                       writel(readl(base) & ~L2_WRITETHROUGH_KIRKWOOD, base);
+       }
+
+       feroceon_l2_init(l2_wt_override);
+
+       return 0;
+}
+#endif