vga_jazzio.c revision 1.3.2.3 1 1.3.2.3 bouyer /* $NetBSD: vga_jazzio.c,v 1.3.2.3 2001/01/05 17:33:59 bouyer Exp $ */
2 1.3.2.2 bouyer /* NetBSD: vga_isa.c,v 1.3 1998/06/12 18:45:48 drochner Exp */
3 1.3.2.2 bouyer
4 1.3.2.2 bouyer /*
5 1.3.2.2 bouyer * Copyright (c) 1995, 1996 Carnegie-Mellon University.
6 1.3.2.2 bouyer * All rights reserved.
7 1.3.2.2 bouyer *
8 1.3.2.2 bouyer * Author: Chris G. Demetriou
9 1.3.2.2 bouyer *
10 1.3.2.2 bouyer * Permission to use, copy, modify and distribute this software and
11 1.3.2.2 bouyer * its documentation is hereby granted, provided that both the copyright
12 1.3.2.2 bouyer * notice and this permission notice appear in all copies of the
13 1.3.2.2 bouyer * software, derivative works or modified versions, and any portions
14 1.3.2.2 bouyer * thereof, and that both notices appear in supporting documentation.
15 1.3.2.2 bouyer *
16 1.3.2.2 bouyer * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 1.3.2.2 bouyer * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18 1.3.2.2 bouyer * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 1.3.2.2 bouyer *
20 1.3.2.2 bouyer * Carnegie Mellon requests users of this software to return to
21 1.3.2.2 bouyer *
22 1.3.2.2 bouyer * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
23 1.3.2.2 bouyer * School of Computer Science
24 1.3.2.2 bouyer * Carnegie Mellon University
25 1.3.2.2 bouyer * Pittsburgh PA 15213-3890
26 1.3.2.2 bouyer *
27 1.3.2.2 bouyer * any improvements or extensions that they make and grant Carnegie the
28 1.3.2.2 bouyer * rights to redistribute these changes.
29 1.3.2.2 bouyer */
30 1.3.2.2 bouyer
31 1.3.2.2 bouyer #include <sys/param.h>
32 1.3.2.2 bouyer #include <sys/systm.h>
33 1.3.2.2 bouyer #include <sys/kernel.h>
34 1.3.2.2 bouyer #include <sys/device.h>
35 1.3.2.2 bouyer #include <sys/malloc.h>
36 1.3.2.2 bouyer
37 1.3.2.2 bouyer #include <machine/autoconf.h>
38 1.3.2.2 bouyer #include <machine/bus.h>
39 1.3.2.2 bouyer
40 1.3.2.2 bouyer #include <dev/ic/mc6845reg.h>
41 1.3.2.2 bouyer #include <dev/ic/pcdisplayvar.h>
42 1.3.2.2 bouyer #include <dev/ic/vgareg.h>
43 1.3.2.2 bouyer #include <dev/ic/vgavar.h>
44 1.3.2.3 bouyer #include <arc/jazz/jazziovar.h>
45 1.3.2.3 bouyer #include <arc/jazz/pica.h>
46 1.3.2.2 bouyer #include <arc/jazz/vga_jazziovar.h>
47 1.3.2.2 bouyer
48 1.3.2.2 bouyer #include <dev/wscons/wsconsio.h>
49 1.3.2.2 bouyer #include <dev/wscons/wsdisplayvar.h>
50 1.3.2.2 bouyer
51 1.3.2.2 bouyer #define WSDISPLAY_TYPE_JAZZVGA WSDISPLAY_TYPE_PCIVGA /* XXX not really */
52 1.3.2.2 bouyer
53 1.3.2.2 bouyer struct vga_jazzio_softc {
54 1.3.2.2 bouyer struct device sc_dev;
55 1.3.2.2 bouyer #if 0
56 1.3.2.2 bouyer struct vga_config *sc_vc; /* VGA configuration */
57 1.3.2.2 bouyer #endif
58 1.3.2.2 bouyer };
59 1.3.2.2 bouyer
60 1.3.2.2 bouyer void vga_jazzio_init_tag __P((bus_space_tag_t *, bus_space_tag_t *));
61 1.3.2.2 bouyer paddr_t vga_jazzio_mmap __P((void *, off_t, int));
62 1.3.2.2 bouyer int vga_jazzio_match __P((struct device *, struct cfdata *, void *));
63 1.3.2.2 bouyer void vga_jazzio_attach __P((struct device *, struct device *, void *));
64 1.3.2.2 bouyer
65 1.3.2.2 bouyer struct cfattach vga_jazzio_ca = {
66 1.3.2.2 bouyer sizeof(struct vga_jazzio_softc), vga_jazzio_match, vga_jazzio_attach,
67 1.3.2.2 bouyer };
68 1.3.2.2 bouyer
69 1.3.2.2 bouyer void
70 1.3.2.2 bouyer vga_jazzio_init_tag(iotp, memtp)
71 1.3.2.2 bouyer bus_space_tag_t *iotp, *memtp;
72 1.3.2.2 bouyer {
73 1.3.2.2 bouyer static int initialized = 0;
74 1.3.2.2 bouyer static struct arc_bus_space vga_io, vga_mem;
75 1.3.2.2 bouyer
76 1.3.2.2 bouyer if (!initialized) {
77 1.3.2.2 bouyer initialized = 1;
78 1.3.2.2 bouyer arc_bus_space_init(&vga_io, "vga_jazzio_io",
79 1.3.2.2 bouyer PICA_P_LOCAL_VIDEO_CTRL, PICA_V_LOCAL_VIDEO_CTRL,
80 1.3.2.2 bouyer 0, PICA_S_LOCAL_VIDEO_CTRL);
81 1.3.2.2 bouyer arc_bus_space_init(&vga_mem, "vga_jazzio_mem",
82 1.3.2.2 bouyer PICA_P_LOCAL_VIDEO, PICA_V_LOCAL_VIDEO,
83 1.3.2.2 bouyer 0, PICA_S_LOCAL_VIDEO);
84 1.3.2.2 bouyer }
85 1.3.2.2 bouyer *iotp = &vga_io;
86 1.3.2.2 bouyer *memtp = &vga_mem;
87 1.3.2.2 bouyer }
88 1.3.2.2 bouyer
89 1.3.2.2 bouyer paddr_t
90 1.3.2.2 bouyer vga_jazzio_mmap(v, offset, prot)
91 1.3.2.2 bouyer void *v;
92 1.3.2.2 bouyer off_t offset;
93 1.3.2.2 bouyer int prot;
94 1.3.2.2 bouyer {
95 1.3.2.2 bouyer if (offset >= 0xa0000 && offset < 0xc0000)
96 1.3.2.2 bouyer return mips_btop(PICA_P_LOCAL_VIDEO + offset);
97 1.3.2.2 bouyer if (offset >= 0x0000 && offset < 0x10000)
98 1.3.2.2 bouyer return mips_btop(PICA_P_LOCAL_VIDEO_CTRL + offset);
99 1.3.2.2 bouyer if (offset >= 0x40000000 && offset < 0x40800000)
100 1.3.2.2 bouyer return mips_btop(PICA_P_LOCAL_VIDEO + offset - 0x40000000);
101 1.3.2.2 bouyer return -1;
102 1.3.2.2 bouyer }
103 1.3.2.2 bouyer
104 1.3.2.2 bouyer int
105 1.3.2.2 bouyer vga_jazzio_match(parent, match, aux)
106 1.3.2.2 bouyer struct device *parent;
107 1.3.2.2 bouyer struct cfdata *match;
108 1.3.2.2 bouyer void *aux;
109 1.3.2.2 bouyer {
110 1.3.2.3 bouyer struct jazzio_attach_args *ja = aux;
111 1.3.2.2 bouyer bus_space_tag_t iot, memt;
112 1.3.2.2 bouyer
113 1.3.2.3 bouyer if(strcmp(ja->ja_name, "vga") != 0)
114 1.3.2.2 bouyer return(0);
115 1.3.2.2 bouyer
116 1.3.2.2 bouyer vga_jazzio_init_tag(&iot, &memt);
117 1.3.2.2 bouyer if (!vga_is_console(iot, WSDISPLAY_TYPE_JAZZVGA) &&
118 1.3.2.2 bouyer !vga_common_probe(iot, memt))
119 1.3.2.2 bouyer return (0);
120 1.3.2.2 bouyer
121 1.3.2.2 bouyer return (1);
122 1.3.2.2 bouyer }
123 1.3.2.2 bouyer
124 1.3.2.2 bouyer void
125 1.3.2.2 bouyer vga_jazzio_attach(parent, self, aux)
126 1.3.2.2 bouyer struct device *parent, *self;
127 1.3.2.2 bouyer void *aux;
128 1.3.2.2 bouyer {
129 1.3.2.2 bouyer #if 0
130 1.3.2.2 bouyer struct vga_jazzio_softc *sc = (struct vga_jazzio_softc *)self;
131 1.3.2.2 bouyer #endif
132 1.3.2.2 bouyer bus_space_tag_t iot, memt;
133 1.3.2.2 bouyer
134 1.3.2.2 bouyer printf("\n");
135 1.3.2.2 bouyer
136 1.3.2.2 bouyer vga_jazzio_init_tag(&iot, &memt);
137 1.3.2.2 bouyer vga_common_attach(self, iot, memt, WSDISPLAY_TYPE_JAZZVGA,
138 1.3.2.2 bouyer vga_jazzio_mmap);
139 1.3.2.2 bouyer }
140 1.3.2.2 bouyer
141 1.3.2.2 bouyer int
142 1.3.2.2 bouyer vga_jazzio_cnattach()
143 1.3.2.2 bouyer {
144 1.3.2.2 bouyer bus_space_tag_t iot, memt;
145 1.3.2.2 bouyer
146 1.3.2.2 bouyer vga_jazzio_init_tag(&iot, &memt);
147 1.3.2.2 bouyer return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_JAZZVGA, 1));
148 1.3.2.2 bouyer }
149