提交 b8e3995a 编写于 作者: D David McKay 提交者: David S. Miller

netdev/phy/icplus: Correct broken phy_init code

The code for ip1001_config_init() was totally broken if you were not
using RGMII. Instead of returning an error code or zero it actually
returned the value in the IP1001_SPEC_CTRL_STATUS_2 register. It was
also trying to set the IP1001_APS_ON bit , but never actually wrote
back the register.

The error checking was also incorrect in both this function and the
reset function, so this patch fixes that up in a consistent fashion.
Signed-off-by: NDavid McKay <david.mckay@st.com>
Signed-off-by: NGiuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 03606895
...@@ -98,20 +98,24 @@ static int ip175c_config_init(struct phy_device *phydev) ...@@ -98,20 +98,24 @@ static int ip175c_config_init(struct phy_device *phydev)
static int ip1xx_reset(struct phy_device *phydev) static int ip1xx_reset(struct phy_device *phydev)
{ {
int err, bmcr; int bmcr;
/* Software Reset PHY */ /* Software Reset PHY */
bmcr = phy_read(phydev, MII_BMCR); bmcr = phy_read(phydev, MII_BMCR);
if (bmcr < 0)
return bmcr;
bmcr |= BMCR_RESET; bmcr |= BMCR_RESET;
err = phy_write(phydev, MII_BMCR, bmcr); bmcr = phy_write(phydev, MII_BMCR, bmcr);
if (err < 0) if (bmcr < 0)
return err; return bmcr;
do { do {
bmcr = phy_read(phydev, MII_BMCR); bmcr = phy_read(phydev, MII_BMCR);
if (bmcr < 0)
return bmcr;
} while (bmcr & BMCR_RESET); } while (bmcr & BMCR_RESET);
return err; return 0;
} }
static int ip1001_config_init(struct phy_device *phydev) static int ip1001_config_init(struct phy_device *phydev)
...@@ -124,7 +128,10 @@ static int ip1001_config_init(struct phy_device *phydev) ...@@ -124,7 +128,10 @@ static int ip1001_config_init(struct phy_device *phydev)
/* Enable Auto Power Saving mode */ /* Enable Auto Power Saving mode */
c = phy_read(phydev, IP1001_SPEC_CTRL_STATUS_2); c = phy_read(phydev, IP1001_SPEC_CTRL_STATUS_2);
if (c < 0)
return c;
c |= IP1001_APS_ON; c |= IP1001_APS_ON;
c = phy_write(phydev, IP1001_SPEC_CTRL_STATUS_2, c);
if (c < 0) if (c < 0)
return c; return c;
...@@ -132,11 +139,16 @@ static int ip1001_config_init(struct phy_device *phydev) ...@@ -132,11 +139,16 @@ static int ip1001_config_init(struct phy_device *phydev)
/* Additional delay (2ns) used to adjust RX clock phase /* Additional delay (2ns) used to adjust RX clock phase
* at RGMII interface */ * at RGMII interface */
c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS); c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
if (c < 0)
return c;
c |= IP1001_PHASE_SEL_MASK; c |= IP1001_PHASE_SEL_MASK;
c = phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c); c = phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c);
if (c < 0)
return c;
} }
return c; return 0;
} }
static int ip101a_config_init(struct phy_device *phydev) static int ip101a_config_init(struct phy_device *phydev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册