xref: /netbsd-src/sys/arch/atari/vme/vme.c (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1 /*	$NetBSD: vme.c,v 1.9 2003/07/15 01:19:56 lukem 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.9 2003/07/15 01:19:56 lukem 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 *, void *));
58 
59 int
60 vmematch(parent, cf, aux)
61 	struct device *parent;
62 	struct cfdata *cf;
63 	void *aux;
64 {
65 	struct vmebus_attach_args *vba = aux;
66 
67 	if (strcmp(vba->vba_busname, cf->cf_name))
68 		return (0);
69 
70         return (1);
71 }
72 
73 void
74 vmeattach(parent, self, aux)
75 	struct device *parent, *self;
76 	void *aux;
77 {
78 	struct vme_softc *sc = (struct vme_softc *)self;
79 	struct vmebus_attach_args *vba = aux;
80 
81 	printf("\n");
82 
83 	sc->sc_iot  = vba->vba_iot;
84 	sc->sc_memt = vba->vba_memt;
85 	sc->sc_vc   = vba->vba_vc;
86 
87 	config_search(vmesearch, self, NULL);
88 }
89 
90 int
91 vmeprint(aux, vme)
92 	void *aux;
93 	const char *vme;
94 {
95 	struct vme_attach_args *va = aux;
96 
97 	if (va->va_iosize)
98 		aprint_normal(" port 0x%x", va->va_iobase);
99 	if (va->va_iosize > 1)
100 		aprint_normal("-0x%x", va->va_iobase + va->va_iosize - 1);
101 	if (va->va_msize)
102 		aprint_normal(" iomem 0x%x", va->va_maddr);
103 	if (va->va_msize > 1)
104 		aprint_normal("-0x%x", va->va_maddr + va->va_msize - 1);
105 	if (va->va_irq != IRQUNK)
106 		aprint_normal(" irq %d", va->va_irq);
107 	return (UNCONF);
108 }
109 
110 int
111 vmesearch(parent, cf, aux)
112 	struct device *parent;
113 	struct cfdata *cf;
114 	void *aux;
115 {
116 	struct vme_softc *sc = (struct vme_softc *)parent;
117 	struct vme_attach_args va;
118 
119 	va.va_iot    = sc->sc_iot;
120 	va.va_memt   = sc->sc_memt;
121 	va.va_vc     = sc->sc_vc;
122 	va.va_iobase = cf->cf_iobase;
123 	va.va_iosize = cf->cf_iosize;
124 	va.va_maddr  = cf->cf_maddr;
125 	va.va_msize  = cf->cf_msize;
126 	va.va_irq    = cf->cf_irq;
127 
128 	if (config_match(parent, cf, &va) > 0)
129 		config_attach(parent, cf, &va, vmeprint);
130 	return (0);
131 }
132