Skip to contentSkip to conversation

Kirkwood standby

PATCH New Ezequiel Garcia 3 participants 15 messages Aug 22, 2013 – Oct 2, 2013

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

v3 cover Kirkwood standby

This patchset implements a very basic suspend/resume support on Kirkwood SoC's, based on the work of Simon Guinot.

Given the CPU itself is not stopped on suspend, but just sits waiting for interruption, this is more similar to a standby-mode, than to a real suspend-to-RAM. Therefore, I've chosen to use the 'standby' power state.

The first patch implements suspend/resume procedures in Feroceon CPU and it's already applied in Russell's. I'm only adding it here for series consistency.

The second patch implements the 'standby' state by disabling SoC memory units and put the CPU in idle state. Additional power savings must be enhanced on each driver by implementing proper suspend/resume support.

This is based in v3.11-rc6 and tested on Openblocks A6.

By simple instrumentation I found (see the table below) that this 'standby' state has *no power savings* compared to a CPUIdle-enabled platform. Therefore, it's not clear to me the real advantage of this support.

However, and hopefully, by implementing proper suspend/resume in relevant peripherals, the power savings of the standby might get improved.

CONFIG_CPU_IDLE=y
State Current (mA)
------------------------------

Normal (system idle)   360
Normal (system busy    440
Standby                360

!CONFIG_CPU_IDLE
State Current (mA)
------------------------------

Normal (system idle)   440
Normal (system busy    440
Standby                360

(The above are sketchy measurements but useful to compare CPUIdle vs. Standby)

Changes from v2:

* In order to remain multiplatform-ready, I reworked the kirkwood_pm_init by having it explicitly called from mach-kirkwood/. Requested by Andrew Lunn.

Changes from v1:

* Removed clock gating. Each peripheral is in charge of implementing a proper suspend/resume path, including gateable clock handling.

Ezequiel Garcia (2):
ARM: feroceon: Add suspend/resume operation
ARM: kirkwood: Add standby support

 arch/arm/Kconfig                                  |  2 +-
 arch/arm/mach-kirkwood/Makefile                   |  2 +
 arch/arm/mach-kirkwood/board-dt.c                 |  1 +
 arch/arm/mach-kirkwood/common.c                   |  1 +
 arch/arm/mach-kirkwood/common.h                   |  6 ++
 arch/arm/mach-kirkwood/include/mach/bridge-regs.h |  2 +
 arch/arm/mach-kirkwood/pm.c                       | 73 +++++++++++++++++++++++
 arch/arm/mm/proc-feroceon.S                       | 26 ++++++++
 8 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-kirkwood/pm.c
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH v3 1/2 ARM: feroceon: Add suspend/resume operation

Add support for suspend/resume operations. The implemented procedures are identical to the ones for ARM926.

---
 arch/arm/Kconfig            |  2 +-
 arch/arm/mm/proc-feroceon.S | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
index 43594d5..a5111ec 100644
@@ -2199,7 +2199,7 @@ source "kernel/power/Kconfig"
 
 config ARCH_SUSPEND_POSSIBLE
 	depends on !ARCH_S5PC100
-	depends on CPU_ARM920T || CPU_ARM926T || CPU_SA1100 || \
+	depends on CPU_ARM920T || CPU_ARM926T || CPU_FEROCEON || CPU_SA1100 || \
 		CPU_V6 || CPU_V6K || CPU_V7 || CPU_XSC3 || CPU_XSCALE || CPU_MOHAWK
 	def_bool y
 
arch/arm/mm/proc-feroceon.S +26 -0
index d5146b9..db79b62 100644
@@ -514,6 +514,32 @@ ENTRY(cpu_feroceon_set_pte_ext)
 #endif
 	mov	pc, lr
 
+/* Suspend/resume support: taken from arch/arm/mm/proc-arm926.S */
+.globl	cpu_feroceon_suspend_size
+.equ	cpu_feroceon_suspend_size, 4 * 3
+#ifdef CONFIG_ARM_CPU_SUSPEND
+ENTRY(cpu_feroceon_do_suspend)
+	stmfd	sp!, {r4 - r6, lr}
+	mrc	p15, 0, r4, c13, c0, 0	@ PID
+	mrc	p15, 0, r5, c3, c0, 0	@ Domain ID
+	mrc	p15, 0, r6, c1, c0, 0	@ Control register
+	stmia	r0, {r4 - r6}
+	ldmfd	sp!, {r4 - r6, pc}
+ENDPROC(cpu_feroceon_do_suspend)
+
+ENTRY(cpu_feroceon_do_resume)
+	mov	ip, #0
+	mcr	p15, 0, ip, c8, c7, 0	@ invalidate I+D TLBs
+	mcr	p15, 0, ip, c7, c7, 0	@ invalidate I+D caches
+	ldmia	r0, {r4 - r6}
+	mcr	p15, 0, r4, c13, c0, 0	@ PID
+	mcr	p15, 0, r5, c3, c0, 0	@ Domain ID
+	mcr	p15, 0, r1, c2, c0, 0	@ TTB address
+	mov	r0, r6			@ control register
+	b	cpu_resume_mmu
+ENDPROC(cpu_feroceon_do_resume)
+#endif
+
 	.type	__feroceon_setup, #function
 __feroceon_setup:
 	mov	r0, #0
Signature · 1 line
1.8.1.5
#2 lore raw

PATCH v3 1/2 ARM: feroceon: Add suspend/resume operation

+rmk

Quoted 8 lines · Ezequiel Garcia

Add support for suspend/resume operations. The implemented procedures are identical to the ones for ARM926.

---
 arch/arm/Kconfig            |  2 +-
 arch/arm/mm/proc-feroceon.S | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

Russell,

This is pretty isolated, and the next patch in the series depends on it for building (it's changes are all in mach-kirkwood/). Should Ezequiel push this into your patch tracker (and then could you create a public, non-rebasable branch containing it?), or can I take it with your Ack?

thx,

Jason.

Quoted 58 lines
arch/arm/Kconfig +1 -1
index 43594d5..a5111ec 100644
@@ -2199,7 +2199,7 @@ source "kernel/power/Kconfig"
 
 config ARCH_SUSPEND_POSSIBLE
 	depends on !ARCH_S5PC100
-	depends on CPU_ARM920T || CPU_ARM926T || CPU_SA1100 || \
+	depends on CPU_ARM920T || CPU_ARM926T || CPU_FEROCEON || CPU_SA1100 || \
 		CPU_V6 || CPU_V6K || CPU_V7 || CPU_XSC3 || CPU_XSCALE || CPU_MOHAWK
 	def_bool y
 
arch/arm/mm/proc-feroceon.S +26 -0
index d5146b9..db79b62 100644
@@ -514,6 +514,32 @@ ENTRY(cpu_feroceon_set_pte_ext)
 #endif
 	mov	pc, lr
 
+/* Suspend/resume support: taken from arch/arm/mm/proc-arm926.S */
+.globl	cpu_feroceon_suspend_size
+.equ	cpu_feroceon_suspend_size, 4 * 3
+#ifdef CONFIG_ARM_CPU_SUSPEND
+ENTRY(cpu_feroceon_do_suspend)
+	stmfd	sp!, {r4 - r6, lr}
+	mrc	p15, 0, r4, c13, c0, 0	@ PID
+	mrc	p15, 0, r5, c3, c0, 0	@ Domain ID
+	mrc	p15, 0, r6, c1, c0, 0	@ Control register
+	stmia	r0, {r4 - r6}
+	ldmfd	sp!, {r4 - r6, pc}
+ENDPROC(cpu_feroceon_do_suspend)
+
+ENTRY(cpu_feroceon_do_resume)
+	mov	ip, #0
+	mcr	p15, 0, ip, c8, c7, 0	@ invalidate I+D TLBs
+	mcr	p15, 0, ip, c7, c7, 0	@ invalidate I+D caches
+	ldmia	r0, {r4 - r6}
+	mcr	p15, 0, r4, c13, c0, 0	@ PID
+	mcr	p15, 0, r5, c3, c0, 0	@ Domain ID
+	mcr	p15, 0, r1, c2, c0, 0	@ TTB address
+	mov	r0, r6			@ control register
+	b	cpu_resume_mmu
+ENDPROC(cpu_feroceon_do_resume)
+#endif
+
 	.type	__feroceon_setup, #function
 __feroceon_setup:
 	mov	r0, #0
Signature · 7 lines
1.8.1.5


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#3 lore raw

PATCH v3 1/2 ARM: feroceon: Add suspend/resume operation

In reply to Ezequiel Garcia

+rmk (oops, forgot to add you the first time around)

Quoted 8 lines · Ezequiel Garcia

Add support for suspend/resume operations. The implemented procedures are identical to the ones for ARM926.

---
 arch/arm/Kconfig            |  2 +-
 arch/arm/mm/proc-feroceon.S | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

Russell,

This is pretty isolated, and the next patch in the series depends on it for building (it's changes are all in mach-kirkwood/). Should Ezequiel push this into your patch tracker (and then could you create a public, non-rebasable branch containing it?), or can I take it with your Ack?

thx,

Jason.

Quoted 58 lines
arch/arm/Kconfig +1 -1
index 43594d5..a5111ec 100644
@@ -2199,7 +2199,7 @@ source "kernel/power/Kconfig"
 
 config ARCH_SUSPEND_POSSIBLE
 	depends on !ARCH_S5PC100
-	depends on CPU_ARM920T || CPU_ARM926T || CPU_SA1100 || \
+	depends on CPU_ARM920T || CPU_ARM926T || CPU_FEROCEON || CPU_SA1100 || \
 		CPU_V6 || CPU_V6K || CPU_V7 || CPU_XSC3 || CPU_XSCALE || CPU_MOHAWK
 	def_bool y
 
arch/arm/mm/proc-feroceon.S +26 -0
index d5146b9..db79b62 100644
@@ -514,6 +514,32 @@ ENTRY(cpu_feroceon_set_pte_ext)
 #endif
 	mov	pc, lr
 
+/* Suspend/resume support: taken from arch/arm/mm/proc-arm926.S */
+.globl	cpu_feroceon_suspend_size
+.equ	cpu_feroceon_suspend_size, 4 * 3
+#ifdef CONFIG_ARM_CPU_SUSPEND
+ENTRY(cpu_feroceon_do_suspend)
+	stmfd	sp!, {r4 - r6, lr}
+	mrc	p15, 0, r4, c13, c0, 0	@ PID
+	mrc	p15, 0, r5, c3, c0, 0	@ Domain ID
+	mrc	p15, 0, r6, c1, c0, 0	@ Control register
+	stmia	r0, {r4 - r6}
+	ldmfd	sp!, {r4 - r6, pc}
+ENDPROC(cpu_feroceon_do_suspend)
+
+ENTRY(cpu_feroceon_do_resume)
+	mov	ip, #0
+	mcr	p15, 0, ip, c8, c7, 0	@ invalidate I+D TLBs
+	mcr	p15, 0, ip, c7, c7, 0	@ invalidate I+D caches
+	ldmia	r0, {r4 - r6}
+	mcr	p15, 0, r4, c13, c0, 0	@ PID
+	mcr	p15, 0, r5, c3, c0, 0	@ Domain ID
+	mcr	p15, 0, r1, c2, c0, 0	@ TTB address
+	mov	r0, r6			@ control register
+	b	cpu_resume_mmu
+ENDPROC(cpu_feroceon_do_resume)
+#endif
+
 	.type	__feroceon_setup, #function
 __feroceon_setup:
 	mov	r0, #0
Signature · 7 lines
1.8.1.5


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw

PATCH v3 1/2 ARM: feroceon: Add suspend/resume operation

Jason,

Quoted 12 lines · Jason Cooper

+rmk (oops, forgot to add you the first time around)

Quoted 8 lines · Ezequiel Garcia

Add support for suspend/resume operations. The implemented procedures are identical to the ones for ARM926.

---
 arch/arm/Kconfig            |  2 +-
 arch/arm/mm/proc-feroceon.S | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
Quoted 7 lines

Russell,

This is pretty isolated, and the next patch in the series depends on it for building (it's changes are all in mach-kirkwood/). Should Ezequiel push this into your patch tracker (and then could you create a public, non-rebasable branch containing it?), or can I take it with your Ack?

This one is already sitting happy in Linus' :-)

Signature · 3 lines
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
#5 lore raw

PATCH v3 1/2 ARM: feroceon: Add suspend/resume operation

Quoted 17 lines · Ezequiel Garcia

Jason,

Quoted 14 lines · Jason Cooper

+rmk (oops, forgot to add you the first time around)

Quoted 8 lines · Ezequiel Garcia

Add support for suspend/resume operations. The implemented procedures are identical to the ones for ARM926.

---
 arch/arm/Kconfig            |  2 +-
 arch/arm/mm/proc-feroceon.S | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

Russell,

Quoted 7 lines
Quoted 5 lines

This is pretty isolated, and the next patch in the series depends on it for building (it's changes are all in mach-kirkwood/). Should Ezequiel push this into your patch tracker (and then could you create a public, non-rebasable branch containing it?), or can I take it with your Ack?

This one is already sitting happy in Linus' :-)

Ah, very well then. I'll queue up the other one.

thx,

Jason.

#6 lore raw

PATCH v3 1/2 ARM: feroceon: Add suspend/resume operation

Quoted 24 lines · Jason Cooper
Quoted 23 lines · Ezequiel Garcia

Jason,

Quoted 19 lines · Jason Cooper

+rmk (oops, forgot to add you the first time around)

Quoted 8 lines · Ezequiel Garcia

Add support for suspend/resume operations. The implemented procedures are identical to the ones for ARM926.

---
 arch/arm/Kconfig            |  2 +-
 arch/arm/mm/proc-feroceon.S | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

Russell,

This is pretty isolated, and the next patch in the series depends on it for building (it's changes are all in mach-kirkwood/). Should Ezequiel push this into your patch tracker (and then could you create a public, non-rebasable branch containing it?), or can I take it with your Ack?

Quoted 4 lines
Quoted 1 line

This one is already sitting happy in Linus' :-)

Ah, very well then. I'll queue up the other one.

Awesome.

Thanks,

Signature · 3 lines
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
#7 lore raw

PATCH v3 1/2 ARM: feroceon: Add suspend/resume operation

In reply to Ezequiel Garcia
Quoted 17 lines · Ezequiel Garcia

Jason,

Quoted 14 lines · Jason Cooper

+rmk (oops, forgot to add you the first time around)

Quoted 8 lines · Ezequiel Garcia

Add support for suspend/resume operations. The implemented procedures are identical to the ones for ARM926.

---
 arch/arm/Kconfig            |  2 +-
 arch/arm/mm/proc-feroceon.S | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

Russell,

Quoted 7 lines
Quoted 5 lines

This is pretty isolated, and the next patch in the series depends on it for building (it's changes are all in mach-kirkwood/). Should Ezequiel push this into your patch tracker (and then could you create a public, non-rebasable branch containing it?), or can I take it with your Ack?

This one is already sitting happy in Linus' :-)

Ah yes, and I see it already came via me. :)

#8 lore raw

PATCH v3 1/2 ARM: feroceon: Add suspend/resume operation

In reply to Jason Cooper
Quoted 12 lines · Jason Cooper

+rmk (oops, forgot to add you the first time around)

Quoted 8 lines · Ezequiel Garcia

Add support for suspend/resume operations. The implemented procedures are identical to the ones for ARM926.

---
 arch/arm/Kconfig            |  2 +-
 arch/arm/mm/proc-feroceon.S | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
Quoted 6 lines

Russell,

This is pretty isolated, and the next patch in the series depends on it for building (it's changes are all in mach-kirkwood/). Should Ezequiel push this into your patch tracker (and then could you create a public, non-rebasable branch containing it?), or can I take it with your Ack?

It looks fine, but it should cone via my tree in case of any conflicts in core code.

Thanks.

#9 lore raw

PATCH v3 2/2 ARM: kirkwood: Add standby support

In reply to Ezequiel Garcia

Implements standby support for Kirkwood SoC. When the SoC enters standby state the memory PM units are disabled, the DDR is set in self-refresh mode, and the CPU is set in WFI.

At this point there's no clock gating, as that is considered each driver's task.

---
 arch/arm/mach-kirkwood/Makefile                   |  2 +
 arch/arm/mach-kirkwood/board-dt.c                 |  1 +
 arch/arm/mach-kirkwood/common.c                   |  1 +
 arch/arm/mach-kirkwood/common.h                   |  6 ++
 arch/arm/mach-kirkwood/include/mach/bridge-regs.h |  2 +
 arch/arm/mach-kirkwood/pm.c                       | 73 +++++++++++++++++++++++
 6 files changed, 85 insertions(+)
 create mode 100644 arch/arm/mach-kirkwood/pm.c
arch/arm/mach-kirkwood/Makefile +2 -0
index ac4cd75..ac78dcc 100644
@@ -1,4 +1,6 @@
 obj-y				+= common.o irq.o pcie.o mpp.o
+obj-$(CONFIG_PM)		+= pm.o
+
 
 obj-$(CONFIG_MACH_D2NET_V2)		+= d2net_v2-setup.o lacie_v2-common.o
 obj-$(CONFIG_MACH_DOCKSTAR)		+= dockstar-setup.o
arch/arm/mach-kirkwood/board-dt.c +1 -0
index 6e122ed..2d4a4aa 100644
@@ -96,6 +96,7 @@ static void __init kirkwood_dt_init(void)
 	/* Setup root of clk tree */
 	kirkwood_of_clk_init();
 
+	kirkwood_pm_init();
 	kirkwood_cpuidle_init();
 
 #ifdef CONFIG_KEXEC
arch/arm/mach-kirkwood/common.c +1 -0
index e9238b5..aceb68a 100644
@@ -717,6 +717,7 @@ void __init kirkwood_init(void)
 	kirkwood_xor1_init();
 	kirkwood_crypto_init();
 
+	kirkwood_pm_init();
 	kirkwood_cpuidle_init();
 #ifdef CONFIG_KEXEC
 	kexec_reinit = kirkwood_enable_pcie;
arch/arm/mach-kirkwood/common.h +6 -0
index fcf3ba6..2be1226 100644
@@ -58,6 +58,12 @@ void kirkwood_cpufreq_init(void);
 void kirkwood_restart(enum reboot_mode, const char *);
 void kirkwood_clk_init(void);
 
+#ifdef CONFIG_PM
+void kirkwood_pm_init(void);
+#else
+static inline void kirkwood_pm_init(void) {};
+#endif
+
 /* board init functions for boards not fully converted to fdt */
 #ifdef CONFIG_MACH_DREAMPLUG_DT
 void dreamplug_init(void);
arch/arm/mach-kirkwood/include/mach/bridge-regs.h +2 -0
index 91242c9..8b9d1c9 100644
@@ -78,4 +78,6 @@
 #define CGC_TDM			(1 << 20)
 #define CGC_RESERVED		(0x6 << 21)
 
+#define MEMORY_PM_CTRL		(BRIDGE_VIRT_BASE + 0x118)
+
 #endif
arch/arm/mach-kirkwood/pm.c new file +73 -0

73 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#10 lore raw

PATCH v3 2/2 ARM: kirkwood: Add standby support

Quoted 164 lines · Ezequiel Garcia

Implements standby support for Kirkwood SoC. When the SoC enters standby state the memory PM units are disabled, the DDR is set in self-refresh mode, and the CPU is set in WFI.

At this point there's no clock gating, as that is considered each driver's task.

---
 arch/arm/mach-kirkwood/Makefile                   |  2 +
 arch/arm/mach-kirkwood/board-dt.c                 |  1 +
 arch/arm/mach-kirkwood/common.c                   |  1 +
 arch/arm/mach-kirkwood/common.h                   |  6 ++
 arch/arm/mach-kirkwood/include/mach/bridge-regs.h |  2 +
 arch/arm/mach-kirkwood/pm.c                       | 73 +++++++++++++++++++++++
 6 files changed, 85 insertions(+)
 create mode 100644 arch/arm/mach-kirkwood/pm.c
arch/arm/mach-kirkwood/Makefile +2 -0
index ac4cd75..ac78dcc 100644
@@ -1,4 +1,6 @@
 obj-y				+= common.o irq.o pcie.o mpp.o
+obj-$(CONFIG_PM)		+= pm.o
+
 
 obj-$(CONFIG_MACH_D2NET_V2)		+= d2net_v2-setup.o lacie_v2-common.o
 obj-$(CONFIG_MACH_DOCKSTAR)		+= dockstar-setup.o
arch/arm/mach-kirkwood/board-dt.c +1 -0
index 6e122ed..2d4a4aa 100644
@@ -96,6 +96,7 @@ static void __init kirkwood_dt_init(void)
 	/* Setup root of clk tree */
 	kirkwood_of_clk_init();
 
+	kirkwood_pm_init();
 	kirkwood_cpuidle_init();
 
 #ifdef CONFIG_KEXEC
arch/arm/mach-kirkwood/common.c +1 -0
index e9238b5..aceb68a 100644
@@ -717,6 +717,7 @@ void __init kirkwood_init(void)
 	kirkwood_xor1_init();
 	kirkwood_crypto_init();
 
+	kirkwood_pm_init();
 	kirkwood_cpuidle_init();
 #ifdef CONFIG_KEXEC
 	kexec_reinit = kirkwood_enable_pcie;
arch/arm/mach-kirkwood/common.h +6 -0
index fcf3ba6..2be1226 100644
@@ -58,6 +58,12 @@ void kirkwood_cpufreq_init(void);
 void kirkwood_restart(enum reboot_mode, const char *);
 void kirkwood_clk_init(void);
 
+#ifdef CONFIG_PM
+void kirkwood_pm_init(void);
+#else
+static inline void kirkwood_pm_init(void) {};
+#endif
+
 /* board init functions for boards not fully converted to fdt */
 #ifdef CONFIG_MACH_DREAMPLUG_DT
 void dreamplug_init(void);
arch/arm/mach-kirkwood/include/mach/bridge-regs.h +2 -0
index 91242c9..8b9d1c9 100644
@@ -78,4 +78,6 @@
 #define CGC_TDM			(1 << 20)
 #define CGC_RESERVED		(0x6 << 21)
 
+#define MEMORY_PM_CTRL		(BRIDGE_VIRT_BASE + 0x118)
+
 #endif
arch/arm/mach-kirkwood/pm.c new file +73 -0
new file mode 100644
index 0000000..8783a71
@@ -0,0 +1,73 @@
+/*
+ * Power Management driver for Marvell Kirkwood SoCs
+ *
+ * Copyright (C) 2013 Ezequiel Garcia <[email protected]>
+ * Copyright (C) 2010 Simon Guinot <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License,
+ * version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/suspend.h>
+#include <linux/io.h>
+#include <mach/bridge-regs.h>
+
+static void __iomem *ddr_operation_base;
+
+static void kirkwood_low_power(void)
+{
+	u32 mem_pm_ctrl;
+
+	mem_pm_ctrl = readl(MEMORY_PM_CTRL);
+
+	/* Set peripherals to low-power mode */
+	writel_relaxed(~0, MEMORY_PM_CTRL);
+
+	/* Set DDR in self-refresh */
+	writel_relaxed(0x7, ddr_operation_base);
+
+	/*
+	 * Set CPU in wait-for-interrupt state.
+	 * This disables the CPU core clocks,
+	 * the array clocks, and also the L2 controller.
+	 */
+	cpu_do_idle();
+
+	writel_relaxed(mem_pm_ctrl, MEMORY_PM_CTRL);
+}
+
+static int kirkwood_suspend_enter(suspend_state_t state)
+{
+	switch (state) {
+	case PM_SUSPEND_STANDBY:
+		kirkwood_low_power();
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static int kirkwood_pm_valid_standby(suspend_state_t state)
+{
+	return state == PM_SUSPEND_STANDBY;
+}
+
+static const struct platform_suspend_ops kirkwood_suspend_ops = {
+	.enter = kirkwood_suspend_enter,
+	.valid = kirkwood_pm_valid_standby,
+};
+
+int __init kirkwood_pm_init(void)
+{
+	ddr_operation_base = ioremap(DDR_OPERATION_BASE, 4);
+	suspend_set_ops(&kirkwood_suspend_ops);
+	return 0;
+}
Signature · 1 line
1.8.1.5

Any comments on this?

Signature · 3 lines
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
#11 lore raw

PATCH v3 2/2 ARM: kirkwood: Add standby support

Quoted 20 lines · Ezequiel Garcia
Quoted 9 lines · Ezequiel Garcia

Implements standby support for Kirkwood SoC. When the SoC enters standby state the memory PM units are disabled, the DDR is set in self-refresh mode, and the CPU is set in WFI.

At this point there's no clock gating, as that is considered each driver's task.

Quoted 9 lines
---
 arch/arm/mach-kirkwood/Makefile                   |  2 +
 arch/arm/mach-kirkwood/board-dt.c                 |  1 +
 arch/arm/mach-kirkwood/common.c                   |  1 +
 arch/arm/mach-kirkwood/common.h                   |  6 ++
 arch/arm/mach-kirkwood/include/mach/bridge-regs.h |  2 +
 arch/arm/mach-kirkwood/pm.c                       | 73 +++++++++++++++++++++++
 6 files changed, 85 insertions(+)
 create mode 100644 arch/arm/mach-kirkwood/pm.c
Quoted 1 line

Any comments on this?

Well, I was sitting on this for the next merge window, since it came in late and honestly, isn't complete. You stated yourself in the coverletter that it offered no real power savings.

How about expanding the series to add proper suspend/resume support to some of the more power hungry drivers (yes, this might re-awaken the mv643xx_eth mac address issue), and resubmit?

thx,

Jason.

#12 lore raw

PATCH v3 2/2 ARM: kirkwood: Add standby support

Quoted 21 lines · Jason Cooper
Quoted 20 lines · Ezequiel Garcia
Quoted 18 lines · Ezequiel Garcia

Implements standby support for Kirkwood SoC. When the SoC enters standby state the memory PM units are disabled, the DDR is set in self-refresh mode, and the CPU is set in WFI.

At this point there's no clock gating, as that is considered each driver's task.

---
 arch/arm/mach-kirkwood/Makefile                   |  2 +
 arch/arm/mach-kirkwood/board-dt.c                 |  1 +
 arch/arm/mach-kirkwood/common.c                   |  1 +
 arch/arm/mach-kirkwood/common.h                   |  6 ++
 arch/arm/mach-kirkwood/include/mach/bridge-regs.h |  2 +
 arch/arm/mach-kirkwood/pm.c                       | 73 +++++++++++++++++++++++
 6 files changed, 85 insertions(+)
 create mode 100644 arch/arm/mach-kirkwood/pm.c
Quoted 3 lines
Quoted 1 line

Any comments on this?

Well, I was sitting on this for the next merge window,

Of course, this isn't intended for this merge window. We need first the feroceon suspend/resume patch that is already queued for v3.12.

So, first of all: sorry if I'm making noise; just wanted to check nobody had any major comments.

Quoted 3 lines

since it came in late and honestly, isn't complete. You stated yourself in the coverletter that it offered no real power savings.

Discussing about this with Simon Guinot on IRC (the original author of this) we agreed the patch was a nice thing to have, and that follow-up patches might add better power savings on a per-device basis.

Maybe it's foolish, but notice this doesn't provide additional power saving in comparison with a cpuidled-kernel (I know, most of users will select it).

Quoted 2 lines

How about expanding the series to add proper suspend/resume support to some of the more power hungry drivers

So -just to check- you definitely prefer not to take the stand-by support until we have some more suspend/resume support in other drivers?

If the stand-by is ready and it's working, I'd say we're ready to include it, disregarding the drivers, but it's completely your call.

Quoted 3 lines

(yes, this might re-awaken the
mv643xx_eth mac address issue), and resubmit?

I'm not entirely familiar with the eth mac issue, but currently we're enabling the eth clock in mach-kirkwood, so those clocks are *impossible* to disable from the driver (due to refcounting-like clock disable). Not sure what's the right thing to do.

Thanks!

Signature · 3 lines
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
#13 lore raw

PATCH v3 2/2 ARM: kirkwood: Add standby support

Quoted 1 line · Ezequiel Garcia

On Sat, Aug 31, 2013 at 11:51:25AM -0400, Jason Cooper wrote:

...

Quoted 8 lines
Quoted 2 lines

How about expanding the series to add proper suspend/resume support to some of the more power hungry drivers

So -just to check- you definitely prefer not to take the stand-by support until we have some more suspend/resume support in other drivers?

If the stand-by is ready and it's working, I'd say we're ready to include it, disregarding the drivers, but it's completely your call.

Looking things over, most drivers we care about are missing suspend/resume. At some point I think it's reasonable to assume that we'll do a sweep. So I drop my objection to this.

Let's see how rmk wants to handle #1 and go from there.

thx,

Jason.

Applied
#14 lore raw

PATCH v3 2/2 ARM: kirkwood: Add standby support

In reply to Ezequiel Garcia
Quoted 9 lines · Ezequiel Garcia

Implements standby support for Kirkwood SoC. When the SoC enters standby state the memory PM units are disabled, the DDR is set in self-refresh mode, and the CPU is set in WFI.

At this point there's no clock gating, as that is considered each driver's task.

Quoted 9 lines
---
 arch/arm/mach-kirkwood/Makefile                   |  2 +
 arch/arm/mach-kirkwood/board-dt.c                 |  1 +
 arch/arm/mach-kirkwood/common.c                   |  1 +
 arch/arm/mach-kirkwood/common.h                   |  6 ++
 arch/arm/mach-kirkwood/include/mach/bridge-regs.h |  2 +
 arch/arm/mach-kirkwood/pm.c                       | 73 +++++++++++++++++++++++
 6 files changed, 85 insertions(+)
 create mode 100644 arch/arm/mach-kirkwood/pm.c

Applied to mvebu/soc

thx,

Jason.