diff options
author | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 17:25:53 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 17:25:53 -0400 |
commit | 7abd3ef9875eb2afcdcd4f450680298a2983a55e (patch) | |
tree | 64c19d2e5ecca182938acfcb8a172efb7d907d85 /drivers/mtd/nand/sharpsl.c | |
parent | 3821720d51b5f304d2c33021a82c8da70f6d6ac9 (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/sharpsl.c')
-rw-r--r-- | drivers/mtd/nand/sharpsl.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c index 5554d0b97c8c..45a1da724bff 100644 --- a/drivers/mtd/nand/sharpsl.c +++ b/drivers/mtd/nand/sharpsl.c | |||
@@ -77,31 +77,26 @@ static struct mtd_partition sharpsl_nand_default_partition_info[] = { | |||
77 | 77 | ||
78 | /* | 78 | /* |
79 | * hardware specific access to control-lines | 79 | * hardware specific access to control-lines |
80 | * ctrl: | ||
81 | * NAND_CNE: bit 0 -> bit 0 & 4 | ||
82 | * NAND_CLE: bit 1 -> bit 1 | ||
83 | * NAND_ALE: bit 2 -> bit 2 | ||
84 | * | ||
80 | */ | 85 | */ |
81 | static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd) | 86 | static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd, |
87 | unsigned int ctrl) | ||
82 | { | 88 | { |
83 | switch (cmd) { | 89 | struct nand_chip *chip = mtd->priv; |
84 | case NAND_CTL_SETCLE: | 90 | |
85 | writeb(readb(FLASHCTL) | FLCLE, FLASHCTL); | 91 | if (ctrl & NAND_CTRL_CHANGE) { |
86 | break; | 92 | unsigned char bits = ctrl & 0x07; |
87 | case NAND_CTL_CLRCLE: | 93 | |
88 | writeb(readb(FLASHCTL) & ~FLCLE, FLASHCTL); | 94 | bits |= (ctrl & 0x01) << 4; |
89 | break; | 95 | writeb((readb(FLASHCTL) & 0x17) | bits, FLASHCTL); |
90 | |||
91 | case NAND_CTL_SETALE: | ||
92 | writeb(readb(FLASHCTL) | FLALE, FLASHCTL); | ||
93 | break; | ||
94 | case NAND_CTL_CLRALE: | ||
95 | writeb(readb(FLASHCTL) & ~FLALE, FLASHCTL); | ||
96 | break; | ||
97 | |||
98 | case NAND_CTL_SETNCE: | ||
99 | writeb(readb(FLASHCTL) & ~(FLCE0 | FLCE1), FLASHCTL); | ||
100 | break; | ||
101 | case NAND_CTL_CLRNCE: | ||
102 | writeb(readb(FLASHCTL) | (FLCE0 | FLCE1), FLASHCTL); | ||
103 | break; | ||
104 | } | 96 | } |
97 | |||
98 | if (cmd != NAND_CMD_NONE) | ||
99 | writeb(cmd, chip->IO_ADDR_W); | ||
105 | } | 100 | } |
106 | 101 | ||
107 | static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; | 102 | static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; |
@@ -196,7 +191,7 @@ static int __init sharpsl_nand_init(void) | |||
196 | this->IO_ADDR_R = FLASHIO; | 191 | this->IO_ADDR_R = FLASHIO; |
197 | this->IO_ADDR_W = FLASHIO; | 192 | this->IO_ADDR_W = FLASHIO; |
198 | /* Set address of hardware control function */ | 193 | /* Set address of hardware control function */ |
199 | this->hwcontrol = sharpsl_nand_hwcontrol; | 194 | this->cmd_ctrl = sharpsl_nand_hwcontrol; |
200 | this->dev_ready = sharpsl_nand_dev_ready; | 195 | this->dev_ready = sharpsl_nand_dev_ready; |
201 | /* 15 us command delay time */ | 196 | /* 15 us command delay time */ |
202 | this->chip_delay = 15; | 197 | this->chip_delay = 15; |