aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/maps/Kconfig2
-rw-r--r--drivers/mtd/maps/ck804xrom.c2
-rw-r--r--drivers/mtd/nand/Kconfig2
-rw-r--r--drivers/mtd/nand/cafe.c86
4 files changed, 38 insertions, 54 deletions
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index f457315579db..bbf0553bdb2e 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -204,7 +204,7 @@ config MTD_ESB2ROM
204 204
205config MTD_CK804XROM 205config MTD_CK804XROM
206 tristate "BIOS flash chip on Nvidia CK804" 206 tristate "BIOS flash chip on Nvidia CK804"
207 depends on X86 && MTD_JEDECPROBE 207 depends on X86 && MTD_JEDECPROBE && PCI
208 help 208 help
209 Support for treating the BIOS flash chip on nvidia motherboards 209 Support for treating the BIOS flash chip on nvidia motherboards
210 as an MTD device - with this you can reprogram your BIOS. 210 as an MTD device - with this you can reprogram your BIOS.
diff --git a/drivers/mtd/maps/ck804xrom.c b/drivers/mtd/maps/ck804xrom.c
index 238d42e88ec5..68ed02ecb2ec 100644
--- a/drivers/mtd/maps/ck804xrom.c
+++ b/drivers/mtd/maps/ck804xrom.c
@@ -327,7 +327,7 @@ static int __init init_ck804xrom(void)
327 pdev = NULL; 327 pdev = NULL;
328 328
329 for(id = ck804xrom_pci_tbl; id->vendor; id++) { 329 for(id = ck804xrom_pci_tbl; id->vendor; id++) {
330 pdev = pci_find_device(id->vendor, id->device, NULL); 330 pdev = pci_get_device(id->vendor, id->device, NULL);
331 if (pdev) 331 if (pdev)
332 break; 332 break;
333 } 333 }
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 358f55a82dbe..9326a56f0fbc 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -223,7 +223,7 @@ config MTD_NAND_SHARPSL
223 223
224config MTD_NAND_CAFE 224config MTD_NAND_CAFE
225 tristate "NAND support for OLPC CAFÉ chip" 225 tristate "NAND support for OLPC CAFÉ chip"
226 depends on PCI 226 depends on MTD_NAND && PCI
227 help 227 help
228 Use NAND flash attached to the CAFÉ chip designed for the $100 228 Use NAND flash attached to the CAFÉ chip designed for the $100
229 laptop. 229 laptop.
diff --git a/drivers/mtd/nand/cafe.c b/drivers/mtd/nand/cafe.c
index b8d9b64cccc0..1e877cbe7757 100644
--- a/drivers/mtd/nand/cafe.c
+++ b/drivers/mtd/nand/cafe.c
@@ -14,6 +14,7 @@
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/dma-mapping.h>
17#include <asm/io.h> 18#include <asm/io.h>
18 19
19#define CAFE_NAND_CTRL1 0x00 20#define CAFE_NAND_CTRL1 0x00
@@ -77,8 +78,9 @@ module_param(regdebug, int, 0644);
77static int checkecc = 1; 78static int checkecc = 1;
78module_param(checkecc, int, 0644); 79module_param(checkecc, int, 0644);
79 80
80static int slowtiming = 0; 81static int numtimings;
81module_param(slowtiming, int, 0644); 82static int timing[3];
83module_param_array(timing, int, &numtimings, 0644);
82 84
83/* Hrm. Why isn't this already conditional on something in the struct device? */ 85/* Hrm. Why isn't this already conditional on something in the struct device? */
84#define cafe_dev_dbg(dev, args...) do { if (debug) dev_dbg(dev, ##args); } while(0) 86#define cafe_dev_dbg(dev, args...) do { if (debug) dev_dbg(dev, ##args); } while(0)
@@ -528,6 +530,7 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev,
528{ 530{
529 struct mtd_info *mtd; 531 struct mtd_info *mtd;
530 struct cafe_priv *cafe; 532 struct cafe_priv *cafe;
533 uint32_t timing1, timing2, timing3;
531 uint32_t ctrl; 534 uint32_t ctrl;
532 int err = 0; 535 int err = 0;
533 536
@@ -579,30 +582,44 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev,
579 cafe->nand.block_bad = cafe_nand_block_bad; 582 cafe->nand.block_bad = cafe_nand_block_bad;
580 } 583 }
581 584
585 if (numtimings && numtimings != 3) {
586 dev_warn(&cafe->pdev->dev, "%d timing register values ignored; precisely three are required\n", numtimings);
587 }
588
589 if (numtimings == 3) {
590 timing1 = timing[0];
591 timing2 = timing[1];
592 timing3 = timing[2];
593 cafe_dev_dbg(&cafe->pdev->dev, "Using provided timings (%08x %08x %08x)\n",
594 timing1, timing2, timing3);
595 } else {
596 timing1 = cafe_readl(cafe, NAND_TIMING1);
597 timing2 = cafe_readl(cafe, NAND_TIMING2);
598 timing3 = cafe_readl(cafe, NAND_TIMING3);
599
600 if (timing1 | timing2 | timing3) {
601 cafe_dev_dbg(&cafe->pdev->dev, "Timing registers already set (%08x %08x %08x)\n", timing1, timing2, timing3);
602 } else {
603 dev_warn(&cafe->pdev->dev, "Timing registers unset; using most conservative defaults\n");
604 timing1 = timing2 = timing3 = 0xffffffff;
605 }
606 }
607
582 /* Start off by resetting the NAND controller completely */ 608 /* Start off by resetting the NAND controller completely */
583 cafe_writel(cafe, 1, NAND_RESET); 609 cafe_writel(cafe, 1, NAND_RESET);
584 cafe_writel(cafe, 0, NAND_RESET); 610 cafe_writel(cafe, 0, NAND_RESET);
585 611
586 cafe_writel(cafe, 0xffffffff, NAND_IRQ_MASK); 612 cafe_writel(cafe, timing1, NAND_TIMING1);
613 cafe_writel(cafe, timing2, NAND_TIMING2);
614 cafe_writel(cafe, timing3, NAND_TIMING3);
587 615
588 /* Timings from Marvell's test code (not verified or calculated by us) */
589 if (!slowtiming) {
590 cafe_writel(cafe, 0x01010a0a, NAND_TIMING1);
591 cafe_writel(cafe, 0x24121212, NAND_TIMING2);
592 cafe_writel(cafe, 0x11000000, NAND_TIMING3);
593 } else {
594 cafe_writel(cafe, 0xffffffff, NAND_TIMING1);
595 cafe_writel(cafe, 0xffffffff, NAND_TIMING2);
596 cafe_writel(cafe, 0xffffffff, NAND_TIMING3);
597 }
598 cafe_writel(cafe, 0xffffffff, NAND_IRQ_MASK); 616 cafe_writel(cafe, 0xffffffff, NAND_IRQ_MASK);
599 err = request_irq(pdev->irq, &cafe_nand_interrupt, SA_SHIRQ, "CAFE NAND", mtd); 617 err = request_irq(pdev->irq, &cafe_nand_interrupt, SA_SHIRQ, "CAFE NAND", mtd);
600 if (err) { 618 if (err) {
601 dev_warn(&pdev->dev, "Could not register IRQ %d\n", pdev->irq); 619 dev_warn(&pdev->dev, "Could not register IRQ %d\n", pdev->irq);
602
603 goto out_free_dma; 620 goto out_free_dma;
604 } 621 }
605#if 1 622
606 /* Disable master reset, enable NAND clock */ 623 /* Disable master reset, enable NAND clock */
607 ctrl = cafe_readl(cafe, GLOBAL_CTRL); 624 ctrl = cafe_readl(cafe, GLOBAL_CTRL);
608 ctrl &= 0xffffeff0; 625 ctrl &= 0xffffeff0;
@@ -629,32 +646,8 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev,
629 cafe_writel(cafe, 0x80000007, GLOBAL_IRQ_MASK); 646 cafe_writel(cafe, 0x80000007, GLOBAL_IRQ_MASK);
630 cafe_dev_dbg(&cafe->pdev->dev, "Control %x, IRQ mask %x\n", 647 cafe_dev_dbg(&cafe->pdev->dev, "Control %x, IRQ mask %x\n",
631 cafe_readl(cafe, GLOBAL_CTRL), cafe_readl(cafe, GLOBAL_IRQ_MASK)); 648 cafe_readl(cafe, GLOBAL_CTRL), cafe_readl(cafe, GLOBAL_IRQ_MASK));
632#endif 649
633#if 1 650 /* Scan to find existence of the device */
634 mtd->writesize=2048;
635 mtd->oobsize = 0x40;
636 memset(cafe->dmabuf, 0x5a, 2112);
637 cafe->nand.cmdfunc(mtd, NAND_CMD_READID, 0, -1);
638 cafe->nand.read_byte(mtd);
639 cafe->nand.read_byte(mtd);
640 cafe->nand.read_byte(mtd);
641 cafe->nand.read_byte(mtd);
642 cafe->nand.read_byte(mtd);
643#endif
644#if 0
645 cafe->nand.cmdfunc(mtd, NAND_CMD_READ0, 0, 0);
646 // nand_wait_ready(mtd);
647 cafe->nand.read_byte(mtd);
648 cafe->nand.read_byte(mtd);
649 cafe->nand.read_byte(mtd);
650 cafe->nand.read_byte(mtd);
651#endif
652#if 0
653 writel(0x84600070, cafe->mmio);
654 udelay(10);
655 cafe_dev_dbg(&cafe->pdev->dev, "Status %x\n", cafe_readl(cafe, NAND_NONMEM));
656#endif
657 /* Scan to find existance of the device */
658 if (nand_scan_ident(mtd, 1)) { 651 if (nand_scan_ident(mtd, 1)) {
659 err = -ENXIO; 652 err = -ENXIO;
660 goto out_irq; 653 goto out_irq;
@@ -758,13 +751,4 @@ module_exit(cafe_nand_exit);
758 751
759MODULE_LICENSE("GPL"); 752MODULE_LICENSE("GPL");
760MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); 753MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
761MODULE_DESCRIPTION("NAND flash driver for OLPC CAFE chip"); 754MODULE_DESCRIPTION("NAND flash driver for OLPC CAFÉ chip");
762
763/* Correct ECC for 2048 bytes of 0xff:
764 41 a0 71 65 54 27 f3 93 ec a9 be ed 0b a1 */
765
766/* dwmw2's B-test board, in case of completely screwing it:
767Bad eraseblock 2394 at 0x12b40000
768Bad eraseblock 2627 at 0x14860000
769Bad eraseblock 3349 at 0x1a2a0000
770*/