diff options
author | Rafal Jaworowski <raj@FreeBSD.org> | 2012-03-04 19:22:52 +0000 |
---|---|---|
committer | Rafal Jaworowski <raj@FreeBSD.org> | 2012-03-04 19:22:52 +0000 |
commit | aa15e881bb453670d9155ace6c4b1885b15056e1 (patch) | |
tree | 78b948ce6795b5c835b79387bde8f64f7f1b2827 /sys/dev/mge | |
parent | 1c7792950cb17570e4911cf341f4145861e0bc0c (diff) | |
download | src-test2-aa15e881bb453670d9155ace6c4b1885b15056e1.tar.gz src-test2-aa15e881bb453670d9155ace6c4b1885b15056e1.zip |
Notes
Diffstat (limited to 'sys/dev/mge')
-rw-r--r-- | sys/dev/mge/if_mge.c | 21 | ||||
-rw-r--r-- | sys/dev/mge/if_mgevar.h | 2 |
2 files changed, 10 insertions, 13 deletions
diff --git a/sys/dev/mge/if_mge.c b/sys/dev/mge/if_mge.c index 824f8a21a615..5b7a78d2dc90 100644 --- a/sys/dev/mge/if_mge.c +++ b/sys/dev/mge/if_mge.c @@ -79,9 +79,6 @@ __FBSDID("$FreeBSD$"); #include "miibus_if.h" -/* PHY registers are in the address space of the first mge unit */ -static struct mge_softc *sc_mge0 = NULL; - static int mge_probe(device_t dev); static int mge_attach(device_t dev); static int mge_detach(device_t dev); @@ -635,14 +632,11 @@ mge_attach(device_t dev) sc->dev = dev; sc->node = ofw_bus_get_node(dev); - if (device_get_unit(dev) == 0) - sc_mge0 = sc; - /* Set chip version-dependent parameters */ mge_ver_params(sc); - /* Get phy address from fdt */ - if (fdt_get_phyaddr(sc->node, &phy) != 0) + /* Get phy address and used softc from fdt */ + if (fdt_get_phyaddr(sc->node, sc->dev, &phy, (void **)&sc->phy_sc) != 0) return (ENXIO); /* Initialize mutexes */ @@ -1294,17 +1288,18 @@ mge_miibus_readreg(device_t dev, int phy, int reg) sc = device_get_softc(dev); - MGE_WRITE(sc_mge0, MGE_REG_SMI, 0x1fffffff & + MGE_WRITE(sc->phy_sc, MGE_REG_SMI, 0x1fffffff & (MGE_SMI_READ | (reg << 21) | (phy << 16))); retries = MGE_SMI_READ_RETRIES; - while (--retries && !(MGE_READ(sc_mge0, MGE_REG_SMI) & MGE_SMI_READVALID)) + while (--retries && + !(MGE_READ(sc->phy_sc, MGE_REG_SMI) & MGE_SMI_READVALID)) DELAY(MGE_SMI_READ_DELAY); if (retries == 0) device_printf(dev, "Timeout while reading from PHY\n"); - return (MGE_READ(sc_mge0, MGE_REG_SMI) & 0xffff); + return (MGE_READ(sc->phy_sc, MGE_REG_SMI) & 0xffff); } static int @@ -1315,11 +1310,11 @@ mge_miibus_writereg(device_t dev, int phy, int reg, int value) sc = device_get_softc(dev); - MGE_WRITE(sc_mge0, MGE_REG_SMI, 0x1fffffff & + MGE_WRITE(sc->phy_sc, MGE_REG_SMI, 0x1fffffff & (MGE_SMI_WRITE | (reg << 21) | (phy << 16) | (value & 0xffff))); retries = MGE_SMI_WRITE_RETRIES; - while (--retries && MGE_READ(sc_mge0, MGE_REG_SMI) & MGE_SMI_BUSY) + while (--retries && MGE_READ(sc->phy_sc, MGE_REG_SMI) & MGE_SMI_BUSY) DELAY(MGE_SMI_WRITE_DELAY); if (retries == 0) diff --git a/sys/dev/mge/if_mgevar.h b/sys/dev/mge/if_mgevar.h index 5f96fa760904..2ce6b6ffe71e 100644 --- a/sys/dev/mge/if_mgevar.h +++ b/sys/dev/mge/if_mgevar.h @@ -103,6 +103,8 @@ struct mge_softc { uint32_t mge_tx_tok_cnt; uint16_t mge_mtu; int mge_ver; + + struct mge_softc *phy_sc; }; |