aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/tg3.c524
-rw-r--r--drivers/net/tg3.h25
2 files changed, 464 insertions, 85 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 12de80884b1a..f65ca3b2da6f 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -85,8 +85,7 @@
85/* hardware minimum and maximum for a single frame's data payload */ 85/* hardware minimum and maximum for a single frame's data payload */
86#define TG3_MIN_MTU 60 86#define TG3_MIN_MTU 60
87#define TG3_MAX_MTU(tp) \ 87#define TG3_MAX_MTU(tp) \
88 ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && \ 88 (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS) ? 9000 : 1500)
89 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) ? 9000 : 1500)
90 89
91/* These numbers seem to be hard coded in the NIC firmware somehow. 90/* These numbers seem to be hard coded in the NIC firmware somehow.
92 * You can't change the ring sizes, but you can change where you place 91 * You can't change the ring sizes, but you can change where you place
@@ -205,6 +204,8 @@ static struct pci_device_id tg3_pci_tbl[] = {
205 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 204 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
206 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5751F, 205 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5751F,
207 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 206 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
207 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5752,
208 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
208 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753, 209 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753,
209 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 210 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
210 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753M, 211 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753M,
@@ -860,8 +861,7 @@ out:
860 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) { 861 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) {
861 /* Cannot do read-modify-write on 5401 */ 862 /* Cannot do read-modify-write on 5401 */
862 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20); 863 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20);
863 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && 864 } else if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
864 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
865 u32 phy_reg; 865 u32 phy_reg;
866 866
867 /* Set bit 14 with read-modify-write to preserve other bits */ 867 /* Set bit 14 with read-modify-write to preserve other bits */
@@ -873,8 +873,7 @@ out:
873 /* Set phy register 0x10 bit 0 to high fifo elasticity to support 873 /* Set phy register 0x10 bit 0 to high fifo elasticity to support
874 * jumbo frames transmission. 874 * jumbo frames transmission.
875 */ 875 */
876 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && 876 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
877 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
878 u32 phy_reg; 877 u32 phy_reg;
879 878
880 if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg)) 879 if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg))
@@ -1006,8 +1005,13 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1006 pci_write_config_word(tp->pdev, 1005 pci_write_config_word(tp->pdev,
1007 pm + PCI_PM_CTRL, 1006 pm + PCI_PM_CTRL,
1008 power_control); 1007 power_control);
1009 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 1008 udelay(100); /* Delay after power state change */
1010 udelay(100); 1009
1010 /* Switch out of Vaux if it is not a LOM */
1011 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)) {
1012 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
1013 udelay(100);
1014 }
1011 1015
1012 return 0; 1016 return 0;
1013 1017
@@ -1068,7 +1072,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1068 mac_mode = MAC_MODE_PORT_MODE_TBI; 1072 mac_mode = MAC_MODE_PORT_MODE_TBI;
1069 } 1073 }
1070 1074
1071 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) 1075 if (!(tp->tg3_flags2 & TG3_FLG2_5750_PLUS))
1072 tw32(MAC_LED_CTRL, tp->led_ctrl); 1076 tw32(MAC_LED_CTRL, tp->led_ctrl);
1073 1077
1074 if (((power_caps & PCI_PM_CAP_PME_D3cold) && 1078 if (((power_caps & PCI_PM_CAP_PME_D3cold) &&
@@ -1095,7 +1099,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1095 CLOCK_CTRL_ALTCLK | 1099 CLOCK_CTRL_ALTCLK |
1096 CLOCK_CTRL_PWRDOWN_PLL133); 1100 CLOCK_CTRL_PWRDOWN_PLL133);
1097 udelay(40); 1101 udelay(40);
1098 } else if (!((GET_ASIC_REV(tp->pci_chip_rev_id) == 5750) && 1102 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
1099 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) { 1103 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) {
1100 u32 newbits1, newbits2; 1104 u32 newbits1, newbits2;
1101 1105
@@ -1152,6 +1156,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1152 1156
1153 /* Finally, set the new power state. */ 1157 /* Finally, set the new power state. */
1154 pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control); 1158 pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control);
1159 udelay(100); /* Delay after power state change */
1155 1160
1156 tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN); 1161 tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN);
1157 1162
@@ -2902,6 +2907,43 @@ static inline unsigned int tg3_has_work(struct net_device *dev, struct tg3 *tp)
2902 return work_exists; 2907 return work_exists;
2903} 2908}
2904 2909
2910/* MSI ISR - No need to check for interrupt sharing and no need to
2911 * flush status block and interrupt mailbox. PCI ordering rules
2912 * guarantee that MSI will arrive after the status block.
2913 */
2914static irqreturn_t tg3_msi(int irq, void *dev_id, struct pt_regs *regs)
2915{
2916 struct net_device *dev = dev_id;
2917 struct tg3 *tp = netdev_priv(dev);
2918 struct tg3_hw_status *sblk = tp->hw_status;
2919 unsigned long flags;
2920
2921 spin_lock_irqsave(&tp->lock, flags);
2922
2923 /*
2924 * writing any value to intr-mbox-0 clears PCI INTA# and
2925 * chip-internal interrupt pending events.
2926 * writing non-zero to intr-mbox-0 additional tells the
2927 * NIC to stop sending us irqs, engaging "in-intr-handler"
2928 * event coalescing.
2929 */
2930 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
2931 sblk->status &= ~SD_STATUS_UPDATED;
2932
2933 if (likely(tg3_has_work(dev, tp)))
2934 netif_rx_schedule(dev); /* schedule NAPI poll */
2935 else {
2936 /* no work, re-enable interrupts
2937 */
2938 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
2939 0x00000000);
2940 }
2941
2942 spin_unlock_irqrestore(&tp->lock, flags);
2943
2944 return IRQ_RETVAL(1);
2945}
2946
2905static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs) 2947static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2906{ 2948{
2907 struct net_device *dev = dev_id; 2949 struct net_device *dev = dev_id;
@@ -2954,13 +2996,31 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2954 return IRQ_RETVAL(handled); 2996 return IRQ_RETVAL(handled);
2955} 2997}
2956 2998
2999/* ISR for interrupt test */
3000static irqreturn_t tg3_test_isr(int irq, void *dev_id,
3001 struct pt_regs *regs)
3002{
3003 struct net_device *dev = dev_id;
3004 struct tg3 *tp = netdev_priv(dev);
3005 struct tg3_hw_status *sblk = tp->hw_status;
3006
3007 if (sblk->status & SD_STATUS_UPDATED) {
3008 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
3009 0x00000001);
3010 return IRQ_RETVAL(1);
3011 }
3012 return IRQ_RETVAL(0);
3013}
3014
2957static int tg3_init_hw(struct tg3 *); 3015static int tg3_init_hw(struct tg3 *);
2958static int tg3_halt(struct tg3 *); 3016static int tg3_halt(struct tg3 *);
2959 3017
2960#ifdef CONFIG_NET_POLL_CONTROLLER 3018#ifdef CONFIG_NET_POLL_CONTROLLER
2961static void tg3_poll_controller(struct net_device *dev) 3019static void tg3_poll_controller(struct net_device *dev)
2962{ 3020{
2963 tg3_interrupt(dev->irq, dev, NULL); 3021 struct tg3 *tp = netdev_priv(dev);
3022
3023 tg3_interrupt(tp->pdev->irq, dev, NULL);
2964} 3024}
2965#endif 3025#endif
2966 3026
@@ -3727,6 +3787,28 @@ static void tg3_nvram_unlock(struct tg3 *tp)
3727} 3787}
3728 3788
3729/* tp->lock is held. */ 3789/* tp->lock is held. */
3790static void tg3_enable_nvram_access(struct tg3 *tp)
3791{
3792 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
3793 !(tp->tg3_flags2 & TG3_FLG2_PROTECTED_NVRAM)) {
3794 u32 nvaccess = tr32(NVRAM_ACCESS);
3795
3796 tw32(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
3797 }
3798}
3799
3800/* tp->lock is held. */
3801static void tg3_disable_nvram_access(struct tg3 *tp)
3802{
3803 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
3804 !(tp->tg3_flags2 & TG3_FLG2_PROTECTED_NVRAM)) {
3805 u32 nvaccess = tr32(NVRAM_ACCESS);
3806
3807 tw32(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
3808 }
3809}
3810
3811/* tp->lock is held. */
3730static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind) 3812static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind)
3731{ 3813{
3732 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X)) 3814 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X))
@@ -3967,7 +4049,7 @@ static int tg3_chip_reset(struct tg3 *tp)
3967 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg); 4049 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg);
3968 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { 4050 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
3969 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; 4051 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
3970 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) 4052 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
3971 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE; 4053 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE;
3972 } 4054 }
3973 } 4055 }
@@ -5041,7 +5123,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5041 tw32(GRC_MISC_CFG, val); 5123 tw32(GRC_MISC_CFG, val);
5042 5124
5043 /* Initialize MBUF/DESC pool. */ 5125 /* Initialize MBUF/DESC pool. */
5044 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 5126 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) {
5045 /* Do nothing. */ 5127 /* Do nothing. */
5046 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) { 5128 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
5047 tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE); 5129 tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
@@ -5238,6 +5320,8 @@ static int tg3_reset_hw(struct tg3 *tp)
5238 RDMAC_MODE_LNGREAD_ENAB); 5320 RDMAC_MODE_LNGREAD_ENAB);
5239 if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE) 5321 if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
5240 rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE; 5322 rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE;
5323
5324 /* If statement applies to 5705 and 5750 PCI devices only */
5241 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 && 5325 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
5242 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) || 5326 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) ||
5243 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) { 5327 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) {
@@ -5251,6 +5335,9 @@ static int tg3_reset_hw(struct tg3 *tp)
5251 } 5335 }
5252 } 5336 }
5253 5337
5338 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)
5339 rdmac_mode |= RDMAC_MODE_FIFO_LONG_BURST;
5340
5254#if TG3_TSO_SUPPORT != 0 5341#if TG3_TSO_SUPPORT != 0
5255 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) 5342 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
5256 rdmac_mode |= (1 << 27); 5343 rdmac_mode |= (1 << 27);
@@ -5332,10 +5419,28 @@ static int tg3_reset_hw(struct tg3 *tp)
5332 tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_RXSTAT_CLEAR | MAC_MODE_TXSTAT_CLEAR); 5419 tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_RXSTAT_CLEAR | MAC_MODE_TXSTAT_CLEAR);
5333 udelay(40); 5420 udelay(40);
5334 5421
5335 tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM; 5422 /* tp->grc_local_ctrl is partially set up during tg3_get_invariants().
5336 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) 5423 * If TG3_FLAG_EEPROM_WRITE_PROT is set, we should read the
5424 * register to preserve the GPIO settings for LOMs. The GPIOs,
5425 * whether used as inputs or outputs, are set by boot code after
5426 * reset.
5427 */
5428 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
5429 u32 gpio_mask;
5430
5431 gpio_mask = GRC_LCLCTRL_GPIO_OE0 | GRC_LCLCTRL_GPIO_OE2 |
5432 GRC_LCLCTRL_GPIO_OUTPUT0 | GRC_LCLCTRL_GPIO_OUTPUT2;
5433
5434 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
5435 gpio_mask |= GRC_LCLCTRL_GPIO_OE3 |
5436 GRC_LCLCTRL_GPIO_OUTPUT3;
5437
5438 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask;
5439
5440 /* GPIO1 must be driven high for eeprom write protect */
5337 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 | 5441 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
5338 GRC_LCLCTRL_GPIO_OUTPUT1); 5442 GRC_LCLCTRL_GPIO_OUTPUT1);
5443 }
5339 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 5444 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
5340 udelay(100); 5445 udelay(100);
5341 5446
@@ -5353,6 +5458,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5353 WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB | 5458 WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB |
5354 WDMAC_MODE_LNGREAD_ENAB); 5459 WDMAC_MODE_LNGREAD_ENAB);
5355 5460
5461 /* If statement applies to 5705 and 5750 PCI devices only */
5356 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 && 5462 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
5357 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) || 5463 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) ||
5358 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 5464 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
@@ -5706,6 +5812,118 @@ static void tg3_timer(unsigned long __opaque)
5706 add_timer(&tp->timer); 5812 add_timer(&tp->timer);
5707} 5813}
5708 5814
5815static int tg3_test_interrupt(struct tg3 *tp)
5816{
5817 struct net_device *dev = tp->dev;
5818 int err, i;
5819 u32 int_mbox = 0;
5820
5821 tg3_disable_ints(tp);
5822
5823 free_irq(tp->pdev->irq, dev);
5824
5825 err = request_irq(tp->pdev->irq, tg3_test_isr,
5826 SA_SHIRQ, dev->name, dev);
5827 if (err)
5828 return err;
5829
5830 tg3_enable_ints(tp);
5831
5832 tw32_f(HOSTCC_MODE, tp->coalesce_mode | HOSTCC_MODE_ENABLE |
5833 HOSTCC_MODE_NOW);
5834
5835 for (i = 0; i < 5; i++) {
5836 int_mbox = tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
5837 if (int_mbox != 0)
5838 break;
5839 msleep(10);
5840 }
5841
5842 tg3_disable_ints(tp);
5843
5844 free_irq(tp->pdev->irq, dev);
5845
5846 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI)
5847 err = request_irq(tp->pdev->irq, tg3_msi,
5848 0, dev->name, dev);
5849 else
5850 err = request_irq(tp->pdev->irq, tg3_interrupt,
5851 SA_SHIRQ, dev->name, dev);
5852
5853 if (err)
5854 return err;
5855
5856 if (int_mbox != 0)
5857 return 0;
5858
5859 return -EIO;
5860}
5861
5862/* Returns 0 if MSI test succeeds or MSI test fails and INTx mode is
5863 * successfully restored
5864 */
5865static int tg3_test_msi(struct tg3 *tp)
5866{
5867 struct net_device *dev = tp->dev;
5868 int err;
5869 u16 pci_cmd;
5870
5871 if (!(tp->tg3_flags2 & TG3_FLG2_USING_MSI))
5872 return 0;
5873
5874 /* Turn off SERR reporting in case MSI terminates with Master
5875 * Abort.
5876 */
5877 pci_read_config_word(tp->pdev, PCI_COMMAND, &pci_cmd);
5878 pci_write_config_word(tp->pdev, PCI_COMMAND,
5879 pci_cmd & ~PCI_COMMAND_SERR);
5880
5881 err = tg3_test_interrupt(tp);
5882
5883 pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd);
5884
5885 if (!err)
5886 return 0;
5887
5888 /* other failures */
5889 if (err != -EIO)
5890 return err;
5891
5892 /* MSI test failed, go back to INTx mode */
5893 printk(KERN_WARNING PFX "%s: No interrupt was generated using MSI, "
5894 "switching to INTx mode. Please report this failure to "
5895 "the PCI maintainer and include system chipset information.\n",
5896 tp->dev->name);
5897
5898 free_irq(tp->pdev->irq, dev);
5899 pci_disable_msi(tp->pdev);
5900
5901 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
5902
5903 err = request_irq(tp->pdev->irq, tg3_interrupt,
5904 SA_SHIRQ, dev->name, dev);
5905
5906 if (err)
5907 return err;
5908
5909 /* Need to reset the chip because the MSI cycle may have terminated
5910 * with Master Abort.
5911 */
5912 spin_lock_irq(&tp->lock);
5913 spin_lock(&tp->tx_lock);
5914
5915 tg3_halt(tp);
5916 err = tg3_init_hw(tp);
5917
5918 spin_unlock(&tp->tx_lock);
5919 spin_unlock_irq(&tp->lock);
5920
5921 if (err)
5922 free_irq(tp->pdev->irq, dev);
5923
5924 return err;
5925}
5926
5709static int tg3_open(struct net_device *dev) 5927static int tg3_open(struct net_device *dev)
5710{ 5928{
5711 struct tg3 *tp = netdev_priv(dev); 5929 struct tg3 *tp = netdev_priv(dev);
@@ -5727,10 +5945,29 @@ static int tg3_open(struct net_device *dev)
5727 if (err) 5945 if (err)
5728 return err; 5946 return err;
5729 5947
5730 err = request_irq(dev->irq, tg3_interrupt, 5948 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
5731 SA_SHIRQ, dev->name, dev); 5949 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) &&
5950 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX)) {
5951 if (pci_enable_msi(tp->pdev) == 0) {
5952 u32 msi_mode;
5953
5954 msi_mode = tr32(MSGINT_MODE);
5955 tw32(MSGINT_MODE, msi_mode | MSGINT_MODE_ENABLE);
5956 tp->tg3_flags2 |= TG3_FLG2_USING_MSI;
5957 }
5958 }
5959 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI)
5960 err = request_irq(tp->pdev->irq, tg3_msi,
5961 0, dev->name, dev);
5962 else
5963 err = request_irq(tp->pdev->irq, tg3_interrupt,
5964 SA_SHIRQ, dev->name, dev);
5732 5965
5733 if (err) { 5966 if (err) {
5967 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
5968 pci_disable_msi(tp->pdev);
5969 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
5970 }
5734 tg3_free_consistent(tp); 5971 tg3_free_consistent(tp);
5735 return err; 5972 return err;
5736 } 5973 }
@@ -5751,23 +5988,47 @@ static int tg3_open(struct net_device *dev)
5751 tp->timer.expires = jiffies + tp->timer_offset; 5988 tp->timer.expires = jiffies + tp->timer_offset;
5752 tp->timer.data = (unsigned long) tp; 5989 tp->timer.data = (unsigned long) tp;
5753 tp->timer.function = tg3_timer; 5990 tp->timer.function = tg3_timer;
5754 add_timer(&tp->timer);
5755
5756 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
5757 } 5991 }
5758 5992
5759 spin_unlock(&tp->tx_lock); 5993 spin_unlock(&tp->tx_lock);
5760 spin_unlock_irq(&tp->lock); 5994 spin_unlock_irq(&tp->lock);
5761 5995
5762 if (err) { 5996 if (err) {
5763 free_irq(dev->irq, dev); 5997 free_irq(tp->pdev->irq, dev);
5998 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
5999 pci_disable_msi(tp->pdev);
6000 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
6001 }
5764 tg3_free_consistent(tp); 6002 tg3_free_consistent(tp);
5765 return err; 6003 return err;
5766 } 6004 }
5767 6005
6006 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
6007 err = tg3_test_msi(tp);
6008 if (err) {
6009 spin_lock_irq(&tp->lock);
6010 spin_lock(&tp->tx_lock);
6011
6012 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
6013 pci_disable_msi(tp->pdev);
6014 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
6015 }
6016 tg3_halt(tp);
6017 tg3_free_rings(tp);
6018 tg3_free_consistent(tp);
6019
6020 spin_unlock(&tp->tx_lock);
6021 spin_unlock_irq(&tp->lock);
6022
6023 return err;
6024 }
6025 }
6026
5768 spin_lock_irq(&tp->lock); 6027 spin_lock_irq(&tp->lock);
5769 spin_lock(&tp->tx_lock); 6028 spin_lock(&tp->tx_lock);
5770 6029
6030 add_timer(&tp->timer);
6031 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
5771 tg3_enable_ints(tp); 6032 tg3_enable_ints(tp);
5772 6033
5773 spin_unlock(&tp->tx_lock); 6034 spin_unlock(&tp->tx_lock);
@@ -6035,7 +6296,11 @@ static int tg3_close(struct net_device *dev)
6035 spin_unlock(&tp->tx_lock); 6296 spin_unlock(&tp->tx_lock);
6036 spin_unlock_irq(&tp->lock); 6297 spin_unlock_irq(&tp->lock);
6037 6298
6038 free_irq(dev->irq, dev); 6299 free_irq(tp->pdev->irq, dev);
6300 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
6301 pci_disable_msi(tp->pdev);
6302 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
6303 }
6039 6304
6040 memcpy(&tp->net_stats_prev, tg3_get_stats(tp->dev), 6305 memcpy(&tp->net_stats_prev, tg3_get_stats(tp->dev),
6041 sizeof(tp->net_stats_prev)); 6306 sizeof(tp->net_stats_prev));
@@ -6509,10 +6774,12 @@ static int tg3_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
6509 start = cpu_to_le32(start); 6774 start = cpu_to_le32(start);
6510 len += b_offset; 6775 len += b_offset;
6511 offset &= ~3; 6776 offset &= ~3;
6777 if (len < 4)
6778 len = 4;
6512 } 6779 }
6513 6780
6514 odd_len = 0; 6781 odd_len = 0;
6515 if ((len & 3) && ((len > 4) || (b_offset == 0))) { 6782 if (len & 3) {
6516 /* adjustments to end on required 4 byte boundary */ 6783 /* adjustments to end on required 4 byte boundary */
6517 odd_len = 1; 6784 odd_len = 1;
6518 len = (len + 3) & ~3; 6785 len = (len + 3) & ~3;
@@ -7067,6 +7334,67 @@ static void __devinit tg3_get_nvram_info(struct tg3 *tp)
7067 } 7334 }
7068} 7335}
7069 7336
7337static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp)
7338{
7339 u32 nvcfg1;
7340
7341 nvcfg1 = tr32(NVRAM_CFG1);
7342
7343 /* NVRAM protection for TPM */
7344 if (nvcfg1 & (1 << 27))
7345 tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM;
7346
7347 switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) {
7348 case FLASH_5752VENDOR_ATMEL_EEPROM_64KHZ:
7349 case FLASH_5752VENDOR_ATMEL_EEPROM_376KHZ:
7350 tp->nvram_jedecnum = JEDEC_ATMEL;
7351 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
7352 break;
7353 case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED:
7354 tp->nvram_jedecnum = JEDEC_ATMEL;
7355 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
7356 tp->tg3_flags2 |= TG3_FLG2_FLASH;
7357 break;
7358 case FLASH_5752VENDOR_ST_M45PE10:
7359 case FLASH_5752VENDOR_ST_M45PE20:
7360 case FLASH_5752VENDOR_ST_M45PE40:
7361 tp->nvram_jedecnum = JEDEC_ST;
7362 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
7363 tp->tg3_flags2 |= TG3_FLG2_FLASH;
7364 break;
7365 }
7366
7367 if (tp->tg3_flags2 & TG3_FLG2_FLASH) {
7368 switch (nvcfg1 & NVRAM_CFG1_5752PAGE_SIZE_MASK) {
7369 case FLASH_5752PAGE_SIZE_256:
7370 tp->nvram_pagesize = 256;
7371 break;
7372 case FLASH_5752PAGE_SIZE_512:
7373 tp->nvram_pagesize = 512;
7374 break;
7375 case FLASH_5752PAGE_SIZE_1K:
7376 tp->nvram_pagesize = 1024;
7377 break;
7378 case FLASH_5752PAGE_SIZE_2K:
7379 tp->nvram_pagesize = 2048;
7380 break;
7381 case FLASH_5752PAGE_SIZE_4K:
7382 tp->nvram_pagesize = 4096;
7383 break;
7384 case FLASH_5752PAGE_SIZE_264:
7385 tp->nvram_pagesize = 264;
7386 break;
7387 }
7388 }
7389 else {
7390 /* For eeprom, set pagesize to maximum eeprom size */
7391 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE;
7392
7393 nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS;
7394 tw32(NVRAM_CFG1, nvcfg1);
7395 }
7396}
7397
7070/* Chips other than 5700/5701 use the NVRAM for fetching info. */ 7398/* Chips other than 5700/5701 use the NVRAM for fetching info. */
7071static void __devinit tg3_nvram_init(struct tg3 *tp) 7399static void __devinit tg3_nvram_init(struct tg3 *tp)
7072{ 7400{
@@ -7093,20 +7421,16 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
7093 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) { 7421 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
7094 tp->tg3_flags |= TG3_FLAG_NVRAM; 7422 tp->tg3_flags |= TG3_FLAG_NVRAM;
7095 7423
7096 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7424 tg3_enable_nvram_access(tp);
7097 u32 nvaccess = tr32(NVRAM_ACCESS);
7098 7425
7099 tw32(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE); 7426 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
7100 } 7427 tg3_get_5752_nvram_info(tp);
7428 else
7429 tg3_get_nvram_info(tp);
7101 7430
7102 tg3_get_nvram_info(tp);
7103 tg3_get_nvram_size(tp); 7431 tg3_get_nvram_size(tp);
7104 7432
7105 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7433 tg3_disable_nvram_access(tp);
7106 u32 nvaccess = tr32(NVRAM_ACCESS);
7107
7108 tw32(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
7109 }
7110 7434
7111 } else { 7435 } else {
7112 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED); 7436 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
@@ -7195,11 +7519,7 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
7195 7519
7196 tg3_nvram_lock(tp); 7520 tg3_nvram_lock(tp);
7197 7521
7198 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7522 tg3_enable_nvram_access(tp);
7199 u32 nvaccess = tr32(NVRAM_ACCESS);
7200
7201 tw32_f(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
7202 }
7203 7523
7204 tw32(NVRAM_ADDR, offset); 7524 tw32(NVRAM_ADDR, offset);
7205 ret = tg3_nvram_exec_cmd(tp, NVRAM_CMD_RD | NVRAM_CMD_GO | 7525 ret = tg3_nvram_exec_cmd(tp, NVRAM_CMD_RD | NVRAM_CMD_GO |
@@ -7210,11 +7530,7 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
7210 7530
7211 tg3_nvram_unlock(tp); 7531 tg3_nvram_unlock(tp);
7212 7532
7213 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7533 tg3_disable_nvram_access(tp);
7214 u32 nvaccess = tr32(NVRAM_ACCESS);
7215
7216 tw32_f(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
7217 }
7218 7534
7219 return ret; 7535 return ret;
7220} 7536}
@@ -7277,7 +7593,7 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
7277 7593
7278 while (len) { 7594 while (len) {
7279 int j; 7595 int j;
7280 u32 phy_addr, page_off, size, nvaccess; 7596 u32 phy_addr, page_off, size;
7281 7597
7282 phy_addr = offset & ~pagemask; 7598 phy_addr = offset & ~pagemask;
7283 7599
@@ -7300,8 +7616,7 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
7300 7616
7301 offset = offset + (pagesize - page_off); 7617 offset = offset + (pagesize - page_off);
7302 7618
7303 nvaccess = tr32(NVRAM_ACCESS); 7619 tg3_enable_nvram_access(tp);
7304 tw32_f(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
7305 7620
7306 /* 7621 /*
7307 * Before we can erase the flash page, we need 7622 * Before we can erase the flash page, we need
@@ -7425,8 +7740,8 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
7425 } 7740 }
7426 7741
7427 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) { 7742 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
7428 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 7743 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl &
7429 GRC_LCLCTRL_GPIO_OE1); 7744 ~GRC_LCLCTRL_GPIO_OUTPUT1);
7430 udelay(40); 7745 udelay(40);
7431 } 7746 }
7432 7747
@@ -7438,13 +7753,10 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
7438 7753
7439 tg3_nvram_lock(tp); 7754 tg3_nvram_lock(tp);
7440 7755
7441 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7756 tg3_enable_nvram_access(tp);
7442 u32 nvaccess = tr32(NVRAM_ACCESS); 7757 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
7443 7758 !(tp->tg3_flags2 & TG3_FLG2_PROTECTED_NVRAM))
7444 tw32(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
7445
7446 tw32(NVRAM_WRITE1, 0x406); 7759 tw32(NVRAM_WRITE1, 0x406);
7447 }
7448 7760
7449 grc_mode = tr32(GRC_MODE); 7761 grc_mode = tr32(GRC_MODE);
7450 tw32(GRC_MODE, grc_mode | GRC_MODE_NVRAM_WR_ENABLE); 7762 tw32(GRC_MODE, grc_mode | GRC_MODE_NVRAM_WR_ENABLE);
@@ -7463,17 +7775,12 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
7463 grc_mode = tr32(GRC_MODE); 7775 grc_mode = tr32(GRC_MODE);
7464 tw32(GRC_MODE, grc_mode & ~GRC_MODE_NVRAM_WR_ENABLE); 7776 tw32(GRC_MODE, grc_mode & ~GRC_MODE_NVRAM_WR_ENABLE);
7465 7777
7466 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7778 tg3_disable_nvram_access(tp);
7467 u32 nvaccess = tr32(NVRAM_ACCESS);
7468
7469 tw32(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
7470 }
7471 tg3_nvram_unlock(tp); 7779 tg3_nvram_unlock(tp);
7472 } 7780 }
7473 7781
7474 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) { 7782 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
7475 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 7783 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
7476 GRC_LCLCTRL_GPIO_OE1 | GRC_LCLCTRL_GPIO_OUTPUT1);
7477 udelay(40); 7784 udelay(40);
7478 } 7785 }
7479 7786
@@ -7537,21 +7844,27 @@ static inline struct subsys_tbl_ent *lookup_by_subsys(struct tg3 *tp)
7537 return NULL; 7844 return NULL;
7538} 7845}
7539 7846
7540static int __devinit tg3_phy_probe(struct tg3 *tp) 7847/* Since this function may be called in D3-hot power state during
7848 * tg3_init_one(), only config cycles are allowed.
7849 */
7850static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
7541{ 7851{
7542 u32 eeprom_phy_id, hw_phy_id_1, hw_phy_id_2;
7543 u32 hw_phy_id, hw_phy_id_masked;
7544 u32 val; 7852 u32 val;
7545 int eeprom_signature_found, eeprom_phy_serdes, err; 7853
7854 /* Make sure register accesses (indirect or otherwise)
7855 * will function correctly.
7856 */
7857 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
7858 tp->misc_host_ctrl);
7546 7859
7547 tp->phy_id = PHY_ID_INVALID; 7860 tp->phy_id = PHY_ID_INVALID;
7548 eeprom_phy_id = PHY_ID_INVALID; 7861 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
7549 eeprom_phy_serdes = 0; 7862
7550 eeprom_signature_found = 0;
7551 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val); 7863 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val);
7552 if (val == NIC_SRAM_DATA_SIG_MAGIC) { 7864 if (val == NIC_SRAM_DATA_SIG_MAGIC) {
7553 u32 nic_cfg, led_cfg; 7865 u32 nic_cfg, led_cfg;
7554 u32 nic_phy_id, ver, cfg2 = 0; 7866 u32 nic_phy_id, ver, cfg2 = 0, eeprom_phy_id;
7867 int eeprom_phy_serdes = 0;
7555 7868
7556 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg); 7869 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg);
7557 tp->nic_sram_data_cfg = nic_cfg; 7870 tp->nic_sram_data_cfg = nic_cfg;
@@ -7564,8 +7877,6 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7564 (ver > 0) && (ver < 0x100)) 7877 (ver > 0) && (ver < 0x100))
7565 tg3_read_mem(tp, NIC_SRAM_DATA_CFG_2, &cfg2); 7878 tg3_read_mem(tp, NIC_SRAM_DATA_CFG_2, &cfg2);
7566 7879
7567 eeprom_signature_found = 1;
7568
7569 if ((nic_cfg & NIC_SRAM_DATA_CFG_PHY_TYPE_MASK) == 7880 if ((nic_cfg & NIC_SRAM_DATA_CFG_PHY_TYPE_MASK) ==
7570 NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER) 7881 NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER)
7571 eeprom_phy_serdes = 1; 7882 eeprom_phy_serdes = 1;
@@ -7581,10 +7892,14 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7581 } else 7892 } else
7582 eeprom_phy_id = 0; 7893 eeprom_phy_id = 0;
7583 7894
7584 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7895 tp->phy_id = eeprom_phy_id;
7896 if (eeprom_phy_serdes)
7897 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES;
7898
7899 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
7585 led_cfg = cfg2 & (NIC_SRAM_DATA_CFG_LED_MODE_MASK | 7900 led_cfg = cfg2 & (NIC_SRAM_DATA_CFG_LED_MODE_MASK |
7586 SHASTA_EXT_LED_MODE_MASK); 7901 SHASTA_EXT_LED_MODE_MASK);
7587 } else 7902 else
7588 led_cfg = nic_cfg & NIC_SRAM_DATA_CFG_LED_MODE_MASK; 7903 led_cfg = nic_cfg & NIC_SRAM_DATA_CFG_LED_MODE_MASK;
7589 7904
7590 switch (led_cfg) { 7905 switch (led_cfg) {
@@ -7634,7 +7949,7 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7634 7949
7635 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { 7950 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
7636 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; 7951 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
7637 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) 7952 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
7638 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE; 7953 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE;
7639 } 7954 }
7640 if (nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL) 7955 if (nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL)
@@ -7648,6 +7963,13 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7648 if (cfg2 & (1 << 18)) 7963 if (cfg2 & (1 << 18))
7649 tp->tg3_flags2 |= TG3_FLG2_SERDES_PREEMPHASIS; 7964 tp->tg3_flags2 |= TG3_FLG2_SERDES_PREEMPHASIS;
7650 } 7965 }
7966}
7967
7968static int __devinit tg3_phy_probe(struct tg3 *tp)
7969{
7970 u32 hw_phy_id_1, hw_phy_id_2;
7971 u32 hw_phy_id, hw_phy_id_masked;
7972 int err;
7651 7973
7652 /* Reading the PHY ID register can conflict with ASF 7974 /* Reading the PHY ID register can conflict with ASF
7653 * firwmare access to the PHY hardware. 7975 * firwmare access to the PHY hardware.
@@ -7676,10 +7998,10 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7676 if (hw_phy_id_masked == PHY_ID_BCM8002) 7998 if (hw_phy_id_masked == PHY_ID_BCM8002)
7677 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES; 7999 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES;
7678 } else { 8000 } else {
7679 if (eeprom_signature_found) { 8001 if (tp->phy_id != PHY_ID_INVALID) {
7680 tp->phy_id = eeprom_phy_id; 8002 /* Do nothing, phy ID already set up in
7681 if (eeprom_phy_serdes) 8003 * tg3_get_eeprom_hw_cfg().
7682 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES; 8004 */
7683 } else { 8005 } else {
7684 struct subsys_tbl_ent *p; 8006 struct subsys_tbl_ent *p;
7685 8007
@@ -7750,9 +8072,6 @@ skip_phy_reset:
7750 err = tg3_init_5401phy_dsp(tp); 8072 err = tg3_init_5401phy_dsp(tp);
7751 } 8073 }
7752 8074
7753 if (!eeprom_signature_found)
7754 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
7755
7756 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) 8075 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)
7757 tp->link_config.advertising = 8076 tp->link_config.advertising =
7758 (ADVERTISED_1000baseT_Half | 8077 (ADVERTISED_1000baseT_Half |
@@ -7917,6 +8236,12 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
7917 tp->pci_chip_rev_id = (misc_ctrl_reg >> 8236 tp->pci_chip_rev_id = (misc_ctrl_reg >>
7918 MISC_HOST_CTRL_CHIPREV_SHIFT); 8237 MISC_HOST_CTRL_CHIPREV_SHIFT);
7919 8238
8239 /* Wrong chip ID in 5752 A0. This code can be removed later
8240 * as A0 is not in production.
8241 */
8242 if (tp->pci_chip_rev_id == CHIPREV_ID_5752_A0_HW)
8243 tp->pci_chip_rev_id = CHIPREV_ID_5752_A0;
8244
7920 /* Initialize misc host control in PCI block. */ 8245 /* Initialize misc host control in PCI block. */
7921 tp->misc_host_ctrl |= (misc_ctrl_reg & 8246 tp->misc_host_ctrl |= (misc_ctrl_reg &
7922 MISC_HOST_CTRL_CHIPREV); 8247 MISC_HOST_CTRL_CHIPREV);
@@ -7931,11 +8256,15 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
7931 tp->pci_hdr_type = (cacheline_sz_reg >> 16) & 0xff; 8256 tp->pci_hdr_type = (cacheline_sz_reg >> 16) & 0xff;
7932 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff; 8257 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff;
7933 8258
8259 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 ||
8260 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
8261 tp->tg3_flags2 |= TG3_FLG2_5750_PLUS;
8262
7934 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) || 8263 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) ||
7935 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) 8264 (tp->tg3_flags2 & TG3_FLG2_5750_PLUS))
7936 tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; 8265 tp->tg3_flags2 |= TG3_FLG2_5705_PLUS;
7937 8266
7938 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) 8267 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
7939 tp->tg3_flags2 |= TG3_FLG2_HW_TSO; 8268 tp->tg3_flags2 |= TG3_FLG2_HW_TSO;
7940 8269
7941 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) 8270 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0)
@@ -8013,6 +8342,31 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
8013 pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg); 8342 pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg);
8014 } 8343 }
8015 8344
8345 /* Get eeprom hw config before calling tg3_set_power_state().
8346 * In particular, the TG3_FLAG_EEPROM_WRITE_PROT flag must be
8347 * determined before calling tg3_set_power_state() so that
8348 * we know whether or not to switch out of Vaux power.
8349 * When the flag is set, it means that GPIO1 is used for eeprom
8350 * write protect and also implies that it is a LOM where GPIOs
8351 * are not used to switch power.
8352 */
8353 tg3_get_eeprom_hw_cfg(tp);
8354
8355 /* Set up tp->grc_local_ctrl before calling tg3_set_power_state().
8356 * GPIO1 driven high will bring 5700's external PHY out of reset.
8357 * It is also used as eeprom write protect on LOMs.
8358 */
8359 tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM;
8360 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) ||
8361 (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT))
8362 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
8363 GRC_LCLCTRL_GPIO_OUTPUT1);
8364 /* Unused GPIO3 must be driven as output on 5752 because there
8365 * are no pull-up resistors on unused GPIO pins.
8366 */
8367 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
8368 tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3;
8369
8016 /* Force the chip into D0. */ 8370 /* Force the chip into D0. */
8017 err = tg3_set_power_state(tp, 0); 8371 err = tg3_set_power_state(tp, 0);
8018 if (err) { 8372 if (err) {
@@ -8065,8 +8419,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
8065 if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0) 8419 if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0)
8066 tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; 8420 tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG;
8067 8421
8068 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 || 8422 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)
8069 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
8070 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; 8423 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG;
8071 8424
8072 /* Only 5701 and later support tagged irq status mode. 8425 /* Only 5701 and later support tagged irq status mode.
@@ -8628,6 +8981,7 @@ static char * __devinit tg3_phy_string(struct tg3 *tp)
8628 case PHY_ID_BCM5704: return "5704"; 8981 case PHY_ID_BCM5704: return "5704";
8629 case PHY_ID_BCM5705: return "5705"; 8982 case PHY_ID_BCM5705: return "5705";
8630 case PHY_ID_BCM5750: return "5750"; 8983 case PHY_ID_BCM5750: return "5750";
8984 case PHY_ID_BCM5752: return "5752";
8631 case PHY_ID_BCM8002: return "8002/serdes"; 8985 case PHY_ID_BCM8002: return "8002/serdes";
8632 case 0: return "serdes"; 8986 case 0: return "serdes";
8633 default: return "unknown"; 8987 default: return "unknown";
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index d48887d90325..8de6f21037ba 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -125,6 +125,9 @@
125#define CHIPREV_ID_5750_A0 0x4000 125#define CHIPREV_ID_5750_A0 0x4000
126#define CHIPREV_ID_5750_A1 0x4001 126#define CHIPREV_ID_5750_A1 0x4001
127#define CHIPREV_ID_5750_A3 0x4003 127#define CHIPREV_ID_5750_A3 0x4003
128#define CHIPREV_ID_5752_A0_HW 0x5000
129#define CHIPREV_ID_5752_A0 0x6000
130#define CHIPREV_ID_5752_A1 0x6001
128#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12) 131#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12)
129#define ASIC_REV_5700 0x07 132#define ASIC_REV_5700 0x07
130#define ASIC_REV_5701 0x00 133#define ASIC_REV_5701 0x00
@@ -132,6 +135,7 @@
132#define ASIC_REV_5704 0x02 135#define ASIC_REV_5704 0x02
133#define ASIC_REV_5705 0x03 136#define ASIC_REV_5705 0x03
134#define ASIC_REV_5750 0x04 137#define ASIC_REV_5750 0x04
138#define ASIC_REV_5752 0x06
135#define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8) 139#define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8)
136#define CHIPREV_5700_AX 0x70 140#define CHIPREV_5700_AX 0x70
137#define CHIPREV_5700_BX 0x71 141#define CHIPREV_5700_BX 0x71
@@ -1307,6 +1311,9 @@
1307#define GRC_LCLCTRL_CLEARINT 0x00000002 1311#define GRC_LCLCTRL_CLEARINT 0x00000002
1308#define GRC_LCLCTRL_SETINT 0x00000004 1312#define GRC_LCLCTRL_SETINT 0x00000004
1309#define GRC_LCLCTRL_INT_ON_ATTN 0x00000008 1313#define GRC_LCLCTRL_INT_ON_ATTN 0x00000008
1314#define GRC_LCLCTRL_GPIO_INPUT3 0x00000020
1315#define GRC_LCLCTRL_GPIO_OE3 0x00000040
1316#define GRC_LCLCTRL_GPIO_OUTPUT3 0x00000080
1310#define GRC_LCLCTRL_GPIO_INPUT0 0x00000100 1317#define GRC_LCLCTRL_GPIO_INPUT0 0x00000100
1311#define GRC_LCLCTRL_GPIO_INPUT1 0x00000200 1318#define GRC_LCLCTRL_GPIO_INPUT1 0x00000200
1312#define GRC_LCLCTRL_GPIO_INPUT2 0x00000400 1319#define GRC_LCLCTRL_GPIO_INPUT2 0x00000400
@@ -1392,6 +1399,20 @@
1392#define FLASH_VENDOR_SAIFUN 0x01000003 1399#define FLASH_VENDOR_SAIFUN 0x01000003
1393#define FLASH_VENDOR_SST_SMALL 0x00000001 1400#define FLASH_VENDOR_SST_SMALL 0x00000001
1394#define FLASH_VENDOR_SST_LARGE 0x02000001 1401#define FLASH_VENDOR_SST_LARGE 0x02000001
1402#define NVRAM_CFG1_5752VENDOR_MASK 0x03c00003
1403#define FLASH_5752VENDOR_ATMEL_EEPROM_64KHZ 0x00000000
1404#define FLASH_5752VENDOR_ATMEL_EEPROM_376KHZ 0x02000000
1405#define FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED 0x02000003
1406#define FLASH_5752VENDOR_ST_M45PE10 0x02400000
1407#define FLASH_5752VENDOR_ST_M45PE20 0x02400002
1408#define FLASH_5752VENDOR_ST_M45PE40 0x02400001
1409#define NVRAM_CFG1_5752PAGE_SIZE_MASK 0x70000000
1410#define FLASH_5752PAGE_SIZE_256 0x00000000
1411#define FLASH_5752PAGE_SIZE_512 0x10000000
1412#define FLASH_5752PAGE_SIZE_1K 0x20000000
1413#define FLASH_5752PAGE_SIZE_2K 0x30000000
1414#define FLASH_5752PAGE_SIZE_4K 0x40000000
1415#define FLASH_5752PAGE_SIZE_264 0x50000000
1395#define NVRAM_CFG2 0x00007018 1416#define NVRAM_CFG2 0x00007018
1396#define NVRAM_CFG3 0x0000701c 1417#define NVRAM_CFG3 0x0000701c
1397#define NVRAM_SWARB 0x00007020 1418#define NVRAM_SWARB 0x00007020
@@ -2100,6 +2121,9 @@ struct tg3 {
2100#define TG3_FLG2_HW_TSO 0x00010000 2121#define TG3_FLG2_HW_TSO 0x00010000
2101#define TG3_FLG2_SERDES_PREEMPHASIS 0x00020000 2122#define TG3_FLG2_SERDES_PREEMPHASIS 0x00020000
2102#define TG3_FLG2_5705_PLUS 0x00040000 2123#define TG3_FLG2_5705_PLUS 0x00040000
2124#define TG3_FLG2_5750_PLUS 0x00080000
2125#define TG3_FLG2_PROTECTED_NVRAM 0x00100000
2126#define TG3_FLG2_USING_MSI 0x00200000
2103 2127
2104 u32 split_mode_max_reqs; 2128 u32 split_mode_max_reqs;
2105#define SPLIT_MODE_5704_MAX_REQ 3 2129#define SPLIT_MODE_5704_MAX_REQ 3
@@ -2145,6 +2169,7 @@ struct tg3 {
2145#define PHY_ID_BCM5704 0x60008190 2169#define PHY_ID_BCM5704 0x60008190
2146#define PHY_ID_BCM5705 0x600081a0 2170#define PHY_ID_BCM5705 0x600081a0
2147#define PHY_ID_BCM5750 0x60008180 2171#define PHY_ID_BCM5750 0x60008180
2172#define PHY_ID_BCM5752 0x60008100
2148#define PHY_ID_BCM8002 0x60010140 2173#define PHY_ID_BCM8002 0x60010140
2149#define PHY_ID_INVALID 0xffffffff 2174#define PHY_ID_INVALID 0xffffffff
2150#define PHY_ID_REV_MASK 0x0000000f 2175#define PHY_ID_REV_MASK 0x0000000f