Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Try reading MAC addr from register if it fails t...



details:   https://anonhg.NetBSD.org/src/rev/60dbba83519d
branches:  trunk
changeset: 760599:60dbba83519d
user:      kochi <kochi%NetBSD.org@localhost>
date:      Sun Jan 09 00:12:45 2011 +0000

description:
Try reading MAC addr from register if it fails to read from EEPROM.
Copied from FreeBSD driver.

Without this my JMC261 doesn't get MAC address properly.

OK'ed by bouyer@

diffstat:

 sys/dev/pci/if_jme.c |  29 ++++++++++++++++++++++++++---
 1 files changed, 26 insertions(+), 3 deletions(-)

diffs (64 lines):

diff -r 6f7220c6cb1b -r 60dbba83519d sys/dev/pci/if_jme.c
--- a/sys/dev/pci/if_jme.c      Sat Jan 08 22:02:49 2011 +0000
+++ b/sys/dev/pci/if_jme.c      Sun Jan 09 00:12:45 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_jme.c,v 1.15 2010/11/13 13:52:06 uebayasi Exp $     */
+/*     $NetBSD: if_jme.c,v 1.16 2011/01/09 00:12:45 kochi Exp $        */
 
 /*
  * Copyright (c) 2008 Manuel Bouyer.  All rights reserved.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.15 2010/11/13 13:52:06 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.16 2011/01/09 00:12:45 kochi Exp $");
 
 
 #include <sys/param.h>
@@ -215,6 +215,7 @@
 
 static int jme_eeprom_read_byte(struct jme_softc *, uint8_t, uint8_t *);
 static int jme_eeprom_macaddr(struct jme_softc *);
+static int jme_reg_macaddr(struct jme_softc *);
 
 #define JME_TIMEOUT            1000
 #define JME_PHY_TIMEOUT                1000
@@ -384,7 +385,7 @@
        jme_reset(sc);
 
        /* read mac addr */
-       if (jme_eeprom_macaddr(sc)) {
+       if (jme_eeprom_macaddr(sc) && jme_reg_macaddr(sc)) {
                aprint_error_dev(self, "error reading Ethernet address\n");
                /* return; */
        }
@@ -2000,6 +2001,28 @@
        return (ENOENT);
 }
 
+static int
+jme_reg_macaddr(struct jme_softc *sc)
+{
+       uint32_t par0, par1;
+
+       par0 = bus_space_read_4(sc->jme_bt_mac, sc->jme_bh_mac, JME_PAR0);
+       par1 = bus_space_read_4(sc->jme_bt_mac, sc->jme_bh_mac, JME_PAR1);
+       par1 &= 0xffff;
+       if ((par0 == 0 && par1 == 0) ||
+           (par0 == 0xffffffff && par1 == 0xffff)) {
+               return (ENOENT);
+       } else {
+               sc->jme_enaddr[0] = (par0 >> 0) & 0xff;
+               sc->jme_enaddr[1] = (par0 >> 8) & 0xff;
+               sc->jme_enaddr[2] = (par0 >> 16) & 0xff;
+               sc->jme_enaddr[3] = (par0 >> 24) & 0xff;
+               sc->jme_enaddr[4] = (par1 >> 0) & 0xff;
+               sc->jme_enaddr[5] = (par1 >> 8) & 0xff;
+       }
+       return (0);
+}
+
 /*
  * Set up sysctl(3) MIB, hw.jme.* - Individual controllers will be
  * set up in jme_pci_attach()



Home | Main Index | Thread Index | Old Index