]> git.sur5r.net Git - u-boot/blobdiff - drivers/mtd/nand/nand_base.c
Merge branch 'u-boot-ti/master' into 'u-boot-arm/master'
[u-boot] / drivers / mtd / nand / nand_base.c
index 50bfb65f75b30c84f2ac0c22dd8b04d51992e64a..a2d06be99fcf4f3f0882671a514b36b4afecb7a3 100644 (file)
@@ -1245,7 +1245,8 @@ 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
@@ -1256,7 +1257,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 &&
                                    !(mtd->ecc_stats.failed - stats.failed))
                                        chip->pagebuf = realpage;
                                memcpy(buf, chip->buffers->databuf + col, bytes);
@@ -2579,9 +2580,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
        if (le16_to_cpu(p->features) & 1)
                *busw = NAND_BUSWIDTH_16;
 
-       chip->options &= ~NAND_CHIPOPTIONS_MSK;
-       chip->options |= (NAND_NO_READRDY |
-                       NAND_NO_AUTOINCR) & NAND_CHIPOPTIONS_MSK;
+       chip->options |= NAND_NO_READRDY | NAND_NO_AUTOINCR;
 
        return 1;
 }
@@ -2603,6 +2602,7 @@ static const struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
                                                  int *maf_id, int *dev_id,
                                                  const struct nand_flash_dev *type)
 {
+       const char *name;
        int i, maf_idx;
        u8 id_data[8];
        int ret;
@@ -2753,8 +2753,7 @@ static const struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
                }
        }
        /* Get chip options, preserve non chip based options */
-       chip->options &= ~NAND_CHIPOPTIONS_MSK;
-       chip->options |= type->options & NAND_CHIPOPTIONS_MSK;
+       chip->options |= type->options;
 
        /* Check if chip is a not a samsung device. Do not clear the
         * options for chips which are not having an extended id.
@@ -2851,14 +2850,14 @@ ident_done:
                chip->cmdfunc = nand_command_lp;
 
        /* TODO onfi flash name */
-       MTDDEBUG (MTD_DEBUG_LEVEL0, "NAND device: Manufacturer ID:"
-               " 0x%02x, Chip ID: 0x%02x (%s %s)\n", *maf_id, *dev_id,
-               nand_manuf_ids[maf_idx].name,
+       name = type->name;
 #ifdef CONFIG_SYS_NAND_ONFI_DETECTION
-               chip->onfi_version ? chip->onfi_params.model : type->name);
-#else
-               type->name);
+       if (chip->onfi_version)
+               name = chip->onfi_params.model;
 #endif
+       MTDDEBUG(MTD_DEBUG_LEVEL0, "NAND device: Manufacturer ID:"
+                " 0x%02x, Chip ID: 0x%02x (%s %s)\n", *maf_id, *dev_id,
+                nand_manuf_ids[maf_idx].name, name);
 
        return type;
 }
@@ -2937,7 +2936,8 @@ int nand_scan_tail(struct mtd_info *mtd)
        struct nand_chip *chip = mtd->priv;
 
        if (!(chip->options & NAND_OWN_BUFFERS))
-               chip->buffers = kmalloc(sizeof(*chip->buffers), GFP_KERNEL);
+               chip->buffers = memalign(ARCH_DMA_MINALIGN,
+                                        sizeof(*chip->buffers));
        if (!chip->buffers)
                return -ENOMEM;
 
@@ -3151,6 +3151,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 = (chip->options & NAND_ROM) ? MTD_CAP_ROM :