summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorPeng Fan <peng.fan@nxp.com>2016-05-08 17:12:12 +0800
committerFrank Li <Frank.Li@nxp.com>2016-05-24 11:09:12 -0500
commitfb748a229919aeae3feb65d398db275ab947cf7c (patch)
treec212694a059dfeba674a98c2e31d1c24e8dbeaec /drivers/mtd
parent79685d64cb1265d9247ac2638919f125242a9880 (diff)
downloadu-boot-imx-fb748a229919aeae3feb65d398db275ab947cf7c.zip
u-boot-imx-fb748a229919aeae3feb65d398db275ab947cf7c.tar.gz
u-boot-imx-fb748a229919aeae3feb65d398db275ab947cf7c.tar.bz2
MLK-12693-2 nand: mxs: correct bitflip for erased NAND page
This patch is a porting of http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/commit/?h=imx_4.1.15_1.0.0_ga&id=e4dacc44d22e9474ec456cb330df525cd805ea38 " i.MX6QP and i.MX7D BCH module integrated a new feature to detect the bitflip number for erased NAND page. So for these two platform, set the erase threshold to gf/2 and if bitflip detected, GPMI driver will correct the data to all 0xFF. Also updated the imx6qp dts file to ditinguish the GPMI module for i.MX6Q with the one for i.MX6QP. " In this patch, i.MX6UL is added and threshold changed to use ecc_strength. Signed-off-by: Peng Fan <peng.fan@nxp.com> (cherry picked from commit 489929be0221bb7d4c46bb5bc6083650b78f73e0)
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/mxs_nand.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 1e93e5f..46dc7b1 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -687,10 +687,14 @@ static int mxs_nand_ecc_read_page(struct mtd_info *mtd, struct nand_chip *nand,
{
struct mxs_nand_info *nand_info = nand->priv;
struct mxs_dma_desc *d;
+#if defined(CONFIG_MX6QP) || defined(CONFIG_MX7) || defined(CONFIG_MX6UL)
+ struct mxs_bch_regs *bch_regs = (struct mxs_bch_regs *)MXS_BCH_BASE;
+#endif
uint32_t channel = MXS_DMA_CHANNEL_AHB_APBH_GPMI0 + nand_info->cur_chip;
uint32_t corrected = 0, failed = 0;
uint8_t *status;
int i, ret;
+ int flag = 0;
/* Compile the DMA descriptor - wait for ready. */
d = mxs_nand_get_dma_desc(nand_info);
@@ -794,8 +798,13 @@ static int mxs_nand_ecc_read_page(struct mtd_info *mtd, struct nand_chip *nand,
if (status[i] == 0x00)
continue;
- if (status[i] == 0xff)
+ if (status[i] == 0xff) {
+#if defined(CONFIG_MX6QP) || defined(CONFIG_MX7) || defined(CONFIG_MX6UL)
+ if (readl(bch_regs->hw_bch_debug1))
+ flag = 1;
+#endif
continue;
+ }
if (status[i] == 0xfe) {
if (mxs_nand_erased_page(mtd, nand,
@@ -827,6 +836,9 @@ static int mxs_nand_ecc_read_page(struct mtd_info *mtd, struct nand_chip *nand,
memcpy(buf, nand_info->data_buf, mtd->writesize);
+ if (flag)
+ memset(buf, 0xff, mtd->writesize);
+
rtn:
mxs_nand_return_dma_descs(nand_info);
@@ -1150,6 +1162,12 @@ static int mxs_nand_scan_bbt(struct mtd_info *mtd)
<< BCH_FLASHLAYOUT1_GF13_0_GF14_1_OFFSET;
writel(tmp, &bch_regs->hw_bch_flash0layout1);
+ /* Set erase threshold to ecc strength for mx6ul, mx6qp and mx7 */
+#if defined(CONFIG_MX6QP) || defined(CONFIG_MX7) || defined(CONFIG_MX6UL)
+ writel(BCH_MODE_ERASE_THRESHOLD(ecc_strength),
+ &bch_regs->hw_bch_mode);
+#endif
+
/* Set *all* chip selects to use layout 0 */
writel(0, &bch_regs->hw_bch_layoutselect);