blob: 800af19c51c59a16999ce05f7a12e3f92d92338a [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 Lunn2f129bf2011-12-15 08:15:07 +010017#include <linux/clk.h>
18#include <linux/clkdev.h>
Andrew Lunn7e3819d2011-05-15 13:32:44 +020019#include <linux/mv643xx_eth.h>
Andrew Lunnaac7ffa2011-05-15 13:32:45 +020020#include <linux/mv643xx_i2c.h>
Andrew Lunn7e3819d2011-05-15 13:32:44 +020021#include <net/dsa.h>
Arnd Bergmannc02cecb2012-08-24 15:21:54 +020022#include <linux/platform_data/dma-mv_xor.h>
23#include <linux/platform_data/usb-ehci-orion.h>
Jason Coopera855a7c2012-03-15 00:33:26 +000024#include <mach/bridge-regs.h>
Andrew Lunn28a2b452011-05-15 13:32:41 +020025
Andrew Lunn4574b882012-04-06 17:17:26 +020026/* Create a clkdev entry for a given device/clk */
27void __init orion_clkdev_add(const char *con_id, const char *dev_id,
28 struct clk *clk)
29{
30 struct clk_lookup *cl;
31
32 cl = clkdev_alloc(clk, con_id, dev_id);
33 if (cl)
34 clkdev_add(cl);
35}
36
37/* Create clkdev entries for all orion platforms except kirkwood.
38 Kirkwood has gated clocks for some of its peripherals, so creates
39 its own clkdev entries. For all the other orion devices, create
40 clkdev entries to the tclk. */
41void __init orion_clkdev_init(struct clk *tclk)
42{
43 orion_clkdev_add(NULL, "orion_spi.0", tclk);
44 orion_clkdev_add(NULL, "orion_spi.1", tclk);
Andrew Lunn452503e2011-12-24 01:24:24 +010045 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".0", tclk);
46 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", tclk);
47 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".2", tclk);
48 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".3", tclk);
Andrew Lunn4f04be62012-03-04 16:57:31 +010049 orion_clkdev_add(NULL, "orion_wdt", tclk);
Andrew Lunne91cac02012-07-20 13:51:55 +020050 orion_clkdev_add(NULL, MV64XXX_I2C_CTLR_NAME ".0", tclk);
Andrew Lunn4574b882012-04-06 17:17:26 +020051}
52
Andrew Lunn28a2b452011-05-15 13:32:41 +020053/* Fill in the resources structure and link it into the platform
54 device structure. There is always a memory region, and nearly
55 always an interrupt.*/
56static void fill_resources(struct platform_device *device,
57 struct resource *resources,
58 resource_size_t mapbase,
59 resource_size_t size,
60 unsigned int irq)
61{
62 device->resource = resources;
63 device->num_resources = 1;
64 resources[0].flags = IORESOURCE_MEM;
65 resources[0].start = mapbase;
66 resources[0].end = mapbase + size;
67
68 if (irq != NO_IRQ) {
69 device->num_resources++;
70 resources[1].flags = IORESOURCE_IRQ;
71 resources[1].start = irq;
72 resources[1].end = irq;
73 }
74}
75
76/*****************************************************************************
77 * UART
78 ****************************************************************************/
Andrew Lunn74c33572011-12-24 03:06:34 +010079static unsigned long __init uart_get_clk_rate(struct clk *clk)
80{
81 clk_prepare_enable(clk);
82 return clk_get_rate(clk);
83}
84
Andrew Lunn28a2b452011-05-15 13:32:41 +020085static void __init uart_complete(
86 struct platform_device *orion_uart,
87 struct plat_serial8250_port *data,
88 struct resource *resources,
Thomas Petazzonid19beac2012-09-11 14:27:23 +020089 void __iomem *membase,
Andrew Lunn28a2b452011-05-15 13:32:41 +020090 resource_size_t mapbase,
91 unsigned int irq,
Andrew Lunn74c33572011-12-24 03:06:34 +010092 struct clk *clk)
Andrew Lunn28a2b452011-05-15 13:32:41 +020093{
94 data->mapbase = mapbase;
Thomas Petazzonid19beac2012-09-11 14:27:23 +020095 data->membase = membase;
Andrew Lunn28a2b452011-05-15 13:32:41 +020096 data->irq = irq;
Andrew Lunn74c33572011-12-24 03:06:34 +010097 data->uartclk = uart_get_clk_rate(clk);
Andrew Lunn28a2b452011-05-15 13:32:41 +020098 orion_uart->dev.platform_data = data;
99
100 fill_resources(orion_uart, resources, mapbase, 0xff, irq);
101 platform_device_register(orion_uart);
102}
103
104/*****************************************************************************
105 * UART0
106 ****************************************************************************/
107static struct plat_serial8250_port orion_uart0_data[] = {
108 {
109 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
110 .iotype = UPIO_MEM,
111 .regshift = 2,
112 }, {
113 },
114};
115
116static struct resource orion_uart0_resources[2];
117
118static struct platform_device orion_uart0 = {
119 .name = "serial8250",
120 .id = PLAT8250_DEV_PLATFORM,
121};
122
Thomas Petazzonid19beac2012-09-11 14:27:23 +0200123void __init orion_uart0_init(void __iomem *membase,
Andrew Lunn28a2b452011-05-15 13:32:41 +0200124 resource_size_t mapbase,
125 unsigned int irq,
Andrew Lunn74c33572011-12-24 03:06:34 +0100126 struct clk *clk)
Andrew Lunn28a2b452011-05-15 13:32:41 +0200127{
128 uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources,
Andrew Lunn74c33572011-12-24 03:06:34 +0100129 membase, mapbase, irq, clk);
Andrew Lunn28a2b452011-05-15 13:32:41 +0200130}
131
132/*****************************************************************************
133 * UART1
134 ****************************************************************************/
135static struct plat_serial8250_port orion_uart1_data[] = {
136 {
137 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
138 .iotype = UPIO_MEM,
139 .regshift = 2,
140 }, {
141 },
142};
143
144static struct resource orion_uart1_resources[2];
145
146static struct platform_device orion_uart1 = {
147 .name = "serial8250",
148 .id = PLAT8250_DEV_PLATFORM1,
149};
150
Thomas Petazzonid19beac2012-09-11 14:27:23 +0200151void __init orion_uart1_init(void __iomem *membase,
Andrew Lunn28a2b452011-05-15 13:32:41 +0200152 resource_size_t mapbase,
153 unsigned int irq,
Andrew Lunn74c33572011-12-24 03:06:34 +0100154 struct clk *clk)
Andrew Lunn28a2b452011-05-15 13:32:41 +0200155{
156 uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources,
Andrew Lunn74c33572011-12-24 03:06:34 +0100157 membase, mapbase, irq, clk);
Andrew Lunn28a2b452011-05-15 13:32:41 +0200158}
159
160/*****************************************************************************
161 * UART2
162 ****************************************************************************/
163static struct plat_serial8250_port orion_uart2_data[] = {
164 {
165 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
166 .iotype = UPIO_MEM,
167 .regshift = 2,
168 }, {
169 },
170};
171
172static struct resource orion_uart2_resources[2];
173
174static struct platform_device orion_uart2 = {
175 .name = "serial8250",
176 .id = PLAT8250_DEV_PLATFORM2,
177};
178
Thomas Petazzonid19beac2012-09-11 14:27:23 +0200179void __init orion_uart2_init(void __iomem *membase,
Andrew Lunn28a2b452011-05-15 13:32:41 +0200180 resource_size_t mapbase,
181 unsigned int irq,
Andrew Lunn74c33572011-12-24 03:06:34 +0100182 struct clk *clk)
Andrew Lunn28a2b452011-05-15 13:32:41 +0200183{
184 uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources,
Andrew Lunn74c33572011-12-24 03:06:34 +0100185 membase, mapbase, irq, clk);
Andrew Lunn28a2b452011-05-15 13:32:41 +0200186}
187
188/*****************************************************************************
189 * UART3
190 ****************************************************************************/
191static struct plat_serial8250_port orion_uart3_data[] = {
192 {
193 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
194 .iotype = UPIO_MEM,
195 .regshift = 2,
196 }, {
197 },
198};
199
200static struct resource orion_uart3_resources[2];
201
202static struct platform_device orion_uart3 = {
203 .name = "serial8250",
204 .id = 3,
205};
206
Thomas Petazzonid19beac2012-09-11 14:27:23 +0200207void __init orion_uart3_init(void __iomem *membase,
Andrew Lunn28a2b452011-05-15 13:32:41 +0200208 resource_size_t mapbase,
209 unsigned int irq,
Andrew Lunn74c33572011-12-24 03:06:34 +0100210 struct clk *clk)
Andrew Lunn28a2b452011-05-15 13:32:41 +0200211{
212 uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources,
Andrew Lunn74c33572011-12-24 03:06:34 +0100213 membase, mapbase, irq, clk);
Andrew Lunn28a2b452011-05-15 13:32:41 +0200214}
Andrew Lunnf6eaccb2011-05-15 13:32:42 +0200215
216/*****************************************************************************
217 * SoC RTC
218 ****************************************************************************/
219static struct resource orion_rtc_resource[2];
220
221void __init orion_rtc_init(unsigned long mapbase,
222 unsigned long irq)
223{
224 orion_rtc_resource[0].start = mapbase;
225 orion_rtc_resource[0].end = mapbase + SZ_32 - 1;
226 orion_rtc_resource[0].flags = IORESOURCE_MEM;
227 orion_rtc_resource[1].start = irq;
228 orion_rtc_resource[1].end = irq;
229 orion_rtc_resource[1].flags = IORESOURCE_IRQ;
230
231 platform_device_register_simple("rtc-mv", -1, orion_rtc_resource, 2);
232}
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200233
234/*****************************************************************************
235 * GE
236 ****************************************************************************/
237static __init void ge_complete(
238 struct mv643xx_eth_shared_platform_data *orion_ge_shared_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200239 struct resource *orion_ge_resource, unsigned long irq,
240 struct platform_device *orion_ge_shared,
241 struct mv643xx_eth_platform_data *eth_data,
242 struct platform_device *orion_ge)
243{
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200244 orion_ge_resource->start = irq;
245 orion_ge_resource->end = irq;
246 eth_data->shared = orion_ge_shared;
247 orion_ge->dev.platform_data = eth_data;
248
249 platform_device_register(orion_ge_shared);
250 platform_device_register(orion_ge);
251}
252
253/*****************************************************************************
254 * GE00
255 ****************************************************************************/
256struct mv643xx_eth_shared_platform_data orion_ge00_shared_data;
257
258static struct resource orion_ge00_shared_resources[] = {
259 {
260 .name = "ge00 base",
261 }, {
262 .name = "ge00 err irq",
263 },
264};
265
266static struct platform_device orion_ge00_shared = {
267 .name = MV643XX_ETH_SHARED_NAME,
268 .id = 0,
269 .dev = {
270 .platform_data = &orion_ge00_shared_data,
271 },
272};
273
274static struct resource orion_ge00_resources[] = {
275 {
276 .name = "ge00 irq",
277 .flags = IORESOURCE_IRQ,
278 },
279};
280
281static struct platform_device orion_ge00 = {
282 .name = MV643XX_ETH_NAME,
283 .id = 0,
284 .num_resources = 1,
285 .resource = orion_ge00_resources,
286 .dev = {
287 .coherent_dma_mask = DMA_BIT_MASK(32),
288 },
289};
290
291void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200292 unsigned long mapbase,
293 unsigned long irq,
Arnaud Patard (Rtp)58569ae2012-07-26 12:15:46 +0200294 unsigned long irq_err,
295 unsigned int tx_csum_limit)
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200296{
297 fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
298 mapbase + 0x2000, SZ_16K - 1, irq_err);
Arnaud Patard (Rtp)58569ae2012-07-26 12:15:46 +0200299 orion_ge00_shared_data.tx_csum_limit = tx_csum_limit;
Andrew Lunn452503e2011-12-24 01:24:24 +0100300 ge_complete(&orion_ge00_shared_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200301 orion_ge00_resources, irq, &orion_ge00_shared,
302 eth_data, &orion_ge00);
303}
304
305/*****************************************************************************
306 * GE01
307 ****************************************************************************/
308struct mv643xx_eth_shared_platform_data orion_ge01_shared_data = {
309 .shared_smi = &orion_ge00_shared,
310};
311
312static struct resource orion_ge01_shared_resources[] = {
313 {
314 .name = "ge01 base",
315 }, {
316 .name = "ge01 err irq",
317 },
318};
319
320static struct platform_device orion_ge01_shared = {
321 .name = MV643XX_ETH_SHARED_NAME,
322 .id = 1,
323 .dev = {
324 .platform_data = &orion_ge01_shared_data,
325 },
326};
327
328static struct resource orion_ge01_resources[] = {
329 {
330 .name = "ge01 irq",
331 .flags = IORESOURCE_IRQ,
332 },
333};
334
335static struct platform_device orion_ge01 = {
336 .name = MV643XX_ETH_NAME,
337 .id = 1,
338 .num_resources = 1,
339 .resource = orion_ge01_resources,
340 .dev = {
341 .coherent_dma_mask = DMA_BIT_MASK(32),
342 },
343};
344
345void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200346 unsigned long mapbase,
347 unsigned long irq,
Arnaud Patard (Rtp)58569ae2012-07-26 12:15:46 +0200348 unsigned long irq_err,
349 unsigned int tx_csum_limit)
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200350{
351 fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
352 mapbase + 0x2000, SZ_16K - 1, irq_err);
Arnaud Patard (Rtp)58569ae2012-07-26 12:15:46 +0200353 orion_ge01_shared_data.tx_csum_limit = tx_csum_limit;
Andrew Lunn452503e2011-12-24 01:24:24 +0100354 ge_complete(&orion_ge01_shared_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200355 orion_ge01_resources, irq, &orion_ge01_shared,
356 eth_data, &orion_ge01);
357}
358
359/*****************************************************************************
360 * GE10
361 ****************************************************************************/
362struct mv643xx_eth_shared_platform_data orion_ge10_shared_data = {
363 .shared_smi = &orion_ge00_shared,
364};
365
366static struct resource orion_ge10_shared_resources[] = {
367 {
368 .name = "ge10 base",
369 }, {
370 .name = "ge10 err irq",
371 },
372};
373
374static struct platform_device orion_ge10_shared = {
375 .name = MV643XX_ETH_SHARED_NAME,
376 .id = 1,
377 .dev = {
378 .platform_data = &orion_ge10_shared_data,
379 },
380};
381
382static struct resource orion_ge10_resources[] = {
383 {
384 .name = "ge10 irq",
385 .flags = IORESOURCE_IRQ,
386 },
387};
388
389static struct platform_device orion_ge10 = {
390 .name = MV643XX_ETH_NAME,
391 .id = 1,
392 .num_resources = 2,
393 .resource = orion_ge10_resources,
394 .dev = {
395 .coherent_dma_mask = DMA_BIT_MASK(32),
396 },
397};
398
399void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200400 unsigned long mapbase,
401 unsigned long irq,
Andrew Lunn452503e2011-12-24 01:24:24 +0100402 unsigned long irq_err)
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200403{
404 fill_resources(&orion_ge10_shared, orion_ge10_shared_resources,
405 mapbase + 0x2000, SZ_16K - 1, irq_err);
Andrew Lunn452503e2011-12-24 01:24:24 +0100406 ge_complete(&orion_ge10_shared_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200407 orion_ge10_resources, irq, &orion_ge10_shared,
408 eth_data, &orion_ge10);
409}
410
411/*****************************************************************************
412 * GE11
413 ****************************************************************************/
414struct mv643xx_eth_shared_platform_data orion_ge11_shared_data = {
415 .shared_smi = &orion_ge00_shared,
416};
417
418static struct resource orion_ge11_shared_resources[] = {
419 {
420 .name = "ge11 base",
421 }, {
422 .name = "ge11 err irq",
423 },
424};
425
426static struct platform_device orion_ge11_shared = {
427 .name = MV643XX_ETH_SHARED_NAME,
428 .id = 1,
429 .dev = {
430 .platform_data = &orion_ge11_shared_data,
431 },
432};
433
434static struct resource orion_ge11_resources[] = {
435 {
436 .name = "ge11 irq",
437 .flags = IORESOURCE_IRQ,
438 },
439};
440
441static struct platform_device orion_ge11 = {
442 .name = MV643XX_ETH_NAME,
443 .id = 1,
444 .num_resources = 2,
445 .resource = orion_ge11_resources,
446 .dev = {
447 .coherent_dma_mask = DMA_BIT_MASK(32),
448 },
449};
450
451void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200452 unsigned long mapbase,
453 unsigned long irq,
Andrew Lunn452503e2011-12-24 01:24:24 +0100454 unsigned long irq_err)
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200455{
456 fill_resources(&orion_ge11_shared, orion_ge11_shared_resources,
457 mapbase + 0x2000, SZ_16K - 1, irq_err);
Andrew Lunn452503e2011-12-24 01:24:24 +0100458 ge_complete(&orion_ge11_shared_data,
Andrew Lunn7e3819d2011-05-15 13:32:44 +0200459 orion_ge11_resources, irq, &orion_ge11_shared,
460 eth_data, &orion_ge11);
461}
462
463/*****************************************************************************
464 * Ethernet switch
465 ****************************************************************************/
466static struct resource orion_switch_resources[] = {
467 {
468 .start = 0,
469 .end = 0,
470 .flags = IORESOURCE_IRQ,
471 },
472};
473
474static struct platform_device orion_switch_device = {
475 .name = "dsa",
476 .id = 0,
477 .num_resources = 0,
478 .resource = orion_switch_resources,
479};
480
481void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq)
482{
483 int i;
484
485 if (irq != NO_IRQ) {
486 orion_switch_resources[0].start = irq;
487 orion_switch_resources[0].end = irq;
488 orion_switch_device.num_resources = 1;
489 }
490
491 d->netdev = &orion_ge00.dev;
492 for (i = 0; i < d->nr_chips; i++)
493 d->chip[i].mii_bus = &orion_ge00_shared.dev;
494 orion_switch_device.dev.platform_data = d;
495
496 platform_device_register(&orion_switch_device);
497}
Andrew Lunnaac7ffa2011-05-15 13:32:45 +0200498
499/*****************************************************************************
500 * I2C
501 ****************************************************************************/
502static struct mv64xxx_i2c_pdata orion_i2c_pdata = {
503 .freq_n = 3,
504 .timeout = 1000, /* Default timeout of 1 second */
505};
506
507static struct resource orion_i2c_resources[2];
508
509static struct platform_device orion_i2c = {
510 .name = MV64XXX_I2C_CTLR_NAME,
511 .id = 0,
512 .dev = {
513 .platform_data = &orion_i2c_pdata,
514 },
515};
516
517static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = {
518 .freq_n = 3,
519 .timeout = 1000, /* Default timeout of 1 second */
520};
521
522static struct resource orion_i2c_1_resources[2];
523
524static struct platform_device orion_i2c_1 = {
525 .name = MV64XXX_I2C_CTLR_NAME,
526 .id = 1,
527 .dev = {
528 .platform_data = &orion_i2c_1_pdata,
529 },
530};
531
532void __init orion_i2c_init(unsigned long mapbase,
533 unsigned long irq,
534 unsigned long freq_m)
535{
536 orion_i2c_pdata.freq_m = freq_m;
537 fill_resources(&orion_i2c, orion_i2c_resources, mapbase,
538 SZ_32 - 1, irq);
539 platform_device_register(&orion_i2c);
540}
541
542void __init orion_i2c_1_init(unsigned long mapbase,
543 unsigned long irq,
544 unsigned long freq_m)
545{
546 orion_i2c_1_pdata.freq_m = freq_m;
547 fill_resources(&orion_i2c_1, orion_i2c_1_resources, mapbase,
548 SZ_32 - 1, irq);
549 platform_device_register(&orion_i2c_1);
550}
Andrew Lunn980f9f62011-05-15 13:32:46 +0200551
552/*****************************************************************************
553 * SPI
554 ****************************************************************************/
Andrew Lunn980f9f62011-05-15 13:32:46 +0200555static struct resource orion_spi_resources;
556
557static struct platform_device orion_spi = {
558 .name = "orion_spi",
559 .id = 0,
Andrew Lunn980f9f62011-05-15 13:32:46 +0200560};
561
Andrew Lunn980f9f62011-05-15 13:32:46 +0200562static struct resource orion_spi_1_resources;
563
564static struct platform_device orion_spi_1 = {
565 .name = "orion_spi",
566 .id = 1,
Andrew Lunn980f9f62011-05-15 13:32:46 +0200567};
568
569/* Note: The SPI silicon core does have interrupts. However the
570 * current Linux software driver does not use interrupts. */
571
Andrew Lunn4574b882012-04-06 17:17:26 +0200572void __init orion_spi_init(unsigned long mapbase)
Andrew Lunn980f9f62011-05-15 13:32:46 +0200573{
Andrew Lunn980f9f62011-05-15 13:32:46 +0200574 fill_resources(&orion_spi, &orion_spi_resources,
575 mapbase, SZ_512 - 1, NO_IRQ);
576 platform_device_register(&orion_spi);
577}
578
Andrew Lunn4574b882012-04-06 17:17:26 +0200579void __init orion_spi_1_init(unsigned long mapbase)
Andrew Lunn980f9f62011-05-15 13:32:46 +0200580{
Andrew Lunn980f9f62011-05-15 13:32:46 +0200581 fill_resources(&orion_spi_1, &orion_spi_1_resources,
582 mapbase, SZ_512 - 1, NO_IRQ);
583 platform_device_register(&orion_spi_1);
584}
Andrew Lunn5e00d372011-05-15 13:32:47 +0200585
586/*****************************************************************************
587 * Watchdog
588 ****************************************************************************/
Jason Coopera855a7c2012-03-15 00:33:26 +0000589static struct resource orion_wdt_resource =
Andrew Lunn0fa1f062012-06-22 08:54:02 +0200590 DEFINE_RES_MEM(TIMER_PHYS_BASE, 0x28);
Jason Coopera855a7c2012-03-15 00:33:26 +0000591
Andrew Lunn5e00d372011-05-15 13:32:47 +0200592static struct platform_device orion_wdt_device = {
593 .name = "orion_wdt",
594 .id = -1,
Jason Coopera855a7c2012-03-15 00:33:26 +0000595 .num_resources = 1,
Andrew Lunn4f04be62012-03-04 16:57:31 +0100596 .resource = &orion_wdt_resource,
Andrew Lunn5e00d372011-05-15 13:32:47 +0200597};
598
Andrew Lunn4f04be62012-03-04 16:57:31 +0100599void __init orion_wdt_init(void)
Andrew Lunn5e00d372011-05-15 13:32:47 +0200600{
Andrew Lunn5e00d372011-05-15 13:32:47 +0200601 platform_device_register(&orion_wdt_device);
602}
Andrew Lunnee962722011-05-15 13:32:48 +0200603
604/*****************************************************************************
605 * XOR
606 ****************************************************************************/
Andrew Lunnee962722011-05-15 13:32:48 +0200607static u64 orion_xor_dmamask = DMA_BIT_MASK(32);
608
609void __init orion_xor_init_channels(
610 struct mv_xor_platform_data *orion_xor0_data,
611 struct platform_device *orion_xor0_channel,
612 struct mv_xor_platform_data *orion_xor1_data,
613 struct platform_device *orion_xor1_channel)
614{
615 /*
616 * two engines can't do memset simultaneously, this limitation
617 * satisfied by removing memset support from one of the engines.
618 */
619 dma_cap_set(DMA_MEMCPY, orion_xor0_data->cap_mask);
620 dma_cap_set(DMA_XOR, orion_xor0_data->cap_mask);
621 platform_device_register(orion_xor0_channel);
622
623 dma_cap_set(DMA_MEMCPY, orion_xor1_data->cap_mask);
624 dma_cap_set(DMA_MEMSET, orion_xor1_data->cap_mask);
625 dma_cap_set(DMA_XOR, orion_xor1_data->cap_mask);
626 platform_device_register(orion_xor1_channel);
627}
628
629/*****************************************************************************
630 * XOR0
631 ****************************************************************************/
632static struct resource orion_xor0_shared_resources[] = {
633 {
634 .name = "xor 0 low",
635 .flags = IORESOURCE_MEM,
636 }, {
637 .name = "xor 0 high",
638 .flags = IORESOURCE_MEM,
Thomas Petazzoniaf19e142012-10-29 17:45:21 +0100639 }, {
640 .name = "irq channel 0",
641 .flags = IORESOURCE_IRQ,
642 }, {
643 .name = "irq channel 1",
644 .flags = IORESOURCE_IRQ,
Andrew Lunnee962722011-05-15 13:32:48 +0200645 },
646};
647
Thomas Petazzoniaf19e142012-10-29 17:45:21 +0100648static struct platform_device orion_xor0_shared;
649
650static struct mv_xor_platform_data orion_xor0_channels_pdata[2] = {
651 {
652 .shared = &orion_xor0_shared,
653 .hw_id = 0,
654 .pool_size = PAGE_SIZE,
655 },
656 {
657 .shared = &orion_xor0_shared,
658 .hw_id = 1,
659 .pool_size = PAGE_SIZE,
660 },
661};
662
663static struct mv_xor_shared_platform_data orion_xor0_pdata = {
664 .channels = orion_xor0_channels_pdata,
665};
666
Andrew Lunnee962722011-05-15 13:32:48 +0200667static struct platform_device orion_xor0_shared = {
668 .name = MV_XOR_SHARED_NAME,
669 .id = 0,
Andrew Lunnee962722011-05-15 13:32:48 +0200670 .num_resources = ARRAY_SIZE(orion_xor0_shared_resources),
671 .resource = orion_xor0_shared_resources,
Thomas Petazzoniaf19e142012-10-29 17:45:21 +0100672 .dev = {
673 .dma_mask = &orion_xor_dmamask,
674 .coherent_dma_mask = DMA_BIT_MASK(64),
675 .platform_data = &orion_xor0_pdata,
Andrew Lunnee962722011-05-15 13:32:48 +0200676 },
677};
678
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100679void __init orion_xor0_init(unsigned long mapbase_low,
Andrew Lunnee962722011-05-15 13:32:48 +0200680 unsigned long mapbase_high,
681 unsigned long irq_0,
682 unsigned long irq_1)
683{
Andrew Lunnee962722011-05-15 13:32:48 +0200684 orion_xor0_shared_resources[0].start = mapbase_low;
685 orion_xor0_shared_resources[0].end = mapbase_low + 0xff;
686 orion_xor0_shared_resources[1].start = mapbase_high;
687 orion_xor0_shared_resources[1].end = mapbase_high + 0xff;
688
Thomas Petazzoniaf19e142012-10-29 17:45:21 +0100689 orion_xor0_shared_resources[2].start = irq_0;
690 orion_xor0_shared_resources[2].end = irq_0;
691 orion_xor0_shared_resources[3].start = irq_1;
692 orion_xor0_shared_resources[3].end = irq_1;
693
694 /*
695 * two engines can't do memset simultaneously, this limitation
696 * satisfied by removing memset support from one of the engines.
697 */
698 dma_cap_set(DMA_MEMCPY, orion_xor0_channels_pdata[0].cap_mask);
699 dma_cap_set(DMA_XOR, orion_xor0_channels_pdata[0].cap_mask);
700
701 dma_cap_set(DMA_MEMSET, orion_xor0_channels_pdata[1].cap_mask);
702 dma_cap_set(DMA_MEMCPY, orion_xor0_channels_pdata[1].cap_mask);
703 dma_cap_set(DMA_XOR, orion_xor0_channels_pdata[1].cap_mask);
Andrew Lunnee962722011-05-15 13:32:48 +0200704
705 platform_device_register(&orion_xor0_shared);
Andrew Lunnee962722011-05-15 13:32:48 +0200706}
707
708/*****************************************************************************
709 * XOR1
710 ****************************************************************************/
711static struct resource orion_xor1_shared_resources[] = {
712 {
713 .name = "xor 1 low",
714 .flags = IORESOURCE_MEM,
715 }, {
716 .name = "xor 1 high",
717 .flags = IORESOURCE_MEM,
718 },
719};
720
721static struct platform_device orion_xor1_shared = {
722 .name = MV_XOR_SHARED_NAME,
723 .id = 1,
Andrew Lunnee962722011-05-15 13:32:48 +0200724 .num_resources = ARRAY_SIZE(orion_xor1_shared_resources),
725 .resource = orion_xor1_shared_resources,
726};
727
728static struct resource orion_xor10_resources[] = {
729 [0] = {
730 .flags = IORESOURCE_IRQ,
731 },
732};
733
734static struct mv_xor_platform_data orion_xor10_data = {
735 .shared = &orion_xor1_shared,
736 .hw_id = 0,
737 .pool_size = PAGE_SIZE,
738};
739
740static struct platform_device orion_xor10_channel = {
741 .name = MV_XOR_NAME,
742 .id = 2,
743 .num_resources = ARRAY_SIZE(orion_xor10_resources),
744 .resource = orion_xor10_resources,
745 .dev = {
746 .dma_mask = &orion_xor_dmamask,
747 .coherent_dma_mask = DMA_BIT_MASK(64),
748 .platform_data = &orion_xor10_data,
749 },
750};
751
752static struct resource orion_xor11_resources[] = {
753 [0] = {
754 .flags = IORESOURCE_IRQ,
755 },
756};
757
758static struct mv_xor_platform_data orion_xor11_data = {
759 .shared = &orion_xor1_shared,
760 .hw_id = 1,
761 .pool_size = PAGE_SIZE,
762};
763
764static struct platform_device orion_xor11_channel = {
765 .name = MV_XOR_NAME,
766 .id = 3,
767 .num_resources = ARRAY_SIZE(orion_xor11_resources),
768 .resource = orion_xor11_resources,
769 .dev = {
770 .dma_mask = &orion_xor_dmamask,
771 .coherent_dma_mask = DMA_BIT_MASK(64),
772 .platform_data = &orion_xor11_data,
773 },
774};
775
776void __init orion_xor1_init(unsigned long mapbase_low,
777 unsigned long mapbase_high,
778 unsigned long irq_0,
779 unsigned long irq_1)
780{
781 orion_xor1_shared_resources[0].start = mapbase_low;
782 orion_xor1_shared_resources[0].end = mapbase_low + 0xff;
783 orion_xor1_shared_resources[1].start = mapbase_high;
784 orion_xor1_shared_resources[1].end = mapbase_high + 0xff;
785
786 orion_xor10_resources[0].start = irq_0;
787 orion_xor10_resources[0].end = irq_0;
788 orion_xor11_resources[0].start = irq_1;
789 orion_xor11_resources[0].end = irq_1;
790
791 platform_device_register(&orion_xor1_shared);
792
793 orion_xor_init_channels(&orion_xor10_data, &orion_xor10_channel,
794 &orion_xor11_data, &orion_xor11_channel);
795}
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200796
797/*****************************************************************************
798 * EHCI
799 ****************************************************************************/
Andrew Lunn72053352012-02-08 15:52:47 +0100800static struct orion_ehci_data orion_ehci_data;
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200801static u64 ehci_dmamask = DMA_BIT_MASK(32);
802
803
804/*****************************************************************************
805 * EHCI0
806 ****************************************************************************/
807static struct resource orion_ehci_resources[2];
808
809static struct platform_device orion_ehci = {
810 .name = "orion-ehci",
811 .id = 0,
812 .dev = {
813 .dma_mask = &ehci_dmamask,
814 .coherent_dma_mask = DMA_BIT_MASK(32),
815 .platform_data = &orion_ehci_data,
816 },
817};
818
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100819void __init orion_ehci_init(unsigned long mapbase,
Andrew Lunn72053352012-02-08 15:52:47 +0100820 unsigned long irq,
821 enum orion_ehci_phy_ver phy_version)
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200822{
Andrew Lunn72053352012-02-08 15:52:47 +0100823 orion_ehci_data.phy_version = phy_version;
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200824 fill_resources(&orion_ehci, orion_ehci_resources, mapbase, SZ_4K - 1,
825 irq);
826
827 platform_device_register(&orion_ehci);
828}
829
830/*****************************************************************************
831 * EHCI1
832 ****************************************************************************/
833static struct resource orion_ehci_1_resources[2];
834
835static struct platform_device orion_ehci_1 = {
836 .name = "orion-ehci",
837 .id = 1,
838 .dev = {
839 .dma_mask = &ehci_dmamask,
840 .coherent_dma_mask = DMA_BIT_MASK(32),
841 .platform_data = &orion_ehci_data,
842 },
843};
844
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100845void __init orion_ehci_1_init(unsigned long mapbase,
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200846 unsigned long irq)
847{
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200848 fill_resources(&orion_ehci_1, orion_ehci_1_resources,
849 mapbase, SZ_4K - 1, irq);
850
851 platform_device_register(&orion_ehci_1);
852}
853
854/*****************************************************************************
855 * EHCI2
856 ****************************************************************************/
857static struct resource orion_ehci_2_resources[2];
858
859static struct platform_device orion_ehci_2 = {
860 .name = "orion-ehci",
861 .id = 2,
862 .dev = {
863 .dma_mask = &ehci_dmamask,
864 .coherent_dma_mask = DMA_BIT_MASK(32),
865 .platform_data = &orion_ehci_data,
866 },
867};
868
Andrew Lunndb33f4d2011-12-07 21:48:08 +0100869void __init orion_ehci_2_init(unsigned long mapbase,
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200870 unsigned long irq)
871{
Andrew Lunn4fcd3f32011-05-15 13:32:49 +0200872 fill_resources(&orion_ehci_2, orion_ehci_2_resources,
873 mapbase, SZ_4K - 1, irq);
874
875 platform_device_register(&orion_ehci_2);
876}
Andrew Lunn9e613f82011-05-15 13:32:50 +0200877
878/*****************************************************************************
879 * SATA
880 ****************************************************************************/
881static struct resource orion_sata_resources[2] = {
882 {
883 .name = "sata base",
884 }, {
885 .name = "sata irq",
886 },
887};
888
889static struct platform_device orion_sata = {
890 .name = "sata_mv",
891 .id = 0,
892 .dev = {
893 .coherent_dma_mask = DMA_BIT_MASK(32),
894 },
895};
896
897void __init orion_sata_init(struct mv_sata_platform_data *sata_data,
Andrew Lunn9e613f82011-05-15 13:32:50 +0200898 unsigned long mapbase,
899 unsigned long irq)
900{
Andrew Lunn9e613f82011-05-15 13:32:50 +0200901 orion_sata.dev.platform_data = sata_data;
902 fill_resources(&orion_sata, orion_sata_resources,
903 mapbase, 0x5000 - 1, irq);
904
905 platform_device_register(&orion_sata);
906}
907
Andrew Lunn44350062011-05-15 13:32:51 +0200908/*****************************************************************************
909 * Cryptographic Engines and Security Accelerator (CESA)
910 ****************************************************************************/
911static struct resource orion_crypto_resources[] = {
912 {
913 .name = "regs",
914 }, {
915 .name = "crypto interrupt",
916 }, {
917 .name = "sram",
918 .flags = IORESOURCE_MEM,
919 },
920};
Andrew Lunn9e613f82011-05-15 13:32:50 +0200921
Andrew Lunn44350062011-05-15 13:32:51 +0200922static struct platform_device orion_crypto = {
923 .name = "mv_crypto",
924 .id = -1,
925};
926
927void __init orion_crypto_init(unsigned long mapbase,
928 unsigned long srambase,
929 unsigned long sram_size,
930 unsigned long irq)
931{
932 fill_resources(&orion_crypto, orion_crypto_resources,
933 mapbase, 0xffff, irq);
934 orion_crypto.num_resources = 3;
935 orion_crypto_resources[2].start = srambase;
936 orion_crypto_resources[2].end = srambase + sram_size - 1;
937
938 platform_device_register(&orion_crypto);
939}