diff options
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 154 |
1 files changed, 143 insertions, 11 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index f9ef8bd8b11e..d4655b2d1f3f 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -64,8 +64,8 @@ | |||
64 | 64 | ||
65 | #define DRV_MODULE_NAME "tg3" | 65 | #define DRV_MODULE_NAME "tg3" |
66 | #define PFX DRV_MODULE_NAME ": " | 66 | #define PFX DRV_MODULE_NAME ": " |
67 | #define DRV_MODULE_VERSION "3.88" | 67 | #define DRV_MODULE_VERSION "3.89" |
68 | #define DRV_MODULE_RELDATE "March 20, 2008" | 68 | #define DRV_MODULE_RELDATE "April 03, 2008" |
69 | 69 | ||
70 | #define TG3_DEF_MAC_MODE 0 | 70 | #define TG3_DEF_MAC_MODE 0 |
71 | #define TG3_DEF_RX_MODE 0 | 71 | #define TG3_DEF_RX_MODE 0 |
@@ -804,6 +804,12 @@ static int tg3_writephy(struct tg3 *tp, int reg, u32 val) | |||
804 | return ret; | 804 | return ret; |
805 | } | 805 | } |
806 | 806 | ||
807 | static void tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val) | ||
808 | { | ||
809 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, reg); | ||
810 | tg3_writephy(tp, MII_TG3_DSP_RW_PORT, val); | ||
811 | } | ||
812 | |||
807 | static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable) | 813 | static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable) |
808 | { | 814 | { |
809 | u32 phy; | 815 | u32 phy; |
@@ -886,6 +892,49 @@ static int tg3_bmcr_reset(struct tg3 *tp) | |||
886 | return 0; | 892 | return 0; |
887 | } | 893 | } |
888 | 894 | ||
895 | static void tg3_phy_apply_otp(struct tg3 *tp) | ||
896 | { | ||
897 | u32 otp, phy; | ||
898 | |||
899 | if (!tp->phy_otp) | ||
900 | return; | ||
901 | |||
902 | otp = tp->phy_otp; | ||
903 | |||
904 | /* Enable SM_DSP clock and tx 6dB coding. */ | ||
905 | phy = MII_TG3_AUXCTL_SHDWSEL_AUXCTL | | ||
906 | MII_TG3_AUXCTL_ACTL_SMDSP_ENA | | ||
907 | MII_TG3_AUXCTL_ACTL_TX_6DB; | ||
908 | tg3_writephy(tp, MII_TG3_AUX_CTRL, phy); | ||
909 | |||
910 | phy = ((otp & TG3_OTP_AGCTGT_MASK) >> TG3_OTP_AGCTGT_SHIFT); | ||
911 | phy |= MII_TG3_DSP_TAP1_AGCTGT_DFLT; | ||
912 | tg3_phydsp_write(tp, MII_TG3_DSP_TAP1, phy); | ||
913 | |||
914 | phy = ((otp & TG3_OTP_HPFFLTR_MASK) >> TG3_OTP_HPFFLTR_SHIFT) | | ||
915 | ((otp & TG3_OTP_HPFOVER_MASK) >> TG3_OTP_HPFOVER_SHIFT); | ||
916 | tg3_phydsp_write(tp, MII_TG3_DSP_AADJ1CH0, phy); | ||
917 | |||
918 | phy = ((otp & TG3_OTP_LPFDIS_MASK) >> TG3_OTP_LPFDIS_SHIFT); | ||
919 | phy |= MII_TG3_DSP_AADJ1CH3_ADCCKADJ; | ||
920 | tg3_phydsp_write(tp, MII_TG3_DSP_AADJ1CH3, phy); | ||
921 | |||
922 | phy = ((otp & TG3_OTP_VDAC_MASK) >> TG3_OTP_VDAC_SHIFT); | ||
923 | tg3_phydsp_write(tp, MII_TG3_DSP_EXP75, phy); | ||
924 | |||
925 | phy = ((otp & TG3_OTP_10BTAMP_MASK) >> TG3_OTP_10BTAMP_SHIFT); | ||
926 | tg3_phydsp_write(tp, MII_TG3_DSP_EXP96, phy); | ||
927 | |||
928 | phy = ((otp & TG3_OTP_ROFF_MASK) >> TG3_OTP_ROFF_SHIFT) | | ||
929 | ((otp & TG3_OTP_RCOFF_MASK) >> TG3_OTP_RCOFF_SHIFT); | ||
930 | tg3_phydsp_write(tp, MII_TG3_DSP_EXP97, phy); | ||
931 | |||
932 | /* Turn off SM_DSP clock. */ | ||
933 | phy = MII_TG3_AUXCTL_SHDWSEL_AUXCTL | | ||
934 | MII_TG3_AUXCTL_ACTL_TX_6DB; | ||
935 | tg3_writephy(tp, MII_TG3_AUX_CTRL, phy); | ||
936 | } | ||
937 | |||
889 | static int tg3_wait_macro_done(struct tg3 *tp) | 938 | static int tg3_wait_macro_done(struct tg3 *tp) |
890 | { | 939 | { |
891 | int limit = 100; | 940 | int limit = 100; |
@@ -1073,6 +1122,7 @@ static void tg3_link_report(struct tg3 *); | |||
1073 | */ | 1122 | */ |
1074 | static int tg3_phy_reset(struct tg3 *tp) | 1123 | static int tg3_phy_reset(struct tg3 *tp) |
1075 | { | 1124 | { |
1125 | u32 cpmuctrl; | ||
1076 | u32 phy_status; | 1126 | u32 phy_status; |
1077 | int err; | 1127 | int err; |
1078 | 1128 | ||
@@ -1102,10 +1152,28 @@ static int tg3_phy_reset(struct tg3 *tp) | |||
1102 | goto out; | 1152 | goto out; |
1103 | } | 1153 | } |
1104 | 1154 | ||
1155 | cpmuctrl = 0; | ||
1156 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 && | ||
1157 | GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5784_AX) { | ||
1158 | cpmuctrl = tr32(TG3_CPMU_CTRL); | ||
1159 | if (cpmuctrl & CPMU_CTRL_GPHY_10MB_RXONLY) | ||
1160 | tw32(TG3_CPMU_CTRL, | ||
1161 | cpmuctrl & ~CPMU_CTRL_GPHY_10MB_RXONLY); | ||
1162 | } | ||
1163 | |||
1105 | err = tg3_bmcr_reset(tp); | 1164 | err = tg3_bmcr_reset(tp); |
1106 | if (err) | 1165 | if (err) |
1107 | return err; | 1166 | return err; |
1108 | 1167 | ||
1168 | if (cpmuctrl & CPMU_CTRL_GPHY_10MB_RXONLY) { | ||
1169 | u32 phy; | ||
1170 | |||
1171 | phy = MII_TG3_DSP_EXP8_AEDW | MII_TG3_DSP_EXP8_REJ2MHz; | ||
1172 | tg3_phydsp_write(tp, MII_TG3_DSP_EXP8, phy); | ||
1173 | |||
1174 | tw32(TG3_CPMU_CTRL, cpmuctrl); | ||
1175 | } | ||
1176 | |||
1109 | if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { | 1177 | if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { |
1110 | u32 val; | 1178 | u32 val; |
1111 | 1179 | ||
@@ -1124,6 +1192,8 @@ static int tg3_phy_reset(struct tg3 *tp) | |||
1124 | MII_TG3_MISC_SHDW_APD_WKTM_84MS); | 1192 | MII_TG3_MISC_SHDW_APD_WKTM_84MS); |
1125 | } | 1193 | } |
1126 | 1194 | ||
1195 | tg3_phy_apply_otp(tp); | ||
1196 | |||
1127 | out: | 1197 | out: |
1128 | if (tp->tg3_flags2 & TG3_FLG2_PHY_ADC_BUG) { | 1198 | if (tp->tg3_flags2 & TG3_FLG2_PHY_ADC_BUG) { |
1129 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); | 1199 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); |
@@ -9464,7 +9534,8 @@ static int tg3_test_loopback(struct tg3 *tp) | |||
9464 | if (err) | 9534 | if (err) |
9465 | return TG3_LOOPBACK_FAILED; | 9535 | return TG3_LOOPBACK_FAILED; |
9466 | 9536 | ||
9467 | if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { | 9537 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || |
9538 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761) { | ||
9468 | int i; | 9539 | int i; |
9469 | u32 status; | 9540 | u32 status; |
9470 | 9541 | ||
@@ -9481,17 +9552,23 @@ static int tg3_test_loopback(struct tg3 *tp) | |||
9481 | if (status != CPMU_MUTEX_GNT_DRIVER) | 9552 | if (status != CPMU_MUTEX_GNT_DRIVER) |
9482 | return TG3_LOOPBACK_FAILED; | 9553 | return TG3_LOOPBACK_FAILED; |
9483 | 9554 | ||
9484 | /* Turn off power management based on link speed. */ | 9555 | /* Turn off link-based power management. */ |
9485 | cpmuctrl = tr32(TG3_CPMU_CTRL); | 9556 | cpmuctrl = tr32(TG3_CPMU_CTRL); |
9486 | tw32(TG3_CPMU_CTRL, | 9557 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || |
9487 | cpmuctrl & ~(CPMU_CTRL_LINK_SPEED_MODE | | 9558 | GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5761_AX) |
9488 | CPMU_CTRL_LINK_AWARE_MODE)); | 9559 | tw32(TG3_CPMU_CTRL, |
9560 | cpmuctrl & ~(CPMU_CTRL_LINK_SPEED_MODE | | ||
9561 | CPMU_CTRL_LINK_AWARE_MODE)); | ||
9562 | else | ||
9563 | tw32(TG3_CPMU_CTRL, | ||
9564 | cpmuctrl & ~CPMU_CTRL_LINK_AWARE_MODE); | ||
9489 | } | 9565 | } |
9490 | 9566 | ||
9491 | if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK)) | 9567 | if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK)) |
9492 | err |= TG3_MAC_LOOPBACK_FAILED; | 9568 | err |= TG3_MAC_LOOPBACK_FAILED; |
9493 | 9569 | ||
9494 | if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { | 9570 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || |
9571 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761) { | ||
9495 | tw32(TG3_CPMU_CTRL, cpmuctrl); | 9572 | tw32(TG3_CPMU_CTRL, cpmuctrl); |
9496 | 9573 | ||
9497 | /* Release the mutex */ | 9574 | /* Release the mutex */ |
@@ -10724,9 +10801,8 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) | |||
10724 | tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL) | 10801 | tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL) |
10725 | tp->led_ctrl = LED_CTRL_MODE_PHY_2; | 10802 | tp->led_ctrl = LED_CTRL_MODE_PHY_2; |
10726 | 10803 | ||
10727 | if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || | 10804 | if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX) |
10728 | tp->pci_chip_rev_id == CHIPREV_ID_5784_A1) | 10805 | tp->led_ctrl = LED_CTRL_MODE_PHY_1; |
10729 | tp->led_ctrl = LED_CTRL_MODE_MAC; | ||
10730 | 10806 | ||
10731 | if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) { | 10807 | if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) { |
10732 | tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; | 10808 | tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; |
@@ -10773,6 +10849,55 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) | |||
10773 | } | 10849 | } |
10774 | } | 10850 | } |
10775 | 10851 | ||
10852 | static int __devinit tg3_issue_otp_command(struct tg3 *tp, u32 cmd) | ||
10853 | { | ||
10854 | int i; | ||
10855 | u32 val; | ||
10856 | |||
10857 | tw32(OTP_CTRL, cmd | OTP_CTRL_OTP_CMD_START); | ||
10858 | tw32(OTP_CTRL, cmd); | ||
10859 | |||
10860 | /* Wait for up to 1 ms for command to execute. */ | ||
10861 | for (i = 0; i < 100; i++) { | ||
10862 | val = tr32(OTP_STATUS); | ||
10863 | if (val & OTP_STATUS_CMD_DONE) | ||
10864 | break; | ||
10865 | udelay(10); | ||
10866 | } | ||
10867 | |||
10868 | return (val & OTP_STATUS_CMD_DONE) ? 0 : -EBUSY; | ||
10869 | } | ||
10870 | |||
10871 | /* Read the gphy configuration from the OTP region of the chip. The gphy | ||
10872 | * configuration is a 32-bit value that straddles the alignment boundary. | ||
10873 | * We do two 32-bit reads and then shift and merge the results. | ||
10874 | */ | ||
10875 | static u32 __devinit tg3_read_otp_phycfg(struct tg3 *tp) | ||
10876 | { | ||
10877 | u32 bhalf_otp, thalf_otp; | ||
10878 | |||
10879 | tw32(OTP_MODE, OTP_MODE_OTP_THRU_GRC); | ||
10880 | |||
10881 | if (tg3_issue_otp_command(tp, OTP_CTRL_OTP_CMD_INIT)) | ||
10882 | return 0; | ||
10883 | |||
10884 | tw32(OTP_ADDRESS, OTP_ADDRESS_MAGIC1); | ||
10885 | |||
10886 | if (tg3_issue_otp_command(tp, OTP_CTRL_OTP_CMD_READ)) | ||
10887 | return 0; | ||
10888 | |||
10889 | thalf_otp = tr32(OTP_READ_DATA); | ||
10890 | |||
10891 | tw32(OTP_ADDRESS, OTP_ADDRESS_MAGIC2); | ||
10892 | |||
10893 | if (tg3_issue_otp_command(tp, OTP_CTRL_OTP_CMD_READ)) | ||
10894 | return 0; | ||
10895 | |||
10896 | bhalf_otp = tr32(OTP_READ_DATA); | ||
10897 | |||
10898 | return ((thalf_otp & 0x0000ffff) << 16) | (bhalf_otp >> 16); | ||
10899 | } | ||
10900 | |||
10776 | static int __devinit tg3_phy_probe(struct tg3 *tp) | 10901 | static int __devinit tg3_phy_probe(struct tg3 *tp) |
10777 | { | 10902 | { |
10778 | u32 hw_phy_id_1, hw_phy_id_2; | 10903 | u32 hw_phy_id_1, hw_phy_id_2; |
@@ -11586,6 +11711,13 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
11586 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; | 11711 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; |
11587 | } | 11712 | } |
11588 | 11713 | ||
11714 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 && | ||
11715 | GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5784_AX) { | ||
11716 | tp->phy_otp = tg3_read_otp_phycfg(tp); | ||
11717 | if (tp->phy_otp == 0) | ||
11718 | tp->phy_otp = TG3_OTP_DEFAULT; | ||
11719 | } | ||
11720 | |||
11589 | tp->coalesce_mode = 0; | 11721 | tp->coalesce_mode = 0; |
11590 | if (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_AX && | 11722 | if (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_AX && |
11591 | GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_BX) | 11723 | GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_BX) |