diff options
author | James Bottomley <jejb@titanic.(none)> | 2005-05-20 16:27:44 -0400 |
---|---|---|
committer | James Bottomley <jejb@titanic.(none)> | 2005-05-20 16:27:44 -0400 |
commit | ad34ea2cc3845ef4dcd7d12fb0fa8484734bd672 (patch) | |
tree | ad434400f5ecaa33b433c8f830e40792d8d6c05c /drivers/net/tg3.c | |
parent | 90356ac3194bf91a441a5f9c3067af386ef62462 (diff) | |
parent | 88d7bd8cb9eb8d64bf7997600b0d64f7834047c5 (diff) |
merge by hand - fix up rejections in Documentation/DocBook/Makefile
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 662 |
1 files changed, 508 insertions, 154 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 12de80884b1a..f79b02e80e75 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -61,8 +61,8 @@ | |||
61 | 61 | ||
62 | #define DRV_MODULE_NAME "tg3" | 62 | #define DRV_MODULE_NAME "tg3" |
63 | #define PFX DRV_MODULE_NAME ": " | 63 | #define PFX DRV_MODULE_NAME ": " |
64 | #define DRV_MODULE_VERSION "3.25" | 64 | #define DRV_MODULE_VERSION "3.27" |
65 | #define DRV_MODULE_RELDATE "March 24, 2005" | 65 | #define DRV_MODULE_RELDATE "May 5, 2005" |
66 | 66 | ||
67 | #define TG3_DEF_MAC_MODE 0 | 67 | #define TG3_DEF_MAC_MODE 0 |
68 | #define TG3_DEF_RX_MODE 0 | 68 | #define TG3_DEF_RX_MODE 0 |
@@ -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, |
@@ -425,9 +426,30 @@ static void tg3_enable_ints(struct tg3 *tp) | |||
425 | tg3_cond_int(tp); | 426 | tg3_cond_int(tp); |
426 | } | 427 | } |
427 | 428 | ||
429 | static inline unsigned int tg3_has_work(struct tg3 *tp) | ||
430 | { | ||
431 | struct tg3_hw_status *sblk = tp->hw_status; | ||
432 | unsigned int work_exists = 0; | ||
433 | |||
434 | /* check for phy events */ | ||
435 | if (!(tp->tg3_flags & | ||
436 | (TG3_FLAG_USE_LINKCHG_REG | | ||
437 | TG3_FLAG_POLL_SERDES))) { | ||
438 | if (sblk->status & SD_STATUS_LINK_CHG) | ||
439 | work_exists = 1; | ||
440 | } | ||
441 | /* check for RX/TX work to do */ | ||
442 | if (sblk->idx[0].tx_consumer != tp->tx_cons || | ||
443 | sblk->idx[0].rx_producer != tp->rx_rcb_ptr) | ||
444 | work_exists = 1; | ||
445 | |||
446 | return work_exists; | ||
447 | } | ||
448 | |||
428 | /* tg3_restart_ints | 449 | /* tg3_restart_ints |
429 | * similar to tg3_enable_ints, but it can return without flushing the | 450 | * similar to tg3_enable_ints, but it accurately determines whether there |
430 | * PIO write which reenables interrupts | 451 | * is new work pending and can return without flushing the PIO write |
452 | * which reenables interrupts | ||
431 | */ | 453 | */ |
432 | static void tg3_restart_ints(struct tg3 *tp) | 454 | static void tg3_restart_ints(struct tg3 *tp) |
433 | { | 455 | { |
@@ -436,7 +458,9 @@ static void tg3_restart_ints(struct tg3 *tp) | |||
436 | tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000); | 458 | tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000); |
437 | mmiowb(); | 459 | mmiowb(); |
438 | 460 | ||
439 | tg3_cond_int(tp); | 461 | if (tg3_has_work(tp)) |
462 | tw32(HOSTCC_MODE, tp->coalesce_mode | | ||
463 | (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW)); | ||
440 | } | 464 | } |
441 | 465 | ||
442 | static inline void tg3_netif_stop(struct tg3 *tp) | 466 | static inline void tg3_netif_stop(struct tg3 *tp) |
@@ -860,8 +884,7 @@ out: | |||
860 | if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) { | 884 | if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) { |
861 | /* Cannot do read-modify-write on 5401 */ | 885 | /* Cannot do read-modify-write on 5401 */ |
862 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20); | 886 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20); |
863 | } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && | 887 | } 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; | 888 | u32 phy_reg; |
866 | 889 | ||
867 | /* Set bit 14 with read-modify-write to preserve other bits */ | 890 | /* Set bit 14 with read-modify-write to preserve other bits */ |
@@ -873,8 +896,7 @@ out: | |||
873 | /* Set phy register 0x10 bit 0 to high fifo elasticity to support | 896 | /* Set phy register 0x10 bit 0 to high fifo elasticity to support |
874 | * jumbo frames transmission. | 897 | * jumbo frames transmission. |
875 | */ | 898 | */ |
876 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && | 899 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { |
877 | GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) { | ||
878 | u32 phy_reg; | 900 | u32 phy_reg; |
879 | 901 | ||
880 | if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg)) | 902 | if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg)) |
@@ -1006,8 +1028,13 @@ static int tg3_set_power_state(struct tg3 *tp, int state) | |||
1006 | pci_write_config_word(tp->pdev, | 1028 | pci_write_config_word(tp->pdev, |
1007 | pm + PCI_PM_CTRL, | 1029 | pm + PCI_PM_CTRL, |
1008 | power_control); | 1030 | power_control); |
1009 | tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); | 1031 | udelay(100); /* Delay after power state change */ |
1010 | udelay(100); | 1032 | |
1033 | /* Switch out of Vaux if it is not a LOM */ | ||
1034 | if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)) { | ||
1035 | tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); | ||
1036 | udelay(100); | ||
1037 | } | ||
1011 | 1038 | ||
1012 | return 0; | 1039 | return 0; |
1013 | 1040 | ||
@@ -1068,7 +1095,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state) | |||
1068 | mac_mode = MAC_MODE_PORT_MODE_TBI; | 1095 | mac_mode = MAC_MODE_PORT_MODE_TBI; |
1069 | } | 1096 | } |
1070 | 1097 | ||
1071 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) | 1098 | if (!(tp->tg3_flags2 & TG3_FLG2_5750_PLUS)) |
1072 | tw32(MAC_LED_CTRL, tp->led_ctrl); | 1099 | tw32(MAC_LED_CTRL, tp->led_ctrl); |
1073 | 1100 | ||
1074 | if (((power_caps & PCI_PM_CAP_PME_D3cold) && | 1101 | if (((power_caps & PCI_PM_CAP_PME_D3cold) && |
@@ -1095,7 +1122,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state) | |||
1095 | CLOCK_CTRL_ALTCLK | | 1122 | CLOCK_CTRL_ALTCLK | |
1096 | CLOCK_CTRL_PWRDOWN_PLL133); | 1123 | CLOCK_CTRL_PWRDOWN_PLL133); |
1097 | udelay(40); | 1124 | udelay(40); |
1098 | } else if (!((GET_ASIC_REV(tp->pci_chip_rev_id) == 5750) && | 1125 | } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && |
1099 | (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) { | 1126 | (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) { |
1100 | u32 newbits1, newbits2; | 1127 | u32 newbits1, newbits2; |
1101 | 1128 | ||
@@ -1152,6 +1179,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state) | |||
1152 | 1179 | ||
1153 | /* Finally, set the new power state. */ | 1180 | /* Finally, set the new power state. */ |
1154 | pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control); | 1181 | pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control); |
1182 | udelay(100); /* Delay after power state change */ | ||
1155 | 1183 | ||
1156 | tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN); | 1184 | tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN); |
1157 | 1185 | ||
@@ -2681,8 +2709,8 @@ static int tg3_vlan_rx(struct tg3 *tp, struct sk_buff *skb, u16 vlan_tag) | |||
2681 | static int tg3_rx(struct tg3 *tp, int budget) | 2709 | static int tg3_rx(struct tg3 *tp, int budget) |
2682 | { | 2710 | { |
2683 | u32 work_mask; | 2711 | u32 work_mask; |
2684 | u32 rx_rcb_ptr = tp->rx_rcb_ptr; | 2712 | u32 sw_idx = tp->rx_rcb_ptr; |
2685 | u16 hw_idx, sw_idx; | 2713 | u16 hw_idx; |
2686 | int received; | 2714 | int received; |
2687 | 2715 | ||
2688 | hw_idx = tp->hw_status->idx[0].rx_producer; | 2716 | hw_idx = tp->hw_status->idx[0].rx_producer; |
@@ -2691,7 +2719,6 @@ static int tg3_rx(struct tg3 *tp, int budget) | |||
2691 | * the opaque cookie. | 2719 | * the opaque cookie. |
2692 | */ | 2720 | */ |
2693 | rmb(); | 2721 | rmb(); |
2694 | sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp); | ||
2695 | work_mask = 0; | 2722 | work_mask = 0; |
2696 | received = 0; | 2723 | received = 0; |
2697 | while (sw_idx != hw_idx && budget > 0) { | 2724 | while (sw_idx != hw_idx && budget > 0) { |
@@ -2796,14 +2823,19 @@ static int tg3_rx(struct tg3 *tp, int budget) | |||
2796 | next_pkt: | 2823 | next_pkt: |
2797 | (*post_ptr)++; | 2824 | (*post_ptr)++; |
2798 | next_pkt_nopost: | 2825 | next_pkt_nopost: |
2799 | rx_rcb_ptr++; | 2826 | sw_idx++; |
2800 | sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp); | 2827 | sw_idx %= TG3_RX_RCB_RING_SIZE(tp); |
2828 | |||
2829 | /* Refresh hw_idx to see if there is new work */ | ||
2830 | if (sw_idx == hw_idx) { | ||
2831 | hw_idx = tp->hw_status->idx[0].rx_producer; | ||
2832 | rmb(); | ||
2833 | } | ||
2801 | } | 2834 | } |
2802 | 2835 | ||
2803 | /* ACK the status ring. */ | 2836 | /* ACK the status ring. */ |
2804 | tp->rx_rcb_ptr = rx_rcb_ptr; | 2837 | tp->rx_rcb_ptr = sw_idx; |
2805 | tw32_rx_mbox(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW, | 2838 | tw32_rx_mbox(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW, sw_idx); |
2806 | (rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp))); | ||
2807 | 2839 | ||
2808 | /* Refill RX ring(s). */ | 2840 | /* Refill RX ring(s). */ |
2809 | if (work_mask & RXD_OPAQUE_RING_STD) { | 2841 | if (work_mask & RXD_OPAQUE_RING_STD) { |
@@ -2882,24 +2914,41 @@ static int tg3_poll(struct net_device *netdev, int *budget) | |||
2882 | return (done ? 0 : 1); | 2914 | return (done ? 0 : 1); |
2883 | } | 2915 | } |
2884 | 2916 | ||
2885 | static inline unsigned int tg3_has_work(struct net_device *dev, struct tg3 *tp) | 2917 | /* MSI ISR - No need to check for interrupt sharing and no need to |
2918 | * flush status block and interrupt mailbox. PCI ordering rules | ||
2919 | * guarantee that MSI will arrive after the status block. | ||
2920 | */ | ||
2921 | static irqreturn_t tg3_msi(int irq, void *dev_id, struct pt_regs *regs) | ||
2886 | { | 2922 | { |
2923 | struct net_device *dev = dev_id; | ||
2924 | struct tg3 *tp = netdev_priv(dev); | ||
2887 | struct tg3_hw_status *sblk = tp->hw_status; | 2925 | struct tg3_hw_status *sblk = tp->hw_status; |
2888 | unsigned int work_exists = 0; | 2926 | unsigned long flags; |
2889 | 2927 | ||
2890 | /* check for phy events */ | 2928 | spin_lock_irqsave(&tp->lock, flags); |
2891 | if (!(tp->tg3_flags & | 2929 | |
2892 | (TG3_FLAG_USE_LINKCHG_REG | | 2930 | /* |
2893 | TG3_FLAG_POLL_SERDES))) { | 2931 | * writing any value to intr-mbox-0 clears PCI INTA# and |
2894 | if (sblk->status & SD_STATUS_LINK_CHG) | 2932 | * chip-internal interrupt pending events. |
2895 | work_exists = 1; | 2933 | * writing non-zero to intr-mbox-0 additional tells the |
2934 | * NIC to stop sending us irqs, engaging "in-intr-handler" | ||
2935 | * event coalescing. | ||
2936 | */ | ||
2937 | tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001); | ||
2938 | sblk->status &= ~SD_STATUS_UPDATED; | ||
2939 | |||
2940 | if (likely(tg3_has_work(tp))) | ||
2941 | netif_rx_schedule(dev); /* schedule NAPI poll */ | ||
2942 | else { | ||
2943 | /* no work, re-enable interrupts | ||
2944 | */ | ||
2945 | tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, | ||
2946 | 0x00000000); | ||
2896 | } | 2947 | } |
2897 | /* check for RX/TX work to do */ | ||
2898 | if (sblk->idx[0].tx_consumer != tp->tx_cons || | ||
2899 | sblk->idx[0].rx_producer != tp->rx_rcb_ptr) | ||
2900 | work_exists = 1; | ||
2901 | 2948 | ||
2902 | return work_exists; | 2949 | spin_unlock_irqrestore(&tp->lock, flags); |
2950 | |||
2951 | return IRQ_RETVAL(1); | ||
2903 | } | 2952 | } |
2904 | 2953 | ||
2905 | static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 2954 | static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs) |
@@ -2935,7 +2984,7 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
2935 | tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); | 2984 | tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); |
2936 | sblk->status &= ~SD_STATUS_UPDATED; | 2985 | sblk->status &= ~SD_STATUS_UPDATED; |
2937 | 2986 | ||
2938 | if (likely(tg3_has_work(dev, tp))) | 2987 | if (likely(tg3_has_work(tp))) |
2939 | netif_rx_schedule(dev); /* schedule NAPI poll */ | 2988 | netif_rx_schedule(dev); /* schedule NAPI poll */ |
2940 | else { | 2989 | else { |
2941 | /* no work, shared interrupt perhaps? re-enable | 2990 | /* no work, shared interrupt perhaps? re-enable |
@@ -2954,13 +3003,31 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
2954 | return IRQ_RETVAL(handled); | 3003 | return IRQ_RETVAL(handled); |
2955 | } | 3004 | } |
2956 | 3005 | ||
3006 | /* ISR for interrupt test */ | ||
3007 | static irqreturn_t tg3_test_isr(int irq, void *dev_id, | ||
3008 | struct pt_regs *regs) | ||
3009 | { | ||
3010 | struct net_device *dev = dev_id; | ||
3011 | struct tg3 *tp = netdev_priv(dev); | ||
3012 | struct tg3_hw_status *sblk = tp->hw_status; | ||
3013 | |||
3014 | if (sblk->status & SD_STATUS_UPDATED) { | ||
3015 | tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, | ||
3016 | 0x00000001); | ||
3017 | return IRQ_RETVAL(1); | ||
3018 | } | ||
3019 | return IRQ_RETVAL(0); | ||
3020 | } | ||
3021 | |||
2957 | static int tg3_init_hw(struct tg3 *); | 3022 | static int tg3_init_hw(struct tg3 *); |
2958 | static int tg3_halt(struct tg3 *); | 3023 | static int tg3_halt(struct tg3 *, int); |
2959 | 3024 | ||
2960 | #ifdef CONFIG_NET_POLL_CONTROLLER | 3025 | #ifdef CONFIG_NET_POLL_CONTROLLER |
2961 | static void tg3_poll_controller(struct net_device *dev) | 3026 | static void tg3_poll_controller(struct net_device *dev) |
2962 | { | 3027 | { |
2963 | tg3_interrupt(dev->irq, dev, NULL); | 3028 | struct tg3 *tp = netdev_priv(dev); |
3029 | |||
3030 | tg3_interrupt(tp->pdev->irq, dev, NULL); | ||
2964 | } | 3031 | } |
2965 | #endif | 3032 | #endif |
2966 | 3033 | ||
@@ -2977,7 +3044,7 @@ static void tg3_reset_task(void *_data) | |||
2977 | restart_timer = tp->tg3_flags2 & TG3_FLG2_RESTART_TIMER; | 3044 | restart_timer = tp->tg3_flags2 & TG3_FLG2_RESTART_TIMER; |
2978 | tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER; | 3045 | tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER; |
2979 | 3046 | ||
2980 | tg3_halt(tp); | 3047 | tg3_halt(tp, 0); |
2981 | tg3_init_hw(tp); | 3048 | tg3_init_hw(tp); |
2982 | 3049 | ||
2983 | tg3_netif_start(tp); | 3050 | tg3_netif_start(tp); |
@@ -3323,7 +3390,7 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu) | |||
3323 | spin_lock_irq(&tp->lock); | 3390 | spin_lock_irq(&tp->lock); |
3324 | spin_lock(&tp->tx_lock); | 3391 | spin_lock(&tp->tx_lock); |
3325 | 3392 | ||
3326 | tg3_halt(tp); | 3393 | tg3_halt(tp, 1); |
3327 | 3394 | ||
3328 | tg3_set_mtu(dev, tp, new_mtu); | 3395 | tg3_set_mtu(dev, tp, new_mtu); |
3329 | 3396 | ||
@@ -3590,7 +3657,7 @@ err_out: | |||
3590 | /* To stop a block, clear the enable bit and poll till it | 3657 | /* To stop a block, clear the enable bit and poll till it |
3591 | * clears. tp->lock is held. | 3658 | * clears. tp->lock is held. |
3592 | */ | 3659 | */ |
3593 | static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit) | 3660 | static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit, int silent) |
3594 | { | 3661 | { |
3595 | unsigned int i; | 3662 | unsigned int i; |
3596 | u32 val; | 3663 | u32 val; |
@@ -3623,7 +3690,7 @@ static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit) | |||
3623 | break; | 3690 | break; |
3624 | } | 3691 | } |
3625 | 3692 | ||
3626 | if (i == MAX_WAIT_CNT) { | 3693 | if (i == MAX_WAIT_CNT && !silent) { |
3627 | printk(KERN_ERR PFX "tg3_stop_block timed out, " | 3694 | printk(KERN_ERR PFX "tg3_stop_block timed out, " |
3628 | "ofs=%lx enable_bit=%x\n", | 3695 | "ofs=%lx enable_bit=%x\n", |
3629 | ofs, enable_bit); | 3696 | ofs, enable_bit); |
@@ -3634,7 +3701,7 @@ static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit) | |||
3634 | } | 3701 | } |
3635 | 3702 | ||
3636 | /* tp->lock is held. */ | 3703 | /* tp->lock is held. */ |
3637 | static int tg3_abort_hw(struct tg3 *tp) | 3704 | static int tg3_abort_hw(struct tg3 *tp, int silent) |
3638 | { | 3705 | { |
3639 | int i, err; | 3706 | int i, err; |
3640 | 3707 | ||
@@ -3644,22 +3711,20 @@ static int tg3_abort_hw(struct tg3 *tp) | |||
3644 | tw32_f(MAC_RX_MODE, tp->rx_mode); | 3711 | tw32_f(MAC_RX_MODE, tp->rx_mode); |
3645 | udelay(10); | 3712 | udelay(10); |
3646 | 3713 | ||
3647 | err = tg3_stop_block(tp, RCVBDI_MODE, RCVBDI_MODE_ENABLE); | 3714 | err = tg3_stop_block(tp, RCVBDI_MODE, RCVBDI_MODE_ENABLE, silent); |
3648 | err |= tg3_stop_block(tp, RCVLPC_MODE, RCVLPC_MODE_ENABLE); | 3715 | err |= tg3_stop_block(tp, RCVLPC_MODE, RCVLPC_MODE_ENABLE, silent); |
3649 | err |= tg3_stop_block(tp, RCVLSC_MODE, RCVLSC_MODE_ENABLE); | 3716 | err |= tg3_stop_block(tp, RCVLSC_MODE, RCVLSC_MODE_ENABLE, silent); |
3650 | err |= tg3_stop_block(tp, RCVDBDI_MODE, RCVDBDI_MODE_ENABLE); | 3717 | err |= tg3_stop_block(tp, RCVDBDI_MODE, RCVDBDI_MODE_ENABLE, silent); |
3651 | err |= tg3_stop_block(tp, RCVDCC_MODE, RCVDCC_MODE_ENABLE); | 3718 | err |= tg3_stop_block(tp, RCVDCC_MODE, RCVDCC_MODE_ENABLE, silent); |
3652 | err |= tg3_stop_block(tp, RCVCC_MODE, RCVCC_MODE_ENABLE); | 3719 | err |= tg3_stop_block(tp, RCVCC_MODE, RCVCC_MODE_ENABLE, silent); |
3653 | 3720 | ||
3654 | err |= tg3_stop_block(tp, SNDBDS_MODE, SNDBDS_MODE_ENABLE); | 3721 | err |= tg3_stop_block(tp, SNDBDS_MODE, SNDBDS_MODE_ENABLE, silent); |
3655 | err |= tg3_stop_block(tp, SNDBDI_MODE, SNDBDI_MODE_ENABLE); | 3722 | err |= tg3_stop_block(tp, SNDBDI_MODE, SNDBDI_MODE_ENABLE, silent); |
3656 | err |= tg3_stop_block(tp, SNDDATAI_MODE, SNDDATAI_MODE_ENABLE); | 3723 | err |= tg3_stop_block(tp, SNDDATAI_MODE, SNDDATAI_MODE_ENABLE, silent); |
3657 | err |= tg3_stop_block(tp, RDMAC_MODE, RDMAC_MODE_ENABLE); | 3724 | err |= tg3_stop_block(tp, RDMAC_MODE, RDMAC_MODE_ENABLE, silent); |
3658 | err |= tg3_stop_block(tp, SNDDATAC_MODE, SNDDATAC_MODE_ENABLE); | 3725 | err |= tg3_stop_block(tp, SNDDATAC_MODE, SNDDATAC_MODE_ENABLE, silent); |
3659 | err |= tg3_stop_block(tp, DMAC_MODE, DMAC_MODE_ENABLE); | 3726 | err |= tg3_stop_block(tp, DMAC_MODE, DMAC_MODE_ENABLE, silent); |
3660 | err |= tg3_stop_block(tp, SNDBDC_MODE, SNDBDC_MODE_ENABLE); | 3727 | err |= tg3_stop_block(tp, SNDBDC_MODE, SNDBDC_MODE_ENABLE, silent); |
3661 | if (err) | ||
3662 | goto out; | ||
3663 | 3728 | ||
3664 | tp->mac_mode &= ~MAC_MODE_TDE_ENABLE; | 3729 | tp->mac_mode &= ~MAC_MODE_TDE_ENABLE; |
3665 | tw32_f(MAC_MODE, tp->mac_mode); | 3730 | tw32_f(MAC_MODE, tp->mac_mode); |
@@ -3677,27 +3742,24 @@ static int tg3_abort_hw(struct tg3 *tp) | |||
3677 | printk(KERN_ERR PFX "tg3_abort_hw timed out for %s, " | 3742 | printk(KERN_ERR PFX "tg3_abort_hw timed out for %s, " |
3678 | "TX_MODE_ENABLE will not clear MAC_TX_MODE=%08x\n", | 3743 | "TX_MODE_ENABLE will not clear MAC_TX_MODE=%08x\n", |
3679 | tp->dev->name, tr32(MAC_TX_MODE)); | 3744 | tp->dev->name, tr32(MAC_TX_MODE)); |
3680 | return -ENODEV; | 3745 | err |= -ENODEV; |
3681 | } | 3746 | } |
3682 | 3747 | ||
3683 | err = tg3_stop_block(tp, HOSTCC_MODE, HOSTCC_MODE_ENABLE); | 3748 | err |= tg3_stop_block(tp, HOSTCC_MODE, HOSTCC_MODE_ENABLE, silent); |
3684 | err |= tg3_stop_block(tp, WDMAC_MODE, WDMAC_MODE_ENABLE); | 3749 | err |= tg3_stop_block(tp, WDMAC_MODE, WDMAC_MODE_ENABLE, silent); |
3685 | err |= tg3_stop_block(tp, MBFREE_MODE, MBFREE_MODE_ENABLE); | 3750 | err |= tg3_stop_block(tp, MBFREE_MODE, MBFREE_MODE_ENABLE, silent); |
3686 | 3751 | ||
3687 | tw32(FTQ_RESET, 0xffffffff); | 3752 | tw32(FTQ_RESET, 0xffffffff); |
3688 | tw32(FTQ_RESET, 0x00000000); | 3753 | tw32(FTQ_RESET, 0x00000000); |
3689 | 3754 | ||
3690 | err |= tg3_stop_block(tp, BUFMGR_MODE, BUFMGR_MODE_ENABLE); | 3755 | err |= tg3_stop_block(tp, BUFMGR_MODE, BUFMGR_MODE_ENABLE, silent); |
3691 | err |= tg3_stop_block(tp, MEMARB_MODE, MEMARB_MODE_ENABLE); | 3756 | err |= tg3_stop_block(tp, MEMARB_MODE, MEMARB_MODE_ENABLE, silent); |
3692 | if (err) | ||
3693 | goto out; | ||
3694 | 3757 | ||
3695 | if (tp->hw_status) | 3758 | if (tp->hw_status) |
3696 | memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE); | 3759 | memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE); |
3697 | if (tp->hw_stats) | 3760 | if (tp->hw_stats) |
3698 | memset(tp->hw_stats, 0, sizeof(struct tg3_hw_stats)); | 3761 | memset(tp->hw_stats, 0, sizeof(struct tg3_hw_stats)); |
3699 | 3762 | ||
3700 | out: | ||
3701 | return err; | 3763 | return err; |
3702 | } | 3764 | } |
3703 | 3765 | ||
@@ -3727,6 +3789,28 @@ static void tg3_nvram_unlock(struct tg3 *tp) | |||
3727 | } | 3789 | } |
3728 | 3790 | ||
3729 | /* tp->lock is held. */ | 3791 | /* tp->lock is held. */ |
3792 | static void tg3_enable_nvram_access(struct tg3 *tp) | ||
3793 | { | ||
3794 | if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && | ||
3795 | !(tp->tg3_flags2 & TG3_FLG2_PROTECTED_NVRAM)) { | ||
3796 | u32 nvaccess = tr32(NVRAM_ACCESS); | ||
3797 | |||
3798 | tw32(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE); | ||
3799 | } | ||
3800 | } | ||
3801 | |||
3802 | /* tp->lock is held. */ | ||
3803 | static void tg3_disable_nvram_access(struct tg3 *tp) | ||
3804 | { | ||
3805 | if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && | ||
3806 | !(tp->tg3_flags2 & TG3_FLG2_PROTECTED_NVRAM)) { | ||
3807 | u32 nvaccess = tr32(NVRAM_ACCESS); | ||
3808 | |||
3809 | tw32(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE); | ||
3810 | } | ||
3811 | } | ||
3812 | |||
3813 | /* tp->lock is held. */ | ||
3730 | static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind) | 3814 | static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind) |
3731 | { | 3815 | { |
3732 | if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X)) | 3816 | if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X)) |
@@ -3967,7 +4051,7 @@ static int tg3_chip_reset(struct tg3 *tp) | |||
3967 | tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg); | 4051 | tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg); |
3968 | if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { | 4052 | if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { |
3969 | tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; | 4053 | tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; |
3970 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) | 4054 | if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) |
3971 | tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE; | 4055 | tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE; |
3972 | } | 4056 | } |
3973 | } | 4057 | } |
@@ -3997,7 +4081,7 @@ static void tg3_stop_fw(struct tg3 *tp) | |||
3997 | } | 4081 | } |
3998 | 4082 | ||
3999 | /* tp->lock is held. */ | 4083 | /* tp->lock is held. */ |
4000 | static int tg3_halt(struct tg3 *tp) | 4084 | static int tg3_halt(struct tg3 *tp, int silent) |
4001 | { | 4085 | { |
4002 | int err; | 4086 | int err; |
4003 | 4087 | ||
@@ -4005,7 +4089,7 @@ static int tg3_halt(struct tg3 *tp) | |||
4005 | 4089 | ||
4006 | tg3_write_sig_pre_reset(tp, RESET_KIND_SHUTDOWN); | 4090 | tg3_write_sig_pre_reset(tp, RESET_KIND_SHUTDOWN); |
4007 | 4091 | ||
4008 | tg3_abort_hw(tp); | 4092 | tg3_abort_hw(tp, silent); |
4009 | err = tg3_chip_reset(tp); | 4093 | err = tg3_chip_reset(tp); |
4010 | 4094 | ||
4011 | tg3_write_sig_legacy(tp, RESET_KIND_SHUTDOWN); | 4095 | tg3_write_sig_legacy(tp, RESET_KIND_SHUTDOWN); |
@@ -4974,9 +5058,7 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
4974 | tg3_write_sig_pre_reset(tp, RESET_KIND_INIT); | 5058 | tg3_write_sig_pre_reset(tp, RESET_KIND_INIT); |
4975 | 5059 | ||
4976 | if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) { | 5060 | if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) { |
4977 | err = tg3_abort_hw(tp); | 5061 | tg3_abort_hw(tp, 1); |
4978 | if (err) | ||
4979 | return err; | ||
4980 | } | 5062 | } |
4981 | 5063 | ||
4982 | err = tg3_chip_reset(tp); | 5064 | err = tg3_chip_reset(tp); |
@@ -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 | ||
5815 | static 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 | SA_SAMPLE_RANDOM, 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 | SA_SAMPLE_RANDOM, dev->name, dev); | ||
5849 | else | ||
5850 | err = request_irq(tp->pdev->irq, tg3_interrupt, | ||
5851 | SA_SHIRQ | SA_SAMPLE_RANDOM, 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 | */ | ||
5865 | static 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 | SA_SAMPLE_RANDOM, 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, 1); | ||
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 | |||
5709 | static int tg3_open(struct net_device *dev) | 5927 | static 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 | SA_SAMPLE_RANDOM, dev->name, dev); | ||
5962 | else | ||
5963 | err = request_irq(tp->pdev->irq, tg3_interrupt, | ||
5964 | SA_SHIRQ | SA_SAMPLE_RANDOM, 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 | } |
@@ -5740,7 +5977,7 @@ static int tg3_open(struct net_device *dev) | |||
5740 | 5977 | ||
5741 | err = tg3_init_hw(tp); | 5978 | err = tg3_init_hw(tp); |
5742 | if (err) { | 5979 | if (err) { |
5743 | tg3_halt(tp); | 5980 | tg3_halt(tp, 1); |
5744 | tg3_free_rings(tp); | 5981 | tg3_free_rings(tp); |
5745 | } else { | 5982 | } else { |
5746 | tp->timer_offset = HZ / 10; | 5983 | tp->timer_offset = HZ / 10; |
@@ -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, 1); | ||
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); |
@@ -6025,7 +6286,7 @@ static int tg3_close(struct net_device *dev) | |||
6025 | 6286 | ||
6026 | tg3_disable_ints(tp); | 6287 | tg3_disable_ints(tp); |
6027 | 6288 | ||
6028 | tg3_halt(tp); | 6289 | tg3_halt(tp, 1); |
6029 | tg3_free_rings(tp); | 6290 | tg3_free_rings(tp); |
6030 | tp->tg3_flags &= | 6291 | tp->tg3_flags &= |
6031 | ~(TG3_FLAG_INIT_COMPLETE | | 6292 | ~(TG3_FLAG_INIT_COMPLETE | |
@@ -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; |
@@ -6739,7 +7006,7 @@ static int tg3_set_ringparam(struct net_device *dev, struct ethtool_ringparam *e | |||
6739 | tp->tx_pending = ering->tx_pending; | 7006 | tp->tx_pending = ering->tx_pending; |
6740 | 7007 | ||
6741 | if (netif_running(dev)) { | 7008 | if (netif_running(dev)) { |
6742 | tg3_halt(tp); | 7009 | tg3_halt(tp, 1); |
6743 | tg3_init_hw(tp); | 7010 | tg3_init_hw(tp); |
6744 | tg3_netif_start(tp); | 7011 | tg3_netif_start(tp); |
6745 | } | 7012 | } |
@@ -6782,7 +7049,7 @@ static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam | |||
6782 | tp->tg3_flags &= ~TG3_FLAG_TX_PAUSE; | 7049 | tp->tg3_flags &= ~TG3_FLAG_TX_PAUSE; |
6783 | 7050 | ||
6784 | if (netif_running(dev)) { | 7051 | if (netif_running(dev)) { |
6785 | tg3_halt(tp); | 7052 | tg3_halt(tp, 1); |
6786 | tg3_init_hw(tp); | 7053 | tg3_init_hw(tp); |
6787 | tg3_netif_start(tp); | 7054 | tg3_netif_start(tp); |
6788 | } | 7055 | } |
@@ -7067,6 +7334,67 @@ static void __devinit tg3_get_nvram_info(struct tg3 *tp) | |||
7067 | } | 7334 | } |
7068 | } | 7335 | } |
7069 | 7336 | ||
7337 | static 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. */ |
7071 | static void __devinit tg3_nvram_init(struct tg3 *tp) | 7399 | static 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 | ||
7540 | static 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 | */ | ||
7850 | static 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 | |||
7968 | static 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"; |
@@ -8878,7 +9232,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
8878 | (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) { | 9232 | (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) { |
8879 | pci_save_state(tp->pdev); | 9233 | pci_save_state(tp->pdev); |
8880 | tw32(MEMARB_MODE, MEMARB_MODE_ENABLE); | 9234 | tw32(MEMARB_MODE, MEMARB_MODE_ENABLE); |
8881 | tg3_halt(tp); | 9235 | tg3_halt(tp, 1); |
8882 | } | 9236 | } |
8883 | 9237 | ||
8884 | err = tg3_test_dma(tp); | 9238 | err = tg3_test_dma(tp); |
@@ -9001,7 +9355,7 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state) | |||
9001 | 9355 | ||
9002 | spin_lock_irq(&tp->lock); | 9356 | spin_lock_irq(&tp->lock); |
9003 | spin_lock(&tp->tx_lock); | 9357 | spin_lock(&tp->tx_lock); |
9004 | tg3_halt(tp); | 9358 | tg3_halt(tp, 1); |
9005 | spin_unlock(&tp->tx_lock); | 9359 | spin_unlock(&tp->tx_lock); |
9006 | spin_unlock_irq(&tp->lock); | 9360 | spin_unlock_irq(&tp->lock); |
9007 | 9361 | ||