mfd: syscon: Add platform data with a regmap config name
[deliverable/linux.git] / arch / arm / mach-vexpress / v2m.c
CommitLineData
ceade897
RK
1/*
2 * Versatile Express V2M Motherboard Support
3 */
4#include <linux/device.h>
5#include <linux/amba/bus.h>
6#include <linux/amba/mmci.h>
7#include <linux/io.h>
3695adc2 8#include <linux/smp.h>
ceade897 9#include <linux/init.h>
8deed178
PM
10#include <linux/of_address.h>
11#include <linux/of_fdt.h>
12#include <linux/of_irq.h>
13#include <linux/of_platform.h>
ceade897 14#include <linux/platform_device.h>
95c34f83 15#include <linux/ata_platform.h>
ceade897
RK
16#include <linux/smsc911x.h>
17#include <linux/spinlock.h>
ceade897 18#include <linux/usb/isp1760.h>
0f71fd49 19#include <linux/mtd/physmap.h>
b2a54ff0
PM
20#include <linux/regulator/fixed.h>
21#include <linux/regulator/machine.h>
38669e04 22#include <linux/vexpress.h>
6e973d2c 23#include <linux/clkdev.h>
ceade897 24
80b5efbd 25#include <asm/mach-types.h>
ceade897 26#include <asm/sizes.h>
80b5efbd 27#include <asm/mach/arch.h>
ceade897
RK
28#include <asm/mach/map.h>
29#include <asm/mach/time.h>
30#include <asm/hardware/arm_timer.h>
8deed178 31#include <asm/hardware/cache-l2x0.h>
58daf18c 32#include <asm/hardware/timer-sp.h>
ceade897 33
80b5efbd 34#include <mach/ct-ca9x4.h>
ceade897
RK
35#include <mach/motherboard.h>
36
0af85dda 37#include <plat/sched_clock.h>
3695adc2 38#include <plat/platsmp.h>
ceade897
RK
39
40#include "core.h"
41
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
47
48static struct map_desc v2m_io_desc[] __initdata = {
49 {
98ed4ceb 50 .virtual = V2M_PERIPH,
ceade897
RK
51 .pfn = __phys_to_pfn(V2M_PA_CS7),
52 .length = SZ_128K,
53 .type = MT_DEVICE,
54 },
55};
56
98ed4ceb
PM
57static void __init v2m_sp804_init(void __iomem *base, unsigned int irq)
58{
59 if (WARN_ON(!base || irq == NO_IRQ))
60 return;
61
98ed4ceb
PM
62 sp804_clocksource_init(base + TIMER_2_BASE, "v2m-timer1");
63 sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0");
64}
ceade897 65
ceade897 66
ceade897
RK
67static 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,
71};
72
73static struct platform_device v2m_pcie_i2c_device = {
74 .name = "versatile-i2c",
75 .id = 0,
76 .num_resources = 1,
77 .resource = &v2m_pcie_i2c_resource,
78};
79
80static 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,
84};
85
86static struct platform_device v2m_ddc_i2c_device = {
87 .name = "versatile-i2c",
88 .id = 1,
89 .num_resources = 1,
90 .resource = &v2m_ddc_i2c_resource,
91};
92
93static struct resource v2m_eth_resources[] = {
94 {
95 .start = V2M_LAN9118,
96 .end = V2M_LAN9118 + SZ_64K - 1,
97 .flags = IORESOURCE_MEM,
98 }, {
99 .start = IRQ_V2M_LAN9118,
100 .end = IRQ_V2M_LAN9118,
101 .flags = IORESOURCE_IRQ,
102 },
103};
104
105static 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,
110};
111
112static struct platform_device v2m_eth_device = {
113 .name = "smsc911x",
114 .id = -1,
115 .resource = v2m_eth_resources,
116 .num_resources = ARRAY_SIZE(v2m_eth_resources),
117 .dev.platform_data = &v2m_eth_config,
118};
119
b2a54ff0
PM
120static struct regulator_consumer_supply v2m_eth_supplies[] = {
121 REGULATOR_SUPPLY("vddvario", "smsc911x"),
122 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
123};
124
ceade897
RK
125static struct resource v2m_usb_resources[] = {
126 {
127 .start = V2M_ISP1761,
128 .end = V2M_ISP1761 + SZ_128K - 1,
129 .flags = IORESOURCE_MEM,
130 }, {
131 .start = IRQ_V2M_ISP1761,
132 .end = IRQ_V2M_ISP1761,
133 .flags = IORESOURCE_IRQ,
134 },
135};
136
137static struct isp1760_platform_data v2m_usb_config = {
138 .is_isp1761 = true,
139 .bus_width_16 = false,
140 .port1_otg = true,
141 .analog_oc = false,
142 .dack_polarity_high = false,
143 .dreq_polarity_high = false,
144};
145
146static struct platform_device v2m_usb_device = {
147 .name = "isp1760",
148 .id = -1,
149 .resource = v2m_usb_resources,
150 .num_resources = ARRAY_SIZE(v2m_usb_resources),
151 .dev.platform_data = &v2m_usb_config,
152};
153
0f71fd49 154static struct physmap_flash_data v2m_flash_data = {
ceade897 155 .width = 4,
ceade897
RK
156};
157
158static struct resource v2m_flash_resources[] = {
159 {
160 .start = V2M_NOR0,
161 .end = V2M_NOR0 + SZ_64M - 1,
162 .flags = IORESOURCE_MEM,
163 }, {
164 .start = V2M_NOR1,
165 .end = V2M_NOR1 + SZ_64M - 1,
166 .flags = IORESOURCE_MEM,
167 },
168};
169
170static struct platform_device v2m_flash_device = {
0f71fd49 171 .name = "physmap-flash",
ceade897
RK
172 .id = -1,
173 .resource = v2m_flash_resources,
174 .num_resources = ARRAY_SIZE(v2m_flash_resources),
175 .dev.platform_data = &v2m_flash_data,
176};
177
95c34f83
NB
178static struct pata_platform_info v2m_pata_data = {
179 .ioport_shift = 2,
180};
181
182static struct resource v2m_pata_resources[] = {
183 {
184 .start = V2M_CF,
185 .end = V2M_CF + 0xff,
186 .flags = IORESOURCE_MEM,
187 }, {
188 .start = V2M_CF + 0x100,
189 .end = V2M_CF + SZ_4K - 1,
190 .flags = IORESOURCE_MEM,
191 },
192};
193
194static struct platform_device v2m_cf_device = {
195 .name = "pata_platform",
196 .id = -1,
197 .resource = v2m_pata_resources,
198 .num_resources = ARRAY_SIZE(v2m_pata_resources),
199 .dev.platform_data = &v2m_pata_data,
200};
ceade897 201
ceade897
RK
202static struct mmci_platform_data v2m_mmci_data = {
203 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
38669e04
PM
204 .gpio_wp = VEXPRESS_GPIO_MMC_WPROT,
205 .gpio_cd = VEXPRESS_GPIO_MMC_CARDIN,
206};
207
208static struct resource v2m_sysreg_resources[] = {
209 {
210 .start = V2M_SYSREGS,
211 .end = V2M_SYSREGS + 0xfff,
212 .flags = IORESOURCE_MEM,
213 },
214};
215
216static struct platform_device v2m_sysreg_device = {
217 .name = "vexpress-sysreg",
218 .id = -1,
219 .resource = v2m_sysreg_resources,
220 .num_resources = ARRAY_SIZE(v2m_sysreg_resources),
221};
222
223static struct platform_device v2m_muxfpga_device = {
224 .name = "vexpress-muxfpga",
225 .id = 0,
226 .num_resources = 1,
227 .resource = (struct resource []) {
228 VEXPRESS_RES_FUNC(0, 7),
229 }
230};
231
232static struct platform_device v2m_shutdown_device = {
233 .name = "vexpress-shutdown",
234 .id = 0,
235 .num_resources = 1,
236 .resource = (struct resource []) {
237 VEXPRESS_RES_FUNC(0, 8),
238 }
239};
240
241static struct platform_device v2m_reboot_device = {
242 .name = "vexpress-reboot",
243 .id = 0,
244 .num_resources = 1,
245 .resource = (struct resource []) {
246 VEXPRESS_RES_FUNC(0, 9),
247 }
248};
249
250static struct platform_device v2m_dvimode_device = {
251 .name = "vexpress-dvimode",
252 .id = 0,
253 .num_resources = 1,
254 .resource = (struct resource []) {
255 VEXPRESS_RES_FUNC(0, 11),
256 }
ceade897
RK
257};
258
cdd4e1a7
RK
259static AMBA_APB_DEVICE(aaci, "mb:aaci", 0, V2M_AACI, IRQ_V2M_AACI, NULL);
260static AMBA_APB_DEVICE(mmci, "mb:mmci", 0, V2M_MMCI, IRQ_V2M_MMCI, &v2m_mmci_data);
261static AMBA_APB_DEVICE(kmi0, "mb:kmi0", 0, V2M_KMI0, IRQ_V2M_KMI0, NULL);
262static AMBA_APB_DEVICE(kmi1, "mb:kmi1", 0, V2M_KMI1, IRQ_V2M_KMI1, NULL);
263static AMBA_APB_DEVICE(uart0, "mb:uart0", 0, V2M_UART0, IRQ_V2M_UART0, NULL);
264static AMBA_APB_DEVICE(uart1, "mb:uart1", 0, V2M_UART1, IRQ_V2M_UART1, NULL);
265static AMBA_APB_DEVICE(uart2, "mb:uart2", 0, V2M_UART2, IRQ_V2M_UART2, NULL);
266static AMBA_APB_DEVICE(uart3, "mb:uart3", 0, V2M_UART3, IRQ_V2M_UART3, NULL);
267static AMBA_APB_DEVICE(wdt, "mb:wdt", 0, V2M_WDT, IRQ_V2M_WDT, NULL);
268static AMBA_APB_DEVICE(rtc, "mb:rtc", 0, V2M_RTC, IRQ_V2M_RTC, NULL);
ceade897
RK
269
270static struct amba_device *v2m_amba_devs[] __initdata = {
271 &aaci_device,
272 &mmci_device,
273 &kmi0_device,
274 &kmi1_device,
275 &uart0_device,
276 &uart1_device,
277 &uart2_device,
278 &uart3_device,
279 &wdt_device,
280 &rtc_device,
281};
282
d1b8a775
PM
283static void __init v2m_timer_init(void)
284{
38669e04 285 vexpress_clk_init(ioremap(V2M_SYSCTL, SZ_4K));
d1b8a775
PM
286 v2m_sp804_init(ioremap(V2M_TIMER01, SZ_4K), IRQ_V2M_TIMER0);
287}
288
2fdf9993
RH
289static void __init v2m_init_early(void)
290{
d1b8a775
PM
291 if (ct_desc->init_early)
292 ct_desc->init_early();
38669e04 293 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
ceade897
RK
294}
295
80b5efbd
WD
296struct ct_desc *ct_desc;
297
298static struct ct_desc *ct_descs[] __initdata = {
299#ifdef CONFIG_ARCH_VEXPRESS_CA9X4
300 &ct_ca9x4_desc,
301#endif
302};
303
304static void __init v2m_populate_ct_desc(void)
305{
306 int i;
307 u32 current_tile_id;
308
309 ct_desc = NULL;
38669e04 310 current_tile_id = vexpress_get_procid(VEXPRESS_SITE_MASTER)
98ed4ceb 311 & V2M_CT_ID_MASK;
80b5efbd
WD
312
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];
316
317 if (!ct_desc)
8deed178
PM
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",
320 current_tile_id);
80b5efbd
WD
321}
322
323static void __init v2m_map_io(void)
324{
325 iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
38669e04 326 vexpress_sysreg_early_init(ioremap(V2M_SYSREGS, SZ_4K));
80b5efbd
WD
327 v2m_populate_ct_desc();
328 ct_desc->map_io();
329}
330
331static void __init v2m_init_irq(void)
332{
333 ct_desc->init_irq();
334}
335
336static void __init v2m_init(void)
ceade897
RK
337{
338 int i;
339
b2a54ff0
PM
340 regulator_register_fixed(0, v2m_eth_supplies,
341 ARRAY_SIZE(v2m_eth_supplies));
342
38669e04 343 platform_device_register(&v2m_sysreg_device);
ceade897
RK
344 platform_device_register(&v2m_pcie_i2c_device);
345 platform_device_register(&v2m_ddc_i2c_device);
346 platform_device_register(&v2m_flash_device);
95c34f83 347 platform_device_register(&v2m_cf_device);
ceade897
RK
348 platform_device_register(&v2m_eth_device);
349 platform_device_register(&v2m_usb_device);
350
351 for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
352 amba_device_register(v2m_amba_devs[i], &iomem_resource);
353
3b9334ac
PM
354 vexpress_sysreg_config_device_register(&v2m_muxfpga_device);
355 vexpress_sysreg_config_device_register(&v2m_shutdown_device);
356 vexpress_sysreg_config_device_register(&v2m_reboot_device);
357 vexpress_sysreg_config_device_register(&v2m_dvimode_device);
358
80b5efbd 359 ct_desc->init_tile();
ceade897 360}
80b5efbd
WD
361
362MACHINE_START(VEXPRESS, "ARM-Versatile Express")
e9ce8e5b 363 .atag_offset = 0x100,
3695adc2 364 .smp = smp_ops(vexpress_smp_ops),
80b5efbd
WD
365 .map_io = v2m_map_io,
366 .init_early = v2m_init_early,
367 .init_irq = v2m_init_irq,
6bb27d73 368 .init_time = v2m_timer_init,
80b5efbd
WD
369 .init_machine = v2m_init,
370MACHINE_END
8deed178 371
6a371956
PM
372static struct map_desc v2m_rs1_io_desc __initdata = {
373 .virtual = V2M_PERIPH,
374 .pfn = __phys_to_pfn(0x1c000000),
375 .length = SZ_2M,
376 .type = MT_DEVICE,
377};
378
379static int __init v2m_dt_scan_memory_map(unsigned long node, const char *uname,
380 int depth, void *data)
381{
382 const char **map = data;
383
384 if (strcmp(uname, "motherboard") != 0)
385 return 0;
386
387 *map = of_get_flat_dt_prop(node, "arm,v2m-memory-map", NULL);
388
389 return 1;
390}
391
8deed178
PM
392void __init v2m_dt_map_io(void)
393{
6a371956
PM
394 const char *map = NULL;
395
396 of_scan_flat_dt(v2m_dt_scan_memory_map, &map);
397
398 if (map && strcmp(map, "rs1") == 0)
399 iotable_init(&v2m_rs1_io_desc, 1);
400 else
401 iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
8deed178
PM
402
403#if defined(CONFIG_SMP)
404 vexpress_dt_smp_map_io();
405#endif
406}
407
8deed178
PM
408void __init v2m_dt_init_early(void)
409{
8deed178
PM
410 u32 dt_hbi;
411
38669e04 412 vexpress_sysreg_of_early_init();
8deed178
PM
413
414 /* Confirm board type against DT property, if available */
465aac6d 415 if (of_property_read_u32(of_allnodes, "arm,hbi", &dt_hbi) == 0) {
38669e04 416 u32 hbi = vexpress_get_hbi(VEXPRESS_SITE_MASTER);
8deed178
PM
417
418 if (WARN_ON(dt_hbi != hbi))
419 pr_warning("vexpress: DT HBI (%x) is not matching "
420 "hardware (%x)!\n", dt_hbi, hbi);
421 }
8deed178 422
56e89cf5 423 versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
8deed178
PM
424}
425
8deed178
PM
426
427static void __init v2m_dt_init(void)
428{
429 l2x0_of_init(0x00400000, 0xfe0fffff);
3b9334ac 430 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
8deed178
PM
431}
432
38669e04 433static const char * const v2m_dt_match[] __initconst = {
8deed178
PM
434 "arm,vexpress",
435 NULL,
436};
437
438DT_MACHINE_START(VEXPRESS_DT, "ARM-Versatile Express")
439 .dt_compat = v2m_dt_match,
3695adc2 440 .smp = smp_ops(vexpress_smp_ops),
033a899c 441 .smp_init = smp_init_ops(vexpress_smp_init_ops),
8deed178
PM
442 .map_io = v2m_dt_map_io,
443 .init_early = v2m_dt_init_early,
8deed178 444 .init_machine = v2m_dt_init,
8deed178 445MACHINE_END
This page took 0.264555 seconds and 5 git commands to generate.