aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/ts7250.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-23 17:25:53 -0400
committerThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-23 17:25:53 -0400
commit7abd3ef9875eb2afcdcd4f450680298a2983a55e (patch)
tree64c19d2e5ecca182938acfcb8a172efb7d907d85 /drivers/mtd/nand/ts7250.c
parent3821720d51b5f304d2c33021a82c8da70f6d6ac9 (diff)
[MTD] Refactor NAND hwcontrol to cmd_ctrl
The hwcontrol function enforced a step by step state machine for any kind of hardware chip access. Let the hardware driver know which control bits are set and inform it about a change of the control lines. Let the hardware driver write out the command and address bytes directly. This gives a peformance advantage for address bus controlled chips and simplifies the quirks in the hardware drivers. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/nand/ts7250.c')
-rw-r--r--drivers/mtd/nand/ts7250.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/drivers/mtd/nand/ts7250.c b/drivers/mtd/nand/ts7250.c
index 70bce1b0326c..a0b4b1edcb0d 100644
--- a/drivers/mtd/nand/ts7250.c
+++ b/drivers/mtd/nand/ts7250.c
@@ -83,31 +83,29 @@ static struct mtd_partition partition_info128[] = {
83 83
84/* 84/*
85 * hardware specific access to control-lines 85 * hardware specific access to control-lines
86 *
87 * ctrl:
88 * NAND_NCE: bit 0 -> bit 2
89 * NAND_CLE: bit 1 -> bit 1
90 * NAND_ALE: bit 2 -> bit 0
86 */ 91 */
87static void ts7250_hwcontrol(struct mtd_info *mtd, int cmd) 92static void ts7250_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
88{ 93{
89 unsigned long ctrl = TS72XX_NAND_CONTROL_VIRT_BASE; 94 struct nand_chip *chip = mtd->priv;
90 95
91 switch (cmd) { 96 if (ctrl & NAND_CTRL_CHANGE) {
92 case NAND_CTL_SETCLE: 97 unsigned long addr = TS72XX_NAND_CONTROL_VIRT_BASE;
93 __raw_writeb(__raw_readb(ctrl) | 0x2, ctrl); 98 unsigned char bits;
94 break; 99
95 case NAND_CTL_CLRCLE: 100 bits = (ctrl & NAND_CNE) << 2;
96 __raw_writeb(__raw_readb(ctrl) & ~0x2, ctrl); 101 bits |= ctrl & NAND_CLE;
97 break; 102 bits |= (ctrl & NAND_ALE) >> 2;
98 case NAND_CTL_SETALE: 103
99 __raw_writeb(__raw_readb(ctrl) | 0x1, ctrl); 104 __raw_writeb((__raw_readb(addr) & ~0x7) | bits, addr);
100 break;
101 case NAND_CTL_CLRALE:
102 __raw_writeb(__raw_readb(ctrl) & ~0x1, ctrl);
103 break;
104 case NAND_CTL_SETNCE:
105 __raw_writeb(__raw_readb(ctrl) | 0x4, ctrl);
106 break;
107 case NAND_CTL_CLRNCE:
108 __raw_writeb(__raw_readb(ctrl) & ~0x4, ctrl);
109 break;
110 } 105 }
106
107 if (cmd != NAND_CMD_NONE)
108 writeb(cmd, chip->IO_ADDR_W);
111} 109}
112 110
113/* 111/*
@@ -152,7 +150,7 @@ static int __init ts7250_init(void)
152 /* insert callbacks */ 150 /* insert callbacks */
153 this->IO_ADDR_R = (void *)TS72XX_NAND_DATA_VIRT_BASE; 151 this->IO_ADDR_R = (void *)TS72XX_NAND_DATA_VIRT_BASE;
154 this->IO_ADDR_W = (void *)TS72XX_NAND_DATA_VIRT_BASE; 152 this->IO_ADDR_W = (void *)TS72XX_NAND_DATA_VIRT_BASE;
155 this->hwcontrol = ts7250_hwcontrol; 153 this->cmd_ctrl = ts7250_hwcontrol;
156 this->dev_ready = ts7250_device_ready; 154 this->dev_ready = ts7250_device_ready;
157 this->chip_delay = 15; 155 this->chip_delay = 15;
158 this->ecc.mode = NAND_ECC_SOFT; 156 this->ecc.mode = NAND_ECC_SOFT;