Re Re: [patch] epic100.c - activating fiber interface for the SMC EtherPower II NIC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Thanks for that..
>
> It would be better to implement this in the driver open routine.
> The media timer function is effectively operating in interrupt
> context and the mdio_read() function has no protection between
> interrupt and non-interrupt context.
>
> But epic100 is already performing mdio functions in its timer
> handler.  If someone was running ethtool in a tight loop it
> would probably fail quite quickly.  Oh well.
>
> Have you been able to test this patch on 100baseT and 10baseT
> cards?
>
> -

Hello,

Changes made to activate the fiber interface at the SMC EtherPower II NIC
(03.Jul.2002) by Christoph Dolina (cdolina@fh-landshut.de):

Due to the notice of Andrew Morton I changed the patch as described below.

5. function check_media is now clean, without new code !

6. the functionality for the check, which media is to activate by the driver 
is now placed in the function open()
 => however this means, that HOT-PLUG CHANGE OF MEDIA is NOT POSSIBLE any 
more, => SOLUTION is to reload and restart the driver after a change
 the udelay in open() of about 1.5 sec is needed for the optical modul to 
finish its autonegotiate,
 so it is checked if link on fiber is up, if link is not up, the driver 
switches to TwistedPair, and all of this in the function open() ;-)

Thanks.

P.S.: We tested the driver successfully with following devices:
SMC TX/FX to 100BaseT Switch
SMC TX/FX to 10BaseT Switch
SMC TX/FX to 100FX Switch
also
SMC TP-only to 100BaseT Switch
SMC TP-only to 10BaseT Switch
--- epic100.c	Fri Jan  1 01:00:34 1999
+++ epic100-v2.c	Fri Jan  1 01:11:57 1999
@@ -60,11 +60,13 @@
 	LK1.1.12:
 	* fix power-up sequence
 
+	LK1.1.xx:
+	* fiber link enabled (Christoph Dolina), switch media delayed by 5 sec
 */
 
 #define DRV_NAME	"epic100"
-#define DRV_VERSION	"1.11+LK1.1.12"
-#define DRV_RELDATE	"Jan 18, 2002"
+#define DRV_VERSION	"1.12+LK1.1.xx"
+#define DRV_RELDATE	"Jun 26, 2002"
 
 
 /* The user-configurable values.
@@ -477,6 +479,9 @@
 	ep->chip_id = chip_idx;
 	ep->chip_flags = pci_id_tbl[chip_idx].drv_flags;
 
+	/* (Christoph Dolina): Needed for rising up the Hardware */
+	{ udelay(200); }
+
 	/* Find the connected MII xcvrs.
 	   Doing this in open() would allow detecting external xcvrs later, but
 	   takes much time and no cards have external MII. */
@@ -692,33 +697,86 @@
 	outl(0x0412 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL);
 #endif
 
+	/* (Christoph Dolina): Needed for rising up the Hardware */
+	{ udelay(200); }
+
 	for (i = 0; i < 3; i++)
 		outl(cpu_to_le16(((u16*)dev->dev_addr)[i]), ioaddr + LAN0 + i*4);
 
 	ep->tx_threshold = TX_FIFO_THRESH;
 	outl(ep->tx_threshold, ioaddr + TxThresh);
 
-	if (media2miictl[dev->if_port & 15]) {
-		if (ep->mii_phy_cnt)
-			mdio_write(dev, ep->phys[0], MII_BMCR, media2miictl[dev->if_port&15]);
-		if (dev->if_port == 1) {
-			if (debug > 1)
-				printk(KERN_INFO "%s: Using the 10base2 transceiver, MII "
-					   "status %4.4x.\n",
-					   dev->name, mdio_read(dev, ep->phys[0], MII_BMSR));
-		}
-	} else {
-		int mii_lpa = mdio_read(dev, ep->phys[0], MII_LPA);
-		if (mii_lpa != 0xffff) {
-			if ((mii_lpa & LPA_100FULL) || (mii_lpa & 0x01C0) == LPA_10FULL)
-				ep->mii.full_duplex = 1;
-			else if (! (mii_lpa & LPA_LPACK))
-				mdio_write(dev, ep->phys[0], MII_BMCR, BMCR_ANENABLE|BMCR_ANRESTART);
-			if (debug > 1)
-				printk(KERN_INFO "%s: Setting %s-duplex based on MII xcvr %d"
-					   " register read of %4.4x.\n", dev->name,
-					   ep->mii.full_duplex ? "full" : "half",
-					   ep->phys[0], mii_lpa);
+	/* 26.Jun.2002: Switch on the Power on Fiber and Enables the Fiber */
+	/* Config-Reg (0x13): Fiber_Enable (0x0004), Fiber_On, Led_On */
+	mdio_write(dev, ep->phys[0], 0x13, 0x0004 | 0x0040 | 0x0080);
+
+	/* Phy-BMC-Reg: Loopback */
+	mdio_write(dev, ep->phys[0], 0x00, 0x4000);
+
+	/* Phy-BMC-Reg: Loopback off(0x0002), FullDuplex (0x0100), 100Mbps (0x2000) */
+	mdio_write(dev, ep->phys[0], 0x00, 0x0002 | 0x0100 | 0x2000);
+
+	/* Wait until Autoneg ready => so you can check for Link up or down on fiber */
+	for (i = 0; i<1000; i++)
+		udelay(1500);
+
+	/* Status-Reg (0x14): check FOR Link up */
+	i = mdio_read(dev, ep->phys[0], 0x14);
+
+	/* IF no Link, change type of media */
+	if ( ( i & 0x2000) == 0 ) {
+
+		/* read Config-Reg (0x13): check IF fiber is on */
+		i = mdio_read(dev, ep->phys[0], 0x13);
+
+		/* fiber on (and no link) then disable fiber */
+		if ( ( i & 0x0004 ) != 0 ) {
+
+			// Config-Reg (0x13): disable it
+			mdio_write(dev, ep->phys[0], 0x13, 0x0000);
+
+			/* and activate utp */
+			{
+				if (media2miictl[dev->if_port & 15]) {
+					if (ep->mii_phy_cnt)
+						mdio_write(dev, ep->phys[0], MII_BMCR, media2miictl[dev->if_port&15]);
+					if (dev->if_port == 1) {
+						if (debug > 1)
+							printk(KERN_INFO "%s: Using the 10base2 transceiver, MII "
+								   "status %4.4x.\n",
+								   dev->name, mdio_read(dev, ep->phys[0], MII_BMSR));
+					}
+				} else {
+					int mii_lpa = mdio_read(dev, ep->phys[0], MII_LPA);
+					if (mii_lpa != 0xffff) {
+						if ((mii_lpa & LPA_100FULL) || (mii_lpa & 0x01C0) == LPA_10FULL)
+							ep->mii.full_duplex = 1;
+ 						else if (! (mii_lpa & LPA_LPACK))
+							mdio_write(dev, ep->phys[0], MII_BMCR, BMCR_ANENABLE|BMCR_ANRESTART);
+						if (debug > 1)
+							printk(KERN_INFO "%s: Setting %s-duplex based on MII xcvr %d"
+								   " register read of %4.4x.\n", dev->name,
+								   ep->mii.full_duplex ? "full" : "half",
+								   ep->phys[0], mii_lpa);
+					}
+				}
+			}
+		/* IF fiber off (and no link) then enable it */
+		} else {
+			/*	26.Jun.2002, Changes for Fiber (Christoph Dolina)
+				1. Switch on the Power and Enables the Fiber
+				2. Activates the Loopbackmode (forces the other side to autoneg.)
+				3. Deactivates the Loopback, back to net in 100Mbps and Fulldplx
+			*/
+
+			/* Config-Reg (0x13): Fiber_Enable (0x0004), Fiber_On, Led_On */
+			mdio_write(dev, ep->phys[0], 0x13, 0x0004 | 0x0040 | 0x0080);
+
+			/* Phy-BMC-Reg: Loopback */
+			mdio_write(dev, ep->phys[0], 0x00, 0x4000);
+
+			/*  Phy-BMC-Reg: Loopback aus(0x0002), FullDuplex (0x0100), 100Mbps (0x2000) */
+			mdio_write(dev, ep->phys[0], 0x00, 0x0002 | 0x0100 | 0x2000);
 		}
 	}
 

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux