nsphyter.c (213364) | nsphyter.c (213893) |
---|---|
1/* $NetBSD: nsphyter.c,v 1.28 2008/01/20 07:58:19 msaitoh 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, --- 41 unchanged lines hidden (view full) --- 50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 55 */ 56 57#include <sys/cdefs.h> | 1/* $NetBSD: nsphyter.c,v 1.28 2008/01/20 07:58:19 msaitoh 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, --- 41 unchanged lines hidden (view full) --- 50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 55 */ 56 57#include <sys/cdefs.h> |
58__FBSDID("$FreeBSD: head/sys/dev/mii/nsphyter.c 213364 2010-10-02 18:53:12Z marius $"); | 58__FBSDID("$FreeBSD: head/sys/dev/mii/nsphyter.c 213893 2010-10-15 14:52:11Z marius $"); |
59 60/* 61 * driver for National Semiconductor's DP83843 `PHYTER' ethernet 10/100 PHY 62 * Data Sheet available from www.national.com 63 * 64 * We also support the DP83815 `MacPHYTER' internal PHY since, for our 65 * purposes, they are compatible. 66 */ --- 58 unchanged lines hidden (view full) --- 125} 126 127static int 128nsphyter_attach(device_t dev) 129{ 130 struct mii_softc *sc; 131 struct mii_attach_args *ma; 132 struct mii_data *mii; | 59 60/* 61 * driver for National Semiconductor's DP83843 `PHYTER' ethernet 10/100 PHY 62 * Data Sheet available from www.national.com 63 * 64 * We also support the DP83815 `MacPHYTER' internal PHY since, for our 65 * purposes, they are compatible. 66 */ --- 58 unchanged lines hidden (view full) --- 125} 126 127static int 128nsphyter_attach(device_t dev) 129{ 130 struct mii_softc *sc; 131 struct mii_attach_args *ma; 132 struct mii_data *mii; |
133 const char *nic; | |
134 135 sc = device_get_softc(dev); 136 ma = device_get_ivars(dev); 137 sc->mii_dev = device_get_parent(dev); 138 mii = ma->mii_data; 139 LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); 140 | 133 134 sc = device_get_softc(dev); 135 ma = device_get_ivars(dev); 136 sc->mii_dev = device_get_parent(dev); 137 mii = ma->mii_data; 138 LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); 139 |
140 sc->mii_flags = miibus_get_flags(dev); |
|
141 sc->mii_inst = mii->mii_instance++; 142 sc->mii_phy = ma->mii_phyno; 143 sc->mii_service = nsphyter_service; 144 sc->mii_pdata = mii; 145 | 141 sc->mii_inst = mii->mii_instance++; 142 sc->mii_phy = ma->mii_phyno; 143 sc->mii_service = nsphyter_service; 144 sc->mii_pdata = mii; 145 |
146#if 1 147 |
|
146#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) 147 | 148#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) 149 |
148 nic = device_get_name(device_get_parent(sc->mii_dev)); | |
149 /* | 150 /* |
150 * In order for MII loopback to work Am79C971 and greater PCnet 151 * chips additionally need to be placed into external loopback 152 * mode which pcn(4) doesn't do so far. | 151 * XXX IFM_LOOP should be handled by mii_phy_add_media() based 152 * on MIIF_NOLOOP. |
153 */ | 153 */ |
154 if (strcmp(nic, "pcn") != 0) 155#if 1 | 154 if ((sc->mii_flags & MIIF_NOLOOP) == 0) |
156 ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, 157 sc->mii_inst), MII_MEDIA_100_TX); | 155 ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, 156 sc->mii_inst), MII_MEDIA_100_TX); |
158#else 159 if (strcmp(nic, "pcn") == 0) 160 sc->mii_flags |= MIIF_NOLOOP; | 157 |
161#endif 162 163 nsphyter_reset(sc); 164 165 sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; 166 device_printf(dev, " "); 167 mii_phy_add_media(sc); 168 printf("\n"); 169 | 158#endif 159 160 nsphyter_reset(sc); 161 162 sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; 163 device_printf(dev, " "); 164 mii_phy_add_media(sc); 165 printf("\n"); 166 |
170#undef ADD 171 | |
172 MIIBUS_MEDIAINIT(sc->mii_dev); 173 return (0); 174} 175 176static int 177nsphyter_service(struct mii_softc *sc, struct mii_data *mii, int cmd) 178{ 179 --- 126 unchanged lines hidden --- | 167 MIIBUS_MEDIAINIT(sc->mii_dev); 168 return (0); 169} 170 171static int 172nsphyter_service(struct mii_softc *sc, struct mii_data *mii, int cmd) 173{ 174 --- 126 unchanged lines hidden --- |