diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2009-06-04 11:18:01 -0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-11-12 02:32:39 -0500 |
commit | 89121a6bfecf4bd81b360fa1b3ae8875ed3e4a71 (patch) | |
tree | 451bd9c5a2761fe9cda8ca5b386d6834e3cc8252 /drivers/mtd | |
parent | f8f9608d9b7a5b3349605284a4f3876e898413f1 (diff) |
mxc nand: simplify command processing
Instead of having two switch/case with other operations
in between, use only one switch/case
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/nand/mxc_nand.c | 81 |
1 files changed, 35 insertions, 46 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index 03d20086170b..67ddc35ca7bc 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -533,7 +533,6 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, | |||
533 | { | 533 | { |
534 | struct nand_chip *nand_chip = mtd->priv; | 534 | struct nand_chip *nand_chip = mtd->priv; |
535 | struct mxc_nand_host *host = nand_chip->priv; | 535 | struct mxc_nand_host *host = nand_chip->priv; |
536 | int useirq = true; | ||
537 | 536 | ||
538 | DEBUG(MTD_DEBUG_LEVEL3, | 537 | DEBUG(MTD_DEBUG_LEVEL3, |
539 | "mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n", | 538 | "mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n", |
@@ -548,19 +547,37 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, | |||
548 | case NAND_CMD_STATUS: | 547 | case NAND_CMD_STATUS: |
549 | host->buf_start = 0; | 548 | host->buf_start = 0; |
550 | host->status_request = true; | 549 | host->status_request = true; |
551 | break; | ||
552 | 550 | ||
553 | case NAND_CMD_READ0: | 551 | send_cmd(host, command, true); |
554 | host->buf_start = column; | 552 | mxc_do_addr_cycle(mtd, column, page_addr); |
555 | useirq = false; | ||
556 | break; | 553 | break; |
557 | 554 | ||
555 | case NAND_CMD_READ0: | ||
558 | case NAND_CMD_READOOB: | 556 | case NAND_CMD_READOOB: |
559 | host->buf_start = column + mtd->writesize; | 557 | if (command == NAND_CMD_READ0) |
558 | host->buf_start = column; | ||
559 | else | ||
560 | host->buf_start = column + mtd->writesize; | ||
560 | 561 | ||
561 | useirq = false; | ||
562 | if (host->pagesize_2k) | 562 | if (host->pagesize_2k) |
563 | command = NAND_CMD_READ0; /* only READ0 is valid */ | 563 | command = NAND_CMD_READ0; /* only READ0 is valid */ |
564 | |||
565 | send_cmd(host, command, false); | ||
566 | mxc_do_addr_cycle(mtd, column, page_addr); | ||
567 | |||
568 | if (host->pagesize_2k) { | ||
569 | /* send read confirm command */ | ||
570 | send_cmd(host, NAND_CMD_READSTART, true); | ||
571 | /* read for each AREA */ | ||
572 | send_page(host, 0, 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 | |||
579 | memcpy(host->data_buf, host->regs + MAIN_AREA0, mtd->writesize); | ||
580 | copy_spare(mtd, true); | ||
564 | break; | 581 | break; |
565 | 582 | ||
566 | case NAND_CMD_SEQIN: | 583 | case NAND_CMD_SEQIN: |
@@ -589,7 +606,9 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, | |||
589 | if (!host->pagesize_2k) | 606 | if (!host->pagesize_2k) |
590 | send_cmd(host, NAND_CMD_READ0, false); | 607 | send_cmd(host, NAND_CMD_READ0, false); |
591 | } | 608 | } |
592 | useirq = false; | 609 | |
610 | send_cmd(host, command, false); | ||
611 | mxc_do_addr_cycle(mtd, column, page_addr); | ||
593 | break; | 612 | break; |
594 | 613 | ||
595 | case NAND_CMD_PAGEPROG: | 614 | case NAND_CMD_PAGEPROG: |
@@ -604,51 +623,21 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, | |||
604 | send_page(host, 3, NFC_INPUT); | 623 | send_page(host, 3, NFC_INPUT); |
605 | } | 624 | } |
606 | 625 | ||
607 | break; | 626 | send_cmd(host, command, true); |
608 | 627 | mxc_do_addr_cycle(mtd, column, page_addr); | |
609 | case NAND_CMD_ERASE1: | ||
610 | useirq = false; | ||
611 | break; | ||
612 | } | ||
613 | |||
614 | /* Write out the command to the device. */ | ||
615 | send_cmd(host, command, useirq); | ||
616 | mxc_do_addr_cycle(mtd, column, page_addr); | ||
617 | |||
618 | /* Command post-processing step */ | ||
619 | switch (command) { | ||
620 | |||
621 | case NAND_CMD_RESET: | ||
622 | break; | ||
623 | |||
624 | case NAND_CMD_READOOB: | ||
625 | case NAND_CMD_READ0: | ||
626 | if (host->pagesize_2k) { | ||
627 | /* send read confirm command */ | ||
628 | send_cmd(host, NAND_CMD_READSTART, true); | ||
629 | /* read for each AREA */ | ||
630 | send_page(host, 0, NFC_OUTPUT); | ||
631 | send_page(host, 1, NFC_OUTPUT); | ||
632 | send_page(host, 2, NFC_OUTPUT); | ||
633 | send_page(host, 3, NFC_OUTPUT); | ||
634 | } else | ||
635 | send_page(host, 0, NFC_OUTPUT); | ||
636 | |||
637 | memcpy(host->data_buf, host->regs + MAIN_AREA0, mtd->writesize); | ||
638 | copy_spare(mtd, true); | ||
639 | break; | 628 | break; |
640 | 629 | ||
641 | case NAND_CMD_READID: | 630 | case NAND_CMD_READID: |
631 | send_cmd(host, command, true); | ||
632 | mxc_do_addr_cycle(mtd, column, page_addr); | ||
642 | send_read_id(host); | 633 | send_read_id(host); |
643 | break; | 634 | break; |
644 | 635 | ||
645 | case NAND_CMD_PAGEPROG: | 636 | case NAND_CMD_ERASE1: |
646 | break; | ||
647 | |||
648 | case NAND_CMD_STATUS: | ||
649 | break; | ||
650 | |||
651 | case NAND_CMD_ERASE2: | 637 | case NAND_CMD_ERASE2: |
638 | send_cmd(host, command, false); | ||
639 | mxc_do_addr_cycle(mtd, column, page_addr); | ||
640 | |||
652 | break; | 641 | break; |
653 | } | 642 | } |
654 | } | 643 | } |