summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMarek BehĂșn <marek.behun@nic.cz>2022-04-07 01:33:01 +0300
committerRamon Fried <ramon@neureality.ai>2022-04-10 08:44:12 +0300
commit123ca114e07ecf28aa2538748d733e2b22d8b8b5 (patch)
tree0a5481e51e4e50b33daf4d10f37574f6f797b04f /net
parent9c06b4815ce1d663085c214133762614bba79fbe (diff)
downloadu-boot-123ca114e07ecf28aa2538748d733e2b22d8b8b5.tar.xz
net: introduce helpers to get PHY interface mode from a device/ofnode
Add helpers ofnode_read_phy_mode() and dev_read_phy_mode() to parse the "phy-mode" / "phy-connection-type" property. Add corresponding UT test. Use them treewide. This allows us to inline the phy_get_interface_by_name() into ofnode_read_phy_mode(), since the former is not used anymore. Signed-off-by: Marek BehĂșn <marek.behun@nic.cz> Reviewed-by: Ramon Fried <rfried.dev@gmail.com> Tested-by: Patrice Chotard <patrice.chotard@foss.st.com>
Diffstat (limited to 'net')
-rw-r--r--net/mdio-uclass.c18
1 files changed, 1 insertions, 17 deletions
diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index bef8280e21..874f59413a 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -15,11 +15,6 @@
#include <dm/uclass-internal.h>
#include <linux/compat.h>
-/* DT node properties for MAC-PHY interface */
-static const char * const phy_mode_str[] = {
- "phy-mode", "phy-connection-type"
-};
-
void dm_mdio_probe_devices(void)
{
struct udevice *it;
@@ -195,26 +190,15 @@ out:
/* Connect to a PHY linked in eth DT node */
struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
{
- const char *if_str;
phy_interface_t interface;
struct phy_device *phy;
- int i;
if (!dev_has_ofnode(ethdev)) {
debug("%s: supplied eth dev has no DT node!\n", ethdev->name);
return NULL;
}
- interface = PHY_INTERFACE_MODE_NONE;
- for (i = 0; i < ARRAY_SIZE(phy_mode_str); i++) {
- if_str = dev_read_string(ethdev, phy_mode_str[i]);
- if (if_str) {
- interface = phy_get_interface_by_name(if_str);
- break;
- }
- }
- if (interface < 0)
- interface = PHY_INTERFACE_MODE_NONE;
+ interface = dev_read_phy_mode(ethdev);
if (interface == PHY_INTERFACE_MODE_NONE)
dev_dbg(ethdev, "can't find interface mode, default to NONE\n");