vga_jazzio.c revision 1.9.6.1 1 /* $NetBSD: vga_jazzio.c,v 1.9.6.1 2004/08/03 10:32:22 skrll 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/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: vga_jazzio.c,v 1.9.6.1 2004/08/03 10:32:22 skrll Exp $");
33
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
37 #include <sys/device.h>
38 #include <sys/malloc.h>
39 #include <uvm/uvm_extern.h>
40
41 #include <machine/autoconf.h>
42 #include <machine/bus.h>
43
44 #include <mips/pte.h>
45
46 #include <dev/ic/mc6845reg.h>
47 #include <dev/ic/pcdisplayvar.h>
48 #include <dev/ic/vgareg.h>
49 #include <dev/ic/vgavar.h>
50
51 #include <arc/arc/wired_map.h>
52 #include <arc/jazz/jazziovar.h>
53 #include <arc/jazz/pica.h>
54 #include <arc/jazz/vga_jazziovar.h>
55
56 #include <dev/wscons/wsconsio.h>
57 #include <dev/wscons/wsdisplayvar.h>
58
59 #define WSDISPLAY_TYPE_JAZZVGA WSDISPLAY_TYPE_PCIVGA /* XXX not really */
60
61 int vga_jazzio_init_tag __P((char*, bus_space_tag_t *, bus_space_tag_t *));
62 paddr_t vga_jazzio_mmap __P((void *, off_t, int));
63 int vga_jazzio_match __P((struct device *, struct cfdata *, void *));
64 void vga_jazzio_attach __P((struct device *, struct device *, void *));
65
66 CFATTACH_DECL(vga_jazzio, sizeof(struct vga_softc),
67 vga_jazzio_match, vga_jazzio_attach, NULL, NULL);
68
69 const struct vga_funcs vga_jazzio_funcs = {
70 NULL,
71 vga_jazzio_mmap,
72 };
73
74 int
75 vga_jazzio_init_tag(name, iotp, memtp)
76 char *name;
77 bus_space_tag_t *iotp, *memtp;
78 {
79 static int initialized = 0;
80 static struct arc_bus_space vga_io, vga_mem;
81
82 if (strcmp(name, "ALI_S3") != 0)
83 return(ENXIO);
84
85 if (!initialized) {
86 initialized = 1;
87
88 arc_bus_space_init(&vga_io, "vga_jazzio_io",
89 PICA_P_LOCAL_VIDEO_CTRL, PICA_V_LOCAL_VIDEO_CTRL,
90 0, PICA_S_LOCAL_VIDEO_CTRL);
91 arc_bus_space_init(&vga_mem, "vga_jazzio_mem",
92 PICA_P_LOCAL_VIDEO, PICA_V_LOCAL_VIDEO,
93 0, PICA_S_LOCAL_VIDEO);
94
95 arc_enter_wired(PICA_V_LOCAL_VIDEO_CTRL,
96 PICA_P_LOCAL_VIDEO_CTRL,
97 PICA_P_LOCAL_VIDEO_CTRL + PICA_S_LOCAL_VIDEO_CTRL/2,
98 MIPS3_PG_SIZE_1M);
99 arc_enter_wired(PICA_V_LOCAL_VIDEO,
100 PICA_P_LOCAL_VIDEO,
101 PICA_P_LOCAL_VIDEO + PICA_S_LOCAL_VIDEO/2,
102 MIPS3_PG_SIZE_4M);
103 #if 0
104 arc_enter_wired(PICA_V_EXTND_VIDEO_CTRL,
105 PICA_P_EXTND_VIDEO_CTRL,
106 PICA_P_EXTND_VIDEO_CTRL + PICA_S_EXTND_VIDEO_CTRL/2,
107 MIPS3_PG_SIZE_1M);
108 #endif
109 }
110 *iotp = &vga_io;
111 *memtp = &vga_mem;
112 return (0);
113 }
114
115 paddr_t
116 vga_jazzio_mmap(v, offset, prot)
117 void *v;
118 off_t offset;
119 int prot;
120 {
121 if (offset >= 0xa0000 && offset < 0xc0000)
122 return mips_btop(PICA_P_LOCAL_VIDEO + offset);
123 if (offset >= 0x0000 && offset < 0x10000)
124 return mips_btop(PICA_P_LOCAL_VIDEO_CTRL + offset);
125 if (offset >= 0x40000000 && offset < 0x40800000)
126 return mips_btop(PICA_P_LOCAL_VIDEO + offset - 0x40000000);
127 return -1;
128 }
129
130 int
131 vga_jazzio_match(parent, match, aux)
132 struct device *parent;
133 struct cfdata *match;
134 void *aux;
135 {
136 struct jazzio_attach_args *ja = aux;
137 bus_space_tag_t iot, memt;
138
139 if (vga_jazzio_init_tag(ja->ja_name, &iot, &memt))
140 return (0);
141
142 if (!vga_is_console(iot, WSDISPLAY_TYPE_JAZZVGA) &&
143 !vga_common_probe(iot, memt))
144 return (0);
145
146 return (1);
147 }
148
149 void
150 vga_jazzio_attach(parent, self, aux)
151 struct device *parent, *self;
152 void *aux;
153 {
154 struct vga_softc *sc = (void *) self;
155 struct jazzio_attach_args *ja = aux;
156 bus_space_tag_t iot, memt;
157
158 printf("\n");
159
160 vga_jazzio_init_tag(ja->ja_name, &iot, &memt);
161 vga_common_attach(sc, iot, memt, WSDISPLAY_TYPE_JAZZVGA, 0,
162 &vga_jazzio_funcs);
163 }
164
165 int
166 vga_jazzio_cnattach(name)
167 char *name;
168 {
169 bus_space_tag_t iot, memt;
170
171 if (vga_jazzio_init_tag(name, &iot, &memt))
172 return (ENXIO);
173 return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_JAZZVGA, 1));
174 }
175