Magnus Damm | 7f627f0 | 2012-05-16 15:44:58 +0900 | [diff] [blame] | 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/delay.h> |
| 25 | #include <linux/input.h> |
| 26 | #include <linux/io.h> |
| 27 | #include <mach/hardware.h> |
| 28 | #include <mach/common.h> |
| 29 | #include <mach/emev2.h> |
| 30 | #include <mach/irqs.h> |
| 31 | #include <asm/mach-types.h> |
| 32 | #include <asm/mach/arch.h> |
| 33 | #include <asm/mach/map.h> |
| 34 | #include <asm/mach/time.h> |
| 35 | #include <asm/hardware/gic.h> |
| 36 | |
Magnus Damm | bd5a875 | 2012-05-16 15:45:25 +0900 | [diff] [blame^] | 37 | static struct map_desc emev2_io_desc[] __initdata = { |
| 38 | #ifdef CONFIG_SMP |
| 39 | /* 128K entity map for 0xe0100000 (SMU) */ |
| 40 | { |
| 41 | .virtual = 0xe0100000, |
| 42 | .pfn = __phys_to_pfn(0xe0100000), |
| 43 | .length = SZ_128K, |
| 44 | .type = MT_DEVICE |
| 45 | }, |
| 46 | /* 2M mapping for SCU + L2 controller */ |
| 47 | { |
| 48 | .virtual = 0xf0000000, |
| 49 | .pfn = __phys_to_pfn(0x1e000000), |
| 50 | .length = SZ_2M, |
| 51 | .type = MT_DEVICE |
| 52 | }, |
| 53 | #endif |
| 54 | }; |
| 55 | |
| 56 | void __init emev2_map_io(void) |
| 57 | { |
| 58 | iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc)); |
| 59 | } |
| 60 | |
Magnus Damm | 7f627f0 | 2012-05-16 15:44:58 +0900 | [diff] [blame] | 61 | /* UART */ |
| 62 | static struct resource uart0_resources[] = { |
| 63 | [0] = { |
| 64 | .start = 0xe1020000, |
| 65 | .end = 0xe1020037, |
| 66 | .flags = IORESOURCE_MEM, |
| 67 | }, |
| 68 | [1] = { |
| 69 | .start = 40, |
| 70 | .flags = IORESOURCE_IRQ, |
| 71 | } |
| 72 | }; |
| 73 | |
| 74 | static struct platform_device uart0_device = { |
| 75 | .name = "serial8250-em", |
| 76 | .id = 0, |
| 77 | .num_resources = ARRAY_SIZE(uart0_resources), |
| 78 | .resource = uart0_resources, |
| 79 | }; |
| 80 | |
| 81 | static struct resource uart1_resources[] = { |
| 82 | [0] = { |
| 83 | .start = 0xe1030000, |
| 84 | .end = 0xe1030037, |
| 85 | .flags = IORESOURCE_MEM, |
| 86 | }, |
| 87 | [1] = { |
| 88 | .start = 41, |
| 89 | .flags = IORESOURCE_IRQ, |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 | static struct platform_device uart1_device = { |
| 94 | .name = "serial8250-em", |
| 95 | .id = 1, |
| 96 | .num_resources = ARRAY_SIZE(uart1_resources), |
| 97 | .resource = uart1_resources, |
| 98 | }; |
| 99 | |
| 100 | static struct resource uart2_resources[] = { |
| 101 | [0] = { |
| 102 | .start = 0xe1040000, |
| 103 | .end = 0xe1040037, |
| 104 | .flags = IORESOURCE_MEM, |
| 105 | }, |
| 106 | [1] = { |
| 107 | .start = 42, |
| 108 | .flags = IORESOURCE_IRQ, |
| 109 | } |
| 110 | }; |
| 111 | |
| 112 | static struct platform_device uart2_device = { |
| 113 | .name = "serial8250-em", |
| 114 | .id = 2, |
| 115 | .num_resources = ARRAY_SIZE(uart2_resources), |
| 116 | .resource = uart2_resources, |
| 117 | }; |
| 118 | |
| 119 | static struct resource uart3_resources[] = { |
| 120 | [0] = { |
| 121 | .start = 0xe1050000, |
| 122 | .end = 0xe1050037, |
| 123 | .flags = IORESOURCE_MEM, |
| 124 | }, |
| 125 | [1] = { |
| 126 | .start = 43, |
| 127 | .flags = IORESOURCE_IRQ, |
| 128 | } |
| 129 | }; |
| 130 | |
| 131 | static struct platform_device uart3_device = { |
| 132 | .name = "serial8250-em", |
| 133 | .id = 3, |
| 134 | .num_resources = ARRAY_SIZE(uart3_resources), |
| 135 | .resource = uart3_resources, |
| 136 | }; |
| 137 | |
| 138 | /* STI */ |
| 139 | static struct resource sti_resources[] = { |
| 140 | [0] = { |
| 141 | .name = "STI", |
| 142 | .start = 0xe0180000, |
| 143 | .end = 0xe0180053, |
| 144 | .flags = IORESOURCE_MEM, |
| 145 | }, |
| 146 | [1] = { |
| 147 | .start = 157, |
| 148 | .flags = IORESOURCE_IRQ, |
| 149 | }, |
| 150 | }; |
| 151 | |
| 152 | static struct platform_device sti_device = { |
| 153 | .name = "em_sti", |
| 154 | .id = 0, |
| 155 | .resource = sti_resources, |
| 156 | .num_resources = ARRAY_SIZE(sti_resources), |
| 157 | }; |
| 158 | |
| 159 | static struct platform_device *emev2_early_devices[] __initdata = { |
| 160 | &uart0_device, |
| 161 | &uart1_device, |
| 162 | &uart2_device, |
| 163 | &uart3_device, |
| 164 | }; |
| 165 | |
| 166 | static struct platform_device *emev2_late_devices[] __initdata = { |
| 167 | &sti_device, |
| 168 | }; |
| 169 | |
| 170 | void __init emev2_add_standard_devices(void) |
| 171 | { |
| 172 | emev2_clock_init(); |
| 173 | |
| 174 | platform_add_devices(emev2_early_devices, |
| 175 | ARRAY_SIZE(emev2_early_devices)); |
| 176 | |
| 177 | platform_add_devices(emev2_late_devices, |
| 178 | ARRAY_SIZE(emev2_late_devices)); |
| 179 | } |
| 180 | |
| 181 | void __init emev2_add_early_devices(void) |
| 182 | { |
| 183 | shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */ |
| 184 | |
| 185 | early_platform_add_devices(emev2_early_devices, |
| 186 | ARRAY_SIZE(emev2_early_devices)); |
| 187 | |
| 188 | /* setup early console here as well */ |
| 189 | shmobile_setup_console(); |
| 190 | } |
| 191 | |
| 192 | void __init emev2_init_irq(void) |
| 193 | { |
| 194 | void __iomem *gic_dist_base; |
| 195 | void __iomem *gic_cpu_base; |
| 196 | |
| 197 | /* Static mappings, never released */ |
| 198 | gic_dist_base = ioremap(0xe0028000, PAGE_SIZE); |
| 199 | gic_cpu_base = ioremap(0xe0020000, PAGE_SIZE); |
| 200 | BUG_ON(!gic_dist_base || !gic_cpu_base); |
| 201 | |
| 202 | /* Use GIC to handle interrupts */ |
| 203 | gic_init(0, 29, gic_dist_base, gic_cpu_base); |
| 204 | } |