From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Extend the Renesas GBETH stmmac glue driver to support the RZ/T2H SoC,
where the GMAC is connected through a MIIC PCS. Introduce a new
`has_pcs` flag in `struct renesas_gbeth_of_data` to indicate when PCS
handling is required.
When enabled, the driver parses the `pcs-handle` phandle, creates a PCS
instance with `miic_create()`, and wires it into phylink. Proper cleanup
is done with `miic_destroy()`. New init/exit/select hooks are added to
`plat_stmmacenet_data` for PCS integration.
Update Kconfig to select `PCS_RZN1_MIIC` when building the Renesas GBETH
driver so the PCS support is always available.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v2->v3:
- Dropped passing STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP flag in stmmac_flags
as it is always set for all the SoCs.
- Updated Kconfig to include RZ/T2H and RZ/N2H.
v1->v2:
- No changes.
---
drivers/net/ethernet/stmicro/stmmac/Kconfig | 12 +++--
.../stmicro/stmmac/dwmac-renesas-gbeth.c | 51 +++++++++++++++++++
2 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index 67fa879b1e52..91d9a14362bf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -133,15 +133,17 @@ config DWMAC_QCOM_ETHQOS
stmmac device driver.
config DWMAC_RENESAS_GBETH
- tristate "Renesas RZ/V2H(P) GBETH support"
+ tristate "Renesas RZ/V2H(P) GBETH and RZ/T2H, RZ/N2H GMAC support"
default ARCH_RENESAS
depends on OF && (ARCH_RENESAS || COMPILE_TEST)
+ select PCS_RZN1_MIIC
help
- Support for Gigabit Ethernet Interface (GBETH) on Renesas
- RZ/V2H(P) SoCs.
+ Support for Gigabit Ethernet Interface (GBETH)/ Ethernet MAC (GMAC)
+ on Renesas SoCs.
- This selects the Renesas RZ/V2H(P) Soc specific glue layer support
- for the stmmac device driver.
+ This selects Renesas SoC glue layer support for the stmmac device
+ driver. This driver is used for the RZ/V2H(P) family, RZ/T2H and
+ RZ/N2H SoCs.
config DWMAC_ROCKCHIP
tristate "Rockchip dwmac support"
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-renesas-gbeth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-renesas-gbeth.c
index 50be944ee37b..bc7bb975803c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-renesas-gbeth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-renesas-gbeth.c
@@ -17,6 +17,7 @@
#include <linux/device.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/pcs-rzn1-miic.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
#include <linux/types.h>
@@ -33,6 +34,7 @@
* handled by the glue driver or core driver.
* @set_clk_tx_rate: Flag to indicate if Tx clock is fixed or
* set_clk_tx_rate is needed.
+ * @has_pcs: Flag to indicate if the MAC has a PCS
*/
struct renesas_gbeth_of_data {
const char * const *clks;
@@ -40,6 +42,7 @@ struct renesas_gbeth_of_data {
u32 stmmac_flags;
bool handle_reset;
bool set_clk_tx_rate;
+ bool has_pcs;
};
struct renesas_gbeth {
@@ -53,6 +56,41 @@ static const char *const renesas_gbeth_clks[] = {
"tx", "tx-180", "rx", "rx-180",
};
+static const char *const renesas_gmac_clks[] = {
+ "tx",
+};
+
+static int renesas_gmac_pcs_init(struct stmmac_priv *priv)
+{
+ struct device_node *np = priv->device->of_node;
+ struct device_node *pcs_node;
+ struct phylink_pcs *pcs;
+
+ pcs_node = of_parse_phandle(np, "pcs-handle", 0);
+ if (pcs_node) {
+ pcs = miic_create(priv->device, pcs_node);
+ of_node_put(pcs_node);
+ if (IS_ERR(pcs))
+ return PTR_ERR(pcs);
+
+ priv->hw->phylink_pcs = pcs;
+ }
+
+ return 0;
+}
+
+static void renesas_gmac_pcs_exit(struct stmmac_priv *priv)
+{
+ if (priv->hw->phylink_pcs)
+ miic_destroy(priv->hw->phylink_pcs);
+}
+
+static struct phylink_pcs *renesas_gmac_select_pcs(struct stmmac_priv *priv,
+ phy_interface_t interface)
+{
+ return priv->hw->phylink_pcs;
+}
+
static int renesas_gbeth_init(struct platform_device *pdev, void *priv)
{
struct plat_stmmacenet_data *plat_dat;
@@ -150,6 +188,11 @@ static int renesas_gbeth_probe(struct platform_device *pdev)
plat_dat->exit = renesas_gbeth_exit;
plat_dat->flags |= STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP |
gbeth->of_data->stmmac_flags;
+ if (of_data->has_pcs) {
+ plat_dat->pcs_init = renesas_gmac_pcs_init;
+ plat_dat->pcs_exit = renesas_gmac_pcs_exit;
+ plat_dat->select_pcs = renesas_gmac_select_pcs;
+ }
return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
}
@@ -163,7 +206,15 @@ static const struct renesas_gbeth_of_data renesas_gbeth_of_data = {
STMMAC_FLAG_SPH_DISABLE,
};
+static const struct renesas_gbeth_of_data renesas_gmac_of_data = {
+ .clks = renesas_gmac_clks,
+ .num_clks = ARRAY_SIZE(renesas_gmac_clks),
+ .stmmac_flags = STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY,
+ .has_pcs = true,
+};
+
static const struct of_device_id renesas_gbeth_match[] = {
+ { .compatible = "renesas,r9a09g077-gbeth", .data = &renesas_gmac_of_data },
{ .compatible = "renesas,rzv2h-gbeth", .data = &renesas_gbeth_of_data },
{ /* Sentinel */ }
};
--
2.51.0
On 2025-09-08 11:59, Prabhakar wrote: > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > Extend the Renesas GBETH stmmac glue driver to support the RZ/T2H SoC, > where the GMAC is connected through a MIIC PCS. Introduce a new > `has_pcs` flag in `struct renesas_gbeth_of_data` to indicate when PCS > handling is required. > > When enabled, the driver parses the `pcs-handle` phandle, creates a PCS > instance with `miic_create()`, and wires it into phylink. Proper cleanup > is done with `miic_destroy()`. New init/exit/select hooks are added to > `plat_stmmacenet_data` for PCS integration. > > Update Kconfig to select `PCS_RZN1_MIIC` when building the Renesas GBETH > driver so the PCS support is always available. > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > --- > v2->v3: > - Dropped passing STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP flag in stmmac_flags > as it is always set for all the SoCs. > - Updated Kconfig to include RZ/T2H and RZ/N2H. > > v1->v2: > - No changes. The following warning is seen when doing a defconfig build (make defconfig) for arm64 on the Linux next-20250915 tag. First seen on next-20250915 Good: next-20250912 Bad: next-20250915 Regression Analysis: - New regression? yes - Reproducibility? yes Build regression: WARNING: unmet direct dependencies detected for PCS_RZN1_MIIC Reported-by: Linux Kernel Functional Testing <lkft@linaro.org> This is the build warning: WARNING: unmet direct dependencies detected for PCS_RZN1_MIIC Depends on [n]: NETDEVICES [=y] && OF [=y] && (ARCH_RZN1 [=n] || COMPILE_TEST [=n]) Selected by [m]: - DWMAC_RENESAS_GBETH [=m] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_STMICRO [=y] && STMMAC_ETH [=m] && STMMAC_PLATFORM [=m] && OF [=y] && (ARCH_RENESAS [=y] || COMPILE_TEST [=n]) WARNING: unmet direct dependencies detected for PCS_RZN1_MIIC Depends on [n]: NETDEVICES [=y] && OF [=y] && (ARCH_RZN1 [=n] || COMPILE_TEST [=n]) Selected by [m]: - DWMAC_RENESAS_GBETH [=m] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_STMICRO [=y] && STMMAC_ETH [=m] && STMMAC_PLATFORM [=m] && OF [=y] && (ARCH_RENESAS [=y] || COMPILE_TEST [=n]) I: config: PASS in 0:00:01.592356 By reverting this patch the warning disapears. ## Source * Kernel version: 6.17.0-rc6 * Git tree: * https://kernel.googlesource.com/pub/scm/linux/kernel/git/next/linux-next.git * Git describe: next-20250915 * Git commit: c3067c2c38316c3ef013636c93daa285ee6aaa2e * Architectures: arm64 * Toolchains: gcc and clang * Kconfigs: lkftconfigs ## Build * Build log: https://storage.tuxsuite.com/public/linaro/lkft/builds/32l4UF8KltAzu6kUpW3hXaYRWjZ/build.log * Test details: https://regressions.linaro.org/lkft/linux-next-master/next-20250915/log-parser-build-clang/general-unmet-dependencies-warning-unmet-direct-dependencies-detected-for-pcs_rzn_miic/ * Build link: https://storage.tuxsuite.com/public/linaro/lkft/builds/32l4UF8KltAzu6kUpW3hXaYRWjZ/ * Kernel config: https://storage.tuxsuite.com/public/linaro/lkft/builds/32l4UF8KltAzu6kUpW3hXaYRWjZ/config -- Linaro LKFT
Hi Anders, On Tue, 16 Sept 2025 at 15:05, Anders Roxell <anders.roxell@linaro.org> wrote: > On 2025-09-08 11:59, Prabhakar wrote: > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > Extend the Renesas GBETH stmmac glue driver to support the RZ/T2H SoC, > > where the GMAC is connected through a MIIC PCS. Introduce a new > > `has_pcs` flag in `struct renesas_gbeth_of_data` to indicate when PCS > > handling is required. > > > > When enabled, the driver parses the `pcs-handle` phandle, creates a PCS > > instance with `miic_create()`, and wires it into phylink. Proper cleanup > > is done with `miic_destroy()`. New init/exit/select hooks are added to > > `plat_stmmacenet_data` for PCS integration. > > > > Update Kconfig to select `PCS_RZN1_MIIC` when building the Renesas GBETH > > driver so the PCS support is always available. > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > --- > > v2->v3: > > - Dropped passing STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP flag in stmmac_flags > > as it is always set for all the SoCs. > > - Updated Kconfig to include RZ/T2H and RZ/N2H. > > > > v1->v2: > > - No changes. > > The following warning is seen when doing a defconfig build (make > defconfig) for arm64 on the Linux next-20250915 tag. > > First seen on next-20250915 > Good: next-20250912 > Bad: next-20250915 > > Regression Analysis: > - New regression? yes > - Reproducibility? yes > > Build regression: WARNING: unmet direct dependencies detected for PCS_RZN1_MIIC > > Reported-by: Linux Kernel Functional Testing <lkft@linaro.org> > > This is the build warning: > WARNING: unmet direct dependencies detected for PCS_RZN1_MIIC > Depends on [n]: NETDEVICES [=y] && OF [=y] && (ARCH_RZN1 [=n] || COMPILE_TEST [=n]) > Selected by [m]: > - DWMAC_RENESAS_GBETH [=m] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_STMICRO [=y] && STMMAC_ETH [=m] && STMMAC_PLATFORM [=m] && OF [=y] && (ARCH_RENESAS [=y] || COMPILE_TEST [=n]) > > WARNING: unmet direct dependencies detected for PCS_RZN1_MIIC > Depends on [n]: NETDEVICES [=y] && OF [=y] && (ARCH_RZN1 [=n] || COMPILE_TEST [=n]) > Selected by [m]: > - DWMAC_RENESAS_GBETH [=m] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_STMICRO [=y] && STMMAC_ETH [=m] && STMMAC_PLATFORM [=m] && OF [=y] && (ARCH_RENESAS [=y] || COMPILE_TEST [=n]) > I: config: PASS in 0:00:01.592356 Thanks for your report! config DWMAC_RENESAS_GBETH depends on OF && (ARCH_RENESAS || COMPILE_TEST) select PCS_RZN1_MIIC config PCS_RZN1_MIIC depends on ARCH_RZN1 || ARCH_R9A09G077 || ARCH_R9A09G087 || COMPILE_TEST "ARCH_RENESAS" is wider than "ARCH_RZN1 || ARCH_R9A09G077 || ARCH_R9A09G087". I would just change the latter to ARCH_RENESAS. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hi Andres and Geert, On Tue, Sep 16, 2025 at 2:31 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > Hi Anders, > > On Tue, 16 Sept 2025 at 15:05, Anders Roxell <anders.roxell@linaro.org> wrote: > > On 2025-09-08 11:59, Prabhakar wrote: > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > > > Extend the Renesas GBETH stmmac glue driver to support the RZ/T2H SoC, > > > where the GMAC is connected through a MIIC PCS. Introduce a new > > > `has_pcs` flag in `struct renesas_gbeth_of_data` to indicate when PCS > > > handling is required. > > > > > > When enabled, the driver parses the `pcs-handle` phandle, creates a PCS > > > instance with `miic_create()`, and wires it into phylink. Proper cleanup > > > is done with `miic_destroy()`. New init/exit/select hooks are added to > > > `plat_stmmacenet_data` for PCS integration. > > > > > > Update Kconfig to select `PCS_RZN1_MIIC` when building the Renesas GBETH > > > driver so the PCS support is always available. > > > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > --- > > > v2->v3: > > > - Dropped passing STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP flag in stmmac_flags > > > as it is always set for all the SoCs. > > > - Updated Kconfig to include RZ/T2H and RZ/N2H. > > > > > > v1->v2: > > > - No changes. > > > > The following warning is seen when doing a defconfig build (make > > defconfig) for arm64 on the Linux next-20250915 tag. > > > > First seen on next-20250915 > > Good: next-20250912 > > Bad: next-20250915 > > > > Regression Analysis: > > - New regression? yes > > - Reproducibility? yes > > > > Build regression: WARNING: unmet direct dependencies detected for PCS_RZN1_MIIC > > > > Reported-by: Linux Kernel Functional Testing <lkft@linaro.org> > > > > This is the build warning: > > WARNING: unmet direct dependencies detected for PCS_RZN1_MIIC > > Depends on [n]: NETDEVICES [=y] && OF [=y] && (ARCH_RZN1 [=n] || COMPILE_TEST [=n]) > > Selected by [m]: > > - DWMAC_RENESAS_GBETH [=m] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_STMICRO [=y] && STMMAC_ETH [=m] && STMMAC_PLATFORM [=m] && OF [=y] && (ARCH_RENESAS [=y] || COMPILE_TEST [=n]) > > > > WARNING: unmet direct dependencies detected for PCS_RZN1_MIIC > > Depends on [n]: NETDEVICES [=y] && OF [=y] && (ARCH_RZN1 [=n] || COMPILE_TEST [=n]) > > Selected by [m]: > > - DWMAC_RENESAS_GBETH [=m] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_STMICRO [=y] && STMMAC_ETH [=m] && STMMAC_PLATFORM [=m] && OF [=y] && (ARCH_RENESAS [=y] || COMPILE_TEST [=n]) > > I: config: PASS in 0:00:01.592356 > > Thanks for your report! > > config DWMAC_RENESAS_GBETH > depends on OF && (ARCH_RENESAS || COMPILE_TEST) > select PCS_RZN1_MIIC > > config PCS_RZN1_MIIC > depends on ARCH_RZN1 || ARCH_R9A09G077 || ARCH_R9A09G087 || COMPILE_TEST > > "ARCH_RENESAS" is wider than "ARCH_RZN1 || ARCH_R9A09G077 || ARCH_R9A09G087". > I would just change the latter to ARCH_RENESAS. > Thank you both. I'll create a patch updating it to use `ARCH_RENESAS`. Cheers, Prabhakar
© 2016 - 2025 Red Hat, Inc.