All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Artem B. Bityuckiy" <abityuckiy@yandex.ru>
To: tglx@linutronix.de
Cc: linux-mtd@lists.infradead.org
Subject: nand_command
Date: Wed, 22 Sep 2004 15:13:06 +0400	[thread overview]
Message-ID: <41515E42.3020900@yandex.ru> (raw)

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.

             reply	other threads:[~2004-09-22 11:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-22 11:13 Artem B. Bityuckiy [this message]
2004-09-23  6:25 ` nand_command Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41515E42.3020900@yandex.ru \
    --to=abityuckiy@yandex.ru \
    --cc=linux-mtd@lists.infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.