summaryrefslogtreecommitdiffstats
path: root/sys/dev/pci/sili_pci.c
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2007-03-31 03:11:38 +0000
committerdlg <dlg@openbsd.org>2007-03-31 03:11:38 +0000
commit9b92dcd6389ca6423e9645365644ee4909b0d095 (patch)
tree4caf2470fc8812ab1f444d4abb54fc89960acc28 /sys/dev/pci/sili_pci.c
parentMake volume state transitions work (diff)
downloadwireguard-openbsd-9b92dcd6389ca6423e9645365644ee4909b0d095.tar.xz
wireguard-openbsd-9b92dcd6389ca6423e9645365644ee4909b0d095.zip
the attach glue now specifies how many ports the chip has.
Diffstat (limited to 'sys/dev/pci/sili_pci.c')
-rw-r--r--sys/dev/pci/sili_pci.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/sys/dev/pci/sili_pci.c b/sys/dev/pci/sili_pci.c
index 80ed7757c33..1c5eb10b345 100644
--- a/sys/dev/pci/sili_pci.c
+++ b/sys/dev/pci/sili_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sili_pci.c,v 1.2 2007/03/22 06:32:14 dlg Exp $ */
+/* $OpenBSD: sili_pci.c,v 1.3 2007/03/31 03:11:38 dlg Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -49,15 +49,38 @@ struct cfattach sili_pci_ca = {
sili_pci_detach
};
-static const struct pci_matchid sili_devices[] = {
- { PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_3124 }
+struct sili_device {
+ pci_vendor_id_t sd_vendor;
+ pci_product_id_t sd_product;
+ u_int sd_nports;
};
+const struct sili_device *sili_lookup(struct pci_attach_args *);
+
+static const struct sili_device sili_devices[] = {
+ { PCI_VENDOR_CMDTECH, PCI_PRODUCT_CMDTECH_3124, 4 }
+};
+
+const struct sili_device *
+sili_lookup(struct pci_attach_args *pa)
+{
+ int i;
+ const struct sili_device *sd;
+
+ for (i = 0; i < (sizeof(sili_devices) / sizeof(sili_devices[0])); i++) {
+ sd = &sili_devices[i];
+ if (sd->sd_vendor == PCI_VENDOR(pa->pa_id) &&
+ sd->sd_product == PCI_PRODUCT(pa->pa_id))
+ return (sd);
+ }
+
+ return (NULL);
+}
+
int
sili_pci_match(struct device *parent, void *match, void *aux)
{
- return (pci_matchbyid((struct pci_attach_args *)aux, sili_devices,
- sizeof(sili_devices) / sizeof(sili_devices[0])));
+ return (sili_lookup((struct pci_attach_args *)aux) != NULL);
}
void
@@ -66,16 +89,20 @@ sili_pci_attach(struct device *parent, struct device *self, void *aux)
struct sili_pci_softc *psc = (void *)self;
struct sili_softc *sc = &psc->psc_sili;
struct pci_attach_args *pa = aux;
+ const struct sili_device *sd;
pcireg_t memtype;
pci_intr_handle_t ih;
const char *intrstr;
+ sd = sili_lookup(pa);
+
psc->psc_pc = pa->pa_pc;
psc->psc_tag = pa->pa_tag;
psc->psc_ih = NULL;
sc->sc_dmat = pa->pa_dmat;
sc->sc_ios_global = 0;
sc->sc_ios_port = 0;
+ sc->sc_nports = sd->sd_nports;
memtype = pci_mapreg_type(psc->psc_pc, psc->psc_tag,
SILI_PCI_BAR_GLOBAL);