From c10887f31ff175b20dcc5ce4fc72c044af879b6e Mon Sep 17 00:00:00 2001 From: Sergei Poselenov Date: Sat, 21 Oct 2017 03:43:53 +0300 Subject: [PATCH] RM 2035 (RT #140914). A2F-SOM: Change PHY link status detection, as per Linux code. Now 10Mb/s link works in U-Boot. --- drivers/net/core10100.c | 20 +++++++++++--------- include/miiphy.h | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/core10100.c b/drivers/net/core10100.c index 76b0986..4cb9231 100644 --- a/drivers/net/core10100.c +++ b/drivers/net/core10100.c @@ -140,7 +140,7 @@ static int phy_init(struct core10100_dev *bp) /* get link status */ static int phy_link_stat(struct core10100_dev *bp) { - u16 val; + u16 val, lpa, adv; u32 link_stat = 0; /* If not initialized, return no link */ @@ -155,17 +155,19 @@ static int phy_link_stat(struct core10100_dev *bp) if (val & PHY_BMSR_LS) { link_stat |= LINK_UP; } + /* Read autonegotiations results, code from linux/drivers/net/phy/phy_device.c, genphy_read_status() */ + lpa = mii_read(bp, PHY_ANLPAR); + adv = mii_read(bp, PHY_ANAR); + lpa &= adv; - /* Read link speed and duplex */ - val = mii_read(bp, PHY_BMCR); - - /* Update link speed */ - if (val & (PHY_BMSR_100TXH | PHY_BMSR_100TXF)) { + if (lpa & (PHY_ANLPAR_100HALF | PHY_ANLPAR_100FULL)){ link_stat |= LINK_100; - } - /* Update link speed */ - if (val & PHY_BMSR_EXT_STAT) { + if (lpa & PHY_ANLPAR_100FULL){ + link_stat |= LINK_FD; + + } + } else if (lpa & PHY_ANLPAR_10FD) { link_stat |= LINK_FD; } diff --git a/include/miiphy.h b/include/miiphy.h index 5362125..c296336 100644 --- a/include/miiphy.h +++ b/include/miiphy.h @@ -162,7 +162,9 @@ int bb_miiphy_write (char *devname, unsigned char addr, #define PHY_ANLPAR_PAUSE 0x0400 #define PHY_ANLPAR_T4 0x0200 #define PHY_ANLPAR_TXFD 0x0100 +#define PHY_ANLPAR_100FULL 0x0100 #define PHY_ANLPAR_TX 0x0080 +#define PHY_ANLPAR_100HALF 0x0080 #define PHY_ANLPAR_10FD 0x0040 #define PHY_ANLPAR_10 0x0020 #define PHY_ANLPAR_100 0x0380 /* we can run at 100 */ -- GitLab