10 #include <linux/module.h>
12 #include <linux/input.h>
13 #include <linux/serio.h>
14 #include <linux/errno.h>
18 #include <linux/device.h>
19 #include <linux/slab.h>
27 #define PS2STAT 0x0004
28 #define PS2DATA 0x0008
29 #define PS2CLKDIV 0x000c
30 #define PS2PRECNT 0x0010
32 #define PS2CR_ENA 0x08
33 #define PS2CR_FKD 0x02
34 #define PS2CR_FKC 0x01
36 #define PS2STAT_STP 0x0100
37 #define PS2STAT_TXE 0x0080
38 #define PS2STAT_TXB 0x0040
39 #define PS2STAT_RXF 0x0020
40 #define PS2STAT_RXB 0x0010
41 #define PS2STAT_ENA 0x0008
42 #define PS2STAT_RXP 0x0004
43 #define PS2STAT_KBD 0x0002
44 #define PS2STAT_KBC 0x0001
96 spin_lock(&ps2if->
lock);
103 ps2if->
tail = (ps2if->
tail + 1) & (
sizeof(ps2if->
buf) - 1);
105 spin_unlock(&ps2if->
lock);
114 static int ps2_write(
struct serio *
io,
unsigned char val)
130 head = (ps2if->
head + 1) & (
sizeof(ps2if->
buf) - 1);
131 if (head != ps2if->
tail) {
137 spin_unlock_irqrestore(&ps2if->
lock, flags);
141 static int ps2_open(
struct serio *io)
154 ps2if->
dev->irq[0], ret);
163 ps2if->
dev->irq[1], ret);
171 enable_irq_wake(ps2if->
dev->irq[0]);
177 static void ps2_close(
struct serio *io)
183 disable_irq_wake(ps2if->
dev->irq[0]);
196 static void __devinit ps2_clear_input(
struct ps2if *ps2if)
206 static unsigned int __devinit ps2_test_one(
struct ps2if *ps2if,
223 static int __devinit ps2_test(
struct ps2if *ps2if)
230 printk(
"PS/2 interface test failed[1]: %02x\n", stat);
234 stat = ps2_test_one(ps2if, 0);
236 printk(
"PS/2 interface test failed[2]: %02x\n", stat);
242 printk(
"PS/2 interface test failed[3]: %02x\n", stat);
260 ps2if = kzalloc(
sizeof(
struct ps2if),
GFP_KERNEL);
261 serio = kzalloc(
sizeof(
struct serio),
GFP_KERNEL);
262 if (!ps2if || !serio) {
269 serio->
write = ps2_write;
270 serio->
open = ps2_open;
271 serio->
close = ps2_close;
275 serio->
dev.parent = &dev->
dev;
286 dev->
res.end - dev->
res.start + 1,
306 ps2_clear_input(ps2if);
311 ret = ps2_test(ps2if);
318 ps2_clear_input(ps2if);
355 .name =
"sa1111-ps2",
368 static void __exit ps2_exit(
void)