vidc20.c revision 1.14 1 /* $NetBSD: vidc20.c,v 1.14 2006/03/08 23:46:23 lukem 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 __KERNEL_RCSID(0, "$NetBSD: vidc20.c,v 1.14 2006/03/08 23:46:23 lukem Exp $");
46
47 #include <sys/types.h>
48 #include <sys/param.h>
49 #include <sys/systm.h>
50 #include <sys/device.h>
51
52 #include <machine/bus.h>
53 #include <arm/iomd/vidc.h>
54 #include <machine/io.h>
55 #include <arm/iomd/iomdreg.h>
56 #include <arm/iomd/iomdvar.h>
57 #include <arm/mainbus/mainbus.h>
58
59 #include "locators.h"
60
61 struct vidc20_softc {
62 struct device sc_dev;
63 bus_space_tag_t sc_iot;
64 };
65
66 static int vidcmatch(struct device *, struct cfdata *, void *);
67 static void vidcattach(struct device *, struct device *, void *);
68 static int vidcsearch(struct device *, struct cfdata *,
69 const int *, void *);
70
71 /*
72 * vidc_base gives the base of the VIDC chip in memory; this is for
73 * the rest isnt busspaceified yet. Initialised with VIDC_BASE for
74 * backwards compatibility.
75 */
76 int *vidc_base = (int *)VIDC_BASE;
77
78
79 /*
80 * vidc_fref is the reference frequency in MHz of the detected VIDC
81 * (dependent on IOMD/IOC)
82 * XXX default is RPC600 ?
83 */
84 int vidc_fref = 24000000;
85
86
87 CFATTACH_DECL(vidc, sizeof (struct vidc20_softc),
88 vidcmatch, vidcattach, NULL, NULL);
89
90 /*
91 * vidcmatch()
92 *
93 * VIDC20 is a write only device so we cannot probe it
94 * We must assume things are ok.
95 */
96 static int
97 vidcmatch(struct device *parent, struct cfdata *cf, void *aux)
98 {
99
100 return(1);
101 }
102
103 /*
104 * vidcsearch()
105 *
106 * search routine used during the config of children
107 */
108
109 static int
110 vidcsearch(struct device *parent, struct cfdata *cf,
111 const int *ldesc, void *aux)
112 {
113
114 if (config_match(parent, cf, NULL) > 0)
115 config_attach(parent, cf, NULL, NULL);
116
117 return (0);
118 }
119
120 /*
121 * vidcattach()
122 *
123 * Configure all the child devices of the VIDC
124 */
125 static void
126 vidcattach(struct device *parent, struct device *self, void *aux)
127 {
128 struct vidc20_softc *sc = (struct vidc20_softc *)self;
129 struct mainbus_attach_args *mb = aux;
130
131 sc->sc_iot = mb->mb_iot;
132
133 /*
134 * Since the VIDC is write-only, infer the type of VIDC from the
135 * type of IOMD.
136 */
137 switch (IOMD_ID) {
138 case ARM7500_IOC_ID:
139 printf(": ARM7500 video and sound macrocell\n");
140 vidc_fref = 32000000;
141 break;
142 case ARM7500FE_IOC_ID:
143 printf(": ARM7500FE video and sound macrocell\n");
144 vidc_fref = 32000000;
145 break;
146 default: /* XXX default? */
147 case RPC600_IOMD_ID:
148 printf(": VIDC20\n");
149 vidc_fref = 24000000;
150 break;
151 };
152
153 config_search_ia(vidcsearch, self, "vidc", NULL);
154 }
155
156 /* End of vidc20.c */
157