aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2011-04-20 03:57:40 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-21 20:05:58 -0400
commit15ee95c36d355a9f47746eaa4ae8cc0ecafec550 (patch)
tree4ed0541d64914e1e29705e4542ea23f5c9b6a03b /drivers
parentb0988c15c12c40b9680730f55a8351f30ec7a564 (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')
-rw-r--r--drivers/net/tg3.c39
-rw-r--r--drivers/net/tg3.h17
2 files changed, 38 insertions, 18 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
952static 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
952static int tg3_bmcr_reset(struct tg3 *tp) 965static 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
1696static void tg3_phy_set_wirespeed(struct tg3 *tp) 1710static 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;
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index dd331f8d3f7a..b9382f18b631 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2194,19 +2194,22 @@
2194 2194
2195#define MII_TG3_AUX_CTRL 0x18 /* auxiliary control register */ 2195#define MII_TG3_AUX_CTRL 0x18 /* auxiliary control register */
2196 2196
2197#define MII_TG3_AUXCTL_SHDWSEL_AUXCTL 0x0000
2198#define MII_TG3_AUXCTL_ACTL_TX_6DB 0x0400
2199#define MII_TG3_AUXCTL_ACTL_SMDSP_ENA 0x0800
2200
2201#define MII_TG3_AUXCTL_SHDWSEL_PWRCTL 0x0002
2197#define MII_TG3_AUXCTL_PCTL_100TX_LPWR 0x0010 2202#define MII_TG3_AUXCTL_PCTL_100TX_LPWR 0x0010
2198#define MII_TG3_AUXCTL_PCTL_SPR_ISOLATE 0x0020 2203#define MII_TG3_AUXCTL_PCTL_SPR_ISOLATE 0x0020
2199#define MII_TG3_AUXCTL_PCTL_VREG_11V 0x0180 2204#define MII_TG3_AUXCTL_PCTL_VREG_11V 0x0180
2200#define MII_TG3_AUXCTL_SHDWSEL_PWRCTL 0x0002
2201 2205
2202#define MII_TG3_AUXCTL_MISC_WREN 0x8000 2206#define MII_TG3_AUXCTL_SHDWSEL_MISCTEST 0x0004
2203#define MII_TG3_AUXCTL_MISC_FORCE_AMDIX 0x0200 2207
2204#define MII_TG3_AUXCTL_MISC_RDSEL_MISC 0x7000
2205#define MII_TG3_AUXCTL_SHDWSEL_MISC 0x0007 2208#define MII_TG3_AUXCTL_SHDWSEL_MISC 0x0007
2209#define MII_TG3_AUXCTL_MISC_FORCE_AMDIX 0x0200
2210#define MII_TG3_AUXCTL_MISC_RDSEL_SHIFT 12
2211#define MII_TG3_AUXCTL_MISC_WREN 0x8000
2206 2212
2207#define MII_TG3_AUXCTL_ACTL_SMDSP_ENA 0x0800
2208#define MII_TG3_AUXCTL_ACTL_TX_6DB 0x0400
2209#define MII_TG3_AUXCTL_SHDWSEL_AUXCTL 0x0000
2210 2213
2211#define MII_TG3_AUX_STAT 0x19 /* auxiliary status register */ 2214#define MII_TG3_AUX_STAT 0x19 /* auxiliary status register */
2212#define MII_TG3_AUX_STAT_LPASS 0x0004 2215#define MII_TG3_AUX_STAT_LPASS 0x0004