| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: tlphy.c,v 1.68 2020/03/15 23:04:50 thorpej Exp $ */ | | 1 | /* $NetBSD: tlphy.c,v 1.69 2020/07/07 06:59:22 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.68 2020/03/15 23:04:50 thorpej Exp $"); | | 62 | __KERNEL_RCSID(0, "$NetBSD: tlphy.c,v 1.69 2020/07/07 06:59:22 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 | |
| @@ -154,50 +154,52 @@ tlphyattach(device_t parent, device_t se | | | @@ -154,50 +154,52 @@ tlphyattach(device_t parent, device_t se |
154 | * be another PHY on the MII wired up to the UTP connector. The parent | | 154 | * be another PHY on the MII wired up to the UTP connector. The parent |
155 | * indicates this to us by specifying the TLPHY_MEDIA_NO_10_T bit. | | 155 | * indicates this to us by specifying the TLPHY_MEDIA_NO_10_T bit. |
156 | */ | | 156 | */ |
157 | tsc->sc_tlphycap = tlsc->tl_product->tp_tlphymedia; | | 157 | tsc->sc_tlphycap = tlsc->tl_product->tp_tlphymedia; |
158 | if ((tsc->sc_tlphycap & TLPHY_MEDIA_NO_10_T) == 0) { | | 158 | if ((tsc->sc_tlphycap & TLPHY_MEDIA_NO_10_T) == 0) { |
159 | PHY_READ(sc, MII_BMSR, &sc->mii_capabilities); | | 159 | PHY_READ(sc, MII_BMSR, &sc->mii_capabilities); |
160 | sc->mii_capabilities &= ma->mii_capmask; | | 160 | sc->mii_capabilities &= ma->mii_capmask; |
161 | } else | | 161 | } else |
162 | sc->mii_capabilities = 0; | | 162 | sc->mii_capabilities = 0; |
163 | | | 163 | |
164 | mii_unlock(mii); | | 164 | mii_unlock(mii); |
165 | | | 165 | |
166 | #define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) | | 166 | #define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) |
167 | #define PRINT(str) aprint_normal("%s%s", sep, str); sep = ", " | | 167 | #define PRINT(str) \ |
| | | 168 | do { \ |
| | | 169 | aprint_normal("%s%s", sep, str); \ |
| | | 170 | sep = ", "; \ |
| | | 171 | } while (/* CONSTCOND */0) |
168 | | | 172 | |
169 | if (tsc->sc_tlphycap) { | | 173 | if (tsc->sc_tlphycap) { |
170 | mii_lock(mii); | | 174 | mii_lock(mii); |
171 | sc->mii_anegticks = MII_ANEGTICKS; | | 175 | sc->mii_anegticks = MII_ANEGTICKS; |
172 | mii_unlock(mii); | | 176 | mii_unlock(mii); |
173 | aprint_normal_dev(self, ""); | | 177 | aprint_normal_dev(self, ""); |
174 | if (tsc->sc_tlphycap & TLPHY_MEDIA_10_2) { | | 178 | if (tsc->sc_tlphycap & TLPHY_MEDIA_10_2) { |
175 | ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_2, 0, sc->mii_inst), | | 179 | ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_2, 0, sc->mii_inst), |
176 | 0); | | 180 | 0); |
177 | PRINT("10base2"); | | 181 | PRINT("10base2"); |
178 | } else if (tsc->sc_tlphycap & TLPHY_MEDIA_10_5) { | | 182 | } else if (tsc->sc_tlphycap & TLPHY_MEDIA_10_5) { |
179 | ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_5, 0, sc->mii_inst), | | 183 | ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_5, 0, sc->mii_inst), |
180 | 0); | | 184 | 0); |
181 | PRINT("10base5"); | | 185 | PRINT("10base5"); |
182 | } | | 186 | } else |
| | | 187 | PRINT("no media present"); |
183 | aprint_normal("\n"); | | 188 | aprint_normal("\n"); |
184 | } | | 189 | } |
185 | if (sc->mii_capabilities & BMSR_MEDIAMASK) | | 190 | if (sc->mii_capabilities & BMSR_MEDIAMASK) |
186 | mii_phy_add_media(sc); | | 191 | mii_phy_add_media(sc); |
187 | else { | | 192 | else { |
188 | if ((tsc->sc_tlphycap & | | | |
189 | (TLPHY_MEDIA_10_2 | TLPHY_MEDIA_10_5)) == 0) | | | |
190 | aprint_error_dev(self, "no media present\n"); | | | |
191 | /* | | 193 | /* |
192 | * mii_phy_add_media() automatically install power handler, | | 194 | * mii_phy_add_media() automatically install power handler, |
193 | * but if_media_add() doesn't. Do it now. | | 195 | * but if_media_add() doesn't. Do it now. |
194 | */ | | 196 | */ |
195 | if (!pmf_device_register(self, NULL, mii_phy_resume)) { | | 197 | if (!pmf_device_register(self, NULL, mii_phy_resume)) { |
196 | aprint_error_dev(self, | | 198 | aprint_error_dev(self, |
197 | "couldn't establish power handler\n"); | | 199 | "couldn't establish power handler\n"); |
198 | } | | 200 | } |
199 | } | | 201 | } |
200 | #undef ADD | | 202 | #undef ADD |
201 | #undef PRINT | | 203 | #undef PRINT |
202 | } | | 204 | } |
203 | | | 205 | |