diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2011-04-20 03:57:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-21 20:05:58 -0400 |
commit | 15ee95c36d355a9f47746eaa4ae8cc0ecafec550 (patch) | |
tree | 4ed0541d64914e1e29705e4542ea23f5c9b6a03b /drivers/net/tg3.c | |
parent | b0988c15c12c40b9680730f55a8351f30ec7a564 (diff) |
tg3: Add read accessor for AUX CTRL phy reg
This patch adds a read accessor for the aux ctrl register.
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index ea41d76a70d3..7be10cfb0a5f 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -949,6 +949,19 @@ static int tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val) | |||
949 | return err; | 949 | return err; |
950 | } | 950 | } |
951 | 951 | ||
952 | static int tg3_phy_auxctl_read(struct tg3 *tp, int reg, u32 *val) | ||
953 | { | ||
954 | int err; | ||
955 | |||
956 | err = tg3_writephy(tp, MII_TG3_AUX_CTRL, | ||
957 | (reg << MII_TG3_AUXCTL_MISC_RDSEL_SHIFT) | | ||
958 | MII_TG3_AUXCTL_SHDWSEL_MISC); | ||
959 | if (!err) | ||
960 | err = tg3_readphy(tp, MII_TG3_AUX_CTRL, val); | ||
961 | |||
962 | return err; | ||
963 | } | ||
964 | |||
952 | static int tg3_bmcr_reset(struct tg3 *tp) | 965 | static int tg3_bmcr_reset(struct tg3 *tp) |
953 | { | 966 | { |
954 | u32 phy_control; | 967 | u32 phy_control; |
@@ -1679,10 +1692,11 @@ static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable) | |||
1679 | tg3_writephy(tp, MII_TG3_FET_TEST, ephy); | 1692 | tg3_writephy(tp, MII_TG3_FET_TEST, ephy); |
1680 | } | 1693 | } |
1681 | } else { | 1694 | } else { |
1682 | phy = MII_TG3_AUXCTL_MISC_RDSEL_MISC | | 1695 | int ret; |
1683 | MII_TG3_AUXCTL_SHDWSEL_MISC; | 1696 | |
1684 | if (!tg3_writephy(tp, MII_TG3_AUX_CTRL, phy) && | 1697 | ret = tg3_phy_auxctl_read(tp, |
1685 | !tg3_readphy(tp, MII_TG3_AUX_CTRL, &phy)) { | 1698 | MII_TG3_AUXCTL_SHDWSEL_MISC, &phy); |
1699 | if (!ret) { | ||
1686 | if (enable) | 1700 | if (enable) |
1687 | phy |= MII_TG3_AUXCTL_MISC_FORCE_AMDIX; | 1701 | phy |= MII_TG3_AUXCTL_MISC_FORCE_AMDIX; |
1688 | else | 1702 | else |
@@ -1695,13 +1709,14 @@ static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable) | |||
1695 | 1709 | ||
1696 | static void tg3_phy_set_wirespeed(struct tg3 *tp) | 1710 | static void tg3_phy_set_wirespeed(struct tg3 *tp) |
1697 | { | 1711 | { |
1712 | int ret; | ||
1698 | u32 val; | 1713 | u32 val; |
1699 | 1714 | ||
1700 | if (tp->phy_flags & TG3_PHYFLG_NO_ETH_WIRE_SPEED) | 1715 | if (tp->phy_flags & TG3_PHYFLG_NO_ETH_WIRE_SPEED) |
1701 | return; | 1716 | return; |
1702 | 1717 | ||
1703 | if (!tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x7007) && | 1718 | ret = tg3_phy_auxctl_read(tp, MII_TG3_AUXCTL_SHDWSEL_MISC, &val); |
1704 | !tg3_readphy(tp, MII_TG3_AUX_CTRL, &val)) | 1719 | if (!ret) |
1705 | tg3_writephy(tp, MII_TG3_AUX_CTRL, | 1720 | tg3_writephy(tp, MII_TG3_AUX_CTRL, |
1706 | (val | (1 << 15) | (1 << 4))); | 1721 | (val | (1 << 15) | (1 << 4))); |
1707 | } | 1722 | } |
@@ -2092,8 +2107,9 @@ out: | |||
2092 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20); | 2107 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20); |
2093 | } else if (tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) { | 2108 | } else if (tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) { |
2094 | /* Set bit 14 with read-modify-write to preserve other bits */ | 2109 | /* Set bit 14 with read-modify-write to preserve other bits */ |
2095 | if (!tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0007) && | 2110 | err = tg3_phy_auxctl_read(tp, |
2096 | !tg3_readphy(tp, MII_TG3_AUX_CTRL, &val)) | 2111 | MII_TG3_AUXCTL_SHDWSEL_AUXCTL, &val); |
2112 | if (!err) | ||
2097 | tg3_writephy(tp, MII_TG3_AUX_CTRL, val | 0x4000); | 2113 | tg3_writephy(tp, MII_TG3_AUX_CTRL, val | 0x4000); |
2098 | } | 2114 | } |
2099 | 2115 | ||
@@ -3263,9 +3279,10 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset) | |||
3263 | current_duplex = DUPLEX_INVALID; | 3279 | current_duplex = DUPLEX_INVALID; |
3264 | 3280 | ||
3265 | if (tp->phy_flags & TG3_PHYFLG_CAPACITIVE_COUPLING) { | 3281 | if (tp->phy_flags & TG3_PHYFLG_CAPACITIVE_COUPLING) { |
3266 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4007); | 3282 | err = tg3_phy_auxctl_read(tp, |
3267 | tg3_readphy(tp, MII_TG3_AUX_CTRL, &val); | 3283 | MII_TG3_AUXCTL_SHDWSEL_MISCTEST, |
3268 | if (!(val & (1 << 10))) { | 3284 | &val); |
3285 | if (!err && !(val & (1 << 10))) { | ||
3269 | val |= (1 << 10); | 3286 | val |= (1 << 10); |
3270 | tg3_writephy(tp, MII_TG3_AUX_CTRL, val); | 3287 | tg3_writephy(tp, MII_TG3_AUX_CTRL, val); |
3271 | goto relink; | 3288 | goto relink; |