diff --git a/sys/dev/mii/igphy.c b/sys/dev/mii/igphy.c index ae013be236db..07be3fcd0fb5 100644 --- a/sys/dev/mii/igphy.c +++ b/sys/dev/mii/igphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: igphy.c,v 1.35 2020/08/03 07:16:51 msaitoh Exp $ */ +/* $NetBSD: igphy.c,v 1.36 2020/08/03 07:25:59 msaitoh Exp $ */ /* * The Intel copyright applies to the analog register setup, and the @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.35 2020/08/03 07:16:51 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.36 2020/08/03 07:25:59 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_mii.h" @@ -431,7 +431,7 @@ igphy_status(struct mii_softc *sc) PHY_READ(sc, IGPHY_PORT_STATUS, &pssr); - if (pssr & PSSR_LINK_UP) + if (pssr & IGPHY_PSSR_LINK_UP) mii->mii_media_status |= IFM_ACTIVE; PHY_READ(sc, MII_BMCR, &bmcr); @@ -453,19 +453,19 @@ igphy_status(struct mii_softc *sc) mii->mii_media_active |= IFM_NONE; return; } - switch (pssr & PSSR_SPEED_MASK) { - case PSSR_SPEED_1000MBPS: + switch (pssr & IGPHY_PSSR_SPEED_MASK) { + case IGPHY_PSSR_SPEED_1000MBPS: mii->mii_media_active |= IFM_1000_T; PHY_READ(sc, MII_100T2SR, >sr); if (gtsr & GTSR_MS_RES) mii->mii_media_active |= IFM_ETH_MASTER; break; - case PSSR_SPEED_100MBPS: + case IGPHY_PSSR_SPEED_100MBPS: mii->mii_media_active |= IFM_100_TX; break; - case PSSR_SPEED_10MBPS: + case IGPHY_PSSR_SPEED_10MBPS: mii->mii_media_active |= IFM_10_T; break; @@ -475,7 +475,7 @@ igphy_status(struct mii_softc *sc) return; } - if (pssr & PSSR_FULL_DUPLEX) + if (pssr & IGPHY_PSSR_FULL_DUPLEX) mii->mii_media_active |= IFM_FDX | mii_phy_flowstatus(sc); else diff --git a/sys/dev/mii/igphyreg.h b/sys/dev/mii/igphyreg.h index ce0b25a31f58..74b4bad7fdb0 100644 --- a/sys/dev/mii/igphyreg.h +++ b/sys/dev/mii/igphyreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: igphyreg.h,v 1.12 2020/08/03 07:16:51 msaitoh Exp $ */ +/* $NetBSD: igphyreg.h,v 1.13 2020/08/03 07:25:59 msaitoh Exp $ */ /******************************************************************************* @@ -53,18 +53,18 @@ /* IGP01E1000 Specific Port Status Register - R/O */ #define IGPHY_PORT_STATUS 0x11 -#define PSSR_AUTONEG_FAILED 0x0001 /* RO LH SC */ -#define PSSR_POLARITY_REVERSED 0x0002 -#define PSSR_CABLE_LENGTH 0x007C -#define PSSR_FULL_DUPLEX 0x0200 -#define PSSR_LINK_UP 0x0400 -#define PSSR_MDIX 0x0800 -#define PSSR_SPEED_MASK 0xC000 /* speed bits mask */ -#define PSSR_SPEED_10MBPS 0x4000 -#define PSSR_SPEED_100MBPS 0x8000 -#define PSSR_SPEED_1000MBPS 0xC000 -#define PSSR_CABLE_LENGTH_SHIFT 0x0002 /* shift right 2 */ -#define PSSR_MDIX_SHIFT 0x000B /* shift right 11 */ +#define IGPHY_PSSR_AUTONEG_FAILED 0x0001 /* RO LH SC */ +#define IGPHY_PSSR_POLARITY_REVERSED 0x0002 +#define IGPHY_PSSR_CABLE_LENGTH 0x007C +#define IGPHY_PSSR_FULL_DUPLEX 0x0200 +#define IGPHY_PSSR_LINK_UP 0x0400 +#define IGPHY_PSSR_MDIX 0x0800 +#define IGPHY_PSSR_SPEED_MASK 0xC000 /* speed bits mask */ +#define IGPHY_PSSR_SPEED_10MBPS 0x4000 +#define IGPHY_PSSR_SPEED_100MBPS 0x8000 +#define IGPHY_PSSR_SPEED_1000MBPS 0xC000 +#define IGPHY_PSSR_CABLE_LENGTH_SHIFT 0x0002 /* shift right 2 */ +#define IGPHY_PSSR_MDIX_SHIFT 0x000B /* shift right 11 */ /* IGP01E1000 Specific Port Control Register - R/W */ #define IGPHY_PORT_CTRL 0x12 diff --git a/sys/dev/mii/makphy.c b/sys/dev/mii/makphy.c index 6e0bb366a935..493996440ae5 100644 --- a/sys/dev/mii/makphy.c +++ b/sys/dev/mii/makphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: makphy.c,v 1.65 2020/03/15 23:04:50 thorpej Exp $ */ +/* $NetBSD: makphy.c,v 1.66 2020/08/03 07:25:59 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.65 2020/03/15 23:04:50 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.66 2020/08/03 07:25:59 msaitoh Exp $"); #include #include @@ -429,7 +429,7 @@ makphy_status(struct mii_softc *sc) /* XXX FIXME: Use different page for Fiber on newer chips */ PHY_READ(sc, MAKPHY_PSSR, &pssr); - if (pssr & PSSR_LINK) + if (pssr & MAKPHY_PSSR_LINK) mii->mii_media_status |= IFM_ACTIVE; if (bmcr & BMCR_LOOP) @@ -446,13 +446,13 @@ makphy_status(struct mii_softc *sc) * Check Speed and Duplex Resolved bit. * Note that this bit is always 1 when autonego is not enabled. */ - if (!(pssr & PSSR_RESOLVED)) { + if (!(pssr & MAKPHY_PSSR_RESOLVED)) { /* Erg, still trying, I guess... */ mii->mii_media_active |= IFM_NONE; return; } } else { - if ((pssr & PSSR_LINK) == 0) { + if ((pssr & MAKPHY_PSSR_LINK) == 0) { mii->mii_media_active |= IFM_NONE; return; } @@ -480,10 +480,10 @@ makphy_status(struct mii_softc *sc) /* Fiber/Copper auto select mode */ PHY_READ(sc, MAKPHY_PSSR, &pssr); - if ((pssr & PSSR_RESOLUTION_FIBER) == 0) + if ((pssr & MAKPHY_PSSR_RESOLUTION_FIBER) == 0) goto copper; - switch (PSSR_SPEED_get(pssr)) { + switch (MAKPHY_PSSR_SPEED_get(pssr)) { case SPEED_1000: mii->mii_media_active |= IFM_1000_SX; break; @@ -497,7 +497,7 @@ makphy_status(struct mii_softc *sc) } } else { copper: - switch (PSSR_SPEED_get(pssr)) { + switch (MAKPHY_PSSR_SPEED_get(pssr)) { case SPEED_1000: mii->mii_media_active |= IFM_1000_T; break; @@ -514,7 +514,7 @@ copper: } } - if (pssr & PSSR_DUPLEX) + if (pssr & MAKPHY_PSSR_DUPLEX) mii->mii_media_active |= mii_phy_flowstatus(sc) | IFM_FDX; else mii->mii_media_active |= IFM_HDX; diff --git a/sys/dev/mii/makphyreg.h b/sys/dev/mii/makphyreg.h index 9d299a6857d3..54f804bcf6c1 100644 --- a/sys/dev/mii/makphyreg.h +++ b/sys/dev/mii/makphyreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: makphyreg.h,v 1.10 2019/12/12 09:25:37 msaitoh Exp $ */ +/* $NetBSD: makphyreg.h,v 1.11 2020/08/03 07:25:59 msaitoh Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -92,15 +92,15 @@ #define MSCR_ENHANCED_SGMII 0x0004 /* Enhanced SGMII */ #define MAKPHY_PSSR 0x11 /* PHY specific status register */ -#define PSSR_JABBER (1U << 0) /* jabber indication */ -#define PSSR_POLARITY (1U << 1) /* polarity indiciation */ -#define PSSR_MDIX (1U << 6) /* 1 = MIDX, 0 = MDI */ -#define PSSR_CABLE_LENGTH_get(x) (((x) >> 7) & 0x3) -#define PSSR_LINK (1U << 10) /* link indication */ -#define PSSR_RESOLVED (1U << 11) /* speed and duplex resolved */ -#define PSSR_PAGE_RECEIVED (1U << 12) /* page received */ -#define PSSR_DUPLEX (1U << 13) /* 1 = FDX */ -#define PSSR_SPEED_get(x) (((x) >> 14) & 0x3) +#define MAKPHY_PSSR_JABBER (1U << 0) /* jabber indication */ +#define MAKPHY_PSSR_POLARITY (1U << 1) /* polarity indiciation */ +#define MAKPHY_PSSR_MDIX (1U << 6) /* 1 = MIDX, 0 = MDI */ +#define MAKPHY_PSSR_CABLE_LENGTH_get(x) (((x) >> 7) & 0x3) +#define MAKPHY_PSSR_LINK (1U << 10) /* link indication */ +#define MAKPHY_PSSR_RESOLVED (1U << 11) /* speed and duplex resolved */ +#define MAKPHY_PSSR_PAGE_RECEIVED (1U << 12) /* page received */ +#define MAKPHY_PSSR_DUPLEX (1U << 13) /* 1 = FDX */ +#define MAKPHY_PSSR_SPEED_get(x) (((x) >> 14) & 0x3) #define SPEED_10 0 #define SPEED_100 1 @@ -108,10 +108,10 @@ #define SPEED_reserved 3 /* For 88E1112 */ -#define PSSR_RESOLUTION_FIBER (1U << 7) /* - * Fiber/Copper resolution - * 1 = Fiber, 0 = Copper - */ +#define MAKPHY_PSSR_RESOLUTION_FIBER (1U << 7) /* + * Fiber/Copper resolution + * 1 = Fiber, 0 = Copper + */ #define MAKPHY_IE 0x12 /* Interrupt enable */ #define IE_JABBER (1U << 0) /* jabber indication */