[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260122105654.105600-4-vladimir.oltean@nxp.com>
Date: Thu, 22 Jan 2026 12:56:42 +0200
From: Vladimir Oltean <vladimir.oltean@....com>
To: netdev@...r.kernel.org
Cc: Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
linux-kernel@...r.kernel.org,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Herve Codina <herve.codina@...tlin.com>,
Mark Brown <broonie@...nel.org>,
Serge Semin <fancer.lancer@...il.com>,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
Lee Jones <lee@...nel.org>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
devicetree@...r.kernel.org,
Choong Yong Liang <yong.liang.choong@...ux.intel.com>,
Jiawen Wu <jiawenwu@...stnetic.com>
Subject: [PATCH v2 net-next 03/15] net: mdio: add generic driver for NXP SJA1110 100BASE-TX embedded PHYs
This is the standalone variant of drivers/net/dsa/sja1105/sja1105_mdio.c.
Same kind of differences between this driver and the embedded DSA one
apply: regmap is being used for register access, and addresses are
multiplied by 4 with regmap.
In fact this is so generic that there is nothing NXP SJA1110 specific
about it at all, and just instantiates mdio-regmap. I decided to name it
mdio-regmap-simple.c in the style of drivers/mfd/simple-mfd-i2c.c which
has support for various vendor compatible strings.
Cc: Maxime Chevallier <maxime.chevallier@...tlin.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
v1->v2:
- reorder MAINTAINERS entry to be alphabetic
- clarify that platform_get_resource() is optional (thanks to Maxime)
- update copyright to 2026
MAINTAINERS | 1 +
drivers/net/mdio/Kconfig | 15 ++++-
drivers/net/mdio/Makefile | 1 +
drivers/net/mdio/mdio-regmap-simple.c | 80 +++++++++++++++++++++++++++
4 files changed, 94 insertions(+), 3 deletions(-)
create mode 100644 drivers/net/mdio/mdio-regmap-simple.c
diff --git a/MAINTAINERS b/MAINTAINERS
index d3fec699c577..2b910fdd1122 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15671,6 +15671,7 @@ MDIO REGMAP DRIVER
M: Maxime Chevallier <maxime.chevallier@...tlin.com>
L: netdev@...r.kernel.org
S: Maintained
+F: drivers/net/mdio/mdio-regmap-simple.c
F: drivers/net/mdio/mdio-regmap.c
F: include/linux/mdio/mdio-regmap.h
diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
index 9819d1dc18de..c6e824baf228 100644
--- a/drivers/net/mdio/Kconfig
+++ b/drivers/net/mdio/Kconfig
@@ -179,14 +179,23 @@ config MDIO_REALTEK_RTL9300
config MDIO_REGMAP
tristate
help
- This driver allows using MDIO devices that are not sitting on a
- regular MDIO bus, but still exposes the standard 802.3 register
+ This support module allows using MDIO devices that are not sitting on
+ a regular MDIO bus, but still exposes the standard 802.3 register
layout. It's regmap-based so that it can be used on integrated,
memory-mapped PHYs, SPI PHYs and so on. A new virtual MDIO bus is
created, and its read/write operations are mapped to the underlying
- regmap. Users willing to use this driver must explicitly select
+ regmap. Users willing to use this module must explicitly select
REGMAP.
+config MDIO_REGMAP_SIMPLE
+ tristate
+ select MDIO_REGMAP
+ help
+ Generic platform driver for MDIO buses with a linear address space
+ that can be directly accessed using the MDIO_REGMAP support code and
+ need no special handling. The regmap is provided by the parent
+ device.
+
config MDIO_THUNDER
tristate "ThunderX SOCs MDIO buses"
depends on 64BIT
diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile
index 9abf20d1b030..95f201b73a7d 100644
--- a/drivers/net/mdio/Makefile
+++ b/drivers/net/mdio/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_MDIO_MVUSB) += mdio-mvusb.o
obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o
obj-$(CONFIG_MDIO_REALTEK_RTL9300) += mdio-realtek-rtl9300.o
obj-$(CONFIG_MDIO_REGMAP) += mdio-regmap.o
+obj-$(CONFIG_MDIO_REGMAP_SIMPLE) += mdio-regmap-simple.o
obj-$(CONFIG_MDIO_SJA1110_CBT1) += mdio-sja1110-cbt1.o
obj-$(CONFIG_MDIO_SUN4I) += mdio-sun4i.o
obj-$(CONFIG_MDIO_THUNDER) += mdio-thunder.o
diff --git a/drivers/net/mdio/mdio-regmap-simple.c b/drivers/net/mdio/mdio-regmap-simple.c
new file mode 100644
index 000000000000..5db1ca50c374
--- /dev/null
+++ b/drivers/net/mdio/mdio-regmap-simple.c
@@ -0,0 +1,80 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright 2025-2026 NXP
+ *
+ * Generic MDIO bus driver for simple regmap-based MDIO devices
+ *
+ * This driver creates MDIO buses for devices that expose their internal
+ * PHYs or PCS through a regmap interface. It's intended to be a simple,
+ * generic driver similar to simple-mfd-i2c.c.
+ */
+#include <linux/module.h>
+#include <linux/of_mdio.h>
+#include <linux/phy.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/mdio/mdio-regmap.h>
+
+struct mdio_regmap_simple_data {
+ u8 valid_addr;
+ bool autoscan;
+};
+
+static const struct mdio_regmap_simple_data nxp_sja1110_base_tx = {
+ .valid_addr = 0,
+ .autoscan = false,
+};
+
+static int mdio_regmap_simple_probe(struct platform_device *pdev)
+{
+ const struct mdio_regmap_simple_data *data;
+ struct mdio_regmap_config config = {};
+ struct device *dev = &pdev->dev;
+ struct regmap *regmap;
+ struct mii_bus *bus;
+
+ if (!dev->of_node || !dev->parent)
+ return -ENODEV;
+
+ regmap = dev_get_regmap(dev->parent, NULL);
+ if (!regmap)
+ return -ENODEV;
+
+ data = device_get_match_data(dev);
+
+ config.regmap = regmap;
+ config.parent = dev;
+ config.name = dev_name(dev);
+ /* The resource is optional, provided for finding the registers
+ * within a device-wide non-MMIO regmap
+ */
+ config.resource = platform_get_resource(pdev, IORESOURCE_REG, 0);
+ if (data) {
+ config.valid_addr = data->valid_addr;
+ config.autoscan = data->autoscan;
+ }
+
+ return PTR_ERR_OR_ZERO(devm_mdio_regmap_register(dev, &config));
+}
+
+static const struct of_device_id mdio_regmap_simple_match[] = {
+ {
+ .compatible = "nxp,sja1110-base-tx-mdio",
+ .data = &nxp_sja1110_base_tx,
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(of, mdio_regmap_simple_match);
+
+static struct platform_driver mdio_regmap_simple_driver = {
+ .probe = mdio_regmap_simple_probe,
+ .driver = {
+ .name = "mdio-regmap-simple",
+ .of_match_table = mdio_regmap_simple_match,
+ },
+};
+
+module_platform_driver(mdio_regmap_simple_driver);
+
+MODULE_DESCRIPTION("Generic MDIO bus driver for simple regmap-based devices");
+MODULE_AUTHOR("Vladimir Oltean <vladimir.oltean@....com>");
+MODULE_LICENSE("GPL");
--
2.34.1
Powered by blists - more mailing lists