Commit 239aa55b authored by David Thomson's avatar David Thomson Committed by David S. Miller

net: phy: Support setting polarity in marvell phy driver

Support manually setting the polarity to mdi or mdix
Signed-off-by: default avatarDavid Thomson <david.thomson@alliedtelesis.co.nz>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 634ec36c
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
#define MII_M1011_IMASK_CLEAR 0x0000 #define MII_M1011_IMASK_CLEAR 0x0000
#define MII_M1011_PHY_SCR 0x10 #define MII_M1011_PHY_SCR 0x10
#define MII_M1011_PHY_SCR_MDI 0x0000
#define MII_M1011_PHY_SCR_MDI_X 0x0020
#define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060 #define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060
#define MII_M1145_PHY_EXT_SR 0x1b #define MII_M1145_PHY_EXT_SR 0x1b
...@@ -159,6 +161,43 @@ static int marvell_config_intr(struct phy_device *phydev) ...@@ -159,6 +161,43 @@ static int marvell_config_intr(struct phy_device *phydev)
return err; return err;
} }
static int marvell_set_polarity(struct phy_device *phydev, int polarity)
{
int reg;
int err;
int val;
/* get the current settings */
reg = phy_read(phydev, MII_M1011_PHY_SCR);
if (reg < 0)
return reg;
val = reg;
val &= ~MII_M1011_PHY_SCR_AUTO_CROSS;
switch (polarity) {
case ETH_TP_MDI:
val |= MII_M1011_PHY_SCR_MDI;
break;
case ETH_TP_MDI_X:
val |= MII_M1011_PHY_SCR_MDI_X;
break;
case ETH_TP_MDI_AUTO:
case ETH_TP_MDI_INVALID:
default:
val |= MII_M1011_PHY_SCR_AUTO_CROSS;
break;
}
if (val != reg) {
/* Set the new polarity value in the register */
err = phy_write(phydev, MII_M1011_PHY_SCR, val);
if (err)
return err;
}
return 0;
}
static int marvell_config_aneg(struct phy_device *phydev) static int marvell_config_aneg(struct phy_device *phydev)
{ {
int err; int err;
...@@ -191,8 +230,7 @@ static int marvell_config_aneg(struct phy_device *phydev) ...@@ -191,8 +230,7 @@ static int marvell_config_aneg(struct phy_device *phydev)
if (err < 0) if (err < 0)
return err; return err;
err = phy_write(phydev, MII_M1011_PHY_SCR, err = marvell_set_polarity(phydev, phydev->mdix);
MII_M1011_PHY_SCR_AUTO_CROSS);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -379,6 +379,7 @@ int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd) ...@@ -379,6 +379,7 @@ int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd)
cmd->transceiver = phy_is_internal(phydev) ? cmd->transceiver = phy_is_internal(phydev) ?
XCVR_INTERNAL : XCVR_EXTERNAL; XCVR_INTERNAL : XCVR_EXTERNAL;
cmd->autoneg = phydev->autoneg; cmd->autoneg = phydev->autoneg;
cmd->eth_tp_mdix_ctrl = phydev->mdix;
return 0; return 0;
} }
......
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