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