Commit 3db5d555 authored by Timur Tabi's avatar Timur Tabi Committed by David S. Miller

net: qcom/emac: always use autonegotiation to configure the SGMII link

Regardless of how the external PHY is configured, the internal PHY
(the "SGMII" block) is capable of configuring the SGMII link automatically.
When the external PHY link comes up, regardless of how it is configured,
the SGMII link is configured automatically.
Signed-off-by: default avatarTimur Tabi <timur@codeaurora.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9da34f27
...@@ -47,44 +47,19 @@ ...@@ -47,44 +47,19 @@
#define SERDES_START_WAIT_TIMES 100 #define SERDES_START_WAIT_TIMES 100
static int emac_sgmii_link_init(struct emac_adapter *adpt) /* Initialize the SGMII link between the internal and external PHYs. */
static void emac_sgmii_link_init(struct emac_adapter *adpt)
{ {
struct phy_device *phydev = adpt->phydev;
struct emac_sgmii *phy = &adpt->phy; struct emac_sgmii *phy = &adpt->phy;
u32 val; u32 val;
/* Always use autonegotiation. It works no matter how the external
* PHY is configured.
*/
val = readl(phy->base + EMAC_SGMII_PHY_AUTONEG_CFG2); val = readl(phy->base + EMAC_SGMII_PHY_AUTONEG_CFG2);
val &= ~(FORCE_AN_RX_CFG | FORCE_AN_TX_CFG);
if (phydev->autoneg == AUTONEG_ENABLE) { val |= AN_ENABLE;
val &= ~(FORCE_AN_RX_CFG | FORCE_AN_TX_CFG); writel(val, phy->base + EMAC_SGMII_PHY_AUTONEG_CFG2);
val |= AN_ENABLE;
writel(val, phy->base + EMAC_SGMII_PHY_AUTONEG_CFG2);
} else {
u32 speed_cfg;
switch (phydev->speed) {
case SPEED_10:
speed_cfg = SPDMODE_10;
break;
case SPEED_100:
speed_cfg = SPDMODE_100;
break;
case SPEED_1000:
speed_cfg = SPDMODE_1000;
break;
default:
return -EINVAL;
}
if (phydev->duplex == DUPLEX_FULL)
speed_cfg |= DUPLEX_MODE;
val &= ~AN_ENABLE;
writel(speed_cfg, phy->base + EMAC_SGMII_PHY_SPEED_CFG1);
writel(val, phy->base + EMAC_SGMII_PHY_AUTONEG_CFG2);
}
return 0;
} }
static int emac_sgmii_irq_clear(struct emac_adapter *adpt, u32 irq_bits) static int emac_sgmii_irq_clear(struct emac_adapter *adpt, u32 irq_bits)
...@@ -145,12 +120,7 @@ void emac_sgmii_reset(struct emac_adapter *adpt) ...@@ -145,12 +120,7 @@ void emac_sgmii_reset(struct emac_adapter *adpt)
int ret; int ret;
emac_sgmii_reset_prepare(adpt); emac_sgmii_reset_prepare(adpt);
emac_sgmii_link_init(adpt);
ret = emac_sgmii_link_init(adpt);
if (ret) {
netdev_err(adpt->netdev, "unsupported link speed\n");
return;
}
ret = adpt->phy.initialize(adpt); ret = adpt->phy.initialize(adpt);
if (ret) if (ret)
...@@ -287,6 +257,7 @@ int emac_sgmii_config(struct platform_device *pdev, struct emac_adapter *adpt) ...@@ -287,6 +257,7 @@ int emac_sgmii_config(struct platform_device *pdev, struct emac_adapter *adpt)
goto error; goto error;
emac_sgmii_irq_clear(adpt, SGMII_PHY_INTERRUPT_ERR); emac_sgmii_irq_clear(adpt, SGMII_PHY_INTERRUPT_ERR);
emac_sgmii_link_init(adpt);
/* We've remapped the addresses, so we don't need the device any /* We've remapped the addresses, so we don't need the device any
* more. of_find_device_by_node() says we should release it. * more. of_find_device_by_node() says we should release it.
......
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