]> git.sur5r.net Git - u-boot/blobdiff - drivers/mtd/nand/nand_base.c
arm: Remove support for unused s3c64xx
[u-boot] / drivers / mtd / nand / nand_base.c
index 891af1f2ea4a06b10a49837757997d5a16423532..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);
@@ -2573,14 +2574,13 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
        mtd->writesize = le32_to_cpu(p->byte_per_page);
        mtd->erasesize = le32_to_cpu(p->pages_per_block) * mtd->writesize;
        mtd->oobsize = le16_to_cpu(p->spare_bytes_per_page);
-       chip->chipsize = (uint64_t)le32_to_cpu(p->blocks_per_lun) * mtd->erasesize;
+       chip->chipsize = le32_to_cpu(p->blocks_per_lun);
+       chip->chipsize *= (uint64_t)mtd->erasesize * p->lun_count;
        *busw = 0;
        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;
 }
@@ -2602,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;
@@ -2752,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.
@@ -2850,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;
 }
@@ -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 :