summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2007-04-27 14:54:11 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2007-04-27 14:54:11 +0000
commit8211cc7a5d2dea315539e12659b022b273855a70 (patch)
treed412f96b0e9e9ca3d0eccefdf94ba896c05db352 /sys
parent1e3a465f3d57d2b834c467d9d3e110917a632ec9 (diff)
only attach nx NICs with 128MB memory and a 32bit memory type for now
(the chipset uses a configurable window to access the complete address range).
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/if_nx.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/sys/dev/pci/if_nx.c b/sys/dev/pci/if_nx.c
index b7460e44292..0be5bae956e 100644
--- a/sys/dev/pci/if_nx.c
+++ b/sys/dev/pci/if_nx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_nx.c,v 1.8 2007/04/27 14:50:31 reyk Exp $ */
+/* $OpenBSD: if_nx.c,v 1.9 2007/04/27 14:54:10 reyk Exp $ */
/*
* Copyright (c) 2007 Reyk Floeter <reyk@openbsd.org>
@@ -185,27 +185,51 @@ nxb_attach(struct device *parent, struct device *self, void *aux)
struct pci_attach_args *pa = aux;
pcireg_t memtype;
const char *intrstr;
+ bus_size_t pcisize;
+ paddr_t pciaddr;
int i;
sc->sc_pc = pa->pa_pc;
sc->sc_tag = pa->pa_tag;
sc->sc_dmat = pa->pa_dmat;
-
+
+ /*
+ * The NetXen NICs can have different PCI memory layouts which
+ * need some special handling in the driver. Support is limited
+ * to 32bit 128MB memory for now (the chipset uses a configurable
+ * window to access the complete memory range).
+ */
memtype = pci_mapreg_type(sc->sc_pc, sc->sc_tag, PCI_MAPREG_START);
switch (memtype) {
case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
+ break;
case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
+ default:
+ printf(": invalid memory type: 0x%x\n", memtype);
+ return;
+ }
+ if (pci_mapreg_info(sc->sc_pc, sc->sc_tag, PCI_MAPREG_START,
+ memtype, &pciaddr, &pcisize, NULL)) {
+ printf(": failed to get pci info\n");
+ return;
+ }
+ switch (pcisize) {
+ case NXPCIMEM_SIZE_128MB:
break;
+ case NXPCIMEM_SIZE_32MB:
default:
- printf(": invalid memory type\n");
+ printf(": invalid memory size: %ld\n", pcisize);
return;
}
+
+ /* Finally map the PCI memory space */
if (pci_mapreg_map(pa, PCI_MAPREG_START, memtype, 0, &sc->sc_memt,
&sc->sc_memh, NULL, &sc->sc_mems, 0) != 0) {
printf(": unable to map system interface register\n");
return;
}
+ /* Map the interrupt, the handlers will be attached later */
if (pci_intr_map(pa, &sc->sc_ih) != 0) {
printf(": unable to map interrupt\n");
goto unmap;