[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221009162006.1289-1-soha@lohu.info>
Date: Mon, 10 Oct 2022 00:20:06 +0800
From: Soha Jin <soha@...u.info>
To: Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: Russell King <linux@...linux.org.uk>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Soha Jin <soha@...u.info>
Subject: [PATCH] net: mdiobus: add fwnode_phy_is_fixed_link()
A helper function to check if PHY is fixed link with fwnode properties.
This is similar to of_phy_is_fixed_link.
Signed-off-by: Soha Jin <soha@...u.info>
---
drivers/net/mdio/fwnode_mdio.c | 30 +++++++++++++++++++++++++++++-
include/linux/fwnode_mdio.h | 2 ++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
index 689e728345ce..8e1773e4d304 100644
--- a/drivers/net/mdio/fwnode_mdio.c
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -6,8 +6,9 @@
* out of the fwnode and using it to populate an mii_bus.
*/
-#include <linux/acpi.h>
#include <linux/fwnode_mdio.h>
+#include <linux/property.h>
+#include <linux/acpi.h>
#include <linux/of.h>
#include <linux/phy.h>
#include <linux/pse-pd/pse.h>
@@ -183,3 +184,30 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
return rc;
}
EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
+
+bool fwnode_phy_is_fixed_link(struct fwnode_handle *fwnode)
+{
+ struct fwnode_handle *dn;
+ int err;
+ const char *managed;
+
+ /* New binding: 'fixed-link' is a sub-node of the Ethernet device. */
+ dn = fwnode_get_named_child_node(fwnode, "fixed-link");
+ if (dn) {
+ fwnode_handle_put(dn);
+ return true;
+ }
+
+ err = fwnode_property_read_string(fwnode, "managed", &managed);
+ if (err == 0 && strcmp(managed, "auto") != 0)
+ return true;
+
+ /* Old binding: 'fixed-link' was a property with 5 cells encoding
+ * various information about the fixed PHY.
+ */
+ if (fwnode_property_count_u32(fwnode, "fixed-link") == 5)
+ return true;
+
+ return false;
+}
+EXPORT_SYMBOL(fwnode_phy_is_fixed_link);
diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
index faf603c48c86..f35e447e524a 100644
--- a/include/linux/fwnode_mdio.h
+++ b/include/linux/fwnode_mdio.h
@@ -32,4 +32,6 @@ static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
}
#endif
+bool fwnode_phy_is_fixed_link(struct fwnode_handle *fwnode);
+
#endif /* __LINUX_FWNODE_MDIO_H */
--
2.30.2
Powered by blists - more mailing lists