All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] arm: mach-omap2: clkdm/pwrdm: Save/restore context
@ 2018-05-16 15:16 ` Keerthy
  0 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-16 15:16 UTC (permalink / raw)
  To: tony; +Cc: t-kristo, j-keerthy, linux-omap, linux-arm-kernel

The series adds a save/restore functions for clockdomain
and powerdomain. The context is lost only with AM43XX SoCs
only in the rtc only mode with ddr in self-refresh.

The other OMAP family do not use the contexts as the PRCM
is in WKUP Domain.

Keerthy (2):
  omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
  omap2: powerdomain: Inroduce cpu_pm notifiers for context     
    save/restore

Russ Dill (2):
  ARM: OMAP2: Add functions to save and restore clockdomain context
    en-masse.
  ARM: OMAP2: Add functions to save and restore powerdomain context

 arch/arm/mach-omap2/clockdomain.c | 73 ++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/clockdomain.h |  8 ++++
 arch/arm/mach-omap2/cm33xx.c      | 53 ++++++++++++++++++++++++
 arch/arm/mach-omap2/cminst44xx.c  | 43 +++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.c | 87 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.h |  7 ++++
 arch/arm/mach-omap2/prm33xx.c     | 31 ++++++++++++++
 arch/arm/mach-omap2/prm44xx.c     | 50 ++++++++++++++++++++++
 8 files changed, 352 insertions(+)

-- 
1.9.1

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

* [PATCH 0/4] arm: mach-omap2: clkdm/pwrdm: Save/restore context
@ 2018-05-16 15:16 ` Keerthy
  0 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-16 15:16 UTC (permalink / raw)
  To: linux-arm-kernel

The series adds a save/restore functions for clockdomain
and powerdomain. The context is lost only with AM43XX SoCs
only in the rtc only mode with ddr in self-refresh.

The other OMAP family do not use the contexts as the PRCM
is in WKUP Domain.

Keerthy (2):
  omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
  omap2: powerdomain: Inroduce cpu_pm notifiers for context     
    save/restore

Russ Dill (2):
  ARM: OMAP2: Add functions to save and restore clockdomain context
    en-masse.
  ARM: OMAP2: Add functions to save and restore powerdomain context

 arch/arm/mach-omap2/clockdomain.c | 73 ++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/clockdomain.h |  8 ++++
 arch/arm/mach-omap2/cm33xx.c      | 53 ++++++++++++++++++++++++
 arch/arm/mach-omap2/cminst44xx.c  | 43 +++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.c | 87 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.h |  7 ++++
 arch/arm/mach-omap2/prm33xx.c     | 31 ++++++++++++++
 arch/arm/mach-omap2/prm44xx.c     | 50 ++++++++++++++++++++++
 8 files changed, 352 insertions(+)

-- 
1.9.1

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

* [PATCH 1/4] ARM: OMAP2: Add functions to save and restore clockdomain context en-masse.
  2018-05-16 15:16 ` Keerthy
@ 2018-05-16 15:16   ` Keerthy
  -1 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-16 15:16 UTC (permalink / raw)
  To: tony
  Cc: Dave Gerlach, j-keerthy, t-kristo, Russ Dill, linux-omap,
	linux-arm-kernel

From: Russ Dill <Russ.Dill@ti.com>

This is used to support suspend modes like RTC-only and hibernate where
the state of the registers controlling clockdomains is lost.

Signed-off-by: Russ Dill <Russ.Dill@ti.com>
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 arch/arm/mach-omap2/clockdomain.c | 46 +++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/clockdomain.h |  8 ++++++
 arch/arm/mach-omap2/cm33xx.c      | 53 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/cminst44xx.c  | 43 +++++++++++++++++++++++++++++++
 4 files changed, 150 insertions(+)

diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index b79b1ca..0906380 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -1307,3 +1307,49 @@ int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh)
 	return 0;
 }
 
+/**
+ * _clkdm_save_context - save the context for the control of this clkdm
+ *
+ * Due to a suspend or hibernation operation, the state of the registers
+ * controlling this clkdm will be lost, save their context.
+ */
+static int _clkdm_save_context(struct clockdomain *clkdm, void *ununsed)
+{
+	if (!arch_clkdm || !arch_clkdm->clkdm_save_context)
+		return -EINVAL;
+
+	return arch_clkdm->clkdm_save_context(clkdm);
+}
+
+/**
+ * _clkdm_restore_context - restore context for control of this clkdm
+ *
+ * Restore the register values for this clockdomain.
+ */
+static int _clkdm_restore_context(struct clockdomain *clkdm, void *ununsed)
+{
+	if (!arch_clkdm || !arch_clkdm->clkdm_restore_context)
+		return -EINVAL;
+
+	return arch_clkdm->clkdm_restore_context(clkdm);
+}
+
+/**
+ * clkdm_save_context - Saves the context for each registered clkdm
+ *
+ * Save the context for each registered clockdomain.
+ */
+void clkdm_save_context(void)
+{
+	clkdm_for_each(_clkdm_save_context, NULL);
+}
+
+/**
+ * clkdm_restore_context - Restores the context for each registered clkdm
+ *
+ * Restore the context for each registered clockdomain.
+ */
+void clkdm_restore_context(void)
+{
+	clkdm_for_each(_clkdm_restore_context, NULL);
+}
diff --git a/arch/arm/mach-omap2/clockdomain.h b/arch/arm/mach-omap2/clockdomain.h
index 24667a5..c7d0953 100644
--- a/arch/arm/mach-omap2/clockdomain.h
+++ b/arch/arm/mach-omap2/clockdomain.h
@@ -141,6 +141,7 @@ struct clockdomain {
 	int usecount;
 	int forcewake_count;
 	struct list_head node;
+	u32 context;
 };
 
 /**
@@ -159,6 +160,8 @@ struct clockdomain {
  * @clkdm_deny_idle: Disable hw supervised idle transitions for clock domain
  * @clkdm_clk_enable: Put the clkdm in right state for a clock enable
  * @clkdm_clk_disable: Put the clkdm in right state for a clock disable
+ * @clkdm_save_context: Save the current clkdm context
+ * @clkdm_restore_context: Restore the clkdm context
  */
 struct clkdm_ops {
 	int	(*clkdm_add_wkdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
@@ -175,6 +178,8 @@ struct clkdm_ops {
 	void	(*clkdm_deny_idle)(struct clockdomain *clkdm);
 	int	(*clkdm_clk_enable)(struct clockdomain *clkdm);
 	int	(*clkdm_clk_disable)(struct clockdomain *clkdm);
+	int	(*clkdm_save_context)(struct clockdomain *clkdm);
+	int	(*clkdm_restore_context)(struct clockdomain *clkdm);
 };
 
 int clkdm_register_platform_funcs(struct clkdm_ops *co);
@@ -214,6 +219,9 @@ int clkdm_for_each(int (*fn)(struct clockdomain *clkdm, void *user),
 int clkdm_hwmod_enable(struct clockdomain *clkdm, struct omap_hwmod *oh);
 int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh);
 
+void clkdm_save_context(void);
+void clkdm_restore_context(void);
+
 extern void __init omap242x_clockdomains_init(void);
 extern void __init omap243x_clockdomains_init(void);
 extern void __init omap3xxx_clockdomains_init(void);
diff --git a/arch/arm/mach-omap2/cm33xx.c b/arch/arm/mach-omap2/cm33xx.c
index 1cc0247..084d454 100644
--- a/arch/arm/mach-omap2/cm33xx.c
+++ b/arch/arm/mach-omap2/cm33xx.c
@@ -72,6 +72,17 @@ static inline u32 am33xx_cm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx)
 	return v;
 }
 
+static inline u32 am33xx_cm_read_reg_bits(u16 inst, s16 idx, u32 mask)
+{
+	u32 v;
+
+	v = am33xx_cm_read_reg(inst, idx);
+	v &= mask;
+	v >>= __ffs(mask);
+
+	return v;
+}
+
 /**
  * _clkctrl_idlest - read a CM_*_CLKCTRL register; mask & shift IDLEST bitfield
  * @inst: CM instance register offset (*_INST macro)
@@ -338,6 +349,46 @@ static u32 am33xx_cm_xlate_clkctrl(u8 part, u16 inst, u16 offset)
 	return cm_base.pa + inst + offset;
 }
 
+/**
+ * am33xx_clkdm_save_context - Save the clockdomain transition context
+ * @clkdm: The clockdomain pointer whose context needs to be saved
+ *
+ * Save the clockdomain transition context.
+ */
+static int am33xx_clkdm_save_context(struct clockdomain *clkdm)
+{
+	clkdm->context = am33xx_cm_read_reg_bits(clkdm->cm_inst,
+						 clkdm->clkdm_offs,
+						 AM33XX_CLKTRCTRL_MASK);
+
+	return 0;
+}
+
+/**
+ * am33xx_restore_save_context - Restore the clockdomain transition context
+ * @clkdm: The clockdomain pointer whose context needs to be restored
+ *
+ * Restore the clockdomain transition context.
+ */
+static int am33xx_clkdm_restore_context(struct clockdomain *clkdm)
+{
+	switch (clkdm->context) {
+	case OMAP34XX_CLKSTCTRL_DISABLE_AUTO:
+		am33xx_clkdm_deny_idle(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_FORCE_SLEEP:
+		am33xx_clkdm_sleep(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_FORCE_WAKEUP:
+		am33xx_clkdm_wakeup(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_ENABLE_AUTO:
+		am33xx_clkdm_allow_idle(clkdm);
+		break;
+	}
+	return 0;
+}
+
 struct clkdm_ops am33xx_clkdm_operations = {
 	.clkdm_sleep		= am33xx_clkdm_sleep,
 	.clkdm_wakeup		= am33xx_clkdm_wakeup,
@@ -345,6 +396,8 @@ struct clkdm_ops am33xx_clkdm_operations = {
 	.clkdm_deny_idle	= am33xx_clkdm_deny_idle,
 	.clkdm_clk_enable	= am33xx_clkdm_clk_enable,
 	.clkdm_clk_disable	= am33xx_clkdm_clk_disable,
+	.clkdm_save_context	= am33xx_clkdm_save_context,
+	.clkdm_restore_context	= am33xx_clkdm_restore_context,
 };
 
 static const struct cm_ll_data am33xx_cm_ll_data = {
diff --git a/arch/arm/mach-omap2/cminst44xx.c b/arch/arm/mach-omap2/cminst44xx.c
index 7deefee..c11ac49 100644
--- a/arch/arm/mach-omap2/cminst44xx.c
+++ b/arch/arm/mach-omap2/cminst44xx.c
@@ -481,6 +481,47 @@ static u32 omap4_cminst_xlate_clkctrl(u8 part, u16 inst, u16 offset)
 	return _cm_bases[part].pa + inst + offset;
 }
 
+/**
+ * omap4_clkdm_save_context - Save the clockdomain modulemode context
+ * @clkdm: The clockdomain pointer whose context needs to be saved
+ *
+ * Save the clockdomain modulemode context.
+ */
+static int omap4_clkdm_save_context(struct clockdomain *clkdm)
+{
+	clkdm->context = omap4_cminst_read_inst_reg(clkdm->prcm_partition,
+						    clkdm->cm_inst,
+						    clkdm->clkdm_offs +
+						    OMAP4_CM_CLKSTCTRL);
+	clkdm->context &= OMAP4430_MODULEMODE_MASK;
+	return 0;
+}
+
+/**
+ * omap4_clkdm_restore_context - Restore the clockdomain modulemode context
+ * @clkdm: The clockdomain pointer whose context needs to be restored
+ *
+ * Restore the clockdomain modulemode context.
+ */
+static int omap4_clkdm_restore_context(struct clockdomain *clkdm)
+{
+	switch (clkdm->context) {
+	case OMAP34XX_CLKSTCTRL_DISABLE_AUTO:
+		omap4_clkdm_deny_idle(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_FORCE_SLEEP:
+		omap4_clkdm_sleep(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_FORCE_WAKEUP:
+		omap4_clkdm_wakeup(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_ENABLE_AUTO:
+		omap4_clkdm_allow_idle(clkdm);
+		break;
+	}
+	return 0;
+}
+
 struct clkdm_ops omap4_clkdm_operations = {
 	.clkdm_add_wkdep	= omap4_clkdm_add_wkup_sleep_dep,
 	.clkdm_del_wkdep	= omap4_clkdm_del_wkup_sleep_dep,
@@ -496,6 +537,8 @@ struct clkdm_ops omap4_clkdm_operations = {
 	.clkdm_deny_idle	= omap4_clkdm_deny_idle,
 	.clkdm_clk_enable	= omap4_clkdm_clk_enable,
 	.clkdm_clk_disable	= omap4_clkdm_clk_disable,
+	.clkdm_save_context	= omap4_clkdm_save_context,
+	.clkdm_restore_context	= omap4_clkdm_restore_context,
 };
 
 struct clkdm_ops am43xx_clkdm_operations = {
-- 
1.9.1

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

* [PATCH 1/4] ARM: OMAP2: Add functions to save and restore clockdomain context en-masse.
@ 2018-05-16 15:16   ` Keerthy
  0 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-16 15:16 UTC (permalink / raw)
  To: linux-arm-kernel

From: Russ Dill <Russ.Dill@ti.com>

This is used to support suspend modes like RTC-only and hibernate where
the state of the registers controlling clockdomains is lost.

Signed-off-by: Russ Dill <Russ.Dill@ti.com>
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 arch/arm/mach-omap2/clockdomain.c | 46 +++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/clockdomain.h |  8 ++++++
 arch/arm/mach-omap2/cm33xx.c      | 53 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/cminst44xx.c  | 43 +++++++++++++++++++++++++++++++
 4 files changed, 150 insertions(+)

diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index b79b1ca..0906380 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -1307,3 +1307,49 @@ int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh)
 	return 0;
 }
 
+/**
+ * _clkdm_save_context - save the context for the control of this clkdm
+ *
+ * Due to a suspend or hibernation operation, the state of the registers
+ * controlling this clkdm will be lost, save their context.
+ */
+static int _clkdm_save_context(struct clockdomain *clkdm, void *ununsed)
+{
+	if (!arch_clkdm || !arch_clkdm->clkdm_save_context)
+		return -EINVAL;
+
+	return arch_clkdm->clkdm_save_context(clkdm);
+}
+
+/**
+ * _clkdm_restore_context - restore context for control of this clkdm
+ *
+ * Restore the register values for this clockdomain.
+ */
+static int _clkdm_restore_context(struct clockdomain *clkdm, void *ununsed)
+{
+	if (!arch_clkdm || !arch_clkdm->clkdm_restore_context)
+		return -EINVAL;
+
+	return arch_clkdm->clkdm_restore_context(clkdm);
+}
+
+/**
+ * clkdm_save_context - Saves the context for each registered clkdm
+ *
+ * Save the context for each registered clockdomain.
+ */
+void clkdm_save_context(void)
+{
+	clkdm_for_each(_clkdm_save_context, NULL);
+}
+
+/**
+ * clkdm_restore_context - Restores the context for each registered clkdm
+ *
+ * Restore the context for each registered clockdomain.
+ */
+void clkdm_restore_context(void)
+{
+	clkdm_for_each(_clkdm_restore_context, NULL);
+}
diff --git a/arch/arm/mach-omap2/clockdomain.h b/arch/arm/mach-omap2/clockdomain.h
index 24667a5..c7d0953 100644
--- a/arch/arm/mach-omap2/clockdomain.h
+++ b/arch/arm/mach-omap2/clockdomain.h
@@ -141,6 +141,7 @@ struct clockdomain {
 	int usecount;
 	int forcewake_count;
 	struct list_head node;
+	u32 context;
 };
 
 /**
@@ -159,6 +160,8 @@ struct clockdomain {
  * @clkdm_deny_idle: Disable hw supervised idle transitions for clock domain
  * @clkdm_clk_enable: Put the clkdm in right state for a clock enable
  * @clkdm_clk_disable: Put the clkdm in right state for a clock disable
+ * @clkdm_save_context: Save the current clkdm context
+ * @clkdm_restore_context: Restore the clkdm context
  */
 struct clkdm_ops {
 	int	(*clkdm_add_wkdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
@@ -175,6 +178,8 @@ struct clkdm_ops {
 	void	(*clkdm_deny_idle)(struct clockdomain *clkdm);
 	int	(*clkdm_clk_enable)(struct clockdomain *clkdm);
 	int	(*clkdm_clk_disable)(struct clockdomain *clkdm);
+	int	(*clkdm_save_context)(struct clockdomain *clkdm);
+	int	(*clkdm_restore_context)(struct clockdomain *clkdm);
 };
 
 int clkdm_register_platform_funcs(struct clkdm_ops *co);
@@ -214,6 +219,9 @@ int clkdm_for_each(int (*fn)(struct clockdomain *clkdm, void *user),
 int clkdm_hwmod_enable(struct clockdomain *clkdm, struct omap_hwmod *oh);
 int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh);
 
+void clkdm_save_context(void);
+void clkdm_restore_context(void);
+
 extern void __init omap242x_clockdomains_init(void);
 extern void __init omap243x_clockdomains_init(void);
 extern void __init omap3xxx_clockdomains_init(void);
diff --git a/arch/arm/mach-omap2/cm33xx.c b/arch/arm/mach-omap2/cm33xx.c
index 1cc0247..084d454 100644
--- a/arch/arm/mach-omap2/cm33xx.c
+++ b/arch/arm/mach-omap2/cm33xx.c
@@ -72,6 +72,17 @@ static inline u32 am33xx_cm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx)
 	return v;
 }
 
+static inline u32 am33xx_cm_read_reg_bits(u16 inst, s16 idx, u32 mask)
+{
+	u32 v;
+
+	v = am33xx_cm_read_reg(inst, idx);
+	v &= mask;
+	v >>= __ffs(mask);
+
+	return v;
+}
+
 /**
  * _clkctrl_idlest - read a CM_*_CLKCTRL register; mask & shift IDLEST bitfield
  * @inst: CM instance register offset (*_INST macro)
@@ -338,6 +349,46 @@ static u32 am33xx_cm_xlate_clkctrl(u8 part, u16 inst, u16 offset)
 	return cm_base.pa + inst + offset;
 }
 
+/**
+ * am33xx_clkdm_save_context - Save the clockdomain transition context
+ * @clkdm: The clockdomain pointer whose context needs to be saved
+ *
+ * Save the clockdomain transition context.
+ */
+static int am33xx_clkdm_save_context(struct clockdomain *clkdm)
+{
+	clkdm->context = am33xx_cm_read_reg_bits(clkdm->cm_inst,
+						 clkdm->clkdm_offs,
+						 AM33XX_CLKTRCTRL_MASK);
+
+	return 0;
+}
+
+/**
+ * am33xx_restore_save_context - Restore the clockdomain transition context
+ * @clkdm: The clockdomain pointer whose context needs to be restored
+ *
+ * Restore the clockdomain transition context.
+ */
+static int am33xx_clkdm_restore_context(struct clockdomain *clkdm)
+{
+	switch (clkdm->context) {
+	case OMAP34XX_CLKSTCTRL_DISABLE_AUTO:
+		am33xx_clkdm_deny_idle(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_FORCE_SLEEP:
+		am33xx_clkdm_sleep(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_FORCE_WAKEUP:
+		am33xx_clkdm_wakeup(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_ENABLE_AUTO:
+		am33xx_clkdm_allow_idle(clkdm);
+		break;
+	}
+	return 0;
+}
+
 struct clkdm_ops am33xx_clkdm_operations = {
 	.clkdm_sleep		= am33xx_clkdm_sleep,
 	.clkdm_wakeup		= am33xx_clkdm_wakeup,
@@ -345,6 +396,8 @@ struct clkdm_ops am33xx_clkdm_operations = {
 	.clkdm_deny_idle	= am33xx_clkdm_deny_idle,
 	.clkdm_clk_enable	= am33xx_clkdm_clk_enable,
 	.clkdm_clk_disable	= am33xx_clkdm_clk_disable,
+	.clkdm_save_context	= am33xx_clkdm_save_context,
+	.clkdm_restore_context	= am33xx_clkdm_restore_context,
 };
 
 static const struct cm_ll_data am33xx_cm_ll_data = {
diff --git a/arch/arm/mach-omap2/cminst44xx.c b/arch/arm/mach-omap2/cminst44xx.c
index 7deefee..c11ac49 100644
--- a/arch/arm/mach-omap2/cminst44xx.c
+++ b/arch/arm/mach-omap2/cminst44xx.c
@@ -481,6 +481,47 @@ static u32 omap4_cminst_xlate_clkctrl(u8 part, u16 inst, u16 offset)
 	return _cm_bases[part].pa + inst + offset;
 }
 
+/**
+ * omap4_clkdm_save_context - Save the clockdomain modulemode context
+ * @clkdm: The clockdomain pointer whose context needs to be saved
+ *
+ * Save the clockdomain modulemode context.
+ */
+static int omap4_clkdm_save_context(struct clockdomain *clkdm)
+{
+	clkdm->context = omap4_cminst_read_inst_reg(clkdm->prcm_partition,
+						    clkdm->cm_inst,
+						    clkdm->clkdm_offs +
+						    OMAP4_CM_CLKSTCTRL);
+	clkdm->context &= OMAP4430_MODULEMODE_MASK;
+	return 0;
+}
+
+/**
+ * omap4_clkdm_restore_context - Restore the clockdomain modulemode context
+ * @clkdm: The clockdomain pointer whose context needs to be restored
+ *
+ * Restore the clockdomain modulemode context.
+ */
+static int omap4_clkdm_restore_context(struct clockdomain *clkdm)
+{
+	switch (clkdm->context) {
+	case OMAP34XX_CLKSTCTRL_DISABLE_AUTO:
+		omap4_clkdm_deny_idle(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_FORCE_SLEEP:
+		omap4_clkdm_sleep(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_FORCE_WAKEUP:
+		omap4_clkdm_wakeup(clkdm);
+		break;
+	case OMAP34XX_CLKSTCTRL_ENABLE_AUTO:
+		omap4_clkdm_allow_idle(clkdm);
+		break;
+	}
+	return 0;
+}
+
 struct clkdm_ops omap4_clkdm_operations = {
 	.clkdm_add_wkdep	= omap4_clkdm_add_wkup_sleep_dep,
 	.clkdm_del_wkdep	= omap4_clkdm_del_wkup_sleep_dep,
@@ -496,6 +537,8 @@ struct clkdm_ops omap4_clkdm_operations = {
 	.clkdm_deny_idle	= omap4_clkdm_deny_idle,
 	.clkdm_clk_enable	= omap4_clkdm_clk_enable,
 	.clkdm_clk_disable	= omap4_clkdm_clk_disable,
+	.clkdm_save_context	= omap4_clkdm_save_context,
+	.clkdm_restore_context	= omap4_clkdm_restore_context,
 };
 
 struct clkdm_ops am43xx_clkdm_operations = {
-- 
1.9.1

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

* [PATCH 2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
  2018-05-16 15:16 ` Keerthy
@ 2018-05-16 15:16   ` Keerthy
  -1 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-16 15:16 UTC (permalink / raw)
  To: tony; +Cc: t-kristo, j-keerthy, linux-omap, linux-arm-kernel

Inroduce cpu_pm notifiers for context save/restore. This will be
needed for am43xx family in case of rtc only mode with ddr in
self-refresh.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 arch/arm/mach-omap2/clockdomain.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index 0906380..6d44fe0 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -23,6 +23,7 @@
 #include <linux/limits.h>
 #include <linux/err.h>
 #include <linux/clk-provider.h>
+#include <linux/cpu_pm.h>
 
 #include <linux/io.h>
 
@@ -31,6 +32,7 @@
 #include "soc.h"
 #include "clock.h"
 #include "clockdomain.h"
+#include "pm.h"
 
 /* clkdm_list contains all registered struct clockdomains */
 static LIST_HEAD(clkdm_list);
@@ -39,6 +41,8 @@
 static struct clkdm_autodep *autodeps;
 
 static struct clkdm_ops *arch_clkdm;
+void clkdm_save_context(void);
+void clkdm_restore_context(void);
 
 /* Private functions */
 
@@ -449,6 +453,22 @@ int clkdm_register_autodeps(struct clkdm_autodep *ia)
 	return 0;
 }
 
+static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
+{
+	switch (cmd) {
+	case CPU_CLUSTER_PM_ENTER:
+		if (enable_off_mode)
+			clkdm_save_context();
+		break;
+	case CPU_CLUSTER_PM_EXIT:
+		if (enable_off_mode)
+			clkdm_restore_context();
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
 /**
  * clkdm_complete_init - set up the clockdomain layer
  *
@@ -460,6 +480,7 @@ int clkdm_register_autodeps(struct clkdm_autodep *ia)
 int clkdm_complete_init(void)
 {
 	struct clockdomain *clkdm;
+	static struct notifier_block nb;
 
 	if (list_empty(&clkdm_list))
 		return -EACCES;
@@ -474,6 +495,12 @@ int clkdm_complete_init(void)
 		clkdm_clear_all_sleepdeps(clkdm);
 	}
 
+	/* Only AM43XX can lose clkdm context during rtc-ddr suspend */
+	if (soc_is_am43xx()) {
+		nb.notifier_call = cpu_notifier;
+		cpu_pm_register_notifier(&nb);
+	}
+
 	return 0;
 }
 
-- 
1.9.1

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

* [PATCH 2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
@ 2018-05-16 15:16   ` Keerthy
  0 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-16 15:16 UTC (permalink / raw)
  To: linux-arm-kernel

Inroduce cpu_pm notifiers for context save/restore. This will be
needed for am43xx family in case of rtc only mode with ddr in
self-refresh.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 arch/arm/mach-omap2/clockdomain.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index 0906380..6d44fe0 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -23,6 +23,7 @@
 #include <linux/limits.h>
 #include <linux/err.h>
 #include <linux/clk-provider.h>
+#include <linux/cpu_pm.h>
 
 #include <linux/io.h>
 
@@ -31,6 +32,7 @@
 #include "soc.h"
 #include "clock.h"
 #include "clockdomain.h"
+#include "pm.h"
 
 /* clkdm_list contains all registered struct clockdomains */
 static LIST_HEAD(clkdm_list);
@@ -39,6 +41,8 @@
 static struct clkdm_autodep *autodeps;
 
 static struct clkdm_ops *arch_clkdm;
+void clkdm_save_context(void);
+void clkdm_restore_context(void);
 
 /* Private functions */
 
@@ -449,6 +453,22 @@ int clkdm_register_autodeps(struct clkdm_autodep *ia)
 	return 0;
 }
 
+static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
+{
+	switch (cmd) {
+	case CPU_CLUSTER_PM_ENTER:
+		if (enable_off_mode)
+			clkdm_save_context();
+		break;
+	case CPU_CLUSTER_PM_EXIT:
+		if (enable_off_mode)
+			clkdm_restore_context();
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
 /**
  * clkdm_complete_init - set up the clockdomain layer
  *
@@ -460,6 +480,7 @@ int clkdm_register_autodeps(struct clkdm_autodep *ia)
 int clkdm_complete_init(void)
 {
 	struct clockdomain *clkdm;
+	static struct notifier_block nb;
 
 	if (list_empty(&clkdm_list))
 		return -EACCES;
@@ -474,6 +495,12 @@ int clkdm_complete_init(void)
 		clkdm_clear_all_sleepdeps(clkdm);
 	}
 
+	/* Only AM43XX can lose clkdm context during rtc-ddr suspend */
+	if (soc_is_am43xx()) {
+		nb.notifier_call = cpu_notifier;
+		cpu_pm_register_notifier(&nb);
+	}
+
 	return 0;
 }
 
-- 
1.9.1

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

* [PATCH 3/4] ARM: OMAP2: Add functions to save and restore powerdomain context
  2018-05-16 15:16 ` Keerthy
@ 2018-05-16 15:17   ` Keerthy
  -1 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-16 15:17 UTC (permalink / raw)
  To: tony
  Cc: Dave Gerlach, j-keerthy, t-kristo, Russ Dill, linux-omap,
	linux-arm-kernel

From: Russ Dill <Russ.Dill@ti.com>

The powerdomain control registers are stored in the WKUP powerdomain on
AM33XX/AM43XX, which is lost on RTC-only suspend and also hibernate. This
adds context save and restore functions for those registers.
Sometimes the powerdomain state does not need to change,
perhaps we only need to change memory retention states, so make
sure the restored state is different from the current state before we wait
for a transition.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Russ Dill <Russ.Dill@ti.com>
---
 arch/arm/mach-omap2/powerdomain.c | 60 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.h |  7 +++++
 arch/arm/mach-omap2/prm33xx.c     | 31 ++++++++++++++++++++
 arch/arm/mach-omap2/prm44xx.c     | 50 ++++++++++++++++++++++++++++++++
 4 files changed, 148 insertions(+)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 1e6a967..b97b308 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -1199,3 +1199,63 @@ bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm)
 
 	return 0;
 }
+
+/**
+ * pwrdm_save_context - save powerdomain registers
+ *
+ * Register state is going to be lost due to a suspend or hibernate
+ * event. Save the powerdomain registers.
+ */
+static int pwrdm_save_context(struct powerdomain *pwrdm, void *unused)
+{
+	if (arch_pwrdm && arch_pwrdm->pwrdm_save_context)
+		arch_pwrdm->pwrdm_save_context(pwrdm);
+	return 0;
+}
+
+/**
+ * pwrdm_save_context - restore powerdomain registers
+ *
+ * Restore powerdomain control registers after a suspend or resume
+ * event.
+ */
+static int pwrdm_restore_context(struct powerdomain *pwrdm, void *unused)
+{
+	if (arch_pwrdm && arch_pwrdm->pwrdm_restore_context)
+		arch_pwrdm->pwrdm_restore_context(pwrdm);
+	return 0;
+}
+
+static int pwrdm_lost_power(struct powerdomain *pwrdm, void *unused)
+{
+	int state;
+
+	/*
+	 * Power has been lost across all powerdomains, increment the
+	 * counter.
+	 */
+
+	state = pwrdm_read_pwrst(pwrdm);
+	if (state != PWRDM_POWER_OFF) {
+		pwrdm->state_counter[state]++;
+		pwrdm->state_counter[PWRDM_POWER_OFF]++;
+	}
+	pwrdm->state = state;
+
+	return 0;
+}
+
+void pwrdms_save_context(void)
+{
+	pwrdm_for_each(pwrdm_save_context, NULL);
+}
+
+void pwrdms_restore_context(void)
+{
+	pwrdm_for_each(pwrdm_restore_context, NULL);
+}
+
+void pwrdms_lost_power(void)
+{
+	pwrdm_for_each(pwrdm_lost_power, NULL);
+}
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index 28a796c..9a907fb 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -144,6 +144,7 @@ struct powerdomain {
 	s64 timer;
 	s64 state_timer[PWRDM_MAX_PWRSTS];
 #endif
+	u32 context;
 };
 
 /**
@@ -198,6 +199,8 @@ struct pwrdm_ops {
 	int	(*pwrdm_set_lowpwrstchange)(struct powerdomain *pwrdm);
 	int	(*pwrdm_wait_transition)(struct powerdomain *pwrdm);
 	int	(*pwrdm_has_voltdm)(void);
+	void	(*pwrdm_save_context)(struct powerdomain *pwrdm);
+	void	(*pwrdm_restore_context)(struct powerdomain *pwrdm);
 };
 
 int pwrdm_register_platform_funcs(struct pwrdm_ops *custom_funcs);
@@ -273,4 +276,8 @@ u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
 extern void pwrdm_lock(struct powerdomain *pwrdm);
 extern void pwrdm_unlock(struct powerdomain *pwrdm);
 
+extern void pwrdms_save_context(void);
+extern void pwrdms_restore_context(void);
+
+extern void pwrdms_lost_power(void);
 #endif
diff --git a/arch/arm/mach-omap2/prm33xx.c b/arch/arm/mach-omap2/prm33xx.c
index ebaf80d..d514166 100644
--- a/arch/arm/mach-omap2/prm33xx.c
+++ b/arch/arm/mach-omap2/prm33xx.c
@@ -342,6 +342,35 @@ static void am33xx_prm_global_warm_sw_reset(void)
 				  AM33XX_PRM_RSTCTRL_OFFSET);
 }
 
+static void am33xx_pwrdm_save_context(struct powerdomain *pwrdm)
+{
+	pwrdm->context = am33xx_prm_read_reg(pwrdm->prcm_offs,
+						pwrdm->pwrstctrl_offs);
+	/*
+	 * Do not save LOWPOWERSTATECHANGE, writing a 1 indicates a request,
+	 * reading back a 1 indicates a request in progress.
+	 */
+	pwrdm->context &= ~AM33XX_LOWPOWERSTATECHANGE_MASK;
+}
+
+static void am33xx_pwrdm_restore_context(struct powerdomain *pwrdm)
+{
+	int st, ctrl;
+
+	st = am33xx_prm_read_reg(pwrdm->prcm_offs,
+				 pwrdm->pwrstst_offs);
+
+	am33xx_prm_write_reg(pwrdm->context, pwrdm->prcm_offs,
+			     pwrdm->pwrstctrl_offs);
+
+	/* Make sure we only wait for a transition if there is one */
+	st &= OMAP_POWERSTATEST_MASK;
+	ctrl = OMAP_POWERSTATEST_MASK & pwrdm->context;
+
+	if (st != ctrl)
+		am33xx_pwrdm_wait_transition(pwrdm);
+}
+
 struct pwrdm_ops am33xx_pwrdm_operations = {
 	.pwrdm_set_next_pwrst		= am33xx_pwrdm_set_next_pwrst,
 	.pwrdm_read_next_pwrst		= am33xx_pwrdm_read_next_pwrst,
@@ -357,6 +386,8 @@ struct pwrdm_ops am33xx_pwrdm_operations = {
 	.pwrdm_set_mem_retst		= am33xx_pwrdm_set_mem_retst,
 	.pwrdm_wait_transition		= am33xx_pwrdm_wait_transition,
 	.pwrdm_has_voltdm		= am33xx_check_vcvp,
+	.pwrdm_save_context		= am33xx_pwrdm_save_context,
+	.pwrdm_restore_context		= am33xx_pwrdm_restore_context,
 };
 
 static struct prm_ll_data am33xx_prm_ll_data = {
diff --git a/arch/arm/mach-omap2/prm44xx.c b/arch/arm/mach-omap2/prm44xx.c
index acb9593..47b657c 100644
--- a/arch/arm/mach-omap2/prm44xx.c
+++ b/arch/arm/mach-omap2/prm44xx.c
@@ -667,6 +667,54 @@ static int omap4_check_vcvp(void)
 	return 0;
 }
 
+/**
+ * omap4_pwrdm_save_context - Saves the powerdomain state
+ * @pwrdm: pointer to individual powerdomain
+ *
+ * The function saves the powerdomain state control information.
+ * This is needed in rtc+ddr modes where we lose powerdomain context.
+ */
+static void omap4_pwrdm_save_context(struct powerdomain *pwrdm)
+{
+	pwrdm->context = omap4_prminst_read_inst_reg(pwrdm->prcm_partition,
+						     pwrdm->prcm_offs,
+						     pwrdm->pwrstctrl_offs);
+
+	/*
+	 * Do not save LOWPOWERSTATECHANGE, writing a 1 indicates a request,
+	 * reading back a 1 indicates a request in progress.
+	 */
+	pwrdm->context &= ~OMAP4430_LOWPOWERSTATECHANGE_MASK;
+}
+
+/**
+ * omap4_pwrdm_restore_context - Restores the powerdomain state
+ * @pwrdm: pointer to individual powerdomain
+ *
+ * The function restores the powerdomain state control information.
+ * This is needed in rtc+ddr modes where we lose powerdomain context.
+ */
+static void omap4_pwrdm_restore_context(struct powerdomain *pwrdm)
+{
+	int st, ctrl;
+
+	st = omap4_prminst_read_inst_reg(pwrdm->prcm_partition,
+					 pwrdm->prcm_offs,
+					 pwrdm->pwrstctrl_offs);
+
+	omap4_prminst_write_inst_reg(pwrdm->context,
+				     pwrdm->prcm_partition,
+				     pwrdm->prcm_offs,
+				     pwrdm->pwrstctrl_offs);
+
+	/* Make sure we only wait for a transition if there is one */
+	st &= OMAP_POWERSTATEST_MASK;
+	ctrl = OMAP_POWERSTATEST_MASK & pwrdm->context;
+
+	if (st != ctrl)
+		omap4_pwrdm_wait_transition(pwrdm);
+}
+
 struct pwrdm_ops omap4_pwrdm_operations = {
 	.pwrdm_set_next_pwrst	= omap4_pwrdm_set_next_pwrst,
 	.pwrdm_read_next_pwrst	= omap4_pwrdm_read_next_pwrst,
@@ -685,6 +733,8 @@ struct pwrdm_ops omap4_pwrdm_operations = {
 	.pwrdm_set_mem_retst	= omap4_pwrdm_set_mem_retst,
 	.pwrdm_wait_transition	= omap4_pwrdm_wait_transition,
 	.pwrdm_has_voltdm	= omap4_check_vcvp,
+	.pwrdm_save_context	= omap4_pwrdm_save_context,
+	.pwrdm_restore_context	= omap4_pwrdm_restore_context,
 };
 
 static int omap44xx_prm_late_init(void);
-- 
1.9.1

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

* [PATCH 3/4] ARM: OMAP2: Add functions to save and restore powerdomain context
@ 2018-05-16 15:17   ` Keerthy
  0 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-16 15:17 UTC (permalink / raw)
  To: linux-arm-kernel

From: Russ Dill <Russ.Dill@ti.com>

The powerdomain control registers are stored in the WKUP powerdomain on
AM33XX/AM43XX, which is lost on RTC-only suspend and also hibernate. This
adds context save and restore functions for those registers.
Sometimes the powerdomain state does not need to change,
perhaps we only need to change memory retention states, so make
sure the restored state is different from the current state before we wait
for a transition.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Russ Dill <Russ.Dill@ti.com>
---
 arch/arm/mach-omap2/powerdomain.c | 60 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.h |  7 +++++
 arch/arm/mach-omap2/prm33xx.c     | 31 ++++++++++++++++++++
 arch/arm/mach-omap2/prm44xx.c     | 50 ++++++++++++++++++++++++++++++++
 4 files changed, 148 insertions(+)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 1e6a967..b97b308 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -1199,3 +1199,63 @@ bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm)
 
 	return 0;
 }
+
+/**
+ * pwrdm_save_context - save powerdomain registers
+ *
+ * Register state is going to be lost due to a suspend or hibernate
+ * event. Save the powerdomain registers.
+ */
+static int pwrdm_save_context(struct powerdomain *pwrdm, void *unused)
+{
+	if (arch_pwrdm && arch_pwrdm->pwrdm_save_context)
+		arch_pwrdm->pwrdm_save_context(pwrdm);
+	return 0;
+}
+
+/**
+ * pwrdm_save_context - restore powerdomain registers
+ *
+ * Restore powerdomain control registers after a suspend or resume
+ * event.
+ */
+static int pwrdm_restore_context(struct powerdomain *pwrdm, void *unused)
+{
+	if (arch_pwrdm && arch_pwrdm->pwrdm_restore_context)
+		arch_pwrdm->pwrdm_restore_context(pwrdm);
+	return 0;
+}
+
+static int pwrdm_lost_power(struct powerdomain *pwrdm, void *unused)
+{
+	int state;
+
+	/*
+	 * Power has been lost across all powerdomains, increment the
+	 * counter.
+	 */
+
+	state = pwrdm_read_pwrst(pwrdm);
+	if (state != PWRDM_POWER_OFF) {
+		pwrdm->state_counter[state]++;
+		pwrdm->state_counter[PWRDM_POWER_OFF]++;
+	}
+	pwrdm->state = state;
+
+	return 0;
+}
+
+void pwrdms_save_context(void)
+{
+	pwrdm_for_each(pwrdm_save_context, NULL);
+}
+
+void pwrdms_restore_context(void)
+{
+	pwrdm_for_each(pwrdm_restore_context, NULL);
+}
+
+void pwrdms_lost_power(void)
+{
+	pwrdm_for_each(pwrdm_lost_power, NULL);
+}
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index 28a796c..9a907fb 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -144,6 +144,7 @@ struct powerdomain {
 	s64 timer;
 	s64 state_timer[PWRDM_MAX_PWRSTS];
 #endif
+	u32 context;
 };
 
 /**
@@ -198,6 +199,8 @@ struct pwrdm_ops {
 	int	(*pwrdm_set_lowpwrstchange)(struct powerdomain *pwrdm);
 	int	(*pwrdm_wait_transition)(struct powerdomain *pwrdm);
 	int	(*pwrdm_has_voltdm)(void);
+	void	(*pwrdm_save_context)(struct powerdomain *pwrdm);
+	void	(*pwrdm_restore_context)(struct powerdomain *pwrdm);
 };
 
 int pwrdm_register_platform_funcs(struct pwrdm_ops *custom_funcs);
@@ -273,4 +276,8 @@ u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
 extern void pwrdm_lock(struct powerdomain *pwrdm);
 extern void pwrdm_unlock(struct powerdomain *pwrdm);
 
+extern void pwrdms_save_context(void);
+extern void pwrdms_restore_context(void);
+
+extern void pwrdms_lost_power(void);
 #endif
diff --git a/arch/arm/mach-omap2/prm33xx.c b/arch/arm/mach-omap2/prm33xx.c
index ebaf80d..d514166 100644
--- a/arch/arm/mach-omap2/prm33xx.c
+++ b/arch/arm/mach-omap2/prm33xx.c
@@ -342,6 +342,35 @@ static void am33xx_prm_global_warm_sw_reset(void)
 				  AM33XX_PRM_RSTCTRL_OFFSET);
 }
 
+static void am33xx_pwrdm_save_context(struct powerdomain *pwrdm)
+{
+	pwrdm->context = am33xx_prm_read_reg(pwrdm->prcm_offs,
+						pwrdm->pwrstctrl_offs);
+	/*
+	 * Do not save LOWPOWERSTATECHANGE, writing a 1 indicates a request,
+	 * reading back a 1 indicates a request in progress.
+	 */
+	pwrdm->context &= ~AM33XX_LOWPOWERSTATECHANGE_MASK;
+}
+
+static void am33xx_pwrdm_restore_context(struct powerdomain *pwrdm)
+{
+	int st, ctrl;
+
+	st = am33xx_prm_read_reg(pwrdm->prcm_offs,
+				 pwrdm->pwrstst_offs);
+
+	am33xx_prm_write_reg(pwrdm->context, pwrdm->prcm_offs,
+			     pwrdm->pwrstctrl_offs);
+
+	/* Make sure we only wait for a transition if there is one */
+	st &= OMAP_POWERSTATEST_MASK;
+	ctrl = OMAP_POWERSTATEST_MASK & pwrdm->context;
+
+	if (st != ctrl)
+		am33xx_pwrdm_wait_transition(pwrdm);
+}
+
 struct pwrdm_ops am33xx_pwrdm_operations = {
 	.pwrdm_set_next_pwrst		= am33xx_pwrdm_set_next_pwrst,
 	.pwrdm_read_next_pwrst		= am33xx_pwrdm_read_next_pwrst,
@@ -357,6 +386,8 @@ struct pwrdm_ops am33xx_pwrdm_operations = {
 	.pwrdm_set_mem_retst		= am33xx_pwrdm_set_mem_retst,
 	.pwrdm_wait_transition		= am33xx_pwrdm_wait_transition,
 	.pwrdm_has_voltdm		= am33xx_check_vcvp,
+	.pwrdm_save_context		= am33xx_pwrdm_save_context,
+	.pwrdm_restore_context		= am33xx_pwrdm_restore_context,
 };
 
 static struct prm_ll_data am33xx_prm_ll_data = {
diff --git a/arch/arm/mach-omap2/prm44xx.c b/arch/arm/mach-omap2/prm44xx.c
index acb9593..47b657c 100644
--- a/arch/arm/mach-omap2/prm44xx.c
+++ b/arch/arm/mach-omap2/prm44xx.c
@@ -667,6 +667,54 @@ static int omap4_check_vcvp(void)
 	return 0;
 }
 
+/**
+ * omap4_pwrdm_save_context - Saves the powerdomain state
+ * @pwrdm: pointer to individual powerdomain
+ *
+ * The function saves the powerdomain state control information.
+ * This is needed in rtc+ddr modes where we lose powerdomain context.
+ */
+static void omap4_pwrdm_save_context(struct powerdomain *pwrdm)
+{
+	pwrdm->context = omap4_prminst_read_inst_reg(pwrdm->prcm_partition,
+						     pwrdm->prcm_offs,
+						     pwrdm->pwrstctrl_offs);
+
+	/*
+	 * Do not save LOWPOWERSTATECHANGE, writing a 1 indicates a request,
+	 * reading back a 1 indicates a request in progress.
+	 */
+	pwrdm->context &= ~OMAP4430_LOWPOWERSTATECHANGE_MASK;
+}
+
+/**
+ * omap4_pwrdm_restore_context - Restores the powerdomain state
+ * @pwrdm: pointer to individual powerdomain
+ *
+ * The function restores the powerdomain state control information.
+ * This is needed in rtc+ddr modes where we lose powerdomain context.
+ */
+static void omap4_pwrdm_restore_context(struct powerdomain *pwrdm)
+{
+	int st, ctrl;
+
+	st = omap4_prminst_read_inst_reg(pwrdm->prcm_partition,
+					 pwrdm->prcm_offs,
+					 pwrdm->pwrstctrl_offs);
+
+	omap4_prminst_write_inst_reg(pwrdm->context,
+				     pwrdm->prcm_partition,
+				     pwrdm->prcm_offs,
+				     pwrdm->pwrstctrl_offs);
+
+	/* Make sure we only wait for a transition if there is one */
+	st &= OMAP_POWERSTATEST_MASK;
+	ctrl = OMAP_POWERSTATEST_MASK & pwrdm->context;
+
+	if (st != ctrl)
+		omap4_pwrdm_wait_transition(pwrdm);
+}
+
 struct pwrdm_ops omap4_pwrdm_operations = {
 	.pwrdm_set_next_pwrst	= omap4_pwrdm_set_next_pwrst,
 	.pwrdm_read_next_pwrst	= omap4_pwrdm_read_next_pwrst,
@@ -685,6 +733,8 @@ struct pwrdm_ops omap4_pwrdm_operations = {
 	.pwrdm_set_mem_retst	= omap4_pwrdm_set_mem_retst,
 	.pwrdm_wait_transition	= omap4_pwrdm_wait_transition,
 	.pwrdm_has_voltdm	= omap4_check_vcvp,
+	.pwrdm_save_context	= omap4_pwrdm_save_context,
+	.pwrdm_restore_context	= omap4_pwrdm_restore_context,
 };
 
 static int omap44xx_prm_late_init(void);
-- 
1.9.1

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

* [PATCH 4/4] omap2: powerdomain: Inroduce cpu_pm notifiers for context save/restore
  2018-05-16 15:16 ` Keerthy
@ 2018-05-16 15:17   ` Keerthy
  -1 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-16 15:17 UTC (permalink / raw)
  To: tony; +Cc: t-kristo, j-keerthy, linux-omap, linux-arm-kernel

Inroduce cpu_pm notifiers for context save/restore. This is
needed for am43xx family during rtc only mode with ddr in
self-refresh.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 arch/arm/mach-omap2/powerdomain.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index b97b308..1a0f69c 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -14,6 +14,7 @@
  */
 #undef DEBUG
 
+#include <linux/cpu_pm.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/list.h>
@@ -39,6 +40,9 @@
 
 #define PWRDM_TRACE_STATES_FLAG	(1<<31)
 
+void pwrdms_save_context(void);
+void pwrdms_restore_context(void);
+
 enum {
 	PWRDM_STATE_NOW = 0,
 	PWRDM_STATE_PREV,
@@ -333,6 +337,22 @@ int pwrdm_register_pwrdms(struct powerdomain **ps)
 	return 0;
 }
 
+static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
+{
+	switch (cmd) {
+	case CPU_CLUSTER_PM_ENTER:
+		if (enable_off_mode)
+			pwrdms_save_context();
+		break;
+	case CPU_CLUSTER_PM_EXIT:
+		if (enable_off_mode)
+			pwrdms_restore_context();
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
 /**
  * pwrdm_complete_init - set up the powerdomain layer
  *
@@ -347,6 +367,7 @@ int pwrdm_register_pwrdms(struct powerdomain **ps)
 int pwrdm_complete_init(void)
 {
 	struct powerdomain *temp_p;
+	static struct notifier_block nb;
 
 	if (list_empty(&pwrdm_list))
 		return -EACCES;
@@ -354,6 +375,12 @@ int pwrdm_complete_init(void)
 	list_for_each_entry(temp_p, &pwrdm_list, node)
 		pwrdm_set_next_pwrst(temp_p, PWRDM_POWER_ON);
 
+	/* Only AM43XX can lose pwrdm context during rtc-ddr suspend */
+	if (soc_is_am43xx()) {
+		nb.notifier_call = cpu_notifier;
+		cpu_pm_register_notifier(&nb);
+	}
+
 	return 0;
 }
 
-- 
1.9.1

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

* [PATCH 4/4] omap2: powerdomain: Inroduce cpu_pm notifiers for context save/restore
@ 2018-05-16 15:17   ` Keerthy
  0 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-16 15:17 UTC (permalink / raw)
  To: linux-arm-kernel

Inroduce cpu_pm notifiers for context save/restore. This is
needed for am43xx family during rtc only mode with ddr in
self-refresh.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 arch/arm/mach-omap2/powerdomain.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index b97b308..1a0f69c 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -14,6 +14,7 @@
  */
 #undef DEBUG
 
+#include <linux/cpu_pm.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/list.h>
@@ -39,6 +40,9 @@
 
 #define PWRDM_TRACE_STATES_FLAG	(1<<31)
 
+void pwrdms_save_context(void);
+void pwrdms_restore_context(void);
+
 enum {
 	PWRDM_STATE_NOW = 0,
 	PWRDM_STATE_PREV,
@@ -333,6 +337,22 @@ int pwrdm_register_pwrdms(struct powerdomain **ps)
 	return 0;
 }
 
+static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
+{
+	switch (cmd) {
+	case CPU_CLUSTER_PM_ENTER:
+		if (enable_off_mode)
+			pwrdms_save_context();
+		break;
+	case CPU_CLUSTER_PM_EXIT:
+		if (enable_off_mode)
+			pwrdms_restore_context();
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
 /**
  * pwrdm_complete_init - set up the powerdomain layer
  *
@@ -347,6 +367,7 @@ int pwrdm_register_pwrdms(struct powerdomain **ps)
 int pwrdm_complete_init(void)
 {
 	struct powerdomain *temp_p;
+	static struct notifier_block nb;
 
 	if (list_empty(&pwrdm_list))
 		return -EACCES;
@@ -354,6 +375,12 @@ int pwrdm_complete_init(void)
 	list_for_each_entry(temp_p, &pwrdm_list, node)
 		pwrdm_set_next_pwrst(temp_p, PWRDM_POWER_ON);
 
+	/* Only AM43XX can lose pwrdm context during rtc-ddr suspend */
+	if (soc_is_am43xx()) {
+		nb.notifier_call = cpu_notifier;
+		cpu_pm_register_notifier(&nb);
+	}
+
 	return 0;
 }
 
-- 
1.9.1

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

* Re: [PATCH 2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
  2018-05-16 15:16   ` Keerthy
@ 2018-05-17 21:43     ` Tony Lindgren
  -1 siblings, 0 replies; 26+ messages in thread
From: Tony Lindgren @ 2018-05-17 21:43 UTC (permalink / raw)
  To: Keerthy; +Cc: t-kristo, linux-omap, linux-arm-kernel

* Keerthy <j-keerthy@ti.com> [180516 15:21]:
> Inroduce cpu_pm notifiers for context save/restore. This will be
> needed for am43xx family in case of rtc only mode with ddr in
> self-refresh.
...
> +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
> +{
> +	switch (cmd) {
> +	case CPU_CLUSTER_PM_ENTER:
> +		if (enable_off_mode)
> +			clkdm_save_context();
> +		break;
> +	case CPU_CLUSTER_PM_EXIT:
> +		if (enable_off_mode)
> +			clkdm_restore_context();
> +		break;
> +	}
> +
> +	return NOTIFY_OK;
> +}

Can you do this too only on suspend instead of the cpu notifier?
If you need to call this eventually from cpuidle also then yeah
the notifier makes sense.

Regards,

Tony

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

* [PATCH 2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
@ 2018-05-17 21:43     ` Tony Lindgren
  0 siblings, 0 replies; 26+ messages in thread
From: Tony Lindgren @ 2018-05-17 21:43 UTC (permalink / raw)
  To: linux-arm-kernel

* Keerthy <j-keerthy@ti.com> [180516 15:21]:
> Inroduce cpu_pm notifiers for context save/restore. This will be
> needed for am43xx family in case of rtc only mode with ddr in
> self-refresh.
...
> +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
> +{
> +	switch (cmd) {
> +	case CPU_CLUSTER_PM_ENTER:
> +		if (enable_off_mode)
> +			clkdm_save_context();
> +		break;
> +	case CPU_CLUSTER_PM_EXIT:
> +		if (enable_off_mode)
> +			clkdm_restore_context();
> +		break;
> +	}
> +
> +	return NOTIFY_OK;
> +}

Can you do this too only on suspend instead of the cpu notifier?
If you need to call this eventually from cpuidle also then yeah
the notifier makes sense.

Regards,

Tony

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

* Re: [PATCH 4/4] omap2: powerdomain: Inroduce cpu_pm notifiers for context save/restore
  2018-05-16 15:17   ` Keerthy
@ 2018-05-17 21:45     ` Tony Lindgren
  -1 siblings, 0 replies; 26+ messages in thread
From: Tony Lindgren @ 2018-05-17 21:45 UTC (permalink / raw)
  To: Keerthy; +Cc: t-kristo, linux-omap, linux-arm-kernel

* Keerthy <j-keerthy@ti.com> [180516 15:21]:
> +	/* Only AM43XX can lose pwrdm context during rtc-ddr suspend */
> +	if (soc_is_am43xx()) {
> +		nb.notifier_call = cpu_notifier;
> +		cpu_pm_register_notifier(&nb);
> +	}
> +

Hmm in patch 3/4 you add omap4_pwrdm_save_context(), I think
that we'd want to run with the notifier for cpuidle on omap4?

Regards,

Tony

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

* [PATCH 4/4] omap2: powerdomain: Inroduce cpu_pm notifiers for context save/restore
@ 2018-05-17 21:45     ` Tony Lindgren
  0 siblings, 0 replies; 26+ messages in thread
From: Tony Lindgren @ 2018-05-17 21:45 UTC (permalink / raw)
  To: linux-arm-kernel

* Keerthy <j-keerthy@ti.com> [180516 15:21]:
> +	/* Only AM43XX can lose pwrdm context during rtc-ddr suspend */
> +	if (soc_is_am43xx()) {
> +		nb.notifier_call = cpu_notifier;
> +		cpu_pm_register_notifier(&nb);
> +	}
> +

Hmm in patch 3/4 you add omap4_pwrdm_save_context(), I think
that we'd want to run with the notifier for cpuidle on omap4?

Regards,

Tony

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

* Re: [PATCH 4/4] omap2: powerdomain: Inroduce cpu_pm notifiers for context save/restore
  2018-05-17 21:45     ` Tony Lindgren
@ 2018-05-18  4:32       ` Keerthy
  -1 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-18  4:32 UTC (permalink / raw)
  To: Tony Lindgren, t-kristo; +Cc: linux-omap, linux-arm-kernel



On Friday 18 May 2018 03:15 AM, Tony Lindgren wrote:
> * Keerthy <j-keerthy@ti.com> [180516 15:21]:
>> +	/* Only AM43XX can lose pwrdm context during rtc-ddr suspend */
>> +	if (soc_is_am43xx()) {
>> +		nb.notifier_call = cpu_notifier;
>> +		cpu_pm_register_notifier(&nb);
>> +	}
>> +
> 
> Hmm in patch 3/4 you add omap4_pwrdm_save_context(), I think
> that we'd want to run with the notifier for cpuidle on omap4?

Okay i believe that is not needed for cpuidle on omap4. PRCM on wakeup
domain so save/restore not needed for powerdomain on omap4.

Tero can confirm the same.

Should i rename omap4_pwrdm_save_context to am43xx_pwrdm_save_context to
avoid confusion?

Regards,
Keerthy

> 
> Regards,
> 
> Tony
> 

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

* [PATCH 4/4] omap2: powerdomain: Inroduce cpu_pm notifiers for context save/restore
@ 2018-05-18  4:32       ` Keerthy
  0 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-18  4:32 UTC (permalink / raw)
  To: linux-arm-kernel



On Friday 18 May 2018 03:15 AM, Tony Lindgren wrote:
> * Keerthy <j-keerthy@ti.com> [180516 15:21]:
>> +	/* Only AM43XX can lose pwrdm context during rtc-ddr suspend */
>> +	if (soc_is_am43xx()) {
>> +		nb.notifier_call = cpu_notifier;
>> +		cpu_pm_register_notifier(&nb);
>> +	}
>> +
> 
> Hmm in patch 3/4 you add omap4_pwrdm_save_context(), I think
> that we'd want to run with the notifier for cpuidle on omap4?

Okay i believe that is not needed for cpuidle on omap4. PRCM on wakeup
domain so save/restore not needed for powerdomain on omap4.

Tero can confirm the same.

Should i rename omap4_pwrdm_save_context to am43xx_pwrdm_save_context to
avoid confusion?

Regards,
Keerthy

> 
> Regards,
> 
> Tony
> 

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

* Re: [PATCH 2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
  2018-05-17 21:43     ` Tony Lindgren
@ 2018-05-18  5:57       ` Keerthy
  -1 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-18  5:57 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: t-kristo, linux-omap, linux-arm-kernel



On Friday 18 May 2018 03:13 AM, Tony Lindgren wrote:
> * Keerthy <j-keerthy@ti.com> [180516 15:21]:
>> Inroduce cpu_pm notifiers for context save/restore. This will be
>> needed for am43xx family in case of rtc only mode with ddr in
>> self-refresh.
> ...
>> +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
>> +{
>> +	switch (cmd) {
>> +	case CPU_CLUSTER_PM_ENTER:
>> +		if (enable_off_mode)
>> +			clkdm_save_context();
>> +		break;
>> +	case CPU_CLUSTER_PM_EXIT:
>> +		if (enable_off_mode)
>> +			clkdm_restore_context();
>> +		break;
>> +	}
>> +
>> +	return NOTIFY_OK;
>> +}
> 
> Can you do this too only on suspend instead of the cpu notifier?
> If you need to call this eventually from cpuidle also then yeah
> the notifier makes sense.

Clockdomain under omap2 does not have suspend/resume calls as its still
not a driver. The initial version of this patch had save/restore calls
directly from pm33xx-core during suspend/resume platform ops are called.

Are you suggesting that?

> 
> Regards,
> 
> Tony
> 

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

* [PATCH 2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
@ 2018-05-18  5:57       ` Keerthy
  0 siblings, 0 replies; 26+ messages in thread
From: Keerthy @ 2018-05-18  5:57 UTC (permalink / raw)
  To: linux-arm-kernel



On Friday 18 May 2018 03:13 AM, Tony Lindgren wrote:
> * Keerthy <j-keerthy@ti.com> [180516 15:21]:
>> Inroduce cpu_pm notifiers for context save/restore. This will be
>> needed for am43xx family in case of rtc only mode with ddr in
>> self-refresh.
> ...
>> +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
>> +{
>> +	switch (cmd) {
>> +	case CPU_CLUSTER_PM_ENTER:
>> +		if (enable_off_mode)
>> +			clkdm_save_context();
>> +		break;
>> +	case CPU_CLUSTER_PM_EXIT:
>> +		if (enable_off_mode)
>> +			clkdm_restore_context();
>> +		break;
>> +	}
>> +
>> +	return NOTIFY_OK;
>> +}
> 
> Can you do this too only on suspend instead of the cpu notifier?
> If you need to call this eventually from cpuidle also then yeah
> the notifier makes sense.

Clockdomain under omap2 does not have suspend/resume calls as its still
not a driver. The initial version of this patch had save/restore calls
directly from pm33xx-core during suspend/resume platform ops are called.

Are you suggesting that?

> 
> Regards,
> 
> Tony
> 

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

* Re: [PATCH 4/4] omap2: powerdomain: Inroduce cpu_pm notifiers for context save/restore
  2018-05-18  4:32       ` Keerthy
@ 2018-05-18  7:00         ` Tero Kristo
  -1 siblings, 0 replies; 26+ messages in thread
From: Tero Kristo @ 2018-05-18  7:00 UTC (permalink / raw)
  To: Keerthy, Tony Lindgren; +Cc: linux-omap, linux-arm-kernel

On 18/05/18 07:32, Keerthy wrote:
> 
> 
> On Friday 18 May 2018 03:15 AM, Tony Lindgren wrote:
>> * Keerthy <j-keerthy@ti.com> [180516 15:21]:
>>> +	/* Only AM43XX can lose pwrdm context during rtc-ddr suspend */
>>> +	if (soc_is_am43xx()) {
>>> +		nb.notifier_call = cpu_notifier;
>>> +		cpu_pm_register_notifier(&nb);
>>> +	}
>>> +
>>
>> Hmm in patch 3/4 you add omap4_pwrdm_save_context(), I think
>> that we'd want to run with the notifier for cpuidle on omap4?
> 
> Okay i believe that is not needed for cpuidle on omap4. PRCM on wakeup
> domain so save/restore not needed for powerdomain on omap4.
> 
> Tero can confirm the same.

Yea I don't believe this is needed. Only certain portions of the OMAP4 
PRCM lose context during device off mode (which is currently not 
supported by linux), and whatever portions do lose, they should use the 
SAR_RAM approach for context save/restore, as that is supported by 
HW/ROM code.

-Tero

> 
> Should i rename omap4_pwrdm_save_context to am43xx_pwrdm_save_context to
> avoid confusion?
> 
> Regards,
> Keerthy
> 
>>
>> Regards,
>>
>> Tony
>>

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH 4/4] omap2: powerdomain: Inroduce cpu_pm notifiers for context save/restore
@ 2018-05-18  7:00         ` Tero Kristo
  0 siblings, 0 replies; 26+ messages in thread
From: Tero Kristo @ 2018-05-18  7:00 UTC (permalink / raw)
  To: linux-arm-kernel

On 18/05/18 07:32, Keerthy wrote:
> 
> 
> On Friday 18 May 2018 03:15 AM, Tony Lindgren wrote:
>> * Keerthy <j-keerthy@ti.com> [180516 15:21]:
>>> +	/* Only AM43XX can lose pwrdm context during rtc-ddr suspend */
>>> +	if (soc_is_am43xx()) {
>>> +		nb.notifier_call = cpu_notifier;
>>> +		cpu_pm_register_notifier(&nb);
>>> +	}
>>> +
>>
>> Hmm in patch 3/4 you add omap4_pwrdm_save_context(), I think
>> that we'd want to run with the notifier for cpuidle on omap4?
> 
> Okay i believe that is not needed for cpuidle on omap4. PRCM on wakeup
> domain so save/restore not needed for powerdomain on omap4.
> 
> Tero can confirm the same.

Yea I don't believe this is needed. Only certain portions of the OMAP4 
PRCM lose context during device off mode (which is currently not 
supported by linux), and whatever portions do lose, they should use the 
SAR_RAM approach for context save/restore, as that is supported by 
HW/ROM code.

-Tero

> 
> Should i rename omap4_pwrdm_save_context to am43xx_pwrdm_save_context to
> avoid confusion?
> 
> Regards,
> Keerthy
> 
>>
>> Regards,
>>
>> Tony
>>

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH 2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
  2018-05-18  5:57       ` Keerthy
@ 2018-05-18  8:38         ` Tero Kristo
  -1 siblings, 0 replies; 26+ messages in thread
From: Tero Kristo @ 2018-05-18  8:38 UTC (permalink / raw)
  To: Keerthy, Tony Lindgren; +Cc: linux-omap, linux-arm-kernel

On 18/05/18 08:57, Keerthy wrote:
> 
> 
> On Friday 18 May 2018 03:13 AM, Tony Lindgren wrote:
>> * Keerthy <j-keerthy@ti.com> [180516 15:21]:
>>> Inroduce cpu_pm notifiers for context save/restore. This will be
>>> needed for am43xx family in case of rtc only mode with ddr in
>>> self-refresh.
>> ...
>>> +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
>>> +{
>>> +	switch (cmd) {
>>> +	case CPU_CLUSTER_PM_ENTER:
>>> +		if (enable_off_mode)
>>> +			clkdm_save_context();
>>> +		break;
>>> +	case CPU_CLUSTER_PM_EXIT:
>>> +		if (enable_off_mode)
>>> +			clkdm_restore_context();
>>> +		break;
>>> +	}
>>> +
>>> +	return NOTIFY_OK;
>>> +}
>>
>> Can you do this too only on suspend instead of the cpu notifier?
>> If you need to call this eventually from cpuidle also then yeah
>> the notifier makes sense.
> 
> Clockdomain under omap2 does not have suspend/resume calls as its still
> not a driver. The initial version of this patch had save/restore calls
> directly from pm33xx-core during suspend/resume platform ops are called.
> 
> Are you suggesting that?

I think using cpu notifiers would help in eventual transition of this 
under drivers also, as this doesn't need any custom interfaces to be 
exported around. And, as it seems now, this is only needed for AM43xx at 
the moment, no other SoCs need this for any purpose, even if device off 
would be implemented. Only exception would be if we want to implement 
RTC+DDR sort of functionality on any other SoC.

-Tero
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH 2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
@ 2018-05-18  8:38         ` Tero Kristo
  0 siblings, 0 replies; 26+ messages in thread
From: Tero Kristo @ 2018-05-18  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

On 18/05/18 08:57, Keerthy wrote:
> 
> 
> On Friday 18 May 2018 03:13 AM, Tony Lindgren wrote:
>> * Keerthy <j-keerthy@ti.com> [180516 15:21]:
>>> Inroduce cpu_pm notifiers for context save/restore. This will be
>>> needed for am43xx family in case of rtc only mode with ddr in
>>> self-refresh.
>> ...
>>> +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
>>> +{
>>> +	switch (cmd) {
>>> +	case CPU_CLUSTER_PM_ENTER:
>>> +		if (enable_off_mode)
>>> +			clkdm_save_context();
>>> +		break;
>>> +	case CPU_CLUSTER_PM_EXIT:
>>> +		if (enable_off_mode)
>>> +			clkdm_restore_context();
>>> +		break;
>>> +	}
>>> +
>>> +	return NOTIFY_OK;
>>> +}
>>
>> Can you do this too only on suspend instead of the cpu notifier?
>> If you need to call this eventually from cpuidle also then yeah
>> the notifier makes sense.
> 
> Clockdomain under omap2 does not have suspend/resume calls as its still
> not a driver. The initial version of this patch had save/restore calls
> directly from pm33xx-core during suspend/resume platform ops are called.
> 
> Are you suggesting that?

I think using cpu notifiers would help in eventual transition of this 
under drivers also, as this doesn't need any custom interfaces to be 
exported around. And, as it seems now, this is only needed for AM43xx at 
the moment, no other SoCs need this for any purpose, even if device off 
would be implemented. Only exception would be if we want to implement 
RTC+DDR sort of functionality on any other SoC.

-Tero
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH 2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
  2018-05-18  8:38         ` Tero Kristo
@ 2018-05-18 13:54           ` Tony Lindgren
  -1 siblings, 0 replies; 26+ messages in thread
From: Tony Lindgren @ 2018-05-18 13:54 UTC (permalink / raw)
  To: Tero Kristo; +Cc: Keerthy, linux-omap, linux-arm-kernel

* Tero Kristo <t-kristo@ti.com> [180518 08:41]:
> On 18/05/18 08:57, Keerthy wrote:
> > 
> > 
> > On Friday 18 May 2018 03:13 AM, Tony Lindgren wrote:
> > > * Keerthy <j-keerthy@ti.com> [180516 15:21]:
> > > > Inroduce cpu_pm notifiers for context save/restore. This will be
> > > > needed for am43xx family in case of rtc only mode with ddr in
> > > > self-refresh.
> > > ...
> > > > +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
> > > > +{
> > > > +	switch (cmd) {
> > > > +	case CPU_CLUSTER_PM_ENTER:
> > > > +		if (enable_off_mode)
> > > > +			clkdm_save_context();
> > > > +		break;
> > > > +	case CPU_CLUSTER_PM_EXIT:
> > > > +		if (enable_off_mode)
> > > > +			clkdm_restore_context();
> > > > +		break;
> > > > +	}
> > > > +
> > > > +	return NOTIFY_OK;
> > > > +}
> > > 
> > > Can you do this too only on suspend instead of the cpu notifier?
> > > If you need to call this eventually from cpuidle also then yeah
> > > the notifier makes sense.
> > 
> > Clockdomain under omap2 does not have suspend/resume calls as its still
> > not a driver. The initial version of this patch had save/restore calls
> > directly from pm33xx-core during suspend/resume platform ops are called.
> > 
> > Are you suggesting that?
> 
> I think using cpu notifiers would help in eventual transition of this under
> drivers also, as this doesn't need any custom interfaces to be exported
> around. And, as it seems now, this is only needed for AM43xx at the moment,
> no other SoCs need this for any purpose, even if device off would be
> implemented. Only exception would be if we want to implement RTC+DDR sort of
> functionality on any other SoC.

OK thanks makes sense. Applying all these into omap-for-v4.18/soc.

Regards,

Tony

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

* [PATCH 2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore
@ 2018-05-18 13:54           ` Tony Lindgren
  0 siblings, 0 replies; 26+ messages in thread
From: Tony Lindgren @ 2018-05-18 13:54 UTC (permalink / raw)
  To: linux-arm-kernel

* Tero Kristo <t-kristo@ti.com> [180518 08:41]:
> On 18/05/18 08:57, Keerthy wrote:
> > 
> > 
> > On Friday 18 May 2018 03:13 AM, Tony Lindgren wrote:
> > > * Keerthy <j-keerthy@ti.com> [180516 15:21]:
> > > > Inroduce cpu_pm notifiers for context save/restore. This will be
> > > > needed for am43xx family in case of rtc only mode with ddr in
> > > > self-refresh.
> > > ...
> > > > +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
> > > > +{
> > > > +	switch (cmd) {
> > > > +	case CPU_CLUSTER_PM_ENTER:
> > > > +		if (enable_off_mode)
> > > > +			clkdm_save_context();
> > > > +		break;
> > > > +	case CPU_CLUSTER_PM_EXIT:
> > > > +		if (enable_off_mode)
> > > > +			clkdm_restore_context();
> > > > +		break;
> > > > +	}
> > > > +
> > > > +	return NOTIFY_OK;
> > > > +}
> > > 
> > > Can you do this too only on suspend instead of the cpu notifier?
> > > If you need to call this eventually from cpuidle also then yeah
> > > the notifier makes sense.
> > 
> > Clockdomain under omap2 does not have suspend/resume calls as its still
> > not a driver. The initial version of this patch had save/restore calls
> > directly from pm33xx-core during suspend/resume platform ops are called.
> > 
> > Are you suggesting that?
> 
> I think using cpu notifiers would help in eventual transition of this under
> drivers also, as this doesn't need any custom interfaces to be exported
> around. And, as it seems now, this is only needed for AM43xx at the moment,
> no other SoCs need this for any purpose, even if device off would be
> implemented. Only exception would be if we want to implement RTC+DDR sort of
> functionality on any other SoC.

OK thanks makes sense. Applying all these into omap-for-v4.18/soc.

Regards,

Tony

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

* Re: [PATCH 4/4] omap2: powerdomain: Inroduce cpu_pm notifiers for context save/restore
  2018-05-18  7:00         ` Tero Kristo
@ 2018-05-18 13:54           ` Tony Lindgren
  -1 siblings, 0 replies; 26+ messages in thread
From: Tony Lindgren @ 2018-05-18 13:54 UTC (permalink / raw)
  To: Tero Kristo; +Cc: Keerthy, linux-omap, linux-arm-kernel

* Tero Kristo <t-kristo@ti.com> [180518 07:02]:
> On 18/05/18 07:32, Keerthy wrote:
> > 
> > 
> > On Friday 18 May 2018 03:15 AM, Tony Lindgren wrote:
> > > * Keerthy <j-keerthy@ti.com> [180516 15:21]:
> > > > +	/* Only AM43XX can lose pwrdm context during rtc-ddr suspend */
> > > > +	if (soc_is_am43xx()) {
> > > > +		nb.notifier_call = cpu_notifier;
> > > > +		cpu_pm_register_notifier(&nb);
> > > > +	}
> > > > +
> > > 
> > > Hmm in patch 3/4 you add omap4_pwrdm_save_context(), I think
> > > that we'd want to run with the notifier for cpuidle on omap4?
> > 
> > Okay i believe that is not needed for cpuidle on omap4. PRCM on wakeup
> > domain so save/restore not needed for powerdomain on omap4.
> > 
> > Tero can confirm the same.
> 
> Yea I don't believe this is needed. Only certain portions of the OMAP4 PRCM
> lose context during device off mode (which is currently not supported by
> linux), and whatever portions do lose, they should use the SAR_RAM approach
> for context save/restore, as that is supported by HW/ROM code.

OK

> > Should i rename omap4_pwrdm_save_context to am43xx_pwrdm_save_context to
> > avoid confusion?

No need to, it follows the naming prm44xx.c.

Regards,

Tony

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

* [PATCH 4/4] omap2: powerdomain: Inroduce cpu_pm notifiers for context save/restore
@ 2018-05-18 13:54           ` Tony Lindgren
  0 siblings, 0 replies; 26+ messages in thread
From: Tony Lindgren @ 2018-05-18 13:54 UTC (permalink / raw)
  To: linux-arm-kernel

* Tero Kristo <t-kristo@ti.com> [180518 07:02]:
> On 18/05/18 07:32, Keerthy wrote:
> > 
> > 
> > On Friday 18 May 2018 03:15 AM, Tony Lindgren wrote:
> > > * Keerthy <j-keerthy@ti.com> [180516 15:21]:
> > > > +	/* Only AM43XX can lose pwrdm context during rtc-ddr suspend */
> > > > +	if (soc_is_am43xx()) {
> > > > +		nb.notifier_call = cpu_notifier;
> > > > +		cpu_pm_register_notifier(&nb);
> > > > +	}
> > > > +
> > > 
> > > Hmm in patch 3/4 you add omap4_pwrdm_save_context(), I think
> > > that we'd want to run with the notifier for cpuidle on omap4?
> > 
> > Okay i believe that is not needed for cpuidle on omap4. PRCM on wakeup
> > domain so save/restore not needed for powerdomain on omap4.
> > 
> > Tero can confirm the same.
> 
> Yea I don't believe this is needed. Only certain portions of the OMAP4 PRCM
> lose context during device off mode (which is currently not supported by
> linux), and whatever portions do lose, they should use the SAR_RAM approach
> for context save/restore, as that is supported by HW/ROM code.

OK

> > Should i rename omap4_pwrdm_save_context to am43xx_pwrdm_save_context to
> > avoid confusion?

No need to, it follows the naming prm44xx.c.

Regards,

Tony

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

end of thread, other threads:[~2018-05-18 13:54 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-16 15:16 [PATCH 0/4] arm: mach-omap2: clkdm/pwrdm: Save/restore context Keerthy
2018-05-16 15:16 ` Keerthy
2018-05-16 15:16 ` [PATCH 1/4] ARM: OMAP2: Add functions to save and restore clockdomain context en-masse Keerthy
2018-05-16 15:16   ` Keerthy
2018-05-16 15:16 ` [PATCH 2/4] omap2: clockdomain: Inroduce cpu_pm notifiers for context save/restore Keerthy
2018-05-16 15:16   ` Keerthy
2018-05-17 21:43   ` Tony Lindgren
2018-05-17 21:43     ` Tony Lindgren
2018-05-18  5:57     ` Keerthy
2018-05-18  5:57       ` Keerthy
2018-05-18  8:38       ` Tero Kristo
2018-05-18  8:38         ` Tero Kristo
2018-05-18 13:54         ` Tony Lindgren
2018-05-18 13:54           ` Tony Lindgren
2018-05-16 15:17 ` [PATCH 3/4] ARM: OMAP2: Add functions to save and restore powerdomain context Keerthy
2018-05-16 15:17   ` Keerthy
2018-05-16 15:17 ` [PATCH 4/4] omap2: powerdomain: Inroduce cpu_pm notifiers for context save/restore Keerthy
2018-05-16 15:17   ` Keerthy
2018-05-17 21:45   ` Tony Lindgren
2018-05-17 21:45     ` Tony Lindgren
2018-05-18  4:32     ` Keerthy
2018-05-18  4:32       ` Keerthy
2018-05-18  7:00       ` Tero Kristo
2018-05-18  7:00         ` Tero Kristo
2018-05-18 13:54         ` Tony Lindgren
2018-05-18 13:54           ` Tony Lindgren

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.