[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aXIWBpIvp7KZYZCn@smile.fi.intel.com>
Date: Thu, 22 Jan 2026 14:20:22 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Vladimir Oltean <vladimir.oltean@....com>
Cc: netdev@...r.kernel.org, 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,
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: Re: [PATCH v2 net-next 03/15] net: mdio: add generic driver for NXP
SJA1110 100BASE-TX embedded PHYs
On Thu, Jan 22, 2026 at 12:56:42PM +0200, Vladimir Oltean wrote:
> 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.
...
> +#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>
...
> +static const struct mdio_regmap_simple_data nxp_sja1110_base_tx = {
> + .valid_addr = 0,
> + .autoscan = false,
> +};
Actually the { } is enough to initialise that. But if you want to be super
explicit... :-)
...
> +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)
dev->of_node check is not needed, see below.
> + 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) {
We may always require data to be present. As you use a default one anyway.
> + config.valid_addr = data->valid_addr;
> + config.autoscan = data->autoscan;
> + }
And if it is not provided we will have a crash which is fine. It will just
point that the code was not ever been run on real HW.
> + return PTR_ERR_OR_ZERO(devm_mdio_regmap_register(dev, &config));
> +}
...
> +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,
> + },
> +};
> +
Unneeded blank line.
> +module_platform_driver(mdio_regmap_simple_driver);
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists