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> | |
8235ee00 | 27 | #include <plat/mvsdio.h> |
09c0ed2e | 28 | #include <plat/mv_xor.h> |
6f088f1d LB |
29 | #include <plat/orion_nand.h> |
30 | #include <plat/time.h> | |
651c74c7 SB |
31 | #include "common.h" |
32 | ||
33 | /***************************************************************************** | |
34 | * I/O Address Mapping | |
35 | ****************************************************************************/ | |
36 | static struct map_desc kirkwood_io_desc[] __initdata = { | |
37 | { | |
38 | .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE, | |
39 | .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE), | |
40 | .length = KIRKWOOD_PCIE_IO_SIZE, | |
41 | .type = MT_DEVICE, | |
42 | }, { | |
43 | .virtual = KIRKWOOD_REGS_VIRT_BASE, | |
44 | .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE), | |
45 | .length = KIRKWOOD_REGS_SIZE, | |
46 | .type = MT_DEVICE, | |
47 | }, | |
48 | }; | |
49 | ||
50 | void __init kirkwood_map_io(void) | |
51 | { | |
52 | iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc)); | |
53 | } | |
54 | ||
55 | ||
56 | /***************************************************************************** | |
57 | * EHCI | |
58 | ****************************************************************************/ | |
59 | static struct orion_ehci_data kirkwood_ehci_data = { | |
60 | .dram = &kirkwood_mbus_dram_info, | |
fb6f5529 | 61 | .phy_version = EHCI_PHY_NA, |
651c74c7 SB |
62 | }; |
63 | ||
64 | static u64 ehci_dmamask = 0xffffffffUL; | |
65 | ||
66 | ||
67 | /***************************************************************************** | |
68 | * EHCI0 | |
69 | ****************************************************************************/ | |
70 | static struct resource kirkwood_ehci_resources[] = { | |
71 | { | |
72 | .start = USB_PHYS_BASE, | |
73 | .end = USB_PHYS_BASE + 0x0fff, | |
74 | .flags = IORESOURCE_MEM, | |
75 | }, { | |
76 | .start = IRQ_KIRKWOOD_USB, | |
77 | .end = IRQ_KIRKWOOD_USB, | |
78 | .flags = IORESOURCE_IRQ, | |
79 | }, | |
80 | }; | |
81 | ||
82 | static struct platform_device kirkwood_ehci = { | |
83 | .name = "orion-ehci", | |
84 | .id = 0, | |
85 | .dev = { | |
86 | .dma_mask = &ehci_dmamask, | |
87 | .coherent_dma_mask = 0xffffffff, | |
88 | .platform_data = &kirkwood_ehci_data, | |
89 | }, | |
90 | .resource = kirkwood_ehci_resources, | |
91 | .num_resources = ARRAY_SIZE(kirkwood_ehci_resources), | |
92 | }; | |
93 | ||
94 | void __init kirkwood_ehci_init(void) | |
95 | { | |
96 | platform_device_register(&kirkwood_ehci); | |
97 | } | |
98 | ||
99 | ||
100 | /***************************************************************************** | |
101 | * GE00 | |
102 | ****************************************************************************/ | |
103 | struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = { | |
651c74c7 SB |
104 | .dram = &kirkwood_mbus_dram_info, |
105 | }; | |
106 | ||
107 | static struct resource kirkwood_ge00_shared_resources[] = { | |
108 | { | |
109 | .name = "ge00 base", | |
110 | .start = GE00_PHYS_BASE + 0x2000, | |
111 | .end = GE00_PHYS_BASE + 0x3fff, | |
112 | .flags = IORESOURCE_MEM, | |
144f814a LB |
113 | }, { |
114 | .name = "ge00 err irq", | |
115 | .start = IRQ_KIRKWOOD_GE00_ERR, | |
116 | .end = IRQ_KIRKWOOD_GE00_ERR, | |
117 | .flags = IORESOURCE_IRQ, | |
651c74c7 SB |
118 | }, |
119 | }; | |
120 | ||
121 | static struct platform_device kirkwood_ge00_shared = { | |
122 | .name = MV643XX_ETH_SHARED_NAME, | |
123 | .id = 0, | |
124 | .dev = { | |
125 | .platform_data = &kirkwood_ge00_shared_data, | |
126 | }, | |
144f814a | 127 | .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources), |
651c74c7 SB |
128 | .resource = kirkwood_ge00_shared_resources, |
129 | }; | |
130 | ||
131 | static struct resource kirkwood_ge00_resources[] = { | |
132 | { | |
133 | .name = "ge00 irq", | |
134 | .start = IRQ_KIRKWOOD_GE00_SUM, | |
135 | .end = IRQ_KIRKWOOD_GE00_SUM, | |
136 | .flags = IORESOURCE_IRQ, | |
137 | }, | |
138 | }; | |
139 | ||
140 | static struct platform_device kirkwood_ge00 = { | |
141 | .name = MV643XX_ETH_NAME, | |
142 | .id = 0, | |
143 | .num_resources = 1, | |
144 | .resource = kirkwood_ge00_resources, | |
145 | }; | |
146 | ||
147 | void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data) | |
148 | { | |
149 | eth_data->shared = &kirkwood_ge00_shared; | |
150 | kirkwood_ge00.dev.platform_data = eth_data; | |
151 | ||
152 | platform_device_register(&kirkwood_ge00_shared); | |
153 | platform_device_register(&kirkwood_ge00); | |
154 | } | |
155 | ||
156 | ||
d15fb9ef RS |
157 | /***************************************************************************** |
158 | * GE01 | |
159 | ****************************************************************************/ | |
160 | struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data = { | |
161 | .dram = &kirkwood_mbus_dram_info, | |
162 | .shared_smi = &kirkwood_ge00_shared, | |
163 | }; | |
164 | ||
165 | static struct resource kirkwood_ge01_shared_resources[] = { | |
166 | { | |
167 | .name = "ge01 base", | |
168 | .start = GE01_PHYS_BASE + 0x2000, | |
169 | .end = GE01_PHYS_BASE + 0x3fff, | |
170 | .flags = IORESOURCE_MEM, | |
171 | }, { | |
172 | .name = "ge01 err irq", | |
173 | .start = IRQ_KIRKWOOD_GE01_ERR, | |
174 | .end = IRQ_KIRKWOOD_GE01_ERR, | |
175 | .flags = IORESOURCE_IRQ, | |
176 | }, | |
177 | }; | |
178 | ||
179 | static struct platform_device kirkwood_ge01_shared = { | |
180 | .name = MV643XX_ETH_SHARED_NAME, | |
181 | .id = 1, | |
182 | .dev = { | |
183 | .platform_data = &kirkwood_ge01_shared_data, | |
184 | }, | |
185 | .num_resources = ARRAY_SIZE(kirkwood_ge01_shared_resources), | |
186 | .resource = kirkwood_ge01_shared_resources, | |
187 | }; | |
188 | ||
189 | static struct resource kirkwood_ge01_resources[] = { | |
190 | { | |
191 | .name = "ge01 irq", | |
192 | .start = IRQ_KIRKWOOD_GE01_SUM, | |
193 | .end = IRQ_KIRKWOOD_GE01_SUM, | |
194 | .flags = IORESOURCE_IRQ, | |
195 | }, | |
196 | }; | |
197 | ||
198 | static struct platform_device kirkwood_ge01 = { | |
199 | .name = MV643XX_ETH_NAME, | |
200 | .id = 1, | |
201 | .num_resources = 1, | |
202 | .resource = kirkwood_ge01_resources, | |
203 | }; | |
204 | ||
205 | void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data) | |
206 | { | |
207 | eth_data->shared = &kirkwood_ge01_shared; | |
208 | kirkwood_ge01.dev.platform_data = eth_data; | |
209 | ||
210 | platform_device_register(&kirkwood_ge01_shared); | |
211 | platform_device_register(&kirkwood_ge01); | |
212 | } | |
213 | ||
214 | ||
dcf1cece LB |
215 | /***************************************************************************** |
216 | * Ethernet switch | |
217 | ****************************************************************************/ | |
218 | static struct resource kirkwood_switch_resources[] = { | |
219 | { | |
220 | .start = 0, | |
221 | .end = 0, | |
222 | .flags = IORESOURCE_IRQ, | |
223 | }, | |
224 | }; | |
225 | ||
226 | static struct platform_device kirkwood_switch_device = { | |
227 | .name = "dsa", | |
228 | .id = 0, | |
229 | .num_resources = 0, | |
230 | .resource = kirkwood_switch_resources, | |
231 | }; | |
232 | ||
233 | void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq) | |
234 | { | |
235 | if (irq != NO_IRQ) { | |
236 | kirkwood_switch_resources[0].start = irq; | |
237 | kirkwood_switch_resources[0].end = irq; | |
238 | kirkwood_switch_device.num_resources = 1; | |
239 | } | |
240 | ||
241 | d->mii_bus = &kirkwood_ge00_shared.dev; | |
242 | d->netdev = &kirkwood_ge00.dev; | |
243 | kirkwood_switch_device.dev.platform_data = d; | |
244 | ||
245 | platform_device_register(&kirkwood_switch_device); | |
246 | } | |
247 | ||
248 | ||
651c74c7 SB |
249 | /***************************************************************************** |
250 | * SoC RTC | |
251 | ****************************************************************************/ | |
252 | static struct resource kirkwood_rtc_resource = { | |
253 | .start = RTC_PHYS_BASE, | |
254 | .end = RTC_PHYS_BASE + SZ_16 - 1, | |
255 | .flags = IORESOURCE_MEM, | |
256 | }; | |
257 | ||
258 | void __init kirkwood_rtc_init(void) | |
259 | { | |
260 | platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1); | |
261 | } | |
262 | ||
263 | ||
264 | /***************************************************************************** | |
265 | * SATA | |
266 | ****************************************************************************/ | |
267 | static struct resource kirkwood_sata_resources[] = { | |
268 | { | |
269 | .name = "sata base", | |
270 | .start = SATA_PHYS_BASE, | |
271 | .end = SATA_PHYS_BASE + 0x5000 - 1, | |
272 | .flags = IORESOURCE_MEM, | |
273 | }, { | |
274 | .name = "sata irq", | |
275 | .start = IRQ_KIRKWOOD_SATA, | |
276 | .end = IRQ_KIRKWOOD_SATA, | |
277 | .flags = IORESOURCE_IRQ, | |
278 | }, | |
279 | }; | |
280 | ||
281 | static struct platform_device kirkwood_sata = { | |
282 | .name = "sata_mv", | |
283 | .id = 0, | |
284 | .dev = { | |
285 | .coherent_dma_mask = 0xffffffff, | |
286 | }, | |
287 | .num_resources = ARRAY_SIZE(kirkwood_sata_resources), | |
288 | .resource = kirkwood_sata_resources, | |
289 | }; | |
290 | ||
291 | void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data) | |
292 | { | |
293 | sata_data->dram = &kirkwood_mbus_dram_info; | |
294 | kirkwood_sata.dev.platform_data = sata_data; | |
295 | platform_device_register(&kirkwood_sata); | |
296 | } | |
297 | ||
298 | ||
8235ee00 NP |
299 | /***************************************************************************** |
300 | * SD/SDIO/MMC | |
301 | ****************************************************************************/ | |
302 | static struct resource mvsdio_resources[] = { | |
303 | [0] = { | |
304 | .start = SDIO_PHYS_BASE, | |
305 | .end = SDIO_PHYS_BASE + SZ_1K - 1, | |
306 | .flags = IORESOURCE_MEM, | |
307 | }, | |
308 | [1] = { | |
309 | .start = IRQ_KIRKWOOD_SDIO, | |
310 | .end = IRQ_KIRKWOOD_SDIO, | |
311 | .flags = IORESOURCE_IRQ, | |
312 | }, | |
313 | }; | |
314 | ||
315 | static u64 mvsdio_dmamask = 0xffffffffUL; | |
316 | ||
317 | static struct platform_device kirkwood_sdio = { | |
318 | .name = "mvsdio", | |
319 | .id = -1, | |
320 | .dev = { | |
321 | .dma_mask = &mvsdio_dmamask, | |
322 | .coherent_dma_mask = 0xffffffff, | |
323 | }, | |
324 | .num_resources = ARRAY_SIZE(mvsdio_resources), | |
325 | .resource = mvsdio_resources, | |
326 | }; | |
327 | ||
328 | void __init kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data) | |
329 | { | |
330 | u32 dev, rev; | |
331 | ||
332 | kirkwood_pcie_id(&dev, &rev); | |
333 | if (rev == 0) /* catch all Kirkwood Z0's */ | |
334 | mvsdio_data->clock = 100000000; | |
335 | else | |
336 | mvsdio_data->clock = 200000000; | |
337 | mvsdio_data->dram = &kirkwood_mbus_dram_info; | |
338 | kirkwood_sdio.dev.platform_data = mvsdio_data; | |
339 | platform_device_register(&kirkwood_sdio); | |
340 | } | |
341 | ||
342 | ||
18365d18 LB |
343 | /***************************************************************************** |
344 | * SPI | |
345 | ****************************************************************************/ | |
346 | static struct orion_spi_info kirkwood_spi_plat_data = { | |
18365d18 LB |
347 | }; |
348 | ||
349 | static struct resource kirkwood_spi_resources[] = { | |
350 | { | |
351 | .start = SPI_PHYS_BASE, | |
352 | .end = SPI_PHYS_BASE + SZ_512 - 1, | |
353 | .flags = IORESOURCE_MEM, | |
354 | }, | |
355 | }; | |
356 | ||
357 | static struct platform_device kirkwood_spi = { | |
358 | .name = "orion_spi", | |
359 | .id = 0, | |
360 | .resource = kirkwood_spi_resources, | |
361 | .dev = { | |
362 | .platform_data = &kirkwood_spi_plat_data, | |
363 | }, | |
364 | .num_resources = ARRAY_SIZE(kirkwood_spi_resources), | |
365 | }; | |
366 | ||
367 | void __init kirkwood_spi_init() | |
368 | { | |
369 | platform_device_register(&kirkwood_spi); | |
370 | } | |
371 | ||
372 | ||
651c74c7 SB |
373 | /***************************************************************************** |
374 | * UART0 | |
375 | ****************************************************************************/ | |
376 | static struct plat_serial8250_port kirkwood_uart0_data[] = { | |
377 | { | |
378 | .mapbase = UART0_PHYS_BASE, | |
379 | .membase = (char *)UART0_VIRT_BASE, | |
380 | .irq = IRQ_KIRKWOOD_UART_0, | |
381 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | |
382 | .iotype = UPIO_MEM, | |
383 | .regshift = 2, | |
79d4dd77 | 384 | .uartclk = 0, |
651c74c7 SB |
385 | }, { |
386 | }, | |
387 | }; | |
388 | ||
389 | static struct resource kirkwood_uart0_resources[] = { | |
390 | { | |
391 | .start = UART0_PHYS_BASE, | |
392 | .end = UART0_PHYS_BASE + 0xff, | |
393 | .flags = IORESOURCE_MEM, | |
394 | }, { | |
395 | .start = IRQ_KIRKWOOD_UART_0, | |
396 | .end = IRQ_KIRKWOOD_UART_0, | |
397 | .flags = IORESOURCE_IRQ, | |
398 | }, | |
399 | }; | |
400 | ||
401 | static struct platform_device kirkwood_uart0 = { | |
402 | .name = "serial8250", | |
403 | .id = 0, | |
404 | .dev = { | |
405 | .platform_data = kirkwood_uart0_data, | |
406 | }, | |
407 | .resource = kirkwood_uart0_resources, | |
408 | .num_resources = ARRAY_SIZE(kirkwood_uart0_resources), | |
409 | }; | |
410 | ||
411 | void __init kirkwood_uart0_init(void) | |
412 | { | |
413 | platform_device_register(&kirkwood_uart0); | |
414 | } | |
415 | ||
416 | ||
417 | /***************************************************************************** | |
418 | * UART1 | |
419 | ****************************************************************************/ | |
420 | static struct plat_serial8250_port kirkwood_uart1_data[] = { | |
421 | { | |
422 | .mapbase = UART1_PHYS_BASE, | |
423 | .membase = (char *)UART1_VIRT_BASE, | |
424 | .irq = IRQ_KIRKWOOD_UART_1, | |
425 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | |
426 | .iotype = UPIO_MEM, | |
427 | .regshift = 2, | |
79d4dd77 | 428 | .uartclk = 0, |
651c74c7 SB |
429 | }, { |
430 | }, | |
431 | }; | |
432 | ||
433 | static struct resource kirkwood_uart1_resources[] = { | |
434 | { | |
435 | .start = UART1_PHYS_BASE, | |
436 | .end = UART1_PHYS_BASE + 0xff, | |
437 | .flags = IORESOURCE_MEM, | |
438 | }, { | |
439 | .start = IRQ_KIRKWOOD_UART_1, | |
440 | .end = IRQ_KIRKWOOD_UART_1, | |
441 | .flags = IORESOURCE_IRQ, | |
442 | }, | |
443 | }; | |
444 | ||
445 | static struct platform_device kirkwood_uart1 = { | |
446 | .name = "serial8250", | |
447 | .id = 1, | |
448 | .dev = { | |
449 | .platform_data = kirkwood_uart1_data, | |
450 | }, | |
451 | .resource = kirkwood_uart1_resources, | |
452 | .num_resources = ARRAY_SIZE(kirkwood_uart1_resources), | |
453 | }; | |
454 | ||
455 | void __init kirkwood_uart1_init(void) | |
456 | { | |
457 | platform_device_register(&kirkwood_uart1); | |
458 | } | |
459 | ||
460 | ||
09c0ed2e SB |
461 | /***************************************************************************** |
462 | * XOR | |
463 | ****************************************************************************/ | |
464 | static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = { | |
465 | .dram = &kirkwood_mbus_dram_info, | |
466 | }; | |
467 | ||
468 | static u64 kirkwood_xor_dmamask = DMA_32BIT_MASK; | |
469 | ||
470 | ||
471 | /***************************************************************************** | |
472 | * XOR0 | |
473 | ****************************************************************************/ | |
474 | static struct resource kirkwood_xor0_shared_resources[] = { | |
475 | { | |
476 | .name = "xor 0 low", | |
477 | .start = XOR0_PHYS_BASE, | |
478 | .end = XOR0_PHYS_BASE + 0xff, | |
479 | .flags = IORESOURCE_MEM, | |
480 | }, { | |
481 | .name = "xor 0 high", | |
482 | .start = XOR0_HIGH_PHYS_BASE, | |
483 | .end = XOR0_HIGH_PHYS_BASE + 0xff, | |
484 | .flags = IORESOURCE_MEM, | |
485 | }, | |
486 | }; | |
487 | ||
488 | static struct platform_device kirkwood_xor0_shared = { | |
489 | .name = MV_XOR_SHARED_NAME, | |
490 | .id = 0, | |
491 | .dev = { | |
492 | .platform_data = &kirkwood_xor_shared_data, | |
493 | }, | |
494 | .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources), | |
495 | .resource = kirkwood_xor0_shared_resources, | |
496 | }; | |
497 | ||
498 | static struct resource kirkwood_xor00_resources[] = { | |
499 | [0] = { | |
500 | .start = IRQ_KIRKWOOD_XOR_00, | |
501 | .end = IRQ_KIRKWOOD_XOR_00, | |
502 | .flags = IORESOURCE_IRQ, | |
503 | }, | |
504 | }; | |
505 | ||
506 | static struct mv_xor_platform_data kirkwood_xor00_data = { | |
507 | .shared = &kirkwood_xor0_shared, | |
508 | .hw_id = 0, | |
509 | .pool_size = PAGE_SIZE, | |
510 | }; | |
511 | ||
512 | static struct platform_device kirkwood_xor00_channel = { | |
513 | .name = MV_XOR_NAME, | |
514 | .id = 0, | |
515 | .num_resources = ARRAY_SIZE(kirkwood_xor00_resources), | |
516 | .resource = kirkwood_xor00_resources, | |
517 | .dev = { | |
518 | .dma_mask = &kirkwood_xor_dmamask, | |
519 | .coherent_dma_mask = DMA_64BIT_MASK, | |
520 | .platform_data = (void *)&kirkwood_xor00_data, | |
521 | }, | |
522 | }; | |
523 | ||
524 | static struct resource kirkwood_xor01_resources[] = { | |
525 | [0] = { | |
526 | .start = IRQ_KIRKWOOD_XOR_01, | |
527 | .end = IRQ_KIRKWOOD_XOR_01, | |
528 | .flags = IORESOURCE_IRQ, | |
529 | }, | |
530 | }; | |
531 | ||
532 | static struct mv_xor_platform_data kirkwood_xor01_data = { | |
533 | .shared = &kirkwood_xor0_shared, | |
534 | .hw_id = 1, | |
535 | .pool_size = PAGE_SIZE, | |
536 | }; | |
537 | ||
538 | static struct platform_device kirkwood_xor01_channel = { | |
539 | .name = MV_XOR_NAME, | |
540 | .id = 1, | |
541 | .num_resources = ARRAY_SIZE(kirkwood_xor01_resources), | |
542 | .resource = kirkwood_xor01_resources, | |
543 | .dev = { | |
544 | .dma_mask = &kirkwood_xor_dmamask, | |
545 | .coherent_dma_mask = DMA_64BIT_MASK, | |
546 | .platform_data = (void *)&kirkwood_xor01_data, | |
547 | }, | |
548 | }; | |
549 | ||
550 | void __init kirkwood_xor0_init(void) | |
551 | { | |
552 | platform_device_register(&kirkwood_xor0_shared); | |
553 | ||
554 | /* | |
555 | * two engines can't do memset simultaneously, this limitation | |
556 | * satisfied by removing memset support from one of the engines. | |
557 | */ | |
558 | dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask); | |
559 | dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask); | |
560 | platform_device_register(&kirkwood_xor00_channel); | |
561 | ||
562 | dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask); | |
563 | dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask); | |
564 | dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask); | |
565 | platform_device_register(&kirkwood_xor01_channel); | |
566 | } | |
567 | ||
568 | ||
569 | /***************************************************************************** | |
570 | * XOR1 | |
571 | ****************************************************************************/ | |
572 | static struct resource kirkwood_xor1_shared_resources[] = { | |
573 | { | |
574 | .name = "xor 1 low", | |
575 | .start = XOR1_PHYS_BASE, | |
576 | .end = XOR1_PHYS_BASE + 0xff, | |
577 | .flags = IORESOURCE_MEM, | |
578 | }, { | |
579 | .name = "xor 1 high", | |
580 | .start = XOR1_HIGH_PHYS_BASE, | |
581 | .end = XOR1_HIGH_PHYS_BASE + 0xff, | |
582 | .flags = IORESOURCE_MEM, | |
583 | }, | |
584 | }; | |
585 | ||
586 | static struct platform_device kirkwood_xor1_shared = { | |
587 | .name = MV_XOR_SHARED_NAME, | |
588 | .id = 1, | |
589 | .dev = { | |
590 | .platform_data = &kirkwood_xor_shared_data, | |
591 | }, | |
592 | .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources), | |
593 | .resource = kirkwood_xor1_shared_resources, | |
594 | }; | |
595 | ||
596 | static struct resource kirkwood_xor10_resources[] = { | |
597 | [0] = { | |
598 | .start = IRQ_KIRKWOOD_XOR_10, | |
599 | .end = IRQ_KIRKWOOD_XOR_10, | |
600 | .flags = IORESOURCE_IRQ, | |
601 | }, | |
602 | }; | |
603 | ||
604 | static struct mv_xor_platform_data kirkwood_xor10_data = { | |
605 | .shared = &kirkwood_xor1_shared, | |
606 | .hw_id = 0, | |
607 | .pool_size = PAGE_SIZE, | |
608 | }; | |
609 | ||
610 | static struct platform_device kirkwood_xor10_channel = { | |
611 | .name = MV_XOR_NAME, | |
612 | .id = 2, | |
613 | .num_resources = ARRAY_SIZE(kirkwood_xor10_resources), | |
614 | .resource = kirkwood_xor10_resources, | |
615 | .dev = { | |
616 | .dma_mask = &kirkwood_xor_dmamask, | |
617 | .coherent_dma_mask = DMA_64BIT_MASK, | |
618 | .platform_data = (void *)&kirkwood_xor10_data, | |
619 | }, | |
620 | }; | |
621 | ||
622 | static struct resource kirkwood_xor11_resources[] = { | |
623 | [0] = { | |
624 | .start = IRQ_KIRKWOOD_XOR_11, | |
625 | .end = IRQ_KIRKWOOD_XOR_11, | |
626 | .flags = IORESOURCE_IRQ, | |
627 | }, | |
628 | }; | |
629 | ||
630 | static struct mv_xor_platform_data kirkwood_xor11_data = { | |
631 | .shared = &kirkwood_xor1_shared, | |
632 | .hw_id = 1, | |
633 | .pool_size = PAGE_SIZE, | |
634 | }; | |
635 | ||
636 | static struct platform_device kirkwood_xor11_channel = { | |
637 | .name = MV_XOR_NAME, | |
638 | .id = 3, | |
639 | .num_resources = ARRAY_SIZE(kirkwood_xor11_resources), | |
640 | .resource = kirkwood_xor11_resources, | |
641 | .dev = { | |
642 | .dma_mask = &kirkwood_xor_dmamask, | |
643 | .coherent_dma_mask = DMA_64BIT_MASK, | |
644 | .platform_data = (void *)&kirkwood_xor11_data, | |
645 | }, | |
646 | }; | |
647 | ||
648 | void __init kirkwood_xor1_init(void) | |
649 | { | |
650 | platform_device_register(&kirkwood_xor1_shared); | |
651 | ||
652 | /* | |
653 | * two engines can't do memset simultaneously, this limitation | |
654 | * satisfied by removing memset support from one of the engines. | |
655 | */ | |
656 | dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask); | |
657 | dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask); | |
658 | platform_device_register(&kirkwood_xor10_channel); | |
659 | ||
660 | dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask); | |
661 | dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask); | |
662 | dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask); | |
663 | platform_device_register(&kirkwood_xor11_channel); | |
664 | } | |
665 | ||
666 | ||
651c74c7 SB |
667 | /***************************************************************************** |
668 | * Time handling | |
669 | ****************************************************************************/ | |
79d4dd77 RS |
670 | int kirkwood_tclk; |
671 | ||
672 | int __init kirkwood_find_tclk(void) | |
673 | { | |
b2b3dc2f RS |
674 | u32 dev, rev; |
675 | ||
676 | kirkwood_pcie_id(&dev, &rev); | |
677 | if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0) | |
678 | return 200000000; | |
679 | ||
79d4dd77 RS |
680 | return 166666667; |
681 | } | |
682 | ||
651c74c7 SB |
683 | static void kirkwood_timer_init(void) |
684 | { | |
79d4dd77 RS |
685 | kirkwood_tclk = kirkwood_find_tclk(); |
686 | orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk); | |
651c74c7 SB |
687 | } |
688 | ||
689 | struct sys_timer kirkwood_timer = { | |
690 | .init = kirkwood_timer_init, | |
691 | }; | |
692 | ||
693 | ||
694 | /***************************************************************************** | |
695 | * General | |
696 | ****************************************************************************/ | |
b2b3dc2f RS |
697 | /* |
698 | * Identify device ID and revision. | |
699 | */ | |
651c74c7 SB |
700 | static char * __init kirkwood_id(void) |
701 | { | |
b2b3dc2f RS |
702 | u32 dev, rev; |
703 | ||
704 | kirkwood_pcie_id(&dev, &rev); | |
705 | ||
706 | if (dev == MV88F6281_DEV_ID) { | |
707 | if (rev == MV88F6281_REV_Z0) | |
708 | return "MV88F6281-Z0"; | |
709 | else if (rev == MV88F6281_REV_A0) | |
710 | return "MV88F6281-A0"; | |
711 | else | |
712 | return "MV88F6281-Rev-Unsupported"; | |
713 | } else if (dev == MV88F6192_DEV_ID) { | |
714 | if (rev == MV88F6192_REV_Z0) | |
715 | return "MV88F6192-Z0"; | |
716 | else if (rev == MV88F6192_REV_A0) | |
717 | return "MV88F6192-A0"; | |
718 | else | |
719 | return "MV88F6192-Rev-Unsupported"; | |
720 | } else if (dev == MV88F6180_DEV_ID) { | |
721 | if (rev == MV88F6180_REV_A0) | |
722 | return "MV88F6180-Rev-A0"; | |
723 | else | |
724 | return "MV88F6180-Rev-Unsupported"; | |
725 | } else { | |
726 | return "Device-Unknown"; | |
651c74c7 | 727 | } |
651c74c7 SB |
728 | } |
729 | ||
4360bb41 | 730 | static void __init kirkwood_l2_init(void) |
13387603 | 731 | { |
4360bb41 RS |
732 | #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH |
733 | writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG); | |
734 | feroceon_l2_init(1); | |
735 | #else | |
736 | writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG); | |
737 | feroceon_l2_init(0); | |
738 | #endif | |
13387603 SB |
739 | } |
740 | ||
651c74c7 SB |
741 | void __init kirkwood_init(void) |
742 | { | |
743 | printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n", | |
79d4dd77 RS |
744 | kirkwood_id(), kirkwood_tclk); |
745 | kirkwood_ge00_shared_data.t_clk = kirkwood_tclk; | |
13731d1a | 746 | kirkwood_ge01_shared_data.t_clk = kirkwood_tclk; |
79d4dd77 RS |
747 | kirkwood_spi_plat_data.tclk = kirkwood_tclk; |
748 | kirkwood_uart0_data[0].uartclk = kirkwood_tclk; | |
749 | kirkwood_uart1_data[0].uartclk = kirkwood_tclk; | |
651c74c7 SB |
750 | |
751 | kirkwood_setup_cpu_mbus(); | |
752 | ||
753 | #ifdef CONFIG_CACHE_FEROCEON_L2 | |
4360bb41 | 754 | kirkwood_l2_init(); |
651c74c7 SB |
755 | #endif |
756 | } |