[U-Boot,3/7] net: netcp: add support for phy with rgmii ids

Message ID 20190211172023.11981-4-m-karicheri2@ti.com
State Superseded
Delegated to: Tom Rini
Headers show
Series
  • Add netcp networking support on K2G ICE EVM
Related show

Commit Message

Murali Karicheri Feb. 11, 2019, 5:20 p.m.
Enhance the netcp driver to support phys that can be configured
for internal delay (rgmii-id, rgmii-rxid, rgmii-txid)

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ti/keystone_net.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/net/ti/keystone_net.c b/drivers/net/ti/keystone_net.c
index a3ba91cc3f..defc57b29f 100644
--- a/drivers/net/ti/keystone_net.c
+++ b/drivers/net/ti/keystone_net.c
@@ -88,6 +88,7 @@  struct ks2_eth_priv {
 	struct mii_dev			*mdio_bus;
 	int				phy_addr;
 	phy_interface_t			phy_if;
+	int				phy_of_handle;
 	int				sgmii_link_type;
 	void				*mdio_base;
 	struct rx_buff_desc		net_rx_buffs;
@@ -588,6 +589,10 @@  static int ks2_eth_probe(struct udevice *dev)
 	if (priv->has_mdio) {
 		priv->phydev = phy_connect(priv->mdio_bus, priv->phy_addr,
 					   dev, priv->phy_if);
+#ifdef CONFIG_DM_ETH
+	if (priv->phy_of_handle)
+		dev_set_of_offset(priv->phydev->dev, priv->phy_of_handle);
+#endif
 		phy_config(priv->phydev);
 	}
 
@@ -679,6 +684,7 @@  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;
@@ -700,7 +706,9 @@  static int ks2_eth_parse_slave_interface(int netcp, int slave,
 	priv->link_type = fdtdec_get_int(fdt, slave, "link-interface", -1);
 
 	phy = fdtdec_lookup_phandle(fdt, slave, "phy-handle");
+
 	if (phy >= 0) {
+		priv->phy_of_handle = phy;
 		priv->phy_addr = fdtdec_get_int(fdt, phy, "reg", -1);
 
 		mdio = fdt_parent_offset(fdt, phy);
@@ -717,7 +725,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) {
-		priv->phy_if = PHY_INTERFACE_MODE_RGMII;
+		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 = PHY_INTERFACE_MODE_RGMII;
+		}
 		pdata->phy_interface = priv->phy_if;
 		priv->has_mdio = true;
 	}