summaryrefslogtreecommitdiffstats
path: root/common/cmd_nand.c
diff options
context:
space:
mode:
authorwdenk <wdenk>2003-03-31 16:34:49 +0000
committerwdenk <wdenk>2003-03-31 16:34:49 +0000
commit85ec0bcc1bc40a67368461fee0435d79305168b1 (patch)
tree084062015af4a61080c48c1796dcffbc90ab02f1 /common/cmd_nand.c
parent506f044131515a80c7c8479a84df028be880b34e (diff)
downloadu-boot-85ec0bcc1bc40a67368461fee0435d79305168b1.tar.gz
u-boot-85ec0bcc1bc40a67368461fee0435d79305168b1.tar.xz
u-boot-85ec0bcc1bc40a67368461fee0435d79305168b1.zip
* Patch by Arun Dharankar, 24 Mar 2003:
- add threads / scheduler example code * Add patches by Robert Schwebel, 31 Mar 2003: - add ctrl-c support for kermit download - align bdinfo output on ARM * Add CPU ID, version, and clock speed for INCA-IP
Diffstat (limited to 'common/cmd_nand.c')
-rw-r--r--common/cmd_nand.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index e9331200f7..a041b29c20 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -1266,6 +1266,7 @@ static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len)
{
unsigned long nandptr;
struct Nand *mychip;
+ int ret = 0;
if (ofs & (nand->erasesize-1) || len & (nand->erasesize-1)) {
printf ("Offset and size must be sector aligned, erasesize = %d\n",
@@ -1275,6 +1276,17 @@ static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len)
nandptr = nand->IO_ADDR;
+ /* Select the NAND device */
+ NAND_ENABLE_CE(nand); /* set pin low */
+
+ /* Check the WP bit */
+ NanD_Command(nand, NAND_CMD_STATUS);
+ if (!(READ_NAND(nand->IO_ADDR) & 0x80)) {
+ printf ("nand_write_ecc: Device is write protected!!!\n");
+ ret = -1;
+ goto out;
+ }
+
/* FIXME: Do nand in the background. Use timers or schedule_task() */
while(len) {
mychip = &nand->chips[shr(ofs, nand->chipshift)];
@@ -1288,20 +1300,22 @@ static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len)
if (READ_NAND(nandptr) & 1) {
printf("Error erasing at 0x%lx\n", (long)ofs);
/* There was an error */
- goto callback;
+ ret = -1;
+ goto out;
}
ofs += nand->erasesize;
len -= nand->erasesize;
}
- callback:
- return 0;
+out:
+ /* De-select the NAND device */
+ NAND_DISABLE_CE(nand); /* set pin high */
+
+ return ret;
}
static inline int nandcheck(unsigned long potential, unsigned long physadr)
{
-
-
return 0;
}