]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
* Add hook to NAND erase and implement nand_wait function.
authorWolfgang Denk <wd@pollux.(none)>
Wed, 2 Nov 2005 13:29:12 +0000 (14:29 +0100)
committerWolfgang Denk <wd@pollux.(none)>
Wed, 2 Nov 2005 13:29:12 +0000 (14:29 +0100)
  Patch by Mike Rapoport, 01 Nov 2005

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
common/Makefile
drivers/nand/nand_base.c
include/nand.h

index 209e17d816feb062d00e7a630b21926661745acd..9bfc11ab50b77982eb1a0278782cd39783d698e5 100644 (file)
@@ -37,7 +37,7 @@ COBJS = main.o ACEX1K.o altera.o bedbug.o circbuf.o \
          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 \
index a7ab8c27adcb93c9d40346d6c64fea0a7c04cd34..9ec5af9d714559ad6c655c2006c7f183ff4cf44f 100644 (file)
@@ -189,7 +189,11 @@ static void nand_release_device (struct mtd_info *mtd)
        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 *mtd, struct nand_chip *this, int state)
 #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
 
index 6dbaa4240276b3c64515c5f3e29b7e8f1c205431..349034772370572ddb65c50ac2bcf660c69c1868 100644 (file)
@@ -50,7 +50,14 @@ static inline int nand_block_isbad(nand_info_t *info, ulong ofs)
 
 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