]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
Blackfin arch: use the generic platform nand driver to support nand flash on bf53x...
authorMike Frysinger <vapier.adi@gmail.com>
Wed, 25 Jun 2008 03:41:42 +0000 (11:41 +0800)
committerBryan Wu <cooloney@kernel.org>
Wed, 25 Jun 2008 03:41:42 +0000 (11:41 +0800)
Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
arch/blackfin/mach-bf537/boards/stamp.c

index 671f9d67f23a33b34207c965cce9ec53f386345a..7e4b9d95674b33b68ff6157e2ad42286032a1473 100644 (file)
  */
 
 #include <linux/device.h>
+#include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
+#include <linux/mtd/plat-ram.h>
 #include <linux/mtd/physmap.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
@@ -355,6 +358,84 @@ static struct platform_device net2272_bfin_device = {
 };
 #endif
 
+#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
+#ifdef CONFIG_MTD_PARTITIONS
+const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
+
+static struct mtd_partition bfin_plat_nand_partitions[] = {
+       {
+               .name   = "linux kernel",
+               .size   = 0x400000,
+               .offset = 0,
+       }, {
+               .name   = "file system",
+               .size   = MTDPART_SIZ_FULL,
+               .offset = MTDPART_OFS_APPEND,
+       },
+};
+#endif
+
+#define BFIN_NAND_PLAT_CLE 2
+#define BFIN_NAND_PLAT_ALE 1
+static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
+{
+       struct nand_chip *this = mtd->priv;
+
+       if (cmd == NAND_CMD_NONE)
+               return;
+
+       if (ctrl & NAND_CLE)
+               writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_CLE));
+       else
+               writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_ALE));
+}
+
+#define BFIN_NAND_PLAT_READY GPIO_PF3
+static int bfin_plat_nand_dev_ready(struct mtd_info *mtd)
+{
+       return gpio_get_value(BFIN_NAND_PLAT_READY);
+}
+
+static struct platform_nand_data bfin_plat_nand_data = {
+       .chip = {
+               .chip_delay = 30,
+#ifdef CONFIG_MTD_PARTITIONS
+               .part_probe_types = part_probes,
+               .partitions = bfin_plat_nand_partitions,
+               .nr_partitions = ARRAY_SIZE(bfin_plat_nand_partitions),
+#endif
+       },
+       .ctrl = {
+               .cmd_ctrl  = bfin_plat_nand_cmd_ctrl,
+               .dev_ready = bfin_plat_nand_dev_ready,
+       },
+};
+
+#define MAX(x, y) (x > y ? x : y)
+static struct resource bfin_plat_nand_resources = {
+       .start = 0x20212000,
+       .end   = 0x20212000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
+       .flags = IORESOURCE_IO,
+};
+
+static struct platform_device bfin_async_nand_device = {
+       .name = "gen_nand",
+       .id = -1,
+       .num_resources = 1,
+       .resource = &bfin_plat_nand_resources,
+       .dev = {
+               .platform_data = &bfin_plat_nand_data,
+       },
+};
+
+static void bfin_plat_nand_init(void)
+{
+       gpio_request(BFIN_NAND_PLAT_READY, "bfin_nand_plat");
+}
+#else
+static void bfin_plat_nand_init(void) {}
+#endif
+
 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
 static struct mtd_partition stamp_partitions[] = {
        {
@@ -922,6 +1003,10 @@ static struct platform_device *stamp_devices[] __initdata = {
 
        &bfin_gpios_device,
 
+#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
+       &bfin_async_nand_device,
+#endif
+
 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
        &stamp_flash_device,
 #endif
@@ -936,6 +1021,7 @@ static int __init stamp_init(void)
                                ARRAY_SIZE(bfin_i2c_board_info));
 #endif
 
+       bfin_plat_nand_init();
        platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
        spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));