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