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#include <mach/bridge-regs.h>
25
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}
182
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}
200
201/*****************************************************************************
202 * GE
203 ****************************************************************************/
204static __init void ge_complete(
205	struct mv643xx_eth_shared_platform_data *orion_ge_shared_data,
206	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->t_clk = tclk;
213	orion_ge_resource->start = irq;
214	orion_ge_resource->end = irq;
215	eth_data->shared = orion_ge_shared;
216	orion_ge->dev.platform_data = eth_data;
217
218	platform_device_register(orion_ge_shared);
219	platform_device_register(orion_ge);
220}
221
222/*****************************************************************************
223 * GE00
224 ****************************************************************************/
225struct mv643xx_eth_shared_platform_data orion_ge00_shared_data;
226
227static struct resource orion_ge00_shared_resources[] = {
228	{
229		.name	= "ge00 base",
230	}, {
231		.name	= "ge00 err irq",
232	},
233};
234
235static struct platform_device orion_ge00_shared = {
236	.name		= MV643XX_ETH_SHARED_NAME,
237	.id		= 0,
238	.dev		= {
239		.platform_data	= &orion_ge00_shared_data,
240	},
241};
242
243static struct resource orion_ge00_resources[] = {
244	{
245		.name	= "ge00 irq",
246		.flags	= IORESOURCE_IRQ,
247	},
248};
249
250static struct platform_device orion_ge00 = {
251	.name		= MV643XX_ETH_NAME,
252	.id		= 0,
253	.num_resources	= 1,
254	.resource	= orion_ge00_resources,
255	.dev		= {
256		.coherent_dma_mask	= DMA_BIT_MASK(32),
257	},
258};
259
260void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
261			    unsigned long mapbase,
262			    unsigned long irq,
263			    unsigned long irq_err,
264			    int tclk)
265{
266	fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
267		       mapbase + 0x2000, SZ_16K - 1, irq_err);
268	ge_complete(&orion_ge00_shared_data, tclk,
269		    orion_ge00_resources, irq, &orion_ge00_shared,
270		    eth_data, &orion_ge00);
271}
272
273/*****************************************************************************
274 * GE01
275 ****************************************************************************/
276struct mv643xx_eth_shared_platform_data orion_ge01_shared_data = {
277	.shared_smi	= &orion_ge00_shared,
278};
279
280static struct resource orion_ge01_shared_resources[] = {
281	{
282		.name	= "ge01 base",
283	}, {
284		.name	= "ge01 err irq",
285	},
286};
287
288static struct platform_device orion_ge01_shared = {
289	.name		= MV643XX_ETH_SHARED_NAME,
290	.id		= 1,
291	.dev		= {
292		.platform_data	= &orion_ge01_shared_data,
293	},
294};
295
296static struct resource orion_ge01_resources[] = {
297	{
298		.name	= "ge01 irq",
299		.flags	= IORESOURCE_IRQ,
300	},
301};
302
303static struct platform_device orion_ge01 = {
304	.name		= MV643XX_ETH_NAME,
305	.id		= 1,
306	.num_resources	= 1,
307	.resource	= orion_ge01_resources,
308	.dev		= {
309		.coherent_dma_mask	= DMA_BIT_MASK(32),
310	},
311};
312
313void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
314			    unsigned long mapbase,
315			    unsigned long irq,
316			    unsigned long irq_err,
317			    int tclk)
318{
319	fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
320		       mapbase + 0x2000, SZ_16K - 1, irq_err);
321	ge_complete(&orion_ge01_shared_data, tclk,
322		    orion_ge01_resources, irq, &orion_ge01_shared,
323		    eth_data, &orion_ge01);
324}
325
326/*****************************************************************************
327 * GE10
328 ****************************************************************************/
329struct mv643xx_eth_shared_platform_data orion_ge10_shared_data = {
330	.shared_smi	= &orion_ge00_shared,
331};
332
333static struct resource orion_ge10_shared_resources[] = {
334	{
335		.name	= "ge10 base",
336	}, {
337		.name	= "ge10 err irq",
338	},
339};
340
341static struct platform_device orion_ge10_shared = {
342	.name		= MV643XX_ETH_SHARED_NAME,
343	.id		= 1,
344	.dev		= {
345		.platform_data	= &orion_ge10_shared_data,
346	},
347};
348
349static struct resource orion_ge10_resources[] = {
350	{
351		.name	= "ge10 irq",
352		.flags	= IORESOURCE_IRQ,
353	},
354};
355
356static struct platform_device orion_ge10 = {
357	.name		= MV643XX_ETH_NAME,
358	.id		= 1,
359	.num_resources	= 2,
360	.resource	= orion_ge10_resources,
361	.dev		= {
362		.coherent_dma_mask	= DMA_BIT_MASK(32),
363	},
364};
365
366void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
367			    unsigned long mapbase,
368			    unsigned long irq,
369			    unsigned long irq_err,
370			    int tclk)
371{
372	fill_resources(&orion_ge10_shared, orion_ge10_shared_resources,
373		       mapbase + 0x2000, SZ_16K - 1, irq_err);
374	ge_complete(&orion_ge10_shared_data, tclk,
375		    orion_ge10_resources, irq, &orion_ge10_shared,
376		    eth_data, &orion_ge10);
377}
378
379/*****************************************************************************
380 * GE11
381 ****************************************************************************/
382struct mv643xx_eth_shared_platform_data orion_ge11_shared_data = {
383	.shared_smi	= &orion_ge00_shared,
384};
385
386static struct resource orion_ge11_shared_resources[] = {
387	{
388		.name	= "ge11 base",
389	}, {
390		.name	= "ge11 err irq",
391	},
392};
393
394static struct platform_device orion_ge11_shared = {
395	.name		= MV643XX_ETH_SHARED_NAME,
396	.id		= 1,
397	.dev		= {
398		.platform_data	= &orion_ge11_shared_data,
399	},
400};
401
402static struct resource orion_ge11_resources[] = {
403	{
404		.name	= "ge11 irq",
405		.flags	= IORESOURCE_IRQ,
406	},
407};
408
409static struct platform_device orion_ge11 = {
410	.name		= MV643XX_ETH_NAME,
411	.id		= 1,
412	.num_resources	= 2,
413	.resource	= orion_ge11_resources,
414	.dev		= {
415		.coherent_dma_mask	= DMA_BIT_MASK(32),
416	},
417};
418
419void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
420			    unsigned long mapbase,
421			    unsigned long irq,
422			    unsigned long irq_err,
423			    int tclk)
424{
425	fill_resources(&orion_ge11_shared, orion_ge11_shared_resources,
426		       mapbase + 0x2000, SZ_16K - 1, irq_err);
427	ge_complete(&orion_ge11_shared_data, tclk,
428		    orion_ge11_resources, irq, &orion_ge11_shared,
429		    eth_data, &orion_ge11);
430}
431
432/*****************************************************************************
433 * Ethernet switch
434 ****************************************************************************/
435static struct resource orion_switch_resources[] = {
436	{
437		.start	= 0,
438		.end	= 0,
439		.flags	= IORESOURCE_IRQ,
440	},
441};
442
443static struct platform_device orion_switch_device = {
444	.name		= "dsa",
445	.id		= 0,
446	.num_resources	= 0,
447	.resource	= orion_switch_resources,
448};
449
450void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq)
451{
452	int i;
453
454	if (irq != NO_IRQ) {
455		orion_switch_resources[0].start = irq;
456		orion_switch_resources[0].end = irq;
457		orion_switch_device.num_resources = 1;
458	}
459
460	d->netdev = &orion_ge00.dev;
461	for (i = 0; i < d->nr_chips; i++)
462		d->chip[i].mii_bus = &orion_ge00_shared.dev;
463	orion_switch_device.dev.platform_data = d;
464
465	platform_device_register(&orion_switch_device);
466}
467
468/*****************************************************************************
469 * I2C
470 ****************************************************************************/
471static struct mv64xxx_i2c_pdata orion_i2c_pdata = {
472	.freq_n		= 3,
473	.timeout	= 1000, /* Default timeout of 1 second */
474};
475
476static struct resource orion_i2c_resources[2];
477
478static struct platform_device orion_i2c = {
479	.name		= MV64XXX_I2C_CTLR_NAME,
480	.id		= 0,
481	.dev		= {
482		.platform_data	= &orion_i2c_pdata,
483	},
484};
485
486static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = {
487	.freq_n		= 3,
488	.timeout	= 1000, /* Default timeout of 1 second */
489};
490
491static struct resource orion_i2c_1_resources[2];
492
493static struct platform_device orion_i2c_1 = {
494	.name		= MV64XXX_I2C_CTLR_NAME,
495	.id		= 1,
496	.dev		= {
497		.platform_data	= &orion_i2c_1_pdata,
498	},
499};
500
501void __init orion_i2c_init(unsigned long mapbase,
502			   unsigned long irq,
503			   unsigned long freq_m)
504{
505	orion_i2c_pdata.freq_m = freq_m;
506	fill_resources(&orion_i2c, orion_i2c_resources, mapbase,
507		       SZ_32 - 1, irq);
508	platform_device_register(&orion_i2c);
509}
510
511void __init orion_i2c_1_init(unsigned long mapbase,
512			     unsigned long irq,
513			     unsigned long freq_m)
514{
515	orion_i2c_1_pdata.freq_m = freq_m;
516	fill_resources(&orion_i2c_1, orion_i2c_1_resources, mapbase,
517		       SZ_32 - 1, irq);
518	platform_device_register(&orion_i2c_1);
519}
520
521/*****************************************************************************
522 * SPI
523 ****************************************************************************/
524static struct orion_spi_info orion_spi_plat_data;
525static struct resource orion_spi_resources;
526
527static struct platform_device orion_spi = {
528	.name		= "orion_spi",
529	.id		= 0,
530	.dev		= {
531		.platform_data	= &orion_spi_plat_data,
532	},
533};
534
535static struct orion_spi_info orion_spi_1_plat_data;
536static struct resource orion_spi_1_resources;
537
538static struct platform_device orion_spi_1 = {
539	.name		= "orion_spi",
540	.id		= 1,
541	.dev		= {
542		.platform_data	= &orion_spi_1_plat_data,
543	},
544};
545
546/* Note: The SPI silicon core does have interrupts. However the
547 * current Linux software driver does not use interrupts. */
548
549void __init orion_spi_init(unsigned long mapbase,
550			   unsigned long tclk)
551{
552	orion_spi_plat_data.tclk = tclk;
553	fill_resources(&orion_spi, &orion_spi_resources,
554		       mapbase, SZ_512 - 1, NO_IRQ);
555	platform_device_register(&orion_spi);
556}
557
558void __init orion_spi_1_init(unsigned long mapbase,
559			     unsigned long tclk)
560{
561	orion_spi_1_plat_data.tclk = tclk;
562	fill_resources(&orion_spi_1, &orion_spi_1_resources,
563		       mapbase, SZ_512 - 1, NO_IRQ);
564	platform_device_register(&orion_spi_1);
565}
566
567/*****************************************************************************
568 * Watchdog
569 ****************************************************************************/
570static struct orion_wdt_platform_data orion_wdt_data;
571
572static struct resource orion_wdt_resource =
573		DEFINE_RES_MEM(TIMER_PHYS_BASE, 0x28);
574
575static struct platform_device orion_wdt_device = {
576	.name		= "orion_wdt",
577	.id		= -1,
578	.dev		= {
579		.platform_data	= &orion_wdt_data,
580	},
581	.resource	= &orion_wdt_resource,
582	.num_resources	= 1,
583};
584
585void __init orion_wdt_init(unsigned long tclk)
586{
587	orion_wdt_data.tclk = tclk;
588	platform_device_register(&orion_wdt_device);
589}
590
591/*****************************************************************************
592 * XOR
593 ****************************************************************************/
594static u64 orion_xor_dmamask = DMA_BIT_MASK(32);
595
596void __init orion_xor_init_channels(
597	struct mv_xor_platform_data *orion_xor0_data,
598	struct platform_device *orion_xor0_channel,
599	struct mv_xor_platform_data *orion_xor1_data,
600	struct platform_device *orion_xor1_channel)
601{
602	/*
603	 * two engines can't do memset simultaneously, this limitation
604	 * satisfied by removing memset support from one of the engines.
605	 */
606	dma_cap_set(DMA_MEMCPY, orion_xor0_data->cap_mask);
607	dma_cap_set(DMA_XOR, orion_xor0_data->cap_mask);
608	platform_device_register(orion_xor0_channel);
609
610	dma_cap_set(DMA_MEMCPY, orion_xor1_data->cap_mask);
611	dma_cap_set(DMA_MEMSET, orion_xor1_data->cap_mask);
612	dma_cap_set(DMA_XOR, orion_xor1_data->cap_mask);
613	platform_device_register(orion_xor1_channel);
614}
615
616/*****************************************************************************
617 * XOR0
618 ****************************************************************************/
619static struct resource orion_xor0_shared_resources[] = {
620	{
621		.name	= "xor 0 low",
622		.flags	= IORESOURCE_MEM,
623	}, {
624		.name	= "xor 0 high",
625		.flags	= IORESOURCE_MEM,
626	},
627};
628
629static struct platform_device orion_xor0_shared = {
630	.name		= MV_XOR_SHARED_NAME,
631	.id		= 0,
632	.num_resources	= ARRAY_SIZE(orion_xor0_shared_resources),
633	.resource	= orion_xor0_shared_resources,
634};
635
636static struct resource orion_xor00_resources[] = {
637	[0] = {
638		.flags	= IORESOURCE_IRQ,
639	},
640};
641
642static struct mv_xor_platform_data orion_xor00_data = {
643	.shared		= &orion_xor0_shared,
644	.hw_id		= 0,
645	.pool_size	= PAGE_SIZE,
646};
647
648static struct platform_device orion_xor00_channel = {
649	.name		= MV_XOR_NAME,
650	.id		= 0,
651	.num_resources	= ARRAY_SIZE(orion_xor00_resources),
652	.resource	= orion_xor00_resources,
653	.dev		= {
654		.dma_mask		= &orion_xor_dmamask,
655		.coherent_dma_mask	= DMA_BIT_MASK(64),
656		.platform_data		= &orion_xor00_data,
657	},
658};
659
660static struct resource orion_xor01_resources[] = {
661	[0] = {
662		.flags	= IORESOURCE_IRQ,
663	},
664};
665
666static struct mv_xor_platform_data orion_xor01_data = {
667	.shared		= &orion_xor0_shared,
668	.hw_id		= 1,
669	.pool_size	= PAGE_SIZE,
670};
671
672static struct platform_device orion_xor01_channel = {
673	.name		= MV_XOR_NAME,
674	.id		= 1,
675	.num_resources	= ARRAY_SIZE(orion_xor01_resources),
676	.resource	= orion_xor01_resources,
677	.dev		= {
678		.dma_mask		= &orion_xor_dmamask,
679		.coherent_dma_mask	= DMA_BIT_MASK(64),
680		.platform_data		= &orion_xor01_data,
681	},
682};
683
684void __init orion_xor0_init(unsigned long mapbase_low,
685			    unsigned long mapbase_high,
686			    unsigned long irq_0,
687			    unsigned long irq_1)
688{
689	orion_xor0_shared_resources[0].start = mapbase_low;
690	orion_xor0_shared_resources[0].end = mapbase_low + 0xff;
691	orion_xor0_shared_resources[1].start = mapbase_high;
692	orion_xor0_shared_resources[1].end = mapbase_high + 0xff;
693
694	orion_xor00_resources[0].start = irq_0;
695	orion_xor00_resources[0].end = irq_0;
696	orion_xor01_resources[0].start = irq_1;
697	orion_xor01_resources[0].end = irq_1;
698
699	platform_device_register(&orion_xor0_shared);
700
701	orion_xor_init_channels(&orion_xor00_data, &orion_xor00_channel,
702				&orion_xor01_data, &orion_xor01_channel);
703}
704
705/*****************************************************************************
706 * XOR1
707 ****************************************************************************/
708static struct resource orion_xor1_shared_resources[] = {
709	{
710		.name	= "xor 1 low",
711		.flags	= IORESOURCE_MEM,
712	}, {
713		.name	= "xor 1 high",
714		.flags	= IORESOURCE_MEM,
715	},
716};
717
718static struct platform_device orion_xor1_shared = {
719	.name		= MV_XOR_SHARED_NAME,
720	.id		= 1,
721	.num_resources	= ARRAY_SIZE(orion_xor1_shared_resources),
722	.resource	= orion_xor1_shared_resources,
723};
724
725static struct resource orion_xor10_resources[] = {
726	[0] = {
727		.flags	= IORESOURCE_IRQ,
728	},
729};
730
731static struct mv_xor_platform_data orion_xor10_data = {
732	.shared		= &orion_xor1_shared,
733	.hw_id		= 0,
734	.pool_size	= PAGE_SIZE,
735};
736
737static struct platform_device orion_xor10_channel = {
738	.name		= MV_XOR_NAME,
739	.id		= 2,
740	.num_resources	= ARRAY_SIZE(orion_xor10_resources),
741	.resource	= orion_xor10_resources,
742	.dev		= {
743		.dma_mask		= &orion_xor_dmamask,
744		.coherent_dma_mask	= DMA_BIT_MASK(64),
745		.platform_data		= &orion_xor10_data,
746	},
747};
748
749static struct resource orion_xor11_resources[] = {
750	[0] = {
751		.flags	= IORESOURCE_IRQ,
752	},
753};
754
755static struct mv_xor_platform_data orion_xor11_data = {
756	.shared		= &orion_xor1_shared,
757	.hw_id		= 1,
758	.pool_size	= PAGE_SIZE,
759};
760
761static struct platform_device orion_xor11_channel = {
762	.name		= MV_XOR_NAME,
763	.id		= 3,
764	.num_resources	= ARRAY_SIZE(orion_xor11_resources),
765	.resource	= orion_xor11_resources,
766	.dev		= {
767		.dma_mask		= &orion_xor_dmamask,
768		.coherent_dma_mask	= DMA_BIT_MASK(64),
769		.platform_data		= &orion_xor11_data,
770	},
771};
772
773void __init orion_xor1_init(unsigned long mapbase_low,
774			    unsigned long mapbase_high,
775			    unsigned long irq_0,
776			    unsigned long irq_1)
777{
778	orion_xor1_shared_resources[0].start = mapbase_low;
779	orion_xor1_shared_resources[0].end = mapbase_low + 0xff;
780	orion_xor1_shared_resources[1].start = mapbase_high;
781	orion_xor1_shared_resources[1].end = mapbase_high + 0xff;
782
783	orion_xor10_resources[0].start = irq_0;
784	orion_xor10_resources[0].end = irq_0;
785	orion_xor11_resources[0].start = irq_1;
786	orion_xor11_resources[0].end = irq_1;
787
788	platform_device_register(&orion_xor1_shared);
789
790	orion_xor_init_channels(&orion_xor10_data, &orion_xor10_channel,
791				&orion_xor11_data, &orion_xor11_channel);
792}
793
794/*****************************************************************************
795 * EHCI
796 ****************************************************************************/
797static struct orion_ehci_data orion_ehci_data;
798static u64 ehci_dmamask = DMA_BIT_MASK(32);
799
800
801/*****************************************************************************
802 * EHCI0
803 ****************************************************************************/
804static struct resource orion_ehci_resources[2];
805
806static struct platform_device orion_ehci = {
807	.name		= "orion-ehci",
808	.id		= 0,
809	.dev		= {
810		.dma_mask		= &ehci_dmamask,
811		.coherent_dma_mask	= DMA_BIT_MASK(32),
812		.platform_data		= &orion_ehci_data,
813	},
814};
815
816void __init orion_ehci_init(unsigned long mapbase,
817			    unsigned long irq,
818			    enum orion_ehci_phy_ver phy_version)
819{
820	orion_ehci_data.phy_version = phy_version;
821	fill_resources(&orion_ehci, orion_ehci_resources, mapbase, SZ_4K - 1,
822		       irq);
823
824	platform_device_register(&orion_ehci);
825}
826
827/*****************************************************************************
828 * EHCI1
829 ****************************************************************************/
830static struct resource orion_ehci_1_resources[2];
831
832static struct platform_device orion_ehci_1 = {
833	.name		= "orion-ehci",
834	.id		= 1,
835	.dev		= {
836		.dma_mask		= &ehci_dmamask,
837		.coherent_dma_mask	= DMA_BIT_MASK(32),
838		.platform_data		= &orion_ehci_data,
839	},
840};
841
842void __init orion_ehci_1_init(unsigned long mapbase,
843			      unsigned long irq)
844{
845	fill_resources(&orion_ehci_1, orion_ehci_1_resources,
846		       mapbase, SZ_4K - 1, irq);
847
848	platform_device_register(&orion_ehci_1);
849}
850
851/*****************************************************************************
852 * EHCI2
853 ****************************************************************************/
854static struct resource orion_ehci_2_resources[2];
855
856static struct platform_device orion_ehci_2 = {
857	.name		= "orion-ehci",
858	.id		= 2,
859	.dev		= {
860		.dma_mask		= &ehci_dmamask,
861		.coherent_dma_mask	= DMA_BIT_MASK(32),
862		.platform_data		= &orion_ehci_data,
863	},
864};
865
866void __init orion_ehci_2_init(unsigned long mapbase,
867			      unsigned long irq)
868{
869	fill_resources(&orion_ehci_2, orion_ehci_2_resources,
870		       mapbase, SZ_4K - 1, irq);
871
872	platform_device_register(&orion_ehci_2);
873}
874
875/*****************************************************************************
876 * SATA
877 ****************************************************************************/
878static struct resource orion_sata_resources[2] = {
879	{
880		.name	= "sata base",
881	}, {
882		.name	= "sata irq",
883	},
884};
885
886static struct platform_device orion_sata = {
887	.name		= "sata_mv",
888	.id		= 0,
889	.dev		= {
890		.coherent_dma_mask	= DMA_BIT_MASK(32),
891	},
892};
893
894void __init orion_sata_init(struct mv_sata_platform_data *sata_data,
895			    unsigned long mapbase,
896			    unsigned long irq)
897{
898	orion_sata.dev.platform_data = sata_data;
899	fill_resources(&orion_sata, orion_sata_resources,
900		       mapbase, 0x5000 - 1, irq);
901
902	platform_device_register(&orion_sata);
903}
904
905/*****************************************************************************
906 * Cryptographic Engines and Security Accelerator (CESA)
907 ****************************************************************************/
908static struct resource orion_crypto_resources[] = {
909	{
910		.name   = "regs",
911	}, {
912		.name   = "crypto interrupt",
913	}, {
914		.name   = "sram",
915		.flags  = IORESOURCE_MEM,
916	},
917};
918
919static struct platform_device orion_crypto = {
920	.name           = "mv_crypto",
921	.id             = -1,
922};
923
924void __init orion_crypto_init(unsigned long mapbase,
925			      unsigned long srambase,
926			      unsigned long sram_size,
927			      unsigned long irq)
928{
929	fill_resources(&orion_crypto, orion_crypto_resources,
930		       mapbase, 0xffff, irq);
931	orion_crypto.num_resources = 3;
932	orion_crypto_resources[2].start = srambase;
933	orion_crypto_resources[2].end = srambase + sram_size - 1;
934
935	platform_device_register(&orion_crypto);
936}
937