blob: 95a469e23e378078af77ffcd9eecc9b29e5ff264 [file] [log] [blame]
Russell Kingceade892010-02-11 21:44:53 +00001/*
2 * Versatile Express V2M Motherboard Support
3 */
Rob Herring0583fe42013-04-10 18:27:51 -05004#include <linux/clocksource.h>
Russell Kingceade892010-02-11 21:44:53 +00005#include <linux/device.h>
6#include <linux/amba/bus.h>
7#include <linux/amba/mmci.h>
8#include <linux/io.h>
Rob Herringda4a6862013-02-06 21:17:47 -06009#include <linux/clocksource.h>
Marc Zyngier3695adc2011-09-08 13:15:22 +010010#include <linux/smp.h>
Russell Kingceade892010-02-11 21:44:53 +000011#include <linux/init.h>
Pawel Moll8deed172012-02-23 13:04:51 +000012#include <linux/of_address.h>
13#include <linux/of_fdt.h>
14#include <linux/of_irq.h>
15#include <linux/of_platform.h>
Russell Kingceade892010-02-11 21:44:53 +000016#include <linux/platform_device.h>
Nick Bowler95c34f82011-01-21 15:51:06 +010017#include <linux/ata_platform.h>
Russell Kingceade892010-02-11 21:44:53 +000018#include <linux/smsc911x.h>
19#include <linux/spinlock.h>
Russell Kingceade892010-02-11 21:44:53 +000020#include <linux/usb/isp1760.h>
Marc Zyngier0f71fd42011-05-18 10:51:51 +010021#include <linux/mtd/physmap.h>
Pawel Mollb2a54ff2012-07-09 11:33:47 +010022#include <linux/regulator/fixed.h>
23#include <linux/regulator/machine.h>
Pawel Moll38669e02012-10-09 12:56:36 +010024#include <linux/vexpress.h>
Pawel Moll6e973d22013-04-18 18:23:22 +010025#include <linux/clk-provider.h>
26#include <linux/clkdev.h>
Russell Kingceade892010-02-11 21:44:53 +000027
Will Deacon80b5efbd2011-02-28 17:01:04 +010028#include <asm/mach-types.h>
Russell Kingceade892010-02-11 21:44:53 +000029#include <asm/sizes.h>
Will Deacon80b5efbd2011-02-28 17:01:04 +010030#include <asm/mach/arch.h>
Russell Kingceade892010-02-11 21:44:53 +000031#include <asm/mach/map.h>
32#include <asm/mach/time.h>
33#include <asm/hardware/arm_timer.h>
Pawel Moll8deed172012-02-23 13:04:51 +000034#include <asm/hardware/cache-l2x0.h>
Russell King58daf182011-01-05 18:09:03 +000035#include <asm/hardware/timer-sp.h>
Russell Kingceade892010-02-11 21:44:53 +000036
Will Deacon80b5efbd2011-02-28 17:01:04 +010037#include <mach/ct-ca9x4.h>
Russell Kingceade892010-02-11 21:44:53 +000038#include <mach/motherboard.h>
39
Russell King0af85dd2010-12-15 21:58:50 +000040#include <plat/sched_clock.h>
Marc Zyngier3695adc2011-09-08 13:15:22 +010041#include <plat/platsmp.h>
Russell Kingceade892010-02-11 21:44:53 +000042
43#include "core.h"
44
45#define V2M_PA_CS0 0x40000000
46#define V2M_PA_CS1 0x44000000
47#define V2M_PA_CS2 0x48000000
48#define V2M_PA_CS3 0x4c000000
49#define V2M_PA_CS7 0x10000000
50
51static struct map_desc v2m_io_desc[] __initdata = {
52 {
Pawel Moll98ed4ce2012-01-25 15:37:29 +000053 .virtual = V2M_PERIPH,
Russell Kingceade892010-02-11 21:44:53 +000054 .pfn = __phys_to_pfn(V2M_PA_CS7),
55 .length = SZ_128K,
56 .type = MT_DEVICE,
57 },
58};
59
Pawel Moll98ed4ce2012-01-25 15:37:29 +000060static void __init v2m_sp804_init(void __iomem *base, unsigned int irq)
61{
62 if (WARN_ON(!base || irq == NO_IRQ))
63 return;
Russell Kingceade892010-02-11 21:44:53 +000064
Pawel Moll98ed4ce2012-01-25 15:37:29 +000065 sp804_clocksource_init(base + TIMER_2_BASE, "v2m-timer1");
66 sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0");
67}
68
Russell Kingceade892010-02-11 21:44:53 +000069
Russell Kingceade892010-02-11 21:44:53 +000070static struct resource v2m_pcie_i2c_resource = {
71 .start = V2M_SERIAL_BUS_PCI,
72 .end = V2M_SERIAL_BUS_PCI + SZ_4K - 1,
73 .flags = IORESOURCE_MEM,
74};
75
76static struct platform_device v2m_pcie_i2c_device = {
77 .name = "versatile-i2c",
78 .id = 0,
79 .num_resources = 1,
80 .resource = &v2m_pcie_i2c_resource,
81};
82
83static struct resource v2m_ddc_i2c_resource = {
84 .start = V2M_SERIAL_BUS_DVI,
85 .end = V2M_SERIAL_BUS_DVI + SZ_4K - 1,
86 .flags = IORESOURCE_MEM,
87};
88
89static struct platform_device v2m_ddc_i2c_device = {
90 .name = "versatile-i2c",
91 .id = 1,
92 .num_resources = 1,
93 .resource = &v2m_ddc_i2c_resource,
94};
95
96static struct resource v2m_eth_resources[] = {
97 {
98 .start = V2M_LAN9118,
99 .end = V2M_LAN9118 + SZ_64K - 1,
100 .flags = IORESOURCE_MEM,
101 }, {
102 .start = IRQ_V2M_LAN9118,
103 .end = IRQ_V2M_LAN9118,
104 .flags = IORESOURCE_IRQ,
105 },
106};
107
108static struct smsc911x_platform_config v2m_eth_config = {
109 .flags = SMSC911X_USE_32BIT,
110 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
111 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
112 .phy_interface = PHY_INTERFACE_MODE_MII,
113};
114
115static struct platform_device v2m_eth_device = {
116 .name = "smsc911x",
117 .id = -1,
118 .resource = v2m_eth_resources,
119 .num_resources = ARRAY_SIZE(v2m_eth_resources),
120 .dev.platform_data = &v2m_eth_config,
121};
122
Pawel Mollb2a54ff2012-07-09 11:33:47 +0100123static struct regulator_consumer_supply v2m_eth_supplies[] = {
124 REGULATOR_SUPPLY("vddvario", "smsc911x"),
125 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
126};
127
Russell Kingceade892010-02-11 21:44:53 +0000128static struct resource v2m_usb_resources[] = {
129 {
130 .start = V2M_ISP1761,
131 .end = V2M_ISP1761 + SZ_128K - 1,
132 .flags = IORESOURCE_MEM,
133 }, {
134 .start = IRQ_V2M_ISP1761,
135 .end = IRQ_V2M_ISP1761,
136 .flags = IORESOURCE_IRQ,
137 },
138};
139
140static struct isp1760_platform_data v2m_usb_config = {
141 .is_isp1761 = true,
142 .bus_width_16 = false,
143 .port1_otg = true,
144 .analog_oc = false,
145 .dack_polarity_high = false,
146 .dreq_polarity_high = false,
147};
148
149static struct platform_device v2m_usb_device = {
150 .name = "isp1760",
151 .id = -1,
152 .resource = v2m_usb_resources,
153 .num_resources = ARRAY_SIZE(v2m_usb_resources),
154 .dev.platform_data = &v2m_usb_config,
155};
156
Marc Zyngier0f71fd42011-05-18 10:51:51 +0100157static struct physmap_flash_data v2m_flash_data = {
Russell Kingceade892010-02-11 21:44:53 +0000158 .width = 4,
Russell Kingceade892010-02-11 21:44:53 +0000159};
160
161static struct resource v2m_flash_resources[] = {
162 {
163 .start = V2M_NOR0,
164 .end = V2M_NOR0 + SZ_64M - 1,
165 .flags = IORESOURCE_MEM,
166 }, {
167 .start = V2M_NOR1,
168 .end = V2M_NOR1 + SZ_64M - 1,
169 .flags = IORESOURCE_MEM,
170 },
171};
172
173static struct platform_device v2m_flash_device = {
Marc Zyngier0f71fd42011-05-18 10:51:51 +0100174 .name = "physmap-flash",
Russell Kingceade892010-02-11 21:44:53 +0000175 .id = -1,
176 .resource = v2m_flash_resources,
177 .num_resources = ARRAY_SIZE(v2m_flash_resources),
178 .dev.platform_data = &v2m_flash_data,
179};
180
Nick Bowler95c34f82011-01-21 15:51:06 +0100181static struct pata_platform_info v2m_pata_data = {
182 .ioport_shift = 2,
183};
184
185static struct resource v2m_pata_resources[] = {
186 {
187 .start = V2M_CF,
188 .end = V2M_CF + 0xff,
189 .flags = IORESOURCE_MEM,
190 }, {
191 .start = V2M_CF + 0x100,
192 .end = V2M_CF + SZ_4K - 1,
193 .flags = IORESOURCE_MEM,
194 },
195};
196
197static struct platform_device v2m_cf_device = {
198 .name = "pata_platform",
199 .id = -1,
200 .resource = v2m_pata_resources,
201 .num_resources = ARRAY_SIZE(v2m_pata_resources),
202 .dev.platform_data = &v2m_pata_data,
203};
Russell Kingceade892010-02-11 21:44:53 +0000204
Russell Kingceade892010-02-11 21:44:53 +0000205static struct mmci_platform_data v2m_mmci_data = {
206 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Pawel Moll38669e02012-10-09 12:56:36 +0100207 .gpio_wp = VEXPRESS_GPIO_MMC_WPROT,
208 .gpio_cd = VEXPRESS_GPIO_MMC_CARDIN,
209};
210
211static struct resource v2m_sysreg_resources[] = {
212 {
213 .start = V2M_SYSREGS,
214 .end = V2M_SYSREGS + 0xfff,
215 .flags = IORESOURCE_MEM,
216 },
217};
218
219static struct platform_device v2m_sysreg_device = {
220 .name = "vexpress-sysreg",
221 .id = -1,
222 .resource = v2m_sysreg_resources,
223 .num_resources = ARRAY_SIZE(v2m_sysreg_resources),
224};
225
226static struct platform_device v2m_muxfpga_device = {
227 .name = "vexpress-muxfpga",
228 .id = 0,
229 .num_resources = 1,
230 .resource = (struct resource []) {
231 VEXPRESS_RES_FUNC(0, 7),
232 }
233};
234
235static struct platform_device v2m_shutdown_device = {
236 .name = "vexpress-shutdown",
237 .id = 0,
238 .num_resources = 1,
239 .resource = (struct resource []) {
240 VEXPRESS_RES_FUNC(0, 8),
241 }
242};
243
244static struct platform_device v2m_reboot_device = {
245 .name = "vexpress-reboot",
246 .id = 0,
247 .num_resources = 1,
248 .resource = (struct resource []) {
249 VEXPRESS_RES_FUNC(0, 9),
250 }
251};
252
253static struct platform_device v2m_dvimode_device = {
254 .name = "vexpress-dvimode",
255 .id = 0,
256 .num_resources = 1,
257 .resource = (struct resource []) {
258 VEXPRESS_RES_FUNC(0, 11),
259 }
Russell Kingceade892010-02-11 21:44:53 +0000260};
261
Russell Kingcdd4e1a2011-12-18 12:07:09 +0000262static AMBA_APB_DEVICE(aaci, "mb:aaci", 0, V2M_AACI, IRQ_V2M_AACI, NULL);
263static AMBA_APB_DEVICE(mmci, "mb:mmci", 0, V2M_MMCI, IRQ_V2M_MMCI, &v2m_mmci_data);
264static AMBA_APB_DEVICE(kmi0, "mb:kmi0", 0, V2M_KMI0, IRQ_V2M_KMI0, NULL);
265static AMBA_APB_DEVICE(kmi1, "mb:kmi1", 0, V2M_KMI1, IRQ_V2M_KMI1, NULL);
266static AMBA_APB_DEVICE(uart0, "mb:uart0", 0, V2M_UART0, IRQ_V2M_UART0, NULL);
267static AMBA_APB_DEVICE(uart1, "mb:uart1", 0, V2M_UART1, IRQ_V2M_UART1, NULL);
268static AMBA_APB_DEVICE(uart2, "mb:uart2", 0, V2M_UART2, IRQ_V2M_UART2, NULL);
269static AMBA_APB_DEVICE(uart3, "mb:uart3", 0, V2M_UART3, IRQ_V2M_UART3, NULL);
270static AMBA_APB_DEVICE(wdt, "mb:wdt", 0, V2M_WDT, IRQ_V2M_WDT, NULL);
271static AMBA_APB_DEVICE(rtc, "mb:rtc", 0, V2M_RTC, IRQ_V2M_RTC, NULL);
Russell Kingceade892010-02-11 21:44:53 +0000272
273static struct amba_device *v2m_amba_devs[] __initdata = {
274 &aaci_device,
275 &mmci_device,
276 &kmi0_device,
277 &kmi1_device,
278 &uart0_device,
279 &uart1_device,
280 &uart2_device,
281 &uart3_device,
282 &wdt_device,
283 &rtc_device,
284};
285
Pawel Molld1b8a772012-07-13 11:48:16 +0100286static void __init v2m_timer_init(void)
287{
Pawel Moll38669e02012-10-09 12:56:36 +0100288 vexpress_clk_init(ioremap(V2M_SYSCTL, SZ_4K));
Pawel Molld1b8a772012-07-13 11:48:16 +0100289 v2m_sp804_init(ioremap(V2M_TIMER01, SZ_4K), IRQ_V2M_TIMER0);
290}
291
Rob Herring2fdf9992011-05-30 19:44:22 +0100292static void __init v2m_init_early(void)
293{
Pawel Molld1b8a772012-07-13 11:48:16 +0100294 if (ct_desc->init_early)
295 ct_desc->init_early();
Pawel Moll38669e02012-10-09 12:56:36 +0100296 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
Russell Kingceade892010-02-11 21:44:53 +0000297}
298
Will Deacon80b5efbd2011-02-28 17:01:04 +0100299struct ct_desc *ct_desc;
300
301static struct ct_desc *ct_descs[] __initdata = {
302#ifdef CONFIG_ARCH_VEXPRESS_CA9X4
303 &ct_ca9x4_desc,
304#endif
305};
306
307static void __init v2m_populate_ct_desc(void)
308{
309 int i;
310 u32 current_tile_id;
311
312 ct_desc = NULL;
Pawel Moll38669e02012-10-09 12:56:36 +0100313 current_tile_id = vexpress_get_procid(VEXPRESS_SITE_MASTER)
Pawel Moll98ed4ce2012-01-25 15:37:29 +0000314 & V2M_CT_ID_MASK;
Will Deacon80b5efbd2011-02-28 17:01:04 +0100315
316 for (i = 0; i < ARRAY_SIZE(ct_descs) && !ct_desc; ++i)
317 if (ct_descs[i]->id == current_tile_id)
318 ct_desc = ct_descs[i];
319
320 if (!ct_desc)
Pawel Moll8deed172012-02-23 13:04:51 +0000321 panic("vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.\n"
322 "You may need a device tree blob or a different kernel to boot on this board.\n",
323 current_tile_id);
Will Deacon80b5efbd2011-02-28 17:01:04 +0100324}
325
326static void __init v2m_map_io(void)
327{
328 iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
Pawel Moll38669e02012-10-09 12:56:36 +0100329 vexpress_sysreg_early_init(ioremap(V2M_SYSREGS, SZ_4K));
Will Deacon80b5efbd2011-02-28 17:01:04 +0100330 v2m_populate_ct_desc();
331 ct_desc->map_io();
332}
333
334static void __init v2m_init_irq(void)
335{
336 ct_desc->init_irq();
337}
338
339static void __init v2m_init(void)
Russell Kingceade892010-02-11 21:44:53 +0000340{
341 int i;
342
Pawel Mollb2a54ff2012-07-09 11:33:47 +0100343 regulator_register_fixed(0, v2m_eth_supplies,
344 ARRAY_SIZE(v2m_eth_supplies));
345
Pawel Moll38669e02012-10-09 12:56:36 +0100346 platform_device_register(&v2m_muxfpga_device);
347 platform_device_register(&v2m_shutdown_device);
348 platform_device_register(&v2m_reboot_device);
349 platform_device_register(&v2m_dvimode_device);
350
351 platform_device_register(&v2m_sysreg_device);
Russell Kingceade892010-02-11 21:44:53 +0000352 platform_device_register(&v2m_pcie_i2c_device);
353 platform_device_register(&v2m_ddc_i2c_device);
354 platform_device_register(&v2m_flash_device);
Nick Bowler95c34f82011-01-21 15:51:06 +0100355 platform_device_register(&v2m_cf_device);
Russell Kingceade892010-02-11 21:44:53 +0000356 platform_device_register(&v2m_eth_device);
357 platform_device_register(&v2m_usb_device);
358
359 for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
360 amba_device_register(v2m_amba_devs[i], &iomem_resource);
361
Will Deacon80b5efbd2011-02-28 17:01:04 +0100362 ct_desc->init_tile();
Russell Kingceade892010-02-11 21:44:53 +0000363}
Will Deacon80b5efbd2011-02-28 17:01:04 +0100364
365MACHINE_START(VEXPRESS, "ARM-Versatile Express")
Nicolas Pitree9ce8e52011-07-05 22:38:18 -0400366 .atag_offset = 0x100,
Marc Zyngier3695adc2011-09-08 13:15:22 +0100367 .smp = smp_ops(vexpress_smp_ops),
Will Deacon80b5efbd2011-02-28 17:01:04 +0100368 .map_io = v2m_map_io,
369 .init_early = v2m_init_early,
370 .init_irq = v2m_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700371 .init_time = v2m_timer_init,
Will Deacon80b5efbd2011-02-28 17:01:04 +0100372 .init_machine = v2m_init,
373MACHINE_END
Pawel Moll8deed172012-02-23 13:04:51 +0000374
Pawel Moll6a371952011-12-09 18:47:39 +0000375static struct map_desc v2m_rs1_io_desc __initdata = {
376 .virtual = V2M_PERIPH,
377 .pfn = __phys_to_pfn(0x1c000000),
378 .length = SZ_2M,
379 .type = MT_DEVICE,
380};
381
382static int __init v2m_dt_scan_memory_map(unsigned long node, const char *uname,
383 int depth, void *data)
384{
385 const char **map = data;
386
387 if (strcmp(uname, "motherboard") != 0)
388 return 0;
389
390 *map = of_get_flat_dt_prop(node, "arm,v2m-memory-map", NULL);
391
392 return 1;
393}
394
Pawel Moll8deed172012-02-23 13:04:51 +0000395void __init v2m_dt_map_io(void)
396{
Pawel Moll6a371952011-12-09 18:47:39 +0000397 const char *map = NULL;
398
399 of_scan_flat_dt(v2m_dt_scan_memory_map, &map);
400
401 if (map && strcmp(map, "rs1") == 0)
402 iotable_init(&v2m_rs1_io_desc, 1);
403 else
404 iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
Pawel Moll8deed172012-02-23 13:04:51 +0000405
406#if defined(CONFIG_SMP)
407 vexpress_dt_smp_map_io();
408#endif
409}
410
Pawel Moll8deed172012-02-23 13:04:51 +0000411void __init v2m_dt_init_early(void)
412{
Pawel Moll8deed172012-02-23 13:04:51 +0000413 u32 dt_hbi;
414
Pawel Moll38669e02012-10-09 12:56:36 +0100415 vexpress_sysreg_of_early_init();
Pawel Moll8deed172012-02-23 13:04:51 +0000416
417 /* Confirm board type against DT property, if available */
Randy Dunlap465aac62012-11-30 10:01:51 +0000418 if (of_property_read_u32(of_allnodes, "arm,hbi", &dt_hbi) == 0) {
Pawel Moll38669e02012-10-09 12:56:36 +0100419 u32 hbi = vexpress_get_hbi(VEXPRESS_SITE_MASTER);
Pawel Moll8deed172012-02-23 13:04:51 +0000420
421 if (WARN_ON(dt_hbi != hbi))
422 pr_warning("vexpress: DT HBI (%x) is not matching "
423 "hardware (%x)!\n", dt_hbi, hbi);
424 }
Pawel Moll8deed172012-02-23 13:04:51 +0000425}
426
Pawel Moll8deed172012-02-23 13:04:51 +0000427static void __init v2m_dt_timer_init(void)
428{
Pawel Moll6e973d22013-04-18 18:23:22 +0100429 of_clk_init(NULL);
Pawel Moll8deed172012-02-23 13:04:51 +0000430
Rob Herringda4a6862013-02-06 21:17:47 -0600431 clocksource_of_init();
Pawel Molld1b8a772012-07-13 11:48:16 +0100432
Rob Herring0583fe42013-04-10 18:27:51 -0500433 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
Pawel Moll38669e02012-10-09 12:56:36 +0100434 24000000);
Pawel Moll8deed172012-02-23 13:04:51 +0000435}
436
Pawel Moll38669e02012-10-09 12:56:36 +0100437static const struct of_device_id v2m_dt_bus_match[] __initconst = {
438 { .compatible = "simple-bus", },
439 { .compatible = "arm,amba-bus", },
440 { .compatible = "arm,vexpress,config-bus", },
Pawel Moll8deed172012-02-23 13:04:51 +0000441 {}
442};
443
444static void __init v2m_dt_init(void)
445{
446 l2x0_of_init(0x00400000, 0xfe0fffff);
Pawel Moll38669e02012-10-09 12:56:36 +0100447 of_platform_populate(NULL, v2m_dt_bus_match, NULL, NULL);
Pawel Moll8deed172012-02-23 13:04:51 +0000448}
449
Pawel Moll38669e02012-10-09 12:56:36 +0100450static const char * const v2m_dt_match[] __initconst = {
Pawel Moll8deed172012-02-23 13:04:51 +0000451 "arm,vexpress",
452 NULL,
453};
454
455DT_MACHINE_START(VEXPRESS_DT, "ARM-Versatile Express")
456 .dt_compat = v2m_dt_match,
Marc Zyngier3695adc2011-09-08 13:15:22 +0100457 .smp = smp_ops(vexpress_smp_ops),
Jon Medhurst033a8992013-01-30 09:12:55 +0000458 .smp_init = smp_init_ops(vexpress_smp_init_ops),
Pawel Moll8deed172012-02-23 13:04:51 +0000459 .map_io = v2m_dt_map_io,
460 .init_early = v2m_dt_init_early,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700461 .init_time = v2m_dt_timer_init,
Pawel Moll8deed172012-02-23 13:04:51 +0000462 .init_machine = v2m_dt_init,
Pawel Moll8deed172012-02-23 13:04:51 +0000463MACHINE_END