[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251118190530.580267-5-vladimir.oltean@nxp.com>
Date: Tue, 18 Nov 2025 21:05:19 +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,
Maxime Chevallier <maxime.chevallier@...tlin.com>
Subject: [PATCH net-next 04/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>
---
MAINTAINERS | 1 +
drivers/net/mdio/Kconfig | 14 +++--
drivers/net/mdio/Makefile | 1 +
drivers/net/mdio/mdio-regmap-simple.c | 77 +++++++++++++++++++++++++++
4 files changed, 90 insertions(+), 3 deletions(-)
create mode 100644 drivers/net/mdio/mdio-regmap-simple.c
diff --git a/MAINTAINERS b/MAINTAINERS
index c41b9d86c144..81c3dba6acd0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15473,6 +15473,7 @@ M: Maxime Chevallier <maxime.chevallier@...tlin.com>
L: netdev@...r.kernel.org
S: Maintained
F: drivers/net/mdio/mdio-regmap.c
+F: drivers/net/mdio/mdio-regmap-simple.c
F: include/linux/mdio/mdio-regmap.h
MEASUREMENT COMPUTING CIO-DAC IIO DRIVER
diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
index 9819d1dc18de..2f86a438a2a7 100644
--- a/drivers/net/mdio/Kconfig
+++ b/drivers/net/mdio/Kconfig
@@ -179,14 +179,22 @@ 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
+ 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..6ac390ec759b
--- /dev/null
+++ b/drivers/net/mdio/mdio-regmap-simple.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright 2025 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);
+ 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