Skip to contentSkip to conversation

Nand driver for Nomadik 8815 SoC (on NHK8815 board)

PATCH In review Alessandro Rubini 2 participants 4 messages Apr 22, 2009 – Apr 24, 2009 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 4/6 Nand driver for Nomadik 8815 SoC (on NHK8815 board)

From: Alessandro Rubini <[email protected]>

The patch is incremental over base Nomadik support as posted to linux-arm-kernel.

---

This and one-nand are Cc: to the mtd list, the other patches have been sent only to linux-arm-kernel.

 arch/arm/configs/nhk15_defconfig              |    1 +
 arch/arm/mach-nomadik/board-8815nhk.c         |   98 ++++++++-
 arch/arm/mach-nomadik/include/mach/fsmc.h     |   29 +++
 arch/arm/mach-nomadik/include/mach/hardware.h |    5 +-
 arch/arm/mach-nomadik/include/mach/nand.h     |   16 ++
 drivers/mtd/nand/Kconfig                      |    6 +
 drivers/mtd/nand/Makefile                     |    1 +
 drivers/mtd/nand/nomadik_nand.c               |  329 +++++++++++++++++++++++++
 8 files changed, 482 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-nomadik/include/mach/fsmc.h
 create mode 100644 arch/arm/mach-nomadik/include/mach/nand.h
 create mode 100644 drivers/mtd/nand/nomadik_nand.c
arch/arm/configs/nhk15_defconfig +1 -0
index cf11d79..1697efe 100644
@@ -476,6 +476,7 @@ CONFIG_MTD_NAND_IDS=y
 # CONFIG_MTD_NAND_DISKONCHIP is not set
 # CONFIG_MTD_NAND_NANDSIM is not set
 # CONFIG_MTD_NAND_PLATFORM is not set
+CONFIG_MTD_NAND_NOMADIK=y
 # CONFIG_MTD_ONENAND is not set
 
 #
arch/arm/mach-nomadik/board-8815nhk.c +97 -1

116 lines not on this page · raw message

arch/arm/mach-nomadik/include/mach/fsmc.h new file +29 -0
new file mode 100644
index 0000000..8c2c051
@@ -0,0 +1,29 @@
+
+/* Definitions for the Nomadik FSMC "Flexible Static Memory controller" */
+
+#ifndef __ASM_ARCH_FSMC_H
+#define __ASM_ARCH_FSMC_H
+
+#include <mach/hardware.h>
+/*
+ * Register list
+ */
+
+/* bus control reg. and bus timing reg. for CS0..CS3 */
+#define FSMC_BCR(x)     (NOMADIK_FSMC_VA + (x << 3))
+#define FSMC_BTR(x)     (NOMADIK_FSMC_VA + (x << 3) + 0x04)
+
+/* PC-card and NAND:
+ * PCR = control register
+ * PMEM = memory timing
+ * PATT = attribute timing
+ * PIO = I/O timing
+ * PECCR = ECC result
+ */
+#define FSMC_PCR(x)     (NOMADIK_FSMC_VA + ((2 + x) << 5) + 0x00)
+#define FSMC_PMEM(x)    (NOMADIK_FSMC_VA + ((2 + x) << 5) + 0x08)
+#define FSMC_PATT(x)    (NOMADIK_FSMC_VA + ((2 + x) << 5) + 0x0c)
+#define FSMC_PIO(x)     (NOMADIK_FSMC_VA + ((2 + x) << 5) + 0x10)
+#define FSMC_PECCR(x)   (NOMADIK_FSMC_VA + ((2 + x) << 5) + 0x14)
+
+#endif /* __ASM_ARCH_FSMC_H */
arch/arm/mach-nomadik/include/mach/hardware.h +3 -2
index 8cdee9b..05ea93b 100644
@@ -82,7 +82,8 @@
 #define NOMADIK_HAMACA_DMEM	0xA0200000	/* HAMACA Data Memory Space */
 
 
-#define NOMADIK_MTU0_VA (IO_ADDRESS(NOMADIK_MTU0_BASE))
-#define NOMADIK_MTU1_VA (IO_ADDRESS(NOMADIK_MTU1_BASE))
+#define NOMADIK_FSMC_VA		IO_ADDRESS(NOMADIK_FSMC_BASE)
+#define NOMADIK_MTU0_VA		IO_ADDRESS(NOMADIK_MTU0_BASE)
+#define NOMADIK_MTU1_VA		IO_ADDRESS(NOMADIK_MTU1_BASE)
 
 #endif /* __ASM_ARCH_HARDWARE_H */
arch/arm/mach-nomadik/include/mach/nand.h new file +16 -0
new file mode 100644
index 0000000..c3c8254
@@ -0,0 +1,16 @@
+#ifndef __ASM_ARCH_NAND_H
+#define __ASM_ARCH_NAND_H
+
+struct nomadik_nand_platform_data {
+	struct mtd_partition *parts;
+	int nparts;
+	int options;
+	int (*init) (void);
+	int (*exit) (void);
+};
+
+#define NAND_IO_DATA	0x40000000
+#define NAND_IO_CMD	0x40800000
+#define NAND_IO_ADDR	0x41000000
+
+#endif				/* __ASM_ARCH_NAND_H */
drivers/mtd/nand/Kconfig +6 -0
index 890936d..61d60fd 100644
@@ -420,6 +420,12 @@ config MTD_NAND_MXC
 	  This enables the driver for the NAND flash controller on the
 	  MXC processors.
 
+config MTD_NAND_NOMADIK
+	tristate "ST Nomadik 8815 NAND support"
+	depends on ARCH_NOMADIK
+	help
+	  Driver for the NAND flash controller on the Nomadik, with ECC.
+
 config MTD_NAND_SH_FLCTL
 	tristate "Support for NAND on Renesas SuperH FLCTL"
 	depends on MTD_NAND && SUPERH && CPU_SUBTYPE_SH7723
drivers/mtd/nand/Makefile +1 -0
index d33860a..404e9c6 100644
@@ -39,5 +39,6 @@ obj-$(CONFIG_MTD_NAND_SH_FLCTL)		+= sh_flctl.o
 obj-$(CONFIG_MTD_NAND_MXC)		+= mxc_nand.o
 obj-$(CONFIG_MTD_NAND_SOCRATES)		+= socrates_nand.o
 obj-$(CONFIG_MTD_NAND_TXX9NDFMC)	+= txx9ndfmc.o
+obj-$(CONFIG_MTD_NAND_NOMADIK)		+= nomadik_nand.o
 
 nand-objs := nand_base.o nand_bbt.o
drivers/mtd/nand/nomadik_nand.c new file +329 -0

329 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#2 lore raw
Quoted 71 lines · Alessandro Rubini

From: Alessandro Rubini <[email protected]>

The patch is incremental over base Nomadik support as posted to linux-arm-kernel.

---

This and one-nand are Cc: to the mtd list, the other patches have been sent only to linux-arm-kernel.

 arch/arm/configs/nhk15_defconfig              |    1 +
 arch/arm/mach-nomadik/board-8815nhk.c         |   98 ++++++++-
 arch/arm/mach-nomadik/include/mach/fsmc.h     |   29 +++
 arch/arm/mach-nomadik/include/mach/hardware.h |    5 +-
 arch/arm/mach-nomadik/include/mach/nand.h     |   16 ++
 drivers/mtd/nand/Kconfig                      |    6 +
 drivers/mtd/nand/Makefile                     |    1 +
 drivers/mtd/nand/nomadik_nand.c               |  329 +++++++++++++++++++++++++
 8 files changed, 482 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-nomadik/include/mach/fsmc.h
 create mode 100644 arch/arm/mach-nomadik/include/mach/nand.h
 create mode 100644 drivers/mtd/nand/nomadik_nand.c
arch/arm/configs/nhk15_defconfig +1 -0
index cf11d79..1697efe 100644
@@ -476,6 +476,7 @@ CONFIG_MTD_NAND_IDS=y
 # CONFIG_MTD_NAND_DISKONCHIP is not set
 # CONFIG_MTD_NAND_NANDSIM is not set
 # CONFIG_MTD_NAND_PLATFORM is not set
+CONFIG_MTD_NAND_NOMADIK=y
 # CONFIG_MTD_ONENAND is not set
 
 #
arch/arm/mach-nomadik/board-8815nhk.c +20 -0
index d6483bf..b7be6c2 100644
@@ -19,12 +19,107 @@
 #include <linux/io.h>
 #include <linux/param.h>
 #include <asm/setup.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/partitions.h>
+#include <asm/sizes.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
 
 #include <mach/hardware.h>
 #include <mach/setup.h>
+#include <mach/nand.h>
+#include <mach/fsmc.h>
+
+/* These adresses span 16MB, so use three individual pages */
+static struct resource nhk8815_nand_resources[] = {
+	{
+		.name = "nand_addr",
+		.start = NAND_IO_ADDR,
+		.end = NAND_IO_ADDR + 0xfff,
+		.flags = IORESOURCE_MEM,
+	}, {
+		.name = "nand_cmd",
+		.start = NAND_IO_CMD,
+		.end = NAND_IO_CMD + 0xfff,
+		.flags = IORESOURCE_MEM,
+	}, {

arch/arm/mach-nomadik/board-8815nhk.c line 57

Quoted 10 lines
arch/arm/mach-nomadik/board-8815nhk.c +10 -0
+		.name = "nand_data",
+		.start = NAND_IO_DATA,
+		.end = NAND_IO_DATA + 0xfff,
+		.flags = IORESOURCE_MEM,
+	}
+};
+
+static int nhk8815_nand_init(void)
+{
+	/* FSMC setup for nand chip select (8-bit nand in 8815NHK) */

use macro to generate these FSMC will make ore readable and easier to update

arch/arm/mach-nomadik/board-8815nhk.c line 61

Quoted 4 lines
arch/arm/mach-nomadik/board-8815nhk.c +4 -0
+	writel(0x0000000E, FSMC_PCR(0));
+	writel(0x000D0A00, FSMC_PMEM(0));
+	writel(0x00100A00, FSMC_PATT(0));
+

otherwise looks fine

Best Regards,
J.

#3 lore raw

PATCH 5/6 OneNand driver for Nomadik 8815 SoC (on NHK8815 board)

In reply to a message not in the archive

From: Alessandro Rubini <[email protected]>

Add the platform_device and the configuration used to activate the OneNand device found on the NHK8815 evaluation kit.

---

This and one-nand are Cc: to the mtd list, the other patches have been sent only to linux-arm-kernel.

 arch/arm/configs/nhk15_defconfig      |    9 +++-
 arch/arm/mach-nomadik/board-8815nhk.c |   67 +++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 2 deletions(-)
arch/arm/configs/nhk15_defconfig +7 -2
index 1697efe..ea99b34 100644
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.29-rc7
-# Thu Mar 12 00:30:32 2009
+# Fri Mar 13 00:06:15 2009
 #
 CONFIG_ARM=y
 CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -477,7 +477,12 @@ CONFIG_MTD_NAND_IDS=y
 # CONFIG_MTD_NAND_NANDSIM is not set
 # CONFIG_MTD_NAND_PLATFORM is not set
 CONFIG_MTD_NAND_NOMADIK=y
-# CONFIG_MTD_ONENAND is not set
+CONFIG_MTD_ONENAND=y
+CONFIG_MTD_ONENAND_VERIFY_WRITE=y
+CONFIG_MTD_ONENAND_GENERIC=y
+# CONFIG_MTD_ONENAND_OTP is not set
+# CONFIG_MTD_ONENAND_2X_PROGRAM is not set
+# CONFIG_MTD_ONENAND_SIM is not set
 
 #
 # LPDDR flash memory drivers
arch/arm/mach-nomadik/board-8815nhk.c +67 -0

91 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#4 lore raw

Re: [PATCH 5/6] OneNand driver for Nomadik 8815 SoC (on NHK8815 board)

Quoted 4 lines · Alessandro Rubini

From: Alessandro Rubini <[email protected]>

Add the platform_device and the configuration used to activate the OneNand device found on the NHK8815 evaluation kit.

it will be nice to known on which one you boot at runtime

Quoted 17 lines

---

This and one-nand are Cc: to the mtd list, the other patches have been sent only to linux-arm-kernel.

arch/arm/mach-nomadik/board-8815nhk.c +9 -0
+	},
+};
+
+static struct platform_device nhk8815_onenand_device = {
+	.name		= "onenand",
+	.id		= -1,
+	.dev		= {
+		.platform_data	= &nhk8815_onenand_data,
+	},

arch/arm/mach-nomadik/board-8815nhk.c static struct platform_device nhk8815_nand_device = { · line 185

Quoted 10 lines
arch/arm/mach-nomadik/board-8815nhk.c +10 -0
+	.resource	= nhk8815_onenand_resource,
+	.num_resources	= ARRAY_SIZE(nhk8815_onenand_resource),
+};
+
+static void __init nhk8815_onenand_init(void)
+{
+#ifdef CONFIG_ONENAND
+       /* Set up SMCS0 for OneNand */
+       writel(0x000030db, FSMC_BCR0);
+       writel(0x02100551, FSMC_BTR0);

same as nand it will be better, more readable and easier to maintain to use macro to generate these SMCSx config instead hard code value

otherwise looks fine

Best Regards,
J.