[MTD] NAND: Add suspend/resume functionality
The changes introduced allow to suspend/resume NAND flash. A new state (FL_PM_SUSPENDED) is introduced, as well as routines for mtd->suspend and mtd->resume to put the flash in suspended state from software pov. Signed-off-by: Vitaly Wool <vwool@ru.mvista.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
9c517e6c80
commit
962034f439
|
@ -46,6 +46,8 @@
|
||||||
* perform extra error status checks on erase and write failures. This required
|
* perform extra error status checks on erase and write failures. This required
|
||||||
* adding a wrapper function for nand_read_ecc.
|
* adding a wrapper function for nand_read_ecc.
|
||||||
*
|
*
|
||||||
|
* 08-20-2005 vwool: suspend/resume added
|
||||||
|
*
|
||||||
* Credits:
|
* Credits:
|
||||||
* David Woodhouse for adding multichip support
|
* David Woodhouse for adding multichip support
|
||||||
*
|
*
|
||||||
|
@ -59,7 +61,7 @@
|
||||||
* The AG-AND chips have nice features for speed improvement,
|
* The AG-AND chips have nice features for speed improvement,
|
||||||
* which are not supported yet. Read / program 4 pages in one go.
|
* which are not supported yet. Read / program 4 pages in one go.
|
||||||
*
|
*
|
||||||
* $Id: nand_base.c,v 1.148 2005/08/04 17:14:48 gleixner Exp $
|
* $Id: nand_base.c,v 1.150 2005/09/15 13:58:48 vwool Exp $
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
@ -153,7 +155,7 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
|
||||||
#define nand_verify_pages(...) (0)
|
#define nand_verify_pages(...) (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state);
|
static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nand_release_device - [GENERIC] release chip
|
* nand_release_device - [GENERIC] release chip
|
||||||
|
@ -756,7 +758,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
|
||||||
*
|
*
|
||||||
* Get the device and lock it for exclusive access
|
* Get the device and lock it for exclusive access
|
||||||
*/
|
*/
|
||||||
static void nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state)
|
static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state)
|
||||||
{
|
{
|
||||||
struct nand_chip *active;
|
struct nand_chip *active;
|
||||||
spinlock_t *lock;
|
spinlock_t *lock;
|
||||||
|
@ -779,7 +781,11 @@ retry:
|
||||||
if (active == this && this->state == FL_READY) {
|
if (active == this && this->state == FL_READY) {
|
||||||
this->state = new_state;
|
this->state = new_state;
|
||||||
spin_unlock(lock);
|
spin_unlock(lock);
|
||||||
return;
|
return 0;
|
||||||
|
}
|
||||||
|
if (new_state == FL_PM_SUSPENDED) {
|
||||||
|
spin_unlock(lock);
|
||||||
|
return (this->state == FL_PM_SUSPENDED) ? 0 : -EAGAIN;
|
||||||
}
|
}
|
||||||
set_current_state(TASK_UNINTERRUPTIBLE);
|
set_current_state(TASK_UNINTERRUPTIBLE);
|
||||||
add_wait_queue(wq, &wait);
|
add_wait_queue(wq, &wait);
|
||||||
|
@ -2284,6 +2290,34 @@ static int nand_block_markbad (struct mtd_info *mtd, loff_t ofs)
|
||||||
return this->block_markbad(mtd, ofs);
|
return this->block_markbad(mtd, ofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nand_suspend - [MTD Interface] Suspend the NAND flash
|
||||||
|
* @mtd: MTD device structure
|
||||||
|
*/
|
||||||
|
static int nand_suspend(struct mtd_info *mtd)
|
||||||
|
{
|
||||||
|
struct nand_chip *this = mtd->priv;
|
||||||
|
|
||||||
|
return nand_get_device (this, mtd, FL_PM_SUSPENDED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nand_resume - [MTD Interface] Resume the NAND flash
|
||||||
|
* @mtd: MTD device structure
|
||||||
|
*/
|
||||||
|
static void nand_resume(struct mtd_info *mtd)
|
||||||
|
{
|
||||||
|
struct nand_chip *this = mtd->priv;
|
||||||
|
|
||||||
|
if (this->state == FL_PM_SUSPENDED)
|
||||||
|
nand_release_device(mtd);
|
||||||
|
else
|
||||||
|
printk(KERN_ERR "resume() called for the chip which is not "
|
||||||
|
"in suspended state\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nand_scan - [NAND Interface] Scan for the NAND device
|
* nand_scan - [NAND Interface] Scan for the NAND device
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
|
@ -2643,8 +2677,8 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
|
||||||
mtd->sync = nand_sync;
|
mtd->sync = nand_sync;
|
||||||
mtd->lock = NULL;
|
mtd->lock = NULL;
|
||||||
mtd->unlock = NULL;
|
mtd->unlock = NULL;
|
||||||
mtd->suspend = NULL;
|
mtd->suspend = nand_suspend;
|
||||||
mtd->resume = NULL;
|
mtd->resume = nand_resume;
|
||||||
mtd->block_isbad = nand_block_isbad;
|
mtd->block_isbad = nand_block_isbad;
|
||||||
mtd->block_markbad = nand_block_markbad;
|
mtd->block_markbad = nand_block_markbad;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Steven J. Hill <sjhill@realitydiluted.com>
|
* Steven J. Hill <sjhill@realitydiluted.com>
|
||||||
* Thomas Gleixner <tglx@linutronix.de>
|
* Thomas Gleixner <tglx@linutronix.de>
|
||||||
*
|
*
|
||||||
* $Id: nand.h,v 1.73 2005/05/31 19:39:17 gleixner Exp $
|
* $Id: nand.h,v 1.74 2005/09/15 13:58:50 vwool Exp $
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
@ -244,6 +244,7 @@ typedef enum {
|
||||||
FL_ERASING,
|
FL_ERASING,
|
||||||
FL_SYNCING,
|
FL_SYNCING,
|
||||||
FL_CACHEDPRG,
|
FL_CACHEDPRG,
|
||||||
|
FL_PM_SUSPENDED,
|
||||||
} nand_state_t;
|
} nand_state_t;
|
||||||
|
|
||||||
/* Keep gcc happy */
|
/* Keep gcc happy */
|
||||||
|
|
Loading…
Reference in New Issue