mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-14 22:46:27 -04:00
net/designware: Try configuring phy on each dw_eth_init
Phy autonegotiation works only when the ethernet cable is plugged in. Since the phy was configured only at the init time, a plugged in cable was necessary to initialize the phy properly. This patch keeps a flag to check if the phy initialization has succeeded, and calls configure_phy routine at every init if this flag reports otherwise. Signed-off-by: Vipin Kumar <vipin.kumar@st.com> Signed-off-by: Amit Virdi <amit.virdi@st.com>
This commit is contained in:
parent
aa51005c3f
commit
13edd1706c
@ -32,6 +32,8 @@
|
|||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include "designware.h"
|
#include "designware.h"
|
||||||
|
|
||||||
|
static int configure_phy(struct eth_device *dev);
|
||||||
|
|
||||||
static void tx_descs_init(struct eth_device *dev)
|
static void tx_descs_init(struct eth_device *dev)
|
||||||
{
|
{
|
||||||
struct dw_eth_dev *priv = dev->priv;
|
struct dw_eth_dev *priv = dev->priv;
|
||||||
@ -144,6 +146,9 @@ static int dw_eth_init(struct eth_device *dev, bd_t *bis)
|
|||||||
struct eth_dma_regs *dma_p = priv->dma_regs_p;
|
struct eth_dma_regs *dma_p = priv->dma_regs_p;
|
||||||
u32 conf;
|
u32 conf;
|
||||||
|
|
||||||
|
if (priv->phy_configured != 1)
|
||||||
|
configure_phy(dev);
|
||||||
|
|
||||||
/* Reset ethernet hardware */
|
/* Reset ethernet hardware */
|
||||||
if (mac_reset(dev) < 0)
|
if (mac_reset(dev) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -422,23 +427,26 @@ static int configure_phy(struct eth_device *dev)
|
|||||||
eth_mdio_read(dev, phy_addr, MII_LPA, &anlpar);
|
eth_mdio_read(dev, phy_addr, MII_LPA, &anlpar);
|
||||||
eth_mdio_read(dev, phy_addr, MII_STAT1000, &btsr);
|
eth_mdio_read(dev, phy_addr, MII_STAT1000, &btsr);
|
||||||
|
|
||||||
if (btsr & (PHY_1000BTSR_1000FD | PHY_1000BTSR_1000HD)) {
|
if (bmsr & BMSR_ANEGCOMPLETE) {
|
||||||
priv->speed = SPEED_1000M;
|
if (btsr & (PHY_1000BTSR_1000FD | PHY_1000BTSR_1000HD)) {
|
||||||
if (btsr & PHY_1000BTSR_1000FD)
|
priv->speed = SPEED_1000M;
|
||||||
priv->duplex = FULL_DUPLEX;
|
if (btsr & PHY_1000BTSR_1000FD)
|
||||||
else
|
priv->duplex = FULL_DUPLEX;
|
||||||
priv->duplex = HALF_DUPLEX;
|
else
|
||||||
} else {
|
priv->duplex = HALF_DUPLEX;
|
||||||
if (anlpar & LPA_100)
|
} else {
|
||||||
priv->speed = SPEED_100M;
|
if (anlpar & LPA_100)
|
||||||
else
|
priv->speed = SPEED_100M;
|
||||||
priv->speed = SPEED_10M;
|
else
|
||||||
|
priv->speed = SPEED_10M;
|
||||||
|
|
||||||
if (anlpar & (LPA_10FULL | LPA_100FULL))
|
if (anlpar & (LPA_10FULL | LPA_100FULL))
|
||||||
priv->duplex = FULL_DUPLEX;
|
priv->duplex = FULL_DUPLEX;
|
||||||
else
|
else
|
||||||
priv->duplex = HALF_DUPLEX;
|
priv->duplex = HALF_DUPLEX;
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
return -1;
|
||||||
#else
|
#else
|
||||||
if (eth_mdio_read(dev, phy_addr, MII_BMCR, &ctrl) < 0)
|
if (eth_mdio_read(dev, phy_addr, MII_BMCR, &ctrl) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -455,6 +463,8 @@ static int configure_phy(struct eth_device *dev)
|
|||||||
else
|
else
|
||||||
priv->speed = SPEED_10M;
|
priv->speed = SPEED_10M;
|
||||||
#endif
|
#endif
|
||||||
|
priv->phy_configured = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,14 +525,12 @@ int designware_initialize(u32 id, ulong base_addr, u32 phy_addr)
|
|||||||
priv->dma_regs_p = (struct eth_dma_regs *)(base_addr +
|
priv->dma_regs_p = (struct eth_dma_regs *)(base_addr +
|
||||||
DW_DMA_BASE_OFFSET);
|
DW_DMA_BASE_OFFSET);
|
||||||
priv->address = phy_addr;
|
priv->address = phy_addr;
|
||||||
|
priv->phy_configured = 0;
|
||||||
|
|
||||||
if (mac_reset(dev) < 0)
|
if (mac_reset(dev) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (configure_phy(dev) < 0) {
|
configure_phy(dev);
|
||||||
printf("Phy could not be configured\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->init = dw_eth_init;
|
dev->init = dw_eth_init;
|
||||||
dev->send = dw_eth_send;
|
dev->send = dw_eth_send;
|
||||||
|
@ -238,6 +238,7 @@ struct dw_eth_dev {
|
|||||||
u32 duplex;
|
u32 duplex;
|
||||||
u32 tx_currdescnum;
|
u32 tx_currdescnum;
|
||||||
u32 rx_currdescnum;
|
u32 rx_currdescnum;
|
||||||
|
u32 phy_configured;
|
||||||
u32 padding;
|
u32 padding;
|
||||||
|
|
||||||
struct dmamacdescr tx_mac_descrtable[CONFIG_TX_DESCR_NUM];
|
struct dmamacdescr tx_mac_descrtable[CONFIG_TX_DESCR_NUM];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user