diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2010-08-09 09:04:19 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-09-13 03:50:34 -0400 |
commit | b8db2f51dcccbaf4d23ed44cd0c64856c58a16c0 (patch) | |
tree | 0ee47ccd841fbc340dec54864d2f40810bfa589a | |
parent | 53d1e137d5ddd8a1c5ec54c5375cb2832e1cbcd1 (diff) |
mtd: mxc_nand: configure pages per block for v2 controller
This patch initializes the pages per block field in CONFIG1 for
v2 controllers. It also sets the FP_INT field. This is the last
field not correctly initialized, so we can switch from
read/modify/write the CONFIG1 reg to just write the correct
value.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: John Ogness <john.ogness@linutronix.de>
Tested-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/nand/mxc_nand.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index 26caa01e34a6..b2828e84d243 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -67,7 +67,9 @@ | |||
67 | #define NFC_V1_V2_CONFIG1_BIG (1 << 5) | 67 | #define NFC_V1_V2_CONFIG1_BIG (1 << 5) |
68 | #define NFC_V1_V2_CONFIG1_RST (1 << 6) | 68 | #define NFC_V1_V2_CONFIG1_RST (1 << 6) |
69 | #define NFC_V1_V2_CONFIG1_CE (1 << 7) | 69 | #define NFC_V1_V2_CONFIG1_CE (1 << 7) |
70 | #define NFC_V1_V2_CONFIG1_ONE_CYCLE (1 << 8) | 70 | #define NFC_V2_CONFIG1_ONE_CYCLE (1 << 8) |
71 | #define NFC_V2_CONFIG1_PPB(x) (((x) & 0x3) << 9) | ||
72 | #define NFC_V2_CONFIG1_FP_INT (1 << 11) | ||
71 | 73 | ||
72 | #define NFC_V1_V2_CONFIG2_INT (1 << 15) | 74 | #define NFC_V1_V2_CONFIG2_INT (1 << 15) |
73 | 75 | ||
@@ -729,27 +731,30 @@ static void preset_v1_v2(struct mtd_info *mtd) | |||
729 | { | 731 | { |
730 | struct nand_chip *nand_chip = mtd->priv; | 732 | struct nand_chip *nand_chip = mtd->priv; |
731 | struct mxc_nand_host *host = nand_chip->priv; | 733 | struct mxc_nand_host *host = nand_chip->priv; |
732 | uint16_t tmp; | 734 | uint16_t config1 = 0; |
733 | 735 | ||
734 | /* enable interrupt, disable spare enable */ | 736 | if (nand_chip->ecc.mode == NAND_ECC_HW) |
735 | tmp = readw(NFC_V1_V2_CONFIG1); | 737 | config1 |= NFC_V1_V2_CONFIG1_ECC_EN; |
736 | tmp &= ~NFC_V1_V2_CONFIG1_INT_MSK; | 738 | |
737 | tmp &= ~NFC_V1_V2_CONFIG1_SP_EN; | 739 | if (nfc_is_v21()) |
738 | if (nand_chip->ecc.mode == NAND_ECC_HW) { | 740 | config1 |= NFC_V2_CONFIG1_FP_INT; |
739 | tmp |= NFC_V1_V2_CONFIG1_ECC_EN; | 741 | |
740 | } else { | 742 | if (!cpu_is_mx21()) |
741 | tmp &= ~NFC_V1_V2_CONFIG1_ECC_EN; | 743 | config1 |= NFC_V1_V2_CONFIG1_INT_MSK; |
742 | } | ||
743 | 744 | ||
744 | if (nfc_is_v21() && mtd->writesize) { | 745 | if (nfc_is_v21() && mtd->writesize) { |
746 | uint16_t pages_per_block = mtd->erasesize / mtd->writesize; | ||
747 | |||
745 | host->eccsize = get_eccsize(mtd); | 748 | host->eccsize = get_eccsize(mtd); |
746 | if (host->eccsize == 4) | 749 | if (host->eccsize == 4) |
747 | tmp |= NFC_V2_CONFIG1_ECC_MODE_4; | 750 | config1 |= NFC_V2_CONFIG1_ECC_MODE_4; |
751 | |||
752 | config1 |= NFC_V2_CONFIG1_PPB(ffs(pages_per_block) - 6); | ||
748 | } else { | 753 | } else { |
749 | host->eccsize = 1; | 754 | host->eccsize = 1; |
750 | } | 755 | } |
751 | 756 | ||
752 | writew(tmp, NFC_V1_V2_CONFIG1); | 757 | writew(config1, NFC_V1_V2_CONFIG1); |
753 | /* preset operation */ | 758 | /* preset operation */ |
754 | 759 | ||
755 | /* Unlock the internal RAM Buffer */ | 760 | /* Unlock the internal RAM Buffer */ |