blob: 1a1df24f419ef6f512b7f2bb24eaaeec6264e44c [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{
223 if (irq != NO_IRQ) {
224 orion5x_switch_resources[0].start = irq;
225 orion5x_switch_resources[0].end = irq;
226 orion5x_switch_device.num_resources = 1;
227 }
228
229 d->mii_bus = &orion5x_eth_shared.dev;
230 d->netdev = &orion5x_eth.dev;
231 orion5x_switch_device.dev.platform_data = d;
232
233 platform_device_register(&orion5x_switch_device);
234}
235
236
237/*****************************************************************************
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200238 * I2C
239 ****************************************************************************/
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400240static struct mv64xxx_i2c_pdata orion5x_i2c_pdata = {
241 .freq_m = 8, /* assumes 166 MHz TCLK */
242 .freq_n = 3,
243 .timeout = 1000, /* Default timeout of 1 second */
244};
245
246static struct resource orion5x_i2c_resources[] = {
247 {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200248 .name = "i2c base",
249 .start = I2C_PHYS_BASE,
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200250 .end = I2C_PHYS_BASE + 0x1f,
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200251 .flags = IORESOURCE_MEM,
252 }, {
253 .name = "i2c irq",
254 .start = IRQ_ORION5X_I2C,
255 .end = IRQ_ORION5X_I2C,
256 .flags = IORESOURCE_IRQ,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400257 },
258};
259
260static struct platform_device orion5x_i2c = {
261 .name = MV64XXX_I2C_CTLR_NAME,
262 .id = 0,
263 .num_resources = ARRAY_SIZE(orion5x_i2c_resources),
264 .resource = orion5x_i2c_resources,
265 .dev = {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200266 .platform_data = &orion5x_i2c_pdata,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400267 },
268};
269
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200270void __init orion5x_i2c_init(void)
271{
272 platform_device_register(&orion5x_i2c);
273}
274
275
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400276/*****************************************************************************
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200277 * SATA
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400278 ****************************************************************************/
279static struct resource orion5x_sata_resources[] = {
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400280 {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200281 .name = "sata base",
282 .start = ORION5X_SATA_PHYS_BASE,
283 .end = ORION5X_SATA_PHYS_BASE + 0x5000 - 1,
284 .flags = IORESOURCE_MEM,
285 }, {
286 .name = "sata irq",
287 .start = IRQ_ORION5X_SATA,
288 .end = IRQ_ORION5X_SATA,
289 .flags = IORESOURCE_IRQ,
290 },
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400291};
292
293static struct platform_device orion5x_sata = {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200294 .name = "sata_mv",
295 .id = 0,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400296 .dev = {
297 .coherent_dma_mask = 0xffffffff,
298 },
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200299 .num_resources = ARRAY_SIZE(orion5x_sata_resources),
300 .resource = orion5x_sata_resources,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400301};
302
303void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data)
304{
305 sata_data->dram = &orion5x_mbus_dram_info;
306 orion5x_sata.dev.platform_data = sata_data;
307 platform_device_register(&orion5x_sata);
308}
309
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200310
311/*****************************************************************************
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200312 * SPI
313 ****************************************************************************/
314static struct orion_spi_info orion5x_spi_plat_data = {
Nicolas Pitrec0e19362008-10-19 14:18:25 -0400315 .tclk = 0,
316 .enable_clock_fix = 1,
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200317};
318
319static struct resource orion5x_spi_resources[] = {
320 {
321 .name = "spi base",
322 .start = SPI_PHYS_BASE,
323 .end = SPI_PHYS_BASE + 0x1f,
324 .flags = IORESOURCE_MEM,
325 },
326};
327
328static struct platform_device orion5x_spi = {
329 .name = "orion_spi",
330 .id = 0,
331 .dev = {
332 .platform_data = &orion5x_spi_plat_data,
333 },
334 .num_resources = ARRAY_SIZE(orion5x_spi_resources),
335 .resource = orion5x_spi_resources,
336};
337
338void __init orion5x_spi_init()
339{
340 platform_device_register(&orion5x_spi);
341}
342
343
344/*****************************************************************************
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200345 * UART0
346 ****************************************************************************/
347static struct plat_serial8250_port orion5x_uart0_data[] = {
348 {
349 .mapbase = UART0_PHYS_BASE,
350 .membase = (char *)UART0_VIRT_BASE,
351 .irq = IRQ_ORION5X_UART0,
352 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
353 .iotype = UPIO_MEM,
354 .regshift = 2,
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200355 .uartclk = 0,
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200356 }, {
357 },
358};
359
360static struct resource orion5x_uart0_resources[] = {
361 {
362 .start = UART0_PHYS_BASE,
363 .end = UART0_PHYS_BASE + 0xff,
364 .flags = IORESOURCE_MEM,
365 }, {
366 .start = IRQ_ORION5X_UART0,
367 .end = IRQ_ORION5X_UART0,
368 .flags = IORESOURCE_IRQ,
369 },
370};
371
372static struct platform_device orion5x_uart0 = {
373 .name = "serial8250",
374 .id = PLAT8250_DEV_PLATFORM,
375 .dev = {
376 .platform_data = orion5x_uart0_data,
377 },
378 .resource = orion5x_uart0_resources,
379 .num_resources = ARRAY_SIZE(orion5x_uart0_resources),
380};
381
382void __init orion5x_uart0_init(void)
383{
384 platform_device_register(&orion5x_uart0);
385}
386
387
388/*****************************************************************************
389 * UART1
390 ****************************************************************************/
391static struct plat_serial8250_port orion5x_uart1_data[] = {
392 {
393 .mapbase = UART1_PHYS_BASE,
394 .membase = (char *)UART1_VIRT_BASE,
395 .irq = IRQ_ORION5X_UART1,
396 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
397 .iotype = UPIO_MEM,
398 .regshift = 2,
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200399 .uartclk = 0,
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200400 }, {
401 },
402};
403
404static struct resource orion5x_uart1_resources[] = {
405 {
406 .start = UART1_PHYS_BASE,
407 .end = UART1_PHYS_BASE + 0xff,
408 .flags = IORESOURCE_MEM,
409 }, {
410 .start = IRQ_ORION5X_UART1,
411 .end = IRQ_ORION5X_UART1,
412 .flags = IORESOURCE_IRQ,
413 },
414};
415
416static struct platform_device orion5x_uart1 = {
417 .name = "serial8250",
418 .id = PLAT8250_DEV_PLATFORM1,
419 .dev = {
420 .platform_data = orion5x_uart1_data,
421 },
422 .resource = orion5x_uart1_resources,
423 .num_resources = ARRAY_SIZE(orion5x_uart1_resources),
424};
425
426void __init orion5x_uart1_init(void)
427{
428 platform_device_register(&orion5x_uart1);
429}
430
431
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400432/*****************************************************************************
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100433 * XOR engine
434 ****************************************************************************/
Saeed Bisharaf45964e2009-03-02 17:30:36 +0200435struct mv_xor_platform_shared_data orion5x_xor_shared_data = {
436 .dram = &orion5x_mbus_dram_info,
437};
438
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100439static struct resource orion5x_xor_shared_resources[] = {
440 {
441 .name = "xor low",
442 .start = ORION5X_XOR_PHYS_BASE,
443 .end = ORION5X_XOR_PHYS_BASE + 0xff,
444 .flags = IORESOURCE_MEM,
445 }, {
446 .name = "xor high",
447 .start = ORION5X_XOR_PHYS_BASE + 0x200,
448 .end = ORION5X_XOR_PHYS_BASE + 0x2ff,
449 .flags = IORESOURCE_MEM,
450 },
451};
452
453static struct platform_device orion5x_xor_shared = {
454 .name = MV_XOR_SHARED_NAME,
455 .id = 0,
Saeed Bisharaf45964e2009-03-02 17:30:36 +0200456 .dev = {
457 .platform_data = &orion5x_xor_shared_data,
458 },
Saeed Bishara1d5a1a62008-06-16 23:25:12 -1100459 .num_resources = ARRAY_SIZE(orion5x_xor_shared_resources),
460 .resource = orion5x_xor_shared_resources,
461};
462
463static u64 orion5x_xor_dmamask = DMA_32BIT_MASK;
464
465static struct resource orion5x_xor0_resources[] = {
466 [0] = {
467 .start = IRQ_ORION5X_XOR0,
468 .end = IRQ_ORION5X_XOR0,
469 .flags = IORESOURCE_IRQ,
470 },
471};
472
473static struct mv_xor_platform_data orion5x_xor0_data = {
474 .shared = &orion5x_xor_shared,
475 .hw_id = 0,
476 .pool_size = PAGE_SIZE,
477};
478
479static struct platform_device orion5x_xor0_channel = {
480 .name = MV_XOR_NAME,
481 .id = 0,
482 .num_resources = ARRAY_SIZE(orion5x_xor0_resources),
483 .resource = orion5x_xor0_resources,
484 .dev = {
485 .dma_mask = &orion5x_xor_dmamask,
486 .coherent_dma_mask = DMA_64BIT_MASK,
487 .platform_data = (void *)&orion5x_xor0_data,
488 },
489};
490
491static struct resource orion5x_xor1_resources[] = {
492 [0] = {
493 .start = IRQ_ORION5X_XOR1,
494 .end = IRQ_ORION5X_XOR1,
495 .flags = IORESOURCE_IRQ,
496 },
497};
498
499static struct mv_xor_platform_data orion5x_xor1_data = {
500 .shared = &orion5x_xor_shared,
501 .hw_id = 1,
502 .pool_size = PAGE_SIZE,
503};
504
505static struct platform_device orion5x_xor1_channel = {
506 .name = MV_XOR_NAME,
507 .id = 1,
508 .num_resources = ARRAY_SIZE(orion5x_xor1_resources),
509 .resource = orion5x_xor1_resources,
510 .dev = {
511 .dma_mask = &orion5x_xor_dmamask,
512 .coherent_dma_mask = DMA_64BIT_MASK,
513 .platform_data = (void *)&orion5x_xor1_data,
514 },
515};
516
517void __init orion5x_xor_init(void)
518{
519 platform_device_register(&orion5x_xor_shared);
520
521 /*
522 * two engines can't do memset simultaneously, this limitation
523 * satisfied by removing memset support from one of the engines.
524 */
525 dma_cap_set(DMA_MEMCPY, orion5x_xor0_data.cap_mask);
526 dma_cap_set(DMA_XOR, orion5x_xor0_data.cap_mask);
527 platform_device_register(&orion5x_xor0_channel);
528
529 dma_cap_set(DMA_MEMCPY, orion5x_xor1_data.cap_mask);
530 dma_cap_set(DMA_MEMSET, orion5x_xor1_data.cap_mask);
531 dma_cap_set(DMA_XOR, orion5x_xor1_data.cap_mask);
532 platform_device_register(&orion5x_xor1_channel);
533}
534
535
536/*****************************************************************************
Thomas Reitmayr9e058d42009-02-24 14:59:22 -0800537 * Watchdog
538 ****************************************************************************/
539static struct orion5x_wdt_platform_data orion5x_wdt_data = {
540 .tclk = 0,
541};
542
543static struct platform_device orion5x_wdt_device = {
544 .name = "orion5x_wdt",
545 .id = -1,
546 .dev = {
547 .platform_data = &orion5x_wdt_data,
548 },
549 .num_resources = 0,
550};
551
552void __init orion5x_wdt_init(void)
553{
554 orion5x_wdt_data.tclk = orion5x_tclk;
555 platform_device_register(&orion5x_wdt_device);
556}
557
558
559/*****************************************************************************
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400560 * Time handling
561 ****************************************************************************/
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200562int orion5x_tclk;
563
564int __init orion5x_find_tclk(void)
565{
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200566 u32 dev, rev;
567
568 orion5x_pcie_id(&dev, &rev);
569 if (dev == MV88F6183_DEV_ID &&
570 (readl(MPP_RESET_SAMPLE) & 0x00000200) == 0)
571 return 133333333;
572
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200573 return 166666667;
574}
575
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400576static void orion5x_timer_init(void)
577{
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200578 orion5x_tclk = orion5x_find_tclk();
579 orion_time_init(IRQ_ORION5X_BRIDGE, orion5x_tclk);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400580}
581
582struct sys_timer orion5x_timer = {
Lennert Buytenheke7068ad2008-05-10 16:30:01 +0200583 .init = orion5x_timer_init,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400584};
585
Lennert Buytenhek044f6c72008-04-22 05:37:12 +0200586
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400587/*****************************************************************************
588 * General
589 ****************************************************************************/
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400590/*
Lennert Buytenhekb46926b2008-04-25 16:31:32 -0400591 * Identify device ID and rev from PCIe configuration header space '0'.
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400592 */
593static void __init orion5x_id(u32 *dev, u32 *rev, char **dev_name)
594{
595 orion5x_pcie_id(dev, rev);
596
597 if (*dev == MV88F5281_DEV_ID) {
598 if (*rev == MV88F5281_REV_D2) {
599 *dev_name = "MV88F5281-D2";
600 } else if (*rev == MV88F5281_REV_D1) {
601 *dev_name = "MV88F5281-D1";
Lennert Buytenhekce72e36e2008-08-09 15:17:27 +0200602 } else if (*rev == MV88F5281_REV_D0) {
603 *dev_name = "MV88F5281-D0";
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400604 } else {
605 *dev_name = "MV88F5281-Rev-Unsupported";
606 }
607 } else if (*dev == MV88F5182_DEV_ID) {
608 if (*rev == MV88F5182_REV_A2) {
609 *dev_name = "MV88F5182-A2";
610 } else {
611 *dev_name = "MV88F5182-Rev-Unsupported";
612 }
613 } else if (*dev == MV88F5181_DEV_ID) {
614 if (*rev == MV88F5181_REV_B1) {
615 *dev_name = "MV88F5181-Rev-B1";
Lennert Buytenhekd2b2a6b2008-05-31 08:30:40 +0200616 } else if (*rev == MV88F5181L_REV_A1) {
617 *dev_name = "MV88F5181L-Rev-A1";
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400618 } else {
Lennert Buytenhekd2b2a6b2008-05-31 08:30:40 +0200619 *dev_name = "MV88F5181(L)-Rev-Unsupported";
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400620 }
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200621 } else if (*dev == MV88F6183_DEV_ID) {
622 if (*rev == MV88F6183_REV_B0) {
623 *dev_name = "MV88F6183-Rev-B0";
624 } else {
625 *dev_name = "MV88F6183-Rev-Unsupported";
626 }
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400627 } else {
628 *dev_name = "Device-Unknown";
629 }
630}
631
632void __init orion5x_init(void)
633{
634 char *dev_name;
635 u32 dev, rev;
636
637 orion5x_id(&dev, &rev, &dev_name);
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200638 printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, orion5x_tclk);
639
640 orion5x_eth_shared_data.t_clk = orion5x_tclk;
Lennert Buytenhekd323ade2008-08-29 06:55:06 +0200641 orion5x_spi_plat_data.tclk = orion5x_tclk;
Lennert Buytenhekebe35af2008-08-29 05:55:51 +0200642 orion5x_uart0_data[0].uartclk = orion5x_tclk;
643 orion5x_uart1_data[0].uartclk = orion5x_tclk;
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400644
645 /*
646 * Setup Orion address map
647 */
648 orion5x_setup_cpu_mbus_bridge();
Lennert Buytenhekce72e36e2008-08-09 15:17:27 +0200649
650 /*
651 * Don't issue "Wait for Interrupt" instruction if we are
652 * running on D0 5281 silicon.
653 */
654 if (dev == MV88F5281_DEV_ID && rev == MV88F5281_REV_D0) {
655 printk(KERN_INFO "Orion: Applying 5281 D0 WFI workaround.\n");
656 disable_hlt();
657 }
Thomas Reitmayr9e058d42009-02-24 14:59:22 -0800658
659 /*
660 * Register watchdog driver
661 */
662 orion5x_wdt_init();
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400663}
664
665/*
666 * Many orion-based systems have buggy bootloader implementations.
667 * This is a common fixup for bogus memory tags.
668 */
669void __init tag_fixup_mem32(struct machine_desc *mdesc, struct tag *t,
670 char **from, struct meminfo *meminfo)
671{
672 for (; t->hdr.size; t = tag_next(t))
673 if (t->hdr.tag == ATAG_MEM &&
674 (!t->u.mem.size || t->u.mem.size & ~PAGE_MASK ||
675 t->u.mem.start & ~PAGE_MASK)) {
676 printk(KERN_WARNING
677 "Clearing invalid memory bank %dKB@0x%08x\n",
678 t->u.mem.size / 1024, t->u.mem.start);
679 t->hdr.tag = 0;
680 }
681}