Commit c10887f3 authored by Sergei Poselenov's avatar Sergei Poselenov

RM 2035 (RT #140914). A2F-SOM: Change PHY link status detection, as per Linux code.

Now 10Mb/s link works in U-Boot.
parent e4558659
...@@ -140,7 +140,7 @@ static int phy_init(struct core10100_dev *bp) ...@@ -140,7 +140,7 @@ static int phy_init(struct core10100_dev *bp)
/* get link status */ /* get link status */
static int phy_link_stat(struct core10100_dev *bp) static int phy_link_stat(struct core10100_dev *bp)
{ {
u16 val; u16 val, lpa, adv;
u32 link_stat = 0; u32 link_stat = 0;
/* If not initialized, return no link */ /* If not initialized, return no link */
...@@ -155,17 +155,19 @@ static int phy_link_stat(struct core10100_dev *bp) ...@@ -155,17 +155,19 @@ static int phy_link_stat(struct core10100_dev *bp)
if (val & PHY_BMSR_LS) { if (val & PHY_BMSR_LS) {
link_stat |= LINK_UP; 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 */ if (lpa & (PHY_ANLPAR_100HALF | PHY_ANLPAR_100FULL)){
val = mii_read(bp, PHY_BMCR);
/* Update link speed */
if (val & (PHY_BMSR_100TXH | PHY_BMSR_100TXF)) {
link_stat |= LINK_100; link_stat |= LINK_100;
}
/* Update link speed */ if (lpa & PHY_ANLPAR_100FULL){
if (val & PHY_BMSR_EXT_STAT) { link_stat |= LINK_FD;
}
} else if (lpa & PHY_ANLPAR_10FD) {
link_stat |= LINK_FD; link_stat |= LINK_FD;
} }
......
...@@ -162,7 +162,9 @@ int bb_miiphy_write (char *devname, unsigned char addr, ...@@ -162,7 +162,9 @@ int bb_miiphy_write (char *devname, unsigned char addr,
#define PHY_ANLPAR_PAUSE 0x0400 #define PHY_ANLPAR_PAUSE 0x0400
#define PHY_ANLPAR_T4 0x0200 #define PHY_ANLPAR_T4 0x0200
#define PHY_ANLPAR_TXFD 0x0100 #define PHY_ANLPAR_TXFD 0x0100
#define PHY_ANLPAR_100FULL 0x0100
#define PHY_ANLPAR_TX 0x0080 #define PHY_ANLPAR_TX 0x0080
#define PHY_ANLPAR_100HALF 0x0080
#define PHY_ANLPAR_10FD 0x0040 #define PHY_ANLPAR_10FD 0x0040
#define PHY_ANLPAR_10 0x0020 #define PHY_ANLPAR_10 0x0020
#define PHY_ANLPAR_100 0x0380 /* we can run at 100 */ #define PHY_ANLPAR_100 0x0380 /* we can run at 100 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment