diff options
Diffstat (limited to 'drivers/mtd/nand/atmel_nand.c')
-rw-r--r-- | drivers/mtd/nand/atmel_nand.c | 74 |
1 files changed, 8 insertions, 66 deletions
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index 55da20ccc7a8..23e5d77c39fc 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c | |||
@@ -161,37 +161,6 @@ static int atmel_nand_device_ready(struct mtd_info *mtd) | |||
161 | !!host->board->rdy_pin_active_low; | 161 | !!host->board->rdy_pin_active_low; |
162 | } | 162 | } |
163 | 163 | ||
164 | /* | ||
165 | * Minimal-overhead PIO for data access. | ||
166 | */ | ||
167 | static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len) | ||
168 | { | ||
169 | struct nand_chip *nand_chip = mtd->priv; | ||
170 | |||
171 | __raw_readsb(nand_chip->IO_ADDR_R, buf, len); | ||
172 | } | ||
173 | |||
174 | static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len) | ||
175 | { | ||
176 | struct nand_chip *nand_chip = mtd->priv; | ||
177 | |||
178 | __raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2); | ||
179 | } | ||
180 | |||
181 | static void atmel_write_buf8(struct mtd_info *mtd, const u8 *buf, int len) | ||
182 | { | ||
183 | struct nand_chip *nand_chip = mtd->priv; | ||
184 | |||
185 | __raw_writesb(nand_chip->IO_ADDR_W, buf, len); | ||
186 | } | ||
187 | |||
188 | static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len) | ||
189 | { | ||
190 | struct nand_chip *nand_chip = mtd->priv; | ||
191 | |||
192 | __raw_writesw(nand_chip->IO_ADDR_W, buf, len / 2); | ||
193 | } | ||
194 | |||
195 | static void dma_complete_func(void *completion) | 164 | static void dma_complete_func(void *completion) |
196 | { | 165 | { |
197 | complete(completion); | 166 | complete(completion); |
@@ -266,33 +235,27 @@ err_buf: | |||
266 | static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len) | 235 | static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len) |
267 | { | 236 | { |
268 | struct nand_chip *chip = mtd->priv; | 237 | struct nand_chip *chip = mtd->priv; |
269 | struct atmel_nand_host *host = chip->priv; | ||
270 | 238 | ||
271 | if (use_dma && len > mtd->oobsize) | 239 | if (use_dma && len > mtd->oobsize) |
272 | /* only use DMA for bigger than oob size: better performances */ | 240 | /* only use DMA for bigger than oob size: better performances */ |
273 | if (atmel_nand_dma_op(mtd, buf, len, 1) == 0) | 241 | if (atmel_nand_dma_op(mtd, buf, len, 1) == 0) |
274 | return; | 242 | return; |
275 | 243 | ||
276 | if (host->board->bus_width_16) | 244 | /* if no DMA operation possible, use PIO */ |
277 | atmel_read_buf16(mtd, buf, len); | 245 | memcpy_fromio(buf, chip->IO_ADDR_R, len); |
278 | else | ||
279 | atmel_read_buf8(mtd, buf, len); | ||
280 | } | 246 | } |
281 | 247 | ||
282 | static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len) | 248 | static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len) |
283 | { | 249 | { |
284 | struct nand_chip *chip = mtd->priv; | 250 | struct nand_chip *chip = mtd->priv; |
285 | struct atmel_nand_host *host = chip->priv; | ||
286 | 251 | ||
287 | if (use_dma && len > mtd->oobsize) | 252 | if (use_dma && len > mtd->oobsize) |
288 | /* only use DMA for bigger than oob size: better performances */ | 253 | /* only use DMA for bigger than oob size: better performances */ |
289 | if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) == 0) | 254 | if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) == 0) |
290 | return; | 255 | return; |
291 | 256 | ||
292 | if (host->board->bus_width_16) | 257 | /* if no DMA operation possible, use PIO */ |
293 | atmel_write_buf16(mtd, buf, len); | 258 | memcpy_toio(chip->IO_ADDR_W, buf, len); |
294 | else | ||
295 | atmel_write_buf8(mtd, buf, len); | ||
296 | } | 259 | } |
297 | 260 | ||
298 | /* | 261 | /* |
@@ -481,10 +444,6 @@ static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) | |||
481 | } | 444 | } |
482 | } | 445 | } |
483 | 446 | ||
484 | #ifdef CONFIG_MTD_CMDLINE_PARTS | ||
485 | static const char *part_probes[] = { "cmdlinepart", NULL }; | ||
486 | #endif | ||
487 | |||
488 | /* | 447 | /* |
489 | * Probe for the NAND device. | 448 | * Probe for the NAND device. |
490 | */ | 449 | */ |
@@ -496,8 +455,6 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
496 | struct resource *regs; | 455 | struct resource *regs; |
497 | struct resource *mem; | 456 | struct resource *mem; |
498 | int res; | 457 | int res; |
499 | struct mtd_partition *partitions = NULL; | ||
500 | int num_partitions = 0; | ||
501 | 458 | ||
502 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 459 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
503 | if (!mem) { | 460 | if (!mem) { |
@@ -583,7 +540,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
583 | 540 | ||
584 | if (on_flash_bbt) { | 541 | if (on_flash_bbt) { |
585 | printk(KERN_INFO "atmel_nand: Use On Flash BBT\n"); | 542 | printk(KERN_INFO "atmel_nand: Use On Flash BBT\n"); |
586 | nand_chip->options |= NAND_USE_FLASH_BBT; | 543 | nand_chip->bbt_options |= NAND_BBT_USE_FLASH; |
587 | } | 544 | } |
588 | 545 | ||
589 | if (!cpu_has_dma()) | 546 | if (!cpu_has_dma()) |
@@ -594,7 +551,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
594 | 551 | ||
595 | dma_cap_zero(mask); | 552 | dma_cap_zero(mask); |
596 | dma_cap_set(DMA_MEMCPY, mask); | 553 | dma_cap_set(DMA_MEMCPY, mask); |
597 | host->dma_chan = dma_request_channel(mask, 0, NULL); | 554 | host->dma_chan = dma_request_channel(mask, NULL, NULL); |
598 | if (!host->dma_chan) { | 555 | if (!host->dma_chan) { |
599 | dev_err(host->dev, "Failed to request DMA channel\n"); | 556 | dev_err(host->dev, "Failed to request DMA channel\n"); |
600 | use_dma = 0; | 557 | use_dma = 0; |
@@ -655,27 +612,12 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
655 | goto err_scan_tail; | 612 | goto err_scan_tail; |
656 | } | 613 | } |
657 | 614 | ||
658 | #ifdef CONFIG_MTD_CMDLINE_PARTS | ||
659 | mtd->name = "atmel_nand"; | 615 | mtd->name = "atmel_nand"; |
660 | num_partitions = parse_mtd_partitions(mtd, part_probes, | 616 | res = mtd_device_parse_register(mtd, NULL, 0, |
661 | &partitions, 0); | 617 | host->board->parts, host->board->num_parts); |
662 | #endif | ||
663 | if (num_partitions <= 0 && host->board->partition_info) | ||
664 | partitions = host->board->partition_info(mtd->size, | ||
665 | &num_partitions); | ||
666 | |||
667 | if ((!partitions) || (num_partitions == 0)) { | ||
668 | printk(KERN_ERR "atmel_nand: No partitions defined, or unsupported device.\n"); | ||
669 | res = -ENXIO; | ||
670 | goto err_no_partitions; | ||
671 | } | ||
672 | |||
673 | res = mtd_device_register(mtd, partitions, num_partitions); | ||
674 | if (!res) | 618 | if (!res) |
675 | return res; | 619 | return res; |
676 | 620 | ||
677 | err_no_partitions: | ||
678 | nand_release(mtd); | ||
679 | err_scan_tail: | 621 | err_scan_tail: |
680 | err_scan_ident: | 622 | err_scan_ident: |
681 | err_no_card: | 623 | err_no_card: |