2 * Versatile Express V2M Motherboard Support
4 #include <linux/clocksource.h>
5 #include <linux/device.h>
6 #include <linux/amba/bus.h>
7 #include <linux/amba/mmci.h>
9 #include <linux/clocksource.h>
10 #include <linux/smp.h>
11 #include <linux/init.h>
12 #include <linux/irqchip.h>
13 #include <linux/of_address.h>
14 #include <linux/of_fdt.h>
15 #include <linux/of_irq.h>
16 #include <linux/of_platform.h>
17 #include <linux/platform_device.h>
18 #include <linux/ata_platform.h>
19 #include <linux/smsc911x.h>
20 #include <linux/spinlock.h>
21 #include <linux/usb/isp1760.h>
22 #include <linux/mtd/physmap.h>
23 #include <linux/regulator/fixed.h>
24 #include <linux/regulator/machine.h>
25 #include <linux/vexpress.h>
27 #include <asm/mach-types.h>
28 #include <asm/sizes.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31 #include <asm/mach/time.h>
32 #include <asm/hardware/arm_timer.h>
33 #include <asm/hardware/cache-l2x0.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 sp804_clocksource_init(base
+ TIMER_2_BASE
, "v2m-timer1");
65 sp804_clockevents_init(base
+ TIMER_1_BASE
, irq
, "v2m-timer0");
69 static struct resource v2m_pcie_i2c_resource
= {
70 .start
= V2M_SERIAL_BUS_PCI
,
71 .end
= V2M_SERIAL_BUS_PCI
+ SZ_4K
- 1,
72 .flags
= IORESOURCE_MEM
,
75 static struct platform_device v2m_pcie_i2c_device
= {
76 .name
= "versatile-i2c",
79 .resource
= &v2m_pcie_i2c_resource
,
82 static struct resource v2m_ddc_i2c_resource
= {
83 .start
= V2M_SERIAL_BUS_DVI
,
84 .end
= V2M_SERIAL_BUS_DVI
+ SZ_4K
- 1,
85 .flags
= IORESOURCE_MEM
,
88 static struct platform_device v2m_ddc_i2c_device
= {
89 .name
= "versatile-i2c",
92 .resource
= &v2m_ddc_i2c_resource
,
95 static struct resource v2m_eth_resources
[] = {
98 .end
= V2M_LAN9118
+ SZ_64K
- 1,
99 .flags
= IORESOURCE_MEM
,
101 .start
= IRQ_V2M_LAN9118
,
102 .end
= IRQ_V2M_LAN9118
,
103 .flags
= IORESOURCE_IRQ
,
107 static struct smsc911x_platform_config v2m_eth_config
= {
108 .flags
= SMSC911X_USE_32BIT
,
109 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_HIGH
,
110 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
111 .phy_interface
= PHY_INTERFACE_MODE_MII
,
114 static struct platform_device v2m_eth_device
= {
117 .resource
= v2m_eth_resources
,
118 .num_resources
= ARRAY_SIZE(v2m_eth_resources
),
119 .dev
.platform_data
= &v2m_eth_config
,
122 static struct regulator_consumer_supply v2m_eth_supplies
[] = {
123 REGULATOR_SUPPLY("vddvario", "smsc911x"),
124 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
127 static struct resource v2m_usb_resources
[] = {
129 .start
= V2M_ISP1761
,
130 .end
= V2M_ISP1761
+ SZ_128K
- 1,
131 .flags
= IORESOURCE_MEM
,
133 .start
= IRQ_V2M_ISP1761
,
134 .end
= IRQ_V2M_ISP1761
,
135 .flags
= IORESOURCE_IRQ
,
139 static struct isp1760_platform_data v2m_usb_config
= {
141 .bus_width_16
= false,
144 .dack_polarity_high
= false,
145 .dreq_polarity_high
= false,
148 static struct platform_device v2m_usb_device
= {
151 .resource
= v2m_usb_resources
,
152 .num_resources
= ARRAY_SIZE(v2m_usb_resources
),
153 .dev
.platform_data
= &v2m_usb_config
,
156 static struct physmap_flash_data v2m_flash_data
= {
160 static struct resource v2m_flash_resources
[] = {
163 .end
= V2M_NOR0
+ SZ_64M
- 1,
164 .flags
= IORESOURCE_MEM
,
167 .end
= V2M_NOR1
+ SZ_64M
- 1,
168 .flags
= IORESOURCE_MEM
,
172 static struct platform_device v2m_flash_device
= {
173 .name
= "physmap-flash",
175 .resource
= v2m_flash_resources
,
176 .num_resources
= ARRAY_SIZE(v2m_flash_resources
),
177 .dev
.platform_data
= &v2m_flash_data
,
180 static struct pata_platform_info v2m_pata_data
= {
184 static struct resource v2m_pata_resources
[] = {
187 .end
= V2M_CF
+ 0xff,
188 .flags
= IORESOURCE_MEM
,
190 .start
= V2M_CF
+ 0x100,
191 .end
= V2M_CF
+ SZ_4K
- 1,
192 .flags
= IORESOURCE_MEM
,
196 static struct platform_device v2m_cf_device
= {
197 .name
= "pata_platform",
199 .resource
= v2m_pata_resources
,
200 .num_resources
= ARRAY_SIZE(v2m_pata_resources
),
201 .dev
.platform_data
= &v2m_pata_data
,
204 static struct mmci_platform_data v2m_mmci_data
= {
205 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
206 .gpio_wp
= VEXPRESS_GPIO_MMC_WPROT
,
207 .gpio_cd
= VEXPRESS_GPIO_MMC_CARDIN
,
210 static struct resource v2m_sysreg_resources
[] = {
212 .start
= V2M_SYSREGS
,
213 .end
= V2M_SYSREGS
+ 0xfff,
214 .flags
= IORESOURCE_MEM
,
218 static struct platform_device v2m_sysreg_device
= {
219 .name
= "vexpress-sysreg",
221 .resource
= v2m_sysreg_resources
,
222 .num_resources
= ARRAY_SIZE(v2m_sysreg_resources
),
225 static struct platform_device v2m_muxfpga_device
= {
226 .name
= "vexpress-muxfpga",
229 .resource
= (struct resource
[]) {
230 VEXPRESS_RES_FUNC(0, 7),
234 static struct platform_device v2m_shutdown_device
= {
235 .name
= "vexpress-shutdown",
238 .resource
= (struct resource
[]) {
239 VEXPRESS_RES_FUNC(0, 8),
243 static struct platform_device v2m_reboot_device
= {
244 .name
= "vexpress-reboot",
247 .resource
= (struct resource
[]) {
248 VEXPRESS_RES_FUNC(0, 9),
252 static struct platform_device v2m_dvimode_device
= {
253 .name
= "vexpress-dvimode",
256 .resource
= (struct resource
[]) {
257 VEXPRESS_RES_FUNC(0, 11),
261 static AMBA_APB_DEVICE(aaci
, "mb:aaci", 0, V2M_AACI
, IRQ_V2M_AACI
, NULL
);
262 static AMBA_APB_DEVICE(mmci
, "mb:mmci", 0, V2M_MMCI
, IRQ_V2M_MMCI
, &v2m_mmci_data
);
263 static AMBA_APB_DEVICE(kmi0
, "mb:kmi0", 0, V2M_KMI0
, IRQ_V2M_KMI0
, NULL
);
264 static AMBA_APB_DEVICE(kmi1
, "mb:kmi1", 0, V2M_KMI1
, IRQ_V2M_KMI1
, NULL
);
265 static AMBA_APB_DEVICE(uart0
, "mb:uart0", 0, V2M_UART0
, IRQ_V2M_UART0
, NULL
);
266 static AMBA_APB_DEVICE(uart1
, "mb:uart1", 0, V2M_UART1
, IRQ_V2M_UART1
, NULL
);
267 static AMBA_APB_DEVICE(uart2
, "mb:uart2", 0, V2M_UART2
, IRQ_V2M_UART2
, NULL
);
268 static AMBA_APB_DEVICE(uart3
, "mb:uart3", 0, V2M_UART3
, IRQ_V2M_UART3
, NULL
);
269 static AMBA_APB_DEVICE(wdt
, "mb:wdt", 0, V2M_WDT
, IRQ_V2M_WDT
, NULL
);
270 static AMBA_APB_DEVICE(rtc
, "mb:rtc", 0, V2M_RTC
, IRQ_V2M_RTC
, NULL
);
272 static struct amba_device
*v2m_amba_devs
[] __initdata
= {
285 static void __init
v2m_timer_init(void)
287 vexpress_clk_init(ioremap(V2M_SYSCTL
, SZ_4K
));
288 v2m_sp804_init(ioremap(V2M_TIMER01
, SZ_4K
), IRQ_V2M_TIMER0
);
291 static void __init
v2m_init_early(void)
293 if (ct_desc
->init_early
)
294 ct_desc
->init_early();
295 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
298 struct ct_desc
*ct_desc
;
300 static struct ct_desc
*ct_descs
[] __initdata
= {
301 #ifdef CONFIG_ARCH_VEXPRESS_CA9X4
306 static void __init
v2m_populate_ct_desc(void)
312 current_tile_id
= vexpress_get_procid(VEXPRESS_SITE_MASTER
)
315 for (i
= 0; i
< ARRAY_SIZE(ct_descs
) && !ct_desc
; ++i
)
316 if (ct_descs
[i
]->id
== current_tile_id
)
317 ct_desc
= ct_descs
[i
];
320 panic("vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.\n"
321 "You may need a device tree blob or a different kernel to boot on this board.\n",
325 static void __init
v2m_map_io(void)
327 iotable_init(v2m_io_desc
, ARRAY_SIZE(v2m_io_desc
));
328 vexpress_sysreg_early_init(ioremap(V2M_SYSREGS
, SZ_4K
));
329 v2m_populate_ct_desc();
333 static void __init
v2m_init_irq(void)
338 static void __init
v2m_init(void)
342 regulator_register_fixed(0, v2m_eth_supplies
,
343 ARRAY_SIZE(v2m_eth_supplies
));
345 platform_device_register(&v2m_muxfpga_device
);
346 platform_device_register(&v2m_shutdown_device
);
347 platform_device_register(&v2m_reboot_device
);
348 platform_device_register(&v2m_dvimode_device
);
350 platform_device_register(&v2m_sysreg_device
);
351 platform_device_register(&v2m_pcie_i2c_device
);
352 platform_device_register(&v2m_ddc_i2c_device
);
353 platform_device_register(&v2m_flash_device
);
354 platform_device_register(&v2m_cf_device
);
355 platform_device_register(&v2m_eth_device
);
356 platform_device_register(&v2m_usb_device
);
358 for (i
= 0; i
< ARRAY_SIZE(v2m_amba_devs
); i
++)
359 amba_device_register(v2m_amba_devs
[i
], &iomem_resource
);
361 pm_power_off
= vexpress_power_off
;
363 ct_desc
->init_tile();
366 MACHINE_START(VEXPRESS
, "ARM-Versatile Express")
367 .atag_offset
= 0x100,
368 .smp
= smp_ops(vexpress_smp_ops
),
369 .map_io
= v2m_map_io
,
370 .init_early
= v2m_init_early
,
371 .init_irq
= v2m_init_irq
,
372 .init_time
= v2m_timer_init
,
373 .init_machine
= v2m_init
,
374 .restart
= vexpress_restart
,
377 static struct map_desc v2m_rs1_io_desc __initdata
= {
378 .virtual = V2M_PERIPH
,
379 .pfn
= __phys_to_pfn(0x1c000000),
384 static int __init
v2m_dt_scan_memory_map(unsigned long node
, const char *uname
,
385 int depth
, void *data
)
387 const char **map
= data
;
389 if (strcmp(uname
, "motherboard") != 0)
392 *map
= of_get_flat_dt_prop(node
, "arm,v2m-memory-map", NULL
);
397 void __init
v2m_dt_map_io(void)
399 const char *map
= NULL
;
401 of_scan_flat_dt(v2m_dt_scan_memory_map
, &map
);
403 if (map
&& strcmp(map
, "rs1") == 0)
404 iotable_init(&v2m_rs1_io_desc
, 1);
406 iotable_init(v2m_io_desc
, ARRAY_SIZE(v2m_io_desc
));
408 #if defined(CONFIG_SMP)
409 vexpress_dt_smp_map_io();
413 void __init
v2m_dt_init_early(void)
417 vexpress_sysreg_of_early_init();
419 /* Confirm board type against DT property, if available */
420 if (of_property_read_u32(of_allnodes
, "arm,hbi", &dt_hbi
) == 0) {
421 u32 hbi
= vexpress_get_hbi(VEXPRESS_SITE_MASTER
);
423 if (WARN_ON(dt_hbi
!= hbi
))
424 pr_warning("vexpress: DT HBI (%x) is not matching "
425 "hardware (%x)!\n", dt_hbi
, hbi
);
429 static void __init
v2m_dt_timer_init(void)
431 vexpress_clk_of_init();
433 clocksource_of_init();
435 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
439 static const struct of_device_id v2m_dt_bus_match
[] __initconst
= {
440 { .compatible
= "simple-bus", },
441 { .compatible
= "arm,amba-bus", },
442 { .compatible
= "arm,vexpress,config-bus", },
446 static void __init
v2m_dt_init(void)
448 l2x0_of_init(0x00400000, 0xfe0fffff);
449 of_platform_populate(NULL
, v2m_dt_bus_match
, NULL
, NULL
);
450 pm_power_off
= vexpress_power_off
;
453 static const char * const v2m_dt_match
[] __initconst
= {
459 DT_MACHINE_START(VEXPRESS_DT
, "ARM-Versatile Express")
460 .dt_compat
= v2m_dt_match
,
461 .smp
= smp_ops(vexpress_smp_ops
),
462 .map_io
= v2m_dt_map_io
,
463 .init_early
= v2m_dt_init_early
,
464 .init_irq
= irqchip_init
,
465 .init_time
= v2m_dt_timer_init
,
466 .init_machine
= v2m_dt_init
,
467 .restart
= vexpress_restart
,