summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorBitan Biswas <bbiswas@nvidia.com>2010-01-27 20:23:22 +0530
committerBitan Biswas <bbiswas@nvidia.com>2010-02-01 16:24:01 +0530
commit3e32c9c3d75819a35387b11f19d8a51c5d6be0cb (patch)
tree8eb2f2e7f6709e73e068ecd288b353356672864f /drivers/mtd
parent3d13613ce235128f6e7e9a46e74d3865b3a940f9 (diff)
tegra pm: nand suspend/resume support
suspend/resume APIs defined for Nand Bug 635299 Tested on : harmony. suspend/resume calls success. Change-Id: I6c962dd771903edd389aa50ec24e173da57ce93a
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/devices/tegra_mtd_nand.c63
1 files changed, 45 insertions, 18 deletions
diff --git a/drivers/mtd/devices/tegra_mtd_nand.c b/drivers/mtd/devices/tegra_mtd_nand.c
index a17b97252733..6af0b3176dc8 100644
--- a/drivers/mtd/devices/tegra_mtd_nand.c
+++ b/drivers/mtd/devices/tegra_mtd_nand.c
@@ -119,7 +119,7 @@ static int check_block_isbad(struct mtd_info *mtd, loff_t offs,
&blockInfo, NV_FALSE);
if (!blockInfo.IsFactoryGoodBlock) {
- //It's a factory bad block
+ /* It's a factory bad block */
ret = 1;
pr_info("Block %d is factory bad in chip %d, offset = "
"%llx\n", block, deviceNum, offs);
@@ -326,10 +326,10 @@ static int tegra_nand_erase(struct mtd_info *mtd, struct erase_info *instr)
pageNumbers[ChipNumber] = -1;
- // get the nand flash chip number
+ /* get the nand flash chip number */
ChipNumber = (NvU32)(curAddr >> info->chip.chip_shift);
- // get the page number on the nand flash chip
+ /* get the page number on the nand flash chip */
PageNumber = (NvU32)((curAddr >> info->chip.page_shift) &
info->chip.page_mask);
@@ -386,10 +386,10 @@ static int tegra_nand_read(struct mtd_info *mtd, loff_t from, size_t len,
do {
pageNumbers[ChipNumber] = -1;
- // get the nand flash chip number
+ /* get the nand flash chip number */
ChipNumber = (NvU32)(curAddr >> info->chip.chip_shift);
- // get the page number on the nand flash chip
+ /* get the page number on the nand flash chip */
PageNumber = (NvU32)((curAddr >> info->chip.page_shift) &
info->chip.page_mask);
@@ -455,10 +455,10 @@ static int do_read_oob(struct mtd_info *mtd, loff_t from,
for (i=0;i<NDFLASH_CS_MAX;i++)
pageNumbers[i] = -1;
- // get the nand flash chip number
+ /* get the nand flash chip number */
ChipNumber = (NvU32)(curAddr >> info->chip.chip_shift);
- // get the page number on the nand flash chip
+ /* get the page number on the nand flash chip */
PageNumber = (NvU32)((curAddr >> info->chip.page_shift) &
info->chip.page_mask);
@@ -549,10 +549,10 @@ static int tegra_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
do {
pageNumbers[ChipNumber] = -1;
- // get the nand flash chip number
+ /* get the nand flash chip number */
ChipNumber = (NvU32)(curAddr >> info->chip.chip_shift);
- // get the page number on the nand flash chip
+ /* get the page number on the nand flash chip */
PageNumber = (NvU32)((curAddr >> info->chip.page_shift) &
info->chip.page_mask);
@@ -613,10 +613,10 @@ static int do_write_oob(struct mtd_info *mtd, loff_t to,
for (i=0;i<NDFLASH_CS_MAX;i++)
pageNumbers[i] = -1;
- // get the nand flash chip number
+ /* get the nand flash chip number */
ChipNumber = (NvU32)(to >> info->chip.chip_shift);
- // get the page number on the nand flash chip
+ /* get the page number on the nand flash chip */
PageNumber = (NvU32)((to >> info->chip.page_shift) &
info->chip.page_mask);
@@ -667,14 +667,41 @@ static int tegra_nand_write_oob(struct mtd_info *mtd, loff_t to,
return do_write_oob(mtd, to, ops);
}
-static int tegra_nand_suspend(struct mtd_info *mtd)
+static int tegra_nand_suspend(struct platform_device *dev,
+ pm_message_t state)
{
+ struct mtd_info *mtd = platform_get_drvdata(dev);
+ NvError Err;
+
+ /* Call ddk suspend API */
+ if (!s_hNand) {
+ NvOsDebugPrintf("\n Nand: Ddk handle NULL in suspend ");
+ return -1;
+ }
+ Err = NvDdkNandSuspend(s_hNand);
+ if (Err != NvSuccess) {
+ NvOsDebugPrintf("\n Nand Ddk Suspend error=0x%x ", Err);
+ return -1;
+ }
return 0;
}
-static void tegra_nand_resume(struct mtd_info *mtd)
+static int tegra_nand_resume(struct platform_device *dev)
{
- ; // do nothing
+ struct mtd_info *mtd = platform_get_drvdata(dev);
+ NvError Err;
+
+ /* call Ddk resume code */
+ if (!s_hNand) {
+ NvOsDebugPrintf("\n Nand: Ddk handle NULL in resume ");
+ return -1;
+ }
+ Err = NvDdkNandResume(s_hNand);
+ if (Err != NvSuccess) {
+ NvOsDebugPrintf("\n Nand Ddk Resume error=0x%x ", Err);
+ return -1;
+ }
+ return 0;
}
static int scan_bad_blocks(struct tegra_nand_info *info)
@@ -728,7 +755,7 @@ static int tegra_nand_scan(struct mtd_info *mtd)
NvDdkNandGetDeviceInfo(s_hNand, 0, &nandDevInfo)
);
- //Get some info from the nand driver
+ /*Get some info from the nand driver */
vendor_id = nandDevInfo.VendorId;
dev_id = nandDevInfo.DeviceId;
@@ -761,7 +788,7 @@ static int tegra_nand_scan(struct mtd_info *mtd)
}
/* spare area, must be at least 64 bytes */
- //FIXME: Nand driver doesn't expose spare area size?
+ /* FIXME: Nand driver doesn't expose spare area size? */
tmp = NAND_SPARE_SIZE;
if (tmp < 64) {
@@ -911,8 +938,8 @@ static int __devexit tegra_nand_remove(struct platform_device *pdev)
static struct platform_driver tegra_nand_driver = {
.probe = tegra_nand_probe,
.remove = __devexit_p(tegra_nand_remove),
- .suspend = NULL,
- .resume = NULL,
+ .suspend = tegra_nand_suspend,
+ .resume = tegra_nand_resume,
.driver = {
.name = "tegra_nand",
.owner = THIS_MODULE,