2 * arch/arm/mach-kirkwood/common.c
4 * Core functions for Marvell Kirkwood SoCs
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/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/serial_8250.h>
15 #include <linux/mbus.h>
16 #include <linux/mv643xx_eth.h>
17 #include <linux/ata_platform.h>
18 #include <linux/spi/orion_spi.h>
20 #include <asm/timex.h>
21 #include <asm/mach/map.h>
22 #include <asm/mach/time.h>
23 #include <mach/kirkwood.h>
24 #include <plat/cache-feroceon-l2.h>
25 #include <plat/ehci-orion.h>
26 #include <plat/mv_xor.h>
27 #include <plat/orion_nand.h>
28 #include <plat/time.h>
31 /*****************************************************************************
33 ****************************************************************************/
34 static struct map_desc kirkwood_io_desc[] __initdata = {
36 .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE,
37 .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE),
38 .length = KIRKWOOD_PCIE_IO_SIZE,
41 .virtual = KIRKWOOD_REGS_VIRT_BASE,
42 .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
43 .length = KIRKWOOD_REGS_SIZE,
48 void __init kirkwood_map_io(void)
50 iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
54 /*****************************************************************************
56 ****************************************************************************/
57 static struct orion_ehci_data kirkwood_ehci_data = {
58 .dram = &kirkwood_mbus_dram_info,
61 static u64 ehci_dmamask = 0xffffffffUL;
64 /*****************************************************************************
66 ****************************************************************************/
67 static struct resource kirkwood_ehci_resources[] = {
69 .start = USB_PHYS_BASE,
70 .end = USB_PHYS_BASE + 0x0fff,
71 .flags = IORESOURCE_MEM,
73 .start = IRQ_KIRKWOOD_USB,
74 .end = IRQ_KIRKWOOD_USB,
75 .flags = IORESOURCE_IRQ,
79 static struct platform_device kirkwood_ehci = {
83 .dma_mask = &ehci_dmamask,
84 .coherent_dma_mask = 0xffffffff,
85 .platform_data = &kirkwood_ehci_data,
87 .resource = kirkwood_ehci_resources,
88 .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
91 void __init kirkwood_ehci_init(void)
93 platform_device_register(&kirkwood_ehci);
97 /*****************************************************************************
99 ****************************************************************************/
100 struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
101 .dram = &kirkwood_mbus_dram_info,
104 static struct resource kirkwood_ge00_shared_resources[] = {
107 .start = GE00_PHYS_BASE + 0x2000,
108 .end = GE00_PHYS_BASE + 0x3fff,
109 .flags = IORESOURCE_MEM,
111 .name = "ge00 err irq",
112 .start = IRQ_KIRKWOOD_GE00_ERR,
113 .end = IRQ_KIRKWOOD_GE00_ERR,
114 .flags = IORESOURCE_IRQ,
118 static struct platform_device kirkwood_ge00_shared = {
119 .name = MV643XX_ETH_SHARED_NAME,
122 .platform_data = &kirkwood_ge00_shared_data,
124 .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
125 .resource = kirkwood_ge00_shared_resources,
128 static struct resource kirkwood_ge00_resources[] = {
131 .start = IRQ_KIRKWOOD_GE00_SUM,
132 .end = IRQ_KIRKWOOD_GE00_SUM,
133 .flags = IORESOURCE_IRQ,
137 static struct platform_device kirkwood_ge00 = {
138 .name = MV643XX_ETH_NAME,
141 .resource = kirkwood_ge00_resources,
144 void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
146 eth_data->shared = &kirkwood_ge00_shared;
147 kirkwood_ge00.dev.platform_data = eth_data;
149 platform_device_register(&kirkwood_ge00_shared);
150 platform_device_register(&kirkwood_ge00);
154 /*****************************************************************************
156 ****************************************************************************/
157 static struct resource kirkwood_rtc_resource = {
158 .start = RTC_PHYS_BASE,
159 .end = RTC_PHYS_BASE + SZ_16 - 1,
160 .flags = IORESOURCE_MEM,
163 void __init kirkwood_rtc_init(void)
165 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
169 /*****************************************************************************
171 ****************************************************************************/
172 static struct resource kirkwood_sata_resources[] = {
175 .start = SATA_PHYS_BASE,
176 .end = SATA_PHYS_BASE + 0x5000 - 1,
177 .flags = IORESOURCE_MEM,
180 .start = IRQ_KIRKWOOD_SATA,
181 .end = IRQ_KIRKWOOD_SATA,
182 .flags = IORESOURCE_IRQ,
186 static struct platform_device kirkwood_sata = {
190 .coherent_dma_mask = 0xffffffff,
192 .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
193 .resource = kirkwood_sata_resources,
196 void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
198 sata_data->dram = &kirkwood_mbus_dram_info;
199 kirkwood_sata.dev.platform_data = sata_data;
200 platform_device_register(&kirkwood_sata);
204 /*****************************************************************************
206 ****************************************************************************/
207 static struct orion_spi_info kirkwood_spi_plat_data = {
210 static struct resource kirkwood_spi_resources[] = {
212 .start = SPI_PHYS_BASE,
213 .end = SPI_PHYS_BASE + SZ_512 - 1,
214 .flags = IORESOURCE_MEM,
218 static struct platform_device kirkwood_spi = {
221 .resource = kirkwood_spi_resources,
223 .platform_data = &kirkwood_spi_plat_data,
225 .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
228 void __init kirkwood_spi_init()
230 platform_device_register(&kirkwood_spi);
234 /*****************************************************************************
236 ****************************************************************************/
237 static struct plat_serial8250_port kirkwood_uart0_data[] = {
239 .mapbase = UART0_PHYS_BASE,
240 .membase = (char *)UART0_VIRT_BASE,
241 .irq = IRQ_KIRKWOOD_UART_0,
242 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
250 static struct resource kirkwood_uart0_resources[] = {
252 .start = UART0_PHYS_BASE,
253 .end = UART0_PHYS_BASE + 0xff,
254 .flags = IORESOURCE_MEM,
256 .start = IRQ_KIRKWOOD_UART_0,
257 .end = IRQ_KIRKWOOD_UART_0,
258 .flags = IORESOURCE_IRQ,
262 static struct platform_device kirkwood_uart0 = {
263 .name = "serial8250",
266 .platform_data = kirkwood_uart0_data,
268 .resource = kirkwood_uart0_resources,
269 .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
272 void __init kirkwood_uart0_init(void)
274 platform_device_register(&kirkwood_uart0);
278 /*****************************************************************************
280 ****************************************************************************/
281 static struct plat_serial8250_port kirkwood_uart1_data[] = {
283 .mapbase = UART1_PHYS_BASE,
284 .membase = (char *)UART1_VIRT_BASE,
285 .irq = IRQ_KIRKWOOD_UART_1,
286 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
294 static struct resource kirkwood_uart1_resources[] = {
296 .start = UART1_PHYS_BASE,
297 .end = UART1_PHYS_BASE + 0xff,
298 .flags = IORESOURCE_MEM,
300 .start = IRQ_KIRKWOOD_UART_1,
301 .end = IRQ_KIRKWOOD_UART_1,
302 .flags = IORESOURCE_IRQ,
306 static struct platform_device kirkwood_uart1 = {
307 .name = "serial8250",
310 .platform_data = kirkwood_uart1_data,
312 .resource = kirkwood_uart1_resources,
313 .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
316 void __init kirkwood_uart1_init(void)
318 platform_device_register(&kirkwood_uart1);
322 /*****************************************************************************
324 ****************************************************************************/
325 static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
326 .dram = &kirkwood_mbus_dram_info,
329 static u64 kirkwood_xor_dmamask = DMA_32BIT_MASK;
332 /*****************************************************************************
334 ****************************************************************************/
335 static struct resource kirkwood_xor0_shared_resources[] = {
338 .start = XOR0_PHYS_BASE,
339 .end = XOR0_PHYS_BASE + 0xff,
340 .flags = IORESOURCE_MEM,
342 .name = "xor 0 high",
343 .start = XOR0_HIGH_PHYS_BASE,
344 .end = XOR0_HIGH_PHYS_BASE + 0xff,
345 .flags = IORESOURCE_MEM,
349 static struct platform_device kirkwood_xor0_shared = {
350 .name = MV_XOR_SHARED_NAME,
353 .platform_data = &kirkwood_xor_shared_data,
355 .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
356 .resource = kirkwood_xor0_shared_resources,
359 static struct resource kirkwood_xor00_resources[] = {
361 .start = IRQ_KIRKWOOD_XOR_00,
362 .end = IRQ_KIRKWOOD_XOR_00,
363 .flags = IORESOURCE_IRQ,
367 static struct mv_xor_platform_data kirkwood_xor00_data = {
368 .shared = &kirkwood_xor0_shared,
370 .pool_size = PAGE_SIZE,
373 static struct platform_device kirkwood_xor00_channel = {
376 .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
377 .resource = kirkwood_xor00_resources,
379 .dma_mask = &kirkwood_xor_dmamask,
380 .coherent_dma_mask = DMA_64BIT_MASK,
381 .platform_data = (void *)&kirkwood_xor00_data,
385 static struct resource kirkwood_xor01_resources[] = {
387 .start = IRQ_KIRKWOOD_XOR_01,
388 .end = IRQ_KIRKWOOD_XOR_01,
389 .flags = IORESOURCE_IRQ,
393 static struct mv_xor_platform_data kirkwood_xor01_data = {
394 .shared = &kirkwood_xor0_shared,
396 .pool_size = PAGE_SIZE,
399 static struct platform_device kirkwood_xor01_channel = {
402 .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
403 .resource = kirkwood_xor01_resources,
405 .dma_mask = &kirkwood_xor_dmamask,
406 .coherent_dma_mask = DMA_64BIT_MASK,
407 .platform_data = (void *)&kirkwood_xor01_data,
411 void __init kirkwood_xor0_init(void)
413 platform_device_register(&kirkwood_xor0_shared);
416 * two engines can't do memset simultaneously, this limitation
417 * satisfied by removing memset support from one of the engines.
419 dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
420 dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
421 platform_device_register(&kirkwood_xor00_channel);
423 dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
424 dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
425 dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
426 platform_device_register(&kirkwood_xor01_channel);
430 /*****************************************************************************
432 ****************************************************************************/
433 static struct resource kirkwood_xor1_shared_resources[] = {
436 .start = XOR1_PHYS_BASE,
437 .end = XOR1_PHYS_BASE + 0xff,
438 .flags = IORESOURCE_MEM,
440 .name = "xor 1 high",
441 .start = XOR1_HIGH_PHYS_BASE,
442 .end = XOR1_HIGH_PHYS_BASE + 0xff,
443 .flags = IORESOURCE_MEM,
447 static struct platform_device kirkwood_xor1_shared = {
448 .name = MV_XOR_SHARED_NAME,
451 .platform_data = &kirkwood_xor_shared_data,
453 .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
454 .resource = kirkwood_xor1_shared_resources,
457 static struct resource kirkwood_xor10_resources[] = {
459 .start = IRQ_KIRKWOOD_XOR_10,
460 .end = IRQ_KIRKWOOD_XOR_10,
461 .flags = IORESOURCE_IRQ,
465 static struct mv_xor_platform_data kirkwood_xor10_data = {
466 .shared = &kirkwood_xor1_shared,
468 .pool_size = PAGE_SIZE,
471 static struct platform_device kirkwood_xor10_channel = {
474 .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
475 .resource = kirkwood_xor10_resources,
477 .dma_mask = &kirkwood_xor_dmamask,
478 .coherent_dma_mask = DMA_64BIT_MASK,
479 .platform_data = (void *)&kirkwood_xor10_data,
483 static struct resource kirkwood_xor11_resources[] = {
485 .start = IRQ_KIRKWOOD_XOR_11,
486 .end = IRQ_KIRKWOOD_XOR_11,
487 .flags = IORESOURCE_IRQ,
491 static struct mv_xor_platform_data kirkwood_xor11_data = {
492 .shared = &kirkwood_xor1_shared,
494 .pool_size = PAGE_SIZE,
497 static struct platform_device kirkwood_xor11_channel = {
500 .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
501 .resource = kirkwood_xor11_resources,
503 .dma_mask = &kirkwood_xor_dmamask,
504 .coherent_dma_mask = DMA_64BIT_MASK,
505 .platform_data = (void *)&kirkwood_xor11_data,
509 void __init kirkwood_xor1_init(void)
511 platform_device_register(&kirkwood_xor1_shared);
514 * two engines can't do memset simultaneously, this limitation
515 * satisfied by removing memset support from one of the engines.
517 dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
518 dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
519 platform_device_register(&kirkwood_xor10_channel);
521 dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
522 dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
523 dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
524 platform_device_register(&kirkwood_xor11_channel);
528 /*****************************************************************************
530 ****************************************************************************/
533 int __init kirkwood_find_tclk(void)
537 kirkwood_pcie_id(&dev, &rev);
538 if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
544 static void kirkwood_timer_init(void)
546 kirkwood_tclk = kirkwood_find_tclk();
547 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
550 struct sys_timer kirkwood_timer = {
551 .init = kirkwood_timer_init,
555 /*****************************************************************************
557 ****************************************************************************/
559 * Identify device ID and revision.
561 static char * __init kirkwood_id(void)
565 kirkwood_pcie_id(&dev, &rev);
567 if (dev == MV88F6281_DEV_ID) {
568 if (rev == MV88F6281_REV_Z0)
569 return "MV88F6281-Z0";
570 else if (rev == MV88F6281_REV_A0)
571 return "MV88F6281-A0";
573 return "MV88F6281-Rev-Unsupported";
574 } else if (dev == MV88F6192_DEV_ID) {
575 if (rev == MV88F6192_REV_Z0)
576 return "MV88F6192-Z0";
577 else if (rev == MV88F6192_REV_A0)
578 return "MV88F6192-A0";
580 return "MV88F6192-Rev-Unsupported";
581 } else if (dev == MV88F6180_DEV_ID) {
582 if (rev == MV88F6180_REV_A0)
583 return "MV88F6180-Rev-A0";
585 return "MV88F6180-Rev-Unsupported";
587 return "Device-Unknown";
591 static void __init kirkwood_l2_init(void)
593 #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
594 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
597 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
602 void __init kirkwood_init(void)
604 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
605 kirkwood_id(), kirkwood_tclk);
606 kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
607 kirkwood_spi_plat_data.tclk = kirkwood_tclk;
608 kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
609 kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
611 kirkwood_setup_cpu_mbus();
613 #ifdef CONFIG_CACHE_FEROCEON_L2