Submitted By: Jim Gifford (patches at jg555 dot com) Date: 2007-02-04 Initial Package Version: 2.6.20 Origin: Grant Gundler (parisc linux) Upstream Status: in -mm Description: Make the tulip drivers follow the chipset specs diff -Naur linux-2.6.20.orig/drivers/net/tulip/21142.c linux-2.6.20/drivers/net/tulip/21142.c --- linux-2.6.20.orig/drivers/net/tulip/21142.c 2007-02-04 10:44:54.000000000 -0800 +++ linux-2.6.20/drivers/net/tulip/21142.c 2007-02-04 20:43:32.000000000 -0800 @@ -173,7 +173,7 @@ int i; for (i = 0; i < tp->mtable->leafcount; i++) if (tp->mtable->mleaf[i].media == dev->if_port) { - int startup = ! ((tp->chip_id == DC21143 && (tp->revision == 48 || tp->revision == 65))); + int startup = ! ((tp->chip_id == DC21143 && tp->revision == 65)); tp->cur_index = i; tulip_select_media(dev, startup); setup_done = 1; diff -Naur linux-2.6.20.orig/drivers/net/tulip/media.c linux-2.6.20/drivers/net/tulip/media.c --- linux-2.6.20.orig/drivers/net/tulip/media.c 2007-02-04 10:44:54.000000000 -0800 +++ linux-2.6.20/drivers/net/tulip/media.c 2007-02-04 20:43:32.000000000 -0800 @@ -44,8 +44,10 @@ /* MII transceiver control section. Read and write the MII registers using software-generated serial - MDIO protocol. See the MII specifications or DP83840A data sheet - for details. */ + MDIO protocol. + See IEEE 802.3-2002.pdf (Section 2, Chapter "22.2.4 Management functions") + or DP83840A data sheet for more details. + */ int tulip_mdio_read(struct net_device *dev, int phy_id, int location) { @@ -261,24 +263,56 @@ u16 *reset_sequence = &((u16*)(p+3))[init_length]; int reset_length = p[2 + init_length*2]; misc_info = reset_sequence + reset_length; - if (startup) + if (startup) { + int timeout = 10; /* max 1 ms */ for (i = 0; i < reset_length; i++) iowrite32(get_u16(&reset_sequence[i]) << 16, ioaddr + CSR15); + + /* flush posted writes */ + ioread32(ioaddr + CSR15); + + /* Sect 3.10.3 in DP83840A.pdf (p39) */ + udelay(500); + + /* Section 4.2 in DP83840A.pdf (p43) */ + /* and IEEE 802.3 "22.2.4.1.1 Reset" */ + while (timeout-- && + (tulip_mdio_read (dev, phy_num, MII_BMCR) & BMCR_RESET)) + udelay(100); + } for (i = 0; i < init_length; i++) iowrite32(get_u16(&init_sequence[i]) << 16, ioaddr + CSR15); + + ioread32(ioaddr + CSR15); /* flush posted writes */ } else { u8 *init_sequence = p + 2; u8 *reset_sequence = p + 3 + init_length; int reset_length = p[2 + init_length]; misc_info = (u16*)(reset_sequence + reset_length); if (startup) { + int timeout = 10; /* max 1 ms */ iowrite32(mtable->csr12dir | 0x100, ioaddr + CSR12); for (i = 0; i < reset_length; i++) iowrite32(reset_sequence[i], ioaddr + CSR12); + + /* flush posted writes */ + ioread32(ioaddr + CSR12); + + /* Sect 3.10.3 in DP83840A.pdf (p39) */ + udelay(500); + + /* Section 4.2 in DP83840A.pdf (p43) */ + /* and IEEE 802.3 "22.2.4.1.1 Reset" */ + while (timeout-- && + (tulip_mdio_read (dev, phy_num, MII_BMCR) & BMCR_RESET)) + udelay(100); } for (i = 0; i < init_length; i++) iowrite32(init_sequence[i], ioaddr + CSR12); + + ioread32(ioaddr + CSR12); /* flush posted writes */ } + tmp_info = get_u16(&misc_info[1]); if (tmp_info) tp->advertising[phy_num] = tmp_info | 1; diff -Naur linux-2.6.20.orig/drivers/net/tulip/tulip.h linux-2.6.20/drivers/net/tulip/tulip.h --- linux-2.6.20.orig/drivers/net/tulip/tulip.h 2007-02-04 10:44:54.000000000 -0800 +++ linux-2.6.20/drivers/net/tulip/tulip.h 2007-02-04 20:43:32.000000000 -0800 @@ -482,8 +482,11 @@ udelay(10); if (!i) - printk(KERN_DEBUG "%s: tulip_stop_rxtx() failed\n", - pci_name(tp->pdev)); + printk(KERN_DEBUG "%s: tulip_stop_rxtx() failed" + " (CSR5 0x%x CSR6 0x%x)\n", + pci_name(tp->pdev), + ioread32(ioaddr + CSR5), + ioread32(ioaddr + CSR6)); } } diff -Naur linux-2.6.20.orig/drivers/net/tulip/tulip_core.c linux-2.6.20/drivers/net/tulip/tulip_core.c --- linux-2.6.20.orig/drivers/net/tulip/tulip_core.c 2007-02-04 10:44:54.000000000 -0800 +++ linux-2.6.20/drivers/net/tulip/tulip_core.c 2007-02-04 20:43:32.000000000 -0800 @@ -21,7 +21,7 @@ #else #define DRV_VERSION "1.1.14" #endif -#define DRV_RELDATE "May 11, 2002" +#define DRV_RELDATE "December 15, 2004" #include