ite8181_vrip.c revision 1.4.4.2 1 1.4.4.2 nathanw /* $NetBSD: ite8181_vrip.c,v 1.4.4.2 2002/02/28 04:10:04 nathanw Exp $ */
2 1.4.4.2 nathanw
3 1.4.4.2 nathanw /*-
4 1.4.4.2 nathanw * Copyright (c) 2000 SATO Kazumi
5 1.4.4.2 nathanw * All rights reserved.
6 1.4.4.2 nathanw *
7 1.4.4.2 nathanw * Redistribution and use in source and binary forms, with or without
8 1.4.4.2 nathanw * modification, are permitted provided that the following conditions
9 1.4.4.2 nathanw * are met:
10 1.4.4.2 nathanw * 1. Redistributions of source code must retain the above copyright
11 1.4.4.2 nathanw * notice, this list of conditions and the following disclaimer.
12 1.4.4.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
13 1.4.4.2 nathanw * notice, this list of conditions and the following disclaimer in the
14 1.4.4.2 nathanw * documentation and/or other materials provided with the distribution.
15 1.4.4.2 nathanw * 3. The name of the author may not be used to endorse or promote products
16 1.4.4.2 nathanw * derived from this software without specific prior written permission.
17 1.4.4.2 nathanw *
18 1.4.4.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 1.4.4.2 nathanw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 1.4.4.2 nathanw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 1.4.4.2 nathanw * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 1.4.4.2 nathanw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 1.4.4.2 nathanw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 1.4.4.2 nathanw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 1.4.4.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 1.4.4.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 1.4.4.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 1.4.4.2 nathanw * SUCH DAMAGE.
29 1.4.4.2 nathanw *
30 1.4.4.2 nathanw */
31 1.4.4.2 nathanw
32 1.4.4.2 nathanw #include <sys/param.h>
33 1.4.4.2 nathanw #include <sys/systm.h>
34 1.4.4.2 nathanw #include <sys/device.h>
35 1.4.4.2 nathanw
36 1.4.4.2 nathanw #include <machine/bus.h>
37 1.4.4.2 nathanw
38 1.4.4.2 nathanw #include "opt_vr41xx.h"
39 1.4.4.2 nathanw #include <hpcmips/vr/vrcpudef.h>
40 1.4.4.2 nathanw #include <hpcmips/vr/vripif.h>
41 1.4.4.2 nathanw #include <hpcmips/dev/ite8181var.h>
42 1.4.4.2 nathanw #include "bivideo.h"
43 1.4.4.2 nathanw #if NBIVIDEO > 0
44 1.4.4.2 nathanw #include <dev/hpc/bivideovar.h>
45 1.4.4.2 nathanw #endif
46 1.4.4.2 nathanw
47 1.4.4.2 nathanw #include "locators.h"
48 1.4.4.2 nathanw
49 1.4.4.2 nathanw struct ite8181_vrip_softc {
50 1.4.4.2 nathanw struct ite8181_softc sc_ite8181;
51 1.4.4.2 nathanw };
52 1.4.4.2 nathanw
53 1.4.4.2 nathanw static int ite8181_vrip_probe(struct device *, struct cfdata *, void *);
54 1.4.4.2 nathanw static void ite8181_vrip_attach(struct device *, struct device *, void *);
55 1.4.4.2 nathanw
56 1.4.4.2 nathanw struct cfattach ite8181video_vrip_ca = {
57 1.4.4.2 nathanw sizeof(struct ite8181_vrip_softc), ite8181_vrip_probe, ite8181_vrip_attach
58 1.4.4.2 nathanw };
59 1.4.4.2 nathanw
60 1.4.4.2 nathanw static int
61 1.4.4.2 nathanw ite8181_vrip_probe(struct device *parent, struct cfdata *cf, void *aux)
62 1.4.4.2 nathanw {
63 1.4.4.2 nathanw struct vrip_attach_args *va = aux;
64 1.4.4.2 nathanw bus_space_handle_t ioh;
65 1.4.4.2 nathanw int res;
66 1.4.4.2 nathanw
67 1.4.4.2 nathanw if (va->va_addr == VRIPIFCF_ADDR_DEFAULT)
68 1.4.4.2 nathanw return (0);
69 1.4.4.2 nathanw
70 1.4.4.2 nathanw #if NBIVIDEO > 0
71 1.4.4.2 nathanw if (bivideo_dont_attach) /* already attach video driver */
72 1.4.4.2 nathanw return 0;
73 1.4.4.2 nathanw #endif /* NBIVIDEO > 0 */
74 1.4.4.2 nathanw
75 1.4.4.2 nathanw if (bus_space_map(va->va_iot, va->va_addr, va->va_size, 0, &ioh)) {
76 1.4.4.2 nathanw printf("ite8181_vrip_probe: can't map i/o space\n");
77 1.4.4.2 nathanw return 0;
78 1.4.4.2 nathanw }
79 1.4.4.2 nathanw res = ite8181_probe(va->va_iot, ioh);
80 1.4.4.2 nathanw bus_space_unmap(va->va_iot, ioh, va->va_size);
81 1.4.4.2 nathanw
82 1.4.4.2 nathanw return (res);
83 1.4.4.2 nathanw }
84 1.4.4.2 nathanw
85 1.4.4.2 nathanw
86 1.4.4.2 nathanw static void
87 1.4.4.2 nathanw ite8181_vrip_attach(struct device *parent, struct device *self, void *aux)
88 1.4.4.2 nathanw {
89 1.4.4.2 nathanw struct ite8181_vrip_softc *vsc = (void *)self;
90 1.4.4.2 nathanw struct ite8181_softc *sc = &vsc->sc_ite8181;
91 1.4.4.2 nathanw struct vrip_attach_args *va = aux;
92 1.4.4.2 nathanw
93 1.4.4.2 nathanw sc->sc_baseaddr = va->va_addr;
94 1.4.4.2 nathanw sc->sc_iot = va->va_iot;
95 1.4.4.2 nathanw if (bus_space_map(va->va_iot, va->va_addr, va->va_size, 0,
96 1.4.4.2 nathanw &sc->sc_ioh)) {
97 1.4.4.2 nathanw printf(": can't map bus space\n");
98 1.4.4.2 nathanw return;
99 1.4.4.2 nathanw }
100 1.4.4.2 nathanw
101 1.4.4.2 nathanw ite8181_attach(sc);
102 1.4.4.2 nathanw }
103