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