Home | History | Annotate | Line # | Download | only in vme
vme.c revision 1.10
      1 /*	$NetBSD: vme.c,v 1.10 2005/06/30 17:03:52 drochner Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *        This product includes software developed by the NetBSD
     18  *        Foundation, Inc. and its contributors.
     19  * 4. Neither the name of The NetBSD Foundation nor the names of its
     20  *    contributors may be used to endorse or promote products derived
     21  *    from this software without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     24  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     25  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     26  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     27  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     33  * POSSIBILITY OF SUCH DAMAGE.
     34  */
     35 
     36 #include <sys/cdefs.h>
     37 __KERNEL_RCSID(0, "$NetBSD: vme.c,v 1.10 2005/06/30 17:03:52 drochner Exp $");
     38 
     39 #include <sys/param.h>
     40 #include <sys/systm.h>
     41 #include <sys/kernel.h>
     42 #include <sys/conf.h>
     43 #include <sys/malloc.h>
     44 #include <sys/device.h>
     45 
     46 #include <machine/intr.h>
     47 
     48 #include <atari/vme/vmevar.h>
     49 
     50 int vmematch __P((struct device *, struct cfdata *, void *));
     51 void vmeattach __P((struct device *, struct device *, void *));
     52 int vmeprint __P((void *, const char *));
     53 
     54 CFATTACH_DECL(vme, sizeof(struct vme_softc),
     55     vmematch, vmeattach, NULL, NULL);
     56 
     57 int	vmesearch __P((struct device *, struct cfdata *,
     58 		       const locdesc_t *, void *));
     59 
     60 int
     61 vmematch(parent, cf, aux)
     62 	struct device *parent;
     63 	struct cfdata *cf;
     64 	void *aux;
     65 {
     66 	struct vmebus_attach_args *vba = aux;
     67 
     68 	if (strcmp(vba->vba_busname, cf->cf_name))
     69 		return (0);
     70 
     71         return (1);
     72 }
     73 
     74 void
     75 vmeattach(parent, self, aux)
     76 	struct device *parent, *self;
     77 	void *aux;
     78 {
     79 	struct vme_softc *sc = (struct vme_softc *)self;
     80 	struct vmebus_attach_args *vba = aux;
     81 
     82 	printf("\n");
     83 
     84 	sc->sc_iot  = vba->vba_iot;
     85 	sc->sc_memt = vba->vba_memt;
     86 	sc->sc_vc   = vba->vba_vc;
     87 
     88 	config_search_ia(vmesearch, self, "vme", NULL);
     89 }
     90 
     91 int
     92 vmeprint(aux, vme)
     93 	void *aux;
     94 	const char *vme;
     95 {
     96 	struct vme_attach_args *va = aux;
     97 
     98 	if (va->va_iosize)
     99 		aprint_normal(" port 0x%x", va->va_iobase);
    100 	if (va->va_iosize > 1)
    101 		aprint_normal("-0x%x", va->va_iobase + va->va_iosize - 1);
    102 	if (va->va_msize)
    103 		aprint_normal(" iomem 0x%x", va->va_maddr);
    104 	if (va->va_msize > 1)
    105 		aprint_normal("-0x%x", va->va_maddr + va->va_msize - 1);
    106 	if (va->va_irq != IRQUNK)
    107 		aprint_normal(" irq %d", va->va_irq);
    108 	return (UNCONF);
    109 }
    110 
    111 int
    112 vmesearch(parent, cf, ldesc, aux)
    113 	struct device *parent;
    114 	struct cfdata *cf;
    115 	const locdesc_t *ldesc;
    116 	void *aux;
    117 {
    118 	struct vme_softc *sc = (struct vme_softc *)parent;
    119 	struct vme_attach_args va;
    120 
    121 	va.va_iot    = sc->sc_iot;
    122 	va.va_memt   = sc->sc_memt;
    123 	va.va_vc     = sc->sc_vc;
    124 	va.va_iobase = cf->cf_iobase;
    125 	va.va_iosize = cf->cf_iosize;
    126 	va.va_maddr  = cf->cf_maddr;
    127 	va.va_msize  = cf->cf_msize;
    128 	va.va_irq    = cf->cf_irq;
    129 
    130 	if (config_match(parent, cf, &va) > 0)
    131 		config_attach(parent, cf, &va, vmeprint);
    132 	return (0);
    133 }
    134