Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 1 | /* |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 2 | * Copyright (C) 2003 Rick Bronson |
| 3 | * |
| 4 | * Derived from drivers/mtd/nand/autcpu12.c |
| 5 | * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) |
| 6 | * |
| 7 | * Derived from drivers/mtd/spia.c |
| 8 | * Copyright (C) 2000 Steven J. Hill (sjhill@cotw.com) |
| 9 | * |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 10 | * |
| 11 | * Add Hardware ECC support for AT91SAM9260 / AT91SAM9263 |
| 12 | * Richard Genoud (richard.genoud@gmail.com), Adeneo Copyright (C) 2007 |
| 13 | * |
| 14 | * Derived from Das U-Boot source code |
| 15 | * (u-boot-1.1.5/board/atmel/at91sam9263ek/nand.c) |
| 16 | * (C) Copyright 2006 ATMEL Rousset, Lacressonniere Nicolas |
| 17 | * |
| 18 | * |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 19 | * This program is free software; you can redistribute it and/or modify |
| 20 | * it under the terms of the GNU General Public License version 2 as |
| 21 | * published by the Free Software Foundation. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <linux/slab.h> |
| 26 | #include <linux/module.h> |
Simon Polette | f4fa697 | 2009-05-27 18:19:39 +0300 | [diff] [blame] | 27 | #include <linux/moduleparam.h> |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 28 | #include <linux/platform_device.h> |
| 29 | #include <linux/mtd/mtd.h> |
| 30 | #include <linux/mtd/nand.h> |
| 31 | #include <linux/mtd/partitions.h> |
| 32 | |
David Woodhouse | 90574d0 | 2008-06-07 08:49:00 +0100 | [diff] [blame] | 33 | #include <linux/gpio.h> |
| 34 | #include <linux/io.h> |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 35 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 36 | #include <mach/board.h> |
| 37 | #include <mach/cpu.h> |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 38 | |
Håvard Skinnemoen | d4f4c0a | 2008-06-06 18:04:52 +0200 | [diff] [blame] | 39 | #ifdef CONFIG_MTD_NAND_ATMEL_ECC_HW |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 40 | #define hard_ecc 1 |
| 41 | #else |
| 42 | #define hard_ecc 0 |
| 43 | #endif |
| 44 | |
Håvard Skinnemoen | d4f4c0a | 2008-06-06 18:04:52 +0200 | [diff] [blame] | 45 | #ifdef CONFIG_MTD_NAND_ATMEL_ECC_NONE |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 46 | #define no_ecc 1 |
| 47 | #else |
| 48 | #define no_ecc 0 |
| 49 | #endif |
| 50 | |
Simon Polette | f4fa697 | 2009-05-27 18:19:39 +0300 | [diff] [blame] | 51 | static int on_flash_bbt = 0; |
| 52 | module_param(on_flash_bbt, int, 0); |
| 53 | |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 54 | /* Register access macros */ |
| 55 | #define ecc_readl(add, reg) \ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 56 | __raw_readl(add + ATMEL_ECC_##reg) |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 57 | #define ecc_writel(add, reg, value) \ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 58 | __raw_writel((value), add + ATMEL_ECC_##reg) |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 59 | |
Håvard Skinnemoen | d4f4c0a | 2008-06-06 18:04:52 +0200 | [diff] [blame] | 60 | #include "atmel_nand_ecc.h" /* Hardware ECC registers */ |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 61 | |
| 62 | /* oob layout for large page size |
| 63 | * bad block info is on bytes 0 and 1 |
| 64 | * the bytes have to be consecutives to avoid |
| 65 | * several NAND_CMD_RNDOUT during read |
| 66 | */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 67 | static struct nand_ecclayout atmel_oobinfo_large = { |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 68 | .eccbytes = 4, |
| 69 | .eccpos = {60, 61, 62, 63}, |
| 70 | .oobfree = { |
| 71 | {2, 58} |
| 72 | }, |
| 73 | }; |
| 74 | |
| 75 | /* oob layout for small page size |
| 76 | * bad block info is on bytes 4 and 5 |
| 77 | * the bytes have to be consecutives to avoid |
| 78 | * several NAND_CMD_RNDOUT during read |
| 79 | */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 80 | static struct nand_ecclayout atmel_oobinfo_small = { |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 81 | .eccbytes = 4, |
| 82 | .eccpos = {0, 1, 2, 3}, |
| 83 | .oobfree = { |
| 84 | {6, 10} |
| 85 | }, |
| 86 | }; |
| 87 | |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 88 | struct atmel_nand_host { |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 89 | struct nand_chip nand_chip; |
| 90 | struct mtd_info mtd; |
| 91 | void __iomem *io_base; |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 92 | struct atmel_nand_data *board; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 93 | struct device *dev; |
| 94 | void __iomem *ecc; |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | /* |
Atsushi Nemoto | 8136508 | 2008-04-27 01:51:12 +0900 | [diff] [blame] | 98 | * Enable NAND. |
| 99 | */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 100 | static void atmel_nand_enable(struct atmel_nand_host *host) |
Atsushi Nemoto | 8136508 | 2008-04-27 01:51:12 +0900 | [diff] [blame] | 101 | { |
| 102 | if (host->board->enable_pin) |
Håvard Skinnemoen | 62fd71f | 2008-06-06 18:04:51 +0200 | [diff] [blame] | 103 | gpio_set_value(host->board->enable_pin, 0); |
Atsushi Nemoto | 8136508 | 2008-04-27 01:51:12 +0900 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | /* |
| 107 | * Disable NAND. |
| 108 | */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 109 | static void atmel_nand_disable(struct atmel_nand_host *host) |
Atsushi Nemoto | 8136508 | 2008-04-27 01:51:12 +0900 | [diff] [blame] | 110 | { |
| 111 | if (host->board->enable_pin) |
Håvard Skinnemoen | 62fd71f | 2008-06-06 18:04:51 +0200 | [diff] [blame] | 112 | gpio_set_value(host->board->enable_pin, 1); |
Atsushi Nemoto | 8136508 | 2008-04-27 01:51:12 +0900 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | /* |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 116 | * Hardware specific access to control-lines |
| 117 | */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 118 | static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 119 | { |
| 120 | struct nand_chip *nand_chip = mtd->priv; |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 121 | struct atmel_nand_host *host = nand_chip->priv; |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 122 | |
Atsushi Nemoto | 8136508 | 2008-04-27 01:51:12 +0900 | [diff] [blame] | 123 | if (ctrl & NAND_CTRL_CHANGE) { |
Atsushi Nemoto | 2314488 | 2008-04-24 23:51:29 +0900 | [diff] [blame] | 124 | if (ctrl & NAND_NCE) |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 125 | atmel_nand_enable(host); |
Atsushi Nemoto | 2314488 | 2008-04-24 23:51:29 +0900 | [diff] [blame] | 126 | else |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 127 | atmel_nand_disable(host); |
Atsushi Nemoto | 2314488 | 2008-04-24 23:51:29 +0900 | [diff] [blame] | 128 | } |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 129 | if (cmd == NAND_CMD_NONE) |
| 130 | return; |
| 131 | |
| 132 | if (ctrl & NAND_CLE) |
| 133 | writeb(cmd, host->io_base + (1 << host->board->cle)); |
| 134 | else |
| 135 | writeb(cmd, host->io_base + (1 << host->board->ale)); |
| 136 | } |
| 137 | |
| 138 | /* |
| 139 | * Read the Device Ready pin. |
| 140 | */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 141 | static int atmel_nand_device_ready(struct mtd_info *mtd) |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 142 | { |
| 143 | struct nand_chip *nand_chip = mtd->priv; |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 144 | struct atmel_nand_host *host = nand_chip->priv; |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 145 | |
Gregory CLEMENT | 744f659 | 2009-02-16 21:21:47 +0100 | [diff] [blame] | 146 | return gpio_get_value(host->board->rdy_pin) ^ |
| 147 | !!host->board->rdy_pin_active_low; |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | /* |
David Brownell | 23a346c | 2008-07-03 23:40:16 -0700 | [diff] [blame] | 151 | * Minimal-overhead PIO for data access. |
| 152 | */ |
| 153 | static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len) |
| 154 | { |
| 155 | struct nand_chip *nand_chip = mtd->priv; |
| 156 | |
| 157 | __raw_readsb(nand_chip->IO_ADDR_R, buf, len); |
| 158 | } |
| 159 | |
| 160 | static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len) |
| 161 | { |
| 162 | struct nand_chip *nand_chip = mtd->priv; |
| 163 | |
| 164 | __raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2); |
| 165 | } |
| 166 | |
| 167 | static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len) |
| 168 | { |
| 169 | struct nand_chip *nand_chip = mtd->priv; |
| 170 | |
| 171 | __raw_writesb(nand_chip->IO_ADDR_W, buf, len); |
| 172 | } |
| 173 | |
| 174 | static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len) |
| 175 | { |
| 176 | struct nand_chip *nand_chip = mtd->priv; |
| 177 | |
| 178 | __raw_writesw(nand_chip->IO_ADDR_W, buf, len / 2); |
| 179 | } |
| 180 | |
| 181 | /* |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 182 | * Calculate HW ECC |
| 183 | * |
| 184 | * function called after a write |
| 185 | * |
| 186 | * mtd: MTD block structure |
| 187 | * dat: raw data (unused) |
| 188 | * ecc_code: buffer for ECC |
| 189 | */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 190 | static int atmel_nand_calculate(struct mtd_info *mtd, |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 191 | const u_char *dat, unsigned char *ecc_code) |
| 192 | { |
| 193 | struct nand_chip *nand_chip = mtd->priv; |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 194 | struct atmel_nand_host *host = nand_chip->priv; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 195 | unsigned int ecc_value; |
| 196 | |
| 197 | /* get the first 2 ECC bytes */ |
Richard Genoud | d43fa14 | 2008-04-25 09:32:26 +0200 | [diff] [blame] | 198 | ecc_value = ecc_readl(host->ecc, PR); |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 199 | |
Richard Genoud | 3fc2389 | 2008-10-12 08:42:28 +0200 | [diff] [blame] | 200 | ecc_code[0] = ecc_value & 0xFF; |
| 201 | ecc_code[1] = (ecc_value >> 8) & 0xFF; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 202 | |
| 203 | /* get the last 2 ECC bytes */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 204 | ecc_value = ecc_readl(host->ecc, NPR) & ATMEL_ECC_NPARITY; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 205 | |
Richard Genoud | 3fc2389 | 2008-10-12 08:42:28 +0200 | [diff] [blame] | 206 | ecc_code[2] = ecc_value & 0xFF; |
| 207 | ecc_code[3] = (ecc_value >> 8) & 0xFF; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 208 | |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | /* |
| 213 | * HW ECC read page function |
| 214 | * |
| 215 | * mtd: mtd info structure |
| 216 | * chip: nand chip info structure |
| 217 | * buf: buffer to store read data |
| 218 | */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 219 | static int atmel_nand_read_page(struct mtd_info *mtd, |
Sneha Narnakaje | 46a8cf2 | 2009-09-18 12:51:46 -0700 | [diff] [blame] | 220 | struct nand_chip *chip, uint8_t *buf, int page) |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 221 | { |
| 222 | int eccsize = chip->ecc.size; |
| 223 | int eccbytes = chip->ecc.bytes; |
| 224 | uint32_t *eccpos = chip->ecc.layout->eccpos; |
| 225 | uint8_t *p = buf; |
| 226 | uint8_t *oob = chip->oob_poi; |
| 227 | uint8_t *ecc_pos; |
| 228 | int stat; |
| 229 | |
Haavard Skinnemoen | d6248fd | 2008-07-03 23:40:18 -0700 | [diff] [blame] | 230 | /* |
| 231 | * Errata: ALE is incorrectly wired up to the ECC controller |
| 232 | * on the AP7000, so it will include the address cycles in the |
| 233 | * ECC calculation. |
| 234 | * |
| 235 | * Workaround: Reset the parity registers before reading the |
| 236 | * actual data. |
| 237 | */ |
| 238 | if (cpu_is_at32ap7000()) { |
| 239 | struct atmel_nand_host *host = chip->priv; |
| 240 | ecc_writel(host->ecc, CR, ATMEL_ECC_RST); |
| 241 | } |
| 242 | |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 243 | /* read the page */ |
| 244 | chip->read_buf(mtd, p, eccsize); |
| 245 | |
| 246 | /* move to ECC position if needed */ |
| 247 | if (eccpos[0] != 0) { |
| 248 | /* This only works on large pages |
| 249 | * because the ECC controller waits for |
| 250 | * NAND_CMD_RNDOUTSTART after the |
| 251 | * NAND_CMD_RNDOUT. |
| 252 | * anyway, for small pages, the eccpos[0] == 0 |
| 253 | */ |
| 254 | chip->cmdfunc(mtd, NAND_CMD_RNDOUT, |
| 255 | mtd->writesize + eccpos[0], -1); |
| 256 | } |
| 257 | |
| 258 | /* the ECC controller needs to read the ECC just after the data */ |
| 259 | ecc_pos = oob + eccpos[0]; |
| 260 | chip->read_buf(mtd, ecc_pos, eccbytes); |
| 261 | |
| 262 | /* check if there's an error */ |
| 263 | stat = chip->ecc.correct(mtd, p, oob, NULL); |
| 264 | |
| 265 | if (stat < 0) |
| 266 | mtd->ecc_stats.failed++; |
| 267 | else |
| 268 | mtd->ecc_stats.corrected += stat; |
| 269 | |
| 270 | /* get back to oob start (end of page) */ |
| 271 | chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1); |
| 272 | |
| 273 | /* read the oob */ |
| 274 | chip->read_buf(mtd, oob, mtd->oobsize); |
| 275 | |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | /* |
| 280 | * HW ECC Correction |
| 281 | * |
| 282 | * function called after a read |
| 283 | * |
| 284 | * mtd: MTD block structure |
| 285 | * dat: raw data read from the chip |
| 286 | * read_ecc: ECC from the chip (unused) |
| 287 | * isnull: unused |
| 288 | * |
| 289 | * Detect and correct a 1 bit error for a page |
| 290 | */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 291 | static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat, |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 292 | u_char *read_ecc, u_char *isnull) |
| 293 | { |
| 294 | struct nand_chip *nand_chip = mtd->priv; |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 295 | struct atmel_nand_host *host = nand_chip->priv; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 296 | unsigned int ecc_status; |
| 297 | unsigned int ecc_word, ecc_bit; |
| 298 | |
| 299 | /* get the status from the Status Register */ |
| 300 | ecc_status = ecc_readl(host->ecc, SR); |
| 301 | |
| 302 | /* if there's no error */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 303 | if (likely(!(ecc_status & ATMEL_ECC_RECERR))) |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 304 | return 0; |
| 305 | |
| 306 | /* get error bit offset (4 bits) */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 307 | ecc_bit = ecc_readl(host->ecc, PR) & ATMEL_ECC_BITADDR; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 308 | /* get word address (12 bits) */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 309 | ecc_word = ecc_readl(host->ecc, PR) & ATMEL_ECC_WORDADDR; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 310 | ecc_word >>= 4; |
| 311 | |
| 312 | /* if there are multiple errors */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 313 | if (ecc_status & ATMEL_ECC_MULERR) { |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 314 | /* check if it is a freshly erased block |
| 315 | * (filled with 0xff) */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 316 | if ((ecc_bit == ATMEL_ECC_BITADDR) |
| 317 | && (ecc_word == (ATMEL_ECC_WORDADDR >> 4))) { |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 318 | /* the block has just been erased, return OK */ |
| 319 | return 0; |
| 320 | } |
| 321 | /* it doesn't seems to be a freshly |
| 322 | * erased block. |
| 323 | * We can't correct so many errors */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 324 | dev_dbg(host->dev, "atmel_nand : multiple errors detected." |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 325 | " Unable to correct.\n"); |
| 326 | return -EIO; |
| 327 | } |
| 328 | |
| 329 | /* if there's a single bit error : we can correct it */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 330 | if (ecc_status & ATMEL_ECC_ECCERR) { |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 331 | /* there's nothing much to do here. |
| 332 | * the bit error is on the ECC itself. |
| 333 | */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 334 | dev_dbg(host->dev, "atmel_nand : one bit error on ECC code." |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 335 | " Nothing to correct\n"); |
| 336 | return 0; |
| 337 | } |
| 338 | |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 339 | dev_dbg(host->dev, "atmel_nand : one bit error on data." |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 340 | " (word offset in the page :" |
| 341 | " 0x%x bit offset : 0x%x)\n", |
| 342 | ecc_word, ecc_bit); |
| 343 | /* correct the error */ |
| 344 | if (nand_chip->options & NAND_BUSWIDTH_16) { |
| 345 | /* 16 bits words */ |
| 346 | ((unsigned short *) dat)[ecc_word] ^= (1 << ecc_bit); |
| 347 | } else { |
| 348 | /* 8 bits words */ |
| 349 | dat[ecc_word] ^= (1 << ecc_bit); |
| 350 | } |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 351 | dev_dbg(host->dev, "atmel_nand : error corrected\n"); |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 352 | return 1; |
| 353 | } |
| 354 | |
| 355 | /* |
Haavard Skinnemoen | d6248fd | 2008-07-03 23:40:18 -0700 | [diff] [blame] | 356 | * Enable HW ECC : unused on most chips |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 357 | */ |
Haavard Skinnemoen | d6248fd | 2008-07-03 23:40:18 -0700 | [diff] [blame] | 358 | static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) |
| 359 | { |
| 360 | if (cpu_is_at32ap7000()) { |
| 361 | struct nand_chip *nand_chip = mtd->priv; |
| 362 | struct atmel_nand_host *host = nand_chip->priv; |
| 363 | ecc_writel(host->ecc, CR, ATMEL_ECC_RST); |
| 364 | } |
| 365 | } |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 366 | |
Andreas Bießmann | 9a9745c3 | 2010-08-05 12:38:41 +0200 | [diff] [blame] | 367 | #ifdef CONFIG_MTD_CMDLINE_PARTS |
Atsushi Nemoto | 52f8301 | 2008-03-30 21:59:37 +0900 | [diff] [blame] | 368 | static const char *part_probes[] = { "cmdlinepart", NULL }; |
Andrew Victor | 693ef66 | 2007-05-03 08:16:44 +0200 | [diff] [blame] | 369 | #endif |
| 370 | |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 371 | /* |
| 372 | * Probe for the NAND device. |
| 373 | */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 374 | static int __init atmel_nand_probe(struct platform_device *pdev) |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 375 | { |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 376 | struct atmel_nand_host *host; |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 377 | struct mtd_info *mtd; |
| 378 | struct nand_chip *nand_chip; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 379 | struct resource *regs; |
| 380 | struct resource *mem; |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 381 | int res; |
| 382 | |
| 383 | #ifdef CONFIG_MTD_PARTITIONS |
| 384 | struct mtd_partition *partitions = NULL; |
| 385 | int num_partitions = 0; |
| 386 | #endif |
| 387 | |
Håvard Skinnemoen | cc0c72e | 2008-06-06 18:04:54 +0200 | [diff] [blame] | 388 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 389 | if (!mem) { |
| 390 | printk(KERN_ERR "atmel_nand: can't get I/O resource mem\n"); |
| 391 | return -ENXIO; |
| 392 | } |
| 393 | |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 394 | /* Allocate memory for the device structure (and zero it) */ |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 395 | host = kzalloc(sizeof(struct atmel_nand_host), GFP_KERNEL); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 396 | if (!host) { |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 397 | printk(KERN_ERR "atmel_nand: failed to allocate device structure.\n"); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 398 | return -ENOMEM; |
| 399 | } |
| 400 | |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 401 | host->io_base = ioremap(mem->start, mem->end - mem->start + 1); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 402 | if (host->io_base == NULL) { |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 403 | printk(KERN_ERR "atmel_nand: ioremap failed\n"); |
Håvard Skinnemoen | cc0c72e | 2008-06-06 18:04:54 +0200 | [diff] [blame] | 404 | res = -EIO; |
| 405 | goto err_nand_ioremap; |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | mtd = &host->mtd; |
| 409 | nand_chip = &host->nand_chip; |
| 410 | host->board = pdev->dev.platform_data; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 411 | host->dev = &pdev->dev; |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 412 | |
| 413 | nand_chip->priv = host; /* link the private data structures */ |
| 414 | mtd->priv = nand_chip; |
| 415 | mtd->owner = THIS_MODULE; |
| 416 | |
| 417 | /* Set address of NAND IO lines */ |
| 418 | nand_chip->IO_ADDR_R = host->io_base; |
| 419 | nand_chip->IO_ADDR_W = host->io_base; |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 420 | nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl; |
Ivan Kuten | a4265f8 | 2007-05-24 14:35:58 +0300 | [diff] [blame] | 421 | |
| 422 | if (host->board->rdy_pin) |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 423 | nand_chip->dev_ready = atmel_nand_device_ready; |
Ivan Kuten | a4265f8 | 2007-05-24 14:35:58 +0300 | [diff] [blame] | 424 | |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 425 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 426 | if (!regs && hard_ecc) { |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 427 | printk(KERN_ERR "atmel_nand: can't get I/O resource " |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 428 | "regs\nFalling back on software ECC\n"); |
| 429 | } |
| 430 | |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 431 | nand_chip->ecc.mode = NAND_ECC_SOFT; /* enable ECC */ |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 432 | if (no_ecc) |
| 433 | nand_chip->ecc.mode = NAND_ECC_NONE; |
| 434 | if (hard_ecc && regs) { |
| 435 | host->ecc = ioremap(regs->start, regs->end - regs->start + 1); |
| 436 | if (host->ecc == NULL) { |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 437 | printk(KERN_ERR "atmel_nand: ioremap failed\n"); |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 438 | res = -EIO; |
| 439 | goto err_ecc_ioremap; |
| 440 | } |
Richard Genoud | 3fc2389 | 2008-10-12 08:42:28 +0200 | [diff] [blame] | 441 | nand_chip->ecc.mode = NAND_ECC_HW; |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 442 | nand_chip->ecc.calculate = atmel_nand_calculate; |
| 443 | nand_chip->ecc.correct = atmel_nand_correct; |
| 444 | nand_chip->ecc.hwctl = atmel_nand_hwctl; |
| 445 | nand_chip->ecc.read_page = atmel_nand_read_page; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 446 | nand_chip->ecc.bytes = 4; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 447 | } |
| 448 | |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 449 | nand_chip->chip_delay = 20; /* 20us command delay time */ |
| 450 | |
David Brownell | 23a346c | 2008-07-03 23:40:16 -0700 | [diff] [blame] | 451 | if (host->board->bus_width_16) { /* 16-bit bus width */ |
Andrew Victor | dd11b8c | 2006-12-08 13:49:42 +0200 | [diff] [blame] | 452 | nand_chip->options |= NAND_BUSWIDTH_16; |
David Brownell | 23a346c | 2008-07-03 23:40:16 -0700 | [diff] [blame] | 453 | nand_chip->read_buf = atmel_read_buf16; |
| 454 | nand_chip->write_buf = atmel_write_buf16; |
| 455 | } else { |
| 456 | nand_chip->read_buf = atmel_read_buf; |
| 457 | nand_chip->write_buf = atmel_write_buf; |
| 458 | } |
Andrew Victor | dd11b8c | 2006-12-08 13:49:42 +0200 | [diff] [blame] | 459 | |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 460 | platform_set_drvdata(pdev, host); |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 461 | atmel_nand_enable(host); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 462 | |
| 463 | if (host->board->det_pin) { |
Håvard Skinnemoen | 62fd71f | 2008-06-06 18:04:51 +0200 | [diff] [blame] | 464 | if (gpio_get_value(host->board->det_pin)) { |
Simon Polette | f4fa697 | 2009-05-27 18:19:39 +0300 | [diff] [blame] | 465 | printk(KERN_INFO "No SmartMedia card inserted.\n"); |
Roel Kluin | 895fb49 | 2009-11-11 21:47:06 +0100 | [diff] [blame] | 466 | res = -ENXIO; |
Håvard Skinnemoen | cc0c72e | 2008-06-06 18:04:54 +0200 | [diff] [blame] | 467 | goto err_no_card; |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 468 | } |
| 469 | } |
| 470 | |
Simon Polette | f4fa697 | 2009-05-27 18:19:39 +0300 | [diff] [blame] | 471 | if (on_flash_bbt) { |
| 472 | printk(KERN_INFO "atmel_nand: Use On Flash BBT\n"); |
| 473 | nand_chip->options |= NAND_USE_FLASH_BBT; |
| 474 | } |
| 475 | |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 476 | /* first scan to find the device and get the page size */ |
David Woodhouse | 5e81e88 | 2010-02-26 18:32:56 +0000 | [diff] [blame] | 477 | if (nand_scan_ident(mtd, 1, NULL)) { |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 478 | res = -ENXIO; |
Håvard Skinnemoen | cc0c72e | 2008-06-06 18:04:54 +0200 | [diff] [blame] | 479 | goto err_scan_ident; |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 480 | } |
| 481 | |
Richard Genoud | 3fc2389 | 2008-10-12 08:42:28 +0200 | [diff] [blame] | 482 | if (nand_chip->ecc.mode == NAND_ECC_HW) { |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 483 | /* ECC is calculated for the whole page (1 step) */ |
| 484 | nand_chip->ecc.size = mtd->writesize; |
| 485 | |
| 486 | /* set ECC page size and oob layout */ |
| 487 | switch (mtd->writesize) { |
| 488 | case 512: |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 489 | nand_chip->ecc.layout = &atmel_oobinfo_small; |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 490 | ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_528); |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 491 | break; |
| 492 | case 1024: |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 493 | nand_chip->ecc.layout = &atmel_oobinfo_large; |
| 494 | ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_1056); |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 495 | break; |
| 496 | case 2048: |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 497 | nand_chip->ecc.layout = &atmel_oobinfo_large; |
| 498 | ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_2112); |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 499 | break; |
| 500 | case 4096: |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 501 | nand_chip->ecc.layout = &atmel_oobinfo_large; |
| 502 | ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_4224); |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 503 | break; |
| 504 | default: |
| 505 | /* page size not handled by HW ECC */ |
| 506 | /* switching back to soft ECC */ |
| 507 | nand_chip->ecc.mode = NAND_ECC_SOFT; |
| 508 | nand_chip->ecc.calculate = NULL; |
| 509 | nand_chip->ecc.correct = NULL; |
| 510 | nand_chip->ecc.hwctl = NULL; |
| 511 | nand_chip->ecc.read_page = NULL; |
| 512 | nand_chip->ecc.postpad = 0; |
| 513 | nand_chip->ecc.prepad = 0; |
| 514 | nand_chip->ecc.bytes = 0; |
| 515 | break; |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | /* second phase scan */ |
| 520 | if (nand_scan_tail(mtd)) { |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 521 | res = -ENXIO; |
Håvard Skinnemoen | cc0c72e | 2008-06-06 18:04:54 +0200 | [diff] [blame] | 522 | goto err_scan_tail; |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | #ifdef CONFIG_MTD_PARTITIONS |
Andrew Victor | 693ef66 | 2007-05-03 08:16:44 +0200 | [diff] [blame] | 526 | #ifdef CONFIG_MTD_CMDLINE_PARTS |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 527 | mtd->name = "atmel_nand"; |
Atsushi Nemoto | 842b1a10 | 2008-01-29 22:28:22 +0900 | [diff] [blame] | 528 | num_partitions = parse_mtd_partitions(mtd, part_probes, |
| 529 | &partitions, 0); |
Andrew Victor | 693ef66 | 2007-05-03 08:16:44 +0200 | [diff] [blame] | 530 | #endif |
Atsushi Nemoto | 842b1a10 | 2008-01-29 22:28:22 +0900 | [diff] [blame] | 531 | if (num_partitions <= 0 && host->board->partition_info) |
| 532 | partitions = host->board->partition_info(mtd->size, |
| 533 | &num_partitions); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 534 | |
| 535 | if ((!partitions) || (num_partitions == 0)) { |
Thadeu Lima de Souza Cascardo | ae27a7a | 2009-06-24 18:40:46 -0300 | [diff] [blame] | 536 | printk(KERN_ERR "atmel_nand: No partitions defined, or unsupported device.\n"); |
Roel Kluin | 895fb49 | 2009-11-11 21:47:06 +0100 | [diff] [blame] | 537 | res = -ENXIO; |
Håvard Skinnemoen | cc0c72e | 2008-06-06 18:04:54 +0200 | [diff] [blame] | 538 | goto err_no_partitions; |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | res = add_mtd_partitions(mtd, partitions, num_partitions); |
| 542 | #else |
| 543 | res = add_mtd_device(mtd); |
| 544 | #endif |
| 545 | |
| 546 | if (!res) |
| 547 | return res; |
| 548 | |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 549 | #ifdef CONFIG_MTD_PARTITIONS |
Håvard Skinnemoen | cc0c72e | 2008-06-06 18:04:54 +0200 | [diff] [blame] | 550 | err_no_partitions: |
Richard Genoud | 77f5492 | 2008-04-23 19:51:14 +0200 | [diff] [blame] | 551 | #endif |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 552 | nand_release(mtd); |
Håvard Skinnemoen | cc0c72e | 2008-06-06 18:04:54 +0200 | [diff] [blame] | 553 | err_scan_tail: |
| 554 | err_scan_ident: |
| 555 | err_no_card: |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 556 | atmel_nand_disable(host); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 557 | platform_set_drvdata(pdev, NULL); |
Håvard Skinnemoen | cc0c72e | 2008-06-06 18:04:54 +0200 | [diff] [blame] | 558 | if (host->ecc) |
| 559 | iounmap(host->ecc); |
| 560 | err_ecc_ioremap: |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 561 | iounmap(host->io_base); |
Håvard Skinnemoen | cc0c72e | 2008-06-06 18:04:54 +0200 | [diff] [blame] | 562 | err_nand_ioremap: |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 563 | kfree(host); |
| 564 | return res; |
| 565 | } |
| 566 | |
| 567 | /* |
| 568 | * Remove a NAND device. |
| 569 | */ |
David Brownell | 23a346c | 2008-07-03 23:40:16 -0700 | [diff] [blame] | 570 | static int __exit atmel_nand_remove(struct platform_device *pdev) |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 571 | { |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 572 | struct atmel_nand_host *host = platform_get_drvdata(pdev); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 573 | struct mtd_info *mtd = &host->mtd; |
| 574 | |
| 575 | nand_release(mtd); |
| 576 | |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 577 | atmel_nand_disable(host); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 578 | |
Håvard Skinnemoen | cc0c72e | 2008-06-06 18:04:54 +0200 | [diff] [blame] | 579 | if (host->ecc) |
| 580 | iounmap(host->ecc); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 581 | iounmap(host->io_base); |
| 582 | kfree(host); |
| 583 | |
| 584 | return 0; |
| 585 | } |
| 586 | |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 587 | static struct platform_driver atmel_nand_driver = { |
David Brownell | 23a346c | 2008-07-03 23:40:16 -0700 | [diff] [blame] | 588 | .remove = __exit_p(atmel_nand_remove), |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 589 | .driver = { |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 590 | .name = "atmel_nand", |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 591 | .owner = THIS_MODULE, |
| 592 | }, |
| 593 | }; |
| 594 | |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 595 | static int __init atmel_nand_init(void) |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 596 | { |
David Brownell | 23a346c | 2008-07-03 23:40:16 -0700 | [diff] [blame] | 597 | return platform_driver_probe(&atmel_nand_driver, atmel_nand_probe); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 601 | static void __exit atmel_nand_exit(void) |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 602 | { |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 603 | platform_driver_unregister(&atmel_nand_driver); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 607 | module_init(atmel_nand_init); |
| 608 | module_exit(atmel_nand_exit); |
Andrew Victor | 42cb140 | 2006-10-19 18:24:35 +0200 | [diff] [blame] | 609 | |
| 610 | MODULE_LICENSE("GPL"); |
| 611 | MODULE_AUTHOR("Rick Bronson"); |
Håvard Skinnemoen | d4f4c0a | 2008-06-06 18:04:52 +0200 | [diff] [blame] | 612 | MODULE_DESCRIPTION("NAND/SmartMedia driver for AT91 / AVR32"); |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 613 | MODULE_ALIAS("platform:atmel_nand"); |