diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2010-09-15 05:00:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-09-15 17:16:15 -0400 |
commit | f833c4c181e4e948758b7b252322f50273100d30 (patch) | |
tree | 164a67e11de5666dd04cd0d680e8170a26fe20ec /drivers/net/tg3.c | |
parent | a4a8bb15aed20ff74aa3ca14a4f2c0d62efd8391 (diff) |
tg3: phy tmp variable roundup
The tg3's phy routines define temporary variables in many locations
within the same routine. This patch unifies all temporary variables
into one location.
Reviewed-by: Benjamin Li <benli@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Matt Carlson <mcarlson@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 | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 0d0deaae5f4c..e7a2ba8b20a2 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -1917,19 +1917,16 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp) | |||
1917 | */ | 1917 | */ |
1918 | static int tg3_phy_reset(struct tg3 *tp) | 1918 | static int tg3_phy_reset(struct tg3 *tp) |
1919 | { | 1919 | { |
1920 | u32 cpmuctrl; | 1920 | u32 val, cpmuctrl; |
1921 | u32 phy_status; | ||
1922 | int err; | 1921 | int err; |
1923 | 1922 | ||
1924 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { | 1923 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { |
1925 | u32 val; | ||
1926 | |||
1927 | val = tr32(GRC_MISC_CFG); | 1924 | val = tr32(GRC_MISC_CFG); |
1928 | tw32_f(GRC_MISC_CFG, val & ~GRC_MISC_CFG_EPHY_IDDQ); | 1925 | tw32_f(GRC_MISC_CFG, val & ~GRC_MISC_CFG_EPHY_IDDQ); |
1929 | udelay(40); | 1926 | udelay(40); |
1930 | } | 1927 | } |
1931 | err = tg3_readphy(tp, MII_BMSR, &phy_status); | 1928 | err = tg3_readphy(tp, MII_BMSR, &val); |
1932 | err |= tg3_readphy(tp, MII_BMSR, &phy_status); | 1929 | err |= tg3_readphy(tp, MII_BMSR, &val); |
1933 | if (err != 0) | 1930 | if (err != 0) |
1934 | return -EBUSY; | 1931 | return -EBUSY; |
1935 | 1932 | ||
@@ -1961,18 +1958,14 @@ static int tg3_phy_reset(struct tg3 *tp) | |||
1961 | return err; | 1958 | return err; |
1962 | 1959 | ||
1963 | if (cpmuctrl & CPMU_CTRL_GPHY_10MB_RXONLY) { | 1960 | if (cpmuctrl & CPMU_CTRL_GPHY_10MB_RXONLY) { |
1964 | u32 phy; | 1961 | val = MII_TG3_DSP_EXP8_AEDW | MII_TG3_DSP_EXP8_REJ2MHz; |
1965 | 1962 | tg3_phydsp_write(tp, MII_TG3_DSP_EXP8, val); | |
1966 | phy = MII_TG3_DSP_EXP8_AEDW | MII_TG3_DSP_EXP8_REJ2MHz; | ||
1967 | tg3_phydsp_write(tp, MII_TG3_DSP_EXP8, phy); | ||
1968 | 1963 | ||
1969 | tw32(TG3_CPMU_CTRL, cpmuctrl); | 1964 | tw32(TG3_CPMU_CTRL, cpmuctrl); |
1970 | } | 1965 | } |
1971 | 1966 | ||
1972 | if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX || | 1967 | if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX || |
1973 | GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5761_AX) { | 1968 | GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5761_AX) { |
1974 | u32 val; | ||
1975 | |||
1976 | val = tr32(TG3_CPMU_LSPD_1000MB_CLK); | 1969 | val = tr32(TG3_CPMU_LSPD_1000MB_CLK); |
1977 | if ((val & CPMU_LSPD_1000MB_MACCLK_MASK) == | 1970 | if ((val & CPMU_LSPD_1000MB_MACCLK_MASK) == |
1978 | CPMU_LSPD_1000MB_MACCLK_12_5) { | 1971 | CPMU_LSPD_1000MB_MACCLK_12_5) { |
@@ -2028,23 +2021,19 @@ out: | |||
2028 | /* Cannot do read-modify-write on 5401 */ | 2021 | /* Cannot do read-modify-write on 5401 */ |
2029 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20); | 2022 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20); |
2030 | } else if (tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) { | 2023 | } else if (tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) { |
2031 | u32 phy_reg; | ||
2032 | |||
2033 | /* Set bit 14 with read-modify-write to preserve other bits */ | 2024 | /* Set bit 14 with read-modify-write to preserve other bits */ |
2034 | if (!tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0007) && | 2025 | if (!tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0007) && |
2035 | !tg3_readphy(tp, MII_TG3_AUX_CTRL, &phy_reg)) | 2026 | !tg3_readphy(tp, MII_TG3_AUX_CTRL, &val)) |
2036 | tg3_writephy(tp, MII_TG3_AUX_CTRL, phy_reg | 0x4000); | 2027 | tg3_writephy(tp, MII_TG3_AUX_CTRL, val | 0x4000); |
2037 | } | 2028 | } |
2038 | 2029 | ||
2039 | /* Set phy register 0x10 bit 0 to high fifo elasticity to support | 2030 | /* Set phy register 0x10 bit 0 to high fifo elasticity to support |
2040 | * jumbo frames transmission. | 2031 | * jumbo frames transmission. |
2041 | */ | 2032 | */ |
2042 | if (tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) { | 2033 | if (tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) { |
2043 | u32 phy_reg; | 2034 | if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &val)) |
2044 | |||
2045 | if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg)) | ||
2046 | tg3_writephy(tp, MII_TG3_EXT_CTRL, | 2035 | tg3_writephy(tp, MII_TG3_EXT_CTRL, |
2047 | phy_reg | MII_TG3_EXT_CTRL_FIFO_ELASTIC); | 2036 | val | MII_TG3_EXT_CTRL_FIFO_ELASTIC); |
2048 | } | 2037 | } |
2049 | 2038 | ||
2050 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { | 2039 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { |
@@ -3060,7 +3049,7 @@ static int tg3_adv_1000T_flowctrl_ok(struct tg3 *tp, u32 *lcladv, u32 *rmtadv) | |||
3060 | static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset) | 3049 | static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset) |
3061 | { | 3050 | { |
3062 | int current_link_up; | 3051 | int current_link_up; |
3063 | u32 bmsr, dummy; | 3052 | u32 bmsr, val; |
3064 | u32 lcl_adv, rmt_adv; | 3053 | u32 lcl_adv, rmt_adv; |
3065 | u16 current_speed; | 3054 | u16 current_speed; |
3066 | u8 current_duplex; | 3055 | u8 current_duplex; |
@@ -3140,8 +3129,8 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset) | |||
3140 | } | 3129 | } |
3141 | 3130 | ||
3142 | /* Clear pending interrupts... */ | 3131 | /* Clear pending interrupts... */ |
3143 | tg3_readphy(tp, MII_TG3_ISTAT, &dummy); | 3132 | tg3_readphy(tp, MII_TG3_ISTAT, &val); |
3144 | tg3_readphy(tp, MII_TG3_ISTAT, &dummy); | 3133 | tg3_readphy(tp, MII_TG3_ISTAT, &val); |
3145 | 3134 | ||
3146 | if (tp->phy_flags & TG3_PHYFLG_USE_MI_INTERRUPT) | 3135 | if (tp->phy_flags & TG3_PHYFLG_USE_MI_INTERRUPT) |
3147 | tg3_writephy(tp, MII_TG3_IMASK, ~MII_TG3_INT_LINKCHG); | 3136 | tg3_writephy(tp, MII_TG3_IMASK, ~MII_TG3_INT_LINKCHG); |
@@ -3162,8 +3151,6 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset) | |||
3162 | current_duplex = DUPLEX_INVALID; | 3151 | current_duplex = DUPLEX_INVALID; |
3163 | 3152 | ||
3164 | if (tp->phy_flags & TG3_PHYFLG_CAPACITIVE_COUPLING) { | 3153 | if (tp->phy_flags & TG3_PHYFLG_CAPACITIVE_COUPLING) { |
3165 | u32 val; | ||
3166 | |||
3167 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4007); | 3154 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4007); |
3168 | tg3_readphy(tp, MII_TG3_AUX_CTRL, &val); | 3155 | tg3_readphy(tp, MII_TG3_AUX_CTRL, &val); |
3169 | if (!(val & (1 << 10))) { | 3156 | if (!(val & (1 << 10))) { |
@@ -3238,13 +3225,11 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset) | |||
3238 | 3225 | ||
3239 | relink: | 3226 | relink: |
3240 | if (current_link_up == 0 || (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) { | 3227 | if (current_link_up == 0 || (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) { |
3241 | u32 tmp; | ||
3242 | |||
3243 | tg3_phy_copper_begin(tp); | 3228 | tg3_phy_copper_begin(tp); |
3244 | 3229 | ||
3245 | tg3_readphy(tp, MII_BMSR, &tmp); | 3230 | tg3_readphy(tp, MII_BMSR, &bmsr); |
3246 | if (!tg3_readphy(tp, MII_BMSR, &tmp) && | 3231 | if (!tg3_readphy(tp, MII_BMSR, &bmsr) && |
3247 | (tmp & BMSR_LSTATUS)) | 3232 | (bmsr & BMSR_LSTATUS)) |
3248 | current_link_up = 1; | 3233 | current_link_up = 1; |
3249 | } | 3234 | } |
3250 | 3235 | ||