Skip to content

Commit 6323471

Browse files
Alessandro RubiniDavid Woodhouse
authored andcommitted
mtd: nand: driver for Nomadik 8815 SoC (on NHK8815 board)
Signed-off-by: Alessandro Rubini <rubini@unipv.it> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 6469f54 commit 6323471

File tree

7 files changed

+395
-1
lines changed

7 files changed

+395
-1
lines changed

arch/arm/configs/nhk8815_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ CONFIG_MTD_CFI_I2=y
498498
# CONFIG_MTD_DOC2001PLUS is not set
499499
CONFIG_MTD_NAND=y
500500
CONFIG_MTD_NAND_VERIFY_WRITE=y
501-
# CONFIG_MTD_NAND_ECC_SMC is not set
501+
CONFIG_MTD_NAND_ECC_SMC=y
502502
# CONFIG_MTD_NAND_MUSEUM_IDS is not set
503503
# CONFIG_MTD_NAND_GPIO is not set
504504
CONFIG_MTD_NAND_IDS=y

arch/arm/mach-nomadik/board-nhk8815.c

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,103 @@
1616
#include <linux/amba/bus.h>
1717
#include <linux/interrupt.h>
1818
#include <linux/gpio.h>
19+
#include <linux/mtd/mtd.h>
20+
#include <linux/mtd/nand.h>
21+
#include <linux/mtd/partitions.h>
22+
#include <linux/io.h>
23+
#include <asm/sizes.h>
1924
#include <asm/mach-types.h>
2025
#include <asm/mach/arch.h>
2126
#include <asm/mach/irq.h>
2227
#include <mach/setup.h>
28+
#include <mach/nand.h>
29+
#include <mach/fsmc.h>
2330
#include "clock.h"
2431

32+
/* These adresses span 16MB, so use three individual pages */
33+
static struct resource nhk8815_nand_resources[] = {
34+
{
35+
.name = "nand_addr",
36+
.start = NAND_IO_ADDR,
37+
.end = NAND_IO_ADDR + 0xfff,
38+
.flags = IORESOURCE_MEM,
39+
}, {
40+
.name = "nand_cmd",
41+
.start = NAND_IO_CMD,
42+
.end = NAND_IO_CMD + 0xfff,
43+
.flags = IORESOURCE_MEM,
44+
}, {
45+
.name = "nand_data",
46+
.start = NAND_IO_DATA,
47+
.end = NAND_IO_DATA + 0xfff,
48+
.flags = IORESOURCE_MEM,
49+
}
50+
};
51+
52+
static int nhk8815_nand_init(void)
53+
{
54+
/* FSMC setup for nand chip select (8-bit nand in 8815NHK) */
55+
writel(0x0000000E, FSMC_PCR(0));
56+
writel(0x000D0A00, FSMC_PMEM(0));
57+
writel(0x00100A00, FSMC_PATT(0));
58+
59+
/* enable access to the chip select area */
60+
writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));
61+
62+
return 0;
63+
}
64+
65+
/*
66+
* These partitions are the same as those used in the 2.6.20 release
67+
* shipped by the vendor; the first two partitions are mandated
68+
* by the boot ROM, and the bootloader area is somehow oversized...
69+
*/
70+
static struct mtd_partition nhk8815_partitions[] = {
71+
{
72+
.name = "X-Loader(NAND)",
73+
.offset = 0,
74+
.size = SZ_256K,
75+
}, {
76+
.name = "MemInit(NAND)",
77+
.offset = MTDPART_OFS_APPEND,
78+
.size = SZ_256K,
79+
}, {
80+
.name = "BootLoader(NAND)",
81+
.offset = MTDPART_OFS_APPEND,
82+
.size = SZ_2M,
83+
}, {
84+
.name = "Kernel zImage(NAND)",
85+
.offset = MTDPART_OFS_APPEND,
86+
.size = 3 * SZ_1M,
87+
}, {
88+
.name = "Root Filesystem(NAND)",
89+
.offset = MTDPART_OFS_APPEND,
90+
.size = 22 * SZ_1M,
91+
}, {
92+
.name = "User Filesystem(NAND)",
93+
.offset = MTDPART_OFS_APPEND,
94+
.size = MTDPART_SIZ_FULL,
95+
}
96+
};
97+
98+
static struct nomadik_nand_platform_data nhk8815_nand_data = {
99+
.parts = nhk8815_partitions,
100+
.nparts = ARRAY_SIZE(nhk8815_partitions),
101+
.options = NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING \
102+
| NAND_NO_READRDY | NAND_NO_AUTOINCR,
103+
.init = nhk8815_nand_init,
104+
};
105+
106+
static struct platform_device nhk8815_nand_device = {
107+
.name = "nomadik_nand",
108+
.dev = {
109+
.platform_data = &nhk8815_nand_data,
110+
},
111+
.resource = nhk8815_nand_resources,
112+
.num_resources = ARRAY_SIZE(nhk8815_nand_resources),
113+
};
114+
115+
25116
#define __MEM_4K_RESOURCE(x) \
26117
.res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
27118

@@ -81,6 +172,7 @@ static int __init nhk8815_eth_init(void)
81172
device_initcall(nhk8815_eth_init);
82173

83174
static struct platform_device *nhk8815_platform_devices[] __initdata = {
175+
&nhk8815_nand_device,
84176
&nhk8815_eth_device,
85177
/* will add more devices */
86178
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
/* Definitions for the Nomadik FSMC "Flexible Static Memory controller" */
3+
4+
#ifndef __ASM_ARCH_FSMC_H
5+
#define __ASM_ARCH_FSMC_H
6+
7+
#include <mach/hardware.h>
8+
/*
9+
* Register list
10+
*/
11+
12+
/* bus control reg. and bus timing reg. for CS0..CS3 */
13+
#define FSMC_BCR(x) (NOMADIK_FSMC_VA + (x << 3))
14+
#define FSMC_BTR(x) (NOMADIK_FSMC_VA + (x << 3) + 0x04)
15+
16+
/* PC-card and NAND:
17+
* PCR = control register
18+
* PMEM = memory timing
19+
* PATT = attribute timing
20+
* PIO = I/O timing
21+
* PECCR = ECC result
22+
*/
23+
#define FSMC_PCR(x) (NOMADIK_FSMC_VA + ((2 + x) << 5) + 0x00)
24+
#define FSMC_PMEM(x) (NOMADIK_FSMC_VA + ((2 + x) << 5) + 0x08)
25+
#define FSMC_PATT(x) (NOMADIK_FSMC_VA + ((2 + x) << 5) + 0x0c)
26+
#define FSMC_PIO(x) (NOMADIK_FSMC_VA + ((2 + x) << 5) + 0x10)
27+
#define FSMC_PECCR(x) (NOMADIK_FSMC_VA + ((2 + x) << 5) + 0x14)
28+
29+
#endif /* __ASM_ARCH_FSMC_H */
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef __ASM_ARCH_NAND_H
2+
#define __ASM_ARCH_NAND_H
3+
4+
struct nomadik_nand_platform_data {
5+
struct mtd_partition *parts;
6+
int nparts;
7+
int options;
8+
int (*init) (void);
9+
int (*exit) (void);
10+
};
11+
12+
#define NAND_IO_DATA 0x40000000
13+
#define NAND_IO_CMD 0x40800000
14+
#define NAND_IO_ADDR 0x41000000
15+
16+
#endif /* __ASM_ARCH_NAND_H */

drivers/mtd/nand/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,12 @@ config MTD_NAND_MXC
443443
This enables the driver for the NAND flash controller on the
444444
MXC processors.
445445

446+
config MTD_NAND_NOMADIK
447+
tristate "ST Nomadik 8815 NAND support"
448+
depends on ARCH_NOMADIK
449+
help
450+
Driver for the NAND flash controller on the Nomadik, with ECC.
451+
446452
config MTD_NAND_SH_FLCTL
447453
tristate "Support for NAND on Renesas SuperH FLCTL"
448454
depends on MTD_NAND && SUPERH && CPU_SUBTYPE_SH7723

drivers/mtd/nand/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ obj-$(CONFIG_MTD_NAND_MXC) += mxc_nand.o
4141
obj-$(CONFIG_MTD_NAND_SOCRATES) += socrates_nand.o
4242
obj-$(CONFIG_MTD_NAND_TXX9NDFMC) += txx9ndfmc.o
4343
obj-$(CONFIG_MTD_NAND_W90P910) += w90p910_nand.o
44+
obj-$(CONFIG_MTD_NAND_NOMADIK) += nomadik_nand.o
4445

4546
nand-objs := nand_base.o nand_bbt.o

0 commit comments

Comments
 (0)