All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/3] suspend/resume support for OMAP nand driver
@ 2013-06-17 18:46 ` Pekon Gupta
  0 siblings, 0 replies; 14+ messages in thread
From: Pekon Gupta @ 2013-06-17 18:46 UTC (permalink / raw)
  To: linux-mtd, linux-omap; +Cc: tony, khilman, Pekon Gupta

This patch series adds runtime PM support (specifically suspend/resume) 
for GPMC and ELM drivers.
[Patch 1/3]: Adds pm_runtime calls to handle GPMC module probe and remove
[Patch 2/3]: Adds GPMC suspend/resume support.
[Patch 3/3]: Adds ELM suspend/resume support.

Tested on am335x-evm with NAND flash support, using following:
	echo devices 	> /sys/power/pm_test
	echo mem	> /sys/power/state

	echo core	> /sys/power/pm_test
	echo mem	> /sys/power/state

Changes since v4:
- added save/restore to ELM suspend/resume
- removed #ifdef CONFIG_ARCH_OMAP3
- updated changelog to be more descriptive

Changes Since v3:
- CONFIG_PM -> CONFIG_PM_SLEEP
- using struct dev_pm_ops via driver->pm, instead of struct platform_driver
- rebased to 3.10-rc5

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.

[1] http://comments.gmane.org/gmane.linux.ports.arm.omap/91405


avinash philip (3):
  ARM: OMAP2+: 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 |  29 +++++++++--
 drivers/mtd/devices/elm.c  | 117 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+), 4 deletions(-)

-- 
1.8.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v5 0/3] suspend/resume support for OMAP nand driver
@ 2013-06-17 18:46 ` Pekon Gupta
  0 siblings, 0 replies; 14+ messages in thread
From: Pekon Gupta @ 2013-06-17 18:46 UTC (permalink / raw)
  To: linux-mtd, linux-omap; +Cc: tony, khilman, Pekon Gupta

This patch series adds runtime PM support (specifically suspend/resume) 
for GPMC and ELM drivers.
[Patch 1/3]: Adds pm_runtime calls to handle GPMC module probe and remove
[Patch 2/3]: Adds GPMC suspend/resume support.
[Patch 3/3]: Adds ELM suspend/resume support.

Tested on am335x-evm with NAND flash support, using following:
	echo devices 	> /sys/power/pm_test
	echo mem	> /sys/power/state

	echo core	> /sys/power/pm_test
	echo mem	> /sys/power/state

Changes since v4:
- added save/restore to ELM suspend/resume
- removed #ifdef CONFIG_ARCH_OMAP3
- updated changelog to be more descriptive

Changes Since v3:
- CONFIG_PM -> CONFIG_PM_SLEEP
- using struct dev_pm_ops via driver->pm, instead of struct platform_driver
- rebased to 3.10-rc5

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.

[1] http://comments.gmane.org/gmane.linux.ports.arm.omap/91405


avinash philip (3):
  ARM: OMAP2+: 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 |  29 +++++++++--
 drivers/mtd/devices/elm.c  | 117 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+), 4 deletions(-)

-- 
1.8.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v5 1/3] ARM: OMAP2+: gpmc: Converts GPMC driver to pm_runtime capable
  2013-06-17 18:46 ` Pekon Gupta
@ 2013-06-17 18:46   ` Pekon Gupta
  -1 siblings, 0 replies; 14+ messages in thread
From: Pekon Gupta @ 2013-06-17 18:46 UTC (permalink / raw)
  To: linux-mtd, linux-omap; +Cc: tony, khilman, avinash philip, Pekon Gupta

From: avinash philip <avinashphilip@ti.com>

Support for pm_runtime add to GPMC driver.

Signed-off-by: Philip Avinash <avinashphilip@ti.com>
Signed-off-by: Pekon Gupta <pekon@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap2/gpmc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index fb6f241..1380cee 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -30,6 +30,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>
 
@@ -1594,7 +1595,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;
 
@@ -1634,7 +1636,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;
@@ -1647,6 +1649,8 @@ static 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;
 }
-- 
1.8.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 1/3] ARM: OMAP2+: gpmc: Converts GPMC driver to pm_runtime capable
@ 2013-06-17 18:46   ` Pekon Gupta
  0 siblings, 0 replies; 14+ messages in thread
From: Pekon Gupta @ 2013-06-17 18:46 UTC (permalink / raw)
  To: linux-mtd, linux-omap; +Cc: tony, khilman, Pekon Gupta

From: avinash philip <avinashphilip@ti.com>

Support for pm_runtime add to GPMC driver.

Signed-off-by: Philip Avinash <avinashphilip@ti.com>
Signed-off-by: Pekon Gupta <pekon@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap2/gpmc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index fb6f241..1380cee 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -30,6 +30,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>
 
@@ -1594,7 +1595,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;
 
@@ -1634,7 +1636,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;
@@ -1647,6 +1649,8 @@ static 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;
 }
-- 
1.8.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 2/3] arm: gpmc: Low power transition support
  2013-06-17 18:46 ` Pekon Gupta
@ 2013-06-17 18:46   ` Pekon Gupta
  -1 siblings, 0 replies; 14+ messages in thread
From: Pekon Gupta @ 2013-06-17 18:46 UTC (permalink / raw)
  To: linux-mtd, linux-omap; +Cc: tony, khilman, avinash philip, Pekon Gupta

From: avinash philip <avinashphilip@ti.com>

GPMC is hardware controller for external memory interfaces.
This patch adds suspend/resume support for GPMC driver.
It also preserves GPMC register configurations across device low-power states
in which GPMC hardware can be powered-off.
gpmc_suspend()/gpmc_resume() are called by default by core PM framework as part
of driver's runtime PM callbacks.

Signed-off-by: Philip Avinash <avinashphilip@ti.com>
Signed-off-by: Pekon Gupta <pekon@ti.com>
---
 arch/arm/mach-omap2/gpmc.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 1380cee..9b579d0 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -1655,6 +1655,24 @@ static int gpmc_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int gpmc_suspend(struct device *dev)
+{
+	omap3_gpmc_save_context();
+	pm_runtime_put_sync(dev);
+	return 0;
+}
+
+static int gpmc_resume(struct device *dev)
+{
+	pm_runtime_get_sync(dev);
+	omap3_gpmc_restore_context();
+	return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(gpmc_pm_ops, gpmc_suspend, gpmc_resume);
+
 static struct platform_driver gpmc_driver = {
 	.probe		= gpmc_probe,
 	.remove		= gpmc_remove,
@@ -1662,6 +1680,7 @@ static struct platform_driver gpmc_driver = {
 		.name	= DEVICE_NAME,
 		.owner	= THIS_MODULE,
 		.of_match_table = of_match_ptr(gpmc_dt_ids),
+		.pm	= &gpmc_pm_ops,
 	},
 };
 
@@ -1724,7 +1743,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)
@@ -1789,4 +1807,3 @@ void omap3_gpmc_restore_context(void)
 		}
 	}
 }
-#endif /* CONFIG_ARCH_OMAP3 */
-- 
1.8.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 2/3] arm: gpmc: Low power transition support
@ 2013-06-17 18:46   ` Pekon Gupta
  0 siblings, 0 replies; 14+ messages in thread
From: Pekon Gupta @ 2013-06-17 18:46 UTC (permalink / raw)
  To: linux-mtd, linux-omap; +Cc: tony, khilman, Pekon Gupta

From: avinash philip <avinashphilip@ti.com>

GPMC is hardware controller for external memory interfaces.
This patch adds suspend/resume support for GPMC driver.
It also preserves GPMC register configurations across device low-power states
in which GPMC hardware can be powered-off.
gpmc_suspend()/gpmc_resume() are called by default by core PM framework as part
of driver's runtime PM callbacks.

Signed-off-by: Philip Avinash <avinashphilip@ti.com>
Signed-off-by: Pekon Gupta <pekon@ti.com>
---
 arch/arm/mach-omap2/gpmc.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 1380cee..9b579d0 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -1655,6 +1655,24 @@ static int gpmc_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int gpmc_suspend(struct device *dev)
+{
+	omap3_gpmc_save_context();
+	pm_runtime_put_sync(dev);
+	return 0;
+}
+
+static int gpmc_resume(struct device *dev)
+{
+	pm_runtime_get_sync(dev);
+	omap3_gpmc_restore_context();
+	return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(gpmc_pm_ops, gpmc_suspend, gpmc_resume);
+
 static struct platform_driver gpmc_driver = {
 	.probe		= gpmc_probe,
 	.remove		= gpmc_remove,
@@ -1662,6 +1680,7 @@ static struct platform_driver gpmc_driver = {
 		.name	= DEVICE_NAME,
 		.owner	= THIS_MODULE,
 		.of_match_table = of_match_ptr(gpmc_dt_ids),
+		.pm	= &gpmc_pm_ops,
 	},
 };
 
@@ -1724,7 +1743,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)
@@ -1789,4 +1807,3 @@ void omap3_gpmc_restore_context(void)
 		}
 	}
 }
-#endif /* CONFIG_ARCH_OMAP3 */
-- 
1.8.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 3/3] mtd: devices: elm: Low power transition support
  2013-06-17 18:46 ` Pekon Gupta
@ 2013-06-17 18:46   ` Pekon Gupta
  -1 siblings, 0 replies; 14+ messages in thread
From: Pekon Gupta @ 2013-06-17 18:46 UTC (permalink / raw)
  To: linux-mtd, linux-omap; +Cc: tony, khilman, avinash philip, Pekon Gupta

From: avinash philip <avinashphilip@ti.com>

ELM is used for locating bit-flip errors in when using BCH ECC scheme.
This patch adds suspend/resume support for leaf level ELM driver,
And also provides ELM register context save & restore support, so that
configurations are preserved across hardware power-off/on transitions.

Signed-off-by: Philip Avinash <avinashphilip@ti.com>
Signed-off-by: Pekon Gupta <pekon@ti.com>
---
 drivers/mtd/devices/elm.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 117 insertions(+)

diff --git a/drivers/mtd/devices/elm.c b/drivers/mtd/devices/elm.c
index dccef9f..e6a7b89 100644
--- a/drivers/mtd/devices/elm.c
+++ b/drivers/mtd/devices/elm.c
@@ -20,14 +20,21 @@
 #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>
 
+#define ELM_SYSCONFIG			0x010
 #define ELM_IRQSTATUS			0x018
 #define ELM_IRQENABLE			0x01c
 #define ELM_LOCATION_CONFIG		0x020
 #define ELM_PAGE_CTRL			0x080
 #define ELM_SYNDROME_FRAGMENT_0		0x400
+#define ELM_SYNDROME_FRAGMENT_1		0x404
+#define ELM_SYNDROME_FRAGMENT_2		0x408
+#define ELM_SYNDROME_FRAGMENT_3		0x40c
+#define ELM_SYNDROME_FRAGMENT_4		0x410
+#define ELM_SYNDROME_FRAGMENT_5		0x414
 #define ELM_SYNDROME_FRAGMENT_6		0x418
 #define ELM_LOCATION_STATUS		0x800
 #define ELM_ERROR_LOCATION_0		0x880
@@ -56,12 +63,27 @@
 #define SYNDROME_FRAGMENT_REG_SIZE	0x40
 #define ERROR_LOCATION_SIZE		0x100
 
+struct elm_registers {
+	u32 elm_irqenable;
+	u32 elm_sysconfig;
+	u32 elm_location_config;
+	u32 elm_page_ctrl;
+	u32 elm_syndrome_fragment_6[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_5[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_4[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_3[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_2[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_1[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_0[ERROR_VECTOR_MAX];
+};
+
 struct elm_info {
 	struct device *dev;
 	void __iomem *elm_base;
 	struct completion elm_completion;
 	struct list_head list;
 	enum bch_ecc bch_type;
+	struct elm_registers elm_regs;
 };
 
 static LIST_HEAD(elm_devices);
@@ -385,6 +407,100 @@ static int elm_remove(struct platform_device *pdev)
 	return 0;
 }
 
+/**
+ * elm_context_save
+ * saves ELM configurations to preserve them across Hardware powered-down
+ */
+static int elm_context_save(struct elm_info *info)
+{
+	struct elm_registers *regs = &info->elm_regs;
+	enum bch_ecc bch_type = info->bch_type;
+	u32 offset = 0, i;
+
+	regs->elm_irqenable       = elm_read_reg(info, ELM_IRQENABLE);
+	regs->elm_sysconfig       = elm_read_reg(info, ELM_SYSCONFIG);
+	regs->elm_location_config = elm_read_reg(info, ELM_LOCATION_CONFIG);
+	regs->elm_page_ctrl       = elm_read_reg(info, ELM_PAGE_CTRL);
+	for (i = 0; i < ERROR_VECTOR_MAX; i++) {
+		offset = i * SYNDROME_FRAGMENT_REG_SIZE;
+		switch (bch_type) {
+		case BCH8_ECC:
+			regs->elm_syndrome_fragment_3[i] = elm_read_reg(info,
+					ELM_SYNDROME_FRAGMENT_3 + offset);
+			regs->elm_syndrome_fragment_2[i] = elm_read_reg(info,
+					ELM_SYNDROME_FRAGMENT_2 + offset);
+		case BCH4_ECC:
+			regs->elm_syndrome_fragment_1[i] = elm_read_reg(info,
+					ELM_SYNDROME_FRAGMENT_1 + offset);
+			regs->elm_syndrome_fragment_0[i] = elm_read_reg(info,
+					ELM_SYNDROME_FRAGMENT_0 + offset);
+		default:
+			return -EINVAL;
+		}
+		/* ELM SYNDROME_VALID bit in SYNDROME_FRAGMENT_6[] needs
+		 * to be saved for all BCH schemes*/
+		regs->elm_syndrome_fragment_6[i] = elm_read_reg(info,
+					ELM_SYNDROME_FRAGMENT_6 + offset);
+	}
+	return 0;
+}
+
+/**
+ * elm_context_restore
+ * writes configurations saved duing power-down back into ELM registers
+ */
+static int elm_context_restore(struct elm_info *info)
+{
+	struct elm_registers *regs = &info->elm_regs;
+	enum bch_ecc bch_type = info->bch_type;
+	u32 offset = 0, i;
+
+	elm_write_reg(info, ELM_IRQENABLE,	 regs->elm_irqenable);
+	elm_write_reg(info, ELM_SYSCONFIG,	 regs->elm_sysconfig);
+	elm_write_reg(info, ELM_LOCATION_CONFIG, regs->elm_location_config);
+	elm_write_reg(info, ELM_PAGE_CTRL,	 regs->elm_page_ctrl);
+	for (i = 0; i < ERROR_VECTOR_MAX; i++) {
+		offset = i * SYNDROME_FRAGMENT_REG_SIZE;
+		switch (bch_type) {
+		case BCH8_ECC:
+			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_3 + offset,
+					regs->elm_syndrome_fragment_3[i]);
+			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_2 + offset,
+					regs->elm_syndrome_fragment_2[i]);
+		case BCH4_ECC:
+			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_1 + offset,
+					regs->elm_syndrome_fragment_1[i]);
+			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_0 + offset,
+					regs->elm_syndrome_fragment_0[i]);
+		default:
+			return -EINVAL;
+		}
+		/* ELM_SYNDROME_VALID bit to be set in last to trigger FSM */
+		elm_write_reg(info, ELM_SYNDROME_FRAGMENT_6 + offset,
+					regs->elm_syndrome_fragment_6[i] &
+							 ELM_SYNDROME_VALID);
+	}
+	return 0;
+}
+
+static int elm_suspend(struct device *dev)
+{
+	struct elm_info *info = dev_get_drvdata(dev);
+	elm_context_save(info);
+	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_context_restore(info);
+	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" },
@@ -398,6 +514,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,
-- 
1.8.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 3/3] mtd: devices: elm: Low power transition support
@ 2013-06-17 18:46   ` Pekon Gupta
  0 siblings, 0 replies; 14+ messages in thread
From: Pekon Gupta @ 2013-06-17 18:46 UTC (permalink / raw)
  To: linux-mtd, linux-omap; +Cc: tony, khilman, Pekon Gupta

From: avinash philip <avinashphilip@ti.com>

ELM is used for locating bit-flip errors in when using BCH ECC scheme.
This patch adds suspend/resume support for leaf level ELM driver,
And also provides ELM register context save & restore support, so that
configurations are preserved across hardware power-off/on transitions.

Signed-off-by: Philip Avinash <avinashphilip@ti.com>
Signed-off-by: Pekon Gupta <pekon@ti.com>
---
 drivers/mtd/devices/elm.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 117 insertions(+)

diff --git a/drivers/mtd/devices/elm.c b/drivers/mtd/devices/elm.c
index dccef9f..e6a7b89 100644
--- a/drivers/mtd/devices/elm.c
+++ b/drivers/mtd/devices/elm.c
@@ -20,14 +20,21 @@
 #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>
 
+#define ELM_SYSCONFIG			0x010
 #define ELM_IRQSTATUS			0x018
 #define ELM_IRQENABLE			0x01c
 #define ELM_LOCATION_CONFIG		0x020
 #define ELM_PAGE_CTRL			0x080
 #define ELM_SYNDROME_FRAGMENT_0		0x400
+#define ELM_SYNDROME_FRAGMENT_1		0x404
+#define ELM_SYNDROME_FRAGMENT_2		0x408
+#define ELM_SYNDROME_FRAGMENT_3		0x40c
+#define ELM_SYNDROME_FRAGMENT_4		0x410
+#define ELM_SYNDROME_FRAGMENT_5		0x414
 #define ELM_SYNDROME_FRAGMENT_6		0x418
 #define ELM_LOCATION_STATUS		0x800
 #define ELM_ERROR_LOCATION_0		0x880
@@ -56,12 +63,27 @@
 #define SYNDROME_FRAGMENT_REG_SIZE	0x40
 #define ERROR_LOCATION_SIZE		0x100
 
+struct elm_registers {
+	u32 elm_irqenable;
+	u32 elm_sysconfig;
+	u32 elm_location_config;
+	u32 elm_page_ctrl;
+	u32 elm_syndrome_fragment_6[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_5[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_4[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_3[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_2[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_1[ERROR_VECTOR_MAX];
+	u32 elm_syndrome_fragment_0[ERROR_VECTOR_MAX];
+};
+
 struct elm_info {
 	struct device *dev;
 	void __iomem *elm_base;
 	struct completion elm_completion;
 	struct list_head list;
 	enum bch_ecc bch_type;
+	struct elm_registers elm_regs;
 };
 
 static LIST_HEAD(elm_devices);
@@ -385,6 +407,100 @@ static int elm_remove(struct platform_device *pdev)
 	return 0;
 }
 
+/**
+ * elm_context_save
+ * saves ELM configurations to preserve them across Hardware powered-down
+ */
+static int elm_context_save(struct elm_info *info)
+{
+	struct elm_registers *regs = &info->elm_regs;
+	enum bch_ecc bch_type = info->bch_type;
+	u32 offset = 0, i;
+
+	regs->elm_irqenable       = elm_read_reg(info, ELM_IRQENABLE);
+	regs->elm_sysconfig       = elm_read_reg(info, ELM_SYSCONFIG);
+	regs->elm_location_config = elm_read_reg(info, ELM_LOCATION_CONFIG);
+	regs->elm_page_ctrl       = elm_read_reg(info, ELM_PAGE_CTRL);
+	for (i = 0; i < ERROR_VECTOR_MAX; i++) {
+		offset = i * SYNDROME_FRAGMENT_REG_SIZE;
+		switch (bch_type) {
+		case BCH8_ECC:
+			regs->elm_syndrome_fragment_3[i] = elm_read_reg(info,
+					ELM_SYNDROME_FRAGMENT_3 + offset);
+			regs->elm_syndrome_fragment_2[i] = elm_read_reg(info,
+					ELM_SYNDROME_FRAGMENT_2 + offset);
+		case BCH4_ECC:
+			regs->elm_syndrome_fragment_1[i] = elm_read_reg(info,
+					ELM_SYNDROME_FRAGMENT_1 + offset);
+			regs->elm_syndrome_fragment_0[i] = elm_read_reg(info,
+					ELM_SYNDROME_FRAGMENT_0 + offset);
+		default:
+			return -EINVAL;
+		}
+		/* ELM SYNDROME_VALID bit in SYNDROME_FRAGMENT_6[] needs
+		 * to be saved for all BCH schemes*/
+		regs->elm_syndrome_fragment_6[i] = elm_read_reg(info,
+					ELM_SYNDROME_FRAGMENT_6 + offset);
+	}
+	return 0;
+}
+
+/**
+ * elm_context_restore
+ * writes configurations saved duing power-down back into ELM registers
+ */
+static int elm_context_restore(struct elm_info *info)
+{
+	struct elm_registers *regs = &info->elm_regs;
+	enum bch_ecc bch_type = info->bch_type;
+	u32 offset = 0, i;
+
+	elm_write_reg(info, ELM_IRQENABLE,	 regs->elm_irqenable);
+	elm_write_reg(info, ELM_SYSCONFIG,	 regs->elm_sysconfig);
+	elm_write_reg(info, ELM_LOCATION_CONFIG, regs->elm_location_config);
+	elm_write_reg(info, ELM_PAGE_CTRL,	 regs->elm_page_ctrl);
+	for (i = 0; i < ERROR_VECTOR_MAX; i++) {
+		offset = i * SYNDROME_FRAGMENT_REG_SIZE;
+		switch (bch_type) {
+		case BCH8_ECC:
+			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_3 + offset,
+					regs->elm_syndrome_fragment_3[i]);
+			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_2 + offset,
+					regs->elm_syndrome_fragment_2[i]);
+		case BCH4_ECC:
+			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_1 + offset,
+					regs->elm_syndrome_fragment_1[i]);
+			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_0 + offset,
+					regs->elm_syndrome_fragment_0[i]);
+		default:
+			return -EINVAL;
+		}
+		/* ELM_SYNDROME_VALID bit to be set in last to trigger FSM */
+		elm_write_reg(info, ELM_SYNDROME_FRAGMENT_6 + offset,
+					regs->elm_syndrome_fragment_6[i] &
+							 ELM_SYNDROME_VALID);
+	}
+	return 0;
+}
+
+static int elm_suspend(struct device *dev)
+{
+	struct elm_info *info = dev_get_drvdata(dev);
+	elm_context_save(info);
+	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_context_restore(info);
+	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" },
@@ -398,6 +514,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,
-- 
1.8.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 2/3] arm: gpmc: Low power transition support
  2013-06-17 18:46   ` Pekon Gupta
@ 2013-06-18 10:50     ` Tony Lindgren
  -1 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2013-06-18 10:50 UTC (permalink / raw)
  To: Pekon Gupta; +Cc: linux-mtd, linux-omap, khilman, avinash philip

* Pekon Gupta <pekon@ti.com> [130617 11:52]:
> From: avinash philip <avinashphilip@ti.com>
> 
> GPMC is hardware controller for external memory interfaces.
> This patch adds suspend/resume support for GPMC driver.
> It also preserves GPMC register configurations across device low-power states
> in which GPMC hardware can be powered-off.
> gpmc_suspend()/gpmc_resume() are called by default by core PM framework as part
> of driver's runtime PM callbacks.
> 
> Signed-off-by: Philip Avinash <avinashphilip@ti.com>
> Signed-off-by: Pekon Gupta <pekon@ti.com>

Thanks applying this into omap-for-v3.11/gpmc, patch 1/3 I already
have applied and the MTD change should get merged along with other
MTD patches.

Regards,

Tony

> ---
>  arch/arm/mach-omap2/gpmc.c | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
> index 1380cee..9b579d0 100644
> --- a/arch/arm/mach-omap2/gpmc.c
> +++ b/arch/arm/mach-omap2/gpmc.c
> @@ -1655,6 +1655,24 @@ static int gpmc_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int gpmc_suspend(struct device *dev)
> +{
> +	omap3_gpmc_save_context();
> +	pm_runtime_put_sync(dev);
> +	return 0;
> +}
> +
> +static int gpmc_resume(struct device *dev)
> +{
> +	pm_runtime_get_sync(dev);
> +	omap3_gpmc_restore_context();
> +	return 0;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(gpmc_pm_ops, gpmc_suspend, gpmc_resume);
> +
>  static struct platform_driver gpmc_driver = {
>  	.probe		= gpmc_probe,
>  	.remove		= gpmc_remove,
> @@ -1662,6 +1680,7 @@ static struct platform_driver gpmc_driver = {
>  		.name	= DEVICE_NAME,
>  		.owner	= THIS_MODULE,
>  		.of_match_table = of_match_ptr(gpmc_dt_ids),
> +		.pm	= &gpmc_pm_ops,
>  	},
>  };
>  
> @@ -1724,7 +1743,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)
> @@ -1789,4 +1807,3 @@ void omap3_gpmc_restore_context(void)
>  		}
>  	}
>  }
> -#endif /* CONFIG_ARCH_OMAP3 */
> -- 
> 1.8.1
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 2/3] arm: gpmc: Low power transition support
@ 2013-06-18 10:50     ` Tony Lindgren
  0 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2013-06-18 10:50 UTC (permalink / raw)
  To: Pekon Gupta; +Cc: linux-omap, linux-mtd, khilman

* Pekon Gupta <pekon@ti.com> [130617 11:52]:
> From: avinash philip <avinashphilip@ti.com>
> 
> GPMC is hardware controller for external memory interfaces.
> This patch adds suspend/resume support for GPMC driver.
> It also preserves GPMC register configurations across device low-power states
> in which GPMC hardware can be powered-off.
> gpmc_suspend()/gpmc_resume() are called by default by core PM framework as part
> of driver's runtime PM callbacks.
> 
> Signed-off-by: Philip Avinash <avinashphilip@ti.com>
> Signed-off-by: Pekon Gupta <pekon@ti.com>

Thanks applying this into omap-for-v3.11/gpmc, patch 1/3 I already
have applied and the MTD change should get merged along with other
MTD patches.

Regards,

Tony

> ---
>  arch/arm/mach-omap2/gpmc.c | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
> index 1380cee..9b579d0 100644
> --- a/arch/arm/mach-omap2/gpmc.c
> +++ b/arch/arm/mach-omap2/gpmc.c
> @@ -1655,6 +1655,24 @@ static int gpmc_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int gpmc_suspend(struct device *dev)
> +{
> +	omap3_gpmc_save_context();
> +	pm_runtime_put_sync(dev);
> +	return 0;
> +}
> +
> +static int gpmc_resume(struct device *dev)
> +{
> +	pm_runtime_get_sync(dev);
> +	omap3_gpmc_restore_context();
> +	return 0;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(gpmc_pm_ops, gpmc_suspend, gpmc_resume);
> +
>  static struct platform_driver gpmc_driver = {
>  	.probe		= gpmc_probe,
>  	.remove		= gpmc_remove,
> @@ -1662,6 +1680,7 @@ static struct platform_driver gpmc_driver = {
>  		.name	= DEVICE_NAME,
>  		.owner	= THIS_MODULE,
>  		.of_match_table = of_match_ptr(gpmc_dt_ids),
> +		.pm	= &gpmc_pm_ops,
>  	},
>  };
>  
> @@ -1724,7 +1743,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)
> @@ -1789,4 +1807,3 @@ void omap3_gpmc_restore_context(void)
>  		}
>  	}
>  }
> -#endif /* CONFIG_ARCH_OMAP3 */
> -- 
> 1.8.1
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH v5 3/3] mtd: devices: elm: Low power transition support
  2013-06-17 18:46   ` Pekon Gupta
@ 2013-07-01  7:35     ` Gupta, Pekon
  -1 siblings, 0 replies; 14+ messages in thread
From: Gupta, Pekon @ 2013-07-01  7:35 UTC (permalink / raw)
  To: Artem Bityutskiy (artem.bityutskiy@linux.intel.com)
  Cc: tony, khilman, Philip, Avinash, avinashphilipk, linux-mtd, linux-omap

> 
> From: avinash philip <avinashphilip@ti.com>
> 
> ELM is used for locating bit-flip errors in when using BCH ECC scheme.
> This patch adds suspend/resume support for leaf level ELM driver,
> And also provides ELM register context save & restore support, so that
> configurations are preserved across hardware power-off/on transitions.
> 
> Signed-off-by: Philip Avinash <avinashphilip@ti.com>
> Signed-off-by: Pekon Gupta <pekon@ti.com>
> ---

Hi Artem,

In following series [Patch 1/3] and [Patch 2/3] were picked up by  Tony (for GPMC). But this last one is awaits your approval, as it touches ELM driver in driver/*mtd*/devices. If everything clean then please pull this one for v3.11 merge.

Also, request you to please look into 
"[PATCH v3 0/4] mtd:nand:omap2: clean-up of supported ECC schemes" series, if it can be taken for 3.11 merge, as lot of further omap2-nand driver enhancements are based on this series.

Thanks ...
with regards, pekon

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH v5 3/3] mtd: devices: elm: Low power transition support
@ 2013-07-01  7:35     ` Gupta, Pekon
  0 siblings, 0 replies; 14+ messages in thread
From: Gupta, Pekon @ 2013-07-01  7:35 UTC (permalink / raw)
  To: Artem Bityutskiy (artem.bityutskiy@linux.intel.com)
  Cc: khilman, tony, avinashphilipk, linux-mtd, linux-omap

> 
> From: avinash philip <avinashphilip@ti.com>
> 
> ELM is used for locating bit-flip errors in when using BCH ECC scheme.
> This patch adds suspend/resume support for leaf level ELM driver,
> And also provides ELM register context save & restore support, so that
> configurations are preserved across hardware power-off/on transitions.
> 
> Signed-off-by: Philip Avinash <avinashphilip@ti.com>
> Signed-off-by: Pekon Gupta <pekon@ti.com>
> ---

Hi Artem,

In following series [Patch 1/3] and [Patch 2/3] were picked up by  Tony (for GPMC). But this last one is awaits your approval, as it touches ELM driver in driver/*mtd*/devices. If everything clean then please pull this one for v3.11 merge.

Also, request you to please look into 
"[PATCH v3 0/4] mtd:nand:omap2: clean-up of supported ECC schemes" series, if it can be taken for 3.11 merge, as lot of further omap2-nand driver enhancements are based on this series.

Thanks ...
with regards, pekon

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 3/3] mtd: devices: elm: Low power transition support
  2013-06-17 18:46   ` Pekon Gupta
@ 2013-07-01  8:02     ` Artem Bityutskiy
  -1 siblings, 0 replies; 14+ messages in thread
From: Artem Bityutskiy @ 2013-07-01  8:02 UTC (permalink / raw)
  To: Pekon Gupta; +Cc: tony, linux-omap, linux-mtd, khilman

On Tue, 2013-06-18 at 00:16 +0530, Pekon Gupta wrote:
> From: avinash philip <avinashphilip@ti.com>
> 
> ELM is used for locating bit-flip errors in when using BCH ECC scheme.
> This patch adds suspend/resume support for leaf level ELM driver,
> And also provides ELM register context save & restore support, so that
> configurations are preserved across hardware power-off/on transitions.
> 
> Signed-off-by: Philip Avinash <avinashphilip@ti.com>
> Signed-off-by: Pekon Gupta <pekon@ti.com>

Pushed to l2-mtd.git, thanks!

-- 
Best Regards,
Artem Bityutskiy


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 3/3] mtd: devices: elm: Low power transition support
@ 2013-07-01  8:02     ` Artem Bityutskiy
  0 siblings, 0 replies; 14+ messages in thread
From: Artem Bityutskiy @ 2013-07-01  8:02 UTC (permalink / raw)
  To: Pekon Gupta; +Cc: tony, linux-omap, linux-mtd, khilman

On Tue, 2013-06-18 at 00:16 +0530, Pekon Gupta wrote:
> From: avinash philip <avinashphilip@ti.com>
> 
> ELM is used for locating bit-flip errors in when using BCH ECC scheme.
> This patch adds suspend/resume support for leaf level ELM driver,
> And also provides ELM register context save & restore support, so that
> configurations are preserved across hardware power-off/on transitions.
> 
> Signed-off-by: Philip Avinash <avinashphilip@ti.com>
> Signed-off-by: Pekon Gupta <pekon@ti.com>

Pushed to l2-mtd.git, thanks!

-- 
Best Regards,
Artem Bityutskiy

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-07-01  8:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-17 18:46 [PATCH v5 0/3] suspend/resume support for OMAP nand driver Pekon Gupta
2013-06-17 18:46 ` Pekon Gupta
2013-06-17 18:46 ` [PATCH v5 1/3] ARM: OMAP2+: gpmc: Converts GPMC driver to pm_runtime capable Pekon Gupta
2013-06-17 18:46   ` Pekon Gupta
2013-06-17 18:46 ` [PATCH v5 2/3] arm: gpmc: Low power transition support Pekon Gupta
2013-06-17 18:46   ` Pekon Gupta
2013-06-18 10:50   ` Tony Lindgren
2013-06-18 10:50     ` Tony Lindgren
2013-06-17 18:46 ` [PATCH v5 3/3] mtd: devices: elm: " Pekon Gupta
2013-06-17 18:46   ` Pekon Gupta
2013-07-01  7:35   ` Gupta, Pekon
2013-07-01  7:35     ` Gupta, Pekon
2013-07-01  8:02   ` Artem Bityutskiy
2013-07-01  8:02     ` Artem Bityutskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.