2004-08-22 02:48:18 +04:00
|
|
|
/* $NetBSD: if_wi_pci.c,v 1.35 2004/08/21 22:48:18 thorpej Exp $ */
|
2001-10-13 19:00:23 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Hideaki Imaizumi <hiddy@sfc.wide.ad.jp>
|
|
|
|
* and Ichiro FUKUHARA (ichiro@ichiro.org).
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCI bus front-end for the Intersil PCI WaveLan.
|
|
|
|
* Works with Prism2.5 Mini-PCI wavelan.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 10:48:40 +03:00
|
|
|
#include <sys/cdefs.h>
|
2004-08-22 02:48:18 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: if_wi_pci.c,v 1.35 2004/08/21 22:48:18 thorpej Exp $");
|
2001-11-13 10:48:40 +03:00
|
|
|
|
2001-10-13 19:00:23 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/callout.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_ether.h>
|
|
|
|
#include <net/if_media.h>
|
2003-10-13 12:07:21 +04:00
|
|
|
|
|
|
|
#include <net80211/ieee80211_var.h>
|
|
|
|
#include <net80211/ieee80211_compat.h>
|
2003-11-16 12:02:42 +03:00
|
|
|
#include <net80211/ieee80211_radiotap.h>
|
2003-12-07 08:44:49 +03:00
|
|
|
#include <net80211/ieee80211_rssadapt.h>
|
2001-10-13 19:00:23 +04:00
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/intr.h>
|
|
|
|
|
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcidevs.h>
|
|
|
|
|
|
|
|
#include <dev/ic/wi_ieee.h>
|
|
|
|
#include <dev/ic/wireg.h>
|
|
|
|
#include <dev/ic/wivar.h>
|
|
|
|
|
2002-10-21 15:57:25 +04:00
|
|
|
#define WI_PCI_CBMA 0x10 /* Configuration Base Memory Address */
|
2002-01-13 22:38:25 +03:00
|
|
|
#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 */
|
|
|
|
|
2003-04-12 12:17:45 +04:00
|
|
|
#define CHIP_PLX_OTHER 0x01
|
|
|
|
#define CHIP_PLX_9052 0x02
|
2003-12-14 13:04:33 +03:00
|
|
|
#define CHIP_TMD_7160 0x03
|
2003-04-12 12:17:45 +04:00
|
|
|
|
2002-01-13 22:38:25 +03:00
|
|
|
#define WI_PLX_COR_OFFSET 0x3E0
|
|
|
|
#define WI_PLX_COR_VALUE 0x41
|
|
|
|
|
2001-10-13 19:00:23 +04:00
|
|
|
struct wi_pci_softc {
|
|
|
|
struct wi_softc psc_wi; /* real "wi" softc */
|
|
|
|
|
|
|
|
/* PCI-specific goo */
|
|
|
|
pci_intr_handle_t psc_ih;
|
2003-09-29 18:10:35 +04:00
|
|
|
pci_chipset_tag_t psc_pc;
|
2001-10-13 19:00:23 +04:00
|
|
|
|
|
|
|
void *sc_powerhook; /* power hook descriptor */
|
|
|
|
};
|
|
|
|
|
2004-08-22 02:48:18 +04:00
|
|
|
static int wi_pci_match(struct device *, struct cfdata *, void *);
|
|
|
|
static void wi_pci_attach(struct device *, struct device *, void *);
|
|
|
|
static int wi_pci_enable(struct wi_softc *);
|
|
|
|
static void wi_pci_disable(struct wi_softc *);
|
|
|
|
static void wi_pci_reset(struct wi_softc *);
|
|
|
|
static void wi_pci_powerhook(int, void *);
|
2001-10-13 19:00:23 +04:00
|
|
|
|
|
|
|
static const struct wi_pci_product
|
2004-08-22 02:48:18 +04:00
|
|
|
*wi_pci_lookup(struct pci_attach_args *);
|
2001-10-13 19:00:23 +04:00
|
|
|
|
2002-10-01 00:37:04 +04:00
|
|
|
CFATTACH_DECL(wi_pci, sizeof(struct wi_pci_softc),
|
2002-10-02 20:51:16 +04:00
|
|
|
wi_pci_match, wi_pci_attach, NULL, NULL);
|
2001-10-13 19:00:23 +04:00
|
|
|
|
2004-08-22 02:48:18 +04:00
|
|
|
static const struct wi_pci_product {
|
2001-10-13 19:00:23 +04:00
|
|
|
pci_vendor_id_t wpp_vendor; /* vendor ID */
|
|
|
|
pci_product_id_t wpp_product; /* product ID */
|
2003-12-14 13:04:33 +03:00
|
|
|
int wpp_chip; /* uses other chip */
|
2001-10-13 19:00:23 +04:00
|
|
|
} wi_pci_products[] = {
|
2002-01-13 22:38:25 +03:00
|
|
|
{ PCI_VENDOR_GLOBALSUN, PCI_PRODUCT_GLOBALSUN_GL24110P,
|
2004-07-18 00:05:39 +04:00
|
|
|
CHIP_PLX_OTHER },
|
2002-01-13 22:38:25 +03:00
|
|
|
{ PCI_VENDOR_GLOBALSUN, PCI_PRODUCT_GLOBALSUN_GL24110P02,
|
2004-07-18 00:05:39 +04:00
|
|
|
CHIP_PLX_OTHER },
|
2002-01-13 22:38:25 +03:00
|
|
|
{ PCI_VENDOR_EUMITCOM, PCI_PRODUCT_EUMITCOM_WL11000P,
|
2004-07-18 00:05:39 +04:00
|
|
|
CHIP_PLX_OTHER },
|
2002-01-13 22:38:25 +03:00
|
|
|
{ PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CRWE777A,
|
2004-07-18 00:05:39 +04:00
|
|
|
CHIP_PLX_OTHER },
|
2002-01-13 22:38:25 +03:00
|
|
|
{ PCI_VENDOR_NETGEAR, PCI_PRODUCT_NETGEAR_MA301,
|
2004-07-18 00:05:39 +04:00
|
|
|
CHIP_PLX_OTHER },
|
2001-10-13 19:00:23 +04:00
|
|
|
{ PCI_VENDOR_INTERSIL, PCI_PRODUCT_INTERSIL_MINI_PCI_WLAN,
|
2004-07-18 00:05:39 +04:00
|
|
|
0 },
|
2003-03-28 16:58:40 +03:00
|
|
|
{ PCI_VENDOR_NDC, PCI_PRODUCT_NDC_NCP130,
|
2004-07-18 00:05:39 +04:00
|
|
|
CHIP_PLX_9052 },
|
2003-03-29 23:49:03 +03:00
|
|
|
{ PCI_VENDOR_USR2, PCI_PRODUCT_USR2_2415,
|
2004-07-18 00:05:39 +04:00
|
|
|
CHIP_PLX_OTHER },
|
2003-12-14 13:04:33 +03:00
|
|
|
{ PCI_VENDOR_NDC, PCI_PRODUCT_NDC_NCP130A2,
|
2004-07-18 00:05:39 +04:00
|
|
|
CHIP_TMD_7160 },
|
2001-10-13 19:00:23 +04:00
|
|
|
{ 0, 0,
|
2004-07-18 00:05:39 +04:00
|
|
|
0},
|
2001-10-13 19:00:23 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2004-08-22 02:48:18 +04:00
|
|
|
wi_pci_enable(struct wi_softc *sc)
|
2001-10-13 19:00:23 +04:00
|
|
|
{
|
|
|
|
struct wi_pci_softc *psc = (struct wi_pci_softc *)sc;
|
|
|
|
|
|
|
|
/* establish the interrupt. */
|
2003-09-29 18:10:35 +04:00
|
|
|
sc->sc_ih = pci_intr_establish(psc->psc_pc,
|
2001-10-13 19:00:23 +04:00
|
|
|
psc->psc_ih, IPL_NET, wi_intr, sc);
|
|
|
|
if (sc->sc_ih == NULL) {
|
|
|
|
printf("%s: couldn't establish interrupt\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reset HFA3842 MAC core */
|
2004-03-28 13:44:59 +04:00
|
|
|
if (sc->sc_reset != NULL)
|
|
|
|
wi_pci_reset(sc);
|
2001-10-13 19:00:23 +04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-08-22 02:48:18 +04:00
|
|
|
wi_pci_disable(struct wi_softc *sc)
|
2001-10-13 19:00:23 +04:00
|
|
|
{
|
|
|
|
struct wi_pci_softc *psc = (struct wi_pci_softc *)sc;
|
|
|
|
|
2003-09-29 18:10:35 +04:00
|
|
|
pci_intr_disestablish(psc->psc_pc, sc->sc_ih);
|
2001-10-13 19:00:23 +04:00
|
|
|
}
|
|
|
|
|
2002-04-04 21:43:31 +04:00
|
|
|
static void
|
2004-08-22 02:48:18 +04:00
|
|
|
wi_pci_reset(struct wi_softc *sc)
|
2002-04-04 21:43:31 +04:00
|
|
|
{
|
2002-09-23 18:12:35 +04:00
|
|
|
int i, secs, usecs;
|
2002-04-04 21:43:31 +04:00
|
|
|
|
2003-06-30 02:28:00 +04:00
|
|
|
bus_space_write_2(sc->sc_iot, sc->sc_ioh,
|
|
|
|
WI_PCI_COR, WI_COR_SOFT_RESET);
|
2002-09-23 18:12:35 +04:00
|
|
|
DELAY(250*1000); /* 1/4 second */
|
|
|
|
|
2003-06-30 02:28:00 +04:00
|
|
|
bus_space_write_2(sc->sc_iot, sc->sc_ioh,
|
|
|
|
WI_PCI_COR, WI_COR_CLEAR);
|
2002-09-23 18:12:35 +04:00
|
|
|
DELAY(500*1000); /* 1/2 second */
|
|
|
|
|
|
|
|
/* wait 2 seconds for firmware to complete initialization. */
|
|
|
|
|
|
|
|
for (i = 200000; i--; DELAY(10))
|
|
|
|
if (!(CSR_READ_2(sc, WI_COMMAND) & WI_CMD_BUSY))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (i < 0) {
|
|
|
|
printf("%s: PCI reset timed out\n", sc->sc_dev.dv_xname);
|
2002-09-30 10:29:29 +04:00
|
|
|
} else if (sc->sc_if.if_flags & IFF_DEBUG) {
|
2002-09-23 18:12:35 +04:00
|
|
|
usecs = (200000 - i) * 10;
|
|
|
|
secs = usecs / 1000000;
|
|
|
|
usecs %= 1000000;
|
|
|
|
|
|
|
|
printf("%s: PCI reset in %d.%06d seconds\n",
|
|
|
|
sc->sc_dev.dv_xname, secs, usecs);
|
|
|
|
}
|
2002-04-04 21:43:31 +04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-10-13 19:00:23 +04:00
|
|
|
static const struct wi_pci_product *
|
2004-08-22 02:48:18 +04:00
|
|
|
wi_pci_lookup(struct pci_attach_args *pa)
|
2001-10-13 19:00:23 +04:00
|
|
|
{
|
|
|
|
const struct wi_pci_product *wpp;
|
|
|
|
|
2002-01-13 22:38:25 +03:00
|
|
|
for (wpp = wi_pci_products; wpp->wpp_vendor != 0; wpp++) {
|
2001-10-13 19:00:23 +04:00
|
|
|
if (PCI_VENDOR(pa->pa_id) == wpp->wpp_vendor &&
|
|
|
|
PCI_PRODUCT(pa->pa_id) == wpp->wpp_product)
|
|
|
|
return (wpp);
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-08-22 02:48:18 +04:00
|
|
|
wi_pci_match(struct device *parent, struct cfdata *match, void *aux)
|
2001-10-13 19:00:23 +04:00
|
|
|
{
|
|
|
|
struct pci_attach_args *pa = aux;
|
|
|
|
|
|
|
|
if (wi_pci_lookup(pa) != NULL)
|
|
|
|
return (1);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-08-22 02:48:18 +04:00
|
|
|
wi_pci_attach(struct device *parent, struct device *self, void *aux)
|
2001-10-13 19:00:23 +04:00
|
|
|
{
|
|
|
|
struct wi_pci_softc *psc = (struct wi_pci_softc *)self;
|
|
|
|
struct wi_softc *sc = &psc->psc_wi;
|
|
|
|
struct pci_attach_args *pa = aux;
|
|
|
|
pci_chipset_tag_t pc = pa->pa_pc;
|
|
|
|
const char *intrstr;
|
|
|
|
const struct wi_pci_product *wpp;
|
|
|
|
pci_intr_handle_t ih;
|
2003-12-14 13:04:33 +03:00
|
|
|
bus_space_tag_t memt, iot, plxt, tmdt;
|
|
|
|
bus_space_handle_t memh, ioh, plxh, tmdh;
|
2001-10-13 19:00:23 +04:00
|
|
|
|
2003-09-29 18:10:35 +04:00
|
|
|
psc->psc_pc = pc;
|
2001-10-13 19:00:23 +04:00
|
|
|
|
2002-01-15 16:50:59 +03:00
|
|
|
wpp = wi_pci_lookup(pa);
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (wpp == NULL) {
|
|
|
|
printf("\n");
|
|
|
|
panic("wi_pci_attach: impossible");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-12-14 13:04:33 +03:00
|
|
|
switch (wpp->wpp_chip) {
|
|
|
|
case CHIP_PLX_OTHER:
|
|
|
|
case CHIP_PLX_9052:
|
2002-01-13 22:38:25 +03:00
|
|
|
/* Map memory and I/O registers. */
|
|
|
|
if (pci_mapreg_map(pa, WI_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0,
|
|
|
|
&memt, &memh, NULL, NULL) != 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) {
|
|
|
|
printf(": can't map I/O space\n");
|
|
|
|
return;
|
|
|
|
}
|
2003-04-12 12:17:45 +04:00
|
|
|
|
2003-12-14 13:04:33 +03:00
|
|
|
if (wpp->wpp_chip == CHIP_PLX_OTHER) {
|
2003-04-12 12:17:45 +04:00
|
|
|
/* The PLX 9052 doesn't have IO at 0x14. Perhaps
|
|
|
|
other chips have, so we'll make this conditional. */
|
|
|
|
if (pci_mapreg_map(pa, WI_PCI_PLX_LOIO,
|
|
|
|
PCI_MAPREG_TYPE_IO, 0, &plxt,
|
|
|
|
&plxh, NULL, NULL) != 0) {
|
|
|
|
printf(": can't map PLX\n");
|
|
|
|
return;
|
|
|
|
}
|
2003-03-29 06:25:22 +03:00
|
|
|
}
|
2003-12-14 13:04:33 +03:00
|
|
|
break;
|
|
|
|
case CHIP_TMD_7160:
|
|
|
|
/* Used instead of PLX on at least one revision of
|
|
|
|
* the National Datacomm Corporation NCP130. Values
|
|
|
|
* for registers acquired from OpenBSD, which in
|
|
|
|
* turn got them from a Linux driver.
|
|
|
|
*/
|
|
|
|
/* Map COR and I/O registers. */
|
|
|
|
if (pci_mapreg_map(pa, WI_TMD_COR, PCI_MAPREG_TYPE_IO, 0,
|
|
|
|
&tmdt, &tmdh, NULL, NULL) != 0) {
|
|
|
|
printf(": can't map TMD\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (pci_mapreg_map(pa, WI_TMD_IO, PCI_MAPREG_TYPE_IO, 0,
|
|
|
|
&iot, &ioh, NULL, NULL) != 0) {
|
|
|
|
printf(": can't map I/O space\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2002-01-13 22:38:25 +03:00
|
|
|
if (pci_mapreg_map(pa, WI_PCI_CBMA,
|
|
|
|
PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
|
|
|
|
0, &iot, &ioh, NULL, NULL) != 0) {
|
|
|
|
printf(": can't map mem space\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memt = iot;
|
|
|
|
memh = ioh;
|
|
|
|
sc->sc_pci = 1;
|
2003-12-14 13:04:33 +03:00
|
|
|
break;
|
2001-10-13 19:00:23 +04:00
|
|
|
}
|
|
|
|
|
2004-07-18 00:05:39 +04:00
|
|
|
{
|
2002-01-13 22:38:25 +03:00
|
|
|
char devinfo[256];
|
|
|
|
|
2004-04-24 01:13:05 +04:00
|
|
|
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
|
2002-01-13 22:38:25 +03:00
|
|
|
printf(": %s (rev. 0x%02x)\n", devinfo,
|
|
|
|
PCI_REVISION(pa->pa_class));
|
|
|
|
}
|
2001-10-13 19:00:23 +04:00
|
|
|
|
|
|
|
sc->sc_enabled = 1;
|
|
|
|
sc->sc_enable = wi_pci_enable;
|
|
|
|
sc->sc_disable = wi_pci_disable;
|
|
|
|
|
2002-01-13 22:38:25 +03:00
|
|
|
sc->sc_iot = iot;
|
|
|
|
sc->sc_ioh = ioh;
|
|
|
|
/* Make sure interrupts are disabled. */
|
|
|
|
CSR_WRITE_2(sc, WI_INT_EN, 0);
|
|
|
|
CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
|
2001-10-13 19:00:23 +04:00
|
|
|
|
2003-12-14 13:04:33 +03:00
|
|
|
if (wpp->wpp_chip == CHIP_PLX_OTHER) {
|
2003-03-29 06:25:22 +03:00
|
|
|
uint32_t command;
|
|
|
|
#define WI_LOCAL_INTCSR 0x4c
|
|
|
|
#define WI_LOCAL_INTEN 0x40 /* poke this into INTCSR */
|
|
|
|
|
|
|
|
command = bus_space_read_4(plxt, plxh, WI_LOCAL_INTCSR);
|
|
|
|
command |= WI_LOCAL_INTEN;
|
|
|
|
bus_space_write_4(plxt, plxh, WI_LOCAL_INTCSR, command);
|
|
|
|
}
|
|
|
|
|
2001-10-13 19:00:23 +04:00
|
|
|
/* Map and establish the interrupt. */
|
|
|
|
if (pci_intr_map(pa, &ih)) {
|
2004-08-07 21:13:27 +04:00
|
|
|
printf("%s: couldn't map interrupt\n", self->dv_xname);
|
2001-10-13 19:00:23 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
intrstr = pci_intr_string(pc, ih);
|
|
|
|
|
|
|
|
psc->psc_ih = ih;
|
|
|
|
sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, wi_intr, sc);
|
|
|
|
if (sc->sc_ih == NULL) {
|
2004-08-07 21:13:27 +04:00
|
|
|
printf("%s: couldn't establish interrupt", self->dv_xname);
|
2001-10-13 19:00:23 +04:00
|
|
|
if (intrstr != NULL)
|
|
|
|
printf(" at %s", intrstr);
|
|
|
|
printf("\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-08-07 21:13:27 +04:00
|
|
|
printf("%s: interrupting at %s\n", self->dv_xname, intrstr);
|
2001-10-13 19:00:23 +04:00
|
|
|
|
2003-12-14 13:04:33 +03:00
|
|
|
switch (wpp->wpp_chip) {
|
|
|
|
case CHIP_PLX_OTHER:
|
|
|
|
case CHIP_PLX_9052:
|
2002-01-13 22:38:25 +03:00
|
|
|
/*
|
|
|
|
* 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);
|
2003-12-14 13:04:33 +03:00
|
|
|
break;
|
|
|
|
case CHIP_TMD_7160:
|
|
|
|
/* Enable I/O mode and level interrupts on the embedded
|
|
|
|
* card. The card's COR is the first byte of BAR 0.
|
|
|
|
*/
|
|
|
|
bus_space_write_1(tmdt, tmdh, 0, WI_COR_IOMODE);
|
|
|
|
break;
|
|
|
|
default:
|
2002-01-13 22:38:25 +03:00
|
|
|
/* reset HFA3842 MAC core */
|
|
|
|
wi_pci_reset(sc);
|
2003-12-14 13:04:33 +03:00
|
|
|
break;
|
2002-01-13 22:38:25 +03:00
|
|
|
}
|
2001-10-13 19:00:23 +04:00
|
|
|
|
2004-08-07 21:13:27 +04:00
|
|
|
printf("%s:", self->dv_xname);
|
|
|
|
|
|
|
|
if (wi_attach(sc, 0) != 0) {
|
|
|
|
printf("%s: failed to attach controller\n", self->dv_xname);
|
2001-10-13 19:00:23 +04:00
|
|
|
pci_intr_disestablish(pa->pa_pc, sc->sc_ih);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-28 13:44:59 +04:00
|
|
|
if (!wpp->wpp_chip)
|
|
|
|
sc->sc_reset = wi_pci_reset;
|
2003-03-27 07:34:16 +03:00
|
|
|
|
2001-10-13 19:00:23 +04:00
|
|
|
/* Add a suspend hook to restore PCI config state */
|
|
|
|
psc->sc_powerhook = powerhook_establish(wi_pci_powerhook, psc);
|
|
|
|
if (psc->sc_powerhook == NULL)
|
2004-08-07 21:13:27 +04:00
|
|
|
printf("%s: WARNING: unable to establish pci power hook\n",
|
|
|
|
self->dv_xname);
|
2001-10-13 19:00:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-08-22 02:48:18 +04:00
|
|
|
wi_pci_powerhook(int why, void *arg)
|
2001-10-13 19:00:23 +04:00
|
|
|
{
|
|
|
|
struct wi_pci_softc *psc = arg;
|
|
|
|
struct wi_softc *sc = &psc->psc_wi;
|
|
|
|
|
|
|
|
wi_power(sc, why);
|
|
|
|
}
|