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