Input: add input event to APM event bridge
[linux-2.6-block.git] / drivers / input / serio / i8042-x86ia64io.h
CommitLineData
1da177e4
LT
1#ifndef _I8042_X86IA64IO_H
2#define _I8042_X86IA64IO_H
3
4/*
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 */
9
10/*
11 * Names.
12 */
13
14#define I8042_KBD_PHYS_DESC "isa0060/serio0"
15#define I8042_AUX_PHYS_DESC "isa0060/serio1"
16#define I8042_MUX_PHYS_DESC "isa0060/serio%d"
17
18/*
19 * IRQs.
20 */
21
22#if defined(__ia64__)
23# define I8042_MAP_IRQ(x) isa_irq_to_vector((x))
24#else
25# define I8042_MAP_IRQ(x) (x)
26#endif
27
28#define I8042_KBD_IRQ i8042_kbd_irq
29#define I8042_AUX_IRQ i8042_aux_irq
30
31static int i8042_kbd_irq;
32static int i8042_aux_irq;
33
34/*
35 * Register numbers.
36 */
37
38#define I8042_COMMAND_REG i8042_command_reg
39#define I8042_STATUS_REG i8042_command_reg
40#define I8042_DATA_REG i8042_data_reg
41
42static int i8042_command_reg = 0x64;
43static int i8042_data_reg = 0x60;
44
45
46static inline int i8042_read_data(void)
47{
48 return inb(I8042_DATA_REG);
49}
50
51static inline int i8042_read_status(void)
52{
53 return inb(I8042_STATUS_REG);
54}
55
56static inline void i8042_write_data(int val)
57{
58 outb(val, I8042_DATA_REG);
59}
60
61static inline void i8042_write_command(int val)
62{
63 outb(val, I8042_COMMAND_REG);
64}
65
66#if defined(__i386__)
67
68#include <linux/dmi.h>
69
70static struct dmi_system_id __initdata i8042_dmi_noloop_table[] = {
90245c17
DT
71 {
72 /* AUX LOOP command does not raise AUX IRQ */
73 .ident = "ASUS P65UP5",
74 .matches = {
75 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
76 DMI_MATCH(DMI_BOARD_NAME, "P/I-P65UP5"),
77 DMI_MATCH(DMI_BOARD_VERSION, "REV 2.X"),
78 },
79 },
1da177e4
LT
80 {
81 .ident = "Compaq Proliant 8500",
82 .matches = {
83 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
84 DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
85 DMI_MATCH(DMI_PRODUCT_VERSION, "8500"),
86 },
87 },
88 {
89 .ident = "Compaq Proliant DL760",
90 .matches = {
91 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
92 DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
93 DMI_MATCH(DMI_PRODUCT_VERSION, "DL760"),
94 },
95 },
6020bafc
BC
96 {
97 .ident = "OQO Model 01",
98 .matches = {
99 DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
100 DMI_MATCH(DMI_PRODUCT_NAME, "ZEPTO"),
101 DMI_MATCH(DMI_PRODUCT_VERSION, "00"),
102 },
103 },
8c4df74e
DT
104 {
105 /* AUX LOOP does not work properly */
106 .ident = "ULI EV4873",
107 .matches = {
108 DMI_MATCH(DMI_SYS_VENDOR, "ULI"),
109 DMI_MATCH(DMI_PRODUCT_NAME, "EV4873"),
110 DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
111 },
112 },
8bf4215e
JK
113 {
114 .ident = "Microsoft Virtual Machine",
115 .matches = {
116 DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
117 DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
118 DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"),
119 },
120 },
1da177e4
LT
121 { }
122};
123
124/*
59311de3 125 * Some Fujitsu notebooks are having trouble with touchpads if
1da177e4
LT
126 * active multiplexing mode is activated. Luckily they don't have
127 * external PS/2 ports so we can safely disable it.
59311de3
DT
128 * ... apparently some Toshibas don't like MUX mode either and
129 * die horrible death on reboot.
1da177e4
LT
130 */
131static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
132 {
133 .ident = "Fujitsu Lifebook P7010/P7010D",
134 .matches = {
135 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
136 DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
137 },
138 },
bb06ec3c
DT
139 {
140 .ident = "Fujitsu Lifebook P7010",
141 .matches = {
142 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
143 DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
144 },
145 },
1da177e4
LT
146 {
147 .ident = "Fujitsu Lifebook P5020D",
148 .matches = {
149 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
150 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
151 },
152 },
153 {
154 .ident = "Fujitsu Lifebook S2000",
155 .matches = {
156 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
157 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
158 },
159 },
b4ff99b6
DT
160 {
161 .ident = "Fujitsu Lifebook S6230",
162 .matches = {
163 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
164 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
165 },
166 },
1da177e4
LT
167 {
168 .ident = "Fujitsu T70H",
169 .matches = {
170 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
171 DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
172 },
173 },
20f07944
VP
174 {
175 .ident = "Fujitsu-Siemens Lifebook T3010",
176 .matches = {
177 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
178 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
179 },
180 },
7545c24c
DT
181 {
182 .ident = "Fujitsu-Siemens Lifebook E4010",
183 .matches = {
184 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
185 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
186 },
187 },
cc8310e3
DT
188 {
189 /*
190 * No data is coming from the touchscreen unless KBC
191 * is in legacy mode.
192 */
193 .ident = "Panasonic CF-29",
194 .matches = {
195 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
196 DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
197 },
198 },
6e782584
DT
199 {
200 /*
201 * Errors on MUX ports are reported without raising AUXDATA
202 * causing "spurious NAK" messages.
203 */
204 .ident = "HP Pavilion DV4017EA",
205 .matches = {
206 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
207 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
208 },
209 },
9d9d50bb
DT
210 {
211 /*
212 * Like DV4017EA does not raise AUXERR for errors on MUX ports.
213 */
214 .ident = "HP Pavilion ZT1000",
215 .matches = {
216 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
217 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Notebook PC"),
218 DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook ZT1000"),
219 },
220 },
749aea73
EP
221 {
222 /*
223 * Like DV4017EA does not raise AUXERR for errors on MUX ports.
224 */
225 .ident = "HP Pavilion DV4270ca",
226 .matches = {
227 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
228 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EH476UA#ABL)"),
229 },
230 },
59311de3
DT
231 {
232 .ident = "Toshiba P10",
233 .matches = {
234 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
235 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
236 },
237 },
a91eaa16
DT
238 {
239 .ident = "Toshiba Equium A110",
240 .matches = {
241 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
242 DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
243 },
244 },
865190cd
DT
245 {
246 .ident = "Alienware Sentia",
247 .matches = {
248 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
249 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
250 },
251 },
4eb38ac0
DT
252 {
253 .ident = "Sharp Actius MM20",
254 .matches = {
255 DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
256 DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
257 },
258 },
3dd01a83
VP
259 {
260 .ident = "Sony Vaio FS-115b",
261 .matches = {
262 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
263 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
264 },
265 },
e2df452b
CH
266 {
267 .ident = "Amoi M636/A737",
268 .matches = {
269 DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
270 DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
271 },
272 },
1da177e4
LT
273 { }
274};
275
276
277
278#endif
279
8987fec0
CC
280#ifdef CONFIG_X86
281
282#include <linux/dmi.h>
283
284/*
285 * Some Wistron based laptops need us to explicitly enable the 'Dritek
286 * keyboard extension' to make their extra keys start generating scancodes.
287 * Originally, this was just confined to older laptops, but a few Acer laptops
288 * have turned up in 2007 that also need this again.
289 */
290static struct dmi_system_id __initdata i8042_dmi_dritek_table[] = {
291 {
292 .ident = "Acer Aspire 5630",
293 .matches = {
294 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
295 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5630"),
296 },
297 },
298 {
299 .ident = "Acer Aspire 5650",
300 .matches = {
301 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
302 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"),
303 },
304 },
305 {
306 .ident = "Acer Aspire 5680",
307 .matches = {
308 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
309 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"),
310 },
311 },
312 {
313 .ident = "Acer TravelMate 2490",
314 .matches = {
315 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
316 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
317 },
318 },
319 { }
320};
321
322#endif /* CONFIG_X86 */
323
1da177e4
LT
324
325#ifdef CONFIG_PNP
326#include <linux/pnp.h>
327
328static int i8042_pnp_kbd_registered;
2bfc3c6e 329static unsigned int i8042_pnp_kbd_devices;
1da177e4 330static int i8042_pnp_aux_registered;
2bfc3c6e 331static unsigned int i8042_pnp_aux_devices;
1da177e4
LT
332
333static int i8042_pnp_command_reg;
334static int i8042_pnp_data_reg;
335static int i8042_pnp_kbd_irq;
336static int i8042_pnp_aux_irq;
337
338static char i8042_pnp_kbd_name[32];
339static char i8042_pnp_aux_name[32];
340
341static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
342{
343 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
344 i8042_pnp_data_reg = pnp_port_start(dev,0);
345
346 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
347 i8042_pnp_command_reg = pnp_port_start(dev, 1);
348
349 if (pnp_irq_valid(dev,0))
350 i8042_pnp_kbd_irq = pnp_irq(dev, 0);
351
352 strncpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
353 if (strlen(pnp_dev_name(dev))) {
354 strncat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
355 strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
356 }
357
2bfc3c6e 358 i8042_pnp_kbd_devices++;
1da177e4
LT
359 return 0;
360}
361
362static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
363{
364 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
365 i8042_pnp_data_reg = pnp_port_start(dev,0);
366
367 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
368 i8042_pnp_command_reg = pnp_port_start(dev, 1);
369
370 if (pnp_irq_valid(dev, 0))
371 i8042_pnp_aux_irq = pnp_irq(dev, 0);
372
373 strncpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
374 if (strlen(pnp_dev_name(dev))) {
375 strncat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
376 strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
377 }
378
2bfc3c6e 379 i8042_pnp_aux_devices++;
1da177e4
LT
380 return 0;
381}
382
383static struct pnp_device_id pnp_kbd_devids[] = {
384 { .id = "PNP0303", .driver_data = 0 },
385 { .id = "PNP030b", .driver_data = 0 },
386 { .id = "", },
387};
388
389static struct pnp_driver i8042_pnp_kbd_driver = {
390 .name = "i8042 kbd",
391 .id_table = pnp_kbd_devids,
392 .probe = i8042_pnp_kbd_probe,
393};
394
395static struct pnp_device_id pnp_aux_devids[] = {
b9973954
DT
396 { .id = "FJC6000", .driver_data = 0 },
397 { .id = "FJC6001", .driver_data = 0 },
1da177e4
LT
398 { .id = "PNP0f03", .driver_data = 0 },
399 { .id = "PNP0f0b", .driver_data = 0 },
400 { .id = "PNP0f0e", .driver_data = 0 },
401 { .id = "PNP0f12", .driver_data = 0 },
402 { .id = "PNP0f13", .driver_data = 0 },
403 { .id = "PNP0f19", .driver_data = 0 },
404 { .id = "PNP0f1c", .driver_data = 0 },
405 { .id = "SYN0801", .driver_data = 0 },
406 { .id = "", },
407};
408
409static struct pnp_driver i8042_pnp_aux_driver = {
410 .name = "i8042 aux",
411 .id_table = pnp_aux_devids,
412 .probe = i8042_pnp_aux_probe,
413};
414
415static void i8042_pnp_exit(void)
416{
74af42bb
KG
417 if (i8042_pnp_kbd_registered) {
418 i8042_pnp_kbd_registered = 0;
1da177e4 419 pnp_unregister_driver(&i8042_pnp_kbd_driver);
74af42bb 420 }
1da177e4 421
74af42bb
KG
422 if (i8042_pnp_aux_registered) {
423 i8042_pnp_aux_registered = 0;
1da177e4 424 pnp_unregister_driver(&i8042_pnp_aux_driver);
74af42bb 425 }
1da177e4
LT
426}
427
8d5987a6 428static int __init i8042_pnp_init(void)
1da177e4 429{
c3d31e7f 430 char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
080c652d 431 int pnp_data_busted = 0;
2bfc3c6e 432 int err;
1da177e4
LT
433
434 if (i8042_nopnp) {
39fa5800 435 printk(KERN_INFO "i8042: PNP detection disabled\n");
1da177e4
LT
436 return 0;
437 }
438
2bfc3c6e
BH
439 err = pnp_register_driver(&i8042_pnp_kbd_driver);
440 if (!err)
1da177e4 441 i8042_pnp_kbd_registered = 1;
c3d31e7f 442
2bfc3c6e
BH
443 err = pnp_register_driver(&i8042_pnp_aux_driver);
444 if (!err)
1da177e4
LT
445 i8042_pnp_aux_registered = 1;
446
2bfc3c6e 447 if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
1da177e4
LT
448 i8042_pnp_exit();
449#if defined(__ia64__)
450 return -ENODEV;
451#else
5a72afc0 452 printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n");
1da177e4
LT
453 return 0;
454#endif
455 }
456
2bfc3c6e 457 if (i8042_pnp_kbd_devices)
c3d31e7f
DT
458 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
459 "%d", i8042_pnp_kbd_irq);
2bfc3c6e 460 if (i8042_pnp_aux_devices)
c3d31e7f
DT
461 snprintf(aux_irq_str, sizeof(aux_irq_str),
462 "%d", i8042_pnp_aux_irq);
463
464 printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
2bfc3c6e 465 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
c3d31e7f
DT
466 i8042_pnp_aux_name,
467 i8042_pnp_data_reg, i8042_pnp_command_reg,
2bfc3c6e 468 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
c3d31e7f
DT
469 aux_irq_str);
470
471#if defined(__ia64__)
2bfc3c6e 472 if (!i8042_pnp_kbd_devices)
945ef0d4 473 i8042_nokbd = 1;
2bfc3c6e 474 if (!i8042_pnp_aux_devices)
c3d31e7f
DT
475 i8042_noaux = 1;
476#endif
477
1da177e4 478 if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
080c652d
DT
479 i8042_pnp_data_reg != i8042_data_reg) ||
480 !i8042_pnp_data_reg) {
481 printk(KERN_WARNING
482 "PNP: PS/2 controller has invalid data port %#x; "
483 "using default %#x\n",
1da177e4
LT
484 i8042_pnp_data_reg, i8042_data_reg);
485 i8042_pnp_data_reg = i8042_data_reg;
080c652d 486 pnp_data_busted = 1;
1da177e4
LT
487 }
488
489 if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
080c652d
DT
490 i8042_pnp_command_reg != i8042_command_reg) ||
491 !i8042_pnp_command_reg) {
492 printk(KERN_WARNING
493 "PNP: PS/2 controller has invalid command port %#x; "
494 "using default %#x\n",
1da177e4
LT
495 i8042_pnp_command_reg, i8042_command_reg);
496 i8042_pnp_command_reg = i8042_command_reg;
080c652d 497 pnp_data_busted = 1;
1da177e4
LT
498 }
499
945ef0d4 500 if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
080c652d
DT
501 printk(KERN_WARNING
502 "PNP: PS/2 controller doesn't have KBD irq; "
503 "using default %d\n", i8042_kbd_irq);
1da177e4 504 i8042_pnp_kbd_irq = i8042_kbd_irq;
080c652d 505 pnp_data_busted = 1;
1da177e4
LT
506 }
507
c3d31e7f 508 if (!i8042_noaux && !i8042_pnp_aux_irq) {
080c652d
DT
509 if (!pnp_data_busted && i8042_pnp_kbd_irq) {
510 printk(KERN_WARNING
511 "PNP: PS/2 appears to have AUX port disabled, "
512 "if this is incorrect please boot with "
513 "i8042.nopnp\n");
514 i8042_noaux = 1;
515 } else {
516 printk(KERN_WARNING
517 "PNP: PS/2 controller doesn't have AUX irq; "
518 "using default %d\n", i8042_aux_irq);
519 i8042_pnp_aux_irq = i8042_aux_irq;
520 }
1da177e4
LT
521 }
522
1da177e4
LT
523 i8042_data_reg = i8042_pnp_data_reg;
524 i8042_command_reg = i8042_pnp_command_reg;
525 i8042_kbd_irq = i8042_pnp_kbd_irq;
526 i8042_aux_irq = i8042_pnp_aux_irq;
527
1da177e4
LT
528 return 0;
529}
530
8d5987a6
DT
531#else
532static inline int i8042_pnp_init(void) { return 0; }
533static inline void i8042_pnp_exit(void) { }
1da177e4
LT
534#endif
535
8d5987a6 536static int __init i8042_platform_init(void)
1da177e4 537{
8d5987a6
DT
538 int retval;
539
1da177e4
LT
540/*
541 * On ix86 platforms touching the i8042 data register region can do really
542 * bad things. Because of this the region is always reserved on ix86 boxes.
543 *
544 * if (!request_region(I8042_DATA_REG, 16, "i8042"))
8d5987a6 545 * return -EBUSY;
1da177e4
LT
546 */
547
548 i8042_kbd_irq = I8042_MAP_IRQ(1);
549 i8042_aux_irq = I8042_MAP_IRQ(12);
550
8d5987a6
DT
551 retval = i8042_pnp_init();
552 if (retval)
553 return retval;
1da177e4
LT
554
555#if defined(__ia64__)
556 i8042_reset = 1;
557#endif
558
559#if defined(__i386__)
560 if (dmi_check_system(i8042_dmi_noloop_table))
561 i8042_noloop = 1;
562
563 if (dmi_check_system(i8042_dmi_nomux_table))
564 i8042_nomux = 1;
565#endif
566
8987fec0
CC
567#ifdef CONFIG_X86
568 if (dmi_check_system(i8042_dmi_dritek_table))
569 i8042_dritek = 1;
570#endif /* CONFIG_X86 */
571
8d5987a6 572 return retval;
1da177e4
LT
573}
574
575static inline void i8042_platform_exit(void)
576{
1da177e4 577 i8042_pnp_exit();
1da177e4
LT
578}
579
580#endif /* _I8042_X86IA64IO_H */