Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/mii STGE_PhyCtrl is not PHY register but MAC registe...



details:   https://anonhg.NetBSD.org/src/rev/8561215a6c43
branches:  trunk
changeset: 461047:8561215a6c43
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Nov 14 09:00:23 2019 +0000

description:
STGE_PhyCtrl is not PHY register but MAC register, so use ukphy_status()
for IP1000A device.

diffstat:

 sys/dev/mii/ipgphy.c |  72 ++++++++++++++++++---------------------------------
 1 files changed, 26 insertions(+), 46 deletions(-)

diffs (97 lines):

diff -r 80637f7d1bfd -r 8561215a6c43 sys/dev/mii/ipgphy.c
--- a/sys/dev/mii/ipgphy.c      Thu Nov 14 08:52:34 2019 +0000
+++ b/sys/dev/mii/ipgphy.c      Thu Nov 14 09:00:23 2019 +0000
@@ -32,7 +32,7 @@
  * Driver for the IC Plus IP1000A/IP1001 10/100/1000 PHY.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipgphy.c,v 1.2 2019/11/14 08:52:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipgphy.c,v 1.3 2019/11/14 09:00:23 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -261,6 +261,12 @@
        struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
        uint16_t bmsr, bmcr, stat, gtsr;
 
+       /* For IP1000A, use generic way */
+       if (sc->mii_mpd_model == MII_MODEL_xxICPLUS_IP1000A) {
+               ukphy_status(sc);
+               return;
+       }
+
        mii->mii_media_status = IFM_AVALID;
        mii->mii_media_active = IFM_ETHER;
 
@@ -280,52 +286,26 @@
                        return;
                }
 
-               if (sc->mii_mpd_model == MII_MODEL_xxICPLUS_IP1001) {
-                       PHY_READ(sc, IPGPHY_LSR, &stat);
-                       switch (stat & IPGPHY_LSR_SPEED_MASK) {
-                       case IPGPHY_LSR_SPEED_10:
-                               mii->mii_media_active |= IFM_10_T;
-                               break;
-                       case IPGPHY_LSR_SPEED_100:
-                               mii->mii_media_active |= IFM_100_TX;
-                               break;
-                       case IPGPHY_LSR_SPEED_1000:
-                               mii->mii_media_active |= IFM_1000_T;
-                               break;
-                       default:
-                               mii->mii_media_active |= IFM_NONE;
-                               return;
-                       }
+               PHY_READ(sc, IPGPHY_LSR, &stat);
+               switch (stat & IPGPHY_LSR_SPEED_MASK) {
+               case IPGPHY_LSR_SPEED_10:
+                       mii->mii_media_active |= IFM_10_T;
+                       break;
+               case IPGPHY_LSR_SPEED_100:
+                       mii->mii_media_active |= IFM_100_TX;
+                       break;
+               case IPGPHY_LSR_SPEED_1000:
+                       mii->mii_media_active |= IFM_1000_T;
+                       break;
+               default:
+                       mii->mii_media_active |= IFM_NONE;
+                       return;
+               }
 
-                       if (stat & IPGPHY_LSR_FULL_DUPLEX)
-                               mii->mii_media_active |= IFM_FDX;
-                       else
-                               mii->mii_media_active |= IFM_HDX;
-               } else {
-                       PHY_READ(sc, STGE_PhyCtrl, &stat);
-                       switch (PC_LinkSpeed(stat)) {
-                       case PC_LinkSpeed_Down:
-                               mii->mii_media_active |= IFM_NONE;
-                               return;
-                       case PC_LinkSpeed_10:
-                               mii->mii_media_active |= IFM_10_T;
-                               break;
-                       case PC_LinkSpeed_100:
-                               mii->mii_media_active |= IFM_100_TX;
-                               break;
-                       case PC_LinkSpeed_1000:
-                               mii->mii_media_active |= IFM_1000_T;
-                               break;
-                       default:
-                               mii->mii_media_active |= IFM_NONE;
-                               return;
-                       }
-
-                       if (stat & PC_PhyDuplexStatus)
-                               mii->mii_media_active |= IFM_FDX;
-                       else
-                               mii->mii_media_active |= IFM_HDX;
-               }
+               if (stat & IPGPHY_LSR_FULL_DUPLEX)
+                       mii->mii_media_active |= IFM_FDX;
+               else
+                       mii->mii_media_active |= IFM_HDX;
 
                if (mii->mii_media_active & IFM_FDX)
                        mii->mii_media_active |= mii_phy_flowstatus(sc);



Home | Main Index | Thread Index | Old Index