diff options
author | Tom Rini | 2022-04-15 08:09:52 -0400 |
---|---|---|
committer | Tom Rini | 2022-04-15 08:10:32 -0400 |
commit | 7f418ea59852945eeb9e5d2555d306f09643d555 (patch) | |
tree | 069dbaf3a1f62b68251189e9acdbd9affcbd98c5 /drivers/core | |
parent | 239fe55a6ce516f329687c0680428ca2acfc73ca (diff) | |
parent | 0154e6de37e8bbaac837939391f6d4a8f0b3fd18 (diff) |
Merge branch 'next' of https://source.denx.de/u-boot/custodians/u-boot-net
- DM9000 DM support
- tftp server bug fix
- mdio ofnode support functions
- Various phy fixes and improvements.
[trini: Fixup merge conflicts in drivers/net/phy/ethernet_id.c
drivers/net/phy/phy.c include/phy.h]
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/ofnode.c | 44 | ||||
-rw-r--r-- | drivers/core/read.c | 10 |
2 files changed, 54 insertions, 0 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 8042847f3c1..a59832ebbfb 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1198,3 +1198,47 @@ 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; +} + +phy_interface_t ofnode_read_phy_mode(ofnode node) +{ + const char *mode; + int i; + + assert(ofnode_valid(node)); + + mode = ofnode_read_string(node, "phy-mode"); + if (!mode) + mode = ofnode_read_string(node, "phy-connection-type"); + + if (!mode) + return PHY_INTERFACE_MODE_NA; + + for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++) + if (!strcmp(mode, phy_interface_strings[i])) + return i; + + debug("%s: Invalid PHY interface '%s'\n", __func__, mode); + + return PHY_INTERFACE_MODE_NA; +} diff --git a/drivers/core/read.c b/drivers/core/read.c index 31f9e78a062..c73508d2760 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -398,3 +398,13 @@ int dev_decode_display_timing(const struct udevice *dev, int index, { return ofnode_decode_display_timing(dev_ofnode(dev), index, config); } + +ofnode dev_get_phy_node(const struct udevice *dev) +{ + return ofnode_get_phy_node(dev_ofnode(dev)); +} + +phy_interface_t dev_read_phy_mode(const struct udevice *dev) +{ + return ofnode_read_phy_mode(dev_ofnode(dev)); +} |