aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-12-19 19:46:14 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-12-19 19:46:14 -0500
commit931b11be325e0e866b64bac7cab64d51c7759371 (patch)
tree1160085424552859138cf6b92acfbc66d86e64b8
parent546ac8a63186a06e5d21778eefa4695232aee5b8 (diff)
parent38690194bc897dd60a61a71b15e861e13b5d8bdd (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/tg3-2.6
-rw-r--r--drivers/net/tg3.c186
1 files changed, 101 insertions, 85 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index a23ed28a72b8..cefb0c08a68d 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -68,8 +68,8 @@
68 68
69#define DRV_MODULE_NAME "tg3" 69#define DRV_MODULE_NAME "tg3"
70#define PFX DRV_MODULE_NAME ": " 70#define PFX DRV_MODULE_NAME ": "
71#define DRV_MODULE_VERSION "3.45" 71#define DRV_MODULE_VERSION "3.46"
72#define DRV_MODULE_RELDATE "Dec 13, 2005" 72#define DRV_MODULE_RELDATE "Dec 19, 2005"
73 73
74#define TG3_DEF_MAC_MODE 0 74#define TG3_DEF_MAC_MODE 0
75#define TG3_DEF_RX_MODE 0 75#define TG3_DEF_RX_MODE 0
@@ -341,6 +341,16 @@ static struct {
341 { "interrupt test (offline)" }, 341 { "interrupt test (offline)" },
342}; 342};
343 343
344static void tg3_write32(struct tg3 *tp, u32 off, u32 val)
345{
346 writel(val, tp->regs + off);
347}
348
349static u32 tg3_read32(struct tg3 *tp, u32 off)
350{
351 return (readl(tp->regs + off));
352}
353
344static void tg3_write_indirect_reg32(struct tg3 *tp, u32 off, u32 val) 354static void tg3_write_indirect_reg32(struct tg3 *tp, u32 off, u32 val)
345{ 355{
346 unsigned long flags; 356 unsigned long flags;
@@ -411,13 +421,29 @@ static u32 tg3_read_indirect_mbox(struct tg3 *tp, u32 off)
411 return val; 421 return val;
412} 422}
413 423
414static void _tw32_flush(struct tg3 *tp, u32 off, u32 val) 424/* usec_wait specifies the wait time in usec when writing to certain registers
425 * where it is unsafe to read back the register without some delay.
426 * GRC_LOCAL_CTRL is one example if the GPIOs are toggled to switch power.
427 * TG3PCI_CLOCK_CTRL is another example if the clock frequencies are changed.
428 */
429static void _tw32_flush(struct tg3 *tp, u32 off, u32 val, u32 usec_wait)
415{ 430{
416 tp->write32(tp, off, val); 431 if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) ||
417 if (!(tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) && 432 (tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND))
418 !(tp->tg3_flags & TG3_FLAG_5701_REG_WRITE_BUG) && 433 /* Non-posted methods */
419 !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND)) 434 tp->write32(tp, off, val);
420 tp->read32(tp, off); /* flush */ 435 else {
436 /* Posted method */
437 tg3_write32(tp, off, val);
438 if (usec_wait)
439 udelay(usec_wait);
440 tp->read32(tp, off);
441 }
442 /* Wait again after the read for the posted method to guarantee that
443 * the wait time is met.
444 */
445 if (usec_wait)
446 udelay(usec_wait);
421} 447}
422 448
423static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val) 449static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val)
@@ -438,16 +464,6 @@ static void tg3_write32_tx_mbox(struct tg3 *tp, u32 off, u32 val)
438 readl(mbox); 464 readl(mbox);
439} 465}
440 466
441static void tg3_write32(struct tg3 *tp, u32 off, u32 val)
442{
443 writel(val, tp->regs + off);
444}
445
446static u32 tg3_read32(struct tg3 *tp, u32 off)
447{
448 return (readl(tp->regs + off));
449}
450
451#define tw32_mailbox(reg, val) tp->write32_mbox(tp, reg, val) 467#define tw32_mailbox(reg, val) tp->write32_mbox(tp, reg, val)
452#define tw32_mailbox_f(reg, val) tw32_mailbox_flush(tp, (reg), (val)) 468#define tw32_mailbox_f(reg, val) tw32_mailbox_flush(tp, (reg), (val))
453#define tw32_rx_mbox(reg, val) tp->write32_rx_mbox(tp, reg, val) 469#define tw32_rx_mbox(reg, val) tp->write32_rx_mbox(tp, reg, val)
@@ -455,7 +471,8 @@ static u32 tg3_read32(struct tg3 *tp, u32 off)
455#define tr32_mailbox(reg) tp->read32_mbox(tp, reg) 471#define tr32_mailbox(reg) tp->read32_mbox(tp, reg)
456 472
457#define tw32(reg,val) tp->write32(tp, reg, val) 473#define tw32(reg,val) tp->write32(tp, reg, val)
458#define tw32_f(reg,val) _tw32_flush(tp,(reg),(val)) 474#define tw32_f(reg,val) _tw32_flush(tp,(reg),(val), 0)
475#define tw32_wait_f(reg,val,us) _tw32_flush(tp,(reg),(val), (us))
459#define tr32(reg) tp->read32(tp, reg) 476#define tr32(reg) tp->read32(tp, reg)
460 477
461static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val) 478static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
@@ -595,21 +612,19 @@ static void tg3_switch_clocks(struct tg3 *tp)
595 612
596 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { 613 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
597 if (orig_clock_ctrl & CLOCK_CTRL_625_CORE) { 614 if (orig_clock_ctrl & CLOCK_CTRL_625_CORE) {
598 tw32_f(TG3PCI_CLOCK_CTRL, 615 tw32_wait_f(TG3PCI_CLOCK_CTRL,
599 clock_ctrl | CLOCK_CTRL_625_CORE); 616 clock_ctrl | CLOCK_CTRL_625_CORE, 40);
600 udelay(40);
601 } 617 }
602 } else if ((orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) { 618 } else if ((orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) {
603 tw32_f(TG3PCI_CLOCK_CTRL, 619 tw32_wait_f(TG3PCI_CLOCK_CTRL,
604 clock_ctrl | 620 clock_ctrl |
605 (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK)); 621 (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK),
606 udelay(40); 622 40);
607 tw32_f(TG3PCI_CLOCK_CTRL, 623 tw32_wait_f(TG3PCI_CLOCK_CTRL,
608 clock_ctrl | (CLOCK_CTRL_ALTCLK)); 624 clock_ctrl | (CLOCK_CTRL_ALTCLK),
609 udelay(40); 625 40);
610 } 626 }
611 tw32_f(TG3PCI_CLOCK_CTRL, clock_ctrl); 627 tw32_wait_f(TG3PCI_CLOCK_CTRL, clock_ctrl, 40);
612 udelay(40);
613} 628}
614 629
615#define PHY_BUSY_LOOPS 5000 630#define PHY_BUSY_LOOPS 5000
@@ -1017,39 +1032,50 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1017 if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0) 1032 if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0)
1018 return; 1033 return;
1019 1034
1020 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { 1035 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
1021 tp_peer = pci_get_drvdata(tp->pdev_peer); 1036 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714)) {
1022 if (!tp_peer) 1037 struct net_device *dev_peer;
1038
1039 dev_peer = pci_get_drvdata(tp->pdev_peer);
1040 if (!dev_peer)
1023 BUG(); 1041 BUG();
1042 tp_peer = netdev_priv(dev_peer);
1024 } 1043 }
1025 1044
1026
1027 if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 || 1045 if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 ||
1028 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0 || 1046 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0 ||
1029 (tp_peer->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 || 1047 (tp_peer->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 ||
1030 (tp_peer->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0) { 1048 (tp_peer->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0) {
1031 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 1049 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
1032 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) { 1050 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
1033 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1051 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1034 (GRC_LCLCTRL_GPIO_OE0 | 1052 (GRC_LCLCTRL_GPIO_OE0 |
1035 GRC_LCLCTRL_GPIO_OE1 | 1053 GRC_LCLCTRL_GPIO_OE1 |
1036 GRC_LCLCTRL_GPIO_OE2 | 1054 GRC_LCLCTRL_GPIO_OE2 |
1037 GRC_LCLCTRL_GPIO_OUTPUT0 | 1055 GRC_LCLCTRL_GPIO_OUTPUT0 |
1038 GRC_LCLCTRL_GPIO_OUTPUT1)); 1056 GRC_LCLCTRL_GPIO_OUTPUT1),
1039 udelay(100); 1057 100);
1040 } else { 1058 } else {
1041 u32 no_gpio2; 1059 u32 no_gpio2;
1042 u32 grc_local_ctrl; 1060 u32 grc_local_ctrl = 0;
1043 1061
1044 if (tp_peer != tp && 1062 if (tp_peer != tp &&
1045 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0) 1063 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
1046 return; 1064 return;
1047 1065
1066 /* Workaround to prevent overdrawing Amps. */
1067 if (GET_ASIC_REV(tp->pci_chip_rev_id) ==
1068 ASIC_REV_5714) {
1069 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3;
1070 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1071 grc_local_ctrl, 100);
1072 }
1073
1048 /* On 5753 and variants, GPIO2 cannot be used. */ 1074 /* On 5753 and variants, GPIO2 cannot be used. */
1049 no_gpio2 = tp->nic_sram_data_cfg & 1075 no_gpio2 = tp->nic_sram_data_cfg &
1050 NIC_SRAM_DATA_CFG_NO_GPIO2; 1076 NIC_SRAM_DATA_CFG_NO_GPIO2;
1051 1077
1052 grc_local_ctrl = GRC_LCLCTRL_GPIO_OE0 | 1078 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE0 |
1053 GRC_LCLCTRL_GPIO_OE1 | 1079 GRC_LCLCTRL_GPIO_OE1 |
1054 GRC_LCLCTRL_GPIO_OE2 | 1080 GRC_LCLCTRL_GPIO_OE2 |
1055 GRC_LCLCTRL_GPIO_OUTPUT1 | 1081 GRC_LCLCTRL_GPIO_OUTPUT1 |
@@ -1058,21 +1084,18 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1058 grc_local_ctrl &= ~(GRC_LCLCTRL_GPIO_OE2 | 1084 grc_local_ctrl &= ~(GRC_LCLCTRL_GPIO_OE2 |
1059 GRC_LCLCTRL_GPIO_OUTPUT2); 1085 GRC_LCLCTRL_GPIO_OUTPUT2);
1060 } 1086 }
1061 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1087 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1062 grc_local_ctrl); 1088 grc_local_ctrl, 100);
1063 udelay(100);
1064 1089
1065 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OUTPUT0; 1090 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OUTPUT0;
1066 1091
1067 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1092 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1068 grc_local_ctrl); 1093 grc_local_ctrl, 100);
1069 udelay(100);
1070 1094
1071 if (!no_gpio2) { 1095 if (!no_gpio2) {
1072 grc_local_ctrl &= ~GRC_LCLCTRL_GPIO_OUTPUT2; 1096 grc_local_ctrl &= ~GRC_LCLCTRL_GPIO_OUTPUT2;
1073 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1097 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1074 grc_local_ctrl); 1098 grc_local_ctrl, 100);
1075 udelay(100);
1076 } 1099 }
1077 } 1100 }
1078 } else { 1101 } else {
@@ -1082,19 +1105,16 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1082 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0) 1105 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
1083 return; 1106 return;
1084 1107
1085 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1108 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1086 (GRC_LCLCTRL_GPIO_OE1 | 1109 (GRC_LCLCTRL_GPIO_OE1 |
1087 GRC_LCLCTRL_GPIO_OUTPUT1)); 1110 GRC_LCLCTRL_GPIO_OUTPUT1), 100);
1088 udelay(100);
1089 1111
1090 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1112 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1091 (GRC_LCLCTRL_GPIO_OE1)); 1113 GRC_LCLCTRL_GPIO_OE1, 100);
1092 udelay(100);
1093 1114
1094 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1115 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1095 (GRC_LCLCTRL_GPIO_OE1 | 1116 (GRC_LCLCTRL_GPIO_OE1 |
1096 GRC_LCLCTRL_GPIO_OUTPUT1)); 1117 GRC_LCLCTRL_GPIO_OUTPUT1), 100);
1097 udelay(100);
1098 } 1118 }
1099 } 1119 }
1100} 1120}
@@ -1137,10 +1157,8 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1137 udelay(100); /* Delay after power state change */ 1157 udelay(100); /* Delay after power state change */
1138 1158
1139 /* Switch out of Vaux if it is not a LOM */ 1159 /* Switch out of Vaux if it is not a LOM */
1140 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)) { 1160 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT))
1141 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 1161 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, 100);
1142 udelay(100);
1143 }
1144 1162
1145 return 0; 1163 return 0;
1146 1164
@@ -1239,10 +1257,8 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1239 base_val |= (CLOCK_CTRL_RXCLK_DISABLE | 1257 base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
1240 CLOCK_CTRL_TXCLK_DISABLE); 1258 CLOCK_CTRL_TXCLK_DISABLE);
1241 1259
1242 tw32_f(TG3PCI_CLOCK_CTRL, base_val | 1260 tw32_wait_f(TG3PCI_CLOCK_CTRL, base_val | CLOCK_CTRL_ALTCLK |
1243 CLOCK_CTRL_ALTCLK | 1261 CLOCK_CTRL_PWRDOWN_PLL133, 40);
1244 CLOCK_CTRL_PWRDOWN_PLL133);
1245 udelay(40);
1246 } else if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) { 1262 } else if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) {
1247 /* do nothing */ 1263 /* do nothing */
1248 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && 1264 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
@@ -1263,11 +1279,11 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1263 newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE; 1279 newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE;
1264 } 1280 }
1265 1281
1266 tw32_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1); 1282 tw32_wait_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1,
1267 udelay(40); 1283 40);
1268 1284
1269 tw32_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2); 1285 tw32_wait_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2,
1270 udelay(40); 1286 40);
1271 1287
1272 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 1288 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
1273 u32 newbits3; 1289 u32 newbits3;
@@ -1281,9 +1297,8 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1281 newbits3 = CLOCK_CTRL_44MHZ_CORE; 1297 newbits3 = CLOCK_CTRL_44MHZ_CORE;
1282 } 1298 }
1283 1299
1284 tw32_f(TG3PCI_CLOCK_CTRL, 1300 tw32_wait_f(TG3PCI_CLOCK_CTRL,
1285 tp->pci_clock_ctrl | newbits3); 1301 tp->pci_clock_ctrl | newbits3, 40);
1286 udelay(40);
1287 } 1302 }
1288 } 1303 }
1289 1304
@@ -1294,7 +1309,8 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1294 tg3_writephy(tp, MII_TG3_EXT_CTRL, 1309 tg3_writephy(tp, MII_TG3_EXT_CTRL,
1295 MII_TG3_EXT_CTRL_FORCE_LED_OFF); 1310 MII_TG3_EXT_CTRL_FORCE_LED_OFF);
1296 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x01b2); 1311 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x01b2);
1297 tg3_writephy(tp, MII_BMCR, BMCR_PDOWN); 1312 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700)
1313 tg3_writephy(tp, MII_BMCR, BMCR_PDOWN);
1298 } 1314 }
1299 } 1315 }
1300 1316
@@ -7959,13 +7975,12 @@ static int tg3_test_memory(struct tg3 *tp)
7959 u32 offset; 7975 u32 offset;
7960 u32 len; 7976 u32 len;
7961 } mem_tbl_570x[] = { 7977 } mem_tbl_570x[] = {
7962 { 0x00000000, 0x01000}, 7978 { 0x00000000, 0x00b50},
7963 { 0x00002000, 0x1c000}, 7979 { 0x00002000, 0x1c000},
7964 { 0xffffffff, 0x00000} 7980 { 0xffffffff, 0x00000}
7965 }, mem_tbl_5705[] = { 7981 }, mem_tbl_5705[] = {
7966 { 0x00000100, 0x0000c}, 7982 { 0x00000100, 0x0000c},
7967 { 0x00000200, 0x00008}, 7983 { 0x00000200, 0x00008},
7968 { 0x00000b50, 0x00400},
7969 { 0x00004000, 0x00800}, 7984 { 0x00004000, 0x00800},
7970 { 0x00006000, 0x01000}, 7985 { 0x00006000, 0x01000},
7971 { 0x00008000, 0x02000}, 7986 { 0x00008000, 0x02000},
@@ -10466,7 +10481,7 @@ static char * __devinit tg3_bus_string(struct tg3 *tp, char *str)
10466 return str; 10481 return str;
10467} 10482}
10468 10483
10469static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp) 10484static struct pci_dev * __devinit tg3_find_peer(struct tg3 *tp)
10470{ 10485{
10471 struct pci_dev *peer; 10486 struct pci_dev *peer;
10472 unsigned int func, devnr = tp->pdev->devfn & ~7; 10487 unsigned int func, devnr = tp->pdev->devfn & ~7;
@@ -10719,8 +10734,9 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10719 tp->rx_pending = 63; 10734 tp->rx_pending = 63;
10720 } 10735 }
10721 10736
10722 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) 10737 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
10723 tp->pdev_peer = tg3_find_5704_peer(tp); 10738 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714))
10739 tp->pdev_peer = tg3_find_peer(tp);
10724 10740
10725 err = tg3_get_device_address(tp); 10741 err = tg3_get_device_address(tp);
10726 if (err) { 10742 if (err) {