26 #include <linux/module.h>
27 #include <linux/slab.h>
28 #include <linux/serio.h>
29 #include <linux/input.h>
45 #define PFX "gscps2.c: "
55 #define GSC_DINO_OFFSET 0x0800
59 #define GSC_RESET 0x00
60 #define GSC_RCVDATA 0x04
61 #define GSC_XMTDATA 0x04
62 #define GSC_CONTROL 0x08
63 #define GSC_STATUS 0x0C
66 #define GSC_CTRL_ENBL 0x01
67 #define GSC_CTRL_LPBXR 0x02
68 #define GSC_CTRL_DIAG 0x20
69 #define GSC_CTRL_DATDIR 0x40
70 #define GSC_CTRL_CLKDIR 0x80
73 #define GSC_STAT_RBNE 0x01
74 #define GSC_STAT_TBNE 0x02
75 #define GSC_STAT_TERR 0x04
76 #define GSC_STAT_PERR 0x08
77 #define GSC_STAT_CMPINTR 0x10
78 #define GSC_STAT_DATSHD 0x40
79 #define GSC_STAT_CLKSHD 0x80
82 #define GSC_ID_KEYBOARD 0
83 #define GSC_ID_MOUSE 1
88 #define BUFFER_SIZE 0x0f
109 #define gscps2_readb_input(x) readb((x)+GSC_RCVDATA)
110 #define gscps2_readb_control(x) readb((x)+GSC_CONTROL)
111 #define gscps2_readb_status(x) readb((x)+GSC_STATUS)
112 #define gscps2_writeb_control(x, y) writeb((x), (y)+GSC_CONTROL)
119 static int wait_TBE(
char *
addr)
135 static void gscps2_flush(
struct gscps2port *ps2port)
153 if (!wait_TBE(addr)) {
163 spin_unlock_irqrestore(&ps2port->
lock, flags);
170 gscps2_interrupt(0,
NULL);
187 gscps2_flush(ps2port);
194 spin_unlock_irqrestore(&ps2port->
lock, flags);
195 wait_TBE(ps2port->
addr);
196 gscps2_flush(ps2port);
203 static void gscps2_reset(
struct gscps2port *ps2port)
205 char *addr = ps2port->
addr;
210 gscps2_flush(ps2port);
212 gscps2_flush(ps2port);
213 spin_unlock_irqrestore(&ps2port->
lock, flags);
246 spin_unlock_irqrestore(&ps2port->
lock, flags);
254 while (ps2port->
act != ps2port->
append) {
256 unsigned int rxflags;
264 status = ps2port->
buffer[ps2port->
act].str;
265 data = ps2port->
buffer[ps2port->
act].data;
285 static int gscps2_write(
struct serio *
port,
unsigned char data)
289 if (!gscps2_writeb_output(ps2port, data)) {
301 static int gscps2_open(
struct serio *port)
305 gscps2_reset(ps2port);
308 gscps2_enable(ps2port,
ENABLE);
310 gscps2_interrupt(0,
NULL);
319 static void gscps2_close(
struct serio *port)
322 gscps2_enable(ps2port,
DISABLE);
334 unsigned long hpa = dev->
hpa.start;
341 if (dev->
id.sversion == 0x96)
345 serio = kzalloc(
sizeof(
struct serio),
GFP_KERNEL);
346 if (!ps2port || !serio) {
353 ps2port->
port = serio;
358 gscps2_reset(ps2port);
365 serio->
write = gscps2_write;
366 serio->
open = gscps2_open;
367 serio->
close = gscps2_close;
369 serio->
dev.parent = &dev->
dev;
391 ps2port->
port->phys);
423 gscps2_flush(ps2port);
445 .id_table = gscps2_device_tbl,
446 .probe = gscps2_probe,
450 static int __init gscps2_init(
void)
456 static void __exit gscps2_exit(
void)