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.
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_i2c.h>
20 #include <linux/ata_platform.h>
21 #include <linux/serial_8250.h>
22 #include <linux/spi/orion_spi.h>
23 #include <linux/gpio.h>
25 #include <asm/setup.h>
26 #include <asm/timex.h>
27 #include <asm/hardware/cache-tauros2.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/time.h>
30 #include <asm/mach/pci.h>
31 #include <mach/dove.h>
32 #include <mach/bridge-regs.h>
33 #include <asm/mach/arch.h>
34 #include <linux/irq.h>
35 #include <plat/mv_xor.h>
36 #include <plat/ehci-orion.h>
37 #include <plat/time.h>
38 #include <plat/common.h>
41 static int get_tclk(void);
43 /*****************************************************************************
45 ****************************************************************************/
46 static struct map_desc dove_io_desc[] __initdata = {
48 .virtual = DOVE_SB_REGS_VIRT_BASE,
49 .pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
50 .length = DOVE_SB_REGS_SIZE,
53 .virtual = DOVE_NB_REGS_VIRT_BASE,
54 .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
55 .length = DOVE_NB_REGS_SIZE,
58 .virtual = DOVE_PCIE0_IO_VIRT_BASE,
59 .pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE),
60 .length = DOVE_PCIE0_IO_SIZE,
63 .virtual = DOVE_PCIE1_IO_VIRT_BASE,
64 .pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE),
65 .length = DOVE_PCIE1_IO_SIZE,
70 void __init dove_map_io(void)
72 iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
75 /*****************************************************************************
77 ****************************************************************************/
78 static struct orion_ehci_data dove_ehci_data = {
79 .dram = &dove_mbus_dram_info,
80 .phy_version = EHCI_PHY_NA,
83 static u64 ehci_dmamask = DMA_BIT_MASK(32);
85 /*****************************************************************************
87 ****************************************************************************/
88 static struct resource dove_ehci0_resources[] = {
90 .start = DOVE_USB0_PHYS_BASE,
91 .end = DOVE_USB0_PHYS_BASE + SZ_4K - 1,
92 .flags = IORESOURCE_MEM,
94 .start = IRQ_DOVE_USB0,
96 .flags = IORESOURCE_IRQ,
100 static struct platform_device dove_ehci0 = {
101 .name = "orion-ehci",
104 .dma_mask = &ehci_dmamask,
105 .coherent_dma_mask = DMA_BIT_MASK(32),
106 .platform_data = &dove_ehci_data,
108 .resource = dove_ehci0_resources,
109 .num_resources = ARRAY_SIZE(dove_ehci0_resources),
112 void __init dove_ehci0_init(void)
114 platform_device_register(&dove_ehci0);
117 /*****************************************************************************
119 ****************************************************************************/
120 static struct resource dove_ehci1_resources[] = {
122 .start = DOVE_USB1_PHYS_BASE,
123 .end = DOVE_USB1_PHYS_BASE + SZ_4K - 1,
124 .flags = IORESOURCE_MEM,
126 .start = IRQ_DOVE_USB1,
127 .end = IRQ_DOVE_USB1,
128 .flags = IORESOURCE_IRQ,
132 static struct platform_device dove_ehci1 = {
133 .name = "orion-ehci",
136 .dma_mask = &ehci_dmamask,
137 .coherent_dma_mask = DMA_BIT_MASK(32),
138 .platform_data = &dove_ehci_data,
140 .resource = dove_ehci1_resources,
141 .num_resources = ARRAY_SIZE(dove_ehci1_resources),
144 void __init dove_ehci1_init(void)
146 platform_device_register(&dove_ehci1);
149 /*****************************************************************************
151 ****************************************************************************/
152 void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
154 orion_ge00_init(eth_data, &dove_mbus_dram_info,
155 DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM,
159 /*****************************************************************************
161 ****************************************************************************/
162 void __init dove_rtc_init(void)
164 orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC);
167 /*****************************************************************************
169 ****************************************************************************/
170 static struct resource dove_sata_resources[] = {
173 .start = DOVE_SATA_PHYS_BASE,
174 .end = DOVE_SATA_PHYS_BASE + 0x5000 - 1,
175 .flags = IORESOURCE_MEM,
178 .start = IRQ_DOVE_SATA,
179 .end = IRQ_DOVE_SATA,
180 .flags = IORESOURCE_IRQ,
184 static struct platform_device dove_sata = {
188 .coherent_dma_mask = DMA_BIT_MASK(32),
190 .num_resources = ARRAY_SIZE(dove_sata_resources),
191 .resource = dove_sata_resources,
194 void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
196 sata_data->dram = &dove_mbus_dram_info;
197 dove_sata.dev.platform_data = sata_data;
198 platform_device_register(&dove_sata);
201 /*****************************************************************************
203 ****************************************************************************/
204 void __init dove_uart0_init(void)
206 orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
207 IRQ_DOVE_UART_0, get_tclk());
210 /*****************************************************************************
212 ****************************************************************************/
213 void __init dove_uart1_init(void)
215 orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
216 IRQ_DOVE_UART_1, get_tclk());
219 /*****************************************************************************
221 ****************************************************************************/
222 void __init dove_uart2_init(void)
224 orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
225 IRQ_DOVE_UART_2, get_tclk());
228 /*****************************************************************************
230 ****************************************************************************/
231 void __init dove_uart3_init(void)
233 orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
234 IRQ_DOVE_UART_3, get_tclk());
237 /*****************************************************************************
239 ****************************************************************************/
240 static struct orion_spi_info dove_spi0_data = {
244 static struct resource dove_spi0_resources[] = {
246 .start = DOVE_SPI0_PHYS_BASE,
247 .end = DOVE_SPI0_PHYS_BASE + SZ_512 - 1,
248 .flags = IORESOURCE_MEM,
250 .start = IRQ_DOVE_SPI0,
251 .end = IRQ_DOVE_SPI0,
252 .flags = IORESOURCE_IRQ,
256 static struct platform_device dove_spi0 = {
259 .resource = dove_spi0_resources,
261 .platform_data = &dove_spi0_data,
263 .num_resources = ARRAY_SIZE(dove_spi0_resources),
266 void __init dove_spi0_init(void)
268 platform_device_register(&dove_spi0);
271 /*****************************************************************************
273 ****************************************************************************/
274 static struct orion_spi_info dove_spi1_data = {
278 static struct resource dove_spi1_resources[] = {
280 .start = DOVE_SPI1_PHYS_BASE,
281 .end = DOVE_SPI1_PHYS_BASE + SZ_512 - 1,
282 .flags = IORESOURCE_MEM,
284 .start = IRQ_DOVE_SPI1,
285 .end = IRQ_DOVE_SPI1,
286 .flags = IORESOURCE_IRQ,
290 static struct platform_device dove_spi1 = {
293 .resource = dove_spi1_resources,
295 .platform_data = &dove_spi1_data,
297 .num_resources = ARRAY_SIZE(dove_spi1_resources),
300 void __init dove_spi1_init(void)
302 platform_device_register(&dove_spi1);
305 /*****************************************************************************
307 ****************************************************************************/
308 static struct mv64xxx_i2c_pdata dove_i2c_data = {
309 .freq_m = 10, /* assumes 166 MHz TCLK gets 94.3kHz */
311 .timeout = 1000, /* Default timeout of 1 second */
314 static struct resource dove_i2c_resources[] = {
317 .start = DOVE_I2C_PHYS_BASE,
318 .end = DOVE_I2C_PHYS_BASE + 0x20 - 1,
319 .flags = IORESOURCE_MEM,
322 .start = IRQ_DOVE_I2C,
324 .flags = IORESOURCE_IRQ,
328 static struct platform_device dove_i2c = {
329 .name = MV64XXX_I2C_CTLR_NAME,
331 .num_resources = ARRAY_SIZE(dove_i2c_resources),
332 .resource = dove_i2c_resources,
334 .platform_data = &dove_i2c_data,
338 void __init dove_i2c_init(void)
340 platform_device_register(&dove_i2c);
343 /*****************************************************************************
345 ****************************************************************************/
346 void __init dove_init_early(void)
348 orion_time_set_base(TIMER_VIRT_BASE);
351 static int get_tclk(void)
353 /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
357 static void dove_timer_init(void)
359 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
360 IRQ_DOVE_BRIDGE, get_tclk());
363 struct sys_timer dove_timer = {
364 .init = dove_timer_init,
367 /*****************************************************************************
369 ****************************************************************************/
370 static struct mv_xor_platform_shared_data dove_xor_shared_data = {
371 .dram = &dove_mbus_dram_info,
374 /*****************************************************************************
376 ****************************************************************************/
377 static u64 dove_xor0_dmamask = DMA_BIT_MASK(32);
379 static struct resource dove_xor0_shared_resources[] = {
382 .start = DOVE_XOR0_PHYS_BASE,
383 .end = DOVE_XOR0_PHYS_BASE + 0xff,
384 .flags = IORESOURCE_MEM,
386 .name = "xor 0 high",
387 .start = DOVE_XOR0_HIGH_PHYS_BASE,
388 .end = DOVE_XOR0_HIGH_PHYS_BASE + 0xff,
389 .flags = IORESOURCE_MEM,
393 static struct platform_device dove_xor0_shared = {
394 .name = MV_XOR_SHARED_NAME,
397 .platform_data = &dove_xor_shared_data,
399 .num_resources = ARRAY_SIZE(dove_xor0_shared_resources),
400 .resource = dove_xor0_shared_resources,
403 static struct resource dove_xor00_resources[] = {
405 .start = IRQ_DOVE_XOR_00,
406 .end = IRQ_DOVE_XOR_00,
407 .flags = IORESOURCE_IRQ,
411 static struct mv_xor_platform_data dove_xor00_data = {
412 .shared = &dove_xor0_shared,
414 .pool_size = PAGE_SIZE,
417 static struct platform_device dove_xor00_channel = {
420 .num_resources = ARRAY_SIZE(dove_xor00_resources),
421 .resource = dove_xor00_resources,
423 .dma_mask = &dove_xor0_dmamask,
424 .coherent_dma_mask = DMA_BIT_MASK(64),
425 .platform_data = &dove_xor00_data,
429 static struct resource dove_xor01_resources[] = {
431 .start = IRQ_DOVE_XOR_01,
432 .end = IRQ_DOVE_XOR_01,
433 .flags = IORESOURCE_IRQ,
437 static struct mv_xor_platform_data dove_xor01_data = {
438 .shared = &dove_xor0_shared,
440 .pool_size = PAGE_SIZE,
443 static struct platform_device dove_xor01_channel = {
446 .num_resources = ARRAY_SIZE(dove_xor01_resources),
447 .resource = dove_xor01_resources,
449 .dma_mask = &dove_xor0_dmamask,
450 .coherent_dma_mask = DMA_BIT_MASK(64),
451 .platform_data = &dove_xor01_data,
455 void __init dove_xor0_init(void)
457 platform_device_register(&dove_xor0_shared);
460 * two engines can't do memset simultaneously, this limitation
461 * satisfied by removing memset support from one of the engines.
463 dma_cap_set(DMA_MEMCPY, dove_xor00_data.cap_mask);
464 dma_cap_set(DMA_XOR, dove_xor00_data.cap_mask);
465 platform_device_register(&dove_xor00_channel);
467 dma_cap_set(DMA_MEMCPY, dove_xor01_data.cap_mask);
468 dma_cap_set(DMA_MEMSET, dove_xor01_data.cap_mask);
469 dma_cap_set(DMA_XOR, dove_xor01_data.cap_mask);
470 platform_device_register(&dove_xor01_channel);
473 /*****************************************************************************
475 ****************************************************************************/
476 static u64 dove_xor1_dmamask = DMA_BIT_MASK(32);
478 static struct resource dove_xor1_shared_resources[] = {
481 .start = DOVE_XOR1_PHYS_BASE,
482 .end = DOVE_XOR1_PHYS_BASE + 0xff,
483 .flags = IORESOURCE_MEM,
485 .name = "xor 0 high",
486 .start = DOVE_XOR1_HIGH_PHYS_BASE,
487 .end = DOVE_XOR1_HIGH_PHYS_BASE + 0xff,
488 .flags = IORESOURCE_MEM,
492 static struct platform_device dove_xor1_shared = {
493 .name = MV_XOR_SHARED_NAME,
496 .platform_data = &dove_xor_shared_data,
498 .num_resources = ARRAY_SIZE(dove_xor1_shared_resources),
499 .resource = dove_xor1_shared_resources,
502 static struct resource dove_xor10_resources[] = {
504 .start = IRQ_DOVE_XOR_10,
505 .end = IRQ_DOVE_XOR_10,
506 .flags = IORESOURCE_IRQ,
510 static struct mv_xor_platform_data dove_xor10_data = {
511 .shared = &dove_xor1_shared,
513 .pool_size = PAGE_SIZE,
516 static struct platform_device dove_xor10_channel = {
519 .num_resources = ARRAY_SIZE(dove_xor10_resources),
520 .resource = dove_xor10_resources,
522 .dma_mask = &dove_xor1_dmamask,
523 .coherent_dma_mask = DMA_BIT_MASK(64),
524 .platform_data = &dove_xor10_data,
528 static struct resource dove_xor11_resources[] = {
530 .start = IRQ_DOVE_XOR_11,
531 .end = IRQ_DOVE_XOR_11,
532 .flags = IORESOURCE_IRQ,
536 static struct mv_xor_platform_data dove_xor11_data = {
537 .shared = &dove_xor1_shared,
539 .pool_size = PAGE_SIZE,
542 static struct platform_device dove_xor11_channel = {
545 .num_resources = ARRAY_SIZE(dove_xor11_resources),
546 .resource = dove_xor11_resources,
548 .dma_mask = &dove_xor1_dmamask,
549 .coherent_dma_mask = DMA_BIT_MASK(64),
550 .platform_data = &dove_xor11_data,
554 void __init dove_xor1_init(void)
556 platform_device_register(&dove_xor1_shared);
559 * two engines can't do memset simultaneously, this limitation
560 * satisfied by removing memset support from one of the engines.
562 dma_cap_set(DMA_MEMCPY, dove_xor10_data.cap_mask);
563 dma_cap_set(DMA_XOR, dove_xor10_data.cap_mask);
564 platform_device_register(&dove_xor10_channel);
566 dma_cap_set(DMA_MEMCPY, dove_xor11_data.cap_mask);
567 dma_cap_set(DMA_MEMSET, dove_xor11_data.cap_mask);
568 dma_cap_set(DMA_XOR, dove_xor11_data.cap_mask);
569 platform_device_register(&dove_xor11_channel);
572 /*****************************************************************************
574 ****************************************************************************/
575 static u64 sdio_dmamask = DMA_BIT_MASK(32);
577 static struct resource dove_sdio0_resources[] = {
579 .start = DOVE_SDIO0_PHYS_BASE,
580 .end = DOVE_SDIO0_PHYS_BASE + 0xff,
581 .flags = IORESOURCE_MEM,
583 .start = IRQ_DOVE_SDIO0,
584 .end = IRQ_DOVE_SDIO0,
585 .flags = IORESOURCE_IRQ,
589 static struct platform_device dove_sdio0 = {
590 .name = "sdhci-dove",
593 .dma_mask = &sdio_dmamask,
594 .coherent_dma_mask = DMA_BIT_MASK(32),
596 .resource = dove_sdio0_resources,
597 .num_resources = ARRAY_SIZE(dove_sdio0_resources),
600 void __init dove_sdio0_init(void)
602 platform_device_register(&dove_sdio0);
605 static struct resource dove_sdio1_resources[] = {
607 .start = DOVE_SDIO1_PHYS_BASE,
608 .end = DOVE_SDIO1_PHYS_BASE + 0xff,
609 .flags = IORESOURCE_MEM,
611 .start = IRQ_DOVE_SDIO1,
612 .end = IRQ_DOVE_SDIO1,
613 .flags = IORESOURCE_IRQ,
617 static struct platform_device dove_sdio1 = {
618 .name = "sdhci-dove",
621 .dma_mask = &sdio_dmamask,
622 .coherent_dma_mask = DMA_BIT_MASK(32),
624 .resource = dove_sdio1_resources,
625 .num_resources = ARRAY_SIZE(dove_sdio1_resources),
628 void __init dove_sdio1_init(void)
630 platform_device_register(&dove_sdio1);
633 void __init dove_init(void)
639 printk(KERN_INFO "Dove 88AP510 SoC, ");
640 printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000);
642 #ifdef CONFIG_CACHE_TAUROS2
645 dove_setup_cpu_mbus();
647 dove_spi0_data.tclk = tclk;
648 dove_spi1_data.tclk = tclk;
650 /* internal devices that every board has */