diff options
author | Lennert Buytenhek <buytenh@wantstofly.org> | 2006-04-30 04:36:38 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-04-30 16:19:44 -0400 |
commit | 7d532dd50de1c0cd7d15ba06ad7261e13474fef2 (patch) | |
tree | 8cdf0c7b882524dcda1ae08e10275817b33af364 /drivers/mtd/nand | |
parent | fbbc21c6a491503e55e08e3f7c4629c1337ea1cc (diff) |
ts72xx NAND driver
The TS-72xx is a series of embedded single board computers from
Technologic Systems based on the Cirrus ep93xx (arm920t based) CPU.
The TS-7200 uses NOR flash, while all the other models in the series
(TS-7250, TS-7260) use NAND flash -- included is a driver for the NAND
flash on those boards.
Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/Kconfig | 6 | ||||
-rw-r--r-- | drivers/mtd/nand/Makefile | 1 | ||||
-rw-r--r-- | drivers/mtd/nand/ts7250.c | 208 |
3 files changed, 215 insertions, 0 deletions
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index cfe288a6e853..b735ab61c1e7 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig | |||
@@ -55,6 +55,12 @@ config MTD_NAND_TOTO | |||
55 | help | 55 | help |
56 | Support for NAND flash on Texas Instruments Toto platform. | 56 | Support for NAND flash on Texas Instruments Toto platform. |
57 | 57 | ||
58 | config MTD_NAND_TS7250 | ||
59 | tristate "NAND Flash device on TS-7250 board" | ||
60 | depends on MACH_TS72XX && MTD_NAND | ||
61 | help | ||
62 | Support for NAND flash on Technologic Systems TS-7250 platform. | ||
63 | |||
58 | config MTD_NAND_IDS | 64 | config MTD_NAND_IDS |
59 | tristate | 65 | tristate |
60 | 66 | ||
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 41742026a52e..073705bc8c2d 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile | |||
@@ -17,6 +17,7 @@ obj-$(CONFIG_MTD_NAND_DISKONCHIP) += diskonchip.o | |||
17 | obj-$(CONFIG_MTD_NAND_H1900) += h1910.o | 17 | obj-$(CONFIG_MTD_NAND_H1900) += h1910.o |
18 | obj-$(CONFIG_MTD_NAND_RTC_FROM4) += rtc_from4.o | 18 | obj-$(CONFIG_MTD_NAND_RTC_FROM4) += rtc_from4.o |
19 | obj-$(CONFIG_MTD_NAND_SHARPSL) += sharpsl.o | 19 | obj-$(CONFIG_MTD_NAND_SHARPSL) += sharpsl.o |
20 | obj-$(CONFIG_MTD_NAND_TS7250) += ts7250.o | ||
20 | obj-$(CONFIG_MTD_NAND_NANDSIM) += nandsim.o | 21 | obj-$(CONFIG_MTD_NAND_NANDSIM) += nandsim.o |
21 | 22 | ||
22 | nand-objs = nand_base.o nand_bbt.o | 23 | nand-objs = nand_base.o nand_bbt.o |
diff --git a/drivers/mtd/nand/ts7250.c b/drivers/mtd/nand/ts7250.c new file mode 100644 index 000000000000..643633d91a8b --- /dev/null +++ b/drivers/mtd/nand/ts7250.c | |||
@@ -0,0 +1,208 @@ | |||
1 | /* | ||
2 | * drivers/mtd/nand/ts7250.c | ||
3 | * | ||
4 | * Copyright (C) 2004 Technologic Systems (support@embeddedARM.com) | ||
5 | * | ||
6 | * Derived from drivers/mtd/nand/edb7312.c | ||
7 | * Copyright (C) 2004 Marius Gröger (mag@sysgo.de) | ||
8 | * | ||
9 | * Derived from drivers/mtd/nand/autcpu12.c | ||
10 | * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) | ||
11 | * | ||
12 | * $Id: ts7250.c,v 1.4 2004/12/30 22:02:07 joff Exp $ | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | * | ||
18 | * Overview: | ||
19 | * This is a device driver for the NAND flash device found on the | ||
20 | * TS-7250 board which utilizes a Samsung 32 Mbyte part. | ||
21 | */ | ||
22 | |||
23 | #include <linux/slab.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/mtd/mtd.h> | ||
27 | #include <linux/mtd/nand.h> | ||
28 | #include <linux/mtd/partitions.h> | ||
29 | #include <asm/io.h> | ||
30 | #include <asm/arch/hardware.h> | ||
31 | #include <asm/sizes.h> | ||
32 | #include <asm/mach-types.h> | ||
33 | |||
34 | /* | ||
35 | * MTD structure for TS7250 board | ||
36 | */ | ||
37 | static struct mtd_info *ts7250_mtd = NULL; | ||
38 | |||
39 | #ifdef CONFIG_MTD_PARTITIONS | ||
40 | static const char *part_probes[] = { "cmdlinepart", NULL }; | ||
41 | |||
42 | #define NUM_PARTITIONS 3 | ||
43 | |||
44 | /* | ||
45 | * Define static partitions for flash device | ||
46 | */ | ||
47 | static struct mtd_partition partition_info32[] = { | ||
48 | { | ||
49 | .name = "TS-BOOTROM", | ||
50 | .offset = 0x00000000, | ||
51 | .size = 0x00004000, | ||
52 | }, { | ||
53 | .name = "Linux", | ||
54 | .offset = 0x00004000, | ||
55 | .size = 0x01d00000, | ||
56 | }, { | ||
57 | .name = "RedBoot", | ||
58 | .offset = 0x01d04000, | ||
59 | .size = 0x002fc000, | ||
60 | }, | ||
61 | }; | ||
62 | |||
63 | /* | ||
64 | * Define static partitions for flash device | ||
65 | */ | ||
66 | static struct mtd_partition partition_info128[] = { | ||
67 | { | ||
68 | .name = "TS-BOOTROM", | ||
69 | .offset = 0x00000000, | ||
70 | .size = 0x00004000, | ||
71 | }, { | ||
72 | .name = "Linux", | ||
73 | .offset = 0x00004000, | ||
74 | .size = 0x07d00000, | ||
75 | }, { | ||
76 | .name = "RedBoot", | ||
77 | .offset = 0x07d04000, | ||
78 | .size = 0x002fc000, | ||
79 | }, | ||
80 | }; | ||
81 | #endif | ||
82 | |||
83 | |||
84 | /* | ||
85 | * hardware specific access to control-lines | ||
86 | */ | ||
87 | static void ts7250_hwcontrol(struct mtd_info *mtd, int cmd) | ||
88 | { | ||
89 | unsigned long ctrl = TS72XX_NAND_CONTROL_VIRT_BASE; | ||
90 | |||
91 | switch(cmd) { | ||
92 | case NAND_CTL_SETCLE: | ||
93 | __raw_writeb(__raw_readb(ctrl) | 0x2, ctrl); | ||
94 | break; | ||
95 | case NAND_CTL_CLRCLE: | ||
96 | __raw_writeb(__raw_readb(ctrl) & ~0x2, ctrl); | ||
97 | break; | ||
98 | case NAND_CTL_SETALE: | ||
99 | __raw_writeb(__raw_readb(ctrl) | 0x1, ctrl); | ||
100 | break; | ||
101 | case NAND_CTL_CLRALE: | ||
102 | __raw_writeb(__raw_readb(ctrl) & ~0x1, ctrl); | ||
103 | break; | ||
104 | case NAND_CTL_SETNCE: | ||
105 | __raw_writeb(__raw_readb(ctrl) | 0x4, ctrl); | ||
106 | break; | ||
107 | case NAND_CTL_CLRNCE: | ||
108 | __raw_writeb(__raw_readb(ctrl) & ~0x4, ctrl); | ||
109 | break; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | /* | ||
114 | * read device ready pin | ||
115 | */ | ||
116 | static int ts7250_device_ready(struct mtd_info *mtd) | ||
117 | { | ||
118 | return __raw_readb(TS72XX_NAND_BUSY_VIRT_BASE) & 0x20; | ||
119 | } | ||
120 | |||
121 | /* | ||
122 | * Main initialization routine | ||
123 | */ | ||
124 | static int __init ts7250_init(void) | ||
125 | { | ||
126 | struct nand_chip *this; | ||
127 | const char *part_type = 0; | ||
128 | int mtd_parts_nb = 0; | ||
129 | struct mtd_partition *mtd_parts = 0; | ||
130 | |||
131 | if (!machine_is_ts72xx() || board_is_ts7200()) | ||
132 | return -ENXIO; | ||
133 | |||
134 | /* Allocate memory for MTD device structure and private data */ | ||
135 | ts7250_mtd = kmalloc(sizeof(struct mtd_info) + | ||
136 | sizeof(struct nand_chip), GFP_KERNEL); | ||
137 | if (!ts7250_mtd) { | ||
138 | printk("Unable to allocate TS7250 NAND MTD device structure.\n"); | ||
139 | return -ENOMEM; | ||
140 | } | ||
141 | |||
142 | /* Get pointer to private data */ | ||
143 | this = (struct nand_chip *)(&ts7250_mtd[1]); | ||
144 | |||
145 | /* Initialize structures */ | ||
146 | memset(ts7250_mtd, 0, sizeof(struct mtd_info)); | ||
147 | memset(this, 0, sizeof(struct nand_chip)); | ||
148 | |||
149 | /* Link the private data with the MTD structure */ | ||
150 | ts7250_mtd->priv = this; | ||
151 | |||
152 | /* insert callbacks */ | ||
153 | this->IO_ADDR_R = (void *)TS72XX_NAND_DATA_VIRT_BASE; | ||
154 | this->IO_ADDR_W = (void *)TS72XX_NAND_DATA_VIRT_BASE; | ||
155 | this->hwcontrol = ts7250_hwcontrol; | ||
156 | this->dev_ready = ts7250_device_ready; | ||
157 | this->chip_delay = 15; | ||
158 | this->eccmode = NAND_ECC_SOFT; | ||
159 | |||
160 | printk("Searching for NAND flash...\n"); | ||
161 | /* Scan to find existence of the device */ | ||
162 | if (nand_scan(ts7250_mtd, 1)) { | ||
163 | kfree(ts7250_mtd); | ||
164 | return -ENXIO; | ||
165 | } | ||
166 | |||
167 | #ifdef CONFIG_MTD_PARTITIONS | ||
168 | ts7250_mtd->name = "ts7250-nand"; | ||
169 | mtd_parts_nb = parse_mtd_partitions(ts7250_mtd, part_probes, | ||
170 | &mtd_parts, 0); | ||
171 | if (mtd_parts_nb > 0) | ||
172 | part_type = "command line"; | ||
173 | else | ||
174 | mtd_parts_nb = 0; | ||
175 | #endif | ||
176 | if (mtd_parts_nb == 0) { | ||
177 | mtd_parts = partition_info32; | ||
178 | if (ts7250_mtd->size >= (128 * 0x100000)) | ||
179 | mtd_parts = partition_info128; | ||
180 | mtd_parts_nb = NUM_PARTITIONS; | ||
181 | part_type = "static"; | ||
182 | } | ||
183 | |||
184 | /* Register the partitions */ | ||
185 | printk(KERN_NOTICE "Using %s partition definition\n", part_type); | ||
186 | add_mtd_partitions(ts7250_mtd, mtd_parts, mtd_parts_nb); | ||
187 | |||
188 | /* Return happy */ | ||
189 | return 0; | ||
190 | } | ||
191 | module_init(ts7250_init); | ||
192 | |||
193 | /* | ||
194 | * Clean up routine | ||
195 | */ | ||
196 | static void __exit ts7250_cleanup(void) | ||
197 | { | ||
198 | /* Unregister the device */ | ||
199 | del_mtd_device(ts7250_mtd); | ||
200 | |||
201 | /* Free the MTD device structure */ | ||
202 | kfree(ts7250_mtd); | ||
203 | } | ||
204 | module_exit(ts7250_cleanup); | ||
205 | |||
206 | MODULE_LICENSE("GPL"); | ||
207 | MODULE_AUTHOR("Jesse Off <joff@embeddedARM.com>"); | ||
208 | MODULE_DESCRIPTION("MTD map driver for Technologic Systems TS-7250 board"); | ||