blob: a51fb9dd65a7c94362d0bbb88015f5c7038d0ca3 [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>
Thomas Reitmayr9e058d42009-02-24 14:59:22 -080034#include <plat/orion5x_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,
191};
192
193void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data)
194{
Lennert Buytenhekfa3959f2008-04-24 01:27:02 +0200195 eth_data->shared = &orion5x_eth_shared;
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400196 orion5x_eth.dev.platform_data = eth_data;
Lennert Buytenhekfa3959f2008-04-24 01:27:02 +0200197
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400198 platform_device_register(&orion5x_eth_shared);
199 platform_device_register(&orion5x_eth);
200}
201
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400202
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200203/*****************************************************************************
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200204 * Ethernet switch
205 ****************************************************************************/
206static struct resource orion5x_switch_resources[] = {
207 {
208 .start = 0,
209 .end = 0,
210 .flags = IORESOURCE_IRQ,
211 },
212};
213
214static struct platform_device orion5x_switch_device = {
215 .name = "dsa",
216 .id = 0,
217 .num_resources = 0,
218 .resource = orion5x_switch_resources,
219};
220
221void __init orion5x_eth_switch_init(struct dsa_platform_data *d, int irq)
222{
Lennert Buytenheke84665c2009-03-20 09:52:09 +0000223 int i;
224
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200225 if (irq != NO_IRQ) {
226 orion5x_switch_resources[0].start = irq;
227 orion5x_switch_resources[0].end = irq;
228 orion5x_switch_device.num_resources = 1;
229 }
230
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200231 d->netdev = &orion5x_eth.dev;
Lennert Buytenheke84665c2009-03-20 09:52:09 +0000232 for (i = 0; i < d->nr_chips; i++)
233 d->chip[i].mii_bus = &orion5x_eth_shared.dev;
Lennert Buytenhekdcf1cec2008-09-25 16:23:48 +0200234 orion5x_switch_device.dev.platform_data = d;
235
236 platform_device_register(&orion5x_switch_device);
237}
238
239
240/*****************************************************************************
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200241 * I2C
242 ****************************************************************************/
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400243static struct mv64xxx_i2c_pdata orion5x_i2c_pdata = {
244 .freq_m = 8, /* assumes 166 MHz TCLK */
245 .freq_n = 3,
246 .timeout = 1000, /* Default timeout of 1 second */
247};
248
249static struct resource orion5x_i2c_resources[] = {
250 {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200251 .start = I2C_PHYS_BASE,
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200252 .end = I2C_PHYS_BASE + 0x1f,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200253 .flags = IORESOURCE_MEM,
254 }, {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200255 .start = IRQ_ORION5X_I2C,
256 .end = IRQ_ORION5X_I2C,
257 .flags = IORESOURCE_IRQ,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400258 },
259};
260
261static struct platform_device orion5x_i2c = {
262 .name = MV64XXX_I2C_CTLR_NAME,
263 .id = 0,
264 .num_resources = ARRAY_SIZE(orion5x_i2c_resources),
265 .resource = orion5x_i2c_resources,
266 .dev = {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200267 .platform_data = &orion5x_i2c_pdata,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400268 },
269};
270
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200271void __init orion5x_i2c_init(void)
272{
273 platform_device_register(&orion5x_i2c);
274}
275
276
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400277/*****************************************************************************
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200278 * SATA
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400279 ****************************************************************************/
280static struct resource orion5x_sata_resources[] = {
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400281 {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200282 .name = "sata base",
283 .start = ORION5X_SATA_PHYS_BASE,
284 .end = ORION5X_SATA_PHYS_BASE + 0x5000 - 1,
285 .flags = IORESOURCE_MEM,
286 }, {
287 .name = "sata irq",
288 .start = IRQ_ORION5X_SATA,
289 .end = IRQ_ORION5X_SATA,
290 .flags = IORESOURCE_IRQ,
291 },
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400292};
293
294static struct platform_device orion5x_sata = {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200295 .name = "sata_mv",
296 .id = 0,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400297 .dev = {
298 .coherent_dma_mask = 0xffffffff,
299 },
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200300 .num_resources = ARRAY_SIZE(orion5x_sata_resources),
301 .resource = orion5x_sata_resources,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400302};
303
304void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data)
305{
306 sata_data->dram = &orion5x_mbus_dram_info;
307 orion5x_sata.dev.platform_data = sata_data;
308 platform_device_register(&orion5x_sata);
309}
310
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200311
312/*****************************************************************************
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200313 * SPI
314 ****************************************************************************/
315static struct orion_spi_info orion5x_spi_plat_data = {
Nicolas Pitrec0e19362008-10-19 14:18:25 -0400316 .tclk = 0,
317 .enable_clock_fix = 1,
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200318};
319
320static struct resource orion5x_spi_resources[] = {
321 {
322 .name = "spi base",
323 .start = SPI_PHYS_BASE,
324 .end = SPI_PHYS_BASE + 0x1f,
325 .flags = IORESOURCE_MEM,
326 },
327};
328
329static struct platform_device orion5x_spi = {
330 .name = "orion_spi",
331 .id = 0,
332 .dev = {
333 .platform_data = &orion5x_spi_plat_data,
334 },
335 .num_resources = ARRAY_SIZE(orion5x_spi_resources),
336 .resource = orion5x_spi_resources,
337};
338
339void __init orion5x_spi_init()
340{
341 platform_device_register(&orion5x_spi);
342}
343
344
345/*****************************************************************************
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200346 * UART0
347 ****************************************************************************/
348static struct plat_serial8250_port orion5x_uart0_data[] = {
349 {
350 .mapbase = UART0_PHYS_BASE,
351 .membase = (char *)UART0_VIRT_BASE,
352 .irq = IRQ_ORION5X_UART0,
353 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
354 .iotype = UPIO_MEM,
355 .regshift = 2,
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200356 .uartclk = 0,
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200357 }, {
358 },
359};
360
361static struct resource orion5x_uart0_resources[] = {
362 {
363 .start = UART0_PHYS_BASE,
364 .end = UART0_PHYS_BASE + 0xff,
365 .flags = IORESOURCE_MEM,
366 }, {
367 .start = IRQ_ORION5X_UART0,
368 .end = IRQ_ORION5X_UART0,
369 .flags = IORESOURCE_IRQ,
370 },
371};
372
373static struct platform_device orion5x_uart0 = {
374 .name = "serial8250",
375 .id = PLAT8250_DEV_PLATFORM,
376 .dev = {
377 .platform_data = orion5x_uart0_data,
378 },
379 .resource = orion5x_uart0_resources,
380 .num_resources = ARRAY_SIZE(orion5x_uart0_resources),
381};
382
383void __init orion5x_uart0_init(void)
384{
385 platform_device_register(&orion5x_uart0);
386}
387
388
389/*****************************************************************************
390 * UART1
391 ****************************************************************************/
392static struct plat_serial8250_port orion5x_uart1_data[] = {
393 {
394 .mapbase = UART1_PHYS_BASE,
395 .membase = (char *)UART1_VIRT_BASE,
396 .irq = IRQ_ORION5X_UART1,
397 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
398 .iotype = UPIO_MEM,
399 .regshift = 2,
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200400 .uartclk = 0,
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200401 }, {
402 },
403};
404
405static struct resource orion5x_uart1_resources[] = {
406 {
407 .start = UART1_PHYS_BASE,
408 .end = UART1_PHYS_BASE + 0xff,
409 .flags = IORESOURCE_MEM,
410 }, {
411 .start = IRQ_ORION5X_UART1,
412 .end = IRQ_ORION5X_UART1,
413 .flags = IORESOURCE_IRQ,
414 },
415};
416
417static struct platform_device orion5x_uart1 = {
418 .name = "serial8250",
419 .id = PLAT8250_DEV_PLATFORM1,
420 .dev = {
421 .platform_data = orion5x_uart1_data,
422 },
423 .resource = orion5x_uart1_resources,
424 .num_resources = ARRAY_SIZE(orion5x_uart1_resources),
425};
426
427void __init orion5x_uart1_init(void)
428{
429 platform_device_register(&orion5x_uart1);
430}
431
432
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400433/*****************************************************************************
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100434 * XOR engine
435 ****************************************************************************/
Saeed Bisharaf45964e2009-03-02 17:30:36 +0200436struct mv_xor_platform_shared_data orion5x_xor_shared_data = {
437 .dram = &orion5x_mbus_dram_info,
438};
439
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100440static struct resource orion5x_xor_shared_resources[] = {
441 {
442 .name = "xor low",
443 .start = ORION5X_XOR_PHYS_BASE,
444 .end = ORION5X_XOR_PHYS_BASE + 0xff,
445 .flags = IORESOURCE_MEM,
446 }, {
447 .name = "xor high",
448 .start = ORION5X_XOR_PHYS_BASE + 0x200,
449 .end = ORION5X_XOR_PHYS_BASE + 0x2ff,
450 .flags = IORESOURCE_MEM,
451 },
452};
453
454static struct platform_device orion5x_xor_shared = {
455 .name = MV_XOR_SHARED_NAME,
456 .id = 0,
Saeed Bisharaf45964e2009-03-02 17:30:36 +0200457 .dev = {
458 .platform_data = &orion5x_xor_shared_data,
459 },
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100460 .num_resources = ARRAY_SIZE(orion5x_xor_shared_resources),
461 .resource = orion5x_xor_shared_resources,
462};
463
Yang Hongyang284901a2009-04-06 19:01:15 -0700464static u64 orion5x_xor_dmamask = DMA_BIT_MASK(32);
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100465
466static struct resource orion5x_xor0_resources[] = {
467 [0] = {
468 .start = IRQ_ORION5X_XOR0,
469 .end = IRQ_ORION5X_XOR0,
470 .flags = IORESOURCE_IRQ,
471 },
472};
473
474static struct mv_xor_platform_data orion5x_xor0_data = {
475 .shared = &orion5x_xor_shared,
476 .hw_id = 0,
477 .pool_size = PAGE_SIZE,
478};
479
480static struct platform_device orion5x_xor0_channel = {
481 .name = MV_XOR_NAME,
482 .id = 0,
483 .num_resources = ARRAY_SIZE(orion5x_xor0_resources),
484 .resource = orion5x_xor0_resources,
485 .dev = {
486 .dma_mask = &orion5x_xor_dmamask,
Yang Hongyang6a355282009-04-06 19:01:13 -0700487 .coherent_dma_mask = DMA_BIT_MASK(64),
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100488 .platform_data = (void *)&orion5x_xor0_data,
489 },
490};
491
492static struct resource orion5x_xor1_resources[] = {
493 [0] = {
494 .start = IRQ_ORION5X_XOR1,
495 .end = IRQ_ORION5X_XOR1,
496 .flags = IORESOURCE_IRQ,
497 },
498};
499
500static struct mv_xor_platform_data orion5x_xor1_data = {
501 .shared = &orion5x_xor_shared,
502 .hw_id = 1,
503 .pool_size = PAGE_SIZE,
504};
505
506static struct platform_device orion5x_xor1_channel = {
507 .name = MV_XOR_NAME,
508 .id = 1,
509 .num_resources = ARRAY_SIZE(orion5x_xor1_resources),
510 .resource = orion5x_xor1_resources,
511 .dev = {
512 .dma_mask = &orion5x_xor_dmamask,
Yang Hongyang6a355282009-04-06 19:01:13 -0700513 .coherent_dma_mask = DMA_BIT_MASK(64),
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100514 .platform_data = (void *)&orion5x_xor1_data,
515 },
516};
517
518void __init orion5x_xor_init(void)
519{
520 platform_device_register(&orion5x_xor_shared);
521
522 /*
523 * two engines can't do memset simultaneously, this limitation
524 * satisfied by removing memset support from one of the engines.
525 */
526 dma_cap_set(DMA_MEMCPY, orion5x_xor0_data.cap_mask);
527 dma_cap_set(DMA_XOR, orion5x_xor0_data.cap_mask);
528 platform_device_register(&orion5x_xor0_channel);
529
530 dma_cap_set(DMA_MEMCPY, orion5x_xor1_data.cap_mask);
531 dma_cap_set(DMA_MEMSET, orion5x_xor1_data.cap_mask);
532 dma_cap_set(DMA_XOR, orion5x_xor1_data.cap_mask);
533 platform_device_register(&orion5x_xor1_channel);
534}
535
536
537/*****************************************************************************
Thomas Reitmayr9e058d42009-02-24 14:59:22 -0800538 * Watchdog
539 ****************************************************************************/
540static struct orion5x_wdt_platform_data orion5x_wdt_data = {
541 .tclk = 0,
542};
543
544static struct platform_device orion5x_wdt_device = {
545 .name = "orion5x_wdt",
546 .id = -1,
547 .dev = {
548 .platform_data = &orion5x_wdt_data,
549 },
550 .num_resources = 0,
551};
552
553void __init orion5x_wdt_init(void)
554{
555 orion5x_wdt_data.tclk = orion5x_tclk;
556 platform_device_register(&orion5x_wdt_device);
557}
558
559
560/*****************************************************************************
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400561 * Time handling
562 ****************************************************************************/
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200563int orion5x_tclk;
564
565int __init orion5x_find_tclk(void)
566{
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200567 u32 dev, rev;
568
569 orion5x_pcie_id(&dev, &rev);
570 if (dev == MV88F6183_DEV_ID &&
571 (readl(MPP_RESET_SAMPLE) & 0x00000200) == 0)
572 return 133333333;
573
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200574 return 166666667;
575}
576
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400577static void orion5x_timer_init(void)
578{
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200579 orion5x_tclk = orion5x_find_tclk();
580 orion_time_init(IRQ_ORION5X_BRIDGE, orion5x_tclk);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400581}
582
583struct sys_timer orion5x_timer = {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200584 .init = orion5x_timer_init,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400585};
586
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200587
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400588/*****************************************************************************
589 * General
590 ****************************************************************************/
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400591/*
Lennert Buytenhekb46926b2008-04-25 16:31:32 -0400592 * Identify device ID and rev from PCIe configuration header space '0'.
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400593 */
594static void __init orion5x_id(u32 *dev, u32 *rev, char **dev_name)
595{
596 orion5x_pcie_id(dev, rev);
597
598 if (*dev == MV88F5281_DEV_ID) {
599 if (*rev == MV88F5281_REV_D2) {
600 *dev_name = "MV88F5281-D2";
601 } else if (*rev == MV88F5281_REV_D1) {
602 *dev_name = "MV88F5281-D1";
Lennert Buytenhekce72e36e2008-08-09 15:17:27 +0200603 } else if (*rev == MV88F5281_REV_D0) {
604 *dev_name = "MV88F5281-D0";
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400605 } else {
606 *dev_name = "MV88F5281-Rev-Unsupported";
607 }
608 } else if (*dev == MV88F5182_DEV_ID) {
609 if (*rev == MV88F5182_REV_A2) {
610 *dev_name = "MV88F5182-A2";
611 } else {
612 *dev_name = "MV88F5182-Rev-Unsupported";
613 }
614 } else if (*dev == MV88F5181_DEV_ID) {
615 if (*rev == MV88F5181_REV_B1) {
616 *dev_name = "MV88F5181-Rev-B1";
Lennert Buytenhekd2b2a6b2008-05-31 08:30:40 +0200617 } else if (*rev == MV88F5181L_REV_A1) {
618 *dev_name = "MV88F5181L-Rev-A1";
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400619 } else {
Lennert Buytenhekd2b2a6b2008-05-31 08:30:40 +0200620 *dev_name = "MV88F5181(L)-Rev-Unsupported";
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400621 }
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200622 } else if (*dev == MV88F6183_DEV_ID) {
623 if (*rev == MV88F6183_REV_B0) {
624 *dev_name = "MV88F6183-Rev-B0";
625 } else {
626 *dev_name = "MV88F6183-Rev-Unsupported";
627 }
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400628 } else {
629 *dev_name = "Device-Unknown";
630 }
631}
632
633void __init orion5x_init(void)
634{
635 char *dev_name;
636 u32 dev, rev;
637
638 orion5x_id(&dev, &rev, &dev_name);
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200639 printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, orion5x_tclk);
640
641 orion5x_eth_shared_data.t_clk = orion5x_tclk;
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200642 orion5x_spi_plat_data.tclk = orion5x_tclk;
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200643 orion5x_uart0_data[0].uartclk = orion5x_tclk;
644 orion5x_uart1_data[0].uartclk = orion5x_tclk;
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400645
646 /*
647 * Setup Orion address map
648 */
649 orion5x_setup_cpu_mbus_bridge();
Lennert Buytenhekce72e36e2008-08-09 15:17:27 +0200650
651 /*
652 * Don't issue "Wait for Interrupt" instruction if we are
653 * running on D0 5281 silicon.
654 */
655 if (dev == MV88F5281_DEV_ID && rev == MV88F5281_REV_D0) {
656 printk(KERN_INFO "Orion: Applying 5281 D0 WFI workaround.\n");
657 disable_hlt();
658 }
Thomas Reitmayr9e058d42009-02-24 14:59:22 -0800659
660 /*
661 * Register watchdog driver
662 */
663 orion5x_wdt_init();
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400664}
665
666/*
667 * Many orion-based systems have buggy bootloader implementations.
668 * This is a common fixup for bogus memory tags.
669 */
670void __init tag_fixup_mem32(struct machine_desc *mdesc, struct tag *t,
671 char **from, struct meminfo *meminfo)
672{
673 for (; t->hdr.size; t = tag_next(t))
674 if (t->hdr.tag == ATAG_MEM &&
675 (!t->u.mem.size || t->u.mem.size & ~PAGE_MASK ||
676 t->u.mem.start & ~PAGE_MASK)) {
677 printk(KERN_WARNING
678 "Clearing invalid memory bank %dKB@0x%08x\n",
679 t->u.mem.size / 1024, t->u.mem.start);
680 t->hdr.tag = 0;
681 }
682}