vidc20.c revision 1.2 1 /* $NetBSD: vidc20.c,v 1.2 2002/06/06 21:03:28 bjh21 Exp $ */
2
3 /*
4 * Copyright (c) 1997 Mark Brinicombe
5 * Copyright (c) 1997 Causality Limited
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Mark Brinicombe
19 * 4. The name of the company nor the name of the author may be used to
20 * endorse or promote products derived from this software without specific
21 * prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
24 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
27 * 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
33 * THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 * RiscBSD kernel project
36 *
37 * vidc20.c
38 *
39 * VIDC20 driver
40 *
41 * Created : 22/02/97
42 */
43
44 #include <sys/cdefs.h>
45 #include <sys/types.h>
46 #include <sys/param.h>
47 #include <sys/systm.h>
48 #include <sys/device.h>
49
50 #include <machine/bus.h>
51 #include <arm/iomd/vidc.h>
52 #include <machine/io.h>
53 #include <arm/iomd/iomdreg.h>
54 #include <arm/iomd/iomdvar.h>
55 #include <arm/mainbus/mainbus.h>
56
57 #include "locators.h"
58
59 struct vidc20_softc {
60 struct device sc_dev;
61 bus_space_tag_t sc_iot;
62 };
63
64 static int vidcmatch __P((struct device *self, struct cfdata *cf, void *aux));
65 static void vidcattach __P((struct device *parent, struct device *self, void *aux));
66 static int vidcprint __P((void *aux, const char *name));
67 static int vidcsearch __P((struct device *, struct cfdata *, void *));
68
69 /*
70 * vidc_base gives the base of the VIDC chip in memory; this is for the rest isnt
71 * busspaceified yet. Initialised with VIDC_BASE for backwards compatibility.
72 */
73 int *vidc_base = (int *) VIDC_BASE;
74
75
76 /*
77 * vidc_fref is the reference frequency in Mhz of the detected VIDC (dependent on IOMD/IOC)
78 * XXX default is RPC600 ?
79 */
80 int vidc_fref = 24000000;
81
82
83 struct cfattach vidc_ca = {
84 sizeof (struct vidc20_softc), vidcmatch, vidcattach
85 };
86
87 /*
88 * vidcmatch()
89 *
90 * VIDC20 is a write only device so we cannot probe it
91 * We must assume things are ok.
92 */
93 static int
94 vidcmatch(parent, cf, aux)
95 struct device *parent;
96 struct cfdata *cf;
97 void *aux;
98 {
99 /* struct mainbus_attach_args *mb = aux;*/
100
101 return(1);
102 }
103
104 /*
105 * vidcprint()
106 *
107 * print routine used during config of children
108 */
109
110 static int
111 vidcprint(aux, name)
112 void *aux;
113 const char *name;
114 {
115 struct mainbus_attach_args *mb = aux;
116
117 if (mb->mb_iobase != MAINBUSCF_BASE_DEFAULT)
118 printf(" base 0x%x", mb->mb_iobase);
119 if (mb->mb_iosize > 1)
120 printf("-0x%x", mb->mb_iobase + mb->mb_iosize - 1);
121 if (mb->mb_irq != -1)
122 printf(" irq %d", mb->mb_irq);
123 if (mb->mb_drq != -1)
124 printf(" drq 0x%08x", mb->mb_drq);
125
126 /* XXXX print flags */
127 return (QUIET);
128 }
129
130 /*
131 * vidcsearch()
132 *
133 * search routine used during the config of children
134 */
135
136 static int
137 vidcsearch(parent, cf, aux)
138 struct device *parent;
139 struct cfdata *cf;
140 void *aux;
141 {
142 struct vidc20_softc *sc = (struct vidc20_softc *)parent;
143 struct mainbus_attach_args mb;
144 int tryagain;
145
146 do {
147 if (cf->cf_loc[MAINBUSCF_BASE] == MAINBUSCF_BASE_DEFAULT) {
148 mb.mb_iobase = MAINBUSCF_BASE_DEFAULT;
149 mb.mb_iosize = 0;
150 mb.mb_drq = MAINBUSCF_DACK_DEFAULT;
151 mb.mb_irq = MAINBUSCF_IRQ_DEFAULT;
152 } else {
153 mb.mb_iobase = cf->cf_loc[MAINBUSCF_BASE] + IO_CONF_BASE;
154 mb.mb_iosize = 0;
155 mb.mb_drq = cf->cf_loc[MAINBUSCF_DACK];
156 mb.mb_irq = cf->cf_loc[MAINBUSCF_IRQ];
157 }
158 mb.mb_iot = sc->sc_iot;
159
160 tryagain = 0;
161 if ((*cf->cf_attach->ca_match)(parent, cf, &mb) > 0) {
162 config_attach(parent, cf, &mb, vidcprint);
163 /* tryagain = (cf->cf_fstate == FSTATE_STAR);*/
164 }
165 } while (tryagain);
166
167 return (0);
168 }
169
170 /*
171 * vidcattach()
172 *
173 * Configure all the child devices of the VIDC
174 */
175 static void
176 vidcattach(parent, self, aux)
177 struct device *parent;
178 struct device *self;
179 void *aux;
180 {
181 struct vidc20_softc *sc = (struct vidc20_softc *)self;
182 struct mainbus_attach_args *mb = aux;
183
184 sc->sc_iot = mb->mb_iot;
185
186 /*
187 * Since the VIDC is write-only, infer the type of VIDC from the
188 * type of IOMD.
189 */
190 switch (IOMD_ID) {
191 case ARM7500_IOC_ID:
192 printf(": ARM7500 video and sound macrocell\n");
193 vidc_fref = 32000000;
194 break;
195 case ARM7500FE_IOC_ID:
196 printf(": ARM7500FE video and sound macrocell\n");
197 vidc_fref = 32000000;
198 break;
199 default: /* XXX default? */
200 case RPC600_IOMD_ID:
201 printf(": VIDC20\n");
202 vidc_fref = 24000000;
203 break;
204 };
205
206 config_search(vidcsearch, self, NULL);
207 }
208
209 /* End of vidc20.c */
210