ARM: add base support for Marvell Dove SoC
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-dove / common.c
bloba20cf099cd97725708ea607af253a7cff7425e59
1 /*
2 * arch/arm/mach-dove/common.c
4 * Core functions for Marvell Dove 88AP510 System On Chip
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
11 #include <linux/kernel.h>
12 #include <linux/delay.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/pci.h>
16 #include <linux/serial_8250.h>
17 #include <linux/clk.h>
18 #include <linux/mbus.h>
19 #include <linux/mv643xx_eth.h>
20 #include <linux/mv643xx_i2c.h>
21 #include <linux/ata_platform.h>
22 #include <linux/spi/orion_spi.h>
23 #include <linux/gpio.h>
24 #include <asm/page.h>
25 #include <asm/setup.h>
26 #include <asm/timex.h>
27 #include <asm/mach/map.h>
28 #include <asm/mach/time.h>
29 #include <asm/mach/pci.h>
30 #include <mach/dove.h>
31 #include <mach/bridge-regs.h>
32 #include <asm/mach/arch.h>
33 #include <linux/irq.h>
34 #include <plat/mv_xor.h>
35 #include <plat/ehci-orion.h>
36 #include <plat/time.h>
37 #include "common.h"
39 /*****************************************************************************
40 * I/O Address Mapping
41 ****************************************************************************/
42 static struct map_desc dove_io_desc[] __initdata = {
44 .virtual = DOVE_SB_REGS_VIRT_BASE,
45 .pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
46 .length = DOVE_SB_REGS_SIZE,
47 .type = MT_DEVICE,
48 }, {
49 .virtual = DOVE_NB_REGS_VIRT_BASE,
50 .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
51 .length = DOVE_NB_REGS_SIZE,
52 .type = MT_DEVICE,
53 }, {
54 .virtual = DOVE_PCIE0_IO_VIRT_BASE,
55 .pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE),
56 .length = DOVE_PCIE0_IO_SIZE,
57 .type = MT_DEVICE,
58 }, {
59 .virtual = DOVE_PCIE1_IO_VIRT_BASE,
60 .pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE),
61 .length = DOVE_PCIE1_IO_SIZE,
62 .type = MT_DEVICE,
66 void __init dove_map_io(void)
68 iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
71 /*****************************************************************************
72 * EHCI
73 ****************************************************************************/
74 static struct orion_ehci_data dove_ehci_data = {
75 .dram = &dove_mbus_dram_info,
76 .phy_version = EHCI_PHY_NA,
79 static u64 ehci_dmamask = DMA_BIT_MASK(32);
81 /*****************************************************************************
82 * EHCI0
83 ****************************************************************************/
84 static struct resource dove_ehci0_resources[] = {
86 .start = DOVE_USB0_PHYS_BASE,
87 .end = DOVE_USB0_PHYS_BASE + SZ_4K - 1,
88 .flags = IORESOURCE_MEM,
89 }, {
90 .start = IRQ_DOVE_USB0,
91 .end = IRQ_DOVE_USB0,
92 .flags = IORESOURCE_IRQ,
96 static struct platform_device dove_ehci0 = {
97 .name = "orion-ehci",
98 .id = 0,
99 .dev = {
100 .dma_mask = &ehci_dmamask,
101 .coherent_dma_mask = DMA_BIT_MASK(32),
102 .platform_data = &dove_ehci_data,
104 .resource = dove_ehci0_resources,
105 .num_resources = ARRAY_SIZE(dove_ehci0_resources),
108 void __init dove_ehci0_init(void)
110 platform_device_register(&dove_ehci0);
113 /*****************************************************************************
114 * EHCI1
115 ****************************************************************************/
116 static struct resource dove_ehci1_resources[] = {
118 .start = DOVE_USB1_PHYS_BASE,
119 .end = DOVE_USB1_PHYS_BASE + SZ_4K - 1,
120 .flags = IORESOURCE_MEM,
121 }, {
122 .start = IRQ_DOVE_USB1,
123 .end = IRQ_DOVE_USB1,
124 .flags = IORESOURCE_IRQ,
128 static struct platform_device dove_ehci1 = {
129 .name = "orion-ehci",
130 .id = 1,
131 .dev = {
132 .dma_mask = &ehci_dmamask,
133 .coherent_dma_mask = DMA_BIT_MASK(32),
134 .platform_data = &dove_ehci_data,
136 .resource = dove_ehci1_resources,
137 .num_resources = ARRAY_SIZE(dove_ehci1_resources),
140 void __init dove_ehci1_init(void)
142 platform_device_register(&dove_ehci1);
145 /*****************************************************************************
146 * GE00
147 ****************************************************************************/
148 struct mv643xx_eth_shared_platform_data dove_ge00_shared_data = {
149 .t_clk = 0,
150 .dram = &dove_mbus_dram_info,
153 static struct resource dove_ge00_shared_resources[] = {
155 .name = "ge00 base",
156 .start = DOVE_GE00_PHYS_BASE + 0x2000,
157 .end = DOVE_GE00_PHYS_BASE + SZ_16K - 1,
158 .flags = IORESOURCE_MEM,
162 static struct platform_device dove_ge00_shared = {
163 .name = MV643XX_ETH_SHARED_NAME,
164 .id = 0,
165 .dev = {
166 .platform_data = &dove_ge00_shared_data,
168 .num_resources = 1,
169 .resource = dove_ge00_shared_resources,
172 static struct resource dove_ge00_resources[] = {
174 .name = "ge00 irq",
175 .start = IRQ_DOVE_GE00_SUM,
176 .end = IRQ_DOVE_GE00_SUM,
177 .flags = IORESOURCE_IRQ,
181 static struct platform_device dove_ge00 = {
182 .name = MV643XX_ETH_NAME,
183 .id = 0,
184 .num_resources = 1,
185 .resource = dove_ge00_resources,
186 .dev = {
187 .coherent_dma_mask = 0xffffffff,
191 void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
193 eth_data->shared = &dove_ge00_shared;
194 dove_ge00.dev.platform_data = eth_data;
196 platform_device_register(&dove_ge00_shared);
197 platform_device_register(&dove_ge00);
200 /*****************************************************************************
201 * SoC RTC
202 ****************************************************************************/
203 static struct resource dove_rtc_resource[] = {
205 .start = DOVE_RTC_PHYS_BASE,
206 .end = DOVE_RTC_PHYS_BASE + 32 - 1,
207 .flags = IORESOURCE_MEM,
208 }, {
209 .start = IRQ_DOVE_RTC,
210 .flags = IORESOURCE_IRQ,
214 void __init dove_rtc_init(void)
216 platform_device_register_simple("rtc-mv", -1, dove_rtc_resource, 2);
219 /*****************************************************************************
220 * SATA
221 ****************************************************************************/
222 static struct resource dove_sata_resources[] = {
224 .name = "sata base",
225 .start = DOVE_SATA_PHYS_BASE,
226 .end = DOVE_SATA_PHYS_BASE + 0x5000 - 1,
227 .flags = IORESOURCE_MEM,
228 }, {
229 .name = "sata irq",
230 .start = IRQ_DOVE_SATA,
231 .end = IRQ_DOVE_SATA,
232 .flags = IORESOURCE_IRQ,
236 static struct platform_device dove_sata = {
237 .name = "sata_mv",
238 .id = 0,
239 .dev = {
240 .coherent_dma_mask = DMA_BIT_MASK(32),
242 .num_resources = ARRAY_SIZE(dove_sata_resources),
243 .resource = dove_sata_resources,
246 void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
248 sata_data->dram = &dove_mbus_dram_info;
249 dove_sata.dev.platform_data = sata_data;
250 platform_device_register(&dove_sata);
253 /*****************************************************************************
254 * UART0
255 ****************************************************************************/
256 static struct plat_serial8250_port dove_uart0_data[] = {
258 .mapbase = DOVE_UART0_PHYS_BASE,
259 .membase = (char *)DOVE_UART0_VIRT_BASE,
260 .irq = IRQ_DOVE_UART_0,
261 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
262 .iotype = UPIO_MEM,
263 .regshift = 2,
264 .uartclk = 0,
265 }, {
269 static struct resource dove_uart0_resources[] = {
271 .start = DOVE_UART0_PHYS_BASE,
272 .end = DOVE_UART0_PHYS_BASE + SZ_256 - 1,
273 .flags = IORESOURCE_MEM,
274 }, {
275 .start = IRQ_DOVE_UART_0,
276 .end = IRQ_DOVE_UART_0,
277 .flags = IORESOURCE_IRQ,
281 static struct platform_device dove_uart0 = {
282 .name = "serial8250",
283 .id = 0,
284 .dev = {
285 .platform_data = dove_uart0_data,
287 .resource = dove_uart0_resources,
288 .num_resources = ARRAY_SIZE(dove_uart0_resources),
291 void __init dove_uart0_init(void)
293 platform_device_register(&dove_uart0);
296 /*****************************************************************************
297 * UART1
298 ****************************************************************************/
299 static struct plat_serial8250_port dove_uart1_data[] = {
301 .mapbase = DOVE_UART1_PHYS_BASE,
302 .membase = (char *)DOVE_UART1_VIRT_BASE,
303 .irq = IRQ_DOVE_UART_1,
304 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
305 .iotype = UPIO_MEM,
306 .regshift = 2,
307 .uartclk = 0,
308 }, {
312 static struct resource dove_uart1_resources[] = {
314 .start = DOVE_UART1_PHYS_BASE,
315 .end = DOVE_UART1_PHYS_BASE + SZ_256 - 1,
316 .flags = IORESOURCE_MEM,
317 }, {
318 .start = IRQ_DOVE_UART_1,
319 .end = IRQ_DOVE_UART_1,
320 .flags = IORESOURCE_IRQ,
324 static struct platform_device dove_uart1 = {
325 .name = "serial8250",
326 .id = 1,
327 .dev = {
328 .platform_data = dove_uart1_data,
330 .resource = dove_uart1_resources,
331 .num_resources = ARRAY_SIZE(dove_uart1_resources),
334 void __init dove_uart1_init(void)
336 platform_device_register(&dove_uart1);
339 /*****************************************************************************
340 * UART2
341 ****************************************************************************/
342 static struct plat_serial8250_port dove_uart2_data[] = {
344 .mapbase = DOVE_UART2_PHYS_BASE,
345 .membase = (char *)DOVE_UART2_VIRT_BASE,
346 .irq = IRQ_DOVE_UART_2,
347 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
348 .iotype = UPIO_MEM,
349 .regshift = 2,
350 .uartclk = 0,
351 }, {
355 static struct resource dove_uart2_resources[] = {
357 .start = DOVE_UART2_PHYS_BASE,
358 .end = DOVE_UART2_PHYS_BASE + SZ_256 - 1,
359 .flags = IORESOURCE_MEM,
360 }, {
361 .start = IRQ_DOVE_UART_2,
362 .end = IRQ_DOVE_UART_2,
363 .flags = IORESOURCE_IRQ,
367 static struct platform_device dove_uart2 = {
368 .name = "serial8250",
369 .id = 2,
370 .dev = {
371 .platform_data = dove_uart2_data,
373 .resource = dove_uart2_resources,
374 .num_resources = ARRAY_SIZE(dove_uart2_resources),
377 void __init dove_uart2_init(void)
379 platform_device_register(&dove_uart2);
382 /*****************************************************************************
383 * UART3
384 ****************************************************************************/
385 static struct plat_serial8250_port dove_uart3_data[] = {
387 .mapbase = DOVE_UART3_PHYS_BASE,
388 .membase = (char *)DOVE_UART3_VIRT_BASE,
389 .irq = IRQ_DOVE_UART_3,
390 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
391 .iotype = UPIO_MEM,
392 .regshift = 2,
393 .uartclk = 0,
394 }, {
398 static struct resource dove_uart3_resources[] = {
400 .start = DOVE_UART3_PHYS_BASE,
401 .end = DOVE_UART3_PHYS_BASE + SZ_256 - 1,
402 .flags = IORESOURCE_MEM,
403 }, {
404 .start = IRQ_DOVE_UART_3,
405 .end = IRQ_DOVE_UART_3,
406 .flags = IORESOURCE_IRQ,
410 static struct platform_device dove_uart3 = {
411 .name = "serial8250",
412 .id = 3,
413 .dev = {
414 .platform_data = dove_uart3_data,
416 .resource = dove_uart3_resources,
417 .num_resources = ARRAY_SIZE(dove_uart3_resources),
420 void __init dove_uart3_init(void)
422 platform_device_register(&dove_uart3);
425 /*****************************************************************************
426 * SPI0
427 ****************************************************************************/
428 static struct orion_spi_info dove_spi0_data = {
429 .tclk = 0,
432 static struct resource dove_spi0_resources[] = {
434 .start = DOVE_SPI0_PHYS_BASE,
435 .end = DOVE_SPI0_PHYS_BASE + SZ_512 - 1,
436 .flags = IORESOURCE_MEM,
437 }, {
438 .start = IRQ_DOVE_SPI0,
439 .end = IRQ_DOVE_SPI0,
440 .flags = IORESOURCE_IRQ,
444 static struct platform_device dove_spi0 = {
445 .name = "orion_spi",
446 .id = 0,
447 .resource = dove_spi0_resources,
448 .dev = {
449 .platform_data = &dove_spi0_data,
451 .num_resources = ARRAY_SIZE(dove_spi0_resources),
454 void __init dove_spi0_init(void)
456 platform_device_register(&dove_spi0);
459 /*****************************************************************************
460 * SPI1
461 ****************************************************************************/
462 static struct orion_spi_info dove_spi1_data = {
463 .tclk = 0,
466 static struct resource dove_spi1_resources[] = {
468 .start = DOVE_SPI1_PHYS_BASE,
469 .end = DOVE_SPI1_PHYS_BASE + SZ_512 - 1,
470 .flags = IORESOURCE_MEM,
471 }, {
472 .start = IRQ_DOVE_SPI1,
473 .end = IRQ_DOVE_SPI1,
474 .flags = IORESOURCE_IRQ,
478 static struct platform_device dove_spi1 = {
479 .name = "orion_spi",
480 .id = 1,
481 .resource = dove_spi1_resources,
482 .dev = {
483 .platform_data = &dove_spi1_data,
485 .num_resources = ARRAY_SIZE(dove_spi1_resources),
488 void __init dove_spi1_init(void)
490 platform_device_register(&dove_spi1);
493 /*****************************************************************************
494 * I2C
495 ****************************************************************************/
496 static struct mv64xxx_i2c_pdata dove_i2c_data = {
497 .freq_m = 10, /* assumes 166 MHz TCLK gets 94.3kHz */
498 .freq_n = 3,
499 .timeout = 1000, /* Default timeout of 1 second */
502 static struct resource dove_i2c_resources[] = {
504 .name = "i2c base",
505 .start = DOVE_I2C_PHYS_BASE,
506 .end = DOVE_I2C_PHYS_BASE + 0x20 - 1,
507 .flags = IORESOURCE_MEM,
508 }, {
509 .name = "i2c irq",
510 .start = IRQ_DOVE_I2C,
511 .end = IRQ_DOVE_I2C,
512 .flags = IORESOURCE_IRQ,
516 static struct platform_device dove_i2c = {
517 .name = MV64XXX_I2C_CTLR_NAME,
518 .id = 0,
519 .num_resources = ARRAY_SIZE(dove_i2c_resources),
520 .resource = dove_i2c_resources,
521 .dev = {
522 .platform_data = &dove_i2c_data,
526 void __init dove_i2c_init(void)
528 platform_device_register(&dove_i2c);
531 /*****************************************************************************
532 * Time handling
533 ****************************************************************************/
534 static int get_tclk(void)
536 /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
537 return 166666667;
540 static void dove_timer_init(void)
542 orion_time_init(IRQ_DOVE_BRIDGE, get_tclk());
545 struct sys_timer dove_timer = {
546 .init = dove_timer_init,
549 /*****************************************************************************
550 * XOR
551 ****************************************************************************/
552 static struct mv_xor_platform_shared_data dove_xor_shared_data = {
553 .dram = &dove_mbus_dram_info,
556 /*****************************************************************************
557 * XOR 0
558 ****************************************************************************/
559 static u64 dove_xor0_dmamask = DMA_BIT_MASK(32);
561 static struct resource dove_xor0_shared_resources[] = {
563 .name = "xor 0 low",
564 .start = DOVE_XOR0_PHYS_BASE,
565 .end = DOVE_XOR0_PHYS_BASE + 0xff,
566 .flags = IORESOURCE_MEM,
567 }, {
568 .name = "xor 0 high",
569 .start = DOVE_XOR0_HIGH_PHYS_BASE,
570 .end = DOVE_XOR0_HIGH_PHYS_BASE + 0xff,
571 .flags = IORESOURCE_MEM,
575 static struct platform_device dove_xor0_shared = {
576 .name = MV_XOR_SHARED_NAME,
577 .id = 0,
578 .dev = {
579 .platform_data = &dove_xor_shared_data,
581 .num_resources = ARRAY_SIZE(dove_xor0_shared_resources),
582 .resource = dove_xor0_shared_resources,
585 static struct resource dove_xor00_resources[] = {
586 [0] = {
587 .start = IRQ_DOVE_XOR_00,
588 .end = IRQ_DOVE_XOR_00,
589 .flags = IORESOURCE_IRQ,
593 static struct mv_xor_platform_data dove_xor00_data = {
594 .shared = &dove_xor0_shared,
595 .hw_id = 0,
596 .pool_size = PAGE_SIZE,
599 static struct platform_device dove_xor00_channel = {
600 .name = MV_XOR_NAME,
601 .id = 0,
602 .num_resources = ARRAY_SIZE(dove_xor00_resources),
603 .resource = dove_xor00_resources,
604 .dev = {
605 .dma_mask = &dove_xor0_dmamask,
606 .coherent_dma_mask = DMA_BIT_MASK(64),
607 .platform_data = (void *)&dove_xor00_data,
611 static struct resource dove_xor01_resources[] = {
612 [0] = {
613 .start = IRQ_DOVE_XOR_01,
614 .end = IRQ_DOVE_XOR_01,
615 .flags = IORESOURCE_IRQ,
619 static struct mv_xor_platform_data dove_xor01_data = {
620 .shared = &dove_xor0_shared,
621 .hw_id = 1,
622 .pool_size = PAGE_SIZE,
625 static struct platform_device dove_xor01_channel = {
626 .name = MV_XOR_NAME,
627 .id = 1,
628 .num_resources = ARRAY_SIZE(dove_xor01_resources),
629 .resource = dove_xor01_resources,
630 .dev = {
631 .dma_mask = &dove_xor0_dmamask,
632 .coherent_dma_mask = DMA_BIT_MASK(64),
633 .platform_data = (void *)&dove_xor01_data,
637 void __init dove_xor0_init(void)
639 platform_device_register(&dove_xor0_shared);
642 * two engines can't do memset simultaneously, this limitation
643 * satisfied by removing memset support from one of the engines.
645 dma_cap_set(DMA_MEMCPY, dove_xor00_data.cap_mask);
646 dma_cap_set(DMA_XOR, dove_xor00_data.cap_mask);
647 platform_device_register(&dove_xor00_channel);
649 dma_cap_set(DMA_MEMCPY, dove_xor01_data.cap_mask);
650 dma_cap_set(DMA_MEMSET, dove_xor01_data.cap_mask);
651 dma_cap_set(DMA_XOR, dove_xor01_data.cap_mask);
652 platform_device_register(&dove_xor01_channel);
655 /*****************************************************************************
656 * XOR 1
657 ****************************************************************************/
658 static u64 dove_xor1_dmamask = DMA_BIT_MASK(32);
660 static struct resource dove_xor1_shared_resources[] = {
662 .name = "xor 0 low",
663 .start = DOVE_XOR1_PHYS_BASE,
664 .end = DOVE_XOR1_PHYS_BASE + 0xff,
665 .flags = IORESOURCE_MEM,
666 }, {
667 .name = "xor 0 high",
668 .start = DOVE_XOR1_HIGH_PHYS_BASE,
669 .end = DOVE_XOR1_HIGH_PHYS_BASE + 0xff,
670 .flags = IORESOURCE_MEM,
674 static struct platform_device dove_xor1_shared = {
675 .name = MV_XOR_SHARED_NAME,
676 .id = 1,
677 .dev = {
678 .platform_data = &dove_xor_shared_data,
680 .num_resources = ARRAY_SIZE(dove_xor1_shared_resources),
681 .resource = dove_xor1_shared_resources,
684 static struct resource dove_xor10_resources[] = {
685 [0] = {
686 .start = IRQ_DOVE_XOR_10,
687 .end = IRQ_DOVE_XOR_10,
688 .flags = IORESOURCE_IRQ,
692 static struct mv_xor_platform_data dove_xor10_data = {
693 .shared = &dove_xor1_shared,
694 .hw_id = 0,
695 .pool_size = PAGE_SIZE,
698 static struct platform_device dove_xor10_channel = {
699 .name = MV_XOR_NAME,
700 .id = 2,
701 .num_resources = ARRAY_SIZE(dove_xor10_resources),
702 .resource = dove_xor10_resources,
703 .dev = {
704 .dma_mask = &dove_xor1_dmamask,
705 .coherent_dma_mask = DMA_BIT_MASK(64),
706 .platform_data = (void *)&dove_xor10_data,
710 static struct resource dove_xor11_resources[] = {
711 [0] = {
712 .start = IRQ_DOVE_XOR_11,
713 .end = IRQ_DOVE_XOR_11,
714 .flags = IORESOURCE_IRQ,
718 static struct mv_xor_platform_data dove_xor11_data = {
719 .shared = &dove_xor1_shared,
720 .hw_id = 1,
721 .pool_size = PAGE_SIZE,
724 static struct platform_device dove_xor11_channel = {
725 .name = MV_XOR_NAME,
726 .id = 3,
727 .num_resources = ARRAY_SIZE(dove_xor11_resources),
728 .resource = dove_xor11_resources,
729 .dev = {
730 .dma_mask = &dove_xor1_dmamask,
731 .coherent_dma_mask = DMA_BIT_MASK(64),
732 .platform_data = (void *)&dove_xor11_data,
736 void __init dove_xor1_init(void)
738 platform_device_register(&dove_xor1_shared);
741 * two engines can't do memset simultaneously, this limitation
742 * satisfied by removing memset support from one of the engines.
744 dma_cap_set(DMA_MEMCPY, dove_xor10_data.cap_mask);
745 dma_cap_set(DMA_XOR, dove_xor10_data.cap_mask);
746 platform_device_register(&dove_xor10_channel);
748 dma_cap_set(DMA_MEMCPY, dove_xor11_data.cap_mask);
749 dma_cap_set(DMA_MEMSET, dove_xor11_data.cap_mask);
750 dma_cap_set(DMA_XOR, dove_xor11_data.cap_mask);
751 platform_device_register(&dove_xor11_channel);
754 void __init dove_init(void)
756 int tclk;
758 tclk = get_tclk();
760 printk(KERN_INFO "Dove 88AP510 SoC, ");
761 printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000);
763 dove_setup_cpu_mbus();
765 dove_ge00_shared_data.t_clk = tclk;
766 dove_uart0_data[0].uartclk = tclk;
767 dove_uart1_data[0].uartclk = tclk;
768 dove_uart2_data[0].uartclk = tclk;
769 dove_uart3_data[0].uartclk = tclk;
770 dove_spi0_data.tclk = tclk;
771 dove_spi1_data.tclk = tclk;
773 /* internal devices that every board has */
774 dove_rtc_init();
775 dove_xor0_init();
776 dove_xor1_init();