aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-10-05 05:24:02 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2009-11-12 02:33:10 -0500
commit2d69c7fadd8580a7cea3ae0caa90a1c2a92ab021 (patch)
treeeab346df3403116c7c1e65527705993f4776c6bf /drivers/mtd/nand
parentc6de7e1bb8d6e1b3ae318bf9fbe84557d7c8baec (diff)
mxc_nand: Get rid of pagesize_2k flag
Later versions of this controller also allow 4k pagesize, so use mtd->writesize instead of a flag. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/mxc_nand.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index c84fd6c35496..09b9aab6823d 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -101,7 +101,6 @@ struct mxc_nand_host {
101 void __iomem *base; 101 void __iomem *base;
102 void __iomem *regs; 102 void __iomem *regs;
103 int status_request; 103 int status_request;
104 int pagesize_2k;
105 struct clk *clk; 104 struct clk *clk;
106 int clk_act; 105 int clk_act;
107 int irq; 106 int irq;
@@ -214,11 +213,13 @@ static void send_addr(struct mxc_nand_host *host, uint16_t addr, int islast)
214 wait_op_done(host, TROP_US_DELAY, islast); 213 wait_op_done(host, TROP_US_DELAY, islast);
215} 214}
216 215
217static void send_page(struct mxc_nand_host *host, unsigned int ops) 216static void send_page(struct mtd_info *mtd, unsigned int ops)
218{ 217{
218 struct nand_chip *nand_chip = mtd->priv;
219 struct mxc_nand_host *host = nand_chip->priv;
219 int bufs, i; 220 int bufs, i;
220 221
221 if (host->pagesize_2k) 222 if (mtd->writesize > 512)
222 bufs = 4; 223 bufs = 4;
223 else 224 else
224 bufs = 1; 225 bufs = 1;
@@ -490,7 +491,7 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
490 * the full page. 491 * the full page.
491 */ 492 */
492 send_addr(host, 0, page_addr == -1); 493 send_addr(host, 0, page_addr == -1);
493 if (host->pagesize_2k) 494 if (mtd->writesize > 512)
494 /* another col addr cycle for 2k page */ 495 /* another col addr cycle for 2k page */
495 send_addr(host, 0, false); 496 send_addr(host, 0, false);
496 } 497 }
@@ -500,7 +501,7 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
500 /* paddr_0 - p_addr_7 */ 501 /* paddr_0 - p_addr_7 */
501 send_addr(host, (page_addr & 0xff), false); 502 send_addr(host, (page_addr & 0xff), false);
502 503
503 if (host->pagesize_2k) { 504 if (mtd->writesize > 512) {
504 if (mtd->size >= 0x10000000) { 505 if (mtd->size >= 0x10000000) {
505 /* paddr_8 - paddr_15 */ 506 /* paddr_8 - paddr_15 */
506 send_addr(host, (page_addr >> 8) & 0xff, false); 507 send_addr(host, (page_addr >> 8) & 0xff, false);
@@ -554,16 +555,16 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
554 else 555 else
555 host->buf_start = column + mtd->writesize; 556 host->buf_start = column + mtd->writesize;
556 557
557 if (host->pagesize_2k) 558 if (mtd->writesize > 512)
558 command = NAND_CMD_READ0; /* only READ0 is valid */ 559 command = NAND_CMD_READ0; /* only READ0 is valid */
559 560
560 send_cmd(host, command, false); 561 send_cmd(host, command, false);
561 mxc_do_addr_cycle(mtd, column, page_addr); 562 mxc_do_addr_cycle(mtd, column, page_addr);
562 563
563 if (host->pagesize_2k) 564 if (mtd->writesize > 512)
564 send_cmd(host, NAND_CMD_READSTART, true); 565 send_cmd(host, NAND_CMD_READSTART, true);
565 566
566 send_page(host, NFC_OUTPUT); 567 send_page(mtd, NFC_OUTPUT);
567 568
568 memcpy(host->data_buf, host->main_area0, mtd->writesize); 569 memcpy(host->data_buf, host->main_area0, mtd->writesize);
569 copy_spare(mtd, true); 570 copy_spare(mtd, true);
@@ -578,7 +579,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
578 * pointer to spare area, we must write the whole page 579 * pointer to spare area, we must write the whole page
579 * including OOB together. 580 * including OOB together.
580 */ 581 */
581 if (host->pagesize_2k) 582 if (mtd->writesize > 512)
582 /* call ourself to read a page */ 583 /* call ourself to read a page */
583 mxc_nand_command(mtd, NAND_CMD_READ0, 0, 584 mxc_nand_command(mtd, NAND_CMD_READ0, 0,
584 page_addr); 585 page_addr);
@@ -586,13 +587,13 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
586 host->buf_start = column; 587 host->buf_start = column;
587 588
588 /* Set program pointer to spare region */ 589 /* Set program pointer to spare region */
589 if (!host->pagesize_2k) 590 if (mtd->writesize == 512)
590 send_cmd(host, NAND_CMD_READOOB, false); 591 send_cmd(host, NAND_CMD_READOOB, false);
591 } else { 592 } else {
592 host->buf_start = column; 593 host->buf_start = column;
593 594
594 /* Set program pointer to page start */ 595 /* Set program pointer to page start */
595 if (!host->pagesize_2k) 596 if (mtd->writesize == 512)
596 send_cmd(host, NAND_CMD_READ0, false); 597 send_cmd(host, NAND_CMD_READ0, false);
597 } 598 }
598 599
@@ -603,7 +604,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
603 case NAND_CMD_PAGEPROG: 604 case NAND_CMD_PAGEPROG:
604 memcpy(host->main_area0, host->data_buf, mtd->writesize); 605 memcpy(host->main_area0, host->data_buf, mtd->writesize);
605 copy_spare(mtd, false); 606 copy_spare(mtd, false);
606 send_page(host, NFC_INPUT); 607 send_page(mtd, NFC_INPUT);
607 send_cmd(host, command, true); 608 send_cmd(host, command, true);
608 mxc_do_addr_cycle(mtd, column, page_addr); 609 mxc_do_addr_cycle(mtd, column, page_addr);
609 break; 610 break;
@@ -745,10 +746,8 @@ static int __init mxcnd_probe(struct platform_device *pdev)
745 goto escan; 746 goto escan;
746 } 747 }
747 748
748 if (mtd->writesize == 2048) { 749 if (mtd->writesize == 2048)
749 host->pagesize_2k = 1;
750 this->ecc.layout = &nand_hw_eccoob_largepage; 750 this->ecc.layout = &nand_hw_eccoob_largepage;
751 }
752 751
753 /* second phase scan */ 752 /* second phase scan */
754 if (nand_scan_tail(mtd)) { 753 if (nand_scan_tail(mtd)) {