Do our io_map()s and intr_establish()es earlier.
This commit is contained in:
parent
af19b73069
commit
2ae40d3e4f
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_ep_pcmcia.c,v 1.44 2004/08/09 15:40:56 mycroft Exp $ */
|
||||
/* $NetBSD: if_ep_pcmcia.c,v 1.45 2004/08/09 18:11:01 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
@ -67,7 +67,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ep_pcmcia.c,v 1.44 2004/08/09 15:40:56 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ep_pcmcia.c,v 1.45 2004/08/09 18:11:01 mycroft Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -180,18 +180,19 @@ ep_pcmcia_enable(sc)
|
||||
struct pcmcia_function *pf = psc->sc_pf;
|
||||
int error;
|
||||
|
||||
if ((error = ep_pcmcia_enable1(sc)) != 0)
|
||||
return error;
|
||||
|
||||
/* establish the interrupt. */
|
||||
sc->sc_ih = pcmcia_intr_establish(pf, IPL_NET, epintr, sc);
|
||||
if (sc->sc_ih == NULL) {
|
||||
printf("%s: couldn't establish interrupt\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
ep_pcmcia_disable1(sc);
|
||||
return (1);
|
||||
}
|
||||
|
||||
if ((error = ep_pcmcia_enable1(sc)) != 0) {
|
||||
pcmcia_intr_disestablish(pf, sc->sc_ih);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -263,71 +264,61 @@ ep_pcmcia_attach(parent, self, aux)
|
||||
int i;
|
||||
|
||||
aprint_normal("\n");
|
||||
|
||||
psc->sc_pf = pa->pf;
|
||||
cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head);
|
||||
|
||||
/* Enable the card. */
|
||||
pcmcia_function_init(pa->pf, cfe);
|
||||
if (ep_pcmcia_enable1(sc)) {
|
||||
aprint_error("%s: function enable failed\n", self->dv_xname);
|
||||
goto enable_failed;
|
||||
}
|
||||
sc->enabled = 1;
|
||||
SIMPLEQ_FOREACH(cfe, &pa->pf->cfe_head, cfe_list) {
|
||||
if (cfe->num_memspace != 0)
|
||||
continue;
|
||||
if (cfe->num_iospace != 1)
|
||||
continue;
|
||||
|
||||
if (cfe->num_memspace != 0) {
|
||||
aprint_error("%s: unexpected number of memory spaces %d should be 0\n",
|
||||
self->dv_xname, cfe->num_memspace);
|
||||
goto ioalloc_failed;
|
||||
}
|
||||
if (pa->product == PCMCIA_PRODUCT_3COM_3C562) {
|
||||
/*
|
||||
* the 3c562 can only use 0x??00-0x??7f
|
||||
* according to the Linux driver
|
||||
*/
|
||||
|
||||
if (cfe->num_iospace != 1) {
|
||||
aprint_error("%s: unexpected number of I/O spaces %d should be 1\n",
|
||||
self->dv_xname, cfe->num_iospace);
|
||||
goto ioalloc_failed;
|
||||
}
|
||||
|
||||
if (pa->product == PCMCIA_PRODUCT_3COM_3C562) {
|
||||
/*
|
||||
* the 3c562 can only use 0x??00-0x??7f
|
||||
* according to the Linux driver
|
||||
*/
|
||||
|
||||
/*
|
||||
* 3c562 i/o may decodes address line not only A0-3
|
||||
* but also A7. Anyway, we must sweep at most
|
||||
* [0x0000, 0x0100). The address higher is given by a
|
||||
* pcmcia bridge. But pcmcia bus-space allocation
|
||||
* function implies cards will decode 10-bit address
|
||||
* line. So we must search [0x0000, 0x0400).
|
||||
*
|
||||
* XXX: We must not check the bunch of I/O space range
|
||||
* [0x400*n, 0x300 + 0x400*n) because they are
|
||||
* reserved for legacy ISA devices and their alias
|
||||
* images on PC/AT architecture.
|
||||
*/
|
||||
for (i = 0x0300; i < 0x0380; i += 0x10) {
|
||||
if (pcmcia_io_alloc(pa->pf, i, cfe->iospace[0].length,
|
||||
0, &psc->sc_pcioh) == 0)
|
||||
/*
|
||||
* 3c562 i/o may decodes address line not only A0-3
|
||||
* but also A7. Anyway, we must sweep at most
|
||||
* [0x0000, 0x0100). The address higher is given by a
|
||||
* pcmcia bridge. But pcmcia bus-space allocation
|
||||
* function implies cards will decode 10-bit address
|
||||
* line. So we must search [0x0000, 0x0400).
|
||||
*
|
||||
* XXX: We must not check the bunch of I/O space range
|
||||
* [0x400*n, 0x300 + 0x400*n) because they are
|
||||
* reserved for legacy ISA devices and their alias
|
||||
* images on PC/AT architecture.
|
||||
*/
|
||||
for (i = 0x0300; i < 0x0380; i += 0x10) {
|
||||
if (pcmcia_io_alloc(pa->pf, i,
|
||||
cfe->iospace[0].length,
|
||||
cfe->iospace[0].length,
|
||||
&psc->sc_pcioh) == 0)
|
||||
break;
|
||||
}
|
||||
if (i != 0x0380)
|
||||
break;
|
||||
} else {
|
||||
if (pcmcia_io_alloc(pa->pf, cfe->iospace[0].start,
|
||||
cfe->iospace[0].length, cfe->iospace[0].length,
|
||||
&psc->sc_pcioh) == 0)
|
||||
break;
|
||||
}
|
||||
if (i == 0x0380) {
|
||||
aprint_error("%s: can't allocate i/o space\n",
|
||||
self->dv_xname);
|
||||
goto ioalloc_failed;
|
||||
}
|
||||
} else {
|
||||
if (pcmcia_io_alloc(pa->pf, 0, cfe->iospace[0].length,
|
||||
cfe->iospace[0].length, &psc->sc_pcioh)) {
|
||||
aprint_error("%s: can't allocate i/o space\n",
|
||||
self->dv_xname);
|
||||
goto ioalloc_failed;
|
||||
}
|
||||
}
|
||||
if (!cfe) {
|
||||
aprint_error("%s: failed to allocate I/O space\n",
|
||||
self->dv_xname);
|
||||
goto ioalloc_failed;
|
||||
}
|
||||
|
||||
sc->sc_iot = psc->sc_pcioh.iot;
|
||||
sc->sc_ioh = psc->sc_pcioh.ioh;
|
||||
|
||||
/* Enable the card. */
|
||||
pcmcia_function_init(pa->pf, cfe);
|
||||
|
||||
if (pcmcia_io_map(pa->pf, ((cfe->flags & PCMCIA_CFE_IO16) ?
|
||||
PCMCIA_WIDTH_AUTO : PCMCIA_WIDTH_IO8), &psc->sc_pcioh,
|
||||
&psc->sc_io_window)) {
|
||||
@ -335,6 +326,12 @@ ep_pcmcia_attach(parent, self, aux)
|
||||
goto iomap_failed;
|
||||
}
|
||||
|
||||
if (ep_pcmcia_enable(sc)) {
|
||||
aprint_error("%s: function enable failed\n", self->dv_xname);
|
||||
goto enable_failed;
|
||||
}
|
||||
sc->enabled = 1;
|
||||
|
||||
switch (pa->product) {
|
||||
case PCMCIA_PRODUCT_3COM_3C562:
|
||||
/*
|
||||
@ -372,22 +369,17 @@ ep_pcmcia_attach(parent, self, aux)
|
||||
}
|
||||
|
||||
sc->enabled = 0;
|
||||
ep_pcmcia_disable1(sc);
|
||||
ep_pcmcia_disable(sc);
|
||||
return;
|
||||
|
||||
config_failed:
|
||||
/* Unmap our i/o window. */
|
||||
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
||||
|
||||
iomap_failed:
|
||||
/* Free our i/o space. */
|
||||
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
||||
|
||||
ioalloc_failed:
|
||||
config_failed:
|
||||
sc->enabled = 0;
|
||||
ep_pcmcia_disable1(sc);
|
||||
|
||||
enable_failed:
|
||||
ep_pcmcia_disable(sc);
|
||||
enable_failed:
|
||||
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
||||
iomap_failed:
|
||||
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
||||
ioalloc_failed:
|
||||
psc->sc_io_window = -1;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_wi_pcmcia.c,v 1.49 2004/08/09 00:33:17 mycroft Exp $ */
|
||||
/* $NetBSD: if_wi_pcmcia.c,v 1.50 2004/08/09 18:11:01 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_wi_pcmcia.c,v 1.49 2004/08/09 00:33:17 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_wi_pcmcia.c,v 1.50 2004/08/09 18:11:01 mycroft Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -102,9 +102,6 @@ struct wi_pcmcia_softc {
|
||||
int sc_symbol_cf; /* Spectrum24t CF card */
|
||||
};
|
||||
|
||||
static int wi_pcmcia_find __P((struct wi_pcmcia_softc *,
|
||||
struct pcmcia_attach_args *, struct pcmcia_config_entry *));
|
||||
|
||||
CFATTACH_DECL(wi_pcmcia, sizeof(struct wi_pcmcia_softc),
|
||||
wi_pcmcia_match, wi_pcmcia_attach, wi_pcmcia_detach, wi_activate);
|
||||
|
||||
@ -321,47 +318,6 @@ wi_pcmcia_disable(sc)
|
||||
pcmcia_function_disable(psc->sc_pf);
|
||||
}
|
||||
|
||||
static int
|
||||
wi_pcmcia_find(psc, pa, cfe)
|
||||
struct wi_pcmcia_softc *psc;
|
||||
struct pcmcia_attach_args *pa;
|
||||
struct pcmcia_config_entry *cfe;
|
||||
{
|
||||
struct wi_softc *sc = &psc->sc_wi;
|
||||
|
||||
/* Allocate/map I/O space. */
|
||||
if (pcmcia_io_alloc(psc->sc_pf, cfe->iospace[0].start,
|
||||
cfe->iospace[0].length, WI_IOSIZE, &psc->sc_pcioh) != 0) {
|
||||
printf("%s: can't allocate i/o space\n", sc->sc_dev.dv_xname);
|
||||
goto fail1;
|
||||
}
|
||||
if (pcmcia_io_map(psc->sc_pf, PCMCIA_WIDTH_IO16, &psc->sc_pcioh,
|
||||
&psc->sc_io_window) != 0) {
|
||||
printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
|
||||
goto fail2;
|
||||
}
|
||||
/* Enable the card */
|
||||
pcmcia_function_init(psc->sc_pf, cfe);
|
||||
if (pcmcia_function_enable(psc->sc_pf)) {
|
||||
printf("%s: function enable failed\n", sc->sc_dev.dv_xname);
|
||||
goto fail3;
|
||||
}
|
||||
|
||||
sc->sc_iot = psc->sc_pcioh.iot;
|
||||
sc->sc_ioh = psc->sc_pcioh.ioh;
|
||||
|
||||
DELAY(1000);
|
||||
return(0);
|
||||
|
||||
fail3:
|
||||
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
||||
fail2:
|
||||
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
||||
fail1:
|
||||
psc->sc_io_window = -1;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static void
|
||||
wi_pcmcia_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
@ -375,7 +331,6 @@ wi_pcmcia_attach(parent, self, aux)
|
||||
int haveaddr;
|
||||
|
||||
aprint_normal("\n");
|
||||
|
||||
psc->sc_pf = pa->pf;
|
||||
|
||||
SIMPLEQ_FOREACH(cfe, &pa->pf->cfe_head, cfe_list) {
|
||||
@ -383,22 +338,22 @@ wi_pcmcia_attach(parent, self, aux)
|
||||
continue;
|
||||
if (cfe->iospace[0].length < WI_IOSIZE)
|
||||
continue;
|
||||
if (wi_pcmcia_find(psc, pa, cfe) == 0)
|
||||
if (pcmcia_io_alloc(psc->sc_pf, cfe->iospace[0].start,
|
||||
cfe->iospace[0].length, WI_IOSIZE, &psc->sc_pcioh) == 0)
|
||||
break;
|
||||
}
|
||||
if (cfe == NULL) {
|
||||
aprint_error("%s: no suitable CIS info found\n", self->dv_xname);
|
||||
goto no_config_entry;
|
||||
goto fail1;
|
||||
}
|
||||
|
||||
sc->sc_iot = psc->sc_pcioh.iot;
|
||||
sc->sc_ioh = psc->sc_pcioh.ioh;
|
||||
|
||||
pp = wi_pcmcia_lookup(pa);
|
||||
if (pp == NULL)
|
||||
panic("wi_pcmcia_attach: impossible");
|
||||
|
||||
sc->sc_pci = 0;
|
||||
sc->sc_enabled = 1;
|
||||
sc->sc_enable = wi_pcmcia_enable;
|
||||
sc->sc_disable = wi_pcmcia_disable;
|
||||
if (pp->pp_vendor == PCMCIA_VENDOR_SYMBOL &&
|
||||
pp->pp_product == PCMCIA_PRODUCT_SYMBOL_LA4100)
|
||||
psc->sc_symbol_cf = 1;
|
||||
@ -412,29 +367,32 @@ wi_pcmcia_attach(parent, self, aux)
|
||||
CSR_READ_2(sc, WI_COR) == WI_COR_IOMODE)
|
||||
psc->sc_symbol_cf = 1;
|
||||
|
||||
if (psc->sc_symbol_cf) {
|
||||
if (wi_pcmcia_load_firm(sc,
|
||||
spectrum24t_primsym, sizeof(spectrum24t_primsym),
|
||||
spectrum24t_secsym, sizeof(spectrum24t_secsym))) {
|
||||
aprint_error("%s: couldn't load firmware\n",
|
||||
self->dv_xname);
|
||||
goto no_interrupt;
|
||||
}
|
||||
/* Enable the card */
|
||||
pcmcia_function_init(psc->sc_pf, cfe);
|
||||
|
||||
/* Allocate/map I/O space. */
|
||||
if (pcmcia_io_map(psc->sc_pf, PCMCIA_WIDTH_IO16, &psc->sc_pcioh,
|
||||
&psc->sc_io_window) != 0) {
|
||||
printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
/* establish the interrupt. */
|
||||
sc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, wi_intr, sc);
|
||||
if (sc->sc_ih == NULL) {
|
||||
aprint_error("%s: couldn't establish interrupt\n", self->dv_xname);
|
||||
goto no_interrupt;
|
||||
if (wi_pcmcia_enable(sc)) {
|
||||
printf("%s: enable failed\n", sc->sc_dev.dv_xname);
|
||||
goto fail3;
|
||||
}
|
||||
|
||||
sc->sc_pci = 0;
|
||||
sc->sc_enabled = 1;
|
||||
sc->sc_enable = wi_pcmcia_enable;
|
||||
sc->sc_disable = wi_pcmcia_disable;
|
||||
|
||||
printf("%s:", self->dv_xname);
|
||||
|
||||
haveaddr = pa->pf->pf_funce_lan_nidlen == IEEE80211_ADDR_LEN;
|
||||
if (wi_attach(sc, haveaddr ? pa->pf->pf_funce_lan_nid : 0) != 0) {
|
||||
aprint_error("%s: failed to attach controller\n", self->dv_xname);
|
||||
goto attach_failed;
|
||||
goto fail4;
|
||||
}
|
||||
|
||||
psc->sc_sdhook = shutdownhook_establish(wi_pcmcia_shutdown, psc);
|
||||
@ -443,16 +401,16 @@ wi_pcmcia_attach(parent, self, aux)
|
||||
/* disable the card */
|
||||
sc->sc_enabled = 0;
|
||||
wi_pcmcia_disable(sc);
|
||||
|
||||
return;
|
||||
|
||||
attach_failed:
|
||||
pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
|
||||
no_interrupt:
|
||||
pcmcia_function_disable(psc->sc_pf);
|
||||
fail4:
|
||||
sc->sc_enabled = 0;
|
||||
wi_pcmcia_disable(sc);
|
||||
fail3:
|
||||
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
||||
fail2:
|
||||
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
||||
no_config_entry:
|
||||
fail1:
|
||||
psc->sc_io_window = -1;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mhzc.c,v 1.20 2004/08/08 23:17:13 mycroft Exp $ */
|
||||
/* $NetBSD: mhzc.c,v 1.21 2004/08/09 18:11:01 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
|
||||
@ -46,7 +46,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mhzc.c,v 1.20 2004/08/08 23:17:13 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mhzc.c,v 1.21 2004/08/09 18:11:01 mycroft Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ns.h"
|
||||
@ -134,7 +134,8 @@ struct mhzc_softc {
|
||||
#define MHZC_ETHERNET_MAPPED 0x02
|
||||
#define MHZC_MODEM_ENABLED 0x04
|
||||
#define MHZC_ETHERNET_ENABLED 0x08
|
||||
#define MHZC_IOSPACE_ALLOCED 0x10
|
||||
#define MHZC_MODEM_ALLOCED 0x10
|
||||
#define MHZC_ETHERNET_ALLOCED 0x20
|
||||
|
||||
int mhzc_match __P((struct device *, struct cfdata *, void *));
|
||||
void mhzc_attach __P((struct device *, struct device *, void *));
|
||||
@ -205,7 +206,6 @@ mhzc_attach(parent, self, aux)
|
||||
struct pcmcia_config_entry *cfe;
|
||||
|
||||
aprint_normal("\n");
|
||||
|
||||
sc->sc_pf = pa->pf;
|
||||
|
||||
sc->sc_product = (const struct mhzc_product *)pcmcia_product_lookup(pa,
|
||||
@ -244,39 +244,36 @@ mhzc_attach(parent, self, aux)
|
||||
if (cfe == NULL) {
|
||||
aprint_error("%s: unable to find suitable config table entry\n",
|
||||
self->dv_xname);
|
||||
return;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (mhzc_alloc_ethernet(sc, cfe) == 0) {
|
||||
aprint_error("%s: unable to allocate space for Ethernet portion\n",
|
||||
self->dv_xname);
|
||||
goto alloc_ethernet_failed;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Enable the card. */
|
||||
pcmcia_function_init(pa->pf, cfe);
|
||||
if (pcmcia_function_enable(pa->pf)) {
|
||||
aprint_error("%s: function enable failed\n", self->dv_xname);
|
||||
goto enable_failed;
|
||||
}
|
||||
sc->sc_flags |= MHZC_IOSPACE_ALLOCED;
|
||||
|
||||
if (sc->sc_product->mp_enable != NULL)
|
||||
(*sc->sc_product->mp_enable)(sc);
|
||||
if (mhzc_enable(sc, MHZC_MODEM_ENABLED|MHZC_ETHERNET_ENABLED)) {
|
||||
aprint_error("%s: enable failed\n", self->dv_xname);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
sc->sc_modem = config_found(self, "com", mhzc_print);
|
||||
sc->sc_ethernet = config_found(self, "sm", mhzc_print);
|
||||
|
||||
pcmcia_function_disable(pa->pf);
|
||||
mhzc_disable(sc, MHZC_MODEM_ENABLED|MHZC_ETHERNET_ENABLED);
|
||||
return;
|
||||
|
||||
enable_failed:
|
||||
/* Free the Ethernet's I/O space. */
|
||||
pcmcia_io_free(sc->sc_pf, &sc->sc_ethernet_pcioh);
|
||||
|
||||
alloc_ethernet_failed:
|
||||
/* Free the Modem's I/O space. */
|
||||
pcmcia_io_free(sc->sc_pf, &sc->sc_modem_pcioh);
|
||||
fail:
|
||||
/* Free our i/o spaces. */
|
||||
if (sc->sc_flags & MHZC_ETHERNET_ALLOCED)
|
||||
pcmcia_io_free(sc->sc_pf, &sc->sc_ethernet_pcioh);
|
||||
if (sc->sc_flags & MHZC_MODEM_ALLOCED)
|
||||
pcmcia_io_free(sc->sc_pf, &sc->sc_modem_pcioh);
|
||||
sc->sc_flags = 0;
|
||||
}
|
||||
|
||||
int
|
||||
@ -297,6 +294,7 @@ mhzc_check_cfe(sc, cfe)
|
||||
cfe->iospace[0].length,
|
||||
&sc->sc_modem_pcioh) == 0) {
|
||||
/* Found one for the modem! */
|
||||
sc->sc_flags |= MHZC_MODEM_ALLOCED;
|
||||
return (1);
|
||||
}
|
||||
|
||||
@ -324,6 +322,7 @@ mhzc_alloc_ethernet(sc, cfe)
|
||||
if (pcmcia_io_alloc(sc->sc_pf, addr, 0x10, 0x10,
|
||||
&sc->sc_ethernet_pcioh) == 0) {
|
||||
/* Found one for the ethernet! */
|
||||
sc->sc_flags |= MHZC_ETHERNET_ALLOCED;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
@ -363,9 +362,7 @@ mhzc_detach(self, flags)
|
||||
rv = config_detach(sc->sc_modem, flags);
|
||||
if (rv != 0)
|
||||
return (rv);
|
||||
#ifdef not_necessary
|
||||
sc->sc_modem = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Unmap our i/o windows. */
|
||||
@ -375,10 +372,11 @@ mhzc_detach(self, flags)
|
||||
pcmcia_io_unmap(sc->sc_pf, sc->sc_ethernet_io_window);
|
||||
|
||||
/* Free our i/o spaces. */
|
||||
if (sc->sc_flags & MHZC_IOSPACE_ALLOCED) {
|
||||
if (sc->sc_flags & MHZC_ETHERNET_ALLOCED)
|
||||
pcmcia_io_free(sc->sc_pf, &sc->sc_modem_pcioh);
|
||||
if (sc->sc_flags & MHZC_MODEM_ALLOCED)
|
||||
pcmcia_io_free(sc->sc_pf, &sc->sc_ethernet_pcioh);
|
||||
}
|
||||
sc->sc_flags = 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -444,10 +442,9 @@ mhzc_enable(sc, flag)
|
||||
int flag;
|
||||
{
|
||||
|
||||
if (sc->sc_flags & flag) {
|
||||
printf("%s: %s already enabled\n", sc->sc_dev.dv_xname,
|
||||
(flag & MHZC_MODEM_ENABLED) ? "modem" : "ethernet");
|
||||
panic("mhzc_enable");
|
||||
if ((sc->sc_flags & flag) == flag) {
|
||||
printf("%s: already enabled\n", sc->sc_dev.dv_xname);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if ((sc->sc_flags & (MHZC_MODEM_ENABLED|MHZC_ETHERNET_ENABLED)) != 0) {
|
||||
@ -499,9 +496,8 @@ mhzc_disable(sc, flag)
|
||||
{
|
||||
|
||||
if ((sc->sc_flags & flag) == 0) {
|
||||
printf("%s: %s already disabled\n", sc->sc_dev.dv_xname,
|
||||
(flag & MHZC_MODEM_ENABLED) ? "modem" : "ethernet");
|
||||
panic("mhzc_disable");
|
||||
printf("%s: already disabled\n", sc->sc_dev.dv_xname);
|
||||
return;
|
||||
}
|
||||
|
||||
sc->sc_flags &= ~flag;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: wdc_pcmcia.c,v 1.70 2004/08/08 23:17:13 mycroft Exp $ */
|
||||
/* $NetBSD: wdc_pcmcia.c,v 1.71 2004/08/09 18:11:01 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: wdc_pcmcia.c,v 1.70 2004/08/08 23:17:13 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: wdc_pcmcia.c,v 1.71 2004/08/09 18:11:01 mycroft Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
@ -273,16 +273,6 @@ wdc_pcmcia_attach(parent, self, aux)
|
||||
|
||||
/* Enable the card. */
|
||||
pcmcia_function_init(pa->pf, cfe);
|
||||
if (pcmcia_function_enable(pa->pf)) {
|
||||
aprint_error("%s: function enable failed\n", self->dv_xname);
|
||||
goto enable_failed;
|
||||
}
|
||||
|
||||
wpp = wdc_pcmcia_lookup(pa);
|
||||
if (wpp != NULL)
|
||||
quirks = wpp->wpp_quirk_flag;
|
||||
else
|
||||
quirks = 0;
|
||||
|
||||
if (sc->sc_flags & WDC_PCMCIA_MEMMODE) {
|
||||
if (pcmcia_mem_map(pa->pf, PCMCIA_MEM_COMMON, 0,
|
||||
@ -321,6 +311,17 @@ wdc_pcmcia_attach(parent, self, aux)
|
||||
goto mapaux_failed;
|
||||
}
|
||||
|
||||
if (wdc_pcmcia_enable(self, 1)) {
|
||||
aprint_error("%s: enable failed\n", self->dv_xname);
|
||||
goto enable_failed;
|
||||
}
|
||||
|
||||
wpp = wdc_pcmcia_lookup(pa);
|
||||
if (wpp != NULL)
|
||||
quirks = wpp->wpp_quirk_flag;
|
||||
else
|
||||
quirks = 0;
|
||||
|
||||
sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16;
|
||||
if (sc->sc_flags & WDC_PCMCIA_MEMMODE) {
|
||||
sc->wdc_channel.cmd_iot = sc->sc_pmemh.memt;
|
||||
@ -365,21 +366,16 @@ wdc_pcmcia_attach(parent, self, aux)
|
||||
|
||||
sc->sc_flags |= WDC_PCMCIA_ATTACH;
|
||||
wdcattach(&sc->wdc_channel);
|
||||
|
||||
return;
|
||||
|
||||
mapaux_failed:
|
||||
enable_failed:
|
||||
/* Unmap our i/o window. */
|
||||
if (sc->sc_flags & WDC_PCMCIA_MEMMODE)
|
||||
pcmcia_mem_unmap(sc->sc_pf, sc->sc_memwindow);
|
||||
else
|
||||
pcmcia_io_unmap(sc->sc_pf, sc->sc_iowindow);
|
||||
|
||||
map_failed:
|
||||
/* Disable the function */
|
||||
pcmcia_function_disable(sc->sc_pf);
|
||||
|
||||
enable_failed:
|
||||
mapaux_failed:
|
||||
/* Unmap our i/o space. */
|
||||
if (sc->sc_flags & WDC_PCMCIA_MEMMODE) {
|
||||
pcmcia_mem_free(sc->sc_pf, &sc->sc_pmembaseh);
|
||||
@ -388,6 +384,7 @@ wdc_pcmcia_attach(parent, self, aux)
|
||||
if (cfe->num_iospace == 2)
|
||||
pcmcia_io_free(sc->sc_pf, &sc->sc_auxpioh);
|
||||
}
|
||||
map_failed:
|
||||
no_config_entry:
|
||||
sc->sc_iowindow = -1;
|
||||
}
|
||||
@ -441,15 +438,6 @@ wdc_pcmcia_enable(self, onoff)
|
||||
struct wdc_pcmcia_softc *sc = (void *)self;
|
||||
|
||||
if (onoff) {
|
||||
/* Establish the interrupt handler. */
|
||||
sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_BIO,
|
||||
wdcintr, &sc->wdc_channel);
|
||||
if (sc->sc_ih == NULL) {
|
||||
printf("%s: couldn't establish interrupt handler\n",
|
||||
sc->sc_wdcdev.sc_dev.dv_xname);
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the WDC_PCMCIA_ATTACH flag is set, we've already
|
||||
* enabled the card in the attach routine, so don't
|
||||
@ -460,6 +448,15 @@ wdc_pcmcia_enable(self, onoff)
|
||||
if (sc->sc_flags & WDC_PCMCIA_ATTACH) {
|
||||
sc->sc_flags &= ~WDC_PCMCIA_ATTACH;
|
||||
} else {
|
||||
/* Establish the interrupt handler. */
|
||||
sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_BIO,
|
||||
wdcintr, &sc->wdc_channel);
|
||||
if (sc->sc_ih == NULL) {
|
||||
printf("%s: couldn't establish interrupt handler\n",
|
||||
sc->sc_wdcdev.sc_dev.dv_xname);
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
if (pcmcia_function_enable(sc->sc_pf)) {
|
||||
printf("%s: couldn't enable PCMCIA function\n",
|
||||
sc->sc_wdcdev.sc_dev.dv_xname);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xirc.c,v 1.4 2004/08/09 16:05:00 mycroft Exp $ */
|
||||
/* $NetBSD: xirc.c,v 1.5 2004/08/09 18:11:01 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2004 The NetBSD Foundation, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xirc.c,v 1.4 2004/08/09 16:05:00 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xirc.c,v 1.5 2004/08/09 18:11:01 mycroft Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ns.h"
|
||||
@ -192,7 +192,6 @@ xirc_attach(parent, self, aux)
|
||||
int rv;
|
||||
|
||||
aprint_normal("\n");
|
||||
|
||||
sc->sc_pf = pa->pf;
|
||||
|
||||
pcmcia_socket_enable(parent);
|
||||
@ -235,35 +234,29 @@ xirc_attach(parent, self, aux)
|
||||
if (sc->sc_id & (XIMEDIA_MODEM << 8)) {
|
||||
if (sc->sc_chipset >= XI_CHIPSET_DINGO) {
|
||||
cfe = xirc_dingo_alloc_modem(sc);
|
||||
if (!cfe) {
|
||||
aprint_error("%s: failed to allocate I/O for modem\n",
|
||||
self->dv_xname);
|
||||
goto fail;
|
||||
if (cfe && sc->sc_id & (XIMEDIA_ETHER << 8)) {
|
||||
if (!xirc_dingo_alloc_ethernet(sc)) {
|
||||
pcmcia_io_free(pa->pf,
|
||||
&sc->sc_modem_pcioh);
|
||||
cfe = 0;
|
||||
}
|
||||
}
|
||||
if (sc->sc_id & (XIMEDIA_ETHER << 8)) {
|
||||
if (!xirc_dingo_alloc_ethernet(sc))
|
||||
aprint_error("%s: failed to allocate I/O for ethernet\n",
|
||||
self->dv_xname);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
cfe = xirc_mako_alloc(sc);
|
||||
if (!cfe) {
|
||||
aprint_error("%s: failed to allocate I/O\n",
|
||||
self->dv_xname);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
cfe = xirc_dingo_alloc_ethernet(sc);
|
||||
if (!cfe)
|
||||
aprint_error("%s: failed to allocate I/O for ethernet\n",
|
||||
self->dv_xname);
|
||||
if (!cfe) {
|
||||
aprint_error("%s: failed to allocate I/O space\n",
|
||||
self->dv_xname);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Enable the card. */
|
||||
pcmcia_function_init(pa->pf, cfe);
|
||||
if (pcmcia_function_enable(pa->pf)) {
|
||||
aprint_error("%s: function enable failed\n", self->dv_xname);
|
||||
|
||||
if (xirc_enable(sc, XIRC_MODEM_ENABLED|XIRC_ETHERNET_ENABLED,
|
||||
sc->sc_id & (XIMEDIA_MODEM|XIMEDIA_ETHER))) {
|
||||
aprint_error("%s: enable failed\n", self->dv_xname);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -274,7 +267,8 @@ xirc_attach(parent, self, aux)
|
||||
if (sc->sc_id & (XIMEDIA_ETHER << 8))
|
||||
sc->sc_ethernet = config_found(self, "xi", xirc_print);
|
||||
|
||||
pcmcia_function_disable(pa->pf);
|
||||
xirc_disable(sc, XIRC_MODEM_ENABLED|XIRC_ETHERNET_ENABLED,
|
||||
sc->sc_id & (XIMEDIA_MODEM|XIMEDIA_ETHER));
|
||||
return;
|
||||
|
||||
fail:
|
||||
@ -412,9 +406,7 @@ xirc_detach(self, flags)
|
||||
rv = config_detach(sc->sc_modem, flags);
|
||||
if (rv != 0)
|
||||
return (rv);
|
||||
#ifdef not_necessary
|
||||
sc->sc_modem = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Unmap our i/o windows. */
|
||||
@ -494,10 +486,9 @@ xirc_enable(sc, flag, media)
|
||||
int flag, media;
|
||||
{
|
||||
|
||||
if (sc->sc_flags & flag) {
|
||||
printf("%s: %s already enabled\n", sc->sc_dev.dv_xname,
|
||||
(flag & XIRC_MODEM_ENABLED) ? "modem" : "ethernet");
|
||||
panic("xirc_enable");
|
||||
if ((sc->sc_flags & flag) == flag) {
|
||||
printf("%s: already enabled\n", sc->sc_dev.dv_xname);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if ((sc->sc_flags & (XIRC_MODEM_ENABLED|XIRC_ETHERNET_ENABLED)) != 0) {
|
||||
@ -546,6 +537,11 @@ xirc_disable(sc, flag, media)
|
||||
int flag, media;
|
||||
{
|
||||
|
||||
if ((sc->sc_flags & flag) == 0) {
|
||||
printf("%s: already disabled\n", sc->sc_dev.dv_xname);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sc->sc_chipset < XI_CHIPSET_DINGO &&
|
||||
sc->sc_id & (XIMEDIA_MODEM << 8)) {
|
||||
sc->sc_mako_intmask &= ~media;
|
||||
@ -553,12 +549,6 @@ xirc_disable(sc, flag, media)
|
||||
sc->sc_ethernet_pcioh.ioh, 0x10, sc->sc_mako_intmask);
|
||||
}
|
||||
|
||||
if ((sc->sc_flags & flag) == 0) {
|
||||
printf("%s: %s already disabled\n", sc->sc_dev.dv_xname,
|
||||
(flag & XIRC_MODEM_ENABLED) ? "modem" : "ethernet");
|
||||
panic("xirc_disable");
|
||||
}
|
||||
|
||||
sc->sc_flags &= ~flag;
|
||||
if ((sc->sc_flags & (XIRC_MODEM_ENABLED|XIRC_ETHERNET_ENABLED)) != 0)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user