ARM: vexpress: remove extra timer-sp control register clearing
[deliverable/linux.git] / arch / arm / mach-vexpress / v2m.c
1 /*
2 * Versatile Express V2M Motherboard Support
3 */
4 #include <linux/clocksource.h>
5 #include <linux/device.h>
6 #include <linux/amba/bus.h>
7 #include <linux/amba/mmci.h>
8 #include <linux/io.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>
26
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>
35
36 #include <mach/ct-ca9x4.h>
37 #include <mach/motherboard.h>
38
39 #include <plat/sched_clock.h>
40 #include <plat/platsmp.h>
41
42 #include "core.h"
43
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
49
50 static struct map_desc v2m_io_desc[] __initdata = {
51 {
52 .virtual = V2M_PERIPH,
53 .pfn = __phys_to_pfn(V2M_PA_CS7),
54 .length = SZ_128K,
55 .type = MT_DEVICE,
56 },
57 };
58
59 static void __init v2m_sp804_init(void __iomem *base, unsigned int irq)
60 {
61 if (WARN_ON(!base || irq == NO_IRQ))
62 return;
63
64 sp804_clocksource_init(base + TIMER_2_BASE, "v2m-timer1");
65 sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0");
66 }
67
68
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,
73 };
74
75 static struct platform_device v2m_pcie_i2c_device = {
76 .name = "versatile-i2c",
77 .id = 0,
78 .num_resources = 1,
79 .resource = &v2m_pcie_i2c_resource,
80 };
81
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,
86 };
87
88 static struct platform_device v2m_ddc_i2c_device = {
89 .name = "versatile-i2c",
90 .id = 1,
91 .num_resources = 1,
92 .resource = &v2m_ddc_i2c_resource,
93 };
94
95 static struct resource v2m_eth_resources[] = {
96 {
97 .start = V2M_LAN9118,
98 .end = V2M_LAN9118 + SZ_64K - 1,
99 .flags = IORESOURCE_MEM,
100 }, {
101 .start = IRQ_V2M_LAN9118,
102 .end = IRQ_V2M_LAN9118,
103 .flags = IORESOURCE_IRQ,
104 },
105 };
106
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,
112 };
113
114 static struct platform_device v2m_eth_device = {
115 .name = "smsc911x",
116 .id = -1,
117 .resource = v2m_eth_resources,
118 .num_resources = ARRAY_SIZE(v2m_eth_resources),
119 .dev.platform_data = &v2m_eth_config,
120 };
121
122 static struct regulator_consumer_supply v2m_eth_supplies[] = {
123 REGULATOR_SUPPLY("vddvario", "smsc911x"),
124 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
125 };
126
127 static struct resource v2m_usb_resources[] = {
128 {
129 .start = V2M_ISP1761,
130 .end = V2M_ISP1761 + SZ_128K - 1,
131 .flags = IORESOURCE_MEM,
132 }, {
133 .start = IRQ_V2M_ISP1761,
134 .end = IRQ_V2M_ISP1761,
135 .flags = IORESOURCE_IRQ,
136 },
137 };
138
139 static struct isp1760_platform_data v2m_usb_config = {
140 .is_isp1761 = true,
141 .bus_width_16 = false,
142 .port1_otg = true,
143 .analog_oc = false,
144 .dack_polarity_high = false,
145 .dreq_polarity_high = false,
146 };
147
148 static struct platform_device v2m_usb_device = {
149 .name = "isp1760",
150 .id = -1,
151 .resource = v2m_usb_resources,
152 .num_resources = ARRAY_SIZE(v2m_usb_resources),
153 .dev.platform_data = &v2m_usb_config,
154 };
155
156 static struct physmap_flash_data v2m_flash_data = {
157 .width = 4,
158 };
159
160 static struct resource v2m_flash_resources[] = {
161 {
162 .start = V2M_NOR0,
163 .end = V2M_NOR0 + SZ_64M - 1,
164 .flags = IORESOURCE_MEM,
165 }, {
166 .start = V2M_NOR1,
167 .end = V2M_NOR1 + SZ_64M - 1,
168 .flags = IORESOURCE_MEM,
169 },
170 };
171
172 static struct platform_device v2m_flash_device = {
173 .name = "physmap-flash",
174 .id = -1,
175 .resource = v2m_flash_resources,
176 .num_resources = ARRAY_SIZE(v2m_flash_resources),
177 .dev.platform_data = &v2m_flash_data,
178 };
179
180 static struct pata_platform_info v2m_pata_data = {
181 .ioport_shift = 2,
182 };
183
184 static struct resource v2m_pata_resources[] = {
185 {
186 .start = V2M_CF,
187 .end = V2M_CF + 0xff,
188 .flags = IORESOURCE_MEM,
189 }, {
190 .start = V2M_CF + 0x100,
191 .end = V2M_CF + SZ_4K - 1,
192 .flags = IORESOURCE_MEM,
193 },
194 };
195
196 static struct platform_device v2m_cf_device = {
197 .name = "pata_platform",
198 .id = -1,
199 .resource = v2m_pata_resources,
200 .num_resources = ARRAY_SIZE(v2m_pata_resources),
201 .dev.platform_data = &v2m_pata_data,
202 };
203
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,
208 };
209
210 static struct resource v2m_sysreg_resources[] = {
211 {
212 .start = V2M_SYSREGS,
213 .end = V2M_SYSREGS + 0xfff,
214 .flags = IORESOURCE_MEM,
215 },
216 };
217
218 static struct platform_device v2m_sysreg_device = {
219 .name = "vexpress-sysreg",
220 .id = -1,
221 .resource = v2m_sysreg_resources,
222 .num_resources = ARRAY_SIZE(v2m_sysreg_resources),
223 };
224
225 static struct platform_device v2m_muxfpga_device = {
226 .name = "vexpress-muxfpga",
227 .id = 0,
228 .num_resources = 1,
229 .resource = (struct resource []) {
230 VEXPRESS_RES_FUNC(0, 7),
231 }
232 };
233
234 static struct platform_device v2m_shutdown_device = {
235 .name = "vexpress-shutdown",
236 .id = 0,
237 .num_resources = 1,
238 .resource = (struct resource []) {
239 VEXPRESS_RES_FUNC(0, 8),
240 }
241 };
242
243 static struct platform_device v2m_reboot_device = {
244 .name = "vexpress-reboot",
245 .id = 0,
246 .num_resources = 1,
247 .resource = (struct resource []) {
248 VEXPRESS_RES_FUNC(0, 9),
249 }
250 };
251
252 static struct platform_device v2m_dvimode_device = {
253 .name = "vexpress-dvimode",
254 .id = 0,
255 .num_resources = 1,
256 .resource = (struct resource []) {
257 VEXPRESS_RES_FUNC(0, 11),
258 }
259 };
260
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);
271
272 static struct amba_device *v2m_amba_devs[] __initdata = {
273 &aaci_device,
274 &mmci_device,
275 &kmi0_device,
276 &kmi1_device,
277 &uart0_device,
278 &uart1_device,
279 &uart2_device,
280 &uart3_device,
281 &wdt_device,
282 &rtc_device,
283 };
284
285 static void __init v2m_timer_init(void)
286 {
287 vexpress_clk_init(ioremap(V2M_SYSCTL, SZ_4K));
288 v2m_sp804_init(ioremap(V2M_TIMER01, SZ_4K), IRQ_V2M_TIMER0);
289 }
290
291 static void __init v2m_init_early(void)
292 {
293 if (ct_desc->init_early)
294 ct_desc->init_early();
295 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
296 }
297
298 struct ct_desc *ct_desc;
299
300 static struct ct_desc *ct_descs[] __initdata = {
301 #ifdef CONFIG_ARCH_VEXPRESS_CA9X4
302 &ct_ca9x4_desc,
303 #endif
304 };
305
306 static void __init v2m_populate_ct_desc(void)
307 {
308 int i;
309 u32 current_tile_id;
310
311 ct_desc = NULL;
312 current_tile_id = vexpress_get_procid(VEXPRESS_SITE_MASTER)
313 & V2M_CT_ID_MASK;
314
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];
318
319 if (!ct_desc)
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",
322 current_tile_id);
323 }
324
325 static void __init v2m_map_io(void)
326 {
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();
330 ct_desc->map_io();
331 }
332
333 static void __init v2m_init_irq(void)
334 {
335 ct_desc->init_irq();
336 }
337
338 static void __init v2m_init(void)
339 {
340 int i;
341
342 regulator_register_fixed(0, v2m_eth_supplies,
343 ARRAY_SIZE(v2m_eth_supplies));
344
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);
349
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);
357
358 for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
359 amba_device_register(v2m_amba_devs[i], &iomem_resource);
360
361 pm_power_off = vexpress_power_off;
362
363 ct_desc->init_tile();
364 }
365
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,
375 MACHINE_END
376
377 static struct map_desc v2m_rs1_io_desc __initdata = {
378 .virtual = V2M_PERIPH,
379 .pfn = __phys_to_pfn(0x1c000000),
380 .length = SZ_2M,
381 .type = MT_DEVICE,
382 };
383
384 static int __init v2m_dt_scan_memory_map(unsigned long node, const char *uname,
385 int depth, void *data)
386 {
387 const char **map = data;
388
389 if (strcmp(uname, "motherboard") != 0)
390 return 0;
391
392 *map = of_get_flat_dt_prop(node, "arm,v2m-memory-map", NULL);
393
394 return 1;
395 }
396
397 void __init v2m_dt_map_io(void)
398 {
399 const char *map = NULL;
400
401 of_scan_flat_dt(v2m_dt_scan_memory_map, &map);
402
403 if (map && strcmp(map, "rs1") == 0)
404 iotable_init(&v2m_rs1_io_desc, 1);
405 else
406 iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
407
408 #if defined(CONFIG_SMP)
409 vexpress_dt_smp_map_io();
410 #endif
411 }
412
413 void __init v2m_dt_init_early(void)
414 {
415 u32 dt_hbi;
416
417 vexpress_sysreg_of_early_init();
418
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);
422
423 if (WARN_ON(dt_hbi != hbi))
424 pr_warning("vexpress: DT HBI (%x) is not matching "
425 "hardware (%x)!\n", dt_hbi, hbi);
426 }
427 }
428
429 static void __init v2m_dt_timer_init(void)
430 {
431 vexpress_clk_of_init();
432
433 clocksource_of_init();
434
435 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
436 24000000);
437 }
438
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", },
443 {}
444 };
445
446 static void __init v2m_dt_init(void)
447 {
448 l2x0_of_init(0x00400000, 0xfe0fffff);
449 of_platform_populate(NULL, v2m_dt_bus_match, NULL, NULL);
450 pm_power_off = vexpress_power_off;
451 }
452
453 static const char * const v2m_dt_match[] __initconst = {
454 "arm,vexpress",
455 "xen,xenvm",
456 NULL,
457 };
458
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,
468 MACHINE_END
This page took 0.066194 seconds and 6 git commands to generate.