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