diff options
author | Jeremy Gebben <jgebben@sweptlaser.com> | 2018-09-18 15:49:37 -0600 |
---|---|---|
committer | Joe Hershberger <joe.hershberger@ni.com> | 2018-10-24 14:45:37 -0500 |
commit | 30a2c8cca80ed71384e5c1ebc4e52695c3db8fff (patch) | |
tree | 3a597d9aa8b32243579d662a3b03e1eb3244f81f /drivers/net/phy/aquantia.c | |
parent | 4506423ad23749a28ae48720bc64ad40caf089b2 (diff) | |
download | u-boot-30a2c8cca80ed71384e5c1ebc4e52695c3db8fff.zip u-boot-30a2c8cca80ed71384e5c1ebc4e52695c3db8fff.tar.gz u-boot-30a2c8cca80ed71384e5c1ebc4e52695c3db8fff.tar.bz2 |
net: phy: aquantia: autodetect if firmware needs to be loaded
If the phy reports a valid firmware version and doesn't indicate
a fault, skip loading the firmware. This allows the same image
to be used on boards that have firmware storage and those that do not.
Signed-off-by: Jeremy Gebben <jgebben@sweptlaser.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers/net/phy/aquantia.c')
-rw-r--r-- | drivers/net/phy/aquantia.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/drivers/net/phy/aquantia.c b/drivers/net/phy/aquantia.c index cbd7012..37749e0 100644 --- a/drivers/net/phy/aquantia.c +++ b/drivers/net/phy/aquantia.c @@ -236,18 +236,34 @@ done: #else static int aquantia_upload_firmware(struct phy_device *phydev) { - return 0; + printf("ERROR %s firmware loading disabled.\n", phydev->dev->name); + return -1; } #endif int aquantia_config(struct phy_device *phydev) { - u32 val; - int ret; + u32 val, id, rstatus, fault; - ret = aquantia_upload_firmware(phydev); - if (ret != 0) - return ret; + id = phy_read(phydev, MDIO_MMD_VEND1, GLOBAL_FIRMWARE_ID); + rstatus = phy_read(phydev, MDIO_MMD_VEND1, GLOBAL_RSTATUS_1); + fault = phy_read(phydev, MDIO_MMD_VEND1, GLOBAL_FAULT); + + if (id != 0) + printf("%s running firmware version %X.%X.%X\n", + phydev->dev->name, (id >> 8), id & 0xff, + (rstatus >> 4) & 0xf); + + if (fault != 0) + printf("%s fault 0x%04x detected\n", phydev->dev->name, fault); + + if (id == 0 || fault != 0) { + int ret; + + ret = aquantia_upload_firmware(phydev); + if (ret != 0) + return ret; + } val = phy_read(phydev, MDIO_MMD_PMAPMD, MII_BMCR); |