]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
nand: Move the sub-page read support enable to a flag
authorJoe Hershberger <joe.hershberger@ni.com>
Mon, 18 Jun 2012 23:10:23 +0000 (18:10 -0500)
committerJohn Linn <john.linn@xilinx.com>
Tue, 19 Jun 2012 21:21:28 +0000 (14:21 -0700)
Use a flag instead of a hard-coded macro so that sub-page reads can be
enabled in other cases (such as on-die ecc).

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
drivers/mtd/nand/nand_base.c
include/linux/mtd/nand.h

index 0bfe7ead848bf0476358d3ce898d146cd7f00c86..cf305d673362e85fd90d28081dcba7f59434cb5a 100644 (file)
@@ -1177,7 +1177,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
                        if (unlikely(ops->mode == MTD_OOB_RAW))
                                ret = chip->ecc.read_page_raw(mtd, chip,
                                                bufpoi, page);
-                       else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
+                       else if (!aligned && NAND_HAS_SUBPAGE_READ(chip) && !oob)
                                ret = chip->ecc.read_subpage(mtd, chip, col, bytes, bufpoi);
                        else
                                ret = chip->ecc.read_page(mtd, chip, bufpoi,
@@ -1187,7 +1187,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 
                        /* Transfer not aligned data */
                        if (!aligned) {
-                               if (!NAND_SUBPAGE_READ(chip) && !oob)
+                               if (!NAND_HAS_SUBPAGE_READ(chip) && !oob)
                                        chip->pagebuf = realpage;
                                memcpy(buf, chip->buffers->databuf + col, bytes);
                        }
@@ -2940,6 +2940,10 @@ int nand_scan_tail(struct mtd_info *mtd)
        /* Invalidate the pagebuffer reference */
        chip->pagebuf = -1;
 
+       /* Large page NAND with SOFT_ECC should support subpage reads */
+       if ((chip->ecc.mode == NAND_ECC_SOFT) && (chip->page_shift > 9))
+               chip->options |= NAND_SUBPAGE_READ;
+
        /* Fill in remaining MTD driver data */
        mtd->type = MTD_NANDFLASH;
        mtd->flags = MTD_CAP_NANDFLASH;
index 5c7ccdfc7c8e55ea315da7e31b638de1f1852a6b..34188c783f702c92e4a8e0ee15b87ecb803c3d32 100644 (file)
@@ -179,6 +179,8 @@ typedef enum {
 /* Chip does not allow subpage writes */
 #define NAND_NO_SUBPAGE_WRITE  0x00000200
 
+/* Device supports subpage reads */
+#define NAND_SUBPAGE_READ       0x00001000
 
 /* Options valid for Samsung large page devices */
 #define NAND_SAMSUNG_LP_OPTIONS \
@@ -189,9 +191,7 @@ typedef enum {
 #define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING))
 #define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG))
 #define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK))
-/* Large page NAND with SOFT_ECC should support subpage reads */
-#define NAND_SUBPAGE_READ(chip) ((chip->ecc.mode == NAND_ECC_SOFT) \
-                                       && (chip->page_shift > 9))
+#define NAND_HAS_SUBPAGE_READ(chip) ((chip->options & NAND_SUBPAGE_READ))
 
 /* Mask to zero out the chip options, which come from the id table */
 #define NAND_CHIPOPTIONS_MSK   (0x0000ffff & ~NAND_NO_AUTOINCR)