Input: synaptics - relax capability ID checks on newer hardware
[sfrench/cifs-2.6.git] / 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 #ifdef CONFIG_X86
67
68 #include <linux/dmi.h>
69
70 static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = {
71         {
72                 /*
73                  * Arima-Rioworks HDAMB -
74                  * AUX LOOP command does not raise AUX IRQ
75                  */
76                 .matches = {
77                         DMI_MATCH(DMI_BOARD_VENDOR, "RIOWORKS"),
78                         DMI_MATCH(DMI_BOARD_NAME, "HDAMB"),
79                         DMI_MATCH(DMI_BOARD_VERSION, "Rev E"),
80                 },
81         },
82         {
83                 /* ASUS G1S */
84                 .matches = {
85                         DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."),
86                         DMI_MATCH(DMI_BOARD_NAME, "G1S"),
87                         DMI_MATCH(DMI_BOARD_VERSION, "1.0"),
88                 },
89         },
90         {
91                 /* ASUS P65UP5 - AUX LOOP command does not raise AUX IRQ */
92                 .matches = {
93                         DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
94                         DMI_MATCH(DMI_BOARD_NAME, "P/I-P65UP5"),
95                         DMI_MATCH(DMI_BOARD_VERSION, "REV 2.X"),
96                 },
97         },
98         {
99                 .matches = {
100                         DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
101                         DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
102                         DMI_MATCH(DMI_PRODUCT_VERSION, "8500"),
103                 },
104         },
105         {
106                 .matches = {
107                         DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
108                         DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
109                         DMI_MATCH(DMI_PRODUCT_VERSION, "DL760"),
110                 },
111         },
112         {
113                 /* OQO Model 01 */
114                 .matches = {
115                         DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
116                         DMI_MATCH(DMI_PRODUCT_NAME, "ZEPTO"),
117                         DMI_MATCH(DMI_PRODUCT_VERSION, "00"),
118                 },
119         },
120         {
121                 /* ULI EV4873 - AUX LOOP does not work properly */
122                 .matches = {
123                         DMI_MATCH(DMI_SYS_VENDOR, "ULI"),
124                         DMI_MATCH(DMI_PRODUCT_NAME, "EV4873"),
125                         DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
126                 },
127         },
128         {
129                 /* Microsoft Virtual Machine */
130                 .matches = {
131                         DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
132                         DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
133                         DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"),
134                 },
135         },
136         {
137                 /* Medion MAM 2070 */
138                 .matches = {
139                         DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
140                         DMI_MATCH(DMI_PRODUCT_NAME, "MAM 2070"),
141                         DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
142                 },
143         },
144         {
145                 /* Blue FB5601 */
146                 .matches = {
147                         DMI_MATCH(DMI_SYS_VENDOR, "blue"),
148                         DMI_MATCH(DMI_PRODUCT_NAME, "FB5601"),
149                         DMI_MATCH(DMI_PRODUCT_VERSION, "M606"),
150                 },
151         },
152         {
153                 /* Gigabyte M912 */
154                 .matches = {
155                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
156                         DMI_MATCH(DMI_PRODUCT_NAME, "M912"),
157                         DMI_MATCH(DMI_PRODUCT_VERSION, "01"),
158                 },
159         },
160         {
161                 /* Gigabyte M1022M netbook */
162                 .matches = {
163                         DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co.,Ltd."),
164                         DMI_MATCH(DMI_BOARD_NAME, "M1022E"),
165                         DMI_MATCH(DMI_BOARD_VERSION, "1.02"),
166                 },
167         },
168         {
169                 /* Gigabyte Spring Peak - defines wrong chassis type */
170                 .matches = {
171                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
172                         DMI_MATCH(DMI_PRODUCT_NAME, "Spring Peak"),
173                 },
174         },
175         {
176                 .matches = {
177                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
178                         DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv9700"),
179                         DMI_MATCH(DMI_PRODUCT_VERSION, "Rev 1"),
180                 },
181         },
182         { }
183 };
184
185 /*
186  * Some Fujitsu notebooks are having trouble with touchpads if
187  * active multiplexing mode is activated. Luckily they don't have
188  * external PS/2 ports so we can safely disable it.
189  * ... apparently some Toshibas don't like MUX mode either and
190  * die horrible death on reboot.
191  */
192 static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
193         {
194                 /* Fujitsu Lifebook P7010/P7010D */
195                 .matches = {
196                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
197                         DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
198                 },
199         },
200         {
201                 /* Fujitsu Lifebook P7010 */
202                 .matches = {
203                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
204                         DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
205                 },
206         },
207         {
208                 /* Fujitsu Lifebook P5020D */
209                 .matches = {
210                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
211                         DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
212                 },
213         },
214         {
215                 /* Fujitsu Lifebook S2000 */
216                 .matches = {
217                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
218                         DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
219                 },
220         },
221         {
222                 /* Fujitsu Lifebook S6230 */
223                 .matches = {
224                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
225                         DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
226                 },
227         },
228         {
229                 /* Fujitsu T70H */
230                 .matches = {
231                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
232                         DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
233                 },
234         },
235         {
236                 /* Fujitsu-Siemens Lifebook T3010 */
237                 .matches = {
238                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
239                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
240                 },
241         },
242         {
243                 /* Fujitsu-Siemens Lifebook E4010 */
244                 .matches = {
245                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
246                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
247                 },
248         },
249         {
250                 /* Fujitsu-Siemens Amilo Pro 2010 */
251                 .matches = {
252                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
253                         DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2010"),
254                 },
255         },
256         {
257                 /* Fujitsu-Siemens Amilo Pro 2030 */
258                 .matches = {
259                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
260                         DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
261                 },
262         },
263         {
264                 /*
265                  * No data is coming from the touchscreen unless KBC
266                  * is in legacy mode.
267                  */
268                 /* Panasonic CF-29 */
269                 .matches = {
270                         DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
271                         DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
272                 },
273         },
274         {
275                 /*
276                  * HP Pavilion DV4017EA -
277                  * errors on MUX ports are reported without raising AUXDATA
278                  * causing "spurious NAK" messages.
279                  */
280                 .matches = {
281                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
282                         DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
283                 },
284         },
285         {
286                 /*
287                  * HP Pavilion ZT1000 -
288                  * like DV4017EA does not raise AUXERR for errors on MUX ports.
289                  */
290                 .matches = {
291                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
292                         DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Notebook PC"),
293                         DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook ZT1000"),
294                 },
295         },
296         {
297                 /*
298                  * HP Pavilion DV4270ca -
299                  * like DV4017EA does not raise AUXERR for errors on MUX ports.
300                  */
301                 .matches = {
302                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
303                         DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EH476UA#ABL)"),
304                 },
305         },
306         {
307                 .matches = {
308                         DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
309                         DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
310                 },
311         },
312         {
313                 .matches = {
314                         DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
315                         DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
316                 },
317         },
318         {
319                 .matches = {
320                         DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
321                         DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
322                 },
323         },
324         {
325                 /* Sharp Actius MM20 */
326                 .matches = {
327                         DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
328                         DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
329                 },
330         },
331         {
332                 /* Sony Vaio FS-115b */
333                 .matches = {
334                         DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
335                         DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
336                 },
337         },
338         {
339                 /*
340                  * Sony Vaio FZ-240E -
341                  * reset and GET ID commands issued via KBD port are
342                  * sometimes being delivered to AUX3.
343                  */
344                 .matches = {
345                         DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
346                         DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ240E"),
347                 },
348         },
349         {
350                 /* Amoi M636/A737 */
351                 .matches = {
352                         DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
353                         DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
354                 },
355         },
356         {
357                 /* Lenovo 3000 n100 */
358                 .matches = {
359                         DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
360                         DMI_MATCH(DMI_PRODUCT_NAME, "076804U"),
361                 },
362         },
363         {
364                 .matches = {
365                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
366                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"),
367                 },
368         },
369         {
370                 /* Gericom Bellagio */
371                 .matches = {
372                         DMI_MATCH(DMI_SYS_VENDOR, "Gericom"),
373                         DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"),
374                 },
375         },
376         {
377                 /* IBM 2656 */
378                 .matches = {
379                         DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
380                         DMI_MATCH(DMI_PRODUCT_NAME, "2656"),
381                 },
382         },
383         {
384                 /* Dell XPS M1530 */
385                 .matches = {
386                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
387                         DMI_MATCH(DMI_PRODUCT_NAME, "XPS M1530"),
388                 },
389         },
390         {
391                 /* Compal HEL80I */
392                 .matches = {
393                         DMI_MATCH(DMI_SYS_VENDOR, "COMPAL"),
394                         DMI_MATCH(DMI_PRODUCT_NAME, "HEL80I"),
395                 },
396         },
397         {
398                 /* Dell Vostro 1510 */
399                 .matches = {
400                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
401                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro1510"),
402                 },
403         },
404         {
405                 /* Acer Aspire 5536 */
406                 .matches = {
407                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
408                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5536"),
409                         DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
410                 },
411         },
412         { }
413 };
414
415 static const struct dmi_system_id __initconst i8042_dmi_reset_table[] = {
416         {
417                 /* MSI Wind U-100 */
418                 .matches = {
419                         DMI_MATCH(DMI_BOARD_NAME, "U-100"),
420                         DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
421                 },
422         },
423         {
424                 /* LG Electronics X110 */
425                 .matches = {
426                         DMI_MATCH(DMI_BOARD_NAME, "X110"),
427                         DMI_MATCH(DMI_BOARD_VENDOR, "LG Electronics Inc."),
428                 },
429         },
430         {
431                 /* Acer Aspire One 150 */
432                 .matches = {
433                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
434                         DMI_MATCH(DMI_PRODUCT_NAME, "AOA150"),
435                 },
436         },
437         {
438                 /* Advent 4211 */
439                 .matches = {
440                         DMI_MATCH(DMI_SYS_VENDOR, "DIXONSXP"),
441                         DMI_MATCH(DMI_PRODUCT_NAME, "Advent 4211"),
442                 },
443         },
444         {
445                 /* Medion Akoya Mini E1210 */
446                 .matches = {
447                         DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
448                         DMI_MATCH(DMI_PRODUCT_NAME, "E1210"),
449                 },
450         },
451         {
452                 /* Medion Akoya E1222 */
453                 .matches = {
454                         DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
455                         DMI_MATCH(DMI_PRODUCT_NAME, "E122X"),
456                 },
457         },
458         {
459                 /* Mivvy M310 */
460                 .matches = {
461                         DMI_MATCH(DMI_SYS_VENDOR, "VIOOO"),
462                         DMI_MATCH(DMI_PRODUCT_NAME, "N10"),
463                 },
464         },
465         {
466                 /* Dell Vostro 1320 */
467                 .matches = {
468                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
469                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1320"),
470                 },
471         },
472         {
473                 /* Dell Vostro 1520 */
474                 .matches = {
475                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
476                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1520"),
477                 },
478         },
479         {
480                 /* Dell Vostro 1720 */
481                 .matches = {
482                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
483                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1720"),
484                 },
485         },
486         { }
487 };
488
489 #ifdef CONFIG_PNP
490 static const struct dmi_system_id __initconst i8042_dmi_nopnp_table[] = {
491         {
492                 /* Intel MBO Desktop D845PESV */
493                 .matches = {
494                         DMI_MATCH(DMI_BOARD_NAME, "D845PESV"),
495                         DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
496                 },
497         },
498         {
499                 /* MSI Wind U-100 */
500                 .matches = {
501                         DMI_MATCH(DMI_BOARD_NAME, "U-100"),
502                         DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
503                 },
504         },
505         { }
506 };
507
508 static const struct dmi_system_id __initconst i8042_dmi_laptop_table[] = {
509         {
510                 .matches = {
511                         DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */
512                 },
513         },
514         {
515                 .matches = {
516                         DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /* Laptop */
517                 },
518         },
519         {
520                 .matches = {
521                         DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */
522                 },
523         },
524         {
525                 .matches = {
526                         DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
527                 },
528         },
529         { }
530 };
531 #endif
532
533 /*
534  * Some Wistron based laptops need us to explicitly enable the 'Dritek
535  * keyboard extension' to make their extra keys start generating scancodes.
536  * Originally, this was just confined to older laptops, but a few Acer laptops
537  * have turned up in 2007 that also need this again.
538  */
539 static const struct dmi_system_id __initconst i8042_dmi_dritek_table[] = {
540         {
541                 /* Acer Aspire 5610 */
542                 .matches = {
543                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
544                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"),
545                 },
546         },
547         {
548                 /* Acer Aspire 5630 */
549                 .matches = {
550                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
551                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5630"),
552                 },
553         },
554         {
555                 /* Acer Aspire 5650 */
556                 .matches = {
557                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
558                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"),
559                 },
560         },
561         {
562                 /* Acer Aspire 5680 */
563                 .matches = {
564                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
565                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"),
566                 },
567         },
568         {
569                 /* Acer Aspire 5720 */
570                 .matches = {
571                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
572                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5720"),
573                 },
574         },
575         {
576                 /* Acer Aspire 9110 */
577                 .matches = {
578                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
579                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 9110"),
580                 },
581         },
582         {
583                 /* Acer TravelMate 660 */
584                 .matches = {
585                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
586                         DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 660"),
587                 },
588         },
589         {
590                 /* Acer TravelMate 2490 */
591                 .matches = {
592                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
593                         DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
594                 },
595         },
596         {
597                 /* Acer TravelMate 4280 */
598                 .matches = {
599                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
600                         DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4280"),
601                 },
602         },
603         { }
604 };
605
606 #endif /* CONFIG_X86 */
607
608 #ifdef CONFIG_PNP
609 #include <linux/pnp.h>
610
611 static bool i8042_pnp_kbd_registered;
612 static unsigned int i8042_pnp_kbd_devices;
613 static bool i8042_pnp_aux_registered;
614 static unsigned int i8042_pnp_aux_devices;
615
616 static int i8042_pnp_command_reg;
617 static int i8042_pnp_data_reg;
618 static int i8042_pnp_kbd_irq;
619 static int i8042_pnp_aux_irq;
620
621 static char i8042_pnp_kbd_name[32];
622 static char i8042_pnp_aux_name[32];
623
624 static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
625 {
626         if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
627                 i8042_pnp_data_reg = pnp_port_start(dev,0);
628
629         if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
630                 i8042_pnp_command_reg = pnp_port_start(dev, 1);
631
632         if (pnp_irq_valid(dev,0))
633                 i8042_pnp_kbd_irq = pnp_irq(dev, 0);
634
635         strlcpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
636         if (strlen(pnp_dev_name(dev))) {
637                 strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
638                 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
639         }
640
641         /* Keyboard ports are always supposed to be wakeup-enabled */
642         device_set_wakeup_enable(&dev->dev, true);
643
644         i8042_pnp_kbd_devices++;
645         return 0;
646 }
647
648 static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
649 {
650         if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
651                 i8042_pnp_data_reg = pnp_port_start(dev,0);
652
653         if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
654                 i8042_pnp_command_reg = pnp_port_start(dev, 1);
655
656         if (pnp_irq_valid(dev, 0))
657                 i8042_pnp_aux_irq = pnp_irq(dev, 0);
658
659         strlcpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
660         if (strlen(pnp_dev_name(dev))) {
661                 strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
662                 strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
663         }
664
665         i8042_pnp_aux_devices++;
666         return 0;
667 }
668
669 static struct pnp_device_id pnp_kbd_devids[] = {
670         { .id = "PNP0300", .driver_data = 0 },
671         { .id = "PNP0301", .driver_data = 0 },
672         { .id = "PNP0302", .driver_data = 0 },
673         { .id = "PNP0303", .driver_data = 0 },
674         { .id = "PNP0304", .driver_data = 0 },
675         { .id = "PNP0305", .driver_data = 0 },
676         { .id = "PNP0306", .driver_data = 0 },
677         { .id = "PNP0309", .driver_data = 0 },
678         { .id = "PNP030a", .driver_data = 0 },
679         { .id = "PNP030b", .driver_data = 0 },
680         { .id = "PNP0320", .driver_data = 0 },
681         { .id = "PNP0343", .driver_data = 0 },
682         { .id = "PNP0344", .driver_data = 0 },
683         { .id = "PNP0345", .driver_data = 0 },
684         { .id = "CPQA0D7", .driver_data = 0 },
685         { .id = "", },
686 };
687
688 static struct pnp_driver i8042_pnp_kbd_driver = {
689         .name           = "i8042 kbd",
690         .id_table       = pnp_kbd_devids,
691         .probe          = i8042_pnp_kbd_probe,
692 };
693
694 static struct pnp_device_id pnp_aux_devids[] = {
695         { .id = "AUI0200", .driver_data = 0 },
696         { .id = "FJC6000", .driver_data = 0 },
697         { .id = "FJC6001", .driver_data = 0 },
698         { .id = "PNP0f03", .driver_data = 0 },
699         { .id = "PNP0f0b", .driver_data = 0 },
700         { .id = "PNP0f0e", .driver_data = 0 },
701         { .id = "PNP0f12", .driver_data = 0 },
702         { .id = "PNP0f13", .driver_data = 0 },
703         { .id = "PNP0f19", .driver_data = 0 },
704         { .id = "PNP0f1c", .driver_data = 0 },
705         { .id = "SYN0801", .driver_data = 0 },
706         { .id = "", },
707 };
708
709 static struct pnp_driver i8042_pnp_aux_driver = {
710         .name           = "i8042 aux",
711         .id_table       = pnp_aux_devids,
712         .probe          = i8042_pnp_aux_probe,
713 };
714
715 static void i8042_pnp_exit(void)
716 {
717         if (i8042_pnp_kbd_registered) {
718                 i8042_pnp_kbd_registered = false;
719                 pnp_unregister_driver(&i8042_pnp_kbd_driver);
720         }
721
722         if (i8042_pnp_aux_registered) {
723                 i8042_pnp_aux_registered = false;
724                 pnp_unregister_driver(&i8042_pnp_aux_driver);
725         }
726 }
727
728 static int __init i8042_pnp_init(void)
729 {
730         char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
731         bool pnp_data_busted = false;
732         int err;
733
734 #ifdef CONFIG_X86
735         if (dmi_check_system(i8042_dmi_nopnp_table))
736                 i8042_nopnp = true;
737 #endif
738
739         if (i8042_nopnp) {
740                 printk(KERN_INFO "i8042: PNP detection disabled\n");
741                 return 0;
742         }
743
744         err = pnp_register_driver(&i8042_pnp_kbd_driver);
745         if (!err)
746                 i8042_pnp_kbd_registered = true;
747
748         err = pnp_register_driver(&i8042_pnp_aux_driver);
749         if (!err)
750                 i8042_pnp_aux_registered = true;
751
752         if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
753                 i8042_pnp_exit();
754 #if defined(__ia64__)
755                 return -ENODEV;
756 #else
757                 printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n");
758                 return 0;
759 #endif
760         }
761
762         if (i8042_pnp_kbd_devices)
763                 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
764                         "%d", i8042_pnp_kbd_irq);
765         if (i8042_pnp_aux_devices)
766                 snprintf(aux_irq_str, sizeof(aux_irq_str),
767                         "%d", i8042_pnp_aux_irq);
768
769         printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
770                 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
771                 i8042_pnp_aux_name,
772                 i8042_pnp_data_reg, i8042_pnp_command_reg,
773                 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
774                 aux_irq_str);
775
776 #if defined(__ia64__)
777         if (!i8042_pnp_kbd_devices)
778                 i8042_nokbd = true;
779         if (!i8042_pnp_aux_devices)
780                 i8042_noaux = true;
781 #endif
782
783         if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
784               i8042_pnp_data_reg != i8042_data_reg) ||
785             !i8042_pnp_data_reg) {
786                 printk(KERN_WARNING
787                         "PNP: PS/2 controller has invalid data port %#x; "
788                         "using default %#x\n",
789                         i8042_pnp_data_reg, i8042_data_reg);
790                 i8042_pnp_data_reg = i8042_data_reg;
791                 pnp_data_busted = true;
792         }
793
794         if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
795               i8042_pnp_command_reg != i8042_command_reg) ||
796             !i8042_pnp_command_reg) {
797                 printk(KERN_WARNING
798                         "PNP: PS/2 controller has invalid command port %#x; "
799                         "using default %#x\n",
800                         i8042_pnp_command_reg, i8042_command_reg);
801                 i8042_pnp_command_reg = i8042_command_reg;
802                 pnp_data_busted = true;
803         }
804
805         if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
806                 printk(KERN_WARNING
807                         "PNP: PS/2 controller doesn't have KBD irq; "
808                         "using default %d\n", i8042_kbd_irq);
809                 i8042_pnp_kbd_irq = i8042_kbd_irq;
810                 pnp_data_busted = true;
811         }
812
813         if (!i8042_noaux && !i8042_pnp_aux_irq) {
814                 if (!pnp_data_busted && i8042_pnp_kbd_irq) {
815                         printk(KERN_WARNING
816                                 "PNP: PS/2 appears to have AUX port disabled, "
817                                 "if this is incorrect please boot with "
818                                 "i8042.nopnp\n");
819                         i8042_noaux = true;
820                 } else {
821                         printk(KERN_WARNING
822                                 "PNP: PS/2 controller doesn't have AUX irq; "
823                                 "using default %d\n", i8042_aux_irq);
824                         i8042_pnp_aux_irq = i8042_aux_irq;
825                 }
826         }
827
828         i8042_data_reg = i8042_pnp_data_reg;
829         i8042_command_reg = i8042_pnp_command_reg;
830         i8042_kbd_irq = i8042_pnp_kbd_irq;
831         i8042_aux_irq = i8042_pnp_aux_irq;
832
833 #ifdef CONFIG_X86
834         i8042_bypass_aux_irq_test = !pnp_data_busted &&
835                                     dmi_check_system(i8042_dmi_laptop_table);
836 #endif
837
838         return 0;
839 }
840
841 #else
842 static inline int i8042_pnp_init(void) { return 0; }
843 static inline void i8042_pnp_exit(void) { }
844 #endif
845
846 static int __init i8042_platform_init(void)
847 {
848         int retval;
849
850 /*
851  * On ix86 platforms touching the i8042 data register region can do really
852  * bad things. Because of this the region is always reserved on ix86 boxes.
853  *
854  *      if (!request_region(I8042_DATA_REG, 16, "i8042"))
855  *              return -EBUSY;
856  */
857
858         i8042_kbd_irq = I8042_MAP_IRQ(1);
859         i8042_aux_irq = I8042_MAP_IRQ(12);
860
861         retval = i8042_pnp_init();
862         if (retval)
863                 return retval;
864
865 #if defined(__ia64__)
866         i8042_reset = true;
867 #endif
868
869 #ifdef CONFIG_X86
870         if (dmi_check_system(i8042_dmi_reset_table))
871                 i8042_reset = true;
872
873         if (dmi_check_system(i8042_dmi_noloop_table))
874                 i8042_noloop = true;
875
876         if (dmi_check_system(i8042_dmi_nomux_table))
877                 i8042_nomux = true;
878
879         if (dmi_check_system(i8042_dmi_dritek_table))
880                 i8042_dritek = true;
881 #endif /* CONFIG_X86 */
882
883         return retval;
884 }
885
886 static inline void i8042_platform_exit(void)
887 {
888         i8042_pnp_exit();
889 }
890
891 #endif /* _I8042_X86IA64IO_H */