vidc20.c revision 1.4 1 1.4 bjh21 /* $NetBSD: vidc20.c,v 1.4 2002/06/16 13:25:02 bjh21 Exp $ */
2 1.1 reinoud
3 1.1 reinoud /*
4 1.1 reinoud * Copyright (c) 1997 Mark Brinicombe
5 1.1 reinoud * Copyright (c) 1997 Causality Limited
6 1.1 reinoud * All rights reserved.
7 1.1 reinoud *
8 1.1 reinoud * Redistribution and use in source and binary forms, with or without
9 1.1 reinoud * modification, are permitted provided that the following conditions
10 1.1 reinoud * are met:
11 1.1 reinoud * 1. Redistributions of source code must retain the above copyright
12 1.1 reinoud * notice, this list of conditions and the following disclaimer.
13 1.1 reinoud * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 reinoud * notice, this list of conditions and the following disclaimer in the
15 1.1 reinoud * documentation and/or other materials provided with the distribution.
16 1.1 reinoud * 3. All advertising materials mentioning features or use of this software
17 1.1 reinoud * must display the following acknowledgement:
18 1.1 reinoud * This product includes software developed by Mark Brinicombe
19 1.1 reinoud * 4. The name of the company nor the name of the author may be used to
20 1.1 reinoud * endorse or promote products derived from this software without specific
21 1.1 reinoud * prior written permission.
22 1.1 reinoud *
23 1.1 reinoud * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
24 1.1 reinoud * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 1.1 reinoud * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 reinoud * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
27 1.1 reinoud * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 1.1 reinoud * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 1.1 reinoud * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 1.1 reinoud * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 1.1 reinoud * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 1.1 reinoud * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 1.1 reinoud * THE POSSIBILITY OF SUCH DAMAGE.
34 1.1 reinoud *
35 1.1 reinoud * RiscBSD kernel project
36 1.1 reinoud *
37 1.1 reinoud * vidc20.c
38 1.1 reinoud *
39 1.1 reinoud * VIDC20 driver
40 1.1 reinoud *
41 1.1 reinoud * Created : 22/02/97
42 1.1 reinoud */
43 1.1 reinoud
44 1.1 reinoud #include <sys/cdefs.h>
45 1.1 reinoud #include <sys/types.h>
46 1.1 reinoud #include <sys/param.h>
47 1.1 reinoud #include <sys/systm.h>
48 1.1 reinoud #include <sys/device.h>
49 1.1 reinoud
50 1.1 reinoud #include <machine/bus.h>
51 1.1 reinoud #include <arm/iomd/vidc.h>
52 1.1 reinoud #include <machine/io.h>
53 1.1 reinoud #include <arm/iomd/iomdreg.h>
54 1.1 reinoud #include <arm/iomd/iomdvar.h>
55 1.1 reinoud #include <arm/mainbus/mainbus.h>
56 1.1 reinoud
57 1.1 reinoud #include "locators.h"
58 1.1 reinoud
59 1.1 reinoud struct vidc20_softc {
60 1.1 reinoud struct device sc_dev;
61 1.1 reinoud bus_space_tag_t sc_iot;
62 1.1 reinoud };
63 1.1 reinoud
64 1.4 bjh21 static int vidcmatch(struct device *, struct cfdata *, void *);
65 1.4 bjh21 static void vidcattach(struct device *, struct device *, void *);
66 1.4 bjh21 static int vidcsearch(struct device *, struct cfdata *, void *);
67 1.1 reinoud
68 1.1 reinoud /*
69 1.4 bjh21 * vidc_base gives the base of the VIDC chip in memory; this is for
70 1.4 bjh21 * the rest isnt busspaceified yet. Initialised with VIDC_BASE for
71 1.4 bjh21 * backwards compatibility.
72 1.1 reinoud */
73 1.4 bjh21 int *vidc_base = (int *)VIDC_BASE;
74 1.1 reinoud
75 1.1 reinoud
76 1.1 reinoud /*
77 1.4 bjh21 * vidc_fref is the reference frequency in Mhz of the detected VIDC
78 1.4 bjh21 * (dependent on IOMD/IOC)
79 1.1 reinoud * XXX default is RPC600 ?
80 1.1 reinoud */
81 1.1 reinoud int vidc_fref = 24000000;
82 1.1 reinoud
83 1.1 reinoud
84 1.1 reinoud struct cfattach vidc_ca = {
85 1.1 reinoud sizeof (struct vidc20_softc), vidcmatch, vidcattach
86 1.1 reinoud };
87 1.1 reinoud
88 1.1 reinoud /*
89 1.1 reinoud * vidcmatch()
90 1.1 reinoud *
91 1.1 reinoud * VIDC20 is a write only device so we cannot probe it
92 1.1 reinoud * We must assume things are ok.
93 1.1 reinoud */
94 1.1 reinoud static int
95 1.4 bjh21 vidcmatch(struct device *parent, struct cfdata *cf, void *aux)
96 1.1 reinoud {
97 1.1 reinoud
98 1.1 reinoud return(1);
99 1.1 reinoud }
100 1.1 reinoud
101 1.1 reinoud /*
102 1.1 reinoud * vidcsearch()
103 1.1 reinoud *
104 1.1 reinoud * search routine used during the config of children
105 1.1 reinoud */
106 1.1 reinoud
107 1.1 reinoud static int
108 1.4 bjh21 vidcsearch(struct device *parent, struct cfdata *cf, void *aux)
109 1.1 reinoud {
110 1.3 bjh21
111 1.3 bjh21 if ((*cf->cf_attach->ca_match)(parent, cf, NULL) > 0)
112 1.3 bjh21 config_attach(parent, cf, NULL, NULL);
113 1.1 reinoud
114 1.1 reinoud return (0);
115 1.1 reinoud }
116 1.1 reinoud
117 1.1 reinoud /*
118 1.1 reinoud * vidcattach()
119 1.1 reinoud *
120 1.1 reinoud * Configure all the child devices of the VIDC
121 1.1 reinoud */
122 1.1 reinoud static void
123 1.4 bjh21 vidcattach(struct device *parent, struct device *self, void *aux)
124 1.1 reinoud {
125 1.1 reinoud struct vidc20_softc *sc = (struct vidc20_softc *)self;
126 1.1 reinoud struct mainbus_attach_args *mb = aux;
127 1.1 reinoud
128 1.1 reinoud sc->sc_iot = mb->mb_iot;
129 1.1 reinoud
130 1.2 bjh21 /*
131 1.2 bjh21 * Since the VIDC is write-only, infer the type of VIDC from the
132 1.2 bjh21 * type of IOMD.
133 1.2 bjh21 */
134 1.1 reinoud switch (IOMD_ID) {
135 1.1 reinoud case ARM7500_IOC_ID:
136 1.2 bjh21 printf(": ARM7500 video and sound macrocell\n");
137 1.2 bjh21 vidc_fref = 32000000;
138 1.2 bjh21 break;
139 1.1 reinoud case ARM7500FE_IOC_ID:
140 1.2 bjh21 printf(": ARM7500FE video and sound macrocell\n");
141 1.1 reinoud vidc_fref = 32000000;
142 1.1 reinoud break;
143 1.1 reinoud default: /* XXX default? */
144 1.1 reinoud case RPC600_IOMD_ID:
145 1.2 bjh21 printf(": VIDC20\n");
146 1.1 reinoud vidc_fref = 24000000;
147 1.1 reinoud break;
148 1.1 reinoud };
149 1.1 reinoud
150 1.1 reinoud config_search(vidcsearch, self, NULL);
151 1.1 reinoud }
152 1.1 reinoud
153 1.1 reinoud /* End of vidc20.c */
154