public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ladislav Michl <ladis@linux-mips.org>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] NAND flash support
Date: Wed, 2 Nov 2005 14:18:53 +0100	[thread overview]
Message-ID: <20051102131853.GA17528@orphique> (raw)
In-Reply-To: <f870da180511010622g26dccedey9f59f1600624047e@mail.gmail.com>

On Tue, Nov 01, 2005 at 04:22:28PM +0200, Mike Rapoport wrote:
> I've tried to make it as clean as possible, but there still may be
> some junk I used for debugging.

Thanks a lot. Updated version (with timeout handling) follows - generated
against testing-NAND branch. Wolfgang, could you apply?

I also got another board with NAND chip for testing and I was able to
reproduce your problem with with bus error. I'll look at it as soon as
I get some spare time.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>

CHANGELOG:
* Add hook to NAND erase and implement nand_wait function.
  Patch by Mike Rapoport, 1 Nov 2005
  
diff --git a/common/Makefile b/common/Makefile
--- a/common/Makefile
+++ b/common/Makefile
@@ -37,7 +37,7 @@ COBJS	= main.o ACEX1K.o altera.o bedbug.
 	  cmd_i2c.o cmd_ide.o cmd_immap.o cmd_itest.o cmd_jffs2.o \
 	  cmd_load.o cmd_log.o \
 	  cmd_mem.o cmd_mii.o cmd_misc.o cmd_mmc.o \
-	  cmd_nand.o cmd_net.o cmd_nvedit.o \
+	  cmd_nand.o cmd_nand_new.o cmd_net.o cmd_nvedit.o \
 	  cmd_pci.o cmd_pcmcia.o cmd_portio.o \
 	  cmd_reginfo.o cmd_reiser.o cmd_scsi.o cmd_spi.o cmd_universe.o cmd_usb.o cmd_vfd.o \
 	  command.o console.o devices.o dlmalloc.o docecc.o \
diff --git a/drivers/nand/nand_base.c b/drivers/nand/nand_base.c
--- a/drivers/nand/nand_base.c
+++ b/drivers/nand/nand_base.c
@@ -189,7 +189,11 @@ static void nand_release_device (struct 
 	spin_unlock (&this->chip_lock);
 }
 #else
-#define nand_release_device(mtd)	do {} while(0)
+static void nand_release_device (struct mtd_info *mtd)
+{
+	struct nand_chip *this = mtd->priv;
+	this->select_chip(mtd, -1);	/* De-select the NAND device */
+}
 #endif
 
 /**
@@ -831,8 +835,34 @@ static int nand_wait(struct mtd_info *mt
 #else
 static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
 {
-	/* TODO */
-	return 0;
+	unsigned long	timeo;
+
+	if (state == FL_ERASING)
+		timeo = CFG_HZ * 400;
+	else
+		timeo = CFG_HZ * 20;
+
+	if ((state == FL_ERASING) && (this->options & NAND_IS_AND))
+		this->cmdfunc(mtd, NAND_CMD_STATUS_MULTI, -1, -1);
+	else
+		this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
+
+	reset_timer_masked();
+
+	while (1) {
+		if (get_timer_masked() > timeo)
+			return 0;
+
+		if (this->dev_ready) {
+			if (this->dev_ready(mtd))
+				break;
+		} else {
+			if (this->read_byte(mtd) & NAND_STATUS_READY)
+				break;
+		}
+	}
+
+	return this->read_byte(mtd);
 }
 #endif
 
diff --git a/include/bmp_logo.h b/include/bmp_logo.h
diff --git a/include/nand.h b/include/nand.h
--- a/include/nand.h
+++ b/include/nand.h
@@ -50,7 +50,14 @@ static inline int nand_block_isbad(nand_
 
 static inline int nand_erase(nand_info_t *info, ulong off, ulong size)
 {
-	return 0; /* FIXME */
+	struct erase_info instr;
+
+	instr.mtd = info;
+	instr.addr = off;
+	instr.len = size;
+	instr.callback = 0;
+
+	return info->erase(info, &instr);
 }
 
 #endif

  reply	other threads:[~2005-11-02 13:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20051028135742.8BAD11606F@sc8-sf-spam2.sourceforge.net>
2005-10-31  8:47 ` [U-Boot-Users] NAND flash support Terence Soh
2005-10-31  9:23   ` Wolfgang Denk
2005-11-01  7:46     ` Mike Rapoport
2005-11-01 12:06       ` Ladislav Michl
2005-11-01 14:22         ` Mike Rapoport
2005-11-02 13:18           ` Ladislav Michl [this message]
2006-08-01 17:29 mitsy

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=20051102131853.GA17528@orphique \
    --to=ladis@linux-mips.org \
    --cc=u-boot@lists.denx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox