2 * PIKA Warp(tm) NAND flash specific routines
4 * Copyright (c) 2008 PIKA Technologies
5 * Sean MacLennan <smaclennan@pikatech.com>
8 #include <linux/platform_device.h>
9 #include <linux/mtd/mtd.h>
10 #include <linux/mtd/map.h>
11 #include <linux/mtd/partitions.h>
12 #include <linux/mtd/nand.h>
13 #include <linux/mtd/ndfc.h>
15 #include <asm/machdep.h>
18 #ifdef CONFIG_MTD_NAND_NDFC
20 #define CS_NAND_0 1 /* use chip select 1 for NAND device 0 */
22 #define WARP_NAND_FLASH_REG_ADDR 0xD0000000UL
23 #define WARP_NAND_FLASH_REG_SIZE 0x2000
25 static struct resource warp_ndfc = {
26 .start = WARP_NAND_FLASH_REG_ADDR,
27 .end = WARP_NAND_FLASH_REG_ADDR + WARP_NAND_FLASH_REG_SIZE,
28 .flags = IORESOURCE_MEM,
31 static struct mtd_partition nand_parts[] = {
48 .name = "persistent1",
53 .name = "persistent2",
59 struct ndfc_controller_settings warp_ndfc_settings = {
60 .ccr_settings = (NDFC_CCR_BS(CS_NAND_0) | NDFC_CCR_ARAC1),
64 static struct ndfc_chip_settings warp_chip0_settings = {
65 .bank_settings = 0x80002222,
68 struct platform_nand_ctrl warp_nand_ctrl = {
69 .priv = &warp_ndfc_settings,
72 static struct platform_device warp_ndfc_device = {
76 .platform_data = &warp_nand_ctrl,
79 .resource = &warp_ndfc,
82 /* Do NOT set the ecclayout: let it default so it is correct for both
83 * 64M and 256M flash chips.
85 static struct platform_nand_chip warp_nand_chip0 = {
87 .chip_offset = CS_NAND_0,
88 .nr_partitions = ARRAY_SIZE(nand_parts),
89 .partitions = nand_parts,
91 .priv = &warp_chip0_settings,
94 static struct platform_device warp_nand_device = {
98 .resource = &warp_ndfc,
100 .platform_data = &warp_nand_chip0,
101 .parent = &warp_ndfc_device.dev,
105 static int warp_setup_nand_flash(void)
107 struct device_node *np;
109 /* Try to detect a rev A based on NOR size. */
110 np = of_find_compatible_node(NULL, NULL, "cfi-flash");
114 pp = of_find_property(np, "reg", NULL);
115 if (pp && (pp->length == 12)) {
117 if (v[2] == 0x4000000)
118 /* Rev A = 64M NAND */
119 warp_nand_chip0.nr_partitions = 2;
124 platform_device_register(&warp_ndfc_device);
125 platform_device_register(&warp_nand_device);
129 machine_device_initcall(warp, warp_setup_nand_flash);