2 * arch/arm/mach-realview/realview_pbx.c
4 * Copyright (C) 2009 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd
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.
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.
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
21 #include <linux/init.h>
22 #include <linux/platform_device.h>
23 #include <linux/device.h>
24 #include <linux/amba/bus.h>
25 #include <linux/amba/pl061.h>
26 #include <linux/amba/mmci.h>
27 #include <linux/amba/pl022.h>
29 #include <linux/irqchip/arm-gic.h>
30 #include <linux/platform_data/clk-realview.h>
31 #include <linux/reboot.h>
32 #include <linux/memblock.h>
35 #include <asm/mach-types.h>
36 #include <asm/smp_twd.h>
37 #include <asm/pgtable.h>
38 #include <asm/hardware/cache-l2x0.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/map.h>
42 #include <asm/mach/time.h>
44 #include <mach/hardware.h>
45 #include <mach/board-pbx.h>
46 #include <mach/irqs.h>
50 static struct map_desc realview_pbx_io_desc
[] __initdata
= {
52 .virtual = IO_ADDRESS(REALVIEW_SYS_BASE
),
53 .pfn
= __phys_to_pfn(REALVIEW_SYS_BASE
),
57 .virtual = IO_ADDRESS(REALVIEW_PBX_GIC_CPU_BASE
),
58 .pfn
= __phys_to_pfn(REALVIEW_PBX_GIC_CPU_BASE
),
62 .virtual = IO_ADDRESS(REALVIEW_PBX_GIC_DIST_BASE
),
63 .pfn
= __phys_to_pfn(REALVIEW_PBX_GIC_DIST_BASE
),
67 .virtual = IO_ADDRESS(REALVIEW_SCTL_BASE
),
68 .pfn
= __phys_to_pfn(REALVIEW_SCTL_BASE
),
72 .virtual = IO_ADDRESS(REALVIEW_PBX_TIMER0_1_BASE
),
73 .pfn
= __phys_to_pfn(REALVIEW_PBX_TIMER0_1_BASE
),
77 .virtual = IO_ADDRESS(REALVIEW_PBX_TIMER2_3_BASE
),
78 .pfn
= __phys_to_pfn(REALVIEW_PBX_TIMER2_3_BASE
),
84 .virtual = PCIX_UNIT_BASE
,
85 .pfn
= __phys_to_pfn(REALVIEW_PBX_PCI_BASE
),
86 .length
= REALVIEW_PBX_PCI_BASE_SIZE
,
90 #ifdef CONFIG_DEBUG_LL
92 .virtual = IO_ADDRESS(REALVIEW_PBX_UART0_BASE
),
93 .pfn
= __phys_to_pfn(REALVIEW_PBX_UART0_BASE
),
100 static struct map_desc realview_local_io_desc
[] __initdata
= {
102 .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_SCU_BASE
),
103 .pfn
= __phys_to_pfn(REALVIEW_PBX_TILE_SCU_BASE
),
107 .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_GIC_DIST_BASE
),
108 .pfn
= __phys_to_pfn(REALVIEW_PBX_TILE_GIC_DIST_BASE
),
112 .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_L220_BASE
),
113 .pfn
= __phys_to_pfn(REALVIEW_PBX_TILE_L220_BASE
),
119 static void __init
realview_pbx_map_io(void)
121 iotable_init(realview_pbx_io_desc
, ARRAY_SIZE(realview_pbx_io_desc
));
122 if (core_tile_pbx11mp() || core_tile_pbxa9mp())
123 iotable_init(realview_local_io_desc
, ARRAY_SIZE(realview_local_io_desc
));
126 static struct pl061_platform_data gpio0_plat_data
= {
130 static struct pl061_platform_data gpio1_plat_data
= {
134 static struct pl061_platform_data gpio2_plat_data
= {
138 static struct pl022_ssp_controller ssp0_plat_data
= {
145 * RealView PBXCore AMBA devices
148 #define GPIO2_IRQ { IRQ_PBX_GPIO2 }
149 #define GPIO3_IRQ { IRQ_PBX_GPIO3 }
150 #define AACI_IRQ { IRQ_PBX_AACI }
151 #define MMCI0_IRQ { IRQ_PBX_MMCI0A, IRQ_PBX_MMCI0B }
152 #define KMI0_IRQ { IRQ_PBX_KMI0 }
153 #define KMI1_IRQ { IRQ_PBX_KMI1 }
154 #define PBX_SMC_IRQ { }
156 #define PBX_CLCD_IRQ { IRQ_PBX_CLCD }
157 #define DMAC_IRQ { IRQ_PBX_DMAC }
159 #define PBX_WATCHDOG_IRQ { IRQ_PBX_WATCHDOG }
160 #define PBX_GPIO0_IRQ { IRQ_PBX_GPIO0 }
161 #define GPIO1_IRQ { IRQ_PBX_GPIO1 }
162 #define PBX_RTC_IRQ { IRQ_PBX_RTC }
163 #define SCI_IRQ { IRQ_PBX_SCI }
164 #define PBX_UART0_IRQ { IRQ_PBX_UART0 }
165 #define PBX_UART1_IRQ { IRQ_PBX_UART1 }
166 #define PBX_UART2_IRQ { IRQ_PBX_UART2 }
167 #define PBX_UART3_IRQ { IRQ_PBX_UART3 }
168 #define PBX_SSP_IRQ { IRQ_PBX_SSP }
170 /* FPGA Primecells */
171 APB_DEVICE(aaci
, "fpga:aaci", AACI
, NULL
);
172 APB_DEVICE(mmc0
, "fpga:mmc0", MMCI0
, &realview_mmc0_plat_data
);
173 APB_DEVICE(kmi0
, "fpga:kmi0", KMI0
, NULL
);
174 APB_DEVICE(kmi1
, "fpga:kmi1", KMI1
, NULL
);
175 APB_DEVICE(uart3
, "fpga:uart3", PBX_UART3
, NULL
);
177 /* DevChip Primecells */
178 AHB_DEVICE(smc
, "dev:smc", PBX_SMC
, NULL
);
179 AHB_DEVICE(sctl
, "dev:sctl", SCTL
, NULL
);
180 APB_DEVICE(wdog
, "dev:wdog", PBX_WATCHDOG
, NULL
);
181 APB_DEVICE(gpio0
, "dev:gpio0", PBX_GPIO0
, &gpio0_plat_data
);
182 APB_DEVICE(gpio1
, "dev:gpio1", GPIO1
, &gpio1_plat_data
);
183 APB_DEVICE(gpio2
, "dev:gpio2", GPIO2
, &gpio2_plat_data
);
184 APB_DEVICE(rtc
, "dev:rtc", PBX_RTC
, NULL
);
185 APB_DEVICE(sci0
, "dev:sci0", SCI
, NULL
);
186 APB_DEVICE(uart0
, "dev:uart0", PBX_UART0
, NULL
);
187 APB_DEVICE(uart1
, "dev:uart1", PBX_UART1
, NULL
);
188 APB_DEVICE(uart2
, "dev:uart2", PBX_UART2
, NULL
);
189 APB_DEVICE(ssp0
, "dev:ssp0", PBX_SSP
, &ssp0_plat_data
);
191 /* Primecells on the NEC ISSP chip */
192 AHB_DEVICE(clcd
, "issp:clcd", PBX_CLCD
, &clcd_plat_data
);
193 AHB_DEVICE(dmac
, "issp:dmac", DMAC
, NULL
);
195 static struct amba_device
*amba_devs
[] __initdata
= {
218 * RealView PB-X platform devices
220 static struct resource realview_pbx_flash_resources
[] = {
222 .start
= REALVIEW_PBX_FLASH0_BASE
,
223 .end
= REALVIEW_PBX_FLASH0_BASE
+ REALVIEW_PBX_FLASH0_SIZE
- 1,
224 .flags
= IORESOURCE_MEM
,
227 .start
= REALVIEW_PBX_FLASH1_BASE
,
228 .end
= REALVIEW_PBX_FLASH1_BASE
+ REALVIEW_PBX_FLASH1_SIZE
- 1,
229 .flags
= IORESOURCE_MEM
,
233 static struct resource realview_pbx_smsc911x_resources
[] = {
235 .start
= REALVIEW_PBX_ETH_BASE
,
236 .end
= REALVIEW_PBX_ETH_BASE
+ SZ_64K
- 1,
237 .flags
= IORESOURCE_MEM
,
240 .start
= IRQ_PBX_ETH
,
242 .flags
= IORESOURCE_IRQ
,
246 static struct resource realview_pbx_isp1761_resources
[] = {
248 .start
= REALVIEW_PBX_USB_BASE
,
249 .end
= REALVIEW_PBX_USB_BASE
+ SZ_128K
- 1,
250 .flags
= IORESOURCE_MEM
,
253 .start
= IRQ_PBX_USB
,
255 .flags
= IORESOURCE_IRQ
,
259 static struct resource pmu_resources
[] = {
261 .start
= IRQ_PBX_PMU_CPU0
,
262 .end
= IRQ_PBX_PMU_CPU0
,
263 .flags
= IORESOURCE_IRQ
,
266 .start
= IRQ_PBX_PMU_CPU1
,
267 .end
= IRQ_PBX_PMU_CPU1
,
268 .flags
= IORESOURCE_IRQ
,
271 .start
= IRQ_PBX_PMU_CPU2
,
272 .end
= IRQ_PBX_PMU_CPU2
,
273 .flags
= IORESOURCE_IRQ
,
276 .start
= IRQ_PBX_PMU_CPU3
,
277 .end
= IRQ_PBX_PMU_CPU3
,
278 .flags
= IORESOURCE_IRQ
,
282 static struct platform_device pmu_device
= {
285 .num_resources
= ARRAY_SIZE(pmu_resources
),
286 .resource
= pmu_resources
,
289 static void __init
gic_init_irq(void)
291 /* ARM PBX on-board GIC */
292 if (core_tile_pbx11mp() || core_tile_pbxa9mp()) {
293 gic_init(0, 29, __io_address(REALVIEW_PBX_TILE_GIC_DIST_BASE
),
294 __io_address(REALVIEW_PBX_TILE_GIC_CPU_BASE
));
296 gic_init(0, IRQ_PBX_GIC_START
,
297 __io_address(REALVIEW_PBX_GIC_DIST_BASE
),
298 __io_address(REALVIEW_PBX_GIC_CPU_BASE
));
302 #ifdef CONFIG_HAVE_ARM_TWD
303 static DEFINE_TWD_LOCAL_TIMER(twd_local_timer
,
304 REALVIEW_PBX_TILE_TWD_BASE
,
307 static void __init
realview_pbx_twd_init(void)
309 int err
= twd_local_timer_register(&twd_local_timer
);
311 pr_err("twd_local_timer_register failed %d\n", err
);
314 #define realview_pbx_twd_init() do { } while(0)
317 static void __init
realview_pbx_timer_init(void)
319 timer0_va_base
= __io_address(REALVIEW_PBX_TIMER0_1_BASE
);
320 timer1_va_base
= __io_address(REALVIEW_PBX_TIMER0_1_BASE
) + 0x20;
321 timer2_va_base
= __io_address(REALVIEW_PBX_TIMER2_3_BASE
);
322 timer3_va_base
= __io_address(REALVIEW_PBX_TIMER2_3_BASE
) + 0x20;
324 realview_clk_init(__io_address(REALVIEW_SYS_BASE
), false);
325 realview_timer_init(IRQ_PBX_TIMER0_1
);
326 realview_pbx_twd_init();
329 static void realview_pbx_fixup(struct tag
*tags
, char **from
)
331 #ifdef CONFIG_SPARSEMEM
333 * Memory configuration with SPARSEMEM enabled on RealView PBX (see
334 * asm/mach/memory.h for more information).
337 memblock_add(0, SZ_256M
);
338 memblock_add(0x20000000, SZ_512M
);
339 memblock_add(0x80000000, SZ_256M
);
341 realview_fixup(tags
, from
);
345 static void realview_pbx_restart(enum reboot_mode mode
, const char *cmd
)
347 void __iomem
*reset_ctrl
= __io_address(REALVIEW_SYS_RESETCTL
);
348 void __iomem
*lock_ctrl
= __io_address(REALVIEW_SYS_LOCK
);
351 * To reset, we hit the on-board reset register
354 __raw_writel(REALVIEW_SYS_LOCK_VAL
, lock_ctrl
);
355 __raw_writel(0x00F0, reset_ctrl
);
356 __raw_writel(0x00F4, reset_ctrl
);
360 static void __init
realview_pbx_init(void)
364 #ifdef CONFIG_CACHE_L2X0
365 if (core_tile_pbxa9mp()) {
366 void __iomem
*l2x0_base
=
367 __io_address(REALVIEW_PBX_TILE_L220_BASE
);
369 /* set RAM latencies to 1 cycle for eASIC */
370 writel(0, l2x0_base
+ L310_TAG_LATENCY_CTRL
);
371 writel(0, l2x0_base
+ L310_DATA_LATENCY_CTRL
);
373 /* 16KB way size, 8-way associativity, parity disabled
374 * Bits: .. 0 0 0 0 1 00 1 0 1 001 0 000 0 .... .... .... */
375 l2x0_init(l2x0_base
, 0x02520000, 0xc0000fff);
376 platform_device_register(&pmu_device
);
380 realview_flash_register(realview_pbx_flash_resources
,
381 ARRAY_SIZE(realview_pbx_flash_resources
));
382 realview_eth_register(NULL
, realview_pbx_smsc911x_resources
);
383 platform_device_register(&realview_i2c_device
);
384 platform_device_register(&realview_cf_device
);
385 platform_device_register(&realview_leds_device
);
386 realview_usb_register(realview_pbx_isp1761_resources
);
388 for (i
= 0; i
< ARRAY_SIZE(amba_devs
); i
++) {
389 struct amba_device
*d
= amba_devs
[i
];
390 amba_device_register(d
, &iomem_resource
);
394 MACHINE_START(REALVIEW_PBX
, "ARM-RealView PBX")
395 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
396 .atag_offset
= 0x100,
397 .smp
= smp_ops(realview_smp_ops
),
398 .fixup
= realview_pbx_fixup
,
399 .map_io
= realview_pbx_map_io
,
400 .init_early
= realview_init_early
,
401 .init_irq
= gic_init_irq
,
402 .init_time
= realview_pbx_timer_init
,
403 .init_machine
= realview_pbx_init
,
404 #ifdef CONFIG_ZONE_DMA
405 .dma_zone_size
= SZ_256M
,
407 .restart
= realview_pbx_restart
,