Skip to contentSkip to conversation

LOW power sleep support for OMAP nand driver

PATCH In review Philip Avinash 2 participants 7 messages Jan 23, 2013 – Feb 6, 2013

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

cover LOW power sleep support for OMAP nand driver

This patch series adds low power transition support for OMAP NAND driver. This includes low power transition support of
- GPMC module
- ELM module
- OMAP2 NAND driver

Low power transition support tested on am335x-evm with NAND flash support. This patch series based on [1] and depends on [2] and is available [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

Philip Avinash (4):
arch: arm: gpmc: gpmc migration support
mtd: devices: elm: Low power transition support
arm: gpmc: Low power transition support
mtd: nand: omap2: Low power transition support

 arch/arm/mach-omap2/gpmc.c   |   22 ++++++++++++++++++++--
 arch/arm/mach-omap2/pm34xx.c |    5 -----
 drivers/mtd/devices/elm.c    |   40 ++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/omap2.c     |   19 +++++++++++++++++++
 4 files changed, 79 insertions(+), 7 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/4 arch: arm: gpmc: gpmc migration support

With recent GPMC driver conversion, usage of gpmc_save/restore_context can done from gpmc driver itself. Hence removes the usage from pm34xx.c. Also removes the conditional compilation primitives ARCH_OMAP3 for gpmc_save/restore_context.

---
 arch/arm/mach-omap2/gpmc.c   |    2 --
 arch/arm/mach-omap2/pm34xx.c |    5 -----
 2 files changed, 7 deletions(-)
arch/arm/mach-omap2/gpmc.c +0 -2
index cbf4e0d..aed958a 100644
@@ -1426,7 +1426,6 @@ static irqreturn_t gpmc_handle_irq(int irq, void *dev)
 	return IRQ_HANDLED;
 }
 
-#ifdef CONFIG_ARCH_OMAP3
 static struct omap3_gpmc_regs gpmc_context;
 
 void omap3_gpmc_save_context(void)
@@ -1491,4 +1490,3 @@ void omap3_gpmc_restore_context(void)
 		}
 	}
 }
-#endif /* CONFIG_ARCH_OMAP3 */
arch/arm/mach-omap2/pm34xx.c +0 -5
index 60fbf0a..cab4c5d 100644
@@ -43,7 +43,6 @@
 #include "common.h"
 #include "cm3xxx.h"
 #include "cm-regbits-34xx.h"
-#include "gpmc.h"
 #include "prm-regbits-34xx.h"
 #include "prm3xxx.h"
 #include "pm.h"
@@ -84,8 +83,6 @@ static void omap3_core_save_context(void)
 
 	/* Save the Interrupt controller context */
 	omap_intc_save_context();
-	/* Save the GPMC context */
-	omap3_gpmc_save_context();
 	/* Save the system control module context, padconf already save above*/
 	omap3_control_save_context();
 	omap_dma_global_context_save();
@@ -95,8 +92,6 @@ static void omap3_core_restore_context(void)
 {
 	/* Restore the control module context, padconf restored by h/w */
 	omap3_control_restore_context();
-	/* Restore the GPMC context */
-	omap3_gpmc_restore_context();
 	/* Restore the interrupt controller context */
 	omap_intc_restore_context();
 	omap_dma_global_context_restore();
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 2/4 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.

---
 drivers/mtd/devices/elm.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
drivers/mtd/devices/elm.c +40 -0
index f78f43f..4793cb0 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>
 
@@ -62,6 +63,7 @@ struct elm_info {
 	struct completion elm_completion;
 	struct list_head list;
 	enum bch_ecc bch_type;
+	bool idle;
 };
 
 static LIST_HEAD(elm_devices);
@@ -86,9 +88,11 @@ void elm_config(struct device *dev, enum bch_ecc bch_type)
 	u32 reg_val;
 	struct elm_info *info = dev_get_drvdata(dev);
 
+	info->idle = true;
 	reg_val = (bch_type & ECC_BCH_LEVEL_MASK) | (ELM_ECC_SIZE << 16);
 	elm_write_reg(info, ELM_LOCATION_CONFIG, reg_val);
 	info->bch_type = bch_type;
+	info->idle = false;
 }
 EXPORT_SYMBOL(elm_config);
 
@@ -280,6 +284,7 @@ void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
 	struct elm_info *info = dev_get_drvdata(dev);
 	u32 reg_val;
 
+	info->idle = true;
 	/* Enable page mode interrupt */
 	reg_val = elm_read_reg(info, ELM_IRQSTATUS);
 	elm_write_reg(info, ELM_IRQSTATUS, reg_val & INTR_STATUS_PAGE_VALID);
@@ -298,6 +303,7 @@ void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
 	reg_val = elm_read_reg(info, ELM_IRQENABLE);
 	elm_write_reg(info, ELM_IRQENABLE, reg_val & ~INTR_EN_PAGE_MASK);
 	elm_error_correction(info, err_vec);
+	info->idle = false;
 }
 EXPORT_SYMBOL(elm_decode_bch_error_page);
 
@@ -368,6 +374,7 @@ static int elm_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&info->list);
 	list_add(&info->list, &elm_devices);
 	platform_set_drvdata(pdev, info);
+	info->idle = false;
 	return ret;
 }
 
@@ -379,6 +386,38 @@ static int elm_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static int elm_suspend(struct device *dev)
+{
+	struct elm_info *info = dev_get_drvdata(dev);
+	wait_queue_head_t wq;
+	DECLARE_WAITQUEUE(wait, current);
+
+	init_waitqueue_head(&wq);
+	while (1) {
+		/* Make sure that ELM not running */
+		if (info->idle) {
+			add_wait_queue(&wq, &wait);
+			schedule();
+			remove_wait_queue(&wq, &wait);
+		} else {
+			break;
+		}
+	}
+	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,am33xx-elm" },
@@ -392,6 +431,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
#5 lore raw

PATCH 3/4 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.

---
 arch/arm/mach-omap2/gpmc.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm/mach-omap2/gpmc.c +20 -0
index aed958a..af10617 100644
@@ -1357,9 +1357,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();
+	clk_disable_unprepare(gpmc_l3_clk);
+	return 0;
+}
+
+static int gpmc_resume(struct platform_device *pdev)
+{
+	clk_prepare_enable(gpmc_l3_clk);
+	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
#6 lore raw

PATCH 4/4 mtd: nand: omap2: Low power transition support

In reply to Philip Avinash

Add support for Low power transition support in nand driver. Also ensures the current transaction finishes before going to low power mode with _suspend support in mtd layer.

---
 drivers/mtd/nand/omap2.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/mtd/nand/omap2.c +19 -0
index 8e820dd..790215b 100644
@@ -2103,9 +2103,28 @@ static int omap_nand_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static int omap_nand_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	struct mtd_info *mtd = platform_get_drvdata(pdev);
+
+	mtd->_suspend(mtd);
+	return 0;
+}
+
+static int omap_nand_resume(struct platform_device *pdev)
+{
+	return 0;
+}
+#endif
+
 static struct platform_driver omap_nand_driver = {
 	.probe		= omap_nand_probe,
 	.remove		= omap_nand_remove,
+#ifdef CONFIG_PM
+	.suspend	= omap_nand_suspend,
+	.resume		= omap_nand_resume,
+#endif
 	.driver		= {
 		.name	= DRIVER_NAME,
 		.owner	= THIS_MODULE,
Signature · 1 line
1.7.9.5
maintainer
#2 lore raw

Re: [PATCH 1/4] arch: arm: gpmc: gpmc migration support

In reply to Philip Avinash
Quoted 4 lines · Philip Avinash

With recent GPMC driver conversion, usage of gpmc_save/restore_context can done from gpmc driver itself. Hence removes the usage from pm34xx.c. Also removes the conditional compilation primitives ARCH_OMAP3 for gpmc_save/restore_context.

Hmm I think this will break GPMC for deeper idle modes. Note that we need to save and restore the context every time hitting off-idle, not just for suspend and resume. Or am I missing something here?

Regards,

Tony

#3 lore raw

RE: [PATCH 1/4] arch: arm: gpmc: gpmc migration support

Quoted 9 lines · Tony Lindgren
Quoted 4 lines · Philip Avinash

With recent GPMC driver conversion, usage of gpmc_save/restore_context can done from gpmc driver itself. Hence removes the usage from pm34xx.c. Also removes the conditional compilation primitives ARCH_OMAP3 for gpmc_save/restore_context.

Hmm I think this will break GPMC for deeper idle modes. Note that we need to save and restore the context every time hitting off-idle, not just for suspend and resume. Or am I missing something here?

I understand dependency on idle modes. So I will send a second version with this patch eliminated so that user initiated suspend/resume work for am335x platforms.

Thanks
Avinash

Quoted 5 lines

Regards,

Tony