2 * arch/arm/mach-orion5x/common.c
4 * Core functions for Marvell Orion 5x SoCs
6 * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/serial_8250.h>
17 #include <linux/mbus.h>
18 #include <linux/mv643xx_eth.h>
19 #include <linux/mv643xx_i2c.h>
20 #include <linux/ata_platform.h>
22 #include <asm/setup.h>
23 #include <asm/timex.h>
24 #include <asm/mach/arch.h>
25 #include <asm/mach/map.h>
26 #include <asm/mach/time.h>
27 #include <mach/hardware.h>
28 #include <mach/orion5x.h>
29 #include <plat/ehci-orion.h>
30 #include <plat/mv_xor.h>
31 #include <plat/orion_nand.h>
32 #include <plat/time.h>
35 /*****************************************************************************
37 ****************************************************************************/
38 static struct map_desc orion5x_io_desc[] __initdata = {
40 .virtual = ORION5X_REGS_VIRT_BASE,
41 .pfn = __phys_to_pfn(ORION5X_REGS_PHYS_BASE),
42 .length = ORION5X_REGS_SIZE,
45 .virtual = ORION5X_PCIE_IO_VIRT_BASE,
46 .pfn = __phys_to_pfn(ORION5X_PCIE_IO_PHYS_BASE),
47 .length = ORION5X_PCIE_IO_SIZE,
50 .virtual = ORION5X_PCI_IO_VIRT_BASE,
51 .pfn = __phys_to_pfn(ORION5X_PCI_IO_PHYS_BASE),
52 .length = ORION5X_PCI_IO_SIZE,
55 .virtual = ORION5X_PCIE_WA_VIRT_BASE,
56 .pfn = __phys_to_pfn(ORION5X_PCIE_WA_PHYS_BASE),
57 .length = ORION5X_PCIE_WA_SIZE,
62 void __init orion5x_map_io(void)
64 iotable_init(orion5x_io_desc, ARRAY_SIZE(orion5x_io_desc));
68 /*****************************************************************************
70 ****************************************************************************/
71 static struct orion_ehci_data orion5x_ehci_data = {
72 .dram = &orion5x_mbus_dram_info,
75 static u64 ehci_dmamask = 0xffffffffUL;
78 /*****************************************************************************
80 ****************************************************************************/
81 static struct resource orion5x_ehci0_resources[] = {
83 .start = ORION5X_USB0_PHYS_BASE,
84 .end = ORION5X_USB0_PHYS_BASE + SZ_4K - 1,
85 .flags = IORESOURCE_MEM,
87 .start = IRQ_ORION5X_USB0_CTRL,
88 .end = IRQ_ORION5X_USB0_CTRL,
89 .flags = IORESOURCE_IRQ,
93 static struct platform_device orion5x_ehci0 = {
97 .dma_mask = &ehci_dmamask,
98 .coherent_dma_mask = 0xffffffff,
99 .platform_data = &orion5x_ehci_data,
101 .resource = orion5x_ehci0_resources,
102 .num_resources = ARRAY_SIZE(orion5x_ehci0_resources),
105 void __init orion5x_ehci0_init(void)
107 platform_device_register(&orion5x_ehci0);
111 /*****************************************************************************
113 ****************************************************************************/
114 static struct resource orion5x_ehci1_resources[] = {
116 .start = ORION5X_USB1_PHYS_BASE,
117 .end = ORION5X_USB1_PHYS_BASE + SZ_4K - 1,
118 .flags = IORESOURCE_MEM,
120 .start = IRQ_ORION5X_USB1_CTRL,
121 .end = IRQ_ORION5X_USB1_CTRL,
122 .flags = IORESOURCE_IRQ,
126 static struct platform_device orion5x_ehci1 = {
127 .name = "orion-ehci",
130 .dma_mask = &ehci_dmamask,
131 .coherent_dma_mask = 0xffffffff,
132 .platform_data = &orion5x_ehci_data,
134 .resource = orion5x_ehci1_resources,
135 .num_resources = ARRAY_SIZE(orion5x_ehci1_resources),
138 void __init orion5x_ehci1_init(void)
140 platform_device_register(&orion5x_ehci1);
144 /*****************************************************************************
146 ****************************************************************************/
147 struct mv643xx_eth_shared_platform_data orion5x_eth_shared_data = {
148 .dram = &orion5x_mbus_dram_info,
149 .t_clk = ORION5X_TCLK,
152 static struct resource orion5x_eth_shared_resources[] = {
154 .start = ORION5X_ETH_PHYS_BASE + 0x2000,
155 .end = ORION5X_ETH_PHYS_BASE + 0x3fff,
156 .flags = IORESOURCE_MEM,
160 static struct platform_device orion5x_eth_shared = {
161 .name = MV643XX_ETH_SHARED_NAME,
164 .platform_data = &orion5x_eth_shared_data,
167 .resource = orion5x_eth_shared_resources,
170 static struct resource orion5x_eth_resources[] = {
173 .start = IRQ_ORION5X_ETH_SUM,
174 .end = IRQ_ORION5X_ETH_SUM,
175 .flags = IORESOURCE_IRQ,
179 static struct platform_device orion5x_eth = {
180 .name = MV643XX_ETH_NAME,
183 .resource = orion5x_eth_resources,
186 void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data)
188 eth_data->shared = &orion5x_eth_shared;
189 orion5x_eth.dev.platform_data = eth_data;
191 platform_device_register(&orion5x_eth_shared);
192 platform_device_register(&orion5x_eth);
196 /*****************************************************************************
198 ****************************************************************************/
199 static struct mv64xxx_i2c_pdata orion5x_i2c_pdata = {
200 .freq_m = 8, /* assumes 166 MHz TCLK */
202 .timeout = 1000, /* Default timeout of 1 second */
205 static struct resource orion5x_i2c_resources[] = {
208 .start = I2C_PHYS_BASE,
209 .end = I2C_PHYS_BASE + 0x1f,
210 .flags = IORESOURCE_MEM,
213 .start = IRQ_ORION5X_I2C,
214 .end = IRQ_ORION5X_I2C,
215 .flags = IORESOURCE_IRQ,
219 static struct platform_device orion5x_i2c = {
220 .name = MV64XXX_I2C_CTLR_NAME,
222 .num_resources = ARRAY_SIZE(orion5x_i2c_resources),
223 .resource = orion5x_i2c_resources,
225 .platform_data = &orion5x_i2c_pdata,
229 void __init orion5x_i2c_init(void)
231 platform_device_register(&orion5x_i2c);
235 /*****************************************************************************
237 ****************************************************************************/
238 static struct resource orion5x_sata_resources[] = {
241 .start = ORION5X_SATA_PHYS_BASE,
242 .end = ORION5X_SATA_PHYS_BASE + 0x5000 - 1,
243 .flags = IORESOURCE_MEM,
246 .start = IRQ_ORION5X_SATA,
247 .end = IRQ_ORION5X_SATA,
248 .flags = IORESOURCE_IRQ,
252 static struct platform_device orion5x_sata = {
256 .coherent_dma_mask = 0xffffffff,
258 .num_resources = ARRAY_SIZE(orion5x_sata_resources),
259 .resource = orion5x_sata_resources,
262 void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data)
264 sata_data->dram = &orion5x_mbus_dram_info;
265 orion5x_sata.dev.platform_data = sata_data;
266 platform_device_register(&orion5x_sata);
270 /*****************************************************************************
272 ****************************************************************************/
273 static struct plat_serial8250_port orion5x_uart0_data[] = {
275 .mapbase = UART0_PHYS_BASE,
276 .membase = (char *)UART0_VIRT_BASE,
277 .irq = IRQ_ORION5X_UART0,
278 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
281 .uartclk = ORION5X_TCLK,
286 static struct resource orion5x_uart0_resources[] = {
288 .start = UART0_PHYS_BASE,
289 .end = UART0_PHYS_BASE + 0xff,
290 .flags = IORESOURCE_MEM,
292 .start = IRQ_ORION5X_UART0,
293 .end = IRQ_ORION5X_UART0,
294 .flags = IORESOURCE_IRQ,
298 static struct platform_device orion5x_uart0 = {
299 .name = "serial8250",
300 .id = PLAT8250_DEV_PLATFORM,
302 .platform_data = orion5x_uart0_data,
304 .resource = orion5x_uart0_resources,
305 .num_resources = ARRAY_SIZE(orion5x_uart0_resources),
308 void __init orion5x_uart0_init(void)
310 platform_device_register(&orion5x_uart0);
314 /*****************************************************************************
316 ****************************************************************************/
317 static struct plat_serial8250_port orion5x_uart1_data[] = {
319 .mapbase = UART1_PHYS_BASE,
320 .membase = (char *)UART1_VIRT_BASE,
321 .irq = IRQ_ORION5X_UART1,
322 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
325 .uartclk = ORION5X_TCLK,
330 static struct resource orion5x_uart1_resources[] = {
332 .start = UART1_PHYS_BASE,
333 .end = UART1_PHYS_BASE + 0xff,
334 .flags = IORESOURCE_MEM,
336 .start = IRQ_ORION5X_UART1,
337 .end = IRQ_ORION5X_UART1,
338 .flags = IORESOURCE_IRQ,
342 static struct platform_device orion5x_uart1 = {
343 .name = "serial8250",
344 .id = PLAT8250_DEV_PLATFORM1,
346 .platform_data = orion5x_uart1_data,
348 .resource = orion5x_uart1_resources,
349 .num_resources = ARRAY_SIZE(orion5x_uart1_resources),
352 void __init orion5x_uart1_init(void)
354 platform_device_register(&orion5x_uart1);
358 /*****************************************************************************
360 ****************************************************************************/
361 static struct resource orion5x_xor_shared_resources[] = {
364 .start = ORION5X_XOR_PHYS_BASE,
365 .end = ORION5X_XOR_PHYS_BASE + 0xff,
366 .flags = IORESOURCE_MEM,
369 .start = ORION5X_XOR_PHYS_BASE + 0x200,
370 .end = ORION5X_XOR_PHYS_BASE + 0x2ff,
371 .flags = IORESOURCE_MEM,
375 static struct platform_device orion5x_xor_shared = {
376 .name = MV_XOR_SHARED_NAME,
378 .num_resources = ARRAY_SIZE(orion5x_xor_shared_resources),
379 .resource = orion5x_xor_shared_resources,
382 static u64 orion5x_xor_dmamask = DMA_32BIT_MASK;
384 static struct resource orion5x_xor0_resources[] = {
386 .start = IRQ_ORION5X_XOR0,
387 .end = IRQ_ORION5X_XOR0,
388 .flags = IORESOURCE_IRQ,
392 static struct mv_xor_platform_data orion5x_xor0_data = {
393 .shared = &orion5x_xor_shared,
395 .pool_size = PAGE_SIZE,
398 static struct platform_device orion5x_xor0_channel = {
401 .num_resources = ARRAY_SIZE(orion5x_xor0_resources),
402 .resource = orion5x_xor0_resources,
404 .dma_mask = &orion5x_xor_dmamask,
405 .coherent_dma_mask = DMA_64BIT_MASK,
406 .platform_data = (void *)&orion5x_xor0_data,
410 static struct resource orion5x_xor1_resources[] = {
412 .start = IRQ_ORION5X_XOR1,
413 .end = IRQ_ORION5X_XOR1,
414 .flags = IORESOURCE_IRQ,
418 static struct mv_xor_platform_data orion5x_xor1_data = {
419 .shared = &orion5x_xor_shared,
421 .pool_size = PAGE_SIZE,
424 static struct platform_device orion5x_xor1_channel = {
427 .num_resources = ARRAY_SIZE(orion5x_xor1_resources),
428 .resource = orion5x_xor1_resources,
430 .dma_mask = &orion5x_xor_dmamask,
431 .coherent_dma_mask = DMA_64BIT_MASK,
432 .platform_data = (void *)&orion5x_xor1_data,
436 void __init orion5x_xor_init(void)
438 platform_device_register(&orion5x_xor_shared);
441 * two engines can't do memset simultaneously, this limitation
442 * satisfied by removing memset support from one of the engines.
444 dma_cap_set(DMA_MEMCPY, orion5x_xor0_data.cap_mask);
445 dma_cap_set(DMA_XOR, orion5x_xor0_data.cap_mask);
446 platform_device_register(&orion5x_xor0_channel);
448 dma_cap_set(DMA_MEMCPY, orion5x_xor1_data.cap_mask);
449 dma_cap_set(DMA_MEMSET, orion5x_xor1_data.cap_mask);
450 dma_cap_set(DMA_XOR, orion5x_xor1_data.cap_mask);
451 platform_device_register(&orion5x_xor1_channel);
455 /*****************************************************************************
457 ****************************************************************************/
458 static void orion5x_timer_init(void)
460 orion_time_init(IRQ_ORION5X_BRIDGE, ORION5X_TCLK);
463 struct sys_timer orion5x_timer = {
464 .init = orion5x_timer_init,
468 /*****************************************************************************
470 ****************************************************************************/
472 * Identify device ID and rev from PCIe configuration header space '0'.
474 static void __init orion5x_id(u32 *dev, u32 *rev, char **dev_name)
476 orion5x_pcie_id(dev, rev);
478 if (*dev == MV88F5281_DEV_ID) {
479 if (*rev == MV88F5281_REV_D2) {
480 *dev_name = "MV88F5281-D2";
481 } else if (*rev == MV88F5281_REV_D1) {
482 *dev_name = "MV88F5281-D1";
483 } else if (*rev == MV88F5281_REV_D0) {
484 *dev_name = "MV88F5281-D0";
486 *dev_name = "MV88F5281-Rev-Unsupported";
488 } else if (*dev == MV88F5182_DEV_ID) {
489 if (*rev == MV88F5182_REV_A2) {
490 *dev_name = "MV88F5182-A2";
492 *dev_name = "MV88F5182-Rev-Unsupported";
494 } else if (*dev == MV88F5181_DEV_ID) {
495 if (*rev == MV88F5181_REV_B1) {
496 *dev_name = "MV88F5181-Rev-B1";
497 } else if (*rev == MV88F5181L_REV_A1) {
498 *dev_name = "MV88F5181L-Rev-A1";
500 *dev_name = "MV88F5181(L)-Rev-Unsupported";
503 *dev_name = "Device-Unknown";
507 void __init orion5x_init(void)
512 orion5x_id(&dev, &rev, &dev_name);
513 printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, ORION5X_TCLK);
516 * Setup Orion address map
518 orion5x_setup_cpu_mbus_bridge();
521 * Don't issue "Wait for Interrupt" instruction if we are
522 * running on D0 5281 silicon.
524 if (dev == MV88F5281_DEV_ID && rev == MV88F5281_REV_D0) {
525 printk(KERN_INFO "Orion: Applying 5281 D0 WFI workaround.\n");
531 * Many orion-based systems have buggy bootloader implementations.
532 * This is a common fixup for bogus memory tags.
534 void __init tag_fixup_mem32(struct machine_desc *mdesc, struct tag *t,
535 char **from, struct meminfo *meminfo)
537 for (; t->hdr.size; t = tag_next(t))
538 if (t->hdr.tag == ATAG_MEM &&
539 (!t->u.mem.size || t->u.mem.size & ~PAGE_MASK ||
540 t->u.mem.start & ~PAGE_MASK)) {
542 "Clearing invalid memory bank %dKB@0x%08x\n",
543 t->u.mem.size / 1024, t->u.mem.start);