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/ata_platform.h>
20 #include <linux/serial_8250.h>
21 #include <linux/gpio.h>
23 #include <asm/setup.h>
24 #include <asm/timex.h>
25 #include <asm/hardware/cache-tauros2.h>
26 #include <asm/mach/map.h>
27 #include <asm/mach/time.h>
28 #include <asm/mach/pci.h>
29 #include <mach/dove.h>
30 #include <mach/bridge-regs.h>
31 #include <asm/mach/arch.h>
32 #include <linux/irq.h>
33 #include <plat/mv_xor.h>
34 #include <plat/ehci-orion.h>
35 #include <plat/time.h>
36 #include <plat/common.h>
39 static int get_tclk(void);
41 /*****************************************************************************
43 ****************************************************************************/
44 static struct map_desc dove_io_desc[] __initdata = {
46 .virtual = DOVE_SB_REGS_VIRT_BASE,
47 .pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
48 .length = DOVE_SB_REGS_SIZE,
51 .virtual = DOVE_NB_REGS_VIRT_BASE,
52 .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
53 .length = DOVE_NB_REGS_SIZE,
56 .virtual = DOVE_PCIE0_IO_VIRT_BASE,
57 .pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE),
58 .length = DOVE_PCIE0_IO_SIZE,
61 .virtual = DOVE_PCIE1_IO_VIRT_BASE,
62 .pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE),
63 .length = DOVE_PCIE1_IO_SIZE,
68 void __init dove_map_io(void)
70 iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
73 /*****************************************************************************
75 ****************************************************************************/
76 static struct orion_ehci_data dove_ehci_data = {
77 .dram = &dove_mbus_dram_info,
78 .phy_version = EHCI_PHY_NA,
81 static u64 ehci_dmamask = DMA_BIT_MASK(32);
83 /*****************************************************************************
85 ****************************************************************************/
86 static struct resource dove_ehci0_resources[] = {
88 .start = DOVE_USB0_PHYS_BASE,
89 .end = DOVE_USB0_PHYS_BASE + SZ_4K - 1,
90 .flags = IORESOURCE_MEM,
92 .start = IRQ_DOVE_USB0,
94 .flags = IORESOURCE_IRQ,
98 static struct platform_device dove_ehci0 = {
102 .dma_mask = &ehci_dmamask,
103 .coherent_dma_mask = DMA_BIT_MASK(32),
104 .platform_data = &dove_ehci_data,
106 .resource = dove_ehci0_resources,
107 .num_resources = ARRAY_SIZE(dove_ehci0_resources),
110 void __init dove_ehci0_init(void)
112 platform_device_register(&dove_ehci0);
115 /*****************************************************************************
117 ****************************************************************************/
118 static struct resource dove_ehci1_resources[] = {
120 .start = DOVE_USB1_PHYS_BASE,
121 .end = DOVE_USB1_PHYS_BASE + SZ_4K - 1,
122 .flags = IORESOURCE_MEM,
124 .start = IRQ_DOVE_USB1,
125 .end = IRQ_DOVE_USB1,
126 .flags = IORESOURCE_IRQ,
130 static struct platform_device dove_ehci1 = {
131 .name = "orion-ehci",
134 .dma_mask = &ehci_dmamask,
135 .coherent_dma_mask = DMA_BIT_MASK(32),
136 .platform_data = &dove_ehci_data,
138 .resource = dove_ehci1_resources,
139 .num_resources = ARRAY_SIZE(dove_ehci1_resources),
142 void __init dove_ehci1_init(void)
144 platform_device_register(&dove_ehci1);
147 /*****************************************************************************
149 ****************************************************************************/
150 void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
152 orion_ge00_init(eth_data, &dove_mbus_dram_info,
153 DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM,
157 /*****************************************************************************
159 ****************************************************************************/
160 void __init dove_rtc_init(void)
162 orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC);
165 /*****************************************************************************
167 ****************************************************************************/
168 static struct resource dove_sata_resources[] = {
171 .start = DOVE_SATA_PHYS_BASE,
172 .end = DOVE_SATA_PHYS_BASE + 0x5000 - 1,
173 .flags = IORESOURCE_MEM,
176 .start = IRQ_DOVE_SATA,
177 .end = IRQ_DOVE_SATA,
178 .flags = IORESOURCE_IRQ,
182 static struct platform_device dove_sata = {
186 .coherent_dma_mask = DMA_BIT_MASK(32),
188 .num_resources = ARRAY_SIZE(dove_sata_resources),
189 .resource = dove_sata_resources,
192 void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
194 sata_data->dram = &dove_mbus_dram_info;
195 dove_sata.dev.platform_data = sata_data;
196 platform_device_register(&dove_sata);
199 /*****************************************************************************
201 ****************************************************************************/
202 void __init dove_uart0_init(void)
204 orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
205 IRQ_DOVE_UART_0, get_tclk());
208 /*****************************************************************************
210 ****************************************************************************/
211 void __init dove_uart1_init(void)
213 orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
214 IRQ_DOVE_UART_1, get_tclk());
217 /*****************************************************************************
219 ****************************************************************************/
220 void __init dove_uart2_init(void)
222 orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
223 IRQ_DOVE_UART_2, get_tclk());
226 /*****************************************************************************
228 ****************************************************************************/
229 void __init dove_uart3_init(void)
231 orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
232 IRQ_DOVE_UART_3, get_tclk());
235 /*****************************************************************************
237 ****************************************************************************/
238 void __init dove_spi0_init(void)
240 orion_spi_init(DOVE_SPI0_PHYS_BASE, get_tclk());
243 void __init dove_spi1_init(void)
245 orion_spi_init(DOVE_SPI1_PHYS_BASE, get_tclk());
248 /*****************************************************************************
250 ****************************************************************************/
251 void __init dove_i2c_init(void)
253 orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
256 /*****************************************************************************
258 ****************************************************************************/
259 void __init dove_init_early(void)
261 orion_time_set_base(TIMER_VIRT_BASE);
264 static int get_tclk(void)
266 /* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
270 static void dove_timer_init(void)
272 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
273 IRQ_DOVE_BRIDGE, get_tclk());
276 struct sys_timer dove_timer = {
277 .init = dove_timer_init,
280 /*****************************************************************************
282 ****************************************************************************/
283 static struct mv_xor_platform_shared_data dove_xor_shared_data = {
284 .dram = &dove_mbus_dram_info,
287 /*****************************************************************************
289 ****************************************************************************/
290 static u64 dove_xor0_dmamask = DMA_BIT_MASK(32);
292 static struct resource dove_xor0_shared_resources[] = {
295 .start = DOVE_XOR0_PHYS_BASE,
296 .end = DOVE_XOR0_PHYS_BASE + 0xff,
297 .flags = IORESOURCE_MEM,
299 .name = "xor 0 high",
300 .start = DOVE_XOR0_HIGH_PHYS_BASE,
301 .end = DOVE_XOR0_HIGH_PHYS_BASE + 0xff,
302 .flags = IORESOURCE_MEM,
306 static struct platform_device dove_xor0_shared = {
307 .name = MV_XOR_SHARED_NAME,
310 .platform_data = &dove_xor_shared_data,
312 .num_resources = ARRAY_SIZE(dove_xor0_shared_resources),
313 .resource = dove_xor0_shared_resources,
316 static struct resource dove_xor00_resources[] = {
318 .start = IRQ_DOVE_XOR_00,
319 .end = IRQ_DOVE_XOR_00,
320 .flags = IORESOURCE_IRQ,
324 static struct mv_xor_platform_data dove_xor00_data = {
325 .shared = &dove_xor0_shared,
327 .pool_size = PAGE_SIZE,
330 static struct platform_device dove_xor00_channel = {
333 .num_resources = ARRAY_SIZE(dove_xor00_resources),
334 .resource = dove_xor00_resources,
336 .dma_mask = &dove_xor0_dmamask,
337 .coherent_dma_mask = DMA_BIT_MASK(64),
338 .platform_data = &dove_xor00_data,
342 static struct resource dove_xor01_resources[] = {
344 .start = IRQ_DOVE_XOR_01,
345 .end = IRQ_DOVE_XOR_01,
346 .flags = IORESOURCE_IRQ,
350 static struct mv_xor_platform_data dove_xor01_data = {
351 .shared = &dove_xor0_shared,
353 .pool_size = PAGE_SIZE,
356 static struct platform_device dove_xor01_channel = {
359 .num_resources = ARRAY_SIZE(dove_xor01_resources),
360 .resource = dove_xor01_resources,
362 .dma_mask = &dove_xor0_dmamask,
363 .coherent_dma_mask = DMA_BIT_MASK(64),
364 .platform_data = &dove_xor01_data,
368 void __init dove_xor0_init(void)
370 platform_device_register(&dove_xor0_shared);
373 * two engines can't do memset simultaneously, this limitation
374 * satisfied by removing memset support from one of the engines.
376 dma_cap_set(DMA_MEMCPY, dove_xor00_data.cap_mask);
377 dma_cap_set(DMA_XOR, dove_xor00_data.cap_mask);
378 platform_device_register(&dove_xor00_channel);
380 dma_cap_set(DMA_MEMCPY, dove_xor01_data.cap_mask);
381 dma_cap_set(DMA_MEMSET, dove_xor01_data.cap_mask);
382 dma_cap_set(DMA_XOR, dove_xor01_data.cap_mask);
383 platform_device_register(&dove_xor01_channel);
386 /*****************************************************************************
388 ****************************************************************************/
389 static u64 dove_xor1_dmamask = DMA_BIT_MASK(32);
391 static struct resource dove_xor1_shared_resources[] = {
394 .start = DOVE_XOR1_PHYS_BASE,
395 .end = DOVE_XOR1_PHYS_BASE + 0xff,
396 .flags = IORESOURCE_MEM,
398 .name = "xor 0 high",
399 .start = DOVE_XOR1_HIGH_PHYS_BASE,
400 .end = DOVE_XOR1_HIGH_PHYS_BASE + 0xff,
401 .flags = IORESOURCE_MEM,
405 static struct platform_device dove_xor1_shared = {
406 .name = MV_XOR_SHARED_NAME,
409 .platform_data = &dove_xor_shared_data,
411 .num_resources = ARRAY_SIZE(dove_xor1_shared_resources),
412 .resource = dove_xor1_shared_resources,
415 static struct resource dove_xor10_resources[] = {
417 .start = IRQ_DOVE_XOR_10,
418 .end = IRQ_DOVE_XOR_10,
419 .flags = IORESOURCE_IRQ,
423 static struct mv_xor_platform_data dove_xor10_data = {
424 .shared = &dove_xor1_shared,
426 .pool_size = PAGE_SIZE,
429 static struct platform_device dove_xor10_channel = {
432 .num_resources = ARRAY_SIZE(dove_xor10_resources),
433 .resource = dove_xor10_resources,
435 .dma_mask = &dove_xor1_dmamask,
436 .coherent_dma_mask = DMA_BIT_MASK(64),
437 .platform_data = &dove_xor10_data,
441 static struct resource dove_xor11_resources[] = {
443 .start = IRQ_DOVE_XOR_11,
444 .end = IRQ_DOVE_XOR_11,
445 .flags = IORESOURCE_IRQ,
449 static struct mv_xor_platform_data dove_xor11_data = {
450 .shared = &dove_xor1_shared,
452 .pool_size = PAGE_SIZE,
455 static struct platform_device dove_xor11_channel = {
458 .num_resources = ARRAY_SIZE(dove_xor11_resources),
459 .resource = dove_xor11_resources,
461 .dma_mask = &dove_xor1_dmamask,
462 .coherent_dma_mask = DMA_BIT_MASK(64),
463 .platform_data = &dove_xor11_data,
467 void __init dove_xor1_init(void)
469 platform_device_register(&dove_xor1_shared);
472 * two engines can't do memset simultaneously, this limitation
473 * satisfied by removing memset support from one of the engines.
475 dma_cap_set(DMA_MEMCPY, dove_xor10_data.cap_mask);
476 dma_cap_set(DMA_XOR, dove_xor10_data.cap_mask);
477 platform_device_register(&dove_xor10_channel);
479 dma_cap_set(DMA_MEMCPY, dove_xor11_data.cap_mask);
480 dma_cap_set(DMA_MEMSET, dove_xor11_data.cap_mask);
481 dma_cap_set(DMA_XOR, dove_xor11_data.cap_mask);
482 platform_device_register(&dove_xor11_channel);
485 /*****************************************************************************
487 ****************************************************************************/
488 static u64 sdio_dmamask = DMA_BIT_MASK(32);
490 static struct resource dove_sdio0_resources[] = {
492 .start = DOVE_SDIO0_PHYS_BASE,
493 .end = DOVE_SDIO0_PHYS_BASE + 0xff,
494 .flags = IORESOURCE_MEM,
496 .start = IRQ_DOVE_SDIO0,
497 .end = IRQ_DOVE_SDIO0,
498 .flags = IORESOURCE_IRQ,
502 static struct platform_device dove_sdio0 = {
503 .name = "sdhci-dove",
506 .dma_mask = &sdio_dmamask,
507 .coherent_dma_mask = DMA_BIT_MASK(32),
509 .resource = dove_sdio0_resources,
510 .num_resources = ARRAY_SIZE(dove_sdio0_resources),
513 void __init dove_sdio0_init(void)
515 platform_device_register(&dove_sdio0);
518 static struct resource dove_sdio1_resources[] = {
520 .start = DOVE_SDIO1_PHYS_BASE,
521 .end = DOVE_SDIO1_PHYS_BASE + 0xff,
522 .flags = IORESOURCE_MEM,
524 .start = IRQ_DOVE_SDIO1,
525 .end = IRQ_DOVE_SDIO1,
526 .flags = IORESOURCE_IRQ,
530 static struct platform_device dove_sdio1 = {
531 .name = "sdhci-dove",
534 .dma_mask = &sdio_dmamask,
535 .coherent_dma_mask = DMA_BIT_MASK(32),
537 .resource = dove_sdio1_resources,
538 .num_resources = ARRAY_SIZE(dove_sdio1_resources),
541 void __init dove_sdio1_init(void)
543 platform_device_register(&dove_sdio1);
546 void __init dove_init(void)
552 printk(KERN_INFO "Dove 88AP510 SoC, ");
553 printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000);
555 #ifdef CONFIG_CACHE_TAUROS2
558 dove_setup_cpu_mbus();
560 /* internal devices that every board has */