Commit 0781191c authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Francois Romieu

skge: genesis phy initialzation

The SysKonnect Genesis based board would fail on initialization
with phy_read errors caused by not waiting for last phy write.
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
parent a9cdab86
...@@ -879,13 +879,12 @@ static int __xm_phy_read(struct skge_hw *hw, int port, u16 reg, u16 *val) ...@@ -879,13 +879,12 @@ static int __xm_phy_read(struct skge_hw *hw, int port, u16 reg, u16 *val)
int i; int i;
xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr); xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr);
xm_read16(hw, port, XM_PHY_DATA); *val = xm_read16(hw, port, XM_PHY_DATA);
/* Need to wait for external PHY */
for (i = 0; i < PHY_RETRIES; i++) { for (i = 0; i < PHY_RETRIES; i++) {
udelay(1);
if (xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_RDY) if (xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_RDY)
goto ready; goto ready;
udelay(1);
} }
return -ETIMEDOUT; return -ETIMEDOUT;
...@@ -918,7 +917,12 @@ static int xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val) ...@@ -918,7 +917,12 @@ static int xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val)
ready: ready:
xm_write16(hw, port, XM_PHY_DATA, val); xm_write16(hw, port, XM_PHY_DATA, val);
return 0; for (i = 0; i < PHY_RETRIES; i++) {
if (!(xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_BUSY))
return 0;
udelay(1);
}
return -ETIMEDOUT;
} }
static void genesis_init(struct skge_hw *hw) static void genesis_init(struct skge_hw *hw)
...@@ -1168,13 +1172,17 @@ static void genesis_mac_init(struct skge_hw *hw, int port) ...@@ -1168,13 +1172,17 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
u32 r; u32 r;
const u8 zero[6] = { 0 }; const u8 zero[6] = { 0 };
/* Clear MIB counters */ for (i = 0; i < 10; i++) {
xm_write16(hw, port, XM_STAT_CMD, skge_write16(hw, SK_REG(port, TX_MFF_CTRL1),
XM_SC_CLR_RXC | XM_SC_CLR_TXC); MFF_SET_MAC_RST);
/* Clear two times according to Errata #3 */ if (skge_read16(hw, SK_REG(port, TX_MFF_CTRL1)) & MFF_SET_MAC_RST)
xm_write16(hw, port, XM_STAT_CMD, goto reset_ok;
XM_SC_CLR_RXC | XM_SC_CLR_TXC); udelay(1);
}
printk(KERN_WARNING PFX "%s: genesis reset failed\n", dev->name);
reset_ok:
/* Unreset the XMAC. */ /* Unreset the XMAC. */
skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_CLR_MAC_RST); skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_CLR_MAC_RST);
...@@ -1191,7 +1199,7 @@ static void genesis_mac_init(struct skge_hw *hw, int port) ...@@ -1191,7 +1199,7 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
r |= GP_DIR_2|GP_IO_2; r |= GP_DIR_2|GP_IO_2;
skge_write32(hw, B2_GP_IO, r); skge_write32(hw, B2_GP_IO, r);
skge_read32(hw, B2_GP_IO);
/* Enable GMII interface */ /* Enable GMII interface */
xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD); xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD);
...@@ -1205,6 +1213,13 @@ static void genesis_mac_init(struct skge_hw *hw, int port) ...@@ -1205,6 +1213,13 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
for (i = 1; i < 16; i++) for (i = 1; i < 16; i++)
xm_outaddr(hw, port, XM_EXM(i), zero); xm_outaddr(hw, port, XM_EXM(i), zero);
/* Clear MIB counters */
xm_write16(hw, port, XM_STAT_CMD,
XM_SC_CLR_RXC | XM_SC_CLR_TXC);
/* Clear two times according to Errata #3 */
xm_write16(hw, port, XM_STAT_CMD,
XM_SC_CLR_RXC | XM_SC_CLR_TXC);
/* configure Rx High Water Mark (XM_RX_HI_WM) */ /* configure Rx High Water Mark (XM_RX_HI_WM) */
xm_write16(hw, port, XM_RX_HI_WM, 1450); xm_write16(hw, port, XM_RX_HI_WM, 1450);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment