Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Add partial support for PCH. We have to do more ...



details:   https://anonhg.NetBSD.org/src/rev/79d88577533a
branches:  trunk
changeset: 750704:79d88577533a
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Jan 11 12:29:28 2010 +0000

description:
Add partial support for PCH. We have to do more work for PCH. Especially
I don't know what driver i82578 should be attached to. makephy? or atphy?
MII_OUI() says that the PHY is from Attansic (== Atheros). Intel's e1000
driver says that it's close to makphy...

 I can't link up at 1000BaseT yet...

diffstat:

 sys/dev/pci/if_wm.c    |  111 ++++++++++++++++++++++++++++++++++++++++--------
 sys/dev/pci/if_wmreg.h |    5 +-
 sys/dev/pci/if_wmvar.h |    3 +-
 3 files changed, 98 insertions(+), 21 deletions(-)

diffs (truncated from 416 to 300 lines):

diff -r d3fb6bea6686 -r 79d88577533a sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Mon Jan 11 12:10:18 2010 +0000
+++ b/sys/dev/pci/if_wm.c       Mon Jan 11 12:29:28 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.189 2010/01/07 17:45:58 msaitoh Exp $      */
+/*     $NetBSD: if_wm.c,v 1.190 2010/01/11 12:29:28 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.189 2010/01/07 17:45:58 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.190 2010/01/11 12:29:28 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -852,6 +852,18 @@
        { PCI_VENDOR_INTEL,     PCI_PRODUCT_INTEL_82801J_D_BM_LF,
          "i82801J (LF) LAN Controller",
          WM_T_ICH10,           WMP_F_1000T },
+       { PCI_VENDOR_INTEL,     PCI_PRODUCT_INTEL_PCH_M_LM,
+         "PCH LAN (82578LM) Controller",
+         WM_T_PCH,             WMP_F_1000T },
+       { PCI_VENDOR_INTEL,     PCI_PRODUCT_INTEL_PCH_M_LC,
+         "PCH LAN (82578LC) Controller",
+         WM_T_PCH,             WMP_F_1000T },
+       { PCI_VENDOR_INTEL,     PCI_PRODUCT_INTEL_PCH_D_DM,
+         "PCH LAN (82578DM) Controller",
+         WM_T_PCH,             WMP_F_1000T },
+       { PCI_VENDOR_INTEL,     PCI_PRODUCT_INTEL_PCH_D_DC,
+         "PCH LAN (82578DC) Controller",
+         WM_T_PCH,             WMP_F_1000T },
        { 0,                    0,
          NULL,
          0,                    0 },
@@ -1104,7 +1116,8 @@
        } else if (sc->sc_type >= WM_T_82571) {
                sc->sc_flags |= WM_F_PCIE;
                if ((sc->sc_type != WM_T_ICH8) && (sc->sc_type != WM_T_ICH9)
-                       && (sc->sc_type != WM_T_ICH10))
+                   && (sc->sc_type != WM_T_ICH10)
+                   && (sc->sc_type != WM_T_PCH))
                        sc->sc_flags |= WM_F_EEPROM_SEMAPHORE;
                aprint_verbose_dev(sc->sc_dev, "PCI-Express bus\n");
        } else {
@@ -1282,6 +1295,7 @@
        case WM_T_ICH8:
        case WM_T_ICH9:
        case WM_T_ICH10:
+       case WM_T_PCH:
                if (wm_check_mng_mode(sc) != 0)
                        wm_get_hw_control(sc);
                break;
@@ -1359,6 +1373,7 @@
                }
                /* FALLTHROUGH */
        case WM_T_ICH10:
+       case WM_T_PCH:
                /* FLASH */
                sc->sc_flags |= WM_F_EEPROM_FLASH | WM_F_SWFWHW_SYNC;
                memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, WM_ICH8_FLASH);
@@ -1551,7 +1566,8 @@
         * media structures accordingly.
         */
        if (sc->sc_type == WM_T_ICH8 || sc->sc_type == WM_T_ICH9
-           || sc->sc_type == WM_T_ICH10 || sc->sc_type == WM_T_82573
+           || sc->sc_type == WM_T_ICH10 || sc->sc_type == WM_T_PCH
+           || sc->sc_type == WM_T_82573
            || sc->sc_type == WM_T_82574 || sc->sc_type == WM_T_82583) {
                /* STATUS_TBIMODE reserved/reused, can't rely on it */
                wm_gmii_mediainit(sc);
@@ -1598,6 +1614,10 @@
                /* XXX limited to 9234 */
                sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU;
                break;
+       case WM_T_PCH:
+               /* XXX limited to 4096 */
+               sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU;
+               break;
        case WM_T_82542_2_0:
        case WM_T_82542_2_1:
        case WM_T_82583:
@@ -2929,6 +2949,7 @@
                return;
        }
 
+       /* TBI mode */
        status = CSR_READ(sc, WMREG_STATUS);
        if (icr & ICR_LSC) {
                if (status & STATUS_LU) {
@@ -3056,6 +3077,7 @@
                break;
        case WM_T_ICH9:
        case WM_T_ICH10:
+       case WM_T_PCH:
                sc->sc_pba = PBA_10K;
                break;
        default:
@@ -3123,6 +3145,10 @@
                delay(5000);
        }
 
+       if (sc->sc_type == WM_T_PCH) {
+               /* Save K1 */
+       }
+
        switch (sc->sc_type) {
        case WM_T_82544: /* XXX check whether WM_F_IOH_VALID is set */
        case WM_T_82541:
@@ -3161,8 +3187,17 @@
        case WM_T_ICH8:
        case WM_T_ICH9:
        case WM_T_ICH10:
+       case WM_T_PCH:
                reg = CSR_READ(sc, WMREG_CTRL) | CTRL_RST;
                if (wm_check_reset_block(sc) == 0) {
+                       if (sc->sc_type >= WM_T_PCH) {
+                               uint32_t status;
+
+                               status = CSR_READ(sc, WMREG_STATUS);
+                               CSR_WRITE(sc, WMREG_STATUS,
+                                   status & ~STATUS_PHYRA);
+                       }
+
                        reg |= CTRL_PHY_RESET;
                        phy_reset = 1;
                }
@@ -3243,7 +3278,8 @@
                /* check EECD_EE_AUTORD */
                wm_get_auto_rd_done(sc);
                break;
-       case WM_T_ICH10: /* & PCH */
+       case WM_T_ICH10:
+       case WM_T_PCH:
                wm_lan_init_done(sc);
                break;
        default:
@@ -3253,6 +3289,14 @@
        /* reload sc_ctrl */
        sc->sc_ctrl = CSR_READ(sc, WMREG_CTRL);
 
+       /*
+        * For PCH, this write will make sure that any noise will be detected
+        * as a CRC error and be dropped rather than show up as a bad packet
+        * to the DMA engine
+        */
+       if (sc->sc_type == WM_T_PCH)
+               CSR_WRITE(sc, WMREG_CRC_OFFSET, 0x65656565);
+
 #if 0
        for (i = 0; i < 1000; i++) {
                if ((CSR_READ(sc, WMREG_CTRL) & CTRL_RST) == 0) {
@@ -3320,6 +3364,7 @@
        case WM_T_ICH8:
        case WM_T_ICH9:
        case WM_T_ICH10:
+       case WM_T_PCH:
                if (wm_check_mng_mode(sc) != 0)
                        wm_get_hw_control(sc);
                break;
@@ -3426,7 +3471,7 @@
         * XXX Values could probably stand some tuning.
         */
        if ((sc->sc_type != WM_T_ICH8) && (sc->sc_type != WM_T_ICH9)
-           && (sc->sc_type != WM_T_ICH10)) {
+           && (sc->sc_type != WM_T_ICH10) && (sc->sc_type != WM_T_PCH)) {
                CSR_WRITE(sc, WMREG_FCAL, FCAL_CONST);
                CSR_WRITE(sc, WMREG_FCAH, FCAH_CONST);
                CSR_WRITE(sc, WMREG_FCT, ETHERTYPE_FLOWCONTROL);
@@ -3463,6 +3508,7 @@
                case WM_T_ICH8:
                case WM_T_ICH9:
                case WM_T_ICH10:
+               case WM_T_PCH:
                        /*
                         * Set the mac to wait the maximum time between each
                         * iteration and increase the max iterations when
@@ -3527,7 +3573,7 @@
        CSR_WRITE(sc, WMREG_IMS, sc->sc_icr);
 
        if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
-           || (sc->sc_type == WM_T_ICH10)) {
+           || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH)) {
                reg = CSR_READ(sc, WMREG_KABGTXD);
                reg |= KABGTXD_BGSQLBIAS;
                CSR_WRITE(sc, WMREG_KABGTXD, reg);
@@ -3737,7 +3783,6 @@
        case WM_T_80003:
        case WM_T_ICH8:
        case WM_T_ICH9:
-       case WM_T_ICH10:
                for (i = 0; i < 10; i++) {
                        if (CSR_READ(sc, WMREG_EECD) & EECD_EE_AUTORD)
                                break;
@@ -3749,7 +3794,6 @@
                }
                break;
        default:
-               delay(5000);
                break;
        }
 }
@@ -3762,7 +3806,8 @@
 
        /* wait for eeprom to reload */
        switch (sc->sc_type) {
-       case WM_T_ICH10: /* & PCH */
+       case WM_T_ICH10:
+       case WM_T_PCH:
                for (i = 0; i < WM_ICH8_LAN_INIT_TIMEOUT; i++) {
                        reg = CSR_READ(sc, WMREG_STATUS);
                        if ((reg & STATUS_LAN_INIT_DONE) != 0)
@@ -3789,6 +3834,7 @@
 {
        int func = 0;
        int mask;
+       uint32_t reg;
        int i;
 
        /* wait for eeprom to reload */
@@ -3817,9 +3863,6 @@
        case WM_T_80003:
        case WM_T_82571:
        case WM_T_82572:
-       case WM_T_ICH8:
-       case WM_T_ICH9:
-       case WM_T_ICH10:
                if (sc->sc_type == WM_T_80003)
                        func = (CSR_READ(sc, WMREG_STATUS)
                            >> STATUS_FUNCID_SHIFT) & 1;
@@ -3836,6 +3879,18 @@
                                device_xname(sc->sc_dev), __func__));
                }
                break;
+       case WM_T_ICH8:
+       case WM_T_ICH9:
+       case WM_T_ICH10:
+       case WM_T_PCH:
+               if (sc->sc_type >= WM_T_PCH) {
+                       reg = CSR_READ(sc, WMREG_STATUS);
+                       if ((reg & STATUS_PHYRA) != 0)
+                               CSR_WRITE(sc, WMREG_STATUS,
+                                   reg & ~STATUS_PHYRA);
+               }
+               delay(10*1000);
+               break;
        default:
                panic("%s: %s: unknown type\n", device_xname(sc->sc_dev),
                    __func__);
@@ -4142,7 +4197,7 @@
                return 1;
 
        if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
-           || (sc->sc_type == WM_T_ICH10))
+           || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH))
                rv = wm_read_eeprom_ich8(sc, word, wordcnt, data);
        else if (sc->sc_flags & WM_F_EEPROM_EERDEEWR)
                rv = wm_read_eeprom_eerd(sc, word, wordcnt, data);
@@ -4289,7 +4344,7 @@
        uint32_t hash;
 
        if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
-           || (sc->sc_type == WM_T_ICH10)) {
+           || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH)) {
                hash = (enaddr[4] >> ich8_lo_shift[sc->sc_mchash_type]) |
                    (((uint16_t) enaddr[5]) << ich8_hi_shift[sc->sc_mchash_type]);
                return (hash & 0x3ff);
@@ -4335,7 +4390,7 @@
         * clear the remaining slots.
         */
        if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
-                || (sc->sc_type == WM_T_ICH10))
+           || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH))
                size = WM_ICH8_RAL_TABSIZE;
        else
                size = WM_RAL_TABSIZE;
@@ -4344,7 +4399,7 @@
                wm_set_ral(sc, NULL, i);
 
        if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
-           || (sc->sc_type == WM_T_ICH10))
+           || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH))
                size = WM_ICH8_MC_TABSIZE;
        else
                size = WM_MC_TABSIZE;
@@ -4370,7 +4425,7 @@
 
                reg = (hash >> 5);
                if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
-                   || (sc->sc_type == WM_T_ICH10))
+                   || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH))
                        reg &= 0x1f;
                else
                        reg &= 0x7f;
@@ -4717,6 +4772,7 @@
        case WM_T_ICH8:
        case WM_T_ICH9:
        case WM_T_ICH10:



Home | Main Index | Thread Index | Old Index