1 #include <linux/sched.h>
2 #include <linux/interrupt.h>
3 #include <linux/errno.h>
4 #include <linux/keyboard.h>
5 #include <linux/delay.h>
6 #include <linux/timer.h>
7 #include <linux/kd.h>
8 #include <linux/kbd_ll.h>
9 #include <linux/random.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/poll.h>
13 #include <linux/miscdevice.h>
14 #include <linux/init.h>
15
16 #include <asm/setup.h>
17 #include <asm/irq.h>
18 #include <asm/apollohw.h>
19 #include <asm/uaccess.h>
20
21 #include "busmouse.h"
22
23 #define DNKEY_CAPS 0x7e
24 #define BREAK_FLAG 0x80
25 #define DNKEY_REPEAT_DELAY 50
26 #define DNKEY_CTRL 0x43
27 #define DNKEY_LSHIFT 0x5e
28 #define DNKEY_RSHIFT 0x6a
29 #define DNKEY_REPT 0x5d
30 #define DNKEY_REPEAT 0x7f
31 #define DNKEY_LALT 0x75
32 #define DNKEY_RALT 0x77
33
34 #define APOLLO_KEYB_CMD_ENTRIES 16
35 #define APOLLO_KBD_MODE_KEYB 0x01
36 #define APOLLO_KBD_MODE_MOUSE 0x02
37 #define APOLLO_KBD_MODE_CHANGE 0xff
38
39 static u_char keyb_cmds[APOLLO_KEYB_CMD_ENTRIES];
40 static short keyb_cmd_read=0, keyb_cmd_write=0;
41 static int keyb_cmd_transmit=0;
42 static int msedev;
43
44 static unsigned int kbd_mode=APOLLO_KBD_MODE_KEYB;
45
46 #if 0
47 static void debug_keyb_timer_handler(unsigned long ignored);
48 static u_char debug_buf1[4096],debug_buf2[4096],*debug_buf=&debug_buf1[0];
49 static u_char *shadow_buf=&debug_buf2[0];
50 static short debug_buf_count=0;
51 static int debug_buf_overrun=0,debug_timer_running=0;
52 static unsigned long debug_buffer_updated=0;
53 static struct timer_list debug_keyb_timer = { function: debug_keyb_timer_handler };
54 #endif
55
56 static u_short dnplain_map[NR_KEYS] __initdata = {
57 /* ins del del F1 F2 F3 F4
58 mark line char */
59 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
60 /* F5 F6 F7 F8 F9 F0 Again Read */
61 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
62 /* Edit Exit Hold Copy Paste Grow ESC */
63 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01b,
64 /* 1 2 3 4 5 6 7 8 */
65 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038,
66 /* 9 0 - = ` Back |<--
67 Space */
68 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf060, 0xf07f, 0xf200, 0xf200,
69 /* Shell -->| Tab q w e
70 Cmd */
71 0xf200, 0xf200, 0xf200, 0xf200, 0xf009, 0xfb71, 0xfb77, 0xfb65,
72 /* r t y u i o p [ */
73 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf05b,
74 /* ] Del 7 8 9 + */
75 0xf05d, 0xf200, 0xf200, 0xf200, 0xf307, 0xf308, 0xf300, 0xf30a,
76 /* [<--] Up [-->] Ctrl a s */
77 0xf200, 0xf600, 0xf200, 0xf702, 0xf200, 0xf200, 0xfb61, 0xfb73,
78 /* d f g h j k l ; */
79 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b,
80 /* ' Return \ 4 5 6 */
81 0xf027, 0xf200, 0xf201, 0xf05c, 0xf200, 0xf304, 0xf305, 0xf306,
82 /* - <-- Next --> Rept Shift
83 Window */
84 0xf30b, 0xf601, 0xf200, 0xf602, 0xf200, 0xf200, 0xf700, 0xf200,
85 /* z x c v b n m , */
86 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf02c,
87 /* . / Shift Pop 1 2 */
88 0xf02e, 0xf02f, 0xf700, 0xf200, 0xf200, 0xf200, 0xf301, 0xf302,
89 /* 3 PgUp Down PgDn Alt Space Alt */
90 0xf303, 0xf200, 0xf118, 0xf603, 0xf119, 0xf703, 0xf020, 0xf701,
91 /* 0 . Enter */
92 0xf200, 0xf300, 0xf200, 0xf310, 0xf30e, 0xf200, 0xf700, 0xf200,
93 };
94
95 static u_short dnshift_map[NR_KEYS] __initdata = {
96 /* ins del del F1 F2 F3 F4
97 mark line char */
98 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
99 /* F5 F6 F7 F8 F9 F0 Again Read */
100 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
101 /* Save Abort Help Cut Undo Grow ESC */
102 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01b,
103 /* ! @ # $ % ^ & * */
104 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a,
105 /* ( ) _ + ~ Back |<--
106 Space */
107 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07e, 0xf07f, 0xf200, 0xf200,
108 /* Shell -->| Tab Q W E
109 Cmd */
110 0xf200, 0xf200, 0xf200, 0xf200, 0xf009, 0xfb51, 0xfb57, 0xfb45,
111 /* R T Y U I O P { */
112 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf07b,
113 /* } Del 7 8 9 + */
114 0xf07d, 0xf200, 0xf200, 0xf200, 0xf307, 0xf308, 0xf300, 0xf30a,
115 /* [<--] Up [-->] Ctrl A S */
116 0xf200, 0xf600, 0xf200, 0xf702, 0xf200, 0xf200, 0xfb41, 0xfb53,
117 /* D F G H J K L : */
118 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a,
119 /* " Return | 4 5 6 */
120 0xf022, 0xf200, 0xf201, 0xf07c, 0xf200, 0xf304, 0xf305, 0xf306,
121 /* - <-- Next --> Rept Shift
122 Window */
123 0xf30b, 0xf601, 0xf200, 0xf602, 0xf200, 0xf200, 0xf700, 0xf200,
124 /* Z X C V B N M < */
125 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf03c,
126 /* > ? Shift Pop 1 2 */
127 0xf03e, 0xf03f, 0xf700, 0xf200, 0xf200, 0xf200, 0xf301, 0xf302,
128 /* 3 PgUp Down PgDn Alt Space Alt */
129 0xf303, 0xf200, 0xf118, 0xf603, 0xf119, 0xf703, 0xf020, 0xf701,
130 /* 0 . Enter */
131 0xf200, 0xf300, 0xf200, 0xf310, 0xf30e, 0xf200, 0xf708, 0xf200,
132 };
133
134 static u_short dnctrl_map[NR_KEYS] __initdata = {
135 /* ins del del F1 F2 F3 F4
136 mark line char */
137 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
138 /* F5 F6 F7 F8 F9 F0 Again Read */
139 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
140 /* Save Abort Help Cut Undo Grow ESC */
141 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01b,
142 /* ! @ # $ % ^ & * */
143 0xf200, 0xf000, 0xf01b, 0xf01c, 0xf01d, 0xf01e, 0xf01f, 0xf07f,
144 /* ( ) _ + ~ Back |<--
145 Space */
146 0xf200, 0xf200, 0xf01f, 0xf200, 0xf01c, 0xf200, 0xf200, 0xf200,
147 /* Shell -->| Tab Q W E
148 Cmd */
149 0xf200, 0xf200, 0xf200, 0xf200, 0xf009, 0xf011, 0xf017, 0xf005,
150 /* R T Y U I O P { */
151 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b,
152 /* } Del 7 8 9 + */
153 0xf01d, 0xf200, 0xf200, 0xf200, 0xf307, 0xf308, 0xf300, 0xf30a,
154 /* [<--] Up [-->] Ctrl A S */
155 0xf200, 0xf600, 0xf200, 0xf702, 0xf200, 0xf200, 0xfb01, 0xfb53,
156 /* D F G H J K L : */
157 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200,
158 /* " Return | 4 5 6 */
159 0xf200, 0xf200, 0xf201, 0xf01c, 0xf200, 0xf304, 0xf305, 0xf306,
160 /* - <-- Next --> Rept Shift
161 Window */
162 0xf30b, 0xf601, 0xf200, 0xf602, 0xf200, 0xf200, 0xf704, 0xf200,
163 /* Z X C V B N M < */
164 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf01d, 0xf03c,
165 /* > ? Shift Pop 1 2 */
166 0xf03e, 0xf03f, 0xf705, 0xf200, 0xf200, 0xf200, 0xf301, 0xf302,
167 /* 3 PgUp Down PgDn Alt Space Alt */
168 0xf303, 0xf200, 0xf118, 0xf603, 0xf119, 0xf703, 0xf020, 0xf701,
169 /* 0 . Enter */
170 0xf200, 0xf300, 0xf200, 0xf310, 0xf30e, 0xf200, 0xf200, 0xf200,
171 };
172
173 static u_short dnalt_map[NR_KEYS] __initdata = {
174 /* ins del del F1 F2 F3 F4
175 mark line char */
176 0xf200, 0xf200, 0xf200, 0xf200, 0xf500, 0xf501, 0xf502, 0xf503,
177 /* F5 F6 F7 F8 F9 F0 Again Read */
178 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf200, 0xf200,
179 /* Edit Exit Hold Copy Paste Grow ESC */
180 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01b,
181 /* 1 2 3 4 5 6 7 8 */
182 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838,
183 /* 9 0 - = ` Back |<--
184 Space */
185 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf860, 0xf87f, 0xf200, 0xf200,
186 /* Shell -->| Tab q w e
187 Cmd */
188 0xf200, 0xf200, 0xf200, 0xf200, 0xf809, 0xf871, 0xf877, 0xf865,
189 /* r t y u i o p [ */
190 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b,
191 /* ] Del 7 8 9 + */
192 0xf05d, 0xf200, 0xf200, 0xf200, 0xf307, 0xf308, 0xf300, 0xf30a,
193 /* [<--] Up [-->] Ctrl a s */
194 0xf200, 0xf600, 0xf200, 0xf702, 0xf200, 0xf200, 0xf861, 0xf873,
195 /* d f g h j k l ; */
196 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf03b,
197 /* ' Return \ 4 5 6 */
198 0xf027, 0xf200, 0xf201, 0xf05c, 0xf200, 0xf304, 0xf305, 0xf306,
199 /* - <-- Next --> Rept Shift
200 Window */
201 0xf30b, 0xf601, 0xf200, 0xf602, 0xf200, 0xf200, 0xf704, 0xf200,
202 /* z x c v b n m , */
203 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c,
204 /* . / Shift Pop 1 2 */
205 0xf82e, 0xf82f, 0xf705, 0xf200, 0xf200, 0xf200, 0xf301, 0xf302,
206 /* 3 PgUp Down PgDn Alt Space Alt */
207 0xf303, 0xf200, 0xf118, 0xf603, 0xf119, 0xf703, 0xf820, 0xf701,
208 /* 0 . Enter */
209 0xf200, 0xf300, 0xf200, 0xf310, 0xf30e, 0xf200, 0xf200, 0xf200,
210 };
211
212 static u_short dnaltgr_map[NR_KEYS] __initdata = {
213 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
214 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
215 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
216 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
217 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
218 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
219 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
220 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
221 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
222 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
223 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
224 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
225 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
226 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
227 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
228 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200
229 };
230
231 static u_short dnshift_ctrl_map[NR_KEYS] __initdata = {
232 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
233 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
234 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
235 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
236 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
237 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
238 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
239 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
240 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
241 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
242 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
243 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
244 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
245 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
246 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
247 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200
248 };
249
250 static u_short dnctrl_alt_map[NR_KEYS] __initdata = {
251 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
252 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
253 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
254 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
255 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
256 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
257 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
258 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
259 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
260 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
261 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
262 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
263 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
264 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
265 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
266 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200
267 };
268
269 #if 0
270 static void debug_keyb_timer_handler(unsigned long ignored) {
271
272 unsigned long flags;
273 u_char *swap;
274 short length,i;
275
276 if (time_after(jiffies, debug_buffer_updated + 100)) {
277 save_flags(flags);
278 cli();
279 length=debug_buf_count;
280 swap=debug_buf;
281 debug_buf=shadow_buf;
282 shadow_buf=swap;
283 debug_buf_count=0;
284 debug_timer_running=0;
285 restore_flags(flags);
286 for(i=1;length;length--,i++)
287 printk("%02x%c",*(swap++), (i % 25) ? ' ' : '\n');
288 printk("\n");
289 }
290 else {
291 debug_keyb_timer.expires=jiffies+10;
292 add_timer(&debug_keyb_timer);
293 }
294 }
295 #endif
296
dn_keyb_process_key_event(unsigned char scancode)297 static void dn_keyb_process_key_event(unsigned char scancode) {
298
299 static unsigned char lastscancode;
300 unsigned char prev_scancode=lastscancode;
301 static unsigned int lastkeypress;
302
303 lastscancode=scancode;
304
305 /* printk("scan: %02x, lastscan: %02X, prev_scancode: %02X\n",scancode,lastscancode,prev_scancode); */
306
307 if(prev_scancode==APOLLO_KBD_MODE_CHANGE) {
308 kbd_mode=scancode;
309 /* printk("modechange: %d\n",scancode); */
310 }
311 else if((scancode & (~BREAK_FLAG)) == DNKEY_CAPS) {
312 /* printk("handle_scancode: %02x\n",DNKEY_CAPS); */
313 handle_scancode(DNKEY_CAPS, 1);
314 /* printk("handle_scancode: %02x\n",BREAK_FLAG | DNKEY_CAPS); */
315 handle_scancode(DNKEY_CAPS, 0);
316 }
317 else if( (scancode == DNKEY_REPEAT) && (prev_scancode < 0x7e) &&
318 !(prev_scancode==DNKEY_CTRL || prev_scancode==DNKEY_LSHIFT ||
319 prev_scancode==DNKEY_RSHIFT || prev_scancode==DNKEY_REPT ||
320 prev_scancode==DNKEY_LALT || prev_scancode==DNKEY_RALT)) {
321 if (time_after(jiffies, lastkeypress + DNKEY_REPEAT_DELAY)) {
322 /* printk("handle_scancode: %02x\n",prev_scancode); */
323 handle_scancode(prev_scancode, 1);
324 }
325 lastscancode=prev_scancode;
326 }
327 else {
328 /* printk("handle_scancode: %02x\n",scancode); */
329 handle_scancode(scancode & ~BREAK_FLAG, !(scancode & BREAK_FLAG));
330 lastkeypress=jiffies;
331 }
332 }
333
dn_keyb_process_mouse_event(unsigned char mouse_data)334 static void dn_keyb_process_mouse_event(unsigned char mouse_data) {
335
336 static short mouse_byte_count=0;
337 static u_char mouse_packet[3];
338 short buttons;
339 int dx, dy;
340
341 mouse_packet[mouse_byte_count++]=mouse_data;
342
343 if(mouse_byte_count==3) {
344 if(mouse_packet[0]==APOLLO_KBD_MODE_CHANGE) {
345 kbd_mode=mouse_packet[1];
346 mouse_byte_count=0;
347 /* printk("modechange: %d\n",mouse_packet[1]); */
348 if(kbd_mode==APOLLO_KBD_MODE_KEYB)
349 dn_keyb_process_key_event(mouse_packet[2]);
350 }
351 if((mouse_packet[0] & 0x8f) == 0x80) {
352 buttons = (mouse_packet[0] >> 4) & 0x7;
353 dx = mouse_packet[1] == 0xff ? 0 : (signed char)mouse_packet[1];
354 dy = mouse_packet[2] == 0xff ? 0 : (signed char)mouse_packet[2];
355 busmouse_add_movementbuttons(msedev, dx, dy, buttons);
356 mouse_byte_count=0;
357 /* printk("mouse: %d, %d, %x\n",mouse_x,mouse_y,buttons); */
358 }
359 }
360 }
361
dn_keyb_int(int irq,void * dummy,struct pt_regs * fp)362 static void dn_keyb_int(int irq, void *dummy, struct pt_regs *fp) {
363
364 unsigned char data;
365 unsigned long flags;
366 int scn2681_ints;
367
368 do {
369 scn2681_ints=sio01.isr_imr & 3;
370 if(scn2681_ints & 2) {
371 data=sio01.rhra_thra;
372 #if 0
373 if(debug_buf_count<4096) {
374 debug_buf[debug_buf_count++]=data;
375 debug_buffer_updated=jiffies;
376 if(!debug_timer_running) {
377 debug_keyb_timer.expires=jiffies+10;
378 add_timer(&debug_keyb_timer);
379 debug_timer_running=1;
380 }
381 }
382 else
383 debug_buf_overrun=1;
384 #endif
385 if(sio01.sra_csra & 0x10) {
386 printk("whaa overrun !\n");
387 continue;
388 }
389
390 if(kbd_mode==APOLLO_KBD_MODE_KEYB)
391 dn_keyb_process_key_event(data);
392 else
393 dn_keyb_process_mouse_event(data);
394 }
395
396 if(scn2681_ints & 1) {
397 save_flags(flags);
398 cli();
399 if(keyb_cmd_write!=keyb_cmd_read) {
400 sio01.rhra_thra=keyb_cmds[keyb_cmd_read++];
401 if(keyb_cmd_read==APOLLO_KEYB_CMD_ENTRIES)
402 keyb_cmd_read=0;
403 keyb_cmd_transmit=1;
404 }
405 else {
406 keyb_cmd_transmit=0;
407 sio01.BRGtest_cra=9;
408 }
409 restore_flags(flags);
410 }
411 } while(scn2681_ints) ;
412 }
413
write_keyb_cmd(u_short length,u_char * cmd)414 void write_keyb_cmd(u_short length, u_char *cmd) {
415
416 unsigned long flags;
417
418 if((keyb_cmd_write==keyb_cmd_read) && keyb_cmd_transmit)
419 return;
420
421 save_flags(flags);
422 cli();
423 for(;length;length--) {
424 keyb_cmds[keyb_cmd_write++]=*(cmd++);
425 if(keyb_cmd_write==keyb_cmd_read)
426 return;
427 if(keyb_cmd_write==APOLLO_KEYB_CMD_ENTRIES)
428 keyb_cmd_write=0;
429 }
430 if(!keyb_cmd_transmit) {
431 sio01.BRGtest_cra=5;
432 }
433 restore_flags(flags);
434
435 }
436
437 static struct busmouse apollo_mouse = {
438 APOLLO_MOUSE_MINOR, "apollomouse", THIS_MODULE, NULL, NULL, 7
439 };
440
dn_keyb_init(void)441 int __init dn_keyb_init(void){
442
443 /* printk("dn_keyb_init\n"); */
444
445 memcpy(key_maps[0], dnplain_map, sizeof(plain_map));
446 memcpy(key_maps[1], dnshift_map, sizeof(plain_map));
447 memcpy(key_maps[2], dnaltgr_map, sizeof(plain_map));
448 memcpy(key_maps[4], dnctrl_map, sizeof(plain_map));
449 memcpy(key_maps[5], dnshift_ctrl_map, sizeof(plain_map));
450 memcpy(key_maps[8], dnalt_map, sizeof(plain_map));
451 memcpy(key_maps[12], dnctrl_alt_map, sizeof(plain_map));
452
453
454 msedev=register_busmouse(&apollo_mouse);
455 if (msedev < 0)
456 printk(KERN_WARNING "Unable to install Apollo mouse driver.\n");
457 else
458 printk(KERN_INFO "Apollo mouse installed.\n");
459
460 /* program UpDownMode */
461
462 while(!(sio01.sra_csra & 0x4));
463 sio01.rhra_thra=0xff;
464
465 while(!(sio01.sra_csra & 0x4));
466 sio01.rhra_thra=0x1;
467
468 request_irq(1, dn_keyb_int,0,NULL,NULL);
469
470 /* enable receive int on DUART */
471 sio01.isr_imr=3;
472
473 return 0;
474
475 }
476
dn_dummy_kbdrate(struct kbd_repeat * k)477 int dn_dummy_kbdrate(struct kbd_repeat *k) {
478
479 printk("dn_dummy_kbdrate\n");
480
481 return 0;
482
483 }
484