From: Romain Gantois <romain.gantois@bootlin.com>
To: "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>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Chen Wang" <unicorn_wang@outlook.com>,
"Inochi Amaoto" <inochiama@outlook.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Richard Cochran" <richardcochran@gmail.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Emil Renner Berthing" <emil.renner.berthing@canonical.com>,
"Jisheng Zhang" <jszhang@kernel.org>,
"Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>,
"Clément Léger" <clement.leger@bootlin.com>,
"Simon Horman" <horms@kernel.org>, "Furong Xu" <0x1207@gmail.com>,
"Serge Semin" <fancer.lancer@gmail.com>,
"Lothar Rubusch" <l.rubusch@gmail.com>,
"Suraj Jaiswal" <quic_jsuraj@quicinc.com>,
"Joe Hattori" <joe@pf.is.s.u-tokyo.ac.jp>,
"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>,
"Giuseppe Cavallaro" <peppe.cavallaro@st.com>,
"Jose Abreu" <joabreu@synopsys.com>,
"Inochi Amaoto" <inochiama@gmail.com>
Cc: Inochi Amaoto <inochiama@gmail.com>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-riscv@lists.infradead.org, Yixun Lan <dlan@gentoo.org>,
Longbin Li <looong.bin@gmail.com>
Subject: Re: [PATCH net-next v4 3/3] net: stmmac: Add glue layer for Sophgo SG2044 SoC
Date: Mon, 10 Feb 2025 12:01:56 +0100 [thread overview]
Message-ID: <2379380.ElGaqSPkdT@fw-rgant> (raw)
In-Reply-To: <20250209013054.816580-4-inochiama@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3939 bytes --]
Hello Inochi,
On dimanche 9 février 2025 02:30:52 heure normale d’Europe centrale Inochi
Amaoto wrote:
> Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC.
...
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
> @@ -0,0 +1,105 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Sophgo DWMAC platform driver
> + *
> + * Copyright (C) 2024 Inochi Amaoto <inochiama@gmail.com>
> + */
> +
> +#include <linux/bits.h>
It doesn't look like this include is used, could you please remove it?
> +#include <linux/mod_devicetable.h>
> +#include <linux/phy.h>
> +#include <linux/platform_device.h>
> +
> +#include "stmmac_platform.h"
> +
> +struct sophgo_dwmac {
> + struct device *dev;
> + struct clk *clk_tx;
> +};
> +
> +static void sophgo_dwmac_fix_mac_speed(void *priv, unsigned int speed,
> unsigned int mode) +{
> + struct sophgo_dwmac *dwmac = priv;
> + long rate;
> + int ret;
> +
> + rate = rgmii_clock(speed);
> + if (rate < 0) {
> + dev_err(dwmac->dev, "invalid speed %u\n", speed);
> + return;
> + }
> +
> + ret = clk_set_rate(dwmac->clk_tx, rate);
> + if (ret)
> + dev_err(dwmac->dev, "failed to set tx rate %lu: %pe\n",
nit: shouldn't this be "%ld"?
> + rate, ERR_PTR(ret));
> +}
> +
> +static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
> + struct plat_stmmacenet_data *plat_dat,
> + struct stmmac_resources *stmmac_res)
> +{
> + struct sophgo_dwmac *dwmac;
> +
> + dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
> + if (!dwmac)
> + return -ENOMEM;
> +
> + dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx");
> + if (IS_ERR(dwmac->clk_tx))
> + return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx),
> + "failed to get tx clock\n");
> +
> + dwmac->dev = &pdev->dev;
> + plat_dat->bsp_priv = dwmac;
> + plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE;
> + plat_dat->fix_mac_speed = sophgo_dwmac_fix_mac_speed;
> + plat_dat->multicast_filter_bins = 0;
> + plat_dat->unicast_filter_entries = 1;
> +
> + return 0;
> +}
> +
> +static int sophgo_dwmac_probe(struct platform_device *pdev)
> +{
> + struct plat_stmmacenet_data *plat_dat;
> + struct stmmac_resources stmmac_res;
nit: I think adding "struct device *dev = &pdev->dev;" here would
be better than repeating "&pdev->dev" later on.
> + int ret;
> +
> + ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "failed to get resources\n");
This error message is a bit too vague, maybe replace it with "failed to get
platform resources"?
> +
> + plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
> + if (IS_ERR(plat_dat))
> + return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat),
> + "dt configuration failed\n");
This error message is a bit misleading IMO, I would replace it with
something like "failed to parse device-tree parameters".
> +
> + ret = sophgo_sg2044_dwmac_init(pdev, plat_dat, &stmmac_res);
> + if (ret)
> + return ret;
> +
> + return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
> +}
> +
> +static const struct of_device_id sophgo_dwmac_match[] = {
> + { .compatible = "sophgo,sg2044-dwmac" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, sophgo_dwmac_match);
> +
> +static struct platform_driver sophgo_dwmac_driver = {
> + .probe = sophgo_dwmac_probe,
> + .remove = stmmac_pltfr_remove,
> + .driver = {
> + .name = "sophgo-dwmac",
> + .pm = &stmmac_pltfr_pm_ops,
> + .of_match_table = sophgo_dwmac_match,
> + },
> +};
> +module_platform_driver(sophgo_dwmac_driver);
> +
> +MODULE_AUTHOR("Inochi Amaoto <inochiama@gmail.com>");
> +MODULE_DESCRIPTION("Sophgo DWMAC platform driver");
> +MODULE_LICENSE("GPL");
Thanks,
--
Romain Gantois, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Romain Gantois <romain.gantois@bootlin.com>
To: "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>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Chen Wang" <unicorn_wang@outlook.com>,
"Inochi Amaoto" <inochiama@outlook.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Richard Cochran" <richardcochran@gmail.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Emil Renner Berthing" <emil.renner.berthing@canonical.com>,
"Jisheng Zhang" <jszhang@kernel.org>,
"Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>,
"Clément Léger" <clement.leger@bootlin.com>,
"Simon Horman" <horms@kernel.org>, "Furong Xu" <0x1207@gmail.com>,
"Serge Semin" <fancer.lancer@gmail.com>,
"Lothar Rubusch" <l.rubusch@gmail.com>,
"Suraj Jaiswal" <quic_jsuraj@quicinc.com>,
"Joe Hattori" <joe@pf.is.s.u-tokyo.ac.jp>,
"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>,
"Giuseppe Cavallaro" <peppe.cavallaro@st.com>,
"Jose Abreu" <joabreu@synopsys.com>,
"Inochi Amaoto" <inochiama@gmail.com>
Cc: Inochi Amaoto <inochiama@gmail.com>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-riscv@lists.infradead.org, Yixun Lan <dlan@gentoo.org>,
Longbin Li <looong.bin@gmail.com>
Subject: Re: [PATCH net-next v4 3/3] net: stmmac: Add glue layer for Sophgo SG2044 SoC
Date: Mon, 10 Feb 2025 12:01:56 +0100 [thread overview]
Message-ID: <2379380.ElGaqSPkdT@fw-rgant> (raw)
In-Reply-To: <20250209013054.816580-4-inochiama@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 3939 bytes --]
Hello Inochi,
On dimanche 9 février 2025 02:30:52 heure normale d’Europe centrale Inochi
Amaoto wrote:
> Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC.
...
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
> @@ -0,0 +1,105 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Sophgo DWMAC platform driver
> + *
> + * Copyright (C) 2024 Inochi Amaoto <inochiama@gmail.com>
> + */
> +
> +#include <linux/bits.h>
It doesn't look like this include is used, could you please remove it?
> +#include <linux/mod_devicetable.h>
> +#include <linux/phy.h>
> +#include <linux/platform_device.h>
> +
> +#include "stmmac_platform.h"
> +
> +struct sophgo_dwmac {
> + struct device *dev;
> + struct clk *clk_tx;
> +};
> +
> +static void sophgo_dwmac_fix_mac_speed(void *priv, unsigned int speed,
> unsigned int mode) +{
> + struct sophgo_dwmac *dwmac = priv;
> + long rate;
> + int ret;
> +
> + rate = rgmii_clock(speed);
> + if (rate < 0) {
> + dev_err(dwmac->dev, "invalid speed %u\n", speed);
> + return;
> + }
> +
> + ret = clk_set_rate(dwmac->clk_tx, rate);
> + if (ret)
> + dev_err(dwmac->dev, "failed to set tx rate %lu: %pe\n",
nit: shouldn't this be "%ld"?
> + rate, ERR_PTR(ret));
> +}
> +
> +static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
> + struct plat_stmmacenet_data *plat_dat,
> + struct stmmac_resources *stmmac_res)
> +{
> + struct sophgo_dwmac *dwmac;
> +
> + dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
> + if (!dwmac)
> + return -ENOMEM;
> +
> + dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx");
> + if (IS_ERR(dwmac->clk_tx))
> + return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx),
> + "failed to get tx clock\n");
> +
> + dwmac->dev = &pdev->dev;
> + plat_dat->bsp_priv = dwmac;
> + plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE;
> + plat_dat->fix_mac_speed = sophgo_dwmac_fix_mac_speed;
> + plat_dat->multicast_filter_bins = 0;
> + plat_dat->unicast_filter_entries = 1;
> +
> + return 0;
> +}
> +
> +static int sophgo_dwmac_probe(struct platform_device *pdev)
> +{
> + struct plat_stmmacenet_data *plat_dat;
> + struct stmmac_resources stmmac_res;
nit: I think adding "struct device *dev = &pdev->dev;" here would
be better than repeating "&pdev->dev" later on.
> + int ret;
> +
> + ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "failed to get resources\n");
This error message is a bit too vague, maybe replace it with "failed to get
platform resources"?
> +
> + plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
> + if (IS_ERR(plat_dat))
> + return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat),
> + "dt configuration failed\n");
This error message is a bit misleading IMO, I would replace it with
something like "failed to parse device-tree parameters".
> +
> + ret = sophgo_sg2044_dwmac_init(pdev, plat_dat, &stmmac_res);
> + if (ret)
> + return ret;
> +
> + return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
> +}
> +
> +static const struct of_device_id sophgo_dwmac_match[] = {
> + { .compatible = "sophgo,sg2044-dwmac" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, sophgo_dwmac_match);
> +
> +static struct platform_driver sophgo_dwmac_driver = {
> + .probe = sophgo_dwmac_probe,
> + .remove = stmmac_pltfr_remove,
> + .driver = {
> + .name = "sophgo-dwmac",
> + .pm = &stmmac_pltfr_pm_ops,
> + .of_match_table = sophgo_dwmac_match,
> + },
> +};
> +module_platform_driver(sophgo_dwmac_driver);
> +
> +MODULE_AUTHOR("Inochi Amaoto <inochiama@gmail.com>");
> +MODULE_DESCRIPTION("Sophgo DWMAC platform driver");
> +MODULE_LICENSE("GPL");
Thanks,
--
Romain Gantois, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-02-10 11:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-09 1:30 [PATCH net-next v4 0/3] riscv: sophgo: Add ethernet support for SG2044 Inochi Amaoto
2025-02-09 1:30 ` Inochi Amaoto
2025-02-09 1:30 ` [PATCH net-next v4 1/3] dt-bindings: net: Add support for Sophgo SG2044 dwmac Inochi Amaoto
2025-02-09 1:30 ` Inochi Amaoto
2025-02-09 1:30 ` [PATCH net-next v4 2/3] net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string Inochi Amaoto
2025-02-09 1:30 ` Inochi Amaoto
2025-02-10 10:04 ` Romain Gantois
2025-02-10 10:04 ` Romain Gantois
2025-02-09 1:30 ` [PATCH net-next v4 3/3] net: stmmac: Add glue layer for Sophgo SG2044 SoC Inochi Amaoto
2025-02-09 1:30 ` Inochi Amaoto
2025-02-10 11:01 ` Romain Gantois [this message]
2025-02-10 11:01 ` Romain Gantois
2025-02-11 0:47 ` Inochi Amaoto
2025-02-11 0:47 ` 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=2379380.ElGaqSPkdT@fw-rgant \
--to=romain.gantois@bootlin.com \
--cc=0x1207@gmail.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=aou@eecs.berkeley.edu \
--cc=bartosz.golaszewski@linaro.org \
--cc=clement.leger@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=dlan@gentoo.org \
--cc=edumazet@google.com \
--cc=emil.renner.berthing@canonical.com \
--cc=fancer.lancer@gmail.com \
--cc=horms@kernel.org \
--cc=inochiama@gmail.com \
--cc=inochiama@outlook.com \
--cc=jan.petrous@oss.nxp.com \
--cc=joabreu@synopsys.com \
--cc=joe@pf.is.s.u-tokyo.ac.jp \
--cc=jszhang@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=l.rubusch@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.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=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peppe.cavallaro@st.com \
--cc=quic_jsuraj@quicinc.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=unicorn_wang@outlook.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: link
Be 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.