From f5185ec79dac01431c01427c4583147a6d0ce20a Mon Sep 17 00:00:00 2001 From: Sagi Maimon Date: Mon, 28 Sep 2026 10:42:55 +0300 Subject: [PATCH 1/2] net: axienet: use device_property and fwnode APIs for probe-time config 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. Convert only the lookups such a caller needs: "xlnx,rxmem", which probe requires; "phy-mode"; the MAC address; and the PHY connection, which is where phylink finds a "fixed-link" child. On a device tree this is a no-op: device_property_read_u32() dispatches to the of_* implementation when dev->fwnode is an OF node, phylink_of_phy_connect() is a wrapper around phylink_fwnode_phy_connect(), and device_get_phy_mode() and 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)". Everything else stays on the OF API. "xlnx,txcsum", "xlnx,rxcsum" and "xlnx,switch-x-sgmii" are optional, and "xlnx,phy-type" is deprecated in favour of "phy-mode". Without an OF node each of those lookups finds nothing, exactly as for a device tree node that leaves them out: no checksum offload, no runtime SGMII/1000BASE-X switching and a fall-through to "phy-mode". The "dmas" test likewise selects the built-in AXI DMA engine. The "axistream-connected", "pcs-handle" and "phy-handle" phandle lookups stay too: a caller without an OF node takes neither branch, getting 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 Reviewed-by: Andrew Lunn Tested-by: Suraj Gupta Reviewed-by: Suraj Gupta Link: https://patch.msgid.link/20260928074256.462345-2-maimon.sagi@gmail.com Signed-off-by: Paolo Abeni --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 782f903d318f..0f2170af9b10 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -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; @@ -2898,7 +2899,7 @@ 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"); @@ -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) { @@ -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 { From 418149559ef3606ea710192e1a12a58d8ff8de4c Mon Sep 17 00:00:00 2001 From: Sagi Maimon Date: Mon, 28 Sep 2026 10:42:56 +0300 Subject: [PATCH 2/2] net: axienet: add a MODULE_ALIAS for platform instantiation The module is built as xilinx_emac.ko while the platform driver it registers is named xilinx_axienet. For a device tree instantiation that mismatch does not matter, because the OF match table supplies the modalias udev uses to load the module. A device registered by name from another driver has no OF node and so no OF modalias. It advertises platform:xilinx_axienet, which matches nothing, and the device is created but never bound. ptp_ocp is going to register the AXI Ethernet MAC of the ADVA TimeCard X2 this way, as a child platform device described by a software node. Add the corresponding MODULE_ALIAS so name-based instantiation can autoload the driver, and give the name a define now that it is used in more than one place. Tested on the X2 with a local ptp_ocp change: with this patch the module is loaded and binds when ptp_ocp registers the device; without it the device stays unbound until xilinx_emac is loaded by hand. Assisted-by: LLM sparse Signed-off-by: Sagi Maimon Link: https://patch.msgid.link/20260928074256.462345-3-maimon.sagi@gmail.com Signed-off-by: Paolo Abeni --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 0f2170af9b10..ae8ed4495ea0 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -48,6 +48,7 @@ #include "xilinx_axienet.h" /* Descriptors defines for Tx and Rx DMA */ +#define AXIENET_DRIVER_NAME "xilinx_axienet" #define TX_BD_NUM_DEFAULT 128 #define RX_BD_NUM_DEFAULT 1024 #define TX_BD_NUM_MIN (MAX_SKB_FRAGS + 1) @@ -3223,7 +3224,7 @@ static struct platform_driver axienet_driver = { .remove = axienet_remove, .shutdown = axienet_shutdown, .driver = { - .name = "xilinx_axienet", + .name = AXIENET_DRIVER_NAME, .pm = &axienet_pm_ops, .of_match_table = axienet_of_match, }, @@ -3231,6 +3232,13 @@ static struct platform_driver axienet_driver = { module_platform_driver(axienet_driver); +/* The module is named xilinx_emac, the platform driver xilinx_axienet. A + * device registered by name rather than from firmware advertises a + * platform:xilinx_axienet modalias, which without this matches no module: + * udev cannot autoload the driver and the device stays unbound. + */ +MODULE_ALIAS("platform:" AXIENET_DRIVER_NAME); + MODULE_DESCRIPTION("Xilinx Axi Ethernet driver"); MODULE_AUTHOR("Xilinx"); MODULE_LICENSE("GPL");