e1000phy.c (213364) | e1000phy.c (213893) |
---|---|
1/*- 2 * Principal Author: Parag Patel 3 * Copyright (c) 2001 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * Additonal Copyright (c) 2001 by Traakan Software under same licence. 29 * Secondary Author: Matthew Jacob 30 */ 31 32#include <sys/cdefs.h> | 1/*- 2 * Principal Author: Parag Patel 3 * Copyright (c) 2001 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * Additonal Copyright (c) 2001 by Traakan Software under same licence. 29 * Secondary Author: Matthew Jacob 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/mii/e1000phy.c 213364 2010-10-02 18:53:12Z marius $"); | 33__FBSDID("$FreeBSD: head/sys/dev/mii/e1000phy.c 213893 2010-10-15 14:52:11Z marius $"); |
34 35/* 36 * driver for the Marvell 88E1000 series external 1000/100/10-BT PHY. 37 */ 38 39/* 40 * Support added for the Marvell 88E1011 (Alaska) 1000/100/10baseTX and 41 * 1000baseSX PHY. --- 12 unchanged lines hidden (view full) --- 54#include <net/if.h> 55#include <net/if_media.h> 56 57#include <dev/mii/mii.h> 58#include <dev/mii/miivar.h> 59#include "miidevs.h" 60 61#include <dev/mii/e1000phyreg.h> | 34 35/* 36 * driver for the Marvell 88E1000 series external 1000/100/10-BT PHY. 37 */ 38 39/* 40 * Support added for the Marvell 88E1011 (Alaska) 1000/100/10baseTX and 41 * 1000baseSX PHY. --- 12 unchanged lines hidden (view full) --- 54#include <net/if.h> 55#include <net/if_media.h> 56 57#include <dev/mii/mii.h> 58#include <dev/mii/miivar.h> 59#include "miidevs.h" 60 61#include <dev/mii/e1000phyreg.h> |
62/* XXX */ 63#include <machine/bus.h> 64#include <dev/msk/if_mskreg.h> | |
65 66#include "miibus_if.h" 67 68static int e1000phy_probe(device_t); 69static int e1000phy_attach(device_t); 70 71struct e1000phy_softc { 72 struct mii_softc mii_sc; 73 int mii_model; | 62 63#include "miibus_if.h" 64 65static int e1000phy_probe(device_t); 66static int e1000phy_attach(device_t); 67 68struct e1000phy_softc { 69 struct mii_softc mii_sc; 70 int mii_model; |
74 struct msk_mii_data *mmd; | |
75}; 76 77static device_method_t e1000phy_methods[] = { 78 /* device interface */ 79 DEVMETHOD(device_probe, e1000phy_probe), 80 DEVMETHOD(device_attach, e1000phy_attach), 81 DEVMETHOD(device_detach, mii_phy_detach), 82 DEVMETHOD(device_shutdown, bus_generic_shutdown), --- 56 unchanged lines hidden (view full) --- 139 140 esc = device_get_softc(dev); 141 sc = &esc->mii_sc; 142 ma = device_get_ivars(dev); 143 sc->mii_dev = device_get_parent(dev); 144 mii = ma->mii_data; 145 LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); 146 | 71}; 72 73static device_method_t e1000phy_methods[] = { 74 /* device interface */ 75 DEVMETHOD(device_probe, e1000phy_probe), 76 DEVMETHOD(device_attach, e1000phy_attach), 77 DEVMETHOD(device_detach, mii_phy_detach), 78 DEVMETHOD(device_shutdown, bus_generic_shutdown), --- 56 unchanged lines hidden (view full) --- 135 136 esc = device_get_softc(dev); 137 sc = &esc->mii_sc; 138 ma = device_get_ivars(dev); 139 sc->mii_dev = device_get_parent(dev); 140 mii = ma->mii_data; 141 LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); 142 |
143 sc->mii_flags = miibus_get_flags(dev); |
|
147 sc->mii_inst = mii->mii_instance++; 148 sc->mii_phy = ma->mii_phyno; 149 sc->mii_service = e1000phy_service; 150 sc->mii_pdata = mii; 151 152 esc->mii_model = MII_MODEL(ma->mii_id2); 153 ifp = sc->mii_pdata->mii_ifp; | 144 sc->mii_inst = mii->mii_instance++; 145 sc->mii_phy = ma->mii_phyno; 146 sc->mii_service = e1000phy_service; 147 sc->mii_pdata = mii; 148 149 esc->mii_model = MII_MODEL(ma->mii_id2); 150 ifp = sc->mii_pdata->mii_ifp; |
154 if (strcmp(ifp->if_dname, "msk") == 0) { 155 /* XXX */ 156 esc->mmd = device_get_ivars( 157 device_get_parent(device_get_parent(dev))); 158 if (esc->mmd != NULL && 159 (esc->mmd->mii_flags & MIIF_HAVEFIBER) != 0) 160 sc->mii_flags |= MIIF_HAVEFIBER; 161 } | 151 if (strcmp(ifp->if_dname, "msk") == 0 && 152 (sc->mii_flags & MIIF_MACPRIV0) != 0) 153 sc->mii_flags |= MIIF_PHYPRIV0; |
162 163 switch (esc->mii_model) { 164 case MII_MODEL_MARVELL_E1011: 165 case MII_MODEL_MARVELL_E1112: 166 if (PHY_READ(sc, E1000_ESSR) & E1000_ESSR_FIBER_LINK) 167 sc->mii_flags |= MIIF_HAVEFIBER; 168 break; 169 case MII_MODEL_MARVELL_E1149: --- 39 unchanged lines hidden (view full) --- 209 if (esc->mii_model == MII_MODEL_MARVELL_E1112) { 210 /* Select 1000BASE-X only mode. */ 211 page = PHY_READ(sc, E1000_EADR); 212 PHY_WRITE(sc, E1000_EADR, 2); 213 reg = PHY_READ(sc, E1000_SCR); 214 reg &= ~E1000_SCR_MODE_MASK; 215 reg |= E1000_SCR_MODE_1000BX; 216 PHY_WRITE(sc, E1000_SCR, reg); | 154 155 switch (esc->mii_model) { 156 case MII_MODEL_MARVELL_E1011: 157 case MII_MODEL_MARVELL_E1112: 158 if (PHY_READ(sc, E1000_ESSR) & E1000_ESSR_FIBER_LINK) 159 sc->mii_flags |= MIIF_HAVEFIBER; 160 break; 161 case MII_MODEL_MARVELL_E1149: --- 39 unchanged lines hidden (view full) --- 201 if (esc->mii_model == MII_MODEL_MARVELL_E1112) { 202 /* Select 1000BASE-X only mode. */ 203 page = PHY_READ(sc, E1000_EADR); 204 PHY_WRITE(sc, E1000_EADR, 2); 205 reg = PHY_READ(sc, E1000_SCR); 206 reg &= ~E1000_SCR_MODE_MASK; 207 reg |= E1000_SCR_MODE_1000BX; 208 PHY_WRITE(sc, E1000_SCR, reg); |
217 if (esc->mmd != NULL && esc->mmd->pmd == 'P') { | 209 if ((sc->mii_flags & MIIF_MACPRIV0) != 0) { |
218 /* Set SIGDET polarity low for SFP module. */ 219 PHY_WRITE(sc, E1000_EADR, 1); 220 reg = PHY_READ(sc, E1000_SCR); 221 reg |= E1000_SCR_FIB_SIGDET_POLARITY; 222 PHY_WRITE(sc, E1000_SCR, reg); 223 } 224 PHY_WRITE(sc, E1000_EADR, page); 225 } --- 324 unchanged lines hidden --- | 210 /* Set SIGDET polarity low for SFP module. */ 211 PHY_WRITE(sc, E1000_EADR, 1); 212 reg = PHY_READ(sc, E1000_SCR); 213 reg |= E1000_SCR_FIB_SIGDET_POLARITY; 214 PHY_WRITE(sc, E1000_SCR, reg); 215 } 216 PHY_WRITE(sc, E1000_EADR, page); 217 } --- 324 unchanged lines hidden --- |