diff options
author | David Thomson <david.thomson@alliedtelesis.co.nz> | 2015-07-10 00:28:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-07-11 02:17:32 -0400 |
commit | 239aa55b9496144f89670b545b5698e6c989f710 (patch) | |
tree | be0bbed05631a3bc8ae273d64319dad5b01ebb0a /drivers/net/phy | |
parent | 634ec36cc0ab9d8dda0f2c101fa28d2e2a61b9eb (diff) |
net: phy: Support setting polarity in marvell phy driver
Support manually setting the polarity to mdi or mdix
Signed-off-by: David Thomson <david.thomson@alliedtelesis.co.nz>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r-- | drivers/net/phy/marvell.c | 42 | ||||
-rw-r--r-- | drivers/net/phy/phy.c | 1 |
2 files changed, 41 insertions, 2 deletions
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index f721444c2b0a..3320a179ee36 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c | |||
@@ -48,6 +48,8 @@ | |||
48 | #define MII_M1011_IMASK_CLEAR 0x0000 | 48 | #define MII_M1011_IMASK_CLEAR 0x0000 |
49 | 49 | ||
50 | #define MII_M1011_PHY_SCR 0x10 | 50 | #define MII_M1011_PHY_SCR 0x10 |
51 | #define MII_M1011_PHY_SCR_MDI 0x0000 | ||
52 | #define MII_M1011_PHY_SCR_MDI_X 0x0020 | ||
51 | #define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060 | 53 | #define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060 |
52 | 54 | ||
53 | #define MII_M1145_PHY_EXT_SR 0x1b | 55 | #define MII_M1145_PHY_EXT_SR 0x1b |
@@ -159,6 +161,43 @@ static int marvell_config_intr(struct phy_device *phydev) | |||
159 | return err; | 161 | return err; |
160 | } | 162 | } |
161 | 163 | ||
164 | static int marvell_set_polarity(struct phy_device *phydev, int polarity) | ||
165 | { | ||
166 | int reg; | ||
167 | int err; | ||
168 | int val; | ||
169 | |||
170 | /* get the current settings */ | ||
171 | reg = phy_read(phydev, MII_M1011_PHY_SCR); | ||
172 | if (reg < 0) | ||
173 | return reg; | ||
174 | |||
175 | val = reg; | ||
176 | val &= ~MII_M1011_PHY_SCR_AUTO_CROSS; | ||
177 | switch (polarity) { | ||
178 | case ETH_TP_MDI: | ||
179 | val |= MII_M1011_PHY_SCR_MDI; | ||
180 | break; | ||
181 | case ETH_TP_MDI_X: | ||
182 | val |= MII_M1011_PHY_SCR_MDI_X; | ||
183 | break; | ||
184 | case ETH_TP_MDI_AUTO: | ||
185 | case ETH_TP_MDI_INVALID: | ||
186 | default: | ||
187 | val |= MII_M1011_PHY_SCR_AUTO_CROSS; | ||
188 | break; | ||
189 | } | ||
190 | |||
191 | if (val != reg) { | ||
192 | /* Set the new polarity value in the register */ | ||
193 | err = phy_write(phydev, MII_M1011_PHY_SCR, val); | ||
194 | if (err) | ||
195 | return err; | ||
196 | } | ||
197 | |||
198 | return 0; | ||
199 | } | ||
200 | |||
162 | static int marvell_config_aneg(struct phy_device *phydev) | 201 | static int marvell_config_aneg(struct phy_device *phydev) |
163 | { | 202 | { |
164 | int err; | 203 | int err; |
@@ -191,8 +230,7 @@ static int marvell_config_aneg(struct phy_device *phydev) | |||
191 | if (err < 0) | 230 | if (err < 0) |
192 | return err; | 231 | return err; |
193 | 232 | ||
194 | err = phy_write(phydev, MII_M1011_PHY_SCR, | 233 | err = marvell_set_polarity(phydev, phydev->mdix); |
195 | MII_M1011_PHY_SCR_AUTO_CROSS); | ||
196 | if (err < 0) | 234 | if (err < 0) |
197 | return err; | 235 | return err; |
198 | 236 | ||
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 47693a9ebd3a..84b1fba58ac3 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c | |||
@@ -379,6 +379,7 @@ int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd) | |||
379 | cmd->transceiver = phy_is_internal(phydev) ? | 379 | cmd->transceiver = phy_is_internal(phydev) ? |
380 | XCVR_INTERNAL : XCVR_EXTERNAL; | 380 | XCVR_INTERNAL : XCVR_EXTERNAL; |
381 | cmd->autoneg = phydev->autoneg; | 381 | cmd->autoneg = phydev->autoneg; |
382 | cmd->eth_tp_mdix_ctrl = phydev->mdix; | ||
382 | 383 | ||
383 | return 0; | 384 | return 0; |
384 | } | 385 | } |