vrkiu.c revision 1.1.1.1.6.1 1 1.1.1.1.6.1 wrstuden /* $NetBSD: vrkiu.c,v 1.1.1.1.6.1 1999/12/27 18:32:15 wrstuden Exp $ */
2 1.1 takemura
3 1.1 takemura /*-
4 1.1.1.1.6.1 wrstuden * Copyright (c) 1999 SASAKI Takesi All rights reserved.
5 1.1.1.1.6.1 wrstuden * Copyright (c) 1999 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 #define VRKIUDEBUG
39 1.1 takemura
40 1.1 takemura #include <sys/param.h>
41 1.1 takemura #include <sys/tty.h>
42 1.1 takemura #include <sys/systm.h>
43 1.1 takemura #include <sys/device.h>
44 1.1 takemura #include <sys/conf.h>
45 1.1 takemura #include <sys/kernel.h>
46 1.1 takemura #include <sys/proc.h>
47 1.1 takemura
48 1.1 takemura #include <machine/intr.h>
49 1.1 takemura #include <machine/cpu.h>
50 1.1 takemura #include <machine/bus.h>
51 1.1 takemura #include <machine/platid.h>
52 1.1.1.1.6.1 wrstuden #include <machine/platid_mask.h>
53 1.1 takemura
54 1.1 takemura #include <hpcmips/vr/vr.h>
55 1.1 takemura #include <hpcmips/vr/vripvar.h>
56 1.1 takemura #include <hpcmips/vr/vrkiuvar.h>
57 1.1 takemura #include <hpcmips/vr/vrkiureg.h>
58 1.1 takemura #include <hpcmips/vr/icureg.h>
59 1.1 takemura
60 1.1.1.1.6.1 wrstuden #include <dev/wscons/wsconsio.h>
61 1.1.1.1.6.1 wrstuden #include <dev/wscons/wskbdvar.h>
62 1.1.1.1.6.1 wrstuden #include <dev/wscons/wsksymdef.h>
63 1.1.1.1.6.1 wrstuden #include <dev/wscons/wsksymvar.h>
64 1.1.1.1.6.1 wrstuden #include <dev/pckbc/wskbdmap_mfii.h>
65 1.1.1.1.6.1 wrstuden
66 1.1.1.1.6.1 wrstuden #include "opt_pckbd_layout.h"
67 1.1.1.1.6.1 wrstuden
68 1.1 takemura #ifdef VRKIUDEBUG
69 1.1 takemura int vrkiu_debug = 0;
70 1.1 takemura #define DPRINTF(arg) if (vrkiu_debug) printf arg;
71 1.1 takemura #else
72 1.1 takemura #define DPRINTF(arg)
73 1.1 takemura #endif
74 1.1 takemura
75 1.1.1.1.6.1 wrstuden /*
76 1.1.1.1.6.1 wrstuden * structure and data types
77 1.1.1.1.6.1 wrstuden */
78 1.1.1.1.6.1 wrstuden struct vrkiu_chip {
79 1.1.1.1.6.1 wrstuden bus_space_tag_t kc_iot;
80 1.1.1.1.6.1 wrstuden bus_space_handle_t kc_ioh;
81 1.1.1.1.6.1 wrstuden unsigned short kc_scandata[KIU_NSCANLINE/2];
82 1.1.1.1.6.1 wrstuden int kc_polling;
83 1.1.1.1.6.1 wrstuden u_int kc_type;
84 1.1.1.1.6.1 wrstuden int kc_data;
85 1.1.1.1.6.1 wrstuden
86 1.1.1.1.6.1 wrstuden int kc_sft:1, kc_alt:1, kc_ctrl:1;
87 1.1.1.1.6.1 wrstuden
88 1.1.1.1.6.1 wrstuden struct vrkiu_softc* kc_sc; /* back link */
89 1.1.1.1.6.1 wrstuden };
90 1.1.1.1.6.1 wrstuden
91 1.1.1.1.6.1 wrstuden struct vrkiu_softc {
92 1.1.1.1.6.1 wrstuden struct device sc_dev;
93 1.1.1.1.6.1 wrstuden struct vrkiu_chip *sc_chip;
94 1.1.1.1.6.1 wrstuden struct vrkiu_chip sc_chip_body;
95 1.1.1.1.6.1 wrstuden int sc_enabled;
96 1.1.1.1.6.1 wrstuden struct device *sc_wskbddev;
97 1.1.1.1.6.1 wrstuden
98 1.1.1.1.6.1 wrstuden void *sc_handler;
99 1.1.1.1.6.1 wrstuden #define NKEYBUF 32
100 1.1.1.1.6.1 wrstuden unsigned char keybuf[NKEYBUF];
101 1.1.1.1.6.1 wrstuden int keybufhead, keybuftail;
102 1.1.1.1.6.1 wrstuden };
103 1.1.1.1.6.1 wrstuden
104 1.1.1.1.6.1 wrstuden /*
105 1.1.1.1.6.1 wrstuden * function prototypes
106 1.1.1.1.6.1 wrstuden */
107 1.1 takemura static int vrkiumatch __P((struct device *, struct cfdata *, void *));
108 1.1 takemura static void vrkiuattach __P((struct device *, struct device *, void *));
109 1.1 takemura
110 1.1 takemura int vrkiu_intr __P((void *));
111 1.1 takemura
112 1.1.1.1.6.1 wrstuden static int vrkiu_init(struct vrkiu_chip*, bus_space_tag_t, bus_space_handle_t);
113 1.1.1.1.6.1 wrstuden static void vrkiu_write __P((struct vrkiu_chip *, int, unsigned short));
114 1.1.1.1.6.1 wrstuden static unsigned short vrkiu_read __P((struct vrkiu_chip *, int));
115 1.1.1.1.6.1 wrstuden static int vrkiu_is_console(bus_space_tag_t, bus_space_handle_t);
116 1.1.1.1.6.1 wrstuden static void detect_key __P((struct vrkiu_chip *));
117 1.1.1.1.6.1 wrstuden
118 1.1.1.1.6.1 wrstuden static struct vrkiu_softc *the_vrkiu = NULL; /* XXX: kludge!! */
119 1.1.1.1.6.1 wrstuden
120 1.1.1.1.6.1 wrstuden /* wskbd accessopts */
121 1.1.1.1.6.1 wrstuden int vrkiu_enable __P((void *, int));
122 1.1.1.1.6.1 wrstuden void vrkiu_set_leds __P((void *, int));
123 1.1.1.1.6.1 wrstuden int vrkiu_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
124 1.1.1.1.6.1 wrstuden
125 1.1.1.1.6.1 wrstuden /* consopts */
126 1.1.1.1.6.1 wrstuden void vrkiu_cngetc __P((void*, u_int*, int*));
127 1.1.1.1.6.1 wrstuden void vrkiu_cnpollc __P((void *, int));
128 1.1 takemura
129 1.1.1.1.6.1 wrstuden /*
130 1.1.1.1.6.1 wrstuden * global/static data
131 1.1.1.1.6.1 wrstuden */
132 1.1 takemura struct cfattach vrkiu_ca = {
133 1.1 takemura sizeof(struct vrkiu_softc), vrkiumatch, vrkiuattach
134 1.1 takemura };
135 1.1 takemura
136 1.1.1.1.6.1 wrstuden const struct wskbd_accessops vrkiu_accessops = {
137 1.1.1.1.6.1 wrstuden vrkiu_enable,
138 1.1.1.1.6.1 wrstuden vrkiu_set_leds,
139 1.1.1.1.6.1 wrstuden vrkiu_ioctl,
140 1.1.1.1.6.1 wrstuden };
141 1.1 takemura
142 1.1.1.1.6.1 wrstuden const struct wskbd_consops vrkiu_consops = {
143 1.1.1.1.6.1 wrstuden vrkiu_cngetc,
144 1.1.1.1.6.1 wrstuden vrkiu_cnpollc,
145 1.1.1.1.6.1 wrstuden };
146 1.1 takemura
147 1.1.1.1.6.1 wrstuden struct wskbd_mapdata vrkiu_keymapdata = {
148 1.1.1.1.6.1 wrstuden pckbd_keydesctab,
149 1.1.1.1.6.1 wrstuden #ifdef PCKBD_LAYOUT
150 1.1.1.1.6.1 wrstuden PCKBD_LAYOUT,
151 1.1 takemura #else
152 1.1.1.1.6.1 wrstuden KB_US,
153 1.1 takemura #endif
154 1.1 takemura };
155 1.1 takemura
156 1.1.1.1.6.1 wrstuden struct vrkiu_chip *vrkiu_consdata = NULL;
157 1.1.1.1.6.1 wrstuden
158 1.1.1.1.6.1 wrstuden #define UNK -1 /* unknown */
159 1.1.1.1.6.1 wrstuden #define IGN -2 /* ignore */
160 1.1.1.1.6.1 wrstuden
161 1.1.1.1.6.1 wrstuden static char default_keytrans[] = {
162 1.1.1.1.6.1 wrstuden /*00*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
163 1.1.1.1.6.1 wrstuden /*08*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
164 1.1.1.1.6.1 wrstuden /*10*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
165 1.1.1.1.6.1 wrstuden /*18*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
166 1.1.1.1.6.1 wrstuden /*20*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
167 1.1.1.1.6.1 wrstuden /*28*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
168 1.1.1.1.6.1 wrstuden /*30*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
169 1.1.1.1.6.1 wrstuden /*38*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
170 1.1.1.1.6.1 wrstuden /*40*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
171 1.1.1.1.6.1 wrstuden /*48*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
172 1.1.1.1.6.1 wrstuden /*50*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
173 1.1.1.1.6.1 wrstuden /*58*/ UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, /* - - - - - - - - */
174 1.1.1.1.6.1 wrstuden };
175 1.1 takemura
176 1.1.1.1.6.1 wrstuden /* NEC MobileGearII MCR series (Japan) */
177 1.1.1.1.6.1 wrstuden static char mcr_jp_keytrans[] = {
178 1.1.1.1.6.1 wrstuden /*00*/ 77, 28, 25, 52, 21, 48, 44, 57, /* right ent p . y b z space */
179 1.1.1.1.6.1 wrstuden /*08*/ 80, 53, 24, 51, 20, 47, 30, 123, /* down / o , t v a nfer */
180 1.1.1.1.6.1 wrstuden /*10*/ 75, 115, 23, 50, 19, 46, 17, 221, /* left \ i m r c w menu */
181 1.1.1.1.6.1 wrstuden /*18*/ 13, IGN, 22, IGN, 18, 45, 16, 2, /* ^ - u - e x q 1 */
182 1.1.1.1.6.1 wrstuden /*20*/ 81, 41, 11, 38, 40, 34, 15, 59, /* pgdn h/z 0 l : g tab f1 */
183 1.1.1.1.6.1 wrstuden /*28*/ 121, 39, 10, 49, 6, 33, 3, 37, /* xfer ; 9 n 5 f 2 k */
184 1.1.1.1.6.1 wrstuden /*30*/ 72, 27, 9, 36, 5, 32, 7, IGN, /* up [ 8 j 4 d 6 - */
185 1.1.1.1.6.1 wrstuden /*38*/ 12, 26, 8, 35, 4, 43, 31, IGN, /* - @ 7 h 3 ] s - */
186 1.1.1.1.6.1 wrstuden /*40*/ 58, IGN, IGN, IGN, 14, IGN, 66, 61, /* caps - - - bs - f8 f3 */
187 1.1.1.1.6.1 wrstuden /*48*/ IGN, 56, IGN, IGN, 125, 112, 65, 62, /* - alt - - | k/h f7 f4 */
188 1.1.1.1.6.1 wrstuden /*50*/ IGN, IGN, 29, IGN, 68, 73, 64, 60, /* - - ctrl - f10 pgup f6 f2 */
189 1.1.1.1.6.1 wrstuden /*58*/ IGN, IGN, IGN, 42, 14, 67, 63, 1, /* - - - shift del f9 f5 esc */
190 1.1.1.1.6.1 wrstuden };
191 1.1.1.1.6.1 wrstuden
192 1.1.1.1.6.1 wrstuden /* IBM WorkPad z50 */
193 1.1.1.1.6.1 wrstuden static char z50_keytrans[] = {
194 1.1.1.1.6.1 wrstuden /*00*/ 59, 61, 63, 65, 67, IGN, IGN, 87, /* f1 f3 f5 f7 f9 - - f11 */
195 1.1.1.1.6.1 wrstuden /*08*/ 60, 62, 64, 66, 68, IGN, IGN, 88, /* f2 f4 f6 f8 f10 - - f12 */
196 1.1.1.1.6.1 wrstuden /*10*/ 40, 26, 12, 11, 25, 39, 72, 53, /* ' [ - 0 p ; up / */
197 1.1.1.1.6.1 wrstuden /*18*/ IGN, IGN, IGN, 10, 24, 38, 52, IGN, /* - - - 9 o l . - */
198 1.1.1.1.6.1 wrstuden /*20*/ 75, 27, 13, 9, 23, 37, 51, IGN, /* left ] = 8 i k , - */
199 1.1.1.1.6.1 wrstuden /*28*/ 35, 21, 7, 8, 22, 36, 50, 49, /* h y 6 7 u j m n */
200 1.1.1.1.6.1 wrstuden /*30*/ IGN, 14, 69, 14, IGN, 43, 28, 57, /* - bs num del - \ ent sp */
201 1.1.1.1.6.1 wrstuden /*38*/ 34, 20, 6, 5, 19, 33, 47, 48, /* g t 5 4 r f v b */
202 1.1.1.1.6.1 wrstuden /*40*/ IGN, IGN, IGN, 4, 18, 32, 46, 77, /* - - - 3 e d c right */
203 1.1.1.1.6.1 wrstuden /*48*/ IGN, IGN, IGN, 3, 17, 31, 45, 80, /* - - - 2 w s x down */
204 1.1.1.1.6.1 wrstuden /*50*/ 1, 29, 41, 2, 16, 30, 44, IGN, /* esc tab ~ 1 q a z - */
205 1.1.1.1.6.1 wrstuden /*58*/ 221, 42, 29, 29, 56, 56, 54, IGN, /* menu Ls Lc Rc La Ra Rs - */
206 1.1.1.1.6.1 wrstuden };
207 1.1.1.1.6.1 wrstuden
208 1.1.1.1.6.1 wrstuden /* Sharp Tripad PV6000 */
209 1.1.1.1.6.1 wrstuden static char tripad_keytrans[] = {
210 1.1.1.1.6.1 wrstuden /*00*/ 42, 15, 41, 16, 1, 2, 104, 221, /* lsh tab ` q esc 1 WIN - */
211 1.1.1.1.6.1 wrstuden /*08*/ 58, 44, 45, 30, 31, 17, 18, 3, /* ctrl z x a s w e 2 */
212 1.1.1.1.6.1 wrstuden /*10*/ 56, 57, 46, 47, 32, 33, 19, 4, /* lalt sp c v d f r 3 */
213 1.1.1.1.6.1 wrstuden /*18*/ 48, 49, 34, 35, 20, 21, 5, 6, /* b n g h t y 4 5 */
214 1.1.1.1.6.1 wrstuden /*20*/ 50, 51, 36, 37, 22, 23, 7, 8, /* m , j k u i 6 7 */
215 1.1.1.1.6.1 wrstuden /*28*/ 105, 29, 38, 24, 25, 9, 10, 11, /* Fn caps l o p 8 9 0 */
216 1.1.1.1.6.1 wrstuden /*30*/ 26, 27, 102, 52, 53, 39, 12, 13, /* [ ] dar , / ; \- = */
217 1.1.1.1.6.1 wrstuden /*38*/ 54, 103, 100, 102, 39, 28, 43, 14, /* rsh - - uar - ; ent \ del */
218 1.1.1.1.6.1 wrstuden /*40*/ IGN, IGN, IGN, IGN, IGN, IGN, IGN, IGN, /* - - - - - - - - */
219 1.1.1.1.6.1 wrstuden /*48*/ IGN, IGN, IGN, IGN, IGN, IGN, IGN, IGN, /* - - - - - - - - */
220 1.1.1.1.6.1 wrstuden /*50*/ IGN, IGN, IGN, IGN, IGN, IGN, IGN, IGN, /* - - - - - - - - */
221 1.1.1.1.6.1 wrstuden /*58*/ IGN, IGN, IGN, IGN, IGN, IGN, IGN, IGN, /* - - - - - - - - */
222 1.1.1.1.6.1 wrstuden };
223 1.1.1.1.6.1 wrstuden
224 1.1.1.1.6.1 wrstuden /* NEC Mobile Gear MCCS series */
225 1.1.1.1.6.1 wrstuden static char mccs_keytrans[] = {
226 1.1.1.1.6.1 wrstuden /*00*/ 58, 28, 102, 25, 52, 21, 48, 44, /* caps cr rar p . y b z */
227 1.1.1.1.6.1 wrstuden /*08*/ 56, 27, 103, 24, 51, 20, 47, 30, /* alt [ dar o , t v a */
228 1.1.1.1.6.1 wrstuden /*10*/ 41, 26, 101, 23, 50, 19, 46, 17, /* zen @ lar i m r c w */
229 1.1.1.1.6.1 wrstuden /*18*/ 29, 39, 100, 22, 49, 18, 45, 16, /* lctrl ; uar u n e x q */
230 1.1.1.1.6.1 wrstuden /*20*/ 42, 14, 115, 11, 38, 7, 34, 15, /* lshft bs \ 0 l 6 g tab */
231 1.1.1.1.6.1 wrstuden /*28*/ 123, 125, 53, 10, 37, 6, 33, 3, /* nconv | / 9 k 5 f 2 */
232 1.1.1.1.6.1 wrstuden /*30*/ 121, 13, 43, 9, 36, 5, 32, 2, /* conv = ] 8 j 4 d 1 */
233 1.1.1.1.6.1 wrstuden /*38*/ 112, 12, 40, 8, 35, 4, 31, 1, /* hira - ' 7 h 3 s esc */
234 1.1.1.1.6.1 wrstuden /*40*/ IGN, 57, IGN, IGN, IGN, IGN, IGN, IGN, /* - sp - - - - - - */
235 1.1.1.1.6.1 wrstuden /*48*/ IGN, IGN, IGN, IGN, IGN, IGN, IGN, IGN, /* - - - - - - - - */
236 1.1.1.1.6.1 wrstuden /*50*/ IGN, IGN, IGN, IGN, IGN, IGN, IGN, IGN, /* - - - - - - - - */
237 1.1.1.1.6.1 wrstuden /*58*/ IGN, IGN, IGN, IGN, IGN, IGN, IGN, IGN, /* - - - - - - - - */
238 1.1.1.1.6.1 wrstuden };
239 1.1.1.1.6.1 wrstuden
240 1.1.1.1.6.1 wrstuden static char mobilepro_keytrans[] = {
241 1.1.1.1.6.1 wrstuden /*00*/ 57, 27, 43, 53, 75, 80, 28, 38, /* space ] \ / - - enter l */
242 1.1.1.1.6.1 wrstuden /*08*/ IGN, 26, 40, 39, 77, 72, 52, 24, /* - [ ' ; - - . o */
243 1.1.1.1.6.1 wrstuden /*10*/ IGN, IGN, IGN, 221, 47, 46, 45, 44, /* - - - Windows v c x z */
244 1.1.1.1.6.1 wrstuden /*18*/ IGN, 13, 12, 41, 33, 32, 31, 30, /* - = \- ` f d s a */
245 1.1.1.1.6.1 wrstuden /*20*/ 9, 8, 7, 6, 19, 18, 17, 16, /* 8 7 6 5 r e w q */
246 1.1.1.1.6.1 wrstuden /*28*/ 51, 50, 49, 48, IGN, IGN, 11, 10, /* , m n b - - 0 9 */
247 1.1.1.1.6.1 wrstuden /*30*/ 37, 36, 35, 34, 5, 4, 3, 2, /* k j h g 4 3 2 1 */
248 1.1.1.1.6.1 wrstuden /*38*/ 23, 22, 21, 20, IGN, 58, 14, 1, /* i u y t - caps del esc */
249 1.1.1.1.6.1 wrstuden /*40*/ 184, IGN, IGN, IGN, 14, 25, 15, IGN, /* alt_R - - - BS p TAB Fn */
250 1.1.1.1.6.1 wrstuden /*48*/ IGN, 56, IGN, IGN, 88, 87, 68, 67, /* - alt_L - - f12 f11 f10 f9*/
251 1.1.1.1.6.1 wrstuden /*50*/ IGN, IGN, 29, IGN, 66, 65, 64, 63, /* - - ctrl - f8 f7 f6 f5 */
252 1.1.1.1.6.1 wrstuden /*58*/ IGN, IGN, IGN, 42, 62, 61, 60, 59, /* - - - shift f4 f3 f2 f1 */
253 1.1.1.1.6.1 wrstuden };
254 1.1.1.1.6.1 wrstuden
255 1.1.1.1.6.1 wrstuden /* NEC MobilePro 750c by "Castor Fu" <castor (at) geocast.com> */
256 1.1.1.1.6.1 wrstuden static char mobilepro750c_keytrans[] = {
257 1.1.1.1.6.1 wrstuden /*00*/ 77, 43, 25, 52, 21, 48, 44, 57, /* right \ p . y b z space */
258 1.1.1.1.6.1 wrstuden /*08*/ 80, 53, 24, 51, 20, 47, 30, IGN, /* down / o , t v a - */
259 1.1.1.1.6.1 wrstuden /*10*/ 75, 28, 23, 50, 19, 46, 17, 221, /* left enter i m r c w Win */
260 1.1.1.1.6.1 wrstuden /*18*/ 69, 27, 22, 49, 18, 45, 16, 58, /* num ] u n e x q caps */
261 1.1.1.1.6.1 wrstuden /*20*/ 81, IGN, 11, 38, 7, 34, 15, 1, /* pgdn - 0 l : g tab esc */
262 1.1.1.1.6.1 wrstuden /*28*/ IGN, 39, 10, 37, 6, 33, 3, 41, /* - ; 9 k 5 f 2 ` */
263 1.1.1.1.6.1 wrstuden /*30*/ 72, 26, 9, 36, 5, 32, 2, 40, /* up [ 8 j 4 d 1 ' */
264 1.1.1.1.6.1 wrstuden /*38*/ 12, 26, 8, 35, 4, 31, 83, IGN, /* - @ 7 h 3 s del - */
265 1.1.1.1.6.1 wrstuden /*40*/ 42, IGN, IGN, IGN, 14, 88, 66, 62, /* shift - - - bs f12 f8 f4 */
266 1.1.1.1.6.1 wrstuden /*48*/ IGN, 56, IGN, IGN, 125, 87, 65, 61, /* - alt - - | f11 f7 f3 */
267 1.1.1.1.6.1 wrstuden /*50*/ IGN, IGN, 29, IGN, 68, 68, 64, 60, /* - - ctrl - f10 f10 f6 f2 */
268 1.1.1.1.6.1 wrstuden /*58*/ IGN, IGN, IGN, 42, 13, 67, 63, 59, /* - - - shift del f9 f5 f1 */
269 1.1.1.1.6.1 wrstuden };
270 1.1.1.1.6.1 wrstuden
271 1.1.1.1.6.1 wrstuden /* FUJITSU INTERTOP CX300 */
272 1.1.1.1.6.1 wrstuden static char intertop_keytrans[] = {
273 1.1.1.1.6.1 wrstuden 57, 60, 2, 15, 28, 58, 75, 41,
274 1.1.1.1.6.1 wrstuden 112, 59, 3, 16, IGN, 30, 56, 1,
275 1.1.1.1.6.1 wrstuden 210, 17, 4, 31, 83, 43, 80, 45,
276 1.1.1.1.6.1 wrstuden 44, 18, 5, 32, 68, 125, 77, 46,
277 1.1.1.1.6.1 wrstuden 115, 19, 39, 33, 67, 26, 13, 47,
278 1.1.1.1.6.1 wrstuden 53, 20, 6, 34, 66, 25, 12, 48,
279 1.1.1.1.6.1 wrstuden 52, 21, 7, 35, 65, 38, 11, 49,
280 1.1.1.1.6.1 wrstuden IGN, 22, 8, 36, 63, 24, 14, 50,
281 1.1.1.1.6.1 wrstuden IGN, 61, 9, 62, IGN, 23, 37, 51,
282 1.1.1.1.6.1 wrstuden 69, 40, 10, 27, 64, IGN, 72, IGN,
283 1.1.1.1.6.1 wrstuden IGN, IGN, IGN, IGN, 42, IGN, IGN, 54,
284 1.1.1.1.6.1 wrstuden 29, 221, 123, 121, 184, IGN, IGN, IGN,
285 1.1.1.1.6.1 wrstuden };
286 1.1.1.1.6.1 wrstuden /*
287 1.1.1.1.6.1 wrstuden space a2 1 tab enter caps left zenkaku
288 1.1.1.1.6.1 wrstuden hiraga a1 2 q - a fnc esc
289 1.1.1.1.6.1 wrstuden ins w 3 s del ] down x
290 1.1.1.1.6.1 wrstuden z e 4 d a10 \ right c
291 1.1.1.1.6.1 wrstuden backsla r ; f a9 @ ^ v
292 1.1.1.1.6.1 wrstuden / t 5 g a8 p - b
293 1.1.1.1.6.1 wrstuden . y 6 h a7 l 0 n
294 1.1.1.1.6.1 wrstuden - u 7 j a5 o bs m
295 1.1.1.1.6.1 wrstuden - a3 8 a4 - i k ,
296 1.1.1.1.6.1 wrstuden num : 9 [ a6 - up -
297 1.1.1.1.6.1 wrstuden - - - - shift_L - - shift_R
298 1.1.1.1.6.1 wrstuden ctrl win muhenka henkan alt - - -
299 1.1.1.1.6.1 wrstuden */
300 1.1.1.1.6.1 wrstuden
301 1.1.1.1.6.1 wrstuden static char *keytrans = default_keytrans;
302 1.1.1.1.6.1 wrstuden
303 1.1.1.1.6.1 wrstuden /*
304 1.1.1.1.6.1 wrstuden * utilities
305 1.1.1.1.6.1 wrstuden */
306 1.1 takemura static inline void
307 1.1.1.1.6.1 wrstuden vrkiu_write(chip, port, val)
308 1.1.1.1.6.1 wrstuden struct vrkiu_chip *chip;
309 1.1 takemura int port;
310 1.1 takemura unsigned short val;
311 1.1 takemura {
312 1.1.1.1.6.1 wrstuden bus_space_write_2(chip->kc_iot, chip->kc_ioh, port, val);
313 1.1 takemura }
314 1.1 takemura
315 1.1 takemura static inline unsigned short
316 1.1.1.1.6.1 wrstuden vrkiu_read(chip, port)
317 1.1.1.1.6.1 wrstuden struct vrkiu_chip *chip;
318 1.1 takemura int port;
319 1.1 takemura {
320 1.1.1.1.6.1 wrstuden return bus_space_read_2(chip->kc_iot, chip->kc_ioh, port);
321 1.1.1.1.6.1 wrstuden }
322 1.1.1.1.6.1 wrstuden
323 1.1.1.1.6.1 wrstuden static inline int
324 1.1.1.1.6.1 wrstuden vrkiu_is_console(iot, ioh)
325 1.1.1.1.6.1 wrstuden bus_space_tag_t iot;
326 1.1.1.1.6.1 wrstuden bus_space_handle_t ioh;
327 1.1.1.1.6.1 wrstuden {
328 1.1.1.1.6.1 wrstuden if (vrkiu_consdata &&
329 1.1.1.1.6.1 wrstuden vrkiu_consdata->kc_iot == iot &&
330 1.1.1.1.6.1 wrstuden vrkiu_consdata->kc_ioh == ioh) {
331 1.1.1.1.6.1 wrstuden return 1;
332 1.1.1.1.6.1 wrstuden } else {
333 1.1.1.1.6.1 wrstuden return 0;
334 1.1.1.1.6.1 wrstuden }
335 1.1.1.1.6.1 wrstuden }
336 1.1.1.1.6.1 wrstuden
337 1.1.1.1.6.1 wrstuden /*
338 1.1.1.1.6.1 wrstuden * initialize device
339 1.1.1.1.6.1 wrstuden */
340 1.1.1.1.6.1 wrstuden static int
341 1.1.1.1.6.1 wrstuden vrkiu_init(chip, iot, ioh)
342 1.1.1.1.6.1 wrstuden struct vrkiu_chip* chip;
343 1.1.1.1.6.1 wrstuden bus_space_tag_t iot;
344 1.1.1.1.6.1 wrstuden bus_space_handle_t ioh;
345 1.1.1.1.6.1 wrstuden {
346 1.1.1.1.6.1 wrstuden memset(chip, 0, sizeof(struct vrkiu_chip));
347 1.1.1.1.6.1 wrstuden chip->kc_iot = iot;
348 1.1.1.1.6.1 wrstuden chip->kc_ioh = ioh;
349 1.1.1.1.6.1 wrstuden chip->kc_polling = 0;
350 1.1.1.1.6.1 wrstuden
351 1.1.1.1.6.1 wrstuden /* set KIU */
352 1.1.1.1.6.1 wrstuden vrkiu_write(chip, KIURST, 1); /* reset */
353 1.1.1.1.6.1 wrstuden vrkiu_write(chip, KIUSCANLINE, 0); /* 96keys */
354 1.1.1.1.6.1 wrstuden vrkiu_write(chip, KIUWKS, 0x18a4); /* XXX: scan timing! */
355 1.1.1.1.6.1 wrstuden vrkiu_write(chip, KIUWKI, 450);
356 1.1.1.1.6.1 wrstuden vrkiu_write(chip, KIUSCANREP, 0x8023);
357 1.1.1.1.6.1 wrstuden /* KEYEN | STPREP = 2 | ATSTP | ATSCAN */
358 1.1.1.1.6.1 wrstuden return 0;
359 1.1.1.1.6.1 wrstuden }
360 1.1.1.1.6.1 wrstuden
361 1.1.1.1.6.1 wrstuden /*
362 1.1.1.1.6.1 wrstuden * probe
363 1.1.1.1.6.1 wrstuden */
364 1.1.1.1.6.1 wrstuden static int
365 1.1.1.1.6.1 wrstuden vrkiumatch(parent, cf, aux)
366 1.1.1.1.6.1 wrstuden struct device *parent;
367 1.1.1.1.6.1 wrstuden struct cfdata *cf;
368 1.1.1.1.6.1 wrstuden void *aux;
369 1.1.1.1.6.1 wrstuden {
370 1.1.1.1.6.1 wrstuden return 1;
371 1.1 takemura }
372 1.1 takemura
373 1.1.1.1.6.1 wrstuden /*
374 1.1.1.1.6.1 wrstuden * attach
375 1.1.1.1.6.1 wrstuden */
376 1.1 takemura static void
377 1.1 takemura vrkiuattach(parent, self, aux)
378 1.1 takemura struct device *parent;
379 1.1 takemura struct device *self;
380 1.1 takemura void *aux;
381 1.1 takemura {
382 1.1 takemura struct vrkiu_softc *sc = (struct vrkiu_softc *)self;
383 1.1 takemura struct vrip_attach_args *va = aux;
384 1.1.1.1.6.1 wrstuden struct wskbddev_attach_args wa;
385 1.1.1.1.6.1 wrstuden int isconsole;
386 1.1 takemura
387 1.1 takemura bus_space_tag_t iot = va->va_iot;
388 1.1 takemura bus_space_handle_t ioh;
389 1.1 takemura
390 1.1 takemura if (bus_space_map(iot, va->va_addr, 1, 0, &ioh)) {
391 1.1 takemura printf(": can't map bus space\n");
392 1.1 takemura return;
393 1.1 takemura }
394 1.1 takemura
395 1.1.1.1.6.1 wrstuden isconsole = vrkiu_is_console(iot, ioh);
396 1.1.1.1.6.1 wrstuden if (isconsole) {
397 1.1.1.1.6.1 wrstuden sc->sc_chip = vrkiu_consdata;
398 1.1.1.1.6.1 wrstuden } else {
399 1.1.1.1.6.1 wrstuden sc->sc_chip = &sc->sc_chip_body;
400 1.1.1.1.6.1 wrstuden vrkiu_init(sc->sc_chip, iot, ioh);
401 1.1.1.1.6.1 wrstuden }
402 1.1.1.1.6.1 wrstuden sc->sc_chip->kc_sc = sc;
403 1.1 takemura
404 1.1 takemura if (!(sc->sc_handler =
405 1.1 takemura vrip_intr_establish(va->va_vc, va->va_intr, IPL_TTY,
406 1.1 takemura vrkiu_intr, sc))) {
407 1.1 takemura printf (": can't map interrupt line.\n");
408 1.1 takemura return;
409 1.1 takemura }
410 1.1 takemura /* Level2 register setting */
411 1.1 takemura vrip_intr_setmask2(va->va_vc, sc->sc_handler, KIUINT_KDATRDY, 1);
412 1.1 takemura
413 1.1 takemura printf("\n");
414 1.1.1.1.6.1 wrstuden
415 1.1.1.1.6.1 wrstuden if (platid_match(&platid, &platid_mask_MACH_NEC_MCR_520A)) {
416 1.1.1.1.6.1 wrstuden keytrans = mobilepro_keytrans;
417 1.1.1.1.6.1 wrstuden #if !defined(PCKBD_LAYOUT)
418 1.1.1.1.6.1 wrstuden vrkiu_keymapdata.layout = KB_US;
419 1.1.1.1.6.1 wrstuden #endif
420 1.1.1.1.6.1 wrstuden } else if (platid_match(&platid, &platid_mask_MACH_NEC_MCR_500A)) {
421 1.1.1.1.6.1 wrstuden keytrans = mobilepro750c_keytrans;
422 1.1.1.1.6.1 wrstuden #if !defined(PCKBD_LAYOUT)
423 1.1.1.1.6.1 wrstuden vrkiu_keymapdata.layout = KB_US;
424 1.1.1.1.6.1 wrstuden #endif
425 1.1.1.1.6.1 wrstuden } else if (platid_match(&platid, &platid_mask_MACH_NEC_MCR_700A)) {
426 1.1.1.1.6.1 wrstuden keytrans = mobilepro_keytrans;
427 1.1.1.1.6.1 wrstuden #if !defined(PCKBD_LAYOUT)
428 1.1.1.1.6.1 wrstuden vrkiu_keymapdata.layout = KB_US;
429 1.1.1.1.6.1 wrstuden #endif
430 1.1.1.1.6.1 wrstuden } else if (platid_match(&platid, &platid_mask_MACH_NEC_MCR)) {
431 1.1.1.1.6.1 wrstuden keytrans = mcr_jp_keytrans;
432 1.1.1.1.6.1 wrstuden #if !defined(PCKBD_LAYOUT)
433 1.1.1.1.6.1 wrstuden vrkiu_keymapdata.layout = KB_JP;
434 1.1.1.1.6.1 wrstuden #endif
435 1.1.1.1.6.1 wrstuden } else if (platid_match(&platid, &platid_mask_MACH_IBM_WORKPAD_Z50)) {
436 1.1.1.1.6.1 wrstuden keytrans = z50_keytrans;
437 1.1.1.1.6.1 wrstuden #if !defined(PCKBD_LAYOUT)
438 1.1.1.1.6.1 wrstuden vrkiu_keymapdata.layout = KB_US;
439 1.1.1.1.6.1 wrstuden #endif
440 1.1.1.1.6.1 wrstuden } else if (platid_match(&platid, &platid_mask_MACH_SHARP_TRIPAD)) {
441 1.1.1.1.6.1 wrstuden keytrans = tripad_keytrans;
442 1.1.1.1.6.1 wrstuden #if !defined(PCKBD_LAYOUT)
443 1.1.1.1.6.1 wrstuden vrkiu_keymapdata.layout = KB_JP;
444 1.1.1.1.6.1 wrstuden #endif
445 1.1.1.1.6.1 wrstuden } else if (platid_match(&platid, &platid_mask_MACH_NEC_MCCS)) {
446 1.1.1.1.6.1 wrstuden keytrans = mccs_keytrans;
447 1.1.1.1.6.1 wrstuden #if !defined(PCKBD_LAYOUT)
448 1.1.1.1.6.1 wrstuden vrkiu_keymapdata.layout = KB_JP;
449 1.1.1.1.6.1 wrstuden #endif
450 1.1.1.1.6.1 wrstuden } else if (platid_match(&platid, &platid_mask_MACH_FUJITSU_INTERTOP)) {
451 1.1.1.1.6.1 wrstuden keytrans = intertop_keytrans;
452 1.1.1.1.6.1 wrstuden #if !defined(PCKBD_LAYOUT)
453 1.1.1.1.6.1 wrstuden vrkiu_keymapdata.layout = KB_JP;
454 1.1.1.1.6.1 wrstuden #endif
455 1.1.1.1.6.1 wrstuden }
456 1.1.1.1.6.1 wrstuden wa.console = isconsole;
457 1.1.1.1.6.1 wrstuden wa.keymap = &vrkiu_keymapdata;
458 1.1.1.1.6.1 wrstuden wa.accessops = &vrkiu_accessops;
459 1.1.1.1.6.1 wrstuden wa.accesscookie = sc;
460 1.1.1.1.6.1 wrstuden
461 1.1.1.1.6.1 wrstuden sc->sc_wskbddev = config_found(self, &wa, wskbddevprint);
462 1.1 takemura }
463 1.1 takemura
464 1.1 takemura int
465 1.1 takemura vrkiu_intr(arg)
466 1.1 takemura void *arg;
467 1.1 takemura {
468 1.1 takemura struct vrkiu_softc *sc = arg;
469 1.1 takemura
470 1.1.1.1.6.1 wrstuden /* When key scan finisshed, this entry is called. */
471 1.1.1.1.6.1 wrstuden DPRINTF(("%s(%d): vrkiu_intr: %d\n",
472 1.1.1.1.6.1 wrstuden __FILE__, __LINE__,
473 1.1.1.1.6.1 wrstuden vrkiu_read(sc->sc_chip, KIUINT) & 7));
474 1.1.1.1.6.1 wrstuden
475 1.1.1.1.6.1 wrstuden /*
476 1.1.1.1.6.1 wrstuden * First, we must clear the interrupt register because
477 1.1.1.1.6.1 wrstuden * detect_key() may takes long time if a bitmap screen
478 1.1.1.1.6.1 wrstuden * scrolls up and it makes us to miss some key release
479 1.1.1.1.6.1 wrstuden * event.
480 1.1.1.1.6.1 wrstuden */
481 1.1.1.1.6.1 wrstuden vrkiu_write(sc->sc_chip, KIUINT, 0x7); /* Clear all interrupt */
482 1.1.1.1.6.1 wrstuden detect_key(sc->sc_chip);
483 1.1 takemura
484 1.1 takemura return 0;
485 1.1 takemura }
486 1.1 takemura
487 1.1 takemura static void
488 1.1.1.1.6.1 wrstuden detect_key(chip)
489 1.1.1.1.6.1 wrstuden struct vrkiu_chip* chip;
490 1.1 takemura {
491 1.1.1.1.6.1 wrstuden int i, j, modified, mask;
492 1.1.1.1.6.1 wrstuden unsigned short scandata[KIU_NSCANLINE/2];
493 1.1 takemura
494 1.1 takemura for (i = 0; i < KIU_NSCANLINE / 2; i++) {
495 1.1.1.1.6.1 wrstuden scandata[i] = vrkiu_read(chip, KIUDATP + i * 2);
496 1.1 takemura }
497 1.1 takemura
498 1.1.1.1.6.1 wrstuden DPRINTF(("%s(%d): detect_key():", __FILE__, __LINE__));
499 1.1 takemura
500 1.1.1.1.6.1 wrstuden if (chip->kc_polling) {
501 1.1.1.1.6.1 wrstuden chip->kc_type = WSCONS_EVENT_ALL_KEYS_UP;
502 1.1.1.1.6.1 wrstuden }
503 1.1.1.1.6.1 wrstuden
504 1.1.1.1.6.1 wrstuden for (i = 0; i < KIU_NSCANLINE / 2; i++) {
505 1.1.1.1.6.1 wrstuden modified = scandata[i] ^ chip->kc_scandata[i];
506 1.1.1.1.6.1 wrstuden mask = 1;
507 1.1.1.1.6.1 wrstuden for (j = 0; j < 16; j++, mask <<= 1) {
508 1.1.1.1.6.1 wrstuden /* XXX: The order of keys can be a problem.
509 1.1.1.1.6.1 wrstuden If CTRL and normal key are pushed simultaneously,
510 1.1.1.1.6.1 wrstuden normal key can be entered in queue first.
511 1.1.1.1.6.1 wrstuden Same problem would occur in key break. */
512 1.1.1.1.6.1 wrstuden if (modified & mask) {
513 1.1.1.1.6.1 wrstuden int key, type;
514 1.1.1.1.6.1 wrstuden key = i * 16 + j;
515 1.1.1.1.6.1 wrstuden if (keytrans[key] == UNK) {
516 1.1.1.1.6.1 wrstuden printf("vrkiu: Unknown scan code 0x%02x\n", key);
517 1.1.1.1.6.1 wrstuden continue;
518 1.1.1.1.6.1 wrstuden } else if (keytrans[key] == IGN) {
519 1.1.1.1.6.1 wrstuden continue;
520 1.1.1.1.6.1 wrstuden }
521 1.1.1.1.6.1 wrstuden type = (scandata[i] & mask) ?
522 1.1.1.1.6.1 wrstuden WSCONS_EVENT_KEY_DOWN :
523 1.1.1.1.6.1 wrstuden WSCONS_EVENT_KEY_UP;
524 1.1.1.1.6.1 wrstuden DPRINTF(("(%d,%d)=%s%d ", i, j,
525 1.1.1.1.6.1 wrstuden (scandata[i] & mask) ? "v" : "^",
526 1.1.1.1.6.1 wrstuden keytrans[key]));
527 1.1.1.1.6.1 wrstuden if (chip->kc_polling) {
528 1.1.1.1.6.1 wrstuden chip->kc_type = type;
529 1.1.1.1.6.1 wrstuden chip->kc_data = keytrans[key];
530 1.1.1.1.6.1 wrstuden } else {
531 1.1.1.1.6.1 wrstuden wskbd_input(chip->kc_sc->sc_wskbddev,
532 1.1.1.1.6.1 wrstuden type,
533 1.1.1.1.6.1 wrstuden keytrans[key]);
534 1.1.1.1.6.1 wrstuden }
535 1.1 takemura }
536 1.1 takemura }
537 1.1.1.1.6.1 wrstuden chip->kc_scandata[i] = scandata[i];
538 1.1 takemura }
539 1.1.1.1.6.1 wrstuden DPRINTF(("\n"));
540 1.1 takemura }
541 1.1 takemura
542 1.1 takemura /* called from biconsdev.c */
543 1.1 takemura int
544 1.1 takemura vrkiu_getc()
545 1.1 takemura {
546 1.1 takemura int ret;
547 1.1 takemura
548 1.1 takemura if (the_vrkiu == NULL) {
549 1.1 takemura return 0; /* XXX */
550 1.1 takemura }
551 1.1 takemura
552 1.1 takemura while (the_vrkiu->keybuftail == the_vrkiu->keybufhead) {
553 1.1.1.1.6.1 wrstuden detect_key(vrkiu_consdata);
554 1.1 takemura }
555 1.1 takemura ret = the_vrkiu->keybuf[the_vrkiu->keybuftail++];
556 1.1 takemura if (the_vrkiu->keybuftail >= NKEYBUF) {
557 1.1 takemura the_vrkiu->keybuftail = 0;
558 1.1 takemura }
559 1.1 takemura return ret;
560 1.1 takemura }
561 1.1 takemura
562 1.1.1.1.6.1 wrstuden int
563 1.1.1.1.6.1 wrstuden vrkiu_enable(scx, on)
564 1.1.1.1.6.1 wrstuden void *scx;
565 1.1.1.1.6.1 wrstuden int on;
566 1.1.1.1.6.1 wrstuden {
567 1.1.1.1.6.1 wrstuden struct vrkiu_softc *sc = scx;
568 1.1.1.1.6.1 wrstuden
569 1.1.1.1.6.1 wrstuden if (on) {
570 1.1.1.1.6.1 wrstuden if (sc->sc_enabled)
571 1.1.1.1.6.1 wrstuden return (EBUSY);
572 1.1.1.1.6.1 wrstuden sc->sc_enabled = 1;
573 1.1.1.1.6.1 wrstuden } else {
574 1.1.1.1.6.1 wrstuden if (sc->sc_chip == vrkiu_consdata)
575 1.1.1.1.6.1 wrstuden return (EBUSY);
576 1.1.1.1.6.1 wrstuden sc->sc_enabled = 0;
577 1.1.1.1.6.1 wrstuden }
578 1.1.1.1.6.1 wrstuden
579 1.1.1.1.6.1 wrstuden return (0);
580 1.1.1.1.6.1 wrstuden }
581 1.1.1.1.6.1 wrstuden
582 1.1.1.1.6.1 wrstuden void
583 1.1.1.1.6.1 wrstuden vrkiu_set_leds(scx, leds)
584 1.1.1.1.6.1 wrstuden void *scx;
585 1.1.1.1.6.1 wrstuden int leds;
586 1.1.1.1.6.1 wrstuden {
587 1.1.1.1.6.1 wrstuden /*struct pckbd_softc *sc = scx;
588 1.1.1.1.6.1 wrstuden */
589 1.1.1.1.6.1 wrstuden
590 1.1.1.1.6.1 wrstuden DPRINTF(("%s(%d): vrkiu_set_leds() not implemented\n",
591 1.1.1.1.6.1 wrstuden __FILE__, __LINE__));
592 1.1.1.1.6.1 wrstuden }
593 1.1.1.1.6.1 wrstuden
594 1.1.1.1.6.1 wrstuden int
595 1.1.1.1.6.1 wrstuden vrkiu_ioctl(scx, cmd, data, flag, p)
596 1.1.1.1.6.1 wrstuden void *scx;
597 1.1.1.1.6.1 wrstuden u_long cmd;
598 1.1.1.1.6.1 wrstuden caddr_t data;
599 1.1.1.1.6.1 wrstuden int flag;
600 1.1.1.1.6.1 wrstuden struct proc *p;
601 1.1.1.1.6.1 wrstuden {
602 1.1.1.1.6.1 wrstuden /*struct vrkiu_softc *sc = scx;
603 1.1.1.1.6.1 wrstuden */
604 1.1.1.1.6.1 wrstuden
605 1.1.1.1.6.1 wrstuden switch (cmd) {
606 1.1.1.1.6.1 wrstuden case WSKBDIO_GTYPE:
607 1.1.1.1.6.1 wrstuden /*
608 1.1.1.1.6.1 wrstuden * XXX, fix me !
609 1.1.1.1.6.1 wrstuden */
610 1.1.1.1.6.1 wrstuden *(int *)data = WSKBD_TYPE_PC_XT;
611 1.1.1.1.6.1 wrstuden return 0;
612 1.1.1.1.6.1 wrstuden case WSKBDIO_SETLEDS:
613 1.1.1.1.6.1 wrstuden DPRINTF(("%s(%d): no LED\n", __FILE__, __LINE__));
614 1.1.1.1.6.1 wrstuden return 0;
615 1.1.1.1.6.1 wrstuden case WSKBDIO_GETLEDS:
616 1.1.1.1.6.1 wrstuden DPRINTF(("%s(%d): no LED\n", __FILE__, __LINE__));
617 1.1.1.1.6.1 wrstuden *(int *)data = 0;
618 1.1.1.1.6.1 wrstuden return (0);
619 1.1.1.1.6.1 wrstuden }
620 1.1.1.1.6.1 wrstuden return -1;
621 1.1.1.1.6.1 wrstuden }
622 1.1.1.1.6.1 wrstuden
623 1.1.1.1.6.1 wrstuden /*
624 1.1.1.1.6.1 wrstuden * console support routines
625 1.1.1.1.6.1 wrstuden */
626 1.1.1.1.6.1 wrstuden int
627 1.1.1.1.6.1 wrstuden vrkiu_cnattach(iot, iobase)
628 1.1.1.1.6.1 wrstuden bus_space_tag_t iot;
629 1.1.1.1.6.1 wrstuden int iobase;
630 1.1.1.1.6.1 wrstuden {
631 1.1.1.1.6.1 wrstuden static struct vrkiu_chip vrkiu_consdata_body;
632 1.1.1.1.6.1 wrstuden bus_space_handle_t ioh;
633 1.1.1.1.6.1 wrstuden
634 1.1.1.1.6.1 wrstuden if (vrkiu_consdata) {
635 1.1.1.1.6.1 wrstuden panic("vrkiu is already attached as the console");
636 1.1.1.1.6.1 wrstuden }
637 1.1.1.1.6.1 wrstuden if (bus_space_map(iot, iobase, 1, 0, &ioh)) {
638 1.1.1.1.6.1 wrstuden printf("%s(%d): can't map bus space\n", __FILE__, __LINE__);
639 1.1.1.1.6.1 wrstuden return -1;
640 1.1.1.1.6.1 wrstuden }
641 1.1.1.1.6.1 wrstuden
642 1.1.1.1.6.1 wrstuden if (vrkiu_init(&vrkiu_consdata_body, iot, ioh) != 0) {
643 1.1.1.1.6.1 wrstuden DPRINTF(("%s(%d): vrkiu_init() failed\n", __FILE__, __LINE__));
644 1.1.1.1.6.1 wrstuden return -1;
645 1.1.1.1.6.1 wrstuden }
646 1.1.1.1.6.1 wrstuden vrkiu_consdata = &vrkiu_consdata_body;
647 1.1.1.1.6.1 wrstuden
648 1.1.1.1.6.1 wrstuden wskbd_cnattach(&vrkiu_consops, vrkiu_consdata, &vrkiu_keymapdata);
649 1.1.1.1.6.1 wrstuden
650 1.1.1.1.6.1 wrstuden return (0);
651 1.1.1.1.6.1 wrstuden }
652 1.1.1.1.6.1 wrstuden
653 1.1.1.1.6.1 wrstuden void
654 1.1.1.1.6.1 wrstuden vrkiu_cngetc(chipx, type, data)
655 1.1.1.1.6.1 wrstuden void *chipx;
656 1.1.1.1.6.1 wrstuden u_int *type;
657 1.1.1.1.6.1 wrstuden int *data;
658 1.1.1.1.6.1 wrstuden {
659 1.1.1.1.6.1 wrstuden struct vrkiu_chip* chip = chipx;
660 1.1.1.1.6.1 wrstuden int s;
661 1.1.1.1.6.1 wrstuden
662 1.1.1.1.6.1 wrstuden if (!chip->kc_polling) {
663 1.1.1.1.6.1 wrstuden printf("%s(%d): kiu is not polled\n", __FILE__, __LINE__);
664 1.1.1.1.6.1 wrstuden while (1);
665 1.1.1.1.6.1 wrstuden }
666 1.1.1.1.6.1 wrstuden
667 1.1.1.1.6.1 wrstuden s = splimp();
668 1.1.1.1.6.1 wrstuden if (chip->kc_type == WSCONS_EVENT_ALL_KEYS_UP) {
669 1.1.1.1.6.1 wrstuden detect_key(chip);
670 1.1.1.1.6.1 wrstuden }
671 1.1.1.1.6.1 wrstuden *type = chip->kc_type;
672 1.1.1.1.6.1 wrstuden *data = chip->kc_data;
673 1.1.1.1.6.1 wrstuden chip->kc_type = WSCONS_EVENT_ALL_KEYS_UP;
674 1.1.1.1.6.1 wrstuden splx(s);
675 1.1.1.1.6.1 wrstuden }
676 1.1.1.1.6.1 wrstuden
677 1.1.1.1.6.1 wrstuden void
678 1.1.1.1.6.1 wrstuden vrkiu_cnpollc(chipx, on)
679 1.1.1.1.6.1 wrstuden void *chipx;
680 1.1.1.1.6.1 wrstuden int on;
681 1.1.1.1.6.1 wrstuden {
682 1.1.1.1.6.1 wrstuden struct vrkiu_chip* chip = chipx;
683 1.1.1.1.6.1 wrstuden int s = splimp();
684 1.1.1.1.6.1 wrstuden
685 1.1.1.1.6.1 wrstuden chip->kc_polling = on;
686 1.1.1.1.6.1 wrstuden
687 1.1.1.1.6.1 wrstuden splx(s);
688 1.1.1.1.6.1 wrstuden
689 1.1.1.1.6.1 wrstuden DPRINTF(("%s(%d): vrkiu polling %s\n",
690 1.1.1.1.6.1 wrstuden __FILE__, __LINE__, on ? "ON" : "OFF"));
691 1.1.1.1.6.1 wrstuden }
692