| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ipgphy.c,v 1.5 2019/11/21 03:04:21 msaitoh Exp $ */ | | 1 | /* $NetBSD: ipgphy.c,v 1.6 2019/11/21 09:48:57 msaitoh Exp $ */ |
2 | /* $OpenBSD: ipgphy.c,v 1.19 2015/07/19 06:28:12 yuo Exp $ */ | | 2 | /* $OpenBSD: ipgphy.c,v 1.19 2015/07/19 06:28:12 yuo Exp $ */ |
3 | | | 3 | |
4 | /*- | | 4 | /*- |
5 | * Copyright (c) 2006, Pyun YongHyeon <yongari@FreeBSD.org> | | 5 | * Copyright (c) 2006, Pyun YongHyeon <yongari@FreeBSD.org> |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice unmodified, this list of conditions, and the following | | 12 | * notice unmodified, this list of conditions, and the following |
13 | * disclaimer. | | 13 | * disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -23,27 +23,27 @@ | | | @@ -23,27 +23,27 @@ |
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 | * SUCH DAMAGE. | | 28 | * SUCH DAMAGE. |
29 | * | | 29 | * |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * Driver for the IC Plus IP1000A/IP1001 10/100/1000 PHY. | | 33 | * Driver for the IC Plus IP1000A/IP1001 10/100/1000 PHY. |
34 | */ | | 34 | */ |
35 | #include <sys/cdefs.h> | | 35 | #include <sys/cdefs.h> |
36 | __KERNEL_RCSID(0, "$NetBSD: ipgphy.c,v 1.5 2019/11/21 03:04:21 msaitoh Exp $"); | | 36 | __KERNEL_RCSID(0, "$NetBSD: ipgphy.c,v 1.6 2019/11/21 09:48:57 msaitoh Exp $"); |
37 | | | 37 | |
38 | #include <sys/param.h> | | 38 | #include <sys/param.h> |
39 | #include <sys/systm.h> | | 39 | #include <sys/systm.h> |
40 | #include <sys/kernel.h> | | 40 | #include <sys/kernel.h> |
41 | #include <sys/device.h> | | 41 | #include <sys/device.h> |
42 | #include <sys/socket.h> | | 42 | #include <sys/socket.h> |
43 | #include <sys/errno.h> | | 43 | #include <sys/errno.h> |
44 | | | 44 | |
45 | #include <net/if.h> | | 45 | #include <net/if.h> |
46 | #include <net/if_media.h> | | 46 | #include <net/if_media.h> |
47 | | | 47 | |
48 | #include <dev/mii/mii.h> | | 48 | #include <dev/mii/mii.h> |
49 | #include <dev/mii/miivar.h> | | 49 | #include <dev/mii/miivar.h> |
| @@ -108,27 +108,27 @@ ipgphy_attach(device_t parent, device_t | | | @@ -108,27 +108,27 @@ ipgphy_attach(device_t parent, device_t |
108 | sc->mii_pdata = mii; | | 108 | sc->mii_pdata = mii; |
109 | sc->mii_flags = ma->mii_flags; | | 109 | sc->mii_flags = ma->mii_flags; |
110 | | | 110 | |
111 | sc->mii_flags |= MIIF_NOISOLATE; | | 111 | sc->mii_flags |= MIIF_NOISOLATE; |
112 | sc->mii_anegticks = MII_ANEGTICKS_GIGE; | | 112 | sc->mii_anegticks = MII_ANEGTICKS_GIGE; |
113 | | | 113 | |
114 | PHY_RESET(sc); | | 114 | PHY_RESET(sc); |
115 | | | 115 | |
116 | PHY_READ(sc, MII_BMSR, &sc->mii_capabilities); | | 116 | PHY_READ(sc, MII_BMSR, &sc->mii_capabilities); |
117 | sc->mii_capabilities &= ma->mii_capmask; | | 117 | sc->mii_capabilities &= ma->mii_capmask; |
118 | //sc->mii_capabilities &= ~BMSR_ANEG; | | 118 | //sc->mii_capabilities &= ~BMSR_ANEG; |
119 | if (sc->mii_capabilities & BMSR_EXTSTAT) | | 119 | if (sc->mii_capabilities & BMSR_EXTSTAT) |
120 | PHY_READ(sc, MII_EXTSR, &sc->mii_extcapabilities); | | 120 | PHY_READ(sc, MII_EXTSR, &sc->mii_extcapabilities); |
121 | | | 121 | |
122 | mii_phy_add_media(sc); | | 122 | mii_phy_add_media(sc); |
123 | aprint_normal("\n"); | | 123 | aprint_normal("\n"); |
124 | } | | 124 | } |
125 | | | 125 | |
126 | static int | | 126 | static int |
127 | ipgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) | | 127 | ipgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) |
128 | { | | 128 | { |
129 | struct ifmedia_entry *ife = mii->mii_media.ifm_cur; | | 129 | struct ifmedia_entry *ife = mii->mii_media.ifm_cur; |
130 | uint16_t reg, speed; | | 130 | uint16_t reg, speed; |
131 | | | 131 | |
132 | switch (cmd) { | | 132 | switch (cmd) { |
133 | case MII_POLLSTAT: | | 133 | case MII_POLLSTAT: |
134 | /* If we're not polling our PHY instance, just return. */ | | 134 | /* If we're not polling our PHY instance, just return. */ |
| @@ -246,27 +246,27 @@ ipgphy_status(struct mii_softc *sc) | | | @@ -246,27 +246,27 @@ ipgphy_status(struct mii_softc *sc) |
246 | uint16_t bmsr, bmcr, stat, gtsr; | | 246 | uint16_t bmsr, bmcr, stat, gtsr; |
247 | | | 247 | |
248 | /* For IP1000A, use generic way */ | | 248 | /* For IP1000A, use generic way */ |
249 | if (sc->mii_mpd_model == MII_MODEL_xxICPLUS_IP1000A) { | | 249 | if (sc->mii_mpd_model == MII_MODEL_xxICPLUS_IP1000A) { |
250 | ukphy_status(sc); | | 250 | ukphy_status(sc); |
251 | return; | | 251 | return; |
252 | } | | 252 | } |
253 | | | 253 | |
254 | mii->mii_media_status = IFM_AVALID; | | 254 | mii->mii_media_status = IFM_AVALID; |
255 | mii->mii_media_active = IFM_ETHER; | | 255 | mii->mii_media_active = IFM_ETHER; |
256 | | | 256 | |
257 | PHY_READ(sc, MII_BMSR, &bmsr); | | 257 | PHY_READ(sc, MII_BMSR, &bmsr); |
258 | PHY_READ(sc, MII_BMSR, &bmsr); | | 258 | PHY_READ(sc, MII_BMSR, &bmsr); |
259 | if (bmsr & BMSR_LINK) | | 259 | if (bmsr & BMSR_LINK) |
260 | mii->mii_media_status |= IFM_ACTIVE; | | 260 | mii->mii_media_status |= IFM_ACTIVE; |
261 | | | 261 | |
262 | PHY_READ(sc, MII_BMCR, &bmcr); | | 262 | PHY_READ(sc, MII_BMCR, &bmcr); |
263 | if (bmcr & BMCR_LOOP) | | 263 | if (bmcr & BMCR_LOOP) |
264 | mii->mii_media_active |= IFM_LOOP; | | 264 | mii->mii_media_active |= IFM_LOOP; |
265 | | | 265 | |
266 | if (bmcr & BMCR_AUTOEN) { | | 266 | if (bmcr & BMCR_AUTOEN) { |
267 | if ((bmsr & BMSR_ACOMP) == 0) { | | 267 | if ((bmsr & BMSR_ACOMP) == 0) { |
268 | /* Erg, still trying, I guess... */ | | 268 | /* Erg, still trying, I guess... */ |
269 | mii->mii_media_active |= IFM_NONE; | | 269 | mii->mii_media_active |= IFM_NONE; |
270 | return; | | 270 | return; |
271 | } | | 271 | } |
272 | | | 272 | |