Skip to content

Commit 8e850f2

Browse files
Masahisa Kojimadavem330
authored andcommitted
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: 533dd11 ("net: socionext: Add Synquacer NetSec driver") Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Signed-off-by: Yoshitoyo Osaki <osaki.yoshitoyo@socionext.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 487e2e2 commit 8e850f2

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

‎drivers/net/ethernet/socionext/netsec.c‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ struct netsec_priv {
274274
struct clk *clk;
275275
u32 msg_enable;
276276
u32 freq;
277+
u32 phy_addr;
277278
bool rx_cksum_offload_flag;
278279
};
279280

@@ -1343,11 +1344,11 @@ static int netsec_netdev_stop(struct net_device *ndev)
13431344
netsec_uninit_pkt_dring(priv, NETSEC_RING_TX);
13441345
netsec_uninit_pkt_dring(priv, NETSEC_RING_RX);
13451346

1346-
ret = netsec_reset_hardware(priv, false);
1347-
13481347
phy_stop(ndev->phydev);
13491348
phy_disconnect(ndev->phydev);
13501349

1350+
ret = netsec_reset_hardware(priv, false);
1351+
13511352
pm_runtime_put_sync(priv->dev);
13521353

13531354
return ret;
@@ -1357,6 +1358,7 @@ static int netsec_netdev_init(struct net_device *ndev)
13571358
{
13581359
struct netsec_priv *priv = netdev_priv(ndev);
13591360
int ret;
1361+
u16 data;
13601362

13611363
ret = netsec_alloc_dring(priv, NETSEC_RING_TX);
13621364
if (ret)
@@ -1366,6 +1368,11 @@ static int netsec_netdev_init(struct net_device *ndev)
13661368
if (ret)
13671369
goto err1;
13681370

1371+
/* set phy power down */
1372+
data = netsec_phy_read(priv->mii_bus, priv->phy_addr, MII_BMCR) |
1373+
BMCR_PDOWN;
1374+
netsec_phy_write(priv->mii_bus, priv->phy_addr, MII_BMCR, data);
1375+
13691376
ret = netsec_reset_hardware(priv, true);
13701377
if (ret)
13711378
goto err2;
@@ -1415,14 +1422,16 @@ static const struct net_device_ops netsec_netdev_ops = {
14151422
};
14161423

14171424
static int netsec_of_probe(struct platform_device *pdev,
1418-
struct netsec_priv *priv)
1425+
struct netsec_priv *priv, u32 *phy_addr)
14191426
{
14201427
priv->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
14211428
if (!priv->phy_np) {
14221429
dev_err(&pdev->dev, "missing required property 'phy-handle'\n");
14231430
return -EINVAL;
14241431
}
14251432

1433+
*phy_addr = of_mdio_parse_addr(&pdev->dev, priv->phy_np);
1434+
14261435
priv->clk = devm_clk_get(&pdev->dev, NULL); /* get by 'phy_ref_clk' */
14271436
if (IS_ERR(priv->clk)) {
14281437
dev_err(&pdev->dev, "phy_ref_clk not found\n");
@@ -1623,12 +1632,14 @@ static int netsec_probe(struct platform_device *pdev)
16231632
}
16241633

16251634
if (dev_of_node(&pdev->dev))
1626-
ret = netsec_of_probe(pdev, priv);
1635+
ret = netsec_of_probe(pdev, priv, &phy_addr);
16271636
else
16281637
ret = netsec_acpi_probe(pdev, priv, &phy_addr);
16291638
if (ret)
16301639
goto free_ndev;
16311640

1641+
priv->phy_addr = phy_addr;
1642+
16321643
if (!priv->freq) {
16331644
dev_err(&pdev->dev, "missing PHY reference clock frequency\n");
16341645
ret = -ENODEV;

0 commit comments

Comments
 (0)