1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) 2005 Michael Schmitz
7 * Based on amikbd.c, which is
9 * Copyright (c) 2000-2001 Vojtech Pavlik
11 * Based on the work of:
16 * Atari keyboard driver for Linux/m68k
18 * The low level init and interrupt stuff is handled in arch/mm68k/atari/atakeyb.c
19 * (the keyboard ACIA also handles the mouse and joystick data, and the keyboard
20 * interrupt is shared with the MIDI ACIA so MIDI data also get handled there).
21 * This driver only deals with handing key events off to the input layer.
24 #include <linux/module.h>
25 #include <linux/init.h>
26 #include <linux/input.h>
27 #include <linux/delay.h>
28 #include <linux/interrupt.h>
30 #include <asm/atariints.h>
31 #include <asm/atarihw.h>
32 #include <asm/atarikb.h>
35 MODULE_AUTHOR("Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>");
36 MODULE_DESCRIPTION("Atari keyboard driver");
37 MODULE_LICENSE("GPL");
63 static unsigned char atakbd_keycode[0x73] = { /* American layout */
90 [27] = KEY_RIGHTBRACE,
102 [39] = KEY_SEMICOLON,
103 [40] = KEY_APOSTROPHE,
105 [42] = KEY_LEFTSHIFT,
106 [43] = KEY_BACKSLASH,
117 [54] = KEY_RIGHTSHIFT,
118 [55] = KEY_KPASTERISK,
144 [99] = KEY_KPLEFTPAREN,
145 [100] = KEY_KPRIGHTPAREN,
147 [102] = KEY_KPASTERISK,
162 static struct input_dev *atakbd_dev;
164 static void atakbd_interrupt(unsigned char scancode, char down)
167 if (scancode < 0x73) { /* scancodes < 0xf3 are keys */
169 // report raw events here?
171 scancode = atakbd_keycode[scancode];
173 input_report_key(atakbd_dev, scancode, down);
174 input_sync(atakbd_dev);
175 } else /* scancodes >= 0xf3 are mouse data, most likely */
176 printk(KERN_INFO "atakbd: unhandled scancode %x\n", scancode);
181 static int __init atakbd_init(void)
185 if (!MACH_IS_ATARI || !ATARIHW_PRESENT(ST_MFP))
188 // need to init core driver if not already done so
189 error = atari_keyb_init();
193 atakbd_dev = input_allocate_device();
197 atakbd_dev->name = "Atari Keyboard";
198 atakbd_dev->phys = "atakbd/input0";
199 atakbd_dev->id.bustype = BUS_HOST;
200 atakbd_dev->id.vendor = 0x0001;
201 atakbd_dev->id.product = 0x0001;
202 atakbd_dev->id.version = 0x0100;
204 atakbd_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
205 atakbd_dev->keycode = atakbd_keycode;
206 atakbd_dev->keycodesize = sizeof(unsigned char);
207 atakbd_dev->keycodemax = ARRAY_SIZE(atakbd_keycode);
209 for (i = 1; i < 0x72; i++) {
210 set_bit(atakbd_keycode[i], atakbd_dev->keybit);
214 error = input_register_device(atakbd_dev);
216 input_free_device(atakbd_dev);
220 atari_input_keyboard_interrupt_hook = atakbd_interrupt;
225 static void __exit atakbd_exit(void)
227 atari_input_keyboard_interrupt_hook = NULL;
228 input_unregister_device(atakbd_dev);
231 module_init(atakbd_init);
232 module_exit(atakbd_exit);