lxtphy.c (139749) | lxtphy.c (150763) |
---|---|
1/* OpenBSD: lxtphy.c,v 1.5 2000/08/26 20:04:17 nate Exp */ 2/* NetBSD: lxtphy.c,v 1.19 2000/02/02 23:34:57 thorpej Exp */ 3 4/*- 5 * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation --- 54 unchanged lines hidden (view full) --- 63 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 64 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 65 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 66 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 67 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 68 */ 69 70#include <sys/cdefs.h> | 1/* OpenBSD: lxtphy.c,v 1.5 2000/08/26 20:04:17 nate Exp */ 2/* NetBSD: lxtphy.c,v 1.19 2000/02/02 23:34:57 thorpej Exp */ 3 4/*- 5 * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation --- 54 unchanged lines hidden (view full) --- 63 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 64 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 65 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 66 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 67 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 68 */ 69 70#include <sys/cdefs.h> |
71__FBSDID("$FreeBSD: head/sys/dev/mii/lxtphy.c 139749 2005-01-06 01:43:34Z imp $"); | 71__FBSDID("$FreeBSD: head/sys/dev/mii/lxtphy.c 150763 2005-09-30 19:39:27Z imp $"); |
72 73/* 74 * driver for Level One's LXT-970 ethernet 10/100 PHY 75 * datasheet from www.level1.com 76 */ 77 78#include <sys/param.h> 79#include <sys/systm.h> --- 37 unchanged lines hidden (view full) --- 117DRIVER_MODULE(lxtphy, miibus, lxtphy_driver, lxtphy_devclass, 0, 0); 118 119static int lxtphy_service(struct mii_softc *, struct mii_data *, int); 120static void lxtphy_status(struct mii_softc *); 121static void lxtphy_set_tp(struct mii_softc *); 122static void lxtphy_set_fx(struct mii_softc *); 123 124static int | 72 73/* 74 * driver for Level One's LXT-970 ethernet 10/100 PHY 75 * datasheet from www.level1.com 76 */ 77 78#include <sys/param.h> 79#include <sys/systm.h> --- 37 unchanged lines hidden (view full) --- 117DRIVER_MODULE(lxtphy, miibus, lxtphy_driver, lxtphy_devclass, 0, 0); 118 119static int lxtphy_service(struct mii_softc *, struct mii_data *, int); 120static void lxtphy_status(struct mii_softc *); 121static void lxtphy_set_tp(struct mii_softc *); 122static void lxtphy_set_fx(struct mii_softc *); 123 124static int |
125lxtphy_probe(dev) 126 device_t dev; | 125lxtphy_probe(device_t dev) |
127{ 128 struct mii_attach_args *ma; 129 130 ma = device_get_ivars(dev); 131 132 if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxLEVEL1 && 133 MII_MODEL(ma->mii_id2) == MII_MODEL_xxLEVEL1_LXT970) { 134 device_set_desc(dev, MII_STR_xxLEVEL1_LXT970); 135 } else 136 return (ENXIO); 137 138 return (0); 139} 140 141static int | 126{ 127 struct mii_attach_args *ma; 128 129 ma = device_get_ivars(dev); 130 131 if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxLEVEL1 && 132 MII_MODEL(ma->mii_id2) == MII_MODEL_xxLEVEL1_LXT970) { 133 device_set_desc(dev, MII_STR_xxLEVEL1_LXT970); 134 } else 135 return (ENXIO); 136 137 return (0); 138} 139 140static int |
142lxtphy_attach(dev) 143 device_t dev; | 141lxtphy_attach(device_t dev) |
144{ 145 struct mii_softc *sc; 146 struct mii_attach_args *ma; 147 struct mii_data *mii; 148 149 sc = device_get_softc(dev); 150 ma = device_get_ivars(dev); 151 sc->mii_dev = device_get_parent(dev); --- 28 unchanged lines hidden (view full) --- 180 mii_add_media(sc); 181 printf("\n"); 182 183 MIIBUS_MEDIAINIT(sc->mii_dev); 184 return(0); 185} 186 187static int | 142{ 143 struct mii_softc *sc; 144 struct mii_attach_args *ma; 145 struct mii_data *mii; 146 147 sc = device_get_softc(dev); 148 ma = device_get_ivars(dev); 149 sc->mii_dev = device_get_parent(dev); --- 28 unchanged lines hidden (view full) --- 178 mii_add_media(sc); 179 printf("\n"); 180 181 MIIBUS_MEDIAINIT(sc->mii_dev); 182 return(0); 183} 184 185static int |
188lxtphy_service(sc, mii, cmd) 189 struct mii_softc *sc; 190 struct mii_data *mii; 191 int cmd; | 186lxtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) |
192{ 193 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 194 int reg; 195 196 switch (cmd) { 197 case MII_POLLSTAT: 198 /* 199 * If we're not polling our PHY instance, just return. --- 65 unchanged lines hidden (view full) --- 265 lxtphy_status(sc); 266 267 /* Callback if something changed. */ 268 mii_phy_update(sc, cmd); 269 return (0); 270} 271 272static void | 187{ 188 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 189 int reg; 190 191 switch (cmd) { 192 case MII_POLLSTAT: 193 /* 194 * If we're not polling our PHY instance, just return. --- 65 unchanged lines hidden (view full) --- 260 lxtphy_status(sc); 261 262 /* Callback if something changed. */ 263 mii_phy_update(sc, cmd); 264 return (0); 265} 266 267static void |
273lxtphy_status(sc) 274 struct mii_softc *sc; | 268lxtphy_status(struct mii_softc *sc) |
275{ 276 struct mii_data *mii = sc->mii_pdata; 277 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 278 int bmcr, bmsr, csr; 279 280 mii->mii_media_status = IFM_AVALID; 281 mii->mii_media_active = IFM_ETHER; 282 --- 29 unchanged lines hidden (view full) --- 312 mii->mii_media_active |= IFM_10_T; 313 if (csr & CSR_DUPLEX) 314 mii->mii_media_active |= IFM_FDX; 315 } else 316 mii->mii_media_active = ife->ifm_media; 317} 318 319static void | 269{ 270 struct mii_data *mii = sc->mii_pdata; 271 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 272 int bmcr, bmsr, csr; 273 274 mii->mii_media_status = IFM_AVALID; 275 mii->mii_media_active = IFM_ETHER; 276 --- 29 unchanged lines hidden (view full) --- 306 mii->mii_media_active |= IFM_10_T; 307 if (csr & CSR_DUPLEX) 308 mii->mii_media_active |= IFM_FDX; 309 } else 310 mii->mii_media_active = ife->ifm_media; 311} 312 313static void |
320lxtphy_set_tp(sc) 321 struct mii_softc *sc; | 314lxtphy_set_tp(struct mii_softc *sc) |
322{ 323 int cfg; 324 325 cfg = PHY_READ(sc, MII_LXTPHY_CONFIG); 326 cfg &= ~CONFIG_100BASEFX; 327 PHY_WRITE(sc, MII_LXTPHY_CONFIG, cfg); 328} 329 330static void | 315{ 316 int cfg; 317 318 cfg = PHY_READ(sc, MII_LXTPHY_CONFIG); 319 cfg &= ~CONFIG_100BASEFX; 320 PHY_WRITE(sc, MII_LXTPHY_CONFIG, cfg); 321} 322 323static void |
331lxtphy_set_fx(sc) 332 struct mii_softc *sc; | 324lxtphy_set_fx(struct mii_softc *sc) |
333{ 334 int cfg; 335 336 cfg = PHY_READ(sc, MII_LXTPHY_CONFIG); 337 cfg |= CONFIG_100BASEFX; 338 PHY_WRITE(sc, MII_LXTPHY_CONFIG, cfg); 339} 340 | 325{ 326 int cfg; 327 328 cfg = PHY_READ(sc, MII_LXTPHY_CONFIG); 329 cfg |= CONFIG_100BASEFX; 330 PHY_WRITE(sc, MII_LXTPHY_CONFIG, cfg); 331} 332 |