blob: 9428eff0b116addda238d99d492cbe9d80c6b8a5 [file] [log] [blame]
Colin Tuckley1b504bb2009-05-30 13:56:12 +01001/*
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>
Russell Kingeb7fffa2009-07-05 22:41:31 +010025#include <linux/amba/pl061.h>
Linus Walleij6ef297f2009-09-22 14:29:36 +010026#include <linux/amba/mmci.h>
Linus Walleijd6ada862010-07-14 23:58:38 +010027#include <linux/amba/pl022.h>
Colin Tuckley1b504bb2009-05-30 13:56:12 +010028#include <linux/io.h>
29
30#include <asm/irq.h>
31#include <asm/leds.h>
32#include <asm/mach-types.h>
Will Deaconf417cba2010-04-15 10:16:26 +010033#include <asm/pmu.h>
Catalin Marinasc3c21742009-06-19 11:28:48 +010034#include <asm/smp_twd.h>
Catalin Marinascc9897d2010-06-21 15:12:40 +010035#include <asm/pgtable.h>
Colin Tuckley1b504bb2009-05-30 13:56:12 +010036#include <asm/hardware/gic.h>
37#include <asm/hardware/cache-l2x0.h>
38
39#include <asm/mach/arch.h>
40#include <asm/mach/map.h>
Colin Tuckley1b504bb2009-05-30 13:56:12 +010041#include <asm/mach/time.h>
42
43#include <mach/hardware.h>
44#include <mach/board-pbx.h>
45#include <mach/irqs.h>
46
47#include "core.h"
48
49static struct map_desc realview_pbx_io_desc[] __initdata = {
50 {
51 .virtual = IO_ADDRESS(REALVIEW_SYS_BASE),
52 .pfn = __phys_to_pfn(REALVIEW_SYS_BASE),
53 .length = SZ_4K,
54 .type = MT_DEVICE,
55 }, {
56 .virtual = IO_ADDRESS(REALVIEW_PBX_GIC_CPU_BASE),
57 .pfn = __phys_to_pfn(REALVIEW_PBX_GIC_CPU_BASE),
58 .length = SZ_4K,
59 .type = MT_DEVICE,
60 }, {
61 .virtual = IO_ADDRESS(REALVIEW_PBX_GIC_DIST_BASE),
62 .pfn = __phys_to_pfn(REALVIEW_PBX_GIC_DIST_BASE),
63 .length = SZ_4K,
64 .type = MT_DEVICE,
65 }, {
66 .virtual = IO_ADDRESS(REALVIEW_SCTL_BASE),
67 .pfn = __phys_to_pfn(REALVIEW_SCTL_BASE),
68 .length = SZ_4K,
69 .type = MT_DEVICE,
70 }, {
71 .virtual = IO_ADDRESS(REALVIEW_PBX_TIMER0_1_BASE),
72 .pfn = __phys_to_pfn(REALVIEW_PBX_TIMER0_1_BASE),
73 .length = SZ_4K,
74 .type = MT_DEVICE,
75 }, {
76 .virtual = IO_ADDRESS(REALVIEW_PBX_TIMER2_3_BASE),
77 .pfn = __phys_to_pfn(REALVIEW_PBX_TIMER2_3_BASE),
78 .length = SZ_4K,
79 .type = MT_DEVICE,
80 },
81#ifdef CONFIG_PCI
82 {
83 .virtual = PCIX_UNIT_BASE,
84 .pfn = __phys_to_pfn(REALVIEW_PBX_PCI_BASE),
85 .length = REALVIEW_PBX_PCI_BASE_SIZE,
86 .type = MT_DEVICE,
87 },
88#endif
89#ifdef CONFIG_DEBUG_LL
90 {
91 .virtual = IO_ADDRESS(REALVIEW_PBX_UART0_BASE),
92 .pfn = __phys_to_pfn(REALVIEW_PBX_UART0_BASE),
93 .length = SZ_4K,
94 .type = MT_DEVICE,
95 },
96#endif
97};
98
99static struct map_desc realview_local_io_desc[] __initdata = {
100 {
101 .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_GIC_CPU_BASE),
102 .pfn = __phys_to_pfn(REALVIEW_PBX_TILE_GIC_CPU_BASE),
103 .length = SZ_4K,
104 .type = MT_DEVICE,
105 }, {
106 .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_GIC_DIST_BASE),
107 .pfn = __phys_to_pfn(REALVIEW_PBX_TILE_GIC_DIST_BASE),
108 .length = SZ_4K,
109 .type = MT_DEVICE,
110 }, {
111 .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_L220_BASE),
112 .pfn = __phys_to_pfn(REALVIEW_PBX_TILE_L220_BASE),
113 .length = SZ_8K,
114 .type = MT_DEVICE,
115 }
116};
117
118static void __init realview_pbx_map_io(void)
119{
120 iotable_init(realview_pbx_io_desc, ARRAY_SIZE(realview_pbx_io_desc));
121 if (core_tile_pbx11mp() || core_tile_pbxa9mp())
122 iotable_init(realview_local_io_desc, ARRAY_SIZE(realview_local_io_desc));
123}
124
Russell Kingeb7fffa2009-07-05 22:41:31 +0100125static struct pl061_platform_data gpio0_plat_data = {
126 .gpio_base = 0,
127 .irq_base = -1,
128};
129
130static struct pl061_platform_data gpio1_plat_data = {
131 .gpio_base = 8,
132 .irq_base = -1,
133};
134
135static struct pl061_platform_data gpio2_plat_data = {
136 .gpio_base = 16,
137 .irq_base = -1,
138};
139
Linus Walleijd6ada862010-07-14 23:58:38 +0100140static struct pl022_ssp_controller ssp0_plat_data = {
141 .bus_id = 0,
142 .enable_dma = 0,
143 .num_chipselect = 1,
144};
145
Colin Tuckley1b504bb2009-05-30 13:56:12 +0100146/*
147 * RealView PBXCore AMBA devices
148 */
149
150#define GPIO2_IRQ { IRQ_PBX_GPIO2, NO_IRQ }
151#define GPIO2_DMA { 0, 0 }
152#define GPIO3_IRQ { IRQ_PBX_GPIO3, NO_IRQ }
153#define GPIO3_DMA { 0, 0 }
154#define AACI_IRQ { IRQ_PBX_AACI, NO_IRQ }
155#define AACI_DMA { 0x80, 0x81 }
156#define MMCI0_IRQ { IRQ_PBX_MMCI0A, IRQ_PBX_MMCI0B }
157#define MMCI0_DMA { 0x84, 0 }
158#define KMI0_IRQ { IRQ_PBX_KMI0, NO_IRQ }
159#define KMI0_DMA { 0, 0 }
160#define KMI1_IRQ { IRQ_PBX_KMI1, NO_IRQ }
161#define KMI1_DMA { 0, 0 }
162#define PBX_SMC_IRQ { NO_IRQ, NO_IRQ }
163#define PBX_SMC_DMA { 0, 0 }
164#define MPMC_IRQ { NO_IRQ, NO_IRQ }
165#define MPMC_DMA { 0, 0 }
166#define PBX_CLCD_IRQ { IRQ_PBX_CLCD, NO_IRQ }
167#define PBX_CLCD_DMA { 0, 0 }
168#define DMAC_IRQ { IRQ_PBX_DMAC, NO_IRQ }
169#define DMAC_DMA { 0, 0 }
170#define SCTL_IRQ { NO_IRQ, NO_IRQ }
171#define SCTL_DMA { 0, 0 }
172#define PBX_WATCHDOG_IRQ { IRQ_PBX_WATCHDOG, NO_IRQ }
173#define PBX_WATCHDOG_DMA { 0, 0 }
174#define PBX_GPIO0_IRQ { IRQ_PBX_GPIO0, NO_IRQ }
175#define PBX_GPIO0_DMA { 0, 0 }
176#define GPIO1_IRQ { IRQ_PBX_GPIO1, NO_IRQ }
177#define GPIO1_DMA { 0, 0 }
178#define PBX_RTC_IRQ { IRQ_PBX_RTC, NO_IRQ }
179#define PBX_RTC_DMA { 0, 0 }
180#define SCI_IRQ { IRQ_PBX_SCI, NO_IRQ }
181#define SCI_DMA { 7, 6 }
182#define PBX_UART0_IRQ { IRQ_PBX_UART0, NO_IRQ }
183#define PBX_UART0_DMA { 15, 14 }
184#define PBX_UART1_IRQ { IRQ_PBX_UART1, NO_IRQ }
185#define PBX_UART1_DMA { 13, 12 }
186#define PBX_UART2_IRQ { IRQ_PBX_UART2, NO_IRQ }
187#define PBX_UART2_DMA { 11, 10 }
188#define PBX_UART3_IRQ { IRQ_PBX_UART3, NO_IRQ }
189#define PBX_UART3_DMA { 0x86, 0x87 }
190#define PBX_SSP_IRQ { IRQ_PBX_SSP, NO_IRQ }
191#define PBX_SSP_DMA { 9, 8 }
192
193/* FPGA Primecells */
Linus Walleij43215322009-09-21 12:30:32 +0100194AMBA_DEVICE(aaci, "fpga:aaci", AACI, NULL);
195AMBA_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data);
196AMBA_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL);
197AMBA_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL);
198AMBA_DEVICE(uart3, "fpga:uart3", PBX_UART3, NULL);
Colin Tuckley1b504bb2009-05-30 13:56:12 +0100199
200/* DevChip Primecells */
Linus Walleij43215322009-09-21 12:30:32 +0100201AMBA_DEVICE(smc, "dev:smc", PBX_SMC, NULL);
202AMBA_DEVICE(sctl, "dev:sctl", SCTL, NULL);
203AMBA_DEVICE(wdog, "dev:wdog", PBX_WATCHDOG, NULL);
204AMBA_DEVICE(gpio0, "dev:gpio0", PBX_GPIO0, &gpio0_plat_data);
205AMBA_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data);
206AMBA_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data);
207AMBA_DEVICE(rtc, "dev:rtc", PBX_RTC, NULL);
208AMBA_DEVICE(sci0, "dev:sci0", SCI, NULL);
209AMBA_DEVICE(uart0, "dev:uart0", PBX_UART0, NULL);
210AMBA_DEVICE(uart1, "dev:uart1", PBX_UART1, NULL);
211AMBA_DEVICE(uart2, "dev:uart2", PBX_UART2, NULL);
Linus Walleijd6ada862010-07-14 23:58:38 +0100212AMBA_DEVICE(ssp0, "dev:ssp0", PBX_SSP, &ssp0_plat_data);
Colin Tuckley1b504bb2009-05-30 13:56:12 +0100213
214/* Primecells on the NEC ISSP chip */
Linus Walleij43215322009-09-21 12:30:32 +0100215AMBA_DEVICE(clcd, "issp:clcd", PBX_CLCD, &clcd_plat_data);
216AMBA_DEVICE(dmac, "issp:dmac", DMAC, NULL);
Colin Tuckley1b504bb2009-05-30 13:56:12 +0100217
218static struct amba_device *amba_devs[] __initdata = {
219 &dmac_device,
220 &uart0_device,
221 &uart1_device,
222 &uart2_device,
223 &uart3_device,
224 &smc_device,
225 &clcd_device,
226 &sctl_device,
227 &wdog_device,
228 &gpio0_device,
229 &gpio1_device,
230 &gpio2_device,
231 &rtc_device,
232 &sci0_device,
233 &ssp0_device,
234 &aaci_device,
235 &mmc0_device,
236 &kmi0_device,
237 &kmi1_device,
238};
239
240/*
241 * RealView PB-X platform devices
242 */
243static struct resource realview_pbx_flash_resources[] = {
244 [0] = {
245 .start = REALVIEW_PBX_FLASH0_BASE,
246 .end = REALVIEW_PBX_FLASH0_BASE + REALVIEW_PBX_FLASH0_SIZE - 1,
247 .flags = IORESOURCE_MEM,
248 },
249 [1] = {
250 .start = REALVIEW_PBX_FLASH1_BASE,
251 .end = REALVIEW_PBX_FLASH1_BASE + REALVIEW_PBX_FLASH1_SIZE - 1,
252 .flags = IORESOURCE_MEM,
253 },
254};
255
256static struct resource realview_pbx_smsc911x_resources[] = {
257 [0] = {
258 .start = REALVIEW_PBX_ETH_BASE,
259 .end = REALVIEW_PBX_ETH_BASE + SZ_64K - 1,
260 .flags = IORESOURCE_MEM,
261 },
262 [1] = {
263 .start = IRQ_PBX_ETH,
264 .end = IRQ_PBX_ETH,
265 .flags = IORESOURCE_IRQ,
266 },
267};
268
269static struct resource realview_pbx_isp1761_resources[] = {
270 [0] = {
271 .start = REALVIEW_PBX_USB_BASE,
272 .end = REALVIEW_PBX_USB_BASE + SZ_128K - 1,
273 .flags = IORESOURCE_MEM,
274 },
275 [1] = {
276 .start = IRQ_PBX_USB,
277 .end = IRQ_PBX_USB,
278 .flags = IORESOURCE_IRQ,
279 },
280};
281
Will Deaconf417cba2010-04-15 10:16:26 +0100282static struct resource pmu_resources[] = {
283 [0] = {
284 .start = IRQ_PBX_PMU_CPU0,
285 .end = IRQ_PBX_PMU_CPU0,
286 .flags = IORESOURCE_IRQ,
287 },
288 [1] = {
289 .start = IRQ_PBX_PMU_CPU1,
290 .end = IRQ_PBX_PMU_CPU1,
291 .flags = IORESOURCE_IRQ,
292 },
293 [2] = {
294 .start = IRQ_PBX_PMU_CPU2,
295 .end = IRQ_PBX_PMU_CPU2,
296 .flags = IORESOURCE_IRQ,
297 },
298 [3] = {
299 .start = IRQ_PBX_PMU_CPU3,
300 .end = IRQ_PBX_PMU_CPU3,
301 .flags = IORESOURCE_IRQ,
302 },
303};
304
305static struct platform_device pmu_device = {
306 .name = "arm-pmu",
307 .id = ARM_PMU_DEVICE_CPU,
308 .num_resources = ARRAY_SIZE(pmu_resources),
309 .resource = pmu_resources,
310};
311
Colin Tuckley1b504bb2009-05-30 13:56:12 +0100312static void __init gic_init_irq(void)
313{
314 /* ARM PBX on-board GIC */
315 if (core_tile_pbx11mp() || core_tile_pbxa9mp()) {
316 gic_cpu_base_addr = __io_address(REALVIEW_PBX_TILE_GIC_CPU_BASE);
317 gic_dist_init(0, __io_address(REALVIEW_PBX_TILE_GIC_DIST_BASE),
318 29);
319 gic_cpu_init(0, __io_address(REALVIEW_PBX_TILE_GIC_CPU_BASE));
320 } else {
321 gic_cpu_base_addr = __io_address(REALVIEW_PBX_GIC_CPU_BASE);
322 gic_dist_init(0, __io_address(REALVIEW_PBX_GIC_DIST_BASE),
323 IRQ_PBX_GIC_START);
324 gic_cpu_init(0, __io_address(REALVIEW_PBX_GIC_CPU_BASE));
325 }
326}
327
328static void __init realview_pbx_timer_init(void)
329{
330 timer0_va_base = __io_address(REALVIEW_PBX_TIMER0_1_BASE);
331 timer1_va_base = __io_address(REALVIEW_PBX_TIMER0_1_BASE) + 0x20;
332 timer2_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE);
333 timer3_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE) + 0x20;
334
335#ifdef CONFIG_LOCAL_TIMERS
336 if (core_tile_pbx11mp() || core_tile_pbxa9mp())
337 twd_base = __io_address(REALVIEW_PBX_TILE_TWD_BASE);
338#endif
339 realview_timer_init(IRQ_PBX_TIMER0_1);
340}
341
342static struct sys_timer realview_pbx_timer = {
343 .init = realview_pbx_timer_init,
344};
345
Catalin Marinasc97c5aa2009-11-04 12:19:05 +0000346static void realview_pbx_fixup(struct machine_desc *mdesc, struct tag *tags,
347 char **from, struct meminfo *meminfo)
348{
349#ifdef CONFIG_SPARSEMEM
350 /*
351 * Memory configuration with SPARSEMEM enabled on RealView PBX (see
352 * asm/mach/memory.h for more information).
353 */
354 meminfo->bank[0].start = 0;
355 meminfo->bank[0].size = SZ_256M;
356 meminfo->bank[1].start = 0x20000000;
357 meminfo->bank[1].size = SZ_512M;
358 meminfo->bank[2].start = 0x80000000;
359 meminfo->bank[2].size = SZ_256M;
360 meminfo->nr_banks = 3;
361#else
362 realview_fixup(mdesc, tags, from, meminfo);
363#endif
364}
365
Colin Tuckley4c9f8be2010-01-11 11:09:15 +0100366static void realview_pbx_reset(char mode)
367{
368 void __iomem *reset_ctrl = __io_address(REALVIEW_SYS_RESETCTL);
369 void __iomem *lock_ctrl = __io_address(REALVIEW_SYS_LOCK);
370
371 /*
372 * To reset, we hit the on-board reset register
373 * in the system FPGA
374 */
375 __raw_writel(REALVIEW_SYS_LOCK_VAL, lock_ctrl);
Colin Tuckleydf2e6152010-01-29 12:52:55 +0100376 __raw_writel(0x00F0, reset_ctrl);
377 __raw_writel(0x00F4, reset_ctrl);
Colin Tuckley4c9f8be2010-01-11 11:09:15 +0100378}
379
Colin Tuckley1b504bb2009-05-30 13:56:12 +0100380static void __init realview_pbx_init(void)
381{
382 int i;
383
384#ifdef CONFIG_CACHE_L2X0
385 if (core_tile_pbxa9mp()) {
386 void __iomem *l2x0_base =
387 __io_address(REALVIEW_PBX_TILE_L220_BASE);
388
389 /* set RAM latencies to 1 cycle for eASIC */
390 writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL);
391 writel(0, l2x0_base + L2X0_DATA_LATENCY_CTRL);
392
393 /* 16KB way size, 8-way associativity, parity disabled
394 * Bits: .. 0 0 0 0 1 00 1 0 1 001 0 000 0 .... .... .... */
395 l2x0_init(l2x0_base, 0x02520000, 0xc0000fff);
Will Deaconf417cba2010-04-15 10:16:26 +0100396 platform_device_register(&pmu_device);
Colin Tuckley1b504bb2009-05-30 13:56:12 +0100397 }
398#endif
399
400 realview_flash_register(realview_pbx_flash_resources,
401 ARRAY_SIZE(realview_pbx_flash_resources));
402 realview_eth_register(NULL, realview_pbx_smsc911x_resources);
403 platform_device_register(&realview_i2c_device);
404 platform_device_register(&realview_cf_device);
405 realview_usb_register(realview_pbx_isp1761_resources);
406
407 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
408 struct amba_device *d = amba_devs[i];
409 amba_device_register(d, &iomem_resource);
410 }
411
412#ifdef CONFIG_LEDS
413 leds_event = realview_leds_event;
414#endif
Colin Tuckley4c9f8be2010-01-11 11:09:15 +0100415 realview_reset = realview_pbx_reset;
Colin Tuckley1b504bb2009-05-30 13:56:12 +0100416}
417
418MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX")
419 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
Catalin Marinascc9897d2010-06-21 15:12:40 +0100420 .phys_io = REALVIEW_PBX_UART0_BASE & SECTION_MASK,
Colin Tuckley1b504bb2009-05-30 13:56:12 +0100421 .io_pg_offst = (IO_ADDRESS(REALVIEW_PBX_UART0_BASE) >> 18) & 0xfffc,
422 .boot_params = PHYS_OFFSET + 0x00000100,
Catalin Marinasc97c5aa2009-11-04 12:19:05 +0000423 .fixup = realview_pbx_fixup,
Colin Tuckley1b504bb2009-05-30 13:56:12 +0100424 .map_io = realview_pbx_map_io,
425 .init_irq = gic_init_irq,
426 .timer = &realview_pbx_timer,
427 .init_machine = realview_pbx_init,
428MACHINE_END