diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-10-25 19:40:15 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-10-25 19:40:15 +0000 |
commit | f58036892d1c192debc42d78dc8234abb13c1bca (patch) | |
tree | 88cfa8106914eb49c3562a576da001cac29de9e6 /sys/dev/pci/if_wi_pci.c | |
parent | 18afe60068a5a19fbc93cd6522eb2882223286ad (diff) |
implement "the other" pci interface for wavelans, found on intersil
mini-pci cards. inspired by the netbsd's if_wi_pci.c .
rename WI_COR_* into WI_PLX_COR_*, per millert@'s suggestion.
tested by millert@ for the plx-based cards.
Diffstat (limited to 'sys/dev/pci/if_wi_pci.c')
-rw-r--r-- | sys/dev/pci/if_wi_pci.c | 90 |
1 files changed, 61 insertions, 29 deletions
diff --git a/sys/dev/pci/if_wi_pci.c b/sys/dev/pci/if_wi_pci.c index ed42b43594a..61c5b0412bc 100644 --- a/sys/dev/pci/if_wi_pci.c +++ b/sys/dev/pci/if_wi_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi_pci.c,v 1.8 2001/10/24 17:33:44 millert Exp $ */ +/* $OpenBSD: if_wi_pci.c,v 1.9 2001/10/25 19:40:14 mickey Exp $ */ /* * Copyright (c) 2001 Todd C. Miller <Todd.Miller@courtesan.com> @@ -108,11 +108,13 @@ #include <dev/ic/if_wi_ieee.h> #include <dev/ic/if_wivar.h> +#define WI_PCI_CBMA 0x10 #define WI_PCI_PLX_LOMEM 0x10 /* PLX chip membase */ #define WI_PCI_PLX_LOIO 0x14 /* PLX chip iobase */ #define WI_PCI_LOMEM 0x18 /* ISA membase */ #define WI_PCI_LOIO 0x1C /* ISA iobase */ +const struct wi_pci_product *wi_pci_lookup __P((struct pci_attach_args *pa)); int wi_pci_match __P((struct device *, void *, void *)); void wi_pci_attach __P((struct device *, struct device *, void *)); int wi_intr __P((void *)); @@ -125,31 +127,39 @@ struct cfattach wi_pci_ca = { static const struct wi_pci_product { pci_vendor_id_t pp_vendor; pci_product_id_t pp_product; + int pp_plx; } wi_pci_products[] = { - { PCI_VENDOR_GLOBALSUN, PCI_PRODUCT_GLOBALSUN_GL24110P }, - { PCI_VENDOR_GLOBALSUN, PCI_PRODUCT_GLOBALSUN_GL24110P02 }, - { PCI_VENDOR_EUMITCOM, PCI_PRODUCT_EUMITCOM_WL11000P }, - { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CRWE777A }, - { PCI_VENDOR_NETGEAR, PCI_PRODUCT_NETGEAR_MA301 }, + { PCI_VENDOR_GLOBALSUN, PCI_PRODUCT_GLOBALSUN_GL24110P, 1 }, + { PCI_VENDOR_GLOBALSUN, PCI_PRODUCT_GLOBALSUN_GL24110P02, 1 }, + { PCI_VENDOR_EUMITCOM, PCI_PRODUCT_EUMITCOM_WL11000P, 1 }, + { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CRWE777A, 1 }, + { PCI_VENDOR_NETGEAR, PCI_PRODUCT_NETGEAR_MA301, 1 }, + { PCI_VENDOR_INTERSIL, PCI_PRODUCT_INTERSIL_MINI_PCI_WLAN, 0 }, { 0, 0 } }; -int -wi_pci_match(parent, match, aux) - struct device *parent; - void *match; - void *aux; +const struct wi_pci_product * +wi_pci_lookup(pa) + struct pci_attach_args *pa; { - struct pci_attach_args *pa = aux; const struct wi_pci_product *pp; for (pp = wi_pci_products; pp->pp_product != 0; pp++) { if (PCI_VENDOR(pa->pa_id) == pp->pp_vendor && PCI_PRODUCT(pa->pa_id) == pp->pp_product) - return(1); + return (pp); } - return(0); + return (NULL); +} + +int +wi_pci_match(parent, match, aux) + struct device *parent; + void *match; + void *aux; +{ + return (wi_pci_lookup(aux) != NULL); } void @@ -160,6 +170,7 @@ wi_pci_attach(parent, self, aux) { struct wi_softc *sc = (struct wi_softc *)self; struct pci_attach_args *pa = aux; + const struct wi_pci_product *pp; pci_intr_handle_t ih; bus_space_handle_t ioh, memh; bus_space_tag_t iot = pa->pa_iot; @@ -168,17 +179,30 @@ wi_pci_attach(parent, self, aux) pcireg_t csr; const char *intrstr; - /* Map memory and I/O registers. */ - if (pci_mapreg_map(pa, WI_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, - &memt, &memh, NULL, NULL, 0) != 0) { - printf(": can't map mem space\n"); - return; - } - if (pci_mapreg_map(pa, WI_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, - &iot, &ioh, NULL, NULL, 0) != 0) { - printf(": can't map I/O space\n"); - return; + pp = wi_pci_lookup(pa); + if (pp->pp_plx) { + /* Map memory and I/O registers. */ + if (pci_mapreg_map(pa, WI_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, + &memt, &memh, NULL, NULL, 0) != 0) { + printf(": can't map mem space\n"); + return; + } + if (pci_mapreg_map(pa, WI_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, + &iot, &ioh, NULL, NULL, 0) != 0) { + printf(": can't map I/O space\n"); + return; + } + } else { + if (pci_mapreg_map(pa, WI_PCI_CBMA, PCI_MAPREG_TYPE_MEM, + 0, &iot, &ioh, NULL, NULL, 0) != 0) { + printf(": can't map mem space\n"); + return; + } + + memt = iot; + memh = ioh; } + sc->wi_btag = iot; sc->wi_bhandle = ioh; @@ -208,11 +232,19 @@ wi_pci_attach(parent, self, aux) } printf(": %s", intrstr); - /* - * Setup the PLX chip for level interrupts and config index 1 - * XXX - should really reset the PLX chip too. - */ - bus_space_write_1(memt, memh, WI_COR_OFFSET, WI_COR_VALUE); + if (pp->pp_plx) + /* + * Setup the PLX chip for level interrupts and config index 1 + * XXX - should really reset the PLX chip too. + */ + bus_space_write_1(memt, memh, + WI_PLX_COR_OFFSET, WI_PLX_COR_VALUE); + else { + bus_space_write_2(iot, ioh, WI_PCI_COR, WI_PCI_SOFT_RESET); + DELAY(100*1000); /* 100 m sec */ + bus_space_write_2(iot, ioh, WI_PCI_COR, 0x0); + DELAY(100*1000); /* 100 m sec */ + } wi_attach(sc, 1); } |