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