blob: 512acfc89012ca962915e870f0a0957c0e1f41ec [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* linux/drivers/mtd/nand/s3c2410.c
2 *
Ben Dooksa4f957f2005-06-20 12:48:25 +01003 * Copyright (c) 2004,2005 Simtec Electronics
Ben Dooksfdf2fd52005-02-18 14:46:15 +00004 * http://www.simtec.co.uk/products/SWLINUX/
5 * Ben Dooks <ben@simtec.co.uk>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
Ben Dooksa4f957f2005-06-20 12:48:25 +01007 * Samsung S3C2410/S3C240 NAND driver
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 * Changelog:
10 * 21-Sep-2004 BJD Initial version
11 * 23-Sep-2004 BJD Mulitple device support
12 * 28-Sep-2004 BJD Fixed ECC placement for Hardware mode
13 * 12-Oct-2004 BJD Fixed errors in use of platform data
Ben Dooks3e4ef3b2005-03-17 11:31:30 +000014 * 18-Feb-2005 BJD Fix sparse errors
15 * 14-Mar-2005 BJD Applied tglx's code reduction patch
Ben Dooksa4f957f2005-06-20 12:48:25 +010016 * 02-May-2005 BJD Fixed s3c2440 support
17 * 02-May-2005 BJD Reduced hwcontrol decode
18 * 20-Jun-2005 BJD Updated s3c2440 support, fixed timing bug
Ben Dooksfb8d82a2005-07-06 21:05:10 +010019 * 08-Jul-2005 BJD Fix OOPS when no platform data supplied
Ben Dookscfd320f2005-10-20 22:22:58 +010020 * 20-Oct-2005 BJD Fix timing calculation bug
Ben Dooksd1fef3c2006-06-19 09:29:38 +010021 * 14-Jan-2006 BJD Allow clock to be stopped when idle
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 *
Ben Dooksd1fef3c2006-06-19 09:29:38 +010023 * $Id: s3c2410.c,v 1.23 2006/04/01 18:06:29 bjd Exp $
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 *
25 * This program is free software; you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation; either version 2 of the License, or
28 * (at your option) any later version.
29 *
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
34 *
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, write to the Free Software
37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38*/
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#ifdef CONFIG_MTD_NAND_S3C2410_DEBUG
41#define DEBUG
42#endif
43
44#include <linux/module.h>
45#include <linux/types.h>
46#include <linux/init.h>
47#include <linux/kernel.h>
48#include <linux/string.h>
49#include <linux/ioport.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010050#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <linux/delay.h>
52#include <linux/err.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -080053#include <linux/slab.h>
Russell Kingf8ce2542006-01-07 16:15:52 +000054#include <linux/clk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56#include <linux/mtd/mtd.h>
57#include <linux/mtd/nand.h>
58#include <linux/mtd/nand_ecc.h>
59#include <linux/mtd/partitions.h>
60
61#include <asm/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Ben Dooksb7a70182007-07-24 13:37:27 +010063#include <asm/plat-s3c/regs-nand.h>
64#include <asm/plat-s3c/nand.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#ifdef CONFIG_MTD_NAND_S3C2410_HWECC
67static int hardware_ecc = 1;
68#else
69static int hardware_ecc = 0;
70#endif
71
Ben Dooksd1fef3c2006-06-19 09:29:38 +010072#ifdef CONFIG_MTD_NAND_S3C2410_CLKSTOP
73static int clock_stop = 1;
74#else
75static const int clock_stop = 0;
76#endif
77
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079/* new oob placement block for use with hardware ecc generation
80 */
81
Thomas Gleixner5bd34c02006-05-27 22:16:10 +020082static struct nand_ecclayout nand_hw_eccoob = {
David Woodhousee0c7d762006-05-13 18:07:53 +010083 .eccbytes = 3,
84 .eccpos = {0, 1, 2},
85 .oobfree = {{8, 8}}
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
88/* controller and mtd information */
89
90struct s3c2410_nand_info;
91
92struct s3c2410_nand_mtd {
93 struct mtd_info mtd;
94 struct nand_chip chip;
95 struct s3c2410_nand_set *set;
96 struct s3c2410_nand_info *info;
97 int scan_res;
98};
99
Ben Dooks2c06a082006-06-27 14:35:46 +0100100enum s3c_cpu_type {
101 TYPE_S3C2410,
102 TYPE_S3C2412,
103 TYPE_S3C2440,
104};
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106/* overview of the s3c2410 nand state */
107
108struct s3c2410_nand_info {
109 /* mtd info */
110 struct nand_hw_control controller;
111 struct s3c2410_nand_mtd *mtds;
112 struct s3c2410_platform_nand *platform;
113
114 /* device info */
115 struct device *device;
116 struct resource *area;
117 struct clk *clk;
Ben Dooksfdf2fd52005-02-18 14:46:15 +0000118 void __iomem *regs;
Ben Dooks2c06a082006-06-27 14:35:46 +0100119 void __iomem *sel_reg;
120 int sel_bit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 int mtd_count;
Ben Dooksa4f957f2005-06-20 12:48:25 +0100122
Ben Dooks03680b12007-11-19 23:28:07 +0000123 unsigned long save_nfconf;
124
Ben Dooks2c06a082006-06-27 14:35:46 +0100125 enum s3c_cpu_type cpu_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126};
127
128/* conversion functions */
129
130static struct s3c2410_nand_mtd *s3c2410_nand_mtd_toours(struct mtd_info *mtd)
131{
132 return container_of(mtd, struct s3c2410_nand_mtd, mtd);
133}
134
135static struct s3c2410_nand_info *s3c2410_nand_mtd_toinfo(struct mtd_info *mtd)
136{
137 return s3c2410_nand_mtd_toours(mtd)->info;
138}
139
Russell King3ae5eae2005-11-09 22:32:44 +0000140static struct s3c2410_nand_info *to_nand_info(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141{
Russell King3ae5eae2005-11-09 22:32:44 +0000142 return platform_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143}
144
Russell King3ae5eae2005-11-09 22:32:44 +0000145static struct s3c2410_platform_nand *to_nand_plat(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146{
Russell King3ae5eae2005-11-09 22:32:44 +0000147 return dev->dev.platform_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148}
149
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100150static inline int allow_clk_stop(struct s3c2410_nand_info *info)
151{
152 return clock_stop;
153}
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155/* timing calculations */
156
Ben Dookscfd320f2005-10-20 22:22:58 +0100157#define NS_IN_KHZ 1000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
Ben Dooks2c06a082006-06-27 14:35:46 +0100159static int s3c_nand_calc_rate(int wanted, unsigned long clk, int max)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160{
161 int result;
162
Ben Dookscfd320f2005-10-20 22:22:58 +0100163 result = (wanted * clk) / NS_IN_KHZ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 result++;
165
166 pr_debug("result %d from %ld, %d\n", result, clk, wanted);
167
168 if (result > max) {
David Woodhousee0c7d762006-05-13 18:07:53 +0100169 printk("%d ns is too big for current clock rate %ld\n", wanted, clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 return -1;
171 }
172
173 if (result < 1)
174 result = 1;
175
176 return result;
177}
178
Ben Dookscfd320f2005-10-20 22:22:58 +0100179#define to_ns(ticks,clk) (((ticks) * NS_IN_KHZ) / (unsigned int)(clk))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
181/* controller setup */
182
Ben Dooks2c06a082006-06-27 14:35:46 +0100183static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
184 struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185{
Russell King3ae5eae2005-11-09 22:32:44 +0000186 struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 unsigned long clkrate = clk_get_rate(info->clk);
Ben Dooks2c06a082006-06-27 14:35:46 +0100188 int tacls_max = (info->cpu_type == TYPE_S3C2412) ? 8 : 4;
Ben Dookscfd320f2005-10-20 22:22:58 +0100189 int tacls, twrph0, twrph1;
Ben Dooks2c06a082006-06-27 14:35:46 +0100190 unsigned long cfg = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
192 /* calculate the timing information for the controller */
193
Ben Dookscfd320f2005-10-20 22:22:58 +0100194 clkrate /= 1000; /* turn clock into kHz for ease of use */
195
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 if (plat != NULL) {
Ben Dooks2c06a082006-06-27 14:35:46 +0100197 tacls = s3c_nand_calc_rate(plat->tacls, clkrate, tacls_max);
198 twrph0 = s3c_nand_calc_rate(plat->twrph0, clkrate, 8);
199 twrph1 = s3c_nand_calc_rate(plat->twrph1, clkrate, 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 } else {
201 /* default timings */
Ben Dooks2c06a082006-06-27 14:35:46 +0100202 tacls = tacls_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 twrph0 = 8;
204 twrph1 = 8;
205 }
Thomas Gleixner61b03bd2005-11-07 11:15:49 +0000206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 if (tacls < 0 || twrph0 < 0 || twrph1 < 0) {
Ben Dooks99974c62006-06-21 15:43:05 +0100208 dev_err(info->device, "cannot get suitable timings\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 return -EINVAL;
210 }
211
Ben Dooks99974c62006-06-21 15:43:05 +0100212 dev_info(info->device, "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n",
David Woodhousee0c7d762006-05-13 18:07:53 +0100213 tacls, to_ns(tacls, clkrate), twrph0, to_ns(twrph0, clkrate), twrph1, to_ns(twrph1, clkrate));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
Ben Dooks2c06a082006-06-27 14:35:46 +0100215 switch (info->cpu_type) {
216 case TYPE_S3C2410:
David Woodhousee0c7d762006-05-13 18:07:53 +0100217 cfg = S3C2410_NFCONF_EN;
218 cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
219 cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
220 cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
Ben Dooks2c06a082006-06-27 14:35:46 +0100221 break;
222
223 case TYPE_S3C2440:
224 case TYPE_S3C2412:
David Woodhousee0c7d762006-05-13 18:07:53 +0100225 cfg = S3C2440_NFCONF_TACLS(tacls - 1);
226 cfg |= S3C2440_NFCONF_TWRPH0(twrph0 - 1);
227 cfg |= S3C2440_NFCONF_TWRPH1(twrph1 - 1);
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100228
229 /* enable the controller and de-assert nFCE */
230
Ben Dooks2c06a082006-06-27 14:35:46 +0100231 writel(S3C2440_NFCONT_ENABLE, info->regs + S3C2440_NFCONT);
Ben Dooksa4f957f2005-06-20 12:48:25 +0100232 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
Ben Dooks99974c62006-06-21 15:43:05 +0100234 dev_dbg(info->device, "NF_CONF is 0x%lx\n", cfg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
236 writel(cfg, info->regs + S3C2410_NFCONF);
237 return 0;
238}
239
240/* select chip */
241
242static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip)
243{
244 struct s3c2410_nand_info *info;
Thomas Gleixner61b03bd2005-11-07 11:15:49 +0000245 struct s3c2410_nand_mtd *nmtd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 struct nand_chip *this = mtd->priv;
247 unsigned long cur;
248
249 nmtd = this->priv;
250 info = nmtd->info;
251
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100252 if (chip != -1 && allow_clk_stop(info))
253 clk_enable(info->clk);
254
Ben Dooks2c06a082006-06-27 14:35:46 +0100255 cur = readl(info->sel_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
257 if (chip == -1) {
Ben Dooks2c06a082006-06-27 14:35:46 +0100258 cur |= info->sel_bit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 } else {
Ben Dooksfb8d82a2005-07-06 21:05:10 +0100260 if (nmtd->set != NULL && chip > nmtd->set->nr_chips) {
Ben Dooks99974c62006-06-21 15:43:05 +0100261 dev_err(info->device, "invalid chip %d\n", chip);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 return;
263 }
264
265 if (info->platform != NULL) {
266 if (info->platform->select_chip != NULL)
David Woodhousee0c7d762006-05-13 18:07:53 +0100267 (info->platform->select_chip) (nmtd->set, chip);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 }
269
Ben Dooks2c06a082006-06-27 14:35:46 +0100270 cur &= ~info->sel_bit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 }
272
Ben Dooks2c06a082006-06-27 14:35:46 +0100273 writel(cur, info->sel_reg);
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100274
275 if (chip == -1 && allow_clk_stop(info))
276 clk_disable(info->clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277}
278
Ben Dooksad3b5fb2006-06-19 09:43:23 +0100279/* s3c2410_nand_hwcontrol
Ben Dooksa4f957f2005-06-20 12:48:25 +0100280 *
Ben Dooksad3b5fb2006-06-19 09:43:23 +0100281 * Issue command and address cycles to the chip
Ben Dooksa4f957f2005-06-20 12:48:25 +0100282*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Thomas Gleixner7abd3ef2006-05-23 23:25:53 +0200284static void s3c2410_nand_hwcontrol(struct mtd_info *mtd, int cmd,
David Woodhousef9068872006-06-10 00:53:16 +0100285 unsigned int ctrl)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286{
287 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
David Woodhousec9ac5972006-11-30 08:17:38 +0000288
Thomas Gleixner7abd3ef2006-05-23 23:25:53 +0200289 if (cmd == NAND_CMD_NONE)
290 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
David Woodhousef9068872006-06-10 00:53:16 +0100292 if (ctrl & NAND_CLE)
Thomas Gleixner7abd3ef2006-05-23 23:25:53 +0200293 writeb(cmd, info->regs + S3C2410_NFCMD);
294 else
295 writeb(cmd, info->regs + S3C2410_NFADDR);
Ben Dooksa4f957f2005-06-20 12:48:25 +0100296}
297
298/* command and control functions */
299
David Woodhousef9068872006-06-10 00:53:16 +0100300static void s3c2440_nand_hwcontrol(struct mtd_info *mtd, int cmd,
301 unsigned int ctrl)
Ben Dooksa4f957f2005-06-20 12:48:25 +0100302{
303 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
Ben Dooksa4f957f2005-06-20 12:48:25 +0100304
Thomas Gleixner7abd3ef2006-05-23 23:25:53 +0200305 if (cmd == NAND_CMD_NONE)
306 return;
Ben Dooksa4f957f2005-06-20 12:48:25 +0100307
David Woodhousef9068872006-06-10 00:53:16 +0100308 if (ctrl & NAND_CLE)
Thomas Gleixner7abd3ef2006-05-23 23:25:53 +0200309 writeb(cmd, info->regs + S3C2440_NFCMD);
310 else
311 writeb(cmd, info->regs + S3C2440_NFADDR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312}
313
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314/* s3c2410_nand_devready()
315 *
316 * returns 0 if the nand is busy, 1 if it is ready
317*/
318
319static int s3c2410_nand_devready(struct mtd_info *mtd)
320{
321 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY;
323}
324
Ben Dooks2c06a082006-06-27 14:35:46 +0100325static int s3c2440_nand_devready(struct mtd_info *mtd)
326{
327 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
328 return readb(info->regs + S3C2440_NFSTAT) & S3C2440_NFSTAT_READY;
329}
330
331static int s3c2412_nand_devready(struct mtd_info *mtd)
332{
333 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
334 return readb(info->regs + S3C2412_NFSTAT) & S3C2412_NFSTAT_READY;
335}
336
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337/* ECC handling functions */
338
Ben Dooks2c06a082006-06-27 14:35:46 +0100339static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
340 u_char *read_ecc, u_char *calc_ecc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341{
Ben Dooksa2593242007-02-02 16:59:33 +0000342 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
343 unsigned int diff0, diff1, diff2;
344 unsigned int bit, byte;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
Ben Dooksa2593242007-02-02 16:59:33 +0000346 pr_debug("%s(%p,%p,%p,%p)\n", __func__, mtd, dat, read_ecc, calc_ecc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347
Ben Dooksa2593242007-02-02 16:59:33 +0000348 diff0 = read_ecc[0] ^ calc_ecc[0];
349 diff1 = read_ecc[1] ^ calc_ecc[1];
350 diff2 = read_ecc[2] ^ calc_ecc[2];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
Ben Dooksa2593242007-02-02 16:59:33 +0000352 pr_debug("%s: rd %02x%02x%02x calc %02x%02x%02x diff %02x%02x%02x\n",
353 __func__,
354 read_ecc[0], read_ecc[1], read_ecc[2],
355 calc_ecc[0], calc_ecc[1], calc_ecc[2],
356 diff0, diff1, diff2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
Ben Dooksa2593242007-02-02 16:59:33 +0000358 if (diff0 == 0 && diff1 == 0 && diff2 == 0)
359 return 0; /* ECC is ok */
360
361 /* Can we correct this ECC (ie, one row and column change).
362 * Note, this is similar to the 256 error code on smartmedia */
363
364 if (((diff0 ^ (diff0 >> 1)) & 0x55) == 0x55 &&
365 ((diff1 ^ (diff1 >> 1)) & 0x55) == 0x55 &&
366 ((diff2 ^ (diff2 >> 1)) & 0x55) == 0x55) {
367 /* calculate the bit position of the error */
368
369 bit = (diff2 >> 2) & 1;
370 bit |= (diff2 >> 3) & 2;
371 bit |= (diff2 >> 4) & 4;
372
373 /* calculate the byte position of the error */
374
375 byte = (diff1 << 1) & 0x80;
376 byte |= (diff1 << 2) & 0x40;
377 byte |= (diff1 << 3) & 0x20;
378 byte |= (diff1 << 4) & 0x10;
379
380 byte |= (diff0 >> 3) & 0x08;
381 byte |= (diff0 >> 2) & 0x04;
382 byte |= (diff0 >> 1) & 0x02;
383 byte |= (diff0 >> 0) & 0x01;
384
385 byte |= (diff2 << 8) & 0x100;
386
387 dev_dbg(info->device, "correcting error bit %d, byte %d\n",
388 bit, byte);
389
390 dat[byte] ^= (1 << bit);
391 return 1;
392 }
393
394 /* if there is only one bit difference in the ECC, then
395 * one of only a row or column parity has changed, which
396 * means the error is most probably in the ECC itself */
397
398 diff0 |= (diff1 << 8);
399 diff0 |= (diff2 << 16);
400
401 if ((diff0 & ~(1<<fls(diff0))) == 0)
402 return 1;
403
404 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405}
406
Ben Dooksa4f957f2005-06-20 12:48:25 +0100407/* ECC functions
408 *
409 * These allow the s3c2410 and s3c2440 to use the controller's ECC
410 * generator block to ECC the data as it passes through]
411*/
412
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413static void s3c2410_nand_enable_hwecc(struct mtd_info *mtd, int mode)
414{
415 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
416 unsigned long ctrl;
417
418 ctrl = readl(info->regs + S3C2410_NFCONF);
419 ctrl |= S3C2410_NFCONF_INITECC;
420 writel(ctrl, info->regs + S3C2410_NFCONF);
421}
422
Matthieu CASTET4f659922007-02-13 12:30:38 +0100423static void s3c2412_nand_enable_hwecc(struct mtd_info *mtd, int mode)
424{
425 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
426 unsigned long ctrl;
427
428 ctrl = readl(info->regs + S3C2440_NFCONT);
429 writel(ctrl | S3C2412_NFCONT_INIT_MAIN_ECC, info->regs + S3C2440_NFCONT);
430}
431
Ben Dooksa4f957f2005-06-20 12:48:25 +0100432static void s3c2440_nand_enable_hwecc(struct mtd_info *mtd, int mode)
433{
434 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
435 unsigned long ctrl;
436
437 ctrl = readl(info->regs + S3C2440_NFCONT);
438 writel(ctrl | S3C2440_NFCONT_INITECC, info->regs + S3C2440_NFCONT);
439}
440
David Woodhousee0c7d762006-05-13 18:07:53 +0100441static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442{
443 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
444
445 ecc_code[0] = readb(info->regs + S3C2410_NFECC + 0);
446 ecc_code[1] = readb(info->regs + S3C2410_NFECC + 1);
447 ecc_code[2] = readb(info->regs + S3C2410_NFECC + 2);
448
Ben Dooksa2593242007-02-02 16:59:33 +0000449 pr_debug("%s: returning ecc %02x%02x%02x\n", __func__,
450 ecc_code[0], ecc_code[1], ecc_code[2]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451
452 return 0;
453}
454
Matthieu CASTET4f659922007-02-13 12:30:38 +0100455static int s3c2412_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
456{
457 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
458 unsigned long ecc = readl(info->regs + S3C2412_NFMECC0);
459
460 ecc_code[0] = ecc;
461 ecc_code[1] = ecc >> 8;
462 ecc_code[2] = ecc >> 16;
463
464 pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n", ecc_code[0], ecc_code[1], ecc_code[2]);
465
466 return 0;
467}
468
David Woodhousee0c7d762006-05-13 18:07:53 +0100469static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
Ben Dooksa4f957f2005-06-20 12:48:25 +0100470{
471 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
472 unsigned long ecc = readl(info->regs + S3C2440_NFMECC0);
473
474 ecc_code[0] = ecc;
475 ecc_code[1] = ecc >> 8;
476 ecc_code[2] = ecc >> 16;
477
Arnaud Patarddff5e442007-02-23 01:00:09 +0100478 pr_debug("%s: returning ecc %06lx\n", __func__, ecc);
Ben Dooksa4f957f2005-06-20 12:48:25 +0100479
480 return 0;
481}
482
Ben Dooksa4f957f2005-06-20 12:48:25 +0100483/* over-ride the standard functions for a little more speed. We can
484 * use read/write block to move the data buffers to/from the controller
485*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486
487static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
488{
489 struct nand_chip *this = mtd->priv;
490 readsb(this->IO_ADDR_R, buf, len);
491}
492
Matt Reimerb773bb22007-10-18 17:43:07 -0700493static void s3c2440_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
494{
495 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
496 readsl(info->regs + S3C2440_NFDATA, buf, len / 4);
497}
498
David Woodhousee0c7d762006-05-13 18:07:53 +0100499static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500{
501 struct nand_chip *this = mtd->priv;
502 writesb(this->IO_ADDR_W, buf, len);
503}
504
Matt Reimerb773bb22007-10-18 17:43:07 -0700505static void s3c2440_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
506{
507 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
508 writesl(info->regs + S3C2440_NFDATA, buf, len / 4);
509}
510
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511/* device management functions */
512
Russell King3ae5eae2005-11-09 22:32:44 +0000513static int s3c2410_nand_remove(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514{
Russell King3ae5eae2005-11-09 22:32:44 +0000515 struct s3c2410_nand_info *info = to_nand_info(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516
Russell King3ae5eae2005-11-09 22:32:44 +0000517 platform_set_drvdata(pdev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518
Thomas Gleixner61b03bd2005-11-07 11:15:49 +0000519 if (info == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 return 0;
521
522 /* first thing we need to do is release all our mtds
523 * and their partitions, then go through freeing the
Thomas Gleixner61b03bd2005-11-07 11:15:49 +0000524 * resources used
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 */
Thomas Gleixner61b03bd2005-11-07 11:15:49 +0000526
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 if (info->mtds != NULL) {
528 struct s3c2410_nand_mtd *ptr = info->mtds;
529 int mtdno;
530
531 for (mtdno = 0; mtdno < info->mtd_count; mtdno++, ptr++) {
532 pr_debug("releasing mtd %d (%p)\n", mtdno, ptr);
533 nand_release(&ptr->mtd);
534 }
535
536 kfree(info->mtds);
537 }
538
539 /* free the common resources */
540
541 if (info->clk != NULL && !IS_ERR(info->clk)) {
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100542 if (!allow_clk_stop(info))
543 clk_disable(info->clk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 clk_put(info->clk);
545 }
546
547 if (info->regs != NULL) {
548 iounmap(info->regs);
549 info->regs = NULL;
550 }
551
552 if (info->area != NULL) {
553 release_resource(info->area);
554 kfree(info->area);
555 info->area = NULL;
556 }
557
558 kfree(info);
559
560 return 0;
561}
562
563#ifdef CONFIG_MTD_PARTITIONS
564static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
565 struct s3c2410_nand_mtd *mtd,
566 struct s3c2410_nand_set *set)
567{
568 if (set == NULL)
569 return add_mtd_device(&mtd->mtd);
570
571 if (set->nr_partitions > 0 && set->partitions != NULL) {
David Woodhousee0c7d762006-05-13 18:07:53 +0100572 return add_mtd_partitions(&mtd->mtd, set->partitions, set->nr_partitions);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 }
574
575 return add_mtd_device(&mtd->mtd);
576}
577#else
578static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
579 struct s3c2410_nand_mtd *mtd,
580 struct s3c2410_nand_set *set)
581{
582 return add_mtd_device(&mtd->mtd);
583}
584#endif
585
586/* s3c2410_nand_init_chip
587 *
Thomas Gleixner61b03bd2005-11-07 11:15:49 +0000588 * init a single instance of an chip
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589*/
590
591static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
592 struct s3c2410_nand_mtd *nmtd,
593 struct s3c2410_nand_set *set)
594{
595 struct nand_chip *chip = &nmtd->chip;
Ben Dooks2c06a082006-06-27 14:35:46 +0100596 void __iomem *regs = info->regs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 chip->write_buf = s3c2410_nand_write_buf;
599 chip->read_buf = s3c2410_nand_read_buf;
600 chip->select_chip = s3c2410_nand_select_chip;
601 chip->chip_delay = 50;
602 chip->priv = nmtd;
603 chip->options = 0;
604 chip->controller = &info->controller;
605
Ben Dooks2c06a082006-06-27 14:35:46 +0100606 switch (info->cpu_type) {
607 case TYPE_S3C2410:
608 chip->IO_ADDR_W = regs + S3C2410_NFDATA;
609 info->sel_reg = regs + S3C2410_NFCONF;
610 info->sel_bit = S3C2410_NFCONF_nFCE;
611 chip->cmd_ctrl = s3c2410_nand_hwcontrol;
612 chip->dev_ready = s3c2410_nand_devready;
613 break;
614
615 case TYPE_S3C2440:
616 chip->IO_ADDR_W = regs + S3C2440_NFDATA;
617 info->sel_reg = regs + S3C2440_NFCONT;
618 info->sel_bit = S3C2440_NFCONT_nFCE;
619 chip->cmd_ctrl = s3c2440_nand_hwcontrol;
620 chip->dev_ready = s3c2440_nand_devready;
Matt Reimerb773bb22007-10-18 17:43:07 -0700621 chip->read_buf = s3c2440_nand_read_buf;
622 chip->write_buf = s3c2440_nand_write_buf;
Ben Dooks2c06a082006-06-27 14:35:46 +0100623 break;
624
625 case TYPE_S3C2412:
626 chip->IO_ADDR_W = regs + S3C2440_NFDATA;
627 info->sel_reg = regs + S3C2440_NFCONT;
628 info->sel_bit = S3C2412_NFCONT_nFCE0;
629 chip->cmd_ctrl = s3c2440_nand_hwcontrol;
630 chip->dev_ready = s3c2412_nand_devready;
631
632 if (readl(regs + S3C2410_NFCONF) & S3C2412_NFCONF_NANDBOOT)
633 dev_info(info->device, "System booted from NAND\n");
634
635 break;
636 }
637
638 chip->IO_ADDR_R = chip->IO_ADDR_W;
Ben Dooksa4f957f2005-06-20 12:48:25 +0100639
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 nmtd->info = info;
641 nmtd->mtd.priv = chip;
David Woodhouse552d9202006-05-14 01:20:46 +0100642 nmtd->mtd.owner = THIS_MODULE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 nmtd->set = set;
644
645 if (hardware_ecc) {
Thomas Gleixner6dfc6d22006-05-23 12:00:46 +0200646 chip->ecc.calculate = s3c2410_nand_calculate_ecc;
Ben Dooks2c06a082006-06-27 14:35:46 +0100647 chip->ecc.correct = s3c2410_nand_correct_data;
Thomas Gleixner6dfc6d22006-05-23 12:00:46 +0200648 chip->ecc.mode = NAND_ECC_HW;
649 chip->ecc.size = 512;
650 chip->ecc.bytes = 3;
Thomas Gleixner5bd34c02006-05-27 22:16:10 +0200651 chip->ecc.layout = &nand_hw_eccoob;
Ben Dooksa4f957f2005-06-20 12:48:25 +0100652
Ben Dooks2c06a082006-06-27 14:35:46 +0100653 switch (info->cpu_type) {
654 case TYPE_S3C2410:
655 chip->ecc.hwctl = s3c2410_nand_enable_hwecc;
656 chip->ecc.calculate = s3c2410_nand_calculate_ecc;
657 break;
658
659 case TYPE_S3C2412:
Matthieu CASTET4f659922007-02-13 12:30:38 +0100660 chip->ecc.hwctl = s3c2412_nand_enable_hwecc;
661 chip->ecc.calculate = s3c2412_nand_calculate_ecc;
662 break;
663
Ben Dooks2c06a082006-06-27 14:35:46 +0100664 case TYPE_S3C2440:
665 chip->ecc.hwctl = s3c2440_nand_enable_hwecc;
666 chip->ecc.calculate = s3c2440_nand_calculate_ecc;
667 break;
668
Ben Dooksa4f957f2005-06-20 12:48:25 +0100669 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 } else {
Thomas Gleixner6dfc6d22006-05-23 12:00:46 +0200671 chip->ecc.mode = NAND_ECC_SOFT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 }
673}
674
675/* s3c2410_nand_probe
676 *
677 * called by device layer when it finds a device matching
678 * one our driver can handled. This code checks to see if
679 * it can allocate all necessary resources then calls the
680 * nand layer to look for devices
681*/
682
Ben Dooks2c06a082006-06-27 14:35:46 +0100683static int s3c24xx_nand_probe(struct platform_device *pdev,
684 enum s3c_cpu_type cpu_type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685{
Russell King3ae5eae2005-11-09 22:32:44 +0000686 struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 struct s3c2410_nand_info *info;
688 struct s3c2410_nand_mtd *nmtd;
689 struct s3c2410_nand_set *sets;
690 struct resource *res;
691 int err = 0;
692 int size;
693 int nr_sets;
694 int setno;
695
Russell King3ae5eae2005-11-09 22:32:44 +0000696 pr_debug("s3c2410_nand_probe(%p)\n", pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697
698 info = kmalloc(sizeof(*info), GFP_KERNEL);
699 if (info == NULL) {
Russell King3ae5eae2005-11-09 22:32:44 +0000700 dev_err(&pdev->dev, "no memory for flash info\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 err = -ENOMEM;
702 goto exit_error;
703 }
704
705 memzero(info, sizeof(*info));
Russell King3ae5eae2005-11-09 22:32:44 +0000706 platform_set_drvdata(pdev, info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707
708 spin_lock_init(&info->controller.lock);
Ben Dooksa4f957f2005-06-20 12:48:25 +0100709 init_waitqueue_head(&info->controller.wq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710
711 /* get the clock source and enable it */
712
Russell King3ae5eae2005-11-09 22:32:44 +0000713 info->clk = clk_get(&pdev->dev, "nand");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 if (IS_ERR(info->clk)) {
Joe Perches898eb712007-10-18 03:06:30 -0700715 dev_err(&pdev->dev, "failed to get clock\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 err = -ENOENT;
717 goto exit_error;
718 }
719
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 clk_enable(info->clk);
721
722 /* allocate and map the resource */
723
Ben Dooksa4f957f2005-06-20 12:48:25 +0100724 /* currently we assume we have the one resource */
725 res = pdev->resource;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 size = res->end - res->start + 1;
727
728 info->area = request_mem_region(res->start, size, pdev->name);
729
730 if (info->area == NULL) {
Russell King3ae5eae2005-11-09 22:32:44 +0000731 dev_err(&pdev->dev, "cannot reserve register region\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 err = -ENOENT;
733 goto exit_error;
734 }
735
Russell King3ae5eae2005-11-09 22:32:44 +0000736 info->device = &pdev->dev;
Ben Dooksa4f957f2005-06-20 12:48:25 +0100737 info->platform = plat;
738 info->regs = ioremap(res->start, size);
Ben Dooks2c06a082006-06-27 14:35:46 +0100739 info->cpu_type = cpu_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740
741 if (info->regs == NULL) {
Russell King3ae5eae2005-11-09 22:32:44 +0000742 dev_err(&pdev->dev, "cannot reserve register region\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 err = -EIO;
744 goto exit_error;
Thomas Gleixner61b03bd2005-11-07 11:15:49 +0000745 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746
Russell King3ae5eae2005-11-09 22:32:44 +0000747 dev_dbg(&pdev->dev, "mapped registers at %p\n", info->regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748
749 /* initialise the hardware */
750
Russell King3ae5eae2005-11-09 22:32:44 +0000751 err = s3c2410_nand_inithw(info, pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 if (err != 0)
753 goto exit_error;
754
755 sets = (plat != NULL) ? plat->sets : NULL;
756 nr_sets = (plat != NULL) ? plat->nr_sets : 1;
757
758 info->mtd_count = nr_sets;
759
760 /* allocate our information */
761
762 size = nr_sets * sizeof(*info->mtds);
763 info->mtds = kmalloc(size, GFP_KERNEL);
764 if (info->mtds == NULL) {
Russell King3ae5eae2005-11-09 22:32:44 +0000765 dev_err(&pdev->dev, "failed to allocate mtd storage\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 err = -ENOMEM;
767 goto exit_error;
768 }
769
770 memzero(info->mtds, size);
771
772 /* initialise all possible chips */
773
774 nmtd = info->mtds;
775
776 for (setno = 0; setno < nr_sets; setno++, nmtd++) {
David Woodhousee0c7d762006-05-13 18:07:53 +0100777 pr_debug("initialising set %d (%p, info %p)\n", setno, nmtd, info);
Thomas Gleixner61b03bd2005-11-07 11:15:49 +0000778
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 s3c2410_nand_init_chip(info, nmtd, sets);
780
David Woodhousee0c7d762006-05-13 18:07:53 +0100781 nmtd->scan_res = nand_scan(&nmtd->mtd, (sets) ? sets->nr_chips : 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782
783 if (nmtd->scan_res == 0) {
784 s3c2410_nand_add_partition(info, nmtd, sets);
785 }
786
787 if (sets != NULL)
788 sets++;
789 }
Thomas Gleixner61b03bd2005-11-07 11:15:49 +0000790
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100791 if (allow_clk_stop(info)) {
792 dev_info(&pdev->dev, "clock idle support enabled\n");
793 clk_disable(info->clk);
794 }
795
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 pr_debug("initialised ok\n");
797 return 0;
798
799 exit_error:
Russell King3ae5eae2005-11-09 22:32:44 +0000800 s3c2410_nand_remove(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801
802 if (err == 0)
803 err = -EINVAL;
804 return err;
805}
806
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100807/* PM Support */
808#ifdef CONFIG_PM
809
810static int s3c24xx_nand_suspend(struct platform_device *dev, pm_message_t pm)
811{
812 struct s3c2410_nand_info *info = platform_get_drvdata(dev);
813
814 if (info) {
Ben Dooks03680b12007-11-19 23:28:07 +0000815 info->save_nfconf = readl(info->regs + S3C2410_NFCONF);
816
817 /* For the moment, we must ensure nFCE is high during
818 * the time we are suspended. This really should be
819 * handled by suspending the MTDs we are using, but
820 * that is currently not the case. */
821
822 writel(info->save_nfconf | info->sel_bit,
823 info->regs + S3C2410_NFCONF);
824
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100825 if (!allow_clk_stop(info))
826 clk_disable(info->clk);
827 }
828
829 return 0;
830}
831
832static int s3c24xx_nand_resume(struct platform_device *dev)
833{
834 struct s3c2410_nand_info *info = platform_get_drvdata(dev);
Ben Dooks03680b12007-11-19 23:28:07 +0000835 unsigned long nfconf;
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100836
837 if (info) {
838 clk_enable(info->clk);
839 s3c2410_nand_inithw(info, dev);
840
Ben Dooks03680b12007-11-19 23:28:07 +0000841 /* Restore the state of the nFCE line. */
842
843 nfconf = readl(info->regs + S3C2410_NFCONF);
844 nfconf &= ~info->sel_bit;
845 nfconf |= info->save_nfconf & info->sel_bit;
846 writel(nfconf, info->regs + S3C2410_NFCONF);
847
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100848 if (allow_clk_stop(info))
849 clk_disable(info->clk);
850 }
851
852 return 0;
853}
854
855#else
856#define s3c24xx_nand_suspend NULL
857#define s3c24xx_nand_resume NULL
858#endif
859
Ben Dooksa4f957f2005-06-20 12:48:25 +0100860/* driver device registration */
861
Russell King3ae5eae2005-11-09 22:32:44 +0000862static int s3c2410_nand_probe(struct platform_device *dev)
Ben Dooksa4f957f2005-06-20 12:48:25 +0100863{
Ben Dooks2c06a082006-06-27 14:35:46 +0100864 return s3c24xx_nand_probe(dev, TYPE_S3C2410);
Ben Dooksa4f957f2005-06-20 12:48:25 +0100865}
866
Russell King3ae5eae2005-11-09 22:32:44 +0000867static int s3c2440_nand_probe(struct platform_device *dev)
Ben Dooksa4f957f2005-06-20 12:48:25 +0100868{
Ben Dooks2c06a082006-06-27 14:35:46 +0100869 return s3c24xx_nand_probe(dev, TYPE_S3C2440);
870}
871
872static int s3c2412_nand_probe(struct platform_device *dev)
873{
874 return s3c24xx_nand_probe(dev, TYPE_S3C2412);
Ben Dooksa4f957f2005-06-20 12:48:25 +0100875}
876
Russell King3ae5eae2005-11-09 22:32:44 +0000877static struct platform_driver s3c2410_nand_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 .probe = s3c2410_nand_probe,
879 .remove = s3c2410_nand_remove,
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100880 .suspend = s3c24xx_nand_suspend,
881 .resume = s3c24xx_nand_resume,
Russell King3ae5eae2005-11-09 22:32:44 +0000882 .driver = {
883 .name = "s3c2410-nand",
884 .owner = THIS_MODULE,
885 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886};
887
Russell King3ae5eae2005-11-09 22:32:44 +0000888static struct platform_driver s3c2440_nand_driver = {
Ben Dooksa4f957f2005-06-20 12:48:25 +0100889 .probe = s3c2440_nand_probe,
890 .remove = s3c2410_nand_remove,
Ben Dooksd1fef3c2006-06-19 09:29:38 +0100891 .suspend = s3c24xx_nand_suspend,
892 .resume = s3c24xx_nand_resume,
Russell King3ae5eae2005-11-09 22:32:44 +0000893 .driver = {
894 .name = "s3c2440-nand",
895 .owner = THIS_MODULE,
896 },
Ben Dooksa4f957f2005-06-20 12:48:25 +0100897};
898
Ben Dooks2c06a082006-06-27 14:35:46 +0100899static struct platform_driver s3c2412_nand_driver = {
900 .probe = s3c2412_nand_probe,
901 .remove = s3c2410_nand_remove,
902 .suspend = s3c24xx_nand_suspend,
903 .resume = s3c24xx_nand_resume,
904 .driver = {
905 .name = "s3c2412-nand",
906 .owner = THIS_MODULE,
907 },
908};
909
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910static int __init s3c2410_nand_init(void)
911{
Ben Dooksa4f957f2005-06-20 12:48:25 +0100912 printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n");
913
Ben Dooks2c06a082006-06-27 14:35:46 +0100914 platform_driver_register(&s3c2412_nand_driver);
Russell King3ae5eae2005-11-09 22:32:44 +0000915 platform_driver_register(&s3c2440_nand_driver);
916 return platform_driver_register(&s3c2410_nand_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917}
918
919static void __exit s3c2410_nand_exit(void)
920{
Ben Dooks2c06a082006-06-27 14:35:46 +0100921 platform_driver_unregister(&s3c2412_nand_driver);
Russell King3ae5eae2005-11-09 22:32:44 +0000922 platform_driver_unregister(&s3c2440_nand_driver);
923 platform_driver_unregister(&s3c2410_nand_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924}
925
926module_init(s3c2410_nand_init);
927module_exit(s3c2410_nand_exit);
928
929MODULE_LICENSE("GPL");
930MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
Ben Dooksa4f957f2005-06-20 12:48:25 +0100931MODULE_DESCRIPTION("S3C24XX MTD NAND driver");