ARCH: CSR: basic PM suspend/resume support
Subsystems (2)
cover ARCH: CSR: basic PM suspend/resume support
it was in thread "ARM: CSR: add rtciobrg and PM support" before. See:
http://www.spinics.net/lists/arm-kernel/msg137375.html
Arnd has pulled rtciobrg into arm-soc next branch. PM should be another series.
This series has been tested on prima2 Linux 3.1-rc6 with log:
# echo mem > /sys/power/state PM: Syncing filesystems ... done. Freezing user space processes ... (elapsed 0.01 seconds) done. Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done. Suspending console(s) (use no_console_suspend to debug) C0PM: suspend of devices complete after 2.083 msecs PM: late suspend of devices complete after 0.697 msecs L310 cache controller enabled l2x0: 8 ways, CACHE_ID 0x410000c7, AUX_CTRL 0x00040000, Cache size: 262144 B PM: early resume of devices complete after 0.628 msecs PM: resume of devices complete after 1.804 msecs Restarting tasks ... done.
Due to L2 cache will lose power and data in suspend cycle, prima2 actually requires the whole l2 cache flushed while suspending and re-initilized after resuming just like code boot.
So the "ARM: CSR: PM: add sleep entry for SiRFprimaII" depends on:
Shawn Guo <[email protected]>'s
[PATCH v2 1/2] ARM: cache-l2x0: remove __init annotation from initialization functions
http://www.spinics.net/lists/arm-kernel/msg139198.html
Barry Song (2):
ARM: CSR: PM: save/restore timer status in suspend cycles
ARM: CSR: PM: save/restore irq status in suspend cycles
Rongjun Ying (1):
ARM: CSR: PM: add sleep entry for SiRFprimaII
arch/arm/mach-prima2/Makefile | 1 + arch/arm/mach-prima2/irq.c | 40 +++++++++++ arch/arm/mach-prima2/pm.c | 150 +++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-prima2/pm.h | 31 +++++++++ arch/arm/mach-prima2/sleep.S | 64 +++++++++++++++++ arch/arm/mach-prima2/timer.c | 34 +++++++++ 6 files changed, 320 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-prima2/pm.c create mode 100644 arch/arm/mach-prima2/pm.h create mode 100644 arch/arm/mach-prima2/sleep.S
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
PATCH 1/3 ARM: CSR: PM: save/restore timer status in suspend cycles
--- arch/arm/mach-prima2/timer.c | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-)
arch/arm/mach-prima2/timer.c +34 -0
@@ -40,6 +40,17 @@#define SIRFSOC_TIMER_LATCH_BIT BIT(0) +#define SIRFSOC_TIMER_REG_CNT 11 + +static const u32 sirfsoc_timer_reg_list[SIRFSOC_TIMER_REG_CNT ] = { +SIRFSOC_TIMER_MATCH_0 ,SIRFSOC_TIMER_MATCH_1 ,SIRFSOC_TIMER_MATCH_2 , +SIRFSOC_TIMER_MATCH_3 ,SIRFSOC_TIMER_MATCH_4 ,SIRFSOC_TIMER_MATCH_5 , +SIRFSOC_TIMER_INT_EN ,SIRFSOC_TIMER_WATCHDOG_EN ,SIRFSOC_TIMER_DIV , +SIRFSOC_TIMER_LATCHED_LO ,SIRFSOC_TIMER_LATCHED_HI , +}; + +static u32 sirfsoc_timer_reg_val[SIRFSOC_TIMER_REG_CNT ]; +static void __iomem *sirfsoc_timer_base;static void __init sirfsoc_of_timer_map (void );
@@ -106,6 +117,27 @@ static void sirfsoc_timer_set_mode(enum clock_event_mode mode, } } +static void sirfsoc_clocksource_suspend (struct clocksource *cs) +{ +int i; + +writel_relaxed (SIRFSOC_TIMER_LATCH_BIT , sirfsoc_timer_base +SIRFSOC_TIMER_LATCH ); + +for (i =0 ; i <SIRFSOC_TIMER_REG_CNT ; i++) + sirfsoc_timer_reg_val[i] =readl_relaxed (sirfsoc_timer_base + sirfsoc_timer_reg_list[i]); +} + +static void sirfsoc_clocksource_resume (struct clocksource *cs) +{ +int i; + +for (i =0 ; i <SIRFSOC_TIMER_REG_CNT ; i++) +writel_relaxed (sirfsoc_timer_reg_val[i], sirfsoc_timer_base + sirfsoc_timer_reg_list[i]); + +writel_relaxed (sirfsoc_timer_reg_val[i -2 ], sirfsoc_timer_base +SIRFSOC_TIMER_COUNTER_LO ); +writel_relaxed (sirfsoc_timer_reg_val[i -1 ], sirfsoc_timer_base +SIRFSOC_TIMER_COUNTER_HI ); +} +static struct clock_event_device sirfsoc_clockevent = { .name ="sirfsoc_clockevent" , .rating =200 ,
@@ -120,6 +152,8 @@ static struct clocksource sirfsoc_clocksource = { .mask = CLOCKSOURCE_MASK(64), .flags = CLOCK_SOURCE_IS_CONTINUOUS, .read = sirfsoc_timer_read, + .suspend = sirfsoc_clocksource_suspend, + .resume = sirfsoc_clocksource_resume, };static struct irqaction sirfsoc_timer_irq = {
Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our [email protected]/blog
PATCH 2/3 ARM: CSR: PM: save/restore irq status in suspend cycles
In reply to Barry Song--- arch/arm/mach-prima2/irq.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-)
arch/arm/mach-prima2/irq.c +40 -0
@@ -14,6 +14,7 @@#include <linux/of.h> #include <linux/of_address.h> #include <linux/irqdomain.h> +#include <linux/syscore_ops.h> #define SIRFSOC_INT_RISC_MASK0 0x0018#define SIRFSOC_INT_RISC_MASK1 0x001C
@@ -73,3 +74,42 @@ void __init sirfsoc_of_irq_init(void)sirfsoc_irq_init (); } + +struct sirfsoc_irq_status { +u32 mask0; +u32 mask1; +u32 level0; +u32 level1; +}; + +static struct sirfsoc_irq_status sirfsoc_irq_st; + +static int sirfsoc_irq_suspend (void ) +{ + sirfsoc_irq_st.mask0 =readl_relaxed (sirfsoc_intc_base +SIRFSOC_INT_RISC_MASK0 ); + sirfsoc_irq_st.mask1 =readl_relaxed (sirfsoc_intc_base +SIRFSOC_INT_RISC_MASK1 ); + sirfsoc_irq_st.level0 =readl_relaxed (sirfsoc_intc_base +SIRFSOC_INT_RISC_LEVEL0 ); + sirfsoc_irq_st.level1 =readl_relaxed (sirfsoc_intc_base +SIRFSOC_INT_RISC_LEVEL1 ); + +return 0 ; +} + +static void sirfsoc_irq_resume (void ) +{ +writel_relaxed (sirfsoc_irq_st.mask0, sirfsoc_intc_base +SIRFSOC_INT_RISC_MASK0 ); +writel_relaxed (sirfsoc_irq_st.mask1, sirfsoc_intc_base +SIRFSOC_INT_RISC_MASK1 ); +writel_relaxed (sirfsoc_irq_st.level0, sirfsoc_intc_base +SIRFSOC_INT_RISC_LEVEL0 ); +writel_relaxed (sirfsoc_irq_st.level1, sirfsoc_intc_base +SIRFSOC_INT_RISC_LEVEL1 ); +} + +static struct syscore_ops sirfsoc_irq_syscore_ops = { + .suspend = sirfsoc_irq_suspend, + .resume = sirfsoc_irq_resume, +}; + +static int __init sirfsoc_irq_pm_init (void ) +{ +register_syscore_ops (&sirfsoc_irq_syscore_ops); +return 0 ; +} +device_initcall (sirfsoc_irq_pm_init);
Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
PATCH 3/3 ARM: CSR: PM: add sleep entry for SiRFprimaII
In reply to Barry SongFrom: Rongjun Ying <[email protected]>
---
Due to L2 cache will lose power and data in suspend cycle, prima2 actually requires the whole l2 cache flushed while suspending and re-initilized after resuming just like code boot.
So the "ARM: CSR: PM: add sleep entry for SiRFprimaII" depends on:
Shawn Guo <[email protected]>'s
[PATCH v2 1/2] ARM: cache-l2x0: remove __init annotation from initialization functions
http://www.spinics.net/lists/arm-kernel/msg139198.html
arch/arm/mach-prima2/Makefile | 1 + arch/arm/mach-prima2/pm.c | 150 +++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-prima2/pm.h | 31 +++++++++ arch/arm/mach-prima2/sleep.S | 64 +++++++++++++++++ 4 files changed, 246 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-prima2/pm.c create mode 100644 arch/arm/mach-prima2/pm.h create mode 100644 arch/arm/mach-prima2/sleep.S
arch/arm/mach-prima2/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-y += prima2.o obj-y += rtciobrg.o obj-$(CONFIG_DEBUG_LL) += lluart.o obj-$(CONFIG_CACHE_L2X0) += l2x0.o +obj-$(CONFIG_SUSPEND) += pm.o sleep.o
arch/arm/mach-prima2/pm.c new file +150 -0
150 lines not on this page · raw message
arch/arm/mach-prima2/pm.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* arch/arm/mach-prima2/pm.h +* +* Copyright (C) 2011 CSR +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#ifndef _MACH_PRIMA2_PM_H_ +#define _MACH_PRIMA2_PM_H_ + +#define SIRFSOC_PWR_SLEEPFORCE 0x01 + +#define SIRFSOC_SLEEP_MODE_MASK 0x3 +#define SIRFSOC_DEEP_SLEEP_MODE 0x1 + +#define SIRFSOC_PWRC_PDN_CTRL 0x0 +#define SIRFSOC_PWRC_PON_OFF 0x4 +#define SIRFSOC_PWRC_TRIGGER_EN 0x8 +#define SIRFSOC_PWRC_PIN_STATUS 0x14 +#define SIRFSOC_PWRC_SCRATCH_PAD1 0x18 +#define SIRFSOC_PWRC_SCRATCH_PAD2 0x1C + +#ifndef __ASSEMBLY__ +extern int sirfsoc_finish_suspend (unsigned long ); +#endif + +#endif +
arch/arm/mach-prima2/sleep.S new file +64 -0
64 lines not on this page · raw message
Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
cover ARCH: CSR: basic PM suspend/resume support
In reply to Barry SongQuoted 6 lines · Barry Song
it was in thread "ARM: CSR: add rtciobrg and PM support" before. See:
http://www.spinics.net/lists/arm-kernel/msg137375.htmlArnd has pulled rtciobrg into arm-soc next branch. PM should be another series.
Looks good to me, feel free to add my Acked-by to the patches, but please add a meaningful changelog text to each patch first. You can use some of the text that you put in the introductory mail.
In general, I expect even trivial patches to have a changelog of one sentence and more text if the patch touches more code.
If nobody has other comments on the code, please send me a pull request once that is done.
Arnd
cover ARCH: CSR: basic PM suspend/resume support
Hi Arnd,
Thanks!
2011/9/14 Arnd Bergmann <[email protected]>:
Quoted 5 lines · Barry Song
Quoted 4 lines
it was in thread "ARM: CSR: add rtciobrg and PM support" before. See:
http://www.spinics.net/lists/arm-kernel/msg137375.html
Quoted 7 lines
Quoted 2 lines
Arnd has pulled rtciobrg into arm-soc next branch. PM should be another series.
Looks good to me, feel free to add my Acked-by to the patches, but please add a meaningful changelog text to each patch first. You can use some of the text that you put in the introductory mail.
ok. i will. and thanks.
Quoted 2 lines
In general, I expect even trivial patches to have a changelog of one sentence and more text if the patch touches more code.
make sense.
Quoted 3 lines
If nobody has other comments on the code, please send me a pull request once that is done.
a problem is patch 3/3 depends on Shawn Guo <[email protected]>'s [PATCH v2 1/2] ARM: cache-l2x0: remove __init annotation from initialization functions
http://www.spinics.net/lists/arm-kernel/msg139198.html
it seems Russell hasn't given feedback yet. i am not sure Russell's opinion about how to suspend/resume l2 for SoCs whose l2 cache will lose in suspend cycle. in my opinion, a complete re-init is simplest.
For imx6q and omap who will not lose l2 in suspend cycle, Russell sent a patchset about suspend and required l2 re-enabled before cpu_resume by omap/imx6q platform-specific codes.
Quoted 2 lines
? ? ? ?Arnd
Thanks
barry