aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyungmin Park <kyungmin.park@samsung.com>2005-09-28 22:55:31 -0400
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-06 16:42:28 -0500
commita41371eb6d9b368e53867cd85156f07371e9f72f (patch)
tree962ef7c7222e0790294548564254022911c239ad
parentd55849aa4d219b734795862692cc6981af848357 (diff)
[MTD] OneNAND: Power Management (PM) support
Add suspend/resume Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--drivers/mtd/onenand/onenand_base.c36
-rw-r--r--include/linux/mtd/onenand.h1
2 files changed, 34 insertions, 3 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 75d757882697..a002d4025b29 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -505,7 +505,7 @@ static int onenand_update_bufferram(struct mtd_info *mtd, loff_t addr,
505 * 505 *
506 * Get the device and lock it for exclusive access 506 * Get the device and lock it for exclusive access
507 */ 507 */
508static void onenand_get_device(struct mtd_info *mtd, int new_state) 508static int onenand_get_device(struct mtd_info *mtd, int new_state)
509{ 509{
510 struct onenand_chip *this = mtd->priv; 510 struct onenand_chip *this = mtd->priv;
511 DECLARE_WAITQUEUE(wait, current); 511 DECLARE_WAITQUEUE(wait, current);
@@ -520,12 +520,18 @@ static void onenand_get_device(struct mtd_info *mtd, int new_state)
520 spin_unlock(&this->chip_lock); 520 spin_unlock(&this->chip_lock);
521 break; 521 break;
522 } 522 }
523 if (new_state == FL_PM_SUSPENDED) {
524 spin_unlock(&this->chip_lock);
525 return (this->state == FL_PM_SUSPENDED) ? 0 : -EAGAIN;
526 }
523 set_current_state(TASK_UNINTERRUPTIBLE); 527 set_current_state(TASK_UNINTERRUPTIBLE);
524 add_wait_queue(&this->wq, &wait); 528 add_wait_queue(&this->wq, &wait);
525 spin_unlock(&this->chip_lock); 529 spin_unlock(&this->chip_lock);
526 schedule(); 530 schedule();
527 remove_wait_queue(&this->wq, &wait); 531 remove_wait_queue(&this->wq, &wait);
528 } 532 }
533
534 return 0;
529} 535}
530 536
531/** 537/**
@@ -1440,6 +1446,30 @@ static int onenand_probe(struct mtd_info *mtd)
1440 return 0; 1446 return 0;
1441} 1447}
1442 1448
1449/**
1450 * onenand_suspend - [MTD Interface] Suspend the OneNAND flash
1451 * @param mtd MTD device structure
1452 */
1453static int onenand_suspend(struct mtd_info *mtd)
1454{
1455 return onenand_get_device(mtd, FL_PM_SUSPENDED);
1456}
1457
1458/**
1459 * onenand_resume - [MTD Interface] Resume the OneNAND flash
1460 * @param mtd MTD device structure
1461 */
1462static void onenand_resume(struct mtd_info *mtd)
1463{
1464 struct onenand_chip *this = mtd->priv;
1465
1466 if (this->state == FL_PM_SUSPENDED)
1467 onenand_release_device(mtd);
1468 else
1469 printk(KERN_ERR "resume() called for the chip which is not"
1470 "in suspended state\n");
1471}
1472
1443 1473
1444/** 1474/**
1445 * onenand_scan - [OneNAND Interface] Scan for the OneNAND device 1475 * onenand_scan - [OneNAND Interface] Scan for the OneNAND device
@@ -1527,8 +1557,8 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
1527 mtd->sync = onenand_sync; 1557 mtd->sync = onenand_sync;
1528 mtd->lock = NULL; 1558 mtd->lock = NULL;
1529 mtd->unlock = onenand_unlock; 1559 mtd->unlock = onenand_unlock;
1530 mtd->suspend = NULL; 1560 mtd->suspend = onenand_suspend;
1531 mtd->resume = NULL; 1561 mtd->resume = onenand_resume;
1532 mtd->block_isbad = onenand_block_isbad; 1562 mtd->block_isbad = onenand_block_isbad;
1533 mtd->block_markbad = onenand_block_markbad; 1563 mtd->block_markbad = onenand_block_markbad;
1534 mtd->owner = THIS_MODULE; 1564 mtd->owner = THIS_MODULE;
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h
index 58023082320a..afaa6342aa7f 100644
--- a/include/linux/mtd/onenand.h
+++ b/include/linux/mtd/onenand.h
@@ -36,6 +36,7 @@ typedef enum {
36 FL_SYNCING, 36 FL_SYNCING,
37 FL_UNLOCKING, 37 FL_UNLOCKING,
38 FL_LOCKING, 38 FL_LOCKING,
39 FL_PM_SUSPENDED,
39} onenand_state_t; 40} onenand_state_t;
40 41
41/** 42/**