blob: d40fede8c9b3408dbf4e62b8cb35ab076d4b0d64 [file] [log] [blame]
Magnus Damm7f627f02012-05-16 15:44:58 +09001/*
2 * Emma Mobile EV2 processor support
3 *
4 * Copyright (C) 2012 Magnus Damm
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/platform_device.h>
Magnus Damm088efd92012-05-16 15:45:34 +090024#include <linux/platform_data/gpio-em.h>
Magnus Damm7f627f02012-05-16 15:44:58 +090025#include <linux/delay.h>
26#include <linux/input.h>
27#include <linux/io.h>
28#include <mach/hardware.h>
29#include <mach/common.h>
30#include <mach/emev2.h>
31#include <mach/irqs.h>
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/map.h>
35#include <asm/mach/time.h>
36#include <asm/hardware/gic.h>
37
Magnus Dammbd5a8752012-05-16 15:45:25 +090038static struct map_desc emev2_io_desc[] __initdata = {
39#ifdef CONFIG_SMP
40 /* 128K entity map for 0xe0100000 (SMU) */
41 {
42 .virtual = 0xe0100000,
43 .pfn = __phys_to_pfn(0xe0100000),
44 .length = SZ_128K,
45 .type = MT_DEVICE
46 },
47 /* 2M mapping for SCU + L2 controller */
48 {
49 .virtual = 0xf0000000,
50 .pfn = __phys_to_pfn(0x1e000000),
51 .length = SZ_2M,
52 .type = MT_DEVICE
53 },
54#endif
55};
56
57void __init emev2_map_io(void)
58{
59 iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc));
60}
61
Magnus Damm7f627f02012-05-16 15:44:58 +090062/* UART */
63static struct resource uart0_resources[] = {
64 [0] = {
65 .start = 0xe1020000,
66 .end = 0xe1020037,
67 .flags = IORESOURCE_MEM,
68 },
69 [1] = {
70 .start = 40,
71 .flags = IORESOURCE_IRQ,
72 }
73};
74
75static struct platform_device uart0_device = {
76 .name = "serial8250-em",
77 .id = 0,
78 .num_resources = ARRAY_SIZE(uart0_resources),
79 .resource = uart0_resources,
80};
81
82static struct resource uart1_resources[] = {
83 [0] = {
84 .start = 0xe1030000,
85 .end = 0xe1030037,
86 .flags = IORESOURCE_MEM,
87 },
88 [1] = {
89 .start = 41,
90 .flags = IORESOURCE_IRQ,
91 }
92};
93
94static struct platform_device uart1_device = {
95 .name = "serial8250-em",
96 .id = 1,
97 .num_resources = ARRAY_SIZE(uart1_resources),
98 .resource = uart1_resources,
99};
100
101static struct resource uart2_resources[] = {
102 [0] = {
103 .start = 0xe1040000,
104 .end = 0xe1040037,
105 .flags = IORESOURCE_MEM,
106 },
107 [1] = {
108 .start = 42,
109 .flags = IORESOURCE_IRQ,
110 }
111};
112
113static struct platform_device uart2_device = {
114 .name = "serial8250-em",
115 .id = 2,
116 .num_resources = ARRAY_SIZE(uart2_resources),
117 .resource = uart2_resources,
118};
119
120static struct resource uart3_resources[] = {
121 [0] = {
122 .start = 0xe1050000,
123 .end = 0xe1050037,
124 .flags = IORESOURCE_MEM,
125 },
126 [1] = {
127 .start = 43,
128 .flags = IORESOURCE_IRQ,
129 }
130};
131
132static struct platform_device uart3_device = {
133 .name = "serial8250-em",
134 .id = 3,
135 .num_resources = ARRAY_SIZE(uart3_resources),
136 .resource = uart3_resources,
137};
138
139/* STI */
140static struct resource sti_resources[] = {
141 [0] = {
142 .name = "STI",
143 .start = 0xe0180000,
144 .end = 0xe0180053,
145 .flags = IORESOURCE_MEM,
146 },
147 [1] = {
148 .start = 157,
149 .flags = IORESOURCE_IRQ,
150 },
151};
152
153static struct platform_device sti_device = {
154 .name = "em_sti",
155 .id = 0,
156 .resource = sti_resources,
157 .num_resources = ARRAY_SIZE(sti_resources),
158};
159
Magnus Damm088efd92012-05-16 15:45:34 +0900160
161/* GIO */
162static struct gpio_em_config gio0_config = {
163 .gpio_base = 0,
164 .irq_base = EMEV2_GPIO_IRQ(0),
165 .number_of_pins = 32,
166};
167
168static struct resource gio0_resources[] = {
169 [0] = {
170 .name = "GIO_000",
171 .start = 0xe0050000,
172 .end = 0xe005002b,
173 .flags = IORESOURCE_MEM,
174 },
175 [1] = {
176 .name = "GIO_000",
177 .start = 0xe0050040,
178 .end = 0xe005005f,
179 .flags = IORESOURCE_MEM,
180 },
181 [2] = {
182 .start = 99,
183 .flags = IORESOURCE_IRQ,
184 },
185 [3] = {
186 .start = 100,
187 .flags = IORESOURCE_IRQ,
188 },
189};
190
191static struct platform_device gio0_device = {
192 .name = "em_gio",
193 .id = 0,
194 .resource = gio0_resources,
195 .num_resources = ARRAY_SIZE(gio0_resources),
196 .dev = {
197 .platform_data = &gio0_config,
198 },
199};
200
201static struct gpio_em_config gio1_config = {
202 .gpio_base = 32,
203 .irq_base = EMEV2_GPIO_IRQ(32),
204 .number_of_pins = 32,
205};
206
207static struct resource gio1_resources[] = {
208 [0] = {
209 .name = "GIO_032",
210 .start = 0xe0050080,
211 .end = 0xe00500ab,
212 .flags = IORESOURCE_MEM,
213 },
214 [1] = {
215 .name = "GIO_032",
216 .start = 0xe00500c0,
217 .end = 0xe00500df,
218 .flags = IORESOURCE_MEM,
219 },
220 [2] = {
221 .start = 101,
222 .flags = IORESOURCE_IRQ,
223 },
224 [3] = {
225 .start = 102,
226 .flags = IORESOURCE_IRQ,
227 },
228};
229
230static struct platform_device gio1_device = {
231 .name = "em_gio",
232 .id = 1,
233 .resource = gio1_resources,
234 .num_resources = ARRAY_SIZE(gio1_resources),
235 .dev = {
236 .platform_data = &gio1_config,
237 },
238};
239
240static struct gpio_em_config gio2_config = {
241 .gpio_base = 64,
242 .irq_base = EMEV2_GPIO_IRQ(64),
243 .number_of_pins = 32,
244};
245
246static struct resource gio2_resources[] = {
247 [0] = {
248 .name = "GIO_064",
249 .start = 0xe0050100,
250 .end = 0xe005012b,
251 .flags = IORESOURCE_MEM,
252 },
253 [1] = {
254 .name = "GIO_064",
255 .start = 0xe0050140,
256 .end = 0xe005015f,
257 .flags = IORESOURCE_MEM,
258 },
259 [2] = {
260 .start = 103,
261 .flags = IORESOURCE_IRQ,
262 },
263 [3] = {
264 .start = 104,
265 .flags = IORESOURCE_IRQ,
266 },
267};
268
269static struct platform_device gio2_device = {
270 .name = "em_gio",
271 .id = 2,
272 .resource = gio2_resources,
273 .num_resources = ARRAY_SIZE(gio2_resources),
274 .dev = {
275 .platform_data = &gio2_config,
276 },
277};
278
279static struct gpio_em_config gio3_config = {
280 .gpio_base = 96,
281 .irq_base = EMEV2_GPIO_IRQ(96),
282 .number_of_pins = 32,
283};
284
285static struct resource gio3_resources[] = {
286 [0] = {
287 .name = "GIO_096",
288 .start = 0xe0050100,
289 .end = 0xe005012b,
290 .flags = IORESOURCE_MEM,
291 },
292 [1] = {
293 .name = "GIO_096",
294 .start = 0xe0050140,
295 .end = 0xe005015f,
296 .flags = IORESOURCE_MEM,
297 },
298 [2] = {
299 .start = 105,
300 .flags = IORESOURCE_IRQ,
301 },
302 [3] = {
303 .start = 106,
304 .flags = IORESOURCE_IRQ,
305 },
306};
307
308static struct platform_device gio3_device = {
309 .name = "em_gio",
310 .id = 3,
311 .resource = gio3_resources,
312 .num_resources = ARRAY_SIZE(gio3_resources),
313 .dev = {
314 .platform_data = &gio3_config,
315 },
316};
317
318static struct gpio_em_config gio4_config = {
319 .gpio_base = 128,
320 .irq_base = EMEV2_GPIO_IRQ(128),
321 .number_of_pins = 31,
322};
323
324static struct resource gio4_resources[] = {
325 [0] = {
326 .name = "GIO_128",
327 .start = 0xe0050200,
328 .end = 0xe005022b,
329 .flags = IORESOURCE_MEM,
330 },
331 [1] = {
332 .name = "GIO_128",
333 .start = 0xe0050240,
334 .end = 0xe005025f,
335 .flags = IORESOURCE_MEM,
336 },
337 [2] = {
338 .start = 107,
339 .flags = IORESOURCE_IRQ,
340 },
341 [3] = {
342 .start = 108,
343 .flags = IORESOURCE_IRQ,
344 },
345};
346
347static struct platform_device gio4_device = {
348 .name = "em_gio",
349 .id = 4,
350 .resource = gio4_resources,
351 .num_resources = ARRAY_SIZE(gio4_resources),
352 .dev = {
353 .platform_data = &gio4_config,
354 },
355};
356
Magnus Damm7f627f02012-05-16 15:44:58 +0900357static struct platform_device *emev2_early_devices[] __initdata = {
358 &uart0_device,
359 &uart1_device,
360 &uart2_device,
361 &uart3_device,
362};
363
364static struct platform_device *emev2_late_devices[] __initdata = {
365 &sti_device,
Magnus Damm088efd92012-05-16 15:45:34 +0900366 &gio0_device,
367 &gio1_device,
368 &gio2_device,
369 &gio3_device,
370 &gio4_device,
Magnus Damm7f627f02012-05-16 15:44:58 +0900371};
372
373void __init emev2_add_standard_devices(void)
374{
375 emev2_clock_init();
376
377 platform_add_devices(emev2_early_devices,
378 ARRAY_SIZE(emev2_early_devices));
379
380 platform_add_devices(emev2_late_devices,
381 ARRAY_SIZE(emev2_late_devices));
382}
383
384void __init emev2_add_early_devices(void)
385{
386 shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */
387
388 early_platform_add_devices(emev2_early_devices,
389 ARRAY_SIZE(emev2_early_devices));
390
391 /* setup early console here as well */
392 shmobile_setup_console();
393}
394
395void __init emev2_init_irq(void)
396{
397 void __iomem *gic_dist_base;
398 void __iomem *gic_cpu_base;
399
400 /* Static mappings, never released */
401 gic_dist_base = ioremap(0xe0028000, PAGE_SIZE);
402 gic_cpu_base = ioremap(0xe0020000, PAGE_SIZE);
403 BUG_ON(!gic_dist_base || !gic_cpu_base);
404
405 /* Use GIC to handle interrupts */
406 gic_init(0, 29, gic_dist_base, gic_cpu_base);
407}