commit a more working version if this driver; so far only tested on an

Intel `PRO/100 LAN+Modem56 CardBus II'
This commit is contained in:
joda 1999-10-31 15:12:39 +00:00
parent 8efdaab402
commit b0e5ebfddc

View File

@ -1,34 +1,37 @@
/* $NetBSD: if_fxp_cardbus.c,v 1.2 1999/10/15 06:42:22 haya Exp $ */
/* $NetBSD: if_fxp_cardbus.c,v 1.3 1999/10/31 15:12:39 joda Exp $ */
/*
* Copyright (c) 1999
* Johan Danielsson <joda@pdc.kth.se>. All rights reserved.
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* 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 author.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* This code is derived from software contributed to
* The NetBSD Foundation by Johan Danielsson.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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
* 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. 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.
*/
@ -76,8 +79,8 @@
#include <dev/mii/miivar.h>
#include <dev/pci/if_fxpreg.h>
#include <dev/pci/if_fxpvar.h>
#include <dev/ic/i82557reg.h>
#include <dev/ic/i82557var.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
@ -88,11 +91,16 @@
static int fxp_cardbus_match __P((struct device *, struct cfdata *, void *));
static void fxp_cardbus_attach __P((struct device *, struct device *, void *));
static void fxp_cardbus_setup __P((struct fxp_softc *sc));
static int fxp_cardbus_enable __P((struct fxp_softc *sc));
static void fxp_cardbus_disable __P((struct fxp_softc *sc));
struct fxp_cardbus_softc {
struct fxp_softc sc;
cardbustag_t tag;
cardbus_devfunc_t ct;
pcireg_t base0_reg;
pcireg_t base1_reg;
bus_size_t size;
};
struct cfattach fxp_cardbus_ca = {
@ -105,9 +113,6 @@ struct cfattach fxp_cardbus_ca = {
#define DPRINTF(X)
#endif
/*
* Check if a device is an 82557.
*/
static int
fxp_cardbus_match(parent, match, aux)
struct device *parent;
@ -128,17 +133,6 @@ fxp_cardbus_match(parent, match, aux)
return (0);
}
int
fxp_enable(struct fxp_softc *sc);
static int
fxp_cardbus_enable(struct fxp_softc *sc);
static void
fxp_cardbus_disable(struct fxp_softc *sc);
static void
fxp_cardbus_setup(struct fxp_softc *sc);
static void
fxp_cardbus_attach(parent, self, aux)
struct device *parent, *self;
@ -147,66 +141,43 @@ fxp_cardbus_attach(parent, self, aux)
struct fxp_softc *sc = (struct fxp_softc*)self;
struct fxp_cardbus_softc *csc = (struct fxp_cardbus_softc*)self;
struct cardbus_attach_args *ca = aux;
cardbus_function_tag_t cf = ca->ca_cf;
bus_space_tag_t iot, memt;
bus_space_handle_t ioh, memh;
bus_addr_t adr;
bus_size_t size;
csc->ct = ca->ca_ct;
/*
* Map control/status registers.
*/
#if rbus
cardbus_function_tag_t cf = ct->ct_cf;
if (cardbus_mapreg_map(ct, CARDBUS_BASE1_REG, CARDBUS_MAPREG_TYPE_IO, 0,
&(sc->sc_iot), &ioh, &adr, NULL)) {
panic("io alloc in ex_attach_cardbus\n");
}
csc->base1_reg = adr | 1;
sc->sc_sh = ioh;
#elif unibus
printf("fxp_cardbus_attach: uni %p\n", ca->ca_uni);
if ((*cf->cf_ub.unibus_space_alloc)(ca->ca_uni, ca->bar_info[1].tag, 0,
ca->bar_info[1].size,
ca->bar_info[1].size - 1,
ca->bar_info[1].size,
0, 0, &adr, &ioh))
panic("io alloc");
csc->base1_reg = adr | 1;
sc->sc_st = ca->bar_info[1].tag;
sc->sc_sh = ioh;
if (0) {
/*
* Map control/status registers.
*/
if ((*cf->cf_ub.unibus_space_alloc)(ca->ca_uni, ca->bar_info[0].tag, 0,
ca->bar_info[0].size,
ca->bar_info[0].size - 1,
ca->bar_info[0].size,
0, 0, &adr, &memh))
panic("mem alloc");
sc->sc_st = ca->bar_info[0].tag;
if(Cardbus_mapreg_map(csc->ct, CARDBUS_BASE0_REG,
PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
0, &memt, &memh, &adr, &size) == 0) {
csc->base0_reg = adr;
sc->sc_st = memt;
sc->sc_sh = memh;
}
#endif
csc->tag = ca->ca_tag;
csc->size = size;
} else if(Cardbus_mapreg_map(csc->ct, CARDBUS_BASE1_REG,
PCI_MAPREG_TYPE_IO,
0, &iot, &ioh, &adr, &size) == 0) {
csc->base1_reg = adr | 1;
sc->sc_st = iot;
sc->sc_sh = ioh;
csc->size = size;
} else
panic("%s: failed to allocate mem and io space", __FUNCTION__);
sc->sc_dmat = ca->ca_dmat;
sc->enable = fxp_cardbus_enable;
sc->disable = fxp_cardbus_disable;
sc->enabled = 0;
fxp_cardbus_setup(sc);
printf(": Intel EtherExpress Pro 10+/100B Ethernet\n");
fxp_attach_common(sc);
sc->sc_enable = fxp_cardbus_enable;
sc->sc_disable = fxp_cardbus_disable;
sc->sc_enabled = 0;
fxp_enable(sc);
fxp_attach(sc);
fxp_disable(sc);
}
@ -219,26 +190,24 @@ fxp_cardbus_setup(struct fxp_softc *sc)
cardbus_function_tag_t cf = psc->sc_cf;
pcireg_t command;
printf("fxp_cardbus_setup\n");
cardbus_conf_write(cc, cf, csc->tag, CARDBUS_BASE1_REG, csc->base1_reg);
(cf->cardbus_ctrl)(cc, CARDBUS_IO_ENABLE);
cardbustag_t tag = cardbus_make_tag(cc, cf, csc->ct->ct_bus,
csc->ct->ct_dev, csc->ct->ct_func);
command = Cardbus_conf_read(csc->ct, tag, CARDBUS_COMMAND_STATUS_REG);
if(csc->base0_reg) {
Cardbus_conf_write(csc->ct, tag,
CARDBUS_BASE0_REG, csc->base0_reg);
(cf->cardbus_ctrl)(cc, CARDBUS_MEM_ENABLE);
command |= CARDBUS_COMMAND_MEM_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE;
} else if(csc->base1_reg) {
Cardbus_conf_write(csc->ct, tag,
CARDBUS_BASE1_REG, csc->base1_reg);
(cf->cardbus_ctrl)(cc, CARDBUS_IO_ENABLE);
command |= (CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE);
}
/* enable the card */
command = cardbus_conf_read(cc, cf, csc->tag, CARDBUS_COMMAND_STATUS_REG);
command |= (CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE);
cardbus_conf_write(cc, cf, csc->tag, CARDBUS_COMMAND_STATUS_REG, command);
#if 0
cardbus_conf_write(cc, cf, ca->tag, CARDBUS_BASE0_REG, adr);
(ca->ca_cf->cardbus_ctrl)(cc, CARDBUS_MEM_ENABLE);
/* enable card mem */
command = cardbus_conf_read(cc, cf, ca->tag, CARDBUS_COMMAND_STATUS_REG);
command |= CARDBUS_COMMAND_MEM_ENABLE;
cardbus_conf_write(cc, cf, ca->tag, CARDBUS_COMMAND_STATUS_REG, command);
#endif
Cardbus_conf_write(csc->ct, tag, CARDBUS_COMMAND_STATUS_REG, command);
}
static int
@ -249,7 +218,7 @@ fxp_cardbus_enable(struct fxp_softc *sc)
cardbus_chipset_tag_t cc = psc->sc_cc;
cardbus_function_tag_t cf = psc->sc_cf;
cardbus_function_enable(psc, csc->tag);
cardbus_function_enable(csc->ct);
fxp_cardbus_setup(sc);
@ -274,8 +243,7 @@ fxp_cardbus_disable(struct fxp_softc *sc)
cardbus_chipset_tag_t cc = psc->sc_cc;
cardbus_function_tag_t cf = psc->sc_cf;
fxp_stop(sc);
cardbus_intr_disestablish(cc, cf, sc->sc_ih); /* remove intr handler */
cardbus_function_disable(psc);
cardbus_function_disable(((struct fxp_cardbus_softc*)sc)->ct);
}