aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-12-09 01:14:38 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-12-09 01:14:38 -0500
commitbcd6acd51f3d4d1ada201e9bc5c40a31d6d80c71 (patch)
tree2f6dffd2d3e4dd67355a224de7e7a960335a92fd /drivers/mtd/nand
parent11c34c7deaeeebcee342cbc35e1bb2a6711b2431 (diff)
parent3ff6a468b45b5dfeb0e903e56f4eb27d34b2437c (diff)
Merge commit 'origin/master' into next
Conflicts: include/linux/kvm.h
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/Kconfig2
-rw-r--r--drivers/mtd/nand/ams-delta.c2
-rw-r--r--drivers/mtd/nand/omap2.c6
-rw-r--r--drivers/mtd/nand/pxa3xx_nand.c82
4 files changed, 73 insertions, 19 deletions
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 2fda0b615246..8f8e87b7ed64 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -358,7 +358,7 @@ endchoice
358 358
359config MTD_NAND_PXA3xx 359config MTD_NAND_PXA3xx
360 tristate "Support for NAND flash devices on PXA3xx" 360 tristate "Support for NAND flash devices on PXA3xx"
361 depends on MTD_NAND && PXA3xx 361 depends on MTD_NAND && (PXA3xx || ARCH_MMP)
362 help 362 help
363 This enables the driver for the NAND flash device found on 363 This enables the driver for the NAND flash device found on
364 PXA3xx processors 364 PXA3xx processors
diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index 005b91f096f2..2548e1065bf8 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -25,7 +25,7 @@
25#include <mach/hardware.h> 25#include <mach/hardware.h>
26#include <asm/sizes.h> 26#include <asm/sizes.h>
27#include <mach/gpio.h> 27#include <mach/gpio.h>
28#include <mach/board-ams-delta.h> 28#include <plat/board-ams-delta.h>
29 29
30/* 30/*
31 * MTD structure for E3 (Delta) 31 * MTD structure for E3 (Delta)
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 090ab87086b5..1bb799f0125c 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -18,9 +18,9 @@
18#include <linux/mtd/partitions.h> 18#include <linux/mtd/partitions.h>
19#include <linux/io.h> 19#include <linux/io.h>
20 20
21#include <mach/dma.h> 21#include <plat/dma.h>
22#include <mach/gpmc.h> 22#include <plat/gpmc.h>
23#include <mach/nand.h> 23#include <plat/nand.h>
24 24
25#define GPMC_IRQ_STATUS 0x18 25#define GPMC_IRQ_STATUS 0x18
26#define GPMC_ECC_CONFIG 0x1F4 26#define GPMC_ECC_CONFIG 0x1F4
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 6ea520ae2410..1a5a0365c983 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -9,6 +9,7 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11 11
12#include <linux/kernel.h>
12#include <linux/module.h> 13#include <linux/module.h>
13#include <linux/interrupt.h> 14#include <linux/interrupt.h>
14#include <linux/platform_device.h> 15#include <linux/platform_device.h>
@@ -22,7 +23,7 @@
22#include <linux/irq.h> 23#include <linux/irq.h>
23 24
24#include <mach/dma.h> 25#include <mach/dma.h>
25#include <mach/pxa3xx_nand.h> 26#include <plat/pxa3xx_nand.h>
26 27
27#define CHIP_DELAY_TIMEOUT (2 * HZ/10) 28#define CHIP_DELAY_TIMEOUT (2 * HZ/10)
28 29
@@ -84,10 +85,6 @@
84#define NDCB0_CMD1_MASK (0xff) 85#define NDCB0_CMD1_MASK (0xff)
85#define NDCB0_ADDR_CYC_SHIFT (16) 86#define NDCB0_ADDR_CYC_SHIFT (16)
86 87
87/* dma-able I/O address for the NAND data and commands */
88#define NDCB0_DMA_ADDR (0x43100048)
89#define NDDB_DMA_ADDR (0x43100040)
90
91/* macros for registers read/write */ 88/* macros for registers read/write */
92#define nand_writel(info, off, val) \ 89#define nand_writel(info, off, val) \
93 __raw_writel((val), (info)->mmio_base + (off)) 90 __raw_writel((val), (info)->mmio_base + (off))
@@ -123,6 +120,7 @@ struct pxa3xx_nand_info {
123 120
124 struct clk *clk; 121 struct clk *clk;
125 void __iomem *mmio_base; 122 void __iomem *mmio_base;
123 unsigned long mmio_phys;
126 124
127 unsigned int buf_start; 125 unsigned int buf_start;
128 unsigned int buf_count; 126 unsigned int buf_count;
@@ -228,13 +226,35 @@ static struct pxa3xx_nand_flash samsung512MbX16 = {
228 .chip_id = 0x46ec, 226 .chip_id = 0x46ec,
229}; 227};
230 228
229static struct pxa3xx_nand_flash samsung2GbX8 = {
230 .timing = &samsung512MbX16_timing,
231 .cmdset = &smallpage_cmdset,
232 .page_per_block = 64,
233 .page_size = 2048,
234 .flash_width = 8,
235 .dfc_width = 8,
236 .num_blocks = 2048,
237 .chip_id = 0xdaec,
238};
239
240static struct pxa3xx_nand_flash samsung32GbX8 = {
241 .timing = &samsung512MbX16_timing,
242 .cmdset = &smallpage_cmdset,
243 .page_per_block = 128,
244 .page_size = 4096,
245 .flash_width = 8,
246 .dfc_width = 8,
247 .num_blocks = 8192,
248 .chip_id = 0xd7ec,
249};
250
231static struct pxa3xx_nand_timing micron_timing = { 251static struct pxa3xx_nand_timing micron_timing = {
232 .tCH = 10, 252 .tCH = 10,
233 .tCS = 25, 253 .tCS = 25,
234 .tWH = 15, 254 .tWH = 15,
235 .tWP = 25, 255 .tWP = 25,
236 .tRH = 15, 256 .tRH = 15,
237 .tRP = 25, 257 .tRP = 30,
238 .tR = 25000, 258 .tR = 25000,
239 .tWHR = 60, 259 .tWHR = 60,
240 .tAR = 10, 260 .tAR = 10,
@@ -262,6 +282,28 @@ static struct pxa3xx_nand_flash micron1GbX16 = {
262 .chip_id = 0xb12c, 282 .chip_id = 0xb12c,
263}; 283};
264 284
285static struct pxa3xx_nand_flash micron4GbX8 = {
286 .timing = &micron_timing,
287 .cmdset = &largepage_cmdset,
288 .page_per_block = 64,
289 .page_size = 2048,
290 .flash_width = 8,
291 .dfc_width = 8,
292 .num_blocks = 4096,
293 .chip_id = 0xdc2c,
294};
295
296static struct pxa3xx_nand_flash micron4GbX16 = {
297 .timing = &micron_timing,
298 .cmdset = &largepage_cmdset,
299 .page_per_block = 64,
300 .page_size = 2048,
301 .flash_width = 16,
302 .dfc_width = 16,
303 .num_blocks = 4096,
304 .chip_id = 0xcc2c,
305};
306
265static struct pxa3xx_nand_timing stm2GbX16_timing = { 307static struct pxa3xx_nand_timing stm2GbX16_timing = {
266 .tCH = 10, 308 .tCH = 10,
267 .tCS = 35, 309 .tCS = 35,
@@ -287,8 +329,12 @@ static struct pxa3xx_nand_flash stm2GbX16 = {
287 329
288static struct pxa3xx_nand_flash *builtin_flash_types[] = { 330static struct pxa3xx_nand_flash *builtin_flash_types[] = {
289 &samsung512MbX16, 331 &samsung512MbX16,
332 &samsung2GbX8,
333 &samsung32GbX8,
290 &micron1GbX8, 334 &micron1GbX8,
291 &micron1GbX16, 335 &micron1GbX16,
336 &micron4GbX8,
337 &micron4GbX16,
292 &stm2GbX16, 338 &stm2GbX16,
293}; 339};
294#endif /* CONFIG_MTD_NAND_PXA3xx_BUILTIN */ 340#endif /* CONFIG_MTD_NAND_PXA3xx_BUILTIN */
@@ -489,7 +535,7 @@ static int handle_data_pio(struct pxa3xx_nand_info *info)
489 switch (info->state) { 535 switch (info->state) {
490 case STATE_PIO_WRITING: 536 case STATE_PIO_WRITING:
491 __raw_writesl(info->mmio_base + NDDB, info->data_buff, 537 __raw_writesl(info->mmio_base + NDDB, info->data_buff,
492 info->data_size << 2); 538 DIV_ROUND_UP(info->data_size, 4));
493 539
494 enable_int(info, NDSR_CS0_BBD | NDSR_CS0_CMDD); 540 enable_int(info, NDSR_CS0_BBD | NDSR_CS0_CMDD);
495 541
@@ -501,7 +547,7 @@ static int handle_data_pio(struct pxa3xx_nand_info *info)
501 break; 547 break;
502 case STATE_PIO_READING: 548 case STATE_PIO_READING:
503 __raw_readsl(info->mmio_base + NDDB, info->data_buff, 549 __raw_readsl(info->mmio_base + NDDB, info->data_buff,
504 info->data_size << 2); 550 DIV_ROUND_UP(info->data_size, 4));
505 break; 551 break;
506 default: 552 default:
507 printk(KERN_ERR "%s: invalid state %d\n", __func__, 553 printk(KERN_ERR "%s: invalid state %d\n", __func__,
@@ -523,11 +569,11 @@ static void start_data_dma(struct pxa3xx_nand_info *info, int dir_out)
523 569
524 if (dir_out) { 570 if (dir_out) {
525 desc->dsadr = info->data_buff_phys; 571 desc->dsadr = info->data_buff_phys;
526 desc->dtadr = NDDB_DMA_ADDR; 572 desc->dtadr = info->mmio_phys + NDDB;
527 desc->dcmd |= DCMD_INCSRCADDR | DCMD_FLOWTRG; 573 desc->dcmd |= DCMD_INCSRCADDR | DCMD_FLOWTRG;
528 } else { 574 } else {
529 desc->dtadr = info->data_buff_phys; 575 desc->dtadr = info->data_buff_phys;
530 desc->dsadr = NDDB_DMA_ADDR; 576 desc->dsadr = info->mmio_phys + NDDB;
531 desc->dcmd |= DCMD_INCTRGADDR | DCMD_FLOWSRC; 577 desc->dcmd |= DCMD_INCTRGADDR | DCMD_FLOWSRC;
532 } 578 }
533 579
@@ -669,6 +715,7 @@ static void pxa3xx_nand_cmdfunc(struct mtd_info *mtd, unsigned command,
669 /* disable HW ECC to get all the OOB data */ 715 /* disable HW ECC to get all the OOB data */
670 info->buf_count = mtd->writesize + mtd->oobsize; 716 info->buf_count = mtd->writesize + mtd->oobsize;
671 info->buf_start = mtd->writesize + column; 717 info->buf_start = mtd->writesize + column;
718 memset(info->data_buff, 0xFF, info->buf_count);
672 719
673 if (prepare_read_prog_cmd(info, cmdset->read1, column, page_addr)) 720 if (prepare_read_prog_cmd(info, cmdset->read1, column, page_addr))
674 break; 721 break;
@@ -1239,13 +1286,17 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
1239 ret = -ENODEV; 1286 ret = -ENODEV;
1240 goto fail_free_res; 1287 goto fail_free_res;
1241 } 1288 }
1289 info->mmio_phys = r->start;
1242 1290
1243 ret = pxa3xx_nand_init_buff(info); 1291 ret = pxa3xx_nand_init_buff(info);
1244 if (ret) 1292 if (ret)
1245 goto fail_free_io; 1293 goto fail_free_io;
1246 1294
1247 ret = request_irq(IRQ_NAND, pxa3xx_nand_irq, IRQF_DISABLED, 1295 /* initialize all interrupts to be disabled */
1248 pdev->name, info); 1296 disable_int(info, NDSR_MASK);
1297
1298 ret = request_irq(irq, pxa3xx_nand_irq, IRQF_DISABLED,
1299 pdev->name, info);
1249 if (ret < 0) { 1300 if (ret < 0) {
1250 dev_err(&pdev->dev, "failed to request IRQ\n"); 1301 dev_err(&pdev->dev, "failed to request IRQ\n");
1251 goto fail_free_buf; 1302 goto fail_free_buf;
@@ -1271,7 +1322,7 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
1271 return add_mtd_partitions(mtd, pdata->parts, pdata->nr_parts); 1322 return add_mtd_partitions(mtd, pdata->parts, pdata->nr_parts);
1272 1323
1273fail_free_irq: 1324fail_free_irq:
1274 free_irq(IRQ_NAND, info); 1325 free_irq(irq, info);
1275fail_free_buf: 1326fail_free_buf:
1276 if (use_dma) { 1327 if (use_dma) {
1277 pxa_free_dma(info->data_dma_ch); 1328 pxa_free_dma(info->data_dma_ch);
@@ -1296,12 +1347,15 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
1296 struct mtd_info *mtd = platform_get_drvdata(pdev); 1347 struct mtd_info *mtd = platform_get_drvdata(pdev);
1297 struct pxa3xx_nand_info *info = mtd->priv; 1348 struct pxa3xx_nand_info *info = mtd->priv;
1298 struct resource *r; 1349 struct resource *r;
1350 int irq;
1299 1351
1300 platform_set_drvdata(pdev, NULL); 1352 platform_set_drvdata(pdev, NULL);
1301 1353
1302 del_mtd_device(mtd); 1354 del_mtd_device(mtd);
1303 del_mtd_partitions(mtd); 1355 del_mtd_partitions(mtd);
1304 free_irq(IRQ_NAND, info); 1356 irq = platform_get_irq(pdev, 0);
1357 if (irq >= 0)
1358 free_irq(irq, info);
1305 if (use_dma) { 1359 if (use_dma) {
1306 pxa_free_dma(info->data_dma_ch); 1360 pxa_free_dma(info->data_dma_ch);
1307 dma_free_writecombine(&pdev->dev, info->data_buff_size, 1361 dma_free_writecombine(&pdev->dev, info->data_buff_size,