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 support for BCM5719, BCM5720, BCM57766, BC...
details: https://anonhg.NetBSD.org/src/rev/9b9f2e481a88
branches: trunk
changeset: 785512:9b9f2e481a88
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Sun Mar 17 04:06:39 2013 +0000
description:
- ADD support for BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Use macros.
- Remove unused code.
- Sync with the latest {Free,Open}BSD's bge.
diffstat:
sys/dev/pci/if_bge.c | 1227 ++++++++++++++++++++++++++++++++++------------
sys/dev/pci/if_bgereg.h | 200 +++++++-
sys/dev/pci/if_bgevar.h | 34 +-
3 files changed, 1109 insertions(+), 352 deletions(-)
diffs (truncated from 2494 to 300 lines):
diff -r ed09d6d73045 -r 9b9f2e481a88 sys/dev/pci/if_bge.c
--- a/sys/dev/pci/if_bge.c Sun Mar 17 03:00:05 2013 +0000
+++ b/sys/dev/pci/if_bge.c Sun Mar 17 04:06:39 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bge.c,v 1.215 2013/03/14 18:49:20 msaitoh Exp $ */
+/* $NetBSD: if_bge.c,v 1.216 2013/03/17 04:06:39 msaitoh Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.215 2013/03/14 18:49:20 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.216 2013/03/17 04:06:39 msaitoh Exp $");
#include "vlan.h"
@@ -240,7 +240,7 @@
static int bge_chipinit(struct bge_softc *);
static int bge_blockinit(struct bge_softc *);
-static int bge_setpowerstate(struct bge_softc *, int);
+static int bge_phy_addr(struct bge_softc *);
static uint32_t bge_readmem_ind(struct bge_softc *, int);
static void bge_writemem_ind(struct bge_softc *, int, int);
static void bge_writembx(struct bge_softc *, int, int);
@@ -253,17 +253,26 @@
static void bge_miibus_writereg(device_t, int, int, int);
static void bge_miibus_statchg(struct ifnet *);
-#define BGE_RESET_START 1
-#define BGE_RESET_STOP 2
+#define BGE_RESET_SHUTDOWN 0
+#define BGE_RESET_START 1
+#define BGE_RESET_SUSPEND 2
static void bge_sig_post_reset(struct bge_softc *, int);
static void bge_sig_legacy(struct bge_softc *, int);
static void bge_sig_pre_reset(struct bge_softc *, int);
+static void bge_wait_for_event_ack(struct bge_softc *);
static void bge_stop_fw(struct bge_softc *);
static int bge_reset(struct bge_softc *);
static void bge_link_upd(struct bge_softc *);
static void bge_sysctl_init(struct bge_softc *);
static int bge_sysctl_verify(SYSCTLFN_PROTO);
+static void bge_ape_lock_init(struct bge_softc *);
+static void bge_ape_read_fw_ver(struct bge_softc *);
+static int bge_ape_lock(struct bge_softc *, int);
+static void bge_ape_unlock(struct bge_softc *, int);
+static void bge_ape_send_event(struct bge_softc *, uint32_t);
+static void bge_ape_driver_state_change(struct bge_softc *, int);
+
#ifdef BGE_DEBUG
#define DPRINTF(x) if (bgedebug) printf x
#define DPRINTFN(n,x) if (bgedebug >= (n)) printf x
@@ -405,12 +414,14 @@
PCI_PRODUCT_BROADCOM_BCM5718,
"Broadcom BCM5718 Gigabit Ethernet",
},
-#if 0
+ { PCI_VENDOR_BROADCOM,
+ PCI_PRODUCT_BROADCOM_BCM5719,
+ "Broadcom BCM5719 Gigabit Ethernet",
+ },
{ PCI_VENDOR_BROADCOM,
PCI_PRODUCT_BROADCOM_BCM5720,
"Broadcom BCM5720 Gigabit Ethernet",
},
-#endif
{ PCI_VENDOR_BROADCOM,
PCI_PRODUCT_BROADCOM_BCM5721,
"Broadcom BCM5721 Gigabit Ethernet",
@@ -596,6 +607,10 @@
"Broadcom BCM57765 Fast Ethernet",
},
{ PCI_VENDOR_BROADCOM,
+ PCI_PRODUCT_BROADCOM_BCM57766,
+ "Broadcom BCM57766 Fast Ethernet",
+ },
+ { PCI_VENDOR_BROADCOM,
PCI_PRODUCT_BROADCOM_BCM57780,
"Broadcom BCM57780 Fast Ethernet",
},
@@ -604,10 +619,18 @@
"Broadcom BCM57781 Fast Ethernet",
},
{ PCI_VENDOR_BROADCOM,
+ PCI_PRODUCT_BROADCOM_BCM57782,
+ "Broadcom BCM57782 Fast Ethernet",
+ },
+ { PCI_VENDOR_BROADCOM,
PCI_PRODUCT_BROADCOM_BCM57785,
"Broadcom BCM57785 Fast Ethernet",
},
{ PCI_VENDOR_BROADCOM,
+ PCI_PRODUCT_BROADCOM_BCM57786,
+ "Broadcom BCM57786 Fast Ethernet",
+ },
+ { PCI_VENDOR_BROADCOM,
PCI_PRODUCT_BROADCOM_BCM57788,
"Broadcom BCM57788 Fast Ethernet",
},
@@ -667,7 +690,6 @@
{ BGE_CHIPID_BCM5700_B1, "BCM5700 B1" },
{ BGE_CHIPID_BCM5700_B2, "BCM5700 B2" },
{ BGE_CHIPID_BCM5700_B3, "BCM5700 B3" },
- /* This is treated like a BCM5700 Bx */
{ BGE_CHIPID_BCM5700_ALTIMA, "BCM5700 Altima" },
{ BGE_CHIPID_BCM5700_C0, "BCM5700 C0" },
{ BGE_CHIPID_BCM5701_A0, "BCM5701 A0" },
@@ -705,6 +727,10 @@
{ BGE_CHIPID_BCM5715_A0, "BCM5715 A0" },
{ BGE_CHIPID_BCM5715_A1, "BCM5715 A1" },
{ BGE_CHIPID_BCM5715_A3, "BCM5715 A3" },
+ { BGE_CHIPID_BCM5717_A0, "BCM5717 A0" },
+ { BGE_CHIPID_BCM5717_B0, "BCM5717 B0" },
+ { BGE_CHIPID_BCM5719_A0, "BCM5719 A0" },
+ { BGE_CHIPID_BCM5720_A0, "BCM5720 A0" },
{ BGE_CHIPID_BCM5755_A0, "BCM5755 A0" },
{ BGE_CHIPID_BCM5755_A1, "BCM5755 A1" },
{ BGE_CHIPID_BCM5755_A2, "BCM5755 A2" },
@@ -739,10 +765,10 @@
{ BGE_ASICREV_BCM5704, "unknown BCM5704" },
{ BGE_ASICREV_BCM5705, "unknown BCM5705" },
{ BGE_ASICREV_BCM5750, "unknown BCM5750" },
+ { BGE_ASICREV_BCM5714, "unknown BCM5714" },
{ BGE_ASICREV_BCM5714_A0, "unknown BCM5714" },
{ BGE_ASICREV_BCM5752, "unknown BCM5752" },
{ BGE_ASICREV_BCM5780, "unknown BCM5780" },
- { BGE_ASICREV_BCM5714, "unknown BCM5714" },
{ BGE_ASICREV_BCM5755, "unknown BCM5755" },
{ BGE_ASICREV_BCM5761, "unknown BCM5761" },
{ BGE_ASICREV_BCM5784, "unknown BCM5784" },
@@ -750,10 +776,12 @@
/* 5754 and 5787 share the same ASIC ID */
{ BGE_ASICREV_BCM5787, "unknown BCM5754/5787" },
{ BGE_ASICREV_BCM5906, "unknown BCM5906" },
+ { BGE_ASICREV_BCM57765, "unknown BCM57765" },
+ { BGE_ASICREV_BCM57766, "unknown BCM57766" },
{ BGE_ASICREV_BCM57780, "unknown BCM57780" },
{ BGE_ASICREV_BCM5717, "unknown BCM5717" },
- { BGE_ASICREV_BCM57765, "unknown BCM57765" },
- { BGE_ASICREV_BCM57766, "unknown BCM57766" },
+ { BGE_ASICREV_BCM5719, "unknown BCM5719" },
+ { BGE_ASICREV_BCM5720, "unknown BCM5720" },
{ 0, NULL }
};
@@ -768,16 +796,23 @@
{
pcireg_t val;
+ if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906 &&
+ off >= BGE_STATS_BLOCK && off < BGE_SEND_RING_1_TO_4)
+ return 0;
+
pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_BASEADDR, off);
val = pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_DATA);
+ pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_BASEADDR, 0);
return val;
}
static void
bge_writemem_ind(struct bge_softc *sc, int off, int val)
{
+
pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_BASEADDR, off);
pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_DATA, val);
+ pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_BASEADDR, 0);
}
/*
@@ -790,16 +825,20 @@
val = pci_conf_read(sc->sc_pc, sc->sc_pcitag, sc->bge_pciecap
+ PCI_PCIE_DCSR);
- if ((val & PCI_PCIE_DCSR_MAX_READ_REQ) !=
- BGE_PCIE_DEVCTL_MAX_READRQ_4096) {
- aprint_verbose_dev(sc->bge_dev,
- "adjust device control 0x%04x ", val);
- val &= ~PCI_PCIE_DCSR_MAX_READ_REQ;
+ val &= ~PCI_PCIE_DCSR_MAX_READ_REQ;
+ switch (sc->bge_expmrq) {
+ case 2048:
+ val |= BGE_PCIE_DEVCTL_MAX_READRQ_2048;
+ break;
+ case 4096:
val |= BGE_PCIE_DEVCTL_MAX_READRQ_4096;
- pci_conf_write(sc->sc_pc, sc->sc_pcitag, sc->bge_pciecap
- + PCI_PCIE_DCSR, val);
- aprint_verbose("-> 0x%04x\n", val);
+ break;
+ default:
+ panic("incorrect expmrq value(%d)", sc->bge_expmrq);
+ break;
}
+ pci_conf_write(sc->sc_pc, sc->sc_pcitag, sc->bge_pciecap
+ + PCI_PCIE_DCSR, val);
}
#ifdef notdef
@@ -842,6 +881,324 @@
CSR_WRITE_4_FLUSH(sc, off, val);
}
+/*
+ * Clear all stale locks and select the lock for this driver instance.
+ */
+void
+bge_ape_lock_init(struct bge_softc *sc)
+{
+ struct pci_attach_args *pa = &(sc->bge_pa);
+ uint32_t bit, regbase;
+ int i;
+
+ if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5761)
+ regbase = BGE_APE_LOCK_GRANT;
+ else
+ regbase = BGE_APE_PER_LOCK_GRANT;
+
+ /* Clear any stale locks. */
+ for (i = BGE_APE_LOCK_PHY0; i <= BGE_APE_LOCK_GPIO; i++) {
+ switch (i) {
+ case BGE_APE_LOCK_PHY0:
+ case BGE_APE_LOCK_PHY1:
+ case BGE_APE_LOCK_PHY2:
+ case BGE_APE_LOCK_PHY3:
+ bit = BGE_APE_LOCK_GRANT_DRIVER0;
+ break;
+ default:
+ if (pa->pa_function != 0)
+ bit = BGE_APE_LOCK_GRANT_DRIVER0;
+ else
+ bit = (1 << pa->pa_function);
+ }
+ APE_WRITE_4(sc, regbase + 4 * i, bit);
+ }
+
+ /* Select the PHY lock based on the device's function number. */
+ switch (pa->pa_function) {
+ case 0:
+ sc->bge_phy_ape_lock = BGE_APE_LOCK_PHY0;
+ break;
+ case 1:
+ sc->bge_phy_ape_lock = BGE_APE_LOCK_PHY1;
+ break;
+ case 2:
+ sc->bge_phy_ape_lock = BGE_APE_LOCK_PHY2;
+ break;
+ case 3:
+ sc->bge_phy_ape_lock = BGE_APE_LOCK_PHY3;
+ break;
+ default:
+ printf("%s: PHY lock not supported on function\n",
+ device_xname(sc->bge_dev));
+ break;
+ }
+}
+
+/*
+ * Check for APE firmware, set flags, and print version info.
+ */
+void
+bge_ape_read_fw_ver(struct bge_softc *sc)
+{
+ const char *fwtype;
+ uint32_t apedata, features;
+
+ /* Check for a valid APE signature in shared memory. */
+ apedata = APE_READ_4(sc, BGE_APE_SEG_SIG);
+ if (apedata != BGE_APE_SEG_SIG_MAGIC) {
+ sc->bge_mfw_flags &= ~ BGE_MFW_ON_APE;
+ return;
+ }
+
+ /* Check if APE firmware is running. */
+ apedata = APE_READ_4(sc, BGE_APE_FW_STATUS);
+ if ((apedata & BGE_APE_FW_STATUS_READY) == 0) {
+ printf("%s: APE signature found but FW status not ready! "
+ "0x%08x\n", device_xname(sc->bge_dev), apedata);
+ return;
+ }
+
+ sc->bge_mfw_flags |= BGE_MFW_ON_APE;
+
+ /* Fetch the APE firwmare type and version. */
+ apedata = APE_READ_4(sc, BGE_APE_FW_VERSION);
+ features = APE_READ_4(sc, BGE_APE_FW_FEATURES);
+ if ((features & BGE_APE_FW_FEATURE_NCSI) != 0) {
+ sc->bge_mfw_flags |= BGE_MFW_TYPE_NCSI;
+ fwtype = "NCSI";
+ } else if ((features & BGE_APE_FW_FEATURE_DASH) != 0) {
+ sc->bge_mfw_flags |= BGE_MFW_TYPE_DASH;
+ fwtype = "DASH";
+ } else
+ fwtype = "UNKN";
+
+ /* Print the APE firmware version. */
+ printf(", APE firmware %s %d.%d.%d.%d", fwtype,
Home |
Main Index |
Thread Index |
Old Index