1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-11-01 19:05:51 +01:00

net: introduce helpers to get PHY ofnode from MAC

Add helpers ofnode_get_phy_node() and dev_get_phy_node() and use it in
net/mdio-uclass.c function dm_eth_connect_phy_handle(). Also add
corresponding UT test.

This is useful because other part's of U-Boot may want to get PHY ofnode
without connecting a PHY.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Marek Behún
2022-04-07 00:32:57 +02:00
committed by Ramon Fried
parent a7a96ef812
commit f3dd213e15
7 changed files with 96 additions and 18 deletions

View File

@@ -1198,3 +1198,24 @@ const char *ofnode_conf_read_str(const char *prop_name)
return ofnode_read_string(node, prop_name);
}
ofnode ofnode_get_phy_node(ofnode node)
{
/* DT node properties that reference a PHY node */
static const char * const phy_handle_str[] = {
"phy-handle", "phy", "phy-device",
};
struct ofnode_phandle_args args = {
.node = ofnode_null()
};
int i;
assert(ofnode_valid(node));
for (i = 0; i < ARRAY_SIZE(phy_handle_str); i++)
if (!ofnode_parse_phandle_with_args(node, phy_handle_str[i],
NULL, 0, 0, &args))
break;
return args.node;
}