From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: u-boot@lists.denx.de
Cc: Jerome Forissier <jerome.forissier@arm.com>,
Tom Rini <trini@konsulko.com>,
Peter Robinson <pbrobinson@gmail.com>,
Svyatoslav Ryhel <clamor95@gmail.com>,
Heiko Schocher <hs@nabladev.com>, Simon Glass <sjg@chromium.org>,
Marek Vasut <marek.vasut+usb@mailbox.org>,
Andrew Goodbody <andrew.goodbody@linaro.org>,
Rasmus Villemoes <ravi@prevas.dk>, Peng Fan <peng.fan@nxp.com>
Subject: [PATCH 6/6] net: mvpp2: convert FDT access to ofnode API
Date: Tue, 26 May 2026 15:25:15 +0800 [thread overview]
Message-ID: <20260526-devfdt-net-v1-6-be3597b85b5e@nxp.com> (raw)
In-Reply-To: <20260526-devfdt-net-v1-0-be3597b85b5e@nxp.com>
From: Peng Fan <peng.fan@nxp.com>
Convert mvpp2 driver from legacy fdtdec/fdt_* APIs to the ofnode-based
interfaces.
Replace usage of dev_of_offset(), fdtdec_lookup_phandle(),
fdtdec_get_int(), fdt_parent_offset(), and related helpers with their
ofnode equivalents, including dev_ofnode(), ofnode_parse_phandle(),
ofnode_read_s32_default(), ofnode_get_parent(), and
ofnode_for_each_subnode().
Remove direct dependencies on gd->fdt_blob.
Main changes:
- Use ofnode_valid() instead of integer checks for node presence
- Switch fixed-link detection to ofnode_find_subnode()
- Replace uclass_get_device_by_of_offset() with
uclass_get_device_by_ofnode()
- Update subnode iteration and device binding to use ofnode
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/net/mvpp2.c | 54 ++++++++++++++++++++++++++---------------------------
1 file changed, 27 insertions(+), 27 deletions(-)
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 193f82ea07d..27f785163ba 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -4731,33 +4731,34 @@ static int mvpp2_port_init(struct udevice *dev, struct mvpp2_port *port)
static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
{
- int port_node = dev_of_offset(dev);
- int phy_node;
+ ofnode port_node = dev_ofnode(dev);
+ ofnode phy_node;
u32 id;
int phyaddr = 0;
- int fixed_link = 0;
+ ofnode fixed_link;
int ret;
- phy_node = fdtdec_lookup_phandle(gd->fdt_blob, port_node, "phy");
- fixed_link = fdt_subnode_offset(gd->fdt_blob, port_node, "fixed-link");
+ phy_node = ofnode_parse_phandle(port_node, "phy", 0);
+ fixed_link = ofnode_find_subnode(port_node, "fixed-link");
- if (phy_node > 0) {
- int parent;
+ if (ofnode_valid(phy_node)) {
+ ofnode parent;
- if (fixed_link != -FDT_ERR_NOTFOUND) {
+ if (ofnode_valid(fixed_link)) {
/* phy_addr is set to invalid value for fixed links */
phyaddr = PHY_MAX_ADDR;
} else {
- phyaddr = fdtdec_get_int(gd->fdt_blob, phy_node,
- "reg", 0);
+ phyaddr = ofnode_read_s32_default(phy_node, "reg", 0);
if (phyaddr < 0) {
dev_err(dev, "could not find phy address\n");
return -1;
}
}
- parent = fdt_parent_offset(gd->fdt_blob, phy_node);
- ret = uclass_get_device_by_of_offset(UCLASS_MDIO, parent,
- &port->mdio_dev);
+ parent = ofnode_get_parent(phy_node);
+ if (!ofnode_valid(parent))
+ return -ENODEV;
+ ret = uclass_get_device_by_ofnode(UCLASS_MDIO, parent,
+ &port->mdio_dev);
if (ret)
return ret;
} else {
@@ -4771,7 +4772,7 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
return -EINVAL;
}
- id = fdtdec_get_int(gd->fdt_blob, port_node, "port-id", -1);
+ id = dev_read_s32_default(dev, "port-id", -1);
if (id == -1) {
dev_err(dev, "missing port-id value\n");
return -EINVAL;
@@ -4812,7 +4813,7 @@ static void mvpp2_gpio_init(struct mvpp2_port *port)
/* Ports initialization */
static int mvpp2_port_probe(struct udevice *dev,
struct mvpp2_port *port,
- int port_node,
+ ofnode port_node,
struct mvpp2 *priv)
{
int err;
@@ -5350,8 +5351,7 @@ static int mvpp2_probe(struct udevice *dev)
if (!port->base)
return -EINVAL;
} else {
- port->gop_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
- "gop-port-id", -1);
+ port->gop_id = ofnode_read_s32_default(dev_ofnode(dev), "gop-port-id", -1);
if (port->gop_id == -1) {
dev_err(dev, "missing gop-port-id value\n");
return -EINVAL;
@@ -5375,7 +5375,7 @@ static int mvpp2_probe(struct udevice *dev)
priv->probe_done = 1;
}
- err = mvpp2_port_probe(dev, port, dev_of_offset(dev), priv);
+ err = mvpp2_port_probe(dev, port, dev_ofnode(dev), priv);
if (err)
return err;
@@ -5436,15 +5436,14 @@ static struct driver mvpp2_driver = {
*/
static int mvpp2_base_bind(struct udevice *parent)
{
- const void *blob = gd->fdt_blob;
- int node = dev_of_offset(parent);
+ ofnode node = dev_ofnode(parent);
struct uclass_driver *drv;
struct udevice *dev;
struct eth_pdata *plat;
char *name;
- int subnode;
+ ofnode subnode;
u32 id;
- int base_id_add;
+ int base_id_add, ret;
/* Lookup eth driver */
drv = lists_uclass_lookup(UCLASS_ETH);
@@ -5455,19 +5454,19 @@ static int mvpp2_base_bind(struct udevice *parent)
base_id_add = base_id;
- fdt_for_each_subnode(subnode, blob, node) {
+ dev_for_each_subnode(subnode, parent) {
/* Increment base_id for all subnodes, also the disabled ones */
base_id++;
/* Skip disabled ports */
- if (!fdtdec_get_is_enabled(blob, subnode))
+ if (!ofnode_is_enabled(subnode))
continue;
plat = calloc(1, sizeof(*plat));
if (!plat)
return -ENOMEM;
- id = fdtdec_get_int(blob, subnode, "port-id", -1);
+ id = ofnode_read_s32_default(subnode, "port-id", -1);
id += base_id_add;
name = calloc(1, 16);
@@ -5478,8 +5477,9 @@ static int mvpp2_base_bind(struct udevice *parent)
sprintf(name, "mvpp2-%d", id);
/* Create child device UCLASS_ETH and bind it */
- device_bind(parent, &mvpp2_driver, name, plat,
- offset_to_ofnode(subnode), &dev);
+ ret = device_bind(parent, &mvpp2_driver, name, plat, subnode, &dev);
+ if (ret)
+ return ret;
}
return 0;
--
2.51.0
next prev parent reply other threads:[~2026-05-26 6:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 7:25 [PATCH 0/6] net: Use dev APIs Peng Fan (OSS)
2026-05-26 7:25 ` [PATCH 1/6] net: ethoc: Use dev_read_addr_index() Peng Fan (OSS)
2026-05-27 1:17 ` Simon Glass
2026-05-26 7:25 ` [PATCH 2/6] net: qe: dm_qe_uec: Use dev_read_addr() Peng Fan (OSS)
2026-05-27 1:17 ` Simon Glass
2026-05-26 7:25 ` [PATCH 3/6] net: calxedaxgmac: " Peng Fan (OSS)
2026-05-27 1:17 ` Simon Glass
2026-05-26 7:25 ` [PATCH 4/6] net: dc2114x: Use dev_remap_addr() Peng Fan (OSS)
2026-05-27 1:17 ` Simon Glass
2026-05-26 7:25 ` [PATCH 5/6] net: mvpp2: Use dev_read_addr_index_ptr() Peng Fan (OSS)
2026-05-27 1:17 ` Simon Glass
2026-05-26 7:25 ` Peng Fan (OSS) [this message]
2026-05-27 1:20 ` [PATCH 6/6] net: mvpp2: convert FDT access to ofnode API Simon Glass
2026-05-27 14:29 ` Peng Fan (OSS)
2026-05-27 14:47 ` Tom Rini
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=20260526-devfdt-net-v1-6-be3597b85b5e@nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=andrew.goodbody@linaro.org \
--cc=clamor95@gmail.com \
--cc=hs@nabladev.com \
--cc=jerome.forissier@arm.com \
--cc=marek.vasut+usb@mailbox.org \
--cc=pbrobinson@gmail.com \
--cc=peng.fan@nxp.com \
--cc=ravi@prevas.dk \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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;
as well as URLs for NNTP newsgroup(s).