GNU Linux-libre 4.9.290-gnu1
[releases.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                 /* Dell Embedded Box PC 3000 */
124                 .matches = {
125                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
126                         DMI_MATCH(DMI_PRODUCT_NAME, "Embedded Box PC 3000"),
127                 },
128         },
129         {
130                 /* OQO Model 01 */
131                 .matches = {
132                         DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
133                         DMI_MATCH(DMI_PRODUCT_NAME, "ZEPTO"),
134                         DMI_MATCH(DMI_PRODUCT_VERSION, "00"),
135                 },
136         },
137         {
138                 /* ULI EV4873 - AUX LOOP does not work properly */
139                 .matches = {
140                         DMI_MATCH(DMI_SYS_VENDOR, "ULI"),
141                         DMI_MATCH(DMI_PRODUCT_NAME, "EV4873"),
142                         DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
143                 },
144         },
145         {
146                 /* Microsoft Virtual Machine */
147                 .matches = {
148                         DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
149                         DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
150                         DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"),
151                 },
152         },
153         {
154                 /* Medion MAM 2070 */
155                 .matches = {
156                         DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
157                         DMI_MATCH(DMI_PRODUCT_NAME, "MAM 2070"),
158                         DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
159                 },
160         },
161         {
162                 /* Medion Akoya E7225 */
163                 .matches = {
164                         DMI_MATCH(DMI_SYS_VENDOR, "Medion"),
165                         DMI_MATCH(DMI_PRODUCT_NAME, "Akoya E7225"),
166                         DMI_MATCH(DMI_PRODUCT_VERSION, "1.0"),
167                 },
168         },
169         {
170                 /* Blue FB5601 */
171                 .matches = {
172                         DMI_MATCH(DMI_SYS_VENDOR, "blue"),
173                         DMI_MATCH(DMI_PRODUCT_NAME, "FB5601"),
174                         DMI_MATCH(DMI_PRODUCT_VERSION, "M606"),
175                 },
176         },
177         {
178                 /* Gigabyte M912 */
179                 .matches = {
180                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
181                         DMI_MATCH(DMI_PRODUCT_NAME, "M912"),
182                         DMI_MATCH(DMI_PRODUCT_VERSION, "01"),
183                 },
184         },
185         {
186                 /* Gigabyte M1022M netbook */
187                 .matches = {
188                         DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co.,Ltd."),
189                         DMI_MATCH(DMI_BOARD_NAME, "M1022E"),
190                         DMI_MATCH(DMI_BOARD_VERSION, "1.02"),
191                 },
192         },
193         {
194                 /* Gigabyte Spring Peak - defines wrong chassis type */
195                 .matches = {
196                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
197                         DMI_MATCH(DMI_PRODUCT_NAME, "Spring Peak"),
198                 },
199         },
200         {
201                 /* Gigabyte T1005 - defines wrong chassis type ("Other") */
202                 .matches = {
203                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
204                         DMI_MATCH(DMI_PRODUCT_NAME, "T1005"),
205                 },
206         },
207         {
208                 /* Gigabyte T1005M/P - defines wrong chassis type ("Other") */
209                 .matches = {
210                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
211                         DMI_MATCH(DMI_PRODUCT_NAME, "T1005M/P"),
212                 },
213         },
214         {
215                 .matches = {
216                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
217                         DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv9700"),
218                         DMI_MATCH(DMI_PRODUCT_VERSION, "Rev 1"),
219                 },
220         },
221         {
222                 .matches = {
223                         DMI_MATCH(DMI_SYS_VENDOR, "PEGATRON CORPORATION"),
224                         DMI_MATCH(DMI_PRODUCT_NAME, "C15B"),
225                 },
226         },
227         {
228                 .matches = {
229                         DMI_MATCH(DMI_SYS_VENDOR, "ByteSpeed LLC"),
230                         DMI_MATCH(DMI_PRODUCT_NAME, "ByteSpeed Laptop C15B"),
231                 },
232         },
233         { }
234 };
235
236 /*
237  * Some Fujitsu notebooks are having trouble with touchpads if
238  * active multiplexing mode is activated. Luckily they don't have
239  * external PS/2 ports so we can safely disable it.
240  * ... apparently some Toshibas don't like MUX mode either and
241  * die horrible death on reboot.
242  */
243 static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
244         {
245                 /* Fujitsu Lifebook P7010/P7010D */
246                 .matches = {
247                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
248                         DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
249                 },
250         },
251         {
252                 /* Fujitsu Lifebook P7010 */
253                 .matches = {
254                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
255                         DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
256                 },
257         },
258         {
259                 /* Fujitsu Lifebook P5020D */
260                 .matches = {
261                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
262                         DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
263                 },
264         },
265         {
266                 /* Fujitsu Lifebook S2000 */
267                 .matches = {
268                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
269                         DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
270                 },
271         },
272         {
273                 /* Fujitsu Lifebook S6230 */
274                 .matches = {
275                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
276                         DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
277                 },
278         },
279         {
280                 /* Fujitsu Lifebook U745 */
281                 .matches = {
282                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
283                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U745"),
284                 },
285         },
286         {
287                 /* Fujitsu T70H */
288                 .matches = {
289                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
290                         DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
291                 },
292         },
293         {
294                 /* Fujitsu-Siemens Lifebook T3010 */
295                 .matches = {
296                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
297                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
298                 },
299         },
300         {
301                 /* Fujitsu-Siemens Lifebook E4010 */
302                 .matches = {
303                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
304                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
305                 },
306         },
307         {
308                 /* Fujitsu-Siemens Amilo Pro 2010 */
309                 .matches = {
310                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
311                         DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2010"),
312                 },
313         },
314         {
315                 /* Fujitsu-Siemens Amilo Pro 2030 */
316                 .matches = {
317                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
318                         DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
319                 },
320         },
321         {
322                 /*
323                  * No data is coming from the touchscreen unless KBC
324                  * is in legacy mode.
325                  */
326                 /* Panasonic CF-29 */
327                 .matches = {
328                         DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
329                         DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
330                 },
331         },
332         {
333                 /*
334                  * HP Pavilion DV4017EA -
335                  * errors on MUX ports are reported without raising AUXDATA
336                  * causing "spurious NAK" messages.
337                  */
338                 .matches = {
339                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
340                         DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
341                 },
342         },
343         {
344                 /*
345                  * HP Pavilion ZT1000 -
346                  * like DV4017EA does not raise AUXERR for errors on MUX ports.
347                  */
348                 .matches = {
349                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
350                         DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Notebook PC"),
351                         DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook ZT1000"),
352                 },
353         },
354         {
355                 /*
356                  * HP Pavilion DV4270ca -
357                  * like DV4017EA does not raise AUXERR for errors on MUX ports.
358                  */
359                 .matches = {
360                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
361                         DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EH476UA#ABL)"),
362                 },
363         },
364         {
365                 .matches = {
366                         DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
367                         DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
368                 },
369         },
370         {
371                 .matches = {
372                         DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
373                         DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
374                 },
375         },
376         {
377                 .matches = {
378                         DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
379                         DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE C850D"),
380                 },
381         },
382         {
383                 .matches = {
384                         DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
385                         DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
386                 },
387         },
388         {
389                 /* Sharp Actius MM20 */
390                 .matches = {
391                         DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
392                         DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
393                 },
394         },
395         {
396                 /* Sony Vaio FS-115b */
397                 .matches = {
398                         DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
399                         DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
400                 },
401         },
402         {
403                 /*
404                  * Sony Vaio FZ-240E -
405                  * reset and GET ID commands issued via KBD port are
406                  * sometimes being delivered to AUX3.
407                  */
408                 .matches = {
409                         DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
410                         DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ240E"),
411                 },
412         },
413         {
414                 /*
415                  * Most (all?) VAIOs do not have external PS/2 ports nor
416                  * they implement active multiplexing properly, and
417                  * MUX discovery usually messes up keyboard/touchpad.
418                  */
419                 .matches = {
420                         DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
421                         DMI_MATCH(DMI_BOARD_NAME, "VAIO"),
422                 },
423         },
424         {
425                 /* Amoi M636/A737 */
426                 .matches = {
427                         DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
428                         DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
429                 },
430         },
431         {
432                 /* Lenovo 3000 n100 */
433                 .matches = {
434                         DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
435                         DMI_MATCH(DMI_PRODUCT_NAME, "076804U"),
436                 },
437         },
438         {
439                 /* Lenovo XiaoXin Air 12 */
440                 .matches = {
441                         DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
442                         DMI_MATCH(DMI_PRODUCT_NAME, "80UN"),
443                 },
444         },
445         {
446                 .matches = {
447                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
448                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"),
449                 },
450         },
451         {
452                 /* Acer Aspire 5710 */
453                 .matches = {
454                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
455                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5710"),
456                 },
457         },
458         {
459                 /* Acer Aspire 7738 */
460                 .matches = {
461                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
462                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7738"),
463                 },
464         },
465         {
466                 /* Gericom Bellagio */
467                 .matches = {
468                         DMI_MATCH(DMI_SYS_VENDOR, "Gericom"),
469                         DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"),
470                 },
471         },
472         {
473                 /* IBM 2656 */
474                 .matches = {
475                         DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
476                         DMI_MATCH(DMI_PRODUCT_NAME, "2656"),
477                 },
478         },
479         {
480                 /* Dell XPS M1530 */
481                 .matches = {
482                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
483                         DMI_MATCH(DMI_PRODUCT_NAME, "XPS M1530"),
484                 },
485         },
486         {
487                 /* Compal HEL80I */
488                 .matches = {
489                         DMI_MATCH(DMI_SYS_VENDOR, "COMPAL"),
490                         DMI_MATCH(DMI_PRODUCT_NAME, "HEL80I"),
491                 },
492         },
493         {
494                 /* Dell Vostro 1510 */
495                 .matches = {
496                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
497                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro1510"),
498                 },
499         },
500         {
501                 /* Acer Aspire 5536 */
502                 .matches = {
503                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
504                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5536"),
505                         DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
506                 },
507         },
508         {
509                 /* Dell Vostro V13 */
510                 .matches = {
511                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
512                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V13"),
513                 },
514         },
515         {
516                 /* Newer HP Pavilion dv4 models */
517                 .matches = {
518                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
519                         DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"),
520                 },
521         },
522         {
523                 /* Asus X450LCP */
524                 .matches = {
525                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
526                         DMI_MATCH(DMI_PRODUCT_NAME, "X450LCP"),
527                 },
528         },
529         {
530                 /* Avatar AVIU-145A6 */
531                 .matches = {
532                         DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
533                         DMI_MATCH(DMI_PRODUCT_NAME, "IC4I"),
534                 },
535         },
536         {
537                 /* TUXEDO BU1406 */
538                 .matches = {
539                         DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
540                         DMI_MATCH(DMI_PRODUCT_NAME, "N24_25BU"),
541                 },
542         },
543         {
544                 /* Lenovo LaVie Z */
545                 .matches = {
546                         DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
547                         DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo LaVie Z"),
548                 },
549         },
550         {
551                 /*
552                  * Acer Aspire 5738z
553                  * Touchpad stops working in mux mode when dis- + re-enabled
554                  * with the touchpad enable/disable toggle hotkey
555                  */
556                 .matches = {
557                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
558                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"),
559                 },
560         },
561         {
562                 /* Entroware Proteus */
563                 .matches = {
564                         DMI_MATCH(DMI_SYS_VENDOR, "Entroware"),
565                         DMI_MATCH(DMI_PRODUCT_NAME, "Proteus"),
566                         DMI_MATCH(DMI_PRODUCT_VERSION, "EL07R4"),
567                 },
568         },
569         { }
570 };
571
572 static const struct dmi_system_id i8042_dmi_forcemux_table[] __initconst = {
573         {
574                 /*
575                  * Sony Vaio VGN-CS series require MUX or the touch sensor
576                  * buttons will disturb touchpad operation
577                  */
578                 .matches = {
579                         DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
580                         DMI_MATCH(DMI_PRODUCT_NAME, "VGN-CS"),
581                 },
582         }, {
583                 .matches = {
584                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
585                         DMI_MATCH(DMI_CHASSIS_TYPE, "31"), /* Convertible Notebook */
586                 },
587         },
588         { }
589 };
590
591 /*
592  * On some Asus laptops, just running self tests cause problems.
593  */
594 static const struct dmi_system_id i8042_dmi_noselftest_table[] = {
595         {
596                 .matches = {
597                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
598                         DMI_MATCH(DMI_PRODUCT_NAME, "A455LD"),
599                 },
600         },
601         {
602                 .matches = {
603                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
604                         DMI_MATCH(DMI_PRODUCT_NAME, "K401LB"),
605                 },
606         },
607         {
608                 .matches = {
609                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
610                         DMI_MATCH(DMI_PRODUCT_NAME, "K501LB"),
611                 },
612         },
613         {
614                 .matches = {
615                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
616                         DMI_MATCH(DMI_PRODUCT_NAME, "K501LX"),
617                 },
618         },
619         {
620                 .matches = {
621                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
622                         DMI_MATCH(DMI_PRODUCT_NAME, "R409L"),
623                 },
624         },
625         {
626                 .matches = {
627                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
628                         DMI_MATCH(DMI_PRODUCT_NAME, "V502LX"),
629                 },
630         },
631         {
632                 .matches = {
633                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
634                         DMI_MATCH(DMI_PRODUCT_NAME, "X302LA"),
635                 },
636         },
637         {
638                 .matches = {
639                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
640                         DMI_MATCH(DMI_PRODUCT_NAME, "X450LCP"),
641                 },
642         },
643         {
644                 .matches = {
645                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
646                         DMI_MATCH(DMI_PRODUCT_NAME, "X450LD"),
647                 },
648         },
649         {
650                 .matches = {
651                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
652                         DMI_MATCH(DMI_PRODUCT_NAME, "X455LAB"),
653                 },
654         },
655         {
656                 .matches = {
657                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
658                         DMI_MATCH(DMI_PRODUCT_NAME, "X455LDB"),
659                 },
660         },
661         {
662                 .matches = {
663                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
664                         DMI_MATCH(DMI_PRODUCT_NAME, "X455LF"),
665                 },
666         },
667         {
668                 .matches = {
669                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
670                         DMI_MATCH(DMI_PRODUCT_NAME, "Z450LA"),
671                 },
672         },
673         { }
674 };
675 static const struct dmi_system_id __initconst i8042_dmi_reset_table[] = {
676         {
677                 /* MSI Wind U-100 */
678                 .matches = {
679                         DMI_MATCH(DMI_BOARD_NAME, "U-100"),
680                         DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
681                 },
682         },
683         {
684                 /* LG Electronics X110 */
685                 .matches = {
686                         DMI_MATCH(DMI_BOARD_NAME, "X110"),
687                         DMI_MATCH(DMI_BOARD_VENDOR, "LG Electronics Inc."),
688                 },
689         },
690         {
691                 /* Acer Aspire One 150 */
692                 .matches = {
693                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
694                         DMI_MATCH(DMI_PRODUCT_NAME, "AOA150"),
695                 },
696         },
697         {
698                 .matches = {
699                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
700                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire A114-31"),
701                 },
702         },
703         {
704                 .matches = {
705                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
706                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire A314-31"),
707                 },
708         },
709         {
710                 .matches = {
711                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
712                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire A315-31"),
713                 },
714         },
715         {
716                 .matches = {
717                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
718                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire ES1-132"),
719                 },
720         },
721         {
722                 .matches = {
723                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
724                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire ES1-332"),
725                 },
726         },
727         {
728                 .matches = {
729                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
730                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire ES1-432"),
731                 },
732         },
733         {
734                 .matches = {
735                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
736                         DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate Spin B118-RN"),
737                 },
738         },
739         {
740                 /* Advent 4211 */
741                 .matches = {
742                         DMI_MATCH(DMI_SYS_VENDOR, "DIXONSXP"),
743                         DMI_MATCH(DMI_PRODUCT_NAME, "Advent 4211"),
744                 },
745         },
746         {
747                 /* Medion Akoya Mini E1210 */
748                 .matches = {
749                         DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
750                         DMI_MATCH(DMI_PRODUCT_NAME, "E1210"),
751                 },
752         },
753         {
754                 /* Medion Akoya E1222 */
755                 .matches = {
756                         DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
757                         DMI_MATCH(DMI_PRODUCT_NAME, "E122X"),
758                 },
759         },
760         {
761                 /* Mivvy M310 */
762                 .matches = {
763                         DMI_MATCH(DMI_SYS_VENDOR, "VIOOO"),
764                         DMI_MATCH(DMI_PRODUCT_NAME, "N10"),
765                 },
766         },
767         {
768                 /* Dell Vostro 1320 */
769                 .matches = {
770                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
771                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1320"),
772                 },
773         },
774         {
775                 /* Dell Vostro 1520 */
776                 .matches = {
777                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
778                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1520"),
779                 },
780         },
781         {
782                 /* Dell Vostro 1720 */
783                 .matches = {
784                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
785                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1720"),
786                 },
787         },
788         {
789                 /* Lenovo Ideapad U455 */
790                 .matches = {
791                         DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
792                         DMI_MATCH(DMI_PRODUCT_NAME, "20046"),
793                 },
794         },
795         {
796                 /* Lenovo ThinkPad L460 */
797                 .matches = {
798                         DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
799                         DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L460"),
800                 },
801         },
802         {
803                 /* Clevo P650RS, 650RP6, Sager NP8152-S, and others */
804                 .matches = {
805                         DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
806                         DMI_MATCH(DMI_PRODUCT_NAME, "P65xRP"),
807                 },
808         },
809         {
810                 /* Lenovo ThinkPad Twist S230u */
811                 .matches = {
812                         DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
813                         DMI_MATCH(DMI_PRODUCT_NAME, "33474HU"),
814                 },
815         },
816         {
817                 /* Entroware Proteus */
818                 .matches = {
819                         DMI_MATCH(DMI_SYS_VENDOR, "Entroware"),
820                         DMI_MATCH(DMI_PRODUCT_NAME, "Proteus"),
821                         DMI_MATCH(DMI_PRODUCT_VERSION, "EL07R4"),
822                 },
823         },
824         { }
825 };
826
827 #ifdef CONFIG_PNP
828 static const struct dmi_system_id __initconst i8042_dmi_nopnp_table[] = {
829         {
830                 /* Intel MBO Desktop D845PESV */
831                 .matches = {
832                         DMI_MATCH(DMI_BOARD_NAME, "D845PESV"),
833                         DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
834                 },
835         },
836         {
837                 /*
838                  * Intel NUC D54250WYK - does not have i8042 controller but
839                  * declares PS/2 devices in DSDT.
840                  */
841                 .matches = {
842                         DMI_MATCH(DMI_BOARD_NAME, "D54250WYK"),
843                         DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
844                 },
845         },
846         {
847                 /* MSI Wind U-100 */
848                 .matches = {
849                         DMI_MATCH(DMI_BOARD_NAME, "U-100"),
850                         DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
851                 },
852         },
853         {
854                 /* Acer Aspire 5 A515 */
855                 .matches = {
856                         DMI_MATCH(DMI_BOARD_NAME, "Grumpy_PK"),
857                         DMI_MATCH(DMI_BOARD_VENDOR, "PK"),
858                 },
859         },
860         { }
861 };
862
863 static const struct dmi_system_id __initconst i8042_dmi_laptop_table[] = {
864         {
865                 .matches = {
866                         DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */
867                 },
868         },
869         {
870                 .matches = {
871                         DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /* Laptop */
872                 },
873         },
874         {
875                 .matches = {
876                         DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */
877                 },
878         },
879         {
880                 .matches = {
881                         DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
882                 },
883         },
884         { }
885 };
886 #endif
887
888 static const struct dmi_system_id __initconst i8042_dmi_notimeout_table[] = {
889         {
890                 /* Dell Vostro V13 */
891                 .matches = {
892                         DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
893                         DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V13"),
894                 },
895         },
896         {
897                 /* Newer HP Pavilion dv4 models */
898                 .matches = {
899                         DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
900                         DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"),
901                 },
902         },
903         {
904                 /* Fujitsu A544 laptop */
905                 /* https://bugzilla.redhat.com/show_bug.cgi?id=1111138 */
906                 .matches = {
907                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
908                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK A544"),
909                 },
910         },
911         {
912                 /* Fujitsu AH544 laptop */
913                 /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
914                 .matches = {
915                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
916                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK AH544"),
917                 },
918         },
919         {
920                 /* Fujitsu U574 laptop */
921                 /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
922                 .matches = {
923                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
924                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U574"),
925                 },
926         },
927         {
928                 /* Fujitsu UH554 laptop */
929                 .matches = {
930                         DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
931                         DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK UH544"),
932                 },
933         },
934         { }
935 };
936
937 /*
938  * Some Wistron based laptops need us to explicitly enable the 'Dritek
939  * keyboard extension' to make their extra keys start generating scancodes.
940  * Originally, this was just confined to older laptops, but a few Acer laptops
941  * have turned up in 2007 that also need this again.
942  */
943 static const struct dmi_system_id __initconst i8042_dmi_dritek_table[] = {
944         {
945                 /* Acer Aspire 5100 */
946                 .matches = {
947                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
948                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"),
949                 },
950         },
951         {
952                 /* Acer Aspire 5610 */
953                 .matches = {
954                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
955                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"),
956                 },
957         },
958         {
959                 /* Acer Aspire 5630 */
960                 .matches = {
961                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
962                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5630"),
963                 },
964         },
965         {
966                 /* Acer Aspire 5650 */
967                 .matches = {
968                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
969                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"),
970                 },
971         },
972         {
973                 /* Acer Aspire 5680 */
974                 .matches = {
975                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
976                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"),
977                 },
978         },
979         {
980                 /* Acer Aspire 5720 */
981                 .matches = {
982                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
983                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5720"),
984                 },
985         },
986         {
987                 /* Acer Aspire 9110 */
988                 .matches = {
989                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
990                         DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 9110"),
991                 },
992         },
993         {
994                 /* Acer TravelMate 660 */
995                 .matches = {
996                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
997                         DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 660"),
998                 },
999         },
1000         {
1001                 /* Acer TravelMate 2490 */
1002                 .matches = {
1003                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1004                         DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
1005                 },
1006         },
1007         {
1008                 /* Acer TravelMate 4280 */
1009                 .matches = {
1010                         DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1011                         DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4280"),
1012                 },
1013         },
1014         { }
1015 };
1016
1017 /*
1018  * Some laptops need keyboard reset before probing for the trackpad to get
1019  * it detected, initialised & finally work.
1020  */
1021 static const struct dmi_system_id __initconst i8042_dmi_kbdreset_table[] = {
1022         {
1023                 /* Gigabyte P35 v2 - Elantech touchpad */
1024                 .matches = {
1025                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
1026                         DMI_MATCH(DMI_PRODUCT_NAME, "P35V2"),
1027                 },
1028         },
1029                 {
1030                 /* Aorus branded Gigabyte X3 Plus - Elantech touchpad */
1031                 .matches = {
1032                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
1033                         DMI_MATCH(DMI_PRODUCT_NAME, "X3"),
1034                 },
1035         },
1036         {
1037                 /* Gigabyte P34 - Elantech touchpad */
1038                 .matches = {
1039                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
1040                         DMI_MATCH(DMI_PRODUCT_NAME, "P34"),
1041                 },
1042         },
1043         {
1044                 /* Gigabyte P57 - Elantech touchpad */
1045                 .matches = {
1046                         DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
1047                         DMI_MATCH(DMI_PRODUCT_NAME, "P57"),
1048                 },
1049         },
1050         {
1051                 /* Schenker XMG C504 - Elantech touchpad */
1052                 .matches = {
1053                         DMI_MATCH(DMI_SYS_VENDOR, "XMG"),
1054                         DMI_MATCH(DMI_PRODUCT_NAME, "C504"),
1055                 },
1056         },
1057         { }
1058 };
1059
1060 #endif /* CONFIG_X86 */
1061
1062 #ifdef CONFIG_PNP
1063 #include <linux/pnp.h>
1064
1065 static bool i8042_pnp_kbd_registered;
1066 static unsigned int i8042_pnp_kbd_devices;
1067 static bool i8042_pnp_aux_registered;
1068 static unsigned int i8042_pnp_aux_devices;
1069
1070 static int i8042_pnp_command_reg;
1071 static int i8042_pnp_data_reg;
1072 static int i8042_pnp_kbd_irq;
1073 static int i8042_pnp_aux_irq;
1074
1075 static char i8042_pnp_kbd_name[32];
1076 static char i8042_pnp_aux_name[32];
1077
1078 static void i8042_pnp_id_to_string(struct pnp_id *id, char *dst, int dst_size)
1079 {
1080         strlcpy(dst, "PNP:", dst_size);
1081
1082         while (id) {
1083                 strlcat(dst, " ", dst_size);
1084                 strlcat(dst, id->id, dst_size);
1085                 id = id->next;
1086         }
1087 }
1088
1089 static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
1090 {
1091         if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
1092                 i8042_pnp_data_reg = pnp_port_start(dev,0);
1093
1094         if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
1095                 i8042_pnp_command_reg = pnp_port_start(dev, 1);
1096
1097         if (pnp_irq_valid(dev,0))
1098                 i8042_pnp_kbd_irq = pnp_irq(dev, 0);
1099
1100         strlcpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
1101         if (strlen(pnp_dev_name(dev))) {
1102                 strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
1103                 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
1104         }
1105         i8042_pnp_id_to_string(dev->id, i8042_kbd_firmware_id,
1106                                sizeof(i8042_kbd_firmware_id));
1107
1108         /* Keyboard ports are always supposed to be wakeup-enabled */
1109         device_set_wakeup_enable(&dev->dev, true);
1110
1111         i8042_pnp_kbd_devices++;
1112         return 0;
1113 }
1114
1115 static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
1116 {
1117         if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
1118                 i8042_pnp_data_reg = pnp_port_start(dev,0);
1119
1120         if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
1121                 i8042_pnp_command_reg = pnp_port_start(dev, 1);
1122
1123         if (pnp_irq_valid(dev, 0))
1124                 i8042_pnp_aux_irq = pnp_irq(dev, 0);
1125
1126         strlcpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
1127         if (strlen(pnp_dev_name(dev))) {
1128                 strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
1129                 strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
1130         }
1131         i8042_pnp_id_to_string(dev->id, i8042_aux_firmware_id,
1132                                sizeof(i8042_aux_firmware_id));
1133
1134         i8042_pnp_aux_devices++;
1135         return 0;
1136 }
1137
1138 static struct pnp_device_id pnp_kbd_devids[] = {
1139         { .id = "PNP0300", .driver_data = 0 },
1140         { .id = "PNP0301", .driver_data = 0 },
1141         { .id = "PNP0302", .driver_data = 0 },
1142         { .id = "PNP0303", .driver_data = 0 },
1143         { .id = "PNP0304", .driver_data = 0 },
1144         { .id = "PNP0305", .driver_data = 0 },
1145         { .id = "PNP0306", .driver_data = 0 },
1146         { .id = "PNP0309", .driver_data = 0 },
1147         { .id = "PNP030a", .driver_data = 0 },
1148         { .id = "PNP030b", .driver_data = 0 },
1149         { .id = "PNP0320", .driver_data = 0 },
1150         { .id = "PNP0343", .driver_data = 0 },
1151         { .id = "PNP0344", .driver_data = 0 },
1152         { .id = "PNP0345", .driver_data = 0 },
1153         { .id = "CPQA0D7", .driver_data = 0 },
1154         { .id = "", },
1155 };
1156 MODULE_DEVICE_TABLE(pnp, pnp_kbd_devids);
1157
1158 static struct pnp_driver i8042_pnp_kbd_driver = {
1159         .name           = "i8042 kbd",
1160         .id_table       = pnp_kbd_devids,
1161         .probe          = i8042_pnp_kbd_probe,
1162 };
1163
1164 static struct pnp_device_id pnp_aux_devids[] = {
1165         { .id = "AUI0200", .driver_data = 0 },
1166         { .id = "FJC6000", .driver_data = 0 },
1167         { .id = "FJC6001", .driver_data = 0 },
1168         { .id = "PNP0f03", .driver_data = 0 },
1169         { .id = "PNP0f0b", .driver_data = 0 },
1170         { .id = "PNP0f0e", .driver_data = 0 },
1171         { .id = "PNP0f12", .driver_data = 0 },
1172         { .id = "PNP0f13", .driver_data = 0 },
1173         { .id = "PNP0f19", .driver_data = 0 },
1174         { .id = "PNP0f1c", .driver_data = 0 },
1175         { .id = "SYN0801", .driver_data = 0 },
1176         { .id = "", },
1177 };
1178 MODULE_DEVICE_TABLE(pnp, pnp_aux_devids);
1179
1180 static struct pnp_driver i8042_pnp_aux_driver = {
1181         .name           = "i8042 aux",
1182         .id_table       = pnp_aux_devids,
1183         .probe          = i8042_pnp_aux_probe,
1184 };
1185
1186 static void i8042_pnp_exit(void)
1187 {
1188         if (i8042_pnp_kbd_registered) {
1189                 i8042_pnp_kbd_registered = false;
1190                 pnp_unregister_driver(&i8042_pnp_kbd_driver);
1191         }
1192
1193         if (i8042_pnp_aux_registered) {
1194                 i8042_pnp_aux_registered = false;
1195                 pnp_unregister_driver(&i8042_pnp_aux_driver);
1196         }
1197 }
1198
1199 static int __init i8042_pnp_init(void)
1200 {
1201         char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
1202         bool pnp_data_busted = false;
1203         int err;
1204
1205 #ifdef CONFIG_X86
1206         if (dmi_check_system(i8042_dmi_nopnp_table))
1207                 i8042_nopnp = true;
1208 #endif
1209
1210         if (i8042_nopnp) {
1211                 pr_info("PNP detection disabled\n");
1212                 return 0;
1213         }
1214
1215         err = pnp_register_driver(&i8042_pnp_kbd_driver);
1216         if (!err)
1217                 i8042_pnp_kbd_registered = true;
1218
1219         err = pnp_register_driver(&i8042_pnp_aux_driver);
1220         if (!err)
1221                 i8042_pnp_aux_registered = true;
1222
1223         if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
1224                 i8042_pnp_exit();
1225 #if defined(__ia64__)
1226                 return -ENODEV;
1227 #else
1228                 pr_info("PNP: No PS/2 controller found. Probing ports directly.\n");
1229                 return 0;
1230 #endif
1231         }
1232
1233         if (i8042_pnp_kbd_devices)
1234                 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
1235                         "%d", i8042_pnp_kbd_irq);
1236         if (i8042_pnp_aux_devices)
1237                 snprintf(aux_irq_str, sizeof(aux_irq_str),
1238                         "%d", i8042_pnp_aux_irq);
1239
1240         pr_info("PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
1241                 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
1242                 i8042_pnp_aux_name,
1243                 i8042_pnp_data_reg, i8042_pnp_command_reg,
1244                 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
1245                 aux_irq_str);
1246
1247 #if defined(__ia64__)
1248         if (!i8042_pnp_kbd_devices)
1249                 i8042_nokbd = true;
1250         if (!i8042_pnp_aux_devices)
1251                 i8042_noaux = true;
1252 #endif
1253
1254         if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
1255               i8042_pnp_data_reg != i8042_data_reg) ||
1256             !i8042_pnp_data_reg) {
1257                 pr_warn("PNP: PS/2 controller has invalid data port %#x; using default %#x\n",
1258                         i8042_pnp_data_reg, i8042_data_reg);
1259                 i8042_pnp_data_reg = i8042_data_reg;
1260                 pnp_data_busted = true;
1261         }
1262
1263         if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
1264               i8042_pnp_command_reg != i8042_command_reg) ||
1265             !i8042_pnp_command_reg) {
1266                 pr_warn("PNP: PS/2 controller has invalid command port %#x; using default %#x\n",
1267                         i8042_pnp_command_reg, i8042_command_reg);
1268                 i8042_pnp_command_reg = i8042_command_reg;
1269                 pnp_data_busted = true;
1270         }
1271
1272         if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
1273                 pr_warn("PNP: PS/2 controller doesn't have KBD irq; using default %d\n",
1274                         i8042_kbd_irq);
1275                 i8042_pnp_kbd_irq = i8042_kbd_irq;
1276                 pnp_data_busted = true;
1277         }
1278
1279         if (!i8042_noaux && !i8042_pnp_aux_irq) {
1280                 if (!pnp_data_busted && i8042_pnp_kbd_irq) {
1281                         pr_warn("PNP: PS/2 appears to have AUX port disabled, "
1282                                 "if this is incorrect please boot with i8042.nopnp\n");
1283                         i8042_noaux = true;
1284                 } else {
1285                         pr_warn("PNP: PS/2 controller doesn't have AUX irq; using default %d\n",
1286                                 i8042_aux_irq);
1287                         i8042_pnp_aux_irq = i8042_aux_irq;
1288                 }
1289         }
1290
1291         i8042_data_reg = i8042_pnp_data_reg;
1292         i8042_command_reg = i8042_pnp_command_reg;
1293         i8042_kbd_irq = i8042_pnp_kbd_irq;
1294         i8042_aux_irq = i8042_pnp_aux_irq;
1295
1296 #ifdef CONFIG_X86
1297         i8042_bypass_aux_irq_test = !pnp_data_busted &&
1298                                     dmi_check_system(i8042_dmi_laptop_table);
1299 #endif
1300
1301         return 0;
1302 }
1303
1304 #else
1305 static inline int i8042_pnp_init(void) { return 0; }
1306 static inline void i8042_pnp_exit(void) { }
1307 #endif
1308
1309 static int __init i8042_platform_init(void)
1310 {
1311         int retval;
1312
1313 #ifdef CONFIG_X86
1314         u8 a20_on = 0xdf;
1315         /* Just return if pre-detection shows no i8042 controller exist */
1316         if (!x86_platform.i8042_detect())
1317                 return -ENODEV;
1318 #endif
1319
1320 /*
1321  * On ix86 platforms touching the i8042 data register region can do really
1322  * bad things. Because of this the region is always reserved on ix86 boxes.
1323  *
1324  *      if (!request_region(I8042_DATA_REG, 16, "i8042"))
1325  *              return -EBUSY;
1326  */
1327
1328         i8042_kbd_irq = I8042_MAP_IRQ(1);
1329         i8042_aux_irq = I8042_MAP_IRQ(12);
1330
1331         retval = i8042_pnp_init();
1332         if (retval)
1333                 return retval;
1334
1335 #if defined(__ia64__)
1336         i8042_reset = I8042_RESET_ALWAYS;
1337 #endif
1338
1339 #ifdef CONFIG_X86
1340         /* Honor module parameter when value is not default */
1341         if (i8042_reset == I8042_RESET_DEFAULT) {
1342                 if (dmi_check_system(i8042_dmi_reset_table))
1343                         i8042_reset = I8042_RESET_ALWAYS;
1344
1345                 if (dmi_check_system(i8042_dmi_noselftest_table))
1346                         i8042_reset = I8042_RESET_NEVER;
1347         }
1348
1349         if (dmi_check_system(i8042_dmi_noloop_table))
1350                 i8042_noloop = true;
1351
1352         if (dmi_check_system(i8042_dmi_nomux_table))
1353                 i8042_nomux = true;
1354
1355         if (dmi_check_system(i8042_dmi_forcemux_table))
1356                 i8042_nomux = false;
1357
1358         if (dmi_check_system(i8042_dmi_notimeout_table))
1359                 i8042_notimeout = true;
1360
1361         if (dmi_check_system(i8042_dmi_dritek_table))
1362                 i8042_dritek = true;
1363
1364         if (dmi_check_system(i8042_dmi_kbdreset_table))
1365                 i8042_kbdreset = true;
1366
1367         /*
1368          * A20 was already enabled during early kernel init. But some buggy
1369          * BIOSes (in MSI Laptops) require A20 to be enabled using 8042 to
1370          * resume from S3. So we do it here and hope that nothing breaks.
1371          */
1372         i8042_command(&a20_on, 0x10d1);
1373         i8042_command(NULL, 0x00ff);    /* Null command for SMM firmware */
1374 #endif /* CONFIG_X86 */
1375
1376         return retval;
1377 }
1378
1379 static inline void i8042_platform_exit(void)
1380 {
1381         i8042_pnp_exit();
1382 }
1383
1384 #endif /* _I8042_X86IA64IO_H */