Commit af043aa5 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Jeff Garzik

sky2: longer PHY delay

Increse phy delay and handle I/O errors.
Signed-off-by: default avatarStephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent ab5adecb
...@@ -156,7 +156,7 @@ static const char *yukon2_name[] = { ...@@ -156,7 +156,7 @@ static const char *yukon2_name[] = {
static void sky2_set_multicast(struct net_device *dev); static void sky2_set_multicast(struct net_device *dev);
/* Access to external PHY */ /* Access to PHY via serial interconnect */
static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
{ {
int i; int i;
...@@ -166,13 +166,22 @@ static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) ...@@ -166,13 +166,22 @@ static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) | GM_SMI_CT_REG_AD(reg)); GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) | GM_SMI_CT_REG_AD(reg));
for (i = 0; i < PHY_RETRIES; i++) { for (i = 0; i < PHY_RETRIES; i++) {
if (!(gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_BUSY)) u16 ctrl = gma_read16(hw, port, GM_SMI_CTRL);
if (ctrl == 0xffff)
goto io_error;
if (!(ctrl & GM_SMI_CT_BUSY))
return 0; return 0;
udelay(1);
udelay(10);
} }
printk(KERN_WARNING PFX "%s: phy write timeout\n", hw->dev[port]->name); dev_warn(&hw->pdev->dev,"%s: phy write timeout\n", hw->dev[port]->name);
return -ETIMEDOUT; return -ETIMEDOUT;
io_error:
dev_err(&hw->pdev->dev, "%s: phy I/O error\n", hw->dev[port]->name);
return -EIO;
} }
static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val) static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
...@@ -183,23 +192,29 @@ static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val) ...@@ -183,23 +192,29 @@ static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
| GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD); | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD);
for (i = 0; i < PHY_RETRIES; i++) { for (i = 0; i < PHY_RETRIES; i++) {
if (gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_RD_VAL) { u16 ctrl = gma_read16(hw, port, GM_SMI_CTRL);
if (ctrl == 0xffff)
goto io_error;
if (ctrl & GM_SMI_CT_RD_VAL) {
*val = gma_read16(hw, port, GM_SMI_DATA); *val = gma_read16(hw, port, GM_SMI_DATA);
return 0; return 0;
} }
udelay(1); udelay(10);
} }
dev_warn(&hw->pdev->dev, "%s: phy read timeout\n", hw->dev[port]->name);
return -ETIMEDOUT; return -ETIMEDOUT;
io_error:
dev_err(&hw->pdev->dev, "%s: phy I/O error\n", hw->dev[port]->name);
return -EIO;
} }
static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg) static inline u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
{ {
u16 v; u16 v;
__gm_phy_read(hw, port, reg, &v);
if (__gm_phy_read(hw, port, reg, &v) != 0)
printk(KERN_WARNING PFX "%s: phy read timeout\n", hw->dev[port]->name);
return v; return v;
} }
......
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