CR ENGR00048608 Work around untrustworthy NFMS_BIT
authorQuinn Jensen <quinn.jensen@freescale.com>
Thu, 25 Oct 2007 03:25:40 +0000 (21:25 -0600)
committerQuinn Jensen <quinn.jensen@freescale.com>
Thu, 25 Oct 2007 03:25:40 +0000 (21:25 -0600)
Patch for CR ENGR00048608: Work around untrustworthy NFMS_BIT.
Changed to set or clear NFMS bit based on mtd->writesize
in driver specific nand_scan routine.  Applies to linux
2.6.22 kernel on MX platforms.

http://www.bitshrine.org/gpp/linux-2.6.22-mx-CR-ENGR00048608-Work-around-untrustworthy-.patch

drivers/mtd/nand/mxc_nd.c

index ccab9e120791aad57846da2bf004d5a7d731ffb8..08ea25ad9421a7affd4f52d94324ce2bff8f03df 100644 (file)
@@ -852,9 +852,6 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
              "mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n",
              command, column, page_addr);
 
-       if ((NFMS >> NFMS_BIT) & 0x1)
-               is2k_Pagesize = 1;
-
        /*
         * Reset command state information
         */
@@ -1045,12 +1042,23 @@ static int mxc_nand_scan_bbt(struct mtd_info *mtd)
        struct nand_chip *this = mtd->priv;
 
        /* Config before scanning */
+       /* Do not rely on NFMS_BIT, set/clear NFMS bit based on mtd->writesize */
        if (mtd->writesize == NAND_PAGESIZE_2KB) {
                NFMS |= (1 << NFMS_BIT);
+               is2k_Pagesize = 1;
+       } else {
+               if ((NFMS >> NFMS_BIT) & 0x1) { /* This case has happened on some SoCs */
+                       printk(KERN_INFO
+                              "NFMS Bit set for 512B Page, resetting it. [RCSR: 0x%08x]\n",
+                              NFMS);
+                       NFMS &= ~(1 << NFMS_BIT);
+               }
+               is2k_Pagesize = 0;
        }
 
        this->bbt_td = NULL;
        this->bbt_md = NULL;
+
        if (!this->badblock_pattern) {
                if (mtd->writesize == NAND_PAGESIZE_2KB)
                        this->badblock_pattern = &smallpage_memorybased;