build/patch/kernel/archive/sunxi-6.5/patches.megous/ARM-sunxi-Add-experimental-suspend-to-memory-implementation-for.patch

89 lines
2.2 KiB
Diff

From 547abe1ddd89f9bbc3547f97e852f6f214a2b77f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Wed, 23 Oct 2019 05:06:29 +0200
Subject: [PATCH 028/464] ARM: sunxi: Add experimental suspend to memory
implementation for A83T
This just ends with WFI, but all secondary CPUs will be shut down.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
arch/arm/mach-sunxi/sunxi.c | 46 +++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/arch/arm/mach-sunxi/sunxi.c b/arch/arm/mach-sunxi/sunxi.c
index e1b7945aac99..2d6b7b4528e9 100644
--- a/arch/arm/mach-sunxi/sunxi.c
+++ b/arch/arm/mach-sunxi/sunxi.c
@@ -12,10 +12,13 @@
#include <linux/init.h>
#include <linux/of_clk.h>
#include <linux/platform_device.h>
+#include <linux/of_platform.h>
#include <linux/reset/sunxi.h>
+#include <linux/suspend.h>
#include <asm/mach/arch.h>
#include <asm/secure_cntvoff.h>
+#include <asm/suspend.h>
static const char * const sunxi_board_dt_compat[] = {
"allwinner,sun4i-a10",
@@ -86,10 +89,53 @@ static const char * const sun8i_a83t_cntvoff_board_dt_compat[] = {
NULL,
};
+#ifdef CONFIG_PM_SLEEP
+static int sun8i_a83t_pm_valid(suspend_state_t state)
+{
+ return state == PM_SUSPEND_MEM;
+}
+
+static int sun8i_a83t_suspend_finish(unsigned long val)
+{
+ // don't do much
+ cpu_do_idle();
+ return 0;
+}
+
+static int sun8i_a83t_pm_enter(suspend_state_t state)
+{
+ switch (state) {
+ case PM_SUSPEND_MEM:
+ cpu_suspend(0, sun8i_a83t_suspend_finish);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static const struct platform_suspend_ops sun8i_a83t_pm_ops = {
+ .enter = sun8i_a83t_pm_enter,
+ .valid = sun8i_a83t_pm_valid,
+};
+#define SUN8I_A83T_PM_OPS &sun8i_a83t_pm_ops
+#else
+#define SUN8I_A83T_PM_OPS NULL
+#endif
+
+static void __init sun8i_a83t_init_machine(void)
+{
+ suspend_set_ops(SUN8I_A83T_PM_OPS);
+
+ of_platform_default_populate(NULL, NULL, NULL);
+}
+
DT_MACHINE_START(SUN8I_A83T_CNTVOFF_DT, "Allwinner A83t board")
.init_early = sun8i_a83t_cntvoff_init,
.init_time = sun6i_timer_init,
.dt_compat = sun8i_a83t_cntvoff_board_dt_compat,
+ .init_machine = sun8i_a83t_init_machine,
MACHINE_END
static const char * const sun9i_board_dt_compat[] = {
--
2.34.1