Commit ef025045 authored by Raju Lakkaraju's avatar Raju Lakkaraju Committed by David S. Miller

net: lan743x: Create separate PCS power reset function

Create separate PCS power reset function from lan743x_sgmii_config () to use
as subroutine.
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarRaju Lakkaraju <Raju.Lakkaraju@microchip.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4b3fc475
...@@ -1147,12 +1147,39 @@ static int lan743x_pcs_seq_state(struct lan743x_adapter *adapter, u8 state) ...@@ -1147,12 +1147,39 @@ static int lan743x_pcs_seq_state(struct lan743x_adapter *adapter, u8 state)
return 0; return 0;
} }
static int lan743x_pcs_power_reset(struct lan743x_adapter *adapter)
{
int mii_ctl;
int ret;
/* SGMII/1000/2500BASE-X PCS power down */
mii_ctl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMCR);
if (mii_ctl < 0)
return mii_ctl;
mii_ctl |= BMCR_PDOWN;
ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl);
if (ret < 0)
return ret;
ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_DOWN);
if (ret < 0)
return ret;
/* SGMII/1000/2500BASE-X PCS power up */
mii_ctl &= ~BMCR_PDOWN;
ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl);
if (ret < 0)
return ret;
return lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_UP);
}
static int lan743x_sgmii_config(struct lan743x_adapter *adapter) static int lan743x_sgmii_config(struct lan743x_adapter *adapter)
{ {
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
struct phy_device *phydev = netdev->phydev; struct phy_device *phydev = netdev->phydev;
enum lan743x_sgmii_lsd lsd = POWER_DOWN; enum lan743x_sgmii_lsd lsd = POWER_DOWN;
int mii_ctl;
bool status; bool status;
int ret; int ret;
...@@ -1209,31 +1236,7 @@ static int lan743x_sgmii_config(struct lan743x_adapter *adapter) ...@@ -1209,31 +1236,7 @@ static int lan743x_sgmii_config(struct lan743x_adapter *adapter)
netif_dbg(adapter, drv, adapter->netdev, netif_dbg(adapter, drv, adapter->netdev,
"SGMII 1G mode enable\n"); "SGMII 1G mode enable\n");
/* SGMII/1000/2500BASE-X PCS power down */ return lan743x_pcs_power_reset(adapter);
mii_ctl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMCR);
if (mii_ctl < 0)
return mii_ctl;
mii_ctl |= BMCR_PDOWN;
ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl);
if (ret < 0)
return ret;
ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_DOWN);
if (ret < 0)
return ret;
/* SGMII/1000/2500BASE-X PCS power up */
mii_ctl &= ~BMCR_PDOWN;
ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl);
if (ret < 0)
return ret;
ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_UP);
if (ret < 0)
return ret;
return 0;
} }
static void lan743x_mac_set_address(struct lan743x_adapter *adapter, static void lan743x_mac_set_address(struct lan743x_adapter *adapter,
......
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