amphy.c (139749) | amphy.c (150763) |
---|---|
1/*- 2 * Copyright (c) 1997, 1998, 1999 3 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997, 1998, 1999 3 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/dev/mii/amphy.c 139749 2005-01-06 01:43:34Z imp $"); | 34__FBSDID("$FreeBSD: head/sys/dev/mii/amphy.c 150763 2005-09-30 19:39:27Z imp $"); |
35 36/* 37 * driver for AMD AM79c873 PHYs 38 * This driver also works for the Davicom DM9101 PHY, which appears to 39 * be an AM79c873 workalike. 40 */ 41 42#include <sys/param.h> --- 35 unchanged lines hidden (view full) --- 78}; 79 80DRIVER_MODULE(amphy, miibus, amphy_driver, amphy_devclass, 0, 0); 81 82static int amphy_service(struct mii_softc *, struct mii_data *, int); 83static void amphy_status(struct mii_softc *); 84 85static int | 35 36/* 37 * driver for AMD AM79c873 PHYs 38 * This driver also works for the Davicom DM9101 PHY, which appears to 39 * be an AM79c873 workalike. 40 */ 41 42#include <sys/param.h> --- 35 unchanged lines hidden (view full) --- 78}; 79 80DRIVER_MODULE(amphy, miibus, amphy_driver, amphy_devclass, 0, 0); 81 82static int amphy_service(struct mii_softc *, struct mii_data *, int); 83static void amphy_status(struct mii_softc *); 84 85static int |
86amphy_probe(dev) 87 device_t dev; | 86amphy_probe(device_t dev) |
88{ 89 struct mii_attach_args *ma; 90 91 ma = device_get_ivars(dev); 92 93 if ((MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_xxAMD || 94 MII_MODEL(ma->mii_id2) != MII_MODEL_xxAMD_79C873) && 95 (MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_xxDAVICOM || --- 4 unchanged lines hidden (view full) --- 100 device_set_desc(dev, MII_STR_xxAMD_79C873); 101 else if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxDAVICOM) 102 device_set_desc(dev, MII_STR_xxDAVICOM_DM9101); 103 104 return(0); 105} 106 107static int | 87{ 88 struct mii_attach_args *ma; 89 90 ma = device_get_ivars(dev); 91 92 if ((MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_xxAMD || 93 MII_MODEL(ma->mii_id2) != MII_MODEL_xxAMD_79C873) && 94 (MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_xxDAVICOM || --- 4 unchanged lines hidden (view full) --- 99 device_set_desc(dev, MII_STR_xxAMD_79C873); 100 else if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxDAVICOM) 101 device_set_desc(dev, MII_STR_xxDAVICOM_DM9101); 102 103 return(0); 104} 105 106static int |
108amphy_attach(dev) 109 device_t dev; | 107amphy_attach(device_t dev) |
110{ 111 struct mii_softc *sc; 112 struct mii_attach_args *ma; 113 struct mii_data *mii; 114 115 sc = device_get_softc(dev); 116 ma = device_get_ivars(dev); 117 sc->mii_dev = device_get_parent(dev); --- 25 unchanged lines hidden (view full) --- 143 mii_add_media(sc); 144 printf("\n"); 145#undef ADD 146 MIIBUS_MEDIAINIT(sc->mii_dev); 147 return(0); 148} 149 150static int | 108{ 109 struct mii_softc *sc; 110 struct mii_attach_args *ma; 111 struct mii_data *mii; 112 113 sc = device_get_softc(dev); 114 ma = device_get_ivars(dev); 115 sc->mii_dev = device_get_parent(dev); --- 25 unchanged lines hidden (view full) --- 141 mii_add_media(sc); 142 printf("\n"); 143#undef ADD 144 MIIBUS_MEDIAINIT(sc->mii_dev); 145 return(0); 146} 147 148static int |
151amphy_service(sc, mii, cmd) 152 struct mii_softc *sc; 153 struct mii_data *mii; 154 int cmd; | 149amphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) |
155{ 156 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 157 int reg; 158 159 switch (cmd) { 160 case MII_POLLSTAT: 161 /* 162 * If we're not polling our PHY instance, just return. --- 58 unchanged lines hidden (view full) --- 221 amphy_status(sc); 222 223 /* Callback if something changed. */ 224 mii_phy_update(sc, cmd); 225 return (0); 226} 227 228static void | 150{ 151 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 152 int reg; 153 154 switch (cmd) { 155 case MII_POLLSTAT: 156 /* 157 * If we're not polling our PHY instance, just return. --- 58 unchanged lines hidden (view full) --- 216 amphy_status(sc); 217 218 /* Callback if something changed. */ 219 mii_phy_update(sc, cmd); 220 return (0); 221} 222 223static void |
229amphy_status(sc) 230 struct mii_softc *sc; | 224amphy_status(struct mii_softc *sc) |
231{ 232 struct mii_data *mii = sc->mii_pdata; 233 int bmsr, bmcr, par, anlpar; 234 235 mii->mii_media_status = IFM_AVALID; 236 mii->mii_media_active = IFM_ETHER; 237 238 bmsr = PHY_READ(sc, MII_BMSR) | --- 58 unchanged lines hidden --- | 225{ 226 struct mii_data *mii = sc->mii_pdata; 227 int bmsr, bmcr, par, anlpar; 228 229 mii->mii_media_status = IFM_AVALID; 230 mii->mii_media_active = IFM_ETHER; 231 232 bmsr = PHY_READ(sc, MII_BMSR) | --- 58 unchanged lines hidden --- |