summaryrefslogtreecommitdiffstats
path: root/patches/linux-3.11-rc1/0005-ARM-efm32-some-more-stuff.patch
blob: 90ddbf39df3e728089f3dd2c3a5968aa75d27da9 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
Date: Tue, 12 Mar 2013 14:44:10 +0100
Subject: [PATCH] ARM: efm32: some more stuff
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/Kconfig-nommu          |   4 +
 arch/arm/mach-efm32/Makefile    |   2 +-
 arch/arm/mach-efm32/common.c    | 207 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-efm32/common.h    |   7 ++
 arch/arm/mach-efm32/dtmachine.c |   7 ++
 5 files changed, 226 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-efm32/common.c

diff --git a/arch/arm/Kconfig-nommu b/arch/arm/Kconfig-nommu
index aed66d5..6128083 100644
--- a/arch/arm/Kconfig-nommu
+++ b/arch/arm/Kconfig-nommu
@@ -11,18 +11,22 @@ config SET_MEM_PARAM
 
 config DRAM_BASE
 	hex '(S)DRAM Base Address' if SET_MEM_PARAM
+	default 0x88000000 if MACH_EFM32GG_DK3750
 	default 0x00800000
 
 config DRAM_SIZE
 	hex '(S)DRAM SIZE' if SET_MEM_PARAM
+	default 0x00400000 if MACH_EFM32GG_DK3750
 	default 0x00800000
 
 config FLASH_MEM_BASE
 	hex 'FLASH Base Address' if SET_MEM_PARAM
+	default 0x00000000 if MACH_EFM32GG_DK3750
 	default 0x00400000
 
 config FLASH_SIZE
 	hex 'FLASH Size' if SET_MEM_PARAM
+	default 0x00100000 if MACH_EFM32GG_DK3750
 	default 0x00400000
 
 config PROCESSOR_ID
diff --git a/arch/arm/mach-efm32/Makefile b/arch/arm/mach-efm32/Makefile
index c6786a0..d70b093 100644
--- a/arch/arm/mach-efm32/Makefile
+++ b/arch/arm/mach-efm32/Makefile
@@ -1 +1 @@
-obj-y += clk.o dtmachine.o time.o
+obj-y += clk.o common.o dtmachine.o time.o
diff --git a/arch/arm/mach-efm32/common.c b/arch/arm/mach-efm32/common.c
new file mode 100644
index 0000000..cb073ba
--- /dev/null
+++ b/arch/arm/mach-efm32/common.c
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2012 Uwe Kleine-Koenig for Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#include <linux/kernel.h>
+#include <linux/bug.h>
+#include <linux/init.h>
+
+#include <asm/io.h>
+#include <asm/barrier.h>
+
+#include "common.h"
+
+/* move this somewhere else */
+void cm3_restart(char mode, const char *cmd)
+{
+	dsb();
+	__raw_writel(0x05fa0004, (void __iomem *)0xe000ed0c);
+	dsb();
+}
+
+#define MEM_INFO_FLASH		(void __iomem *)0x0fe081f8
+#define MEM_INFO_RAM		(void __iomem *)0x0fe081fa
+#define PART_NUMBER		(void __iomem *)0x0fe081fc
+#define PART_FAMILY		(void __iomem *)0x0fe081fe
+#define PROD_REV		(void __iomem *)0x0fe081ff
+
+static const struct efm32_family_mapping {
+	u8 id;
+	const char *name;
+	const char *abbrev;
+} efm32_family_mapping[] __initconst = {
+	{
+		.id = 71,
+		.name = "Gecko",
+		.abbrev = "G",
+	}, {
+		.id = 72,
+		.name = "Giant Gecko",
+		.abbrev = "GG",
+	}, {
+		.id = 73,
+		.name = "Tiny Gecko",
+		.abbrev = "TG",
+	}, {
+		.id = 74,
+		.name = "Leopard Gecko",
+		.abbrev = "LG",
+	}, {
+		.id = 75,
+		.name = "Zero Gecko",
+		.abbrev = "ZG",
+	},
+};
+
+static const char *__init efm32_get_familyname(u8 id)
+{
+	size_t i;
+
+	for (i = 0; i < ARRAY_SIZE(efm32_family_mapping) &&
+			efm32_family_mapping[i].id <= id; ++i) {
+		if (efm32_family_mapping[i].id == id)
+			return efm32_family_mapping[i].name;
+	}
+
+	return "unknown";
+}
+
+static const char *__init efm32_get_familyabbrev(u8 id)
+{
+	size_t i;
+
+	for (i = 0; i < ARRAY_SIZE(efm32_family_mapping) &&
+			efm32_family_mapping[i].id <= id; ++i) {
+		if (efm32_family_mapping[i].id == id)
+			return efm32_family_mapping[i].abbrev;
+	}
+
+	return "unknown";
+}
+
+static char revbuf[4] __initdata = "";
+static volatile const u32 * const romtable = (void *)0xe00fffe0;
+
+static const char *__init efm32_get_rev(void)
+{
+	if (revbuf[0] == '\0') {
+		u32 major = romtable[0] & 0x3f;
+		u32 minor = (romtable[2] & 0xf0) | ((romtable[3] >> 4) & 0x0f);
+
+		if (minor < 25)
+			sprintf(revbuf, "%u%c", major, 'A' + minor);
+		else {
+			revbuf[0] = '?';
+			revbuf[1] = '\0';
+		}
+	}
+	return revbuf;
+}
+
+void __init efm32_print_cpuinfo(void)
+{
+	u16 partno = __raw_readw(PART_NUMBER);
+	u8 family = __raw_readb(PART_FAMILY);
+	u8 rev = __raw_readb(PROD_REV);
+	u16 flashsize = __raw_readw(MEM_INFO_FLASH);
+	u16 raminfo = __raw_readw(MEM_INFO_RAM);
+
+	pr_info("Energy Micro %s, EFM32%s%hdF%hd (rev %s, prodrev %hhd), %hd kB RAM\n",
+			efm32_get_familyname(family),
+			efm32_get_familyabbrev(family), partno,
+			flashsize, efm32_get_rev(), rev, raminfo);
+}
+
+static const struct {
+	u32 value;
+	u32 mask;
+	const char *cause;
+} efm32_reset_causes[] = {
+	{
+		.value = 0x0001,
+		.mask = 0x0001,
+		.cause = "A Power-on Reset has been performed",
+	}, {
+		.value = 0x0002,
+		.mask = 0x0083,
+		.cause = "A Brown-out has been detected on the unregulated power",
+	}, {
+		.value = 0x0004,
+		.mask = 0x001f,
+		.cause = "A Brown-out has been detected on the regulated power",
+	}, {
+		.value = 0x0008,
+		.mask = 0x000b,
+		.cause = "An external reset has been applied",
+	}, {
+		.value = 0x0010,
+		.mask = 0x0013,
+		.cause = "A watchdog reset has occurred",
+	}, {
+		.value = 0x0020,
+		.mask = 0x07ff,
+		.cause = "A lockup reset has occurred",
+	}, {
+		.value = 0x0080,
+		.mask = 0x07df,
+		.cause = "A system request reset has occurred",
+	}, {
+		.value = 0x0080,
+		.mask = 0x0799,
+		.cause = "The system as woken up from EM4",
+	}, {
+		.value = 0x0180,
+		.mask = 0x799,
+		.cause = "The system as woken up from EM4 on an EM4 wakeup reset request from pin",
+	}, {
+		.value = 0x0200,
+		.mask = 0x079f,
+		.cause = "A Brown-out has been detected on Analog Power Domain 0 (AVDD0)",
+	}, {
+		.value = 0x0400,
+		.mask = 0x079f,
+		.cause = "A Brown-out has been detected on Analog Power Domain 1 (AVDD1)",
+	}, {
+		.value = 0x0800,
+		.mask = 0x0800,
+		.cause = "A Brown-out has been detected by the Backup BOD on VDD_DREG",
+	}, {
+		.value = 0x1000,
+		.mask = 0x1000,
+		.cause = "A Brown-out has been detected by the Backup BOD on BU_VIN",
+	}, {
+		.value = 0x2000,
+		.mask = 0x2000,
+		.cause = "A Brown-out has been detected by the Backup BOD on unregulated power",
+	}, {
+		.value= 0x4000,
+		.mask = 0x4000,
+		.cause = "A Brown-out has been detected by the Backup BOD on regulated power",
+	}, {
+		.value = 0x8000,
+		.mask = 0x8000,
+		.cause = "The system has been in Backup mode",
+	},
+};
+
+void __init efm32_print_reset_cause(void)
+{
+	u32 rmu_rstcause = __raw_readl((void __iomem *)0x400ca004);
+	int i;
+
+	pr_info("Reset Cause: 0x%08x\n", rmu_rstcause);
+
+	for (i = 0; i < ARRAY_SIZE(efm32_reset_causes); ++i) {
+		if ((rmu_rstcause & efm32_reset_causes[i].mask) ==
+				efm32_reset_causes[i].value)
+			pr_info(" `-> %s.\n", efm32_reset_causes[i].cause);
+	}
+
+	/* clear RMU_RSTCAUSE */
+	__raw_writel(1, (void __iomem *)0x400ca008);
+	__raw_writel(1, (void __iomem *)0x400c6024);
+	__raw_writel(0, (void __iomem *)0x400c6024);
+}
diff --git a/arch/arm/mach-efm32/common.h b/arch/arm/mach-efm32/common.h
index 8b04c19..96109b6 100644
--- a/arch/arm/mach-efm32/common.h
+++ b/arch/arm/mach-efm32/common.h
@@ -1,3 +1,10 @@
 void efm32_timer_init(void);
 
 void efm32_clk_init(void);
+
+/* XXX: find a better place for that */
+void cm3_restart(char mode, const char *cmd);
+
+void efm32_print_cpuinfo(void);
+
+void efm32_print_reset_cause(void);
diff --git a/arch/arm/mach-efm32/dtmachine.c b/arch/arm/mach-efm32/dtmachine.c
index 30fce6d..edad4c4 100644
--- a/arch/arm/mach-efm32/dtmachine.c
+++ b/arch/arm/mach-efm32/dtmachine.c
@@ -13,6 +13,13 @@
 static void __init efm32_init(void)
 {
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+
+	/*
+	 * Pinmuxing isn't specified in the device tree. Probably it's too heavy
+	 * considering that there is only 4 MiB of RAM
+	 */
+	//efm32gg990_add_efm32_pinctrl();
+	//pinmux_register_mappings(efm32_pinmux, ARRAY_SIZE(efm32_pinmux));
 }
 
 static const char *const efm32gg_compat[] __initconst = {