Input: i8042 - quirks for Fujitsu Lifebook A544 and Lifebook AH544
[cascardo/linux.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 #ifdef CONFIG_X86
11 #include <asm/x86_init.h>
12 #endif
13
14 /*
15  * Names.
16  */
17
18 #define I8042_KBD_PHYS_DESC "isa0060/serio0"
19 #define I8042_AUX_PHYS_DESC "isa0060/serio1"
20 #define I8042_MUX_PHYS_DESC "isa0060/serio%d"
21
22 /*
23  * IRQs.
24  */
25
26 #if defined(__ia64__)
27 # define I8042_MAP_IRQ(x)       isa_irq_to_vector((x))
28 #else
29 # define I8042_MAP_IRQ(x)       (x)
30 #endif
31
32 #define I8042_KBD_IRQ   i8042_kbd_irq
33 #define I8042_AUX_IRQ   i8042_aux_irq
34
35 static int i8042_kbd_irq;
36 static int i8042_aux_irq;
37
38 /*
39  * Register numbers.
40  */
41
42 #define I8042_COMMAND_REG       i8042_command_reg
43 #define I8042_STATUS_REG        i8042_command_reg
44 #define I8042_DATA_REG          i8042_data_reg
45
46 static int i8042_command_reg = 0x64;
47 static int i8042_data_reg = 0x60;
48
49
50 static inline int i8042_read_data(void)
51 {
52         return inb(I8042_DATA_REG);
53 }
54
55 static inline int i8042_read_status(void)
56 {
57         return inb(I8042_STATUS_REG);
58 }
59
60 static inline void i8042_write_data(int val)
61 {
62         outb(val, I8042_DATA_REG);
63 }
64
65 static inline void i8042_write_command(int val)
66 {
67         outb(val, I8042_COMMAND_REG);
68 }
69
70 #ifdef CONFIG_X86
71
72 #include <linux/dmi.h>
73
74 static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = {
75         {
76                 /*
77                  * Arima-Rioworks HDAMB -
78                  * AUX LOOP command does not raise AUX IRQ
79                  */
80                 .matches = {
81                         DMI_MATCH(DMI_BOARD_VENDOR, "RIOWORKS"),
82                         DMI_MATCH(DMI_BOARD_NAME, "HDAMB"),
83                         DMI_MATCH(DMI_BOARD_VERSION, "Rev E"),
84                 },
85         },
86         {
87                 /* ASUS G1S */
88                 .matches = {
89                         DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."),
90                         DMI_MATCH(DMI_BOARD_NAME, "G1S"),
91                         DMI_MATCH(DMI_BOARD_VERSION, "1.0"),
92                 },
93         },
94         {
95                 /* ASUS P65UP5 - AUX LOOP command does not raise AUX IRQ */
96                 .matches = {
97                         DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
98                         DMI_MATCH(DMI_BOARD_NAME, "P/I-P65UP5"),
99                         DMI_MATCH(DMI_BOARD_VERSION, "REV 2.X"),
100                 },
101         },
102         {
103                 .matches = {
104                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
105                         DMI_MATCH(DMI_PRODUCT_NAME, "X750LN"),
106                 },
107         },
108         {
109                 .matches = {
110                         DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
111                         DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
112                         DMI_MATCH(DMI_PRODUCT_VERSION, "8500"),
113                 },
114         },
115         {
116                 .matches = {
117                         DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
118                         DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
119                         DMI_MATCH(DMI_PRODUCT_VERSION, "DL760"),
120                 },
121         },
122         {
123                 /* OQO Model 01 */
124                 .matches = {
125                         DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
126                         DMI_MATCH(DMI_PRODUCT_NAME, "ZEPTO"),
127                         DMI_MATCH(DMI_PRODUCT_VERSION, "00"),
128                 },
129         },
130         {
131                 /* ULI EV4873 - AUX LOOP does not work properly */
132                 .matches = {
133                         DMI_MATCH(DMI_SYS_VENDOR, "ULI"),
134                         DMI_MATCH(DMI_PRODUCT_NAME, "EV4873"),
135                         DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
136                 },
137         },
138         {
139                 /* Microsoft Virtual Machine */
140                 .matches = {
141                         DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
142                         DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
143                         DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"),
144                 },
145         },
146         {
147                 /* Medion MAM 2070 */
148                 .matches = {
149                         DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
150                         DMI_MATCH(DMI_PRODUCT_NAME, "MAM 2070"),
151                         DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
152                 },
153         },
154         {
155                 /* Blue FB5601 */
156                 .matches = {
157                         DMI_MATCH(DMI_SYS_VENDOR, "blue"),
158                         DMI_MATCH(DMI_PRODUCT_NAME, "FB5601"),
159                         DMI_MATCH(DMI_PRODUCT_VERSION, "M606"),
160                 },
161         },
162         {
163                 /* Gigabyte M912 */
164                 .matches = {
165                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
166                         DMI_MATCH(DMI_PRODUCT_NAME, "M912"),
167                         DMI_MATCH(DMI_PRODUCT_VERSION, "01"),
168                 },
169         },
170         {
171                 /* Gigabyte M1022M netbook */
172                 .matches = {
173                         DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co.,Ltd."),
174                         DMI_MATCH(DMI_BOARD_NAME, "M1022E"),
175                         DMI_MATCH(DMI_BOARD_VERSION, "1.02"),
176                 },
177         },
178         {
179                 /* Gigabyte Spring Peak - defines wrong chassis type */
180                 .matches = {
181                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
182                         DMI_MATCH(DMI_PRODUCT_NAME, "Spring Peak"),
183                 },
184         },
185         {
186                 /* Gigabyte T1005 - defines wrong chassis type ("Other") */
187                 .matches = {
188                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
189                         DMI_MATCH(DMI_PRODUCT_NAME, "T1005"),
190                 },
191         },
192         {
193                 /* Gigabyte T1005M/P - defines wrong chassis type ("Other") */
194                 .matches = {
195                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
196                         DMI_MATCH(DMI_PRODUCT_NAME, "T1005M/P"),
197                 },
198         },
199         {
200                 .matches = {
201                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
202                         DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv9700"),
203                         DMI_MATCH(DMI_PRODUCT_VERSION, "Rev 1"),
204                 },
205         },
206         { }
207 };
208
209 /*
210  * Some laptops do implement active multiplexing mode correctly;
211  * unfortunately they are in minority.
212  */
213 static const struct dmi_system_id __initconst i8042_dmi_mux_table[] = {
214         {
215                 /*
216                  * Panasonic CF-18 needs to be in MUX mode since the
217                  * touchscreen is on serio3 and it also has touchpad.
218                  */
219                 .matches = {
220                         DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"),
221                 },
222         },
223         { }
224 };
225
226 static const struct dmi_system_id __initconst i8042_dmi_reset_table[] = {
227         {
228                 /* MSI Wind U-100 */
229                 .matches = {
230                         DMI_MATCH(DMI_BOARD_NAME, "U-100"),
231                         DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
232                 },
233         },
234         {
235                 /* LG Electronics X110 */
236                 .matches = {
237                         DMI_MATCH(DMI_BOARD_NAME, "X110"),
238                         DMI_MATCH(DMI_BOARD_VENDOR, "LG Electronics Inc."),
239                 },
240         },
241         {
242                 /* Acer Aspire One 150 */
243                 .matches = {
244                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
245                         DMI_MATCH(DMI_PRODUCT_NAME, "AOA150"),
246                 },
247         },
248         {
249                 /* Advent 4211 */
250                 .matches = {
251                         DMI_MATCH(DMI_SYS_VENDOR, "DIXONSXP"),
252                         DMI_MATCH(DMI_PRODUCT_NAME, "Advent 4211"),
253                 },
254         },
255         {
256                 /* Medion Akoya Mini E1210 */
257                 .matches = {
258                         DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
259                         DMI_MATCH(DMI_PRODUCT_NAME, "E1210"),
260                 },
261         },
262         {
263                 /* Medion Akoya E1222 */
264                 .matches = {
265                         DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
266                         DMI_MATCH(DMI_PRODUCT_NAME, "E122X"),
267                 },
268         },
269         {
270                 /* Mivvy M310 */
271                 .matches = {
272                         DMI_MATCH(DMI_SYS_VENDOR, "VIOOO"),
273                         DMI_MATCH(DMI_PRODUCT_NAME, "N10"),
274                 },
275         },
276         {
277                 /* Dell Vostro 1320 */
278                 .matches = {
279                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
280                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1320"),
281                 },
282         },
283         {
284                 /* Dell Vostro 1520 */
285                 .matches = {
286                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
287                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1520"),
288                 },
289         },
290         {
291                 /* Dell Vostro 1720 */
292                 .matches = {
293                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
294                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1720"),
295                 },
296         },
297         {
298                 /* Lenovo Ideapad U455 */
299                 .matches = {
300                         DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
301                         DMI_MATCH(DMI_PRODUCT_NAME, "20046"),
302                 },
303         },
304         { }
305 };
306
307 #ifdef CONFIG_PNP
308 static const struct dmi_system_id __initconst i8042_dmi_nopnp_table[] = {
309         {
310                 /* Intel MBO Desktop D845PESV */
311                 .matches = {
312                         DMI_MATCH(DMI_BOARD_NAME, "D845PESV"),
313                         DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
314                 },
315         },
316         {
317                 /* MSI Wind U-100 */
318                 .matches = {
319                         DMI_MATCH(DMI_BOARD_NAME, "U-100"),
320                         DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
321                 },
322         },
323         { }
324 };
325
326 static const struct dmi_system_id __initconst i8042_dmi_laptop_table[] = {
327         {
328                 .matches = {
329                         DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */
330                 },
331         },
332         {
333                 .matches = {
334                         DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /* Laptop */
335                 },
336         },
337         {
338                 .matches = {
339                         DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */
340                 },
341         },
342         {
343                 .matches = {
344                         DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
345                 },
346         },
347         { }
348 };
349 #endif
350
351 static const struct dmi_system_id __initconst i8042_dmi_notimeout_table[] = {
352         {
353                 /* Dell Vostro V13 */
354                 .matches = {
355                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
356                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V13"),
357                 },
358         },
359         {
360                 /* Newer HP Pavilion dv4 models */
361                 .matches = {
362                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
363                         DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"),
364                 },
365         },
366         {
367                 /* Fujitsu A544 laptop */
368                 /* https://bugzilla.redhat.com/show_bug.cgi?id=1111138 */
369                 .matches = {
370                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
371                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK A544"),
372                 },
373         },
374         {
375                 /* Fujitsu AH544 laptop */
376                 /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
377                 .matches = {
378                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
379                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK AH544"),
380                 },
381         },
382         {
383                 /* Fujitsu U574 laptop */
384                 /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
385                 .matches = {
386                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
387                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U574"),
388                 },
389         },
390         { }
391 };
392
393 /*
394  * Some Wistron based laptops need us to explicitly enable the 'Dritek
395  * keyboard extension' to make their extra keys start generating scancodes.
396  * Originally, this was just confined to older laptops, but a few Acer laptops
397  * have turned up in 2007 that also need this again.
398  */
399 static const struct dmi_system_id __initconst i8042_dmi_dritek_table[] = {
400         {
401                 /* Acer Aspire 5100 */
402                 .matches = {
403                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
404                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"),
405                 },
406         },
407         {
408                 /* Acer Aspire 5610 */
409                 .matches = {
410                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
411                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"),
412                 },
413         },
414         {
415                 /* Acer Aspire 5630 */
416                 .matches = {
417                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
418                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5630"),
419                 },
420         },
421         {
422                 /* Acer Aspire 5650 */
423                 .matches = {
424                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
425                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"),
426                 },
427         },
428         {
429                 /* Acer Aspire 5680 */
430                 .matches = {
431                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
432                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"),
433                 },
434         },
435         {
436                 /* Acer Aspire 5720 */
437                 .matches = {
438                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
439                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5720"),
440                 },
441         },
442         {
443                 /* Acer Aspire 9110 */
444                 .matches = {
445                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
446                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 9110"),
447                 },
448         },
449         {
450                 /* Acer TravelMate 660 */
451                 .matches = {
452                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
453                         DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 660"),
454                 },
455         },
456         {
457                 /* Acer TravelMate 2490 */
458                 .matches = {
459                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
460                         DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
461                 },
462         },
463         {
464                 /* Acer TravelMate 4280 */
465                 .matches = {
466                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
467                         DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4280"),
468                 },
469         },
470         { }
471 };
472
473 #endif /* CONFIG_X86 */
474
475 #ifdef CONFIG_PNP
476 #include <linux/pnp.h>
477
478 static bool i8042_pnp_kbd_registered;
479 static unsigned int i8042_pnp_kbd_devices;
480 static bool i8042_pnp_aux_registered;
481 static unsigned int i8042_pnp_aux_devices;
482
483 static int i8042_pnp_command_reg;
484 static int i8042_pnp_data_reg;
485 static int i8042_pnp_kbd_irq;
486 static int i8042_pnp_aux_irq;
487
488 static char i8042_pnp_kbd_name[32];
489 static char i8042_pnp_aux_name[32];
490
491 static void i8042_pnp_id_to_string(struct pnp_id *id, char *dst, int dst_size)
492 {
493         strlcpy(dst, "PNP:", dst_size);
494
495         while (id) {
496                 strlcat(dst, " ", dst_size);
497                 strlcat(dst, id->id, dst_size);
498                 id = id->next;
499         }
500 }
501
502 static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
503 {
504         if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
505                 i8042_pnp_data_reg = pnp_port_start(dev,0);
506
507         if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
508                 i8042_pnp_command_reg = pnp_port_start(dev, 1);
509
510         if (pnp_irq_valid(dev,0))
511                 i8042_pnp_kbd_irq = pnp_irq(dev, 0);
512
513         strlcpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
514         if (strlen(pnp_dev_name(dev))) {
515                 strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
516                 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
517         }
518         i8042_pnp_id_to_string(dev->id, i8042_kbd_firmware_id,
519                                sizeof(i8042_kbd_firmware_id));
520
521         /* Keyboard ports are always supposed to be wakeup-enabled */
522         device_set_wakeup_enable(&dev->dev, true);
523
524         i8042_pnp_kbd_devices++;
525         return 0;
526 }
527
528 static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
529 {
530         if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
531                 i8042_pnp_data_reg = pnp_port_start(dev,0);
532
533         if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
534                 i8042_pnp_command_reg = pnp_port_start(dev, 1);
535
536         if (pnp_irq_valid(dev, 0))
537                 i8042_pnp_aux_irq = pnp_irq(dev, 0);
538
539         strlcpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
540         if (strlen(pnp_dev_name(dev))) {
541                 strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
542                 strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
543         }
544         i8042_pnp_id_to_string(dev->id, i8042_aux_firmware_id,
545                                sizeof(i8042_aux_firmware_id));
546
547         i8042_pnp_aux_devices++;
548         return 0;
549 }
550
551 static struct pnp_device_id pnp_kbd_devids[] = {
552         { .id = "PNP0300", .driver_data = 0 },
553         { .id = "PNP0301", .driver_data = 0 },
554         { .id = "PNP0302", .driver_data = 0 },
555         { .id = "PNP0303", .driver_data = 0 },
556         { .id = "PNP0304", .driver_data = 0 },
557         { .id = "PNP0305", .driver_data = 0 },
558         { .id = "PNP0306", .driver_data = 0 },
559         { .id = "PNP0309", .driver_data = 0 },
560         { .id = "PNP030a", .driver_data = 0 },
561         { .id = "PNP030b", .driver_data = 0 },
562         { .id = "PNP0320", .driver_data = 0 },
563         { .id = "PNP0343", .driver_data = 0 },
564         { .id = "PNP0344", .driver_data = 0 },
565         { .id = "PNP0345", .driver_data = 0 },
566         { .id = "CPQA0D7", .driver_data = 0 },
567         { .id = "", },
568 };
569 MODULE_DEVICE_TABLE(pnp, pnp_kbd_devids);
570
571 static struct pnp_driver i8042_pnp_kbd_driver = {
572         .name           = "i8042 kbd",
573         .id_table       = pnp_kbd_devids,
574         .probe          = i8042_pnp_kbd_probe,
575 };
576
577 static struct pnp_device_id pnp_aux_devids[] = {
578         { .id = "AUI0200", .driver_data = 0 },
579         { .id = "FJC6000", .driver_data = 0 },
580         { .id = "FJC6001", .driver_data = 0 },
581         { .id = "PNP0f03", .driver_data = 0 },
582         { .id = "PNP0f0b", .driver_data = 0 },
583         { .id = "PNP0f0e", .driver_data = 0 },
584         { .id = "PNP0f12", .driver_data = 0 },
585         { .id = "PNP0f13", .driver_data = 0 },
586         { .id = "PNP0f19", .driver_data = 0 },
587         { .id = "PNP0f1c", .driver_data = 0 },
588         { .id = "SYN0801", .driver_data = 0 },
589         { .id = "", },
590 };
591 MODULE_DEVICE_TABLE(pnp, pnp_aux_devids);
592
593 static struct pnp_driver i8042_pnp_aux_driver = {
594         .name           = "i8042 aux",
595         .id_table       = pnp_aux_devids,
596         .probe          = i8042_pnp_aux_probe,
597 };
598
599 static void i8042_pnp_exit(void)
600 {
601         if (i8042_pnp_kbd_registered) {
602                 i8042_pnp_kbd_registered = false;
603                 pnp_unregister_driver(&i8042_pnp_kbd_driver);
604         }
605
606         if (i8042_pnp_aux_registered) {
607                 i8042_pnp_aux_registered = false;
608                 pnp_unregister_driver(&i8042_pnp_aux_driver);
609         }
610 }
611
612 static int __init i8042_pnp_init(void)
613 {
614         char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
615         bool pnp_data_busted = false;
616         int err;
617
618 #ifdef CONFIG_X86
619         if (dmi_check_system(i8042_dmi_nopnp_table))
620                 i8042_nopnp = true;
621 #endif
622
623         if (i8042_nopnp) {
624                 pr_info("PNP detection disabled\n");
625                 return 0;
626         }
627
628         err = pnp_register_driver(&i8042_pnp_kbd_driver);
629         if (!err)
630                 i8042_pnp_kbd_registered = true;
631
632         err = pnp_register_driver(&i8042_pnp_aux_driver);
633         if (!err)
634                 i8042_pnp_aux_registered = true;
635
636         if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
637                 i8042_pnp_exit();
638 #if defined(__ia64__)
639                 return -ENODEV;
640 #else
641                 pr_info("PNP: No PS/2 controller found. Probing ports directly.\n");
642                 return 0;
643 #endif
644         }
645
646         if (i8042_pnp_kbd_devices)
647                 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
648                         "%d", i8042_pnp_kbd_irq);
649         if (i8042_pnp_aux_devices)
650                 snprintf(aux_irq_str, sizeof(aux_irq_str),
651                         "%d", i8042_pnp_aux_irq);
652
653         pr_info("PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
654                 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
655                 i8042_pnp_aux_name,
656                 i8042_pnp_data_reg, i8042_pnp_command_reg,
657                 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
658                 aux_irq_str);
659
660 #if defined(__ia64__)
661         if (!i8042_pnp_kbd_devices)
662                 i8042_nokbd = true;
663         if (!i8042_pnp_aux_devices)
664                 i8042_noaux = true;
665 #endif
666
667         if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
668               i8042_pnp_data_reg != i8042_data_reg) ||
669             !i8042_pnp_data_reg) {
670                 pr_warn("PNP: PS/2 controller has invalid data port %#x; using default %#x\n",
671                         i8042_pnp_data_reg, i8042_data_reg);
672                 i8042_pnp_data_reg = i8042_data_reg;
673                 pnp_data_busted = true;
674         }
675
676         if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
677               i8042_pnp_command_reg != i8042_command_reg) ||
678             !i8042_pnp_command_reg) {
679                 pr_warn("PNP: PS/2 controller has invalid command port %#x; using default %#x\n",
680                         i8042_pnp_command_reg, i8042_command_reg);
681                 i8042_pnp_command_reg = i8042_command_reg;
682                 pnp_data_busted = true;
683         }
684
685         if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
686                 pr_warn("PNP: PS/2 controller doesn't have KBD irq; using default %d\n",
687                         i8042_kbd_irq);
688                 i8042_pnp_kbd_irq = i8042_kbd_irq;
689                 pnp_data_busted = true;
690         }
691
692         if (!i8042_noaux && !i8042_pnp_aux_irq) {
693                 if (!pnp_data_busted && i8042_pnp_kbd_irq) {
694                         pr_warn("PNP: PS/2 appears to have AUX port disabled, "
695                                 "if this is incorrect please boot with i8042.nopnp\n");
696                         i8042_noaux = true;
697                 } else {
698                         pr_warn("PNP: PS/2 controller doesn't have AUX irq; using default %d\n",
699                                 i8042_aux_irq);
700                         i8042_pnp_aux_irq = i8042_aux_irq;
701                 }
702         }
703
704         i8042_data_reg = i8042_pnp_data_reg;
705         i8042_command_reg = i8042_pnp_command_reg;
706         i8042_kbd_irq = i8042_pnp_kbd_irq;
707         i8042_aux_irq = i8042_pnp_aux_irq;
708
709 #ifdef CONFIG_X86
710         i8042_bypass_aux_irq_test = !pnp_data_busted &&
711                                     dmi_check_system(i8042_dmi_laptop_table);
712 #endif
713
714         return 0;
715 }
716
717 #else
718 static inline int i8042_pnp_init(void) { return 0; }
719 static inline void i8042_pnp_exit(void) { }
720 #endif
721
722 static int __init i8042_platform_init(void)
723 {
724         int retval;
725
726 #ifdef CONFIG_X86
727         u8 a20_on = 0xdf;
728         /* Just return if pre-detection shows no i8042 controller exist */
729         if (!x86_platform.i8042_detect())
730                 return -ENODEV;
731 #endif
732
733 /*
734  * On ix86 platforms touching the i8042 data register region can do really
735  * bad things. Because of this the region is always reserved on ix86 boxes.
736  *
737  *      if (!request_region(I8042_DATA_REG, 16, "i8042"))
738  *              return -EBUSY;
739  */
740
741         i8042_kbd_irq = I8042_MAP_IRQ(1);
742         i8042_aux_irq = I8042_MAP_IRQ(12);
743
744         retval = i8042_pnp_init();
745         if (retval)
746                 return retval;
747
748 #if defined(__ia64__)
749         i8042_reset = true;
750 #endif
751
752 #ifdef CONFIG_X86
753         if (dmi_check_system(i8042_dmi_reset_table))
754                 i8042_reset = true;
755
756         if (dmi_check_system(i8042_dmi_noloop_table))
757                 i8042_noloop = true;
758
759         if (dmi_check_system(i8042_dmi_mux_table))
760                 i8042_nomux = false;
761
762         if (dmi_check_system(i8042_dmi_notimeout_table))
763                 i8042_notimeout = true;
764
765         if (dmi_check_system(i8042_dmi_dritek_table))
766                 i8042_dritek = true;
767
768         /*
769          * A20 was already enabled during early kernel init. But some buggy
770          * BIOSes (in MSI Laptops) require A20 to be enabled using 8042 to
771          * resume from S3. So we do it here and hope that nothing breaks.
772          */
773         i8042_command(&a20_on, 0x10d1);
774         i8042_command(NULL, 0x00ff);    /* Null command for SMM firmware */
775 #endif /* CONFIG_X86 */
776
777         return retval;
778 }
779
780 static inline void i8042_platform_exit(void)
781 {
782         i8042_pnp_exit();
783 }
784
785 #endif /* _I8042_X86IA64IO_H */