2005-12-11 15:16:03 +03:00
|
|
|
/* $NetBSD: if_mbe_pcmcia.c,v 1.38 2005/12/11 12:23:23 christos Exp $ */
|
1998-03-22 07:32:27 +03:00
|
|
|
|
|
|
|
/*-
|
2004-08-10 22:39:08 +04:00
|
|
|
* Copyright (c) 1998, 2000, 2004 The NetBSD Foundation, Inc.
|
1998-03-22 07:32:27 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Enami Tsugutomo.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 10:24:43 +03:00
|
|
|
#include <sys/cdefs.h>
|
2005-12-11 15:16:03 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: if_mbe_pcmcia.c,v 1.38 2005/12/11 12:23:23 christos Exp $");
|
2001-11-13 10:24:43 +03:00
|
|
|
|
1998-03-22 07:32:27 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_ether.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
|
|
|
|
#include <machine/intr.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
#include <dev/ic/mb86960reg.h>
|
|
|
|
#include <dev/ic/mb86960var.h>
|
|
|
|
|
|
|
|
#include <dev/pcmcia/pcmciareg.h>
|
|
|
|
#include <dev/pcmcia/pcmciavar.h>
|
1998-07-19 21:28:15 +04:00
|
|
|
#include <dev/pcmcia/pcmciadevs.h>
|
1998-03-22 07:32:27 +03:00
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
int mbe_pcmcia_match(struct device *, struct cfdata *, void *);
|
|
|
|
int mbe_pcmcia_validate_config(struct pcmcia_config_entry *);
|
|
|
|
void mbe_pcmcia_attach(struct device *, struct device *, void *);
|
|
|
|
int mbe_pcmcia_detach(struct device *, int);
|
1998-03-22 07:32:27 +03:00
|
|
|
|
|
|
|
struct mbe_pcmcia_softc {
|
|
|
|
struct mb86960_softc sc_mb86960; /* real "mb" softc */
|
|
|
|
|
|
|
|
struct pcmcia_function *sc_pf; /* our PCMCIA function */
|
2004-08-11 00:47:17 +04:00
|
|
|
void *sc_ih; /* interrupt cookie */
|
|
|
|
|
|
|
|
int sc_state;
|
|
|
|
#define MBE_PCMCIA_ATTACHED 3
|
1998-03-22 07:32:27 +03:00
|
|
|
};
|
|
|
|
|
2002-10-01 01:57:46 +04:00
|
|
|
CFATTACH_DECL(mbe_pcmcia, sizeof(struct mbe_pcmcia_softc),
|
2002-10-02 20:51:16 +04:00
|
|
|
mbe_pcmcia_match, mbe_pcmcia_attach, mbe_pcmcia_detach, mb86960_activate);
|
1998-03-22 07:32:27 +03:00
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
int mbe_pcmcia_enable(struct mb86960_softc *);
|
|
|
|
void mbe_pcmcia_disable(struct mb86960_softc *);
|
1998-03-22 07:32:27 +03:00
|
|
|
|
|
|
|
struct mbe_pcmcia_get_enaddr_args {
|
|
|
|
u_int8_t enaddr[ETHER_ADDR_LEN];
|
2000-05-11 23:24:35 +04:00
|
|
|
int maddr;
|
1998-03-22 07:32:27 +03:00
|
|
|
};
|
2005-02-04 05:10:35 +03:00
|
|
|
int mbe_pcmcia_get_enaddr_from_cis(struct pcmcia_tuple *, void *);
|
|
|
|
int mbe_pcmcia_get_enaddr_from_mem(struct mbe_pcmcia_softc *,
|
|
|
|
struct mbe_pcmcia_get_enaddr_args *);
|
|
|
|
int mbe_pcmcia_get_enaddr_from_io(struct mbe_pcmcia_softc *,
|
|
|
|
struct mbe_pcmcia_get_enaddr_args *);
|
1998-03-22 07:32:27 +03:00
|
|
|
|
2001-12-18 14:32:47 +03:00
|
|
|
static const struct mbe_pcmcia_product {
|
2004-08-10 22:39:08 +04:00
|
|
|
struct pcmcia_product mpp_product;
|
2001-12-18 14:32:47 +03:00
|
|
|
int mpp_enet_maddr;
|
2004-08-10 22:39:08 +04:00
|
|
|
int mpp_flags;
|
2001-12-23 12:25:19 +03:00
|
|
|
#define MBH10302 0x0001 /* FUJITSU MBH10302 */
|
1999-04-27 08:56:18 +04:00
|
|
|
} mbe_pcmcia_products[] = {
|
2004-08-10 22:39:08 +04:00
|
|
|
{ { PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_CD021BX,
|
|
|
|
PCMCIA_CIS_TDK_LAK_CD021BX },
|
2005-02-27 03:26:58 +03:00
|
|
|
-1 },
|
1999-11-29 05:28:19 +03:00
|
|
|
|
2004-08-10 22:39:08 +04:00
|
|
|
{ { PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_CF010,
|
|
|
|
PCMCIA_CIS_TDK_LAK_CF010 },
|
2004-08-11 00:47:17 +04:00
|
|
|
-1 },
|
2000-05-15 11:57:19 +04:00
|
|
|
|
1999-04-27 08:56:18 +04:00
|
|
|
#if 0 /* XXX 86960-based? */
|
2004-08-10 22:39:08 +04:00
|
|
|
{ { PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_DFL9610,
|
|
|
|
PCMCIA_CIS_TDK_DFL9610 },
|
2004-08-11 00:47:17 +04:00
|
|
|
-1, MBH10302 /* XXX */ },
|
1999-04-27 08:56:18 +04:00
|
|
|
#endif
|
|
|
|
|
2004-08-10 22:39:08 +04:00
|
|
|
{ { PCMCIA_VENDOR_CONTEC, PCMCIA_PRODUCT_CONTEC_CNETPC,
|
|
|
|
PCMCIA_CIS_CONTEC_CNETPC },
|
2004-08-11 00:47:17 +04:00
|
|
|
-1 },
|
1999-08-24 21:47:44 +04:00
|
|
|
|
2004-08-10 22:39:08 +04:00
|
|
|
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_LA501,
|
|
|
|
PCMCIA_CIS_FUJITSU_LA501 },
|
2004-08-11 00:47:17 +04:00
|
|
|
-1 },
|
1999-04-27 08:56:18 +04:00
|
|
|
|
2004-08-10 22:39:08 +04:00
|
|
|
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_FMV_J181,
|
|
|
|
PCMCIA_CIS_FUJITSU_FMV_J181 },
|
2004-08-11 00:47:17 +04:00
|
|
|
-1, MBH10302 },
|
2001-12-23 12:25:19 +03:00
|
|
|
|
2004-08-10 22:39:08 +04:00
|
|
|
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_FMV_J182,
|
|
|
|
PCMCIA_CIS_FUJITSU_FMV_J182 },
|
2004-08-11 00:47:17 +04:00
|
|
|
0xf2c },
|
2001-12-23 12:25:19 +03:00
|
|
|
|
2004-08-10 22:39:08 +04:00
|
|
|
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_FMV_J182A,
|
|
|
|
PCMCIA_CIS_FUJITSU_FMV_J182A },
|
2004-08-11 00:47:17 +04:00
|
|
|
0x1cc },
|
2000-05-11 23:24:35 +04:00
|
|
|
|
2004-08-10 22:39:08 +04:00
|
|
|
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_ITCFJ182A,
|
|
|
|
PCMCIA_CIS_FUJITSU_ITCFJ182A },
|
2004-08-11 00:47:17 +04:00
|
|
|
0x1cc },
|
2001-12-16 08:44:33 +03:00
|
|
|
|
2004-08-10 22:39:08 +04:00
|
|
|
{ { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_LA10S,
|
|
|
|
PCMCIA_CIS_FUJITSU_LA10S },
|
2004-08-11 00:47:17 +04:00
|
|
|
-1 },
|
2001-12-23 12:25:19 +03:00
|
|
|
|
2004-08-10 22:39:08 +04:00
|
|
|
{ { PCMCIA_VENDOR_RATOC, PCMCIA_PRODUCT_RATOC_REX_R280,
|
|
|
|
PCMCIA_CIS_RATOC_REX_R280 },
|
2004-08-11 00:47:17 +04:00
|
|
|
0x1fc },
|
1999-04-27 08:56:18 +04:00
|
|
|
};
|
2004-08-10 22:39:08 +04:00
|
|
|
static const size_t mbe_pcmcia_nproducts =
|
|
|
|
sizeof(mbe_pcmcia_products) / sizeof(mbe_pcmcia_products[0]);
|
2001-12-18 14:32:47 +03:00
|
|
|
|
1998-03-22 07:32:27 +03:00
|
|
|
int
|
|
|
|
mbe_pcmcia_match(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct pcmcia_attach_args *pa = aux;
|
|
|
|
|
2004-08-10 22:39:08 +04:00
|
|
|
if (pcmcia_product_lookup(pa, mbe_pcmcia_products, mbe_pcmcia_nproducts,
|
|
|
|
sizeof(mbe_pcmcia_products[0]), NULL))
|
1999-04-27 08:56:18 +04:00
|
|
|
return (1);
|
1998-03-22 07:32:27 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2004-08-11 00:47:17 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
1998-03-22 07:32:27 +03:00
|
|
|
void
|
|
|
|
mbe_pcmcia_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
2004-08-11 00:47:17 +04:00
|
|
|
struct mbe_pcmcia_softc *psc = (void *)self;
|
1998-03-22 07:32:27 +03:00
|
|
|
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;
|
1999-04-27 08:56:18 +04:00
|
|
|
const struct mbe_pcmcia_product *mpp;
|
2004-08-11 00:47:17 +04:00
|
|
|
int error;
|
1998-03-22 07:32:27 +03:00
|
|
|
|
|
|
|
psc->sc_pf = pa->pf;
|
|
|
|
|
2004-08-11 00:47:17 +04:00
|
|
|
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;
|
1998-03-22 07:32:27 +03:00
|
|
|
}
|
|
|
|
|
2004-08-11 00:47:17 +04:00
|
|
|
cfe = pa->pf->cfe;
|
|
|
|
sc->sc_bst = cfe->iospace[0].handle.iot;
|
|
|
|
sc->sc_bsh = cfe->iospace[0].handle.ioh;
|
1998-03-22 07:32:27 +03:00
|
|
|
|
2004-08-11 00:47:17 +04:00
|
|
|
mpp = pcmcia_product_lookup(pa, mbe_pcmcia_products,
|
|
|
|
mbe_pcmcia_nproducts, sizeof(mbe_pcmcia_products[0]), NULL);
|
|
|
|
if (!mpp)
|
|
|
|
panic("mbe_pcmcia_attach: impossible");
|
1998-03-22 07:32:27 +03:00
|
|
|
|
2001-12-23 12:25:19 +03:00
|
|
|
/* Read station address from io/mem or CIS. */
|
2000-05-15 11:57:19 +04:00
|
|
|
if (mpp->mpp_enet_maddr >= 0) {
|
|
|
|
pgea.maddr = mpp->mpp_enet_maddr;
|
2000-05-11 23:24:35 +04:00
|
|
|
if (mbe_pcmcia_get_enaddr_from_mem(psc, &pgea) != 0) {
|
2004-08-11 00:47:17 +04:00
|
|
|
printf("%s: couldn't get ethernet address "
|
|
|
|
"from memory\n", self->dv_xname);
|
2004-08-11 07:56:03 +04:00
|
|
|
goto fail;
|
2000-05-11 23:24:35 +04:00
|
|
|
}
|
2004-08-11 00:47:17 +04:00
|
|
|
} else if (mpp->mpp_flags & MBH10302) {
|
2001-12-23 12:25:19 +03:00
|
|
|
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) {
|
2004-08-11 00:47:17 +04:00
|
|
|
printf("%s: couldn't get ethernet address from i/o\n",
|
|
|
|
self->dv_xname);
|
2004-08-11 07:56:03 +04:00
|
|
|
goto fail;
|
2001-12-23 12:25:19 +03:00
|
|
|
}
|
2000-05-11 23:24:35 +04:00
|
|
|
} else {
|
2004-08-11 00:47:17 +04:00
|
|
|
if (pa->pf->pf_funce_lan_nidlen != ETHER_ADDR_LEN) {
|
|
|
|
printf("%s: couldn't get ethernet address from CIS\n",
|
|
|
|
self->dv_xname);
|
2004-08-11 07:56:03 +04:00
|
|
|
goto fail;
|
2000-05-11 23:24:35 +04:00
|
|
|
}
|
2004-08-11 00:47:17 +04:00
|
|
|
memcpy(pgea.enaddr, pa->pf->pf_funce_lan_nid, ETHER_ADDR_LEN);
|
2000-05-11 23:24:35 +04:00
|
|
|
}
|
1998-03-22 07:32:27 +03:00
|
|
|
|
|
|
|
/* Perform generic initialization. */
|
2004-08-11 00:47:17 +04:00
|
|
|
if (mpp->mpp_flags & MBH10302)
|
2002-11-30 17:15:10 +03:00
|
|
|
sc->sc_flags |= FE_FLAGS_MB86960;
|
|
|
|
|
2004-08-11 07:56:03 +04:00
|
|
|
sc->sc_enable = mbe_pcmcia_enable;
|
|
|
|
sc->sc_disable = mbe_pcmcia_disable;
|
|
|
|
|
|
|
|
error = mbe_pcmcia_enable(sc);
|
|
|
|
if (error)
|
|
|
|
goto fail;
|
1998-03-22 07:32:27 +03:00
|
|
|
|
2004-08-11 07:56:03 +04:00
|
|
|
mb86960_attach(sc, pgea.enaddr);
|
1998-03-22 07:32:27 +03:00
|
|
|
mb86960_config(sc, NULL, 0, 0);
|
|
|
|
|
2004-08-11 00:47:17 +04:00
|
|
|
mbe_pcmcia_disable(sc);
|
|
|
|
psc->sc_state = MBE_PCMCIA_ATTACHED;
|
2000-02-04 06:38:06 +03:00
|
|
|
return;
|
|
|
|
|
2004-08-11 00:47:17 +04:00
|
|
|
fail:
|
|
|
|
pcmcia_function_unconfigure(pa->pf);
|
1998-03-22 07:32:27 +03:00
|
|
|
}
|
|
|
|
|
1998-11-17 23:44:02 +03:00
|
|
|
int
|
|
|
|
mbe_pcmcia_detach(self, flags)
|
|
|
|
struct device *self;
|
|
|
|
int flags;
|
|
|
|
{
|
2004-08-11 00:47:17 +04:00
|
|
|
struct mbe_pcmcia_softc *psc = (void *)self;
|
2000-02-02 12:34:51 +03:00
|
|
|
int error;
|
|
|
|
|
2004-08-11 00:47:17 +04:00
|
|
|
if (psc->sc_state != MBE_PCMCIA_ATTACHED)
|
2000-02-04 06:38:06 +03:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
error = mb86960_detach(&psc->sc_mb86960);
|
2004-08-11 00:47:17 +04:00
|
|
|
if (error)
|
2000-02-02 12:34:51 +03:00
|
|
|
return (error);
|
1998-11-18 21:15:56 +03:00
|
|
|
|
2004-08-11 00:47:17 +04:00
|
|
|
pcmcia_function_unconfigure(psc->sc_pf);
|
1998-11-17 23:44:02 +03:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1998-03-22 07:32:27 +03:00
|
|
|
int
|
|
|
|
mbe_pcmcia_enable(sc)
|
|
|
|
struct mb86960_softc *sc;
|
|
|
|
{
|
2004-08-11 00:47:17 +04:00
|
|
|
struct mbe_pcmcia_softc *psc = (void *)sc;
|
|
|
|
int error;
|
1998-03-22 07:32:27 +03:00
|
|
|
|
|
|
|
/* Establish the interrupt handler. */
|
|
|
|
psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, mb86960_intr,
|
|
|
|
sc);
|
2004-08-11 00:47:17 +04:00
|
|
|
if (!psc->sc_ih)
|
|
|
|
return (EIO);
|
1998-03-22 07:32:27 +03:00
|
|
|
|
2004-08-11 00:47:17 +04:00
|
|
|
error = pcmcia_function_enable(psc->sc_pf);
|
|
|
|
if (error) {
|
2000-02-04 12:30:28 +03:00
|
|
|
pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
|
2004-08-11 00:47:17 +04:00
|
|
|
psc->sc_ih = 0;
|
2000-02-04 12:30:28 +03:00
|
|
|
}
|
2000-02-04 07:54:51 +03:00
|
|
|
|
2004-08-11 00:47:17 +04:00
|
|
|
return (error);
|
1998-03-22 07:32:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mbe_pcmcia_disable(sc)
|
|
|
|
struct mb86960_softc *sc;
|
|
|
|
{
|
2004-08-11 00:47:17 +04:00
|
|
|
struct mbe_pcmcia_softc *psc = (void *)sc;
|
1998-03-22 07:32:27 +03:00
|
|
|
|
|
|
|
pcmcia_function_disable(psc->sc_pf);
|
2000-02-04 12:30:28 +03:00
|
|
|
pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
|
2004-08-11 00:47:17 +04:00
|
|
|
psc->sc_ih = 0;
|
1998-03-22 07:32:27 +03:00
|
|
|
}
|
2000-05-11 23:24:35 +04:00
|
|
|
|
2001-12-23 12:25:19 +03:00
|
|
|
int
|
|
|
|
mbe_pcmcia_get_enaddr_from_io(psc, ea)
|
|
|
|
struct mbe_pcmcia_softc *psc;
|
|
|
|
struct mbe_pcmcia_get_enaddr_args *ea;
|
2005-02-27 03:26:58 +03:00
|
|
|
{
|
2004-08-11 00:47:17 +04:00
|
|
|
struct mb86960_softc *sc = &psc->sc_mb86960;
|
2001-12-23 12:25:19 +03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ETHER_ADDR_LEN; i++)
|
2004-08-11 00:47:17 +04:00
|
|
|
ea->enaddr[i] = bus_space_read_1(sc->sc_bst, sc->sc_bsh,
|
|
|
|
FE_MBH_ENADDR + i);
|
2001-12-23 12:25:19 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-11 23:24:35 +04:00
|
|
|
int
|
|
|
|
mbe_pcmcia_get_enaddr_from_mem(psc, ea)
|
|
|
|
struct mbe_pcmcia_softc *psc;
|
|
|
|
struct mbe_pcmcia_get_enaddr_args *ea;
|
|
|
|
{
|
|
|
|
struct mb86960_softc *sc = &psc->sc_mb86960;
|
|
|
|
struct pcmcia_mem_handle pcmh;
|
2001-12-15 16:23:20 +03:00
|
|
|
bus_size_t offset;
|
2000-05-15 12:08:12 +04:00
|
|
|
int i, mwindow, rv = 1;
|
2000-05-11 23:24:35 +04:00
|
|
|
|
|
|
|
if (ea->maddr < 0)
|
2000-05-15 12:08:12 +04:00
|
|
|
goto bad_memaddr;
|
2000-05-11 23:24:35 +04:00
|
|
|
|
|
|
|
if (pcmcia_mem_alloc(psc->sc_pf, ETHER_ADDR_LEN * 2, &pcmh)) {
|
2005-02-27 03:26:58 +03:00
|
|
|
printf("%s: can't alloc mem for enet addr\n",
|
2000-05-15 11:57:19 +04:00
|
|
|
sc->sc_dev.dv_xname);
|
2000-05-15 12:08:12 +04:00
|
|
|
goto memalloc_failed;
|
2000-05-11 23:24:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR, ea->maddr,
|
2000-05-15 11:57:19 +04:00
|
|
|
ETHER_ADDR_LEN * 2, &pcmh, &offset, &mwindow)) {
|
2005-02-27 03:26:58 +03:00
|
|
|
printf("%s: can't map mem for enet addr\n",
|
2000-05-15 11:57:19 +04:00
|
|
|
sc->sc_dev.dv_xname);
|
2000-05-15 12:08:12 +04:00
|
|
|
goto memmap_failed;
|
2000-05-11 23:24:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ETHER_ADDR_LEN; i++)
|
|
|
|
ea->enaddr[i] = bus_space_read_1(pcmh.memt, pcmh.memh,
|
2000-05-15 11:57:19 +04:00
|
|
|
offset + (i * 2));
|
2000-05-11 23:24:35 +04:00
|
|
|
|
2000-05-15 12:08:12 +04:00
|
|
|
rv = 0;
|
2000-05-11 23:24:35 +04:00
|
|
|
pcmcia_mem_unmap(psc->sc_pf, mwindow);
|
2000-05-15 12:08:12 +04:00
|
|
|
memmap_failed:
|
2000-05-11 23:24:35 +04:00
|
|
|
pcmcia_mem_free(psc->sc_pf, &pcmh);
|
2000-05-15 12:08:12 +04:00
|
|
|
memalloc_failed:
|
|
|
|
bad_memaddr:
|
2000-05-11 23:24:35 +04:00
|
|
|
|
2000-05-15 12:08:12 +04:00
|
|
|
return (rv);
|
2000-05-11 23:24:35 +04:00
|
|
|
}
|