summaryrefslogtreecommitdiff
path: root/drivers/net/mvpp2.c
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 /drivers/net/mvpp2.c
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 'drivers/net/mvpp2.c')
-rw-r--r--drivers/net/mvpp2.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 4c0a7b0a9f..dfddac180f 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -4786,11 +4786,9 @@ static int mvpp2_port_init(struct udevice *dev, struct mvpp2_port *port)
static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
{
int port_node = dev_of_offset(dev);
- const char *phy_mode_str;
int phy_node;
u32 id;
u32 phyaddr = 0;
- int phy_mode = -1;
int fixed_link = 0;
int ret;
@@ -4821,10 +4819,8 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
phyaddr = PHY_MAX_ADDR;
}
- phy_mode_str = fdt_getprop(gd->fdt_blob, port_node, "phy-mode", NULL);
- if (phy_mode_str)
- phy_mode = phy_get_interface_by_name(phy_mode_str);
- if (phy_mode == -1) {
+ port->phy_interface = dev_read_phy_mode(dev);
+ if (port->phy_interface == PHY_INTERFACE_MODE_NONE) {
dev_err(dev, "incorrect phy mode\n");
return -EINVAL;
}
@@ -4847,7 +4843,6 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
port->first_rxq = port->id * rxq_number;
else
port->first_rxq = port->id * port->priv->max_port_rxqs;
- port->phy_interface = phy_mode;
port->phyaddr = phyaddr;
return 0;