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