From 200406b07adaa072e1a30ef1a65dbc349fb5a2c9 Mon Sep 17 00:00:00 2001 From: tsutsui Date: Sat, 5 Oct 2002 15:16:10 +0000 Subject: [PATCH] Overhaul of fmv(4) driver: - Split if_fmv.c into MI/MD part and add ISA-PnP attachment for FMV-183. (XXX FMV-184 is not tested. It would require extra media-select functions..) - Fix probe functions of fmv_isa so that FMV-181A/182A will also match. Fixes port-i386/9476. --- sys/conf/files | 7 +- sys/dev/ic/fmv.c | 173 +++++++++++++++++++++++ sys/dev/{isa/if_fmvreg.h => ic/fmvreg.h} | 16 ++- sys/dev/ic/fmvvar.h | 35 +++++ sys/dev/ic/mb86960var.h | 6 +- sys/dev/isa/files.isa | 8 +- sys/dev/isa/{if_fmv.c => if_fmv_isa.c} | 129 +++-------------- sys/dev/isapnp/files.isapnp | 6 +- sys/dev/isapnp/if_fmv_isapnp.c | 114 +++++++++++++++ 9 files changed, 374 insertions(+), 120 deletions(-) create mode 100644 sys/dev/ic/fmv.c rename sys/dev/{isa/if_fmvreg.h => ic/fmvreg.h} (85%) create mode 100644 sys/dev/ic/fmvvar.h rename sys/dev/isa/{if_fmv.c => if_fmv_isa.c} (69%) create mode 100644 sys/dev/isapnp/if_fmv_isapnp.c diff --git a/sys/conf/files b/sys/conf/files index a7dfe6862d8e..ba020d0e2cc6 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.556 2002/10/04 23:04:53 elric Exp $ +# $NetBSD: files,v 1.557 2002/10/05 15:16:10 tsutsui Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -749,6 +749,11 @@ file dev/ic/we.c we # device ate: arp, ether, ifnet, mb86960 +# Fujitsu FMV-18x Ethernet driver based on Fujitsu MB8696xA controllers +# +device fmv: arp, ether, ifnet, mb86960 +file dev/ic/fmv.c fmv + # Crystal Semiconductor CS8900, CS8920, and CS8920M Ethernet # device cs: arp, ether, ifnet diff --git a/sys/dev/ic/fmv.c b/sys/dev/ic/fmv.c new file mode 100644 index 000000000000..938d927cf2c2 --- /dev/null +++ b/sys/dev/ic/fmv.c @@ -0,0 +1,173 @@ +/* $NetBSD: fmv.c,v 1.1 2002/10/05 15:16:11 tsutsui Exp $ */ + +/* + * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 + * + * This software may be used, modified, copied, distributed, and sold, in + * both source and binary form provided that the above copyright, these + * terms and the following disclaimer are retained. The name of the author + * and/or the contributor may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND THE CONTRIBUTOR ``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 OR THE CONTRIBUTOR 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. + */ + +/* + * Portions copyright (C) 1993, David Greenman. This software may be used, + * modified, copied, distributed, and sold, in both source and binary form + * provided that the above copyright and these terms are retained. Under no + * circumstances is the author responsible for the proper functioning of this + * software, nor does the author assume any responsibility for damages + * incurred with its use. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: fmv.c,v 1.1 2002/10/05 15:16:11 tsutsui Exp $"); + +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +/* + * Determine type and ethernet address. + */ +int +fmv_detect(iot, ioh, enaddr) + bus_space_tag_t iot; + bus_space_handle_t ioh; + u_int8_t *enaddr; +{ + int model, id, type; + + /* Get our station address from EEPROM. */ + bus_space_read_region_1(iot, ioh, FE_FMV4, enaddr, ETHER_ADDR_LEN); + + /* Make sure we got a valid station address. */ + if ((enaddr[0] & 0x03) != 0x00 || + (enaddr[0] == 0x00 && enaddr[1] == 0x00 && enaddr[2] == 0x00)) { +#ifdef FMV_DEBUG + printf("fmv_detect: invalid ethernet address\n"); +#endif + return (0); + } + + /* Determine the card type. */ + model = bus_space_read_1(iot, ioh, FE_FMV0) & FE_FMV0_MODEL; + id = bus_space_read_1(iot, ioh, FE_FMV1) & FE_FMV1_CARDID_REV; + + switch (model) { + case FE_FMV0_MODEL_FMV181: + type = FE_TYPE_FMV181; + if (id == FE_FMV1_CARDID_REV_A) + type = FE_TYPE_FMV181A; + break; + case FE_FMV0_MODEL_FMV182: + type = FE_TYPE_FMV182; + if (id == FE_FMV1_CARDID_REV_A) + type = FE_TYPE_FMV182A; + else if (id == FE_FMV1_CARDID_PNP) + type = FE_TYPE_FMV184; + break; + case FE_FMV0_MODEL_FMV183: + type = FE_TYPE_FMV183; + break; + default: + type = 0; +#ifdef FMV_DEBUG + printf("fmv_detect: unknown card\n"); +#endif + break; + } + + return (type); +} + +void +fmv_attach(sc) + struct mb86960_softc *sc; +{ + bus_space_tag_t iot; + bus_space_handle_t ioh; + const char *typestr; + int type; + u_int8_t myea[ETHER_ADDR_LEN]; + + iot = sc->sc_bst; + ioh = sc->sc_bsh; + + /* Determine the card type. */ + type = fmv_detect(iot, ioh, myea); + switch (type) { + case FE_TYPE_FMV181: + typestr = "FMV-181"; + break; + case FE_TYPE_FMV181A: + typestr = "FMV-181A"; + break; + case FE_TYPE_FMV182: + typestr = "FMV-182"; + break; + case FE_TYPE_FMV182A: + typestr = "FMV-182A"; + break; + case FE_TYPE_FMV183: + typestr = "FMV-183"; + break; + case FE_TYPE_FMV184: + typestr = "FMV-184"; + break; + default: + /* Unknown card type: maybe a new model, but... */ + panic("%s: unknown FMV-18x card", sc->sc_dev.dv_xname); + } + + printf("%s: %s Ethernet\n", sc->sc_dev.dv_xname, typestr); + + /* This interface is always enabled. */ + sc->sc_flags |= FE_FLAGS_ENABLED; + + /* + * Minimum initialization of the hardware. + * We write into registers; hope I/O ports have no + * overlap with other boards. + */ + + /* Initialize ASIC. */ + bus_space_write_1(iot, ioh, FE_FMV3, 0); + bus_space_write_1(iot, ioh, FE_FMV10, 0); + + /* Wait for a while. I'm not sure this is necessary. FIXME */ + delay(200); + + /* + * Do generic MB86960 attach. + */ + mb86960_attach(sc, MB86960_TYPE_86965, myea); + + /* Is this really needs to be done here? XXX */ + /* Turn the "master interrupt control" flag of ASIC on. */ + bus_space_write_1(iot, ioh, FE_FMV3, FE_FMV3_ENABLE_FLAG); + + mb86960_config(sc, NULL, 0, 0); +} diff --git a/sys/dev/isa/if_fmvreg.h b/sys/dev/ic/fmvreg.h similarity index 85% rename from sys/dev/isa/if_fmvreg.h rename to sys/dev/ic/fmvreg.h index 7cfc9233a310..65f5913d82ad 100644 --- a/sys/dev/isa/if_fmvreg.h +++ b/sys/dev/ic/fmvreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_fmvreg.h,v 1.1 2002/09/28 18:43:08 tsutsui Exp $ */ +/* $NetBSD: fmvreg.h,v 1.1 2002/10/05 15:16:11 tsutsui Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -56,12 +56,16 @@ /* Model identification. */ #define FE_FMV0_MODEL 0x07 -#define FE_FMV0_MODEL_FMV181 0x05 -#define FE_FMV0_MODEL_FMV182 0x03 +#define FE_FMV0_MODEL_FMV181 0x05 /* FMV-181/181A */ +#define FE_FMV0_MODEL_FMV182 0x03 /* FMV-182/182A/184 */ +#define FE_FMV0_MODEL_FMV183 0x04 /* FMV-183 */ -/* Card type ID? Always 0? */ -#define FE_FMV1_CARDID_MASK 0xFF -#define FE_FMV1_CARDID_ID 0x00 +/* Card type ID */ +#define FE_FMV1_MAGIC_MASK 0xB0 +#define FE_FMV1_MAGIC_VALUE 0x00 +#define FE_FMV1_CARDID_REV 0x0F +#define FE_FMV1_CARDID_REV_A 0x01 /* FMV-181A/182A */ +#define FE_FMV1_CARDID_PNP 0x08 /* FMV-183/184 */ /* I/O port address assignment. */ #define FE_FMV2_ADDR 0x07 diff --git a/sys/dev/ic/fmvvar.h b/sys/dev/ic/fmvvar.h new file mode 100644 index 000000000000..e4819fcb14b4 --- /dev/null +++ b/sys/dev/ic/fmvvar.h @@ -0,0 +1,35 @@ +/* $NetBSD: fmvvar.h,v 1.1 2002/10/05 15:16:12 tsutsui Exp $ */ + +/* + * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 + * + * This software may be used, modified, copied, distributed, and sold, in + * both source and binary form provided that the above copyright, these + * terms and the following disclaimer are retained. The name of the author + * and/or the contributor may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND THE CONTRIBUTOR ``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 OR THE CONTRIBUTOR 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. + */ + +/* + * Portions copyright (C) 1993, David Greenman. This software may be used, + * modified, copied, distributed, and sold, in both source and binary form + * provided that the above copyright and these terms are retained. Under no + * circumstances is the author responsible for the proper functioning of this + * software, nor does the author assume any responsibility for damages + * incurred with its use. + */ + +int fmv_detect __P((bus_space_tag_t, bus_space_handle_t, u_int8_t *)); +void fmv_attach __P((struct mb86960_softc *)); diff --git a/sys/dev/ic/mb86960var.h b/sys/dev/ic/mb86960var.h index 7b4223478325..69e36b21682c 100644 --- a/sys/dev/ic/mb86960var.h +++ b/sys/dev/ic/mb86960var.h @@ -1,4 +1,4 @@ -/* $NetBSD: mb86960var.h,v 1.30 2002/10/04 21:19:34 tsutsui Exp $ */ +/* $NetBSD: mb86960var.h,v 1.31 2002/10/05 15:16:12 tsutsui Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -106,7 +106,11 @@ enum fe_type { /* Fujitsu FMV-180 series. */ FE_TYPE_FMV181, + FE_TYPE_FMV181A, FE_TYPE_FMV182, + FE_TYPE_FMV182A, + FE_TYPE_FMV183, + FE_TYPE_FMV184, /* Allied-Telesis AT1700 series and RE2000 series. */ FE_TYPE_AT1700T, diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa index b84b9d3c3c14..4574a0acf5ec 100644 --- a/sys/dev/isa/files.isa +++ b/sys/dev/isa/files.isa @@ -1,4 +1,4 @@ -# $NetBSD: files.isa,v 1.126 2002/08/11 13:17:54 isaki Exp $ +# $NetBSD: files.isa,v 1.127 2002/10/05 15:16:13 tsutsui Exp $ # # Config file and device description for machine-independent ISA code. # Included by ports that need it. Requires that the SCSI files be @@ -209,9 +209,9 @@ file dev/isa/if_cs_isa.c cs_isa # Fujitsu MB86960-based boards # (Fujitsu FMV-180 series) -device fmv: arp, ether, ifnet, mb86960 -attach fmv at isa -file dev/isa/if_fmv.c fmv +# device in sys/conf/files +attach fmv at isa with fmv_isa +file dev/isa/if_fmv_isa.c fmv_isa # HP Lan Ethernet controllers # XXX currently broken diff --git a/sys/dev/isa/if_fmv.c b/sys/dev/isa/if_fmv_isa.c similarity index 69% rename from sys/dev/isa/if_fmv.c rename to sys/dev/isa/if_fmv_isa.c index 481b67470b83..ce53d5a1b905 100644 --- a/sys/dev/isa/if_fmv.c +++ b/sys/dev/isa/if_fmv_isa.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_fmv.c,v 1.32 2002/10/02 03:10:47 thorpej Exp $ */ +/* $NetBSD: if_fmv_isa.c,v 1.1 2002/10/05 15:16:12 tsutsui Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -32,13 +32,11 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_fmv.c,v 1.32 2002/10/02 03:10:47 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_fmv_isa.c,v 1.1 2002/10/05 15:16:12 tsutsui Exp $"); #include #include #include -#include -#include #include #include @@ -49,35 +47,33 @@ __KERNEL_RCSID(0, "$NetBSD: if_fmv.c,v 1.32 2002/10/02 03:10:47 thorpej Exp $"); #include #include +#include +#include #include -#include -int fmv_match __P((struct device *, struct cfdata *, void *)); -void fmv_attach __P((struct device *, struct device *, void *)); +int fmv_isa_match __P((struct device *, struct cfdata *, void *)); +void fmv_isa_attach __P((struct device *, struct device *, void *)); -struct fmv_softc { +struct fmv_isa_softc { struct mb86960_softc sc_mb86960; /* real "mb86960" softc */ /* ISA-specific goo. */ void *sc_ih; /* interrupt cookie */ }; -CFATTACH_DECL(fmv, sizeof(struct fmv_softc), - fmv_match, fmv_attach, NULL, NULL); +CFATTACH_DECL(fmv_isa, sizeof(struct fmv_isa_softc), + fmv_isa_match, fmv_isa_attach, NULL, NULL); struct fe_simple_probe_struct { - u_char port; /* Offset from the base I/O address. */ - u_char mask; /* Bits to be checked. */ - u_char bits; /* Values to be compared against. */ + u_int8_t port; /* Offset from the base I/O address. */ + u_int8_t mask; /* Bits to be checked. */ + u_int8_t bits; /* Values to be compared against. */ }; static __inline__ int fe_simple_probe __P((bus_space_tag_t, bus_space_handle_t, struct fe_simple_probe_struct const *)); -static int fmv_find __P((bus_space_tag_t, bus_space_handle_t, int *, - int *)); -static int fmv_detect __P((bus_space_tag_t, bus_space_handle_t, - u_int8_t enaddr[ETHER_ADDR_LEN])); +static int fmv_find __P((bus_space_tag_t, bus_space_handle_t, int *, int *)); static int const fmv_iomap[8] = { 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x300, 0x340 @@ -93,7 +89,7 @@ static int const fmv_iomap[8] = { * Determine if the device is present. */ int -fmv_match(parent, match, aux) +fmv_isa_match(parent, match, aux) struct device *parent; struct cfdata *match; void *aux; @@ -124,7 +120,8 @@ fmv_match(parent, match, aux) break; if (i == NFMV_IOMAP) { #ifdef FMV_DEBUG - printf("fmv_match: unknown iobase 0x%x\n", ia->ia_iobase); + printf("fmv_match: unknown iobase 0x%x\n", + ia->ia_io[0].ir_addr); #endif return (0); } @@ -232,9 +229,9 @@ fmv_find(iot, ioh, iobase, irq) { FE_DLCR4, 0x08, 0x00 }, /* { FE_DLCR5, 0x80, 0x00 }, Doesn't work. */ - { FE_FMV0, FE_FMV0_MAGIC_MASK, FE_FMV0_MAGIC_VALUE }, - { FE_FMV1, FE_FMV1_CARDID_MASK, FE_FMV1_CARDID_ID }, - { FE_FMV3, FE_FMV3_EXTRA_MASK, FE_FMV3_EXTRA_VALUE }, + { FE_FMV0, FE_FMV0_MAGIC_MASK, FE_FMV0_MAGIC_VALUE }, + { FE_FMV1, FE_FMV1_MAGIC_MASK, FE_FMV1_MAGIC_VALUE }, + { FE_FMV3, FE_FMV3_EXTRA_MASK, FE_FMV3_EXTRA_VALUE }, #if 1 /* * Test *vendor* part of the station address for Fujitsu. @@ -276,56 +273,16 @@ fmv_find(iot, ioh, iobase, irq) return (1); } -/* - * Determine type and ethernet address. - */ -static int -fmv_detect(iot, ioh, enaddr) - bus_space_tag_t iot; - bus_space_handle_t ioh; - u_int8_t enaddr[ETHER_ADDR_LEN]; -{ - - /* Get our station address from EEPROM. */ - bus_space_read_region_1(iot, ioh, FE_FMV4, enaddr, ETHER_ADDR_LEN); - - /* Make sure we got a valid station address. */ - if ((enaddr[0] & 0x03) != 0x00 || - (enaddr[0] == 0x00 && enaddr[1] == 0x00 && enaddr[2] == 0x00)) { -#ifdef FMV_DEBUG - printf("fmv_detect: invalid ethernet address\n"); -#endif - return (0); - } - - /* Determine the card type. */ - switch (bus_space_read_1(iot, ioh, FE_FMV0) & FE_FMV0_MODEL) { - case FE_FMV0_MODEL_FMV181: - return (FE_TYPE_FMV181); - case FE_FMV0_MODEL_FMV182: - return (FE_TYPE_FMV182); - } - -#ifdef FMV_DEBUG - printf("fmv_detect: unknown card\n"); -#endif - /* Unknown card type: maybe a new model, but... */ - return (0); -} - void -fmv_attach(parent, self, aux) +fmv_isa_attach(parent, self, aux) struct device *parent, *self; void *aux; { - struct fmv_softc *isc = (struct fmv_softc *)self; + struct fmv_isa_softc *isc = (struct fmv_isa_softc *)self; struct mb86960_softc *sc = &isc->sc_mb86960; struct isa_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_iot; bus_space_handle_t ioh; - u_int8_t myea[ETHER_ADDR_LEN]; - const char *typestr; - int type; printf("\n"); @@ -338,49 +295,7 @@ fmv_attach(parent, self, aux) sc->sc_bst = iot; sc->sc_bsh = ioh; - /* Determine the card type. */ - type = fmv_detect(iot, ioh, myea); - switch (type) { - case FE_TYPE_FMV181: - typestr = "FMV-181"; - break; - case FE_TYPE_FMV182: - typestr = "FMV-182"; - break; - default: - /* Unknown card type: maybe a new model, but... */ - printf("%s: where did the card go?!\n", sc->sc_dev.dv_xname); - panic("unknown card"); - } - - printf("%s: %s Ethernet\n", sc->sc_dev.dv_xname, typestr); - - /* This interface is always enabled. */ - sc->sc_flags |= FE_FLAGS_ENABLED; - - /* - * Minimum initialization of the hardware. - * We write into registers; hope I/O ports have no - * overlap with other boards. - */ - - /* Initialize ASIC. */ - bus_space_write_1(iot, ioh, FE_FMV3, 0); - bus_space_write_1(iot, ioh, FE_FMV10, 0); - - /* Wait for a while. I'm not sure this is necessary. FIXME */ - delay(200); - - /* - * Do generic MB86960 attach. - */ - mb86960_attach(sc, MB86960_TYPE_86965, myea); - - /* Is this really needs to be done here? XXX */ - /* Turn the "master interrupt control" flag of ASIC on. */ - bus_space_write_1(iot, ioh, FE_FMV3, FE_FMV3_ENABLE_FLAG); - - mb86960_config(sc, NULL, 0, 0); + fmv_attach(sc); /* Establish the interrupt handler. */ isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, diff --git a/sys/dev/isapnp/files.isapnp b/sys/dev/isapnp/files.isapnp index 8771aefd1693..df48399d9c6b 100644 --- a/sys/dev/isapnp/files.isapnp +++ b/sys/dev/isapnp/files.isapnp @@ -1,4 +1,4 @@ -# $NetBSD: files.isapnp,v 1.32 2002/04/22 09:41:22 augustss Exp $ +# $NetBSD: files.isapnp,v 1.33 2002/10/05 15:16:14 tsutsui Exp $ # # Config file and device description for machine-independent ISAPnP code. # Included by ports that need it. @@ -18,6 +18,10 @@ file dev/isapnp/isapnpdevs.c isapnp attach ep at isapnp with ep_isapnp file dev/isapnp/if_ep_isapnp.c ep_isapnp +# Fujitsu FMV-183/184 +attach fmv at isapnp with fmv_isapnp +file dev/isapnp/if_fmv_isapnp.c fmv_isapnp + # PCnet-PnP attach le at isapnp with le_isapnp: le24 file dev/isapnp/if_le_isapnp.c le_isapnp diff --git a/sys/dev/isapnp/if_fmv_isapnp.c b/sys/dev/isapnp/if_fmv_isapnp.c new file mode 100644 index 000000000000..e5e37aa92f30 --- /dev/null +++ b/sys/dev/isapnp/if_fmv_isapnp.c @@ -0,0 +1,114 @@ +/* $NetBSD: if_fmv_isapnp.c,v 1.1 2002/10/05 15:16:14 tsutsui Exp $ */ + +/* + * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 + * + * This software may be used, modified, copied, distributed, and sold, in + * both source and binary form provided that the above copyright, these + * terms and the following disclaimer are retained. The name of the author + * and/or the contributor may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND THE CONTRIBUTOR ``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 OR THE CONTRIBUTOR 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. + */ + +/* + * Portions copyright (C) 1993, David Greenman. This software may be used, + * modified, copied, distributed, and sold, in both source and binary form + * provided that the above copyright and these terms are retained. Under no + * circumstances is the author responsible for the proper functioning of this + * software, nor does the author assume any responsibility for damages + * incurred with its use. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: if_fmv_isapnp.c,v 1.1 2002/10/05 15:16:14 tsutsui Exp $"); + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +int fmv_isapnp_match __P((struct device *, struct cfdata *, void *)); +void fmv_isapnp_attach __P((struct device *, struct device *, void *)); + +struct fmv_isapnp_softc { + struct mb86960_softc sc_mb86960; /* real "mb86960" softc */ + + /* ISAPnP-specific goo. */ + void *sc_ih; /* interrupt cookie */ +}; + +CFATTACH_DECL(fmv_isapnp, sizeof(struct fmv_isapnp_softc), + fmv_isapnp_match, fmv_isapnp_attach, NULL, NULL); + +int +fmv_isapnp_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + int pri, variant; + + pri = isapnp_devmatch(aux, &isapnp_fmv_devinfo, &variant); + if (pri && variant > 0) + pri = 0; + return (pri); +} + +void +fmv_isapnp_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct fmv_isapnp_softc *isc = (struct fmv_isapnp_softc *)self; + struct mb86960_softc *sc = &isc->sc_mb86960; + struct isapnp_attach_args * const ipa = aux; + + printf("\n"); + + if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) { + printf("%s: can't configure isapnp resources\n", + sc->sc_dev.dv_xname); + return; + } + + sc->sc_bst = ipa->ipa_iot; + sc->sc_bsh = ipa->ipa_io[0].h; + + fmv_attach(sc); + + /* Establish the interrupt handler. */ + isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num, + ipa->ipa_irq[0].type, IPL_NET, mb86960_intr, sc); + if (isc->sc_ih == NULL) + printf("%s: couldn't establish interrupt handler\n", + sc->sc_dev.dv_xname); +}