Home | History | Annotate | Line # | Download | only in isapnp
aic_isapnp.c revision 1.15
      1  1.15        ad /*	$NetBSD: aic_isapnp.c,v 1.15 2007/10/19 12:00:30 ad Exp $	*/
      2   1.1     enami 
      3   1.1     enami /*-
      4   1.1     enami  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5   1.1     enami  * All rights reserved.
      6   1.1     enami  *
      7   1.1     enami  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1     enami  * by Enami Tsugutomo <enami (at) but-b.or.jp>
      9   1.1     enami  *
     10   1.1     enami  * Redistribution and use in source and binary forms, with or without
     11   1.1     enami  * modification, are permitted provided that the following conditions
     12   1.1     enami  * are met:
     13   1.1     enami  * 1. Redistributions of source code must retain the above copyright
     14   1.1     enami  *    notice, this list of conditions and the following disclaimer.
     15   1.1     enami  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1     enami  *    notice, this list of conditions and the following disclaimer in the
     17   1.1     enami  *    documentation and/or other materials provided with the distribution.
     18   1.1     enami  * 3. All advertising materials mentioning features or use of this software
     19   1.1     enami  *    must display the following acknowledgement:
     20   1.1     enami  *        This product includes software developed by the NetBSD
     21   1.1     enami  *        Foundation, Inc. and its contributors.
     22   1.1     enami  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23   1.1     enami  *    contributors may be used to endorse or promote products derived
     24   1.1     enami  *    from this software without specific prior written permission.
     25   1.1     enami  *
     26   1.1     enami  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27   1.1     enami  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28   1.1     enami  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29   1.1     enami  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30   1.1     enami  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31   1.1     enami  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32   1.1     enami  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33   1.1     enami  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34   1.1     enami  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35   1.1     enami  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36   1.1     enami  * POSSIBILITY OF SUCH DAMAGE.
     37   1.1     enami  */
     38   1.6     lukem 
     39   1.6     lukem #include <sys/cdefs.h>
     40  1.15        ad __KERNEL_RCSID(0, "$NetBSD: aic_isapnp.c,v 1.15 2007/10/19 12:00:30 ad Exp $");
     41   1.1     enami 
     42   1.1     enami #include <sys/param.h>
     43   1.1     enami #include <sys/systm.h>
     44   1.1     enami #include <sys/device.h>
     45   1.1     enami 
     46  1.15        ad #include <sys/bus.h>
     47   1.1     enami 
     48   1.1     enami #include <dev/isa/isavar.h>
     49   1.1     enami 
     50   1.1     enami #include <dev/isapnp/isapnpreg.h>
     51   1.1     enami #include <dev/isapnp/isapnpvar.h>
     52   1.3  christos #include <dev/isapnp/isapnpdevs.h>
     53   1.1     enami 
     54   1.1     enami #include <dev/scsipi/scsipi_all.h>
     55   1.1     enami #include <dev/scsipi/scsipiconf.h>
     56   1.1     enami #include <dev/scsipi/scsi_all.h>
     57   1.1     enami 
     58   1.1     enami #include <dev/ic/aic6360var.h>
     59   1.1     enami 
     60   1.1     enami struct aic_isapnp_softc {
     61   1.1     enami 	struct	aic_softc sc_aic;	/* real "com" softc */
     62   1.1     enami 
     63   1.1     enami 	/* ISAPnP-specific goo. */
     64   1.1     enami 	void	*sc_ih;			/* interrupt handler */
     65   1.1     enami };
     66   1.1     enami 
     67  1.10     perry int	aic_isapnp_match(struct device *, struct cfdata *, void *);
     68  1.10     perry void	aic_isapnp_attach(struct device *, struct device *, void *);
     69   1.1     enami 
     70   1.8   thorpej CFATTACH_DECL(aic_isapnp, sizeof(struct aic_isapnp_softc),
     71   1.9   thorpej     aic_isapnp_match, aic_isapnp_attach, NULL, NULL);
     72   1.1     enami 
     73   1.1     enami int
     74  1.14  christos aic_isapnp_match(struct device *parent, struct cfdata *match,
     75  1.13  christos     void *aux)
     76   1.1     enami {
     77   1.5   mycroft 	int pri, variant;
     78   1.4   mycroft 
     79   1.5   mycroft 	pri = isapnp_devmatch(aux, &isapnp_aic_devinfo, &variant);
     80   1.5   mycroft 	if (pri && variant > 0)
     81   1.5   mycroft 		pri = 0;
     82   1.5   mycroft 	return (pri);
     83   1.1     enami }
     84   1.1     enami 
     85   1.1     enami void
     86  1.14  christos aic_isapnp_attach(struct device *parent, struct device *self,
     87  1.13  christos     void *aux)
     88   1.1     enami {
     89  1.12   thorpej 	struct aic_isapnp_softc *isc = device_private(self);
     90   1.1     enami 	struct aic_softc *sc = &isc->sc_aic;
     91   1.1     enami 	struct isapnp_attach_args *ipa = aux;
     92   1.1     enami 
     93   1.1     enami 	printf("\n");
     94   1.1     enami 
     95   1.1     enami 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
     96   1.1     enami 		printf("%s: error in region allocation\n",
     97   1.1     enami 		    sc->sc_dev.dv_xname);
     98   1.1     enami 		return;
     99   1.1     enami 	}
    100   1.1     enami 
    101   1.1     enami 	sc->sc_iot = ipa->ipa_iot;
    102   1.1     enami 	sc->sc_ioh = ipa->ipa_io[0].h;
    103   1.1     enami 
    104   1.1     enami 	if (!aic_find(sc->sc_iot, sc->sc_ioh)) {
    105   1.1     enami 		printf("%s: couldn't find device\n", sc->sc_dev.dv_xname);
    106   1.1     enami 		return;
    107   1.1     enami 	}
    108   1.1     enami 
    109   1.1     enami 	aicattach(sc);
    110   1.1     enami 
    111   1.1     enami 	/* Establish the interrupt handler. */
    112   1.1     enami 	isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
    113   1.1     enami 	    ipa->ipa_irq[0].type, IPL_BIO, aicintr, sc);
    114   1.1     enami 	if (isc->sc_ih == NULL)
    115   1.1     enami 		printf("%s: couldn't establish interrupt\n",
    116   1.1     enami 		    sc->sc_dev.dv_xname);
    117   1.1     enami }
    118