Home | History | Annotate | Line # | Download | only in isapnp
if_fmv_isapnp.c revision 1.2.2.2
      1 /*	$NetBSD: if_fmv_isapnp.c,v 1.2.2.2 2002/10/18 02:42:42 nathanw Exp $	*/
      2 
      3 /*
      4  * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
      5  *
      6  * This software may be used, modified, copied, distributed, and sold, in
      7  * both source and binary form provided that the above copyright, these
      8  * terms and the following disclaimer are retained.  The name of the author
      9  * and/or the contributor may not be used to endorse or promote products
     10  * derived from this software without specific prior written permission.
     11  *
     12  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND THE CONTRIBUTOR ``AS IS'' AND
     13  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     14  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     15  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR THE CONTRIBUTOR BE LIABLE
     16  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     17  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     18  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION.
     19  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     20  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     21  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     22  * SUCH DAMAGE.
     23  */
     24 
     25 /*
     26  * Portions copyright (C) 1993, David Greenman.  This software may be used,
     27  * modified, copied, distributed, and sold, in both source and binary form
     28  * provided that the above copyright and these terms are retained.  Under no
     29  * circumstances is the author responsible for the proper functioning of this
     30  * software, nor does the author assume any responsibility for damages
     31  * incurred with its use.
     32  */
     33 
     34 #include <sys/cdefs.h>
     35 __KERNEL_RCSID(0, "$NetBSD: if_fmv_isapnp.c,v 1.2.2.2 2002/10/18 02:42:42 nathanw Exp $");
     36 
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 #include <sys/device.h>
     40 
     41 #include <net/if.h>
     42 #include <net/if_ether.h>
     43 #include <net/if_media.h>
     44 
     45 #include <machine/bus.h>
     46 #include <machine/intr.h>
     47 
     48 #include <dev/ic/mb86960reg.h>
     49 #include <dev/ic/mb86960var.h>
     50 #include <dev/ic/fmvreg.h>
     51 #include <dev/ic/fmvvar.h>
     52 
     53 #include <dev/isa/isavar.h>
     54 
     55 #include <dev/isapnp/isapnpreg.h>
     56 #include <dev/isapnp/isapnpvar.h>
     57 #include <dev/isapnp/isapnpdevs.h>
     58 
     59 int	fmv_isapnp_match __P((struct device *, struct cfdata *, void *));
     60 void	fmv_isapnp_attach __P((struct device *, struct device *, void *));
     61 
     62 struct fmv_isapnp_softc {
     63 	struct	mb86960_softc sc_mb86960;	/* real "mb86960" softc */
     64 
     65 	/* ISAPnP-specific goo. */
     66 	void	*sc_ih;				/* interrupt cookie */
     67 };
     68 
     69 CFATTACH_DECL(fmv_isapnp, sizeof(struct fmv_isapnp_softc),
     70     fmv_isapnp_match, fmv_isapnp_attach, NULL, NULL);
     71 
     72 int
     73 fmv_isapnp_match(parent, match, aux)
     74 	struct device *parent;
     75 	struct cfdata *match;
     76 	void *aux;
     77 {
     78 	int pri, variant;
     79 
     80 	pri = isapnp_devmatch(aux, &isapnp_fmv_devinfo, &variant);
     81 	if (pri && variant > 0)
     82 		pri = 0;
     83 	return (pri);
     84 }
     85 
     86 void
     87 fmv_isapnp_attach(parent, self, aux)
     88 	struct device *parent, *self;
     89 	void *aux;
     90 {
     91 	struct fmv_isapnp_softc *isc = (struct fmv_isapnp_softc *)self;
     92 	struct mb86960_softc *sc = &isc->sc_mb86960;
     93 	struct isapnp_attach_args * const ipa = aux;
     94 
     95 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
     96 		printf(": can't configure isapnp resources\n");
     97 		return;
     98 	}
     99 
    100 	sc->sc_bst = ipa->ipa_iot;
    101 	sc->sc_bsh = ipa->ipa_io[0].h;
    102 
    103 	fmv_attach(sc);
    104 
    105 	/* Establish the interrupt handler. */
    106 	isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
    107 	    ipa->ipa_irq[0].type, IPL_NET, mb86960_intr, sc);
    108 	if (isc->sc_ih == NULL)
    109 		printf("%s: couldn't establish interrupt handler\n",
    110 		    sc->sc_dev.dv_xname);
    111 }
    112