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