aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/amikbd.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/input/keyboard/amikbd.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/input/keyboard/amikbd.c')
-rw-r--r--drivers/input/keyboard/amikbd.c241
1 files changed, 241 insertions, 0 deletions
diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c
new file mode 100644
index 000000000000..4e8e8ea214ab
--- /dev/null
+++ b/drivers/input/keyboard/amikbd.c
@@ -0,0 +1,241 @@
1/*
2 * $Id: amikbd.c,v 1.13 2002/02/01 16:02:24 vojtech Exp $
3 *
4 * Copyright (c) 2000-2001 Vojtech Pavlik
5 *
6 * Based on the work of:
7 * Hamish Macdonald
8 */
9
10/*
11 * Amiga keyboard driver for Linux/m68k
12 */
13
14/*
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Should you need to contact me, the author, you can do so either by
30 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
31 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
32 */
33
34#include <linux/module.h>
35#include <linux/init.h>
36#include <linux/input.h>
37#include <linux/delay.h>
38#include <linux/interrupt.h>
39
40#include <asm/amigaints.h>
41#include <asm/amigahw.h>
42#include <asm/irq.h>
43
44MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
45MODULE_DESCRIPTION("Amiga keyboard driver");
46MODULE_LICENSE("GPL");
47
48static unsigned char amikbd_keycode[0x78] = {
49 [0] = KEY_GRAVE,
50 [1] = KEY_1,
51 [2] = KEY_2,
52 [3] = KEY_3,
53 [4] = KEY_4,
54 [5] = KEY_5,
55 [6] = KEY_6,
56 [7] = KEY_7,
57 [8] = KEY_8,
58 [9] = KEY_9,
59 [10] = KEY_0,
60 [11] = KEY_MINUS,
61 [12] = KEY_EQUAL,
62 [13] = KEY_BACKSLASH,
63 [15] = KEY_KP0,
64 [16] = KEY_Q,
65 [17] = KEY_W,
66 [18] = KEY_E,
67 [19] = KEY_R,
68 [20] = KEY_T,
69 [21] = KEY_Y,
70 [22] = KEY_U,
71 [23] = KEY_I,
72 [24] = KEY_O,
73 [25] = KEY_P,
74 [26] = KEY_LEFTBRACE,
75 [27] = KEY_RIGHTBRACE,
76 [29] = KEY_KP1,
77 [30] = KEY_KP2,
78 [31] = KEY_KP3,
79 [32] = KEY_A,
80 [33] = KEY_S,
81 [34] = KEY_D,
82 [35] = KEY_F,
83 [36] = KEY_G,
84 [37] = KEY_H,
85 [38] = KEY_J,
86 [39] = KEY_K,
87 [40] = KEY_L,
88 [41] = KEY_SEMICOLON,
89 [42] = KEY_APOSTROPHE,
90 [43] = KEY_BACKSLASH,
91 [45] = KEY_KP4,
92 [46] = KEY_KP5,
93 [47] = KEY_KP6,
94 [48] = KEY_102ND,
95 [49] = KEY_Z,
96 [50] = KEY_X,
97 [51] = KEY_C,
98 [52] = KEY_V,
99 [53] = KEY_B,
100 [54] = KEY_N,
101 [55] = KEY_M,
102 [56] = KEY_COMMA,
103 [57] = KEY_DOT,
104 [58] = KEY_SLASH,
105 [60] = KEY_KPDOT,
106 [61] = KEY_KP7,
107 [62] = KEY_KP8,
108 [63] = KEY_KP9,
109 [64] = KEY_SPACE,
110 [65] = KEY_BACKSPACE,
111 [66] = KEY_TAB,
112 [67] = KEY_KPENTER,
113 [68] = KEY_ENTER,
114 [69] = KEY_ESC,
115 [70] = KEY_DELETE,
116 [74] = KEY_KPMINUS,
117 [76] = KEY_UP,
118 [77] = KEY_DOWN,
119 [78] = KEY_RIGHT,
120 [79] = KEY_LEFT,
121 [80] = KEY_F1,
122 [81] = KEY_F2,
123 [82] = KEY_F3,
124 [83] = KEY_F4,
125 [84] = KEY_F5,
126 [85] = KEY_F6,
127 [86] = KEY_F7,
128 [87] = KEY_F8,
129 [88] = KEY_F9,
130 [89] = KEY_F10,
131 [90] = KEY_KPLEFTPAREN,
132 [91] = KEY_KPRIGHTPAREN,
133 [92] = KEY_KPSLASH,
134 [93] = KEY_KPASTERISK,
135 [94] = KEY_KPPLUS,
136 [95] = KEY_HELP,
137 [96] = KEY_LEFTSHIFT,
138 [97] = KEY_RIGHTSHIFT,
139 [98] = KEY_CAPSLOCK,
140 [99] = KEY_LEFTCTRL,
141 [100] = KEY_LEFTALT,
142 [101] = KEY_RIGHTALT,
143 [102] = KEY_LEFTMETA,
144 [103] = KEY_RIGHTMETA
145};
146
147static const char *amikbd_messages[8] = {
148 [0] = KERN_ALERT "amikbd: Ctrl-Amiga-Amiga reset warning!!\n",
149 [1] = KERN_WARNING "amikbd: keyboard lost sync\n",
150 [2] = KERN_WARNING "amikbd: keyboard buffer overflow\n",
151 [3] = KERN_WARNING "amikbd: keyboard controller failure\n",
152 [4] = KERN_ERR "amikbd: keyboard selftest failure\n",
153 [5] = KERN_INFO "amikbd: initiate power-up key stream\n",
154 [6] = KERN_INFO "amikbd: terminate power-up key stream\n",
155 [7] = KERN_WARNING "amikbd: keyboard interrupt\n"
156};
157
158static struct input_dev amikbd_dev;
159
160static char *amikbd_name = "Amiga keyboard";
161static char *amikbd_phys = "amikbd/input0";
162
163static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp)
164{
165 unsigned char scancode, down;
166
167 scancode = ~ciaa.sdr; /* get and invert scancode (keyboard is active low) */
168 ciaa.cra |= 0x40; /* switch SP pin to output for handshake */
169 udelay(85); /* wait until 85 us have expired */
170 ciaa.cra &= ~0x40; /* switch CIA serial port to input mode */
171
172 down = !(scancode & 1); /* lowest bit is release bit */
173 scancode >>= 1;
174
175 if (scancode < 0x78) { /* scancodes < 0x78 are keys */
176
177 scancode = amikbd_keycode[scancode];
178
179 input_regs(&amikbd_dev, fp);
180
181 if (scancode == KEY_CAPSLOCK) { /* CapsLock is a toggle switch key on Amiga */
182 input_report_key(&amikbd_dev, scancode, 1);
183 input_report_key(&amikbd_dev, scancode, 0);
184 input_sync(&amikbd_dev);
185 } else {
186 input_report_key(&amikbd_dev, scancode, down);
187 input_sync(&amikbd_dev);
188 }
189 } else /* scancodes >= 0x78 are error codes */
190 printk(amikbd_messages[scancode - 0x78]);
191
192 return IRQ_HANDLED;
193}
194
195static int __init amikbd_init(void)
196{
197 int i;
198
199 if (!AMIGAHW_PRESENT(AMI_KEYBOARD))
200 return -EIO;
201
202 if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb"))
203 return -EBUSY;
204
205 init_input_dev(&amikbd_dev);
206
207 amikbd_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
208 amikbd_dev.keycode = amikbd_keycode;
209 amikbd_dev.keycodesize = sizeof(unsigned char);
210 amikbd_dev.keycodemax = ARRAY_SIZE(amikbd_keycode);
211
212 for (i = 0; i < 0x78; i++)
213 if (amikbd_keycode[i])
214 set_bit(amikbd_keycode[i], amikbd_dev.keybit);
215
216 ciaa.cra &= ~0x41; /* serial data in, turn off TA */
217 request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", amikbd_interrupt);
218
219 amikbd_dev.name = amikbd_name;
220 amikbd_dev.phys = amikbd_phys;
221 amikbd_dev.id.bustype = BUS_AMIGA;
222 amikbd_dev.id.vendor = 0x0001;
223 amikbd_dev.id.product = 0x0001;
224 amikbd_dev.id.version = 0x0100;
225
226 input_register_device(&amikbd_dev);
227
228 printk(KERN_INFO "input: %s\n", amikbd_name);
229
230 return 0;
231}
232
233static void __exit amikbd_exit(void)
234{
235 input_unregister_device(&amikbd_dev);
236 free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt);
237 release_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100);
238}
239
240module_init(amikbd_init);
241module_exit(amikbd_exit);