From: Lothar Waßmann Date: Tue, 23 Jun 2015 08:32:58 +0000 (+0200) Subject: net: macb: fix network configuration error when using gmac with non-Gbit PHY X-Git-Tag: KARO-TXA5-2015-06-26~4 X-Git-Url: https://git.kernelconcepts.de/?p=karo-tx-uboot.git;a=commitdiff_plain;h=53293be4423faf85f9f53d0442c499a84c11a588 net: macb: fix network configuration error when using gmac with non-Gbit PHY If the ethernet controller is detected as GMAC, the driver silently assumes, that the connected PHY is also 1000Mbit capable and reads the probably non-existant MII_STAT1000 register. This may lead to falsely assuming a 1000Mbit link. --- diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 9c2ff487a7..abeb1ae62b 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -419,6 +419,15 @@ static int macb_phy_find(struct macb_device *macb) } #endif /* CONFIG_MACB_SEARCH_PHY */ +#ifdef CONFIG_PHYLIB +#define gbit_phy_support(p) ((p)->supported & \ + (SUPPORTED_1000baseT_Full | \ + SUPPORTED_1000baseT_Half)) +#elif defined(CONFIG_RGMII) || defined(CONFIG_GMII) +#define gbit_phy_support(p) 1 +#else +#define gbit_phy_support(p) 0 +#endif static int macb_phy_init(struct macb_device *macb) { @@ -478,26 +487,28 @@ static int macb_phy_init(struct macb_device *macb) /* First check for GMAC */ if (macb_is_gem(macb)) { - lpa = macb_mdio_read(macb, MII_STAT1000); + if (gbit_phy_support(phydev)) { + lpa = macb_mdio_read(macb, MII_STAT1000); - if (lpa & (LPA_1000FULL | LPA_1000HALF)) { - duplex = ((lpa & LPA_1000FULL) ? 1 : 0); + if (lpa & (LPA_1000FULL | LPA_1000HALF)) { + duplex = ((lpa & LPA_1000FULL) ? 1 : 0); - printf("%s: link up, 1000Mbps %s-duplex (lpa: 0x%04x)\n", - netdev->name, - duplex ? "full" : "half", - lpa); + printf("%s: link up, 1000Mbps %s-duplex (lpa: 0x%04x)\n", + netdev->name, + duplex ? "full" : "half", + lpa); - ncfgr = macb_readl(macb, NCFGR); - ncfgr &= ~(MACB_BIT(SPD) | MACB_BIT(FD)); - ncfgr |= GEM_BIT(GBE); + ncfgr = macb_readl(macb, NCFGR); + ncfgr &= ~(MACB_BIT(SPD) | MACB_BIT(FD)); + ncfgr |= GEM_BIT(GBE); - if (duplex) - ncfgr |= MACB_BIT(FD); + if (duplex) + ncfgr |= MACB_BIT(FD); - macb_writel(macb, NCFGR, ncfgr); + macb_writel(macb, NCFGR, ncfgr); - return 1; + return 1; + } } }