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>
23 #include <linux/clkdev.h>
25 #include <asm/mach-types.h>
26 #include <asm/sizes.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/time.h>
30 #include <asm/hardware/arm_timer.h>
31 #include <asm/hardware/cache-l2x0.h>
32 #include <asm/hardware/timer-sp.h>
34 #include <mach/ct-ca9x4.h>
35 #include <mach/motherboard.h>
37 #include <plat/sched_clock.h>
38 #include <plat/platsmp.h>
42 #define V2M_PA_CS0 0x40000000
43 #define V2M_PA_CS1 0x44000000
44 #define V2M_PA_CS2 0x48000000
45 #define V2M_PA_CS3 0x4c000000
46 #define V2M_PA_CS7 0x10000000
48 static struct map_desc v2m_io_desc
[] __initdata
= {
50 .virtual = V2M_PERIPH
,
51 .pfn
= __phys_to_pfn(V2M_PA_CS7
),
57 static void __init
v2m_sp804_init(void __iomem
*base
, unsigned int irq
)
59 if (WARN_ON(!base
|| irq
== NO_IRQ
))
62 sp804_clocksource_init(base
+ TIMER_2_BASE
, "v2m-timer1");
63 sp804_clockevents_init(base
+ TIMER_1_BASE
, irq
, "v2m-timer0");
67 static struct resource v2m_pcie_i2c_resource
= {
68 .start
= V2M_SERIAL_BUS_PCI
,
69 .end
= V2M_SERIAL_BUS_PCI
+ SZ_4K
- 1,
70 .flags
= IORESOURCE_MEM
,
73 static struct platform_device v2m_pcie_i2c_device
= {
74 .name
= "versatile-i2c",
77 .resource
= &v2m_pcie_i2c_resource
,
80 static struct resource v2m_ddc_i2c_resource
= {
81 .start
= V2M_SERIAL_BUS_DVI
,
82 .end
= V2M_SERIAL_BUS_DVI
+ SZ_4K
- 1,
83 .flags
= IORESOURCE_MEM
,
86 static struct platform_device v2m_ddc_i2c_device
= {
87 .name
= "versatile-i2c",
90 .resource
= &v2m_ddc_i2c_resource
,
93 static struct resource v2m_eth_resources
[] = {
96 .end
= V2M_LAN9118
+ SZ_64K
- 1,
97 .flags
= IORESOURCE_MEM
,
99 .start
= IRQ_V2M_LAN9118
,
100 .end
= IRQ_V2M_LAN9118
,
101 .flags
= IORESOURCE_IRQ
,
105 static struct smsc911x_platform_config v2m_eth_config
= {
106 .flags
= SMSC911X_USE_32BIT
,
107 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_HIGH
,
108 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
109 .phy_interface
= PHY_INTERFACE_MODE_MII
,
112 static struct platform_device v2m_eth_device
= {
115 .resource
= v2m_eth_resources
,
116 .num_resources
= ARRAY_SIZE(v2m_eth_resources
),
117 .dev
.platform_data
= &v2m_eth_config
,
120 static struct regulator_consumer_supply v2m_eth_supplies
[] = {
121 REGULATOR_SUPPLY("vddvario", "smsc911x"),
122 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
125 static struct resource v2m_usb_resources
[] = {
127 .start
= V2M_ISP1761
,
128 .end
= V2M_ISP1761
+ SZ_128K
- 1,
129 .flags
= IORESOURCE_MEM
,
131 .start
= IRQ_V2M_ISP1761
,
132 .end
= IRQ_V2M_ISP1761
,
133 .flags
= IORESOURCE_IRQ
,
137 static struct isp1760_platform_data v2m_usb_config
= {
139 .bus_width_16
= false,
142 .dack_polarity_high
= false,
143 .dreq_polarity_high
= false,
146 static struct platform_device v2m_usb_device
= {
149 .resource
= v2m_usb_resources
,
150 .num_resources
= ARRAY_SIZE(v2m_usb_resources
),
151 .dev
.platform_data
= &v2m_usb_config
,
154 static struct physmap_flash_data v2m_flash_data
= {
158 static struct resource v2m_flash_resources
[] = {
161 .end
= V2M_NOR0
+ SZ_64M
- 1,
162 .flags
= IORESOURCE_MEM
,
165 .end
= V2M_NOR1
+ SZ_64M
- 1,
166 .flags
= IORESOURCE_MEM
,
170 static struct platform_device v2m_flash_device
= {
171 .name
= "physmap-flash",
173 .resource
= v2m_flash_resources
,
174 .num_resources
= ARRAY_SIZE(v2m_flash_resources
),
175 .dev
.platform_data
= &v2m_flash_data
,
178 static struct pata_platform_info v2m_pata_data
= {
182 static struct resource v2m_pata_resources
[] = {
185 .end
= V2M_CF
+ 0xff,
186 .flags
= IORESOURCE_MEM
,
188 .start
= V2M_CF
+ 0x100,
189 .end
= V2M_CF
+ SZ_4K
- 1,
190 .flags
= IORESOURCE_MEM
,
194 static struct platform_device v2m_cf_device
= {
195 .name
= "pata_platform",
197 .resource
= v2m_pata_resources
,
198 .num_resources
= ARRAY_SIZE(v2m_pata_resources
),
199 .dev
.platform_data
= &v2m_pata_data
,
202 static struct mmci_platform_data v2m_mmci_data
= {
203 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
204 .gpio_wp
= VEXPRESS_GPIO_MMC_WPROT
,
205 .gpio_cd
= VEXPRESS_GPIO_MMC_CARDIN
,
208 static struct resource v2m_sysreg_resources
[] = {
210 .start
= V2M_SYSREGS
,
211 .end
= V2M_SYSREGS
+ 0xfff,
212 .flags
= IORESOURCE_MEM
,
216 static struct platform_device v2m_sysreg_device
= {
217 .name
= "vexpress-sysreg",
219 .resource
= v2m_sysreg_resources
,
220 .num_resources
= ARRAY_SIZE(v2m_sysreg_resources
),
223 static struct platform_device v2m_muxfpga_device
= {
224 .name
= "vexpress-muxfpga",
227 .resource
= (struct resource
[]) {
228 VEXPRESS_RES_FUNC(0, 7),
232 static struct platform_device v2m_shutdown_device
= {
233 .name
= "vexpress-shutdown",
236 .resource
= (struct resource
[]) {
237 VEXPRESS_RES_FUNC(0, 8),
241 static struct platform_device v2m_reboot_device
= {
242 .name
= "vexpress-reboot",
245 .resource
= (struct resource
[]) {
246 VEXPRESS_RES_FUNC(0, 9),
250 static struct platform_device v2m_dvimode_device
= {
251 .name
= "vexpress-dvimode",
254 .resource
= (struct resource
[]) {
255 VEXPRESS_RES_FUNC(0, 11),
259 static AMBA_APB_DEVICE(aaci
, "mb:aaci", 0, V2M_AACI
, IRQ_V2M_AACI
, NULL
);
260 static AMBA_APB_DEVICE(mmci
, "mb:mmci", 0, V2M_MMCI
, IRQ_V2M_MMCI
, &v2m_mmci_data
);
261 static AMBA_APB_DEVICE(kmi0
, "mb:kmi0", 0, V2M_KMI0
, IRQ_V2M_KMI0
, NULL
);
262 static AMBA_APB_DEVICE(kmi1
, "mb:kmi1", 0, V2M_KMI1
, IRQ_V2M_KMI1
, NULL
);
263 static AMBA_APB_DEVICE(uart0
, "mb:uart0", 0, V2M_UART0
, IRQ_V2M_UART0
, NULL
);
264 static AMBA_APB_DEVICE(uart1
, "mb:uart1", 0, V2M_UART1
, IRQ_V2M_UART1
, NULL
);
265 static AMBA_APB_DEVICE(uart2
, "mb:uart2", 0, V2M_UART2
, IRQ_V2M_UART2
, NULL
);
266 static AMBA_APB_DEVICE(uart3
, "mb:uart3", 0, V2M_UART3
, IRQ_V2M_UART3
, NULL
);
267 static AMBA_APB_DEVICE(wdt
, "mb:wdt", 0, V2M_WDT
, IRQ_V2M_WDT
, NULL
);
268 static AMBA_APB_DEVICE(rtc
, "mb:rtc", 0, V2M_RTC
, IRQ_V2M_RTC
, NULL
);
270 static struct amba_device
*v2m_amba_devs
[] __initdata
= {
283 static void __init
v2m_timer_init(void)
285 vexpress_clk_init(ioremap(V2M_SYSCTL
, SZ_4K
));
286 v2m_sp804_init(ioremap(V2M_TIMER01
, SZ_4K
), IRQ_V2M_TIMER0
);
289 static void __init
v2m_init_early(void)
291 if (ct_desc
->init_early
)
292 ct_desc
->init_early();
293 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
296 struct ct_desc
*ct_desc
;
298 static struct ct_desc
*ct_descs
[] __initdata
= {
299 #ifdef CONFIG_ARCH_VEXPRESS_CA9X4
304 static void __init
v2m_populate_ct_desc(void)
310 current_tile_id
= vexpress_get_procid(VEXPRESS_SITE_MASTER
)
313 for (i
= 0; i
< ARRAY_SIZE(ct_descs
) && !ct_desc
; ++i
)
314 if (ct_descs
[i
]->id
== current_tile_id
)
315 ct_desc
= ct_descs
[i
];
318 panic("vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.\n"
319 "You may need a device tree blob or a different kernel to boot on this board.\n",
323 static void __init
v2m_map_io(void)
325 iotable_init(v2m_io_desc
, ARRAY_SIZE(v2m_io_desc
));
326 vexpress_sysreg_early_init(ioremap(V2M_SYSREGS
, SZ_4K
));
327 v2m_populate_ct_desc();
331 static void __init
v2m_init_irq(void)
336 static void __init
v2m_init(void)
340 regulator_register_fixed(0, v2m_eth_supplies
,
341 ARRAY_SIZE(v2m_eth_supplies
));
343 platform_device_register(&v2m_muxfpga_device
);
344 platform_device_register(&v2m_shutdown_device
);
345 platform_device_register(&v2m_reboot_device
);
346 platform_device_register(&v2m_dvimode_device
);
348 platform_device_register(&v2m_sysreg_device
);
349 platform_device_register(&v2m_pcie_i2c_device
);
350 platform_device_register(&v2m_ddc_i2c_device
);
351 platform_device_register(&v2m_flash_device
);
352 platform_device_register(&v2m_cf_device
);
353 platform_device_register(&v2m_eth_device
);
354 platform_device_register(&v2m_usb_device
);
356 for (i
= 0; i
< ARRAY_SIZE(v2m_amba_devs
); i
++)
357 amba_device_register(v2m_amba_devs
[i
], &iomem_resource
);
359 ct_desc
->init_tile();
362 MACHINE_START(VEXPRESS
, "ARM-Versatile Express")
363 .atag_offset
= 0x100,
364 .smp
= smp_ops(vexpress_smp_ops
),
365 .map_io
= v2m_map_io
,
366 .init_early
= v2m_init_early
,
367 .init_irq
= v2m_init_irq
,
368 .init_time
= v2m_timer_init
,
369 .init_machine
= v2m_init
,
372 static struct map_desc v2m_rs1_io_desc __initdata
= {
373 .virtual = V2M_PERIPH
,
374 .pfn
= __phys_to_pfn(0x1c000000),
379 static int __init
v2m_dt_scan_memory_map(unsigned long node
, const char *uname
,
380 int depth
, void *data
)
382 const char **map
= data
;
384 if (strcmp(uname
, "motherboard") != 0)
387 *map
= of_get_flat_dt_prop(node
, "arm,v2m-memory-map", NULL
);
392 void __init
v2m_dt_map_io(void)
394 const char *map
= NULL
;
396 of_scan_flat_dt(v2m_dt_scan_memory_map
, &map
);
398 if (map
&& strcmp(map
, "rs1") == 0)
399 iotable_init(&v2m_rs1_io_desc
, 1);
401 iotable_init(v2m_io_desc
, ARRAY_SIZE(v2m_io_desc
));
403 #if defined(CONFIG_SMP)
404 vexpress_dt_smp_map_io();
408 void __init
v2m_dt_init_early(void)
412 vexpress_sysreg_of_early_init();
414 /* Confirm board type against DT property, if available */
415 if (of_property_read_u32(of_allnodes
, "arm,hbi", &dt_hbi
) == 0) {
416 u32 hbi
= vexpress_get_hbi(VEXPRESS_SITE_MASTER
);
418 if (WARN_ON(dt_hbi
!= hbi
))
419 pr_warning("vexpress: DT HBI (%x) is not matching "
420 "hardware (%x)!\n", dt_hbi
, hbi
);
423 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
426 static const struct of_device_id v2m_dt_bus_match
[] __initconst
= {
427 { .compatible
= "simple-bus", },
428 { .compatible
= "arm,amba-bus", },
429 { .compatible
= "arm,vexpress,config-bus", },
433 static void __init
v2m_dt_init(void)
435 l2x0_of_init(0x00400000, 0xfe0fffff);
436 of_platform_populate(NULL
, v2m_dt_bus_match
, NULL
, NULL
);
439 static const char * const v2m_dt_match
[] __initconst
= {
444 DT_MACHINE_START(VEXPRESS_DT
, "ARM-Versatile Express")
445 .dt_compat
= v2m_dt_match
,
446 .smp
= smp_ops(vexpress_smp_ops
),
447 .smp_init
= smp_init_ops(vexpress_smp_init_ops
),
448 .map_io
= v2m_dt_map_io
,
449 .init_early
= v2m_dt_init_early
,
450 .init_machine
= v2m_dt_init
,