diff options
| author | Wolfgang Denk <wd@pollux.(none)> | 2005-11-02 14:29:12 +0100 | 
|---|---|---|
| committer | Wolfgang Denk <wd@pollux.(none)> | 2005-11-02 14:29:12 +0100 | 
| commit | 8e9655f863246db60c51140153186acc2afdc855 (patch) | |
| tree | 5bf681d78aaac91aac3ddaeef4972752cba33816 /drivers/nand/nand_base.c | |
| parent | ac7eb8a315e25863637a8d2c02af18815458b63f (diff) | |
| download | olio-uboot-2014.01-8e9655f863246db60c51140153186acc2afdc855.tar.xz olio-uboot-2014.01-8e9655f863246db60c51140153186acc2afdc855.zip | |
* Add hook to NAND erase and implement nand_wait function.
  Patch by Mike Rapoport, 01 Nov 2005
  Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Diffstat (limited to 'drivers/nand/nand_base.c')
| -rw-r--r-- | drivers/nand/nand_base.c | 36 | 
1 files changed, 33 insertions, 3 deletions
| diff --git a/drivers/nand/nand_base.c b/drivers/nand/nand_base.c index a7ab8c27a..9ec5af9d7 100644 --- a/drivers/nand/nand_base.c +++ b/drivers/nand/nand_base.c @@ -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 |