Commit | Line | Data |
---|---|---|
651c74c7 SB |
1 | /* |
2 | * arch/arm/mach-kirkwood/common.c | |
3 | * | |
4 | * Core functions for Marvell Kirkwood SoCs | |
5 | * | |
6 | * This file is licensed under the terms of the GNU General Public | |
7 | * License version 2. This program is licensed "as is" without any | |
8 | * warranty of any kind, whether express or implied. | |
9 | */ | |
10 | ||
11 | #include <linux/kernel.h> | |
12 | #include <linux/init.h> | |
13 | #include <linux/platform_device.h> | |
14 | #include <linux/serial_8250.h> | |
15 | #include <linux/mbus.h> | |
16 | #include <linux/mv643xx_eth.h> | |
17 | #include <linux/ata_platform.h> | |
18365d18 | 18 | #include <linux/spi/orion_spi.h> |
dcf1cece | 19 | #include <net/dsa.h> |
651c74c7 SB |
20 | #include <asm/page.h> |
21 | #include <asm/timex.h> | |
22 | #include <asm/mach/map.h> | |
23 | #include <asm/mach/time.h> | |
a09e64fb | 24 | #include <mach/kirkwood.h> |
6f088f1d LB |
25 | #include <plat/cache-feroceon-l2.h> |
26 | #include <plat/ehci-orion.h> | |
09c0ed2e | 27 | #include <plat/mv_xor.h> |
6f088f1d LB |
28 | #include <plat/orion_nand.h> |
29 | #include <plat/time.h> | |
651c74c7 SB |
30 | #include "common.h" |
31 | ||
32 | /***************************************************************************** | |
33 | * I/O Address Mapping | |
34 | ****************************************************************************/ | |
35 | static 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 | ||
49 | void __init kirkwood_map_io(void) | |
50 | { | |
51 | iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc)); | |
52 | } | |
53 | ||
54 | ||
55 | /***************************************************************************** | |
56 | * EHCI | |
57 | ****************************************************************************/ | |
58 | static struct orion_ehci_data kirkwood_ehci_data = { | |
59 | .dram = &kirkwood_mbus_dram_info, | |
fb6f5529 | 60 | .phy_version = EHCI_PHY_NA, |
651c74c7 SB |
61 | }; |
62 | ||
63 | static u64 ehci_dmamask = 0xffffffffUL; | |
64 | ||
65 | ||
66 | /***************************************************************************** | |
67 | * EHCI0 | |
68 | ****************************************************************************/ | |
69 | static 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 | ||
81 | static 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 | ||
93 | void __init kirkwood_ehci_init(void) | |
94 | { | |
95 | platform_device_register(&kirkwood_ehci); | |
96 | } | |
97 | ||
98 | ||
99 | /***************************************************************************** | |
100 | * GE00 | |
101 | ****************************************************************************/ | |
102 | struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = { | |
651c74c7 SB |
103 | .dram = &kirkwood_mbus_dram_info, |
104 | }; | |
105 | ||
106 | static 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, | |
144f814a LB |
112 | }, { |
113 | .name = "ge00 err irq", | |
114 | .start = IRQ_KIRKWOOD_GE00_ERR, | |
115 | .end = IRQ_KIRKWOOD_GE00_ERR, | |
116 | .flags = IORESOURCE_IRQ, | |
651c74c7 SB |
117 | }, |
118 | }; | |
119 | ||
120 | static 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 | }, | |
144f814a | 126 | .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources), |
651c74c7 SB |
127 | .resource = kirkwood_ge00_shared_resources, |
128 | }; | |
129 | ||
130 | static 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 | ||
139 | static struct platform_device kirkwood_ge00 = { | |
140 | .name = MV643XX_ETH_NAME, | |
141 | .id = 0, | |
142 | .num_resources = 1, | |
143 | .resource = kirkwood_ge00_resources, | |
144 | }; | |
145 | ||
146 | void __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 | ||
dcf1cece LB |
156 | /***************************************************************************** |
157 | * Ethernet switch | |
158 | ****************************************************************************/ | |
159 | static struct resource kirkwood_switch_resources[] = { | |
160 | { | |
161 | .start = 0, | |
162 | .end = 0, | |
163 | .flags = IORESOURCE_IRQ, | |
164 | }, | |
165 | }; | |
166 | ||
167 | static struct platform_device kirkwood_switch_device = { | |
168 | .name = "dsa", | |
169 | .id = 0, | |
170 | .num_resources = 0, | |
171 | .resource = kirkwood_switch_resources, | |
172 | }; | |
173 | ||
174 | void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq) | |
175 | { | |
176 | if (irq != NO_IRQ) { | |
177 | kirkwood_switch_resources[0].start = irq; | |
178 | kirkwood_switch_resources[0].end = irq; | |
179 | kirkwood_switch_device.num_resources = 1; | |
180 | } | |
181 | ||
182 | d->mii_bus = &kirkwood_ge00_shared.dev; | |
183 | d->netdev = &kirkwood_ge00.dev; | |
184 | kirkwood_switch_device.dev.platform_data = d; | |
185 | ||
186 | platform_device_register(&kirkwood_switch_device); | |
187 | } | |
188 | ||
189 | ||
651c74c7 SB |
190 | /***************************************************************************** |
191 | * SoC RTC | |
192 | ****************************************************************************/ | |
193 | static struct resource kirkwood_rtc_resource = { | |
194 | .start = RTC_PHYS_BASE, | |
195 | .end = RTC_PHYS_BASE + SZ_16 - 1, | |
196 | .flags = IORESOURCE_MEM, | |
197 | }; | |
198 | ||
199 | void __init kirkwood_rtc_init(void) | |
200 | { | |
201 | platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1); | |
202 | } | |
203 | ||
204 | ||
205 | /***************************************************************************** | |
206 | * SATA | |
207 | ****************************************************************************/ | |
208 | static struct resource kirkwood_sata_resources[] = { | |
209 | { | |
210 | .name = "sata base", | |
211 | .start = SATA_PHYS_BASE, | |
212 | .end = SATA_PHYS_BASE + 0x5000 - 1, | |
213 | .flags = IORESOURCE_MEM, | |
214 | }, { | |
215 | .name = "sata irq", | |
216 | .start = IRQ_KIRKWOOD_SATA, | |
217 | .end = IRQ_KIRKWOOD_SATA, | |
218 | .flags = IORESOURCE_IRQ, | |
219 | }, | |
220 | }; | |
221 | ||
222 | static struct platform_device kirkwood_sata = { | |
223 | .name = "sata_mv", | |
224 | .id = 0, | |
225 | .dev = { | |
226 | .coherent_dma_mask = 0xffffffff, | |
227 | }, | |
228 | .num_resources = ARRAY_SIZE(kirkwood_sata_resources), | |
229 | .resource = kirkwood_sata_resources, | |
230 | }; | |
231 | ||
232 | void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data) | |
233 | { | |
234 | sata_data->dram = &kirkwood_mbus_dram_info; | |
235 | kirkwood_sata.dev.platform_data = sata_data; | |
236 | platform_device_register(&kirkwood_sata); | |
237 | } | |
238 | ||
239 | ||
18365d18 LB |
240 | /***************************************************************************** |
241 | * SPI | |
242 | ****************************************************************************/ | |
243 | static struct orion_spi_info kirkwood_spi_plat_data = { | |
18365d18 LB |
244 | }; |
245 | ||
246 | static struct resource kirkwood_spi_resources[] = { | |
247 | { | |
248 | .start = SPI_PHYS_BASE, | |
249 | .end = SPI_PHYS_BASE + SZ_512 - 1, | |
250 | .flags = IORESOURCE_MEM, | |
251 | }, | |
252 | }; | |
253 | ||
254 | static struct platform_device kirkwood_spi = { | |
255 | .name = "orion_spi", | |
256 | .id = 0, | |
257 | .resource = kirkwood_spi_resources, | |
258 | .dev = { | |
259 | .platform_data = &kirkwood_spi_plat_data, | |
260 | }, | |
261 | .num_resources = ARRAY_SIZE(kirkwood_spi_resources), | |
262 | }; | |
263 | ||
264 | void __init kirkwood_spi_init() | |
265 | { | |
266 | platform_device_register(&kirkwood_spi); | |
267 | } | |
268 | ||
269 | ||
651c74c7 SB |
270 | /***************************************************************************** |
271 | * UART0 | |
272 | ****************************************************************************/ | |
273 | static struct plat_serial8250_port kirkwood_uart0_data[] = { | |
274 | { | |
275 | .mapbase = UART0_PHYS_BASE, | |
276 | .membase = (char *)UART0_VIRT_BASE, | |
277 | .irq = IRQ_KIRKWOOD_UART_0, | |
278 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | |
279 | .iotype = UPIO_MEM, | |
280 | .regshift = 2, | |
79d4dd77 | 281 | .uartclk = 0, |
651c74c7 SB |
282 | }, { |
283 | }, | |
284 | }; | |
285 | ||
286 | static struct resource kirkwood_uart0_resources[] = { | |
287 | { | |
288 | .start = UART0_PHYS_BASE, | |
289 | .end = UART0_PHYS_BASE + 0xff, | |
290 | .flags = IORESOURCE_MEM, | |
291 | }, { | |
292 | .start = IRQ_KIRKWOOD_UART_0, | |
293 | .end = IRQ_KIRKWOOD_UART_0, | |
294 | .flags = IORESOURCE_IRQ, | |
295 | }, | |
296 | }; | |
297 | ||
298 | static struct platform_device kirkwood_uart0 = { | |
299 | .name = "serial8250", | |
300 | .id = 0, | |
301 | .dev = { | |
302 | .platform_data = kirkwood_uart0_data, | |
303 | }, | |
304 | .resource = kirkwood_uart0_resources, | |
305 | .num_resources = ARRAY_SIZE(kirkwood_uart0_resources), | |
306 | }; | |
307 | ||
308 | void __init kirkwood_uart0_init(void) | |
309 | { | |
310 | platform_device_register(&kirkwood_uart0); | |
311 | } | |
312 | ||
313 | ||
314 | /***************************************************************************** | |
315 | * UART1 | |
316 | ****************************************************************************/ | |
317 | static struct plat_serial8250_port kirkwood_uart1_data[] = { | |
318 | { | |
319 | .mapbase = UART1_PHYS_BASE, | |
320 | .membase = (char *)UART1_VIRT_BASE, | |
321 | .irq = IRQ_KIRKWOOD_UART_1, | |
322 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | |
323 | .iotype = UPIO_MEM, | |
324 | .regshift = 2, | |
79d4dd77 | 325 | .uartclk = 0, |
651c74c7 SB |
326 | }, { |
327 | }, | |
328 | }; | |
329 | ||
330 | static struct resource kirkwood_uart1_resources[] = { | |
331 | { | |
332 | .start = UART1_PHYS_BASE, | |
333 | .end = UART1_PHYS_BASE + 0xff, | |
334 | .flags = IORESOURCE_MEM, | |
335 | }, { | |
336 | .start = IRQ_KIRKWOOD_UART_1, | |
337 | .end = IRQ_KIRKWOOD_UART_1, | |
338 | .flags = IORESOURCE_IRQ, | |
339 | }, | |
340 | }; | |
341 | ||
342 | static struct platform_device kirkwood_uart1 = { | |
343 | .name = "serial8250", | |
344 | .id = 1, | |
345 | .dev = { | |
346 | .platform_data = kirkwood_uart1_data, | |
347 | }, | |
348 | .resource = kirkwood_uart1_resources, | |
349 | .num_resources = ARRAY_SIZE(kirkwood_uart1_resources), | |
350 | }; | |
351 | ||
352 | void __init kirkwood_uart1_init(void) | |
353 | { | |
354 | platform_device_register(&kirkwood_uart1); | |
355 | } | |
356 | ||
357 | ||
09c0ed2e SB |
358 | /***************************************************************************** |
359 | * XOR | |
360 | ****************************************************************************/ | |
361 | static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = { | |
362 | .dram = &kirkwood_mbus_dram_info, | |
363 | }; | |
364 | ||
365 | static u64 kirkwood_xor_dmamask = DMA_32BIT_MASK; | |
366 | ||
367 | ||
368 | /***************************************************************************** | |
369 | * XOR0 | |
370 | ****************************************************************************/ | |
371 | static struct resource kirkwood_xor0_shared_resources[] = { | |
372 | { | |
373 | .name = "xor 0 low", | |
374 | .start = XOR0_PHYS_BASE, | |
375 | .end = XOR0_PHYS_BASE + 0xff, | |
376 | .flags = IORESOURCE_MEM, | |
377 | }, { | |
378 | .name = "xor 0 high", | |
379 | .start = XOR0_HIGH_PHYS_BASE, | |
380 | .end = XOR0_HIGH_PHYS_BASE + 0xff, | |
381 | .flags = IORESOURCE_MEM, | |
382 | }, | |
383 | }; | |
384 | ||
385 | static struct platform_device kirkwood_xor0_shared = { | |
386 | .name = MV_XOR_SHARED_NAME, | |
387 | .id = 0, | |
388 | .dev = { | |
389 | .platform_data = &kirkwood_xor_shared_data, | |
390 | }, | |
391 | .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources), | |
392 | .resource = kirkwood_xor0_shared_resources, | |
393 | }; | |
394 | ||
395 | static struct resource kirkwood_xor00_resources[] = { | |
396 | [0] = { | |
397 | .start = IRQ_KIRKWOOD_XOR_00, | |
398 | .end = IRQ_KIRKWOOD_XOR_00, | |
399 | .flags = IORESOURCE_IRQ, | |
400 | }, | |
401 | }; | |
402 | ||
403 | static struct mv_xor_platform_data kirkwood_xor00_data = { | |
404 | .shared = &kirkwood_xor0_shared, | |
405 | .hw_id = 0, | |
406 | .pool_size = PAGE_SIZE, | |
407 | }; | |
408 | ||
409 | static struct platform_device kirkwood_xor00_channel = { | |
410 | .name = MV_XOR_NAME, | |
411 | .id = 0, | |
412 | .num_resources = ARRAY_SIZE(kirkwood_xor00_resources), | |
413 | .resource = kirkwood_xor00_resources, | |
414 | .dev = { | |
415 | .dma_mask = &kirkwood_xor_dmamask, | |
416 | .coherent_dma_mask = DMA_64BIT_MASK, | |
417 | .platform_data = (void *)&kirkwood_xor00_data, | |
418 | }, | |
419 | }; | |
420 | ||
421 | static struct resource kirkwood_xor01_resources[] = { | |
422 | [0] = { | |
423 | .start = IRQ_KIRKWOOD_XOR_01, | |
424 | .end = IRQ_KIRKWOOD_XOR_01, | |
425 | .flags = IORESOURCE_IRQ, | |
426 | }, | |
427 | }; | |
428 | ||
429 | static struct mv_xor_platform_data kirkwood_xor01_data = { | |
430 | .shared = &kirkwood_xor0_shared, | |
431 | .hw_id = 1, | |
432 | .pool_size = PAGE_SIZE, | |
433 | }; | |
434 | ||
435 | static struct platform_device kirkwood_xor01_channel = { | |
436 | .name = MV_XOR_NAME, | |
437 | .id = 1, | |
438 | .num_resources = ARRAY_SIZE(kirkwood_xor01_resources), | |
439 | .resource = kirkwood_xor01_resources, | |
440 | .dev = { | |
441 | .dma_mask = &kirkwood_xor_dmamask, | |
442 | .coherent_dma_mask = DMA_64BIT_MASK, | |
443 | .platform_data = (void *)&kirkwood_xor01_data, | |
444 | }, | |
445 | }; | |
446 | ||
447 | void __init kirkwood_xor0_init(void) | |
448 | { | |
449 | platform_device_register(&kirkwood_xor0_shared); | |
450 | ||
451 | /* | |
452 | * two engines can't do memset simultaneously, this limitation | |
453 | * satisfied by removing memset support from one of the engines. | |
454 | */ | |
455 | dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask); | |
456 | dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask); | |
457 | platform_device_register(&kirkwood_xor00_channel); | |
458 | ||
459 | dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask); | |
460 | dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask); | |
461 | dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask); | |
462 | platform_device_register(&kirkwood_xor01_channel); | |
463 | } | |
464 | ||
465 | ||
466 | /***************************************************************************** | |
467 | * XOR1 | |
468 | ****************************************************************************/ | |
469 | static struct resource kirkwood_xor1_shared_resources[] = { | |
470 | { | |
471 | .name = "xor 1 low", | |
472 | .start = XOR1_PHYS_BASE, | |
473 | .end = XOR1_PHYS_BASE + 0xff, | |
474 | .flags = IORESOURCE_MEM, | |
475 | }, { | |
476 | .name = "xor 1 high", | |
477 | .start = XOR1_HIGH_PHYS_BASE, | |
478 | .end = XOR1_HIGH_PHYS_BASE + 0xff, | |
479 | .flags = IORESOURCE_MEM, | |
480 | }, | |
481 | }; | |
482 | ||
483 | static struct platform_device kirkwood_xor1_shared = { | |
484 | .name = MV_XOR_SHARED_NAME, | |
485 | .id = 1, | |
486 | .dev = { | |
487 | .platform_data = &kirkwood_xor_shared_data, | |
488 | }, | |
489 | .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources), | |
490 | .resource = kirkwood_xor1_shared_resources, | |
491 | }; | |
492 | ||
493 | static struct resource kirkwood_xor10_resources[] = { | |
494 | [0] = { | |
495 | .start = IRQ_KIRKWOOD_XOR_10, | |
496 | .end = IRQ_KIRKWOOD_XOR_10, | |
497 | .flags = IORESOURCE_IRQ, | |
498 | }, | |
499 | }; | |
500 | ||
501 | static struct mv_xor_platform_data kirkwood_xor10_data = { | |
502 | .shared = &kirkwood_xor1_shared, | |
503 | .hw_id = 0, | |
504 | .pool_size = PAGE_SIZE, | |
505 | }; | |
506 | ||
507 | static struct platform_device kirkwood_xor10_channel = { | |
508 | .name = MV_XOR_NAME, | |
509 | .id = 2, | |
510 | .num_resources = ARRAY_SIZE(kirkwood_xor10_resources), | |
511 | .resource = kirkwood_xor10_resources, | |
512 | .dev = { | |
513 | .dma_mask = &kirkwood_xor_dmamask, | |
514 | .coherent_dma_mask = DMA_64BIT_MASK, | |
515 | .platform_data = (void *)&kirkwood_xor10_data, | |
516 | }, | |
517 | }; | |
518 | ||
519 | static struct resource kirkwood_xor11_resources[] = { | |
520 | [0] = { | |
521 | .start = IRQ_KIRKWOOD_XOR_11, | |
522 | .end = IRQ_KIRKWOOD_XOR_11, | |
523 | .flags = IORESOURCE_IRQ, | |
524 | }, | |
525 | }; | |
526 | ||
527 | static struct mv_xor_platform_data kirkwood_xor11_data = { | |
528 | .shared = &kirkwood_xor1_shared, | |
529 | .hw_id = 1, | |
530 | .pool_size = PAGE_SIZE, | |
531 | }; | |
532 | ||
533 | static struct platform_device kirkwood_xor11_channel = { | |
534 | .name = MV_XOR_NAME, | |
535 | .id = 3, | |
536 | .num_resources = ARRAY_SIZE(kirkwood_xor11_resources), | |
537 | .resource = kirkwood_xor11_resources, | |
538 | .dev = { | |
539 | .dma_mask = &kirkwood_xor_dmamask, | |
540 | .coherent_dma_mask = DMA_64BIT_MASK, | |
541 | .platform_data = (void *)&kirkwood_xor11_data, | |
542 | }, | |
543 | }; | |
544 | ||
545 | void __init kirkwood_xor1_init(void) | |
546 | { | |
547 | platform_device_register(&kirkwood_xor1_shared); | |
548 | ||
549 | /* | |
550 | * two engines can't do memset simultaneously, this limitation | |
551 | * satisfied by removing memset support from one of the engines. | |
552 | */ | |
553 | dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask); | |
554 | dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask); | |
555 | platform_device_register(&kirkwood_xor10_channel); | |
556 | ||
557 | dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask); | |
558 | dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask); | |
559 | dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask); | |
560 | platform_device_register(&kirkwood_xor11_channel); | |
561 | } | |
562 | ||
563 | ||
651c74c7 SB |
564 | /***************************************************************************** |
565 | * Time handling | |
566 | ****************************************************************************/ | |
79d4dd77 RS |
567 | int kirkwood_tclk; |
568 | ||
569 | int __init kirkwood_find_tclk(void) | |
570 | { | |
b2b3dc2f RS |
571 | u32 dev, rev; |
572 | ||
573 | kirkwood_pcie_id(&dev, &rev); | |
574 | if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0) | |
575 | return 200000000; | |
576 | ||
79d4dd77 RS |
577 | return 166666667; |
578 | } | |
579 | ||
651c74c7 SB |
580 | static void kirkwood_timer_init(void) |
581 | { | |
79d4dd77 RS |
582 | kirkwood_tclk = kirkwood_find_tclk(); |
583 | orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk); | |
651c74c7 SB |
584 | } |
585 | ||
586 | struct sys_timer kirkwood_timer = { | |
587 | .init = kirkwood_timer_init, | |
588 | }; | |
589 | ||
590 | ||
591 | /***************************************************************************** | |
592 | * General | |
593 | ****************************************************************************/ | |
b2b3dc2f RS |
594 | /* |
595 | * Identify device ID and revision. | |
596 | */ | |
651c74c7 SB |
597 | static char * __init kirkwood_id(void) |
598 | { | |
b2b3dc2f RS |
599 | u32 dev, rev; |
600 | ||
601 | kirkwood_pcie_id(&dev, &rev); | |
602 | ||
603 | if (dev == MV88F6281_DEV_ID) { | |
604 | if (rev == MV88F6281_REV_Z0) | |
605 | return "MV88F6281-Z0"; | |
606 | else if (rev == MV88F6281_REV_A0) | |
607 | return "MV88F6281-A0"; | |
608 | else | |
609 | return "MV88F6281-Rev-Unsupported"; | |
610 | } else if (dev == MV88F6192_DEV_ID) { | |
611 | if (rev == MV88F6192_REV_Z0) | |
612 | return "MV88F6192-Z0"; | |
613 | else if (rev == MV88F6192_REV_A0) | |
614 | return "MV88F6192-A0"; | |
615 | else | |
616 | return "MV88F6192-Rev-Unsupported"; | |
617 | } else if (dev == MV88F6180_DEV_ID) { | |
618 | if (rev == MV88F6180_REV_A0) | |
619 | return "MV88F6180-Rev-A0"; | |
620 | else | |
621 | return "MV88F6180-Rev-Unsupported"; | |
622 | } else { | |
623 | return "Device-Unknown"; | |
651c74c7 | 624 | } |
651c74c7 SB |
625 | } |
626 | ||
4360bb41 | 627 | static void __init kirkwood_l2_init(void) |
13387603 | 628 | { |
4360bb41 RS |
629 | #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH |
630 | writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG); | |
631 | feroceon_l2_init(1); | |
632 | #else | |
633 | writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG); | |
634 | feroceon_l2_init(0); | |
635 | #endif | |
13387603 SB |
636 | } |
637 | ||
651c74c7 SB |
638 | void __init kirkwood_init(void) |
639 | { | |
640 | printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n", | |
79d4dd77 RS |
641 | kirkwood_id(), kirkwood_tclk); |
642 | kirkwood_ge00_shared_data.t_clk = kirkwood_tclk; | |
643 | kirkwood_spi_plat_data.tclk = kirkwood_tclk; | |
644 | kirkwood_uart0_data[0].uartclk = kirkwood_tclk; | |
645 | kirkwood_uart1_data[0].uartclk = kirkwood_tclk; | |
651c74c7 SB |
646 | |
647 | kirkwood_setup_cpu_mbus(); | |
648 | ||
649 | #ifdef CONFIG_CACHE_FEROCEON_L2 | |
4360bb41 | 650 | kirkwood_l2_init(); |
651c74c7 SB |
651 | #endif |
652 | } |