[PATCH] sky2: speed setting fix
authorStephen Hemminger <shemminger@osdl.org>
Fri, 10 Feb 2006 23:58:59 +0000 (15:58 -0800)
committerJeff Garzik <jgarzik@pobox.com>
Fri, 17 Feb 2006 21:16:21 +0000 (16:16 -0500)
Users report problems w/ auto-negotiation disabled and the link set
to 100/Half or 10/Half.  Problems range from poor performance to no
link at all.

The current sky2 code does not set things properly on link up if
autonegotiation is disabled.  Plus it does not contemplate a 10Mbit
setting at all.  This patch corrects that.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
drivers/net/sky2.c

index cae2edf23004e9b54c571f0b23f34dbacf8a2662..bfeba5b9cd7a7087d815c3c85aec20ecd38151ce 100644 (file)
@@ -520,10 +520,16 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
 
                switch (sky2->speed) {
                case SPEED_1000:
+                       reg &= ~GM_GPCR_SPEED_100;
                        reg |= GM_GPCR_SPEED_1000;
-                       /* fallthru */
+                       break;
                case SPEED_100:
+                       reg &= ~GM_GPCR_SPEED_1000;
                        reg |= GM_GPCR_SPEED_100;
+                       break;
+               case SPEED_10:
+                       reg &= ~(GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100);
+                       break;
                }
 
                if (sky2->duplex == DUPLEX_FULL)
@@ -1446,6 +1452,29 @@ static void sky2_link_up(struct sky2_port *sky2)
        sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), GMAC_DEF_MSK);
 
        reg = gma_read16(hw, port, GM_GP_CTRL);
+       if (sky2->autoneg == AUTONEG_DISABLE) {
+               reg |= GM_GPCR_AU_ALL_DIS;
+
+               /* Is write/read necessary?  Copied from sky2_mac_init */
+               gma_write16(hw, port, GM_GP_CTRL, reg);
+               gma_read16(hw, port, GM_GP_CTRL);
+
+               switch (sky2->speed) {
+               case SPEED_1000:
+                       reg &= ~GM_GPCR_SPEED_100;
+                       reg |= GM_GPCR_SPEED_1000;
+                       break;
+               case SPEED_100:
+                       reg &= ~GM_GPCR_SPEED_1000;
+                       reg |= GM_GPCR_SPEED_100;
+                       break;
+               case SPEED_10:
+                       reg &= ~(GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100);
+                       break;
+               }
+       } else
+               reg &= ~GM_GPCR_AU_ALL_DIS;
+
        if (sky2->duplex == DUPLEX_FULL || sky2->autoneg == AUTONEG_ENABLE)
                reg |= GM_GPCR_DUP_FULL;