lkml.org 
[lkml]   [2021]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[net-next PATCH v4 11/15] net: mdiobus: Introduce fwnode_mdiobus_register()
Date
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>
---

Changes in v4:
- Remove redundant else from fwnode_mdiobus_register()

Changes in v3:
- Use acpi_mdiobus_register()

Changes in v2: None

drivers/net/phy/mdio_bus.c | 21 +++++++++++++++++++++
include/linux/phy.h | 1 +
2 files changed, 22 insertions(+)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 44ddfb0ba99f..362e12853f30 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -9,6 +9,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/acpi.h>
+#include <linux/acpi_mdio.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/errno.h>
@@ -568,6 +569,26 @@ static int mdiobus_create_device(struct mii_bus *bus,
return ret;
}

+/**
+ * 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);
+
/**
* __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
* @bus: target mii_bus
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 957ce3c9b058..765e1844cfdb 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -387,6 +387,7 @@ static inline struct mii_bus *mdiobus_alloc(void)
return mdiobus_alloc_size(0);
}

+int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode);
int __mdiobus_register(struct mii_bus *bus, struct module *owner);
int __devm_mdiobus_register(struct device *dev, struct mii_bus *bus,
struct module *owner);
--
2.17.1
\
 
 \ /
  Last update: 2021-01-22 18:41    [W:0.249 / U:21.968 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site