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