Skip to contentSkip to conversation

suspend/resume support for OMAP nand driver

PATCH In review Philip Avinash 2 participants 5 messages Feb 19, 2013

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v3 cover suspend/resume support for OMAP nand driver

This patch series adds low power transition support for OMAP NAND driver. With recent driver conversion of GPMC to platform_driver, pm_runtime calls can be used to handle module enable & disable of GPMC. This is taken care patch #1.

patch #2 is for GPMC suspend/resume support.

This includes low power transition support of
- GPMC module
- ELM module

User initiated suspend/resume sequence tested on am335x-evm with NAND flash support. Also tested in omap3-evm for user initiated suspend/resume sequence with NAND flash.
This patch series based on [1] and is present in [2].

1. ARM: OMAP2+: AM33XX: Add suspend-resume support
http://comments.gmane.org/gmane.linux.ports.arm.omap/91405
2. https://github.com/avinashphilip/am335x_linux/commits/NAND_supend_resume_support

Changes Since v2:
- Remove calll back of nand_suspend from omap2 nand driver, as the same call already done from suspend activity mtd class driver.

Philip Avinash (3):
arm: gpmc: Converts GPMC driver to pm_runtime capable
arm: gpmc: Low power transition support
mtd: devices: elm: Low power transition support

 arch/arm/mach-omap2/gpmc.c |   30 +++++++++++++++++++++---
 drivers/mtd/devices/elm.c  |   54 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/3 arm: gpmc: Converts GPMC driver to pm_runtime capable

Support for pm_runtime add to GPMC driver.

---
 arch/arm/mach-omap2/gpmc.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
arch/arm/mach-omap2/gpmc.c +7 -3
index 2c57f81..b1cd6c1 100644
@@ -29,6 +29,7 @@
 #include <linux/of_mtd.h>
 #include <linux/of_device.h>
 #include <linux/mtd/nand.h>
+#include <linux/pm_runtime.h>
 
 #include <linux/platform_data/mtd-nand-omap2.h>
 
@@ -1317,7 +1318,8 @@ static int gpmc_probe(struct platform_device *pdev)
 		return PTR_ERR(gpmc_l3_clk);
 	}
 
-	clk_prepare_enable(gpmc_l3_clk);
+	pm_runtime_enable(&pdev->dev);
+	pm_runtime_get_sync(&pdev->dev);
 
 	gpmc_dev = &pdev->dev;
 
@@ -1329,7 +1331,7 @@ static int gpmc_probe(struct platform_device *pdev)
 
 	rc = gpmc_mem_init();
 	if (IS_ERR_VALUE(rc)) {
-		clk_disable_unprepare(gpmc_l3_clk);
+		pm_runtime_put_sync(&pdev->dev);
 		clk_put(gpmc_l3_clk);
 		dev_err(gpmc_dev, "failed to reserve memory\n");
 		return rc;
@@ -1340,7 +1342,7 @@ static int gpmc_probe(struct platform_device *pdev)
 
 	rc = gpmc_probe_dt(pdev);
 	if (rc < 0) {
-		clk_disable_unprepare(gpmc_l3_clk);
+		pm_runtime_put_sync(&pdev->dev);
 		clk_put(gpmc_l3_clk);
 		dev_err(gpmc_dev, "failed to probe DT parameters\n");
 		return rc;
@@ -1353,6 +1355,8 @@ static __devexit int gpmc_remove(struct platform_device *pdev)
 {
 	gpmc_free_irq();
 	gpmc_mem_exit();
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 	gpmc_dev = NULL;
 	return 0;
 }
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 2/3 arm: gpmc: Low power transition support

In reply to Philip Avinash

With GPMC converted to platform driver recently, adds low power transition support in driver itself.

---
Changes since v1:
Module disable & enable added using pm_runtime support.

 arch/arm/mach-omap2/gpmc.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm/mach-omap2/gpmc.c +20 -0
index b1cd6c1..cc57988 100644
@@ -1361,9 +1361,29 @@ static __devexit int gpmc_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static int gpmc_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	omap3_gpmc_save_context();
+	pm_runtime_put_sync(&pdev->dev);
+	return 0;
+}
+
+static int gpmc_resume(struct platform_device *pdev)
+{
+	pm_runtime_get_sync(&pdev->dev);
+	omap3_gpmc_restore_context();
+	return 0;
+}
+#endif
+
 static struct platform_driver gpmc_driver = {
 	.probe		= gpmc_probe,
 	.remove		= __devexit_p(gpmc_remove),
+#ifdef CONFIG_PM
+	.suspend	= gpmc_suspend,
+	.resume		= gpmc_resume,
+#endif
 	.driver		= {
 		.name	= DEVICE_NAME,
 		.owner	= THIS_MODULE,
Signature · 1 line
1.7.9.5
#3 lore raw

Re: [PATCH v3 2/3] arm: gpmc: Low power transition support

Quoted 16 lines · Philip Avinash

With GPMC converted to platform driver recently, adds low power transition support in driver itself.

---
Changes since v1:
Module disable & enable added using pm_runtime support.

 arch/arm/mach-omap2/gpmc.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm/mach-omap2/gpmc.c +0 -0
index b1cd6c1..cc57988 100644

arch/arm/mach-omap2/gpmc.c static __devexit int gpmc_remove(struct platform_device *pdev) · line 1364

Quoted 4 lines
arch/arm/mach-omap2/gpmc.c +1 -0
@@ -1361,9 +1361,29 @@ static __devexit int gpmc_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM

This should be CONFIG_PM_SLEEP for suspend/resume specific stuff.

Quoted 12 lines
arch/arm/mach-omap2/gpmc.c +12 -0
+static int gpmc_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	omap3_gpmc_save_context();
+	pm_runtime_put_sync(&pdev->dev);
+	return 0;
+}
+
+static int gpmc_resume(struct platform_device *pdev)
+{
+	pm_runtime_get_sync(&pdev->dev);
+	omap3_gpmc_restore_context();
+	return 0;

arch/arm/mach-omap2/gpmc.c static __devexit int gpmc_remove(struct platform_device *pdev) · line 1386

Quoted 10 lines
arch/arm/mach-omap2/gpmc.c +7 -0
+}
+#endif
+
 static struct platform_driver gpmc_driver = {
 	.probe		= gpmc_probe,
 	.remove		= __devexit_p(gpmc_remove),
+#ifdef CONFIG_PM
+	.suspend	= gpmc_suspend,
+	.resume		= gpmc_resume,
+#endif

These are the legacy PM operations, you need to use the ones in the drivers struct dev_pm_ops.

arch/arm/mach-omap2/gpmc.c static __devexit int gpmc_remove(struct platform_device *pdev) · line 1389

Quoted 3 lines
arch/arm/mach-omap2/gpmc.c +0 -0
 	.driver		= {
 		.name	= DEVICE_NAME,
 		.owner	= THIS_MODULE,

Kevin

#4 lore raw

PATCH v3 3/3 mtd: devices: elm: Low power transition support

In reply to Philip Avinash

In low power modes of AM335X platforms, peripherals power is cut off. This patch supports low power sleep transition support for ELM driver.

---
Changes Since v2:
- Removes wait queue mechanism. The order of device creation ensures that nand driver got suspended well before elm module suspend. Hence no need to check elm module state on suspend.

 drivers/mtd/devices/elm.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/mtd/devices/elm.c +19 -0
index f034239..a41c968 100644
@@ -20,6 +20,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/sched.h>
 #include <linux/pm_runtime.h>
 #include <linux/platform_data/elm.h>
 
@@ -379,6 +380,23 @@ static int elm_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static int elm_suspend(struct device *dev)
+{
+	pm_runtime_put_sync(dev);
+	return 0;
+}
+
+static int elm_resume(struct device *dev)
+{
+	struct elm_info *info = dev_get_drvdata(dev);
+
+	pm_runtime_get_sync(dev);
+	elm_config(dev, info->bch_type);
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(elm_pm_ops, elm_suspend, elm_resume);
+
 #ifdef CONFIG_OF
 static const struct of_device_id elm_of_match[] = {
 	{ .compatible = "ti,am3352-elm" },
@@ -392,6 +410,7 @@ static struct platform_driver elm_driver = {
 		.name	= "elm",
 		.owner	= THIS_MODULE,
 		.of_match_table = of_match_ptr(elm_of_match),
+		.pm	= &elm_pm_ops,
 	},
 	.probe	= elm_probe,
 	.remove	= elm_remove,
Signature · 1 line
1.7.9.5