summaryrefslogtreecommitdiff
path: root/drivers/core/of_extra.c
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2021-03-14 15:14:46 +0300
committerPriyanka Jain <priyanka.jain@nxp.com>2021-04-15 11:52:17 +0300
commit173c66bf9c0cfefd0ff69f0939c95900340d0988 (patch)
tree68c250b142404cca1dfa1b582243fe5160e1b919 /drivers/core/of_extra.c
parent1c196b308aeb226ae1849d49082d43a5f7617b35 (diff)
downloadu-boot-173c66bf9c0cfefd0ff69f0939c95900340d0988.tar.xz
of: extra: Introduce ofnode_phy_is_fixed_link() API
Introduce a helper API ofnode_phy_is_fixed_link() to detect whether the ethernet controller connects to a fixed-link pseudo-PHY device. Note there are two ways to describe a fixed PHY attached to an Ethernet device: - the new DT binding, where 'fixed-link' is a sub-node of the Ethernet device - the old DT binding, where 'fixed-link' is a property with 5 cells encoding various information about the fixed PHY Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
Diffstat (limited to 'drivers/core/of_extra.c')
-rw-r--r--drivers/core/of_extra.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/core/of_extra.c b/drivers/core/of_extra.c
index 653344529e..7702beff97 100644
--- a/drivers/core/of_extra.c
+++ b/drivers/core/of_extra.c
@@ -130,3 +130,26 @@ int ofnode_decode_memory_region(ofnode config_node, const char *mem_type,
return 0;
}
+
+bool ofnode_phy_is_fixed_link(ofnode eth_node, ofnode *phy_node)
+{
+ ofnode node, subnode;
+ int len;
+
+ subnode = ofnode_find_subnode(eth_node, "fixed-link");
+ if (ofnode_valid(subnode)) {
+ /* new binding */
+ node = subnode;
+ } else if (ofnode_get_property(eth_node, "fixed-link", &len) &&
+ len == (5 * sizeof(__be32))) {
+ /* old binding */
+ node = eth_node;
+ } else {
+ return false;
+ }
+
+ if (phy_node)
+ *phy_node = node;
+
+ return true;
+}