1 #include <linux/slab.h>
2 #include <linux/serio.h>
3 #include <linux/delay.h>
6 #define START_STREAMING {'\x06','\x03','\x01'}
7 #define STOP_STREAMING {'\x06','\x04'}
8 #define SEND_COMMAND {'\x06','\x01','\xf4','\x01'}
12 struct serio
*ser_dev
;
13 struct notifier_block notifier
;
14 struct nvec_chip
*nvec
;
17 static struct nvec_ps2 ps2_dev
;
19 static int ps2_startstreaming(struct serio
*ser_dev
)
21 unsigned char buf
[] = START_STREAMING
;
22 nvec_write_async(ps2_dev
.nvec
, buf
, sizeof(buf
));
26 static void ps2_stopstreaming(struct serio
*ser_dev
)
28 unsigned char buf
[] = STOP_STREAMING
;
29 nvec_write_async(ps2_dev
.nvec
, buf
, sizeof(buf
));
32 /* is this really needed?
33 static void nvec_resp_handler(unsigned char *data) {
34 serio_interrupt(ser_dev, data[4], 0);
38 static int ps2_sendcommand(struct serio
*ser_dev
, unsigned char cmd
)
40 unsigned char buf
[] = SEND_COMMAND
;
44 dev_dbg(&ser_dev
->dev
, "Sending ps2 cmd %02x\n", cmd
);
45 nvec_write_async(ps2_dev
.nvec
, buf
, sizeof(buf
));
50 static int nvec_ps2_notifier(struct notifier_block
*nb
,
51 unsigned long event_type
, void *data
)
54 unsigned char *msg
= (unsigned char *)data
;
58 serio_interrupt(ps2_dev
.ser_dev
, msg
[2], 0);
63 for(i
= 0; i
< (msg
[1] - 2); i
++)
64 serio_interrupt(ps2_dev
.ser_dev
, msg
[i
+4], 0);
65 else if (msg
[1] != 2) /* !ack */
67 printk("nvec_ps2: unhandled mouse event ");
68 for(i
= 0; i
<= (msg
[1]+1); i
++)
69 printk("%02x ", msg
[i
]);
80 int __init
nvec_ps2(struct nvec_chip
*nvec
)
82 struct serio
*ser_dev
= kzalloc(sizeof(struct serio
), GFP_KERNEL
);
84 ser_dev
->id
.type
=SERIO_8042
;
85 ser_dev
->write
=ps2_sendcommand
;
86 ser_dev
->open
=ps2_startstreaming
;
87 ser_dev
->close
=ps2_stopstreaming
;
89 strlcpy(ser_dev
->name
, "NVEC PS2", sizeof(ser_dev
->name
));
90 strlcpy(ser_dev
->phys
, "NVEC I2C slave", sizeof(ser_dev
->phys
));
92 ps2_dev
.ser_dev
= ser_dev
;
93 ps2_dev
.notifier
.notifier_call
= nvec_ps2_notifier
;
95 nvec_register_notifier(nvec
, &ps2_dev
.notifier
, 0);
97 serio_register_port(ser_dev
);
100 nvec_write_async(nvec
, "\x06\x01\xff\x03", 4);