blob: 8b68a2be0360d26766e13edb422a764e90021c8a [file] [log] [blame]
Andrew Lunn28a2b452011-05-15 13:32:41 +02001/*
2 * arch/arm/plat-orion/common.c
3 *
4 * Marvell Orion SoC common setup code used by multiple mach-/common.c
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/platform_device.h>
Andrew Lunn7e3819d2011-05-15 13:32:44 +020014#include <linux/dma-mapping.h>
Andrew Lunn28a2b452011-05-15 13:32:41 +020015#include <linux/serial_8250.h>
Andrew Lunn9e613f82011-05-15 13:32:50 +020016#include <linux/ata_platform.h>
Andrew Lunn7e3819d2011-05-15 13:32:44 +020017#include <linux/mv643xx_eth.h>
Andrew Lunnaac7ffa2011-05-15 13:32:45 +020018#include <linux/mv643xx_i2c.h>
Andrew Lunn7e3819d2011-05-15 13:32:44 +020019#include <net/dsa.h>
Andrew Lunn980f9f62011-05-15 13:32:46 +020020#include <linux/spi/orion_spi.h>
Andrew Lunn5e00d372011-05-15 13:32:47 +020021#include <plat/orion_wdt.h>
Andrew Lunnee962722011-05-15 13:32:48 +020022#include <plat/mv_xor.h>
Andrew Lunn4fcd3f32011-05-15 13:32:49 +020023#include <plat/ehci-orion.h>
Jason Coopera855a7c2012-03-15 00:33:26 +000024#include <mach/bridge-regs.h>
Andrew Lunn28a2b452011-05-15 13:32:41 +020025
26/* Fill in the resources structure and link it into the platform
27 device structure. There is always a memory region, and nearly
28 always an interrupt.*/
29static void fill_resources(struct platform_device *device,
30 struct resource *resources,
31 resource_size_t mapbase,
32 resource_size_t size,
33 unsigned int irq)
34{
35 device->resource = resources;
36 device->num_resources = 1;
37 resources[0].flags = IORESOURCE_MEM;
38 resources[0].start = mapbase;
39 resources[0].end = mapbase + size;
40
41 if (irq != NO_IRQ) {
42 device->num_resources++;
43 resources[1].flags = IORESOURCE_IRQ;
44 resources[1].start = irq;
45 resources[1].end = irq;
46 }
47}
48
49/*****************************************************************************
50 * UART
51 ****************************************************************************/
52static void __init uart_complete(
53 struct platform_device *orion_uart,
54 struct plat_serial8250_port *data,
55 struct resource *resources,
56 unsigned int membase,
57 resource_size_t mapbase,
58 unsigned int irq,
59 unsigned int uartclk)
60{
61 data->mapbase = mapbase;
62 data->membase = (void __iomem *)membase;
63 data->irq = irq;
64 data->uartclk = uartclk;
65 orion_uart->dev.platform_data = data;
66
67 fill_resources(orion_uart, resources, mapbase, 0xff, irq);
68 platform_device_register(orion_uart);
69}
70
71/*****************************************************************************
72 * UART0
73 ****************************************************************************/
74static struct plat_serial8250_port orion_uart0_data[] = {
75 {
76 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
77 .iotype = UPIO_MEM,
78 .regshift = 2,
79 }, {
80 },
81};
82
83static struct resource orion_uart0_resources[2];
84
85static struct platform_device orion_uart0 = {
86 .name = "serial8250",
87 .id = PLAT8250_DEV_PLATFORM,
88};
89
90void __init orion_uart0_init(unsigned int membase,
91 resource_size_t mapbase,
92 unsigned int irq,
93 unsigned int uartclk)
94{
95 uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources,
96 membase, mapbase, irq, uartclk);
97}
98
99/*****************************************************************************
100 * UART1
101 ****************************************************************************/
102static struct plat_serial8250_port orion_uart1_data[] = {
103 {
104 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
105 .iotype = UPIO_MEM,
106 .regshift = 2,
107 }, {
108 },
109};
110
111static struct resource orion_uart1_resources[2];
112
113static struct platform_device orion_uart1 = {
114 .name = "serial8250",
115 .id = PLAT8250_DEV_PLATFORM1,
116};
117
118void __init orion_uart1_init(unsigned int membase,
119 resource_size_t mapbase,
120 unsigned int irq,
121 unsigned int uartclk)
122{
123 uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources,
124 membase, mapbase, irq, uartclk);
125}
126
127/*****************************************************************************
128 * UART2
129 ****************************************************************************/
130static struct plat_serial8250_port orion_uart2_data[] = {
131 {
132 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
133 .iotype = UPIO_MEM,
134 .regshift = 2,
135 }, {
136 },
137};
138
139static struct resource orion_uart2_resources[2];
140
141static struct platform_device orion_uart2 = {
142 .name = "serial8250",
143 .id = PLAT8250_DEV_PLATFORM2,
144};
145
146void __init orion_uart2_init(unsigned int membase,
147 resource_size_t mapbase,
148 unsigned int irq,
149 unsigned int uartclk)
150{
151 uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources,
152 membase, mapbase, irq, uartclk);
153}
154
155/*****************************************************************************
156 * UART3
157 ****************************************************************************/
158static struct plat_serial8250_port orion_uart3_data[] = {
159 {
160 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
161 .iotype = UPIO_MEM,
162 .regshift = 2,
163 }, {
164 },
165};
166
167static struct resource orion_uart3_resources[2];
168
169static struct platform_device orion_uart3 = {
170 .name = "serial8250",
171 .id = 3,
172};
173
174void __init orion_uart3_init(unsigned int membase,
175 resource_size_t mapbase,
176 unsigned int irq,
177 unsigned int uartclk)
178{
179 uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources,
180 membase, mapbase, irq, uartclk);
181}
Andrew Lunnf6eaccb2011-05-15 13:32:42 +0200182
183/*****************************************************************************
184 * SoC RTC
185 ****************************************************************************/
186static struct resource orion_rtc_resource[2];
187
188void __init orion_rtc_init(unsigned long mapbase,
189 unsigned long irq)
190{
191 orion_rtc_resource[0].start = mapbase;
192 orion_rtc_resource[0].end = mapbase + SZ_32 - 1;
193 orion_rtc_resource[0].flags = IORESOURCE_MEM;
194 orion_rtc_resource[1].start = irq;
195 orion_rtc_resource[1].end = irq;
196 orion_rtc_resource[1].flags = IORESOURCE_IRQ;
197
198 platform_device_register_simple("rtc-mv", -1, orion_rtc_resource, 2);
199}
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200200
201/*****************************************************************************
202 * GE
203 ****************************************************************************/
204static __init void ge_complete(
205 struct mv643xx_eth_shared_platform_data *orion_ge_shared_data,
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100206 int tclk,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200207 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{
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200212 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,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200261 unsigned long mapbase,
262 unsigned long irq,
263 unsigned long irq_err,
Arnaud Patard (Rtp)f9938882012-07-26 12:15:46 +0200264 int tclk,
265 unsigned int tx_csum_limit)
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200266{
267 fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
268 mapbase + 0x2000, SZ_16K - 1, irq_err);
Arnaud Patard (Rtp)f9938882012-07-26 12:15:46 +0200269 orion_ge00_shared_data.tx_csum_limit = tx_csum_limit;
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100270 ge_complete(&orion_ge00_shared_data, tclk,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200271 orion_ge00_resources, irq, &orion_ge00_shared,
272 eth_data, &orion_ge00);
273}
274
275/*****************************************************************************
276 * GE01
277 ****************************************************************************/
278struct mv643xx_eth_shared_platform_data orion_ge01_shared_data = {
279 .shared_smi = &orion_ge00_shared,
280};
281
282static struct resource orion_ge01_shared_resources[] = {
283 {
284 .name = "ge01 base",
285 }, {
286 .name = "ge01 err irq",
287 },
288};
289
290static struct platform_device orion_ge01_shared = {
291 .name = MV643XX_ETH_SHARED_NAME,
292 .id = 1,
293 .dev = {
294 .platform_data = &orion_ge01_shared_data,
295 },
296};
297
298static struct resource orion_ge01_resources[] = {
299 {
300 .name = "ge01 irq",
301 .flags = IORESOURCE_IRQ,
302 },
303};
304
305static struct platform_device orion_ge01 = {
306 .name = MV643XX_ETH_NAME,
307 .id = 1,
308 .num_resources = 1,
309 .resource = orion_ge01_resources,
310 .dev = {
311 .coherent_dma_mask = DMA_BIT_MASK(32),
312 },
313};
314
315void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200316 unsigned long mapbase,
317 unsigned long irq,
318 unsigned long irq_err,
Arnaud Patard (Rtp)f9938882012-07-26 12:15:46 +0200319 int tclk,
320 unsigned int tx_csum_limit)
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200321{
322 fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
323 mapbase + 0x2000, SZ_16K - 1, irq_err);
Arnaud Patard (Rtp)f9938882012-07-26 12:15:46 +0200324 orion_ge01_shared_data.tx_csum_limit = tx_csum_limit;
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100325 ge_complete(&orion_ge01_shared_data, tclk,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200326 orion_ge01_resources, irq, &orion_ge01_shared,
327 eth_data, &orion_ge01);
328}
329
330/*****************************************************************************
331 * GE10
332 ****************************************************************************/
333struct mv643xx_eth_shared_platform_data orion_ge10_shared_data = {
334 .shared_smi = &orion_ge00_shared,
335};
336
337static struct resource orion_ge10_shared_resources[] = {
338 {
339 .name = "ge10 base",
340 }, {
341 .name = "ge10 err irq",
342 },
343};
344
345static struct platform_device orion_ge10_shared = {
346 .name = MV643XX_ETH_SHARED_NAME,
Gregory CLEMENTd8259182013-05-19 22:12:43 +0200347 .id = 2,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200348 .dev = {
349 .platform_data = &orion_ge10_shared_data,
350 },
351};
352
353static struct resource orion_ge10_resources[] = {
354 {
355 .name = "ge10 irq",
356 .flags = IORESOURCE_IRQ,
357 },
358};
359
360static struct platform_device orion_ge10 = {
361 .name = MV643XX_ETH_NAME,
Gregory CLEMENTd8259182013-05-19 22:12:43 +0200362 .id = 2,
363 .num_resources = 1,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200364 .resource = orion_ge10_resources,
365 .dev = {
366 .coherent_dma_mask = DMA_BIT_MASK(32),
367 },
368};
369
370void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200371 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);
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100378 ge_complete(&orion_ge10_shared_data, tclk,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200379 orion_ge10_resources, irq, &orion_ge10_shared,
380 eth_data, &orion_ge10);
381}
382
383/*****************************************************************************
384 * GE11
385 ****************************************************************************/
386struct mv643xx_eth_shared_platform_data orion_ge11_shared_data = {
387 .shared_smi = &orion_ge00_shared,
388};
389
390static struct resource orion_ge11_shared_resources[] = {
391 {
392 .name = "ge11 base",
393 }, {
394 .name = "ge11 err irq",
395 },
396};
397
398static struct platform_device orion_ge11_shared = {
399 .name = MV643XX_ETH_SHARED_NAME,
Gregory CLEMENTd8259182013-05-19 22:12:43 +0200400 .id = 3,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200401 .dev = {
402 .platform_data = &orion_ge11_shared_data,
403 },
404};
405
406static struct resource orion_ge11_resources[] = {
407 {
408 .name = "ge11 irq",
409 .flags = IORESOURCE_IRQ,
410 },
411};
412
413static struct platform_device orion_ge11 = {
414 .name = MV643XX_ETH_NAME,
Gregory CLEMENTd8259182013-05-19 22:12:43 +0200415 .id = 3,
416 .num_resources = 1,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200417 .resource = orion_ge11_resources,
418 .dev = {
419 .coherent_dma_mask = DMA_BIT_MASK(32),
420 },
421};
422
423void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200424 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);
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100431 ge_complete(&orion_ge11_shared_data, tclk,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200432 orion_ge11_resources, irq, &orion_ge11_shared,
433 eth_data, &orion_ge11);
434}
435
436/*****************************************************************************
437 * Ethernet switch
438 ****************************************************************************/
439static struct resource orion_switch_resources[] = {
440 {
441 .start = 0,
442 .end = 0,
443 .flags = IORESOURCE_IRQ,
444 },
445};
446
447static struct platform_device orion_switch_device = {
448 .name = "dsa",
449 .id = 0,
450 .num_resources = 0,
451 .resource = orion_switch_resources,
452};
453
454void __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}
Andrew Lunnaac7ffa2011-05-15 13:32:45 +0200471
472/*****************************************************************************
473 * I2C
474 ****************************************************************************/
475static struct mv64xxx_i2c_pdata orion_i2c_pdata = {
476 .freq_n = 3,
477 .timeout = 1000, /* Default timeout of 1 second */
478};
479
480static struct resource orion_i2c_resources[2];
481
482static 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
490static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = {
491 .freq_n = 3,
492 .timeout = 1000, /* Default timeout of 1 second */
493};
494
495static struct resource orion_i2c_1_resources[2];
496
497static 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
505void __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
515void __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}
Andrew Lunn980f9f62011-05-15 13:32:46 +0200524
525/*****************************************************************************
526 * SPI
527 ****************************************************************************/
528static struct orion_spi_info orion_spi_plat_data;
529static struct resource orion_spi_resources;
530
531static struct platform_device orion_spi = {
532 .name = "orion_spi",
533 .id = 0,
534 .dev = {
535 .platform_data = &orion_spi_plat_data,
536 },
537};
538
539static struct orion_spi_info orion_spi_1_plat_data;
540static struct resource orion_spi_1_resources;
541
542static 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
553void __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
562void __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}
Andrew Lunn5e00d372011-05-15 13:32:47 +0200570
571/*****************************************************************************
572 * Watchdog
573 ****************************************************************************/
574static struct orion_wdt_platform_data orion_wdt_data;
575
Jason Coopera855a7c2012-03-15 00:33:26 +0000576static struct resource orion_wdt_resource =
Andrew Lunncb739ad2012-06-22 08:54:02 +0200577 DEFINE_RES_MEM(TIMER_PHYS_BASE, 0x28);
Jason Coopera855a7c2012-03-15 00:33:26 +0000578
Andrew Lunn5e00d372011-05-15 13:32:47 +0200579static struct platform_device orion_wdt_device = {
580 .name = "orion_wdt",
581 .id = -1,
582 .dev = {
583 .platform_data = &orion_wdt_data,
584 },
Jason Coopera855a7c2012-03-15 00:33:26 +0000585 .resource = &orion_wdt_resource,
586 .num_resources = 1,
Andrew Lunn5e00d372011-05-15 13:32:47 +0200587};
588
589void __init orion_wdt_init(unsigned long tclk)
590{
591 orion_wdt_data.tclk = tclk;
592 platform_device_register(&orion_wdt_device);
593}
Andrew Lunnee962722011-05-15 13:32:48 +0200594
595/*****************************************************************************
596 * XOR
597 ****************************************************************************/
Andrew Lunnee962722011-05-15 13:32:48 +0200598static u64 orion_xor_dmamask = DMA_BIT_MASK(32);
599
600void __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 ****************************************************************************/
623static 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
633static struct platform_device orion_xor0_shared = {
634 .name = MV_XOR_SHARED_NAME,
635 .id = 0,
Andrew Lunnee962722011-05-15 13:32:48 +0200636 .num_resources = ARRAY_SIZE(orion_xor0_shared_resources),
637 .resource = orion_xor0_shared_resources,
638};
639
640static struct resource orion_xor00_resources[] = {
641 [0] = {
642 .flags = IORESOURCE_IRQ,
643 },
644};
645
646static struct mv_xor_platform_data orion_xor00_data = {
647 .shared = &orion_xor0_shared,
648 .hw_id = 0,
649 .pool_size = PAGE_SIZE,
650};
651
652static 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
664static struct resource orion_xor01_resources[] = {
665 [0] = {
666 .flags = IORESOURCE_IRQ,
667 },
668};
669
670static struct mv_xor_platform_data orion_xor01_data = {
671 .shared = &orion_xor0_shared,
672 .hw_id = 1,
673 .pool_size = PAGE_SIZE,
674};
675
676static 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
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100688void __init orion_xor0_init(unsigned long mapbase_low,
Andrew Lunnee962722011-05-15 13:32:48 +0200689 unsigned long mapbase_high,
690 unsigned long irq_0,
691 unsigned long irq_1)
692{
Andrew Lunnee962722011-05-15 13:32:48 +0200693 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 ****************************************************************************/
712static 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
722static struct platform_device orion_xor1_shared = {
723 .name = MV_XOR_SHARED_NAME,
724 .id = 1,
Andrew Lunnee962722011-05-15 13:32:48 +0200725 .num_resources = ARRAY_SIZE(orion_xor1_shared_resources),
726 .resource = orion_xor1_shared_resources,
727};
728
729static struct resource orion_xor10_resources[] = {
730 [0] = {
731 .flags = IORESOURCE_IRQ,
732 },
733};
734
735static struct mv_xor_platform_data orion_xor10_data = {
736 .shared = &orion_xor1_shared,
737 .hw_id = 0,
738 .pool_size = PAGE_SIZE,
739};
740
741static 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
753static struct resource orion_xor11_resources[] = {
754 [0] = {
755 .flags = IORESOURCE_IRQ,
756 },
757};
758
759static struct mv_xor_platform_data orion_xor11_data = {
760 .shared = &orion_xor1_shared,
761 .hw_id = 1,
762 .pool_size = PAGE_SIZE,
763};
764
765static 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
777void __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}
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200797
798/*****************************************************************************
799 * EHCI
800 ****************************************************************************/
Andrew Lunn72053352012-02-08 15:52:47 +0100801static struct orion_ehci_data orion_ehci_data;
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200802static u64 ehci_dmamask = DMA_BIT_MASK(32);
803
804
805/*****************************************************************************
806 * EHCI0
807 ****************************************************************************/
808static struct resource orion_ehci_resources[2];
809
810static 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
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100820void __init orion_ehci_init(unsigned long mapbase,
Andrew Lunn72053352012-02-08 15:52:47 +0100821 unsigned long irq,
822 enum orion_ehci_phy_ver phy_version)
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200823{
Andrew Lunn72053352012-02-08 15:52:47 +0100824 orion_ehci_data.phy_version = phy_version;
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200825 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 ****************************************************************************/
834static struct resource orion_ehci_1_resources[2];
835
836static 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
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100846void __init orion_ehci_1_init(unsigned long mapbase,
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200847 unsigned long irq)
848{
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200849 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 ****************************************************************************/
858static struct resource orion_ehci_2_resources[2];
859
860static 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
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100870void __init orion_ehci_2_init(unsigned long mapbase,
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200871 unsigned long irq)
872{
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200873 fill_resources(&orion_ehci_2, orion_ehci_2_resources,
874 mapbase, SZ_4K - 1, irq);
875
876 platform_device_register(&orion_ehci_2);
877}
Andrew Lunn9e613f82011-05-15 13:32:50 +0200878
879/*****************************************************************************
880 * SATA
881 ****************************************************************************/
882static struct resource orion_sata_resources[2] = {
883 {
884 .name = "sata base",
885 }, {
886 .name = "sata irq",
887 },
888};
889
890static 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
898void __init orion_sata_init(struct mv_sata_platform_data *sata_data,
Andrew Lunn9e613f82011-05-15 13:32:50 +0200899 unsigned long mapbase,
900 unsigned long irq)
901{
Andrew Lunn9e613f82011-05-15 13:32:50 +0200902 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
Andrew Lunn44350062011-05-15 13:32:51 +0200909/*****************************************************************************
910 * Cryptographic Engines and Security Accelerator (CESA)
911 ****************************************************************************/
912static struct resource orion_crypto_resources[] = {
913 {
914 .name = "regs",
915 }, {
916 .name = "crypto interrupt",
917 }, {
918 .name = "sram",
919 .flags = IORESOURCE_MEM,
920 },
921};
Andrew Lunn9e613f82011-05-15 13:32:50 +0200922
Andrew Lunn44350062011-05-15 13:32:51 +0200923static struct platform_device orion_crypto = {
924 .name = "mv_crypto",
925 .id = -1,
926};
927
928void __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}