PATCH 2.3.99-pre3-pre3: Tulip 21041 fix (and other stuff)

Jeff Garzik jgarzik@mandrakesoft.com
Tue Mar 21 12:59:37 2000


This is a multi-part message in MIME format.
--------------83F1C16254D81967A842F22E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Jeff Garzik wrote:
> 
> Alan and Donald,
> 
> Here is the fix against 2.3.x which people have reported now works with
> the 21041 chip.

!@#$!@$# mailer :)

patch attached.
-- 
Jeff Garzik              | Tact is the ability to tell a man 
Building 1024            | he has an open mind when he has a
MandrakeSoft, Inc.       | hole in his head.  (-random fortune)
--------------83F1C16254D81967A842F22E
Content-Type: text/plain; charset=us-ascii;
 name="tulip-21041.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="tulip-21041.patch"

Index: 21142.c
===================================================================
RCS file: /g/cvslan/linux_2_3/drivers/net/tulip/Attic/21142.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 21142.c
--- 21142.c	2000/02/26 01:57:21	1.1.1.2
+++ 21142.c	2000/03/21 07:03:10
@@ -14,7 +14,6 @@
 */
 
 #include "tulip.h"
-#include <asm/io.h>
 
 
 static u16 t21142_csr13[] = { 0x0001, 0x0009, 0x0009, 0x0000, 0x0001, };
Index: eeprom.c
===================================================================
RCS file: /g/cvslan/linux_2_3/drivers/net/tulip/Attic/eeprom.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 eeprom.c
--- eeprom.c	2000/03/20 16:51:42	1.1.1.4
+++ eeprom.c	2000/03/21 07:03:10
@@ -15,7 +15,6 @@
 
 #include "tulip.h"
 #include <linux/init.h>
-#include <asm/io.h>
 #include <asm/unaligned.h>
 
 
Index: interrupt.c
===================================================================
RCS file: /g/cvslan/linux_2_3/drivers/net/tulip/Attic/interrupt.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 interrupt.c
--- interrupt.c	2000/03/20 16:51:42	1.1.1.4
+++ interrupt.c	2000/03/21 07:03:10
@@ -14,7 +14,6 @@
 */
 
 #include "tulip.h"
-#include <asm/io.h>
 #include <linux/etherdevice.h>
 #include <linux/pci.h>
 
Index: media.c
===================================================================
RCS file: /g/cvslan/linux_2_3/drivers/net/tulip/Attic/media.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 media.c
--- media.c	2000/02/26 01:57:21	1.1.1.2
+++ media.c	2000/03/21 07:03:10
@@ -14,7 +14,6 @@
 */
 
 #include "tulip.h"
-#include <asm/io.h>
 
 
 /* This is a mysterious value that can be written to CSR11 in the 21040 (only)
Index: pnic.c
===================================================================
RCS file: /g/cvslan/linux_2_3/drivers/net/tulip/Attic/pnic.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 pnic.c
--- pnic.c	2000/02/26 01:57:21	1.1.1.2
+++ pnic.c	2000/03/21 07:03:10
@@ -15,7 +15,6 @@
 
 #include <linux/kernel.h>
 #include "tulip.h"
-#include <asm/io.h>
 
 
 void pnic_do_nway(struct net_device *dev)
Index: timer.c
===================================================================
RCS file: /g/cvslan/linux_2_3/drivers/net/tulip/Attic/timer.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 timer.c
--- timer.c	2000/02/26 01:57:21	1.1.1.2
+++ timer.c	2000/03/21 07:03:10
@@ -14,7 +14,6 @@
 */
 
 #include "tulip.h"
-#include <asm/io.h>
 
 
 void tulip_timer(unsigned long data)
@@ -87,7 +86,11 @@
 			break;
 		}
 		break;
-	case DC21140:  case DC21142: case MX98713: case COMPEX9881: default: {
+	case DC21140:
+	case DC21142:
+	case MX98713:
+	case COMPEX9881:
+	default: {
 		struct medialeaf *mleaf;
 		unsigned char *p;
 		if (tp->mtable == NULL) {	/* No EEPROM info, use generic code. */
Index: tulip.h
===================================================================
RCS file: /g/cvslan/linux_2_3/drivers/net/tulip/Attic/tulip.h,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 tulip.h
--- tulip.h	2000/03/20 16:51:42	1.1.1.5
+++ tulip.h	2000/03/21 17:28:03
@@ -17,6 +17,7 @@
 #include <linux/spinlock.h>
 #include <linux/netdevice.h>
 #include <linux/timer.h>
+#include <asm/io.h>
 
 
 struct tulip_chip_table {
@@ -36,8 +37,10 @@
 	HAS_ACPI = 0x10,
 	MC_HASH_ONLY = 0x20,	/* Hash-only multicast filter. */
 	HAS_PNICNWAY = 0x80,
-	HAS_NWAY143 = 0x40,	/* Uses internal NWay xcvr. */
-	HAS_8023X = 0x100,
+	HAS_NWAY = 0x40,	/* Uses internal NWay xcvr. */
+	HAS_INTR_MITIGATION = 0x100,
+	IS_ASIX = 0x200,
+	HAS_8023X = 0x400,
 };
 
 
@@ -133,6 +136,17 @@
 	DescOwned = 0x80000000,
 	RxDescFatalErr = 0x8000,
 	RxWholePkt = 0x0300,
+};
+
+
+enum t21040_csr13_bits {
+	csr13_eng = (0xEF0<<4), /* for eng. purposes only, hardcode at EF0h */
+	csr13_aui = (1<<3), /* clear to force 10bT, set to force AUI/BNC */
+	csr13_cac = (1<<2), /* CSR13/14/15 autoconfiguration */
+	csr13_srl = (1<<0), /* When reset, resets all SIA functions, machines */
+
+	csr13_mask_auibnc = (csr13_eng | csr13_aui | csr13_cac | csr13_srl),
+	csr13_mask_10bt = (csr13_eng | csr13_cac | csr13_srl),
 };
 
 
Index: tulip_core.c
===================================================================
RCS file: /g/cvslan/linux_2_3/drivers/net/tulip/Attic/tulip_core.c,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 tulip_core.c
--- tulip_core.c	2000/03/20 16:51:42	1.1.1.7
+++ tulip_core.c	2000/03/21 08:20:02
@@ -19,7 +19,7 @@
 
 */
 
-static const char version[] = "Linux Tulip driver version 0.9.4.1 (Mar 18, 2000)\n";
+static const char version[] = "Linux Tulip driver version 0.9.4.2 (Mar 21, 2000)\n";
 
 #include <linux/module.h>
 #include "tulip.h"
@@ -27,7 +27,6 @@
 #include <linux/init.h>
 #include <linux/etherdevice.h>
 #include <linux/delay.h>
-#include <asm/io.h>
 #include <asm/unaligned.h>
 
 
@@ -120,12 +119,13 @@
 
 struct tulip_chip_table tulip_tbl[] = {
   { "Digital DC21040 Tulip", 128, 0x0001ebef, 0, tulip_timer },
-  { "Digital DC21041 Tulip", 128, 0x0001ebff, HAS_MEDIA_TABLE, tulip_timer },
+  { "Digital DC21041 Tulip", 128, 0x0001ebef,
+	HAS_MEDIA_TABLE | HAS_NWAY, tulip_timer },
   { "Digital DS21140 Tulip", 128, 0x0001ebef,
 	HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM, tulip_timer },
   { "Digital DS21143 Tulip", 128, 0x0801fbff,
-	HAS_MII | HAS_MEDIA_TABLE | ALWAYS_CHECK_MII | HAS_ACPI | HAS_NWAY143,
-	t21142_timer },
+	HAS_MII | HAS_MEDIA_TABLE | ALWAYS_CHECK_MII | HAS_ACPI | HAS_NWAY
+	| HAS_INTR_MITIGATION, t21142_timer },
   { "Lite-On 82c168 PNIC", 256, 0x0001ebef,
 	HAS_MII | HAS_PNICNWAY, pnic_timer },
   { "Macronix 98713 PMAC", 128, 0x0001ebef,
@@ -135,15 +135,15 @@
   { "Macronix 98725 PMAC", 256, 0x0001ebef,
 	HAS_MEDIA_TABLE, mxic_timer },
   { "ASIX AX88140", 128, 0x0001fbff,
-	HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM | MC_HASH_ONLY, tulip_timer },
+	HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM | MC_HASH_ONLY | IS_ASIX, tulip_timer },
   { "Lite-On PNIC-II", 256, 0x0801fbff,
-	HAS_MII | HAS_NWAY143 | HAS_8023X, t21142_timer },
+	HAS_MII | HAS_NWAY | HAS_8023X, t21142_timer },
   { "ADMtek Comet", 256, 0x0001abef,
 	MC_HASH_ONLY, comet_timer },
   { "Compex 9881 PMAC", 128, 0x0001ebef,
 	HAS_MII | HAS_MEDIA_TABLE | CSR12_IN_SROM, mxic_timer },
   { "Intel DS21145 Tulip", 128, 0x0801fbff,
-	HAS_MII | HAS_MEDIA_TABLE | ALWAYS_CHECK_MII | HAS_NWAY143,
+	HAS_MII | HAS_MEDIA_TABLE | ALWAYS_CHECK_MII | HAS_ACPI | HAS_NWAY,
 	t21142_timer },
   {0},
 };
@@ -157,12 +157,17 @@
 	{ 0x11AD, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, LC82C168 },
 	{ 0x10d9, 0x0512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MX98713 },
 	{ 0x10d9, 0x0531, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MX98715 },
-	{ 0x10d9, 0x0531, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MX98725 },
+/*	{ 0x10d9, 0x0531, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MX98725 },*/
 	{ 0x125B, 0x1400, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AX88140 },
 	{ 0x11AD, 0xc115, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PNIC2 },
 	{ 0x1317, 0x0981, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
+	{ 0x1317, 0x0985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
+	{ 0x1317, 0x1985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMET },
 	{ 0x11F6, 0x9881, PCI_ANY_ID, PCI_ANY_ID, 0, 0, COMPEX9881 },
 	{ 0x8086, 0x0039, PCI_ANY_ID, PCI_ANY_ID, 0, 0, I21145 },
+	{ 0x1282, 0x9100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21140 },
+	{ 0x1282, 0x9102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21140 },
+	{ 0x1113, 0x1217, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MX98715 },
 	{0},
 };
 MODULE_DEVICE_TABLE(pci, tulip_pci_tbl);
@@ -174,7 +179,13 @@
 u8 t21040_csr13[] = {2,0x0C,8,4,  4,0,0,0, 0,0,0,0, 4,0,0,0};
 
 /* 21041 transceiver register settings: 10-T, 10-2, AUI, 10-T, 10T-FD*/
-u16 t21041_csr13[] = { 0xEF01, 0xEF09, 0xEF09, 0xEF01, 0xEF09, };
+u16 t21041_csr13[] = {
+	csr13_mask_10bt,		/* 10-T */
+	csr13_mask_auibnc,		/* 10-2 */
+	csr13_mask_auibnc,		/* AUI */
+	csr13_mask_10bt,		/* 10-T */
+	csr13_mask_10bt,		/* 10T-FD */
+};
 u16 t21041_csr14[] = { 0xFFFF, 0xF7FD, 0xF7FD, 0x7F3F, 0x7F3D, };
 u16 t21041_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
 
@@ -209,11 +220,13 @@
 
 	/* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
 	outl(0x00000001, ioaddr + CSR0);
+	udelay(100);
 
 	/* Deassert reset.
 	   Wait the specified 50 PCI cycles after a reset by initializing
 	   Tx and Rx queues and the address filter list. */
 	outl(tp->csr0, ioaddr + CSR0);
+	udelay(100);
 
 	if (tulip_debug > 1)
 		printk(KERN_DEBUG "%s: tulip_up(), irq==%d.\n", dev->name, dev->irq);
@@ -730,14 +743,14 @@
 	case SIOCDEVPRIVATE:		/* Get the address of the PHY in use. */
 		if (tp->mii_cnt)
 			data[0] = phy;
-		else if (tp->flags & HAS_NWAY143)
+		else if (tp->flags & HAS_NWAY)
 			data[0] = 32;
 		else if (tp->chip_id == COMET)
 			data[0] = 1;
 		else
 			return -ENODEV;
 	case SIOCDEVPRIVATE+1:		/* Read the specified MII register. */
-		if (data[0] == 32  &&  (tp->flags & HAS_NWAY143)) {
+		if (data[0] == 32  &&  (tp->flags & HAS_NWAY)) {
 			int csr12 = inl(ioaddr + CSR12);
 			int csr14 = inl(ioaddr + CSR14);
 			switch (data[1]) {
@@ -765,7 +778,7 @@
 	case SIOCDEVPRIVATE+2:		/* Write the specified MII register */
 		if (!capable(CAP_NET_ADMIN))
 			return -EPERM;
-		if (data[0] == 32  &&  (tp->flags & HAS_NWAY143)) {
+		if (data[0] == 32  &&  (tp->flags & HAS_NWAY)) {
 			if (data[1] == 5)
 				tp->to_advertise = data[2];
 		} else {
@@ -1052,9 +1065,13 @@
 	/* Clear the missed-packet counter. */
 	(volatile int)inl(ioaddr + CSR8);
 
-	if (chip_idx == DC21041  &&  inl(ioaddr + CSR9) & 0x8000) {
-		printk(" 21040 compatible mode,");
-		chip_idx = DC21040;
+	if (chip_idx == DC21041) {
+		if (inl(ioaddr + CSR9) & 0x8000) {
+			printk(" 21040 compatible mode,");
+			chip_idx = DC21040;
+		} else {
+			printk(" 21041 mode,");
+		}
 	}
 
 	/* The station address ROM is read byte serially.  The register must
@@ -1251,7 +1268,7 @@
 	dev->do_ioctl = private_ioctl;
 	dev->set_multicast_list = set_rx_mode;
 
-	if ((tp->flags & HAS_NWAY143)  || tp->chip_id == DC21041)
+	if ((tp->flags & HAS_NWAY)  || tp->chip_id == DC21041)
 		tp->link_change = t21142_lnk_change;
 	else if (tp->flags & HAS_PNICNWAY)
 		tp->link_change = pnic_lnk_change;

--------------83F1C16254D81967A842F22E--

-------------------------------------------------------------------
To unsubscribe send a message body containing "unsubscribe"
to linux-tulip-request@beowulf.org