aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/au1550nd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand/au1550nd.c')
-rw-r--r--drivers/mtd/nand/au1550nd.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
index 29dde7dcafa1..31228334da12 100644
--- a/drivers/mtd/nand/au1550nd.c
+++ b/drivers/mtd/nand/au1550nd.c
@@ -40,6 +40,7 @@
40static struct mtd_info *au1550_mtd = NULL; 40static struct mtd_info *au1550_mtd = NULL;
41static void __iomem *p_nand; 41static void __iomem *p_nand;
42static int nand_width = 1; /* default x8 */ 42static int nand_width = 1; /* default x8 */
43static void (*au1550_write_byte)(struct mtd_info *, u_char);
43 44
44/* 45/*
45 * Define partitions for flash device 46 * Define partitions for flash device
@@ -129,21 +130,6 @@ static u16 au_read_word(struct mtd_info *mtd)
129} 130}
130 131
131/** 132/**
132 * au_write_word - write one word to the chip
133 * @mtd: MTD device structure
134 * @word: data word to write
135 *
136 * write function for 16bit buswith without
137 * endianess conversion
138 */
139static void au_write_word(struct mtd_info *mtd, u16 word)
140{
141 struct nand_chip *this = mtd->priv;
142 writew(word, this->IO_ADDR_W);
143 au_sync();
144}
145
146/**
147 * au_write_buf - write buffer to chip 133 * au_write_buf - write buffer to chip
148 * @mtd: MTD device structure 134 * @mtd: MTD device structure
149 * @buf: data buffer 135 * @buf: data buffer
@@ -269,6 +255,18 @@ static int au_verify_buf16(struct mtd_info *mtd, const u_char *buf, int len)
269 return 0; 255 return 0;
270} 256}
271 257
258/* Select the chip by setting nCE to low */
259#define NAND_CTL_SETNCE 1
260/* Deselect the chip by setting nCE to high */
261#define NAND_CTL_CLRNCE 2
262/* Select the command latch by setting CLE to high */
263#define NAND_CTL_SETCLE 3
264/* Deselect the command latch by setting CLE to low */
265#define NAND_CTL_CLRCLE 4
266/* Select the address latch by setting ALE to high */
267#define NAND_CTL_SETALE 5
268/* Deselect the address latch by setting ALE to low */
269#define NAND_CTL_CLRALE 6
272 270
273static void au1550_hwcontrol(struct mtd_info *mtd, int cmd) 271static void au1550_hwcontrol(struct mtd_info *mtd, int cmd)
274{ 272{
@@ -349,7 +347,7 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i
349 ulong flags; 347 ulong flags;
350 348
351 /* Begin command latch cycle */ 349 /* Begin command latch cycle */
352 this->hwcontrol(mtd, NAND_CTL_SETCLE); 350 au1550_hwcontrol(mtd, NAND_CTL_SETCLE);
353 /* 351 /*
354 * Write out the command to the device. 352 * Write out the command to the device.
355 */ 353 */
@@ -367,25 +365,25 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i
367 column -= 256; 365 column -= 256;
368 readcmd = NAND_CMD_READ1; 366 readcmd = NAND_CMD_READ1;
369 } 367 }
370 this->write_byte(mtd, readcmd); 368 au1550_write_byte(mtd, readcmd);
371 } 369 }
372 this->write_byte(mtd, command); 370 au1550_write_byte(mtd, command);
373 371
374 /* Set ALE and clear CLE to start address cycle */ 372 /* Set ALE and clear CLE to start address cycle */
375 this->hwcontrol(mtd, NAND_CTL_CLRCLE); 373 au1550_hwcontrol(mtd, NAND_CTL_CLRCLE);
376 374
377 if (column != -1 || page_addr != -1) { 375 if (column != -1 || page_addr != -1) {
378 this->hwcontrol(mtd, NAND_CTL_SETALE); 376 au1550_hwcontrol(mtd, NAND_CTL_SETALE);
379 377
380 /* Serially input address */ 378 /* Serially input address */
381 if (column != -1) { 379 if (column != -1) {
382 /* Adjust columns for 16 bit buswidth */ 380 /* Adjust columns for 16 bit buswidth */
383 if (this->options & NAND_BUSWIDTH_16) 381 if (this->options & NAND_BUSWIDTH_16)
384 column >>= 1; 382 column >>= 1;
385 this->write_byte(mtd, column); 383 au1550_write_byte(mtd, column);
386 } 384 }
387 if (page_addr != -1) { 385 if (page_addr != -1) {
388 this->write_byte(mtd, (u8)(page_addr & 0xff)); 386 au1550_write_byte(mtd, (u8)(page_addr & 0xff));
389 387
390 if (command == NAND_CMD_READ0 || 388 if (command == NAND_CMD_READ0 ||
391 command == NAND_CMD_READ1 || 389 command == NAND_CMD_READ1 ||
@@ -400,17 +398,17 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i
400 */ 398 */
401 ce_override = 1; 399 ce_override = 1;
402 local_irq_save(flags); 400 local_irq_save(flags);
403 this->hwcontrol(mtd, NAND_CTL_SETNCE); 401 au1550_hwcontrol(mtd, NAND_CTL_SETNCE);
404 } 402 }
405 403
406 this->write_byte(mtd, (u8)(page_addr >> 8)); 404 au1550_write_byte(mtd, (u8)(page_addr >> 8));
407 405
408 /* One more address cycle for devices > 32MiB */ 406 /* One more address cycle for devices > 32MiB */
409 if (this->chipsize > (32 << 20)) 407 if (this->chipsize > (32 << 20))
410 this->write_byte(mtd, (u8)((page_addr >> 16) & 0x0f)); 408 au1550_write_byte(mtd, (u8)((page_addr >> 16) & 0x0f));
411 } 409 }
412 /* Latch in address */ 410 /* Latch in address */
413 this->hwcontrol(mtd, NAND_CTL_CLRALE); 411 au1550_hwcontrol(mtd, NAND_CTL_CLRALE);
414 } 412 }
415 413
416 /* 414 /*
@@ -443,7 +441,7 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i
443 udelay(1); 441 udelay(1);
444 442
445 /* Release -CE and re-enable interrupts. */ 443 /* Release -CE and re-enable interrupts. */
446 this->hwcontrol(mtd, NAND_CTL_CLRNCE); 444 au1550_hwcontrol(mtd, NAND_CTL_CLRNCE);
447 local_irq_restore(flags); 445 local_irq_restore(flags);
448 return; 446 return;
449 } 447 }
@@ -571,7 +569,6 @@ static int __init au1xxx_nand_init(void)
571 nand_width = au_readl(MEM_STCFG3) & (1 << 22); 569 nand_width = au_readl(MEM_STCFG3) & (1 << 22);
572 570
573 /* Set address of hardware control function */ 571 /* Set address of hardware control function */
574 this->hwcontrol = au1550_hwcontrol;
575 this->dev_ready = au1550_device_ready; 572 this->dev_ready = au1550_device_ready;
576 this->select_chip = au1550_select_chip; 573 this->select_chip = au1550_select_chip;
577 this->cmdfunc = au1550_command; 574 this->cmdfunc = au1550_command;
@@ -586,8 +583,7 @@ static int __init au1xxx_nand_init(void)
586 this->options |= NAND_BUSWIDTH_16; 583 this->options |= NAND_BUSWIDTH_16;
587 584
588 this->read_byte = (!nand_width) ? au_read_byte16 : au_read_byte; 585 this->read_byte = (!nand_width) ? au_read_byte16 : au_read_byte;
589 this->write_byte = (!nand_width) ? au_write_byte16 : au_write_byte; 586 au1550_write_byte = (!nand_width) ? au_write_byte16 : au_write_byte;
590 this->write_word = au_write_word;
591 this->read_word = au_read_word; 587 this->read_word = au_read_word;
592 this->write_buf = (!nand_width) ? au_write_buf16 : au_write_buf; 588 this->write_buf = (!nand_width) ? au_write_buf16 : au_write_buf;
593 this->read_buf = (!nand_width) ? au_read_buf16 : au_read_buf; 589 this->read_buf = (!nand_width) ? au_read_buf16 : au_read_buf;