Merge git://git.infradead.org/mtd-2.6
authorLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 19 Feb 2007 21:34:11 +0000 (13:34 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 19 Feb 2007 21:34:11 +0000 (13:34 -0800)
* git://git.infradead.org/mtd-2.6: (49 commits)
  [MTD] [NAND] S3C2412 fix hw ecc
  [MTD] [NAND] Work around false compiler warning in CAFÉ driver
  [JFFS2] printk warning fixes
  [MTD] [MAPS] ichxrom warning fix
  [MTD] [MAPS] amd76xrom warning fix
  [MTD] [MAPS] esb2rom warning fixes
  [MTD] [MAPS] ck804xrom warning fix
  [MTD] [MAPS] netsc520 warning fix
  [MTD] [MAPS] sc520cdp warning fix
  [MTD] [ONENAND] onenand_base warning fix
  [MTD] [NAND] eXcite nand flash driver
  [MTD] Improve heuristic for detecting wrong-endian RedBoot partition table
  [MTD] Fix RedBoot partition parsing regression harder.
  [MTD] [NAND] S3C2410: Hardware ECC correction code
  [JFFS2] Use MTD_OOB_AUTO to automatically place cleanmarker on NAND
  [MTD] Clarify OOB-operation interface comments
  [MTD] remove unused ecctype,eccsize fields from struct mtd_info
  [MTD] [NOR] Intel: remove ugly PROGREGION macros
  [MTD] [NOR] STAA: use writesize instead off eccsize to represent ECC block
  [MTD] OneNAND: Invalidate bufferRAM after erase
  ...

1  2 
drivers/mtd/devices/doc2001.c
drivers/mtd/devices/doc2001plus.c
drivers/mtd/mtdchar.c
drivers/mtd/nand/cafe.c

@@@ -16,6 -16,7 +16,6 @@@
  #include <linux/pci.h>
  #include <linux/delay.h>
  #include <linux/slab.h>
 -#include <linux/sched.h>
  #include <linux/init.h>
  #include <linux/types.h>
  #include <linux/bitops.h>
@@@ -348,7 -349,6 +348,6 @@@ void DoCMil_init(struct mtd_info *mtd
  
        mtd->type = MTD_NANDFLASH;
        mtd->flags = MTD_CAP_NANDFLASH;
-       mtd->ecctype = MTD_ECC_RS_DiskOnChip;
        mtd->size = 0;
  
        /* FIXME: erase size is not always 8KiB */
@@@ -20,6 -20,7 +20,6 @@@
  #include <linux/pci.h>
  #include <linux/delay.h>
  #include <linux/slab.h>
 -#include <linux/sched.h>
  #include <linux/init.h>
  #include <linux/types.h>
  #include <linux/bitops.h>
@@@ -472,7 -473,6 +472,6 @@@ void DoCMilPlus_init(struct mtd_info *m
  
        mtd->type = MTD_NANDFLASH;
        mtd->flags = MTD_CAP_NANDFLASH;
-       mtd->ecctype = MTD_ECC_RS_DiskOnChip;
        mtd->size = 0;
  
        mtd->erasesize = 0;
diff --combined drivers/mtd/mtdchar.c
@@@ -419,8 -419,9 +419,9 @@@ static int mtd_ioctl(struct inode *inod
                info.erasesize  = mtd->erasesize;
                info.writesize  = mtd->writesize;
                info.oobsize    = mtd->oobsize;
-               info.ecctype    = mtd->ecctype;
-               info.eccsize    = mtd->eccsize;
+               /* The below fields are obsolete */
+               info.ecctype    = -1;
+               info.eccsize    = 0;
                if (copy_to_user(argp, &info, sizeof(struct mtd_info_user)))
                        return -EFAULT;
                break;
        return ret;
  } /* memory_ioctl */
  
 -static struct file_operations mtd_fops = {
 +static const struct file_operations mtd_fops = {
        .owner          = THIS_MODULE,
        .llseek         = mtd_lseek,
        .read           = mtd_read,
diff --combined drivers/mtd/nand/cafe.c
@@@ -78,8 -78,9 +78,9 @@@ module_param(regdebug, int, 0644)
  static int checkecc = 1;
  module_param(checkecc, int, 0644);
  
- static int slowtiming = 0;
- module_param(slowtiming, int, 0644);
+ static int numtimings;
+ static int timing[3];
+ module_param_array(timing, int, &numtimings, 0644);
  
  /* Hrm. Why isn't this already conditional on something in the struct device? */
  #define cafe_dev_dbg(dev, args...) do { if (debug) dev_dbg(dev, ##args); } while(0)
@@@ -264,10 -265,10 +265,10 @@@ static void cafe_nand_cmdfunc(struct mt
        ndelay(100);
  
        if (1) {
-               int c = 500000;
+               int c;
                uint32_t irqs;
  
-               while (c--) {
+               for (c = 500000; c != 0; c--) {
                        irqs = cafe_readl(cafe, NAND_IRQ);
                        if (irqs & doneint)
                                break;
@@@ -529,6 -530,7 +530,7 @@@ static int __devinit cafe_nand_probe(st
  {
        struct mtd_info *mtd;
        struct cafe_priv *cafe;
+       uint32_t timing1, timing2, timing3;
        uint32_t ctrl;
        int err = 0;
  
                cafe->nand.block_bad = cafe_nand_block_bad;
        }
  
+       if (numtimings && numtimings != 3) {
+               dev_warn(&cafe->pdev->dev, "%d timing register values ignored; precisely three are required\n", numtimings);
+       }
+       if (numtimings == 3) {
+               timing1 = timing[0];
+               timing2 = timing[1];
+               timing3 = timing[2];
+               cafe_dev_dbg(&cafe->pdev->dev, "Using provided timings (%08x %08x %08x)\n",
+                            timing1, timing2, timing3);
+       } else {
+               timing1 = cafe_readl(cafe, NAND_TIMING1);
+               timing2 = cafe_readl(cafe, NAND_TIMING2);
+               timing3 = cafe_readl(cafe, NAND_TIMING3);
+               if (timing1 | timing2 | timing3) {
+                       cafe_dev_dbg(&cafe->pdev->dev, "Timing registers already set (%08x %08x %08x)\n", timing1, timing2, timing3);
+               } else {
+                       dev_warn(&cafe->pdev->dev, "Timing registers unset; using most conservative defaults\n");
+                       timing1 = timing2 = timing3 = 0xffffffff;
+               }
+       }
        /* Start off by resetting the NAND controller completely */
        cafe_writel(cafe, 1, NAND_RESET);
        cafe_writel(cafe, 0, NAND_RESET);
  
-       cafe_writel(cafe, 0xffffffff, NAND_IRQ_MASK);
+       cafe_writel(cafe, timing1, NAND_TIMING1);
+       cafe_writel(cafe, timing2, NAND_TIMING2);
+       cafe_writel(cafe, timing3, NAND_TIMING3);
  
-       /* Timings from Marvell's test code (not verified or calculated by us) */
-       if (!slowtiming) {
-               cafe_writel(cafe, 0x01010a0a, NAND_TIMING1);
-               cafe_writel(cafe, 0x24121212, NAND_TIMING2);
-               cafe_writel(cafe, 0x11000000, NAND_TIMING3);
-       } else {
-               cafe_writel(cafe, 0xffffffff, NAND_TIMING1);
-               cafe_writel(cafe, 0xffffffff, NAND_TIMING2);
-               cafe_writel(cafe, 0xffffffff, NAND_TIMING3);
-       }
        cafe_writel(cafe, 0xffffffff, NAND_IRQ_MASK);
 -      err = request_irq(pdev->irq, &cafe_nand_interrupt, SA_SHIRQ, "CAFE NAND", mtd);
 +      err = request_irq(pdev->irq, &cafe_nand_interrupt, IRQF_SHARED,
 +                        "CAFE NAND", mtd);
        if (err) {
                dev_warn(&pdev->dev, "Could not register IRQ %d\n", pdev->irq);
                goto out_free_dma;
        }
- #if 1
        /* Disable master reset, enable NAND clock */
        ctrl = cafe_readl(cafe, GLOBAL_CTRL);
        ctrl &= 0xffffeff0;
        cafe_writel(cafe, 0x80000007, GLOBAL_IRQ_MASK);
        cafe_dev_dbg(&cafe->pdev->dev, "Control %x, IRQ mask %x\n",
                cafe_readl(cafe, GLOBAL_CTRL), cafe_readl(cafe, GLOBAL_IRQ_MASK));
- #endif
- #if 1
-       mtd->writesize=2048;
-       mtd->oobsize = 0x40;
-       memset(cafe->dmabuf, 0x5a, 2112);
-       cafe->nand.cmdfunc(mtd, NAND_CMD_READID, 0, -1);
-       cafe->nand.read_byte(mtd);
-       cafe->nand.read_byte(mtd);
-       cafe->nand.read_byte(mtd);
-       cafe->nand.read_byte(mtd);
-       cafe->nand.read_byte(mtd);
- #endif
- #if 0
-       cafe->nand.cmdfunc(mtd, NAND_CMD_READ0, 0, 0);
-       //      nand_wait_ready(mtd);
-       cafe->nand.read_byte(mtd);
-       cafe->nand.read_byte(mtd);
-       cafe->nand.read_byte(mtd);
-       cafe->nand.read_byte(mtd);
- #endif
- #if 0
-       writel(0x84600070, cafe->mmio);
-       udelay(10);
-       cafe_dev_dbg(&cafe->pdev->dev, "Status %x\n", cafe_readl(cafe, NAND_NONMEM));
- #endif
-       /* Scan to find existance of the device */
+       /* Scan to find existence of the device */
        if (nand_scan_ident(mtd, 1)) {
                err = -ENXIO;
                goto out_irq;
@@@ -760,13 -751,4 +752,4 @@@ module_exit(cafe_nand_exit)
  
  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
- MODULE_DESCRIPTION("NAND flash driver for OLPC CAFE chip");
- /* Correct ECC for 2048 bytes of 0xff:
-    41 a0 71 65 54 27 f3 93 ec a9 be ed 0b a1 */
- /* dwmw2's B-test board, in case of completely screwing it:
- Bad eraseblock 2394 at 0x12b40000
- Bad eraseblock 2627 at 0x14860000
- Bad eraseblock 3349 at 0x1a2a0000
- */
+ MODULE_DESCRIPTION("NAND flash driver for OLPC CAFÉ chip");