From: Andrew Lunn <andrew@lunn.ch>
To: Minda Chen <minda.chen@starfivetech.com>
Cc: Emil Renner Berthing <kernel@esmil.dk>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
Russell King <rmk+kernel@armlinux.org.uk>
Subject: Re: [net-next v1] net: stmmac: starfive: Add serdes PHY init/deinit function
Date: Tue, 15 Apr 2025 14:08:55 +0200 [thread overview]
Message-ID: <840346cf-52a3-4e40-bf38-9d66231366d7@lunn.ch> (raw)
In-Reply-To: <20250410070453.61178-1-minda.chen@starfivetech.com>
> +static int starfive_dwmac_serdes_powerup(struct net_device *ndev, void *priv)
> +{
> + struct starfive_dwmac *dwmac = priv;
> + int ret;
> +
> + ret = phy_init(dwmac->serdes_phy);
> + if (ret)
> + return ret;
> +
> + return phy_power_on(dwmac->serdes_phy);
> +}
static int qcom_ethqos_serdes_powerup(struct net_device *ndev, void *priv)
{
struct qcom_ethqos *ethqos = priv;
int ret;
ret = phy_init(ethqos->serdes_phy);
if (ret)
return ret;
ret = phy_power_on(ethqos->serdes_phy);
if (ret)
return ret;
return phy_set_speed(ethqos->serdes_phy, ethqos->speed);
}
Similar?
> +static void starfive_dwmac_serdes_powerdown(struct net_device *ndev, void *priv)
> +{
> + struct starfive_dwmac *dwmac = priv;
> +
> + phy_power_off(dwmac->serdes_phy);
> + phy_exit(dwmac->serdes_phy);
> +}
static void qcom_ethqos_serdes_powerdown(struct net_device *ndev, void *priv)
{
struct qcom_ethqos *ethqos = priv;
phy_power_off(ethqos->serdes_phy);
phy_exit(ethqos->serdes_phy);
}
Pretty much cut & paste.
> static int starfive_dwmac_probe(struct platform_device *pdev)
> {
> struct plat_stmmacenet_data *plat_dat;
> @@ -102,6 +125,11 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
> if (!dwmac)
> return -ENOMEM;
>
> + dwmac->serdes_phy = devm_phy_optional_get(&pdev->dev, NULL);
> + if (IS_ERR(dwmac->serdes_phy))
> + return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->serdes_phy),
> + "Failed to get serdes phy\n");
> +
ethqos->serdes_phy = devm_phy_optional_get(dev, "serdes");
if (IS_ERR(ethqos->serdes_phy))
return dev_err_probe(dev, PTR_ERR(ethqos->serdes_phy),
"Failed to get serdes phy\n");
> dwmac->data = device_get_match_data(&pdev->dev);
>
> plat_dat->clk_tx_i = devm_clk_get_enabled(&pdev->dev, "tx");
> @@ -132,6 +160,11 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
> if (err)
> return err;
>
> + if (dwmac->serdes_phy) {
> + plat_dat->serdes_powerup = starfive_dwmac_serdes_powerup;
> + plat_dat->serdes_powerdown = starfive_dwmac_serdes_powerdown;
> + }
> +
if (ethqos->serdes_phy) {
plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup;
plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown;
}
I assume you have seen all the work Russell King has been doing
recently cleaning up all the copy/paste code between various glue
drivers. Please don't add to that mess. Please consider how you can
refactor the ethqos code to make is generic for any stmmac driver
which has a generic phy.
Andrew
---
pw-bot: cr
next prev parent reply other threads:[~2025-04-15 12:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 7:04 Minda Chen
2025-04-15 9:14 ` Paolo Abeni
2025-04-16 3:13 ` Minda Chen
2025-04-15 12:08 ` Andrew Lunn [this message]
2025-04-16 3:14 ` Minda Chen
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=840346cf-52a3-4e40-bf38-9d66231366d7@lunn.ch \
--to=andrew@lunn.ch \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel@esmil.dk \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=minda.chen@starfivetech.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rmk+kernel@armlinux.org.uk \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®