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)
/* 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;
}
......
......@@ -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 */
......
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