Commit 8e850f25 authored by Masahisa Kojima's avatar Masahisa Kojima Committed by David S. Miller

net: socionext: Stop PHY before resetting netsec

In ndo_stop, driver resets the netsec ethernet controller IP.
When the netsec IP is reset, HW running mode turns to NRM mode
and driver has to wait until this mode transition completes.

But mode transition to NRM will not complete if the PHY is
in normal operation state. Netsec IP requires PHY is in
power down state when it is reset.

This modification stops the PHY before resetting netsec.

Together with this modification, phy_addr is stored in netsec_priv
structure because ndev->phydev is not yet ready in ndo_init.

Fixes: 533dd11a ("net: socionext: Add Synquacer NetSec driver")
Signed-off-by: default avatarMasahisa Kojima <masahisa.kojima@linaro.org>
Signed-off-by: default avatarYoshitoyo Osaki <osaki.yoshitoyo@socionext.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 487e2e22
...@@ -274,6 +274,7 @@ struct netsec_priv { ...@@ -274,6 +274,7 @@ struct netsec_priv {
struct clk *clk; struct clk *clk;
u32 msg_enable; u32 msg_enable;
u32 freq; u32 freq;
u32 phy_addr;
bool rx_cksum_offload_flag; bool rx_cksum_offload_flag;
}; };
...@@ -1343,11 +1344,11 @@ static int netsec_netdev_stop(struct net_device *ndev) ...@@ -1343,11 +1344,11 @@ static int netsec_netdev_stop(struct net_device *ndev)
netsec_uninit_pkt_dring(priv, NETSEC_RING_TX); netsec_uninit_pkt_dring(priv, NETSEC_RING_TX);
netsec_uninit_pkt_dring(priv, NETSEC_RING_RX); netsec_uninit_pkt_dring(priv, NETSEC_RING_RX);
ret = netsec_reset_hardware(priv, false);
phy_stop(ndev->phydev); phy_stop(ndev->phydev);
phy_disconnect(ndev->phydev); phy_disconnect(ndev->phydev);
ret = netsec_reset_hardware(priv, false);
pm_runtime_put_sync(priv->dev); pm_runtime_put_sync(priv->dev);
return ret; return ret;
...@@ -1357,6 +1358,7 @@ static int netsec_netdev_init(struct net_device *ndev) ...@@ -1357,6 +1358,7 @@ static int netsec_netdev_init(struct net_device *ndev)
{ {
struct netsec_priv *priv = netdev_priv(ndev); struct netsec_priv *priv = netdev_priv(ndev);
int ret; int ret;
u16 data;
ret = netsec_alloc_dring(priv, NETSEC_RING_TX); ret = netsec_alloc_dring(priv, NETSEC_RING_TX);
if (ret) if (ret)
...@@ -1366,6 +1368,11 @@ static int netsec_netdev_init(struct net_device *ndev) ...@@ -1366,6 +1368,11 @@ static int netsec_netdev_init(struct net_device *ndev)
if (ret) if (ret)
goto err1; goto err1;
/* set phy power down */
data = netsec_phy_read(priv->mii_bus, priv->phy_addr, MII_BMCR) |
BMCR_PDOWN;
netsec_phy_write(priv->mii_bus, priv->phy_addr, MII_BMCR, data);
ret = netsec_reset_hardware(priv, true); ret = netsec_reset_hardware(priv, true);
if (ret) if (ret)
goto err2; goto err2;
...@@ -1415,7 +1422,7 @@ static const struct net_device_ops netsec_netdev_ops = { ...@@ -1415,7 +1422,7 @@ static const struct net_device_ops netsec_netdev_ops = {
}; };
static int netsec_of_probe(struct platform_device *pdev, static int netsec_of_probe(struct platform_device *pdev,
struct netsec_priv *priv) struct netsec_priv *priv, u32 *phy_addr)
{ {
priv->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); priv->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
if (!priv->phy_np) { if (!priv->phy_np) {
...@@ -1423,6 +1430,8 @@ static int netsec_of_probe(struct platform_device *pdev, ...@@ -1423,6 +1430,8 @@ static int netsec_of_probe(struct platform_device *pdev,
return -EINVAL; return -EINVAL;
} }
*phy_addr = of_mdio_parse_addr(&pdev->dev, priv->phy_np);
priv->clk = devm_clk_get(&pdev->dev, NULL); /* get by 'phy_ref_clk' */ priv->clk = devm_clk_get(&pdev->dev, NULL); /* get by 'phy_ref_clk' */
if (IS_ERR(priv->clk)) { if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "phy_ref_clk not found\n"); dev_err(&pdev->dev, "phy_ref_clk not found\n");
...@@ -1623,12 +1632,14 @@ static int netsec_probe(struct platform_device *pdev) ...@@ -1623,12 +1632,14 @@ static int netsec_probe(struct platform_device *pdev)
} }
if (dev_of_node(&pdev->dev)) if (dev_of_node(&pdev->dev))
ret = netsec_of_probe(pdev, priv); ret = netsec_of_probe(pdev, priv, &phy_addr);
else else
ret = netsec_acpi_probe(pdev, priv, &phy_addr); ret = netsec_acpi_probe(pdev, priv, &phy_addr);
if (ret) if (ret)
goto free_ndev; goto free_ndev;
priv->phy_addr = phy_addr;
if (!priv->freq) { if (!priv->freq) {
dev_err(&pdev->dev, "missing PHY reference clock frequency\n"); dev_err(&pdev->dev, "missing PHY reference clock frequency\n");
ret = -ENODEV; ret = -ENODEV;
......
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