gentbi.c (215714) | gentbi.c (221407) |
---|---|
1/* $NetBSD: gentbi.c,v 1.15 2006/03/29 07:05:24 thorpej Exp $ */ 2 3/*- 4 * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, --- 48 unchanged lines hidden (view full) --- 57/* 58 * Driver for generic ten-bit (1000BASE-SX) interfaces, built into 59 * many Gigabit Ethernet chips. 60 * 61 * All we have to do here is correctly report speed and duplex. 62 */ 63 64#include <sys/cdefs.h> | 1/* $NetBSD: gentbi.c,v 1.15 2006/03/29 07:05:24 thorpej Exp $ */ 2 3/*- 4 * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, --- 48 unchanged lines hidden (view full) --- 57/* 58 * Driver for generic ten-bit (1000BASE-SX) interfaces, built into 59 * many Gigabit Ethernet chips. 60 * 61 * All we have to do here is correctly report speed and duplex. 62 */ 63 64#include <sys/cdefs.h> |
65__FBSDID("$FreeBSD: head/sys/dev/mii/gentbi.c 215714 2010-11-22 21:20:11Z marius $"); | 65__FBSDID("$FreeBSD: head/sys/dev/mii/gentbi.c 221407 2011-05-03 19:51:29Z marius $"); |
66 67/* 68 * Driver for generic unknown ten-bit interfaces(1000BASE-{LX,SX} 69 * fiber interfaces). 70 */ 71 72#include <sys/param.h> 73#include <sys/systm.h> --- 32 unchanged lines hidden (view full) --- 106 sizeof(struct mii_softc) 107}; 108 109DRIVER_MODULE(gentbi, miibus, gentbi_driver, gentbi_devclass, 0, 0); 110 111static int gentbi_service(struct mii_softc *, struct mii_data *, int); 112static void gentbi_status(struct mii_softc *); 113 | 66 67/* 68 * Driver for generic unknown ten-bit interfaces(1000BASE-{LX,SX} 69 * fiber interfaces). 70 */ 71 72#include <sys/param.h> 73#include <sys/systm.h> --- 32 unchanged lines hidden (view full) --- 106 sizeof(struct mii_softc) 107}; 108 109DRIVER_MODULE(gentbi, miibus, gentbi_driver, gentbi_devclass, 0, 0); 110 111static int gentbi_service(struct mii_softc *, struct mii_data *, int); 112static void gentbi_status(struct mii_softc *); 113 |
114static const struct mii_phy_funcs gentbi_funcs = { 115 gentbi_service, 116 gentbi_status, 117 mii_phy_reset 118}; 119 |
|
114static int 115gentbi_probe(device_t dev) 116{ 117 device_t parent; 118 struct mii_attach_args *ma; 119 int bmsr, extsr; 120 121 parent = device_get_parent(dev); --- 25 unchanged lines hidden (view full) --- 147 148 return (ENXIO); 149} 150 151static int 152gentbi_attach(device_t dev) 153{ 154 struct mii_softc *sc; | 120static int 121gentbi_probe(device_t dev) 122{ 123 device_t parent; 124 struct mii_attach_args *ma; 125 int bmsr, extsr; 126 127 parent = device_get_parent(dev); --- 25 unchanged lines hidden (view full) --- 153 154 return (ENXIO); 155} 156 157static int 158gentbi_attach(device_t dev) 159{ 160 struct mii_softc *sc; |
155 struct mii_attach_args *ma; 156 struct mii_data *mii; | |
157 158 sc = device_get_softc(dev); | 161 162 sc = device_get_softc(dev); |
159 ma = device_get_ivars(dev); 160 sc->mii_dev = device_get_parent(dev); 161 mii = ma->mii_data; 162 LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); | |
163 | 163 |
164 if (bootverbose) 165 device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n", 166 MII_OUI(ma->mii_id1, ma->mii_id2), 167 MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2)); | 164 mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &gentbi_funcs, 0); |
168 | 165 |
169 sc->mii_flags = miibus_get_flags(dev); 170 sc->mii_inst = mii->mii_instance++; 171 sc->mii_phy = ma->mii_phyno; 172 sc->mii_service = gentbi_service; 173 sc->mii_pdata = mii; | 166 PHY_RESET(sc); |
174 | 167 |
175 sc->mii_flags |= MIIF_NOMANPAUSE; 176 177 mii_phy_reset(sc); 178 | |
179 /* 180 * Mask out all media in the BMSR. We only are really interested 181 * in "auto". 182 */ 183 sc->mii_capabilities = | 168 /* 169 * Mask out all media in the BMSR. We only are really interested 170 * in "auto". 171 */ 172 sc->mii_capabilities = |
184 PHY_READ(sc, MII_BMSR) & ma->mii_capmask & ~BMSR_MEDIAMASK; | 173 PHY_READ(sc, MII_BMSR) & sc->mii_capmask & ~BMSR_MEDIAMASK; |
185 if (sc->mii_capabilities & BMSR_EXTSTAT) 186 sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); 187 188 device_printf(dev, " "); 189 mii_phy_add_media(sc); 190 printf("\n"); 191 192 MIIBUS_MEDIAINIT(sc->mii_dev); --- 20 unchanged lines hidden (view full) --- 213 214 case MII_TICK: 215 if (mii_phy_tick(sc) == EJUSTRETURN) 216 return (0); 217 break; 218 } 219 220 /* Update the media status. */ | 174 if (sc->mii_capabilities & BMSR_EXTSTAT) 175 sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); 176 177 device_printf(dev, " "); 178 mii_phy_add_media(sc); 179 printf("\n"); 180 181 MIIBUS_MEDIAINIT(sc->mii_dev); --- 20 unchanged lines hidden (view full) --- 202 203 case MII_TICK: 204 if (mii_phy_tick(sc) == EJUSTRETURN) 205 return (0); 206 break; 207 } 208 209 /* Update the media status. */ |
221 gentbi_status(sc); | 210 PHY_STATUS(sc); |
222 223 /* Callback if something changed. */ 224 mii_phy_update(sc, cmd); 225 return (0); 226} 227 228static void 229gentbi_status(struct mii_softc *sc) --- 49 unchanged lines hidden --- | 211 212 /* Callback if something changed. */ 213 mii_phy_update(sc, cmd); 214 return (0); 215} 216 217static void 218gentbi_status(struct mii_softc *sc) --- 49 unchanged lines hidden --- |