From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Jisheng Zhang <jszhang@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"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>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, richard.genoud@bootlin.com
Subject: Re: [PATCH net-next v5 2/2] net: stmmac: Add glue layer for Synaptics SL2610 SoC
Date: Fri, 4 Dec 2026 18:16:31 +0100 [thread overview]
Message-ID: <d4eda519-290f-46c3-bb39-51428869ef23@bootlin.com> (raw)
In-Reply-To: <20261204152836.31432-3-jszhang@kernel.org>
Hi,
On 12/4/26 16:28, Jisheng Zhang wrote:
> Add dwmac glue driver to support the DesignWare-based GMAC controllers
> in the Synaptics SL2610 SoC.
>
> Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> ---
> drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++
> drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
> .../net/ethernet/stmicro/stmmac/dwmac-syna.c | 165 ++++++++++++++++++
> 3 files changed, 177 insertions(+)
> create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-syna.c
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> index c6559e749c0c..79ffebcaba0e 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> @@ -310,6 +310,17 @@ config DWMAC_SUN55I
> stmmac device driver. This driver is used for A523/T527
> GMAC200 ethernet controller.
>
> +config DWMAC_SYNA
> + tristate "Synaptics SL2610 DWMAC support"
> + depends on OF && HAS_DMA && (ARCH_BERLIN || COMPILE_TEST)
> + select MFD_SYSCON
> + help
> + Support for the Synaptics SL2610 DesignWare Ethernet MAC glue.
> + This configures the PHY interface through the system controller.
> +
> + To compile this driver as a module, choose M here. The module
> + will be called dwmac-syna.
> +
> config DWMAC_THEAD
> tristate "T-HEAD dwmac support"
> depends on OF && (ARCH_THEAD || COMPILE_TEST)
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
> index b16a456b730e..d132353e9403 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Makefile
> +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
> @@ -35,6 +35,7 @@ obj-$(CONFIG_DWMAC_STM32) += dwmac-stm32.o
> obj-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o
> obj-$(CONFIG_DWMAC_SUN8I) += dwmac-sun8i.o
> obj-$(CONFIG_DWMAC_SUN55I) += dwmac-sun55i.o
> +obj-$(CONFIG_DWMAC_SYNA) += dwmac-syna.o
> obj-$(CONFIG_DWMAC_THEAD) += dwmac-thead.o
> obj-$(CONFIG_DWMAC_ULTRARISC) += dwmac-ultrarisc.o
> obj-$(CONFIG_DWMAC_DWC_QOS_ETH) += dwmac-dwc-qos-eth.o
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-syna.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-syna.c
> new file mode 100644
> index 000000000000..b2cb47c0d39e
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-syna.c
> @@ -0,0 +1,165 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Synaptics DWMAC platform driver
> + *
> + * Copyright (C) 2026 Synaptics Incorporated
> + * Author: Jisheng Zhang <jszhang@kernel.org>
> + *
> + */
> +
> +#include <linux/bitfield.h>
> +#include <linux/bitops.h>
> +#include <linux/module.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_net.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +
> +#include "stmmac_platform.h"
> +
> +#define CTL_PHY_INTF_SEL GENMASK(4, 1)
> +#define CTL_PHY_INTF_RGMII FIELD_PREP(CTL_PHY_INTF_SEL, PHY_INTF_SEL_RGMII)
> +#define CTL_PHY_INTF_RMII FIELD_PREP(CTL_PHY_INTF_SEL, PHY_INTF_SEL_RMII)
> +
> +#define SYNA_RGMII0_CTRL 0xa18
> +#define SYNA_RGMII1_CTRL 0xa3c
> +#define SYNA_TW_PORT_CTRL 0xa04
> +#define SYNA_MDIO_MASTER_SEL BIT(4)
> +
> +struct syna_dwmac {
> + struct plat_stmmacenet_data *plat;
> + struct regmap *regmap;
> + u32 rgmii_ctl;
> + struct device *dev;
> +};
> +
> +/* Only one MAC can provide the shared external MDIO bus. */
> +static unsigned long syna_mdio_claimed;
If another SoC with this glue comes up without that muxing logic but instead
uses one mdio per MAC, this won't work anymore :) But I don't see another
clean way of doing the validation, let's roll with this for now,
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Maxime
> +
> +static void syna_dwmac_release_mdio(void *data)
> +{
> + clear_bit(0, &syna_mdio_claimed);
> +}
> +
> +static int syna_dwmac_claim_mdio(struct syna_dwmac *dwmac)
> +{
> + if (!dwmac->plat->mdio_node ||
> + !of_device_is_available(dwmac->plat->mdio_node))
> + return 0;
> +
> + if (test_and_set_bit(0, &syna_mdio_claimed))
> + return dev_err_probe(dwmac->dev, -EINVAL,
> + "Shared MDIO bus already claimed\n");
> +
> + return devm_add_action_or_reset(dwmac->dev, syna_dwmac_release_mdio, NULL);
> +}
> +
> +static int syna_dwmac_set_phy_intf_sel(void *bsp_priv, u8 phy_intf_sel)
> +{
> + struct syna_dwmac *dwmac = bsp_priv;
> + u32 phyif;
> +
> + switch (phy_intf_sel) {
> + case PHY_INTF_SEL_RMII:
> + phyif = CTL_PHY_INTF_RMII;
> + break;
> + case PHY_INTF_SEL_RGMII:
> + phyif = CTL_PHY_INTF_RGMII;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + return regmap_update_bits(dwmac->regmap, dwmac->rgmii_ctl, CTL_PHY_INTF_SEL, phyif);
> +}
> +
> +static int syna_dwmac_init(struct device *dev, void *priv)
> +{
> + struct syna_dwmac *dwmac = priv;
> + u32 mdio_sel;
> +
> + /* Only the MAC providing the shared MDIO bus selects its master. */
> + if (!dwmac->plat->mdio_node ||
> + !of_device_is_available(dwmac->plat->mdio_node))
> + return 0;
> +
> + /* Interface-control offsets identify the hardware MAC, unlike aliases. */
> + switch (dwmac->rgmii_ctl) {
> + case SYNA_RGMII0_CTRL:
> + mdio_sel = 0;
> + break;
> + case SYNA_RGMII1_CTRL:
> + mdio_sel = SYNA_MDIO_MASTER_SEL;
> + break;
> + default:
> + return dev_err_probe(dev, -EINVAL,
> + "Unknown Ethernet interface register %#x\n",
> + dwmac->rgmii_ctl);
> + }
> +
> + return regmap_update_bits(dwmac->regmap, SYNA_TW_PORT_CTRL,
> + SYNA_MDIO_MASTER_SEL, mdio_sel);
> +}
> +
> +static int syna_dwmac_probe(struct platform_device *pdev)
> +{
> + struct stmmac_resources stmmac_res;
> + struct plat_stmmacenet_data *plat;
> + struct syna_dwmac *dwmac;
> + int ret;
> +
> + ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "failed to get resources\n");
> +
> + plat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
> + if (IS_ERR(plat))
> + return dev_err_probe(&pdev->dev, PTR_ERR(plat),
> + "dt configuration failed\n");
> +
> + dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
> + if (!dwmac)
> + return -ENOMEM;
> +
> + dwmac->regmap = syscon_regmap_lookup_by_phandle_args(pdev->dev.of_node,
> + "syna,syscon", 1,
> + &dwmac->rgmii_ctl);
> + if (IS_ERR(dwmac->regmap))
> + return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->regmap),
> + "Failed to get syscon regmap\n");
> +
> + dwmac->dev = &pdev->dev;
> + dwmac->plat = plat;
> + plat->bsp_priv = dwmac;
> + plat->init = syna_dwmac_init;
> + plat->set_phy_intf_sel = syna_dwmac_set_phy_intf_sel;
> +
> + ret = syna_dwmac_claim_mdio(dwmac);
> + if (ret)
> + return ret;
> +
> + return devm_stmmac_pltfr_probe(pdev, plat, &stmmac_res);
> +}
> +
> +static const struct of_device_id syna_dwmac_match[] = {
> + { .compatible = "syna,sl2610-dwmac" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, syna_dwmac_match);
> +
> +static struct platform_driver syna_dwmac_driver = {
> + .probe = syna_dwmac_probe,
> + .driver = {
> + .name = "syna-dwmac",
> + .pm = &stmmac_pltfr_pm_ops,
> + .of_match_table = syna_dwmac_match,
> + },
> +};
> +module_platform_driver(syna_dwmac_driver);
> +
> +MODULE_AUTHOR("Jisheng Zhang <jszhang@kernel.org>");
> +MODULE_DESCRIPTION("Synaptics DWMAC platform driver");
> +MODULE_LICENSE("GPL");
next prev parent reply other threads:[~2026-12-04 17:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 15:28 [PATCH net-next v5 0/2] net: stmmac: add SL2610 ethernet support Jisheng Zhang
2026-12-04 15:28 ` [PATCH net-next v5 1/2] dt-bindings: net: Add Synaptics SL2610 DWMAC Jisheng Zhang
2026-12-04 15:28 ` [PATCH net-next v5 2/2] net: stmmac: Add glue layer for Synaptics SL2610 SoC Jisheng Zhang
2026-12-04 17:16 ` Maxime Chevallier [this message]
2026-12-04 19:01 ` Andrew Lunn
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=d4eda519-290f-46c3-bb39-51428869ef23@bootlin.com \
--to=maxime.chevallier@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=jszhang@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richard.genoud@bootlin.com \
--cc=robh@kernel.org \
--cc=sebastian.hesselbarth@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox