2 * Emma Mobile EV2 processor support
4 * Copyright (C) 2012 Magnus Damm
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.
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.
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
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>
24 #include <linux/platform_data/gpio-em.h>
25 #include <linux/of_platform.h>
26 #include <linux/delay.h>
27 #include <linux/input.h>
29 #include <linux/of_irq.h>
30 #include <mach/hardware.h>
31 #include <mach/common.h>
32 #include <mach/emev2.h>
33 #include <mach/irqs.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37 #include <asm/mach/time.h>
38 #include <asm/hardware/gic.h>
40 static struct map_desc emev2_io_desc[] __initdata = {
42 /* 128K entity map for 0xe0100000 (SMU) */
44 .virtual = 0xe0100000,
45 .pfn = __phys_to_pfn(0xe0100000),
49 /* 2M mapping for SCU + L2 controller */
51 .virtual = 0xf0000000,
52 .pfn = __phys_to_pfn(0x1e000000),
59 void __init emev2_map_io(void)
61 iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc));
65 static struct resource uart0_resources[] = {
69 .flags = IORESOURCE_MEM,
73 .flags = IORESOURCE_IRQ,
77 static struct platform_device uart0_device = {
78 .name = "serial8250-em",
80 .num_resources = ARRAY_SIZE(uart0_resources),
81 .resource = uart0_resources,
84 static struct resource uart1_resources[] = {
88 .flags = IORESOURCE_MEM,
92 .flags = IORESOURCE_IRQ,
96 static struct platform_device uart1_device = {
97 .name = "serial8250-em",
99 .num_resources = ARRAY_SIZE(uart1_resources),
100 .resource = uart1_resources,
103 static struct resource uart2_resources[] = {
107 .flags = IORESOURCE_MEM,
111 .flags = IORESOURCE_IRQ,
115 static struct platform_device uart2_device = {
116 .name = "serial8250-em",
118 .num_resources = ARRAY_SIZE(uart2_resources),
119 .resource = uart2_resources,
122 static struct resource uart3_resources[] = {
126 .flags = IORESOURCE_MEM,
130 .flags = IORESOURCE_IRQ,
134 static struct platform_device uart3_device = {
135 .name = "serial8250-em",
137 .num_resources = ARRAY_SIZE(uart3_resources),
138 .resource = uart3_resources,
142 static struct resource sti_resources[] = {
147 .flags = IORESOURCE_MEM,
151 .flags = IORESOURCE_IRQ,
155 static struct platform_device sti_device = {
158 .resource = sti_resources,
159 .num_resources = ARRAY_SIZE(sti_resources),
164 static struct gpio_em_config gio0_config = {
166 .irq_base = EMEV2_GPIO_IRQ(0),
167 .number_of_pins = 32,
170 static struct resource gio0_resources[] = {
175 .flags = IORESOURCE_MEM,
181 .flags = IORESOURCE_MEM,
185 .flags = IORESOURCE_IRQ,
189 .flags = IORESOURCE_IRQ,
193 static struct platform_device gio0_device = {
196 .resource = gio0_resources,
197 .num_resources = ARRAY_SIZE(gio0_resources),
199 .platform_data = &gio0_config,
203 static struct gpio_em_config gio1_config = {
205 .irq_base = EMEV2_GPIO_IRQ(32),
206 .number_of_pins = 32,
209 static struct resource gio1_resources[] = {
214 .flags = IORESOURCE_MEM,
220 .flags = IORESOURCE_MEM,
224 .flags = IORESOURCE_IRQ,
228 .flags = IORESOURCE_IRQ,
232 static struct platform_device gio1_device = {
235 .resource = gio1_resources,
236 .num_resources = ARRAY_SIZE(gio1_resources),
238 .platform_data = &gio1_config,
242 static struct gpio_em_config gio2_config = {
244 .irq_base = EMEV2_GPIO_IRQ(64),
245 .number_of_pins = 32,
248 static struct resource gio2_resources[] = {
253 .flags = IORESOURCE_MEM,
259 .flags = IORESOURCE_MEM,
263 .flags = IORESOURCE_IRQ,
267 .flags = IORESOURCE_IRQ,
271 static struct platform_device gio2_device = {
274 .resource = gio2_resources,
275 .num_resources = ARRAY_SIZE(gio2_resources),
277 .platform_data = &gio2_config,
281 static struct gpio_em_config gio3_config = {
283 .irq_base = EMEV2_GPIO_IRQ(96),
284 .number_of_pins = 32,
287 static struct resource gio3_resources[] = {
292 .flags = IORESOURCE_MEM,
298 .flags = IORESOURCE_MEM,
302 .flags = IORESOURCE_IRQ,
306 .flags = IORESOURCE_IRQ,
310 static struct platform_device gio3_device = {
313 .resource = gio3_resources,
314 .num_resources = ARRAY_SIZE(gio3_resources),
316 .platform_data = &gio3_config,
320 static struct gpio_em_config gio4_config = {
322 .irq_base = EMEV2_GPIO_IRQ(128),
323 .number_of_pins = 31,
326 static struct resource gio4_resources[] = {
331 .flags = IORESOURCE_MEM,
337 .flags = IORESOURCE_MEM,
341 .flags = IORESOURCE_IRQ,
345 .flags = IORESOURCE_IRQ,
349 static struct platform_device gio4_device = {
352 .resource = gio4_resources,
353 .num_resources = ARRAY_SIZE(gio4_resources),
355 .platform_data = &gio4_config,
359 static struct platform_device *emev2_early_devices[] __initdata = {
366 static struct platform_device *emev2_late_devices[] __initdata = {
375 void __init emev2_add_standard_devices(void)
379 platform_add_devices(emev2_early_devices,
380 ARRAY_SIZE(emev2_early_devices));
382 platform_add_devices(emev2_late_devices,
383 ARRAY_SIZE(emev2_late_devices));
386 void __init emev2_init_delay(void)
388 shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */
391 void __init emev2_add_early_devices(void)
395 early_platform_add_devices(emev2_early_devices,
396 ARRAY_SIZE(emev2_early_devices));
398 /* setup early console here as well */
399 shmobile_setup_console();
402 void __init emev2_init_irq(void)
404 void __iomem *gic_dist_base;
405 void __iomem *gic_cpu_base;
407 /* Static mappings, never released */
408 gic_dist_base = ioremap(0xe0028000, PAGE_SIZE);
409 gic_cpu_base = ioremap(0xe0020000, PAGE_SIZE);
410 BUG_ON(!gic_dist_base || !gic_cpu_base);
412 /* Use GIC to handle interrupts */
413 gic_init(0, 29, gic_dist_base, gic_cpu_base);
417 static const struct of_dev_auxdata emev2_auxdata_lookup[] __initconst = {
421 void __init emev2_add_standard_devices_dt(void)
423 of_platform_populate(NULL, of_default_bus_match_table,
424 emev2_auxdata_lookup, NULL);
427 static const struct of_device_id emev2_dt_irq_match[] = {
428 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
432 static const char *emev2_boards_compat_dt[] __initdata = {
437 void __init emev2_init_irq_dt(void)
439 of_irq_init(emev2_dt_irq_match);
442 DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
443 .init_early = emev2_init_delay,
444 .nr_irqs = NR_IRQS_LEGACY,
445 .init_irq = emev2_init_irq_dt,
446 .handle_irq = gic_handle_irq,
447 .init_machine = emev2_add_standard_devices_dt,
448 .timer = &shmobile_timer,
449 .dt_compat = emev2_boards_compat_dt,
452 #endif /* CONFIG_USE_OF */