1 /*
2 * arch/arm/plat-orion/common.c
3 *
4 * Marvell Orion SoC common setup code used by multiple mach-/common.c
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/dma-mapping.h>
15 #include <linux/serial_8250.h>
16 #include <linux/ata_platform.h>
17 #include <linux/mv643xx_eth.h>
18 #include <linux/mv643xx_i2c.h>
19 #include <net/dsa.h>
20 #include <linux/spi/orion_spi.h>
21 #include <plat/orion_wdt.h>
22 #include <plat/mv_xor.h>
23 #include <plat/ehci-orion.h>
24
25 /* Fill in the resources structure and link it into the platform
26 device structure. There is always a memory region, and nearly
27 always an interrupt.*/
fill_resources(struct platform_device * device,struct resource * resources,resource_size_t mapbase,resource_size_t size,unsigned int irq)28 static void fill_resources(struct platform_device *device,
29 struct resource *resources,
30 resource_size_t mapbase,
31 resource_size_t size,
32 unsigned int irq)
33 {
34 device->resource = resources;
35 device->num_resources = 1;
36 resources[0].flags = IORESOURCE_MEM;
37 resources[0].start = mapbase;
38 resources[0].end = mapbase + size;
39
40 if (irq != NO_IRQ) {
41 device->num_resources++;
42 resources[1].flags = IORESOURCE_IRQ;
43 resources[1].start = irq;
44 resources[1].end = irq;
45 }
46 }
47
48 /*****************************************************************************
49 * UART
50 ****************************************************************************/
uart_complete(struct platform_device * orion_uart,struct plat_serial8250_port * data,struct resource * resources,unsigned int membase,resource_size_t mapbase,unsigned int irq,unsigned int uartclk)51 static void __init uart_complete(
52 struct platform_device *orion_uart,
53 struct plat_serial8250_port *data,
54 struct resource *resources,
55 unsigned int membase,
56 resource_size_t mapbase,
57 unsigned int irq,
58 unsigned int uartclk)
59 {
60 data->mapbase = mapbase;
61 data->membase = (void __iomem *)membase;
62 data->irq = irq;
63 data->uartclk = uartclk;
64 orion_uart->dev.platform_data = data;
65
66 fill_resources(orion_uart, resources, mapbase, 0xff, irq);
67 platform_device_register(orion_uart);
68 }
69
70 /*****************************************************************************
71 * UART0
72 ****************************************************************************/
73 static struct plat_serial8250_port orion_uart0_data[] = {
74 {
75 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
76 .iotype = UPIO_MEM,
77 .regshift = 2,
78 }, {
79 },
80 };
81
82 static struct resource orion_uart0_resources[2];
83
84 static struct platform_device orion_uart0 = {
85 .name = "serial8250",
86 .id = PLAT8250_DEV_PLATFORM,
87 };
88
orion_uart0_init(unsigned int membase,resource_size_t mapbase,unsigned int irq,unsigned int uartclk)89 void __init orion_uart0_init(unsigned int membase,
90 resource_size_t mapbase,
91 unsigned int irq,
92 unsigned int uartclk)
93 {
94 uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources,
95 membase, mapbase, irq, uartclk);
96 }
97
98 /*****************************************************************************
99 * UART1
100 ****************************************************************************/
101 static struct plat_serial8250_port orion_uart1_data[] = {
102 {
103 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
104 .iotype = UPIO_MEM,
105 .regshift = 2,
106 }, {
107 },
108 };
109
110 static struct resource orion_uart1_resources[2];
111
112 static struct platform_device orion_uart1 = {
113 .name = "serial8250",
114 .id = PLAT8250_DEV_PLATFORM1,
115 };
116
orion_uart1_init(unsigned int membase,resource_size_t mapbase,unsigned int irq,unsigned int uartclk)117 void __init orion_uart1_init(unsigned int membase,
118 resource_size_t mapbase,
119 unsigned int irq,
120 unsigned int uartclk)
121 {
122 uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources,
123 membase, mapbase, irq, uartclk);
124 }
125
126 /*****************************************************************************
127 * UART2
128 ****************************************************************************/
129 static struct plat_serial8250_port orion_uart2_data[] = {
130 {
131 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
132 .iotype = UPIO_MEM,
133 .regshift = 2,
134 }, {
135 },
136 };
137
138 static struct resource orion_uart2_resources[2];
139
140 static struct platform_device orion_uart2 = {
141 .name = "serial8250",
142 .id = PLAT8250_DEV_PLATFORM2,
143 };
144
orion_uart2_init(unsigned int membase,resource_size_t mapbase,unsigned int irq,unsigned int uartclk)145 void __init orion_uart2_init(unsigned int membase,
146 resource_size_t mapbase,
147 unsigned int irq,
148 unsigned int uartclk)
149 {
150 uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources,
151 membase, mapbase, irq, uartclk);
152 }
153
154 /*****************************************************************************
155 * UART3
156 ****************************************************************************/
157 static struct plat_serial8250_port orion_uart3_data[] = {
158 {
159 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
160 .iotype = UPIO_MEM,
161 .regshift = 2,
162 }, {
163 },
164 };
165
166 static struct resource orion_uart3_resources[2];
167
168 static struct platform_device orion_uart3 = {
169 .name = "serial8250",
170 .id = 3,
171 };
172
orion_uart3_init(unsigned int membase,resource_size_t mapbase,unsigned int irq,unsigned int uartclk)173 void __init orion_uart3_init(unsigned int membase,
174 resource_size_t mapbase,
175 unsigned int irq,
176 unsigned int uartclk)
177 {
178 uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources,
179 membase, mapbase, irq, uartclk);
180 }
181
182 /*****************************************************************************
183 * SoC RTC
184 ****************************************************************************/
185 static struct resource orion_rtc_resource[2];
186
orion_rtc_init(unsigned long mapbase,unsigned long irq)187 void __init orion_rtc_init(unsigned long mapbase,
188 unsigned long irq)
189 {
190 orion_rtc_resource[0].start = mapbase;
191 orion_rtc_resource[0].end = mapbase + SZ_32 - 1;
192 orion_rtc_resource[0].flags = IORESOURCE_MEM;
193 orion_rtc_resource[1].start = irq;
194 orion_rtc_resource[1].end = irq;
195 orion_rtc_resource[1].flags = IORESOURCE_IRQ;
196
197 platform_device_register_simple("rtc-mv", -1, orion_rtc_resource, 2);
198 }
199
200 /*****************************************************************************
201 * GE
202 ****************************************************************************/
ge_complete(struct mv643xx_eth_shared_platform_data * orion_ge_shared_data,int tclk,struct resource * orion_ge_resource,unsigned long irq,struct platform_device * orion_ge_shared,struct mv643xx_eth_platform_data * eth_data,struct platform_device * orion_ge)203 static __init void ge_complete(
204 struct mv643xx_eth_shared_platform_data *orion_ge_shared_data,
205 int tclk,
206 struct resource *orion_ge_resource, unsigned long irq,
207 struct platform_device *orion_ge_shared,
208 struct mv643xx_eth_platform_data *eth_data,
209 struct platform_device *orion_ge)
210 {
211 orion_ge_shared_data->t_clk = tclk;
212 orion_ge_resource->start = irq;
213 orion_ge_resource->end = irq;
214 eth_data->shared = orion_ge_shared;
215 orion_ge->dev.platform_data = eth_data;
216
217 platform_device_register(orion_ge_shared);
218 platform_device_register(orion_ge);
219 }
220
221 /*****************************************************************************
222 * GE00
223 ****************************************************************************/
224 struct mv643xx_eth_shared_platform_data orion_ge00_shared_data;
225
226 static struct resource orion_ge00_shared_resources[] = {
227 {
228 .name = "ge00 base",
229 }, {
230 .name = "ge00 err irq",
231 },
232 };
233
234 static struct platform_device orion_ge00_shared = {
235 .name = MV643XX_ETH_SHARED_NAME,
236 .id = 0,
237 .dev = {
238 .platform_data = &orion_ge00_shared_data,
239 },
240 };
241
242 static struct resource orion_ge00_resources[] = {
243 {
244 .name = "ge00 irq",
245 .flags = IORESOURCE_IRQ,
246 },
247 };
248
249 static struct platform_device orion_ge00 = {
250 .name = MV643XX_ETH_NAME,
251 .id = 0,
252 .num_resources = 1,
253 .resource = orion_ge00_resources,
254 .dev = {
255 .coherent_dma_mask = DMA_BIT_MASK(32),
256 },
257 };
258
orion_ge00_init(struct mv643xx_eth_platform_data * eth_data,unsigned long mapbase,unsigned long irq,unsigned long irq_err,int tclk)259 void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
260 unsigned long mapbase,
261 unsigned long irq,
262 unsigned long irq_err,
263 int tclk)
264 {
265 fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
266 mapbase + 0x2000, SZ_16K - 1, irq_err);
267 ge_complete(&orion_ge00_shared_data, tclk,
268 orion_ge00_resources, irq, &orion_ge00_shared,
269 eth_data, &orion_ge00);
270 }
271
272 /*****************************************************************************
273 * GE01
274 ****************************************************************************/
275 struct mv643xx_eth_shared_platform_data orion_ge01_shared_data = {
276 .shared_smi = &orion_ge00_shared,
277 };
278
279 static struct resource orion_ge01_shared_resources[] = {
280 {
281 .name = "ge01 base",
282 }, {
283 .name = "ge01 err irq",
284 },
285 };
286
287 static struct platform_device orion_ge01_shared = {
288 .name = MV643XX_ETH_SHARED_NAME,
289 .id = 1,
290 .dev = {
291 .platform_data = &orion_ge01_shared_data,
292 },
293 };
294
295 static struct resource orion_ge01_resources[] = {
296 {
297 .name = "ge01 irq",
298 .flags = IORESOURCE_IRQ,
299 },
300 };
301
302 static struct platform_device orion_ge01 = {
303 .name = MV643XX_ETH_NAME,
304 .id = 1,
305 .num_resources = 1,
306 .resource = orion_ge01_resources,
307 .dev = {
308 .coherent_dma_mask = DMA_BIT_MASK(32),
309 },
310 };
311
orion_ge01_init(struct mv643xx_eth_platform_data * eth_data,unsigned long mapbase,unsigned long irq,unsigned long irq_err,int tclk)312 void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
313 unsigned long mapbase,
314 unsigned long irq,
315 unsigned long irq_err,
316 int tclk)
317 {
318 fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
319 mapbase + 0x2000, SZ_16K - 1, irq_err);
320 ge_complete(&orion_ge01_shared_data, tclk,
321 orion_ge01_resources, irq, &orion_ge01_shared,
322 eth_data, &orion_ge01);
323 }
324
325 /*****************************************************************************
326 * GE10
327 ****************************************************************************/
328 struct mv643xx_eth_shared_platform_data orion_ge10_shared_data = {
329 .shared_smi = &orion_ge00_shared,
330 };
331
332 static struct resource orion_ge10_shared_resources[] = {
333 {
334 .name = "ge10 base",
335 }, {
336 .name = "ge10 err irq",
337 },
338 };
339
340 static struct platform_device orion_ge10_shared = {
341 .name = MV643XX_ETH_SHARED_NAME,
342 .id = 1,
343 .dev = {
344 .platform_data = &orion_ge10_shared_data,
345 },
346 };
347
348 static struct resource orion_ge10_resources[] = {
349 {
350 .name = "ge10 irq",
351 .flags = IORESOURCE_IRQ,
352 },
353 };
354
355 static struct platform_device orion_ge10 = {
356 .name = MV643XX_ETH_NAME,
357 .id = 1,
358 .num_resources = 2,
359 .resource = orion_ge10_resources,
360 .dev = {
361 .coherent_dma_mask = DMA_BIT_MASK(32),
362 },
363 };
364
orion_ge10_init(struct mv643xx_eth_platform_data * eth_data,unsigned long mapbase,unsigned long irq,unsigned long irq_err,int tclk)365 void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
366 unsigned long mapbase,
367 unsigned long irq,
368 unsigned long irq_err,
369 int tclk)
370 {
371 fill_resources(&orion_ge10_shared, orion_ge10_shared_resources,
372 mapbase + 0x2000, SZ_16K - 1, irq_err);
373 ge_complete(&orion_ge10_shared_data, tclk,
374 orion_ge10_resources, irq, &orion_ge10_shared,
375 eth_data, &orion_ge10);
376 }
377
378 /*****************************************************************************
379 * GE11
380 ****************************************************************************/
381 struct mv643xx_eth_shared_platform_data orion_ge11_shared_data = {
382 .shared_smi = &orion_ge00_shared,
383 };
384
385 static struct resource orion_ge11_shared_resources[] = {
386 {
387 .name = "ge11 base",
388 }, {
389 .name = "ge11 err irq",
390 },
391 };
392
393 static struct platform_device orion_ge11_shared = {
394 .name = MV643XX_ETH_SHARED_NAME,
395 .id = 1,
396 .dev = {
397 .platform_data = &orion_ge11_shared_data,
398 },
399 };
400
401 static struct resource orion_ge11_resources[] = {
402 {
403 .name = "ge11 irq",
404 .flags = IORESOURCE_IRQ,
405 },
406 };
407
408 static struct platform_device orion_ge11 = {
409 .name = MV643XX_ETH_NAME,
410 .id = 1,
411 .num_resources = 2,
412 .resource = orion_ge11_resources,
413 .dev = {
414 .coherent_dma_mask = DMA_BIT_MASK(32),
415 },
416 };
417
orion_ge11_init(struct mv643xx_eth_platform_data * eth_data,unsigned long mapbase,unsigned long irq,unsigned long irq_err,int tclk)418 void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
419 unsigned long mapbase,
420 unsigned long irq,
421 unsigned long irq_err,
422 int tclk)
423 {
424 fill_resources(&orion_ge11_shared, orion_ge11_shared_resources,
425 mapbase + 0x2000, SZ_16K - 1, irq_err);
426 ge_complete(&orion_ge11_shared_data, tclk,
427 orion_ge11_resources, irq, &orion_ge11_shared,
428 eth_data, &orion_ge11);
429 }
430
431 /*****************************************************************************
432 * Ethernet switch
433 ****************************************************************************/
434 static struct resource orion_switch_resources[] = {
435 {
436 .start = 0,
437 .end = 0,
438 .flags = IORESOURCE_IRQ,
439 },
440 };
441
442 static struct platform_device orion_switch_device = {
443 .name = "dsa",
444 .id = 0,
445 .num_resources = 0,
446 .resource = orion_switch_resources,
447 };
448
orion_ge00_switch_init(struct dsa_platform_data * d,int irq)449 void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq)
450 {
451 int i;
452
453 if (irq != NO_IRQ) {
454 orion_switch_resources[0].start = irq;
455 orion_switch_resources[0].end = irq;
456 orion_switch_device.num_resources = 1;
457 }
458
459 d->netdev = &orion_ge00.dev;
460 for (i = 0; i < d->nr_chips; i++)
461 d->chip[i].mii_bus = &orion_ge00_shared.dev;
462 orion_switch_device.dev.platform_data = d;
463
464 platform_device_register(&orion_switch_device);
465 }
466
467 /*****************************************************************************
468 * I2C
469 ****************************************************************************/
470 static struct mv64xxx_i2c_pdata orion_i2c_pdata = {
471 .freq_n = 3,
472 .timeout = 1000, /* Default timeout of 1 second */
473 };
474
475 static struct resource orion_i2c_resources[2];
476
477 static struct platform_device orion_i2c = {
478 .name = MV64XXX_I2C_CTLR_NAME,
479 .id = 0,
480 .dev = {
481 .platform_data = &orion_i2c_pdata,
482 },
483 };
484
485 static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = {
486 .freq_n = 3,
487 .timeout = 1000, /* Default timeout of 1 second */
488 };
489
490 static struct resource orion_i2c_1_resources[2];
491
492 static struct platform_device orion_i2c_1 = {
493 .name = MV64XXX_I2C_CTLR_NAME,
494 .id = 1,
495 .dev = {
496 .platform_data = &orion_i2c_1_pdata,
497 },
498 };
499
orion_i2c_init(unsigned long mapbase,unsigned long irq,unsigned long freq_m)500 void __init orion_i2c_init(unsigned long mapbase,
501 unsigned long irq,
502 unsigned long freq_m)
503 {
504 orion_i2c_pdata.freq_m = freq_m;
505 fill_resources(&orion_i2c, orion_i2c_resources, mapbase,
506 SZ_32 - 1, irq);
507 platform_device_register(&orion_i2c);
508 }
509
orion_i2c_1_init(unsigned long mapbase,unsigned long irq,unsigned long freq_m)510 void __init orion_i2c_1_init(unsigned long mapbase,
511 unsigned long irq,
512 unsigned long freq_m)
513 {
514 orion_i2c_1_pdata.freq_m = freq_m;
515 fill_resources(&orion_i2c_1, orion_i2c_1_resources, mapbase,
516 SZ_32 - 1, irq);
517 platform_device_register(&orion_i2c_1);
518 }
519
520 /*****************************************************************************
521 * SPI
522 ****************************************************************************/
523 static struct orion_spi_info orion_spi_plat_data;
524 static struct resource orion_spi_resources;
525
526 static struct platform_device orion_spi = {
527 .name = "orion_spi",
528 .id = 0,
529 .dev = {
530 .platform_data = &orion_spi_plat_data,
531 },
532 };
533
534 static struct orion_spi_info orion_spi_1_plat_data;
535 static struct resource orion_spi_1_resources;
536
537 static struct platform_device orion_spi_1 = {
538 .name = "orion_spi",
539 .id = 1,
540 .dev = {
541 .platform_data = &orion_spi_1_plat_data,
542 },
543 };
544
545 /* Note: The SPI silicon core does have interrupts. However the
546 * current Linux software driver does not use interrupts. */
547
orion_spi_init(unsigned long mapbase,unsigned long tclk)548 void __init orion_spi_init(unsigned long mapbase,
549 unsigned long tclk)
550 {
551 orion_spi_plat_data.tclk = tclk;
552 fill_resources(&orion_spi, &orion_spi_resources,
553 mapbase, SZ_512 - 1, NO_IRQ);
554 platform_device_register(&orion_spi);
555 }
556
orion_spi_1_init(unsigned long mapbase,unsigned long tclk)557 void __init orion_spi_1_init(unsigned long mapbase,
558 unsigned long tclk)
559 {
560 orion_spi_1_plat_data.tclk = tclk;
561 fill_resources(&orion_spi_1, &orion_spi_1_resources,
562 mapbase, SZ_512 - 1, NO_IRQ);
563 platform_device_register(&orion_spi_1);
564 }
565
566 /*****************************************************************************
567 * Watchdog
568 ****************************************************************************/
569 static struct orion_wdt_platform_data orion_wdt_data;
570
571 static struct platform_device orion_wdt_device = {
572 .name = "orion_wdt",
573 .id = -1,
574 .dev = {
575 .platform_data = &orion_wdt_data,
576 },
577 .num_resources = 0,
578 };
579
orion_wdt_init(unsigned long tclk)580 void __init orion_wdt_init(unsigned long tclk)
581 {
582 orion_wdt_data.tclk = tclk;
583 platform_device_register(&orion_wdt_device);
584 }
585
586 /*****************************************************************************
587 * XOR
588 ****************************************************************************/
589 static u64 orion_xor_dmamask = DMA_BIT_MASK(32);
590
orion_xor_init_channels(struct mv_xor_platform_data * orion_xor0_data,struct platform_device * orion_xor0_channel,struct mv_xor_platform_data * orion_xor1_data,struct platform_device * orion_xor1_channel)591 void __init orion_xor_init_channels(
592 struct mv_xor_platform_data *orion_xor0_data,
593 struct platform_device *orion_xor0_channel,
594 struct mv_xor_platform_data *orion_xor1_data,
595 struct platform_device *orion_xor1_channel)
596 {
597 /*
598 * two engines can't do memset simultaneously, this limitation
599 * satisfied by removing memset support from one of the engines.
600 */
601 dma_cap_set(DMA_MEMCPY, orion_xor0_data->cap_mask);
602 dma_cap_set(DMA_XOR, orion_xor0_data->cap_mask);
603 platform_device_register(orion_xor0_channel);
604
605 dma_cap_set(DMA_MEMCPY, orion_xor1_data->cap_mask);
606 dma_cap_set(DMA_MEMSET, orion_xor1_data->cap_mask);
607 dma_cap_set(DMA_XOR, orion_xor1_data->cap_mask);
608 platform_device_register(orion_xor1_channel);
609 }
610
611 /*****************************************************************************
612 * XOR0
613 ****************************************************************************/
614 static struct resource orion_xor0_shared_resources[] = {
615 {
616 .name = "xor 0 low",
617 .flags = IORESOURCE_MEM,
618 }, {
619 .name = "xor 0 high",
620 .flags = IORESOURCE_MEM,
621 },
622 };
623
624 static struct platform_device orion_xor0_shared = {
625 .name = MV_XOR_SHARED_NAME,
626 .id = 0,
627 .num_resources = ARRAY_SIZE(orion_xor0_shared_resources),
628 .resource = orion_xor0_shared_resources,
629 };
630
631 static struct resource orion_xor00_resources[] = {
632 [0] = {
633 .flags = IORESOURCE_IRQ,
634 },
635 };
636
637 static struct mv_xor_platform_data orion_xor00_data = {
638 .shared = &orion_xor0_shared,
639 .hw_id = 0,
640 .pool_size = PAGE_SIZE,
641 };
642
643 static struct platform_device orion_xor00_channel = {
644 .name = MV_XOR_NAME,
645 .id = 0,
646 .num_resources = ARRAY_SIZE(orion_xor00_resources),
647 .resource = orion_xor00_resources,
648 .dev = {
649 .dma_mask = &orion_xor_dmamask,
650 .coherent_dma_mask = DMA_BIT_MASK(64),
651 .platform_data = &orion_xor00_data,
652 },
653 };
654
655 static struct resource orion_xor01_resources[] = {
656 [0] = {
657 .flags = IORESOURCE_IRQ,
658 },
659 };
660
661 static struct mv_xor_platform_data orion_xor01_data = {
662 .shared = &orion_xor0_shared,
663 .hw_id = 1,
664 .pool_size = PAGE_SIZE,
665 };
666
667 static struct platform_device orion_xor01_channel = {
668 .name = MV_XOR_NAME,
669 .id = 1,
670 .num_resources = ARRAY_SIZE(orion_xor01_resources),
671 .resource = orion_xor01_resources,
672 .dev = {
673 .dma_mask = &orion_xor_dmamask,
674 .coherent_dma_mask = DMA_BIT_MASK(64),
675 .platform_data = &orion_xor01_data,
676 },
677 };
678
orion_xor0_init(unsigned long mapbase_low,unsigned long mapbase_high,unsigned long irq_0,unsigned long irq_1)679 void __init orion_xor0_init(unsigned long mapbase_low,
680 unsigned long mapbase_high,
681 unsigned long irq_0,
682 unsigned long irq_1)
683 {
684 orion_xor0_shared_resources[0].start = mapbase_low;
685 orion_xor0_shared_resources[0].end = mapbase_low + 0xff;
686 orion_xor0_shared_resources[1].start = mapbase_high;
687 orion_xor0_shared_resources[1].end = mapbase_high + 0xff;
688
689 orion_xor00_resources[0].start = irq_0;
690 orion_xor00_resources[0].end = irq_0;
691 orion_xor01_resources[0].start = irq_1;
692 orion_xor01_resources[0].end = irq_1;
693
694 platform_device_register(&orion_xor0_shared);
695
696 orion_xor_init_channels(&orion_xor00_data, &orion_xor00_channel,
697 &orion_xor01_data, &orion_xor01_channel);
698 }
699
700 /*****************************************************************************
701 * XOR1
702 ****************************************************************************/
703 static struct resource orion_xor1_shared_resources[] = {
704 {
705 .name = "xor 1 low",
706 .flags = IORESOURCE_MEM,
707 }, {
708 .name = "xor 1 high",
709 .flags = IORESOURCE_MEM,
710 },
711 };
712
713 static struct platform_device orion_xor1_shared = {
714 .name = MV_XOR_SHARED_NAME,
715 .id = 1,
716 .num_resources = ARRAY_SIZE(orion_xor1_shared_resources),
717 .resource = orion_xor1_shared_resources,
718 };
719
720 static struct resource orion_xor10_resources[] = {
721 [0] = {
722 .flags = IORESOURCE_IRQ,
723 },
724 };
725
726 static struct mv_xor_platform_data orion_xor10_data = {
727 .shared = &orion_xor1_shared,
728 .hw_id = 0,
729 .pool_size = PAGE_SIZE,
730 };
731
732 static struct platform_device orion_xor10_channel = {
733 .name = MV_XOR_NAME,
734 .id = 2,
735 .num_resources = ARRAY_SIZE(orion_xor10_resources),
736 .resource = orion_xor10_resources,
737 .dev = {
738 .dma_mask = &orion_xor_dmamask,
739 .coherent_dma_mask = DMA_BIT_MASK(64),
740 .platform_data = &orion_xor10_data,
741 },
742 };
743
744 static struct resource orion_xor11_resources[] = {
745 [0] = {
746 .flags = IORESOURCE_IRQ,
747 },
748 };
749
750 static struct mv_xor_platform_data orion_xor11_data = {
751 .shared = &orion_xor1_shared,
752 .hw_id = 1,
753 .pool_size = PAGE_SIZE,
754 };
755
756 static struct platform_device orion_xor11_channel = {
757 .name = MV_XOR_NAME,
758 .id = 3,
759 .num_resources = ARRAY_SIZE(orion_xor11_resources),
760 .resource = orion_xor11_resources,
761 .dev = {
762 .dma_mask = &orion_xor_dmamask,
763 .coherent_dma_mask = DMA_BIT_MASK(64),
764 .platform_data = &orion_xor11_data,
765 },
766 };
767
orion_xor1_init(unsigned long mapbase_low,unsigned long mapbase_high,unsigned long irq_0,unsigned long irq_1)768 void __init orion_xor1_init(unsigned long mapbase_low,
769 unsigned long mapbase_high,
770 unsigned long irq_0,
771 unsigned long irq_1)
772 {
773 orion_xor1_shared_resources[0].start = mapbase_low;
774 orion_xor1_shared_resources[0].end = mapbase_low + 0xff;
775 orion_xor1_shared_resources[1].start = mapbase_high;
776 orion_xor1_shared_resources[1].end = mapbase_high + 0xff;
777
778 orion_xor10_resources[0].start = irq_0;
779 orion_xor10_resources[0].end = irq_0;
780 orion_xor11_resources[0].start = irq_1;
781 orion_xor11_resources[0].end = irq_1;
782
783 platform_device_register(&orion_xor1_shared);
784
785 orion_xor_init_channels(&orion_xor10_data, &orion_xor10_channel,
786 &orion_xor11_data, &orion_xor11_channel);
787 }
788
789 /*****************************************************************************
790 * EHCI
791 ****************************************************************************/
792 static struct orion_ehci_data orion_ehci_data;
793 static u64 ehci_dmamask = DMA_BIT_MASK(32);
794
795
796 /*****************************************************************************
797 * EHCI0
798 ****************************************************************************/
799 static struct resource orion_ehci_resources[2];
800
801 static struct platform_device orion_ehci = {
802 .name = "orion-ehci",
803 .id = 0,
804 .dev = {
805 .dma_mask = &ehci_dmamask,
806 .coherent_dma_mask = DMA_BIT_MASK(32),
807 .platform_data = &orion_ehci_data,
808 },
809 };
810
orion_ehci_init(unsigned long mapbase,unsigned long irq,enum orion_ehci_phy_ver phy_version)811 void __init orion_ehci_init(unsigned long mapbase,
812 unsigned long irq,
813 enum orion_ehci_phy_ver phy_version)
814 {
815 orion_ehci_data.phy_version = phy_version;
816 fill_resources(&orion_ehci, orion_ehci_resources, mapbase, SZ_4K - 1,
817 irq);
818
819 platform_device_register(&orion_ehci);
820 }
821
822 /*****************************************************************************
823 * EHCI1
824 ****************************************************************************/
825 static struct resource orion_ehci_1_resources[2];
826
827 static struct platform_device orion_ehci_1 = {
828 .name = "orion-ehci",
829 .id = 1,
830 .dev = {
831 .dma_mask = &ehci_dmamask,
832 .coherent_dma_mask = DMA_BIT_MASK(32),
833 .platform_data = &orion_ehci_data,
834 },
835 };
836
orion_ehci_1_init(unsigned long mapbase,unsigned long irq)837 void __init orion_ehci_1_init(unsigned long mapbase,
838 unsigned long irq)
839 {
840 fill_resources(&orion_ehci_1, orion_ehci_1_resources,
841 mapbase, SZ_4K - 1, irq);
842
843 platform_device_register(&orion_ehci_1);
844 }
845
846 /*****************************************************************************
847 * EHCI2
848 ****************************************************************************/
849 static struct resource orion_ehci_2_resources[2];
850
851 static struct platform_device orion_ehci_2 = {
852 .name = "orion-ehci",
853 .id = 2,
854 .dev = {
855 .dma_mask = &ehci_dmamask,
856 .coherent_dma_mask = DMA_BIT_MASK(32),
857 .platform_data = &orion_ehci_data,
858 },
859 };
860
orion_ehci_2_init(unsigned long mapbase,unsigned long irq)861 void __init orion_ehci_2_init(unsigned long mapbase,
862 unsigned long irq)
863 {
864 fill_resources(&orion_ehci_2, orion_ehci_2_resources,
865 mapbase, SZ_4K - 1, irq);
866
867 platform_device_register(&orion_ehci_2);
868 }
869
870 /*****************************************************************************
871 * SATA
872 ****************************************************************************/
873 static struct resource orion_sata_resources[2] = {
874 {
875 .name = "sata base",
876 }, {
877 .name = "sata irq",
878 },
879 };
880
881 static struct platform_device orion_sata = {
882 .name = "sata_mv",
883 .id = 0,
884 .dev = {
885 .coherent_dma_mask = DMA_BIT_MASK(32),
886 },
887 };
888
orion_sata_init(struct mv_sata_platform_data * sata_data,unsigned long mapbase,unsigned long irq)889 void __init orion_sata_init(struct mv_sata_platform_data *sata_data,
890 unsigned long mapbase,
891 unsigned long irq)
892 {
893 orion_sata.dev.platform_data = sata_data;
894 fill_resources(&orion_sata, orion_sata_resources,
895 mapbase, 0x5000 - 1, irq);
896
897 platform_device_register(&orion_sata);
898 }
899
900 /*****************************************************************************
901 * Cryptographic Engines and Security Accelerator (CESA)
902 ****************************************************************************/
903 static struct resource orion_crypto_resources[] = {
904 {
905 .name = "regs",
906 }, {
907 .name = "crypto interrupt",
908 }, {
909 .name = "sram",
910 .flags = IORESOURCE_MEM,
911 },
912 };
913
914 static struct platform_device orion_crypto = {
915 .name = "mv_crypto",
916 .id = -1,
917 };
918
orion_crypto_init(unsigned long mapbase,unsigned long srambase,unsigned long sram_size,unsigned long irq)919 void __init orion_crypto_init(unsigned long mapbase,
920 unsigned long srambase,
921 unsigned long sram_size,
922 unsigned long irq)
923 {
924 fill_resources(&orion_crypto, orion_crypto_resources,
925 mapbase, 0xffff, irq);
926 orion_crypto.num_resources = 3;
927 orion_crypto_resources[2].start = srambase;
928 orion_crypto_resources[2].end = srambase + sram_size - 1;
929
930 platform_device_register(&orion_crypto);
931 }
932