kirkwood: Allow nand to be configured via. devicetree
authorJamie Lentin <jm@lentin.co.uk>
Wed, 18 Apr 2012 10:06:42 +0000 (11:06 +0100)
committerJason Cooper <jason@lakedaemon.net>
Tue, 15 May 2012 02:29:11 +0000 (02:29 +0000)
Add default configuration for NAND, to be enabled in your board config. Ensure
clock gating is set appropriately when the NAND is enabled.

Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Jamie Lentin <jm@lentin.co.uk>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
arch/arm/boot/dts/kirkwood.dtsi
arch/arm/mach-kirkwood/common.c

index 3474ef8909455e6899dd184c8f71b06fdba2f2ec..926528b81baa00dace4faf5b39ca0dbe7b2dfe03 100644 (file)
@@ -5,7 +5,7 @@
 
        ocp@f1000000 {
                compatible = "simple-bus";
-               ranges = <0 0xf1000000 0x1000000>;
+               ranges = <0 0xf1000000 0x4000000>;
                #address-cells = <1>;
                #size-cells = <1>;
 
                        reg = <0x10300 0x20>;
                        interrupts = <53>;
                };
+
+               nand@3000000 {
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       cle = <0>;
+                       ale = <1>;
+                       bank-width = <1>;
+                       compatible = "mrvl,orion-nand";
+                       reg = <0x3000000 0x400>;
+                       chip-delay = <25>;
+                       /* set partition map and/or chip-delay in board dts */
+                       status = "disabled";
+               };
        };
 };
index a02cae881f2fe199929f789b3275e7ad9cd17d69..3ad037385a5e8ad1883d8c242a689417f1f15c7f 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/ata_platform.h>
 #include <linux/mtd/nand.h>
 #include <linux/dma-mapping.h>
+#include <linux/of.h>
 #include <net/dsa.h>
 #include <asm/page.h>
 #include <asm/timex.h>
@@ -482,6 +483,9 @@ static int __init kirkwood_clock_gate(void)
        unsigned int curr = readl(CLOCK_GATING_CTRL);
        u32 dev, rev;
 
+#ifdef CONFIG_OF
+       struct device_node *np;
+#endif
        kirkwood_pcie_id(&dev, &rev);
        printk(KERN_DEBUG "Gating clock of unused units\n");
        printk(KERN_DEBUG "before: 0x%08x\n", curr);
@@ -489,6 +493,14 @@ static int __init kirkwood_clock_gate(void)
        /* Make sure those units are accessible */
        writel(curr | CGC_SATA0 | CGC_SATA1 | CGC_PEX0 | CGC_PEX1, CLOCK_GATING_CTRL);
 
+#ifdef CONFIG_OF
+       np = of_find_compatible_node(NULL, NULL, "mrvl,orion-nand");
+       if (np && of_device_is_available(np)) {
+               kirkwood_clk_ctrl |= CGC_RUNIT;
+               of_node_put(np);
+       }
+#endif
+
        /* For SATA: first shutdown the phy */
        if (!(kirkwood_clk_ctrl & CGC_SATA0)) {
                /* Disable PLL and IVREF */