Commit 1b0a83ac authored by Richard Leitner's avatar Richard Leitner Committed by David S. Miller

net: fec: add phy_reset_after_clk_enable() support

Some PHYs (for example the SMSC LAN8710/LAN8720) doesn't allow turning
the refclk on and off again during operation (according to their
datasheet). Nonetheless exactly this behaviour was introduced for power
saving reasons by commit e8fcfcd5 ("net: fec: optimize the clock management to save power").
Therefore add support for the phy_reset_after_clk_enable function from
phylib to mitigate this issue.

Generally speaking this issue is only relevant if the ref clk for the
PHY is generated by the SoC and therefore the PHY is configured to
"REF_CLK In Mode". In our specific case (PCB) this problem does occur at
about every 10th to 50th POR of an LAN8710 connected to an i.MX6SOLO
SoC. The typical symptom of this problem is a "swinging" ethernet link.
Similar issues were reported by users of the NXP forum:
	https://community.nxp.com/thread/389902
	https://community.nxp.com/message/309354
With this patch applied the issue didn't occur for at least a few
hundret PORs of our board.

Fixes: e8fcfcd5 ("net: fec: optimize the clock management to save power")
Signed-off-by: default avatarRichard Leitner <richard.leitner@skidata.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7f64e5b1
...@@ -1862,6 +1862,8 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) ...@@ -1862,6 +1862,8 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
ret = clk_prepare_enable(fep->clk_ref); ret = clk_prepare_enable(fep->clk_ref);
if (ret) if (ret)
goto failed_clk_ref; goto failed_clk_ref;
phy_reset_after_clk_enable(ndev->phydev);
} else { } else {
clk_disable_unprepare(fep->clk_ahb); clk_disable_unprepare(fep->clk_ahb);
clk_disable_unprepare(fep->clk_enet_out); clk_disable_unprepare(fep->clk_enet_out);
...@@ -2834,6 +2836,7 @@ fec_enet_open(struct net_device *ndev) ...@@ -2834,6 +2836,7 @@ fec_enet_open(struct net_device *ndev)
{ {
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
int ret; int ret;
bool reset_again;
ret = pm_runtime_get_sync(&fep->pdev->dev); ret = pm_runtime_get_sync(&fep->pdev->dev);
if (ret < 0) if (ret < 0)
...@@ -2844,6 +2847,17 @@ fec_enet_open(struct net_device *ndev) ...@@ -2844,6 +2847,17 @@ fec_enet_open(struct net_device *ndev)
if (ret) if (ret)
goto clk_enable; goto clk_enable;
/* During the first fec_enet_open call the PHY isn't probed at this
* point. Therefore the phy_reset_after_clk_enable() call within
* fec_enet_clk_enable() fails. As we need this reset in order to be
* sure the PHY is working correctly we check if we need to reset again
* later when the PHY is probed
*/
if (ndev->phydev && ndev->phydev->drv)
reset_again = false;
else
reset_again = true;
/* I should reset the ring buffers here, but I don't yet know /* I should reset the ring buffers here, but I don't yet know
* a simple way to do that. * a simple way to do that.
*/ */
...@@ -2860,6 +2874,12 @@ fec_enet_open(struct net_device *ndev) ...@@ -2860,6 +2874,12 @@ fec_enet_open(struct net_device *ndev)
if (ret) if (ret)
goto err_enet_mii_probe; goto err_enet_mii_probe;
/* Call phy_reset_after_clk_enable() again if it failed during
* phy_reset_after_clk_enable() before because the PHY wasn't probed.
*/
if (reset_again)
phy_reset_after_clk_enable(ndev->phydev);
if (fep->quirks & FEC_QUIRK_ERR006687) if (fep->quirks & FEC_QUIRK_ERR006687)
imx6q_cpuidle_fec_irqs_used(); imx6q_cpuidle_fec_irqs_used();
......
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