From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: "Clément Léger" <clement.leger@bootlin.com>
Cc: "Sergey Shtylyov" <s.shtylyov@omp.ru>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Magnus Damm" <magnus.damm@gmail.com>,
"Giuseppe Cavallaro" <peppe.cavallaro@st.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Jose Abreu" <joabreu@synopsys.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Wong Vee Khee" <veekhee@apple.com>,
"Kurt Kanzenbach" <kurt@linutronix.de>,
"Revanth Kumar Uppala" <ruppala@nvidia.com>,
"Tan Tee Min" <tee.min.tan@linux.intel.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Herve Codina" <herve.codina@bootlin.com>,
"Miquèl Raynal" <miquel.raynal@bootlin.com>,
"Milan Stevanovic" <milan.stevanovic@se.com>,
"Jimmy Lalande" <jimmy.lalande@se.com>,
"Pascal Eberhard" <pascal.eberhard@se.com>,
"Mohammad Athari Bin Ismail" <mohammad.athari.ismail@intel.com>,
"Jon Hunter" <jonathanh@nvidia.com>,
netdev@vger.kernel.org, linux-renesas-soc@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
Subject: Re: [PATCH net-next v2 5/6] net: stmmac: add support for RZ/N1 GMAC
Date: Thu, 9 Feb 2023 16:51:44 +0000 [thread overview]
Message-ID: <Y+UkoNpA9NiXlGmT@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230208164203.378153-6-clement.leger@bootlin.com>
On Wed, Feb 08, 2023 at 05:42:02PM +0100, Clément Léger wrote:
> Add support for Renesas RZ/N1 GMAC. This support uses a custom PCS (MIIC)
> which is handle by parsing the pcs-handle device tree property.
>
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++
> drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
> .../net/ethernet/stmicro/stmmac/dwmac-rzn1.c | 120 ++++++++++++++++++
> 3 files changed, 132 insertions(+)
> create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> index f77511fe4e87..be5429b7e192 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> @@ -153,6 +153,17 @@ config DWMAC_ROCKCHIP
> This selects the Rockchip RK3288 SoC glue layer support for
> the stmmac device driver.
>
> +config DWMAC_RZN1
> + tristate "Renesas RZ/N1 dwmac support"
> + default ARCH_RZN1
> + depends on OF && (ARCH_RZN1 || COMPILE_TEST)
> + select PCS_RZN1_MIIC
> + help
> + Support for Ethernet controller on Renesas RZ/N1 SoC family.
> +
> + This selects the Renesas RZ/N1 SoC glue layer support for
> + the stmmac device driver.
> +
> config DWMAC_SOCFPGA
> tristate "SOCFPGA dwmac support"
> default ARCH_INTEL_SOCFPGA
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
> index 057e4bab5c08..53a0f74c1cb5 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Makefile
> +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
> @@ -22,6 +22,7 @@ obj-$(CONFIG_DWMAC_MESON) += dwmac-meson.o dwmac-meson8b.o
> obj-$(CONFIG_DWMAC_OXNAS) += dwmac-oxnas.o
> obj-$(CONFIG_DWMAC_QCOM_ETHQOS) += dwmac-qcom-ethqos.o
> obj-$(CONFIG_DWMAC_ROCKCHIP) += dwmac-rk.o
> +obj-$(CONFIG_DWMAC_RZN1) += dwmac-rzn1.o
> obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o
> obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o
> obj-$(CONFIG_DWMAC_STM32) += dwmac-stm32.o
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c
> new file mode 100644
> index 000000000000..82118d8cb50e
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c
> @@ -0,0 +1,120 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2022 Schneider-Electric
> + *
> + * Clément Léger <clement.leger@bootlin.com>
> + */
> +
> +#include <linux/of.h>
> +#include <linux/pcs-rzn1-miic.h>
> +#include <linux/phylink.h>
> +#include <linux/platform_device.h>
> +
> +#include "stmmac_platform.h"
> +#include "stmmac.h"
> +
> +struct rzn1_dwmac {
> + struct phylink_pcs *pcs;
> +};
I don't understand why you need this...
> +
> +static int rzn1_dt_parse(struct device *dev, struct rzn1_dwmac *dwmac)
You could pass a pointer to struct plat_stmmacenet_data into here, and
have it fill in your new ->pcs directly, and save the extra devm
allocations.
> +{
> + struct device_node *np = dev->of_node;
> + struct device_node *pcs_node;
> + struct phylink_pcs *pcs;
> + int ret;
> +
> + pcs_node = of_parse_phandle(np, "pcs-handle", 0);
> + if (!pcs_node)
> + return 0;
> +
> + pcs = miic_create(dev, pcs_node);
Don't you need to put pcs_node?
> + if (IS_ERR(pcs))
> + return PTR_ERR(pcs);
> +
> + ret = miic_early_setup(pcs, dev);
> + if (ret) {
> + miic_destroy(pcs);
> + return ret;
> + }
> +
> + dwmac->pcs = pcs;
> +
> + return 0;
> +}
> +
> +static int rzn1_dwmac_probe(struct platform_device *pdev)
> +{
> + struct plat_stmmacenet_data *plat_dat;
> + struct stmmac_resources stmmac_res;
> + struct device *dev = &pdev->dev;
> + struct rzn1_dwmac *dwmac;
> + int ret;
> +
> + ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> + if (ret)
> + return ret;
> +
> + plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
> + if (IS_ERR(plat_dat))
> + return PTR_ERR(plat_dat);
> +
> + dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL);
> + if (!dwmac) {
> + ret = -ENOMEM;
> + goto err_remove_config_dt;
> + }
> +
> + ret = rzn1_dt_parse(dev, dwmac);
> + if (ret)
> + goto err_remove_config_dt;
> +
> + plat_dat->bsp_priv = dwmac;
You could set this to point back to plat_dat.
> + plat_dat->pcs = dwmac->pcs;
> +
> + ret = stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
> + if (ret)
> + goto err_free_pcs;
> +
> + return 0;
> +
> +err_free_pcs:
> + if (dwmac->pcs)
> + miic_destroy(dwmac->pcs);
> +
> +err_remove_config_dt:
> + stmmac_remove_config_dt(pdev, plat_dat);
> +
> + return ret;
> +}
> +
> +static int rzn1_dwmac_remove(struct platform_device *pdev)
> +{
> + struct rzn1_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
... which means you get plat_dat back here...
> + int ret = stmmac_dvr_remove(&pdev->dev);
> +
> + if (dwmac->pcs)
> + miic_destroy(dwmac->pcs);
and can still destroy the pcs.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
WARNING: multiple messages have this Message-ID (diff)
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: "Clément Léger" <clement.leger@bootlin.com>
Cc: "Sergey Shtylyov" <s.shtylyov@omp.ru>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Magnus Damm" <magnus.damm@gmail.com>,
"Giuseppe Cavallaro" <peppe.cavallaro@st.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Jose Abreu" <joabreu@synopsys.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Wong Vee Khee" <veekhee@apple.com>,
"Kurt Kanzenbach" <kurt@linutronix.de>,
"Revanth Kumar Uppala" <ruppala@nvidia.com>,
"Tan Tee Min" <tee.min.tan@linux.intel.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Herve Codina" <herve.codina@bootlin.com>,
"Miquèl Raynal" <miquel.raynal@bootlin.com>,
"Milan Stevanovic" <milan.stevanovic@se.com>,
"Jimmy Lalande" <jimmy.lalande@se.com>,
"Pascal Eberhard" <pascal.eberhard@se.com>,
"Mohammad Athari Bin Ismail" <mohammad.athari.ismail@intel.com>,
"Jon Hunter" <jonathanh@nvidia.com>,
netdev@vger.kernel.org, linux-renesas-soc@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
Subject: Re: [PATCH net-next v2 5/6] net: stmmac: add support for RZ/N1 GMAC
Date: Thu, 9 Feb 2023 16:51:44 +0000 [thread overview]
Message-ID: <Y+UkoNpA9NiXlGmT@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230208164203.378153-6-clement.leger@bootlin.com>
On Wed, Feb 08, 2023 at 05:42:02PM +0100, Clément Léger wrote:
> Add support for Renesas RZ/N1 GMAC. This support uses a custom PCS (MIIC)
> which is handle by parsing the pcs-handle device tree property.
>
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++
> drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
> .../net/ethernet/stmicro/stmmac/dwmac-rzn1.c | 120 ++++++++++++++++++
> 3 files changed, 132 insertions(+)
> create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> index f77511fe4e87..be5429b7e192 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> @@ -153,6 +153,17 @@ config DWMAC_ROCKCHIP
> This selects the Rockchip RK3288 SoC glue layer support for
> the stmmac device driver.
>
> +config DWMAC_RZN1
> + tristate "Renesas RZ/N1 dwmac support"
> + default ARCH_RZN1
> + depends on OF && (ARCH_RZN1 || COMPILE_TEST)
> + select PCS_RZN1_MIIC
> + help
> + Support for Ethernet controller on Renesas RZ/N1 SoC family.
> +
> + This selects the Renesas RZ/N1 SoC glue layer support for
> + the stmmac device driver.
> +
> config DWMAC_SOCFPGA
> tristate "SOCFPGA dwmac support"
> default ARCH_INTEL_SOCFPGA
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
> index 057e4bab5c08..53a0f74c1cb5 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Makefile
> +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
> @@ -22,6 +22,7 @@ obj-$(CONFIG_DWMAC_MESON) += dwmac-meson.o dwmac-meson8b.o
> obj-$(CONFIG_DWMAC_OXNAS) += dwmac-oxnas.o
> obj-$(CONFIG_DWMAC_QCOM_ETHQOS) += dwmac-qcom-ethqos.o
> obj-$(CONFIG_DWMAC_ROCKCHIP) += dwmac-rk.o
> +obj-$(CONFIG_DWMAC_RZN1) += dwmac-rzn1.o
> obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o
> obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o
> obj-$(CONFIG_DWMAC_STM32) += dwmac-stm32.o
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c
> new file mode 100644
> index 000000000000..82118d8cb50e
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c
> @@ -0,0 +1,120 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2022 Schneider-Electric
> + *
> + * Clément Léger <clement.leger@bootlin.com>
> + */
> +
> +#include <linux/of.h>
> +#include <linux/pcs-rzn1-miic.h>
> +#include <linux/phylink.h>
> +#include <linux/platform_device.h>
> +
> +#include "stmmac_platform.h"
> +#include "stmmac.h"
> +
> +struct rzn1_dwmac {
> + struct phylink_pcs *pcs;
> +};
I don't understand why you need this...
> +
> +static int rzn1_dt_parse(struct device *dev, struct rzn1_dwmac *dwmac)
You could pass a pointer to struct plat_stmmacenet_data into here, and
have it fill in your new ->pcs directly, and save the extra devm
allocations.
> +{
> + struct device_node *np = dev->of_node;
> + struct device_node *pcs_node;
> + struct phylink_pcs *pcs;
> + int ret;
> +
> + pcs_node = of_parse_phandle(np, "pcs-handle", 0);
> + if (!pcs_node)
> + return 0;
> +
> + pcs = miic_create(dev, pcs_node);
Don't you need to put pcs_node?
> + if (IS_ERR(pcs))
> + return PTR_ERR(pcs);
> +
> + ret = miic_early_setup(pcs, dev);
> + if (ret) {
> + miic_destroy(pcs);
> + return ret;
> + }
> +
> + dwmac->pcs = pcs;
> +
> + return 0;
> +}
> +
> +static int rzn1_dwmac_probe(struct platform_device *pdev)
> +{
> + struct plat_stmmacenet_data *plat_dat;
> + struct stmmac_resources stmmac_res;
> + struct device *dev = &pdev->dev;
> + struct rzn1_dwmac *dwmac;
> + int ret;
> +
> + ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> + if (ret)
> + return ret;
> +
> + plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
> + if (IS_ERR(plat_dat))
> + return PTR_ERR(plat_dat);
> +
> + dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL);
> + if (!dwmac) {
> + ret = -ENOMEM;
> + goto err_remove_config_dt;
> + }
> +
> + ret = rzn1_dt_parse(dev, dwmac);
> + if (ret)
> + goto err_remove_config_dt;
> +
> + plat_dat->bsp_priv = dwmac;
You could set this to point back to plat_dat.
> + plat_dat->pcs = dwmac->pcs;
> +
> + ret = stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
> + if (ret)
> + goto err_free_pcs;
> +
> + return 0;
> +
> +err_free_pcs:
> + if (dwmac->pcs)
> + miic_destroy(dwmac->pcs);
> +
> +err_remove_config_dt:
> + stmmac_remove_config_dt(pdev, plat_dat);
> +
> + return ret;
> +}
> +
> +static int rzn1_dwmac_remove(struct platform_device *pdev)
> +{
> + struct rzn1_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
... which means you get plat_dat back here...
> + int ret = stmmac_dvr_remove(&pdev->dev);
> +
> + if (dwmac->pcs)
> + miic_destroy(dwmac->pcs);
and can still destroy the pcs.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
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:[~2023-02-09 16:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-08 16:41 [PATCH net-next v2 0/6] net: stmmac: add renesas,rzn1-gmac support Clément Léger
2023-02-08 16:41 ` Clément Léger
2023-02-08 16:41 ` [PATCH net-next v2 1/6] net: pcs: rzn1-miic: add pcs_early_setup() function Clément Léger
2023-02-08 16:41 ` Clément Léger
2023-02-08 16:41 ` [PATCH net-next v2 2/6] net: stmmac: add support to use a generic phylink_pcs as PCS Clément Léger
2023-02-08 16:41 ` Clément Léger
2023-02-08 16:42 ` [PATCH net-next v2 3/6] net: stmmac: add support to provide pcs from platform data Clément Léger
2023-02-08 16:42 ` Clément Léger
2023-02-08 18:21 ` Sergey Shtylyov
2023-02-08 18:21 ` Sergey Shtylyov
2023-02-08 16:42 ` [PATCH net-next v2 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support Clément Léger
2023-02-08 16:42 ` Clément Léger
2023-02-08 19:51 ` Krzysztof Kozlowski
2023-02-08 19:51 ` Krzysztof Kozlowski
2023-02-08 16:42 ` [PATCH net-next v2 5/6] net: stmmac: add support for RZ/N1 GMAC Clément Léger
2023-02-08 16:42 ` Clément Léger
2023-02-09 16:51 ` Russell King (Oracle) [this message]
2023-02-09 16:51 ` Russell King (Oracle)
2023-02-08 16:42 ` [PATCH net-next v2 6/6] ARM: dts: r9a06g032: describe GMAC1 Clément Léger
2023-02-08 16:42 ` Clément Léger
2023-02-08 19:54 ` Krzysztof Kozlowski
2023-02-08 19:54 ` Krzysztof Kozlowski
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=Y+UkoNpA9NiXlGmT@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=alexandre.torgue@foss.st.com \
--cc=clement.leger@bootlin.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=geert+renesas@glider.be \
--cc=herve.codina@bootlin.com \
--cc=jimmy.lalande@se.com \
--cc=joabreu@synopsys.com \
--cc=jonathanh@nvidia.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuba@kernel.org \
--cc=kurt@linutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=magnus.damm@gmail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=milan.stevanovic@se.com \
--cc=miquel.raynal@bootlin.com \
--cc=mohammad.athari.ismail@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pascal.eberhard@se.com \
--cc=peppe.cavallaro@st.com \
--cc=robh+dt@kernel.org \
--cc=ruppala@nvidia.com \
--cc=s.shtylyov@omp.ru \
--cc=tee.min.tan@linux.intel.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=veekhee@apple.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.