]>
Commit | Line | Data |
---|---|---|
1b504bbe CT |
1 | /* |
2 | * arch/arm/mach-realview/realview_pbx.c | |
3 | * | |
4 | * Copyright (C) 2009 ARM Limited | |
5 | * Copyright (C) 2000 Deep Blue Solutions Ltd | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 | */ | |
20 | ||
21 | #include <linux/init.h> | |
22 | #include <linux/platform_device.h> | |
23 | #include <linux/sysdev.h> | |
24 | #include <linux/amba/bus.h> | |
eb7fffa3 | 25 | #include <linux/amba/pl061.h> |
6ef297f8 | 26 | #include <linux/amba/mmci.h> |
1b504bbe CT |
27 | #include <linux/io.h> |
28 | ||
29 | #include <asm/irq.h> | |
30 | #include <asm/leds.h> | |
31 | #include <asm/mach-types.h> | |
f417cbad | 32 | #include <asm/pmu.h> |
c3c21740 | 33 | #include <asm/smp_twd.h> |
cc9897df | 34 | #include <asm/pgtable.h> |
1b504bbe CT |
35 | #include <asm/hardware/gic.h> |
36 | #include <asm/hardware/cache-l2x0.h> | |
37 | ||
38 | #include <asm/mach/arch.h> | |
39 | #include <asm/mach/map.h> | |
1b504bbe CT |
40 | #include <asm/mach/time.h> |
41 | ||
42 | #include <mach/hardware.h> | |
43 | #include <mach/board-pbx.h> | |
44 | #include <mach/irqs.h> | |
45 | ||
46 | #include "core.h" | |
47 | ||
48 | static struct map_desc realview_pbx_io_desc[] __initdata = { | |
49 | { | |
50 | .virtual = IO_ADDRESS(REALVIEW_SYS_BASE), | |
51 | .pfn = __phys_to_pfn(REALVIEW_SYS_BASE), | |
52 | .length = SZ_4K, | |
53 | .type = MT_DEVICE, | |
54 | }, { | |
55 | .virtual = IO_ADDRESS(REALVIEW_PBX_GIC_CPU_BASE), | |
56 | .pfn = __phys_to_pfn(REALVIEW_PBX_GIC_CPU_BASE), | |
57 | .length = SZ_4K, | |
58 | .type = MT_DEVICE, | |
59 | }, { | |
60 | .virtual = IO_ADDRESS(REALVIEW_PBX_GIC_DIST_BASE), | |
61 | .pfn = __phys_to_pfn(REALVIEW_PBX_GIC_DIST_BASE), | |
62 | .length = SZ_4K, | |
63 | .type = MT_DEVICE, | |
64 | }, { | |
65 | .virtual = IO_ADDRESS(REALVIEW_SCTL_BASE), | |
66 | .pfn = __phys_to_pfn(REALVIEW_SCTL_BASE), | |
67 | .length = SZ_4K, | |
68 | .type = MT_DEVICE, | |
69 | }, { | |
70 | .virtual = IO_ADDRESS(REALVIEW_PBX_TIMER0_1_BASE), | |
71 | .pfn = __phys_to_pfn(REALVIEW_PBX_TIMER0_1_BASE), | |
72 | .length = SZ_4K, | |
73 | .type = MT_DEVICE, | |
74 | }, { | |
75 | .virtual = IO_ADDRESS(REALVIEW_PBX_TIMER2_3_BASE), | |
76 | .pfn = __phys_to_pfn(REALVIEW_PBX_TIMER2_3_BASE), | |
77 | .length = SZ_4K, | |
78 | .type = MT_DEVICE, | |
79 | }, | |
80 | #ifdef CONFIG_PCI | |
81 | { | |
82 | .virtual = PCIX_UNIT_BASE, | |
83 | .pfn = __phys_to_pfn(REALVIEW_PBX_PCI_BASE), | |
84 | .length = REALVIEW_PBX_PCI_BASE_SIZE, | |
85 | .type = MT_DEVICE, | |
86 | }, | |
87 | #endif | |
88 | #ifdef CONFIG_DEBUG_LL | |
89 | { | |
90 | .virtual = IO_ADDRESS(REALVIEW_PBX_UART0_BASE), | |
91 | .pfn = __phys_to_pfn(REALVIEW_PBX_UART0_BASE), | |
92 | .length = SZ_4K, | |
93 | .type = MT_DEVICE, | |
94 | }, | |
95 | #endif | |
96 | }; | |
97 | ||
98 | static struct map_desc realview_local_io_desc[] __initdata = { | |
99 | { | |
100 | .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_GIC_CPU_BASE), | |
101 | .pfn = __phys_to_pfn(REALVIEW_PBX_TILE_GIC_CPU_BASE), | |
102 | .length = SZ_4K, | |
103 | .type = MT_DEVICE, | |
104 | }, { | |
105 | .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_GIC_DIST_BASE), | |
106 | .pfn = __phys_to_pfn(REALVIEW_PBX_TILE_GIC_DIST_BASE), | |
107 | .length = SZ_4K, | |
108 | .type = MT_DEVICE, | |
109 | }, { | |
110 | .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_L220_BASE), | |
111 | .pfn = __phys_to_pfn(REALVIEW_PBX_TILE_L220_BASE), | |
112 | .length = SZ_8K, | |
113 | .type = MT_DEVICE, | |
114 | } | |
115 | }; | |
116 | ||
117 | static void __init realview_pbx_map_io(void) | |
118 | { | |
119 | iotable_init(realview_pbx_io_desc, ARRAY_SIZE(realview_pbx_io_desc)); | |
120 | if (core_tile_pbx11mp() || core_tile_pbxa9mp()) | |
121 | iotable_init(realview_local_io_desc, ARRAY_SIZE(realview_local_io_desc)); | |
122 | } | |
123 | ||
eb7fffa3 RK |
124 | static struct pl061_platform_data gpio0_plat_data = { |
125 | .gpio_base = 0, | |
126 | .irq_base = -1, | |
127 | }; | |
128 | ||
129 | static struct pl061_platform_data gpio1_plat_data = { | |
130 | .gpio_base = 8, | |
131 | .irq_base = -1, | |
132 | }; | |
133 | ||
134 | static struct pl061_platform_data gpio2_plat_data = { | |
135 | .gpio_base = 16, | |
136 | .irq_base = -1, | |
137 | }; | |
138 | ||
1b504bbe CT |
139 | /* |
140 | * RealView PBXCore AMBA devices | |
141 | */ | |
142 | ||
143 | #define GPIO2_IRQ { IRQ_PBX_GPIO2, NO_IRQ } | |
144 | #define GPIO2_DMA { 0, 0 } | |
145 | #define GPIO3_IRQ { IRQ_PBX_GPIO3, NO_IRQ } | |
146 | #define GPIO3_DMA { 0, 0 } | |
147 | #define AACI_IRQ { IRQ_PBX_AACI, NO_IRQ } | |
148 | #define AACI_DMA { 0x80, 0x81 } | |
149 | #define MMCI0_IRQ { IRQ_PBX_MMCI0A, IRQ_PBX_MMCI0B } | |
150 | #define MMCI0_DMA { 0x84, 0 } | |
151 | #define KMI0_IRQ { IRQ_PBX_KMI0, NO_IRQ } | |
152 | #define KMI0_DMA { 0, 0 } | |
153 | #define KMI1_IRQ { IRQ_PBX_KMI1, NO_IRQ } | |
154 | #define KMI1_DMA { 0, 0 } | |
155 | #define PBX_SMC_IRQ { NO_IRQ, NO_IRQ } | |
156 | #define PBX_SMC_DMA { 0, 0 } | |
157 | #define MPMC_IRQ { NO_IRQ, NO_IRQ } | |
158 | #define MPMC_DMA { 0, 0 } | |
159 | #define PBX_CLCD_IRQ { IRQ_PBX_CLCD, NO_IRQ } | |
160 | #define PBX_CLCD_DMA { 0, 0 } | |
161 | #define DMAC_IRQ { IRQ_PBX_DMAC, NO_IRQ } | |
162 | #define DMAC_DMA { 0, 0 } | |
163 | #define SCTL_IRQ { NO_IRQ, NO_IRQ } | |
164 | #define SCTL_DMA { 0, 0 } | |
165 | #define PBX_WATCHDOG_IRQ { IRQ_PBX_WATCHDOG, NO_IRQ } | |
166 | #define PBX_WATCHDOG_DMA { 0, 0 } | |
167 | #define PBX_GPIO0_IRQ { IRQ_PBX_GPIO0, NO_IRQ } | |
168 | #define PBX_GPIO0_DMA { 0, 0 } | |
169 | #define GPIO1_IRQ { IRQ_PBX_GPIO1, NO_IRQ } | |
170 | #define GPIO1_DMA { 0, 0 } | |
171 | #define PBX_RTC_IRQ { IRQ_PBX_RTC, NO_IRQ } | |
172 | #define PBX_RTC_DMA { 0, 0 } | |
173 | #define SCI_IRQ { IRQ_PBX_SCI, NO_IRQ } | |
174 | #define SCI_DMA { 7, 6 } | |
175 | #define PBX_UART0_IRQ { IRQ_PBX_UART0, NO_IRQ } | |
176 | #define PBX_UART0_DMA { 15, 14 } | |
177 | #define PBX_UART1_IRQ { IRQ_PBX_UART1, NO_IRQ } | |
178 | #define PBX_UART1_DMA { 13, 12 } | |
179 | #define PBX_UART2_IRQ { IRQ_PBX_UART2, NO_IRQ } | |
180 | #define PBX_UART2_DMA { 11, 10 } | |
181 | #define PBX_UART3_IRQ { IRQ_PBX_UART3, NO_IRQ } | |
182 | #define PBX_UART3_DMA { 0x86, 0x87 } | |
183 | #define PBX_SSP_IRQ { IRQ_PBX_SSP, NO_IRQ } | |
184 | #define PBX_SSP_DMA { 9, 8 } | |
185 | ||
186 | /* FPGA Primecells */ | |
4321532c LW |
187 | AMBA_DEVICE(aaci, "fpga:aaci", AACI, NULL); |
188 | AMBA_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data); | |
189 | AMBA_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL); | |
190 | AMBA_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL); | |
191 | AMBA_DEVICE(uart3, "fpga:uart3", PBX_UART3, NULL); | |
1b504bbe CT |
192 | |
193 | /* DevChip Primecells */ | |
4321532c LW |
194 | AMBA_DEVICE(smc, "dev:smc", PBX_SMC, NULL); |
195 | AMBA_DEVICE(sctl, "dev:sctl", SCTL, NULL); | |
196 | AMBA_DEVICE(wdog, "dev:wdog", PBX_WATCHDOG, NULL); | |
197 | AMBA_DEVICE(gpio0, "dev:gpio0", PBX_GPIO0, &gpio0_plat_data); | |
198 | AMBA_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data); | |
199 | AMBA_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data); | |
200 | AMBA_DEVICE(rtc, "dev:rtc", PBX_RTC, NULL); | |
201 | AMBA_DEVICE(sci0, "dev:sci0", SCI, NULL); | |
202 | AMBA_DEVICE(uart0, "dev:uart0", PBX_UART0, NULL); | |
203 | AMBA_DEVICE(uart1, "dev:uart1", PBX_UART1, NULL); | |
204 | AMBA_DEVICE(uart2, "dev:uart2", PBX_UART2, NULL); | |
205 | AMBA_DEVICE(ssp0, "dev:ssp0", PBX_SSP, NULL); | |
1b504bbe CT |
206 | |
207 | /* Primecells on the NEC ISSP chip */ | |
4321532c LW |
208 | AMBA_DEVICE(clcd, "issp:clcd", PBX_CLCD, &clcd_plat_data); |
209 | AMBA_DEVICE(dmac, "issp:dmac", DMAC, NULL); | |
1b504bbe CT |
210 | |
211 | static struct amba_device *amba_devs[] __initdata = { | |
212 | &dmac_device, | |
213 | &uart0_device, | |
214 | &uart1_device, | |
215 | &uart2_device, | |
216 | &uart3_device, | |
217 | &smc_device, | |
218 | &clcd_device, | |
219 | &sctl_device, | |
220 | &wdog_device, | |
221 | &gpio0_device, | |
222 | &gpio1_device, | |
223 | &gpio2_device, | |
224 | &rtc_device, | |
225 | &sci0_device, | |
226 | &ssp0_device, | |
227 | &aaci_device, | |
228 | &mmc0_device, | |
229 | &kmi0_device, | |
230 | &kmi1_device, | |
231 | }; | |
232 | ||
233 | /* | |
234 | * RealView PB-X platform devices | |
235 | */ | |
236 | static struct resource realview_pbx_flash_resources[] = { | |
237 | [0] = { | |
238 | .start = REALVIEW_PBX_FLASH0_BASE, | |
239 | .end = REALVIEW_PBX_FLASH0_BASE + REALVIEW_PBX_FLASH0_SIZE - 1, | |
240 | .flags = IORESOURCE_MEM, | |
241 | }, | |
242 | [1] = { | |
243 | .start = REALVIEW_PBX_FLASH1_BASE, | |
244 | .end = REALVIEW_PBX_FLASH1_BASE + REALVIEW_PBX_FLASH1_SIZE - 1, | |
245 | .flags = IORESOURCE_MEM, | |
246 | }, | |
247 | }; | |
248 | ||
249 | static struct resource realview_pbx_smsc911x_resources[] = { | |
250 | [0] = { | |
251 | .start = REALVIEW_PBX_ETH_BASE, | |
252 | .end = REALVIEW_PBX_ETH_BASE + SZ_64K - 1, | |
253 | .flags = IORESOURCE_MEM, | |
254 | }, | |
255 | [1] = { | |
256 | .start = IRQ_PBX_ETH, | |
257 | .end = IRQ_PBX_ETH, | |
258 | .flags = IORESOURCE_IRQ, | |
259 | }, | |
260 | }; | |
261 | ||
262 | static struct resource realview_pbx_isp1761_resources[] = { | |
263 | [0] = { | |
264 | .start = REALVIEW_PBX_USB_BASE, | |
265 | .end = REALVIEW_PBX_USB_BASE + SZ_128K - 1, | |
266 | .flags = IORESOURCE_MEM, | |
267 | }, | |
268 | [1] = { | |
269 | .start = IRQ_PBX_USB, | |
270 | .end = IRQ_PBX_USB, | |
271 | .flags = IORESOURCE_IRQ, | |
272 | }, | |
273 | }; | |
274 | ||
f417cbad WD |
275 | static struct resource pmu_resources[] = { |
276 | [0] = { | |
277 | .start = IRQ_PBX_PMU_CPU0, | |
278 | .end = IRQ_PBX_PMU_CPU0, | |
279 | .flags = IORESOURCE_IRQ, | |
280 | }, | |
281 | [1] = { | |
282 | .start = IRQ_PBX_PMU_CPU1, | |
283 | .end = IRQ_PBX_PMU_CPU1, | |
284 | .flags = IORESOURCE_IRQ, | |
285 | }, | |
286 | [2] = { | |
287 | .start = IRQ_PBX_PMU_CPU2, | |
288 | .end = IRQ_PBX_PMU_CPU2, | |
289 | .flags = IORESOURCE_IRQ, | |
290 | }, | |
291 | [3] = { | |
292 | .start = IRQ_PBX_PMU_CPU3, | |
293 | .end = IRQ_PBX_PMU_CPU3, | |
294 | .flags = IORESOURCE_IRQ, | |
295 | }, | |
296 | }; | |
297 | ||
298 | static struct platform_device pmu_device = { | |
299 | .name = "arm-pmu", | |
300 | .id = ARM_PMU_DEVICE_CPU, | |
301 | .num_resources = ARRAY_SIZE(pmu_resources), | |
302 | .resource = pmu_resources, | |
303 | }; | |
304 | ||
1b504bbe CT |
305 | static void __init gic_init_irq(void) |
306 | { | |
307 | /* ARM PBX on-board GIC */ | |
308 | if (core_tile_pbx11mp() || core_tile_pbxa9mp()) { | |
309 | gic_cpu_base_addr = __io_address(REALVIEW_PBX_TILE_GIC_CPU_BASE); | |
310 | gic_dist_init(0, __io_address(REALVIEW_PBX_TILE_GIC_DIST_BASE), | |
311 | 29); | |
312 | gic_cpu_init(0, __io_address(REALVIEW_PBX_TILE_GIC_CPU_BASE)); | |
313 | } else { | |
314 | gic_cpu_base_addr = __io_address(REALVIEW_PBX_GIC_CPU_BASE); | |
315 | gic_dist_init(0, __io_address(REALVIEW_PBX_GIC_DIST_BASE), | |
316 | IRQ_PBX_GIC_START); | |
317 | gic_cpu_init(0, __io_address(REALVIEW_PBX_GIC_CPU_BASE)); | |
318 | } | |
319 | } | |
320 | ||
321 | static void __init realview_pbx_timer_init(void) | |
322 | { | |
323 | timer0_va_base = __io_address(REALVIEW_PBX_TIMER0_1_BASE); | |
324 | timer1_va_base = __io_address(REALVIEW_PBX_TIMER0_1_BASE) + 0x20; | |
325 | timer2_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE); | |
326 | timer3_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE) + 0x20; | |
327 | ||
328 | #ifdef CONFIG_LOCAL_TIMERS | |
329 | if (core_tile_pbx11mp() || core_tile_pbxa9mp()) | |
330 | twd_base = __io_address(REALVIEW_PBX_TILE_TWD_BASE); | |
331 | #endif | |
332 | realview_timer_init(IRQ_PBX_TIMER0_1); | |
333 | } | |
334 | ||
335 | static struct sys_timer realview_pbx_timer = { | |
336 | .init = realview_pbx_timer_init, | |
337 | }; | |
338 | ||
c97c5aa8 CM |
339 | static void realview_pbx_fixup(struct machine_desc *mdesc, struct tag *tags, |
340 | char **from, struct meminfo *meminfo) | |
341 | { | |
342 | #ifdef CONFIG_SPARSEMEM | |
343 | /* | |
344 | * Memory configuration with SPARSEMEM enabled on RealView PBX (see | |
345 | * asm/mach/memory.h for more information). | |
346 | */ | |
347 | meminfo->bank[0].start = 0; | |
348 | meminfo->bank[0].size = SZ_256M; | |
349 | meminfo->bank[1].start = 0x20000000; | |
350 | meminfo->bank[1].size = SZ_512M; | |
351 | meminfo->bank[2].start = 0x80000000; | |
352 | meminfo->bank[2].size = SZ_256M; | |
353 | meminfo->nr_banks = 3; | |
354 | #else | |
355 | realview_fixup(mdesc, tags, from, meminfo); | |
356 | #endif | |
357 | } | |
358 | ||
4c9f8be7 CT |
359 | static void realview_pbx_reset(char mode) |
360 | { | |
361 | void __iomem *reset_ctrl = __io_address(REALVIEW_SYS_RESETCTL); | |
362 | void __iomem *lock_ctrl = __io_address(REALVIEW_SYS_LOCK); | |
363 | ||
364 | /* | |
365 | * To reset, we hit the on-board reset register | |
366 | * in the system FPGA | |
367 | */ | |
368 | __raw_writel(REALVIEW_SYS_LOCK_VAL, lock_ctrl); | |
df2e615a CT |
369 | __raw_writel(0x00F0, reset_ctrl); |
370 | __raw_writel(0x00F4, reset_ctrl); | |
4c9f8be7 CT |
371 | } |
372 | ||
1b504bbe CT |
373 | static void __init realview_pbx_init(void) |
374 | { | |
375 | int i; | |
376 | ||
377 | #ifdef CONFIG_CACHE_L2X0 | |
378 | if (core_tile_pbxa9mp()) { | |
379 | void __iomem *l2x0_base = | |
380 | __io_address(REALVIEW_PBX_TILE_L220_BASE); | |
381 | ||
382 | /* set RAM latencies to 1 cycle for eASIC */ | |
383 | writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL); | |
384 | writel(0, l2x0_base + L2X0_DATA_LATENCY_CTRL); | |
385 | ||
386 | /* 16KB way size, 8-way associativity, parity disabled | |
387 | * Bits: .. 0 0 0 0 1 00 1 0 1 001 0 000 0 .... .... .... */ | |
388 | l2x0_init(l2x0_base, 0x02520000, 0xc0000fff); | |
f417cbad | 389 | platform_device_register(&pmu_device); |
1b504bbe CT |
390 | } |
391 | #endif | |
392 | ||
393 | realview_flash_register(realview_pbx_flash_resources, | |
394 | ARRAY_SIZE(realview_pbx_flash_resources)); | |
395 | realview_eth_register(NULL, realview_pbx_smsc911x_resources); | |
396 | platform_device_register(&realview_i2c_device); | |
397 | platform_device_register(&realview_cf_device); | |
398 | realview_usb_register(realview_pbx_isp1761_resources); | |
399 | ||
400 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { | |
401 | struct amba_device *d = amba_devs[i]; | |
402 | amba_device_register(d, &iomem_resource); | |
403 | } | |
404 | ||
405 | #ifdef CONFIG_LEDS | |
406 | leds_event = realview_leds_event; | |
407 | #endif | |
4c9f8be7 | 408 | realview_reset = realview_pbx_reset; |
1b504bbe CT |
409 | } |
410 | ||
411 | MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX") | |
412 | /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ | |
cc9897df | 413 | .phys_io = REALVIEW_PBX_UART0_BASE & SECTION_MASK, |
1b504bbe CT |
414 | .io_pg_offst = (IO_ADDRESS(REALVIEW_PBX_UART0_BASE) >> 18) & 0xfffc, |
415 | .boot_params = PHYS_OFFSET + 0x00000100, | |
c97c5aa8 | 416 | .fixup = realview_pbx_fixup, |
1b504bbe CT |
417 | .map_io = realview_pbx_map_io, |
418 | .init_irq = gic_init_irq, | |
419 | .timer = &realview_pbx_timer, | |
420 | .init_machine = realview_pbx_init, | |
421 | MACHINE_END |