]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/mtd/nand/atmel_nand.c
mtd: atmel_nand: according to pmecc version to perform 0xff page correction
[karo-tx-uboot.git] / drivers / mtd / nand / atmel_nand.c
index 620b6e8ff9a4cfac6745eb6477718ce14a93d05f..b16e3aa15749428e1a9937f98767ae662b55acb6 100644 (file)
@@ -44,6 +44,7 @@ struct atmel_nand_host {
        u8              pmecc_corr_cap;
        u16             pmecc_sector_size;
        u32             pmecc_index_table_offset;
+       u32             pmecc_version;
 
        int             pmecc_bytes_per_sector;
        int             pmecc_sector_number;
@@ -486,6 +487,10 @@ static int pmecc_correction(struct mtd_info *mtd, u32 pmecc_stat, uint8_t *buf,
        int i, err_nbr, eccbytes;
        uint8_t *buf_pos;
 
+       /* SAMA5D4 PMECC IP can correct errors for all 0xff page */
+       if (host->pmecc_version >= PMECC_VERSION_SAMA5D4)
+               goto normal_check;
+
        eccbytes = nand_chip->ecc.bytes;
        for (i = 0; i < eccbytes; i++)
                if (ecc[i] != 0xff)
@@ -961,6 +966,10 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,
        nand->ecc.write_page = atmel_nand_pmecc_write_page;
        nand->ecc.strength = cap;
 
+       /* Check the PMECC ip version */
+       host->pmecc_version = pmecc_readl(host->pmerrloc, version);
+       dev_dbg(host->dev, "PMECC IP version is: %x\n", host->pmecc_version);
+
        atmel_pmecc_core_init(mtd);
 
        return 0;