]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mtd/nand/spia.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[linux-2.6-omap-h63xx.git] / drivers / mtd / nand / spia.c
index b06aada31f79a41b6957d56d3679487231a39ad9..1f6d429b158319c6db75f710e8daad63bbe48588 100644 (file)
@@ -82,26 +82,33 @@ static const struct mtd_partition partition_info[] = {
 
 /*
  *     hardware specific access to control-lines
-*/
+ *
+ *     ctrl:
+ *     NAND_CNE: bit 0 -> bit 2
+ *     NAND_CLE: bit 1 -> bit 0
+ *     NAND_ALE: bit 2 -> bit 1
+ */
 static void spia_hwcontrol(struct mtd_info *mtd, int cmd)
 {
-       switch (cmd) {
+       struct nand_chip *chip = mtd->priv;
 
-       case NAND_CTL_SETCLE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |=  0x01; break;
-       case NAND_CTL_CLRCLE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) &= ~0x01; break;
+       if (ctrl & NAND_CTRL_CHANGE) {
+               void __iomem *addr = spia_io_base + spia_pedr;
+               unsigned char bits;
 
-       case NAND_CTL_SETALE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |=  0x02; break;
-       case NAND_CTL_CLRALE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) &= ~0x02; break;
-
-       case NAND_CTL_SETNCE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) &= ~0x04; break;
-       case NAND_CTL_CLRNCE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |=  0x04; break;
+               bits = (ctrl & NAND_CNE) << 2;
+               bits |= (ctrl & NAND_CLE | NAND_ALE) >> 1;
+               writeb((readb(addr) & ~0x7) | bits, addr);
        }
+
+       if (cmd != NAND_CMD_NONE)
+               writeb(cmd, chip->IO_ADDR_W);
 }
 
 /*
  * Main initialization routine
  */
-int __init spia_init(void)
+static int __init spia_init(void)
 {
        struct nand_chip *this;
 
@@ -133,7 +140,7 @@ int __init spia_init(void)
        this->IO_ADDR_R = (void __iomem *)spia_fio_base;
        this->IO_ADDR_W = (void __iomem *)spia_fio_base;
        /* Set address of hardware control function */
-       this->hwcontrol = spia_hwcontrol;
+       this->cmd_ctrl = spia_hwcontrol;
        /* 15 us command delay time */
        this->chip_delay = 15;
 
@@ -155,7 +162,6 @@ module_init(spia_init);
 /*
  * Clean up routine
  */
-#ifdef MODULE
 static void __exit spia_cleanup(void)
 {
        /* Release resources, unregister device */
@@ -166,7 +172,6 @@ static void __exit spia_cleanup(void)
 }
 
 module_exit(spia_cleanup);
-#endif
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Steven J. Hill <sjhill@realitydiluted.com");