aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorVitaly Wool <vwool@ru.mvista.com>2005-09-15 14:58:53 +0100
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-06 21:43:45 +0100
commit962034f43937d02a1c18e802a6641aed0a266ac5 (patch)
treed1e1f2fe4f45614f7714bc117fc55c4d5d9ee982 /drivers/mtd/nand
parent9c517e6c801aab0f8de8f9c67bfc16ea13d72971 (diff)
downloadkernel_samsung_smdk4412-962034f43937d02a1c18e802a6641aed0a266ac5.zip
kernel_samsung_smdk4412-962034f43937d02a1c18e802a6641aed0a266ac5.tar.gz
kernel_samsung_smdk4412-962034f43937d02a1c18e802a6641aed0a266ac5.tar.bz2
[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>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/nand_base.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index cdf1086..4e22317 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -46,6 +46,8 @@
* perform extra error status checks on erase and write failures. This required
* adding a wrapper function for nand_read_ecc.
*
+ * 08-20-2005 vwool: suspend/resume added
+ *
* Credits:
* David Woodhouse for adding multichip support
*
@@ -59,7 +61,7 @@
* The AG-AND chips have nice features for speed improvement,
* 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
* 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)
#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
@@ -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
*/
-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;
spinlock_t *lock;
@@ -779,7 +781,11 @@ retry:
if (active == this && this->state == FL_READY) {
this->state = new_state;
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);
add_wait_queue(wq, &wait);
@@ -2285,6 +2291,34 @@ static int nand_block_markbad (struct mtd_info *mtd, loff_t 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
* @mtd: MTD device structure
* @maxchips: Number of chips to scan for
@@ -2643,8 +2677,8 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
mtd->sync = nand_sync;
mtd->lock = NULL;
mtd->unlock = NULL;
- mtd->suspend = NULL;
- mtd->resume = NULL;
+ mtd->suspend = nand_suspend;
+ mtd->resume = nand_resume;
mtd->block_isbad = nand_block_isbad;
mtd->block_markbad = nand_block_markbad;