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