aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/mxc_nand.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 67ddc35ca7bc..1131ad126fd2 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -228,16 +228,25 @@ static void send_addr(struct mxc_nand_host *host, uint16_t addr, int islast)
228 wait_op_done(host, TROP_US_DELAY, islast); 228 wait_op_done(host, TROP_US_DELAY, islast);
229} 229}
230 230
231static void send_page(struct mxc_nand_host *host, uint8_t buf_id, 231static void send_page(struct mxc_nand_host *host, unsigned int ops)
232 unsigned int ops)
233{ 232{
234 /* NANDFC buffer 0 is used for page read/write */ 233 int bufs, i;
235 writew(buf_id, host->regs + NFC_BUF_ADDR);
236 234
237 writew(ops, host->regs + NFC_CONFIG2); 235 if (host->pagesize_2k)
236 bufs = 4;
237 else
238 bufs = 1;
238 239
239 /* Wait for operation to complete */ 240 for (i = 0; i < bufs; i++) {
240 wait_op_done(host, TROP_US_DELAY, true); 241
242 /* NANDFC buffer 0 is used for page read/write */
243 writew(i, host->regs + NFC_BUF_ADDR);
244
245 writew(ops, host->regs + NFC_CONFIG2);
246
247 /* Wait for operation to complete */
248 wait_op_done(host, TROP_US_DELAY, true);
249 }
241} 250}
242 251
243/* Request the NANDFC to perform a read of the NAND device ID. */ 252/* Request the NANDFC to perform a read of the NAND device ID. */
@@ -565,16 +574,10 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
565 send_cmd(host, command, false); 574 send_cmd(host, command, false);
566 mxc_do_addr_cycle(mtd, column, page_addr); 575 mxc_do_addr_cycle(mtd, column, page_addr);
567 576
568 if (host->pagesize_2k) { 577 if (host->pagesize_2k)
569 /* send read confirm command */
570 send_cmd(host, NAND_CMD_READSTART, true); 578 send_cmd(host, NAND_CMD_READSTART, true);
571 /* read for each AREA */ 579
572 send_page(host, 0, NFC_OUTPUT); 580 send_page(host, NFC_OUTPUT);
573 send_page(host, 1, NFC_OUTPUT);
574 send_page(host, 2, NFC_OUTPUT);
575 send_page(host, 3, NFC_OUTPUT);
576 } else
577 send_page(host, 0, NFC_OUTPUT);
578 581
579 memcpy(host->data_buf, host->regs + MAIN_AREA0, mtd->writesize); 582 memcpy(host->data_buf, host->regs + MAIN_AREA0, mtd->writesize);
580 copy_spare(mtd, true); 583 copy_spare(mtd, true);
@@ -614,15 +617,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
614 case NAND_CMD_PAGEPROG: 617 case NAND_CMD_PAGEPROG:
615 memcpy(host->regs + MAIN_AREA0, host->data_buf, mtd->writesize); 618 memcpy(host->regs + MAIN_AREA0, host->data_buf, mtd->writesize);
616 copy_spare(mtd, false); 619 copy_spare(mtd, false);
617 send_page(host, 0, NFC_INPUT); 620 send_page(host, NFC_INPUT);
618
619 if (host->pagesize_2k) {
620 /* data in 4 areas datas */
621 send_page(host, 1, NFC_INPUT);
622 send_page(host, 2, NFC_INPUT);
623 send_page(host, 3, NFC_INPUT);
624 }
625
626 send_cmd(host, command, true); 621 send_cmd(host, command, true);
627 mxc_do_addr_cycle(mtd, column, page_addr); 622 mxc_do_addr_cycle(mtd, column, page_addr);
628 break; 623 break;