Update to the new world order.
This commit is contained in:
parent
ab96663a2a
commit
8355db5e7a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_an_pcmcia.c,v 1.24 2004/08/10 19:12:25 mycroft Exp $ */
|
||||
/* $NetBSD: if_an_pcmcia.c,v 1.25 2004/08/10 20:47:17 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_an_pcmcia.c,v 1.24 2004/08/10 19:12:25 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_an_pcmcia.c,v 1.25 2004/08/10 20:47:17 mycroft Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -70,6 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_an_pcmcia.c,v 1.24 2004/08/10 19:12:25 mycroft Ex
|
|||
#include <dev/pcmcia/pcmciadevs.h>
|
||||
|
||||
static int an_pcmcia_match __P((struct device *, struct cfdata *, void *));
|
||||
static int an_pcmcia_validate_config __P((struct pcmcia_config_entry *));
|
||||
static void an_pcmcia_attach __P((struct device *, struct device *, void *));
|
||||
static int an_pcmcia_detach __P((struct device *, int));
|
||||
static int an_pcmcia_enable __P((struct an_softc *));
|
||||
|
@ -84,6 +85,9 @@ struct an_pcmcia_softc {
|
|||
struct pcmcia_function *sc_pf; /* our PCMCIA function */
|
||||
void *sc_ih; /* interrupt handle */
|
||||
void *sc_powerhook; /* power hook descriptor */
|
||||
|
||||
int sc_state;
|
||||
#define AN_PCMCIA_ATTACHED 3
|
||||
};
|
||||
|
||||
CFATTACH_DECL(an_pcmcia, sizeof(struct an_pcmcia_softc),
|
||||
|
@ -100,41 +104,6 @@ static const struct pcmcia_product an_pcmcia_products[] = {
|
|||
static const size_t an_pcmcia_nproducts =
|
||||
sizeof(an_pcmcia_products) / sizeof(an_pcmcia_products[0]);
|
||||
|
||||
static int
|
||||
an_pcmcia_enable(sc)
|
||||
struct an_softc *sc;
|
||||
{
|
||||
struct an_pcmcia_softc *psc = (struct an_pcmcia_softc *)sc;
|
||||
struct pcmcia_function *pf = psc->sc_pf;
|
||||
|
||||
/* establish the interrupt. */
|
||||
psc->sc_ih = pcmcia_intr_establish(pf, IPL_NET, an_intr, sc);
|
||||
if (psc->sc_ih == NULL) {
|
||||
printf("%s: couldn't establish interrupt\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (pcmcia_function_enable(pf)) {
|
||||
pcmcia_intr_disestablish(pf, psc->sc_ih);
|
||||
return (1);
|
||||
}
|
||||
DELAY(1000);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
an_pcmcia_disable(sc)
|
||||
struct an_softc *sc;
|
||||
{
|
||||
struct an_pcmcia_softc *psc = (struct an_pcmcia_softc *)sc;
|
||||
struct pcmcia_function *pf = psc->sc_pf;
|
||||
|
||||
pcmcia_function_disable(pf);
|
||||
pcmcia_intr_disestablish(pf, psc->sc_ih);
|
||||
}
|
||||
|
||||
static int
|
||||
an_pcmcia_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
|
@ -149,6 +118,16 @@ an_pcmcia_match(parent, match, aux)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
an_pcmcia_validate_config(cfe)
|
||||
struct pcmcia_config_entry *cfe;
|
||||
{
|
||||
if (cfe->iftype != PCMCIA_IFTYPE_IO ||
|
||||
cfe->num_iospace < 1)
|
||||
return (EINVAL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
an_pcmcia_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
|
@ -158,61 +137,48 @@ an_pcmcia_attach(parent, self, aux)
|
|||
struct an_softc *sc = &psc->sc_an;
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
struct pcmcia_config_entry *cfe;
|
||||
int error;
|
||||
|
||||
psc->sc_pf = pa->pf;
|
||||
if ((cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head)) == NULL) {
|
||||
printf("%s: no suitable CIS info found\n", sc->sc_dev.dv_xname);
|
||||
goto fail1;
|
||||
|
||||
error = pcmcia_function_configure(pa->pf, an_pcmcia_validate_config);
|
||||
if (error) {
|
||||
aprint_error("%s: configure failed, error=%d\n", self->dv_xname,
|
||||
error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pcmcia_io_alloc(psc->sc_pf, cfe->iospace[0].start,
|
||||
cfe->iospace[0].length, AN_IOSIZ, &psc->sc_pcioh) != 0) {
|
||||
printf("%s: failed to allocate io space\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
goto fail1;
|
||||
}
|
||||
cfe = pa->pf->cfe;
|
||||
sc->sc_iot = cfe->iospace[0].handle.iot;
|
||||
sc->sc_ioh = cfe->iospace[0].handle.ioh;
|
||||
|
||||
if (pcmcia_io_map(psc->sc_pf, PCMCIA_WIDTH_AUTO, &psc->sc_pcioh,
|
||||
&psc->sc_io_window) != 0) {
|
||||
printf("%s: failed to map io space\n", sc->sc_dev.dv_xname);
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
sc->sc_iot = psc->sc_pcioh.iot;
|
||||
sc->sc_ioh = psc->sc_pcioh.ioh;
|
||||
|
||||
pcmcia_function_init(psc->sc_pf, cfe);
|
||||
|
||||
if (an_pcmcia_enable(sc)) {
|
||||
printf("%s: enable failed\n", sc->sc_dev.dv_xname);
|
||||
goto fail3;
|
||||
}
|
||||
error = an_pcmcia_enable(sc);
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
sc->sc_enabled = 1;
|
||||
sc->sc_enable = an_pcmcia_enable;
|
||||
sc->sc_disable = an_pcmcia_disable;
|
||||
|
||||
if (an_attach(sc) != 0) {
|
||||
printf("%s: failed to attach controller\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
goto fail4;
|
||||
error = an_attach(sc);
|
||||
if (error) {
|
||||
aprint_error("%s: failed to attach controller\n",
|
||||
self->dv_xname);
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
psc->sc_powerhook = powerhook_establish(an_power, sc);
|
||||
|
||||
/* disable device and disestablish the interrupt */
|
||||
sc->sc_enabled = 0;
|
||||
an_pcmcia_disable(sc);
|
||||
sc->sc_enabled = 0;
|
||||
psc->sc_state = AN_PCMCIA_ATTACHED;
|
||||
return;
|
||||
|
||||
fail4:
|
||||
sc->sc_enabled = 0;
|
||||
an_pcmcia_disable(sc);
|
||||
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;
|
||||
an_pcmcia_disable(sc);
|
||||
sc->sc_enabled = 0;
|
||||
fail:
|
||||
pcmcia_function_unconfigure(pa->pf);
|
||||
}
|
||||
|
||||
|
||||
|
@ -221,24 +187,52 @@ an_pcmcia_detach(self, flags)
|
|||
struct device *self;
|
||||
int flags;
|
||||
{
|
||||
struct an_pcmcia_softc *psc = (struct an_pcmcia_softc *)self;
|
||||
struct an_pcmcia_softc *psc = (void *)self;
|
||||
int error;
|
||||
|
||||
if (psc->sc_io_window == -1)
|
||||
/* Nothing to detach. */
|
||||
if (psc->sc_state != AN_PCMCIA_ATTACHED)
|
||||
return (0);
|
||||
|
||||
if (psc->sc_powerhook != NULL)
|
||||
if (psc->sc_powerhook)
|
||||
powerhook_disestablish(psc->sc_powerhook);
|
||||
|
||||
error = an_detach(&psc->sc_an);
|
||||
if (error != 0)
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
/* Unmap our i/o window. */
|
||||
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
||||
pcmcia_function_unconfigure(psc->sc_pf);
|
||||
|
||||
/* Free our i/o space. */
|
||||
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
an_pcmcia_enable(sc)
|
||||
struct an_softc *sc;
|
||||
{
|
||||
struct an_pcmcia_softc *psc = (void *)sc;
|
||||
int error;
|
||||
|
||||
/* establish the interrupt. */
|
||||
psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, an_intr, sc);
|
||||
if (!psc->sc_ih)
|
||||
return (EIO);
|
||||
|
||||
error = pcmcia_function_enable(psc->sc_pf);
|
||||
if (error) {
|
||||
pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
|
||||
psc->sc_ih = 0;
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
static void
|
||||
an_pcmcia_disable(sc)
|
||||
struct an_softc *sc;
|
||||
{
|
||||
struct an_pcmcia_softc *psc = (void *)sc;
|
||||
|
||||
pcmcia_function_disable(psc->sc_pf);
|
||||
pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
|
||||
psc->sc_ih = 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_cs_pcmcia.c,v 1.9 2004/08/10 18:43:49 mycroft Exp $ */
|
||||
/* $NetBSD: if_cs_pcmcia.c,v 1.10 2004/08/10 20:47:17 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2001 YAMAMOTO Takashi,
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_cs_pcmcia.c,v 1.9 2004/08/10 18:43:49 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_cs_pcmcia.c,v 1.10 2004/08/10 20:47:17 mycroft Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -59,6 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_cs_pcmcia.c,v 1.9 2004/08/10 18:43:49 mycroft Exp
|
|||
struct cs_pcmcia_softc;
|
||||
|
||||
static int cs_pcmcia_match(struct device *, struct cfdata *, void *);
|
||||
static int cs_pcmcia_validate_config(struct pcmcia_config_entry *);
|
||||
static void cs_pcmcia_attach(struct device *, struct device *, void *);
|
||||
static int cs_pcmcia_detach(struct device *, int);
|
||||
static int cs_pcmcia_enable(struct cs_softc *);
|
||||
|
@ -67,14 +68,11 @@ static void cs_pcmcia_disable(struct cs_softc *);
|
|||
struct cs_pcmcia_softc {
|
||||
struct cs_softc sc_cs; /* real "cs" softc */
|
||||
|
||||
struct pcmcia_io_handle sc_pcioh;
|
||||
struct pcmcia_function *sc_pf;
|
||||
int sc_io_window;
|
||||
int sc_flags;
|
||||
};
|
||||
|
||||
#define CS_PCMCIA_FLAGS_IO_ALLOCATED 1
|
||||
#define CS_PCMCIA_FLAGS_IO_MAPPED 2
|
||||
int sc_state;
|
||||
#define CS_PCMCIA_ATTACHED 3
|
||||
};
|
||||
|
||||
CFATTACH_DECL(cs_pcmcia, sizeof(struct cs_pcmcia_softc),
|
||||
cs_pcmcia_match, cs_pcmcia_attach, cs_pcmcia_detach, cs_activate);
|
||||
|
@ -84,11 +82,21 @@ cs_pcmcia_match(struct device *parent, struct cfdata *match, void *aux)
|
|||
{
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
|
||||
if (pa->card->manufacturer == PCMCIA_VENDOR_IBM
|
||||
&& pa->card->product == PCMCIA_PRODUCT_IBM_ETHERJET)
|
||||
return 1;
|
||||
if (pa->manufacturer == PCMCIA_VENDOR_IBM &&
|
||||
pa->product == PCMCIA_PRODUCT_IBM_ETHERJET)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
static int
|
||||
cs_pcmcia_validate_config(struct pcmcia_config_entry *cfe)
|
||||
{
|
||||
if (cfe->iftype != PCMCIA_IFTYPE_IO ||
|
||||
cfe->num_memspace != 0 ||
|
||||
cfe->num_iospace != 1 ||
|
||||
cfe->iospace[0].length < CS8900_IOSIZE)
|
||||
return (EINVAL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -99,40 +107,20 @@ cs_pcmcia_attach(struct device *parent, struct device *self, void *aux)
|
|||
struct pcmcia_attach_args *pa = aux;
|
||||
struct pcmcia_config_entry *cfe;
|
||||
struct pcmcia_function *pf;
|
||||
int error;
|
||||
|
||||
pf = psc->sc_pf = pa->pf;
|
||||
|
||||
cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head);
|
||||
|
||||
if (cfe->num_iospace != 1) {
|
||||
printf("%s: unexpected number of iospace(%d)\n",
|
||||
DEVNAME(sc), cfe->num_iospace);
|
||||
goto fail;
|
||||
error = pcmcia_function_configure(pa->pf, cs_pcmcia_validate_config);
|
||||
if (error) {
|
||||
aprint_error("%s: configure failed, error=%d\n", self->dv_xname,
|
||||
error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cfe->iospace[0].length < CS8900_IOSIZE) {
|
||||
printf("%s: unexpected iosize(%lu)\n",
|
||||
DEVNAME(sc), cfe->iospace[0].length);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (cfe->num_memspace != 0) {
|
||||
printf("%s: unexpected number of memspace(%d)\n",
|
||||
DEVNAME(sc), cfe->num_memspace);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (pcmcia_io_alloc(pf, cfe->iospace[0].start,
|
||||
cfe->iospace[0].length, cfe->iospace[0].length,
|
||||
&psc->sc_pcioh) != 0) {
|
||||
printf("%s: can't allocate i/o space %lx:%lx\n", DEVNAME(sc),
|
||||
cfe->iospace[0].start, cfe->iospace[0].length);
|
||||
goto fail;
|
||||
}
|
||||
psc->sc_flags |= CS_PCMCIA_FLAGS_IO_ALLOCATED;
|
||||
|
||||
sc->sc_iot = psc->sc_pcioh.iot;
|
||||
sc->sc_ioh = psc->sc_pcioh.ioh;
|
||||
cfe = pf->cfe;
|
||||
sc->sc_iot = cfe->iospace[0].handle.iot;
|
||||
sc->sc_ioh = cfe->iospace[0].handle.ioh;
|
||||
sc->sc_irq = -1;
|
||||
#define CS_PCMCIA_HACK_FOR_CARDBUS
|
||||
#ifdef CS_PCMCIA_HACK_FOR_CARDBUS
|
||||
|
@ -141,24 +129,27 @@ cs_pcmcia_attach(struct device *parent, struct device *self, void *aux)
|
|||
*/
|
||||
sc->sc_cfgflags |= CFGFLG_CARDBUS_HACK;
|
||||
#endif
|
||||
|
||||
error = cs_pcmcia_enable(sc);
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
sc->sc_enable = cs_pcmcia_enable;
|
||||
sc->sc_disable = cs_pcmcia_disable;
|
||||
|
||||
pcmcia_function_init(pa->pf, cfe);
|
||||
|
||||
if (cs_pcmcia_enable(sc))
|
||||
goto fail;
|
||||
|
||||
/* chip attach */
|
||||
if (cs_attach(sc, 0, 0, 0, 0))
|
||||
goto fail;
|
||||
error = cs_attach(sc, 0, 0, 0, 0);
|
||||
if (error)
|
||||
goto fail2;
|
||||
|
||||
cs_pcmcia_disable(sc);
|
||||
psc->sc_state = CS_PCMCIA_ATTACHED;
|
||||
return;
|
||||
|
||||
fail2:
|
||||
cs_pcmcia_disable(sc);
|
||||
fail:
|
||||
cs_pcmcia_detach((struct device *)psc, 0);
|
||||
return;
|
||||
pcmcia_function_unconfigure(pf);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -166,69 +157,45 @@ cs_pcmcia_detach(struct device *self, int flags)
|
|||
{
|
||||
struct cs_pcmcia_softc *psc = (void *)self;
|
||||
struct cs_softc *sc = &psc->sc_cs;
|
||||
struct pcmcia_function *pf = psc->sc_pf;
|
||||
int rv;
|
||||
int error;
|
||||
|
||||
rv = cs_detach(sc);
|
||||
if (rv)
|
||||
return rv;
|
||||
if (psc->sc_state != CS_PCMCIA_ATTACHED)
|
||||
return (0);
|
||||
|
||||
error = cs_detach(sc);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
cs_pcmcia_disable(sc);
|
||||
pcmcia_function_unconfigure(psc->sc_pf);
|
||||
|
||||
if (psc->sc_flags & CS_PCMCIA_FLAGS_IO_ALLOCATED) {
|
||||
pcmcia_io_free(pf, &psc->sc_pcioh);
|
||||
psc->sc_flags &= ~CS_PCMCIA_FLAGS_IO_ALLOCATED;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
cs_pcmcia_enable(struct cs_softc *sc)
|
||||
{
|
||||
struct cs_pcmcia_softc *psc = (void *)sc;
|
||||
struct pcmcia_function *pf = psc->sc_pf;
|
||||
int error;
|
||||
|
||||
if (pcmcia_io_map(pf, PCMCIA_WIDTH_AUTO, &psc->sc_pcioh,
|
||||
&psc->sc_io_window) != 0) {
|
||||
printf("%s: can't map i/o space\n", DEVNAME(sc));
|
||||
goto fail;
|
||||
}
|
||||
psc->sc_flags |= CS_PCMCIA_FLAGS_IO_MAPPED;
|
||||
sc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, cs_intr, sc);
|
||||
if (!sc->sc_ih)
|
||||
return (EIO);
|
||||
|
||||
sc->sc_ih = pcmcia_intr_establish(pf, IPL_NET, cs_intr, sc);
|
||||
if (sc->sc_ih == 0) {
|
||||
printf("%s: can't establish interrupt\n", DEVNAME(sc));
|
||||
goto fail;
|
||||
error = pcmcia_function_enable(psc->sc_pf);
|
||||
if (error) {
|
||||
pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
|
||||
sc->sc_ih = 0;
|
||||
}
|
||||
|
||||
if (pcmcia_function_enable(pf)) {
|
||||
printf("%s: can't enable function\n", DEVNAME(sc));
|
||||
pcmcia_intr_disestablish(pf, sc->sc_ih);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
return EIO;
|
||||
return (error);
|
||||
}
|
||||
|
||||
static void
|
||||
cs_pcmcia_disable(struct cs_softc *sc)
|
||||
{
|
||||
struct cs_pcmcia_softc *psc = (void *)sc;
|
||||
struct pcmcia_function *pf = psc->sc_pf;
|
||||
|
||||
pcmcia_function_disable(pf);
|
||||
|
||||
if (sc->sc_ih != 0) {
|
||||
pcmcia_intr_disestablish(pf, sc->sc_ih);
|
||||
sc->sc_ih = 0;
|
||||
}
|
||||
|
||||
if (psc->sc_flags & CS_PCMCIA_FLAGS_IO_MAPPED) {
|
||||
pcmcia_io_unmap(pf, psc->sc_io_window);
|
||||
psc->sc_flags &= ~CS_PCMCIA_FLAGS_IO_MAPPED;
|
||||
}
|
||||
pcmcia_function_disable(psc->sc_pf);
|
||||
pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
|
||||
sc->sc_ih = 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_mbe_pcmcia.c,v 1.33 2004/08/10 18:43:49 mycroft Exp $ */
|
||||
/* $NetBSD: if_mbe_pcmcia.c,v 1.34 2004/08/10 20:47:17 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_mbe_pcmcia.c,v 1.33 2004/08/10 18:43:49 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_mbe_pcmcia.c,v 1.34 2004/08/10 20:47:17 mycroft Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -59,17 +59,18 @@ __KERNEL_RCSID(0, "$NetBSD: if_mbe_pcmcia.c,v 1.33 2004/08/10 18:43:49 mycroft E
|
|||
#include <dev/pcmcia/pcmciadevs.h>
|
||||
|
||||
int mbe_pcmcia_match __P((struct device *, struct cfdata *, void *));
|
||||
int mbe_pcmcia_validate_config __P((struct pcmcia_config_entry *));
|
||||
void mbe_pcmcia_attach __P((struct device *, struct device *, void *));
|
||||
int mbe_pcmcia_detach __P((struct device *, int));
|
||||
|
||||
struct mbe_pcmcia_softc {
|
||||
struct mb86960_softc sc_mb86960; /* real "mb" softc */
|
||||
|
||||
/* PCMCIA-specific goo. */
|
||||
struct pcmcia_io_handle sc_pcioh; /* PCMCIA i/o space info */
|
||||
int sc_io_window; /* our i/o window */
|
||||
void *sc_ih; /* interrupt cookie */
|
||||
struct pcmcia_function *sc_pf; /* our PCMCIA function */
|
||||
void *sc_ih; /* interrupt cookie */
|
||||
|
||||
int sc_state;
|
||||
#define MBE_PCMCIA_ATTACHED 3
|
||||
};
|
||||
|
||||
CFATTACH_DECL(mbe_pcmcia, sizeof(struct mbe_pcmcia_softc),
|
||||
|
@ -90,56 +91,55 @@ int mbe_pcmcia_get_enaddr_from_io __P((struct mbe_pcmcia_softc *,
|
|||
|
||||
static const struct mbe_pcmcia_product {
|
||||
struct pcmcia_product mpp_product;
|
||||
u_int32_t mpp_ioalign; /* required alignment */
|
||||
int mpp_enet_maddr;
|
||||
int mpp_flags;
|
||||
#define MBH10302 0x0001 /* FUJITSU MBH10302 */
|
||||
} mbe_pcmcia_products[] = {
|
||||
{ { PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_CD021BX,
|
||||
PCMCIA_CIS_TDK_LAK_CD021BX },
|
||||
0, -1 },
|
||||
-1 },
|
||||
|
||||
{ { PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_CF010,
|
||||
PCMCIA_CIS_TDK_LAK_CF010 },
|
||||
0, -1 },
|
||||
-1 },
|
||||
|
||||
#if 0 /* XXX 86960-based? */
|
||||
{ { PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_DFL9610,
|
||||
PCMCIA_CIS_TDK_DFL9610 },
|
||||
0, -1, MBH10302 /* XXX */ },
|
||||
-1, MBH10302 /* XXX */ },
|
||||
#endif
|
||||
|
||||
{ { PCMCIA_VENDOR_CONTEC, PCMCIA_PRODUCT_CONTEC_CNETPC,
|
||||
PCMCIA_CIS_CONTEC_CNETPC },
|
||||
0, -1 },
|
||||
-1 },
|
||||
|
||||
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_LA501,
|
||||
PCMCIA_CIS_FUJITSU_LA501 },
|
||||
0x20, -1 },
|
||||
-1 },
|
||||
|
||||
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_FMV_J181,
|
||||
PCMCIA_CIS_FUJITSU_FMV_J181 },
|
||||
0x20, -1, MBH10302 },
|
||||
-1, MBH10302 },
|
||||
|
||||
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_FMV_J182,
|
||||
PCMCIA_CIS_FUJITSU_FMV_J182 },
|
||||
0, 0xf2c },
|
||||
0xf2c },
|
||||
|
||||
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_FMV_J182A,
|
||||
PCMCIA_CIS_FUJITSU_FMV_J182A },
|
||||
0, 0x1cc },
|
||||
0x1cc },
|
||||
|
||||
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_ITCFJ182A,
|
||||
PCMCIA_CIS_FUJITSU_ITCFJ182A },
|
||||
0, 0x1cc },
|
||||
0x1cc },
|
||||
|
||||
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_LA10S,
|
||||
PCMCIA_CIS_FUJITSU_LA10S },
|
||||
0, -1 },
|
||||
-1 },
|
||||
|
||||
{ { PCMCIA_VENDOR_RATOC, PCMCIA_PRODUCT_RATOC_REX_R280,
|
||||
PCMCIA_CIS_RATOC_REX_R280 },
|
||||
0, 0x1fc },
|
||||
0x1fc },
|
||||
};
|
||||
static const size_t mbe_pcmcia_nproducts =
|
||||
sizeof(mbe_pcmcia_products) / sizeof(mbe_pcmcia_products[0]);
|
||||
|
@ -158,122 +158,95 @@ mbe_pcmcia_match(parent, match, aux)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
mbe_pcmcia_validate_config(cfe)
|
||||
struct pcmcia_config_entry *cfe;
|
||||
{
|
||||
if (cfe->iftype != PCMCIA_IFTYPE_IO ||
|
||||
cfe->num_iospace < 1)
|
||||
return (EINVAL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
mbe_pcmcia_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct mbe_pcmcia_softc *psc = (struct mbe_pcmcia_softc *)self;
|
||||
struct mbe_pcmcia_softc *psc = (void *)self;
|
||||
struct mb86960_softc *sc = &psc->sc_mb86960;
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
struct pcmcia_config_entry *cfe;
|
||||
struct mbe_pcmcia_get_enaddr_args pgea;
|
||||
const struct mbe_pcmcia_product *mpp;
|
||||
int rv;
|
||||
int error;
|
||||
|
||||
psc->sc_pf = pa->pf;
|
||||
|
||||
error = pcmcia_function_configure(pa->pf, mbe_pcmcia_validate_config);
|
||||
if (error) {
|
||||
aprint_error("%s: configure failed, error=%d\n", self->dv_xname,
|
||||
error);
|
||||
return;
|
||||
}
|
||||
|
||||
cfe = pa->pf->cfe;
|
||||
sc->sc_bst = cfe->iospace[0].handle.iot;
|
||||
sc->sc_bsh = cfe->iospace[0].handle.ioh;
|
||||
|
||||
error = mbe_pcmcia_enable(sc);
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
mpp = pcmcia_product_lookup(pa, mbe_pcmcia_products,
|
||||
mbe_pcmcia_nproducts, sizeof(mbe_pcmcia_products[0]), NULL);
|
||||
if (!mpp)
|
||||
panic("mbe_pcmcia_attach: impossible");
|
||||
|
||||
psc->sc_pf = pa->pf;
|
||||
cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head);
|
||||
|
||||
/* Enable the card. */
|
||||
pcmcia_function_init(pa->pf, cfe);
|
||||
if (pcmcia_function_enable(pa->pf)) {
|
||||
printf("%s: function enable failed\n", sc->sc_dev.dv_xname);
|
||||
goto enable_failed;
|
||||
}
|
||||
|
||||
/* Allocate and map i/o space for the card. */
|
||||
if (pcmcia_io_alloc(pa->pf, cfe->iospace[0].start,
|
||||
cfe->iospace[0].length,
|
||||
mpp->mpp_ioalign ? mpp->mpp_ioalign : cfe->iospace[0].length,
|
||||
&psc->sc_pcioh)) {
|
||||
printf("%s: can't allocate i/o space\n", sc->sc_dev.dv_xname);
|
||||
goto ioalloc_failed;
|
||||
}
|
||||
|
||||
sc->sc_bst = psc->sc_pcioh.iot;
|
||||
sc->sc_bsh = psc->sc_pcioh.ioh;
|
||||
|
||||
sc->sc_enable = mbe_pcmcia_enable;
|
||||
sc->sc_disable = mbe_pcmcia_disable;
|
||||
|
||||
/*
|
||||
* Don't bother checking flags; the back-end sets the chip
|
||||
* into 16-bit mode.
|
||||
*/
|
||||
if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO16, &psc->sc_pcioh,
|
||||
&psc->sc_io_window)) {
|
||||
printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
|
||||
goto iomap_failed;
|
||||
}
|
||||
|
||||
/* Read station address from io/mem or CIS. */
|
||||
if (mpp->mpp_enet_maddr >= 0) {
|
||||
pgea.maddr = mpp->mpp_enet_maddr;
|
||||
if (mbe_pcmcia_get_enaddr_from_mem(psc, &pgea) != 0) {
|
||||
printf("%s: Couldn't get ethernet address "
|
||||
"from mem\n", sc->sc_dev.dv_xname);
|
||||
goto no_enaddr;
|
||||
printf("%s: couldn't get ethernet address "
|
||||
"from memory\n", self->dv_xname);
|
||||
goto fail2;
|
||||
}
|
||||
} else if ((mpp->mpp_flags & MBH10302) != 0) {
|
||||
} else if (mpp->mpp_flags & MBH10302) {
|
||||
bus_space_write_1(sc->sc_bst, sc->sc_bsh, FE_MBH0 ,
|
||||
FE_MBH0_MASK | FE_MBH0_INTR_ENABLE);
|
||||
if (mbe_pcmcia_get_enaddr_from_io(psc, &pgea) != 0) {
|
||||
printf("%s: Couldn't get ethernet address "
|
||||
"from io\n", sc->sc_dev.dv_xname);
|
||||
goto no_enaddr;
|
||||
printf("%s: couldn't get ethernet address from i/o\n",
|
||||
self->dv_xname);
|
||||
goto fail2;
|
||||
}
|
||||
} else {
|
||||
rv = pcmcia_scan_cis(parent,
|
||||
mbe_pcmcia_get_enaddr_from_cis, &pgea);
|
||||
if (rv == -1) {
|
||||
printf("%s: Couldn't read CIS to get ethernet "
|
||||
"address\n", sc->sc_dev.dv_xname);
|
||||
goto no_enaddr;
|
||||
} else if (rv == 0) {
|
||||
printf("%s: Couldn't get ethernet address "
|
||||
"from CIS\n", sc->sc_dev.dv_xname);
|
||||
goto no_enaddr;
|
||||
if (pa->pf->pf_funce_lan_nidlen != ETHER_ADDR_LEN) {
|
||||
printf("%s: couldn't get ethernet address from CIS\n",
|
||||
self->dv_xname);
|
||||
goto fail2;
|
||||
}
|
||||
#ifdef DIAGNOSTIC
|
||||
if (rv != 1) {
|
||||
printf("%s: pcmcia_scan_cis returns %d\n",
|
||||
sc->sc_dev.dv_xname, rv);
|
||||
panic("mbe_pcmcia_attach");
|
||||
}
|
||||
printf("%s: Ethernet address from CIS: %s\n",
|
||||
sc->sc_dev.dv_xname, ether_sprintf(pgea.enaddr));
|
||||
#endif
|
||||
memcpy(pgea.enaddr, pa->pf->pf_funce_lan_nid, ETHER_ADDR_LEN);
|
||||
}
|
||||
|
||||
/* Perform generic initialization. */
|
||||
if ((mpp->mpp_flags & MBH10302) != 0)
|
||||
if (mpp->mpp_flags & MBH10302)
|
||||
sc->sc_flags |= FE_FLAGS_MB86960;
|
||||
|
||||
mb86960_attach(sc, pgea.enaddr);
|
||||
|
||||
mb86960_config(sc, NULL, 0, 0);
|
||||
|
||||
pcmcia_function_disable(pa->pf);
|
||||
mbe_pcmcia_disable(sc);
|
||||
psc->sc_state = MBE_PCMCIA_ATTACHED;
|
||||
return;
|
||||
|
||||
no_enaddr:
|
||||
/* 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:
|
||||
pcmcia_function_disable(pa->pf);
|
||||
|
||||
enable_failed:
|
||||
psc->sc_io_window = -1;
|
||||
fail2:
|
||||
mbe_pcmcia_disable(sc);
|
||||
fail:
|
||||
pcmcia_function_unconfigure(pa->pf);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -281,22 +254,17 @@ mbe_pcmcia_detach(self, flags)
|
|||
struct device *self;
|
||||
int flags;
|
||||
{
|
||||
struct mbe_pcmcia_softc *psc = (struct mbe_pcmcia_softc *)self;
|
||||
struct mbe_pcmcia_softc *psc = (void *)self;
|
||||
int error;
|
||||
|
||||
if (psc->sc_io_window == -1)
|
||||
/* Nothing to detach. */
|
||||
if (psc->sc_state != MBE_PCMCIA_ATTACHED)
|
||||
return (0);
|
||||
|
||||
error = mb86960_detach(&psc->sc_mb86960);
|
||||
if (error != 0)
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
/* Unmap our i/o window. */
|
||||
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
||||
|
||||
/* Free our i/o space. */
|
||||
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
||||
pcmcia_function_unconfigure(psc->sc_pf);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -305,57 +273,33 @@ int
|
|||
mbe_pcmcia_enable(sc)
|
||||
struct mb86960_softc *sc;
|
||||
{
|
||||
struct mbe_pcmcia_softc *psc = (struct mbe_pcmcia_softc *)sc;
|
||||
struct mbe_pcmcia_softc *psc = (void *)sc;
|
||||
int error;
|
||||
|
||||
/* Establish the interrupt handler. */
|
||||
psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, mb86960_intr,
|
||||
sc);
|
||||
if (psc->sc_ih == NULL) {
|
||||
printf("%s: couldn't establish interrupt handler\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
return (1);
|
||||
}
|
||||
if (!psc->sc_ih)
|
||||
return (EIO);
|
||||
|
||||
if (pcmcia_function_enable(psc->sc_pf)) {
|
||||
error = pcmcia_function_enable(psc->sc_pf);
|
||||
if (error) {
|
||||
pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
|
||||
return (1);
|
||||
psc->sc_ih = 0;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return (error);
|
||||
}
|
||||
|
||||
void
|
||||
mbe_pcmcia_disable(sc)
|
||||
struct mb86960_softc *sc;
|
||||
{
|
||||
struct mbe_pcmcia_softc *psc = (struct mbe_pcmcia_softc *)sc;
|
||||
struct mbe_pcmcia_softc *psc = (void *)sc;
|
||||
|
||||
pcmcia_function_disable(psc->sc_pf);
|
||||
pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
|
||||
}
|
||||
|
||||
int
|
||||
mbe_pcmcia_get_enaddr_from_cis(tuple, arg)
|
||||
struct pcmcia_tuple *tuple;
|
||||
void *arg;
|
||||
{
|
||||
struct mbe_pcmcia_get_enaddr_args *p = arg;
|
||||
int i;
|
||||
|
||||
if (tuple->code == PCMCIA_CISTPL_FUNCE) {
|
||||
if (tuple->length < 2) /* sub code and ether addr length */
|
||||
return (0);
|
||||
|
||||
if ((pcmcia_tuple_read_1(tuple, 0) !=
|
||||
PCMCIA_TPLFE_TYPE_LAN_NID) ||
|
||||
(pcmcia_tuple_read_1(tuple, 1) != ETHER_ADDR_LEN))
|
||||
return (0);
|
||||
|
||||
for (i = 0; i < ETHER_ADDR_LEN; i++)
|
||||
p->enaddr[i] = pcmcia_tuple_read_1(tuple, i + 2);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
psc->sc_ih = 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -363,14 +307,12 @@ mbe_pcmcia_get_enaddr_from_io(psc, ea)
|
|||
struct mbe_pcmcia_softc *psc;
|
||||
struct mbe_pcmcia_get_enaddr_args *ea;
|
||||
{
|
||||
struct mb86960_softc *sc = &psc->sc_mb86960;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ETHER_ADDR_LEN; i++)
|
||||
ea->enaddr[i] = bus_space_read_1(psc->sc_pcioh.iot,
|
||||
psc->sc_pcioh.ioh, FE_MBH_ENADDR + i);
|
||||
|
||||
if (ea->enaddr == NULL)
|
||||
return (1);
|
||||
ea->enaddr[i] = bus_space_read_1(sc->sc_bst, sc->sc_bsh,
|
||||
FE_MBH_ENADDR + i);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nca_pcmcia.c,v 1.16 2004/08/10 20:25:03 mycroft Exp $ */
|
||||
/* $NetBSD: nca_pcmcia.c,v 1.17 2004/08/10 20:47:17 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nca_pcmcia.c,v 1.16 2004/08/10 20:25:03 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nca_pcmcia.c,v 1.17 2004/08/10 20:47:17 mycroft Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -196,7 +196,7 @@ nca_pcmcia_attach(parent, self, aux)
|
|||
esc->sc_state = NCA_PCMCIA_ATTACH1;
|
||||
ncr5380_attach(sc);
|
||||
if (esc->sc_state == NCA_PCMCIA_ATTACH1)
|
||||
nca_pcmcia_disable(self, 0);
|
||||
nca_pcmcia_enable(self, 0);
|
||||
esc->sc_state = NCA_PCMCIA_ATTACHED;
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue