2 * Versatile Express V2M Motherboard Support
4 #include <linux/device.h>
5 #include <linux/amba/bus.h>
6 #include <linux/amba/mmci.h>
9 #include <linux/init.h>
10 #include <linux/of_address.h>
11 #include <linux/of_fdt.h>
12 #include <linux/of_irq.h>
13 #include <linux/of_platform.h>
14 #include <linux/platform_device.h>
15 #include <linux/ata_platform.h>
16 #include <linux/smsc911x.h>
17 #include <linux/spinlock.h>
18 #include <linux/usb/isp1760.h>
19 #include <linux/mtd/physmap.h>
20 #include <linux/regulator/fixed.h>
21 #include <linux/regulator/machine.h>
22 #include <linux/vexpress.h>
24 #include <asm/arch_timer.h>
25 #include <asm/mach-types.h>
26 #include <asm/sizes.h>
27 #include <asm/smp_twd.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/time.h>
31 #include <asm/hardware/arm_timer.h>
32 #include <asm/hardware/cache-l2x0.h>
33 #include <asm/hardware/gic.h>
34 #include <asm/hardware/timer-sp.h>
36 #include <mach/ct-ca9x4.h>
37 #include <mach/motherboard.h>
39 #include <plat/sched_clock.h>
40 #include <plat/platsmp.h>
44 #define V2M_PA_CS0 0x40000000
45 #define V2M_PA_CS1 0x44000000
46 #define V2M_PA_CS2 0x48000000
47 #define V2M_PA_CS3 0x4c000000
48 #define V2M_PA_CS7 0x10000000
50 static struct map_desc v2m_io_desc
[] __initdata
= {
52 .virtual = V2M_PERIPH
,
53 .pfn
= __phys_to_pfn(V2M_PA_CS7
),
59 static void __init
v2m_sp804_init(void __iomem
*base
, unsigned int irq
)
61 if (WARN_ON(!base
|| irq
== NO_IRQ
))
64 writel(0, base
+ TIMER_1_BASE
+ TIMER_CTRL
);
65 writel(0, base
+ TIMER_2_BASE
+ TIMER_CTRL
);
67 sp804_clocksource_init(base
+ TIMER_2_BASE
, "v2m-timer1");
68 sp804_clockevents_init(base
+ TIMER_1_BASE
, irq
, "v2m-timer0");
72 static struct resource v2m_pcie_i2c_resource
= {
73 .start
= V2M_SERIAL_BUS_PCI
,
74 .end
= V2M_SERIAL_BUS_PCI
+ SZ_4K
- 1,
75 .flags
= IORESOURCE_MEM
,
78 static struct platform_device v2m_pcie_i2c_device
= {
79 .name
= "versatile-i2c",
82 .resource
= &v2m_pcie_i2c_resource
,
85 static struct resource v2m_ddc_i2c_resource
= {
86 .start
= V2M_SERIAL_BUS_DVI
,
87 .end
= V2M_SERIAL_BUS_DVI
+ SZ_4K
- 1,
88 .flags
= IORESOURCE_MEM
,
91 static struct platform_device v2m_ddc_i2c_device
= {
92 .name
= "versatile-i2c",
95 .resource
= &v2m_ddc_i2c_resource
,
98 static struct resource v2m_eth_resources
[] = {
100 .start
= V2M_LAN9118
,
101 .end
= V2M_LAN9118
+ SZ_64K
- 1,
102 .flags
= IORESOURCE_MEM
,
104 .start
= IRQ_V2M_LAN9118
,
105 .end
= IRQ_V2M_LAN9118
,
106 .flags
= IORESOURCE_IRQ
,
110 static struct smsc911x_platform_config v2m_eth_config
= {
111 .flags
= SMSC911X_USE_32BIT
,
112 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_HIGH
,
113 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
114 .phy_interface
= PHY_INTERFACE_MODE_MII
,
117 static struct platform_device v2m_eth_device
= {
120 .resource
= v2m_eth_resources
,
121 .num_resources
= ARRAY_SIZE(v2m_eth_resources
),
122 .dev
.platform_data
= &v2m_eth_config
,
125 static struct regulator_consumer_supply v2m_eth_supplies
[] = {
126 REGULATOR_SUPPLY("vddvario", "smsc911x"),
127 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
130 static struct resource v2m_usb_resources
[] = {
132 .start
= V2M_ISP1761
,
133 .end
= V2M_ISP1761
+ SZ_128K
- 1,
134 .flags
= IORESOURCE_MEM
,
136 .start
= IRQ_V2M_ISP1761
,
137 .end
= IRQ_V2M_ISP1761
,
138 .flags
= IORESOURCE_IRQ
,
142 static struct isp1760_platform_data v2m_usb_config
= {
144 .bus_width_16
= false,
147 .dack_polarity_high
= false,
148 .dreq_polarity_high
= false,
151 static struct platform_device v2m_usb_device
= {
154 .resource
= v2m_usb_resources
,
155 .num_resources
= ARRAY_SIZE(v2m_usb_resources
),
156 .dev
.platform_data
= &v2m_usb_config
,
159 static struct physmap_flash_data v2m_flash_data
= {
163 static struct resource v2m_flash_resources
[] = {
166 .end
= V2M_NOR0
+ SZ_64M
- 1,
167 .flags
= IORESOURCE_MEM
,
170 .end
= V2M_NOR1
+ SZ_64M
- 1,
171 .flags
= IORESOURCE_MEM
,
175 static struct platform_device v2m_flash_device
= {
176 .name
= "physmap-flash",
178 .resource
= v2m_flash_resources
,
179 .num_resources
= ARRAY_SIZE(v2m_flash_resources
),
180 .dev
.platform_data
= &v2m_flash_data
,
183 static struct pata_platform_info v2m_pata_data
= {
187 static struct resource v2m_pata_resources
[] = {
190 .end
= V2M_CF
+ 0xff,
191 .flags
= IORESOURCE_MEM
,
193 .start
= V2M_CF
+ 0x100,
194 .end
= V2M_CF
+ SZ_4K
- 1,
195 .flags
= IORESOURCE_MEM
,
199 static struct platform_device v2m_cf_device
= {
200 .name
= "pata_platform",
202 .resource
= v2m_pata_resources
,
203 .num_resources
= ARRAY_SIZE(v2m_pata_resources
),
204 .dev
.platform_data
= &v2m_pata_data
,
207 static struct mmci_platform_data v2m_mmci_data
= {
208 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
209 .gpio_wp
= VEXPRESS_GPIO_MMC_WPROT
,
210 .gpio_cd
= VEXPRESS_GPIO_MMC_CARDIN
,
213 static struct resource v2m_sysreg_resources
[] = {
215 .start
= V2M_SYSREGS
,
216 .end
= V2M_SYSREGS
+ 0xfff,
217 .flags
= IORESOURCE_MEM
,
221 static struct platform_device v2m_sysreg_device
= {
222 .name
= "vexpress-sysreg",
224 .resource
= v2m_sysreg_resources
,
225 .num_resources
= ARRAY_SIZE(v2m_sysreg_resources
),
228 static struct platform_device v2m_muxfpga_device
= {
229 .name
= "vexpress-muxfpga",
232 .resource
= (struct resource
[]) {
233 VEXPRESS_RES_FUNC(0, 7),
237 static struct platform_device v2m_shutdown_device
= {
238 .name
= "vexpress-shutdown",
241 .resource
= (struct resource
[]) {
242 VEXPRESS_RES_FUNC(0, 8),
246 static struct platform_device v2m_reboot_device
= {
247 .name
= "vexpress-reboot",
250 .resource
= (struct resource
[]) {
251 VEXPRESS_RES_FUNC(0, 9),
255 static struct platform_device v2m_dvimode_device
= {
256 .name
= "vexpress-dvimode",
259 .resource
= (struct resource
[]) {
260 VEXPRESS_RES_FUNC(0, 11),
264 static AMBA_APB_DEVICE(aaci
, "mb:aaci", 0, V2M_AACI
, IRQ_V2M_AACI
, NULL
);
265 static AMBA_APB_DEVICE(mmci
, "mb:mmci", 0, V2M_MMCI
, IRQ_V2M_MMCI
, &v2m_mmci_data
);
266 static AMBA_APB_DEVICE(kmi0
, "mb:kmi0", 0, V2M_KMI0
, IRQ_V2M_KMI0
, NULL
);
267 static AMBA_APB_DEVICE(kmi1
, "mb:kmi1", 0, V2M_KMI1
, IRQ_V2M_KMI1
, NULL
);
268 static AMBA_APB_DEVICE(uart0
, "mb:uart0", 0, V2M_UART0
, IRQ_V2M_UART0
, NULL
);
269 static AMBA_APB_DEVICE(uart1
, "mb:uart1", 0, V2M_UART1
, IRQ_V2M_UART1
, NULL
);
270 static AMBA_APB_DEVICE(uart2
, "mb:uart2", 0, V2M_UART2
, IRQ_V2M_UART2
, NULL
);
271 static AMBA_APB_DEVICE(uart3
, "mb:uart3", 0, V2M_UART3
, IRQ_V2M_UART3
, NULL
);
272 static AMBA_APB_DEVICE(wdt
, "mb:wdt", 0, V2M_WDT
, IRQ_V2M_WDT
, NULL
);
273 static AMBA_APB_DEVICE(rtc
, "mb:rtc", 0, V2M_RTC
, IRQ_V2M_RTC
, NULL
);
275 static struct amba_device
*v2m_amba_devs
[] __initdata
= {
288 static void __init
v2m_timer_init(void)
290 vexpress_clk_init(ioremap(V2M_SYSCTL
, SZ_4K
));
291 v2m_sp804_init(ioremap(V2M_TIMER01
, SZ_4K
), IRQ_V2M_TIMER0
);
294 static struct sys_timer v2m_timer
= {
295 .init
= v2m_timer_init
,
298 static void __init
v2m_init_early(void)
300 if (ct_desc
->init_early
)
301 ct_desc
->init_early();
302 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
305 struct ct_desc
*ct_desc
;
307 static struct ct_desc
*ct_descs
[] __initdata
= {
308 #ifdef CONFIG_ARCH_VEXPRESS_CA9X4
313 static void __init
v2m_populate_ct_desc(void)
319 current_tile_id
= vexpress_get_procid(VEXPRESS_SITE_MASTER
)
322 for (i
= 0; i
< ARRAY_SIZE(ct_descs
) && !ct_desc
; ++i
)
323 if (ct_descs
[i
]->id
== current_tile_id
)
324 ct_desc
= ct_descs
[i
];
327 panic("vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.\n"
328 "You may need a device tree blob or a different kernel to boot on this board.\n",
332 static void __init
v2m_map_io(void)
334 iotable_init(v2m_io_desc
, ARRAY_SIZE(v2m_io_desc
));
335 vexpress_sysreg_early_init(ioremap(V2M_SYSREGS
, SZ_4K
));
336 v2m_populate_ct_desc();
340 static void __init
v2m_init_irq(void)
345 static void __init
v2m_init(void)
349 regulator_register_fixed(0, v2m_eth_supplies
,
350 ARRAY_SIZE(v2m_eth_supplies
));
352 platform_device_register(&v2m_muxfpga_device
);
353 platform_device_register(&v2m_shutdown_device
);
354 platform_device_register(&v2m_reboot_device
);
355 platform_device_register(&v2m_dvimode_device
);
357 platform_device_register(&v2m_sysreg_device
);
358 platform_device_register(&v2m_pcie_i2c_device
);
359 platform_device_register(&v2m_ddc_i2c_device
);
360 platform_device_register(&v2m_flash_device
);
361 platform_device_register(&v2m_cf_device
);
362 platform_device_register(&v2m_eth_device
);
363 platform_device_register(&v2m_usb_device
);
365 for (i
= 0; i
< ARRAY_SIZE(v2m_amba_devs
); i
++)
366 amba_device_register(v2m_amba_devs
[i
], &iomem_resource
);
368 pm_power_off
= vexpress_power_off
;
370 ct_desc
->init_tile();
373 MACHINE_START(VEXPRESS
, "ARM-Versatile Express")
374 .atag_offset
= 0x100,
375 .smp
= smp_ops(vexpress_smp_ops
),
376 .map_io
= v2m_map_io
,
377 .init_early
= v2m_init_early
,
378 .init_irq
= v2m_init_irq
,
380 .handle_irq
= gic_handle_irq
,
381 .init_machine
= v2m_init
,
382 .restart
= vexpress_restart
,
385 static struct map_desc v2m_rs1_io_desc __initdata
= {
386 .virtual = V2M_PERIPH
,
387 .pfn
= __phys_to_pfn(0x1c000000),
392 static int __init
v2m_dt_scan_memory_map(unsigned long node
, const char *uname
,
393 int depth
, void *data
)
395 const char **map
= data
;
397 if (strcmp(uname
, "motherboard") != 0)
400 *map
= of_get_flat_dt_prop(node
, "arm,v2m-memory-map", NULL
);
405 void __init
v2m_dt_map_io(void)
407 const char *map
= NULL
;
409 of_scan_flat_dt(v2m_dt_scan_memory_map
, &map
);
411 if (map
&& strcmp(map
, "rs1") == 0)
412 iotable_init(&v2m_rs1_io_desc
, 1);
414 iotable_init(v2m_io_desc
, ARRAY_SIZE(v2m_io_desc
));
416 #if defined(CONFIG_SMP)
417 vexpress_dt_smp_map_io();
421 void __init
v2m_dt_init_early(void)
425 vexpress_sysreg_of_early_init();
427 /* Confirm board type against DT property, if available */
428 if (of_property_read_u32(of_allnodes
, "arm,hbi", &dt_hbi
) == 0) {
429 u32 hbi
= vexpress_get_hbi(VEXPRESS_SITE_MASTER
);
431 if (WARN_ON(dt_hbi
!= hbi
))
432 pr_warning("vexpress: DT HBI (%x) is not matching "
433 "hardware (%x)!\n", dt_hbi
, hbi
);
437 static struct of_device_id vexpress_irq_match
[] __initdata
= {
438 { .compatible
= "arm,cortex-a9-gic", .data
= gic_of_init
, },
442 static void __init
v2m_dt_init_irq(void)
444 of_irq_init(vexpress_irq_match
);
447 static void __init
v2m_dt_timer_init(void)
449 struct device_node
*node
= NULL
;
451 vexpress_clk_of_init();
454 node
= of_find_compatible_node(node
, NULL
, "arm,sp804");
455 } while (node
&& vexpress_get_site_by_node(node
) != VEXPRESS_SITE_MB
);
457 pr_info("Using SP804 '%s' as a clock & events source\n",
459 v2m_sp804_init(of_iomap(node
, 0),
460 irq_of_parse_and_map(node
, 0));
463 if (arch_timer_of_register() != 0)
464 twd_local_timer_of_register();
466 if (arch_timer_sched_clock_init() != 0)
467 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
471 static struct sys_timer v2m_dt_timer
= {
472 .init
= v2m_dt_timer_init
,
475 static const struct of_device_id v2m_dt_bus_match
[] __initconst
= {
476 { .compatible
= "simple-bus", },
477 { .compatible
= "arm,amba-bus", },
478 { .compatible
= "arm,vexpress,config-bus", },
482 static void __init
v2m_dt_init(void)
484 l2x0_of_init(0x00400000, 0xfe0fffff);
485 of_platform_populate(NULL
, v2m_dt_bus_match
, NULL
, NULL
);
486 pm_power_off
= vexpress_power_off
;
489 static const char * const v2m_dt_match
[] __initconst
= {
495 DT_MACHINE_START(VEXPRESS_DT
, "ARM-Versatile Express")
496 .dt_compat
= v2m_dt_match
,
497 .smp
= smp_ops(vexpress_smp_ops
),
498 .map_io
= v2m_dt_map_io
,
499 .init_early
= v2m_dt_init_early
,
500 .init_irq
= v2m_dt_init_irq
,
501 .timer
= &v2m_dt_timer
,
502 .init_machine
= v2m_dt_init
,
503 .handle_irq
= gic_handle_irq
,
504 .restart
= vexpress_restart
,