2015-02-12 02:53:12

by Wenyou Yang

[permalink] [raw]
Subject: [PATCH 0/3] AT91 pm fixes for 3.21

Hi,

The patch series purpose is to fix the AT91 pm.
Add pm support for sama5d3 and sama5d4.
Fix the MOR register KEY missing when writing.
Add flush and disable the cache before going to suspending.

Patrice Vilchez (1):
pm: at91: pm_suspend: MOR register KEY was missing

Wenyou Yang (2):
pm: at91: pm_suspend: add the WFI instruction support for ARMv7
pm: at91: flush data cache and clean, invalidate and disable the L2
cache

arch/arm/mach-at91/pm.c | 6 ++++++
arch/arm/mach-at91/pm_suspend.S | 22 +++++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)

--
1.7.9.5


2015-02-12 02:54:14

by Wenyou Yang

[permalink] [raw]
Subject: [PATCH 1/3] pm: at91: pm_suspend: add the WFI instruction support for ARMv7

Add the WFI instruction to make the cpu to the idle state.
In the meanwhile, disable the processor's clock.

Signed-off-by: Wenyou Yang <[email protected]>
---
arch/arm/mach-at91/pm_suspend.S | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/pm_suspend.S b/arch/arm/mach-at91/pm_suspend.S
index bebe3de..1c7256a 100644
--- a/arch/arm/mach-at91/pm_suspend.S
+++ b/arch/arm/mach-at91/pm_suspend.S
@@ -51,6 +51,24 @@ tmp2 .req r5
beq 1b
.endm

+/*
+ * Put the processor to enter the idle state
+ */
+ .macro at91_cpu_idle
+
+#if defined(CONFIG_CPU_V7)
+ mov tmp1, #AT91_PMC_PCK
+ str tmp1, [pmc, #AT91_PMC_SCDR]
+
+ dsb
+
+ wfi @ Wait For Interrupt
+#else
+ mcr p15, 0, tmp1, c7, c0, 4
+#endif
+
+ .endm
+
.text

/*
@@ -120,7 +138,7 @@ skip_disable_main_clock:
ldr pmc, .pmc_base

/* Wait for interrupt */
- mcr p15, 0, tmp1, c7, c0, 4
+ at91_cpu_idle

ldr r0, .pm_mode
tst r0, #AT91_PM_SLOW_CLOCK
--
1.7.9.5

2015-02-12 02:54:33

by Wenyou Yang

[permalink] [raw]
Subject: [PATCH 2/3] pm: at91: pm_suspend: MOR register KEY was missing

From: Patrice Vilchez <[email protected]>

Because writing the MOR register requires the PASSWD(0x37),
if missed, the write operation will be aborted.

Signed-off-by: Patrice Vilchez <[email protected]>
---
arch/arm/mach-at91/pm_suspend.S | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-at91/pm_suspend.S b/arch/arm/mach-at91/pm_suspend.S
index 1c7256a..5347ad4 100644
--- a/arch/arm/mach-at91/pm_suspend.S
+++ b/arch/arm/mach-at91/pm_suspend.S
@@ -132,6 +132,7 @@ ENTRY(at91_pm_suspend_in_sram)
/* Turn off the main oscillator */
ldr tmp1, [pmc, #AT91_CKGR_MOR]
bic tmp1, tmp1, #AT91_PMC_MOSCEN
+ orr tmp1, tmp1, #AT91_PMC_KEY
str tmp1, [pmc, #AT91_CKGR_MOR]

skip_disable_main_clock:
@@ -149,6 +150,7 @@ skip_disable_main_clock:
/* Turn on the main oscillator */
ldr tmp1, [pmc, #AT91_CKGR_MOR]
orr tmp1, tmp1, #AT91_PMC_MOSCEN
+ orr tmp1, tmp1, #AT91_PMC_KEY
str tmp1, [pmc, #AT91_CKGR_MOR]

wait_moscrdy
--
1.7.9.5

2015-02-12 03:00:45

by Wenyou Yang

[permalink] [raw]
Subject: [PATCH 3/3] pm: at91: flush data cache and clean, invalidate and disable the L2 cache

Flush data cache, and clean, invalidate and disable the L2 cache before going to suspend.
Restore the L2 cache configuration and re-enable the L2 cache after waking up.

Signed-off-by: Wenyou Yang <[email protected]>
---
arch/arm/mach-at91/pm.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 9075b41..2574bad 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -30,6 +30,7 @@
#include <asm/mach/time.h>
#include <asm/mach/irq.h>
#include <asm/fncpy.h>
+#include <asm/cacheflush.h>

#include <mach/cpu.h>
#include <mach/hardware.h>
@@ -145,8 +146,13 @@ static void at91_pm_suspend(suspend_state_t state)
pm_data |= (state == PM_SUSPEND_MEM) ?
AT91_PM_MODE(AT91_PM_SLOW_CLOCK) : 0;

+ flush_cache_all();
+ outer_disable();
+
at91_suspend_sram_fn(at91_pmc_base, at91_ramc_base[0],
at91_ramc_base[1], pm_data);
+
+ outer_resume();
}

static int at91_pm_enter(suspend_state_t state)
--
1.7.9.5

2015-02-17 10:22:58

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 1/3] pm: at91: pm_suspend: add the WFI instruction support for ARMv7

On 12/02/2015 at 10:51:26 +0800, Wenyou Yang wrote :
> Add the WFI instruction to make the cpu to the idle state.
> In the meanwhile, disable the processor's clock.
>
> Signed-off-by: Wenyou Yang <[email protected]>
Acked-by: Alexandre Belloni <[email protected]>

> ---
> arch/arm/mach-at91/pm_suspend.S | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-at91/pm_suspend.S b/arch/arm/mach-at91/pm_suspend.S
> index bebe3de..1c7256a 100644
> --- a/arch/arm/mach-at91/pm_suspend.S
> +++ b/arch/arm/mach-at91/pm_suspend.S
> @@ -51,6 +51,24 @@ tmp2 .req r5
> beq 1b
> .endm
>
> +/*
> + * Put the processor to enter the idle state
> + */
> + .macro at91_cpu_idle
> +
> +#if defined(CONFIG_CPU_V7)
> + mov tmp1, #AT91_PMC_PCK
> + str tmp1, [pmc, #AT91_PMC_SCDR]
> +
> + dsb
> +
> + wfi @ Wait For Interrupt
> +#else
> + mcr p15, 0, tmp1, c7, c0, 4
> +#endif
> +
> + .endm
> +
> .text
>
> /*
> @@ -120,7 +138,7 @@ skip_disable_main_clock:
> ldr pmc, .pmc_base
>
> /* Wait for interrupt */
> - mcr p15, 0, tmp1, c7, c0, 4
> + at91_cpu_idle
>
> ldr r0, .pm_mode
> tst r0, #AT91_PM_SLOW_CLOCK
> --
> 1.7.9.5
>

--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

2015-02-17 10:24:13

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 2/3] pm: at91: pm_suspend: MOR register KEY was missing

On 12/02/2015 at 10:52:13 +0800, Wenyou Yang wrote :
> From: Patrice Vilchez <[email protected]>
>
> Because writing the MOR register requires the PASSWD(0x37),
> if missed, the write operation will be aborted.
>
> Signed-off-by: Patrice Vilchez <[email protected]>
Acked-by: Alexandre Belloni <[email protected]>

> ---
> arch/arm/mach-at91/pm_suspend.S | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/arm/mach-at91/pm_suspend.S b/arch/arm/mach-at91/pm_suspend.S
> index 1c7256a..5347ad4 100644
> --- a/arch/arm/mach-at91/pm_suspend.S
> +++ b/arch/arm/mach-at91/pm_suspend.S
> @@ -132,6 +132,7 @@ ENTRY(at91_pm_suspend_in_sram)
> /* Turn off the main oscillator */
> ldr tmp1, [pmc, #AT91_CKGR_MOR]
> bic tmp1, tmp1, #AT91_PMC_MOSCEN
> + orr tmp1, tmp1, #AT91_PMC_KEY
> str tmp1, [pmc, #AT91_CKGR_MOR]
>
> skip_disable_main_clock:
> @@ -149,6 +150,7 @@ skip_disable_main_clock:
> /* Turn on the main oscillator */
> ldr tmp1, [pmc, #AT91_CKGR_MOR]
> orr tmp1, tmp1, #AT91_PMC_MOSCEN
> + orr tmp1, tmp1, #AT91_PMC_KEY
> str tmp1, [pmc, #AT91_CKGR_MOR]
>
> wait_moscrdy
> --
> 1.7.9.5
>

--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

2015-02-17 10:26:02

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 3/3] pm: at91: flush data cache and clean, invalidate and disable the L2 cache

On 12/02/2015 at 10:52:58 +0800, Wenyou Yang wrote :
> Flush data cache, and clean, invalidate and disable the L2 cache before going to suspend.
> Restore the L2 cache configuration and re-enable the L2 cache after waking up.
>
> Signed-off-by: Wenyou Yang <[email protected]>
Acked-by: Alexandre Belloni <[email protected]>

> ---
> arch/arm/mach-at91/pm.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 9075b41..2574bad 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -30,6 +30,7 @@
> #include <asm/mach/time.h>
> #include <asm/mach/irq.h>
> #include <asm/fncpy.h>
> +#include <asm/cacheflush.h>
>
> #include <mach/cpu.h>
> #include <mach/hardware.h>
> @@ -145,8 +146,13 @@ static void at91_pm_suspend(suspend_state_t state)
> pm_data |= (state == PM_SUSPEND_MEM) ?
> AT91_PM_MODE(AT91_PM_SLOW_CLOCK) : 0;
>
> + flush_cache_all();
> + outer_disable();
> +
> at91_suspend_sram_fn(at91_pmc_base, at91_ramc_base[0],
> at91_ramc_base[1], pm_data);
> +
> + outer_resume();
> }
>
> static int at91_pm_enter(suspend_state_t state)
> --
> 1.7.9.5
>

--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com