]> git.sur5r.net Git - u-boot/blobdiff - drivers/mtd/nand/nand_base.c
Merge branch 'post' of git://git.denx.de/u-boot-blackfin
[u-boot] / drivers / mtd / nand / nand_base.c
index fa286a8d8101dee5d50f57637172459c27984169..e7dfcb1568108194414b8676f6abe780dd4d2a7b 100644 (file)
@@ -213,7 +213,7 @@ static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
  *
  * Default read function for 8bit buswith
  */
-static void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
+void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
 {
        int i;
        struct nand_chip *chip = mtd->priv;
@@ -269,7 +269,7 @@ static void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
  *
  * Default read function for 16bit buswith
  */
-static void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len)
+void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len)
 {
        int i;
        struct nand_chip *chip = mtd->priv;
@@ -1950,7 +1950,7 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
        struct nand_chip *chip = mtd->priv;
        int ret;
 
-       /* Do not allow reads past end of device */
+       /* Do not allow writes past end of device */
        if ((to + len) > mtd->size)
                return -EINVAL;
        if (!len)
@@ -2461,20 +2461,24 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd,
 
        /* check version */
        val = le16_to_cpu(p->revision);
-       if (val == 1 || val > (1 << 4)) {
-               printk(KERN_INFO "%s: unsupported ONFI "
-                                       "version: %d\n", __func__, val);
-               return 0;
-       }
-
-       if (val & (1 << 4))
+       if (val & (1 << 5))
+               chip->onfi_version = 23;
+       else if (val & (1 << 4))
                chip->onfi_version = 22;
        else if (val & (1 << 3))
                chip->onfi_version = 21;
        else if (val & (1 << 2))
                chip->onfi_version = 20;
-       else
+       else if (val & (1 << 1))
                chip->onfi_version = 10;
+       else
+               chip->onfi_version = 0;
+
+       if (!chip->onfi_version) {
+               printk(KERN_INFO "%s: unsupported ONFI "
+                                       "version: %d\n", __func__, val);
+               return 0;
+       }
 
        if (!mtd->name)
                mtd->name = p->model;
@@ -2482,7 +2486,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd,
        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 = le32_to_cpu(p->blocks_per_lun) * mtd->erasesize;
+       chip->chipsize = (uint64_t)le32_to_cpu(p->blocks_per_lun) * mtd->erasesize;
        *busw = 0;
        if (le16_to_cpu(p->features) & 1)
                *busw = NAND_BUSWIDTH_16;