4 * Copyright (c) 2005 Michael Schmitz
6 * Based on amikbd.c, which is
8 * Copyright (c) 2000-2001 Vojtech Pavlik
10 * Based on the work of:
15 * Atari keyboard driver for Linux/m68k
17 * The low level init and interrupt stuff is handled in arch/mm68k/atari/atakeyb.c
18 * (the keyboard ACIA also handles the mouse and joystick data, and the keyboard
19 * interrupt is shared with the MIDI ACIA so MIDI data also get handled there).
20 * This driver only deals with handing key events off to the input layer.
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation; either version 2 of the License, or
27 * (at your option) any later version.
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 #include <linux/module.h>
40 #include <linux/init.h>
41 #include <linux/input.h>
42 #include <linux/delay.h>
43 #include <linux/interrupt.h>
45 #include <asm/atariints.h>
46 #include <asm/atarihw.h>
47 #include <asm/atarikb.h>
50 MODULE_AUTHOR("Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>");
51 MODULE_DESCRIPTION("Atari keyboard driver");
52 MODULE_LICENSE("GPL");
78 static unsigned char atakbd_keycode
[0x73] = { /* American layout */
104 [26] = KEY_LEFTBRACE
,
105 [27] = KEY_RIGHTBRACE
,
117 [39] = KEY_SEMICOLON
,
118 [40] = KEY_APOSTROPHE
,
120 [42] = KEY_LEFTSHIFT
,
121 [43] = KEY_BACKSLASH
,
132 [54] = KEY_RIGHTSHIFT
,
133 [55] = KEY_KPASTERISK
,
159 [99] = KEY_KPLEFTPAREN
,
160 [100] = KEY_KPRIGHTPAREN
,
162 [102] = KEY_KPASTERISK
,
177 static struct input_dev
*atakbd_dev
;
179 static void atakbd_interrupt(unsigned char scancode
, char down
)
182 if (scancode
< 0x73) { /* scancodes < 0xf3 are keys */
184 // report raw events here?
186 scancode
= atakbd_keycode
[scancode
];
188 input_report_key(atakbd_dev
, scancode
, down
);
189 input_sync(atakbd_dev
);
190 } else /* scancodes >= 0xf3 are mouse data, most likely */
191 printk(KERN_INFO
"atakbd: unhandled scancode %x\n", scancode
);
196 static int __init
atakbd_init(void)
200 if (!MACH_IS_ATARI
|| !ATARIHW_PRESENT(ST_MFP
))
203 // need to init core driver if not already done so
204 error
= atari_keyb_init();
208 atakbd_dev
= input_allocate_device();
212 atakbd_dev
->name
= "Atari Keyboard";
213 atakbd_dev
->phys
= "atakbd/input0";
214 atakbd_dev
->id
.bustype
= BUS_HOST
;
215 atakbd_dev
->id
.vendor
= 0x0001;
216 atakbd_dev
->id
.product
= 0x0001;
217 atakbd_dev
->id
.version
= 0x0100;
219 atakbd_dev
->evbit
[0] = BIT_MASK(EV_KEY
) | BIT_MASK(EV_REP
);
220 atakbd_dev
->keycode
= atakbd_keycode
;
221 atakbd_dev
->keycodesize
= sizeof(unsigned char);
222 atakbd_dev
->keycodemax
= ARRAY_SIZE(atakbd_keycode
);
224 for (i
= 1; i
< 0x72; i
++) {
225 set_bit(atakbd_keycode
[i
], atakbd_dev
->keybit
);
229 error
= input_register_device(atakbd_dev
);
231 input_free_device(atakbd_dev
);
235 atari_input_keyboard_interrupt_hook
= atakbd_interrupt
;
240 static void __exit
atakbd_exit(void)
242 atari_input_keyboard_interrupt_hook
= NULL
;
243 input_unregister_device(atakbd_dev
);
246 module_init(atakbd_init
);
247 module_exit(atakbd_exit
);