[ARM] Kirkwood: rationalize NAND setup a bit
authorNicolas Pitre <nico@cam.org>
Mon, 1 Jun 2009 19:36:36 +0000 (15:36 -0400)
committerNicolas Pitre <nico@cam.org>
Mon, 8 Jun 2009 17:04:58 +0000 (13:04 -0400)
Common resource and platform device structures are moved to common.c
and only the partition table and chip delay remains a per board
parameter.

Signed-off-by: Nicolas Pitre <nico@marvell.com>
arch/arm/mach-kirkwood/common.c
arch/arm/mach-kirkwood/common.h
arch/arm/mach-kirkwood/db88f6281-bp-setup.c
arch/arm/mach-kirkwood/rd88f6192-nas-setup.c
arch/arm/mach-kirkwood/rd88f6281-setup.c
arch/arm/mach-kirkwood/sheevaplug-setup.c

index be1ca28fed3fb9eceb03394338eaaf5166821a06..6e3eb1a6a660e0a8811666a5901d9d5dee5a4524 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/mv643xx_eth.h>
 #include <linux/mv643xx_i2c.h>
 #include <linux/ata_platform.h>
+#include <linux/mtd/nand.h>
 #include <linux/spi/orion_spi.h>
 #include <net/dsa.h>
 #include <asm/page.h>
@@ -257,6 +258,42 @@ void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
 }
 
 
+/*****************************************************************************
+ * NAND flash
+ ****************************************************************************/
+static struct resource kirkwood_nand_resource = {
+       .flags          = IORESOURCE_MEM,
+       .start          = KIRKWOOD_NAND_MEM_PHYS_BASE,
+       .end            = KIRKWOOD_NAND_MEM_PHYS_BASE +
+                               KIRKWOOD_NAND_MEM_SIZE - 1,
+};
+
+static struct orion_nand_data kirkwood_nand_data = {
+       .cle            = 0,
+       .ale            = 1,
+       .width          = 8,
+};
+
+static struct platform_device kirkwood_nand_flash = {
+       .name           = "orion_nand",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &kirkwood_nand_data,
+       },
+       .resource       = &kirkwood_nand_resource,
+       .num_resources  = 1,
+};
+
+void __init kirkwood_nand_init(struct mtd_partition *parts, int nr_parts,
+                              int chip_delay)
+{
+       kirkwood_nand_data.parts = parts;
+       kirkwood_nand_data.nr_parts = nr_parts;
+       kirkwood_nand_data.chip_delay = chip_delay;
+       platform_device_register(&kirkwood_nand_flash);
+}
+
+
 /*****************************************************************************
  * SoC RTC
  ****************************************************************************/
index 6ee88406f381a4f76771501433b694b16d740d27..9de525664bb30eccd1de16d5b7aa0072ccc1f317 100644 (file)
@@ -15,6 +15,7 @@ struct dsa_platform_data;
 struct mv643xx_eth_platform_data;
 struct mv_sata_platform_data;
 struct mvsdio_platform_data;
+struct mtd_partition;
 
 /*
  * Basic Kirkwood init functions used early by machine-setup.
@@ -40,9 +41,11 @@ void kirkwood_spi_init(void);
 void kirkwood_i2c_init(void);
 void kirkwood_uart0_init(void);
 void kirkwood_uart1_init(void);
+void kirkwood_nand_init(struct mtd_partition *parts, int nr_parts, int delay);
 
 extern int kirkwood_tclk;
 extern struct sys_timer kirkwood_timer;
 
+#define ARRAY_AND_SIZE(x)      (x), ARRAY_SIZE(x)
 
 #endif
index 5505d58377524d6c45ed8a42fbe9794d90215a53..39bdf4bcace959322cc966d613cc976007dbe020 100644 (file)
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
 #include <linux/ata_platform.h>
 #include <linux/mv643xx_eth.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <mach/kirkwood.h>
-#include <plat/orion_nand.h>
 #include <plat/mvsdio.h>
 #include "common.h"
 #include "mpp.h"
@@ -39,32 +37,6 @@ static struct mtd_partition db88f6281_nand_parts[] = {
        },
 };
 
-static struct resource db88f6281_nand_resource = {
-       .flags          = IORESOURCE_MEM,
-       .start          = KIRKWOOD_NAND_MEM_PHYS_BASE,
-       .end            = KIRKWOOD_NAND_MEM_PHYS_BASE +
-                         KIRKWOOD_NAND_MEM_SIZE - 1,
-};
-
-static struct orion_nand_data db88f6281_nand_data = {
-       .parts          = db88f6281_nand_parts,
-       .nr_parts       = ARRAY_SIZE(db88f6281_nand_parts),
-       .cle            = 0,
-       .ale            = 1,
-       .width          = 8,
-       .chip_delay     = 25,
-};
-
-static struct platform_device db88f6281_nand_flash = {
-       .name           = "orion_nand",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = &db88f6281_nand_data,
-       },
-       .resource       = &db88f6281_nand_resource,
-       .num_resources  = 1,
-};
-
 static struct mv643xx_eth_platform_data db88f6281_ge00_data = {
        .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
 };
@@ -92,13 +64,12 @@ static void __init db88f6281_init(void)
        kirkwood_init();
        kirkwood_mpp_conf(db88f6281_mpp_config);
 
+       kirkwood_nand_init(ARRAY_AND_SIZE(db88f6281_nand_parts), 25);
        kirkwood_ehci_init();
        kirkwood_ge00_init(&db88f6281_ge00_data);
        kirkwood_sata_init(&db88f6281_sata_data);
        kirkwood_uart0_init();
        kirkwood_sdio_init(&db88f6281_mvsdio_data);
-       
-       platform_device_register(&db88f6281_nand_flash);
 }
 
 static int __init db88f6281_pci_init(void)
index 2f0e4ef3db0f44bd6766af9db41402f5c87617a2..8bf4153d0840f3a2ac08fff3adbf2ebca5308258 100644 (file)
@@ -11,8 +11,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/mtd/nand.h>
-#include <linux/mtd/partitions.h>
 #include <linux/ata_platform.h>
 #include <linux/mv643xx_eth.h>
 #include <linux/spi/flash.h>
index 31e996d65fc46523845420eac063a29fcacaef40..31708ddbc83e13d5d97b31bdbaf3c13eeb735c1a 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/irq.h>
-#include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
 #include <linux/ata_platform.h>
 #include <linux/mv643xx_eth.h>
@@ -22,7 +21,6 @@
 #include <asm/mach/arch.h>
 #include <mach/kirkwood.h>
 #include <plat/mvsdio.h>
-#include <plat/orion_nand.h>
 #include "common.h"
 #include "mpp.h"
 
@@ -42,32 +40,6 @@ static struct mtd_partition rd88f6281_nand_parts[] = {
        },
 };
 
-static struct resource rd88f6281_nand_resource = {
-       .flags          = IORESOURCE_MEM,
-       .start          = KIRKWOOD_NAND_MEM_PHYS_BASE,
-       .end            = KIRKWOOD_NAND_MEM_PHYS_BASE +
-                         KIRKWOOD_NAND_MEM_SIZE - 1,
-};
-
-static struct orion_nand_data rd88f6281_nand_data = {
-       .parts          = rd88f6281_nand_parts,
-       .nr_parts       = ARRAY_SIZE(rd88f6281_nand_parts),
-       .cle            = 0,
-       .ale            = 1,
-       .width          = 8,
-       .chip_delay     = 25,
-};
-
-static struct platform_device rd88f6281_nand_flash = {
-       .name           = "orion_nand",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = &rd88f6281_nand_data,
-       },
-       .resource       = &rd88f6281_nand_resource,
-       .num_resources  = 1,
-};
-
 static struct mv643xx_eth_platform_data rd88f6281_ge00_data = {
        .phy_addr       = MV643XX_ETH_PHY_NONE,
        .speed          = SPEED_1000,
@@ -114,6 +86,7 @@ static void __init rd88f6281_init(void)
        kirkwood_init();
        kirkwood_mpp_conf(rd88f6281_mpp_config);
 
+       kirkwood_nand_init(ARRAY_AND_SIZE(rd88f6281_nand_parts), 25);
        kirkwood_ehci_init();
 
        kirkwood_ge00_init(&rd88f6281_ge00_data);
@@ -129,8 +102,6 @@ static void __init rd88f6281_init(void)
        kirkwood_sata_init(&rd88f6281_sata_data);
        kirkwood_sdio_init(&rd88f6281_mvsdio_data);
        kirkwood_uart0_init();
-
-       platform_device_register(&rd88f6281_nand_flash);
 }
 
 static int __init rd88f6281_pci_init(void)
index dcc448c983895b18e8d0e6c93a652c627ef222d2..c7319eeac8bbcddf0eafa3d501a3500b63128a92 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mv643xx_eth.h>
 #include <linux/gpio.h>
@@ -20,7 +19,6 @@
 #include <asm/mach/arch.h>
 #include <mach/kirkwood.h>
 #include <plat/mvsdio.h>
-#include <plat/orion_nand.h>
 #include "common.h"
 #include "mpp.h"
 
@@ -40,32 +38,6 @@ static struct mtd_partition sheevaplug_nand_parts[] = {
        },
 };
 
-static struct resource sheevaplug_nand_resource = {
-       .flags          = IORESOURCE_MEM,
-       .start          = KIRKWOOD_NAND_MEM_PHYS_BASE,
-       .end            = KIRKWOOD_NAND_MEM_PHYS_BASE +
-                         KIRKWOOD_NAND_MEM_SIZE - 1,
-};
-
-static struct orion_nand_data sheevaplug_nand_data = {
-       .parts          = sheevaplug_nand_parts,
-       .nr_parts       = ARRAY_SIZE(sheevaplug_nand_parts),
-       .cle            = 0,
-       .ale            = 1,
-       .width          = 8,
-       .chip_delay     = 25,
-};
-
-static struct platform_device sheevaplug_nand_flash = {
-       .name           = "orion_nand",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = &sheevaplug_nand_data,
-       },
-       .resource       = &sheevaplug_nand_resource,
-       .num_resources  = 1,
-};
-
 static struct mv643xx_eth_platform_data sheevaplug_ge00_data = {
        .phy_addr       = MV643XX_ETH_PHY_ADDR(0),
 };
@@ -111,6 +83,7 @@ static void __init sheevaplug_init(void)
        kirkwood_mpp_conf(sheevaplug_mpp_config);
 
        kirkwood_uart0_init();
+       kirkwood_nand_init(ARRAY_AND_SIZE(sheevaplug_nand_parts), 25);
 
        if (gpio_request(29, "USB Power Enable") != 0 ||
            gpio_direction_output(29, 1) != 0)
@@ -120,7 +93,6 @@ static void __init sheevaplug_init(void)
        kirkwood_ge00_init(&sheevaplug_ge00_data);
        kirkwood_sdio_init(&sheevaplug_mvsdio_data);
 
-       platform_device_register(&sheevaplug_nand_flash);
        platform_device_register(&sheevaplug_leds);
 }