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.
27 #include <linux/module.h>
28 #include <linux/init.h>
29 #include <linux/input.h>
30 #include <linux/delay.h>
31 #include <linux/interrupt.h>
33 #include <asm/atariints.h>
34 #include <asm/atarihw.h>
35 #include <asm/atarikb.h>
39 MODULE_DESCRIPTION("Atari keyboard driver");
40 MODULE_LICENSE("GPL");
66 static unsigned char atakbd_keycode[0x73] = { /* American layout */
93 [27] = KEY_RIGHTBRACE,
105 [39] = KEY_SEMICOLON,
106 [40] = KEY_APOSTROPHE,
108 [42] = KEY_LEFTSHIFT,
109 [43] = KEY_BACKSLASH,
120 [54] = KEY_RIGHTSHIFT,
121 [55] = KEY_KPASTERISK,
147 [99] = KEY_KPLEFTPAREN,
148 [100] = KEY_KPRIGHTPAREN,
150 [102] = KEY_KPASTERISK,
165 static struct input_dev *atakbd_dev;
167 static void atakbd_interrupt(unsigned char scancode, char down)
170 if (scancode < 0x73) { /* scancodes < 0xf3 are keys */
172 // report raw events here?
174 scancode = atakbd_keycode[scancode];
176 input_report_key(atakbd_dev, scancode, down);
177 input_sync(atakbd_dev);
178 } else /* scancodes >= 0xf3 are mouse data, most likely */
179 printk(KERN_INFO "atakbd: unhandled scancode %x\n", scancode);
184 static int __init atakbd_init(void)
188 if (!MACH_IS_ATARI || !ATARIHW_PRESENT(ST_MFP))
191 // need to init core driver if not already done so
192 error = atari_keyb_init();
196 atakbd_dev = input_allocate_device();
200 atakbd_dev->name = "Atari Keyboard";
201 atakbd_dev->phys = "atakbd/input0";
202 atakbd_dev->id.bustype = BUS_HOST;
203 atakbd_dev->id.vendor = 0x0001;
204 atakbd_dev->id.product = 0x0001;
205 atakbd_dev->id.version = 0x0100;
207 atakbd_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
208 atakbd_dev->keycode = atakbd_keycode;
209 atakbd_dev->keycodesize = sizeof(unsigned char);
210 atakbd_dev->keycodemax = ARRAY_SIZE(atakbd_keycode);
212 for (i = 1; i < 0x72; i++) {
213 set_bit(atakbd_keycode[i], atakbd_dev->keybit);
217 error = input_register_device(atakbd_dev);
219 input_free_device(atakbd_dev);
223 atari_input_keyboard_interrupt_hook = atakbd_interrupt;
228 static void __exit atakbd_exit(void)
230 atari_input_keyboard_interrupt_hook = NULL;
231 input_unregister_device(atakbd_dev);
234 module_init(atakbd_init);
235 module_exit(atakbd_exit);