From mboxrd@z Thu Jan 1 00:00:00 1970 From: masahisa.kojima@linaro.org Subject: [PATCH 1/3] net: socionext: Stop PHY before resetting netsec Date: Fri, 19 Oct 2018 10:08:41 +0900 Message-ID: <20181019010843.3605-2-masahisa.kojima@linaro.org> References: <20181019010843.3605-1-masahisa.kojima@linaro.org> Cc: ilias.apalodimas@linaro.org, jaswinder.singh@linaro.org, ard.biesheuvel@linaro.org, osaki.yoshitoyo@socionext.com, Masahisa Kojima To: netdev@vger.kernel.org Return-path: Received: from mail-yb1-f195.google.com ([209.85.219.195]:36247 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbeJSJOP (ORCPT ); Fri, 19 Oct 2018 05:14:15 -0400 Received: by mail-yb1-f195.google.com with SMTP id 5-v6so12645671ybf.3 for ; Thu, 18 Oct 2018 18:10:32 -0700 (PDT) In-Reply-To: <20181019010843.3605-1-masahisa.kojima@linaro.org> Sender: netdev-owner@vger.kernel.org List-ID: From: Masahisa Kojima After resetting netsec IP, driver have to wait until netsec mode turns to NRM mode. But sometimes mode transition to NRM will not complete if the PHY is in normal operation state. To avoid this situation, stop PHY before resetting netsec. Signed-off-by: Masahisa Kojima Signed-off-by: Yoshitoyo Osaki --- drivers/net/ethernet/socionext/netsec.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 4289ccb26e4e..273cc5fc07e0 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -1343,11 +1343,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_RX); - ret = netsec_reset_hardware(priv, false); - phy_stop(ndev->phydev); phy_disconnect(ndev->phydev); + ret = netsec_reset_hardware(priv, false); + pm_runtime_put_sync(priv->dev); return ret; @@ -1415,7 +1415,7 @@ static const struct net_device_ops netsec_netdev_ops = { }; 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); if (!priv->phy_np) { @@ -1423,6 +1423,8 @@ static int netsec_of_probe(struct platform_device *pdev, 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' */ if (IS_ERR(priv->clk)) { dev_err(&pdev->dev, "phy_ref_clk not found\n"); @@ -1473,6 +1475,7 @@ static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr) { struct mii_bus *bus; int ret; + u16 data; bus = devm_mdiobus_alloc(priv->dev); if (!bus) @@ -1486,6 +1489,10 @@ static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr) bus->parent = priv->dev; priv->mii_bus = bus; + /* set phy power down */ + data = netsec_phy_read(bus, phy_addr, 0) | 0x800; + netsec_phy_write(bus, phy_addr, 0, data); + if (dev_of_node(priv->dev)) { struct device_node *mdio_node, *parent = dev_of_node(priv->dev); @@ -1623,7 +1630,7 @@ static int netsec_probe(struct platform_device *pdev) } if (dev_of_node(&pdev->dev)) - ret = netsec_of_probe(pdev, priv); + ret = netsec_of_probe(pdev, priv, &phy_addr); else ret = netsec_acpi_probe(pdev, priv, &phy_addr); if (ret) -- 2.14.2