net: cadence: macb: only register MDIO bus when an MDIO child node exists in DT
Subsystems (3)
PATCH 1/1 net: cadence: macb: only register MDIO bus when an MDIO child node exists in DT
Prior to this patch, the MDIO peripheral was enabled for every GEM instance, even if no MDIO child node was defined in the device tree. In a setup where gem1 shares the MDIO bus with gem0 but has no MDIO subnode, gem1 would still scan the bus (both Clause 22 and Clause 45), adding unnecessary delay to the boot sequence.
This patch changes the driver so that each GEM instance only registers its MDIO bus if it has an explicit MDIO child node in DT, e.g.:
&gem0 {
phy-handle = <ðernet_phy0>;
mdio: mdio {
#address-cells = <1>;
#size-cells = <0>;
ethernet_phy0: ethernet-phy@7 {
#phy-cells = <1>;
compatible = "ethernet-phy-id0022.1640",
"ethernet-phy-ieee802.3-c22";
reg = <7>;
};
ethernet_phy1: ethernet-phy@3 {
#phy-cells = <1>;
compatible = "ethernet-phy-id0022.1640",
"ethernet-phy-ieee802.3-c22";
reg = <3>;
};
};
};
&gem1 {
phy-handle = <ðernet_phy1>;
/* no MDIO subnode here, so MDIO bus won’t be registered */
};--- drivers/net/ethernet/cadence/macb_main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +3 -4
@@ -1024,12 +1024,11 @@ static int macb_mii_init(struct macb *bp)struct device_node *mdio_np, *np = bp->pdev->dev.of_node;int err = -ENXIO ; -/* With fixed-link, we don't need to register the MDIO bus, -* except if we have a child named "mdio" in the device tree. -* In that case, some devices may be attached to the MACB's MDIO bus. +/* Only register MDIO bus if there is a child named "mdio" in +* the device tree */ mdio_np =of_get_child_by_name (np,"mdio" ); -if (!mdio_np &&of_phy_is_fixed_link (np)) +if (!mdio_np)return macb_mii_probe (bp->dev);/* Enable management port */
Signature · 1 line
2.43.0
Quoted 8 lines · Jonas Karlsson
Prior to this patch, the MDIO peripheral was enabled for every GEM instance, even if no MDIO child node was defined in the device tree. In a setup where gem1 shares the MDIO bus with gem0 but has no MDIO subnode, gem1 would still scan the bus (both Clause 22 and Clause 45), adding unnecessary delay to the boot sequence.
This patch changes the driver so that each GEM instance only registers its MDIO bus if it has an explicit MDIO child node in DT, e.g.:
What is missing is a paragraph starting something like:
This is safe and won't cause any regressions because ....
When writing this paragraph, please take into account:
https://elixir.bootlin.com/linux/v6.15.3/source/drivers/net/ethernet/cadence/macb_main.c#L818
Andrew
---
pw-bot: cr