- Remove the waitfor argument from mii_phy_auto(). - Whitespace fix.diff -r1.39 -r1.40 src/sys/dev/mii/ciphy.c
(msaitoh)
--- src/sys/dev/mii/ciphy.c 2020/03/15 23:04:50 1.39
+++ src/sys/dev/mii/ciphy.c 2020/07/07 08:44:12 1.40
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ciphy.c,v 1.39 2020/03/15 23:04:50 thorpej Exp $ */ | 1 | /* $NetBSD: ciphy.c,v 1.40 2020/07/07 08:44:12 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2004 | 4 | * Copyright (c) 2004 | |
5 | * Bill Paul <wpaul@windriver.com>. All rights reserved. | 5 | * Bill Paul <wpaul@windriver.com>. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD | |
26 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 26 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
32 | * THE POSSIBILITY OF SUCH DAMAGE. | 32 | * THE POSSIBILITY OF SUCH DAMAGE. | |
33 | * | 33 | * | |
34 | * FreeBSD: src/sys/dev/mii/ciphy.c,v 1.2 2005/01/06 01:42:55 imp Exp | 34 | * FreeBSD: src/sys/dev/mii/ciphy.c,v 1.2 2005/01/06 01:42:55 imp Exp | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: ciphy.c,v 1.39 2020/03/15 23:04:50 thorpej Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: ciphy.c,v 1.40 2020/07/07 08:44:12 msaitoh Exp $"); | |
39 | 39 | |||
40 | /* | 40 | /* | |
41 | * Driver for the Cicada CS8201 10/100/1000 copper PHY. | 41 | * Driver for the Cicada CS8201 10/100/1000 copper PHY. | |
42 | */ | 42 | */ | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/systm.h> | 45 | #include <sys/systm.h> | |
46 | #include <sys/device.h> | 46 | #include <sys/device.h> | |
47 | #include <sys/kernel.h> | 47 | #include <sys/kernel.h> | |
48 | #include <sys/socket.h> | 48 | #include <sys/socket.h> | |
49 | #include <sys/bus.h> | 49 | #include <sys/bus.h> | |
50 | 50 | |||
51 | #include <net/if.h> | 51 | #include <net/if.h> | |
@@ -163,27 +163,27 @@ ciphy_service(struct mii_softc *sc, stru | @@ -163,27 +163,27 @@ ciphy_service(struct mii_softc *sc, stru | |||
163 | if ((mii->mii_ifp->if_flags & IFF_UP) == 0) | 163 | if ((mii->mii_ifp->if_flags & IFF_UP) == 0) | |
164 | break; | 164 | break; | |
165 | 165 | |||
166 | ciphy_fixup(sc); /* XXX hardware bug work-around */ | 166 | ciphy_fixup(sc); /* XXX hardware bug work-around */ | |
167 | 167 | |||
168 | switch (IFM_SUBTYPE(ife->ifm_media)) { | 168 | switch (IFM_SUBTYPE(ife->ifm_media)) { | |
169 | case IFM_AUTO: | 169 | case IFM_AUTO: | |
170 | #ifdef foo | 170 | #ifdef foo | |
171 | /* If we're already in auto mode, just return. */ | 171 | /* If we're already in auto mode, just return. */ | |
172 | PHY_READ(sc, MII_BMCR, ®); | 172 | PHY_READ(sc, MII_BMCR, ®); | |
173 | if (reg & BMCR_AUTOEN) | 173 | if (reg & BMCR_AUTOEN) | |
174 | return 0; | 174 | return 0; | |
175 | #endif | 175 | #endif | |
176 | (void) mii_phy_auto(sc, 0); | 176 | (void) mii_phy_auto(sc); | |
177 | break; | 177 | break; | |
178 | case IFM_1000_T: | 178 | case IFM_1000_T: | |
179 | speed = BMCR_S1000; | 179 | speed = BMCR_S1000; | |
180 | goto setit; | 180 | goto setit; | |
181 | case IFM_100_TX: | 181 | case IFM_100_TX: | |
182 | speed = BMCR_S100; | 182 | speed = BMCR_S100; | |
183 | goto setit; | 183 | goto setit; | |
184 | case IFM_10_T: | 184 | case IFM_10_T: | |
185 | speed = BMCR_S10; | 185 | speed = BMCR_S10; | |
186 | setit: | 186 | setit: | |
187 | if ((ife->ifm_media & IFM_FDX) != 0) { | 187 | if ((ife->ifm_media & IFM_FDX) != 0) { | |
188 | speed |= BMCR_FDX; | 188 | speed |= BMCR_FDX; | |
189 | gig = GTCR_ADV_1000TFDX; | 189 | gig = GTCR_ADV_1000TFDX; | |
@@ -263,27 +263,27 @@ setit: | @@ -263,27 +263,27 @@ setit: | |||
263 | 263 | |||
264 | /* | 264 | /* | |
265 | * mii_ticks == 0 means it's the first tick after changing the | 265 | * mii_ticks == 0 means it's the first tick after changing the | |
266 | * media or the link became down since the last tick | 266 | * media or the link became down since the last tick | |
267 | * (see above), so return with 0 to update the status. | 267 | * (see above), so return with 0 to update the status. | |
268 | */ | 268 | */ | |
269 | if (sc->mii_ticks++ == 0) | 269 | if (sc->mii_ticks++ == 0) | |
270 | break; | 270 | break; | |
271 | 271 | |||
272 | /* Only retry autonegotiation every N seconds. */ | 272 | /* Only retry autonegotiation every N seconds. */ | |
273 | if (sc->mii_ticks <= sc->mii_anegticks) | 273 | if (sc->mii_ticks <= sc->mii_anegticks) | |
274 | break; | 274 | break; | |
275 | 275 | |||
276 | mii_phy_auto(sc, 0); | 276 | mii_phy_auto(sc); | |
277 | return 0; | 277 | return 0; | |
278 | } | 278 | } | |
279 | 279 | |||
280 | /* Update the media status. */ | 280 | /* Update the media status. */ | |
281 | ciphy_status(sc); | 281 | ciphy_status(sc); | |
282 | 282 | |||
283 | /* | 283 | /* | |
284 | * Callback if something changed. Note that we need to poke | 284 | * Callback if something changed. Note that we need to poke | |
285 | * apply fixups for certain PHY revs. | 285 | * apply fixups for certain PHY revs. | |
286 | */ | 286 | */ | |
287 | if (sc->mii_media_active != mii->mii_media_active || | 287 | if (sc->mii_media_active != mii->mii_media_active || | |
288 | sc->mii_media_status != mii->mii_media_status || | 288 | sc->mii_media_status != mii->mii_media_status || | |
289 | cmd == MII_MEDIACHG) { | 289 | cmd == MII_MEDIACHG) { |
--- src/sys/dev/mii/igphy.c 2020/03/15 23:04:50 1.33
+++ src/sys/dev/mii/igphy.c 2020/07/07 08:44:12 1.34
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: igphy.c,v 1.33 2020/03/15 23:04:50 thorpej Exp $ */ | 1 | /* $NetBSD: igphy.c,v 1.34 2020/07/07 08:44:12 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * The Intel copyright applies to the analog register setup, and the | 4 | * The Intel copyright applies to the analog register setup, and the | |
5 | * SmartSpeed workaround code. | 5 | * SmartSpeed workaround code. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | /******************************************************************************* | 8 | /******************************************************************************* | |
9 | 9 | |||
10 | Copyright (c) 2001-2003, Intel Corporation | 10 | Copyright (c) 2001-2003, Intel Corporation | |
11 | All rights reserved. | 11 | All rights reserved. | |
12 | 12 | |||
13 | Redistribution and use in source and binary forms, with or without | 13 | Redistribution and use in source and binary forms, with or without | |
14 | modification, are permitted provided that the following conditions are met: | 14 | modification, are permitted provided that the following conditions are met: | |
@@ -60,27 +60,27 @@ | @@ -60,27 +60,27 @@ | |||
60 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 60 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
61 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 61 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
62 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 62 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
63 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 63 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
64 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 64 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
65 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 65 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
66 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 66 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
67 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 67 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
68 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 68 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
69 | * POSSIBILITY OF SUCH DAMAGE. | 69 | * POSSIBILITY OF SUCH DAMAGE. | |
70 | */ | 70 | */ | |
71 | 71 | |||
72 | #include <sys/cdefs.h> | 72 | #include <sys/cdefs.h> | |
73 | __KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.33 2020/03/15 23:04:50 thorpej Exp $"); | 73 | __KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.34 2020/07/07 08:44:12 msaitoh Exp $"); | |
74 | 74 | |||
75 | #ifdef _KERNEL_OPT | 75 | #ifdef _KERNEL_OPT | |
76 | #include "opt_mii.h" | 76 | #include "opt_mii.h" | |
77 | #endif | 77 | #endif | |
78 | 78 | |||
79 | #include <sys/param.h> | 79 | #include <sys/param.h> | |
80 | #include <sys/systm.h> | 80 | #include <sys/systm.h> | |
81 | #include <sys/kernel.h> | 81 | #include <sys/kernel.h> | |
82 | #include <sys/device.h> | 82 | #include <sys/device.h> | |
83 | #include <sys/socket.h> | 83 | #include <sys/socket.h> | |
84 | #include <sys/errno.h> | 84 | #include <sys/errno.h> | |
85 | 85 | |||
86 | #include <net/if.h> | 86 | #include <net/if.h> | |
@@ -513,30 +513,30 @@ igphy_smartspeed_workaround(struct mii_s | @@ -513,30 +513,30 @@ igphy_smartspeed_workaround(struct mii_s | |||
513 | if ((reg & BMSR_LINK) == 0) { | 513 | if ((reg & BMSR_LINK) == 0) { | |
514 | switch (igsc->sc_smartspeed) { | 514 | switch (igsc->sc_smartspeed) { | |
515 | case 0: | 515 | case 0: | |
516 | PHY_READ(sc, MII_100T2SR, >sr); | 516 | PHY_READ(sc, MII_100T2SR, >sr); | |
517 | if (!(gtsr & GTSR_MAN_MS_FLT)) | 517 | if (!(gtsr & GTSR_MAN_MS_FLT)) | |
518 | break; | 518 | break; | |
519 | PHY_READ(sc, MII_100T2SR, >sr); | 519 | PHY_READ(sc, MII_100T2SR, >sr); | |
520 | if (gtsr & GTSR_MAN_MS_FLT) { | 520 | if (gtsr & GTSR_MAN_MS_FLT) { | |
521 | PHY_READ(sc, MII_100T2CR, >cr); | 521 | PHY_READ(sc, MII_100T2CR, >cr); | |
522 | if (gtcr & GTCR_MAN_MS) { | 522 | if (gtcr & GTCR_MAN_MS) { | |
523 | gtcr &= ~GTCR_MAN_MS; | 523 | gtcr &= ~GTCR_MAN_MS; | |
524 | PHY_WRITE(sc, MII_100T2CR, gtcr); | 524 | PHY_WRITE(sc, MII_100T2CR, gtcr); | |
525 | } | 525 | } | |
526 | mii_phy_auto(sc, 0); | 526 | mii_phy_auto(sc); | |
527 | } | 527 | } | |
528 | break; | 528 | break; | |
529 | case IGPHY_TICK_DOWNSHIFT: | 529 | case IGPHY_TICK_DOWNSHIFT: | |
530 | PHY_READ(sc, MII_100T2CR, >cr); | 530 | PHY_READ(sc, MII_100T2CR, >cr); | |
531 | gtcr |= GTCR_MAN_MS; | 531 | gtcr |= GTCR_MAN_MS; | |
532 | PHY_WRITE(sc, MII_100T2CR, gtcr); | 532 | PHY_WRITE(sc, MII_100T2CR, gtcr); | |
533 | mii_phy_auto(sc, 0); | 533 | mii_phy_auto(sc); | |
534 | break; | 534 | break; | |
535 | default: | 535 | default: | |
536 | break; | 536 | break; | |
537 | } | 537 | } | |
538 | if (igsc->sc_smartspeed++ == IGPHY_TICK_MAX) | 538 | if (igsc->sc_smartspeed++ == IGPHY_TICK_MAX) | |
539 | igsc->sc_smartspeed = 0; | 539 | igsc->sc_smartspeed = 0; | |
540 | } else | 540 | } else | |
541 | igsc->sc_smartspeed = 0; | 541 | igsc->sc_smartspeed = 0; | |
542 | } | 542 | } |
--- src/sys/dev/mii/mii_physubr.c 2020/03/15 23:04:50 1.90
+++ src/sys/dev/mii/mii_physubr.c 2020/07/07 08:44:12 1.91
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mii_physubr.c,v 1.90 2020/03/15 23:04:50 thorpej Exp $ */ | 1 | /* $NetBSD: mii_physubr.c,v 1.91 2020/07/07 08:44:12 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center. | 9 | * NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 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 | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 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 THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * Subroutines common to all PHYs. | 34 | * Subroutines common to all PHYs. | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.90 2020/03/15 23:04:50 thorpej Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.91 2020/07/07 08:44:12 msaitoh Exp $"); | |
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/device.h> | 41 | #include <sys/device.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/kernel.h> | 43 | #include <sys/kernel.h> | |
44 | #include <sys/socket.h> | 44 | #include <sys/socket.h> | |
45 | #include <sys/errno.h> | 45 | #include <sys/errno.h> | |
46 | #include <sys/module.h> | 46 | #include <sys/module.h> | |
47 | #include <sys/proc.h> | 47 | #include <sys/proc.h> | |
48 | 48 | |||
49 | #include <net/if.h> | 49 | #include <net/if.h> | |
50 | #include <net/if_media.h> | 50 | #include <net/if_media.h> | |
51 | #include <net/route.h> | 51 | #include <net/route.h> | |
@@ -137,27 +137,27 @@ mii_phy_setmedia(struct mii_softc *sc) | @@ -137,27 +137,27 @@ mii_phy_setmedia(struct mii_softc *sc) | |||
137 | KASSERT(mii_locked(mii)); | 137 | KASSERT(mii_locked(mii)); | |
138 | 138 | |||
139 | if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) { | 139 | if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) { | |
140 | /* | 140 | /* | |
141 | * Force renegotiation if MIIF_DOPAUSE. | 141 | * Force renegotiation if MIIF_DOPAUSE. | |
142 | * | 142 | * | |
143 | * XXX This is only necessary because many NICs don't | 143 | * XXX This is only necessary because many NICs don't | |
144 | * XXX advertise PAUSE capabilities at boot time. Maybe | 144 | * XXX advertise PAUSE capabilities at boot time. Maybe | |
145 | * XXX we should force this only once? | 145 | * XXX we should force this only once? | |
146 | */ | 146 | */ | |
147 | PHY_READ(sc, MII_BMCR, &bmcr); | 147 | PHY_READ(sc, MII_BMCR, &bmcr); | |
148 | if ((bmcr & BMCR_AUTOEN) == 0 || | 148 | if ((bmcr & BMCR_AUTOEN) == 0 || | |
149 | (sc->mii_flags & (MIIF_FORCEANEG | MIIF_DOPAUSE))) | 149 | (sc->mii_flags & (MIIF_FORCEANEG | MIIF_DOPAUSE))) | |
150 | (void) mii_phy_auto(sc, 1); | 150 | (void) mii_phy_auto(sc); | |
151 | return; | 151 | return; | |
152 | } | 152 | } | |
153 | 153 | |||
154 | /* Table index is stored in the media entry. */ | 154 | /* Table index is stored in the media entry. */ | |
155 | 155 | |||
156 | #ifdef DIAGNOSTIC | 156 | #ifdef DIAGNOSTIC | |
157 | if (/* ife->ifm_data < 0 || */ ife->ifm_data >= MII_NMEDIA) | 157 | if (/* ife->ifm_data < 0 || */ ife->ifm_data >= MII_NMEDIA) | |
158 | panic("mii_phy_setmedia"); | 158 | panic("mii_phy_setmedia"); | |
159 | #endif | 159 | #endif | |
160 | 160 | |||
161 | anar = mii_media_table[ife->ifm_data].mm_anar; | 161 | anar = mii_media_table[ife->ifm_data].mm_anar; | |
162 | bmcr = mii_media_table[ife->ifm_data].mm_bmcr; | 162 | bmcr = mii_media_table[ife->ifm_data].mm_bmcr; | |
163 | gtcr = mii_media_table[ife->ifm_data].mm_gtcr; | 163 | gtcr = mii_media_table[ife->ifm_data].mm_gtcr; | |
@@ -183,35 +183,34 @@ mii_phy_setmedia(struct mii_softc *sc) | @@ -183,35 +183,34 @@ mii_phy_setmedia(struct mii_softc *sc) | |||
183 | (sc->mii_extcapabilities & | 183 | (sc->mii_extcapabilities & | |
184 | (EXTSR_1000THDX | EXTSR_1000TFDX))) | 184 | (EXTSR_1000THDX | EXTSR_1000TFDX))) | |
185 | anar |= ANAR_PAUSE_ASYM; | 185 | anar |= ANAR_PAUSE_ASYM; | |
186 | } | 186 | } | |
187 | } | 187 | } | |
188 | 188 | |||
189 | if (ife->ifm_media & IFM_LOOP) | 189 | if (ife->ifm_media & IFM_LOOP) | |
190 | bmcr |= BMCR_LOOP; | 190 | bmcr |= BMCR_LOOP; | |
191 | 191 | |||
192 | PHY_WRITE(sc, MII_ANAR, anar); | 192 | PHY_WRITE(sc, MII_ANAR, anar); | |
193 | if (sc->mii_flags & MIIF_HAVE_GTCR) | 193 | if (sc->mii_flags & MIIF_HAVE_GTCR) | |
194 | PHY_WRITE(sc, MII_100T2CR, gtcr); | 194 | PHY_WRITE(sc, MII_100T2CR, gtcr); | |
195 | if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) | 195 | if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) | |
196 | mii_phy_auto(sc, 0); | 196 | mii_phy_auto(sc); | |
197 | else | 197 | else | |
198 | PHY_WRITE(sc, MII_BMCR, bmcr); | 198 | PHY_WRITE(sc, MII_BMCR, bmcr); | |
199 | } | 199 | } | |
200 | 200 | |||
201 | int | 201 | int | |
202 | mii_phy_auto(struct mii_softc *sc, int waitfor) | 202 | mii_phy_auto(struct mii_softc *sc) | |
203 | { | 203 | { | |
204 | int i; | |||
205 | struct mii_data *mii = sc->mii_pdata; | 204 | struct mii_data *mii = sc->mii_pdata; | |
206 | struct ifmedia_entry *ife = mii->mii_media.ifm_cur; | 205 | struct ifmedia_entry *ife = mii->mii_media.ifm_cur; | |
207 | 206 | |||
208 | KASSERT(mii_locked(mii)); | 207 | KASSERT(mii_locked(mii)); | |
209 | 208 | |||
210 | sc->mii_ticks = 0; | 209 | sc->mii_ticks = 0; | |
211 | if ((sc->mii_flags & MIIF_DOINGAUTO) == 0) { | 210 | if ((sc->mii_flags & MIIF_DOINGAUTO) == 0) { | |
212 | /* | 211 | /* | |
213 | * Check for 1000BASE-X. Autonegotiation is a bit | 212 | * Check for 1000BASE-X. Autonegotiation is a bit | |
214 | * different on such devices. | 213 | * different on such devices. | |
215 | */ | 214 | */ | |
216 | if (sc->mii_flags & MIIF_IS_1000X) { | 215 | if (sc->mii_flags & MIIF_IS_1000X) { | |
217 | uint16_t anar = 0; | 216 | uint16_t anar = 0; | |
@@ -256,69 +255,51 @@ mii_phy_auto(struct mii_softc *sc, int w | @@ -256,69 +255,51 @@ mii_phy_auto(struct mii_softc *sc, int w | |||
256 | uint16_t gtcr = 0; | 255 | uint16_t gtcr = 0; | |
257 | 256 | |||
258 | if (sc->mii_extcapabilities & EXTSR_1000TFDX) | 257 | if (sc->mii_extcapabilities & EXTSR_1000TFDX) | |
259 | gtcr |= GTCR_ADV_1000TFDX; | 258 | gtcr |= GTCR_ADV_1000TFDX; | |
260 | if (sc->mii_extcapabilities & EXTSR_1000THDX) | 259 | if (sc->mii_extcapabilities & EXTSR_1000THDX) | |
261 | gtcr |= GTCR_ADV_1000THDX; | 260 | gtcr |= GTCR_ADV_1000THDX; | |
262 | 261 | |||
263 | PHY_WRITE(sc, MII_100T2CR, gtcr); | 262 | PHY_WRITE(sc, MII_100T2CR, gtcr); | |
264 | } | 263 | } | |
265 | } | 264 | } | |
266 | PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG); | 265 | PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG); | |
267 | } | 266 | } | |
268 | 267 | |||
269 | if (waitfor) { | |||
270 | /* Wait 500ms for it to complete. */ | |||
271 | for (i = 0; i < 500; i++) { | |||
272 | uint16_t bmsr; | |||
273 | ||||
274 | PHY_READ(sc, MII_BMSR, &bmsr); | |||
275 | if (bmsr & BMSR_ACOMP) | |||
276 | return 0; | |||
277 | delay(1000); | |||
278 | } | |||
279 | ||||
280 | /* | |||
281 | * Don't need to worry about clearing MIIF_DOINGAUTO. If that's | |||
282 | * set, a timeout is pending, and it will clear the flag. | |||
283 | */ | |||
284 | return EIO; | |||
285 | } | |||
286 | ||||
287 | /* | 268 | /* | |
288 | * Just let it finish asynchronously. This is for the benefit of | 269 | * Just let it finish asynchronously. This is for the benefit of | |
289 | * the tick handler driving autonegotiation. Don't want 500ms | 270 | * the tick handler driving autonegotiation. Don't want 500ms | |
290 | * delays all the time while the system is running! | 271 | * delays all the time while the system is running! | |
291 | */ | 272 | */ | |
292 | if (sc->mii_flags & MIIF_AUTOTSLEEP) { | 273 | if (sc->mii_flags & MIIF_AUTOTSLEEP) { | |
293 | ASSERT_SLEEPABLE(); | 274 | ASSERT_SLEEPABLE(); | |
294 | sc->mii_flags |= MIIF_DOINGAUTO; | 275 | sc->mii_flags |= MIIF_DOINGAUTO; | |
295 | kpause("miiaut", false, hz >> 1, mii->mii_media.ifm_lock); | 276 | kpause("miiaut", false, hz >> 1, mii->mii_media.ifm_lock); | |
296 | mii_phy_auto_timeout_locked(sc); | 277 | mii_phy_auto_timeout_locked(sc); | |
297 | } else if ((sc->mii_flags & MIIF_DOINGAUTO) == 0) { | 278 | } else if ((sc->mii_flags & MIIF_DOINGAUTO) == 0) { | |
298 | sc->mii_flags |= MIIF_DOINGAUTO; | 279 | sc->mii_flags |= MIIF_DOINGAUTO; | |
299 | callout_reset(&sc->mii_nway_ch, hz >> 1, | 280 | callout_reset(&sc->mii_nway_ch, hz >> 1, | |
300 | mii_phy_auto_timeout, sc); | 281 | mii_phy_auto_timeout, sc); | |
301 | } | 282 | } | |
302 | return EJUSTRETURN; | 283 | return EJUSTRETURN; | |
303 | } | 284 | } | |
304 | 285 | |||
305 | static void | 286 | static void | |
306 | mii_phy_auto_timeout_locked(struct mii_softc *sc) | 287 | mii_phy_auto_timeout_locked(struct mii_softc *sc) | |
307 | { | 288 | { | |
308 | 289 | |||
309 | if (!device_is_active(sc->mii_dev)) | 290 | if (!device_is_active(sc->mii_dev)) | |
310 | return; | 291 | return; | |
311 | 292 | |||
312 | sc->mii_flags &= ~MIIF_DOINGAUTO; | 293 | sc->mii_flags &= ~MIIF_DOINGAUTO; | |
313 | 294 | |||
314 | /* Update the media status. */ | 295 | /* Update the media status. */ | |
315 | (void) PHY_SERVICE(sc, sc->mii_pdata, MII_POLLSTAT); | 296 | (void) PHY_SERVICE(sc, sc->mii_pdata, MII_POLLSTAT); | |
316 | } | 297 | } | |
317 | 298 | |||
318 | static void | 299 | static void | |
319 | mii_phy_auto_timeout(void *arg) | 300 | mii_phy_auto_timeout(void *arg) | |
320 | { | 301 | { | |
321 | struct mii_softc *sc = arg; | 302 | struct mii_softc *sc = arg; | |
322 | 303 | |||
323 | if (!device_is_active(sc->mii_dev)) | 304 | if (!device_is_active(sc->mii_dev)) | |
324 | return; | 305 | return; | |
@@ -376,27 +357,27 @@ mii_phy_tick(struct mii_softc *sc) | @@ -376,27 +357,27 @@ mii_phy_tick(struct mii_softc *sc) | |||
376 | */ | 357 | */ | |
377 | if (sc->mii_ticks++ == 0) | 358 | if (sc->mii_ticks++ == 0) | |
378 | return 0; | 359 | return 0; | |
379 | 360 | |||
380 | /* | 361 | /* | |
381 | * Only retry autonegotiation every N seconds. | 362 | * Only retry autonegotiation every N seconds. | |
382 | */ | 363 | */ | |
383 | KASSERT(sc->mii_anegticks != 0); | 364 | KASSERT(sc->mii_anegticks != 0); | |
384 | if (sc->mii_ticks <= sc->mii_anegticks) | 365 | if (sc->mii_ticks <= sc->mii_anegticks) | |
385 | return EJUSTRETURN; | 366 | return EJUSTRETURN; | |
386 | 367 | |||
387 | PHY_RESET(sc); | 368 | PHY_RESET(sc); | |
388 | 369 | |||
389 | if (mii_phy_auto(sc, 0) == EJUSTRETURN) | 370 | if (mii_phy_auto(sc) == EJUSTRETURN) | |
390 | return EJUSTRETURN; | 371 | return EJUSTRETURN; | |
391 | 372 | |||
392 | /* | 373 | /* | |
393 | * Might need to generate a status message if autonegotiation | 374 | * Might need to generate a status message if autonegotiation | |
394 | * failed. | 375 | * failed. | |
395 | */ | 376 | */ | |
396 | return 0; | 377 | return 0; | |
397 | } | 378 | } | |
398 | 379 | |||
399 | void | 380 | void | |
400 | mii_phy_reset(struct mii_softc *sc) | 381 | mii_phy_reset(struct mii_softc *sc) | |
401 | { | 382 | { | |
402 | int i; | 383 | int i; |
--- src/sys/dev/mii/miivar.h 2020/05/25 19:47:58 1.71
+++ src/sys/dev/mii/miivar.h 2020/07/07 08:44:12 1.72
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: miivar.h,v 1.71 2020/05/25 19:47:58 jmcneill Exp $ */ | 1 | /* $NetBSD: miivar.h,v 1.72 2020/07/07 08:44:12 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 1999, 2000, 2001, 2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 1999, 2000, 2001, 2020 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center. | 9 | * NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -321,27 +321,27 @@ uint16_t mii_anar(struct ifmedia_entry * | @@ -321,27 +321,27 @@ uint16_t mii_anar(struct ifmedia_entry * | |||
321 | int mii_phy_activate(device_t, enum devact); | 321 | int mii_phy_activate(device_t, enum devact); | |
322 | int mii_phy_detach(device_t, int); | 322 | int mii_phy_detach(device_t, int); | |
323 | bool mii_phy_resume(device_t, const pmf_qual_t *); | 323 | bool mii_phy_resume(device_t, const pmf_qual_t *); | |
324 | 324 | |||
325 | const struct mii_phydesc *mii_phy_match(const struct mii_attach_args *, | 325 | const struct mii_phydesc *mii_phy_match(const struct mii_attach_args *, | |
326 | const struct mii_phydesc *); | 326 | const struct mii_phydesc *); | |
327 | 327 | |||
328 | /* MII must be UNLOCKED */ | 328 | /* MII must be UNLOCKED */ | |
329 | void mii_phy_add_media(struct mii_softc *); | 329 | void mii_phy_add_media(struct mii_softc *); | |
330 | void mii_phy_delete_media(struct mii_softc *); | 330 | void mii_phy_delete_media(struct mii_softc *); | |
331 | 331 | |||
332 | /* MII must be LOCKED */ | 332 | /* MII must be LOCKED */ | |
333 | void mii_phy_setmedia(struct mii_softc *); | 333 | void mii_phy_setmedia(struct mii_softc *); | |
334 | int mii_phy_auto(struct mii_softc *, int); | 334 | int mii_phy_auto(struct mii_softc *); | |
335 | void mii_phy_reset(struct mii_softc *); | 335 | void mii_phy_reset(struct mii_softc *); | |
336 | void mii_phy_down(struct mii_softc *); | 336 | void mii_phy_down(struct mii_softc *); | |
337 | int mii_phy_tick(struct mii_softc *); | 337 | int mii_phy_tick(struct mii_softc *); | |
338 | 338 | |||
339 | /* MII must be LOCKED */ | 339 | /* MII must be LOCKED */ | |
340 | void mii_phy_status(struct mii_softc *); | 340 | void mii_phy_status(struct mii_softc *); | |
341 | void mii_phy_update(struct mii_softc *, int); | 341 | void mii_phy_update(struct mii_softc *, int); | |
342 | 342 | |||
343 | /* MII must be LOCKED */ | 343 | /* MII must be LOCKED */ | |
344 | u_int mii_phy_flowstatus(struct mii_softc *); | 344 | u_int mii_phy_flowstatus(struct mii_softc *); | |
345 | 345 | |||
346 | /* MII must be LOCKED */ | 346 | /* MII must be LOCKED */ | |
347 | void ukphy_status(struct mii_softc *); | 347 | void ukphy_status(struct mii_softc *); |
--- src/sys/dev/mii/tlphy.c 2020/07/07 08:35:16 1.70
+++ src/sys/dev/mii/tlphy.c 2020/07/07 08:44:12 1.71
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tlphy.c,v 1.70 2020/07/07 08:35:16 msaitoh Exp $ */ | 1 | /* $NetBSD: tlphy.c,v 1.71 2020/07/07 08:44:12 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center. | 9 | * NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -49,27 +49,27 @@ | @@ -49,27 +49,27 @@ | |||
49 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 49 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
50 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 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 | 51 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
52 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 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 | 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. | 54 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
55 | */ | 55 | */ | |
56 | 56 | |||
57 | /* | 57 | /* | |
58 | * Driver for Texas Instruments's ThunderLAN PHYs | 58 | * Driver for Texas Instruments's ThunderLAN PHYs | |
59 | */ | 59 | */ | |
60 | 60 | |||
61 | #include <sys/cdefs.h> | 61 | #include <sys/cdefs.h> | |
62 | __KERNEL_RCSID(0, "$NetBSD: tlphy.c,v 1.70 2020/07/07 08:35:16 msaitoh Exp $"); | 62 | __KERNEL_RCSID(0, "$NetBSD: tlphy.c,v 1.71 2020/07/07 08:44:12 msaitoh Exp $"); | |
63 | 63 | |||
64 | #include <sys/param.h> | 64 | #include <sys/param.h> | |
65 | #include <sys/systm.h> | 65 | #include <sys/systm.h> | |
66 | #include <sys/kernel.h> | 66 | #include <sys/kernel.h> | |
67 | #include <sys/device.h> | 67 | #include <sys/device.h> | |
68 | #include <sys/socket.h> | 68 | #include <sys/socket.h> | |
69 | #include <sys/errno.h> | 69 | #include <sys/errno.h> | |
70 | 70 | |||
71 | #include <sys/bus.h> | 71 | #include <sys/bus.h> | |
72 | 72 | |||
73 | #include <net/if.h> | 73 | #include <net/if.h> | |
74 | #include <net/if_media.h> | 74 | #include <net/if_media.h> | |
75 | 75 | |||
@@ -357,35 +357,27 @@ tlphy_status(struct mii_softc *sc) | @@ -357,35 +357,27 @@ tlphy_status(struct mii_softc *sc) | |||
357 | if (bmcr & BMCR_FDX) | 357 | if (bmcr & BMCR_FDX) | |
358 | mii->mii_media_active |= IFM_FDX; | 358 | mii->mii_media_active |= IFM_FDX; | |
359 | else | 359 | else | |
360 | mii->mii_media_active |= IFM_HDX; | 360 | mii->mii_media_active |= IFM_HDX; | |
361 | mii->mii_media_active |= IFM_10_T; | 361 | mii->mii_media_active |= IFM_10_T; | |
362 | } | 362 | } | |
363 | 363 | |||
364 | static int | 364 | static int | |
365 | tlphy_auto(struct tlphy_softc *tsc) | 365 | tlphy_auto(struct tlphy_softc *tsc) | |
366 | { | 366 | { | |
367 | struct mii_softc *sc = &tsc->sc_mii; | 367 | struct mii_softc *sc = &tsc->sc_mii; | |
368 | int error; | 368 | int error; | |
369 | 369 | |||
370 | switch ((error = mii_phy_auto(sc, 0))) { | 370 | switch ((error = mii_phy_auto(sc))) { | |
371 | case EIO: | |||
372 | /* | |||
373 | * Just assume we're not in full-duplex mode. | |||
374 | * XXX Check link and try AUI/BNC? | |||
375 | */ | |||
376 | PHY_WRITE(sc, MII_BMCR, 0); | |||
377 | break; | |||
378 | ||||
379 | case EJUSTRETURN: | 371 | case EJUSTRETURN: | |
380 | /* Flag that we need to program when it completes. */ | 372 | /* Flag that we need to program when it completes. */ | |
381 | tsc->sc_need_acomp = 1; | 373 | tsc->sc_need_acomp = 1; | |
382 | break; | 374 | break; | |
383 | 375 | |||
384 | default: | 376 | default: | |
385 | tlphy_acomp(tsc); | 377 | tlphy_acomp(tsc); | |
386 | } | 378 | } | |
387 | 379 | |||
388 | return error; | 380 | return error; | |
389 | } | 381 | } | |
390 | 382 | |||
391 | static void | 383 | static void |
--- src/sys/dev/mii/urlphy.c 2019/11/27 10:19:21 1.35
+++ src/sys/dev/mii/urlphy.c 2020/07/07 08:44:12 1.36
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: urlphy.c,v 1.35 2019/11/27 10:19:21 msaitoh Exp $ */ | 1 | /* $NetBSD: urlphy.c,v 1.36 2020/07/07 08:44:12 msaitoh Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 2001, 2002 | 3 | * Copyright (c) 2001, 2002 | |
4 | * Shingo WATANABE <nabe@nabechan.org>. All rights reserved. | 4 | * Shingo WATANABE <nabe@nabechan.org>. All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. Neither the name of the author nor the names of any co-contributors | 14 | * 3. Neither the name of the author nor the names of any co-contributors | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
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 Realtek RL8150L internal phy | 33 | * driver for Realtek RL8150L internal phy | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: urlphy.c,v 1.35 2019/11/27 10:19:21 msaitoh Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: urlphy.c,v 1.36 2020/07/07 08:44:12 msaitoh Exp $"); | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/kernel.h> | 41 | #include <sys/kernel.h> | |
42 | #include <sys/device.h> | 42 | #include <sys/device.h> | |
43 | #include <sys/socket.h> | 43 | #include <sys/socket.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> | |
50 | #include <dev/mii/miidevs.h> | 50 | #include <dev/mii/miidevs.h> | |
@@ -189,27 +189,27 @@ urlphy_service(struct mii_softc *sc, str | @@ -189,27 +189,27 @@ urlphy_service(struct mii_softc *sc, str | |||
189 | * media or the link became down since the last tick (see | 189 | * media or the link became down since the last tick (see | |
190 | * above), so break to update the status. | 190 | * above), so break to update the status. | |
191 | */ | 191 | */ | |
192 | if (sc->mii_ticks++ == 0) | 192 | if (sc->mii_ticks++ == 0) | |
193 | break; | 193 | break; | |
194 | 194 | |||
195 | /* Only retry autonegotiation every N seconds. */ | 195 | /* Only retry autonegotiation every N seconds. */ | |
196 | KASSERT(sc->mii_anegticks != 0); | 196 | KASSERT(sc->mii_anegticks != 0); | |
197 | if (sc->mii_ticks <= sc->mii_anegticks) | 197 | if (sc->mii_ticks <= sc->mii_anegticks) | |
198 | return 0; | 198 | return 0; | |
199 | 199 | |||
200 | PHY_RESET(sc); | 200 | PHY_RESET(sc); | |
201 | 201 | |||
202 | if (mii_phy_auto(sc, 0) == EJUSTRETURN) | 202 | if (mii_phy_auto(sc) == EJUSTRETURN) | |
203 | return 0; | 203 | return 0; | |
204 | 204 | |||
205 | break; | 205 | break; | |
206 | 206 | |||
207 | case MII_DOWN: | 207 | case MII_DOWN: | |
208 | mii_phy_down(sc); | 208 | mii_phy_down(sc); | |
209 | return 0; | 209 | return 0; | |
210 | } | 210 | } | |
211 | 211 | |||
212 | /* Update the media status. */ | 212 | /* Update the media status. */ | |
213 | mii_phy_status(sc); | 213 | mii_phy_status(sc); | |
214 | 214 | |||
215 | /* Callback if something changed. */ | 215 | /* Callback if something changed. */ |