From: Yixun Lan <dlan@gentoo.org>
To: Inochi Amaoto <inochiama@gmail.com>
Cc: 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>,
Chen Wang <unicorn_wang@outlook.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Han Gao <rabenda.cn@gmail.com>, Icenowy Zheng <uwu@icenowy.me>,
Vivian Wang <wangruikang@iscas.ac.cn>, Yao Zi <ziyao@disroot.org>,
netdev@vger.kernel.org, sophgo@lists.linux.dev,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Longbin Li <looong.bin@gmail.com>
Subject: Re: [PATCH] net: stmmac: dwmac-sophgo: Add phy interface filter
Date: Sat, 18 Oct 2025 08:05:48 +0800 [thread overview]
Message-ID: <20251018000548-GYA1481334@gentoo.org> (raw)
In-Reply-To: <20251017011802.523140-1-inochiama@gmail.com>
Hi Inochi,
On 09:18 Fri 17 Oct , Inochi Amaoto wrote:
> As the SG2042 has an internal rx delay, the delay should be remove
s/remove/removed/
> when init the mac, otherwise the phy will be misconfigurated.
s/init/initialize/
>
> Fixes: 543009e2d4cd ("net: stmmac: dwmac-sophgo: Add support for Sophgo SG2042 SoC")
> Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> Tested-by: Han Gao <rabenda.cn@gmail.com>
> ---
> .../ethernet/stmicro/stmmac/dwmac-sophgo.c | 25 ++++++++++++++++++-
> 1 file changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
> index 3b7947a7a7ba..b2dee1399eb0 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
> @@ -7,6 +7,7 @@
>
> #include <linux/clk.h>
> #include <linux/module.h>
> +#include <linux/property.h>
> #include <linux/mod_devicetable.h>
> #include <linux/platform_device.h>
>
> @@ -29,8 +30,23 @@ static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
> return 0;
> }
>
> +static int sophgo_sg2042_set_mode(struct plat_stmmacenet_data *plat_dat)
> +{
> + switch (plat_dat->phy_interface) {
> + case PHY_INTERFACE_MODE_RGMII_ID:
> + plat_dat->phy_interface = PHY_INTERFACE_MODE_RGMII_TXID;
> + return 0;
> + case PHY_INTERFACE_MODE_RGMII_RXID:
> + plat_dat->phy_interface = PHY_INTERFACE_MODE_RGMII;
> + return 0;
> + default:
> + return -EINVAL;
> + }
> +}
> +
> static int sophgo_dwmac_probe(struct platform_device *pdev)
> {
> + int (*plat_set_mode)(struct plat_stmmacenet_data *plat_dat);
> struct plat_stmmacenet_data *plat_dat;
> struct stmmac_resources stmmac_res;
> struct device *dev = &pdev->dev;
> @@ -50,11 +66,18 @@ static int sophgo_dwmac_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> + plat_set_mode = device_get_match_data(&pdev->dev);
> + if (plat_set_mode) {
> + ret = plat_set_mode(plat_dat);
> + if (ret)
> + return ret;
> + }
> +
> return stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
> }
>
> static const struct of_device_id sophgo_dwmac_match[] = {
> - { .compatible = "sophgo,sg2042-dwmac" },
> + { .compatible = "sophgo,sg2042-dwmac", .data = sophgo_sg2042_set_mode },
I'd personally prefer to introduce a flag for this, it would be more readable and
maintainable, something like
struct sophgo_dwmac_compitable_data {
bool has_internal_rx_delay;
}
then.
if (data->has_internal_rx_delay)
sophgo_sg2042_set_mode(..)
> { .compatible = "sophgo,sg2044-dwmac" },
> { /* sentinel */ }
> };
> --
> 2.51.0
>
--
Yixun Lan (dlan)
next prev parent reply other threads:[~2025-10-18 0:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 1:18 [PATCH] net: stmmac: dwmac-sophgo: Add phy interface filter Inochi Amaoto
2025-10-17 18:16 ` Andrew Lunn
2025-10-18 0:42 ` Inochi Amaoto
2025-10-18 20:38 ` Andrew Lunn
2025-10-18 20:49 ` Russell King (Oracle)
2025-10-19 0:04 ` Andrew Lunn
2025-10-19 9:25 ` Russell King (Oracle)
2025-10-18 0:05 ` Yixun Lan [this message]
2025-10-18 0:43 ` Inochi Amaoto
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=20251018000548-GYA1481334@gentoo.org \
--to=dlan@gentoo.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=inochiama@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=looong.bin@gmail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rabenda.cn@gmail.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=sophgo@lists.linux.dev \
--cc=unicorn_wang@outlook.com \
--cc=uwu@icenowy.me \
--cc=wangruikang@iscas.ac.cn \
--cc=ziyao@disroot.org \
/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;
as well as URLs for NNTP newsgroup(s).