diff options
author | Marek BehĂșn <marek.behun@nic.cz> | 2022-04-07 00:33:01 +0200 |
---|---|---|
committer | Ramon Fried <ramon@neureality.ai> | 2022-04-10 08:44:12 +0300 |
commit | 123ca114e07ecf28aa2538748d733e2b22d8b8b5 (patch) | |
tree | 0a5481e51e4e50b33daf4d10f37574f6f797b04f /drivers/net/ti/keystone_net.c | |
parent | 9c06b4815ce1d663085c214133762614bba79fbe (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/keystone_net.c')
-rw-r--r-- | drivers/net/ti/keystone_net.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/net/ti/keystone_net.c b/drivers/net/ti/keystone_net.c index 5e8f683c29..b55e7da4c1 100644 --- a/drivers/net/ti/keystone_net.c +++ b/drivers/net/ti/keystone_net.c @@ -687,7 +687,6 @@ static int ks2_eth_parse_slave_interface(int netcp, int slave, int phy; int dma_count; u32 dma_channel[8]; - const char *phy_mode; priv->slave_port = fdtdec_get_int(fdt, slave, "slave-port", -1); priv->net_rx_buffs.rx_flow = priv->slave_port * 8; @@ -728,20 +727,19 @@ static int ks2_eth_parse_slave_interface(int netcp, int slave, priv->sgmii_link_type = SGMII_LINK_MAC_PHY; priv->has_mdio = true; } else if (priv->link_type == LINK_TYPE_RGMII_LINK_MAC_PHY) { - phy_mode = fdt_getprop(fdt, slave, "phy-mode", NULL); - if (phy_mode) { - priv->phy_if = phy_get_interface_by_name(phy_mode); - if (priv->phy_if != PHY_INTERFACE_MODE_RGMII && - priv->phy_if != PHY_INTERFACE_MODE_RGMII_ID && - priv->phy_if != PHY_INTERFACE_MODE_RGMII_RXID && - priv->phy_if != PHY_INTERFACE_MODE_RGMII_TXID) { - pr_err("invalid phy-mode\n"); - return -EINVAL; - } - } else { + priv->phy_if = ofnode_read_phy_mode(offset_to_ofnode(slave)); + if (priv->phy_if == PHY_INTERFACE_MODE_NONE) priv->phy_if = PHY_INTERFACE_MODE_RGMII; - } pdata->phy_interface = priv->phy_if; + + if (priv->phy_if != PHY_INTERFACE_MODE_RGMII && + priv->phy_if != PHY_INTERFACE_MODE_RGMII_ID && + priv->phy_if != PHY_INTERFACE_MODE_RGMII_RXID && + priv->phy_if != PHY_INTERFACE_MODE_RGMII_TXID) { + pr_err("invalid phy-mode\n"); + return -EINVAL; + } + priv->has_mdio = true; } |