2 * Copyright (c) 2000-2001 Vojtech Pavlik
4 * Based on the work of:
5 * Alan Cox Robin O'Leary
9 * IBM PC110 touchpad driver for Linux
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
32 #include <linux/module.h>
33 #include <linux/kernel.h>
34 #include <linux/errno.h>
35 #include <linux/ioport.h>
36 #include <linux/input.h>
37 #include <linux/init.h>
38 #include <linux/interrupt.h>
39 #include <linux/pci.h>
40 #include <linux/delay.h>
45 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
46 MODULE_DESCRIPTION("IBM PC110 touchpad driver");
47 MODULE_LICENSE("GPL");
49 #define PC110PAD_OFF 0x30
50 #define PC110PAD_ON 0x38
52 static int pc110pad_irq
= 10;
53 static int pc110pad_io
= 0x15e0;
55 static struct input_dev
*pc110pad_dev
;
56 static int pc110pad_data
[3];
57 static int pc110pad_count
;
59 static irqreturn_t
pc110pad_interrupt(int irq
, void *ptr
)
61 int value
= inb_p(pc110pad_io
);
62 int handshake
= inb_p(pc110pad_io
+ 2);
64 outb(handshake
| 1, pc110pad_io
+ 2);
66 outb(handshake
& ~1, pc110pad_io
+ 2);
70 pc110pad_data
[pc110pad_count
++] = value
;
72 if (pc110pad_count
< 3)
75 input_report_key(pc110pad_dev
, BTN_TOUCH
,
76 pc110pad_data
[0] & 0x01);
77 input_report_abs(pc110pad_dev
, ABS_X
,
78 pc110pad_data
[1] | ((pc110pad_data
[0] << 3) & 0x80) | ((pc110pad_data
[0] << 1) & 0x100));
79 input_report_abs(pc110pad_dev
, ABS_Y
,
80 pc110pad_data
[2] | ((pc110pad_data
[0] << 4) & 0x80));
81 input_sync(pc110pad_dev
);
87 static void pc110pad_close(struct input_dev
*dev
)
89 outb(PC110PAD_OFF
, pc110pad_io
+ 2);
92 static int pc110pad_open(struct input_dev
*dev
)
94 pc110pad_interrupt(0, NULL
);
95 pc110pad_interrupt(0, NULL
);
96 pc110pad_interrupt(0, NULL
);
97 outb(PC110PAD_ON
, pc110pad_io
+ 2);
104 * We try to avoid enabling the hardware if it's not
105 * there, but we don't know how to test. But we do know
106 * that the PC110 is not a PCI system. So if we find any
107 * PCI devices in the machine, we don't have a PC110.
109 static int __init
pc110pad_init(void)
114 if (!no_pci_devices())
117 if (!request_region(pc110pad_io
, 4, "pc110pad")) {
118 printk(KERN_ERR
"pc110pad: I/O area %#x-%#x in use.\n",
119 pc110pad_io
, pc110pad_io
+ 4);
123 outb(PC110PAD_OFF
, pc110pad_io
+ 2);
125 if (request_irq(pc110pad_irq
, pc110pad_interrupt
, 0, "pc110pad", NULL
)) {
126 printk(KERN_ERR
"pc110pad: Unable to get irq %d.\n", pc110pad_irq
);
128 goto err_release_region
;
131 pc110pad_dev
= input_allocate_device();
133 printk(KERN_ERR
"pc110pad: Not enough memory.\n");
138 pc110pad_dev
->name
= "IBM PC110 TouchPad";
139 pc110pad_dev
->phys
= "isa15e0/input0";
140 pc110pad_dev
->id
.bustype
= BUS_ISA
;
141 pc110pad_dev
->id
.vendor
= 0x0003;
142 pc110pad_dev
->id
.product
= 0x0001;
143 pc110pad_dev
->id
.version
= 0x0100;
145 pc110pad_dev
->evbit
[0] = BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
146 pc110pad_dev
->absbit
[0] = BIT_MASK(ABS_X
) | BIT_MASK(ABS_Y
);
147 pc110pad_dev
->keybit
[BIT_WORD(BTN_TOUCH
)] = BIT_MASK(BTN_TOUCH
);
149 pc110pad_dev
->absmax
[ABS_X
] = 0x1ff;
150 pc110pad_dev
->absmax
[ABS_Y
] = 0x0ff;
152 pc110pad_dev
->open
= pc110pad_open
;
153 pc110pad_dev
->close
= pc110pad_close
;
155 err
= input_register_device(pc110pad_dev
);
162 input_free_device(pc110pad_dev
);
164 free_irq(pc110pad_irq
, NULL
);
166 release_region(pc110pad_io
, 4);
171 static void __exit
pc110pad_exit(void)
173 outb(PC110PAD_OFF
, pc110pad_io
+ 2);
174 free_irq(pc110pad_irq
, NULL
);
175 input_unregister_device(pc110pad_dev
);
176 release_region(pc110pad_io
, 4);
179 module_init(pc110pad_init
);
180 module_exit(pc110pad_exit
);