2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* drivers/mtd/nand/au1550nd.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Embedded Edge, LLC
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/slab.h>
|
2011-05-08 10:42:20 +02:00
|
|
|
#include <linux/gpio.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/module.h>
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
#include <linux/interrupt.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/mtd/mtd.h>
|
|
|
|
#include <linux/mtd/nand.h>
|
|
|
|
#include <linux/mtd/partitions.h>
|
2011-12-08 11:42:10 +01:00
|
|
|
#include <linux/platform_device.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/io.h>
|
2011-12-08 11:42:10 +01:00
|
|
|
#include <asm/mach-au1x00/au1000.h>
|
|
|
|
#include <asm/mach-au1x00/au1550nd.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
struct au1550nd_ctx {
|
|
|
|
struct mtd_info info;
|
|
|
|
struct nand_chip chip;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
int cs;
|
|
|
|
void __iomem *base;
|
|
|
|
void (*write_byte)(struct mtd_info *, u_char);
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* au_read_byte - read one byte from the chip
|
|
|
|
* @mtd: MTD device structure
|
|
|
|
*
|
2011-06-23 23:12:08 +02:00
|
|
|
* read function for 8bit buswidth
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static u_char au_read_byte(struct mtd_info *mtd)
|
|
|
|
{
|
|
|
|
struct nand_chip *this = mtd->priv;
|
|
|
|
u_char ret = readb(this->IO_ADDR_R);
|
2014-07-23 16:36:26 +02:00
|
|
|
wmb(); /* drain writebuffer */
|
2005-04-17 00:20:36 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* au_write_byte - write one byte to the chip
|
|
|
|
* @mtd: MTD device structure
|
|
|
|
* @byte: pointer to data byte to write
|
|
|
|
*
|
2011-06-23 23:12:08 +02:00
|
|
|
* write function for 8it buswidth
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static void au_write_byte(struct mtd_info *mtd, u_char byte)
|
|
|
|
{
|
|
|
|
struct nand_chip *this = mtd->priv;
|
|
|
|
writeb(byte, this->IO_ADDR_W);
|
2014-07-23 16:36:26 +02:00
|
|
|
wmb(); /* drain writebuffer */
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-06-23 23:12:08 +02:00
|
|
|
* au_read_byte16 - read one byte endianness aware from the chip
|
2005-04-17 00:20:36 +02:00
|
|
|
* @mtd: MTD device structure
|
|
|
|
*
|
2011-06-23 23:12:08 +02:00
|
|
|
* read function for 16bit buswidth with endianness conversion
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static u_char au_read_byte16(struct mtd_info *mtd)
|
|
|
|
{
|
|
|
|
struct nand_chip *this = mtd->priv;
|
|
|
|
u_char ret = (u_char) cpu_to_le16(readw(this->IO_ADDR_R));
|
2014-07-23 16:36:26 +02:00
|
|
|
wmb(); /* drain writebuffer */
|
2005-04-17 00:20:36 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-06-23 23:12:08 +02:00
|
|
|
* au_write_byte16 - write one byte endianness aware to the chip
|
2005-04-17 00:20:36 +02:00
|
|
|
* @mtd: MTD device structure
|
|
|
|
* @byte: pointer to data byte to write
|
|
|
|
*
|
2011-06-23 23:12:08 +02:00
|
|
|
* write function for 16bit buswidth with endianness conversion
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static void au_write_byte16(struct mtd_info *mtd, u_char byte)
|
|
|
|
{
|
|
|
|
struct nand_chip *this = mtd->priv;
|
|
|
|
writew(le16_to_cpu((u16) byte), this->IO_ADDR_W);
|
2014-07-23 16:36:26 +02:00
|
|
|
wmb(); /* drain writebuffer */
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* au_read_word - read one word from the chip
|
|
|
|
* @mtd: MTD device structure
|
|
|
|
*
|
2011-06-23 23:12:08 +02:00
|
|
|
* read function for 16bit buswidth without endianness conversion
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static u16 au_read_word(struct mtd_info *mtd)
|
|
|
|
{
|
|
|
|
struct nand_chip *this = mtd->priv;
|
|
|
|
u16 ret = readw(this->IO_ADDR_R);
|
2014-07-23 16:36:26 +02:00
|
|
|
wmb(); /* drain writebuffer */
|
2005-04-17 00:20:36 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* au_write_buf - write buffer to chip
|
|
|
|
* @mtd: MTD device structure
|
|
|
|
* @buf: data buffer
|
|
|
|
* @len: number of bytes to write
|
|
|
|
*
|
2011-06-23 23:12:08 +02:00
|
|
|
* write function for 8bit buswidth
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct nand_chip *this = mtd->priv;
|
|
|
|
|
2006-05-13 19:07:53 +02:00
|
|
|
for (i = 0; i < len; i++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
writeb(buf[i], this->IO_ADDR_W);
|
2014-07-23 16:36:26 +02:00
|
|
|
wmb(); /* drain writebuffer */
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-11-07 12:15:49 +01:00
|
|
|
* au_read_buf - read chip data into buffer
|
2005-04-17 00:20:36 +02:00
|
|
|
* @mtd: MTD device structure
|
|
|
|
* @buf: buffer to store date
|
|
|
|
* @len: number of bytes to read
|
|
|
|
*
|
2011-06-23 23:12:08 +02:00
|
|
|
* read function for 8bit buswidth
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static void au_read_buf(struct mtd_info *mtd, u_char *buf, int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct nand_chip *this = mtd->priv;
|
|
|
|
|
2006-05-13 19:07:53 +02:00
|
|
|
for (i = 0; i < len; i++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
buf[i] = readb(this->IO_ADDR_R);
|
2014-07-23 16:36:26 +02:00
|
|
|
wmb(); /* drain writebuffer */
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* au_write_buf16 - write buffer to chip
|
|
|
|
* @mtd: MTD device structure
|
|
|
|
* @buf: data buffer
|
|
|
|
* @len: number of bytes to write
|
|
|
|
*
|
2011-06-23 23:12:08 +02:00
|
|
|
* write function for 16bit buswidth
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static void au_write_buf16(struct mtd_info *mtd, const u_char *buf, int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct nand_chip *this = mtd->priv;
|
|
|
|
u16 *p = (u16 *) buf;
|
|
|
|
len >>= 1;
|
2005-11-07 12:15:49 +01:00
|
|
|
|
2006-05-13 19:07:53 +02:00
|
|
|
for (i = 0; i < len; i++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
writew(p[i], this->IO_ADDR_W);
|
2014-07-23 16:36:26 +02:00
|
|
|
wmb(); /* drain writebuffer */
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2005-11-07 12:15:49 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-11-07 12:15:49 +01:00
|
|
|
* au_read_buf16 - read chip data into buffer
|
2005-04-17 00:20:36 +02:00
|
|
|
* @mtd: MTD device structure
|
|
|
|
* @buf: buffer to store date
|
|
|
|
* @len: number of bytes to read
|
|
|
|
*
|
2011-06-23 23:12:08 +02:00
|
|
|
* read function for 16bit buswidth
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static void au_read_buf16(struct mtd_info *mtd, u_char *buf, int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct nand_chip *this = mtd->priv;
|
|
|
|
u16 *p = (u16 *) buf;
|
|
|
|
len >>= 1;
|
|
|
|
|
2006-05-13 19:07:53 +02:00
|
|
|
for (i = 0; i < len; i++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
p[i] = readw(this->IO_ADDR_R);
|
2014-07-23 16:36:26 +02:00
|
|
|
wmb(); /* drain writebuffer */
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-23 23:25:53 +02:00
|
|
|
/* Select the chip by setting nCE to low */
|
|
|
|
#define NAND_CTL_SETNCE 1
|
|
|
|
/* Deselect the chip by setting nCE to high */
|
|
|
|
#define NAND_CTL_CLRNCE 2
|
|
|
|
/* Select the command latch by setting CLE to high */
|
|
|
|
#define NAND_CTL_SETCLE 3
|
|
|
|
/* Deselect the command latch by setting CLE to low */
|
|
|
|
#define NAND_CTL_CLRCLE 4
|
|
|
|
/* Select the address latch by setting ALE to high */
|
|
|
|
#define NAND_CTL_SETALE 5
|
|
|
|
/* Deselect the address latch by setting ALE to low */
|
|
|
|
#define NAND_CTL_CLRALE 6
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
static void au1550_hwcontrol(struct mtd_info *mtd, int cmd)
|
|
|
|
{
|
2011-12-08 11:42:10 +01:00
|
|
|
struct au1550nd_ctx *ctx = container_of(mtd, struct au1550nd_ctx, info);
|
|
|
|
struct nand_chip *this = mtd->priv;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-05-13 19:07:53 +02:00
|
|
|
switch (cmd) {
|
|
|
|
|
|
|
|
case NAND_CTL_SETCLE:
|
2011-12-08 11:42:10 +01:00
|
|
|
this->IO_ADDR_W = ctx->base + MEM_STNAND_CMD;
|
2006-05-13 19:07:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NAND_CTL_CLRCLE:
|
2011-12-08 11:42:10 +01:00
|
|
|
this->IO_ADDR_W = ctx->base + MEM_STNAND_DATA;
|
2006-05-13 19:07:53 +02:00
|
|
|
break;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-05-13 19:07:53 +02:00
|
|
|
case NAND_CTL_SETALE:
|
2011-12-08 11:42:10 +01:00
|
|
|
this->IO_ADDR_W = ctx->base + MEM_STNAND_ADDR;
|
2006-05-13 19:07:53 +02:00
|
|
|
break;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-11-07 12:15:49 +01:00
|
|
|
case NAND_CTL_CLRALE:
|
2011-12-08 11:42:10 +01:00
|
|
|
this->IO_ADDR_W = ctx->base + MEM_STNAND_DATA;
|
2006-05-13 19:07:53 +02:00
|
|
|
/* FIXME: Nobody knows why this is necessary,
|
2005-04-17 00:20:36 +02:00
|
|
|
* but it works only that way */
|
2005-11-07 12:15:49 +01:00
|
|
|
udelay(1);
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
|
2005-11-07 12:15:49 +01:00
|
|
|
case NAND_CTL_SETNCE:
|
2005-04-17 00:20:36 +02:00
|
|
|
/* assert (force assert) chip enable */
|
2014-07-23 16:36:25 +02:00
|
|
|
alchemy_wrsmem((1 << (4 + ctx->cs)), AU1000_MEM_STNDCTL);
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
|
2005-11-07 12:15:49 +01:00
|
|
|
case NAND_CTL_CLRNCE:
|
2006-05-13 19:07:53 +02:00
|
|
|
/* deassert chip enable */
|
2014-07-23 16:36:25 +02:00
|
|
|
alchemy_wrsmem(0, AU1000_MEM_STNDCTL);
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->IO_ADDR_R = this->IO_ADDR_W;
|
2005-11-07 12:15:49 +01:00
|
|
|
|
2014-07-23 16:36:26 +02:00
|
|
|
wmb(); /* Drain the writebuffer */
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int au1550_device_ready(struct mtd_info *mtd)
|
|
|
|
{
|
2014-07-23 16:36:25 +02:00
|
|
|
return (alchemy_rdsmem(AU1000_MEM_STSTAT) & 0x1) ? 1 : 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
/**
|
|
|
|
* au1550_select_chip - control -CE line
|
|
|
|
* Forbid driving -CE manually permitting the NAND controller to do this.
|
|
|
|
* Keeping -CE asserted during the whole sector reads interferes with the
|
|
|
|
* NOR flash and PCMCIA drivers as it causes contention on the static bus.
|
|
|
|
* We only have to hold -CE low for the NAND read commands since the flash
|
|
|
|
* chip needs it to be asserted during chip not ready time but the NAND
|
|
|
|
* controller keeps it released.
|
|
|
|
*
|
|
|
|
* @mtd: MTD device structure
|
|
|
|
* @chip: chipnumber to select, -1 for deselect
|
|
|
|
*/
|
|
|
|
static void au1550_select_chip(struct mtd_info *mtd, int chip)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* au1550_command - Send command to NAND device
|
|
|
|
* @mtd: MTD device structure
|
|
|
|
* @command: the command to be sent
|
|
|
|
* @column: the column address for this command, -1 if none
|
|
|
|
* @page_addr: the page address for this command, -1 if none
|
|
|
|
*/
|
|
|
|
static void au1550_command(struct mtd_info *mtd, unsigned command, int column, int page_addr)
|
|
|
|
{
|
2011-12-08 11:42:10 +01:00
|
|
|
struct au1550nd_ctx *ctx = container_of(mtd, struct au1550nd_ctx, info);
|
|
|
|
struct nand_chip *this = mtd->priv;
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
int ce_override = 0, i;
|
2011-12-08 11:42:10 +01:00
|
|
|
unsigned long flags = 0;
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
|
|
|
|
/* Begin command latch cycle */
|
2006-05-23 23:25:53 +02:00
|
|
|
au1550_hwcontrol(mtd, NAND_CTL_SETCLE);
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
/*
|
|
|
|
* Write out the command to the device.
|
|
|
|
*/
|
|
|
|
if (command == NAND_CMD_SEQIN) {
|
|
|
|
int readcmd;
|
|
|
|
|
2006-05-22 23:18:05 +02:00
|
|
|
if (column >= mtd->writesize) {
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
/* OOB area */
|
2006-05-22 23:18:05 +02:00
|
|
|
column -= mtd->writesize;
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
readcmd = NAND_CMD_READOOB;
|
|
|
|
} else if (column < 256) {
|
|
|
|
/* First 256 bytes --> READ0 */
|
|
|
|
readcmd = NAND_CMD_READ0;
|
|
|
|
} else {
|
|
|
|
column -= 256;
|
|
|
|
readcmd = NAND_CMD_READ1;
|
|
|
|
}
|
2011-12-08 11:42:10 +01:00
|
|
|
ctx->write_byte(mtd, readcmd);
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
}
|
2011-12-08 11:42:10 +01:00
|
|
|
ctx->write_byte(mtd, command);
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
|
|
|
|
/* Set ALE and clear CLE to start address cycle */
|
2006-05-23 23:25:53 +02:00
|
|
|
au1550_hwcontrol(mtd, NAND_CTL_CLRCLE);
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
|
|
|
|
if (column != -1 || page_addr != -1) {
|
2006-05-23 23:25:53 +02:00
|
|
|
au1550_hwcontrol(mtd, NAND_CTL_SETALE);
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
|
|
|
|
/* Serially input address */
|
|
|
|
if (column != -1) {
|
|
|
|
/* Adjust columns for 16 bit buswidth */
|
mtd: nand: force NAND_CMD_READID onto 8-bit bus
The NAND command helpers tend to automatically shift the column address
for x16 bus devices, since most commands expect a word address, not a
byte address. The Read ID command, however, expects an 8-bit address
(i.e., 0x00, 0x20, or 0x40 should not be translated to 0x00, 0x10, or
0x20).
This fixes the column address for a few drivers which imitate the
nand_base defaults. Note that I don't touch sh_flctl.c, since it already
handles this problem slightly differently (note its comment "READID is
always performed using an 8-bit bus").
I have not tested this patch, as I only have x8 parts up for testing at
this point. Hopefully that can change soon...
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Tested-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-By: Pekon Gupta <pekon@ti.com>
2014-01-29 23:08:12 +01:00
|
|
|
if (this->options & NAND_BUSWIDTH_16 &&
|
|
|
|
!nand_opcode_8bits(command))
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
column >>= 1;
|
2011-12-08 11:42:10 +01:00
|
|
|
ctx->write_byte(mtd, column);
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
}
|
|
|
|
if (page_addr != -1) {
|
2011-12-08 11:42:10 +01:00
|
|
|
ctx->write_byte(mtd, (u8)(page_addr & 0xff));
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
|
|
|
|
if (command == NAND_CMD_READ0 ||
|
|
|
|
command == NAND_CMD_READ1 ||
|
|
|
|
command == NAND_CMD_READOOB) {
|
|
|
|
/*
|
|
|
|
* NAND controller will release -CE after
|
|
|
|
* the last address byte is written, so we'll
|
|
|
|
* have to forcibly assert it. No interrupts
|
|
|
|
* are allowed while we do this as we don't
|
|
|
|
* want the NOR flash or PCMCIA drivers to
|
|
|
|
* steal our precious bytes of data...
|
|
|
|
*/
|
|
|
|
ce_override = 1;
|
|
|
|
local_irq_save(flags);
|
2006-05-23 23:25:53 +02:00
|
|
|
au1550_hwcontrol(mtd, NAND_CTL_SETNCE);
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
}
|
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
ctx->write_byte(mtd, (u8)(page_addr >> 8));
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
|
|
|
|
/* One more address cycle for devices > 32MiB */
|
|
|
|
if (this->chipsize > (32 << 20))
|
2011-12-08 11:42:10 +01:00
|
|
|
ctx->write_byte(mtd,
|
|
|
|
((page_addr >> 16) & 0x0f));
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
}
|
|
|
|
/* Latch in address */
|
2006-05-23 23:25:53 +02:00
|
|
|
au1550_hwcontrol(mtd, NAND_CTL_CLRALE);
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Program and erase have their own busy handlers.
|
|
|
|
* Status and sequential in need no delay.
|
|
|
|
*/
|
|
|
|
switch (command) {
|
|
|
|
|
|
|
|
case NAND_CMD_PAGEPROG:
|
|
|
|
case NAND_CMD_ERASE1:
|
|
|
|
case NAND_CMD_ERASE2:
|
|
|
|
case NAND_CMD_SEQIN:
|
|
|
|
case NAND_CMD_STATUS:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case NAND_CMD_RESET:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAND_CMD_READ0:
|
|
|
|
case NAND_CMD_READ1:
|
|
|
|
case NAND_CMD_READOOB:
|
|
|
|
/* Check if we're really driving -CE low (just in case) */
|
|
|
|
if (unlikely(!ce_override))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Apply a short delay always to ensure that we do wait tWB. */
|
|
|
|
ndelay(100);
|
|
|
|
/* Wait for a chip to become ready... */
|
|
|
|
for (i = this->chip_delay; !this->dev_ready(mtd) && i > 0; --i)
|
|
|
|
udelay(1);
|
|
|
|
|
|
|
|
/* Release -CE and re-enable interrupts. */
|
2006-05-23 23:25:53 +02:00
|
|
|
au1550_hwcontrol(mtd, NAND_CTL_CLRNCE);
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
local_irq_restore(flags);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Apply this short delay always to ensure that we do wait tWB. */
|
|
|
|
ndelay(100);
|
|
|
|
|
|
|
|
while(!this->dev_ready(mtd));
|
|
|
|
}
|
|
|
|
|
2012-11-19 19:23:07 +01:00
|
|
|
static int find_nand_cs(unsigned long nand_base)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2011-12-08 11:42:10 +01:00
|
|
|
void __iomem *base =
|
|
|
|
(void __iomem *)KSEG1ADDR(AU1000_STATIC_MEM_PHYS_ADDR);
|
|
|
|
unsigned long addr, staddr, start, mask, end;
|
|
|
|
int i;
|
2005-11-07 12:15:49 +01:00
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
addr = 0x1000 + (i * 0x10); /* CSx */
|
|
|
|
staddr = __raw_readl(base + addr + 0x08); /* STADDRx */
|
|
|
|
/* figure out the decoded range of this CS */
|
|
|
|
start = (staddr << 4) & 0xfffc0000;
|
|
|
|
mask = (staddr << 18) & 0xfffc0000;
|
|
|
|
end = (start | (start - 1)) & ~(start ^ mask);
|
|
|
|
if ((nand_base >= start) && (nand_base < end))
|
|
|
|
return i;
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2012-11-19 19:23:07 +01:00
|
|
|
static int au1550nd_probe(struct platform_device *pdev)
|
2011-12-08 11:42:10 +01:00
|
|
|
{
|
|
|
|
struct au1550nd_platdata *pd;
|
|
|
|
struct au1550nd_ctx *ctx;
|
|
|
|
struct nand_chip *this;
|
|
|
|
struct resource *r;
|
|
|
|
int ret, cs;
|
2009-10-04 14:55:24 +02:00
|
|
|
|
2013-07-30 10:18:33 +02:00
|
|
|
pd = dev_get_platdata(&pdev->dev);
|
2011-12-08 11:42:10 +01:00
|
|
|
if (!pd) {
|
|
|
|
dev_err(&pdev->dev, "missing platform data\n");
|
|
|
|
return -ENODEV;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2011-12-08 11:42:10 +01:00
|
|
|
|
|
|
|
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
|
2013-12-26 04:02:30 +01:00
|
|
|
if (!ctx)
|
2011-12-08 11:42:10 +01:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
if (!r) {
|
|
|
|
dev_err(&pdev->dev, "no NAND memory resource\n");
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto out1;
|
2005-09-23 03:44:58 +02:00
|
|
|
}
|
2011-12-08 11:42:10 +01:00
|
|
|
if (request_mem_region(r->start, resource_size(r), "au1550-nand")) {
|
|
|
|
dev_err(&pdev->dev, "cannot claim NAND memory area\n");
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out1;
|
2005-09-23 03:44:58 +02:00
|
|
|
}
|
2011-12-08 11:42:10 +01:00
|
|
|
|
|
|
|
ctx->base = ioremap_nocache(r->start, 0x1000);
|
|
|
|
if (!ctx->base) {
|
|
|
|
dev_err(&pdev->dev, "cannot remap NAND memory area\n");
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto out2;
|
2005-09-23 03:44:58 +02:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
this = &ctx->chip;
|
|
|
|
ctx->info.priv = this;
|
2015-06-10 22:38:37 +02:00
|
|
|
ctx->info.dev.parent = &pdev->dev;
|
2005-09-23 03:44:58 +02:00
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
/* figure out which CS# r->start belongs to */
|
|
|
|
cs = find_nand_cs(r->start);
|
|
|
|
if (cs < 0) {
|
|
|
|
dev_err(&pdev->dev, "cannot detect NAND chipselect\n");
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto out3;
|
|
|
|
}
|
|
|
|
ctx->cs = cs;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
this->dev_ready = au1550_device_ready;
|
NAND: Fix NAND ECC errors on AMD Au1550
On AMD Au1550 the static bus controller fails to keep -CE asserted during
chip ready delay on read commands and the NAND chip being used requires this.
So, the current driver allows nand_base.c to drive -CE manually during the
entire sector read. When the PCMCIA driver is enabled however, occasionally
the ECC errors occur on NAND reads. This happens because the PCMCIA driver
polls sockets periodically and reads one of the board's control/status regs
(BCSRs) which are on the same static bus as the NAND flash, and just use
another chip select (and the NOR flash also resides on that bus), so as the
NAND driver forces NAND chip select asserted and the -RE signal is shared, a
contention occurs on the static bus when BCSR or NOR flash is read while we're
reading from NAND.
So, we either can't keep interrupts enabled during the whole NAND sector
read (which is hardly acceptable), or have to implement some interlocking
scheme between multiple drivers (which is painful, and makes me shudder :-).
There's a third way which has proven to work: to force -CE asserted only
while we're waiting for a NAND chip to become ready after a read command,
disabling interrupts for a maximum of 25 microseconds (according to Toshiba
TC58DVM92A1FT00 datasheet -- this chip is mentioned in the board schematics);
for Samsung NAND chip which seems to be actually used this delay is even less,
12 us.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-16 18:52:06 +02:00
|
|
|
this->select_chip = au1550_select_chip;
|
|
|
|
this->cmdfunc = au1550_command;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* 30 us command delay time */
|
2005-11-07 12:15:49 +01:00
|
|
|
this->chip_delay = 30;
|
2006-05-23 12:00:46 +02:00
|
|
|
this->ecc.mode = NAND_ECC_SOFT;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
if (pd->devwidth)
|
2005-04-17 00:20:36 +02:00
|
|
|
this->options |= NAND_BUSWIDTH_16;
|
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
this->read_byte = (pd->devwidth) ? au_read_byte16 : au_read_byte;
|
|
|
|
ctx->write_byte = (pd->devwidth) ? au_write_byte16 : au_write_byte;
|
2005-04-17 00:20:36 +02:00
|
|
|
this->read_word = au_read_word;
|
2011-12-08 11:42:10 +01:00
|
|
|
this->write_buf = (pd->devwidth) ? au_write_buf16 : au_write_buf;
|
|
|
|
this->read_buf = (pd->devwidth) ? au_read_buf16 : au_read_buf;
|
|
|
|
|
|
|
|
ret = nand_scan(&ctx->info, 1);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(&pdev->dev, "NAND scan failed with %d\n", ret);
|
|
|
|
goto out3;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
mtd_device_register(&ctx->info, pd->parts, pd->num_parts);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2013-11-11 07:18:29 +01:00
|
|
|
platform_set_drvdata(pdev, ctx);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
out3:
|
|
|
|
iounmap(ctx->base);
|
|
|
|
out2:
|
|
|
|
release_mem_region(r->start, resource_size(r));
|
|
|
|
out1:
|
|
|
|
kfree(ctx);
|
|
|
|
return ret;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2012-11-19 19:26:04 +01:00
|
|
|
static int au1550nd_remove(struct platform_device *pdev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2011-12-08 11:42:10 +01:00
|
|
|
struct au1550nd_ctx *ctx = platform_get_drvdata(pdev);
|
|
|
|
struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
nand_release(&ctx->info);
|
|
|
|
iounmap(ctx->base);
|
|
|
|
release_mem_region(r->start, 0x1000);
|
|
|
|
kfree(ctx);
|
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2006-05-13 19:07:53 +02:00
|
|
|
|
2011-12-08 11:42:10 +01:00
|
|
|
static struct platform_driver au1550nd_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "au1550-nand",
|
|
|
|
},
|
|
|
|
.probe = au1550nd_probe,
|
2012-11-19 19:21:24 +01:00
|
|
|
.remove = au1550nd_remove,
|
2011-12-08 11:42:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
module_platform_driver(au1550nd_driver);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Embedded Edge, LLC");
|
|
|
|
MODULE_DESCRIPTION("Board-specific glue layer for NAND flash on Pb1550 board");
|