Thu Nov 21 09:48:57 2019 UTC ()
 Whitespace.


(msaitoh)
diff -r1.33 -r1.34 src/sys/dev/mii/gphyter.c
diff -r1.5 -r1.6 src/sys/dev/mii/ipgphy.c

cvs diff -r1.33 -r1.34 src/sys/dev/mii/gphyter.c (expand / switch to unified diff)

--- src/sys/dev/mii/gphyter.c 2019/03/25 07:34:13 1.33
+++ src/sys/dev/mii/gphyter.c 2019/11/21 09:48:57 1.34
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: gphyter.c,v 1.33 2019/03/25 07:34:13 msaitoh Exp $ */ 1/* $NetBSD: gphyter.c,v 1.34 2019/11/21 09:48:57 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
@@ -56,27 +56,27 @@ @@ -56,27 +56,27 @@
56 56
57/* 57/*
58 * driver for National Semiconductor's DP83891, DP83861 and DP83865 58 * driver for National Semiconductor's DP83891, DP83861 and DP83865
59 * `Gig PHYTER' ethernet 10/100/1000 PHYs. The DP83891 is an older, 59 * `Gig PHYTER' ethernet 10/100/1000 PHYs. The DP83891 is an older,
60 * non-firmware-driven version of the DP83861. The DP83865 is a low 60 * non-firmware-driven version of the DP83861. The DP83865 is a low
61 * power version of the DP83861. 61 * power version of the DP83861.
62 * 62 *
63 * Data Sheets available from www.national.com: 63 * Data Sheets available from www.national.com:
64 * http://www.national.com/ds/DP/DP83861.pdf 64 * http://www.national.com/ds/DP/DP83861.pdf
65 * http://www.national.com/ds/DP/DP83865.pdf 65 * http://www.national.com/ds/DP/DP83865.pdf
66 */ 66 */
67 67
68#include <sys/cdefs.h> 68#include <sys/cdefs.h>
69__KERNEL_RCSID(0, "$NetBSD: gphyter.c,v 1.33 2019/03/25 07:34:13 msaitoh Exp $"); 69__KERNEL_RCSID(0, "$NetBSD: gphyter.c,v 1.34 2019/11/21 09:48:57 msaitoh Exp $");
70 70
71#include <sys/param.h> 71#include <sys/param.h>
72#include <sys/systm.h> 72#include <sys/systm.h>
73#include <sys/kernel.h> 73#include <sys/kernel.h>
74#include <sys/device.h> 74#include <sys/device.h>
75#include <sys/socket.h> 75#include <sys/socket.h>
76#include <sys/errno.h> 76#include <sys/errno.h>
77 77
78#include <net/if.h> 78#include <net/if.h>
79#include <net/if_media.h> 79#include <net/if_media.h>
80 80
81#include <dev/mii/mii.h> 81#include <dev/mii/mii.h>
82#include <dev/mii/miivar.h> 82#include <dev/mii/miivar.h>
@@ -254,27 +254,27 @@ gphyter_status(struct mii_softc *sc) @@ -254,27 +254,27 @@ gphyter_status(struct mii_softc *sc)
254 mii->mii_media_active |= IFM_LOOP; 254 mii->mii_media_active |= IFM_LOOP;
255 255
256 if (bmcr & BMCR_AUTOEN) { 256 if (bmcr & BMCR_AUTOEN) {
257 /* 257 /*
258 * The media status bits are only valid of autonegotiation 258 * The media status bits are only valid of autonegotiation
259 * has completed (or it's disabled). 259 * has completed (or it's disabled).
260 */ 260 */
261 if ((bmsr & BMSR_ACOMP) == 0) { 261 if ((bmsr & BMSR_ACOMP) == 0) {
262 /* Erg, still trying, I guess... */ 262 /* Erg, still trying, I guess... */
263 mii->mii_media_active |= IFM_NONE; 263 mii->mii_media_active |= IFM_NONE;
264 return; 264 return;
265 } 265 }
266 266
267 switch (physup & (PHY_SUP_SPEED1|PHY_SUP_SPEED0)) { 267 switch (physup & (PHY_SUP_SPEED1 | PHY_SUP_SPEED0)) {
268 case PHY_SUP_SPEED1: 268 case PHY_SUP_SPEED1:
269 mii->mii_media_active |= IFM_1000_T; 269 mii->mii_media_active |= IFM_1000_T;
270 PHY_READ(sc, MII_100T2SR, &gtsr); 270 PHY_READ(sc, MII_100T2SR, &gtsr);
271 if (gtsr & GTSR_MS_RES) 271 if (gtsr & GTSR_MS_RES)
272 mii->mii_media_active |= IFM_ETH_MASTER; 272 mii->mii_media_active |= IFM_ETH_MASTER;
273 break; 273 break;
274 274
275 case PHY_SUP_SPEED0: 275 case PHY_SUP_SPEED0:
276 mii->mii_media_active |= IFM_100_TX; 276 mii->mii_media_active |= IFM_100_TX;
277 break; 277 break;
278 278
279 case 0: 279 case 0:
280 mii->mii_media_active |= IFM_10_T; 280 mii->mii_media_active |= IFM_10_T;

cvs diff -r1.5 -r1.6 src/sys/dev/mii/ipgphy.c (expand / switch to unified diff)

--- src/sys/dev/mii/ipgphy.c 2019/11/21 03:04:21 1.5
+++ src/sys/dev/mii/ipgphy.c 2019/11/21 09:48:57 1.6
@@ -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
126static int 126static int
127ipgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) 127ipgphy_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