[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210122154300.7628-12-calvin.johnson@oss.nxp.com>
Date: Fri, 22 Jan 2021 21:12:56 +0530
From: Calvin Johnson <calvin.johnson@....nxp.com>
To: Grant Likely <grant.likely@....com>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Jeremy Linton <jeremy.linton@....com>,
Andrew Lunn <andrew@...n.ch>,
Andy Shevchenko <andy.shevchenko@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
Russell King - ARM Linux admin <linux@...linux.org.uk>,
Cristi Sovaiala <cristian.sovaiala@....com>,
Florin Laurentiu Chiculita <florinlaurentiu.chiculita@....com>,
Ioana Ciornei <ioana.ciornei@....com>,
Madalin Bucur <madalin.bucur@....nxp.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Marcin Wojtas <mw@...ihalf.com>,
Pieter Jansen Van Vuuren <pieter.jansenvv@...boosystems.io>,
Jon <jon@...id-run.com>, Saravana Kannan <saravanak@...gle.com>,
Randy Dunlap <rdunlap@...radead.org>
Cc: linux.cj@...il.com, Diana Madalina Craciun <diana.craciun@....com>,
linux-acpi@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
Laurentiu Tudor <laurentiu.tudor@....com>,
Calvin Johnson <calvin.johnson@....nxp.com>,
"David S. Miller" <davem@...emloft.net>,
Heiner Kallweit <hkallweit1@...il.com>,
Jakub Kicinski <kuba@...nel.org>
Subject: [net-next PATCH v4 11/15] 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@....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
Powered by blists - more mailing lists