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/irqchip.h>
11 #include <linux/of_address.h>
12 #include <linux/of_fdt.h>
13 #include <linux/of_irq.h>
14 #include <linux/of_platform.h>
15 #include <linux/platform_device.h>
16 #include <linux/ata_platform.h>
17 #include <linux/smsc911x.h>
18 #include <linux/spinlock.h>
19 #include <linux/usb/isp1760.h>
20 #include <linux/mtd/physmap.h>
21 #include <linux/regulator/fixed.h>
22 #include <linux/regulator/machine.h>
23 #include <linux/vexpress.h>
24 #include <linux/clk-provider.h>
25 #include <linux/clkdev.h>
27 #include <asm/arch_timer.h>
28 #include <asm/mach-types.h>
29 #include <asm/sizes.h>
30 #include <asm/smp_twd.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/time.h>
34 #include <asm/hardware/arm_timer.h>
35 #include <asm/hardware/cache-l2x0.h>
36 #include <asm/hardware/timer-sp.h>
38 #include <mach/ct-ca9x4.h>
39 #include <mach/motherboard.h>
41 #include <plat/sched_clock.h>
42 #include <plat/platsmp.h>
46 #define V2M_PA_CS0 0x40000000
47 #define V2M_PA_CS1 0x44000000
48 #define V2M_PA_CS2 0x48000000
49 #define V2M_PA_CS3 0x4c000000
50 #define V2M_PA_CS7 0x10000000
52 static struct map_desc v2m_io_desc
[] __initdata
= {
54 .virtual = V2M_PERIPH
,
55 .pfn
= __phys_to_pfn(V2M_PA_CS7
),
61 static void __init
v2m_sp804_init(void __iomem
*base
, unsigned int irq
)
63 if (WARN_ON(!base
|| irq
== NO_IRQ
))
66 writel(0, base
+ TIMER_1_BASE
+ TIMER_CTRL
);
67 writel(0, base
+ TIMER_2_BASE
+ TIMER_CTRL
);
69 sp804_clocksource_init(base
+ TIMER_2_BASE
, "v2m-timer1");
70 sp804_clockevents_init(base
+ TIMER_1_BASE
, irq
, "v2m-timer0");
74 static struct resource v2m_pcie_i2c_resource
= {
75 .start
= V2M_SERIAL_BUS_PCI
,
76 .end
= V2M_SERIAL_BUS_PCI
+ SZ_4K
- 1,
77 .flags
= IORESOURCE_MEM
,
80 static struct platform_device v2m_pcie_i2c_device
= {
81 .name
= "versatile-i2c",
84 .resource
= &v2m_pcie_i2c_resource
,
87 static struct resource v2m_ddc_i2c_resource
= {
88 .start
= V2M_SERIAL_BUS_DVI
,
89 .end
= V2M_SERIAL_BUS_DVI
+ SZ_4K
- 1,
90 .flags
= IORESOURCE_MEM
,
93 static struct platform_device v2m_ddc_i2c_device
= {
94 .name
= "versatile-i2c",
97 .resource
= &v2m_ddc_i2c_resource
,
100 static struct resource v2m_eth_resources
[] = {
102 .start
= V2M_LAN9118
,
103 .end
= V2M_LAN9118
+ SZ_64K
- 1,
104 .flags
= IORESOURCE_MEM
,
106 .start
= IRQ_V2M_LAN9118
,
107 .end
= IRQ_V2M_LAN9118
,
108 .flags
= IORESOURCE_IRQ
,
112 static struct smsc911x_platform_config v2m_eth_config
= {
113 .flags
= SMSC911X_USE_32BIT
,
114 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_HIGH
,
115 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
116 .phy_interface
= PHY_INTERFACE_MODE_MII
,
119 static struct platform_device v2m_eth_device
= {
122 .resource
= v2m_eth_resources
,
123 .num_resources
= ARRAY_SIZE(v2m_eth_resources
),
124 .dev
.platform_data
= &v2m_eth_config
,
127 static struct regulator_consumer_supply v2m_eth_supplies
[] = {
128 REGULATOR_SUPPLY("vddvario", "smsc911x"),
129 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
132 static struct resource v2m_usb_resources
[] = {
134 .start
= V2M_ISP1761
,
135 .end
= V2M_ISP1761
+ SZ_128K
- 1,
136 .flags
= IORESOURCE_MEM
,
138 .start
= IRQ_V2M_ISP1761
,
139 .end
= IRQ_V2M_ISP1761
,
140 .flags
= IORESOURCE_IRQ
,
144 static struct isp1760_platform_data v2m_usb_config
= {
146 .bus_width_16
= false,
149 .dack_polarity_high
= false,
150 .dreq_polarity_high
= false,
153 static struct platform_device v2m_usb_device
= {
156 .resource
= v2m_usb_resources
,
157 .num_resources
= ARRAY_SIZE(v2m_usb_resources
),
158 .dev
.platform_data
= &v2m_usb_config
,
161 static struct physmap_flash_data v2m_flash_data
= {
165 static struct resource v2m_flash_resources
[] = {
168 .end
= V2M_NOR0
+ SZ_64M
- 1,
169 .flags
= IORESOURCE_MEM
,
172 .end
= V2M_NOR1
+ SZ_64M
- 1,
173 .flags
= IORESOURCE_MEM
,
177 static struct platform_device v2m_flash_device
= {
178 .name
= "physmap-flash",
180 .resource
= v2m_flash_resources
,
181 .num_resources
= ARRAY_SIZE(v2m_flash_resources
),
182 .dev
.platform_data
= &v2m_flash_data
,
185 static struct pata_platform_info v2m_pata_data
= {
189 static struct resource v2m_pata_resources
[] = {
192 .end
= V2M_CF
+ 0xff,
193 .flags
= IORESOURCE_MEM
,
195 .start
= V2M_CF
+ 0x100,
196 .end
= V2M_CF
+ SZ_4K
- 1,
197 .flags
= IORESOURCE_MEM
,
201 static struct platform_device v2m_cf_device
= {
202 .name
= "pata_platform",
204 .resource
= v2m_pata_resources
,
205 .num_resources
= ARRAY_SIZE(v2m_pata_resources
),
206 .dev
.platform_data
= &v2m_pata_data
,
209 static struct mmci_platform_data v2m_mmci_data
= {
210 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
211 .gpio_wp
= VEXPRESS_GPIO_MMC_WPROT
,
212 .gpio_cd
= VEXPRESS_GPIO_MMC_CARDIN
,
215 static struct resource v2m_sysreg_resources
[] = {
217 .start
= V2M_SYSREGS
,
218 .end
= V2M_SYSREGS
+ 0xfff,
219 .flags
= IORESOURCE_MEM
,
223 static struct platform_device v2m_sysreg_device
= {
224 .name
= "vexpress-sysreg",
226 .resource
= v2m_sysreg_resources
,
227 .num_resources
= ARRAY_SIZE(v2m_sysreg_resources
),
230 static struct platform_device v2m_muxfpga_device
= {
231 .name
= "vexpress-muxfpga",
234 .resource
= (struct resource
[]) {
235 VEXPRESS_RES_FUNC(0, 7),
239 static struct platform_device v2m_shutdown_device
= {
240 .name
= "vexpress-shutdown",
243 .resource
= (struct resource
[]) {
244 VEXPRESS_RES_FUNC(0, 8),
248 static struct platform_device v2m_reboot_device
= {
249 .name
= "vexpress-reboot",
252 .resource
= (struct resource
[]) {
253 VEXPRESS_RES_FUNC(0, 9),
257 static struct platform_device v2m_dvimode_device
= {
258 .name
= "vexpress-dvimode",
261 .resource
= (struct resource
[]) {
262 VEXPRESS_RES_FUNC(0, 11),
266 static AMBA_APB_DEVICE(aaci
, "mb:aaci", 0, V2M_AACI
, IRQ_V2M_AACI
, NULL
);
267 static AMBA_APB_DEVICE(mmci
, "mb:mmci", 0, V2M_MMCI
, IRQ_V2M_MMCI
, &v2m_mmci_data
);
268 static AMBA_APB_DEVICE(kmi0
, "mb:kmi0", 0, V2M_KMI0
, IRQ_V2M_KMI0
, NULL
);
269 static AMBA_APB_DEVICE(kmi1
, "mb:kmi1", 0, V2M_KMI1
, IRQ_V2M_KMI1
, NULL
);
270 static AMBA_APB_DEVICE(uart0
, "mb:uart0", 0, V2M_UART0
, IRQ_V2M_UART0
, NULL
);
271 static AMBA_APB_DEVICE(uart1
, "mb:uart1", 0, V2M_UART1
, IRQ_V2M_UART1
, NULL
);
272 static AMBA_APB_DEVICE(uart2
, "mb:uart2", 0, V2M_UART2
, IRQ_V2M_UART2
, NULL
);
273 static AMBA_APB_DEVICE(uart3
, "mb:uart3", 0, V2M_UART3
, IRQ_V2M_UART3
, NULL
);
274 static AMBA_APB_DEVICE(wdt
, "mb:wdt", 0, V2M_WDT
, IRQ_V2M_WDT
, NULL
);
275 static AMBA_APB_DEVICE(rtc
, "mb:rtc", 0, V2M_RTC
, IRQ_V2M_RTC
, NULL
);
277 static struct amba_device
*v2m_amba_devs
[] __initdata
= {
290 static void __init
v2m_timer_init(void)
292 vexpress_clk_init(ioremap(V2M_SYSCTL
, SZ_4K
));
293 v2m_sp804_init(ioremap(V2M_TIMER01
, SZ_4K
), IRQ_V2M_TIMER0
);
296 static void __init
v2m_init_early(void)
298 if (ct_desc
->init_early
)
299 ct_desc
->init_early();
300 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
303 struct ct_desc
*ct_desc
;
305 static struct ct_desc
*ct_descs
[] __initdata
= {
306 #ifdef CONFIG_ARCH_VEXPRESS_CA9X4
311 static void __init
v2m_populate_ct_desc(void)
317 current_tile_id
= vexpress_get_procid(VEXPRESS_SITE_MASTER
)
320 for (i
= 0; i
< ARRAY_SIZE(ct_descs
) && !ct_desc
; ++i
)
321 if (ct_descs
[i
]->id
== current_tile_id
)
322 ct_desc
= ct_descs
[i
];
325 panic("vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.\n"
326 "You may need a device tree blob or a different kernel to boot on this board.\n",
330 static void __init
v2m_map_io(void)
332 iotable_init(v2m_io_desc
, ARRAY_SIZE(v2m_io_desc
));
333 vexpress_sysreg_early_init(ioremap(V2M_SYSREGS
, SZ_4K
));
334 v2m_populate_ct_desc();
338 static void __init
v2m_init_irq(void)
343 static void __init
v2m_init(void)
347 regulator_register_fixed(0, v2m_eth_supplies
,
348 ARRAY_SIZE(v2m_eth_supplies
));
350 platform_device_register(&v2m_muxfpga_device
);
351 platform_device_register(&v2m_shutdown_device
);
352 platform_device_register(&v2m_reboot_device
);
353 platform_device_register(&v2m_dvimode_device
);
355 platform_device_register(&v2m_sysreg_device
);
356 platform_device_register(&v2m_pcie_i2c_device
);
357 platform_device_register(&v2m_ddc_i2c_device
);
358 platform_device_register(&v2m_flash_device
);
359 platform_device_register(&v2m_cf_device
);
360 platform_device_register(&v2m_eth_device
);
361 platform_device_register(&v2m_usb_device
);
363 for (i
= 0; i
< ARRAY_SIZE(v2m_amba_devs
); i
++)
364 amba_device_register(v2m_amba_devs
[i
], &iomem_resource
);
366 ct_desc
->init_tile();
369 MACHINE_START(VEXPRESS
, "ARM-Versatile Express")
370 .atag_offset
= 0x100,
371 .smp
= smp_ops(vexpress_smp_ops
),
372 .map_io
= v2m_map_io
,
373 .init_early
= v2m_init_early
,
374 .init_irq
= v2m_init_irq
,
375 .init_time
= v2m_timer_init
,
376 .init_machine
= v2m_init
,
379 static struct map_desc v2m_rs1_io_desc __initdata
= {
380 .virtual = V2M_PERIPH
,
381 .pfn
= __phys_to_pfn(0x1c000000),
386 static int __init
v2m_dt_scan_memory_map(unsigned long node
, const char *uname
,
387 int depth
, void *data
)
389 const char **map
= data
;
391 if (strcmp(uname
, "motherboard") != 0)
394 *map
= of_get_flat_dt_prop(node
, "arm,v2m-memory-map", NULL
);
399 void __init
v2m_dt_map_io(void)
401 const char *map
= NULL
;
403 of_scan_flat_dt(v2m_dt_scan_memory_map
, &map
);
405 if (map
&& strcmp(map
, "rs1") == 0)
406 iotable_init(&v2m_rs1_io_desc
, 1);
408 iotable_init(v2m_io_desc
, ARRAY_SIZE(v2m_io_desc
));
410 #if defined(CONFIG_SMP)
411 vexpress_dt_smp_map_io();
415 void __init
v2m_dt_init_early(void)
419 vexpress_sysreg_of_early_init();
421 /* Confirm board type against DT property, if available */
422 if (of_property_read_u32(of_allnodes
, "arm,hbi", &dt_hbi
) == 0) {
423 u32 hbi
= vexpress_get_hbi(VEXPRESS_SITE_MASTER
);
425 if (WARN_ON(dt_hbi
!= hbi
))
426 pr_warning("vexpress: DT HBI (%x) is not matching "
427 "hardware (%x)!\n", dt_hbi
, hbi
);
431 static void __init
v2m_dt_timer_init(void)
433 struct device_node
*node
= NULL
;
438 node
= of_find_compatible_node(node
, NULL
, "arm,sp804");
439 } while (node
&& vexpress_get_site_by_node(node
) != VEXPRESS_SITE_MB
);
441 pr_info("Using SP804 '%s' as a clock & events source\n",
443 WARN_ON(clk_register_clkdev(of_clk_get_by_name(node
,
444 "timclken1"), "v2m-timer0", "sp804"));
445 WARN_ON(clk_register_clkdev(of_clk_get_by_name(node
,
446 "timclken2"), "v2m-timer1", "sp804"));
447 v2m_sp804_init(of_iomap(node
, 0),
448 irq_of_parse_and_map(node
, 0));
451 if (arch_timer_of_register() != 0)
452 twd_local_timer_of_register();
454 if (arch_timer_sched_clock_init() != 0)
455 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
459 static const struct of_device_id v2m_dt_bus_match
[] __initconst
= {
460 { .compatible
= "simple-bus", },
461 { .compatible
= "arm,amba-bus", },
462 { .compatible
= "arm,vexpress,config-bus", },
466 static void __init
v2m_dt_init(void)
468 l2x0_of_init(0x00400000, 0xfe0fffff);
469 of_platform_populate(NULL
, v2m_dt_bus_match
, NULL
, NULL
);
472 static const char * const v2m_dt_match
[] __initconst
= {
478 DT_MACHINE_START(VEXPRESS_DT
, "ARM-Versatile Express")
479 .dt_compat
= v2m_dt_match
,
480 .smp
= smp_ops(vexpress_smp_ops
),
481 .map_io
= v2m_dt_map_io
,
482 .init_early
= v2m_dt_init_early
,
483 .init_irq
= irqchip_init
,
484 .init_time
= v2m_dt_timer_init
,
485 .init_machine
= v2m_dt_init
,