Skip to content
Permalink
Browse files
net: mdiobus: Introduce fwnode_mdiobus_register()
Introduce fwnode_mdiobus_register() to register PHYs on the  mdiobus.
If the fwnode is DT node, then call of_mdiobus_register().
If it is an ACPI node, then call acpi_mdiobus_register().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
  • Loading branch information
calvinjolinux authored and intel-lab-lkp committed Mar 11, 2021
1 parent e5f2f7a commit fc2494f709d3130a0c1dbb4d3769904ee869185b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
@@ -7,6 +7,7 @@
*/

#include <linux/acpi.h>
#include <linux/acpi_mdio.h>
#include <linux/of.h>
#include <linux/of_mdio.h>
#include <linux/phy.h>
@@ -75,3 +76,23 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
return 0;
}
EXPORT_SYMBOL(fwnode_mdiobus_register_phy);

/**
* fwnode_mdiobus_register - Register mii_bus and create PHYs from fwnode
* @mdio: pointer to mii_bus structure
* @fwnode: pointer to fwnode of MDIO bus.
*
* This function returns of_mdiobus_register() for DT and
* acpi_mdiobus_register() for ACPI.
*/
int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
{
if (is_of_node(fwnode))
return of_mdiobus_register(mdio, to_of_node(fwnode));

if (is_acpi_node(fwnode))
return acpi_mdiobus_register(mdio, fwnode);

return -EINVAL;
}
EXPORT_SYMBOL(fwnode_mdiobus_register);
@@ -12,13 +12,18 @@
int fwnode_mdiobus_register_phy(struct mii_bus *bus,
struct fwnode_handle *child, u32 addr);

int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode);
#else /* CONFIG_FWNODE_MDIO */
static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
struct fwnode_handle *child,
u32 addr)
{
return -EINVAL;
}
static int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
{
return -EINVAL;
}
#endif

#endif /* __LINUX_FWNODE_MDIO_H */

0 comments on commit fc2494f

Please sign in to comment.