Get bus clock, which will be used to fix broken TCTR setting (hardware timer,
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 5 Oct 2008 06:15:36 +0000 (06:15 +0000)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 5 Oct 2008 06:15:36 +0000 (06:15 +0000)
interrupt moderation related)

sys/dev/netif/re/if_re.c
sys/dev/netif/re/if_rereg.h
sys/dev/netif/re/if_revar.h

index 8b67ad9..17908f9 100644 (file)
@@ -33,7 +33,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/re/if_re.c,v 1.25 2004/06/09 14:34:01 naddy Exp $
- * $DragonFly: src/sys/dev/netif/re/if_re.c,v 1.64 2008/10/05 05:00:58 sephe Exp $
+ * $DragonFly: src/sys/dev/netif/re/if_re.c,v 1.65 2008/10/05 06:15:36 sephe Exp $
  */
 
 /*
@@ -1328,7 +1328,35 @@ re_attach(device_t dev)
                        break;
                }
        }
-       device_printf(dev, "hardware rev. 0x%08x\n", hwrev);
+
+       if (sc->re_type == RE_8139CPLUS) {
+               sc->re_bus_speed = 33; /* XXX */
+       } else if (sc->re_flags & RE_F_PCIE) {
+               sc->re_bus_speed = 125;
+       } else {
+               uint8_t cfg2;
+
+               cfg2 = CSR_READ_1(sc, RE_CFG2);
+               switch (cfg2 & RE_CFG2_PCICLK_MASK) {
+               case RE_CFG2_PCICLK_33MHZ:
+                       sc->re_bus_speed = 33;
+                       break;
+               case RE_CFG2_PCICLK_66MHZ:
+                       sc->re_bus_speed = 66;
+                       break;
+               default:
+                       device_printf(dev, "unknown bus speed, assume 33MHz\n");
+                       sc->re_bus_speed = 33;
+                       break;
+               }
+               if (cfg2 & RE_CFG2_PCI64)
+                       sc->re_flags |= RE_F_PCI64;
+       }
+       device_printf(dev, "Hardware rev. 0x%08x; PCI%s %dMHz\n",
+                     sc->re_hwrev,
+                     (sc->re_flags & RE_F_PCIE) ?
+                     "-E" : ((sc->re_flags & RE_F_PCI64) ? "64" : "32"),
+                     sc->re_bus_speed);
 
        sc->re_eewidth = 6;
        re_read_eeprom(sc, (caddr_t)&re_did, 0, 1);
index ef7d799..c766891 100644 (file)
@@ -33,7 +33,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/pci/if_rlreg.h,v 1.42 2004/05/24 19:39:23 jhb Exp $
- * $DragonFly: src/sys/dev/netif/re/if_rereg.h,v 1.12 2008/10/05 01:53:41 sephe Exp $
+ * $DragonFly: src/sys/dev/netif/re/if_rereg.h,v 1.13 2008/10/05 06:15:36 sephe Exp $
  */
 
 /*
@@ -70,7 +70,8 @@
 #define RE_EECMD       0x0050          /* EEPROM command register */
 #define RE_CFG0                0x0051          /* config register #0 */
 #define RE_CFG1                0x0052          /* config register #1 */
-                                        /* 0053-0057 reserved */   
+#define RE_CFG2                0x0053          /* config register #2 */
+                                        /* 0054-0057 reserved */   
 #define RE_MEDIASTAT   0x0058          /* media status register (8139) */
                                        /* 0059-005A reserved */
 #define RE_MII         0x005A          /* 8129 chip only */
 #define RE_TXCFG_IFG           0x03000000      /* interframe gap */
 #define RE_TXCFG_HWREV         0x7CC00000
 
+/*
+ * Config 2 register bits
+ */
+#define RE_CFG2_PCICLK_MASK    0x07
+#define RE_CFG2_PCICLK_33MHZ   0x00
+#define RE_CFG2_PCICLK_66MHZ   0x01
+#define RE_CFG2_PCI64          0x08
+
 #define RE_LOOPTEST_OFF                0x00000000
 #define RE_LOOPTEST_ON         0x00020000
 #define RE_LOOPTEST_ON_CPLUS   0x00060000
index c2e20c7..7b982e3 100644 (file)
@@ -33,7 +33,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/pci/if_rlreg.h,v 1.42 2004/05/24 19:39:23 jhb Exp $
- * $DragonFly: src/sys/dev/netif/re/if_revar.h,v 1.12 2008/10/05 04:54:51 sephe Exp $
+ * $DragonFly: src/sys/dev/netif/re/if_revar.h,v 1.13 2008/10/05 06:15:36 sephe Exp $
  */
 
 #define RE_RX_DESC_CNT_DEF     64
@@ -148,6 +148,7 @@ struct re_softc {
        int                     re_maxmtu;
        int                     re_rx_desc_cnt;
        int                     re_tx_desc_cnt;
+       int                     re_bus_speed;
 #ifdef DEVICE_POLLING
        int                     rxcycles;
 #endif
@@ -168,6 +169,7 @@ struct re_softc {
 
 #define RE_F_HASMPC            0x1
 #define RE_F_PCIE              0x2
+#define RE_F_PCI64             0x4
 
 #define RE_TX_MODERATION_IS_ENABLED(sc)                        \
        ((sc)->re_tx_ack == RE_ISR_TIMEOUT_EXPIRED)