blob: 7b8ef97fb5016a99127a34b3ce0cdcd5ae3a7574 [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{
234 if (irq != NO_IRQ) {
235 kirkwood_switch_resources[0].start = irq;
236 kirkwood_switch_resources[0].end = irq;
237 kirkwood_switch_device.num_resources = 1;
238 }
239
240 d->mii_bus = &kirkwood_ge00_shared.dev;
241 d->netdev = &kirkwood_ge00.dev;
242 kirkwood_switch_device.dev.platform_data = d;
243
244 platform_device_register(&kirkwood_switch_device);
245}
246
247
248/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200249 * SoC RTC
250 ****************************************************************************/
251static struct resource kirkwood_rtc_resource = {
252 .start = RTC_PHYS_BASE,
253 .end = RTC_PHYS_BASE + SZ_16 - 1,
254 .flags = IORESOURCE_MEM,
255};
256
257void __init kirkwood_rtc_init(void)
258{
259 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
260}
261
262
263/*****************************************************************************
264 * SATA
265 ****************************************************************************/
266static struct resource kirkwood_sata_resources[] = {
267 {
268 .name = "sata base",
269 .start = SATA_PHYS_BASE,
270 .end = SATA_PHYS_BASE + 0x5000 - 1,
271 .flags = IORESOURCE_MEM,
272 }, {
273 .name = "sata irq",
274 .start = IRQ_KIRKWOOD_SATA,
275 .end = IRQ_KIRKWOOD_SATA,
276 .flags = IORESOURCE_IRQ,
277 },
278};
279
280static struct platform_device kirkwood_sata = {
281 .name = "sata_mv",
282 .id = 0,
283 .dev = {
284 .coherent_dma_mask = 0xffffffff,
285 },
286 .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
287 .resource = kirkwood_sata_resources,
288};
289
290void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
291{
292 sata_data->dram = &kirkwood_mbus_dram_info;
293 kirkwood_sata.dev.platform_data = sata_data;
294 platform_device_register(&kirkwood_sata);
295}
296
297
298/*****************************************************************************
Lennert Buytenhek18365d12008-08-09 15:38:18 +0200299 * SPI
300 ****************************************************************************/
301static struct orion_spi_info kirkwood_spi_plat_data = {
Lennert Buytenhek18365d12008-08-09 15:38:18 +0200302};
303
304static struct resource kirkwood_spi_resources[] = {
305 {
306 .start = SPI_PHYS_BASE,
307 .end = SPI_PHYS_BASE + SZ_512 - 1,
308 .flags = IORESOURCE_MEM,
309 },
310};
311
312static struct platform_device kirkwood_spi = {
313 .name = "orion_spi",
314 .id = 0,
315 .resource = kirkwood_spi_resources,
316 .dev = {
317 .platform_data = &kirkwood_spi_plat_data,
318 },
319 .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
320};
321
322void __init kirkwood_spi_init()
323{
324 platform_device_register(&kirkwood_spi);
325}
326
327
328/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200329 * UART0
330 ****************************************************************************/
331static struct plat_serial8250_port kirkwood_uart0_data[] = {
332 {
333 .mapbase = UART0_PHYS_BASE,
334 .membase = (char *)UART0_VIRT_BASE,
335 .irq = IRQ_KIRKWOOD_UART_0,
336 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
337 .iotype = UPIO_MEM,
338 .regshift = 2,
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200339 .uartclk = 0,
Saeed Bishara651c74c2008-06-22 22:45:06 +0200340 }, {
341 },
342};
343
344static struct resource kirkwood_uart0_resources[] = {
345 {
346 .start = UART0_PHYS_BASE,
347 .end = UART0_PHYS_BASE + 0xff,
348 .flags = IORESOURCE_MEM,
349 }, {
350 .start = IRQ_KIRKWOOD_UART_0,
351 .end = IRQ_KIRKWOOD_UART_0,
352 .flags = IORESOURCE_IRQ,
353 },
354};
355
356static struct platform_device kirkwood_uart0 = {
357 .name = "serial8250",
358 .id = 0,
359 .dev = {
360 .platform_data = kirkwood_uart0_data,
361 },
362 .resource = kirkwood_uart0_resources,
363 .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
364};
365
366void __init kirkwood_uart0_init(void)
367{
368 platform_device_register(&kirkwood_uart0);
369}
370
371
372/*****************************************************************************
373 * UART1
374 ****************************************************************************/
375static struct plat_serial8250_port kirkwood_uart1_data[] = {
376 {
377 .mapbase = UART1_PHYS_BASE,
378 .membase = (char *)UART1_VIRT_BASE,
379 .irq = IRQ_KIRKWOOD_UART_1,
380 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
381 .iotype = UPIO_MEM,
382 .regshift = 2,
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200383 .uartclk = 0,
Saeed Bishara651c74c2008-06-22 22:45:06 +0200384 }, {
385 },
386};
387
388static struct resource kirkwood_uart1_resources[] = {
389 {
390 .start = UART1_PHYS_BASE,
391 .end = UART1_PHYS_BASE + 0xff,
392 .flags = IORESOURCE_MEM,
393 }, {
394 .start = IRQ_KIRKWOOD_UART_1,
395 .end = IRQ_KIRKWOOD_UART_1,
396 .flags = IORESOURCE_IRQ,
397 },
398};
399
400static struct platform_device kirkwood_uart1 = {
401 .name = "serial8250",
402 .id = 1,
403 .dev = {
404 .platform_data = kirkwood_uart1_data,
405 },
406 .resource = kirkwood_uart1_resources,
407 .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
408};
409
410void __init kirkwood_uart1_init(void)
411{
412 platform_device_register(&kirkwood_uart1);
413}
414
415
416/*****************************************************************************
Saeed Bishara09c0ed22008-06-23 04:26:07 -1100417 * XOR
418 ****************************************************************************/
419static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
420 .dram = &kirkwood_mbus_dram_info,
421};
422
423static u64 kirkwood_xor_dmamask = DMA_32BIT_MASK;
424
425
426/*****************************************************************************
427 * XOR0
428 ****************************************************************************/
429static struct resource kirkwood_xor0_shared_resources[] = {
430 {
431 .name = "xor 0 low",
432 .start = XOR0_PHYS_BASE,
433 .end = XOR0_PHYS_BASE + 0xff,
434 .flags = IORESOURCE_MEM,
435 }, {
436 .name = "xor 0 high",
437 .start = XOR0_HIGH_PHYS_BASE,
438 .end = XOR0_HIGH_PHYS_BASE + 0xff,
439 .flags = IORESOURCE_MEM,
440 },
441};
442
443static struct platform_device kirkwood_xor0_shared = {
444 .name = MV_XOR_SHARED_NAME,
445 .id = 0,
446 .dev = {
447 .platform_data = &kirkwood_xor_shared_data,
448 },
449 .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
450 .resource = kirkwood_xor0_shared_resources,
451};
452
453static struct resource kirkwood_xor00_resources[] = {
454 [0] = {
455 .start = IRQ_KIRKWOOD_XOR_00,
456 .end = IRQ_KIRKWOOD_XOR_00,
457 .flags = IORESOURCE_IRQ,
458 },
459};
460
461static struct mv_xor_platform_data kirkwood_xor00_data = {
462 .shared = &kirkwood_xor0_shared,
463 .hw_id = 0,
464 .pool_size = PAGE_SIZE,
465};
466
467static struct platform_device kirkwood_xor00_channel = {
468 .name = MV_XOR_NAME,
469 .id = 0,
470 .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
471 .resource = kirkwood_xor00_resources,
472 .dev = {
473 .dma_mask = &kirkwood_xor_dmamask,
474 .coherent_dma_mask = DMA_64BIT_MASK,
475 .platform_data = (void *)&kirkwood_xor00_data,
476 },
477};
478
479static struct resource kirkwood_xor01_resources[] = {
480 [0] = {
481 .start = IRQ_KIRKWOOD_XOR_01,
482 .end = IRQ_KIRKWOOD_XOR_01,
483 .flags = IORESOURCE_IRQ,
484 },
485};
486
487static struct mv_xor_platform_data kirkwood_xor01_data = {
488 .shared = &kirkwood_xor0_shared,
489 .hw_id = 1,
490 .pool_size = PAGE_SIZE,
491};
492
493static struct platform_device kirkwood_xor01_channel = {
494 .name = MV_XOR_NAME,
495 .id = 1,
496 .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
497 .resource = kirkwood_xor01_resources,
498 .dev = {
499 .dma_mask = &kirkwood_xor_dmamask,
500 .coherent_dma_mask = DMA_64BIT_MASK,
501 .platform_data = (void *)&kirkwood_xor01_data,
502 },
503};
504
505void __init kirkwood_xor0_init(void)
506{
507 platform_device_register(&kirkwood_xor0_shared);
508
509 /*
510 * two engines can't do memset simultaneously, this limitation
511 * satisfied by removing memset support from one of the engines.
512 */
513 dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
514 dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
515 platform_device_register(&kirkwood_xor00_channel);
516
517 dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
518 dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
519 dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
520 platform_device_register(&kirkwood_xor01_channel);
521}
522
523
524/*****************************************************************************
525 * XOR1
526 ****************************************************************************/
527static struct resource kirkwood_xor1_shared_resources[] = {
528 {
529 .name = "xor 1 low",
530 .start = XOR1_PHYS_BASE,
531 .end = XOR1_PHYS_BASE + 0xff,
532 .flags = IORESOURCE_MEM,
533 }, {
534 .name = "xor 1 high",
535 .start = XOR1_HIGH_PHYS_BASE,
536 .end = XOR1_HIGH_PHYS_BASE + 0xff,
537 .flags = IORESOURCE_MEM,
538 },
539};
540
541static struct platform_device kirkwood_xor1_shared = {
542 .name = MV_XOR_SHARED_NAME,
543 .id = 1,
544 .dev = {
545 .platform_data = &kirkwood_xor_shared_data,
546 },
547 .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
548 .resource = kirkwood_xor1_shared_resources,
549};
550
551static struct resource kirkwood_xor10_resources[] = {
552 [0] = {
553 .start = IRQ_KIRKWOOD_XOR_10,
554 .end = IRQ_KIRKWOOD_XOR_10,
555 .flags = IORESOURCE_IRQ,
556 },
557};
558
559static struct mv_xor_platform_data kirkwood_xor10_data = {
560 .shared = &kirkwood_xor1_shared,
561 .hw_id = 0,
562 .pool_size = PAGE_SIZE,
563};
564
565static struct platform_device kirkwood_xor10_channel = {
566 .name = MV_XOR_NAME,
567 .id = 2,
568 .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
569 .resource = kirkwood_xor10_resources,
570 .dev = {
571 .dma_mask = &kirkwood_xor_dmamask,
572 .coherent_dma_mask = DMA_64BIT_MASK,
573 .platform_data = (void *)&kirkwood_xor10_data,
574 },
575};
576
577static struct resource kirkwood_xor11_resources[] = {
578 [0] = {
579 .start = IRQ_KIRKWOOD_XOR_11,
580 .end = IRQ_KIRKWOOD_XOR_11,
581 .flags = IORESOURCE_IRQ,
582 },
583};
584
585static struct mv_xor_platform_data kirkwood_xor11_data = {
586 .shared = &kirkwood_xor1_shared,
587 .hw_id = 1,
588 .pool_size = PAGE_SIZE,
589};
590
591static struct platform_device kirkwood_xor11_channel = {
592 .name = MV_XOR_NAME,
593 .id = 3,
594 .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
595 .resource = kirkwood_xor11_resources,
596 .dev = {
597 .dma_mask = &kirkwood_xor_dmamask,
598 .coherent_dma_mask = DMA_64BIT_MASK,
599 .platform_data = (void *)&kirkwood_xor11_data,
600 },
601};
602
603void __init kirkwood_xor1_init(void)
604{
605 platform_device_register(&kirkwood_xor1_shared);
606
607 /*
608 * two engines can't do memset simultaneously, this limitation
609 * satisfied by removing memset support from one of the engines.
610 */
611 dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
612 dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
613 platform_device_register(&kirkwood_xor10_channel);
614
615 dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
616 dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
617 dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
618 platform_device_register(&kirkwood_xor11_channel);
619}
620
621
622/*****************************************************************************
Saeed Bishara651c74c2008-06-22 22:45:06 +0200623 * Time handling
624 ****************************************************************************/
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200625int kirkwood_tclk;
626
627int __init kirkwood_find_tclk(void)
628{
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300629 u32 dev, rev;
630
631 kirkwood_pcie_id(&dev, &rev);
632 if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
633 return 200000000;
634
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200635 return 166666667;
636}
637
Saeed Bishara651c74c2008-06-22 22:45:06 +0200638static void kirkwood_timer_init(void)
639{
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200640 kirkwood_tclk = kirkwood_find_tclk();
641 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
Saeed Bishara651c74c2008-06-22 22:45:06 +0200642}
643
644struct sys_timer kirkwood_timer = {
645 .init = kirkwood_timer_init,
646};
647
648
649/*****************************************************************************
650 * General
651 ****************************************************************************/
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300652/*
653 * Identify device ID and revision.
654 */
Saeed Bishara651c74c2008-06-22 22:45:06 +0200655static char * __init kirkwood_id(void)
656{
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300657 u32 dev, rev;
Saeed Bishara651c74c2008-06-22 22:45:06 +0200658
Ronen Shitritb2b3dc22008-09-15 10:40:35 +0300659 kirkwood_pcie_id(&dev, &rev);
660
661 if (dev == MV88F6281_DEV_ID) {
662 if (rev == MV88F6281_REV_Z0)
663 return "MV88F6281-Z0";
664 else if (rev == MV88F6281_REV_A0)
665 return "MV88F6281-A0";
666 else
667 return "MV88F6281-Rev-Unsupported";
668 } else if (dev == MV88F6192_DEV_ID) {
669 if (rev == MV88F6192_REV_Z0)
670 return "MV88F6192-Z0";
671 else if (rev == MV88F6192_REV_A0)
672 return "MV88F6192-A0";
673 else
674 return "MV88F6192-Rev-Unsupported";
675 } else if (dev == MV88F6180_DEV_ID) {
676 if (rev == MV88F6180_REV_A0)
677 return "MV88F6180-Rev-A0";
678 else
679 return "MV88F6180-Rev-Unsupported";
680 } else {
681 return "Device-Unknown";
682 }
Saeed Bishara651c74c2008-06-22 22:45:06 +0200683}
684
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300685static void __init kirkwood_l2_init(void)
Saeed Bishara13387602008-06-23 01:05:08 -1100686{
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300687#ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
688 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
689 feroceon_l2_init(1);
690#else
691 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
692 feroceon_l2_init(0);
693#endif
Saeed Bishara13387602008-06-23 01:05:08 -1100694}
695
Saeed Bishara651c74c2008-06-22 22:45:06 +0200696void __init kirkwood_init(void)
697{
698 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
Ronen Shitrit79d4dd72008-09-15 00:56:38 +0200699 kirkwood_id(), kirkwood_tclk);
700 kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
701 kirkwood_spi_plat_data.tclk = kirkwood_tclk;
702 kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
703 kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
Saeed Bishara651c74c2008-06-22 22:45:06 +0200704
705 kirkwood_setup_cpu_mbus();
706
707#ifdef CONFIG_CACHE_FEROCEON_L2
Ronen Shitrit4360bb42008-09-23 15:28:10 +0300708 kirkwood_l2_init();
Saeed Bishara651c74c2008-06-22 22:45:06 +0200709#endif
710}