smdk2410_kbd.c revision 1.4.20.1 1 1.4.20.1 matt /* $NetBSD: smdk2410_kbd.c,v 1.4.20.1 2008/01/09 01:45:48 matt Exp $ */
2 1.1 bsh
3 1.1 bsh /*
4 1.1 bsh * Copyright (c) 2004 Genetec Corporation. All rights reserved.
5 1.1 bsh * Written by Hiroyuki Bessho for Genetec Corporation.
6 1.1 bsh *
7 1.1 bsh * Redistribution and use in source and binary forms, with or without
8 1.1 bsh * modification, are permitted provided that the following conditions
9 1.1 bsh * are met:
10 1.1 bsh * 1. Redistributions of source code must retain the above copyright
11 1.1 bsh * notice, this list of conditions and the following disclaimer.
12 1.1 bsh * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 bsh * notice, this list of conditions and the following disclaimer in the
14 1.1 bsh * documentation and/or other materials provided with the distribution.
15 1.1 bsh * 3. The name of Genetec Corporation may not be used to endorse or
16 1.1 bsh * promote products derived from this software without specific prior
17 1.1 bsh * written permission.
18 1.1 bsh *
19 1.1 bsh * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
20 1.1 bsh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 bsh * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 bsh * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
23 1.1 bsh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 bsh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 bsh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 bsh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 bsh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 bsh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 bsh * POSSIBILITY OF SUCH DAMAGE.
30 1.1 bsh */
31 1.1 bsh
32 1.1 bsh /*
33 1.1 bsh * Support SMDK2410's keyboard.
34 1.1 bsh *
35 1.1 bsh * On-board keyboard controller is Semtech SPICoder SA01.
36 1.1 bsh * (http://www.semtech.com/pdf/doc5-spi-sa01-ds.pdf)
37 1.1 bsh *
38 1.1 bsh * The controller is connected to SPI1.
39 1.1 bsh * _ATN signal from the SPICoder is connected to EINT1.
40 1.1 bsh */
41 1.1 bsh
42 1.1 bsh #include <sys/cdefs.h>
43 1.4.20.1 matt __KERNEL_RCSID(0, "$NetBSD: smdk2410_kbd.c,v 1.4.20.1 2008/01/09 01:45:48 matt Exp $");
44 1.1 bsh
45 1.1 bsh #include <sys/param.h>
46 1.1 bsh #include <sys/systm.h>
47 1.1 bsh #include <sys/conf.h>
48 1.1 bsh
49 1.1 bsh #include <machine/bus.h>
50 1.1 bsh #include <machine/cpu.h>
51 1.1 bsh
52 1.1 bsh #include <dev/wscons/wsconsio.h>
53 1.1 bsh #include <dev/wscons/wskbdvar.h>
54 1.1 bsh #include <dev/wscons/wsksymdef.h>
55 1.1 bsh #include <dev/wscons/wsksymvar.h>
56 1.1 bsh
57 1.1 bsh #include <arm/s3c2xx0/s3c24x0var.h>
58 1.1 bsh #include <arm/s3c2xx0/s3c24x0reg.h>
59 1.1 bsh #include <arm/s3c2xx0/s3c2410reg.h>
60 1.1 bsh
61 1.1 bsh #include <arm/s3c2xx0/s3c24x0_spi.h>
62 1.1 bsh
63 1.1 bsh #include "locators.h"
64 1.1 bsh
65 1.1 bsh /*
66 1.1 bsh * Keyboard driver for Semtech keyboard controller on SMDK2410.
67 1.1 bsh *
68 1.1 bsh * There are several keycoder products from Semtech.
69 1.1 bsh * This driver supports SPICoder(R) SA01 (UR5HCSPI-SA01) only.
70 1.1 bsh *
71 1.1 bsh * See http://www.semtech.com/products/ for detail.
72 1.1 bsh */
73 1.1 bsh
74 1.1 bsh /*
75 1.1 bsh * Commands/responce
76 1.1 bsh */
77 1.1 bsh #define KCDR_INITIALIZE 0xa0 /* Initialize request */
78 1.1 bsh #define KCDR_INITCOMP 0xa1 /* Initialize complete */
79 1.1 bsh #define KCDR_HEARTBEAT 0xa2 /* Heaartbeat request/response */
80 1.1 bsh #define KCDR_IDENTIFY 0xf2 /* Identification request/response */
81 1.1 bsh #define KCDR_LEDSTATUS 0xa3 /* LED status request/report */
82 1.1 bsh #define KCDR_LEDMODIFY 0xa6 /* LED mode modify */
83 1.1 bsh #define KCDR_RESENTREQ 0xa5 /* Re-send request upon error */
84 1.1 bsh #define KCDR_IOMODE 0xa7 /* Input/output mode modify/report */
85 1.1 bsh #define KCDR_OUTPUT 0xa8 /* output to GPIO0 pin */
86 1.1 bsh #define KCDR_SETWAKEUP 0xa9 /* define wake-up keys */
87 1.1 bsh
88 1.1 bsh #define KCDR_CONTROL 0x80 /* Commands from KeyCorder to Host starts with
89 1.1 bsh this code. */
90 1.1 bsh #define KCDR_ESC 0x1b /* Commands from host to KeyCorder starts with
91 1.1 bsh this code. */
92 1.1 bsh
93 1.1 bsh /*
94 1.1 bsh * GPIO ports
95 1.1 bsh */
96 1.1 bsh #define SSKBD_WUP 0 /* nWUP = GPB0 */
97 1.1 bsh #define SSKBD_SS 6 /* nSS = GPB6 */
98 1.1 bsh
99 1.1 bsh /*
100 1.1 bsh * keymap
101 1.1 bsh */
102 1.1 bsh
103 1.1 bsh #define _(col,row) KS_KEYCODE((col)*8+(row))
104 1.1 bsh
105 1.1 bsh static const keysym_t sskbd_keydesc_0[] = {
106 1.1 bsh /* _(col,row) normal shifted */
107 1.1 bsh _(0,0), KS_Alt_L, KS_Alt_L,
108 1.1 bsh
109 1.1 bsh _(1,0), KS_grave, KS_asciitilde,
110 1.1 bsh _(1,1), KS_backslash, KS_bar,
111 1.1 bsh _(1,2), KS_Tab, KS_Tab,
112 1.1 bsh _(1,3), KS_z, KS_Z,
113 1.1 bsh _(1,4), KS_a, KS_A,
114 1.1 bsh _(1,5), KS_x, KS_X,
115 1.1 bsh
116 1.1 bsh _(2,1), KS_Shift_L, KS_Shift_L,
117 1.1 bsh
118 1.1 bsh _(3,0), KS_Control_L, KS_Control_L,
119 1.1 bsh
120 1.1 bsh _(4,0), KS_Meta_L, KS_Meta_L,
121 1.1 bsh
122 1.1 bsh _(5,0), KS_Escape, KS_Escape,
123 1.1 bsh _(5,1), KS_Delete, KS_Delete,
124 1.1 bsh _(5,2), KS_q, KS_Q,
125 1.1 bsh _(5,3), KS_Caps_Lock, KS_Caps_Lock,
126 1.1 bsh _(5,4), KS_s, KS_S,
127 1.1 bsh _(5,5), KS_c, KS_C,
128 1.1 bsh _(5,6), KS_3, KS_numbersign,
129 1.1 bsh
130 1.1 bsh _(6,0), KS_1, KS_exclam,
131 1.1 bsh _(6,2), KS_w, KS_W,
132 1.1 bsh _(6,4), KS_d, KS_D,
133 1.1 bsh _(6,5), KS_v, KS_V,
134 1.1 bsh _(6,6), KS_4, KS_dollar,
135 1.1 bsh
136 1.1 bsh _(7,0), KS_2, KS_at,
137 1.1 bsh _(7,1), KS_t, KS_T,
138 1.1 bsh _(7,2), KS_e, KS_E,
139 1.1 bsh _(7,4), KS_f, KS_F,
140 1.1 bsh _(7,5), KS_b, KS_B,
141 1.1 bsh _(7,6), KS_5, KS_percent,
142 1.1 bsh
143 1.1 bsh _(8,0), KS_9, KS_parenleft,
144 1.1 bsh _(8,1), KS_y, KS_Y,
145 1.1 bsh _(8,2), KS_r, KS_R,
146 1.1 bsh _(8,3), KS_k, KS_K,
147 1.1 bsh _(8,4), KS_g, KS_G,
148 1.1 bsh _(8,5), KS_n, KS_N,
149 1.1 bsh _(8,6), KS_6, KS_asciicircum,
150 1.1 bsh
151 1.1 bsh _(9,0), KS_0, KS_parenright,
152 1.1 bsh _(9,1), KS_u, KS_U,
153 1.1 bsh _(9,2), KS_o, KS_O,
154 1.1 bsh _(9,3), KS_l, KS_L,
155 1.1 bsh _(9,4), KS_h, KS_H,
156 1.1 bsh _(9,5), KS_m, KS_M,
157 1.1 bsh _(9,6), KS_7, KS_ampersand,
158 1.1 bsh
159 1.1 bsh _(10,0), KS_minus, KS_underscore,
160 1.1 bsh _(10,1), KS_i, KS_I,
161 1.1 bsh _(10,2), KS_p, KS_P,
162 1.1 bsh _(10,3), KS_l, KS_L,
163 1.1 bsh _(10,4), KS_j, KS_J,
164 1.1 bsh _(10,5), KS_comma, KS_less,
165 1.1 bsh _(10,6), KS_8, KS_asterisk,
166 1.1 bsh
167 1.1 bsh _(11,0), KS_equal, KS_plus,
168 1.1 bsh _(11,1), KS_Return, KS_Return,
169 1.1 bsh _(11,2), KS_bracketleft, KS_braceleft,
170 1.1 bsh _(11,3), KS_apostrophe, KS_quotedbl,
171 1.1 bsh _(11,4), KS_slash, KS_question,
172 1.1 bsh _(11,5), KS_period, KS_greater,
173 1.1 bsh _(11,6), KS_Menu, KS_Menu, /* Prog key */
174 1.1 bsh
175 1.1 bsh _(12,1), KS_Shift_R, KS_Shift_R,
176 1.1 bsh
177 1.1 bsh _(13,0), KS_BackSpace, KS_BackSpace,
178 1.1 bsh _(13,1), KS_Down, KS_Next,
179 1.1 bsh _(13,2), KS_bracketright, KS_braceright,
180 1.1 bsh _(13,3), KS_Up, KS_Prior,
181 1.1 bsh _(13,4), KS_Left, KS_Home,
182 1.1 bsh _(13,5), KS_space, KS_space,
183 1.1 bsh _(13,6), KS_Right, KS_End,
184 1.1 bsh };
185 1.1 bsh
186 1.1 bsh #define KBD_MAP(name, base, map) \
187 1.1 bsh { name, base, sizeof(map)/sizeof(keysym_t), map }
188 1.1 bsh
189 1.1 bsh static const struct wscons_keydesc sskbd_keydesctab[] = {
190 1.1 bsh KBD_MAP(KB_MACHDEP, 0, sskbd_keydesc_0),
191 1.1 bsh {0, 0, 0, 0}
192 1.1 bsh };
193 1.1 bsh
194 1.1 bsh const struct wskbd_mapdata sskbd_keymapdata = {
195 1.1 bsh sskbd_keydesctab,
196 1.1 bsh KB_MACHDEP,
197 1.1 bsh };
198 1.1 bsh
199 1.1 bsh
200 1.1 bsh /*
201 1.1 bsh * SMDK2410 keyboard driver.
202 1.1 bsh */
203 1.1 bsh struct sskbd_softc {
204 1.1 bsh struct device dev;
205 1.1 bsh
206 1.1 bsh struct device *wskbddev;
207 1.1 bsh void *atn_ih; /* interrupt handler for nATN */
208 1.1 bsh void *spi_ih; /* interrupt handler for SPI rx */
209 1.1 bsh
210 1.1 bsh void *soft_ih; /* soft interrupt */
211 1.1 bsh
212 1.1 bsh bus_space_tag_t iot;
213 1.1 bsh bus_space_handle_t ioh;
214 1.1 bsh bus_space_handle_t gpioh;
215 1.1 bsh
216 1.1 bsh #define RING_SIZE 16 /* must be power of 2 */
217 1.1 bsh short inptr, outptr;
218 1.1 bsh unsigned char ring[RING_SIZE];
219 1.1 bsh #define advance_ring_ptr(p) ((p+1) & ~RING_SIZE)
220 1.1 bsh
221 1.1 bsh short reading, enable;
222 1.1 bsh };
223 1.1 bsh
224 1.1 bsh
225 1.1 bsh int sskbd_match(struct device *, struct cfdata *, void *);
226 1.1 bsh void sskbd_attach(struct device *, struct device *, void *);
227 1.1 bsh
228 1.1 bsh CFATTACH_DECL(sskbd, sizeof(struct sskbd_softc),
229 1.1 bsh sskbd_match, sskbd_attach, NULL, NULL);
230 1.1 bsh
231 1.1 bsh static int sskbd_enable(void *, int);
232 1.1 bsh static void sskbd_set_leds(void *, int);
233 1.4 christos static int sskbd_ioctl(void *, u_long, void *, int, struct lwp *);
234 1.1 bsh static int sskbd_atn_intr(void *);
235 1.1 bsh static int sskbd_spi_intr(void *);
236 1.1 bsh static void sskbd_soft_intr(void *);
237 1.1 bsh
238 1.1 bsh const struct wskbd_accessops sskbd_accessops = {
239 1.1 bsh sskbd_enable,
240 1.1 bsh sskbd_set_leds,
241 1.1 bsh sskbd_ioctl,
242 1.1 bsh };
243 1.1 bsh
244 1.1 bsh #if 0
245 1.1 bsh void sskbd_cngetc(void *, u_int *, int *);
246 1.1 bsh void sskbd_cnpollc(void *, int);
247 1.1 bsh void sskbd_cnbell(void *, u_int, u_int, u_int);
248 1.1 bsh
249 1.1 bsh const struct wskbd_consops sskbd_consops = {
250 1.1 bsh sskbd_cngetc,
251 1.1 bsh sskbd_cnpollc,
252 1.1 bsh sskbd_cnbell,
253 1.1 bsh };
254 1.1 bsh #endif
255 1.1 bsh
256 1.1 bsh int
257 1.1 bsh sskbd_match(struct device *parent, struct cfdata *cf, void *aux)
258 1.1 bsh {
259 1.1 bsh return 1;
260 1.1 bsh }
261 1.1 bsh
262 1.1 bsh void
263 1.1 bsh sskbd_attach(struct device *parent, struct device *self, void *aux)
264 1.1 bsh {
265 1.1 bsh struct sskbd_softc *sc = (void *)self;
266 1.1 bsh struct ssspi_attach_args *spia = aux;
267 1.1 bsh uint32_t reg;
268 1.1 bsh bus_space_handle_t gpioh;
269 1.1 bsh bus_space_tag_t iot;
270 1.1 bsh struct wskbddev_attach_args a;
271 1.1 bsh
272 1.1 bsh aprint_normal("\n");
273 1.1 bsh
274 1.1 bsh sc->iot = iot = spia->spia_iot;
275 1.1 bsh sc->ioh = spia->spia_ioh;
276 1.1 bsh sc->gpioh = gpioh = spia->spia_gpioh;
277 1.1 bsh
278 1.1 bsh /* enable pullup register for MISO */
279 1.1 bsh reg = bus_space_read_2(iot, gpioh, GPIO_PGUP);
280 1.1 bsh bus_space_write_2(iot, gpioh, GPIO_PGUP, reg & ~(1<<5));
281 1.1 bsh
282 1.1 bsh /* nSS and wakeup */
283 1.1 bsh bus_space_write_2(iot, gpioh, GPIO_PBDAT,
284 1.1 bsh (1<<SSKBD_SS) | (1<<SSKBD_WUP) |
285 1.1 bsh bus_space_read_2(iot, gpioh, GPIO_PBDAT));
286 1.1 bsh reg = bus_space_read_4(iot, gpioh, GPIO_PBCON);
287 1.1 bsh reg = GPIO_SET_FUNC(reg, SSKBD_WUP, PCON_OUTPUT);
288 1.1 bsh reg = GPIO_SET_FUNC(reg, SSKBD_SS, PCON_OUTPUT);
289 1.1 bsh bus_space_write_4(iot, gpioh, GPIO_PBCON, reg);
290 1.1 bsh
291 1.1 bsh /* nATN input to EINT1 */
292 1.1 bsh reg = bus_space_read_4(iot, gpioh, GPIO_PFCON);
293 1.1 bsh reg = GPIO_SET_FUNC(reg, 1, PCON_ALTFUN);
294 1.1 bsh bus_space_write_4(iot, gpioh, GPIO_PFCON, reg);
295 1.1 bsh
296 1.1 bsh #if 0 /* Controller doesn't seem to respond to this. */
297 1.1 bsh
298 1.1 bsh /* wakeup pulse */
299 1.1 bsh reg = bus_space_read_4(iot, gpioh, GPIO_PBDAT);
300 1.1 bsh reg &= ~(1<<SSKBD_WUP);
301 1.1 bsh bus_space_write_4(iot, gpioh, GPIO_PBDAT, reg);
302 1.1 bsh delay(100);
303 1.1 bsh reg |= (1<<SSKBD_WUP);
304 1.1 bsh bus_space_write_4(iot, gpioh, GPIO_PBDAT, reg);
305 1.1 bsh
306 1.1 bsh delay(1000);
307 1.1 bsh
308 1.1 bsh /* Send initialize command. */
309 1.1 bsh sskbd_send(sc, KCDR_ESC);
310 1.1 bsh sskbd_send(sc, KCDR_INITIALIZE);
311 1.1 bsh sskbd_send(sc, 0x7b);
312 1.1 bsh #endif
313 1.1 bsh
314 1.1 bsh sc->inptr = sc->outptr = 0;
315 1.1 bsh sc->reading = sc->enable = 0;
316 1.1 bsh
317 1.1 bsh sc->atn_ih = s3c24x0_intr_establish(spia->spia_aux_intr, IPL_TTY,
318 1.1 bsh IST_EDGE_FALLING, sskbd_atn_intr, sc);
319 1.1 bsh
320 1.1 bsh sc->spi_ih = s3c24x0_intr_establish(spia->spia_intr, IPL_SERIAL,
321 1.1 bsh 0, sskbd_spi_intr, sc);
322 1.1 bsh
323 1.4.20.1 matt sc->soft_ih = softint_establish(SOFTINT_SERIAL, sskbd_soft_intr, sc);
324 1.1 bsh
325 1.1 bsh if (sc->atn_ih == NULL || sc->spi_ih == NULL)
326 1.1 bsh aprint_error("%s: can't establish interrupt handler\n",
327 1.1 bsh sc->dev.dv_xname);
328 1.1 bsh
329 1.1 bsh /* setup SPI control register, and prescaler */
330 1.3 thorpej s3c24x0_spi_setup((struct ssspi_softc *)device_parent(self),
331 1.1 bsh SPCON_SMOD_INT | SPCON_ENSCK |
332 1.1 bsh SPCON_MSTR | SPCON_IDLELOW_RISING,
333 1.1 bsh 100*1000, 0);
334 1.1 bsh
335 1.1 bsh
336 1.1 bsh /* Attach the wskbd. */
337 1.1 bsh a.console = 0;
338 1.1 bsh a.keymap = &sskbd_keymapdata;
339 1.1 bsh a.accessops = &sskbd_accessops;
340 1.1 bsh a.accesscookie = sc;
341 1.1 bsh
342 1.1 bsh sc->wskbddev = config_found(self, &a, wskbddevprint);
343 1.1 bsh }
344 1.1 bsh
345 1.1 bsh
346 1.1 bsh /*
347 1.1 bsh * Interrupt handler for nATN signal.
348 1.1 bsh */
349 1.1 bsh static int
350 1.1 bsh sskbd_atn_intr(void *arg)
351 1.1 bsh {
352 1.1 bsh struct sskbd_softc *sc = arg;
353 1.1 bsh int s;
354 1.1 bsh uint32_t reg;
355 1.1 bsh
356 1.1 bsh /* make sure SPI transmitter is ready */
357 1.1 bsh if (!(bus_space_read_1(sc->iot, sc->ioh, SPI_SPSTA) & SPSTA_REDY))
358 1.1 bsh return 1;
359 1.1 bsh
360 1.1 bsh
361 1.1 bsh if (advance_ring_ptr(sc->inptr) == sc->outptr) {
362 1.1 bsh /* ring buffer is full. ignore this nATN signale */
363 1.4.20.1 matt softint_schedule(sc->soft_ih);
364 1.1 bsh return 1;
365 1.1 bsh }
366 1.1 bsh
367 1.1 bsh /* nSS = L */
368 1.1 bsh s = splserial();
369 1.1 bsh sc->reading = 1;
370 1.1 bsh reg = bus_space_read_2(sc->iot, sc->gpioh, GPIO_PBDAT);
371 1.1 bsh bus_space_write_2(sc->iot, sc->gpioh, GPIO_PBDAT,
372 1.1 bsh reg & ~(1<<SSKBD_SS));
373 1.1 bsh
374 1.1 bsh /* generate clock to receive data from the controller */
375 1.1 bsh bus_space_write_1(sc->iot, sc->ioh, SPI_SPTDAT, 0xff);
376 1.1 bsh
377 1.1 bsh splx(s);
378 1.1 bsh
379 1.1 bsh return 1;
380 1.1 bsh }
381 1.1 bsh
382 1.1 bsh /*
383 1.1 bsh * Interrupt handler for SPI rx
384 1.1 bsh */
385 1.1 bsh static int
386 1.1 bsh sskbd_spi_intr(void *arg)
387 1.1 bsh {
388 1.1 bsh struct sskbd_softc *sc = arg;
389 1.1 bsh int data;
390 1.1 bsh uint32_t reg;
391 1.1 bsh
392 1.1 bsh if (sc->reading == 0)
393 1.1 bsh return 1; /* Ignore garbate input. */
394 1.1 bsh
395 1.1 bsh sc->reading = 0;
396 1.1 bsh
397 1.1 bsh data = bus_space_read_1(sc->iot, sc->ioh, SPI_SPRDAT);
398 1.1 bsh
399 1.1 bsh /* nSS = H */
400 1.1 bsh reg = bus_space_read_2(sc->iot, sc->gpioh, GPIO_PBDAT);
401 1.1 bsh bus_space_write_2(sc->iot, sc->gpioh, GPIO_PBDAT,
402 1.1 bsh reg | (1<<SSKBD_SS));
403 1.1 bsh
404 1.1 bsh if (sc->enable) {
405 1.1 bsh sc->ring[sc->inptr] = data;
406 1.1 bsh sc->inptr = advance_ring_ptr(sc->inptr);
407 1.1 bsh
408 1.4.20.1 matt softint_schedule(sc->soft_ih);
409 1.1 bsh }
410 1.1 bsh #ifdef KBD_DEBUG
411 1.1 bsh else {
412 1.1 bsh printf("discard %x\n", data);
413 1.1 bsh }
414 1.1 bsh #endif
415 1.1 bsh
416 1.1 bsh return 1;
417 1.1 bsh }
418 1.1 bsh
419 1.1 bsh static void
420 1.1 bsh sskbd_soft_intr(void *arg)
421 1.1 bsh {
422 1.1 bsh struct sskbd_softc *sc = arg;
423 1.1 bsh int key, up;
424 1.1 bsh
425 1.1 bsh while (sc->outptr != sc->inptr) {
426 1.1 bsh key = sc->ring[sc->outptr];
427 1.1 bsh sc->outptr = advance_ring_ptr(sc->outptr);
428 1.1 bsh
429 1.1 bsh up = key & 0x80;
430 1.1 bsh key &= ~0x80;
431 1.1 bsh
432 1.1 bsh key -= 1;
433 1.1 bsh if (key < 0 || 8*14 < key)
434 1.1 bsh continue;
435 1.1 bsh
436 1.1 bsh #ifdef KBD_DEBUG
437 1.1 bsh printf("key %d %s\n", key, up ? "up" : "down");
438 1.1 bsh #endif
439 1.1 bsh wskbd_input(sc->wskbddev,
440 1.1 bsh up ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN,
441 1.1 bsh key);
442 1.1 bsh }
443 1.1 bsh }
444 1.1 bsh
445 1.1 bsh static int
446 1.1 bsh sskbd_enable(void *v, int on)
447 1.1 bsh {
448 1.1 bsh struct sskbd_softc *sc = v;
449 1.1 bsh
450 1.1 bsh #ifdef KBD_DEBUG
451 1.1 bsh printf("%s: enable\n", sc->dev.dv_xname);
452 1.1 bsh #endif
453 1.1 bsh
454 1.1 bsh #if 0
455 1.1 bsh if (!on && isconsole(sc))
456 1.1 bsh return EBUSY;
457 1.1 bsh #endif
458 1.1 bsh
459 1.1 bsh sc->enable = on;
460 1.1 bsh return (0);
461 1.1 bsh }
462 1.1 bsh
463 1.1 bsh
464 1.1 bsh static void
465 1.1 bsh sskbd_set_leds(void *v, int leds)
466 1.1 bsh {
467 1.1 bsh }
468 1.1 bsh
469 1.1 bsh static int
470 1.4 christos sskbd_ioctl(void *v, u_long cmd, void *data, int flag, struct lwp *l)
471 1.1 bsh {
472 1.1 bsh /*struct sskbd_softc *sc = v;*/
473 1.1 bsh
474 1.1 bsh switch (cmd) {
475 1.1 bsh case WSKBDIO_GTYPE:
476 1.1 bsh *(int *)data = WSKBD_TYPE_HPC_KBD; /* XXX */
477 1.1 bsh return 0;
478 1.1 bsh case WSKBDIO_COMPLEXBELL:
479 1.1 bsh #ifdef notyet
480 1.1 bsh #define d ((struct wskbd_bell_data *)data)
481 1.1 bsh /*
482 1.1 bsh * Keyboard can't beep directly; we have an
483 1.1 bsh * externally-provided global hook to do this.
484 1.1 bsh */
485 1.1 bsh sskbd_bell(d->pitch, d->period, d->volume, 0);
486 1.1 bsh #undef d
487 1.1 bsh #endif
488 1.1 bsh return (0);
489 1.1 bsh #ifdef WSDISPLAY_COMPAT_RAWKBD
490 1.1 bsh case WSKBDIO_SETMODE:
491 1.1 bsh sc->rawkbd = (*(int *)data == WSKBD_RAW);
492 1.1 bsh return (0);
493 1.1 bsh #endif
494 1.1 bsh
495 1.1 bsh #if 0
496 1.1 bsh case WSKBDIO_SETLEDS:
497 1.1 bsh case WSKBDIO_GETLEDS:
498 1.1 bsh /* no LED support */
499 1.1 bsh #endif
500 1.1 bsh }
501 1.1 bsh return EPASSTHROUGH;
502 1.1 bsh }
503