1 /* 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> 24 #include <linux/platform_data/gpio-em.h> 25 #include <linux/of_platform.h> 26 #include <linux/delay.h> 27 #include <linux/input.h> 28 #include <linux/io.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> 38 39 static struct map_desc emev2_io_desc[] __initdata = { 40 #ifdef CONFIG_SMP 41 /* 128K entity map for 0xe0100000 (SMU) */ 42 { 43 .virtual = 0xe0100000, 44 .pfn = __phys_to_pfn(0xe0100000), 45 .length = SZ_128K, 46 .type = MT_DEVICE 47 }, 48 /* 2M mapping for SCU + L2 controller */ 49 { 50 .virtual = 0xf0000000, 51 .pfn = __phys_to_pfn(0x1e000000), 52 .length = SZ_2M, 53 .type = MT_DEVICE 54 }, 55 #endif 56 }; 57 58 void __init emev2_map_io(void) 59 { 60 iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc)); 61 } 62 63 /* UART */ 64 static struct resource uart0_resources[] = { 65 DEFINE_RES_MEM(0xe1020000, 0x38), 66 DEFINE_RES_IRQ(40), 67 }; 68 69 static struct resource uart1_resources[] = { 70 DEFINE_RES_MEM(0xe1030000, 0x38), 71 DEFINE_RES_IRQ(41), 72 }; 73 74 static struct resource uart2_resources[] = { 75 DEFINE_RES_MEM(0xe1040000, 0x38), 76 DEFINE_RES_IRQ(42), 77 }; 78 79 static struct resource uart3_resources[] = { 80 DEFINE_RES_MEM(0xe1050000, 0x38), 81 DEFINE_RES_IRQ(43), 82 }; 83 84 #define emev2_register_uart(idx) \ 85 platform_device_register_simple("serial8250-em", idx, \ 86 uart##idx##_resources, \ 87 ARRAY_SIZE(uart##idx##_resources)) 88 89 /* STI */ 90 static struct resource sti_resources[] = { 91 DEFINE_RES_MEM(0xe0180000, 0x54), 92 DEFINE_RES_IRQ(157), 93 }; 94 95 #define emev2_register_sti() \ 96 platform_device_register_simple("em_sti", 0, \ 97 sti_resources, \ 98 ARRAY_SIZE(sti_resources)) 99 100 /* GIO */ 101 static struct gpio_em_config gio0_config = { 102 .gpio_base = 0, 103 .irq_base = EMEV2_GPIO_IRQ(0), 104 .number_of_pins = 32, 105 }; 106 107 static struct resource gio0_resources[] = { 108 DEFINE_RES_MEM(0xe0050000, 0x2c), 109 DEFINE_RES_MEM(0xe0050040, 0x20), 110 DEFINE_RES_IRQ(99), 111 DEFINE_RES_IRQ(100), 112 }; 113 114 static struct gpio_em_config gio1_config = { 115 .gpio_base = 32, 116 .irq_base = EMEV2_GPIO_IRQ(32), 117 .number_of_pins = 32, 118 }; 119 120 static struct resource gio1_resources[] = { 121 DEFINE_RES_MEM(0xe0050080, 0x2c), 122 DEFINE_RES_MEM(0xe00500c0, 0x20), 123 DEFINE_RES_IRQ(101), 124 DEFINE_RES_IRQ(102), 125 }; 126 127 static struct gpio_em_config gio2_config = { 128 .gpio_base = 64, 129 .irq_base = EMEV2_GPIO_IRQ(64), 130 .number_of_pins = 32, 131 }; 132 133 static struct resource gio2_resources[] = { 134 DEFINE_RES_MEM(0xe0050100, 0x2c), 135 DEFINE_RES_MEM(0xe0050140, 0x20), 136 DEFINE_RES_IRQ(103), 137 DEFINE_RES_IRQ(104), 138 }; 139 140 static struct gpio_em_config gio3_config = { 141 .gpio_base = 96, 142 .irq_base = EMEV2_GPIO_IRQ(96), 143 .number_of_pins = 32, 144 }; 145 146 static struct resource gio3_resources[] = { 147 DEFINE_RES_MEM(0xe0050180, 0x2c), 148 DEFINE_RES_MEM(0xe00501c0, 0x20), 149 DEFINE_RES_IRQ(105), 150 DEFINE_RES_IRQ(106), 151 }; 152 153 static struct gpio_em_config gio4_config = { 154 .gpio_base = 128, 155 .irq_base = EMEV2_GPIO_IRQ(128), 156 .number_of_pins = 31, 157 }; 158 159 static struct resource gio4_resources[] = { 160 DEFINE_RES_MEM(0xe0050200, 0x2c), 161 DEFINE_RES_MEM(0xe0050240, 0x20), 162 DEFINE_RES_IRQ(107), 163 DEFINE_RES_IRQ(108), 164 }; 165 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)) 172 173 static struct resource pmu_resources[] = { 174 DEFINE_RES_IRQ(152), 175 DEFINE_RES_IRQ(153), 176 }; 177 178 #define emev2_register_pmu() \ 179 platform_device_register_simple("arm-pmu", -1, \ 180 pmu_resources, \ 181 ARRAY_SIZE(pmu_resources)) 182 183 void __init emev2_add_standard_devices(void) 184 { 185 emev2_clock_init(); 186 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(); 198 } 199 200 void __init emev2_init_delay(void) 201 { 202 shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */ 203 } 204 205 void __init emev2_init_irq(void) 206 { 207 void __iomem *gic_dist_base; 208 void __iomem *gic_cpu_base; 209 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); 214 215 /* Use GIC to handle interrupts */ 216 gic_init(0, 29, gic_dist_base, gic_cpu_base); 217 } 218 219 #ifdef CONFIG_USE_OF 220 221 static const char *emev2_boards_compat_dt[] __initdata = { 222 "renesas,emev2", 223 NULL, 224 }; 225 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, 231 MACHINE_END 232 233 #endif /* CONFIG_USE_OF */ 234