diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2009-06-02 05:47:59 -0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-11-12 02:31:49 -0500 |
commit | a3e65b64d5067f86b929eabde82f132b81437da8 (patch) | |
tree | f7e000413355bd3fb9bb58339b85fc076fddba22 /drivers/mtd | |
parent | 06ecb04ac5c038248d2bcee92a2a4259f2acfa31 (diff) |
mxc_nand: introduce mxc_do_addr_cycle
This factors the address cycle to a seperate function. This
becomes useful in a later patch where we can simplify the
command processing by making use of this function.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/nand/mxc_nand.c | 87 |
1 files changed, 47 insertions, 40 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index 8aa8a429e6b8..325645c60488 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -658,6 +658,52 @@ static void mxc_nand_select_chip(struct mtd_info *mtd, int chip) | |||
658 | } | 658 | } |
659 | } | 659 | } |
660 | 660 | ||
661 | static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr) | ||
662 | { | ||
663 | struct nand_chip *nand_chip = mtd->priv; | ||
664 | struct mxc_nand_host *host = nand_chip->priv; | ||
665 | |||
666 | /* Write out column address, if necessary */ | ||
667 | if (column != -1) { | ||
668 | /* | ||
669 | * MXC NANDFC can only perform full page+spare or | ||
670 | * spare-only read/write. When the upper layers | ||
671 | * layers perform a read/write buf operation, | ||
672 | * we will used the saved column adress to index into | ||
673 | * the full page. | ||
674 | */ | ||
675 | send_addr(host, 0, page_addr == -1); | ||
676 | if (host->pagesize_2k) | ||
677 | /* another col addr cycle for 2k page */ | ||
678 | send_addr(host, 0, false); | ||
679 | } | ||
680 | |||
681 | /* Write out page address, if necessary */ | ||
682 | if (page_addr != -1) { | ||
683 | /* paddr_0 - p_addr_7 */ | ||
684 | send_addr(host, (page_addr & 0xff), false); | ||
685 | |||
686 | if (host->pagesize_2k) { | ||
687 | if (mtd->size >= 0x10000000) { | ||
688 | /* paddr_8 - paddr_15 */ | ||
689 | send_addr(host, (page_addr >> 8) & 0xff, false); | ||
690 | send_addr(host, (page_addr >> 16) & 0xff, true); | ||
691 | } else | ||
692 | /* paddr_8 - paddr_15 */ | ||
693 | send_addr(host, (page_addr >> 8) & 0xff, true); | ||
694 | } else { | ||
695 | /* One more address cycle for higher density devices */ | ||
696 | if (mtd->size >= 0x4000000) { | ||
697 | /* paddr_8 - paddr_15 */ | ||
698 | send_addr(host, (page_addr >> 8) & 0xff, false); | ||
699 | send_addr(host, (page_addr >> 16) & 0xff, true); | ||
700 | } else | ||
701 | /* paddr_8 - paddr_15 */ | ||
702 | send_addr(host, (page_addr >> 8) & 0xff, true); | ||
703 | } | ||
704 | } | ||
705 | } | ||
706 | |||
661 | /* Used by the upper layer to write command to NAND Flash for | 707 | /* Used by the upper layer to write command to NAND Flash for |
662 | * different operations to be carried out on NAND Flash */ | 708 | * different operations to be carried out on NAND Flash */ |
663 | static void mxc_nand_command(struct mtd_info *mtd, unsigned command, | 709 | static void mxc_nand_command(struct mtd_info *mtd, unsigned command, |
@@ -746,46 +792,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, | |||
746 | 792 | ||
747 | /* Write out the command to the device. */ | 793 | /* Write out the command to the device. */ |
748 | send_cmd(host, command, useirq); | 794 | send_cmd(host, command, useirq); |
749 | 795 | mxc_do_addr_cycle(mtd, column, page_addr); | |
750 | /* Write out column address, if necessary */ | ||
751 | if (column != -1) { | ||
752 | /* | ||
753 | * MXC NANDFC can only perform full page+spare or | ||
754 | * spare-only read/write. When the upper layers | ||
755 | * layers perform a read/write buf operation, | ||
756 | * we will used the saved column adress to index into | ||
757 | * the full page. | ||
758 | */ | ||
759 | send_addr(host, 0, page_addr == -1); | ||
760 | if (host->pagesize_2k) | ||
761 | /* another col addr cycle for 2k page */ | ||
762 | send_addr(host, 0, false); | ||
763 | } | ||
764 | |||
765 | /* Write out page address, if necessary */ | ||
766 | if (page_addr != -1) { | ||
767 | /* paddr_0 - p_addr_7 */ | ||
768 | send_addr(host, (page_addr & 0xff), false); | ||
769 | |||
770 | if (host->pagesize_2k) { | ||
771 | if (mtd->size >= 0x10000000) { | ||
772 | /* paddr_8 - paddr_15 */ | ||
773 | send_addr(host, (page_addr >> 8) & 0xff, false); | ||
774 | send_addr(host, (page_addr >> 16) & 0xff, true); | ||
775 | } else | ||
776 | /* paddr_8 - paddr_15 */ | ||
777 | send_addr(host, (page_addr >> 8) & 0xff, true); | ||
778 | } else { | ||
779 | /* One more address cycle for higher density devices */ | ||
780 | if (mtd->size >= 0x4000000) { | ||
781 | /* paddr_8 - paddr_15 */ | ||
782 | send_addr(host, (page_addr >> 8) & 0xff, false); | ||
783 | send_addr(host, (page_addr >> 16) & 0xff, true); | ||
784 | } else | ||
785 | /* paddr_8 - paddr_15 */ | ||
786 | send_addr(host, (page_addr >> 8) & 0xff, true); | ||
787 | } | ||
788 | } | ||
789 | 796 | ||
790 | /* Command post-processing step */ | 797 | /* Command post-processing step */ |
791 | switch (command) { | 798 | switch (command) { |