diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2010-08-02 07:26:05 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-08-02 18:46:32 -0400 |
commit | f08aa1a8b8ff0738d42936c3ac8c5516848bca02 (patch) | |
tree | a2924ae50bd60a00c08cbdf11591a2938902293b /drivers/net/tg3.c | |
parent | 6ee7c0a0a5003abd4afd724f5c2f654fe7328c0a (diff) |
tg3: Add phy-related preprocessor constants
This patch replaces some instances of hardcoded phy register values with
preprocessor equivalents.
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 | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index a9bca8aa254f..281cd7aff8fe 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -1742,7 +1742,7 @@ static int tg3_wait_macro_done(struct tg3 *tp) | |||
1742 | while (limit--) { | 1742 | while (limit--) { |
1743 | u32 tmp32; | 1743 | u32 tmp32; |
1744 | 1744 | ||
1745 | if (!tg3_readphy(tp, 0x16, &tmp32)) { | 1745 | if (!tg3_readphy(tp, MII_TG3_DSP_CONTROL, &tmp32)) { |
1746 | if ((tmp32 & 0x1000) == 0) | 1746 | if ((tmp32 & 0x1000) == 0) |
1747 | break; | 1747 | break; |
1748 | } | 1748 | } |
@@ -1768,13 +1768,13 @@ static int tg3_phy_write_and_check_testpat(struct tg3 *tp, int *resetp) | |||
1768 | 1768 | ||
1769 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, | 1769 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, |
1770 | (chan * 0x2000) | 0x0200); | 1770 | (chan * 0x2000) | 0x0200); |
1771 | tg3_writephy(tp, 0x16, 0x0002); | 1771 | tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0002); |
1772 | 1772 | ||
1773 | for (i = 0; i < 6; i++) | 1773 | for (i = 0; i < 6; i++) |
1774 | tg3_writephy(tp, MII_TG3_DSP_RW_PORT, | 1774 | tg3_writephy(tp, MII_TG3_DSP_RW_PORT, |
1775 | test_pat[chan][i]); | 1775 | test_pat[chan][i]); |
1776 | 1776 | ||
1777 | tg3_writephy(tp, 0x16, 0x0202); | 1777 | tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0202); |
1778 | if (tg3_wait_macro_done(tp)) { | 1778 | if (tg3_wait_macro_done(tp)) { |
1779 | *resetp = 1; | 1779 | *resetp = 1; |
1780 | return -EBUSY; | 1780 | return -EBUSY; |
@@ -1782,13 +1782,13 @@ static int tg3_phy_write_and_check_testpat(struct tg3 *tp, int *resetp) | |||
1782 | 1782 | ||
1783 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, | 1783 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, |
1784 | (chan * 0x2000) | 0x0200); | 1784 | (chan * 0x2000) | 0x0200); |
1785 | tg3_writephy(tp, 0x16, 0x0082); | 1785 | tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0082); |
1786 | if (tg3_wait_macro_done(tp)) { | 1786 | if (tg3_wait_macro_done(tp)) { |
1787 | *resetp = 1; | 1787 | *resetp = 1; |
1788 | return -EBUSY; | 1788 | return -EBUSY; |
1789 | } | 1789 | } |
1790 | 1790 | ||
1791 | tg3_writephy(tp, 0x16, 0x0802); | 1791 | tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0802); |
1792 | if (tg3_wait_macro_done(tp)) { | 1792 | if (tg3_wait_macro_done(tp)) { |
1793 | *resetp = 1; | 1793 | *resetp = 1; |
1794 | return -EBUSY; | 1794 | return -EBUSY; |
@@ -1828,10 +1828,10 @@ static int tg3_phy_reset_chanpat(struct tg3 *tp) | |||
1828 | 1828 | ||
1829 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, | 1829 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, |
1830 | (chan * 0x2000) | 0x0200); | 1830 | (chan * 0x2000) | 0x0200); |
1831 | tg3_writephy(tp, 0x16, 0x0002); | 1831 | tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0002); |
1832 | for (i = 0; i < 6; i++) | 1832 | for (i = 0; i < 6; i++) |
1833 | tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x000); | 1833 | tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x000); |
1834 | tg3_writephy(tp, 0x16, 0x0202); | 1834 | tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0202); |
1835 | if (tg3_wait_macro_done(tp)) | 1835 | if (tg3_wait_macro_done(tp)) |
1836 | return -EBUSY; | 1836 | return -EBUSY; |
1837 | } | 1837 | } |
@@ -1891,7 +1891,7 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp) | |||
1891 | tg3_phydsp_write(tp, 0x8005, 0x0000); | 1891 | tg3_phydsp_write(tp, 0x8005, 0x0000); |
1892 | 1892 | ||
1893 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200); | 1893 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200); |
1894 | tg3_writephy(tp, 0x16, 0x0000); | 1894 | tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0000); |
1895 | 1895 | ||
1896 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 || | 1896 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 || |
1897 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { | 1897 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { |
@@ -2002,8 +2002,8 @@ out: | |||
2002 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400); | 2002 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400); |
2003 | } | 2003 | } |
2004 | if (tp->tg3_flags2 & TG3_FLG2_PHY_5704_A0_BUG) { | 2004 | if (tp->tg3_flags2 & TG3_FLG2_PHY_5704_A0_BUG) { |
2005 | tg3_writephy(tp, 0x1c, 0x8d68); | 2005 | tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8d68); |
2006 | tg3_writephy(tp, 0x1c, 0x8d68); | 2006 | tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8d68); |
2007 | } | 2007 | } |
2008 | if (tp->tg3_flags2 & TG3_FLG2_PHY_BER_BUG) { | 2008 | if (tp->tg3_flags2 & TG3_FLG2_PHY_BER_BUG) { |
2009 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); | 2009 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); |
@@ -3134,9 +3134,9 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset) | |||
3134 | tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) { | 3134 | tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) { |
3135 | /* 5701 {A0,B0} CRC bug workaround */ | 3135 | /* 5701 {A0,B0} CRC bug workaround */ |
3136 | tg3_writephy(tp, 0x15, 0x0a75); | 3136 | tg3_writephy(tp, 0x15, 0x0a75); |
3137 | tg3_writephy(tp, 0x1c, 0x8c68); | 3137 | tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8c68); |
3138 | tg3_writephy(tp, 0x1c, 0x8d68); | 3138 | tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8d68); |
3139 | tg3_writephy(tp, 0x1c, 0x8c68); | 3139 | tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8c68); |
3140 | } | 3140 | } |
3141 | 3141 | ||
3142 | /* Clear pending interrupts... */ | 3142 | /* Clear pending interrupts... */ |
@@ -4249,13 +4249,14 @@ static void tg3_serdes_parallel_detect(struct tg3 *tp) | |||
4249 | u32 phy1, phy2; | 4249 | u32 phy1, phy2; |
4250 | 4250 | ||
4251 | /* Select shadow register 0x1f */ | 4251 | /* Select shadow register 0x1f */ |
4252 | tg3_writephy(tp, 0x1c, 0x7c00); | 4252 | tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x7c00); |
4253 | tg3_readphy(tp, 0x1c, &phy1); | 4253 | tg3_readphy(tp, MII_TG3_MISC_SHDW, &phy1); |
4254 | 4254 | ||
4255 | /* Select expansion interrupt status register */ | 4255 | /* Select expansion interrupt status register */ |
4256 | tg3_writephy(tp, 0x17, 0x0f01); | 4256 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, |
4257 | tg3_readphy(tp, 0x15, &phy2); | 4257 | MII_TG3_DSP_EXP1_INT_STAT); |
4258 | tg3_readphy(tp, 0x15, &phy2); | 4258 | tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &phy2); |
4259 | tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &phy2); | ||
4259 | 4260 | ||
4260 | if ((phy1 & 0x10) && !(phy2 & 0x20)) { | 4261 | if ((phy1 & 0x10) && !(phy2 & 0x20)) { |
4261 | /* We have signal detect and not receiving | 4262 | /* We have signal detect and not receiving |
@@ -4275,8 +4276,9 @@ static void tg3_serdes_parallel_detect(struct tg3 *tp) | |||
4275 | u32 phy2; | 4276 | u32 phy2; |
4276 | 4277 | ||
4277 | /* Select expansion interrupt status register */ | 4278 | /* Select expansion interrupt status register */ |
4278 | tg3_writephy(tp, 0x17, 0x0f01); | 4279 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, |
4279 | tg3_readphy(tp, 0x15, &phy2); | 4280 | MII_TG3_DSP_EXP1_INT_STAT); |
4281 | tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &phy2); | ||
4280 | if (phy2 & 0x20) { | 4282 | if (phy2 & 0x20) { |
4281 | u32 bmcr; | 4283 | u32 bmcr; |
4282 | 4284 | ||
@@ -8337,7 +8339,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) | |||
8337 | if (!tg3_readphy(tp, MII_TG3_TEST1, &tmp)) { | 8339 | if (!tg3_readphy(tp, MII_TG3_TEST1, &tmp)) { |
8338 | tg3_writephy(tp, MII_TG3_TEST1, | 8340 | tg3_writephy(tp, MII_TG3_TEST1, |
8339 | tmp | MII_TG3_TEST1_CRC_EN); | 8341 | tmp | MII_TG3_TEST1_CRC_EN); |
8340 | tg3_readphy(tp, 0x14, &tmp); | 8342 | tg3_readphy(tp, MII_TG3_RXR_COUNTERS, &tmp); |
8341 | } | 8343 | } |
8342 | } | 8344 | } |
8343 | } | 8345 | } |
@@ -9076,7 +9078,7 @@ static u64 calc_crc_errors(struct tg3 *tp) | |||
9076 | if (!tg3_readphy(tp, MII_TG3_TEST1, &val)) { | 9078 | if (!tg3_readphy(tp, MII_TG3_TEST1, &val)) { |
9077 | tg3_writephy(tp, MII_TG3_TEST1, | 9079 | tg3_writephy(tp, MII_TG3_TEST1, |
9078 | val | MII_TG3_TEST1_CRC_EN); | 9080 | val | MII_TG3_TEST1_CRC_EN); |
9079 | tg3_readphy(tp, 0x14, &val); | 9081 | tg3_readphy(tp, MII_TG3_RXR_COUNTERS, &val); |
9080 | } else | 9082 | } else |
9081 | val = 0; | 9083 | val = 0; |
9082 | spin_unlock_bh(&tp->lock); | 9084 | spin_unlock_bh(&tp->lock); |