aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/dwc_eth_qos.c
diff options
context:
space:
mode:
authorMarek BehĂșn <marek.behun@nic.cz>2022-04-07 00:33:01 +0200
committerRamon Fried <ramon@neureality.ai>2022-04-10 08:44:12 +0300
commit123ca114e07ecf28aa2538748d733e2b22d8b8b5 (patch)
tree0a5481e51e4e50b33daf4d10f37574f6f797b04f /drivers/net/dwc_eth_qos.c
parent9c06b4815ce1d663085c214133762614bba79fbe (diff)
downloadu-boot-123ca114e07ecf28aa2538748d733e2b22d8b8b5.zip
u-boot-123ca114e07ecf28aa2538748d733e2b22d8b8b5.tar.gz
u-boot-123ca114e07ecf28aa2538748d733e2b22d8b8b5.tar.bz2
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/dwc_eth_qos.c')
-rw-r--r--drivers/net/dwc_eth_qos.c36
1 files changed, 4 insertions, 32 deletions
diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index 22dad5b..9777f6c 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -270,7 +270,7 @@ struct eqos_config {
int config_mac;
int config_mac_mdio;
unsigned int axi_bus_width;
- phy_interface_t (*interface)(struct udevice *dev);
+ phy_interface_t (*interface)(const struct udevice *dev);
struct eqos_ops *ops;
};
@@ -1729,21 +1729,7 @@ err_probe:
return ret;
}
-static phy_interface_t eqos_get_interface_stm32(struct udevice *dev)
-{
- const char *phy_mode;
- phy_interface_t interface = PHY_INTERFACE_MODE_NONE;
-
- debug("%s(dev=%p):\n", __func__, dev);
-
- phy_mode = dev_read_prop(dev, "phy-mode", NULL);
- if (phy_mode)
- interface = phy_get_interface_by_name(phy_mode);
-
- return interface;
-}
-
-static phy_interface_t eqos_get_interface_tegra186(struct udevice *dev)
+static phy_interface_t eqos_get_interface_tegra186(const struct udevice *dev)
{
return PHY_INTERFACE_MODE_MII;
}
@@ -1766,20 +1752,6 @@ static int eqos_probe_resources_imx(struct udevice *dev)
return 0;
}
-static phy_interface_t eqos_get_interface_imx(struct udevice *dev)
-{
- const char *phy_mode;
- phy_interface_t interface = PHY_INTERFACE_MODE_NONE;
-
- debug("%s(dev=%p):\n", __func__, dev);
-
- phy_mode = dev_read_prop(dev, "phy-mode", NULL);
- if (phy_mode)
- interface = phy_get_interface_by_name(phy_mode);
-
- return interface;
-}
-
static int eqos_remove_resources_tegra186(struct udevice *dev)
{
struct eqos_priv *eqos = dev_get_priv(dev);
@@ -1985,7 +1957,7 @@ static const struct eqos_config __maybe_unused eqos_stm32_config = {
.config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_AV,
.config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_250_300,
.axi_bus_width = EQOS_AXI_WIDTH_64,
- .interface = eqos_get_interface_stm32,
+ .interface = dev_read_phy_mode,
.ops = &eqos_stm32_ops
};
@@ -2013,7 +1985,7 @@ struct eqos_config __maybe_unused eqos_imx_config = {
.config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB,
.config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_250_300,
.axi_bus_width = EQOS_AXI_WIDTH_64,
- .interface = eqos_get_interface_imx,
+ .interface = dev_read_phy_mode,
.ops = &eqos_imx_ops
};