diff options
author | Florian Fainelli <florian@openwrt.org> | 2009-11-09 19:13:30 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2010-02-27 06:53:01 -0500 |
commit | 66f75ccb856304c190fde9c26e651c2b754e3e72 (patch) | |
tree | f63f8fe9362fc9805b73f9146a20457d1ceddff0 /arch/mips/alchemy/common | |
parent | cf6e47e03239059bcf2942b1b3242e835231ab75 (diff) |
MIPS: Alchemy: Add au1000-eth platform device
This patch makes the board code register the au1000-eth platform device. The
au1000-eth platform data can be overriden with the au1xxx_override_eth_cfg
function like it has to be done for the Bosporus board which uses a
different MAC/PHY setup.
Signed-off-by: Florian Fainelli <florian@openwrt.org>
Cc: David Miller <davem@davemloft.net>
Cc: linux-mips@linux-mips.org
Cc: netdev@vger.kernel.org
Patchwork: http://patchwork.linux-mips.org/patch/618/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/alchemy/common')
-rw-r--r-- | arch/mips/alchemy/common/platform.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c index 3be14b09157c..3fbe30c1fd9a 100644 --- a/arch/mips/alchemy/common/platform.c +++ b/arch/mips/alchemy/common/platform.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <asm/mach-au1x00/au1xxx.h> | 19 | #include <asm/mach-au1x00/au1xxx.h> |
20 | #include <asm/mach-au1x00/au1xxx_dbdma.h> | 20 | #include <asm/mach-au1x00/au1xxx_dbdma.h> |
21 | #include <asm/mach-au1x00/au1100_mmc.h> | 21 | #include <asm/mach-au1x00/au1100_mmc.h> |
22 | #include <asm/mach-au1x00/au1xxx_eth.h> | ||
22 | 23 | ||
23 | #define PORT(_base, _irq) \ | 24 | #define PORT(_base, _irq) \ |
24 | { \ | 25 | { \ |
@@ -326,6 +327,88 @@ static struct platform_device pbdb_smbus_device = { | |||
326 | }; | 327 | }; |
327 | #endif | 328 | #endif |
328 | 329 | ||
330 | /* Macro to help defining the Ethernet MAC resources */ | ||
331 | #define MAC_RES(_base, _enable, _irq) \ | ||
332 | { \ | ||
333 | .start = CPHYSADDR(_base), \ | ||
334 | .end = CPHYSADDR(_base + 0xffff), \ | ||
335 | .flags = IORESOURCE_MEM, \ | ||
336 | }, \ | ||
337 | { \ | ||
338 | .start = CPHYSADDR(_enable), \ | ||
339 | .end = CPHYSADDR(_enable + 0x3), \ | ||
340 | .flags = IORESOURCE_MEM, \ | ||
341 | }, \ | ||
342 | { \ | ||
343 | .start = _irq, \ | ||
344 | .end = _irq, \ | ||
345 | .flags = IORESOURCE_IRQ \ | ||
346 | } | ||
347 | |||
348 | static struct resource au1xxx_eth0_resources[] = { | ||
349 | #if defined(CONFIG_SOC_AU1000) | ||
350 | MAC_RES(AU1000_ETH0_BASE, AU1000_MAC0_ENABLE, AU1000_MAC0_DMA_INT), | ||
351 | #elif defined(CONFIG_SOC_AU1100) | ||
352 | MAC_RES(AU1100_ETH0_BASE, AU1100_MAC0_ENABLE, AU1100_MAC0_DMA_INT), | ||
353 | #elif defined(CONFIG_SOC_AU1550) | ||
354 | MAC_RES(AU1550_ETH0_BASE, AU1550_MAC0_ENABLE, AU1550_MAC0_DMA_INT), | ||
355 | #elif defined(CONFIG_SOC_AU1500) | ||
356 | MAC_RES(AU1500_ETH0_BASE, AU1500_MAC0_ENABLE, AU1500_MAC0_DMA_INT), | ||
357 | #endif | ||
358 | }; | ||
359 | |||
360 | static struct resource au1xxx_eth1_resources[] = { | ||
361 | #if defined(CONFIG_SOC_AU1000) | ||
362 | MAC_RES(AU1000_ETH1_BASE, AU1000_MAC1_ENABLE, AU1000_MAC1_DMA_INT), | ||
363 | #elif defined(CONFIG_SOC_AU1550) | ||
364 | MAC_RES(AU1550_ETH1_BASE, AU1550_MAC1_ENABLE, AU1550_MAC1_DMA_INT), | ||
365 | #elif defined(CONFIG_SOC_AU1500) | ||
366 | MAC_RES(AU1500_ETH1_BASE, AU1500_MAC1_ENABLE, AU1500_MAC1_DMA_INT), | ||
367 | #endif | ||
368 | }; | ||
369 | |||
370 | static struct au1000_eth_platform_data au1xxx_eth0_platform_data = { | ||
371 | .phy1_search_mac0 = 1, | ||
372 | }; | ||
373 | |||
374 | static struct platform_device au1xxx_eth0_device = { | ||
375 | .name = "au1000-eth", | ||
376 | .id = 0, | ||
377 | .num_resources = ARRAY_SIZE(au1xxx_eth0_resources), | ||
378 | .resource = au1xxx_eth0_resources, | ||
379 | .dev.platform_data = &au1xxx_eth0_platform_data, | ||
380 | }; | ||
381 | |||
382 | #ifndef CONFIG_SOC_AU1100 | ||
383 | static struct au1000_eth_platform_data au1xxx_eth1_platform_data = { | ||
384 | .phy1_search_mac0 = 1, | ||
385 | }; | ||
386 | |||
387 | static struct platform_device au1xxx_eth1_device = { | ||
388 | .name = "au1000-eth", | ||
389 | .id = 1, | ||
390 | .num_resources = ARRAY_SIZE(au1xxx_eth1_resources), | ||
391 | .resource = au1xxx_eth1_resources, | ||
392 | .dev.platform_data = &au1xxx_eth1_platform_data, | ||
393 | }; | ||
394 | #endif | ||
395 | |||
396 | void __init au1xxx_override_eth_cfg(unsigned int port, | ||
397 | struct au1000_eth_platform_data *eth_data) | ||
398 | { | ||
399 | if (!eth_data || port > 1) | ||
400 | return; | ||
401 | |||
402 | if (port == 0) | ||
403 | memcpy(&au1xxx_eth0_platform_data, eth_data, | ||
404 | sizeof(struct au1000_eth_platform_data)); | ||
405 | #ifndef CONFIG_SOC_AU1100 | ||
406 | else | ||
407 | memcpy(&au1xxx_eth1_platform_data, eth_data, | ||
408 | sizeof(struct au1000_eth_platform_data)); | ||
409 | #endif | ||
410 | } | ||
411 | |||
329 | static struct platform_device *au1xxx_platform_devices[] __initdata = { | 412 | static struct platform_device *au1xxx_platform_devices[] __initdata = { |
330 | &au1xx0_uart_device, | 413 | &au1xx0_uart_device, |
331 | &au1xxx_usb_ohci_device, | 414 | &au1xxx_usb_ohci_device, |
@@ -345,6 +428,7 @@ static struct platform_device *au1xxx_platform_devices[] __initdata = { | |||
345 | #ifdef SMBUS_PSC_BASE | 428 | #ifdef SMBUS_PSC_BASE |
346 | &pbdb_smbus_device, | 429 | &pbdb_smbus_device, |
347 | #endif | 430 | #endif |
431 | &au1xxx_eth0_device, | ||
348 | }; | 432 | }; |
349 | 433 | ||
350 | static int __init au1xxx_platform_init(void) | 434 | static int __init au1xxx_platform_init(void) |
@@ -356,6 +440,12 @@ static int __init au1xxx_platform_init(void) | |||
356 | for (i = 0; au1x00_uart_data[i].flags; i++) | 440 | for (i = 0; au1x00_uart_data[i].flags; i++) |
357 | au1x00_uart_data[i].uartclk = uartclk; | 441 | au1x00_uart_data[i].uartclk = uartclk; |
358 | 442 | ||
443 | #ifndef CONFIG_SOC_AU1100 | ||
444 | /* Register second MAC if enabled in pinfunc */ | ||
445 | if (!(au_readl(SYS_PINFUNC) & (u32)SYS_PF_NI2)) | ||
446 | platform_device_register(&au1xxx_eth1_device); | ||
447 | #endif | ||
448 | |||
359 | return platform_add_devices(au1xxx_platform_devices, | 449 | return platform_add_devices(au1xxx_platform_devices, |
360 | ARRAY_SIZE(au1xxx_platform_devices)); | 450 | ARRAY_SIZE(au1xxx_platform_devices)); |
361 | } | 451 | } |