vga_ofbus.c revision 1.1.2.3 1 1.1.2.3 nathanw /* $NetBSD: vga_ofbus.c,v 1.1.2.3 2002/10/18 02:39:48 nathanw Exp $ */
2 1.1.2.2 nathanw
3 1.1.2.2 nathanw /*
4 1.1.2.2 nathanw * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 1.1.2.2 nathanw * All rights reserved.
6 1.1.2.2 nathanw *
7 1.1.2.2 nathanw * Author: Chris G. Demetriou
8 1.1.2.2 nathanw *
9 1.1.2.2 nathanw * Permission to use, copy, modify and distribute this software and
10 1.1.2.2 nathanw * its documentation is hereby granted, provided that both the copyright
11 1.1.2.2 nathanw * notice and this permission notice appear in all copies of the
12 1.1.2.2 nathanw * software, derivative works or modified versions, and any portions
13 1.1.2.2 nathanw * thereof, and that both notices appear in supporting documentation.
14 1.1.2.2 nathanw *
15 1.1.2.2 nathanw * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 1.1.2.2 nathanw * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 1.1.2.2 nathanw * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 1.1.2.2 nathanw *
19 1.1.2.2 nathanw * Carnegie Mellon requests users of this software to return to
20 1.1.2.2 nathanw *
21 1.1.2.2 nathanw * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 1.1.2.2 nathanw * School of Computer Science
23 1.1.2.2 nathanw * Carnegie Mellon University
24 1.1.2.2 nathanw * Pittsburgh PA 15213-3890
25 1.1.2.2 nathanw *
26 1.1.2.2 nathanw * any improvements or extensions that they make and grant Carnegie the
27 1.1.2.2 nathanw * rights to redistribute these changes.
28 1.1.2.2 nathanw */
29 1.1.2.2 nathanw
30 1.1.2.2 nathanw #include <sys/param.h>
31 1.1.2.2 nathanw #include <sys/systm.h>
32 1.1.2.2 nathanw #include <sys/kernel.h>
33 1.1.2.2 nathanw #include <sys/device.h>
34 1.1.2.2 nathanw #include <sys/malloc.h>
35 1.1.2.2 nathanw
36 1.1.2.2 nathanw #include <dev/isa/isavar.h>
37 1.1.2.2 nathanw
38 1.1.2.2 nathanw #include <dev/ic/mc6845reg.h>
39 1.1.2.2 nathanw #include <dev/ic/pcdisplayvar.h>
40 1.1.2.2 nathanw #include <dev/ic/vgareg.h>
41 1.1.2.2 nathanw #include <dev/ic/vgavar.h>
42 1.1.2.2 nathanw
43 1.1.2.2 nathanw #include <dev/wscons/wsconsio.h>
44 1.1.2.2 nathanw #include <dev/wscons/wsdisplayvar.h>
45 1.1.2.2 nathanw
46 1.1.2.2 nathanw #include <dev/ofw/openfirm.h>
47 1.1.2.2 nathanw #if 0
48 1.1.2.2 nathanw #include <dnard/ofw/vga_ofisavar.h>
49 1.1.2.2 nathanw #endif
50 1.1.2.2 nathanw
51 1.1.2.2 nathanw struct vga_ofbus_softc {
52 1.1.2.2 nathanw struct vga_softc sc_vga;
53 1.1.2.2 nathanw
54 1.1.2.2 nathanw int sc_phandle;
55 1.1.2.2 nathanw };
56 1.1.2.2 nathanw
57 1.1.2.2 nathanw int vga_ofbus_match (struct device *, struct cfdata *, void *);
58 1.1.2.2 nathanw void vga_ofbus_attach (struct device *, struct device *, void *);
59 1.1.2.2 nathanw
60 1.1.2.3 nathanw CFATTACH_DECL(vga_ofbus, sizeof(struct vga_ofbus_softc),
61 1.1.2.3 nathanw vga_ofbus_match, vga_ofbus_attach, NULL, NULL);
62 1.1.2.2 nathanw
63 1.1.2.2 nathanw static const char *compat_strings[] = { "pnpPNP,900", 0 };
64 1.1.2.2 nathanw
65 1.1.2.2 nathanw int
66 1.1.2.2 nathanw vga_ofbus_match(struct device *parent, struct cfdata *match, void *aux)
67 1.1.2.2 nathanw {
68 1.1.2.2 nathanw struct ofbus_attach_args *oba = aux;
69 1.1.2.2 nathanw
70 1.1.2.2 nathanw if (of_compatible(oba->oba_phandle, compat_strings) == -1)
71 1.1.2.2 nathanw return (0);
72 1.1.2.2 nathanw
73 1.1.2.2 nathanw if (!vga_is_console(&isa_io_bs_tag, WSDISPLAY_TYPE_ISAVGA) &&
74 1.1.2.2 nathanw !vga_common_probe(&isa_io_bs_tag, &isa_mem_bs_tag))
75 1.1.2.2 nathanw return (0);
76 1.1.2.2 nathanw
77 1.1.2.2 nathanw return (2); /* more than generic pcdisplay */
78 1.1.2.2 nathanw }
79 1.1.2.2 nathanw
80 1.1.2.2 nathanw void
81 1.1.2.2 nathanw vga_ofbus_attach(struct device *parent, struct device *self, void *aux)
82 1.1.2.2 nathanw {
83 1.1.2.2 nathanw struct vga_ofbus_softc *osc = (void *) self;
84 1.1.2.2 nathanw struct vga_softc *sc = &osc->sc_vga;
85 1.1.2.2 nathanw struct ofbus_attach_args *oba = aux;
86 1.1.2.2 nathanw
87 1.1.2.2 nathanw printf("\n");
88 1.1.2.2 nathanw osc->sc_phandle = oba->oba_phandle;
89 1.1.2.2 nathanw
90 1.1.2.2 nathanw vga_common_attach(sc, &isa_io_bs_tag, &isa_mem_bs_tag,
91 1.1.2.2 nathanw WSDISPLAY_TYPE_ISAVGA, NULL);
92 1.1.2.2 nathanw }
93 1.1.2.2 nathanw
94 1.1.2.2 nathanw int
95 1.1.2.2 nathanw vga_ofbus_cnattach(int phandle, bus_space_tag_t iot, bus_space_tag_t memt)
96 1.1.2.2 nathanw {
97 1.1.2.2 nathanw if (OF_call_method("text-mode3", phandle, 0, 0) != 0) {
98 1.1.2.2 nathanw printf("vga_ofbus_match: text-mode3 method invocation on VGA "
99 1.1.2.2 nathanw "screen device failed\n");
100 1.1.2.2 nathanw }
101 1.1.2.2 nathanw
102 1.1.2.2 nathanw return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_ISAVGA, 1));
103 1.1.2.2 nathanw }
104