nand_command
Artem B. Bityuckiy
abityuckiy at yandex.ru
Wed Sep 22 07:13:06 EDT 2004
Hello.
Thomas, as you sad, "only the ones with 512byte pagesize" NAND chips
support operations like this:
1. NAND_CND_READ0, NAND_CMD_SEQIN, <addr>, <data>, NAND_CMD_PAGEPRG
2. NAND_CND_READ1, NAND_CMD_SEQIN, <addr>, <data>, NAND_CMD_PAGEPRG
3. NAND_CND_READOOB, NAND_CMD_SEQIN, <addr>, <data>, NAND_CMD_PAGEPRG
The first chain - programm page starting from the beginning
The second chain - programm page starting from the second half
The third chain - programm starting from OOB area.
Chips with 256-byte page support only one programm operation like this:
NAND_CMD_SEQIN, <addr>, <data>, NAND_CMD_PAGEPRG
Correct? (I can't find any 256-byte page Flash manual to check)
If I'm correct, I propose to change a little the default command
function for "small page" devices (nand_base.c, nand_command). The code
is like this:
static void nand_command (struct mtd_info *mtd, unsigned command, int
column, int page_addr)
{
register struct nand_chip *this = mtd->priv;
/* Begin command latch cycle */
this->hwcontrol(mtd, NAND_CTL_SETCLE);
/*
* Write out the command to the device.
*/
if (command == NAND_CMD_SEQIN) {
int readcmd;
if (column >= mtd->oobblock) {
/* OOB area */
column -= mtd->oobblock;
readcmd = NAND_CMD_READOOB;
} else if (column < 256) {
/* First 256 bytes --> READ0 */
readcmd = NAND_CMD_READ0;
} else {
column -= 256;
readcmd = NAND_CMD_READ1;
}
this->write_byte(mtd, readcmd);
}
this->write_byte(mtd, command);
.............
It can be seen that for "small page" devices the NAND_CMD_READ0 command
is also input before NAND_CMD_SEQIN. This is not big error, but if to be
pedantic, this isn't needed.
I propose to change this code the following way:
static void nand_command (struct mtd_info *mtd, unsigned command, int
column, int page_addr)
{
register struct nand_chip *this = mtd->priv;
/* Begin command latch cycle */
this->hwcontrol(mtd, NAND_CTL_SETCLE);
/*
* Write out the command to the device.
*/
if (mtd->oobblock > 256 && command == NAND_CMD_SEQIN) { /*
<----- here */
int readcmd;
if (column >= mtd->oobblock) {
/* OOB area */
column -= mtd->oobblock;
readcmd = NAND_CMD_READOOB;
} else if (column < 256) {
/* First 256 bytes --> READ0 */
readcmd = NAND_CMD_READ0;
} else {
column -= 256;
readcmd = NAND_CMD_READ1;
}
this->write_byte(mtd, readcmd);
}
this->write_byte(mtd, command);
.............
Comments?
--
Best Regards,
Artem B. Bityuckiy,
St.-Petersburg, Russia.
More information about the linux-mtd
mailing list