aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/tc35815.c50
1 files changed, 45 insertions, 5 deletions
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c
index 463d600ed83d..75655add3f34 100644
--- a/drivers/net/tc35815.c
+++ b/drivers/net/tc35815.c
@@ -23,9 +23,9 @@
23 */ 23 */
24 24
25#ifdef TC35815_NAPI 25#ifdef TC35815_NAPI
26#define DRV_VERSION "1.35-NAPI" 26#define DRV_VERSION "1.36-NAPI"
27#else 27#else
28#define DRV_VERSION "1.35" 28#define DRV_VERSION "1.36"
29#endif 29#endif
30static const char *version = "tc35815.c:v" DRV_VERSION "\n"; 30static const char *version = "tc35815.c:v" DRV_VERSION "\n";
31#define MODNAME "tc35815" 31#define MODNAME "tc35815"
@@ -49,6 +49,7 @@ static const char *version = "tc35815.c:v" DRV_VERSION "\n";
49#include <linux/pci.h> 49#include <linux/pci.h>
50#include <linux/mii.h> 50#include <linux/mii.h>
51#include <linux/ethtool.h> 51#include <linux/ethtool.h>
52#include <linux/platform_device.h>
52#include <asm/io.h> 53#include <asm/io.h>
53#include <asm/byteorder.h> 54#include <asm/byteorder.h>
54 55
@@ -597,13 +598,46 @@ static int tc_mdio_read(struct net_device *dev, int phy_id, int location);
597static void tc_mdio_write(struct net_device *dev, int phy_id, int location, 598static void tc_mdio_write(struct net_device *dev, int phy_id, int location,
598 int val); 599 int val);
599 600
600static void __devinit tc35815_init_dev_addr (struct net_device *dev) 601#ifdef CONFIG_CPU_TX49XX
602/*
603 * Find a platform_device providing a MAC address. The platform code
604 * should provide a "tc35815-mac" device with a MAC address in its
605 * platform_data.
606 */
607static int __devinit tc35815_mac_match(struct device *dev, void *data)
608{
609 struct platform_device *plat_dev = to_platform_device(dev);
610 struct pci_dev *pci_dev = data;
611 unsigned int id = (pci_dev->bus->number << 8) | pci_dev->devfn;
612 return !strcmp(plat_dev->name, "tc35815-mac") && plat_dev->id == id;
613}
614
615static int __devinit tc35815_read_plat_dev_addr(struct net_device *dev)
616{
617 struct tc35815_local *lp = dev->priv;
618 struct device *pd = bus_find_device(&platform_bus_type, NULL,
619 lp->pci_dev, tc35815_mac_match);
620 if (pd) {
621 if (pd->platform_data)
622 memcpy(dev->dev_addr, pd->platform_data, ETH_ALEN);
623 put_device(pd);
624 return is_valid_ether_addr(dev->dev_addr) ? 0 : -ENODEV;
625 }
626 return -ENODEV;
627}
628#else
629static int __devinit tc35815_read_plat_dev_addr(struct device *dev)
630{
631 return -ENODEV;
632}
633#endif
634
635static int __devinit tc35815_init_dev_addr (struct net_device *dev)
601{ 636{
602 struct tc35815_regs __iomem *tr = 637 struct tc35815_regs __iomem *tr =
603 (struct tc35815_regs __iomem *)dev->base_addr; 638 (struct tc35815_regs __iomem *)dev->base_addr;
604 int i; 639 int i;
605 640
606 /* dev_addr will be overwritten on NETDEV_REGISTER event */
607 while (tc_readl(&tr->PROM_Ctl) & PROM_Busy) 641 while (tc_readl(&tr->PROM_Ctl) & PROM_Busy)
608 ; 642 ;
609 for (i = 0; i < 6; i += 2) { 643 for (i = 0; i < 6; i += 2) {
@@ -615,6 +649,9 @@ static void __devinit tc35815_init_dev_addr (struct net_device *dev)
615 dev->dev_addr[i] = data & 0xff; 649 dev->dev_addr[i] = data & 0xff;
616 dev->dev_addr[i+1] = data >> 8; 650 dev->dev_addr[i+1] = data >> 8;
617 } 651 }
652 if (!is_valid_ether_addr(dev->dev_addr))
653 return tc35815_read_plat_dev_addr(dev);
654 return 0;
618} 655}
619 656
620static int __devinit tc35815_init_one (struct pci_dev *pdev, 657static int __devinit tc35815_init_one (struct pci_dev *pdev,
@@ -724,7 +761,10 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
724 tc35815_chip_reset(dev); 761 tc35815_chip_reset(dev);
725 762
726 /* Retrieve the ethernet address. */ 763 /* Retrieve the ethernet address. */
727 tc35815_init_dev_addr(dev); 764 if (tc35815_init_dev_addr(dev)) {
765 dev_warn(&pdev->dev, "not valid ether addr\n");
766 random_ether_addr(dev->dev_addr);
767 }
728 768
729 rc = register_netdev (dev); 769 rc = register_netdev (dev);
730 if (rc) 770 if (rc)