Pull video into release branch
[linux-2.6] / drivers / input / serio / i8042-x86ia64io.h
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
31 static int i8042_kbd_irq;
32 static 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
42 static int i8042_command_reg = 0x64;
43 static int i8042_data_reg = 0x60;
44
45
46 static inline int i8042_read_data(void)
47 {
48         return inb(I8042_DATA_REG);
49 }
50
51 static inline int i8042_read_status(void)
52 {
53         return inb(I8042_STATUS_REG);
54 }
55
56 static inline void i8042_write_data(int val)
57 {
58         outb(val, I8042_DATA_REG);
59 }
60
61 static 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
70 static struct dmi_system_id __initdata i8042_dmi_noloop_table[] = {
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         },
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         },
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         },
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         },
113         { }
114 };
115
116 /*
117  * Some Fujitsu notebooks are having trouble with touchpads if
118  * active multiplexing mode is activated. Luckily they don't have
119  * external PS/2 ports so we can safely disable it.
120  * ... apparently some Toshibas don't like MUX mode either and
121  * die horrible death on reboot.
122  */
123 static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
124         {
125                 .ident = "Fujitsu Lifebook P7010/P7010D",
126                 .matches = {
127                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
128                         DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
129                 },
130         },
131         {
132                 .ident = "Fujitsu Lifebook P7010",
133                 .matches = {
134                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
135                         DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
136                 },
137         },
138         {
139                 .ident = "Fujitsu Lifebook P5020D",
140                 .matches = {
141                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
142                         DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
143                 },
144         },
145         {
146                 .ident = "Fujitsu Lifebook S2000",
147                 .matches = {
148                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
149                         DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
150                 },
151         },
152         {
153                 .ident = "Fujitsu Lifebook S6230",
154                 .matches = {
155                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
156                         DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
157                 },
158         },
159         {
160                 .ident = "Fujitsu T70H",
161                 .matches = {
162                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
163                         DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
164                 },
165         },
166         {
167                 .ident = "Fujitsu-Siemens Lifebook T3010",
168                 .matches = {
169                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
170                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
171                 },
172         },
173         {
174                 .ident = "Fujitsu-Siemens Lifebook E4010",
175                 .matches = {
176                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
177                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
178                 },
179         },
180         {
181                 /*
182                  * No data is coming from the touchscreen unless KBC
183                  * is in legacy mode.
184                  */
185                 .ident = "Panasonic CF-29",
186                 .matches = {
187                         DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
188                         DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
189                 },
190         },
191         {
192                 /*
193                  * Errors on MUX ports are reported without raising AUXDATA
194                  * causing "spurious NAK" messages.
195                  */
196                 .ident = "HP Pavilion DV4017EA",
197                 .matches = {
198                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
199                         DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
200                 },
201         },
202         {
203                 /*
204                  * Like DV4017EA does not raise AUXERR for errors on MUX ports.
205                  */
206                 .ident = "HP Pavilion ZT1000",
207                 .matches = {
208                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
209                         DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Notebook PC"),
210                         DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook ZT1000"),
211                 },
212         },
213         {
214                 .ident = "Toshiba P10",
215                 .matches = {
216                         DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
217                         DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
218                 },
219         },
220         {
221                 .ident = "Toshiba Equium A110",
222                 .matches = {
223                         DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
224                         DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
225                 },
226         },
227         {
228                 .ident = "Alienware Sentia",
229                 .matches = {
230                         DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
231                         DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
232                 },
233         },
234         {
235                 .ident = "Sharp Actius MM20",
236                 .matches = {
237                         DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
238                         DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
239                 },
240         },
241         {
242                 .ident = "Sony Vaio FS-115b",
243                 .matches = {
244                         DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
245                         DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
246                 },
247         },
248         {
249                 .ident = "Amoi M636/A737",
250                 .matches = {
251                         DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
252                         DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
253                 },
254         },
255         { }
256 };
257
258
259
260 #endif
261
262
263 #ifdef CONFIG_PNP
264 #include <linux/pnp.h>
265
266 static int i8042_pnp_kbd_registered;
267 static unsigned int i8042_pnp_kbd_devices;
268 static int i8042_pnp_aux_registered;
269 static unsigned int i8042_pnp_aux_devices;
270
271 static int i8042_pnp_command_reg;
272 static int i8042_pnp_data_reg;
273 static int i8042_pnp_kbd_irq;
274 static int i8042_pnp_aux_irq;
275
276 static char i8042_pnp_kbd_name[32];
277 static char i8042_pnp_aux_name[32];
278
279 static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
280 {
281         if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
282                 i8042_pnp_data_reg = pnp_port_start(dev,0);
283
284         if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
285                 i8042_pnp_command_reg = pnp_port_start(dev, 1);
286
287         if (pnp_irq_valid(dev,0))
288                 i8042_pnp_kbd_irq = pnp_irq(dev, 0);
289
290         strncpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
291         if (strlen(pnp_dev_name(dev))) {
292                 strncat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
293                 strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
294         }
295
296         i8042_pnp_kbd_devices++;
297         return 0;
298 }
299
300 static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
301 {
302         if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
303                 i8042_pnp_data_reg = pnp_port_start(dev,0);
304
305         if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
306                 i8042_pnp_command_reg = pnp_port_start(dev, 1);
307
308         if (pnp_irq_valid(dev, 0))
309                 i8042_pnp_aux_irq = pnp_irq(dev, 0);
310
311         strncpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
312         if (strlen(pnp_dev_name(dev))) {
313                 strncat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
314                 strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
315         }
316
317         i8042_pnp_aux_devices++;
318         return 0;
319 }
320
321 static struct pnp_device_id pnp_kbd_devids[] = {
322         { .id = "PNP0303", .driver_data = 0 },
323         { .id = "PNP030b", .driver_data = 0 },
324         { .id = "", },
325 };
326
327 static struct pnp_driver i8042_pnp_kbd_driver = {
328         .name           = "i8042 kbd",
329         .id_table       = pnp_kbd_devids,
330         .probe          = i8042_pnp_kbd_probe,
331 };
332
333 static struct pnp_device_id pnp_aux_devids[] = {
334         { .id = "FJC6000", .driver_data = 0 },
335         { .id = "FJC6001", .driver_data = 0 },
336         { .id = "PNP0f03", .driver_data = 0 },
337         { .id = "PNP0f0b", .driver_data = 0 },
338         { .id = "PNP0f0e", .driver_data = 0 },
339         { .id = "PNP0f12", .driver_data = 0 },
340         { .id = "PNP0f13", .driver_data = 0 },
341         { .id = "PNP0f19", .driver_data = 0 },
342         { .id = "PNP0f1c", .driver_data = 0 },
343         { .id = "SYN0801", .driver_data = 0 },
344         { .id = "", },
345 };
346
347 static struct pnp_driver i8042_pnp_aux_driver = {
348         .name           = "i8042 aux",
349         .id_table       = pnp_aux_devids,
350         .probe          = i8042_pnp_aux_probe,
351 };
352
353 static void i8042_pnp_exit(void)
354 {
355         if (i8042_pnp_kbd_registered) {
356                 i8042_pnp_kbd_registered = 0;
357                 pnp_unregister_driver(&i8042_pnp_kbd_driver);
358         }
359
360         if (i8042_pnp_aux_registered) {
361                 i8042_pnp_aux_registered = 0;
362                 pnp_unregister_driver(&i8042_pnp_aux_driver);
363         }
364 }
365
366 static int __init i8042_pnp_init(void)
367 {
368         char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
369         int pnp_data_busted = 0;
370         int err;
371
372         if (i8042_nopnp) {
373                 printk(KERN_INFO "i8042: PNP detection disabled\n");
374                 return 0;
375         }
376
377         err = pnp_register_driver(&i8042_pnp_kbd_driver);
378         if (!err)
379                 i8042_pnp_kbd_registered = 1;
380
381         err = pnp_register_driver(&i8042_pnp_aux_driver);
382         if (!err)
383                 i8042_pnp_aux_registered = 1;
384
385         if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
386                 i8042_pnp_exit();
387 #if defined(__ia64__)
388                 return -ENODEV;
389 #else
390                 printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n");
391                 return 0;
392 #endif
393         }
394
395         if (i8042_pnp_kbd_devices)
396                 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
397                         "%d", i8042_pnp_kbd_irq);
398         if (i8042_pnp_aux_devices)
399                 snprintf(aux_irq_str, sizeof(aux_irq_str),
400                         "%d", i8042_pnp_aux_irq);
401
402         printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
403                 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
404                 i8042_pnp_aux_name,
405                 i8042_pnp_data_reg, i8042_pnp_command_reg,
406                 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
407                 aux_irq_str);
408
409 #if defined(__ia64__)
410         if (!i8042_pnp_kbd_devices)
411                 i8042_nokbd = 1;
412         if (!i8042_pnp_aux_devices)
413                 i8042_noaux = 1;
414 #endif
415
416         if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
417               i8042_pnp_data_reg != i8042_data_reg) ||
418             !i8042_pnp_data_reg) {
419                 printk(KERN_WARNING
420                         "PNP: PS/2 controller has invalid data port %#x; "
421                         "using default %#x\n",
422                         i8042_pnp_data_reg, i8042_data_reg);
423                 i8042_pnp_data_reg = i8042_data_reg;
424                 pnp_data_busted = 1;
425         }
426
427         if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
428               i8042_pnp_command_reg != i8042_command_reg) ||
429             !i8042_pnp_command_reg) {
430                 printk(KERN_WARNING
431                         "PNP: PS/2 controller has invalid command port %#x; "
432                         "using default %#x\n",
433                         i8042_pnp_command_reg, i8042_command_reg);
434                 i8042_pnp_command_reg = i8042_command_reg;
435                 pnp_data_busted = 1;
436         }
437
438         if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
439                 printk(KERN_WARNING
440                         "PNP: PS/2 controller doesn't have KBD irq; "
441                         "using default %d\n", i8042_kbd_irq);
442                 i8042_pnp_kbd_irq = i8042_kbd_irq;
443                 pnp_data_busted = 1;
444         }
445
446         if (!i8042_noaux && !i8042_pnp_aux_irq) {
447                 if (!pnp_data_busted && i8042_pnp_kbd_irq) {
448                         printk(KERN_WARNING
449                                 "PNP: PS/2 appears to have AUX port disabled, "
450                                 "if this is incorrect please boot with "
451                                 "i8042.nopnp\n");
452                         i8042_noaux = 1;
453                 } else {
454                         printk(KERN_WARNING
455                                 "PNP: PS/2 controller doesn't have AUX irq; "
456                                 "using default %d\n", i8042_aux_irq);
457                         i8042_pnp_aux_irq = i8042_aux_irq;
458                 }
459         }
460
461         i8042_data_reg = i8042_pnp_data_reg;
462         i8042_command_reg = i8042_pnp_command_reg;
463         i8042_kbd_irq = i8042_pnp_kbd_irq;
464         i8042_aux_irq = i8042_pnp_aux_irq;
465
466         return 0;
467 }
468
469 #else
470 static inline int i8042_pnp_init(void) { return 0; }
471 static inline void i8042_pnp_exit(void) { }
472 #endif
473
474 static int __init i8042_platform_init(void)
475 {
476         int retval;
477
478 /*
479  * On ix86 platforms touching the i8042 data register region can do really
480  * bad things. Because of this the region is always reserved on ix86 boxes.
481  *
482  *      if (!request_region(I8042_DATA_REG, 16, "i8042"))
483  *              return -EBUSY;
484  */
485
486         i8042_kbd_irq = I8042_MAP_IRQ(1);
487         i8042_aux_irq = I8042_MAP_IRQ(12);
488
489         retval = i8042_pnp_init();
490         if (retval)
491                 return retval;
492
493 #if defined(__ia64__)
494         i8042_reset = 1;
495 #endif
496
497 #if defined(__i386__)
498         if (dmi_check_system(i8042_dmi_noloop_table))
499                 i8042_noloop = 1;
500
501         if (dmi_check_system(i8042_dmi_nomux_table))
502                 i8042_nomux = 1;
503 #endif
504
505         return retval;
506 }
507
508 static inline void i8042_platform_exit(void)
509 {
510         i8042_pnp_exit();
511 }
512
513 #endif /* _I8042_X86IA64IO_H */