[U-Boot] [U-boot] [Patch v2 4/5] net: keystone_net: register eth PHYs on MDIO bus
Ivan Khoronzhuk
ivan.khoronzhuk at ti.com
Fri Oct 17 19:44:35 CEST 2014
As MDIO bus has been added we can register PHYs with it.
After registration, the PHY driver will be probed according to the
hardware on board.
Startup PHY at the ethernet open.
Use phy_startup() instead of keystone_get_link_status() when eth open,
as it verifies PHY link inside and SGMII link is checked before.
For K2HK evm PHY configuration at init was absent, so don't enable
phy config at init for k2hk evm.
Acked-by: Vitaly Andrianov <vitalya at ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk at ti.com>
---
arch/arm/include/asm/ti-common/keystone_net.h | 1 +
drivers/net/keystone_net.c | 24 +++++++++++++++++++++---
include/configs/ks2_evm.h | 2 ++
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/arch/arm/include/asm/ti-common/keystone_net.h b/arch/arm/include/asm/ti-common/keystone_net.h
index e56759d..011c03c 100644
--- a/arch/arm/include/asm/ti-common/keystone_net.h
+++ b/arch/arm/include/asm/ti-common/keystone_net.h
@@ -239,6 +239,7 @@ struct eth_priv_t {
int phy_addr;
int slave_port;
int sgmii_link_type;
+ struct phy_device *phy_dev;
};
int keystone2_emac_initialize(struct eth_priv_t *eth_priv);
diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c
index 265530a..fa8e1ef 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>
@@ -398,8 +399,8 @@ int32_t cpmac_drv_send(u32 *buffer, int num_bytes, int slave_port_num)
/* Eth device open */
static int keystone2_eth_open(struct eth_device *dev, bd_t *bis)
{
- int link;
struct eth_priv_t *eth_priv = (struct eth_priv_t *)dev->priv;
+ struct phy_device *phy_dev = eth_priv->phy_dev;
debug("+ emac_open\n");
@@ -439,8 +440,8 @@ static int keystone2_eth_open(struct eth_device *dev, bd_t *bis)
if (sys_has_mdio) {
keystone2_mdio_reset(mdio_bus);
- link = keystone_get_link_status(dev);
- if (link == 0) {
+ phy_startup(phy_dev);
+ if (phy_dev->link == 0) {
ksnav_close(&netcp_pktdma);
qm_close();
return -1;
@@ -461,6 +462,9 @@ static int keystone2_eth_open(struct eth_device *dev, bd_t *bis)
/* Eth device close */
void keystone2_eth_close(struct eth_device *dev)
{
+ struct eth_priv_t *eth_priv = (struct eth_priv_t *)dev->priv;
+ struct phy_device *phy_dev = eth_priv->phy_dev;
+
debug("+ emac_close\n");
if (!emac_open)
@@ -470,6 +474,7 @@ void keystone2_eth_close(struct eth_device *dev)
ksnav_close(&netcp_pktdma);
qm_close();
+ phy_shutdown(phy_dev);
emac_open = 0;
@@ -522,6 +527,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)
@@ -556,6 +562,18 @@ int keystone2_emac_initialize(struct eth_priv_t *eth_priv)
return res;
}
+ /* Create phy device and bind it with driver */
+#ifdef CONFIG_KSNET_MDIO_PHY_CONFIG_ENABLE
+ phy_dev = phy_connect(mdio_bus, eth_priv->phy_addr,
+ dev, PHY_INTERFACE_MODE_SGMII);
+ phy_config(phy_dev);
+#else
+ phy_dev = phy_find_by_mask(mdio_bus, 1 << eth_priv->phy_addr,
+ PHY_INTERFACE_MODE_SGMII);
+ phy_dev->dev = dev;
+#endif
+ eth_priv->phy_dev = phy_dev;
+
return 0;
}
diff --git a/include/configs/ks2_evm.h b/include/configs/ks2_evm.h
index 7fbb648..8d02d18 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