blob: 8dc2c76d226004de633bdc1e2dbe14681790a7d4 [file] [log] [blame]
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -04001/*
2 * arch/arm/mach-orion5x/common.c
3 *
4 * Core functions for Marvell Orion 5x SoCs
5 *
6 * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
7 *
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/serial_8250.h>
17#include <linux/mbus.h>
18#include <linux/mv643xx_eth.h>
19#include <linux/mv643xx_i2c.h>
20#include <linux/ata_platform.h>
Lennert Buytenhekd323ade2008-08-29 06:55:06 +020021#include <linux/spi/orion_spi.h>
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +020022#include <net/dsa.h>
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040023#include <asm/page.h>
24#include <asm/setup.h>
25#include <asm/timex.h>
26#include <asm/mach/arch.h>
27#include <asm/mach/map.h>
28#include <asm/mach/time.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/hardware.h>
30#include <mach/orion5x.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020031#include <plat/ehci-orion.h>
Saeed Bishara1d5a1a62008-06-16 23:25:12 -110032#include <plat/mv_xor.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020033#include <plat/orion_nand.h>
Nicolas Pitre3b937a72009-06-01 13:56:02 -040034#include <plat/orion_wdt.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020035#include <plat/time.h>
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040036#include "common.h"
37
38/*****************************************************************************
39 * I/O Address Mapping
40 ****************************************************************************/
41static struct map_desc orion5x_io_desc[] __initdata = {
42 {
43 .virtual = ORION5X_REGS_VIRT_BASE,
44 .pfn = __phys_to_pfn(ORION5X_REGS_PHYS_BASE),
45 .length = ORION5X_REGS_SIZE,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +020046 .type = MT_DEVICE,
47 }, {
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040048 .virtual = ORION5X_PCIE_IO_VIRT_BASE,
49 .pfn = __phys_to_pfn(ORION5X_PCIE_IO_PHYS_BASE),
50 .length = ORION5X_PCIE_IO_SIZE,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +020051 .type = MT_DEVICE,
52 }, {
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040053 .virtual = ORION5X_PCI_IO_VIRT_BASE,
54 .pfn = __phys_to_pfn(ORION5X_PCI_IO_PHYS_BASE),
55 .length = ORION5X_PCI_IO_SIZE,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +020056 .type = MT_DEVICE,
57 }, {
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040058 .virtual = ORION5X_PCIE_WA_VIRT_BASE,
59 .pfn = __phys_to_pfn(ORION5X_PCIE_WA_PHYS_BASE),
60 .length = ORION5X_PCIE_WA_SIZE,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +020061 .type = MT_DEVICE,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040062 },
63};
64
65void __init orion5x_map_io(void)
66{
67 iotable_init(orion5x_io_desc, ARRAY_SIZE(orion5x_io_desc));
68}
69
Lennert Buytenhek044f6c72008-04-22 05:37:12 +020070
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040071/*****************************************************************************
Lennert Buytenhek044f6c72008-04-22 05:37:12 +020072 * EHCI
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040073 ****************************************************************************/
Lennert Buytenhek044f6c72008-04-22 05:37:12 +020074static struct orion_ehci_data orion5x_ehci_data = {
75 .dram = &orion5x_mbus_dram_info,
Ronen Shitritfb6f5522008-09-17 10:08:05 +030076 .phy_version = EHCI_PHY_ORION,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040077};
78
Lennert Buytenhek044f6c72008-04-22 05:37:12 +020079static u64 ehci_dmamask = 0xffffffffUL;
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040080
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040081
Lennert Buytenhek044f6c72008-04-22 05:37:12 +020082/*****************************************************************************
83 * EHCI0
84 ****************************************************************************/
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040085static struct resource orion5x_ehci0_resources[] = {
86 {
87 .start = ORION5X_USB0_PHYS_BASE,
Lennert Buytenhek994cab82008-04-25 16:30:21 -040088 .end = ORION5X_USB0_PHYS_BASE + SZ_4K - 1,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040089 .flags = IORESOURCE_MEM,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +020090 }, {
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040091 .start = IRQ_ORION5X_USB0_CTRL,
92 .end = IRQ_ORION5X_USB0_CTRL,
93 .flags = IORESOURCE_IRQ,
94 },
95};
96
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040097static struct platform_device orion5x_ehci0 = {
98 .name = "orion-ehci",
99 .id = 0,
100 .dev = {
101 .dma_mask = &ehci_dmamask,
102 .coherent_dma_mask = 0xffffffff,
103 .platform_data = &orion5x_ehci_data,
104 },
105 .resource = orion5x_ehci0_resources,
106 .num_resources = ARRAY_SIZE(orion5x_ehci0_resources),
107};
108
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200109void __init orion5x_ehci0_init(void)
110{
111 platform_device_register(&orion5x_ehci0);
112}
113
114
115/*****************************************************************************
116 * EHCI1
117 ****************************************************************************/
118static struct resource orion5x_ehci1_resources[] = {
119 {
120 .start = ORION5X_USB1_PHYS_BASE,
121 .end = ORION5X_USB1_PHYS_BASE + SZ_4K - 1,
122 .flags = IORESOURCE_MEM,
123 }, {
124 .start = IRQ_ORION5X_USB1_CTRL,
125 .end = IRQ_ORION5X_USB1_CTRL,
126 .flags = IORESOURCE_IRQ,
127 },
128};
129
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400130static struct platform_device orion5x_ehci1 = {
131 .name = "orion-ehci",
132 .id = 1,
133 .dev = {
134 .dma_mask = &ehci_dmamask,
135 .coherent_dma_mask = 0xffffffff,
136 .platform_data = &orion5x_ehci_data,
137 },
138 .resource = orion5x_ehci1_resources,
139 .num_resources = ARRAY_SIZE(orion5x_ehci1_resources),
140};
141
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200142void __init orion5x_ehci1_init(void)
143{
144 platform_device_register(&orion5x_ehci1);
145}
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400146
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200147
148/*****************************************************************************
149 * GigE
150 ****************************************************************************/
Lennert Buytenhekd236f5a2008-04-26 14:48:11 -0400151struct mv643xx_eth_shared_platform_data orion5x_eth_shared_data = {
152 .dram = &orion5x_mbus_dram_info,
153};
154
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400155static struct resource orion5x_eth_shared_resources[] = {
156 {
157 .start = ORION5X_ETH_PHYS_BASE + 0x2000,
158 .end = ORION5X_ETH_PHYS_BASE + 0x3fff,
159 .flags = IORESOURCE_MEM,
Lennert Buytenhekeeff6d82008-08-26 16:01:21 +0200160 }, {
161 .start = IRQ_ORION5X_ETH_ERR,
162 .end = IRQ_ORION5X_ETH_ERR,
163 .flags = IORESOURCE_IRQ,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400164 },
165};
166
167static struct platform_device orion5x_eth_shared = {
168 .name = MV643XX_ETH_SHARED_NAME,
169 .id = 0,
Lennert Buytenhekd236f5a2008-04-26 14:48:11 -0400170 .dev = {
171 .platform_data = &orion5x_eth_shared_data,
172 },
Lennert Buytenhekeeff6d82008-08-26 16:01:21 +0200173 .num_resources = ARRAY_SIZE(orion5x_eth_shared_resources),
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400174 .resource = orion5x_eth_shared_resources,
175};
176
177static struct resource orion5x_eth_resources[] = {
178 {
179 .name = "eth irq",
180 .start = IRQ_ORION5X_ETH_SUM,
181 .end = IRQ_ORION5X_ETH_SUM,
182 .flags = IORESOURCE_IRQ,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200183 },
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400184};
185
186static struct platform_device orion5x_eth = {
187 .name = MV643XX_ETH_NAME,
188 .id = 0,
189 .num_resources = 1,
190 .resource = orion5x_eth_resources,
Nicolas Pitrea49a0182009-05-22 16:53:40 -0400191 .dev = {
192 .coherent_dma_mask = 0xffffffff,
193 },
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400194};
195
196void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data)
197{
Lennert Buytenhekfa3959f2008-04-24 01:27:02 +0200198 eth_data->shared = &orion5x_eth_shared;
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400199 orion5x_eth.dev.platform_data = eth_data;
Lennert Buytenhekfa3959f2008-04-24 01:27:02 +0200200
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400201 platform_device_register(&orion5x_eth_shared);
202 platform_device_register(&orion5x_eth);
203}
204
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400205
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200206/*****************************************************************************
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200207 * Ethernet switch
208 ****************************************************************************/
209static struct resource orion5x_switch_resources[] = {
210 {
211 .start = 0,
212 .end = 0,
213 .flags = IORESOURCE_IRQ,
214 },
215};
216
217static struct platform_device orion5x_switch_device = {
218 .name = "dsa",
219 .id = 0,
220 .num_resources = 0,
221 .resource = orion5x_switch_resources,
222};
223
224void __init orion5x_eth_switch_init(struct dsa_platform_data *d, int irq)
225{
Lennert Buytenheke84665c2009-03-20 09:52:09 +0000226 int i;
227
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200228 if (irq != NO_IRQ) {
229 orion5x_switch_resources[0].start = irq;
230 orion5x_switch_resources[0].end = irq;
231 orion5x_switch_device.num_resources = 1;
232 }
233
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200234 d->netdev = &orion5x_eth.dev;
Lennert Buytenheke84665c2009-03-20 09:52:09 +0000235 for (i = 0; i < d->nr_chips; i++)
236 d->chip[i].mii_bus = &orion5x_eth_shared.dev;
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200237 orion5x_switch_device.dev.platform_data = d;
238
239 platform_device_register(&orion5x_switch_device);
240}
241
242
243/*****************************************************************************
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200244 * I2C
245 ****************************************************************************/
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400246static struct mv64xxx_i2c_pdata orion5x_i2c_pdata = {
247 .freq_m = 8, /* assumes 166 MHz TCLK */
248 .freq_n = 3,
249 .timeout = 1000, /* Default timeout of 1 second */
250};
251
252static struct resource orion5x_i2c_resources[] = {
253 {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200254 .start = I2C_PHYS_BASE,
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200255 .end = I2C_PHYS_BASE + 0x1f,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200256 .flags = IORESOURCE_MEM,
257 }, {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200258 .start = IRQ_ORION5X_I2C,
259 .end = IRQ_ORION5X_I2C,
260 .flags = IORESOURCE_IRQ,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400261 },
262};
263
264static struct platform_device orion5x_i2c = {
265 .name = MV64XXX_I2C_CTLR_NAME,
266 .id = 0,
267 .num_resources = ARRAY_SIZE(orion5x_i2c_resources),
268 .resource = orion5x_i2c_resources,
269 .dev = {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200270 .platform_data = &orion5x_i2c_pdata,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400271 },
272};
273
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200274void __init orion5x_i2c_init(void)
275{
276 platform_device_register(&orion5x_i2c);
277}
278
279
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400280/*****************************************************************************
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200281 * SATA
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400282 ****************************************************************************/
283static struct resource orion5x_sata_resources[] = {
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400284 {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200285 .name = "sata base",
286 .start = ORION5X_SATA_PHYS_BASE,
287 .end = ORION5X_SATA_PHYS_BASE + 0x5000 - 1,
288 .flags = IORESOURCE_MEM,
289 }, {
290 .name = "sata irq",
291 .start = IRQ_ORION5X_SATA,
292 .end = IRQ_ORION5X_SATA,
293 .flags = IORESOURCE_IRQ,
294 },
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400295};
296
297static struct platform_device orion5x_sata = {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200298 .name = "sata_mv",
299 .id = 0,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400300 .dev = {
301 .coherent_dma_mask = 0xffffffff,
302 },
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200303 .num_resources = ARRAY_SIZE(orion5x_sata_resources),
304 .resource = orion5x_sata_resources,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400305};
306
307void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data)
308{
309 sata_data->dram = &orion5x_mbus_dram_info;
310 orion5x_sata.dev.platform_data = sata_data;
311 platform_device_register(&orion5x_sata);
312}
313
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200314
315/*****************************************************************************
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200316 * SPI
317 ****************************************************************************/
318static struct orion_spi_info orion5x_spi_plat_data = {
Nicolas Pitrec0e19362008-10-19 14:18:25 -0400319 .tclk = 0,
320 .enable_clock_fix = 1,
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200321};
322
323static struct resource orion5x_spi_resources[] = {
324 {
325 .name = "spi base",
326 .start = SPI_PHYS_BASE,
327 .end = SPI_PHYS_BASE + 0x1f,
328 .flags = IORESOURCE_MEM,
329 },
330};
331
332static struct platform_device orion5x_spi = {
333 .name = "orion_spi",
334 .id = 0,
335 .dev = {
336 .platform_data = &orion5x_spi_plat_data,
337 },
338 .num_resources = ARRAY_SIZE(orion5x_spi_resources),
339 .resource = orion5x_spi_resources,
340};
341
342void __init orion5x_spi_init()
343{
344 platform_device_register(&orion5x_spi);
345}
346
347
348/*****************************************************************************
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200349 * UART0
350 ****************************************************************************/
351static struct plat_serial8250_port orion5x_uart0_data[] = {
352 {
353 .mapbase = UART0_PHYS_BASE,
354 .membase = (char *)UART0_VIRT_BASE,
355 .irq = IRQ_ORION5X_UART0,
356 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
357 .iotype = UPIO_MEM,
358 .regshift = 2,
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200359 .uartclk = 0,
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200360 }, {
361 },
362};
363
364static struct resource orion5x_uart0_resources[] = {
365 {
366 .start = UART0_PHYS_BASE,
367 .end = UART0_PHYS_BASE + 0xff,
368 .flags = IORESOURCE_MEM,
369 }, {
370 .start = IRQ_ORION5X_UART0,
371 .end = IRQ_ORION5X_UART0,
372 .flags = IORESOURCE_IRQ,
373 },
374};
375
376static struct platform_device orion5x_uart0 = {
377 .name = "serial8250",
378 .id = PLAT8250_DEV_PLATFORM,
379 .dev = {
380 .platform_data = orion5x_uart0_data,
381 },
382 .resource = orion5x_uart0_resources,
383 .num_resources = ARRAY_SIZE(orion5x_uart0_resources),
384};
385
386void __init orion5x_uart0_init(void)
387{
388 platform_device_register(&orion5x_uart0);
389}
390
391
392/*****************************************************************************
393 * UART1
394 ****************************************************************************/
395static struct plat_serial8250_port orion5x_uart1_data[] = {
396 {
397 .mapbase = UART1_PHYS_BASE,
398 .membase = (char *)UART1_VIRT_BASE,
399 .irq = IRQ_ORION5X_UART1,
400 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
401 .iotype = UPIO_MEM,
402 .regshift = 2,
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200403 .uartclk = 0,
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200404 }, {
405 },
406};
407
408static struct resource orion5x_uart1_resources[] = {
409 {
410 .start = UART1_PHYS_BASE,
411 .end = UART1_PHYS_BASE + 0xff,
412 .flags = IORESOURCE_MEM,
413 }, {
414 .start = IRQ_ORION5X_UART1,
415 .end = IRQ_ORION5X_UART1,
416 .flags = IORESOURCE_IRQ,
417 },
418};
419
420static struct platform_device orion5x_uart1 = {
421 .name = "serial8250",
422 .id = PLAT8250_DEV_PLATFORM1,
423 .dev = {
424 .platform_data = orion5x_uart1_data,
425 },
426 .resource = orion5x_uart1_resources,
427 .num_resources = ARRAY_SIZE(orion5x_uart1_resources),
428};
429
430void __init orion5x_uart1_init(void)
431{
432 platform_device_register(&orion5x_uart1);
433}
434
435
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400436/*****************************************************************************
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100437 * XOR engine
438 ****************************************************************************/
Saeed Bisharaf45964e2009-03-02 17:30:36 +0200439struct mv_xor_platform_shared_data orion5x_xor_shared_data = {
440 .dram = &orion5x_mbus_dram_info,
441};
442
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100443static struct resource orion5x_xor_shared_resources[] = {
444 {
445 .name = "xor low",
446 .start = ORION5X_XOR_PHYS_BASE,
447 .end = ORION5X_XOR_PHYS_BASE + 0xff,
448 .flags = IORESOURCE_MEM,
449 }, {
450 .name = "xor high",
451 .start = ORION5X_XOR_PHYS_BASE + 0x200,
452 .end = ORION5X_XOR_PHYS_BASE + 0x2ff,
453 .flags = IORESOURCE_MEM,
454 },
455};
456
457static struct platform_device orion5x_xor_shared = {
458 .name = MV_XOR_SHARED_NAME,
459 .id = 0,
Saeed Bisharaf45964e2009-03-02 17:30:36 +0200460 .dev = {
461 .platform_data = &orion5x_xor_shared_data,
462 },
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100463 .num_resources = ARRAY_SIZE(orion5x_xor_shared_resources),
464 .resource = orion5x_xor_shared_resources,
465};
466
Yang Hongyang284901a2009-04-06 19:01:15 -0700467static u64 orion5x_xor_dmamask = DMA_BIT_MASK(32);
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100468
469static struct resource orion5x_xor0_resources[] = {
470 [0] = {
471 .start = IRQ_ORION5X_XOR0,
472 .end = IRQ_ORION5X_XOR0,
473 .flags = IORESOURCE_IRQ,
474 },
475};
476
477static struct mv_xor_platform_data orion5x_xor0_data = {
478 .shared = &orion5x_xor_shared,
479 .hw_id = 0,
480 .pool_size = PAGE_SIZE,
481};
482
483static struct platform_device orion5x_xor0_channel = {
484 .name = MV_XOR_NAME,
485 .id = 0,
486 .num_resources = ARRAY_SIZE(orion5x_xor0_resources),
487 .resource = orion5x_xor0_resources,
488 .dev = {
489 .dma_mask = &orion5x_xor_dmamask,
Yang Hongyang6a355282009-04-06 19:01:13 -0700490 .coherent_dma_mask = DMA_BIT_MASK(64),
H Hartley Sweetenef4a6772010-01-29 14:56:58 -0800491 .platform_data = &orion5x_xor0_data,
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100492 },
493};
494
495static struct resource orion5x_xor1_resources[] = {
496 [0] = {
497 .start = IRQ_ORION5X_XOR1,
498 .end = IRQ_ORION5X_XOR1,
499 .flags = IORESOURCE_IRQ,
500 },
501};
502
503static struct mv_xor_platform_data orion5x_xor1_data = {
504 .shared = &orion5x_xor_shared,
505 .hw_id = 1,
506 .pool_size = PAGE_SIZE,
507};
508
509static struct platform_device orion5x_xor1_channel = {
510 .name = MV_XOR_NAME,
511 .id = 1,
512 .num_resources = ARRAY_SIZE(orion5x_xor1_resources),
513 .resource = orion5x_xor1_resources,
514 .dev = {
515 .dma_mask = &orion5x_xor_dmamask,
Yang Hongyang6a355282009-04-06 19:01:13 -0700516 .coherent_dma_mask = DMA_BIT_MASK(64),
H Hartley Sweetenef4a6772010-01-29 14:56:58 -0800517 .platform_data = &orion5x_xor1_data,
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100518 },
519};
520
521void __init orion5x_xor_init(void)
522{
523 platform_device_register(&orion5x_xor_shared);
524
525 /*
526 * two engines can't do memset simultaneously, this limitation
527 * satisfied by removing memset support from one of the engines.
528 */
529 dma_cap_set(DMA_MEMCPY, orion5x_xor0_data.cap_mask);
530 dma_cap_set(DMA_XOR, orion5x_xor0_data.cap_mask);
531 platform_device_register(&orion5x_xor0_channel);
532
533 dma_cap_set(DMA_MEMCPY, orion5x_xor1_data.cap_mask);
534 dma_cap_set(DMA_MEMSET, orion5x_xor1_data.cap_mask);
535 dma_cap_set(DMA_XOR, orion5x_xor1_data.cap_mask);
536 platform_device_register(&orion5x_xor1_channel);
537}
538
Sebastian Andrzej Siewior3a8f7442009-05-07 22:59:24 +0200539static struct resource orion5x_crypto_res[] = {
540 {
541 .name = "regs",
542 .start = ORION5X_CRYPTO_PHYS_BASE,
543 .end = ORION5X_CRYPTO_PHYS_BASE + 0xffff,
544 .flags = IORESOURCE_MEM,
545 }, {
546 .name = "sram",
547 .start = ORION5X_SRAM_PHYS_BASE,
548 .end = ORION5X_SRAM_PHYS_BASE + SZ_8K - 1,
549 .flags = IORESOURCE_MEM,
550 }, {
551 .name = "crypto interrupt",
552 .start = IRQ_ORION5X_CESA,
553 .end = IRQ_ORION5X_CESA,
554 .flags = IORESOURCE_IRQ,
555 },
556};
557
558static struct platform_device orion5x_crypto_device = {
559 .name = "mv_crypto",
560 .id = -1,
561 .num_resources = ARRAY_SIZE(orion5x_crypto_res),
562 .resource = orion5x_crypto_res,
563};
564
Nicolas Pitre3fade492009-06-11 22:27:20 +0200565static int __init orion5x_crypto_init(void)
Sebastian Andrzej Siewior3a8f7442009-05-07 22:59:24 +0200566{
567 int ret;
568
569 ret = orion5x_setup_sram_win();
570 if (ret)
571 return ret;
572
573 return platform_device_register(&orion5x_crypto_device);
574}
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100575
576/*****************************************************************************
Thomas Reitmayr9e058d42009-02-24 14:59:22 -0800577 * Watchdog
578 ****************************************************************************/
Nicolas Pitre3b937a72009-06-01 13:56:02 -0400579static struct orion_wdt_platform_data orion5x_wdt_data = {
Thomas Reitmayr9e058d42009-02-24 14:59:22 -0800580 .tclk = 0,
581};
582
583static struct platform_device orion5x_wdt_device = {
Nicolas Pitre3b937a72009-06-01 13:56:02 -0400584 .name = "orion_wdt",
Thomas Reitmayr9e058d42009-02-24 14:59:22 -0800585 .id = -1,
586 .dev = {
587 .platform_data = &orion5x_wdt_data,
588 },
589 .num_resources = 0,
590};
591
592void __init orion5x_wdt_init(void)
593{
594 orion5x_wdt_data.tclk = orion5x_tclk;
595 platform_device_register(&orion5x_wdt_device);
596}
597
598
599/*****************************************************************************
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400600 * Time handling
601 ****************************************************************************/
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200602int orion5x_tclk;
603
604int __init orion5x_find_tclk(void)
605{
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200606 u32 dev, rev;
607
608 orion5x_pcie_id(&dev, &rev);
609 if (dev == MV88F6183_DEV_ID &&
610 (readl(MPP_RESET_SAMPLE) & 0x00000200) == 0)
611 return 133333333;
612
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200613 return 166666667;
614}
615
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400616static void orion5x_timer_init(void)
617{
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200618 orion5x_tclk = orion5x_find_tclk();
619 orion_time_init(IRQ_ORION5X_BRIDGE, orion5x_tclk);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400620}
621
622struct sys_timer orion5x_timer = {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200623 .init = orion5x_timer_init,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400624};
625
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200626
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400627/*****************************************************************************
628 * General
629 ****************************************************************************/
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400630/*
Lennert Buytenhekb46926b2008-04-25 16:31:32 -0400631 * Identify device ID and rev from PCIe configuration header space '0'.
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400632 */
633static void __init orion5x_id(u32 *dev, u32 *rev, char **dev_name)
634{
635 orion5x_pcie_id(dev, rev);
636
637 if (*dev == MV88F5281_DEV_ID) {
638 if (*rev == MV88F5281_REV_D2) {
639 *dev_name = "MV88F5281-D2";
640 } else if (*rev == MV88F5281_REV_D1) {
641 *dev_name = "MV88F5281-D1";
Lennert Buytenhekce72e36e2008-08-09 15:17:27 +0200642 } else if (*rev == MV88F5281_REV_D0) {
643 *dev_name = "MV88F5281-D0";
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400644 } else {
645 *dev_name = "MV88F5281-Rev-Unsupported";
646 }
647 } else if (*dev == MV88F5182_DEV_ID) {
648 if (*rev == MV88F5182_REV_A2) {
649 *dev_name = "MV88F5182-A2";
650 } else {
651 *dev_name = "MV88F5182-Rev-Unsupported";
652 }
653 } else if (*dev == MV88F5181_DEV_ID) {
654 if (*rev == MV88F5181_REV_B1) {
655 *dev_name = "MV88F5181-Rev-B1";
Lennert Buytenhekd2b2a6b2008-05-31 08:30:40 +0200656 } else if (*rev == MV88F5181L_REV_A1) {
657 *dev_name = "MV88F5181L-Rev-A1";
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400658 } else {
Lennert Buytenhekd2b2a6b2008-05-31 08:30:40 +0200659 *dev_name = "MV88F5181(L)-Rev-Unsupported";
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400660 }
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200661 } else if (*dev == MV88F6183_DEV_ID) {
662 if (*rev == MV88F6183_REV_B0) {
663 *dev_name = "MV88F6183-Rev-B0";
664 } else {
665 *dev_name = "MV88F6183-Rev-Unsupported";
666 }
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400667 } else {
668 *dev_name = "Device-Unknown";
669 }
670}
671
672void __init orion5x_init(void)
673{
674 char *dev_name;
675 u32 dev, rev;
676
677 orion5x_id(&dev, &rev, &dev_name);
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200678 printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, orion5x_tclk);
679
680 orion5x_eth_shared_data.t_clk = orion5x_tclk;
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200681 orion5x_spi_plat_data.tclk = orion5x_tclk;
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200682 orion5x_uart0_data[0].uartclk = orion5x_tclk;
683 orion5x_uart1_data[0].uartclk = orion5x_tclk;
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400684
685 /*
686 * Setup Orion address map
687 */
688 orion5x_setup_cpu_mbus_bridge();
Lennert Buytenhekce72e36e2008-08-09 15:17:27 +0200689
690 /*
691 * Don't issue "Wait for Interrupt" instruction if we are
692 * running on D0 5281 silicon.
693 */
694 if (dev == MV88F5281_DEV_ID && rev == MV88F5281_REV_D0) {
695 printk(KERN_INFO "Orion: Applying 5281 D0 WFI workaround.\n");
696 disable_hlt();
697 }
Thomas Reitmayr9e058d42009-02-24 14:59:22 -0800698
699 /*
Nicolas Pitre3fade492009-06-11 22:27:20 +0200700 * The 5082/5181l/5182/6082/6082l/6183 have crypto
701 * while 5180n/5181/5281 don't have crypto.
702 */
703 if ((dev == MV88F5181_DEV_ID && rev >= MV88F5181L_REV_A0) ||
704 dev == MV88F5182_DEV_ID || dev == MV88F6183_DEV_ID)
705 orion5x_crypto_init();
706
707 /*
Thomas Reitmayr9e058d42009-02-24 14:59:22 -0800708 * Register watchdog driver
709 */
710 orion5x_wdt_init();
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400711}
712
713/*
714 * Many orion-based systems have buggy bootloader implementations.
715 * This is a common fixup for bogus memory tags.
716 */
717void __init tag_fixup_mem32(struct machine_desc *mdesc, struct tag *t,
718 char **from, struct meminfo *meminfo)
719{
720 for (; t->hdr.size; t = tag_next(t))
721 if (t->hdr.tag == ATAG_MEM &&
722 (!t->u.mem.size || t->u.mem.size & ~PAGE_MASK ||
723 t->u.mem.start & ~PAGE_MASK)) {
724 printk(KERN_WARNING
725 "Clearing invalid memory bank %dKB@0x%08x\n",
726 t->u.mem.size / 1024, t->u.mem.start);
727 t->hdr.tag = 0;
728 }
729}