Commit b8db2f51 authored by Sascha Hauer's avatar Sascha Hauer Committed by David Woodhouse

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: default avatarSascha Hauer <s.hauer@pengutronix.de>
Acked-by: default avatarJohn Ogness <john.ogness@linutronix.de>
Tested-by: default avatarJohn Ogness <john.ogness@linutronix.de>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 53d1e137
...@@ -67,7 +67,9 @@ ...@@ -67,7 +67,9 @@
#define NFC_V1_V2_CONFIG1_BIG (1 << 5) #define NFC_V1_V2_CONFIG1_BIG (1 << 5)
#define NFC_V1_V2_CONFIG1_RST (1 << 6) #define NFC_V1_V2_CONFIG1_RST (1 << 6)
#define NFC_V1_V2_CONFIG1_CE (1 << 7) #define NFC_V1_V2_CONFIG1_CE (1 << 7)
#define NFC_V1_V2_CONFIG1_ONE_CYCLE (1 << 8) #define NFC_V2_CONFIG1_ONE_CYCLE (1 << 8)
#define NFC_V2_CONFIG1_PPB(x) (((x) & 0x3) << 9)
#define NFC_V2_CONFIG1_FP_INT (1 << 11)
#define NFC_V1_V2_CONFIG2_INT (1 << 15) #define NFC_V1_V2_CONFIG2_INT (1 << 15)
...@@ -729,27 +731,30 @@ static void preset_v1_v2(struct mtd_info *mtd) ...@@ -729,27 +731,30 @@ static void preset_v1_v2(struct mtd_info *mtd)
{ {
struct nand_chip *nand_chip = mtd->priv; struct nand_chip *nand_chip = mtd->priv;
struct mxc_nand_host *host = nand_chip->priv; struct mxc_nand_host *host = nand_chip->priv;
uint16_t tmp; uint16_t config1 = 0;
/* enable interrupt, disable spare enable */ if (nand_chip->ecc.mode == NAND_ECC_HW)
tmp = readw(NFC_V1_V2_CONFIG1); config1 |= NFC_V1_V2_CONFIG1_ECC_EN;
tmp &= ~NFC_V1_V2_CONFIG1_INT_MSK;
tmp &= ~NFC_V1_V2_CONFIG1_SP_EN; if (nfc_is_v21())
if (nand_chip->ecc.mode == NAND_ECC_HW) { config1 |= NFC_V2_CONFIG1_FP_INT;
tmp |= NFC_V1_V2_CONFIG1_ECC_EN;
} else { if (!cpu_is_mx21())
tmp &= ~NFC_V1_V2_CONFIG1_ECC_EN; config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
}
if (nfc_is_v21() && mtd->writesize) { if (nfc_is_v21() && mtd->writesize) {
uint16_t pages_per_block = mtd->erasesize / mtd->writesize;
host->eccsize = get_eccsize(mtd); host->eccsize = get_eccsize(mtd);
if (host->eccsize == 4) if (host->eccsize == 4)
tmp |= NFC_V2_CONFIG1_ECC_MODE_4; config1 |= NFC_V2_CONFIG1_ECC_MODE_4;
config1 |= NFC_V2_CONFIG1_PPB(ffs(pages_per_block) - 6);
} else { } else {
host->eccsize = 1; host->eccsize = 1;
} }
writew(tmp, NFC_V1_V2_CONFIG1); writew(config1, NFC_V1_V2_CONFIG1);
/* preset operation */ /* preset operation */
/* Unlock the internal RAM Buffer */ /* Unlock the internal RAM Buffer */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment