Home | History | Annotate | Line # | Download | only in isapnp
if_fmv_isapnp.c revision 1.6.8.1
      1 /*	$NetBSD: if_fmv_isapnp.c,v 1.6.8.1 2006/11/18 21:34:26 ad 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.6.8.1 2006/11/18 21:34:26 ad 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(struct device *, struct cfdata *, void *);
     66 void	fmv_isapnp_attach(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(struct device *parent, struct cfdata *match,
     80     void *aux)
     81 {
     82 	int pri, variant;
     83 
     84 	pri = isapnp_devmatch(aux, &isapnp_fmv_devinfo, &variant);
     85 	if (pri && variant > 0)
     86 		pri = 0;
     87 	return pri;
     88 }
     89 
     90 void
     91 fmv_isapnp_attach(struct device *parent, struct device *self,
     92     void *aux)
     93 {
     94 	struct fmv_isapnp_softc *isc = device_private(self);
     95 	struct mb86960_softc *sc = &isc->sc_mb86960;
     96 	struct isapnp_attach_args * const ipa = aux;
     97 
     98 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
     99 		printf(": can't configure isapnp resources\n");
    100 		return;
    101 	}
    102 
    103 	sc->sc_bst = ipa->ipa_iot;
    104 	sc->sc_bsh = ipa->ipa_io[0].h;
    105 
    106 	fmv_attach(sc);
    107 
    108 	/* Establish the interrupt handler. */
    109 	isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
    110 	    ipa->ipa_irq[0].type, IPL_NET, mb86960_intr, sc);
    111 	if (isc->sc_ih == NULL)
    112 		printf("%s: couldn't establish interrupt handler\n",
    113 		    sc->sc_dev.dv_xname);
    114 }
    115