aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/ti/cpsw.c
diff options
context:
space:
mode:
authorMarek BehĂșn2022-04-07 00:33:01 +0200
committerRamon Fried2022-04-10 08:44:12 +0300
commit123ca114e07ecf28aa2538748d733e2b22d8b8b5 (patch)
tree0a5481e51e4e50b33daf4d10f37574f6f797b04f /drivers/net/ti/cpsw.c
parent9c06b4815ce1d663085c214133762614bba79fbe (diff)
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 'drivers/net/ti/cpsw.c')
-rw-r--r--drivers/net/ti/cpsw.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c
index 68f4191fe97..5b7bab734e4 100644
--- a/drivers/net/ti/cpsw.c
+++ b/drivers/net/ti/cpsw.c
@@ -1194,15 +1194,12 @@ static void cpsw_eth_of_parse_slave(struct cpsw_platform_data *data,
{
struct ofnode_phandle_args out_args;
struct cpsw_slave_data *slave_data;
- const char *phy_mode;
u32 phy_id[2];
int ret;
slave_data = &data->slave_data[slave_index];
- phy_mode = ofnode_read_string(subnode, "phy-mode");
- if (phy_mode)
- slave_data->phy_if = phy_get_interface_by_name(phy_mode);
+ slave_data->phy_if = ofnode_read_phy_mode(subnode);
ret = ofnode_parse_phandle_with_args(subnode, "phy-handle",
NULL, 0, 0, &out_args);
@@ -1348,11 +1345,8 @@ static int cpsw_eth_of_to_plat(struct udevice *dev)
}
pdata->phy_interface = data->slave_data[data->active_slave].phy_if;
- if (pdata->phy_interface == -1) {
- debug("%s: Invalid PHY interface '%s'\n", __func__,
- phy_string_for_interface(pdata->phy_interface));
+ if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE)
return -EINVAL;
- }
return 0;
}