summaryrefslogtreecommitdiffstats
path: root/configs/platform-energymicro-efm32gg-dk3750/patches/linux-3.11-rc1/0009-ARM-efm32-add-trivial-suspend-support.patch
blob: f11ea68613e32efa64ed69c5880ce38537dd3740 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
Date: Wed, 1 Feb 2012 10:00:21 +0100
Subject: [PATCH] ARM: efm32: add trivial suspend support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/mach-efm32/Makefile |  2 ++
 arch/arm/mach-efm32/pm.c     | 50 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 arch/arm/mach-efm32/pm.c

diff --git a/arch/arm/mach-efm32/Makefile b/arch/arm/mach-efm32/Makefile
index d70b093..a7f1102 100644
--- a/arch/arm/mach-efm32/Makefile
+++ b/arch/arm/mach-efm32/Makefile
@@ -1 +1,3 @@
 obj-y += clk.o common.o dtmachine.o time.o
+
+obj-$(CONFIG_PM) += pm.o
diff --git a/arch/arm/mach-efm32/pm.c b/arch/arm/mach-efm32/pm.c
new file mode 100644
index 0000000..282205e
--- /dev/null
+++ b/arch/arm/mach-efm32/pm.c
@@ -0,0 +1,50 @@
+#include <linux/init.h>
+#include <linux/suspend.h>
+
+#include <asm/io.h>
+#include <asm/v7m.h>
+
+#include "cmu.h"
+
+#define CMU_BASE IOMEM(0x400c8000)
+
+#define scb_writel(val, addroff)	writel(val, BASEADDR_V7M_SCB + addroff)
+
+static int efm32_suspend_enter(suspend_state_t state)
+{
+	u32 cmu_status = readl(CMU_BASE + CMU_STATUS);
+
+	/*
+	 * setting SLEEPDEEP makes the efm32 enter EM2 or EM3 (iff both
+	 * LFACLK and LFBCLK are off).
+	 */
+	scb_writel(V7M_SCB_SCR_SLEEPDEEP, V7M_SCB_SCR);
+
+	cpu_do_idle();
+
+	scb_writel(0, V7M_SCB_SCR);
+
+	/*
+	 * deep sleep disables the HF oscilator, reenable it if it was on
+	 * before.
+	 */
+	if (cmu_status & CMU_STATUS_HFXOSEL) {
+		writel(CMU_OSCENCMD_HFXOEN, CMU_BASE + CMU_OSCENCMD);
+		writel(CMU_CMD_HFCLKSEL_HFXO, CMU_BASE + CMU_CMD);
+	}
+
+	return 0;
+}
+
+static const struct platform_suspend_ops efm32_suspend_ops = {
+	.valid = suspend_valid_only_mem,
+	.enter = efm32_suspend_enter,
+};
+
+static int __init efm32_pm_init(void)
+{
+	suspend_set_ops(&efm32_suspend_ops);
+
+	return 0;
+}
+arch_initcall(efm32_pm_init);