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