Browse Source

[tg3] Added support for tg3-5754.

In tg3_chip_reset(), the PCI_EXPRESS change is taken from the Linux
tg3 driver. I am not sure what exactly it does (it is not documented
in the Linux driver), but it is necessary for the NIC to work
correctly.
tags/v0.9.4
Andrew Schran 16 years ago
parent
commit
6b58992318
3 changed files with 67 additions and 25 deletions
  1. 50
    23
      src/drivers/net/tg3.c
  2. 16
    2
      src/drivers/net/tg3.h
  3. 1
    0
      src/include/gpxe/pci.h

+ 50
- 23
src/drivers/net/tg3.c View File

@@ -1431,7 +1431,8 @@ static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, uint32_t enable_bit
1431 1431
 	unsigned int i;
1432 1432
 	uint32_t val;
1433 1433
 
1434
-	if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
1434
+	if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
1435
+	    GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) {
1435 1436
 		switch(ofs) {
1436 1437
 		case RCVLSC_MODE:
1437 1438
 		case DMAC_MODE:
@@ -1439,7 +1440,7 @@ static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, uint32_t enable_bit
1439 1440
 		case BUFMGR_MODE:
1440 1441
 		case MEMARB_MODE:
1441 1442
 			/* We can't enable/disable these bits of the
1442
-			 * 5705, just say success.
1443
+			 * 5705 or 5787, just say success.
1443 1444
 			 */
1444 1445
 			return 0;
1445 1446
 		default:
@@ -1470,6 +1471,7 @@ static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, uint32_t enable_bit
1470 1471
 static int tg3_abort_hw(struct tg3 *tp)
1471 1472
 {
1472 1473
 	int i, err;
1474
+	uint32_t val;
1473 1475
 
1474 1476
 	tg3_disable_ints(tp);
1475 1477
 
@@ -1513,8 +1515,14 @@ static int tg3_abort_hw(struct tg3 *tp)
1513 1515
 	err |= tg3_stop_block(tp, WDMAC_MODE,  WDMAC_MODE_ENABLE);
1514 1516
 	err |= tg3_stop_block(tp, MBFREE_MODE, MBFREE_MODE_ENABLE);
1515 1517
 
1516
-	tw32(FTQ_RESET, 0xffffffff);
1517
-	tw32(FTQ_RESET, 0x00000000);
1518
+	val = tr32(FTQ_RESET);
1519
+	val |= FTQ_RESET_DMA_READ_QUEUE | FTQ_RESET_DMA_HIGH_PRI_READ |
1520
+	       FTQ_RESET_SEND_BD_COMPLETION | FTQ_RESET_DMA_WRITE |
1521
+	       FTQ_RESET_DMA_HIGH_PRI_WRITE | FTQ_RESET_SEND_DATA_COMPLETION |
1522
+	       FTQ_RESET_HOST_COALESCING | FTQ_RESET_MAC_TX |
1523
+	       FTQ_RESET_RX_BD_COMPLETE | FTQ_RESET_RX_LIST_PLCMT |
1524
+               FTQ_RESET_RX_DATA_COMPLETION;
1525
+	tw32(FTQ_RESET, val);
1518 1526
 
1519 1527
 	err |= tg3_stop_block(tp, BUFMGR_MODE, BUFMGR_MODE_ENABLE);
1520 1528
 	err |= tg3_stop_block(tp, MEMARB_MODE, MEMARB_MODE_ENABLE);
@@ -1554,8 +1562,19 @@ static void tg3_chip_reset(struct tg3 *tp)
1554 1562
 	// Alf: here patched
1555 1563
 	/* do the reset */
1556 1564
 	val = GRC_MISC_CFG_CORECLK_RESET;
1565
+	if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
1566
+		if (tr32(0x7e2c) == 0x60) {
1567
+			tw32(0x7e2c, 0x20);
1568
+		}
1569
+		if (tp->pci_chip_rev_id != CHIPREV_ID_5750_A0) {
1570
+			tw32(GRC_MISC_CFG, (1 << 29));
1571
+			val |= (1 << 29);
1572
+		}
1573
+	}
1574
+	
1557 1575
 	if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
1558
-	    || (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) {
1576
+	    || (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
1577
+	    || (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)) {
1559 1578
 		val |= GRC_MISC_CFG_KEEP_GPHY_POWER;
1560 1579
 	}
1561 1580
 
@@ -1644,7 +1663,8 @@ static int tg3_restart_fw(struct tg3 *tp, uint32_t state)
1644 1663
 		udelay(10);
1645 1664
 	}
1646 1665
 	if (i >= 100000 &&
1647
-		    !(tp->tg3_flags2 & TG3_FLG2_SUN_5704)) {
1666
+		    !(tp->tg3_flags2 & TG3_FLG2_SUN_5704) &&
1667
+		    !(GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)) {
1648 1668
 		printf ( "Firmware will not restart magic=%#lx\n",
1649 1669
 			val );
1650 1670
 		return -ENODEV;
@@ -1879,7 +1899,9 @@ static int tg3_setup_hw(struct tg3 *tp)
1879 1899
 	     (65 << GRC_MISC_CFG_PRESCALAR_SHIFT));
1880 1900
 
1881 1901
 	/* Initialize MBUF/DESC pool. */
1882
-	if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) &&
1902
+	if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) {
1903
+		/* Do nothing. */
1904
+	} else if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) &&
1883 1905
 		(tp->pci_chip_rev_id != CHIPREV_ID_5721)) {
1884 1906
 		tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
1885 1907
 		if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
@@ -1976,7 +1998,8 @@ static int tg3_setup_hw(struct tg3 *tp)
1976 1998
 		TG3_WRITE_SETTINGS(table_all);
1977 1999
 		tw32(RCVDBDI_STD_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW, 
1978 2000
 			virt_to_bus(tp->rx_std));
1979
-		if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
2001
+		if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
2002
+		    GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) {
1980 2003
 			tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
1981 2004
 				RX_STD_MAX_SIZE_5705 << BDINFO_FLAGS_MAXLEN_SHIFT);
1982 2005
 		} else {
@@ -1985,10 +2008,11 @@ static int tg3_setup_hw(struct tg3 *tp)
1985 2008
 	}
1986 2009
 
1987 2010
 	
1988
-	/* There is only one send ring on 5705, no need to explicitly
2011
+	/* There is only one send ring on 5705 and 5787, no need to explicitly
1989 2012
 	 * disable the others.
1990 2013
 	 */
1991
-	if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
2014
+	if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
2015
+	    GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) {
1992 2016
 		/* Clear out send RCB ring in SRAM. */
1993 2017
 		for (i = NIC_SRAM_SEND_RCB; i < NIC_SRAM_RCV_RET_RCB; i += TG3_BDINFO_SIZE)
1994 2018
 			tg3_write_mem(i + TG3_BDINFO_MAXLEN_FLAGS, BDINFO_FLAGS_DISABLED);
@@ -2004,10 +2028,11 @@ static int tg3_setup_hw(struct tg3 *tp)
2004 2028
 		(TG3_TX_RING_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT),
2005 2029
 		NIC_SRAM_TX_BUFFER_DESC);
2006 2030
 
2007
-	/* There is only one receive return ring on 5705, no need to explicitly
2008
-	 * disable the others.
2031
+	/* There is only one receive return ring on 5705 and 5787, no need to
2032
+	 * explicitly disable the others.
2009 2033
 	 */
2010
-	if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
2034
+	if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
2035
+	    GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) {
2011 2036
 		for (i = NIC_SRAM_RCV_RET_RCB; i < NIC_SRAM_STATS_BLK; i += TG3_BDINFO_SIZE) {
2012 2037
 			tg3_write_mem(i + TG3_BDINFO_MAXLEN_FLAGS,
2013 2038
 				BDINFO_FLAGS_DISABLED);
@@ -2086,6 +2111,11 @@ static int tg3_setup_hw(struct tg3 *tp)
2086 2111
 		!(tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
2087 2112
 		val |= WDMAC_MODE_RX_ACCEL;
2088 2113
 	}
2114
+
2115
+	/* Host coalescing bug fix */
2116
+	if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
2117
+		val |= (1 << 29);
2118
+
2089 2119
 	tw32_carefully(WDMAC_MODE, val);
2090 2120
 
2091 2121
 	if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) {
@@ -2182,7 +2212,8 @@ static int tg3_setup_hw(struct tg3 *tp)
2182 2212
 			virt_to_bus(tp->hw_stats));
2183 2213
 		tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
2184 2214
 			virt_to_bus(tp->hw_status));
2185
-		if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
2215
+		if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
2216
+		    GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) {
2186 2217
 			TG3_WRITE_SETTINGS(table_not_5705);
2187 2218
 		}
2188 2219
 	}
@@ -2762,15 +2793,9 @@ static int tg3_get_invariants(struct tg3 *tp)
2762 2793
 	/* determine if it is PCIE system */
2763 2794
 	// Alf : I have no idea what this is about...
2764 2795
 	// But it's definitely usefull
2765
-	if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
2766
-	  val = tr32(TG3PCI_MSI_CAP_ID) ;
2767
-	  if (((val >> 8) & 0xff) == T3_PCIE_CAPABILITY_ID_REG) {
2768
-	    val = tr32(T3_PCIE_CAPABILITY_ID_REG) ;
2769
-	    if ((val & 0xff) == T3_PCIE_CAPABILITY_ID) {
2770
-	      tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS ;
2771
-	    }
2772
-	  }
2773
-	}
2796
+	val = pci_find_capability(tp->pdev, PCI_CAP_ID_EXP);
2797
+	if (val)
2798
+		tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
2774 2799
 
2775 2800
 	/* Force the chip into D0. */
2776 2801
 	tg3_set_power_state_0(tp);
@@ -3010,6 +3035,7 @@ static const char * tg3_phy_string(struct tg3 *tp)
3010 3035
         case PHY_ID_BCM5705:    return "5705";
3011 3036
         case PHY_ID_BCM5750:    return "5750";
3012 3037
 	case PHY_ID_BCM5751:	return "5751"; 
3038
+	case PHY_ID_BCM5787:	return "5787";
3013 3039
 	case PHY_ID_BCM8002:	return "8002/serdes";
3014 3040
 	case PHY_ID_SERDES:	return "serdes";
3015 3041
 	default:		return "unknown";
@@ -3370,6 +3396,7 @@ PCI_ROM(0x14e4, 0x1659, "tg3-5721",        "Broadcom Tigon 3 5721"),
3370 3396
 PCI_ROM(0x14e4, 0x165d, "tg3-5705M",       "Broadcom Tigon 3 5705M"),
3371 3397
 PCI_ROM(0x14e4, 0x165e, "tg3-5705M_2",     "Broadcom Tigon 3 5705M_2"),
3372 3398
 PCI_ROM(0x14e4, 0x1677, "tg3-5751",        "Broadcom Tigon 3 5751"),
3399
+PCI_ROM(0x14e4, 0x167a, "tg3-5754",        "Broadcom Tigon 3 5754"),
3373 3400
 PCI_ROM(0x14e4, 0x1696, "tg3-5782",        "Broadcom Tigon 3 5782"),
3374 3401
 PCI_ROM(0x14e4, 0x169c, "tg3-5788",        "Broadcom Tigon 3 5788"),
3375 3402
 PCI_ROM(0x14e4, 0x169d, "tg3-5789",        "Broadcom Tigon 3 5789"),

+ 16
- 2
src/drivers/net/tg3.h View File

@@ -294,6 +294,7 @@ typedef unsigned long dma_addr_t;
294 294
 #define   ASIC_REV_5704			 0x02
295 295
 #define   ASIC_REV_5705			 0x03
296 296
 #define   ASIC_REV_5750			 0x04
297
+#define   ASIC_REV_5787			 0x0b
297 298
 #define  GET_CHIP_REV(CHIP_REV_ID)	((CHIP_REV_ID) >> 8)
298 299
 #define   CHIPREV_5700_AX		 0x70
299 300
 #define   CHIPREV_5700_BX		 0x71
@@ -1273,6 +1274,17 @@ typedef unsigned long dma_addr_t;
1273 1274
 
1274 1275
 /* Flow Through queues */
1275 1276
 #define FTQ_RESET			0x00005c00
1277
+#define FTQ_RESET_DMA_READ_QUEUE	(1 << 1)
1278
+#define FTQ_RESET_DMA_HIGH_PRI_READ	(1 << 2)
1279
+#define FTQ_RESET_SEND_BD_COMPLETION	(1 << 4)
1280
+#define FTQ_RESET_DMA_WRITE		(1 << 6)
1281
+#define FTQ_RESET_DMA_HIGH_PRI_WRITE	(1 << 7)
1282
+#define FTQ_RESET_SEND_DATA_COMPLETION	(1 << 9)
1283
+#define FTQ_RESET_HOST_COALESCING	(1 << 10)
1284
+#define FTQ_RESET_MAC_TX		(1 << 11)
1285
+#define FTQ_RESET_RX_BD_COMPLETE	(1 << 13)
1286
+#define FTQ_RESET_RX_LIST_PLCMT		(1 << 14)
1287
+#define FTQ_RESET_RX_DATA_COMPLETION	(1 << 16)
1276 1288
 /* 0x5c04 --> 0x5c10 unused */
1277 1289
 #define FTQ_DMA_NORM_READ_CTL		0x00005c10
1278 1290
 #define FTQ_DMA_NORM_READ_FULL_CNT	0x00005c14
@@ -2130,7 +2142,8 @@ struct tg3 {
2130 2142
 #define PHY_ID_BCM5703			0x60008160
2131 2143
 #define PHY_ID_BCM5704			0x60008190
2132 2144
 #define PHY_ID_BCM5705			0x600081a0
2133
-#define PHY_ID_BCM5750                  0x60008180
2145
+#define PHY_ID_BCM5750			0x60008180
2146
+#define PHY_ID_BCM5787			0xbc050ce0
2134 2147
 #define PHY_ID_BCM8002			0x60010140
2135 2148
 #define PHY_ID_BCM5751			0x00206180
2136 2149
 #define PHY_ID_SERDES			0xfeedbee0
@@ -2157,7 +2170,8 @@ struct tg3 {
2157 2170
 	((X) == PHY_ID_BCM5400 || (X) == PHY_ID_BCM5401 || \
2158 2171
 	 (X) == PHY_ID_BCM5411 || (X) == PHY_ID_BCM5701 || \
2159 2172
 	 (X) == PHY_ID_BCM5703 || (X) == PHY_ID_BCM5704 || \
2160
-	 (X) == PHY_ID_BCM5705 || (X) == PHY_ID_BCM5750 || (X) == PHY_ID_BCM5751 || \
2173
+	 (X) == PHY_ID_BCM5705 || (X) == PHY_ID_BCM5750 || \
2174
+	 (X) == PHY_ID_BCM5751 || (X) == PHY_ID_BCM5787 || \
2161 2175
 	 (X) == PHY_ID_BCM8002 || (X) == PHY_ID_SERDES)
2162 2176
 
2163 2177
 	unsigned long			regs;

+ 1
- 0
src/include/gpxe/pci.h View File

@@ -156,6 +156,7 @@
156 156
 #define  PCI_CAP_ID_SLOTID	0x04	/* Slot Identification */
157 157
 #define  PCI_CAP_ID_MSI		0x05	/* Message Signalled Interrupts */
158 158
 #define  PCI_CAP_ID_CHSWP	0x06	/* CompactPCI HotSwap */
159
+#define  PCI_CAP_ID_EXP		0x10	/* PCI Express */
159 160
 #define PCI_CAP_LIST_NEXT	1	/* Next capability in the list */
160 161
 #define PCI_CAP_FLAGS		2	/* Capability defined flags (16 bits) */
161 162
 #define PCI_CAP_SIZEOF		4

Loading…
Cancel
Save