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