]> git.hungrycats.org Git - linux/commitdiff
[TG3]: Support OBP firmware mac-addresses on sparc64.
authorDavid S. Miller <davem@nuts.ninka.net>
Wed, 23 Jul 2003 02:04:10 +0000 (19:04 -0700)
committerDavid S. Miller <davem@nuts.ninka.net>
Wed, 23 Jul 2003 02:04:10 +0000 (19:04 -0700)
drivers/net/tg3.c

index 0ba668a7878425eb2765dc684934739f1d458619..d2a0f9082a63405144a62157df64ec434d5881f7 100644 (file)
 #include <asm/byteorder.h>
 #include <asm/uaccess.h>
 
+#ifdef CONFIG_SPARC64
+#include <asm/idprom.h>
+#include <asm/oplib.h>
+#include <asm/pbm.h>
+#endif
+
 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
 #define TG3_VLAN_TAG_USED 1
 #else
@@ -51,8 +57,8 @@
 
 #define DRV_MODULE_NAME                "tg3"
 #define PFX DRV_MODULE_NAME    ": "
-#define DRV_MODULE_VERSION     "1.6"
-#define DRV_MODULE_RELDATE     "June 11, 2003"
+#define DRV_MODULE_VERSION     "1.7"
+#define DRV_MODULE_RELDATE     "July 23, 2003"
 
 #define TG3_DEF_MAC_MODE       0
 #define TG3_DEF_RX_MODE                0
@@ -6272,11 +6278,44 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
        return err;
 }
 
+#ifdef CONFIG_SPARC64
+static int __devinit tg3_get_macaddr_sparc(struct tg3 *tp)
+{
+       struct net_device *dev = tp->dev;
+       struct pci_dev *pdev = tp->pdev;
+       struct pcidev_cookie *pcp = pdev->sysdata;
+
+       if (pcp != NULL) {
+               int node = pcp->prom_node;
+
+               if (prom_getproplen(node, "local-mac-address") == 6) {
+                       prom_getproperty(node, "local-mac-address",
+                                        dev->dev_addr, 6);
+                       return 0;
+               }
+       }
+       return -ENODEV;
+}
+
+static int __devinit tg3_get_default_macaddr_sparc(struct tg3 *tp)
+{
+       struct net_device *dev = tp->dev;
+
+       memcpy(dev->dev_addr, idprom->id_ethaddr, 6);
+       return 0;
+}
+#endif
+
 static int __devinit tg3_get_device_address(struct tg3 *tp)
 {
        struct net_device *dev = tp->dev;
        u32 hi, lo, mac_offset;
 
+#ifdef CONFIG_SPARC64
+       if (!tg3_get_macaddr_sparc(tp))
+               return 0;
+#endif
+
        if (PCI_FUNC(tp->pdev->devfn) == 0)
                mac_offset = 0x7c;
        else
@@ -6317,9 +6356,13 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
                dev->dev_addr[0] = (hi >> 8) & 0xff;
        }
 
-       if (!is_valid_ether_addr(&dev->dev_addr[0]))
+       if (!is_valid_ether_addr(&dev->dev_addr[0])) {
+#ifdef CONFIG_SPARC64
+               if (!tg3_get_default_macaddr_sparc(tp))
+                       return 0;
+#endif
                return -EINVAL;
-
+       }
        return 0;
 }