Home | History | Annotate | Line # | Download | only in isapnp
if_fmv_isapnp.c revision 1.2.2.3
      1 /*	$NetBSD: if_fmv_isapnp.c,v 1.2.2.3 2002/12/11 06:38:12 thorpej Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center and Matt Thomas of the 3am Software Foundry.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *      This product includes software developed by the NetBSD
     22  *      Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 #include <sys/cdefs.h>
     41 __KERNEL_RCSID(0, "$NetBSD: if_fmv_isapnp.c,v 1.2.2.3 2002/12/11 06:38:12 thorpej Exp $");
     42 
     43 #include <sys/param.h>
     44 #include <sys/systm.h>
     45 #include <sys/device.h>
     46 
     47 #include <net/if.h>
     48 #include <net/if_ether.h>
     49 #include <net/if_media.h>
     50 
     51 #include <machine/bus.h>
     52 #include <machine/intr.h>
     53 
     54 #include <dev/ic/mb86960reg.h>
     55 #include <dev/ic/mb86960var.h>
     56 #include <dev/ic/fmvreg.h>
     57 #include <dev/ic/fmvvar.h>
     58 
     59 #include <dev/isa/isavar.h>
     60 
     61 #include <dev/isapnp/isapnpreg.h>
     62 #include <dev/isapnp/isapnpvar.h>
     63 #include <dev/isapnp/isapnpdevs.h>
     64 
     65 int	fmv_isapnp_match __P((struct device *, struct cfdata *, void *));
     66 void	fmv_isapnp_attach __P((struct device *, struct device *, void *));
     67 
     68 struct fmv_isapnp_softc {
     69 	struct	mb86960_softc sc_mb86960;	/* real "mb86960" softc */
     70 
     71 	/* ISAPnP-specific goo. */
     72 	void	*sc_ih;				/* interrupt cookie */
     73 };
     74 
     75 CFATTACH_DECL(fmv_isapnp, sizeof(struct fmv_isapnp_softc),
     76     fmv_isapnp_match, fmv_isapnp_attach, NULL, NULL);
     77 
     78 int
     79 fmv_isapnp_match(parent, match, aux)
     80 	struct device *parent;
     81 	struct cfdata *match;
     82 	void *aux;
     83 {
     84 	int pri, variant;
     85 
     86 	pri = isapnp_devmatch(aux, &isapnp_fmv_devinfo, &variant);
     87 	if (pri && variant > 0)
     88 		pri = 0;
     89 	return (pri);
     90 }
     91 
     92 void
     93 fmv_isapnp_attach(parent, self, aux)
     94 	struct device *parent, *self;
     95 	void *aux;
     96 {
     97 	struct fmv_isapnp_softc *isc = (struct fmv_isapnp_softc *)self;
     98 	struct mb86960_softc *sc = &isc->sc_mb86960;
     99 	struct isapnp_attach_args * const ipa = aux;
    100 
    101 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
    102 		printf(": can't configure isapnp resources\n");
    103 		return;
    104 	}
    105 
    106 	sc->sc_bst = ipa->ipa_iot;
    107 	sc->sc_bsh = ipa->ipa_io[0].h;
    108 
    109 	fmv_attach(sc);
    110 
    111 	/* Establish the interrupt handler. */
    112 	isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
    113 	    ipa->ipa_irq[0].type, IPL_NET, mb86960_intr, sc);
    114 	if (isc->sc_ih == NULL)
    115 		printf("%s: couldn't establish interrupt handler\n",
    116 		    sc->sc_dev.dv_xname);
    117 }
    118