diff options
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/core.c | 56 | ||||
-rw-r--r-- | drivers/mtd/mtdoob.c | 3 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_mxs.c | 13 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_write.c | 7 |
4 files changed, 16 insertions, 63 deletions
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c index 8601787286..b5916dab02 100644 --- a/drivers/mtd/core.c +++ b/drivers/mtd/core.c @@ -62,65 +62,15 @@ static ssize_t mtd_read(struct cdev *cdev, void* buf, size_t count, #define MTDPGALG(x) ((x) & ~(mtd->writesize - 1)) #ifdef CONFIG_MTD_WRITE -static int all_ff(const void *buf, int len) -{ - int i; - const uint8_t *p = buf; - - for (i = 0; i < len; i++) - if (p[i] != 0xFF) - return 0; - return 1; -} - static ssize_t mtd_write(struct cdev* cdev, const void *buf, size_t _count, loff_t _offset, ulong flags) { struct mtd_info *mtd = cdev->priv; - size_t retlen, now; - int ret = 0; - void *wrbuf = NULL; - size_t count = _count; - unsigned long offset = _offset; - - if (NOTALIGNED(offset)) { - printf("offset 0x%0lx not page aligned\n", offset); - return -EINVAL; - } - - dev_dbg(cdev->dev, "write: offset: 0x%08lx count: 0x%zx\n", offset, count); - while (count) { - now = count > mtd->writesize ? mtd->writesize : count; - - if (NOTALIGNED(now)) { - dev_dbg(cdev->dev, "not aligned: %d %ld\n", - mtd->writesize, - (offset % mtd->writesize)); - wrbuf = xmalloc(mtd->writesize); - memset(wrbuf, 0xff, mtd->writesize); - memcpy(wrbuf + (offset % mtd->writesize), buf, now); - if (!all_ff(wrbuf, mtd->writesize)) - ret = mtd->write(mtd, MTDPGALG(offset), - mtd->writesize, &retlen, - wrbuf); - free(wrbuf); - } else { - if (!all_ff(buf, mtd->writesize)) - ret = mtd->write(mtd, offset, now, &retlen, - buf); - dev_dbg(cdev->dev, - "offset: 0x%08lx now: 0x%zx retlen: 0x%zx\n", - offset, now, retlen); - } - if (ret) - goto out; + size_t retlen; + int ret; - offset += now; - count -= now; - buf += now; - } + ret = mtd->write(mtd, _offset, _count, &retlen, buf); -out: return ret ? ret : _count; } #endif diff --git a/drivers/mtd/mtdoob.c b/drivers/mtd/mtdoob.c index c7bf40cef8..e5d803903a 100644 --- a/drivers/mtd/mtdoob.c +++ b/drivers/mtd/mtdoob.c @@ -73,6 +73,9 @@ static int add_mtdoob_device(struct mtd_info *mtd, char *devname, void **priv) { struct mtdoob *mtdoob; + if (mtd->oobsize == 0) + return 0; + mtdoob = xzalloc(sizeof(*mtdoob)); mtdoob->cdev.ops = &mtd_ops_oob; mtdoob->cdev.size = (mtd->size / mtd->writesize) * mtd->oobsize; diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c index 975a44f569..c4509d3dd6 100644 --- a/drivers/mtd/nand/nand_mxs.c +++ b/drivers/mtd/nand/nand_mxs.c @@ -1128,6 +1128,7 @@ int mxs_nand_alloc_buffers(struct mxs_nand_info *nand_info) int mxs_nand_hw_init(struct mxs_nand_info *info) { void __iomem *gpmi_regs = (void *)MXS_GPMI_BASE; + void __iomem *bch_regs = (void __iomem *)MXS_BCH_BASE; int i = 0, ret; u32 val; @@ -1153,6 +1154,15 @@ int mxs_nand_hw_init(struct mxs_nand_info *info) if (ret) return ret; + val = readl(gpmi_regs + GPMI_VERSION); + info->version = val >> GPMI_VERSION_MINOR_OFFSET; + + /* Reset BCH. Don't use SFTRST on MX23 due to Errata #2847 */ + ret = mxs_reset_block(bch_regs + BCH_CTRL, + info->version == GPMI_VERSION_TYPE_MX23); + if (ret) + return ret; + /* * Choose NAND mode, set IRQ polarity, disable write protection and * select BCH ECC. @@ -1163,9 +1173,6 @@ int mxs_nand_hw_init(struct mxs_nand_info *info) GPMI_CTRL1_BCH_MODE; writel(val, gpmi_regs + GPMI_CTRL1); - val = readl(gpmi_regs + GPMI_VERSION); - info->version = val >> GPMI_VERSION_MINOR_OFFSET; - return 0; err2: diff --git a/drivers/mtd/nand/nand_write.c b/drivers/mtd/nand/nand_write.c index 5ed04cee57..999712795c 100644 --- a/drivers/mtd/nand/nand_write.c +++ b/drivers/mtd/nand/nand_write.c @@ -273,13 +273,6 @@ int nand_do_write_ops(struct mtd_info *mtd, loff_t to, if (!writelen) return 0; - /* reject writes, which are not page aligned */ - if (NOTALIGNED(to) || NOTALIGNED(ops->len)) { - printk(KERN_NOTICE "nand_write: " - "Attempt to write not page aligned data\n"); - return -EINVAL; - } - column = to & (mtd->writesize - 1); subpage = column || (writelen & (mtd->writesize - 1)); |