]> err.no Git - linux-2.6/blobdiff - drivers/mtd/nand/edb7312.c
Merge branches 'release', 'acpi_pm_device_sleep_state' and 'battery' into release
[linux-2.6] / drivers / mtd / nand / edb7312.c
index ad4488abfb0b2aed3fae1df292414901aab3c11a..ba67bbec20d3a4fbab3ac9733d05ee7cc3f61229 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  drivers/mtd/nand/edb7312.c
  *
- *  Copyright (C) 2002 Marius Gröger (mag@sysgo.de)
+ *  Copyright (C) 2002 Marius Gröger (mag@sysgo.de)
  *
  *  Derived from drivers/mtd/nand/autcpu12.c
  *       Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
@@ -73,32 +73,26 @@ static struct mtd_partition partition_info[] = {
 
 /*
  *     hardware specific access to control-lines
+ *
+ *     NAND_NCE: bit 0 -> bit 6 (bit 7 = 1)
+ *     NAND_CLE: bit 1 -> bit 4
+ *     NAND_ALE: bit 2 -> bit 5
  */
-static void ep7312_hwcontrol(struct mtd_info *mtd, int cmd)
+static void ep7312_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
-       switch (cmd) {
-
-       case NAND_CTL_SETCLE:
-               clps_writeb(clps_readb(ep7312_pxdr) | 0x10, ep7312_pxdr);
-               break;
-       case NAND_CTL_CLRCLE:
-               clps_writeb(clps_readb(ep7312_pxdr) & ~0x10, ep7312_pxdr);
-               break;
-
-       case NAND_CTL_SETALE:
-               clps_writeb(clps_readb(ep7312_pxdr) | 0x20, ep7312_pxdr);
-               break;
-       case NAND_CTL_CLRALE:
-               clps_writeb(clps_readb(ep7312_pxdr) & ~0x20, ep7312_pxdr);
-               break;
-
-       case NAND_CTL_SETNCE:
-               clps_writeb((clps_readb(ep7312_pxdr) | 0x80) & ~0x40, ep7312_pxdr);
-               break;
-       case NAND_CTL_CLRNCE:
-               clps_writeb((clps_readb(ep7312_pxdr) | 0x80) | 0x40, ep7312_pxdr);
-               break;
+       struct nand_chip *chip = mtd->priv;
+
+       if (ctrl & NAND_CTRL_CHANGE) {
+               unsigned char bits = 0x80;
+
+               bits |= (ctrl & (NAND_CLE | NAND_ALE)) << 3;
+               bits |= (ctrl & NAND_NCE) ? 0x00 : 0x40;
+
+               clps_writeb((clps_readb(ep7312_pxdr)  & 0xF0) | bits,
+                           ep7312_pxdr);
        }
+       if (cmd != NAND_CMD_NONE)
+               writeb(cmd, chip->IO_ADDR_W);
 }
 
 /*
@@ -131,7 +125,7 @@ static int __init ep7312_init(void)
                return -ENOMEM;
        }
 
-       /* map physical adress */
+       /* map physical address */
        ep7312_fio_base = ioremap(ep7312_fio_pbase, SZ_1K);
        if (!ep7312_fio_base) {
                printk("ioremap EDB7312 NAND flash failed\n");
@@ -159,7 +153,7 @@ static int __init ep7312_init(void)
        /* insert callbacks */
        this->IO_ADDR_R = ep7312_fio_base;
        this->IO_ADDR_W = ep7312_fio_base;
-       this->hwcontrol = ep7312_hwcontrol;
+       this->cmd_ctrl = ep7312_hwcontrol;
        this->dev_ready = ep7312_device_ready;
        /* 15 us command delay time */
        this->chip_delay = 15;
@@ -204,8 +198,8 @@ static void __exit ep7312_cleanup(void)
        /* Release resources, unregister device */
        nand_release(ap7312_mtd);
 
-       /* Free internal data buffer */
-       kfree(this->data_buf);
+       /* Release io resource */
+       iounmap(this->IO_ADDR_R);
 
        /* Free the MTD device structure */
        kfree(ep7312_mtd);