e1000phy.c (197588) | e1000phy.c (197590) |
---|---|
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 197588 2009-09-28 19:53:53Z yongari $"); | 33__FBSDID("$FreeBSD: head/sys/dev/mii/e1000phy.c 197590 2009-09-28 21:03:28Z yongari $"); |
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> |
|
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; | 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; |
74 struct msk_mii_data *mmd; |
|
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), --- 46 unchanged lines hidden (view full) --- 125 126static int 127e1000phy_attach(device_t dev) 128{ 129 struct e1000phy_softc *esc; 130 struct mii_softc *sc; 131 struct mii_attach_args *ma; 132 struct mii_data *mii; | 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), --- 46 unchanged lines hidden (view full) --- 129 130static int 131e1000phy_attach(device_t dev) 132{ 133 struct e1000phy_softc *esc; 134 struct mii_softc *sc; 135 struct mii_attach_args *ma; 136 struct mii_data *mii; |
137 struct ifnet *ifp; |
|
133 134 esc = device_get_softc(dev); 135 sc = &esc->mii_sc; 136 ma = device_get_ivars(dev); 137 sc->mii_dev = device_get_parent(dev); 138 mii = device_get_softc(sc->mii_dev); 139 LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); 140 141 sc->mii_inst = mii->mii_instance; 142 sc->mii_phy = ma->mii_phyno; 143 sc->mii_service = e1000phy_service; 144 sc->mii_pdata = mii; 145 mii->mii_instance++; 146 147 esc->mii_model = MII_MODEL(ma->mii_id2); | 138 139 esc = device_get_softc(dev); 140 sc = &esc->mii_sc; 141 ma = device_get_ivars(dev); 142 sc->mii_dev = device_get_parent(dev); 143 mii = device_get_softc(sc->mii_dev); 144 LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); 145 146 sc->mii_inst = mii->mii_instance; 147 sc->mii_phy = ma->mii_phyno; 148 sc->mii_service = e1000phy_service; 149 sc->mii_pdata = mii; 150 mii->mii_instance++; 151 152 esc->mii_model = MII_MODEL(ma->mii_id2); |
153 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 } 162 |
|
148 switch (esc->mii_model) { 149 case MII_MODEL_MARVELL_E1011: 150 case MII_MODEL_MARVELL_E1112: 151 if (PHY_READ(sc, E1000_ESSR) & E1000_ESSR_FIBER_LINK) 152 sc->mii_flags |= MIIF_HAVEFIBER; 153 break; 154 case MII_MODEL_MARVELL_E1149: 155 /* --- 38 unchanged lines hidden (view full) --- 194 if (esc->mii_model == MII_MODEL_MARVELL_E1112) { 195 /* Select 1000BASE-X only mode. */ 196 page = PHY_READ(sc, E1000_EADR); 197 PHY_WRITE(sc, E1000_EADR, 2); 198 reg = PHY_READ(sc, E1000_SCR); 199 reg &= ~E1000_SCR_MODE_MASK; 200 reg |= E1000_SCR_MODE_1000BX; 201 PHY_WRITE(sc, E1000_SCR, reg); | 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: 170 /* --- 38 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); |
217 if (esc->mmd != NULL && esc->mmd->pmd == 'P') { 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 } |
|
202 PHY_WRITE(sc, E1000_EADR, page); 203 } 204 } else { 205 switch (esc->mii_model) { 206 case MII_MODEL_MARVELL_E1111: 207 case MII_MODEL_MARVELL_E1112: 208 case MII_MODEL_MARVELL_E1116: 209 case MII_MODEL_MARVELL_E1118: --- 339 unchanged lines hidden --- | 224 PHY_WRITE(sc, E1000_EADR, page); 225 } 226 } else { 227 switch (esc->mii_model) { 228 case MII_MODEL_MARVELL_E1111: 229 case MII_MODEL_MARVELL_E1112: 230 case MII_MODEL_MARVELL_E1116: 231 case MII_MODEL_MARVELL_E1118: --- 339 unchanged lines hidden --- |