| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_msk.c,v 1.113 2020/05/11 23:47:45 jakllsch Exp $ */ | | 1 | /* $NetBSD: if_msk.c,v 1.114 2020/10/04 16:23:04 jakllsch Exp $ */ |
2 | /* $OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $ */ | | 2 | /* $OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 1997, 1998, 1999, 2000 | | 5 | * Copyright (c) 1997, 1998, 1999, 2000 |
6 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | | 6 | * Bill Paul <wpaul@ctr.columbia.edu>. 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, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -42,27 +42,27 @@ | | | @@ -42,27 +42,27 @@ |
42 | * purpose with or without fee is hereby granted, provided that the above | | 42 | * purpose with or without fee is hereby granted, provided that the above |
43 | * copyright notice and this permission notice appear in all copies. | | 43 | * copyright notice and this permission notice appear in all copies. |
44 | * | | 44 | * |
45 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 45 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
46 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 46 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
47 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 47 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
48 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 48 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
49 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 49 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
50 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 50 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
51 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 51 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
52 | */ | | 52 | */ |
53 | | | 53 | |
54 | #include <sys/cdefs.h> | | 54 | #include <sys/cdefs.h> |
55 | __KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.113 2020/05/11 23:47:45 jakllsch Exp $"); | | 55 | __KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.114 2020/10/04 16:23:04 jakllsch Exp $"); |
56 | | | 56 | |
57 | #include <sys/param.h> | | 57 | #include <sys/param.h> |
58 | #include <sys/systm.h> | | 58 | #include <sys/systm.h> |
59 | #include <sys/sockio.h> | | 59 | #include <sys/sockio.h> |
60 | #include <sys/mbuf.h> | | 60 | #include <sys/mbuf.h> |
61 | #include <sys/malloc.h> | | 61 | #include <sys/malloc.h> |
62 | #include <sys/mutex.h> | | 62 | #include <sys/mutex.h> |
63 | #include <sys/kernel.h> | | 63 | #include <sys/kernel.h> |
64 | #include <sys/socket.h> | | 64 | #include <sys/socket.h> |
65 | #include <sys/device.h> | | 65 | #include <sys/device.h> |
66 | #include <sys/queue.h> | | 66 | #include <sys/queue.h> |
67 | #include <sys/callout.h> | | 67 | #include <sys/callout.h> |
68 | #include <sys/sysctl.h> | | 68 | #include <sys/sysctl.h> |
| @@ -245,27 +245,27 @@ msk_miibus_readreg(device_t dev, int phy | | | @@ -245,27 +245,27 @@ msk_miibus_readreg(device_t dev, int phy |
245 | int i; | | 245 | int i; |
246 | | | 246 | |
247 | SK_YU_WRITE_2(sc_if, YUKON_SMICR, YU_SMICR_PHYAD(phy) | | | 247 | SK_YU_WRITE_2(sc_if, YUKON_SMICR, YU_SMICR_PHYAD(phy) | |
248 | YU_SMICR_REGAD(reg) | YU_SMICR_OP_READ); | | 248 | YU_SMICR_REGAD(reg) | YU_SMICR_OP_READ); |
249 | | | 249 | |
250 | for (i = 0; i < SK_TIMEOUT; i++) { | | 250 | for (i = 0; i < SK_TIMEOUT; i++) { |
251 | DELAY(1); | | 251 | DELAY(1); |
252 | data = SK_YU_READ_2(sc_if, YUKON_SMICR); | | 252 | data = SK_YU_READ_2(sc_if, YUKON_SMICR); |
253 | if (data & YU_SMICR_READ_VALID) | | 253 | if (data & YU_SMICR_READ_VALID) |
254 | break; | | 254 | break; |
255 | } | | 255 | } |
256 | | | 256 | |
257 | if (i == SK_TIMEOUT) { | | 257 | if (i == SK_TIMEOUT) { |
258 | aprint_error_dev(sc_if->sk_dev, "phy failed to come ready\n"); | | 258 | device_printf(sc_if->sk_dev, "phy failed to come ready\n"); |
259 | return ETIMEDOUT; | | 259 | return ETIMEDOUT; |
260 | } | | 260 | } |
261 | | | 261 | |
262 | DPRINTFN(9, ("msk_miibus_readreg: i=%d, timeout=%d\n", i, SK_TIMEOUT)); | | 262 | DPRINTFN(9, ("msk_miibus_readreg: i=%d, timeout=%d\n", i, SK_TIMEOUT)); |
263 | | | 263 | |
264 | *val = SK_YU_READ_2(sc_if, YUKON_SMIDR); | | 264 | *val = SK_YU_READ_2(sc_if, YUKON_SMIDR); |
265 | | | 265 | |
266 | DPRINTFN(9, ("msk_miibus_readreg phy=%d, reg=%#x, val=%#hx\n", | | 266 | DPRINTFN(9, ("msk_miibus_readreg phy=%d, reg=%#x, val=%#hx\n", |
267 | phy, reg, *val)); | | 267 | phy, reg, *val)); |
268 | | | 268 | |
269 | return 0; | | 269 | return 0; |
270 | } | | 270 | } |
271 | | | 271 | |
| @@ -279,27 +279,27 @@ msk_miibus_writereg(device_t dev, int ph | | | @@ -279,27 +279,27 @@ msk_miibus_writereg(device_t dev, int ph |
279 | phy, reg, val)); | | 279 | phy, reg, val)); |
280 | | | 280 | |
281 | SK_YU_WRITE_2(sc_if, YUKON_SMIDR, val); | | 281 | SK_YU_WRITE_2(sc_if, YUKON_SMIDR, val); |
282 | SK_YU_WRITE_2(sc_if, YUKON_SMICR, YU_SMICR_PHYAD(phy) | | | 282 | SK_YU_WRITE_2(sc_if, YUKON_SMICR, YU_SMICR_PHYAD(phy) | |
283 | YU_SMICR_REGAD(reg) | YU_SMICR_OP_WRITE); | | 283 | YU_SMICR_REGAD(reg) | YU_SMICR_OP_WRITE); |
284 | | | 284 | |
285 | for (i = 0; i < SK_TIMEOUT; i++) { | | 285 | for (i = 0; i < SK_TIMEOUT; i++) { |
286 | DELAY(1); | | 286 | DELAY(1); |
287 | if (!(SK_YU_READ_2(sc_if, YUKON_SMICR) & YU_SMICR_BUSY)) | | 287 | if (!(SK_YU_READ_2(sc_if, YUKON_SMICR) & YU_SMICR_BUSY)) |
288 | break; | | 288 | break; |
289 | } | | 289 | } |
290 | | | 290 | |
291 | if (i == SK_TIMEOUT) { | | 291 | if (i == SK_TIMEOUT) { |
292 | aprint_error_dev(sc_if->sk_dev, "phy write timed out\n"); | | 292 | device_printf(sc_if->sk_dev, "phy write timed out\n"); |
293 | return ETIMEDOUT; | | 293 | return ETIMEDOUT; |
294 | } | | 294 | } |
295 | | | 295 | |
296 | return 0; | | 296 | return 0; |
297 | } | | 297 | } |
298 | | | 298 | |
299 | static void | | 299 | static void |
300 | msk_miibus_statchg(struct ifnet *ifp) | | 300 | msk_miibus_statchg(struct ifnet *ifp) |
301 | { | | 301 | { |
302 | struct sk_if_softc *sc_if = ifp->if_softc; | | 302 | struct sk_if_softc *sc_if = ifp->if_softc; |
303 | struct mii_data *mii = &sc_if->sk_mii; | | 303 | struct mii_data *mii = &sc_if->sk_mii; |
304 | struct ifmedia_entry *ife = mii->mii_media.ifm_cur; | | 304 | struct ifmedia_entry *ife = mii->mii_media.ifm_cur; |
305 | int gpcr; | | 305 | int gpcr; |
| @@ -2025,27 +2025,27 @@ msk_start(struct ifnet *ifp) | | | @@ -2025,27 +2025,27 @@ msk_start(struct ifnet *ifp) |
2025 | } | | 2025 | } |
2026 | | | 2026 | |
2027 | static void | | 2027 | static void |
2028 | msk_watchdog(struct ifnet *ifp) | | 2028 | msk_watchdog(struct ifnet *ifp) |
2029 | { | | 2029 | { |
2030 | struct sk_if_softc *sc_if = ifp->if_softc; | | 2030 | struct sk_if_softc *sc_if = ifp->if_softc; |
2031 | | | 2031 | |
2032 | /* | | 2032 | /* |
2033 | * Reclaim first as there is a possibility of losing Tx completion | | 2033 | * Reclaim first as there is a possibility of losing Tx completion |
2034 | * interrupts. | | 2034 | * interrupts. |
2035 | */ | | 2035 | */ |
2036 | msk_txeof(sc_if); | | 2036 | msk_txeof(sc_if); |
2037 | if (sc_if->sk_cdata.sk_tx_cnt != 0) { | | 2037 | if (sc_if->sk_cdata.sk_tx_cnt != 0) { |
2038 | aprint_error_dev(sc_if->sk_dev, "watchdog timeout\n"); | | 2038 | device_printf(sc_if->sk_dev, "watchdog timeout\n"); |
2039 | | | 2039 | |
2040 | if_statinc(ifp, if_oerrors); | | 2040 | if_statinc(ifp, if_oerrors); |
2041 | | | 2041 | |
2042 | /* XXX Resets both ports; we shouldn't do that. */ | | 2042 | /* XXX Resets both ports; we shouldn't do that. */ |
2043 | mskc_reset(sc_if->sk_softc); | | 2043 | mskc_reset(sc_if->sk_softc); |
2044 | msk_reset(sc_if); | | 2044 | msk_reset(sc_if); |
2045 | msk_init(ifp); | | 2045 | msk_init(ifp); |
2046 | } | | 2046 | } |
2047 | } | | 2047 | } |
2048 | | | 2048 | |
2049 | static bool | | 2049 | static bool |
2050 | mskc_suspend(device_t dv, const pmf_qual_t *qual) | | 2050 | mskc_suspend(device_t dv, const pmf_qual_t *qual) |
2051 | { | | 2051 | { |