[U-Boot] [U-boot] [Patch v2 4/5] net: keystone_net: register eth PHYs on MDIO bus

Ivan Khoronzhuk ivan.khoronzhuk at ti.com
Mon Sep 29 22:25:35 CEST 2014


As MDIO bus has been added we can register PHYs on it.
Register only for SGMII ports connected with appropriate PHY.
After registration, the PHY driver will be probed according to the
hardware on board.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk at ti.com>
---
 drivers/net/keystone_net.c | 14 ++++++++++++++
 include/configs/ks2_evm.h  |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c
index 6f7cc17..5789045 100644
--- a/drivers/net/keystone_net.c
+++ b/drivers/net/keystone_net.c
@@ -10,6 +10,7 @@
 #include <command.h>
 
 #include <net.h>
+#include <phy.h>
 #include <miiphy.h>
 #include <malloc.h>
 #include <asm/ti-common/keystone_nav.h>
@@ -527,6 +528,7 @@ int keystone2_emac_initialize(struct eth_priv_t *eth_priv)
 {
 	int res;
 	struct eth_device *dev;
+	struct phy_device *phy_dev;
 
 	dev = malloc(sizeof(struct eth_device));
 	if (dev == NULL)
@@ -561,6 +563,18 @@ int keystone2_emac_initialize(struct eth_priv_t *eth_priv)
 			return res;
 	}
 
+	/* Don't add ports that hasn't PHY */
+	if (eth_priv->sgmii_link_type != SGMII_LINK_MAC_MAC_FORCED) {
+		/* Find a phy by address and register it */
+		phy_dev = phy_connect(mdio_bus, eth_priv->phy_addr,
+				      dev, PHY_INTERFACE_MODE_SGMII);
+
+		if (phy_dev)
+			phy_config(phy_dev);
+		else
+			return -1;
+	}
+
 	return 0;
 }
 
diff --git a/include/configs/ks2_evm.h b/include/configs/ks2_evm.h
index 2e781b9..af84abc 100644
--- a/include/configs/ks2_evm.h
+++ b/include/configs/ks2_evm.h
@@ -94,6 +94,8 @@
 #define CONFIG_SYS_SPI2_NUM_CS		4
 
 /* Network Configuration */
+#define CONFIG_PHYLIB
+#define CONFIG_PHY_MARVELL
 #define CONFIG_MII
 #define CONFIG_BOOTP_DEFAULT
 #define CONFIG_BOOTP_DNS
-- 
1.8.3.2



More information about the U-Boot mailing list