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