blob: 6e3eb1a6a660e0a8811666a5901d9d5dee5a4524 [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>
Nicolas Pitrefb7b2d32009-06-01 15:36:36 -040019#include <linux/mtd/nand.h>
Lennert Buytenhek18365d12008-08-09 15:38:18 +020020#include <linux/spi/orion_spi.h>
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +020021#include <net/dsa.h>
Saeed Bishara651c74c2008-06-22 22:45:06 +020022#include <asm/page.h>
23#include <asm/timex.h>
24#include <asm/mach/map.h>
25#include <asm/mach/time.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/kirkwood.h>
Nicolas Pitrefdd8b072009-04-22 20:08:17 +010027#include <mach/bridge-regs.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020028#include <plat/cache-feroceon-l2.h>
29#include <plat/ehci-orion.h>
Nicolas Pitre8235ee02009-02-14 03:15:55 -050030#include <plat/mvsdio.h>
Saeed Bishara09c0ed22008-06-23 04:26:07 -110031#include <plat/mv_xor.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020032#include <plat/orion_nand.h>
33#include <plat/time.h>
Saeed Bishara651c74c2008-06-22 22:45:06 +020034#include "common.h"
35
36/*****************************************************************************
37 * I/O Address Mapping
38 ****************************************************************************/
39static 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
53void __init kirkwood_map_io(void)
54{
55 iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
56}
57
58
59/*****************************************************************************
60 * EHCI
61 ****************************************************************************/
62static struct orion_ehci_data kirkwood_ehci_data = {
63 .dram = &kirkwood_mbus_dram_info,
Ronen Shitritfb6f5522008-09-17 10:08:05 +030064 .phy_version = EHCI_PHY_NA,
Saeed Bishara651c74c2008-06-22 22:45:06 +020065};
66
67static u64 ehci_dmamask = 0xffffffffUL;
68
69
70/*****************************************************************************
71 * EHCI0
72 ****************************************************************************/
73static 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
85static 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
97void __init kirkwood_ehci_init(void)
98{
99 platform_device_register(&kirkwood_ehci);
100}
101
102
103/*****************************************************************************
104 * GE00
105 ****************************************************************************/
106struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
Saeed Bishara651c74c2008-06-22 22:45:06 +0200107 .dram = &kirkwood_mbus_dram_info,
108};
109
110static 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,
Lennert Buytenhek144f8142008-08-26 16:04:05 +0200116 }, {
117 .name = "ge00 err irq",
118 .start = IRQ_KIRKWOOD_GE00_ERR,
119 .end = IRQ_KIRKWOOD_GE00_ERR,
120 .flags = IORESOURCE_IRQ,
Saeed Bishara651c74c2008-06-22 22:45:06 +0200121 },
122};
123
124static 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 },
Lennert Buytenhek144f8142008-08-26 16:04:05 +0200130 .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
Saeed Bishara651c74c2008-06-22 22:45:06 +0200131 .resource = kirkwood_ge00_shared_resources,
132};
133
134static 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
143static struct platform_device kirkwood_ge00 = {
144 .name = MV643XX_ETH_NAME,
145 .id = 0,
146 .num_resources = 1,
147 .resource = kirkwood_ge00_resources,
Nicolas Pitrea49a0182009-05-22 16:53:40 -0400148 .dev = {
149 .coherent_dma_mask = 0xffffffff,
150 },
Saeed Bishara651c74c2008-06-22 22:45:06 +0200151};
152
153void __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/*****************************************************************************
Ronen Shitritd15fb9e2008-10-19 23:10:14 +0200164 * GE01
165 ****************************************************************************/
166struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data = {
167 .dram = &kirkwood_mbus_dram_info,
168 .shared_smi = &kirkwood_ge00_shared,
169};
170
171static 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
185static 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
195static 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
204static struct platform_device kirkwood_ge01 = {
205 .name = MV643XX_ETH_NAME,
206 .id = 1,
207 .num_resources = 1,
208 .resource = kirkwood_ge01_resources,
Nicolas Pitrea49a0182009-05-22 16:53:40 -0400209 .dev = {
210 .coherent_dma_mask = 0xffffffff,
211 },
Ronen Shitritd15fb9e2008-10-19 23:10:14 +0200212};
213
214void __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/*****************************************************************************
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200225 * Ethernet switch
226 ****************************************************************************/
227static struct resource kirkwood_switch_resources[] = {
228 {
229 .start = 0,
230 .end = 0,
231 .flags = IORESOURCE_IRQ,
232 },
233};
234
235static struct platform_device kirkwood_switch_device = {
236 .name = "dsa",
237 .id = 0,
238 .num_resources = 0,
239 .resource = kirkwood_switch_resources,
240};
241
242void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
243{
Lennert Buytenheke84665c2009-03-20 09:52:09 +0000244 int i;
245
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200246 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
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200252 d->netdev = &kirkwood_ge00.dev;
Lennert Buytenheke84665c2009-03-20 09:52:09 +0000253 for (i = 0; i < d->nr_chips; i++)
254 d->chip[i].mii_bus = &kirkwood_ge00_shared.dev;
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200255 kirkwood_switch_device.dev.platform_data = d;
256
257 platform_device_register(&kirkwood_switch_device);
258}
259
260
261/*****************************************************************************
Nicolas Pitrefb7b2d32009-06-01 15:36:36 -0400262 * NAND flash
263 ****************************************************************************/
264static 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
271static struct orion_nand_data kirkwood_nand_data = {
272 .cle = 0,
273 .ale = 1,
274 .width = 8,
275};
276
277static 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
287void __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/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200298 * SoC RTC
299 ****************************************************************************/
300static struct resource kirkwood_rtc_resource = {
301 .start = RTC_PHYS_BASE,
302 .end = RTC_PHYS_BASE + SZ_16 - 1,
303 .flags = IORESOURCE_MEM,
304};
305
Nicolas Pitre5b99d532009-02-26 22:55:59 -0500306static void __init kirkwood_rtc_init(void)
Saeed Bishara651c74c2008-06-22 22:45:06 +0200307{
308 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
309}
310
311
312/*****************************************************************************
313 * SATA
314 ****************************************************************************/
315static 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
329static 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
339void __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/*****************************************************************************
Nicolas Pitre8235ee02009-02-14 03:15:55 -0500348 * SD/SDIO/MMC
349 ****************************************************************************/
350static 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
363static u64 mvsdio_dmamask = 0xffffffffUL;
364
365static 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
376void __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/*****************************************************************************
Lennert Buytenhek18365d12008-08-09 15:38:18 +0200392 * SPI
393 ****************************************************************************/
394static struct orion_spi_info kirkwood_spi_plat_data = {
Lennert Buytenhek18365d12008-08-09 15:38:18 +0200395};
396
397static 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
405static 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
415void __init kirkwood_spi_init()
416{
417 platform_device_register(&kirkwood_spi);
418}
419
420
421/*****************************************************************************
Martin Michlmayr6574e002009-03-23 19:13:21 +0100422 * I2C
423 ****************************************************************************/
424static 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
430static struct resource kirkwood_i2c_resources[] = {
431 {
Martin Michlmayr6574e002009-03-23 19:13:21 +0100432 .start = I2C_PHYS_BASE,
433 .end = I2C_PHYS_BASE + 0x1f,
434 .flags = IORESOURCE_MEM,
435 }, {
Martin Michlmayr6574e002009-03-23 19:13:21 +0100436 .start = IRQ_KIRKWOOD_TWSI,
437 .end = IRQ_KIRKWOOD_TWSI,
438 .flags = IORESOURCE_IRQ,
439 },
440};
441
442static 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
452void __init kirkwood_i2c_init(void)
453{
454 platform_device_register(&kirkwood_i2c);
455}
456
457
458/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200459 * UART0
460 ****************************************************************************/
461static 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,
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200469 .uartclk = 0,
Saeed Bishara651c74c2008-06-22 22:45:06 +0200470 }, {
471 },
472};
473
474static 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
486static 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
496void __init kirkwood_uart0_init(void)
497{
498 platform_device_register(&kirkwood_uart0);
499}
500
501
502/*****************************************************************************
503 * UART1
504 ****************************************************************************/
505static 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,
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200513 .uartclk = 0,
Saeed Bishara651c74c2008-06-22 22:45:06 +0200514 }, {
515 },
516};
517
518static 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
530static 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
540void __init kirkwood_uart1_init(void)
541{
542 platform_device_register(&kirkwood_uart1);
543}
544
545
546/*****************************************************************************
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100547 * XOR
548 ****************************************************************************/
549static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
550 .dram = &kirkwood_mbus_dram_info,
551};
552
Yang Hongyang284901a2009-04-06 19:01:15 -0700553static u64 kirkwood_xor_dmamask = DMA_BIT_MASK(32);
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100554
555
556/*****************************************************************************
557 * XOR0
558 ****************************************************************************/
559static 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
573static 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
583static 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
591static struct mv_xor_platform_data kirkwood_xor00_data = {
592 .shared = &kirkwood_xor0_shared,
593 .hw_id = 0,
594 .pool_size = PAGE_SIZE,
595};
596
597static 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,
Yang Hongyang6a355282009-04-06 19:01:13 -0700604 .coherent_dma_mask = DMA_BIT_MASK(64),
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100605 .platform_data = (void *)&kirkwood_xor00_data,
606 },
607};
608
609static 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
617static struct mv_xor_platform_data kirkwood_xor01_data = {
618 .shared = &kirkwood_xor0_shared,
619 .hw_id = 1,
620 .pool_size = PAGE_SIZE,
621};
622
623static 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,
Yang Hongyang6a355282009-04-06 19:01:13 -0700630 .coherent_dma_mask = DMA_BIT_MASK(64),
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100631 .platform_data = (void *)&kirkwood_xor01_data,
632 },
633};
634
Nicolas Pitre5b99d532009-02-26 22:55:59 -0500635static void __init kirkwood_xor0_init(void)
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100636{
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 ****************************************************************************/
657static 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
671static 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
681static 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
689static struct mv_xor_platform_data kirkwood_xor10_data = {
690 .shared = &kirkwood_xor1_shared,
691 .hw_id = 0,
692 .pool_size = PAGE_SIZE,
693};
694
695static 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,
Yang Hongyang6a355282009-04-06 19:01:13 -0700702 .coherent_dma_mask = DMA_BIT_MASK(64),
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100703 .platform_data = (void *)&kirkwood_xor10_data,
704 },
705};
706
707static 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
715static struct mv_xor_platform_data kirkwood_xor11_data = {
716 .shared = &kirkwood_xor1_shared,
717 .hw_id = 1,
718 .pool_size = PAGE_SIZE,
719};
720
721static 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,
Yang Hongyang6a355282009-04-06 19:01:13 -0700728 .coherent_dma_mask = DMA_BIT_MASK(64),
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100729 .platform_data = (void *)&kirkwood_xor11_data,
730 },
731};
732
Nicolas Pitre5b99d532009-02-26 22:55:59 -0500733static void __init kirkwood_xor1_init(void)
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100734{
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/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200753 * Time handling
754 ****************************************************************************/
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200755int kirkwood_tclk;
756
757int __init kirkwood_find_tclk(void)
758{
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300759 u32 dev, rev;
760
761 kirkwood_pcie_id(&dev, &rev);
762 if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
763 return 200000000;
764
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200765 return 166666667;
766}
767
Saeed Bishara651c74c2008-06-22 22:45:06 +0200768static void kirkwood_timer_init(void)
769{
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200770 kirkwood_tclk = kirkwood_find_tclk();
771 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
Saeed Bishara651c74c2008-06-22 22:45:06 +0200772}
773
774struct sys_timer kirkwood_timer = {
775 .init = kirkwood_timer_init,
776};
777
778
779/*****************************************************************************
780 * General
781 ****************************************************************************/
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300782/*
783 * Identify device ID and revision.
784 */
Saeed Bishara651c74c2008-06-22 22:45:06 +0200785static char * __init kirkwood_id(void)
786{
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300787 u32 dev, rev;
Saeed Bishara651c74c2008-06-22 22:45:06 +0200788
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300789 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 }
Saeed Bishara651c74c2008-06-22 22:45:06 +0200813}
814
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300815static void __init kirkwood_l2_init(void)
Saeed Bishara13387602008-06-23 01:05:08 -1100816{
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300817#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
Saeed Bishara13387602008-06-23 01:05:08 -1100824}
825
Saeed Bishara651c74c2008-06-22 22:45:06 +0200826void __init kirkwood_init(void)
827{
828 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200829 kirkwood_id(), kirkwood_tclk);
830 kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
Nicolas Pitre13731d12009-01-06 23:02:08 +0100831 kirkwood_ge01_shared_data.t_clk = kirkwood_tclk;
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200832 kirkwood_spi_plat_data.tclk = kirkwood_tclk;
833 kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
834 kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
Saeed Bishara651c74c2008-06-22 22:45:06 +0200835
836 kirkwood_setup_cpu_mbus();
837
838#ifdef CONFIG_CACHE_FEROCEON_L2
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300839 kirkwood_l2_init();
Saeed Bishara651c74c2008-06-22 22:45:06 +0200840#endif
Nicolas Pitre5b99d532009-02-26 22:55:59 -0500841
842 /* internal devices that every board has */
843 kirkwood_rtc_init();
844 kirkwood_xor0_init();
845 kirkwood_xor1_init();
Saeed Bishara651c74c2008-06-22 22:45:06 +0200846}