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/irqchip/arm-gic.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>
39 static struct map_desc emev2_io_desc[] __initdata = {
41 /* 128K entity map for 0xe0100000 (SMU) */
43 .virtual = 0xe0100000,
44 .pfn = __phys_to_pfn(0xe0100000),
48 /* 2M mapping for SCU + L2 controller */
50 .virtual = 0xf0000000,
51 .pfn = __phys_to_pfn(0x1e000000),
58 void __init emev2_map_io(void)
60 iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc));
64 static struct resource uart0_resources[] = {
65 DEFINE_RES_MEM(0xe1020000, 0x38),
69 static struct resource uart1_resources[] = {
70 DEFINE_RES_MEM(0xe1030000, 0x38),
74 static struct resource uart2_resources[] = {
75 DEFINE_RES_MEM(0xe1040000, 0x38),
79 static struct resource uart3_resources[] = {
80 DEFINE_RES_MEM(0xe1050000, 0x38),
84 #define emev2_register_uart(idx) \
85 platform_device_register_simple("serial8250-em", idx, \
86 uart##idx##_resources, \
87 ARRAY_SIZE(uart##idx##_resources))
90 static struct resource sti_resources[] = {
91 DEFINE_RES_MEM(0xe0180000, 0x54),
95 #define emev2_register_sti() \
96 platform_device_register_simple("em_sti", 0, \
98 ARRAY_SIZE(sti_resources))
101 static struct gpio_em_config gio0_config = {
103 .irq_base = EMEV2_GPIO_IRQ(0),
104 .number_of_pins = 32,
107 static struct resource gio0_resources[] = {
108 DEFINE_RES_MEM(0xe0050000, 0x2c),
109 DEFINE_RES_MEM(0xe0050040, 0x20),
114 static struct gpio_em_config gio1_config = {
116 .irq_base = EMEV2_GPIO_IRQ(32),
117 .number_of_pins = 32,
120 static struct resource gio1_resources[] = {
121 DEFINE_RES_MEM(0xe0050080, 0x2c),
122 DEFINE_RES_MEM(0xe00500c0, 0x20),
127 static struct gpio_em_config gio2_config = {
129 .irq_base = EMEV2_GPIO_IRQ(64),
130 .number_of_pins = 32,
133 static struct resource gio2_resources[] = {
134 DEFINE_RES_MEM(0xe0050100, 0x2c),
135 DEFINE_RES_MEM(0xe0050140, 0x20),
140 static struct gpio_em_config gio3_config = {
142 .irq_base = EMEV2_GPIO_IRQ(96),
143 .number_of_pins = 32,
146 static struct resource gio3_resources[] = {
147 DEFINE_RES_MEM(0xe0050180, 0x2c),
148 DEFINE_RES_MEM(0xe00501c0, 0x20),
153 static struct gpio_em_config gio4_config = {
155 .irq_base = EMEV2_GPIO_IRQ(128),
156 .number_of_pins = 31,
159 static struct resource gio4_resources[] = {
160 DEFINE_RES_MEM(0xe0050200, 0x2c),
161 DEFINE_RES_MEM(0xe0050240, 0x20),
166 #define emev2_register_gio(idx) \
167 platform_device_register_resndata(&platform_bus, "em_gio", \
168 idx, gio##idx##_resources, \
169 ARRAY_SIZE(gio##idx##_resources), \
170 &gio##idx##_config, \
171 sizeof(struct gpio_em_config))
173 static struct resource pmu_resources[] = {
178 #define emev2_register_pmu() \
179 platform_device_register_simple("arm-pmu", -1, \
181 ARRAY_SIZE(pmu_resources))
183 void __init emev2_add_standard_devices(void)
187 emev2_register_uart(0);
188 emev2_register_uart(1);
189 emev2_register_uart(2);
190 emev2_register_uart(3);
191 emev2_register_sti();
192 emev2_register_gio(0);
193 emev2_register_gio(1);
194 emev2_register_gio(2);
195 emev2_register_gio(3);
196 emev2_register_gio(4);
197 emev2_register_pmu();
200 void __init emev2_init_delay(void)
202 shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */
205 void __init emev2_init_irq(void)
207 void __iomem *gic_dist_base;
208 void __iomem *gic_cpu_base;
210 /* Static mappings, never released */
211 gic_dist_base = ioremap(0xe0028000, PAGE_SIZE);
212 gic_cpu_base = ioremap(0xe0020000, PAGE_SIZE);
213 BUG_ON(!gic_dist_base || !gic_cpu_base);
215 /* Use GIC to handle interrupts */
216 gic_init(0, 29, gic_dist_base, gic_cpu_base);
221 static const char *emev2_boards_compat_dt[] __initdata = {
226 DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
227 .smp = smp_ops(emev2_smp_ops),
228 .init_early = emev2_init_delay,
229 .nr_irqs = NR_IRQS_LEGACY,
230 .dt_compat = emev2_boards_compat_dt,
233 #endif /* CONFIG_USE_OF */