blob: 0d2074f51a593ff0e6294889b4ba26a0fa57fd07 [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>
17#include <linux/ata_platform.h>
Lennert Buytenhek18365d12008-08-09 15:38:18 +020018#include <linux/spi/orion_spi.h>
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +020019#include <net/dsa.h>
Saeed Bishara651c74c2008-06-22 22:45:06 +020020#include <asm/page.h>
21#include <asm/timex.h>
22#include <asm/mach/map.h>
23#include <asm/mach/time.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010024#include <mach/kirkwood.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020025#include <plat/cache-feroceon-l2.h>
26#include <plat/ehci-orion.h>
Saeed Bishara09c0ed22008-06-23 04:26:07 -110027#include <plat/mv_xor.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020028#include <plat/orion_nand.h>
29#include <plat/time.h>
Saeed Bishara651c74c2008-06-22 22:45:06 +020030#include "common.h"
31
32/*****************************************************************************
33 * I/O Address Mapping
34 ****************************************************************************/
35static struct map_desc kirkwood_io_desc[] __initdata = {
36 {
37 .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE,
38 .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE),
39 .length = KIRKWOOD_PCIE_IO_SIZE,
40 .type = MT_DEVICE,
41 }, {
42 .virtual = KIRKWOOD_REGS_VIRT_BASE,
43 .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
44 .length = KIRKWOOD_REGS_SIZE,
45 .type = MT_DEVICE,
46 },
47};
48
49void __init kirkwood_map_io(void)
50{
51 iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
52}
53
54
55/*****************************************************************************
56 * EHCI
57 ****************************************************************************/
58static struct orion_ehci_data kirkwood_ehci_data = {
59 .dram = &kirkwood_mbus_dram_info,
Ronen Shitritfb6f5522008-09-17 10:08:05 +030060 .phy_version = EHCI_PHY_NA,
Saeed Bishara651c74c2008-06-22 22:45:06 +020061};
62
63static u64 ehci_dmamask = 0xffffffffUL;
64
65
66/*****************************************************************************
67 * EHCI0
68 ****************************************************************************/
69static struct resource kirkwood_ehci_resources[] = {
70 {
71 .start = USB_PHYS_BASE,
72 .end = USB_PHYS_BASE + 0x0fff,
73 .flags = IORESOURCE_MEM,
74 }, {
75 .start = IRQ_KIRKWOOD_USB,
76 .end = IRQ_KIRKWOOD_USB,
77 .flags = IORESOURCE_IRQ,
78 },
79};
80
81static struct platform_device kirkwood_ehci = {
82 .name = "orion-ehci",
83 .id = 0,
84 .dev = {
85 .dma_mask = &ehci_dmamask,
86 .coherent_dma_mask = 0xffffffff,
87 .platform_data = &kirkwood_ehci_data,
88 },
89 .resource = kirkwood_ehci_resources,
90 .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
91};
92
93void __init kirkwood_ehci_init(void)
94{
95 platform_device_register(&kirkwood_ehci);
96}
97
98
99/*****************************************************************************
100 * GE00
101 ****************************************************************************/
102struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
Saeed Bishara651c74c2008-06-22 22:45:06 +0200103 .dram = &kirkwood_mbus_dram_info,
104};
105
106static struct resource kirkwood_ge00_shared_resources[] = {
107 {
108 .name = "ge00 base",
109 .start = GE00_PHYS_BASE + 0x2000,
110 .end = GE00_PHYS_BASE + 0x3fff,
111 .flags = IORESOURCE_MEM,
Lennert Buytenhek144f8142008-08-26 16:04:05 +0200112 }, {
113 .name = "ge00 err irq",
114 .start = IRQ_KIRKWOOD_GE00_ERR,
115 .end = IRQ_KIRKWOOD_GE00_ERR,
116 .flags = IORESOURCE_IRQ,
Saeed Bishara651c74c2008-06-22 22:45:06 +0200117 },
118};
119
120static struct platform_device kirkwood_ge00_shared = {
121 .name = MV643XX_ETH_SHARED_NAME,
122 .id = 0,
123 .dev = {
124 .platform_data = &kirkwood_ge00_shared_data,
125 },
Lennert Buytenhek144f8142008-08-26 16:04:05 +0200126 .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
Saeed Bishara651c74c2008-06-22 22:45:06 +0200127 .resource = kirkwood_ge00_shared_resources,
128};
129
130static struct resource kirkwood_ge00_resources[] = {
131 {
132 .name = "ge00 irq",
133 .start = IRQ_KIRKWOOD_GE00_SUM,
134 .end = IRQ_KIRKWOOD_GE00_SUM,
135 .flags = IORESOURCE_IRQ,
136 },
137};
138
139static struct platform_device kirkwood_ge00 = {
140 .name = MV643XX_ETH_NAME,
141 .id = 0,
142 .num_resources = 1,
143 .resource = kirkwood_ge00_resources,
144};
145
146void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
147{
148 eth_data->shared = &kirkwood_ge00_shared;
149 kirkwood_ge00.dev.platform_data = eth_data;
150
151 platform_device_register(&kirkwood_ge00_shared);
152 platform_device_register(&kirkwood_ge00);
153}
154
155
156/*****************************************************************************
Ronen Shitritd15fb9e2008-10-19 23:10:14 +0200157 * GE01
158 ****************************************************************************/
159struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data = {
160 .dram = &kirkwood_mbus_dram_info,
161 .shared_smi = &kirkwood_ge00_shared,
162};
163
164static struct resource kirkwood_ge01_shared_resources[] = {
165 {
166 .name = "ge01 base",
167 .start = GE01_PHYS_BASE + 0x2000,
168 .end = GE01_PHYS_BASE + 0x3fff,
169 .flags = IORESOURCE_MEM,
170 }, {
171 .name = "ge01 err irq",
172 .start = IRQ_KIRKWOOD_GE01_ERR,
173 .end = IRQ_KIRKWOOD_GE01_ERR,
174 .flags = IORESOURCE_IRQ,
175 },
176};
177
178static struct platform_device kirkwood_ge01_shared = {
179 .name = MV643XX_ETH_SHARED_NAME,
180 .id = 1,
181 .dev = {
182 .platform_data = &kirkwood_ge01_shared_data,
183 },
184 .num_resources = ARRAY_SIZE(kirkwood_ge01_shared_resources),
185 .resource = kirkwood_ge01_shared_resources,
186};
187
188static struct resource kirkwood_ge01_resources[] = {
189 {
190 .name = "ge01 irq",
191 .start = IRQ_KIRKWOOD_GE01_SUM,
192 .end = IRQ_KIRKWOOD_GE01_SUM,
193 .flags = IORESOURCE_IRQ,
194 },
195};
196
197static struct platform_device kirkwood_ge01 = {
198 .name = MV643XX_ETH_NAME,
199 .id = 1,
200 .num_resources = 1,
201 .resource = kirkwood_ge01_resources,
202};
203
204void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
205{
206 eth_data->shared = &kirkwood_ge01_shared;
207 kirkwood_ge01.dev.platform_data = eth_data;
208
209 platform_device_register(&kirkwood_ge01_shared);
210 platform_device_register(&kirkwood_ge01);
211}
212
213
214/*****************************************************************************
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200215 * Ethernet switch
216 ****************************************************************************/
217static struct resource kirkwood_switch_resources[] = {
218 {
219 .start = 0,
220 .end = 0,
221 .flags = IORESOURCE_IRQ,
222 },
223};
224
225static struct platform_device kirkwood_switch_device = {
226 .name = "dsa",
227 .id = 0,
228 .num_resources = 0,
229 .resource = kirkwood_switch_resources,
230};
231
232void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
233{
Lennert Buytenheke84665c2009-03-20 09:52:09 +0000234 int i;
235
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200236 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
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200242 d->netdev = &kirkwood_ge00.dev;
Lennert Buytenheke84665c2009-03-20 09:52:09 +0000243 for (i = 0; i < d->nr_chips; i++)
244 d->chip[i].mii_bus = &kirkwood_ge00_shared.dev;
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200245 kirkwood_switch_device.dev.platform_data = d;
246
247 platform_device_register(&kirkwood_switch_device);
248}
249
250
251/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200252 * SoC RTC
253 ****************************************************************************/
254static struct resource kirkwood_rtc_resource = {
255 .start = RTC_PHYS_BASE,
256 .end = RTC_PHYS_BASE + SZ_16 - 1,
257 .flags = IORESOURCE_MEM,
258};
259
260void __init kirkwood_rtc_init(void)
261{
262 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
263}
264
265
266/*****************************************************************************
267 * SATA
268 ****************************************************************************/
269static struct resource kirkwood_sata_resources[] = {
270 {
271 .name = "sata base",
272 .start = SATA_PHYS_BASE,
273 .end = SATA_PHYS_BASE + 0x5000 - 1,
274 .flags = IORESOURCE_MEM,
275 }, {
276 .name = "sata irq",
277 .start = IRQ_KIRKWOOD_SATA,
278 .end = IRQ_KIRKWOOD_SATA,
279 .flags = IORESOURCE_IRQ,
280 },
281};
282
283static struct platform_device kirkwood_sata = {
284 .name = "sata_mv",
285 .id = 0,
286 .dev = {
287 .coherent_dma_mask = 0xffffffff,
288 },
289 .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
290 .resource = kirkwood_sata_resources,
291};
292
293void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
294{
295 sata_data->dram = &kirkwood_mbus_dram_info;
296 kirkwood_sata.dev.platform_data = sata_data;
297 platform_device_register(&kirkwood_sata);
298}
299
300
301/*****************************************************************************
Lennert Buytenhek18365d12008-08-09 15:38:18 +0200302 * SPI
303 ****************************************************************************/
304static struct orion_spi_info kirkwood_spi_plat_data = {
Lennert Buytenhek18365d12008-08-09 15:38:18 +0200305};
306
307static struct resource kirkwood_spi_resources[] = {
308 {
309 .start = SPI_PHYS_BASE,
310 .end = SPI_PHYS_BASE + SZ_512 - 1,
311 .flags = IORESOURCE_MEM,
312 },
313};
314
315static struct platform_device kirkwood_spi = {
316 .name = "orion_spi",
317 .id = 0,
318 .resource = kirkwood_spi_resources,
319 .dev = {
320 .platform_data = &kirkwood_spi_plat_data,
321 },
322 .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
323};
324
325void __init kirkwood_spi_init()
326{
327 platform_device_register(&kirkwood_spi);
328}
329
330
331/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200332 * UART0
333 ****************************************************************************/
334static struct plat_serial8250_port kirkwood_uart0_data[] = {
335 {
336 .mapbase = UART0_PHYS_BASE,
337 .membase = (char *)UART0_VIRT_BASE,
338 .irq = IRQ_KIRKWOOD_UART_0,
339 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
340 .iotype = UPIO_MEM,
341 .regshift = 2,
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200342 .uartclk = 0,
Saeed Bishara651c74c2008-06-22 22:45:06 +0200343 }, {
344 },
345};
346
347static struct resource kirkwood_uart0_resources[] = {
348 {
349 .start = UART0_PHYS_BASE,
350 .end = UART0_PHYS_BASE + 0xff,
351 .flags = IORESOURCE_MEM,
352 }, {
353 .start = IRQ_KIRKWOOD_UART_0,
354 .end = IRQ_KIRKWOOD_UART_0,
355 .flags = IORESOURCE_IRQ,
356 },
357};
358
359static struct platform_device kirkwood_uart0 = {
360 .name = "serial8250",
361 .id = 0,
362 .dev = {
363 .platform_data = kirkwood_uart0_data,
364 },
365 .resource = kirkwood_uart0_resources,
366 .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
367};
368
369void __init kirkwood_uart0_init(void)
370{
371 platform_device_register(&kirkwood_uart0);
372}
373
374
375/*****************************************************************************
376 * UART1
377 ****************************************************************************/
378static struct plat_serial8250_port kirkwood_uart1_data[] = {
379 {
380 .mapbase = UART1_PHYS_BASE,
381 .membase = (char *)UART1_VIRT_BASE,
382 .irq = IRQ_KIRKWOOD_UART_1,
383 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
384 .iotype = UPIO_MEM,
385 .regshift = 2,
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200386 .uartclk = 0,
Saeed Bishara651c74c2008-06-22 22:45:06 +0200387 }, {
388 },
389};
390
391static struct resource kirkwood_uart1_resources[] = {
392 {
393 .start = UART1_PHYS_BASE,
394 .end = UART1_PHYS_BASE + 0xff,
395 .flags = IORESOURCE_MEM,
396 }, {
397 .start = IRQ_KIRKWOOD_UART_1,
398 .end = IRQ_KIRKWOOD_UART_1,
399 .flags = IORESOURCE_IRQ,
400 },
401};
402
403static struct platform_device kirkwood_uart1 = {
404 .name = "serial8250",
405 .id = 1,
406 .dev = {
407 .platform_data = kirkwood_uart1_data,
408 },
409 .resource = kirkwood_uart1_resources,
410 .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
411};
412
413void __init kirkwood_uart1_init(void)
414{
415 platform_device_register(&kirkwood_uart1);
416}
417
418
419/*****************************************************************************
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100420 * XOR
421 ****************************************************************************/
422static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
423 .dram = &kirkwood_mbus_dram_info,
424};
425
426static u64 kirkwood_xor_dmamask = DMA_32BIT_MASK;
427
428
429/*****************************************************************************
430 * XOR0
431 ****************************************************************************/
432static struct resource kirkwood_xor0_shared_resources[] = {
433 {
434 .name = "xor 0 low",
435 .start = XOR0_PHYS_BASE,
436 .end = XOR0_PHYS_BASE + 0xff,
437 .flags = IORESOURCE_MEM,
438 }, {
439 .name = "xor 0 high",
440 .start = XOR0_HIGH_PHYS_BASE,
441 .end = XOR0_HIGH_PHYS_BASE + 0xff,
442 .flags = IORESOURCE_MEM,
443 },
444};
445
446static struct platform_device kirkwood_xor0_shared = {
447 .name = MV_XOR_SHARED_NAME,
448 .id = 0,
449 .dev = {
450 .platform_data = &kirkwood_xor_shared_data,
451 },
452 .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
453 .resource = kirkwood_xor0_shared_resources,
454};
455
456static struct resource kirkwood_xor00_resources[] = {
457 [0] = {
458 .start = IRQ_KIRKWOOD_XOR_00,
459 .end = IRQ_KIRKWOOD_XOR_00,
460 .flags = IORESOURCE_IRQ,
461 },
462};
463
464static struct mv_xor_platform_data kirkwood_xor00_data = {
465 .shared = &kirkwood_xor0_shared,
466 .hw_id = 0,
467 .pool_size = PAGE_SIZE,
468};
469
470static struct platform_device kirkwood_xor00_channel = {
471 .name = MV_XOR_NAME,
472 .id = 0,
473 .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
474 .resource = kirkwood_xor00_resources,
475 .dev = {
476 .dma_mask = &kirkwood_xor_dmamask,
477 .coherent_dma_mask = DMA_64BIT_MASK,
478 .platform_data = (void *)&kirkwood_xor00_data,
479 },
480};
481
482static struct resource kirkwood_xor01_resources[] = {
483 [0] = {
484 .start = IRQ_KIRKWOOD_XOR_01,
485 .end = IRQ_KIRKWOOD_XOR_01,
486 .flags = IORESOURCE_IRQ,
487 },
488};
489
490static struct mv_xor_platform_data kirkwood_xor01_data = {
491 .shared = &kirkwood_xor0_shared,
492 .hw_id = 1,
493 .pool_size = PAGE_SIZE,
494};
495
496static struct platform_device kirkwood_xor01_channel = {
497 .name = MV_XOR_NAME,
498 .id = 1,
499 .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
500 .resource = kirkwood_xor01_resources,
501 .dev = {
502 .dma_mask = &kirkwood_xor_dmamask,
503 .coherent_dma_mask = DMA_64BIT_MASK,
504 .platform_data = (void *)&kirkwood_xor01_data,
505 },
506};
507
508void __init kirkwood_xor0_init(void)
509{
510 platform_device_register(&kirkwood_xor0_shared);
511
512 /*
513 * two engines can't do memset simultaneously, this limitation
514 * satisfied by removing memset support from one of the engines.
515 */
516 dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
517 dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
518 platform_device_register(&kirkwood_xor00_channel);
519
520 dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
521 dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
522 dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
523 platform_device_register(&kirkwood_xor01_channel);
524}
525
526
527/*****************************************************************************
528 * XOR1
529 ****************************************************************************/
530static struct resource kirkwood_xor1_shared_resources[] = {
531 {
532 .name = "xor 1 low",
533 .start = XOR1_PHYS_BASE,
534 .end = XOR1_PHYS_BASE + 0xff,
535 .flags = IORESOURCE_MEM,
536 }, {
537 .name = "xor 1 high",
538 .start = XOR1_HIGH_PHYS_BASE,
539 .end = XOR1_HIGH_PHYS_BASE + 0xff,
540 .flags = IORESOURCE_MEM,
541 },
542};
543
544static struct platform_device kirkwood_xor1_shared = {
545 .name = MV_XOR_SHARED_NAME,
546 .id = 1,
547 .dev = {
548 .platform_data = &kirkwood_xor_shared_data,
549 },
550 .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
551 .resource = kirkwood_xor1_shared_resources,
552};
553
554static struct resource kirkwood_xor10_resources[] = {
555 [0] = {
556 .start = IRQ_KIRKWOOD_XOR_10,
557 .end = IRQ_KIRKWOOD_XOR_10,
558 .flags = IORESOURCE_IRQ,
559 },
560};
561
562static struct mv_xor_platform_data kirkwood_xor10_data = {
563 .shared = &kirkwood_xor1_shared,
564 .hw_id = 0,
565 .pool_size = PAGE_SIZE,
566};
567
568static struct platform_device kirkwood_xor10_channel = {
569 .name = MV_XOR_NAME,
570 .id = 2,
571 .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
572 .resource = kirkwood_xor10_resources,
573 .dev = {
574 .dma_mask = &kirkwood_xor_dmamask,
575 .coherent_dma_mask = DMA_64BIT_MASK,
576 .platform_data = (void *)&kirkwood_xor10_data,
577 },
578};
579
580static struct resource kirkwood_xor11_resources[] = {
581 [0] = {
582 .start = IRQ_KIRKWOOD_XOR_11,
583 .end = IRQ_KIRKWOOD_XOR_11,
584 .flags = IORESOURCE_IRQ,
585 },
586};
587
588static struct mv_xor_platform_data kirkwood_xor11_data = {
589 .shared = &kirkwood_xor1_shared,
590 .hw_id = 1,
591 .pool_size = PAGE_SIZE,
592};
593
594static struct platform_device kirkwood_xor11_channel = {
595 .name = MV_XOR_NAME,
596 .id = 3,
597 .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
598 .resource = kirkwood_xor11_resources,
599 .dev = {
600 .dma_mask = &kirkwood_xor_dmamask,
601 .coherent_dma_mask = DMA_64BIT_MASK,
602 .platform_data = (void *)&kirkwood_xor11_data,
603 },
604};
605
606void __init kirkwood_xor1_init(void)
607{
608 platform_device_register(&kirkwood_xor1_shared);
609
610 /*
611 * two engines can't do memset simultaneously, this limitation
612 * satisfied by removing memset support from one of the engines.
613 */
614 dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
615 dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
616 platform_device_register(&kirkwood_xor10_channel);
617
618 dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
619 dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
620 dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
621 platform_device_register(&kirkwood_xor11_channel);
622}
623
624
625/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200626 * Time handling
627 ****************************************************************************/
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200628int kirkwood_tclk;
629
630int __init kirkwood_find_tclk(void)
631{
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300632 u32 dev, rev;
633
634 kirkwood_pcie_id(&dev, &rev);
635 if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
636 return 200000000;
637
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200638 return 166666667;
639}
640
Saeed Bishara651c74c2008-06-22 22:45:06 +0200641static void kirkwood_timer_init(void)
642{
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200643 kirkwood_tclk = kirkwood_find_tclk();
644 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
Saeed Bishara651c74c2008-06-22 22:45:06 +0200645}
646
647struct sys_timer kirkwood_timer = {
648 .init = kirkwood_timer_init,
649};
650
651
652/*****************************************************************************
653 * General
654 ****************************************************************************/
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300655/*
656 * Identify device ID and revision.
657 */
Saeed Bishara651c74c2008-06-22 22:45:06 +0200658static char * __init kirkwood_id(void)
659{
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300660 u32 dev, rev;
Saeed Bishara651c74c2008-06-22 22:45:06 +0200661
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300662 kirkwood_pcie_id(&dev, &rev);
663
664 if (dev == MV88F6281_DEV_ID) {
665 if (rev == MV88F6281_REV_Z0)
666 return "MV88F6281-Z0";
667 else if (rev == MV88F6281_REV_A0)
668 return "MV88F6281-A0";
669 else
670 return "MV88F6281-Rev-Unsupported";
671 } else if (dev == MV88F6192_DEV_ID) {
672 if (rev == MV88F6192_REV_Z0)
673 return "MV88F6192-Z0";
674 else if (rev == MV88F6192_REV_A0)
675 return "MV88F6192-A0";
676 else
677 return "MV88F6192-Rev-Unsupported";
678 } else if (dev == MV88F6180_DEV_ID) {
679 if (rev == MV88F6180_REV_A0)
680 return "MV88F6180-Rev-A0";
681 else
682 return "MV88F6180-Rev-Unsupported";
683 } else {
684 return "Device-Unknown";
685 }
Saeed Bishara651c74c2008-06-22 22:45:06 +0200686}
687
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300688static void __init kirkwood_l2_init(void)
Saeed Bishara13387602008-06-23 01:05:08 -1100689{
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300690#ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
691 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
692 feroceon_l2_init(1);
693#else
694 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
695 feroceon_l2_init(0);
696#endif
Saeed Bishara13387602008-06-23 01:05:08 -1100697}
698
Saeed Bishara651c74c2008-06-22 22:45:06 +0200699void __init kirkwood_init(void)
700{
701 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200702 kirkwood_id(), kirkwood_tclk);
703 kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
Nicolas Pitre13731d12009-01-06 23:02:08 +0100704 kirkwood_ge01_shared_data.t_clk = kirkwood_tclk;
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200705 kirkwood_spi_plat_data.tclk = kirkwood_tclk;
706 kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
707 kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
Saeed Bishara651c74c2008-06-22 22:45:06 +0200708
709 kirkwood_setup_cpu_mbus();
710
711#ifdef CONFIG_CACHE_FEROCEON_L2
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300712 kirkwood_l2_init();
Saeed Bishara651c74c2008-06-22 22:45:06 +0200713#endif
714}