From: Sagi Maimon <maimon.sagi@gmail.com>
To: netdev@vger.kernel.org
Cc: radhey.shyam.pandey@amd.com, michal.simek@amd.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux@armlinux.org.uk,
vadim.fedorenko@linux.dev, Sagi Maimon <maimon.sagi@gmail.com>
Subject: [PATCH net-next 1/2] net: axienet: use device_property and fwnode APIs for probe-time config
Date: Sun, 27 Sep 2026 10:38:42 +0300 [thread overview]
Message-ID: <20260927073843.346910-2-maimon.sagi@gmail.com> (raw)
In-Reply-To: <20260927073843.346910-1-maimon.sagi@gmail.com>
axienet_probe() reads its configuration exclusively through the of_*
API, so the driver can only be instantiated from a device tree node.
The ADVA TimeCard X2 is a PCIe timing card, driven by ptp_ocp, whose
FPGA contains an AXI Ethernet MAC with an AXI DMA engine. ptp_ocp is
going to register the MAC as a child platform device described by a
software node, so that this driver runs it rather than a copy in
ptp_ocp. That needs the probe-time configuration to be readable from a
software node.
The of_property_read_*(), of_get_phy_mode(), of_get_mac_address() and
phylink_of_phy_connect() calls used here all have fwnode-based
equivalents that resolve identically for a DT-backed device, and
additionally work for a device described by a software node.
Convert them. On a device tree this is a no-op: device_property_*()
dispatches to the of_* implementation when dev->fwnode is an OF node,
and device_get_phy_mode()/device_get_mac_address() are thin fwnode
wrappers around the same lookups. device_get_mac_address() also keeps
the "mac-address" nvmem cell fallback that of_get_mac_address() has.
Note that device_get_phy_mode() returns the mode as a positive value
rather than through an out parameter, so the error test changes from
"if (ret)" to "if (ret < 0)".
Not everything is converted. The "axistream-connected" lookup stays on
the OF API because its result is passed to of_address_to_resource(),
which has no fwnode counterpart. The "pcs-handle" and "phy-handle"
lookups could use fwnode_find_reference() and fwnode_mdio_find_device(),
but they refer to MDIO devices that only a device tree describes - the
bus axienet_mdio_setup() registers goes through of_mdiobus_register() -
so converting them would not let a caller without a device tree use
them. Such a caller takes neither branch: it gets its DMA registers
from its own platform resources, and it cannot use the SGMII and
1000BASE-X modes, which need a PCS.
No functional change intended.
Tested on the X2 with a local ptp_ocp change, with CONFIG_OF disabled
and enabled: the interface probes with its configuration read from the
software node and passes traffic. No device tree board was available,
so the claim that this is a no-op for device tree users rests on the
dispatch described above.
Assisted-by: LLM sparse
Signed-off-by: Sagi Maimon <maimon.sagi@gmail.com>
---
.../net/ethernet/xilinx/xilinx_axienet_main.c | 24 ++++++++++---------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 782f903d318f..cfef8ad75909 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -33,6 +33,7 @@
#include <linux/of_irq.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/skbuff.h>
#include <linux/math64.h>
#include <linux/phy.h>
@@ -1671,7 +1672,7 @@ static int axienet_open(struct net_device *ndev)
ret = axienet_device_reset(ndev);
axienet_unlock_mii(lp);
- ret = phylink_of_phy_connect(lp->phylink, lp->dev->of_node, 0);
+ ret = phylink_fwnode_phy_connect(lp->phylink, dev_fwnode(lp->dev), 0);
if (ret) {
dev_err(lp->dev, "phylink_of_phy_connect() failed: %d\n", ret);
return ret;
@@ -2864,7 +2865,7 @@ static int axienet_probe(struct platform_device *pdev)
if (axienet_ior(lp, XAE_ABILITY_OFFSET) & XAE_ABILITY_STATS)
lp->features |= XAE_FEATURE_STATS;
- ret = of_property_read_u32(pdev->dev.of_node, "xlnx,txcsum", &value);
+ ret = device_property_read_u32(&pdev->dev, "xlnx,txcsum", &value);
if (!ret) {
switch (value) {
case 1:
@@ -2879,7 +2880,7 @@ static int axienet_probe(struct platform_device *pdev)
break;
}
}
- ret = of_property_read_u32(pdev->dev.of_node, "xlnx,rxcsum", &value);
+ ret = device_property_read_u32(&pdev->dev, "xlnx,rxcsum", &value);
if (!ret) {
switch (value) {
case 1:
@@ -2898,16 +2899,16 @@ static int axienet_probe(struct platform_device *pdev)
* Here we check for memory allocated for Rx/Tx in the hardware from
* the device-tree and accordingly set flags.
*/
- ret = of_property_read_u32(pdev->dev.of_node, "xlnx,rxmem", &lp->rxmem);
+ ret = device_property_read_u32(&pdev->dev, "xlnx,rxmem", &lp->rxmem);
if (ret)
return dev_err_probe(&pdev->dev, ret,
"failed to read xlnx,rxmem property\n");
- lp->switch_x_sgmii = of_property_read_bool(pdev->dev.of_node,
- "xlnx,switch-x-sgmii");
+ lp->switch_x_sgmii = device_property_read_bool(&pdev->dev,
+ "xlnx,switch-x-sgmii");
/* Start with the proprietary, and broken phy_type */
- ret = of_property_read_u32(pdev->dev.of_node, "xlnx,phy-type", &value);
+ ret = device_property_read_u32(&pdev->dev, "xlnx,phy-type", &value);
if (!ret) {
netdev_warn(ndev, "Please upgrade your device tree binary blob to use phy-mode");
switch (value) {
@@ -2930,9 +2931,10 @@ static int axienet_probe(struct platform_device *pdev)
return -EINVAL;
}
} else {
- ret = of_get_phy_mode(pdev->dev.of_node, &lp->phy_mode);
- if (ret)
+ ret = device_get_phy_mode(&pdev->dev);
+ if (ret < 0)
return ret;
+ lp->phy_mode = ret;
}
if (lp->switch_x_sgmii && lp->phy_mode != PHY_INTERFACE_MODE_SGMII &&
lp->phy_mode != PHY_INTERFACE_MODE_1000BASEX) {
@@ -2940,7 +2942,7 @@ static int axienet_probe(struct platform_device *pdev)
return -EINVAL;
}
- if (!of_property_present(pdev->dev.of_node, "dmas")) {
+ if (!device_property_present(&pdev->dev, "dmas")) {
/* Find the DMA node, map the DMA registers, and decode the DMA IRQs */
np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0);
@@ -3060,7 +3062,7 @@ static int axienet_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "Ethernet core IRQ not defined\n");
/* Retrieve the MAC address */
- ret = of_get_mac_address(pdev->dev.of_node, mac_addr);
+ ret = device_get_mac_address(&pdev->dev, mac_addr);
if (!ret) {
axienet_set_mac_address(ndev, mac_addr);
} else {
--
2.47.0
next prev parent reply other threads:[~2026-09-27 7:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 7:38 [PATCH net-next 0/2] net: axienet: allow instantiation without a device tree Sagi Maimon
2026-09-27 7:38 ` Sagi Maimon [this message]
2026-09-27 17:55 ` [PATCH net-next 1/2] net: axienet: use device_property and fwnode APIs for probe-time config Andrew Lunn
2026-09-28 7:03 ` Sagi Maimon
2026-09-27 7:38 ` [PATCH net-next 2/2] net: axienet: add a MODULE_ALIAS for platform instantiation Sagi Maimon
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=20260927073843.346910-2-maimon.sagi@gmail.com \
--to=maimon.sagi@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=michal.simek@amd.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=radhey.shyam.pandey@amd.com \
--cc=vadim.fedorenko@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.