diff options
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 8042847f3c..a59832ebbf 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 31f9e78a06..c73508d276 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)); +} |