net: Phy: Add PHY lookup support on MDIO bus in case of ACPI probe
Subsystems (3)
PATCH v2 1/1 net: Phy: Add PHY lookup support on MDIO bus in case of ACPI probe
The function referred to (of_mdiobus_link_mdiodev()) is only built when CONFIG_OF_MDIO is enabled, which is again, a DT specific thing, and would not work in case of ACPI.
Given that it is a static function so renamed of_mdiobus_link_mdiodev() as mdiobus_link_mdiodev() and did necessary changes, finally moved it out of the #ifdef(CONFIG_OF_MDIO) therefore make it work for both DT & ACPI.
---
Notes:
- Add generic handling for "fwnode" and "of_node".
- Remove duplicate loops.
drivers/net/phy/mdio_bus.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-)
drivers/net/phy/mdio_bus.c +23 -20
@@ -434,6 +434,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np) return d ? to_mii_bus(d) : NULL; }EXPORT_SYMBOL (of_mdio_find_bus); +#endif /* Walk the list of subnodes of a mdio bus and look for a node that * matches the mdio device's address with its 'reg' property. If
@@ -441,35 +442,37 @@ EXPORT_SYMBOL(of_mdio_find_bus);* auto-probed phy devices to be supplied with information passed in * via DT. */ -static void of_mdiobus_link_mdiodev (struct mii_bus *bus, -struct mdio_device *mdiodev) +static void mdiobus_link_mdiodev (struct mii_bus *bus, +struct mdio_device *mdiodev) {struct device *dev = &mdiodev->dev; -struct device_node *child; +struct fwnode_handle *child; +int addr; -if (dev->of_node || !bus->dev.of_node) +if (dev->fwnode || !bus->dev.fwnode) { +pr_err ("PHY fwnode is not available on bus for registration\n" );return ; + } -for_each_available_child_of_node (bus->dev.of_node, child) { -int addr; +device_for_each_child_node (&bus->dev, child) { +if (!fwnode_device_is_available (child)) +continue ; - addr =of_mdio_parse_addr (dev, child); -if (addr <0 ) +if (is_of_node (child)) { + addr =of_mdio_parse_addr (dev,to_of_node (child)); +if (addr <0 ) +continue ; + }else if (fwnode_property_read_u32 (child,"reg" , &addr))continue ;if (addr == mdiodev->addr) { - dev->of_node = child; - dev->fwnode =of_fwnode_handle (child); -return ; + dev->of_node =to_of_node (child); + dev->fwnode = child; +break ; } } +return ; } -#else /* !IS_ENABLED(CONFIG_OF_MDIO) */ -static inline void of_mdiobus_link_mdiodev (struct mii_bus *mdio, -struct mdio_device *mdiodev) -{ -} -#endif /** * mdiobus_create_device_from_board_info - create a full MDIO device given
@@ -688,10 +691,10 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)return phydev;/* -* For DT, see if the auto-probed phy has a correspoding child -* in the bus node, and set the of_node pointer in this case. +* See if the auto-probed phy has a corresponding child +* in the bus node, and set the of_node & fwnode pointers. */ -of_mdiobus_link_mdiodev (bus, &phydev->mdio); +mdiobus_link_mdiodev (bus, &phydev->mdio); err =phy_device_register (phydev);if (err) {
Signature · 1 line
2.7.4
Andrew Lunn
maintainerQuoted 3 lines · Vikas Singh
The function referred to (
of_mdiobus_link_mdiodev()) is only built whenCONFIG_OF_MDIOis enabled, which is again, a DT specific thing, and would not work in case of ACPI.
Vikas
How are you describing the MDIO bus in ACPI? Do you have a proposed standard document for submission to UEFI?
Andrew
Quoted 6 lines · Andrew Lunn
Quoted 3 lines · Vikas Singh
The function referred to (
of_mdiobus_link_mdiodev()) is only built whenCONFIG_OF_MDIOis enabled, which is again, a DT specific thing, and would not work in case of ACPI.
Quoted 6 lines
Vikas
How are you describing the MDIO bus in ACPI? Do you have a proposed standard document for submission to UEFI?
Andrew
Hi Andrew,
We are evaluating this internally with NXP stakeholders. Once finalised, I will share the plan & documentation accordingly.
Thnx !!
Vikas Singh
Jakub Kicinski
maintainerQuoted 8 lines · On Thu, 10 Sep 2020 17:13:03 +0530 Vikas Singh wrote:
The function referred to (
of_mdiobus_link_mdiodev()) is only built whenCONFIG_OF_MDIOis enabled, which is again, a DT specific thing, and would not work in case of ACPI.
Given that it is a static function so renamedof_mdiobus_link_mdiodev()asmdiobus_link_mdiodev()and did necessary changes, finally moved it out of the #ifdef(CONFIG_OF_MDIO) therefore make it work for both DT & ACPI.Signed-off-by Vikas Singh <[email protected]>
nit:
CHECK: braces {} should be used on all arms of this statement #60: FILE: drivers/net/phy/mdio_bus.c:461:
+ if (is_of_node(child)) {
[...]
+ } else if (fwnode_property_read_u32(child, "reg", &addr))
[...]