* [PATCH v3 1/4] ARM: mvebu: Use __init for the PM initialization functions
2015-07-03 11:55 [PATCH v3 0/4] Add standby support for the recent mvebu SoCs Gregory CLEMENT
@ 2015-07-03 11:55 ` Gregory CLEMENT
2015-07-03 11:55 ` [PATCH v3 2/4] ARM: mvebu: Add standby support Gregory CLEMENT
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Gregory CLEMENT @ 2015-07-03 11:55 UTC (permalink / raw)
To: Jason Cooper, Andrew Lunn, Sebastian Hesselbarth, Gregory CLEMENT
Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
Maxime Ripard, Boris BREZILLON, Lior Amsalem, Tawfik Bayouk,
Nadav Haklai, linux-pm, linux-kernel
mvebu_pm_init and mvebu_armada_pm_init are only called during boot, so
flag them with __init and save some memory.
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
arch/arm/mach-mvebu/pm-board.c | 2 +-
arch/arm/mach-mvebu/pm.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-mvebu/pm-board.c b/arch/arm/mach-mvebu/pm-board.c
index 0f471fad214a..acc69e369c8b 100644
--- a/arch/arm/mach-mvebu/pm-board.c
+++ b/arch/arm/mach-mvebu/pm-board.c
@@ -76,7 +76,7 @@ static void mvebu_armada_pm_enter(void __iomem *sdram_reg, u32 srcmd)
[ackcmd] "r" (ackcmd), [gpio_ctrl] "r" (gpio_ctrl) : "r1");
}
-static int mvebu_armada_pm_init(void)
+static int __init mvebu_armada_pm_init(void)
{
struct device_node *np;
struct device_node *gpio_ctrl_np;
diff --git a/arch/arm/mach-mvebu/pm.c b/arch/arm/mach-mvebu/pm.c
index 90d85ef75d54..f249c8e04bd4 100644
--- a/arch/arm/mach-mvebu/pm.c
+++ b/arch/arm/mach-mvebu/pm.c
@@ -235,7 +235,7 @@ static const struct platform_suspend_ops mvebu_pm_ops = {
.valid = suspend_valid_only_mem,
};
-int mvebu_pm_init(void (*board_pm_enter)(void __iomem *sdram_reg, u32 srcmd))
+int __init mvebu_pm_init(void (*board_pm_enter)(void __iomem *sdram_reg, u32 srcmd))
{
struct device_node *np;
struct resource res;
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 2/4] ARM: mvebu: Add standby support
2015-07-03 11:55 [PATCH v3 0/4] Add standby support for the recent mvebu SoCs Gregory CLEMENT
2015-07-03 11:55 ` [PATCH v3 1/4] ARM: mvebu: Use __init for the PM initialization functions Gregory CLEMENT
@ 2015-07-03 11:55 ` Gregory CLEMENT
2015-07-03 11:55 ` [PATCH v3 3/4] ARM: mvebu: Allow using the GIC for wakeup in standby mode Gregory CLEMENT
2015-07-03 11:55 ` [PATCH v3 4/4] ARM: mvebu: Warn about the wake-up sources not taken into account in suspend Gregory CLEMENT
3 siblings, 0 replies; 6+ messages in thread
From: Gregory CLEMENT @ 2015-07-03 11:55 UTC (permalink / raw)
To: Jason Cooper, Andrew Lunn, Sebastian Hesselbarth, Gregory CLEMENT
Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
Maxime Ripard, Boris BREZILLON, Lior Amsalem, Tawfik Bayouk,
Nadav Haklai, linux-pm, linux-kernel
Until now only one Armada XP and one Armada 388 based board supported
suspend to ram. However, most of the recent mvebu SoCs can support the
standby mode. Unlike for the suspend to ram, nothing special has to be
done for these SoCs. This patch allows the system to use the standby
mode on Armada 370, 38x, 39x and XP SoCs. There are issues with the
Armada 375, and the support might be added (if possible) in a future
patch.
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
arch/arm/mach-mvebu/common.h | 4 ++--
arch/arm/mach-mvebu/pm-board.c | 12 ++++++++--
arch/arm/mach-mvebu/pm.c | 52 +++++++++++++++++++++++++++++++++++-------
3 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/arch/arm/mach-mvebu/common.h b/arch/arm/mach-mvebu/common.h
index 3e0aca1f288a..6b775492cfad 100644
--- a/arch/arm/mach-mvebu/common.h
+++ b/arch/arm/mach-mvebu/common.h
@@ -25,6 +25,6 @@ int mvebu_system_controller_get_soc_id(u32 *dev, u32 *rev);
void __iomem *mvebu_get_scu_base(void);
-int mvebu_pm_init(void (*board_pm_enter)(void __iomem *sdram_reg, u32 srcmd));
-
+int mvebu_pm_suspend_init(void (*board_pm_enter)(void __iomem *sdram_reg,
+ u32 srcmd));
#endif
diff --git a/arch/arm/mach-mvebu/pm-board.c b/arch/arm/mach-mvebu/pm-board.c
index acc69e369c8b..16a4b480c16a 100644
--- a/arch/arm/mach-mvebu/pm-board.c
+++ b/arch/arm/mach-mvebu/pm-board.c
@@ -135,11 +135,19 @@ static int __init mvebu_armada_pm_init(void)
if (!gpio_ctrl)
return -ENOMEM;
- mvebu_pm_init(mvebu_armada_pm_enter);
+ mvebu_pm_suspend_init(mvebu_armada_pm_enter);
out:
of_node_put(np);
return ret;
}
-late_initcall(mvebu_armada_pm_init);
+/*
+ * Registering the mvebu_board_pm_enter callback must be done before
+ * the platform_suspend_ops will be registered. In the same time we
+ * also need to have the gpio devices registered. That's why we use a
+ * device_initcall_sync which is called after all the device_initcall
+ * (used by the gpio device) but before the late_initcall (used to
+ * register the platform_suspend_ops)
+ */
+device_initcall_sync(mvebu_armada_pm_init);
diff --git a/arch/arm/mach-mvebu/pm.c b/arch/arm/mach-mvebu/pm.c
index f249c8e04bd4..db31cbb6e2c8 100644
--- a/arch/arm/mach-mvebu/pm.c
+++ b/arch/arm/mach-mvebu/pm.c
@@ -204,13 +204,10 @@ static int mvebu_pm_store_bootinfo(void)
return 0;
}
-static int mvebu_pm_enter(suspend_state_t state)
+static int mvebu_enter_suspend(void)
{
int ret;
- if (state != PM_SUSPEND_MEM)
- return -EINVAL;
-
ret = mvebu_pm_store_bootinfo();
if (ret)
return ret;
@@ -226,16 +223,57 @@ static int mvebu_pm_enter(suspend_state_t state)
set_cpu_coherent();
cpu_pm_exit();
+ return 0;
+}
+
+static int mvebu_pm_enter(suspend_state_t state)
+{
+ switch (state) {
+ case PM_SUSPEND_STANDBY:
+ cpu_do_idle();
+ break;
+ case PM_SUSPEND_MEM:
+ return mvebu_enter_suspend();
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static int mvebu_pm_valid(suspend_state_t state)
+{
+ if (state == PM_SUSPEND_STANDBY)
+ return 1;
+
+ if (state == PM_SUSPEND_MEM && mvebu_board_pm_enter != NULL)
+ return 1;
return 0;
}
static const struct platform_suspend_ops mvebu_pm_ops = {
.enter = mvebu_pm_enter,
- .valid = suspend_valid_only_mem,
+ .valid = mvebu_pm_valid,
};
-int __init mvebu_pm_init(void (*board_pm_enter)(void __iomem *sdram_reg, u32 srcmd))
+static int __init mvebu_pm_init(void)
+{
+ if (!of_machine_is_compatible("marvell,armadaxp") &&
+ !of_machine_is_compatible("marvell,armada370") &&
+ !of_machine_is_compatible("marvell,armada380") &&
+ !of_machine_is_compatible("marvell,armada390"))
+ return -ENODEV;
+
+ suspend_set_ops(&mvebu_pm_ops);
+
+ return 0;
+}
+
+
+late_initcall(mvebu_pm_init);
+
+int __init mvebu_pm_suspend_init(void (*board_pm_enter)(void __iomem *sdram_reg,
+ u32 srcmd))
{
struct device_node *np;
struct resource res;
@@ -267,7 +305,5 @@ int __init mvebu_pm_init(void (*board_pm_enter)(void __iomem *sdram_reg, u32 src
mvebu_board_pm_enter = board_pm_enter;
- suspend_set_ops(&mvebu_pm_ops);
-
return 0;
}
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 3/4] ARM: mvebu: Allow using the GIC for wakeup in standby mode
2015-07-03 11:55 [PATCH v3 0/4] Add standby support for the recent mvebu SoCs Gregory CLEMENT
2015-07-03 11:55 ` [PATCH v3 1/4] ARM: mvebu: Use __init for the PM initialization functions Gregory CLEMENT
2015-07-03 11:55 ` [PATCH v3 2/4] ARM: mvebu: Add standby support Gregory CLEMENT
@ 2015-07-03 11:55 ` Gregory CLEMENT
2015-07-28 9:41 ` Gregory CLEMENT
2015-07-03 11:55 ` [PATCH v3 4/4] ARM: mvebu: Warn about the wake-up sources not taken into account in suspend Gregory CLEMENT
3 siblings, 1 reply; 6+ messages in thread
From: Gregory CLEMENT @ 2015-07-03 11:55 UTC (permalink / raw)
To: Jason Cooper, Andrew Lunn, Sebastian Hesselbarth, Gregory CLEMENT
Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
Maxime Ripard, Boris BREZILLON, Lior Amsalem, Tawfik Bayouk,
Nadav Haklai, linux-pm, linux-kernel
On the Armada 375/38x/39x SoCs, in standby mode the SoCs stay powered
and it is possible to wake-up from any interrupt sources. This patch
adds flag to the GIC irqchip driver to let linux know this.
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
arch/arm/mach-mvebu/board-v7.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c
index e5911defccac..b789f7037445 100644
--- a/arch/arm/mach-mvebu/board-v7.c
+++ b/arch/arm/mach-mvebu/board-v7.c
@@ -18,6 +18,7 @@
#include <linux/of_address.h>
#include <linux/of_fdt.h>
#include <linux/of_platform.h>
+#include <linux/irq.h>
#include <linux/io.h>
#include <linux/clocksource.h>
#include <linux/dma-mapping.h>
@@ -26,6 +27,7 @@
#include <linux/signal.h>
#include <linux/slab.h>
#include <linux/irqchip.h>
+#include <linux/irqchip/arm-gic.h>
#include <asm/hardware/cache-l2x0.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
@@ -129,6 +131,13 @@ static int armada_375_external_abort_wa(unsigned long addr, unsigned int fsr,
static void __init mvebu_init_irq(void)
{
+ struct device_node *np;
+
+ np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-gic");
+ if (np)
+ gic_set_irqchip_flags(IRQCHIP_SKIP_SET_WAKE |
+ IRQCHIP_MASK_ON_SUSPEND);
+ of_node_put(np);
irqchip_init();
mvebu_scu_enable();
coherency_init();
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v3 3/4] ARM: mvebu: Allow using the GIC for wakeup in standby mode
2015-07-03 11:55 ` [PATCH v3 3/4] ARM: mvebu: Allow using the GIC for wakeup in standby mode Gregory CLEMENT
@ 2015-07-28 9:41 ` Gregory CLEMENT
0 siblings, 0 replies; 6+ messages in thread
From: Gregory CLEMENT @ 2015-07-28 9:41 UTC (permalink / raw)
To: linux-pm
Cc: Jason Cooper, Andrew Lunn, Sebastian Hesselbarth,
Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
Maxime Ripard, Boris BREZILLON, Lior Amsalem, Tawfik Bayouk,
Nadav Haklai, linux-kernel
Hi,
On 03/07/2015 13:55, Gregory CLEMENT wrote:
> On the Armada 375/38x/39x SoCs, in standby mode the SoCs stay powered
> and it is possible to wake-up from any interrupt sources. This patch
> adds flag to the GIC irqchip driver to let linux know this.
>
> Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
I eventually remove this patch, as now these two flags are part of the GIC driver:
https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=irq/core&id=0d3f2c92e004c67404fabea19728c1962b777bd6
Gregory
> ---
> arch/arm/mach-mvebu/board-v7.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c
> index e5911defccac..b789f7037445 100644
> --- a/arch/arm/mach-mvebu/board-v7.c
> +++ b/arch/arm/mach-mvebu/board-v7.c
> @@ -18,6 +18,7 @@
> #include <linux/of_address.h>
> #include <linux/of_fdt.h>
> #include <linux/of_platform.h>
> +#include <linux/irq.h>
> #include <linux/io.h>
> #include <linux/clocksource.h>
> #include <linux/dma-mapping.h>
> @@ -26,6 +27,7 @@
> #include <linux/signal.h>
> #include <linux/slab.h>
> #include <linux/irqchip.h>
> +#include <linux/irqchip/arm-gic.h>
> #include <asm/hardware/cache-l2x0.h>
> #include <asm/mach/arch.h>
> #include <asm/mach/map.h>
> @@ -129,6 +131,13 @@ static int armada_375_external_abort_wa(unsigned long addr, unsigned int fsr,
>
> static void __init mvebu_init_irq(void)
> {
> + struct device_node *np;
> +
> + np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-gic");
> + if (np)
> + gic_set_irqchip_flags(IRQCHIP_SKIP_SET_WAKE |
> + IRQCHIP_MASK_ON_SUSPEND);
> + of_node_put(np);
> irqchip_init();
> mvebu_scu_enable();
> coherency_init();
>
--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 4/4] ARM: mvebu: Warn about the wake-up sources not taken into account in suspend
2015-07-03 11:55 [PATCH v3 0/4] Add standby support for the recent mvebu SoCs Gregory CLEMENT
` (2 preceding siblings ...)
2015-07-03 11:55 ` [PATCH v3 3/4] ARM: mvebu: Allow using the GIC for wakeup in standby mode Gregory CLEMENT
@ 2015-07-03 11:55 ` Gregory CLEMENT
3 siblings, 0 replies; 6+ messages in thread
From: Gregory CLEMENT @ 2015-07-03 11:55 UTC (permalink / raw)
To: Jason Cooper, Andrew Lunn, Sebastian Hesselbarth, Gregory CLEMENT
Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
Maxime Ripard, Boris BREZILLON, Lior Amsalem, Tawfik Bayouk,
Nadav Haklai, linux-pm, linux-kernel
On the Armada 370/XP/38x/39x SoCs when the suspend to ram feature is
supported, the SoCs are shutdown and will be woken up by an external
micro-controller, so there is no possibility to setup wake-up sources
from Linux. However, in standby mode, the SoCs stay powered and it is
possible to wake-up from any interrupt sources. Since when the users
configures the enabled wake-up sources there is no way to know if the
user will be doing suspend to RAM or standby, we just allow all
wake-up sources to be enabled, and only warn when entering suspend to
RAM
The purpose of this patch is to inform the user that in suspend to ram
mode, the wake-up sources won't be taken into consideration.
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
arch/arm/mach-mvebu/pm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/mach-mvebu/pm.c b/arch/arm/mach-mvebu/pm.c
index db31cbb6e2c8..14c7d9d7d973 100644
--- a/arch/arm/mach-mvebu/pm.c
+++ b/arch/arm/mach-mvebu/pm.c
@@ -233,6 +233,7 @@ static int mvebu_pm_enter(suspend_state_t state)
cpu_do_idle();
break;
case PM_SUSPEND_MEM:
+ pr_warn("Entering suspend to RAM. Only special wake-up sources will resume the system\n");
return mvebu_enter_suspend();
default:
return -EINVAL;
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread