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