blob: 19b03f62c3f40e4d5047ad7278036d8e67c0a2db [file] [log] [blame]
Saeed Bishara651c74c2008-06-22 22:45:06 +02001/*
2 * arch/arm/mach-kirkwood/common.c
3 *
4 * Core functions for Marvell Kirkwood SoCs
5 *
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 */
10
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>
Martin Michlmayr6574e002009-03-23 19:13:21 +010017#include <linux/mv643xx_i2c.h>
Saeed Bishara651c74c2008-06-22 22:45:06 +020018#include <linux/ata_platform.h>
Lennert Buytenhek18365d12008-08-09 15:38:18 +020019#include <linux/spi/orion_spi.h>
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +020020#include <net/dsa.h>
Saeed Bishara651c74c2008-06-22 22:45:06 +020021#include <asm/page.h>
22#include <asm/timex.h>
23#include <asm/mach/map.h>
24#include <asm/mach/time.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/kirkwood.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020026#include <plat/cache-feroceon-l2.h>
27#include <plat/ehci-orion.h>
Nicolas Pitre8235ee02009-02-14 03:15:55 -050028#include <plat/mvsdio.h>
Saeed Bishara09c0ed22008-06-23 04:26:07 -110029#include <plat/mv_xor.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020030#include <plat/orion_nand.h>
31#include <plat/time.h>
Saeed Bishara651c74c2008-06-22 22:45:06 +020032#include "common.h"
33
34/*****************************************************************************
35 * I/O Address Mapping
36 ****************************************************************************/
37static struct map_desc kirkwood_io_desc[] __initdata = {
38 {
39 .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE,
40 .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE),
41 .length = KIRKWOOD_PCIE_IO_SIZE,
42 .type = MT_DEVICE,
43 }, {
44 .virtual = KIRKWOOD_REGS_VIRT_BASE,
45 .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
46 .length = KIRKWOOD_REGS_SIZE,
47 .type = MT_DEVICE,
48 },
49};
50
51void __init kirkwood_map_io(void)
52{
53 iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
54}
55
56
57/*****************************************************************************
58 * EHCI
59 ****************************************************************************/
60static struct orion_ehci_data kirkwood_ehci_data = {
61 .dram = &kirkwood_mbus_dram_info,
Ronen Shitritfb6f5522008-09-17 10:08:05 +030062 .phy_version = EHCI_PHY_NA,
Saeed Bishara651c74c2008-06-22 22:45:06 +020063};
64
65static u64 ehci_dmamask = 0xffffffffUL;
66
67
68/*****************************************************************************
69 * EHCI0
70 ****************************************************************************/
71static struct resource kirkwood_ehci_resources[] = {
72 {
73 .start = USB_PHYS_BASE,
74 .end = USB_PHYS_BASE + 0x0fff,
75 .flags = IORESOURCE_MEM,
76 }, {
77 .start = IRQ_KIRKWOOD_USB,
78 .end = IRQ_KIRKWOOD_USB,
79 .flags = IORESOURCE_IRQ,
80 },
81};
82
83static struct platform_device kirkwood_ehci = {
84 .name = "orion-ehci",
85 .id = 0,
86 .dev = {
87 .dma_mask = &ehci_dmamask,
88 .coherent_dma_mask = 0xffffffff,
89 .platform_data = &kirkwood_ehci_data,
90 },
91 .resource = kirkwood_ehci_resources,
92 .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
93};
94
95void __init kirkwood_ehci_init(void)
96{
97 platform_device_register(&kirkwood_ehci);
98}
99
100
101/*****************************************************************************
102 * GE00
103 ****************************************************************************/
104struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
Saeed Bishara651c74c2008-06-22 22:45:06 +0200105 .dram = &kirkwood_mbus_dram_info,
106};
107
108static struct resource kirkwood_ge00_shared_resources[] = {
109 {
110 .name = "ge00 base",
111 .start = GE00_PHYS_BASE + 0x2000,
112 .end = GE00_PHYS_BASE + 0x3fff,
113 .flags = IORESOURCE_MEM,
Lennert Buytenhek144f8142008-08-26 16:04:05 +0200114 }, {
115 .name = "ge00 err irq",
116 .start = IRQ_KIRKWOOD_GE00_ERR,
117 .end = IRQ_KIRKWOOD_GE00_ERR,
118 .flags = IORESOURCE_IRQ,
Saeed Bishara651c74c2008-06-22 22:45:06 +0200119 },
120};
121
122static struct platform_device kirkwood_ge00_shared = {
123 .name = MV643XX_ETH_SHARED_NAME,
124 .id = 0,
125 .dev = {
126 .platform_data = &kirkwood_ge00_shared_data,
127 },
Lennert Buytenhek144f8142008-08-26 16:04:05 +0200128 .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
Saeed Bishara651c74c2008-06-22 22:45:06 +0200129 .resource = kirkwood_ge00_shared_resources,
130};
131
132static struct resource kirkwood_ge00_resources[] = {
133 {
134 .name = "ge00 irq",
135 .start = IRQ_KIRKWOOD_GE00_SUM,
136 .end = IRQ_KIRKWOOD_GE00_SUM,
137 .flags = IORESOURCE_IRQ,
138 },
139};
140
141static struct platform_device kirkwood_ge00 = {
142 .name = MV643XX_ETH_NAME,
143 .id = 0,
144 .num_resources = 1,
145 .resource = kirkwood_ge00_resources,
146};
147
148void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
149{
150 eth_data->shared = &kirkwood_ge00_shared;
151 kirkwood_ge00.dev.platform_data = eth_data;
152
153 platform_device_register(&kirkwood_ge00_shared);
154 platform_device_register(&kirkwood_ge00);
155}
156
157
158/*****************************************************************************
Ronen Shitritd15fb9e2008-10-19 23:10:14 +0200159 * GE01
160 ****************************************************************************/
161struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data = {
162 .dram = &kirkwood_mbus_dram_info,
163 .shared_smi = &kirkwood_ge00_shared,
164};
165
166static struct resource kirkwood_ge01_shared_resources[] = {
167 {
168 .name = "ge01 base",
169 .start = GE01_PHYS_BASE + 0x2000,
170 .end = GE01_PHYS_BASE + 0x3fff,
171 .flags = IORESOURCE_MEM,
172 }, {
173 .name = "ge01 err irq",
174 .start = IRQ_KIRKWOOD_GE01_ERR,
175 .end = IRQ_KIRKWOOD_GE01_ERR,
176 .flags = IORESOURCE_IRQ,
177 },
178};
179
180static struct platform_device kirkwood_ge01_shared = {
181 .name = MV643XX_ETH_SHARED_NAME,
182 .id = 1,
183 .dev = {
184 .platform_data = &kirkwood_ge01_shared_data,
185 },
186 .num_resources = ARRAY_SIZE(kirkwood_ge01_shared_resources),
187 .resource = kirkwood_ge01_shared_resources,
188};
189
190static struct resource kirkwood_ge01_resources[] = {
191 {
192 .name = "ge01 irq",
193 .start = IRQ_KIRKWOOD_GE01_SUM,
194 .end = IRQ_KIRKWOOD_GE01_SUM,
195 .flags = IORESOURCE_IRQ,
196 },
197};
198
199static struct platform_device kirkwood_ge01 = {
200 .name = MV643XX_ETH_NAME,
201 .id = 1,
202 .num_resources = 1,
203 .resource = kirkwood_ge01_resources,
204};
205
206void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
207{
208 eth_data->shared = &kirkwood_ge01_shared;
209 kirkwood_ge01.dev.platform_data = eth_data;
210
211 platform_device_register(&kirkwood_ge01_shared);
212 platform_device_register(&kirkwood_ge01);
213}
214
215
216/*****************************************************************************
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200217 * Ethernet switch
218 ****************************************************************************/
219static struct resource kirkwood_switch_resources[] = {
220 {
221 .start = 0,
222 .end = 0,
223 .flags = IORESOURCE_IRQ,
224 },
225};
226
227static struct platform_device kirkwood_switch_device = {
228 .name = "dsa",
229 .id = 0,
230 .num_resources = 0,
231 .resource = kirkwood_switch_resources,
232};
233
234void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
235{
236 if (irq != NO_IRQ) {
237 kirkwood_switch_resources[0].start = irq;
238 kirkwood_switch_resources[0].end = irq;
239 kirkwood_switch_device.num_resources = 1;
240 }
241
242 d->mii_bus = &kirkwood_ge00_shared.dev;
243 d->netdev = &kirkwood_ge00.dev;
244 kirkwood_switch_device.dev.platform_data = d;
245
246 platform_device_register(&kirkwood_switch_device);
247}
248
249
250/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200251 * SoC RTC
252 ****************************************************************************/
253static struct resource kirkwood_rtc_resource = {
254 .start = RTC_PHYS_BASE,
255 .end = RTC_PHYS_BASE + SZ_16 - 1,
256 .flags = IORESOURCE_MEM,
257};
258
Nicolas Pitre5b99d532009-02-26 22:55:59 -0500259static void __init kirkwood_rtc_init(void)
Saeed Bishara651c74c2008-06-22 22:45:06 +0200260{
261 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
262}
263
264
265/*****************************************************************************
266 * SATA
267 ****************************************************************************/
268static struct resource kirkwood_sata_resources[] = {
269 {
270 .name = "sata base",
271 .start = SATA_PHYS_BASE,
272 .end = SATA_PHYS_BASE + 0x5000 - 1,
273 .flags = IORESOURCE_MEM,
274 }, {
275 .name = "sata irq",
276 .start = IRQ_KIRKWOOD_SATA,
277 .end = IRQ_KIRKWOOD_SATA,
278 .flags = IORESOURCE_IRQ,
279 },
280};
281
282static struct platform_device kirkwood_sata = {
283 .name = "sata_mv",
284 .id = 0,
285 .dev = {
286 .coherent_dma_mask = 0xffffffff,
287 },
288 .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
289 .resource = kirkwood_sata_resources,
290};
291
292void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
293{
294 sata_data->dram = &kirkwood_mbus_dram_info;
295 kirkwood_sata.dev.platform_data = sata_data;
296 platform_device_register(&kirkwood_sata);
297}
298
299
300/*****************************************************************************
Nicolas Pitre8235ee02009-02-14 03:15:55 -0500301 * SD/SDIO/MMC
302 ****************************************************************************/
303static struct resource mvsdio_resources[] = {
304 [0] = {
305 .start = SDIO_PHYS_BASE,
306 .end = SDIO_PHYS_BASE + SZ_1K - 1,
307 .flags = IORESOURCE_MEM,
308 },
309 [1] = {
310 .start = IRQ_KIRKWOOD_SDIO,
311 .end = IRQ_KIRKWOOD_SDIO,
312 .flags = IORESOURCE_IRQ,
313 },
314};
315
316static u64 mvsdio_dmamask = 0xffffffffUL;
317
318static struct platform_device kirkwood_sdio = {
319 .name = "mvsdio",
320 .id = -1,
321 .dev = {
322 .dma_mask = &mvsdio_dmamask,
323 .coherent_dma_mask = 0xffffffff,
324 },
325 .num_resources = ARRAY_SIZE(mvsdio_resources),
326 .resource = mvsdio_resources,
327};
328
329void __init kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data)
330{
331 u32 dev, rev;
332
333 kirkwood_pcie_id(&dev, &rev);
334 if (rev == 0) /* catch all Kirkwood Z0's */
335 mvsdio_data->clock = 100000000;
336 else
337 mvsdio_data->clock = 200000000;
338 mvsdio_data->dram = &kirkwood_mbus_dram_info;
339 kirkwood_sdio.dev.platform_data = mvsdio_data;
340 platform_device_register(&kirkwood_sdio);
341}
342
343
344/*****************************************************************************
Lennert Buytenhek18365d12008-08-09 15:38:18 +0200345 * SPI
346 ****************************************************************************/
347static struct orion_spi_info kirkwood_spi_plat_data = {
Lennert Buytenhek18365d12008-08-09 15:38:18 +0200348};
349
350static struct resource kirkwood_spi_resources[] = {
351 {
352 .start = SPI_PHYS_BASE,
353 .end = SPI_PHYS_BASE + SZ_512 - 1,
354 .flags = IORESOURCE_MEM,
355 },
356};
357
358static struct platform_device kirkwood_spi = {
359 .name = "orion_spi",
360 .id = 0,
361 .resource = kirkwood_spi_resources,
362 .dev = {
363 .platform_data = &kirkwood_spi_plat_data,
364 },
365 .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
366};
367
368void __init kirkwood_spi_init()
369{
370 platform_device_register(&kirkwood_spi);
371}
372
373
374/*****************************************************************************
Martin Michlmayr6574e002009-03-23 19:13:21 +0100375 * I2C
376 ****************************************************************************/
377static struct mv64xxx_i2c_pdata kirkwood_i2c_pdata = {
378 .freq_m = 8, /* assumes 166 MHz TCLK */
379 .freq_n = 3,
380 .timeout = 1000, /* Default timeout of 1 second */
381};
382
383static struct resource kirkwood_i2c_resources[] = {
384 {
385 .name = "i2c",
386 .start = I2C_PHYS_BASE,
387 .end = I2C_PHYS_BASE + 0x1f,
388 .flags = IORESOURCE_MEM,
389 }, {
390 .name = "i2c",
391 .start = IRQ_KIRKWOOD_TWSI,
392 .end = IRQ_KIRKWOOD_TWSI,
393 .flags = IORESOURCE_IRQ,
394 },
395};
396
397static struct platform_device kirkwood_i2c = {
398 .name = MV64XXX_I2C_CTLR_NAME,
399 .id = 0,
400 .num_resources = ARRAY_SIZE(kirkwood_i2c_resources),
401 .resource = kirkwood_i2c_resources,
402 .dev = {
403 .platform_data = &kirkwood_i2c_pdata,
404 },
405};
406
407void __init kirkwood_i2c_init(void)
408{
409 platform_device_register(&kirkwood_i2c);
410}
411
412
413/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200414 * UART0
415 ****************************************************************************/
416static struct plat_serial8250_port kirkwood_uart0_data[] = {
417 {
418 .mapbase = UART0_PHYS_BASE,
419 .membase = (char *)UART0_VIRT_BASE,
420 .irq = IRQ_KIRKWOOD_UART_0,
421 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
422 .iotype = UPIO_MEM,
423 .regshift = 2,
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200424 .uartclk = 0,
Saeed Bishara651c74c2008-06-22 22:45:06 +0200425 }, {
426 },
427};
428
429static struct resource kirkwood_uart0_resources[] = {
430 {
431 .start = UART0_PHYS_BASE,
432 .end = UART0_PHYS_BASE + 0xff,
433 .flags = IORESOURCE_MEM,
434 }, {
435 .start = IRQ_KIRKWOOD_UART_0,
436 .end = IRQ_KIRKWOOD_UART_0,
437 .flags = IORESOURCE_IRQ,
438 },
439};
440
441static struct platform_device kirkwood_uart0 = {
442 .name = "serial8250",
443 .id = 0,
444 .dev = {
445 .platform_data = kirkwood_uart0_data,
446 },
447 .resource = kirkwood_uart0_resources,
448 .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
449};
450
451void __init kirkwood_uart0_init(void)
452{
453 platform_device_register(&kirkwood_uart0);
454}
455
456
457/*****************************************************************************
458 * UART1
459 ****************************************************************************/
460static struct plat_serial8250_port kirkwood_uart1_data[] = {
461 {
462 .mapbase = UART1_PHYS_BASE,
463 .membase = (char *)UART1_VIRT_BASE,
464 .irq = IRQ_KIRKWOOD_UART_1,
465 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
466 .iotype = UPIO_MEM,
467 .regshift = 2,
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200468 .uartclk = 0,
Saeed Bishara651c74c2008-06-22 22:45:06 +0200469 }, {
470 },
471};
472
473static struct resource kirkwood_uart1_resources[] = {
474 {
475 .start = UART1_PHYS_BASE,
476 .end = UART1_PHYS_BASE + 0xff,
477 .flags = IORESOURCE_MEM,
478 }, {
479 .start = IRQ_KIRKWOOD_UART_1,
480 .end = IRQ_KIRKWOOD_UART_1,
481 .flags = IORESOURCE_IRQ,
482 },
483};
484
485static struct platform_device kirkwood_uart1 = {
486 .name = "serial8250",
487 .id = 1,
488 .dev = {
489 .platform_data = kirkwood_uart1_data,
490 },
491 .resource = kirkwood_uart1_resources,
492 .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
493};
494
495void __init kirkwood_uart1_init(void)
496{
497 platform_device_register(&kirkwood_uart1);
498}
499
500
501/*****************************************************************************
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100502 * XOR
503 ****************************************************************************/
504static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
505 .dram = &kirkwood_mbus_dram_info,
506};
507
508static u64 kirkwood_xor_dmamask = DMA_32BIT_MASK;
509
510
511/*****************************************************************************
512 * XOR0
513 ****************************************************************************/
514static struct resource kirkwood_xor0_shared_resources[] = {
515 {
516 .name = "xor 0 low",
517 .start = XOR0_PHYS_BASE,
518 .end = XOR0_PHYS_BASE + 0xff,
519 .flags = IORESOURCE_MEM,
520 }, {
521 .name = "xor 0 high",
522 .start = XOR0_HIGH_PHYS_BASE,
523 .end = XOR0_HIGH_PHYS_BASE + 0xff,
524 .flags = IORESOURCE_MEM,
525 },
526};
527
528static struct platform_device kirkwood_xor0_shared = {
529 .name = MV_XOR_SHARED_NAME,
530 .id = 0,
531 .dev = {
532 .platform_data = &kirkwood_xor_shared_data,
533 },
534 .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
535 .resource = kirkwood_xor0_shared_resources,
536};
537
538static struct resource kirkwood_xor00_resources[] = {
539 [0] = {
540 .start = IRQ_KIRKWOOD_XOR_00,
541 .end = IRQ_KIRKWOOD_XOR_00,
542 .flags = IORESOURCE_IRQ,
543 },
544};
545
546static struct mv_xor_platform_data kirkwood_xor00_data = {
547 .shared = &kirkwood_xor0_shared,
548 .hw_id = 0,
549 .pool_size = PAGE_SIZE,
550};
551
552static struct platform_device kirkwood_xor00_channel = {
553 .name = MV_XOR_NAME,
554 .id = 0,
555 .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
556 .resource = kirkwood_xor00_resources,
557 .dev = {
558 .dma_mask = &kirkwood_xor_dmamask,
559 .coherent_dma_mask = DMA_64BIT_MASK,
560 .platform_data = (void *)&kirkwood_xor00_data,
561 },
562};
563
564static struct resource kirkwood_xor01_resources[] = {
565 [0] = {
566 .start = IRQ_KIRKWOOD_XOR_01,
567 .end = IRQ_KIRKWOOD_XOR_01,
568 .flags = IORESOURCE_IRQ,
569 },
570};
571
572static struct mv_xor_platform_data kirkwood_xor01_data = {
573 .shared = &kirkwood_xor0_shared,
574 .hw_id = 1,
575 .pool_size = PAGE_SIZE,
576};
577
578static struct platform_device kirkwood_xor01_channel = {
579 .name = MV_XOR_NAME,
580 .id = 1,
581 .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
582 .resource = kirkwood_xor01_resources,
583 .dev = {
584 .dma_mask = &kirkwood_xor_dmamask,
585 .coherent_dma_mask = DMA_64BIT_MASK,
586 .platform_data = (void *)&kirkwood_xor01_data,
587 },
588};
589
Nicolas Pitre5b99d532009-02-26 22:55:59 -0500590static void __init kirkwood_xor0_init(void)
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100591{
592 platform_device_register(&kirkwood_xor0_shared);
593
594 /*
595 * two engines can't do memset simultaneously, this limitation
596 * satisfied by removing memset support from one of the engines.
597 */
598 dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
599 dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
600 platform_device_register(&kirkwood_xor00_channel);
601
602 dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
603 dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
604 dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
605 platform_device_register(&kirkwood_xor01_channel);
606}
607
608
609/*****************************************************************************
610 * XOR1
611 ****************************************************************************/
612static struct resource kirkwood_xor1_shared_resources[] = {
613 {
614 .name = "xor 1 low",
615 .start = XOR1_PHYS_BASE,
616 .end = XOR1_PHYS_BASE + 0xff,
617 .flags = IORESOURCE_MEM,
618 }, {
619 .name = "xor 1 high",
620 .start = XOR1_HIGH_PHYS_BASE,
621 .end = XOR1_HIGH_PHYS_BASE + 0xff,
622 .flags = IORESOURCE_MEM,
623 },
624};
625
626static struct platform_device kirkwood_xor1_shared = {
627 .name = MV_XOR_SHARED_NAME,
628 .id = 1,
629 .dev = {
630 .platform_data = &kirkwood_xor_shared_data,
631 },
632 .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
633 .resource = kirkwood_xor1_shared_resources,
634};
635
636static struct resource kirkwood_xor10_resources[] = {
637 [0] = {
638 .start = IRQ_KIRKWOOD_XOR_10,
639 .end = IRQ_KIRKWOOD_XOR_10,
640 .flags = IORESOURCE_IRQ,
641 },
642};
643
644static struct mv_xor_platform_data kirkwood_xor10_data = {
645 .shared = &kirkwood_xor1_shared,
646 .hw_id = 0,
647 .pool_size = PAGE_SIZE,
648};
649
650static struct platform_device kirkwood_xor10_channel = {
651 .name = MV_XOR_NAME,
652 .id = 2,
653 .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
654 .resource = kirkwood_xor10_resources,
655 .dev = {
656 .dma_mask = &kirkwood_xor_dmamask,
657 .coherent_dma_mask = DMA_64BIT_MASK,
658 .platform_data = (void *)&kirkwood_xor10_data,
659 },
660};
661
662static struct resource kirkwood_xor11_resources[] = {
663 [0] = {
664 .start = IRQ_KIRKWOOD_XOR_11,
665 .end = IRQ_KIRKWOOD_XOR_11,
666 .flags = IORESOURCE_IRQ,
667 },
668};
669
670static struct mv_xor_platform_data kirkwood_xor11_data = {
671 .shared = &kirkwood_xor1_shared,
672 .hw_id = 1,
673 .pool_size = PAGE_SIZE,
674};
675
676static struct platform_device kirkwood_xor11_channel = {
677 .name = MV_XOR_NAME,
678 .id = 3,
679 .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
680 .resource = kirkwood_xor11_resources,
681 .dev = {
682 .dma_mask = &kirkwood_xor_dmamask,
683 .coherent_dma_mask = DMA_64BIT_MASK,
684 .platform_data = (void *)&kirkwood_xor11_data,
685 },
686};
687
Nicolas Pitre5b99d532009-02-26 22:55:59 -0500688static void __init kirkwood_xor1_init(void)
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100689{
690 platform_device_register(&kirkwood_xor1_shared);
691
692 /*
693 * two engines can't do memset simultaneously, this limitation
694 * satisfied by removing memset support from one of the engines.
695 */
696 dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
697 dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
698 platform_device_register(&kirkwood_xor10_channel);
699
700 dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
701 dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
702 dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
703 platform_device_register(&kirkwood_xor11_channel);
704}
705
706
707/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200708 * Time handling
709 ****************************************************************************/
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200710int kirkwood_tclk;
711
712int __init kirkwood_find_tclk(void)
713{
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300714 u32 dev, rev;
715
716 kirkwood_pcie_id(&dev, &rev);
717 if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
718 return 200000000;
719
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200720 return 166666667;
721}
722
Saeed Bishara651c74c2008-06-22 22:45:06 +0200723static void kirkwood_timer_init(void)
724{
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200725 kirkwood_tclk = kirkwood_find_tclk();
726 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
Saeed Bishara651c74c2008-06-22 22:45:06 +0200727}
728
729struct sys_timer kirkwood_timer = {
730 .init = kirkwood_timer_init,
731};
732
733
734/*****************************************************************************
735 * General
736 ****************************************************************************/
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300737/*
738 * Identify device ID and revision.
739 */
Saeed Bishara651c74c2008-06-22 22:45:06 +0200740static char * __init kirkwood_id(void)
741{
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300742 u32 dev, rev;
Saeed Bishara651c74c2008-06-22 22:45:06 +0200743
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300744 kirkwood_pcie_id(&dev, &rev);
745
746 if (dev == MV88F6281_DEV_ID) {
747 if (rev == MV88F6281_REV_Z0)
748 return "MV88F6281-Z0";
749 else if (rev == MV88F6281_REV_A0)
750 return "MV88F6281-A0";
751 else
752 return "MV88F6281-Rev-Unsupported";
753 } else if (dev == MV88F6192_DEV_ID) {
754 if (rev == MV88F6192_REV_Z0)
755 return "MV88F6192-Z0";
756 else if (rev == MV88F6192_REV_A0)
757 return "MV88F6192-A0";
758 else
759 return "MV88F6192-Rev-Unsupported";
760 } else if (dev == MV88F6180_DEV_ID) {
761 if (rev == MV88F6180_REV_A0)
762 return "MV88F6180-Rev-A0";
763 else
764 return "MV88F6180-Rev-Unsupported";
765 } else {
766 return "Device-Unknown";
767 }
Saeed Bishara651c74c2008-06-22 22:45:06 +0200768}
769
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300770static void __init kirkwood_l2_init(void)
Saeed Bishara13387602008-06-23 01:05:08 -1100771{
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300772#ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
773 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
774 feroceon_l2_init(1);
775#else
776 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
777 feroceon_l2_init(0);
778#endif
Saeed Bishara13387602008-06-23 01:05:08 -1100779}
780
Saeed Bishara651c74c2008-06-22 22:45:06 +0200781void __init kirkwood_init(void)
782{
783 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200784 kirkwood_id(), kirkwood_tclk);
785 kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
Nicolas Pitre13731d12009-01-06 23:02:08 +0100786 kirkwood_ge01_shared_data.t_clk = kirkwood_tclk;
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200787 kirkwood_spi_plat_data.tclk = kirkwood_tclk;
788 kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
789 kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
Saeed Bishara651c74c2008-06-22 22:45:06 +0200790
791 kirkwood_setup_cpu_mbus();
792
793#ifdef CONFIG_CACHE_FEROCEON_L2
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300794 kirkwood_l2_init();
Saeed Bishara651c74c2008-06-22 22:45:06 +0200795#endif
Nicolas Pitre5b99d532009-02-26 22:55:59 -0500796
797 /* internal devices that every board has */
798 kirkwood_rtc_init();
799 kirkwood_xor0_init();
800 kirkwood_xor1_init();
Saeed Bishara651c74c2008-06-22 22:45:06 +0200801}