47 #include <linux/module.h>
48 #include <linux/parport.h>
49 #include <linux/slab.h>
51 #include <linux/serio.h>
57 static unsigned int parkbd_pp_no;
65 #define PARKBD_CLOCK 0x01
66 #define PARKBD_DATA 0x02
68 static int parkbd_buffer;
69 static int parkbd_counter;
70 static unsigned long parkbd_last;
71 static int parkbd_writing;
72 static unsigned long parkbd_start;
75 static struct serio *parkbd_port;
77 static int parkbd_readlines(
void)
82 static void parkbd_writelines(
int data)
87 static int parkbd_write(
struct serio *
port,
unsigned char c)
91 if (!parkbd_mode)
return -1;
99 parkbd_buffer = c | (((
int) (~p & 1)) << 8) | 0x600;
101 parkbd_writelines(2);
106 static void parkbd_interrupt(
void *
dev_id)
109 if (parkbd_writing) {
111 if (parkbd_counter && ((parkbd_counter == 11) ||
time_after(jiffies, parkbd_last +
HZ/100))) {
115 parkbd_writelines(3);
119 parkbd_writelines(((parkbd_buffer >> parkbd_counter++) & 1) | 2);
121 if (parkbd_counter == 11) {
125 parkbd_writelines(3);
130 if ((parkbd_counter == parkbd_mode + 10) ||
time_after(jiffies, parkbd_last +
HZ/100)) {
135 parkbd_buffer |= (parkbd_readlines() >> 1) << parkbd_counter++;
137 if (parkbd_counter == parkbd_mode + 10)
138 serio_interrupt(parkbd_port, (parkbd_buffer >> (2 - parkbd_mode)) & 0xff, 0);
144 static int parkbd_getport(
void)
171 static struct serio *
__init parkbd_allocate_serio(
void)
175 serio = kzalloc(
sizeof(
struct serio),
GFP_KERNEL);
177 serio->
id.type = parkbd_mode;
178 serio->
write = parkbd_write,
179 strlcpy(serio->
name,
"PARKBD AT/XT keyboard adapter",
sizeof(serio->
name));
186 static int __init parkbd_init(
void)
190 err = parkbd_getport();
194 parkbd_port = parkbd_allocate_serio();
200 parkbd_writelines(3);
205 parkbd_mode ?
"AT" :
"XT", parkbd_dev->
port->name);
210 static void __exit parkbd_exit(
void)