From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> To: Jose.Abreu@synopsys.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, kuba@kernel.org, netdev@vger.kernel.org, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, davem@davemloft.net, mcoquelin.stm32@gmail.com, weifeng.voon@intel.com, boon.leong.ong@intel.com, tee.min.tan@intel.com, vee.khee.wong@linux.intel.com, vee.khee.wong@intel.com, michael.wei.hong.sit@intel.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, vladimir.oltean@nxp.com Subject: [PATCH net-next v6 1/3] net: stmmac: split xPCS setup from mdio register Date: Tue, 8 Jun 2021 11:51:56 +0800 [thread overview] Message-ID: <20210608035158.4869-2-michael.wei.hong.sit@intel.com> (raw) In-Reply-To: <20210608035158.4869-1-michael.wei.hong.sit@intel.com> From: Voon Weifeng <weifeng.voon@intel.com> This patch is a preparation patch for the enabling of Intel mGbE 2.5Gbps link speed. The Intel mGbR link speed configuration (1G/2.5G) is depends on a mdio ADHOC register which can be configured in the bios menu. As PHY interface might be different for 1G and 2.5G, the mdio bus need be ready to check the link speed and select the PHY interface before probing the xPCS. Signed-off-by: Voon Weifeng <weifeng.voon@intel.com> Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++ .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 64 ++++++++++--------- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index b6cd43eda7ac..fd7212afc543 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -311,6 +311,7 @@ enum stmmac_state { int stmmac_mdio_unregister(struct net_device *ndev); int stmmac_mdio_register(struct net_device *ndev); int stmmac_mdio_reset(struct mii_bus *mii); +int stmmac_xpcs_setup(struct mii_bus *mii); void stmmac_set_ethtool_ops(struct net_device *netdev); void stmmac_ptp_register(struct stmmac_priv *priv); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 0a266fa0af7e..af406ea3dd46 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6993,6 +6993,14 @@ int stmmac_dvr_probe(struct device *device, } } + if (priv->plat->mdio_bus_data) { + if (priv->plat->mdio_bus_data->has_xpcs) { + ret = stmmac_xpcs_setup(priv->mii); + if (ret) + goto error_xpcs_setup; + } + } + ret = stmmac_phy_setup(priv); if (ret) { netdev_err(ndev, "failed to setup phy (%d)\n", ret); @@ -7029,6 +7037,7 @@ int stmmac_dvr_probe(struct device *device, unregister_netdev(ndev); error_netdev_register: phylink_destroy(priv->phylink); +error_xpcs_setup: error_phy_setup: if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 6312a152c8ad..bc900e240da2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -397,6 +397,41 @@ int stmmac_mdio_reset(struct mii_bus *bus) return 0; } +int stmmac_xpcs_setup(struct mii_bus *bus) +{ + int mode, addr; + struct net_device *ndev = bus->priv; + struct mdio_xpcs_args *xpcs; + struct stmmac_priv *priv; + struct mdio_device *mdiodev; + + priv = netdev_priv(ndev); + mode = priv->plat->phy_interface; + + /* Try to probe the XPCS by scanning all addresses. */ + for (addr = 0; addr < PHY_MAX_ADDR; addr++) { + mdiodev = mdio_device_create(bus, addr); + if (IS_ERR(mdiodev)) + continue; + + xpcs = xpcs_create(mdiodev, mode); + if (IS_ERR_OR_NULL(xpcs)) { + mdio_device_free(mdiodev); + continue; + } + + priv->hw->xpcs = xpcs; + break; + } + + if (!priv->hw->xpcs) { + dev_warn(priv->device, "No xPCS found\n"); + return -ENODEV; + } + + return 0; +} + /** * stmmac_mdio_register * @ndev: net device structure @@ -501,40 +536,11 @@ int stmmac_mdio_register(struct net_device *ndev) goto no_phy_found; } - /* Try to probe the XPCS by scanning all addresses. */ - if (mdio_bus_data->has_xpcs) { - int mode = priv->plat->phy_interface; - struct mdio_device *mdiodev; - struct mdio_xpcs_args *xpcs; - - for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - mdiodev = mdio_device_create(new_bus, addr); - if (IS_ERR(mdiodev)) - continue; - - xpcs = xpcs_create(mdiodev, mode); - if (IS_ERR_OR_NULL(xpcs)) { - mdio_device_free(mdiodev); - continue; - } - - priv->hw->xpcs = xpcs; - break; - } - - if (!priv->hw->xpcs) { - dev_warn(dev, "No XPCS found\n"); - err = -ENODEV; - goto no_xpcs_found; - } - } - bus_register_done: priv->mii = new_bus; return 0; -no_xpcs_found: no_phy_found: mdiobus_unregister(new_bus); bus_register_fail: -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> To: Jose.Abreu@synopsys.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, kuba@kernel.org, netdev@vger.kernel.org, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, davem@davemloft.net, mcoquelin.stm32@gmail.com, weifeng.voon@intel.com, boon.leong.ong@intel.com, tee.min.tan@intel.com, vee.khee.wong@linux.intel.com, vee.khee.wong@intel.com, michael.wei.hong.sit@intel.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, vladimir.oltean@nxp.com Subject: [PATCH net-next v6 1/3] net: stmmac: split xPCS setup from mdio register Date: Tue, 8 Jun 2021 11:51:56 +0800 [thread overview] Message-ID: <20210608035158.4869-2-michael.wei.hong.sit@intel.com> (raw) In-Reply-To: <20210608035158.4869-1-michael.wei.hong.sit@intel.com> From: Voon Weifeng <weifeng.voon@intel.com> This patch is a preparation patch for the enabling of Intel mGbE 2.5Gbps link speed. The Intel mGbR link speed configuration (1G/2.5G) is depends on a mdio ADHOC register which can be configured in the bios menu. As PHY interface might be different for 1G and 2.5G, the mdio bus need be ready to check the link speed and select the PHY interface before probing the xPCS. Signed-off-by: Voon Weifeng <weifeng.voon@intel.com> Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++ .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 64 ++++++++++--------- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index b6cd43eda7ac..fd7212afc543 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -311,6 +311,7 @@ enum stmmac_state { int stmmac_mdio_unregister(struct net_device *ndev); int stmmac_mdio_register(struct net_device *ndev); int stmmac_mdio_reset(struct mii_bus *mii); +int stmmac_xpcs_setup(struct mii_bus *mii); void stmmac_set_ethtool_ops(struct net_device *netdev); void stmmac_ptp_register(struct stmmac_priv *priv); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 0a266fa0af7e..af406ea3dd46 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6993,6 +6993,14 @@ int stmmac_dvr_probe(struct device *device, } } + if (priv->plat->mdio_bus_data) { + if (priv->plat->mdio_bus_data->has_xpcs) { + ret = stmmac_xpcs_setup(priv->mii); + if (ret) + goto error_xpcs_setup; + } + } + ret = stmmac_phy_setup(priv); if (ret) { netdev_err(ndev, "failed to setup phy (%d)\n", ret); @@ -7029,6 +7037,7 @@ int stmmac_dvr_probe(struct device *device, unregister_netdev(ndev); error_netdev_register: phylink_destroy(priv->phylink); +error_xpcs_setup: error_phy_setup: if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 6312a152c8ad..bc900e240da2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -397,6 +397,41 @@ int stmmac_mdio_reset(struct mii_bus *bus) return 0; } +int stmmac_xpcs_setup(struct mii_bus *bus) +{ + int mode, addr; + struct net_device *ndev = bus->priv; + struct mdio_xpcs_args *xpcs; + struct stmmac_priv *priv; + struct mdio_device *mdiodev; + + priv = netdev_priv(ndev); + mode = priv->plat->phy_interface; + + /* Try to probe the XPCS by scanning all addresses. */ + for (addr = 0; addr < PHY_MAX_ADDR; addr++) { + mdiodev = mdio_device_create(bus, addr); + if (IS_ERR(mdiodev)) + continue; + + xpcs = xpcs_create(mdiodev, mode); + if (IS_ERR_OR_NULL(xpcs)) { + mdio_device_free(mdiodev); + continue; + } + + priv->hw->xpcs = xpcs; + break; + } + + if (!priv->hw->xpcs) { + dev_warn(priv->device, "No xPCS found\n"); + return -ENODEV; + } + + return 0; +} + /** * stmmac_mdio_register * @ndev: net device structure @@ -501,40 +536,11 @@ int stmmac_mdio_register(struct net_device *ndev) goto no_phy_found; } - /* Try to probe the XPCS by scanning all addresses. */ - if (mdio_bus_data->has_xpcs) { - int mode = priv->plat->phy_interface; - struct mdio_device *mdiodev; - struct mdio_xpcs_args *xpcs; - - for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - mdiodev = mdio_device_create(new_bus, addr); - if (IS_ERR(mdiodev)) - continue; - - xpcs = xpcs_create(mdiodev, mode); - if (IS_ERR_OR_NULL(xpcs)) { - mdio_device_free(mdiodev); - continue; - } - - priv->hw->xpcs = xpcs; - break; - } - - if (!priv->hw->xpcs) { - dev_warn(dev, "No XPCS found\n"); - err = -ENODEV; - goto no_xpcs_found; - } - } - bus_register_done: priv->mii = new_bus; return 0; -no_xpcs_found: no_phy_found: mdiobus_unregister(new_bus); bus_register_fail: -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-06-08 3:56 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-08 3:51 [PATCH net-next v6 0/3] Enable 2.5Gbps speed for stmmac Michael Sit Wei Hong 2021-06-08 3:51 ` Michael Sit Wei Hong 2021-06-08 3:51 ` Michael Sit Wei Hong [this message] 2021-06-08 3:51 ` [PATCH net-next v6 1/3] net: stmmac: split xPCS setup from mdio register Michael Sit Wei Hong 2021-06-08 3:51 ` [PATCH net-next v6 2/3] net: pcs: add 2500BASEX support for Intel mGbE controller Michael Sit Wei Hong 2021-06-08 3:51 ` Michael Sit Wei Hong 2021-06-08 3:51 ` [PATCH net-next v6 3/3] net: stmmac: enable Intel mGbE 2.5Gbps link speed Michael Sit Wei Hong 2021-06-08 3:51 ` Michael Sit Wei Hong 2021-06-08 21:40 ` [PATCH net-next v6 0/3] Enable 2.5Gbps speed for stmmac patchwork-bot+netdevbpf 2021-06-08 21:40 ` patchwork-bot+netdevbpf
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210608035158.4869-2-michael.wei.hong.sit@intel.com \ --to=michael.wei.hong.sit@intel.com \ --cc=Jose.Abreu@synopsys.com \ --cc=alexandre.torgue@foss.st.com \ --cc=andrew@lunn.ch \ --cc=boon.leong.ong@intel.com \ --cc=davem@davemloft.net \ --cc=hkallweit1@gmail.com \ --cc=kuba@kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-stm32@st-md-mailman.stormreply.com \ --cc=linux@armlinux.org.uk \ --cc=mcoquelin.stm32@gmail.com \ --cc=netdev@vger.kernel.org \ --cc=peppe.cavallaro@st.com \ --cc=tee.min.tan@intel.com \ --cc=vee.khee.wong@intel.com \ --cc=vee.khee.wong@linux.intel.com \ --cc=vladimir.oltean@nxp.com \ --cc=weifeng.voon@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.