net: stmmac: add renesas,rzn1-gmac support
Subsystems (8)
Clément Léger
maintainerv2 cover net: stmmac: add renesas,rzn1-gmac support
The rzn1-gmac instance is connected to a PCS (MIIC). In order to use this pcs, add support in the sttmac driver to set a generic phylink pcs device instead of the xpcs only. Moreover, it adds support to provide a phylink pcs device from the stmmac platform data and use it with the driver. It also adds the bindings and the new rzn1-gmac driver that retrieve this pcs from the device-tree.
---
V2:
- Remove patch that moves phylink_start() earlier in init
- Add miic_early_qsetup() which allows initializing some miic port earlier to provide a RX clock to stmmac IP
- Call miic_early_setup() in rzn1 stmmac driver
- Fix bindings
Clément Léger (6):
net: pcs: rzn1-miic: add pcs_early_setup() function
net: stmmac: add support to use a generic phylink_pcs as PCS
net: stmmac: add support to provide pcs from platform data
dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support
net: stmmac: add support for RZ/N1 GMAC
ARM: dts: r9a06g032: describe GMAC1
.../bindings/net/renesas,rzn1-gmac.yaml | 67 ++++++++++ arch/arm/boot/dts/r9a06g032.dtsi | 18 +++ drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++ drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + drivers/net/ethernet/stmicro/stmmac/common.h | 2 + .../net/ethernet/stmicro/stmmac/dwmac-rzn1.c | 120 ++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 1 + drivers/net/pcs/pcs-rzn1-miic.c | 12 ++ include/linux/pcs-rzn1-miic.h | 3 + include/linux/stmmac.h | 1 + 11 files changed, 240 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c
Signature · 1 line
2.39.0
Clément Léger
maintainerPATCH v2 1/6 net: pcs: rzn1-miic: add pcs_early_setup() function
When using this PCS with the stmmac IP, if the pcs is not configured and enabled before setting up stmmac hardware, driver setup will fail due to the lack of input RGMII RX clock. Add pcs_early_setup() function which allows to configure the MIIC converter based on the "phy-mode" that is described in the device-tree.
--- drivers/net/pcs/pcs-rzn1-miic.c | 12 ++++++++++++ include/linux/pcs-rzn1-miic.h | 3 +++ 2 files changed, 15 insertions(+)
drivers/net/pcs/pcs-rzn1-miic.c +12 -0
@@ -288,6 +288,18 @@ static const struct phylink_pcs_ops miic_phylink_ops = { .pcs_link_up = miic_link_up, }; +int miic_early_setup (struct phylink_pcs *pcs,struct device *dev) +{ +int interface; + + interface =device_get_phy_mode (dev); +if (interface <0 ) +return interface; + +return miic_config (pcs,0 , interface,NULL , false); +} +EXPORT_SYMBOL (miic_early_setup); +struct phylink_pcs *miic_create (struct device *dev,struct device_node *np) {struct platform_device *pdev;
include/linux/pcs-rzn1-miic.h +3 -0
@@ -9,8 +9,11 @@#define __LINUX_PCS_MIIC_Hstruct phylink ; +struct phylink_pcs ;struct device_node ; +int miic_early_setup (struct phylink_pcs *pcs,struct device *dev); +struct phylink_pcs *miic_create (struct device *dev,struct device_node *np);void miic_destroy (struct phylink_pcs *pcs);
Signature · 1 line
2.39.0
Clément Léger
maintainerPATCH v2 2/6 net: stmmac: add support to use a generic phylink_pcs as PCS
In reply to Clément LégerCurrently, the PCS is set based on the presence of the xpcs field. In order to allow supporting other PCS, add a phylink_pcs pcs field to struct mac_device_info which is used in stmmac_mac_select_pcs() to select the correct PCS.
--- drivers/net/ethernet/stmicro/stmmac/common.h | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +---- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 1 + 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +2 -0
@@ -15,6 +15,7 @@#include <linux/netdevice.h> #include <linux/stmmac.h> #include <linux/phy.h> +#include <linux/phylink.h> #include <linux/pcs/pcs-xpcs.h> #include <linux/module.h> #if IS_ENABLED (CONFIG_VLAN_8021Q )
@@ -518,6 +519,7 @@ struct mac_device_info {const struct stmmac_tc_ops *tc;const struct stmmac_mmc_ops *mmc;struct dw_xpcs *xpcs; +struct phylink_pcs *phylink_pcs;struct mii_regs mii;/* MII register Addresses */ struct mac_link link;void __iomem *pcsr;/* vpointer to device CSRs */
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -4
@@ -937,10 +937,7 @@ static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config, {struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev)); -if (!priv->hw->xpcs) -return NULL ; - -return &priv->hw->xpcs->pcs; +return priv->hw->phylink_pcs; } static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +1 -0
@@ -513,6 +513,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus) } priv->hw->xpcs = xpcs; + priv->hw->phylink_pcs = &xpcs->pcs;break ; }
Signature · 1 line
2.39.0
Clément Léger
maintainerPATCH v2 3/6 net: stmmac: add support to provide pcs from platform data
In reply to Clément LégerAdd a pcs field in platform_data to allow providing platform data. This is gonig to be used by the renesas,rzn1-gmac compatible driver which can make use of a PCS.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++ include/linux/stmmac.h | 1 + 2 files changed, 4 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -0
@@ -7295,6 +7295,9 @@ int stmmac_dvr_probe(struct device *device, goto error_xpcs_setup; } +if (priv->plat->pcs) + priv->hw->phylink_pcs = priv->plat->pcs; + ret =stmmac_phy_setup (priv);if (ret) {netdev_err (ndev,"failed to setup phy (%d)\n" , ret);
include/linux/stmmac.h +1 -0
@@ -273,5 +273,6 @@ struct plat_stmmacenet_data {bool use_phy_wol;bool sph_disable;bool serdes_up_after_phy_linkup; + struct phylink_pcs *pcs; };#endif
Signature · 1 line
2.39.0
Re: [PATCH net-next v2 3/6] net: stmmac: add support to provide pcs from platform data
Hello!
Quoted 2 lines · Clément Léger
Add a pcs field in
platform_datato allow providing platform data. This is gonig to be used by the renesas,rzn1-gmac compatible driver which can make
s/gonig/going/ :-)
Quoted 3 lines
use of a PCS.
Signed-off-by Clément Léger <[email protected]>
[...]
MBR, Sergey
Clément Léger
maintainerPATCH v2 4/6 dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support
In reply to Clément LégerAdd "renesas,rzn1-gmac" binding documentation which is compatible with "snps,dwmac" compatible driver but uses a custom PCS to communicate with the phy.
--- .../bindings/net/renesas,rzn1-gmac.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml
Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml new file +67 -0
@@ -0,0 +1,67 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/renesas,rzn1-gmac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas GMAC + +maintainers: + - Clément Léger <[email protected]> + +select: + properties: + compatible: + contains: + enum: + - renesas,r9a06g032-gmac + - renesas,rzn1-gmac + required: + - compatible + +allOf: + - $ref: snps,dwmac.yaml# + +properties: + compatible: + items: + - enum: + - renesas,r9a06g032-gmac + - renesas,rzn1-gmac + - snps,dwmac + + pcs-handle: + description: + phandle pointing to a PCS sub-node compatible with + renesas,rzn1-miic.yaml# + $ref: /schemas/types.yaml#/definitions/phandle + +required: + - compatible + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/r9a06g032-sysctrl.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + + ethernet@44000000 { + compatible = "renesas,rzn1-gmac"; + reg = <0x44000000 0x2000>; + interrupt-parent = <&gic>; + interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; + clock-names = "stmmaceth"; + clocks = <&sysctrl R9A06G032_HCLK_GMAC0>; + snps,multicast-filter-bins = <256>; + snps,perfect-filter-entries = <128>; + tx-fifo-depth = <2048>; + rx-fifo-depth = <4096>; + pcs-handle = <&mii_conv1>; + phy-mode = "mii"; + }; + +...
Signature · 1 line
2.39.0
Re: [PATCH net-next v2 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support
Quoted 37 lines · Clément Léger
Add "renesas,rzn1-gmac" binding documentation which is compatible with "snps,dwmac" compatible driver but uses a custom PCS to communicate with the phy.
Signed-off-by Clément Léger <[email protected]>--- .../bindings/net/renesas,rzn1-gmac.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yamlDocumentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml new file +21
-0@@ -0,0 +1,67 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/renesas,rzn1-gmac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas GMAC + +maintainers: + - Clément Léger <[email protected]> + +select: + properties: + compatible: + contains: + enum: + - renesas,r9a06g032-gmac + - renesas,rzn1-gmac + required: + - compatible +
Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml line 31
Quoted 10 lines
Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml new file +10
-0+allOf: + - $ref: snps,dwmac.yaml# + +properties: + compatible: + items: + - enum: + - renesas,r9a06g032-gmac + - renesas,rzn1-gmac + - snps,dwmac
This is still not correct and does not make any sense.
What do you want to say here with such binding? That you describe "snps,dwmac" here? Then it's duplicated with snps,dwmac.yaml... Drop that enum and make it a proper list.
Best regards,
Krzysztof
Clément Léger
maintainerPATCH v2 5/6 net: stmmac: add support for RZ/N1 GMAC
In reply to Clément LégerAdd support for Renesas RZ/N1 GMAC. This support uses a custom PCS (MIIC) which is handle by parsing the pcs-handle device tree property.
--- 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
drivers/net/ethernet/stmicro/stmmac/Kconfig +11 -0
@@ -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
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
@@ -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
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c new file +120 -0
120 lines not on this page · raw message
Signature · 1 line
2.39.0
Russell King (Oracle)
reviewerRe: [PATCH net-next v2 5/6] net: stmmac: add support for RZ/N1 GMAC
Quoted 59 lines · Clément Léger
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 <[email protected]>--- 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.cdrivers/net/ethernet/stmicro/stmmac/Kconfig +11
-0@@ -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_SOCFPGAdrivers/net/ethernet/stmicro/stmmac/Makefile +1
-0@@ -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.odrivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c new file +8
-0@@ -0,0 +1,120 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2022 Schneider-Electric +* +* Clément Léger <[email protected]> +*/ + +#include <linux/of.h>
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c line 18
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c new file +10
-0+#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...
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c line 20
Quoted 2 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c new file +2
-0+ +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.
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c line 31
Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c new file +11
-0+{ +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?
Quoted 31 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c new file +31
-0+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 );
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c line 72
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c new file +10
-0+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.
Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c new file +11
-0+ 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);
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c line 93
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c new file +10
-0+ +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...
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c line 97
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c new file +4
-0+int ret =stmmac_dvr_remove (&pdev->dev); + +if (dwmac->pcs) +miic_destroy (dwmac->pcs);
and can still destroy the pcs.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Clément Léger
maintainerPATCH v2 6/6 ARM: dts: r9a06g032: describe GMAC1
In reply to Clément LégerRZ/N1 SoC includes two MAC named GMACx that are compatible with the "snps,dwmac" driver. GMAC1 is connected directly to the MII converter port 1. Since this MII converter is represented using a PCS driver, it uses the renesas specific compatible driver which uses this PCS.
--- arch/arm/boot/dts/r9a06g032.dtsi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/arm/boot/dts/r9a06g032.dtsi +18 -0
@@ -304,6 +304,24 @@ dma1: dma-controller@40105000 { data-width = <8>; }; + gmac1: ethernet@44000000 { + compatible = "renesas,r9a06g032-gmac", "renesas,rzn1-gmac", "snps,dwmac"; + reg = <0x44000000 0x2000>; + interrupt-parent = <&gic>; + interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; + clock-names = "stmmaceth"; + clocks = <&sysctrl R9A06G032_HCLK_GMAC0>; + snps,multicast-filter-bins = <256>; + snps,perfect-filter-entries = <128>; + tx-fifo-depth = <2048>; + rx-fifo-depth = <4096>; + pcs-handle = <&mii_conv1>; + status = "disabled"; + }; + gmac2: ethernet@44002000 { compatible = "renesas,r9a06g032-gmac", "renesas,rzn1-gmac", "snps,dwmac"; reg = <0x44002000 0x2000>;
Signature · 1 line
2.39.0
Re: [PATCH net-next v2 6/6] ARM: dts: r9a06g032: describe GMAC1
Quoted 15 lines · Clément Léger
RZ/N1 SoC includes two MAC named GMACx that are compatible with the "snps,dwmac" driver. GMAC1 is connected directly to the MII converter port 1. Since this MII converter is represented using a PCS driver, it uses the renesas specific compatible driver which uses this PCS.
Signed-off-by Clément Léger <[email protected]>--- arch/arm/boot/dts/r9a06g032.dtsi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)arch/arm/boot/dts/r9a06g032.dtsi +0
-0
arch/arm/boot/dts/r9a06g032.dtsi dma1: dma-controller@40105000 { · line 308
Quoted 5 lines
arch/arm/boot/dts/r9a06g032.dtsi +2
-0@@ -304,6 +304,24 @@ dma1: dma-controller@40105000 { data-width = <8>; }; + gmac1: ethernet@44000000 { + compatible = "renesas,r9a06g032-gmac", "renesas,rzn1-gmac", "snps,dwmac";
Please test your DTS against the binding you send. If you did it, you would see here that the binding does not work and needs fixes... The difference between your DTS and your example should also warn you that it's not correct.
Best regards,
Krzysztof