vrkiu.c revision 1.1.1.1.2.2 1 1.1.1.1.2.2 bouyer /* $NetBSD: vrkiu.c,v 1.1.1.1.2.2 2001/03/12 13:28:49 bouyer Exp $ */
2 1.1 takemura
3 1.1 takemura /*-
4 1.1.1.1.2.1 bouyer * Copyright (c) 1999 SASAKI Takesi All rights reserved.
5 1.1.1.1.2.1 bouyer * Copyright (c) 1999,2000 TAKEMRUA, Shin All rights reserved.
6 1.1 takemura * Copyright (c) 1999 PocketBSD Project. All rights reserved.
7 1.1 takemura *
8 1.1 takemura * Redistribution and use in source and binary forms, with or without
9 1.1 takemura * modification, are permitted provided that the following conditions
10 1.1 takemura * are met:
11 1.1 takemura * 1. Redistributions of source code must retain the above copyright
12 1.1 takemura * notice, this list of conditions and the following disclaimer.
13 1.1 takemura * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 takemura * notice, this list of conditions and the following disclaimer in the
15 1.1 takemura * documentation and/or other materials provided with the distribution.
16 1.1 takemura * 3. All advertising materials mentioning features or use of this software
17 1.1 takemura * must display the following acknowledgement:
18 1.1 takemura * This product includes software developed by the PocketBSD project
19 1.1 takemura * and its contributors.
20 1.1 takemura * 4. Neither the name of the project nor the names of its contributors
21 1.1 takemura * may be used to endorse or promote products derived from this software
22 1.1 takemura * without specific prior written permission.
23 1.1 takemura *
24 1.1 takemura * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 1.1 takemura * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 1.1 takemura * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 1.1 takemura * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 1.1 takemura * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 1.1 takemura * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 1.1 takemura * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.1 takemura * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.1 takemura * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.1 takemura * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.1 takemura * SUCH DAMAGE.
35 1.1 takemura *
36 1.1 takemura */
37 1.1 takemura
38 1.1 takemura #include <sys/param.h>
39 1.1 takemura #include <sys/tty.h>
40 1.1 takemura #include <sys/systm.h>
41 1.1 takemura #include <sys/device.h>
42 1.1 takemura #include <sys/conf.h>
43 1.1 takemura #include <sys/kernel.h>
44 1.1 takemura #include <sys/proc.h>
45 1.1 takemura
46 1.1 takemura #include <machine/intr.h>
47 1.1 takemura #include <machine/cpu.h>
48 1.1 takemura #include <machine/bus.h>
49 1.1 takemura #include <machine/platid.h>
50 1.1.1.1.2.1 bouyer #include <machine/platid_mask.h>
51 1.1 takemura
52 1.1 takemura #include <hpcmips/vr/vr.h>
53 1.1 takemura #include <hpcmips/vr/vripvar.h>
54 1.1 takemura #include <hpcmips/vr/vrkiuvar.h>
55 1.1 takemura #include <hpcmips/vr/vrkiureg.h>
56 1.1 takemura #include <hpcmips/vr/icureg.h>
57 1.1.1.1.2.2 bouyer #include <dev/hpc/hpckbdvar.h>
58 1.1.1.1.2.1 bouyer
59 1.1.1.1.2.1 bouyer #include "opt_wsdisplay_compat.h"
60 1.1.1.1.2.1 bouyer #include "opt_pckbd_layout.h"
61 1.1.1.1.2.1 bouyer #include <dev/wscons/wsconsio.h>
62 1.1.1.1.2.1 bouyer #include <dev/wscons/wskbdvar.h>
63 1.1.1.1.2.1 bouyer #include <dev/wscons/wsksymdef.h>
64 1.1.1.1.2.1 bouyer #include <dev/wscons/wsksymvar.h>
65 1.1.1.1.2.1 bouyer #include <dev/pckbc/wskbdmap_mfii.h>
66 1.1.1.1.2.1 bouyer #ifdef WSDISPLAY_COMPAT_RAWKBD
67 1.1.1.1.2.2 bouyer #include <dev/hpc/pckbd_encode.h>
68 1.1.1.1.2.1 bouyer #endif
69 1.1 takemura
70 1.1.1.1.2.1 bouyer #define VRKIUDEBUG
71 1.1 takemura #ifdef VRKIUDEBUG
72 1.1 takemura int vrkiu_debug = 0;
73 1.1 takemura #define DPRINTF(arg) if (vrkiu_debug) printf arg;
74 1.1 takemura #else
75 1.1 takemura #define DPRINTF(arg)
76 1.1 takemura #endif
77 1.1 takemura
78 1.1.1.1.2.1 bouyer /*
79 1.1.1.1.2.1 bouyer * structure and data types
80 1.1.1.1.2.1 bouyer */
81 1.1.1.1.2.1 bouyer struct vrkiu_chip {
82 1.1.1.1.2.1 bouyer bus_space_tag_t kc_iot;
83 1.1.1.1.2.1 bouyer bus_space_handle_t kc_ioh;
84 1.1.1.1.2.1 bouyer unsigned short kc_scandata[KIU_NSCANLINE/2];
85 1.1.1.1.2.1 bouyer int kc_enabled;
86 1.1.1.1.2.1 bouyer struct vrkiu_softc* kc_sc; /* back link */
87 1.1.1.1.2.1 bouyer struct hpckbd_ic_if kc_if;
88 1.1.1.1.2.1 bouyer struct hpckbd_if *kc_hpckbd;
89 1.1.1.1.2.1 bouyer };
90 1.1.1.1.2.1 bouyer
91 1.1.1.1.2.1 bouyer struct vrkiu_softc {
92 1.1.1.1.2.1 bouyer struct device sc_dev;
93 1.1.1.1.2.1 bouyer struct vrkiu_chip *sc_chip;
94 1.1.1.1.2.1 bouyer struct vrkiu_chip sc_chip_body;
95 1.1.1.1.2.1 bouyer void *sc_handler;
96 1.1.1.1.2.1 bouyer };
97 1.1.1.1.2.1 bouyer
98 1.1.1.1.2.1 bouyer /*
99 1.1.1.1.2.1 bouyer * function prototypes
100 1.1.1.1.2.1 bouyer */
101 1.1 takemura static int vrkiumatch __P((struct device *, struct cfdata *, void *));
102 1.1 takemura static void vrkiuattach __P((struct device *, struct device *, void *));
103 1.1 takemura
104 1.1 takemura int vrkiu_intr __P((void *));
105 1.1 takemura
106 1.1.1.1.2.1 bouyer static int vrkiu_init(struct vrkiu_chip*, bus_space_tag_t, bus_space_handle_t);
107 1.1.1.1.2.1 bouyer static void vrkiu_write __P((struct vrkiu_chip *, int, unsigned short));
108 1.1.1.1.2.1 bouyer static unsigned short vrkiu_read __P((struct vrkiu_chip *, int));
109 1.1.1.1.2.1 bouyer static int vrkiu_is_console(bus_space_tag_t, bus_space_handle_t);
110 1.1.1.1.2.1 bouyer static void vrkiu_scan __P((struct vrkiu_chip *));
111 1.1.1.1.2.1 bouyer static int countbits(int);
112 1.1.1.1.2.1 bouyer static void eliminate_phantom_keys(struct vrkiu_chip*, unsigned short *);
113 1.1.1.1.2.1 bouyer static int vrkiu_poll __P((void*));
114 1.1.1.1.2.1 bouyer static int vrkiu_input_establish __P((void*, struct hpckbd_if*));
115 1.1 takemura
116 1.1.1.1.2.1 bouyer /*
117 1.1.1.1.2.1 bouyer * global/static data
118 1.1.1.1.2.1 bouyer */
119 1.1 takemura struct cfattach vrkiu_ca = {
120 1.1 takemura sizeof(struct vrkiu_softc), vrkiumatch, vrkiuattach
121 1.1 takemura };
122 1.1 takemura
123 1.1.1.1.2.1 bouyer struct vrkiu_chip *vrkiu_consdata = NULL;
124 1.1 takemura
125 1.1.1.1.2.1 bouyer /*
126 1.1.1.1.2.1 bouyer * utilities
127 1.1.1.1.2.1 bouyer */
128 1.1.1.1.2.1 bouyer static inline void
129 1.1.1.1.2.1 bouyer vrkiu_write(chip, port, val)
130 1.1.1.1.2.1 bouyer struct vrkiu_chip *chip;
131 1.1.1.1.2.1 bouyer int port;
132 1.1.1.1.2.1 bouyer unsigned short val;
133 1.1.1.1.2.1 bouyer {
134 1.1.1.1.2.1 bouyer bus_space_write_2(chip->kc_iot, chip->kc_ioh, port, val);
135 1.1.1.1.2.1 bouyer }
136 1.1 takemura
137 1.1.1.1.2.1 bouyer static inline unsigned short
138 1.1.1.1.2.1 bouyer vrkiu_read(chip, port)
139 1.1.1.1.2.1 bouyer struct vrkiu_chip *chip;
140 1.1.1.1.2.1 bouyer int port;
141 1.1.1.1.2.1 bouyer {
142 1.1.1.1.2.1 bouyer return bus_space_read_2(chip->kc_iot, chip->kc_ioh, port);
143 1.1.1.1.2.1 bouyer }
144 1.1 takemura
145 1.1.1.1.2.1 bouyer static inline int
146 1.1.1.1.2.1 bouyer vrkiu_is_console(iot, ioh)
147 1.1.1.1.2.1 bouyer bus_space_tag_t iot;
148 1.1.1.1.2.1 bouyer bus_space_handle_t ioh;
149 1.1.1.1.2.1 bouyer {
150 1.1.1.1.2.1 bouyer if (vrkiu_consdata &&
151 1.1.1.1.2.1 bouyer vrkiu_consdata->kc_iot == iot &&
152 1.1.1.1.2.1 bouyer vrkiu_consdata->kc_ioh == ioh) {
153 1.1.1.1.2.1 bouyer return 1;
154 1.1.1.1.2.1 bouyer } else {
155 1.1.1.1.2.1 bouyer return 0;
156 1.1.1.1.2.1 bouyer }
157 1.1.1.1.2.1 bouyer }
158 1.1 takemura
159 1.1.1.1.2.1 bouyer /*
160 1.1.1.1.2.1 bouyer * initialize device
161 1.1.1.1.2.1 bouyer */
162 1.1.1.1.2.1 bouyer static int
163 1.1.1.1.2.1 bouyer vrkiu_init(chip, iot, ioh)
164 1.1.1.1.2.1 bouyer struct vrkiu_chip* chip;
165 1.1.1.1.2.1 bouyer bus_space_tag_t iot;
166 1.1.1.1.2.1 bouyer bus_space_handle_t ioh;
167 1.1.1.1.2.1 bouyer {
168 1.1.1.1.2.1 bouyer memset(chip, 0, sizeof(struct vrkiu_chip));
169 1.1.1.1.2.1 bouyer chip->kc_iot = iot;
170 1.1.1.1.2.1 bouyer chip->kc_ioh = ioh;
171 1.1.1.1.2.1 bouyer chip->kc_enabled = 0;
172 1.1.1.1.2.1 bouyer
173 1.1.1.1.2.1 bouyer chip->kc_if.hii_ctx = chip;
174 1.1.1.1.2.1 bouyer chip->kc_if.hii_establish = vrkiu_input_establish;
175 1.1.1.1.2.1 bouyer chip->kc_if.hii_poll = vrkiu_poll;
176 1.1.1.1.2.1 bouyer
177 1.1.1.1.2.1 bouyer /* set KIU */
178 1.1.1.1.2.1 bouyer vrkiu_write(chip, KIURST, 1); /* reset */
179 1.1.1.1.2.1 bouyer vrkiu_write(chip, KIUSCANLINE, 0); /* 96keys */
180 1.1.1.1.2.1 bouyer vrkiu_write(chip, KIUWKS, 0x18a4); /* XXX: scan timing! */
181 1.1.1.1.2.1 bouyer vrkiu_write(chip, KIUWKI, 450);
182 1.1.1.1.2.1 bouyer vrkiu_write(chip, KIUSCANREP, 0x8023);
183 1.1.1.1.2.1 bouyer /* KEYEN | STPREP = 2 | ATSTP | ATSCAN */
184 1.1 takemura
185 1.1.1.1.2.1 bouyer return 0;
186 1.1.1.1.2.1 bouyer }
187 1.1.1.1.2.1 bouyer
188 1.1.1.1.2.1 bouyer /*
189 1.1.1.1.2.1 bouyer * probe
190 1.1.1.1.2.1 bouyer */
191 1.1 takemura static int
192 1.1 takemura vrkiumatch(parent, cf, aux)
193 1.1 takemura struct device *parent;
194 1.1 takemura struct cfdata *cf;
195 1.1 takemura void *aux;
196 1.1 takemura {
197 1.1.1.1.2.1 bouyer return 1;
198 1.1 takemura }
199 1.1 takemura
200 1.1.1.1.2.1 bouyer /*
201 1.1.1.1.2.1 bouyer * attach
202 1.1.1.1.2.1 bouyer */
203 1.1 takemura static void
204 1.1 takemura vrkiuattach(parent, self, aux)
205 1.1 takemura struct device *parent;
206 1.1 takemura struct device *self;
207 1.1 takemura void *aux;
208 1.1 takemura {
209 1.1 takemura struct vrkiu_softc *sc = (struct vrkiu_softc *)self;
210 1.1 takemura struct vrip_attach_args *va = aux;
211 1.1.1.1.2.1 bouyer struct hpckbd_attach_args haa;
212 1.1.1.1.2.1 bouyer int isconsole;
213 1.1 takemura
214 1.1 takemura bus_space_tag_t iot = va->va_iot;
215 1.1 takemura bus_space_handle_t ioh;
216 1.1 takemura
217 1.1 takemura if (bus_space_map(iot, va->va_addr, 1, 0, &ioh)) {
218 1.1 takemura printf(": can't map bus space\n");
219 1.1 takemura return;
220 1.1 takemura }
221 1.1 takemura
222 1.1.1.1.2.1 bouyer isconsole = vrkiu_is_console(iot, ioh);
223 1.1.1.1.2.1 bouyer if (isconsole) {
224 1.1.1.1.2.1 bouyer sc->sc_chip = vrkiu_consdata;
225 1.1.1.1.2.1 bouyer } else {
226 1.1.1.1.2.1 bouyer sc->sc_chip = &sc->sc_chip_body;
227 1.1.1.1.2.1 bouyer vrkiu_init(sc->sc_chip, iot, ioh);
228 1.1.1.1.2.1 bouyer }
229 1.1.1.1.2.1 bouyer sc->sc_chip->kc_sc = sc;
230 1.1 takemura
231 1.1 takemura if (!(sc->sc_handler =
232 1.1 takemura vrip_intr_establish(va->va_vc, va->va_intr, IPL_TTY,
233 1.1 takemura vrkiu_intr, sc))) {
234 1.1 takemura printf (": can't map interrupt line.\n");
235 1.1 takemura return;
236 1.1 takemura }
237 1.1 takemura /* Level2 register setting */
238 1.1 takemura vrip_intr_setmask2(va->va_vc, sc->sc_handler, KIUINT_KDATRDY, 1);
239 1.1 takemura
240 1.1 takemura printf("\n");
241 1.1.1.1.2.1 bouyer
242 1.1.1.1.2.1 bouyer /* attach hpckbd */
243 1.1.1.1.2.1 bouyer haa.haa_ic = &sc->sc_chip->kc_if;
244 1.1.1.1.2.1 bouyer config_found(self, &haa, hpckbd_print);
245 1.1 takemura }
246 1.1 takemura
247 1.1 takemura int
248 1.1 takemura vrkiu_intr(arg)
249 1.1 takemura void *arg;
250 1.1 takemura {
251 1.1 takemura struct vrkiu_softc *sc = arg;
252 1.1.1.1.2.1 bouyer
253 1.1 takemura /* When key scan finisshed, this entry is called. */
254 1.1.1.1.2.1 bouyer #if 0
255 1.1.1.1.2.1 bouyer DPRINTF(("vrkiu_intr: intr=%x scan=%x\n",
256 1.1.1.1.2.1 bouyer vrkiu_read(sc->sc_chip, KIUINT) & 7,
257 1.1.1.1.2.1 bouyer vrkiu_read(sc->sc_chip, KIUSCANS) & KIUSCANS_SSTAT_MASK));
258 1.1.1.1.2.1 bouyer #endif
259 1.1 takemura
260 1.1.1.1.2.1 bouyer /*
261 1.1.1.1.2.1 bouyer * First, we must clear the interrupt register because
262 1.1.1.1.2.1 bouyer * vrkiu_scan() may takes long time if a bitmap screen
263 1.1.1.1.2.1 bouyer * scrolls up and it makes us to miss some key release
264 1.1.1.1.2.1 bouyer * event.
265 1.1.1.1.2.1 bouyer */
266 1.1.1.1.2.1 bouyer vrkiu_write(sc->sc_chip, KIUINT, 0x7); /* Clear all interrupt */
267 1.1.1.1.2.1 bouyer
268 1.1.1.1.2.1 bouyer #if 1
269 1.1.1.1.2.1 bouyer /* just return if kiu is scanning keyboard. */
270 1.1.1.1.2.1 bouyer if ((vrkiu_read(sc->sc_chip, KIUSCANS) & KIUSCANS_SSTAT_MASK) ==
271 1.1.1.1.2.1 bouyer KIUSCANS_SSTAT_SCANNING)
272 1.1.1.1.2.1 bouyer return (0);
273 1.1.1.1.2.1 bouyer #endif
274 1.1.1.1.2.1 bouyer vrkiu_scan(sc->sc_chip);
275 1.1 takemura
276 1.1.1.1.2.1 bouyer return (0);
277 1.1 takemura }
278 1.1 takemura
279 1.1.1.1.2.1 bouyer static int
280 1.1.1.1.2.1 bouyer countbits(d)
281 1.1.1.1.2.1 bouyer int d;
282 1.1 takemura {
283 1.1.1.1.2.1 bouyer int i, n;
284 1.1 takemura
285 1.1.1.1.2.1 bouyer for (i = 0, n = 0; i < NBBY; i++)
286 1.1.1.1.2.1 bouyer if (d & (1 << i))
287 1.1.1.1.2.1 bouyer n++;
288 1.1.1.1.2.1 bouyer return n;
289 1.1.1.1.2.1 bouyer }
290 1.1 takemura
291 1.1.1.1.2.1 bouyer static void
292 1.1.1.1.2.1 bouyer eliminate_phantom_keys(chip, scandata)
293 1.1.1.1.2.1 bouyer struct vrkiu_chip* chip;
294 1.1.1.1.2.1 bouyer unsigned short *scandata;
295 1.1.1.1.2.1 bouyer {
296 1.1.1.1.2.1 bouyer unsigned char inkey[KIU_NSCANLINE], *prevkey, *reskey;
297 1.1.1.1.2.1 bouyer int i, j;
298 1.1.1.1.2.1 bouyer #ifdef VRKIUDEBUG
299 1.1.1.1.2.1 bouyer int modified = 0;
300 1.1.1.1.2.1 bouyer static int prevmod = 0;
301 1.1.1.1.2.1 bouyer #endif
302 1.1.1.1.2.1 bouyer
303 1.1.1.1.2.1 bouyer reskey = (unsigned char *)scandata;
304 1.1.1.1.2.1 bouyer for (i = 0; i < KIU_NSCANLINE; i++)
305 1.1.1.1.2.1 bouyer inkey[i] = reskey[i];
306 1.1.1.1.2.1 bouyer prevkey = (unsigned char *)chip->kc_scandata;
307 1.1.1.1.2.1 bouyer
308 1.1.1.1.2.1 bouyer for (i = 0; i < KIU_NSCANLINE; i++) {
309 1.1.1.1.2.1 bouyer if (countbits(inkey[i]) > 1) {
310 1.1.1.1.2.1 bouyer for (j = 0; j < KIU_NSCANLINE; j++) {
311 1.1.1.1.2.1 bouyer if (i != j && (inkey[i] & inkey[j])) {
312 1.1.1.1.2.1 bouyer #ifdef VRKIUDEBUG
313 1.1.1.1.2.1 bouyer modified = 1;
314 1.1.1.1.2.1 bouyer if (!prevmod) {
315 1.1.1.1.2.1 bouyer DPRINTF(("vrkiu_scan: %x:%02x->%02x",
316 1.1.1.1.2.1 bouyer i, inkey[i], prevkey[i]));
317 1.1.1.1.2.1 bouyer DPRINTF((" %x:%02x->%02x\n",
318 1.1.1.1.2.1 bouyer j, inkey[j], prevkey[j]));
319 1.1.1.1.2.1 bouyer }
320 1.1.1.1.2.1 bouyer #endif
321 1.1.1.1.2.1 bouyer reskey[i] = prevkey[i];
322 1.1.1.1.2.1 bouyer reskey[j] = prevkey[j];
323 1.1.1.1.2.1 bouyer }
324 1.1 takemura }
325 1.1.1.1.2.1 bouyer }
326 1.1 takemura }
327 1.1.1.1.2.1 bouyer #ifdef VRKIUDEBUG
328 1.1.1.1.2.1 bouyer prevmod = modified;
329 1.1.1.1.2.1 bouyer #endif
330 1.1 takemura }
331 1.1 takemura
332 1.1 takemura static void
333 1.1.1.1.2.1 bouyer vrkiu_scan(chip)
334 1.1.1.1.2.1 bouyer struct vrkiu_chip* chip;
335 1.1.1.1.2.1 bouyer {
336 1.1.1.1.2.1 bouyer int i, j, modified, mask;
337 1.1.1.1.2.1 bouyer unsigned short scandata[KIU_NSCANLINE/2];
338 1.1.1.1.2.1 bouyer
339 1.1.1.1.2.1 bouyer if (!chip->kc_enabled)
340 1.1.1.1.2.1 bouyer return;
341 1.1.1.1.2.1 bouyer
342 1.1.1.1.2.1 bouyer for (i = 0; i < KIU_NSCANLINE / 2; i++) {
343 1.1.1.1.2.1 bouyer scandata[i] = vrkiu_read(chip, KIUDATP + i * 2);
344 1.1.1.1.2.1 bouyer }
345 1.1.1.1.2.1 bouyer eliminate_phantom_keys(chip, scandata);
346 1.1.1.1.2.1 bouyer
347 1.1.1.1.2.1 bouyer for (i = 0; i < KIU_NSCANLINE / 2; i++) {
348 1.1.1.1.2.1 bouyer modified = scandata[i] ^ chip->kc_scandata[i];
349 1.1.1.1.2.1 bouyer chip->kc_scandata[i] = scandata[i];
350 1.1.1.1.2.1 bouyer mask = 1;
351 1.1.1.1.2.1 bouyer for (j = 0; j < 16; j++, mask <<= 1) {
352 1.1.1.1.2.1 bouyer /*
353 1.1.1.1.2.1 bouyer * Simultaneous keypresses are resolved by registering
354 1.1.1.1.2.1 bouyer * the one with the lowest bit index first.
355 1.1.1.1.2.1 bouyer */
356 1.1.1.1.2.1 bouyer if (modified & mask) {
357 1.1.1.1.2.1 bouyer int key = i * 16 + j;
358 1.1.1.1.2.1 bouyer DPRINTF(("vrkiu_scan: %s(%d,%d)\n",
359 1.1.1.1.2.1 bouyer (scandata[i] & mask) ? "down" : "up",
360 1.1.1.1.2.1 bouyer i, j));
361 1.1.1.1.2.1 bouyer hpckbd_input(chip->kc_hpckbd,
362 1.1.1.1.2.1 bouyer (scandata[i] & mask), key);
363 1.1 takemura }
364 1.1 takemura }
365 1.1 takemura }
366 1.1 takemura }
367 1.1 takemura
368 1.1.1.1.2.1 bouyer /* called from bicons.c */
369 1.1 takemura int
370 1.1 takemura vrkiu_getc()
371 1.1 takemura {
372 1.1.1.1.2.1 bouyer static int flag = 1;
373 1.1 takemura
374 1.1.1.1.2.1 bouyer /*
375 1.1.1.1.2.1 bouyer * XXX, currently
376 1.1.1.1.2.1 bouyer */
377 1.1.1.1.2.1 bouyer if (flag) {
378 1.1.1.1.2.1 bouyer flag = 0;
379 1.1.1.1.2.1 bouyer printf("%s(%d): vrkiu_getc() is not implemented\n",
380 1.1.1.1.2.1 bouyer __FILE__, __LINE__);
381 1.1 takemura }
382 1.1.1.1.2.1 bouyer return 0;
383 1.1.1.1.2.1 bouyer }
384 1.1.1.1.2.1 bouyer
385 1.1.1.1.2.1 bouyer /*
386 1.1.1.1.2.1 bouyer * hpckbd interface routines
387 1.1.1.1.2.1 bouyer */
388 1.1.1.1.2.1 bouyer int
389 1.1.1.1.2.1 bouyer vrkiu_input_establish(ic, kbdif)
390 1.1.1.1.2.1 bouyer void *ic;
391 1.1.1.1.2.1 bouyer struct hpckbd_if *kbdif;
392 1.1.1.1.2.1 bouyer {
393 1.1.1.1.2.1 bouyer struct vrkiu_chip *kc = ic;
394 1.1 takemura
395 1.1.1.1.2.1 bouyer /* save hpckbd interface */
396 1.1.1.1.2.1 bouyer kc->kc_hpckbd = kbdif;
397 1.1.1.1.2.1 bouyer
398 1.1.1.1.2.1 bouyer kc->kc_enabled = 1;
399 1.1.1.1.2.1 bouyer
400 1.1.1.1.2.1 bouyer return 0;
401 1.1.1.1.2.1 bouyer }
402 1.1.1.1.2.1 bouyer
403 1.1.1.1.2.1 bouyer int
404 1.1.1.1.2.1 bouyer vrkiu_poll(ic)
405 1.1.1.1.2.1 bouyer void *ic;
406 1.1.1.1.2.1 bouyer {
407 1.1.1.1.2.1 bouyer struct vrkiu_chip *kc = ic;
408 1.1.1.1.2.1 bouyer
409 1.1.1.1.2.1 bouyer #if 1
410 1.1.1.1.2.1 bouyer /* wait until kiu completes keyboard scan. */
411 1.1.1.1.2.1 bouyer while ((vrkiu_read(kc, KIUSCANS) & KIUSCANS_SSTAT_MASK) ==
412 1.1.1.1.2.1 bouyer KIUSCANS_SSTAT_SCANNING)
413 1.1.1.1.2.1 bouyer /* wait until kiu completes keyboard scan */;
414 1.1.1.1.2.1 bouyer #endif
415 1.1.1.1.2.1 bouyer
416 1.1.1.1.2.1 bouyer vrkiu_scan(kc);
417 1.1.1.1.2.1 bouyer
418 1.1.1.1.2.1 bouyer return 0;
419 1.1.1.1.2.1 bouyer }
420 1.1.1.1.2.1 bouyer
421 1.1.1.1.2.1 bouyer /*
422 1.1.1.1.2.1 bouyer * console support routine
423 1.1.1.1.2.1 bouyer */
424 1.1.1.1.2.1 bouyer int
425 1.1.1.1.2.1 bouyer vrkiu_cnattach(iot, iobase)
426 1.1.1.1.2.1 bouyer bus_space_tag_t iot;
427 1.1.1.1.2.1 bouyer int iobase;
428 1.1.1.1.2.1 bouyer {
429 1.1.1.1.2.1 bouyer static struct vrkiu_chip vrkiu_consdata_body;
430 1.1.1.1.2.1 bouyer bus_space_handle_t ioh;
431 1.1.1.1.2.1 bouyer
432 1.1.1.1.2.1 bouyer if (vrkiu_consdata) {
433 1.1.1.1.2.1 bouyer panic("vrkiu is already attached as the console");
434 1.1 takemura }
435 1.1.1.1.2.1 bouyer if (bus_space_map(iot, iobase, 1, 0, &ioh)) {
436 1.1.1.1.2.1 bouyer printf("%s(%d): can't map bus space\n", __FILE__, __LINE__);
437 1.1.1.1.2.1 bouyer return -1;
438 1.1 takemura }
439 1.1 takemura
440 1.1.1.1.2.1 bouyer if (vrkiu_init(&vrkiu_consdata_body, iot, ioh) != 0) {
441 1.1.1.1.2.1 bouyer DPRINTF(("%s(%d): vrkiu_init() failed\n", __FILE__, __LINE__));
442 1.1.1.1.2.1 bouyer return -1;
443 1.1.1.1.2.1 bouyer }
444 1.1.1.1.2.1 bouyer vrkiu_consdata = &vrkiu_consdata_body;
445 1.1.1.1.2.1 bouyer
446 1.1.1.1.2.1 bouyer hpckbd_cnattach(&vrkiu_consdata_body.kc_if);
447 1.1.1.1.2.1 bouyer
448 1.1.1.1.2.1 bouyer return (0);
449 1.1.1.1.2.1 bouyer }
450