]> err.no Git - linux-2.6/blobdiff - drivers/mtd/nand/ts7250.c
Merge branch 'for-linus' of git://www.jni.nu/cris
[linux-2.6] / drivers / mtd / nand / ts7250.c
index 643633d91a8ba29b8588f99e5350a491ca1c9965..f40081069ab2c6fa0f2a5705eaad7c9e698c28af 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2004 Technologic Systems (support@embeddedARM.com)
  *
  * Derived from drivers/mtd/nand/edb7312.c
- *   Copyright (C) 2004 Marius Gröger (mag@sysgo.de)
+ *   Copyright (C) 2004 Marius Gröger (mag@sysgo.de)
  *
  * Derived from drivers/mtd/nand/autcpu12.c
  *   Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
@@ -83,31 +83,29 @@ static struct mtd_partition partition_info128[] = {
 
 /*
  *     hardware specific access to control-lines
+ *
+ *     ctrl:
+ *     NAND_NCE: bit 0 -> bit 2
+ *     NAND_CLE: bit 1 -> bit 1
+ *     NAND_ALE: bit 2 -> bit 0
  */
-static void ts7250_hwcontrol(struct mtd_info *mtd, int cmd)
+static void ts7250_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
-       unsigned long ctrl = TS72XX_NAND_CONTROL_VIRT_BASE;
-
-       switch(cmd) {
-       case NAND_CTL_SETCLE:
-               __raw_writeb(__raw_readb(ctrl) | 0x2, ctrl);
-               break;
-       case NAND_CTL_CLRCLE:
-               __raw_writeb(__raw_readb(ctrl) & ~0x2, ctrl);
-               break;
-       case NAND_CTL_SETALE:
-               __raw_writeb(__raw_readb(ctrl) | 0x1, ctrl);
-               break;
-       case NAND_CTL_CLRALE:
-               __raw_writeb(__raw_readb(ctrl) & ~0x1, ctrl);
-               break;
-       case NAND_CTL_SETNCE:
-               __raw_writeb(__raw_readb(ctrl) | 0x4, ctrl);
-               break;
-       case NAND_CTL_CLRNCE:
-               __raw_writeb(__raw_readb(ctrl) & ~0x4, ctrl);
-               break;
+       struct nand_chip *chip = mtd->priv;
+
+       if (ctrl & NAND_CTRL_CHANGE) {
+               unsigned long addr = TS72XX_NAND_CONTROL_VIRT_BASE;
+               unsigned char bits;
+
+               bits = (ctrl & NAND_NCE) << 2;
+               bits |= ctrl & NAND_CLE;
+               bits |= (ctrl & NAND_ALE) >> 2;
+
+               __raw_writeb((__raw_readb(addr) & ~0x7) | bits, addr);
        }
+
+       if (cmd != NAND_CMD_NONE)
+               writeb(cmd, chip->IO_ADDR_W);
 }
 
 /*
@@ -132,8 +130,7 @@ static int __init ts7250_init(void)
                return -ENXIO;
 
        /* Allocate memory for MTD device structure and private data */
-       ts7250_mtd = kmalloc(sizeof(struct mtd_info) +
-                               sizeof(struct nand_chip), GFP_KERNEL);
+       ts7250_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
        if (!ts7250_mtd) {
                printk("Unable to allocate TS7250 NAND MTD device structure.\n");
                return -ENOMEM;
@@ -148,14 +145,15 @@ static int __init ts7250_init(void)
 
        /* Link the private data with the MTD structure */
        ts7250_mtd->priv = this;
+       ts7250_mtd->owner = THIS_MODULE;
 
        /* insert callbacks */
        this->IO_ADDR_R = (void *)TS72XX_NAND_DATA_VIRT_BASE;
        this->IO_ADDR_W = (void *)TS72XX_NAND_DATA_VIRT_BASE;
-       this->hwcontrol = ts7250_hwcontrol;
+       this->cmd_ctrl = ts7250_hwcontrol;
        this->dev_ready = ts7250_device_ready;
        this->chip_delay = 15;
-       this->eccmode = NAND_ECC_SOFT;
+       this->ecc.mode = NAND_ECC_SOFT;
 
        printk("Searching for NAND flash...\n");
        /* Scan to find existence of the device */
@@ -163,11 +161,9 @@ static int __init ts7250_init(void)
                kfree(ts7250_mtd);
                return -ENXIO;
        }
-
 #ifdef CONFIG_MTD_PARTITIONS
        ts7250_mtd->name = "ts7250-nand";
-       mtd_parts_nb = parse_mtd_partitions(ts7250_mtd, part_probes,
-                                               &mtd_parts, 0);
+       mtd_parts_nb = parse_mtd_partitions(ts7250_mtd, part_probes, &mtd_parts, 0);
        if (mtd_parts_nb > 0)
                part_type = "command line";
        else
@@ -188,6 +184,7 @@ static int __init ts7250_init(void)
        /* Return happy */
        return 0;
 }
+
 module_init(ts7250_init);
 
 /*
@@ -201,6 +198,7 @@ static void __exit ts7250_cleanup(void)
        /* Free the MTD device structure */
        kfree(ts7250_mtd);
 }
+
 module_exit(ts7250_cleanup);
 
 MODULE_LICENSE("GPL");