qsphy.c (139749) | qsphy.c (150763) |
---|---|
1/* OpenBSD: qsphy.c,v 1.6 2000/08/26 20:04:18 nate Exp */ 2/* NetBSD: qsphy.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: qsphy.c,v 1.6 2000/08/26 20:04:18 nate Exp */ 2/* NetBSD: qsphy.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/qsphy.c 139749 2005-01-06 01:43:34Z imp $"); | 71__FBSDID("$FreeBSD: head/sys/dev/mii/qsphy.c 150763 2005-09-30 19:39:27Z imp $"); |
72 73/* 74 * driver for Quality Semiconductor's QS6612 ethernet 10/100 PHY 75 * datasheet from www.qualitysemi.com 76 */ 77 78#include <sys/param.h> 79#include <sys/systm.h> --- 36 unchanged lines hidden (view full) --- 116 117DRIVER_MODULE(qsphy, miibus, qsphy_driver, qsphy_devclass, 0, 0); 118 119static int qsphy_service(struct mii_softc *, struct mii_data *, int); 120static void qsphy_reset(struct mii_softc *); 121static void qsphy_status(struct mii_softc *); 122 123static int | 72 73/* 74 * driver for Quality Semiconductor's QS6612 ethernet 10/100 PHY 75 * datasheet from www.qualitysemi.com 76 */ 77 78#include <sys/param.h> 79#include <sys/systm.h> --- 36 unchanged lines hidden (view full) --- 116 117DRIVER_MODULE(qsphy, miibus, qsphy_driver, qsphy_devclass, 0, 0); 118 119static int qsphy_service(struct mii_softc *, struct mii_data *, int); 120static void qsphy_reset(struct mii_softc *); 121static void qsphy_status(struct mii_softc *); 122 123static int |
124qsphy_probe(dev) 125 device_t dev; | 124qsphy_probe(device_t dev) |
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_QUALSEMI && 132 MII_MODEL(ma->mii_id2) == MII_MODEL_QUALSEMI_QS6612) { 133 device_set_desc(dev, MII_STR_QUALSEMI_QS6612); 134 } else 135 return (ENXIO); 136 137 return (0); 138} 139 140static int | 125{ 126 struct mii_attach_args *ma; 127 128 ma = device_get_ivars(dev); 129 130 if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_QUALSEMI && 131 MII_MODEL(ma->mii_id2) == MII_MODEL_QUALSEMI_QS6612) { 132 device_set_desc(dev, MII_STR_QUALSEMI_QS6612); 133 } else 134 return (ENXIO); 135 136 return (0); 137} 138 139static int |
141qsphy_attach(dev) 142 device_t dev; | 140qsphy_attach(device_t dev) |
143{ 144 struct mii_softc *sc; 145 struct mii_attach_args *ma; 146 struct mii_data *mii; 147 148 sc = device_get_softc(dev); 149 ma = device_get_ivars(dev); 150 sc->mii_dev = device_get_parent(dev); --- 16 unchanged lines hidden (view full) --- 167 mii_add_media(sc); 168 printf("\n"); 169 170 MIIBUS_MEDIAINIT(sc->mii_dev); 171 return (0); 172} 173 174static int | 141{ 142 struct mii_softc *sc; 143 struct mii_attach_args *ma; 144 struct mii_data *mii; 145 146 sc = device_get_softc(dev); 147 ma = device_get_ivars(dev); 148 sc->mii_dev = device_get_parent(dev); --- 16 unchanged lines hidden (view full) --- 165 mii_add_media(sc); 166 printf("\n"); 167 168 MIIBUS_MEDIAINIT(sc->mii_dev); 169 return (0); 170} 171 172static int |
175qsphy_service(sc, mii, cmd) 176 struct mii_softc *sc; 177 struct mii_data *mii; 178 int cmd; | 173qsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) |
179{ 180 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 181 int reg; 182 183 /* 184 * If we're not selected, then do nothing, just isolate, if 185 * changing media. 186 */ --- 61 unchanged lines hidden (view full) --- 248 qsphy_status(sc); 249 250 /* Callback if something changed. */ 251 mii_phy_update(sc, cmd); 252 return (0); 253} 254 255static void | 174{ 175 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 176 int reg; 177 178 /* 179 * If we're not selected, then do nothing, just isolate, if 180 * changing media. 181 */ --- 61 unchanged lines hidden (view full) --- 243 qsphy_status(sc); 244 245 /* Callback if something changed. */ 246 mii_phy_update(sc, cmd); 247 return (0); 248} 249 250static void |
256qsphy_status(sc) 257 struct mii_softc *sc; | 251qsphy_status(struct mii_softc *sc) |
258{ 259 struct mii_data *mii = sc->mii_pdata; 260 int bmsr, bmcr, pctl; 261 262 mii->mii_media_status = IFM_AVALID; 263 mii->mii_media_active = IFM_ETHER; 264 265 bmsr = PHY_READ(sc, MII_BMSR) | --- 34 unchanged lines hidden (view full) --- 300 default: 301 /* Erg... this shouldn't happen. */ 302 mii->mii_media_active |= IFM_NONE; 303 break; 304 } 305} 306 307static void | 252{ 253 struct mii_data *mii = sc->mii_pdata; 254 int bmsr, bmcr, pctl; 255 256 mii->mii_media_status = IFM_AVALID; 257 mii->mii_media_active = IFM_ETHER; 258 259 bmsr = PHY_READ(sc, MII_BMSR) | --- 34 unchanged lines hidden (view full) --- 294 default: 295 /* Erg... this shouldn't happen. */ 296 mii->mii_media_active |= IFM_NONE; 297 break; 298 } 299} 300 301static void |
308qsphy_reset(sc) 309 struct mii_softc *sc; | 302qsphy_reset(struct mii_softc *sc) |
310{ 311 312 mii_phy_reset(sc); 313 PHY_WRITE(sc, MII_QSPHY_IMASK, 0); 314} | 303{ 304 305 mii_phy_reset(sc); 306 PHY_WRITE(sc, MII_QSPHY_IMASK, 0); 307} |