linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v1] ARM: tango: add Suspend-to-RAM support
@ 2016-06-29 13:58 Marc Gonzalez
  2016-06-29 17:48 ` Sudeep Holla
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Gonzalez @ 2016-06-29 13:58 UTC (permalink / raw)
  To: linux-pm, Linux ARM
  Cc: Mark Rutland, Thomas Petazzoni, Kevin Hilman, Thibaud Cornic,
	Mason, Sebastian Frias, Robin Murphy

Ask firmware to put RAM in self-refresh mode and power system down.

    echo mem > /sys/power/state

See Documentation/power/states.txt

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
---
This is a RFC because I have a few doubts:
1) return value when tango_suspend() fails and unexpectedly returns (I used -EIO)
2) conditionally building pm.c (using CONFIG_SUSPEND? CONFIG_PM_SLEEP? other?)
3) .valid is required, right?
---
 arch/arm/mach-tango/Makefile |  1 +
 arch/arm/mach-tango/pm.c     | 37 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-tango/smc.h    |  1 +
 3 files changed, 39 insertions(+)
 create mode 100644 arch/arm/mach-tango/pm.c

diff --git a/arch/arm/mach-tango/Makefile b/arch/arm/mach-tango/Makefile
index 7ca753aa9fb6..822b7ca803c6 100644
--- a/arch/arm/mach-tango/Makefile
+++ b/arch/arm/mach-tango/Makefile
@@ -3,3 +3,4 @@ AFLAGS_smc.o := -Wa,-march=armv7-a$(plus_sec)
 
 obj-y += setup.o smc.o xenv.o
 obj-$(CONFIG_SMP) += platsmp.o
+obj-$(CONFIG_SUSPEND) += pm.o
diff --git a/arch/arm/mach-tango/pm.c b/arch/arm/mach-tango/pm.c
new file mode 100644
index 000000000000..08a39beaea09
--- /dev/null
+++ b/arch/arm/mach-tango/pm.c
@@ -0,0 +1,37 @@
+#include <linux/init.h>
+#include <linux/suspend.h>
+#include <asm/suspend.h>
+#include "smc.h"
+
+static int tango_pm_powerdown(unsigned long arg)
+{
+	tango_suspend(virt_to_phys(cpu_resume));
+
+	return -EIO; /* tango_suspend has failed */
+}
+
+static int tango_pm_enter(suspend_state_t state)
+{
+	if (state == PM_SUSPEND_MEM)
+		return cpu_suspend(0, tango_pm_powerdown);
+
+	return -EINVAL;
+}
+
+static int tango_pm_valid(suspend_state_t state)
+{
+	return state == PM_SUSPEND_MEM;
+}
+
+static const struct platform_suspend_ops tango_pm_ops = {
+	.enter = tango_pm_enter,
+	.valid = tango_pm_valid,
+};
+
+static int __init tango_pm_init(void)
+{
+	suspend_set_ops(&tango_pm_ops);
+	return 0;
+}
+
+late_initcall(tango_pm_init);
diff --git a/arch/arm/mach-tango/smc.h b/arch/arm/mach-tango/smc.h
index 3d31f984f44c..57919539da1b 100644
--- a/arch/arm/mach-tango/smc.h
+++ b/arch/arm/mach-tango/smc.h
@@ -3,5 +3,6 @@ extern int tango_smc(unsigned int val, unsigned int service);
 #define tango_set_l2_control(val)	tango_smc(val, 0x102)
 #define tango_start_aux_core(val)	tango_smc(val, 0x104)
 #define tango_set_aux_boot_addr(val)	tango_smc(val, 0x105)
+#define tango_suspend(val)		tango_smc(val, 0x120)
 #define tango_aux_core_die(val)		tango_smc(val, 0x121)
 #define tango_aux_core_kill(val)	tango_smc(val, 0x122)
-- 
2.9.0

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

* Re: [RFC PATCH v1] ARM: tango: add Suspend-to-RAM support
  2016-06-29 13:58 [RFC PATCH v1] ARM: tango: add Suspend-to-RAM support Marc Gonzalez
@ 2016-06-29 17:48 ` Sudeep Holla
  2016-06-30  8:44   ` [RFC PATCH v2] " Marc Gonzalez
  0 siblings, 1 reply; 6+ messages in thread
From: Sudeep Holla @ 2016-06-29 17:48 UTC (permalink / raw)
  To: Marc Gonzalez, linux-pm, Linux ARM
  Cc: Sudeep Holla, Mark Rutland, Thomas Petazzoni, Kevin Hilman,
	Thibaud Cornic, Mason, Sebastian Frias, Robin Murphy



On 29/06/16 14:58, Marc Gonzalez wrote:
> Ask firmware to put RAM in self-refresh mode and power system down.
>
>      echo mem > /sys/power/state
>
> See Documentation/power/states.txt
>
> Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
> ---
> This is a RFC because I have a few doubts:
> 1) return value when tango_suspend() fails and unexpectedly returns (I used -EIO)
> 2) conditionally building pm.c (using CONFIG_SUSPEND? CONFIG_PM_SLEEP? other?)
> 3) .valid is required, right?
> ---
>   arch/arm/mach-tango/Makefile |  1 +
>   arch/arm/mach-tango/pm.c     | 37 +++++++++++++++++++++++++++++++++++++
>   arch/arm/mach-tango/smc.h    |  1 +
>   3 files changed, 39 insertions(+)
>   create mode 100644 arch/arm/mach-tango/pm.c
>
> diff --git a/arch/arm/mach-tango/Makefile b/arch/arm/mach-tango/Makefile
> index 7ca753aa9fb6..822b7ca803c6 100644
> --- a/arch/arm/mach-tango/Makefile
> +++ b/arch/arm/mach-tango/Makefile
> @@ -3,3 +3,4 @@ AFLAGS_smc.o := -Wa,-march=armv7-a$(plus_sec)
>
>   obj-y += setup.o smc.o xenv.o
>   obj-$(CONFIG_SMP) += platsmp.o
> +obj-$(CONFIG_SUSPEND) += pm.o
> diff --git a/arch/arm/mach-tango/pm.c b/arch/arm/mach-tango/pm.c
> new file mode 100644
> index 000000000000..08a39beaea09
> --- /dev/null
> +++ b/arch/arm/mach-tango/pm.c
> @@ -0,0 +1,37 @@
> +#include <linux/init.h>
> +#include <linux/suspend.h>
> +#include <asm/suspend.h>
> +#include "smc.h"
> +
> +static int tango_pm_powerdown(unsigned long arg)
> +{
> +	tango_suspend(virt_to_phys(cpu_resume));
> +
> +	return -EIO; /* tango_suspend has failed */
> +}
> +
> +static int tango_pm_enter(suspend_state_t state)
> +{
> +	if (state == PM_SUSPEND_MEM)
> +		return cpu_suspend(0, tango_pm_powerdown);
> +
> +	return -EINVAL;
> +}
> +
> +static int tango_pm_valid(suspend_state_t state)
> +{
> +	return state == PM_SUSPEND_MEM;
> +}
> +
> +static const struct platform_suspend_ops tango_pm_ops = {
> +	.enter = tango_pm_enter,
> +	.valid = tango_pm_valid,

You can use suspend_valid_only_mem instead which does exactly same thing.

-- 
Regards,
Sudeep

-- 
Regards,
Sudeep

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

* [RFC PATCH v2] ARM: tango: add Suspend-to-RAM support
  2016-06-29 17:48 ` Sudeep Holla
@ 2016-06-30  8:44   ` Marc Gonzalez
  2016-07-04  9:01     ` Marc Gonzalez
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Gonzalez @ 2016-06-30  8:44 UTC (permalink / raw)
  To: Sudeep Holla, linux-pm, Linux ARM
  Cc: Mark Rutland, Thomas Petazzoni, Kevin Hilman, Thibaud Cornic,
	Mason, Sebastian Frias, Robin Murphy

Ask firmware to put RAM in self-refresh mode and power system down.

    echo mem > /sys/power/state

See Documentation/power/states.txt

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
---

This is a RFC because I have a few doubts:

1) return value when tango_suspend() fails and unexpectedly returns (I used -EIO)
Is there a better error to return?

2) conditionally building pm.c (using CONFIG_SUSPEND? CONFIG_PM_SLEEP? other?)
Is there a better config knob to use?

3) .valid is required, right?
AFAICS, the answer is "yes", .valid is indeed required:
("no valid callback implies that none are valid")

static bool valid_state(suspend_state_t state)
{
	/*
	 * PM_SUSPEND_STANDBY and PM_SUSPEND_MEM states need low level
	 * support and need to be valid to the low level
	 * implementation, no valid callback implies that none are valid.
	 */
	return suspend_ops && suspend_ops->valid && suspend_ops->valid(state);
}

---
 arch/arm/mach-tango/Makefile |  1 +
 arch/arm/mach-tango/pm.c     | 32 ++++++++++++++++++++++++++++++++
 arch/arm/mach-tango/smc.h    |  1 +
 3 files changed, 34 insertions(+)
 create mode 100644 arch/arm/mach-tango/pm.c

diff --git a/arch/arm/mach-tango/Makefile b/arch/arm/mach-tango/Makefile
index 7ca753aa9fb6..822b7ca803c6 100644
--- a/arch/arm/mach-tango/Makefile
+++ b/arch/arm/mach-tango/Makefile
@@ -3,3 +3,4 @@ AFLAGS_smc.o := -Wa,-march=armv7-a$(plus_sec)
 
 obj-y += setup.o smc.o xenv.o
 obj-$(CONFIG_SMP) += platsmp.o
+obj-$(CONFIG_SUSPEND) += pm.o
diff --git a/arch/arm/mach-tango/pm.c b/arch/arm/mach-tango/pm.c
new file mode 100644
index 000000000000..b05c6d6f99d0
--- /dev/null
+++ b/arch/arm/mach-tango/pm.c
@@ -0,0 +1,32 @@
+#include <linux/init.h>
+#include <linux/suspend.h>
+#include <asm/suspend.h>
+#include "smc.h"
+
+static int tango_pm_powerdown(unsigned long arg)
+{
+	tango_suspend(virt_to_phys(cpu_resume));
+
+	return -EIO; /* tango_suspend has failed */
+}
+
+static int tango_pm_enter(suspend_state_t state)
+{
+	if (state == PM_SUSPEND_MEM)
+		return cpu_suspend(0, tango_pm_powerdown);
+
+	return -EINVAL;
+}
+
+static const struct platform_suspend_ops tango_pm_ops = {
+	.enter = tango_pm_enter,
+	.valid = suspend_valid_only_mem,
+};
+
+static int __init tango_pm_init(void)
+{
+	suspend_set_ops(&tango_pm_ops);
+	return 0;
+}
+
+late_initcall(tango_pm_init);
diff --git a/arch/arm/mach-tango/smc.h b/arch/arm/mach-tango/smc.h
index 3d31f984f44c..57919539da1b 100644
--- a/arch/arm/mach-tango/smc.h
+++ b/arch/arm/mach-tango/smc.h
@@ -3,5 +3,6 @@ extern int tango_smc(unsigned int val, unsigned int service);
 #define tango_set_l2_control(val)	tango_smc(val, 0x102)
 #define tango_start_aux_core(val)	tango_smc(val, 0x104)
 #define tango_set_aux_boot_addr(val)	tango_smc(val, 0x105)
+#define tango_suspend(val)		tango_smc(val, 0x120)
 #define tango_aux_core_die(val)		tango_smc(val, 0x121)
 #define tango_aux_core_kill(val)	tango_smc(val, 0x122)
-- 
2.9.0

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

* Re: [RFC PATCH v2] ARM: tango: add Suspend-to-RAM support
  2016-06-30  8:44   ` [RFC PATCH v2] " Marc Gonzalez
@ 2016-07-04  9:01     ` Marc Gonzalez
  2016-07-07 13:08       ` [PATCH v3] " Marc Gonzalez
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Gonzalez @ 2016-07-04  9:01 UTC (permalink / raw)
  To: linux-pm, Linux ARM
  Cc: Sudeep Holla, Mark Rutland, Kevin Hilman, Thibaud Cornic, Mason,
	Sebastian Frias, Robin Murphy, Arnd Bergmann

On 30/06/2016 10:44, Marc Gonzalez wrote:

> Ask firmware to put RAM in self-refresh mode and power system down.
> 
>     echo mem > /sys/power/state
> 
> See Documentation/power/states.txt
> 
> Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
> ---
> 
> This is a RFC because I have a few doubts:
> 
> 1) return value when tango_suspend() fails and unexpectedly returns (I used -EIO)
> Is there a better error to return?
> 
> 2) conditionally building pm.c (using CONFIG_SUSPEND? CONFIG_PM_SLEEP? other?)
> Is there a better config knob to use?
> 
> 3) .valid is required, right?
> AFAICS, the answer is "yes", .valid is indeed required:
> ("no valid callback implies that none are valid")
> 
> static bool valid_state(suspend_state_t state)
> {
> 	/*
> 	 * PM_SUSPEND_STANDBY and PM_SUSPEND_MEM states need low level
> 	 * support and need to be valid to the low level
> 	 * implementation, no valid callback implies that none are valid.
> 	 */
> 	return suspend_ops && suspend_ops->valid && suspend_ops->valid(state);
> }
> 
> ---
>  arch/arm/mach-tango/Makefile |  1 +
>  arch/arm/mach-tango/pm.c     | 32 ++++++++++++++++++++++++++++++++
>  arch/arm/mach-tango/smc.h    |  1 +
>  3 files changed, 34 insertions(+)
>  create mode 100644 arch/arm/mach-tango/pm.c
> 
> diff --git a/arch/arm/mach-tango/Makefile b/arch/arm/mach-tango/Makefile
> index 7ca753aa9fb6..822b7ca803c6 100644
> --- a/arch/arm/mach-tango/Makefile
> +++ b/arch/arm/mach-tango/Makefile
> @@ -3,3 +3,4 @@ AFLAGS_smc.o := -Wa,-march=armv7-a$(plus_sec)
>  
>  obj-y += setup.o smc.o xenv.o
>  obj-$(CONFIG_SMP) += platsmp.o
> +obj-$(CONFIG_SUSPEND) += pm.o
> diff --git a/arch/arm/mach-tango/pm.c b/arch/arm/mach-tango/pm.c
> new file mode 100644
> index 000000000000..b05c6d6f99d0
> --- /dev/null
> +++ b/arch/arm/mach-tango/pm.c
> @@ -0,0 +1,32 @@
> +#include <linux/init.h>
> +#include <linux/suspend.h>
> +#include <asm/suspend.h>
> +#include "smc.h"
> +
> +static int tango_pm_powerdown(unsigned long arg)
> +{
> +	tango_suspend(virt_to_phys(cpu_resume));
> +
> +	return -EIO; /* tango_suspend has failed */
> +}
> +
> +static int tango_pm_enter(suspend_state_t state)
> +{
> +	if (state == PM_SUSPEND_MEM)
> +		return cpu_suspend(0, tango_pm_powerdown);
> +
> +	return -EINVAL;
> +}
> +
> +static const struct platform_suspend_ops tango_pm_ops = {
> +	.enter = tango_pm_enter,
> +	.valid = suspend_valid_only_mem,
> +};
> +
> +static int __init tango_pm_init(void)
> +{
> +	suspend_set_ops(&tango_pm_ops);
> +	return 0;
> +}
> +
> +late_initcall(tango_pm_init);
> diff --git a/arch/arm/mach-tango/smc.h b/arch/arm/mach-tango/smc.h
> index 3d31f984f44c..57919539da1b 100644
> --- a/arch/arm/mach-tango/smc.h
> +++ b/arch/arm/mach-tango/smc.h
> @@ -3,5 +3,6 @@ extern int tango_smc(unsigned int val, unsigned int service);
>  #define tango_set_l2_control(val)	tango_smc(val, 0x102)
>  #define tango_start_aux_core(val)	tango_smc(val, 0x104)
>  #define tango_set_aux_boot_addr(val)	tango_smc(val, 0x105)
> +#define tango_suspend(val)		tango_smc(val, 0x120)
>  #define tango_aux_core_die(val)		tango_smc(val, 0x121)
>  #define tango_aux_core_kill(val)	tango_smc(val, 0x122)
> 

Hello everyone,

I'll wait a few more days for comments, then I'll submit the patch
to arm-soc for inclusion in v4.8 (if no issues are raised).

(I suppose the return value for tango_pm_powerdown() is not that
big a deal.)

Regards.


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

* [PATCH v3] ARM: tango: add Suspend-to-RAM support
  2016-07-04  9:01     ` Marc Gonzalez
@ 2016-07-07 13:08       ` Marc Gonzalez
  2016-07-07 14:01         ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Gonzalez @ 2016-07-07 13:08 UTC (permalink / raw)
  To: Olof Johansson, arm-soc
  Cc: linux-pm, Linux ARM, Sudeep Holla, Mark Rutland, Kevin Hilman,
	Thibaud Cornic, Mason, Sebastian Frias, Robin Murphy,
	Arnd Bergmann

Ask firmware to put RAM in self-refresh mode and power system down.

    echo mem > /sys/power/state

See Documentation/power/states.txt

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
---
v3 is identical to v2 minus the RFC tag
Olof, if still possible, please merge for v4.8
---
 arch/arm/mach-tango/Makefile |  1 +
 arch/arm/mach-tango/pm.c     | 32 ++++++++++++++++++++++++++++++++
 arch/arm/mach-tango/smc.h    |  1 +
 3 files changed, 34 insertions(+)
 create mode 100644 arch/arm/mach-tango/pm.c

diff --git a/arch/arm/mach-tango/Makefile b/arch/arm/mach-tango/Makefile
index 7ca753aa9fb6..822b7ca803c6 100644
--- a/arch/arm/mach-tango/Makefile
+++ b/arch/arm/mach-tango/Makefile
@@ -3,3 +3,4 @@ AFLAGS_smc.o := -Wa,-march=armv7-a$(plus_sec)
 
 obj-y += setup.o smc.o xenv.o
 obj-$(CONFIG_SMP) += platsmp.o
+obj-$(CONFIG_SUSPEND) += pm.o
diff --git a/arch/arm/mach-tango/pm.c b/arch/arm/mach-tango/pm.c
new file mode 100644
index 000000000000..b05c6d6f99d0
--- /dev/null
+++ b/arch/arm/mach-tango/pm.c
@@ -0,0 +1,32 @@
+#include <linux/init.h>
+#include <linux/suspend.h>
+#include <asm/suspend.h>
+#include "smc.h"
+
+static int tango_pm_powerdown(unsigned long arg)
+{
+	tango_suspend(virt_to_phys(cpu_resume));
+
+	return -EIO; /* tango_suspend has failed */
+}
+
+static int tango_pm_enter(suspend_state_t state)
+{
+	if (state == PM_SUSPEND_MEM)
+		return cpu_suspend(0, tango_pm_powerdown);
+
+	return -EINVAL;
+}
+
+static const struct platform_suspend_ops tango_pm_ops = {
+	.enter = tango_pm_enter,
+	.valid = suspend_valid_only_mem,
+};
+
+static int __init tango_pm_init(void)
+{
+	suspend_set_ops(&tango_pm_ops);
+	return 0;
+}
+
+late_initcall(tango_pm_init);
diff --git a/arch/arm/mach-tango/smc.h b/arch/arm/mach-tango/smc.h
index 3d31f984f44c..57919539da1b 100644
--- a/arch/arm/mach-tango/smc.h
+++ b/arch/arm/mach-tango/smc.h
@@ -3,5 +3,6 @@ extern int tango_smc(unsigned int val, unsigned int service);
 #define tango_set_l2_control(val)	tango_smc(val, 0x102)
 #define tango_start_aux_core(val)	tango_smc(val, 0x104)
 #define tango_set_aux_boot_addr(val)	tango_smc(val, 0x105)
+#define tango_suspend(val)		tango_smc(val, 0x120)
 #define tango_aux_core_die(val)		tango_smc(val, 0x121)
 #define tango_aux_core_kill(val)	tango_smc(val, 0x122)
-- 
2.9.0

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

* Re: [PATCH v3] ARM: tango: add Suspend-to-RAM support
  2016-07-07 13:08       ` [PATCH v3] " Marc Gonzalez
@ 2016-07-07 14:01         ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-07-07 14:01 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Marc Gonzalez, Olof Johansson, arm-soc, Mark Rutland,
	Sebastian Frias, Kevin Hilman, Thibaud Cornic, linux-pm, Mason,
	Sudeep Holla, Robin Murphy

On Thursday, July 7, 2016 3:08:14 PM CEST Marc Gonzalez wrote:
> Ask firmware to put RAM in self-refresh mode and power system down.
> 
>     echo mem > /sys/power/state
> 
> See Documentation/power/states.txt
> 
> Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
> ---
> v3 is identical to v2 minus the RFC tag
> Olof, if still possible, please merge for v4.8

Applied to next/soc, thanks!

	Arnd


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

end of thread, other threads:[~2016-07-07 13:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-29 13:58 [RFC PATCH v1] ARM: tango: add Suspend-to-RAM support Marc Gonzalez
2016-06-29 17:48 ` Sudeep Holla
2016-06-30  8:44   ` [RFC PATCH v2] " Marc Gonzalez
2016-07-04  9:01     ` Marc Gonzalez
2016-07-07 13:08       ` [PATCH v3] " Marc Gonzalez
2016-07-07 14:01         ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).